From bf2c693f893ab6f9458f1a4840c2a9cbbd4bb9f2 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Fri, 21 Jun 2019 16:39:59 -0600 Subject: libpayload/usb: Increase USB request timeout to 5 s Increase the timeout for USB requests to 5 seconds for all USB host controllers. Prior to this fix, the xCHI driver was detecting false timeouts during SET ADDRESS requests when nested downstream hubs were connected to the xHCI root hub. BUG=b:124730179 BRANCH=sarien TEST=Build libpayload and depthcharge on sarien/arcada. TEST=Without change replicate USB set address timeouts in depthcharge when dock and 4K monitor connected (which includes a total of 4 USB hubs). With timeout fix, depthcharge boots OS with no USB errors and the same USB topology. Note that this tests xHCI operation only. Change-Id: I53e3e67d893420e7c9e8b52c47dd0edb979e5468 Signed-off-by: Keith Short Reviewed-on: https://review.coreboot.org/c/coreboot/+/33671 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner --- payloads/libpayload/drivers/usb/uhci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'payloads/libpayload/drivers/usb/uhci.c') diff --git a/payloads/libpayload/drivers/usb/uhci.c b/payloads/libpayload/drivers/usb/uhci.c index e62fd25a2d..32d40901a0 100644 --- a/payloads/libpayload/drivers/usb/uhci.c +++ b/payloads/libpayload/drivers/usb/uhci.c @@ -272,21 +272,23 @@ uhci_stop (hci_t *controller) uhci_reg_read16(controller, USBCMD) & ~1); // stop work on schedule } +#define UHCI_SLEEP_TIME_US 30 +#define UHCI_TIMEOUT (USB_MAX_PROCESSING_TIME_US / UHCI_SLEEP_TIME_US) #define GET_TD(x) ((void*)(((unsigned int)(x))&~0xf)) static td_t * wait_for_completed_qh (hci_t *controller, qh_t *qh) { - int timeout = 1000; /* max 30 ms. */ + int timeout = UHCI_TIMEOUT; void *current = GET_TD (qh->elementlinkptr); while (((qh->elementlinkptr & FLISTP_TERMINATE) == 0) && (timeout-- > 0)) { if (current != GET_TD (qh->elementlinkptr)) { current = GET_TD (qh->elementlinkptr); - timeout = 1000; + timeout = UHCI_TIMEOUT; } uhci_reg_write16(controller, USBSTS, uhci_reg_read16(controller, USBSTS) | 0); // clear resettable registers - udelay (30); + udelay(UHCI_SLEEP_TIME_US); } return (GET_TD (qh->elementlinkptr) == 0) ? 0 : GET_TD (phys_to_virt (qh->elementlinkptr)); -- cgit v1.2.3