linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] MHI fix for v5.12
@ 2021-02-10  8:25 Manivannan Sadhasivam
  2021-02-10  8:25 ` [PATCH 1/1] mhi: Fix double dma free Manivannan Sadhasivam
  2021-03-01 19:59 ` [PATCH 0/1] MHI fix for v5.12 patchwork-bot+linux-arm-msm
  0 siblings, 2 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2021-02-10  8:25 UTC (permalink / raw)
  To: gregkh
  Cc: hemantk, bbhatt, linux-arm-msm, jhugo, linux-kernel,
	loic.poulain, kvalo, ath11k, Manivannan Sadhasivam

Hi Greg,

At the last moment we noticed a regression which existed since last release.
Since we are very late for v5.11 rc, please consider merging this patch for
v5.12.

Thanks,
Mani

Loic Poulain (1):
  mhi: Fix double dma free

 drivers/bus/mhi/core/init.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] mhi: Fix double dma free
  2021-02-10  8:25 [PATCH 0/1] MHI fix for v5.12 Manivannan Sadhasivam
@ 2021-02-10  8:25 ` Manivannan Sadhasivam
  2021-02-10 17:45   ` Bhaumik Bhatt
  2021-03-01 19:59 ` [PATCH 0/1] MHI fix for v5.12 patchwork-bot+linux-arm-msm
  1 sibling, 1 reply; 4+ messages in thread
From: Manivannan Sadhasivam @ 2021-02-10  8:25 UTC (permalink / raw)
  To: gregkh
  Cc: hemantk, bbhatt, linux-arm-msm, jhugo, linux-kernel,
	loic.poulain, kvalo, ath11k, Manivannan Sadhasivam

From: Loic Poulain <loic.poulain@linaro.org>

mhi_deinit_chan_ctxt functionthat takes care of unitializing channel
resources, including unmapping coherent MHI areas, can be called
from different path in case of controller unregistering/removal:
 - From a client driver remove callback, via mhi_unprepare_channel
 - From mhi_driver_remove that unitialize all channels

mhi_driver_remove()
|-> driver->remove()
|    |-> mhi_unprepare_channel()
|        |-> mhi_deinit_chan_ctxt()
|...
|-> mhi_deinit_chan_ctxt()

This leads to double dma freeing...

Fix that by preventing deinit for already uninitialized channel.

Fixes: a7f422f2f89e ("bus: mhi: Fix channel close issue on driver remove")
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reported-by: Kalle Valo <kvalo@codeaurora.org>
Tested-by: Kalle Valo <kvalo@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/1612894264-15956-1-git-send-email-loic.poulain@linaro.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/core/init.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index aa575d3fb3ae..be4eebb0971b 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -557,6 +557,9 @@ void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl,
 	tre_ring = &mhi_chan->tre_ring;
 	chan_ctxt = &mhi_cntrl->mhi_ctxt->chan_ctxt[mhi_chan->chan];
 
+	if (!chan_ctxt->rbase) /* Already uninitialized */
+		return;
+
 	mhi_free_coherent(mhi_cntrl, tre_ring->alloc_size,
 			  tre_ring->pre_aligned, tre_ring->dma_handle);
 	vfree(buf_ring->base);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] mhi: Fix double dma free
  2021-02-10  8:25 ` [PATCH 1/1] mhi: Fix double dma free Manivannan Sadhasivam
@ 2021-02-10 17:45   ` Bhaumik Bhatt
  0 siblings, 0 replies; 4+ messages in thread
From: Bhaumik Bhatt @ 2021-02-10 17:45 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: gregkh, hemantk, linux-arm-msm, jhugo, linux-kernel,
	loic.poulain, kvalo, ath11k

On 2021-02-10 12:25 AM, Manivannan Sadhasivam wrote:
> From: Loic Poulain <loic.poulain@linaro.org>
> 
> mhi_deinit_chan_ctxt functionthat takes care of unitializing channel
s/functionthat/function that, uninitializing
> resources, including unmapping coherent MHI areas, can be called
> from different path in case of controller unregistering/removal:
>  - From a client driver remove callback, via mhi_unprepare_channel
>  - From mhi_driver_remove that unitialize all channels
uninitialize
> 
> mhi_driver_remove()
> |-> driver->remove()
> |    |-> mhi_unprepare_channel()
> |        |-> mhi_deinit_chan_ctxt()
> |...
> |-> mhi_deinit_chan_ctxt()
> 
> This leads to double dma freeing...
> 
> Fix that by preventing deinit for already uninitialized channel.
> 
> Fixes: a7f422f2f89e ("bus: mhi: Fix channel close issue on driver 
> remove")
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> Reported-by: Kalle Valo <kvalo@codeaurora.org>
> Tested-by: Kalle Valo <kvalo@codeaurora.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Link:
> https://lore.kernel.org/r/1612894264-15956-1-git-send-email-loic.poulain@linaro.org
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  drivers/bus/mhi/core/init.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index aa575d3fb3ae..be4eebb0971b 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -557,6 +557,9 @@ void mhi_deinit_chan_ctxt(struct mhi_controller 
> *mhi_cntrl,
>  	tre_ring = &mhi_chan->tre_ring;
>  	chan_ctxt = &mhi_cntrl->mhi_ctxt->chan_ctxt[mhi_chan->chan];
> 
> +	if (!chan_ctxt->rbase) /* Already uninitialized */
> +		return;
> +
>  	mhi_free_coherent(mhi_cntrl, tre_ring->alloc_size,
>  			  tre_ring->pre_aligned, tre_ring->dma_handle);
>  	vfree(buf_ring->base);

As mentioned in my previous email, I see some improvements can be made 
to the commit
message and title of this patch. Highlighted those above.

Please update title to "bus: mhi: core: Fix double DMA free from 
mhi_deinit_chan_ctxt()".

Thanks,
Bhaumik
---
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/1] MHI fix for v5.12
  2021-02-10  8:25 [PATCH 0/1] MHI fix for v5.12 Manivannan Sadhasivam
  2021-02-10  8:25 ` [PATCH 1/1] mhi: Fix double dma free Manivannan Sadhasivam
@ 2021-03-01 19:59 ` patchwork-bot+linux-arm-msm
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+linux-arm-msm @ 2021-03-01 19:59 UTC (permalink / raw)
  To: Manivannan Sadhasivam; +Cc: linux-arm-msm

Hello:

This patch was applied to qcom/linux.git (refs/heads/for-next):

On Wed, 10 Feb 2021 13:55:37 +0530 you wrote:
> Hi Greg,
> 
> At the last moment we noticed a regression which existed since last release.
> Since we are very late for v5.11 rc, please consider merging this patch for
> v5.12.
> 
> Thanks,
> Mani
> 
> [...]

Here is the summary with links:
  - [1/1] mhi: Fix double dma free
    https://git.kernel.org/qcom/c/db4e8de1935b

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-01 20:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10  8:25 [PATCH 0/1] MHI fix for v5.12 Manivannan Sadhasivam
2021-02-10  8:25 ` [PATCH 1/1] mhi: Fix double dma free Manivannan Sadhasivam
2021-02-10 17:45   ` Bhaumik Bhatt
2021-03-01 19:59 ` [PATCH 0/1] MHI fix for v5.12 patchwork-bot+linux-arm-msm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).