regulator: avoid deadlock when disabling regulator with supply
authorJeffrey Carlyle <jeff.carlyle@motorola.com>
Fri, 8 Oct 2010 19:49:19 +0000 (14:49 -0500)
committerLiam Girdwood <lrg@slimlogic.co.uk>
Thu, 28 Oct 2010 21:40:31 +0000 (22:40 +0100)
commit8cbf811dfd027bde8504e541d0009c5722b98be5
tree0f7190a0c3680485ad7893a36d37967ae8f3c526
parent688fe99a439f7c9dfcc52fbf7cb347f140a2dc8b
regulator: avoid deadlock when disabling regulator with supply

I have a regulator A that sets regulator B as its supply. When I call
set_supply to add B as the supply for A, regulator A gets added to the
supply_list for regulator B.

When I call regulator_disable(A), I end up with a call chain like this:

regulator_disable(A)
> mutex_lock(A)
> _regulator_disable(A)
>> _regulator_disable(B)
>>> _notifier_call_chain(B)
>>>> mutex_lock(A)

Which results in dead lock since we are trying to acquire the mutex lock
for regulator A which we already hold.

This patch addresses this issue by moving the call to disable regulator
B outside of the lock aquired inside the initial call to
regulator_disable.

This change also addresses the issue of not acquiring the mutex for
regulator B before calling _regulator_disable(B).

Signed-off-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
drivers/regulator/core.c