Index: dev/acpica/acpi.c =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpi.c,v retrieving revision 1.320 diff -u -r1.320 acpi.c --- dev/acpica/acpi.c 29 May 2012 05:28:34 -0000 1.320 +++ dev/acpica/acpi.c 31 May 2012 02:40:06 -0000 @@ -2666,6 +2666,7 @@ register_t intr; ACPI_STATUS status; enum acpi_sleep_state slp_state; + int sleep_result; ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, state); @@ -2746,7 +2747,12 @@ DELAY(sc->acpi_sleep_delay * 1000000); if (state != ACPI_STATE_S1) { - if (acpi_sleep_machdep(sc, state)) + intr = intr_disable(); + sleep_result = acpi_sleep_machdep(sc, state); + acpi_wakeup_machdep(sc, state, sleep_result); + AcpiLeaveSleepStatePrep(state, acpi_sleep_flags); + intr_restore(intr); + if (sleep_result == -1) goto backout; /* Re-enable ACPI hardware on wakeup from sleep state 4. */ @@ -2776,7 +2782,6 @@ if (slp_state >= ACPI_SS_DEV_SUSPEND) DEVICE_RESUME(root_bus); if (slp_state >= ACPI_SS_SLP_PREP) { - AcpiLeaveSleepStatePrep(state, acpi_sleep_flags); AcpiLeaveSleepState(state); } if (slp_state >= ACPI_SS_SLEPT) { Index: dev/acpica/acpivar.h =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpivar.h,v retrieving revision 1.130 diff -u -r1.130 acpivar.h --- dev/acpica/acpivar.h 17 May 2012 17:58:53 -0000 1.130 +++ dev/acpica/acpivar.h 31 May 2012 02:27:22 -0000 @@ -439,6 +439,7 @@ int acpi_machdep_init(device_t dev); void acpi_install_wakeup_handler(struct acpi_softc *sc); int acpi_sleep_machdep(struct acpi_softc *sc, int state); +int acpi_wakeup_machdep(struct acpi_softc *sc, int state, int sleep_result); int acpi_table_quirks(int *quirks); int acpi_machdep_quirks(int *quirks); Index: i386/acpica/acpi_wakeup.c =================================================================== RCS file: /home/ncvs/src/sys/i386/acpica/acpi_wakeup.c,v retrieving revision 1.57 diff -u -r1.57 acpi_wakeup.c --- i386/acpica/acpi_wakeup.c 19 May 2012 02:31:38 -0000 1.57 +++ i386/acpica/acpi_wakeup.c 31 May 2012 02:40:55 -0000 @@ -209,13 +209,15 @@ } #endif + +#ifdef SMP +static cpuset_t wakeup_cpus; +#endif +static register_t cr3; + int acpi_sleep_machdep(struct acpi_softc *sc, int state) { -#ifdef SMP - cpuset_t wakeup_cpus; -#endif - register_t cr3, rf; ACPI_STATUS status; struct pmap *pm; int ret; @@ -235,7 +237,6 @@ AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc)); - rf = intr_disable(); intr_suspend(); /* @@ -252,6 +253,7 @@ #endif if (suspendctx(susppcbs[0])) { + ret = 0; #ifdef SMP if (!CPU_EMPTY(&wakeup_cpus) && suspend_cpus(wakeup_cpus) == 0) { @@ -284,6 +286,21 @@ for (;;) ia32_pause(); } else { + ret = 1; + } +out: + return (ret); +} + +int +acpi_wakeup_machdep(struct acpi_softc *sc, int state, int sleep_result) +{ + + if (sleep_result == -1) { + return (sleep_result); + } + + if (sleep_result == 1) { pmap_init_pat(); initializecpu(); PCPU_SET(switchtime, 0); @@ -292,10 +309,8 @@ if (!CPU_EMPTY(&wakeup_cpus)) acpi_wakeup_cpus(sc, &wakeup_cpus); #endif - ret = 0; } -out: #ifdef SMP if (!CPU_EMPTY(&wakeup_cpus)) restart_cpus(wakeup_cpus); @@ -304,15 +319,14 @@ load_cr3(cr3); mca_resume(); intr_resume(); - intr_restore(rf); AcpiSetFirmwareWakingVector(0); - if (ret == 0 && mem_range_softc.mr_op != NULL && + if (sleep_result == 1 && mem_range_softc.mr_op != NULL && mem_range_softc.mr_op->reinit != NULL) mem_range_softc.mr_op->reinit(&mem_range_softc); - return (ret); + return (sleep_result); } static void *