coresight: Move remaining AMBA ACPI devices into platform driver
Subsystems (5)
v5 cover coresight: Move remaining AMBA ACPI devices into platform driver
This moves remaining AMBA ACPI devices into respective platform drivers for enabling ACPI based power management support. This series applies on kernel v6.8-rc5 release. This series has been built, and boot tested on a DT based (RB5) and ACPI supported coresight platform (N1SDP).
https://git.gitlab.arm.com/linux-arm/linux-anshuman.git (amba_other_acpi_migration_v5)
Changes in V5:
- Used table->mask to filter out bits from pid in coresight_get_uci_data_from_amba()
- Dropped custom masks such as STM_AMBA_MASK and TMC_AMBA_MASK
- Modified tmc_etr_setup_caps() to accept struct csdev_access argument
- Reverted back tmc_etr_setup_caps() call site position in tmc_probe()
- Changed replicator and funnel devices to use the new helpers earlier in series
- Updated the commit messages regarding xxx_probe() refactoring and renaming
Changes in V4:
https://lore.kernel.org/all/[email protected]/
- Fixed PM imbalance in etm4_probe() error path with pm_runtime_disable()
- Restored back the pm_runtime_disable() on platform probe error paths in replicator, funnel, catu, tpiu, tmc and stm devices
- Dropped dev_caps argument from __tmc_probe()
- Changed xxxx_platform_remove() for platform_driver->remove_new() callback
Changes in V3:
https://lore.kernel.org/all/[email protected]/
- Split coresight_init_driver/remove_driver() helpers into a separate patch
- Added 'drvdata->pclk' comments in replicator, funnel, tpiu, tmc, and stm devices
- Updated funnel, and replicator drivers to use these new helpers
- Check for drvdata instead of drvdata->pclk in suspend and resume paths in catu, tmc and debug devices
- Added patch to extract device name from AMBA pid based table lookup for stm
- Added patch to extract device properties from AMBA pid based table look for tmc
- Dropped pm_runtime_put() from common __probe() functions
- Handled pm_runtime_put() in AMBA driver in success path
- Handled pm_runtime_put() in platform driver in both success and error paths
Changes in V2:
https://lore.kernel.org/all/[email protected]/
- 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/[email protected]/
- Replaced all IS_ERR() instances with IS_ERR_OR_NULL() as per Suzuki
Changes in RFC:
https://lore.kernel.org/all/[email protected]/
Anshuman Khandual (11):
coresight: etm4x: Fix unbalanced pm_runtime_enable()
coresight: stm: Extract device name from AMBA pid based table lookup
coresight: tmc: Extract device properties from AMBA pid based table lookup
coresight: Add helpers registering/removing both AMBA and platform drivers
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 | 142 +++++++++++++--- drivers/hwtracing/coresight/coresight-catu.h | 1 + drivers/hwtracing/coresight/coresight-core.c | 29 ++++ .../hwtracing/coresight/coresight-cpu-debug.c | 141 ++++++++++++++-- .../coresight/coresight-etm4x-core.c | 3 + .../hwtracing/coresight/coresight-funnel.c | 86 +++++----- drivers/hwtracing/coresight/coresight-priv.h | 10 ++ .../coresight/coresight-replicator.c | 81 +++++----- drivers/hwtracing/coresight/coresight-stm.c | 115 +++++++++++-- .../hwtracing/coresight/coresight-tmc-core.c | 153 +++++++++++++++--- drivers/hwtracing/coresight/coresight-tmc.h | 2 + drivers/hwtracing/coresight/coresight-tpiu.c | 102 ++++++++++-- include/linux/coresight.h | 7 + 14 files changed, 721 insertions(+), 159 deletions(-)
Signature · 1 line
2.25.1
PATCH v5 1/11 coresight: etm4x: Fix unbalanced pm_runtime_enable()
There is an unbalanced pm_runtime_enable() in etm4_probe_platform_dev() when etm4_probe() fails. This problem can be observed via the coresight etm4 module's (load -> unload -> load) sequence when etm4_probe() fails in etm4_probe_platform_dev().
[ 63.379943] coresight-etm4x 7040000.etm: Unbalanced pm_runtime_enable! [ 63.393630] coresight-etm4x 7140000.etm: Unbalanced pm_runtime_enable! [ 63.407455] coresight-etm4x 7240000.etm: Unbalanced pm_runtime_enable! [ 63.420983] coresight-etm4x 7340000.etm: Unbalanced pm_runtime_enable! [ 63.420999] coresight-etm4x 7440000.etm: Unbalanced pm_runtime_enable! [ 63.441209] coresight-etm4x 7540000.etm: Unbalanced pm_runtime_enable! [ 63.454689] coresight-etm4x 7640000.etm: Unbalanced pm_runtime_enable! [ 63.474982] coresight-etm4x 7740000.etm: Unbalanced pm_runtime_enable!
This fixes the above problem - with an explicit pm_runtime_disable() call when etm4_probe() fails during etm4_probe_platform_dev().
---
Changes in V5:
- Added "Fixes:" tag
drivers/hwtracing/coresight/coresight-etm4x-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwtracing/coresight/coresight-etm4x-core.c +3 -0
@@ -2217,6 +2217,9 @@ static int etm4_probe_platform_dev(struct platform_device *pdev) ret =etm4_probe (&pdev->dev);pm_runtime_put (&pdev->dev); +if (ret) +pm_runtime_disable (&pdev->dev); +return ret; }
Signature · 1 line
2.25.1
PATCH v5 2/11 coresight: stm: Extract device name from AMBA pid based table lookup
In reply to Anshuman KhandualInstead of using AMBA private data field, extract the device name from AMBA pid based table lookup using new coresight_get_uci_data_from_amba() helper.
---
Changes in V5:
- Used table->mask to filter out bits from pid in coresight_get_uci_data_from_amba()
- Dropped custom mask STM_AMBA_MASK
drivers/hwtracing/coresight/coresight-priv.h | 10 ++++++++++ drivers/hwtracing/coresight/coresight-stm.c | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-priv.h +10 -0
@@ -221,6 +221,16 @@ static inline void *coresight_get_uci_data(const struct amba_id *id)return uci_id->data; } +static inline void *coresight_get_uci_data_from_amba (const struct amba_id *table,u32 pid) +{ +while (table->mask) { +if ((pid & table->mask) == table->id) +return coresight_get_uci_data (table); + table++; + }; +return NULL ; +} +void coresight_release_platform_data (struct coresight_device *csdev,struct device *dev,struct coresight_platform_data *pdata);
drivers/hwtracing/coresight/coresight-stm.c +11 -1
@@ -804,6 +804,16 @@ static void stm_init_generic_data(struct stm_drvdata *drvdata, drvdata->stm.set_options = stm_generic_set_options; } +static const struct amba_id stm_ids[]; + +static char *stm_csdev_name (struct coresight_device *csdev) +{ +u32 stm_pid =coresight_get_pid (&csdev->access); +void *uci_data =coresight_get_uci_data_from_amba (stm_ids, stm_pid); + +return uci_data ? (char *)uci_data :"STM" ; +} +static int stm_probe (struct amba_device *adev,const struct amba_id *id) {int ret, trace_id;
@@ -900,7 +910,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)pm_runtime_put (&adev->dev);dev_info (&drvdata->csdev->dev,"%s initialized\n" , - (char *)coresight_get_uci_data (id)); +stm_csdev_name (drvdata->csdev));return 0 ; cs_unregister:
Signature · 1 line
2.25.1
PATCH v5 3/11 coresight: tmc: Extract device properties from AMBA pid based table lookup
In reply to Anshuman KhandualThis extracts device properties from AMBA pid based table lookup. But first this modifies tmc_etr_setup_caps() to accept csdev access.
---
Changes in V5:
- Modified tmc_etr_setup_caps() to accept struct csdev_access argument
- Reverted back tmc_etr_setup_caps() call site position in tmc_probe()
- Dropped custom mask TMC_AMBA_MASK
drivers/hwtracing/coresight/coresight-tmc-core.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/hwtracing/coresight/coresight-tmc-core.c +10 -4
@@ -370,16 +370,23 @@ static inline bool tmc_etr_has_non_secure_access(struct tmc_drvdata *drvdata)return (auth &TMC_AUTH_NSID_MASK ) ==0x3 ; } +static const struct amba_id tmc_ids[]; +/* Detect and initialise the capabilities of a TMC ETR */ -static int tmc_etr_setup_caps (struct device *parent,u32 devid,void *dev_caps) +static int tmc_etr_setup_caps (struct device *parent,u32 devid, +struct csdev_access *access) {int rc; -u32 dma_mask =0 ; +u32 tmc_pid, dma_mask =0 ;struct tmc_drvdata *drvdata =dev_get_drvdata (parent); +void *dev_caps;if (!tmc_etr_has_non_secure_access (drvdata))return -EACCES ; + tmc_pid =coresight_get_pid (access); + dev_caps =coresight_get_uci_data_from_amba (tmc_ids, tmc_pid); +/* Set the unadvertised capabilities */ tmc_etr_init_caps (drvdata, (u32 )(unsigned long )dev_caps);
@@ -497,8 +504,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, &desc.access);if (ret) goto out;idr_init (&drvdata->idr);
Signature · 1 line
2.25.1
Suzuki K Poulose
maintainerRe: [PATCH V5 03/11] coresight: tmc: Extract device properties from AMBA pid based table lookup
Quoted 10 lines · Anshuman Khandual
This extracts device properties from AMBA pid based table lookup. But first this modifies
tmc_etr_setup_caps()to accept csdev access.Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Cc James Clark <[email protected]>Reviewed-by James Clark <[email protected]>
minor nit: Since there were significant changes from what James previously reviewed, it is a good idea to drop his Reviewed-by:
Otherwise, the changes look good to me.
Suzuki
Quoted 51 lines
Signed-off-by Anshuman Khandual <[email protected]>---
Changes in V5:- Modified
tmc_etr_setup_caps()to accept structcsdev_accessargument
- Reverted backtmc_etr_setup_caps()call site position intmc_probe()
- Dropped custom maskTMC_AMBA_MASKdrivers/hwtracing/coresight/coresight-tmc-core.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/hwtracing/coresight/coresight-tmc-core.c +10
-4@@ -370,16 +370,23 @@ static inline bool tmc_etr_has_non_secure_access(struct tmc_drvdata *drvdata)return (auth &TMC_AUTH_NSID_MASK ) ==0x3 ; } +static const struct amba_id tmc_ids[]; +/* Detect and initialise the capabilities of a TMC ETR */ -static int tmc_etr_setup_caps (struct device *parent,u32 devid,void *dev_caps) +static int tmc_etr_setup_caps (struct device *parent,u32 devid, +struct csdev_access *access) {int rc; -u32 dma_mask =0 ; +u32 tmc_pid, dma_mask =0 ;struct tmc_drvdata *drvdata =dev_get_drvdata (parent); +void *dev_caps;if (!tmc_etr_has_non_secure_access (drvdata))return -EACCES ; + tmc_pid =coresight_get_pid (access); + dev_caps =coresight_get_uci_data_from_amba (tmc_ids, tmc_pid); +/* Set the unadvertised capabilities */ tmc_etr_init_caps (drvdata, (u32 )(unsigned long )dev_caps);@@ -497,8 +504,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, &desc.access);if (ret) goto out;idr_init (&drvdata->idr);
Re: [PATCH V5 03/11] coresight: tmc: Extract device properties from AMBA pid based table lookup
Quoted 12 lines · Suzuki K Poulose
Quoted 10 lines · Anshuman Khandual
This extracts device properties from AMBA pid based table lookup. But first this modifies
tmc_etr_setup_caps()to accept csdev access.Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Cc James Clark <[email protected]>Reviewed-by James Clark <[email protected]>
Quoted 1 line
minor nit: Since there were significant changes from what James previously reviewed, it is a good idea to drop his Reviewed-by:
Sure, will do.
Quoted 53 lines
Otherwise, the changes look good to me.
Suzuki
Quoted 47 lines
Signed-off-by Anshuman Khandual <[email protected]>---
Changes in V5:- Modified
tmc_etr_setup_caps()to accept structcsdev_accessargument
- Reverted backtmc_etr_setup_caps()call site position intmc_probe()
- Dropped custom maskTMC_AMBA_MASK
drivers/hwtracing/coresight/coresight-tmc-core.c| 14 ++++++++++----1 file changed, 10 insertions(+), 4 deletions(-)drivers/hwtracing/coresight/coresight-tmc-core.c +7
-2@@ -370,16 +370,23 @@ static inline bool tmc_etr_has_non_secure_access(struct tmc_drvdata *drvdata) return (auth & TMC_AUTH_NSID_MASK) == 0x3; } +static const struct amba_id tmc_ids[]; + /* Detect and initialise the capabilities of a TMC ETR */ -static int tmc_etr_setup_caps (struct device *parent,u32 devid,void *dev_caps) +static int tmc_etr_setup_caps (struct device *parent,u32 devid, + struct csdev_access *access) { int rc; - u32 dma_mask = 0; + u32 tmc_pid, dma_mask = 0; struct tmc_drvdata *drvdata = dev_get_drvdata(parent); + void *dev_caps; if (!tmc_etr_has_non_secure_access(drvdata)) return -EACCES; + tmc_pid = coresight_get_pid(access); + dev_caps = coresight_get_uci_data_from_amba(tmc_ids, tmc_pid); + /* Set the unadvertised capabilities */ tmc_etr_init_caps(drvdata, (u32)(unsigned long)dev_caps); @@ -497,8 +504,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, &desc.access); if (ret)
goto out;
idr_init(&drvdata->idr);
PATCH v5 4/11 coresight: Add helpers registering/removing both AMBA and platform drivers
In reply to Anshuman KhandualThis adds two different helpers i.e coresight_init_driver()/remove_driver() enabling coresight devices to register or remove AMBA and platform drivers. This changes replicator and funnel devices to use above new helpers.
---
Changes in V5:
- Changed replicator and funnel devices to use the new helpers
drivers/hwtracing/coresight/coresight-core.c | 29 +++++++++++++++++++ .../hwtracing/coresight/coresight-funnel.c | 19 ++---------- .../coresight/coresight-replicator.c | 20 ++----------- include/linux/coresight.h | 7 +++++ 4 files changed, 41 insertions(+), 34 deletions(-)
drivers/hwtracing/coresight/coresight-core.c +29 -0
@@ -1836,6 +1836,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 <[email protected]>" );MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" );
drivers/hwtracing/coresight/coresight-funnel.c +2 -17
@@ -410,27 +410,12 @@ static struct amba_driver dynamic_funnel_driver = {static int __init funnel_init (void ) { -int ret; - - ret =platform_driver_register (&static_funnel_driver); -if (ret) { -pr_info ("Error registering platform driver\n" ); -return ret; - } - - ret =amba_driver_register (&dynamic_funnel_driver); -if (ret) { -pr_info ("Error registering amba driver\n" ); -platform_driver_unregister (&static_funnel_driver); - } - -return ret; +return coresight_init_driver ("funnel" , &dynamic_funnel_driver, &static_funnel_driver); } static void __exit funnel_exit(void) { -platform_driver_unregister (&static_funnel_driver); -amba_driver_unregister (&dynamic_funnel_driver); +coresight_remove_driver (&dynamic_funnel_driver, &static_funnel_driver); }module_init (funnel_init);
drivers/hwtracing/coresight/coresight-replicator.c +3 -17
@@ -416,27 +416,13 @@ static struct amba_driver dynamic_replicator_driver = {static int __init replicator_init (void ) { -int ret; - - ret =platform_driver_register (&static_replicator_driver); -if (ret) { -pr_info ("Error registering platform driver\n" ); -return ret; - } - - ret =amba_driver_register (&dynamic_replicator_driver); -if (ret) { -pr_info ("Error registering amba driver\n" ); -platform_driver_unregister (&static_replicator_driver); - } - -return ret; +return coresight_init_driver ("replicator" , &dynamic_replicator_driver, + &static_replicator_driver); } static void __exit replicator_exit(void) { -platform_driver_unregister (&static_replicator_driver); -amba_driver_unregister (&dynamic_replicator_driver); +coresight_remove_driver (&dynamic_replicator_driver, &static_replicator_driver); }module_init (replicator_init);
include/linux/coresight.h +7 -0
@@ -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
@@ -598,6 +600,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 ; }
Signature · 1 line
2.25.1
PATCH v5 5/11 coresight: replicator: Move ACPI support from AMBA driver to platform driver
In reply to Anshuman KhandualAdd 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 replicator 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. But first this refactors replicator_probe() making sure it can be used both for platform and AMBA drivers, by moving the pm_runtime_put() to the callers.
---
Changes in V5:
- Updated the commit message regarding replicator_probe() refactoring
- coresight_[init|remove]_driver() replacement has been folded earlier
drivers/acpi/arm64/amba.c | 1 - .../coresight/coresight-replicator.c | 67 ++++++++++++------- 2 files changed, 43 insertions(+), 25 deletions(-)
drivers/acpi/arm64/amba.c +0 -1
@@ -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},
drivers/hwtracing/coresight/coresight-replicator.c +43 -24
160 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 6/11 coresight: funnel: Move ACPI support from AMBA driver to platform driver
In reply to Anshuman KhandualAdd 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. But first this refactors funnel_probe() making sure it can be used both for platform and AMBA drivers, by moving the pm_runtime_put() to the callers.
---
Changes in V5:
- Updated the commit message regarding funnel_probe() refactoring
- coresight_[init|remove]_driver() replacement has been folded earlier
drivers/acpi/arm64/amba.c | 1 - .../hwtracing/coresight/coresight-funnel.c | 71 ++++++++++++------- 2 files changed, 46 insertions(+), 26 deletions(-)
drivers/acpi/arm64/amba.c +0 -1
@@ -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}, };
drivers/hwtracing/coresight/coresight-funnel.c +46 -25
157 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 7/11 coresight: catu: Move ACPI support from AMBA driver to platform driver
In reply to Anshuman KhandualAdd 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. But first this renames and then refactors catu_probe() and catu_remove(), making sure it can be used both for platform and AMBA drivers. This also moves pm_runtime_put() from catu_probe() to the callers.
---
Changes in V5:
- Updated commit message regarding catu_probe/remove() refactoring and renaming
drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-catu.c | 142 ++++++++++++++++--- drivers/hwtracing/coresight/coresight-catu.h | 1 + 3 files changed, 124 insertions(+), 20 deletions(-)
drivers/acpi/arm64/amba.c +0 -1
@@ -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}, };
drivers/hwtracing/coresight/coresight-catu.c +123 -19
196 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-catu.h +1 -0
@@ -61,6 +61,7 @@#define CATU_IRQEN_OFF 0x0struct catu_drvdata { +struct clk *pclk;void __iomem *base;struct coresight_device *csdev;int irq;
Signature · 1 line
2.25.1
Suzuki K Poulose
maintainerRe: [PATCH V5 07/11] coresight: catu: Move ACPI support from AMBA driver to platform driver
Quoted 137 lines · Anshuman Khandual
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. But first this renames and then refactors
catu_probe()andcatu_remove(), making sure it can be used both for platform and AMBA drivers. This also movespm_runtime_put()fromcatu_probe()to the callers.Cc Lorenzo Pieralisi <[email protected]>Cc Sudeep Holla <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Cc James Clark <[email protected]>Reviewed-by James Clark <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
Changes in V5:- Updated commit message regarding catu_probe/remove() refactoring and renaming
drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-catu.c | 142 ++++++++++++++++--- drivers/hwtracing/coresight/coresight-catu.h | 1 + 3 files changed, 124 insertions(+), 20 deletions(-)drivers/acpi/arm64/amba.c +0
-1@@ -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}, };drivers/hwtracing/coresight/coresight-catu.c +32
-15@@ -7,6 +7,8 @@* Author: Suzuki K Poulose <[email protected]> */ +#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;@@ -567,19 +561,39 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) drvdata->csdev =coresight_register (&catu_desc);if (IS_ERR (drvdata->csdev)) ret =PTR_ERR (drvdata->csdev); -else -pm_runtime_put (&adev->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 =dev_get_drvdata (&adev->dev); +struct catu_drvdata *drvdata; +int ret; + + drvdata =devm_kzalloc (&adev->dev,sizeof (*drvdata),GFP_KERNEL ); +if (!drvdata) +return -ENOMEM ; + +amba_set_drvdata (adev, drvdata); + ret =__catu_probe (&adev->dev, &adev->res); +if (!ret) +pm_runtime_put (&adev->dev); + +return ret; +} + +static void __catu_remove (struct device *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 +612,103 @@ 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 );
drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 627
Quoted 10 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-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 ;
---8>---
drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 635
Quoted 8 lines
drivers/hwtracing/coresight/coresight-catu.c +8
-0+ +if (res) { + drvdata->base =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (drvdata->base)) { +clk_put (drvdata->pclk); +return PTR_ERR (drvdata->base); + } + }
---<8---
The above section seems unncessary as we already try to map the base in __catu_probe ?
Quoted 10 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-0+ +pm_runtime_get_noresume (&pdev->dev); +pm_runtime_set_active (&pdev->dev); +pm_runtime_enable (&pdev->dev); + +dev_set_drvdata (&pdev->dev, drvdata); + ret =__catu_probe (&pdev->dev, res); +pm_runtime_put (&pdev->dev); +if (ret) +pm_runtime_disable (&pdev->dev);
drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 655
Quoted 10 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-0+ +return ret; +} + +static int catu_platform_remove (struct platform_device *pdev) +{ +struct catu_drvdata *drvdata =dev_get_drvdata (&pdev->dev); + +if (drvdata) +__catu_remove (&pdev->dev);
I don't understand the need for if () check here (and on all the other drivers). Even if we have a drvdata != NULL, what guarantees that the drvdata->csdev is valid (which is used in xx_remove) ?
Suzuki
Quoted 83 lines
drivers/hwtracing/coresight/coresight-catu.c +53
-4+ +pm_runtime_disable (&pdev->dev); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_put (drvdata->pclk); +return 0 ; +} + +#ifdef CONFIG_PM +static int catu_runtime_suspend (struct device *dev) +{ +struct catu_drvdata *drvdata =dev_get_drvdata (dev); + +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_disable_unprepare (drvdata->pclk); +return 0 ; +} + +static int catu_runtime_resume (struct device *dev) +{ +struct catu_drvdata *drvdata =dev_get_drvdata (dev); + +if (drvdata && !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 +716,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);drivers/hwtracing/coresight/coresight-catu.h +1
-0@@ -61,6 +61,7 @@#define CATU_IRQEN_OFF 0x0struct catu_drvdata { +struct clk *pclk;void __iomem *base;struct coresight_device *csdev;int irq;
Re: [PATCH V5 07/11] coresight: catu: Move ACPI support from AMBA driver to platform driver
Quoted 152 lines · Suzuki K Poulose
Quoted 128 lines · Anshuman Khandual
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. But first this renames and then refactors
catu_probe()andcatu_remove(), making sure it can be used both for platform and AMBA drivers. This also movespm_runtime_put()fromcatu_probe()to the callers.Cc Lorenzo Pieralisi <[email protected]>Cc Sudeep Holla <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Cc James Clark <[email protected]>Reviewed-by James Clark <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
Changes in V5:- Updated commit message regarding catu_probe/remove() refactoring and renaming
drivers/acpi/arm64/amba.c | 1 -
drivers/hwtracing/coresight/coresight-catu.c| 142 ++++++++++++++++---drivers/hwtracing/coresight/coresight-catu.h| 1 +3 files changed, 124 insertions(+), 20 deletions(-)drivers/acpi/arm64/amba.c +0
-0@@ -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 --gita/drivers/hwtracing/coresight/coresight-catu.cb/drivers/hwtracing/coresight/coresight-catu.cindex3949ded0d4fa..a3ea46b53898100644drivers/hwtracing/coresight/coresight-catu.c +0
-0@@ -7,6 +7,8 @@* Author: Suzuki K Poulose <[email protected]> */ +#include <
linux/platform_device.h>
+#include <linux/acpi.h>
#include <linux/amba/bus.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>drivers/hwtracing/coresight/coresight-catu.c +3
-11@@ -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;@@ -567,19 +561,39 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) drvdata->csdev = coresight_register(&catu_desc); if (IS_ERR(drvdata->csdev)) ret = PTR_ERR(drvdata->csdev); - else - pm_runtime_put(&adev->dev);out:
return ret;
}
-static voidcatu_remove(struct amba_device *adev)
+static intcatu_probe(struct amba_device *adev, const struct amba_id *id){
- structcatu_drvdata*drvdata =dev_get_drvdata(&adev->dev); + structcatu_drvdata*drvdata;
+ int ret;drivers/hwtracing/coresight/coresight-catu.c +16
-0+ + drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + amba_set_drvdata(adev, drvdata); + ret = __catu_probe(&adev->dev, &adev->res); + if (!ret) + pm_runtime_put(&adev->dev); + + return ret; +} + +static void __catu_remove (struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev);
coresight_unregister(drvdata->csdev); }
+static voidcatu_remove(struct amba_device *adev)drivers/hwtracing/coresight/coresight-catu.c +4
-0+{ + __catu_remove(&adev->dev); +} +static struct
amba_idcatu_ids[] = {
CS_AMBA_ID(0x000bb9ee),
{},drivers/hwtracing/coresight/coresight-catu.c +2
-0@@ -598,13 +612,103 @@ 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);drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 626
Quoted 10 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-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;---8>---
drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 635
Quoted 8 lines
drivers/hwtracing/coresight/coresight-catu.c +8
-0+ + if (res) { + drvdata->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(drvdata->base)) { + clk_put(drvdata->pclk); + return PTR_ERR(drvdata->base); + } + }
Quoted 3 lines
---<8---
The above section seems unncessary as we already try to map the base in
__catu_probe?
Agreed, though it seems unnecessary, there is a small difference in there. In the platform driver case i.e catu_platform_probe(), clk_put() is called on platform clock drvdata->pclk (just enabled earlier) for cases when devm_ioremap_resource() fails.
To remove this redundancy, let's move devm_ioremap_resource() into it's AMBA caller i.e catu_probe() thus dropping struct resource argument from __catu_probe(). Similar situation is present in coresight-cpu-debug driver as well, will fix that.
But there are some other drivers in the series where coresight_get_enable_apb_pclk() called on 'drvdata->pclk' and devm_ioremap_resource() is attempted inside the factored __xxx_probe() function which is common for both AMBA and platform drivers.
Such drivers are ...
- tpiu
- tmc
- stm
- replicator
IMHO it would be better to follow same scheme for all drivers in the series. Please do let me know which method will be preferred.
Quoted 17 lines
Quoted 17 lines
drivers/hwtracing/coresight/coresight-catu.c +15
-0+ + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + dev_set_drvdata(&pdev->dev, drvdata); + ret = __catu_probe(&pdev->dev, res); + pm_runtime_put(&pdev->dev); + if (ret) + pm_runtime_disable(&pdev->dev); + + return ret; +} + +static int catu_platform_remove (struct platform_device *pdev)
Quoted 8 lines
drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 655
Quoted 5 lines
drivers/hwtracing/coresight/coresight-catu.c +5
-0+{ + struct catu_drvdata *drvdata = dev_get_drvdata(&pdev->dev); + + if (drvdata) + __catu_remove(&pdev->dev);I don't understand the need for if () check here (and on all the other drivers). Even if we have a drvdata != NULL, what guarantees that the
drvdata->csdevis valid (which is used inxx_remove) ?
Agreed, although drvdata is derived in __xxx_remove() functions, a pre-check here is not required - similar to the AMBA remove path. Sure, will drop them across drivers.
Quoted 84 lines
Suzuki
Quoted 80 lines
drivers/hwtracing/coresight/coresight-catu.c +53
-3+ + pm_runtime_disable(&pdev->dev); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_put(drvdata->pclk); + return 0; +} + +#ifdef CONFIG_PM +static int catu_runtime_suspend (struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); + return 0; +} + +static int catu_runtime_resume (struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata && !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 +716,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);drivers/hwtracing/coresight/coresight-catu.h +1
-0@@ -61,6 +61,7 @@ #define CATU_IRQEN_OFF 0x0 struct catu_drvdata { + struct clk *pclk; void __iomem *base; struct coresight_device *csdev; int irq;
Suzuki K Poulose
maintainerRe: [PATCH V5 07/11] coresight: catu: Move ACPI support from AMBA driver to platform driver
Quoted 173 lines · Anshuman Khandual
Quoted 152 lines · Suzuki K Poulose
Quoted 128 lines · Anshuman Khandual
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. But first this renames and then refactors
catu_probe()andcatu_remove(), making sure it can be used both for platform and AMBA drivers. This also movespm_runtime_put()fromcatu_probe()to the callers.Cc Lorenzo Pieralisi <[email protected]>Cc Sudeep Holla <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Cc James Clark <[email protected]>Reviewed-by James Clark <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
Changes in V5:- Updated commit message regarding catu_probe/remove() refactoring and renaming
drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-catu.c | 142 ++++++++++++++++--- drivers/hwtracing/coresight/coresight-catu.h | 1 + 3 files changed, 124 insertions(+), 20 deletions(-)drivers/acpi/arm64/amba.c +0
-1@@ -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.cindex
3949ded0d4fa..a3ea46b53898100644drivers/hwtracing/coresight/coresight-catu.c +29
-12@@ -7,6 +7,8 @@* Author: Suzuki K Poulose <[email protected]> */ +#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;@@ -567,19 +561,39 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) drvdata->csdev = coresight_register(&catu_desc); if (IS_ERR(drvdata->csdev)) ret = PTR_ERR(drvdata->csdev); - else - pm_runtime_put(&adev->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 = dev_get_drvdata(&adev->dev); + struct catu_drvdata *drvdata; + int ret; + + drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + amba_set_drvdata(adev, drvdata); + ret = __catu_probe(&adev->dev, &adev->res); + if (!ret) + pm_runtime_put(&adev->dev); + + return ret; +} + +static void __catu_remove (struct device *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 +612,103 @@ 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);drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 626
Quoted 10 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-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;---8>---
drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 635
Quoted 8 lines
drivers/hwtracing/coresight/coresight-catu.c +8
-0+ + if (res) { + drvdata->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(drvdata->base)) { + clk_put(drvdata->pclk); + return PTR_ERR(drvdata->base); + } + }Quoted 3 lines
---<8---
The above section seems unncessary as we already try to map the base in
__catu_probe?Agreed, though it seems unnecessary, there is a small difference in there. In the platform driver case i.e
catu_platform_probe(),clk_put()is called on platform clockdrvdata->pclk(just enabled earlier) for cases whendevm_ioremap_resource()fails.To remove this redundancy, let's move
devm_ioremap_resource()into it's AMBA caller i.ecatu_probe()thus dropping struct resource argument from__catu_probe(). Similar situation is present in coresight-cpu-debug driver as well, will fix that.But there are some other drivers in the series where
coresight_get_enable_apb_pclk()called on 'drvdata->pclk' anddevm_ioremap_resource()is attempted inside the factored__xxx_probe()function which is common for both AMBA and platform drivers.Such drivers are ...
Quoted 7 lines
- tpiu
- tmc
- stm
- replicatorIMHO it would be better to follow same scheme for all drivers in the series. Please do let me know which method will be preferred.
Lets pass the "res" to the common probe and deal it there.
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
drivers/hwtracing/coresight/coresight-catu.c +15
-0+ + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + dev_set_drvdata(&pdev->dev, drvdata); + ret = __catu_probe(&pdev->dev, res); + pm_runtime_put(&pdev->dev); + if (ret) + pm_runtime_disable(&pdev->dev); + + return ret; +} + +static int catu_platform_remove (struct platform_device *pdev)Quoted 8 lines
drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 655
Quoted 5 lines
drivers/hwtracing/coresight/coresight-catu.c +5
-0+{ + struct catu_drvdata *drvdata = dev_get_drvdata(&pdev->dev); + + if (drvdata) + __catu_remove(&pdev->dev);I don't understand the need for if () check here (and on all the other drivers). Even if we have a drvdata != NULL, what guarantees that the
drvdata->csdevis valid (which is used inxx_remove) ?
Quoted 2 lines
Agreed, although drvdata is derived in
__xxx_remove()functions, a pre-check here is not required - similar to the AMBA remove path. Sure, will drop them across drivers.
No, my point is : Is there a case where :
1) drvdata == NULL, but we have a device to do some cleanup ?
2) If drvdata != NULL, but drvdata->csdev is not valid, because we failed to register the coresight device ?
Suzuki
Quoted 85 lines
Quoted 85 lines
Suzuki
Quoted 80 lines
drivers/hwtracing/coresight/coresight-catu.c +53
-3+ + pm_runtime_disable(&pdev->dev); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_put(drvdata->pclk); + return 0; +} + +#ifdef CONFIG_PM +static int catu_runtime_suspend (struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); + return 0; +} + +static int catu_runtime_resume (struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata && !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 +716,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);drivers/hwtracing/coresight/coresight-catu.h +1
-0@@ -61,6 +61,7 @@ #define CATU_IRQEN_OFF 0x0 struct catu_drvdata { + struct clk *pclk; void __iomem *base; struct coresight_device *csdev; int irq;
Re: [PATCH V5 07/11] coresight: catu: Move ACPI support from AMBA driver to platform driver
Quoted 179 lines · Suzuki K Poulose
Quoted 178 lines · Anshuman Khandual
Quoted 152 lines · Suzuki K Poulose
Quoted 128 lines · Anshuman Khandual
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. But first this renames and then refactors
catu_probe()andcatu_remove(), making sure it can be used both for platform and AMBA drivers. This also movespm_runtime_put()fromcatu_probe()to the callers.Cc Lorenzo Pieralisi <[email protected]>Cc Sudeep Holla <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Cc James Clark <[email protected]>Reviewed-by James Clark <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
Changes in V5:- Updated commit message regarding catu_probe/remove() refactoring and renaming
drivers/acpi/arm64/amba.c | 1 -
drivers/hwtracing/coresight/coresight-catu.c| 142 ++++++++++++++++---drivers/hwtracing/coresight/coresight-catu.h| 1 +3 files changed, 124 insertions(+), 20 deletions(-)drivers/acpi/arm64/amba.c +0
-0@@ -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 --gita/drivers/hwtracing/coresight/coresight-catu.cb/drivers/hwtracing/coresight/coresight-catu.cindex3949ded0d4fa..a3ea46b53898100644drivers/hwtracing/coresight/coresight-catu.c +0
-0@@ -7,6 +7,8 @@* Author: Suzuki K Poulose <[email protected]> */ +#include <
linux/platform_device.h>
+#include <linux/acpi.h>
#include <linux/amba/bus.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>drivers/hwtracing/coresight/coresight-catu.c +3
-11@@ -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;@@ -567,19 +561,39 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) drvdata->csdev = coresight_register(&catu_desc); if (IS_ERR(drvdata->csdev)) ret = PTR_ERR(drvdata->csdev); - else - pm_runtime_put(&adev->dev);out:
return ret;
}
-static voidcatu_remove(struct amba_device *adev)
+static intcatu_probe(struct amba_device *adev, const struct amba_id *id){
- structcatu_drvdata*drvdata =dev_get_drvdata(&adev->dev); + structcatu_drvdata*drvdata;
+ int ret;drivers/hwtracing/coresight/coresight-catu.c +16
-0+ + drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + amba_set_drvdata(adev, drvdata); + ret = __catu_probe(&adev->dev, &adev->res); + if (!ret) + pm_runtime_put(&adev->dev); + + return ret; +} + +static void __catu_remove (struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev);
coresight_unregister(drvdata->csdev); }
+static voidcatu_remove(struct amba_device *adev)drivers/hwtracing/coresight/coresight-catu.c +4
-0+{ + __catu_remove(&adev->dev); +} +static struct
amba_idcatu_ids[] = {
CS_AMBA_ID(0x000bb9ee),
{},drivers/hwtracing/coresight/coresight-catu.c +2
-0@@ -598,13 +612,103 @@ 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);drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 626
Quoted 10 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-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;---8>---
drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 634
Quoted 8 lines
drivers/hwtracing/coresight/coresight-catu.c +8
-0+ + if (res) { + drvdata->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(drvdata->base)) { + clk_put(drvdata->pclk); + return PTR_ERR(drvdata->base); + } + }Quoted 3 lines
---<8---
The above section seems unncessary as we already try to map the base in
__catu_probe?Agreed, though it seems unnecessary, there is a small difference in there. In the platform driver case i.e
catu_platform_probe(),clk_put()is called on platform clockdrvdata->pclk(just enabled earlier) for cases whendevm_ioremap_resource()fails.To remove this redundancy, let's move
devm_ioremap_resource()into it's AMBA caller i.ecatu_probe()thus dropping struct resource argument from__catu_probe(). Similar situation is present in coresight-cpu-debug driver as well, will fix that.But there are some other drivers in the series where
coresight_get_enable_apb_pclk()called on 'drvdata->pclk' anddevm_ioremap_resource()is attempted inside the factored__xxx_probe()function which is common for both AMBA and platform drivers.Such drivers are ...
- tpiu
- tmc
- stm
- replicator
Quoted 4 lines
Quoted 2 lines
IMHO it would be better to follow same scheme for all drivers in the series. Please do let me know which method will be preferred.
Lets pass the "res" to the common probe and deal it there.
Sure, but then will have to deal with drvdata->pclk in the caller, where it was originally acquired, when the __xxxx_probe() fails. For example - in case with the debug cpu driver, following changes will be required.
drivers/hwtracing/coresight/coresight-cpu-debug.c +7 -13
@@ -577,11 +577,11 @@ static int __debug_probe(struct device *dev, struct resource *res) } drvdata->dev = dev; - -/* Validity for the resource is already checked by the AMBA core */ - base =devm_ioremap_resource (dev, res); -if (IS_ERR (base)) -return PTR_ERR (base); +if (res) { + base =devm_ioremap_resource (dev, res); +if (IS_ERR (base)) +return PTR_ERR (base); + } drvdata->base = base;
@@ -703,14 +703,6 @@ static int debug_platform_probe(struct platform_device *pdev)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);
@@ -720,6 +712,8 @@ static int debug_platform_probe(struct platform_device *pdev)if (ret) {pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_put (drvdata->pclk); }return ret;
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 13 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-0+ + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + dev_set_drvdata(&pdev->dev, drvdata); + ret = __catu_probe(&pdev->dev, res); + pm_runtime_put(&pdev->dev); + if (ret) + pm_runtime_disable(&pdev->dev);drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 655
Quoted 10 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-0+ + return ret; +} + +static int catu_platform_remove (struct platform_device *pdev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(&pdev->dev); + + if (drvdata) + __catu_remove(&pdev->dev);I don't understand the need for if () check here (and on all the other drivers). Even if we have a drvdata != NULL, what guarantees that the
drvdata->csdevis valid (which is used inxx_remove) ?
Quoted 6 lines
Quoted 2 lines
Agreed, although drvdata is derived in
__xxx_remove()functions, a pre-check here is not required - similar to the AMBA remove path. Sure, will drop them across drivers.No, my point is : Is there a case where :
1) drvdata == NULL, but we have a device to do some cleanup ?
NO, I don't believe there are any such cases.
Quoted 1 line
2) If drvdata != NULL, but
drvdata->csdevis not valid, because we failed to register the coresight device ?
I don't believe so. If drvdata->csdev is not valid because coresight_register() has failed, that would have also failed driver' probe() as well. Hence driver remove() could not have been called in such situations.
Quoted 91 lines
Suzuki
Quoted 85 lines
Quoted 85 lines
Suzuki
Quoted 80 lines
drivers/hwtracing/coresight/coresight-catu.c +53
-3+ + pm_runtime_disable(&pdev->dev); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_put(drvdata->pclk); + return 0; +} + +#ifdef CONFIG_PM +static int catu_runtime_suspend (struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); + return 0; +} + +static int catu_runtime_resume (struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata && !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 +716,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);drivers/hwtracing/coresight/coresight-catu.h +1
-0@@ -61,6 +61,7 @@ #define CATU_IRQEN_OFF 0x0 struct catu_drvdata { + struct clk *pclk; void __iomem *base; struct coresight_device *csdev; int irq;
Suzuki K Poulose
maintainerRe: [PATCH V5 07/11] coresight: catu: Move ACPI support from AMBA driver to platform driver
Quoted 182 lines · Anshuman Khandual
Quoted 179 lines · Suzuki K Poulose
Quoted 178 lines · Anshuman Khandual
Quoted 152 lines · Suzuki K Poulose
Quoted 128 lines · Anshuman Khandual
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. But first this renames and then refactors
catu_probe()andcatu_remove(), making sure it can be used both for platform and AMBA drivers. This also movespm_runtime_put()fromcatu_probe()to the callers.Cc Lorenzo Pieralisi <[email protected]>Cc Sudeep Holla <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Cc James Clark <[email protected]>Reviewed-by James Clark <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
Changes in V5:- Updated commit message regarding catu_probe/remove() refactoring and renaming
drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-catu.c | 142 ++++++++++++++++--- drivers/hwtracing/coresight/coresight-catu.h | 1 + 3 files changed, 124 insertions(+), 20 deletions(-)drivers/acpi/arm64/amba.c +0
-1@@ -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.cindex
3949ded0d4fa..a3ea46b53898100644drivers/hwtracing/coresight/coresight-catu.c +29
-12@@ -7,6 +7,8 @@* Author: Suzuki K Poulose <[email protected]> */ +#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;@@ -567,19 +561,39 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) drvdata->csdev = coresight_register(&catu_desc); if (IS_ERR(drvdata->csdev)) ret = PTR_ERR(drvdata->csdev); - else - pm_runtime_put(&adev->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 = dev_get_drvdata(&adev->dev); + struct catu_drvdata *drvdata; + int ret; + + drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + amba_set_drvdata(adev, drvdata); + ret = __catu_probe(&adev->dev, &adev->res); + if (!ret) + pm_runtime_put(&adev->dev); + + return ret; +} + +static void __catu_remove (struct device *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 +612,103 @@ 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);drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 626
Quoted 10 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-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;---8>---
drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 634
Quoted 8 lines
drivers/hwtracing/coresight/coresight-catu.c +8
-0+ + if (res) { + drvdata->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(drvdata->base)) { + clk_put(drvdata->pclk); + return PTR_ERR(drvdata->base); + } + }Quoted 3 lines
---<8---
The above section seems unncessary as we already try to map the base in
__catu_probe?Agreed, though it seems unnecessary, there is a small difference in there. In the platform driver case i.e
catu_platform_probe(),clk_put()is called on platform clockdrvdata->pclk(just enabled earlier) for cases whendevm_ioremap_resource()fails.To remove this redundancy, let's move
devm_ioremap_resource()into it's AMBA caller i.ecatu_probe()thus dropping struct resource argument from__catu_probe(). Similar situation is present in coresight-cpu-debug driver as well, will fix that.But there are some other drivers in the series where
coresight_get_enable_apb_pclk()called on 'drvdata->pclk' anddevm_ioremap_resource()is attempted inside the factored__xxx_probe()function which is common for both AMBA and platform drivers.Such drivers are ...
- tpiu
- tmc
- stm
- replicator
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
IMHO it would be better to follow same scheme for all drivers in the series. Please do let me know which method will be preferred.
Lets pass the "res" to the common probe and deal it there.
Sure, but then will have to deal with
drvdata->pclkin the caller, where it was originally acquired, when the__xxxx_probe()fails. For example - in case with the debug cpu driver, following changes will be required.
Of course, why not. Because that is specific to the platform driver (for a reason). The whole point is, push everything that is common across AMBA or Platform to a common __xxx_probe()/remove() routine, rather than duplicating things around.
Quoted 80 lines
drivers/hwtracing/coresight/coresight-cpu-debug.c +7
-13@@ -577,11 +577,11 @@ static int __debug_probe(struct device *dev, struct resource *res) } drvdata->dev = dev; - -/* Validity for the resource is already checked by the AMBA core */ - base =devm_ioremap_resource (dev, res); -if (IS_ERR (base)) -return PTR_ERR (base); +if (res) { + base =devm_ioremap_resource (dev, res); +if (IS_ERR (base)) +return PTR_ERR (base); + } drvdata->base = base;@@ -703,14 +703,6 @@ static int debug_platform_probe(struct platform_device *pdev)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);@@ -720,6 +712,8 @@ static int debug_platform_probe(struct platform_device *pdev)if (ret) {pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_put (drvdata->pclk); }return ret;Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 13 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-0+ + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + dev_set_drvdata(&pdev->dev, drvdata); + ret = __catu_probe(&pdev->dev, res); + pm_runtime_put(&pdev->dev); + if (ret) + pm_runtime_disable(&pdev->dev);drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 655
Quoted 10 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-0+ + return ret; +} + +static int catu_platform_remove (struct platform_device *pdev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(&pdev->dev); + + if (drvdata) + __catu_remove(&pdev->dev);I don't understand the need for if () check here (and on all the other drivers). Even if we have a drvdata != NULL, what guarantees that the
drvdata->csdevis valid (which is used inxx_remove) ?Quoted 6 lines
Quoted 2 lines
Agreed, although drvdata is derived in
__xxx_remove()functions, a pre-check here is not required - similar to the AMBA remove path. Sure, will drop them across drivers.No, my point is : Is there a case where :
1) drvdata == NULL, but we have a device to do some cleanup ?
Quoted 7 lines
NO, I don't believe there are any such cases.
Quoted 1 line
2) If drvdata != NULL, but
drvdata->csdevis not valid, because we failed to register the coresight device ?I don't believe so. If
drvdata->csdevis not valid becausecoresight_register()has failed, that would have also failed driver'probe()as well. Hence driverremove()could not have been called in such situations.
So, all of those seem to be cases we don't expect. To be on the safer side, add a if (WARN_ON(!drvdata)) and return. Deal the rest with drvdata and drvdata->csdev being valid.
Suzuki
Quoted 92 lines
Quoted 92 lines
Suzuki
Quoted 85 lines
Quoted 85 lines
Suzuki
Quoted 80 lines
drivers/hwtracing/coresight/coresight-catu.c +53
-3+ + pm_runtime_disable(&pdev->dev); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_put(drvdata->pclk); + return 0; +} + +#ifdef CONFIG_PM +static int catu_runtime_suspend (struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); + return 0; +} + +static int catu_runtime_resume (struct device *dev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(dev); + + if (drvdata && !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 +716,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);drivers/hwtracing/coresight/coresight-catu.h +1
-0@@ -61,6 +61,7 @@ #define CATU_IRQEN_OFF 0x0 struct catu_drvdata { + struct clk *pclk; void __iomem *base; struct coresight_device *csdev; int irq;
PATCH v5 8/11 coresight: tpiu: Move ACPI support from AMBA driver to platform driver
In reply to Anshuman KhandualAdd 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. But first this renames and then refactors tpiu_probe() and tpiu_remove(), making sure it can be used both for platform and AMBA drivers. This also moves pm_runtime_put() from tpiu_probe() to the callers.
---
Changes in V5:
- Updated commit message regarding tpiu_probe/remove() refactoring and renaming
drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-tpiu.c | 102 +++++++++++++++++-- 2 files changed, 92 insertions(+), 11 deletions(-)
drivers/acpi/arm64/amba.c +0 -1
@@ -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}, };
drivers/hwtracing/coresight/coresight-tpiu.c +92 -10
175 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 9/11 coresight: tmc: Move ACPI support from AMBA driver to platform driver
In reply to Anshuman KhandualAdd 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. But first this renames and then refactors tmc_probe() and tmc_remove(), making sure it can be used both for platform and AMBA drivers. This also moves pm_runtime_put() from tmc_probe() to the callers.
---
Changes in V5:
- Updated the commit message regarding tmc_probe/remove() refactoring and renaming
drivers/acpi/arm64/amba.c | 2 - .../hwtracing/coresight/coresight-tmc-core.c | 139 ++++++++++++++++-- drivers/hwtracing/coresight/coresight-tmc.h | 2 + 3 files changed, 126 insertions(+), 17 deletions(-)
drivers/acpi/arm64/amba.c +0 -2
@@ -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 }, };
drivers/hwtracing/coresight/coresight-tmc-core.c +124 -15
195 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-tmc.h +2 -0
@@ -166,6 +166,7 @@ struct etr_buf {/** * struct tmc_drvdata - specifics associated to an TMC component +* @pclk: APB clock if present, otherwise NULL * @base: memory mapped base address for this component. * @csdev: component vitals needed by the framework. * @miscdev: specifics to handle "/dev/xyz.tmc" entry.
@@ -190,6 +191,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;
Signature · 1 line
2.25.1
PATCH v5 10/11 coresight: stm: Move ACPI support from AMBA driver to platform driver
In reply to Anshuman KhandualAdd 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. But first this renames and then refactors stm_probe() and stm_remove(), making sure it can be used both for platform and AMBA drivers. Also this moves pm_runtime_put() from stm_probe() to the callers.
---
Changes in V5:
- Updated commit message regarding stm_probe/remove() refactoring and renaming
drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-stm.c | 103 ++++++++++++++++++-- 2 files changed, 93 insertions(+), 11 deletions(-)
drivers/acpi/arm64/amba.c +0 -1
@@ -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 }, };
drivers/hwtracing/coresight/coresight-stm.c +93 -10
186 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 11/11 coresight: debug: Move ACPI support from AMBA driver to platform driver
In reply to Anshuman KhandualAdd 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. But first this renames and then refactors debug_probe() and debug_remove(), making sure they can be used both for platform and AMBA drivers.
---
Changes in V5:
- Updated commit message regarding debug_probe/remove() refactoring
- Replaced device name s/tmc/debug in coresight_init_driver()
drivers/acpi/arm64/amba.c | 1 - .../hwtracing/coresight/coresight-cpu-debug.c | 141 ++++++++++++++++-- 2 files changed, 127 insertions(+), 15 deletions(-)
drivers/acpi/arm64/amba.c +0 -1
@@ -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 }, };
drivers/hwtracing/coresight/coresight-cpu-debug.c +127 -14
188 lines not on this page · raw message
Signature · 1 line
2.25.1
Suzuki K Poulose
maintainerQuoted 4 lines · Anshuman Khandual
This moves remaining AMBA ACPI devices into respective platform drivers for enabling ACPI based power management support. This series applies on kernel v6.8-rc5 release. This series has been built, and boot tested on a DT based (RB5) and ACPI supported coresight platform (N1SDP).
Please rebase your series on coresight next and fix build failures with the extra warnings turned ON (should be on by default with next).
Suzuki
Quoted 99 lines
https://git.gitlab.arm.com/linux-arm/linux-anshuman.git (
amba_other_acpi_migration_v5)Cc Lorenzo Pieralisi <[email protected]>Cc Sudeep Holla <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Cc James Clark <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Changes in V5:
- Used
table->maskto filter out bits from pid incoresight_get_uci_data_from_amba()
- Dropped custom masks such asSTM_AMBA_MASKandTMC_AMBA_MASK
- Modifiedtmc_etr_setup_caps()to accept structcsdev_accessargument
- Reverted backtmc_etr_setup_caps()call site position intmc_probe()
- Changed replicator and funnel devices to use the new helpers earlier in series
- Updated the commit messages regardingxxx_probe()refactoring and renamingChanges in V4:
https://lore.kernel.org/all/[email protected]/
- Fixed PM imbalance in
etm4_probe()error path withpm_runtime_disable()
- Restored back thepm_runtime_disable()on platform probe error paths in replicator, funnel, catu, tpiu, tmc and stm devices
- Droppeddev_capsargument from__tmc_probe()
- Changedxxxx_platform_remove()forplatform_driver->remove_new()callbackChanges in V3:
https://lore.kernel.org/all/[email protected]/
- Split coresight_init_driver/remove_driver() helpers into a separate patch
- Added 'drvdata->pclk' comments in replicator, funnel, tpiu, tmc, and stm devices
- Updated funnel, and replicator drivers to use these new helpers
- Check for drvdata instead ofdrvdata->pclkin suspend and resume paths in catu, tmc and debug devices
- Added patch to extract device name from AMBA pid based table lookup for stm
- Added patch to extract device properties from AMBA pid based table look for tmc
- Droppedpm_runtime_put()from common__probe()functions
- Handledpm_runtime_put()in AMBA driver in success path
- Handledpm_runtime_put()in platform driver in both success and error pathsChanges in V2:
https://lore.kernel.org/all/[email protected]/
- Dropped redundant
devm_ioremap_resource()hunk fromtmc_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 frommodule_amba_driver(), andmodule_platform_driver()being on the same fileChanges in V1:
https://lore.kernel.org/all/[email protected]/
- Replaced all
IS_ERR()instances withIS_ERR_OR_NULL()as per SuzukiChanges in RFC:
https://lore.kernel.org/all/[email protected]/
Anshuman Khandual (11):
coresight: etm4x: Fix unbalancedpm_runtime_enable()
coresight: stm: Extract device name from AMBA pid based table lookup
coresight: tmc: Extract device properties from AMBA pid based table lookup
coresight: Add helpers registering/removing both AMBA and platform drivers
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 driverdrivers/acpi/arm64/amba.c | 8 - drivers/hwtracing/coresight/coresight-catu.c | 142 +++++++++++++--- drivers/hwtracing/coresight/coresight-catu.h | 1 + drivers/hwtracing/coresight/coresight-core.c | 29 ++++ .../hwtracing/coresight/coresight-cpu-debug.c | 141 ++++++++++++++-- .../coresight/coresight-etm4x-core.c | 3 + .../hwtracing/coresight/coresight-funnel.c | 86 +++++----- drivers/hwtracing/coresight/coresight-priv.h | 10 ++ .../coresight/coresight-replicator.c | 81 +++++----- drivers/hwtracing/coresight/coresight-stm.c | 115 +++++++++++-- .../hwtracing/coresight/coresight-tmc-core.c | 153 +++++++++++++++--- drivers/hwtracing/coresight/coresight-tmc.h | 2 + drivers/hwtracing/coresight/coresight-tpiu.c | 102 ++++++++++-- include/linux/coresight.h | 7 + 14 files changed, 721 insertions(+), 159 deletions(-)
Quoted 7 lines · Suzuki K Poulose
Quoted 4 lines · Anshuman Khandual
This moves remaining AMBA ACPI devices into respective platform drivers for enabling ACPI based power management support. This series applies on kernel v6.8-rc5 release. This series has been built, and boot tested on a DT based (RB5) and ACPI supported coresight platform (N1SDP).
Please rebase your series on coresight next and fix build failures with the extra warnings turned ON (should be on by default with next).
I did rebase the series (which required some rebase related changes for some) on coresight next i.e with the following commit as HEAD.
a4f3057d19ff ("coresight-tpda: Change qcom,dsb-element-size to qcom,dsb-elem-bits")
Although did not see any warning either with = m or = y based coresight options. Is there any other particular config which needs to be enabled for these warnings to come up ?
Quoted 104 lines
Suzuki
Quoted 99 lines
https://git.gitlab.arm.com/linux-arm/linux-anshuman.git (
amba_other_acpi_migration_v5)Cc Lorenzo Pieralisi <[email protected]>Cc Sudeep Holla <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Cc James Clark <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Changes in V5:
- Used
table->maskto filter out bits from pid incoresight_get_uci_data_from_amba()
- Dropped custom masks such asSTM_AMBA_MASKandTMC_AMBA_MASK
- Modifiedtmc_etr_setup_caps()to accept structcsdev_accessargument
- Reverted backtmc_etr_setup_caps()call site position intmc_probe()
- Changed replicator and funnel devices to use the new helpers earlier in series
- Updated the commit messages regardingxxx_probe()refactoring and renamingChanges in V4:
https://lore.kernel.org/all/[email protected]/
- Fixed PM imbalance in
etm4_probe()error path withpm_runtime_disable()
- Restored back thepm_runtime_disable()on platform probe error paths in replicator, funnel, catu, tpiu, tmc and stm devices
- Droppeddev_capsargument from__tmc_probe()
- Changedxxxx_platform_remove()forplatform_driver->remove_new()callbackChanges in V3:
https://lore.kernel.org/all/[email protected]/
- Split coresight_init_driver/remove_driver() helpers into a separate patch
- Added 'drvdata->pclk' comments in replicator, funnel, tpiu, tmc, and stm devices
- Updated funnel, and replicator drivers to use these new helpers
- Check for drvdata instead ofdrvdata->pclkin suspend and resume paths in catu, tmc and debug devices
- Added patch to extract device name from AMBA pid based table lookup for stm
- Added patch to extract device properties from AMBA pid based table look for tmc
- Droppedpm_runtime_put()from common__probe()functions
- Handledpm_runtime_put()in AMBA driver in success path
- Handledpm_runtime_put()in platform driver in both success and error pathsChanges in V2:
https://lore.kernel.org/all/[email protected]/
- Dropped redundant
devm_ioremap_resource()hunk fromtmc_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 frommodule_amba_driver(), andmodule_platform_driver()being on the same fileChanges in V1:
https://lore.kernel.org/all/[email protected]/
- Replaced all
IS_ERR()instances withIS_ERR_OR_NULL()as per SuzukiChanges in RFC:
https://lore.kernel.org/all/[email protected]/
Anshuman Khandual (11):
coresight: etm4x: Fix unbalancedpm_runtime_enable()
coresight: stm: Extract device name from AMBA pid based table lookup
coresight: tmc: Extract device properties from AMBA pid based table lookup
coresight: Add helpers registering/removing both AMBA and platform drivers
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 driverdrivers/acpi/arm64/amba.c | 8 -
drivers/hwtracing/coresight/coresight-catu.c | 142 +++++++++++++--- drivers/hwtracing/coresight/coresight-catu.h | 1 + drivers/hwtracing/coresight/coresight-core.c | 29 ++++
.../hwtracing/coresight/coresight-cpu-debug.c| 141 ++++++++++++++-- .../coresight/coresight-etm4x-core.c | 3 + .../hwtracing/coresight/coresight-funnel.c | 86 +++++----- drivers/hwtracing/coresight/coresight-priv.h | 10 ++ .../coresight/coresight-replicator.c | 81 +++++----- drivers/hwtracing/coresight/coresight-stm.c | 115 +++++++++++-- .../hwtracing/coresight/coresight-tmc-core.c | 153 +++++++++++++++--- drivers/hwtracing/coresight/coresight-tmc.h | 2 + drivers/hwtracing/coresight/coresight-tpiu.c | 102 ++++++++++-- include/linux/coresight.h | 7 +14 files changed, 721 insertions(+), 159 deletions(-)
Quoted 11 lines · Anshuman Khandual
Quoted 7 lines · Suzuki K Poulose
Quoted 4 lines · Anshuman Khandual
This moves remaining AMBA ACPI devices into respective platform drivers for enabling ACPI based power management support. This series applies on kernel v6.8-rc5 release. This series has been built, and boot tested on a DT based (RB5) and ACPI supported coresight platform (N1SDP).
Please rebase your series on coresight next and fix build failures with the extra warnings turned ON (should be on by default with next).
Quoted 9 lines
I did rebase the series (which required some rebase related changes for some) on coresight next i.e with the following commit as HEAD.
a4f3057d19ff("coresight-tpda: Change qcom,dsb-element-size to qcom,dsb-elem-bits")Although did not see any warning either with = m or = y based coresight options. Is there any other particular config which needs to be enabled for these warnings to come up ?
It doesn't apply cleanly on a4f305 for me, maybe you sent an old version after rebasing?
This change in patch 5 is a warning for example, because not all members of the struct are initialised. No special config is required:
+ {"ARMHC98D", 0}, /* ARM CoreSight Dynamic Replicator */"
Quoted 104 lines
Quoted 104 lines
Suzuki
Quoted 99 lines
https://git.gitlab.arm.com/linux-arm/linux-anshuman.git (
amba_other_acpi_migration_v5)Cc Lorenzo Pieralisi <[email protected]>Cc Sudeep Holla <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Cc James Clark <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Changes in V5:
- Used
table->maskto filter out bits from pid incoresight_get_uci_data_from_amba()
- Dropped custom masks such asSTM_AMBA_MASKandTMC_AMBA_MASK
- Modifiedtmc_etr_setup_caps()to accept structcsdev_accessargument
- Reverted backtmc_etr_setup_caps()call site position intmc_probe()
- Changed replicator and funnel devices to use the new helpers earlier in series
- Updated the commit messages regardingxxx_probe()refactoring and renamingChanges in V4:
https://lore.kernel.org/all/[email protected]/
- Fixed PM imbalance in
etm4_probe()error path withpm_runtime_disable()
- Restored back thepm_runtime_disable()on platform probe error paths in replicator, funnel, catu, tpiu, tmc and stm devices
- Droppeddev_capsargument from__tmc_probe()
- Changedxxxx_platform_remove()forplatform_driver->remove_new()callbackChanges in V3:
https://lore.kernel.org/all/[email protected]/
- Split coresight_init_driver/remove_driver() helpers into a separate patch
- Added 'drvdata->pclk' comments in replicator, funnel, tpiu, tmc, and stm devices
- Updated funnel, and replicator drivers to use these new helpers
- Check for drvdata instead ofdrvdata->pclkin suspend and resume paths in catu, tmc and debug devices
- Added patch to extract device name from AMBA pid based table lookup for stm
- Added patch to extract device properties from AMBA pid based table look for tmc
- Droppedpm_runtime_put()from common__probe()functions
- Handledpm_runtime_put()in AMBA driver in success path
- Handledpm_runtime_put()in platform driver in both success and error pathsChanges in V2:
https://lore.kernel.org/all/[email protected]/
- Dropped redundant
devm_ioremap_resource()hunk fromtmc_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 frommodule_amba_driver(), andmodule_platform_driver()being on the same fileChanges in V1:
https://lore.kernel.org/all/[email protected]/
- Replaced all
IS_ERR()instances withIS_ERR_OR_NULL()as per SuzukiChanges in RFC:
https://lore.kernel.org/all/[email protected]/
Anshuman Khandual (11):
coresight: etm4x: Fix unbalancedpm_runtime_enable()
coresight: stm: Extract device name from AMBA pid based table lookup
coresight: tmc: Extract device properties from AMBA pid based table lookup
coresight: Add helpers registering/removing both AMBA and platform drivers
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 driverdrivers/acpi/arm64/amba.c | 8 -
drivers/hwtracing/coresight/coresight-catu.c | 142 +++++++++++++--- drivers/hwtracing/coresight/coresight-catu.h | 1 + drivers/hwtracing/coresight/coresight-core.c | 29 ++++
.../hwtracing/coresight/coresight-cpu-debug.c| 141 ++++++++++++++-- .../coresight/coresight-etm4x-core.c | 3 + .../hwtracing/coresight/coresight-funnel.c | 86 +++++----- drivers/hwtracing/coresight/coresight-priv.h | 10 ++ .../coresight/coresight-replicator.c | 81 +++++----- drivers/hwtracing/coresight/coresight-stm.c | 115 +++++++++++-- .../hwtracing/coresight/coresight-tmc-core.c | 153 +++++++++++++++--- drivers/hwtracing/coresight/coresight-tmc.h | 2 + drivers/hwtracing/coresight/coresight-tpiu.c | 102 ++++++++++-- include/linux/coresight.h | 7 +14 files changed, 721 insertions(+), 159 deletions(-)
Quoted 13 lines · James Clark
Quoted 11 lines · Anshuman Khandual
Quoted 6 lines · Suzuki K Poulose
Quoted 4 lines · Anshuman Khandual
This moves remaining AMBA ACPI devices into respective platform drivers for enabling ACPI based power management support. This series applies on kernel v6.8-rc5 release. This series has been built, and boot tested on a DT based (RB5) and ACPI supported coresight platform (N1SDP).
Please rebase your series on coresight next and fix build failures with the extra warnings turned ON (should be on by default with next).
I did rebase the series (which required some rebase related changes for some) on coresight next i.e with the following commit as HEAD.
Quoted 8 lines
Quoted 6 lines
a4f3057d19ff("coresight-tpda: Change qcom,dsb-element-size to qcom,dsb-elem-bits")Although did not see any warning either with = m or = y based coresight options. Is there any other particular config which needs to be enabled for these warnings to come up ?
It doesn't apply cleanly on a4f305 for me, maybe you sent an old version after rebasing?
Ohh, I was not clear enough earlier. This series is NOT rebased against coresight next. I am preparing V6 series respin which is rebased against the above mentioned commit on coresight next branch instead.
Review
Quoted 5 lines
This change in patch 5 is a warning for example, because not all members of the struct are initialised. No special config is required:
(quoted diff) +1
-0+ {"ARMHC98D", 0}, /* ARM CoreSight Dynamic Replicator */"
Right, will change the above as follows and fix other affected places as well.
{"ARMHC98D", 0, 0, 0}, /* ARM CoreSight Dynamic Replicator */