From owner-svn-src-head@FreeBSD.ORG Thu Feb 9 17:38:09 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 41842106566B; Thu, 9 Feb 2012 17:38:09 +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 118FF8FC12; Thu, 9 Feb 2012 17:38:09 +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 q19Hc8RA015087; Thu, 9 Feb 2012 17:38:08 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q19Hc8Iv015085; Thu, 9 Feb 2012 17:38:08 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201202091738.q19Hc8Iv015085@svn.freebsd.org> From: Jung-uk Kim Date: Thu, 9 Feb 2012 17:38:08 +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: r231295 - head/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: Thu, 09 Feb 2012 17:38:09 -0000 Author: jkim Date: Thu Feb 9 17:38:08 2012 New Revision: 231295 URL: http://svn.freebsd.org/changeset/base/231295 Log: Refine r231226. Swap timecounters before suspending any device drivers. Modified: head/sys/dev/acpica/acpi_timer.c Modified: head/sys/dev/acpica/acpi_timer.c ============================================================================== --- head/sys/dev/acpica/acpi_timer.c Thu Feb 9 16:58:06 2012 (r231294) +++ head/sys/dev/acpica/acpi_timer.c Thu Feb 9 17:38:08 2012 (r231295) @@ -68,8 +68,8 @@ static u_int acpi_timer_frequency = 1431 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 void acpi_timer_suspend_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); @@ -81,7 +81,6 @@ 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} }; @@ -249,6 +248,12 @@ acpi_timer_attach(device_t dev) return (ENXIO); acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg); acpi_timer_bst = rman_get_bustag(acpi_timer_reg); + + /* Register suspend event handler. */ + if (EVENTHANDLER_REGISTER(power_suspend, acpi_timer_suspend_handler, + &acpi_timer_timecounter, EVENTHANDLER_PRI_LAST) == NULL) + device_printf(dev, "failed to register suspend event handler\n"); + return (0); } @@ -269,22 +274,25 @@ acpi_timer_resume_handler(struct timecou } } -static int -acpi_timer_suspend(device_t dev) +static void +acpi_timer_suspend_handler(struct timecounter *newtc) { - struct timecounter *newtc, *tc; - int error; + struct timecounter *tc; - error = bus_generic_suspend(dev); + /* Deregister existing resume event handler. */ if (acpi_timer_eh != NULL) { EVENTHANDLER_DEREGISTER(power_resume, acpi_timer_eh); acpi_timer_eh = NULL; } + + KASSERT(newtc == &acpi_timer_timecounter, + ("acpi_timer_suspend_handler: wrong timecounter")); + tc = timecounter; - newtc = &acpi_timer_timecounter; if (tc != newtc) { if (bootverbose) - device_printf(dev, "switching timecounter, %s -> %s\n", + device_printf(acpi_timer_dev, + "switching timecounter, %s -> %s\n", tc->tc_name, newtc->tc_name); (void)acpi_timer_read(); (void)acpi_timer_read(); @@ -292,7 +300,6 @@ acpi_timer_suspend(device_t dev) acpi_timer_eh = EVENTHANDLER_REGISTER(power_resume, acpi_timer_resume_handler, tc, EVENTHANDLER_PRI_LAST); } - return (error); } /*