xhci fixes for usb-linus
Subsystems (3)
cover xhci fixes for usb-linus
Hi Greg
A few small xhci fixes for usb-linus
Fixes USB 3 link resume for tunneled USB 3 devices, timers left running after shutdown, and a bug in how we handle a full event ring.
Thanks
-Mathias
Henry Lin (1):
xhci: stop polling roothubs after shutdown
Mathias Nyman (1):
xhci: increase usb U3 -> U0 link resume timeout from 100ms to 500ms
Weitao Wang (1):
USB: Fix xhci event ring dequeue pointer ERDP update issue
drivers/usb/host/xhci-hub.c | 2 +- drivers/usb/host/xhci-ring.c | 1 + drivers/usb/host/xhci.c | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
PATCH 1/3 USB: Fix xhci event ring dequeue pointer ERDP update issue
From: Weitao Wang <[email protected]>
In some situations software handles TRB events slower than adding TRBs. If the number of TRB events to be processed in a given interrupt is exactly the same as the event ring size 256, then the local variable "event_ring_deq" that holds the initial dequeue position is equal to software_dequeue after handling all 256 interrupts.
It will cause driver to not update ERDP to hardware,
Software dequeue pointer is out of sync with ERDP on interrupt exit. On the next interrupt, the event ring may full but driver will not update ERDP as software_dequeue is equal to ERDP.
[ 536.377115] xhci_hcd 0000:00:12.0: ERROR unknown event type 37 [ 566.933173] sd 8:0:0:0: [sdb] tag#27 uas_eh_abort_handler 0 uas-tag 7 inflight: CMD OUT [ 566.933181] sd 8:0:0:0: [sdb] tag#27 CDB: Write(10) 2a 00 17 71 e6 78 00 00 08 00 [ 572.041186] xhci_hcd On some situataions,the0000:00:12.0: xHCI host not responding to stop endpoint command. [ 572.057193] xhci_hcd 0000:00:12.0: Host halt failed, -110 [ 572.057196] xhci_hcd 0000:00:12.0: xHCI host controller not responding, assume dead [ 572.057236] sd 8:0:0:0: [sdb] tag#26 uas_eh_abort_handler 0 uas-tag 6 inflight: CMD [ 572.057240] sd 8:0:0:0: [sdb] tag#26 CDB: Write(10) 2a 00 38 eb cc d8 00 00 08 00 [ 572.057244] sd 8:0:0:0: [sdb] tag#25 uas_eh_abort_handler 0 uas-tag 5 inflight: CMD
Hardware ERDP is updated mid event handling if there are more than 128 events in an interrupt (half of ring size).
Fix this by updating the software local variable at the same time as hardware ERDP.
--- drivers/usb/host/xhci-ring.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/xhci-ring.c +1 -0
@@ -3141,6 +3141,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)if (event_loop++ <TRBS_PER_SEGMENT /2 )continue ;xhci_update_erst_dequeue (xhci, event_ring_deq); + event_ring_deq = xhci->event_ring->dequeue;/* ring is half-full, force isoc trbs to interrupt more often */ if (xhci->isoc_bei_interval >AVOID_BEI_INTERVAL_MIN )
Signature · 1 line
2.25.1
PATCH 2/3 xhci: stop polling roothubs after shutdown
In reply to Mathias NymanFrom: Henry Lin <[email protected]>
While rebooting, XHCI controller and its bus device will be shut down in order by .shutdown callback. Stopping roothubs polling in xhci_shutdown() can prevent XHCI driver from accessing port status after its bus device shutdown.
Take PCIe XHCI controller as example, if XHCI driver doesn't stop roothubs polling, XHCI driver may access PCIe BAR register for port status after parent PCIe root port driver is shutdown and cause PCIe bus error.
--- drivers/usb/host/xhci.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/usb/host/xhci.c +11 -0
@@ -781,6 +781,17 @@ void xhci_shutdown(struct usb_hcd *hcd)if (xhci->quirks &XHCI_SPURIOUS_REBOOT )usb_disable_xhci_ports (to_pci_dev (hcd->self.sysdev)); +/* Don't poll the roothubs after shutdown. */ +xhci_dbg (xhci,"%s: stopping usb%d port polling.\n" , + __func__, hcd->self.busnum); +clear_bit (HCD_FLAG_POLL_RH , &hcd->flags); +del_timer_sync (&hcd->rh_timer); + +if (xhci->shared_hcd) { +clear_bit (HCD_FLAG_POLL_RH , &xhci->shared_hcd->flags); +del_timer_sync (&xhci->shared_hcd->rh_timer); + } +spin_lock_irq (&xhci->lock);xhci_halt (xhci);/* Workaround for spurious wakeups at shutdown with HSW */
Signature · 1 line
2.25.1
PATCH 3/3 xhci: increase usb U3 -> U0 link resume timeout from 100ms to 500ms
In reply to Mathias NymanThe first U3 wake signal by the host may be lost if the USB 3 connection is tunneled over USB4, with a runtime suspended USB4 host, and firmware implemented connection manager.
Specs state the host must wait 100ms (tU3WakeupRetryDelay) before resending a U3 wake signal if device doesn't respond, leading to U3 -> U0 link transition times around 270ms in the tunneled case.
--- drivers/usb/host/xhci-hub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-hub.c +1 -1
@@ -1434,7 +1434,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, }spin_unlock_irqrestore (&xhci->lock, flags);if (!wait_for_completion_timeout (&bus_state->u3exit_done[wIndex], -msecs_to_jiffies (100 ))) +msecs_to_jiffies (500 )))xhci_dbg (xhci,"missing U0 port change event for port %d-%d\n" , hcd->self.busnum, wIndex +1 );spin_lock_irqsave (&xhci->lock, flags);
Signature · 1 line
2.25.1