Commit Graph

253 Commits

Author SHA1 Message Date
John Baldwin
0d484d249f Allow device hints to wire the unit numbers of devices.
- An "at" hint now reserves a device name.
- A new BUS_HINT_DEVICE_UNIT method is added to the bus interface.  When
  determining the unit number of a device, this method is invoked to
  let the bus driver specify the unit of a device given a specific
  devclass.  This is the only way a device can be given a name reserved
  via an "at" hint.
- Implement BUS_HINT_DEVICE_UNIT() for the acpi(4) and isa(4) bus drivers.
  Both of these busses implement this by comparing the resources for a
  given hint device with the resources enumerated by ACPI/PnPBIOS and
  wire a unit if the hint resources are a subset of the "real" resources.
- Use bus_hinted_children() for adding hinted devices on isa(4) busses
  now instead of doing it by hand.
- Remove the unit kludging from sio(4) as it is no longer necessary.

Prodding from:	peter, imp
OK'd by:	marcel
MFC after:	1 month
2008-11-18 21:01:54 +00:00
Warner Losh
96cf0b6d56 Make the no driver stuff an ifdef. 2008-11-02 17:35:15 +00:00
Warner Losh
099ea4b570 Handle errors from device_get_children. 2008-08-23 16:38:20 +00:00
John Baldwin
d320e05ca5 Extend the support for PCI-e memory mapped configuration space access:
- Rename pciereg_cfgopen() to pcie_cfgregopen() and expose it to the
  rest of the kernel.  It now also accepts parameters via function
  arguments rather than global variables.
- Add a notion of minimum and maximum bus numbers and reject requests for
  an out of range bus.
- Add more range checks on slot/func/reg/bytes parameters to the cfg reg
  read/write routines.  Don't panic on any invalid parameters, just fail
  the request (writes do nothing, reads return -1).  This matches the
  behavior of the other cfg mechanisms.
- Port the memory mapped configuration space access to amd64.  On amd64
  we simply use the direct map (via pmap_mapdev()) for the memory mapped
  window.
- During acpi_attach() just after loading the ACPI tables, check for a
  MCFG table.  If it exists, call pciereg_cfgopen() on each subtable
  (memory mapped window).  For now we only support windows for domain 0
  that start with bus 0.  This removes the need for more chipset-specific
  quirks in the MD code.
- Remove the chipset-specific quirks for the Intel 5000P/V/Z chipsets
  since these machines should all have MCFG tables via ACPI.
- Updated pci_cfgregopen() to DTRT if ACPI had invoked pcie_cfgregopen()
  earlier.

MFC after:	2 weeks
2008-08-22 02:14:23 +00:00
John Baldwin
8c0879b6f6 Fix a typo. 2008-08-04 19:45:15 +00:00
John Baldwin
b661868711 Further refine the probe order of devices to more closely match the previous
behavior.  Specifically, probe Host-PCI bridges in the order they are
encountered in the tree.  For CPUs, just use an order of 100000 and assume
that no Host-PCI bridges will be more than 10000 levels deep in the
namespace.  This fixes an issue on some boxes where the HPET timer stopped
attaching.
2008-07-23 15:13:06 +00:00
John Baldwin
d227204d2d Revert back to probing Host-PCI bridges in the order we encounter them in
the tree rather than sorting them by their address on PCI bus 0.

Reported by:	kan
2008-04-07 18:35:11 +00:00
John Baldwin
5217af301c Rework how the nexus(4) device works on x86 to better handle the idea of
different "platforms" on x86 machines.  The existing code already handles
having two platforms: ACPI and legacy.  However, the existing approach was
rather hardcoded and difficult to extend.  These changes take the approach
that each x86 hardware platform should provide its own nexus(4) driver (it
can inherit most of its behavior from the default legacy nexus(4) driver)
which is responsible for probing for the platform and performing
appropriate platform-specific setup during attach (such as adding a
platform-specific bus device).  This does mean changing the x86 platform
busses to no longer use an identify routine for probing, but to move that
logic into their matching nexus(4) driver instead.
- Make the default nexus(4) driver in nexus.c on i386 and amd64 handle the
  legacy platform.  It's probe routine now returns BUS_PROBE_GENERIC so it
  can be overriden.
- Expose a nexus_init_resources() routine which initializes the various
  resource managers so that subclassed nexus(4) drivers can invoke it from
  their attach routine.
- The legacy nexus(4) driver explicitly adds a legacy0 device in its
  attach routine.
- The ACPI driver no longer contains an new-bus identify method.  Instead
  it exposes a public function (acpi_identify()) which is a probe routine
  that the MD nexus(4) drivers can use to probe for ACPI.  All of the
  probe logic in acpi_probe() is now moved into acpi_identify() and
  acpi_probe() is just a stub.
- On i386 and amd64, an ACPI-specific nexus(4) driver checks for ACPI via
  acpi_identify() and claims the nexus0 device if the probe succeeds.  It
  then explicitly adds an acpi0 device in its attach routine.
- The legacy(4) driver no longer knows anything about the acpi0 device.
- On ia64 if acpi_identify() fails you basically end up with no devices.
  This matches the previous behavior where the old acpi_identify() would
  fail to add an acpi0 device again leaving you with no devices.

Discussed with:	imp
Silence on:	arch@
2008-03-13 20:39:04 +00:00
John Baldwin
463e0f91cb Probe CPUs after the PCI hierarchy on i386, amd64, and ia64. This allows
the cpufreq drivers to reliably use properties of PCI devices for quirks,
etc.
- For the legacy drivers, add CPU devices via an identify routine in the
  CPU driver itself rather than in the legacy driver's attach routine.
- Add CPU devices after Host-PCI bridges in the acpi bus driver.
- Change the ichss(4) driver to use pci_find_bsf() to locate the ICH and
  check its device ID rather than having a bogus PCI attachment that only
  checked for the ID in probe and always failed.  As a side effect, you
  can now kldload ichss after boot.
- Fix the ichss(4) driver to use the correct device_t for the ICH (and not
  for ichss0) when doing PCI config space operations to enable SpeedStep.

MFC after:	2 weeks
Reviewed by:	njl, Andriy Gapon  avg of icyb.net.ua
2008-03-10 22:18:07 +00:00
Mitsuru IWASAKI
7572a9c749 Return errno value rather than boolean in this context.
MFC after:	1 week
2008-01-28 01:57:48 +00:00
Mitsuru IWASAKI
0c26519e5a Enter the sleep state immediately without waiting for timeout if
devd(8) is not running such as the system in single user mode.

MFC after:	1 week
2008-01-27 16:11:04 +00:00
Nate Lawson
f74e3c98dd Fix the HPET table probe routine to run from device_identify() instead
of directly from acpi0.  Before it would attach prior to the sysresource
devices, causing the later allocation of its memory range to fail and
print a warning like "acpi0: reservation of fed00000, 1000 (3) failed".
Use an explicit define for our probe order base value of 10.

Help from:	jhb
Tested by:	Abdullah Ibn Hamad Al-Marri <almarrie / gmail.com>
MFC after:	3 days
Approved by:	re
2007-10-09 07:48:07 +00:00
Nate Lawson
b6648efd3b Reject requests to start or ack a suspend sequence on platforms that do not
support suspend/resume, currently all except i386.

Tested by:	jkim
Approved by:	re
2007-09-13 01:37:17 +00:00
Nate Lawson
813d6dca45 My previous commit introduced a spurious warning for the case where a
switch (i.e. lid) is set to have an action of NONE.  This is not an
invalid state, so silently return.  This fixes the warning:
"acpi: request to enter state S6 failed (err 22)"

Approved by:	re
2007-06-30 17:27:31 +00:00
Nate Lawson
00a304487f Update the suspend/resume user API while maintaining backwards compat.
Improvements:
* /etc/rc.suspend,rc.resume are always run, no matter the source of the
  suspend request (user or kernel, apm or acpi)
* suspend now requires positive user acknowledgement.  If a user program
  wants to cancel the suspend, they can.  If one of the user programs
  hangs or doesn't respond within 10 seconds, the system suspends anyway.
* /dev/apm is clonable, allowing multiple listeners for suspend events.
  In the future, xorg-server can use this to be informed about suspend
  even if there are other listeners (i.e. apmd).

Changes:
* Two new ACPI ioctls:  REQSLPSTATE and ACKSLPSTATE.  Request begins the
  process of suspending by notifying all listeners.  acpi is monitored by
  devd(8) and /dev/apm listener(s) are also counted.  Users register their
  approval or disapproval via Ack.  If anyone disapproves, suspend is vetoed.
* Old user programs or kernel modules that used SETSLPSTATE continue to
  work.  A message is printed once that this interface is deprecated.
* acpiconf gains the -k flag to ack the suspend request.  This flag is
  undocumented on purpose since it's only used by /etc/rc.suspend.  It is
  not intended to be a permanent change and will be removed once a better
  power API is implemented.
* S5 (power off) is no longer supported via acpiconf -s 5 or apm -z/-Z.
  This restores previous behavior of halt/shutdown -p being the interface.
* Miscellaneous improvements to error reporting

Approved by:	re
2007-06-21 22:50:37 +00:00
Nate Lawson
70fa7bc0ac Convert magic to a uintptr_t. This should get rid of some warnings on
gcc4.
2007-06-15 18:02:34 +00:00
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