xhci fixes for usb-linus
Subsystems (3)
cover xhci fixes for usb-linus
Hi Greg
A few xhci fixes for usb-linus.
This series makes sure we don't ignore devices attached during suspend that are stuck in a resume "cold attach status" state, and makes sure xhci driver doesn't prevent queuing urbs to a endpoint only because driver previously refused to manually clear the data toggle of a non-empty endpoint.
-Mathias
Ding Hui (1):
xhci: Always restore EP_SOFT_CLEAR_TOGGLE even if ep reset failed
Kai-Heng Feng (1):
xhci: Do warm-reset when both CAS and XDEV_RESUME are set
Li Jun (1):
usb: host: xhci: fix ep context print mismatch in debugfs
drivers/usb/host/xhci-debugfs.c | 8 ++++---- drivers/usb/host/xhci-hub.c | 19 ++++++++++--------- drivers/usb/host/xhci.c | 3 ++- 3 files changed, 16 insertions(+), 14 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 usb: host: xhci: fix ep context print mismatch in debugfs
From: Li Jun <[email protected]>
dci is 0 based and xhci_get_ep_ctx() will do ep index increment to get the ep context.
--- drivers/usb/host/xhci-debugfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-debugfs.c +4 -4
@@ -274,7 +274,7 @@ static int xhci_slot_context_show(struct seq_file *s, void *unused)static int xhci_endpoint_context_show (struct seq_file *s,void *unused) { -int dci; +int ep_index;dma_addr_t dma;struct xhci_hcd *xhci;struct xhci_ep_ctx *ep_ctx;
@@ -283,9 +283,9 @@ static int xhci_endpoint_context_show(struct seq_file *s, void *unused) xhci =hcd_to_xhci (bus_to_hcd (dev->udev->bus)); -for (dci =1 ; dci <32 ; dci++) { - ep_ctx =xhci_get_ep_ctx (xhci, dev->out_ctx, dci); - dma = dev->out_ctx->dma + dci *CTX_SIZE (xhci->hcc_params); +for (ep_index =0 ; ep_index <31 ; ep_index++) { + ep_ctx =xhci_get_ep_ctx (xhci, dev->out_ctx, ep_index); + dma = dev->out_ctx->dma + (ep_index +1 ) *CTX_SIZE (xhci->hcc_params); seq_printf(s, "%pad: %s\n", &dma, xhci_decode_ep_context(le32_to_cpu(ep_ctx->ep_info), le32_to_cpu(ep_ctx->ep_info2),
Signature · 1 line
2.17.1
PATCH 2/3 xhci: Do warm-reset when both CAS and XDEV_RESUME are set
In reply to Mathias NymanFrom: Kai-Heng Feng <[email protected]>
Sometimes re-plugging a USB device during system sleep renders the device useless:
[ 173.418345] xhci_hcd 0000:00:14.0: Get port status 2-4 read: 0x14203e2, return 0x10262 ... [ 176.496485] usb 2-4: Waited 2000ms for CONNECT [ 176.496781] usb usb2-port4: status 0000.0262 after resume, -19 [ 176.497103] usb 2-4: can't resume, status -19 [ 176.497438] usb usb2-port4: logical disconnect
Because PLS equals to XDEV_RESUME, xHCI driver reports U3 to usbcore, despite of CAS bit is flagged.
So proritize CAS over XDEV_RESUME to let usbcore handle warm-reset for the port.
--- drivers/usb/host/xhci-hub.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/usb/host/xhci-hub.c +10 -9
@@ -740,15 +740,6 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci, {u32 pls = status_reg &PORT_PLS_MASK ; -/* resume state is a xHCI internal state. -* Do not report it to usb core, instead, pretend to be U3, -* thus usb core knows it's not ready for transfer -*/ -if (pls ==XDEV_RESUME ) { - *status |=USB_SS_PORT_LS_U3 ; -return ; - } -/* When the CAS bit is set then warm reset * should be performed on port */
@@ -770,6 +761,16 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci,*/ pls |=USB_PORT_STAT_CONNECTION ; }else { +/* +* Resume state is an xHCI internal state. Do not report it to +* usb core, instead, pretend to be U3, thus usb core knows +* it's not ready for transfer. +*/ +if (pls ==XDEV_RESUME ) { + *status |=USB_SS_PORT_LS_U3 ; +return ; + } +/* * If CAS bit isn't set but the Port is already at * Compliance Mode, fake a connection so the USB core
Signature · 1 line
2.17.1
PATCH 3/3 xhci: Always restore EP_SOFT_CLEAR_TOGGLE even if ep reset failed
In reply to Mathias NymanFrom: Ding Hui <[email protected]>
Some device drivers call libusb_clear_halt when target ep queue is not empty. (eg. spice client connected to qemu for usb redir)
Before commit f5249461b504 ("xhci: Clear the host side toggle manually when endpoint is soft reset"), that works well. But now, we got the error log:
EP not empty, refuse reset
xhci_endpoint_reset failed and left ep_state's EP_SOFT_CLEAR_TOGGLE bit still set
So all the subsequent urb sumbits to the ep will fail with the warn log:
Can't enqueue URB while manually clearing toggle
We need to clear ep_state EP_SOFT_CLEAR_TOGGLE bit after xhci_endpoint_reset, even if it failed.
--- drivers/usb/host/xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/xhci.c +2 -1
@@ -3236,10 +3236,11 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd,wait_for_completion (cfg_cmd->completion); - ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE ;xhci_free_command (xhci, cfg_cmd); cleanup:xhci_free_command (xhci, stop_cmd); +if (ep->ep_state &EP_SOFT_CLEAR_TOGGLE ) + ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE ; } static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,
Signature · 1 line
2.17.1
Greg KH
maintainerRe: [PATCH 3/3] xhci: Always restore EP_SOFT_CLEAR_TOGGLE even if ep reset failed
Quoted 17 lines · Mathias Nyman
From: Ding Hui <[email protected]>
Some device drivers call
libusb_clear_haltwhen target ep queue is not empty. (eg. spice client connected to qemu for usb redir)Before commit
f5249461b504("xhci: Clear the host side toggle manually when endpoint is soft reset"), that works well. But now, we got the error log:EP not empty, refuse reset
xhci_endpoint_resetfailed and left ep_state'sEP_SOFT_CLEAR_TOGGLEbit still setSo all the subsequent urb sumbits to the ep will fail with the warn log:
Quoted 6 lines
Can't enqueue URB while manually clearing toggle
We need to clear
ep_stateEP_SOFT_CLEAR_TOGGLEbit afterxhci_endpoint_reset, even if it failed.Fixes f5249461b504 ("xhci: Clear the host side toggle manually when endpoint is soft reset"
Nit, you forgot the trailing ')' here...
Re: [PATCH 3/3] xhci: Always restore EP_SOFT_CLEAR_TOGGLE even if ep reset failed
Quoted 18 lines · Greg KH
Quoted 17 lines · Mathias Nyman
From: Ding Hui <[email protected]>
Some device drivers call
libusb_clear_haltwhen target ep queue is not empty. (eg. spice client connected to qemu for usb redir)Before commit
f5249461b504("xhci: Clear the host side toggle manually when endpoint is soft reset"), that works well. But now, we got the error log:EP not empty, refuse reset
xhci_endpoint_resetfailed and left ep_state'sEP_SOFT_CLEAR_TOGGLEbit still setSo all the subsequent urb sumbits to the ep will fail with the warn log:
Quoted 9 lines
Quoted 6 lines
Can't enqueue URB while manually clearing toggle
We need to clear
ep_stateEP_SOFT_CLEAR_TOGGLEbit afterxhci_endpoint_reset, even if it failed.Fixes f5249461b504 ("xhci: Clear the host side toggle manually when endpoint is soft reset"Nit, you forgot the trailing ')' here...
Argh, I had one job..
Odd that checkpatch didn't catch that.
Thanks for fixing and applying
-Mathias