linux-sg2042/drivers/bus/mhi
Manivannan Sadhasivam 86e9eb69c0 bus: mhi: ep: Change state_lock to mutex
[ Upstream commit 1ddc761829 ]

state_lock, the spinlock type is meant to protect race against concurrent
MHI state transitions. In mhi_ep_set_m0_state(), while the state_lock is
being held, the channels are resumed in mhi_ep_resume_channels() if the
previous state was M3. This causes sleeping in atomic bug, since
mhi_ep_resume_channels() use mutex internally.

Since the state_lock is supposed to be held throughout the state change,
it is not ideal to drop the lock before calling mhi_ep_resume_channels().
So to fix this issue, let's change the type of state_lock to mutex. This
would also allow holding the lock throughout all state transitions thereby
avoiding any potential race.

Cc: <stable@vger.kernel.org> # 5.19
Fixes: e4b7b5f0f3 ("bus: mhi: ep: Add support for suspending and resuming channels")
Reported-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-03-17 08:50:19 +01:00
..
ep bus: mhi: ep: Change state_lock to mutex 2023-03-17 08:50:19 +01:00
host bus: mhi: host: Fix race between channel preparation and M0 event 2023-01-07 11:11:54 +01:00
Kconfig bus: mhi: ep: Add support for registering MHI endpoint controllers 2022-04-26 13:17:40 +02:00
Makefile bus: mhi: ep: Add support for registering MHI endpoint controllers 2022-04-26 13:17:40 +02:00
common.h bus: mhi: ep: Add support for sending events to the host 2022-04-26 13:17:41 +02:00