]> git.baikalelectronics.ru Git - kernel.git/commit
clk: fix reentrancy of clk_enable() on UP systems
authorDavid Lechner <david@lechnology.com>
Fri, 5 Jan 2018 01:46:08 +0000 (19:46 -0600)
committerStephen Boyd <sboyd@codeaurora.org>
Wed, 10 Jan 2018 21:39:31 +0000 (13:39 -0800)
commit2b8f115cedd3d6317929a911ee7cf8b0cf6c89a1
treef2faf66b671c503e15028be86a07e70f63767f96
parentf9e9d4ede33f20ad238fc11db0232eaede684940
clk: fix reentrancy of clk_enable() on UP systems

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 <sboyd@codeaurora.org>
Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
drivers/clk/clk.c