summaryrefslogtreecommitdiffstats
path: root/sys/dev/acpi/acpi.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add acpi_iommu_device_map(), which replaces the DMA tag with one thatpatrick2021-03-151-1/+3
| | | | | | | | | is blessed with IOMMU magic, if available. This is mainly for arm64, since on amd64 and i386 the IOMMU only captures PCIe devices, as far as I know, which uses the pci_probe_device_hook(). This though is for non-PCI devices attached through ACPI. ok kettenis@
* Pass standard DMA tag to acpi(4) table drivers.patrick2021-03-071-1/+2
| | | | ok kettenis@
* acpi_map_address() cannot be wrapped by SMALL_KERNEL anymore, asderaadt2020-12-271-3/+3
| | | | it is used by acpihpet.c
* Refactor klist insertion and removalvisa2020-12-251-3/+3
| | | | | | | | | | | | Rename klist_{insert,remove}() to klist_{insert,remove}_locked(). These functions assume that the caller has locked the klist. The current state of locking remains intact because the kernel lock is still used with all klists. Add new functions klist_insert() and klist_remove() that lock the klist internally. This allows some code simplification. OK mpi@
* Fix some issues with referencing named ACPI nodes from Packages.kettenis2020-12-171-14/+28
| | | | | | | | | | | | | | | | | These references need to be resolved at runtime rather than when they're parsed such that they pick up the right values for those nodes which can be changed when for example _INI methods run. The current approach is to replace these reference with a string that names the node in question. The problem with that is that packages can also contain normal strings. Which means that we need special code that depends on the context where the package is used. This diff takes a different approach by retaining a reference when parsing. Code that uses a package will need to resolve this reference but there is no ambiguiety anymore. ok patrick@
* Add support for the _EVT method to the GPIO support code.kettenis2020-12-051-3/+12
| | | | ok patrick@
* Reorder the acpi attach process so we look at Processor() CPU nodesjmatthew2020-08-271-3/+5
| | | | | | | | | after Device() ones, since we should prefer the newer node type. If we see any Device() nodes, don't attach acpicpu(4) to any Processor() nodes if they're also present. This also makes acpitz(4) and acpipwrres(4) devices attach slightly later. ok kettenis@, also tested by jmc@
* Remove sc_maxgpe from acpi_softc which was never read fromgnezdo2020-08-161-7/+2
| | | | | | Remove a dead conditional from acpi_init_gpes while there. ok jcs@
* acpi can use IPL_BIO (a low interrupt) since it only enqueues operations forderaadt2020-07-211-13/+13
| | | | | | later processing. The use of a high interrupt will predate suspend/resume efforts, we had to redesign acpi to be non-reentrant obviously discussed with kettenis, in snaps for more than a week
* kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(9)cheloha2020-06-241-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | time_second(9) and time_uptime(9) are widely used in the kernel to quickly get the system UTC or system uptime as a time_t. However, time_t is 64-bit everywhere, so it is not generally safe to use them on 32-bit platforms: you have a split-read problem if your hardware cannot perform atomic 64-bit reads. This patch replaces time_second(9) with gettime(9), a safer successor interface, throughout the kernel. Similarly, time_uptime(9) is replaced with getuptime(9). There is a performance cost on 32-bit platforms in exchange for eliminating the split-read problem: instead of two register reads you now have a lockless read loop to pull the values from the timehands. This is really not *too* bad in the grand scheme of things, but compared to what we were doing before it is several times slower. There is no performance cost on 64-bit (__LP64__) platforms. With input from visa@, dlg@, and tedu@. Several bugs squashed by visa@. ok kettenis@
* Give userland a consistent battery and A/C state after resumejca2020-06-101-12/+3
| | | | | | | | | | | | | | | | | | | | | | | Previously we refreshed the state of acpiac(4) and acpibat(4)/acpisbs(4) by queueing fake ACPI events to be processed by the acpi thread. acpibat(4) using ACPIDEV_POLL meant that its status could be refreshed first, resulting in an APM_POWER_CHANGE event sent to userland before the state of acpiac(4) was up to date. Because of this, apmd(8) could see A/C unplugged when it was in fact plugged, possibly leading to a wrong decision. Instead of using fake ACPI events, refresh the status of acpiac(4) and acpibat(4)/acpisbs(4) right away at DVACT_WAKEUP time. To reuse the existing refresh code of those drivers, make their ACPI *_notify() handlers responsible for sending APM_POWER_CHANGE events instead. Also queue an APM_POWER_CHANGE event right after resume to retain existing behavior. This fixes the consistency of data shown to userland, and makes those drivers less special. Initially discussed last year (!) with mpi@ at Miod's place. Feedback and ok jcs@, deraadt@ agrees with the use of DVACT_WAKEUP here.
* dev/rndvar.h no longer has statistical interfaces (removed during variousderaadt2020-05-291-2/+1
| | | | | | conversion steps). it only contains kernel prototypes for 4 interfaces, all of which legitimately belong in sys/systm.h, which are already included by all enqueue_randomness() users.
* Bring back the acpi(4) changes. This time around only use the ACPI _CRSkettenis2020-05-141-1/+2
| | | | | | information on ACPI 5.0 and later. ok krw@, patrick@
* More accurate remaining power reporting with disparate batteriesjca2020-05-111-13/+11
| | | | | | | | | Overall remaining power was computed as the average of the remaining power of each battery, in percents. This doesn't work with batteries of different capacity, so use the total capacity and remaining power instead. Reported by lidstah, successful tests by lidstah and benno@, ok kettenis@
* Move parsing of _CRS into acpi(4) and pass the parsed address and interruptkettenis2020-05-081-1/+131
| | | | | | information in struct acpi_attach_args. ok mpi@
* Implement acpi_getprop(), the ACPI equivalent of OF_getprop().kettenis2020-04-141-2/+53
| | | | ok patrick@
* Add support for the _CCA method. This method indicates whether DMA iskettenis2020-04-121-2/+6
| | | | | | | | | cache-coherent or not. To implement this, acpi(4) gets two bus_dma tags and passes the appropriate one when attaching devices based on _CCA. On i386/amd64, where for all practical purpose DMA is always cache-coherent, the two tags are the same. But on arm64 they are distinct. ok patrick@
* Abstract the head of knote lists. This allows extending the lists,visa2020-04-071-3/+3
| | | | | | for example, with locking assertions. OK mpi@, anton@
* Fix incoherencies of errors returned by various *kqfilter routines.mpi2020-04-031-2/+2
| | | | | | | | EOPNOTSUPP is returned when there's no "filterops" for a given fd. EINVAL when the requested filter isn't supported by the "filterops". ENXIO means the underlying device is no longer valid/present. ok visa@
* Replace field f_isfd with field f_flags in struct filterops to allowvisa2020-02-201-2/+2
| | | | | | adding more filter properties without cluttering the struct. OK mpi@, anton@
* Use C99 designated initializers with struct filterops. In addition,visa2019-12-311-3/+6
| | | | | | make the structs const so that the data are put in .rodata. OK mpi@, deraadt@, anton@, bluhm@
* Convert infinite sleeps to {m,t}sleep_nsec(9).mpi2019-12-311-2/+2
| | | | ok kn@
* include sys/sensors.h for sensor usejsg2019-12-311-1/+2
| | | | don't depend on indirect inclusion from acpidev.h
* Revert acpipci(4) changes. Too many systems are broken. We'll try againkettenis2019-09-071-2/+1
| | | | after 6.6 as been released. The acpireg.h change stays behind.
* Use ACPI information to attach PCI busses like we do on arm64. There are akettenis2019-08-281-1/+2
| | | | | | | | | | | few additional quirks though, and attaching the PCI busses is delayed to replicate the existing code more closely. That may be changed in the future. Also tweak how we handle MSI support and respect to ACPI flag that says we shouldn't attempt to use MSIs. Some fallout is expected. ok patrick@
* On amd64 the bootup and resume paths for SP/BP/SP were not performingderaadt2019-08-271-4/+2
| | | | | | | msr/pat, clock-startup, firmware upgrade, fpu initialization, and cpu soft-state initialization in the same order. That kind of chaos is crazy and fragile. Improve the acpi resume call sequence and unify order of the operations.
* acpi_set_gpehandler: turn edge arg into flags, add support forjcs2019-07-021-26/+44
| | | | | | | | | | | passing GPE_DIRECT which directly executes the supplied callback and clears a level interrupt rather than going through acpi_taskq which can be slow when other driver callbacks are in the queue. This should not be used for GPE handlers that need to do anything ACPI-related. ok kettenis
* Print proper ACPI version number.kettenis2019-06-101-7/+9
| | | | ok mlarkin@
* When establishing the mapping between ACPI device nodes and PCI devices,kettenis2019-06-081-1/+6
| | | | | | skip PCI host bridges and devices that aren't there. ok patrick@
* Introduce acpi_getsta() and use it to eliminate some duplicated code.kettenis2019-06-071-23/+26
| | | | ok patrick@
* Make sure the extended PM register descriptions actually exist beforekettenis2019-05-121-9/+9
| | | | | | | using them. Fixes machines with ancient ACPI 1.0 (such as recent hypervisors). ok deraadt@
* Add support for mapping ACPI PM registers using the "extended" gasiokettenis2019-05-121-30/+71
| | | | | | representation from the FADT. Mostly fixes the Lanner NCA-1510. ok lteo@, mlarkin@, deraadt@
* Fix incorrect error message.lteo2019-05-111-2/+2
| | | | ok kettenis@
* free size. the allocation is the header plus the length.tedu2019-05-081-3/+3
|
* Avoid potential null-pointer dereference. Found by Kent R. Spillner.kettenis2019-04-041-3/+3
| | | | ok deraadt@, jsg@
* fix SMALL_KERNEL build after changes in rev 1.361jsg2019-01-201-1/+3
| | | | reported by naddy@ ok deraadt@
* Add a pwraction sysctl that controls what the power button does on acpi.tedu2019-01-191-2/+12
| | | | | | By default, nothing changes -- shutdown is initiated. But allows turning power button into a sleep button if desired. (grudging) ok from a few parties
* Add acpipci(4) on amd64. For now this only calls the PCI-specific _OSCkettenis2018-10-261-5/+1
| | | | method to let the ACPI implementation know what features we support.
* Move softbutton check before the check that skips attaching certain acpikettenis2018-08-301-5/+5
| | | | | | | devices. Fixes regression caused by matching on _CID in addition to matching on _HID. ok matthieu@, mlarkin@
* Match ACPI devices based on _CID if no match for _HID is found.kettenis2018-08-251-2/+9
| | | | ok mpi@
* Add support for multiple PCI segments. Only really implemented for arm64kettenis2018-08-191-11/+7
| | | | | | | for now as amd64/i386 firmware still caters for legacy OSes that only support a single PCI segment. ok patrick@
* Let ahci(4) match on _CLS instead of _HID when attaching at acpi(4). Avoidskettenis2018-08-031-4/+28
| | | | | | having to add many more _HID entries to the match table. ok deraadt@, mlarkin@
* Make legacy interrupts work in acpipci(4).kettenis2018-07-101-1/+16
| | | | ok patrick@
* Add acpipci(4), a driver that supports generic ECAM-compatible PCI hostkettenis2018-07-051-1/+5
| | | | | | bridges based on information provided by ACPI. ok mlarkin@
* Properly pass around the PCI "chipset tag" in acpi(4) and refactorkettenis2018-07-041-4/+4
| | | | | | | acpimcfg(4) to call an MD initialization functions that sets up a tag for PCI ECAM. ok guenther@, mlarkin@, krw@
* Move acpi(4) attach glue into acpi_machdep.c.kettenis2018-07-011-43/+1
| | | | ok guenther@, deraadt@
* Add support for _DSD Device Properties.kettenis2018-07-011-1/+45
| | | | ok mlarkin@
* Add intr_enable() function, intended for MI use to amd64 and i386 and usekettenis2018-06-301-5/+5
| | | | | | this in the acpi(4) suspend/resume code paths. ok deraadt@
* Use <stdint.h> types.kettenis2018-06-291-10/+10
| | | | ok mpi@, jung@, krw@, deraadt@
* ACPI: Allow (with warning) GPE handler reassignment, instead of returningmlarkin2018-06-291-6/+5
| | | | | | a failure code. ok kettenis