Date: Mon, 29 Aug 2011 16:25:08 +0300 From: Andriy Gapon <avg@FreeBSD.org> To: Hans Petter Selasky <hselasky@FreeBSD.org> Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r223989 - head/sys/dev/usb/input Message-ID: <4E5B9334.5020502@FreeBSD.org> In-Reply-To: <201107132107.p6DL7ojq099900@svn.freebsd.org> References: <201107132107.p6DL7ojq099900@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
on 14/07/2011 00:07 Hans Petter Selasky said the following: > Author: hselasky > Date: Wed Jul 13 21:07:50 2011 > New Revision: 223989 > URL: http://svn.freebsd.org/changeset/base/223989 > > Log: > Fix for dump after shutdown with USB keyboard plugged in. It appears that the > system timer is stopped during shutdown and that the pause() statement in ukbd > causes infinite hang in this regard. The fix is to use mi_switch() instead of > pause() to do the required task switch to ensure that the required USB processes > get executed. > > Reported by: Mike_Karels@mcafee.com > MFC after: 1 week > > Modified: > head/sys/dev/usb/input/ukbd.c > > Modified: head/sys/dev/usb/input/ukbd.c > ============================================================================== > --- head/sys/dev/usb/input/ukbd.c Wed Jul 13 21:07:41 2011 (r223988) > +++ head/sys/dev/usb/input/ukbd.c Wed Jul 13 21:07:50 2011 (r223989) > @@ -59,6 +59,8 @@ __FBSDID("$FreeBSD$"); > #include <sys/callout.h> > #include <sys/malloc.h> > #include <sys/priv.h> > +#include <sys/proc.h> > +#include <sys/sched.h> > #include <sys/kdb.h> > > #include <dev/usb/usb.h> > @@ -386,6 +388,33 @@ ukbd_put_key(struct ukbd_softc *sc, uint > } > > static void > +ukbd_yield(void) > +{ > + struct thread *td = curthread; > + uint32_t old_prio; > + > + DROP_GIANT(); > + > + thread_lock(td); > + > + /* get current priority */ > + old_prio = td->td_base_pri; > + > + /* set new priority */ > + sched_prio(td, td->td_user_pri); > + > + /* cause a task switch */ > + mi_switch(SW_INVOL | SWT_RELINQUISH, NULL); > + > + /* restore priority */ > + sched_prio(td, old_prio); > + > + thread_unlock(td); > + > + PICKUP_GIANT(); > +} > + Another question - why ukbd_yield() is needed? Why kern_yield() would not be good here? What are the priority manipulations in ukbd_yield? Not saying that the code is incorrect, just that this is not explained in the commit message. -- Andriy Gapon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E5B9334.5020502>