public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Clark <james.clark@arm.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
	linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Mike Leach <mike.leach@linaro.org>,
	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 V3 04/10] coresight: replicator: Move ACPI support from AMBA driver to platform driver
Date: Mon, 11 Dec 2023 10:12:35 +0000	[thread overview]
Message-ID: <6c3d9c5c-8185-bcdf-2897-0db13c00a843@arm.com> (raw)
In-Reply-To: <862afccb-e9c5-4fcb-abdf-45a5eb9aa6d8@arm.com>



On 11/12/2023 07:51, Anshuman Khandual wrote:
> 
> 
> On 12/8/23 11:09, 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 repliacator 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.
>>
>> 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
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>> Changes in V3:
>>
>> - Added commnets for 'drvdata->pclk'
>> - Used coresight_init_driver()/coresight_remove_driver() helpers instead
>> - Dropped pm_runtime_put() from replicator_probe()
>> - Added pm_runtime_put() on success path in dynamic_replicator_probe()
>> - Added pm_runtime_put() on success/error paths in
>>   replicator_platform_probe()
>>
>>  drivers/acpi/arm64/amba.c                     |  1 -
>>  .../coresight/coresight-replicator.c          | 81 ++++++++++---------
>>  2 files changed, 42 insertions(+), 40 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 b6be73034996..125b256cb8db 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,7 +291,6 @@ 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))
>> @@ -301,29 +306,31 @@ 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);
>> -		pm_runtime_disable(&pdev->dev);
>> -	}
>> +	ret = replicator_probe(&pdev->dev, res);
>> +	pm_runtime_put(&pdev->dev);
> 
> I believe pm_runtime_disable() would still be needed on the error path. Otherwise
> pm_runtime_enable() will remain unbalanced on this error path when the replicator
> module could not be loaded.
> 
> --- a/drivers/hwtracing/coresight/coresight-replicator.c
> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
> @@ -317,6 +317,8 @@ static int replicator_platform_probe(struct platform_device *pdev)
>  
>         ret = replicator_probe(&pdev->dev, res);
>         pm_runtime_put(&pdev->dev);
> +       if (ret)
> +               pm_runtime_disable(&pdev->dev);
>  
>         return ret;
>  }
> 
> Similar constructs in this error path are also required in all other drivers (except
> cpu debug) as well.

Would that not need to be done as a fixes commit first with more detail
about the issue if that's true? Maybe simulate the error and paste any
error logs. For example etm4 already has this:

  	pm_runtime_get_noresume(&pdev->dev);
	pm_runtime_set_active(&pdev->dev);
	pm_runtime_enable(&pdev->dev);

	ret = etm4_probe(&pdev->dev);

	pm_runtime_put(&pdev->dev);

I'm wondering if the disable is already covered by the platform code if
the probe fails so no change is required?

	if (drv->probe) {
		ret = drv->probe(dev);
		if (ret)
			dev_pm_domain_detach(_dev, true);
	}

  reply	other threads:[~2023-12-11 10:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08  5:39 [PATCH V3 00/10] coresight: Move remaining AMBA ACPI devices into platform driver Anshuman Khandual
2023-12-08  5:39 ` [PATCH V3 01/10] coresight: stm: Extract device name from AMBA pid based table lookup Anshuman Khandual
2023-12-08  5:39 ` [PATCH V3 02/10] coresight: tmc: Extract device properties " Anshuman Khandual
2023-12-08  5:39 ` [PATCH V3 03/10] coresight: Add helpers registering/removing both AMBA and platform drivers Anshuman Khandual
2023-12-08  5:39 ` [PATCH V3 04/10] coresight: replicator: Move ACPI support from AMBA driver to platform driver Anshuman Khandual
2023-12-11  7:51   ` Anshuman Khandual
2023-12-11 10:12     ` James Clark [this message]
2023-12-12  7:31       ` Anshuman Khandual
2023-12-08  5:39 ` [PATCH V3 05/10] coresight: funnel: " Anshuman Khandual
2023-12-08  5:39 ` [PATCH V3 06/10] coresight: catu: " Anshuman Khandual
2023-12-08  5:39 ` [PATCH V3 07/10] coresight: tpiu: " Anshuman Khandual
2023-12-08  5:39 ` [PATCH V3 08/10] coresight: tmc: " Anshuman Khandual
2023-12-08 15:31   ` James Clark
2023-12-11  7:39     ` Anshuman Khandual
2023-12-08  5:39 ` [PATCH V3 09/10] coresight: stm: " Anshuman Khandual
2023-12-08  5:39 ` [PATCH V3 10/10] coresight: debug: " Anshuman Khandual
2023-12-08 15:32 ` [PATCH V3 00/10] coresight: Move remaining AMBA ACPI devices into " James Clark

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=6c3d9c5c-8185-bcdf-2897-0db13c00a843@arm.com \
    --to=james.clark@arm.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=anshuman.khandual@arm.com \
    --cc=coresight@lists.linaro.org \
    --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 \
    --cc=suzuki.poulose@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