linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] MHI fixes for v5.13
@ 2021-06-06 15:37 Manivannan Sadhasivam
  2021-06-06 15:37 ` [PATCH 1/3] bus: mhi: pci_generic: T99W175: update channel name from AT to DUN Manivannan Sadhasivam
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Manivannan Sadhasivam @ 2021-06-06 15:37 UTC (permalink / raw)
  To: gregkh
  Cc: hemantk, bbhatt, linux-arm-msm, linux-kernel, jarvis.w.jiang,
	loic.poulain, Manivannan Sadhasivam

Hi Greg,

This patchset contains below MHI fixes for v5.13. All of the issues are
fixed in the mhi_pci_generic controller driver:

1. Fixed channel names for channels 32 and 33 in T99W175 modem
2. Fixed the issue with hibernation reported in kernel bugzilla
3. Fixed possible use-after-free in mhi_pci_remove()

Please consider merging!

Thanks,
Mani

Jarvis Jiang (1):
  bus: mhi: pci_generic: T99W175: update channel name from AT to DUN

Loic Poulain (1):
  bus: mhi: pci-generic: Fix hibernation

Wei Yongjun (1):
  bus: mhi: pci_generic: Fix possible use-after-free in mhi_pci_remove()

 drivers/bus/mhi/pci_generic.c | 42 +++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)

-- 
2.25.1


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

* [PATCH 1/3] bus: mhi: pci_generic: T99W175: update channel name from AT to DUN
  2021-06-06 15:37 [PATCH 0/3] MHI fixes for v5.13 Manivannan Sadhasivam
@ 2021-06-06 15:37 ` Manivannan Sadhasivam
  2021-06-06 15:37 ` [PATCH 2/3] bus: mhi: pci_generic: Fix possible use-after-free in mhi_pci_remove() Manivannan Sadhasivam
  2021-06-06 15:37 ` [PATCH 3/3] bus: mhi: pci-generic: Fix hibernation Manivannan Sadhasivam
  2 siblings, 0 replies; 7+ messages in thread
From: Manivannan Sadhasivam @ 2021-06-06 15:37 UTC (permalink / raw)
  To: gregkh
  Cc: hemantk, bbhatt, linux-arm-msm, linux-kernel, jarvis.w.jiang,
	loic.poulain, Manivannan Sadhasivam

From: Jarvis Jiang <jarvis.w.jiang@gmail.com>

According to MHI v1.1 specification, change the channel name of T99W175
from "AT" to "DUN" (Dial-up networking) for both channel 32 and 33,
so that the channels can be bound to the Qcom WWAN control driver, and
device node such as /dev/wwan0p3DUN will be generated, which is very useful
for debugging modem

Fixes: aac426562f56 ("bus: mhi: pci_generic: Introduce Foxconn T99W175 support")
Signed-off-by: Jarvis Jiang <jarvis.w.jiang@gmail.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20210429014226.21017-1-jarvis.w.jiang@gmail.com
[mani: changed the dev node to /dev/wwan0p3DUN]
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/pci_generic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/mhi/pci_generic.c b/drivers/bus/mhi/pci_generic.c
index 7c810f02a2ef..8c7f6576e421 100644
--- a/drivers/bus/mhi/pci_generic.c
+++ b/drivers/bus/mhi/pci_generic.c
@@ -311,8 +311,8 @@ static const struct mhi_channel_config mhi_foxconn_sdx55_channels[] = {
 	MHI_CHANNEL_CONFIG_DL(5, "DIAG", 32, 1),
 	MHI_CHANNEL_CONFIG_UL(12, "MBIM", 32, 0),
 	MHI_CHANNEL_CONFIG_DL(13, "MBIM", 32, 0),
-	MHI_CHANNEL_CONFIG_UL(32, "AT", 32, 0),
-	MHI_CHANNEL_CONFIG_DL(33, "AT", 32, 0),
+	MHI_CHANNEL_CONFIG_UL(32, "DUN", 32, 0),
+	MHI_CHANNEL_CONFIG_DL(33, "DUN", 32, 0),
 	MHI_CHANNEL_CONFIG_HW_UL(100, "IP_HW0_MBIM", 128, 2),
 	MHI_CHANNEL_CONFIG_HW_DL(101, "IP_HW0_MBIM", 128, 3),
 };
-- 
2.25.1


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

* [PATCH 2/3] bus: mhi: pci_generic: Fix possible use-after-free in mhi_pci_remove()
  2021-06-06 15:37 [PATCH 0/3] MHI fixes for v5.13 Manivannan Sadhasivam
  2021-06-06 15:37 ` [PATCH 1/3] bus: mhi: pci_generic: T99W175: update channel name from AT to DUN Manivannan Sadhasivam
@ 2021-06-06 15:37 ` Manivannan Sadhasivam
  2021-06-09 16:59   ` Greg KH
  2021-06-06 15:37 ` [PATCH 3/3] bus: mhi: pci-generic: Fix hibernation Manivannan Sadhasivam
  2 siblings, 1 reply; 7+ messages in thread
From: Manivannan Sadhasivam @ 2021-06-06 15:37 UTC (permalink / raw)
  To: gregkh
  Cc: hemantk, bbhatt, linux-arm-msm, linux-kernel, jarvis.w.jiang,
	loic.poulain, Wei Yongjun, Hulk Robot, Manivannan Sadhasivam

From: Wei Yongjun <weiyongjun1@huawei.com>

This driver's remove path calls del_timer(). However, that function
does not wait until the timer handler finishes. This means that the
timer handler may still be running after the driver's remove function
has finished, which would result in a use-after-free.

Fix by calling del_timer_sync(), which makes sure the timer handler
has finished, and unable to re-schedule itself.

Fixes: 8562d4fe34a3 ("mhi: pci_generic: Add health-check")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: Hemant kumar <hemantk@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Link: https://lore.kernel.org/r/20210413160318.2003699-1-weiyongjun1@huawei.com
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/pci_generic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/pci_generic.c b/drivers/bus/mhi/pci_generic.c
index 8c7f6576e421..0a6619ad292c 100644
--- a/drivers/bus/mhi/pci_generic.c
+++ b/drivers/bus/mhi/pci_generic.c
@@ -708,7 +708,7 @@ static void mhi_pci_remove(struct pci_dev *pdev)
 	struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
 	struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
 
-	del_timer(&mhi_pdev->health_check_timer);
+	del_timer_sync(&mhi_pdev->health_check_timer);
 	cancel_work_sync(&mhi_pdev->recovery_work);
 
 	if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) {
-- 
2.25.1


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

* [PATCH 3/3] bus: mhi: pci-generic: Fix hibernation
  2021-06-06 15:37 [PATCH 0/3] MHI fixes for v5.13 Manivannan Sadhasivam
  2021-06-06 15:37 ` [PATCH 1/3] bus: mhi: pci_generic: T99W175: update channel name from AT to DUN Manivannan Sadhasivam
  2021-06-06 15:37 ` [PATCH 2/3] bus: mhi: pci_generic: Fix possible use-after-free in mhi_pci_remove() Manivannan Sadhasivam
@ 2021-06-06 15:37 ` Manivannan Sadhasivam
  2021-06-09 17:04   ` Greg KH
  2 siblings, 1 reply; 7+ messages in thread
From: Manivannan Sadhasivam @ 2021-06-06 15:37 UTC (permalink / raw)
  To: gregkh
  Cc: hemantk, bbhatt, linux-arm-msm, linux-kernel, jarvis.w.jiang,
	loic.poulain, Shujun Wang, Manivannan Sadhasivam

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

This patch fixes crash after resuming from hibernation. The issue
occurs when mhi stack is builtin and so part of the 'restore-kernel',
causing the device to be resumed from 'restored kernel' with a no
more valid context (memory mappings etc...) and leading to spurious
crashes.

This patch fixes the issue by implementing proper freeze/restore
callbacks.

Reported-by: Shujun Wang <wsj20369@163.com>
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/1622571445-4505-1-git-send-email-loic.poulain@linaro.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/pci_generic.c | 36 ++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/pci_generic.c b/drivers/bus/mhi/pci_generic.c
index 0a6619ad292c..b3357a8a2fdb 100644
--- a/drivers/bus/mhi/pci_generic.c
+++ b/drivers/bus/mhi/pci_generic.c
@@ -935,9 +935,43 @@ static int __maybe_unused mhi_pci_resume(struct device *dev)
 	return ret;
 }
 
+static int __maybe_unused mhi_pci_freeze(struct device *dev)
+{
+	struct mhi_pci_device *mhi_pdev = dev_get_drvdata(dev);
+	struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
+
+	/* We want to stop all operations, hibernation does not guarantee that
+	 * device will be in the same state as before freezing, especially if
+	 * the intermediate restore kernel reinitializes MHI device with new
+	 * context.
+	 */
+	if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) {
+		mhi_power_down(mhi_cntrl, false);
+		mhi_unprepare_after_power_down(mhi_cntrl);
+	}
+
+	return 0;
+}
+
+static int __maybe_unused mhi_pci_restore(struct device *dev)
+{
+	struct mhi_pci_device *mhi_pdev = dev_get_drvdata(dev);
+
+	/* Reinitialize the device */
+	queue_work(system_long_wq, &mhi_pdev->recovery_work);
+
+	return 0;
+}
+
 static const struct dev_pm_ops mhi_pci_pm_ops = {
 	SET_RUNTIME_PM_OPS(mhi_pci_runtime_suspend, mhi_pci_runtime_resume, NULL)
-	SET_SYSTEM_SLEEP_PM_OPS(mhi_pci_suspend, mhi_pci_resume)
+#ifdef CONFIG_PM_SLEEP
+	.suspend = mhi_pci_suspend,
+	.resume = mhi_pci_resume,
+	.freeze = mhi_pci_freeze,
+	.thaw = mhi_pci_restore,
+	.restore = mhi_pci_restore,
+#endif
 };
 
 static struct pci_driver mhi_pci_driver = {
-- 
2.25.1


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

* Re: [PATCH 2/3] bus: mhi: pci_generic: Fix possible use-after-free in mhi_pci_remove()
  2021-06-06 15:37 ` [PATCH 2/3] bus: mhi: pci_generic: Fix possible use-after-free in mhi_pci_remove() Manivannan Sadhasivam
@ 2021-06-09 16:59   ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2021-06-09 16:59 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: hemantk, bbhatt, linux-arm-msm, linux-kernel, jarvis.w.jiang,
	loic.poulain, Wei Yongjun, Hulk Robot

On Sun, Jun 06, 2021 at 09:07:40PM +0530, Manivannan Sadhasivam wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> This driver's remove path calls del_timer(). However, that function
> does not wait until the timer handler finishes. This means that the
> timer handler may still be running after the driver's remove function
> has finished, which would result in a use-after-free.
> 
> Fix by calling del_timer_sync(), which makes sure the timer handler
> has finished, and unable to re-schedule itself.
> 
> Fixes: 8562d4fe34a3 ("mhi: pci_generic: Add health-check")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> Reviewed-by: Hemant kumar <hemantk@codeaurora.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
> Link: https://lore.kernel.org/r/20210413160318.2003699-1-weiyongjun1@huawei.com
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  drivers/bus/mhi/pci_generic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

No Cc: stable on this?  I'll go add it...

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

* Re: [PATCH 3/3] bus: mhi: pci-generic: Fix hibernation
  2021-06-06 15:37 ` [PATCH 3/3] bus: mhi: pci-generic: Fix hibernation Manivannan Sadhasivam
@ 2021-06-09 17:04   ` Greg KH
  2021-06-09 17:44     ` Manivannan Sadhasivam
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2021-06-09 17:04 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: hemantk, bbhatt, linux-arm-msm, linux-kernel, jarvis.w.jiang,
	loic.poulain, Shujun Wang

On Sun, Jun 06, 2021 at 09:07:41PM +0530, Manivannan Sadhasivam wrote:
> From: Loic Poulain <loic.poulain@linaro.org>
> 
> This patch fixes crash after resuming from hibernation. The issue
> occurs when mhi stack is builtin and so part of the 'restore-kernel',
> causing the device to be resumed from 'restored kernel' with a no
> more valid context (memory mappings etc...) and leading to spurious
> crashes.
> 
> This patch fixes the issue by implementing proper freeze/restore
> callbacks.
> 
> Reported-by: Shujun Wang <wsj20369@163.com>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Link: https://lore.kernel.org/r/1622571445-4505-1-git-send-email-loic.poulain@linaro.org
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  drivers/bus/mhi/pci_generic.c | 36 ++++++++++++++++++++++++++++++++++-
>  1 file changed, 35 insertions(+), 1 deletion(-)

Also needs a stable link, right?  I'll go add it by hand.  Please be
more careful next time...

greg k-h

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

* Re: [PATCH 3/3] bus: mhi: pci-generic: Fix hibernation
  2021-06-09 17:04   ` Greg KH
@ 2021-06-09 17:44     ` Manivannan Sadhasivam
  0 siblings, 0 replies; 7+ messages in thread
From: Manivannan Sadhasivam @ 2021-06-09 17:44 UTC (permalink / raw)
  To: Greg KH
  Cc: hemantk, bbhatt, linux-arm-msm, linux-kernel, jarvis.w.jiang,
	loic.poulain, Shujun Wang

On Wed, Jun 09, 2021 at 07:04:35PM +0200, Greg KH wrote:
> On Sun, Jun 06, 2021 at 09:07:41PM +0530, Manivannan Sadhasivam wrote:
> > From: Loic Poulain <loic.poulain@linaro.org>
> > 
> > This patch fixes crash after resuming from hibernation. The issue
> > occurs when mhi stack is builtin and so part of the 'restore-kernel',
> > causing the device to be resumed from 'restored kernel' with a no
> > more valid context (memory mappings etc...) and leading to spurious
> > crashes.
> > 
> > This patch fixes the issue by implementing proper freeze/restore
> > callbacks.
> > 
> > Reported-by: Shujun Wang <wsj20369@163.com>
> > Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> > Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > Link: https://lore.kernel.org/r/1622571445-4505-1-git-send-email-loic.poulain@linaro.org
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > ---
> >  drivers/bus/mhi/pci_generic.c | 36 ++++++++++++++++++++++++++++++++++-
> >  1 file changed, 35 insertions(+), 1 deletion(-)
> 
> Also needs a stable link, right?  I'll go add it by hand.  Please be
> more careful next time...
> 

Oops... yes, sorry.

Thanks,
Mani

> greg k-h

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

end of thread, other threads:[~2021-06-09 17:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-06 15:37 [PATCH 0/3] MHI fixes for v5.13 Manivannan Sadhasivam
2021-06-06 15:37 ` [PATCH 1/3] bus: mhi: pci_generic: T99W175: update channel name from AT to DUN Manivannan Sadhasivam
2021-06-06 15:37 ` [PATCH 2/3] bus: mhi: pci_generic: Fix possible use-after-free in mhi_pci_remove() Manivannan Sadhasivam
2021-06-09 16:59   ` Greg KH
2021-06-06 15:37 ` [PATCH 3/3] bus: mhi: pci-generic: Fix hibernation Manivannan Sadhasivam
2021-06-09 17:04   ` Greg KH
2021-06-09 17:44     ` Manivannan Sadhasivam

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).