Linux-ARM-Kernel Archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/7] coresight: Move remaining AMBA ACPI devices into platform driver
@ 2023-12-01  6:20 Anshuman Khandual
  2023-12-01  6:20 ` [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to " Anshuman Khandual
                   ` (6 more replies)
  0 siblings, 7 replies; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-01  6:20 UTC (permalink / raw)
  To: linux-arm-kernel, suzuki.poulose
  Cc: Anshuman Khandual, Lorenzo Pieralisi, Sudeep Holla, Mike Leach,
	James Clark, Maxime Coquelin, Alexandre Torgue, linux-acpi,
	linux-kernel, coresight, linux-stm32

This moves remaining AMBA ACPI devices into respective platform drivers for
enabling ACPI based power management support. This series applies on latest
coresight/next branch. This series has been built, and boot tested on a DT
based coresight platform. Although this still requires some more testing on
ACPI based coresight platforms.

https://git.gitlab.arm.com/linux-arm/linux-anshuman.git (amba_other_acpi_migration_v2)

Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: James Clark <james.clark@arm.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: linux-acpi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: coresight@lists.linaro.org
Cc: linux-stm32@st-md-mailman.stormreply.com

Changes in V2:

- Dropped redundant devm_ioremap_resource() hunk from tmc_platform_probe()
- Defined coresight_[init|remove]_driver() for both AMBA/platform drivers
- Changed catu, tmc, tpiu, stm and debug coresight drivers to use the new
  helpers avoiding build issues arising from module_amba_driver(), and
  module_platform_driver() being on the same file

Changes in V1:

https://lore.kernel.org/all/20231027072943.3418997-1-anshuman.khandual@arm.com/

- Replaced all IS_ERR() instances with IS_ERR_OR_NULL() as per Suzuki

Changes in RFC:

https://lore.kernel.org/all/20230921042040.1334641-1-anshuman.khandual@arm.com/

Anshuman Khandual (7):
  coresight: replicator: Move ACPI support from AMBA driver to platform driver
  coresight: funnel: Move ACPI support from AMBA driver to platform driver
  coresight: catu: Move ACPI support from AMBA driver to platform driver
  coresight: tpiu: Move ACPI support from AMBA driver to platform driver
  coresight: tmc: Move ACPI support from AMBA driver to platform driver
  coresight: stm: Move ACPI support from AMBA driver to platform driver
  coresight: debug: Move ACPI support from AMBA driver to platform driver

 drivers/acpi/arm64/amba.c                     |   8 -
 drivers/hwtracing/coresight/coresight-catu.c  | 130 +++++++++++++---
 drivers/hwtracing/coresight/coresight-catu.h  |   1 +
 drivers/hwtracing/coresight/coresight-core.c  |  29 ++++
 .../hwtracing/coresight/coresight-cpu-debug.c | 141 ++++++++++++++++--
 .../hwtracing/coresight/coresight-funnel.c    |  49 +++---
 .../coresight/coresight-replicator.c          |  44 +++---
 drivers/hwtracing/coresight/coresight-stm.c   |  91 +++++++++--
 .../hwtracing/coresight/coresight-tmc-core.c  | 130 ++++++++++++++--
 drivers/hwtracing/coresight/coresight-tmc.h   |   1 +
 drivers/hwtracing/coresight/coresight-tpiu.c  |  87 ++++++++++-
 include/linux/coresight.h                     |   7 +
 12 files changed, 608 insertions(+), 110 deletions(-)

-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 [PATCH V2 0/7] coresight: Move remaining AMBA ACPI devices into platform driver Anshuman Khandual
@ 2023-12-01  6:20 ` Anshuman Khandual
  2023-12-01 12:35   ` Sudeep Holla
  2023-12-01  6:20 ` [PATCH V2 2/7] coresight: funnel: " Anshuman Khandual
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-01  6:20 UTC (permalink / raw)
  To: linux-arm-kernel, suzuki.poulose
  Cc: Anshuman Khandual, Lorenzo Pieralisi, Sudeep Holla, Mike Leach,
	James Clark, Maxime Coquelin, Alexandre Torgue, linux-acpi,
	linux-kernel, coresight, linux-stm32

Add support for the dynamic replicator device in the platform driver, which
can then be used on ACPI based platforms. This change would now allow
runtime power management for repliacator devices on ACPI based systems.

The driver would try to enable the APB clock if available. Also, rename the
code to reflect the fact that it now handles both static and dynamic
replicators.

Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: James Clark <james.clark@arm.com>
Cc: linux-acpi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: coresight@lists.linaro.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 drivers/acpi/arm64/amba.c                     |  1 -
 .../coresight/coresight-replicator.c          | 44 ++++++++++++-------
 2 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
index 171b5c2c7edd..270f4e3819a2 100644
--- a/drivers/acpi/arm64/amba.c
+++ b/drivers/acpi/arm64/amba.c
@@ -27,7 +27,6 @@ static const struct acpi_device_id amba_id_list[] = {
 	{"ARMHC503", 0}, /* ARM CoreSight Debug */
 	{"ARMHC979", 0}, /* ARM CoreSight TPIU */
 	{"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */
-	{"ARMHC98D", 0}, /* ARM CoreSight Dynamic Replicator */
 	{"ARMHC9CA", 0}, /* ARM CoreSight CATU */
 	{"ARMHC9FF", 0}, /* ARM CoreSight Dynamic Funnel */
 	{"", 0},
diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
index b6be73034996..64de0bee02ec 100644
--- a/drivers/hwtracing/coresight/coresight-replicator.c
+++ b/drivers/hwtracing/coresight/coresight-replicator.c
@@ -38,6 +38,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
 struct replicator_drvdata {
 	void __iomem		*base;
 	struct clk		*atclk;
+	struct clk		*pclk;
 	struct coresight_device	*csdev;
 	spinlock_t		spinlock;
 	bool			check_idfilter_val;
@@ -243,6 +244,10 @@ static int replicator_probe(struct device *dev, struct resource *res)
 			return ret;
 	}
 
+	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
+	if (IS_ERR(drvdata->pclk))
+		return -ENODEV;
+
 	/*
 	 * Map the device base for dynamic-replicator, which has been
 	 * validated by AMBA core
@@ -301,16 +306,16 @@ static int replicator_remove(struct device *dev)
 	return 0;
 }
 
-static int static_replicator_probe(struct platform_device *pdev)
+static int replicator_platform_probe(struct platform_device *pdev)
 {
+	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	int ret;
 
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
 
-	/* Static replicators do not have programming base */
-	ret = replicator_probe(&pdev->dev, NULL);
+	ret = replicator_probe(&pdev->dev, res);
 
 	if (ret) {
 		pm_runtime_put_noidle(&pdev->dev);
@@ -320,7 +325,7 @@ static int static_replicator_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int static_replicator_remove(struct platform_device *pdev)
+static int replicator_platform_remove(struct platform_device *pdev)
 {
 	replicator_remove(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
@@ -335,6 +340,8 @@ static int replicator_runtime_suspend(struct device *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);
 	return 0;
 }
 
@@ -345,6 +352,8 @@ static int replicator_runtime_resume(struct device *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);
 	return 0;
 }
 #endif
@@ -354,31 +363,32 @@ static const struct dev_pm_ops replicator_dev_pm_ops = {
 			   replicator_runtime_resume, NULL)
 };
 
-static const struct of_device_id static_replicator_match[] = {
+static const struct of_device_id replicator_match[] = {
 	{.compatible = "arm,coresight-replicator"},
 	{.compatible = "arm,coresight-static-replicator"},
 	{}
 };
 
-MODULE_DEVICE_TABLE(of, static_replicator_match);
+MODULE_DEVICE_TABLE(of, replicator_match);
 
 #ifdef CONFIG_ACPI
-static const struct acpi_device_id static_replicator_acpi_ids[] = {
+static const struct acpi_device_id replicator_acpi_ids[] = {
 	{"ARMHC985", 0}, /* ARM CoreSight Static Replicator */
+	{"ARMHC98D", 0}, /* ARM CoreSight Dynamic Replicator */
 	{}
 };
 
-MODULE_DEVICE_TABLE(acpi, static_replicator_acpi_ids);
+MODULE_DEVICE_TABLE(acpi, replicator_acpi_ids);
 #endif
 
-static struct platform_driver static_replicator_driver = {
-	.probe          = static_replicator_probe,
-	.remove         = static_replicator_remove,
+static struct platform_driver replicator_driver = {
+	.probe          = replicator_platform_probe,
+	.remove         = replicator_platform_remove,
 	.driver         = {
-		.name   = "coresight-static-replicator",
+		.name   = "coresight-replicator",
 		/* THIS_MODULE is taken care of by platform_driver_register() */
-		.of_match_table = of_match_ptr(static_replicator_match),
-		.acpi_match_table = ACPI_PTR(static_replicator_acpi_ids),
+		.of_match_table = of_match_ptr(replicator_match),
+		.acpi_match_table = ACPI_PTR(replicator_acpi_ids),
 		.pm	= &replicator_dev_pm_ops,
 		.suppress_bind_attrs = true,
 	},
@@ -419,7 +429,7 @@ static int __init replicator_init(void)
 {
 	int ret;
 
-	ret = platform_driver_register(&static_replicator_driver);
+	ret = platform_driver_register(&replicator_driver);
 	if (ret) {
 		pr_info("Error registering platform driver\n");
 		return ret;
@@ -428,7 +438,7 @@ static int __init replicator_init(void)
 	ret = amba_driver_register(&dynamic_replicator_driver);
 	if (ret) {
 		pr_info("Error registering amba driver\n");
-		platform_driver_unregister(&static_replicator_driver);
+		platform_driver_unregister(&replicator_driver);
 	}
 
 	return ret;
@@ -436,7 +446,7 @@ static int __init replicator_init(void)
 
 static void __exit replicator_exit(void)
 {
-	platform_driver_unregister(&static_replicator_driver);
+	platform_driver_unregister(&replicator_driver);
 	amba_driver_unregister(&dynamic_replicator_driver);
 }
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH V2 2/7] coresight: funnel: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 [PATCH V2 0/7] coresight: Move remaining AMBA ACPI devices into platform driver Anshuman Khandual
  2023-12-01  6:20 ` [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to " Anshuman Khandual
@ 2023-12-01  6:20 ` Anshuman Khandual
  2023-12-01 12:35   ` Sudeep Holla
  2023-12-01  6:20 ` [PATCH V2 3/7] coresight: catu: " Anshuman Khandual
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-01  6:20 UTC (permalink / raw)
  To: linux-arm-kernel, suzuki.poulose
  Cc: Anshuman Khandual, Lorenzo Pieralisi, Sudeep Holla, Mike Leach,
	James Clark, Maxime Coquelin, Alexandre Torgue, linux-acpi,
	linux-kernel, coresight, linux-stm32

Add support for the dynamic funnel device in the platform driver, which can
then be used on ACPI based platforms. This change would allow runtime power
management for ACPI based systems.

The driver would try to enable the APB clock if available. Also, rename the
code to reflect the fact that it now handles both static and dynamic
funnels.

Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: James Clark <james.clark@arm.com>
Cc: linux-acpi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: coresight@lists.linaro.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 drivers/acpi/arm64/amba.c                     |  1 -
 .../hwtracing/coresight/coresight-funnel.c    | 49 ++++++++++++-------
 2 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
index 270f4e3819a2..afb6afb66967 100644
--- a/drivers/acpi/arm64/amba.c
+++ b/drivers/acpi/arm64/amba.c
@@ -28,7 +28,6 @@ static const struct acpi_device_id amba_id_list[] = {
 	{"ARMHC979", 0}, /* ARM CoreSight TPIU */
 	{"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */
 	{"ARMHC9CA", 0}, /* ARM CoreSight CATU */
-	{"ARMHC9FF", 0}, /* ARM CoreSight Dynamic Funnel */
 	{"", 0},
 };
 
diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
index b8e150e45b27..939fe79f031f 100644
--- a/drivers/hwtracing/coresight/coresight-funnel.c
+++ b/drivers/hwtracing/coresight/coresight-funnel.c
@@ -43,6 +43,7 @@ DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel");
 struct funnel_drvdata {
 	void __iomem		*base;
 	struct clk		*atclk;
+	struct clk		*pclk;
 	struct coresight_device	*csdev;
 	unsigned long		priority;
 	spinlock_t		spinlock;
@@ -236,6 +237,10 @@ static int funnel_probe(struct device *dev, struct resource *res)
 			return ret;
 	}
 
+	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
+	if (IS_ERR(drvdata->pclk))
+		return -ENODEV;
+
 	/*
 	 * Map the device base for dynamic-funnel, which has been
 	 * validated by AMBA core.
@@ -298,6 +303,9 @@ static int funnel_runtime_suspend(struct device *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);
+
 	return 0;
 }
 
@@ -308,6 +316,8 @@ static int funnel_runtime_resume(struct device *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);
 	return 0;
 }
 #endif
@@ -316,16 +326,16 @@ static const struct dev_pm_ops funnel_dev_pm_ops = {
 	SET_RUNTIME_PM_OPS(funnel_runtime_suspend, funnel_runtime_resume, NULL)
 };
 
-static int static_funnel_probe(struct platform_device *pdev)
+static int funnel_platform_probe(struct platform_device *pdev)
 {
+	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	int ret;
 
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
 
-	/* Static funnel do not have programming base */
-	ret = funnel_probe(&pdev->dev, NULL);
+	ret = funnel_probe(&pdev->dev, res);
 
 	if (ret) {
 		pm_runtime_put_noidle(&pdev->dev);
@@ -335,37 +345,38 @@ static int static_funnel_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int static_funnel_remove(struct platform_device *pdev)
+static int funnel_platform_remove(struct platform_device *pdev)
 {
 	funnel_remove(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 	return 0;
 }
 
-static const struct of_device_id static_funnel_match[] = {
+static const struct of_device_id funnel_match[] = {
 	{.compatible = "arm,coresight-static-funnel"},
 	{}
 };
 
-MODULE_DEVICE_TABLE(of, static_funnel_match);
+MODULE_DEVICE_TABLE(of, funnel_match);
 
 #ifdef CONFIG_ACPI
-static const struct acpi_device_id static_funnel_ids[] = {
-	{"ARMHC9FE", 0},
+static const struct acpi_device_id funnel_acpi_ids[] = {
+	{"ARMHC9FE", 0}, /* ARM Coresight Static Funnel */
+	{"ARMHC9FF", 0}, /* ARM CoreSight Dynamic Funnel */
 	{},
 };
 
-MODULE_DEVICE_TABLE(acpi, static_funnel_ids);
+MODULE_DEVICE_TABLE(acpi, funnel_acpi_ids);
 #endif
 
-static struct platform_driver static_funnel_driver = {
-	.probe          = static_funnel_probe,
-	.remove          = static_funnel_remove,
-	.driver         = {
-		.name   = "coresight-static-funnel",
+static struct platform_driver funnel_driver = {
+	.probe	= funnel_platform_probe,
+	.remove	= funnel_platform_remove,
+	.driver	= {
+		.name   = "coresight-funnel",
 		/* THIS_MODULE is taken care of by platform_driver_register() */
-		.of_match_table = static_funnel_match,
-		.acpi_match_table = ACPI_PTR(static_funnel_ids),
+		.of_match_table = funnel_match,
+		.acpi_match_table = ACPI_PTR(funnel_acpi_ids),
 		.pm	= &funnel_dev_pm_ops,
 		.suppress_bind_attrs = true,
 	},
@@ -413,7 +424,7 @@ static int __init funnel_init(void)
 {
 	int ret;
 
-	ret = platform_driver_register(&static_funnel_driver);
+	ret = platform_driver_register(&funnel_driver);
 	if (ret) {
 		pr_info("Error registering platform driver\n");
 		return ret;
@@ -422,7 +433,7 @@ static int __init funnel_init(void)
 	ret = amba_driver_register(&dynamic_funnel_driver);
 	if (ret) {
 		pr_info("Error registering amba driver\n");
-		platform_driver_unregister(&static_funnel_driver);
+		platform_driver_unregister(&funnel_driver);
 	}
 
 	return ret;
@@ -430,7 +441,7 @@ static int __init funnel_init(void)
 
 static void __exit funnel_exit(void)
 {
-	platform_driver_unregister(&static_funnel_driver);
+	platform_driver_unregister(&funnel_driver);
 	amba_driver_unregister(&dynamic_funnel_driver);
 }
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH V2 3/7] coresight: catu: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 [PATCH V2 0/7] coresight: Move remaining AMBA ACPI devices into platform driver Anshuman Khandual
  2023-12-01  6:20 ` [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to " Anshuman Khandual
  2023-12-01  6:20 ` [PATCH V2 2/7] coresight: funnel: " Anshuman Khandual
@ 2023-12-01  6:20 ` Anshuman Khandual
  2023-12-01 12:35   ` Sudeep Holla
  2023-12-01 13:41   ` Suzuki K Poulose
  2023-12-01  6:20 ` [PATCH V2 4/7] coresight: tpiu: " Anshuman Khandual
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-01  6:20 UTC (permalink / raw)
  To: linux-arm-kernel, suzuki.poulose
  Cc: Anshuman Khandual, Lorenzo Pieralisi, Sudeep Holla, Mike Leach,
	James Clark, Maxime Coquelin, Alexandre Torgue, linux-acpi,
	linux-kernel, coresight, linux-stm32

Add support for the catu devices in a new platform driver, which can then
be used on ACPI based platforms. This change would now allow runtime power
management for ACPI based systems. The driver would try to enable the APB
clock if available.

Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: James Clark <james.clark@arm.com>
Cc: linux-acpi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: coresight@lists.linaro.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 drivers/acpi/arm64/amba.c                    |   1 -
 drivers/hwtracing/coresight/coresight-catu.c | 130 ++++++++++++++++---
 drivers/hwtracing/coresight/coresight-catu.h |   1 +
 drivers/hwtracing/coresight/coresight-core.c |  29 +++++
 include/linux/coresight.h                    |   7 +
 5 files changed, 149 insertions(+), 19 deletions(-)

diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
index afb6afb66967..587061b0fd2f 100644
--- a/drivers/acpi/arm64/amba.c
+++ b/drivers/acpi/arm64/amba.c
@@ -27,7 +27,6 @@ static const struct acpi_device_id amba_id_list[] = {
 	{"ARMHC503", 0}, /* ARM CoreSight Debug */
 	{"ARMHC979", 0}, /* ARM CoreSight TPIU */
 	{"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */
-	{"ARMHC9CA", 0}, /* ARM CoreSight CATU */
 	{"", 0},
 };
 
diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
index 3949ded0d4fa..ba5ee7d158dd 100644
--- a/drivers/hwtracing/coresight/coresight-catu.c
+++ b/drivers/hwtracing/coresight/coresight-catu.c
@@ -7,6 +7,8 @@
  * Author: Suzuki K Poulose <suzuki.poulose@arm.com>
  */
 
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
 #include <linux/amba/bus.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
@@ -502,28 +504,20 @@ static const struct coresight_ops catu_ops = {
 	.helper_ops = &catu_helper_ops,
 };
 
-static int catu_probe(struct amba_device *adev, const struct amba_id *id)
+static int __catu_probe(struct device *dev, struct resource *res)
 {
 	int ret = 0;
 	u32 dma_mask;
-	struct catu_drvdata *drvdata;
+	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
 	struct coresight_desc catu_desc;
 	struct coresight_platform_data *pdata = NULL;
-	struct device *dev = &adev->dev;
 	void __iomem *base;
 
 	catu_desc.name = coresight_alloc_device_name(&catu_devs, dev);
 	if (!catu_desc.name)
 		return -ENOMEM;
 
-	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
-	if (!drvdata) {
-		ret = -ENOMEM;
-		goto out;
-	}
-
-	dev_set_drvdata(dev, drvdata);
-	base = devm_ioremap_resource(dev, &adev->res);
+	base = devm_ioremap_resource(dev, res);
 	if (IS_ERR(base)) {
 		ret = PTR_ERR(base);
 		goto out;
@@ -568,18 +562,35 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id)
 	if (IS_ERR(drvdata->csdev))
 		ret = PTR_ERR(drvdata->csdev);
 	else
-		pm_runtime_put(&adev->dev);
+		pm_runtime_put(dev);
 out:
 	return ret;
 }
 
-static void catu_remove(struct amba_device *adev)
+static int catu_probe(struct amba_device *adev, const struct amba_id *id)
+{
+	struct catu_drvdata *drvdata;
+
+	drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
+	amba_set_drvdata(adev, drvdata);
+	return __catu_probe(&adev->dev, &adev->res);
+}
+
+static void __catu_remove(struct device *dev)
 {
-	struct catu_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
 
 	coresight_unregister(drvdata->csdev);
 }
 
+static void catu_remove(struct amba_device *adev)
+{
+	__catu_remove(&adev->dev);
+}
+
 static struct amba_id catu_ids[] = {
 	CS_AMBA_ID(0x000bb9ee),
 	{},
@@ -598,13 +609,96 @@ static struct amba_driver catu_driver = {
 	.id_table			= catu_ids,
 };
 
+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;
+
+	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
+	if (IS_ERR(drvdata->pclk))
+		return -ENODEV;
+
+	if (res) {
+		drvdata->base = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(drvdata->base)) {
+			clk_put(drvdata->pclk);
+			return PTR_ERR(drvdata->base);
+		}
+	}
+
+	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);
+	if (ret) {
+		pm_runtime_put_noidle(&pdev->dev);
+		pm_runtime_disable(&pdev->dev);
+	}
+	return ret;
+}
+
+static int catu_platform_remove(struct platform_device *pdev)
+{
+	__catu_remove(&pdev->dev);
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int catu_runtime_suspend(struct device *dev)
+{
+	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
+
+	if (drvdata->pclk && !IS_ERR_OR_NULL(drvdata->pclk))
+		clk_disable_unprepare(drvdata->pclk);
+	return 0;
+}
+
+static int catu_runtime_resume(struct device *dev)
+{
+	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
+
+	if (drvdata->pclk && !IS_ERR_OR_NULL(drvdata->pclk))
+		clk_prepare_enable(drvdata->pclk);
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops catu_dev_pm_ops = {
+	SET_RUNTIME_PM_OPS(catu_runtime_suspend, catu_runtime_resume, NULL)
+};
+
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id catu_acpi_ids[] = {
+	{"ARMHC9CA", 0}, /* ARM CoreSight CATU */
+	{},
+};
+
+MODULE_DEVICE_TABLE(acpi, catu_acpi_ids);
+#endif
+
+static struct platform_driver catu_platform_driver = {
+	.probe	= catu_platform_probe,
+	.remove	= catu_platform_remove,
+	.driver	= {
+		.name			= "coresight-catu-platform",
+		.acpi_match_table	= ACPI_PTR(catu_acpi_ids),
+		.suppress_bind_attrs	= true,
+		.pm			= &catu_dev_pm_ops,
+	},
+};
+
 static int __init catu_init(void)
 {
 	int ret;
 
-	ret = amba_driver_register(&catu_driver);
-	if (ret)
-		pr_info("Error registering catu driver\n");
+	ret = coresight_init_driver("catu", &catu_driver, &catu_platform_driver);
 	tmc_etr_set_catu_ops(&etr_catu_buf_ops);
 	return ret;
 }
@@ -612,7 +706,7 @@ static int __init catu_init(void)
 static void __exit catu_exit(void)
 {
 	tmc_etr_remove_catu_ops();
-	amba_driver_unregister(&catu_driver);
+	coresight_remove_driver(&catu_driver, &catu_platform_driver);
 }
 
 module_init(catu_init);
diff --git a/drivers/hwtracing/coresight/coresight-catu.h b/drivers/hwtracing/coresight/coresight-catu.h
index 442e034bbfba..141feac1c14b 100644
--- a/drivers/hwtracing/coresight/coresight-catu.h
+++ b/drivers/hwtracing/coresight/coresight-catu.h
@@ -61,6 +61,7 @@
 #define CATU_IRQEN_OFF		0x0
 
 struct catu_drvdata {
+	struct clk *pclk;
 	void __iomem *base;
 	struct coresight_device *csdev;
 	int irq;
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index 9fabe00a40d6..ede9b0723f95 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1833,6 +1833,35 @@ static void __exit coresight_exit(void)
 module_init(coresight_init);
 module_exit(coresight_exit);
 
+int coresight_init_driver(const char *drv, struct amba_driver *amba_drv,
+			  struct platform_driver *pdev_drv)
+{
+	int ret;
+
+	ret = amba_driver_register(amba_drv);
+	if (ret) {
+		pr_err("%s: error registering AMBA driver\n", drv);
+		return ret;
+	}
+
+	ret = platform_driver_register(pdev_drv);
+	if (!ret)
+		return 0;
+
+	pr_err("%s: error registering platform driver\n", drv);
+	amba_driver_unregister(amba_drv);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(coresight_init_driver);
+
+void coresight_remove_driver(struct amba_driver *amba_drv,
+			     struct platform_driver *pdev_drv)
+{
+	amba_driver_unregister(amba_drv);
+	platform_driver_unregister(pdev_drv);
+}
+EXPORT_SYMBOL_GPL(coresight_remove_driver);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
 MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
diff --git a/include/linux/coresight.h b/include/linux/coresight.h
index a269fffaf991..be7fe3793763 100644
--- a/include/linux/coresight.h
+++ b/include/linux/coresight.h
@@ -12,6 +12,8 @@
 #include <linux/io.h>
 #include <linux/perf_event.h>
 #include <linux/sched.h>
+#include <linux/amba/bus.h>
+#include <linux/platform_device.h>
 
 /* Peripheral id registers (0xFD0-0xFEC) */
 #define CORESIGHT_PERIPHIDR4	0xfd0
@@ -597,6 +599,11 @@ void coresight_relaxed_write64(struct coresight_device *csdev,
 			       u64 val, u32 offset);
 void coresight_write64(struct coresight_device *csdev, u64 val, u32 offset);
 
+int coresight_init_driver(const char *drv, struct amba_driver *amba_drv,
+			  struct platform_driver *pdev_drv);
+
+void coresight_remove_driver(struct amba_driver *amba_drv,
+			     struct platform_driver *pdev_drv);
 #else
 static inline struct coresight_device *
 coresight_register(struct coresight_desc *desc) { return NULL; }
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH V2 4/7] coresight: tpiu: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 [PATCH V2 0/7] coresight: Move remaining AMBA ACPI devices into platform driver Anshuman Khandual
                   ` (2 preceding siblings ...)
  2023-12-01  6:20 ` [PATCH V2 3/7] coresight: catu: " Anshuman Khandual
@ 2023-12-01  6:20 ` Anshuman Khandual
  2023-12-01 12:36   ` Sudeep Holla
  2023-12-01  6:20 ` [PATCH V2 5/7] coresight: tmc: " Anshuman Khandual
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-01  6:20 UTC (permalink / raw)
  To: linux-arm-kernel, suzuki.poulose
  Cc: Anshuman Khandual, Lorenzo Pieralisi, Sudeep Holla, Mike Leach,
	James Clark, Maxime Coquelin, Alexandre Torgue, linux-acpi,
	linux-kernel, coresight, linux-stm32

Add support for the tpiu device in the platform driver, which can then be
used on ACPI based platforms. This change would now allow runtime power
management for ACPI based systems. The driver would try to enable the APB
clock if available.

Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: James Clark <james.clark@arm.com>
Cc: linux-acpi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: coresight@lists.linaro.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 drivers/acpi/arm64/amba.c                    |  1 -
 drivers/hwtracing/coresight/coresight-tpiu.c | 87 ++++++++++++++++++--
 2 files changed, 79 insertions(+), 9 deletions(-)

diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
index 587061b0fd2f..6d24a8f7914b 100644
--- a/drivers/acpi/arm64/amba.c
+++ b/drivers/acpi/arm64/amba.c
@@ -25,7 +25,6 @@ static const struct acpi_device_id amba_id_list[] = {
 	{"ARMHC501", 0}, /* ARM CoreSight ETR */
 	{"ARMHC502", 0}, /* ARM CoreSight STM */
 	{"ARMHC503", 0}, /* ARM CoreSight Debug */
-	{"ARMHC979", 0}, /* ARM CoreSight TPIU */
 	{"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */
 	{"", 0},
 };
diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c
index 59eac93fd6bb..3ee7c5064389 100644
--- a/drivers/hwtracing/coresight/coresight-tpiu.c
+++ b/drivers/hwtracing/coresight/coresight-tpiu.c
@@ -5,6 +5,8 @@
  * Description: CoreSight Trace Port Interface Unit driver
  */
 
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
 #include <linux/atomic.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -57,6 +59,7 @@ DEFINE_CORESIGHT_DEVLIST(tpiu_devs, "tpiu");
 struct tpiu_drvdata {
 	void __iomem		*base;
 	struct clk		*atclk;
+	struct clk		*pclk;
 	struct coresight_device	*csdev;
 };
 
@@ -114,14 +117,12 @@ static const struct coresight_ops tpiu_cs_ops = {
 	.sink_ops	= &tpiu_sink_ops,
 };
 
-static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)
+static int __tpiu_probe(struct device *dev, struct resource *res)
 {
 	int ret;
 	void __iomem *base;
-	struct device *dev = &adev->dev;
 	struct coresight_platform_data *pdata = NULL;
 	struct tpiu_drvdata *drvdata;
-	struct resource *res = &adev->res;
 	struct coresight_desc desc = { 0 };
 
 	desc.name = coresight_alloc_device_name(&tpiu_devs, dev);
@@ -132,12 +133,16 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */
+	drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */
 	if (!IS_ERR(drvdata->atclk)) {
 		ret = clk_prepare_enable(drvdata->atclk);
 		if (ret)
 			return ret;
 	}
+
+	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
+	if (IS_ERR(drvdata->pclk))
+		return -ENODEV;
 	dev_set_drvdata(dev, drvdata);
 
 	/* Validity for the resource is already checked by the AMBA core */
@@ -164,20 +169,30 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)
 	drvdata->csdev = coresight_register(&desc);
 
 	if (!IS_ERR(drvdata->csdev)) {
-		pm_runtime_put(&adev->dev);
+		pm_runtime_put(dev);
 		return 0;
 	}
 
 	return PTR_ERR(drvdata->csdev);
 }
 
-static void tpiu_remove(struct amba_device *adev)
+static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)
 {
-	struct tpiu_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+	return __tpiu_probe(&adev->dev, &adev->res);
+}
+
+static void __tpiu_remove(struct device *dev)
+{
+	struct tpiu_drvdata *drvdata = dev_get_drvdata(dev);
 
 	coresight_unregister(drvdata->csdev);
 }
 
+static void tpiu_remove(struct amba_device *adev)
+{
+	__tpiu_remove(&adev->dev);
+}
+
 #ifdef CONFIG_PM
 static int tpiu_runtime_suspend(struct device *dev)
 {
@@ -186,6 +201,8 @@ static int tpiu_runtime_suspend(struct device *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);
 	return 0;
 }
 
@@ -196,6 +213,8 @@ static int tpiu_runtime_resume(struct device *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);
 	return 0;
 }
 #endif
@@ -235,7 +254,59 @@ static struct amba_driver tpiu_driver = {
 	.id_table	= tpiu_ids,
 };
 
-module_amba_driver(tpiu_driver);
+static int tpiu_platform_probe(struct platform_device *pdev)
+{
+	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	int ret;
+
+	pm_runtime_get_noresume(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+
+	ret = __tpiu_probe(&pdev->dev, res);
+	if (ret) {
+		pm_runtime_put_noidle(&pdev->dev);
+		pm_runtime_disable(&pdev->dev);
+	}
+	return ret;
+}
+
+static int tpiu_platform_remove(struct platform_device *pdev)
+{
+	__tpiu_remove(&pdev->dev);
+	return 0;
+}
+
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id tpiu_acpi_ids[] = {
+	{"ARMHC979", 0}, /* ARM CoreSight TPIU */
+	{}
+};
+MODULE_DEVICE_TABLE(acpi, tpiu_acpi_ids);
+#endif
+
+static struct platform_driver tpiu_platform_driver = {
+	.probe	= tpiu_platform_probe,
+	.remove	= tpiu_platform_remove,
+	.driver = {
+		.name			= "coresight-tpiu-platform",
+		.acpi_match_table	= ACPI_PTR(tpiu_acpi_ids),
+		.suppress_bind_attrs	= true,
+		.pm			= &tpiu_dev_pm_ops,
+	},
+};
+
+static int __init tpiu_init(void)
+{
+	return coresight_init_driver("tpiu", &tpiu_driver, &tpiu_platform_driver);
+}
+
+static void __exit tpiu_exit(void)
+{
+	coresight_remove_driver(&tpiu_driver, &tpiu_platform_driver);
+}
+module_init(tpiu_init);
+module_exit(tpiu_exit);
 
 MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
 MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH V2 5/7] coresight: tmc: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 [PATCH V2 0/7] coresight: Move remaining AMBA ACPI devices into platform driver Anshuman Khandual
                   ` (3 preceding siblings ...)
  2023-12-01  6:20 ` [PATCH V2 4/7] coresight: tpiu: " Anshuman Khandual
@ 2023-12-01  6:20 ` Anshuman Khandual
  2023-12-01 12:36   ` Sudeep Holla
                     ` (2 more replies)
  2023-12-01  6:20 ` [PATCH V2 6/7] coresight: stm: " Anshuman Khandual
  2023-12-01  6:20 ` [PATCH V2 7/7] coresight: debug: " Anshuman Khandual
  6 siblings, 3 replies; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-01  6:20 UTC (permalink / raw)
  To: linux-arm-kernel, suzuki.poulose
  Cc: Anshuman Khandual, Lorenzo Pieralisi, Sudeep Holla, Mike Leach,
	James Clark, Maxime Coquelin, Alexandre Torgue, linux-acpi,
	linux-kernel, coresight, linux-stm32

Add support for the tmc devices in the platform driver, which can then be
used on ACPI based platforms. This change would now allow runtime power
management for ACPI based systems. The driver would try to enable the APB
clock if available.

Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: James Clark <james.clark@arm.com>
Cc: linux-acpi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: coresight@lists.linaro.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 drivers/acpi/arm64/amba.c                     |   2 -
 .../hwtracing/coresight/coresight-tmc-core.c  | 130 +++++++++++++++---
 drivers/hwtracing/coresight/coresight-tmc.h   |   1 +
 3 files changed, 115 insertions(+), 18 deletions(-)

diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
index 6d24a8f7914b..d3c1defa7bc8 100644
--- a/drivers/acpi/arm64/amba.c
+++ b/drivers/acpi/arm64/amba.c
@@ -22,10 +22,8 @@
 static const struct acpi_device_id amba_id_list[] = {
 	{"ARMH0061", 0}, /* PL061 GPIO Device */
 	{"ARMH0330", 0}, /* ARM DMA Controller DMA-330 */
-	{"ARMHC501", 0}, /* ARM CoreSight ETR */
 	{"ARMHC502", 0}, /* ARM CoreSight STM */
 	{"ARMHC503", 0}, /* ARM CoreSight Debug */
-	{"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */
 	{"", 0},
 };
 
diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
index c106d142e632..13b6dcb8b390 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-core.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
@@ -23,6 +23,8 @@
 #include <linux/of.h>
 #include <linux/coresight.h>
 #include <linux/amba/bus.h>
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
 
 #include "coresight-priv.h"
 #include "coresight-tmc.h"
@@ -429,24 +431,17 @@ static u32 tmc_etr_get_max_burst_size(struct device *dev)
 	return burst_size;
 }
 
-static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
+static int __tmc_probe(struct device *dev, struct resource *res, void *dev_caps)
 {
 	int ret = 0;
 	u32 devid;
 	void __iomem *base;
-	struct device *dev = &adev->dev;
 	struct coresight_platform_data *pdata = NULL;
-	struct tmc_drvdata *drvdata;
-	struct resource *res = &adev->res;
+	struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
 	struct coresight_desc desc = { 0 };
 	struct coresight_dev_list *dev_list = NULL;
 
 	ret = -ENOMEM;
-	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
-	if (!drvdata)
-		goto out;
-
-	dev_set_drvdata(dev, drvdata);
 
 	/* Validity for the resource is already checked by the AMBA core */
 	base = devm_ioremap_resource(dev, res);
@@ -487,8 +482,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
 		desc.type = CORESIGHT_DEV_TYPE_SINK;
 		desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM;
 		desc.ops = &tmc_etr_cs_ops;
-		ret = tmc_etr_setup_caps(dev, devid,
-					 coresight_get_uci_data(id));
+		ret = tmc_etr_setup_caps(dev, devid, dev_caps);
 		if (ret)
 			goto out;
 		idr_init(&drvdata->idr);
@@ -519,7 +513,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
 		ret = PTR_ERR(pdata);
 		goto out;
 	}
-	adev->dev.platform_data = pdata;
+	dev->platform_data = pdata;
 	desc.pdata = pdata;
 
 	drvdata->csdev = coresight_register(&desc);
@@ -535,11 +529,23 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
 	if (ret)
 		coresight_unregister(drvdata->csdev);
 	else
-		pm_runtime_put(&adev->dev);
+		pm_runtime_put(dev);
 out:
 	return ret;
 }
 
+static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
+{
+	struct tmc_drvdata *drvdata;
+
+	drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
+	amba_set_drvdata(adev, drvdata);
+	return __tmc_probe(&adev->dev, &adev->res, coresight_get_uci_data(id));
+}
+
 static void tmc_shutdown(struct amba_device *adev)
 {
 	unsigned long flags;
@@ -562,9 +568,9 @@ static void tmc_shutdown(struct amba_device *adev)
 	spin_unlock_irqrestore(&drvdata->spinlock, flags);
 }
 
-static void tmc_remove(struct amba_device *adev)
+static void __tmc_remove(struct device *dev)
 {
-	struct tmc_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+	struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
 
 	/*
 	 * Since misc_open() holds a refcount on the f_ops, which is
@@ -575,6 +581,11 @@ static void tmc_remove(struct amba_device *adev)
 	coresight_unregister(drvdata->csdev);
 }
 
+static void tmc_remove(struct amba_device *adev)
+{
+	__tmc_remove(&adev->dev);
+}
+
 static const struct amba_id tmc_ids[] = {
 	CS_AMBA_ID(0x000bb961),
 	/* Coresight SoC 600 TMC-ETR/ETS */
@@ -600,7 +611,94 @@ static struct amba_driver tmc_driver = {
 	.id_table	= tmc_ids,
 };
 
-module_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;
+
+	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
+	if (IS_ERR(drvdata->pclk))
+		return -ENODEV;
+
+	dev_set_drvdata(&pdev->dev, drvdata);
+	pm_runtime_get_noresume(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+
+	ret = __tmc_probe(&pdev->dev, res, NULL);
+	if (ret) {
+		pm_runtime_put_noidle(&pdev->dev);
+		pm_runtime_disable(&pdev->dev);
+	}
+	return ret;
+}
+
+static int tmc_platform_remove(struct platform_device *pdev)
+{
+	__tmc_remove(&pdev->dev);
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int tmc_runtime_suspend(struct device *dev)
+{
+	struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
+
+	if (drvdata->pclk && !IS_ERR_OR_NULL(drvdata->pclk))
+		clk_disable_unprepare(drvdata->pclk);
+	return 0;
+}
+
+static int tmc_runtime_resume(struct device *dev)
+{
+	struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
+
+	if (drvdata->pclk && !IS_ERR_OR_NULL(drvdata->pclk))
+		clk_prepare_enable(drvdata->pclk);
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops tmc_dev_pm_ops = {
+	SET_RUNTIME_PM_OPS(tmc_runtime_suspend, tmc_runtime_resume, NULL)
+};
+
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id tmc_acpi_ids[] = {
+	{"ARMHC501", 0}, /* ARM CoreSight ETR */
+	{"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */
+	{},
+};
+MODULE_DEVICE_TABLE(acpi, tmc_acpi_ids);
+#endif
+
+static struct platform_driver tmc_platform_driver = {
+	.probe	= tmc_platform_probe,
+	.remove	= tmc_platform_remove,
+	.driver	= {
+		.name			= "coresight-tmc-platform",
+		.acpi_match_table	= ACPI_PTR(tmc_acpi_ids),
+		.suppress_bind_attrs	= true,
+		.pm			= &tmc_dev_pm_ops,
+	},
+};
+
+static int __init tmc_init(void)
+{
+	return coresight_init_driver("tmc", &tmc_driver, &tmc_platform_driver);
+}
+
+static void __exit tmc_exit(void)
+{
+	coresight_remove_driver(&tmc_driver, &tmc_platform_driver);
+}
+module_init(tmc_init);
+module_exit(tmc_exit);
 
 MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
 MODULE_DESCRIPTION("Arm CoreSight Trace Memory Controller driver");
diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h
index 0ee48c5ba764..193af5959f2c 100644
--- a/drivers/hwtracing/coresight/coresight-tmc.h
+++ b/drivers/hwtracing/coresight/coresight-tmc.h
@@ -189,6 +189,7 @@ struct etr_buf {
  * @perf_buf:	PERF buffer for ETR.
  */
 struct tmc_drvdata {
+	struct clk		*pclk;
 	void __iomem		*base;
 	struct coresight_device	*csdev;
 	struct miscdevice	miscdev;
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH V2 6/7] coresight: stm: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 [PATCH V2 0/7] coresight: Move remaining AMBA ACPI devices into platform driver Anshuman Khandual
                   ` (4 preceding siblings ...)
  2023-12-01  6:20 ` [PATCH V2 5/7] coresight: tmc: " Anshuman Khandual
@ 2023-12-01  6:20 ` Anshuman Khandual
  2023-12-01 12:36   ` Sudeep Holla
  2023-12-04 10:23   ` James Clark
  2023-12-01  6:20 ` [PATCH V2 7/7] coresight: debug: " Anshuman Khandual
  6 siblings, 2 replies; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-01  6:20 UTC (permalink / raw)
  To: linux-arm-kernel, suzuki.poulose
  Cc: Anshuman Khandual, Lorenzo Pieralisi, Sudeep Holla, Mike Leach,
	James Clark, Maxime Coquelin, Alexandre Torgue, linux-acpi,
	linux-kernel, coresight, linux-stm32

Add support for the stm devices in the platform driver, which can then be
used on ACPI based platforms. This change would now allow runtime power
management for ACPI based systems. The driver would try to enable the APB
clock if available.

Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: James Clark <james.clark@arm.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: linux-acpi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: coresight@lists.linaro.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 drivers/acpi/arm64/amba.c                   |  1 -
 drivers/hwtracing/coresight/coresight-stm.c | 91 ++++++++++++++++++---
 2 files changed, 81 insertions(+), 11 deletions(-)

diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
index d3c1defa7bc8..bec0976541da 100644
--- a/drivers/acpi/arm64/amba.c
+++ b/drivers/acpi/arm64/amba.c
@@ -22,7 +22,6 @@
 static const struct acpi_device_id amba_id_list[] = {
 	{"ARMH0061", 0}, /* PL061 GPIO Device */
 	{"ARMH0330", 0}, /* ARM DMA Controller DMA-330 */
-	{"ARMHC502", 0}, /* ARM CoreSight STM */
 	{"ARMHC503", 0}, /* ARM CoreSight Debug */
 	{"", 0},
 };
diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index a1c27c901ad1..564aa5f1eb8a 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -29,6 +29,8 @@
 #include <linux/perf_event.h>
 #include <linux/pm_runtime.h>
 #include <linux/stm.h>
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
 
 #include "coresight-priv.h"
 #include "coresight-trace-id.h"
@@ -132,6 +134,7 @@ DEFINE_CORESIGHT_DEVLIST(stm_devs, "stm");
 struct stm_drvdata {
 	void __iomem		*base;
 	struct clk		*atclk;
+	struct clk		*pclk;
 	struct coresight_device	*csdev;
 	spinlock_t		spinlock;
 	struct channel_space	chs;
@@ -804,14 +807,12 @@ static void stm_init_generic_data(struct stm_drvdata *drvdata,
 	drvdata->stm.set_options = stm_generic_set_options;
 }
 
-static int stm_probe(struct amba_device *adev, const struct amba_id *id)
+static int __stm_probe(struct device *dev, struct resource *res, void *dev_caps)
 {
 	int ret, trace_id;
 	void __iomem *base;
-	struct device *dev = &adev->dev;
 	struct coresight_platform_data *pdata = NULL;
 	struct stm_drvdata *drvdata;
-	struct resource *res = &adev->res;
 	struct resource ch_res;
 	struct coresight_desc desc = { 0 };
 
@@ -823,12 +824,16 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
 	if (!drvdata)
 		return -ENOMEM;
 
-	drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */
+	drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */
 	if (!IS_ERR(drvdata->atclk)) {
 		ret = clk_prepare_enable(drvdata->atclk);
 		if (ret)
 			return ret;
 	}
+
+	drvdata->pclk = coresight_get_enable_apb_pclk(dev);
+	if (IS_ERR(drvdata->pclk))
+		return -ENODEV;
 	dev_set_drvdata(dev, drvdata);
 
 	base = devm_ioremap_resource(dev, res);
@@ -876,7 +881,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
 		ret = PTR_ERR(pdata);
 		goto stm_unregister;
 	}
-	adev->dev.platform_data = pdata;
+	dev->platform_data = pdata;
 
 	desc.type = CORESIGHT_DEV_TYPE_SOURCE;
 	desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE;
@@ -897,10 +902,10 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
 	}
 	drvdata->traceid = (u8)trace_id;
 
-	pm_runtime_put(&adev->dev);
+	pm_runtime_put(dev);
 
 	dev_info(&drvdata->csdev->dev, "%s initialized\n",
-		 (char *)coresight_get_uci_data(id));
+		 (char *)dev_caps);
 	return 0;
 
 cs_unregister:
@@ -911,9 +916,14 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
 	return ret;
 }
 
-static void stm_remove(struct amba_device *adev)
+static int stm_probe(struct amba_device *adev, const struct amba_id *id)
 {
-	struct stm_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+	return __stm_probe(&adev->dev, &adev->res, coresight_get_uci_data(id));
+}
+
+static void __stm_remove(struct device *dev)
+{
+	struct stm_drvdata *drvdata = dev_get_drvdata(dev);
 
 	coresight_trace_id_put_system_id(drvdata->traceid);
 	coresight_unregister(drvdata->csdev);
@@ -921,6 +931,11 @@ static void stm_remove(struct amba_device *adev)
 	stm_unregister_device(&drvdata->stm);
 }
 
+static void stm_remove(struct amba_device *adev)
+{
+	__stm_remove(&adev->dev);
+}
+
 #ifdef CONFIG_PM
 static int stm_runtime_suspend(struct device *dev)
 {
@@ -929,6 +944,8 @@ static int stm_runtime_suspend(struct device *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);
 	return 0;
 }
 
@@ -939,6 +956,8 @@ static int stm_runtime_resume(struct device *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);
 	return 0;
 }
 #endif
@@ -967,7 +986,59 @@ static struct amba_driver stm_driver = {
 	.id_table	= stm_ids,
 };
 
-module_amba_driver(stm_driver);
+static int stm_platform_probe(struct platform_device *pdev)
+{
+	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	int ret = 0;
+
+	pm_runtime_get_noresume(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+
+	ret = __stm_probe(&pdev->dev, res, NULL);
+	if (ret) {
+		pm_runtime_put_noidle(&pdev->dev);
+		pm_runtime_disable(&pdev->dev);
+	}
+	return ret;
+}
+
+static int stm_platform_remove(struct platform_device *pdev)
+{
+	__stm_remove(&pdev->dev);
+	return 0;
+}
+
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id stm_acpi_ids[] = {
+	{"ARMHC502", 0}, /* ARM CoreSight STM */
+	{},
+};
+MODULE_DEVICE_TABLE(acpi, stm_acpi_ids);
+#endif
+
+static struct platform_driver stm_platform_driver = {
+	.probe	= stm_platform_probe,
+	.remove	= stm_platform_remove,
+	.driver	= {
+		.name			= "coresight-stm-platform",
+		.acpi_match_table	= ACPI_PTR(stm_acpi_ids),
+		.suppress_bind_attrs	= true,
+		.pm			= &stm_dev_pm_ops,
+	},
+};
+
+static int __init stm_init(void)
+{
+	return coresight_init_driver("stm", &stm_driver, &stm_platform_driver);
+}
+
+static void __exit stm_exit(void)
+{
+	coresight_remove_driver(&stm_driver, &stm_platform_driver);
+}
+module_init(stm_init);
+module_exit(stm_exit);
 
 MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
 MODULE_DESCRIPTION("Arm CoreSight System Trace Macrocell driver");
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH V2 7/7] coresight: debug: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 [PATCH V2 0/7] coresight: Move remaining AMBA ACPI devices into platform driver Anshuman Khandual
                   ` (5 preceding siblings ...)
  2023-12-01  6:20 ` [PATCH V2 6/7] coresight: stm: " Anshuman Khandual
@ 2023-12-01  6:20 ` Anshuman Khandual
  2023-12-01 12:37   ` Sudeep Holla
  6 siblings, 1 reply; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-01  6:20 UTC (permalink / raw)
  To: linux-arm-kernel, suzuki.poulose
  Cc: Anshuman Khandual, Lorenzo Pieralisi, Sudeep Holla, Mike Leach,
	James Clark, Maxime Coquelin, Alexandre Torgue, linux-acpi,
	linux-kernel, coresight, linux-stm32

Add support for the cpu debug devices in a new platform driver, which can
then be used on ACPI based platforms. This change would now allow runtime
power management for ACPI based systems. The driver would try to enable
the APB clock if available.

Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: James Clark <james.clark@arm.com>
Cc: linux-acpi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: coresight@lists.linaro.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 drivers/acpi/arm64/amba.c                     |   1 -
 .../hwtracing/coresight/coresight-cpu-debug.c | 141 ++++++++++++++++--
 2 files changed, 127 insertions(+), 15 deletions(-)

diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
index bec0976541da..e1f0bbb8f393 100644
--- a/drivers/acpi/arm64/amba.c
+++ b/drivers/acpi/arm64/amba.c
@@ -22,7 +22,6 @@
 static const struct acpi_device_id amba_id_list[] = {
 	{"ARMH0061", 0}, /* PL061 GPIO Device */
 	{"ARMH0330", 0}, /* ARM DMA Controller DMA-330 */
-	{"ARMHC503", 0}, /* ARM CoreSight Debug */
 	{"", 0},
 };
 
diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index 1874df7c6a73..75a0ba8c62a4 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -23,6 +23,8 @@
 #include <linux/smp.h>
 #include <linux/types.h>
 #include <linux/uaccess.h>
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
 
 #include "coresight-priv.h"
 
@@ -84,6 +86,7 @@
 #define DEBUG_WAIT_TIMEOUT		32000
 
 struct debug_drvdata {
+	struct clk	*pclk;
 	void __iomem	*base;
 	struct device	*dev;
 	int		cpu;
@@ -557,18 +560,12 @@ static void debug_func_exit(void)
 	debugfs_remove_recursive(debug_debugfs_dir);
 }
 
-static int debug_probe(struct amba_device *adev, const struct amba_id *id)
+static int __debug_probe(struct device *dev, struct resource *res)
 {
+	struct debug_drvdata *drvdata = dev_get_drvdata(dev);
 	void __iomem *base;
-	struct device *dev = &adev->dev;
-	struct debug_drvdata *drvdata;
-	struct resource *res = &adev->res;
 	int ret;
 
-	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
-	if (!drvdata)
-		return -ENOMEM;
-
 	drvdata->cpu = coresight_get_cpu(dev);
 	if (drvdata->cpu < 0)
 		return drvdata->cpu;
@@ -579,8 +576,7 @@ static int debug_probe(struct amba_device *adev, const struct amba_id *id)
 		return -EBUSY;
 	}
 
-	drvdata->dev = &adev->dev;
-	amba_set_drvdata(adev, drvdata);
+	drvdata->dev = dev;
 
 	/* Validity for the resource is already checked by the AMBA core */
 	base = devm_ioremap_resource(dev, res);
@@ -629,10 +625,21 @@ static int debug_probe(struct amba_device *adev, const struct amba_id *id)
 	return ret;
 }
 
-static void debug_remove(struct amba_device *adev)
+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);
+}
+
+static void __debug_remove(struct device *dev)
 {
-	struct device *dev = &adev->dev;
-	struct debug_drvdata *drvdata = amba_get_drvdata(adev);
+	struct debug_drvdata *drvdata = dev_get_drvdata(dev);
 
 	per_cpu(debug_drvdata, drvdata->cpu) = NULL;
 
@@ -646,6 +653,11 @@ static void debug_remove(struct amba_device *adev)
 		debug_func_exit();
 }
 
+static void debug_remove(struct amba_device *adev)
+{
+	__debug_remove(&adev->dev);
+}
+
 static const struct amba_cs_uci_id uci_id_debug[] = {
 	{
 		/*  CPU Debug UCI data */
@@ -677,7 +689,108 @@ static struct amba_driver debug_driver = {
 	.id_table	= debug_ids,
 };
 
-module_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;
+
+	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
+	if (IS_ERR(drvdata->pclk))
+		return -ENODEV;
+
+	if (res) {
+		drvdata->base = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(drvdata->base)) {
+			clk_put(drvdata->pclk);
+			return PTR_ERR(drvdata->base);
+		}
+	}
+
+	dev_set_drvdata(&pdev->dev, drvdata);
+	pm_runtime_get_noresume(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+
+	ret = __debug_probe(&pdev->dev, res);
+	if (ret) {
+		pm_runtime_put_noidle(&pdev->dev);
+		pm_runtime_disable(&pdev->dev);
+	}
+	return ret;
+}
+
+static int debug_platform_remove(struct platform_device *pdev)
+{
+	struct debug_drvdata *drvdata = dev_get_drvdata(&pdev->dev);
+
+	if (drvdata)
+		__debug_remove(&pdev->dev);
+
+	pm_runtime_disable(&pdev->dev);
+	if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
+		clk_put(drvdata->pclk);
+	return 0;
+}
+
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id debug_platform_ids[] = {
+	{"ARMHC503", 0}, /* ARM CoreSight Debug */
+	{},
+};
+MODULE_DEVICE_TABLE(acpi, debug_platform_ids);
+#endif
+
+#ifdef CONFIG_PM
+static int debug_runtime_suspend(struct device *dev)
+{
+	struct debug_drvdata *drvdata = dev_get_drvdata(dev);
+
+	if (drvdata->pclk && !IS_ERR_OR_NULL(drvdata->pclk))
+		clk_disable_unprepare(drvdata->pclk);
+	return 0;
+}
+
+static int debug_runtime_resume(struct device *dev)
+{
+	struct debug_drvdata *drvdata = dev_get_drvdata(dev);
+
+	if (drvdata->pclk && !IS_ERR_OR_NULL(drvdata->pclk))
+		clk_prepare_enable(drvdata->pclk);
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops debug_dev_pm_ops = {
+	SET_RUNTIME_PM_OPS(debug_runtime_suspend, debug_runtime_resume, NULL)
+};
+
+static struct platform_driver debug_platform_driver = {
+	.probe	= debug_platform_probe,
+	.remove	= debug_platform_remove,
+	.driver	= {
+		.name			= "coresight-debug-platform",
+		.acpi_match_table	= ACPI_PTR(debug_platform_ids),
+		.suppress_bind_attrs	= true,
+		.pm			= &debug_dev_pm_ops,
+	},
+};
+
+static int __init debug_init(void)
+{
+	return coresight_init_driver("tmc", &debug_driver, &debug_platform_driver);
+}
+
+static void __exit debug_exit(void)
+{
+	coresight_remove_driver(&debug_driver, &debug_platform_driver);
+}
+module_init(debug_init);
+module_exit(debug_exit);
 
 MODULE_AUTHOR("Leo Yan <leo.yan@linaro.org>");
 MODULE_DESCRIPTION("ARM Coresight CPU Debug Driver");
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 ` [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to " Anshuman Khandual
@ 2023-12-01 12:35   ` Sudeep Holla
  2023-12-04  4:26     ` Anshuman Khandual
  0 siblings, 1 reply; 33+ messages in thread
From: Sudeep Holla @ 2023-12-01 12:35 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-arm-kernel, suzuki.poulose, Lorenzo Pieralisi, Sudeep Holla,
	Mike Leach, James Clark, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32

On Fri, Dec 01, 2023 at 11:50:47AM +0530, Anshuman Khandual wrote:
> Add support for the dynamic replicator device in the platform driver, which
> can then be used on ACPI based platforms. This change would now allow
> runtime power management for repliacator devices on ACPI based systems.
> 
> The driver would try to enable the APB clock if available. Also, rename the
> code to reflect the fact that it now handles both static and dynamic
> replicators.
> 
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Sudeep Holla <sudeep.holla@arm.com>

Except the minor nit below which may apply also for few other patches
in the series

Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes
Tested-by: Sudeep Holla <sudeep.holla@arm.com> # Boot and driver probe only

[...]

> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
> index b6be73034996..64de0bee02ec 100644
> --- a/drivers/hwtracing/coresight/coresight-replicator.c
> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
> @@ -38,6 +38,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
>  struct replicator_drvdata {
>  	void __iomem		*base;
>  	struct clk		*atclk;
> +	struct clk		*pclk;

[minor nit] Perhaps can be documented as well ?

-- 
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 2/7] coresight: funnel: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 ` [PATCH V2 2/7] coresight: funnel: " Anshuman Khandual
@ 2023-12-01 12:35   ` Sudeep Holla
  0 siblings, 0 replies; 33+ messages in thread
From: Sudeep Holla @ 2023-12-01 12:35 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-arm-kernel, suzuki.poulose, Lorenzo Pieralisi, Sudeep Holla,
	Mike Leach, James Clark, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32

On Fri, Dec 01, 2023 at 11:50:48AM +0530, Anshuman Khandual wrote:
> Add support for the dynamic funnel device in the platform driver, which can
> then be used on ACPI based platforms. This change would allow runtime power
> management for ACPI based systems.
> 
> The driver would try to enable the APB clock if available. Also, rename the
> code to reflect the fact that it now handles both static and dynamic
> funnels.
> 
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Sudeep Holla <sudeep.holla@arm.com>

Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes
Tested-by: Sudeep Holla <sudeep.holla@arm.com> # Boot and driver probe only

-- 
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 3/7] coresight: catu: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 ` [PATCH V2 3/7] coresight: catu: " Anshuman Khandual
@ 2023-12-01 12:35   ` Sudeep Holla
  2023-12-01 13:41   ` Suzuki K Poulose
  1 sibling, 0 replies; 33+ messages in thread
From: Sudeep Holla @ 2023-12-01 12:35 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-arm-kernel, suzuki.poulose, Lorenzo Pieralisi, Sudeep Holla,
	Mike Leach, James Clark, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32

On Fri, Dec 01, 2023 at 11:50:49AM +0530, Anshuman Khandual wrote:
> Add support for the catu devices in a new platform driver, which can then
> be used on ACPI based platforms. This change would now allow runtime power
> management for ACPI based systems. The driver would try to enable the APB
> clock if available.
> 
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Sudeep Holla <sudeep.holla@arm.com>

Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes

-- 
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 4/7] coresight: tpiu: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 ` [PATCH V2 4/7] coresight: tpiu: " Anshuman Khandual
@ 2023-12-01 12:36   ` Sudeep Holla
  0 siblings, 0 replies; 33+ messages in thread
From: Sudeep Holla @ 2023-12-01 12:36 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-arm-kernel, suzuki.poulose, Lorenzo Pieralisi, Mike Leach,
	Sudeep Holla, James Clark, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32

On Fri, Dec 01, 2023 at 11:50:50AM +0530, Anshuman Khandual wrote:
> Add support for the tpiu device in the platform driver, which can then be
> used on ACPI based platforms. This change would now allow runtime power
> management for ACPI based systems. The driver would try to enable the APB
> clock if available.
> 
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Sudeep Holla <sudeep.holla@arm.com>

Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes
Tested-by: Sudeep Holla <sudeep.holla@arm.com> # Boot and driver probe only

-- 
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 5/7] coresight: tmc: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 ` [PATCH V2 5/7] coresight: tmc: " Anshuman Khandual
@ 2023-12-01 12:36   ` Sudeep Holla
  2023-12-04 10:42   ` James Clark
  2023-12-04 10:54   ` James Clark
  2 siblings, 0 replies; 33+ messages in thread
From: Sudeep Holla @ 2023-12-01 12:36 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-arm-kernel, suzuki.poulose, Lorenzo Pieralisi, Mike Leach,
	Sudeep Holla, James Clark, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32

On Fri, Dec 01, 2023 at 11:50:51AM +0530, Anshuman Khandual wrote:
> Add support for the tmc devices in the platform driver, which can then be
> used on ACPI based platforms. This change would now allow runtime power
> management for ACPI based systems. The driver would try to enable the APB
> clock if available.
> 
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Sudeep Holla <sudeep.holla@arm.com>

Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes
Tested-by: Sudeep Holla <sudeep.holla@arm.com> # Boot and driver probe only

-- 
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 6/7] coresight: stm: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 ` [PATCH V2 6/7] coresight: stm: " Anshuman Khandual
@ 2023-12-01 12:36   ` Sudeep Holla
  2023-12-04 10:23   ` James Clark
  1 sibling, 0 replies; 33+ messages in thread
From: Sudeep Holla @ 2023-12-01 12:36 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-arm-kernel, suzuki.poulose, Lorenzo Pieralisi, Mike Leach,
	Sudeep Holla, James Clark, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32

On Fri, Dec 01, 2023 at 11:50:52AM +0530, Anshuman Khandual wrote:
> Add support for the stm devices in the platform driver, which can then be
> used on ACPI based platforms. This change would now allow runtime power
> management for ACPI based systems. The driver would try to enable the APB
> clock if available.
> 
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Sudeep Holla <sudeep.holla@arm.com>

Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes
Tested-by: Sudeep Holla <sudeep.holla@arm.com> # Boot and driver probe only

-- 
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 7/7] coresight: debug: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 ` [PATCH V2 7/7] coresight: debug: " Anshuman Khandual
@ 2023-12-01 12:37   ` Sudeep Holla
  0 siblings, 0 replies; 33+ messages in thread
From: Sudeep Holla @ 2023-12-01 12:37 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-arm-kernel, suzuki.poulose, Lorenzo Pieralisi, Mike Leach,
	Sudeep Holla, James Clark, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32

On Fri, Dec 01, 2023 at 11:50:53AM +0530, Anshuman Khandual wrote:
> Add support for the cpu debug devices in a new platform driver, which can
> then be used on ACPI based platforms. This change would now allow runtime
> power management for ACPI based systems. The driver would try to enable
> the APB clock if available.
> 
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Sudeep Holla <sudeep.holla@arm.com>

Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes

-- 
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 3/7] coresight: catu: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 ` [PATCH V2 3/7] coresight: catu: " Anshuman Khandual
  2023-12-01 12:35   ` Sudeep Holla
@ 2023-12-01 13:41   ` Suzuki K Poulose
  2023-12-04  6:48     ` Anshuman Khandual
  1 sibling, 1 reply; 33+ messages in thread
From: Suzuki K Poulose @ 2023-12-01 13:41 UTC (permalink / raw)
  To: Anshuman Khandual, linux-arm-kernel
  Cc: Lorenzo Pieralisi, Sudeep Holla, Mike Leach, James Clark,
	Maxime Coquelin, Alexandre Torgue, linux-acpi, linux-kernel,
	coresight, linux-stm32

Hi Anshuman,

On 01/12/2023 06:20, Anshuman Khandual wrote:
> Add support for the catu devices in a new platform driver, which can then
> be used on ACPI based platforms. This change would now allow runtime power
> management for ACPI based systems. The driver would try to enable the APB
> clock if available.

This doesn't talk about the new helper. As such I would prefer that to 
be a separate preparatory patch. See below.

> 
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Sudeep Holla <sudeep.holla@arm.com>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Mike Leach <mike.leach@linaro.org>
> Cc: James Clark <james.clark@arm.com>
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Cc: coresight@lists.linaro.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>   drivers/acpi/arm64/amba.c                    |   1 -
>   drivers/hwtracing/coresight/coresight-catu.c | 130 ++++++++++++++++---
>   drivers/hwtracing/coresight/coresight-catu.h |   1 +
>   drivers/hwtracing/coresight/coresight-core.c |  29 +++++
>   include/linux/coresight.h                    |   7 +
>   5 files changed, 149 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
> index afb6afb66967..587061b0fd2f 100644
> --- a/drivers/acpi/arm64/amba.c
> +++ b/drivers/acpi/arm64/amba.c
> @@ -27,7 +27,6 @@ static const struct acpi_device_id amba_id_list[] = {
>   	{"ARMHC503", 0}, /* ARM CoreSight Debug */
>   	{"ARMHC979", 0}, /* ARM CoreSight TPIU */
>   	{"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */
> -	{"ARMHC9CA", 0}, /* ARM CoreSight CATU */
>   	{"", 0},
>   };
>   
> diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
> index 3949ded0d4fa..ba5ee7d158dd 100644
> --- a/drivers/hwtracing/coresight/coresight-catu.c
> +++ b/drivers/hwtracing/coresight/coresight-catu.c
> @@ -7,6 +7,8 @@
>    * Author: Suzuki K Poulose <suzuki.poulose@arm.com>
>    */
>   
> +#include <linux/platform_device.h>
> +#include <linux/acpi.h>
>   #include <linux/amba/bus.h>
>   #include <linux/device.h>
>   #include <linux/dma-mapping.h>
> @@ -502,28 +504,20 @@ static const struct coresight_ops catu_ops = {
>   	.helper_ops = &catu_helper_ops,
>   };
>   
> -static int catu_probe(struct amba_device *adev, const struct amba_id *id)
> +static int __catu_probe(struct device *dev, struct resource *res)
>   {
>   	int ret = 0;
>   	u32 dma_mask;
> -	struct catu_drvdata *drvdata;
> +	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
>   	struct coresight_desc catu_desc;
>   	struct coresight_platform_data *pdata = NULL;
> -	struct device *dev = &adev->dev;
>   	void __iomem *base;
>   
>   	catu_desc.name = coresight_alloc_device_name(&catu_devs, dev);
>   	if (!catu_desc.name)
>   		return -ENOMEM;
>   
> -	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> -	if (!drvdata) {
> -		ret = -ENOMEM;
> -		goto out;
> -	}
> -
> -	dev_set_drvdata(dev, drvdata);
> -	base = devm_ioremap_resource(dev, &adev->res);
> +	base = devm_ioremap_resource(dev, res);
>   	if (IS_ERR(base)) {
>   		ret = PTR_ERR(base);
>   		goto out;
> @@ -568,18 +562,35 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id)
>   	if (IS_ERR(drvdata->csdev))
>   		ret = PTR_ERR(drvdata->csdev);
>   	else
> -		pm_runtime_put(&adev->dev);
> +		pm_runtime_put(dev);
>   out:
>   	return ret;
>   }
>   
> -static void catu_remove(struct amba_device *adev)
> +static int catu_probe(struct amba_device *adev, const struct amba_id *id)
> +{
> +	struct catu_drvdata *drvdata;
> +
> +	drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL);
> +	if (!drvdata)
> +		return -ENOMEM;
> +
> +	amba_set_drvdata(adev, drvdata);
> +	return __catu_probe(&adev->dev, &adev->res);
> +}
> +
> +static void __catu_remove(struct device *dev)
>   {
> -	struct catu_drvdata *drvdata = dev_get_drvdata(&adev->dev);
> +	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
>   
>   	coresight_unregister(drvdata->csdev);
>   }
>   
> +static void catu_remove(struct amba_device *adev)
> +{
> +	__catu_remove(&adev->dev);
> +}
> +
>   static struct amba_id catu_ids[] = {
>   	CS_AMBA_ID(0x000bb9ee),
>   	{},
> @@ -598,13 +609,96 @@ static struct amba_driver catu_driver = {
>   	.id_table			= catu_ids,
>   };
>   
> +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;
> +
> +	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
> +	if (IS_ERR(drvdata->pclk))
> +		return -ENODEV;
> +
> +	if (res) {
> +		drvdata->base = devm_ioremap_resource(&pdev->dev, res);
> +		if (IS_ERR(drvdata->base)) {
> +			clk_put(drvdata->pclk);
> +			return PTR_ERR(drvdata->base);
> +		}
> +	}
> +
> +	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);
> +	if (ret) {
> +		pm_runtime_put_noidle(&pdev->dev);
> +		pm_runtime_disable(&pdev->dev);
> +	}
> +	return ret;
> +}
> +
> +static int catu_platform_remove(struct platform_device *pdev)
> +{
> +	__catu_remove(&pdev->dev);
> +	return 0;
> +}
> +
> +#ifdef CONFIG_PM
> +static int catu_runtime_suspend(struct device *dev)
> +{
> +	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
> +
> +	if (drvdata->pclk && !IS_ERR_OR_NULL(drvdata->pclk))

Only the second part is needed. IS_ERR_OR_NULL() already checks for NULL.

> +		clk_disable_unprepare(drvdata->pclk);
> +	return 0;
> +}
> +
> +static int catu_runtime_resume(struct device *dev)
> +{
> +	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
> +
> +	if (drvdata->pclk && !IS_ERR_OR_NULL(drvdata->pclk))

Same here.

> +		clk_prepare_enable(drvdata->pclk);
> +	return 0;
> +}
> +#endif
> +
> +static const struct dev_pm_ops catu_dev_pm_ops = {
> +	SET_RUNTIME_PM_OPS(catu_runtime_suspend, catu_runtime_resume, NULL)
> +};
> +
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id catu_acpi_ids[] = {
> +	{"ARMHC9CA", 0}, /* ARM CoreSight CATU */
> +	{},
> +};
> +
> +MODULE_DEVICE_TABLE(acpi, catu_acpi_ids);
> +#endif
> +
> +static struct platform_driver catu_platform_driver = {
> +	.probe	= catu_platform_probe,
> +	.remove	= catu_platform_remove,
> +	.driver	= {
> +		.name			= "coresight-catu-platform",
> +		.acpi_match_table	= ACPI_PTR(catu_acpi_ids),
> +		.suppress_bind_attrs	= true,
> +		.pm			= &catu_dev_pm_ops,
> +	},
> +};
> +
>   static int __init catu_init(void)
>   {
>   	int ret;
>   
> -	ret = amba_driver_register(&catu_driver);
> -	if (ret)
> -		pr_info("Error registering catu driver\n");
> +	ret = coresight_init_driver("catu", &catu_driver, &catu_platform_driver);
>   	tmc_etr_set_catu_ops(&etr_catu_buf_ops);
>   	return ret;
>   }
> @@ -612,7 +706,7 @@ static int __init catu_init(void)
>   static void __exit catu_exit(void)
>   {
>   	tmc_etr_remove_catu_ops();
> -	amba_driver_unregister(&catu_driver);
> +	coresight_remove_driver(&catu_driver, &catu_platform_driver);
>   }
>   
>   module_init(catu_init);
> diff --git a/drivers/hwtracing/coresight/coresight-catu.h b/drivers/hwtracing/coresight/coresight-catu.h
> index 442e034bbfba..141feac1c14b 100644
> --- a/drivers/hwtracing/coresight/coresight-catu.h
> +++ b/drivers/hwtracing/coresight/coresight-catu.h
> @@ -61,6 +61,7 @@
>   #define CATU_IRQEN_OFF		0x0
>   
>   struct catu_drvdata {
> +	struct clk *pclk;
>   	void __iomem *base;
>   	struct coresight_device *csdev;
>   	int irq;
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index 9fabe00a40d6..ede9b0723f95 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -1833,6 +1833,35 @@ static void __exit coresight_exit(void)
>   module_init(coresight_init);
>   module_exit(coresight_exit);
>   

---8>---

> +int coresight_init_driver(const char *drv, struct amba_driver *amba_drv,
> +			  struct platform_driver *pdev_drv)
> +{
> +	int ret;
> +
> +	ret = amba_driver_register(amba_drv);
> +	if (ret) {
> +		pr_err("%s: error registering AMBA driver\n", drv);
> +		return ret;
> +	}
> +
> +	ret = platform_driver_register(pdev_drv);
> +	if (!ret)
> +		return 0;
> +
> +	pr_err("%s: error registering platform driver\n", drv);
> +	amba_driver_unregister(amba_drv);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(coresight_init_driver);
> +
> +void coresight_remove_driver(struct amba_driver *amba_drv,
> +			     struct platform_driver *pdev_drv)
> +{
> +	amba_driver_unregister(amba_drv);
> +	platform_driver_unregister(pdev_drv);
> +}
> +EXPORT_SYMBOL_GPL(coresight_remove_driver);

Please could we split this into a separate patch itself ? Also, can we 
not use them for the other components ? funnel, replicator ?


> +
>   MODULE_LICENSE("GPL v2");
>   MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
>   MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
> diff --git a/include/linux/coresight.h b/include/linux/coresight.h
> index a269fffaf991..be7fe3793763 100644
> --- a/include/linux/coresight.h
> +++ b/include/linux/coresight.h
> @@ -12,6 +12,8 @@
>   #include <linux/io.h>
>   #include <linux/perf_event.h>
>   #include <linux/sched.h>
> +#include <linux/amba/bus.h>
> +#include <linux/platform_device.h>
>   
>   /* Peripheral id registers (0xFD0-0xFEC) */
>   #define CORESIGHT_PERIPHIDR4	0xfd0
> @@ -597,6 +599,11 @@ void coresight_relaxed_write64(struct coresight_device *csdev,
>   			       u64 val, u32 offset);
>   void coresight_write64(struct coresight_device *csdev, u64 val, u32 offset);
>   
> +int coresight_init_driver(const char *drv, struct amba_driver *amba_drv,
> +			  struct platform_driver *pdev_drv);
> +
> +void coresight_remove_driver(struct amba_driver *amba_drv,
> +			     struct platform_driver *pdev_drv);
>   #else
>   static inline struct coresight_device *
>   coresight_register(struct coresight_desc *desc) { return NULL; }


Suzuki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to platform driver
  2023-12-01 12:35   ` Sudeep Holla
@ 2023-12-04  4:26     ` Anshuman Khandual
  2023-12-04  4:48       ` Anshuman Khandual
  0 siblings, 1 reply; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-04  4:26 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: linux-arm-kernel, suzuki.poulose, Lorenzo Pieralisi, Mike Leach,
	James Clark, Maxime Coquelin, Alexandre Torgue, linux-acpi,
	linux-kernel, coresight, linux-stm32



On 12/1/23 18:05, Sudeep Holla wrote:
> On Fri, Dec 01, 2023 at 11:50:47AM +0530, Anshuman Khandual wrote:
>> Add support for the dynamic replicator device in the platform driver, which
>> can then be used on ACPI based platforms. This change would now allow
>> runtime power management for repliacator devices on ACPI based systems.
>>
>> The driver would try to enable the APB clock if available. Also, rename the
>> code to reflect the fact that it now handles both static and dynamic
>> replicators.
>>
>> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
>> Cc: Sudeep Holla <sudeep.holla@arm.com>
> 
> Except the minor nit below which may apply also for few other patches
> in the series
> 
> Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes
> Tested-by: Sudeep Holla <sudeep.holla@arm.com> # Boot and driver probe only
> 
> [...]
> 
>> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
>> index b6be73034996..64de0bee02ec 100644
>> --- a/drivers/hwtracing/coresight/coresight-replicator.c
>> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
>> @@ -38,6 +38,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
>>  struct replicator_drvdata {
>>  	void __iomem		*base;
>>  	struct clk		*atclk;
>> +	struct clk		*pclk;
> 
> [minor nit] Perhaps can be documented as well ?

Sure, will add the following comment above the structure.

@pclk:    optional clock for the core parts of the replicator.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to platform driver
  2023-12-04  4:26     ` Anshuman Khandual
@ 2023-12-04  4:48       ` Anshuman Khandual
  2023-12-04  9:57         ` James Clark
  0 siblings, 1 reply; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-04  4:48 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: linux-arm-kernel, Lorenzo Pieralisi, Mike Leach, Maxime Coquelin,
	Alexandre Torgue, linux-acpi, linux-kernel, coresight,
	linux-stm32



On 12/4/23 09:56, Anshuman Khandual wrote:
> 
> 
> On 12/1/23 18:05, Sudeep Holla wrote:
>> On Fri, Dec 01, 2023 at 11:50:47AM +0530, Anshuman Khandual wrote:
>>> Add support for the dynamic replicator device in the platform driver, which
>>> can then be used on ACPI based platforms. This change would now allow
>>> runtime power management for repliacator devices on ACPI based systems.
>>>
>>> The driver would try to enable the APB clock if available. Also, rename the
>>> code to reflect the fact that it now handles both static and dynamic
>>> replicators.
>>>
>>> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
>>> Cc: Sudeep Holla <sudeep.holla@arm.com>
>>
>> Except the minor nit below which may apply also for few other patches
>> in the series
>>
>> Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes
>> Tested-by: Sudeep Holla <sudeep.holla@arm.com> # Boot and driver probe only
>>
>> [...]
>>
>>> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
>>> index b6be73034996..64de0bee02ec 100644
>>> --- a/drivers/hwtracing/coresight/coresight-replicator.c
>>> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
>>> @@ -38,6 +38,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
>>>  struct replicator_drvdata {
>>>  	void __iomem		*base;
>>>  	struct clk		*atclk;
>>> +	struct clk		*pclk;
>>
>> [minor nit] Perhaps can be documented as well ?
> 
> Sure, will add the following comment above the structure.
> 
> @pclk:    optional clock for the core parts of the replicator.

My bad, this will be the following instead.

diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
index 64de0bee02ec..44b9a77ec8aa 100644
--- a/drivers/hwtracing/coresight/coresight-replicator.c
+++ b/drivers/hwtracing/coresight/coresight-replicator.c
@@ -31,6 +31,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
  * @base:      memory mapped base address for this component. Also indicates
  *             whether this one is programmable or not.
  * @atclk:     optional clock for the core parts of the replicator.
+ * @pclk:      APB clock if present, otherwise NULL
  * @csdev:     component vitals needed by the framework
  * @spinlock:  serialize enable/disable operations.
  * @check_idfilter_val: check if the context is lost upon clock removal.

I will update replicator, tpiu, tmc, and stm devices.

struct catu_drvdata and debug_drvdata do not have the comment section itself.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 3/7] coresight: catu: Move ACPI support from AMBA driver to platform driver
  2023-12-01 13:41   ` Suzuki K Poulose
@ 2023-12-04  6:48     ` Anshuman Khandual
  0 siblings, 0 replies; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-04  6:48 UTC (permalink / raw)
  To: Suzuki K Poulose, linux-arm-kernel
  Cc: Lorenzo Pieralisi, Sudeep Holla, Mike Leach, James Clark,
	Maxime Coquelin, Alexandre Torgue, linux-acpi, linux-kernel,
	coresight, linux-stm32



On 12/1/23 19:11, Suzuki K Poulose wrote:
> Hi Anshuman,
> 
> On 01/12/2023 06:20, Anshuman Khandual wrote:
>> Add support for the catu devices in a new platform driver, which can then
>> be used on ACPI based platforms. This change would now allow runtime power
>> management for ACPI based systems. The driver would try to enable the APB
>> clock if available.
> 
> This doesn't talk about the new helper. As such I would prefer that to be a separate preparatory patch. See below.

Makes sense.

> 
>>
>> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
>> Cc: Sudeep Holla <sudeep.holla@arm.com>
>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
>> Cc: Mike Leach <mike.leach@linaro.org>
>> Cc: James Clark <james.clark@arm.com>
>> Cc: linux-acpi@vger.kernel.org
>> Cc: linux-arm-kernel@lists.infradead.org
>> Cc: linux-kernel@vger.kernel.org
>> Cc: coresight@lists.linaro.org
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>>   drivers/acpi/arm64/amba.c                    |   1 -
>>   drivers/hwtracing/coresight/coresight-catu.c | 130 ++++++++++++++++---
>>   drivers/hwtracing/coresight/coresight-catu.h |   1 +
>>   drivers/hwtracing/coresight/coresight-core.c |  29 +++++
>>   include/linux/coresight.h                    |   7 +
>>   5 files changed, 149 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
>> index afb6afb66967..587061b0fd2f 100644
>> --- a/drivers/acpi/arm64/amba.c
>> +++ b/drivers/acpi/arm64/amba.c
>> @@ -27,7 +27,6 @@ static const struct acpi_device_id amba_id_list[] = {
>>       {"ARMHC503", 0}, /* ARM CoreSight Debug */
>>       {"ARMHC979", 0}, /* ARM CoreSight TPIU */
>>       {"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */
>> -    {"ARMHC9CA", 0}, /* ARM CoreSight CATU */
>>       {"", 0},
>>   };
>>   diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
>> index 3949ded0d4fa..ba5ee7d158dd 100644
>> --- a/drivers/hwtracing/coresight/coresight-catu.c
>> +++ b/drivers/hwtracing/coresight/coresight-catu.c
>> @@ -7,6 +7,8 @@
>>    * Author: Suzuki K Poulose <suzuki.poulose@arm.com>
>>    */
>>   +#include <linux/platform_device.h>
>> +#include <linux/acpi.h>
>>   #include <linux/amba/bus.h>
>>   #include <linux/device.h>
>>   #include <linux/dma-mapping.h>
>> @@ -502,28 +504,20 @@ static const struct coresight_ops catu_ops = {
>>       .helper_ops = &catu_helper_ops,
>>   };
>>   -static int catu_probe(struct amba_device *adev, const struct amba_id *id)
>> +static int __catu_probe(struct device *dev, struct resource *res)
>>   {
>>       int ret = 0;
>>       u32 dma_mask;
>> -    struct catu_drvdata *drvdata;
>> +    struct catu_drvdata *drvdata = dev_get_drvdata(dev);
>>       struct coresight_desc catu_desc;
>>       struct coresight_platform_data *pdata = NULL;
>> -    struct device *dev = &adev->dev;
>>       void __iomem *base;
>>         catu_desc.name = coresight_alloc_device_name(&catu_devs, dev);
>>       if (!catu_desc.name)
>>           return -ENOMEM;
>>   -    drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
>> -    if (!drvdata) {
>> -        ret = -ENOMEM;
>> -        goto out;
>> -    }
>> -
>> -    dev_set_drvdata(dev, drvdata);
>> -    base = devm_ioremap_resource(dev, &adev->res);
>> +    base = devm_ioremap_resource(dev, res);
>>       if (IS_ERR(base)) {
>>           ret = PTR_ERR(base);
>>           goto out;
>> @@ -568,18 +562,35 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id)
>>       if (IS_ERR(drvdata->csdev))
>>           ret = PTR_ERR(drvdata->csdev);
>>       else
>> -        pm_runtime_put(&adev->dev);
>> +        pm_runtime_put(dev);
>>   out:
>>       return ret;
>>   }
>>   -static void catu_remove(struct amba_device *adev)
>> +static int catu_probe(struct amba_device *adev, const struct amba_id *id)
>> +{
>> +    struct catu_drvdata *drvdata;
>> +
>> +    drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL);
>> +    if (!drvdata)
>> +        return -ENOMEM;
>> +
>> +    amba_set_drvdata(adev, drvdata);
>> +    return __catu_probe(&adev->dev, &adev->res);
>> +}
>> +
>> +static void __catu_remove(struct device *dev)
>>   {
>> -    struct catu_drvdata *drvdata = dev_get_drvdata(&adev->dev);
>> +    struct catu_drvdata *drvdata = dev_get_drvdata(dev);
>>         coresight_unregister(drvdata->csdev);
>>   }
>>   +static void catu_remove(struct amba_device *adev)
>> +{
>> +    __catu_remove(&adev->dev);
>> +}
>> +
>>   static struct amba_id catu_ids[] = {
>>       CS_AMBA_ID(0x000bb9ee),
>>       {},
>> @@ -598,13 +609,96 @@ static struct amba_driver catu_driver = {
>>       .id_table            = catu_ids,
>>   };
>>   +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;
>> +
>> +    drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
>> +    if (IS_ERR(drvdata->pclk))
>> +        return -ENODEV;
>> +
>> +    if (res) {
>> +        drvdata->base = devm_ioremap_resource(&pdev->dev, res);
>> +        if (IS_ERR(drvdata->base)) {
>> +            clk_put(drvdata->pclk);
>> +            return PTR_ERR(drvdata->base);
>> +        }
>> +    }
>> +
>> +    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);
>> +    if (ret) {
>> +        pm_runtime_put_noidle(&pdev->dev);
>> +        pm_runtime_disable(&pdev->dev);
>> +    }
>> +    return ret;
>> +}
>> +
>> +static int catu_platform_remove(struct platform_device *pdev)
>> +{
>> +    __catu_remove(&pdev->dev);
>> +    return 0;
>> +}
>> +
>> +#ifdef CONFIG_PM
>> +static int catu_runtime_suspend(struct device *dev)
>> +{
>> +    struct catu_drvdata *drvdata = dev_get_drvdata(dev);
>> +
>> +    if (drvdata->pclk && !IS_ERR_OR_NULL(drvdata->pclk))
> 
> Only the second part is needed. IS_ERR_OR_NULL() already checks for NULL.

Actually, the first check here should be for valid drvdata instead,
ensuring that subsequent de-referencing for drvdata->pclk does not
crash. Will do this replacement for all affected patches.

> 
>> +        clk_disable_unprepare(drvdata->pclk);
>> +    return 0;
>> +}
>> +
>> +static int catu_runtime_resume(struct device *dev)
>> +{
>> +    struct catu_drvdata *drvdata = dev_get_drvdata(dev);
>> +
>> +    if (drvdata->pclk && !IS_ERR_OR_NULL(drvdata->pclk))
> 
> Same here.
> 
>> +        clk_prepare_enable(drvdata->pclk);
>> +    return 0;
>> +}
>> +#endif
>> +
>> +static const struct dev_pm_ops catu_dev_pm_ops = {
>> +    SET_RUNTIME_PM_OPS(catu_runtime_suspend, catu_runtime_resume, NULL)
>> +};
>> +
>> +#ifdef CONFIG_ACPI
>> +static const struct acpi_device_id catu_acpi_ids[] = {
>> +    {"ARMHC9CA", 0}, /* ARM CoreSight CATU */
>> +    {},
>> +};
>> +
>> +MODULE_DEVICE_TABLE(acpi, catu_acpi_ids);
>> +#endif
>> +
>> +static struct platform_driver catu_platform_driver = {
>> +    .probe    = catu_platform_probe,
>> +    .remove    = catu_platform_remove,
>> +    .driver    = {
>> +        .name            = "coresight-catu-platform",
>> +        .acpi_match_table    = ACPI_PTR(catu_acpi_ids),
>> +        .suppress_bind_attrs    = true,
>> +        .pm            = &catu_dev_pm_ops,
>> +    },
>> +};
>> +
>>   static int __init catu_init(void)
>>   {
>>       int ret;
>>   -    ret = amba_driver_register(&catu_driver);
>> -    if (ret)
>> -        pr_info("Error registering catu driver\n");
>> +    ret = coresight_init_driver("catu", &catu_driver, &catu_platform_driver);
>>       tmc_etr_set_catu_ops(&etr_catu_buf_ops);
>>       return ret;
>>   }
>> @@ -612,7 +706,7 @@ static int __init catu_init(void)
>>   static void __exit catu_exit(void)
>>   {
>>       tmc_etr_remove_catu_ops();
>> -    amba_driver_unregister(&catu_driver);
>> +    coresight_remove_driver(&catu_driver, &catu_platform_driver);
>>   }
>>     module_init(catu_init);
>> diff --git a/drivers/hwtracing/coresight/coresight-catu.h b/drivers/hwtracing/coresight/coresight-catu.h
>> index 442e034bbfba..141feac1c14b 100644
>> --- a/drivers/hwtracing/coresight/coresight-catu.h
>> +++ b/drivers/hwtracing/coresight/coresight-catu.h
>> @@ -61,6 +61,7 @@
>>   #define CATU_IRQEN_OFF        0x0
>>     struct catu_drvdata {
>> +    struct clk *pclk;
>>       void __iomem *base;
>>       struct coresight_device *csdev;
>>       int irq;
>> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
>> index 9fabe00a40d6..ede9b0723f95 100644
>> --- a/drivers/hwtracing/coresight/coresight-core.c
>> +++ b/drivers/hwtracing/coresight/coresight-core.c
>> @@ -1833,6 +1833,35 @@ static void __exit coresight_exit(void)
>>   module_init(coresight_init);
>>   module_exit(coresight_exit);
>>   
> 
> ---8>---
> 
>> +int coresight_init_driver(const char *drv, struct amba_driver *amba_drv,
>> +              struct platform_driver *pdev_drv)
>> +{
>> +    int ret;
>> +
>> +    ret = amba_driver_register(amba_drv);
>> +    if (ret) {
>> +        pr_err("%s: error registering AMBA driver\n", drv);
>> +        return ret;
>> +    }
>> +
>> +    ret = platform_driver_register(pdev_drv);
>> +    if (!ret)
>> +        return 0;
>> +
>> +    pr_err("%s: error registering platform driver\n", drv);
>> +    amba_driver_unregister(amba_drv);
>> +    return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(coresight_init_driver);
>> +
>> +void coresight_remove_driver(struct amba_driver *amba_drv,
>> +                 struct platform_driver *pdev_drv)
>> +{
>> +    amba_driver_unregister(amba_drv);
>> +    platform_driver_unregister(pdev_drv);
>> +}
>> +EXPORT_SYMBOL_GPL(coresight_remove_driver);
> 
> Please could we split this into a separate patch itself ? Also, can we not use them for the other components ? funnel, replicator ?

Sure, will split the helpers addition along with their header changes
into a separate patch at the beginning of this series, and then use
them for funnel and replicator devices in subsequent patches.

> 
> 
>> +
>>   MODULE_LICENSE("GPL v2");
>>   MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
>>   MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
>> diff --git a/include/linux/coresight.h b/include/linux/coresight.h
>> index a269fffaf991..be7fe3793763 100644
>> --- a/include/linux/coresight.h
>> +++ b/include/linux/coresight.h
>> @@ -12,6 +12,8 @@
>>   #include <linux/io.h>
>>   #include <linux/perf_event.h>
>>   #include <linux/sched.h>
>> +#include <linux/amba/bus.h>
>> +#include <linux/platform_device.h>
>>     /* Peripheral id registers (0xFD0-0xFEC) */
>>   #define CORESIGHT_PERIPHIDR4    0xfd0
>> @@ -597,6 +599,11 @@ void coresight_relaxed_write64(struct coresight_device *csdev,
>>                      u64 val, u32 offset);
>>   void coresight_write64(struct coresight_device *csdev, u64 val, u32 offset);
>>   +int coresight_init_driver(const char *drv, struct amba_driver *amba_drv,
>> +              struct platform_driver *pdev_drv);
>> +
>> +void coresight_remove_driver(struct amba_driver *amba_drv,
>> +                 struct platform_driver *pdev_drv);
>>   #else
>>   static inline struct coresight_device *
>>   coresight_register(struct coresight_desc *desc) { return NULL; }
> 
> 
> Suzuki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to platform driver
  2023-12-04  4:48       ` Anshuman Khandual
@ 2023-12-04  9:57         ` James Clark
  2023-12-04 11:37           ` Anshuman Khandual
  0 siblings, 1 reply; 33+ messages in thread
From: James Clark @ 2023-12-04  9:57 UTC (permalink / raw)
  To: Anshuman Khandual, Sudeep Holla
  Cc: linux-arm-kernel, Lorenzo Pieralisi, Mike Leach, Maxime Coquelin,
	Alexandre Torgue, linux-acpi, linux-kernel, coresight,
	linux-stm32



On 04/12/2023 04:48, Anshuman Khandual wrote:
> 
> 
> On 12/4/23 09:56, Anshuman Khandual wrote:
>>
>>
>> On 12/1/23 18:05, Sudeep Holla wrote:
>>> On Fri, Dec 01, 2023 at 11:50:47AM +0530, Anshuman Khandual wrote:
>>>> Add support for the dynamic replicator device in the platform driver, which
>>>> can then be used on ACPI based platforms. This change would now allow
>>>> runtime power management for repliacator devices on ACPI based systems.
>>>>
>>>> The driver would try to enable the APB clock if available. Also, rename the
>>>> code to reflect the fact that it now handles both static and dynamic
>>>> replicators.
>>>>
>>>> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
>>>> Cc: Sudeep Holla <sudeep.holla@arm.com>
>>>
>>> Except the minor nit below which may apply also for few other patches
>>> in the series
>>>
>>> Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes
>>> Tested-by: Sudeep Holla <sudeep.holla@arm.com> # Boot and driver probe only
>>>
>>> [...]
>>>
>>>> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
>>>> index b6be73034996..64de0bee02ec 100644
>>>> --- a/drivers/hwtracing/coresight/coresight-replicator.c
>>>> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
>>>> @@ -38,6 +38,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
>>>>  struct replicator_drvdata {
>>>>  	void __iomem		*base;
>>>>  	struct clk		*atclk;
>>>> +	struct clk		*pclk;
>>>
>>> [minor nit] Perhaps can be documented as well ?
>>
>> Sure, will add the following comment above the structure.
>>
>> @pclk:    optional clock for the core parts of the replicator.
> 
> My bad, this will be the following instead.
> 
> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
> index 64de0bee02ec..44b9a77ec8aa 100644
> --- a/drivers/hwtracing/coresight/coresight-replicator.c
> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
> @@ -31,6 +31,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
>   * @base:      memory mapped base address for this component. Also indicates
>   *             whether this one is programmable or not.
>   * @atclk:     optional clock for the core parts of the replicator.
> + * @pclk:      APB clock if present, otherwise NULL
>   * @csdev:     component vitals needed by the framework
>   * @spinlock:  serialize enable/disable operations.
>   * @check_idfilter_val: check if the context is lost upon clock removal.
> 
> I will update replicator, tpiu, tmc, and stm devices.
> 

funnel is missing it as well. If you build with W=1 it shows up.

> struct catu_drvdata and debug_drvdata do not have the comment section itself.
> _______________________________________________
> CoreSight mailing list -- coresight@lists.linaro.org
> To unsubscribe send an email to coresight-leave@lists.linaro.org

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 6/7] coresight: stm: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 ` [PATCH V2 6/7] coresight: stm: " Anshuman Khandual
  2023-12-01 12:36   ` Sudeep Holla
@ 2023-12-04 10:23   ` James Clark
  2023-12-04 11:50     ` Anshuman Khandual
  2023-12-04 11:58     ` Sudeep Holla
  1 sibling, 2 replies; 33+ messages in thread
From: James Clark @ 2023-12-04 10:23 UTC (permalink / raw)
  To: Anshuman Khandual, linux-arm-kernel, suzuki.poulose
  Cc: Lorenzo Pieralisi, Sudeep Holla, Mike Leach, Maxime Coquelin,
	Alexandre Torgue, linux-acpi, linux-kernel, coresight,
	linux-stm32



On 01/12/2023 06:20, Anshuman Khandual wrote:
> Add support for the stm devices in the platform driver, which can then be
> used on ACPI based platforms. This change would now allow runtime power
> management for ACPI based systems. The driver would try to enable the APB
> clock if available.
> 
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Sudeep Holla <sudeep.holla@arm.com>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Mike Leach <mike.leach@linaro.org>
> Cc: James Clark <james.clark@arm.com>
> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Cc: coresight@lists.linaro.org
> Cc: linux-stm32@st-md-mailman.stormreply.com
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
[...]
>  
> -module_amba_driver(stm_driver);
> +static int stm_platform_probe(struct platform_device *pdev)
> +{
> +	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	int ret = 0;
> +
> +	pm_runtime_get_noresume(&pdev->dev);
> +	pm_runtime_set_active(&pdev->dev);
> +	pm_runtime_enable(&pdev->dev);
> +
> +	ret = __stm_probe(&pdev->dev, res, NULL);

Very minor nit, but this used to print this:

  coresight stm0: STM500 initialized

And now it prints this:

  coresight stm0: (null) initialized

(null) kind of makes it look a little bit like something has gone wrong.
Maybe we could just put "initialised" if you don't have a string from ACPI?

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 5/7] coresight: tmc: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 ` [PATCH V2 5/7] coresight: tmc: " Anshuman Khandual
  2023-12-01 12:36   ` Sudeep Holla
@ 2023-12-04 10:42   ` James Clark
  2023-12-04 10:50     ` Suzuki K Poulose
  2023-12-04 10:54   ` James Clark
  2 siblings, 1 reply; 33+ messages in thread
From: James Clark @ 2023-12-04 10:42 UTC (permalink / raw)
  To: Anshuman Khandual, linux-arm-kernel, suzuki.poulose
  Cc: Lorenzo Pieralisi, Sudeep Holla, Mike Leach, Maxime Coquelin,
	Alexandre Torgue, linux-acpi, linux-kernel, coresight,
	linux-stm32



On 01/12/2023 06:20, Anshuman Khandual wrote:
> Add support for the tmc devices in the platform driver, which can then be
> used on ACPI based platforms. This change would now allow runtime power
> management for ACPI based systems. The driver would try to enable the APB
> clock if available.
> 
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Sudeep Holla <sudeep.holla@arm.com>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Mike Leach <mike.leach@linaro.org>
> Cc: James Clark <james.clark@arm.com>
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Cc: coresight@lists.linaro.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  drivers/acpi/arm64/amba.c                     |   2 -
>  .../hwtracing/coresight/coresight-tmc-core.c  | 130 +++++++++++++++---
>  drivers/hwtracing/coresight/coresight-tmc.h   |   1 +
>  3 files changed, 115 insertions(+), 18 deletions(-)
> 
[...]
> -static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
> +static int __tmc_probe(struct device *dev, struct resource *res, void *dev_caps)
>  {
>  	int ret = 0;
>  	u32 devid;
>  	void __iomem *base;
> -	struct device *dev = &adev->dev;
>  	struct coresight_platform_data *pdata = NULL;
> -	struct tmc_drvdata *drvdata;
> -	struct resource *res = &adev->res;
> +	struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
>  	struct coresight_desc desc = { 0 };
>  	struct coresight_dev_list *dev_list = NULL;
>  
>  	ret = -ENOMEM;
> -	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> -	if (!drvdata)
> -		goto out;
> -
> -	dev_set_drvdata(dev, drvdata);
>  
>  	/* Validity for the resource is already checked by the AMBA core */
>  	base = devm_ioremap_resource(dev, res);
> @@ -487,8 +482,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
>  		desc.type = CORESIGHT_DEV_TYPE_SINK;
>  		desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM;
>  		desc.ops = &tmc_etr_cs_ops;
> -		ret = tmc_etr_setup_caps(dev, devid,
> -					 coresight_get_uci_data(id));
> +		ret = tmc_etr_setup_caps(dev, devid, dev_caps);
>  		if (ret)
>  			goto out;
[...]
> -module_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;
> +
> +	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
> +	if (IS_ERR(drvdata->pclk))
> +		return -ENODEV;
> +
> +	dev_set_drvdata(&pdev->dev, drvdata);
> +	pm_runtime_get_noresume(&pdev->dev);
> +	pm_runtime_set_active(&pdev->dev);
> +	pm_runtime_enable(&pdev->dev);
> +
> +	ret = __tmc_probe(&pdev->dev, res, NULL);

What effect does passing NULL here have? It seems like the dev_caps did
something useful when it's set to CORESIGHT_SOC_600_ETR_CAPS. Maybe
Suzuki knows as he added it?

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 5/7] coresight: tmc: Move ACPI support from AMBA driver to platform driver
  2023-12-04 10:42   ` James Clark
@ 2023-12-04 10:50     ` Suzuki K Poulose
  0 siblings, 0 replies; 33+ messages in thread
From: Suzuki K Poulose @ 2023-12-04 10:50 UTC (permalink / raw)
  To: James Clark, Anshuman Khandual, linux-arm-kernel
  Cc: Lorenzo Pieralisi, Sudeep Holla, Mike Leach, Maxime Coquelin,
	Alexandre Torgue, linux-acpi, linux-kernel, coresight,
	linux-stm32

On 04/12/2023 10:42, James Clark wrote:
> 
> 
> On 01/12/2023 06:20, Anshuman Khandual wrote:
>> Add support for the tmc devices in the platform driver, which can then be
>> used on ACPI based platforms. This change would now allow runtime power
>> management for ACPI based systems. The driver would try to enable the APB
>> clock if available.
>>
>> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
>> Cc: Sudeep Holla <sudeep.holla@arm.com>
>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
>> Cc: Mike Leach <mike.leach@linaro.org>
>> Cc: James Clark <james.clark@arm.com>
>> Cc: linux-acpi@vger.kernel.org
>> Cc: linux-arm-kernel@lists.infradead.org
>> Cc: linux-kernel@vger.kernel.org
>> Cc: coresight@lists.linaro.org
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>>   drivers/acpi/arm64/amba.c                     |   2 -
>>   .../hwtracing/coresight/coresight-tmc-core.c  | 130 +++++++++++++++---
>>   drivers/hwtracing/coresight/coresight-tmc.h   |   1 +
>>   3 files changed, 115 insertions(+), 18 deletions(-)
>>
> [...]
>> -static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
>> +static int __tmc_probe(struct device *dev, struct resource *res, void *dev_caps)
>>   {
>>   	int ret = 0;
>>   	u32 devid;
>>   	void __iomem *base;
>> -	struct device *dev = &adev->dev;
>>   	struct coresight_platform_data *pdata = NULL;
>> -	struct tmc_drvdata *drvdata;
>> -	struct resource *res = &adev->res;
>> +	struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
>>   	struct coresight_desc desc = { 0 };
>>   	struct coresight_dev_list *dev_list = NULL;
>>   
>>   	ret = -ENOMEM;
>> -	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
>> -	if (!drvdata)
>> -		goto out;
>> -
>> -	dev_set_drvdata(dev, drvdata);
>>   
>>   	/* Validity for the resource is already checked by the AMBA core */
>>   	base = devm_ioremap_resource(dev, res);
>> @@ -487,8 +482,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
>>   		desc.type = CORESIGHT_DEV_TYPE_SINK;
>>   		desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM;
>>   		desc.ops = &tmc_etr_cs_ops;
>> -		ret = tmc_etr_setup_caps(dev, devid,
>> -					 coresight_get_uci_data(id));
>> +		ret = tmc_etr_setup_caps(dev, devid, dev_caps);
>>   		if (ret)
>>   			goto out;
> [...]
>> -module_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;
>> +
>> +	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
>> +	if (IS_ERR(drvdata->pclk))
>> +		return -ENODEV;
>> +
>> +	dev_set_drvdata(&pdev->dev, drvdata);
>> +	pm_runtime_get_noresume(&pdev->dev);
>> +	pm_runtime_set_active(&pdev->dev);
>> +	pm_runtime_enable(&pdev->dev);
>> +
>> +	ret = __tmc_probe(&pdev->dev, res, NULL);
> 
> What effect does passing NULL here have? It seems like the dev_caps did
> something useful when it's set to CORESIGHT_SOC_600_ETR_CAPS. Maybe
> Suzuki knows as he added it?

That was supposed to initialise the capabilities of the TMC-ETR, which
are not discoverable by ID registers. (e.g., SAVE restore of RRP/RWP).
I guess, we could get rid of that cap and use the "PID" register match
to figure out the capabilities.

Suzuki



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 5/7] coresight: tmc: Move ACPI support from AMBA driver to platform driver
  2023-12-01  6:20 ` [PATCH V2 5/7] coresight: tmc: " Anshuman Khandual
  2023-12-01 12:36   ` Sudeep Holla
  2023-12-04 10:42   ` James Clark
@ 2023-12-04 10:54   ` James Clark
  2023-12-04 11:40     ` Sudeep Holla
  2023-12-05  3:56     ` Anshuman Khandual
  2 siblings, 2 replies; 33+ messages in thread
From: James Clark @ 2023-12-04 10:54 UTC (permalink / raw)
  To: Anshuman Khandual, linux-arm-kernel, suzuki.poulose
  Cc: Lorenzo Pieralisi, Sudeep Holla, Mike Leach, Maxime Coquelin,
	Alexandre Torgue, linux-acpi, linux-kernel, coresight,
	linux-stm32



On 01/12/2023 06:20, Anshuman Khandual wrote:
> Add support for the tmc devices in the platform driver, which can then be
> used on ACPI based platforms. This change would now allow runtime power
> management for ACPI based systems. The driver would try to enable the APB
> clock if available.
> 
[...]
> -module_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;
> +
> +	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
> +	if (IS_ERR(drvdata->pclk))
> +		return -ENODEV;
> +
> +	dev_set_drvdata(&pdev->dev, drvdata);
> +	pm_runtime_get_noresume(&pdev->dev);
> +	pm_runtime_set_active(&pdev->dev);
> +	pm_runtime_enable(&pdev->dev);
> +
> +	ret = __tmc_probe(&pdev->dev, res, NULL);
> +	if (ret) {
> +		pm_runtime_put_noidle(&pdev->dev);
> +		pm_runtime_disable(&pdev->dev);
> +	}

I'm not sure if these pm_runtime()s are right because there is already a
put inside of __tmc_probe() if it fails. If you unload and then reload
all the coresight modules with these patches you get these errors which
are new:

  coresight-tpiu-platform ARMHC979:00: Unbalanced pm_runtime_enable!
  CSCFG registered etm0
  coresight etm0: CPU0: etm v4.2 initialized
  CSCFG registered etm1
  coresight etm1: CPU1: etm v4.2 initialized
  CSCFG registered etm2
  coresight etm2: CPU2: etm v4.2 initialized
  CSCFG registered etm3
  coresight etm3: CPU3: etm v4.2 initialized
  coresight-tmc-platform ARMHC97C:00: Unbalanced pm_runtime_enable!
  coresight-tmc-platform ARMHC97C:01: Unbalanced pm_runtime_enable!
  coresight-tmc-platform ARMHC97C:02: Unbalanced pm_runtime_enable!
  coresight-tmc-platform ARMHC97C:03: Unbalanced pm_runtime_enable!

It might be worth testing all of these pm_runtime()s, including the
error case ones, because loading and unloading the modules doesn't even
include the error scenarios, so there are probably more bad ones in
there too.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to platform driver
  2023-12-04  9:57         ` James Clark
@ 2023-12-04 11:37           ` Anshuman Khandual
  0 siblings, 0 replies; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-04 11:37 UTC (permalink / raw)
  To: James Clark, Sudeep Holla
  Cc: linux-arm-kernel, Lorenzo Pieralisi, Mike Leach, Maxime Coquelin,
	Alexandre Torgue, linux-acpi, linux-kernel, coresight,
	linux-stm32



On 12/4/23 15:27, James Clark wrote:
> 
> On 04/12/2023 04:48, Anshuman Khandual wrote:
>>
>> On 12/4/23 09:56, Anshuman Khandual wrote:
>>>
>>> On 12/1/23 18:05, Sudeep Holla wrote:
>>>> On Fri, Dec 01, 2023 at 11:50:47AM +0530, Anshuman Khandual wrote:
>>>>> Add support for the dynamic replicator device in the platform driver, which
>>>>> can then be used on ACPI based platforms. This change would now allow
>>>>> runtime power management for repliacator devices on ACPI based systems.
>>>>>
>>>>> The driver would try to enable the APB clock if available. Also, rename the
>>>>> code to reflect the fact that it now handles both static and dynamic
>>>>> replicators.
>>>>>
>>>>> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
>>>>> Cc: Sudeep Holla <sudeep.holla@arm.com>
>>>> Except the minor nit below which may apply also for few other patches
>>>> in the series
>>>>
>>>> Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes
>>>> Tested-by: Sudeep Holla <sudeep.holla@arm.com> # Boot and driver probe only
>>>>
>>>> [...]
>>>>
>>>>> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
>>>>> index b6be73034996..64de0bee02ec 100644
>>>>> --- a/drivers/hwtracing/coresight/coresight-replicator.c
>>>>> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
>>>>> @@ -38,6 +38,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
>>>>>  struct replicator_drvdata {
>>>>>  	void __iomem		*base;
>>>>>  	struct clk		*atclk;
>>>>> +	struct clk		*pclk;
>>>> [minor nit] Perhaps can be documented as well ?
>>> Sure, will add the following comment above the structure.
>>>
>>> @pclk:    optional clock for the core parts of the replicator.
>> My bad, this will be the following instead.
>>
>> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
>> index 64de0bee02ec..44b9a77ec8aa 100644
>> --- a/drivers/hwtracing/coresight/coresight-replicator.c
>> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
>> @@ -31,6 +31,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
>>   * @base:      memory mapped base address for this component. Also indicates
>>   *             whether this one is programmable or not.
>>   * @atclk:     optional clock for the core parts of the replicator.
>> + * @pclk:      APB clock if present, otherwise NULL
>>   * @csdev:     component vitals needed by the framework
>>   * @spinlock:  serialize enable/disable operations.
>>   * @check_idfilter_val: check if the context is lost upon clock removal.
>>
>> I will update replicator, tpiu, tmc, and stm devices.
>>
> funnel is missing it as well. If you build with W=1 it shows up.

Updated, done.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 5/7] coresight: tmc: Move ACPI support from AMBA driver to platform driver
  2023-12-04 10:54   ` James Clark
@ 2023-12-04 11:40     ` Sudeep Holla
  2023-12-05  3:56     ` Anshuman Khandual
  1 sibling, 0 replies; 33+ messages in thread
From: Sudeep Holla @ 2023-12-04 11:40 UTC (permalink / raw)
  To: James Clark
  Cc: Anshuman Khandual, linux-arm-kernel, suzuki.poulose, Sudeep Holla,
	Lorenzo Pieralisi, Mike Leach, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32

On Mon, Dec 04, 2023 at 10:54:15AM +0000, James Clark wrote:
>
>
> On 01/12/2023 06:20, Anshuman Khandual wrote:
> > Add support for the tmc devices in the platform driver, which can then be
> > used on ACPI based platforms. This change would now allow runtime power
> > management for ACPI based systems. The driver would try to enable the APB
> > clock if available.
> >
> [...]
> > -module_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;
> > +
> > +	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
> > +	if (IS_ERR(drvdata->pclk))
> > +		return -ENODEV;
> > +
> > +	dev_set_drvdata(&pdev->dev, drvdata);
> > +	pm_runtime_get_noresume(&pdev->dev);
> > +	pm_runtime_set_active(&pdev->dev);
> > +	pm_runtime_enable(&pdev->dev);
> > +
> > +	ret = __tmc_probe(&pdev->dev, res, NULL);
> > +	if (ret) {
> > +		pm_runtime_put_noidle(&pdev->dev);
> > +		pm_runtime_disable(&pdev->dev);
> > +	}
>
> I'm not sure if these pm_runtime()s are right because there is already a
> put inside of __tmc_probe() if it fails. If you unload and then reload
> all the coresight modules with these patches you get these errors which
> are new:
>

Ah good find. I have just tested with ACPI and these modules as built-in
to be more specific.

--
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 6/7] coresight: stm: Move ACPI support from AMBA driver to platform driver
  2023-12-04 10:23   ` James Clark
@ 2023-12-04 11:50     ` Anshuman Khandual
  2023-12-04 13:17       ` James Clark
  2023-12-04 11:58     ` Sudeep Holla
  1 sibling, 1 reply; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-04 11:50 UTC (permalink / raw)
  To: James Clark, linux-arm-kernel, suzuki.poulose
  Cc: Lorenzo Pieralisi, Sudeep Holla, Mike Leach, Maxime Coquelin,
	Alexandre Torgue, linux-acpi, linux-kernel, coresight,
	linux-stm32



On 12/4/23 15:53, James Clark wrote:
> 
> 
> On 01/12/2023 06:20, Anshuman Khandual wrote:
>> Add support for the stm devices in the platform driver, which can then be
>> used on ACPI based platforms. This change would now allow runtime power
>> management for ACPI based systems. The driver would try to enable the APB
>> clock if available.
>>
>> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
>> Cc: Sudeep Holla <sudeep.holla@arm.com>
>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
>> Cc: Mike Leach <mike.leach@linaro.org>
>> Cc: James Clark <james.clark@arm.com>
>> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
>> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
>> Cc: linux-acpi@vger.kernel.org
>> Cc: linux-arm-kernel@lists.infradead.org
>> Cc: linux-kernel@vger.kernel.org
>> Cc: coresight@lists.linaro.org
>> Cc: linux-stm32@st-md-mailman.stormreply.com
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
> [...]
>>  
>> -module_amba_driver(stm_driver);
>> +static int stm_platform_probe(struct platform_device *pdev)
>> +{
>> +	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> +	int ret = 0;
>> +
>> +	pm_runtime_get_noresume(&pdev->dev);
>> +	pm_runtime_set_active(&pdev->dev);
>> +	pm_runtime_enable(&pdev->dev);
>> +
>> +	ret = __stm_probe(&pdev->dev, res, NULL);
> 
> Very minor nit, but this used to print this:
> 
>   coresight stm0: STM500 initialized
> 
> And now it prints this:
> 
>   coresight stm0: (null) initialized
> 
> (null) kind of makes it look a little bit like something has gone wrong.
> Maybe we could just put "initialised" if you don't have a string from ACPI?

__stm_probe() gets called from both AMBA and platform driver paths. Even though
a NULL check inside dev_info(..."%s initialized\n",...) could be added, but how
to differentiate it from a scenario when coresight_get_uci_data() returns NULL ?

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 6/7] coresight: stm: Move ACPI support from AMBA driver to platform driver
  2023-12-04 10:23   ` James Clark
  2023-12-04 11:50     ` Anshuman Khandual
@ 2023-12-04 11:58     ` Sudeep Holla
  1 sibling, 0 replies; 33+ messages in thread
From: Sudeep Holla @ 2023-12-04 11:58 UTC (permalink / raw)
  To: James Clark
  Cc: Anshuman Khandual, Sudeep Holla, linux-arm-kernel, suzuki.poulose,
	Lorenzo Pieralisi, Mike Leach, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32

On Mon, Dec 04, 2023 at 10:23:49AM +0000, James Clark wrote:
> 
> On 01/12/2023 06:20, Anshuman Khandual wrote:
> > Add support for the stm devices in the platform driver, which can then be
> > used on ACPI based platforms. This change would now allow runtime power
> > management for ACPI based systems. The driver would try to enable the APB
> > clock if available.
> > 
> > Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> > Cc: Sudeep Holla <sudeep.holla@arm.com>
> > Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> > Cc: Mike Leach <mike.leach@linaro.org>
> > Cc: James Clark <james.clark@arm.com>
> > Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> > Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
> > Cc: linux-acpi@vger.kernel.org
> > Cc: linux-arm-kernel@lists.infradead.org
> > Cc: linux-kernel@vger.kernel.org
> > Cc: coresight@lists.linaro.org
> > Cc: linux-stm32@st-md-mailman.stormreply.com
> > Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> > ---
> [...]
> >  
> > -module_amba_driver(stm_driver);
> > +static int stm_platform_probe(struct platform_device *pdev)
> > +{
> > +	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	int ret = 0;
> > +
> > +	pm_runtime_get_noresume(&pdev->dev);
> > +	pm_runtime_set_active(&pdev->dev);
> > +	pm_runtime_enable(&pdev->dev);
> > +
> > +	ret = __stm_probe(&pdev->dev, res, NULL);
> 
> Very minor nit, but this used to print this:
> 
>   coresight stm0: STM500 initialized
> 
> And now it prints this:
> 
>   coresight stm0: (null) initialized
> 
> (null) kind of makes it look a little bit like something has gone wrong.
> Maybe we could just put "initialised" if you don't have a string from ACPI?

Ah right, I too noticed this and forgot to mention. Just add a generic
"STM" string for ACPI if we don't have a way to identify exact IP ?

--
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 6/7] coresight: stm: Move ACPI support from AMBA driver to platform driver
  2023-12-04 11:50     ` Anshuman Khandual
@ 2023-12-04 13:17       ` James Clark
  2023-12-05  5:20         ` Anshuman Khandual
  0 siblings, 1 reply; 33+ messages in thread
From: James Clark @ 2023-12-04 13:17 UTC (permalink / raw)
  To: Anshuman Khandual, linux-arm-kernel, suzuki.poulose, Sudeep Holla
  Cc: Lorenzo Pieralisi, Mike Leach, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32



On 04/12/2023 11:50, Anshuman Khandual wrote:
> 
> 
> On 12/4/23 15:53, James Clark wrote:
>>
>>
>> On 01/12/2023 06:20, Anshuman Khandual wrote:
>>> Add support for the stm devices in the platform driver, which can then be
>>> used on ACPI based platforms. This change would now allow runtime power
>>> management for ACPI based systems. The driver would try to enable the APB
>>> clock if available.
>>>
>>> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
>>> Cc: Sudeep Holla <sudeep.holla@arm.com>
>>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
>>> Cc: Mike Leach <mike.leach@linaro.org>
>>> Cc: James Clark <james.clark@arm.com>
>>> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
>>> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
>>> Cc: linux-acpi@vger.kernel.org
>>> Cc: linux-arm-kernel@lists.infradead.org
>>> Cc: linux-kernel@vger.kernel.org
>>> Cc: coresight@lists.linaro.org
>>> Cc: linux-stm32@st-md-mailman.stormreply.com
>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>>> ---
>> [...]
>>>  
>>> -module_amba_driver(stm_driver);
>>> +static int stm_platform_probe(struct platform_device *pdev)
>>> +{
>>> +	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> +	int ret = 0;
>>> +
>>> +	pm_runtime_get_noresume(&pdev->dev);
>>> +	pm_runtime_set_active(&pdev->dev);
>>> +	pm_runtime_enable(&pdev->dev);
>>> +
>>> +	ret = __stm_probe(&pdev->dev, res, NULL);
>>
>> Very minor nit, but this used to print this:
>>
>>   coresight stm0: STM500 initialized
>>
>> And now it prints this:
>>
>>   coresight stm0: (null) initialized
>>
>> (null) kind of makes it look a little bit like something has gone wrong.
>> Maybe we could just put "initialised" if you don't have a string from ACPI?
> 
> __stm_probe() gets called from both AMBA and platform driver paths. Even though
> a NULL check inside dev_info(..."%s initialized\n",...) could be added, but how
> to differentiate it from a scenario when coresight_get_uci_data() returns NULL ?

Sudeep's suggestion seems ok, just add a hard coded string instead of
the NULL. And keep the coresight_get_uci_data() the same.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 5/7] coresight: tmc: Move ACPI support from AMBA driver to platform driver
  2023-12-04 10:54   ` James Clark
  2023-12-04 11:40     ` Sudeep Holla
@ 2023-12-05  3:56     ` Anshuman Khandual
  1 sibling, 0 replies; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-05  3:56 UTC (permalink / raw)
  To: James Clark, linux-arm-kernel, suzuki.poulose
  Cc: Lorenzo Pieralisi, Sudeep Holla, Mike Leach, Maxime Coquelin,
	Alexandre Torgue, linux-acpi, linux-kernel, coresight,
	linux-stm32

On 12/4/23 16:24, James Clark wrote:
> 
> 
> On 01/12/2023 06:20, Anshuman Khandual wrote:
>> Add support for the tmc devices in the platform driver, which can then be
>> used on ACPI based platforms. This change would now allow runtime power
>> management for ACPI based systems. The driver would try to enable the APB
>> clock if available.
>>
> [...]
>> -module_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;
>> +
>> +	drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev);
>> +	if (IS_ERR(drvdata->pclk))
>> +		return -ENODEV;
>> +
>> +	dev_set_drvdata(&pdev->dev, drvdata);
>> +	pm_runtime_get_noresume(&pdev->dev);
>> +	pm_runtime_set_active(&pdev->dev);
>> +	pm_runtime_enable(&pdev->dev);
>> +
>> +	ret = __tmc_probe(&pdev->dev, res, NULL);
>> +	if (ret) {
>> +		pm_runtime_put_noidle(&pdev->dev);
>> +		pm_runtime_disable(&pdev->dev);
>> +	}
> 
> I'm not sure if these pm_runtime()s are right because there is already a
> put inside of __tmc_probe() if it fails. If you unload and then reload

Actually there is a pm_runtime_put() on the success path, not when it
fails. So pm_runtime_put() gets called when __tmc_probe() returns 0.

__tmc_probe()
{
	....
        ret = misc_register(&drvdata->miscdev);
        if (ret)
                coresight_unregister(drvdata->csdev);
        else
                pm_runtime_put(dev);
out:
        return ret;
}

tmc_platform_probe()
{
	....
        pm_runtime_get_noresume(&pdev->dev);
        pm_runtime_set_active(&pdev->dev);
        pm_runtime_enable(&pdev->dev);

        ret = __tmc_probe(&pdev->dev, res, NULL);
        if (ret) {
                pm_runtime_put_noidle(&pdev->dev);
                pm_runtime_disable(&pdev->dev);
        }
        return ret;
}

tmc_probe()
{
	....
	return __tmc_probe(&adev->dev, &adev->res, coresight_get_uci_data(id));
}

Currently pm_runtime_put() gets called

- In success path both for AMBA and platform drivers
- In error path only for platform driver

Although the problem might be with pm_runtime_disable() instead

- pm_runtime_disable() is not required in the platform driver probe() path
- But might be required in tmc_platform_remove() along with a clk_put()

> all the coresight modules with these patches you get these errors which
> are new:
> 
>   coresight-tpiu-platform ARMHC979:00: Unbalanced pm_runtime_enable!

The code is similar in TPIU platform driver as well.

>   CSCFG registered etm0
>   coresight etm0: CPU0: etm v4.2 initialized
>   CSCFG registered etm1
>   coresight etm1: CPU1: etm v4.2 initialized
>   CSCFG registered etm2
>   coresight etm2: CPU2: etm v4.2 initialized
>   CSCFG registered etm3
>   coresight etm3: CPU3: etm v4.2 initialized
>   coresight-tmc-platform ARMHC97C:00: Unbalanced pm_runtime_enable!
>   coresight-tmc-platform ARMHC97C:01: Unbalanced pm_runtime_enable!
>   coresight-tmc-platform ARMHC97C:02: Unbalanced pm_runtime_enable!
>   coresight-tmc-platform ARMHC97C:03: Unbalanced pm_runtime_enable!
> 
> It might be worth testing all of these pm_runtime()s, including the
> error case ones, because loading and unloading the modules doesn't even
> include the error scenarios, so there are probably more bad ones in
> there too.
The code is very similar in CATU, STM as well but debug_platform_remove()
seems to be doing this right.

I am not very familiar with all the power management aspects in coresight,
please do let me know if I missing something here.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 6/7] coresight: stm: Move ACPI support from AMBA driver to platform driver
  2023-12-04 13:17       ` James Clark
@ 2023-12-05  5:20         ` Anshuman Khandual
  2023-12-05  9:35           ` Sudeep Holla
  2023-12-05 10:18           ` Suzuki K Poulose
  0 siblings, 2 replies; 33+ messages in thread
From: Anshuman Khandual @ 2023-12-05  5:20 UTC (permalink / raw)
  To: James Clark, linux-arm-kernel, suzuki.poulose, Sudeep Holla
  Cc: Lorenzo Pieralisi, Mike Leach, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32



On 12/4/23 18:47, James Clark wrote:
> 
> 
> On 04/12/2023 11:50, Anshuman Khandual wrote:
>>
>>
>> On 12/4/23 15:53, James Clark wrote:
>>>
>>>
>>> On 01/12/2023 06:20, Anshuman Khandual wrote:
>>>> Add support for the stm devices in the platform driver, which can then be
>>>> used on ACPI based platforms. This change would now allow runtime power
>>>> management for ACPI based systems. The driver would try to enable the APB
>>>> clock if available.
>>>>
>>>> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
>>>> Cc: Sudeep Holla <sudeep.holla@arm.com>
>>>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
>>>> Cc: Mike Leach <mike.leach@linaro.org>
>>>> Cc: James Clark <james.clark@arm.com>
>>>> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
>>>> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
>>>> Cc: linux-acpi@vger.kernel.org
>>>> Cc: linux-arm-kernel@lists.infradead.org
>>>> Cc: linux-kernel@vger.kernel.org
>>>> Cc: coresight@lists.linaro.org
>>>> Cc: linux-stm32@st-md-mailman.stormreply.com
>>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>>>> ---
>>> [...]
>>>>  
>>>> -module_amba_driver(stm_driver);
>>>> +static int stm_platform_probe(struct platform_device *pdev)
>>>> +{
>>>> +	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>> +	int ret = 0;
>>>> +
>>>> +	pm_runtime_get_noresume(&pdev->dev);
>>>> +	pm_runtime_set_active(&pdev->dev);
>>>> +	pm_runtime_enable(&pdev->dev);
>>>> +
>>>> +	ret = __stm_probe(&pdev->dev, res, NULL);
>>>
>>> Very minor nit, but this used to print this:
>>>
>>>   coresight stm0: STM500 initialized
>>>
>>> And now it prints this:
>>>
>>>   coresight stm0: (null) initialized
>>>
>>> (null) kind of makes it look a little bit like something has gone wrong.
>>> Maybe we could just put "initialised" if you don't have a string from ACPI?
>>
>> __stm_probe() gets called from both AMBA and platform driver paths. Even though
>> a NULL check inside dev_info(..."%s initialized\n",...) could be added, but how
>> to differentiate it from a scenario when coresight_get_uci_data() returns NULL ?
> 
> Sudeep's suggestion seems ok, just add a hard coded string instead of
> the NULL. And keep the coresight_get_uci_data() the same.

Something like this works ?

diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index 3387ebc9d8ab..2b6834c4cac6 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -906,7 +906,7 @@ static int __stm_probe(struct device *dev, struct resource *res, void *dev_caps)
        pm_runtime_put(dev);
 
        dev_info(&drvdata->csdev->dev, "%s initialized\n",
-                (char *)dev_caps);
+                dev_caps ? (char *)dev_caps: "STM");
        return 0;
 
 cs_unregister:


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 6/7] coresight: stm: Move ACPI support from AMBA driver to platform driver
  2023-12-05  5:20         ` Anshuman Khandual
@ 2023-12-05  9:35           ` Sudeep Holla
  2023-12-05 10:18           ` Suzuki K Poulose
  1 sibling, 0 replies; 33+ messages in thread
From: Sudeep Holla @ 2023-12-05  9:35 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: James Clark, linux-arm-kernel, Sudeep Holla, suzuki.poulose,
	Lorenzo Pieralisi, Mike Leach, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32

On Tue, Dec 05, 2023 at 10:50:19AM +0530, Anshuman Khandual wrote:
> Something like this works ?
> 
> diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
> index 3387ebc9d8ab..2b6834c4cac6 100644
> --- a/drivers/hwtracing/coresight/coresight-stm.c
> +++ b/drivers/hwtracing/coresight/coresight-stm.c
> @@ -906,7 +906,7 @@ static int __stm_probe(struct device *dev, struct resource *res, void *dev_caps)
>         pm_runtime_put(dev);
>  
>         dev_info(&drvdata->csdev->dev, "%s initialized\n",
> -                (char *)dev_caps);
> +                dev_caps ? (char *)dev_caps: "STM");
>         return 0;
>  
>  cs_unregister:

Yes, looks good to me.

-- 
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V2 6/7] coresight: stm: Move ACPI support from AMBA driver to platform driver
  2023-12-05  5:20         ` Anshuman Khandual
  2023-12-05  9:35           ` Sudeep Holla
@ 2023-12-05 10:18           ` Suzuki K Poulose
  1 sibling, 0 replies; 33+ messages in thread
From: Suzuki K Poulose @ 2023-12-05 10:18 UTC (permalink / raw)
  To: Anshuman Khandual, James Clark, linux-arm-kernel, Sudeep Holla
  Cc: Lorenzo Pieralisi, Mike Leach, Maxime Coquelin, Alexandre Torgue,
	linux-acpi, linux-kernel, coresight, linux-stm32

On 05/12/2023 05:20, Anshuman Khandual wrote:
> 
> 
> On 12/4/23 18:47, James Clark wrote:
>>
>>
>> On 04/12/2023 11:50, Anshuman Khandual wrote:
>>>
>>>
>>> On 12/4/23 15:53, James Clark wrote:
>>>>
>>>>
>>>> On 01/12/2023 06:20, Anshuman Khandual wrote:
>>>>> Add support for the stm devices in the platform driver, which can then be
>>>>> used on ACPI based platforms. This change would now allow runtime power
>>>>> management for ACPI based systems. The driver would try to enable the APB
>>>>> clock if available.
>>>>>
>>>>> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
>>>>> Cc: Sudeep Holla <sudeep.holla@arm.com>
>>>>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
>>>>> Cc: Mike Leach <mike.leach@linaro.org>
>>>>> Cc: James Clark <james.clark@arm.com>
>>>>> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
>>>>> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
>>>>> Cc: linux-acpi@vger.kernel.org
>>>>> Cc: linux-arm-kernel@lists.infradead.org
>>>>> Cc: linux-kernel@vger.kernel.org
>>>>> Cc: coresight@lists.linaro.org
>>>>> Cc: linux-stm32@st-md-mailman.stormreply.com
>>>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>>>>> ---
>>>> [...]
>>>>>   
>>>>> -module_amba_driver(stm_driver);
>>>>> +static int stm_platform_probe(struct platform_device *pdev)
>>>>> +{
>>>>> +	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>>> +	int ret = 0;
>>>>> +
>>>>> +	pm_runtime_get_noresume(&pdev->dev);
>>>>> +	pm_runtime_set_active(&pdev->dev);
>>>>> +	pm_runtime_enable(&pdev->dev);
>>>>> +
>>>>> +	ret = __stm_probe(&pdev->dev, res, NULL);
>>>>
>>>> Very minor nit, but this used to print this:
>>>>
>>>>    coresight stm0: STM500 initialized
>>>>
>>>> And now it prints this:
>>>>
>>>>    coresight stm0: (null) initialized
>>>>
>>>> (null) kind of makes it look a little bit like something has gone wrong.
>>>> Maybe we could just put "initialised" if you don't have a string from ACPI?
>>>
>>> __stm_probe() gets called from both AMBA and platform driver paths. Even though
>>> a NULL check inside dev_info(..."%s initialized\n",...) could be added, but how
>>> to differentiate it from a scenario when coresight_get_uci_data() returns NULL ?
>>
>> Sudeep's suggestion seems ok, just add a hard coded string instead of
>> the NULL. And keep the coresight_get_uci_data() the same.
> 
> Something like this works ?
> 
> diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
> index 3387ebc9d8ab..2b6834c4cac6 100644
> --- a/drivers/hwtracing/coresight/coresight-stm.c
> +++ b/drivers/hwtracing/coresight/coresight-stm.c
> @@ -906,7 +906,7 @@ static int __stm_probe(struct device *dev, struct resource *res, void *dev_caps)
>          pm_runtime_put(dev);
>   
>          dev_info(&drvdata->csdev->dev, "%s initialized\n",
> -                (char *)dev_caps);
> +                dev_caps ? (char *)dev_caps: "STM");
>          return 0;
>   

Please could stop abusing the private data for storing the name ? 
Instead, we could read the PID of the device and use a table to map
it to the name and use that instead ?

Suzuki


>   cs_unregister:
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-12-05 10:19 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-01  6:20 [PATCH V2 0/7] coresight: Move remaining AMBA ACPI devices into platform driver Anshuman Khandual
2023-12-01  6:20 ` [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to " Anshuman Khandual
2023-12-01 12:35   ` Sudeep Holla
2023-12-04  4:26     ` Anshuman Khandual
2023-12-04  4:48       ` Anshuman Khandual
2023-12-04  9:57         ` James Clark
2023-12-04 11:37           ` Anshuman Khandual
2023-12-01  6:20 ` [PATCH V2 2/7] coresight: funnel: " Anshuman Khandual
2023-12-01 12:35   ` Sudeep Holla
2023-12-01  6:20 ` [PATCH V2 3/7] coresight: catu: " Anshuman Khandual
2023-12-01 12:35   ` Sudeep Holla
2023-12-01 13:41   ` Suzuki K Poulose
2023-12-04  6:48     ` Anshuman Khandual
2023-12-01  6:20 ` [PATCH V2 4/7] coresight: tpiu: " Anshuman Khandual
2023-12-01 12:36   ` Sudeep Holla
2023-12-01  6:20 ` [PATCH V2 5/7] coresight: tmc: " Anshuman Khandual
2023-12-01 12:36   ` Sudeep Holla
2023-12-04 10:42   ` James Clark
2023-12-04 10:50     ` Suzuki K Poulose
2023-12-04 10:54   ` James Clark
2023-12-04 11:40     ` Sudeep Holla
2023-12-05  3:56     ` Anshuman Khandual
2023-12-01  6:20 ` [PATCH V2 6/7] coresight: stm: " Anshuman Khandual
2023-12-01 12:36   ` Sudeep Holla
2023-12-04 10:23   ` James Clark
2023-12-04 11:50     ` Anshuman Khandual
2023-12-04 13:17       ` James Clark
2023-12-05  5:20         ` Anshuman Khandual
2023-12-05  9:35           ` Sudeep Holla
2023-12-05 10:18           ` Suzuki K Poulose
2023-12-04 11:58     ` Sudeep Holla
2023-12-01  6:20 ` [PATCH V2 7/7] coresight: debug: " Anshuman Khandual
2023-12-01 12:37   ` Sudeep Holla

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 read-only IMAP folder(s) and NNTP newsgroup(s).