All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: fix critical clock locking
@ 2016-05-13  8:00 Maxime Ripard
  2016-05-17 12:25 ` Heiko Stuebner
  2016-05-19 21:10 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Maxime Ripard @ 2016-05-13  8:00 UTC (permalink / raw
  To: Mike Turquette, Stephen Boyd; +Cc: linux-clk, Maxime Ripard

The critical clock handling in __clk_core_init isn't taking the enable lock
before calling clk_core_enable, which in turns triggers the warning in the
lockdep_assert_held call in that function when lockep is enabled.

Add the calls to clk_enable_lock/unlock to make sure it doesn't happen.

Fixes: 32b9b1096186 ("clk: Allow clocks to be marked as CRITICAL")
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

---
Changes from v1:
  - Removed the redundant prepare lock

 drivers/clk/clk.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ce39add5a258..d584004f7af7 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2404,8 +2404,13 @@ static int __clk_core_init(struct clk_core *core)
 		core->ops->init(core->hw);
 
 	if (core->flags & CLK_IS_CRITICAL) {
+		unsigned long flags;
+
 		clk_core_prepare(core);
+
+		flags = clk_enable_lock();
 		clk_core_enable(core);
+		clk_enable_unlock(flags);
 	}
 
 	kref_init(&core->ref);
-- 
2.8.2

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

* Re: [PATCH] clk: fix critical clock locking
  2016-05-13  8:00 [PATCH] clk: fix critical clock locking Maxime Ripard
@ 2016-05-17 12:25 ` Heiko Stuebner
  2016-05-19 21:10 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Heiko Stuebner @ 2016-05-17 12:25 UTC (permalink / raw
  To: Maxime Ripard; +Cc: Mike Turquette, Stephen Boyd, linux-clk

Am Freitag, 13. Mai 2016, 10:00:31 schrieb Maxime Ripard:
> The critical clock handling in __clk_core_init isn't taking the enable
> lock before calling clk_core_enable, which in turns triggers the warning
> in the lockdep_assert_held call in that function when lockep is enabled.
> 
> Add the calls to clk_enable_lock/unlock to make sure it doesn't happen.
> 
> Fixes: 32b9b1096186 ("clk: Allow clocks to be marked as CRITICAL")
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

ran into this issue today as well and doing the same fix before trying to 
look at the lists, so on a rk3288-veyron

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Heiko Stuebner <heiko@sntech.de>


one nit below

> ---
> Changes from v1:
>   - Removed the redundant prepare lock
> 
>  drivers/clk/clk.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index ce39add5a258..d584004f7af7 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2404,8 +2404,13 @@ static int __clk_core_init(struct clk_core *core)
>  		core->ops->init(core->hw);
> 
>  	if (core->flags & CLK_IS_CRITICAL) {
> +		unsigned long flags;
> +
>  		clk_core_prepare(core);
> +

nit: all other invocations of both clk_core_prepare/clk_core_enable in clk.c 
(__clk_set_parent_before, __clk_set_parent_after, clk_change_rate) do it 
like 
	clk_core_prepare(core);
	flags = clk_enable_lock();
	clk_core_enable(core);
	clk_enable_unlock(flags);

aka without the blank. Might be nice to standardize on one format.


> +		flags = clk_enable_lock();
>  		clk_core_enable(core);
> +		clk_enable_unlock(flags);
>  	}
> 
>  	kref_init(&core->ref);

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

* Re: [PATCH] clk: fix critical clock locking
  2016-05-13  8:00 [PATCH] clk: fix critical clock locking Maxime Ripard
  2016-05-17 12:25 ` Heiko Stuebner
@ 2016-05-19 21:10 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2016-05-19 21:10 UTC (permalink / raw
  To: Maxime Ripard; +Cc: Mike Turquette, linux-clk

On 05/13, Maxime Ripard wrote:
> The critical clock handling in __clk_core_init isn't taking the enable lock
> before calling clk_core_enable, which in turns triggers the warning in the
> lockdep_assert_held call in that function when lockep is enabled.
> 
> Add the calls to clk_enable_lock/unlock to make sure it doesn't happen.
> 
> Fixes: 32b9b1096186 ("clk: Allow clocks to be marked as CRITICAL")
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> 
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

end of thread, other threads:[~2016-05-19 21:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-13  8:00 [PATCH] clk: fix critical clock locking Maxime Ripard
2016-05-17 12:25 ` Heiko Stuebner
2016-05-19 21:10 ` Stephen Boyd

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.