From owner-freebsd-bugs@FreeBSD.ORG Thu May 26 21:10:02 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 89DC916A41C for ; Thu, 26 May 2005 21:10:02 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id B207E43D58 for ; Thu, 26 May 2005 21:10:01 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j4QLA1GN064759 for ; Thu, 26 May 2005 21:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j4QLA1eT064756; Thu, 26 May 2005 21:10:01 GMT (envelope-from gnats) Resent-Date: Thu, 26 May 2005 21:10:01 GMT Resent-Message-Id: <200505262110.j4QLA1eT064756@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Darren Pilgrim Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 50BCB16A41C for ; Thu, 26 May 2005 21:08:08 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0EBB943D48 for ; Thu, 26 May 2005 21:08:08 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j4QL87Oc087355 for ; Thu, 26 May 2005 21:08:07 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id j4QL87T2087354; Thu, 26 May 2005 21:08:07 GMT (envelope-from nobody) Message-Id: <200505262108.j4QL87T2087354@www.freebsd.org> Date: Thu, 26 May 2005 21:08:07 GMT From: Darren Pilgrim To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: bin/81533: /usr/sbin/usbd has MAXUSBDEV set too low, resulting not all /dev/usb* being opened and subsequent attach failures. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2005 21:10:02 -0000 >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: