From nobody Mon Oct 6 06:47:32 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E35172EA494 for ; Thu, 24 Jul 2025 15:22:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753370575; cv=none; b=u/uSPIk7CgGd2WzoBqJQtzDWGDVGWtXvJq32XJqCFGDojcWU8sFbDvHLmjSYf25Mx5J1O8VyvTEPYI8RqopjOrO2p/u//SDQdOMfbaJuiDvgJLr8t94x5GvZjA0+kJch3GC0eSNjnPXfUEJYUd4S4JHyhEQB23BloqnEI4qeKTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753370575; c=relaxed/simple; bh=gL18oifQaqU0//jNBxoRSHnI+sM1548EENL0MomrCR0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N7ZC6k1xJg+vlpgsW9ZVCWsa/e6mel+3Qbj/rFfj7B8BbzUHR5eMA8tRylDUmJVDXdiax706cFC78R2GNDFU6gX19SsqzB24GeGM8RmXMypggMGsjwSgZh0G+kbYibjiM2wrH39wL9RYeJQSg8UvDtvBQd1h7EujnnsJw0VvgbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0B9581CC4; Thu, 24 Jul 2025 08:22:47 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DD0723F6A8; Thu, 24 Jul 2025 08:22:51 -0700 (PDT) From: Leo Yan Date: Thu, 24 Jul 2025 16:22:33 +0100 Subject: [PATCH v5 03/10] coresight: etm4x: Support atclk Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250724-arm_cs_fix_clock_v4-v5-3-63f648dae021@arm.com> References: <20250724-arm_cs_fix_clock_v4-v5-0-63f648dae021@arm.com> In-Reply-To: <20250724-arm_cs_fix_clock_v4-v5-0-63f648dae021@arm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Anshuman Khandual , Yeoreum Yun , Alexander Shishkin , Greg Kroah-Hartman Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1753370566; l=3478; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=gL18oifQaqU0//jNBxoRSHnI+sM1548EENL0MomrCR0=; b=IiXDUUFwrC020umpsBKxG8LnH0BrxtLpPZVQlXbgPS0gSb00IUSGj2i99zwGDrbPGgyMghLCa bCPVid4Uuk6AwY2XtH7zCM+EBYCAOH1WAYG7Ng6LLpTyaFJBN1AmbqR X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= The atclk is an optional clock for the CoreSight ETMv4, but the driver misses to initialize it. This change enables atclk in probe of the ETMv4 driver, and dynamically control the clock during suspend and resume. No need to check the driver data and clock pointer in the runtime suspend and resume, so remove checks. And add error handling in the resume function. Add a minor fix to the comment format when adding the atclk field. Fixes: 2e1cdfe184b5 ("coresight-etm4x: Adding CoreSight ETM4x driver") Reviewed-by: Anshuman Khandual Reviewed-by: Yeoreum Yun Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-etm4x-core.c | 20 +++++++++++++++---= -- drivers/hwtracing/coresight/coresight-etm4x.h | 4 +++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index cbea200489c8f3676d08c6bc6334ecd71d2569ca..36cbf60f24f1e86b466c9c216d3= 3c74393f65504 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -2216,6 +2216,10 @@ static int etm4_probe(struct device *dev) if (WARN_ON(!drvdata)) return -ENOMEM; =20 + drvdata->atclk =3D devm_clk_get_optional_enabled(dev, "atclk"); + if (IS_ERR(drvdata->atclk)) + return PTR_ERR(drvdata->atclk); + if (pm_save_enable =3D=3D PARAM_PM_SAVE_FIRMWARE) pm_save_enable =3D coresight_loses_context_with_cpu(dev) ? PARAM_PM_SAVE_SELF_HOSTED : PARAM_PM_SAVE_NEVER; @@ -2464,8 +2468,8 @@ static int etm4_runtime_suspend(struct device *dev) { struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev); =20 - if (drvdata->pclk && !IS_ERR(drvdata->pclk)) - clk_disable_unprepare(drvdata->pclk); + clk_disable_unprepare(drvdata->atclk); + clk_disable_unprepare(drvdata->pclk); =20 return 0; } @@ -2473,11 +2477,17 @@ static int etm4_runtime_suspend(struct device *dev) static int etm4_runtime_resume(struct device *dev) { struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev); + int ret; + + ret =3D clk_prepare_enable(drvdata->pclk); + if (ret) + return ret; =20 - if (drvdata->pclk && !IS_ERR(drvdata->pclk)) - clk_prepare_enable(drvdata->pclk); + ret =3D clk_prepare_enable(drvdata->atclk); + if (ret) + clk_disable_unprepare(drvdata->pclk); =20 - return 0; + return ret; } #endif =20 diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtrac= ing/coresight/coresight-etm4x.h index ac649515054d905fa365203bd35f1d839b03292f..96c14ec26893a489a96c7acfe9b= a308e0e890917 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -919,7 +919,8 @@ struct etmv4_save_state { =20 /** * struct etm4_drvdata - specifics associated to an ETM component - * @pclk APB clock if present, otherwise NULL + * @pclk: APB clock if present, otherwise NULL + * @atclk: Optional clock for the core parts of the ETMv4. * @base: Memory mapped base address for this component. * @csdev: Component vitals needed by the framework. * @spinlock: Only one at a time pls. @@ -988,6 +989,7 @@ struct etmv4_save_state { */ struct etmv4_drvdata { struct clk *pclk; + struct clk *atclk; void __iomem *base; struct coresight_device *csdev; raw_spinlock_t spinlock; --=20 2.34.1