• Jeffrey Carlyle's avatar
    regulator: avoid deadlock when disabling regulator with supply · 8cbf811d
    Jeffrey Carlyle authored
    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: default avatarJeffrey Carlyle <jeff.carlyle@motorola.com>
    Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
    Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
    8cbf811d
core.c 68.2 KB