1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-26 11:47:31 +00:00

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
This commit is contained in:
Nate Lawson 2004-12-05 01:35:18 +00:00
parent 062a5b33f3
commit 5d3d03f152
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=138378

View File

@ -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);
}