[v8,2/9] bus: mhi: core: Clear context for stopped channels from remove()
diff mbox series

Message ID 1617311778-1254-3-git-send-email-bbhatt@codeaurora.org
State Accepted
Commit 4e44ae3d6d9c2c2a6d9356dd279c925532d5cd8c
Headers show
Series
  • [v8,1/9] bus: mhi: core: Allow sending the STOP channel command
Related show

Commit Message

Bhaumik Bhatt April 1, 2021, 9:16 p.m. UTC
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>
---
 drivers/bus/mhi/core/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jeffrey Hugo May 4, 2021, 5:41 p.m. UTC | #1
On 4/1/2021 3:16 PM, Bhaumik Bhatt wrote:
> 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>

Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>

Patch
diff mbox series

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index d1d9b0d..f8ba954 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -1293,7 +1293,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);