Re: [PATCH AUTOSEL for 4.15 104/124] clk: fix reentrancy of clk_enable() on UP systems
On Mon, Mar 19, 2018 at 10:55:16AM -0500, David Lechner wrote: >On 03/19/2018 10:48 AM, Sasha Levin wrote: >>From: David Lechner>> >>[ Upstream commit a12aa8a68dfef5de181f2e555aa950a0ab05411f ] >> >>Reentrant calls to clk_enable() are not working on UP systems. This is >>caused by the fact spin_trylock_irqsave() always returns true when >>CONFIG_SMP=n (and CONFIG_DEBUG_SPINLOCK=n) which causes the reference >>counting to not work correctly when clk_enable_lock() is called twice >>before clk_enable_unlock() is called (this happens when clk_enable() >>is called from within another clk_enable()). >> >>This fixes the problem by skipping the call to spin_trylock_irqsave() on UP >>systems and relying solely on reference counting. We also make sure to set >>flags in this case so that we are not returning an uninitialized value. >> >>Suggested-by: Stephen Boyd >>Signed-off-by: David Lechner >>Signed-off-by: Stephen Boyd >>Signed-off-by: Sasha Levin >>--- > >I don't know of any existing bugs in v4.15 that this fixes, so I don't >think this really fits the criteria for stable. > Now removed, thanks!
Re: [PATCH AUTOSEL for 4.15 104/124] clk: fix reentrancy of clk_enable() on UP systems
On Mon, Mar 19, 2018 at 10:55:16AM -0500, David Lechner wrote: >On 03/19/2018 10:48 AM, Sasha Levin wrote: >>From: David Lechner >> >>[ Upstream commit a12aa8a68dfef5de181f2e555aa950a0ab05411f ] >> >>Reentrant calls to clk_enable() are not working on UP systems. This is >>caused by the fact spin_trylock_irqsave() always returns true when >>CONFIG_SMP=n (and CONFIG_DEBUG_SPINLOCK=n) which causes the reference >>counting to not work correctly when clk_enable_lock() is called twice >>before clk_enable_unlock() is called (this happens when clk_enable() >>is called from within another clk_enable()). >> >>This fixes the problem by skipping the call to spin_trylock_irqsave() on UP >>systems and relying solely on reference counting. We also make sure to set >>flags in this case so that we are not returning an uninitialized value. >> >>Suggested-by: Stephen Boyd >>Signed-off-by: David Lechner >>Signed-off-by: Stephen Boyd >>Signed-off-by: Sasha Levin >>--- > >I don't know of any existing bugs in v4.15 that this fixes, so I don't >think this really fits the criteria for stable. > Now removed, thanks!
[PATCH AUTOSEL for 4.15 104/124] clk: fix reentrancy of clk_enable() on UP systems
From: David Lechner[ Upstream commit a12aa8a68dfef5de181f2e555aa950a0ab05411f ] Reentrant calls to clk_enable() are not working on UP systems. This is caused by the fact spin_trylock_irqsave() always returns true when CONFIG_SMP=n (and CONFIG_DEBUG_SPINLOCK=n) which causes the reference counting to not work correctly when clk_enable_lock() is called twice before clk_enable_unlock() is called (this happens when clk_enable() is called from within another clk_enable()). This fixes the problem by skipping the call to spin_trylock_irqsave() on UP systems and relying solely on reference counting. We also make sure to set flags in this case so that we are not returning an uninitialized value. Suggested-by: Stephen Boyd Signed-off-by: David Lechner Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/clk.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b56c11f51baf..a6575359de58 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -141,10 +141,18 @@ static unsigned long clk_enable_lock(void) { unsigned long flags; - if (!spin_trylock_irqsave(_lock, flags)) { + /* +* On UP systems, spin_trylock_irqsave() always returns true, even if +* we already hold the lock. So, in that case, we rely only on +* reference counting. +*/ + if (!IS_ENABLED(CONFIG_SMP) || + !spin_trylock_irqsave(_lock, flags)) { if (enable_owner == current) { enable_refcnt++; __acquire(enable_lock); + if (!IS_ENABLED(CONFIG_SMP)) + local_save_flags(flags); return flags; } spin_lock_irqsave(_lock, flags); -- 2.14.1
[PATCH AUTOSEL for 4.15 104/124] clk: fix reentrancy of clk_enable() on UP systems
From: David Lechner [ Upstream commit a12aa8a68dfef5de181f2e555aa950a0ab05411f ] Reentrant calls to clk_enable() are not working on UP systems. This is caused by the fact spin_trylock_irqsave() always returns true when CONFIG_SMP=n (and CONFIG_DEBUG_SPINLOCK=n) which causes the reference counting to not work correctly when clk_enable_lock() is called twice before clk_enable_unlock() is called (this happens when clk_enable() is called from within another clk_enable()). This fixes the problem by skipping the call to spin_trylock_irqsave() on UP systems and relying solely on reference counting. We also make sure to set flags in this case so that we are not returning an uninitialized value. Suggested-by: Stephen Boyd Signed-off-by: David Lechner Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/clk.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b56c11f51baf..a6575359de58 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -141,10 +141,18 @@ static unsigned long clk_enable_lock(void) { unsigned long flags; - if (!spin_trylock_irqsave(_lock, flags)) { + /* +* On UP systems, spin_trylock_irqsave() always returns true, even if +* we already hold the lock. So, in that case, we rely only on +* reference counting. +*/ + if (!IS_ENABLED(CONFIG_SMP) || + !spin_trylock_irqsave(_lock, flags)) { if (enable_owner == current) { enable_refcnt++; __acquire(enable_lock); + if (!IS_ENABLED(CONFIG_SMP)) + local_save_flags(flags); return flags; } spin_lock_irqsave(_lock, flags); -- 2.14.1
Re: [PATCH AUTOSEL for 4.15 104/124] clk: fix reentrancy of clk_enable() on UP systems
On 03/19/2018 10:48 AM, Sasha Levin wrote: From: David Lechner[ Upstream commit a12aa8a68dfef5de181f2e555aa950a0ab05411f ] Reentrant calls to clk_enable() are not working on UP systems. This is caused by the fact spin_trylock_irqsave() always returns true when CONFIG_SMP=n (and CONFIG_DEBUG_SPINLOCK=n) which causes the reference counting to not work correctly when clk_enable_lock() is called twice before clk_enable_unlock() is called (this happens when clk_enable() is called from within another clk_enable()). This fixes the problem by skipping the call to spin_trylock_irqsave() on UP systems and relying solely on reference counting. We also make sure to set flags in this case so that we are not returning an uninitialized value. Suggested-by: Stephen Boyd Signed-off-by: David Lechner Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- I don't know of any existing bugs in v4.15 that this fixes, so I don't think this really fits the criteria for stable.
Re: [PATCH AUTOSEL for 4.15 104/124] clk: fix reentrancy of clk_enable() on UP systems
On 03/19/2018 10:48 AM, Sasha Levin wrote: From: David Lechner [ Upstream commit a12aa8a68dfef5de181f2e555aa950a0ab05411f ] Reentrant calls to clk_enable() are not working on UP systems. This is caused by the fact spin_trylock_irqsave() always returns true when CONFIG_SMP=n (and CONFIG_DEBUG_SPINLOCK=n) which causes the reference counting to not work correctly when clk_enable_lock() is called twice before clk_enable_unlock() is called (this happens when clk_enable() is called from within another clk_enable()). This fixes the problem by skipping the call to spin_trylock_irqsave() on UP systems and relying solely on reference counting. We also make sure to set flags in this case so that we are not returning an uninitialized value. Suggested-by: Stephen Boyd Signed-off-by: David Lechner Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- I don't know of any existing bugs in v4.15 that this fixes, so I don't think this really fits the criteria for stable.
Re: [PATCH AUTOSEL for 4.15 104/124] clk: fix reentrancy of clk_enable() on UP systems
On Mon, Mar 19, 2018 at 10:55:16AM -0500, David Lechner wrote: >On 03/19/2018 10:48 AM, Sasha Levin wrote: >>From: David Lechner>> >>[ Upstream commit a12aa8a68dfef5de181f2e555aa950a0ab05411f ] >> >>Reentrant calls to clk_enable() are not working on UP systems. This is >>caused by the fact spin_trylock_irqsave() always returns true when >>CONFIG_SMP=n (and CONFIG_DEBUG_SPINLOCK=n) which causes the reference >>counting to not work correctly when clk_enable_lock() is called twice >>before clk_enable_unlock() is called (this happens when clk_enable() >>is called from within another clk_enable()). >> >>This fixes the problem by skipping the call to spin_trylock_irqsave() on UP >>systems and relying solely on reference counting. We also make sure to set >>flags in this case so that we are not returning an uninitialized value. >> >>Suggested-by: Stephen Boyd >>Signed-off-by: David Lechner >>Signed-off-by: Stephen Boyd >>Signed-off-by: Sasha Levin >>--- > >I don't know of any existing bugs in v4.15 that this fixes, so I don't >think this really fits the criteria for stable. > I'll remove it, thanks David! -- Thanks, Sasha
Re: [PATCH AUTOSEL for 4.15 104/124] clk: fix reentrancy of clk_enable() on UP systems
On Mon, Mar 19, 2018 at 10:55:16AM -0500, David Lechner wrote: >On 03/19/2018 10:48 AM, Sasha Levin wrote: >>From: David Lechner >> >>[ Upstream commit a12aa8a68dfef5de181f2e555aa950a0ab05411f ] >> >>Reentrant calls to clk_enable() are not working on UP systems. This is >>caused by the fact spin_trylock_irqsave() always returns true when >>CONFIG_SMP=n (and CONFIG_DEBUG_SPINLOCK=n) which causes the reference >>counting to not work correctly when clk_enable_lock() is called twice >>before clk_enable_unlock() is called (this happens when clk_enable() >>is called from within another clk_enable()). >> >>This fixes the problem by skipping the call to spin_trylock_irqsave() on UP >>systems and relying solely on reference counting. We also make sure to set >>flags in this case so that we are not returning an uninitialized value. >> >>Suggested-by: Stephen Boyd >>Signed-off-by: David Lechner >>Signed-off-by: Stephen Boyd >>Signed-off-by: Sasha Levin >>--- > >I don't know of any existing bugs in v4.15 that this fixes, so I don't >think this really fits the criteria for stable. > I'll remove it, thanks David! -- Thanks, Sasha