linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] bus: mhi: possible deadlock in mhi_pm_disable_transition() and mhi_async_power_up()
@ 2022-01-29  2:56 Jia-Ju Bai
  2022-02-01 17:15 ` Daniel Thompson
  2022-02-07  6:39 ` Manivannan Sadhasivam
  0 siblings, 2 replies; 6+ messages in thread
From: Jia-Ju Bai @ 2022-01-29  2:56 UTC (permalink / raw)
  To: mani, hemantk, bbhatt, loic.poulain, jhugo; +Cc: linux-arm-msm, linux-kernel

Hello,

My static analysis tool reports a possible deadlock in the mhi driver in 
Linux 5.10:

mhi_async_power_up()
   mutex_lock(&mhi_cntrl->pm_mutex); --> Line 933 (Lock A)
   wait_event_timeout(mhi_cntrl->state_event, ...) --> Line 985 (Wait X)
   mutex_unlock(&mhi_cntrl->pm_mutex); --> Line 1040 (Unlock A)

mhi_pm_disable_transition()
   mutex_lock(&mhi_cntrl->pm_mutex); --> Line 463 (Lock A)
   wake_up_all(&mhi_cntrl->state_event); --> Line 474 (Wake X)
   mutex_unlock(&mhi_cntrl->pm_mutex); --> Line 524 (Unlock A)
   wake_up_all(&mhi_cntrl->state_event); --> Line 526 (Wake X)

When mhi_async_power_up() is executed, "Wait X" is performed by holding 
"Lock A". If mhi_pm_disable_transition() is concurrently executed at 
this time, "Wake X" cannot be performed to wake up "Wait X" in 
mhi_async_power_up(), because "Lock A" is already hold by 
mhi_async_power_up(), causing a possible deadlock.
I find that "Wait X" is performed with a timeout, to relieve the 
possible deadlock; but I think this timeout can cause inefficient execution.

I am not quite sure whether this possible problem is real and how to fix 
it if it is real.
Any feedback would be appreciated, thanks :)


Best wishes,
Jia-Ju Bai




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-02-07  8:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-29  2:56 [BUG] bus: mhi: possible deadlock in mhi_pm_disable_transition() and mhi_async_power_up() Jia-Ju Bai
2022-02-01 17:15 ` Daniel Thompson
2022-02-06 15:34   ` Jia-Ju Bai
2022-02-07  8:34     ` Manivannan Sadhasivam
2022-02-07  6:45   ` Manivannan Sadhasivam
2022-02-07  6:39 ` Manivannan Sadhasivam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).