Commit Graph

821 Commits

Author SHA1 Message Date
John Baldwin
ef2cda76c0 - Quiet the pci_link(4) devices so that they don't show up in dmesg now.
- Improve panic message if we fail to read the PCI bus number from a bridge
  device.
- Don't try to lookup a BIOS IRQ for a link unless the link is routed via
  an ISA IRQ since BIOSen currently only route PCI link devices via ISA
  IRQs.

Tested by:	Mathieu Prevot bsdhack at club-internet dot fr
MFC after:	1 week
2005-11-23 16:36:13 +00:00
Nate Lawson
2010798dab Try to fix problems with periodic hangs by never directly calling _BIF.
Instead, re-evaluate _BIF only when we get a notify and use the cached
results.  We also still evaluate _BIF once on boot.  Also, optimize the
init loop a little by only querying for a particular info if it's not valid.

MFC after:	2 days
2005-11-23 00:57:51 +00:00
Nate Lawson
f08e63dc4d Simplify checks for valid battery info via DeMorgan's Rule. No
functional change.
2005-11-23 00:53:01 +00:00
Hajimu UMEMOTO
4796860760 Cache the result of battery info retrieval from smbat as well
as cmbat.

Reviewed by:	njl
MFC after:	3 days
2005-11-22 03:34:09 +00:00
John Baldwin
a4104d1c3b Fix the code to look up the BIOS IRQ for a given link device by reading
the IRQ set by the BIOS in existing devices to actually get the correct
bus number of the child PCI bus.  I was not reading the bus number from
the bridge device correctly.  The __BUS_ACCESSOR() macros (from which
pcib_get_bus() is built) assume that the passed in argument is a child
device.  However, at the time I'm reading the bus there is no child
device yet, so I was passing in the pcib device as the child device.
The parent of the pcib device probably returned an error in the case of
a host bridge, thus resulting in random stack garbage for the bus number.
For PCI-PCI bridges, the bus number being used was actually the subvendor
of the PCI-PCI bridge device itself.

MFC after:	1 week
2005-11-21 22:01:16 +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
Scott Long
6a4810bd6d Move HPET debugging under ACPI_TIMER in order to save a bitfield. 2005-11-01 20:41:43 +00:00
Scott Long
5be4c55fea Add proper debugging infrastructure for acpi_hpet.c. 2005-11-01 15:57:15 +00:00
Poul-Henning Kamp
4fa7241fd4 Add a basic HPET timecounter.
It has -200 quality for now so it will not get automatically selected.
2005-10-31 21:39:50 +00:00
Robert Watson
5bb84bc84b Normalize a significant number of kernel malloc type names:
- Prefer '_' to ' ', as it results in more easily parsed results in
  memory monitoring tools such as vmstat.

- Remove punctuation that is incompatible with using memory type names
  as file names, such as '/' characters.

- Disambiguate some collisions by adding subsystem prefixes to some
  memory types.

- Generally prefer lower case to upper case.

- If the same type is defined in multiple architecture directories,
  attempt to use the same name in additional cases.

Not all instances were caught in this change, so more work is required to
finish this conversion.  Similar changes are required for UMA zone names.
2005-10-31 15:41:29 +00:00
Nate Lawson
80f006a1e3 If we're trying to use C2/3 and reads from the register are returning
immediately, back off to the next higher Cx sleep state.  Some machines
with a Via chipset report a valid C3 but a register read doesn't actually
halt the CPU.  This would cause the machine to appear unresponsive as it
repeatedly called cpu_idle() which immediately returned.  Causing interrupts
(i.e. by pressing the power button) would cause the system to make forward
progress, showing that it wasn't actually hung.

Also, enable interrupts a little earlier.  We don't need them disabled
to calculate the delta time for the read.

Reported by:	silby
MFC after:	2 weeks
2005-10-25 21:15:47 +00:00
Nate Lawson
c395e805cd Invert the check logic. No functional change, but I prefer this version. 2005-10-24 18:30:57 +00:00
Nate Lawson
895e60b801 If no AC line devices are found, go ahead and notify devd that the system
is on AC power (i.e. not a laptop).  This allows power_profile to run once
for desktop systems as well, for instance, to set C3 or CPU frequency.

MFC after:	2 weeks
2005-10-24 05:34:21 +00:00
Nate Lawson
49ab824149 Add prototype to be consistent. 2005-10-23 19:31:18 +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
Nate Lawson
a7e59a7679 Import ACPI smart battery support. Newer systems (Acer, mostly) do not
support the CM-battery interface.  Smart batteries can eventually be
supported without ACPI via a separate SMBus interface.  The ACPI interface
uses the embedded controller for reading/writing to the SMBus, and normal
ASL definitions for locating the battery controller (since SMBus can't be
enumerated.)  Also import definitions for the smart battery interface.

This was written by Hans Petter Selasky with minor cleanups from myself.

Submitted by:	Hans Petter Selasky <hselasky / c2i.net>
2005-10-23 00:20:13 +00:00
Nate Lawson
9aa72f7404 Cleanups and support code for importing smart battery support.
* Use ACPI_BATT_UNKNOWN instead of constants
* Use maxunit instead of a count of devices since we may have sparse
  battery devices in the future.  Only userland should be using unit
  numbers anyway, so provide a translation function.  (Kernel use of
  batteries should be restricted to looking up a device_t and calling
  methods directly.
* Don't check acpi_BatteryIsPresent() in acpi_battery.  Leave it up to
  the hardware-specific driver (i.e. cmbat) since smart batteries seem
  to not report the "battery present" flag.
* Convert mA to mW if the battery uses those units.  CM-batteries only
  used mW so this deficiency went unnoticed.
* Clean strings reported in the battery info from any control chars.
* Only dereference the unit from ioctl_arg if the full struct is present.
  Unit wouldn't have been used later if it wasn't present but this is
  cleaner.  Translate the unit if it's not ACPI_BATTERY_ALL_UNITS.
* bzero structs before returning them to usermode for future compat.

Most of this work was submitted by Hans Petter Selasky and then majorly
reworked by myself.

Submitted by:	Hans Petter Selasky <hselasky / c2i.net>
2005-10-23 00:16:41 +00:00
Warner Losh
dca2069084 Commit a workaround to a problem with resource allocation. This helps
with some Dell servers that booted w/o a problem[*] on 5.4, but failed
with 6.0-BETA.

On the PCI bus, when we do lazy resource allocation, we narrow the
range requested as we pass through bridges to reflect how the bridges
are programmed and what addresses they pass.  However, when we're
doing an allocation on a bus that's directly connected to a host
bridge, no such translation can take place.  We already had a fallback
range for memory requests, but none for ioports.  As such, provide a
fallback for I/O ports so we don't allocate location 0, which will
have undesired side effects when the resources are actually used.

This fixes a problem with booting a Dell server with usb in the
kernel.  However, it is an unsatisfying solution.  I don't like the
hard coded value, and I think we should start narrowing the resources
returned to not be in the so-called isa alias area (where the ranage &
0x0300 must be 0 iirc).  Doing such filtering will have to wait for
another day.

This may be a good 6 candidate, maybe after its had a chance to be
refined.

Tested by: glebius@
2005-09-16 07:02:29 +00:00
David E. O'Brien
2a191126de Canonize the include of acpi.h. 2005-09-11 18:39:03 +00:00
Alexander Kabaev
83582626ad Unbreak compiles with ACPI_DEBUG. 2005-08-26 02:21:02 +00:00
Hajimu UMEMOTO
b3130703e6 get current temperature from _TMP during passive cooling is active.
it makes CPU freq transition smooth.
2005-08-25 11:31:30 +00:00
Hajimu UMEMOTO
9b96aa9ad7 initialize only ACPI_BUFFER to avoid race condition with passive
cooling thread which refers psv, tc1, tc2 and tsp.  The previous
code made the period where sc->tz_zone.tsp was zero, and it caused
panic at msleep().

Reported by:	keramida
Tested by:	keramida
2005-08-25 10:50:36 +00:00
Hajimu UMEMOTO
c219fd0c5e don't raise cpu speed over the value when passive cooling is in
effect.  since CPU speed is restored by degrees, we cannot use
the facility of saving cpu speed by CPUFREQ_set() effectively.
so, we need to save the value when passive cooling is in effect.

Repoeted by:	Kevin Oberman <oberman__at__es.net>
2005-08-17 17:01:25 +00:00
Nate Lawson
84cdcfb36f Modify the fix in rev 1.16 slightly. Instead of setting the cap to zero,
just skip summing it if it's unknown.

MFC after:	1 day
2005-08-11 17:12:57 +00:00
Nate Lawson
9396c1b2d1 When summing capacities, skip info from batteries that weren't present.
Previously, we used all info (including -1 or "not present") which would
keep the system from reaching 100% when charging.

Reported by:	Eric Anderson
MFC after:	2 days
2005-08-05 17:00:58 +00:00
Hajimu UMEMOTO
fa4679950b don't do mutex locking around kthread_create() call.
Reported by:	Maxim Maximov <mcsi__at__mcsi.pp.ru>
2005-08-04 18:34:26 +00:00
Nate Lawson
e4515dd568 Add descriptions for the sysctls.
MFC after:	1 day
2005-07-28 19:34:51 +00:00
Nate Lawson
50d0e47aa7 Zero the _BST, _BIF, and battinfo allocations. This is needed since we
later sum capacities for all batteries, even those that weren't actually
present.  We only need to do this for _BST but do it for all of them.

Reported by:	Eric Anderson
MFC after:	1 day
2005-07-28 18:19:50 +00:00
John Baldwin
b88076fede Correct the order of some if tests so that we don't complain about being
unable to route an IRQ when we do route an IRQ ok but bootverbose is off.

Reported by:	Ben Kaduk minimarmot at gmail dot com
2005-07-27 15:21:32 +00:00
Nate Lawson
f4e31e2e89 Correct minor output bug. When the battery being queried is charging or
the overall discharge rate is 0, mark the battery remaining time as
"unknown", not 0.

Reported by:	Eric Kjeldergaard
MFC after:	4 days
2005-07-25 17:44:10 +00:00
Nate Lawson
76f6fe4f31 Rewrite the acpi_battery interface to allow for other battery types
(i.e., smart battery) and fix various bugs found during the cleanup.

API changes:
* kernel access:
Access to individual batteries is now via devclass_find("battery").
Introduce new methods ACPI_BATT_GET_STATUS (for _BST-formatted data) and
ACPI_BATT_GET_INFO (for _BIF-formatted data).  The helper function
acpi_battery_get_battinfo() now takes a device_t instead of a unit #
argument.  If dev is NULL, this signifies all batteries.

* ioctl access:
The ACPIIO_BATT_GET_TYPE and ACPIIO_BATT_GET_BATTDESC ioctls have been
removed.  Since there is now no need for a mapping between "virtual" unit
and physical unit, usermode programs can just specify the unit directly and
skip the old translation steps.  In fact, acpiconf(8) was actually already
doing this and virtual unit was the same as physical unit in all cases
since there was previously only one battery type (acpi_cmbat).  Additionally,
we now map the ACPIIO_BATT_GET_BIF and ACPIIO_BATT_GET_BST ioctls for all
batteries, if they provide the associated methods.

* apm compatibility device/ioctls:  no change
* sysctl:  no change

Since most third-party applications use the apm(4) compat interface, there
should be very few affected applications (if any).

Reviewed by:	bruno
MFC after:	5 days
2005-07-23 19:36:00 +00:00
Nate Lawson
a3ab9d1e3e Standardize __FBSDID identifiers.
MFC after:	2 days
2005-07-22 23:10:02 +00:00
Hajimu UMEMOTO
e71de913d8 Implement passive cooling. It is enabled for tz0 by default where
it is available.

Reviewed by:	njl
2005-07-18 20:12:23 +00:00
David Malone
d446f3569c Add a quirk for a motherboard whose acpi timer runs too fast.
Approved by:	re (scottl)
Approved by:	nate
MFC after:	2 weeks
2005-06-26 18:19:14 +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
Yoshihiro Takahashi
d4fcf3cba5 Remove bus_{mem,p}io.h and related code for a micro-optimization on i386
and amd64.  The optimization is a trivial on recent machines.

Reviewed by:	-arch (imp, marcel, dfr)
2005-05-29 04:42:30 +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
Takanori Watanabe
b4b4c81522 Use General definition for general notify. 2005-05-19 09:13:26 +00:00
Nate Lawson
a6761eb377 If there is a problem during probe, be sure to free up any resources
allocated for it.  The normal exit case handles this correctly so we
use it as well for errors.

Submitted by:	pjd
Obtained from:	Coverity Prevent
2005-05-12 22:35:08 +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
Nate Lawson
98cc161947 Add the tunable "debug.acpi.max_threads" to allow users to set the
number of task threads to start on boot.  Go back to a default of 3
threads to work around lost battery state problems.  Users that need
a setting of 1 can set this via the tunable.  I am investigating the
underlying issues and this tunable can be removed once they are solved.

MFC after:	2 days
2005-04-21 06:13:48 +00:00
Mark Santcroos
b3919c8d96 Use AcpiUtStrupr() instead of strupr() as the latter will disappear in
future versions of acpica.

MFC after:	2 weeks
2005-04-14 06:50:13 +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
0a133d67f3 Set CPU speed to 100% in acpi_throttle attach. This is needed for some
systems that boot with this value at the lowest setting.  Change the
default boot config back to "leave frequency as BIOS set it".  Also, fix
buglet where acpi_throttle wouldn't be used if p4tcc was present but
disabled by the user.

MFC after:	1 week
2005-04-10 20:04:30 +00:00
Nate Lawson
f2d942579b Advertise that we can handle unified SMP control of processor power
states, idling, etc.  This has been supported since the cpufreq import.
2005-04-10 19:21:42 +00:00
Nate Lawson
bce9288570 Fix support for _PDC by using the proper version/length format for the
buffer.  Also, reference the Intel document where the _PDC values were
found.  This now supports ACPI-assisted SpeedStep on my borrowed T42.
2005-04-10 19:07:08 +00:00
Nate Lawson
cb3f3e5c9b Revert part of 1.19. We do want to set the count to 0 since otherwise
it would give false info to other parts of the driver.
2005-04-07 17:33:22 +00:00
John Baldwin
fbe648c9b8 Don't free the _PSS buffer until after we check to see if we have no valid
states as otherwise we will try to free the buffer twice.
2005-04-05 19:39:44 +00:00
Nate Lawson
b29224c2a0 Add the acpi_get_features() method. This method is called on child drivers
to see what features they may support before calling identify/probe/attach.
This is necessary because the ACPI 3.0 spec requires driver support be
advertised before running any methods.  For now, the flags are as specified
in for the _PDC and _OSC methods but we can support private flags as needed.

Add an implementation of this for acpi_cpu.  It checks all its children
(notably cpufreq drivers) and calls the _PDC method to report the results.
2005-04-04 15:46:57 +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
b8a1664840 Serialize task queue by starting only one thread instead of three. This
may help with various interdependencies between subsystems.  More testing
is needed to understand what the underlying issues are here.

Tested by:	Juho Vuori
MFC after:	2 days
2005-03-27 21:30:33 +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
55fa5feab7 Check for invalid frequencies after parsing the package. Keep a running
count of valid frequencies and use that as the final package count, don't
give up when the first invalid state is found.  Also, add 0x9999 and expand
our upper check to >= 0xffff Mhz [2].

Submitted by:	Bruno Ducrot, Jung-uk Kim [2]
2005-03-26 17:30:34 +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
Nate Lawson
6638c61aa6 Attach acpi_perf early. Especially when it is being used to provide info
to other devices, it needs to be attached first.  (Multi-pass newbus
probes would be a better solution.)
2005-03-20 03:51:18 +00:00
Nate Lawson
e33bea8d9e Add the acpi_ec_read and write methods. This allows an external driver
(like an EC/SMbus controller) to access the EC address space.  Access
is synchronized by the EcLock/Unlock routines in EcSpaceHandler().

Tested by:	Hans Petter Selasky
2005-03-20 01:27:27 +00:00
Poul-Henning Kamp
be1bf4d2b8 s/SLIST/STAILQ/
/imp/a\
pointy hat
.
2005-03-18 11:57:44 +00:00
Nate Lawson
8f76495941 Introduce a general name for the previously cmbat-only ioctls. It has the
same value as the previous ioctls so no binary change.  Also, make a few
style changes to reduce diffs to my tree.

Loosely based on code from:	Hans Petter Selasky
2005-03-17 22:42:49 +00:00
John Baldwin
18e6466b0f - If we fail to find an entry in the PRT, output a warning message.
- Fix a bug in the same condition where we forgot to drop the ACPI pcib
  lock.  This fixes hangs after the pcib0 attach on some machines.

Tested by:	sos (2)
2005-03-08 17:22:11 +00:00
Nate Lawson
5e517fee01 On i386 platforms at least, ACPI throttling is accomplished by the chipset
modulating the STPCLK# pin based on the duty cycle.  Since p4tcc uses the
same mechanism (but internal to the CPU), we triggered a hang on some
systems at low frequencies when both were in use.  Now, disable
acpi_throttle when p4tcc is also present.

Tested by:	Kevin Oberman
2005-03-04 18:59:54 +00:00
Nate Lawson
0716d65cef Check for some impossible frequencies that some systems use to indicate
they don't actually support Px states.
2005-03-04 05:29:56 +00:00
David E. O'Brien
dad97fee58 Fix SCM ID's. 2005-03-02 09:22:34 +00:00
Nate Lawson
2d81061879 Protect acpivar.h with _KERNEL. No user parts inside currently. 2005-03-02 04:36:24 +00:00
Nate Lawson
a885159fea Protect against multiple includes and use _KERNEL to protect the PCI fns. 2005-02-28 05:39:34 +00:00
Nate Lawson
97d31723e7 Make a pass through all drivers checking specs for desired behavior on
SMP systems.  It appears all drivers except ichss should attach to each
CPU and that settings should be performed on each CPU.  Add comments about
this.  Also, add a guard for p4tcc's identify method being called more than
once.
2005-02-27 02:43:02 +00:00
Nate Lawson
f81de92f96 Don't bother with cpufreq_register if we're info-only.
Suggested by:	Jung-uk Kim
2005-02-26 22:09:05 +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
John Baldwin
af2b9fec22 Add a entry for the Compaq R3000Z to indicate that it has the weird MADT
IRQ 0 quirk.
2005-02-22 21:54:20 +00:00
John Baldwin
373dd87688 - Add a new quirk to indicate that pin 0 of the first I/O APIC is really
IRQ 0 and not an ExtINT pin.  The MADT enumerators ignore the PC-AT flag
  and ignore overrides that map IRQ 0 to pin 2 when this quirk is present.
- Add a block comment above the quirks to document each quirk so that we
  can use more verbose descriptions quirks.

MFC after:	2 weeks
2005-02-22 21:52:52 +00:00
Nate Lawson
0db8fa8984 Increase the maximum to wait for a transition from 1 to 10 ms. In some
modes, systems may take longer.  If the status values don't match, try
matching just the lowest 8 bits if no bits above 8 are set in the desired
value.  The IBM R32 has other bits set in the status register that are
irrelevant to the expected value.
2005-02-22 06:34:53 +00:00
Nate Lawson
0dc1b976eb Support disabling individual cpufreq drivers with hints, e.g.,
hint.ichss.0.disabled="1"
2005-02-22 06:31:45 +00:00
Nate Lawson
a1adf35e65 Set the start of the cooling time later on, when we're actually performing
the switch.  Other interim tests (i.e., for minimum runtime) could
invalidate the start time.  This fixes transitions to cooler states in that
now they go to the next active state (_AC0 -> _AC1) instead of going
straight to off (_AC0 -> off).

Submitted by:	Alexandre "Sunny" Kovalenko (Alex.Kovalenko / verizon.net)
2005-02-22 00:40:13 +00:00
Nate Lawson
1395b555de Since the GPE handler is directly called by ACPI-CA and it may have unknown
locks held, specify the ACPI_ISR flag to keep it from acquiring any more
mutexes (which could potentially sleep.)  This should fix "could sleep"
warning messages on the following path:

    msleep()
    AcpiOsWaitSemaphore()
    AcpiUtAcquireMutex()
    AcpiDisableGpe()
    EcGpeHandler()
    AcpiEvGpeDispatch()
    AcpiEvGpeDetect()
    AcpiEvGpeDetect()
    AcpiEvSciXruptHandler()
2005-02-21 23:38:41 +00:00
Nate Lawson
28d7170f1c Add a new field to struct cf_setting for special values. These are driver-
specific values that other components may want to use.  Add support to
acpi_perf(4) to export the control and status values via this field.
2005-02-19 06:13:26 +00:00
Nate Lawson
e94a0c1a18 Introduce a new method, cpufreq_drv_type(), that returns the type of the
driver.  This used to be handled by cpufreq_drv_settings() but it's
useful to get the type/flags separately from getting the settings.
(For example, you don't have to pass an array of cf_setting just to find
the driver type.)

Use this new method in our in-tree drivers to detect reliably if acpi_perf
is present and owns the hardware.  This simplifies logic in drivers as well
as fixing a bug introduced in my last commit where too many drivers attached.
2005-02-18 00:23:36 +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
ededc31dd1 The correct error value for not having enough storage is E2BIG, not
ENOMEM.  The manpage and ichss(4) are correct.
2005-02-17 01:02:58 +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
e22cd41c01 Add support for the CPUFREQ_FLAG_INFO_ONLY flag. Devices that report this
are not added to the list(s) of available settings.  However, other drivers
can call the CPUFREQ_DRV_SETTINGS() method on those devices directly to
get info about available settings.

Update the acpi_perf(4) driver to use this flag in the presence of
"functional fixed hardware."  Thus, future drivers like Powernow can
query acpi_perf for platform info but perform frequency transitions
themselves.
2005-02-13 18:49:48 +00:00
Nate Lawson
3bd74b84f5 Be sure to register with cpufreq(4). On systems that only supported
throttling, neglecting to do this kept the sysctls from appearing.
Attach an acpi_throttle device to each CPU that supports it.
Don't add a device if the P_BLK is invalid or if _PTC is not present.
This removes extraneous probe/attach failure messages on some machines.
Make the cpu throttle state local to the softc to account for partial
successes when changing the clock rate on MP machines.
2005-02-13 05:34:52 +00:00
Nate Lawson
8b39b8ce63 Attach an acpi_perf device for every processor that offers the right
methods.
2005-02-13 05:25:27 +00:00
Nate Lawson
8b888c66d7 Remove handling _PSS notifies from acpi_cpu and let acpi_perf handle them. 2005-02-07 04:03:06 +00:00
Nate Lawson
8c5468e3f5 Remove acpi throttling support from the acpi_cpu(4) driver now that this
is supported by acpi_throttle(4).
2005-02-06 21:10:19 +00:00
Nate Lawson
7150dfc7e5 Break out acpi throttling support into a new relative cpufreq driver,
acpi_throttle(4).
2005-02-06 21:09:51 +00:00
Nate Lawson
3cc2f17689 Notify the OS that we're taking over Px states in acpi_perf(4) instead of
doing it in the cpu driver.  The previous code was incorrect anyway since
this value controls Px states, not throttling as the comment said.  Since
we didn't support Px states before, there was no impact.  Also, note that
we delay the write to SMI_CMD until after booting is complete since it
sometimes triggers a change in the frequency and we want to have all
drivers ready to detect/handle this.
2005-02-06 20:12:28 +00:00
Nate Lawson
3045c8af3f Staticize the legacy cpu devclasses and revert the name for the acpi_cpu
devclass.  As pointed out by dfr@, devclasses don't have to share the same
linkage if multiple drivers have the same name.  Newbus should match the
devclasses based on name and allocate non-conflicting unit numbers.
2005-02-06 07:36:08 +00:00
Nate Lawson
76ce4cc456 Convert to the new GAS APIs to allow for detach in the future. Also, check
the PERF_CTRL register in our probe method so that we can tell earlier
that another driver should handle this device due to FFixedHW.  This avoids
scaring users when attach failed when we really wanted probe to fail.
2005-02-05 22:30:57 +00:00
Nate Lawson
f4eb041868 Convert to the new GAS API so that we can free registers in the future. 2005-02-05 22:29:03 +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
26d5f7dfa7 Don't print out a failure message when an attach for FFixedHW fails.
Instead, just fail to attach so another hardware-specific driver can
claim the device.  Also, clean up some small memory leaks in the failure
case.
2005-02-04 18:09:01 +00:00
Nate Lawson
b68b14adaf Return a special status of "not supported" for functional fixed hardware
since this type of register should be handled by another driver.
2005-02-04 18:07:03 +00:00
Nate Lawson
7d3a06201d Make the devclass static for now until deciding whether to share them. 2005-02-04 07:25:44 +00:00
Nate Lawson
6cb2040baf Add the ACPI Performance states driver. This driver offers two or more
settings as exported via the ACPI _PSS method.  OEMs use this interface
to encapsulate chipset or processor-specific methods (e.g., SpeedStep or
Powernow) and export their settings in a standard way.  On systems that
have valid ACPI Performance states and a hardware-specific driver (e.g.,
ichss), acpi_perf(4) is preferred.
2005-02-04 05:45:07 +00:00
Nate Lawson
98aa9cd052 Update the CPU attachments to return CPU_IVAR_PCPU as well as pass on
appropriate requests to any children.
2005-02-04 05:36:40 +00:00
Nate Lawson
286fceb541 Consistently use pcib for a printf. 2005-01-27 20:49:59 +00:00
John Baldwin
b0977ecfd7 Don't create new-bus resources for ACPI extended IRQ resources that are
producers rather than consumers as new-bus resources only handle consumed
resources.  We already do this for the other ACPI resource types that
support the producer/consumer attribute.
2005-01-18 20:21:36 +00:00
John Baldwin
5e15a08100 For the sake of consistency, look up link devices relative to the root
object (/) rather than the pci bus object when walking the _PRT to force
attach devices.  We already look up relative to the root object when doing
interrupt routing.

Suggested by:	njl
2005-01-18 20:20:32 +00:00
John Baldwin
94b3af82c1 - Add support for link devices where _CRS just outright fails to execute.
For such devices, we require _PRS to exist and we warn if any of the
  resources in _PRS are not IRQ resources (since we'll have no way of knowing
  which of those resources to use without a working _CRS).  When it does
  come time to set resources, we build up a resource buffer from scratch
  as we do for devices with _CRS that only have IRQ resources.
- Fix a bug with setting extended IRQ resources where we set the IRQ value
  in the wrong resource structure meaning that whichever IRQ was listed in
  _PRS was used instead.  This might fix some weird issues on certain boxes
  where IRQs > 16 don't seem to work when using ACPI.
- Fix a bug with how we walked the resource buffer after _SRS to call
  config_intr() in that the 'end' variable was not properly updated, so we
  could either terminate the loop early or loop after the end of the
  buffer.

Tested by:	pjd
2005-01-18 20:18:46 +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
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Nate Lawson
2f3f3112c8 Minor cleanup: Reduce stack usage in probe method. Outdent probe. Use
TRUE/FALSE instead of 1/0 for booleans.  Remove trailing and extra whitespace.
2004-12-27 05:42:32 +00:00
Nate Lawson
d05fa56bb3 Remove trailing whitespace. 2004-12-27 05:36:47 +00:00
Nate Lawson
8c702862e4 Only use the current value if there's one IRQ. Some systems return
multiple IRQs (which is nonsense for _CRS) when the link hasn't been
programmed.  Before, this was a KASSERT.  A ServerWorks system was
seen returning IRQs of 0, 2 in response to _CRS before link setup.
Thanks to sam@ for quick testing and turnaround on this.

Tested by:	sam
2004-12-20 10:46:56 +00:00
Nate Lawson
54640fac34 Only report a critical battery level once until it's gone non-critical.
An improvement would be to check all batteries for critical state before
printing a message.

Reported by:	Kevin Oberman (oberman at es net)
2004-12-20 05:03:41 +00:00
Nate Lawson
276cd9216d Unify ACPI_DEBUG support for all OEM drivers under ACPI_OEM. Since more than
one will never be supported on the same platform, this does not hurt
debugging.

MFC after:	3 days
2004-12-13 23:31:46 +00:00
Nate Lawson
6c69283ca8 Re-enable link programming on resume. It appears the previous bounds
error had caused the hang and it has been corrected now.
2004-12-13 06:59:34 +00:00
Scott Long
82d4da0f73 Allow the acpi_ibm module to be built with ACPI_DEBUG. 2004-12-13 03:22:11 +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
ef205c82ca Add the ACPI_PWR_FOR_SLEEP method. It takes a device and outputs the
appropriate power (Dx) state, if the BIOS suggests one.

MFC after:	3 weeks
2004-12-02 08:04:57 +00:00
Mark Santcroos
f8c60df7a6 Catch up with AcpiOsSleep() interface change.
Catch up with some #define's renaming.
Implement AcpiOsGetTimer() as per ACPI 3.0.

Approved by:	njl
MFC after:	1 week
2004-12-02 00:25:35 +00:00
John Baldwin
7e1f562e2a - Do a better job of handling any Dependent Functions (aka DPFs) that appear
in the _PRS or _CRS of link devices.  If faced with multiple DPFs in a
  _PRS, we just use the first one.  We assume that if _CRS has DPF tags they
  only contain a single set since multiple DPFs wouldn't make any sense.  In
  practice, the only DPFs I've seen so far for link devices are that the one
  IRQ resource is surrounded by a DPF tag pair for no apparent reason, and
  this should handle that case fine now.
- Only allocate link structures for IRQ resources for link devices rather
  than allocating a link structure for every resource.

Reviewed by:	njl
Tested by:	phk
2004-12-01 21:05:02 +00:00
Nate Lawson
ba1c3b5304 Completely back out 1.37. Something else is going on and John wants to
keep the locking and solve the real problem.
2004-12-01 05:49:26 +00:00
David E. O'Brien
0297d51ea3 Fix "Lock ACPI PCI link not exclusively locked
@sys/dev/acpica/acpi_pci_link.c:153" panic by backing out rev 1.37 in the SMP
case.  It appears that on a dual-proc machine the assertions in the rev 1.37
commit log hold true.
2004-12-01 04:34:08 +00:00
Nate Lawson
06faf06ac5 Don't bother locking in attach(). At boot time, we're single-threaded
anyway and for some reason, witness seems confused about what's already
locked and triggers a false panic.
2004-11-30 17:48:10 +00:00
Nate Lawson
ad71daf0cb Make sure the link array is big enough to hold both _CRS and _PRS
resource lists.  It used to be sized based only on _CRS, hence _PRS could
perform an out-of-bounds access if it was larger (i.e., when there are
dependent functions).  Add asserts to detect this case.  Note, this is
only a temporary fix and I believe _PRS and _CRS should have separate
arrays.

Also, fix a typo where the wrong irq was being check for the APIC case.

Submitted by:	tegge
2004-11-30 06:55:43 +00:00
Nate Lawson
a811035e4f Instead of translating PCI to ACPI power states, just use a CTASSERT
that they are equivalent.
2004-11-29 18:48:51 +00:00
Nate Lawson
4a29e1698c Temporarily disable programming IRQ links on resume. The new code hangs
several of my systems.
2004-11-26 23:31:59 +00:00
John Baldwin
2dacd5d401 - Remove some no longer used constants.
- Sort function prototypes.
2004-11-23 22:30:03 +00:00
John Baldwin
5e1ba6d4ae Rework the ACPI PCI link code.
- Use a new-bus device driver for the ACPI PCI link devices.  The devices
  are called pci_linkX.  The driver includes suspend/resume support so that
  the ACPI bridge drivers no longer have to poke the links to get them
  to handle suspend/resume.  Also, the code to handle which IRQs a link is
  routed to and choosing an IRQ when a link is not already routed is all
  contained in the link driver.  The PCI bridge drivers now ask the link
  driver which IRQ to use once they determine that a _PRT entry does not
  use a hardwired interrupt number.
- The new link driver includes support for multiple IRQ resources per
  link device as well as preserving any non-IRQ resources when adjusting
  the IRQ that a link is routed to.
- The entire approach to routing when using a link device is now
  link-centric rather than pci bus/device/pin specific.  Thus, when
  using a tunable to override the default IRQ settings, one now uses
  a single tunable to route an entire link rather than routing a single
  device that uses the link (which has great foot-shooting potential if
  the user tries to route the same link to two different IRQs using two
  different pci bus/device/pin hints).  For example, to adjust the IRQ
  that \_SB_.LNKA uses, one would set 'hw.pci.link.LNKA.irq=10' from the
  loader.
- As a side effect of having the link driver, unused link devices will now
  be disabled when they are probed.
- The algorithm for choosing an IRQ for a link that doesn't already have an
  IRQ assigned is now much closer to the one used in $PIR routing.  When a
  link is routed via an ISA IRQ, only known-good IRQs that the BIOS has
  already used are used for routing instead of using probabilities to
  guess at which IRQs are probably not used by an ISA device.  One change
  from $PIR is that the SCI is always considered a viable ISA IRQ, so that
  if the BIOS does not setup any IRQs the kernel will degenerate to routing
  all interrupts over the SCI.  For non ISA IRQs, interrupts are picked
  from the possible pool using a simplistic weighting algorithm.

Tested by:	ru, scottl, others on acpi@
Reviewed by:	njl
2004-11-23 22:26:44 +00:00
Nate Lawson
ae56b59f8b Enable throttling/C3 quirks for PIIX4 parts. Defer checking quirks until
after boot so that PCI is initialized and we can probe for the problem
chipsets.  Note that while probed but unusable states are disabled, they
aren't freed yet.  In the future, it may make sense to detach them.

Tested by:	Adam K Kirchoff <adamk at voicenet com>
MFC after:	2 days
2004-11-16 18:47:42 +00:00
Warner Losh
c2aed5122b After discussions with Nate, repo copy the acpi assist drivers from
i386 to dev/acpi_support.  In theory, these devices could be found
other than in i386 machines only as amd64 becomes more popular.  These
drivers don't appear to do anything i386 specific, so move them to
dev/acpi_support.  Move config lines to files so that those
architectures that don't support kernel modules can build them into
the kernel.  At the same time, rename acpi_snc to acpi_sony to follow
the lead of all the other specialty devices.
2004-11-15 05:54:15 +00:00
Don Lewis
f38e4909dd s/return_VALUE/return / to fix build breakage when ACPI_DEBUG is
defined.
2004-11-14 20:37:41 +00:00
Warner Losh
f454a309d3 Kill ACPI_FUNCTION_TRACE. It is killing the tinderbox build, and it
isn't worth adding to the modules lists that we have to hard code for
this to work.  Since we print PID right away, we have a trace point
already.

Minor knf while I'm here.
2004-11-13 23:39:56 +00:00
Warner Losh
dbacb6c44d Commit takawata-san's Sony Notebook Controller driver, integrated into
the tree.  Small tweaks were made by myself to eliminate unnecessary
includes and some other minor issues.  Last time I asked takawata-san
about this driver, he suggested I commit it.

Submitted by: takawata
2004-11-11 22:54:58 +00:00
John Baldwin
20447d54c4 Only warn about missing _PRT tables if bootverbose is set. I've yet to see
a bridge without a _PRT were a _PRT was needed.  Instead, the warning in
dmesg is a false warning and only serves to cause unnecessary concern.

MFC after:	1 week
2004-11-11 22:33:08 +00:00
Nate Lawson
5b8c471915 unsigned long -> u_long 2004-11-09 07:02:33 +00:00
Nate Lawson
cbd886065b Tell the BIOS we want to handle brightness switching as well as output
switching.  Don't initialize variables in their declaration.  Reduce stack
usage for device names.  Minor style cleanups.

MFC after:	1 week
2004-11-09 04:41:30 +00:00
Poul-Henning Kamp
2a921b0543 Make the bootverbose output from qualitydetermination of the ACPI timer
take up only one line.
2004-11-03 09:09:13 +00:00
Dag-Erling Smørgrav
b0e1e474f7 Add TUNABLE_LONG and TUNABLE_ULONG, and use the latter for the
hw.pci.host_mem_start tunable.  Add comments to TUNABLE_INT and
TUNABLE_QUAD recommending against their use.

MFC after:	3 weeks
2004-10-31 15:50:33 +00:00
Dag-Erling Smørgrav
38228f7221 Whitespace cleanup 2004-10-31 15:02:53 +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
f435261d6d Update C3 support when BM control is not present.
* Fix a bug where caches were flushed on non-C3 transitions.
* Be sure a working flush cache instruction is present before using it.
* Disable C3 completely if it isn't present.
2004-10-11 21:15:10 +00:00
Warner Losh
fd492ee0e6 Make the lower range of the memory area 0x80000000 again. Also
introduce hw.{pci,acpi}.host_mem_start tunable to change this.

MFC: ASAP
2004-10-11 21:10:23 +00:00
Nate Lawson
a0885d3f14 Notify the user when the battery is critically low. In the future, we
may want to shut down here but the chance of BIOS vendors getting this
wrong is high.  They're only supposed to announce this when all batteries
hit their critical level but past experience indicates we should be
conservative about this for now.
2004-10-11 06:18:07 +00:00
Nate Lawson
18ececa0b8 If bus mastering control is not available (PM2_BLK), don't just disable
C3.  Instead, flush caches before entering C3.  This may be slower but
provides good power savings.
2004-10-11 06:06:42 +00:00
Nate Lawson
31ad3b8802 Move the code for halting the CPU (acpi_cpu_c1) into machdep files.
This removes the last MD portion of acpi_cpu.c.

MFC after:	2 weeks
2004-10-11 05:39:15 +00:00
Nate Lawson
4f8c4e4d53 Update a quirk for the ASUS P5A to disable the timer. It appears to work fine
with acpi but the timer runs twice as fast.  Note that the main problem
(system doesn't work properly with acpi disabled) should be fixed separately.

Changes:
* Add a quirk to disable the timer
* Merge the P5A and P5A-B quirks since they appear to be based on the
  same ASL.

PR:		i386/72450
Tested by:	Kevin Oberman <oberman es.net>
MFC after:	3 days
2004-10-08 17:56:47 +00:00
Warner Losh
5cee9db399 For older systems with ACPI which don't have a pci <-> pci bridge,
allocate unallocated memory resources from the top 32MB of the address
space rather than the top 2GB.  While the latter works on some
chipsets, it fails badly on others.  32MB is more conservative and
matches what cheap harware from this era is hardwired to pass.
2004-10-06 07:26:52 +00:00
Nate Lawson
67e87637df When the user overrides the DSDT, replace any SSDTs with a simple no-op
table.  acpidump(8) concatenates the body of the DSDT and SSDTs so an
edited ASL will contain all the necessary information.  We can't use a
completely empty table since ACPI-CA reports this as a problem.

MFC after:	3 days
2004-10-05 20:41:44 +00:00
Nate Lawson
6e1151b6ab Allow routing to the SCI even if it's not in the list of valid IRQs.
MFC if:		no problems
2004-09-25 06:15:56 +00:00
John Baldwin
e0a9358679 Add a couple of macros to extract the PCI slot (device) and function from
an ACPI _ADR value and use that rather than inlining the same shifts and
masks everywhere.
2004-09-22 15:46:16 +00:00