Date: Wed, 20 Jul 2011 04:57:40 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r224223 - stable/8/sys/dev/usb/input Message-ID: <201107200457.p6K4vets001681@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Wed Jul 20 04:57:40 2011 New Revision: 224223 URL: http://svn.freebsd.org/changeset/base/224223 Log: MFC r223989: Fix for dump after shutdown with USB keyboard plugged in. Modified: stable/8/sys/dev/usb/input/ukbd.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/usb/input/ukbd.c ============================================================================== --- stable/8/sys/dev/usb/input/ukbd.c Wed Jul 20 00:36:47 2011 (r224222) +++ stable/8/sys/dev/usb/input/ukbd.c Wed Jul 20 04:57:40 2011 (r224223) @@ -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(); +} + +static void ukbd_do_poll(struct ukbd_softc *sc, uint8_t wait) { DPRINTFN(2, "polling\n"); @@ -396,8 +425,9 @@ ukbd_do_poll(struct ukbd_softc *sc, uint if (kdb_active == 0) { while (sc->sc_inputs == 0) { - /* make sure the USB code gets a chance to run */ - pause("UKBD", 1); + + /* give USB threads a chance to run */ + ukbd_yield(); /* check if we should wait */ if (!wait)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107200457.p6K4vets001681>