aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/acpica
Commit message (Collapse)AuthorAgeFilesLines
* acpi_battery: avoid divide-by-zero when no devices have capacity infoJosef 'Jeff' Sipek47 hours1-1/+8
| | | | | | | | | | | | | | | | On laptops with builtin batteries, disconnecting the battery may show up as a battery without any capacity information. (The theory is that one is disconnecting the cells but the electronics identifying the battery are still connected.) As a result, the loop over all batteries in acpi_battery_get_battinfo results in total_lfcap == 0. So, just check that total_lfcap is non-zero to avoid a division by zero (triggerable by sysctl hw.acpi.battery). Reported by: Stefano Marinelli Tested by: Stefano Marinelli Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D44818
* acpi_hpet: Make use of enum for vm_guest to improve readabilityZhenlei Huang2024-03-241-1/+1
| | | | | | | No functional change intended. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D44402
* new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCEJohn Baldwin2024-03-132-11/+9
| | | | | | | | | | The public bus_release_resource() API still accepts both forms, but the internal kobj method no longer passes the arguments. Implementations which need the rid or type now use rman_get_rid() or rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44131
* new-bus: Remove the 'rid' and 'type' arguments from BUS_*ACTIVATE_RESOURCEJohn Baldwin2024-03-132-24/+17
| | | | | | | | | | The public bus_activate/deactivate_resource() API still accepts both forms, but the internal kobj methods no longer pass the arguments. Implementations which need the rid or type now use rman_get_rid() or rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44130
* new-bus: Remove the 'type' argument from BUS_MAP/UNMAP_RESOURCEJohn Baldwin2024-03-131-10/+9
| | | | | | | | | | The public bus_map/unmap_resource() API still accepts both forms, but the internal kobj methods no longer pass the argument. Implementations which need the type now use rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44129
* new-bus: Remove the 'type' argument from BUS_ADJUST_RESOURCEJohn Baldwin2024-03-132-7/+6
| | | | | | | | | | The public bus_adjust_resource() API still accepts both forms, but the internal kobj method no longer passes the argument. Implementations which need the type now use rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44128
* acpi: Use rman_get_type in acpi_is_resource_managedJohn Baldwin2024-03-131-9/+9
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44125
* acpi: Defer reserving resources for ACPI devicesJohn Baldwin2024-02-221-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | The goal of reserving firmware-assigned resources is to ensure that "wildcard" resource allocation requests will not claim an address range that is actually in use even if no attached driver is actively using that range. However, the current approach can break in some cases. In particular, ACPI can enumerate devices behind PCI bridges that don't show up in a normal PCI scan, but those device_t objects can end up as direct children of acpi0. Reserving resources for those devices directly from acpi0 ends up conflicting with later attempts to reserve the PCI bridge windows. As a workaround, defer reserving unclaimed resources until after the initial probe and attach scan. Eventually this pass of reserving unclaimed resources can be moved earlier, but it requires changes to other drivers in the tree to permit enumerating devices and reserving firmware-assigned resources in a depth-first traversal before attaching devices whose drivers request wildcard allocations. PR: 272507 Reported by: Justin Tocci <justin@tocci.org> Reported by: john@feith.com, many others Tested by: Oleg Sidorkin <osidorkin@gmail.com>, dch
* acpi: Allow child drivers to use bus_set_resource for more resourcesJohn Baldwin2024-02-142-36/+67
| | | | | | | | | | | | | acpi_set_resource excludes certain types of resources for certain devices. The intention of this is to avoid adding resource entries for bogus resources enumerated via _CRS. However, this also prevents drivers from adding those resources explicitly if needed. To fix this, move the logic to exclude these resources into an ignore hook used when parsing _CRS to create the initial set of resources for each device. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43892
* acpi: Don't assume a resource is reserved in acpi_delete_resourceJohn Baldwin2024-02-141-1/+2
| | | | | | | | | This fixes a panic if a driver uses bus_set_resource to add a resource that fails to reserve and then deletes the resource via bus_delete_resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43891
* acpi: Cleanup handling of suballocated resourcesJohn Baldwin2024-02-093-82/+130
| | | | | | | | | | | | | | | | | | | | | | | | | For resources suballocated from the system resource rmans, handle those in the ACPI bus driver without passing them up to the parent. This means using bus_generic_rman_* for several bus methods for operations on suballocated resources. For bus_map/unmap_resource, find the system resource allocated from the parent bus (nexus) that contains the range being mapped and request a mapping of that parent resource. This avoids a layering violation where nexus drivers were previously asked to manage the activation and mapping of resources created belonging to the ACPI resource managers. Note that this does require passing RF_ACTIVE (with RF_UNMAPPED) when allocating system resources from the parent. While here, don't assume that the parent bus (nexus) provides a resource list that sysres resources are placed on. Instead, create a dedicated resource_list in the ACPI bus driver's softc to hold sysres resources. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43687
* acpi: Use bus_generic_alloc_resource instead of duplicating itJohn Baldwin2024-02-091-1/+1
| | | | | | | | No functional change, but it is cleaner to use the existing generic wrappers rather than KOBJ methods directly. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43686
* acpi: Use kobj typedefs for new-bus method prototypesJohn Baldwin2024-02-092-52/+36
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43685
* run acpi_shutdown_final later to give other handlers a chanceAndriy Gapon2024-01-281-1/+1
| | | | | | | | | | | For example, shutdown_panic wants to produce some output and maybe take some input before a system is actually reset. The change should only make difference for the case of system reset (reboot), poweroff and halt should not be affected. The change makes difference only if hw.acpi.handle_reboot is set. It used to default to zero until r213755 / ac731af5670c7.
* acpi_pcib: Use pci_domain_[de]activate_bus for PCI_RES_BUS resourcesJohn Baldwin2024-01-231-1/+34
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43428
* apei: Mark ReadAckRegister resource as shareableAndrew Gallatin2024-01-091-1/+1
| | | | | | | | | | | | Work around vendors who use the same address for multiple ReadAckRegisters in their ACPI HEST table. This allows apei to attach cleanly on Ampere Altra servers. Note the issue is not specific to Ampere, I've run into it with at least one other vendor (whose server is not yet released). Sponsored by: Netflix Reviewed by: jhb
* acpi: Only reserve resources enumerated via _CRSJohn Baldwin2024-01-092-37/+0
| | | | | | | | | | | | | | | | | | | | | | | In particular, don't reserve resources added by drivers via other means (e.g. acpi_bus_alloc_gas which calls bus_alloc_resource right after adding the resource). The intention of reserved resources is to ensure that a resource range that a bus driver knows is assigned to a device is reserved by the system even if no driver is attached to the device. This prevents other "wildcard" resource requests from conflicting with these resources. For ACPI, the only resources the bus driver knows about for unattached devices are the resources returned from _CRS. All of these resources are already reserved now via acpi_reserve_resources called from acpi_probe_children. As such, remove the logic from acpi_set_resource to try to reserve resources when they are set. This permits RF_SHAREABLE to work with acpi_bus_alloc_gas without requiring hacks like the current one for CPU device resources in acpi_set_resource. Reported by: gallatin (RF_SHAREABLE not working) Diagnosed by: jrtc27
* acpi_cpu: Reduce BUS_MASTER_RLD manipulationsAlexander Motin2023-12-261-9/+9
| | | | | | | | | | | | | | | Instead of setting and clearing BUS_MASTER_RLD register on every C3 state enter/exit, set it only once if the system supports C3 state and we are going to "disable" bus master arbitration while in it. This is what Linux does for the past 14 years, and for even more time this register is not implemented in a relevant hardware. Same time since this is only a single bit in a bigger register, ACPI has to do take a global lock and do read-modify-write for it, that is too expensive, saved only by C3 not entered frequently, but enough to be seen in idle system CPU profiles. MFC after: 1 month
* acpi_lid: Remove duplicate eventsAlexander Motin2023-12-241-6/+10
| | | | | | | | | | Remove extra acpi_UserNotify() call per event. Filter duplicate notifications received from ACPI without actual status change. Without this on my Dell XPS 13 9310 I saw 4 devd events for either open or close, now only one. MFC after: 1 month
* x86: Support multiple PCI MCFG regionsJohn Baldwin2023-11-291-5/+2
| | | | | | | | | | | In particular, this enables support for PCI config access for domains (segments) other than 0. Reported by: cperciva Tested by: cperciva (m7i.metal-48xl AWS instance) Reviewed by: imp Relnotes: yes Differential Revision: https://reviews.freebsd.org/D42828
* pci_cfgreg: Add a PCI domain argument to the low-level register APIJohn Baldwin2023-11-293-18/+29
| | | | | | | | | | | | | | | | | | | | | | | This commit changes the API of pci_cfgreg(read|write) to add a domain argument (referred to as a segment in ACPI parlance) (note that this is not the same as a NUMA domain, but something PCI-specific). This does not yet enable access to domains other than 0, but updates the API to support domains. Places that use hard-coded bus/slot/function addresses have been updated to hardcode a domain of 0. A few places that have the PCI domain (segment) available such as the acpi_pcib_acpi.c Host-PCI bridge driver pass the PCI domain. The hpt27xx(4) and hptnr(4) drivers fail to attach to a device not on domain 0 since they provide APIs to their binary blobs that only permit bus/slot/function addressing. The x86 non-ACPI PCI bus drivers all hardcode a domain of 0 as they do not support multiple domains. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D42827
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-275-5/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* acpi: Add workaround for Altra I2C memory resourceAndrew Gallatin2023-11-151-0/+7
| | | | | | | Submitted by: allanjude Sponsored by: Ampere Computing LLC Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D28741
* acpi_pcib: Rename decoded_bus_range to get_decoded_bus_rangeJohn Baldwin2023-10-201-6/+6
| | | | | | While here, change the return value to bool. Discussed by: gibbs
* acpi_pcib: Trust decoded bus range from _CRS over _BBNJohn Baldwin2023-10-161-11/+19
| | | | | | | | | | | | | | | Currently if _BBN doesn't match the first bus in the decoded bus range from _CRS for a Host to PCI bridge, the driver fails to attach as a defensive measure. There is now firmware in the field where these do not match, and the _BBN values are clearly wrong, so rather than failing attach, trust the range from _CRS over _BBN. Co-authored-by: Justin Gibbs <gibbs@FreeBSD.org> Reported by: gibbs Reviewed by: imp (earlier version) Differential Revision: https://reviews.freebsd.org/D42231
* acpi_ged: Handle events directlyAndrew Gallatin2023-10-121-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Handle ged interrupts directly from the interrupt handler, while the interrupt source is masked, so as to conform with the acpi spec, and avoid spurious interrupts and lockups on boot. When an acpi ged interrupt is encountered, the spec requires the os (as stated in 5.6.4: General Purpose Event Handling) to leave the interrupt source masked until it runs the EOI handler. This is not a good fit for our method of queuing the work (including the EOI ack of the interrupt), via the AcpiOsExecute() taskqueue mechanism. Note this fixes a bug where an arm64 server could lock up if it encountered a ged interrupt at boot. The lockup was due to running on a single core (due to arm64 not using EARLY_AP_STARTUP), and due to that core encountering a new interrupt each time the interrupt handler unmasked the interrupt source, and having the EOI queued on a taskqueue which never got a chance to run. This is also possible on any platform when using just a single processor. The symptom of this is a lockup at boot, with: "AcpiOsExecute: failed to enqueue task, consider increasing the debug.acpi.max_tasks tunable" scrolling on console. Similarly, spurious interrupts would occur when running with multiple cores, because it was likely that the interrupt would fire again immediately, before the ged task could be run, and before an EOI could be sent to lower the interrupt line. I would typically see 3-5 copies of every ged event due to this issue. This adds a tunable, debug.acpi.ged_defer, which can be set to 1 to restore the old behavior. This was done because acpi is a complex system, and it may be theoretically possible something the ged handler does may sleep (though I cannot easily find anthing by inspection). MFC after: 1 month Reviewed by: andrew, jhb, imp Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D42158
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-163-3/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-1637-74/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-167-14/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* tc_fill_vdso_timehands32(): fixKonstantin Belousov2023-08-121-1/+2
| | | | | | | | | | | | | 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
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-122-2/+2
| | | | | | | | | 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
* acpi_button: Replace boolean_t with better types.John Baldwin2023-05-041-6/+4
| | | | | | | | | - 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
* Use bool for one-bit wide bit-fieldsDimitry Andric2023-04-252-16/+16
| | | | | | | | | | | | 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
* acpi(4): Fix a typo in a kernel messageGordon Bergling2023-03-231-1/+1
| | | | | | - s/enitialization/initialization/ MFC afer: 5 days
* acpica: do not print warning for missing _ADRYuri2023-03-071-2/+3
| | | | | | | | | | | | | | | | 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
* acpica: purge EOL release compatibilityElliott Mitchell2023-02-041-2/+0
| | | | | | | | 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
* Add support for _CR3 critical standby (S3) threshold.Cyrus Rahman2022-11-221-5/+21
| | | | | | | | | | | | | | | 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
* acpi_ged: fix build with ACPI_DEBUGGleb Smirnoff2022-10-241-1/+1
|
* acpi_ged: fix build, as module and non INTRNG case.Takanori Watanabe2022-10-241-1/+1
| | | | | | Reviewed-by: cy Differential Revision: https://reviews.freebsd.org/D37104
* acpi_ged: New driver to ACPI generic event deviceTakanori Watanabe2022-10-241-0/+267
| | | | | | | | | | | | | | | | 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
* acpi: Create cppc_notify sysctl before it is checkedTom Jones2022-10-231-8/+8
| | | | | | Reported by: Henrix Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D37081
* acpi: Put CPPC workaround behind i386/amd64 if defTom Jones2022-10-111-0/+4
| | | | | While CPPC is available on arm64 platforms with ACPI we don't know if we need to work around issues with firmware there.
* acpi: Tell SMM we will handle CPPC notificationsTom Jones2022-10-101-0/+14
| | | | | | | | | | | | | | | | | | | | | | | 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
* device_get_property: add a HANDLE caseBjoern A. Zeeb2022-10-091-0/+47
| | | | | | | | | | 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
* acpi_thermal: Fix a potential stack buffer overflow.Johannes Totz2022-10-031-3/+3
| | | | | | | While here, fix a typo as well. Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D36495
* pmap_unmapdev/bios: Accept a pointer instead of a vm_offset_t.John Baldwin2022-09-223-6/+5
| | | | | | | | This matches the return type of pmap_mapdev/bios. Reviewed by: kib, markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D36548
* acpi: mark INVARIANTS variables as __diagusedEd Maste2022-08-101-2/+2
| | | | | | | | | | 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
* acpi(4): Fix two typos in a source code commentsGordon Bergling2022-08-071-1/+1
| | | | | | - s/paramater/parameter/ MFC after: 3 days
* acpi_apei: Add sysctl to mute corrected errors.Alexander Motin2022-08-051-4/+54
| | | | | | Setting hw.acpi.apei.log_corrected to 0 will mute corrected errors logging. MFC after: 1 week
* Adjust function definition in acpi_timer.c to avoid clang 15 warningsDimitry Andric2022-07-261-1/+1
| | | | | | | | | | | | | | | 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