From: Anshuman Khandual <anshuman.khandual@arm.com>
To: James Clark <james.clark@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 V2 5/7] coresight: tmc: Move ACPI support from AMBA driver to platform driver
Date: Tue, 5 Dec 2023 09:26:30 +0530 [thread overview]
Message-ID: <604b5b56-9f48-434e-b328-0b9616b47ec8@arm.com> (raw)
In-Reply-To: <fe5c82d1-8b7d-6701-4e19-9019f23d9c7b@arm.com>
On 12/4/23 16:24, James Clark wrote:
>
>
> On 01/12/2023 06:20, Anshuman Khandual wrote:
>> Add 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.
>>
> [...]
>> -module_amba_driver(tmc_driver);
>> +static int tmc_platform_probe(struct platform_device *pdev)
>> +{
>> + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> + struct tmc_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;
>> +
>> + dev_set_drvdata(&pdev->dev, drvdata);
>> + pm_runtime_get_noresume(&pdev->dev);
>> + pm_runtime_set_active(&pdev->dev);
>> + pm_runtime_enable(&pdev->dev);
>> +
>> + ret = __tmc_probe(&pdev->dev, res, NULL);
>> + if (ret) {
>> + pm_runtime_put_noidle(&pdev->dev);
>> + pm_runtime_disable(&pdev->dev);
>> + }
>
> I'm not sure if these pm_runtime()s are right because there is already a
> put inside of __tmc_probe() if it fails. If you unload and then reload
Actually there is a pm_runtime_put() on the success path, not when it
fails. So pm_runtime_put() gets called when __tmc_probe() returns 0.
__tmc_probe()
{
....
ret = misc_register(&drvdata->miscdev);
if (ret)
coresight_unregister(drvdata->csdev);
else
pm_runtime_put(dev);
out:
return ret;
}
tmc_platform_probe()
{
....
pm_runtime_get_noresume(&pdev->dev);
pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
ret = __tmc_probe(&pdev->dev, res, NULL);
if (ret) {
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
}
return ret;
}
tmc_probe()
{
....
return __tmc_probe(&adev->dev, &adev->res, coresight_get_uci_data(id));
}
Currently pm_runtime_put() gets called
- In success path both for AMBA and platform drivers
- In error path only for platform driver
Although the problem might be with pm_runtime_disable() instead
- pm_runtime_disable() is not required in the platform driver probe() path
- But might be required in tmc_platform_remove() along with a clk_put()
> all the coresight modules with these patches you get these errors which
> are new:
>
> coresight-tpiu-platform ARMHC979:00: Unbalanced pm_runtime_enable!
The code is similar in TPIU platform driver as well.
> CSCFG registered etm0
> coresight etm0: CPU0: etm v4.2 initialized
> CSCFG registered etm1
> coresight etm1: CPU1: etm v4.2 initialized
> CSCFG registered etm2
> coresight etm2: CPU2: etm v4.2 initialized
> CSCFG registered etm3
> coresight etm3: CPU3: etm v4.2 initialized
> coresight-tmc-platform ARMHC97C:00: Unbalanced pm_runtime_enable!
> coresight-tmc-platform ARMHC97C:01: Unbalanced pm_runtime_enable!
> coresight-tmc-platform ARMHC97C:02: Unbalanced pm_runtime_enable!
> coresight-tmc-platform ARMHC97C:03: Unbalanced pm_runtime_enable!
>
> It might be worth testing all of these pm_runtime()s, including the
> error case ones, because loading and unloading the modules doesn't even
> include the error scenarios, so there are probably more bad ones in
> there too.
The code is very similar in CATU, STM as well but debug_platform_remove()
seems to be doing this right.
I am not very familiar with all the power management aspects in coresight,
please do let me know if I missing something here.
next prev parent reply other threads:[~2023-12-05 4:04 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-01 6:20 [PATCH V2 0/7] coresight: Move remaining AMBA ACPI devices into " Anshuman Khandual
2023-12-01 6:20 ` [PATCH V2 1/7] coresight: replicator: Move ACPI support from AMBA driver to " Anshuman Khandual
2023-12-01 12:35 ` Sudeep Holla
2023-12-04 4:26 ` Anshuman Khandual
2023-12-04 4:48 ` Anshuman Khandual
2023-12-04 9:57 ` James Clark
2023-12-04 11:37 ` Anshuman Khandual
2023-12-01 6:20 ` [PATCH V2 2/7] coresight: funnel: " Anshuman Khandual
2023-12-01 12:35 ` Sudeep Holla
2023-12-01 6:20 ` [PATCH V2 3/7] coresight: catu: " Anshuman Khandual
2023-12-01 12:35 ` Sudeep Holla
2023-12-01 13:41 ` Suzuki K Poulose
2023-12-04 6:48 ` Anshuman Khandual
2023-12-01 6:20 ` [PATCH V2 4/7] coresight: tpiu: " Anshuman Khandual
2023-12-01 12:36 ` Sudeep Holla
2023-12-01 6:20 ` [PATCH V2 5/7] coresight: tmc: " Anshuman Khandual
2023-12-01 12:36 ` Sudeep Holla
2023-12-04 10:42 ` James Clark
2023-12-04 10:50 ` Suzuki K Poulose
2023-12-04 10:54 ` James Clark
2023-12-04 11:40 ` Sudeep Holla
2023-12-05 3:56 ` Anshuman Khandual [this message]
2023-12-01 6:20 ` [PATCH V2 6/7] coresight: stm: " Anshuman Khandual
2023-12-01 12:36 ` Sudeep Holla
2023-12-04 10:23 ` James Clark
2023-12-04 11:50 ` Anshuman Khandual
2023-12-04 13:17 ` James Clark
2023-12-05 5:20 ` Anshuman Khandual
2023-12-05 9:35 ` Sudeep Holla
2023-12-05 10:18 ` Suzuki K Poulose
2023-12-04 11:58 ` Sudeep Holla
2023-12-01 6:20 ` [PATCH V2 7/7] coresight: debug: " Anshuman Khandual
2023-12-01 12:37 ` Sudeep Holla
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=604b5b56-9f48-434e-b328-0b9616b47ec8@arm.com \
--to=anshuman.khandual@arm.com \
--cc=alexandre.torgue@foss.st.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 \
--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
all inboxes | Powered by JetHome®