Check whether devd is running before calling resume notifier and
reshuffle code to reduce unnecessary locking coverage.
This commit is contained in:
parent
effc077868
commit
9ece6c032d
@ -2336,7 +2336,7 @@ acpi_ReqSleepState(struct acpi_softc *sc, int state)
|
||||
#endif
|
||||
|
||||
/* If devd(8) is not running, immediately enter the sleep state. */
|
||||
if (devctl_process_running() == FALSE) {
|
||||
if (!devctl_process_running()) {
|
||||
ACPI_UNLOCK(acpi);
|
||||
if (ACPI_SUCCESS(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) {
|
||||
return (0);
|
||||
@ -2345,9 +2345,6 @@ acpi_ReqSleepState(struct acpi_softc *sc, int state)
|
||||
}
|
||||
}
|
||||
|
||||
/* Now notify devd(8) also. */
|
||||
acpi_UserNotify("Suspend", ACPI_ROOT_OBJECT, state);
|
||||
|
||||
/*
|
||||
* Set a timeout to fire if userland doesn't ack the suspend request
|
||||
* in time. This way we still eventually go to sleep if we were
|
||||
@ -2357,6 +2354,10 @@ acpi_ReqSleepState(struct acpi_softc *sc, int state)
|
||||
*/
|
||||
callout_reset(&sc->susp_force_to, 10 * hz, acpi_sleep_force, sc);
|
||||
ACPI_UNLOCK(acpi);
|
||||
|
||||
/* Now notify devd(8) also. */
|
||||
acpi_UserNotify("Suspend", ACPI_ROOT_OBJECT, state);
|
||||
|
||||
return (0);
|
||||
#else
|
||||
/* This platform does not support acpi suspend/resume. */
|
||||
@ -2432,8 +2433,24 @@ acpi_AckSleepState(struct apm_clone_data *clone, int error)
|
||||
static void
|
||||
acpi_sleep_enable(void *arg)
|
||||
{
|
||||
struct acpi_softc *sc = (struct acpi_softc *)arg;
|
||||
|
||||
((struct acpi_softc *)arg)->acpi_sleep_disabled = 0;
|
||||
ACPI_LOCK(acpi);
|
||||
sc->acpi_sleep_disabled = 0;
|
||||
ACPI_UNLOCK(acpi);
|
||||
}
|
||||
|
||||
static ACPI_STATUS
|
||||
acpi_sleep_disable(struct acpi_softc *sc)
|
||||
{
|
||||
ACPI_STATUS status;
|
||||
|
||||
ACPI_LOCK(acpi);
|
||||
status = sc->acpi_sleep_disabled ? AE_ERROR : AE_OK;
|
||||
sc->acpi_sleep_disabled = 1;
|
||||
ACPI_UNLOCK(acpi);
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
enum acpi_sleep_state {
|
||||
@ -2460,15 +2477,11 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
|
||||
ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, state);
|
||||
|
||||
/* Re-entry once we're suspending is not allowed. */
|
||||
status = AE_OK;
|
||||
ACPI_LOCK(acpi);
|
||||
if (sc->acpi_sleep_disabled) {
|
||||
ACPI_UNLOCK(acpi);
|
||||
status = acpi_sleep_disable(sc);
|
||||
if (ACPI_FAILURE(status)) {
|
||||
printf("acpi: suspend request ignored (not ready yet)\n");
|
||||
return (AE_ERROR);
|
||||
return (status);
|
||||
}
|
||||
sc->acpi_sleep_disabled = 1;
|
||||
ACPI_UNLOCK(acpi);
|
||||
|
||||
#ifdef SMP
|
||||
thread_lock(curthread);
|
||||
@ -2557,6 +2570,7 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
|
||||
* shutdown handlers.
|
||||
*/
|
||||
shutdown_nice(RB_POWEROFF);
|
||||
status = AE_OK;
|
||||
break;
|
||||
case ACPI_STATE_S0:
|
||||
default:
|
||||
@ -2580,13 +2594,6 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
|
||||
if (slp_state >= ACPI_SS_SLEPT)
|
||||
acpi_enable_fixed_events(sc);
|
||||
|
||||
/* Allow another sleep request after a while. */
|
||||
if (state != ACPI_STATE_S5)
|
||||
timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME);
|
||||
|
||||
/* Run /etc/rc.resume after we are back. */
|
||||
acpi_UserNotify("Resume", ACPI_ROOT_OBJECT, state);
|
||||
|
||||
mtx_unlock(&Giant);
|
||||
|
||||
/* Warm up timecounter again */
|
||||
@ -2599,6 +2606,14 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
|
||||
thread_unlock(curthread);
|
||||
#endif
|
||||
|
||||
/* Allow another sleep request after a while. */
|
||||
if (state != ACPI_STATE_S5)
|
||||
timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME);
|
||||
|
||||
/* Run /etc/rc.resume after we are back. */
|
||||
if (devctl_process_running())
|
||||
acpi_UserNotify("Resume", ACPI_ROOT_OBJECT, state);
|
||||
|
||||
return_ACPI_STATUS (status);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user