[PATCH] clk: renesas: cpg-mssr: Unlock before reset verification

Prabhakar posted 1 patch 1 month ago
drivers/clk/renesas/renesas-cpg-mssr.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH] clk: renesas: cpg-mssr: Unlock before reset verification
Posted by Prabhakar 1 month ago
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Move spin_unlock_irqrestore() before verifying the reset result and
printing errors. The verification condition only uses local variables
and does not require locking.

Reported-by: Pavel Machek <pavel@nabladev.com>
Closes: https://lore.kernel.org/all/aVujAQJSDn6WyORK@duo.ucw.cz/
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/clk/renesas/renesas-cpg-mssr.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c
index 35cb49763014..a6df0d2538c7 100644
--- a/drivers/clk/renesas/renesas-cpg-mssr.c
+++ b/drivers/clk/renesas/renesas-cpg-mssr.c
@@ -806,14 +806,12 @@ static int cpg_mrcr_set_reset_state(struct reset_controller_dev *rcdev,
 
 	/* Verify the operation */
 	val = readl(reg_addr);
+	spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);
 	if (set == !(bitmask & val)) {
 		dev_err(priv->dev, "Reset register %u%02u operation failed\n", reg, bit);
-		spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);
 		return -EIO;
 	}
 
-	spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);
-
 	return 0;
 }
 
-- 
2.52.0
Re: [PATCH] clk: renesas: cpg-mssr: Unlock before reset verification
Posted by Geert Uytterhoeven 1 month ago
On Mon, 5 Jan 2026 at 15:06, Prabhakar <prabhakar.csengg@gmail.com> wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Move spin_unlock_irqrestore() before verifying the reset result and
> printing errors. The verification condition only uses local variables
> and does not require locking.
>
> Reported-by: Pavel Machek <pavel@nabladev.com>
> Closes: https://lore.kernel.org/all/aVujAQJSDn6WyORK@duo.ucw.cz/
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-clk for v6.20.

> --- a/drivers/clk/renesas/renesas-cpg-mssr.c
> +++ b/drivers/clk/renesas/renesas-cpg-mssr.c
> @@ -806,14 +806,12 @@ static int cpg_mrcr_set_reset_state(struct reset_controller_dev *rcdev,
>
>         /* Verify the operation */
>         val = readl(reg_addr);
> +       spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);

I will surround this by blank lines while applying.

>         if (set == !(bitmask & val)) {
>                 dev_err(priv->dev, "Reset register %u%02u operation failed\n", reg, bit);
> -               spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);
>                 return -EIO;
>         }
>
> -       spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);
> -
>         return 0;
>  }

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Re: [PATCH] clk: renesas: cpg-mssr: Unlock before reset verification
Posted by Lad, Prabhakar 1 month ago
Hi Geert,

On Wed, Jan 7, 2026 at 4:16 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> On Mon, 5 Jan 2026 at 15:06, Prabhakar <prabhakar.csengg@gmail.com> wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > Move spin_unlock_irqrestore() before verifying the reset result and
> > printing errors. The verification condition only uses local variables
> > and does not require locking.
> >
> > Reported-by: Pavel Machek <pavel@nabladev.com>
> > Closes: https://lore.kernel.org/all/aVujAQJSDn6WyORK@duo.ucw.cz/
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> i.e. will queue in renesas-clk for v6.20.
>
> > --- a/drivers/clk/renesas/renesas-cpg-mssr.c
> > +++ b/drivers/clk/renesas/renesas-cpg-mssr.c
> > @@ -806,14 +806,12 @@ static int cpg_mrcr_set_reset_state(struct reset_controller_dev *rcdev,
> >
> >         /* Verify the operation */
> >         val = readl(reg_addr);
> > +       spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);
>
> I will surround this by blank lines while applying.
>
Makes sense, thank you for taking care of it.

Cheers,
Prabhakar

> >         if (set == !(bitmask & val)) {
> >                 dev_err(priv->dev, "Reset register %u%02u operation failed\n", reg, bit);
> > -               spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);
> >                 return -EIO;
> >         }
> >
> > -       spin_unlock_irqrestore(&priv->pub.rmw_lock, flags);
> > -
> >         return 0;
> >  }
>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds