* [PATCH v3] counter: rz-mtu3-cnt: put runtime PM ref if counter init fails
@ 2026-11-01 13:07 Li Youhong
2026-11-02 7:40 ` Biju Das
0 siblings, 1 reply; 3+ messages in thread
From: Li Youhong @ 2026-11-01 13:07 UTC (permalink / raw)
To: biju.das.jz, wbg
Cc: linux-iio, linux-renesas-soc, linux-kernel,
cosmin-gabriel.tanislav.xa, Li Youhong, stable
From: Li Youhong <liyouhong@kylinos.cn>
Counter enable takes a runtime PM reference before initialization but
only puts it on disable. Drop the reference if initialization fails.
Fixes: 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
Cc: stable@vger.kernel.org
Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
---
v3:
- Set count_is_enabled from enable after either branch succeeds.
- v2: https://lore.kernel.org/all/20261031142813.2522444-1-dayou5941@163.com/
v2:
- Add Cc: stable@vger.kernel.org.
- v1: https://lore.kernel.org/all/20261008020506.211566-1-dayou5941@163.com/
drivers/counter/rz-mtu3-cnt.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
index 7bfb6979193c..e7fe8bf45164 100644
--- a/drivers/counter/rz-mtu3-cnt.c
+++ b/drivers/counter/rz-mtu3-cnt.c
@@ -506,14 +506,17 @@ static int rz_mtu3_count_enable_write(struct counter_device *counter,
if (enable) {
pm_runtime_get_sync(counter->parent);
ret = rz_mtu3_initialize_counter(counter, count->id);
- if (ret == 0)
- priv->count_is_enabled[count->id] = true;
+ if (ret < 0) {
+ pm_runtime_put(counter->parent);
+ goto exit;
+ }
} else {
rz_mtu3_terminate_counter(counter, count->id);
- priv->count_is_enabled[count->id] = false;
pm_runtime_put(counter->parent);
}
+ priv->count_is_enabled[count->id] = enable;
+
exit:
mutex_unlock(&priv->lock);
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v3] counter: rz-mtu3-cnt: put runtime PM ref if counter init fails
2026-11-01 13:07 [PATCH v3] counter: rz-mtu3-cnt: put runtime PM ref if counter init fails Li Youhong
@ 2026-11-02 7:40 ` Biju Das
2026-11-02 14:43 ` 李佑鸿
0 siblings, 1 reply; 3+ messages in thread
From: Biju Das @ 2026-11-02 7:40 UTC (permalink / raw)
To: Li Youhong, wbg
Cc: linux-iio, linux-renesas-soc, linux-kernel,
Cosmin-Gabriel Tanislav, Li Youhong, stable
Hi Li Youhong,
> -----Original Message-----
> From: Li Youhong <dayou5941@163.com>
> Sent: 01 November 2026 13:08
> Subject: [PATCH v3] counter: rz-mtu3-cnt: put runtime PM ref if counter init fails
>
> From: Li Youhong <liyouhong@kylinos.cn>
>
> Counter enable takes a runtime PM reference before initialization but only puts it on disable. Drop the
> reference if initialization fails.
>
> Fixes: 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
> ---
> v3:
> - Set count_is_enabled from enable after either branch succeeds.
> - v2: https://lore.kernel.org/all/20261031142813.2522444-1-dayou5941@163.com/
>
> v2:
> - Add Cc: stable@vger.kernel.org.
> - v1: https://lore.kernel.org/all/20261008020506.211566-1-dayou5941@163.com/
>
> drivers/counter/rz-mtu3-cnt.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c index
> 7bfb6979193c..e7fe8bf45164 100644
> --- a/drivers/counter/rz-mtu3-cnt.c
> +++ b/drivers/counter/rz-mtu3-cnt.c
> @@ -506,14 +506,17 @@ static int rz_mtu3_count_enable_write(struct counter_device *counter,
> if (enable) {
> pm_runtime_get_sync(counter->parent);
> ret = rz_mtu3_initialize_counter(counter, count->id);
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Now days bots started complaining if pm_runtime_get_sync() fails
Then rz_mtu3_initialize_counter() will lead to kernel crash(sysnchronous abort)
as it is accessing registers without the clk.
Since you have added fixes tag, not sure this to be fixed in this patch??
Cheers,
Biju
> - if (ret == 0)
> - priv->count_is_enabled[count->id] = true;
> + if (ret < 0) {
> + pm_runtime_put(counter->parent);
> + goto exit;
> + }
> } else {
> rz_mtu3_terminate_counter(counter, count->id);
> - priv->count_is_enabled[count->id] = false;
> pm_runtime_put(counter->parent);
> }
>
> + priv->count_is_enabled[count->id] = enable;
> +
> exit:
> mutex_unlock(&priv->lock);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re:RE: [PATCH v3] counter: rz-mtu3-cnt: put runtime PM ref if counter init fails
2026-11-02 7:40 ` Biju Das
@ 2026-11-02 14:43 ` 李佑鸿
0 siblings, 0 replies; 3+ messages in thread
From: 李佑鸿 @ 2026-11-02 14:43 UTC (permalink / raw)
To: Biju Das
Cc: wbg, linux-iio, linux-renesas-soc, linux-kernel,
Cosmin-Gabriel Tanislav, Li Youhong, stable
Hi Biju,
At 2026-11-02 15:40:31, "Biju Das" <biju.das.jz@bp.renesas.com> wrote:
>Hi Li Youhong,
>
>> -----Original Message-----
>> From: Li Youhong <dayou5941@163.com>
>> Sent: 01 November 2026 13:08
>> Subject: [PATCH v3] counter: rz-mtu3-cnt: put runtime PM ref if counter init fails
>>
>> From: Li Youhong <liyouhong@kylinos.cn>
>>
>> Counter enable takes a runtime PM reference before initialization but only puts it on disable. Drop the
>> reference if initialization fails.
>>
>> Fixes: 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
>> ---
>> v3:
>> - Set count_is_enabled from enable after either branch succeeds.
>> - v2: https://lore.kernel.org/all/20261031142813.2522444-1-dayou5941@163.com/
>>
>> v2:
>> - Add Cc: stable@vger.kernel.org.
>> - v1: https://lore.kernel.org/all/20261008020506.211566-1-dayou5941@163.com/
>>
>> drivers/counter/rz-mtu3-cnt.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c index
>> 7bfb6979193c..e7fe8bf45164 100644
>> --- a/drivers/counter/rz-mtu3-cnt.c
>> +++ b/drivers/counter/rz-mtu3-cnt.c
>> @@ -506,14 +506,17 @@ static int rz_mtu3_count_enable_write(struct counter_device *counter,
>> if (enable) {
>> pm_runtime_get_sync(counter->parent);
>> ret = rz_mtu3_initialize_counter(counter, count->id);
>
>Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
>
>Now days bots started complaining if pm_runtime_get_sync() fails
>Then rz_mtu3_initialize_counter() will lead to kernel crash(sysnchronous abort)
>as it is accessing registers without the clk.
>
>Since you have added fixes tag, not sure this to be fixed in this patch??
>
The runtime PM get checks are patch 2 of this series:
https://lore.kernel.org/all/20260903090719.3498955-1-dayou5941@163.com/
We already discussed that here:
https://lore.kernel.org/all/66575d8d.214d.1a1193fd2ba.Coremail.dayou5941@163.com/
So I don't think the pm_runtime_get_sync() return value needs to be
handled in this patch. Cosmin's patch series covers that.
Thanks,
Li
>Cheers,
>Biju
>
>> - if (ret == 0)
>> - priv->count_is_enabled[count->id] = true;
>> + if (ret < 0) {
>> + pm_runtime_put(counter->parent);
>> + goto exit;
>> + }
>> } else {
>> rz_mtu3_terminate_counter(counter, count->id);
>> - priv->count_is_enabled[count->id] = false;
>> pm_runtime_put(counter->parent);
>> }
>>
>> + priv->count_is_enabled[count->id] = enable;
>> +
>> exit:
>> mutex_unlock(&priv->lock);
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-02 14:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-01 13:07 [PATCH v3] counter: rz-mtu3-cnt: put runtime PM ref if counter init fails Li Youhong
2026-11-02 7:40 ` Biju Das
2026-11-02 14:43 ` 李佑鸿
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®