Home | History | Annotate | Download | only in acpi
History log of /src/sys/dev/acpi/acpi_cpu.c
RevisionDateAuthorComments
 1.53  07-Dec-2020  jmcneill acpicpu: Add support for ACPI P-states and T-states on Arm.
 1.52  16-Mar-2020  pgoyette branches: 1.52.4;
Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.
 1.51  01-Jun-2017  chs branches: 1.51.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.50  25-Feb-2014  pooka branches: 1.50.6;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.49  27-Mar-2012  jruoho branches: 1.49.2; 1.49.4;
Fix a regression introduced during the change of the DMI naming conventions
(rev. 1.48). Also add a quirk for ASUSTeK's M2A-MX in order to allow
powernow(4) to attach (reported by bouyer@).
 1.48  14-Nov-2011  jmcneill branches: 1.48.4;
add a machdep.dmi sysctl tree with the following read-only keys:
system-vendor, system-product, system-version, system-serial, system-uuid
bios-vendor, bios-version
board-vendor, board-product, board-version, board-serial
the *-serial and *-uuid keys are marked with CTLFLAG_PRIVATE

a few of the pmf platform key names changed so update callers to match
 1.47  27-Oct-2011  jruoho branches: 1.47.2;
Revert the revision 1.5 in cpufreq(9). Instead, document that the KPI can
not be used before interrupts have been enabled. Suggested by macallan@.
 1.46  20-Oct-2011  jruoho Initialize P-states to P0 (i.e. the highest frequency).
 1.45  18-Oct-2011  jruoho Convert to use cpufreq(9).
 1.44  22-Jun-2011  jruoho Get rid of RUN_ONCE(9). Should fix PR # kern/44043.
 1.43  21-Jun-2011  jruoho Rename acpi_get_node() to acpi_match_node() for consistency.
 1.42  20-Jun-2011  jruoho Use the new acpi_match_cpu_info() from acpi_util.c.
 1.41  12-Jun-2011  jruoho Move the evaluation of the _PDC control method out from the acpicpu(4)
driver to the main acpi(4) stack. Follow Linux and evaluate it early.
Should fix PR port-amd64/42895, possibly also PR kern/42583, and many
other comparable bugs.

A common sense explanation is that Intel supplies additional CPU tables to
OEMs. BIOS writers do not bother to modify their DSDTs, but instead load
these extra tables dynamically as secondary SSDT tables. The actual Load()
happens when the _PDC method is invoked, and thus namespace errors occur
when the CPU-specific ACPI methods are not yet present but referenced in the
AML by various drivers, including, but not limited to, acpitz(4).
 1.40  25-Apr-2011  jruoho branches: 1.40.2;
Add a missing case value in a switch statement.
 1.39  24-Mar-2011  jruoho Remove the "simple CPU lock" that was unnecessary.
Thanks to rmind@ for clarifications.
 1.38  19-Mar-2011  jruoho Like in rest of the acpi(4) stack, queue all resume hooks.
 1.37  05-Mar-2011  jruoho branches: 1.37.2;
Add __cpu_simple_lock_t. Use it, x86_read_psl(), and x86_disable_intr() to
disable interrupts locally and protect the access to APERF and MPERF. Also
rationalize the MD initialization sequence.
 1.36  03-Mar-2011  jruoho Add DMI quirk support via pmf_get_platform(9). If any of the listed models
are matched, the whole driver will be prevented from attaching. The first
entry is Supermicro PDSMi-LN4+ (a BIOS bug with bogus P-state entries).
 1.35  02-Mar-2011  jruoho Append Intel's Turbo Boost to the debug printfs if we detect it.
 1.34  01-Mar-2011  jruoho Detach evcnt(9) before the states.
 1.33  01-Mar-2011  jruoho Move also the evcnt(9) event counters to one place. No functional change.
 1.32  01-Mar-2011  jruoho Simplify by moving the debug printfs to one place. No functional change.
 1.31  27-Feb-2011  jruoho Provide MD wrappers for match and attach.
 1.30  27-Feb-2011  jruoho Move acpicpu(4) from "acpinodebus" to "cpufeaturebus".
 1.29  25-Feb-2011  jruoho Start to derive the percpu(9) (or per-domain) state coordination
mechanisms by parsing the _CSD, _PSD, and _TSD objects by default.
 1.28  25-Feb-2011  jruoho Rename couple of badly named functions for consistency. No functional change.
 1.27  25-Feb-2011  jruoho Store a pointer to cpu_info rather than cpu_info::ci_acpiid alone.
 1.26  16-Feb-2011  jruoho Use ioconf for the module declarations.
 1.25  13-Jan-2011  jruoho branches: 1.25.2; 1.25.4;
Do not try to attach more ACPI CPUs than the amount of "real" CPUs.
 1.24  30-Dec-2010  jruoho Change the default behavior to enforce the maximum frequency when the
firmware requests to do so. This cures severe overhating (> 120 C) observed
on many laptops, being also on par with the specification(s). This can be
reverted by using the new "hw.acpi.cpu.dynamic" sysctl variable.
 1.23  28-Oct-2010  jruoho Fix a comment typo.
 1.22  27-Aug-2010  jruoho Fix PR kern/43765 from Scott Ellis.

Note that the solution is not optimal. If ichlpcib(4) provides SpeedStep
support, possible I/O resource conflicts may occur with acpicpu(4). Ideally,
as noted for instance in Windows design documents, ichlpcib(4) should never
expose SpeedStep when ACPI is being used. The probability for potential race
conditions is however very small, being limited to few P4-era machines and
being dependent on user actions.
 1.21  27-Aug-2010  jruoho From jmcneill@: fix and rework the obscure _OSC evaluation.
 1.20  19-Aug-2010  jruoho Deal with autoconfiguration madness by using config_defer(9) to defer
config_interrupts(9) to be executed. This is necessary because: (a) the
initialization routines must be run only once after interrupts are enabled
and (b) all ACPI CPUs have attached.
 1.19  17-Aug-2010  jruoho Add support for the optional dynamic minimum (in terms of MHz) via _PDL.
Comparable to T-states, this gives effectively a window of available
performance states for passive cooling. An example:

Init: max = 0, min = Pn.

Time j. Time j + 1.
----------- -----------
2000 MHz P0 max P0
P1 P1 max
P2 ==> P2
P3 P3 min
P4 P4
P5 min P5
500 Mhz Pn Pn
----------- -----------

Search: repeat (i = P0; i <= P5) repeat (i = P1; i <= P3)
 1.18  16-Aug-2010  jruoho branches: 1.18.2;
Two changes:

1. Initialize P-states properly to P0. It is processor-specific
what value we might get without initialization. (Some AMD CPUs
have even specific registers for the state after cold reset.)

2. Following design notes for Windows, set the lowest-power P-state
upon suspend and restore the saved state after resume.
 1.17  16-Aug-2010  jruoho Now that the deferred configuration actually works as expected and documented,
use config_defer(9) instead of config_finalize_register(9), and simplify the
code paths around the initialization.
 1.16  14-Aug-2010  jruoho Check the cold-flag also in the notify handler.
 1.15  13-Aug-2010  jruoho Merge T-state a.k.a. throttling support for acpicpu(4).

Remarks:

1. Native instructions are supported only on Intel. Native support for
other x86 vendors will be investigated. By assumption, AMD and others
use the I/O based approach.

2. The existing code, INTEL_ONDEMAND_CLOCKMOD, must be disabled in
order to use acpicpu(4). Otherwise fatal MSR races may occur.
Unlike with P-states, no attempt is done to disable the existing
implementation.

3. There is no rationale to export controls to user land.

4. Throttling is an artefact from the past. T-states will not be used for
power management per se. For CPU frequency management, P-states are
preferred in all circumstances. No noticeable additional power savings
were observed in various experiments. When the system has been scaled
to the highest (i.e. lowest power) P-state, it is preferable to move
from C0 to deeper C-states than it is to actively throttle the CPU.

5. But T-states need to be implemented for passive cooling via acpitz(4).
As specified by ACPI and Intel documents, these can be used as the
last line of defence against critical thermal conditions. Support
for this will be added later.
 1.14  11-Aug-2010  jruoho branches: 1.14.2;
Check the 'sc->sc_cold' flag also in P-state code, and set this flag once
we start the detachment routine.
 1.13  08-Aug-2010  jruoho jmcneill@: do not touch the bus_space(9) handle.
 1.12  08-Aug-2010  jruoho Merge P-state support for acpicpu(4).

Remarks:

1. All processors (x86 or not) for which the vendor has implemented
ACPI I/O access routines are supported. Native instructions are
currently supported only for Intel's "Enhanced Speedstep". Code for
"PowerNow!" (AMD) will be merged later. Native support for VIA's
"PowerSaver" will be investigated.

2. Backwards compatibility with existing userland code is maintained.
Comparable to the case with cpu_idle(9), the ACPI CPU driver
installs alternative functions for the existing sysctl(8) controls.
The "native" behavior (if any) is restored upon detachment.

3. The dynamic nature of ACPI-provided P-states needs more investigation.
The maximum frequency induced (but not forced) by the firmware may
change dynamically. Currently, the sysctl(8) controls error out with
a value larger than the dynamic maximum. The code itself does not
however yet react to the notifications from the firmware by changing
the frequencies in-place. Presumably the system administrator should
be able to choose whether to use dynamic or static frequencies.
 1.11  04-Aug-2010  jruoho Store the MADT-derived CPU ID to <x86/cpu.h>. This is required to properly
match the ACPI processor object ID with the ID available in the APIC table.
 1.10  30-Jul-2010  jruoho On second thought, rename the mutex so it can be (logically) shared. We will
not need such granularity that different states would require a different lock.
 1.9  29-Jul-2010  jruoho Add a per ACPI CPU mutex for C-states. Protect the _CST update with this:
when the idle-information is being updated (e.g. due acpiacad(4) events),
we can not enter the idle-loop. The lock must run at the same priority
(IPL_NONE) as ACPICA's mutexes obtained via AcpiOsCreateMutex() a.k.a.
AcpiOsCreateSemaphore(). Also check want_resched as the first thing and
clarify the suspend/resume path.

There is still one race condition identified: when the driver is loaded as a
module, we must gracefully kick all CPUs out from the ACPI idle-loop upon
detachment.
 1.8  26-Jul-2010  jruoho Fix wrong return value.
 1.7  25-Jul-2010  jruoho Improve comments. Move the #ifdef around.
 1.6  24-Jul-2010  jruoho Remove the currently unnecessary mutex.
 1.5  23-Jul-2010  jruoho Remove the recently added ACPICPU_FLAG_INIT and instead operate with the
existing ACPICPU_FLAG_C, as was intended. Set that flag only after the
idle-loop has been installed, so that the notify handler errors out if an
interrupt is received before the idle-loop is in place.
 1.4  21-Jul-2010  cegger ACPI enumerates cpus with 0..n.
Fixes panic reported by Patrick Welche on current-users@
Fixes panic on my own HP Pavilion laptop
 1.3  19-Jul-2010  christos XXX: If this is not correct, revert or fix.
This makes my laptop boot instead of panic:

panic: kernel diagnostic assertion "native_idle != NULL" failed: file "../../../../arch/x86/acpi/acpi_cpu_md.c", line 155
fatal breakpoint trap in supervisor mode
type 1 code 0 rip ffffffff8022e4ad cs 8 rflags 246 cr2 0 cpl 0 rsp ffff80004c37db10

trace
breakpoint() at netbsd:breakpoint+0x5
panic() at netbsd:panic+0x2ba
kern_assert() at netbsd:kern_assert+0x2d
acpicpu_md_idle_stop() at netbsd:acpicpu_md_idle_stop+0x62
acpicpu_cstate_callback() at netbsd:acpicpu_cstate_callback+0x34
sysmon_task_queue_thread() at netbsd:sysmon_task_queue_thread+0x41

1. ACPI seems to define cpuids 1..n; we define 0..n-1. Adjust for that
2. My laptop is dual core, but ACPI reports 4 cpu nodes. Instead of
attaching the unmatched ones, make the match fail. Do we want to
attach and do nothing instead?
3. Create a flag, and only set it after we are completely initialized,
so the sysmon thread does not try to access unitialized state.
 1.2  18-Jul-2010  jruoho Add missing CVS identifiers.
 1.1  18-Jul-2010  jruoho Merge a driver for ACPI CPUs with basic support for processor power states,
also known as C-states. The code is modular and provides an easy way to add
the remaining functionality later (namely throttling and P-states).

Remarks:

1. Commented out in the GENERICs; more testing exposure is needed.

2. The C3-state is disabled for the time being because it turns off
timers, among them the local APIC timer. This may not be universally
true on all x86 processors; define ACPICPU_ENABLE_C3 to test.

3. The algorithm used to choose a power state may need tuning. When
evaluating the appropriate state, the implementation uses the
previous sleep time as an indicator. Additional hints would include
for example the system load.

Also bus master activity is evaluated when choosing a state. The
usb(4) stack is notorious for such activity even when unused.
Typically it must be disabled in order to reach the C3-state,
but it may also prevent the use of C2.

4. While no extensive empirical measurements have been carried out, the
power savings are somewhere between 1-2 W with C1 and C2, depending
on the processor, firmware, and load. With C3 even up to 4 W can be
saved. The less something ticks, the more power is saved.

ok jmcneill@, joerg@, and discussed with various people.
 1.14.2.3  09-Oct-2010  yamt sync with head
 1.14.2.2  11-Aug-2010  yamt sync with head.
 1.14.2.1  11-Aug-2010  yamt file acpi_cpu.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:15 +0000
 1.18.2.4  06-Nov-2010  uebayasi Sync with HEAD.
 1.18.2.3  22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.18.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.18.2.1  16-Aug-2010  uebayasi file acpi_cpu.c was added on branch uebayasi-xip on 2010-08-17 06:45:59 +0000
 1.25.4.2  05-Mar-2011  bouyer Sync with HEAD
 1.25.4.1  17-Feb-2011  bouyer Sync with HEAD
 1.25.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.37.2.5  31-May-2011  rmind sync with head
 1.37.2.4  21-Apr-2011  rmind sync with head
 1.37.2.3  06-Mar-2011  rmind sync with head (and fix few botches with this)
 1.37.2.2  05-Mar-2011  rmind sync with head
 1.37.2.1  05-Mar-2011  rmind file acpi_cpu.c was added on branch rmind-uvmplock on 2011-03-05 20:53:02 +0000
 1.40.2.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.47.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.47.2.1  17-Apr-2012  yamt sync with head
 1.48.4.1  05-Apr-2012  mrg sync to latest -current.
 1.49.4.1  18-May-2014  rmind sync with head
 1.49.2.2  03-Dec-2017  jdolecek update from HEAD
 1.49.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.50.6.1  28-Aug-2017  skrll Sync with HEAD
 1.51.10.1  08-Apr-2020  martin Merge changes from current as of 20200406
 1.52.4.1  14-Dec-2020  thorpej Sync w/ HEAD.

RSS XML Feed