From owner-freebsd-usb@FreeBSD.ORG Mon Dec 19 15:06:21 2011 Return-Path: Delivered-To: freebsd-usb@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F7E61065680; Mon, 19 Dec 2011 15:06:21 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 57ABA8FC0A; Mon, 19 Dec 2011 15:06:19 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id RAA08656; Mon, 19 Dec 2011 17:06:15 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1Rcen9-000G52-8n; Mon, 19 Dec 2011 17:06:15 +0200 Message-ID: <4EEF52E5.8020102@FreeBSD.org> Date: Mon, 19 Dec 2011 17:06:13 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:8.0) Gecko/20111206 Thunderbird/8.0 MIME-Version: 1.0 To: Hans Petter Selasky References: <4EEF2B11.6080802@FreeBSD.org> <201112191530.40526.hselasky@c2i.net> In-Reply-To: <201112191530.40526.hselasky@c2i.net> X-Enigmail-Version: undefined Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: FreeBSD current , "freebsd-usb@FreeBSD.org" Subject: Re: a few usb issues related to edge cases X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Dec 2011 15:06:21 -0000 First replying just to couple of points where there seems to be a misunderstanding. on 19/12/2011 16:30 Hans Petter Selasky said the following: >> 2. Somewhat related to the above. I think that because the USB subsystem >> implements the shutdown method and detaches all its drivers, then the ukbd >> driver won't be able to properly handle the 'shutdown -h' case where the >> kernel asks to "press any key to reboot" at the end. Depending on which >> thread wins the race (the one that executes the mainline shutdown code or >> the USB explore thread that detaches USB devices) there will either an >> immediate reboot or a later crash when any key is pressed. >> This is not critical, but OTOH perhaps the USB subsystem doesn't have to do >> the shutdown. As far as I can see a lot of the drivers just do nothing >> for the shutdown, for better or for worth. >> >> A side note: perhaps it would be a good idea to pass the 'how' value as an >> additional parameter to device_shutdown. > > The shutdown of USB is done to give USB devices at last chance to turn off or > reduce their current consumption. > > In the old code the Host controller itself would be disabled, so keyboard > wouldn't have worked I believe like you suggest. I am not sure about the old code, I have never checked it. But the atkbd definitely works at this stage. > BTW: Shutdown should be executed after any "Press any key to reboot." and > shutdown should be given time to complete, hence for USB this needs to happen > in sync with the rest of the USB system. Have you actually ever done "shutdown -h"? In other words do you know what the "system halt" is? :) I am not sure if it would be a good idea to declare a system as "halted" before shutdown_final hooks are executed. I would rather sacrifice the whole "press a key" interactivity and simply executed hlt. That's because I think that the system halt has a very limited usage, mostly in combination with UPS, where interactivity via console/keyboard is not very important. BTW, the reason that I suggested to pass 'how' to device_shutdown is to give drivers some choice. E.g. USB could the whole shutdown thing for the cases of poweroff and reboot, but keep the devices going for halt. But probably right now we just need to make a decision whether ukbd is going to support system halt or not. If not, then I think that usb_shutdown() must wait until the explore_proc terminates. If yes, then usb_shutdown() should become a noop. Or it could become quite smart to detach/poweroff other devices in such a way that ukbd still stays usable. But that's probably harder to implement. [snip] >> As a side note: we probably need a flag to mark certain things such as e.g. >> the ukbd driver as "non recoverable", meaning that once those are used in >> the kdb context then there is no safe way to go back to normal system >> operation. > > I think you need to do shutdown _after_ the "Press any key to reboot". A flag > won't help. Umm, this suggestion was about entering and exiting KDB/DDB, not about shutdown/reboot. P.S. I've just looked at the code in stable/7 and it seems that it didn't actually unconfigured USB and detached device drivers. At least ohci_shutdown and ohci_shutdown are not called on FreeBSD. -- Andriy Gapon