Commit Graph

476 Commits

Author SHA1 Message Date
Nate Lawson
4a03551ddd Use uintmax_t for CPU statistics and add a cast to prevent truncation of
the statistics in a multiply.

Pointed out by:	YONETANI Tomokazu
2004-06-24 00:38:51 +00:00
John Baldwin
95957f6256 - Defer BUS_CONFIG_INTR() on ACPI IRQ resources until the resources are
actually used.  For most ACPI devices this means deferring the call
  until bus_alloc_resource().
  - Add a function acpi_config_intr() to call BUS_CONFIG_INTR() for an
    ACPI IRQ resource using the trigger mode and polarity information
    stored in the ACPI resource object.
  - Add a function acpi_lookup_irq_resource() to lookup the ACPI IRQ
    resource that corresponds to a specified rid and new-bus resource.
  - Have the ACPI PCI bridge driver call BUS_CONFIG_INTR() on interrupts
    that it routes through link devices.
- Remove needactivate variable from acpi_alloc_resource() by changing the
  function not modify the flags variable but just mask off RF_ACTIVE when
  calling rman_reserve_resource().

Reviewed by:	njl (1, an earlier version)
2004-06-23 17:21:02 +00:00
John Baldwin
81bb99d26b Now that we associate a device_t with ACPI device handles, lookup the
device associated with any PCI devices that are enumerated in the ACPI
tree when adding children to an ACPI PCI bus and remove the duplicate
ACPI-only device_t and replace the device_t associated with the handle with
the ACPI and PCI aware device_t.
2004-06-23 15:08:40 +00:00
Christian Brueffer
889608790b Fix typos and add spaces before `(' in some comments
Submitted by:	markus
Approved by:	njl
MFC after:	3 days
2004-06-22 08:23:26 +00:00
Nate Lawson
3e7fa136ea Add more precision to the cx_usage sysctl output and special-case 0%.
Submitted by:	YONETANI Tomokazu <qhwt+freebsd-acpi AT les.ath.cx>
2004-06-19 02:27:23 +00:00
Nate Lawson
98910d5551 Remove compat code and unused lock declarations. 2004-06-18 17:58:11 +00:00
Nate Lawson
c5fe3c3311 Remove compat defines. 2004-06-18 17:56:45 +00:00
Poul-Henning Kamp
89c9c53da0 Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.
2004-06-16 09:47:26 +00:00
John Baldwin
522542cc9c Revert the removal of the initial_irq hack for now as this code is more
broken than I thought and doesn't do a good job of routing virgin
interrupts at all.
2004-06-14 18:54:14 +00:00
Nate Lawson
59e472e952 Remove disable_on_poweroff and our pre-sync shutdown handler. Disabling
of GPEs is now done in acpi_shutdown() and so we no longer need the option
of disabling ACPI in the poweroff case.
2004-06-14 04:37:45 +00:00
Nate Lawson
b82ca9a91f Clean up acpi_probe_order() a bit and clarify some comments. 2004-06-14 04:01:12 +00:00
Nate Lawson
f504b6074b Don't probe/attach in the ACPI_DEBUG case. 2004-06-14 03:52:19 +00:00
Nate Lawson
9123341378 Add support to ACPI to manage its own resources. Previously, resource
allocation was passed up to nexus.  Now, we probe sysresource objects and
manage the resources they describe in a local rman pool.  This helps
devices which attach/detach varying resources (like the _CST object) and
module loads/unloads.  The allocation/release routines now check to see if
the resource is described in a child sysresource object and if so,
allocate from the local rman.  Sysresource objects add their resources to
the pool and reserve them upon boot.  This means sysresources need to be
probed before other ACPI devices.

Changes include:
* Add ordering to the child device probe.  The current order is:  system
resource objects, embedded controllers, then everything else.
* Make acpi_MatchHid take a handle instead of a device_t arg.
* Replace acpi_{get,set}_resource with the generic equivalents.
2004-06-13 22:52:30 +00:00
Nate Lawson
59a890e6a3 Associate a device_t with an ACPI_HANDLE. This make AcpiWalkNamespace more
useful.  If ACPI-CA allowed null object handlers, we wouldn't need the
placeholder function.
2004-06-13 17:29:35 +00:00
Nate Lawson
1f36889f63 Remove accidental change. 2004-06-07 21:44:01 +00:00
Nate Lawson
45e556cc69 Avoid printing extraneous warning messages when trying to switch a device
which doesn't support ACPI power states.  Return AE_NOT_FOUND for these
cases and don't print the warning message.  Also, print the name of the
handle instead of device when unable to switch states.  The device is often
not attached at this point and so its name is NULL, which doesn't help
debugging.
2004-06-07 21:39:15 +00:00
John Baldwin
4dc4ea2604 - Use PCI_INVALID_IRQ macro rather than a magic number.
- Remove obsolete comment about APIC_IO routing.
2004-06-07 17:36:22 +00:00
Nate Lawson
0e4148688c Don't forget to pass shutdown events down to children first now that we
handle them at the bus level too.
2004-06-05 09:56:04 +00:00
Nate Lawson
169b539a33 Disable wake GPEs in the reboot path as well as poweroff path. This fixes
"stray irq 9" messages on my Thinkpad.  It may also help with general
reboot consistency although the recent hang on reboot was solved by
acpi_cpu.c rev 1.39.
2004-06-05 07:25:58 +00:00
Nate Lawson
a2afe45a8a Rework acpi_cpu_idle() to select the next idle state before sleeping, not
after.  Unify the paths for all Cx states.  Remove cpu_idle_busy and
instead do the little profiling we need before re-enabling interrupts.
Use 1 quantum as estimate for C1 sleep duration since the timer interrupt
is the main reason we wake.

While here, change the cx_history sysctl to cx_usage and report statistics
for which idle states were used in terms of percent.  This seems more
intuitive than counters.  Remove the cx_stats structure since it's no
longer used.  Update the man page.

Change various types which do not need explicit size.
2004-06-05 07:02:18 +00:00
Peter Wemm
f2b6954343 Work around the preemption problem in acpi_cpu.c for shutting down.
Submitted by:  nate / jhb
2004-06-04 17:03:18 +00:00
Poul-Henning Kamp
fe12f24bb0 Add missing <sys/module.h> includes 2004-05-30 20:08:47 +00:00
Nate Lawson
2b9609ab9b Decrease sleep_delay default to 1 second now that the machines that
required the 5 second delay have been fixed.
2004-05-29 05:34:04 +00:00
Nate Lawson
5acd02180c Style cleanups, don't set the device description before the probe routine
has completed successfully.
2004-05-29 04:32:50 +00:00
John Baldwin
91c14f698c Don't assume that the current setting (_CRS) of a PCI link device is
correct.  Instead, check it against the possible settings (_PRS) when
the link is probed.  This is important when using APIC mode but link
devices still have PIC mode settings.  This is also what Linux does.

Additional prodding by:	Len Brown len dot brown at intel dot com
2004-05-28 17:31:32 +00:00
Nate Lawson
e3aa81b84d Style fixes. 2004-05-28 16:38:37 +00:00
Nate Lawson
043498df33 Now that we properly disable GPEs before entering a sleep state, including
S5 (soft off), we don't need to disable ACPI when powering off.  This may
fix some systems that don't power off correctly.
2004-05-28 07:16:52 +00:00
Nate Lawson
54af2f27c7 Style cleanups. "extern" is unneeded for function prototypes. 2004-05-28 07:15:55 +00:00
Nate Lawson
cc85c78ce3 Update the new suspend/resume GPE methods to properly limit the GPE
based on the destination sleep state.  Add a method to restore the old
state on resume.  This is needed for the case of suspending to a very low
state disabling a GPE (i.e. S4), resuming, and then suspending to a higher
state (i.e. S3).  This case should now keep the proper GPEs enabled.
2004-05-28 07:04:09 +00:00
Nate Lawson
44b8ae7193 Pass a pointer to the sleep state instead of casting gymnastics to pass
the value itself in the pointer.
2004-05-28 06:32:16 +00:00
Nate Lawson
5c9ea25e69 Fix paste-o. 2004-05-28 06:29:30 +00:00
Nate Lawson
88a79fc05b Attach per-device sysctls to allow users to set whether or not a given
device can wake the system.  For example:

    dev.root0.nexus0.acpi0.acpi_lid0.wake: 1
    dev.root0.nexus0.acpi0.acpi_button0.wake: 1
    dev.root0.nexus0.acpi0.pcib0.wake: 0
    dev.root0.nexus0.acpi0.sio0.wake: 0
2004-05-28 06:28:55 +00:00
Marcel Moolenaar
80c74f3d56 Fix LP64 environments: cast a pointer type to intptr_t before casting
to int and vice versa.
2004-05-28 02:50:43 +00:00
Nate Lawson
e8b4d56eb5 Restructure the wake GPE API. Now there are three functions:
acpi_wake_init:
    Evaluate _PRW and set the GPE type
acpi_wake_set_enable:
    Enable or disable a device's GPE.
acpi_wake_sleep_prep:
    Perform any last-minute changes to the device to prepare it for
    entering the given sleep state.

Also, walk the entire namespace when transitioning to a sleep state,
disabling any GPEs which aren't appropriate for the given state.  Transition
acpi_lid and acpi_button to the new API.

This clears the way for non-ACPI-aware devices to wake the system (i.e.
modems) and fixes a problem where systems power up after shutdown when a
GPE is triggered.
2004-05-27 18:38:45 +00:00
Nate Lawson
841caa96b4 Enable GPE at runtime rather than suspend time. This is to match the
new behavior in ACPI-CA that defers GPE configuration.  This is a temporary
measure while reworking the GPE interface.
2004-05-25 16:17:39 +00:00
Nate Lawson
09a98d8ce9 Remove call to _INI for thermal devices. ACPI-CA now calls _INI for
Devices, ThermalZones, and Processors.
2004-05-25 04:18:22 +00:00
Nate Lawson
f3fc4f8b4a Changes to implement 20040514:
* Add calls to AcpiSetGpeType.  We use wake/run as the type for lid and
button switches since wake-only causes Thinkpads to immediately wake on
the second suspend.  Note that with wake/run, some systems return both
wake and device-specific notifies so we don't register for system notifies
for lid and button switches.
* Remove the hw.acpi.osi_method tunable since it is not needed.
* Always print unknown notifies for all types.
* Add more cleanup for the EC if it fails to attach.
* Use the GPE handle now that we parse it.  This allows GPEs to be defined
in AML GPE blocks.
* Always use ACPI_NOT_ISR since it's ok to acquire a mutex in our thread
which processes queued requests.
2004-05-25 02:47:35 +00:00
Nate Lawson
12957d4991 Revert the previous commit. The bus accessor macros do not check the
return value for BUS_READ_IVAR and thus don't generate the proper NULL
in cases where a device (i.e. on PCI) does not have a handle.

Found by:	peadar, tjr
2004-05-22 17:19:59 +00:00
Nate Lawson
14e2b11f18 Use the simpler __BUS_ACCESSOR macros for ivars instead of defining them
ourselves.
2004-05-18 16:53:29 +00:00
Nate Lawson
0025fb0f4f Add support for GPE being a package of { reference, gpe bit }.
Rework the ECDT probe to pass all the parameters in a temporary struct.
Note why we are mostly ok evaluating _GLK so early.
2004-05-14 04:17:56 +00:00
Nate Lawson
c868ac7d12 Add support for retrieving _GLK in the ECDT probe. Now we no longer always
use the global lock at the beginning of the ECDT probe.  Instead, we use
the handle from the ECDT to call _GLK.  Also, unify the device description.
2004-05-13 03:17:08 +00:00
John Baldwin
fb0ac5433b If an ACPI PCI-PCI bridge doesn't have a _PRT object, fall back to using
the swizzle method for routing PCI interrupts across the bridge.  This
fixes problems with motherboards (typically laptops) whose BIOS doesn't
provide a PRT for the AGP bridge even though there is a device entry for
the bridge in the ACPI namespace.

Tested by:	Kenneth Culver culverk at sweetdreamsracing dot biz
2004-05-10 18:26:22 +00:00
Nate Lawson
ccc09458fa Change hw.acpi.cpu.cx_lowest to accept values in the form of C1,
C2, ...  Update power_profile to use the new format.  Update the
man page to reflect this and give more info on Cx states.
2004-05-07 05:22:38 +00:00
Nate Lawson
b0e2b625f2 Rename acpi_cpu to cpu. Change the probe routine to early on reject
devices it cannot attach to.  This gets rid of extraneous but harmless
device_probe_and_attach() errors.  While I'm here, make the device
description more useful.  The !acpi case for cpu is handled by legacy0.
2004-05-06 17:25:23 +00:00
Nate Lawson
ea27c63ec6 Select the highest valid (i.e., S3) sleep state for the default for the
sleep button.  Change the default for the lid switch to NONE.  This can
be overridden in /etc/sysctl.conf as desired.
2004-05-06 08:04:34 +00:00
Nate Lawson
2fb3498126 Add back sys/reboot.h which is needed. 2004-05-06 02:57:24 +00:00
Nate Lawson
869ec176fc Make unnecessary globals static and remove unused includes.
Pointed out by:	cscout
2004-05-06 02:18:58 +00:00
Nate Lawson
7e639165c2 Fix setting debug strings via sysctl. Also, clean up the way we print
debug strings.
2004-05-06 02:05:45 +00:00
Nate Lawson
c8dd768173 Remove extra parentheses. 2004-05-05 20:07:52 +00:00
Nate Lawson
65a7c90189 Add an MI implementation of the ACPI global lock routines and retire the
individual asm versions.  The global lock is shared between the BIOS and
OS and thus cannot use our mutexes.  It is defined in section 5.2.9.1 of
the ACPI specification.

Reviewed by:	marcel, bde, jhb
2004-05-05 20:04:14 +00:00