Commit Graph

892 Commits

Author SHA1 Message Date
jruoho
15a42e9f63 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.
2010-06-08 21:47:26 +00:00
jruoho
709c34f11d Fix a comment and some debug printing. 2010-06-08 18:38:18 +00:00
jruoho
fc9a58b32f 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.
2010-06-08 18:18:24 +00:00
jruoho
64f353c42a Add PNP0C33, "a hardware error device". Part of APEI. 2010-06-08 17:04:49 +00:00
jruoho
c51a135130 Add and organize some comments. Add also ACPI_DEVICE_EJECT constant to
indicate "ejectable" devices such as docking stations.
2010-06-08 16:55:02 +00:00
jruoho
5f7d603c37 Use the same notation with the PNP identifiers. Specifically note that
PNP0C80 is the device that is required for memory hot-plug on x86.
2010-06-08 16:49:53 +00:00
jruoho
2052593844 Now that we have 1:1 mapping between handles and nodes, use the former for
all power resource operations. Eliminates the wrapper functions.
2010-06-07 17:28:17 +00:00
jruoho
5e449c623c Use the new ACPICA functions AcpiAttachData() and AcpiGetData() to associate
all "struct acpi_devnodes" to their corresponding ACPI_HANDLEs. Anywhere in
the acpi(4) subtree, the node-structure can be obtained from a handle via
acpi_get_node(). The idea is similar to e.g. device_private().

Benefits: (a) simplifies code, (b) avoids issues with locking as ACPICA does
the serialization for us, (c) avoids the need to access the glocal softc, and
(d) avoids the O(n) loop required to search for a handle from the node queue.
2010-06-07 17:13:52 +00:00
jruoho
2da098d0fd Fix a bug: the last elements in the _PRW package are direct references to
power resources, not devices. Thus, we can not use the function that sets
the power state of a device.
2010-06-07 14:12:20 +00:00
jruoho
9c09c7fc2c Refactor slightly: we need to expose the function that turns individual
power resource on or off.
2010-06-07 14:07:25 +00:00
jruoho
4333086998 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.
2010-06-07 13:04:31 +00:00
jruoho
c751d2d518 Instead of disabling all GPEs for non-wakedevs, set both runtime and wake
GPEs, but unset only wake GPEs. The old behavior was questionable, as the
intention was only to disable a device's ability to wake the system.
Maintaining the runtime GPE generation is more important now as ACPICA
supports sharing a single GPE across multiple devices.

Discussed with jmcneill@.
2010-06-07 04:08:26 +00:00
pgoyette
9f0fa4d25b Update acpiverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
2010-06-07 01:45:27 +00:00
jruoho
d02842f45a We can no longer explicitly clear a GPE by calling AcpiClearGpe() in the
interrupt handler. However, all edge-triggered GPEs should already be
cleared before our GPE handler has a chance to run.

The reason can be found from the changes in the locking primitives of
ACPICA. All GPE operations now use a spin mutex on AcpiGbl_GpeLock, acquired
via AcpiOsAcquireLock(). This same lock is now acquired unconditionally in
the AcpiClearGpe() function. This causes a deadlock of the following form:

  ...

  AcpiEvGpeDetect() : acquire AcpiGbl_GpeLock;

 	  -> AcpiEvGpeDispatch();

		  -> acpiec_gpe_handler();

			  -> AcpiClearGpe() : acquire AcpiGbl_GpeLock;

			 	  -> panic.
2010-06-06 18:56:10 +00:00
jruoho
4563fc3267 ACPICA 20100331:
Completed a major update for the GPE support in order to improve
	support for shared GPEs and to simplify both host OS and ACPICA
	code. Added a reference count mechanism to support shared GPEs that
	require multiple device drivers.  Several external interfaces have
	changed. One external interface has been removed. One new external
	interface was added. Most of the GPE external interfaces now use the
	GPE spinlock instead of the events mutex (and the Flags parameter
	for many GPE interfaces has been removed.) See the updated ACPICA
	Programmer Reference for details. Matthew Garrett, Bob Moore, Rafael
	Wysocki. ACPICA BZ 831.

	Changed:
	    AcpiEnableGpe, AcpiDisableGpe, AcpiClearGpe, AcpiGetGpeStatus
	Removed:
	    AcpiSetGpeType
	New:
	    AcpiSetGpe
2010-06-06 18:40:51 +00:00
jruoho
03fcc3422b Although sysmon_pswitch_unregister(9) does not currently do anything, in
order to be ready for possible future API changes, call it if we failed to
install the fixed event handlers. Also small ACPI_DEBUG_PRINT clarifications.
2010-06-06 10:44:40 +00:00
jruoho
7b26e5d94f Remove also the debug-printf in case of long Stall() requests;
/*
	* sleep(9) isn't safe because AcpiOsStall may be called
	* with interrupt-disabled. (eg. by AcpiEnterSleepState)
	* we should watch out for long stall requests.
	*/

ACPICA has long printed a similar warning by itself. Moreover, this message
was never reached as the interpreter does not invoke AcpiOsStall() when a
delay longer than 255 usec is requested.
2010-06-05 16:57:48 +00:00
jruoho
3aca70d9a2 Remove the recently added warning about long Sleep() requests.
This is now in ACPICA (20100528):

	Added support to limit the maximum time for the ASL Sleep()
	operator. To prevent accidental deep sleeps, limit the maximum time
	that Sleep() will actually sleep. Configurable, the default maximum
	is two seconds. ACPICA bugzilla 854.
2010-06-05 16:47:49 +00:00
jruoho
e42cf0f8ae Switch the third argument to the _DSW method from 3 to 0. This means that
devices should be placed in the D0 state ("fully on") after resume. We were
not prepared to handle the previous value as it implied that devices could
be placed in an arbitrary power state once in S0.

Minimal functional change, given that the _DSW is seldom seen in the field.
2010-06-05 15:47:59 +00:00
jruoho
1bfe5139f3 Complete the support for wakeup devices. As imposed by the standard, all
power resources should be turned on for wakeup devices. This follows common
sense: a device cannot wake if the power of it is turned off.

ok jmcneill@
2010-06-05 15:31:21 +00:00
jruoho
8e7819f753 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.
2010-06-05 07:59:13 +00:00
jruoho
1f4ce9efc5 Remove trailing white space. 2010-06-05 06:07:12 +00:00
plunky
6d4cc93fdf adjust autoconfig output: this item is part of a verbose line 2010-06-01 19:20:43 +00:00
pgoyette
6c40070d66 Extract ACPIVERBOSE into a kernel module. The module can be builtin
by defining 'options ACPIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

ACPIVERBOSE also includes code to dump acpi/wmi data.
2010-05-31 20:32:28 +00:00
jruoho
5b0c19905b 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.)
2010-05-31 20:10:56 +00:00
plunky
31555cd112 fix up autoconfig output 2010-05-31 17:41:24 +00:00
jruoho
46e95075aa Regen. 2010-05-26 09:48:26 +00:00
jruoho
0f7795c449 Split the IrDA devices to their own section. Add HWPC224 and IBM0071,
both for the PC8738x-family of SuperIO chips from NSC (or Winbond).
2010-05-26 09:47:17 +00:00
christos
208ad48907 no need for double the newlines! 2010-05-23 22:05:54 +00:00
jruoho
2731b5ff2f Print a warning if AcpiOsSleep() is called with a value larger than two
seconds. It is known that there are systems in the field that pass bogus AML
values to the Sleep() operation code, possibly requesting delays that could
be measured in days.

Discussed with jmcneill@.

XXX: While the used mstohz(9) is documented to round to one second if the
     passed value is larger than 131072 ms, we may still need to force a
     sensible upper limit if this warning starts to appear.
2010-05-12 17:03:11 +00:00
jruoho
881c3c1e3f When scanning the device "capabilities" (power, wake-up, etc.),
include all device nodes, regardless of the status of the device.

XXX: It is known that some systems implement the _STA method incorrectly.
     If needed in the future, attachment based on the values from this
     method may need revisiting. Same goes for ACPI_ACTIVATE_DEV.
2010-05-12 16:11:05 +00:00
jruoho
a24d118616 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.
2010-05-12 15:59:52 +00:00
jruoho
7600ada264 Add ASUS CUV4X-D. From Pierre Pronchery in PR #41351. 2010-04-28 17:52:17 +00:00
jruoho
20524a61c1 Include the new prototype for acpi_enter_sleep_state(). 2010-04-27 08:37:07 +00:00
jruoho
cd8924253f Make acpi_enter_sleep_state() not to return. No one cared what it returned. 2010-04-27 08:36:06 +00:00
jruoho
e7c1114893 Be consistent with the returned exception codes. Check for NULL pointers. 2010-04-27 08:15:07 +00:00
jruoho
f04ee53053 Use ACPICA's standard notify values from <actypes.h> and move the
device-specific notify constants to the device-specific files.
2010-04-27 05:57:43 +00:00
jruoho
d5124a1812 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.
2010-04-27 05:34:14 +00:00
jruoho
f655bf2ab4 Fix typo. Doh. 2010-04-26 13:38:42 +00:00
jruoho
727f1f57e9 Improve and rearrange comments. 2010-04-26 13:30:31 +00:00
jruoho
696f7c4b2e AE_CTRL_TERMINATE -> AE_CTRL_FALSE. 2010-04-26 12:46:48 +00:00
jruoho
a0542f149f Move the ACPIVERBOSE blocks to a single place.
Also print non-devices in the EISAID/HID/UID/ADR-block
2010-04-26 04:31:09 +00:00
jruoho
ccaec16d65 Return instead of breaking out if the sleep state is not available. 2010-04-25 17:06:23 +00:00
jruoho
902b38408b As noted by jmcneill@, the specifications specifically mention that the _TTS
should be invoked before the system has notified any native mode device
drivers. Thus, do the call before pmf_system_suspend(9).
2010-04-25 17:03:08 +00:00
jruoho
61a52d7657 Evaluate _TTS on sleep state transitions. This is mainly to pro-actively
support some weird BIOS, which may require the evaluation. Ok jmcneill@.
2010-04-25 10:05:22 +00:00
jruoho
0c1ea6e257 Add a note about AcpiEnterSleepStatePrep(). 2010-04-25 09:12:38 +00:00
jruoho
2e3ac7f8ad Embarrassing typos: _PI_ -> _SI_, _PB_ -> _SB_. 2010-04-24 19:51:15 +00:00
jruoho
a84baa0293 Do not use __func__ with ACPI_DEBUG_PRINT (it already adds it). 2010-04-24 19:36:14 +00:00
jruoho
80e5813055 Remove retrieving the zone name via something called "REGN".
We really should not add code that aims to satisfy some oddball firmware,
not in the generic drivers that aim to comply with the specifications.
In the long-term this is even worse than quirk tables.
2010-04-24 19:16:10 +00:00
jruoho
ac93d6907f Some purely cosmetic editing in the name of readability: clean up the softc
and remove unused variables therein, remove unused constants, use
ACPI_DEBUG_PRINT, add more detailed comments, et cetera.
2010-04-24 19:11:48 +00:00