acpi: allow building without CONFIG_HAS_IOPORT
Subsystems (4)
PATCH 1/1 acpi: allow building without CONFIG_HAS_IOPORT
From: Arnd Bergmann <[email protected]>
CONFIG_HAS_IOPORT will soon become optional and cause a build time failure when it is disabled but a driver calls inb()/outb(). At the moment, all architectures that can support ACPI have port I/O, but this is not necessarily the case in the future. The result is a set of errors like:
drivers/acpi/osl.c: In function 'acpi_os_read_port':include/asm-generic/io.h:542:14: error: call to '_inb' declared with attribute error: inb()) requires CONFIG_HAS_IOPORT
In function 'acpi_ec_read_status',
inlined from 'advance_transaction' at drivers/acpi/ec.c:665:11:include/asm-generic/io.h:542:14: error: call to '_inb' declared with attribute error: inb()) requires CONFIG_HAS_IOPORT
Since the embedded controller can only exist when port I/O is active, it makes sense to disable that code on targets that don't have it. The same is true for anything using acpi_os_read_port() and similar functions.
Add compile-time conditionals around all of those and their callers.
---
Should this be split up into smaller patches?
--- drivers/acpi/Kconfig | 1 + drivers/acpi/Makefile | 2 +- drivers/acpi/acpica/Makefile | 4 +++- drivers/acpi/acpica/evhandler.c | 3 ++- drivers/acpi/acpica/exregion.c | 2 ++ drivers/acpi/acpica/hwregs.c | 6 ++++-- drivers/acpi/acpica/hwxface.c | 3 ++- drivers/acpi/apei/apei-base.c | 4 ++++ drivers/acpi/bus.c | 9 ++++++--- drivers/acpi/cppc_acpi.c | 6 ++++-- drivers/acpi/osl.c | 2 ++ drivers/acpi/processor_perflib.c | 3 ++- drivers/acpi/scan.c | 3 ++- 13 files changed, 35 insertions(+), 13 deletions(-)
drivers/acpi/Kconfig +1 -0
@@ -134,6 +134,7 @@ config ACPI_REV_OVERRIDE_POSSIBLE config ACPI_EC_DEBUGFS tristate "EC read/write access through /sys/kernel/debug/ec" + depends on HAS_IOPORT help Say N to disable Embedded Controller /sys/kernel/debug interface
drivers/acpi/Makefile +1 -1
@@ -41,7 +41,7 @@ acpi-y += resource.o acpi-y += acpi_processor.o acpi-y += processor_core.o acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o -acpi-y += ec.o +acpi-$(CONFIG_HAS_IOPORT) += ec.o acpi-$(CONFIG_ACPI_DOCK) += dock.o acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.o
drivers/acpi/acpica/Makefile +3 -1
@@ -80,10 +80,12 @@ acpi-y += \ hwgpe.o \ hwregs.o \ hwsleep.o \ - hwvalid.o \ hwxface.o \ hwxfsleep.o +acpi-$(CONFIG_HAS_IOPORT) += \ + hwvalid.o + acpi-$(CONFIG_PCI) += hwpci.o acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o
drivers/acpi/acpica/evhandler.c +2 -1
@@ -358,12 +358,13 @@ acpi_ev_install_space_handler(struct acpi_namespace_node *node, handler = acpi_ex_system_memory_space_handler; setup = acpi_ev_system_memory_region_setup;break ; - +#ifdef CONFIG_HAS_IOPORT case ACPI_ADR_SPACE_SYSTEM_IO : handler = acpi_ex_system_io_space_handler; setup = acpi_ev_io_space_region_setup;break ; +#endif #ifdef ACPI_PCI_CONFIGURED case ACPI_ADR_SPACE_PCI_CONFIG :
drivers/acpi/acpica/exregion.c +2 -0
@@ -261,6 +261,7 @@ acpi_ex_system_memory_space_handler(u32 function,return_ACPI_STATUS (status); } +#ifdef CONFIG_HAS_IOPORT /******************************************************************************* * * FUNCTION: acpi_ex_system_io_space_handler
@@ -319,6 +320,7 @@ acpi_ex_system_io_space_handler(u32 function, return_ACPI_STATUS(status); } +#endif #ifdef ACPI_PCI_CONFIGURED /*******************************************************************************
drivers/acpi/acpica/hwregs.c +4 -2
@@ -239,7 +239,8 @@ acpi_status acpi_hw_read(u64 *value, struct acpi_generic_address *reg)ACPI_DIV_8 (access_width), &value64, access_width); - }else {/* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + }else if (IS_ENABLED (CONFIG_HAS_IOPORT )) { +/* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ status = acpi_hw_read_port((acpi_io_address) address +
@@ -336,7 +337,8 @@ acpi_status acpi_hw_write(u64 value, struct acpi_generic_address *reg)ACPI_DIV_8 (access_width), value64, access_width); - }else {/* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + }else if (IS_ENABLED (CONFIG_HAS_IOPORT )) { +/* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ status = acpi_hw_write_port((acpi_io_address) address +
drivers/acpi/acpica/hwxface.c +2 -1
@@ -45,7 +45,8 @@ acpi_status acpi_reset(void)return_ACPI_STATUS (AE_NOT_EXIST ); } -if (reset_reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) { +if (IS_ENABLED (CONFIG_HAS_IOPORT ) && + reset_reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) {/* * For I/O space, write directly to the OSL. This bypasses the port * validation mechanism, which may block a valid write to the reset
drivers/acpi/apei/apei-base.c +4 -0
@@ -661,12 +661,14 @@ int apei_read(u64 *val, struct acpi_generic_address *reg)if (ACPI_FAILURE (status))return -EIO ;break ; +#ifdef CONFIG_HAS_IOPORT case ACPI_ADR_SPACE_SYSTEM_IO : status =acpi_os_read_port (address, (u32 *)val, access_bit_width);if (ACPI_FAILURE (status))return -EIO ;break ; +#endif default :return -EINVAL ; }
@@ -694,11 +696,13 @@ int apei_write(u64 val, struct acpi_generic_address *reg)if (ACPI_FAILURE (status))return -EIO ;break ; +#ifdef CONFIG_HAS_IOPORT case ACPI_ADR_SPACE_SYSTEM_IO : status =acpi_os_write_port (address, val, access_bit_width);if (ACPI_FAILURE (status))return -EIO ;break ; +#endif default :return -EINVAL ; }
drivers/acpi/bus.c +6 -3
@@ -1356,7 +1356,8 @@ static int __init acpi_bus_init(void)* Do that before calling acpi_initialize_objects() which may trigger EC * address space accesses. */ -acpi_ec_ecdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_ecdt_probe (); status =acpi_enable_subsystem (ACPI_NO_ACPI_ENABLE );if (ACPI_FAILURE (status)) {
@@ -1391,7 +1392,8 @@ static int __init acpi_bus_init(void)* Maybe EC region is required at bus_scan/acpi_get_devices. So it * is necessary to enable it as early as possible. */ -acpi_ec_dsdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_dsdt_probe ();pr_info ("Interpreter enabled\n" );
@@ -1464,7 +1466,8 @@ static int __init acpi_init(void)acpi_arm_init ();acpi_riscv_init ();acpi_scan_init (); -acpi_ec_init (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_init ();acpi_debugfs_init ();acpi_sleep_proc_init ();acpi_wakeup_device_init ();
drivers/acpi/cppc_acpi.c +4 -2
@@ -1017,7 +1017,8 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val) *val =0 ; size =GET_BIT_WIDTH (reg); -if (reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) { +if (IS_ENABLED (CONFIG_HAS_IOPORT ) && + reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) {u32 val_u32;acpi_status status;
@@ -1090,7 +1091,8 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val) size =GET_BIT_WIDTH (reg); -if (reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) { +if (IS_ENABLED (CONFIG_HAS_IOPORT ) && + reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) {acpi_status status; status = acpi_os_write_port((acpi_io_address)reg->address,
drivers/acpi/osl.c +2 -0
@@ -638,6 +638,7 @@ u64 acpi_os_get_timer(void) (ACPI_100NSEC_PER_SEC /HZ ); } +#ifdef CONFIG_HAS_IOPORT acpi_status acpi_os_read_port (acpi_io_address port,u32 *value,u32 width) {u32 dummy;
@@ -680,6 +681,7 @@ acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) }EXPORT_SYMBOL (acpi_os_write_port); +#endif int acpi_os_read_iomem (void __iomem *virt_addr,u64 *value,u32 width) {
drivers/acpi/processor_perflib.c +2 -1
@@ -455,7 +455,8 @@ int acpi_processor_pstate_control(void) {acpi_status status; -if (!acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control) +if (!IS_ENABLED (CONFIG_HAS_IOPORT ) || + !acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control)return 0 ; pr_debug("Writing pstate_control [0x%x] to smi_command [0x%x]\n",
drivers/acpi/scan.c +2 -1
@@ -2293,7 +2293,8 @@ static int acpi_bus_attach(struct acpi_device *device, void *first_pass)if (device->handler) goto ok; -acpi_ec_register_opregions (device); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_register_opregions (device);if (!device->flags.initialized) { device->flags.power_manageable =
Signature · 1 line
2.39.2
Rafael J. Wysocki
maintainerQuoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
CONFIG_HAS_IOPORTwill soon become optional and cause a build time failure when it is disabled but a driver calls inb()/outb(). At the moment, all architectures that can support ACPI have port I/O, but this is not necessarily the case in the future.
Can addressing this be deferred to that point?
Quoted 14 lines
The result is a set of errors like:
drivers/acpi/osl.c: In function 'acpi_os_read_port':include/asm-generic/io.h:542:14: error: call to '_inb' declared with attribute error:inb()) requiresCONFIG_HAS_IOPORTIn function '
acpi_ec_read_status',
inlined from 'advance_transaction' atdrivers/acpi/ec.c:665:11:include/asm-generic/io.h:542:14: error: call to '_inb' declared with attribute error:inb()) requiresCONFIG_HAS_IOPORTSince the embedded controller can only exist when port I/O is active, it makes sense to disable that code on targets that don't have it. The same is true for anything using
acpi_os_read_port()and similar functions.
Quoted 5 lines
Add compile-time conditionals around all of those and their callers.
Signed-off-by Arnd Bergmann <[email protected]>---
Should this be split up into smaller patches?
No need, but the ACPICA part is kind of nasty.
Quoted 65 lines
--- drivers/acpi/Kconfig | 1 + drivers/acpi/Makefile | 2 +- drivers/acpi/acpica/Makefile | 4 +++- drivers/acpi/acpica/evhandler.c | 3 ++- drivers/acpi/acpica/exregion.c | 2 ++ drivers/acpi/acpica/hwregs.c | 6 ++++-- drivers/acpi/acpica/hwxface.c | 3 ++- drivers/acpi/apei/apei-base.c | 4 ++++ drivers/acpi/bus.c | 9 ++++++--- drivers/acpi/cppc_acpi.c | 6 ++++-- drivers/acpi/osl.c | 2 ++ drivers/acpi/processor_perflib.c | 3 ++- drivers/acpi/scan.c | 3 ++- 13 files changed, 35 insertions(+), 13 deletions(-)drivers/acpi/Kconfig +1
-0@@ -134,6 +134,7 @@ config ACPI_REV_OVERRIDE_POSSIBLE config ACPI_EC_DEBUGFS tristate "EC read/write access through /sys/kernel/debug/ec" + depends on HAS_IOPORT help Say N to disable Embedded Controller /sys/kernel/debug interfacedrivers/acpi/Makefile +1
-1@@ -41,7 +41,7 @@ acpi-y += resource.o acpi-y += acpi_processor.o acpi-y += processor_core.o acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o -acpi-y += ec.o +acpi-$(CONFIG_HAS_IOPORT) += ec.o acpi-$(CONFIG_ACPI_DOCK) += dock.o acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.odrivers/acpi/acpica/Makefile +3
-1@@ -80,10 +80,12 @@ acpi-y += \ hwgpe.o \ hwregs.o \ hwsleep.o \ - hwvalid.o \ hwxface.o \ hwxfsleep.o +acpi-$(CONFIG_HAS_IOPORT) += \ + hwvalid.o + acpi-$(CONFIG_PCI) += hwpci.o acpi-$(ACPI_FUTURE_USAGE) += hwtimer.odrivers/acpi/acpica/evhandler.c +0
-0@@ -358,12 +358,13 @@ acpi_ev_install_space_handler(struct acpi_namespace_node *node, handler = acpi_ex_system_memory_space_handler;
drivers/acpi/acpica/evhandler.c acpi_ev_install_space_handler(struct acpi_namespace_node *node, · line 367
Quoted 10 lines
drivers/acpi/acpica/evhandler.c +2
-1setup = acpi_ev_system_memory_region_setup;break ; - +#ifdef CONFIG_HAS_IOPORT case ACPI_ADR_SPACE_SYSTEM_IO : handler = acpi_ex_system_io_space_handler; setup = acpi_ev_io_space_region_setup;break ; +#endif
All changes like the above in the ACPICA code potentially increase the number of times when upstream ACPICA patches will have to be ported to Linux manually, which in turn increases the number of potential mistakes in the process.
I'd rather avoid making them, if possible.
Quoted 204 lines
drivers/acpi/acpica/evhandler.c +0
-0#ifdef ACPI_PCI_CONFIGURED case ACPI_ADR_SPACE_PCI_CONFIG :drivers/acpi/acpica/exregion.c +2
-0@@ -261,6 +261,7 @@ acpi_ex_system_memory_space_handler(u32 function,return_ACPI_STATUS (status); } +#ifdef CONFIG_HAS_IOPORT /******************************************************************************* * * FUNCTION: acpi_ex_system_io_space_handler @@ -319,6 +320,7 @@ acpi_ex_system_io_space_handler(u32 function, return_ACPI_STATUS(status); } +#endif #ifdef ACPI_PCI_CONFIGURED /******************************************************************************* drivers/acpi/acpica/hwregs.c +4
-2@@ -239,7 +239,8 @@ acpi_status acpi_hw_read(u64 *value, struct acpi_generic_address *reg)ACPI_DIV_8 (access_width), &value64, access_width); - }else {/* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + }else if (IS_ENABLED (CONFIG_HAS_IOPORT )) { +/* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ status = acpi_hw_read_port((acpi_io_address) address +@@ -336,7 +337,8 @@ acpi_status acpi_hw_write(u64 value, struct acpi_generic_address *reg)ACPI_DIV_8 (access_width), value64, access_width); - }else {/* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + }else if (IS_ENABLED (CONFIG_HAS_IOPORT )) { +/* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ status = acpi_hw_write_port((acpi_io_address) address +drivers/acpi/acpica/hwxface.c +2
-1@@ -45,7 +45,8 @@ acpi_status acpi_reset(void)return_ACPI_STATUS (AE_NOT_EXIST ); } -if (reset_reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) { +if (IS_ENABLED (CONFIG_HAS_IOPORT ) && + reset_reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) {/* * For I/O space, write directly to the OSL. This bypasses the port * validation mechanism, which may block a valid write to the reset drivers/acpi/apei/apei-base.c +4
-0@@ -661,12 +661,14 @@ int apei_read(u64 *val, struct acpi_generic_address *reg)if (ACPI_FAILURE (status))return -EIO ;break ; +#ifdef CONFIG_HAS_IOPORT case ACPI_ADR_SPACE_SYSTEM_IO : status =acpi_os_read_port (address, (u32 *)val, access_bit_width);if (ACPI_FAILURE (status))return -EIO ;break ; +#endif default :return -EINVAL ; }@@ -694,11 +696,13 @@ int apei_write(u64 val, struct acpi_generic_address *reg)if (ACPI_FAILURE (status))return -EIO ;break ; +#ifdef CONFIG_HAS_IOPORT case ACPI_ADR_SPACE_SYSTEM_IO : status =acpi_os_write_port (address, val, access_bit_width);if (ACPI_FAILURE (status))return -EIO ;break ; +#endif default :return -EINVAL ; }drivers/acpi/bus.c +6
-3@@ -1356,7 +1356,8 @@ static int __init acpi_bus_init(void)* Do that before calling acpi_initialize_objects() which may trigger EC * address space accesses. */ -acpi_ec_ecdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_ecdt_probe (); status =acpi_enable_subsystem (ACPI_NO_ACPI_ENABLE );if (ACPI_FAILURE (status)) {@@ -1391,7 +1392,8 @@ static int __init acpi_bus_init(void)* Maybe EC region is required at bus_scan/acpi_get_devices. So it * is necessary to enable it as early as possible. */ -acpi_ec_dsdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_dsdt_probe ();pr_info ("Interpreter enabled\n" );@@ -1464,7 +1466,8 @@ static int __init acpi_init(void)acpi_arm_init ();acpi_riscv_init ();acpi_scan_init (); -acpi_ec_init (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_init ();acpi_debugfs_init ();acpi_sleep_proc_init ();acpi_wakeup_device_init ();drivers/acpi/cppc_acpi.c +4
-2@@ -1017,7 +1017,8 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val) *val =0 ; size =GET_BIT_WIDTH (reg); -if (reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) { +if (IS_ENABLED (CONFIG_HAS_IOPORT ) && + reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) {u32 val_u32;acpi_status status;@@ -1090,7 +1091,8 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val) size =GET_BIT_WIDTH (reg); -if (reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) { +if (IS_ENABLED (CONFIG_HAS_IOPORT ) && + reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) {acpi_status status; status = acpi_os_write_port((acpi_io_address)reg->address,drivers/acpi/osl.c +2
-0@@ -638,6 +638,7 @@ u64 acpi_os_get_timer(void) (ACPI_100NSEC_PER_SEC /HZ ); } +#ifdef CONFIG_HAS_IOPORT acpi_status acpi_os_read_port (acpi_io_address port,u32 *value,u32 width) {u32 dummy;@@ -680,6 +681,7 @@ acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) }EXPORT_SYMBOL (acpi_os_write_port); +#endif int acpi_os_read_iomem (void __iomem *virt_addr,u64 *value,u32 width) {drivers/acpi/processor_perflib.c +2
-1@@ -455,7 +455,8 @@ int acpi_processor_pstate_control(void) {acpi_status status; -if (!acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control) +if (!IS_ENABLED (CONFIG_HAS_IOPORT ) || + !acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control)return 0 ; pr_debug("Writing pstate_control [0x%x] to smi_command [0x%x]\n",drivers/acpi/scan.c +2
-2@@ -2293,7 +2293,8 @@ static int acpi_bus_attach(struct acpi_device *device, void *first_pass)if (device->handler) goto ok; -acpi_ec_register_opregions (device); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_register_opregions (device);if (!device->flags.initialized) { device->flags.power_manageable = --2.39.2
Quoted 10 lines · Rafael J. Wysocki
Quoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
CONFIG_HAS_IOPORTwill soon become optional and cause a build time failure when it is disabled but a driver calls inb()/outb(). At the moment, all architectures that can support ACPI have port I/O, but this is not necessarily the case in the future.Can addressing this be deferred to that point?
Yes. I would like to have all of arm64 and riscv be able to turn off HAS_IOPORT eventually, but nothing depends on doing this when ACPI is enabled.
Quoted 5 lines
Quoted 5 lines
Since the embedded controller can only exist when port I/O is active, it makes sense to disable that code on targets that don't have it. The same is true for anything using
acpi_os_read_port()and similar functions.
Quoted 7 lines
Quoted 5 lines
Add compile-time conditionals around all of those and their callers.
Signed-off-by Arnd Bergmann <[email protected]>---
Should this be split up into smaller patches?No need, but the ACPICA part is kind of nasty.
Right, I see.
Quoted 20 lines
Quoted 4 lines
drivers/acpi/acpica/evhandler.c +0
-0@@ -358,12 +358,13 @@ acpi_ev_install_space_handler(struct acpi_namespace_node *node, handler = acpi_ex_system_memory_space_handler;drivers/acpi/acpica/evhandler.c acpi_ev_install_space_handler(struct acpi_namespace_node *node, · line 367
Quoted 10 lines
drivers/acpi/acpica/evhandler.c +2
-1setup = acpi_ev_system_memory_region_setup;break ; - +#ifdef CONFIG_HAS_IOPORT case ACPI_ADR_SPACE_SYSTEM_IO : handler = acpi_ex_system_io_space_handler; setup = acpi_ev_io_space_region_setup;break ; +#endif All changes like the above in the ACPICA code potentially increase the number of times when upstream ACPICA patches will have to be ported to Linux manually, which in turn increases the number of potential mistakes in the process.
Quoted 1 line
I'd rather avoid making them, if possible.
Understood. Does that mean that on the flip-side we can change the drivers/acpi/osl.c portion to turn acpi_os_read_port() and acpi_os_write_port() into a runtime error for configurations without port I/O, without causing the same maintenance overhead?
The version below builds fine and doesn't touch acpica but it's a bit harder to predict what would happen at runtime.
Arnd
drivers/acpi/Kconfig +1 -0
@@ -134,6 +134,7 @@ config ACPI_REV_OVERRIDE_POSSIBLE config ACPI_EC_DEBUGFS tristate "EC read/write access through /sys/kernel/debug/ec" + depends on HAS_IOPORT help Say N to disable Embedded Controller /sys/kernel/debug interface
drivers/acpi/Makefile +1 -1
@@ -41,7 +41,7 @@ acpi-y += resource.o acpi-y += acpi_processor.o acpi-y += processor_core.o acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o -acpi-y += ec.o +acpi-$(CONFIG_HAS_IOPORT) += ec.o acpi-$(CONFIG_ACPI_DOCK) += dock.o acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.o
drivers/acpi/bus.c +6 -3
@@ -1356,7 +1356,8 @@ static int __init acpi_bus_init(void)* Do that before calling acpi_initialize_objects() which may trigger EC * address space accesses. */ -acpi_ec_ecdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_ecdt_probe (); status =acpi_enable_subsystem (ACPI_NO_ACPI_ENABLE );if (ACPI_FAILURE (status)) {
@@ -1391,7 +1392,8 @@ static int __init acpi_bus_init(void)* Maybe EC region is required at bus_scan/acpi_get_devices. So it * is necessary to enable it as early as possible. */ -acpi_ec_dsdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_dsdt_probe ();pr_info ("Interpreter enabled\n" );
@@ -1464,7 +1466,8 @@ static int __init acpi_init(void)acpi_arm_init ();acpi_riscv_init ();acpi_scan_init (); -acpi_ec_init (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_init ();acpi_debugfs_init ();acpi_sleep_proc_init ();acpi_wakeup_device_init ();
drivers/acpi/cppc_acpi.c +4 -2
@@ -1017,7 +1017,8 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val) *val =0 ; size =GET_BIT_WIDTH (reg); -if (reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) { +if (IS_ENABLED (CONFIG_HAS_IOPORT ) && + reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) {u32 val_u32;acpi_status status;
@@ -1090,7 +1091,8 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val) size =GET_BIT_WIDTH (reg); -if (reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) { +if (IS_ENABLED (CONFIG_HAS_IOPORT ) && + reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) {acpi_status status; status = acpi_os_write_port((acpi_io_address)reg->address,
drivers/acpi/osl.c +8 -0
@@ -642,6 +642,11 @@ acpi_status acpi_os_read_port(acpi_io_address port, u32 *value, u32 width) {u32 dummy; +if (!IS_ENABLED (CONFIG_HAS_IOPORT )) { + *value =BIT_MASK (width); +return AE_NOT_IMPLEMENTED ; + } +if (value) *value =0 ;else
@@ -665,6 +670,9 @@ EXPORT_SYMBOL(acpi_os_read_port);acpi_status acpi_os_write_port (acpi_io_address port,u32 value,u32 width) { +if (!IS_ENABLED (CONFIG_HAS_IOPORT )) +return AE_NOT_IMPLEMENTED ; +if (width <=8 ) {outb (value, port); }else if (width <=16 ) {
drivers/acpi/processor_perflib.c +2 -1
@@ -455,7 +455,8 @@ int acpi_processor_pstate_control(void) {acpi_status status; -if (!acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control) +if (!IS_ENABLED (CONFIG_HAS_IOPORT ) || + !acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control)return 0 ; pr_debug("Writing pstate_control [0x%x] to smi_command [0x%x]\n",
drivers/acpi/scan.c +2 -1
@@ -2293,7 +2293,8 @@ static int acpi_bus_attach(struct acpi_device *device, void *first_pass)if (device->handler) goto ok; -acpi_ec_register_opregions (device); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_register_opregions (device);if (!device->flags.initialized) { device->flags.power_manageable =
Rafael J. Wysocki
maintainerQuoted 52 lines · Arnd Bergmann
Quoted 10 lines · Rafael J. Wysocki
Quoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
CONFIG_HAS_IOPORTwill soon become optional and cause a build time failure when it is disabled but a driver calls inb()/outb(). At the moment, all architectures that can support ACPI have port I/O, but this is not necessarily the case in the future.Can addressing this be deferred to that point?
Yes. I would like to have all of arm64 and riscv be able to turn off
HAS_IOPORTeventually, but nothing depends on doing this when ACPI is enabled.Quoted 5 lines
Quoted 5 lines
Since the embedded controller can only exist when port I/O is active, it makes sense to disable that code on targets that don't have it. The same is true for anything using
acpi_os_read_port()and similar functions.Quoted 7 lines
Quoted 5 lines
Add compile-time conditionals around all of those and their callers.
Signed-off-by Arnd Bergmann <[email protected]>---
Should this be split up into smaller patches?No need, but the ACPICA part is kind of nasty.
Right, I see.
Quoted 20 lines
Quoted 4 lines
drivers/acpi/acpica/evhandler.c +0
-0@@ -358,12 +358,13 @@ acpi_ev_install_space_handler(struct acpi_namespace_node *node, handler = acpi_ex_system_memory_space_handler;drivers/acpi/acpica/evhandler.c acpi_ev_install_space_handler(struct acpi_namespace_node *node, · line 367
Quoted 10 lines
drivers/acpi/acpica/evhandler.c +2
-1setup = acpi_ev_system_memory_region_setup;break ; - +#ifdef CONFIG_HAS_IOPORT case ACPI_ADR_SPACE_SYSTEM_IO : handler = acpi_ex_system_io_space_handler; setup = acpi_ev_io_space_region_setup;break ; +#endif All changes like the above in the ACPICA code potentially increase the number of times when upstream ACPICA patches will have to be ported to Linux manually, which in turn increases the number of potential mistakes in the process.
Quoted 6 lines
Quoted 1 line
I'd rather avoid making them, if possible.
Understood. Does that mean that on the flip-side we can change the
drivers/acpi/osl.cportion to turnacpi_os_read_port()andacpi_os_write_port()into a runtime error for configurations without port I/O, without causing the same maintenance overhead?
Yes, that can be done.
Quoted 2 lines
The version below builds fine and doesn't touch acpica but it's a bit harder to predict what would happen at runtime.
Sure.
Quoted 40 lines
drivers/acpi/Kconfig +1
-0@@ -134,6 +134,7 @@ config ACPI_REV_OVERRIDE_POSSIBLE config ACPI_EC_DEBUGFS tristate "EC read/write access through /sys/kernel/debug/ec" + depends on HAS_IOPORT help Say N to disable Embedded Controller /sys/kernel/debug interfacedrivers/acpi/Makefile +1
-1@@ -41,7 +41,7 @@ acpi-y += resource.o acpi-y += acpi_processor.o acpi-y += processor_core.o acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o -acpi-y += ec.o +acpi-$(CONFIG_HAS_IOPORT) += ec.o acpi-$(CONFIG_ACPI_DOCK) += dock.o acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.odrivers/acpi/bus.c +2
-1@@ -1356,7 +1356,8 @@ static int __init acpi_bus_init(void)* Do that before calling acpi_initialize_objects() which may trigger EC * address space accesses. */ -acpi_ec_ecdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_ecdt_probe (); status =acpi_enable_subsystem (ACPI_NO_ACPI_ENABLE );if (ACPI_FAILURE (status)) {
drivers/acpi/bus.c static int __init acpi_bus_init(void) · line 1396
Quoted 6 lines
drivers/acpi/bus.c +2
-1@@ -1391,7 +1392,8 @@ static int __init acpi_bus_init(void)* Maybe EC region is required at bus_scan/acpi_get_devices. So it * is necessary to enable it as early as possible. */ -acpi_ec_dsdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_dsdt_probe ();
The above two changes mean that it is not necessary to compile either acpi_ec_ecdt_probe() or acpi_ec_dsdt_probe() at all if CONFIG_HAS_IOPORT is not enabled.
drivers/acpi/bus.c static int __init acpi_init(void) · line 1470
Quoted 10 lines
drivers/acpi/bus.c +2
-1pr_info ("Interpreter enabled\n" );@@ -1464,7 +1466,8 @@ static int __init acpi_init(void)acpi_arm_init ();acpi_riscv_init ();acpi_scan_init (); -acpi_ec_init (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_init ();
And this means that the whole EC driver is not going to work at all then.
Quoted 44 lines
drivers/acpi/bus.c +0
-0acpi_debugfs_init ();acpi_sleep_proc_init ();acpi_wakeup_device_init ();drivers/acpi/cppc_acpi.c +4
-2@@ -1017,7 +1017,8 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val) *val =0 ; size =GET_BIT_WIDTH (reg); -if (reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) { +if (IS_ENABLED (CONFIG_HAS_IOPORT ) && + reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) {u32 val_u32;acpi_status status;@@ -1090,7 +1091,8 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val) size =GET_BIT_WIDTH (reg); -if (reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) { +if (IS_ENABLED (CONFIG_HAS_IOPORT ) && + reg->space_id ==ACPI_ADR_SPACE_SYSTEM_IO ) {acpi_status status; status = acpi_os_write_port((acpi_io_address)reg->address,drivers/acpi/osl.c +5
-0@@ -642,6 +642,11 @@ acpi_status acpi_os_read_port(acpi_io_address port, u32 *value, u32 width) {u32 dummy; +if (!IS_ENABLED (CONFIG_HAS_IOPORT )) { + *value =BIT_MASK (width); +return AE_NOT_IMPLEMENTED ; + } +if (value) *value =0 ;else
drivers/acpi/osl.c EXPORT_SYMBOL(acpi_os_read_port); · line 678
Quoted 9 lines
drivers/acpi/osl.c +3
-0@@ -665,6 +670,9 @@ EXPORT_SYMBOL(acpi_os_read_port);acpi_status acpi_os_write_port (acpi_io_address port,u32 value,u32 width) { +if (!IS_ENABLED (CONFIG_HAS_IOPORT )) +return AE_NOT_IMPLEMENTED ; +if (width <=8 ) {outb (value, port); }else if (width <=16 ) {
The above two changes look reasonable to me.
drivers/acpi/processor_perflib.c int acpi_processor_pstate_control(void) · line 460
Quoted 12 lines
drivers/acpi/processor_perflib.c +2
-1@@ -455,7 +455,8 @@ int acpi_processor_pstate_control(void) {acpi_status status; -if (!acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control) +if (!IS_ENABLED (CONFIG_HAS_IOPORT ) || + !acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control)return 0 ;
All of the existing callers of acpi_processor_pstate_control() are x86 which has CONFIG_HAS_IOPORT AFAICS.
And if you care about the code size, acpi_processor_notify_smm() can go away for !CONFIG_HAS_IOPORT too.
drivers/acpi/scan.c static int acpi_bus_attach(struct acpi_device *device, void *first_pass) · line 2297
Quoted 12 lines
drivers/acpi/processor_perflib.c +0
-0pr_debug("Writing pstate_control [0x%x] to smi_command [0x%x]\n",drivers/acpi/scan.c +2
-1@@ -2293,7 +2293,8 @@ static int acpi_bus_attach(struct acpi_device *device, void *first_pass)if (device->handler) goto ok; -acpi_ec_register_opregions (device); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_register_opregions (device);
I'd rather have an empty stub of acpi_ec_register_opregions() for !CONFIG_HAS_IOPORT instead.
Quoted 3 lines
drivers/acpi/scan.c +0
-0if (!device->flags.initialized) { device->flags.power_manageable =
Quoted 26 lines · Rafael J. Wysocki
Quoted 25 lines · Arnd Bergmann
drivers/acpi/Makefile +1
-1@@ -41,7 +41,7 @@ acpi-y += resource.o acpi-y += acpi_processor.o acpi-y += processor_core.o acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o -acpi-y += ec.o +acpi-$(CONFIG_HAS_IOPORT) += ec.o acpi-$(CONFIG_ACPI_DOCK) += dock.o acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.odrivers/acpi/bus.c +2
-1@@ -1356,7 +1356,8 @@ static int __init acpi_bus_init(void)* Do that before calling acpi_initialize_objects() which may trigger EC * address space accesses. */ -acpi_ec_ecdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_ecdt_probe ();
Quoted 13 lines
drivers/acpi/bus.c static int __init acpi_bus_init(void) · line 1396
Quoted 9 lines
drivers/acpi/bus.c +2
-1status =acpi_enable_subsystem (ACPI_NO_ACPI_ENABLE );if (ACPI_FAILURE (status)) {@@ -1391,7 +1392,8 @@ static int __init acpi_bus_init(void)* Maybe EC region is required at bus_scan/acpi_get_devices. So it * is necessary to enable it as early as possible. */ -acpi_ec_dsdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_dsdt_probe ();The above two changes mean that it is not necessary to compile either
acpi_ec_ecdt_probe()oracpi_ec_dsdt_probe()at all ifCONFIG_HAS_IOPORTis not enabled.
Correct, this is a result of removing ec.o from the list of objects.
Quoted 11 lines
drivers/acpi/bus.c static int __init acpi_init(void) · line 1470
Quoted 9 lines
drivers/acpi/bus.c +2
-1pr_info ("Interpreter enabled\n" );@@ -1464,7 +1466,8 @@ static int __init acpi_init(void)acpi_arm_init ();acpi_riscv_init ();acpi_scan_init (); -acpi_ec_init (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_init ();And this means that the whole EC driver is not going to work at all then.
Correct. The way I read ec.c it makes no sense if acpi_ec_write_cmd() and acpi_ec_write_data() don't actually access the registers. Is there anything in ec.c that still makes sense without port I/O?
Quoted 28 lines
drivers/acpi/processor_perflib.c int acpi_processor_pstate_control(void) · line 460
Quoted 12 lines
drivers/acpi/processor_perflib.c +2
-1@@ -455,7 +455,8 @@ int acpi_processor_pstate_control(void) {acpi_status status; -if (!acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control) +if (!IS_ENABLED (CONFIG_HAS_IOPORT ) || + !acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control)return 0 ;All of the existing callers of
acpi_processor_pstate_control()are x86 which hasCONFIG_HAS_IOPORTAFAICS.And if you care about the code size,
acpi_processor_notify_smm()can go away for !CONFIG_HAS_IOPORT too.Quoted 9 lines
drivers/acpi/processor_perflib.c +0
-0pr_debug("Writing pstate_control [0x%x] to smi_command [0x%x]\n",drivers/acpi/scan.c +0
-0@@ -2293,7 +2293,8 @@ static int acpi_bus_attach(struct acpi_device *device, void *first_pass)if (device->handler) goto ok;
Quoted 6 lines
drivers/acpi/scan.c static int acpi_bus_attach(struct acpi_device *device, void *first_pass) · line 2297
Quoted 3 lines
drivers/acpi/scan.c +2
-1-acpi_ec_register_opregions (device); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_register_opregions (device);I'd rather have an empty stub of
acpi_ec_register_opregions()for !CONFIG_HAS_IOPORT instead.
Fair enough. Should I add stubs for all the global EC functions then? I also wonder if there should be a separate CONFIG_ACPI_EC symbol that allows the EC logic to be turned off on non-x86 architectures even when HAS_IOPORT is otherwise enabled.
Arnd
Rafael J. Wysocki
maintainerQuoted 88 lines · Arnd Bergmann
Quoted 26 lines · Rafael J. Wysocki
Quoted 25 lines · Arnd Bergmann
drivers/acpi/Makefile +1
-1@@ -41,7 +41,7 @@ acpi-y += resource.o acpi-y += acpi_processor.o acpi-y += processor_core.o acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o -acpi-y += ec.o +acpi-$(CONFIG_HAS_IOPORT) += ec.o acpi-$(CONFIG_ACPI_DOCK) += dock.o acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.odrivers/acpi/bus.c +2
-1@@ -1356,7 +1356,8 @@ static int __init acpi_bus_init(void)* Do that before calling acpi_initialize_objects() which may trigger EC * address space accesses. */ -acpi_ec_ecdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_ecdt_probe ();Quoted 13 lines
drivers/acpi/bus.c static int __init acpi_bus_init(void) · line 1396
Quoted 9 lines
drivers/acpi/bus.c +2
-1status =acpi_enable_subsystem (ACPI_NO_ACPI_ENABLE );if (ACPI_FAILURE (status)) {@@ -1391,7 +1392,8 @@ static int __init acpi_bus_init(void)* Maybe EC region is required at bus_scan/acpi_get_devices. So it * is necessary to enable it as early as possible. */ -acpi_ec_dsdt_probe (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_dsdt_probe ();The above two changes mean that it is not necessary to compile either
acpi_ec_ecdt_probe()oracpi_ec_dsdt_probe()at all ifCONFIG_HAS_IOPORTis not enabled.Correct, this is a result of removing ec.o from the list of objects.
Quoted 11 lines
drivers/acpi/bus.c static int __init acpi_init(void) · line 1470
Quoted 9 lines
drivers/acpi/bus.c +2
-1pr_info ("Interpreter enabled\n" );@@ -1464,7 +1466,8 @@ static int __init acpi_init(void)acpi_arm_init ();acpi_riscv_init ();acpi_scan_init (); -acpi_ec_init (); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_init ();And this means that the whole EC driver is not going to work at all then.
Correct. The way I read
ec.cit makes no sense ifacpi_ec_write_cmd()andacpi_ec_write_data()don't actually access the registers. Is there anything inec.cthat still makes sense without port I/O?Quoted 28 lines
drivers/acpi/processor_perflib.c int acpi_processor_pstate_control(void) · line 460
Quoted 12 lines
drivers/acpi/processor_perflib.c +2
-1@@ -455,7 +455,8 @@ int acpi_processor_pstate_control(void) {acpi_status status; -if (!acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control) +if (!IS_ENABLED (CONFIG_HAS_IOPORT ) || + !acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control)return 0 ;All of the existing callers of
acpi_processor_pstate_control()are x86 which hasCONFIG_HAS_IOPORTAFAICS.And if you care about the code size,
acpi_processor_notify_smm()can go away for !CONFIG_HAS_IOPORT too.Quoted 9 lines
drivers/acpi/processor_perflib.c +0
-0pr_debug("Writing pstate_control [0x%x] to smi_command [0x%x]\n",drivers/acpi/scan.c +0
-0@@ -2293,7 +2293,8 @@ static int acpi_bus_attach(struct acpi_device *device, void *first_pass)if (device->handler) goto ok;
Quoted 8 lines
Quoted 6 lines
drivers/acpi/scan.c static int acpi_bus_attach(struct acpi_device *device, void *first_pass) · line 2297
Quoted 3 lines
drivers/acpi/scan.c +2
-1-acpi_ec_register_opregions (device); +if (IS_ENABLED (CONFIG_HAS_IOPORT )) +acpi_ec_register_opregions (device);I'd rather have an empty stub of
acpi_ec_register_opregions()for !CONFIG_HAS_IOPORT instead.Fair enough. Should I add stubs for all the global EC functions then?
Yes, please.
Quoted 3 lines
I also wonder if there should be a separate
CONFIG_ACPI_ECsymbol that allows the EC logic to be turned off on non-x86 architectures even whenHAS_IOPORTis otherwise enabled.
Yes, CONFIG_ACPI_EC would make sense IMV.
Thanks!