From owner-freebsd-current@FreeBSD.ORG Thu Dec 30 18:20:21 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0249816A4CE for ; Thu, 30 Dec 2004 18:20:21 +0000 (GMT) Received: from harmony.village.org (rover.village.org [168.103.84.182]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5A53243D39 for ; Thu, 30 Dec 2004 18:20:20 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.13.1/8.13.1) with ESMTP id iBUIGOFT010775; Thu, 30 Dec 2004 11:17:19 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Thu, 30 Dec 2004 11:16:31 -0700 (MST) Message-Id: <20041230.111631.13597845.imp@bsdimp.com> To: jb@cimlogic.com.au From: "M. Warner Losh" In-Reply-To: <20041228010938.GA39686@freebsd3.cimlogic.com.au> References: <20041228010938.GA39686@freebsd3.cimlogic.com.au> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: current@freebsd.org Subject: Re: USB problems X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Dec 2004 18:20:21 -0000 In message: <20041228010938.GA39686@freebsd3.cimlogic.com.au> John Birrell writes: : 1. The USB sub-system doesn't handle loading and unloading drivers properly. : If a driver is unloaded when a USB device is still attached, the next : time the driver is loaded, the kernel panics. This might not be such : a problem to normal users because they don't have a need to do that, but : during driver development when you want to load and unload repeatedly, : it's a pain. I don't see this. Can you give a more concrete example? I've done work in this area and I believe that it is almost working correctly. : 3. The usbd_bulk_transfer function calls tsleep() to wait for streaming : data to become available. On current, this bumps into a KASSERT in : msleep because Giant is not locked and no mutex has been supplied. : In my driver, I need to run an 'encoder' thread which calls : usbd_bulk_transfer() to gobble the incoming MPEG data stream. While : this is going on, there is no syscall in progress because the : application is off doing other things. It might be looking at the : mmaped buffer or it may not. : : For FreeBSD, usbd_bulk_transfer() needs to change to allow the driver : to specify it's mutex. I don't know what the implications are for : uhci given that it hasn't been converted to use mutexes. Can anyone : comment on that? I have changes to make sure this can't happen as well. But you must hold Giant whenever you call into the usb subsystem. : I'd love to get rid of the attach_args structure and just pass a : usbd_device_handle into the drivers, with struct usbd_device containing : a couple of extra variables for use during matching. I'd love to remove that attach_args and replace it with nothing. : I'd like to remove the subdevs array from struct usbd_device under : FreeBSD because the parent/child device tree should only be managed by : bus routines. The relationship between a USB device and it's device_t : should just be a field in struct usbd_device and it should be cleared : when there is no device_t. Leaving a device_t hanging around when a : driver had been unloaded is what is causing the panics I am seeing. I'm working on this. However, many of the panics around this area were fixed just before 5.3. : I think that the uhub driver should have a uhub_driver_added routine rather : than using the generic one. I'd really like to see the uhub code re-match : vendor/product codes when a new driver is added, and if the new driver : matches, then uhub should detach ugen and use the new driver. Similarly, : when a driver is unloaded, if a USB device is still present, it should go : back to ugen. I already deal with these things, are you sure you're looking at the current code? Well, I Don't deal with ugen, but when I have to load drivers I don't include it in my kernel. There's no harm in that. I'm working on a generic newbus way of dealing with this situation, but acpi does non-idempotent things in its probe routines :-(. Warner