The Linux Kernel Mailing List
 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 06/11] coresight: funnel: Move ACPI support from AMBA driver to platform driver
Date: Wed, 13 Mar 2024 11:08:37 +0000	[thread overview]
Message-ID: <b4450fd4-677d-45a1-8627-bd0b0eb45e7e@arm.com> (raw)
In-Reply-To: <bab93283-3b4a-4f39-a4a9-fee8cea1605a@arm.com>

On 13/03/2024 04:33, Anshuman Khandual wrote:
> 
> 
> On 3/12/24 20:11, Suzuki K Poulose wrote:
>> On 12/03/2024 10:23, Anshuman Khandual wrote:
>>> Add support for the dynamic funnel device in the platform driver, which can
>>> then be used on ACPI based platforms. This change would allow runtime power
>>> management for ACPI based systems.
>>>
>>> The driver would try to enable the APB clock if available. Also, rename the
>>> code to reflect the fact that it now handles both static and dynamic
>>> funnels. 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.
>>>
>>> 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 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(-)
>>>
>>> diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
>>> index 270f4e3819a2..afb6afb66967 100644
>>> --- a/drivers/acpi/arm64/amba.c
>>> +++ b/drivers/acpi/arm64/amba.c
>>> @@ -28,7 +28,6 @@ static const struct acpi_device_id amba_id_list[] = {
>>>        {"ARMHC979", 0}, /* ARM CoreSight TPIU */
>>>        {"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */
>>>        {"ARMHC9CA", 0}, /* ARM CoreSight CATU */
>>> -    {"ARMHC9FF", 0}, /* ARM CoreSight Dynamic Funnel */
>>>        {"", 0},
>>>    };
>>>    diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
>>> index ff3ea0670a5b..3b4be10a0f0c 100644
>>> --- a/drivers/hwtracing/coresight/coresight-funnel.c
>>> +++ b/drivers/hwtracing/coresight/coresight-funnel.c
>>> @@ -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);
>>> +
>>> +    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.

This applies to almost all the drivers, so please fix it elsewhere

Suzuki


  reply	other threads:[~2024-03-13 11:08 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 platform driver 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
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 [this message]
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=b4450fd4-677d-45a1-8627-bd0b0eb45e7e@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