[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5c4512ff-3102-4302-bc4b-2400799bd598@arm.com>
Date: Wed, 13 Mar 2024 08:01:52 +0530
From: Anshuman Khandual <anshuman.khandual@....com>
To: Suzuki K Poulose <suzuki.poulose@....com>,
linux-arm-kernel@...ts.infradead.org
Cc: Lorenzo Pieralisi <lpieralisi@...nel.org>,
Sudeep Holla <sudeep.holla@....com>, Mike Leach <mike.leach@...aro.org>,
James Clark <james.clark@....com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>, linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org, coresight@...ts.linaro.org,
linux-stm32@...md-mailman.stormreply.com
Subject: Re: [PATCH V6 05/11] coresight: replicator: Move ACPI support from
AMBA driver to platform driver
On 3/12/24 20:09, Suzuki K Poulose wrote:
> On 12/03/2024 10:23, Anshuman Khandual wrote:
>> Add support for the dynamic replicator device in the platform driver, which
>> can then be used on ACPI based platforms. This change would now allow
>> runtime power management for 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.
>>
>> Cc: Lorenzo Pieralisi <lpieralisi@...nel.org>
>> Cc: Sudeep Holla <sudeep.holla@....com>
>> Cc: Suzuki K Poulose <suzuki.poulose@....com>
>> Cc: Mike Leach <mike.leach@...aro.org>
>> Cc: James Clark <james.clark@....com>
>> Cc: linux-acpi@...r.kernel.org
>> Cc: linux-arm-kernel@...ts.infradead.org
>> Cc: linux-kernel@...r.kernel.org
>> Cc: coresight@...ts.linaro.org
>> Tested-by: Sudeep Holla <sudeep.holla@....com> # Boot and driver probe only
>> Acked-by: Sudeep Holla <sudeep.holla@....com> # For ACPI related changes
>> Reviewed-by: James Clark <james.clark@....com>
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@....com>
>> ---
>> 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(-)
>>
>> diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
>> index 171b5c2c7edd..270f4e3819a2 100644
>> --- a/drivers/acpi/arm64/amba.c
>> +++ b/drivers/acpi/arm64/amba.c
>> @@ -27,7 +27,6 @@ static const struct acpi_device_id amba_id_list[] = {
>> {"ARMHC503", 0}, /* ARM CoreSight Debug */
>> {"ARMHC979", 0}, /* ARM CoreSight TPIU */
>> {"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */
>> - {"ARMHC98D", 0}, /* ARM CoreSight Dynamic Replicator */
>> {"ARMHC9CA", 0}, /* ARM CoreSight CATU */
>> {"ARMHC9FF", 0}, /* ARM CoreSight Dynamic Funnel */
>> {"", 0},
>> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
>> index ddb530a8436f..ed9be5435f94 100644
>> --- a/drivers/hwtracing/coresight/coresight-replicator.c
>> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
>> @@ -31,6 +31,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
>> * @base: memory mapped base address for this component. Also indicates
>> * whether this one is programmable or not.
>> * @atclk: optional clock for the core parts of the replicator.
>> + * @pclk: APB clock if present, otherwise NULL
>> * @csdev: component vitals needed by the framework
>> * @spinlock: serialize enable/disable operations.
>> * @check_idfilter_val: check if the context is lost upon clock removal.
>> @@ -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;
>> }
>> @@ -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 ?
Powered by blists - more mailing lists