From ffe3f1f8cc6a938b8f2aee9d91d006fda968763f Mon Sep 17 00:00:00 2001 From: Mitsuru IWASAKI Date: Tue, 29 May 2012 05:09:40 +0000 Subject: [PATCH] Fix the problem acpi_sleep_force() hang. Suspending from callout cause the freeze in DEVICE_SUSPEND(). Suspend from acpi_task thread in stead. MFC after: 3 days --- sys/dev/acpica/acpi.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 3b53e5429581..012517499d5d 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -2448,6 +2448,16 @@ acpi_SetSleepState(struct acpi_softc *sc, int state) } #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) { @@ -2455,9 +2465,13 @@ acpi_sleep_force(void *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