History log of /freebsd-current/sys/dev/acpica/acpi_timer.c
Revision Date Author Comments
# bad36a49 04-Feb-2024 Mark Johnston <markj@FreeBSD.org>

acpi: Use device_set_descf()

No functional change intended.

MFC after: 1 week


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# c45bc025 26-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Adjust function definition in acpi_timer.c to avoid clang 15 warnings

With clang 15, the following -Werror warning is produced:

sys/dev/acpica/acpi_timer.c:402:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
acpi_timer_test()
^
void

This is because acpi_timer_test() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days


# 916a5d8a 19-Apr-2022 John Baldwin <jhb@FreeBSD.org>

acpi: Remove unused devclass arguments to DRIVER_MODULE.


# 3e68d2c5 26-Dec-2021 Alexander Motin <mav@FreeBSD.org>

acpica: Remove CTLFLAG_NEEDGIANT from most sysctls.

MFC after: 2 weeks


# a8b89dff 07-Sep-2021 Colin Percival <cperciva@FreeBSD.org>

Disable acpi_timer_test by default

This disables testing the ACPI timer by default, forcing the use of
ACPI-fast rather than ACPI-safe. The broken-ACPI-timers workaround
can be re-enabled by setting the hw.acpi.timer_test_enabled=1 tunable.

This speeds up the FreeBSD boot process by 140 ms on an EC2 c5.xlarge
instance.

This change will not be MFCed.

Assuming no problems are reported, acpi_timer_test, the associated
tunable, and the ACPI-safe timecounter should be removed in FreeBSD 15.

Relnotes: The ACPI-safe timer is disabled in favour of ACPI-fast;
if timekeeping issues are observed, please test with
hw.acpi.timer_test_enabled=1 in loader.conf and report
if that fixes the problem.


# 3c253d03 07-Sep-2021 Colin Percival <cperciva@FreeBSD.org>

Hide acpi_timer_test behind a tunable

When hw.acpi.timer_test_enabled is set to 0, this makes acpi_timer_test
return 1 without actually testing the ACPI timer; this results in the
ACPI-fast timecounter always being used rather than potentially using
ACPI-safe.

The ACPI timer testing was introduced in 2002 as a workaround for
errata in Pentium II and Pentium III chipsets, and is unlikely to be
needed in 2021.

While I'm here, add TSENTER/TSEXIT to make it easier to see the time
spent on the test (if it is enabled).

Reviewed by: allanjude, imp
MFC After: 1 week


# 82c28121 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

acpica: clean up empty lines in .c and .h files


# 4149c6a3 10-Jun-2020 Konstantin Belousov <kib@FreeBSD.org>

Remove double-calls to tc_get_timecount() to warm timecounters.

It seems that second call does not add any useful state change for all
implemented timecounters.

Discussed with: bde
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks


# 7029da5c 26-Feb-2020 Pawel Biernacki <kaktus@FreeBSD.org>

Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)

r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE. All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by: kib (mentor, blanket)
Commented by: kib, gallatin, melifaro
Differential Revision: https://reviews.freebsd.org/D23718


# da1b038a 17-Mar-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.

On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit. This extends rman's resources to uintmax_t. With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).

Why uintmax_t and not something machine dependent, or uint64_t? Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures. 64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead. That being said, uintmax_t was chosen for source
clarity. If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros. Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.

Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)

Tested PAE and devinfo on virtualbox (live CD)

Special thanks to bz for his testing on ARM.

Reviewed By: bz, jhb (previous)
Relnotes: Yes
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544


# 2dd1bdf1 26-Jan-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Convert rman to use rman_res_t instead of u_long

Summary:
Migrate to using the semi-opaque type rman_res_t to specify rman resources. For
now, this is still compatible with u_long.

This is step one in migrating rman to use uintmax_t for resources instead of
u_long.

Going forward, this could feasibly be used to specify architecture-specific
definitions of resource ranges, rather than baking a specific integer type into
the API.

This change has been broken out to facilitate MFC'ing drivers back to 10 without
breaking ABI.

Reviewed By: jhb
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5075


# ef745449 06-May-2015 Andrew Turner <andrew@FreeBSD.org>

If the power management timer is unsupported the PmTimerLength value will
be zero.


# c2641d23 04-Aug-2014 Roger Pau Monné <royger@FreeBSD.org>

xen: add ACPI bus to xen_nexus when running as Dom0

Also disable a couple of ACPI devices that are not usable under Dom0.
To this end a couple of booleans are added that allow disabling ACPI
specific devices.

Sponsored by: Citrix Systems R&D
Reviewed by: jhb

x86/xen/xen_nexus.c:
- Return BUS_PROBE_SPECIFIC in the Xen Nexus attachement routine to
force the usage of the Xen Nexus.
- Attach the ACPI bus when running as Dom0.

dev/acpica/acpi_cpu.c:
dev/acpica/acpi_hpet.c:
dev/acpica/acpi_timer.c
- Add a variable that gates the addition of the devices.

x86/include/init.h:
- Declare variables that control the attachment of ACPI cpu, hpet and
timer devices.


# 428b7ca2 19-Sep-2013 Justin T. Gibbs <gibbs@FreeBSD.org>

Add support for suspend/resume/migration operations when running as a
Xen PVHVM guest.

Submitted by: Roger Pau Monné
Sponsored by: Citrix Systems R&D
Reviewed by: gibbs
Approved by: re (blanket Xen)
MFC after: 2 weeks

sys/amd64/amd64/mp_machdep.c:
sys/i386/i386/mp_machdep.c:
- Make sure that are no MMU related IPIs pending on migration.
- Reset pending IPI_BITMAP on resume.
- Init vcpu_info on resume.

sys/amd64/include/intr_machdep.h:
sys/i386/include/intr_machdep.h:
sys/x86/acpica/acpi_wakeup.c:
sys/x86/x86/intr_machdep.c:
sys/x86/isa/atpic.c:
sys/x86/x86/io_apic.c:
sys/x86/x86/local_apic.c:
- Add a "suspend_cancelled" parameter to pic_resume(). For the
Xen PIC, restoration of interrupt services differs between
the aborted suspend and normal resume cases, so we must provide
this information.

sys/dev/acpica/acpi_timer.c:
sys/dev/xen/timer/timer.c:
sys/timetc.h:
- Don't swap out "suspend safe" timers across a suspend/resume
cycle. This includes the Xen PV and ACPI timers.

sys/dev/xen/control/control.c:
- Perform proper suspend/resume process for PVHVM:
- Suspend all APs before going into suspension, this allows us
to reset the vcpu_info on resume for each AP.
- Reset shared info page and callback on resume.

sys/dev/xen/timer/timer.c:
- Implement suspend/resume support for the PV timer. Since FreeBSD
doesn't perform a per-cpu resume of the timer, we need to call
smp_rendezvous in order to correctly resume the timer on each CPU.

sys/dev/xen/xenpci/xenpci.c:
- Don't reset the PCI interrupt on each suspend/resume.

sys/kern/subr_smp.c:
- When suspending a PVHVM domain make sure there are no MMU IPIs
in-flight, or we will get a lockup on resume due to the fact that
pending event channels are not carried over on migration.
- Implement a generic version of restart_cpus that can be used by
suspended and stopped cpus.

sys/x86/xen/hvm.c:
- Implement resume support for the hypercall page and shared info.
- Clear vcpu_info so it can be reset by APs when resuming from
suspension.

sys/dev/xen/xenpci/xenpci.c:
sys/x86/xen/hvm.c:
sys/x86/xen/xen_intr.c:
- Support UP kernel configurations.

sys/x86/xen/xen_intr.c:
- Properly rebind per-cpus VIRQs and IPIs on resume.


# 61bfd867 30-Jan-2013 Sofian Brabez <sbz@FreeBSD.org>

Use DEVMETHOD_END macro defined in sys/bus.h instead of {0, 0} sentinel on device_method_t arrays

Reviewed by: cognet
Approved by: cognet


# 6303ae4d 09-Feb-2012 Jung-uk Kim <jkim@FreeBSD.org>

Refine r231226. Swap timecounters before suspending any device drivers.


# cc43a851 08-Feb-2012 Jung-uk Kim <jkim@FreeBSD.org>

Revert r211288 and move the logic to the acpi_timer itself.


# 404b0d10 07-Feb-2012 Jung-uk Kim <jkim@FreeBSD.org>

- Give all clocks and timers on acpi0 the equal probing order.
- Increase probing order for ECDT table to match HID-based probing.
- Decrease probing order for HPET table to match HID-based probing.
- Decrease probing order for CPUs and system resources.
- Fix ACPI_DEV_BASE_ORDER to reflect the reality.


# ca5f1efd 23-May-2011 Jung-uk Kim <jkim@FreeBSD.org>

Decrease ACPI-fast timecounter quality to 900 and increase HPET timecounter
quality to 950. HPET on modern platforms usually have better resolution and
lower latency than ACPI timer. Effectively this changes default timecounter
hardware from ACPI-fast to HPET by default when both are available.

Discussed with: avg


# 6af444b1 18-Apr-2011 Jung-uk Kim <jkim@FreeBSD.org>

Do not assume PM timer GAS type is I/O or memory. It may be an unsupported
type, i. e., a broken table. Also, do not hardcode ACPI timer frequency in
device description.


# 5331d61d 13-Apr-2011 Jung-uk Kim <jkim@FreeBSD.org>

Add some tunable descriptions about x86 timers.

Requested by: arundel


# 9abd8cd0 05-Apr-2011 Jung-uk Kim <jkim@FreeBSD.org>

Lower the bar for ACPI-fast on real machines slightly. Empirical evidences
show that there are perfectly working PM timers with occasional "hiccups",
probably because of an SMI. Now we ignore the maximum if it happens once in
the test loop and the width is small enough. Also, relax normal width a bit
to count in a boundary case.


# aa977fc7 04-Apr-2011 Jung-uk Kim <jkim@FreeBSD.org>

Always check the current minimum value to make the test more predictable.
Use INT32_MAX instead of an arbitrary big number for the initial minimum.


# d141bf6e 04-Apr-2011 Jung-uk Kim <jkim@FreeBSD.org>

Lower the bar for ACPI-fast on virtual machines. The current logic depends
on the fact that real hardware has almost fixed cost to read the ACPI timer.
It is virtually always false for hardware emulation and it makes no sense to
read it multiple times, which is already quite expensive for full emulation.


# 93bd1f7e 04-Apr-2011 Jung-uk Kim <jkim@FreeBSD.org>

Add inline to acpi_timer_read() to reduce unnecessary jumps and calls.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 129d3046 05-Jun-2009 Jung-uk Kim <jkim@FreeBSD.org>

Import ACPICA 20090521.


# aaac7452 02-Jun-2009 Jung-uk Kim <jkim@FreeBSD.org>

Chase ACPICA API changes (for kernel and boot loader).


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 430eaa74 30-Jul-2007 Nate Lawson <njl@FreeBSD.org>

Dynamically choose the quality of the ACPI timer depending on whether
the fast or safe/slow method is in use. Fast remains at 1000, slow is
now at 850 (always preferred to TSC). Since the HPET has proven slower
than ACPI-fast on some systems, drop its quality to 900. In the future,
it is hoped that HPET performance will improve as it is the main
timer Intel supports. HPET may move back to 2000 in -current once RELENG_7
is branched to ensure that it gets tested.

Approved by: re


# 041b706b 04-Jun-2007 David Malone <dwmalone@FreeBSD.org>

Despite several examples in the kernel, the third argument of
sysctl_handle_int is not sizeof the int type you want to export.
The type must always be an int or an unsigned int.

Remove the instances where a sizeof(variable) is passed to stop
people accidently cut and pasting these examples.

In a few places this was sysctl_handle_int was being used on 64 bit
types, which would truncate the value to be exported. In these
cases use sysctl_handle_quad to export them and change the format
to Q so that sysctl(1) can still print them.


# 2be4e471 22-Mar-2007 Jung-uk Kim <jkim@FreeBSD.org>

Catch up with ACPI-CA 20070320 import.


# 2a191126 11-Sep-2005 David E. O'Brien <obrien@FreeBSD.org>

Canonize the include of acpi.h.


# dad97fee 02-Mar-2005 David E. O'Brien <obrien@FreeBSD.org>

Fix SCM ID's.


# 2a921b05 03-Nov-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Make the bootverbose output from qualitydetermination of the ACPI timer
take up only one line.


# 4f8c4e4d 08-Oct-2004 Nate Lawson <njl@FreeBSD.org>

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


# 14827d7e 21-Jul-2004 Nate Lawson <njl@FreeBSD.org>

Reinsert the bus space handle and tag, they are needed for the timer test.


# be1841b4 21-Jul-2004 Nate Lawson <njl@FreeBSD.org>

Instead of doing everything in identify, do a proper probe/attach. Also,
don't add another device if identify is called twice. Minor reworking by
myself.

Submitted by: marcel


# fe12f24b 30-May-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Add missing <sys/module.h> includes


# c0b9a6de 24-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Disable interrupts while testing the timer. Not doing this unnecessarily
added an arbitrary delay to our readings, causing us to use the ACPI-safe
read method when not necessary. Submitted by: bde

Old:
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks BAD min = 3, max = 19, width = 16
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks BAD min = 3, max = 19, width = 16
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 4, width = 1
Timecounter "ACPI-safe" frequency 3579545 Hz quality 1000

New:
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000

Also, reduce unnecesary overhead in ACPI-fast by remove the barrier for
reads. The timer in the ACPI-fast case is known to increase monotonically
so there is no need to serialize access to it.


# d9b6df60 21-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Fix stepping in ddb by not checking for a maximum interval. The ACPI-safe
workaround was for hardware where the clock was not latched, not for
hardware that was too slow. Also, make variable names more specific for ddb
printing.


# af807c0f 21-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Add comments, including restoring the PIIX4 errata comment, to indicate
what the ACPI-safe workaround is intended to fix. Requested by phk.

Set the bushandle and tag when attaching the timer, don't do it each time
in read_counter(). Pointed out by bde.

Move test_counter() to the end. Staticize acpi_timer_reg.


# 75988358 20-Apr-2004 Nate Lawson <njl@FreeBSD.org>

Fix several bugs where 32-bit timers and wraparound were not properly
supported. Symptoms of this bug included unnecessary use of ACPI-safe
and a dmesg that has deltas of about 2^24:

ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 2, max = 16777210, width = 16777208
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185

To fix this:
* Use a 32 bit timecounter mask when the timer is 32 bits.
* In test_counter(), use the acpi_TimerDelta function which handles 24/32
bit timers and wraparound.

Miscellaneous fixes:
* Use C99 initializers for timecounter struct.
* Use u_int and uint32_t where appropriate instead of unsigned.
* Remove whitespace-only lines
* Remove the old PIIX4 PCI workaround. The timecounter testing code has
been in use for long enough to prove it's functional.


# 64278df5 09-Apr-2004 Nate Lawson <njl@FreeBSD.org>

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


# 5f96beb9 17-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Convert callers to the new bus_alloc_resource_any(9) API.

Submitted by: Mark Santcroos <marks@ripe.net>
Reviewed by: imp, dfr, bde


# 3184cf5a 02-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Add support for quirks for acpi tables. Key off OEM vendor and revision.
Sort acpi debug values. Change "disable" to "disabled" to match rest of
the kernel. Remove debugging from acpi_toshiba since it was only used for
probe/attach.


# be2b1797 28-Aug-2003 Nate Lawson <njl@FreeBSD.org>

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


# cace7a2a 22-Aug-2003 Warner Losh <imp@FreeBSD.org>

Prefer new location of pci include files (which have only been in the
tree for two or more years now), except in a few places where there's
code to be compatible with older versions of FreeBSD.


# 78a49a45 16-Aug-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Give timecounters a numeric quality field.

A timecounter will be selected when registered if its quality is
not negative and no less than the current timecounters.

Add a sysctl to report all available timecounters and their qualities.

Give the dummy timecounter a solid negative quality of minus a million.

Give the i8254 zero and the ACPI 1000.

The TSC gets 800, unless APM or SMP forces it negative.

Other timecounters default to zero quality and thereby retain current
selection behaviour.


# 214475d8 29-Apr-2003 Marcel Moolenaar <marcel@FreeBSD.org>

o Don't announce that the timer is good when in fact it isn't timing
at all (ie reads yield constant values). Display the width as the
difference between max and min so that constant timers have width
zero.
o Get the address of the timer from the XPmTmrBlk field instead of
the V1_PmTmrBlk field. The former is a generic address and can
specify a memory mapped I/O address. Remove <machine/bus_pio.h>
to account for this. The timer is now properly configured on
machines with ACPI v2 tables, whether PIO or MEMIO. Note that
the acpica code converts v1 tables into v2 tables so the address
is always present in XPmTmrBlk.
o Replace the TIMER_READ macro with a call to the read_counter()
function and add a barrier to make sure that we observe proper
ordering of the reads.


# 3a65df00 16-Oct-2002 John Baldwin <jhb@FreeBSD.org>

struct timecounter is defined in sys/time.h on 4-stable.

Sponsored by: The Weather Channel


# 87e5d361 09-Oct-2002 John Baldwin <jhb@FreeBSD.org>

Include <dev/acpica/acpivar.h> instead of <acpica/acpivar.h> like all the
other sys/dev/acpica files.


# b4a05238 19-May-2002 Peter Wemm <peter@FreeBSD.org>

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


# 2266fe77 30-Apr-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Don't export timecounter structures under debug. with sysctl, they
contain no truly interesting data anymore.


# 7e2d76ff 26-Apr-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Remove the tc_update() function. Any frequency change to the
timecounter will be used starting at the next second, which is
good enough for sysctl purposes. If better adjustment is needed
the NTP PLL should be used.


# d786139c 17-Apr-2002 Maxime Henrion <mux@FreeBSD.org>

Rework the kernel environment subsystem. We now convert the static
environment needed at boot time to a dynamic subsystem when VM is
up. The dynamic kernel environment is protected by an sx lock.

This adds some new functions to manipulate the kernel environment :
freeenv(), setenv(), unsetenv() and testenv(). freeenv() has to be
called after every getenv() when you have finished using the string.
testenv() only tests if an environment variable is present, and
doesn't require a freeenv() call. setenv() and unsetenv() are self
explanatory.

The kenv(2) syscall exports these new functionalities to userland,
mainly for kenv(1).

Reviewed by: peter


# 116caf7c 24-Mar-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Hide the ACPI counter probing printf behind bootverbose.

The conclusion is that this method really can tell the perfect from the
less than perfect ACPI counters.

It is in fact probably a bit more discriminative than that, but we
will rather condemn some otherwise perfect counters to the slightly
slower "-safe" version, than certify a counter as perfect which
will let us down later.

Many thanks to all the people who sent email reports!


# cb877d00 25-Feb-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Add a new test_counter() function which tries to determine the width of
the inter-value histogram for 2000 samples. If the width is 3 or less
for 10 consequtive samples, we trust the counter to be good, otherwise
we use the *_safe() method.

This method may be too strict, but the worst which can happen is that
we take the performance hit of the *_safe() method when we should not.

Make the *_safe() method more discriminating by mandating that the three
samples do not span more than 15 ticks on the counter.

Disable the PCI-ident based probing as a means to recognize good
counters.

Inspiration from: dillon and msmith


# d32e27a9 24-Feb-2002 Matthew Dillon <dillon@FreeBSD.org>

Tests by numerous people have shown that many chipsets do not properly
latch the acpi timer, resulting in weird deltas. The problem is severe
enough to adversely effect the timecounter code.

Default to the 'safe' version of the get-timecount function. The probe
will override it if a known-good chipset is found. This is temporary
until a more complete solution is found.

Reviewed by: phk


# 72e5754c 22-Feb-2002 Mike Smith <msmith@FreeBSD.org>

Match namespace cleanup changes in ACPI CA 20020217 update.


# 3273b005 07-Jan-2002 Mike Smith <msmith@FreeBSD.org>

Staticise devclasses and some unnecessarily global variables.


# b2c98acc 05-Aug-2001 Mike Smith <msmith@FreeBSD.org>

The Intel 440MX ACPI timer seems to work properly, so add it to the list
here. Restructure slightly so that adding more devices is easier.

Submitted by: Jose Gabriel J Marcelino <gabriel@maquina.com>


# feade919 03-Aug-2001 Mike Smith <msmith@FreeBSD.org>

Reverse the logic here again with regards to "trusted" ACPI timer
implementations. More of them seem to be broken, so only "trust"
timers we know work.


# d8a9fe36 30-Jul-2001 Mike Smith <msmith@FreeBSD.org>

Minor updates (no functional changes)

- Remove the beer-ware license (reqested by phk)
- Reorganise so that the PIIX4 workaround code is kept together, and
switch the workaround function via the timecounter struct, saving
a compare in the read-timecounter codepath. Also indicate that
the workaround is active by changing the timecounter hardware string.


# 7b60d04d 27-Jul-2001 Mike Smith <msmith@FreeBSD.org>

The ACPI timer register corruption problem is resolved in the PIIX4
starting with the PIIX4M. Restrict enabling the workaround to those
chips known to be buggy.


# 787fa5b8 20-Jul-2001 Mike Smith <msmith@FreeBSD.org>

Implement a "proper" timecounter hung off the ACPI timer device.

This code is based on the mp_clock code by phk. It attempts to
detect the PIIX4 (see comments for details) and use a workaround
for its problems.

This code is experimental, and could use some testing and review by a
timekeeping enthusiast.


# 2a4ac806 29-May-2001 Mike Smith <msmith@FreeBSD.org>

- Updates for new constant naming in the ACPI CA 20010518 update.
- Use __func__ instead of __FUNCTION.
- Support power-off to S3 or S5 (takawata)
- Enable ACPI debugging earlier (with a sysinit)
- Fix a deadlock in the EC code (takawata)
- Improve arithmetic and reduce the risk of spurious wakeup in
AcpiOsSleep.
- Add AcpiOsGetThreadId.
- Simplify mutex code (still disabled).


# 91467fc6 31-Jan-2001 Mike Smith <msmith@FreeBSD.org>

ACPI_NUMBER becomes ACPI_INTEGER. acpi_EvaluateNumber becomes
acpi_EvaluateInteger.

Use acpi_EvaluateInteger instead of doing things the hard way where
possible.

AcpiSetSystemSleepState (unofficial) becomes AcpiEnterSleepState.

Use the AcpiGbl_FADT pointer rather than searching for the FADT.


# 0ae55423 08-Dec-2000 Mike Smith <msmith@FreeBSD.org>

- Convert a lot of homebrew debugging output to use the ACPI CA debugging
infrastructure. It's not perfect, but it's a lot better than what
we've been using so far. The following rules apply to this:
o BSD component names should be capitalised
o Layer names should be taken from the non-CA set for now. We
may elect to add some new BSD-specific layers later.

- Make it possible to turn off selective debugging flags or layers
by listing them in debug.acpi.layer or debug.acpi.level prefixed
with !.

- Fully implement support for avoiding nodes in the ACPI namespace.
Nodes may be listed in the debug.acpi.avoid environment variable;
these nodes and all their children will be ignored (although still
scanned over) by ACPI functions which scan the namespace. Multiple
nodes can be specified, separated by whitespace.

- Implement support for selectively disabling ACPI subsystem components
via the debug.acpi.disable environment variable. The following
components can be disabled:
o bus creation/scanning of the ACPI 'bus'
o children attachment of children to the ACPI 'bus'
o button the acpi_button control-method button driver
o ec the acpi_ec embedded-controller driver
o isa acpi replacement of PnP BIOS for ISA device discovery
o lid the control-method lid switch driver
o pci pci root-bus discovery
o processor CPU power/speed management
o thermal system temperature detection and control
o timer ACPI timecounter
Multiple components may be disabled by specifying their name(s)
separated by whitespace.

- Add support for ioctl registration. ACPI subsystem components may
register ioctl handlers with the /dev/acpi generic ioctl handler,
allowing us to avoid the need for a multitude of /dev/acpi* control
devices, etc.


# 042283a6 01-Dec-2000 Mike Smith <msmith@FreeBSD.org>

Update to work with the new ACPI CA snapshot.

- Use ACPI_PHYSICAL_ADDRESS
- RSDT -> XSDT
- FACP -> FADT
- No APIC table support
- Don't install a global EC handler; this has bad side-effects
(it invokes _REG in *all* EC spaces in the namespace!)
- Check for PCI bus instances already existing before adding them


# 15e32d5d 28-Oct-2000 Mike Smith <msmith@FreeBSD.org>

Initial FreeBSD OSPM (operating system power management) modules for
ACPICA. Most of these are still works in progress. Support exists for:

- Fixed feature and control method power, lid and sleep buttons.
- Detection of ISA PnP devices using ACPI namespace.
- Detection of PCI root busses using ACPI namespace.
- CPU throttling and sleep states (incomplete)
- Thermal monitoring and cooling control (incomplete)
- Interface to platform embedded controllers (mostly complete)
- ACPI timer (incomplete)
- Simple userland control of sleep states.
- Shutdown and poweroff.