From owner-freebsd-current@FreeBSD.ORG Wed Jan 7 18:32:14 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 3B30116A4CE for ; Wed, 7 Jan 2004 18:32:14 -0800 (PST) Received: from python.evilrealms.net (evilrealms.demon.co.uk [62.49.12.231]) by mx1.FreeBSD.org (Postfix) with ESMTP id CD7B043D67 for ; Wed, 7 Jan 2004 18:32:11 -0800 (PST) (envelope-from jay@evilrealms.net) Received: from evilrealms.net (viper.evilrealms.net [192.168.1.2]) by python.evilrealms.net (Postfix) with ESMTP id 25A765CC5; Thu, 8 Jan 2004 02:31:59 +0000 (GMT) Message-ID: <3FFCC12A.7030609@evilrealms.net> Date: Thu, 08 Jan 2004 02:32:10 +0000 From: Jay Cornwall User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Martin References: <3FFB4150.2020601@evilrealms.net> <3FFB41DE.7030607@evilrealms.net> <1073497253.715.27.camel@klotz.local> In-Reply-To: <1073497253.715.27.camel@klotz.local> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: FreeBSD Current Subject: Re: [PATCH] Fix for USB ugen panics 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, 08 Jan 2004 02:32:14 -0000 Martin wrote: > Good news: the panic is gone. :D But I managed to test this with my Speedtouch USB modem, so no surprises there. ;) > I'm _trying_ to write a small capture program for my webcam > (Creative Videoblaster Webcam Go). I'm not very successful. > I managed to get a stream of black(?) pixels from my webcam, > using the so-called isochronous transfer mode. The program is > called "camtest". > > I was doing some experiments with ugen to check out why only > black pixels are coming from the interface and so I tried out > a sysctl "USB_SET_CONFIG". That caused a panic instantly. > I removed all unnecessary code around the sysctl-call to > submit a PR and called the program "camtest-panic". Yep, the panic was caused by ugen not expecting to be asked to USB_SET_CONFIG a value of zero. > - you can start "camtest" as many times as you want after > fresh reboot and the isochronous transfer can be established > successfully Correct. > - after starting "camtest-panic", first time there is no error At this point, you've called USB_SET_CONFIG with a value of 0. This value is reserved as a way to put the device into the "unconfigured" state. From here (as I was discussing with Bernd on freebsd-hackers@), the only way to leave the state is to either reset the USB hub or detach/reattach the device. > - after starting "camtest-panic" only one time, you will not > get past the sysctl-call "USB_SET_ALTINTERFACE" in "camtest", > it stops with the message (from perror): "Invalid argument" Correct, according to the USB spec interfaces are unavailable when the device is in the "unconfigured" state. > - after starting "camtest-panic" first time, you get an error > when starting it (e.a. "camtest-panic") more times after the > sysctl-call "USB_SET_CONFIG", it stops with the message > (perror): "Input/output error" The device is in configuration zero at this point. No further configuration changes can be made now, until the device has been put back into the "configured" state. As discussed in the post to freebsd-hackers@, both I and Bernd think that USB_SET_CONFIG probably shouldn't let the user set configuration zero in case it happens accidentally. But I haven't disallowed this in the patch until I've got in touch with the USB stack developer, and confirmed that would be sensible behaviour. > I hope you can see from my description that there is still > something weird going on with ugen. I wish I could help, but > I don't know much about USB and just started my first program. > It just looks for me like there is something not being > cleaned up correctly after the USB_SET_CONFIG-sysctl in > "camtest-panic". I think you're on the right lines, but all that's going wrong is setting the device configuration to zero. You need to look up the technical specs for your USB webcam to see which configurations are available, and what interfaces and endpoints are available in each configuration. If it says that configuration zero is an acceptable configuration, then I'm confused. :) Certainly my USB modem lets you set configuration 1, and operates correctly in that configuration. As it only has one configuration, I can only presume USB devices generally start from configuration 1 onwards. > Thanks for the patch, Thanks for testing it. :) -- Cheers, Jay http://www.evilrealms.net/ - Systems Administrator & Developer http://www.imperial.ac.uk/ - 3rd year CS student