From owner-svn-src-head@FreeBSD.ORG Wed Feb 8 20:31:43 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 34AF51065670; Wed, 8 Feb 2012 20:31:43 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 183998FC08; Wed, 8 Feb 2012 20:31:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q18KVgfC062103; Wed, 8 Feb 2012 20:31:42 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q18KVgdC062099; Wed, 8 Feb 2012 20:31:42 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201202082031.q18KVgdC062099@svn.freebsd.org> From: Jung-uk Kim Date: Wed, 8 Feb 2012 20:31:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r231226 - in head: etc sys/dev/acpica X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Feb 2012 20:31:43 -0000 Author: jkim Date: Wed Feb 8 20:31:42 2012 New Revision: 231226 URL: http://svn.freebsd.org/changeset/base/231226 Log: Revert r211288 and move the logic to the acpi_timer itself. Modified: head/etc/rc.resume head/etc/rc.suspend head/sys/dev/acpica/acpi_timer.c Modified: head/etc/rc.resume ============================================================================== --- head/etc/rc.resume Wed Feb 8 19:31:32 2012 (r231225) +++ head/etc/rc.resume Wed Feb 8 20:31:42 2012 (r231226) @@ -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 Modified: head/etc/rc.suspend ============================================================================== --- head/etc/rc.suspend Wed Feb 8 19:31:32 2012 (r231225) +++ head/etc/rc.suspend Wed Feb 8 20:31:42 2012 (r231226) @@ -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/ \ Modified: head/sys/dev/acpica/acpi_timer.c ============================================================================== --- head/sys/dev/acpica/acpi_timer.c Wed Feb 8 19:31:32 2012 (r231225) +++ head/sys/dev/acpica/acpi_timer.c Wed Feb 8 20:31:42 2012 (r231226) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include "opt_acpi.h" #include #include +#include #include #include #include @@ -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_method 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. */