ACPI: bus: Remove struct acpi_driver from the kernel
Subsystems (4)
Rafael J. Wysocki (Intel)
maintainercover ACPI: bus: Remove struct acpi_driver from the kernel
Hi All,
After converting all of the drivers using the struct acpi_driver interface to proper platform drivers, that interface can be dropped now, which is done in this series (patch [1/2]).
Additionally, the no_pm flag is set for all struct acpi_device object since they are not going to be directly involved in any kind of power management now (that is, they will not have PM-aware drivers and they will not be included in PM domains).
Thanks!
Rafael J. Wysocki
maintainerPATCH 1/2 1/2] ACPI: bus: Eliminate struct acpi_driver
From: "Rafael J. Wysocki" <[email protected]>
Now that struct acpi_driver has no more users, eliminate it along with all of the code related to it.
Also remove the file added by commit b8c8a8ea18ad ("ACPI: Documentation:
driver-api: Disapprove of using ACPI drivers") because it will not be necessary any more after eliminating struct acpi_driver from the code.
No intentional functional impact.
--- .../driver-api/acpi/acpi-drivers.rst | 80 ---------- Documentation/driver-api/acpi/index.rst | 1 - drivers/acpi/bus.c | 138 +----------------- drivers/acpi/power.c | 1 - drivers/acpi/scan.c | 16 +- include/acpi/acpi_bus.h | 50 +------ 6 files changed, 5 insertions(+), 281 deletions(-) delete mode 100644 Documentation/driver-api/acpi/acpi-drivers.rst
Documentation/driver-api/acpi/acpi-drivers.rst deleted +0 -80
@@ -1,80 +0,0 @@ -.. SPDX-License-Identifier: GPL-2.0 -.. include:: <isonum.txt> - -========================================= -Why using ACPI drivers is not a good idea -========================================= - -:Copyright: |copy| 2026, Intel Corporation - -:Author: Rafael J. Wysocki <[email protected]> - -Even though binding drivers directly to struct acpi_device objects, also -referred to as "ACPI device nodes", allows basic functionality to be provided -at least in some cases, there are problems with it, related to general -consistency, sysfs layout, power management operation ordering, and code -cleanliness. - -First of all, ACPI device nodes represent firmware entities rather than -hardware and in many cases they provide auxiliary information on devices -enumerated independently (like PCI devices or CPUs). It is therefore generally -questionable to assign resources to them because the entities represented by -them do not decode addresses in the memory or I/O address spaces and do not -generate interrupts or similar (all of that is done by hardware). - -Second, as a general rule, a struct acpi_device can only be a parent of another -struct acpi_device. If that is not the case, the location of the child device -in the device hierarchy is at least confusing and it may not be straightforward -to identify the piece of hardware providing functionality represented by it. -However, binding a driver directly to an ACPI device node may cause that to -happen if the given driver registers input devices or wakeup sources under it, -for example. - -Next, using system suspend and resume callbacks directly on ACPI device nodes -is also questionable because it may cause ordering problems to appear. Namely, -ACPI device nodes are registered before enumerating hardware corresponding to -them and they land on the PM list in front of the majority of other device -objects. Consequently, the execution ordering of their PM callbacks may be -different from what is generally expected. Also, in general, dependencies -returned by _DEP objects do not affect ACPI device nodes themselves, but the -"physical" devices associated with them, which potentially is one more source -of inconsistency related to treating ACPI device nodes as "real" device -representation. - -All of the above means that binding drivers to ACPI device nodes should -generally be avoided and so struct acpi_driver objects should not be used. - -Moreover, a device ID is necessary to bind a driver directly to an ACPI device -node, but device IDs are not generally associated with all of them. Some of -them contain alternative information allowing the corresponding pieces of -hardware to be identified, for example represented by an _ADR object return -value, and device IDs are not used in those cases. In consequence, confusingly -enough, binding an ACPI driver to an ACPI device node may even be impossible. - -When that happens, the piece of hardware corresponding to the given ACPI device -node is represented by another device object, like a struct pci_dev, and the -ACPI device node is the "ACPI companion" of that device, accessible through its -fwnode pointer used by the ACPI_COMPANION() macro. The ACPI companion holds -additional information on the device configuration and possibly some "recipes" -on device manipulation in the form of AML (ACPI Machine Language) bytecode -provided by the platform firmware. Thus the role of the ACPI device node is -similar to the role of a struct device_node on a system where Device Tree is -used for platform description. - -For consistency, this approach has been extended to the cases in which ACPI -device IDs are used. Namely, in those cases, an additional device object is -created to represent the piece of hardware corresponding to a given ACPI device -node. By default, it is a platform device, but it may also be a PNP device, a -CPU device, or another type of device, depending on what the given piece of -hardware actually is. There are even cases in which multiple devices are -"backed" or "accompanied" by one ACPI device node (e.g. ACPI device nodes -corresponding to GPUs that may provide firmware interfaces for backlight -brightness control in addition to GPU configuration information). - -This means that it really should never be necessary to bind a driver directly to -an ACPI device node because there is a "proper" device object representing the -corresponding piece of hardware that can be bound to by a "proper" driver using -the given ACPI device node as the device's ACPI companion. Thus, in principle, -there is no reason to use ACPI drivers and if they all were replaced with other -driver types (for example, platform drivers), some code could be dropped and -some complexity would go away.
Documentation/driver-api/acpi/index.rst +0 -1
@@ -7,4 +7,3 @@ ACPI Support linuxized-acpica scan_handlers - acpi-drivers
drivers/acpi/bus.c +1 -137
165 lines not on this page · raw message
drivers/acpi/power.c +0 -1
@@ -954,7 +954,6 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle)INIT_LIST_HEAD (&resource->list_node);INIT_LIST_HEAD (&resource->dependents); device->power.state =ACPI_STATE_UNKNOWN ; - device->flags.match_driver = true;/* Evaluate the object to get the system level and resource order. */ status =acpi_evaluate_object (handle,NULL ,NULL , &buffer);
drivers/acpi/scan.c +3 -13
@@ -273,13 +273,9 @@ static int acpi_scan_check_and_detach(struct acpi_device *adev, void *p) } } - adev->flags.match_driver = false; -if (handler) { -if (handler->detach) - handler->detach (adev); - }else { -device_release_driver (&adev->dev); - } +if (handler && handler->detach) + handler->detach (adev); +/* * Most likely, the device is going away, so put it into D3cold before * that.
@@ -1821,7 +1817,6 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,acpi_set_pnp_ids (handle, &device->pnp, type);acpi_init_properties (device);acpi_bus_get_flags (device); - device->flags.match_driver = false; device->flags.initialized = true; device->flags.enumeration_by_parent =acpi_device_enumeration_by_parent (device);
@@ -2375,16 +2370,11 @@ static int acpi_bus_attach(struct acpi_device *device, void *first_pass)if (ret <0 )return 0 ; - device->flags.match_driver = true;if (ret >0 && !device->flags.enumeration_by_parent) {acpi_device_set_enumerated (device); goto ok; } - ret =device_attach (&device->dev); -if (ret <0 ) -return 0 ; -if (device->pnp.type.platform_id || device->pnp.type.backlight || device->flags.enumeration_by_parent)acpi_default_enumeration (device);
include/acpi/acpi_bus.h +1 -49
92 lines not on this page · raw message
Signature · 1 line
2.51.0
Re: [PATCH v1 1/2] 1/2] ACPI: bus: Eliminate struct acpi_driver
Quoted 5 lines · Rafael J. Wysocki
From: "Rafael J. Wysocki" <[email protected]>
Now that struct
acpi_driverhas no more users, eliminate it along with all of the code related to it.
Quoted 7 lines
Also remove the file added by commit
b8c8a8ea18ad("ACPI: Documentation:
driver-api: Disapprove of using ACPI drivers") because it will not be necessary any more after eliminating structacpi_driverfrom the code.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>
Rafael J. Wysocki
maintainerPATCH 2/2 ACPI: scan: Set power.no_pm for all struct acpi_device objects
In reply to Rafael J. Wysocki (Intel)From: "Rafael J. Wysocki" <[email protected]>
Now that drivers do not bind to ACPI device objects, there is no reason for them to be included directly in power management in any way, so set power.no_pm for all of them.
--- drivers/acpi/scan.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/scan.c +1 -0
@@ -1811,6 +1811,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, device->dev.release = release; device->dev.bus = &acpi_bus_type; device->dev.groups = acpi_groups; +device_set_pm_not_required (&device->dev);fwnode_init (&device->fwnode, &acpi_device_fwnode_ops);acpi_set_device_status (device,ACPI_STA_DEFAULT );acpi_device_get_busid (device);
Signature · 1 line
2.51.0
Re: [PATCH v1 2/2] ACPI: scan: Set power.no_pm for all struct acpi_device objects
Quoted 7 lines · Rafael J. Wysocki
From: "Rafael J. Wysocki" <[email protected]>
Now that drivers do not bind to ACPI device objects, there is no reason for them to be included directly in power management in any way, so set power.no_pm for all of them.
Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 5 lines · Rafael J. Wysocki (Intel)
Hi All,
After converting all of the drivers using the struct
acpi_driverinterface to proper platform drivers, that interface can be dropped now, which is done in this series (patch [1/2]).
What a nice result!
Quoted 4 lines
Additionally, the
no_pmflag is set for all structacpi_deviceobject since they are not going to be directly involved in any kind of power management now (that is, they will not have PM-aware drivers and they will not be included in PM domains).
I am in favour of this cleanup!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Rafael J. Wysocki (Intel)
maintainerQuoted 10 lines · Andy Shevchenko
Quoted 5 lines · Rafael J. Wysocki (Intel)
Hi All,
After converting all of the drivers using the struct
acpi_driverinterface to proper platform drivers, that interface can be dropped now, which is done in this series (patch [1/2]).What a nice result!
Quoted 7 lines
Quoted 4 lines
Additionally, the
no_pmflag is set for all structacpi_deviceobject since they are not going to be directly involved in any kind of power management now (that is, they will not have PM-aware drivers and they will not be included in PM domains).I am in favour of this cleanup!
Reviewed-by Andy Shevchenko <[email protected]>
Thank you!