svn commit: r247884 - stable/9/sys/dev/acpica

Andriy Gapon avg at FreeBSD.org
Wed Mar 6 10:52:02 UTC 2013


Author: avg
Date: Wed Mar  6 10:52:01 2013
New Revision: 247884
URL: http://svnweb.freebsd.org/changeset/base/247884

Log:
  MFC r246251: acpi: clear power button status bit after waking up

Modified:
  stable/9/sys/dev/acpica/acpi.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/acpica/acpi.c
==============================================================================
--- stable/9/sys/dev/acpica/acpi.c	Wed Mar  6 10:45:46 2013	(r247883)
+++ stable/9/sys/dev/acpica/acpi.c	Wed Mar  6 10:52:01 2013	(r247884)
@@ -2657,6 +2657,7 @@ acpi_EnterSleepState(struct acpi_softc *
 {
     register_t intr;
     ACPI_STATUS status;
+    ACPI_EVENT_STATUS power_button_status;
     enum acpi_sleep_state slp_state;
     int sleep_result;
 
@@ -2755,6 +2756,30 @@ acpi_EnterSleepState(struct acpi_softc *
 	if (sleep_result == 1 && state != ACPI_STATE_S4)
 	    AcpiWriteBitRegister(ACPI_BITREG_SCI_ENABLE, ACPI_ENABLE_EVENT);
 
+
+	if (sleep_result == 1 && state == ACPI_STATE_S3) {
+	    /*
+	     * Prevent mis-interpretation of the wakeup by power button
+	     * as a request for power off.
+	     * Ideally we should post an appropriate wakeup event,
+	     * perhaps using acpi_event_power_button_wake or alike.
+	     *
+	     * Clearing of power button status after wakeup is mandated
+	     * by ACPI specification in section "Fixed Power Button".
+	     *
+	     * XXX As of ACPICA 20121114 AcpiGetEventStatus provides
+	     * status as 0/1 corressponding to inactive/active despite
+	     * its type being ACPI_EVENT_STATUS.  In other words,
+	     * we should not test for ACPI_EVENT_FLAG_SET for time being.
+	     */
+	    if (ACPI_SUCCESS(AcpiGetEventStatus(ACPI_EVENT_POWER_BUTTON,
+		&power_button_status)) && power_button_status != 0) {
+		AcpiClearEvent(ACPI_EVENT_POWER_BUTTON);
+		device_printf(sc->acpi_dev,
+		    "cleared fixed power button status\n");
+	    }
+	}
+
 	intr_restore(intr);
 
 	/* call acpi_wakeup_machdep() again with interrupt enabled */


More information about the svn-src-stable-9 mailing list