All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] soc: imx: gpcv2: Assert reset before ungating clock
@ 2022-08-02 23:37 Marek Vasut
  2022-08-10  8:31 ` Lucas Stach
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2022-08-02 23:37 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Marek Vasut, Fabio Estevam, Frieder Schrempf, Lucas Stach,
	NXP Linux Team, Peng Fan, Shawn Guo

In case the power domain clock are ungated before the reset is asserted,
the system might freeze completely. This is likely due to a device is an
undefined state being attached to bus, which sporadically leads to a bus
hang. Assert the reset before the clock are enabled to assure the device
is in defined state before being attached to bus.

Fixes: fe58c887fb8ca ("soc: imx: gpcv2: add support for optional resets")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Shawn Guo <shawnguo@kernel.org>
To: linux-arm-kernel@lists.infradead.org
---
V2: - Always assert the reset before enabling clock
    - Update commit message
    - Add Fixes tag
---
 drivers/soc/imx/gpcv2.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
index 85aa86e1338af..f38a4420e94a6 100644
--- a/drivers/soc/imx/gpcv2.c
+++ b/drivers/soc/imx/gpcv2.c
@@ -333,6 +333,11 @@ static int imx_pgc_power_up(struct generic_pm_domain *genpd)
 		}
 	}
 
+	reset_control_assert(domain->reset);
+
+	/* delays for reset to propagate */
+	udelay(5);
+
 	/* Enable reset clocks for all devices in the domain */
 	ret = clk_bulk_prepare_enable(domain->num_clks, domain->clks);
 	if (ret) {
@@ -340,8 +345,6 @@ static int imx_pgc_power_up(struct generic_pm_domain *genpd)
 		goto out_regulator_disable;
 	}
 
-	reset_control_assert(domain->reset);
-
 	if (domain->bits.pxx) {
 		/* request the domain to power up */
 		regmap_update_bits(domain->regmap, domain->regs->pup,
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2] soc: imx: gpcv2: Assert reset before ungating clock
  2022-08-02 23:37 [PATCH v2] soc: imx: gpcv2: Assert reset before ungating clock Marek Vasut
@ 2022-08-10  8:31 ` Lucas Stach
  0 siblings, 0 replies; 2+ messages in thread
From: Lucas Stach @ 2022-08-10  8:31 UTC (permalink / raw)
  To: Marek Vasut, linux-arm-kernel
  Cc: Fabio Estevam, Frieder Schrempf, NXP Linux Team, Peng Fan, Shawn Guo

Am Mittwoch, dem 03.08.2022 um 01:37 +0200 schrieb Marek Vasut:
> In case the power domain clock are ungated before the reset is asserted,
> the system might freeze completely. This is likely due to a device is an
> undefined state being attached to bus, which sporadically leads to a bus
> hang. Assert the reset before the clock are enabled to assure the device
> is in defined state before being attached to bus.
> 
> Fixes: fe58c887fb8ca ("soc: imx: gpcv2: add support for optional resets")
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Fabio Estevam <festevam@denx.de>
> Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Cc: NXP Linux Team <linux-imx@nxp.com>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Shawn Guo <shawnguo@kernel.org>
> To: linux-arm-kernel@lists.infradead.org
> ---
> V2: - Always assert the reset before enabling clock
>     - Update commit message
>     - Add Fixes tag
> ---
>  drivers/soc/imx/gpcv2.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
> index 85aa86e1338af..f38a4420e94a6 100644
> --- a/drivers/soc/imx/gpcv2.c
> +++ b/drivers/soc/imx/gpcv2.c
> @@ -333,6 +333,11 @@ static int imx_pgc_power_up(struct generic_pm_domain *genpd)
>  		}
>  	}
>  
> +	reset_control_assert(domain->reset);
> +
> +	/* delays for reset to propagate */
> +	udelay(5);
> +
Most peripheral resets in the i.MX are synchronous, so they won't
propagate without the clocks being enabled. If this delay is really
necessary, it should be placed after the clock enable below.

Regards,
Lucas

>  	/* Enable reset clocks for all devices in the domain */
>  	ret = clk_bulk_prepare_enable(domain->num_clks, domain->clks);
>  	if (ret) {
> @@ -340,8 +345,6 @@ static int imx_pgc_power_up(struct generic_pm_domain *genpd)
>  		goto out_regulator_disable;
>  	}
>  
> -	reset_control_assert(domain->reset);
> -
>  	if (domain->bits.pxx) {
>  		/* request the domain to power up */
>  		regmap_update_bits(domain->regmap, domain->regs->pup,



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-08-10  8:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 23:37 [PATCH v2] soc: imx: gpcv2: Assert reset before ungating clock Marek Vasut
2022-08-10  8:31 ` Lucas Stach

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.