imx.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: imx: Add some delay before deassert the reset
@ 2025-07-29  3:38 Jacky Bai
  2025-07-30 20:37 ` Frank Li
  0 siblings, 1 reply; 5+ messages in thread
From: Jacky Bai @ 2025-07-29  3:38 UTC (permalink / raw)
  To: abelvesa, peng.fan, mturquette, sboyd, shawnguo, s.hauer
  Cc: kernel, festevam, linux-clk, imx

Some of the PCCs on i.MX8ULP have a sw_rst bit to control
the peripheral reset through SW method. For peripherals like GPU
that need sync reset, some delay is necessary befere & after release
the reset to make sure the HW is reset into a known status. So add
some delay before & after release reset.

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/clk/imx/clk-composite-7ulp.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/clk/imx/clk-composite-7ulp.c b/drivers/clk/imx/clk-composite-7ulp.c
index 8ed2e0ad2769..710fe4f84465 100644
--- a/drivers/clk/imx/clk-composite-7ulp.c
+++ b/drivers/clk/imx/clk-composite-7ulp.c
@@ -7,6 +7,7 @@
 
 #include <linux/bits.h>
 #include <linux/clk-provider.h>
+#include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/slab.h>
@@ -36,6 +37,9 @@ static int pcc_gate_enable(struct clk_hw *hw)
 	if (ret)
 		return ret;
 
+	/* wait before release reset */
+	udelay(1);
+
 	spin_lock_irqsave(gate->lock, flags);
 	/*
 	 * release the sw reset for peripherals associated with
@@ -47,6 +51,9 @@ static int pcc_gate_enable(struct clk_hw *hw)
 
 	spin_unlock_irqrestore(gate->lock, flags);
 
+	/* wait sync reset done */
+	udelay(1);
+
 	return 0;
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: imx: Add some delay before deassert the reset
  2025-07-29  3:38 [PATCH] clk: imx: Add some delay before deassert the reset Jacky Bai
@ 2025-07-30 20:37 ` Frank Li
  2025-07-31  0:39   ` Jacky Bai
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Li @ 2025-07-30 20:37 UTC (permalink / raw)
  To: Jacky Bai
  Cc: abelvesa, peng.fan, mturquette, sboyd, shawnguo, s.hauer, kernel,
	festevam, linux-clk, imx

On Tue, Jul 29, 2025 at 11:38:17AM +0800, Jacky Bai wrote:
> Some of the PCCs on i.MX8ULP have a sw_rst bit to control
> the peripheral reset through SW method. For peripherals like GPU
> that need sync reset, some delay is necessary befere & after release
> the reset to make sure the HW is reset into a known status. So add
> some delay before & after release reset.

Nit: wrap at 75 char.

>
> Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/clk/imx/clk-composite-7ulp.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/clk/imx/clk-composite-7ulp.c b/drivers/clk/imx/clk-composite-7ulp.c
> index 8ed2e0ad2769..710fe4f84465 100644
> --- a/drivers/clk/imx/clk-composite-7ulp.c
> +++ b/drivers/clk/imx/clk-composite-7ulp.c
> @@ -7,6 +7,7 @@
>
>  #include <linux/bits.h>
>  #include <linux/clk-provider.h>
> +#include <linux/delay.h>
>  #include <linux/err.h>
>  #include <linux/io.h>
>  #include <linux/slab.h>
> @@ -36,6 +37,9 @@ static int pcc_gate_enable(struct clk_hw *hw)
>  	if (ret)
>  		return ret;
>
> +	/* wait before release reset */
> +	udelay(1);
> +

It is quite small value. udelay()'s implement is not necessary to access
MMIO register space. (arm64 use cp15)

writel(val, gate->reg);
udelay(1); // it may less than 1us as what you expect, because previous
write have not reach target place yet.

It needs a readl() before udelay(1) to make sure value actually reach to
target place.

Frank

>  	spin_lock_irqsave(gate->lock, flags);
>  	/*
>  	 * release the sw reset for peripherals associated with
> @@ -47,6 +51,9 @@ static int pcc_gate_enable(struct clk_hw *hw)
>
>  	spin_unlock_irqrestore(gate->lock, flags);
>
> +	/* wait sync reset done */
> +	udelay(1);
> +
>  	return 0;
>  }
>
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] clk: imx: Add some delay before deassert the reset
  2025-07-30 20:37 ` Frank Li
@ 2025-07-31  0:39   ` Jacky Bai
  2025-07-31  5:42     ` Daniel Baluta
  0 siblings, 1 reply; 5+ messages in thread
From: Jacky Bai @ 2025-07-31  0:39 UTC (permalink / raw)
  To: Frank Li
  Cc: abelvesa@kernel.org, Peng Fan, mturquette@baylibre.com,
	sboyd@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com,
	linux-clk@vger.kernel.org, imx@lists.linux.dev

> Subject: Re: [PATCH] clk: imx: Add some delay before deassert the reset
> 
> On Tue, Jul 29, 2025 at 11:38:17AM +0800, Jacky Bai wrote:
> > Some of the PCCs on i.MX8ULP have a sw_rst bit to control the
> > peripheral reset through SW method. For peripherals like GPU that need
> > sync reset, some delay is necessary befere & after release the reset
> > to make sure the HW is reset into a known status. So add some delay
> > before & after release reset.
> 
> Nit: wrap at 75 char.

Thx.

> 
> >
> > Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> > Reviewed-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/clk/imx/clk-composite-7ulp.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/clk/imx/clk-composite-7ulp.c
> > b/drivers/clk/imx/clk-composite-7ulp.c
> > index 8ed2e0ad2769..710fe4f84465 100644
> > --- a/drivers/clk/imx/clk-composite-7ulp.c
> > +++ b/drivers/clk/imx/clk-composite-7ulp.c
> > @@ -7,6 +7,7 @@
> >
> >  #include <linux/bits.h>
> >  #include <linux/clk-provider.h>
> > +#include <linux/delay.h>
> >  #include <linux/err.h>
> >  #include <linux/io.h>
> >  #include <linux/slab.h>
> > @@ -36,6 +37,9 @@ static int pcc_gate_enable(struct clk_hw *hw)
> >  	if (ret)
> >  		return ret;
> >
> > +	/* wait before release reset */
> > +	udelay(1);
> > +
> 
> It is quite small value. udelay()'s implement is not necessary to access MMIO
> register space. (arm64 use cp15)
> 

1us should be enough as the GPU IP reset propagation only need 128 cycle
of its own clock(> 200MHz). the first udelay is to add some margin to make
sure the GPU clock is stable.

> writel(val, gate->reg);
> udelay(1); // it may less than 1us as what you expect, because previous write
> have not reach target place yet.
> 
> It needs a readl() before udelay(1) to make sure value actually reach to target
> place.
> 

Sure, will add this.

BR
Jacky Bai

> Frank
> 
> >  	spin_lock_irqsave(gate->lock, flags);
> >  	/*
> >  	 * release the sw reset for peripherals associated with @@ -47,6
> > +51,9 @@ static int pcc_gate_enable(struct clk_hw *hw)
> >
> >  	spin_unlock_irqrestore(gate->lock, flags);
> >
> > +	/* wait sync reset done */
> > +	udelay(1);
> > +
> >  	return 0;
> >  }
> >
> > --
> > 2.34.1
> >

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: imx: Add some delay before deassert the reset
  2025-07-31  0:39   ` Jacky Bai
@ 2025-07-31  5:42     ` Daniel Baluta
  2025-07-31  6:07       ` Jacky Bai
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Baluta @ 2025-07-31  5:42 UTC (permalink / raw)
  To: Jacky Bai
  Cc: Frank Li, abelvesa@kernel.org, Peng Fan, mturquette@baylibre.com,
	sboyd@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com,
	linux-clk@vger.kernel.org, imx@lists.linux.dev

On Thu, Jul 31, 2025 at 3:39 AM Jacky Bai <ping.bai@nxp.com> wrote:
>
> > Subject: Re: [PATCH] clk: imx: Add some delay before deassert the reset
> >
> > On Tue, Jul 29, 2025 at 11:38:17AM +0800, Jacky Bai wrote:
> > > Some of the PCCs on i.MX8ULP have a sw_rst bit to control the
> > > peripheral reset through SW method. For peripherals like GPU that need
> > > sync reset, some delay is necessary befere & after release the reset
> > > to make sure the HW is reset into a known status. So add some delay
> > > before & after release reset.
> >
> > Nit: wrap at 75 char.
>
> Thx.
>
> >
> > >
> > > Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> > > Reviewed-by: Peng Fan <peng.fan@nxp.com>
> > > ---
> > >  drivers/clk/imx/clk-composite-7ulp.c | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > >
> > > diff --git a/drivers/clk/imx/clk-composite-7ulp.c
> > > b/drivers/clk/imx/clk-composite-7ulp.c
> > > index 8ed2e0ad2769..710fe4f84465 100644
> > > --- a/drivers/clk/imx/clk-composite-7ulp.c
> > > +++ b/drivers/clk/imx/clk-composite-7ulp.c
> > > @@ -7,6 +7,7 @@
> > >
> > >  #include <linux/bits.h>
> > >  #include <linux/clk-provider.h>
> > > +#include <linux/delay.h>
> > >  #include <linux/err.h>
> > >  #include <linux/io.h>
> > >  #include <linux/slab.h>
> > > @@ -36,6 +37,9 @@ static int pcc_gate_enable(struct clk_hw *hw)
> > >     if (ret)
> > >             return ret;
> > >
> > > +   /* wait before release reset */
> > > +   udelay(1);
> > > +
> >
> > It is quite small value. udelay()'s implement is not necessary to access MMIO
> > register space. (arm64 use cp15)
> >
>
> 1us should be enough as the GPU IP reset propagation only need 128 cycle
> of its own clock(> 200MHz). the first udelay is to add some margin to make
> sure the GPU clock is stable.
>
> > writel(val, gate->reg);
> > udelay(1); // it may less than 1us as what you expect, because previous write
> > have not reach target place yet.
> >
> > It needs a readl() before udelay(1) to make sure value actually reach to target
> > place.

I think we should capture this explanation in a comment above the udelay.

/* wait before release reset */ doesn't really tell much. We should
explain *why*
a code change is needed. The *what* is obvious from the code.

thanks,
Daniel.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] clk: imx: Add some delay before deassert the reset
  2025-07-31  5:42     ` Daniel Baluta
@ 2025-07-31  6:07       ` Jacky Bai
  0 siblings, 0 replies; 5+ messages in thread
From: Jacky Bai @ 2025-07-31  6:07 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: Frank Li, abelvesa@kernel.org, Peng Fan, mturquette@baylibre.com,
	sboyd@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com,
	linux-clk@vger.kernel.org, imx@lists.linux.dev

> Subject: Re: [PATCH] clk: imx: Add some delay before deassert the reset
> 
> [You don't often get email from daniel.baluta@gmail.com. Learn why this is
> important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> On Thu, Jul 31, 2025 at 3:39 AM Jacky Bai <ping.bai@nxp.com> wrote:
> >
> > > Subject: Re: [PATCH] clk: imx: Add some delay before deassert the
> > > reset
> > >
> > > On Tue, Jul 29, 2025 at 11:38:17AM +0800, Jacky Bai wrote:
> > > > Some of the PCCs on i.MX8ULP have a sw_rst bit to control the
> > > > peripheral reset through SW method. For peripherals like GPU that
> > > > need sync reset, some delay is necessary befere & after release
> > > > the reset to make sure the HW is reset into a known status. So add
> > > > some delay before & after release reset.
> > >
> > > Nit: wrap at 75 char.
> >
> > Thx.
> >
> > >
> > > >
> > > > Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> > > > Reviewed-by: Peng Fan <peng.fan@nxp.com>
> > > > ---
> > > >  drivers/clk/imx/clk-composite-7ulp.c | 7 +++++++
> > > >  1 file changed, 7 insertions(+)
> > > >
> > > > diff --git a/drivers/clk/imx/clk-composite-7ulp.c
> > > > b/drivers/clk/imx/clk-composite-7ulp.c
> > > > index 8ed2e0ad2769..710fe4f84465 100644
> > > > --- a/drivers/clk/imx/clk-composite-7ulp.c
> > > > +++ b/drivers/clk/imx/clk-composite-7ulp.c
> > > > @@ -7,6 +7,7 @@
> > > >
> > > >  #include <linux/bits.h>
> > > >  #include <linux/clk-provider.h>
> > > > +#include <linux/delay.h>
> > > >  #include <linux/err.h>
> > > >  #include <linux/io.h>
> > > >  #include <linux/slab.h>
> > > > @@ -36,6 +37,9 @@ static int pcc_gate_enable(struct clk_hw *hw)
> > > >     if (ret)
> > > >             return ret;
> > > >
> > > > +   /* wait before release reset */
> > > > +   udelay(1);
> > > > +
> > >
> > > It is quite small value. udelay()'s implement is not necessary to
> > > access MMIO register space. (arm64 use cp15)
> > >
> >
> > 1us should be enough as the GPU IP reset propagation only need 128
> > cycle of its own clock(> 200MHz). the first udelay is to add some
> > margin to make sure the GPU clock is stable.
> >
> > > writel(val, gate->reg);
> > > udelay(1); // it may less than 1us as what you expect, because
> > > previous write have not reach target place yet.
> > >
> > > It needs a readl() before udelay(1) to make sure value actually
> > > reach to target place.
> 
> I think we should capture this explanation in a comment above the udelay.
> 
> /* wait before release reset */ doesn't really tell much. We should explain
> *why* a code change is needed. The *what* is obvious from the code.
> 

Thx, will add some more comments for the details.

BR  
> thanks,
> Daniel.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-31  6:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-29  3:38 [PATCH] clk: imx: Add some delay before deassert the reset Jacky Bai
2025-07-30 20:37 ` Frank Li
2025-07-31  0:39   ` Jacky Bai
2025-07-31  5:42     ` Daniel Baluta
2025-07-31  6:07       ` Jacky Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).