Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Feb 2013 12:44:20 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r246251 - head/sys/dev/acpica
Message-ID:  <201302021244.r12CiKgj046079@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Sat Feb  2 12:44:19 2013
New Revision: 246251
URL: http://svnweb.freebsd.org/changeset/base/246251

Log:
  acpi: clear power button status bit after waking up...
  
  so that it is not confused for a new power off request.
  
  Learned from:	Linux and ACPI specification
  Tested by:	gjb
  MFC after:	12 days

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

Modified: head/sys/dev/acpica/acpi.c
==============================================================================
--- head/sys/dev/acpica/acpi.c	Sat Feb  2 12:42:07 2013	(r246250)
+++ head/sys/dev/acpica/acpi.c	Sat Feb  2 12:44:19 2013	(r246251)
@@ -2659,6 +2659,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;
 
@@ -2758,6 +2759,30 @@ acpi_EnterSleepState(struct acpi_softc *
 	    AcpiWriteBitRegister(ACPI_BITREG_SCI_ENABLE, ACPI_ENABLE_EVENT);
 
 	AcpiLeaveSleepStatePrep(state);
+
+	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 */



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