From 5d3d03f1521c60255b746eaf8743eca3e67e6902 Mon Sep 17 00:00:00 2001 From: Nate Lawson Date: Sun, 5 Dec 2004 01:35:18 +0000 Subject: [PATCH] Grab Giant around calls to DEVICE_SUSPEND/RESUME in acpi_SetSleepState(). If we are resuming non-MPSAFE drivers, they need Giant held for them. This may fix some obscure suspend/resume problems. It has fixed keyrate setting problems that were triggered by cardbus (MPSAFE) changing the ordering for syscons resume (non-MPSAFE). Also, add some asserts that Giant is held in our suspend/resume and shutdown methods. Found by: iedowse MFC after: 2 days --- sys/dev/acpica/acpi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 8ba0c33df156..eccee0e3f65b 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -600,6 +600,8 @@ acpi_suspend(device_t dev) device_t child, *devlist; int error, i, numdevs, pstate; + GIANT_REQUIRED; + /* First give child devices a chance to suspend. */ error = bus_generic_suspend(dev); if (error) @@ -641,6 +643,8 @@ acpi_resume(device_t dev) int i, numdevs; device_t child, *devlist; + GIANT_REQUIRED; + /* * Put all devices in D0 before resuming them. Call _S0D on each one * since some systems expect this. @@ -663,6 +667,8 @@ static int acpi_shutdown(device_t dev) { + GIANT_REQUIRED; + /* Allow children to shutdown first. */ bus_generic_shutdown(dev); @@ -2039,6 +2045,11 @@ acpi_SetSleepState(struct acpi_softc *sc, int state) sc->acpi_sleep_disabled = 1; ACPI_UNLOCK(acpi); + /* + * Be sure to hold Giant across DEVICE_SUSPEND/RESUME since non-MPSAFE + * drivers need this. + */ + mtx_lock(&Giant); slp_state = ACPI_SS_NONE; switch (state) { case ACPI_STATE_S1: @@ -2136,6 +2147,7 @@ acpi_SetSleepState(struct acpi_softc *sc, int state) if (state != ACPI_STATE_S5) timeout(acpi_sleep_enable, (caddr_t)sc, hz * ACPI_MINIMUM_AWAKETIME); + mtx_unlock(&Giant); return_ACPI_STATUS (status); }