Prevent issues during reset deassertion by re-asserting the reset if a
timeout occurs when trying to deassert. This ensures the reset line is in a
known state and improves reliability for hardware that may not immediately
clear the reset monitor bit.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/clk/renesas/rzg2l-cpg.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c
index 1c648c0baf7c..6ed90368cf94 100644
--- a/drivers/clk/renesas/rzg2l-cpg.c
+++ b/drivers/clk/renesas/rzg2l-cpg.c
@@ -1667,9 +1667,16 @@ static int __rzg2l_cpg_assert(struct reset_controller_dev *rcdev,
return 0;
}
- return readl_poll_timeout_atomic(priv->base + reg, value,
- assert ? (value & mask) : !(value & mask),
- 10, 200);
+ ret = readl_poll_timeout_atomic(priv->base + reg, value,
+ assert ? (value & mask) : !(value & mask),
+ 10, 200);
+ if (ret && !assert) {
+ dev_warn(rcdev->dev, "deassert timeout, re-asserting reset id %ld\n", id);
+ value = mask << 16;
+ writel(value, priv->base + CLK_RST_R(info->resets[id].off));
+ }
+
+ return ret;
}
static int rzg2l_cpg_assert(struct reset_controller_dev *rcdev,
--
2.43.0
Hi Tommaso,
On Wed, 20 Aug 2025 at 12:05, Tommaso Merciai
<tommaso.merciai.xr@bp.renesas.com> wrote:
> Prevent issues during reset deassertion by re-asserting the reset if a
> timeout occurs when trying to deassert. This ensures the reset line is in a
> known state and improves reliability for hardware that may not immediately
> clear the reset monitor bit.
>
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Thanks for your patch!
> --- a/drivers/clk/renesas/rzg2l-cpg.c
> +++ b/drivers/clk/renesas/rzg2l-cpg.c
> @@ -1667,9 +1667,16 @@ static int __rzg2l_cpg_assert(struct reset_controller_dev *rcdev,
> return 0;
> }
>
> - return readl_poll_timeout_atomic(priv->base + reg, value,
> - assert ? (value & mask) : !(value & mask),
> - 10, 200);
> + ret = readl_poll_timeout_atomic(priv->base + reg, value,
> + assert ? (value & mask) : !(value & mask),
> + 10, 200);
> + if (ret && !assert) {
> + dev_warn(rcdev->dev, "deassert timeout, re-asserting reset id %ld\n", id);
> + value = mask << 16;
> + writel(value, priv->base + CLK_RST_R(info->resets[id].off));
> + }
Is this an issue you've seen during actual use?
Would it make sense to print warnings on assertion timeouts, too?
> +
> + return ret;
> }
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
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
Hi Geert,
Thank you for your review!
On Tue, Sep 02, 2025 at 02:18:17PM +0200, Geert Uytterhoeven wrote:
> Hi Tommaso,
>
> On Wed, 20 Aug 2025 at 12:05, Tommaso Merciai
> <tommaso.merciai.xr@bp.renesas.com> wrote:
> > Prevent issues during reset deassertion by re-asserting the reset if a
> > timeout occurs when trying to deassert. This ensures the reset line is in a
> > known state and improves reliability for hardware that may not immediately
> > clear the reset monitor bit.
> >
> > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
>
> Thanks for your patch!
>
> > --- a/drivers/clk/renesas/rzg2l-cpg.c
> > +++ b/drivers/clk/renesas/rzg2l-cpg.c
> > @@ -1667,9 +1667,16 @@ static int __rzg2l_cpg_assert(struct reset_controller_dev *rcdev,
> > return 0;
> > }
> >
> > - return readl_poll_timeout_atomic(priv->base + reg, value,
> > - assert ? (value & mask) : !(value & mask),
> > - 10, 200);
> > + ret = readl_poll_timeout_atomic(priv->base + reg, value,
> > + assert ? (value & mask) : !(value & mask),
> > + 10, 200);
> > + if (ret && !assert) {
> > + dev_warn(rcdev->dev, "deassert timeout, re-asserting reset id %ld\n", id);
> > + value = mask << 16;
> > + writel(value, priv->base + CLK_RST_R(info->resets[id].off));
> > + }
>
> Is this an issue you've seen during actual use?
> Would it make sense to print warnings on assertion timeouts, too?
I haven’t observed any assertion timeout issues during actual use,
so maybe printing warnings on assertion may not be necessary.
What do you think?
Thanks & Regards,
Tommaso
>
> > +
> > + return ret;
> > }
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> 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
Hi Tommaso,
On Tue, 2 Sept 2025 at 15:51, Tommaso Merciai
<tommaso.merciai.xr@bp.renesas.com> wrote:
> On Tue, Sep 02, 2025 at 02:18:17PM +0200, Geert Uytterhoeven wrote:
> > On Wed, 20 Aug 2025 at 12:05, Tommaso Merciai
> > <tommaso.merciai.xr@bp.renesas.com> wrote:
> > > Prevent issues during reset deassertion by re-asserting the reset if a
> > > timeout occurs when trying to deassert. This ensures the reset line is in a
> > > known state and improves reliability for hardware that may not immediately
> > > clear the reset monitor bit.
> > >
> > > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> >
> > > --- a/drivers/clk/renesas/rzg2l-cpg.c
> > > +++ b/drivers/clk/renesas/rzg2l-cpg.c
> > > @@ -1667,9 +1667,16 @@ static int __rzg2l_cpg_assert(struct reset_controller_dev *rcdev,
> > > return 0;
> > > }
> > >
> > > - return readl_poll_timeout_atomic(priv->base + reg, value,
> > > - assert ? (value & mask) : !(value & mask),
> > > - 10, 200);
> > > + ret = readl_poll_timeout_atomic(priv->base + reg, value,
> > > + assert ? (value & mask) : !(value & mask),
> > > + 10, 200);
> > > + if (ret && !assert) {
> > > + dev_warn(rcdev->dev, "deassert timeout, re-asserting reset id %ld\n", id);
> > > + value = mask << 16;
> > > + writel(value, priv->base + CLK_RST_R(info->resets[id].off));
> > > + }
> >
> > Is this an issue you've seen during actual use?
> > Would it make sense to print warnings on assertion timeouts, too?
>
> I haven’t observed any assertion timeout issues during actual use,
> so maybe printing warnings on assertion may not be necessary.
> What do you think?
Have you seen deassertion timeouts?
I would rather not print a warning. The error code would be propagated
up anyway.
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
Hi Geert,
On Tue, Sep 02, 2025 at 04:16:12PM +0200, Geert Uytterhoeven wrote:
> Hi Tommaso,
>
> On Tue, 2 Sept 2025 at 15:51, Tommaso Merciai
> <tommaso.merciai.xr@bp.renesas.com> wrote:
> > On Tue, Sep 02, 2025 at 02:18:17PM +0200, Geert Uytterhoeven wrote:
> > > On Wed, 20 Aug 2025 at 12:05, Tommaso Merciai
> > > <tommaso.merciai.xr@bp.renesas.com> wrote:
> > > > Prevent issues during reset deassertion by re-asserting the reset if a
> > > > timeout occurs when trying to deassert. This ensures the reset line is in a
> > > > known state and improves reliability for hardware that may not immediately
> > > > clear the reset monitor bit.
> > > >
> > > > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> > >
> > > > --- a/drivers/clk/renesas/rzg2l-cpg.c
> > > > +++ b/drivers/clk/renesas/rzg2l-cpg.c
> > > > @@ -1667,9 +1667,16 @@ static int __rzg2l_cpg_assert(struct reset_controller_dev *rcdev,
> > > > return 0;
> > > > }
> > > >
> > > > - return readl_poll_timeout_atomic(priv->base + reg, value,
> > > > - assert ? (value & mask) : !(value & mask),
> > > > - 10, 200);
> > > > + ret = readl_poll_timeout_atomic(priv->base + reg, value,
> > > > + assert ? (value & mask) : !(value & mask),
> > > > + 10, 200);
> > > > + if (ret && !assert) {
> > > > + dev_warn(rcdev->dev, "deassert timeout, re-asserting reset id %ld\n", id);
> > > > + value = mask << 16;
> > > > + writel(value, priv->base + CLK_RST_R(info->resets[id].off));
> > > > + }
> > >
> > > Is this an issue you've seen during actual use?
> > > Would it make sense to print warnings on assertion timeouts, too?
> >
> > I haven’t observed any assertion timeout issues during actual use,
> > so maybe printing warnings on assertion may not be necessary.
> > What do you think?
>
> Have you seen deassertion timeouts?
I haven’t seen any deassertion timeouts either.
> I would rather not print a warning. The error code would be propagated
> up anyway.
If for you is ok.
I will drop dev_warn() on both:
- __rzg2l_cpg_assert()
- __rzv2h_cpg_assert()
in v2.
Please gently le me know.
Thanks & Regards,
Tommaso
>
> 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
>
Hi Tommaso,
On Tue, 2 Sept 2025 at 16:26, Tommaso Merciai
<tommaso.merciai.xr@bp.renesas.com> wrote:
> On Tue, Sep 02, 2025 at 04:16:12PM +0200, Geert Uytterhoeven wrote:
> > On Tue, 2 Sept 2025 at 15:51, Tommaso Merciai
> > <tommaso.merciai.xr@bp.renesas.com> wrote:
> > > On Tue, Sep 02, 2025 at 02:18:17PM +0200, Geert Uytterhoeven wrote:
> > > > On Wed, 20 Aug 2025 at 12:05, Tommaso Merciai
> > > > <tommaso.merciai.xr@bp.renesas.com> wrote:
> > > > > Prevent issues during reset deassertion by re-asserting the reset if a
> > > > > timeout occurs when trying to deassert. This ensures the reset line is in a
> > > > > known state and improves reliability for hardware that may not immediately
> > > > > clear the reset monitor bit.
> > > > >
> > > > > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> > > >
> > > > > --- a/drivers/clk/renesas/rzg2l-cpg.c
> > > > > +++ b/drivers/clk/renesas/rzg2l-cpg.c
> > > > > @@ -1667,9 +1667,16 @@ static int __rzg2l_cpg_assert(struct reset_controller_dev *rcdev,
> > > > > return 0;
> > > > > }
> > > > >
> > > > > - return readl_poll_timeout_atomic(priv->base + reg, value,
> > > > > - assert ? (value & mask) : !(value & mask),
> > > > > - 10, 200);
> > > > > + ret = readl_poll_timeout_atomic(priv->base + reg, value,
> > > > > + assert ? (value & mask) : !(value & mask),
> > > > > + 10, 200);
> > > > > + if (ret && !assert) {
> > > > > + dev_warn(rcdev->dev, "deassert timeout, re-asserting reset id %ld\n", id);
> > > > > + value = mask << 16;
> > > > > + writel(value, priv->base + CLK_RST_R(info->resets[id].off));
> > > > > + }
> > > >
> > > > Is this an issue you've seen during actual use?
> > > > Would it make sense to print warnings on assertion timeouts, too?
> > >
> > > I haven’t observed any assertion timeout issues during actual use,
> > > so maybe printing warnings on assertion may not be necessary.
> > > What do you think?
> >
> > Have you seen deassertion timeouts?
>
> I haven’t seen any deassertion timeouts either.
>
> > I would rather not print a warning. The error code would be propagated
> > up anyway.
>
> If for you is ok.
> I will drop dev_warn() on both:
>
> - __rzg2l_cpg_assert()
> - __rzv2h_cpg_assert()
>
> in v2.
> Please gently le me know.
Please drop dev_warn() on both. Thanks!
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
© 2016 - 2026 Red Hat, Inc.