lkml.org 
[lkml]   [2021]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[BUG] bus: mhi: possible ABBA deadlock in mhi_pm_m0_transition() and mhi_send_cmd()
Date
Hello,

I find there is a possible ABBA deadlock in the MHI driver in Linux 5.10:

In mhi_pm_m0_transition():
262:     read_lock_bh(&mhi_cntrl->pm_lock);
281:     spin_lock_irq(&mhi_cmd->lock);

In mhi_send_cmd():
1181:   spin_lock_bh(&mhi_cmd->lock);
1207:   read_lock_bh(&mhi_cntrl->pm_lock);

When mhi_pm_m0_transition() and mhi_send_cmd() are concurrently
executed, the deadlock can occur.

I check the code and find a possible case of such concurrent execution:

#CPU1:
mhi_poll (mhi_event->process_event(...))
  mhi_process_ctrl_ev_ring
    mhi_pm_m0_transition

#CPU2:
mhi_prepare_for_transfer
  mhi_prepare_channel
    mhi_send_cmd

Note that mhi_poll() and mhi_prepare_for_transfer() are both exported by
EXPORT_SYMBOL.
Thus, I guess these two functions could be concurrently called by a MHI
driver.

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


Best wishes,
Jia-Ju Bai

\
 
 \ /
  Last update: 2021-07-15 11:47    [W:0.341 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site