diff mbox series

[v5,9/9] bus: mhi: core: Do not clear channel context more than once

Message ID 1610139297-36435-10-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
When clearing the channel context, calling mhi_free_coherent()
more than once can result in kernel warnings such as "trying to
free invalid coherent area". Prevent extra work by adding a check
to skip calling mhi_deinit_chan_ctxt() if the client driver has
already disabled the channels.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
---
 drivers/bus/mhi/core/init.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Hemant Kumar Jan. 9, 2021, 4:39 a.m. UTC | #1
On 1/8/21 12:54 PM, Bhaumik Bhatt wrote:
> When clearing the channel context, calling mhi_free_coherent()
> more than once can result in kernel warnings such as "trying to
> free invalid coherent area". Prevent extra work by adding a check
> to skip calling mhi_deinit_chan_ctxt() if the client driver has
> already disabled the channels.
> 
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> ---
>   drivers/bus/mhi/core/init.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index 30eef19..272f350 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -1314,6 +1314,7 @@ static int mhi_driver_remove(struct device *dev)
>   
>   		if ((ch_state[dir] == MHI_CH_STATE_ENABLED ||
>   		     ch_state[dir] == MHI_CH_STATE_STOP) &&
> +		    mhi_chan->ch_state != MHI_CH_STATE_DISABLED &&
>   		    !mhi_chan->offload_ch)
>   			mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan);
>   
> 
Reviewed-by: Hemant Kumar <hemantk@codeaurora.org>
Manivannan Sadhasivam Jan. 21, 2021, 3:15 p.m. UTC | #2
On Fri, Jan 08, 2021 at 12:54:57PM -0800, Bhaumik Bhatt wrote:
> When clearing the channel context, calling mhi_free_coherent()
> more than once can result in kernel warnings such as "trying to
> free invalid coherent area". Prevent extra work by adding a check
> to skip calling mhi_deinit_chan_ctxt() if the client driver has
> already disabled the channels.
> 

Again, please explain where and when exactly you spotted this issue.

Thanks,
Mani

> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> ---
>  drivers/bus/mhi/core/init.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index 30eef19..272f350 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -1314,6 +1314,7 @@ static int mhi_driver_remove(struct device *dev)
>  
>  		if ((ch_state[dir] == MHI_CH_STATE_ENABLED ||
>  		     ch_state[dir] == MHI_CH_STATE_STOP) &&
> +		    mhi_chan->ch_state != MHI_CH_STATE_DISABLED &&
>  		    !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 30eef19..272f350 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -1314,6 +1314,7 @@  static int mhi_driver_remove(struct device *dev)
 
 		if ((ch_state[dir] == MHI_CH_STATE_ENABLED ||
 		     ch_state[dir] == MHI_CH_STATE_STOP) &&
+		    mhi_chan->ch_state != MHI_CH_STATE_DISABLED &&
 		    !mhi_chan->offload_ch)
 			mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan);