[PATCH v2 1/4] xhci.c: Add retry in xhci_address_device()

Jason Wessel jason.wessel at windriver.com
Mon Sep 14 04:39:18 CEST 2020


After a port reset some usb keyboard devices do not respond
immediately, and instead the controller reports COMP_TX_ERR.  Adding a
retry after the first TX error is returned resolves the issue.

Without the patch u-boot prints:

   Starting the controller
   USB XHCI 1.00
   scanning bus xhci_pci for devices... Device not responding to set address.

         USB device not accepting new address (error=80000000)

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
---
 drivers/usb/host/xhci.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 126dabc11b..9a31eba2bb 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -675,6 +675,7 @@ static int xhci_address_device(struct usb_device *udev, int root_portnr)
 	struct xhci_virt_device *virt_dev;
 	int slot_id = udev->slot_id;
 	union xhci_trb *event;
+	int retry_cnt = 0;
 
 	virt_dev = ctrl->devs[slot_id];
 
@@ -685,6 +686,7 @@ static int xhci_address_device(struct usb_device *udev, int root_portnr)
 	debug("Setting up addressable devices %p\n", ctrl->dcbaa);
 	xhci_setup_addressable_virt_dev(ctrl, udev, root_portnr);
 
+retry:
 	ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx);
 	ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG | EP0_FLAG);
 	ctrl_ctx->drop_flags = 0;
@@ -701,6 +703,13 @@ static int xhci_address_device(struct usb_device *udev, int root_portnr)
 		ret = -EINVAL;
 		break;
 	case COMP_TX_ERR:
+		retry_cnt++;
+		if (retry_cnt < 2) {
+			/* Retry in case this was just after a port reset */
+			debug("COMP_TX_ERR retry\n");
+			xhci_acknowledge_event(ctrl);
+			goto retry;
+		}
 		puts("Device not responding to set address.\n");
 		ret = -EPROTO;
 		break;
-- 
2.17.1



More information about the U-Boot mailing list