RE: [PATCH v3 05/14] counter: rz-mtu3-cnt: disable channel before releasing
From: Biju Das
Date: Tue Nov 17 2026 - 09:06:20 EST
> -----Original Message-----
> From: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@xxxxxxxxxxx>
> Sent: 17 November 2026 10:26
> Subject: [PATCH v3 05/14] counter: rz-mtu3-cnt: disable channel before releasing
>
> Releasing a channel marks it as not busy, allowing other threads to claim it. With the current logic,
> it is possible for another thread to claim the channel before disable is called, since we release the
> channel before we disable it, causing the channel to possibly remain disabled while it should have
> been enabled.
>
> Disable the channel before releasing it.
>
> Fixes: 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
> Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@xxxxxxxxxxx>
Reviewed-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> ---
>
> V3:
> * no changes
>
> V2:
> * no changes
>
> drivers/counter/rz-mtu3-cnt.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c index
> db30470215c2..23dbca3b5cfb 100644
> --- a/drivers/counter/rz-mtu3-cnt.c
> +++ b/drivers/counter/rz-mtu3-cnt.c
> @@ -456,13 +456,13 @@ static void rz_mtu3_terminate_counter(struct counter_device *counter, int id)
> struct rz_mtu3_channel *const ch2 = rz_mtu3_get_ch(counter, 1);
>
> if (id == RZ_MTU3_32_BIT_CH) {
> - rz_mtu3_release_channel(ch2);
> - rz_mtu3_release_channel(ch1);
> rz_mtu3_disable(ch2);
> rz_mtu3_disable(ch1);
> + rz_mtu3_release_channel(ch2);
> + rz_mtu3_release_channel(ch1);
> } else {
> - rz_mtu3_release_channel(ch);
> rz_mtu3_disable(ch);
> + rz_mtu3_release_channel(ch);
> }
> }
>
> --
> 2.56.0