Skip to content

Commit b637a15

Browse files
Sumit Kumargregkh
authored andcommitted
bus: mhi: ep: Fix potential deadlock in mhi_ep_reset_worker()
[ Upstream commit 9dece44 ] There is a potential deadlock scenario in mhi_ep_reset_worker() where the state_lock mutex is acquired twice in the same call chain: mhi_ep_reset_worker() mutex_lock(&mhi_cntrl->state_lock) mhi_ep_power_up() mhi_ep_set_ready_state() mutex_lock(&mhi_cntrl->state_lock) <- Deadlock Fix this by releasing the state_lock before calling mhi_ep_power_up(). The lock is only needed to protect current MHI state read operation. The lock can be safely released before proceeding with the power up sequence. Fixes: 7a97b6b ("bus: mhi: ep: Add support for handling MHI_RESET") Signed-off-by: Sumit Kumar <sumit.kumar@oss.qualcomm.com> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com> Link: https://patch.msgid.link/20260414-reset_worker_deadlock-v2-1-42fd682b45db@oss.qualcomm.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 326d918 commit b637a15

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

drivers/bus/mhi/ep/main.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,11 +1026,12 @@ static void mhi_ep_reset_worker(struct work_struct *work)
10261026

10271027
mhi_ep_power_down(mhi_cntrl);
10281028

1029-
mutex_lock(&mhi_cntrl->state_lock);
1030-
10311029
/* Reset MMIO to signal host that the MHI_RESET is completed in endpoint */
10321030
mhi_ep_mmio_reset(mhi_cntrl);
1031+
1032+
mutex_lock(&mhi_cntrl->state_lock);
10331033
cur_state = mhi_cntrl->mhi_state;
1034+
mutex_unlock(&mhi_cntrl->state_lock);
10341035

10351036
/*
10361037
* Only proceed further if the reset is due to SYS_ERR. The host will
@@ -1039,8 +1040,6 @@ static void mhi_ep_reset_worker(struct work_struct *work)
10391040
*/
10401041
if (cur_state == MHI_STATE_SYS_ERR)
10411042
mhi_ep_power_up(mhi_cntrl);
1042-
1043-
mutex_unlock(&mhi_cntrl->state_lock);
10441043
}
10451044

10461045
/*

0 commit comments

Comments
 (0)