History log of /freebsd-9.3-release/sys/dev/acpica/acpi_cpu.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 244618 23-Dec-2012 avg

MFC r243404: acpi_cpu: use fixed resource ids for cx state i/o resources


# 244616 23-Dec-2012 avg

MFC r243761: acpi_cpu_notify: disable acpi_cpu_idle while updating
C-state data


# 244614 23-Dec-2012 avg

MFC r243760: acpi_cpu: change cpu_disable_idle to be a per-cpu flag


# 243562 26-Nov-2012 mav

MFC r238943:
Add several performance optimizations to acpi_cpu_idle().

For C1 and C2 states use cpu_ticks() to measure sleep time instead of much
slower ACPI timer. We can't do it for C3, as TSC may stop there. But it is
less important there as wake up latency is high any way.

For C1 and C2 states do not check/clear bus mastering activity status, as
it is important only for C3. As side effect it can make CPU enter C2 instead
of C3 if last BM activity was two sleeps back (unlike one before), but
that may be even good because of collecting more statistics. Premature BM
wakeup from C3, entered because of overestimation, can easily be worse then
entering C2 from both performance and power consumption points of view.

Together on dual Xeon E5645 system on sequential 512 bytes read test this
change makes cpu_idle_acpi() as fast as simplest cpu_idle_hlt() and only
few percents slower then cpu_idle_mwait(), while deeper states are still
actively used during idle periods.

To help with diagnostics, add C-state type into dev.cpu.X.cx_supported.

PR: kern/170021


# 241524 14-Oct-2012 avg

MFC r240634: acpi_cpu: explicitly notify userland about c-state changes


# 239815 29-Aug-2012 avg

MFC r238229: acpi_cpu: we are able to handle _CST change notifications


# 239813 29-Aug-2012 avg

MFC r238194: acpi_cpu_generic_cx_probe: for consistency set cpu_non_c3
here too


# 239812 29-Aug-2012 avg

MFC r238193: acpi_cpu_cx_list: there is no need to re-evaluate
cpu_non_c3 here


# 239809 29-Aug-2012 avg

MFC r238192: acpi_cpu_cx_cst: consistently use cpu_cx_count during state
enumeration


# 239807 29-Aug-2012 avg

MFC r238418: acpi_cpu: separate a notion of current deepest
allowed+available Cx level from a user-set persistent limit on the said level


# 237822 29-Jun-2012 jhb

MFC 235024,235029,235556,235834,235845:
Use MADT to match ACPI Processor objects to CPUs. MADT and DSDT/SSDTs may
list CPUs in different orders, especially for disabled logical cores. Now
we match ACPI IDs from the MADT with Processor objects, strictly order CPUs
accordingly, and ignore disabled cores. This prevents us from executing
methods for other CPUs, e. g., _PSS for disabled logical core, which may not
exist. Unfortunately, it is known that there are a few systems with buggy
BIOSes that do not have unique ACPI IDs for MADT and Processor objects. To
work around these problems, 'debug.acpi.cpu_unordered' tunable is added.
Set this to a non-zero value to restore the old behavior.


# 229093 31-Dec-2011 hselasky

MFC r226173, r227843, r227848 and r227908:
Use DEVMETHOD_END to mark end of device methods.
Remove superfluous device methods.
Add some missing __FBSBID() macros.


# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 223527 25-Jun-2011 marcel

Now that ia64 has been switched to the event timers, remove the
conditional compilation work-arounds.


# 223449 22-Jun-2011 jkim

Fix build on ia64 after r223426.


# 223426 22-Jun-2011 jkim

Set negative quality to TSC timecounter when C3 state is enabled for Intel
processors unless the invariant TSC bit of CPUID is set. Intel processors
may stop incrementing TSC when DPSLP# pin is asserted, according to Intel
processor manuals, i. e., TSC timecounter is useless if the processor can
enter deep sleep state (C3/C4). This problem was accidentally uncovered by
r222869, which increased timecounter quality of P-state invariant TSC, e.g.,
for Core2 Duo T5870 (Family 6, Model f) and Atom N270 (Family 6, Model 1c).

Reported by: Fabian Keil (freebsd-listen at fabiankeil dot de)
Ian FREISLICH (ianf at clue dot co dot za)
Tested by: Fabian Keil (freebsd-listen at fabiankeil dot de)
- Core2 Duo T5870 (C3 state available/enabled)
jkim - Xeon X5150 (C3 state unavailable)


# 220433 07-Apr-2011 jkim

Use atomic load & store for TSC frequency. It may be overkill for amd64 but
safer for i386 because it can be easily over 4 GHz now. More worse, it can
be easily changed by user with 'machdep.tsc_freq' tunable (directly) or
cpufreq(4) (indirectly). Note it is intentionally not used in performance
critical paths to avoid performance regression (but we should, in theory).
Alternatively, we may add "virtual TSC" with lower frequency if maximum
frequency overflows 32 bits (and ignore possible incoherency as we do now).


# 216443 14-Dec-2010 jkim

Stop lying about supporting cpu_est_clockrate() when TSC is invariant. This
function always returned the nominal frequency instead of current frequency
because we use RDTSC instruction to calculate difference in CPU ticks, which
is supposedly constant for the case. Now we support cpu_get_nominal_mhz()
for the case, instead. Note it should be just enough for most usage cases
because cpu_est_clockrate() is often times abused to find maximum frequency
of the processor.


# 215188 12-Nov-2010 jkim

Create C1 state when _CST is valid but _CST does not have one. Some BIOSes
do not report C1 state in _CST object, probably because it is a mandatory
state with or without existence of the optional _CST.

Reviewed by: avg


# 212997 22-Sep-2010 mav

Quick fix for unmotivated C2 state usage during boot, introduced at r212541.
That caused LAPIC timer failure and huge delays during boot on some systems.


# 212549 13-Sep-2010 avg

acpi_cpu: do not apply P_LVLx_LAT rules to latencies returned by _CST

ACPI specification sates that if P_LVL2_LAT > 100, then a system doesn't
support C2; if P_LVL3_LAT > 1000, then C3 is not supported.
But there are no such rules for Cx state data returned by _CST. If a
state is not supported it should not be included into the return
package. In other words, any latency value returned by _CST is valid,
it's up to the OS and/or user to decide whether to use it.

Submitted by: nork
Suggested by: mav
MFC after: 1 week


# 212541 13-Sep-2010 mav

Refactor timer management code with priority to one-shot operation mode.
The main goal of this is to generate timer interrupts only when there is
some work to do. When CPU is busy interrupts are generating at full rate
of hz + stathz to fullfill scheduler and timekeeping requirements. But
when CPU is idle, only minimum set of interrupts (down to 8 interrupts per
second per CPU now), needed to handle scheduled callouts is executed.
This allows significantly increase idle CPU sleep time, increasing effect
of static power-saving technologies. Also it should reduce host CPU load
on virtualized systems, when guest system is idle.

There is set of tunables, also available as writable sysctls, allowing to
control wanted event timer subsystem behavior:
kern.eventtimer.timer - allows to choose event timer hardware to use.
On x86 there is up to 4 different kinds of timers. Depending on whether
chosen timer is per-CPU, behavior of other options slightly differs.
kern.eventtimer.periodic - allows to choose periodic and one-shot
operation mode. In periodic mode, current timer hardware taken as the only
source of time for time events. This mode is quite alike to previous kernel
behavior. One-shot mode instead uses currently selected time counter
hardware to schedule all needed events one by one and program timer to
generate interrupt exactly in specified time. Default value depends of
chosen timer capabilities, but one-shot mode is preferred, until other is
forced by user or hardware.
kern.eventtimer.singlemul - in periodic mode specifies how much times
higher timer frequency should be, to not strictly alias hardclock() and
statclock() events. Default values are 2 and 4, but could be reduced to 1
if extra interrupts are unwanted.
kern.eventtimer.idletick - makes each CPU to receive every timer interrupt
independently of whether they busy or not. By default this options is
disabled. If chosen timer is per-CPU and runs in periodic mode, this option
has no effect - all interrupts are generating.

As soon as this patch modifies cpu_idle() on some platforms, I have also
refactored one on x86. Now it makes use of MONITOR/MWAIT instrunctions
(if supported) under high sleep/wakeup rate, as fast alternative to other
methods. It allows SMP scheduler to wake up sleeping CPUs much faster
without using IPI, significantly increasing performance on some highly
task-switching loads.

Tested by: many (on i386, amd64, sparc64 and powerc)
H/W donated by: Gheorghe Ardelean
Sponsored by: iXsystems, Inc.


# 212413 10-Sep-2010 avg

bus_add_child: change type of order parameter to u_int

This reflects actual type used to store and compare child device orders.
Change is mostly done via a Coccinelle (soon to be devel/coccinelle)
semantic patch.
Verified by LINT+modules kernel builds.

Followup to: r212213
MFC after: 10 days


# 209330 19-Jun-2010 mav

Oops! Add " / hz" missed in r209328. Assume interrupt rate hz/2, not 1/2.


# 209328 19-Jun-2010 mav

While we indeed can't precisely measure time spent in C1, we can consider
measured interval as upper bound. It should be more precise then just
assuming hz/2. For idle CPU it should be quite precise, for busy - not
worse then before.


# 209213 15-Jun-2010 jhb

When updating individual CPU's lowest Cx state to use, never set it to a
state lower than the lowest one supported by the current CPU. This closes
some races with changes to the hw.acpi.cpu_cx_lowest sysctl while Cx
states for individual CPUs were changing (e.g. unplugging the AC adapter
of a laptop) that could result in panics.

Submitted by: Giovanni Trematerra
Tested by: David Demelier demelier dot david of gmail
MFC after: 3 days


# 209059 11-Jun-2010 jhb

Update several places that iterate over CPUs to use CPU_FOREACH().


# 203776 11-Feb-2010 avg

acpi cpu: probe+attach before all other enumerated children on acpi bus

Some current systems dynamically load SSDT(s) when _PDC/_OSC method
of Processor is evaluated. Other devices in ACPI namespace may access
objects defined in the dynamic SSDT. Drivers for such devices might
have to have a rather high priority, because of other dependencies.
Good example is acpi_ec driver for EC.
Thus we attach to Processors as early as possible to load the SSDTs
before any other drivers may try to evaluate control methods.
It also seems to be a natural order for a processor in a device
hierarchy.

On the other hand, some child devices on acpi cpu bus need to access
other system resources like PCI configuration space of chipset devices,
so they need to be probed and attached rather late.
For this reason we probe and attach the cpu bus at
SI_SUB_CONFIGURE:SI_ORDER_MIDDLE SYSINIT level.
In the future this could be done more elegantly via multipass.

Please note that acpi drivers that might access ACPI namespace from
device_identify will do that before _PDC/_OSC of Processors are evaluated.

Legacy cpu driver is not affected by this change.

PR: kern/142561 (in part)
Reviewed by: jhb
Silence from: acpi@
MFC after: 5 weeks


# 203546 06-Feb-2010 avg

acpi_cpu: prefer _OSC over _PDC, just in case

_PDC was deprecated in favor of _OSC long time ago, but it
seems that they still peacefully coexist and in some case
only _PDC is present.
Still _OSC provides a reacher interface and is capable to
report back its status.
If the status is non-zero, then report it, we may find
it useful to understand what firmware expects from OS.
Also clean up some comments that became less useful over time.

Reviewed by: njl, jhb, rpaulo
MFC after: 3 weeks


# 203430 03-Feb-2010 avg

acpi_cpu: correct capabilities arguments for Processor _OSC evaluation

Populate capabilities buffer according to
Intel Processor Vendor-Specific ACPI Interface Specification.

MFC after: 2 weeks


# 199016 07-Nov-2009 avg

acpi: remove 'magic' ivar

o acpi_hpet: auto-added 'wildcard' devices can be identified by
non-NULL handle attribute.
o acpi_ec: auto-add 'wildcard' devices can be identified by
unset (NULL) private attribute.
o acpi_cpu: use private instead of magic to store cpu id.

Reviewed by: jhb
Silence from: acpi@
MFC after: 2 weeks
X-MFC-Note: perhaps the ivar should stay for ABI stability


# 197105 11-Sep-2009 jkim

Catch up with ACPICA 20090903.


# 196403 20-Aug-2009 jhb

Temporarily revert the new-bus locking for 8.0 release. It will be
reintroduced after HEAD is reopened for commits by re@.

Approved by: re (kib), attilio


# 196037 02-Aug-2009 attilio

Make the newbus subsystem Giant free by adding the new newbus sxlock.
The newbus lock is responsible for protecting newbus internIal structures,
device states and devclass flags. It is necessary to hold it when all
such datas are accessed. For the other operations, softc locking should
ensure enough protection to avoid races.

Newbus lock is automatically held when virtual operations on the device
and bus are invoked when loading the driver or when the suspend/resume
take place. For other 'spourious' operations trying to access/modify
the newbus topology, newbus lock needs to be automatically acquired and
dropped.

For the moment Giant is also acquired in some key point (modules subsystem)
in order to avoid problems before the 8.0 release as module handlers could
make assumptions about it. This Giant locking should go just after
the release happens.

Please keep in mind that the public interface can be expanded in order
to provide more support, if there are really necessities at some point
and also some bugs could arise as long as the patch needs a bit of
further testing.

Bump __FreeBSD_version in order to reflect the newbus lock introduction.

Reviewed by: ed, hps, jhb, imp, mav, scottl
No answer by: ariff, thompsa, yongari
Tested by: pho,
G. Trematerra <giovanni dot trematerra at gmail dot com>,
Brandon Gooch <jamesbrandongooch at gmail dot com>
Sponsored by: Yahoo! Incorporated
Approved by: re (ksmith)


# 193530 05-Jun-2009 jkim

Import ACPICA 20090521.


# 191764 03-May-2009 mav

Make dev.cpu.X.cx_usage sysctl also report current average of sleep time.


# 191763 03-May-2009 mav

Remove unused variable and fix spelling in comment.


# 191760 02-May-2009 mav

Avoid comparing negative signed to positive unsignad values. It was
leading to a bug, when C-state does not decrease on sleep shorter then
declared transition latency. Fixing this deprecates workaround for broken
C-states on some hardware.

By the way, change state selecting logic a bit. Instead of last sleep
time use short-time average of it. Global interrupts rate in system is a
quite random value, to corellate subsequent sleeps so directly.


# 190454 26-Mar-2009 jhb

Move the code to update cpu_cx_count out of acpi_cpu_generic_cx_probe() and
into acpi_cpu_startup() which is where all the other code to update this
global variable lives. This fixes a bug where cpu_cx_count was not updated
correctly if acpi_cpu_generic_cx_probe() returned early.

PR: kern/108581
Debugged by: Bruce Cran
Reviewed by: avg, njl, sepotvin
MFC after: 3 days


# 188814 19-Feb-2009 avg

acpi_cpu: fixup for PIIX4E PCI config related to C2

This is triggered only if BIOS configures ACPI_BITREG_BUS_MASTER_RLD
aka BRLD_EN_BM to 1.
Rationale:
1. we do not support C3 on PIIX4E
2. bus master activity need not break out of C2 state
3. because of CPU_QUIRK_NO_BM_CTRL quirk we may reset bus master
status which would result in immediate break out from C2

So if you have seen
cpu0: too many short sleeps, backing off to C1
with this chipset before you may want to try cx_lowest of C2 again.

Reviewed by: rpaulo (mentor), njl
Approved by: rpaulo (mentor)


# 178146 12-Apr-2008 rpaulo

Update the list of Cx states when ACPICA notifies us. Usually, this
notification is sent when the AC plug is plugged in/out.

This is required on some laptops, namely the MacBooks.

Silence on: freebsd-acpi


# 176972 09-Mar-2008 rpaulo

Some PIIX4 chipsets need to be told to generate Stop Breaks by setting
the appropriate bit in the DEVACTB register.
This change allows the C2 state on those systems to work as expected.

Reviewed by: njl
Submitted by: Andriy Gapon <avg at icyb.net.ua>
MFC after: 1 week


# 176326 16-Feb-2008 rpaulo

Skip validation of the C3 state if we disabled C3 by software (i.e.,
via quirk).

Submitted by: Andriy Gapon <avg at icyb.net.ua>
Reviewed by: njl (mentor)
Approved by: njl (mentor)
Requested by: njl (mentor)
MFC after: 3 days


# 176205 12-Feb-2008 jhb

Fix a typo when testing for the NO_C3 quirk.

MFC after: 3 days


# 173284 02-Nov-2007 njl

Fix a shutdown hang on some SMP systems. The previous logic was to IPI all
CPUs to make sure idle threads are evicted from the softc before returning
from acpi_cpu_shutdown(). However, this is unnecessary since stop_cpus()
handles this for itself and at this point it's possible that our IPI will be
blocked (interrupts disabled).

Thanks to: Glen Leeder <glen.leeder / nokia.com>
MFC after: 3 days


# 172022 30-Aug-2007 njl

Evaluate _OSC on boot to indicate our OS capabilities to ACPI. This is
needed at least to convince the BIOS to give us access to CPU freq
control on MacBooks.

Submitted by: Rui Paulo <rpaulo / fnop.net>
Approved by: re
MFC after: 5 days


# 170228 02-Jun-2007 njl

Disable CPU idle states during suspend and reenable them during resume.
While in the suspend path, this means the idle thread will just return
immediately rather than trying to enter C1-n. This helps in the case where
the chipset is powered down before the rest of the system and reads from
the cpu sleep registers begin returning immediately, causing the logic that
catches bad C2/C3 behavior to kick in. Observed on my Panasonic Y4.

MFC after: 3 days


# 170214 02-Jun-2007 njl

Fix a bug introduced in the per-CPU Cx states commit. The wrong loop var
(j/i) was being used and it was being incremented, not decremented as before.
Factor out this code into a common function and call it from both the common
and per-CPU case.

MFC after: 1 day


# 167814 22-Mar-2007 jkim

Catch up with ACPI-CA 20070320 import.


# 166184 23-Jan-2007 njl

Add missing function trace for debug prints.


# 166027 15-Jan-2007 njl

Clean up some debug prints from last commit and move one under boot -v.
Reminded by: bruno


# 165882 07-Jan-2007 njl

Fix LINT and ACPI_DEBUG builds and add print for use of flush cache inst.


# 165875 07-Jan-2007 njl

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


# 151678 25-Oct-2005 njl

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


# 150003 11-Sep-2005 obrien

Canonize the include of acpi.h.


# 144878 10-Apr-2005 njl

Advertise that we can handle unified SMP control of processor power
states, idling, etc. This has been supported since the cpufreq import.


# 144875 10-Apr-2005 njl

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.


# 144629 04-Apr-2005 njl

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.


# 144170 27-Mar-2005 njl

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


# 141429 07-Feb-2005 njl

Remove handling _PSS notifies from acpi_cpu and let acpi_perf handle them.


# 141415 06-Feb-2005 njl

Remove acpi throttling support from the acpi_cpu(4) driver now that this
is supported by acpi_throttle(4).


# 141411 06-Feb-2005 njl

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.


# 141380 06-Feb-2005 njl

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.


# 141372 05-Feb-2005 njl

Convert to the new GAS API so that we can free registers in the future.


# 141251 04-Feb-2005 njl

Make the devclass static for now until deciding whether to share them.


# 141238 04-Feb-2005 njl

Update the CPU attachments to return CPU_IVAR_PCPU as well as pass on
appropriate requests to any children.


# 137780 16-Nov-2004 njl

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


# 136398 11-Oct-2004 njl

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.


# 136368 11-Oct-2004 njl

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.


# 136366 11-Oct-2004 njl

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


# 133616 13-Aug-2004 njl

MPSAFE locking

* Hold the ACPI lock over table register writes.
* Serialize calls to acpi_cpu_throttle_set() and the sysctls.


# 131002 23-Jun-2004 njl

Use uintmax_t for CPU statistics and add a cast to prevent truncation of
the statistics in a multiply.

Pointed out by: YONETANI Tomokazu


# 130704 19-Jun-2004 njl

Add more precision to the cx_usage sysctl output and special-case 0%.

Submitted by: YONETANI Tomokazu <qhwt+freebsd-acpi AT les.ath.cx>


# 130113 05-Jun-2004 njl

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.


# 130080 04-Jun-2004 peter

Work around the preemption problem in acpi_cpu.c for shutting down.

Submitted by: nate / jhb


# 129879 30-May-2004 phk

Add missing <sys/module.h> includes


# 129021 07-May-2004 njl

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.


# 129014 06-May-2004 njl

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.


# 128503 20-Apr-2004 njl

Move the timer difference convenience function from acpi_cpu.c to make it
globally available. acpi_TimerDelta() subtracts two readings from the
ACPI PM timer and returns the difference. It properly distinguishes between
24-bit and 32-bit timers and handles wraparound.


# 128071 09-Apr-2004 njl

Add MODULE_DEPEND entries so some of these drivers can eventually be
loaded separately from ACPI (i.e., embedded use).


# 127147 17-Mar-2004 njl

Fix border error to allow systems that specify 100 for latency also use
C2 and 1000 to use C3.

Submitted by: Bruno Ducrot <ducrot@poupinou.org>
Tested by: Scott Lambert <lambert@lambertfam.org>


# 126663 05-Mar-2004 njl

Document a sysctl.

Submitted by: Craig Rodrigues <rodrigc@crodrigues.org>


# 126575 04-Mar-2004 njl

Don't disable Cx support and throttling on machines with a P_BLK_LEN != 6
even though the spec mandates this. Some have a value of 5 to indicate
throttling + C2 and some have 7 to indicate an extra C3 state. Support
throttling if the value is >= 4, C2 for >= 5, and C3 for >= 6.


# 123942 28-Dec-2003 njl

Don't attach throttling if the P_BLK is 0, even if the P_BLK_LEN is 6.
This is more strict but no known systems have this problem.


# 123776 23-Dec-2003 njl

Remove the device_t parameter from package routines that only used it to
print an error message. Update all callers of the package routines.


# 123624 18-Dec-2003 njl

Remove power profile support from acpi_cpu, it will be managed by a
script run from devd(8).


# 123496 12-Dec-2003 njl

Fix throttling to use the proper mask. The bug resulted in only two
throttling values being available regardless of the CPU's capabilities.
This has been broken since rev 1.1. Also clarify a comment.

Submitted by: Taku YAMAMATO <taku@cent.saitama-u.ac.jp>


# 123400 10-Dec-2003 jhb

Trim trailing whitespace.


# 123325 09-Dec-2003 njl

We don't need to call _INI on processor objects now that ACPI-CA does
this as it should.


# 123132 03-Dec-2003 jhb

Update this driver to be more module friendly:
- Dynamically allocate the cpu_softc[] array based on mp_maxid instead of
using a statically sized array that depended on 'options SMP'.
- Use mp_maxid rather than MAXCPU when walking all the CPUs looking for a
match.
- Always call smp_rendezvous() since UP kernels now provide this.
- Use mp_ncpus rather than cpu_ndevices when determining if we need to
disable C3 for SMP machines.

Approved by: re (rwatson)
Reviewed by: njl


# 123007 27-Nov-2003 njl

* If a processor's softc is NULL, use C1 since there is no ACPI
processor object for this CPU. This occurs for logical CPUs which
do not have an associated processor object (e.g., HTT).

Approved by: re (rwatson)


# 122995 26-Nov-2003 njl

* Add acpi_pcpu_get_id(idx, *acpi_id, *cpu_id) which fetches the
idx'th present CPU with pc_acpi_id equal to *acpi_id. If *acpi_id
does not match that processor's pc_acpi_id, return the value for
ProcId derived from the MADT in *acpi_id. If pc_acpi_id is 0xffffffff,
always override it with the value of *acpi_id. Finally, return
pc_cpuid in *cpu_id and use that as our primary key.

* Use pc_cpuid as our unique key because we know it is valid since
MD code set it. The values for ProcId in the ASL and MADT don't
match up on some machines (!), forcing us to fall back to ordered
probing in that case.

* Remove some #ifdef SMP since the refcount doesn't hurt performance
and will be needed for dynamic _CST objects. Only one #ifdef SMP
(for smp_rendezvous) remains.

* Hook up SMP in the compile flags in the Makefile.

Tested by: marcel, truckman
Approved by: re (scottl)


# 122904 19-Nov-2003 njl

* Add a DEVMETHOD for acpi so that child detach methods get called. Add
an acpi_cpu method for shutdown that disables entry to acpi_cpu_idle
and then IPIs/waits for threads to exit. This fixes a panic late in
reboot in the SMP case.

* In the !SMP case, don't use the processor id filled out by the MADT
since there can only be one processor. This was causing a panic in
acpi_cpu_idle if the id was 1 since the data was being dereferenced from
cpu_softc[1] even though the actual data was in cpu_softc[0] (which is
correct).

* Rework the initialization functions so that cpu_idle_hook is written
late in the boot process.

* Make the P_BLK, P_BLK_LEN, and cpu_cx_count all softc-local variables.
This will help SMP boxes that have _CST or multiple P_BLKs. No such
boxes are known at this time.

* Always allocate the C1 state, even if the P_BLK is invalid. This means
we will always take over idling if enabled. Remove the value -1 as
valid for cx_lowest since this is redundant with machdep.cpu_idle_hlt.

* Reduce locking for the throttle initialization case to around the write
to the smi_cmd port. Add disabled code to write the CST_CNT. It will
be enabled once _CST re-evaluation is tested (post 5.2R).

Thank you: dfr, imp, jhb, marcel, peter
Tested by: rwatson, Harald Schmalzbauer <h@schmalzbauer.de>
Approved by: re (rwatson)


# 122766 15-Nov-2003 njl

Implement Cx CPU idle states and updated throttling support.

* Use the cpu_idle_hook() to do idling for C1-C3.
* Use both _CST and the FADT to detect Cx states.
* Use both _PTC and P_CNT for controlling throttling.
* Add a notify handler to detect changes in _CST and _PSS
* Call the _INI function for each processor if present. This will be
done by ACPI-CA in the future.
* Fix a bug on SMP systems where CPUs will attach multiple times if the
bus is rescan.
* Document new sysctls for controlling idling.


# 119529 28-Aug-2003 njl

Style and whitespace changes. Also, make the ivar functions non-inline
since inlining failed due to the size of BUS_*


# 119418 24-Aug-2003 obrien

Use __FBSDID().
Also some minor style cleanups.


# 109760 23-Jan-2003 njl

More useful announce message containing current speed of CPU


# 109247 14-Jan-2003 njl

For the cpu throttling message, s/enabled/available

Requested by: many


# 105282 16-Oct-2002 jhb

Catch up to changes in acpivar.h to add support for using ACPI on
4-stable systems.

Sponsored by: The Weather Channel


# 96926 19-May-2002 peter

Brutally deal with __func__ being 'const char *' on gcc-3.1.


# 91640 04-Mar-2002 iwasaki

Add generalized power profile code.
This makes other power-management system (APM for now) to be able to
generate power profile change events (ie. AC-line status changes), and
other kernel components, not only the ACPI components, can be notified
the events.

- move subroutines in acpi_powerprofile.c (removed) to kern/subr_power.c
- call power_profile_set_state() also from APM driver when AC-line
status changes
- add call-back function for Crusoe LongRun controlling on power
profile changes for a example


# 91123 23-Feb-2002 msmith

Match namespace cleanup changes in ACPI CA 20020217 update.
Use ACPI_SUCCESS/ACPI_FAILURE consistently.


# 89054 08-Jan-2002 msmith

Staticise devclasses and some unnecessarily global variables.


# 88808 02-Jan-2002 msmith

If the CLK_VAL register is 0 bits wide, the system does not support
CPU throttling, so don't do some bogus math to check it.


# 86552 18-Nov-2001 iwasaki

Cleanups of verbose printing. All the messages for the debugging is
disabled unless verbose flag is set. Also fix some messages in terms
of English.
The critical messages and error messages in probe/attach routine are
unchanged by this commit.


# 85387 23-Oct-2001 jhb

Allow hw.acpi.cpu.{economy,performance}_speed to be set from the loader
via tunables.


# 82532 29-Aug-2001 msmith

Add missing acpi_disabled() call so that this driver can be disabled.


# 82372 26-Aug-2001 msmith

Updates to match the ACPI CA 20010816 import:

- New debug macro (ACPI_DEBUG_PRINT), reducing debug-case code size.
- New debug level/subsystem codes.


# 80078 21-Jul-2001 msmith

Convert from acpi_strerror() to AcpiFormatException()

Fix dangling include of the dear departed acpi_ecreg.h


# 80068 21-Jul-2001 msmith

Use our saved copy of the FADT rather than fetching it again.


# 79401 07-Jul-2001 iwasaki

Fix typo in acpi_cpu_attach() and correct range checking in
acpi_cpu_speed_sysctl().


# 79388 07-Jul-2001 msmith

Kill the old processor driver; the ACPI CA functions it depended on
are not coming back any time soon. Implement a new 'acpi_cpu' driver
with support for CPU throttling and power policies.