Home | History | Annotate | Download | only in acpi
History log of /src/sys/dev/acpi/acpi_power.c
RevisionDateAuthorComments
 1.38  25-Aug-2025  christos More explicit asserts and comment fix (thanks Rillig)
 1.37  24-Aug-2025  christos D3 constant changed
 1.36  31-May-2022  mrg allow ACPI to compile without PCI support. fixes ia64 build.
 1.35  01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.34  25-Feb-2014  pooka branches: 1.34.6;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.33  02-Jun-2012  dsl branches: 1.33.2; 1.33.4;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.32  21-Jun-2011  jruoho branches: 1.32.2;
Rename acpi_get_node() to acpi_match_node() for consistency.
 1.31  22-May-2011  joerg branches: 1.31.2;
Let's not be silly. Use a fancy "if else" to decide behavior of a bool
and hope cosmic radition doesn't create a third state.
 1.30  14-Apr-2011  jruoho Simplify by using a static array for the reference counting.
 1.29  09-Jan-2011  jruoho branches: 1.29.2;
Convert aprint_error(9) to ACPI_DEBUG_PRINT.
 1.28  09-Jan-2011  jruoho Remove also rest of the ACPI_DEVICE_POWER checks.
 1.27  09-Jan-2011  jruoho We use config_defer(9) now when scanning power resource and wake-up
capabilities, so do not fail in acpi_power_register() if ACPI_DEVICE_POWER is
not set in struct acpi_devnode::ad_flags.
 1.26  06-Jan-2011  jruoho Fix a comment.
 1.25  02-Jan-2011  jruoho Adjust error messages for the previous commit.
 1.24  02-Jan-2011  jruoho Use "real" device names for the hw.acpi.wake and hw.acpi.power sysctl(8)
trees. For instance, instead of hw.acpi.wake.DURT, we have hw.acpi.wake.wm0
for wm(4). This is a temporary solution, but without solving the big
abstraction questions, this is the best we can do.
 1.23  08-Oct-2010  gsutre Store sysctl MIBs instead of a pointer to the root of the sysctl
sub-tree (because the pointer may be invalid at the time we use it).

ok jruoho@
 1.22  06-Aug-2010  jruoho branches: 1.22.2;
Fix prototypes; SYSCTLFN_ARGS -> SYSCTLFN_PROTO.
(These things really only obscure the code.)
 1.21  01-Jul-2010  jruoho Fix a carelessness bug introduced in the revision 1.17; acpi_power_get() now
takes a handle instead of node as a parameter. (The compiler did not catch
this as ACPI_HANDLE is a pointer to void.)
 1.20  08-Jun-2010  jruoho Only check the parent's power state if the parent has power management
capabilities. Based on a short DSDT survey, not all systems adhere to the
model noted in the comment.
 1.19  08-Jun-2010  jruoho Fix a comment and some debug printing.
 1.18  08-Jun-2010  jruoho 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.
 1.17  07-Jun-2010  jruoho Now that we have 1:1 mapping between handles and nodes, use the former for
all power resource operations. Eliminates the wrapper functions.
 1.16  07-Jun-2010  jruoho Refactor slightly: we need to expose the function that turns individual
power resource on or off.
 1.15  07-Jun-2010  jruoho Build the power resource queue dynamically. This eliminates the need to call
acpi_power_res_add() in the main scan function, also saving few bytes of
memory.
 1.14  05-Jun-2010  jruoho Convert an aprint_error_dev() to ACPI_DEBUG_PRINT in acpi_power_set().

This "fixes" the issue observed by dyoung@. Since the AML may not keep any
state by itself, it is possible that the firmware tries to continuously put
a device into a power state where the device already is (e.g. D3 -> D3).

XXX: The code (like the old power resource code) rests on the assumption
that it is possible to reliably obtain the power state of a device
either directly via _PSC or indirectly via _STA. However, because there
is some evidence that few broken systems implement these methods
incorrectly (e.g. always returns D0 as a constant, even if the state
would be D3 in reality), we may need to revisit this by always setting
the power state, even if it is impossible to get the power state.
 1.13  31-May-2010  jruoho Silently return if a power state transition is requested for a device that
has no support for it. For example, in Kurt Schreiner's Shuttle G61:

Device (FAN)
{
Name (_HID, EisaId ("PNP0C0B"))
Method (_INI, 0, NotSerialized)
{
Store (TP1H, CTOS)
Store (TP1L, CTHY)
}
}

Obviously acpitz(4) has little use for a device that only contains _INI.
(The handle of this device is referenced incorrectly in _AL0.)
 1.12  12-May-2010  jruoho branches: 1.12.2;
Initial pass for issues observed by dyoung@ on HP Pavilion N3270. In this
laptop there is a PNP0C0B ("ACPI fan") with the following properties:

_PSC : Power state for D3 (alone).
_PR0 : Power resources for D0.
_PSx : Power state switch for D0 and D3.

Thus, it is impossible to get or set the D3 power state via power resources
alone; there is only a single PowerResource() and it is for D0.

To tackle this:

1. Evaluate the direct _PSC control method if and only if there is no
given _PRx. The order is important; it is known that some other
systems implement the _PSC method (like _STA) incorrectly.

2. If no _PRx is available (and thus no _ON or _OFF), do not error out.
Instead, if we have AE_NOT_FOUND, continue to evaluate the power state
switch method, _PSx, which (on this laptop) should alone suffice for
the D0 -> D3 transition.
 1.11  27-Apr-2010  jruoho branches: 1.11.2;
Clean up <dev/acpi/acpireg.h>. While documenting the control methods is an
admirable goal, it is pretty much mission impossible; the specifications are
nearly thousand pages each and the amount of methods is counted in hundreds.

In addition, use ACPICA's native constants from <actypes.h> when possible.
Also move ACPI_STA_OK from "mpacpi.c" to <dev/acpi/acpireg.h> to simplify
the evaluation of device status.
 1.10  26-Apr-2010  jruoho Fix typo. Doh.
 1.9  26-Apr-2010  jruoho AE_CTRL_TERMINATE -> AE_CTRL_FALSE.
 1.8  24-Apr-2010  jruoho Do not use __func__ with ACPI_DEBUG_PRINT (it already adds it).
 1.7  24-Apr-2010  jruoho Add utility function acpi_get_node().

This retrieves a struct acpi_devnode from a handle. Since this requires
accessing the global softc, it is better to do it in one place alone. The
same goes for possible locking of the node-queue; it is better not to
publicize such a lock for generic device drivers.
 1.6  24-Apr-2010  jruoho Now that we are able to remove references to power resources, provide a
detachment routine for acpitz(4). Add comments explaining the relationship
between power resources and active cooling. Also some improvements to code
readability.
 1.5  23-Apr-2010  jruoho Forgot that the firmware may change the power state behind our back,
so actively query the state when the sysctl(8) is invoked.
 1.4  23-Apr-2010  jruoho Add hw.acpi.power sysctl-node.
 1.3  23-Apr-2010  jruoho Cosmetics: be pedantic and use AE_CTRL_TERMINATE instead of AE_ABORT_METHOD
as a condition to break out of a loop.
 1.2  23-Apr-2010  jruoho When setting the power, always mark the state as invalid on failure, even if
going to D0. Also fix a potential NULL pointer dereference in an aprint_().
 1.1  22-Apr-2010  jruoho Merge new code for ACPI power resources.

The old code served us well, but a major overhaul would have been needed for
it to cope with the increased demands of the code -- and the specifications.

ok jmcneill@, pgoyette@
 1.11.2.4  22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.11.2.3  17-Aug-2010  uebayasi Sync with HEAD.
 1.11.2.2  30-Apr-2010  uebayasi Sync with HEAD.
 1.11.2.1  27-Apr-2010  uebayasi file acpi_power.c was added on branch uebayasi-xip on 2010-04-30 14:43:05 +0000
 1.12.2.6  31-May-2011  rmind sync with head
 1.12.2.5  21-Apr-2011  rmind sync with head
 1.12.2.4  05-Mar-2011  rmind sync with head
 1.12.2.3  03-Jul-2010  rmind sync with head
 1.12.2.2  30-May-2010  rmind sync with head
 1.12.2.1  12-May-2010  rmind file acpi_power.c was added on branch rmind-uvmplock on 2010-05-30 05:17:17 +0000
 1.22.2.2  11-Aug-2010  yamt sync with head.
 1.22.2.1  06-Aug-2010  yamt file acpi_power.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:16 +0000
 1.29.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.31.2.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.32.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.32.2.1  30-Oct-2012  yamt sync with head
 1.33.4.1  18-May-2014  rmind sync with head
 1.33.2.2  03-Dec-2017  jdolecek update from HEAD
 1.33.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.6.1  28-Aug-2017  skrll Sync with HEAD

RSS XML Feed