linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: at91: fix possible dead lock in new drivers
@ 2020-07-03  7:32 Ahmad Fatoum
  2020-07-03  8:58 ` Alexandre Belloni
  2020-07-24  9:25 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2020-07-03  7:32 UTC (permalink / raw)
  To: Nicolas Ferre, Alexandre Belloni, Ludovic Desroches, Stephen Boyd
  Cc: kernel, Ahmad Fatoum, Michael Turquette, linux-clk,
	linux-arm-kernel, linux-kernel

syscon_node_to_regmap() will make the created regmap get and enable the
first clock it can parse from the device tree. This clock is not needed to
access the registers and should not be enabled at that time.

Use device_node_to_regmap to resolve this as it looks up the regmap in
the same list but doesn't care about the clocks. This issue is detected
by lockdep when booting the sama5d3 with a device tree containing the
new clk bindings.

This fix already happened in 6956eb33abb5 ("clk: at91: fix possible
deadlock") for the drivers that had been migrated to the new clk binding
back then. This does the same for the new drivers as well.

Fixes: 01e2113de9a5 ("clk: at91: add sam9x60 pmc driver")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Only boot tested on the sama5d3.
---
 drivers/clk/at91/at91sam9g45.c | 2 +-
 drivers/clk/at91/at91sam9n12.c | 2 +-
 drivers/clk/at91/sam9x60.c     | 2 +-
 drivers/clk/at91/sama5d3.c     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/at91/at91sam9g45.c b/drivers/clk/at91/at91sam9g45.c
index 9873b583c260..fe9d391adeba 100644
--- a/drivers/clk/at91/at91sam9g45.c
+++ b/drivers/clk/at91/at91sam9g45.c
@@ -111,7 +111,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
 		return;
 	mainxtal_name = of_clk_get_parent_name(np, i);
 
-	regmap = syscon_node_to_regmap(np);
+	regmap = device_node_to_regmap(np);
 	if (IS_ERR(regmap))
 		return;
 
diff --git a/drivers/clk/at91/at91sam9n12.c b/drivers/clk/at91/at91sam9n12.c
index 630dc5d87171..4aa97e672bd6 100644
--- a/drivers/clk/at91/at91sam9n12.c
+++ b/drivers/clk/at91/at91sam9n12.c
@@ -124,7 +124,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
 		return;
 	mainxtal_name = of_clk_get_parent_name(np, i);
 
-	regmap = syscon_node_to_regmap(np);
+	regmap = device_node_to_regmap(np);
 	if (IS_ERR(regmap))
 		return;
 
diff --git a/drivers/clk/at91/sam9x60.c b/drivers/clk/at91/sam9x60.c
index 3e20aa68259f..2b4c67485eee 100644
--- a/drivers/clk/at91/sam9x60.c
+++ b/drivers/clk/at91/sam9x60.c
@@ -178,7 +178,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
 		return;
 	mainxtal_name = of_clk_get_parent_name(np, i);
 
-	regmap = syscon_node_to_regmap(np);
+	regmap = device_node_to_regmap(np);
 	if (IS_ERR(regmap))
 		return;
 
diff --git a/drivers/clk/at91/sama5d3.c b/drivers/clk/at91/sama5d3.c
index 5e4e44dd4c37..5609b04e6565 100644
--- a/drivers/clk/at91/sama5d3.c
+++ b/drivers/clk/at91/sama5d3.c
@@ -121,7 +121,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np)
 		return;
 	mainxtal_name = of_clk_get_parent_name(np, i);
 
-	regmap = syscon_node_to_regmap(np);
+	regmap = device_node_to_regmap(np);
 	if (IS_ERR(regmap))
 		return;
 
-- 
2.27.0


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

* Re: [PATCH] clk: at91: fix possible dead lock in new drivers
  2020-07-03  7:32 [PATCH] clk: at91: fix possible dead lock in new drivers Ahmad Fatoum
@ 2020-07-03  8:58 ` Alexandre Belloni
  2020-07-24  9:25 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2020-07-03  8:58 UTC (permalink / raw)
  To: Ahmad Fatoum
  Cc: Nicolas Ferre, Ludovic Desroches, Stephen Boyd, kernel,
	Michael Turquette, linux-clk, linux-arm-kernel, linux-kernel

On 03/07/2020 09:32:35+0200, Ahmad Fatoum wrote:
> syscon_node_to_regmap() will make the created regmap get and enable the
> first clock it can parse from the device tree. This clock is not needed to
> access the registers and should not be enabled at that time.
> 
> Use device_node_to_regmap to resolve this as it looks up the regmap in
> the same list but doesn't care about the clocks. This issue is detected
> by lockdep when booting the sama5d3 with a device tree containing the
> new clk bindings.
> 
> This fix already happened in 6956eb33abb5 ("clk: at91: fix possible
> deadlock") for the drivers that had been migrated to the new clk binding
> back then. This does the same for the new drivers as well.
> 
> Fixes: 01e2113de9a5 ("clk: at91: add sam9x60 pmc driver")
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
> Only boot tested on the sama5d3.
> ---
>  drivers/clk/at91/at91sam9g45.c | 2 +-
>  drivers/clk/at91/at91sam9n12.c | 2 +-
>  drivers/clk/at91/sam9x60.c     | 2 +-
>  drivers/clk/at91/sama5d3.c     | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clk/at91/at91sam9g45.c b/drivers/clk/at91/at91sam9g45.c
> index 9873b583c260..fe9d391adeba 100644
> --- a/drivers/clk/at91/at91sam9g45.c
> +++ b/drivers/clk/at91/at91sam9g45.c
> @@ -111,7 +111,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
>  		return;
>  	mainxtal_name = of_clk_get_parent_name(np, i);
>  
> -	regmap = syscon_node_to_regmap(np);
> +	regmap = device_node_to_regmap(np);
>  	if (IS_ERR(regmap))
>  		return;
>  
> diff --git a/drivers/clk/at91/at91sam9n12.c b/drivers/clk/at91/at91sam9n12.c
> index 630dc5d87171..4aa97e672bd6 100644
> --- a/drivers/clk/at91/at91sam9n12.c
> +++ b/drivers/clk/at91/at91sam9n12.c
> @@ -124,7 +124,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
>  		return;
>  	mainxtal_name = of_clk_get_parent_name(np, i);
>  
> -	regmap = syscon_node_to_regmap(np);
> +	regmap = device_node_to_regmap(np);
>  	if (IS_ERR(regmap))
>  		return;
>  
> diff --git a/drivers/clk/at91/sam9x60.c b/drivers/clk/at91/sam9x60.c
> index 3e20aa68259f..2b4c67485eee 100644
> --- a/drivers/clk/at91/sam9x60.c
> +++ b/drivers/clk/at91/sam9x60.c
> @@ -178,7 +178,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
>  		return;
>  	mainxtal_name = of_clk_get_parent_name(np, i);
>  
> -	regmap = syscon_node_to_regmap(np);
> +	regmap = device_node_to_regmap(np);
>  	if (IS_ERR(regmap))
>  		return;
>  
> diff --git a/drivers/clk/at91/sama5d3.c b/drivers/clk/at91/sama5d3.c
> index 5e4e44dd4c37..5609b04e6565 100644
> --- a/drivers/clk/at91/sama5d3.c
> +++ b/drivers/clk/at91/sama5d3.c
> @@ -121,7 +121,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np)
>  		return;
>  	mainxtal_name = of_clk_get_parent_name(np, i);
>  
> -	regmap = syscon_node_to_regmap(np);
> +	regmap = device_node_to_regmap(np);
>  	if (IS_ERR(regmap))
>  		return;
>  
> -- 
> 2.27.0
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH] clk: at91: fix possible dead lock in new drivers
  2020-07-03  7:32 [PATCH] clk: at91: fix possible dead lock in new drivers Ahmad Fatoum
  2020-07-03  8:58 ` Alexandre Belloni
@ 2020-07-24  9:25 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2020-07-24  9:25 UTC (permalink / raw)
  To: Ahmad Fatoum, Alexandre Belloni, Ludovic Desroches, Nicolas Ferre
  Cc: kernel, Ahmad Fatoum, Michael Turquette, linux-clk,
	linux-arm-kernel, linux-kernel

Quoting Ahmad Fatoum (2020-07-03 00:32:35)
> syscon_node_to_regmap() will make the created regmap get and enable the
> first clock it can parse from the device tree. This clock is not needed to
> access the registers and should not be enabled at that time.
> 
> Use device_node_to_regmap to resolve this as it looks up the regmap in
> the same list but doesn't care about the clocks. This issue is detected
> by lockdep when booting the sama5d3 with a device tree containing the
> new clk bindings.
> 
> This fix already happened in 6956eb33abb5 ("clk: at91: fix possible
> deadlock") for the drivers that had been migrated to the new clk binding
> back then. This does the same for the new drivers as well.
> 
> Fixes: 01e2113de9a5 ("clk: at91: add sam9x60 pmc driver")
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---

Applied to clk-next

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

end of thread, other threads:[~2020-07-24  9:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03  7:32 [PATCH] clk: at91: fix possible dead lock in new drivers Ahmad Fatoum
2020-07-03  8:58 ` Alexandre Belloni
2020-07-24  9:25 ` Stephen Boyd

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).