Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jul 2010 23:24:07 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r210150 - head/sys/dev/acpica
Message-ID:  <201007152324.o6FNO7gd032588@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Thu Jul 15 23:24:06 2010
New Revision: 210150
URL: http://svn.freebsd.org/changeset/base/210150

Log:
  If there is any pending sleep request, disallow entering S5 state.
  Otherwise, bad things may happen. ;-)

Modified:
  head/sys/dev/acpica/acpi.c

Modified: head/sys/dev/acpica/acpi.c
==============================================================================
--- head/sys/dev/acpica/acpi.c	Thu Jul 15 23:11:51 2010	(r210149)
+++ head/sys/dev/acpica/acpi.c	Thu Jul 15 23:24:06 2010	(r210150)
@@ -2317,27 +2317,28 @@ acpi_ReqSleepState(struct acpi_softc *sc
 {
 #if defined(__amd64__) || defined(__i386__)
     struct apm_clone_data *clone;
+    ACPI_STATUS status;
 
     if (state < ACPI_STATE_S1 || state > ACPI_S_STATES_MAX)
 	return (EINVAL);
     if (!acpi_sleep_states[state])
 	return (EOPNOTSUPP);
 
-    /* S5 (soft-off) should be entered directly with no waiting. */
-    if (state == ACPI_STATE_S5) {
-	if (ACPI_SUCCESS(acpi_EnterSleepState(sc, state)))
-	    return (0);
-	else
-	    return (ENXIO);
-    }
+    ACPI_LOCK(acpi);
 
     /* If a suspend request is already in progress, just return. */
-    ACPI_LOCK(acpi);
     if (sc->acpi_next_sstate != 0) {
     	ACPI_UNLOCK(acpi);
 	return (0);
     }
 
+    /* S5 (soft-off) should be entered directly with no waiting. */
+    if (state == ACPI_STATE_S5) {
+    	ACPI_UNLOCK(acpi);
+	status = acpi_EnterSleepState(sc, state);
+	return (ACPI_SUCCESS(status) ? 0 : ENXIO);
+    }
+
     /* Record the pending state and notify all apm devices. */
     sc->acpi_next_sstate = state;
     STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) {
@@ -2351,11 +2352,8 @@ acpi_ReqSleepState(struct acpi_softc *sc
     /* If devd(8) is not running, immediately enter the sleep state. */
     if (!devctl_process_running()) {
 	ACPI_UNLOCK(acpi);
-	if (ACPI_SUCCESS(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) {
-	    return (0);
-	} else {
-	    return (ENXIO);
-	}
+	status = acpi_EnterSleepState(sc, state);
+	return (ACPI_SUCCESS(status) ? 0 : ENXIO);
     }
 
     /*
@@ -2592,7 +2590,6 @@ acpi_EnterSleepState(struct acpi_softc *
      * process.  This handles both the error and success cases.
      */
 backout:
-    sc->acpi_next_sstate = 0;
     if (slp_state >= ACPI_SS_GPE_SET) {
 	acpi_wake_prep_walk(state);
 	sc->acpi_sstate = ACPI_STATE_S0;
@@ -2603,6 +2600,7 @@ backout:
 	DEVICE_RESUME(root_bus);
     if (slp_state >= ACPI_SS_SLEPT)
 	acpi_enable_fixed_events(sc);
+    sc->acpi_next_sstate = 0;
 
     mtx_unlock(&Giant);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007152324.o6FNO7gd032588>