Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit a947a2fa authored by Stephen Boyd's avatar Stephen Boyd
Browse files

hwmon: qpnp-adc: Initialize adc mutex in each driver



The qpnp adc drivers take different mutex locks one after the
other but lockdep can't figure that out because each mutex is
intialized with one call to mutex_init() in
qpnp_adc_get_devicetree_data(). Move the mutex initialization to
each caller so that lockdep can see different lock classes for
each adc mutex. This silences the below recursive mutex warning.

=============================================
[ INFO: possible recursive locking detected ]
3.4.0-gc11e688-00030-g8f5e269-dirty #567 Tainted: G        W
---------------------------------------------
kworker/u:2/21 is trying to acquire lock:
 (&adc_qpnp->adc_lock){+.+...}, at: [<c04c0918>] qpnp_iadc_read+0x64/0x174

but task is already holding lock:
 (&adc_qpnp->adc_lock){+.+...}, at: [<c04be7f4>] qpnp_vadc_iadc_sync_request+0x34/0x198

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&adc_qpnp->adc_lock);
  lock(&adc_qpnp->adc_lock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

6 locks held by kworker/u:2/21:
 #0:  (deferwq){.+.+.+}, at: [<c00a7e84>] process_one_work+0x1c8/0x528
 #1:  (deferred_probe_work){+.+.+.}, at: [<c00a7e84>] process_one_work+0x1c8/0x528
 #2:  (&__lockdep_no_validate__){......}, at: [<c0339670>] device_attach+0x18/0xa4
 #3:  (&chip->last_ocv_uv_mutex){+.+...}, at: [<c04b8b74>] recalculate_soc+0x190/0x124c
 #4:  (&iadc->iadc_vadc_lock){+.+...}, at: [<c04c0aa8>] qpnp_iadc_vadc_sync_read+0x40/0xe4
 #5:  (&adc_qpnp->adc_lock){+.+...}, at: [<c04be7f4>] qpnp_vadc_iadc_sync_request+0x34/0x198

stack backtrace:
[<c00140cc>] (unwind_backtrace+0x0/0x11c) from [<c00d6ea8>] (__lock_acquire+0x238/0x1784)
[<c00d6ea8>] (__lock_acquire+0x238/0x1784) from [<c00d895c>] (lock_acquire+0xf0/0x138)
[<c00d895c>] (lock_acquire+0xf0/0x138) from [<c079aa50>] (mutex_lock_nested+0x5c/0x3d8)
[<c079aa50>] (mutex_lock_nested+0x5c/0x3d8) from [<c04c0918>] (qpnp_iadc_read+0x64/0x174)
[<c04c0918>] (qpnp_iadc_read+0x64/0x174) from [<c04c0ae0>] (qpnp_iadc_vadc_sync_read+0x78/0xe4)
[<c04c0ae0>] (qpnp_iadc_vadc_sync_read+0x78/0xe4) from [<c04b6d88>] (get_simultaneous_batt_v_and_i+0x24/0x68)
[<c04b6d88>] (get_simultaneous_batt_v_and_i+0x24/0x68) from [<c04b927c>] (recalculate_soc+0x898/0x124c)
[<c04b927c>] (recalculate_soc+0x898/0x124c) from [<c04b9cfc>] (calculate_soc_work+0x10/0x4c)
[<c04b9cfc>] (calculate_soc_work+0x10/0x4c) from [<c07750f8>] (qpnp_bms_probe+0xeac/0x1228)
[<c07750f8>] (qpnp_bms_probe+0xeac/0x1228) from [<c037d6b0>] (spmi_drv_probe+0x10/0x14)
[<c037d6b0>] (spmi_drv_probe+0x10/0x14) from [<c0339884>] (driver_probe_device+0x134/0x338)
[<c0339884>] (driver_probe_device+0x134/0x338) from [<c0337d28>] (bus_for_each_drv+0x48/0x8c)
[<c0337d28>] (bus_for_each_drv+0x48/0x8c) from [<c03396d8>] (device_attach+0x80/0xa4)
[<c03396d8>] (device_attach+0x80/0xa4) from [<c0338bdc>] (bus_probe_device+0x28/0x9c)
[<c0338bdc>] (bus_probe_device+0x28/0x9c) from [<c0339144>] (deferred_probe_work_func+0x68/0xa0)
[<c0339144>] (deferred_probe_work_func+0x68/0xa0) from [<c00a7f54>] (process_one_work+0x298/0x528)
[<c00a7f54>] (process_one_work+0x298/0x528) from [<c00a83a8>] (worker_thread+0x198/0x2b8)
[<c00a83a8>] (worker_thread+0x198/0x2b8) from [<c00ad2fc>] (kthread+0x90/0xa4)
[<c00ad2fc>] (kthread+0x90/0xa4) from [<c000edcc>] (kernel_thread_exit+0x0/0x8)

Change-Id: Iebda9a8dfc407273748545bb81f91d6dc27e97cc
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent fccf7a89
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment