Module Name: src
Committed By: jruoho
Date: Tue Jun 8 18:18:25 UTC 2010
Modified Files:
src/sys/dev/acpi: acpi_power.c
Log Message:
Error out if we try to set power to a higher-power state than the parent's
state. This follows the "bus power state" -logic noted in the spec:
bus: D1
device A : D1 -> D0 -> error
device B : D1 -> D2 -> success
-> bus must remain in D1 due device A
Following this scheme, it is easy to derive the "bus power state" now that
we have the device nodes in a tree-like structure. If required, separate
acpi_power_get_bus() and acpi_power_set_bus() can be added in the future.
To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/acpi/acpi_power.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/acpi/acpi_power.c
diff -u src/sys/dev/acpi/acpi_power.c:1.17 src/sys/dev/acpi/acpi_power.c:1.18
--- src/sys/dev/acpi/acpi_power.c:1.17 Mon Jun 7 17:28:17 2010
+++ src/sys/dev/acpi/acpi_power.c Tue Jun 8 18:18:24 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_power.c,v 1.17 2010/06/07 17:28:17 jruoho Exp $ */
+/* $NetBSD: acpi_power.c,v 1.18 2010/06/08 18:18:24 jruoho Exp $ */
/*-
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.17 2010/06/07 17:28:17 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.18 2010/06/08 18:18:24 jruoho Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -395,6 +395,17 @@
}
/*
+ * As noted in ACPI 4.0 (appendix A.2.1), the bus power state
+ * should never be lower than the highest state of one of its
+ * devices. Consequently, we cannot set the state to a lower
+ * (i.e. higher power) state than the parent device's state.
+ */
+ if (ad->ad_parent != NULL && ad->ad_parent->ad_state > state) {
+ rv = AE_ABORT_METHOD;
+ goto fail;
+ }
+
+ /*
* We first sweep through the resources required for the target
* state, turning things on and building references. After this
* we dereference the resources required for the current state,
@@ -418,8 +429,8 @@
(void)snprintf(path, sizeof(path), "_PS%d", state);
(void)AcpiEvaluateObject(ad->ad_handle, path, NULL, NULL);
- aprint_debug_dev(ad->ad_root, "%s turned from "
- "D%d to D%d\n", ad->ad_name, old, state);
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s turned from "
+ "D%d to D%d\n", ad->ad_name, old, state));
ad->ad_state = state;