]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bus: mhi: core: Clear context for stopped channels from remove()
authorBhaumik Bhatt <bbhatt@codeaurora.org>
Thu, 1 Apr 2021 21:16:11 +0000 (14:16 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 12 May 2021 06:39:37 +0000 (08:39 +0200)
[ Upstream commit 4e44ae3d6d9c2c2a6d9356dd279c925532d5cd8c ]

If a channel was explicitly stopped but not reset and a driver
remove is issued, clean up the channel context such that it is
reflected on the device. This move is useful if a client driver
module is unloaded or a device crash occurs with the host having
placed the channel in a stopped state.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Reviewed-by: Hemant Kumar <hemantk@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/1617311778-1254-3-git-send-email-bbhatt@codeaurora.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/bus/mhi/core/init.c

index 6cb0d67fc921674714f8816c98a5257c8b4aaa87..08b7f4a06bfcce39b8a258e8991938a2067362fe 100644 (file)
@@ -1304,7 +1304,8 @@ static int mhi_driver_remove(struct device *dev)
 
                mutex_lock(&mhi_chan->mutex);
 
-               if (ch_state[dir] == MHI_CH_STATE_ENABLED &&
+               if ((ch_state[dir] == MHI_CH_STATE_ENABLED ||
+                    ch_state[dir] == MHI_CH_STATE_STOP) &&
                    !mhi_chan->offload_ch)
                        mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan);