diff mbox series

[v5,2/9] bus: mhi: core: Allow channel to be disabled from stopped state

Message ID 1610139297-36435-3-git-send-email-bbhatt@codeaurora.org (mailing list archive)
State Superseded
Headers show
Series Updates to MHI channel handling | expand

Commit Message

Bhaumik Bhatt Jan. 8, 2021, 8:54 p.m. UTC
If a channel was explicitly stopped but not reset, allow it to
move to a disabled state so that the channel context can be
cleaned up after a driver remove is issued. Since the channel
remained in stopped state, its context on the device is not
cleared. Allow this move if a client driver module is unloaded
or a device crash occurs.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Reviewed-by: Hemant Kumar <hemantk@codeaurora.org>
---
 drivers/bus/mhi/core/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Manivannan Sadhasivam Jan. 21, 2021, 11:35 a.m. UTC | #1
On Fri, Jan 08, 2021 at 12:54:50PM -0800, Bhaumik Bhatt wrote:
> If a channel was explicitly stopped but not reset, allow it to
> move to a disabled state so that the channel context can be
> cleaned up after a driver remove is issued. Since the channel
> remained in stopped state, its context on the device is not
> cleared. Allow this move if a client driver module is unloaded
> or a device crash occurs.
> 

The commit message needs to be improved. The stopped channel will by default
move to stopped state during mhi_driver_remove(). So this patch is not at all
doing anything other than clearing the context for stopped channels.

Please fix it!

> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> Reviewed-by: Hemant Kumar <hemantk@codeaurora.org>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Thanks,
Mani

> ---
>  drivers/bus/mhi/core/init.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index aa575d3..03c5786 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);
>  
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>
diff mbox series

Patch

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index aa575d3..03c5786 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);