Date: Wed, 23 Jan 2008 21:40:13 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 133951 for review Message-ID: <200801232140.m0NLeDk0006677@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=133951 Change 133951 by hselasky@hselasky_laptop001 on 2008/01/23 21:40:11 More advanced USB sysctls for USB device stress testing. The sysctls are only available when USB is compiled having USB_DEBUG defined. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_requests.c#18 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_requests.c#18 (text+ko) ==== @@ -50,6 +50,16 @@ #include <dev/usb/usb_quirks.h> #include <dev/usb/usb_hid.h> +#ifdef USB_DEBUG +static int usb_pr_poll_delay = USB_PORT_RESET_DELAY; +static int usb_pr_recovery_delay = USB_PORT_RESET_RECOVERY; + +SYSCTL_INT(_hw_usb, OID_AUTO, pr_poll_delay, CTLFLAG_RW, + &usb_pr_poll_delay, 0, "USB port reset poll delay in ms"); +SYSCTL_INT(_hw_usb, OID_AUTO, pr_recovery_delay, CTLFLAG_RW, + &usb_pr_recovery_delay, 0, "USB port reset recovery delay in ms"); +#endif + /*------------------------------------------------------------------------* * usbreq_reset_port *------------------------------------------------------------------------*/ @@ -58,16 +68,41 @@ { usb_port_status_t ps; usbd_status_t err; - uint8_t n; + uint16_t n; + +#ifdef USB_DEBUG + uint16_t pr_poll_delay; + uint16_t pr_recovery_delay; +#endif err = usbreq_set_port_feature(udev, mtx, port, UHF_PORT_RESET); if (err) { goto done; } - for (n = 12; n != 0; n--) { - +#ifdef USB_DEBUG + /* range check input parameters */ + pr_poll_delay = usb_pr_poll_delay; + if (pr_poll_delay < 1) { + pr_poll_delay = 1; + } else if (pr_poll_delay > 1000) { + pr_poll_delay = 1000; + } + pr_recovery_delay = usb_pr_recovery_delay; + if (pr_recovery_delay > 1000) { + pr_recovery_delay = 1000; + } +#endif + n = 0; + while (1) { +#ifdef USB_DEBUG + /* wait for the device to recover from reset */ + usbd_pause_mtx(mtx, pr_poll_delay); + n += pr_poll_delay; +#else /* wait for the device to recover from reset */ usbd_pause_mtx(mtx, USB_PORT_RESET_DELAY); + n += USB_PORT_RESET_DELAY; +#endif err = usbreq_get_port_status(udev, mtx, &ps, port); if (err) { goto done; @@ -80,6 +115,11 @@ if (UGETW(ps.wPortChange) & UPS_C_PORT_RESET) { break; } + /* check for timeout */ + if (n > 1000) { + n = 0; + break; + } } /* clear port reset first */ @@ -93,8 +133,14 @@ err = USBD_ERR_TIMEOUT; goto done; } +#ifdef USB_DEBUG + /* wait for the device to recover from reset */ + usbd_pause_mtx(mtx, pr_recovery_delay); +#else /* wait for the device to recover from reset */ usbd_pause_mtx(mtx, USB_PORT_RESET_RECOVERY); +#endif + done: PRINTFN(1, ("port %d reset returning error=%s\n", port, usbd_errstr(err)));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801232140.m0NLeDk0006677>