linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 00/10] coresight: Fix and improve clock usage
@ 2025-07-24 15:22 Leo Yan
  2025-07-24 15:22 ` [PATCH v5 01/10] coresight: tmc: Support atclk Leo Yan
                   ` (11 more replies)
  0 siblings, 12 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-24 15:22 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman
  Cc: coresight, linux-arm-kernel, linux-kernel, Leo Yan

This series fixes and improves clock usage in the Arm CoreSight drivers.

Based on the DT binding documents, the trace clock (atclk) is defined in
some CoreSight modules, but support is absent. In most cases, the issue
is hidden because the atclk clock is shared by multiple CoreSight
modules and the clock is enabled anyway by other drivers. The first
three patches address this issue.

The programming clock (pclk) management in CoreSight drivers does not
use the devm_XXX() variant APIs, the drivers needs to manually disable
and release clocks for errors and for normal module exit.  However, the
drivers miss to disable clocks during module exit. The atclk may also
not be disabled in CoreSight drivers during module exit. By using devm
APIs, patches 04 and 05 fix clock disabling issues.

Another issue is pclk might be enabled twice in init phase - once by
AMBA bus driver, and again by CoreSight drivers. This is fixed in
patch 06.

Patches 07 to 10 refactor the clock related code. Patch 07 consolidates
the clock initialization into a central place. Patch 08 polishes driver
data allocation. Patch 09 makes the clock enabling sequence consistent.
Patch 09 removes redundant condition checks and adds error handling in
runtime PM.

This series has been verified on Arm64 Juno platform, for both DT and
ACPI modes.

---
Changes in v5:
- Skip clock management for ACPI devices (Suzuki).
- Link to v4: https://lore.kernel.org/r/20250627-arm_cs_fix_clock_v4-v4-0-0ce0009c38f8@arm.com

Changes in v4:
- Separated patch 07 into two patches, one is for clock consolidation
  and another is for polishing driver data allocation (Anshuman).

Changes in v3:
- Updated subjects for patches 04 and 05 (Anshuman).
- Refined condition checking "if (dev_is_amba(dev))" in patch 07
  (Anshuman).

---
Leo Yan (10):
      coresight: tmc: Support atclk
      coresight: catu: Support atclk
      coresight: etm4x: Support atclk
      coresight: Appropriately disable programming clocks
      coresight: Appropriately disable trace bus clocks
      coresight: Avoid enable programming clock duplicately
      coresight: Consolidate clock enabling
      coresight: Refactor driver data allocation
      coresight: Make clock sequence consistent
      coresight: Refactor runtime PM

 drivers/hwtracing/coresight/coresight-catu.c       | 53 ++++++++---------
 drivers/hwtracing/coresight/coresight-catu.h       |  1 +
 drivers/hwtracing/coresight/coresight-core.c       | 48 ++++++++++++++++
 drivers/hwtracing/coresight/coresight-cpu-debug.c  | 41 +++++---------
 drivers/hwtracing/coresight/coresight-ctcu-core.c  | 24 +++-----
 drivers/hwtracing/coresight/coresight-etb10.c      | 18 ++----
 drivers/hwtracing/coresight/coresight-etm3x-core.c | 17 ++----
 drivers/hwtracing/coresight/coresight-etm4x-core.c | 32 ++++++-----
 drivers/hwtracing/coresight/coresight-etm4x.h      |  4 +-
 drivers/hwtracing/coresight/coresight-funnel.c     | 66 ++++++++--------------
 drivers/hwtracing/coresight/coresight-replicator.c | 63 ++++++++-------------
 drivers/hwtracing/coresight/coresight-stm.c        | 34 +++++------
 drivers/hwtracing/coresight/coresight-tmc-core.c   | 48 ++++++++--------
 drivers/hwtracing/coresight/coresight-tmc.h        |  2 +
 drivers/hwtracing/coresight/coresight-tpiu.c       | 36 +++++-------
 include/linux/coresight.h                          | 31 +---------
 16 files changed, 228 insertions(+), 290 deletions(-)
---
base-commit: a80198ba650f50d266d7fc4a6c5262df9970f9f2
change-id: 20250627-arm_cs_fix_clock_v4-e24b1e1f8920

Best regards,
-- 
Leo Yan <leo.yan@arm.com>



^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v5 01/10] coresight: tmc: Support atclk
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
@ 2025-07-24 15:22 ` Leo Yan
  2025-07-24 15:22 ` [PATCH v5 02/10] coresight: catu: " Leo Yan
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-24 15:22 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman
  Cc: coresight, linux-arm-kernel, linux-kernel, Leo Yan

The atclk is an optional clock for the CoreSight TMC, but the driver
misses to initialize it.  In most cases, TMC shares the atclk clock with
other CoreSight components.  Since these components enable the clock
before the TMC device is initialized, the TMC continues properly,
which is why we don’t observe any lockup issues.

This change enables atclk in probe of the TMC driver.  Given the clock
is optional, it is possible to return NULL if the clock does not exist.
IS_ERR() is tolerant for this case.

Dynamically disable and enable atclk during suspend and resume.  The
clock pointers will never be error values if the driver has successfully
probed, and the case of a NULL pointer case will be handled by the clock
core layer.  The driver data is always valid after probe. Therefore,
remove the related checks.  Also in the resume flow adds error handling.

Fixes: bc4bf7fe98da ("coresight-tmc: add CoreSight TMC driver")
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 drivers/hwtracing/coresight/coresight-tmc-core.c | 22 +++++++++++++++++-----
 drivers/hwtracing/coresight/coresight-tmc.h      |  2 ++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
index be964656be9335f1b74277ba4e012ab8d6ed1785..85ba037c27f7b18fd4aed2447129f15316e635d5 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-core.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
@@ -779,6 +779,10 @@ static int __tmc_probe(struct device *dev, struct resource *res)
 	struct coresight_desc desc = { 0 };
 	struct coresight_dev_list *dev_list = NULL;
 
+	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
+	if (IS_ERR(drvdata->atclk))
+		return PTR_ERR(drvdata->atclk);
+
 	ret = -ENOMEM;
 
 	/* Validity for the resource is already checked by the AMBA core */
@@ -1010,18 +1014,26 @@ static int tmc_runtime_suspend(struct device *dev)
 {
 	struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_disable_unprepare(drvdata->pclk);
+	clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->pclk);
+
 	return 0;
 }
 
 static int tmc_runtime_resume(struct device *dev)
 {
 	struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
+	int ret;
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_prepare_enable(drvdata->pclk);
-	return 0;
+	ret = clk_prepare_enable(drvdata->pclk);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(drvdata->atclk);
+	if (ret)
+		clk_disable_unprepare(drvdata->pclk);
+
+	return ret;
 }
 #endif
 
diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h
index 6541a27a018e6c3da8685e2e1c93b228d44e66fc..cbb4ba43915855a8acbb9205167e87185c9a8c6c 100644
--- a/drivers/hwtracing/coresight/coresight-tmc.h
+++ b/drivers/hwtracing/coresight/coresight-tmc.h
@@ -210,6 +210,7 @@ struct tmc_resrv_buf {
 
 /**
  * struct tmc_drvdata - specifics associated to an TMC component
+ * @atclk:	optional clock for the core parts of the TMC.
  * @pclk:	APB clock if present, otherwise NULL
  * @base:	memory mapped base address for this component.
  * @csdev:	component vitals needed by the framework.
@@ -244,6 +245,7 @@ struct tmc_resrv_buf {
  *		 Used by ETR/ETF.
  */
 struct tmc_drvdata {
+	struct clk		*atclk;
 	struct clk		*pclk;
 	void __iomem		*base;
 	struct coresight_device	*csdev;

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v5 02/10] coresight: catu: Support atclk
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
  2025-07-24 15:22 ` [PATCH v5 01/10] coresight: tmc: Support atclk Leo Yan
@ 2025-07-24 15:22 ` Leo Yan
  2025-07-24 15:22 ` [PATCH v5 03/10] coresight: etm4x: " Leo Yan
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-24 15:22 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman
  Cc: coresight, linux-arm-kernel, linux-kernel, Leo Yan

The atclk is an optional clock for the CoreSight CATU, but the driver
misses to initialize it.

This change enables atclk in probe of the CATU driver, and dynamically
control the clock during suspend and resume.

The checks for driver data and clocks in suspend and resume are not
needed, remove them.  Add error handling in the resume function.

Fixes: fcacb5c154ba ("coresight: Introduce support for Coresight Address Translation Unit")
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 drivers/hwtracing/coresight/coresight-catu.c | 22 +++++++++++++++++-----
 drivers/hwtracing/coresight/coresight-catu.h |  1 +
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
index 5058432233da1932f1965008fc1b98b560490414..af2a55f0c907c392d092a50612b23c115a1b0f5f 100644
--- a/drivers/hwtracing/coresight/coresight-catu.c
+++ b/drivers/hwtracing/coresight/coresight-catu.c
@@ -520,6 +520,10 @@ static int __catu_probe(struct device *dev, struct resource *res)
 	struct coresight_platform_data *pdata = NULL;
 	void __iomem *base;
 
+	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
+	if (IS_ERR(drvdata->atclk))
+		return PTR_ERR(drvdata->atclk);
+
 	catu_desc.name = coresight_alloc_device_name(&catu_devs, dev);
 	if (!catu_desc.name)
 		return -ENOMEM;
@@ -668,18 +672,26 @@ static int catu_runtime_suspend(struct device *dev)
 {
 	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_disable_unprepare(drvdata->pclk);
+	clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->pclk);
+
 	return 0;
 }
 
 static int catu_runtime_resume(struct device *dev)
 {
 	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
+	int ret;
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_prepare_enable(drvdata->pclk);
-	return 0;
+	ret = clk_prepare_enable(drvdata->pclk);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(drvdata->atclk);
+	if (ret)
+		clk_disable_unprepare(drvdata->pclk);
+
+	return ret;
 }
 #endif
 
diff --git a/drivers/hwtracing/coresight/coresight-catu.h b/drivers/hwtracing/coresight/coresight-catu.h
index 755776cd19c5bb724845ca586ace1e0b29e72556..6e6b7aac206dcae9ff062355e50179637b4d1703 100644
--- a/drivers/hwtracing/coresight/coresight-catu.h
+++ b/drivers/hwtracing/coresight/coresight-catu.h
@@ -62,6 +62,7 @@
 
 struct catu_drvdata {
 	struct clk *pclk;
+	struct clk *atclk;
 	void __iomem *base;
 	struct coresight_device *csdev;
 	int irq;

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v5 03/10] coresight: etm4x: Support atclk
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
  2025-07-24 15:22 ` [PATCH v5 01/10] coresight: tmc: Support atclk Leo Yan
  2025-07-24 15:22 ` [PATCH v5 02/10] coresight: catu: " Leo Yan
@ 2025-07-24 15:22 ` Leo Yan
  2025-07-24 15:22 ` [PATCH v5 04/10] coresight: Appropriately disable programming clocks Leo Yan
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-24 15:22 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman
  Cc: coresight, linux-arm-kernel, linux-kernel, Leo Yan

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 <anshuman.khandual@arm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 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/hwtracing/coresight/coresight-etm4x-core.c
index cbea200489c8f3676d08c6bc6334ecd71d2569ca..36cbf60f24f1e86b466c9c216d33c74393f65504 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;
 
+	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
+	if (IS_ERR(drvdata->atclk))
+		return PTR_ERR(drvdata->atclk);
+
 	if (pm_save_enable == PARAM_PM_SAVE_FIRMWARE)
 		pm_save_enable = 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 = dev_get_drvdata(dev);
 
-	if (drvdata->pclk && !IS_ERR(drvdata->pclk))
-		clk_disable_unprepare(drvdata->pclk);
+	clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->pclk);
 
 	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 = dev_get_drvdata(dev);
+	int ret;
+
+	ret = clk_prepare_enable(drvdata->pclk);
+	if (ret)
+		return ret;
 
-	if (drvdata->pclk && !IS_ERR(drvdata->pclk))
-		clk_prepare_enable(drvdata->pclk);
+	ret = clk_prepare_enable(drvdata->atclk);
+	if (ret)
+		clk_disable_unprepare(drvdata->pclk);
 
-	return 0;
+	return ret;
 }
 #endif
 
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h
index ac649515054d905fa365203bd35f1d839b03292f..96c14ec26893a489a96c7acfe9ba308e0e890917 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.h
+++ b/drivers/hwtracing/coresight/coresight-etm4x.h
@@ -919,7 +919,8 @@ struct etmv4_save_state {
 
 /**
  * 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;

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v5 04/10] coresight: Appropriately disable programming clocks
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
                   ` (2 preceding siblings ...)
  2025-07-24 15:22 ` [PATCH v5 03/10] coresight: etm4x: " Leo Yan
@ 2025-07-24 15:22 ` Leo Yan
  2025-07-28 16:18   ` Mark Brown
  2025-07-28 16:44   ` Mark Brown
  2025-07-24 15:22 ` [PATCH v5 05/10] coresight: Appropriately disable trace bus clocks Leo Yan
                   ` (7 subsequent siblings)
  11 siblings, 2 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-24 15:22 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman
  Cc: coresight, linux-arm-kernel, linux-kernel, Leo Yan

Some CoreSight components have programming clocks (pclk) and are enabled
using clk_get() and clk_prepare_enable().  However, in many cases, these
clocks are not disabled when modules exit and only released by clk_put().

To fix the issue, this commit refactors coresight_get_enable_apb_pclk()
by replacing clk_get() and clk_prepare_enable() with
devm_clk_get_enabled() for enabling APB clock.  Callers are updated
to reuse the returned error value.

Since ACPI platforms rely on firmware to manage clocks, returning a NULL
pointer in this case leaves clock management to the firmware rather than
the driver. This effectively avoids a clock imbalance issue during
module removal - where the clock could be disabled twice: once during
the ACPI runtime suspend and again during the devm resource release.

With the change, programming clocks are managed as resources in driver
model layer, allowing clock cleanup to be handled automatically.  As a
result, manual cleanup operations are no longer needed and are removed
from the Coresight drivers.

Fixes: 73d779a03a76 ("coresight: etm4x: Change etm4_platform_driver driver for MMIO devices")
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 drivers/hwtracing/coresight/coresight-catu.c       |  9 ++-------
 drivers/hwtracing/coresight/coresight-cpu-debug.c  |  6 +-----
 drivers/hwtracing/coresight/coresight-ctcu-core.c  | 10 ++--------
 drivers/hwtracing/coresight/coresight-etm4x-core.c |  9 ++-------
 drivers/hwtracing/coresight/coresight-funnel.c     |  6 +-----
 drivers/hwtracing/coresight/coresight-replicator.c |  6 +-----
 drivers/hwtracing/coresight/coresight-stm.c        |  4 +---
 drivers/hwtracing/coresight/coresight-tmc-core.c   |  4 +---
 drivers/hwtracing/coresight/coresight-tpiu.c       |  4 +---
 include/linux/coresight.h                          | 22 +++++++++-------------
 10 files changed, 21 insertions(+), 59 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
index af2a55f0c907c392d092a50612b23c115a1b0f5f..4c345ff2cff141ea63c2220393e5fdd00c449ca6 100644
--- a/drivers/hwtracing/coresight/coresight-catu.c
+++ b/drivers/hwtracing/coresight/coresight-catu.c
@@ -636,7 +636,7 @@ static int catu_platform_probe(struct platform_device *pdev)
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
 	if (IS_ERR(drvdata->pclk))
-		return -ENODEV;
+		return PTR_ERR(drvdata->pclk);
 
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
@@ -645,11 +645,8 @@ static int catu_platform_probe(struct platform_device *pdev)
 	dev_set_drvdata(&pdev->dev, drvdata);
 	ret = __catu_probe(&pdev->dev, res);
 	pm_runtime_put(&pdev->dev);
-	if (ret) {
+	if (ret)
 		pm_runtime_disable(&pdev->dev);
-		if (!IS_ERR_OR_NULL(drvdata->pclk))
-			clk_put(drvdata->pclk);
-	}
 
 	return ret;
 }
@@ -663,8 +660,6 @@ static void catu_platform_remove(struct platform_device *pdev)
 
 	__catu_remove(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	if (!IS_ERR_OR_NULL(drvdata->pclk))
-		clk_put(drvdata->pclk);
 }
 
 #ifdef CONFIG_PM
diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index a871d997330b09bdb741f35c59108b0b3252cc54..e39dfb886688e111eee95d4294f37fa85baccd14 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -699,7 +699,7 @@ static int debug_platform_probe(struct platform_device *pdev)
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
 	if (IS_ERR(drvdata->pclk))
-		return -ENODEV;
+		return PTR_ERR(drvdata->pclk);
 
 	dev_set_drvdata(&pdev->dev, drvdata);
 	pm_runtime_get_noresume(&pdev->dev);
@@ -710,8 +710,6 @@ static int debug_platform_probe(struct platform_device *pdev)
 	if (ret) {
 		pm_runtime_put_noidle(&pdev->dev);
 		pm_runtime_disable(&pdev->dev);
-		if (!IS_ERR_OR_NULL(drvdata->pclk))
-			clk_put(drvdata->pclk);
 	}
 	return ret;
 }
@@ -725,8 +723,6 @@ static void debug_platform_remove(struct platform_device *pdev)
 
 	__debug_remove(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	if (!IS_ERR_OR_NULL(drvdata->pclk))
-		clk_put(drvdata->pclk);
 }
 
 #ifdef CONFIG_ACPI
diff --git a/drivers/hwtracing/coresight/coresight-ctcu-core.c b/drivers/hwtracing/coresight/coresight-ctcu-core.c
index c6bafc96db963310b5e77a095953c83a172cfc7c..de279efe340581ceabfb9e1cd1e7fe4b5e4f826e 100644
--- a/drivers/hwtracing/coresight/coresight-ctcu-core.c
+++ b/drivers/hwtracing/coresight/coresight-ctcu-core.c
@@ -209,7 +209,7 @@ static int ctcu_probe(struct platform_device *pdev)
 
 	drvdata->apb_clk = coresight_get_enable_apb_pclk(dev);
 	if (IS_ERR(drvdata->apb_clk))
-		return -ENODEV;
+		return PTR_ERR(drvdata->apb_clk);
 
 	cfgs = of_device_get_match_data(dev);
 	if (cfgs) {
@@ -233,12 +233,8 @@ static int ctcu_probe(struct platform_device *pdev)
 	desc.access = CSDEV_ACCESS_IOMEM(base);
 
 	drvdata->csdev = coresight_register(&desc);
-	if (IS_ERR(drvdata->csdev)) {
-		if (!IS_ERR_OR_NULL(drvdata->apb_clk))
-			clk_put(drvdata->apb_clk);
-
+	if (IS_ERR(drvdata->csdev))
 		return PTR_ERR(drvdata->csdev);
-	}
 
 	return 0;
 }
@@ -275,8 +271,6 @@ static void ctcu_platform_remove(struct platform_device *pdev)
 
 	ctcu_remove(pdev);
 	pm_runtime_disable(&pdev->dev);
-	if (!IS_ERR_OR_NULL(drvdata->apb_clk))
-		clk_put(drvdata->apb_clk);
 }
 
 #ifdef CONFIG_PM
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
index 36cbf60f24f1e86b466c9c216d33c74393f65504..1892e1c3e4a1b2389e858abf9cf08a6868ae475e 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
@@ -2304,14 +2304,12 @@ static int etm4_probe_platform_dev(struct platform_device *pdev)
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
 	if (IS_ERR(drvdata->pclk))
-		return -ENODEV;
+		return PTR_ERR(drvdata->pclk);
 
 	if (res) {
 		drvdata->base = devm_ioremap_resource(&pdev->dev, res);
-		if (IS_ERR(drvdata->base)) {
-			clk_put(drvdata->pclk);
+		if (IS_ERR(drvdata->base))
 			return PTR_ERR(drvdata->base);
-		}
 	}
 
 	dev_set_drvdata(&pdev->dev, drvdata);
@@ -2418,9 +2416,6 @@ static void etm4_remove_platform_dev(struct platform_device *pdev)
 	if (drvdata)
 		etm4_remove_dev(drvdata);
 	pm_runtime_disable(&pdev->dev);
-
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_put(drvdata->pclk);
 }
 
 static const struct amba_id etm4_ids[] = {
diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
index b1922dbe9292b02c91ca5730998e59ecdb08fdc7..36fc4e991458c112521c4261d73f3e58e9a3f995 100644
--- a/drivers/hwtracing/coresight/coresight-funnel.c
+++ b/drivers/hwtracing/coresight/coresight-funnel.c
@@ -240,7 +240,7 @@ static int funnel_probe(struct device *dev, struct resource *res)
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
 	if (IS_ERR(drvdata->pclk))
-		return -ENODEV;
+		return PTR_ERR(drvdata->pclk);
 
 	/*
 	 * Map the device base for dynamic-funnel, which has been
@@ -284,8 +284,6 @@ static int funnel_probe(struct device *dev, struct resource *res)
 out_disable_clk:
 	if (ret && !IS_ERR_OR_NULL(drvdata->atclk))
 		clk_disable_unprepare(drvdata->atclk);
-	if (ret && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_disable_unprepare(drvdata->pclk);
 	return ret;
 }
 
@@ -355,8 +353,6 @@ static void funnel_platform_remove(struct platform_device *pdev)
 
 	funnel_remove(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	if (!IS_ERR_OR_NULL(drvdata->pclk))
-		clk_put(drvdata->pclk);
 }
 
 static const struct of_device_id funnel_match[] = {
diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
index 06efd2b01a0f71620eac71166567d14655b58403..6dd24eb10a94b0eb28f4f27afab845227e22b96c 100644
--- a/drivers/hwtracing/coresight/coresight-replicator.c
+++ b/drivers/hwtracing/coresight/coresight-replicator.c
@@ -247,7 +247,7 @@ static int replicator_probe(struct device *dev, struct resource *res)
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
 	if (IS_ERR(drvdata->pclk))
-		return -ENODEV;
+		return PTR_ERR(drvdata->pclk);
 
 	/*
 	 * Map the device base for dynamic-replicator, which has been
@@ -296,8 +296,6 @@ static int replicator_probe(struct device *dev, struct resource *res)
 out_disable_clk:
 	if (ret && !IS_ERR_OR_NULL(drvdata->atclk))
 		clk_disable_unprepare(drvdata->atclk);
-	if (ret && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_disable_unprepare(drvdata->pclk);
 	return ret;
 }
 
@@ -335,8 +333,6 @@ static void replicator_platform_remove(struct platform_device *pdev)
 
 	replicator_remove(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	if (!IS_ERR_OR_NULL(drvdata->pclk))
-		clk_put(drvdata->pclk);
 }
 
 #ifdef CONFIG_PM
diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index 464b0c85c3f7d3519169d62a51e9f8c6281b5358..f2de16e4d3b4cc0fc3fa06654fc7ddd9dee1e302 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -851,7 +851,7 @@ static int __stm_probe(struct device *dev, struct resource *res)
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
 	if (IS_ERR(drvdata->pclk))
-		return -ENODEV;
+		return PTR_ERR(drvdata->pclk);
 	dev_set_drvdata(dev, drvdata);
 
 	base = devm_ioremap_resource(dev, res);
@@ -1033,8 +1033,6 @@ static void stm_platform_remove(struct platform_device *pdev)
 
 	__stm_remove(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	if (!IS_ERR_OR_NULL(drvdata->pclk))
-		clk_put(drvdata->pclk);
 }
 
 #ifdef CONFIG_ACPI
diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
index 85ba037c27f7b18fd4aed2447129f15316e635d5..519f225428070df5c5e6fcf014cd132058f01228 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-core.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
@@ -981,7 +981,7 @@ static int tmc_platform_probe(struct platform_device *pdev)
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
 	if (IS_ERR(drvdata->pclk))
-		return -ENODEV;
+		return PTR_ERR(drvdata->pclk);
 
 	dev_set_drvdata(&pdev->dev, drvdata);
 	pm_runtime_get_noresume(&pdev->dev);
@@ -1005,8 +1005,6 @@ static void tmc_platform_remove(struct platform_device *pdev)
 
 	__tmc_remove(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	if (!IS_ERR_OR_NULL(drvdata->pclk))
-		clk_put(drvdata->pclk);
 }
 
 #ifdef CONFIG_PM
diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c
index 3e01592884280819c16398cbb5e09cbaee5d3efb..b2559c6fac6d2f02e0038e583cd324d7165c5aee 100644
--- a/drivers/hwtracing/coresight/coresight-tpiu.c
+++ b/drivers/hwtracing/coresight/coresight-tpiu.c
@@ -153,7 +153,7 @@ static int __tpiu_probe(struct device *dev, struct resource *res)
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
 	if (IS_ERR(drvdata->pclk))
-		return -ENODEV;
+		return PTR_ERR(drvdata->pclk);
 	dev_set_drvdata(dev, drvdata);
 
 	/* Validity for the resource is already checked by the AMBA core */
@@ -293,8 +293,6 @@ static void tpiu_platform_remove(struct platform_device *pdev)
 
 	__tpiu_remove(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	if (!IS_ERR_OR_NULL(drvdata->pclk))
-		clk_put(drvdata->pclk);
 }
 
 #ifdef CONFIG_ACPI
diff --git a/include/linux/coresight.h b/include/linux/coresight.h
index 4ac65c68bbf44b98db22c3dad2d83a224ce5278e..c6eb35cc25397656b52eb142f3f2eb5bf5dd4b69 100644
--- a/include/linux/coresight.h
+++ b/include/linux/coresight.h
@@ -6,6 +6,7 @@
 #ifndef _LINUX_CORESIGHT_H
 #define _LINUX_CORESIGHT_H
 
+#include <linux/acpi.h>
 #include <linux/amba/bus.h>
 #include <linux/clk.h>
 #include <linux/device.h>
@@ -480,26 +481,21 @@ static inline bool is_coresight_device(void __iomem *base)
  * Returns:
  *
  * clk   - Clock is found and enabled
- * NULL  - clock is not found
+ * NULL  - Clock is controlled by firmware (ACPI device only)
  * ERROR - Clock is found but failed to enable
  */
 static inline struct clk *coresight_get_enable_apb_pclk(struct device *dev)
 {
 	struct clk *pclk;
-	int ret;
 
-	pclk = clk_get(dev, "apb_pclk");
-	if (IS_ERR(pclk)) {
-		pclk = clk_get(dev, "apb");
-		if (IS_ERR(pclk))
-			return NULL;
-	}
+	/* Firmware controls clocks for an ACPI device. */
+	if (has_acpi_companion(dev))
+		return NULL;
+
+	pclk = devm_clk_get_enabled(dev, "apb_pclk");
+	if (IS_ERR(pclk))
+		pclk = devm_clk_get_enabled(dev, "apb");
 
-	ret = clk_prepare_enable(pclk);
-	if (ret) {
-		clk_put(pclk);
-		return ERR_PTR(ret);
-	}
 	return pclk;
 }
 

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v5 05/10] coresight: Appropriately disable trace bus clocks
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
                   ` (3 preceding siblings ...)
  2025-07-24 15:22 ` [PATCH v5 04/10] coresight: Appropriately disable programming clocks Leo Yan
@ 2025-07-24 15:22 ` Leo Yan
  2025-07-24 15:22 ` [PATCH v5 06/10] coresight: Avoid enable programming clock duplicately Leo Yan
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-24 15:22 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman
  Cc: coresight, linux-arm-kernel, linux-kernel, Leo Yan

Some CoreSight components have trace bus clocks 'atclk' and are enabled
using clk_prepare_enable().  These clocks are not disabled when modules
exit.

As atclk is optional, use devm_clk_get_optional_enabled() to manage it.
The benefit is the driver model layer can automatically disable and
release clocks.

Check the returned value with IS_ERR() to detect errors but leave the
NULL pointer case if the clock is not found.  And remove the error
handling codes which are no longer needed.

Fixes: d1839e687773 ("coresight: etm: retrieve and handle atclk")
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 drivers/hwtracing/coresight/coresight-etb10.c      | 10 +++---
 drivers/hwtracing/coresight/coresight-etm3x-core.c |  9 ++----
 drivers/hwtracing/coresight/coresight-funnel.c     | 36 +++++++---------------
 drivers/hwtracing/coresight/coresight-replicator.c | 34 ++++++--------------
 drivers/hwtracing/coresight/coresight-stm.c        |  9 ++----
 drivers/hwtracing/coresight/coresight-tpiu.c       | 10 ++----
 6 files changed, 34 insertions(+), 74 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index d5efb085b30d36b51ca591c1b595ef82481f5569..8e81b41eb22264f17606050fa8da277aae05c5cc 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -730,12 +730,10 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */
-	if (!IS_ERR(drvdata->atclk)) {
-		ret = clk_prepare_enable(drvdata->atclk);
-		if (ret)
-			return ret;
-	}
+	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
+	if (IS_ERR(drvdata->atclk))
+		return PTR_ERR(drvdata->atclk);
+
 	dev_set_drvdata(dev, drvdata);
 
 	/* validity for the resource is already checked by the AMBA core */
diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/hwtracing/coresight/coresight-etm3x-core.c
index 1c6204e1442211be6f3d7ca34bd2251ba796601b..baba2245b1dfb31f4bf19080e20c33df3a5b854f 100644
--- a/drivers/hwtracing/coresight/coresight-etm3x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c
@@ -832,12 +832,9 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id)
 
 	spin_lock_init(&drvdata->spinlock);
 
-	drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */
-	if (!IS_ERR(drvdata->atclk)) {
-		ret = clk_prepare_enable(drvdata->atclk);
-		if (ret)
-			return ret;
-	}
+	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
+	if (IS_ERR(drvdata->atclk))
+		return PTR_ERR(drvdata->atclk);
 
 	drvdata->cpu = coresight_get_cpu(dev);
 	if (drvdata->cpu < 0)
diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
index 36fc4e991458c112521c4261d73f3e58e9a3f995..b044a4125310ba4f8c88df295ec3684ab266682f 100644
--- a/drivers/hwtracing/coresight/coresight-funnel.c
+++ b/drivers/hwtracing/coresight/coresight-funnel.c
@@ -213,7 +213,6 @@ ATTRIBUTE_GROUPS(coresight_funnel);
 
 static int funnel_probe(struct device *dev, struct resource *res)
 {
-	int ret;
 	void __iomem *base;
 	struct coresight_platform_data *pdata = NULL;
 	struct funnel_drvdata *drvdata;
@@ -231,12 +230,9 @@ static int funnel_probe(struct device *dev, struct resource *res)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */
-	if (!IS_ERR(drvdata->atclk)) {
-		ret = clk_prepare_enable(drvdata->atclk);
-		if (ret)
-			return ret;
-	}
+	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
+	if (IS_ERR(drvdata->atclk))
+		return PTR_ERR(drvdata->atclk);
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
 	if (IS_ERR(drvdata->pclk))
@@ -248,10 +244,8 @@ static int funnel_probe(struct device *dev, struct resource *res)
 	 */
 	if (res) {
 		base = devm_ioremap_resource(dev, res);
-		if (IS_ERR(base)) {
-			ret = PTR_ERR(base);
-			goto out_disable_clk;
-		}
+		if (IS_ERR(base))
+			return PTR_ERR(base);
 		drvdata->base = base;
 		desc.groups = coresight_funnel_groups;
 		desc.access = CSDEV_ACCESS_IOMEM(base);
@@ -261,10 +255,9 @@ static int funnel_probe(struct device *dev, struct resource *res)
 	dev_set_drvdata(dev, drvdata);
 
 	pdata = coresight_get_platform_data(dev);
-	if (IS_ERR(pdata)) {
-		ret = PTR_ERR(pdata);
-		goto out_disable_clk;
-	}
+	if (IS_ERR(pdata))
+		return PTR_ERR(pdata);
+
 	dev->platform_data = pdata;
 
 	raw_spin_lock_init(&drvdata->spinlock);
@@ -274,17 +267,10 @@ static int funnel_probe(struct device *dev, struct resource *res)
 	desc.pdata = pdata;
 	desc.dev = dev;
 	drvdata->csdev = coresight_register(&desc);
-	if (IS_ERR(drvdata->csdev)) {
-		ret = PTR_ERR(drvdata->csdev);
-		goto out_disable_clk;
-	}
+	if (IS_ERR(drvdata->csdev))
+		return PTR_ERR(drvdata->csdev);
 
-	ret = 0;
-
-out_disable_clk:
-	if (ret && !IS_ERR_OR_NULL(drvdata->atclk))
-		clk_disable_unprepare(drvdata->atclk);
-	return ret;
+	return 0;
 }
 
 static int funnel_remove(struct device *dev)
diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
index 6dd24eb10a94b0eb28f4f27afab845227e22b96c..9e8bd36e7a9a2fd061f41c56242ac2b11549daf5 100644
--- a/drivers/hwtracing/coresight/coresight-replicator.c
+++ b/drivers/hwtracing/coresight/coresight-replicator.c
@@ -219,7 +219,6 @@ static const struct attribute_group *replicator_groups[] = {
 
 static int replicator_probe(struct device *dev, struct resource *res)
 {
-	int ret = 0;
 	struct coresight_platform_data *pdata = NULL;
 	struct replicator_drvdata *drvdata;
 	struct coresight_desc desc = { 0 };
@@ -238,12 +237,9 @@ static int replicator_probe(struct device *dev, struct resource *res)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */
-	if (!IS_ERR(drvdata->atclk)) {
-		ret = clk_prepare_enable(drvdata->atclk);
-		if (ret)
-			return ret;
-	}
+	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
+	if (IS_ERR(drvdata->atclk))
+		return PTR_ERR(drvdata->atclk);
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
 	if (IS_ERR(drvdata->pclk))
@@ -255,10 +251,8 @@ static int replicator_probe(struct device *dev, struct resource *res)
 	 */
 	if (res) {
 		base = devm_ioremap_resource(dev, res);
-		if (IS_ERR(base)) {
-			ret = PTR_ERR(base);
-			goto out_disable_clk;
-		}
+		if (IS_ERR(base))
+			return PTR_ERR(base);
 		drvdata->base = base;
 		desc.groups = replicator_groups;
 		desc.access = CSDEV_ACCESS_IOMEM(base);
@@ -272,10 +266,8 @@ static int replicator_probe(struct device *dev, struct resource *res)
 	dev_set_drvdata(dev, drvdata);
 
 	pdata = coresight_get_platform_data(dev);
-	if (IS_ERR(pdata)) {
-		ret = PTR_ERR(pdata);
-		goto out_disable_clk;
-	}
+	if (IS_ERR(pdata))
+		return PTR_ERR(pdata);
 	dev->platform_data = pdata;
 
 	raw_spin_lock_init(&drvdata->spinlock);
@@ -286,17 +278,11 @@ static int replicator_probe(struct device *dev, struct resource *res)
 	desc.dev = dev;
 
 	drvdata->csdev = coresight_register(&desc);
-	if (IS_ERR(drvdata->csdev)) {
-		ret = PTR_ERR(drvdata->csdev);
-		goto out_disable_clk;
-	}
+	if (IS_ERR(drvdata->csdev))
+		return PTR_ERR(drvdata->csdev);
 
 	replicator_reset(drvdata);
-
-out_disable_clk:
-	if (ret && !IS_ERR_OR_NULL(drvdata->atclk))
-		clk_disable_unprepare(drvdata->atclk);
-	return ret;
+	return 0;
 }
 
 static int replicator_remove(struct device *dev)
diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index f2de16e4d3b4cc0fc3fa06654fc7ddd9dee1e302..275d67b91dfd58002918c3e0ec0be077467c601a 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -842,12 +842,9 @@ static int __stm_probe(struct device *dev, struct resource *res)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */
-	if (!IS_ERR(drvdata->atclk)) {
-		ret = clk_prepare_enable(drvdata->atclk);
-		if (ret)
-			return ret;
-	}
+	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
+	if (IS_ERR(drvdata->atclk))
+		return PTR_ERR(drvdata->atclk);
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
 	if (IS_ERR(drvdata->pclk))
diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c
index b2559c6fac6d2f02e0038e583cd324d7165c5aee..8d6179c83e5d3194d1f90e10c88fcc1faccf0cd7 100644
--- a/drivers/hwtracing/coresight/coresight-tpiu.c
+++ b/drivers/hwtracing/coresight/coresight-tpiu.c
@@ -128,7 +128,6 @@ static const struct coresight_ops tpiu_cs_ops = {
 
 static int __tpiu_probe(struct device *dev, struct resource *res)
 {
-	int ret;
 	void __iomem *base;
 	struct coresight_platform_data *pdata = NULL;
 	struct tpiu_drvdata *drvdata;
@@ -144,12 +143,9 @@ static int __tpiu_probe(struct device *dev, struct resource *res)
 
 	spin_lock_init(&drvdata->spinlock);
 
-	drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */
-	if (!IS_ERR(drvdata->atclk)) {
-		ret = clk_prepare_enable(drvdata->atclk);
-		if (ret)
-			return ret;
-	}
+	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
+	if (IS_ERR(drvdata->atclk))
+		return PTR_ERR(drvdata->atclk);
 
 	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
 	if (IS_ERR(drvdata->pclk))

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v5 06/10] coresight: Avoid enable programming clock duplicately
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
                   ` (4 preceding siblings ...)
  2025-07-24 15:22 ` [PATCH v5 05/10] coresight: Appropriately disable trace bus clocks Leo Yan
@ 2025-07-24 15:22 ` Leo Yan
  2025-07-24 15:22 ` [PATCH v5 07/10] coresight: Consolidate clock enabling Leo Yan
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-24 15:22 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman
  Cc: coresight, linux-arm-kernel, linux-kernel, Leo Yan

The programming clock is enabled by AMBA bus driver before a dynamic
probe. As a result, a CoreSight driver may redundantly enable the same
clock.

To avoid this, add a check for device type and skip enabling the
programming clock for AMBA devices. The returned NULL pointer will be
tolerated by the drivers.

Fixes: 73d779a03a76 ("coresight: etm4x: Change etm4_platform_driver driver for MMIO devices")
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 include/linux/coresight.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/linux/coresight.h b/include/linux/coresight.h
index c6eb35cc25397656b52eb142f3f2eb5bf5dd4b69..4eada894c08293f36056483a8b5a038b26c387df 100644
--- a/include/linux/coresight.h
+++ b/include/linux/coresight.h
@@ -481,20 +481,23 @@ static inline bool is_coresight_device(void __iomem *base)
  * Returns:
  *
  * clk   - Clock is found and enabled
- * NULL  - Clock is controlled by firmware (ACPI device only)
+ * NULL  - Clock is controlled by firmware (ACPI device only) or when managed
+ *	   by the AMBA bus driver instead
  * ERROR - Clock is found but failed to enable
  */
 static inline struct clk *coresight_get_enable_apb_pclk(struct device *dev)
 {
-	struct clk *pclk;
+	struct clk *pclk = NULL;
 
 	/* Firmware controls clocks for an ACPI device. */
 	if (has_acpi_companion(dev))
 		return NULL;
 
-	pclk = devm_clk_get_enabled(dev, "apb_pclk");
-	if (IS_ERR(pclk))
-		pclk = devm_clk_get_enabled(dev, "apb");
+	if (!dev_is_amba(dev)) {
+		pclk = devm_clk_get_enabled(dev, "apb_pclk");
+		if (IS_ERR(pclk))
+			pclk = devm_clk_get_enabled(dev, "apb");
+	}
 
 	return pclk;
 }

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v5 07/10] coresight: Consolidate clock enabling
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
                   ` (5 preceding siblings ...)
  2025-07-24 15:22 ` [PATCH v5 06/10] coresight: Avoid enable programming clock duplicately Leo Yan
@ 2025-07-24 15:22 ` Leo Yan
  2025-07-24 15:22 ` [PATCH v5 08/10] coresight: Refactor driver data allocation Leo Yan
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-24 15:22 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman
  Cc: coresight, linux-arm-kernel, linux-kernel, Leo Yan

CoreSight drivers enable pclk and atclk conditionally. For example,
pclk is only enabled in the static probe, while atclk is an optional
clock that it is enabled for both dynamic and static probes, if it is
present. In the current CoreSight drivers, these two clocks are
initialized separately.  This causes complex and duplicate codes.

CoreSight drivers are refined so that clocks are initialized in one go.
For this purpose, this commit renames coresight_get_enable_apb_pclk() to
coresight_get_enable_clocks() and encapsulates clock initialization
logic:

 - If a clock is initialized successfully, its clock pointer is assigned
   to the double pointer passed as an argument.
 - For ACPI devices, clocks are controlled by firmware, directly bail
   out.
 - Skip enabling pclk for an AMBA device.
 - If atclk is not found, the corresponding double pointer is set to
   NULL. The function returns Success (0) to guide callers can proceed
   with no error.
 - Otherwise, an error number is returned for failures.

The function became complex, move it from the header to the CoreSight
core layer and the symbol is exported. Added comments for recording
details.

Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 drivers/hwtracing/coresight/coresight-catu.c       | 10 ++---
 drivers/hwtracing/coresight/coresight-core.c       | 48 ++++++++++++++++++++++
 drivers/hwtracing/coresight/coresight-cpu-debug.c  |  8 ++--
 drivers/hwtracing/coresight/coresight-ctcu-core.c  |  8 ++--
 drivers/hwtracing/coresight/coresight-etm4x-core.c | 11 ++---
 drivers/hwtracing/coresight/coresight-funnel.c     | 11 ++---
 drivers/hwtracing/coresight/coresight-replicator.c | 11 ++---
 drivers/hwtracing/coresight/coresight-stm.c        |  9 ++--
 drivers/hwtracing/coresight/coresight-tmc-core.c   | 10 ++---
 drivers/hwtracing/coresight/coresight-tpiu.c       | 10 ++---
 include/linux/coresight.h                          | 30 +-------------
 11 files changed, 83 insertions(+), 83 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
index 4c345ff2cff141ea63c2220393e5fdd00c449ca6..0f476a0cbd740c233d039c5c411ca192681e2023 100644
--- a/drivers/hwtracing/coresight/coresight-catu.c
+++ b/drivers/hwtracing/coresight/coresight-catu.c
@@ -520,9 +520,9 @@ static int __catu_probe(struct device *dev, struct resource *res)
 	struct coresight_platform_data *pdata = NULL;
 	void __iomem *base;
 
-	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
-	if (IS_ERR(drvdata->atclk))
-		return PTR_ERR(drvdata->atclk);
+	ret = coresight_get_enable_clocks(dev, &drvdata->pclk, &drvdata->atclk);
+	if (ret)
+		return ret;
 
 	catu_desc.name = coresight_alloc_device_name(&catu_devs, dev);
 	if (!catu_desc.name)
@@ -634,10 +634,6 @@ static int catu_platform_probe(struct platform_device *pdev)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
-	if (IS_ERR(drvdata->pclk))
-		return PTR_ERR(drvdata->pclk);
-
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index 1accd7cbd54bf0c41ba209dccfd510d9710a21f7..66b7eb4990fa0e390eae78e711196d7662c8cde7 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2012, The Linux Foundation. All rights reserved.
  */
 
+#include <linux/acpi.h>
 #include <linux/bitfield.h>
 #include <linux/build_bug.h>
 #include <linux/kernel.h>
@@ -1700,6 +1701,53 @@ int coresight_etm_get_trace_id(struct coresight_device *csdev, enum cs_mode mode
 }
 EXPORT_SYMBOL_GPL(coresight_etm_get_trace_id);
 
+/*
+ * Attempt to find and enable programming clock (pclk) and trace clock (atclk)
+ * for the given device.
+ *
+ * For ACPI devices, clocks are controlled by firmware, so bail out early in
+ * this case. Also, skip enabling pclk if the clock is managed by the AMBA
+ * bus driver instead.
+ *
+ * atclk is an optional clock, it will be only enabled when it is existed.
+ * Otherwise, a NULL pointer will be returned to caller.
+ *
+ * Returns: '0' on Success; Error code otherwise.
+ */
+int coresight_get_enable_clocks(struct device *dev, struct clk **pclk,
+				struct clk **atclk)
+{
+	WARN_ON(!pclk);
+
+	if (has_acpi_companion(dev))
+		return 0;
+
+	if (!dev_is_amba(dev)) {
+		/*
+		 * "apb_pclk" is the default clock name for an Arm Primecell
+		 * peripheral, while "apb" is used only by the CTCU driver.
+		 *
+		 * For easier maintenance, CoreSight drivers should use
+		 * "apb_pclk" as the programming clock name.
+		 */
+		*pclk = devm_clk_get_enabled(dev, "apb_pclk");
+		if (IS_ERR(*pclk))
+			*pclk = devm_clk_get_enabled(dev, "apb");
+		if (IS_ERR(*pclk))
+			return PTR_ERR(*pclk);
+	}
+
+	/* Initialization of atclk is skipped if it is a NULL pointer. */
+	if (atclk) {
+		*atclk = devm_clk_get_optional_enabled(dev, "atclk");
+		if (IS_ERR(*atclk))
+			return PTR_ERR(*atclk);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(coresight_get_enable_clocks);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
 MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index e39dfb886688e111eee95d4294f37fa85baccd14..5f6db2fb95d4623a0bab08828ae00442870abd7d 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -566,6 +566,10 @@ static int __debug_probe(struct device *dev, struct resource *res)
 	void __iomem *base;
 	int ret;
 
+	ret = coresight_get_enable_clocks(dev, &drvdata->pclk, NULL);
+	if (ret)
+		return ret;
+
 	drvdata->cpu = coresight_get_cpu(dev);
 	if (drvdata->cpu < 0)
 		return drvdata->cpu;
@@ -697,10 +701,6 @@ static int debug_platform_probe(struct platform_device *pdev)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
-	if (IS_ERR(drvdata->pclk))
-		return PTR_ERR(drvdata->pclk);
-
 	dev_set_drvdata(&pdev->dev, drvdata);
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
diff --git a/drivers/hwtracing/coresight/coresight-ctcu-core.c b/drivers/hwtracing/coresight/coresight-ctcu-core.c
index de279efe340581ceabfb9e1cd1e7fe4b5e4f826e..75b5114ef652e4a47c53fbd2b7811c1bab575645 100644
--- a/drivers/hwtracing/coresight/coresight-ctcu-core.c
+++ b/drivers/hwtracing/coresight/coresight-ctcu-core.c
@@ -188,7 +188,7 @@ static int ctcu_probe(struct platform_device *pdev)
 	const struct ctcu_config *cfgs;
 	struct ctcu_drvdata *drvdata;
 	void __iomem *base;
-	int i;
+	int i, ret;
 
 	desc.name = coresight_alloc_device_name(&ctcu_devs, dev);
 	if (!desc.name)
@@ -207,9 +207,9 @@ static int ctcu_probe(struct platform_device *pdev)
 	if (IS_ERR(base))
 		return PTR_ERR(base);
 
-	drvdata->apb_clk = coresight_get_enable_apb_pclk(dev);
-	if (IS_ERR(drvdata->apb_clk))
-		return PTR_ERR(drvdata->apb_clk);
+	ret = coresight_get_enable_clocks(dev, &drvdata->apb_clk, NULL);
+	if (ret)
+		return ret;
 
 	cfgs = of_device_get_match_data(dev);
 	if (cfgs) {
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
index 1892e1c3e4a1b2389e858abf9cf08a6868ae475e..3046605b5e6121c438b96d8cbfb761c23456edf2 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
@@ -2212,13 +2212,14 @@ static int etm4_probe(struct device *dev)
 	struct csdev_access access = { 0 };
 	struct etm4_init_arg init_arg = { 0 };
 	struct etm4_init_arg *delayed;
+	int ret;
 
 	if (WARN_ON(!drvdata))
 		return -ENOMEM;
 
-	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
-	if (IS_ERR(drvdata->atclk))
-		return PTR_ERR(drvdata->atclk);
+	ret = coresight_get_enable_clocks(dev, &drvdata->pclk, &drvdata->atclk);
+	if (ret)
+		return ret;
 
 	if (pm_save_enable == PARAM_PM_SAVE_FIRMWARE)
 		pm_save_enable = coresight_loses_context_with_cpu(dev) ?
@@ -2302,10 +2303,6 @@ static int etm4_probe_platform_dev(struct platform_device *pdev)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
-	if (IS_ERR(drvdata->pclk))
-		return PTR_ERR(drvdata->pclk);
-
 	if (res) {
 		drvdata->base = devm_ioremap_resource(&pdev->dev, res);
 		if (IS_ERR(drvdata->base))
diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
index b044a4125310ba4f8c88df295ec3684ab266682f..02e0dc678a32c3b1f32fc955bf8871142e3412e1 100644
--- a/drivers/hwtracing/coresight/coresight-funnel.c
+++ b/drivers/hwtracing/coresight/coresight-funnel.c
@@ -217,6 +217,7 @@ static int funnel_probe(struct device *dev, struct resource *res)
 	struct coresight_platform_data *pdata = NULL;
 	struct funnel_drvdata *drvdata;
 	struct coresight_desc desc = { 0 };
+	int ret;
 
 	if (is_of_node(dev_fwnode(dev)) &&
 	    of_device_is_compatible(dev->of_node, "arm,coresight-funnel"))
@@ -230,13 +231,9 @@ static int funnel_probe(struct device *dev, struct resource *res)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
-	if (IS_ERR(drvdata->atclk))
-		return PTR_ERR(drvdata->atclk);
-
-	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
-	if (IS_ERR(drvdata->pclk))
-		return PTR_ERR(drvdata->pclk);
+	ret = coresight_get_enable_clocks(dev, &drvdata->pclk, &drvdata->atclk);
+	if (ret)
+		return ret;
 
 	/*
 	 * Map the device base for dynamic-funnel, which has been
diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
index 9e8bd36e7a9a2fd061f41c56242ac2b11549daf5..f1bbd12e63e0c130f945d8df34fb2334bd21336f 100644
--- a/drivers/hwtracing/coresight/coresight-replicator.c
+++ b/drivers/hwtracing/coresight/coresight-replicator.c
@@ -223,6 +223,7 @@ static int replicator_probe(struct device *dev, struct resource *res)
 	struct replicator_drvdata *drvdata;
 	struct coresight_desc desc = { 0 };
 	void __iomem *base;
+	int ret;
 
 	if (is_of_node(dev_fwnode(dev)) &&
 	    of_device_is_compatible(dev->of_node, "arm,coresight-replicator"))
@@ -237,13 +238,9 @@ static int replicator_probe(struct device *dev, struct resource *res)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
-	if (IS_ERR(drvdata->atclk))
-		return PTR_ERR(drvdata->atclk);
-
-	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
-	if (IS_ERR(drvdata->pclk))
-		return PTR_ERR(drvdata->pclk);
+	ret = coresight_get_enable_clocks(dev, &drvdata->pclk, &drvdata->atclk);
+	if (ret)
+		return ret;
 
 	/*
 	 * Map the device base for dynamic-replicator, which has been
diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index 275d67b91dfd58002918c3e0ec0be077467c601a..23ba33ac4d2ed8d63f1e0fb922e7f6e44de86cd1 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -842,13 +842,10 @@ static int __stm_probe(struct device *dev, struct resource *res)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
-	if (IS_ERR(drvdata->atclk))
-		return PTR_ERR(drvdata->atclk);
+	ret = coresight_get_enable_clocks(dev, &drvdata->pclk, &drvdata->atclk);
+	if (ret)
+		return ret;
 
-	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
-	if (IS_ERR(drvdata->pclk))
-		return PTR_ERR(drvdata->pclk);
 	dev_set_drvdata(dev, drvdata);
 
 	base = devm_ioremap_resource(dev, res);
diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
index 519f225428070df5c5e6fcf014cd132058f01228..25c987e2d114881a4e4d8f6ed1791d183a64da5a 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-core.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
@@ -779,9 +779,9 @@ static int __tmc_probe(struct device *dev, struct resource *res)
 	struct coresight_desc desc = { 0 };
 	struct coresight_dev_list *dev_list = NULL;
 
-	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
-	if (IS_ERR(drvdata->atclk))
-		return PTR_ERR(drvdata->atclk);
+	ret = coresight_get_enable_clocks(dev, &drvdata->pclk, &drvdata->atclk);
+	if (ret)
+		return ret;
 
 	ret = -ENOMEM;
 
@@ -979,10 +979,6 @@ static int tmc_platform_probe(struct platform_device *pdev)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
-	if (IS_ERR(drvdata->pclk))
-		return PTR_ERR(drvdata->pclk);
-
 	dev_set_drvdata(&pdev->dev, drvdata);
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c
index 8d6179c83e5d3194d1f90e10c88fcc1faccf0cd7..5e47d761e1c4e99072eeb492c1eac7dd4285a591 100644
--- a/drivers/hwtracing/coresight/coresight-tpiu.c
+++ b/drivers/hwtracing/coresight/coresight-tpiu.c
@@ -132,6 +132,7 @@ static int __tpiu_probe(struct device *dev, struct resource *res)
 	struct coresight_platform_data *pdata = NULL;
 	struct tpiu_drvdata *drvdata;
 	struct coresight_desc desc = { 0 };
+	int ret;
 
 	desc.name = coresight_alloc_device_name(&tpiu_devs, dev);
 	if (!desc.name)
@@ -143,13 +144,10 @@ static int __tpiu_probe(struct device *dev, struct resource *res)
 
 	spin_lock_init(&drvdata->spinlock);
 
-	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
-	if (IS_ERR(drvdata->atclk))
-		return PTR_ERR(drvdata->atclk);
+	ret = coresight_get_enable_clocks(dev, &drvdata->pclk, &drvdata->atclk);
+	if (ret)
+		return ret;
 
-	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
-	if (IS_ERR(drvdata->pclk))
-		return PTR_ERR(drvdata->pclk);
 	dev_set_drvdata(dev, drvdata);
 
 	/* Validity for the resource is already checked by the AMBA core */
diff --git a/include/linux/coresight.h b/include/linux/coresight.h
index 4eada894c08293f36056483a8b5a038b26c387df..6de59ce8ef8ca45c29e2f09c1b979eb7686b685f 100644
--- a/include/linux/coresight.h
+++ b/include/linux/coresight.h
@@ -6,7 +6,6 @@
 #ifndef _LINUX_CORESIGHT_H
 #define _LINUX_CORESIGHT_H
 
-#include <linux/acpi.h>
 #include <linux/amba/bus.h>
 #include <linux/clk.h>
 #include <linux/device.h>
@@ -475,33 +474,6 @@ static inline bool is_coresight_device(void __iomem *base)
 	return cid == CORESIGHT_CID;
 }
 
-/*
- * Attempt to find and enable "APB clock" for the given device
- *
- * Returns:
- *
- * clk   - Clock is found and enabled
- * NULL  - Clock is controlled by firmware (ACPI device only) or when managed
- *	   by the AMBA bus driver instead
- * ERROR - Clock is found but failed to enable
- */
-static inline struct clk *coresight_get_enable_apb_pclk(struct device *dev)
-{
-	struct clk *pclk = NULL;
-
-	/* Firmware controls clocks for an ACPI device. */
-	if (has_acpi_companion(dev))
-		return NULL;
-
-	if (!dev_is_amba(dev)) {
-		pclk = devm_clk_get_enabled(dev, "apb_pclk");
-		if (IS_ERR(pclk))
-			pclk = devm_clk_get_enabled(dev, "apb");
-	}
-
-	return pclk;
-}
-
 #define CORESIGHT_PIDRn(i)	(0xFE0 + ((i) * 4))
 
 static inline u32 coresight_get_pid(struct csdev_access *csa)
@@ -732,4 +704,6 @@ void coresight_remove_driver(struct amba_driver *amba_drv,
 			     struct platform_driver *pdev_drv);
 int coresight_etm_get_trace_id(struct coresight_device *csdev, enum cs_mode mode,
 			       struct coresight_device *sink);
+int coresight_get_enable_clocks(struct device *dev, struct clk **pclk,
+				struct clk **atclk);
 #endif		/* _LINUX_COREISGHT_H */

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v5 08/10] coresight: Refactor driver data allocation
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
                   ` (6 preceding siblings ...)
  2025-07-24 15:22 ` [PATCH v5 07/10] coresight: Consolidate clock enabling Leo Yan
@ 2025-07-24 15:22 ` Leo Yan
  2025-07-24 15:22 ` [PATCH v5 09/10] coresight: Make clock sequence consistent Leo Yan
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-24 15:22 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman
  Cc: coresight, linux-arm-kernel, linux-kernel, Leo Yan

The driver data no longer needs to be allocated separately in the static
and dynamic probes. Moved the allocation into the low-level functions to
avoid code duplication.

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 drivers/hwtracing/coresight/coresight-catu.c      | 20 +++++++-------------
 drivers/hwtracing/coresight/coresight-cpu-debug.c | 21 +++++++--------------
 drivers/hwtracing/coresight/coresight-tmc-core.c  | 20 +++++++-------------
 3 files changed, 21 insertions(+), 40 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
index 0f476a0cbd740c233d039c5c411ca192681e2023..a3ccb7034ae14d7339bc2549bccadf11e28c45e2 100644
--- a/drivers/hwtracing/coresight/coresight-catu.c
+++ b/drivers/hwtracing/coresight/coresight-catu.c
@@ -515,11 +515,17 @@ static int __catu_probe(struct device *dev, struct resource *res)
 {
 	int ret = 0;
 	u32 dma_mask;
-	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
+	struct catu_drvdata *drvdata;
 	struct coresight_desc catu_desc;
 	struct coresight_platform_data *pdata = NULL;
 	void __iomem *base;
 
+	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
+	dev_set_drvdata(dev, drvdata);
+
 	ret = coresight_get_enable_clocks(dev, &drvdata->pclk, &drvdata->atclk);
 	if (ret)
 		return ret;
@@ -580,14 +586,8 @@ static int __catu_probe(struct device *dev, struct resource *res)
 
 static int catu_probe(struct amba_device *adev, const struct amba_id *id)
 {
-	struct catu_drvdata *drvdata;
 	int ret;
 
-	drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL);
-	if (!drvdata)
-		return -ENOMEM;
-
-	amba_set_drvdata(adev, drvdata);
 	ret = __catu_probe(&adev->dev, &adev->res);
 	if (!ret)
 		pm_runtime_put(&adev->dev);
@@ -627,18 +627,12 @@ static struct amba_driver catu_driver = {
 static int catu_platform_probe(struct platform_device *pdev)
 {
 	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	struct catu_drvdata *drvdata;
 	int ret = 0;
 
-	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
-	if (!drvdata)
-		return -ENOMEM;
-
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
 
-	dev_set_drvdata(&pdev->dev, drvdata);
 	ret = __catu_probe(&pdev->dev, res);
 	pm_runtime_put(&pdev->dev);
 	if (ret)
diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index 5f6db2fb95d4623a0bab08828ae00442870abd7d..3edfb5d3d02056afcaab4da575d1101c68aeac80 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -562,10 +562,16 @@ static void debug_func_exit(void)
 
 static int __debug_probe(struct device *dev, struct resource *res)
 {
-	struct debug_drvdata *drvdata = dev_get_drvdata(dev);
+	struct debug_drvdata *drvdata;
 	void __iomem *base;
 	int ret;
 
+	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
+	dev_set_drvdata(dev, drvdata);
+
 	ret = coresight_get_enable_clocks(dev, &drvdata->pclk, NULL);
 	if (ret)
 		return ret;
@@ -629,13 +635,6 @@ static int __debug_probe(struct device *dev, struct resource *res)
 
 static int debug_probe(struct amba_device *adev, const struct amba_id *id)
 {
-	struct debug_drvdata *drvdata;
-
-	drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL);
-	if (!drvdata)
-		return -ENOMEM;
-
-	amba_set_drvdata(adev, drvdata);
 	return __debug_probe(&adev->dev, &adev->res);
 }
 
@@ -694,14 +693,8 @@ static struct amba_driver debug_driver = {
 static int debug_platform_probe(struct platform_device *pdev)
 {
 	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	struct debug_drvdata *drvdata;
 	int ret = 0;
 
-	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
-	if (!drvdata)
-		return -ENOMEM;
-
-	dev_set_drvdata(&pdev->dev, drvdata);
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
index 25c987e2d114881a4e4d8f6ed1791d183a64da5a..36599c431be6203e871fdcb8de569cc6701c52bb 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-core.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
@@ -775,10 +775,16 @@ static int __tmc_probe(struct device *dev, struct resource *res)
 	u32 devid;
 	void __iomem *base;
 	struct coresight_platform_data *pdata = NULL;
-	struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
+	struct tmc_drvdata *drvdata;
 	struct coresight_desc desc = { 0 };
 	struct coresight_dev_list *dev_list = NULL;
 
+	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
+	dev_set_drvdata(dev, drvdata);
+
 	ret = coresight_get_enable_clocks(dev, &drvdata->pclk, &drvdata->atclk);
 	if (ret)
 		return ret;
@@ -888,14 +894,8 @@ static int __tmc_probe(struct device *dev, struct resource *res)
 
 static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
 {
-	struct tmc_drvdata *drvdata;
 	int ret;
 
-	drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL);
-	if (!drvdata)
-		return -ENOMEM;
-
-	amba_set_drvdata(adev, drvdata);
 	ret = __tmc_probe(&adev->dev, &adev->res);
 	if (!ret)
 		pm_runtime_put(&adev->dev);
@@ -972,14 +972,8 @@ static struct amba_driver tmc_driver = {
 static int tmc_platform_probe(struct platform_device *pdev)
 {
 	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	struct tmc_drvdata *drvdata;
 	int ret = 0;
 
-	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
-	if (!drvdata)
-		return -ENOMEM;
-
-	dev_set_drvdata(&pdev->dev, drvdata);
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v5 09/10] coresight: Make clock sequence consistent
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
                   ` (7 preceding siblings ...)
  2025-07-24 15:22 ` [PATCH v5 08/10] coresight: Refactor driver data allocation Leo Yan
@ 2025-07-24 15:22 ` Leo Yan
  2025-07-24 15:22 ` [PATCH v5 10/10] coresight: Refactor runtime PM Leo Yan
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-24 15:22 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman
  Cc: coresight, linux-arm-kernel, linux-kernel, Leo Yan

Since atclk is enabled after pclk during the probe phase, this commit
maintains the same sequence for the runtime resume flow.

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 drivers/hwtracing/coresight/coresight-funnel.c     | 6 +++---
 drivers/hwtracing/coresight/coresight-replicator.c | 6 +++---
 drivers/hwtracing/coresight/coresight-stm.c        | 6 +++---
 drivers/hwtracing/coresight/coresight-tpiu.c       | 6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
index 02e0dc678a32c3b1f32fc955bf8871142e3412e1..9dcfc5ce8845d9e01bb956dddab0d64de51ec397 100644
--- a/drivers/hwtracing/coresight/coresight-funnel.c
+++ b/drivers/hwtracing/coresight/coresight-funnel.c
@@ -297,11 +297,11 @@ static int funnel_runtime_resume(struct device *dev)
 {
 	struct funnel_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_prepare_enable(drvdata->atclk);
-
 	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
 		clk_prepare_enable(drvdata->pclk);
+
+	if (drvdata && !IS_ERR(drvdata->atclk))
+		clk_prepare_enable(drvdata->atclk);
 	return 0;
 }
 #endif
diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
index f1bbd12e63e0c130f945d8df34fb2334bd21336f..e53095603b0c0419bc96a66b23d15bb54e75e634 100644
--- a/drivers/hwtracing/coresight/coresight-replicator.c
+++ b/drivers/hwtracing/coresight/coresight-replicator.c
@@ -335,11 +335,11 @@ static int replicator_runtime_resume(struct device *dev)
 {
 	struct replicator_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_prepare_enable(drvdata->atclk);
-
 	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
 		clk_prepare_enable(drvdata->pclk);
+
+	if (drvdata && !IS_ERR(drvdata->atclk))
+		clk_prepare_enable(drvdata->atclk);
 	return 0;
 }
 #endif
diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index 23ba33ac4d2ed8d63f1e0fb922e7f6e44de86cd1..7b1e289f17ab2000816d8641fe0a79759452d3b4 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -969,11 +969,11 @@ static int stm_runtime_resume(struct device *dev)
 {
 	struct stm_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_prepare_enable(drvdata->atclk);
-
 	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
 		clk_prepare_enable(drvdata->pclk);
+
+	if (drvdata && !IS_ERR(drvdata->atclk))
+		clk_prepare_enable(drvdata->atclk);
 	return 0;
 }
 #endif
diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c
index 5e47d761e1c4e99072eeb492c1eac7dd4285a591..1c5c2a82971490888c45508c68b516ab7dbf3eeb 100644
--- a/drivers/hwtracing/coresight/coresight-tpiu.c
+++ b/drivers/hwtracing/coresight/coresight-tpiu.c
@@ -218,11 +218,11 @@ static int tpiu_runtime_resume(struct device *dev)
 {
 	struct tpiu_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_prepare_enable(drvdata->atclk);
-
 	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
 		clk_prepare_enable(drvdata->pclk);
+
+	if (drvdata && !IS_ERR(drvdata->atclk))
+		clk_prepare_enable(drvdata->atclk);
 	return 0;
 }
 #endif

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v5 10/10] coresight: Refactor runtime PM
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
                   ` (8 preceding siblings ...)
  2025-07-24 15:22 ` [PATCH v5 09/10] coresight: Make clock sequence consistent Leo Yan
@ 2025-07-24 15:22 ` Leo Yan
  2025-07-25  8:45 ` [PATCH v5 00/10] coresight: Fix and improve clock usage James Clark
  2025-07-25  9:22 ` Suzuki K Poulose
  11 siblings, 0 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-24 15:22 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman
  Cc: coresight, linux-arm-kernel, linux-kernel, Leo Yan

The validation for driver data pointers and clock pointers are redundant
in the runtime PM callbacks.  After a driver's probing, its driver data
and clocks have been initialized successfully, this ensures it is safe
to access driver data and clocks in the runtime PM callbacks.  A corner
case is a clock pointer is NULL, in this case, the clock core layer can
handle it properly.  So remove these redundant checking.

In runtime resume, respect values returned from clock function and add
error handling.

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 drivers/hwtracing/coresight/coresight-cpu-debug.c  |  8 +++-----
 drivers/hwtracing/coresight/coresight-ctcu-core.c  |  8 ++------
 drivers/hwtracing/coresight/coresight-etb10.c      |  8 ++------
 drivers/hwtracing/coresight/coresight-etm3x-core.c |  8 ++------
 drivers/hwtracing/coresight/coresight-funnel.c     | 21 +++++++++++----------
 drivers/hwtracing/coresight/coresight-replicator.c | 20 +++++++++++---------
 drivers/hwtracing/coresight/coresight-stm.c        | 20 +++++++++++---------
 drivers/hwtracing/coresight/coresight-tpiu.c       | 20 +++++++++++---------
 8 files changed, 53 insertions(+), 60 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index 3edfb5d3d02056afcaab4da575d1101c68aeac80..5f21366406aae03edef9e4fb737e19941afb9ac2 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -731,8 +731,8 @@ static int debug_runtime_suspend(struct device *dev)
 {
 	struct debug_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_disable_unprepare(drvdata->pclk);
+	clk_disable_unprepare(drvdata->pclk);
+
 	return 0;
 }
 
@@ -740,9 +740,7 @@ static int debug_runtime_resume(struct device *dev)
 {
 	struct debug_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_prepare_enable(drvdata->pclk);
-	return 0;
+	return clk_prepare_enable(drvdata->pclk);
 }
 #endif
 
diff --git a/drivers/hwtracing/coresight/coresight-ctcu-core.c b/drivers/hwtracing/coresight/coresight-ctcu-core.c
index 75b5114ef652e4a47c53fbd2b7811c1bab575645..c586495e9a088a63cec481a82fd9f4ec7c645160 100644
--- a/drivers/hwtracing/coresight/coresight-ctcu-core.c
+++ b/drivers/hwtracing/coresight/coresight-ctcu-core.c
@@ -278,8 +278,7 @@ static int ctcu_runtime_suspend(struct device *dev)
 {
 	struct ctcu_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->apb_clk))
-		clk_disable_unprepare(drvdata->apb_clk);
+	clk_disable_unprepare(drvdata->apb_clk);
 
 	return 0;
 }
@@ -288,10 +287,7 @@ static int ctcu_runtime_resume(struct device *dev)
 {
 	struct ctcu_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->apb_clk))
-		clk_prepare_enable(drvdata->apb_clk);
-
-	return 0;
+	return clk_prepare_enable(drvdata->apb_clk);
 }
 #endif
 
diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index 8e81b41eb22264f17606050fa8da277aae05c5cc..35db1b6093d154d67dc567df42f838e2ba3d1d58 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -809,8 +809,7 @@ static int etb_runtime_suspend(struct device *dev)
 {
 	struct etb_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->atclk);
 
 	return 0;
 }
@@ -819,10 +818,7 @@ static int etb_runtime_resume(struct device *dev)
 {
 	struct etb_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_prepare_enable(drvdata->atclk);
-
-	return 0;
+	return clk_prepare_enable(drvdata->atclk);
 }
 #endif
 
diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/hwtracing/coresight/coresight-etm3x-core.c
index baba2245b1dfb31f4bf19080e20c33df3a5b854f..45630a1cd32fbd05ec8b2a6979f0174cacce365e 100644
--- a/drivers/hwtracing/coresight/coresight-etm3x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c
@@ -925,8 +925,7 @@ static int etm_runtime_suspend(struct device *dev)
 {
 	struct etm_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->atclk);
 
 	return 0;
 }
@@ -935,10 +934,7 @@ static int etm_runtime_resume(struct device *dev)
 {
 	struct etm_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_prepare_enable(drvdata->atclk);
-
-	return 0;
+	return clk_prepare_enable(drvdata->atclk);
 }
 #endif
 
diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
index 9dcfc5ce8845d9e01bb956dddab0d64de51ec397..3b248e54471a38f501777fe162fea850d1c851b3 100644
--- a/drivers/hwtracing/coresight/coresight-funnel.c
+++ b/drivers/hwtracing/coresight/coresight-funnel.c
@@ -284,11 +284,8 @@ static int funnel_runtime_suspend(struct device *dev)
 {
 	struct funnel_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_disable_unprepare(drvdata->atclk);
-
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_disable_unprepare(drvdata->pclk);
+	clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->pclk);
 
 	return 0;
 }
@@ -296,13 +293,17 @@ static int funnel_runtime_suspend(struct device *dev)
 static int funnel_runtime_resume(struct device *dev)
 {
 	struct funnel_drvdata *drvdata = dev_get_drvdata(dev);
+	int ret;
+
+	ret = clk_prepare_enable(drvdata->pclk);
+	if (ret)
+		return ret;
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_prepare_enable(drvdata->pclk);
+	ret = clk_prepare_enable(drvdata->atclk);
+	if (ret)
+		clk_disable_unprepare(drvdata->pclk);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_prepare_enable(drvdata->atclk);
-	return 0;
+	return ret;
 }
 #endif
 
diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
index e53095603b0c0419bc96a66b23d15bb54e75e634..e6472658235dc479cec91ac18f3737f76f8c74f0 100644
--- a/drivers/hwtracing/coresight/coresight-replicator.c
+++ b/drivers/hwtracing/coresight/coresight-replicator.c
@@ -323,24 +323,26 @@ static int replicator_runtime_suspend(struct device *dev)
 {
 	struct replicator_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->pclk);
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_disable_unprepare(drvdata->pclk);
 	return 0;
 }
 
 static int replicator_runtime_resume(struct device *dev)
 {
 	struct replicator_drvdata *drvdata = dev_get_drvdata(dev);
+	int ret;
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_prepare_enable(drvdata->pclk);
+	ret = clk_prepare_enable(drvdata->pclk);
+	if (ret)
+		return ret;
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_prepare_enable(drvdata->atclk);
-	return 0;
+	ret = clk_prepare_enable(drvdata->atclk);
+	if (ret)
+		clk_disable_unprepare(drvdata->pclk);
+
+	return ret;
 }
 #endif
 
diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index 7b1e289f17ab2000816d8641fe0a79759452d3b4..e68529bf89c9815a8118955bf3114ad1ed4fb346 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -957,24 +957,26 @@ static int stm_runtime_suspend(struct device *dev)
 {
 	struct stm_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->pclk);
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_disable_unprepare(drvdata->pclk);
 	return 0;
 }
 
 static int stm_runtime_resume(struct device *dev)
 {
 	struct stm_drvdata *drvdata = dev_get_drvdata(dev);
+	int ret;
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_prepare_enable(drvdata->pclk);
+	ret = clk_prepare_enable(drvdata->pclk);
+	if (ret)
+		return ret;
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_prepare_enable(drvdata->atclk);
-	return 0;
+	ret = clk_prepare_enable(drvdata->atclk);
+	if (ret)
+		clk_disable_unprepare(drvdata->pclk);
+
+	return ret;
 }
 #endif
 
diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c
index 1c5c2a82971490888c45508c68b516ab7dbf3eeb..9463afdbda8ad74eee78c72185fe7603f81b7888 100644
--- a/drivers/hwtracing/coresight/coresight-tpiu.c
+++ b/drivers/hwtracing/coresight/coresight-tpiu.c
@@ -206,24 +206,26 @@ static int tpiu_runtime_suspend(struct device *dev)
 {
 	struct tpiu_drvdata *drvdata = dev_get_drvdata(dev);
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->atclk);
+	clk_disable_unprepare(drvdata->pclk);
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_disable_unprepare(drvdata->pclk);
 	return 0;
 }
 
 static int tpiu_runtime_resume(struct device *dev)
 {
 	struct tpiu_drvdata *drvdata = dev_get_drvdata(dev);
+	int ret;
 
-	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
-		clk_prepare_enable(drvdata->pclk);
+	ret = clk_prepare_enable(drvdata->pclk);
+	if (ret)
+		return ret;
 
-	if (drvdata && !IS_ERR(drvdata->atclk))
-		clk_prepare_enable(drvdata->atclk);
-	return 0;
+	ret = clk_prepare_enable(drvdata->atclk);
+	if (ret)
+		clk_disable_unprepare(drvdata->pclk);
+
+	return ret;
 }
 #endif
 

-- 
2.34.1



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 00/10] coresight: Fix and improve clock usage
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
                   ` (9 preceding siblings ...)
  2025-07-24 15:22 ` [PATCH v5 10/10] coresight: Refactor runtime PM Leo Yan
@ 2025-07-25  8:45 ` James Clark
  2025-07-25  9:22 ` Suzuki K Poulose
  11 siblings, 0 replies; 24+ messages in thread
From: James Clark @ 2025-07-25  8:45 UTC (permalink / raw)
  To: Leo Yan
  Cc: coresight, linux-arm-kernel, linux-kernel, Suzuki K Poulose,
	Mike Leach, Anshuman Khandual, Yeoreum Yun, Alexander Shishkin,
	Greg Kroah-Hartman



On 24/07/2025 4:22 pm, Leo Yan wrote:
> This series fixes and improves clock usage in the Arm CoreSight drivers.
> 
> Based on the DT binding documents, the trace clock (atclk) is defined in
> some CoreSight modules, but support is absent. In most cases, the issue
> is hidden because the atclk clock is shared by multiple CoreSight
> modules and the clock is enabled anyway by other drivers. The first
> three patches address this issue.
> 
> The programming clock (pclk) management in CoreSight drivers does not
> use the devm_XXX() variant APIs, the drivers needs to manually disable
> and release clocks for errors and for normal module exit.  However, the
> drivers miss to disable clocks during module exit. The atclk may also
> not be disabled in CoreSight drivers during module exit. By using devm
> APIs, patches 04 and 05 fix clock disabling issues.
> 
> Another issue is pclk might be enabled twice in init phase - once by
> AMBA bus driver, and again by CoreSight drivers. This is fixed in
> patch 06.
> 
> Patches 07 to 10 refactor the clock related code. Patch 07 consolidates
> the clock initialization into a central place. Patch 08 polishes driver
> data allocation. Patch 09 makes the clock enabling sequence consistent.
> Patch 09 removes redundant condition checks and adds error handling in
> runtime PM.
> 
> This series has been verified on Arm64 Juno platform, for both DT and
> ACPI modes.
> 

Tested on N1SDP with ACPI:

Tested-by: James Clark <james.clark@linaro.org>

> ---
> Changes in v5:
> - Skip clock management for ACPI devices (Suzuki).
> - Link to v4: https://lore.kernel.org/r/20250627-arm_cs_fix_clock_v4-v4-0-0ce0009c38f8@arm.com
> 
> Changes in v4:
> - Separated patch 07 into two patches, one is for clock consolidation
>    and another is for polishing driver data allocation (Anshuman).
> 
> Changes in v3:
> - Updated subjects for patches 04 and 05 (Anshuman).
> - Refined condition checking "if (dev_is_amba(dev))" in patch 07
>    (Anshuman).
> 
> ---
> Leo Yan (10):
>        coresight: tmc: Support atclk
>        coresight: catu: Support atclk
>        coresight: etm4x: Support atclk
>        coresight: Appropriately disable programming clocks
>        coresight: Appropriately disable trace bus clocks
>        coresight: Avoid enable programming clock duplicately
>        coresight: Consolidate clock enabling
>        coresight: Refactor driver data allocation
>        coresight: Make clock sequence consistent
>        coresight: Refactor runtime PM
> 
>   drivers/hwtracing/coresight/coresight-catu.c       | 53 ++++++++---------
>   drivers/hwtracing/coresight/coresight-catu.h       |  1 +
>   drivers/hwtracing/coresight/coresight-core.c       | 48 ++++++++++++++++
>   drivers/hwtracing/coresight/coresight-cpu-debug.c  | 41 +++++---------
>   drivers/hwtracing/coresight/coresight-ctcu-core.c  | 24 +++-----
>   drivers/hwtracing/coresight/coresight-etb10.c      | 18 ++----
>   drivers/hwtracing/coresight/coresight-etm3x-core.c | 17 ++----
>   drivers/hwtracing/coresight/coresight-etm4x-core.c | 32 ++++++-----
>   drivers/hwtracing/coresight/coresight-etm4x.h      |  4 +-
>   drivers/hwtracing/coresight/coresight-funnel.c     | 66 ++++++++--------------
>   drivers/hwtracing/coresight/coresight-replicator.c | 63 ++++++++-------------
>   drivers/hwtracing/coresight/coresight-stm.c        | 34 +++++------
>   drivers/hwtracing/coresight/coresight-tmc-core.c   | 48 ++++++++--------
>   drivers/hwtracing/coresight/coresight-tmc.h        |  2 +
>   drivers/hwtracing/coresight/coresight-tpiu.c       | 36 +++++-------
>   include/linux/coresight.h                          | 31 +---------
>   16 files changed, 228 insertions(+), 290 deletions(-)
> ---
> base-commit: a80198ba650f50d266d7fc4a6c5262df9970f9f2
> change-id: 20250627-arm_cs_fix_clock_v4-e24b1e1f8920
> 
> Best regards,



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 00/10] coresight: Fix and improve clock usage
  2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
                   ` (10 preceding siblings ...)
  2025-07-25  8:45 ` [PATCH v5 00/10] coresight: Fix and improve clock usage James Clark
@ 2025-07-25  9:22 ` Suzuki K Poulose
  2025-07-29 12:31   ` Suzuki K Poulose
  11 siblings, 1 reply; 24+ messages in thread
From: Suzuki K Poulose @ 2025-07-25  9:22 UTC (permalink / raw)
  To: Mike Leach, James Clark, Anshuman Khandual, Yeoreum Yun,
	Alexander Shishkin, Greg Kroah-Hartman, Leo Yan
  Cc: Suzuki K Poulose, coresight, linux-arm-kernel, linux-kernel


On Thu, 24 Jul 2025 16:22:30 +0100, Leo Yan wrote:
> This series fixes and improves clock usage in the Arm CoreSight drivers.
> 
> Based on the DT binding documents, the trace clock (atclk) is defined in
> some CoreSight modules, but support is absent. In most cases, the issue
> is hidden because the atclk clock is shared by multiple CoreSight
> modules and the clock is enabled anyway by other drivers. The first
> three patches address this issue.
> 
> [...]

Applied, thanks!

[01/10] coresight: tmc: Support atclk
        https://git.kernel.org/coresight/c/e96d605a66ff
[02/10] coresight: catu: Support atclk
        https://git.kernel.org/coresight/c/7eca4399060d
[03/10] coresight: etm4x: Support atclk
        https://git.kernel.org/coresight/c/14fb833b8204
[04/10] coresight: Appropriately disable programming clocks
        https://git.kernel.org/coresight/c/ce15ee28bddd
[05/10] coresight: Appropriately disable trace bus clocks
        https://git.kernel.org/coresight/c/90b0000bd501
[06/10] coresight: Avoid enable programming clock duplicately
        https://git.kernel.org/coresight/c/5c0ead76597b
[07/10] coresight: Consolidate clock enabling
        https://git.kernel.org/coresight/c/f47d7f7da638
[08/10] coresight: Refactor driver data allocation
        https://git.kernel.org/coresight/c/7471c81e60b9
[09/10] coresight: Make clock sequence consistent
        https://git.kernel.org/coresight/c/d4cf59aa905b
[10/10] coresight: Refactor runtime PM
        https://git.kernel.org/coresight/c/2b52cf338d39

Best regards,
-- 
Suzuki K Poulose <suzuki.poulose@arm.com>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 04/10] coresight: Appropriately disable programming clocks
  2025-07-24 15:22 ` [PATCH v5 04/10] coresight: Appropriately disable programming clocks Leo Yan
@ 2025-07-28 16:18   ` Mark Brown
  2025-07-28 16:44   ` Mark Brown
  1 sibling, 0 replies; 24+ messages in thread
From: Mark Brown @ 2025-07-28 16:18 UTC (permalink / raw)
  To: Leo Yan
  Cc: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman, coresight,
	linux-arm-kernel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 36597 bytes --]

On Thu, Jul 24, 2025 at 04:22:34PM +0100, Leo Yan wrote:
> Some CoreSight components have programming clocks (pclk) and are enabled
> using clk_get() and clk_prepare_enable().  However, in many cases, these
> clocks are not disabled when modules exit and only released by clk_put().

This patch, which is in -next as ce15ee28bdddc49d18c4e296859456b819cf0690,
appears to cause the funnel device to stop probing on the i.MX8MP based
Verdin module, I also have the i.MX8MP-EVK but that has potentially
separate boot issues.  The device fails to probe with:

[   15.080552] coresight-funnel funnel: probe with driver coresight-funnel failed with error -2

and a bisect identifies this commit as the cuplprit.  Full log at:

   https://lava.sirena.org.uk/scheduler/job/1612972#L1661

bisect log:

# bad: [0b90c3b6d76ea512dc3dac8fb30215e175b0019a] Add linux-next specific files for 20250728
# good: [60a48532c31d9d652a1e3a92ff7d620ff4545e8c] Merge branch 'tip/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
# good: [2d442a0c781403702de27ccfbc4bb233721585f5] spi: SPISG: Fix less than zero comparison on a u32 variable
# good: [e95122a32e777309412e30dc638dbc88b9036811] ASoC: codecs: Add acpi_match_table for aw88399 driver
# good: [87aa3c8d8c4aa2e2567fe04126d14eb9fde815e5] spi: intel: Allow writeable MTD partition with module param
# good: [ffc72771ff6ec9f5b431a86c4b00d8ef0fea958b] regmap: Annotate that MMIO implies fast IO
# good: [0bd042ae771d61ef7ccd5882f7aeca59a25f71d9] regulator: mt6370: Fix spelling mistake in mt6370_regualtor_register
# good: [50a479527ef01f9b36dde1803a7e81741a222509] ASoC: SDCA: Add support for -cn- value properties
# good: [f6b159431697c903da1418e70c825faa0cddbdae] spi: spi-sg2044-nor: Add SPI-NOR controller for SG2042
# good: [da98e8b97058c73b5c58e9976af2e7286f1c799b] ASoC: dt-bindings: atmel,at91-ssc: add microchip,sam9x7-ssc
# good: [6776ecc9dd587c08a6bb334542f9f8821a091013] ASoC: fsl_xcvr: get channel status data with firmware exists
# good: [71d141edbfa3e0a213c537e979790835550270d6] regulator: Kconfig: Fix spelling mistake "regualtor" -> "regulator"
# good: [8b61c8919dff080d83415523cd68f2fef03ccfc7] spi: Add driver for the RZ/V2H(P) RSPI IP
# good: [0ef2a9779e9decee52a85bc393309b3e068a74a6] MAINTAINERS: Add an entry for Amlogic spi driver
# good: [c58c35ef6ae62e36927f506a5afc66610b7261d9] ASoC: qcom: sm8250: Add Fairphone 4 soundcard compatible
# good: [1f590fa4b93dd7c7daaa4e09d8381ac2aab3853c] spi: spi-qpic-snand: simplify bad block marker duplication
# good: [246570cd351299959822ac21e75e2975f80ce4b7] ASoC: SDCA: Fix implicit cast from le16
# good: [59c5dbd585a0bee70e51fcdf36185f7602b9c285] ASoC: SDCA: Shrink detected_mode_handler() stack frame
# good: [17882721dcb49323eaa9728d7eaa2ae826c876f7] ASoC: SDCA: add route by the number of input pins in MU entity
# good: [d60f7cab7c04944a79af16caa43c141e780a59c6] spi: spidev: Add an entry for the ABB spi sensors
# good: [d511206dc7443120637efd9cfa3ab06a26da33dd] regulator: core: repeat voltage setting request for stepped regulators
# good: [951a6d8d41289b86a564ee5563ededa702b62b1b] spi: stm32-ospi: Fix NULL vs IS_ERR() bug in stm32_ospi_get_resources()
# good: [03aa2ed9e187e42f25b3871b691d535fc19156c4] ASoC: Intel: sof_rt5682: Add HDMI-In capture with rt5682 support for PTL.
# good: [63be976da994260ea116c431a2e61485dbede1b0] regulator: rt6160: Add rt6166 vout min_uV setting for compatible
# good: [8778837f0a5b7c1bc5dbf0cccd7619fec6981588] ASoC: codec: tlv320aic32x4: Fix reset GPIO check
# good: [d929cc75e9791def049a90998aaab8934196131c] spi: gpio: Use explicit 'unsigned int' for parameter types
# good: [d5255ae7ec48ac1f702e95b472801dbb7bf1e97f] spi: dt-bindings: spi-mux: Drop "spi-max-frequency" as required
# good: [4ed357f72a0e0a691304e5f14a3323811c8ce862] ASoC: SDCA: Add hw_params() helper function
# good: [d9f334fca5448907cc47ba8553926f9ba148512f] MAINTAINERS: add regulator.rs to the regulator API entry
# good: [d5f317fd5cd9dfdf5bbe11384001817760c12b75] ASoC: stm: stm32_sai_sub: convert from round_rate() to determine_rate()
# good: [15247b5a63f506125360fa45d7aa1fbe8b903b95] ASoC: SDCA: Update memory allocations to zero initialise
# good: [6f8584a4826f01a55d3d0c4bbad5961f1de52fc9] spi: st: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
# good: [43728a6434f9eca0385fd180d8452a5071678a5b] regulator: tps6286x-regulator: Fix a copy & paste error
# good: [790d5f8ee6f2a27686d042abbce16b4e03ac1608] ASoC: codec: tlv320aic32x4: Convert to GPIO descriptors
# good: [af241e3fa4d823f8af899c92fd50d020816a1860] ASoC: fsl-asoc-card: add sysclk_ratio for calculate sysclk frequency
# good: [3aa47d2ec83316c24e1ed15a492b331802dc6a69] regulator: qcom-rpmh: add support for pm7550 regulators
# good: [5030abcb0aa3304bf91497844ffa9607a2d4ad5d] ASoC: SDCA: Pull HID and IRQ into the primary SDCA module
# good: [f00e06296ba3f0d8440030afe8cc2258758b7af7] ASoC: samsung: littlemill: don't set dapm->bias_level directly
# good: [b30d390812c8559c5835f8ae5f490b38488fafc8] regulator: tps6594-regulator: Add TI TPS652G1 PMIC regulators
# good: [7d61715c58a39edc5f74fc7366487726fc223530] spi: rspi: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
# good: [ad4655653a6c463026ed3c300e5fb34f39abff48] ASoC: SDCA: fix HID dependency
# good: [c61da55412a08268ea0cdef99dea11f7ade934ee] ASoC: sdw_utils: Add missed component_name strings for speaker amps
# good: [68e4dadacb7faa393b532b41bbf99a2dbfec3b1b] ASoC: img: Imagination Technologies sound should depend on MIPS
# good: [defe01abfb7f5c5bd53c723b8577d4fcd64faa5a] spi: stm32-ospi: Use of_reserved_mem_region_to_resource() for "memory-region"
# good: [86ccd4d3e8bc9eeb5dde4080fcc67e0505d1d2c6] ASoC: Intel: soc-acpi-intel-lnl-match: add rt1320_l12_rt714_l0 support
# good: [67bdd67aedcec8c63e3158c3c82991fbde0c4d22] ASoC: rt715: don't set dapm->bias_level
# good: [5054740e0092aac528c0589251f612b3b41c9e7b] regulator: sy8827n: make enable gpio NONEXCLUSIVE
# good: [08dc0f5cc26a203e8008c38d9b436c079e7dbb45] ASoC: soc-dapm: add prefix on soc_dapm_dev_attrs
# good: [2fca750160f29015ab1109bb478537a4e415f7cd] spi: Remove redundant pm_runtime_mark_last_busy() calls
# good: [571defe0dff3f1e4180bd0db79283d3d5bf74a71] ASoC: codec: rockchip_sai: Remove including of_gpio.h
# good: [2bd9648d5a8d329ca734ca2c273a80934867471e] ASoC: SOF: Remove redundant pm_runtime_mark_last_busy() calls
# good: [c61e94e5e4e6bc50064119e6a779564d1d2ac0e7] regulator: stm32-vrefbuf: Remove redundant pm_runtime_mark_last_busy() calls
# good: [9f711c9321cffe3e03709176873c277fa911c366] regmap: get rid of redundant debugfs_file_{get,put}()
# good: [bc163baef57002c08b3afe64cdd2f55f55a765eb] ASoC: Use of_reserved_mem_region_to_resource() for "memory-region"
# good: [baee26a9d6cd3d3c6c3c03c56270aa647a67e4bd] ASoC: fsl_mqs: rename system manager indices for i.MX95
# good: [7105fdd54a14bee49371b39374a61b3c967d74cb] spi: dt-bindings: Convert marvell,orion-spi to DT schema
# good: [913bf8d50cbd144c87e9660b591781179182ff59] spi: spi-qpic-snand: add support for 8 bits ECC strength
# good: [0c0ef1d90967717b91cded41b00dbae05d8e521c] ASoC: amd: acp: Enable acp7.2 platform based DMIC support in machine driver
# good: [34d340d48e595f8dfd4e72fe4100d2579dbe4a1a] ASoC: qcom: sc8280xp: Add support for QCS8275
# good: [3fcd3d2fe44dc9dfca20b6aed117f314a50ba0ff] spi: offload trigger: add ADI Util Sigma-Delta SPI driver
# good: [244bc18e5f1875401a4af87d2eae3f9376d9d720] spi: stm32: delete stray tabs in stm32h7_spi_data_idleness()
# good: [fc0d2840a00d75931777e6dba55fcce40f34a24a] arm64: dts: imx93-11x11-evk: remove the duplicated pinctrl_lpi2c3 node
# good: [b6fb05efd90e0f0bfc3e3d2557b6aa1c65fcbfa6] arm64: dts: imx93-11x11-evk: reduce the driving strength of net RXC/TXC
# good: [b63ae4182b6afa89ad0f7cff9c932328d887b936] ARM: dts: imx28: add pwm7 muxing options
# good: [b9ab3b61824190b1c6b2c59e7ba4de591f24eb92] ASoC: SDCA: Add some initial IRQ handlers
# good: [c4f2c05ab02952c9a56067aeb700ded95b183570] spi: stm32: fix pointer-to-pointer variables usage
# good: [7e1c28fbf235791cb5046fafdac5bc16fe8e788d] spi: spi-pci1xxxx: enable concurrent DMA read/write across SPI transfers
# good: [427ceac823e58813b510e585011488f603f0d891] regulator: tps6286x-regulator: Enable REGCACHE_MAPLE
# good: [29ddce17e909779633f856ad1c2f111fbf71c0df] ASoC: codecs: Add calibration function to aw88399 chip
# good: [ac4c064f67d3cdf9118b9b09c1e3b28b6c10a7ea] spi: dt-bindings: add nxp,lpc3220-spi.yaml
# good: [2555691165a0285a4617230fed859f20dcc51608] spi: atmel-quadspi: Use `devm_dma_request_chan()`
# good: [ce57bc9771411d6d27f2ca7b40396cbd7d684ba9] regulator: core: Don't use "proxy" headers
# good: [08bf1663c21a3e815eda28fa242d84c945ca3b94] dmaengine: Add devm_dma_request_chan()
# good: [0f60ecffbfe35e12eb56c99640ba2360244b5bb3] ASoC: sdw_utils: generate combined spk components string
# good: [9a944494c299fabf3cc781798eb7c02a0bece364] spi: dt-bindings: stm32: deprecate `st,spi-midi-ns` property
# good: [3e36c822506d924894ff7de549b9377d3114c2d7] spi: spi-pci1xxxx: Add support for per-instance DMA interrupt vectors
# good: [68fbc70ece40139380380dce74059afa592846b3] ASoC: hisilicon: Standardize ASoC menu
# good: [8f9cf02c8852837923f1cdacfcc92e138513325c] spi: microchip-core-qspi: Add regular transfers
# good: [17cc308b183308bf5ada36e164284fff7eb064ba] ASoC: wm8524: enable constraints when sysclk is configured.
# good: [59566923d955b69bfb1e1163f07dff437dde8c9c] ASoC: SOF: amd: add alternate machines for ACP7.0 and ACP7.1 platforms
# good: [024f39fff6d222cedde361f7fe34d9ba4e6afb92] regulator: mtk-dvfsrc: Add support for MediaTek MT8196 DVFSRC
# good: [19cbc930c209d59a2c9828de4c7b767e9f14667e] regulator: pca9450: Support PWM mode also for pca9451a
# good: [c4ca928a6db1593802cd945f075a7e21dd0430c1] ASoC: hdac_hdmi: Rate limit logging on connection and disconnection
# good: [a48352921f0b15b1f7eff83f5b5613d6ae2350d3] ASoC: codecs: wcd939x: Add defines for major/minor version decoding
# good: [3421d46440ebe0865bec71dbd2330b4e17a425ab] HID: core: Add bus define for SoundWire bus
# good: [a1d203d390e04798ccc1c3c06019cd4411885d6d] ASoC: SOF: ipc4-pcm: Enable delay reporting for ChainDMA streams
# good: [2756b7f08ff6ca7c68c8c7dd61c8dc6895c9de34] ASoC: SOF: ipc4-pcm: Harmonize sof_ipc4_set_pipeline_state() dbg print
# good: [ace9b3daf2b4778358573d3698e34cb1c0fa7e14] ASoC: SOF: ipc4/Intel: Add support for library restore firmware functionality
# good: [bb48117b79ebc39485f7306d09dc602981fe540f] ASoC: Intel: sof_sdw: Implement add_dai_link to filter HDMI PCMs
# good: [cd4da713f99651e99fbce8ed6b6ec8f686c029a8] Documentation: PM: *_autosuspend() functions update last busy time
# good: [5fc2c383125c2b4b6037e02ad8796b776b25e6d0] spi: falcon: mark falcon_sflash_xfer() as static
# good: [7f8924e8785b68c998bc1906e049bf5595865e60] ASoC: dt-bindings: cirrus,cs42xx8: add 'port' property
# good: [3e1c01d06e1f52f78fe00ef26a9cf80dbb0a3115] regulator: rpi-panel-v2: Add shutdown hook
# good: [d9f38d9824bfb1b046d2e720349d2f45959ab184] ASoC: tegra: AHUB: Remove unneeded semicolon
# good: [d03b53c9139352b744ed007bf562bd35517bacff] dt-bindings: gpio: gpio-xilinx: Mark clocks as required property
# good: [dce4bc30f42d313b4dc5832316196411b7f07ad0] spi: spi-fsl-dspi: Revert unintended dependency change in config SPI_FSL_DSPI
# good: [47972c1c3315672352f25c68f91dd88543541947] ASoC: Intel: Replace deprecated strcpy() with strscpy()
# good: [367864935785382bab95f5e5a691535d28f5a21b] gpio: raspberrypi-exp: use new GPIO line value setter callbacks
# good: [7b2c2f1eb3914f5214a5b2ae966d7d7bb0057582] gpio: Use dev_fwnode() where applicable across drivers
# good: [5eb8a0d7733d4cd32a776acf1d1aa1c7c01c8a14] ASoC: hdmi-codec: use SND_JACK_AVOUT as jack status
# good: [bb8d8ba4715cb8f997d63d90ba935f6073595df5] ASoC: mediatek: mt8183-afe-pcm: use local `dev` pointer in driver callbacks
# good: [8a5a5cecb79058b608e5562d8998123a3adb313c] ASoC: tas2781: Move the "include linux/debugfs.h" into tas2781.h
# good: [a4eb71ff98c4792f441f108910bd829da7a04092] regulator: rpi-panel-v2: Fix missing OF dependency
# good: [6cafcc53eb5fffd9b9bdfde700bb9bad21e98ed3] spi: spi-mt65xx: Add support for MT6991 Dimensity 9400 SPI IPM
# good: [7e10d7242ea8a5947878880b912ffa5806520705] ASoC: ops: dynamically allocate struct snd_ctl_elem_value
# good: [d6fa0ca959db8efd4462d7beef4bdc5568640fd0] regulator: rpi-panel-v2: Add missing GPIOLIB dependency
# good: [d49305862fdc4d9ff1b1093b4ed7d8e0cb9971b4] regulator: rpi-panel-v2: Add regulator for 7" Raspberry Pi 720x1280
# good: [1f5cdb6ab45e1c06ae0953609acbb52f8946b3e8] ASoC: codecs: Add support for Richtek RTQ9124
# good: [6ba68e5aa9d5d15c8877a655db279fcfc0b38b04] ASoC: renesas: msiof: Convert to <linux/spi/sh_msiof.h>
# good: [548d770c330cd1027549947a6ea899c56b5bc4e4] regulator: pca9450: Add support for mode operations
# good: [c459262159f39e6e6336797feb975799344b749b] spi: spi-pci1xxxx: Add support for 25MHz Clock frequency in C0
# good: [267be32b0a7b70cc777f8a46f0904c92c0521d89] ASoC: remove component->id
# good: [03b778d1994827ea5cc971dbdfbb457bbb7bfa5d] ASOC: rockchip: Use helper function devm_clk_get_enabled()
# good: [111a2c8ab462d77d1519b71b46f13ae1b46920b4] ASoC: imx-card: Use helper function for_each_child_of_node_scoped()
# good: [f6f914893d478b7ba08e5c375de1ced16deb5e92] ASoC: dt-bindings: tas57xx: add tas5753 compatibility
# good: [c95e925daa434ee1a40a86aec6476ce588e4bd77] ASoC: Intel: avs: Add rt5640 machine board
# good: [9a30e332c36c52e92e5316b4a012d45284dedeb5] spi: spi-fsl-dspi: Enable support for S32G platforms
# good: [c8c4694ede7ed42d8d4db0e8927dea9839a3e248] regmap: kunit: Constify regmap_range_cfg array
# good: [ac209bde018fd320b79976657a44c23113181af6] ASoC: tas2781: Drop the unnecessary symbol imply
# good: [b9ecde0bcf6a99a3ff08496d4ba90a385ebbfd68] ASoC: codecs: wcd939x: Add VDD_PX supply
# good: [ece5d881004f041c2e1493436409dbcbea3ad5f8] ASoC: codecs: wcd939x: Drop unused 'struct wcd939x_priv' fields
# good: [e6e8897995a9e6028563ce36c27877e5478c8571] ASoC: qcom: sm8250: Add Fairphone 5 soundcard compatible
# good: [7e17e80c3a7eb2734795f66ba946f933412d597f] Merge branch 'for-6.14/stack-order' into for-next
git bisect start '0b90c3b6d76ea512dc3dac8fb30215e175b0019a' '60a48532c31d9d652a1e3a92ff7d620ff4545e8c' '2d442a0c781403702de27ccfbc4bb233721585f5' 'e95122a32e777309412e30dc638dbc88b9036811' '87aa3c8d8c4aa2e2567fe04126d14eb9fde815e5' 'ffc72771ff6ec9f5b431a86c4b00d8ef0fea958b' '0bd042ae771d61ef7ccd5882f7aeca59a25f71d9' '50a479527ef01f9b36dde1803a7e81741a222509' 'f6b159431697c903da1418e70c825faa0cddbdae' 'da98e8b97058c73b5c58e9976af2e7286f1c799b' '6776ecc9dd587c08a6bb334542f9f8821a091013' '71d141edbfa3e0a213c537e979790835550270d6' '8b61c8919dff080d83415523cd68f2fef03ccfc7' '0ef2a9779e9decee52a85bc393309b3e068a74a6' 'c58c35ef6ae62e36927f506a5afc66610b7261d9' '1f590fa4b93dd7c7daaa4e09d8381ac2aab3853c' '246570cd351299959822ac21e75e2975f80ce4b7' '59c5dbd585a0bee70e51fcdf36185f7602b9c285' '17882721dcb49323eaa9728d7eaa2ae826c876f7' 'd60f7cab7c04944a79af16caa43c141e780a59c6' 'd511206dc7443120637efd9cfa3ab06a26da33dd' '951a6d8d41289b86a564ee5563ededa702b62b1b' '03aa2ed9e187e42f25b3871b691d535fc19156c4' '63be976da994260ea116c431a2e61485dbede1b0' '8778837f0a5b7c1bc5dbf0cccd7619fec6981588' 'd929cc75e9791def049a90998aaab8934196131c' 'd5255ae7ec48ac1f702e95b472801dbb7bf1e97f' '4ed357f72a0e0a691304e5f14a3323811c8ce862' 'd9f334fca5448907cc47ba8553926f9ba148512f' 'd5f317fd5cd9dfdf5bbe11384001817760c12b75' '15247b5a63f506125360fa45d7aa1fbe8b903b95' '6f8584a4826f01a55d3d0c4bbad5961f1de52fc9' '43728a6434f9eca0385fd180d8452a5071678a5b' '790d5f8ee6f2a27686d042abbce16b4e03ac1608' 'af241e3fa4d823f8af899c92fd50d020816a1860' '3aa47d2ec83316c24e1ed15a492b331802dc6a69' '5030abcb0aa3304bf91497844ffa9607a2d4ad5d' 'f00e06296ba3f0d8440030afe8cc2258758b7af7' 'b30d390812c8559c5835f8ae5f490b38488fafc8' '7d61715c58a39edc5f74fc7366487726fc223530' 'ad4655653a6c463026ed3c300e5fb34f39abff48' 'c61da55412a08268ea0cdef99dea11f7ade934ee' '68e4dadacb7faa393b532b41bbf99a2dbfec3b1b' 'defe01abfb7f5c5bd53c723b8577d4fcd64faa5a' '86ccd4d3e8bc9eeb5dde4080fcc67e0505d1d2c6' '67bdd67aedcec8c63e3158c3c82991fbde0c4d22' '5054740e0092aac528c0589251f612b3b41c9e7b' '08dc0f5cc26a203e8008c38d9b436c079e7dbb45' '2fca750160f29015ab1109bb478537a4e415f7cd' '571defe0dff3f1e4180bd0db79283d3d5bf74a71' '2bd9648d5a8d329ca734ca2c273a80934867471e' 'c61e94e5e4e6bc50064119e6a779564d1d2ac0e7' '9f711c9321cffe3e03709176873c277fa911c366' 'bc163baef57002c08b3afe64cdd2f55f55a765eb' 'baee26a9d6cd3d3c6c3c03c56270aa647a67e4bd' '7105fdd54a14bee49371b39374a61b3c967d74cb' '913bf8d50cbd144c87e9660b591781179182ff59' '0c0ef1d90967717b91cded41b00dbae05d8e521c' '34d340d48e595f8dfd4e72fe4100d2579dbe4a1a' '3fcd3d2fe44dc9dfca20b6aed117f314a50ba0ff' '244bc18e5f1875401a4af87d2eae3f9376d9d720' 'fc0d2840a00d75931777e6dba55fcce40f34a24a' 'b6fb05efd90e0f0bfc3e3d2557b6aa1c65fcbfa6' 'b63ae4182b6afa89ad0f7cff9c932328d887b936' 'b9ab3b61824190b1c6b2c59e7ba4de591f24eb92' 'c4f2c05ab02952c9a56067aeb700ded95b183570' '7e1c28fbf235791cb5046fafdac5bc16fe8e788d' '427ceac823e58813b510e585011488f603f0d891' '29ddce17e909779633f856ad1c2f111fbf71c0df' 'ac4c064f67d3cdf9118b9b09c1e3b28b6c10a7ea' '2555691165a0285a4617230fed859f20dcc51608' 'ce57bc9771411d6d27f2ca7b40396cbd7d684ba9' '08bf1663c21a3e815eda28fa242d84c945ca3b94' '0f60ecffbfe35e12eb56c99640ba2360244b5bb3' '9a944494c299fabf3cc781798eb7c02a0bece364' '3e36c822506d924894ff7de549b9377d3114c2d7' '68fbc70ece40139380380dce74059afa592846b3' '8f9cf02c8852837923f1cdacfcc92e138513325c' '17cc308b183308bf5ada36e164284fff7eb064ba' '59566923d955b69bfb1e1163f07dff437dde8c9c' '024f39fff6d222cedde361f7fe34d9ba4e6afb92' '19cbc930c209d59a2c9828de4c7b767e9f14667e' 'c4ca928a6db1593802cd945f075a7e21dd0430c1' 'a48352921f0b15b1f7eff83f5b5613d6ae2350d3' '3421d46440ebe0865bec71dbd2330b4e17a425ab' 'a1d203d390e04798ccc1c3c06019cd4411885d6d' '2756b7f08ff6ca7c68c8c7dd61c8dc6895c9de34' 'ace9b3daf2b4778358573d3698e34cb1c0fa7e14' 'bb48117b79ebc39485f7306d09dc602981fe540f' 'cd4da713f99651e99fbce8ed6b6ec8f686c029a8' '5fc2c383125c2b4b6037e02ad8796b776b25e6d0' '7f8924e8785b68c998bc1906e049bf5595865e60' '3e1c01d06e1f52f78fe00ef26a9cf80dbb0a3115' 'd9f38d9824bfb1b046d2e720349d2f45959ab184' 'd03b53c9139352b744ed007bf562bd35517bacff' 'dce4bc30f42d313b4dc5832316196411b7f07ad0' '47972c1c3315672352f25c68f91dd88543541947' '367864935785382bab95f5e5a691535d28f5a21b' '7b2c2f1eb3914f5214a5b2ae966d7d7bb0057582' '5eb8a0d7733d4cd32a776acf1d1aa1c7c01c8a14' 'bb8d8ba4715cb8f997d63d90ba935f6073595df5' '8a5a5cecb79058b608e5562d8998123a3adb313c' 'a4eb71ff98c4792f441f108910bd829da7a04092' '6cafcc53eb5fffd9b9bdfde700bb9bad21e98ed3' '7e10d7242ea8a5947878880b912ffa5806520705' 'd6fa0ca959db8efd4462d7beef4bdc5568640fd0' 'd49305862fdc4d9ff1b1093b4ed7d8e0cb9971b4' '1f5cdb6ab45e1c06ae0953609acbb52f8946b3e8' '6ba68e5aa9d5d15c8877a655db279fcfc0b38b04' '548d770c330cd1027549947a6ea899c56b5bc4e4' 'c459262159f39e6e6336797feb975799344b749b' '267be32b0a7b70cc777f8a46f0904c92c0521d89' '03b778d1994827ea5cc971dbdfbb457bbb7bfa5d' '111a2c8ab462d77d1519b71b46f13ae1b46920b4' 'f6f914893d478b7ba08e5c375de1ced16deb5e92' 'c95e925daa434ee1a40a86aec6476ce588e4bd77' '9a30e332c36c52e92e5316b4a012d45284dedeb5' 'c8c4694ede7ed42d8d4db0e8927dea9839a3e248' 'ac209bde018fd320b79976657a44c23113181af6' 'b9ecde0bcf6a99a3ff08496d4ba90a385ebbfd68' 'ece5d881004f041c2e1493436409dbcbea3ad5f8' 'e6e8897995a9e6028563ce36c27877e5478c8571' '7e17e80c3a7eb2734795f66ba946f933412d597f'
# test job: [2d442a0c781403702de27ccfbc4bb233721585f5] https://lava.sirena.org.uk/scheduler/job/1608649
# test job: [e95122a32e777309412e30dc638dbc88b9036811] https://lava.sirena.org.uk/scheduler/job/1607724
# test job: [87aa3c8d8c4aa2e2567fe04126d14eb9fde815e5] https://lava.sirena.org.uk/scheduler/job/1607785
# test job: [ffc72771ff6ec9f5b431a86c4b00d8ef0fea958b] https://lava.sirena.org.uk/scheduler/job/1607863
# test job: [0bd042ae771d61ef7ccd5882f7aeca59a25f71d9] https://lava.sirena.org.uk/scheduler/job/1605091
# test job: [50a479527ef01f9b36dde1803a7e81741a222509] https://lava.sirena.org.uk/scheduler/job/1604262
# test job: [f6b159431697c903da1418e70c825faa0cddbdae] https://lava.sirena.org.uk/scheduler/job/1604203
# test job: [da98e8b97058c73b5c58e9976af2e7286f1c799b] https://lava.sirena.org.uk/scheduler/job/1604511
# test job: [6776ecc9dd587c08a6bb334542f9f8821a091013] https://lava.sirena.org.uk/scheduler/job/1604444
# test job: [71d141edbfa3e0a213c537e979790835550270d6] https://lava.sirena.org.uk/scheduler/job/1603792
# test job: [8b61c8919dff080d83415523cd68f2fef03ccfc7] https://lava.sirena.org.uk/scheduler/job/1604568
# test job: [0ef2a9779e9decee52a85bc393309b3e068a74a6] https://lava.sirena.org.uk/scheduler/job/1603982
# test job: [c58c35ef6ae62e36927f506a5afc66610b7261d9] https://lava.sirena.org.uk/scheduler/job/1600231
# test job: [1f590fa4b93dd7c7daaa4e09d8381ac2aab3853c] https://lava.sirena.org.uk/scheduler/job/1599937
# test job: [246570cd351299959822ac21e75e2975f80ce4b7] https://lava.sirena.org.uk/scheduler/job/1595440
# test job: [59c5dbd585a0bee70e51fcdf36185f7602b9c285] https://lava.sirena.org.uk/scheduler/job/1594678
# test job: [17882721dcb49323eaa9728d7eaa2ae826c876f7] https://lava.sirena.org.uk/scheduler/job/1592665
# test job: [d60f7cab7c04944a79af16caa43c141e780a59c6] https://lava.sirena.org.uk/scheduler/job/1592406
# test job: [d511206dc7443120637efd9cfa3ab06a26da33dd] https://lava.sirena.org.uk/scheduler/job/1585934
# test job: [951a6d8d41289b86a564ee5563ededa702b62b1b] https://lava.sirena.org.uk/scheduler/job/1579912
# test job: [03aa2ed9e187e42f25b3871b691d535fc19156c4] https://lava.sirena.org.uk/scheduler/job/1580023
# test job: [63be976da994260ea116c431a2e61485dbede1b0] https://lava.sirena.org.uk/scheduler/job/1578734
# test job: [8778837f0a5b7c1bc5dbf0cccd7619fec6981588] https://lava.sirena.org.uk/scheduler/job/1578568
# test job: [d929cc75e9791def049a90998aaab8934196131c] https://lava.sirena.org.uk/scheduler/job/1578406
# test job: [d5255ae7ec48ac1f702e95b472801dbb7bf1e97f] https://lava.sirena.org.uk/scheduler/job/1575898
# test job: [4ed357f72a0e0a691304e5f14a3323811c8ce862] https://lava.sirena.org.uk/scheduler/job/1575105
# test job: [d9f334fca5448907cc47ba8553926f9ba148512f] https://lava.sirena.org.uk/scheduler/job/1573838
# test job: [d5f317fd5cd9dfdf5bbe11384001817760c12b75] https://lava.sirena.org.uk/scheduler/job/1574065
# test job: [15247b5a63f506125360fa45d7aa1fbe8b903b95] https://lava.sirena.org.uk/scheduler/job/1574632
# test job: [6f8584a4826f01a55d3d0c4bbad5961f1de52fc9] https://lava.sirena.org.uk/scheduler/job/1573953
# test job: [43728a6434f9eca0385fd180d8452a5071678a5b] https://lava.sirena.org.uk/scheduler/job/1565302
# test job: [790d5f8ee6f2a27686d042abbce16b4e03ac1608] https://lava.sirena.org.uk/scheduler/job/1563425
# test job: [af241e3fa4d823f8af899c92fd50d020816a1860] https://lava.sirena.org.uk/scheduler/job/1563277
# test job: [3aa47d2ec83316c24e1ed15a492b331802dc6a69] https://lava.sirena.org.uk/scheduler/job/1563161
# test job: [5030abcb0aa3304bf91497844ffa9607a2d4ad5d] https://lava.sirena.org.uk/scheduler/job/1563376
# test job: [f00e06296ba3f0d8440030afe8cc2258758b7af7] https://lava.sirena.org.uk/scheduler/job/1562391
# test job: [b30d390812c8559c5835f8ae5f490b38488fafc8] https://lava.sirena.org.uk/scheduler/job/1557141
# test job: [7d61715c58a39edc5f74fc7366487726fc223530] https://lava.sirena.org.uk/scheduler/job/1556515
# test job: [ad4655653a6c463026ed3c300e5fb34f39abff48] https://lava.sirena.org.uk/scheduler/job/1554886
# test job: [c61da55412a08268ea0cdef99dea11f7ade934ee] https://lava.sirena.org.uk/scheduler/job/1554475
# test job: [68e4dadacb7faa393b532b41bbf99a2dbfec3b1b] https://lava.sirena.org.uk/scheduler/job/1553556
# test job: [defe01abfb7f5c5bd53c723b8577d4fcd64faa5a] https://lava.sirena.org.uk/scheduler/job/1553627
# test job: [86ccd4d3e8bc9eeb5dde4080fcc67e0505d1d2c6] https://lava.sirena.org.uk/scheduler/job/1547948
# test job: [67bdd67aedcec8c63e3158c3c82991fbde0c4d22] https://lava.sirena.org.uk/scheduler/job/1548029
# test job: [5054740e0092aac528c0589251f612b3b41c9e7b] https://lava.sirena.org.uk/scheduler/job/1546903
# test job: [08dc0f5cc26a203e8008c38d9b436c079e7dbb45] https://lava.sirena.org.uk/scheduler/job/1546255
# test job: [2fca750160f29015ab1109bb478537a4e415f7cd] https://lava.sirena.org.uk/scheduler/job/1540301
# test job: [571defe0dff3f1e4180bd0db79283d3d5bf74a71] https://lava.sirena.org.uk/scheduler/job/1539760
# test job: [2bd9648d5a8d329ca734ca2c273a80934867471e] https://lava.sirena.org.uk/scheduler/job/1539583
# test job: [c61e94e5e4e6bc50064119e6a779564d1d2ac0e7] https://lava.sirena.org.uk/scheduler/job/1538601
# test job: [9f711c9321cffe3e03709176873c277fa911c366] https://lava.sirena.org.uk/scheduler/job/1538696
# test job: [bc163baef57002c08b3afe64cdd2f55f55a765eb] https://lava.sirena.org.uk/scheduler/job/1538737
# test job: [baee26a9d6cd3d3c6c3c03c56270aa647a67e4bd] https://lava.sirena.org.uk/scheduler/job/1533847
# test job: [7105fdd54a14bee49371b39374a61b3c967d74cb] https://lava.sirena.org.uk/scheduler/job/1533532
# test job: [913bf8d50cbd144c87e9660b591781179182ff59] https://lava.sirena.org.uk/scheduler/job/1531295
# test job: [0c0ef1d90967717b91cded41b00dbae05d8e521c] https://lava.sirena.org.uk/scheduler/job/1530379
# test job: [34d340d48e595f8dfd4e72fe4100d2579dbe4a1a] https://lava.sirena.org.uk/scheduler/job/1530296
# test job: [3fcd3d2fe44dc9dfca20b6aed117f314a50ba0ff] https://lava.sirena.org.uk/scheduler/job/1528998
# test job: [244bc18e5f1875401a4af87d2eae3f9376d9d720] https://lava.sirena.org.uk/scheduler/job/1528326
# test job: [fc0d2840a00d75931777e6dba55fcce40f34a24a] https://lava.sirena.org.uk/scheduler/job/1531509
# test job: [b6fb05efd90e0f0bfc3e3d2557b6aa1c65fcbfa6] https://lava.sirena.org.uk/scheduler/job/1531006
# test job: [b63ae4182b6afa89ad0f7cff9c932328d887b936] https://lava.sirena.org.uk/scheduler/job/1531089
# test job: [b9ab3b61824190b1c6b2c59e7ba4de591f24eb92] https://lava.sirena.org.uk/scheduler/job/1526374
# test job: [c4f2c05ab02952c9a56067aeb700ded95b183570] https://lava.sirena.org.uk/scheduler/job/1526246
# test job: [7e1c28fbf235791cb5046fafdac5bc16fe8e788d] https://lava.sirena.org.uk/scheduler/job/1525641
# test job: [427ceac823e58813b510e585011488f603f0d891] https://lava.sirena.org.uk/scheduler/job/1525664
# test job: [29ddce17e909779633f856ad1c2f111fbf71c0df] https://lava.sirena.org.uk/scheduler/job/1523970
# test job: [ac4c064f67d3cdf9118b9b09c1e3b28b6c10a7ea] https://lava.sirena.org.uk/scheduler/job/1515921
# test job: [2555691165a0285a4617230fed859f20dcc51608] https://lava.sirena.org.uk/scheduler/job/1515764
# test job: [ce57bc9771411d6d27f2ca7b40396cbd7d684ba9] https://lava.sirena.org.uk/scheduler/job/1515820
# test job: [08bf1663c21a3e815eda28fa242d84c945ca3b94] https://lava.sirena.org.uk/scheduler/job/1517644
# test job: [0f60ecffbfe35e12eb56c99640ba2360244b5bb3] https://lava.sirena.org.uk/scheduler/job/1511602
# test job: [9a944494c299fabf3cc781798eb7c02a0bece364] https://lava.sirena.org.uk/scheduler/job/1507932
# test job: [3e36c822506d924894ff7de549b9377d3114c2d7] https://lava.sirena.org.uk/scheduler/job/1506359
# test job: [68fbc70ece40139380380dce74059afa592846b3] https://lava.sirena.org.uk/scheduler/job/1504183
# test job: [8f9cf02c8852837923f1cdacfcc92e138513325c] https://lava.sirena.org.uk/scheduler/job/1502895
# test job: [17cc308b183308bf5ada36e164284fff7eb064ba] https://lava.sirena.org.uk/scheduler/job/1501541
# test job: [59566923d955b69bfb1e1163f07dff437dde8c9c] https://lava.sirena.org.uk/scheduler/job/1499643
# test job: [024f39fff6d222cedde361f7fe34d9ba4e6afb92] https://lava.sirena.org.uk/scheduler/job/1499718
# test job: [19cbc930c209d59a2c9828de4c7b767e9f14667e] https://lava.sirena.org.uk/scheduler/job/1499004
# test job: [c4ca928a6db1593802cd945f075a7e21dd0430c1] https://lava.sirena.org.uk/scheduler/job/1499010
# test job: [a48352921f0b15b1f7eff83f5b5613d6ae2350d3] https://lava.sirena.org.uk/scheduler/job/1499007
# test job: [3421d46440ebe0865bec71dbd2330b4e17a425ab] https://lava.sirena.org.uk/scheduler/job/1493072
# test job: [a1d203d390e04798ccc1c3c06019cd4411885d6d] https://lava.sirena.org.uk/scheduler/job/1491497
# test job: [2756b7f08ff6ca7c68c8c7dd61c8dc6895c9de34] https://lava.sirena.org.uk/scheduler/job/1489214
# test job: [ace9b3daf2b4778358573d3698e34cb1c0fa7e14] https://lava.sirena.org.uk/scheduler/job/1489281
# test job: [bb48117b79ebc39485f7306d09dc602981fe540f] https://lava.sirena.org.uk/scheduler/job/1489352
# test job: [cd4da713f99651e99fbce8ed6b6ec8f686c029a8] https://lava.sirena.org.uk/scheduler/job/1538865
# test job: [5fc2c383125c2b4b6037e02ad8796b776b25e6d0] https://lava.sirena.org.uk/scheduler/job/1486917
# test job: [7f8924e8785b68c998bc1906e049bf5595865e60] https://lava.sirena.org.uk/scheduler/job/1486907
# test job: [3e1c01d06e1f52f78fe00ef26a9cf80dbb0a3115] https://lava.sirena.org.uk/scheduler/job/1481712
# test job: [d9f38d9824bfb1b046d2e720349d2f45959ab184] https://lava.sirena.org.uk/scheduler/job/1481616
# test job: [d03b53c9139352b744ed007bf562bd35517bacff] https://lava.sirena.org.uk/scheduler/job/1488745
# test job: [dce4bc30f42d313b4dc5832316196411b7f07ad0] https://lava.sirena.org.uk/scheduler/job/1479475
# test job: [47972c1c3315672352f25c68f91dd88543541947] https://lava.sirena.org.uk/scheduler/job/1479561
# test job: [367864935785382bab95f5e5a691535d28f5a21b] https://lava.sirena.org.uk/scheduler/job/1488643
# test job: [7b2c2f1eb3914f5214a5b2ae966d7d7bb0057582] https://lava.sirena.org.uk/scheduler/job/1488133
# test job: [5eb8a0d7733d4cd32a776acf1d1aa1c7c01c8a14] https://lava.sirena.org.uk/scheduler/job/1474493
# test job: [bb8d8ba4715cb8f997d63d90ba935f6073595df5] https://lava.sirena.org.uk/scheduler/job/1472038
# test job: [8a5a5cecb79058b608e5562d8998123a3adb313c] https://lava.sirena.org.uk/scheduler/job/1471855
# test job: [a4eb71ff98c4792f441f108910bd829da7a04092] https://lava.sirena.org.uk/scheduler/job/1469012
# test job: [6cafcc53eb5fffd9b9bdfde700bb9bad21e98ed3] https://lava.sirena.org.uk/scheduler/job/1468918
# test job: [7e10d7242ea8a5947878880b912ffa5806520705] https://lava.sirena.org.uk/scheduler/job/1466023
# test job: [d6fa0ca959db8efd4462d7beef4bdc5568640fd0] https://lava.sirena.org.uk/scheduler/job/1464675
# test job: [d49305862fdc4d9ff1b1093b4ed7d8e0cb9971b4] https://lava.sirena.org.uk/scheduler/job/1463032
# test job: [1f5cdb6ab45e1c06ae0953609acbb52f8946b3e8] https://lava.sirena.org.uk/scheduler/job/1462978
# test job: [6ba68e5aa9d5d15c8877a655db279fcfc0b38b04] https://lava.sirena.org.uk/scheduler/job/1463334
# test job: [548d770c330cd1027549947a6ea899c56b5bc4e4] https://lava.sirena.org.uk/scheduler/job/1460070
# test job: [c459262159f39e6e6336797feb975799344b749b] https://lava.sirena.org.uk/scheduler/job/1461008
# test job: [267be32b0a7b70cc777f8a46f0904c92c0521d89] https://lava.sirena.org.uk/scheduler/job/1460425
# test job: [03b778d1994827ea5cc971dbdfbb457bbb7bfa5d] https://lava.sirena.org.uk/scheduler/job/1461891
# test job: [111a2c8ab462d77d1519b71b46f13ae1b46920b4] https://lava.sirena.org.uk/scheduler/job/1460867
# test job: [f6f914893d478b7ba08e5c375de1ced16deb5e92] https://lava.sirena.org.uk/scheduler/job/1461469
# test job: [c95e925daa434ee1a40a86aec6476ce588e4bd77] https://lava.sirena.org.uk/scheduler/job/1460121
# test job: [9a30e332c36c52e92e5316b4a012d45284dedeb5] https://lava.sirena.org.uk/scheduler/job/1460546
# test job: [c8c4694ede7ed42d8d4db0e8927dea9839a3e248] https://lava.sirena.org.uk/scheduler/job/1461313
# test job: [ac209bde018fd320b79976657a44c23113181af6] https://lava.sirena.org.uk/scheduler/job/1461924
# test job: [b9ecde0bcf6a99a3ff08496d4ba90a385ebbfd68] https://lava.sirena.org.uk/scheduler/job/1461083
# test job: [ece5d881004f041c2e1493436409dbcbea3ad5f8] https://lava.sirena.org.uk/scheduler/job/1461674
# test job: [e6e8897995a9e6028563ce36c27877e5478c8571] https://lava.sirena.org.uk/scheduler/job/1461769
# test job: [7e17e80c3a7eb2734795f66ba946f933412d597f] https://lava.sirena.org.uk/scheduler/job/1130953
# test job: [0b90c3b6d76ea512dc3dac8fb30215e175b0019a] https://lava.sirena.org.uk/scheduler/job/1612972
# bad: [0b90c3b6d76ea512dc3dac8fb30215e175b0019a] Add linux-next specific files for 20250728
git bisect bad 0b90c3b6d76ea512dc3dac8fb30215e175b0019a
# test job: [8f39ed5e760dad5ca25eb6a49264cd22ec971c63] https://lava.sirena.org.uk/scheduler/job/1613241
# good: [8f39ed5e760dad5ca25eb6a49264cd22ec971c63] Merge branch 'main' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git
git bisect good 8f39ed5e760dad5ca25eb6a49264cd22ec971c63
# test job: [3935bbac1876808a0199d8b3724f1e9a225cc6a9] https://lava.sirena.org.uk/scheduler/job/1613371
# good: [3935bbac1876808a0199d8b3724f1e9a225cc6a9] Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit.git
git bisect good 3935bbac1876808a0199d8b3724f1e9a225cc6a9
# test job: [c87c8601aa83e2d78894181ac9eff9ec26cc10a7] https://lava.sirena.org.uk/scheduler/job/1613389
# good: [c87c8601aa83e2d78894181ac9eff9ec26cc10a7] Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
git bisect good c87c8601aa83e2d78894181ac9eff9ec26cc10a7
# test job: [fcf2858f22433b60a33f86ca56bed8657b263539] https://lava.sirena.org.uk/scheduler/job/1613493
# bad: [fcf2858f22433b60a33f86ca56bed8657b263539] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux.git
git bisect bad fcf2858f22433b60a33f86ca56bed8657b263539
# test job: [05ef423f543d8f5f41f0bc66510562906120b8a4] https://lava.sirena.org.uk/scheduler/job/1613626
# bad: [05ef423f543d8f5f41f0bc66510562906120b8a4] Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy.git
git bisect bad 05ef423f543d8f5f41f0bc66510562906120b8a4
# test job: [0eb8d7b25397330beab8ee62c681975b79f37223] https://lava.sirena.org.uk/scheduler/job/1613798
# good: [0eb8d7b25397330beab8ee62c681975b79f37223] iio: adc: ad7173: fix channels index for syscalib_mode
git bisect good 0eb8d7b25397330beab8ee62c681975b79f37223
# test job: [b13b41cc3dc1811189b9cbeb04d11d8bef474679] https://lava.sirena.org.uk/scheduler/job/1613833
# good: [b13b41cc3dc1811189b9cbeb04d11d8bef474679] misc: ti_fpc202: Switch to of_fwnode_handle()
git bisect good b13b41cc3dc1811189b9cbeb04d11d8bef474679
# test job: [351e07e6b2ecc16ef8669713b14b6f67518c945d] https://lava.sirena.org.uk/scheduler/job/1613891
# good: [351e07e6b2ecc16ef8669713b14b6f67518c945d] phy: cadence-torrent: Add PCIe multilink + USB with same SSC register config for 100 MHz refclk
git bisect good 351e07e6b2ecc16ef8669713b14b6f67518c945d
# test job: [4a3556b81b99f0c8c0358f7cc6801a62b4538fe2] https://lava.sirena.org.uk/scheduler/job/1613931
# good: [4a3556b81b99f0c8c0358f7cc6801a62b4538fe2] phy: qcom: phy-qcom-m31: Update IPQ5332 M31 USB phy initialization sequence
git bisect good 4a3556b81b99f0c8c0358f7cc6801a62b4538fe2
# test job: [7eca4399060def1a65098564ad84e327d8388d4c] https://lava.sirena.org.uk/scheduler/job/1614008
# good: [7eca4399060def1a65098564ad84e327d8388d4c] coresight: catu: Support atclk
git bisect good 7eca4399060def1a65098564ad84e327d8388d4c
# test job: [7471c81e60b9f0945d33577efe467c9eef2476e5] https://lava.sirena.org.uk/scheduler/job/1614054
# bad: [7471c81e60b9f0945d33577efe467c9eef2476e5] coresight: Refactor driver data allocation
git bisect bad 7471c81e60b9f0945d33577efe467c9eef2476e5
# test job: [90b0000bd5016bcfeccfe4c7d5276637aa380e76] https://lava.sirena.org.uk/scheduler/job/1614124
# bad: [90b0000bd5016bcfeccfe4c7d5276637aa380e76] coresight: Appropriately disable trace bus clocks
git bisect bad 90b0000bd5016bcfeccfe4c7d5276637aa380e76
# test job: [ce15ee28bdddc49d18c4e296859456b819cf0690] https://lava.sirena.org.uk/scheduler/job/1614174
# bad: [ce15ee28bdddc49d18c4e296859456b819cf0690] coresight: Appropriately disable programming clocks
git bisect bad ce15ee28bdddc49d18c4e296859456b819cf0690
# test job: [14fb833b820422bc1cdb18d2e1a35eccbf9789de] https://lava.sirena.org.uk/scheduler/job/1614220
# good: [14fb833b820422bc1cdb18d2e1a35eccbf9789de] coresight: etm4x: Support atclk
git bisect good 14fb833b820422bc1cdb18d2e1a35eccbf9789de
# first bad commit: [ce15ee28bdddc49d18c4e296859456b819cf0690] coresight: Appropriately disable programming clocks

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 04/10] coresight: Appropriately disable programming clocks
  2025-07-24 15:22 ` [PATCH v5 04/10] coresight: Appropriately disable programming clocks Leo Yan
  2025-07-28 16:18   ` Mark Brown
@ 2025-07-28 16:44   ` Mark Brown
  2025-07-29 11:31     ` Mark Brown
  1 sibling, 1 reply; 24+ messages in thread
From: Mark Brown @ 2025-07-28 16:44 UTC (permalink / raw)
  To: Leo Yan
  Cc: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman, coresight,
	linux-arm-kernel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 674 bytes --]

On Thu, Jul 24, 2025 at 04:22:34PM +0100, Leo Yan wrote:

>  static inline struct clk *coresight_get_enable_apb_pclk(struct device *dev)
>  {
>  	struct clk *pclk;
> -	int ret;
>  
> -	pclk = clk_get(dev, "apb_pclk");
> -	if (IS_ERR(pclk)) {
> -		pclk = clk_get(dev, "apb");
> -		if (IS_ERR(pclk))
> -			return NULL;
> -	}

Previously we would return NULL for any error (which isn't super great
for deferred probe but never mind).

> +	pclk = devm_clk_get_enabled(dev, "apb_pclk");
> +	if (IS_ERR(pclk))
> +		pclk = devm_clk_get_enabled(dev, "apb");

...

>  	return pclk;
>  }

Now we pass errors back to the caller, making missing clocks fatal.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 04/10] coresight: Appropriately disable programming clocks
  2025-07-28 16:44   ` Mark Brown
@ 2025-07-29 11:31     ` Mark Brown
  2025-07-29 12:30       ` Suzuki K Poulose
  0 siblings, 1 reply; 24+ messages in thread
From: Mark Brown @ 2025-07-29 11:31 UTC (permalink / raw)
  To: Leo Yan
  Cc: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman, coresight,
	linux-arm-kernel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 761 bytes --]

On Mon, Jul 28, 2025 at 05:45:04PM +0100, Mark Brown wrote:
> On Thu, Jul 24, 2025 at 04:22:34PM +0100, Leo Yan wrote:
> 
> Previously we would return NULL for any error (which isn't super great
> for deferred probe but never mind).
> 
> > +	pclk = devm_clk_get_enabled(dev, "apb_pclk");
> > +	if (IS_ERR(pclk))
> > +		pclk = devm_clk_get_enabled(dev, "apb");
> 
> ...
> 
> >  	return pclk;
> >  }
> 
> Now we pass errors back to the caller, making missing clocks fatal.

Thinking about this some more I think for compatiblity these clocks need
to be treated as optional - that's what the original code was
effectively doing, and I can imagine this isn't the only SoC which has
(hopefully) always on clocks and didn't wire things up in DT.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 04/10] coresight: Appropriately disable programming clocks
  2025-07-29 11:31     ` Mark Brown
@ 2025-07-29 12:30       ` Suzuki K Poulose
  2025-07-30  8:56         ` Leo Yan
  0 siblings, 1 reply; 24+ messages in thread
From: Suzuki K Poulose @ 2025-07-29 12:30 UTC (permalink / raw)
  To: Mark Brown, Leo Yan
  Cc: Mike Leach, James Clark, Anshuman Khandual, Yeoreum Yun,
	Alexander Shishkin, Greg Kroah-Hartman, coresight,
	linux-arm-kernel, linux-kernel

On 29/07/2025 12:31, Mark Brown wrote:
> On Mon, Jul 28, 2025 at 05:45:04PM +0100, Mark Brown wrote:
>> On Thu, Jul 24, 2025 at 04:22:34PM +0100, Leo Yan wrote:
>>
>> Previously we would return NULL for any error (which isn't super great
>> for deferred probe but never mind).
>>
>>> +	pclk = devm_clk_get_enabled(dev, "apb_pclk");
>>> +	if (IS_ERR(pclk))
>>> +		pclk = devm_clk_get_enabled(dev, "apb");
>>
>> ...
>>
>>>   	return pclk;
>>>   }
>>
>> Now we pass errors back to the caller, making missing clocks fatal.
> 
> Thinking about this some more I think for compatiblity these clocks need
> to be treated as optional - that's what the original code was
> effectively doing, and I can imagine this isn't the only SoC which has
> (hopefully) always on clocks and didn't wire things up in DT.

You're right. The static components (funnels, replicators) don't have
APB programming interface and hence no clocks. That said, may be the
"is amba device" check could be used to enforce the presence of a clock.

I will let Leo sort this out

Suzuki


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 00/10] coresight: Fix and improve clock usage
  2025-07-25  9:22 ` Suzuki K Poulose
@ 2025-07-29 12:31   ` Suzuki K Poulose
  0 siblings, 0 replies; 24+ messages in thread
From: Suzuki K Poulose @ 2025-07-29 12:31 UTC (permalink / raw)
  To: Mike Leach, James Clark, Anshuman Khandual, Yeoreum Yun,
	Alexander Shishkin, Greg Kroah-Hartman, Leo Yan
  Cc: coresight, linux-arm-kernel, linux-kernel

On 25/07/2025 10:22, Suzuki K Poulose wrote:
> 
> On Thu, 24 Jul 2025 16:22:30 +0100, Leo Yan wrote:
>> This series fixes and improves clock usage in the Arm CoreSight drivers.
>>
>> Based on the DT binding documents, the trace clock (atclk) is defined in
>> some CoreSight modules, but support is absent. In most cases, the issue
>> is hidden because the atclk clock is shared by multiple CoreSight
>> modules and the clock is enabled anyway by other drivers. The first
>> three patches address this issue.
>>
>> [...]
> 
> Applied, thanks!
> 
> [01/10] coresight: tmc: Support atclk
>          https://git.kernel.org/coresight/c/e96d605a66ff
> [02/10] coresight: catu: Support atclk
>          https://git.kernel.org/coresight/c/7eca4399060d
> [03/10] coresight: etm4x: Support atclk
>          https://git.kernel.org/coresight/c/14fb833b8204
> [04/10] coresight: Appropriately disable programming clocks
>          https://git.kernel.org/coresight/c/ce15ee28bddd
> [05/10] coresight: Appropriately disable trace bus clocks
>          https://git.kernel.org/coresight/c/90b0000bd501
> [06/10] coresight: Avoid enable programming clock duplicately
>          https://git.kernel.org/coresight/c/5c0ead76597b
> [07/10] coresight: Consolidate clock enabling
>          https://git.kernel.org/coresight/c/f47d7f7da638
> [08/10] coresight: Refactor driver data allocation
>          https://git.kernel.org/coresight/c/7471c81e60b9
> [09/10] coresight: Make clock sequence consistent
>          https://git.kernel.org/coresight/c/d4cf59aa905b
> [10/10] coresight: Refactor runtime PM
>          https://git.kernel.org/coresight/c/2b52cf338d39
> 
> Best regards,

I have dropped this from -next, due to the issues reported by
Mark.

Suzuki



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 04/10] coresight: Appropriately disable programming clocks
  2025-07-29 12:30       ` Suzuki K Poulose
@ 2025-07-30  8:56         ` Leo Yan
  2025-07-30  9:27           ` Suzuki K Poulose
  0 siblings, 1 reply; 24+ messages in thread
From: Leo Yan @ 2025-07-30  8:56 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Mark Brown, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman, coresight,
	linux-arm-kernel, linux-kernel

On Tue, Jul 29, 2025 at 01:30:28PM +0100, Suzuki Kuruppassery Poulose wrote:
> On 29/07/2025 12:31, Mark Brown wrote:
> > On Mon, Jul 28, 2025 at 05:45:04PM +0100, Mark Brown wrote:
> > > On Thu, Jul 24, 2025 at 04:22:34PM +0100, Leo Yan wrote:
> > > 
> > > Previously we would return NULL for any error (which isn't super great
> > > for deferred probe but never mind).
> > > 
> > > > +	pclk = devm_clk_get_enabled(dev, "apb_pclk");
> > > > +	if (IS_ERR(pclk))
> > > > +		pclk = devm_clk_get_enabled(dev, "apb");
> > > 
> > > ...
> > > 
> > > >   	return pclk;
> > > >   }
> > > 
> > > Now we pass errors back to the caller, making missing clocks fatal.
> > 
> > Thinking about this some more I think for compatiblity these clocks need
> > to be treated as optional - that's what the original code was
> > effectively doing, and I can imagine this isn't the only SoC which has
> > (hopefully) always on clocks and didn't wire things up in DT.
> 
> You're right. The static components (funnels, replicators) don't have
> APB programming interface and hence no clocks. That said, may be the
> "is amba device" check could be used to enforce the presence of a clock.

I was wondering how this issue slipped through when I tested it on the
Hikey960 board. The Hikey960 also has one static funnel, but it binds
pclk with the static funnel node. That's why I didn't detect the issue.

I don't think using optional clock API is right thing, as DT binding
schema claims the pclk is mandatory for dynamic components. My proposal
is to enable the clocks only when IORESOURCE_MEM is available, something
like:

  if (res) {
      ret = coresight_get_enable_clocks(dev, &drvdata->pclk,
                                        &drvdata->atclk);
      if (ret)
              return ret;

      base = devm_ioremap_resource(dev, res);
      ...
  }

The static components don't bind I/O resources, it is naturally not to
enable clocks for them. Please let me know if this is reasonable
solution.

@Mark, thanks a lot for testing and bisection.

Leo


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 04/10] coresight: Appropriately disable programming clocks
  2025-07-30  8:56         ` Leo Yan
@ 2025-07-30  9:27           ` Suzuki K Poulose
  2025-07-30 10:54             ` Leo Yan
  0 siblings, 1 reply; 24+ messages in thread
From: Suzuki K Poulose @ 2025-07-30  9:27 UTC (permalink / raw)
  To: Leo Yan
  Cc: Mark Brown, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman, coresight,
	linux-arm-kernel, linux-kernel

On 30/07/2025 09:56, Leo Yan wrote:
> On Tue, Jul 29, 2025 at 01:30:28PM +0100, Suzuki Kuruppassery Poulose wrote:
>> On 29/07/2025 12:31, Mark Brown wrote:
>>> On Mon, Jul 28, 2025 at 05:45:04PM +0100, Mark Brown wrote:
>>>> On Thu, Jul 24, 2025 at 04:22:34PM +0100, Leo Yan wrote:
>>>>
>>>> Previously we would return NULL for any error (which isn't super great
>>>> for deferred probe but never mind).
>>>>
>>>>> +	pclk = devm_clk_get_enabled(dev, "apb_pclk");
>>>>> +	if (IS_ERR(pclk))
>>>>> +		pclk = devm_clk_get_enabled(dev, "apb");
>>>>
>>>> ...
>>>>
>>>>>    	return pclk;
>>>>>    }
>>>>
>>>> Now we pass errors back to the caller, making missing clocks fatal.
>>>
>>> Thinking about this some more I think for compatiblity these clocks need
>>> to be treated as optional - that's what the original code was
>>> effectively doing, and I can imagine this isn't the only SoC which has
>>> (hopefully) always on clocks and didn't wire things up in DT.
>>
>> You're right. The static components (funnels, replicators) don't have
>> APB programming interface and hence no clocks. That said, may be the
>> "is amba device" check could be used to enforce the presence of a clock.
> 
> I was wondering how this issue slipped through when I tested it on the
> Hikey960 board. The Hikey960 also has one static funnel, but it binds
> pclk with the static funnel node. That's why I didn't detect the issue.
> 
> I don't think using optional clock API is right thing, as DT binding
> schema claims the pclk is mandatory for dynamic components. My proposal
> is to enable the clocks only when IORESOURCE_MEM is available, something
> like:
> 
>    if (res) {
>        ret = coresight_get_enable_clocks(dev, &drvdata->pclk,
>                                          &drvdata->atclk);

That may not work, as they may need the ATCLK enabled to
push the trace over ATB. They may skip the APB, as there
is no programming interface.

Suzuki




>        if (ret)
>                return ret;
> 
>        base = devm_ioremap_resource(dev, res);
>        ...
>    }
> 
> The static components don't bind I/O resources, it is naturally not to
> enable clocks for them. Please let me know if this is reasonable
> solution.
> 
> @Mark, thanks a lot for testing and bisection.
> 
> Leo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 04/10] coresight: Appropriately disable programming clocks
  2025-07-30  9:27           ` Suzuki K Poulose
@ 2025-07-30 10:54             ` Leo Yan
  2025-07-30 11:01               ` Suzuki K Poulose
  0 siblings, 1 reply; 24+ messages in thread
From: Leo Yan @ 2025-07-30 10:54 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Mark Brown, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman, coresight,
	linux-arm-kernel, linux-kernel

On Wed, Jul 30, 2025 at 10:27:48AM +0100, Suzuki Kuruppassery Poulose wrote:
> On 30/07/2025 09:56, Leo Yan wrote:
> > On Tue, Jul 29, 2025 at 01:30:28PM +0100, Suzuki Kuruppassery Poulose wrote:
> > > On 29/07/2025 12:31, Mark Brown wrote:
> > > > On Mon, Jul 28, 2025 at 05:45:04PM +0100, Mark Brown wrote:
> > > > > On Thu, Jul 24, 2025 at 04:22:34PM +0100, Leo Yan wrote:
> > > > > 
> > > > > Previously we would return NULL for any error (which isn't super great
> > > > > for deferred probe but never mind).
> > > > > 
> > > > > > +	pclk = devm_clk_get_enabled(dev, "apb_pclk");
> > > > > > +	if (IS_ERR(pclk))
> > > > > > +		pclk = devm_clk_get_enabled(dev, "apb");
> > > > > 
> > > > > ...
> > > > > 
> > > > > >    	return pclk;
> > > > > >    }
> > > > > 
> > > > > Now we pass errors back to the caller, making missing clocks fatal.
> > > > 
> > > > Thinking about this some more I think for compatiblity these clocks need
> > > > to be treated as optional - that's what the original code was
> > > > effectively doing, and I can imagine this isn't the only SoC which has
> > > > (hopefully) always on clocks and didn't wire things up in DT.
> > > 
> > > You're right. The static components (funnels, replicators) don't have
> > > APB programming interface and hence no clocks. That said, may be the
> > > "is amba device" check could be used to enforce the presence of a clock.
> > 
> > I was wondering how this issue slipped through when I tested it on the
> > Hikey960 board. The Hikey960 also has one static funnel, but it binds
> > pclk with the static funnel node. That's why I didn't detect the issue.
> > 
> > I don't think using optional clock API is right thing, as DT binding
> > schema claims the pclk is mandatory for dynamic components. My proposal
> > is to enable the clocks only when IORESOURCE_MEM is available, something
> > like:
> > 
> >    if (res) {
> >        ret = coresight_get_enable_clocks(dev, &drvdata->pclk,
> >                                          &drvdata->atclk);
> 
> That may not work, as they may need the ATCLK enabled to
> push the trace over ATB. They may skip the APB, as there
> is no programming interface.

If so, I will use an extra patch to skip pclk enabling for static funnel
and replicator, as a result, patch 04 will be:

  if (res) {
      drvdata->pclk = coresight_get_enable_apb_pclk(dev);
      if (IS_ERR(drvdata->pclk))
          return PTR_ERR(drvdata->pclk);
  }

Then, when consolidation in patch 07, it will have a code:

  /* Only enable pclk for a device with I/O resource */
  ret = coresight_get_enable_clocks(dev, res ? &drvdata->pclk : NULL,
                                    &drvdata->atclk);

This turns out to be the case for both static funnel and replicator
devices — regardless of whether the DT binding includes "apb_pclk" or
not, the driver will always skip enabling it. Any concerns?

Thanks,
Leo


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 04/10] coresight: Appropriately disable programming clocks
  2025-07-30 10:54             ` Leo Yan
@ 2025-07-30 11:01               ` Suzuki K Poulose
  2025-07-30 11:09                 ` Mark Brown
  0 siblings, 1 reply; 24+ messages in thread
From: Suzuki K Poulose @ 2025-07-30 11:01 UTC (permalink / raw)
  To: Leo Yan
  Cc: Mark Brown, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman, coresight,
	linux-arm-kernel, linux-kernel

On 30/07/2025 11:54, Leo Yan wrote:
> On Wed, Jul 30, 2025 at 10:27:48AM +0100, Suzuki Kuruppassery Poulose wrote:
>> On 30/07/2025 09:56, Leo Yan wrote:
>>> On Tue, Jul 29, 2025 at 01:30:28PM +0100, Suzuki Kuruppassery Poulose wrote:
>>>> On 29/07/2025 12:31, Mark Brown wrote:
>>>>> On Mon, Jul 28, 2025 at 05:45:04PM +0100, Mark Brown wrote:
>>>>>> On Thu, Jul 24, 2025 at 04:22:34PM +0100, Leo Yan wrote:
>>>>>>
>>>>>> Previously we would return NULL for any error (which isn't super great
>>>>>> for deferred probe but never mind).
>>>>>>
>>>>>>> +	pclk = devm_clk_get_enabled(dev, "apb_pclk");
>>>>>>> +	if (IS_ERR(pclk))
>>>>>>> +		pclk = devm_clk_get_enabled(dev, "apb");
>>>>>>
>>>>>> ...
>>>>>>
>>>>>>>     	return pclk;
>>>>>>>     }
>>>>>>
>>>>>> Now we pass errors back to the caller, making missing clocks fatal.
>>>>>
>>>>> Thinking about this some more I think for compatiblity these clocks need
>>>>> to be treated as optional - that's what the original code was
>>>>> effectively doing, and I can imagine this isn't the only SoC which has
>>>>> (hopefully) always on clocks and didn't wire things up in DT.
>>>>
>>>> You're right. The static components (funnels, replicators) don't have
>>>> APB programming interface and hence no clocks. That said, may be the
>>>> "is amba device" check could be used to enforce the presence of a clock.
>>>
>>> I was wondering how this issue slipped through when I tested it on the
>>> Hikey960 board. The Hikey960 also has one static funnel, but it binds
>>> pclk with the static funnel node. That's why I didn't detect the issue.
>>>
>>> I don't think using optional clock API is right thing, as DT binding
>>> schema claims the pclk is mandatory for dynamic components. My proposal
>>> is to enable the clocks only when IORESOURCE_MEM is available, something
>>> like:
>>>
>>>     if (res) {
>>>         ret = coresight_get_enable_clocks(dev, &drvdata->pclk,
>>>                                           &drvdata->atclk);
>>
>> That may not work, as they may need the ATCLK enabled to
>> push the trace over ATB. They may skip the APB, as there
>> is no programming interface.
> 
> If so, I will use an extra patch to skip pclk enabling for static funnel
> and replicator, as a result, patch 04 will be:
> 
>    if (res) {
>        drvdata->pclk = coresight_get_enable_apb_pclk(dev);
>        if (IS_ERR(drvdata->pclk))
>            return PTR_ERR(drvdata->pclk);
>    }
> 
> Then, when consolidation in patch 07, it will have a code:
> 
>    /* Only enable pclk for a device with I/O resource */
>    ret = coresight_get_enable_clocks(dev, res ? &drvdata->pclk : NULL,
>                                      &drvdata->atclk);

Can we not differentiate the error code in devm_get..() for

  ENOENT (not found) vs Some other failure ?

I would recommend using that and don't force the use of apb_clk/apb
for AMBA devices. If the firmware doesn't specify a clock, but does
specify the CoreSight components, it knows it better.

Suzuki



> 
> This turns out to be the case for both static funnel and replicator
> devices — regardless of whether the DT binding includes "apb_pclk" or
> not, the driver will always skip enabling it. Any concerns?
> 
> Thanks,
> Leo



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 04/10] coresight: Appropriately disable programming clocks
  2025-07-30 11:01               ` Suzuki K Poulose
@ 2025-07-30 11:09                 ` Mark Brown
  2025-07-30 17:57                   ` Leo Yan
  0 siblings, 1 reply; 24+ messages in thread
From: Mark Brown @ 2025-07-30 11:09 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Leo Yan, Mike Leach, James Clark, Anshuman Khandual, Yeoreum Yun,
	Alexander Shishkin, Greg Kroah-Hartman, coresight,
	linux-arm-kernel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

On Wed, Jul 30, 2025 at 12:01:25PM +0100, Suzuki K Poulose wrote:

> I would recommend using that and don't force the use of apb_clk/apb
> for AMBA devices. If the firmware doesn't specify a clock, but does
> specify the CoreSight components, it knows it better.

And perhaps more to the point if a currently working system suddenly
starts requiring additional clocks in it's binding that's an ABI break.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v5 04/10] coresight: Appropriately disable programming clocks
  2025-07-30 11:09                 ` Mark Brown
@ 2025-07-30 17:57                   ` Leo Yan
  0 siblings, 0 replies; 24+ messages in thread
From: Leo Yan @ 2025-07-30 17:57 UTC (permalink / raw)
  To: Mark Brown
  Cc: Suzuki K Poulose, Mike Leach, James Clark, Anshuman Khandual,
	Yeoreum Yun, Alexander Shishkin, Greg Kroah-Hartman, coresight,
	linux-arm-kernel, linux-kernel, Rob Herring

On Wed, Jul 30, 2025 at 12:09:42PM +0100, Mark Brown wrote:
> On Wed, Jul 30, 2025 at 12:01:25PM +0100, Suzuki K Poulose wrote:
> 
> > I would recommend using that and don't force the use of apb_clk/apb
> > for AMBA devices. If the firmware doesn't specify a clock, but does
> > specify the CoreSight components, it knows it better.
> 
> And perhaps more to the point if a currently working system suddenly
> starts requiring additional clocks in it's binding that's an ABI break.

Yes, the change should not break any platforms if the DT binding is
passed correctly. I will update with devm_clk_get_optional_enabled().

Just for the record, I was a bit concerned that the driver might not
report a missing clock after switching to the optional clock API.
After discussed with Rob and Suzuki, I understand this should not be a
problem. Any missing clock issue can be caught by the DT schema static
checker, or a system hang during the development phase would remind
developers to bind clocks properly.

Thanks,
Leo


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2025-07-30 18:00 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-24 15:22 [PATCH v5 00/10] coresight: Fix and improve clock usage Leo Yan
2025-07-24 15:22 ` [PATCH v5 01/10] coresight: tmc: Support atclk Leo Yan
2025-07-24 15:22 ` [PATCH v5 02/10] coresight: catu: " Leo Yan
2025-07-24 15:22 ` [PATCH v5 03/10] coresight: etm4x: " Leo Yan
2025-07-24 15:22 ` [PATCH v5 04/10] coresight: Appropriately disable programming clocks Leo Yan
2025-07-28 16:18   ` Mark Brown
2025-07-28 16:44   ` Mark Brown
2025-07-29 11:31     ` Mark Brown
2025-07-29 12:30       ` Suzuki K Poulose
2025-07-30  8:56         ` Leo Yan
2025-07-30  9:27           ` Suzuki K Poulose
2025-07-30 10:54             ` Leo Yan
2025-07-30 11:01               ` Suzuki K Poulose
2025-07-30 11:09                 ` Mark Brown
2025-07-30 17:57                   ` Leo Yan
2025-07-24 15:22 ` [PATCH v5 05/10] coresight: Appropriately disable trace bus clocks Leo Yan
2025-07-24 15:22 ` [PATCH v5 06/10] coresight: Avoid enable programming clock duplicately Leo Yan
2025-07-24 15:22 ` [PATCH v5 07/10] coresight: Consolidate clock enabling Leo Yan
2025-07-24 15:22 ` [PATCH v5 08/10] coresight: Refactor driver data allocation Leo Yan
2025-07-24 15:22 ` [PATCH v5 09/10] coresight: Make clock sequence consistent Leo Yan
2025-07-24 15:22 ` [PATCH v5 10/10] coresight: Refactor runtime PM Leo Yan
2025-07-25  8:45 ` [PATCH v5 00/10] coresight: Fix and improve clock usage James Clark
2025-07-25  9:22 ` Suzuki K Poulose
2025-07-29 12:31   ` Suzuki K Poulose

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).