Date: Fri, 1 Jun 2012 13:21:33 +0000 (UTC) From: Mitsuru IWASAKI <iwasaki@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: r236396 - stable/8/sys/dev/acpica Message-ID: <201206011321.q51DLXZ7021363@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: iwasaki Date: Fri Jun 1 13:21:32 2012 New Revision: 236396 URL: http://svn.freebsd.org/changeset/base/236396 Log: MFC r235692,235772,236220,236221: - Don't start the sleep state transition procedure while sleep is disabled or the system is in shutdown procedure. - Ignore the power button press event for resuming rather than starting shutdown. - Fix the problem acpi_sleep_force() hang. - Reorder resume procedures to avoid hang during AcpiLeaveSleepState() execution. Modified: stable/8/sys/dev/acpica/acpi.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/dev/acpica/acpi.c ============================================================================== --- stable/8/sys/dev/acpica/acpi.c Fri Jun 1 12:47:13 2012 (r236395) +++ stable/8/sys/dev/acpica/acpi.c Fri Jun 1 13:21:32 2012 (r236396) @@ -2307,15 +2307,29 @@ acpi_SetSleepState(struct acpi_softc *sc #if defined(__amd64__) || defined(__i386__) static void +acpi_sleep_force_task(void *context) +{ + struct acpi_softc *sc = (struct acpi_softc *)context; + + if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) + device_printf(sc->acpi_dev, "force sleep state S%d failed\n", + sc->acpi_next_sstate); +} + +static void acpi_sleep_force(void *arg) { struct acpi_softc *sc = (struct acpi_softc *)arg; device_printf(sc->acpi_dev, "suspend request timed out, forcing sleep now\n"); - if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) - device_printf(sc->acpi_dev, "force sleep state S%d failed\n", - sc->acpi_next_sstate); + /* + * XXX Suspending from callout cause the freeze in DEVICE_SUSPEND(). + * Suspend from acpi_task thread in stead. + */ + if (ACPI_FAILURE(AcpiOsExecute(OSL_NOTIFY_HANDLER, + acpi_sleep_force_task, sc))) + device_printf(sc->acpi_dev, "AcpiOsExecute() for sleeping failed\n"); } #endif @@ -2339,14 +2353,20 @@ acpi_ReqSleepState(struct acpi_softc *sc if (!acpi_sleep_states[state]) return (EOPNOTSUPP); - ACPI_LOCK(acpi); - /* If a suspend request is already in progress, just return. */ if (sc->acpi_next_sstate != 0) { - ACPI_UNLOCK(acpi); return (0); } + /* Wait until sleep is enabled. */ + while (sc->acpi_sleep_disabled) { + AcpiOsSleep(1000); + } + + ACPI_LOCK(acpi); + + sc->acpi_next_sstate = state; + /* S5 (soft-off) should be entered directly with no waiting. */ if (state == ACPI_STATE_S5) { ACPI_UNLOCK(acpi); @@ -2355,7 +2375,6 @@ acpi_ReqSleepState(struct acpi_softc *sc } /* Record the pending state and notify all apm devices. */ - sc->acpi_next_sstate = state; #if defined(__i386__) STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) { clone->notify_status = APM_EV_NONE; @@ -2615,10 +2634,10 @@ backout: acpi_wake_prep_walk(state); sc->acpi_sstate = ACPI_STATE_S0; } - if (slp_state >= ACPI_SS_SLP_PREP) - AcpiLeaveSleepState(state); if (slp_state >= ACPI_SS_DEV_SUSPEND) DEVICE_RESUME(root_bus); + if (slp_state >= ACPI_SS_SLP_PREP) + AcpiLeaveSleepState(state); if (slp_state >= ACPI_SS_SLEPT) acpi_enable_fixed_events(sc); sc->acpi_next_sstate = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206011321.q51DLXZ7021363>