Re: [PATCH 1/2] bus: mhi: ep: Fix potential deadlock in mhi_ep_reset_worker()

From: Manivannan Sadhasivam

Date: Mon Mar 02 2026 - 04:01:45 EST


On Tue, Feb 03, 2026 at 12:25:01PM +0530, Sumit Kumar wrote:
> 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.
>

While inspecting the code, I also found one instance where
mhi_ep_handle_syserr() was not locked. I've sent a patch to fix it. Please spare
some time to test it and give a tested-by tag.

> Fixes: 7a97b6b47353 ("bus: mhi: ep: Add support for handling MHI_RESET")
> Signed-off-by: Sumit Kumar <sumit.kumar@xxxxxxxxxxxxxxxx>
> ---
> drivers/bus/mhi/ep/main.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
> index cdea24e9291959ae0a92487c1b9698dc8164d2f1..73597de373ef7e0c428bcbc126d63a9a97f95144 100644
> --- a/drivers/bus/mhi/ep/main.c
> +++ b/drivers/bus/mhi/ep/main.c
> @@ -1093,6 +1093,7 @@ static void mhi_ep_reset_worker(struct work_struct *work)
> mhi_ep_mmio_reset(mhi_cntrl);

You can also perform locking after mhi_ep_mmio_reset(). There is no need to
protect mhi_ep_mmio_reset().

- Mani

--
மணிவண்ணன் சதாசிவம்