coresight: Move remaining AMBA ACPI devices into platform driver
Subsystems (5)
v6 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 latest coresight next. 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_v6)
Changes in V6:
- Dropped Jame's RB tag from [PATCH 3/11]
- Added clk_disable_unprepare() for pclk in replicator_probe() error path
- Added clk_disable_unprepare() for pclk in funnel_probe() error path
- Added clk_put() for pclk in catu_platform_probe() error path
- Added clk_put() for pclk in debug_platform_probe() error path
- Added WARN_ON(!drvdata) check in replicator_platform_remove()
- Added WARN_ON(!drvdata) check in funnel_platform_remove()
- Added WARN_ON(!drvdata) check in catu_platform_remove()
- Added WARN_ON(!drvdata) check in tpiu_platform_remove()
- Added WARN_ON(!drvdata) check in tmc_platform_remove()
- Added WARN_ON(!drvdata) check in stm_platform_remove()
- Added WARN_ON(!drvdata) check in debug_platform_remove()
- Added additional elements for all acpi_device_id[] updates
Changes in V5:
https://lore.kernel.org/all/[email protected]/
- 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 | 146 ++++++++++++++--- drivers/hwtracing/coresight/coresight-catu.h | 1 + drivers/hwtracing/coresight/coresight-core.c | 29 ++++ .../hwtracing/coresight/coresight-cpu-debug.c | 146 ++++++++++++++--- .../coresight/coresight-etm4x-core.c | 3 + .../hwtracing/coresight/coresight-funnel.c | 87 +++++----- drivers/hwtracing/coresight/coresight-priv.h | 10 ++ .../coresight/coresight-replicator.c | 82 +++++----- drivers/hwtracing/coresight/coresight-stm.c | 116 +++++++++++-- .../hwtracing/coresight/coresight-tmc-core.c | 154 +++++++++++++++--- drivers/hwtracing/coresight/coresight-tmc.h | 2 + drivers/hwtracing/coresight/coresight-tpiu.c | 103 ++++++++++-- include/linux/coresight.h | 7 + 14 files changed, 729 insertions(+), 165 deletions(-)
Signature · 1 line
2.25.1
PATCH v6 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().
--- drivers/hwtracing/coresight/coresight-etm4x-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwtracing/coresight/coresight-etm4x-core.c +3 -0
@@ -2213,6 +2213,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 v6 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.
--- 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
@@ -222,6 +222,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
@@ -800,6 +800,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;
@@ -896,7 +906,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 v6 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.
--- 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
PATCH v6 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.
--- 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
@@ -1398,6 +1398,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
@@ -658,4 +660,9 @@ coresight_find_output_type(struct coresight_platform_data *pdata,enum coresight_dev_type type, union coresight_dev_subtype subtype); +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);#endif /* _LINUX_COREISGHT_H */
Signature · 1 line
2.25.1
PATCH v6 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 V6:
- Added clk_disable_unprepare() for pclk in replicator_probe() error path
- Added WARN_ON(!drvdata) check in replicator_platform_remove()
- Added additional elements for acpi_device_id[]
drivers/acpi/arm64/amba.c | 1 - .../coresight/coresight-replicator.c | 68 ++++++++++++------- 2 files changed, 45 insertions(+), 24 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 +45 -23
166 lines not on this page · raw message
Signature · 1 line
2.25.1
Suzuki K Poulose
maintainerRe: [PATCH V6 05/11] coresight: replicator: Move ACPI support from AMBA driver to platform driver
Quoted 144 lines · Anshuman Khandual
Add support for the dynamic replicator device in the platform driver, which can then be used on ACPI based platforms. This change would now allow runtime power management for 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 thepm_runtime_put()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 V6:- Added
clk_disable_unprepare()for pclk inreplicator_probe()error path
- AddedWARN_ON(!drvdata)check inreplicator_platform_remove()
- Added additional elements for acpi_device_id[]drivers/acpi/arm64/amba.c | 1 - .../coresight/coresight-replicator.c | 68 ++++++++++++------- 2 files changed, 45 insertions(+), 24 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 +23
-9@@ -31,6 +31,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");* @base: memory mapped base address for this component. Also indicates * whether this one is programmable or not. * @atclk: optional clock for the core parts of the replicator. +* @pclk: APB clock if present, otherwise NULL * @csdev: component vitals needed by the framework * @spinlock: serialize enable/disable operations. * @check_idfilter_val: check if the context is lost upon clock removal. @@ -38,6 +39,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");struct replicator_drvdata {void __iomem *base;struct clk *atclk; +struct clk *pclk;struct coresight_device *csdev;spinlock_t spinlock;bool check_idfilter_val;@@ -243,6 +245,10 @@ static int replicator_probe(struct device *dev, struct resource *res)return ret; } + drvdata->pclk =coresight_get_enable_apb_pclk (dev); +if (IS_ERR (drvdata->pclk)) +return -ENODEV ; +/* * Map the device base for dynamic-replicator, which has been * validated by AMBA core @@ -285,11 +291,12 @@ static int replicator_probe(struct device *dev, struct resource *res) }replicator_reset (drvdata); -pm_runtime_put (dev); out_disable_clk:if (ret && !IS_ERR_OR_NULL (drvdata->atclk))clk_disable_unprepare (drvdata->atclk); +if (ret && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_disable_unprepare (drvdata->pclk);return ret; }@@ -301,29 +308,34 @@ static int replicator_remove(struct device *dev)return 0 ; } -static int static_replicator_probe (struct platform_device *pdev) +static int replicator_platform_probe (struct platform_device *pdev) { +struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );int ret;pm_runtime_get_noresume (&pdev->dev);pm_runtime_set_active (&pdev->dev);pm_runtime_enable (&pdev->dev); -/* Static replicators do not have programming base */ - ret =replicator_probe (&pdev->dev,NULL ); - -if (ret) { -pm_runtime_put_noidle (&pdev->dev); + ret =replicator_probe (&pdev->dev, res); +pm_runtime_put (&pdev->dev); +if (ret)pm_runtime_disable (&pdev->dev); - }return ret; } -static void static_replicator_remove (struct platform_device *pdev) +static void replicator_platform_remove (struct platform_device *pdev) { +struct replicator_drvdata *drvdata =dev_get_drvdata (&pdev->dev); + +if (WARN_ON (!drvdata)) +return ; +replicator_remove (&pdev->dev);pm_runtime_disable (&pdev->dev); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_put (drvdata->pclk); }#ifdef CONFIG_PM @@ -334,6 +346,8 @@ static int replicator_runtime_suspend(struct device *dev)if (drvdata && !IS_ERR (drvdata->atclk))clk_disable_unprepare (drvdata->atclk); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_disable_unprepare (drvdata->pclk);return 0 ; }
drivers/hwtracing/coresight/coresight-replicator.c static int replicator_runtime_resume(struct device *dev) · line 362
Quoted 5 lines
drivers/hwtracing/coresight/coresight-replicator.c +2
-0@@ -344,6 +358,8 @@ static int replicator_runtime_resume(struct device *dev)if (drvdata && !IS_ERR (drvdata->atclk))clk_prepare_enable (drvdata->atclk); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_prepare_enable (drvdata->pclk);
nit: drvdata is != NULL, so could drop it.
Rest looks fine
Suzuki
Re: [PATCH V6 05/11] coresight: replicator: Move ACPI support from AMBA driver to platform driver
Quoted 131 lines · Suzuki K Poulose
Quoted 130 lines · Anshuman Khandual
Add support for the dynamic replicator device in the platform driver, which can then be used on ACPI based platforms. This change would now allow runtime power management for 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 thepm_runtime_put()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 V6:- Added
clk_disable_unprepare()for pclk inreplicator_probe()error path
- AddedWARN_ON(!drvdata)check inreplicator_platform_remove()
- Added additional elements for acpi_device_id[]drivers/acpi/arm64/amba.c | 1 - .../coresight/coresight-replicator.c | 68 ++++++++++++-------
2 files changed, 45 insertions(+), 24 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 */ - {"ARMHC98D", 0}, /* ARM CoreSight Dynamic Replicator */ {"ARMHC9CA", 0}, /* ARM CoreSight CATU */
{"ARMHC9FF", 0}, /* ARM CoreSight Dynamic Funnel */ {"", 0},drivers/hwtracing/coresight/coresight-replicator.c +5
-1@@ -31,6 +31,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator"); * @base: memory mapped base address for this component. Also indicates * whether this one is programmable or not. * @atclk: optional clock for the core parts of the replicator. + * @pclk: APB clock if present, otherwise NULL * @csdev: component vitals needed by the framework * @spinlock: serialize enable/disable operations. * @check_idfilter_val: check if the context is lost upon clock removal.@@ -38,6 +39,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator"); struct replicator_drvdata { void __iomem *base; struct clk *atclk; + struct clk *pclk; struct coresight_device *csdev; spinlock_t spinlock; bool check_idfilter_val;@@ -243,6 +245,10 @@ static int replicator_probe(struct device *dev, struct resource *res) return ret; } + drvdata->pclk = coresight_get_enable_apb_pclk(dev); + if (IS_ERR(drvdata->pclk)) + return -ENODEV; + /** Map the device base for dynamic-replicator, which has been * validated by AMBA core @@ -285,11 +291,12 @@ static int replicator_probe(struct device *dev, struct resource *res) } replicator_reset(drvdata); - pm_runtime_put(dev);
out_disable_clk:
if (ret && !IS_ERR_OR_NULL(drvdata->atclk))clk_disable_unprepare(drvdata->atclk);
+ if (ret && !IS_ERR_OR_NULL(drvdata->pclk))
+clk_disable_unprepare(drvdata->pclk);
return ret;
}
@@ -301,29 +308,34 @@ static intreplicator_remove(struct device *dev)return 0;
}
-static intstatic_replicator_probe(struct platform_device *pdev)+static intreplicator_platform_probe(struct platform_device *pdev){
+ struct resource *res =platform_get_resource(pdev, IORESOURCE_MEM, 0); int ret;
pm_runtime_get_noresume(&pdev->dev);pm_runtime_set_active(&pdev->dev);pm_runtime_enable(&pdev->dev);
- /* Static replicators do not have programming base */
- ret =replicator_probe(&pdev->dev, NULL);
-
- if (ret) {
-pm_runtime_put_noidle(&pdev->dev);
+ ret =replicator_probe(&pdev->dev, res);
+pm_runtime_put(&pdev->dev);
+ if (ret)
pm_runtime_disable(&pdev->dev);
- }
return ret;
}
-static voidstatic_replicator_remove(struct platform_device *pdev)+static voidreplicator_platform_remove(struct platform_device *pdev){
+ structreplicator_drvdata*drvdata =dev_get_drvdata(&pdev->dev);drivers/hwtracing/coresight/coresight-replicator.c +4
-0+ + if (WARN_ON(!drvdata)) + return; +
replicator_remove(&pdev->dev);pm_runtime_disable(&pdev->dev);
+ if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) +clk_put(drvdata->pclk);
}
#ifdefCONFIG_PMdrivers/hwtracing/coresight/coresight-replicator.c +1
-0@@ -334,6 +346,8 @@ static int replicator_runtime_suspend(struct device *dev) if (drvdata && !IS_ERR(drvdata->atclk)) clk_disable_unprepare(drvdata->atclk); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); return 0;
Quoted 8 lines
Quoted 6 lines
drivers/hwtracing/coresight/coresight-replicator.c +0
-0} @@ -344,6 +358,8 @@ static int replicator_runtime_resume(struct device *dev)if (drvdata && !IS_ERR(drvdata->atclk))
clk_prepare_enable(drvdata->atclk); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) +clk_prepare_enable(drvdata->pclk);nit: drvdata is != NULL, so could drop it
But we already have a similar check for drvdata->atclk above, would not dropping drvdata for drvdata->pclk cause inconsistency and asymmetry ?
Suzuki K Poulose
maintainerRe: [PATCH V6 05/11] coresight: replicator: Move ACPI support from AMBA driver to platform driver
Quoted 118 lines · Anshuman Khandual
Quoted 115 lines · Suzuki K Poulose
Quoted 114 lines · Anshuman Khandual
Add support for the dynamic replicator device in the platform driver, which can then be used on ACPI based platforms. This change would now allow runtime power management for 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 thepm_runtime_put()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 V6:- Added
clk_disable_unprepare()for pclk inreplicator_probe()error path
- AddedWARN_ON(!drvdata)check inreplicator_platform_remove()
- Added additional elements for acpi_device_id[]drivers/acpi/arm64/amba.c | 1 - .../coresight/coresight-replicator.c | 68 ++++++++++++------- 2 files changed, 45 insertions(+), 24 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 +7
-1@@ -31,6 +31,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator"); * @base: memory mapped base address for this component. Also indicates * whether this one is programmable or not. * @atclk: optional clock for the core parts of the replicator. + * @pclk: APB clock if present, otherwise NULL * @csdev: component vitals needed by the framework * @spinlock: serialize enable/disable operations. * @check_idfilter_val: check if the context is lost upon clock removal.@@ -38,6 +39,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator"); struct replicator_drvdata { void __iomem *base; struct clk *atclk; + struct clk *pclk; struct coresight_device *csdev; spinlock_t spinlock; bool check_idfilter_val;@@ -243,6 +245,10 @@ static int replicator_probe(struct device *dev, struct resource *res) return ret; } + drvdata->pclk = coresight_get_enable_apb_pclk(dev); + if (IS_ERR(drvdata->pclk)) + return -ENODEV; + /** Map the device base for dynamic-replicator, which has been * validated by AMBA core @@ -285,11 +291,12 @@ static int replicator_probe(struct device *dev, struct resource *res) } replicator_reset(drvdata); - pm_runtime_put(dev); out_disable_clk: if (ret && !IS_ERR_OR_NULL(drvdata->atclk)) clk_disable_unprepare(drvdata->atclk); + if (ret && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); return ret; } @@ -301,29 +308,34 @@ static int replicator_remove(struct device *dev) return 0; }-static int
static_replicator_probe(struct platform_device *pdev)drivers/hwtracing/coresight/coresight-replicator.c +7
-5+static int replicator_platform_probe (struct platform_device *pdev) { + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); int ret; pm_runtime_get_noresume(&pdev->dev); pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); - /* Static replicators do not have programming base */ - ret = replicator_probe(&pdev->dev, NULL); - - if (ret) { - pm_runtime_put_noidle(&pdev->dev); + ret = replicator_probe(&pdev->dev, res); + pm_runtime_put(&pdev->dev); + if (ret) pm_runtime_disable(&pdev->dev); - } return ret; } -static void static_replicator_remove(struct platform_device *pdev) +static void replicator_platform_remove(struct platform_device *pdev) { + struct replicator_drvdata *drvdata = dev_get_drvdata(&pdev->dev);
Quoted 8 lines
Quoted 8 lines
drivers/hwtracing/coresight/coresight-replicator.c static int replicator_remove(struct device *dev) · line 338
Quoted 8 lines
drivers/hwtracing/coresight/coresight-replicator.c +6
-0+ + if (WARN_ON(!drvdata)) + return; + replicator_remove(&pdev->dev); pm_runtime_disable(&pdev->dev); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_put(drvdata->pclk);
The comment below applies here. We already return for !drvdata, so you don't need a duplicate check.
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
}
#ifdefCONFIG_PMdrivers/hwtracing/coresight/coresight-replicator.c +1
-0@@ -334,6 +346,8 @@ static int replicator_runtime_suspend(struct device *dev) if (drvdata && !IS_ERR(drvdata->atclk)) clk_disable_unprepare(drvdata->atclk); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); return 0;Quoted 8 lines
drivers/hwtracing/coresight/coresight-replicator.c static int replicator_runtime_resume(struct device *dev) · line 362
Quoted 6 lines
drivers/hwtracing/coresight/coresight-replicator.c +1
-0} @@ -344,6 +358,8 @@ static int replicator_runtime_resume(struct device *dev) if (drvdata && !IS_ERR(drvdata->atclk)) clk_prepare_enable(drvdata->atclk); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_prepare_enable(drvdata->pclk);nit: drvdata is != NULL, so could drop it
Quoted 2 lines
But we already have a similar check for
drvdata->atclkabove, would not dropping drvdata fordrvdata->pclkcause inconsistency and asymmetry ?
Sorry, I meant this for above. See above.
PATCH v6 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 V6:
- Added clk_disable_unprepare() for pclk in funnel_probe() error path
- Added WARN_ON(!drvdata) check in funnel_platform_remove()
- Added additional elements for acpi_device_id[]
drivers/acpi/arm64/amba.c | 1 - .../hwtracing/coresight/coresight-funnel.c | 72 ++++++++++++------- 2 files changed, 48 insertions(+), 25 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 +48 -24
164 lines not on this page · raw message
Signature · 1 line
2.25.1
Suzuki K Poulose
maintainerRe: [PATCH V6 06/11] coresight: funnel: Move ACPI support from AMBA driver to platform driver
Quoted 140 lines · Anshuman Khandual
Add support for the dynamic funnel device in the platform driver, which can then be used on ACPI based platforms. This change would allow runtime power management for ACPI based systems.
The driver would try to enable the APB clock if available. Also, rename the code to reflect the fact that it now handles both static and dynamic funnels. But first this refactors
funnel_probe()making sure it can be used both for platform and AMBA drivers, by moving thepm_runtime_put()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 V6:- Added
clk_disable_unprepare()for pclk infunnel_probe()error path
- AddedWARN_ON(!drvdata)check infunnel_platform_remove()
- Added additional elements for acpi_device_id[]drivers/acpi/arm64/amba.c | 1 - .../hwtracing/coresight/coresight-funnel.c | 72 ++++++++++++------- 2 files changed, 48 insertions(+), 25 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 +18
-9@@ -36,6 +36,7 @@ DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel");* struct funnel_drvdata - specifics associated to a funnel component * @base: memory mapped base address for this component. * @atclk: optional clock for the core parts of the funnel. +* @pclk: APB clock if present, otherwise NULL * @csdev: component vitals needed by the framework. * @priority: port selection order. * @spinlock: serialize enable/disable operations. @@ -43,6 +44,7 @@ DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel");struct funnel_drvdata {void __iomem *base;struct clk *atclk; +struct clk *pclk;struct coresight_device *csdev;unsigned long priority;spinlock_t spinlock;@@ -236,6 +238,10 @@ static int funnel_probe(struct device *dev, struct resource *res)return ret; } + drvdata->pclk =coresight_get_enable_apb_pclk (dev); +if (IS_ERR (drvdata->pclk)) +return -ENODEV ; +/* * Map the device base for dynamic-funnel, which has been * validated by AMBA core. @@ -272,12 +278,13 @@ static int funnel_probe(struct device *dev, struct resource *res) goto out_disable_clk; } -pm_runtime_put (dev); ret =0 ; out_disable_clk:if (ret && !IS_ERR_OR_NULL (drvdata->atclk))clk_disable_unprepare (drvdata->atclk); +if (ret && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_disable_unprepare (drvdata->pclk);return ret; }@@ -298,6 +305,9 @@ static int funnel_runtime_suspend(struct device *dev)if (drvdata && !IS_ERR (drvdata->atclk))clk_disable_unprepare (drvdata->atclk); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_disable_unprepare (drvdata->pclk); +return 0 ; }@@ -308,6 +318,8 @@ static int funnel_runtime_resume(struct device *dev)if (drvdata && !IS_ERR (drvdata->atclk))clk_prepare_enable (drvdata->atclk); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_prepare_enable (drvdata->pclk); return 0; }#endif @@ -316,55 +328,61 @@ static const struct dev_pm_ops funnel_dev_pm_ops = { SET_RUNTIME_PM_OPS(funnel_runtime_suspend, funnel_runtime_resume, NULL) }; -static int static_funnel_probe (struct platform_device *pdev) +static int funnel_platform_probe (struct platform_device *pdev) { +struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );int ret;pm_runtime_get_noresume (&pdev->dev);pm_runtime_set_active (&pdev->dev);pm_runtime_enable (&pdev->dev); -/* Static funnel do not have programming base */ - ret =funnel_probe (&pdev->dev,NULL ); - -if (ret) { -pm_runtime_put_noidle (&pdev->dev); + ret =funnel_probe (&pdev->dev, res); +pm_runtime_put (&pdev->dev); +if (ret)pm_runtime_disable (&pdev->dev); - }return ret; } -static void static_funnel_remove (struct platform_device *pdev)
drivers/hwtracing/coresight/coresight-funnel.c static const struct dev_pm_ops funnel_dev_pm_ops = { · line 357
Quoted 10 lines
drivers/hwtracing/coresight/coresight-funnel.c +7
-0+static void funnel_platform_remove (struct platform_device *pdev) { +struct funnel_drvdata *drvdata =dev_get_drvdata (&pdev->dev); + +if (WARN_ON (!drvdata)) +return ; +funnel_remove (&pdev->dev);pm_runtime_disable (&pdev->dev); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk))
Same as the previous patch
Suzuki
Re: [PATCH V6 06/11] coresight: funnel: Move ACPI support from AMBA driver to platform driver
Quoted 132 lines · Suzuki K Poulose
Quoted 131 lines · Anshuman Khandual
Add support for the dynamic funnel device in the platform driver, which can then be used on ACPI based platforms. This change would allow runtime power management for ACPI based systems.
The driver would try to enable the APB clock if available. Also, rename the code to reflect the fact that it now handles both static and dynamic funnels. But first this refactors
funnel_probe()making sure it can be used both for platform and AMBA drivers, by moving thepm_runtime_put()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 V6:- Added
clk_disable_unprepare()for pclk infunnel_probe()error path
- AddedWARN_ON(!drvdata)check infunnel_platform_remove()
- Added additional elements for acpi_device_id[]drivers/acpi/arm64/amba.c | 1 - .../hwtracing/coresight/coresight-funnel.c | 72 ++++++++++++-------
2 files changed, 48 insertions(+), 25 deletions(-)drivers/acpi/arm64/amba.c +0
-0@@ -28,7 +28,6 @@ static const struct acpi_device_id amba_id_list[] = {{"ARMHC979", 0}, /* ARM CoreSight TPIU */
{"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */
{"ARMHC9CA", 0}, /* ARM CoreSight CATU */
- {"ARMHC9FF", 0}, /* ARM CoreSight Dynamic Funnel */
{"", 0},
};
diff --gita/drivers/hwtracing/coresight/coresight-funnel.cb/drivers/hwtracing/coresight/coresight-funnel.cindexff3ea0670a5b..3b4be10a0f0c100644drivers/hwtracing/coresight/coresight-funnel.c +5
-0@@ -36,6 +36,7 @@ DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel"); * struct funnel_drvdata - specifics associated to a funnel component * @base: memory mapped base address for this component. * @atclk: optional clock for the core parts of the funnel. + * @pclk: APB clock if present, otherwise NULL * @csdev: component vitals needed by the framework. * @priority: port selection order. * @spinlock: serialize enable/disable operations.@@ -43,6 +44,7 @@ DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel"); struct funnel_drvdata { void __iomem *base; struct clk *atclk; + struct clk *pclk; struct coresight_device *csdev; unsigned long priority; spinlock_t spinlock;@@ -236,6 +238,10 @@ static int funnel_probe(struct device *dev, struct resource *res) return ret; } + drvdata->pclk = coresight_get_enable_apb_pclk(dev); + if (IS_ERR(drvdata->pclk)) + return -ENODEV; + /** Map the device base for dynamic-funnel, which has been * validated by AMBA core. @@ -272,12 +278,13 @@ static int funnel_probe(struct device *dev, struct resource *res) goto out_disable_clk; } - pm_runtime_put(dev); ret = 0;
out_disable_clk:
if (ret && !IS_ERR_OR_NULL(drvdata->atclk))clk_disable_unprepare(drvdata->atclk);
+ if (ret && !IS_ERR_OR_NULL(drvdata->pclk))
+clk_disable_unprepare(drvdata->pclk);
return ret;
}
@@ -298,6 +305,9 @@ static intfunnel_runtime_suspend(struct device *dev)if (drvdata && !IS_ERR(drvdata->atclk))clk_disable_unprepare(drvdata->atclk);
+ if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
+clk_disable_unprepare(drvdata->pclk);
+
return 0;
}
@@ -308,6 +318,8 @@ static intfunnel_runtime_resume(struct device *dev)if (drvdata && !IS_ERR(drvdata->atclk))clk_prepare_enable(drvdata->atclk);
+ if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
+clk_prepare_enable(drvdata->pclk);
return 0;
}
#endifdrivers/hwtracing/coresight/coresight-funnel.c +2
-0@@ -316,55 +328,61 @@ static const struct dev_pm_ops funnel_dev_pm_ops = { SET_RUNTIME_PM_OPS(funnel_runtime_suspend, funnel_runtime_resume, NULL) }; -static int static_funnel_probe(struct platform_device *pdev) +static int funnel_platform_probe(struct platform_device *pdev) { + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); int ret; pm_runtime_get_noresume(&pdev->dev); pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev);- /* Static funnel do not have programming base */ - ret =
funnel_probe(&pdev->dev, NULL);
-
- if (ret) {
-pm_runtime_put_noidle(&pdev->dev);
+ ret =funnel_probe(&pdev->dev, res);
+pm_runtime_put(&pdev->dev);
+ if (ret)
pm_runtime_disable(&pdev->dev);
- }
return ret;
}
-static voidstatic_funnel_remove(struct platform_device *pdev)+static voidfunnel_platform_remove(struct platform_device *pdev){
+ structfunnel_drvdata*drvdata =dev_get_drvdata(&pdev->dev); +
Quoted 8 lines
Quoted 6 lines
+ if (
WARN_ON(!drvdata))
+ return;
+
funnel_remove(&pdev->dev);pm_runtime_disable(&pdev->dev);
+ if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))Same as the previous patch
Right, unlike in xxx_runtime_suspend/resume() functions, xxx_platform_remove() functions do have a (!drvdata) check right at the beginning. Hence a redundant check in such places can be dropped.
Suzuki K Poulose
maintainerRe: [PATCH V6 06/11] coresight: funnel: Move ACPI support from AMBA driver to platform driver
Quoted 144 lines · Anshuman Khandual
Quoted 132 lines · Suzuki K Poulose
Quoted 131 lines · Anshuman Khandual
Add support for the dynamic funnel device in the platform driver, which can then be used on ACPI based platforms. This change would allow runtime power management for ACPI based systems.
The driver would try to enable the APB clock if available. Also, rename the code to reflect the fact that it now handles both static and dynamic funnels. But first this refactors
funnel_probe()making sure it can be used both for platform and AMBA drivers, by moving thepm_runtime_put()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 V6:- Added
clk_disable_unprepare()for pclk infunnel_probe()error path
- AddedWARN_ON(!drvdata)check infunnel_platform_remove()
- Added additional elements for acpi_device_id[]drivers/acpi/arm64/amba.c | 1 - .../hwtracing/coresight/coresight-funnel.c | 72 ++++++++++++------- 2 files changed, 48 insertions(+), 25 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}, }; diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.cindex
ff3ea0670a5b..3b4be10a0f0c100644drivers/hwtracing/coresight/coresight-funnel.c +18
-5@@ -36,6 +36,7 @@ DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel"); * struct funnel_drvdata - specifics associated to a funnel component * @base: memory mapped base address for this component. * @atclk: optional clock for the core parts of the funnel. + * @pclk: APB clock if present, otherwise NULL * @csdev: component vitals needed by the framework. * @priority: port selection order. * @spinlock: serialize enable/disable operations.@@ -43,6 +44,7 @@ DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel"); struct funnel_drvdata { void __iomem *base; struct clk *atclk; + struct clk *pclk; struct coresight_device *csdev; unsigned long priority; spinlock_t spinlock;@@ -236,6 +238,10 @@ static int funnel_probe(struct device *dev, struct resource *res) return ret; } + drvdata->pclk = coresight_get_enable_apb_pclk(dev); + if (IS_ERR(drvdata->pclk)) + return -ENODEV; + /** Map the device base for dynamic-funnel, which has been * validated by AMBA core. @@ -272,12 +278,13 @@ static int funnel_probe(struct device *dev, struct resource *res) goto out_disable_clk; } - pm_runtime_put(dev); ret = 0; out_disable_clk: if (ret && !IS_ERR_OR_NULL(drvdata->atclk)) clk_disable_unprepare(drvdata->atclk); + if (ret && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); return ret; } @@ -298,6 +305,9 @@ static int funnel_runtime_suspend(struct device *dev) if (drvdata && !IS_ERR(drvdata->atclk)) clk_disable_unprepare(drvdata->atclk); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); + return 0; } @@ -308,6 +318,8 @@ static int funnel_runtime_resume(struct device *dev) if (drvdata && !IS_ERR(drvdata->atclk)) clk_prepare_enable(drvdata->atclk); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_prepare_enable(drvdata->pclk); return 0; } #endif@@ -316,55 +328,61 @@ static const struct dev_pm_ops funnel_dev_pm_ops = { SET_RUNTIME_PM_OPS(funnel_runtime_suspend, funnel_runtime_resume, NULL) }; -static int static_funnel_probe(struct platform_device *pdev) +static int funnel_platform_probe(struct platform_device *pdev) { + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); int ret; pm_runtime_get_noresume(&pdev->dev); pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); - /* Static funnel do not have programming base */ - ret = funnel_probe(&pdev->dev, NULL); - - if (ret) { - pm_runtime_put_noidle(&pdev->dev); + ret = funnel_probe(&pdev->dev, res); + pm_runtime_put(&pdev->dev); + if (ret) pm_runtime_disable(&pdev->dev); - } return ret; } -static void static_funnel_remove(struct platform_device *pdev) +static void funnel_platform_remove(struct platform_device *pdev) { + struct funnel_drvdata *drvdata = dev_get_drvdata(&pdev->dev); +Quoted 8 lines
drivers/hwtracing/coresight/coresight-funnel.c static const struct dev_pm_ops funnel_dev_pm_ops = { · line 357
Quoted 6 lines
drivers/hwtracing/coresight/coresight-funnel.c +4
-0+ if (WARN_ON(!drvdata)) + return; + funnel_remove(&pdev->dev); pm_runtime_disable(&pdev->dev); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))Same as the previous patch
Quoted 3 lines
Right, unlike in xxx_runtime_suspend/resume() functions,
xxx_platform_remove()functions do have a (!drvdata) check right at the beginning. Hence a redundant check in such places can be dropped.
This applies to almost all the drivers, so please fix it elsewhere
Suzuki
PATCH v6 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 V6:
- Added clk_put() for pclk in catu_platform_probe() error path
- Added WARN_ON(!drvdata) check in catu_platform_remove()
- Added additional elements for acpi_device_id[]
drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-catu.c | 146 ++++++++++++++++--- drivers/hwtracing/coresight/coresight-catu.h | 1 + 3 files changed, 125 insertions(+), 23 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 +124 -22
200 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 V6 07/11] coresight: catu: Move ACPI support from AMBA driver to platform driver
Quoted 48 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 V6:- Added
clk_put()for pclk incatu_platform_probe()error path
- AddedWARN_ON(!drvdata)check incatu_platform_remove()
- Added additional elements for acpi_device_id[]drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-catu.c | 146 ++++++++++++++++--- drivers/hwtracing/coresight/coresight-catu.h | 1 + 3 files changed, 125 insertions(+), 23 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 +0
-0
drivers/hwtracing/coresight/coresight-catu.c line 11
Quoted 5 lines
drivers/hwtracing/coresight/coresight-catu.c +2
-0@@ -7,6 +7,8 @@* Author: Suzuki K Poulose <[email protected]> */ +#include <linux/platform_device.h> +#include <linux/acpi.h>
minor nit: Please retain the alphabetic order.
Quoted 25 lines
drivers/hwtracing/coresight/coresight-catu.c +2
-5#include <linux/amba/bus.h> #include <linux/device.h> #include <linux/dma-mapping.h> @@ -502,31 +504,25 @@ 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) {
drivers/hwtracing/coresight/coresight-catu.c static const struct coresight_ops catu_ops = { · line 520
Quoted 10 lines
drivers/hwtracing/coresight/coresight-catu.c +1
-9- ret = -ENOMEM ; - goto out; - } - -dev_set_drvdata (dev, drvdata); - base =devm_ioremap_resource (dev, &adev->res); -if (IS_ERR (base)) { - ret =PTR_ERR (base); - goto out; +if (res) {
We don't have a case where res == NULL and we shouldn't support that.
Quoted 70 lines
drivers/hwtracing/coresight/coresight-catu.c +43
-4+ base =devm_ioremap_resource (dev, res); +if (IS_ERR (base)) { + ret =PTR_ERR (base); + goto out; + } }/* Setup dma mask for the device */ @@ -567,19 +563,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; +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 (&adev->dev); +struct catu_drvdata *drvdata =dev_get_drvdata (dev);coresight_unregister (drvdata->csdev); } +static void catu_remove (struct amba_device *adev) +{ +__catu_remove (&adev->dev); +} +static struct amba_id catu_ids[] = {CS_AMBA_ID (0x000bb9ee ), {},@@ -598,13 +614,99 @@ static struct amba_driver catu_driver = { .id_table = catu_ids, }; +static int catu_platform_probe (struct platform_device *pdev) +{ +struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +struct catu_drvdata *drvdata; +int ret =0 ; + + drvdata =devm_kzalloc (&pdev->dev,sizeof (*drvdata),GFP_KERNEL ); +if (!drvdata) +return -ENOMEM ; + + drvdata->pclk =coresight_get_enable_apb_pclk (&pdev->dev); +if (IS_ERR (drvdata->pclk)) +return -ENODEV ; +
drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 640
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); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk))
Here drvdata is guaranteed to be valid and the check is not required.
Quoted 6 lines
drivers/hwtracing/coresight/coresight-catu.c +6
-0+clk_put (drvdata->pclk); + } + +return ret; +} +
drivers/hwtracing/coresight/coresight-catu.c static struct amba_driver catu_driver = { · line 656
Quoted 10 lines
drivers/hwtracing/coresight/coresight-catu.c +10
-0+static int catu_platform_remove (struct platform_device *pdev) +{ +struct catu_drvdata *drvdata =dev_get_drvdata (&pdev->dev); + +if (WARN_ON (!drvdata)) +return -ENODEV ; + +__catu_remove (&pdev->dev); +pm_runtime_disable (&pdev->dev); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk))
Same here. Rest looks fine.
Suzuki
Re: [PATCH V6 07/11] coresight: catu: Move ACPI support from AMBA driver to platform driver
Quoted 46 lines · Suzuki K Poulose
Quoted 45 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 V6:- Added
clk_put()for pclk incatu_platform_probe()error path
- AddedWARN_ON(!drvdata)check incatu_platform_remove()
- Added additional elements for acpi_device_id[]drivers/acpi/arm64/amba.c | 1 -
drivers/hwtracing/coresight/coresight-catu.c| 146 ++++++++++++++++---drivers/hwtracing/coresight/coresight-catu.h| 1 +3 files changed, 125 insertions(+), 23 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..8fa035e5a0e8100644
---a/drivers/hwtracing/coresight/coresight-catu.c
Quoted 8 lines
Quoted 6 lines
+++
b/drivers/hwtracing/coresight/coresight-catu.cdrivers/acpi/arm64/amba.c +0
-0@@ -7,6 +7,8 @@* Author: Suzuki K Poulose <[email protected]> */ +#include <
linux/platform_device.h>
+#include <linux/acpi.h>minor nit: Please retain the alphabetic order.
Sure, will do that.
Quoted 27 lines
Quoted 27 lines
#include <
linux/amba/bus.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>drivers/acpi/arm64/amba.c +2
-7@@ -502,31 +504,25 @@ 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; - } -
Quoted 8 lines
drivers/acpi/arm64/amba.c static const struct coresight_ops catu_ops = { · line 519
Quoted 6 lines
drivers/acpi/arm64/amba.c +1
-5- dev_set_drvdata(dev, drvdata); - base = devm_ioremap_resource(dev, &adev->res); - if (IS_ERR(base)) { - ret = PTR_ERR(base); - goto out; + if (res) {We don't have a case where res == NULL and we shouldn't support that.
Sure, will drop that here and in cpu debug driver as well.
Quoted 70 lines
Quoted 70 lines
drivers/acpi/arm64/amba.c +5
-2+ base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) { + ret = PTR_ERR(base); + goto out; + } } /* Setup dma mask for the device */@@ -567,19 +563,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)drivers/acpi/arm64/amba.c +18
-0+static int catu_probe (struct amba_device *adev,const struct amba_id *id) +{ + struct catu_drvdata *drvdata; + int ret; + + drvdata = devm_kzalloc(&adev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + amba_set_drvdata(adev, drvdata); + ret = __catu_probe(&adev->dev, &adev->res); + if (!ret) + pm_runtime_put(&adev->dev); + + return ret; +} + +static void __catu_remove (struct device *dev){
- structcatu_drvdata*drvdata =dev_get_drvdata(&adev->dev); + structcatu_drvdata*drvdata =dev_get_drvdata(dev);coresight_unregister(drvdata->csdev);
}
+static voidcatu_remove(struct amba_device *adev)drivers/acpi/arm64/amba.c +4
-0+{ + __catu_remove(&adev->dev); +} +static struct
amba_idcatu_ids[] = {
CS_AMBA_ID(0x000bb9ee),
{},drivers/acpi/arm64/amba.c +17
-0@@ -598,13 +614,99 @@ static struct amba_driver catu_driver = { .id_table = catu_ids, }; +static int catu_platform_probe(struct platform_device *pdev) +{ + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + struct catu_drvdata *drvdata; + int ret = 0; + + drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev); + if (IS_ERR(drvdata->pclk)) + return -ENODEV; + + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); +
Quoted 8 lines
drivers/acpi/arm64/amba.c static struct amba_driver catu_driver = { · line 639
Quoted 6 lines
drivers/acpi/arm64/amba.c +6
-0+ dev_set_drvdata(&pdev->dev, drvdata); + ret = __catu_probe(&pdev->dev, res); + pm_runtime_put(&pdev->dev); + if (ret) { + pm_runtime_disable(&pdev->dev); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))Here drvdata is guaranteed to be valid and the check is not required.
Sure, will drop.
Quoted 11 lines
Quoted 11 lines
drivers/acpi/arm64/amba.c +10
-0+ clk_put(drvdata->pclk); + } + + return ret; +} + +static int catu_platform_remove (struct platform_device *pdev) +{ + struct catu_drvdata *drvdata = dev_get_drvdata(&pdev->dev); +
Quoted 8 lines
drivers/acpi/arm64/amba.c static struct amba_driver catu_driver = { · line 655
Quoted 6 lines
drivers/acpi/arm64/amba.c +6
-0+ if (WARN_ON(!drvdata)) + return -ENODEV; + + __catu_remove(&pdev->dev); + pm_runtime_disable(&pdev->dev); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))Same here. Rest looks fine.
Sure, will drop.
PATCH v6 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 V6:
- Added WARN_ON(!drvdata) check in tpiu_platform_remove()
- Added additional elements for acpi_device_id[]
drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-tpiu.c | 103 +++++++++++++++++-- 2 files changed, 93 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 +93 -10
176 lines not on this page · raw message
Signature · 1 line
2.25.1
Suzuki K Poulose
maintainerRe: [PATCH V6 08/11] coresight: tpiu: Move ACPI support from AMBA driver to platform driver
Quoted 47 lines · Anshuman Khandual
Add support for the tpiu device in the platform driver, which can then be used on ACPI based platforms. This change would now allow runtime power management for ACPI based systems. The driver would try to enable the APB clock if available. But first this renames and then refactors
tpiu_probe()andtpiu_remove(), making sure it can be used both for platform and AMBA drivers. This also movespm_runtime_put()fromtpiu_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 V6:- Added
WARN_ON(!drvdata)check intpiu_platform_remove()
- Added additional elements for acpi_device_id[]drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-tpiu.c | 103 +++++++++++++++++-- 2 files changed, 93 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 +0
-0
drivers/hwtracing/coresight/coresight-tpiu.c line 9
Quoted 5 lines
drivers/hwtracing/coresight/coresight-tpiu.c +2
-0@@ -5,6 +5,8 @@* Description: CoreSight Trace Port Interface Unit driver */ +#include <linux/platform_device.h> +#include <linux/acpi.h>
nit: Please could you keep them alphabetic order (including the existing ones below).
Quoted 131 lines
drivers/hwtracing/coresight/coresight-tpiu.c +47
-10#include <linux/atomic.h> #include <linux/kernel.h> #include <linux/init.h> @@ -52,11 +54,13 @@ DEFINE_CORESIGHT_DEVLIST(tpiu_devs, "tpiu");/* * @base: memory mapped base address for this component. * @atclk: optional clock for the core parts of the TPIU. +* @pclk: APB clock if present, otherwise NULL * @csdev: component vitals needed by the framework. */ struct tpiu_drvdata {void __iomem *base;struct clk *atclk; +struct clk *pclk;struct coresight_device *csdev;spinlock_t spinlock; };@@ -122,14 +126,12 @@ static const struct coresight_ops tpiu_cs_ops = { .sink_ops = &tpiu_sink_ops, }; -static int tpiu_probe (struct amba_device *adev,const struct amba_id *id) +static int __tpiu_probe (struct device *dev,struct resource *res) {int ret;void __iomem *base; -struct device *dev = &adev->dev;struct coresight_platform_data *pdata =NULL ;struct tpiu_drvdata *drvdata; -struct resource *res = &adev->res;struct coresight_desc desc = {0 }; desc.name =coresight_alloc_device_name (&tpiu_devs, dev);@@ -142,12 +144,16 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)spin_lock_init (&drvdata->spinlock); - drvdata->atclk =devm_clk_get (&adev->dev,"atclk" );/* optional */ + drvdata->atclk =devm_clk_get (dev,"atclk" );/* optional */ if (!IS_ERR (drvdata->atclk)) { ret =clk_prepare_enable (drvdata->atclk);if (ret)return ret; } + + drvdata->pclk =coresight_get_enable_apb_pclk (dev); +if (IS_ERR (drvdata->pclk)) +return -ENODEV ;dev_set_drvdata (dev, drvdata);/* Validity for the resource is already checked by the AMBA core */ @@ -173,21 +179,34 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) desc.dev = dev; drvdata->csdev =coresight_register (&desc); -if (!IS_ERR (drvdata->csdev)) { -pm_runtime_put (&adev->dev); +if (!IS_ERR (drvdata->csdev))return 0 ; - }return PTR_ERR (drvdata->csdev); } -static void tpiu_remove (struct amba_device *adev) +static int tpiu_probe (struct amba_device *adev,const struct amba_id *id) { -struct tpiu_drvdata *drvdata =dev_get_drvdata (&adev->dev); +int ret; + + ret =__tpiu_probe (&adev->dev, &adev->res); +if (!ret) +pm_runtime_put (&adev->dev); +return ret; +} + +static void __tpiu_remove (struct device *dev) +{ +struct tpiu_drvdata *drvdata =dev_get_drvdata (dev);coresight_unregister (drvdata->csdev); } +static void tpiu_remove (struct amba_device *adev) +{ +__tpiu_remove (&adev->dev); +} +#ifdef CONFIG_PM static int tpiu_runtime_suspend (struct device *dev) {@@ -196,6 +215,8 @@ static int tpiu_runtime_suspend(struct device *dev)if (drvdata && !IS_ERR (drvdata->atclk))clk_disable_unprepare (drvdata->atclk); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_disable_unprepare (drvdata->pclk);return 0 ; }@@ -206,6 +227,8 @@ static int tpiu_runtime_resume(struct device *dev)if (drvdata && !IS_ERR (drvdata->atclk))clk_prepare_enable (drvdata->atclk); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk)) +clk_prepare_enable (drvdata->pclk); return 0; }#endif @@ -245,7 +268,67 @@ static struct amba_driver tpiu_driver = { .id_table = tpiu_ids, }; -module_amba_driver (tpiu_driver); +static int tpiu_platform_probe (struct platform_device *pdev) +{ +struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +int ret; + +pm_runtime_get_noresume (&pdev->dev); +pm_runtime_set_active (&pdev->dev); +pm_runtime_enable (&pdev->dev); + + ret =__tpiu_probe (&pdev->dev, res); +pm_runtime_put (&pdev->dev); +if (ret) +pm_runtime_disable (&pdev->dev); + +return ret; +} +
drivers/hwtracing/coresight/coresight-tpiu.c static struct amba_driver tpiu_driver = { · line 297
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tpiu.c +10
-0+static int tpiu_platform_remove (struct platform_device *pdev) +{ +struct tpiu_drvdata *drvdata =dev_get_drvdata (&pdev->dev); + +if (WARN_ON (!drvdata)) +return -ENODEV ; + +__tpiu_remove (&pdev->dev); +pm_runtime_disable (&pdev->dev); +if (drvdata && !IS_ERR_OR_NULL (drvdata->pclk))
Same as the previous patches.
Suzuki
Quoted 37 lines
drivers/hwtracing/coresight/coresight-tpiu.c +34
-0+clk_put (drvdata->pclk); +return 0 ; +} + +#ifdef CONFIG_ACPI +static const struct acpi_device_id tpiu_acpi_ids[] = { + {"ARMHC979" ,0 ,0 ,0 },/* ARM CoreSight TPIU */ + {} +}; +MODULE_DEVICE_TABLE (acpi, tpiu_acpi_ids); +#endif + +static struct platform_driver tpiu_platform_driver = { + .probe = tpiu_platform_probe, + .remove = tpiu_platform_remove, + .driver = { + .name ="coresight-tpiu-platform" , + .acpi_match_table =ACPI_PTR (tpiu_acpi_ids), + .suppress_bind_attrs = true, + .pm = &tpiu_dev_pm_ops, + }, +}; + +static int __init tpiu_init (void ) +{ +return coresight_init_driver ("tpiu" , &tpiu_driver, &tpiu_platform_driver); +} + +static void __exit tpiu_exit(void) +{ +coresight_remove_driver (&tpiu_driver, &tpiu_platform_driver); +} +module_init (tpiu_init); +module_exit (tpiu_exit);MODULE_AUTHOR ("Pratik Patel <[email protected]>" );MODULE_AUTHOR ("Mathieu Poirier <[email protected]>" );
Re: [PATCH V6 08/11] coresight: tpiu: Move ACPI support from AMBA driver to platform driver
Quoted 46 lines · Suzuki K Poulose
Quoted 45 lines · Anshuman Khandual
Add support for the tpiu device in the platform driver, which can then be used on ACPI based platforms. This change would now allow runtime power management for ACPI based systems. The driver would try to enable the APB clock if available. But first this renames and then refactors
tpiu_probe()andtpiu_remove(), making sure it can be used both for platform and AMBA drivers. This also movespm_runtime_put()fromtpiu_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 V6:- Added
WARN_ON(!drvdata)check intpiu_platform_remove()
- Added additional elements for acpi_device_id[]drivers/acpi/arm64/amba.c | 1 -
drivers/hwtracing/coresight/coresight-tpiu.c| 103 +++++++++++++++++--2 files changed, 93 insertions(+), 11 deletions(-)drivers/acpi/arm64/amba.c +0
-0@@ -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 +0
-1--- a/drivers/hwtracing/coresight/coresight-tpiu.c
Quoted 8 lines
Quoted 6 lines
+++
b/drivers/hwtracing/coresight/coresight-tpiu.cdrivers/hwtracing/coresight/coresight-tpiu.c +0
-0@@ -5,6 +5,8 @@* Description: CoreSight Trace Port Interface Unit driver */ +#include <
linux/platform_device.h>
+#include <linux/acpi.h>nit: Please could you keep them alphabetic order (including the existing ones below).
Sorting the existing ones along with the new header being added here, creates the following code churn. Sure, will do the changes.
drivers/hwtracing/coresight/coresight-tpiu.c +9 -7
@@ -5,17 +5,19 @@* Description: CoreSight Trace Port Interface Unit driver */ +#include <linux/acpi.h> +#include <linux/amba/bus.h> #include <linux/atomic.h> -#include <linux/kernel.h> -#include <linux/init.h> +#include <linux/clk.h> +#include <linux/coresight.h> #include <linux/device.h> -#include <linux/io.h> #include <linux/err.h> -#include <linux/slab.h> +#include <linux/init.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/platform_device.h> #include <linux/pm_runtime.h> -#include <linux/coresight.h> -#include <linux/amba/bus.h> -#include <linux/clk.h> +#include <linux/slab.h>
Quoted 122 lines
Quoted 122 lines
#include <
linux/atomic.h>
#include <linux/kernel.h>
#include <linux/init.h>drivers/hwtracing/coresight/coresight-tpiu.c +3
-2@@ -52,11 +54,13 @@ DEFINE_CORESIGHT_DEVLIST(tpiu_devs, "tpiu"); /* * @base: memory mapped base address for this component. * @atclk: optional clock for the core parts of the TPIU. + * @pclk: APB clock if present, otherwise NULL * @csdev: component vitals needed by the framework. */ struct tpiu_drvdata { void __iomem *base; struct clk *atclk; + struct clk *pclk; struct coresight_device *csdev; spinlock_t spinlock; };@@ -122,14 +126,12 @@ static const struct coresight_ops tpiu_cs_ops = { .sink_ops = &tpiu_sink_ops, }; -static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) +static int __tpiu_probe(struct device *dev, struct resource *res) { int ret; void __iomem *base; - struct device *dev = &adev->dev; struct coresight_platform_data *pdata = NULL; struct tpiu_drvdata *drvdata; - struct resource *res = &adev->res; struct coresight_desc desc = { 0 }; desc.name = coresight_alloc_device_name(&tpiu_devs, dev);@@ -142,12 +144,16 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) spin_lock_init(&drvdata->spinlock);-
drvdata->atclk=devm_clk_get(&adev->dev, "atclk"); /* optional */ +drvdata->atclk=devm_clk_get(dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) {
ret =clk_prepare_enable(drvdata->atclk);
if (ret)
return ret;
}
+
+drvdata->pclk=coresight_get_enable_apb_pclk(dev);
+ if (IS_ERR(drvdata->pclk))
+ return-ENODEV;
dev_set_drvdata(dev, drvdata);
/* Validity for the resource is already checked by the AMBA core */drivers/hwtracing/coresight/coresight-tpiu.c +18
-3@@ -173,21 +179,34 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) desc.dev = dev; drvdata->csdev = coresight_register(&desc); - if (!IS_ERR(drvdata->csdev)) { - pm_runtime_put(&adev->dev); + if (!IS_ERR(drvdata->csdev)) return 0; - } return PTR_ERR(drvdata->csdev); } -static void tpiu_remove(struct amba_device *adev) +static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) { - struct tpiu_drvdata *drvdata = dev_get_drvdata(&adev->dev); + int ret; + + ret = __tpiu_probe(&adev->dev, &adev->res); + if (!ret) + pm_runtime_put(&adev->dev); + return ret; +} + +static void __tpiu_remove (struct device *dev) +{ + struct tpiu_drvdata *drvdata = dev_get_drvdata(dev); coresight_unregister(drvdata->csdev); } +static void tpiu_remove(struct amba_device *adev) +{ + __tpiu_remove(&adev->dev); +} + #ifdef CONFIG_PM static int tpiu_runtime_suspend(struct device *dev) {@@ -196,6 +215,8 @@ static int tpiu_runtime_suspend(struct device *dev) if (drvdata && !IS_ERR(drvdata->atclk)) clk_disable_unprepare(drvdata->atclk); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) + clk_disable_unprepare(drvdata->pclk); return 0; } @@ -206,6 +227,8 @@ static int tpiu_runtime_resume(struct device *dev)if (drvdata && !IS_ERR(drvdata->atclk))
clk_prepare_enable(drvdata->atclk); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) +clk_prepare_enable(drvdata->pclk); return 0;
}
#endifdrivers/hwtracing/coresight/coresight-tpiu.c +21
-0@@ -245,7 +268,67 @@ static struct amba_driver tpiu_driver = { .id_table = tpiu_ids, }; -module_amba_driver(tpiu_driver); +static int tpiu_platform_probe (struct platform_device *pdev) +{ + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + int ret; + + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + ret = __tpiu_probe(&pdev->dev, res); + pm_runtime_put(&pdev->dev); + if (ret) + pm_runtime_disable(&pdev->dev); + + return ret; +} + +static int tpiu_platform_remove (struct platform_device *pdev) +{ + struct tpiu_drvdata *drvdata = dev_get_drvdata(&pdev->dev); +
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tpiu.c static struct amba_driver tpiu_driver = { · line 297
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tpiu.c +6
-0+ if (WARN_ON(!drvdata)) + return -ENODEV; + + __tpiu_remove(&pdev->dev); + pm_runtime_disable(&pdev->dev); + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))Same as the previous patches.
Sure, will drop the above drvdata check.
Quoted 41 lines
Suzuki
Quoted 36 lines
drivers/hwtracing/coresight/coresight-tpiu.c +34
-0+ clk_put(drvdata->pclk); + return 0; +} + +#ifdef CONFIG_ACPI +static const struct acpi_device_id tpiu_acpi_ids[] = { + {"ARMHC979", 0, 0, 0}, /* ARM CoreSight TPIU */ + {} +}; +MODULE_DEVICE_TABLE (acpi, tpiu_acpi_ids); +#endif + +static struct platform_driver tpiu_platform_driver = { + .probe = tpiu_platform_probe, + .remove = tpiu_platform_remove, + .driver = { + .name = "coresight-tpiu-platform", + .acpi_match_table = ACPI_PTR(tpiu_acpi_ids), + .suppress_bind_attrs = true, + .pm = &tpiu_dev_pm_ops, + }, +}; + +static int __init tpiu_init (void ) +{ + return coresight_init_driver("tpiu", &tpiu_driver, &tpiu_platform_driver); +} + +static void __exit tpiu_exit(void) +{ + coresight_remove_driver(&tpiu_driver, &tpiu_platform_driver); +} +module_init (tpiu_init); +module_exit (tpiu_exit); MODULE_AUTHOR("Pratik Patel <[email protected]>"); MODULE_AUTHOR("Mathieu Poirier <[email protected]>");
PATCH v6 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 V6:
- Added WARN_ON(!drvdata) check in tmc_platform_remove()
- Added additional elements for acpi_device_id[]
drivers/acpi/arm64/amba.c | 2 - .../hwtracing/coresight/coresight-tmc-core.c | 140 ++++++++++++++++-- drivers/hwtracing/coresight/coresight-tmc.h | 2 + 3 files changed, 127 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 +125 -15
196 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.
@@ -189,6 +190,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 v6 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 V6:
- Added WARN_ON(!drvdata) check in stm_platform_remove()
- Added additional elements for acpi_device_id[]
drivers/acpi/arm64/amba.c | 1 - drivers/hwtracing/coresight/coresight-stm.c | 104 ++++++++++++++++++-- 2 files changed, 94 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 +94 -10
187 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v6 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 V6:
- Added clk_put() for pclk in debug_platform_probe() error path
- Added WARN_ON(!drvdata) check in debug_platform_remove()
- Added additional elements for acpi_device_id[]
drivers/acpi/arm64/amba.c | 1 - .../hwtracing/coresight/coresight-cpu-debug.c | 146 +++++++++++++++--- 2 files changed, 127 insertions(+), 20 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 -19
193 lines not on this page · raw message
Signature · 1 line
2.25.1