]> git.baikalelectronics.ru Git - kernel.git/commit
bus: mhi: ep: Change state_lock to mutex
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Mon, 23 Jan 2023 07:29:45 +0000 (12:59 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2023 07:50:19 +0000 (08:50 +0100)
commit4915e27e166ac1fb4db120b07d61f9be2a7ab237
tree566ebd562db09fc241adada5ca8cba1a5dbaa1d5
parent59f39ebb40d498c282c98d8f7a4879e241b2cc65
bus: mhi: ep: Change state_lock to mutex

[ Upstream commit 7b96306c051550829ae3d195865ed2627b3c9aa3 ]

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: 9ac68db5eafd ("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>
drivers/bus/mhi/ep/main.c
drivers/bus/mhi/ep/sm.c
include/linux/mhi_ep.h