xhci fixes for usb-linus
Subsystems (3)
cover xhci fixes for usb-linus
Hi Greg
A couple small xhci fixes for usb-linus
Add Host controller error (HCE) to the list of reasons to reset the host during resume.
Also make sure we don't change the error value returned if URB submission fails.
Thanks
-Mathias
Hongyu Xie (1):
xhci: Prevent futile URB re-submissions due to incorrect return value.
Puma Hsu (1):
xhci: re-initialize the HC during resume if HCE was set
drivers/usb/host/xhci.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 xhci: re-initialize the HC during resume if HCE was set
From: Puma Hsu <[email protected]>
When HCE(Host Controller Error) is set, it means an internal error condition has been detected. Software needs to re-initialize the HC, so add this check in xhci resume.
--- drivers/usb/host/xhci.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/usb/host/xhci.c +13 -6
@@ -1091,6 +1091,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)int retval =0 ;bool comp_timer_running = false;bool pending_portevent = false; +bool reinit_xhc = false;if (!hcd->state)return 0 ;
@@ -1107,10 +1108,11 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)set_bit (HCD_FLAG_HW_ACCESSIBLE , &xhci->shared_hcd->flags);spin_lock_irq (&xhci->lock); -if ((xhci->quirks &XHCI_RESET_ON_RESUME ) || xhci->broken_suspend) - hibernated = true; -if (!hibernated) { +if (hibernated || xhci->quirks &XHCI_RESET_ON_RESUME || xhci->broken_suspend) + reinit_xhc = true; + +if (!reinit_xhc) {/* * Some controllers might lose power during suspend, so wait * for controller not ready bit to clear, just as in xHC init.
@@ -1143,12 +1145,17 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)spin_unlock_irq (&xhci->lock);return -ETIMEDOUT ; } - temp =readl (&xhci->op_regs->status); } -/* If restore operation fails, re-initialize the HC during resume */ -if ((temp &STS_SRE ) || hibernated) { + temp =readl (&xhci->op_regs->status); + +/* re-initialize the HC on Restore Error, or Host Controller Error */ +if (temp & (STS_SRE |STS_HCE )) { + reinit_xhc = true; +xhci_warn (xhci,"xHC error in resume, USBSTS 0x%x, Reinit\n" , temp); + } +if (reinit_xhc) {if ((xhci->quirks &XHCI_COMP_MODE_QUIRK ) && !(xhci_all_ports_seen_u0 (xhci))) {del_timer_sync (&xhci->comp_mode_recovery_timer);
Signature · 1 line
2.25.1
PATCH 2/2 xhci: Prevent futile URB re-submissions due to incorrect return value.
In reply to Mathias NymanFrom: Hongyu Xie <[email protected]>
The -ENODEV return value from xhci_check_args() is incorrectly changed to -EINVAL in a couple places before propagated further.
xhci_check_args() returns 4 types of value, -ENODEV, -EINVAL, 1 and 0. xhci_urb_enqueue and xhci_check_streams_endpoint return -EINVAL if the return value of xhci_check_args <= 0.
This causes problems for example r8152_submit_rx, calling usb_submit_urb in drivers/net/usb/r8152.c.r8152_submit_rx will never get -ENODEV after submiting an urb when xHC is halted because xhci_urb_enqueue returns -EINVAL in the very beginning.
--- drivers/usb/host/xhci.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/host/xhci.c +6 -3
@@ -1611,9 +1611,12 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flagstruct urb_priv *urb_priv;int num_tds; -if (!urb ||xhci_check_args (hcd, urb->dev, urb->ep, - true, true, __func__) <=0 ) +if (!urb)return -EINVAL ; + ret =xhci_check_args (hcd, urb->dev, urb->ep, + true, true, __func__); +if (ret <=0 ) +return ret ? ret : -EINVAL ; slot_id = urb->dev->slot_id; ep_index =xhci_get_endpoint_index (&urb->ep->desc);
@@ -3330,7 +3333,7 @@ static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,return -EINVAL ; ret =xhci_check_args (xhci_to_hcd (xhci), udev, ep,1 , true, __func__);if (ret <=0 ) -return -EINVAL ; +return ret ? ret : -EINVAL ;if (usb_ss_max_streams (&ep->ss_ep_comp) ==0 ) { xhci_warn(xhci, "WARN: SuperSpeed Endpoint Companion" " descriptor for ep 0x%x does not support streams\n",
Signature · 1 line
2.25.1