mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
	linux-arm-kernel@lists.infradead.org
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Mike Leach <mike.leach@linaro.org>,
	James Clark <james.clark@arm.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	coresight@lists.linaro.org,
	linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH V6 05/11] coresight: replicator: Move ACPI support from AMBA driver to platform driver
Date: Wed, 13 Mar 2024 09:41:42 +0000	[thread overview]
Message-ID: <9b8f8e96-c205-4089-abf4-8b6ef0d4b182@arm.com> (raw)
In-Reply-To: <5c4512ff-3102-4302-bc4b-2400799bd598@arm.com>

On 13/03/2024 02:31, Anshuman Khandual wrote:
> 
> 
> 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@kernel.org>
>>> Cc: Sudeep Holla <sudeep.holla@arm.com>
>>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
>>> Cc: Mike Leach <mike.leach@linaro.org>
>>> Cc: James Clark <james.clark@arm.com>
>>> Cc: linux-acpi@vger.kernel.org
>>> Cc: linux-arm-kernel@lists.infradead.org
>>> Cc: linux-kernel@vger.kernel.org
>>> Cc: coresight@lists.linaro.org
>>> Tested-by: Sudeep Holla <sudeep.holla@arm.com> # Boot and driver probe only
>>> Acked-by: Sudeep Holla <sudeep.holla@arm.com> # For ACPI related changes
>>> Reviewed-by: James Clark <james.clark@arm.com>
>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.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);

The comment below applies here. We already return for !drvdata, so you 
don't need a duplicate check.


>>>    }
>>>      #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 ?

Sorry, I meant this for above. See above.




  reply	other threads:[~2024-03-13  9:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 10:23 [PATCH V6 00/11] coresight: Move remaining AMBA ACPI devices into " Anshuman Khandual
2024-03-12 10:23 ` [PATCH V6 01/11] coresight: etm4x: Fix unbalanced pm_runtime_enable() Anshuman Khandual
2024-03-12 10:23 ` [PATCH V6 02/11] coresight: stm: Extract device name from AMBA pid based table lookup Anshuman Khandual
2024-03-12 10:23 ` [PATCH V6 03/11] coresight: tmc: Extract device properties " Anshuman Khandual
2024-03-12 10:23 ` [PATCH V6 04/11] coresight: Add helpers registering/removing both AMBA and platform drivers Anshuman Khandual
2024-03-12 10:23 ` [PATCH V6 05/11] coresight: replicator: Move ACPI support from AMBA driver to platform driver Anshuman Khandual
2024-03-12 14:39   ` Suzuki K Poulose
2024-03-13  2:31     ` Anshuman Khandual
2024-03-13  9:41       ` Suzuki K Poulose [this message]
2024-03-12 10:23 ` [PATCH V6 06/11] coresight: funnel: " Anshuman Khandual
2024-03-12 14:41   ` Suzuki K Poulose
2024-03-13  4:33     ` Anshuman Khandual
2024-03-13 11:08       ` Suzuki K Poulose
2024-03-12 10:23 ` [PATCH V6 07/11] coresight: catu: " Anshuman Khandual
2024-03-12 15:05   ` Suzuki K Poulose
2024-03-13  4:35     ` Anshuman Khandual
2024-03-12 10:23 ` [PATCH V6 08/11] coresight: tpiu: " Anshuman Khandual
2024-03-12 16:37   ` Suzuki K Poulose
2024-03-13  4:42     ` Anshuman Khandual
2024-03-12 10:23 ` [PATCH V6 09/11] coresight: tmc: " Anshuman Khandual
2024-03-12 10:23 ` [PATCH V6 10/11] coresight: stm: " Anshuman Khandual
2024-03-12 10:23 ` [PATCH V6 11/11] coresight: debug: " Anshuman Khandual

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9b8f8e96-c205-4089-abf4-8b6ef0d4b182@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=anshuman.khandual@arm.com \
    --cc=coresight@lists.linaro.org \
    --cc=james.clark@arm.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=lpieralisi@kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mike.leach@linaro.org \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®