Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi Error out if we try to set power to a higher-po...
details: https://anonhg.NetBSD.org/src/rev/ab23adeea543
branches: trunk
changeset: 755535:ab23adeea543
user: jruoho <jruoho%NetBSD.org@localhost>
date: Tue Jun 08 18:18:24 2010 +0000
description:
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.
diffstat:
sys/dev/acpi/acpi_power.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diffs (47 lines):
diff -r f31b65d4fee4 -r ab23adeea543 sys/dev/acpi/acpi_power.c
--- a/sys/dev/acpi/acpi_power.c Tue Jun 08 18:04:17 2010 +0000
+++ b/sys/dev/acpi/acpi_power.c Tue Jun 08 18:18:24 2010 +0000
@@ -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;
Home |
Main Index |
Thread Index |
Old Index