Commit Graph

237 Commits

Author SHA1 Message Date
Nate Lawson
93bfd059fd Add a sysctl, 'debug.acpi.suspend_bounce', that causes the system to bounce
back in a simulated resume instead of entering the requested suspend state.
This helps in testing drivers separately from the acpi suspend code.  To
test your drivers, set debug.acpi.suspend_bounce=1 and then run
acpiconf -s3 (or 4).

MFC after:	1 day
2007-05-25 05:26:21 +00:00
Takanori Watanabe
fffe371da3 Add ACPI HPET table support.
Reviewed by:njl
2007-05-15 08:41:05 +00:00
Mark Santcroos
4b1ff978df Set the debug.acpi.acpi_ca_version sysctl even if ACPI support is not
available.
2007-05-08 14:31:49 +00:00
John Baldwin
147c0ad0a1 Use a tighter check to see if a resource allocation request is for a
specific request and thus should first try to be allocated from the
sys_resource pool.  This avoids using the sys_resource pool for wildcard
requests that have bounded ranges coming from cbb(4) and Host-PCI pcib(4)
drivers.

Tested by:	Andrea Bittau <a.bittau of cs.ucl.ac.uk fame>
Sleuthing by:	Andrea Bittau as well
2007-04-25 16:22:18 +00:00
Jung-uk Kim
2be4e4713a Catch up with ACPI-CA 20070320 import. 2007-03-22 18:16:43 +00:00
John Baldwin
397c30a83d Change acpi's handling of suballocating system resources to be a little
simpler.  It now can just use rman_is_region_manager() during
acpi_release_resource() to see if the the resource is suballocated from
a system resource.  Also, the driver no longer needs MD knowledge about
how to setup bus space tags and handles when doing a suballocation, but
can simply rely on bus_activate_resource() in the parent setting all that
up.
2007-03-21 15:39:11 +00:00
John Baldwin
ce533e82a2 Tweak the probe/attach order of devices on the x86 nexus devices.
Various BIOS-related psuedo-devices are added at an order of 5.  acpi0 is
added at an order of 10, and legacy0 is added at an order of 11.
2007-03-20 20:21:44 +00:00
Nate Lawson
c7c42f0abb Improve readability of the version string. 2007-02-22 05:59:23 +00:00
Nate Lawson
907b6777c1 Re-work Cx handling to be per-cpu and asymmetrical, fixing support on
modern dual-core systems as well.

- Parse the _CST packages for each cpu and track all the states individually,
on a per-cpu basis.

- Revert to generic FADT/P_BLK based Cx control if the _CST package
is not present on all cpus. In that case, the new driver will
still support per-cpu Cx state handling. The driver will determine the
highest Cx level that can be supported by all the cpus and configure the
available Cx state based on that.

- Fixed the case where multiple cpus in the system share the same
registers for Cx state handling. To do that, added a new flag
parameter to the acpi_PkgGas and acpi_bus_alloc_gas functions that
enable the caller to add the RF_SHAREABLE flag.  This flag could also be
useful to other callers (acpi_throttle?) in the tree but this change is
not yet made.

- For Core Duo cpus, both cores seems to be taken out of C3 state when
any one of the cores need to transition out. This broke the short sleep
detection logic.  It is disabled now if there is more than one cpu in
the system for now as it fixed it in my case.  This quirk may need to
be re-enabled later differently.

- Added support to control cx_lowest on a per-cpu basis. There is still
a generic cx_lowest to enable changing cx_lowest for all cpus with a single
sysctl and for ease of use.  Sample output for the new sysctl:

dev.cpu.0.cx_supported: C1/1 C2/1 C3/57
dev.cpu.0.cx_lowest: C3
dev.cpu.0.cx_usage: 0.00% 43.16% 56.83%
dev.cpu.1.cx_supported: C1/1 C2/1 C3/57
dev.cpu.1.cx_lowest: C3
dev.cpu.1.cx_usage: 0.00% 45.65% 54.34%
hw.acpi.cpu.cx_lowest: C3

This work was done by Stephane E. Potvin with some simple reworking by
myself.  Thank you.

Submitted by:	Stephane E. Potvin <sepotvin / videotron.ca>
MFC after:	2 weeks
2007-01-07 21:53:42 +00:00
John Baldwin
e7a975adbe Fix a sign bug in acpi_release_resource(). acpi_sysres_find() returns !=
NULL if the specified resource is a sub-alloc of a system resource.
2006-09-21 18:56:03 +00:00
John Baldwin
0bba6acf85 Give the ACPI I/O rman's unique description strings to make 'devinfo -u'
output less confusing.

MFC after:	3 days
2006-09-11 19:32:54 +00:00
Nate Lawson
d1b16e1864 Add a new sysctl, hw.acpi.handle_reboot. If set, acpi will attempt to
perform the reboot action via the reset register instead of our legacy
method.  Default is 0 (use legacy).  This is needed because some systems
hang on reboot even though they claim to support the reset register.

MFC after:	2 days
2006-07-29 21:46:16 +00:00
Nate Lawson
d85e6785c5 By default, don't disable ACPI during reboot. This appears to hang some
systems.  Introduce a new sysctl "hw.acpi.disable_on_reboot" that allows
users to re-enable the old behavior in case it's needed for some systems.
We never disable in the power-off path.

Original approach submitted by Alexander Logvinov <abuse@akavia.ru> with
reworking by Jung-uk Kim and myself.
2006-06-11 20:31:41 +00:00
Nate Lawson
197b4dcc64 Minor sysctl cleanup. The RW flag means read|write and so it is redundant
to add the RD flag.  Also, the debug node does not need to be writable.
2006-06-10 08:04:38 +00:00
Poul-Henning Kamp
c40da00ca3 Since DELAY() was moved, most <machine/clock.h> #includes have been
unnecessary.
2006-05-16 14:37:58 +00:00
Nate Lawson
da72d149ef Don't attach special devices in the order they appear in the AML tree.
If the embedded controller exists before the sysresource devices, for
example, it will be attached first.  Instead, let the normal device
order function work as we first desired. [1]

There still remained a problem where we couldn't allocate resources in
acpi0 that were passed up by the sysresource pseudo-devices.  These
devices had to probe/attach first to give their resources to acpi, then
acpi would allocate them before probing/attaching other devices.  To
work around this, we attach them from acpi_sysres_alloc().  A better
approach would be to implement multi-pass probe/attach in newbus but
that's a much bigger task.

Suggested by:	jhb [1]
Hardware from:	Centaur Technologies
MFC after:	1 week
2006-05-07 03:28:10 +00:00
Warner Losh
c3f861f491 Set the rid for the resoruce obtained from rman_reserve_resource. 2006-04-20 04:21:27 +00:00
Mitsuru IWASAKI
858a52f464 Import ACPI Dock Station support. Note that this is still very young.
Additional detach implementaions (or maybe improvement) for other
deivce drivers is required.

Reviewed by:	njl, imp
MFC after:	1 week
2006-04-15 12:31:34 +00:00
Nate Lawson
87a500cd3b Add reset register support. This is the only method to reboot some new
systems (blade servers).  On most systems, this is implemented as an IO
write to the SMI port and the BIOS generates the actual reset.

PR:		kern/94939
Submitted by:	dodell@ixsystems.com
Reviewed by:	jhb
MFC after:	3 weeks
2006-03-29 06:30:47 +00:00
John Baldwin
3a6497c102 *sigh* Revert stuff that wasn't supposed to be committed. The
acpi_resource change was a minor nit offered as an early candidate for
the recent ACPICA import problem and the acpi.c change is one I need to
test still that makes the ordered probing of system devices actually work
as advertised (probe devices in order based on the type of device rather
than in the order we encounter them in the device tree).
2005-11-07 21:52:06 +00:00
John Baldwin
f25bdd3bb3 Work around at least one busted BIOS. If we get a source index in a _PRT
entry that is not zero, assume that it is really a hard-wired IRQ (commonly
used for APIC routing) and not a source index.  In practice, we've only
ever seen source indices of 0 for legitimate non-hard-wired _PRT entries.

Reviewed by:	njl
Tested by:	Alex Lyashkov shadow at psoft dot net
MFC after:	2 weeks
2005-11-07 21:48:45 +00:00
Jung-uk Kim
e8d472a7af Catch up with ACPI-CA 20051021 import 2005-11-01 22:44:08 +00:00
Nate Lawson
893f750a5c Add a hack to get around PCI link devices that report "present" but not
"functional" (i.e., if they are disabled).  We should probe them anyway
since we may enable them later.

Tested by:	thompsa
MFC after:	3 days
2005-10-23 00:28:39 +00:00
David E. O'Brien
2a191126de Canonize the include of acpi.h. 2005-09-11 18:39:03 +00:00
Warner Losh
f09aa88c33 In newbus land, ivars can only be accessed for direct child, or when
the driver has unholy private knowledge of its great-*cgrandchildren.
The ACPI allocation routine lacked such knowledge when it tried to do
a default allocation for all descendants, rather than just its
immeidate children, so would access grandchild's ivar in an unsafe
way.  This could lead to a panic when devices were present which had
no addresses setup by the BIOS, but which were later allocated in a
lazy manner via pci_alloc_map.  As such, only do the default
allocation adjustments for immediate children.  The manner that
acpi_sysres_find accesses the resource list, used later in
acpi_alloc_resource, is safe and proper so no additional test is
needed there.

This fixes a panic when probing an disabled ata controller on some
newer intel blades.

Reported by: dwhite
2005-06-03 20:12:12 +00:00
Nate Lawson
1c9ec53854 If devclass_get_devices() returns success but a count of 0, free the
pointer.  If kernel malloc(0) returns a valid pointer, it needs to be
freed.  If it returns NULL, it's ok to free this also.

Submitted by:	pjd
Reviewed by:	imp, dfr
Obtained from:	Coverity Prevent
2005-05-20 05:00:43 +00:00
Mark Santcroos
8518ed9ecd Simplify the ACPI taskqueue implementation. Use a thread queue type instead
of swi. This allows us to use the taskqueue_thread_* functions instead of
rolling our own. It also avoids a double trip through the queue.

Submitted by:	njl
Reviewed by:	sam
2005-05-09 07:34:04 +00:00
John Baldwin
b460c6f86b Probe PCI link devices early so that we turn them all off via _DIS before
we start turning any of them back on again.  This works around a bug in
some BIOSen that alias two different link devices for APIC vs ATPIC modes
onto the same physical hardware link.

Submitted by:	njl
Tested by:	Antoine Brodin antoine dot brodin at laposte dot net
2005-04-14 06:45:24 +00:00
Nate Lawson
965a34fb62 Always free the returned env pointer even it doesn't indicate we're in
verbose mode.

Found by:	Coverity Prevent (via sam)
2005-03-31 19:07:26 +00:00
Nate Lawson
ca2c69c8ef Clean up resources properly if acpi_perf fails to attach. First, change
acpi_bus_alloc_gas() to delete the resource it set if alloc fails.  Then,
change acpi_perf to delete the resource after releasing it if alloc fails.
This should make probe and attach both fully restartable if either fails.
2005-03-27 22:38:28 +00:00
Nate Lawson
43ce1c7762 If a device_add_child fails (i.e. low memory situation), be sure to free
the unused ivars also.

Submitted by:	pjd
Obtained from:	Coverity Prevent analysis
2005-03-27 03:37:43 +00:00
Nate Lawson
8b28b622f7 Add support for bus_delete_resource() and make acpi_bus_alloc_gas() do
this before setting a new resource.
2005-03-22 20:00:57 +00:00
Poul-Henning Kamp
be1bf4d2b8 s/SLIST/STAILQ/
/imp/a\
pointy hat
.
2005-03-18 11:57:44 +00:00
David E. O'Brien
dad97fee58 Fix SCM ID's. 2005-03-02 09:22:34 +00:00
Nate Lawson
ac8671f18f Remove unused variable.
Noticed by:	Coverity tool
2005-02-25 22:01:58 +00:00
Nate Lawson
f45fc848c5 Instead of assuming units of bytes, it seems more likely that this is
a bitfield.
2005-02-25 16:57:34 +00:00
Nate Lawson
2fe912df6b If a register width is less than 8, assume the BIOS author thought it was
in units of bytes and adjust accordingly.  This is found at least on the
Sony PCG-505BX.
2005-02-23 03:20:00 +00:00
Nate Lawson
8f118e25ec Check for the address space type first before validating it. In particular,
we want to return EOPNOTSUPP for FFixedHW no matter what the address.

Submitted by:	Bruno Ducrot
2005-02-17 19:00:14 +00:00
Nate Lawson
39da3eb359 Allow users to manually override quirks with the tunable "debug.acpi.quirks".
Suggested by:	Jung-uk Kim
2005-02-13 20:10:28 +00:00
Nate Lawson
e1c4bf3f42 Convert the acpi_bus_alloc_gas() and acpi_PkgGas() APIs to output the memory
type.  This is needed if the resource is to be released later.  The RID is
still also present, though less necessary since rman_get_rid() can be used
to obtain it from the resource.
2005-02-05 22:28:36 +00:00
Nate Lawson
33332dc271 In total violation of at least 4 sections in the ACPI spec, some systems
place device objects in \ (in this case, PCI links.)  Work around this by
starting our probe from \.  To avoid attaching system scope objects,
explicitly skip them.  (I think it's an ACPI-CA bug that \_SB and \_TZ have
device and thermal object types.)  Thanks to pjd@ for testing.

MFC after:	2 weeks
2005-01-08 09:10:20 +00:00
Nate Lawson
d05fa56bb3 Remove trailing whitespace. 2004-12-27 05:36:47 +00:00
Nate Lawson
5d3d03f152 Grab Giant around calls to DEVICE_SUSPEND/RESUME in acpi_SetSleepState().
If we are resuming non-MPSAFE drivers, they need Giant held for them.
This may fix some obscure suspend/resume problems.  It has fixed keyrate
setting problems that were triggered by cardbus (MPSAFE) changing the
ordering for syscons resume (non-MPSAFE).  Also, add some asserts that
Giant is held in our suspend/resume and shutdown methods.

Found by:	iedowse
MFC after:	2 days
2004-12-05 01:35:18 +00:00
Nate Lawson
834a79de94 Enable the relaxed behavior for op regions and other workarounds for
non-standard BIOSen.  We used to implement this in local patches but
now that ACPI-CA has merged/re-implemented most of our fixes, they were
no longer needed and we just needed to turn this knob on.  Also, remove
an unnecessary cast.

Tested by:	phk
2004-12-03 08:01:09 +00:00
Nate Lawson
10ce62b975 Turn ACPI and PCI devices off or to a lower power state in suspend and
back on again in resume.  Override the default of D3 with the value the
BIOS specifies in _SxD, if present.  Skip serial devices (PNP05xx) since
they seem to hang when set to D3 and may require special driver support.
Also, skip non-type 0 PCI devices (i.e., bridges) since our we don't yet
save/restore their config space and that seems to be necessary.

If this gives you trouble with suspend/resume, you can disable the new
ACPI and PCI power behavior separately with these tunables & sysctls:
    debug.acpi.do_powerstate
    hw.pci.do_powerstate

Approved by:	imp (pci)
Tested by:	acpi@ (numerous)
2004-12-02 08:07:12 +00:00
Nate Lawson
2c8d3b23ed Print before the footer, not after. 2004-10-13 07:29:29 +00:00
Nate Lawson
a91c5fa830 If flags are present, print them like ISA does.
MFC after:	1 day
2004-10-13 07:27:21 +00:00
Nate Lawson
9e0dd54fea Attach the device description for ISA devices on the ACPI bus.
MFC after:	1 day
2004-10-12 21:33:08 +00:00
Nate Lawson
ba36768b22 Don't disable acpi in shutdown if we're panicing (panicstr != NULL). This
may help with double panics.
2004-09-21 17:19:38 +00:00
Nate Lawson
adad474471 Rework sysresource management. Instead of having each sysresource object
hold its own values, pass them up to the parent (acpi0) and merge/uniq them
on the way.  After the namespace evaluation, acpi will reserve these
resources and manage them via rman before bus_generic_probe() and
bus_generic_attach().  This is necessary because some systems specify
conflicting resources in separate sysresource objects.  It's also cleaner
in that the interface between sysresource and acpi is now merely the parent's
resource list.  This code handles the following cases:

1. Unique resource:  add it to the parent via bus_set_resource().
2. New wholly contained in old:  discard new.
3. New tail overlaps old head:  grow old head downward.
   AND/OR
4. New head overlaps old tail:  grow old tail upward.

Tested by:	Pawel Worach <sajd_at_telia.com>
Tested by:	Radek Kozlowski <radek_at_raadradd.com>
MFC after:	5 days
2004-08-23 16:28:42 +00:00