From: Claudiu Beznea <[email protected]>
pm_runtime_put() may return an error code. Check its return status.
Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L")
Signed-off-by: Claudiu Beznea <[email protected]>
---
drivers/watchdog/rzg2l_wdt.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
index 4ab9e7c5e771..0554965027cd 100644
--- a/drivers/watchdog/rzg2l_wdt.c
+++ b/drivers/watchdog/rzg2l_wdt.c
@@ -144,9 +144,13 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev)
static int rzg2l_wdt_stop(struct watchdog_device *wdev)
{
struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
+ int ret;
rzg2l_wdt_reset(priv);
- pm_runtime_put(wdev->parent);
+
+ ret = pm_runtime_put(wdev->parent);
+ if (ret < 0)
+ return ret;
return 0;
}
--
2.39.2
On 1/22/24 03:11, Claudiu wrote:
> From: Claudiu Beznea <[email protected]>
>
> pm_runtime_put() may return an error code. Check its return status.
>
> Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L")
> Signed-off-by: Claudiu Beznea <[email protected]>
> ---
> drivers/watchdog/rzg2l_wdt.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
> index 4ab9e7c5e771..0554965027cd 100644
> --- a/drivers/watchdog/rzg2l_wdt.c
> +++ b/drivers/watchdog/rzg2l_wdt.c
> @@ -144,9 +144,13 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev)
> static int rzg2l_wdt_stop(struct watchdog_device *wdev)
> {
> struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
> + int ret;
>
> rzg2l_wdt_reset(priv);
> - pm_runtime_put(wdev->parent);
> +
> + ret = pm_runtime_put(wdev->parent);
> + if (ret < 0)
> + return ret;
>
> return 0;
> }
A simple
return pm_runtime_put();
might do.
However, one question: Given that pm_runtime_put() returns -ENOSYS if
CONFIG_PM is disabled, that means the driver will depend on CONFIG_PM=y.
Assuming this is intentional, would it make sense to explicitly declare
that dependency in Kconfig ? It doesn't seem to make any sense to build
the driver if it won't work anyway.
Thanks,
Guenter
On 1/22/24 23:02, claudiu beznea wrote:
>
>
> On 22.01.2024 19:31, Guenter Roeck wrote:
>> On 1/22/24 03:11, Claudiu wrote:
>>> From: Claudiu Beznea <[email protected]>
>>>
>>> pm_runtime_put() may return an error code. Check its return status.
>>>
>>> Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L")
>>> Signed-off-by: Claudiu Beznea <[email protected]>
>>> ---
>>> drivers/watchdog/rzg2l_wdt.c | 6 +++++-
>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
>>> index 4ab9e7c5e771..0554965027cd 100644
>>> --- a/drivers/watchdog/rzg2l_wdt.c
>>> +++ b/drivers/watchdog/rzg2l_wdt.c
>>> @@ -144,9 +144,13 @@ static int rzg2l_wdt_start(struct watchdog_device
>>> *wdev)
>>> static int rzg2l_wdt_stop(struct watchdog_device *wdev)
>>> {
>>> struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
>>> + int ret;
>>> rzg2l_wdt_reset(priv);
>>> - pm_runtime_put(wdev->parent);
>>> +
>>> + ret = pm_runtime_put(wdev->parent);
>>> + if (ret < 0)
>>> + return ret;
>>> return 0;
>>> }
>>
>> A simple
>> return pm_runtime_put();
>> might do.
>
> pm_runtime_put() may return 1 if the device is already suspended though
> this call trace:
>
> pm_runtime_put() ->
> __pm_runtime_idle() ->
> rpm_idle() ->
> rpm_suspend() ->
> rpm_check_suspend_allowed() [1]
>
> That return value is not considered error thus I wanted to consider it
> here, too.
>
Good point.
> [1]
> https://elixir.bootlin.com/linux/latest/source/drivers/base/power/runtime.c#L278
>
>>
>> However, one question: Given that pm_runtime_put() returns -ENOSYS if
>> CONFIG_PM is disabled, that means the driver will depend on CONFIG_PM=y.
>
> Indeed, the driver depends on CONFIG_PM=y for proper working. It is for
> devices selecting ARCH_RZG2L and RZ/V2M (ARM64 based uarch) which select
> CONFIG_PM=y:
> https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L45
>
> The driver is written with CONFIG_PM=y dependency in mind (e.g. the clocks
> are enabled though runtime PM APIs).
>
>> Assuming this is intentional, would it make sense to explicitly declare
>> that dependency in Kconfig ? It doesn't seem to make any sense to build
>> the driver if it won't work anyway.
>
> The dependency exists there for ARCH_RZG2L and RZ/V2M devices but not
> directly and it is not strict (in the sense that we allow to build the
> driver w/o CONFIG_PM (I think this is good to check build on different
> configurations, the COMPILE_TEST is there anyway in [1]) ). E.g.:
>
> RENESAS_RZG2LWDT depends on ARCH_RENESAS [1]
> ARCH_RENESAS is the ARMv8 uarch flag [2]
> SOC_RENESAS is set if ARCH_RENESAS [3]
> ARCH_RZG2L is visible only if SOC_RENESAS [4]
> ARCH_RZG2L selects PM [5]
> RZ/V2M selects PM [6]
>
> Please let me know what do you think about it?
>
If the driver indeed depends on CONFIG_PM, that should be made explicit.
Guenter
> Thank you,
> Claudiu Beznea
>
>
> [1]
> https://elixir.bootlin.com/linux/latest/source/drivers/watchdog/Kconfig#L913
> [2]
> https://elixir.bootlin.com/linux/latest/source/arch/arm64/Kconfig.platforms#L273
> [3]
> https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L2
> [4]
> https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L9
> [5]
> https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L45
> [6]
> https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L328
>
>
>>
>> Thanks,
>> Guenter
>>
>
On 22.01.2024 19:31, Guenter Roeck wrote:
> On 1/22/24 03:11, Claudiu wrote:
>> From: Claudiu Beznea <[email protected]>
>>
>> pm_runtime_put() may return an error code. Check its return status.
>>
>> Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L")
>> Signed-off-by: Claudiu Beznea <[email protected]>
>> ---
>> drivers/watchdog/rzg2l_wdt.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
>> index 4ab9e7c5e771..0554965027cd 100644
>> --- a/drivers/watchdog/rzg2l_wdt.c
>> +++ b/drivers/watchdog/rzg2l_wdt.c
>> @@ -144,9 +144,13 @@ static int rzg2l_wdt_start(struct watchdog_device
>> *wdev)
>> static int rzg2l_wdt_stop(struct watchdog_device *wdev)
>> {
>> struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
>> + int ret;
>> rzg2l_wdt_reset(priv);
>> - pm_runtime_put(wdev->parent);
>> +
>> + ret = pm_runtime_put(wdev->parent);
>> + if (ret < 0)
>> + return ret;
>> return 0;
>> }
>
> A simple
> return pm_runtime_put();
> might do.
pm_runtime_put() may return 1 if the device is already suspended though
this call trace:
pm_runtime_put() ->
__pm_runtime_idle() ->
rpm_idle() ->
rpm_suspend() ->
rpm_check_suspend_allowed() [1]
That return value is not considered error thus I wanted to consider it
here, too.
[1]
https://elixir.bootlin.com/linux/latest/source/drivers/base/power/runtime.c#L278
>
> However, one question: Given that pm_runtime_put() returns -ENOSYS if
> CONFIG_PM is disabled, that means the driver will depend on CONFIG_PM=y.
Indeed, the driver depends on CONFIG_PM=y for proper working. It is for
devices selecting ARCH_RZG2L and RZ/V2M (ARM64 based uarch) which select
CONFIG_PM=y:
https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L45
The driver is written with CONFIG_PM=y dependency in mind (e.g. the clocks
are enabled though runtime PM APIs).
> Assuming this is intentional, would it make sense to explicitly declare
> that dependency in Kconfig ? It doesn't seem to make any sense to build
> the driver if it won't work anyway.
The dependency exists there for ARCH_RZG2L and RZ/V2M devices but not
directly and it is not strict (in the sense that we allow to build the
driver w/o CONFIG_PM (I think this is good to check build on different
configurations, the COMPILE_TEST is there anyway in [1]) ). E.g.:
RENESAS_RZG2LWDT depends on ARCH_RENESAS [1]
ARCH_RENESAS is the ARMv8 uarch flag [2]
SOC_RENESAS is set if ARCH_RENESAS [3]
ARCH_RZG2L is visible only if SOC_RENESAS [4]
ARCH_RZG2L selects PM [5]
RZ/V2M selects PM [6]
Please let me know what do you think about it?
Thank you,
Claudiu Beznea
[1]
https://elixir.bootlin.com/linux/latest/source/drivers/watchdog/Kconfig#L913
[2]
https://elixir.bootlin.com/linux/latest/source/arch/arm64/Kconfig.platforms#L273
[3]
https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L2
[4]
https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L9
[5]
https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L45
[6]
https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L328
>
> Thanks,
> Guenter
>