regulator: qcom_pm8008-regulator: Avoid deadlock in OCP handling
For handling OCP events in PM8008, the PM8008 driver will acquire the
chip-level regulator's mutex and then the affected LDO's regulator
mutex, as part of the call flow, needed for calling
regulator_notifier_call_chain twice. This could lead to a deadlock if
any PM8008 LDO client also tries to enable the affected LDO at the same
time.
Thread 1: Camera trying to enable a PM8008 LDO
[<ffffff9bb5ecebac>] mutex_lock+0x54 (en_supply regulator mutex, taken in below thread)
[<ffffff9bb50912b8>] regulator_disable+0x30
[<ffffff9bb50a0ad4>] pm8008_regulator_enable+0x26c
[<ffffff9bb5096cfc>] _regulator_do_enable+0x25c
[<ffffff9bb5091228>] regulator_enable+0x168 (PM8008 regulator mutex acquired)
Thread 2: OCP IRQ trigger and handling
[<ffffff9bb5ecebac>] mutex_lock+0x54 (PM8008 regulator mutex, taken in above thread)
[<ffffff9bb50a0450>] pm8008_ldo_cb+0x170
[<ffffff9bb4af7270>] blocking_notifier_call_chain+0x90
[<ffffff9bb5094448>] regulator_notifier_call_chain+0x30
[<ffffff9bb50a15e0>] pm8008_ocp_irq+0x30 (en_supply regulator mutex acquired)
To avoid this race condition, move the second call to
regulator_notifier_call_chain along with the acquisition of the
LDO regulator mutex into a queued work task, to avoid the OCP handling
thread holding both mutexes simultaneously.
Change-Id: I649bfdc5cfd1d7bf84e6538cf91df6898adb90a0
Signed-off-by:
Jishnu Prakash <quic_jprakash@quicinc.com>
Loading
Please register or sign in to comment