Module Name:    src
Committed By:   jmcneill
Date:           Sun Oct 10 20:10:12 UTC 2021

Modified Files:
        src/sys/dev/usb: xhci.c

Log Message:
xhci: shrink port reset delay

Instead of waiting for USB_PORT_ROOT_RESET_DELAY (250ms) before checking
the port reset status, poll the PORTSC register and return early if the
reset has completed.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.148 src/sys/dev/usb/xhci.c:1.149
--- src/sys/dev/usb/xhci.c:1.148	Tue Aug 17 22:00:32 2021
+++ src/sys/dev/usb/xhci.c	Sun Oct 10 20:10:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.148 2021/08/17 22:00:32 andvar Exp $	*/
+/*	$NetBSD: xhci.c,v 1.149 2021/10/10 20:10:12 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.148 2021/08/17 22:00:32 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.149 2021/10/10 20:10:12 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -4121,18 +4121,17 @@ xhci_roothub_ctrl(struct usbd_bus *bus, 
 			/* XXX suspend */
 			break;
 		case UHF_PORT_RESET:
-			v &= ~(XHCI_PS_PED | XHCI_PS_PR);
 			xhci_op_write_4(sc, port, v | XHCI_PS_PR);
 			/* Wait for reset to complete. */
-			usb_delay_ms(&sc->sc_bus, USB_PORT_ROOT_RESET_DELAY);
-			if (sc->sc_dying) {
-				return -1;
-			}
-			v = xhci_op_read_4(sc, port);
-			if (v & XHCI_PS_PR) {
-				xhci_op_write_4(sc, port, v & ~XHCI_PS_PR);
+			for (i = 0; i < USB_PORT_ROOT_RESET_DELAY / 10; i++) {
+				if (sc->sc_dying) {
+					return -1;
+				}
+				v = xhci_op_read_4(sc, port);
+				if ((v & XHCI_PS_PR) == 0) {
+					break;
+				}
 				usb_delay_ms(&sc->sc_bus, 10);
-				/* XXX */
 			}
 			break;
 		case UHF_PORT_POWER:

Reply via email to