From 8d6b2a87ee2379aa6b5f70eade44f5c20244bfb8 Mon Sep 17 00:00:00 2001 From: njl Date: Mon, 26 Apr 2004 05:25:06 +0000 Subject: Move the call to AcpiEnterSleepStatePrep() to before we select the BSP (cpuid 0) as the processor. It mallocs some data and smp_rendezvous calls functions with locks held. --- sys/dev/acpica/acpi.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index e432b9f..c4dd1db 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1168,6 +1168,12 @@ acpi_shutdown_final(void *arg, int howto) * not power off the system correctly if called from an AP. */ if ((howto & RB_POWEROFF) != 0) { + status = AcpiEnterSleepStatePrep(ACPI_STATE_S5); + if (ACPI_FAILURE(status)) { + printf("AcpiEnterSleepStatePrep failed - %s\n", + AcpiFormatException(status)); + return; + } printf("Powering system off using ACPI\n"); smp_rendezvous(NULL, acpi_shutdown_poweroff, NULL, NULL); } else { @@ -1176,6 +1182,10 @@ acpi_shutdown_final(void *arg, int howto) } } +/* + * Since this function may be called with locks held or in an unknown + * context, it cannot allocate memory, acquire locks, sleep, etc. + */ static void acpi_shutdown_poweroff(void *arg) { @@ -1187,12 +1197,6 @@ acpi_shutdown_poweroff(void *arg) if (PCPU_GET(cpuid) != 0) return; - status = AcpiEnterSleepStatePrep(ACPI_STATE_S5); - if (ACPI_FAILURE(status)) { - printf("AcpiEnterSleepStatePrep failed - %s\n", - AcpiFormatException(status)); - return; - } ACPI_DISABLE_IRQS(); status = AcpiEnterSleepState(ACPI_STATE_S5); if (ACPI_FAILURE(status)) { -- cgit v1.1