Re: [PATCH 1/2] watchdog: rti_wdt: Use managed APIs to handle runtime PM
From: Vignesh Raghavendra
Date: Mon Nov 20 2023 - 23:02:35 EST
Hi,
On 10/11/23 20:33, Guenter Roeck wrote:
> On 11/10/23 02:07, Vignesh Raghavendra wrote:
>> Switch to devm_pm_runtime_enable() to simplify error handling in driver
>> probe.
>>
>
> This also replaces the call to pm_runtime_resume_and_get() without
> explanation.
> Worse, the next patch conditionally re-introduces pm_runtime_put_sync()
> on the probe function.
>
>> Signed-off-by: Vignesh Raghavendra <vigneshr@xxxxxx>
>> ---
>> drivers/watchdog/rti_wdt.c | 30 ++++++++----------------------
>> 1 file changed, 8 insertions(+), 22 deletions(-)
>>
>> diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
>> index 8e1be7ba0103..163bdeb6929a 100644
>> --- a/drivers/watchdog/rti_wdt.c
>> +++ b/drivers/watchdog/rti_wdt.c
>> @@ -236,12 +236,8 @@ static int rti_wdt_probe(struct platform_device
>> *pdev)
>> if (wdt->freq < 32768)
>> wdt->freq = wdt->freq * 9 / 10;
>> - pm_runtime_enable(dev);
>> - ret = pm_runtime_resume_and_get(dev);
>> - if (ret < 0) {
>> - pm_runtime_disable(&pdev->dev);
>> - return dev_err_probe(dev, ret, "runtime pm failed\n");
>> - }
>> + devm_pm_runtime_enable(dev);
>
> devm_pm_runtime_enable() returns an error code. I don't think ignoring it
> is a good idea.
>
Oops, yes...
>> + pm_runtime_get_noresume(dev);
>
> Is this functionally identical to pm_runtime_resume_and_get() ?
> That would require further explanation. Why is it not necessary
> to resume here ?
include/linux/pm_runtime.h ::
pm_runtime_resume_and_get - Bump up usage counter of a device and
resume it.
vs
pm_runtime_get_noresume - Bump up runtime PM usage counter of a device.
During probe, device is already active. Hence, there is really no need
to call driver level runtime_resume() callback as there is really no
context to resume from. Driver currently doesnt have runtime_pm calls
which I intend to add as a later patch. I guess, its probably better to
move this patch to same series.
Also, missed a call to pm_runtime_put_noidle() in the error path.
So for now I will respin 2/2 as standalone fix and repost along with
runtime_pm support.
Apologies, for the delayed response!
--
Regards
Vignesh