From owner-freebsd-stable@FreeBSD.ORG Thu Mar 18 21:29:26 2004 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0D59716A4CE for ; Thu, 18 Mar 2004 21:29:26 -0800 (PST) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id DFAA543D46 for ; Thu, 18 Mar 2004 21:29:25 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) i2J5TN82083921; Thu, 18 Mar 2004 21:29:23 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.9p2/8.12.9/Submit) id i2J5TLXs083918; Thu, 18 Mar 2004 21:29:21 -0800 (PST) (envelope-from dillon) Date: Thu, 18 Mar 2004 21:29:21 -0800 (PST) From: Matthew Dillon Message-Id: <200403190529.i2J5TLXs083918@apollo.backplane.com> To: Julian Elischer cc: freebsd-stable@freebsd.org cc: Anthony Wood Subject: USB bug fix for DETACH message. X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Mar 2004 05:29:26 -0000 A DragonFly user noticed that usbd does not seem to get DETACH events for UMASS devices. I tracked this down (in the FreeBSD-5 codebase for your convenience) to line 1382 of usb_subr.c: /*usbd_add_dev_event(USB_EVENT_DEVICE_DETACH, dev);*/ This line was apparently commented out by wpaul in rev 1.22, in January 2000. NetBSD has this line uncommented... that is, activated, and they recently committed a bug fix (1.110 I believe in the NetBSD source tree) that solves the problem I'm sure wpaul encountered that caused him to comment the line out. The bug fix is trivial. Just above this code, around line 1378, you simply need to NULL out dev->subdevs[i] after detaching it: printf(" port %d", up->portno); printf(" (addr %d) disconnected\n", dev->address); config_detach(dev->subdevs[i], DETACH_FORCE); dev->subdevs[i] = NULL; <<<<<<<<<<<<<<<<<< ADDME If you want DETACH events to work, uncomment the add_dev_event and make the bug fix above and DETACH events will work again. If you are going to do this, please do this in both FreeBSD-5.x and FreeBSD-4.x. You may also wish to commit NetBSD's 1.111 of sub_subr.c, which reorders an address assignment to work around certain non-compliant USB devices and allow them to work. The NetBSD repository can be accessed via CVS using the server string ':pserver:anoncvs@anoncvs.netbsd.org:/cvsroot' (don't accidently overwrite your FBsd tree, though! :-)). -Matt