On Thu, Jul 15, 2021 at 09:57:22AM -0700, Bhaumik Bhatt wrote:
On 2021-07-15 02:45 AM, Jia-Ju Bai wrote:Then this shouldn't be added in first place... :/
Hello,Few pointers from your example:
I find there is a possible ABBA deadlock in the MHI driver in Linux
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:
Note that mhi_poll() and mhi_prepare_for_transfer() are both exported
Thus, I guess these two functions could be concurrently called by a MHI
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 :)
1. mhi_poll() is currently not used by any client upstream yet.
2. Polling is not to be used for single event ring (shared control + data)But client can be unloaded during M0 event!
since it is meant to be for client drivers with dedicated data packets only.
3. mhi_send_cmd() will always be called after an mhi_pm_m0_transition() has
completed by design since we wait for the device to be held in M0 prior to
Anyway, I don't think the deadlock scenario is valid because of the usage
of "read_lock_bh()". So if "mhi_send_cmd()" has acquired
"spin_lock_bh(&mhi_cmd->lock)", it can always acquire
"read_lock_bh(&mhi_cntrl->pm_lock)" as multiple readers can acquire the
Deadlock would only occur if one of the functions take write lock.
Thanks for auditing.