Commit Graph

1423 Commits

Author SHA1 Message Date
Warner Losh
031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06:00
Warner Losh
685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh
95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Konstantin Belousov
93626d5437 tc_fill_vdso_timehands32(): fix
On 64bit, there is a 4-byte hole in struct vdso_timekeep32 after
tk_current, if the structure is not packed.  This is due to the MD
th_x86_pvc_last_systime being 64bit.

Change amd64 VDSO_TIMEHANDS_MD32 to not use uint64_t, replace it with
pair of uint32_t, as it is done for all other members.

PR:	273085
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-08-13 01:34:08 +03:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
John Baldwin
65c92e48c4 acpi_button: Replace boolean_t with better types.
- Use an enum for the button type (it is not really a boolean value).

- Use bool for fixed.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D39922
2023-05-04 12:32:09 -07:00
Dimitry Andric
bab8274c09 Use bool for one-bit wide bit-fields
A signed one-bit wide bit-field can take only the values 0 and -1. Clang
16 introduced a warning that "implicit truncation from 'int' to a
one-bit wide bit-field changes value from 1 to -1". Fix the warnings by
using C99 bool.

Reported by:	Clang 16
Reviewed by:	emaste, jhb
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D39705
2023-04-25 19:26:03 +02:00
Gordon Bergling
f63aaffebc acpi(4): Fix a typo in a kernel message
- s/enitialization/initialization/

MFC afer:	5 days
2023-03-23 22:03:31 +01:00
Yuri
109abf744b acpica: do not print warning for missing _ADR
Started seeing the following after updating to VMware ESXi 8.0:

pcib2: <ACPI Host-PCI bridge> on acpi0
pcib2: could not evaluate _ADR - AE_NOT_FOUND
pci2: <ACPI PCI bus> on pcib2
vmx0: <VMware VMXNET3 Ethernet Adapter> ...

The virtual NIC works fine, and the code comment suggests that
missing _ADR is not something fatal, skip printing the message
if status is AE_NOT_FOUND.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/682
2023-03-07 16:25:21 -07:00
Elliott Mitchell
33f6a4e90f acpica: purge EOL release compatibility
Remove obsolete check for FreeBSD >= 11

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/603
Differential Revision: https://reviews.freebsd.org/D35560
2023-02-04 09:13:09 -07:00
Cyrus Rahman
b8a0dfb17e Add support for _CR3 critical standby (S3) threshold.
Along with _PSV, _HOT, and _CRT, ACPI supports the _CR3 threshold
which specifies a temperature above which a system should transition
to the S3 standby state.

On FreeBSD, this is more useful than _HOT, which specifies the S4
transition threshold temperature (since FreeBSD does not generally
support the S4 state), or, in many cases, _CRT, since after
transitioning to S3 the system can cool and then be resumed.

Reviewed by:	jhb, bcr (manpages)
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D35980
2022-11-21 22:12:04 -08:00
Gleb Smirnoff
ba23f762ec acpi_ged: fix build with ACPI_DEBUG 2022-10-24 09:00:04 -07:00
Takanori Watanabe
9cf5db6369 acpi_ged: fix build, as module and non INTRNG case.
Reviewed-by: cy

Differential Revision: https://reviews.freebsd.org/D37104
2022-10-24 23:37:28 +09:00
Takanori Watanabe
a9880bfe11 acpi_ged: New driver to ACPI generic event device
New driver to ACPI generic event device, defined in ACPI spec.
Some ACPI power button may not work without this.

In qemu arm64 with "virt" machine, with ACPI firmware,
enable devd check devd message by
and invoke following command in qemu monitor
(qemu) system_powerdown
and make sure some power button input event appear.
(setting sysctl hw.acpi.power_button_state=S5 is not work,
because ACPI tree does not have \_S5 object.)

Reviewed by: andrew, hrs
Differential Revision: https://reviews.freebsd.org/D37032
2022-10-24 18:57:36 +09:00
Tom Jones
15bd2f366d acpi: Create cppc_notify sysctl before it is checked
Reported by:	Henrix
Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D37081
2022-10-23 10:10:56 +01:00
Tom Jones
eee0f7aea4 acpi: Put CPPC workaround behind i386/amd64 if def
While CPPC is available on arm64 platforms with ACPI we don't know if we
need to work around issues with firmware there.
2022-10-11 09:31:22 +01:00
Tom Jones
67f2a563bf acpi: Tell SMM we will handle CPPC notifications
Buggy SMM implementations can hang while processing CPPC notifications.
This leads to some laptops (notably Thinkpads) hanging when the
hwpstate_intel driver is loaded.

Tell the SMM that we will handle CPPC notifications as described in:

- Intel® Processor Vendor-Specific ACPI
- Intel® 64 and IA-32 Architectures Software Developer’s Manual

CPPC events default to masked (disabled) so while we do not do any
handling right now this does not seem to lead to any issues.

This approach was found via this Linux Kernel patch:
https://lkml.org/lkml/2016/3/17/563

PR:		253288
Reviewed by:	imp, jhb
Sponsored by:	Modirum
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D36699
2022-10-10 14:53:15 +01:00
Bjoern A. Zeeb
99e6980fcf device_get_property: add a HANDLE case
This will resolve a reference and return the appropriate handle, a node
on the simplebus or an ACPI_HANDLE for ACPI.  For now we do not try to
further abstract the return type.

MFC after:	2 weeks
Reviewed by:	mw
Differential Revision: https://reviews.freebsd.org/D36793
2022-10-09 21:51:25 +00:00
Johannes Totz
a9a267c1f7 acpi_thermal: Fix a potential stack buffer overflow.
While here, fix a typo as well.

Reviewed by:	jhb
Differential Revision: https://reviews.freebsd.org/D36495
2022-10-03 11:16:27 -07:00
John Baldwin
7ae99f80b6 pmap_unmapdev/bios: Accept a pointer instead of a vm_offset_t.
This matches the return type of pmap_mapdev/bios.

Reviewed by:	kib, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D36548
2022-09-22 15:08:52 -07:00
Ed Maste
0fd8d3589a acpi: mark INVARIANTS variables as __diagused
Fixes INVARIANTS build with Clang 15, which previously failed due to
set-but-not-used variable warnings.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36096
2022-08-10 17:17:33 -04:00
Gordon Bergling
cc538081ef acpi(4): Fix two typos in a source code comments
- s/paramater/parameter/

MFC after:	3 days
2022-08-07 15:58:04 +02:00
Alexander Motin
52a54b96ed acpi_apei: Add sysctl to mute corrected errors.
Setting hw.acpi.apei.log_corrected to 0 will mute corrected errors logging.

MFC after:	1 week
2022-08-05 13:48:05 -04:00
Dimitry Andric
c45bc02560 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
2022-07-26 22:08:01 +02:00
Bjoern A. Zeeb
945eaca155 ACPI: change arguments to internal acpi_find_dsd()
acpi_find_dsd() is not a bus function and we only need the acpi_device (ad).
The only caller has already looked up the ad (from ivars) for us.
Directly pass the ad to acpi_find_dsd() instead of bus, dev and remove
the extra call to device_get_ivars(); the changed argument also means we
now call AcpiEvaluateObject directly on the handle.

This optimisation was done a while ago while debugging a driver which
ended up with a bad bus, dev combination making the old version fail.

MFC after:	2 weeks
Reviewed by:	mw
Differential Revision: https://reviews.freebsd.org/D35558
2022-06-28 12:57:04 +00:00
John Baldwin
916a5d8ad5 acpi: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-06 15:39:28 -07:00
John Baldwin
43ac2b6d7c Remove isab_devclass from ISA bridge drivers. 2022-05-06 15:39:28 -07:00
John Baldwin
5a03f17a9a acpi_tz: Lookup devclass by name when needed.
Cache the value in a local variable in the worker thread.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34992
2022-04-21 10:29:13 -07:00
John Baldwin
9066471175 acpi_isab: Check the unit in probe instead of using the devclass.
This is an alternate way to only attach to isab0 for the reasons
described in commit 852989bdbf.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34991
2022-04-21 10:29:13 -07:00
John Baldwin
33883cdce4 acpi_hpet: Use devclass_find to find devclass in identify.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34990
2022-04-21 10:29:13 -07:00
John Baldwin
97c076d237 acpi_ec: Use device_get_devclass to find devclass in probe.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34989
2022-04-21 10:29:13 -07:00
John Baldwin
e206dddcfe acpi_cpu: Use device_get_devclass to find devclass in attach.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34988
2022-04-21 10:29:13 -07:00
John Baldwin
3730d6aa8f acpi_apei: Use devclass_find to find devclass in identify.
Reviewed by:	mav
Differential Revision:	https://reviews.freebsd.org/D34987
2022-04-21 10:29:13 -07:00
John Baldwin
5a84b710a9 acpi_acad: Use devclass_find to find the acpi_acad devclass.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34986
2022-04-21 10:29:13 -07:00
Roger Pau Monné
b93f47eaee xen/acpi: upload Cx and Px data to Xen
When FreeBSD is running as dom0 (initial domain) on a Xen system it
has access to the native ACPI tables and is the OSPM. However the
hypervisor is the entity in charge of the CPU idle and frequency
states, and in order to perform this duty it requires information
found the ACPI dynamic tables that can only be parsed by the OSPM.

Introduce a new Xen specific ACPI driver to fetch the Processor
related information and upload it to Xen. Note that this driver needs
to take precedence over the generic ACPI CPU driver when running as
dom0, so downgrade the probe score of the native driver to
BUS_PROBE_DEFAULT in order for the Xen specific driver to use
BUS_PROBE_SPECIFIC.

Tested on an Intel NUC to successfully parse and upload both the Cx and
Px states to Xen.

Sponsored by: Citrix Systems R&D
Reviewed by: jhb kib
Differential revision: https://reviews.freebsd.org/D34841
2022-04-12 10:03:26 +02:00
John F. Carr
964bf2f902 hpet: Allow a MMIO window smaller than 1K
Some new AMD systems provide a HPET MMIO region smaller than the 1KB
specified, and a correspondingly small number of timers.  Handle this in
the HPET driver rather than requiring a 1KB window.  This allows the
HPET driver to attach on such systems.

PR:		262638
Reviewed by:	markj
MFC after:	1 month
2022-03-28 11:23:45 -04:00
Kornel Duleba
b344de4d0d Extend device_get_property API
In order to support various types of data stored in device
tree properties or ACPI _DSD packages, create a new enum so
the caller can specify the expected type of a property they
want to read, according to the binding. The bus logic will use
that information to process the underlying data.

For example in DT all integer properties are stored in BE format.
In order to get constant results across different platforms we
need to convert its endianness to match the host.

Another example are ACPI_TYPE_INTEGER properties stored
as uint64_t. Before this patch the ACPI logic would refuse
to read them if the provided buffer was smaller than 8 bytes.
Now this can be handled by using DEVICE_PROP_UINT32 type.

Modify the existing consumers of this API to reflect the changes
and update the man pages accordingly.

Reviewed by: mw
Obtained from: Semihalf
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D33457
2022-03-10 12:11:32 +01:00
Warner Losh
dbee7944ba acpi: Allow matching based on locators
Allow wiring of unit numbers based any of the standard locators that
match.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D32787
2022-03-01 08:06:42 -07:00
Warner Losh
6837d9d7e8 acpi hints: Abstract out acpi_hint_device_matches_resources
Abstract out acpi_hint_device_matches_resources from
acpi_hint_device_unit to simplify that code. Continue matching like
we've always matched: no functional change.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D32786
2022-03-01 08:06:42 -07:00
Warner Losh
3278bf9268 acpi_hint_device_unit: matches is a bool, make it one
"matches" is used as a bool and doesn't need to count anything. Convert
it to a bool.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D32785
2022-03-01 08:06:42 -07:00
Warner Losh
d0a20e401e Add UEFI locator for bus_get_device_path, pci acpi
Add a UEFI locator type. It prints the UEFI device names for a FreeBSD
device_t name. It works with PCI and ACPI device nodes. USB forthcoming.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D32749
2022-03-01 08:06:41 -07:00
Warner Losh
cae7d9ec83 bus: Add ACPI locator support
Add support for printing ACPI paths. This is a bit of a degenerate case
for this interface since it's always just the device handle if the
device has one. But it is illustrtive of how to do this for a few nodes
in the tree.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D32748
2022-03-01 08:06:41 -07:00
Alexander Motin
3b248a2113 APEI: Make sure event data fit into the buffer.
There seem to be systems returning some garbage here.  I still don't
know why, but at least I hope this check fix indefinite printf loop.

MFC after:	2 weeks
2022-02-03 15:33:01 -05:00
Takanori Watanabe
5c69be7084 acpi: Ignore _STA and never disable AT RTC devices
atrtc(4) should always install a SystemCMOS address space handler unless
the RTC Not Present bit is not set in IAPC_BOOT_ARCH in the FADT.
The atrtc(4) driver already checks this bit, but _STA can return not-present
even when this bit is clear.

Reviewed by : jhb
Differential Revision: https://reviews.freebsd.org/D33891
2022-01-21 15:30:46 +09:00
Stefan Eßer
e2650af157 Make CPU_SET macros compliant with other implementations
The introduction of <sched.h> improved compatibility with some 3rd
party software, but caused the configure scripts of some ports to
assume that they were run in a GLIBC compatible environment.

Parts of sched.h were made conditional on -D_WITH_CPU_SET_T being
added to ports, but there still were compatibility issues due to
invalid assumptions made in autoconfigure scripts.

The differences between the FreeBSD version of macros like CPU_AND,
CPU_OR, etc. and the GLIBC versions was in the number of arguments:
FreeBSD used a 2-address scheme (one source argument is also used as
the destination of the operation), while GLIBC uses a 3-adderess
scheme (2 source operands and a separately passed destination).

The GLIBC scheme provides a super-set of the functionality of the
FreeBSD macros, since it does not prevent passing the same variable
as source and destination arguments. In code that wanted to preserve
both source arguments, the FreeBSD macros required a temporary copy of
one of the source arguments.

This patch set allows to unconditionally provide functions and macros
expected by 3rd party software written for GLIBC based systems, but
breaks builds of externally maintained sources that use any of the
following macros: CPU_AND, CPU_ANDNOT, CPU_OR, CPU_XOR.

One contributed driver (contrib/ofed/libmlx5) has been patched to
support both the old and the new CPU_OR signatures. If this commit
is merged to -STABLE, the version test will have to be extended to
cover more ranges.

Ports that have added -D_WITH_CPU_SET_T to build on -CURRENT do
no longer require that option.

The FreeBSD version has been bumped to 1400046 to reflect this
incompatible change.

Reviewed by:	kib
MFC after:	2 weeks
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D33451
2021-12-30 12:20:32 +01:00
Alexander Motin
3e68d2c52b acpica: Remove CTLFLAG_NEEDGIANT from most sysctls.
MFC after:	2 weeks
2021-12-26 19:18:55 -05:00
Alexander Motin
de291c5d10 acpi_cpu: Replace Giant with bus_topo_lock. 2021-12-09 20:08:25 -05:00
Warner Losh
d14bc7230b newbus: add bus_topo_assert
Add bus_topo_assert() and implmement it as GIANT_REQUIRED for the
moment. This will allow us to change more easily to a newbus-specific
lock int he future.

Sponsored by:		Netflix
Reviewed by:		wulf, mav, jhb
Differential Revision:	https://reviews.freebsd.org/D31833
2021-12-09 17:04:57 -07:00
Warner Losh
c6df6f5322 Create wrapper for Giant taken for newbus
Create a wrapper for newbus to take giant and for busses to take it too.
bus_topo_lock() should be called before interacting with newbus routines
and unlocked with bus_topo_unlock(). If you need the topology lock for
some reason, bus_topo_mtx() will provide that.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D31831
2021-12-09 17:04:45 -07:00
Alexander Motin
2dfc1f7355 APEI: Improve multiple error sources handling.
Some AMD systems I have report 8 NMI and 3591 polled error sources.
Previous code could handle only one NMI source and used separate
callout for each polled source.  New code can handle multiple NMIs
and groups polled sources by power of 2 of the polling period.

MFC after:	2 weeks
2021-12-02 18:06:12 -05:00