All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] usb: core: Bail out when port is stuck in reset loop
@ 2021-12-30  5:28 Kai-Heng Feng
  2022-01-17  3:00 ` Kai-Heng Feng
  0 siblings, 1 reply; 4+ messages in thread
From: Kai-Heng Feng @ 2021-12-30  5:28 UTC (permalink / raw)
  To: gregkh
  Cc: stern, mathias.nyman, Kai-Heng Feng, Thinh Nguyen, Bixuan Cui,
	Rajat Jain, Andrew Lunn, Chris Chiu, linux-usb, linux-kernel

Unplugging USB device may cause an incorrect warm reset loop and the
port can no longer be used:
[  143.039019] xhci_hcd 0000:00:14.0: Port change event, 2-3, id 19, portsc: 0x4202c0
[  143.039025] xhci_hcd 0000:00:14.0: handle_port_status: starting usb2 port polling.
[  143.039051] hub 2-0:1.0: state 7 ports 10 chg 0000 evt 0008
[  143.039058] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x4202c0, return 0x4102c0
[  143.039092] xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x4002c0
[  143.039096] usb usb2-port3: link state change
[  143.039099] xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
[  143.039101] usb usb2-port3: do warm reset
[  143.096736] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0
[  143.096751] usb usb2-port3: not warm reset yet, waiting 50ms
[  143.131500] xhci_hcd 0000:00:14.0: Can't queue urb, port error, link inactive
[  143.138260] xhci_hcd 0000:00:14.0: Port change event, 2-3, id 19, portsc: 0x2802a0
[  143.138263] xhci_hcd 0000:00:14.0: handle_port_status: starting usb2 port polling.
[  143.160756] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2802a0, return 0x3002a0
[  143.160798] usb usb2-port3: not warm reset yet, waiting 200ms

The port status is PP=1, CCS=0, PED=0, PLS=Inactive, which is Error
state per "USB3 Root Hub Port State Machine". It's reasonable to perform
warm reset several times, but if the port is still not enabled after
many attempts, consider it's gone and treat it as disconnected.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/usb/core/hub.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 00070a8a65079..f618d86d526d1 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2979,7 +2979,8 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
 		}
 
 		/* Check for disconnect or reset */
-		if (status == 0 || status == -ENOTCONN || status == -ENODEV) {
+		if (status == 0 || status == -ENOTCONN || status == -ENODEV ||
+		    (status == -EBUSY && i == PORT_RESET_TRIES - 1)) {
 			usb_clear_port_feature(hub->hdev, port1,
 					USB_PORT_FEAT_C_RESET);
 
-- 
2.33.1


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

* Re: [PATCH v3] usb: core: Bail out when port is stuck in reset loop
  2021-12-30  5:28 [PATCH v3] usb: core: Bail out when port is stuck in reset loop Kai-Heng Feng
@ 2022-01-17  3:00 ` Kai-Heng Feng
  2022-01-17  7:18   ` Greg KH
  2022-01-17 16:10   ` Alan Stern
  0 siblings, 2 replies; 4+ messages in thread
From: Kai-Heng Feng @ 2022-01-17  3:00 UTC (permalink / raw)
  To: gregkh
  Cc: stern, mathias.nyman, Thinh Nguyen, Bixuan Cui, Rajat Jain,
	Andrew Lunn, Chris Chiu, linux-usb, linux-kernel

On Thu, Dec 30, 2021 at 1:28 PM Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
>
> Unplugging USB device may cause an incorrect warm reset loop and the
> port can no longer be used:
> [  143.039019] xhci_hcd 0000:00:14.0: Port change event, 2-3, id 19, portsc: 0x4202c0
> [  143.039025] xhci_hcd 0000:00:14.0: handle_port_status: starting usb2 port polling.
> [  143.039051] hub 2-0:1.0: state 7 ports 10 chg 0000 evt 0008
> [  143.039058] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x4202c0, return 0x4102c0
> [  143.039092] xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x4002c0
> [  143.039096] usb usb2-port3: link state change
> [  143.039099] xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> [  143.039101] usb usb2-port3: do warm reset
> [  143.096736] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0
> [  143.096751] usb usb2-port3: not warm reset yet, waiting 50ms
> [  143.131500] xhci_hcd 0000:00:14.0: Can't queue urb, port error, link inactive
> [  143.138260] xhci_hcd 0000:00:14.0: Port change event, 2-3, id 19, portsc: 0x2802a0
> [  143.138263] xhci_hcd 0000:00:14.0: handle_port_status: starting usb2 port polling.
> [  143.160756] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2802a0, return 0x3002a0
> [  143.160798] usb usb2-port3: not warm reset yet, waiting 200ms
>
> The port status is PP=1, CCS=0, PED=0, PLS=Inactive, which is Error
> state per "USB3 Root Hub Port State Machine". It's reasonable to perform
> warm reset several times, but if the port is still not enabled after
> many attempts, consider it's gone and treat it as disconnected.
>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

A gentle ping...

> ---
>  drivers/usb/core/hub.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 00070a8a65079..f618d86d526d1 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -2979,7 +2979,8 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
>                 }
>
>                 /* Check for disconnect or reset */
> -               if (status == 0 || status == -ENOTCONN || status == -ENODEV) {
> +               if (status == 0 || status == -ENOTCONN || status == -ENODEV ||
> +                   (status == -EBUSY && i == PORT_RESET_TRIES - 1)) {
>                         usb_clear_port_feature(hub->hdev, port1,
>                                         USB_PORT_FEAT_C_RESET);
>
> --
> 2.33.1
>

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

* Re: [PATCH v3] usb: core: Bail out when port is stuck in reset loop
  2022-01-17  3:00 ` Kai-Heng Feng
@ 2022-01-17  7:18   ` Greg KH
  2022-01-17 16:10   ` Alan Stern
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2022-01-17  7:18 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: stern, mathias.nyman, Thinh Nguyen, Bixuan Cui, Rajat Jain,
	Andrew Lunn, Chris Chiu, linux-usb, linux-kernel

On Mon, Jan 17, 2022 at 11:00:05AM +0800, Kai-Heng Feng wrote:
> On Thu, Dec 30, 2021 at 1:28 PM Kai-Heng Feng
> <kai.heng.feng@canonical.com> wrote:
> >
> > Unplugging USB device may cause an incorrect warm reset loop and the
> > port can no longer be used:
> > [  143.039019] xhci_hcd 0000:00:14.0: Port change event, 2-3, id 19, portsc: 0x4202c0
> > [  143.039025] xhci_hcd 0000:00:14.0: handle_port_status: starting usb2 port polling.
> > [  143.039051] hub 2-0:1.0: state 7 ports 10 chg 0000 evt 0008
> > [  143.039058] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x4202c0, return 0x4102c0
> > [  143.039092] xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x4002c0
> > [  143.039096] usb usb2-port3: link state change
> > [  143.039099] xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> > [  143.039101] usb usb2-port3: do warm reset
> > [  143.096736] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0
> > [  143.096751] usb usb2-port3: not warm reset yet, waiting 50ms
> > [  143.131500] xhci_hcd 0000:00:14.0: Can't queue urb, port error, link inactive
> > [  143.138260] xhci_hcd 0000:00:14.0: Port change event, 2-3, id 19, portsc: 0x2802a0
> > [  143.138263] xhci_hcd 0000:00:14.0: handle_port_status: starting usb2 port polling.
> > [  143.160756] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2802a0, return 0x3002a0
> > [  143.160798] usb usb2-port3: not warm reset yet, waiting 200ms
> >
> > The port status is PP=1, CCS=0, PED=0, PLS=Inactive, which is Error
> > state per "USB3 Root Hub Port State Machine". It's reasonable to perform
> > warm reset several times, but if the port is still not enabled after
> > many attempts, consider it's gone and treat it as disconnected.
> >
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> 
> A gentle ping...

It's the merge window, I can't do anything, sorry.  Please wait until
after 5.17-rc1 is out.

thanks,

greg k-h

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

* Re: [PATCH v3] usb: core: Bail out when port is stuck in reset loop
  2022-01-17  3:00 ` Kai-Heng Feng
  2022-01-17  7:18   ` Greg KH
@ 2022-01-17 16:10   ` Alan Stern
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Stern @ 2022-01-17 16:10 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: gregkh, mathias.nyman, Thinh Nguyen, Bixuan Cui, Rajat Jain,
	Andrew Lunn, Chris Chiu, linux-usb, linux-kernel

On Mon, Jan 17, 2022 at 11:00:05AM +0800, Kai-Heng Feng wrote:
> On Thu, Dec 30, 2021 at 1:28 PM Kai-Heng Feng
> <kai.heng.feng@canonical.com> wrote:
> >
> > Unplugging USB device may cause an incorrect warm reset loop and the
> > port can no longer be used:
> > [  143.039019] xhci_hcd 0000:00:14.0: Port change event, 2-3, id 19, portsc: 0x4202c0
> > [  143.039025] xhci_hcd 0000:00:14.0: handle_port_status: starting usb2 port polling.
> > [  143.039051] hub 2-0:1.0: state 7 ports 10 chg 0000 evt 0008
> > [  143.039058] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x4202c0, return 0x4102c0
> > [  143.039092] xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x4002c0
> > [  143.039096] usb usb2-port3: link state change
> > [  143.039099] xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0
> > [  143.039101] usb usb2-port3: do warm reset
> > [  143.096736] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0
> > [  143.096751] usb usb2-port3: not warm reset yet, waiting 50ms
> > [  143.131500] xhci_hcd 0000:00:14.0: Can't queue urb, port error, link inactive
> > [  143.138260] xhci_hcd 0000:00:14.0: Port change event, 2-3, id 19, portsc: 0x2802a0
> > [  143.138263] xhci_hcd 0000:00:14.0: handle_port_status: starting usb2 port polling.
> > [  143.160756] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2802a0, return 0x3002a0
> > [  143.160798] usb usb2-port3: not warm reset yet, waiting 200ms
> >
> > The port status is PP=1, CCS=0, PED=0, PLS=Inactive, which is Error
> > state per "USB3 Root Hub Port State Machine". It's reasonable to perform
> > warm reset several times, but if the port is still not enabled after
> > many attempts, consider it's gone and treat it as disconnected.
> >
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> 
> A gentle ping...
> 
> > ---
> >  drivers/usb/core/hub.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> > index 00070a8a65079..f618d86d526d1 100644
> > --- a/drivers/usb/core/hub.c
> > +++ b/drivers/usb/core/hub.c
> > @@ -2979,7 +2979,8 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
> >                 }
> >
> >                 /* Check for disconnect or reset */
> > -               if (status == 0 || status == -ENOTCONN || status == -ENODEV) {
> > +               if (status == 0 || status == -ENOTCONN || status == -ENODEV ||
> > +                   (status == -EBUSY && i == PORT_RESET_TRIES - 1)) {

How about modifying the comment so that people will know what this 
extra test is trying to do?  The original comment no longer gives an 
accurate description of the test.

Alan Stern

> >                         usb_clear_port_feature(hub->hdev, port1,
> >                                         USB_PORT_FEAT_C_RESET);
> >
> > --
> > 2.33.1
> >

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

end of thread, other threads:[~2022-01-17 16:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-30  5:28 [PATCH v3] usb: core: Bail out when port is stuck in reset loop Kai-Heng Feng
2022-01-17  3:00 ` Kai-Heng Feng
2022-01-17  7:18   ` Greg KH
2022-01-17 16:10   ` Alan Stern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.