Date: Thu, 26 May 2005 21:08:07 GMT From: Darren Pilgrim <dmp@bitfreak.org> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/81533: /usr/sbin/usbd has MAXUSBDEV set too low, resulting not all /dev/usb* being opened and subsequent attach failures. Message-ID: <200505262108.j4QL87T2087354@www.freebsd.org> Resent-Message-ID: <200505262110.j4QLA1eT064756@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 81533 >Category: bin >Synopsis: /usr/sbin/usbd has MAXUSBDEV set too low, resulting not all /dev/usb* being opened and subsequent attach failures. >Confidential: no >Severity: critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu May 26 21:10:01 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Darren Pilgrim >Release: 6.0-CURRENT >Organization: n/a >Environment: FreeBSD Smiley.Blackthornes.LAN 6.0-CURRENT FreeBSD 6.0-CURRENT #0: Sun May 22 18:51:16 PDT 2005 root@Sonomago.loki.lan:/usr/obj/usr/src/sys/Sonomago i386 >Description: In order to watch for events, usbd opens the /dev/usb* devices. usbd uses a #define called MAXUSBDEV to size arrays used in opening the USB bus devices. As the name of the constant implies, usbd will not open more than MAXUSBDEV /dev/usb* devices. Presently, MAXUSBDEV is set to 4. Modern hardware is trending toward four or more USB 2.0 ports using a one-hub-per-port configuration on the motherboard to increase performance. As such, the current value for MAXUSBDEV is no longer sufficient. When a device is plugged into a bus not being watched by usbd, the event is not caught and the attach procedure it not performed. This is further complicated by the dual-hub nature of USB 2.0. Because of this odd design, it is possible for usbd to be watching the USB 1.1 hub for a port, but not the USB 2.0 hub or vice versa. When a USB device is connected to such a port, the results are unpredicatable. The author was able to reliably produce panics in this scenario by plugging and unplugging an external USB 2.0 hub. >How-To-Repeat: The problem can be observed on any machine with at least four USB 2.0 ports or five USB 1.1 ports or any other combination that would produce at least five /dev/usb* devices. Use fstat to look at the files usbd has open and note that only /dev/usb0, /dev/usb1, /dev/usb2 and /dev/usb3 are open despite the presence of /dev/usb4 and (possibly) higher-numbered devices. Plugging devices into the unwatched or partially-watched hubs will result in missing or erroneous attach behavior. WARNING: You may panic your system trying this! >Fix: Increasing MAXUSBDEV to at least the number of USB hubs present results in proper operation of usbd for all USB busses. The following patch to src/usr.sbin/usbd/usbd.c v1.31 increases MAXUSBDEV to 40: --- usbd.c.orig Mon Jan 3 22:45:41 2005 +++ usbd.c Wed May 25 20:52:01 2005 @@ -81,7 +81,7 @@ /* Maximum number of USB busses expected to be in a system * XXX should be replaced by dynamic allocation. */ -#define MAXUSBDEV 4 +#define MAXUSBDEV 40 /* Sometimes a device does not respond in time for interrupt * driven explore to find it. Therefore we run an exploration >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200505262108.j4QL87T2087354>