On Monday 19 December 2011 16:06:13 Andriy Gapon wrote:
> 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.

ATKBD is no comparison to UKBD :-)

> > 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? :)

No, I'm usually "shutdown -p now".

> 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.

I see.

> 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.

I will fix that. I see a missing wait there. Can I assume that we are allowed 
to sleep from device_shutdown() and that system timers still work?

> 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.


freebsd-usb@freebsd.org mailing list
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"

Reply via email to