aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/acpica
Commit message (Collapse)AuthorAgeFilesLines
* acpi: Use AcpiGbl_FACS even on ACPI_REDUCED_HARDWAREOlivier Certner5 days1-2/+0
| | | | | | | | | | | | | | | This has been possible since ACPICA 20240827, and is actually a requirement to get out of S3 on ACPI_REDUCED_HARDWARE (that said, we don't implement S3 on arm64 yet). Relevant ACPICA commit: https://github.com/acpica/acpica/commit/79cd933e7b370e8d3fb490bf36ca5d111a12f96a. Reviewed by: obiwac MFC after: 2 weeks MFC to: stable/15 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54625
* acpi: Use only AcpiGetSleepTypeData() to determine Sx supportOlivier Certner5 days1-5/+5
| | | | | | | | | | | | | | Previously, we would first call AcpiEvaluateObject() to execute \_Sx before calling AcpiGetSleepTypeData(). This was unnecessary, as AcpiGetSleepTypeData() performs the same call itself. While doing so, the latter function logs any other error than AE_NOT_FOUND (which indicates that a particular sleep state is not supported), which most probably is an added benefit of this change. Reviewed by: obiwac MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54624
* acpi_spmc(4): Fix compilation on 32-bit platformsOlivier Certner5 days1-1/+4
| | | | | Fixes: c5daa5a4c32c ("acpi_spmc: Add system power management controller driver") Sponsored by: The FreeBSD Foundation
* acpi: Add ACPI_SPMC debug layer defineAymeric Wibo6 days1-0/+1
| | | | | | Reported by: des Fixes: c5daa5a4c32c ("acpi_spmc: Add system power management controller driver") Sponsored by: The FreeBSD Foundation
* acpi_spmc: Add system power management controller driverAymeric Wibo6 days2-0/+619
| | | | | | | | | | | | | | | | | | | Add SPMC (system power management controller) driver as acpi_spmc. This is the device which provides the LPI device D-state constraints and allows for OSPM to send S0ix/modern standby entry/exit notifications. This supports the original Intel DSM (https://uefi.org/sites/default/files/resources/Intel_ACPI_Low_Power_S0_Idle.pdf, untested), the AMD DSM (tested), and the Microsoft DSM (tested). Before entry, acpi_spmc_check_constraints is called to notify of any violated power constraints. This will use acpi_pwr_get_state to get current device D-states when that gets added back. Reviewed by: olce Tested by: jkim, Oleksandr Kryvulia, Matthias Lanter Approved by: olce Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48387
* acpi: Fix not calling AcpiLeaveSleepState() in S3 pathAymeric Wibo13 days1-6/+3
| | | | | | | | | | | | | | | | | | | | | | When resuming from ACPI suspend, the ACPI_SS_SLP_PREP bit in slp_state was being checked and subsequently unset when calling resumeclock(). This bit was also being checked for the AcpiLeaveSleepState() call in the non-s2idle path, but having just been unset, it was never actually being called. Change this so that resumeclock() is always being called (since we never goto breakout between suspendclock() and resumeclock() anyway) and ACPI_SS_SLP_PREP is purely used for AcpiEnterSleepStatePrep() and AcpiLeaveSleepState() in the non-s2idle paths. PR: 292568 Reported by: Marek Zarychta Reviewed by: olce Tested by: Marek Zarychta Approved by: olce Fixes: 7669cbd0f064 (“acpi: Suspend-to-idle support (s2idle)”) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54777
* acpi: Add a function to deregister all ioctl commands using the same functionJohn Baldwin2026-01-153-7/+17
| | | | | | | | This simplifies detach/cleanup for drivers that add multiple ACPI ioctls. Reviewed by: imp Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D54420
* acpi: Suspend-to-idle support (s2idle)Aymeric Wibo2026-01-131-93/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement STYPE_SUSPEND_TO_IDLE sleep type added in c43473dc9b83 ("sys/power: Generic sleep types"). This is a prerequisite for the firmware to enter the S0ix states. When suspending to idle, the system stays in an ACPI S0 state, but the CPUs are idled and devices are suspended/resumed before and after this as they would be when entering any other sleep type (except for AWAKE and POWEROFF). Factor out do_standby, do_sleep, and add a new do_idle function for idling the CPU (a future patch will make this an idle loop and not just a simple cpu_idle() call). In do_idle, SCIs (interrupt 9) are enabled to allow wake events to break the CPU out of idle. Record all the steps made instead of just the last one in slp_state, which allows for more flexible unwinding (will be useful to not have to goto breakout if the SPMC entry call fails when that is committed). A lot of this borrows from Ben Widawsky's patch: D17675. The main functional difference with that patch is that suspend-to-idle is a wholly separate sleep type in this one as opposed to being an alternative implementation for s2mem (S3). Reviewed by: emaste, olce Approved by: olce Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48734
* acpi: Make taskqueue only run on BSPAymeric Wibo2026-01-081-1/+5
| | | | | | | | | | | | | | This is needed because when we add the suspend-to-idle loop, we only want to break the BSP out of idle to process the taskqueue while keeping all the others idled. Currently assuming BSP to be CPU0, which may not always be the case on non-x86. Reviewed by: kib Approved by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54406
* acpi: Statically initialize acpi_ioctl_hooksJohn Baldwin2025-12-261-11/+6
| | | | | | Reviewed by: imp Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D54313
* acpi: Use M_WAITOK in acpi_register_ioctlJohn Baldwin2025-12-261-2/+1
| | | | | | | | | This function is only called from device attach routines which can sleep. Reviewed by: imp Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D54312
* acpi: Reject duplicate handlers for ioctl commandsJohn Baldwin2025-12-261-1/+9
| | | | | | Reviewed by: imp Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D54311
* acpi_apei: Remove the hest member from the softcJohn Baldwin2025-12-261-6/+5
| | | | | | | | | | This is only used during attach and freed after use, so just use a local variable in the attach routine instead to avoid leaving a dangling pointer around in the softc. Reviewed by: imp Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D54310
* acpi: Free ivars in bus_child_deleted methodJohn Baldwin2025-12-261-0/+1
| | | | | | Reviewed by: imp Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D54309
* acpi_PkgGas: Pass rid by valueJohn Baldwin2025-12-094-7/+7
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D53406
* acpi_bus_alloc_gas: Pass rid by valueJohn Baldwin2025-12-096-12/+12
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D53405
* resource_list_reserve: Pass rid by valueJohn Baldwin2025-12-091-1/+1
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D53403
* bus_alloc_resource: Pass rid by value to BUS_ALLOC_RESOURCE DEVMETHODJohn Baldwin2025-12-092-8/+8
| | | | | | | | | The wrapper functions such as bus_alloc_resource_any() still support passing the rid by value or pointer, but the underlying implementation now passes by value. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D53402
* acpi: Fix typos in sysctl descriptionsAymeric Wibo2025-11-281-2/+2
| | | | | | Reviewed by: thj, emaste Approved by: thj Sponsored by: The FreeBSD Foundation
* acpi: Fix setting sleep state sysctls to NONEAymeric Wibo2025-11-281-15/+24
| | | | | | | | | | | | | | This restores the functionality as it was pre-97d152698f48. A stopgap was committed by glebius@ in 34dfccc64f47 ("acpi: in acpi_stype_sysctl() use same logic as in acpi_sleep_state_sysctl()"). PR: 290651 Reviewed by: thj, emaste Approved by: thj Fixes: 97d152698f48 ("acpi: Use sleep types defined in sys/power.h") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D53909
* acpi: add counters for cumulative time spent in each sleep state.Adrian Chadd2025-11-111-0/+30
| | | | | | | Add this so it can be consumed/graphed. Differential Revision: https://reviews.freebsd.org/D53633 Reviewed by: gallatin, imp
* acpi(4): Fix typo in a panic messageGordon Bergling2025-10-291-1/+1
| | | | | | - s/depenedent/dependent/ MFC after: 5 days
* acpi: in acpi_stype_sysctl() use same logic as in acpi_sleep_state_sysctl()Gleb Smirnoff2025-10-271-2/+2
| | | | | | | | | | | | Otherwise we allow to trigger an MPASS() by a userland sysctl, e.g. hw.acpi.power_button_state=NONE. This does not bring fully compatibility, where as before 97d152698f483 setting to 'NONE' actually meant disabling any action on a power or sleep button. Now sysctl will fail, but with this change it won't at least panic. Aymeric may come with a better fix. Fixes: 97d152698f4831db5a94d55c15233330c188feda
* power: Add stype parameter in power_suspend/resume eventhandlersAymeric Wibo2025-10-062-7/+10
| | | | | | | | | | Add enum sleep_type stype parameter in power_suspend/resume event handlers, as with the introduction of s2idle there are more than one type of suspend. Reviewed by: bz Approved by: bz Sponsored by: The FreeBSD Foundation
* apei_detach: fix swi_remove parameterEric van Gyzen2025-10-041-1/+1
| | | | | | | swi_remove expects a void *, but we were passing void **. MFC after: 1 week Sponsored by: Dell Inc.
* Revert "acpi_powerres: Fix turning off power resources on first D-state switch"Aymeric Wibo2025-10-011-105/+5
| | | | | | | | This reverts commit a13f28d57ecfd136ce73493659c28a47fa1a4b9f. Reported by: phk Tested by: phk Sponsored by: The FreeBSD Foundation
* Revert "acpi_powerres: `acpi_pwr_get_state` and getting initial D-state for ↵Aymeric Wibo2025-09-282-160/+5
| | | | | | | | | | | | | | device" Setting ACPI D-states is generally broken on FreeBSD and this change surfaced an issue. So reverting for the time being whilst I write a proper fix for this. This reverts commit 02a8fadd2c4dc4b78d6d93d9d8b70e9348a6de6d. Reported by: glebius, phk Tested by: glebius Sponsored by: The FreeBSD Foundation
* sys/power: Sleep type reporting by PM backendsAymeric Wibo2025-09-261-2/+4
| | | | | | | | | | | | | | | Allow PM backends to report supported sleep types when registering through `power_pm_register`. Expose this information through `kern.power.supported_stype` sysctl, and set defaults for `power_standby/suspend/hibernate_stype` based on this. Implement this in ACPI PM backend. Reviewed by: cy Approved by: cy Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52727 Event: EuroBSDcon 2025 Devsummit
* acpi: Add back `hw.acpi.suspend_state` sysctlAymeric Wibo2025-09-261-0/+32
| | | | | | | | | | | | | | | | | When writing an ACPI S-state to it it will set kern.power.suspend to the appropriate sleep type, and when reading from it it will return the corresponding ACPI S-state to the sleep type in kern.power.suspend. This is deprecated and kern.power.suspend should be used directly instead, but add this back because zzz(1) makes use of this and we can't easily rewrite it just now. PR: 289634 Reviewed by: cy, markj Approved by: cy, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52600 Event: EuroBSDcon 2025 Devsummit
* acpi: Use sleep types defined in sys/power.hAymeric Wibo2025-09-263-149/+255
| | | | | | | | | | | | | | | This is as opposed to using ACPI sleep states directly (`ACPI_STATE_S*`). We now use `POWER_STYPE_*` added in D52036. This is in preparation for adding support for s2idle, which is not an ACPI sleep state, but needs to be handled specially by `acpi_EnterSleepState`. Reviewed by: cy Approved by: cy Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52705 Event: EuroBSDcon 2025 Devsummit
* Revert "acpi: Use sleep types defined in sys/power.h"Aymeric Wibo2025-09-183-241/+146
| | | | | | This reverts commit ce5e22b28ef6caff3ffd228ac188114b08c0da02. PR: 289634
* Revert "sys/power: Sleep type reporting by PM backends"Aymeric Wibo2025-09-181-4/+2
| | | | | | This reverts commit e779891327b1d9b9ab10ba482e59f498790505a7. PR: 289634
* Revert "acpi: Fix build when `ACPI_DEBUG_OUTPUT` defined"Aymeric Wibo2025-09-181-2/+2
| | | | | | This reverts commit 4894f5ba394306a75dbed9ed4377ab0eae75aede. PR: 289634
* acpi: Fix build when `ACPI_DEBUG_OUTPUT` definedAymeric Wibo2025-09-151-2/+2
| | | | | | | Reviewed by: olce Fixes: ce5e22b28ef6 ("acpi: Use sleep types defined in sys/power.h") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52545
* sys/power: Sleep type reporting by PM backendsAymeric Wibo2025-09-141-2/+4
| | | | | | | | | | | | | | Allow PM backends to report supported sleep types when registering through `power_pm_register`. Expose this information through `kern.power.supported_stype` sysctl, and set defaults for `power_standby/suspend/hibernate_stype` based on this. Implement this in ACPI PM backend. Reviewed by: mckusick (mentor), markj Approved by: mckusick (mentor), markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52044
* acpi: Use sleep types defined in sys/power.hAymeric Wibo2025-09-143-146/+241
| | | | | | | | | | | | | | | | This is as opposed to using ACPI sleep states (`ACPI_STATE_S*`). We now use `POWER_STYPE_*` added in D52036. This is in preparation for adding support for s2idle, which is not an ACPI sleep state, but needs to be handled specially by `acpi_EnterSleepState`. Supersedes D48732. Reviewed by: mckusick (mentor), markj Approved by: mckusick (mentor), markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52043
* sys/power: Generic sleep typesAymeric Wibo2025-09-142-26/+33
| | | | | | | | | | | | | | | | Pull out the sleep types (stype) from ACPI, as was previously being done in D48732, and pass this sleep type to `power_pm_fn` instead of passing the existing sleep state. This is a little awkward because we already kinda have generic sleep states (`POWER_SLEEP_STATE_*`), but these are not precise enough to build upon. This revision also adds generic equivalents to `hw.acpi.suspend_state` etc sysctls, e.g. `kern.power.suspend`. Reviewed by: markj, mckusick (mentor) Approved by: markj, mckusick (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52036
* acpi_powerres: `acpi_pwr_get_state` and getting initial D-state for deviceAymeric Wibo2025-08-182-5/+160
| | | | | | | | | | | | | | | | | | | | | Add `acpi_pwr_get_state` as a prerequisite to LPI (low-power idle) states. Since these states define minimum D-state constraints on other devices to be able to enter them, it will be necessary to use this function to check them before attempting to do so. Aside from that, this function is used to get the initial D-state of a power consumer when registering it (previously the `ac_state` value would be set to `ACPI_STATE_UNKNOWN`). It uses the `_PSC` method if available (older devices), or infers the D-state through the `_PRx` objects (cached in `ac_prx`) with `acpi_pwr_infer_state` if not. `acpi_pwr_switch_consumer` now uses this to verify that the D-state of a power consumer was switched correctly. Reviewed by: imp, markj, jrm (mentor) Approved by: markj, jrm (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48386
* acpi_powerres: Fix turning off power resources on first D-state switchAymeric Wibo2025-08-181-5/+105
| | | | | | | | | | | | | | | | | | | | | | The power resource dependencies for each `_PRx` object are discovered and cached in `ac_prx` on the power consumer struct (`struct acpi_powerconsumer`) when a power consumer is registered. This is done in `acpi_pwr_get_power_resources`. ACPI guarantees these `_PRx` objects will evaluate to the same thing each time they are called. This discovery process also registers those power resources, which were previously only registered when they were referenced by the relevant `_PRx` object for the target D-state when switching. This meant that the first D-state switch for a power consumer would not turn off any power resources as they wouldn't have been registered yet. This change fixes this. `ac_prx` will be used by subsequent patches. Reviewed by: markj, imp, jrm (mentor) Approved by: markj, jrm (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48385
* pci: Fix dependency on ACPICA for non-ACPI buildsAymeric Wibo2025-08-081-1/+2
| | | | | | | | | | | | | | | | Commit 84bbfc32a3f4 introduced a dependency on ACPICA for non-ACPI builds. This removes that unintended dependency. While here, print "D3hot" for D3hot in ACPI code instead of just "D3", as it was unclear whether that referred to D3hot or D3cold and was inconsistent with the `PCI_POWERSTATE_D3` and `ACPI_D_STATE_D3` defines. Reported by: jrtc27, freebsd@sysctl.cz Reviewed by: jrtc27, des, jrm (mentor) Approved by: jrtc27, jrm (mentor) Fixes: 84bbfc32a3f4 ("acpi_powerres: D3cold support") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51823
* acpi_powerres: D3cold supportAymeric Wibo2025-08-084-26/+62
| | | | | | | | | | | | | | | | | | | | | Cherry-pick commit 0b76c0a from ACPICA (actypes: Distinguish between D3hot/cold, and default `ACPI_STATE_D3` to D3cold). The same distinction is made between `PCI_POWERSTATE_D3_HOT` and `PCI_POWERSTATE_D3_COLD`, as they're defined by ACPI (and are asserted to be the same). D3cold is essentially the same as D3hot except the power resources are turned off. Add support for D3cold to `acpi_pwr_switch_consumer`. `acpi_d_state_to_str` replaces the `printf("D%d", d_state)` pattern, allowing for "D3hot" and "D3cold" strings to be printed instead of just "D3". Reviewed by: markj, ziaee, mckusick (mentor) Approved by: markj, mckusick (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48384
* newbus: replace leftover device unit wildcardsAhmad Khalifa2025-06-214-6/+6
| | | | | | Reviewed by: imp, jhb Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D50913
* pci: Ignore PCRx devices resourcesAndrew Turner2025-05-081-0/+15
| | | | | | | | | | Some systems provide two PCI root complex devices in the ACPI tables. Allow us to skip known pci-like devices even if they aren't detected as a PCI root complex. Reviewed by: cognet, jhb Co-authored-by: cognet Differential Revision: https://reviews.freebsd.org/D49709
* sys: Make the iommu xref uintptr_tAndrew Turner2025-04-081-3/+4
| | | | | | | | | | On arm64 we use the iommu base address as an xref. This fails when the address has the lower 32-bits in common with another iommu as they will share an xref. Reviewed by: kib Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D48726
* acpi_pci: Use pci_has_pm and pci_clear_pmeJohn Baldwin2025-03-271-8/+2
| | | | Differential Revision: https://reviews.freebsd.org/D49266
* acpi_pci: Add quirk for DELAY-after-EJ0Colin Percival2025-03-142-0/+5
| | | | | | | | | | | | | | | | | | | | | On some EC2 instances, there is a race between removing a device from the system and making the PCI bus stop reporting the presence of the device. As a result, a PCI BUS_RESCAN performed immediately after the _EJ0 method returns "sees" the device which is being ejected, which then causes problems later (e.g. we won't recognize a new device being plugged into that slot because we never knew it was vacant). On other operating systems the bus is synchronously marked as needing to be rescanned but the rescan does not occur until O(1) seconds later. Create a new ACPI_Q_DELAY_BEFORE_EJECT_RESCAN quirk and set it in EC2 AMIs, and add a 10 ms DELAY between _EJ0 and BUS_RESCAN when tht quirk is set. Reviewed by: jhb MFC after: 1 month Sponsored by: Amazon Differential Revision: https://reviews.freebsd.org/D49252
* acpi_pci: Add quirk for PSTAT_PME-before-detachColin Percival2025-03-052-0/+12
| | | | | | | | | | | | | | | | | | | | | In order to signal to Graviton [123] systems that a device is ready to be "ejected" (after a detach request is made via the EC2 API) we need to set PCIM_PSTAT_PME to 1 and PCIM_PSTAT_PMEENABLE to 0. We are not aware of any rationale for this requirement beyond "another OS kernel happens to do this", i.e. this is effectively bug-for-bug compatibility. Arguably this should be done by the ACPI _EJ0 method on these systems, but it is not. Create a new ACPI_Q_CLEAR_PME_ON_DETACH quirk and set it in EC2 AMIs, and add the PCI register write to acpi_pci_device_notify_handler when that quirk is set. Reviewed by: jhb MFC after: 1 month Sponsored by: Amazon Differential Revision: https://reviews.freebsd.org/D49146
* acpi: Mark the GED ithread as sleepableAndrew Turner2025-01-241-2/+3
| | | | | | | | | | | | | | | We need to complete calling the ACPI method before marking the interrupt as complete. If two threads are inspecting the ACPI tables at the same time they may both try to lock the ACPI mutex causing one to sleep. If this is the ithread it will panic the kernel as this is not allowed. Update the ged ithread to allow sleeping as it is expected this lock will be uncommon enough any sleep will be short. PR: 283103 Reviewed by: markj (earlier version) Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D48284
* acpi: Pass the correct device to acpi_pcib_oscAndrew Turner2025-01-031-1/+1
| | | | | | | | | | | Fix a copy-and-paste error in acpi_pcib_request_feature where the child device was passed into acpi_pcib_osc rather than the pcib device. Reviewed by: garga, jhb Fixes: ba1904937d9a ("acpica: Extract _OSC parsing to a common file") Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D48285
* acpica: Extract _OSC parsing to a common fileAndrew Turner2024-12-123-58/+62
| | | | | | | | | This will be used by pci_host_generic_acpi.c so needs to be in a common location. Reviewed by: imp, jhb Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D48044