Skip to contentSkip to conversation

refine xhci-plat-Fix-xhci_plat-shutdown-sequence

PATCH [email protected] 2 participants 4 messages Apr 17, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

xhci-plat Shutdown callback should check HCD_FLAG_HW_ACCESSIBLE before accessing any register. This should avoid hung with access controllers which support runtime suspend

This can fix for issue of https://patchwork.kernel.org/patch/10339317/
corresponding upload in CAF:
https://source.codeaurora.org/quic/la/kernel/msm-4.4/commit/?h=LV.HB.1.1.5-03810-8x96.0&id=a7a5307ee04ad349d365ad50f304605a9cd9bd0a

full patch refer attachment.

From 9b65acb64f1ad87d115fa147c9e947fb3d37471c Mon Sep 17 00:00:00 2001
From: Lei wang <[email protected]>
Date: Tue, 17 Apr 2018 10:55:35 +0800
Subject: [PATCH] xhci: plat: Fix xhci_plat shutdown hung

xhci-plat Shutdown callback should check HCD_FLAG_HW_ACCESSIBLE before accessing any register. This should avoid hung with access controllers which support runtime suspend

---
 drivers/usb/host/xhci.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/host/xhci.c +4 -0
index 9b27798..bdf914d 100644
@@ -702,6 +702,10 @@ static void xhci_shutdown(struct usb_hcd *hcd)
 		usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
 
 	spin_lock_irq(&xhci->lock);
+	if (!HCD_HW_ACCESSIBLE(hcd)) {
+		spin_unlock_irq(&xhci->lock);
+		return;
+	}
 	xhci_halt(xhci);
 	/* Workaround for spurious wakeups at shutdown with HSW */
 	if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
Signature · 1 line
1.9.1
#1 lore raw
Quoted 15 lines · On Tue, Apr 17, 2018 at 11:32:42AM +0800, [email protected] wrote:

xhci-plat Shutdown callback should check HCD_FLAG_HW_ACCESSIBLE before accessing any register. This should avoid hung with access controllers which support runtime suspend

This can fix for issue of https://patchwork.kernel.org/patch/10339317/
corresponding upload in CAF:
https://source.codeaurora.org/quic/la/kernel/msm-4.4/commit/?h=LV.HB.1.1.5-03810-8x96.0&id=a7a5307ee04ad349d365ad50f304605a9cd9bd0a

full patch refer attachment.

drivers/usb/host/xhci.c +0 -0
index 9b27798..bdf914d 100644

drivers/usb/host/xhci.c static void xhci_shutdown(struct usb_hcd *hcd) · line 709

Quoted 8 lines
drivers/usb/host/xhci.c +4 -0
@@ -702,6 +702,10 @@ static void xhci_shutdown(struct usb_hcd *hcd)
                usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
 
        spin_lock_irq(&xhci->lock);
+       if (!HCD_HW_ACCESSIBLE(hcd)) {
+               spin_unlock_irq(&xhci->lock);
+               return;
+       }
        xhci_halt(xhci);

A blank line after the if statement?

What about all of the other places in this driver that you should also check for this? Look at the other host controllers, shouldn't you mirror what they are doing?

And this needs a Fixes: tag, along with a cc: stable so as to properly get backported as this is broken in some stable kernels right now.

thanks,

greg k-h
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 31 lines · 在 2018-04-17 18:32,Greg KH 写道:
Quoted 15 lines · On Tue, Apr 17, 2018 at 11:32:42AM +0800, [email protected] wrote:

xhci-plat Shutdown callback should check HCD_FLAG_HW_ACCESSIBLE before accessing any register. This should avoid hung with access controllers which support runtime suspend

This can fix for issue of https://patchwork.kernel.org/patch/10339317/
corresponding upload in CAF:
https://source.codeaurora.org/quic/la/kernel/msm-4.4/commit/?h=LV.HB.1.1.5-03810-8x96.0&id=a7a5307ee04ad349d365ad50f304605a9cd9bd0a

full patch refer attachment.

drivers/usb/host/xhci.c +0 -0
index 9b27798..bdf914d 100644

drivers/usb/host/xhci.c static void xhci_shutdown(struct usb_hcd *hcd) · line 709

Quoted 8 lines
drivers/usb/host/xhci.c +4 -0
@@ -702,6 +702,10 @@ static void xhci_shutdown(struct usb_hcd *hcd)
                usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
 
        spin_lock_irq(&xhci->lock);
+       if (!HCD_HW_ACCESSIBLE(hcd)) {
+               spin_unlock_irq(&xhci->lock);
+               return;
+       }
        xhci_halt(xhci);

A blank line after the if statement?

Quoted 1 line
Quoted 1 line

[lei]yes

What about all of the other places in this driver that you should also check for this? Look at the other host controllers, shouldn't you mirror what they are doing?

Quoted 1 line
Quoted 1 line

[lei]I checked other usb host module shutdown and suspend workflow.

Quoted 8 lines
Quoted 2 lines

All usb host driver need to check hw accessable before read/write usb register especially in runtime PM case..

And this needs a Fixes: tag, along with a cc: stable so as to properly get backported as this is broken in some stable kernels right now.

Quoted 1 line
Quoted 1 line

[lei] Added by v2 patch

thanks,

greg k-h

From c03697fa259ab38d1002598ec2ccfac37607ca0b Mon Sep 17 00:00:00 2001
From: Lei wang <[email protected]>
Date: Tue, 17 Apr 2018 10:55:35 +0800
Subject: [PATCH v2] xhci: plat: Fix xhci_plat shutdown hung

xhci-plat Shutdown callback should check HCD_FLAG_HW_ACCESSIBLE before accessing any register. This should avoid hung with access controllers which support runtime suspend

Fixes b07c12517f2a ("xhci: plat: Register shutdown for xhci_plat")
---
 drivers/usb/host/xhci.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/host/xhci.c +4 -0
index 9b27798..bdf914d 100644
@@ -702,6 +702,10 @@ static void xhci_shutdown(struct usb_hcd *hcd)
        usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
 
    spin_lock_irq(&xhci->lock);
+   if (!HCD_HW_ACCESSIBLE(hcd)) {
+       spin_unlock_irq(&xhci->lock);
+       return;
+   }
    xhci_halt(xhci);
    /* Workaround for spurious wakeups at shutdown with HSW */
    if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)

--
1.9.1

maintainer
#3 lore raw
Quoted 74 lines · On Tue, Apr 17, 2018 at 10:32:28PM +0800, [email protected] wrote:
Quoted 31 lines · 在 2018-04-17 18:32,Greg KH 写道:
Quoted 15 lines · On Tue, Apr 17, 2018 at 11:32:42AM +0800, [email protected] wrote:

xhci-plat Shutdown callback should check HCD_FLAG_HW_ACCESSIBLE before accessing any register. This should avoid hung with access controllers which support runtime suspend

This can fix for issue of https://patchwork.kernel.org/patch/10339317/
corresponding upload in CAF:
https://source.codeaurora.org/quic/la/kernel/msm-4.4/commit/?h=LV.HB.1.1.5-03810-8x96.0&id=a7a5307ee04ad349d365ad50f304605a9cd9bd0a

full patch refer attachment.

drivers/usb/host/xhci.c +0 -0
index 9b27798..bdf914d 100644

drivers/usb/host/xhci.c static void xhci_shutdown(struct usb_hcd *hcd) · line 709

Quoted 8 lines
drivers/usb/host/xhci.c +4 -0
@@ -702,6 +702,10 @@ static void xhci_shutdown(struct usb_hcd *hcd)
                usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
 
        spin_lock_irq(&xhci->lock);
+       if (!HCD_HW_ACCESSIBLE(hcd)) {
+               spin_unlock_irq(&xhci->lock);
+               return;
+       }
        xhci_halt(xhci);

A blank line after the if statement?

Quoted 1 line
Quoted 1 line

[lei]yes

What about all of the other places in this driver that you should also check for this? Look at the other host controllers, shouldn't you mirror what they are doing?

Quoted 1 line
Quoted 1 line

[lei]I checked other usb host module shutdown and suspend workflow.

Quoted 8 lines
Quoted 2 lines

All usb host driver need to check hw accessable before read/write usb register especially in runtime PM case..

And this needs a Fixes: tag, along with a cc: stable so as to properly get backported as this is broken in some stable kernels right now.

Quoted 1 line
Quoted 1 line

[lei] Added by v2 patch

thanks,

greg k-h

From c03697fa259ab38d1002598ec2ccfac37607ca0b Mon Sep 17 00:00:00 2001
From: Lei wang <[email protected]>
Date: Tue, 17 Apr 2018 10:55:35 +0800
Subject: [PATCH v2] xhci: plat: Fix xhci_plat shutdown hung

xhci-plat Shutdown callback should check HCD_FLAG_HW_ACCESSIBLE before accessing any register. This should avoid hung with access controllers which support runtime suspend

Fixes b07c12517f2a ("xhci: plat: Register shutdown for xhci_plat")
---
 drivers/usb/host/xhci.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/host/xhci.c +4 -1
index 9b27798..bdf914d 100644
@@ -702,6 +702,10 @@ static void xhci_shutdown(struct usb_hcd *hcd)
        usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
 
    spin_lock_irq(&xhci->lock);
+   if (!HCD_HW_ACCESSIBLE(hcd)) {
+       spin_unlock_irq(&xhci->lock);
+       return;
+   }
    xhci_halt(xhci);
    /* Workaround for spurious wakeups at shutdown with HSW */
    if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
--
Quoted 1 line

1.9.1

I totally do not understand, why did you forward a broken patch that was not accepted upstream to the stable list?

Please go read Documentation/SubmittingPatches for how to do this correctly. Your first email was close, but it was attached, which isn't ok. And then I provided code review comments which you seem to have ignored here...

thanks,

greg k-h