diff options
author | jkim <jkim@FreeBSD.org> | 2012-02-08 20:31:42 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2012-02-08 20:31:42 +0000 |
commit | 234d88c28880ea3d9014955d1d8c6d90d043c878 (patch) | |
tree | abb6b7995319484efdf7ea41ba66f289b0c56d77 | |
parent | 2622c5d01eccafbd6a0c3dfd4a4ab839f612244a (diff) | |
download | FreeBSD-src-234d88c28880ea3d9014955d1d8c6d90d043c878.zip FreeBSD-src-234d88c28880ea3d9014955d1d8c6d90d043c878.tar.gz |
Revert r211288 and move the logic to the acpi_timer itself.
-rwxr-xr-x | etc/rc.resume | 6 | ||||
-rwxr-xr-x | etc/rc.suspend | 12 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_timer.c | 48 |
3 files changed, 48 insertions, 18 deletions
diff --git a/etc/rc.resume b/etc/rc.resume index 3b2e970..b68f981 100755 --- a/etc/rc.resume +++ b/etc/rc.resume @@ -43,12 +43,6 @@ if [ -r /var/run/rc.suspend.pid ]; then echo 'rc.resume: killed rc.suspend that was still around' fi -if [ -r /var/run/rc.suspend.tch ]; then - _t=`cat /var/run/rc.suspend.tch` - /sbin/sysctl -n kern.timecounter.hardware=$_t > /dev/null 2>&1 - /bin/rm -f /var/run/rc.suspend.tch -fi - if [ -r /var/run/moused.pid ]; then pkill -HUP -F /var/run/moused.pid fi diff --git a/etc/rc.suspend b/etc/rc.suspend index 90c085b..5f22cd1 100755 --- a/etc/rc.suspend +++ b/etc/rc.suspend @@ -43,18 +43,6 @@ fi echo $$ 2> /dev/null > /var/run/rc.suspend.pid -_t=`/sbin/sysctl -n kern.timecounter.hardware 2> /dev/null` -case ${_t#ACPI-} in -fast|safe) - /bin/rm -f /var/run/rc.suspend.tch - ;; -*) - { /sbin/sysctl -n kern.timecounter.hardware=ACPI-fast || \ - /sbin/sysctl -n kern.timecounter.hardware=ACPI-safe; } \ - > /dev/null 2>&1 && echo $_t > /var/run/rc.suspend.tch - ;; -esac - # If you have troubles on suspending with PC-CARD modem, try this. # See also contrib/pccardq.c (Only for PAO users). # pccardq | awk -F '~' '$5 == "filled" && $4 ~ /uart/ \ diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c index ce8551f..c330eb1 100644 --- a/sys/dev/acpica/acpi_timer.c +++ b/sys/dev/acpica/acpi_timer.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include "opt_acpi.h" #include <sys/param.h> #include <sys/bus.h> +#include <sys/eventhandler.h> #include <sys/kernel.h> #include <sys/module.h> #include <sys/sysctl.h> @@ -60,12 +61,15 @@ static device_t acpi_timer_dev; static struct resource *acpi_timer_reg; static bus_space_handle_t acpi_timer_bsh; static bus_space_tag_t acpi_timer_bst; +static eventhandler_tag acpi_timer_eh; static u_int acpi_timer_frequency = 14318182 / 4; static void acpi_timer_identify(driver_t *driver, device_t parent); static int acpi_timer_probe(device_t dev); static int acpi_timer_attach(device_t dev); +static int acpi_timer_suspend(device_t); +static void acpi_timer_resume_handler(struct timecounter *); static u_int acpi_timer_get_timecount(struct timecounter *tc); static u_int acpi_timer_get_timecount_safe(struct timecounter *tc); static int acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS); @@ -77,6 +81,7 @@ static device_method_t acpi_timer_methods[] = { DEVMETHOD(device_identify, acpi_timer_identify), DEVMETHOD(device_probe, acpi_timer_probe), DEVMETHOD(device_attach, acpi_timer_attach), + DEVMETHOD(device_suspend, acpi_timer_suspend), {0, 0} }; @@ -247,6 +252,49 @@ acpi_timer_attach(device_t dev) return (0); } +static void +acpi_timer_resume_handler(struct timecounter *newtc) +{ + struct timecounter *tc; + + tc = timecounter; + if (tc != newtc) { + if (bootverbose) + device_printf(acpi_timer_dev, + "restoring timecounter, %s -> %s\n", + tc->tc_name, newtc->tc_name); + (void)newtc->tc_get_timecount(newtc); + (void)newtc->tc_get_timecount(newtc); + timecounter = newtc; + } +} + +static int +acpi_timer_suspend(device_t dev) +{ + struct timecounter *newtc, *tc; + int error; + + error = bus_generic_suspend(dev); + if (acpi_timer_eh != NULL) { + EVENTHANDLER_DEREGISTER(power_resume, acpi_timer_eh); + acpi_timer_eh = NULL; + } + tc = timecounter; + newtc = &acpi_timer_timecounter; + if (tc != newtc) { + if (bootverbose) + device_printf(dev, "switching timecounter, %s -> %s\n", + tc->tc_name, newtc->tc_name); + (void)acpi_timer_read(); + (void)acpi_timer_read(); + timecounter = newtc; + acpi_timer_eh = EVENTHANDLER_REGISTER(power_resume, + acpi_timer_resume_handler, tc, EVENTHANDLER_PRI_LAST); + } + return (error); +} + /* * Fetch current time value from reliable hardware. */ |