Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'acpi-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
"This one is significantly larger than previous ACPI support pull
requests because several significant updates have coincided in it.

First, there is a routine ACPICA code update, to upstream version
20251212, but this time it covers new ACPI 6.6 material that has not
been covered yet. Among other things, it includes definitions of a few
new ACPI tables and updates of some others, like the GICv5 MADT
structures and ARM IORT IWB node definitions that are used for adding
GICv5 ACPI probing on ARM (that technically is IRQ subsystem material,
but it depends on the ACPICA changes, so it is included here). The
latter alone adds a few hundred lines of new code.

Second, there is an update of ACPI _OSC handling including a fix that
prevents failures from occurring in some corner cases due to careless
handling of _OSC error bits.

On top of that, the "system resource" ACPI device objects with the
PNP0C01 and PNP0C02 are now going to be handled by the ACPI core
device enumeration code instead of handing them over to the legacy PNP
system driver which causes device enumeration issues to occur. Some of
those issues have been worked around in device drivers and elsewhere
and those workarounds should not be necessary any more, so they are
going away.

Moreover, the time has come to convert all "core ACPI" device drivers
that were still using struct acpi_driver objects for device binding
into proper platform drivers that use struct platform_driver for this
purpose. These updates are accompanied by some requisite core ACPI
device enumeration code changes.

Next, there are ACPI APEI updates, including changes to avoid excess
overhead in the NMI handler and in SEA on the ARM side, changes to
unify ACPI-based HW error tracing and logging, and changes to prevent
APEI code from reaching out of its allocated memory.

There are also some ACPI power management updates, mostly related to
the ACPI cpuidle support in the processor driver, suspend-to-idle
handling on systems with ACPI support and to ACPI PM of devices.

In addition to the above, bugs are fixed and the code is cleaned up in
assorted places all over.

Specifics:

- Update the ACPICA code in the kernel to upstream version 20251212
which includes the following changes:
* Add support for new ACPI table DTPR (Michal Camacho Romero)
* Release objects with acpi_ut_delete_object_desc() (Zilin Guan)
* Add UUIDs for Microsoft fan extensions and UUIDs associated with
TPM 2.0 devices (Armin Wolf)
* Fix NULL pointer dereference in acpi_ev_address_space_dispatch()
(Alexey Simakov)
* Add KEYP ACPI table definition (Dave Jiang)
* Add support for the Microsoft display mux _OSI string (Armin
Wolf)
* Add definitions for the IOVT ACPI table (Xianglai Li)
* Abort AML bytecode execution on AML_FATAL_OP (Armin Wolf)
* Include all fields in subtable type1 for PPTT (Ben Horgan)
* Add GICv5 MADT structures and Arm IORT IWB node definitions
(Jose Marinho)
* Update Parameter Block structure for RAS2 and add a new flag in
Memory Affinity Structure for SRAT (Pawel Chmielewski)
* Add _VDM (Voltage Domain) object (Pawel Chmielewski)

- Add support for GICv5 ACPI probing on ARM which is based on the
GICv5 MADT structures and ARM IORT IWB node definitions recently
added to ACPICA (Lorenzo Pieralisi)

- Rework ACPI PM notification setup for PCI root buses and modify the
ACPI PM setup for devices to register wakeup source objects under
physical (that is, PCI, platform, etc.) devices instead of doing
that under their ACPI companions (Rafael Wysocki)

- Adjust debug messages regarding postponed ACPI PM printed during
system resume to be more accurate (Rafael Wysocki)

- Remove dead code from lps0_device_attach() (Gergo Koteles)

- Start to invoke Microsoft Function 9 (Turn On Display) of the Low-
Power S0 Idle (LPS0) _DSM in the suspend-to-idle resume flow on
systems with ACPI LPS0 support to address a functional issue on
Lenovo Yoga Slim 7i Aura (15ILL9), where system fans and keyboard
backlights fail to resume after suspend (Jakob Riemenschneider)

- Add sysfs attribute cid for exposing _CID lists under ACPI device
objects (Rafael Wysocki)

- Replace sprintf() with sysfs_emit() in all of the core ACPI sysfs
interface code (Sumeet Pawnikar)

- Use acpi_get_local_u64_address() in the code implementing ACPI
support for PCI to evaluate _ADR instead of evaluating that object
directly (Andy Shevchenko)

- Add JWIPC JVC9100 to irq1_level_low_skip_override[] to unbreak
serial IRQs on that system (Ai Chao)

- Fix handling of _OSC errors in acpi_run_osc() to avoid failures on
systems where _OSC error bits are set even though the _OSC return
buffer contains acknowledged feature bits (Rafael Wysocki)

- Clean up and rearrange \_SB._OSC handling for general platform
features and USB4 features to avoid code duplication and
unnecessary memory management overhead (Rafael Wysocki)

- Make the ACPI core device enumeration code handle PNP0C01 and
PNP0C02 ("system resource") device objects directly instead of
letting the legacy PNP system driver handle them to avoid device
enumeration issues on systems where PNP0C02 is present in the _CID
list under ACPI device objects with a _HID matching a proper device
driver in Linux (Rafael Wysocki)

- Drop workarounds for the known device enumeration issues related to
_CID lists containing PNP0C02 (Rafael Wysocki)

- Drop outdated comment regarding removed function in the ACPI-based
device enumeration code (Julia Lawall)

- Make PRP0001 device matching work as expected for ACPI device
objects using it as a _HID for board development and similar
purposes (Kartik Rajput)

- Use async schedule function in acpi_scan_clear_dep_fn() to avoid
races with user space initialization on some systems (Yicong Yang)

- Add a piece of documentation explaining why binding drivers
directly to ACPI device objects is not a good idea in general and
why it is desirable to convert drivers doing so into proper
platform drivers that use struct platform_driver for device binding
(Rafael Wysocki)

- Convert multiple "core ACPI" drivers, including the NFIT ACPI
device driver, the generic ACPI button drivers, the generic ACPI
thermal zone driver, the ACPI hardware event device (HED) driver,
the ACPI EC driver, the ACPI SMBUS HC driver, the ACPI Smart
Battery Subsystem (SBS) driver, and the ACPI backlight (video)
driver to proper platform drivers that use struct platform_driver
for device binding (Rafael Wysocki)

- Use acpi_get_local_u64_address() in the ACPI backlight (video)
driver to evaluate _ADR instead of evaluating that object directly
(Andy Shevchenko)

- Convert the generic ACPI battery driver to a proper platform driver
using struct platform_driver for device binding (Rafael Wysocki)

- Fix incorrect charging status when current is zero in the generic
ACPI battery driver (Ata İlhan Köktürk)

- Use LIST_HEAD() for initializing a stack-allocated list in the
generic ACPI watchdog device driver (Can Peng)

- Rework the ACPI idle driver initialization to register it directly
from the common initialization code instead of doing that from a
CPU hotplug "online" callback and clean it up (Huisong Li, Rafael
Wysocki)

- Fix a possible NULL pointer dereference in
acpi_processor_errata_piix4() (Tuo Li)

- Make read-only array non_mmio_desc[] static const (Colin Ian King)

- Prevent the APEI GHES support code on ARM from accessing memory out
of bounds or going past the ARM processor CPER record buffer (Mauro
Carvalho Chehab)

- Prevent cper_print_fw_err() from dumping the entire memory on
systems with defective firmware (Mauro Carvalho Chehab)

- Improve ghes_notify_nmi() status check to avoid unnecessary
overhead in the NMI handler by carrying out all of the requisite
preparations and the NMI registration time (Tony Luck)

- Refactor the GHES driver by extracting common functionality into
reusable helper functions to reduce code duplication and improve
the ghes_notify_sea() status check in analogy with the previous
ghes_notify_nmi() status check improvement (Shuai Xue)

- Make ELOG and GHES log and trace consistently and support the CPER
CXL protocol analogously (Fabio De Francesco)

- Disable KASAN instrumentation in the APEI GHES driver when compile
testing with clang < 18 (Nathan Chancellor)

- Let ghes_edac be the preferred driver to load on __ZX__ and _BYO_
systems by extending the platform detection list in the APEI GHES
driver (Tony W Wang-oc)

- Clean up cppc_perf_caps and cppc_perf_ctrls structs and rename EPP
constants for clarity in the ACPI CPPC library (Sumit Gupta)"

* tag 'acpi-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (117 commits)
ACPI: battery: fix incorrect charging status when current is zero
ACPI: scan: Use async schedule function in acpi_scan_clear_dep_fn()
ACPI: x86: s2idle: Invoke Microsoft _DSM Function 9 (Turn On Display)
ACPI: APEI: GHES: Add ghes_edac support for __ZX__ and _BYO_ systems
ACPI: APEI: GHES: Disable KASAN instrumentation when compile testing with clang < 18
ACPI: sysfs: Replace sprintf() with sysfs_emit()
ACPI: CPPC: Rename EPP constants for clarity
ACPI: CPPC: Clean up cppc_perf_caps and cppc_perf_ctrls structs
ACPI: processor: idle: Rework the handling of acpi_processor_ffh_lpi_probe()
ACPI: processor: idle: Convert acpi_processor_setup_cpuidle_dev() to void
ACPI: processor: idle: Convert acpi_processor_setup_cpuidle_states() to void
irqchip/gic-v5: Add ACPI IWB probing
irqchip/gic-v5: Add ACPI ITS probing
irqchip/gic-v5: Add ACPI IRS probing
irqchip/gic-v5: Split IRS probing into OF and generic portions
PCI/MSI: Make the pci_msi_map_rid_ctlr_node() interface firmware agnostic
irqdomain: Add parent field to struct irqchip_fwid
ACPI: PCI: simplify code with acpi_get_local_u64_address()
ACPI: video: simplify code with acpi_get_local_u64_address()
ACPI: PM: Adjust messages regarding postponed ACPI PM
...

+2589 -1127
+80
Documentation/driver-api/acpi/acpi-drivers.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + .. include:: <isonum.txt> 3 + 4 + ========================================= 5 + Why using ACPI drivers is not a good idea 6 + ========================================= 7 + 8 + :Copyright: |copy| 2026, Intel Corporation 9 + 10 + :Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> 11 + 12 + Even though binding drivers directly to struct acpi_device objects, also 13 + referred to as "ACPI device nodes", allows basic functionality to be provided 14 + at least in some cases, there are problems with it, related to general 15 + consistency, sysfs layout, power management operation ordering, and code 16 + cleanliness. 17 + 18 + First of all, ACPI device nodes represent firmware entities rather than 19 + hardware and in many cases they provide auxiliary information on devices 20 + enumerated independently (like PCI devices or CPUs). It is therefore generally 21 + questionable to assign resources to them because the entities represented by 22 + them do not decode addresses in the memory or I/O address spaces and do not 23 + generate interrupts or similar (all of that is done by hardware). 24 + 25 + Second, as a general rule, a struct acpi_device can only be a parent of another 26 + struct acpi_device. If that is not the case, the location of the child device 27 + in the device hierarchy is at least confusing and it may not be straightforward 28 + to identify the piece of hardware providing functionality represented by it. 29 + However, binding a driver directly to an ACPI device node may cause that to 30 + happen if the given driver registers input devices or wakeup sources under it, 31 + for example. 32 + 33 + Next, using system suspend and resume callbacks directly on ACPI device nodes 34 + is also questionable because it may cause ordering problems to appear. Namely, 35 + ACPI device nodes are registered before enumerating hardware corresponding to 36 + them and they land on the PM list in front of the majority of other device 37 + objects. Consequently, the execution ordering of their PM callbacks may be 38 + different from what is generally expected. Also, in general, dependencies 39 + returned by _DEP objects do not affect ACPI device nodes themselves, but the 40 + "physical" devices associated with them, which potentially is one more source 41 + of inconsistency related to treating ACPI device nodes as "real" device 42 + representation. 43 + 44 + All of the above means that binding drivers to ACPI device nodes should 45 + generally be avoided and so struct acpi_driver objects should not be used. 46 + 47 + Moreover, a device ID is necessary to bind a driver directly to an ACPI device 48 + node, but device IDs are not generally associated with all of them. Some of 49 + them contain alternative information allowing the corresponding pieces of 50 + hardware to be identified, for example represeted by an _ADR object return 51 + value, and device IDs are not used in those cases. In consequence, confusingly 52 + enough, binding an ACPI driver to an ACPI device node may even be impossible. 53 + 54 + When that happens, the piece of hardware corresponding to the given ACPI device 55 + node is represented by another device object, like a struct pci_dev, and the 56 + ACPI device node is the "ACPI companion" of that device, accessible through its 57 + fwnode pointer used by the ACPI_COMPANION() macro. The ACPI companion holds 58 + additional information on the device configuration and possibly some "recipes" 59 + on device manipulation in the form of AML (ACPI Machine Language) bytecode 60 + provided by the platform firmware. Thus the role of the ACPI device node is 61 + similar to the role of a struct device_node on a system where Device Tree is 62 + used for platform description. 63 + 64 + For consistency, this approach has been extended to the cases in which ACPI 65 + device IDs are used. Namely, in those cases, an additional device object is 66 + created to represent the piece of hardware corresponding to a given ACPI device 67 + node. By default, it is a platform device, but it may also be a PNP device, a 68 + CPU device, or another type of device, depending on what the given piece of 69 + hardware actually is. There are even cases in which multiple devices are 70 + "backed" or "accompanied" by one ACPI device node (e.g. ACPI device nodes 71 + corresponding to GPUs that may provide firmware interfaces for backlight 72 + brightness control in addition to GPU configuration information). 73 + 74 + This means that it really should never be necessary to bind a driver directly to 75 + an ACPI device node because there is a "proper" device object representing the 76 + corresponding piece of hardware that can be bound to by a "proper" driver using 77 + the given ACPI device node as the device's ACPI companion. Thus, in principle, 78 + there is no reason to use ACPI drivers and if they all were replaced with other 79 + driver types (for example, platform drivers), some code could be dropped and 80 + some complexity would go away.
+1
Documentation/driver-api/acpi/index.rst
··· 7 7 8 8 linuxized-acpica 9 9 scan_handlers 10 + acpi-drivers
+2
drivers/acpi/Kconfig
··· 494 494 tristate "Extended Error Log support" 495 495 depends on X86_MCE && X86_LOCAL_APIC && EDAC 496 496 select UEFI_CPER 497 + select ACPI_APEI 498 + select ACPI_APEI_GHES 497 499 help 498 500 Certain usages such as Predictive Failure Analysis (PFA) require 499 501 more information about the error than what can be described in
+64
drivers/acpi/acpi_extlog.c
··· 12 12 #include <linux/ratelimit.h> 13 13 #include <linux/edac.h> 14 14 #include <linux/ras.h> 15 + #include <cxl/event.h> 15 16 #include <acpi/ghes.h> 16 17 #include <asm/cpu.h> 17 18 #include <asm/mce.h> ··· 133 132 return 1; 134 133 } 135 134 135 + static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, 136 + int severity) 137 + { 138 + #ifdef ACPI_APEI_PCIEAER 139 + struct aer_capability_regs *aer; 140 + struct pci_dev *pdev; 141 + unsigned int devfn; 142 + unsigned int bus; 143 + int aer_severity; 144 + int domain; 145 + 146 + if (!(pcie_err->validation_bits & CPER_PCIE_VALID_DEVICE_ID && 147 + pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO)) 148 + return; 149 + 150 + aer_severity = cper_severity_to_aer(severity); 151 + aer = (struct aer_capability_regs *)pcie_err->aer_info; 152 + domain = pcie_err->device_id.segment; 153 + bus = pcie_err->device_id.bus; 154 + devfn = PCI_DEVFN(pcie_err->device_id.device, 155 + pcie_err->device_id.function); 156 + pdev = pci_get_domain_bus_and_slot(domain, bus, devfn); 157 + if (!pdev) 158 + return; 159 + 160 + pci_print_aer(pdev, aer_severity, aer); 161 + pci_dev_put(pdev); 162 + #endif 163 + } 164 + 165 + static void 166 + extlog_cxl_cper_handle_prot_err(struct cxl_cper_sec_prot_err *prot_err, 167 + int severity) 168 + { 169 + #ifdef ACPI_APEI_PCIEAER 170 + struct cxl_cper_prot_err_work_data wd; 171 + 172 + if (cxl_cper_sec_prot_err_valid(prot_err)) 173 + return; 174 + 175 + if (cxl_cper_setup_prot_err_work_data(&wd, prot_err, severity)) 176 + return; 177 + 178 + cxl_cper_handle_prot_err(&wd); 179 + #endif 180 + } 181 + 136 182 static int extlog_print(struct notifier_block *nb, unsigned long val, 137 183 void *data) 138 184 { ··· 231 183 if (gdata->error_data_length >= sizeof(*mem)) 232 184 trace_extlog_mem_event(mem, err_seq, fru_id, fru_text, 233 185 (u8)gdata->error_severity); 186 + } else if (guid_equal(sec_type, &CPER_SEC_CXL_PROT_ERR)) { 187 + struct cxl_cper_sec_prot_err *prot_err = 188 + acpi_hest_get_payload(gdata); 189 + 190 + extlog_cxl_cper_handle_prot_err(prot_err, 191 + gdata->error_severity); 192 + } else if (guid_equal(sec_type, &CPER_SEC_PCIE)) { 193 + struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata); 194 + 195 + extlog_print_pcie(pcie_err, gdata->error_severity); 196 + } else { 197 + void *err = acpi_hest_get_payload(gdata); 198 + 199 + log_non_standard_event(sec_type, fru_id, fru_text, 200 + gdata->error_severity, err, 201 + gdata->error_data_length); 234 202 } 235 203 } 236 204
+23 -19
drivers/acpi/acpi_platform.c
··· 114 114 struct platform_device *pdev = NULL; 115 115 struct platform_device_info pdevinfo; 116 116 const struct acpi_device_id *match; 117 - struct resource_entry *rentry; 118 - struct list_head resource_list; 119 117 struct resource *resources = NULL; 120 - int count; 118 + int count = 0; 121 119 122 120 /* If the ACPI node already has a physical device attached, skip it. */ 123 - if (adev->physical_node_count) 121 + if (adev->physical_node_count && !adev->pnp.type.backlight) 124 122 return NULL; 125 123 126 124 match = acpi_match_acpi_device(forbidden_id_list, adev); ··· 135 137 } 136 138 } 137 139 138 - INIT_LIST_HEAD(&resource_list); 139 - count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); 140 - if (count < 0) 141 - return NULL; 142 - if (count > 0) { 143 - resources = kcalloc(count, sizeof(*resources), GFP_KERNEL); 144 - if (!resources) { 145 - acpi_dev_free_resource_list(&resource_list); 146 - return ERR_PTR(-ENOMEM); 147 - } 148 - count = 0; 149 - list_for_each_entry(rentry, &resource_list, node) 150 - acpi_platform_fill_resource(adev, rentry->res, 151 - &resources[count++]); 140 + if (adev->device_type == ACPI_BUS_TYPE_DEVICE && !adev->pnp.type.backlight) { 141 + LIST_HEAD(resource_list); 152 142 153 - acpi_dev_free_resource_list(&resource_list); 143 + count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); 144 + if (count < 0) 145 + return ERR_PTR(-ENODATA); 146 + 147 + if (count > 0) { 148 + struct resource_entry *rentry; 149 + 150 + resources = kcalloc(count, sizeof(*resources), GFP_KERNEL); 151 + if (!resources) { 152 + acpi_dev_free_resource_list(&resource_list); 153 + return ERR_PTR(-ENOMEM); 154 + } 155 + count = 0; 156 + list_for_each_entry(rentry, &resource_list, node) 157 + acpi_platform_fill_resource(adev, rentry->res, 158 + &resources[count++]); 159 + 160 + acpi_dev_free_resource_list(&resource_list); 161 + } 154 162 } 155 163 156 164 memset(&pdevinfo, 0, sizeof(pdevinfo));
+1 -18
drivers/acpi/acpi_pnp.c
··· 125 125 {"PNP0401"}, /* ECP Printer Port */ 126 126 /* apple-gmux */ 127 127 {"APP000B"}, 128 - /* system */ 129 - {"PNP0c02"}, /* General ID for reserving resources */ 130 - {"PNP0c01"}, /* memory controller */ 131 128 /* rtc_cmos */ 132 129 {"PNP0b00"}, 133 130 {"PNP0b01"}, ··· 343 346 return false; 344 347 } 345 348 346 - /* 347 - * If one of the device IDs below is present in the list of device IDs of a 348 - * given ACPI device object, the PNP scan handler will not attach to that 349 - * object, because there is a proper non-PNP driver in the kernel for the 350 - * device represented by it. 351 - */ 352 - static const struct acpi_device_id acpi_nonpnp_device_ids[] = { 353 - {"INT3F0D"}, 354 - {"INTC1080"}, 355 - {"INTC1081"}, 356 - {"INTC1099"}, 357 - {""}, 358 - }; 359 - 360 349 static int acpi_pnp_attach(struct acpi_device *adev, 361 350 const struct acpi_device_id *id) 362 351 { 363 - return !!acpi_match_device_ids(adev, acpi_nonpnp_device_ids); 352 + return true; 364 353 } 365 354 366 355 static struct acpi_scan_handler acpi_pnp_handler = {
+15 -13
drivers/acpi/acpi_processor.c
··· 50 50 { 51 51 u8 value1 = 0; 52 52 u8 value2 = 0; 53 + struct pci_dev *ide_dev = NULL, *isa_dev = NULL; 53 54 54 55 55 56 if (!dev) ··· 108 107 * each IDE controller's DMA status to make sure we catch all 109 108 * DMA activity. 110 109 */ 111 - dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 110 + ide_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 112 111 PCI_DEVICE_ID_INTEL_82371AB, 113 112 PCI_ANY_ID, PCI_ANY_ID, NULL); 114 - if (dev) { 115 - errata.piix4.bmisx = pci_resource_start(dev, 4); 116 - pci_dev_put(dev); 113 + if (ide_dev) { 114 + errata.piix4.bmisx = pci_resource_start(ide_dev, 4); 115 + pci_dev_put(ide_dev); 117 116 } 118 117 119 118 /* ··· 125 124 * disable C3 support if this is enabled, as some legacy 126 125 * devices won't operate well if fast DMA is disabled. 127 126 */ 128 - dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 127 + isa_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 129 128 PCI_DEVICE_ID_INTEL_82371AB_0, 130 129 PCI_ANY_ID, PCI_ANY_ID, NULL); 131 - if (dev) { 132 - pci_read_config_byte(dev, 0x76, &value1); 133 - pci_read_config_byte(dev, 0x77, &value2); 130 + if (isa_dev) { 131 + pci_read_config_byte(isa_dev, 0x76, &value1); 132 + pci_read_config_byte(isa_dev, 0x77, &value2); 134 133 if ((value1 & 0x80) || (value2 & 0x80)) 135 134 errata.piix4.fdma = 1; 136 - pci_dev_put(dev); 135 + pci_dev_put(isa_dev); 137 136 } 138 137 139 138 break; 140 139 } 141 140 142 - if (errata.piix4.bmisx) 143 - dev_dbg(&dev->dev, "Bus master activity detection (BM-IDE) erratum enabled\n"); 144 - if (errata.piix4.fdma) 145 - dev_dbg(&dev->dev, "Type-F DMA livelock erratum (C3 disabled)\n"); 141 + if (ide_dev) 142 + dev_dbg(&ide_dev->dev, "Bus master activity detection (BM-IDE) erratum enabled\n"); 143 + 144 + if (isa_dev) 145 + dev_dbg(&isa_dev->dev, "Type-F DMA livelock erratum (C3 disabled)\n"); 146 146 147 147 return 0; 148 148 }
+28 -34
drivers/acpi/acpi_video.c
··· 21 21 #include <linux/sort.h> 22 22 #include <linux/pci.h> 23 23 #include <linux/pci_ids.h> 24 + #include <linux/platform_device.h> 24 25 #include <linux/slab.h> 25 26 #include <linux/dmi.h> 26 27 #include <linux/suspend.h> ··· 77 76 static DEFINE_MUTEX(register_count_mutex); 78 77 static DEFINE_MUTEX(video_list_lock); 79 78 static LIST_HEAD(video_bus_head); 80 - static int acpi_video_bus_add(struct acpi_device *device); 81 - static void acpi_video_bus_remove(struct acpi_device *device); 79 + static int acpi_video_bus_probe(struct platform_device *pdev); 80 + static void acpi_video_bus_remove(struct platform_device *pdev); 82 81 static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data); 83 82 84 83 /* ··· 99 98 }; 100 99 MODULE_DEVICE_TABLE(acpi, video_device_ids); 101 100 102 - static struct acpi_driver acpi_video_bus = { 103 - .name = "video", 104 - .class = ACPI_VIDEO_CLASS, 105 - .ids = video_device_ids, 106 - .ops = { 107 - .add = acpi_video_bus_add, 108 - .remove = acpi_video_bus_remove, 109 - }, 101 + static struct platform_driver acpi_video_bus = { 102 + .probe = acpi_video_bus_probe, 103 + .remove = acpi_video_bus_remove, 104 + .driver = { 105 + .name = "acpi-video", 106 + .acpi_match_table = video_device_ids, 107 + }, 110 108 }; 111 109 112 110 struct acpi_video_bus_flags { ··· 1134 1134 struct acpi_video_bus *video = arg; 1135 1135 struct acpi_video_device_attrib *attribute; 1136 1136 struct acpi_video_device *data; 1137 - unsigned long long device_id; 1138 - acpi_status status; 1139 1137 int device_type; 1138 + u64 device_id; 1140 1139 1141 - status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); 1142 1140 /* Skip devices without _ADR instead of failing. */ 1143 - if (ACPI_FAILURE(status)) 1141 + if (acpi_get_local_u64_address(device->handle, &device_id)) 1144 1142 goto exit; 1145 1143 1146 1144 data = kzalloc(sizeof(struct acpi_video_device), GFP_KERNEL); ··· 1538 1540 1539 1541 static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) 1540 1542 { 1541 - struct acpi_device *device = data; 1542 - struct acpi_video_bus *video = acpi_driver_data(device); 1543 + struct acpi_video_bus *video = data; 1544 + struct acpi_device *device = video->device; 1543 1545 struct input_dev *input; 1544 1546 int keycode = 0; 1545 - 1546 - if (!video || !video->input) 1547 - return; 1548 1547 1549 1548 input = video->input; 1550 1549 ··· 1886 1891 device->flags.notify = 1; 1887 1892 } 1888 1893 1889 - static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video) 1894 + static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video, 1895 + struct platform_device *pdev) 1890 1896 { 1891 1897 struct input_dev *input; 1892 1898 struct acpi_video_device *dev; ··· 1910 1914 input->phys = video->phys; 1911 1915 input->id.bustype = BUS_HOST; 1912 1916 input->id.product = 0x06; 1913 - input->dev.parent = &video->device->dev; 1917 + input->dev.parent = &pdev->dev; 1914 1918 input->evbit[0] = BIT(EV_KEY); 1915 1919 set_bit(KEY_SWITCHVIDEOMODE, input->keybit); 1916 1920 set_bit(KEY_VIDEO_NEXT, input->keybit); ··· 1982 1986 1983 1987 static int instance; 1984 1988 1985 - static int acpi_video_bus_add(struct acpi_device *device) 1989 + static int acpi_video_bus_probe(struct platform_device *pdev) 1986 1990 { 1991 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1987 1992 struct acpi_video_bus *video; 1988 1993 bool auto_detect; 1989 1994 int error; ··· 2020 2023 device->pnp.bus_id[3] = '0' + instance; 2021 2024 instance++; 2022 2025 } 2026 + 2027 + platform_set_drvdata(pdev, video); 2023 2028 2024 2029 video->device = device; 2025 2030 strscpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); ··· 2070 2071 !auto_detect) 2071 2072 acpi_video_bus_register_backlight(video); 2072 2073 2073 - error = acpi_video_bus_add_notify_handler(video); 2074 + error = acpi_video_bus_add_notify_handler(video, pdev); 2074 2075 if (error) 2075 2076 goto err_del; 2076 2077 2077 2078 error = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, 2078 - acpi_video_bus_notify, device); 2079 + acpi_video_bus_notify, video); 2079 2080 if (error) 2080 2081 goto err_remove; 2081 2082 ··· 2098 2099 return error; 2099 2100 } 2100 2101 2101 - static void acpi_video_bus_remove(struct acpi_device *device) 2102 + static void acpi_video_bus_remove(struct platform_device *pdev) 2102 2103 { 2103 - struct acpi_video_bus *video = NULL; 2104 - 2105 - 2106 - if (!device || !acpi_driver_data(device)) 2107 - return; 2108 - 2109 - video = acpi_driver_data(device); 2104 + struct acpi_video_bus *video = platform_get_drvdata(pdev); 2105 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 2110 2106 2111 2107 acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, 2112 2108 acpi_video_bus_notify); ··· 2164 2170 2165 2171 dmi_check_system(video_dmi_table); 2166 2172 2167 - ret = acpi_bus_register_driver(&acpi_video_bus); 2173 + ret = platform_driver_register(&acpi_video_bus); 2168 2174 if (ret) 2169 2175 goto leave; 2170 2176 ··· 2184 2190 { 2185 2191 mutex_lock(&register_count_mutex); 2186 2192 if (register_count) { 2187 - acpi_bus_unregister_driver(&acpi_video_bus); 2193 + platform_driver_unregister(&acpi_video_bus); 2188 2194 register_count = 0; 2189 2195 may_report_brightness_keys = false; 2190 2196 }
+1 -3
drivers/acpi/acpi_watchdog.c
··· 103 103 { 104 104 const struct acpi_wdat_entry *entries; 105 105 const struct acpi_table_wdat *wdat; 106 - struct list_head resource_list; 106 + LIST_HEAD(resource_list); 107 107 struct resource_entry *rentry; 108 108 struct platform_device *pdev; 109 109 struct resource *resources; ··· 124 124 if (wdat->pci_segment != 0xff || wdat->pci_bus != 0xff || 125 125 wdat->pci_device != 0xff || wdat->pci_function != 0xff) 126 126 goto fail_put_wdat; 127 - 128 - INIT_LIST_HEAD(&resource_list); 129 127 130 128 entries = (struct acpi_wdat_entry *)(wdat + 1); 131 129 for (i = 0; i < wdat->entries; i++) {
+3
drivers/acpi/acpica/acpredef.h
··· 587 587 METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (var Ints) */ 588 588 PACKAGE_INFO(ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5, 0, 0, 0), 589 589 590 + {{"_VDM", METHOD_0ARGS, 591 + METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, 592 + 590 593 {{"_HRV", METHOD_0ARGS, 591 594 METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, 592 595
+3 -1
drivers/acpi/acpica/evregion.c
··· 163 163 return_ACPI_STATUS(AE_NOT_EXIST); 164 164 } 165 165 166 - if (region_obj->region.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) { 166 + if (field_obj 167 + && region_obj->region.space_id == 168 + ACPI_ADR_SPACE_PLATFORM_COMM) { 167 169 struct acpi_pcc_info *ctx = 168 170 handler_desc->address_space.context; 169 171
+24 -27
drivers/acpi/acpica/exoparg3.c
··· 10 10 #include <acpi/acpi.h> 11 11 #include "accommon.h" 12 12 #include "acinterp.h" 13 + #include <acpi/acoutput.h> 13 14 #include "acparser.h" 14 15 #include "amlcode.h" 15 16 ··· 52 51 acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state) 53 52 { 54 53 union acpi_operand_object **operand = &walk_state->operands[0]; 55 - struct acpi_signal_fatal_info *fatal; 56 - acpi_status status = AE_OK; 54 + struct acpi_signal_fatal_info fatal; 57 55 58 56 ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_0T_0R, 59 57 acpi_ps_get_opcode_name(walk_state->opcode)); ··· 60 60 switch (walk_state->opcode) { 61 61 case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */ 62 62 63 - ACPI_DEBUG_PRINT((ACPI_DB_INFO, 64 - "FatalOp: Type %X Code %X Arg %X " 65 - "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", 66 - (u32)operand[0]->integer.value, 67 - (u32)operand[1]->integer.value, 68 - (u32)operand[2]->integer.value)); 63 + fatal.type = (u32)operand[0]->integer.value; 64 + fatal.code = (u32)operand[1]->integer.value; 65 + fatal.argument = (u32)operand[2]->integer.value; 69 66 70 - fatal = ACPI_ALLOCATE(sizeof(struct acpi_signal_fatal_info)); 71 - if (fatal) { 72 - fatal->type = (u32) operand[0]->integer.value; 73 - fatal->code = (u32) operand[1]->integer.value; 74 - fatal->argument = (u32) operand[2]->integer.value; 75 - } 67 + ACPI_BIOS_ERROR((AE_INFO, 68 + "Fatal ACPI BIOS error (Type 0x%X Code 0x%X Arg 0x%X)\n", 69 + fatal.type, fatal.code, fatal.argument)); 76 70 77 71 /* Always signal the OS! */ 78 72 79 - status = acpi_os_signal(ACPI_SIGNAL_FATAL, fatal); 73 + acpi_os_signal(ACPI_SIGNAL_FATAL, &fatal); 80 74 81 - /* Might return while OS is shutting down, just continue */ 82 - 83 - ACPI_FREE(fatal); 84 - goto cleanup; 75 + #ifndef ACPI_CONTINUE_ON_FATAL 76 + /* 77 + * Might return while OS is shutting down, so abort the AML execution 78 + * by returning an error. 79 + */ 80 + return_ACPI_STATUS(AE_ERROR); 81 + #else 82 + /* 83 + * The alstests require that the Fatal() opcode does not return an error. 84 + */ 85 + return_ACPI_STATUS(AE_OK); 86 + #endif 85 87 86 88 case AML_EXTERNAL_OP: 87 89 /* ··· 95 93 * wrong if an external opcode ever gets here. 96 94 */ 97 95 ACPI_ERROR((AE_INFO, "Executed External Op")); 98 - status = AE_OK; 99 - goto cleanup; 96 + 97 + return_ACPI_STATUS(AE_OK); 100 98 101 99 default: 102 100 103 101 ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X", 104 102 walk_state->opcode)); 105 103 106 - status = AE_AML_BAD_OPCODE; 107 - goto cleanup; 104 + return_ACPI_STATUS(AE_AML_BAD_OPCODE); 108 105 } 109 - 110 - cleanup: 111 - 112 - return_ACPI_STATUS(status); 113 106 } 114 107 115 108 /*******************************************************************************
+1 -1
drivers/acpi/acpica/nsxfname.c
··· 601 601 error_exit: 602 602 603 603 ACPI_FREE(aml_buffer); 604 - ACPI_FREE(method_obj); 604 + acpi_ut_delete_object_desc(method_obj); 605 605 return (status); 606 606 } 607 607 ACPI_EXPORT_SYMBOL(acpi_install_method)
+1 -1
drivers/acpi/acpica/utobject.c
··· 148 148 package_elements = ACPI_ALLOCATE_ZEROED(((acpi_size)count + 149 149 1) * sizeof(void *)); 150 150 if (!package_elements) { 151 - ACPI_FREE(package_desc); 151 + acpi_ut_delete_object_desc(package_desc); 152 152 return_PTR(NULL); 153 153 } 154 154
+5 -1
drivers/acpi/acpica/utosi.c
··· 92 92 {"Processor Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, 93 93 {"3.0 Thermal Model", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, 94 94 {"3.0 _SCP Extensions", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, 95 - {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0} 95 + {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, 96 + 97 + /* See https://learn.microsoft.com/en-us/windows-hardware/drivers/display/automatic-display-switch */ 98 + 99 + {"DisplayMux", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0} 96 100 }; 97 101 98 102 /*******************************************************************************
+5
drivers/acpi/apei/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 obj-$(CONFIG_ACPI_APEI) += apei.o 3 3 obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o 4 + # clang versions prior to 18 may blow out the stack with KASAN 5 + ifeq ($(CONFIG_COMPILE_TEST)_$(CONFIG_CC_IS_CLANG)_$(call clang-min-version, 180000),y_y_) 6 + KASAN_SANITIZE_ghes.o := n 7 + endif 8 + obj-$(CONFIG_ACPI_APEI_PCIEAER) += ghes_helpers.o 4 9 obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o 5 10 einj-y := einj-core.o 6 11 einj-$(CONFIG_ACPI_APEI_EINJ_CXL) += einj-cxl.o
+1 -1
drivers/acpi/apei/einj-core.c
··· 679 679 * region intersects with known resource. So do an allow list check for 680 680 * IORES_DESCs that definitely or most likely not MMIO. 681 681 */ 682 - int non_mmio_desc[] = { 682 + static const int non_mmio_desc[] = { 683 683 IORES_DESC_CRASH_KERNEL, 684 684 IORES_DESC_ACPI_TABLES, 685 685 IORES_DESC_ACPI_NV_STORAGE,
+138 -49
drivers/acpi/apei/ghes.c
··· 29 29 #include <linux/cper.h> 30 30 #include <linux/cleanup.h> 31 31 #include <linux/platform_device.h> 32 + #include <linux/minmax.h> 32 33 #include <linux/mutex.h> 33 34 #include <linux/ratelimit.h> 34 35 #include <linux/vmalloc.h> ··· 295 294 error_block_length = GHES_ESTATUS_MAX_SIZE; 296 295 } 297 296 ghes->estatus = kmalloc(error_block_length, GFP_KERNEL); 297 + ghes->estatus_length = error_block_length; 298 298 if (!ghes->estatus) { 299 299 rc = -ENOMEM; 300 300 goto err_unmap_status_addr; ··· 367 365 struct acpi_hest_generic_status *estatus) 368 366 { 369 367 u32 len = cper_estatus_len(estatus); 368 + u32 max_len = min(ghes->generic->error_block_length, 369 + ghes->estatus_length); 370 370 371 371 if (len < sizeof(*estatus)) { 372 372 pr_warn_ratelimited(FW_WARN GHES_PFX "Truncated error status block!\n"); 373 373 return -EIO; 374 374 } 375 375 376 - if (len > ghes->generic->error_block_length) { 376 + if (!len || len > max_len) { 377 377 pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid error status block length!\n"); 378 378 return -EIO; 379 379 } ··· 556 552 { 557 553 struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata); 558 554 int flags = sync ? MF_ACTION_REQUIRED : 0; 555 + int length = gdata->error_data_length; 559 556 char error_type[120]; 560 557 bool queued = false; 561 558 int sec_sev, i; 562 559 char *p; 563 560 564 561 sec_sev = ghes_severity(gdata->error_severity); 565 - log_arm_hw_error(err, sec_sev); 562 + if (length >= sizeof(*err)) { 563 + log_arm_hw_error(err, sec_sev); 564 + } else { 565 + pr_warn(FW_BUG "arm error length: %d\n", length); 566 + pr_warn(FW_BUG "length is too small\n"); 567 + pr_warn(FW_BUG "firmware-generated error record is incorrect\n"); 568 + return false; 569 + } 570 + 566 571 if (sev != GHES_SEV_RECOVERABLE || sec_sev != GHES_SEV_RECOVERABLE) 567 572 return false; 568 573 569 574 p = (char *)(err + 1); 575 + length -= sizeof(err); 576 + 570 577 for (i = 0; i < err->err_info_num; i++) { 571 - struct cper_arm_err_info *err_info = (struct cper_arm_err_info *)p; 572 - bool is_cache = err_info->type & CPER_ARM_CACHE_ERROR; 573 - bool has_pa = (err_info->validation_bits & CPER_ARM_INFO_VALID_PHYSICAL_ADDR); 578 + struct cper_arm_err_info *err_info; 579 + bool is_cache, has_pa; 580 + 581 + /* Ensure we have enough data for the error info header */ 582 + if (length < sizeof(*err_info)) 583 + break; 584 + 585 + err_info = (struct cper_arm_err_info *)p; 586 + 587 + /* Validate the claimed length before using it */ 588 + length -= err_info->length; 589 + if (length < 0) 590 + break; 591 + 592 + is_cache = err_info->type & CPER_ARM_CACHE_ERROR; 593 + has_pa = (err_info->validation_bits & CPER_ARM_INFO_VALID_PHYSICAL_ADDR); 574 594 575 595 /* 576 596 * The field (err_info->error_info & BIT(26)) is fixed to set to ··· 739 711 { 740 712 #ifdef CONFIG_ACPI_APEI_PCIEAER 741 713 struct cxl_cper_prot_err_work_data wd; 742 - u8 *dvsec_start, *cap_start; 743 714 744 - if (!(prot_err->valid_bits & PROT_ERR_VALID_AGENT_ADDRESS)) { 745 - pr_err_ratelimited("CXL CPER invalid agent type\n"); 715 + if (cxl_cper_sec_prot_err_valid(prot_err)) 746 716 return; 747 - } 748 - 749 - if (!(prot_err->valid_bits & PROT_ERR_VALID_ERROR_LOG)) { 750 - pr_err_ratelimited("CXL CPER invalid protocol error log\n"); 751 - return; 752 - } 753 - 754 - if (prot_err->err_len != sizeof(struct cxl_ras_capability_regs)) { 755 - pr_err_ratelimited("CXL CPER invalid RAS Cap size (%u)\n", 756 - prot_err->err_len); 757 - return; 758 - } 759 - 760 - if (!(prot_err->valid_bits & PROT_ERR_VALID_SERIAL_NUMBER)) 761 - pr_warn(FW_WARN "CXL CPER no device serial number\n"); 762 717 763 718 guard(spinlock_irqsave)(&cxl_cper_prot_err_work_lock); 764 719 765 720 if (!cxl_cper_prot_err_work) 766 721 return; 767 722 768 - switch (prot_err->agent_type) { 769 - case RCD: 770 - case DEVICE: 771 - case LD: 772 - case FMLD: 773 - case RP: 774 - case DSP: 775 - case USP: 776 - memcpy(&wd.prot_err, prot_err, sizeof(wd.prot_err)); 777 - 778 - dvsec_start = (u8 *)(prot_err + 1); 779 - cap_start = dvsec_start + prot_err->dvsec_len; 780 - 781 - memcpy(&wd.ras_cap, cap_start, sizeof(wd.ras_cap)); 782 - wd.severity = cper_severity_to_aer(severity); 783 - break; 784 - default: 785 - pr_err_ratelimited("CXL CPER invalid agent type: %d\n", 786 - prot_err->agent_type); 723 + if (cxl_cper_setup_prot_err_work_data(&wd, prot_err, severity)) 787 724 return; 788 - } 789 725 790 726 if (!kfifo_put(&cxl_cper_prot_err_fifo, wd)) { 791 727 pr_err_ratelimited("CXL CPER kfifo overflow\n"); ··· 1398 1406 return ret; 1399 1407 } 1400 1408 1409 + /** 1410 + * ghes_has_active_errors - Check if there are active errors in error sources 1411 + * @ghes_list: List of GHES entries to check for active errors 1412 + * 1413 + * This function iterates through all GHES entries in the given list and 1414 + * checks if any of them has active error status by reading the error 1415 + * status register. 1416 + * 1417 + * Return: true if at least one source has active error, false otherwise. 1418 + */ 1419 + static bool __maybe_unused ghes_has_active_errors(struct list_head *ghes_list) 1420 + { 1421 + struct ghes *ghes; 1422 + 1423 + guard(rcu)(); 1424 + list_for_each_entry_rcu(ghes, ghes_list, list) { 1425 + if (ghes->error_status_vaddr && 1426 + readl(ghes->error_status_vaddr)) 1427 + return true; 1428 + } 1429 + 1430 + return false; 1431 + } 1432 + 1433 + /** 1434 + * ghes_map_error_status - Map error status address to virtual address 1435 + * @ghes: pointer to GHES structure 1436 + * 1437 + * Reads the error status address from ACPI HEST table and maps it to a virtual 1438 + * address that can be accessed by the kernel. 1439 + * 1440 + * Return: 0 on success, error code on failure. 1441 + */ 1442 + static int __maybe_unused ghes_map_error_status(struct ghes *ghes) 1443 + { 1444 + struct acpi_hest_generic *g = ghes->generic; 1445 + u64 paddr; 1446 + int rc; 1447 + 1448 + rc = apei_read(&paddr, &g->error_status_address); 1449 + if (rc) 1450 + return rc; 1451 + 1452 + ghes->error_status_vaddr = 1453 + acpi_os_ioremap(paddr, sizeof(ghes->estatus->block_status)); 1454 + if (!ghes->error_status_vaddr) 1455 + return -EINVAL; 1456 + 1457 + return 0; 1458 + } 1459 + 1460 + /** 1461 + * ghes_unmap_error_status - Unmap error status virtual address 1462 + * @ghes: pointer to GHES structure 1463 + * 1464 + * Unmaps the error status address if it was previously mapped. 1465 + */ 1466 + static void __maybe_unused ghes_unmap_error_status(struct ghes *ghes) 1467 + { 1468 + if (ghes->error_status_vaddr) { 1469 + iounmap(ghes->error_status_vaddr); 1470 + ghes->error_status_vaddr = NULL; 1471 + } 1472 + } 1473 + 1401 1474 #ifdef CONFIG_ACPI_APEI_SEA 1402 1475 static LIST_HEAD(ghes_sea); 1403 1476 ··· 1475 1418 static DEFINE_RAW_SPINLOCK(ghes_notify_lock_sea); 1476 1419 int rv; 1477 1420 1421 + if (!ghes_has_active_errors(&ghes_sea)) 1422 + return -ENOENT; 1423 + 1478 1424 raw_spin_lock(&ghes_notify_lock_sea); 1479 1425 rv = ghes_in_nmi_spool_from_list(&ghes_sea, FIX_APEI_GHES_SEA); 1480 1426 raw_spin_unlock(&ghes_notify_lock_sea); ··· 1485 1425 return rv; 1486 1426 } 1487 1427 1488 - static void ghes_sea_add(struct ghes *ghes) 1428 + static int ghes_sea_add(struct ghes *ghes) 1489 1429 { 1430 + int rc; 1431 + 1432 + rc = ghes_map_error_status(ghes); 1433 + if (rc) 1434 + return rc; 1435 + 1490 1436 mutex_lock(&ghes_list_mutex); 1491 1437 list_add_rcu(&ghes->list, &ghes_sea); 1492 1438 mutex_unlock(&ghes_list_mutex); 1439 + 1440 + return 0; 1493 1441 } 1494 1442 1495 1443 static void ghes_sea_remove(struct ghes *ghes) ··· 1505 1437 mutex_lock(&ghes_list_mutex); 1506 1438 list_del_rcu(&ghes->list); 1507 1439 mutex_unlock(&ghes_list_mutex); 1440 + ghes_unmap_error_status(ghes); 1508 1441 synchronize_rcu(); 1509 1442 } 1510 1443 #else /* CONFIG_ACPI_APEI_SEA */ 1511 - static inline void ghes_sea_add(struct ghes *ghes) { } 1444 + static inline int ghes_sea_add(struct ghes *ghes) { return -EINVAL; } 1512 1445 static inline void ghes_sea_remove(struct ghes *ghes) { } 1513 1446 #endif /* CONFIG_ACPI_APEI_SEA */ 1514 1447 ··· 1527 1458 static DEFINE_RAW_SPINLOCK(ghes_notify_lock_nmi); 1528 1459 int ret = NMI_DONE; 1529 1460 1461 + if (!ghes_has_active_errors(&ghes_nmi)) 1462 + return ret; 1463 + 1530 1464 if (!atomic_add_unless(&ghes_in_nmi, 1, 1)) 1531 1465 return ret; 1532 1466 ··· 1542 1470 return ret; 1543 1471 } 1544 1472 1545 - static void ghes_nmi_add(struct ghes *ghes) 1473 + static int ghes_nmi_add(struct ghes *ghes) 1546 1474 { 1475 + int rc; 1476 + 1477 + rc = ghes_map_error_status(ghes); 1478 + if (rc) 1479 + return rc; 1480 + 1547 1481 mutex_lock(&ghes_list_mutex); 1548 1482 if (list_empty(&ghes_nmi)) 1549 1483 register_nmi_handler(NMI_LOCAL, ghes_notify_nmi, 0, "ghes"); 1550 1484 list_add_rcu(&ghes->list, &ghes_nmi); 1551 1485 mutex_unlock(&ghes_list_mutex); 1486 + 1487 + return 0; 1552 1488 } 1553 1489 1554 1490 static void ghes_nmi_remove(struct ghes *ghes) ··· 1566 1486 if (list_empty(&ghes_nmi)) 1567 1487 unregister_nmi_handler(NMI_LOCAL, "ghes"); 1568 1488 mutex_unlock(&ghes_list_mutex); 1489 + 1490 + ghes_unmap_error_status(ghes); 1491 + 1569 1492 /* 1570 1493 * To synchronize with NMI handler, ghes can only be 1571 1494 * freed after NMI handler finishes. ··· 1576 1493 synchronize_rcu(); 1577 1494 } 1578 1495 #else /* CONFIG_HAVE_ACPI_APEI_NMI */ 1579 - static inline void ghes_nmi_add(struct ghes *ghes) { } 1496 + static inline int ghes_nmi_add(struct ghes *ghes) { return -EINVAL; } 1580 1497 static inline void ghes_nmi_remove(struct ghes *ghes) { } 1581 1498 #endif /* CONFIG_HAVE_ACPI_APEI_NMI */ 1582 1499 ··· 1741 1658 break; 1742 1659 1743 1660 case ACPI_HEST_NOTIFY_SEA: 1744 - ghes_sea_add(ghes); 1661 + rc = ghes_sea_add(ghes); 1662 + if (rc) 1663 + goto err; 1745 1664 break; 1746 1665 case ACPI_HEST_NOTIFY_NMI: 1747 - ghes_nmi_add(ghes); 1666 + rc = ghes_nmi_add(ghes); 1667 + if (rc) 1668 + goto err; 1748 1669 break; 1749 1670 case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED: 1750 1671 rc = apei_sdei_register_ghes(ghes); ··· 1897 1810 */ 1898 1811 static struct acpi_platform_list plat_list[] = { 1899 1812 {"HPE ", "Server ", 0, ACPI_SIG_FADT, all_versions}, 1813 + {"__ZX__", "EDK2 ", 3, ACPI_SIG_FADT, greater_than_or_equal}, 1814 + {"_BYO_ ", "BYOSOFT ", 3, ACPI_SIG_FADT, greater_than_or_equal}, 1900 1815 { } /* End */ 1901 1816 }; 1902 1817
+66
drivers/acpi/apei/ghes_helpers.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + // Copyright(c) 2025 Intel Corporation. All rights reserved 3 + 4 + #include <linux/printk.h> 5 + #include <linux/aer.h> 6 + #include <cxl/event.h> 7 + 8 + int cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err) 9 + { 10 + if (!(prot_err->valid_bits & PROT_ERR_VALID_AGENT_ADDRESS)) { 11 + pr_err_ratelimited("CXL CPER invalid agent type\n"); 12 + return -EINVAL; 13 + } 14 + 15 + if (!(prot_err->valid_bits & PROT_ERR_VALID_ERROR_LOG)) { 16 + pr_err_ratelimited("CXL CPER invalid protocol error log\n"); 17 + return -EINVAL; 18 + } 19 + 20 + if (prot_err->err_len != sizeof(struct cxl_ras_capability_regs)) { 21 + pr_err_ratelimited("CXL CPER invalid RAS Cap size (%u)\n", 22 + prot_err->err_len); 23 + return -EINVAL; 24 + } 25 + 26 + if ((prot_err->agent_type == RCD || prot_err->agent_type == DEVICE || 27 + prot_err->agent_type == LD || prot_err->agent_type == FMLD) && 28 + !(prot_err->valid_bits & PROT_ERR_VALID_SERIAL_NUMBER)) 29 + pr_warn_ratelimited(FW_WARN 30 + "CXL CPER no device serial number\n"); 31 + 32 + return 0; 33 + } 34 + EXPORT_SYMBOL_GPL(cxl_cper_sec_prot_err_valid); 35 + 36 + int cxl_cper_setup_prot_err_work_data(struct cxl_cper_prot_err_work_data *wd, 37 + struct cxl_cper_sec_prot_err *prot_err, 38 + int severity) 39 + { 40 + u8 *dvsec_start, *cap_start; 41 + 42 + switch (prot_err->agent_type) { 43 + case RCD: 44 + case DEVICE: 45 + case LD: 46 + case FMLD: 47 + case RP: 48 + case DSP: 49 + case USP: 50 + memcpy(&wd->prot_err, prot_err, sizeof(wd->prot_err)); 51 + 52 + dvsec_start = (u8 *)(prot_err + 1); 53 + cap_start = dvsec_start + prot_err->dvsec_len; 54 + 55 + memcpy(&wd->ras_cap, cap_start, sizeof(wd->ras_cap)); 56 + wd->severity = cper_severity_to_aer(severity); 57 + break; 58 + default: 59 + pr_err_ratelimited("CXL CPER invalid agent type: %d\n", 60 + prot_err->agent_type); 61 + return -EINVAL; 62 + } 63 + 64 + return 0; 65 + } 66 + EXPORT_SYMBOL_GPL(cxl_cper_setup_prot_err_work_data);
+157 -36
drivers/acpi/arm64/iort.c
··· 264 264 struct device *dev = context; 265 265 acpi_status status = AE_NOT_FOUND; 266 266 267 - if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT) { 267 + if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT || 268 + node->type == ACPI_IORT_NODE_IWB) { 268 269 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL }; 269 - struct acpi_device *adev; 270 270 struct acpi_iort_named_component *ncomp; 271 - struct device *nc_dev = dev; 271 + struct acpi_iort_iwb *iwb; 272 + struct device *cdev = dev; 273 + struct acpi_device *adev; 274 + const char *device_name; 272 275 273 276 /* 274 277 * Walk the device tree to find a device with an 275 278 * ACPI companion; there is no point in scanning 276 - * IORT for a device matching a named component if 279 + * IORT for a device matching a named component or IWB if 277 280 * the device does not have an ACPI companion to 278 281 * start with. 279 282 */ 280 283 do { 281 - adev = ACPI_COMPANION(nc_dev); 284 + adev = ACPI_COMPANION(cdev); 282 285 if (adev) 283 286 break; 284 287 285 - nc_dev = nc_dev->parent; 286 - } while (nc_dev); 288 + cdev = cdev->parent; 289 + } while (cdev); 287 290 288 291 if (!adev) 289 292 goto out; 290 293 291 294 status = acpi_get_name(adev->handle, ACPI_FULL_PATHNAME, &buf); 292 295 if (ACPI_FAILURE(status)) { 293 - dev_warn(nc_dev, "Can't get device full path name\n"); 296 + dev_warn(cdev, "Can't get device full path name\n"); 294 297 goto out; 295 298 } 296 299 297 - ncomp = (struct acpi_iort_named_component *)node->node_data; 298 - status = !strcmp(ncomp->device_name, buf.pointer) ? 299 - AE_OK : AE_NOT_FOUND; 300 + if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT) { 301 + ncomp = (struct acpi_iort_named_component *)node->node_data; 302 + device_name = ncomp->device_name; 303 + } else { 304 + iwb = (struct acpi_iort_iwb *)node->node_data; 305 + device_name = iwb->device_name; 306 + } 307 + status = !strcmp(device_name, buf.pointer) ? AE_OK : AE_NOT_FOUND; 300 308 acpi_os_free(buf.pointer); 301 309 } else if (node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) { 302 310 struct acpi_iort_root_complex *pci_rc; ··· 325 317 return status; 326 318 } 327 319 320 + static acpi_status iort_match_iwb_callback(struct acpi_iort_node *node, void *context) 321 + { 322 + struct acpi_iort_iwb *iwb; 323 + u32 *id = context; 324 + 325 + if (node->type != ACPI_IORT_NODE_IWB) 326 + return AE_NOT_FOUND; 327 + 328 + iwb = (struct acpi_iort_iwb *)node->node_data; 329 + if (iwb->iwb_index != *id) 330 + return AE_NOT_FOUND; 331 + 332 + return AE_OK; 333 + } 334 + 328 335 static int iort_id_map(struct acpi_iort_id_mapping *map, u8 type, u32 rid_in, 329 336 u32 *rid_out, bool check_overlap) 330 337 { 331 338 /* Single mapping does not care for input id */ 332 339 if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) { 333 340 if (type == ACPI_IORT_NODE_NAMED_COMPONENT || 341 + type == ACPI_IORT_NODE_IWB || 334 342 type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) { 335 343 *rid_out = map->output_base; 336 344 return 0; ··· 416 392 417 393 if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) { 418 394 if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT || 395 + node->type == ACPI_IORT_NODE_IWB || 419 396 node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX || 420 397 node->type == ACPI_IORT_NODE_SMMU_V3 || 421 398 node->type == ACPI_IORT_NODE_PMCG) { ··· 587 562 return node; 588 563 /* 589 564 * if not, then it should be a platform device defined in 590 - * DSDT/SSDT (with Named Component node in IORT) 565 + * DSDT/SSDT (with Named Component node in IORT) or an 566 + * IWB device in the DSDT/SSDT. 591 567 */ 592 - return iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT, 568 + node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT, 569 + iort_match_node_callback, dev); 570 + if (node) 571 + return node; 572 + return iort_scan_node(ACPI_IORT_NODE_IWB, 593 573 iort_match_node_callback, dev); 594 574 } 595 575 ··· 625 595 } 626 596 627 597 /** 628 - * iort_pmsi_get_dev_id() - Get the device id for a device 598 + * iort_msi_xlate() - Map a MSI input ID for a device 629 599 * @dev: The device for which the mapping is to be done. 630 - * @dev_id: The device ID found. 600 + * @input_id: The device input ID. 601 + * @fwnode: Pointer to store the fwnode. 631 602 * 632 - * Returns: 0 for successful find a dev id, -ENODEV on error 603 + * Returns: mapped MSI ID on success, input ID otherwise 604 + * On success, the fwnode pointer is initialized to the MSI 605 + * controller fwnode handle. 633 606 */ 634 - int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id) 607 + u32 iort_msi_xlate(struct device *dev, u32 input_id, struct fwnode_handle **fwnode) 635 608 { 636 - int i, index; 609 + struct acpi_iort_its_group *its; 637 610 struct acpi_iort_node *node; 611 + u32 dev_id; 638 612 639 613 node = iort_find_dev_node(dev); 640 614 if (!node) 641 - return -ENODEV; 615 + return input_id; 642 616 643 - index = iort_get_id_mapping_index(node); 644 - /* if there is a valid index, go get the dev_id directly */ 645 - if (index >= 0) { 646 - if (iort_node_get_id(node, dev_id, index)) 647 - return 0; 648 - } else { 649 - for (i = 0; i < node->mapping_count; i++) { 650 - if (iort_node_map_platform_id(node, dev_id, 651 - IORT_MSI_TYPE, i)) 652 - return 0; 653 - } 654 - } 617 + node = iort_node_map_id(node, input_id, &dev_id, IORT_MSI_TYPE); 618 + if (!node) 619 + return input_id; 655 620 656 - return -ENODEV; 621 + /* Move to ITS specific data */ 622 + its = (struct acpi_iort_its_group *)node->node_data; 623 + 624 + *fwnode = iort_find_domain_token(its->identifiers[0]); 625 + 626 + return dev_id; 657 627 } 658 628 659 - static int __maybe_unused iort_find_its_base(u32 its_id, phys_addr_t *base) 629 + int iort_its_translate_pa(struct fwnode_handle *node, phys_addr_t *base) 660 630 { 661 631 struct iort_its_msi_chip *its_msi_chip; 662 632 int ret = -ENODEV; 663 633 664 634 spin_lock(&iort_msi_chip_lock); 665 635 list_for_each_entry(its_msi_chip, &iort_msi_chip_list, list) { 666 - if (its_msi_chip->translation_id == its_id) { 636 + if (its_msi_chip->fw_node == node) { 667 637 *base = its_msi_chip->base_addr; 668 638 ret = 0; 669 639 break; ··· 672 642 spin_unlock(&iort_msi_chip_lock); 673 643 674 644 return ret; 645 + } 646 + 647 + static int __maybe_unused iort_find_its_base(u32 its_id, phys_addr_t *base) 648 + { 649 + struct fwnode_handle *fwnode = iort_find_domain_token(its_id); 650 + 651 + if (!fwnode) 652 + return -ENODEV; 653 + 654 + return iort_its_translate_pa(fwnode, base); 655 + } 656 + 657 + /** 658 + * iort_pmsi_get_msi_info() - Get the device id and translate frame PA for a device 659 + * @dev: The device for which the mapping is to be done. 660 + * @dev_id: The device ID found. 661 + * @pa: optional pointer to store translate frame address. 662 + * 663 + * Returns: 0 for successful devid and pa retrieval, -ENODEV on error 664 + */ 665 + int iort_pmsi_get_msi_info(struct device *dev, u32 *dev_id, phys_addr_t *pa) 666 + { 667 + struct acpi_iort_node *node, *parent = NULL; 668 + struct acpi_iort_its_group *its; 669 + int i, index; 670 + 671 + node = iort_find_dev_node(dev); 672 + if (!node) 673 + return -ENODEV; 674 + 675 + index = iort_get_id_mapping_index(node); 676 + /* if there is a valid index, go get the dev_id directly */ 677 + if (index >= 0) { 678 + parent = iort_node_get_id(node, dev_id, index); 679 + } else { 680 + for (i = 0; i < node->mapping_count; i++) { 681 + parent = iort_node_map_platform_id(node, dev_id, 682 + IORT_MSI_TYPE, i); 683 + if (parent) 684 + break; 685 + } 686 + } 687 + 688 + if (!parent) 689 + return -ENODEV; 690 + 691 + if (pa) { 692 + int ret; 693 + 694 + its = (struct acpi_iort_its_group *)node->node_data; 695 + ret = iort_find_its_base(its->identifiers[0], pa); 696 + if (ret) 697 + return ret; 698 + } 699 + 700 + return 0; 675 701 } 676 702 677 703 /** ··· 787 701 return NULL; 788 702 789 703 return irq_find_matching_fwnode(handle, bus_token); 704 + } 705 + 706 + struct fwnode_handle *iort_iwb_handle(u32 iwb_id) 707 + { 708 + struct fwnode_handle *fwnode; 709 + struct acpi_iort_node *node; 710 + struct acpi_device *device; 711 + struct acpi_iort_iwb *iwb; 712 + acpi_status status; 713 + acpi_handle handle; 714 + 715 + /* find its associated IWB node */ 716 + node = iort_scan_node(ACPI_IORT_NODE_IWB, iort_match_iwb_callback, &iwb_id); 717 + if (!node) 718 + return NULL; 719 + 720 + iwb = (struct acpi_iort_iwb *)node->node_data; 721 + status = acpi_get_handle(NULL, iwb->device_name, &handle); 722 + if (ACPI_FAILURE(status)) 723 + return NULL; 724 + 725 + device = acpi_get_acpi_dev(handle); 726 + if (!device) 727 + return NULL; 728 + 729 + fwnode = acpi_fwnode_handle(device); 730 + acpi_put_acpi_dev(device); 731 + 732 + return fwnode; 790 733 } 791 734 792 735 static void iort_set_device_domain(struct device *dev, ··· 878 763 /* find its associated iort node */ 879 764 node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT, 880 765 iort_match_node_callback, dev); 881 - if (!node) 882 - return NULL; 766 + if (!node) { 767 + /* find its associated iort node */ 768 + node = iort_scan_node(ACPI_IORT_NODE_IWB, 769 + iort_match_node_callback, dev); 770 + 771 + if (!node) 772 + return NULL; 773 + } 883 774 884 775 /* then find its msi parent node */ 885 776 for (i = 0; i < node->mapping_count; i++) {
+40 -40
drivers/acpi/battery.c
··· 17 17 #include <linux/list.h> 18 18 #include <linux/module.h> 19 19 #include <linux/mutex.h> 20 + #include <linux/platform_device.h> 20 21 #include <linux/slab.h> 21 22 #include <linux/suspend.h> 22 23 #include <linux/types.h> ··· 212 211 if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) 213 212 val->intval = acpi_battery_handle_discharging(battery); 214 213 else if (battery->state & ACPI_BATTERY_STATE_CHARGING) 215 - val->intval = POWER_SUPPLY_STATUS_CHARGING; 214 + /* Validate the status by checking the current. */ 215 + if (battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN && 216 + battery->rate_now == 0) { 217 + /* On charge but no current (0W/0mA). */ 218 + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; 219 + } else { 220 + val->intval = POWER_SUPPLY_STATUS_CHARGING; 221 + } 216 222 else if (battery->state & ACPI_BATTERY_STATE_CHARGE_LIMITING) 217 223 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; 218 224 else if (acpi_battery_is_charged(battery)) ··· 1062 1054 /* Driver Interface */ 1063 1055 static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) 1064 1056 { 1065 - struct acpi_device *device = data; 1066 - struct acpi_battery *battery = acpi_driver_data(device); 1057 + struct acpi_battery *battery = data; 1058 + struct acpi_device *device = battery->device; 1067 1059 struct power_supply *old; 1068 1060 1069 1061 if (!battery) ··· 1216 1208 sysfs_remove_battery(battery); 1217 1209 } 1218 1210 1219 - static int acpi_battery_add(struct acpi_device *device) 1211 + static int acpi_battery_probe(struct platform_device *pdev) 1220 1212 { 1221 - int result = 0; 1213 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1222 1214 struct acpi_battery *battery; 1223 - 1224 - if (!device) 1225 - return -EINVAL; 1215 + int result; 1226 1216 1227 1217 if (device->dep_unmet) 1228 1218 return -EPROBE_DEFER; 1229 1219 1230 - battery = devm_kzalloc(&device->dev, sizeof(*battery), GFP_KERNEL); 1220 + battery = devm_kzalloc(&pdev->dev, sizeof(*battery), GFP_KERNEL); 1231 1221 if (!battery) 1232 1222 return -ENOMEM; 1223 + 1224 + platform_set_drvdata(pdev, battery); 1225 + 1233 1226 battery->device = device; 1234 1227 strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); 1235 1228 strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS); 1236 - device->driver_data = battery; 1237 1229 1238 - result = devm_mutex_init(&device->dev, &battery->update_lock); 1230 + result = devm_mutex_init(&pdev->dev, &battery->update_lock); 1239 1231 if (result) 1240 1232 return result; 1241 1233 ··· 1254 1246 if (result) 1255 1247 goto fail; 1256 1248 1257 - device_init_wakeup(&device->dev, 1); 1249 + device_init_wakeup(&pdev->dev, true); 1258 1250 1259 1251 result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY, 1260 - acpi_battery_notify, device); 1252 + acpi_battery_notify, battery); 1261 1253 if (result) 1262 1254 goto fail_pm; 1263 1255 1264 1256 return 0; 1265 1257 1266 1258 fail_pm: 1267 - device_init_wakeup(&device->dev, 0); 1259 + device_init_wakeup(&pdev->dev, false); 1268 1260 unregister_pm_notifier(&battery->pm_nb); 1269 1261 fail: 1270 1262 sysfs_battery_cleanup(battery); ··· 1272 1264 return result; 1273 1265 } 1274 1266 1275 - static void acpi_battery_remove(struct acpi_device *device) 1267 + static void acpi_battery_remove(struct platform_device *pdev) 1276 1268 { 1277 - struct acpi_battery *battery; 1269 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1270 + struct acpi_battery *battery = platform_get_drvdata(pdev); 1278 1271 1279 - if (!device || !acpi_driver_data(device)) 1272 + if (!device || !battery) 1280 1273 return; 1281 - 1282 - battery = acpi_driver_data(device); 1283 1274 1284 1275 acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY, 1285 1276 acpi_battery_notify); 1286 1277 1287 - device_init_wakeup(&device->dev, 0); 1278 + device_init_wakeup(&pdev->dev, false); 1288 1279 unregister_pm_notifier(&battery->pm_nb); 1289 1280 1290 - guard(mutex)(&battery->update_lock); 1291 - 1292 - sysfs_remove_battery(battery); 1281 + sysfs_battery_cleanup(battery); 1293 1282 } 1294 1283 1295 1284 /* this is needed to learn about changes made in suspended state */ 1296 1285 static int acpi_battery_resume(struct device *dev) 1297 1286 { 1298 - struct acpi_battery *battery; 1287 + struct acpi_battery *battery = dev_get_drvdata(dev); 1299 1288 1300 - if (!dev) 1301 - return -EINVAL; 1302 - 1303 - battery = acpi_driver_data(to_acpi_device(dev)); 1304 1289 if (!battery) 1305 1290 return -EINVAL; 1306 1291 ··· 1307 1306 1308 1307 static DEFINE_SIMPLE_DEV_PM_OPS(acpi_battery_pm, NULL, acpi_battery_resume); 1309 1308 1310 - static struct acpi_driver acpi_battery_driver = { 1311 - .name = "battery", 1312 - .class = ACPI_BATTERY_CLASS, 1313 - .ids = battery_device_ids, 1314 - .ops = { 1315 - .add = acpi_battery_add, 1316 - .remove = acpi_battery_remove, 1317 - }, 1318 - .drv.pm = pm_sleep_ptr(&acpi_battery_pm), 1319 - .drv.probe_type = PROBE_PREFER_ASYNCHRONOUS, 1309 + static struct platform_driver acpi_battery_driver = { 1310 + .probe = acpi_battery_probe, 1311 + .remove = acpi_battery_remove, 1312 + .driver = { 1313 + .name = "acpi-battery", 1314 + .acpi_match_table = battery_device_ids, 1315 + .pm = pm_sleep_ptr(&acpi_battery_pm), 1316 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1317 + }, 1320 1318 }; 1321 1319 1322 1320 static int __init acpi_battery_init(void) ··· 1325 1325 1326 1326 dmi_check_system(bat_dmi_table); 1327 1327 1328 - return acpi_bus_register_driver(&acpi_battery_driver); 1328 + return platform_driver_register(&acpi_battery_driver); 1329 1329 } 1330 1330 1331 1331 static void __exit acpi_battery_exit(void) 1332 1332 { 1333 - acpi_bus_unregister_driver(&acpi_battery_driver); 1333 + platform_driver_unregister(&acpi_battery_driver); 1334 1334 battery_hook_exit(); 1335 1335 } 1336 1336
+271 -214
drivers/acpi/bus.c
··· 180 180 } 181 181 EXPORT_SYMBOL_GPL(acpi_bus_detach_private_data); 182 182 183 - static void acpi_print_osc_error(acpi_handle handle, 184 - struct acpi_osc_context *context, char *error) 183 + static void acpi_dump_osc_data(acpi_handle handle, const guid_t *guid, int rev, 184 + struct acpi_buffer *cap) 185 185 { 186 + u32 *capbuf = cap->pointer; 186 187 int i; 187 188 188 - acpi_handle_debug(handle, "(%s): %s\n", context->uuid_str, error); 189 + acpi_handle_debug(handle, "_OSC: UUID: %pUL, rev: %d\n", guid, rev); 190 + for (i = 0; i < cap->length / sizeof(u32); i++) 191 + acpi_handle_debug(handle, "_OSC: capabilities DWORD %i: [%08x]\n", 192 + i, capbuf[i]); 193 + } 189 194 190 - pr_debug("_OSC request data:"); 191 - for (i = 0; i < context->cap.length; i += sizeof(u32)) 192 - pr_debug(" %x", *((u32 *)(context->cap.pointer + i))); 195 + #define OSC_ERROR_MASK (OSC_REQUEST_ERROR | OSC_INVALID_UUID_ERROR | \ 196 + OSC_INVALID_REVISION_ERROR | \ 197 + OSC_CAPABILITIES_MASK_ERROR) 193 198 194 - pr_debug("\n"); 199 + static int acpi_eval_osc(acpi_handle handle, guid_t *guid, int rev, 200 + struct acpi_buffer *cap, 201 + union acpi_object in_params[at_least 4], 202 + struct acpi_buffer *output) 203 + { 204 + struct acpi_object_list input; 205 + union acpi_object *out_obj; 206 + acpi_status status; 207 + 208 + in_params[0].type = ACPI_TYPE_BUFFER; 209 + in_params[0].buffer.length = sizeof(*guid); 210 + in_params[0].buffer.pointer = (u8 *)guid; 211 + in_params[1].type = ACPI_TYPE_INTEGER; 212 + in_params[1].integer.value = rev; 213 + in_params[2].type = ACPI_TYPE_INTEGER; 214 + in_params[2].integer.value = cap->length / sizeof(u32); 215 + in_params[3].type = ACPI_TYPE_BUFFER; 216 + in_params[3].buffer.length = cap->length; 217 + in_params[3].buffer.pointer = cap->pointer; 218 + input.pointer = in_params; 219 + input.count = 4; 220 + 221 + output->length = ACPI_ALLOCATE_BUFFER; 222 + output->pointer = NULL; 223 + 224 + status = acpi_evaluate_object(handle, "_OSC", &input, output); 225 + if (ACPI_FAILURE(status) || !output->length) 226 + return -ENODATA; 227 + 228 + out_obj = output->pointer; 229 + if (out_obj->type != ACPI_TYPE_BUFFER || 230 + out_obj->buffer.length != cap->length) { 231 + acpi_handle_debug(handle, "Invalid _OSC return buffer\n"); 232 + acpi_dump_osc_data(handle, guid, rev, cap); 233 + ACPI_FREE(out_obj); 234 + return -ENODATA; 235 + } 236 + 237 + return 0; 238 + } 239 + 240 + static bool acpi_osc_error_check(acpi_handle handle, guid_t *guid, int rev, 241 + struct acpi_buffer *cap, u32 *retbuf) 242 + { 243 + /* Only take defined error bits into account. */ 244 + u32 errors = retbuf[OSC_QUERY_DWORD] & OSC_ERROR_MASK; 245 + u32 *capbuf = cap->pointer; 246 + bool fail; 247 + 248 + /* 249 + * If OSC_QUERY_ENABLE is set, ignore the "capabilities masked" 250 + * bit because it merely means that some features have not been 251 + * acknowledged which is not unexpected. 252 + */ 253 + if (capbuf[OSC_QUERY_DWORD] & OSC_QUERY_ENABLE) 254 + errors &= ~OSC_CAPABILITIES_MASK_ERROR; 255 + 256 + if (!errors) 257 + return false; 258 + 259 + acpi_dump_osc_data(handle, guid, rev, cap); 260 + /* 261 + * As a rule, fail only if OSC_QUERY_ENABLE is set because otherwise the 262 + * acknowledged features need to be controlled. 263 + */ 264 + fail = !!(capbuf[OSC_QUERY_DWORD] & OSC_QUERY_ENABLE); 265 + 266 + if (errors & OSC_REQUEST_ERROR) 267 + acpi_handle_debug(handle, "_OSC: request failed\n"); 268 + 269 + if (errors & OSC_INVALID_UUID_ERROR) { 270 + acpi_handle_debug(handle, "_OSC: invalid UUID\n"); 271 + /* 272 + * Always fail if this bit is set because it means that the 273 + * request could not be processed. 274 + */ 275 + fail = true; 276 + } 277 + 278 + if (errors & OSC_INVALID_REVISION_ERROR) 279 + acpi_handle_debug(handle, "_OSC: invalid revision\n"); 280 + 281 + if (errors & OSC_CAPABILITIES_MASK_ERROR) 282 + acpi_handle_debug(handle, "_OSC: capability bits masked\n"); 283 + 284 + return fail; 195 285 } 196 286 197 287 acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context) 198 288 { 199 - acpi_status status; 200 - struct acpi_object_list input; 201 - union acpi_object in_params[4]; 202 - union acpi_object *out_obj; 289 + union acpi_object in_params[4], *out_obj; 290 + struct acpi_buffer output; 291 + acpi_status status = AE_OK; 203 292 guid_t guid; 204 - u32 errors; 205 - struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; 293 + u32 *retbuf; 294 + int ret; 206 295 207 - if (!context) 296 + if (!context || !context->cap.pointer || 297 + context->cap.length < 2 * sizeof(u32) || 298 + guid_parse(context->uuid_str, &guid)) 299 + return AE_BAD_PARAMETER; 300 + 301 + ret = acpi_eval_osc(handle, &guid, context->rev, &context->cap, 302 + in_params, &output); 303 + if (ret) 208 304 return AE_ERROR; 209 - if (guid_parse(context->uuid_str, &guid)) 210 - return AE_ERROR; 211 - context->ret.length = ACPI_ALLOCATE_BUFFER; 212 - context->ret.pointer = NULL; 213 - 214 - /* Setting up input parameters */ 215 - input.count = 4; 216 - input.pointer = in_params; 217 - in_params[0].type = ACPI_TYPE_BUFFER; 218 - in_params[0].buffer.length = 16; 219 - in_params[0].buffer.pointer = (u8 *)&guid; 220 - in_params[1].type = ACPI_TYPE_INTEGER; 221 - in_params[1].integer.value = context->rev; 222 - in_params[2].type = ACPI_TYPE_INTEGER; 223 - in_params[2].integer.value = context->cap.length/sizeof(u32); 224 - in_params[3].type = ACPI_TYPE_BUFFER; 225 - in_params[3].buffer.length = context->cap.length; 226 - in_params[3].buffer.pointer = context->cap.pointer; 227 - 228 - status = acpi_evaluate_object(handle, "_OSC", &input, &output); 229 - if (ACPI_FAILURE(status)) 230 - return status; 231 - 232 - if (!output.length) 233 - return AE_NULL_OBJECT; 234 305 235 306 out_obj = output.pointer; 236 - if (out_obj->type != ACPI_TYPE_BUFFER 237 - || out_obj->buffer.length != context->cap.length) { 238 - acpi_print_osc_error(handle, context, 239 - "_OSC evaluation returned wrong type"); 240 - status = AE_TYPE; 241 - goto out_kfree; 242 - } 243 - /* Need to ignore the bit0 in result code */ 244 - errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0); 245 - if (errors) { 246 - if (errors & OSC_REQUEST_ERROR) 247 - acpi_print_osc_error(handle, context, 248 - "_OSC request failed"); 249 - if (errors & OSC_INVALID_UUID_ERROR) 250 - acpi_print_osc_error(handle, context, 251 - "_OSC invalid UUID"); 252 - if (errors & OSC_INVALID_REVISION_ERROR) 253 - acpi_print_osc_error(handle, context, 254 - "_OSC invalid revision"); 255 - if (errors & OSC_CAPABILITIES_MASK_ERROR) { 256 - if (((u32 *)context->cap.pointer)[OSC_QUERY_DWORD] 257 - & OSC_QUERY_ENABLE) 258 - goto out_success; 259 - status = AE_SUPPORT; 260 - goto out_kfree; 261 - } 307 + retbuf = (u32 *)out_obj->buffer.pointer; 308 + 309 + if (acpi_osc_error_check(handle, &guid, context->rev, &context->cap, retbuf)) { 262 310 status = AE_ERROR; 263 - goto out_kfree; 311 + goto out; 264 312 } 265 - out_success: 313 + 266 314 context->ret.length = out_obj->buffer.length; 267 - context->ret.pointer = kmemdup(out_obj->buffer.pointer, 268 - context->ret.length, GFP_KERNEL); 315 + context->ret.pointer = kmemdup(retbuf, context->ret.length, GFP_KERNEL); 269 316 if (!context->ret.pointer) { 270 317 status = AE_NO_MEMORY; 271 - goto out_kfree; 318 + goto out; 272 319 } 273 320 status = AE_OK; 274 321 275 - out_kfree: 276 - kfree(output.pointer); 322 + out: 323 + ACPI_FREE(out_obj); 277 324 return status; 278 325 } 279 326 EXPORT_SYMBOL(acpi_run_osc); 327 + 328 + static int acpi_osc_handshake(acpi_handle handle, const char *uuid_str, 329 + int rev, u32 *capbuf, size_t bufsize) 330 + { 331 + union acpi_object in_params[4], *out_obj; 332 + struct acpi_object_list input; 333 + struct acpi_buffer cap = { 334 + .pointer = capbuf, 335 + .length = bufsize * sizeof(u32), 336 + }; 337 + struct acpi_buffer output; 338 + u32 *retbuf, test; 339 + guid_t guid; 340 + int ret, i; 341 + 342 + if (!capbuf || bufsize < 2 || guid_parse(uuid_str, &guid)) 343 + return -EINVAL; 344 + 345 + /* First evaluate _OSC with OSC_QUERY_ENABLE set. */ 346 + capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE; 347 + 348 + ret = acpi_eval_osc(handle, &guid, rev, &cap, in_params, &output); 349 + if (ret) 350 + return ret; 351 + 352 + out_obj = output.pointer; 353 + retbuf = (u32 *)out_obj->buffer.pointer; 354 + 355 + if (acpi_osc_error_check(handle, &guid, rev, &cap, retbuf)) { 356 + ret = -ENODATA; 357 + goto out; 358 + } 359 + 360 + /* 361 + * Clear the feature bits in the capabilities buffer that have not been 362 + * acknowledged and clear the return buffer. 363 + */ 364 + for (i = OSC_QUERY_DWORD + 1, test = 0; i < bufsize; i++) { 365 + capbuf[i] &= retbuf[i]; 366 + test |= capbuf[i]; 367 + retbuf[i] = 0; 368 + } 369 + /* 370 + * If none of the feature bits have been acknowledged, there's nothing 371 + * more to do. capbuf[] contains a feature mask of all zeros. 372 + */ 373 + if (!test) 374 + goto out; 375 + 376 + retbuf[OSC_QUERY_DWORD] = 0; 377 + /* 378 + * Now evaluate _OSC again (directly) with OSC_QUERY_ENABLE clear and 379 + * the updated input and output buffers used before. Since the feature 380 + * bits that were clear in the return buffer from the previous _OSC 381 + * evaluation are also clear in the capabilities buffer now, this _OSC 382 + * evaluation is not expected to fail. 383 + */ 384 + capbuf[OSC_QUERY_DWORD] = 0; 385 + /* Reuse in_params[] populated by acpi_eval_osc(). */ 386 + input.pointer = in_params; 387 + input.count = 4; 388 + 389 + if (ACPI_FAILURE(acpi_evaluate_object(handle, "_OSC", &input, &output))) { 390 + ret = -ENODATA; 391 + goto out; 392 + } 393 + 394 + /* 395 + * Clear the feature bits in capbuf[] that have not been acknowledged. 396 + * After that, capbuf[] contains the resultant feature mask. 397 + */ 398 + for (i = OSC_QUERY_DWORD + 1; i < bufsize; i++) 399 + capbuf[i] &= retbuf[i]; 400 + 401 + if (retbuf[OSC_QUERY_DWORD] & OSC_ERROR_MASK) { 402 + /* 403 + * Complain about the unexpected errors and print diagnostic 404 + * information related to them. 405 + */ 406 + acpi_handle_err(handle, "_OSC: errors while processing control request\n"); 407 + acpi_handle_err(handle, "_OSC: some features may be missing\n"); 408 + acpi_osc_error_check(handle, &guid, rev, &cap, retbuf); 409 + } 410 + 411 + out: 412 + ACPI_FREE(out_obj); 413 + return ret; 414 + } 280 415 281 416 bool osc_sb_apei_support_acked; 282 417 ··· 444 309 445 310 bool osc_sb_cppc2_support_acked; 446 311 447 - static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48"; 448 312 static void acpi_bus_osc_negotiate_platform_control(void) 449 313 { 450 - u32 capbuf[2], *capbuf_ret; 451 - struct acpi_osc_context context = { 452 - .uuid_str = sb_uuid_str, 453 - .rev = 1, 454 - .cap.length = 8, 455 - .cap.pointer = capbuf, 456 - }; 314 + static const u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48"; 315 + u32 capbuf[2], feature_mask; 457 316 acpi_handle handle; 458 317 459 - capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE; 460 - capbuf[OSC_SUPPORT_DWORD] = OSC_SB_PR3_SUPPORT; /* _PR3 is in use */ 318 + feature_mask = OSC_SB_PR3_SUPPORT | OSC_SB_HOTPLUG_OST_SUPPORT | 319 + OSC_SB_PCLPI_SUPPORT | OSC_SB_OVER_16_PSTATES_SUPPORT | 320 + OSC_SB_GED_SUPPORT | OSC_SB_IRQ_RESOURCE_SOURCE_SUPPORT; 321 + 322 + if (IS_ENABLED(CONFIG_ARM64) || IS_ENABLED(CONFIG_X86)) 323 + feature_mask |= OSC_SB_GENERIC_INITIATOR_SUPPORT; 324 + 325 + if (IS_ENABLED(CONFIG_ACPI_CPPC_LIB)) { 326 + feature_mask |= OSC_SB_CPC_SUPPORT | OSC_SB_CPCV2_SUPPORT | 327 + OSC_SB_CPC_FLEXIBLE_ADR_SPACE; 328 + if (IS_ENABLED(CONFIG_SCHED_MC_PRIO)) 329 + feature_mask |= OSC_SB_CPC_DIVERSE_HIGH_SUPPORT; 330 + } 331 + 461 332 if (IS_ENABLED(CONFIG_ACPI_PROCESSOR_AGGREGATOR)) 462 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PAD_SUPPORT; 333 + feature_mask |= OSC_SB_PAD_SUPPORT; 334 + 463 335 if (IS_ENABLED(CONFIG_ACPI_PROCESSOR)) 464 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PPC_OST_SUPPORT; 336 + feature_mask |= OSC_SB_PPC_OST_SUPPORT; 337 + 465 338 if (IS_ENABLED(CONFIG_ACPI_THERMAL)) 466 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_FAST_THERMAL_SAMPLING_SUPPORT; 339 + feature_mask |= OSC_SB_FAST_THERMAL_SAMPLING_SUPPORT; 340 + 467 341 if (IS_ENABLED(CONFIG_ACPI_BATTERY)) 468 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_BATTERY_CHARGE_LIMITING_SUPPORT; 342 + feature_mask |= OSC_SB_BATTERY_CHARGE_LIMITING_SUPPORT; 469 343 470 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_HOTPLUG_OST_SUPPORT; 471 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PCLPI_SUPPORT; 472 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_OVER_16_PSTATES_SUPPORT; 473 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_GED_SUPPORT; 474 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_IRQ_RESOURCE_SOURCE_SUPPORT; 475 344 if (IS_ENABLED(CONFIG_ACPI_PRMT)) 476 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PRM_SUPPORT; 345 + feature_mask |= OSC_SB_PRM_SUPPORT; 346 + 477 347 if (IS_ENABLED(CONFIG_ACPI_FFH)) 478 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_FFH_OPR_SUPPORT; 479 - 480 - #ifdef CONFIG_ARM64 481 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_GENERIC_INITIATOR_SUPPORT; 482 - #endif 483 - #ifdef CONFIG_X86 484 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_GENERIC_INITIATOR_SUPPORT; 485 - #endif 486 - 487 - #ifdef CONFIG_ACPI_CPPC_LIB 488 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_SUPPORT; 489 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPCV2_SUPPORT; 490 - #endif 491 - 492 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_FLEXIBLE_ADR_SPACE; 493 - 494 - if (IS_ENABLED(CONFIG_SCHED_MC_PRIO)) 495 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_DIVERSE_HIGH_SUPPORT; 348 + feature_mask |= OSC_SB_FFH_OPR_SUPPORT; 496 349 497 350 if (IS_ENABLED(CONFIG_USB4)) 498 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_NATIVE_USB4_SUPPORT; 351 + feature_mask |= OSC_SB_NATIVE_USB4_SUPPORT; 499 352 500 353 if (!ghes_disable) 501 - capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_APEI_SUPPORT; 354 + feature_mask |= OSC_SB_APEI_SUPPORT; 355 + 502 356 if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle))) 503 357 return; 504 358 505 - if (ACPI_FAILURE(acpi_run_osc(handle, &context))) 359 + capbuf[OSC_SUPPORT_DWORD] = feature_mask; 360 + 361 + acpi_handle_info(handle, "platform _OSC: OS support mask [%08x]\n", feature_mask); 362 + 363 + if (acpi_osc_handshake(handle, sb_uuid_str, 1, capbuf, ARRAY_SIZE(capbuf))) 506 364 return; 507 365 508 - capbuf_ret = context.ret.pointer; 509 - if (context.ret.length <= OSC_SUPPORT_DWORD) { 510 - kfree(context.ret.pointer); 511 - return; 512 - } 366 + feature_mask = capbuf[OSC_SUPPORT_DWORD]; 513 367 514 - /* 515 - * Now run _OSC again with query flag clear and with the caps 516 - * supported by both the OS and the platform. 517 - */ 518 - capbuf[OSC_QUERY_DWORD] = 0; 519 - capbuf[OSC_SUPPORT_DWORD] = capbuf_ret[OSC_SUPPORT_DWORD]; 520 - kfree(context.ret.pointer); 368 + acpi_handle_info(handle, "platform _OSC: OS control mask [%08x]\n", feature_mask); 521 369 522 - if (ACPI_FAILURE(acpi_run_osc(handle, &context))) 523 - return; 524 - 525 - capbuf_ret = context.ret.pointer; 526 - if (context.ret.length > OSC_SUPPORT_DWORD) { 527 - #ifdef CONFIG_ACPI_CPPC_LIB 528 - osc_sb_cppc2_support_acked = capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_CPCV2_SUPPORT; 529 - #endif 530 - 531 - osc_sb_apei_support_acked = 532 - capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT; 533 - osc_pc_lpi_support_confirmed = 534 - capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT; 535 - osc_sb_native_usb4_support_confirmed = 536 - capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT; 537 - osc_cpc_flexible_adr_space_confirmed = 538 - capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_CPC_FLEXIBLE_ADR_SPACE; 539 - } 540 - 541 - kfree(context.ret.pointer); 370 + osc_sb_cppc2_support_acked = feature_mask & OSC_SB_CPCV2_SUPPORT; 371 + osc_sb_apei_support_acked = feature_mask & OSC_SB_APEI_SUPPORT; 372 + osc_pc_lpi_support_confirmed = feature_mask & OSC_SB_PCLPI_SUPPORT; 373 + osc_sb_native_usb4_support_confirmed = feature_mask & OSC_SB_NATIVE_USB4_SUPPORT; 374 + osc_cpc_flexible_adr_space_confirmed = feature_mask & OSC_SB_CPC_FLEXIBLE_ADR_SPACE; 542 375 } 543 376 544 377 /* ··· 526 423 (bits & OSC_USB_XDOMAIN) ? '+' : '-'); 527 424 } 528 425 529 - static u8 sb_usb_uuid_str[] = "23A0D13A-26AB-486C-9C5F-0FFA525A575A"; 530 426 static void acpi_bus_osc_negotiate_usb_control(void) 531 427 { 532 - u32 capbuf[3], *capbuf_ret; 533 - struct acpi_osc_context context = { 534 - .uuid_str = sb_usb_uuid_str, 535 - .rev = 1, 536 - .cap.length = sizeof(capbuf), 537 - .cap.pointer = capbuf, 538 - }; 428 + static const u8 sb_usb_uuid_str[] = "23A0D13A-26AB-486C-9C5F-0FFA525A575A"; 429 + u32 capbuf[3], control; 539 430 acpi_handle handle; 540 - acpi_status status; 541 - u32 control; 542 431 543 432 if (!osc_sb_native_usb4_support_confirmed) 544 433 return; ··· 541 446 control = OSC_USB_USB3_TUNNELING | OSC_USB_DP_TUNNELING | 542 447 OSC_USB_PCIE_TUNNELING | OSC_USB_XDOMAIN; 543 448 544 - /* 545 - * Run _OSC first with query bit set, trying to get control over 546 - * all tunneling. The platform can then clear out bits in the 547 - * control dword that it does not want to grant to the OS. 548 - */ 549 - capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE; 550 449 capbuf[OSC_SUPPORT_DWORD] = 0; 551 450 capbuf[OSC_CONTROL_DWORD] = control; 552 451 553 - status = acpi_run_osc(handle, &context); 554 - if (ACPI_FAILURE(status)) 452 + if (acpi_osc_handshake(handle, sb_usb_uuid_str, 1, capbuf, ARRAY_SIZE(capbuf))) 555 453 return; 556 454 557 - if (context.ret.length != sizeof(capbuf)) { 558 - pr_info("USB4 _OSC: returned invalid length buffer\n"); 559 - goto out_free; 560 - } 561 - 562 - /* 563 - * Run _OSC again now with query bit clear and the control dword 564 - * matching what the platform granted (which may not have all 565 - * the control bits set). 566 - */ 567 - capbuf_ret = context.ret.pointer; 568 - 569 - capbuf[OSC_QUERY_DWORD] = 0; 570 - capbuf[OSC_CONTROL_DWORD] = capbuf_ret[OSC_CONTROL_DWORD]; 571 - 572 - kfree(context.ret.pointer); 573 - 574 - status = acpi_run_osc(handle, &context); 575 - if (ACPI_FAILURE(status)) 576 - return; 577 - 578 - if (context.ret.length != sizeof(capbuf)) { 579 - pr_info("USB4 _OSC: returned invalid length buffer\n"); 580 - goto out_free; 581 - } 582 - 583 - osc_sb_native_usb4_control = 584 - control & acpi_osc_ctx_get_pci_control(&context); 455 + osc_sb_native_usb4_control = capbuf[OSC_CONTROL_DWORD]; 585 456 586 457 acpi_bus_decode_usb_osc("USB4 _OSC: OS supports", control); 587 - acpi_bus_decode_usb_osc("USB4 _OSC: OS controls", 588 - osc_sb_native_usb4_control); 589 - 590 - out_free: 591 - kfree(context.ret.pointer); 458 + acpi_bus_decode_usb_osc("USB4 _OSC: OS controls", osc_sb_native_usb4_control); 592 459 } 593 460 594 461 /* -------------------------------------------------------------------------- ··· 818 761 if (list_empty(&adev->pnp.ids)) 819 762 return NULL; 820 763 764 + if (adev->pnp.type.backlight) 765 + return adev; 766 + 821 767 return acpi_primary_dev_companion(adev, dev); 822 768 } 823 769 ··· 1016 956 } 1017 957 EXPORT_SYMBOL_GPL(acpi_match_device); 1018 958 1019 - static const void *acpi_of_device_get_match_data(const struct device *dev) 1020 - { 1021 - struct acpi_device *adev = ACPI_COMPANION(dev); 1022 - const struct of_device_id *match = NULL; 1023 - 1024 - if (!acpi_of_match_device(adev, dev->driver->of_match_table, &match)) 1025 - return NULL; 1026 - 1027 - return match->data; 1028 - } 1029 - 1030 959 const void *acpi_device_get_match_data(const struct device *dev) 1031 960 { 1032 961 const struct acpi_device_id *acpi_ids = dev->driver->acpi_match_table; 1033 - const struct acpi_device_id *match; 962 + const struct of_device_id *of_ids = dev->driver->of_match_table; 963 + const struct acpi_device *adev = acpi_companion_match(dev); 964 + const struct acpi_device_id *acpi_id = NULL; 965 + const struct of_device_id *of_id = NULL; 1034 966 1035 - if (!acpi_ids) 1036 - return acpi_of_device_get_match_data(dev); 1037 - 1038 - match = acpi_match_device(acpi_ids, dev); 1039 - if (!match) 967 + if (!__acpi_match_device(adev, acpi_ids, of_ids, &acpi_id, &of_id)) 1040 968 return NULL; 1041 969 1042 - return (const void *)match->driver_data; 970 + if (acpi_id) 971 + return (const void *)acpi_id->driver_data; 972 + 973 + if (of_id) 974 + return of_id->data; 975 + 976 + return NULL; 1043 977 } 1044 978 EXPORT_SYMBOL_GPL(acpi_device_get_match_data); 1045 979 ··· 1250 1196 break; 1251 1197 case ACPI_IRQ_MODEL_GIC: 1252 1198 message = "GIC"; 1199 + break; 1200 + case ACPI_IRQ_MODEL_GIC_V5: 1201 + message = "GICv5"; 1253 1202 break; 1254 1203 case ACPI_IRQ_MODEL_PLATFORM: 1255 1204 message = "platform specific model";
+65 -63
drivers/acpi/button.c
··· 19 19 #include <linux/slab.h> 20 20 #include <linux/acpi.h> 21 21 #include <linux/dmi.h> 22 + #include <linux/platform_device.h> 22 23 #include <acpi/button.h> 23 24 24 25 #define ACPI_BUTTON_CLASS "button" ··· 146 145 {} 147 146 }; 148 147 149 - static int acpi_button_add(struct acpi_device *device); 150 - static void acpi_button_remove(struct acpi_device *device); 148 + static int acpi_button_probe(struct platform_device *pdev); 149 + static void acpi_button_remove(struct platform_device *pdev); 151 150 152 151 #ifdef CONFIG_PM_SLEEP 153 152 static int acpi_button_suspend(struct device *dev); ··· 158 157 #endif 159 158 static SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume); 160 159 161 - static struct acpi_driver acpi_button_driver = { 162 - .name = "button", 163 - .class = ACPI_BUTTON_CLASS, 164 - .ids = button_device_ids, 165 - .ops = { 166 - .add = acpi_button_add, 167 - .remove = acpi_button_remove, 160 + static struct platform_driver acpi_button_driver = { 161 + .probe = acpi_button_probe, 162 + .remove = acpi_button_remove, 163 + .driver = { 164 + .name = "acpi-button", 165 + .acpi_match_table = button_device_ids, 166 + .pm = &acpi_button_pm, 168 167 }, 169 - .drv.pm = &acpi_button_pm, 170 168 }; 171 169 172 170 struct acpi_button { 171 + struct acpi_device *adev; 172 + struct platform_device *pdev; 173 173 unsigned int type; 174 174 struct input_dev *input; 175 175 char phys[32]; /* for input device */ ··· 204 202 return lid_state ? 1 : 0; 205 203 } 206 204 207 - static int acpi_lid_notify_state(struct acpi_device *device, int state) 205 + static int acpi_lid_notify_state(struct acpi_button *button, int state) 208 206 { 209 - struct acpi_button *button = acpi_driver_data(device); 207 + struct acpi_device *device = button->adev; 210 208 ktime_t next_report; 211 209 bool do_update; 212 210 ··· 289 287 static int __maybe_unused acpi_button_state_seq_show(struct seq_file *seq, 290 288 void *offset) 291 289 { 292 - struct acpi_device *device = seq->private; 290 + struct acpi_button *button = seq->private; 293 291 int state; 294 292 295 - state = acpi_lid_evaluate_state(device); 293 + state = acpi_lid_evaluate_state(button->adev); 296 294 seq_printf(seq, "state: %s\n", 297 295 state < 0 ? "unsupported" : (state ? "open" : "closed")); 298 296 return 0; 299 297 } 300 298 301 - static int acpi_button_add_fs(struct acpi_device *device) 299 + static int acpi_button_add_fs(struct acpi_button *button) 302 300 { 303 - struct acpi_button *button = acpi_driver_data(device); 301 + struct acpi_device *device = button->adev; 304 302 struct proc_dir_entry *entry = NULL; 305 303 int ret = 0; 306 304 ··· 335 333 /* create /proc/acpi/button/lid/LID/state */ 336 334 entry = proc_create_single_data(ACPI_BUTTON_FILE_STATE, S_IRUGO, 337 335 acpi_device_dir(device), acpi_button_state_seq_show, 338 - device); 336 + button); 339 337 if (!entry) { 340 338 ret = -ENODEV; 341 339 goto remove_dev_dir; ··· 357 355 goto done; 358 356 } 359 357 360 - static int acpi_button_remove_fs(struct acpi_device *device) 358 + static int acpi_button_remove_fs(struct acpi_button *button) 361 359 { 362 - struct acpi_button *button = acpi_driver_data(device); 360 + struct acpi_device *device = button->adev; 363 361 364 362 if (button->type != ACPI_BUTTON_TYPE_LID) 365 363 return 0; ··· 387 385 } 388 386 EXPORT_SYMBOL(acpi_lid_open); 389 387 390 - static int acpi_lid_update_state(struct acpi_device *device, 388 + static int acpi_lid_update_state(struct acpi_button *button, 391 389 bool signal_wakeup) 392 390 { 391 + struct acpi_device *device = button->adev; 393 392 int state; 394 393 395 394 state = acpi_lid_evaluate_state(device); ··· 398 395 return state; 399 396 400 397 if (state && signal_wakeup) 401 - acpi_pm_wakeup_event(&device->dev); 398 + acpi_pm_wakeup_event(&button->pdev->dev); 402 399 403 - return acpi_lid_notify_state(device, state); 400 + return acpi_lid_notify_state(button, state); 404 401 } 405 402 406 - static void acpi_lid_initialize_state(struct acpi_device *device) 403 + static void acpi_lid_initialize_state(struct acpi_button *button) 407 404 { 408 - struct acpi_button *button = acpi_driver_data(device); 409 - 410 405 switch (lid_init_state) { 411 406 case ACPI_BUTTON_LID_INIT_OPEN: 412 - (void)acpi_lid_notify_state(device, 1); 407 + (void)acpi_lid_notify_state(button, 1); 413 408 break; 414 409 case ACPI_BUTTON_LID_INIT_METHOD: 415 - (void)acpi_lid_update_state(device, false); 410 + (void)acpi_lid_update_state(button, false); 416 411 break; 417 412 case ACPI_BUTTON_LID_INIT_IGNORE: 418 413 default: ··· 422 421 423 422 static void acpi_lid_notify(acpi_handle handle, u32 event, void *data) 424 423 { 425 - struct acpi_device *device = data; 426 - struct acpi_button *button; 424 + struct acpi_button *button = data; 425 + struct acpi_device *device = button->adev; 427 426 428 427 if (event != ACPI_BUTTON_NOTIFY_STATUS) { 429 428 acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", ··· 431 430 return; 432 431 } 433 432 434 - button = acpi_driver_data(device); 435 433 if (!button->lid_state_initialized) 436 434 return; 437 435 438 - acpi_lid_update_state(device, true); 436 + acpi_lid_update_state(button, true); 439 437 } 440 438 441 439 static void acpi_button_notify(acpi_handle handle, u32 event, void *data) 442 440 { 443 - struct acpi_device *device = data; 444 - struct acpi_button *button; 441 + struct acpi_button *button = data; 442 + struct acpi_device *device = button->adev; 445 443 struct input_dev *input; 446 444 int keycode; 447 445 ··· 455 455 return; 456 456 } 457 457 458 - acpi_pm_wakeup_event(&device->dev); 458 + acpi_pm_wakeup_event(&button->pdev->dev); 459 459 460 - button = acpi_driver_data(device); 461 460 if (button->suspended || event == ACPI_BUTTON_NOTIFY_WAKE) 462 461 return; 463 462 ··· 487 488 #ifdef CONFIG_PM_SLEEP 488 489 static int acpi_button_suspend(struct device *dev) 489 490 { 490 - struct acpi_device *device = to_acpi_device(dev); 491 - struct acpi_button *button = acpi_driver_data(device); 491 + struct acpi_button *button = dev_get_drvdata(dev); 492 492 493 493 button->suspended = true; 494 494 return 0; ··· 495 497 496 498 static int acpi_button_resume(struct device *dev) 497 499 { 500 + struct acpi_button *button = dev_get_drvdata(dev); 501 + struct acpi_device *device = ACPI_COMPANION(dev); 498 502 struct input_dev *input; 499 - struct acpi_device *device = to_acpi_device(dev); 500 - struct acpi_button *button = acpi_driver_data(device); 501 503 502 504 button->suspended = false; 503 505 if (button->type == ACPI_BUTTON_TYPE_LID) { 504 506 button->last_state = !!acpi_lid_evaluate_state(device); 505 507 button->last_time = ktime_get(); 506 - acpi_lid_initialize_state(device); 508 + acpi_lid_initialize_state(button); 507 509 } 508 510 509 511 if (button->type == ACPI_BUTTON_TYPE_POWER) { ··· 519 521 520 522 static int acpi_lid_input_open(struct input_dev *input) 521 523 { 522 - struct acpi_device *device = input_get_drvdata(input); 523 - struct acpi_button *button = acpi_driver_data(device); 524 + struct acpi_button *button = input_get_drvdata(input); 525 + struct acpi_device *device = button->adev; 524 526 525 527 button->last_state = !!acpi_lid_evaluate_state(device); 526 528 button->last_time = ktime_get(); 527 - acpi_lid_initialize_state(device); 529 + acpi_lid_initialize_state(button); 528 530 529 531 return 0; 530 532 } 531 533 532 - static int acpi_button_add(struct acpi_device *device) 534 + static int acpi_button_probe(struct platform_device *pdev) 533 535 { 536 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 534 537 acpi_notify_handler handler; 535 538 struct acpi_button *button; 536 539 struct input_dev *input; ··· 548 549 if (!button) 549 550 return -ENOMEM; 550 551 551 - device->driver_data = button; 552 + platform_set_drvdata(pdev, button); 552 553 554 + button->pdev = pdev; 555 + button->adev = device; 553 556 button->input = input = input_allocate_device(); 554 557 if (!input) { 555 558 error = -ENOMEM; ··· 588 587 } 589 588 590 589 if (!error) 591 - error = acpi_button_add_fs(device); 590 + error = acpi_button_add_fs(button); 592 591 593 592 if (error) { 594 593 input_free_device(input); ··· 601 600 input->phys = button->phys; 602 601 input->id.bustype = BUS_HOST; 603 602 input->id.product = button->type; 604 - input->dev.parent = &device->dev; 603 + input->dev.parent = &pdev->dev; 605 604 606 605 switch (button->type) { 607 606 case ACPI_BUTTON_TYPE_POWER: ··· 618 617 break; 619 618 } 620 619 621 - input_set_drvdata(input, device); 620 + input_set_drvdata(input, button); 622 621 error = input_register_device(input); 623 622 if (error) { 624 623 input_free_device(input); ··· 629 628 case ACPI_BUS_TYPE_POWER_BUTTON: 630 629 status = acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, 631 630 acpi_button_event, 632 - device); 631 + button); 633 632 break; 634 633 case ACPI_BUS_TYPE_SLEEP_BUTTON: 635 634 status = acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, 636 635 acpi_button_event, 637 - device); 636 + button); 638 637 break; 639 638 default: 640 639 status = acpi_install_notify_handler(device->handle, 641 640 ACPI_ALL_NOTIFY, handler, 642 - device); 641 + button); 643 642 break; 644 643 } 645 644 if (ACPI_FAILURE(status)) { ··· 655 654 lid_device = device; 656 655 } 657 656 658 - device_init_wakeup(&device->dev, true); 657 + device_init_wakeup(&pdev->dev, true); 659 658 pr_info("%s [%s]\n", name, acpi_device_bid(device)); 660 659 return 0; 661 660 662 661 err_input_unregister: 663 662 input_unregister_device(input); 664 663 err_remove_fs: 665 - acpi_button_remove_fs(device); 664 + acpi_button_remove_fs(button); 666 665 err_free_button: 667 666 kfree(button); 668 667 return error; 669 668 } 670 669 671 - static void acpi_button_remove(struct acpi_device *device) 670 + static void acpi_button_remove(struct platform_device *pdev) 672 671 { 673 - struct acpi_button *button = acpi_driver_data(device); 672 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 673 + struct acpi_button *button = platform_get_drvdata(pdev); 674 674 675 675 switch (device->device_type) { 676 676 case ACPI_BUS_TYPE_POWER_BUTTON: ··· 691 689 } 692 690 acpi_os_wait_events_complete(); 693 691 694 - acpi_button_remove_fs(device); 692 + acpi_button_remove_fs(button); 695 693 input_unregister_device(button->input); 696 694 kfree(button); 697 695 } ··· 730 728 NULL, 0644); 731 729 MODULE_PARM_DESC(lid_init_state, "Behavior for reporting LID initial state"); 732 730 733 - static int acpi_button_register_driver(struct acpi_driver *driver) 731 + static int __init acpi_button_init(void) 734 732 { 735 733 const struct dmi_system_id *dmi_id; 736 734 ··· 746 744 * Modules such as nouveau.ko and i915.ko have a link time dependency 747 745 * on acpi_lid_open(), and would therefore not be loadable on ACPI 748 746 * capable kernels booted in non-ACPI mode if the return value of 749 - * acpi_bus_register_driver() is returned from here with ACPI disabled 747 + * platform_driver_register() is returned from here with ACPI disabled 750 748 * when this driver is built as a module. 751 749 */ 752 750 if (acpi_disabled) 753 751 return 0; 754 752 755 - return acpi_bus_register_driver(driver); 753 + return platform_driver_register(&acpi_button_driver); 756 754 } 757 755 758 - static void acpi_button_unregister_driver(struct acpi_driver *driver) 756 + static void __exit acpi_button_exit(void) 759 757 { 760 758 if (!acpi_disabled) 761 - acpi_bus_unregister_driver(driver); 759 + platform_driver_unregister(&acpi_button_driver); 762 760 } 763 761 764 - module_driver(acpi_button_driver, acpi_button_register_driver, 765 - acpi_button_unregister_driver); 762 + module_init(acpi_button_init); 763 + module_exit(acpi_button_exit);
+1 -1
drivers/acpi/cppc_acpi.c
··· 1609 1609 */ 1610 1610 int cppc_set_epp(int cpu, u64 epp_val) 1611 1611 { 1612 - if (epp_val > CPPC_ENERGY_PERF_MAX) 1612 + if (epp_val > CPPC_EPP_ENERGY_EFFICIENCY_PREF) 1613 1613 return -EINVAL; 1614 1614 1615 1615 return cppc_set_reg_val(cpu, ENERGY_PERF, epp_val);
+12 -4
drivers/acpi/device_pm.c
··· 586 586 goto out; 587 587 588 588 mutex_lock(&acpi_pm_notifier_lock); 589 - adev->wakeup.ws = wakeup_source_register(&adev->dev, 590 - dev_name(&adev->dev)); 589 + adev->wakeup.ws = wakeup_source_register(dev, dev_name(&adev->dev)); 591 590 adev->wakeup.context.dev = dev; 592 591 adev->wakeup.context.func = func; 593 592 adev->wakeup.flags.notifier_present = true; ··· 1251 1252 return 0; 1252 1253 1253 1254 if (pm && !pm->resume_early) { 1254 - dev_dbg(dev, "postponing D0 transition to normal resume stage\n"); 1255 + dev_dbg(dev, "Postponing ACPI PM to normal resume stage\n"); 1255 1256 return 0; 1256 1257 } 1257 1258 ··· 1273 1274 int ret = 0; 1274 1275 1275 1276 if (!dev_pm_skip_resume(dev) && pm && !pm->resume_early) { 1276 - dev_dbg(dev, "executing postponed D0 transition\n"); 1277 + dev_dbg(dev, "Applying postponed ACPI PM\n"); 1277 1278 ret = acpi_dev_resume(dev); 1278 1279 } 1279 1280 ··· 1455 1456 1456 1457 if (!adev || !acpi_match_device_ids(adev, special_pm_ids)) 1457 1458 return 0; 1459 + 1460 + /* 1461 + * Skip devices whose ACPI companions don't support power management and 1462 + * don't have a wakeup GPE. 1463 + */ 1464 + if (!acpi_device_power_manageable(adev) && !acpi_device_can_wakeup(adev)) { 1465 + dev_dbg(dev, "No ACPI power management or wakeup GPE\n"); 1466 + return 0; 1467 + } 1458 1468 1459 1469 /* 1460 1470 * Only attach the power domain to the first device if the
+41 -10
drivers/acpi/device_sysfs.c
··· 27 27 if (result) 28 28 return result; 29 29 30 - result = sprintf(buf, "%s\n", (char *)path.pointer); 30 + result = sysfs_emit(buf, "%s\n", (char *)path.pointer); 31 31 kfree(path.pointer); 32 32 return result; 33 33 } ··· 347 347 if (ret) 348 348 return ret; 349 349 350 - return sprintf(buf, "%s\n", acpi_power_state_string(state)); 350 + return sysfs_emit(buf, "%s\n", acpi_power_state_string(state)); 351 351 } 352 352 353 353 static DEVICE_ATTR_RO(real_power_state); ··· 357 357 { 358 358 struct acpi_device *adev = to_acpi_device(dev); 359 359 360 - return sprintf(buf, "%s\n", acpi_power_state_string(adev->power.state)); 360 + return sysfs_emit(buf, "%s\n", acpi_power_state_string(adev->power.state)); 361 361 } 362 362 363 363 static DEVICE_ATTR_RO(power_state); ··· 399 399 { 400 400 struct acpi_device *acpi_dev = to_acpi_device(dev); 401 401 402 - return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev)); 402 + return sysfs_emit(buf, "%s\n", acpi_device_hid(acpi_dev)); 403 403 } 404 404 static DEVICE_ATTR_RO(hid); 405 + 406 + static ssize_t cid_show(struct device *dev, struct device_attribute *attr, 407 + char *buf) 408 + { 409 + struct acpi_device *acpi_dev = to_acpi_device(dev); 410 + struct acpi_device_info *info = NULL; 411 + ssize_t len = 0; 412 + 413 + acpi_get_object_info(acpi_dev->handle, &info); 414 + if (!info) 415 + return 0; 416 + 417 + if (info->valid & ACPI_VALID_CID) { 418 + struct acpi_pnp_device_id_list *cid_list = &info->compatible_id_list; 419 + int i; 420 + 421 + for (i = 0; i < cid_list->count - 1; i++) 422 + len += sysfs_emit_at(buf, len, "%s,", cid_list->ids[i].string); 423 + 424 + len += sysfs_emit_at(buf, len, "%s\n", cid_list->ids[i].string); 425 + } 426 + 427 + kfree(info); 428 + 429 + return len; 430 + } 431 + static DEVICE_ATTR_RO(cid); 405 432 406 433 static ssize_t uid_show(struct device *dev, 407 434 struct device_attribute *attr, char *buf) 408 435 { 409 436 struct acpi_device *acpi_dev = to_acpi_device(dev); 410 437 411 - return sprintf(buf, "%s\n", acpi_device_uid(acpi_dev)); 438 + return sysfs_emit(buf, "%s\n", acpi_device_uid(acpi_dev)); 412 439 } 413 440 static DEVICE_ATTR_RO(uid); 414 441 ··· 445 418 struct acpi_device *acpi_dev = to_acpi_device(dev); 446 419 447 420 if (acpi_dev->pnp.bus_address > U32_MAX) 448 - return sprintf(buf, "0x%016llx\n", acpi_dev->pnp.bus_address); 421 + return sysfs_emit(buf, "0x%016llx\n", acpi_dev->pnp.bus_address); 449 422 else 450 - return sprintf(buf, "0x%08llx\n", acpi_dev->pnp.bus_address); 423 + return sysfs_emit(buf, "0x%08llx\n", acpi_dev->pnp.bus_address); 451 424 } 452 425 static DEVICE_ATTR_RO(adr); 453 426 ··· 509 482 if (ACPI_FAILURE(status)) 510 483 return -EIO; 511 484 512 - return sprintf(buf, "%llu\n", sun); 485 + return sysfs_emit(buf, "%llu\n", sun); 513 486 } 514 487 static DEVICE_ATTR_RO(sun); 515 488 ··· 525 498 if (ACPI_FAILURE(status)) 526 499 return -EIO; 527 500 528 - return sprintf(buf, "%llu\n", hrv); 501 + return sysfs_emit(buf, "%llu\n", hrv); 529 502 } 530 503 static DEVICE_ATTR_RO(hrv); 531 504 ··· 540 513 if (ACPI_FAILURE(status)) 541 514 return -EIO; 542 515 543 - return sprintf(buf, "%llu\n", sta); 516 + return sysfs_emit(buf, "%llu\n", sta); 544 517 } 545 518 static DEVICE_ATTR_RO(status); 546 519 547 520 static struct attribute *acpi_attrs[] = { 548 521 &dev_attr_path.attr, 549 522 &dev_attr_hid.attr, 523 + &dev_attr_cid.attr, 550 524 &dev_attr_modalias.attr, 551 525 &dev_attr_description.attr, 552 526 &dev_attr_adr.attr, ··· 589 561 590 562 if (attr == &dev_attr_status) 591 563 return acpi_has_method(dev->handle, "_STA"); 564 + 565 + if (attr == &dev_attr_cid) 566 + return acpi_has_method(dev->handle, "_CID"); 592 567 593 568 /* 594 569 * If device has _EJ0, 'eject' file is created that is used to trigger
+20 -34
drivers/acpi/ec.c
··· 23 23 #include <linux/delay.h> 24 24 #include <linux/interrupt.h> 25 25 #include <linux/list.h> 26 + #include <linux/platform_device.h> 26 27 #include <linux/printk.h> 27 28 #include <linux/spinlock.h> 28 29 #include <linux/slab.h> ··· 1675 1674 return ret; 1676 1675 } 1677 1676 1678 - static int acpi_ec_add(struct acpi_device *device) 1677 + static int acpi_ec_probe(struct platform_device *pdev) 1679 1678 { 1679 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1680 1680 struct acpi_ec *ec; 1681 1681 int ret; 1682 1682 ··· 1732 1730 acpi_handle_info(ec->handle, 1733 1731 "EC: Used to handle transactions and events\n"); 1734 1732 1735 - device->driver_data = ec; 1733 + platform_set_drvdata(pdev, ec); 1736 1734 1737 1735 ret = !!request_region(ec->data_addr, 1, "EC data"); 1738 1736 WARN(!ret, "Could not request EC data io port 0x%lx", ec->data_addr); ··· 1752 1750 return ret; 1753 1751 } 1754 1752 1755 - static void acpi_ec_remove(struct acpi_device *device) 1753 + static void acpi_ec_remove(struct platform_device *pdev) 1756 1754 { 1757 - struct acpi_ec *ec; 1755 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1756 + struct acpi_ec *ec = platform_get_drvdata(pdev); 1758 1757 1759 - if (!device) 1760 - return; 1761 - 1762 - ec = acpi_driver_data(device); 1763 1758 release_region(ec->data_addr, 1); 1764 1759 release_region(ec->command_addr, 1); 1765 1760 device->driver_data = NULL; ··· 2094 2095 #ifdef CONFIG_PM_SLEEP 2095 2096 static int acpi_ec_suspend(struct device *dev) 2096 2097 { 2097 - struct acpi_ec *ec = 2098 - acpi_driver_data(to_acpi_device(dev)); 2098 + struct acpi_ec *ec = dev_get_drvdata(dev); 2099 2099 2100 2100 if (!pm_suspend_no_platform() && ec_freeze_events) 2101 2101 acpi_ec_disable_event(ec); ··· 2103 2105 2104 2106 static int acpi_ec_suspend_noirq(struct device *dev) 2105 2107 { 2106 - struct acpi_ec *ec = acpi_driver_data(to_acpi_device(dev)); 2108 + struct acpi_ec *ec = dev_get_drvdata(dev); 2107 2109 2108 2110 /* 2109 2111 * The SCI handler doesn't run at this point, so the GPE can be ··· 2120 2122 2121 2123 static int acpi_ec_resume_noirq(struct device *dev) 2122 2124 { 2123 - struct acpi_ec *ec = acpi_driver_data(to_acpi_device(dev)); 2125 + struct acpi_ec *ec = dev_get_drvdata(dev); 2124 2126 2125 2127 acpi_ec_leave_noirq(ec); 2126 2128 ··· 2133 2135 2134 2136 static int acpi_ec_resume(struct device *dev) 2135 2137 { 2136 - struct acpi_ec *ec = 2137 - acpi_driver_data(to_acpi_device(dev)); 2138 + struct acpi_ec *ec = dev_get_drvdata(dev); 2138 2139 2139 2140 acpi_ec_enable_event(ec); 2140 2141 return 0; ··· 2262 2265 NULL, 0644); 2263 2266 MODULE_PARM_DESC(ec_event_clearing, "Assumed SCI_EVT clearing timing"); 2264 2267 2265 - static struct acpi_driver acpi_ec_driver = { 2266 - .name = "ec", 2267 - .class = ACPI_EC_CLASS, 2268 - .ids = ec_device_ids, 2269 - .ops = { 2270 - .add = acpi_ec_add, 2271 - .remove = acpi_ec_remove, 2272 - }, 2273 - .drv.pm = &acpi_ec_pm, 2268 + static struct platform_driver acpi_ec_driver = { 2269 + .probe = acpi_ec_probe, 2270 + .remove = acpi_ec_remove, 2271 + .driver = { 2272 + .name = "acpi-ec", 2273 + .acpi_match_table = ec_device_ids, 2274 + .pm = &acpi_ec_pm, 2275 + }, 2274 2276 }; 2275 2277 2276 2278 static void acpi_ec_destroy_workqueues(void) ··· 2374 2378 } 2375 2379 2376 2380 /* Driver must be registered after acpi_ec_init_workqueues(). */ 2377 - acpi_bus_register_driver(&acpi_ec_driver); 2381 + platform_driver_register(&acpi_ec_driver); 2378 2382 2379 2383 acpi_ec_ecdt_start(); 2380 2384 } 2381 - 2382 - /* EC driver currently not unloadable */ 2383 - #if 0 2384 - static void __exit acpi_ec_exit(void) 2385 - { 2386 - 2387 - acpi_bus_unregister_driver(&acpi_ec_driver); 2388 - acpi_ec_destroy_workqueues(); 2389 - } 2390 - #endif /* 0 */
+13 -10
drivers/acpi/hed.c
··· 13 13 #include <linux/module.h> 14 14 #include <linux/init.h> 15 15 #include <linux/acpi.h> 16 + #include <linux/platform_device.h> 16 17 #include <acpi/hed.h> 17 18 18 19 static const struct acpi_device_id acpi_hed_ids[] = { ··· 48 47 blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL); 49 48 } 50 49 51 - static int acpi_hed_add(struct acpi_device *device) 50 + static int acpi_hed_probe(struct platform_device *pdev) 52 51 { 52 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 53 53 int err; 54 54 55 55 /* Only one hardware error device */ ··· 66 64 return err; 67 65 } 68 66 69 - static void acpi_hed_remove(struct acpi_device *device) 67 + static void acpi_hed_remove(struct platform_device *pdev) 70 68 { 69 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 70 + 71 71 acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, 72 72 acpi_hed_notify); 73 73 hed_handle = NULL; 74 74 } 75 75 76 - static struct acpi_driver acpi_hed_driver = { 77 - .name = "hardware_error_device", 78 - .class = "hardware_error", 79 - .ids = acpi_hed_ids, 80 - .ops = { 81 - .add = acpi_hed_add, 82 - .remove = acpi_hed_remove, 76 + static struct platform_driver acpi_hed_driver = { 77 + .probe = acpi_hed_probe, 78 + .remove = acpi_hed_remove, 79 + .driver = { 80 + .name = "acpi-hardware-error-device", 81 + .acpi_match_table = acpi_hed_ids, 83 82 }, 84 83 }; 85 84 86 85 static int __init acpi_hed_driver_init(void) 87 86 { 88 - return acpi_bus_register_driver(&acpi_hed_driver); 87 + return platform_driver_register(&acpi_hed_driver); 89 88 } 90 89 subsys_initcall(acpi_hed_driver_init); 91 90
+28 -19
drivers/acpi/nfit/core.c
··· 2 2 /* 3 3 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved. 4 4 */ 5 + #include <linux/platform_device.h> 5 6 #include <linux/list_sort.h> 6 7 #include <linux/libnvdimm.h> 7 8 #include <linux/module.h> ··· 90 89 static struct acpi_device *to_acpi_dev(struct acpi_nfit_desc *acpi_desc) 91 90 { 92 91 struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc; 92 + struct acpi_device *adev; 93 93 94 - /* 95 - * If provider == 'ACPI.NFIT' we can assume 'dev' is a struct 96 - * acpi_device. 97 - */ 94 + /* If provider == 'ACPI.NFIT', a struct acpi_device is there. */ 98 95 if (!nd_desc->provider_name 99 96 || strcmp(nd_desc->provider_name, "ACPI.NFIT") != 0) 100 97 return NULL; 101 98 99 + /* 100 + * But it can be the ACPI companion of acpi_desc->dev when it cones from 101 + * acpi_nfit_probe(). 102 + */ 103 + adev = ACPI_COMPANION(acpi_desc->dev); 104 + if (adev) 105 + return adev; 106 + 107 + /* Or it is acpi_desc->dev itself when it comes from nfit_ctl_test(). */ 102 108 return to_acpi_device(acpi_desc->dev); 103 109 } 104 110 ··· 3291 3283 3292 3284 static void acpi_nfit_notify(acpi_handle handle, u32 event, void *data) 3293 3285 { 3294 - struct acpi_device *adev = data; 3286 + struct device *dev = data; 3295 3287 3296 - device_lock(&adev->dev); 3297 - __acpi_nfit_notify(&adev->dev, handle, event); 3298 - device_unlock(&adev->dev); 3288 + device_lock(dev); 3289 + __acpi_nfit_notify(dev, handle, event); 3290 + device_unlock(dev); 3299 3291 } 3300 3292 3301 3293 static void acpi_nfit_remove_notify_handler(void *data) ··· 3336 3328 } 3337 3329 EXPORT_SYMBOL_GPL(acpi_nfit_shutdown); 3338 3330 3339 - static int acpi_nfit_add(struct acpi_device *adev) 3331 + static int acpi_nfit_probe(struct platform_device *pdev) 3340 3332 { 3341 3333 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL }; 3342 3334 struct acpi_nfit_desc *acpi_desc; 3343 - struct device *dev = &adev->dev; 3335 + struct device *dev = &pdev->dev; 3336 + struct acpi_device *adev = ACPI_COMPANION(dev); 3344 3337 struct acpi_table_header *tbl; 3345 3338 acpi_status status = AE_OK; 3346 3339 acpi_size sz; 3347 3340 int rc = 0; 3348 3341 3349 3342 rc = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY, 3350 - acpi_nfit_notify, adev); 3343 + acpi_nfit_notify, dev); 3351 3344 if (rc) 3352 3345 return rc; 3353 3346 ··· 3378 3369 acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL); 3379 3370 if (!acpi_desc) 3380 3371 return -ENOMEM; 3381 - acpi_nfit_desc_init(acpi_desc, &adev->dev); 3372 + acpi_nfit_desc_init(acpi_desc, dev); 3382 3373 3383 3374 /* Save the acpi header for exporting the revision via sysfs */ 3384 3375 acpi_desc->acpi_header = *tbl; ··· 3483 3474 }; 3484 3475 MODULE_DEVICE_TABLE(acpi, acpi_nfit_ids); 3485 3476 3486 - static struct acpi_driver acpi_nfit_driver = { 3487 - .name = KBUILD_MODNAME, 3488 - .ids = acpi_nfit_ids, 3489 - .ops = { 3490 - .add = acpi_nfit_add, 3477 + static struct platform_driver acpi_nfit_driver = { 3478 + .probe = acpi_nfit_probe, 3479 + .driver = { 3480 + .name = "acpi-nfit", 3481 + .acpi_match_table = acpi_nfit_ids, 3491 3482 }, 3492 3483 }; 3493 3484 ··· 3525 3516 return -ENOMEM; 3526 3517 3527 3518 nfit_mce_register(); 3528 - ret = acpi_bus_register_driver(&acpi_nfit_driver); 3519 + ret = platform_driver_register(&acpi_nfit_driver); 3529 3520 if (ret) { 3530 3521 nfit_mce_unregister(); 3531 3522 destroy_workqueue(nfit_wq); ··· 3538 3529 static __exit void nfit_exit(void) 3539 3530 { 3540 3531 nfit_mce_unregister(); 3541 - acpi_bus_unregister_driver(&acpi_nfit_driver); 3532 + platform_driver_unregister(&acpi_nfit_driver); 3542 3533 destroy_workqueue(nfit_wq); 3543 3534 WARN_ON(!list_empty(&acpi_descs)); 3544 3535 }
+1 -1
drivers/acpi/pci_root.c
··· 738 738 if (no_aspm) 739 739 pcie_no_aspm(); 740 740 741 - pci_acpi_add_bus_pm_notifier(device); 741 + pci_acpi_add_root_pm_notifier(device, root); 742 742 device_set_wakeup_capable(root->bus->bridge, device->wakeup.flags.valid); 743 743 744 744 if (hotadd) {
+5 -5
drivers/acpi/pci_slot.c
··· 42 42 check_slot(acpi_handle handle, unsigned long long *sun) 43 43 { 44 44 int device = -1; 45 - unsigned long long adr, sta; 45 + unsigned long long sta; 46 46 acpi_status status; 47 + u64 adr; 47 48 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 48 49 49 50 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); ··· 57 56 goto out; 58 57 } 59 58 60 - status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); 61 - if (ACPI_FAILURE(status)) { 62 - pr_debug("_ADR returned %d on %s\n", 63 - status, (char *)buffer.pointer); 59 + if (acpi_get_local_u64_address(handle, &adr)) { 60 + pr_debug("_ADR returned with failure on %s\n", 61 + (char *)buffer.pointer); 64 62 goto out; 65 63 } 66 64
+10 -3
drivers/acpi/processor_driver.c
··· 166 166 if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS)) 167 167 dev_dbg(&device->dev, "CPPC data invalid or not present\n"); 168 168 169 - if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver) 170 - acpi_processor_power_init(pr); 169 + acpi_processor_power_init(pr); 171 170 172 171 acpi_pss_perf_init(pr); 173 172 ··· 258 259 acpi_processor_ignore_ppc_init(); 259 260 } 260 261 262 + acpi_processor_register_idle_driver(); 263 + 261 264 result = driver_register(&acpi_processor_driver); 262 265 if (result < 0) 263 - return result; 266 + goto unregister_idle_drv; 264 267 265 268 result = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, 266 269 "acpi/cpu-drv:online", ··· 284 283 acpi_idle_rescan_dead_smt_siblings(); 285 284 286 285 return 0; 286 + 287 287 err: 288 288 driver_unregister(&acpi_processor_driver); 289 + 290 + unregister_idle_drv: 291 + acpi_processor_unregister_idle_driver(); 292 + 289 293 return result; 290 294 } 291 295 ··· 308 302 cpuhp_remove_state_nocalls(hp_online); 309 303 cpuhp_remove_state_nocalls(CPUHP_ACPI_CPUDRV_DEAD); 310 304 driver_unregister(&acpi_processor_driver); 305 + acpi_processor_unregister_idle_driver(); 311 306 } 312 307 313 308 module_init(acpi_processor_driver_init);
+95 -67
drivers/acpi/processor_idle.c
··· 51 51 52 52 static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device); 53 53 54 - struct cpuidle_driver acpi_idle_driver = { 54 + static struct cpuidle_driver acpi_idle_driver = { 55 55 .name = "acpi_idle", 56 56 .owner = THIS_MODULE, 57 57 }; ··· 946 946 lpi_state->entry_method = ACPI_CSTATE_INTEGER; 947 947 lpi_state->address = obj->integer.value; 948 948 } else { 949 + pr_debug("Entry method of state-%d is invalid, disable it.\n", 950 + state_idx); 949 951 continue; 950 952 } 951 953 ··· 1180 1178 return -EINVAL; 1181 1179 } 1182 1180 1183 - static int acpi_processor_setup_lpi_states(struct acpi_processor *pr) 1181 + static void acpi_processor_setup_lpi_states(struct acpi_processor *pr) 1184 1182 { 1185 1183 int i; 1186 1184 struct acpi_lpi_state *lpi; ··· 1188 1186 struct cpuidle_driver *drv = &acpi_idle_driver; 1189 1187 1190 1188 if (!pr->flags.has_lpi) 1191 - return -EOPNOTSUPP; 1189 + return; 1192 1190 1193 1191 for (i = 0; i < pr->power.count && i < CPUIDLE_STATE_MAX; i++) { 1194 1192 lpi = &pr->power.lpi_states[i]; ··· 1206 1204 } 1207 1205 1208 1206 drv->state_count = i; 1209 - 1210 - return 0; 1211 1207 } 1212 1208 1213 1209 /** ··· 1214 1214 * 1215 1215 * @pr: the ACPI processor 1216 1216 */ 1217 - static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr) 1217 + static void acpi_processor_setup_cpuidle_states(struct acpi_processor *pr) 1218 1218 { 1219 1219 int i; 1220 1220 struct cpuidle_driver *drv = &acpi_idle_driver; 1221 1221 1222 1222 if (!pr->flags.power_setup_done || !pr->flags.power) 1223 - return -EINVAL; 1223 + return; 1224 1224 1225 1225 drv->safe_state_index = -1; 1226 1226 for (i = ACPI_IDLE_STATE_START; i < CPUIDLE_STATE_MAX; i++) { ··· 1228 1228 drv->states[i].desc[0] = '\0'; 1229 1229 } 1230 1230 1231 - if (pr->flags.has_lpi) 1232 - return acpi_processor_setup_lpi_states(pr); 1231 + if (pr->flags.has_lpi) { 1232 + acpi_processor_setup_lpi_states(pr); 1233 + return; 1234 + } 1233 1235 1234 1236 acpi_processor_setup_cstates(pr); 1235 - return 0; 1236 1237 } 1237 1238 1238 1239 /** 1239 - * acpi_processor_setup_cpuidle_dev - prepares and configures CPUIDLE 1240 + * acpi_processor_setup_cpuidle_dev - configures CPUIDLE 1240 1241 * device i.e. per-cpu data 1241 1242 * 1242 1243 * @pr: the ACPI processor 1243 1244 * @dev : the cpuidle device 1244 1245 */ 1245 - static int acpi_processor_setup_cpuidle_dev(struct acpi_processor *pr, 1246 - struct cpuidle_device *dev) 1246 + static void acpi_processor_setup_cpuidle_dev(struct acpi_processor *pr, 1247 + struct cpuidle_device *dev) 1247 1248 { 1248 1249 if (!pr->flags.power_setup_done || !pr->flags.power || !dev) 1249 - return -EINVAL; 1250 + return; 1250 1251 1251 1252 dev->cpu = pr->id; 1252 - if (pr->flags.has_lpi) 1253 - return acpi_processor_ffh_lpi_probe(pr->id); 1254 - 1255 - acpi_processor_setup_cpuidle_cx(pr, dev); 1256 - return 0; 1253 + if (!pr->flags.has_lpi) 1254 + acpi_processor_setup_cpuidle_cx(pr, dev); 1257 1255 } 1258 1256 1259 1257 static int acpi_processor_get_power_info(struct acpi_processor *pr) ··· 1260 1262 1261 1263 ret = acpi_processor_get_lpi_info(pr); 1262 1264 if (ret) 1263 - ret = acpi_processor_get_cstate_info(pr); 1265 + return acpi_processor_get_cstate_info(pr); 1266 + 1267 + if (pr->flags.has_lpi) { 1268 + ret = acpi_processor_ffh_lpi_probe(pr->id); 1269 + if (ret) 1270 + pr_err("CPU%u: Invalid FFH LPI data\n", pr->id); 1271 + } 1264 1272 1265 1273 return ret; 1266 1274 } ··· 1351 1347 return 0; 1352 1348 } 1353 1349 1354 - static int acpi_processor_registered; 1355 - 1356 - int acpi_processor_power_init(struct acpi_processor *pr) 1350 + void acpi_processor_register_idle_driver(void) 1357 1351 { 1358 - int retval; 1352 + struct acpi_processor *pr; 1353 + int ret = -ENODEV; 1354 + int cpu; 1355 + 1356 + /* 1357 + * ACPI idle driver is used by all possible CPUs. 1358 + * Use the processor power info of one in them to set up idle states. 1359 + * Note that the existing idle handler will be used on platforms that 1360 + * only support C1. 1361 + */ 1362 + for_each_possible_cpu(cpu) { 1363 + pr = per_cpu(processors, cpu); 1364 + if (!pr) 1365 + continue; 1366 + 1367 + acpi_processor_cstate_first_run_checks(); 1368 + ret = acpi_processor_get_power_info(pr); 1369 + if (!ret) { 1370 + pr->flags.power_setup_done = 1; 1371 + acpi_processor_setup_cpuidle_states(pr); 1372 + break; 1373 + } 1374 + } 1375 + 1376 + if (ret) { 1377 + pr_debug("No ACPI power information from any CPUs.\n"); 1378 + return; 1379 + } 1380 + 1381 + ret = cpuidle_register_driver(&acpi_idle_driver); 1382 + if (ret) { 1383 + pr_debug("register %s failed.\n", acpi_idle_driver.name); 1384 + return; 1385 + } 1386 + pr_debug("%s registered with cpuidle.\n", acpi_idle_driver.name); 1387 + } 1388 + 1389 + void acpi_processor_unregister_idle_driver(void) 1390 + { 1391 + cpuidle_unregister_driver(&acpi_idle_driver); 1392 + } 1393 + 1394 + void acpi_processor_power_init(struct acpi_processor *pr) 1395 + { 1359 1396 struct cpuidle_device *dev; 1360 1397 1398 + /* 1399 + * The code below only works if the current cpuidle driver is the ACPI 1400 + * idle driver. 1401 + */ 1402 + if (cpuidle_get_driver() != &acpi_idle_driver) 1403 + return; 1404 + 1361 1405 if (disabled_by_idle_boot_param()) 1362 - return 0; 1406 + return; 1363 1407 1364 1408 acpi_processor_cstate_first_run_checks(); 1365 1409 1366 1410 if (!acpi_processor_get_power_info(pr)) 1367 1411 pr->flags.power_setup_done = 1; 1368 1412 1413 + if (!pr->flags.power) 1414 + return; 1415 + 1416 + dev = kzalloc(sizeof(*dev), GFP_KERNEL); 1417 + if (!dev) 1418 + return; 1419 + 1420 + per_cpu(acpi_cpuidle_device, pr->id) = dev; 1421 + 1422 + acpi_processor_setup_cpuidle_dev(pr, dev); 1423 + 1369 1424 /* 1370 - * Install the idle handler if processor power management is supported. 1371 - * Note that we use previously set idle handler will be used on 1372 - * platforms that only support C1. 1425 + * Register a cpuidle device for this CPU. The cpuidle driver using 1426 + * this device is expected to be registered. 1373 1427 */ 1374 - if (pr->flags.power) { 1375 - /* Register acpi_idle_driver if not already registered */ 1376 - if (!acpi_processor_registered) { 1377 - acpi_processor_setup_cpuidle_states(pr); 1378 - retval = cpuidle_register_driver(&acpi_idle_driver); 1379 - if (retval) 1380 - return retval; 1381 - pr_debug("%s registered with cpuidle\n", 1382 - acpi_idle_driver.name); 1383 - } 1384 - 1385 - dev = kzalloc(sizeof(*dev), GFP_KERNEL); 1386 - if (!dev) 1387 - return -ENOMEM; 1388 - per_cpu(acpi_cpuidle_device, pr->id) = dev; 1389 - 1390 - acpi_processor_setup_cpuidle_dev(pr, dev); 1391 - 1392 - /* Register per-cpu cpuidle_device. Cpuidle driver 1393 - * must already be registered before registering device 1394 - */ 1395 - retval = cpuidle_register_device(dev); 1396 - if (retval) { 1397 - if (acpi_processor_registered == 0) 1398 - cpuidle_unregister_driver(&acpi_idle_driver); 1399 - 1400 - per_cpu(acpi_cpuidle_device, pr->id) = NULL; 1401 - kfree(dev); 1402 - return retval; 1403 - } 1404 - acpi_processor_registered++; 1428 + if (cpuidle_register_device(dev)) { 1429 + per_cpu(acpi_cpuidle_device, pr->id) = NULL; 1430 + kfree(dev); 1405 1431 } 1406 - return 0; 1407 1432 } 1408 1433 1409 - int acpi_processor_power_exit(struct acpi_processor *pr) 1434 + void acpi_processor_power_exit(struct acpi_processor *pr) 1410 1435 { 1411 1436 struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id); 1412 1437 1413 1438 if (disabled_by_idle_boot_param()) 1414 - return 0; 1439 + return; 1415 1440 1416 1441 if (pr->flags.power) { 1417 1442 cpuidle_unregister_device(dev); 1418 - acpi_processor_registered--; 1419 - if (acpi_processor_registered == 0) 1420 - cpuidle_unregister_driver(&acpi_idle_driver); 1421 - 1422 1443 kfree(dev); 1423 1444 } 1424 1445 1425 1446 pr->flags.power_setup_done = 0; 1426 - return 0; 1427 1447 } 1428 1448 1429 1449 MODULE_IMPORT_NS("ACPI_PROCESSOR_IDLE");
+8
drivers/acpi/resource.c
··· 532 532 DMI_MATCH(DMI_BOARD_NAME, "16T90SP"), 533 533 }, 534 534 }, 535 + { 536 + /* JWIPC JVC9100 */ 537 + .matches = { 538 + DMI_MATCH(DMI_BOARD_NAME, "JVC9100"), 539 + }, 540 + }, 535 541 { } 536 542 }; 537 543 ··· 712 706 713 707 static const struct irq_override_cmp override_table[] = { 714 708 { irq1_level_low_skip_override, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false }, 709 + { irq1_level_low_skip_override, 10, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 1, false }, 710 + { irq1_level_low_skip_override, 11, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 1, false }, 715 711 { irq1_edge_low_force_override, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true }, 716 712 }; 717 713
+21 -27
drivers/acpi/sbs.c
··· 19 19 #include <linux/timer.h> 20 20 #include <linux/jiffies.h> 21 21 #include <linux/delay.h> 22 + #include <linux/platform_device.h> 22 23 #include <linux/power_supply.h> 23 24 #include <linux/platform_data/x86/apple.h> 24 25 #include <acpi/battery.h> ··· 96 95 97 96 #define to_acpi_sbs(x) power_supply_get_drvdata(x) 98 97 99 - static void acpi_sbs_remove(struct acpi_device *device); 98 + static void acpi_sbs_remove(struct platform_device *pdev); 100 99 static int acpi_battery_get_state(struct acpi_battery *battery); 101 100 102 101 static inline int battery_scale(int log) ··· 629 628 } 630 629 } 631 630 632 - static int acpi_sbs_add(struct acpi_device *device) 631 + static int acpi_sbs_probe(struct platform_device *pdev) 633 632 { 633 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 634 634 struct acpi_sbs *sbs; 635 635 int result = 0; 636 636 int id; ··· 644 642 645 643 mutex_init(&sbs->lock); 646 644 647 - sbs->hc = acpi_driver_data(acpi_dev_parent(device)); 645 + platform_set_drvdata(pdev, sbs); 646 + 647 + sbs->hc = dev_get_drvdata(pdev->dev.parent); 648 648 sbs->device = device; 649 649 strscpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME); 650 650 strscpy(acpi_device_class(device), ACPI_SBS_CLASS); 651 - device->driver_data = sbs; 652 651 653 652 result = acpi_charger_add(sbs); 654 653 if (result && result != -ENODEV) ··· 673 670 acpi_smbus_register_callback(sbs->hc, acpi_sbs_callback, sbs); 674 671 end: 675 672 if (result) 676 - acpi_sbs_remove(device); 673 + acpi_sbs_remove(pdev); 677 674 return result; 678 675 } 679 676 680 - static void acpi_sbs_remove(struct acpi_device *device) 677 + static void acpi_sbs_remove(struct platform_device *pdev) 681 678 { 682 - struct acpi_sbs *sbs; 679 + struct acpi_sbs *sbs = platform_get_drvdata(pdev); 683 680 int id; 684 681 685 - if (!device) 686 - return; 687 - sbs = acpi_driver_data(device); 688 - if (!sbs) 689 - return; 690 682 mutex_lock(&sbs->lock); 691 683 acpi_smbus_unregister_callback(sbs->hc); 692 684 for (id = 0; id < MAX_SBS_BAT; ++id) ··· 695 697 #ifdef CONFIG_PM_SLEEP 696 698 static int acpi_sbs_resume(struct device *dev) 697 699 { 698 - struct acpi_sbs *sbs; 699 - if (!dev) 700 - return -EINVAL; 701 - sbs = to_acpi_device(dev)->driver_data; 702 - acpi_sbs_callback(sbs); 700 + acpi_sbs_callback(dev_get_drvdata(dev)); 703 701 return 0; 704 702 } 705 703 #else ··· 704 710 705 711 static SIMPLE_DEV_PM_OPS(acpi_sbs_pm, NULL, acpi_sbs_resume); 706 712 707 - static struct acpi_driver acpi_sbs_driver = { 708 - .name = "sbs", 709 - .class = ACPI_SBS_CLASS, 710 - .ids = sbs_device_ids, 711 - .ops = { 712 - .add = acpi_sbs_add, 713 - .remove = acpi_sbs_remove, 714 - }, 715 - .drv.pm = &acpi_sbs_pm, 713 + static struct platform_driver acpi_sbs_driver = { 714 + .probe = acpi_sbs_probe, 715 + .remove = acpi_sbs_remove, 716 + .driver = { 717 + .name = "acpi-sbs", 718 + .acpi_match_table = sbs_device_ids, 719 + .pm = &acpi_sbs_pm, 720 + }, 716 721 }; 717 - module_acpi_driver(acpi_sbs_driver); 722 + 723 + module_platform_driver(acpi_sbs_driver);
+20 -23
drivers/acpi/sbshc.c
··· 13 13 #include <linux/delay.h> 14 14 #include <linux/module.h> 15 15 #include <linux/interrupt.h> 16 + #include <linux/platform_device.h> 17 + 16 18 #include "sbshc.h" 17 19 #include "internal.h" 18 20 ··· 32 30 bool done; 33 31 }; 34 32 35 - static int acpi_smbus_hc_add(struct acpi_device *device); 36 - static void acpi_smbus_hc_remove(struct acpi_device *device); 33 + static int acpi_smbus_hc_probe(struct platform_device *pdev); 34 + static void acpi_smbus_hc_remove(struct platform_device *pdev); 37 35 38 36 static const struct acpi_device_id sbs_device_ids[] = { 39 37 {"ACPI0001", 0}, ··· 43 41 44 42 MODULE_DEVICE_TABLE(acpi, sbs_device_ids); 45 43 46 - static struct acpi_driver acpi_smb_hc_driver = { 47 - .name = "smbus_hc", 48 - .class = ACPI_SMB_HC_CLASS, 49 - .ids = sbs_device_ids, 50 - .ops = { 51 - .add = acpi_smbus_hc_add, 52 - .remove = acpi_smbus_hc_remove, 53 - }, 44 + static struct platform_driver acpi_smb_hc_driver = { 45 + .probe = acpi_smbus_hc_probe, 46 + .remove = acpi_smbus_hc_remove, 47 + .driver = { 48 + .name = "acpi-smbus-hc", 49 + .acpi_match_table = sbs_device_ids, 50 + }, 54 51 }; 55 52 56 53 union acpi_smb_status { ··· 238 237 return 0; 239 238 } 240 239 241 - static int acpi_smbus_hc_add(struct acpi_device *device) 240 + static int acpi_smbus_hc_probe(struct platform_device *pdev) 242 241 { 242 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 243 243 int status; 244 244 unsigned long long val; 245 245 struct acpi_smb_hc *hc; 246 - 247 - if (!device) 248 - return -EINVAL; 249 246 250 247 status = acpi_evaluate_integer(device->handle, "_EC", NULL, &val); 251 248 if (ACPI_FAILURE(status)) { ··· 260 261 mutex_init(&hc->lock); 261 262 init_waitqueue_head(&hc->wait); 262 263 263 - hc->ec = acpi_driver_data(acpi_dev_parent(device)); 264 + platform_set_drvdata(pdev, hc); 265 + 266 + hc->ec = dev_get_drvdata(pdev->dev.parent); 264 267 hc->offset = (val >> 8) & 0xff; 265 268 hc->query_bit = val & 0xff; 266 - device->driver_data = hc; 267 269 268 270 acpi_ec_add_query_handler(hc->ec, hc->query_bit, NULL, smbus_alarm, hc); 269 271 dev_info(&device->dev, "SBS HC: offset = 0x%0x, query_bit = 0x%0x\n", ··· 273 273 return 0; 274 274 } 275 275 276 - static void acpi_smbus_hc_remove(struct acpi_device *device) 276 + static void acpi_smbus_hc_remove(struct platform_device *pdev) 277 277 { 278 - struct acpi_smb_hc *hc; 278 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 279 + struct acpi_smb_hc *hc = platform_get_drvdata(pdev); 279 280 280 - if (!device) 281 - return; 282 - 283 - hc = acpi_driver_data(device); 284 281 acpi_ec_remove_query_handler(hc->ec, hc->query_bit); 285 282 acpi_os_wait_events_complete(); 286 283 kfree(hc); 287 284 device->driver_data = NULL; 288 285 } 289 286 290 - module_acpi_driver(acpi_smb_hc_driver); 287 + module_platform_driver(acpi_smb_hc_driver); 291 288 292 289 MODULE_LICENSE("GPL"); 293 290 MODULE_AUTHOR("Alexey Starikovskiy");
+152 -74
drivers/acpi/scan.c
··· 5 5 6 6 #define pr_fmt(fmt) "ACPI: " fmt 7 7 8 + #include <linux/async.h> 8 9 #include <linux/module.h> 9 10 #include <linux/init.h> 10 11 #include <linux/slab.h> ··· 43 42 DEFINE_MUTEX(acpi_device_lock); 44 43 LIST_HEAD(acpi_wakeup_device_list); 45 44 static DEFINE_MUTEX(acpi_hp_context_lock); 45 + static LIST_HEAD(acpi_scan_system_dev_list); 46 46 47 47 /* 48 48 * The UART device described by the SPCR table is the only object which needs ··· 1000 998 return err; 1001 999 } 1002 1000 1003 - /* Do not use a button for S5 wakeup */ 1004 - #define ACPI_AVOID_WAKE_FROM_S5 BIT(0) 1005 - 1006 1001 static bool acpi_wakeup_gpe_init(struct acpi_device *device) 1007 1002 { 1008 1003 static const struct acpi_device_id button_device_ids[] = { 1009 - {"PNP0C0C", 0}, /* Power button */ 1010 - {"PNP0C0D", ACPI_AVOID_WAKE_FROM_S5}, /* Lid */ 1011 - {"PNP0C0E", ACPI_AVOID_WAKE_FROM_S5}, /* Sleep button */ 1004 + {"PNP0C0D", 0}, /* Lid */ 1005 + {"PNP0C0E", 0}, /* Sleep button */ 1012 1006 {"", 0}, 1013 1007 }; 1014 1008 struct acpi_device_wakeup *wakeup = &device->wakeup; ··· 1013 1015 1014 1016 wakeup->flags.notifier_present = 0; 1015 1017 1016 - /* Power button, Lid switch always enable wakeup */ 1017 1018 match = acpi_match_acpi_device(button_device_ids, device); 1018 - if (match) { 1019 - if ((match->driver_data & ACPI_AVOID_WAKE_FROM_S5) && 1020 - wakeup->sleep_state == ACPI_STATE_S5) 1021 - wakeup->sleep_state = ACPI_STATE_S4; 1022 - acpi_mark_gpe_for_wake(wakeup->gpe_device, wakeup->gpe_number); 1023 - device_set_wakeup_capable(&device->dev, true); 1024 - return true; 1025 - } 1019 + if (match && wakeup->sleep_state == ACPI_STATE_S5) 1020 + wakeup->sleep_state = ACPI_STATE_S4; 1026 1021 1027 1022 status = acpi_setup_gpe_for_wake(device->handle, wakeup->gpe_device, 1028 1023 wakeup->gpe_number); ··· 1285 1294 * The device will get a Linux specific CID added in scan.c to 1286 1295 * identify the device as an ACPI graphics device 1287 1296 * Be aware that the graphics device may not be physically present 1288 - * Use acpi_video_get_capabilities() to detect general ACPI video 1289 - * capabilities of present cards 1290 1297 */ 1291 1298 long acpi_is_video_device(acpi_handle handle) 1292 1299 { ··· 1458 1469 break; 1459 1470 case ACPI_BUS_TYPE_THERMAL: 1460 1471 acpi_add_id(pnp, ACPI_THERMAL_HID); 1472 + pnp->type.platform_id = 1; 1461 1473 break; 1462 1474 case ACPI_BUS_TYPE_POWER_BUTTON: 1463 1475 acpi_add_id(pnp, ACPI_BUTTON_HID_POWERF); ··· 2193 2203 return acpi_bus_check_add(handle, false, (struct acpi_device **)ret_p); 2194 2204 } 2195 2205 2206 + struct acpi_scan_system_dev { 2207 + struct list_head node; 2208 + struct acpi_device *adev; 2209 + }; 2210 + 2211 + static const char * const acpi_system_dev_ids[] = { 2212 + "PNP0C01", /* Memory controller */ 2213 + "PNP0C02", /* Motherboard resource */ 2214 + NULL 2215 + }; 2216 + 2196 2217 static void acpi_default_enumeration(struct acpi_device *device) 2197 2218 { 2198 2219 /* 2199 2220 * Do not enumerate devices with enumeration_by_parent flag set as 2200 2221 * they will be enumerated by their respective parents. 2201 2222 */ 2202 - if (!device->flags.enumeration_by_parent) { 2203 - acpi_create_platform_device(device, NULL); 2204 - acpi_device_set_enumerated(device); 2205 - } else { 2223 + if (device->flags.enumeration_by_parent) { 2206 2224 blocking_notifier_call_chain(&acpi_reconfig_chain, 2207 2225 ACPI_RECONFIG_DEVICE_ADD, device); 2226 + return; 2208 2227 } 2228 + if (match_string(acpi_system_dev_ids, -1, acpi_device_hid(device)) >= 0) { 2229 + struct acpi_scan_system_dev *sd; 2230 + 2231 + /* 2232 + * This is a generic system device, so there is no need to 2233 + * create a platform device for it, but its resources need to be 2234 + * reserved. However, that needs to be done after all of the 2235 + * other device objects have been processed and PCI has claimed 2236 + * BARs in case there are resource conflicts. 2237 + */ 2238 + sd = kmalloc(sizeof(*sd), GFP_KERNEL); 2239 + if (sd) { 2240 + sd->adev = device; 2241 + list_add_tail(&sd->node, &acpi_scan_system_dev_list); 2242 + } 2243 + } else { 2244 + /* For a regular device object, create a platform device. */ 2245 + acpi_create_platform_device(device, NULL); 2246 + } 2247 + acpi_device_set_enumerated(device); 2209 2248 } 2210 2249 2211 2250 static const struct acpi_device_id generic_device_ids[] = { ··· 2339 2320 if (ret < 0) 2340 2321 return 0; 2341 2322 2342 - if (device->pnp.type.platform_id || device->flags.enumeration_by_parent) 2323 + if (device->pnp.type.platform_id || device->pnp.type.backlight || 2324 + device->flags.enumeration_by_parent) 2343 2325 acpi_default_enumeration(device); 2344 2326 else 2345 2327 acpi_device_set_enumerated(device); ··· 2380 2360 return 0; 2381 2361 } 2382 2362 2383 - struct acpi_scan_clear_dep_work { 2384 - struct work_struct work; 2385 - struct acpi_device *adev; 2386 - }; 2387 - 2388 - static void acpi_scan_clear_dep_fn(struct work_struct *work) 2363 + static void acpi_scan_clear_dep_fn(void *dev, async_cookie_t cookie) 2389 2364 { 2390 - struct acpi_scan_clear_dep_work *cdw; 2391 - 2392 - cdw = container_of(work, struct acpi_scan_clear_dep_work, work); 2365 + struct acpi_device *adev = to_acpi_device(dev); 2393 2366 2394 2367 acpi_scan_lock_acquire(); 2395 - acpi_bus_attach(cdw->adev, (void *)true); 2368 + acpi_bus_attach(adev, (void *)true); 2396 2369 acpi_scan_lock_release(); 2397 2370 2398 - acpi_dev_put(cdw->adev); 2399 - kfree(cdw); 2371 + acpi_dev_put(adev); 2400 2372 } 2401 2373 2402 2374 static bool acpi_scan_clear_dep_queue(struct acpi_device *adev) 2403 2375 { 2404 - struct acpi_scan_clear_dep_work *cdw; 2405 - 2406 2376 if (adev->dep_unmet) 2407 2377 return false; 2408 2378 2409 - cdw = kmalloc(sizeof(*cdw), GFP_KERNEL); 2410 - if (!cdw) 2411 - return false; 2412 - 2413 - cdw->adev = adev; 2414 - INIT_WORK(&cdw->work, acpi_scan_clear_dep_fn); 2415 2379 /* 2416 - * Since the work function may block on the lock until the entire 2417 - * initial enumeration of devices is complete, put it into the unbound 2418 - * workqueue. 2380 + * Async schedule the deferred acpi_scan_clear_dep_fn() since: 2381 + * - acpi_bus_attach() needs to hold acpi_scan_lock which cannot 2382 + * be acquired under acpi_dep_list_lock (held here) 2383 + * - the deferred work at boot stage is ensured to be finished 2384 + * before userspace init task by the async_synchronize_full() 2385 + * barrier 2386 + * 2387 + * Use _nocall variant since it'll return on failure instead of 2388 + * run the function synchronously. 2419 2389 */ 2420 - queue_work(system_dfl_wq, &cdw->work); 2421 - 2422 - return true; 2390 + return async_schedule_dev_nocall(acpi_scan_clear_dep_fn, &adev->dev); 2423 2391 } 2424 2392 2425 2393 static void acpi_scan_delete_dep_data(struct acpi_dep_data *dep) ··· 2579 2571 mutex_unlock(&acpi_dep_list_lock); 2580 2572 } 2581 2573 2574 + static void acpi_scan_claim_resources(struct acpi_device *adev) 2575 + { 2576 + struct resource_entry *rentry; 2577 + LIST_HEAD(resource_list); 2578 + unsigned int count = 0; 2579 + const char *regionid; 2580 + 2581 + if (acpi_dev_get_resources(adev, &resource_list, NULL, NULL) <= 0) 2582 + return; 2583 + 2584 + regionid = kstrdup(dev_name(&adev->dev), GFP_KERNEL); 2585 + if (!regionid) 2586 + goto exit; 2587 + 2588 + list_for_each_entry(rentry, &resource_list, node) { 2589 + struct resource *res = rentry->res; 2590 + struct resource *r; 2591 + 2592 + /* Skip disabled and invalid resources. */ 2593 + if ((res->flags & IORESOURCE_DISABLED) || res->end < res->start) 2594 + continue; 2595 + 2596 + if (resource_type(res) == IORESOURCE_IO) { 2597 + /* 2598 + * Follow the PNP system driver and on x86 skip I/O 2599 + * resources that start below 0x100 (the "standard PC 2600 + * hardware" boundary). 2601 + */ 2602 + if (IS_ENABLED(CONFIG_X86) && res->start < 0x100) { 2603 + dev_info(&adev->dev, "Skipped %pR\n", res); 2604 + continue; 2605 + } 2606 + r = request_region(res->start, resource_size(res), regionid); 2607 + } else if (resource_type(res) == IORESOURCE_MEM) { 2608 + r = request_mem_region(res->start, resource_size(res), regionid); 2609 + } else { 2610 + continue; 2611 + } 2612 + 2613 + if (r) { 2614 + r->flags &= ~IORESOURCE_BUSY; 2615 + dev_info(&adev->dev, "Reserved %pR\n", r); 2616 + count++; 2617 + } else { 2618 + /* 2619 + * Failures at this point are usually harmless. PCI 2620 + * quirks, for example, reserve resources they know 2621 + * about too, so there may well be double reservations. 2622 + */ 2623 + dev_info(&adev->dev, "Could not reserve %pR\n", res); 2624 + } 2625 + } 2626 + 2627 + if (!count) 2628 + kfree(regionid); 2629 + 2630 + exit: 2631 + acpi_dev_free_resource_list(&resource_list); 2632 + } 2633 + 2634 + static int __init acpi_reserve_motherboard_resources(void) 2635 + { 2636 + struct acpi_scan_system_dev *sd, *tmp; 2637 + 2638 + guard(mutex)(&acpi_scan_lock); 2639 + 2640 + list_for_each_entry_safe(sd, tmp, &acpi_scan_system_dev_list, node) { 2641 + acpi_scan_claim_resources(sd->adev); 2642 + list_del(&sd->node); 2643 + kfree(sd); 2644 + } 2645 + 2646 + return 0; 2647 + } 2648 + 2649 + /* 2650 + * Reserve motherboard resources after PCI claims BARs, but before PCI assigns 2651 + * resources for uninitialized PCI devices. 2652 + */ 2653 + fs_initcall(acpi_reserve_motherboard_resources); 2654 + 2582 2655 /** 2583 2656 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. 2584 2657 * @handle: Root of the namespace scope to scan. ··· 2731 2642 if (result) 2732 2643 return result; 2733 2644 2734 - device->flags.match_driver = true; 2735 - return device_attach(&device->dev); 2645 + acpi_default_enumeration(device); 2646 + return 0; 2736 2647 } 2737 2648 EXPORT_SYMBOL_GPL(acpi_bus_register_early_device); 2738 2649 2650 + static void acpi_bus_add_fixed_device_object(enum acpi_bus_device_type type) 2651 + { 2652 + struct acpi_device *adev = NULL; 2653 + 2654 + acpi_add_single_object(&adev, NULL, type, false); 2655 + if (adev) 2656 + acpi_default_enumeration(adev); 2657 + } 2658 + 2739 2659 static void acpi_bus_scan_fixed(void) 2740 2660 { 2741 - if (!(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) { 2742 - struct acpi_device *adev = NULL; 2661 + if (!(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) 2662 + acpi_bus_add_fixed_device_object(ACPI_BUS_TYPE_POWER_BUTTON); 2743 2663 2744 - acpi_add_single_object(&adev, NULL, ACPI_BUS_TYPE_POWER_BUTTON, 2745 - false); 2746 - if (adev) { 2747 - adev->flags.match_driver = true; 2748 - if (device_attach(&adev->dev) >= 0) 2749 - device_init_wakeup(&adev->dev, true); 2750 - else 2751 - dev_dbg(&adev->dev, "No driver\n"); 2752 - } 2753 - } 2754 - 2755 - if (!(acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON)) { 2756 - struct acpi_device *adev = NULL; 2757 - 2758 - acpi_add_single_object(&adev, NULL, ACPI_BUS_TYPE_SLEEP_BUTTON, 2759 - false); 2760 - if (adev) { 2761 - adev->flags.match_driver = true; 2762 - if (device_attach(&adev->dev) < 0) 2763 - dev_dbg(&adev->dev, "No driver\n"); 2764 - } 2765 - } 2664 + if (!(acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON)) 2665 + acpi_bus_add_fixed_device_object(ACPI_BUS_TYPE_SLEEP_BUTTON); 2766 2666 } 2767 2667 2768 2668 static void __init acpi_get_spcr_uart_addr(void)
+15 -15
drivers/acpi/sysfs.c
··· 687 687 acpi_irq_not_handled; 688 688 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count = 689 689 acpi_gpe_count; 690 - size = sprintf(buf, "%8u", all_counters[index].count); 690 + size = sysfs_emit(buf, "%8u", all_counters[index].count); 691 691 692 692 /* "gpe_all" or "sci" */ 693 693 if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS) ··· 698 698 goto end; 699 699 700 700 if (status & ACPI_EVENT_FLAG_ENABLE_SET) 701 - size += sprintf(buf + size, " EN"); 701 + size += sysfs_emit_at(buf, size, " EN"); 702 702 else 703 - size += sprintf(buf + size, " "); 703 + size += sysfs_emit_at(buf, size, " "); 704 704 if (status & ACPI_EVENT_FLAG_STATUS_SET) 705 - size += sprintf(buf + size, " STS"); 705 + size += sysfs_emit_at(buf, size, " STS"); 706 706 else 707 - size += sprintf(buf + size, " "); 707 + size += sysfs_emit_at(buf, size, " "); 708 708 709 709 if (!(status & ACPI_EVENT_FLAG_HAS_HANDLER)) 710 - size += sprintf(buf + size, " invalid "); 710 + size += sysfs_emit_at(buf, size, " invalid "); 711 711 else if (status & ACPI_EVENT_FLAG_ENABLED) 712 - size += sprintf(buf + size, " enabled "); 712 + size += sysfs_emit_at(buf, size, " enabled "); 713 713 else if (status & ACPI_EVENT_FLAG_WAKE_ENABLED) 714 - size += sprintf(buf + size, " wake_enabled"); 714 + size += sysfs_emit_at(buf, size, " wake_enabled"); 715 715 else 716 - size += sprintf(buf + size, " disabled "); 716 + size += sysfs_emit_at(buf, size, " disabled "); 717 717 if (status & ACPI_EVENT_FLAG_MASKED) 718 - size += sprintf(buf + size, " masked "); 718 + size += sysfs_emit_at(buf, size, " masked "); 719 719 else 720 - size += sprintf(buf + size, " unmasked"); 720 + size += sysfs_emit_at(buf, size, " unmasked"); 721 721 722 722 end: 723 - size += sprintf(buf + size, "\n"); 723 + size += sysfs_emit_at(buf, size, "\n"); 724 724 return result ? result : size; 725 725 } 726 726 ··· 937 937 938 938 static ssize_t pm_profile_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 939 939 { 940 - return sprintf(buf, "%d\n", acpi_gbl_FADT.preferred_profile); 940 + return sysfs_emit(buf, "%d\n", acpi_gbl_FADT.preferred_profile); 941 941 } 942 942 943 943 static const struct kobj_attribute pm_profile_attr = __ATTR_RO(pm_profile); ··· 946 946 { 947 947 struct acpi_hotplug_profile *hotplug = to_acpi_hotplug_profile(kobj); 948 948 949 - return sprintf(buf, "%d\n", hotplug->enabled); 949 + return sysfs_emit(buf, "%d\n", hotplug->enabled); 950 950 } 951 951 952 952 static ssize_t enabled_store(struct kobject *kobj, struct kobj_attribute *attr, ··· 1000 1000 static ssize_t force_remove_show(struct kobject *kobj, 1001 1001 struct kobj_attribute *attr, char *buf) 1002 1002 { 1003 - return sprintf(buf, "%d\n", 0); 1003 + return sysfs_emit(buf, "%d\n", 0); 1004 1004 } 1005 1005 1006 1006 static ssize_t force_remove_store(struct kobject *kobj,
+34 -56
drivers/acpi/thermal.c
··· 25 25 #include <linux/kmod.h> 26 26 #include <linux/reboot.h> 27 27 #include <linux/device.h> 28 + #include <linux/platform_device.h> 28 29 #include <linux/thermal.h> 29 30 #include <linux/acpi.h> 30 31 #include <linux/workqueue.h> ··· 671 670 672 671 static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) 673 672 { 674 - struct acpi_device *device = data; 675 - struct acpi_thermal *tz = acpi_driver_data(device); 673 + struct acpi_thermal *tz = data; 676 674 677 675 if (!tz) 678 676 return; ··· 685 685 acpi_thermal_trips_update(tz, event); 686 686 break; 687 687 default: 688 - acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", 689 - event); 688 + acpi_handle_debug(tz->device->handle, 689 + "Unsupported event [0x%x]\n", event); 690 690 break; 691 691 } 692 692 } ··· 777 777 kfree(tz); 778 778 } 779 779 780 - static int acpi_thermal_add(struct acpi_device *device) 780 + static int acpi_thermal_probe(struct platform_device *pdev) 781 781 { 782 782 struct thermal_trip trip_table[ACPI_THERMAL_MAX_NR_TRIPS] = { 0 }; 783 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 783 784 struct acpi_thermal_trip *acpi_trip; 784 785 struct thermal_trip *trip; 785 786 struct acpi_thermal *tz; ··· 796 795 if (!tz) 797 796 return -ENOMEM; 798 797 798 + platform_set_drvdata(pdev, tz); 799 + 799 800 tz->device = device; 800 801 strscpy(tz->name, device->pnp.bus_id); 801 802 strscpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); 802 803 strscpy(acpi_device_class(device), ACPI_THERMAL_CLASS); 803 - device->driver_data = tz; 804 804 805 805 acpi_thermal_aml_dependency_fix(tz); 806 806 ··· 883 881 acpi_device_bid(device), deci_kelvin_to_celsius(tz->temp_dk)); 884 882 885 883 result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, 886 - acpi_thermal_notify, device); 884 + acpi_thermal_notify, tz); 887 885 if (result) 888 886 goto flush_wq; 889 887 ··· 898 896 return result; 899 897 } 900 898 901 - static void acpi_thermal_remove(struct acpi_device *device) 899 + static void acpi_thermal_remove(struct platform_device *pdev) 902 900 { 903 - struct acpi_thermal *tz; 901 + struct acpi_thermal *tz = platform_get_drvdata(pdev); 904 902 905 - if (!device || !acpi_driver_data(device)) 906 - return; 907 - 908 - tz = acpi_driver_data(device); 909 - 910 - acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, 903 + acpi_dev_remove_notify_handler(tz->device, ACPI_DEVICE_NOTIFY, 911 904 acpi_thermal_notify); 912 905 913 906 flush_workqueue(acpi_thermal_pm_queue); ··· 911 914 } 912 915 913 916 #ifdef CONFIG_PM_SLEEP 914 - static int acpi_thermal_suspend(struct device *dev) 917 + static int acpi_thermal_prepare(struct device *dev) 915 918 { 916 919 /* Make sure the previously queued thermal check work has been done */ 917 920 flush_workqueue(acpi_thermal_pm_queue); 918 921 return 0; 919 922 } 920 923 921 - static int acpi_thermal_resume(struct device *dev) 924 + static void acpi_thermal_complete(struct device *dev) 922 925 { 923 - struct acpi_thermal *tz; 924 - int i, j; 925 - 926 - if (!dev) 927 - return -EINVAL; 928 - 929 - tz = acpi_driver_data(to_acpi_device(dev)); 930 - if (!tz) 931 - return -EINVAL; 932 - 933 - for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { 934 - struct acpi_thermal_trip *acpi_trip = &tz->trips.active[i].trip; 935 - 936 - if (!acpi_thermal_trip_valid(acpi_trip)) 937 - break; 938 - 939 - for (j = 0; j < acpi_trip->devices.count; j++) 940 - acpi_bus_update_power(acpi_trip->devices.handles[j], NULL); 941 - } 942 - 943 - acpi_queue_thermal_check(tz); 944 - 945 - return AE_OK; 926 + acpi_queue_thermal_check(dev_get_drvdata(dev)); 946 927 } 947 - #else 948 - #define acpi_thermal_suspend NULL 949 - #define acpi_thermal_resume NULL 950 - #endif 951 - static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, acpi_thermal_suspend, acpi_thermal_resume); 928 + 929 + static const struct dev_pm_ops acpi_thermal_pm_ops = { 930 + .prepare = acpi_thermal_prepare, 931 + .complete = acpi_thermal_complete, 932 + }; 933 + #define ACPI_THERMAL_PM &acpi_thermal_pm_ops 934 + #else /* !CONFIG_PM_SLEEP */ 935 + #define ACPI_THERMAL_PM NULL 936 + #endif /* CONFIG_PM_SLEEP */ 952 937 953 938 static const struct acpi_device_id thermal_device_ids[] = { 954 939 {ACPI_THERMAL_HID, 0}, ··· 938 959 }; 939 960 MODULE_DEVICE_TABLE(acpi, thermal_device_ids); 940 961 941 - static struct acpi_driver acpi_thermal_driver = { 942 - .name = "thermal", 943 - .class = ACPI_THERMAL_CLASS, 944 - .ids = thermal_device_ids, 945 - .ops = { 946 - .add = acpi_thermal_add, 947 - .remove = acpi_thermal_remove, 948 - }, 949 - .drv.pm = &acpi_thermal_pm, 962 + static struct platform_driver acpi_thermal_driver = { 963 + .probe = acpi_thermal_probe, 964 + .remove = acpi_thermal_remove, 965 + .driver = { 966 + .name = "acpi-thermal", 967 + .acpi_match_table = thermal_device_ids, 968 + .pm = ACPI_THERMAL_PM, 969 + }, 950 970 }; 951 971 952 972 static int thermal_act(const struct dmi_system_id *d) ··· 1043 1065 if (!acpi_thermal_pm_queue) 1044 1066 return -ENODEV; 1045 1067 1046 - result = acpi_bus_register_driver(&acpi_thermal_driver); 1068 + result = platform_driver_register(&acpi_thermal_driver); 1047 1069 if (result < 0) { 1048 1070 destroy_workqueue(acpi_thermal_pm_queue); 1049 1071 return -ENODEV; ··· 1054 1076 1055 1077 static void __exit acpi_thermal_exit(void) 1056 1078 { 1057 - acpi_bus_unregister_driver(&acpi_thermal_driver); 1079 + platform_driver_unregister(&acpi_thermal_driver); 1058 1080 destroy_workqueue(acpi_thermal_pm_queue); 1059 1081 } 1060 1082
+15 -12
drivers/acpi/tiny-power-button.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 - #include <linux/module.h> 3 - #include <linux/sched/signal.h> 4 2 #include <linux/acpi.h> 3 + #include <linux/module.h> 4 + #include <linux/platform_device.h> 5 + #include <linux/sched/signal.h> 5 6 #include <acpi/button.h> 6 7 7 8 MODULE_AUTHOR("Josh Triplett"); ··· 36 35 return ACPI_INTERRUPT_HANDLED; 37 36 } 38 37 39 - static int acpi_tiny_power_button_add(struct acpi_device *device) 38 + static int acpi_tiny_power_button_probe(struct platform_device *pdev) 40 39 { 40 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 41 41 acpi_status status; 42 42 43 43 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { ··· 57 55 return 0; 58 56 } 59 57 60 - static void acpi_tiny_power_button_remove(struct acpi_device *device) 58 + static void acpi_tiny_power_button_remove(struct platform_device *pdev) 61 59 { 60 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 61 + 62 62 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { 63 63 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, 64 64 acpi_tiny_power_button_event); ··· 71 67 acpi_os_wait_events_complete(); 72 68 } 73 69 74 - static struct acpi_driver acpi_tiny_power_button_driver = { 75 - .name = "tiny-power-button", 76 - .class = "tiny-power-button", 77 - .ids = tiny_power_button_device_ids, 78 - .ops = { 79 - .add = acpi_tiny_power_button_add, 80 - .remove = acpi_tiny_power_button_remove, 70 + static struct platform_driver acpi_tiny_power_button_driver = { 71 + .probe = acpi_tiny_power_button_probe, 72 + .remove = acpi_tiny_power_button_remove, 73 + .driver = { 74 + .name = "acpi-tiny-power-button", 75 + .acpi_match_table = tiny_power_button_device_ids, 81 76 }, 82 77 }; 83 78 84 - module_acpi_driver(acpi_tiny_power_button_driver); 79 + module_platform_driver(acpi_tiny_power_button_driver);
+6 -3
drivers/acpi/x86/s2idle.c
··· 49 49 #define ACPI_LPS0_EXIT 6 50 50 #define ACPI_LPS0_MS_ENTRY 7 51 51 #define ACPI_LPS0_MS_EXIT 8 52 + #define ACPI_MS_TURN_ON_DISPLAY 9 52 53 53 54 /* AMD */ 54 55 #define ACPI_LPS0_DSM_UUID_AMD "e3f32452-febc-43ce-9039-932122d37721" ··· 357 356 return "lps0 ms entry"; 358 357 case ACPI_LPS0_MS_EXIT: 359 358 return "lps0 ms exit"; 359 + case ACPI_MS_TURN_ON_DISPLAY: 360 + return "lps0 ms turn on display"; 360 361 } 361 362 } else { 362 363 switch (state) { ··· 466 463 lps0_dsm_func_mask = (lps0_dsm_func_mask << 1) | 0x1; 467 464 acpi_handle_debug(adev->handle, "_DSM UUID %s: Adjusted function mask: 0x%x\n", 468 465 ACPI_LPS0_DSM_UUID_AMD, lps0_dsm_func_mask); 469 - } else if (lps0_dsm_func_mask_microsoft > 0 && rev_id) { 470 - lps0_dsm_func_mask_microsoft = -EINVAL; 471 - acpi_handle_debug(adev->handle, "_DSM Using AMD method\n"); 472 466 } 473 467 } else { 474 468 rev_id = 1; ··· 616 616 617 617 if (lps0_dsm_func_mask_microsoft > 0) { 618 618 acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT, 619 + lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); 620 + /* Intent to turn on display */ 621 + acpi_sleep_run_lps0_dsm(ACPI_MS_TURN_ON_DISPLAY, 619 622 lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); 620 623 /* Modern Standby exit */ 621 624 acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_EXIT,
+2 -1
drivers/cxl/core/ras.c
··· 63 63 return 0; 64 64 } 65 65 66 - static void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data) 66 + void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data) 67 67 { 68 68 unsigned int devfn = PCI_DEVFN(data->prot_err.agent_addr.device, 69 69 data->prot_err.agent_addr.function); ··· 104 104 else 105 105 cxl_cper_trace_uncorr_prot_err(cxlmd, data->ras_cap); 106 106 } 107 + EXPORT_SYMBOL_GPL(cxl_cper_handle_prot_err); 107 108 108 109 static void cxl_cper_prot_err_work_fn(struct work_struct *work) 109 110 {
+8 -4
drivers/firmware/efi/cper-arm.c
··· 226 226 } 227 227 228 228 void cper_print_proc_arm(const char *pfx, 229 - const struct cper_sec_proc_arm *proc) 229 + const struct cper_sec_proc_arm *proc, 230 + u32 length) 230 231 { 231 232 int i, len, max_ctx_type; 232 233 struct cper_arm_err_info *err_info; ··· 239 238 240 239 len = proc->section_length - (sizeof(*proc) + 241 240 proc->err_info_num * (sizeof(*err_info))); 242 - if (len < 0) { 243 - printk("%ssection length: %d\n", pfx, proc->section_length); 244 - printk("%ssection length is too small\n", pfx); 241 + 242 + if (len < 0 || proc->section_length > length) { 243 + printk("%ssection length: %d, CPER size: %d\n", 244 + pfx, proc->section_length, length); 245 + printk("%ssection length is too %s\n", pfx, 246 + (len < 0) ? "small" : "big"); 245 247 printk("%sfirmware-generated error record is incorrect\n", pfx); 246 248 printk("%sERR_INFO_NUM is %d\n", pfx, proc->err_info_num); 247 249 return;
+7 -1
drivers/firmware/efi/cper.c
··· 560 560 } else { 561 561 offset = sizeof(*fw_err); 562 562 } 563 + if (offset > length) { 564 + printk("%s""error section length is too small: offset=%d, length=%d\n", 565 + pfx, offset, length); 566 + return; 567 + } 563 568 564 569 buf += offset; 565 570 length -= offset; ··· 664 659 665 660 printk("%ssection_type: ARM processor error\n", newpfx); 666 661 if (gdata->error_data_length >= sizeof(*arm_err)) 667 - cper_print_proc_arm(newpfx, arm_err); 662 + cper_print_proc_arm(newpfx, arm_err, 663 + gdata->error_data_length); 668 664 else 669 665 goto err_section_too_small; 670 666 #endif
+22 -21
drivers/irqchip/irq-gic-its-msi-parent.c
··· 19 19 MSI_FLAG_PCI_MSIX | \ 20 20 MSI_FLAG_MULTI_PCI_MSI) 21 21 22 - static int its_translate_frame_address(struct device_node *msi_node, phys_addr_t *pa) 22 + static int its_translate_frame_address(struct fwnode_handle *msi_node, phys_addr_t *pa) 23 23 { 24 24 struct resource res; 25 25 int ret; 26 26 27 - ret = of_property_match_string(msi_node, "reg-names", "ns-translate"); 28 - if (ret < 0) 29 - return ret; 27 + if (is_of_node(msi_node)) { 28 + struct device_node *msi_np = to_of_node(msi_node); 30 29 31 - ret = of_address_to_resource(msi_node, ret, &res); 32 - if (ret) 33 - return ret; 30 + ret = of_property_match_string(msi_np, "reg-names", "ns-translate"); 31 + if (ret < 0) 32 + return ret; 33 + 34 + ret = of_address_to_resource(msi_np, ret, &res); 35 + if (ret) 36 + return ret; 37 + } else { 38 + ret = iort_its_translate_pa(msi_node, &res.start); 39 + } 34 40 35 41 *pa = res.start; 36 42 return 0; ··· 110 104 static int its_v5_pci_msi_prepare(struct irq_domain *domain, struct device *dev, 111 105 int nvec, msi_alloc_info_t *info) 112 106 { 113 - struct device_node *msi_node = NULL; 107 + struct fwnode_handle *msi_node = NULL; 114 108 struct msi_domain_info *msi_info; 115 109 struct pci_dev *pdev; 116 110 phys_addr_t pa; ··· 122 116 123 117 pdev = to_pci_dev(dev); 124 118 125 - rid = pci_msi_map_rid_ctlr_node(pdev, &msi_node); 119 + rid = pci_msi_map_rid_ctlr_node(domain->parent, pdev, &msi_node); 126 120 if (!msi_node) 127 121 return -ENODEV; 128 122 ··· 130 124 if (ret) 131 125 return -ENODEV; 132 126 133 - of_node_put(msi_node); 127 + fwnode_handle_put(msi_node); 134 128 135 129 /* ITS specific DeviceID */ 136 130 info->scratchpad[0].ul = rid; ··· 167 161 ret = -EINVAL; 168 162 169 163 if (!ret && pa) 170 - ret = its_translate_frame_address(it.node, pa); 164 + ret = its_translate_frame_address(of_fwnode_handle(it.node), pa); 171 165 172 166 if (!ret) 173 167 *dev_id = args; ··· 182 176 return of_map_id(dev->of_node, dev->id, "msi-map", "msi-map-mask", &msi_ctrl, dev_id); 183 177 } 184 178 185 - int __weak iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id) 186 - { 187 - return -1; 188 - } 189 - 190 179 static int its_pmsi_prepare(struct irq_domain *domain, struct device *dev, 191 180 int nvec, msi_alloc_info_t *info) 192 181 { ··· 192 191 if (dev->of_node) 193 192 ret = of_pmsi_get_msi_info(domain->parent, dev, &dev_id, NULL); 194 193 else 195 - ret = iort_pmsi_get_dev_id(dev, &dev_id); 194 + ret = iort_pmsi_get_msi_info(dev, &dev_id, NULL); 196 195 if (ret) 197 196 return ret; 198 197 ··· 215 214 u32 dev_id; 216 215 int ret; 217 216 218 - if (!dev->of_node) 219 - return -ENODEV; 220 - 221 - ret = of_pmsi_get_msi_info(domain->parent, dev, &dev_id, &pa); 217 + if (dev->of_node) 218 + ret = of_pmsi_get_msi_info(domain->parent, dev, &dev_id, &pa); 219 + else 220 + ret = iort_pmsi_get_msi_info(dev, &dev_id, &pa); 222 221 if (ret) 223 222 return ret; 224 223
+193 -54
drivers/irqchip/irq-gic-v5-irs.c
··· 5 5 6 6 #define pr_fmt(fmt) "GICv5 IRS: " fmt 7 7 8 + #include <linux/acpi.h> 8 9 #include <linux/kmemleak.h> 9 10 #include <linux/log2.h> 10 11 #include <linux/of.h> ··· 546 545 547 546 static void __init gicv5_irs_init_bases(struct gicv5_irs_chip_data *irs_data, 548 547 void __iomem *irs_base, 549 - struct fwnode_handle *handle) 548 + bool noncoherent) 550 549 { 551 - struct device_node *np = to_of_node(handle); 552 550 u32 cr0, cr1; 553 551 554 - irs_data->fwnode = handle; 555 552 irs_data->irs_base = irs_base; 556 553 557 - if (of_property_read_bool(np, "dma-noncoherent")) { 554 + if (noncoherent) { 558 555 /* 559 556 * A non-coherent IRS implies that some cache levels cannot be 560 557 * used coherently by the cores and GIC. Our only option is to mark ··· 677 678 } 678 679 } 679 680 680 - static int __init gicv5_irs_init(struct device_node *node) 681 + static int __init gicv5_irs_init(struct gicv5_irs_chip_data *irs_data) 681 682 { 682 - struct gicv5_irs_chip_data *irs_data; 683 - void __iomem *irs_base; 684 - u32 idr, spi_count; 685 - u8 iaffid_bits; 686 - int ret; 683 + u32 spi_count, idr = irs_readl_relaxed(irs_data, GICV5_IRS_IDR2); 687 684 688 - irs_data = kzalloc(sizeof(*irs_data), GFP_KERNEL); 689 - if (!irs_data) 690 - return -ENOMEM; 691 - 692 - raw_spin_lock_init(&irs_data->spi_config_lock); 693 - 694 - ret = of_property_match_string(node, "reg-names", "ns-config"); 695 - if (ret < 0) { 696 - pr_err("%pOF: ns-config reg-name not present\n", node); 697 - goto out_err; 698 - } 699 - 700 - irs_base = of_io_request_and_map(node, ret, of_node_full_name(node)); 701 - if (IS_ERR(irs_base)) { 702 - pr_err("%pOF: unable to map GICv5 IRS registers\n", node); 703 - ret = PTR_ERR(irs_base); 704 - goto out_err; 705 - } 706 - 707 - gicv5_irs_init_bases(irs_data, irs_base, &node->fwnode); 708 - 709 - idr = irs_readl_relaxed(irs_data, GICV5_IRS_IDR1); 710 - iaffid_bits = FIELD_GET(GICV5_IRS_IDR1_IAFFID_BITS, idr) + 1; 711 - 712 - ret = gicv5_irs_of_init_affinity(node, irs_data, iaffid_bits); 713 - if (ret) { 714 - pr_err("Failed to parse CPU IAFFIDs from the device tree!\n"); 715 - goto out_iomem; 716 - } 717 - 718 - idr = irs_readl_relaxed(irs_data, GICV5_IRS_IDR2); 719 685 if (WARN(!FIELD_GET(GICV5_IRS_IDR2_LPI, idr), 720 686 "LPI support not available - no IPIs, can't proceed\n")) { 721 - ret = -ENODEV; 722 - goto out_iomem; 687 + return -ENODEV; 723 688 } 724 689 725 690 idr = irs_readl_relaxed(irs_data, GICV5_IRS_IDR7); ··· 691 728 692 729 idr = irs_readl_relaxed(irs_data, GICV5_IRS_IDR6); 693 730 irs_data->spi_range = FIELD_GET(GICV5_IRS_IDR6_SPI_IRS_RANGE, idr); 694 - 695 - if (irs_data->spi_range) { 696 - pr_info("%s detected SPI range [%u-%u]\n", 697 - of_node_full_name(node), 698 - irs_data->spi_min, 699 - irs_data->spi_min + 700 - irs_data->spi_range - 1); 701 - } 702 731 703 732 /* 704 733 * Do the global setting only on the first IRS. ··· 715 760 list_add_tail(&irs_data->entry, &irs_nodes); 716 761 717 762 return 0; 763 + } 764 + 765 + static int __init gicv5_irs_of_init(struct device_node *node) 766 + { 767 + struct gicv5_irs_chip_data *irs_data; 768 + void __iomem *irs_base; 769 + u8 iaffid_bits; 770 + u32 idr; 771 + int ret; 772 + 773 + irs_data = kzalloc(sizeof(*irs_data), GFP_KERNEL); 774 + if (!irs_data) 775 + return -ENOMEM; 776 + 777 + raw_spin_lock_init(&irs_data->spi_config_lock); 778 + 779 + ret = of_property_match_string(node, "reg-names", "ns-config"); 780 + if (ret < 0) { 781 + pr_err("%pOF: ns-config reg-name not present\n", node); 782 + goto out_err; 783 + } 784 + 785 + irs_base = of_io_request_and_map(node, ret, of_node_full_name(node)); 786 + if (IS_ERR(irs_base)) { 787 + pr_err("%pOF: unable to map GICv5 IRS registers\n", node); 788 + ret = PTR_ERR(irs_base); 789 + goto out_err; 790 + } 791 + 792 + irs_data->fwnode = of_fwnode_handle(node); 793 + gicv5_irs_init_bases(irs_data, irs_base, of_property_read_bool(node, "dma-noncoherent")); 794 + 795 + idr = irs_readl_relaxed(irs_data, GICV5_IRS_IDR1); 796 + iaffid_bits = FIELD_GET(GICV5_IRS_IDR1_IAFFID_BITS, idr) + 1; 797 + 798 + ret = gicv5_irs_of_init_affinity(node, irs_data, iaffid_bits); 799 + if (ret) { 800 + pr_err("Failed to parse CPU IAFFIDs from the device tree!\n"); 801 + goto out_iomem; 802 + } 803 + 804 + ret = gicv5_irs_init(irs_data); 805 + if (ret) 806 + goto out_iomem; 807 + 808 + if (irs_data->spi_range) { 809 + pr_info("%s detected SPI range [%u-%u]\n", 810 + of_node_full_name(node), 811 + irs_data->spi_min, 812 + irs_data->spi_min + 813 + irs_data->spi_range - 1); 814 + } 815 + 816 + return ret; 718 817 719 818 out_iomem: 720 819 iounmap(irs_base); ··· 814 805 { 815 806 struct gicv5_irs_chip_data *irs_data; 816 807 817 - list_for_each_entry(irs_data, &irs_nodes, entry) 818 - gicv5_its_of_probe(to_of_node(irs_data->fwnode)); 808 + if (acpi_disabled) 809 + list_for_each_entry(irs_data, &irs_nodes, entry) 810 + gicv5_its_of_probe(to_of_node(irs_data->fwnode)); 811 + else 812 + gicv5_its_acpi_probe(); 819 813 } 820 814 821 815 int __init gicv5_irs_of_probe(struct device_node *parent) ··· 830 818 if (!of_device_is_compatible(np, "arm,gic-v5-irs")) 831 819 continue; 832 820 833 - ret = gicv5_irs_init(np); 821 + ret = gicv5_irs_of_init(np); 834 822 if (ret) 835 823 pr_err("Failed to init IRS %s\n", np->full_name); 836 824 } 837 825 838 826 return list_empty(&irs_nodes) ? -ENODEV : 0; 839 827 } 828 + 829 + #ifdef CONFIG_ACPI 830 + 831 + #define ACPI_GICV5_IRS_MEM_SIZE (SZ_64K) 832 + static struct gicv5_irs_chip_data *current_irs_data __initdata; 833 + static int current_irsid __initdata = -1; 834 + static u8 current_iaffid_bits __initdata; 835 + 836 + static int __init gic_acpi_parse_iaffid(union acpi_subtable_headers *header, 837 + const unsigned long end) 838 + { 839 + struct acpi_madt_generic_interrupt *gicc = (struct acpi_madt_generic_interrupt *)header; 840 + int cpu; 841 + 842 + if (!(gicc->flags & (ACPI_MADT_ENABLED | ACPI_MADT_GICC_ONLINE_CAPABLE))) 843 + return 0; 844 + 845 + if (gicc->irs_id != current_irsid) 846 + return 0; 847 + 848 + cpu = get_logical_index(gicc->arm_mpidr); 849 + 850 + if (gicc->iaffid & ~GENMASK(current_iaffid_bits - 1, 0)) { 851 + pr_warn("CPU %d iaffid 0x%x exceeds IRS iaffid bits\n", cpu, gicc->iaffid); 852 + return 0; 853 + } 854 + 855 + /* Bind the IAFFID and the CPU */ 856 + per_cpu(cpu_iaffid, cpu).iaffid = gicc->iaffid; 857 + per_cpu(cpu_iaffid, cpu).valid = true; 858 + pr_debug("Processed IAFFID %u for CPU%d", per_cpu(cpu_iaffid, cpu).iaffid, cpu); 859 + 860 + /* We also know that the CPU is connected to this IRS */ 861 + per_cpu(per_cpu_irs_data, cpu) = current_irs_data; 862 + 863 + return 0; 864 + } 865 + 866 + static int __init gicv5_irs_acpi_init_affinity(u32 irsid, struct gicv5_irs_chip_data *irs_data) 867 + { 868 + u32 idr; 869 + 870 + current_irsid = irsid; 871 + current_irs_data = irs_data; 872 + 873 + idr = irs_readl_relaxed(irs_data, GICV5_IRS_IDR1); 874 + current_iaffid_bits = FIELD_GET(GICV5_IRS_IDR1_IAFFID_BITS, idr) + 1; 875 + 876 + acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT, gic_acpi_parse_iaffid, 0); 877 + 878 + return 0; 879 + } 880 + 881 + static struct resource * __init gic_request_region(resource_size_t base, resource_size_t size, 882 + const char *name) 883 + { 884 + struct resource *r = request_mem_region(base, size, name); 885 + 886 + if (!r) 887 + pr_warn_once(FW_BUG "%s region %pa has overlapping address\n", name, &base); 888 + 889 + return r; 890 + } 891 + 892 + static int __init gic_acpi_parse_madt_irs(union acpi_subtable_headers *header, 893 + const unsigned long end) 894 + { 895 + struct acpi_madt_gicv5_irs *irs = (struct acpi_madt_gicv5_irs *)header; 896 + struct gicv5_irs_chip_data *irs_data; 897 + void __iomem *irs_base; 898 + struct resource *r; 899 + int ret; 900 + 901 + /* Per-IRS data structure */ 902 + irs_data = kzalloc(sizeof(*irs_data), GFP_KERNEL); 903 + if (!irs_data) 904 + return -ENOMEM; 905 + 906 + /* This spinlock is used for SPI config changes */ 907 + raw_spin_lock_init(&irs_data->spi_config_lock); 908 + 909 + r = gic_request_region(irs->config_base_address, ACPI_GICV5_IRS_MEM_SIZE, "GICv5 IRS"); 910 + if (!r) { 911 + ret = -EBUSY; 912 + goto out_free; 913 + } 914 + 915 + irs_base = ioremap(irs->config_base_address, ACPI_GICV5_IRS_MEM_SIZE); 916 + if (!irs_base) { 917 + pr_err("Unable to map GIC IRS registers\n"); 918 + ret = -ENOMEM; 919 + goto out_release; 920 + } 921 + 922 + gicv5_irs_init_bases(irs_data, irs_base, irs->flags & ACPI_MADT_IRS_NON_COHERENT); 923 + 924 + gicv5_irs_acpi_init_affinity(irs->irs_id, irs_data); 925 + 926 + ret = gicv5_irs_init(irs_data); 927 + if (ret) 928 + goto out_map; 929 + 930 + if (irs_data->spi_range) { 931 + pr_info("%s @%llx detected SPI range [%u-%u]\n", "IRS", irs->config_base_address, 932 + irs_data->spi_min, 933 + irs_data->spi_min + 934 + irs_data->spi_range - 1); 935 + } 936 + 937 + return 0; 938 + 939 + out_map: 940 + iounmap(irs_base); 941 + out_release: 942 + release_mem_region(r->start, resource_size(r)); 943 + out_free: 944 + kfree(irs_data); 945 + return ret; 946 + } 947 + 948 + int __init gicv5_irs_acpi_probe(void) 949 + { 950 + acpi_table_parse_madt(ACPI_MADT_TYPE_GICV5_IRS, gic_acpi_parse_madt_irs, 0); 951 + 952 + return list_empty(&irs_nodes) ? -ENODEV : 0; 953 + } 954 + #endif
+130 -2
drivers/irqchip/irq-gic-v5-its.c
··· 5 5 6 6 #define pr_fmt(fmt) "GICv5 ITS: " fmt 7 7 8 + #include <linux/acpi.h> 9 + #include <linux/acpi_iort.h> 8 10 #include <linux/bitmap.h> 9 11 #include <linux/iommu.h> 10 12 #include <linux/init.h> ··· 1117 1115 } 1118 1116 1119 1117 static int __init gicv5_its_init_bases(void __iomem *its_base, struct fwnode_handle *handle, 1120 - struct irq_domain *parent_domain) 1118 + struct irq_domain *parent_domain, bool noncoherent) 1121 1119 { 1122 1120 struct device_node *np = to_of_node(handle); 1123 1121 struct gicv5_its_chip_data *its_node; ··· 1210 1208 } 1211 1209 1212 1210 ret = gicv5_its_init_bases(its_base, of_fwnode_handle(node), 1213 - gicv5_global_data.lpi_domain); 1211 + gicv5_global_data.lpi_domain, 1212 + of_property_read_bool(node, "dma-noncoherent")); 1214 1213 if (ret) 1215 1214 goto out_unmap; 1216 1215 ··· 1234 1231 pr_err("Failed to init ITS %s\n", np->full_name); 1235 1232 } 1236 1233 } 1234 + 1235 + #ifdef CONFIG_ACPI 1236 + 1237 + #define ACPI_GICV5_ITS_MEM_SIZE (SZ_64K) 1238 + 1239 + static struct acpi_madt_gicv5_translator *current_its_entry __initdata; 1240 + static struct fwnode_handle *current_its_fwnode __initdata; 1241 + 1242 + static int __init gic_acpi_parse_madt_its_translate(union acpi_subtable_headers *header, 1243 + const unsigned long end) 1244 + { 1245 + struct acpi_madt_gicv5_translate_frame *its_frame; 1246 + struct fwnode_handle *msi_dom_handle; 1247 + struct resource res = {}; 1248 + int err; 1249 + 1250 + its_frame = (struct acpi_madt_gicv5_translate_frame *)header; 1251 + if (its_frame->linked_translator_id != current_its_entry->translator_id) 1252 + return 0; 1253 + 1254 + res.start = its_frame->base_address; 1255 + res.end = its_frame->base_address + ACPI_GICV5_ITS_MEM_SIZE - 1; 1256 + res.flags = IORESOURCE_MEM; 1257 + 1258 + msi_dom_handle = irq_domain_alloc_parented_fwnode(&res.start, current_its_fwnode); 1259 + if (!msi_dom_handle) { 1260 + pr_err("ITS@%pa: Unable to allocate GICv5 ITS translate domain token\n", 1261 + &res.start); 1262 + return -ENOMEM; 1263 + } 1264 + 1265 + err = iort_register_domain_token(its_frame->translate_frame_id, res.start, 1266 + msi_dom_handle); 1267 + if (err) { 1268 + pr_err("ITS@%pa: Unable to register GICv5 ITS domain token (ITS TRANSLATE FRAME ID %d) to IORT\n", 1269 + &res.start, its_frame->translate_frame_id); 1270 + irq_domain_free_fwnode(msi_dom_handle); 1271 + return err; 1272 + } 1273 + 1274 + return 0; 1275 + } 1276 + 1277 + static int __init gic_acpi_free_madt_its_translate(union acpi_subtable_headers *header, 1278 + const unsigned long end) 1279 + { 1280 + struct acpi_madt_gicv5_translate_frame *its_frame; 1281 + struct fwnode_handle *msi_dom_handle; 1282 + 1283 + its_frame = (struct acpi_madt_gicv5_translate_frame *)header; 1284 + if (its_frame->linked_translator_id != current_its_entry->translator_id) 1285 + return 0; 1286 + 1287 + msi_dom_handle = iort_find_domain_token(its_frame->translate_frame_id); 1288 + if (!msi_dom_handle) 1289 + return 0; 1290 + 1291 + iort_deregister_domain_token(its_frame->translate_frame_id); 1292 + irq_domain_free_fwnode(msi_dom_handle); 1293 + 1294 + return 0; 1295 + } 1296 + 1297 + static int __init gic_acpi_parse_madt_its(union acpi_subtable_headers *header, 1298 + const unsigned long end) 1299 + { 1300 + struct acpi_madt_gicv5_translator *its_entry; 1301 + struct fwnode_handle *dom_handle; 1302 + struct resource res = {}; 1303 + void __iomem *its_base; 1304 + int err; 1305 + 1306 + its_entry = (struct acpi_madt_gicv5_translator *)header; 1307 + res.start = its_entry->base_address; 1308 + res.end = its_entry->base_address + ACPI_GICV5_ITS_MEM_SIZE - 1; 1309 + res.flags = IORESOURCE_MEM; 1310 + 1311 + if (!request_mem_region(res.start, resource_size(&res), "GICv5 ITS")) 1312 + return -EBUSY; 1313 + 1314 + dom_handle = irq_domain_alloc_fwnode(&res.start); 1315 + if (!dom_handle) { 1316 + pr_err("ITS@%pa: Unable to allocate GICv5 ITS domain token\n", 1317 + &res.start); 1318 + err = -ENOMEM; 1319 + goto out_rel_res; 1320 + } 1321 + 1322 + current_its_entry = its_entry; 1323 + current_its_fwnode = dom_handle; 1324 + 1325 + acpi_table_parse_madt(ACPI_MADT_TYPE_GICV5_ITS_TRANSLATE, 1326 + gic_acpi_parse_madt_its_translate, 0); 1327 + 1328 + its_base = ioremap(res.start, ACPI_GICV5_ITS_MEM_SIZE); 1329 + if (!its_base) { 1330 + err = -ENOMEM; 1331 + goto out_unregister; 1332 + } 1333 + 1334 + err = gicv5_its_init_bases(its_base, dom_handle, gicv5_global_data.lpi_domain, 1335 + its_entry->flags & ACPI_MADT_GICV5_ITS_NON_COHERENT); 1336 + if (err) 1337 + goto out_unmap; 1338 + 1339 + return 0; 1340 + 1341 + out_unmap: 1342 + iounmap(its_base); 1343 + out_unregister: 1344 + acpi_table_parse_madt(ACPI_MADT_TYPE_GICV5_ITS_TRANSLATE, 1345 + gic_acpi_free_madt_its_translate, 0); 1346 + irq_domain_free_fwnode(dom_handle); 1347 + out_rel_res: 1348 + release_mem_region(res.start, resource_size(&res)); 1349 + return err; 1350 + } 1351 + 1352 + void __init gicv5_its_acpi_probe(void) 1353 + { 1354 + acpi_table_parse_madt(ACPI_MADT_TYPE_GICV5_ITS, gic_acpi_parse_madt_its, 0); 1355 + } 1356 + #else 1357 + void __init gicv5_its_acpi_probe(void) { } 1358 + #endif
+32 -10
drivers/irqchip/irq-gic-v5-iwb.c
··· 4 4 */ 5 5 #define pr_fmt(fmt) "GICv5 IWB: " fmt 6 6 7 + #include <linux/acpi.h> 7 8 #include <linux/init.h> 8 9 #include <linux/kernel.h> 9 10 #include <linux/msi.h> ··· 137 136 irq_hw_number_t *hwirq, 138 137 unsigned int *type) 139 138 { 140 - if (!is_of_node(fwspec->fwnode)) 141 - return -EINVAL; 139 + if (is_of_node(fwspec->fwnode)) { 142 140 143 - if (fwspec->param_count < 2) 144 - return -EINVAL; 141 + if (fwspec->param_count < 2) 142 + return -EINVAL; 145 143 146 - /* 147 - * param[0] is be the wire 148 - * param[1] is the interrupt type 149 - */ 150 - *hwirq = fwspec->param[0]; 151 - *type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK; 144 + /* 145 + * param[0] is be the wire 146 + * param[1] is the interrupt type 147 + */ 148 + *hwirq = fwspec->param[0]; 149 + *type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK; 150 + } 151 + 152 + if (is_acpi_device_node(fwspec->fwnode)) { 153 + 154 + if (fwspec->param_count < 2) 155 + return -EINVAL; 156 + 157 + /* 158 + * Extract the wire from param[0] 159 + * param[1] is the interrupt type 160 + */ 161 + *hwirq = FIELD_GET(GICV5_GSI_IWB_WIRE, fwspec->param[0]); 162 + *type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK; 163 + } 152 164 153 165 return 0; 154 166 } ··· 279 265 }; 280 266 MODULE_DEVICE_TABLE(of, gicv5_iwb_of_match); 281 267 268 + #ifdef CONFIG_ACPI 269 + static const struct acpi_device_id iwb_acpi_match[] = { 270 + { "ARMH0003", 0 }, 271 + {} 272 + }; 273 + #endif 274 + 282 275 static struct platform_driver gicv5_iwb_platform_driver = { 283 276 .driver = { 284 277 .name = "GICv5 IWB", 285 278 .of_match_table = gicv5_iwb_of_match, 279 + .acpi_match_table = ACPI_PTR(iwb_acpi_match), 286 280 .suppress_bind_attrs = true, 287 281 }, 288 282 .probe = gicv5_iwb_device_probe,
+119 -19
drivers/irqchip/irq-gic-v5.c
··· 5 5 6 6 #define pr_fmt(fmt) "GICv5: " fmt 7 7 8 + #include <linux/acpi_iort.h> 8 9 #include <linux/cpuhotplug.h> 9 10 #include <linux/idr.h> 10 11 #include <linux/irqdomain.h> ··· 580 579 unsigned int *type, 581 580 const u8 hwirq_type) 582 581 { 583 - if (!is_of_node(fwspec->fwnode)) 584 - return -EINVAL; 582 + unsigned int hwirq_trigger; 583 + u8 fwspec_irq_type; 585 584 586 - if (fwspec->param_count < 3) 587 - return -EINVAL; 585 + if (is_of_node(fwspec->fwnode)) { 588 586 589 - if (fwspec->param[0] != hwirq_type) 590 - return -EINVAL; 587 + if (fwspec->param_count < 3) 588 + return -EINVAL; 591 589 592 - *hwirq = fwspec->param[1]; 590 + fwspec_irq_type = fwspec->param[0]; 591 + 592 + if (fwspec->param[0] != hwirq_type) 593 + return -EINVAL; 594 + 595 + *hwirq = fwspec->param[1]; 596 + hwirq_trigger = fwspec->param[2]; 597 + } 598 + 599 + if (is_fwnode_irqchip(fwspec->fwnode)) { 600 + 601 + if (fwspec->param_count != 2) 602 + return -EINVAL; 603 + 604 + fwspec_irq_type = FIELD_GET(GICV5_HWIRQ_TYPE, fwspec->param[0]); 605 + 606 + if (fwspec_irq_type != hwirq_type) 607 + return -EINVAL; 608 + 609 + *hwirq = FIELD_GET(GICV5_HWIRQ_ID, fwspec->param[0]); 610 + hwirq_trigger = fwspec->param[1]; 611 + } 593 612 594 613 switch (hwirq_type) { 595 614 case GICV5_HWIRQ_TYPE_PPI: ··· 621 600 IRQ_TYPE_EDGE_RISING; 622 601 break; 623 602 case GICV5_HWIRQ_TYPE_SPI: 624 - *type = fwspec->param[2] & IRQ_TYPE_SENSE_MASK; 603 + *type = hwirq_trigger & IRQ_TYPE_SENSE_MASK; 625 604 break; 626 605 default: 627 606 BUILD_BUG_ON(1); ··· 681 660 static int gicv5_irq_ppi_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec, 682 661 enum irq_domain_bus_token bus_token) 683 662 { 663 + u32 hwirq_type; 664 + 684 665 if (fwspec->fwnode != d->fwnode) 685 666 return 0; 686 667 687 - if (fwspec->param[0] != GICV5_HWIRQ_TYPE_PPI) 668 + if (is_of_node(fwspec->fwnode)) 669 + hwirq_type = fwspec->param[0]; 670 + 671 + if (is_fwnode_irqchip(fwspec->fwnode)) 672 + hwirq_type = FIELD_GET(GICV5_HWIRQ_TYPE, fwspec->param[0]); 673 + 674 + if (hwirq_type != GICV5_HWIRQ_TYPE_PPI) 688 675 return 0; 689 676 690 677 return (d == gicv5_global_data.ppi_domain); ··· 747 718 static int gicv5_irq_spi_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec, 748 719 enum irq_domain_bus_token bus_token) 749 720 { 721 + u32 hwirq_type; 722 + 750 723 if (fwspec->fwnode != d->fwnode) 751 724 return 0; 752 725 753 - if (fwspec->param[0] != GICV5_HWIRQ_TYPE_SPI) 726 + if (is_of_node(fwspec->fwnode)) 727 + hwirq_type = fwspec->param[0]; 728 + 729 + if (is_fwnode_irqchip(fwspec->fwnode)) 730 + hwirq_type = FIELD_GET(GICV5_HWIRQ_TYPE, fwspec->param[0]); 731 + 732 + if (hwirq_type != GICV5_HWIRQ_TYPE_SPI) 754 733 return 0; 755 734 756 735 return (d == gicv5_global_data.spi_domain); ··· 1119 1082 } 1120 1083 #endif // CONFIG_KVM 1121 1084 1122 - static int __init gicv5_of_init(struct device_node *node, struct device_node *parent) 1085 + static int __init gicv5_init_common(struct fwnode_handle *parent_domain) 1123 1086 { 1124 - int ret = gicv5_irs_of_probe(node); 1087 + int ret = gicv5_init_domains(parent_domain); 1125 1088 if (ret) 1126 1089 return ret; 1127 - 1128 - ret = gicv5_init_domains(of_fwnode_handle(node)); 1129 - if (ret) 1130 - goto out_irs; 1131 1090 1132 1091 gicv5_set_cpuif_pribits(); 1133 1092 gicv5_set_cpuif_idbits(); ··· 1146 1113 gicv5_smp_init(); 1147 1114 1148 1115 gicv5_irs_its_probe(); 1149 - 1150 - gic_of_setup_kvm_info(node); 1151 - 1152 1116 return 0; 1153 1117 1154 1118 out_int: 1155 1119 gicv5_cpu_disable_interrupts(); 1156 1120 out_dom: 1157 1121 gicv5_free_domains(); 1122 + return ret; 1123 + } 1124 + 1125 + static int __init gicv5_of_init(struct device_node *node, struct device_node *parent) 1126 + { 1127 + int ret = gicv5_irs_of_probe(node); 1128 + if (ret) 1129 + return ret; 1130 + 1131 + ret = gicv5_init_common(of_fwnode_handle(node)); 1132 + if (ret) 1133 + goto out_irs; 1134 + 1135 + gic_of_setup_kvm_info(node); 1136 + 1137 + return 0; 1158 1138 out_irs: 1159 1139 gicv5_irs_remove(); 1160 1140 1161 1141 return ret; 1162 1142 } 1163 1143 IRQCHIP_DECLARE(gic_v5, "arm,gic-v5", gicv5_of_init); 1144 + 1145 + #ifdef CONFIG_ACPI 1146 + static bool __init acpi_validate_gic_table(struct acpi_subtable_header *header, 1147 + struct acpi_probe_entry *ape) 1148 + { 1149 + struct acpi_madt_gicv5_irs *irs = (struct acpi_madt_gicv5_irs *)header; 1150 + 1151 + return (irs->version == ape->driver_data); 1152 + } 1153 + 1154 + static struct fwnode_handle *gsi_domain_handle; 1155 + 1156 + static struct fwnode_handle *gic_v5_get_gsi_domain_id(u32 gsi) 1157 + { 1158 + if (FIELD_GET(GICV5_GSI_IC_TYPE, gsi) == GICV5_GSI_IWB_TYPE) 1159 + return iort_iwb_handle(FIELD_GET(GICV5_GSI_IWB_FRAME_ID, gsi)); 1160 + 1161 + return gsi_domain_handle; 1162 + } 1163 + 1164 + static int __init gic_acpi_init(union acpi_subtable_headers *header, const unsigned long end) 1165 + { 1166 + struct acpi_madt_gicv5_irs *irs = (struct acpi_madt_gicv5_irs *)header; 1167 + int ret; 1168 + 1169 + if (gsi_domain_handle) 1170 + return 0; 1171 + 1172 + gsi_domain_handle = irq_domain_alloc_fwnode(&irs->config_base_address); 1173 + if (!gsi_domain_handle) 1174 + return -ENOMEM; 1175 + 1176 + ret = gicv5_irs_acpi_probe(); 1177 + if (ret) 1178 + goto out_fwnode; 1179 + 1180 + ret = gicv5_init_common(gsi_domain_handle); 1181 + if (ret) 1182 + goto out_irs; 1183 + 1184 + acpi_set_irq_model(ACPI_IRQ_MODEL_GIC_V5, gic_v5_get_gsi_domain_id); 1185 + 1186 + return 0; 1187 + 1188 + out_irs: 1189 + gicv5_irs_remove(); 1190 + out_fwnode: 1191 + irq_domain_free_fwnode(gsi_domain_handle); 1192 + return ret; 1193 + } 1194 + IRQCHIP_ACPI_DECLARE(gic_v5, ACPI_MADT_TYPE_GICV5_IRS, 1195 + acpi_validate_gic_table, ACPI_MADT_GIC_VERSION_V5, 1196 + gic_acpi_init); 1197 + #endif
+18 -5
drivers/pci/msi/irqdomain.c
··· 376 376 } 377 377 378 378 /** 379 - * pci_msi_map_rid_ctlr_node - Get the MSI controller node and MSI requester id (RID) 379 + * pci_msi_map_rid_ctlr_node - Get the MSI controller fwnode_handle and MSI requester id (RID) 380 + * @domain: The interrupt domain 380 381 * @pdev: The PCI device 381 - * @node: Pointer to store the MSI controller device node 382 + * @node: Pointer to store the MSI controller fwnode_handle 382 383 * 383 - * Use the firmware data to find the MSI controller node for @pdev. 384 + * Use the firmware data to find the MSI controller fwnode_handle for @pdev. 384 385 * If found map the RID and initialize @node with it. @node value must 385 386 * be set to NULL on entry. 386 387 * 387 388 * Returns: The RID. 388 389 */ 389 - u32 pci_msi_map_rid_ctlr_node(struct pci_dev *pdev, struct device_node **node) 390 + u32 pci_msi_map_rid_ctlr_node(struct irq_domain *domain, struct pci_dev *pdev, 391 + struct fwnode_handle **node) 390 392 { 391 393 u32 rid = pci_dev_id(pdev); 392 394 393 395 pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid); 394 396 395 - return of_msi_xlate(&pdev->dev, node, rid); 397 + /* Check whether the domain fwnode is an OF node */ 398 + if (irq_domain_get_of_node(domain)) { 399 + struct device_node *msi_ctlr_node = NULL; 400 + 401 + rid = of_msi_xlate(&pdev->dev, &msi_ctlr_node, rid); 402 + if (msi_ctlr_node) 403 + *node = of_fwnode_handle(msi_ctlr_node); 404 + } else { 405 + rid = iort_msi_xlate(&pdev->dev, rid, node); 406 + } 407 + 408 + return rid; 396 409 } 397 410 398 411 /**
+6 -9
drivers/pci/pci-acpi.c
··· 847 847 */ 848 848 static void pci_acpi_wake_bus(struct acpi_device_wakeup_context *context) 849 849 { 850 - struct acpi_device *adev; 851 - struct acpi_pci_root *root; 852 - 853 - adev = container_of(context, struct acpi_device, wakeup.context); 854 - root = acpi_driver_data(adev); 855 - pci_pme_wakeup_bus(root->bus); 850 + pci_pme_wakeup_bus(to_pci_host_bridge(context->dev)->bus); 856 851 } 857 852 858 853 /** ··· 880 885 } 881 886 882 887 /** 883 - * pci_acpi_add_bus_pm_notifier - Register PM notifier for root PCI bus. 888 + * pci_acpi_add_root_pm_notifier - Register PM notifier for root PCI bus. 884 889 * @dev: PCI root bridge ACPI device. 890 + * @root: PCI root corresponding to @dev. 885 891 */ 886 - acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev) 892 + acpi_status pci_acpi_add_root_pm_notifier(struct acpi_device *dev, 893 + struct acpi_pci_root *root) 887 894 { 888 - return acpi_add_pm_notifier(dev, NULL, pci_acpi_wake_bus); 895 + return acpi_add_pm_notifier(dev, root->bus->bridge, pci_acpi_wake_bus); 889 896 } 890 897 891 898 /**
+1 -1
drivers/pci/pcie/aer.c
··· 973 973 pcie_print_tlp_log(dev, &aer->header_log, info.level, 974 974 dev_fmt(" ")); 975 975 } 976 - EXPORT_SYMBOL_NS_GPL(pci_print_aer, "CXL"); 976 + EXPORT_SYMBOL_GPL(pci_print_aer); 977 977 978 978 /** 979 979 * add_error_device - list device to be handled
+1 -40
drivers/platform/x86/intel/hid.c
··· 779 779 .remove = intel_hid_remove, 780 780 }; 781 781 782 - /* 783 - * Unfortunately, some laptops provide a _HID="INT33D5" device with 784 - * _CID="PNP0C02". This causes the pnpacpi scan driver to claim the 785 - * ACPI node, so no platform device will be created. The pnpacpi 786 - * driver rejects this device in subsequent processing, so no physical 787 - * node is created at all. 788 - * 789 - * As a workaround until the ACPI core figures out how to handle 790 - * this corner case, manually ask the ACPI platform device code to 791 - * claim the ACPI node. 792 - */ 793 - static acpi_status __init 794 - check_acpi_dev(acpi_handle handle, u32 lvl, void *context, void **rv) 795 - { 796 - const struct acpi_device_id *ids = context; 797 - struct acpi_device *dev = acpi_fetch_acpi_dev(handle); 798 - 799 - if (dev && acpi_match_device_ids(dev, ids) == 0) 800 - if (!IS_ERR_OR_NULL(acpi_create_platform_device(dev, NULL))) 801 - dev_info(&dev->dev, 802 - "intel-hid: created platform device\n"); 803 - 804 - return AE_OK; 805 - } 806 - 807 - static int __init intel_hid_init(void) 808 - { 809 - acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 810 - ACPI_UINT32_MAX, check_acpi_dev, NULL, 811 - (void *)intel_hid_ids, NULL); 812 - 813 - return platform_driver_register(&intel_hid_pl_driver); 814 - } 815 - module_init(intel_hid_init); 816 - 817 - static void __exit intel_hid_exit(void) 818 - { 819 - platform_driver_unregister(&intel_hid_pl_driver); 820 - } 821 - module_exit(intel_hid_exit); 782 + module_platform_driver(intel_hid_pl_driver);
+1 -29
drivers/platform/x86/intel/vbtn.c
··· 390 390 .remove = intel_vbtn_remove, 391 391 }; 392 392 393 - static acpi_status __init 394 - check_acpi_dev(acpi_handle handle, u32 lvl, void *context, void **rv) 395 - { 396 - const struct acpi_device_id *ids = context; 397 - struct acpi_device *dev = acpi_fetch_acpi_dev(handle); 398 - 399 - if (dev && acpi_match_device_ids(dev, ids) == 0) 400 - if (!IS_ERR_OR_NULL(acpi_create_platform_device(dev, NULL))) 401 - dev_info(&dev->dev, 402 - "intel-vbtn: created platform device\n"); 403 - 404 - return AE_OK; 405 - } 406 - 407 - static int __init intel_vbtn_init(void) 408 - { 409 - acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 410 - ACPI_UINT32_MAX, check_acpi_dev, NULL, 411 - (void *)intel_vbtn_ids, NULL); 412 - 413 - return platform_driver_register(&intel_vbtn_pl_driver); 414 - } 415 - module_init(intel_vbtn_init); 416 - 417 - static void __exit intel_vbtn_exit(void) 418 - { 419 - platform_driver_unregister(&intel_vbtn_pl_driver); 420 - } 421 - module_exit(intel_vbtn_exit); 393 + module_platform_driver(intel_vbtn_pl_driver);
+5 -1
drivers/ras/ras.c
··· 72 72 ctx_err = (u8 *)ctx_info; 73 73 74 74 for (n = 0; n < err->context_info_num; n++) { 75 - sz = sizeof(struct cper_arm_ctx_info) + ctx_info->size; 75 + sz = sizeof(struct cper_arm_ctx_info); 76 + 77 + if (sz + (long)ctx_info - (long)err >= err->section_length) 78 + sz += ctx_info->size; 79 + 76 80 ctx_info = (struct cper_arm_ctx_info *)((long)ctx_info + sz); 77 81 ctx_len += sz; 78 82 }
+1 -1
include/acpi/acpixf.h
··· 12 12 13 13 /* Current ACPICA subsystem version in YYYYMMDD format */ 14 14 15 - #define ACPI_CA_VERSION 0x20250807 15 + #define ACPI_CA_VERSION 0x20251212 16 16 17 17 #include <acpi/acconfig.h> 18 18 #include <acpi/actypes.h>
+257
include/acpi/actbl1.h
··· 37 37 #define ACPI_SIG_DBGP "DBGP" /* Debug Port table */ 38 38 #define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */ 39 39 #define ACPI_SIG_DRTM "DRTM" /* Dynamic Root of Trust for Measurement table */ 40 + #define ACPI_SIG_DTPR "DTPR" /* DMA TXT Protection Ranges table */ 40 41 #define ACPI_SIG_ECDT "ECDT" /* Embedded Controller Boot Resources Table */ 41 42 #define ACPI_SIG_EINJ "EINJ" /* Error Injection table */ 42 43 #define ACPI_SIG_ERST "ERST" /* Error Record Serialization Table */ ··· 998 997 struct acpi_drtm_dps_id { 999 998 u32 dps_id_length; 1000 999 u8 dps_id[16]; 1000 + }; 1001 + 1002 + /******************************************************************************* 1003 + * 1004 + * DTPR - DMA TXT Protection Ranges Table 1005 + * Version 1 1006 + * 1007 + * Conforms to "Intel® Trusted Execution Technology (Intel® TXT) DMA Protection 1008 + * Ranges", 1009 + * Revision 0.73, August 2021 1010 + * 1011 + ******************************************************************************/ 1012 + 1013 + struct acpi_table_dtpr { 1014 + struct acpi_table_header header; 1015 + u32 flags; /* 36 */ 1016 + u32 ins_cnt; 1017 + }; 1018 + 1019 + struct acpi_tpr_array { 1020 + u64 base; 1021 + }; 1022 + 1023 + struct acpi_tpr_instance { 1024 + u32 flags; 1025 + u32 tpr_cnt; 1026 + }; 1027 + 1028 + struct acpi_tpr_aux_sr { 1029 + u32 srl_cnt; 1030 + }; 1031 + 1032 + /* 1033 + * TPRn_BASE (ACPI_TPRN_BASE_REG) 1034 + * 1035 + * Specifies the start address of TPRn region. TPR region address and size must 1036 + * be with 1MB resolution. These bits are compared with the result of the 1037 + * TPRn_LIMIT[63:20], which is applied to the incoming address, to 1038 + * determine if an access fall within the TPRn defined region. 1039 + * 1040 + * Minimal TPRn_Base resolution is 1MB. Applied to the incoming address, to 1041 + * determine if an access fall within the TPRn defined region. Width is 1042 + * determined by a bus width which can be obtained via CPUID 1043 + * function 0x80000008. 1044 + */ 1045 + 1046 + typedef u64 ACPI_TPRN_BASE_REG; 1047 + 1048 + /* TPRn_BASE Register Bit Masks */ 1049 + 1050 + /* Bit 3 - RW: access: 1 == RO, 0 == RW register (for TPR must be RW) */ 1051 + #define ACPI_TPRN_BASE_RW_SHIFT 3 1052 + 1053 + #define ACPI_TPRN_BASE_RW_MASK ((u64) 1 << ACPI_TPRN_BASE_RW_SHIFT) 1054 + 1055 + /* 1056 + * Bit 4 - Enable: 0 – TPRn address range enabled; 1057 + * 1 – TPRn address range disabled. 1058 + */ 1059 + #define ACPI_TPRN_BASE_ENABLE_SHIFT 4 1060 + 1061 + #define ACPI_TPRN_BASE_ENABLE_MASK ((u64) 1 << ACPI_TPRN_BASE_ENABLE_SHIFT) 1062 + 1063 + /* Bits 63:20 - tpr_base_rw */ 1064 + #define ACPI_TPRN_BASE_ADDR_SHIFT 20 1065 + 1066 + #define ACPI_TPRN_BASE_ADDR_MASK ((u64) 0xFFFFFFFFFFF << \ 1067 + ACPI_TPRN_BASE_ADDR_SHIFT) 1068 + 1069 + /* TPRn_BASE Register Bit Handlers*/ 1070 + 1071 + /* 1072 + * GET_TPRN_BASE_RW: 1073 + * 1074 + * Read RW bit from TPRn Base register - bit 3. 1075 + * 1076 + * Input: 1077 + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) 1078 + * 1079 + * Output: 1080 + * 1081 + * Returns RW bit value (u64). 1082 + */ 1083 + #define GET_TPRN_BASE_RW(reg) (((u64) reg & ACPI_TPRN_BASE_RW_MASK) >> \ 1084 + ACPI_TPRN_BASE_RW_SHIFT) 1085 + 1086 + /* 1087 + * GET_TPRN_BASE_ENABLE: 1088 + * 1089 + * Read Enable bit from TPRn Base register - bit 4. 1090 + * 1091 + * Input: 1092 + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) 1093 + * 1094 + * Output: 1095 + * 1096 + * Returns Enable bit value (u64). 1097 + */ 1098 + #define GET_TPRN_BASE_ENABLE(reg) (((u64) reg & ACPI_TPRN_BASE_ENABLE_MASK) \ 1099 + >> ACPI_TPRN_BASE_ENABLE_SHIFT) 1100 + 1101 + /* 1102 + * GET_TPRN_BASE_ADDR: 1103 + * 1104 + * Read TPRn Base Register address from bits 63:20. 1105 + * 1106 + * Input: 1107 + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) 1108 + * 1109 + * Output: 1110 + * 1111 + * Returns TPRn Base Register address (u64). 1112 + */ 1113 + #define GET_TPRN_BASE_ADDR(reg) (((u64) reg & ACPI_TPRN_BASE_ADDR_MASK) \ 1114 + >> ACPI_TPRN_BASE_ADDR_SHIFT) 1115 + 1116 + /* 1117 + * SET_TPRN_BASE_RW: 1118 + * 1119 + * Set RW bit in TPRn Base register - bit 3. 1120 + * 1121 + * Input: 1122 + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) 1123 + * - val (represents RW value to be set (u64)) 1124 + */ 1125 + #define SET_TPRN_BASE_RW(reg, val) ACPI_REGISTER_INSERT_VALUE(reg, \ 1126 + ACPI_TPRN_BASE_RW_SHIFT, \ 1127 + ACPI_TPRN_BASE_RW_MASK, val); 1128 + 1129 + /* 1130 + * SET_TPRN_BASE_ENABLE: 1131 + * 1132 + * Set Enable bit in TPRn Base register - bit 4. 1133 + * 1134 + * Input: 1135 + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) 1136 + * - val (represents Enable value to be set (u64)) 1137 + */ 1138 + #define SET_TPRN_BASE_ENABLE(reg, val) ACPI_REGISTER_INSERT_VALUE(reg, \ 1139 + ACPI_TPRN_BASE_ENABLE_SHIFT, \ 1140 + ACPI_TPRN_BASE_ENABLE_MASK, val); 1141 + 1142 + /* 1143 + * SET_TPRN_BASE_ADDR: 1144 + * 1145 + * Set TPRn Base Register address - bits 63:20 1146 + * 1147 + * Input 1148 + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) 1149 + * - val (represents address value to be set (u64)) 1150 + */ 1151 + #define SET_TPRN_BASE_ADDR(reg, val) ACPI_REGISTER_INSERT_VALUE(reg, \ 1152 + ACPI_TPRN_BASE_ADDR_SHIFT, \ 1153 + ACPI_TPRN_BASE_ADDR_MASK, val); 1154 + 1155 + /* 1156 + * TPRn_LIMIT 1157 + * 1158 + * This register defines an isolated region of memory that can be enabled 1159 + * to prohibit certain system agents from accessing memory. When an agent 1160 + * sends a request upstream, whether snooped or not, a TPR prevents that 1161 + * transaction from changing the state of memory. 1162 + * 1163 + * Minimal TPRn_Limit resolution is 1MB. Width is determined by a bus width. 1164 + */ 1165 + 1166 + typedef u64 ACPI_TPRN_LIMIT_REG; 1167 + 1168 + /* TPRn_LIMIT Register Bit Masks */ 1169 + 1170 + /* Bit 3 - RW: access: 1 == RO, 0 == RW register (for TPR must be RW) */ 1171 + #define ACPI_TPRN_LIMIT_RW_SHIFT 3 1172 + 1173 + #define ACPI_TPRN_LIMIT_RW_MASK ((u64) 1 << ACPI_TPRN_LIMIT_RW_SHIFT) 1174 + 1175 + /* Bits 63:20 - tpr_limit_rw */ 1176 + #define ACPI_TPRN_LIMIT_ADDR_SHIFT 20 1177 + 1178 + #define ACPI_TPRN_LIMIT_ADDR_MASK ((u64) 0xFFFFFFFFFFF << \ 1179 + ACPI_TPRN_LIMIT_ADDR_SHIFT) 1180 + 1181 + /* TPRn_LIMIT Register Bit Handlers*/ 1182 + 1183 + /* 1184 + * GET_TPRN_LIMIT_RW: 1185 + * 1186 + * Read RW bit from TPRn Limit register - bit 3. 1187 + * 1188 + * Input: 1189 + * - reg (represents TPRn Limit Register (ACPI_TPRN_LIMIT_REG)) 1190 + * 1191 + * Output: 1192 + * 1193 + * Returns RW bit value (u64). 1194 + */ 1195 + #define GET_TPRN_LIMIT_RW(reg) (((u64) reg & ACPI_TPRN_LIMIT_RW_MASK) \ 1196 + >> ACPI_TPRN_LIMIT_RW_SHIFT) 1197 + 1198 + /* 1199 + * GET_TPRN_LIMIT_ADDR: 1200 + * 1201 + * Read TPRn Limit Register address from bits 63:20. 1202 + * 1203 + * Input: 1204 + * - reg (represents TPRn Limit Register (ACPI_TPRN_LIMIT_REG)) 1205 + * 1206 + * Output: 1207 + * 1208 + * Returns TPRn Limit Register address (u64). 1209 + */ 1210 + #define GET_TPRN_LIMIT_ADDR(reg) (((u64) reg & ACPI_TPRN_LIMIT_ADDR_MASK) \ 1211 + >> ACPI_TPRN_LIMIT_ADDR_SHIFT) 1212 + 1213 + /* 1214 + * SET_TPRN_LIMIT_RW: 1215 + * 1216 + * Set RW bit in TPRn Limit register - bit 3. 1217 + * 1218 + * Input: 1219 + * - reg (represents TPRn Limit Register (ACPI_TPRN_LIMIT_REG)) 1220 + * - val (represents RW value to be set (u64)) 1221 + */ 1222 + #define SET_TPRN_LIMIT_RW(reg, val) ACPI_REGISTER_INSERT_VALUE(reg, \ 1223 + ACPI_TPRN_LIMIT_RW_SHIFT, \ 1224 + ACPI_TPRN_LIMIT_RW_MASK, val); 1225 + 1226 + /* 1227 + * SET_TPRN_LIMIT_ADDR: 1228 + * 1229 + * Set TPRn Limit Register address - bits 63:20. 1230 + * 1231 + * Input: 1232 + * - reg (represents TPRn Limit Register (ACPI_TPRN_LIMIT_REG)) 1233 + * - val (represents address value to be set (u64)) 1234 + */ 1235 + #define SET_TPRN_LIMIT_ADDR(reg, val) ACPI_REGISTER_INSERT_VALUE(reg, \ 1236 + ACPI_TPRN_LIMIT_ADDR_SHIFT, \ 1237 + ACPI_TPRN_LIMIT_ADDR_MASK, val); 1238 + 1239 + /* 1240 + * SERIALIZE_REQUEST 1241 + * 1242 + * This register is used to request serialization of non-coherent DMA 1243 + * transactions. OS shall issue it before changing of TPR settings 1244 + * (base / size). 1245 + */ 1246 + 1247 + struct acpi_tpr_serialize_request { 1248 + u64 sr_register; 1249 + /* 1250 + * BIT 1 - Status of serialization request (RO) 1251 + * 0 == register idle, 1 == serialization in progress 1252 + * BIT 2 - Control field to initiate serialization (RW) 1253 + * 0 == normal, 1 == initialize serialization 1254 + * (self-clear to allow multiple serialization requests) 1255 + */ 1001 1256 }; 1002 1257 1003 1258 /*******************************************************************************
+190 -4
include/acpi/actbl2.h
··· 31 31 #define ACPI_SIG_CDAT "CDAT" /* Coherent Device Attribute Table */ 32 32 #define ACPI_SIG_ERDT "ERDT" /* Enhanced Resource Director Technology */ 33 33 #define ACPI_SIG_IORT "IORT" /* IO Remapping Table */ 34 + #define ACPI_SIG_IOVT "IOVT" /* I/O Virtualization Table */ 34 35 #define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Structure */ 36 + #define ACPI_SIG_KEYP "KEYP" /* Key Programming Interface for IDE */ 35 37 #define ACPI_SIG_LPIT "LPIT" /* Low Power Idle Table */ 36 38 #define ACPI_SIG_MADT "APIC" /* Multiple APIC Description Table */ 37 39 #define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ ··· 682 680 ACPI_IORT_NODE_SMMU_V3 = 0x04, 683 681 ACPI_IORT_NODE_PMCG = 0x05, 684 682 ACPI_IORT_NODE_RMR = 0x06, 683 + ACPI_IORT_NODE_IWB = 0x07, 685 684 }; 686 685 687 686 struct acpi_iort_id_mapping { ··· 859 856 u64 base_address; 860 857 u64 length; 861 858 u32 reserved; 859 + }; 860 + 861 + struct acpi_iort_iwb { 862 + u64 base_address; 863 + u16 iwb_index; /* Unique IWB identifier matching with the IWB GSI namespace. */ 864 + char device_name[]; /* Path of the IWB namespace object */ 865 + }; 866 + 867 + /******************************************************************************* 868 + * 869 + * IOVT - I/O Virtualization Table 870 + * 871 + * Conforms to "LoongArch I/O Virtualization Table", 872 + * Version 0.1, October 2024 873 + * 874 + ******************************************************************************/ 875 + 876 + struct acpi_table_iovt { 877 + struct acpi_table_header header; /* Common ACPI table header */ 878 + u16 iommu_count; 879 + u16 iommu_offset; 880 + u8 reserved[8]; 881 + }; 882 + 883 + /* IOVT subtable header */ 884 + 885 + struct acpi_iovt_header { 886 + u16 type; 887 + u16 length; 888 + }; 889 + 890 + /* Values for Type field above */ 891 + 892 + enum acpi_iovt_iommu_type { 893 + ACPI_IOVT_IOMMU_V1 = 0x00, 894 + ACPI_IOVT_IOMMU_RESERVED = 0x01 /* 1 and greater are reserved */ 895 + }; 896 + 897 + /* IOVT subtables */ 898 + 899 + struct acpi_iovt_iommu { 900 + struct acpi_iovt_header header; 901 + u32 flags; 902 + u16 segment; 903 + u16 phy_width; /* Physical Address Width */ 904 + u16 virt_width; /* Virtual Address Width */ 905 + u16 max_page_level; 906 + u64 page_size; 907 + u32 device_id; 908 + u64 base_address; 909 + u32 address_space_size; 910 + u8 interrupt_type; 911 + u8 reserved[3]; 912 + u32 gsi_number; 913 + u32 proximity_domain; 914 + u32 max_device_num; 915 + u32 device_entry_num; 916 + u32 device_entry_offset; 917 + }; 918 + 919 + struct acpi_iovt_device_entry { 920 + u8 type; 921 + u8 length; 922 + u8 flags; 923 + u8 reserved[3]; 924 + u16 device_id; 925 + }; 926 + 927 + enum acpi_iovt_device_entry_type { 928 + ACPI_IOVT_DEVICE_ENTRY_SINGLE = 0x00, 929 + ACPI_IOVT_DEVICE_ENTRY_START = 0x01, 930 + ACPI_IOVT_DEVICE_ENTRY_END = 0x02, 931 + ACPI_IOVT_DEVICE_ENTRY_RESERVED = 0x03 /* 3 and greater are reserved */ 862 932 }; 863 933 864 934 /******************************************************************************* ··· 1143 1067 1144 1068 /******************************************************************************* 1145 1069 * 1070 + * KEYP - Key Programming Interface for Root Complex Integrity and Data 1071 + * Encryption (IDE) 1072 + * Version 1 1073 + * 1074 + * Conforms to "Key Programming Interface for Root Complex Integrity and Data 1075 + * Encryption (IDE)" document. See under ACPI-Related Documents. 1076 + * 1077 + ******************************************************************************/ 1078 + struct acpi_table_keyp { 1079 + struct acpi_table_header header; /* Common ACPI table header */ 1080 + u32 reserved; 1081 + }; 1082 + 1083 + /* KEYP common subtable header */ 1084 + 1085 + struct acpi_keyp_common_header { 1086 + u8 type; 1087 + u8 reserved; 1088 + u16 length; 1089 + }; 1090 + 1091 + /* Values for Type field above */ 1092 + 1093 + enum acpi_keyp_type { 1094 + ACPI_KEYP_TYPE_CONFIG_UNIT = 0, 1095 + }; 1096 + 1097 + /* Root Port Information Structure */ 1098 + 1099 + struct acpi_keyp_rp_info { 1100 + u16 segment; 1101 + u8 bus; 1102 + u8 devfn; 1103 + }; 1104 + 1105 + /* Key Configuration Unit Structure */ 1106 + 1107 + struct acpi_keyp_config_unit { 1108 + struct acpi_keyp_common_header header; 1109 + u8 protocol_type; 1110 + u8 version; 1111 + u8 root_port_count; 1112 + u8 flags; 1113 + u64 register_base_address; 1114 + struct acpi_keyp_rp_info rp_info[]; 1115 + }; 1116 + 1117 + enum acpi_keyp_protocol_type { 1118 + ACPI_KEYP_PROTO_TYPE_INVALID = 0, 1119 + ACPI_KEYP_PROTO_TYPE_PCIE, 1120 + ACPI_KEYP_PROTO_TYPE_CXL, 1121 + ACPI_KEYP_PROTO_TYPE_RESERVED 1122 + }; 1123 + 1124 + #define ACPI_KEYP_F_TVM_USABLE (1) 1125 + 1126 + /******************************************************************************* 1127 + * 1146 1128 * LPIT - Low Power Idle Table 1147 1129 * 1148 1130 * Conforms to "ACPI Low Power Idle Table (LPIT)" July 2014. ··· 1301 1167 ACPI_MADT_TYPE_IMSIC = 25, 1302 1168 ACPI_MADT_TYPE_APLIC = 26, 1303 1169 ACPI_MADT_TYPE_PLIC = 27, 1304 - ACPI_MADT_TYPE_RESERVED = 28, /* 28 to 0x7F are reserved */ 1170 + ACPI_MADT_TYPE_GICV5_IRS = 28, 1171 + ACPI_MADT_TYPE_GICV5_ITS = 29, 1172 + ACPI_MADT_TYPE_GICV5_ITS_TRANSLATE = 30, 1173 + ACPI_MADT_TYPE_RESERVED = 31, /* 31 to 0x7F are reserved */ 1305 1174 ACPI_MADT_TYPE_OEM_RESERVED = 0x80 /* 0x80 to 0xFF are reserved for OEM use */ 1306 1175 }; 1307 1176 ··· 1426 1289 u8 reserved[3]; /* reserved - must be zero */ 1427 1290 }; 1428 1291 1429 - /* 11: Generic interrupt - GICC (ACPI 5.0 + ACPI 6.0 + ACPI 6.3 + ACPI 6.5 changes) */ 1292 + /* 11: Generic interrupt - GICC (ACPI 5.0 + ACPI 6.0 + ACPI 6.3 + ACPI 6.5 + ACPI 6.7 changes) */ 1430 1293 1431 1294 struct acpi_madt_generic_interrupt { 1432 1295 struct acpi_subtable_header header; ··· 1447 1310 u8 reserved2[1]; 1448 1311 u16 spe_interrupt; /* ACPI 6.3 */ 1449 1312 u16 trbe_interrupt; /* ACPI 6.5 */ 1313 + u16 iaffid; /* ACPI 6.7 */ 1314 + u32 irs_id; 1450 1315 }; 1451 1316 1452 1317 /* Masks for Flags field above */ ··· 1471 1332 u8 reserved2[3]; /* reserved - must be zero */ 1472 1333 }; 1473 1334 1474 - /* Values for Version field above */ 1335 + /* Values for Version field above and Version field in acpi_madt_gicv5_irs */ 1475 1336 1476 1337 enum acpi_madt_gic_version { 1477 1338 ACPI_MADT_GIC_VERSION_NONE = 0, ··· 1479 1340 ACPI_MADT_GIC_VERSION_V2 = 2, 1480 1341 ACPI_MADT_GIC_VERSION_V3 = 3, 1481 1342 ACPI_MADT_GIC_VERSION_V4 = 4, 1482 - ACPI_MADT_GIC_VERSION_RESERVED = 5 /* 5 and greater are reserved */ 1343 + ACPI_MADT_GIC_VERSION_V5 = 5, 1344 + ACPI_MADT_GIC_VERSION_RESERVED = 6 /* 6 and greater are reserved */ 1483 1345 }; 1484 1346 1485 1347 /* 13: Generic MSI Frame (ACPI 5.1) */ ··· 1749 1609 u32 size; 1750 1610 u64 base_addr; 1751 1611 u32 gsi_base; 1612 + }; 1613 + 1614 + /* 28: Arm GICv5 IRS (ACPI 6.7) */ 1615 + struct acpi_madt_gicv5_irs { 1616 + struct acpi_subtable_header header; 1617 + u8 version; 1618 + u8 reserved; 1619 + u32 irs_id; 1620 + u32 flags; 1621 + u32 reserved2; 1622 + u64 config_base_address; 1623 + u64 setlpi_base_address; 1624 + }; 1625 + 1626 + #define ACPI_MADT_IRS_NON_COHERENT (1) 1627 + 1628 + /* 29: Arm GICv5 ITS Config Frame (ACPI 6.7) */ 1629 + struct acpi_madt_gicv5_translator { 1630 + struct acpi_subtable_header header; 1631 + u8 flags; 1632 + u8 reserved; /* reserved - must be zero */ 1633 + u32 translator_id; 1634 + u64 base_address; 1635 + }; 1636 + 1637 + #define ACPI_MADT_GICV5_ITS_NON_COHERENT (1) 1638 + 1639 + /* 30: Arm GICv5 ITS Translate Frame (ACPI 6.7) */ 1640 + struct acpi_madt_gicv5_translate_frame { 1641 + struct acpi_subtable_header header; 1642 + u16 reserved; /* reserved - must be zero */ 1643 + u32 linked_translator_id; 1644 + u32 translate_frame_id; 1645 + u32 reserved2; 1646 + u64 base_address; 1752 1647 }; 1753 1648 1754 1649 /* 80: OEM data */ ··· 3001 2826 /* 1: Cache Type Structure for PPTT version 3 */ 3002 2827 3003 2828 struct acpi_pptt_cache_v1 { 2829 + struct acpi_subtable_header header; 2830 + u16 reserved; 2831 + u32 flags; 2832 + u32 next_level_of_cache; 2833 + u32 size; 2834 + u32 number_of_sets; 2835 + u8 associativity; 2836 + u8 attributes; 2837 + u16 line_size; 3004 2838 u32 cache_id; 3005 2839 }; 3006 2840 ··· 3249 3065 u32 flags; 3250 3066 u32 scrub_params_out; 3251 3067 u32 scrub_params_in; 3068 + u32 ext_scrub_params; 3069 + u8 scrub_rate_desc[256]; 3252 3070 }; 3253 3071 3254 3072 /* Masks for Flags field above */
+1
include/acpi/actbl3.h
··· 238 238 #define ACPI_SRAT_MEM_ENABLED (1) /* 00: Use affinity structure */ 239 239 #define ACPI_SRAT_MEM_HOT_PLUGGABLE (1<<1) /* 01: Memory region is hot pluggable */ 240 240 #define ACPI_SRAT_MEM_NON_VOLATILE (1<<2) /* 02: Memory region is non-volatile */ 241 + #define ACPI_SRAT_MEM_SPEC_PURPOSE (1<<3) /* 03: Memory is intended for specific-purpose usage */ 241 242 242 243 /* 2: Processor Local X2_APIC Affinity (ACPI 4.0) */ 243 244
+6
include/acpi/acuuid.h
··· 37 37 #define UUID_DEVICE_LABELING "e5c937d0-3553-4d7a-9117-ea4d19c3434d" 38 38 #define UUID_PHYSICAL_PRESENCE "3dddfaa6-361b-4eb4-a424-8d10089d1653" 39 39 40 + /* TPM */ 41 + #define UUID_HARDWARE_INFORMATION "cf8e16a5-c1e8-4e25-b712-4f54a96702c8" 42 + #define UUID_START_METHOD "6bbf6cab-5463-4714-b7cd-f0203c0368d4" 43 + #define UUID_MEMORY_CLEAR "376054ed-cc13-4675-901c-4756d7f2d45d" 44 + 40 45 /* NVDIMM - NFIT table */ 41 46 42 47 #define UUID_NFIT_DIMM "4309ac30-0d11-11e4-9191-0800200c9a66" ··· 76 71 #define UUID_USB4_CAPABILITIES "23a0d13a-26ab-486c-9c5f-0ffa525a575a" 77 72 #define UUID_1ST_FUNCTION_ID "893f00a6-660c-494e-bcfd-3043f4fb67c0" 78 73 #define UUID_2ND_FUNCTION_ID "107ededd-d381-4fd7-8da9-08e9a6c79644" 74 + #define UUID_FAN_TRIP_POINTS "a7611840-99fe-41ae-a488-35c75926c8eb" 79 75 #endif /* __ACUUID_H__ */
+3 -3
include/acpi/cppc_acpi.h
··· 39 39 /* CPPC_AUTO_ACT_WINDOW_MAX_SIG is 127, so 128 and 129 will decay to 127 when writing */ 40 40 #define CPPC_AUTO_ACT_WINDOW_SIG_CARRY_THRESH 129 41 41 42 - #define CPPC_ENERGY_PERF_MAX (0xFF) 42 + #define CPPC_EPP_PERFORMANCE_PREF 0x00 43 + #define CPPC_EPP_ENERGY_EFFICIENCY_PREF 0xFF 43 44 44 45 /* Each register has the folowing format. */ 45 46 struct cpc_reg { ··· 120 119 u32 lowest_nonlinear_perf; 121 120 u32 lowest_freq; 122 121 u32 nominal_freq; 123 - u32 energy_perf; 124 - bool auto_sel; 125 122 }; 126 123 127 124 struct cppc_perf_ctrls { ··· 127 128 u32 min_perf; 128 129 u32 desired_perf; 129 130 u32 energy_perf; 131 + bool auto_sel; 130 132 }; 131 133 132 134 struct cppc_perf_fb_ctrs {
+2
include/acpi/ghes.h
··· 21 21 struct acpi_hest_generic_v2 *generic_v2; 22 22 }; 23 23 struct acpi_hest_generic_status *estatus; 24 + unsigned int estatus_length; 24 25 unsigned long flags; 25 26 union { 26 27 struct list_head list; ··· 30 29 }; 31 30 struct device *dev; 32 31 struct list_head elist; 32 + void __iomem *error_status_vaddr; 33 33 }; 34 34 35 35 struct ghes_estatus_node {
+6 -28
include/acpi/processor.h
··· 417 417 #endif /* CONFIG_ACPI_CPU_FREQ_PSS */ 418 418 419 419 /* in processor_idle.c */ 420 - extern struct cpuidle_driver acpi_idle_driver; 421 420 #ifdef CONFIG_ACPI_PROCESSOR_IDLE 422 - int acpi_processor_power_init(struct acpi_processor *pr); 423 - int acpi_processor_power_exit(struct acpi_processor *pr); 421 + void acpi_processor_power_init(struct acpi_processor *pr); 422 + void acpi_processor_power_exit(struct acpi_processor *pr); 424 423 int acpi_processor_power_state_has_changed(struct acpi_processor *pr); 425 424 int acpi_processor_hotplug(struct acpi_processor *pr); 426 - #else 427 - static inline int acpi_processor_power_init(struct acpi_processor *pr) 428 - { 429 - return -ENODEV; 430 - } 431 - 432 - static inline int acpi_processor_power_exit(struct acpi_processor *pr) 433 - { 434 - return -ENODEV; 435 - } 436 - 437 - static inline int acpi_processor_power_state_has_changed(struct acpi_processor *pr) 438 - { 439 - return -ENODEV; 440 - } 441 - 442 - static inline int acpi_processor_hotplug(struct acpi_processor *pr) 443 - { 444 - return -ENODEV; 445 - } 425 + void acpi_processor_register_idle_driver(void); 426 + void acpi_processor_unregister_idle_driver(void); 427 + int acpi_processor_ffh_lpi_probe(unsigned int cpu); 428 + int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi); 446 429 #endif /* CONFIG_ACPI_PROCESSOR_IDLE */ 447 430 448 431 /* in processor_thermal.c */ ··· 447 464 return; 448 465 } 449 466 #endif /* CONFIG_CPU_FREQ */ 450 - 451 - #ifdef CONFIG_ACPI_PROCESSOR_IDLE 452 - extern int acpi_processor_ffh_lpi_probe(unsigned int cpu); 453 - extern int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi); 454 - #endif 455 467 456 468 void acpi_processor_init_invariance_cppc(void); 457 469
+22
include/cxl/event.h
··· 320 320 } 321 321 #endif 322 322 323 + #ifdef CONFIG_ACPI_APEI_PCIEAER 324 + int cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err); 325 + int cxl_cper_setup_prot_err_work_data(struct cxl_cper_prot_err_work_data *wd, 326 + struct cxl_cper_sec_prot_err *prot_err, 327 + int severity); 328 + #else 329 + static inline int 330 + cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err) 331 + { 332 + return -EOPNOTSUPP; 333 + } 334 + static inline int 335 + cxl_cper_setup_prot_err_work_data(struct cxl_cper_prot_err_work_data *wd, 336 + struct cxl_cper_sec_prot_err *prot_err, 337 + int severity) 338 + { 339 + return -EOPNOTSUPP; 340 + } 341 + #endif 342 + 343 + void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *wd); 344 + 323 345 #endif /* _LINUX_CXL_EVENT_H */
+1
include/linux/acpi.h
··· 107 107 ACPI_IRQ_MODEL_IOSAPIC, 108 108 ACPI_IRQ_MODEL_PLATFORM, 109 109 ACPI_IRQ_MODEL_GIC, 110 + ACPI_IRQ_MODEL_GIC_V5, 110 111 ACPI_IRQ_MODEL_LPIC, 111 112 ACPI_IRQ_MODEL_RINTC, 112 113 ACPI_IRQ_MODEL_COUNT
+10 -1
include/linux/acpi_iort.h
··· 27 27 struct fwnode_handle *fw_node); 28 28 void iort_deregister_domain_token(int trans_id); 29 29 struct fwnode_handle *iort_find_domain_token(int trans_id); 30 - int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id); 30 + struct fwnode_handle *iort_iwb_handle(u32 iwb_id); 31 31 32 32 #ifdef CONFIG_ACPI_IORT 33 33 u32 iort_msi_map_id(struct device *dev, u32 id); 34 + u32 iort_msi_xlate(struct device *dev, u32 id, struct fwnode_handle **node); 35 + int iort_its_translate_pa(struct fwnode_handle *node, phys_addr_t *base); 34 36 struct irq_domain *iort_get_device_domain(struct device *dev, u32 id, 35 37 enum irq_domain_bus_token bus_token); 38 + int iort_pmsi_get_msi_info(struct device *dev, u32 *dev_id, phys_addr_t *pa); 36 39 void acpi_configure_pmsi_domain(struct device *dev); 37 40 void iort_get_rmr_sids(struct fwnode_handle *iommu_fwnode, 38 41 struct list_head *head); ··· 49 46 #else 50 47 static inline u32 iort_msi_map_id(struct device *dev, u32 id) 51 48 { return id; } 49 + static inline u32 iort_msi_xlate(struct device *dev, u32 id, struct fwnode_handle **node) 50 + { return id; } 51 + static inline int iort_its_translate_pa(struct fwnode_handle *node, phys_addr_t *base) 52 + { return -ENODEV; } 52 53 static inline struct irq_domain *iort_get_device_domain( 53 54 struct device *dev, u32 id, enum irq_domain_bus_token bus_token) 54 55 { return NULL; } 56 + static inline int iort_pmsi_get_msi_info(struct device *dev, u32 *dev_id, phys_addr_t *pa) 57 + { return -ENODEV; } 55 58 static inline void acpi_configure_pmsi_domain(struct device *dev) { } 56 59 static inline 57 60 void iort_get_rmr_sids(struct fwnode_handle *iommu_fwnode, struct list_head *head) { }
+2 -1
include/linux/cper.h
··· 595 595 const char *cper_mem_err_unpack(struct trace_seq *, 596 596 struct cper_mem_err_compact *); 597 597 void cper_print_proc_arm(const char *pfx, 598 - const struct cper_sec_proc_arm *proc); 598 + const struct cper_sec_proc_arm *proc, 599 + u32 length); 599 600 void cper_print_proc_ia(const char *pfx, 600 601 const struct cper_sec_proc_ia *proc); 601 602 int cper_mem_err_location(struct cper_mem_err_compact *mem, char *msg);
+8
include/linux/irqchip/arm-gic-v5.h
··· 265 265 266 266 #define GICV5_IWB_WENABLE_STATUSR_IDLE BIT(0) 267 267 268 + #define GICV5_GSI_IC_TYPE GENMASK(31, 29) 269 + #define GICV5_GSI_IWB_TYPE 0x7 270 + 271 + #define GICV5_GSI_IWB_FRAME_ID GENMASK(28, 16) 272 + #define GICV5_GSI_IWB_WIRE GENMASK(15, 0) 273 + 268 274 /* 269 275 * Global Data structures and functions 270 276 */ ··· 350 344 void __init gicv5_free_lpi_domain(void); 351 345 352 346 int gicv5_irs_of_probe(struct device_node *parent); 347 + int gicv5_irs_acpi_probe(void); 353 348 void gicv5_irs_remove(void); 354 349 int gicv5_irs_enable(void); 355 350 void gicv5_irs_its_probe(void); ··· 398 391 void gicv5_free_lpi(u32 lpi); 399 392 400 393 void __init gicv5_its_of_probe(struct device_node *parent); 394 + void __init gicv5_its_acpi_probe(void); 401 395 #endif
+26 -4
include/linux/irqdomain.h
··· 257 257 258 258 #ifdef CONFIG_IRQ_DOMAIN 259 259 struct fwnode_handle *__irq_domain_alloc_fwnode(unsigned int type, int id, 260 - const char *name, phys_addr_t *pa); 260 + const char *name, phys_addr_t *pa, 261 + struct fwnode_handle *parent); 261 262 262 263 enum { 263 264 IRQCHIP_FWNODE_REAL, ··· 268 267 269 268 static inline struct fwnode_handle *irq_domain_alloc_named_fwnode(const char *name) 270 269 { 271 - return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_NAMED, 0, name, NULL); 270 + return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_NAMED, 0, name, NULL, NULL); 271 + } 272 + 273 + static inline 274 + struct fwnode_handle *irq_domain_alloc_named_parented_fwnode(const char *name, 275 + struct fwnode_handle *parent) 276 + { 277 + return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_NAMED, 0, name, NULL, parent); 272 278 } 273 279 274 280 static inline struct fwnode_handle *irq_domain_alloc_named_id_fwnode(const char *name, int id) 275 281 { 276 282 return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_NAMED_ID, id, name, 277 - NULL); 283 + NULL, NULL); 284 + } 285 + 286 + static inline 287 + struct fwnode_handle *irq_domain_alloc_named_id_parented_fwnode(const char *name, int id, 288 + struct fwnode_handle *parent) 289 + { 290 + return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_NAMED_ID, id, name, 291 + NULL, parent); 278 292 } 279 293 280 294 static inline struct fwnode_handle *irq_domain_alloc_fwnode(phys_addr_t *pa) 281 295 { 282 - return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_REAL, 0, NULL, pa); 296 + return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_REAL, 0, NULL, pa, NULL); 297 + } 298 + 299 + static inline struct fwnode_handle *irq_domain_alloc_parented_fwnode(phys_addr_t *pa, 300 + struct fwnode_handle *parent) 301 + { 302 + return __irq_domain_alloc_fwnode(IRQCHIP_FWNODE_REAL, 0, NULL, pa, parent); 283 303 } 284 304 285 305 void irq_domain_free_fwnode(struct fwnode_handle *fwnode);
+2 -1
include/linux/msi.h
··· 702 702 void pci_msi_mask_irq(struct irq_data *data); 703 703 void pci_msi_unmask_irq(struct irq_data *data); 704 704 u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev); 705 - u32 pci_msi_map_rid_ctlr_node(struct pci_dev *pdev, struct device_node **node); 705 + u32 pci_msi_map_rid_ctlr_node(struct irq_domain *domain, struct pci_dev *pdev, 706 + struct fwnode_handle **node); 706 707 struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev); 707 708 void pci_msix_prepare_desc(struct irq_domain *domain, msi_alloc_info_t *arg, 708 709 struct msi_desc *desc);
+2 -1
include/linux/pci-acpi.h
··· 12 12 #include <linux/acpi.h> 13 13 14 14 #ifdef CONFIG_ACPI 15 - extern acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev); 15 + extern acpi_status pci_acpi_add_root_pm_notifier(struct acpi_device *dev, 16 + struct acpi_pci_root *pci_root); 16 17 static inline acpi_status pci_acpi_remove_bus_pm_notifier(struct acpi_device *dev) 17 18 { 18 19 return acpi_remove_pm_notifier(dev);
+13 -1
kernel/irq/irqdomain.c
··· 33 33 34 34 struct irqchip_fwid { 35 35 struct fwnode_handle fwnode; 36 + struct fwnode_handle *parent; 36 37 unsigned int type; 37 38 char *name; 38 39 phys_addr_t *pa; ··· 54 53 return fwid->name; 55 54 } 56 55 56 + static struct fwnode_handle *irqchip_fwnode_get_parent(const struct fwnode_handle *fwnode) 57 + { 58 + struct irqchip_fwid *fwid = container_of(fwnode, struct irqchip_fwid, fwnode); 59 + 60 + return fwid->parent; 61 + } 62 + 57 63 const struct fwnode_operations irqchip_fwnode_ops = { 58 64 .get_name = irqchip_fwnode_get_name, 65 + .get_parent = irqchip_fwnode_get_parent, 59 66 }; 60 67 EXPORT_SYMBOL_GPL(irqchip_fwnode_ops); 61 68 ··· 74 65 * @id: Optional user provided id if name != NULL 75 66 * @name: Optional user provided domain name 76 67 * @pa: Optional user-provided physical address 68 + * @parent: Optional parent fwnode_handle 77 69 * 78 70 * Allocate a struct irqchip_fwid, and return a pointer to the embedded 79 71 * fwnode_handle (or NULL on failure). ··· 86 76 */ 87 77 struct fwnode_handle *__irq_domain_alloc_fwnode(unsigned int type, int id, 88 78 const char *name, 89 - phys_addr_t *pa) 79 + phys_addr_t *pa, 80 + struct fwnode_handle *parent) 90 81 { 91 82 struct irqchip_fwid *fwid; 92 83 char *n; ··· 115 104 fwid->type = type; 116 105 fwid->name = n; 117 106 fwid->pa = pa; 107 + fwid->parent = parent; 118 108 fwnode_init(&fwid->fwnode, &irqchip_fwnode_ops); 119 109 return &fwid->fwnode; 120 110 }