ACPI: Allow CONFIG_PCI to be unset for reboot
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v11 1/7 ACPI: Allow CONFIG_PCI to be unset for reboot
Make PCI reboot conditional on PCI support being present on the kernel configuration.
--- drivers/acpi/reboot.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/acpi/reboot.c +7 -3
@@ -7,8 +7,6 @@void acpi_reboot (void ) {struct acpi_generic_address *rr; -struct pci_bus *bus0; -unsigned int devfn;u8 reset_value;if (acpi_disabled)
@@ -33,6 +31,11 @@ void acpi_reboot(void)* on a device on bus 0. */ switch (rr->space_id) {case ACPI_ADR_SPACE_PCI_CONFIG : + { +#ifdef CONFIG_PCI +unsigned int devfn; +struct pci_bus *bus0; +/* The reset register can only live on bus 0. */ bus0 =pci_find_bus (0 ,0 );if (!bus0)
@@ -44,8 +47,9 @@ void acpi_reboot(void)/* Write the value that resets us. */ pci_bus_write_config_byte (bus0, devfn, (rr->address &0xffff ), reset_value); +#endif break ; - + }case ACPI_ADR_SPACE_SYSTEM_MEMORY :case ACPI_ADR_SPACE_SYSTEM_IO :printk (KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n" );
Signature · 1 line
2.19.0
drivers/acpi/reboot.c void acpi_reboot(void) · line 50
Quoted 12 lines
drivers/acpi/reboot.c +5
-0+#ifdef CONFIG_PCI +unsigned int devfn; +struct pci_bus *bus0; +/* The reset register can only live on bus 0. */ bus0 =pci_find_bus (0 ,0 );if (!bus0)@@ -44,8 +47,9 @@ void acpi_reboot(void)/* Write the value that resets us. */ pci_bus_write_config_byte (bus0, devfn, (rr->address &0xffff ), reset_value); +#endif
This would be a lot cleaner if this was split into a little helper function.
Quoted 8 lines · Christoph Hellwig
drivers/acpi/reboot.c void acpi_reboot(void) · line 50
Quoted 5 lines
drivers/acpi/reboot.c +1
-0@@ -44,8 +47,9 @@ void acpi_reboot(void)/* Write the value that resets us. */ pci_bus_write_config_byte (bus0, devfn, (rr->address &0xffff ), reset_value); +#endif This would be a lot cleaner if this was split into a little helper function.
done.
PATCH v11 2/7 ACPI / OSL: Stub out acpi_os_(read/write)_pci_configurations()
In reply to a message not in the archiveGetting ready to allow CONFIG_PCI to be unset with ACPI enabled. Stub out acpi_os_read_pci_configuration and acpi_os_write_pci_configuration functions when CONFIG_PCI is not defined.
--- drivers/acpi/osl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/acpi/osl.c +14 -0
@@ -773,6 +773,7 @@ acpi_status acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, u64 *value, u32 width) { +#ifdef CONFIG_PCI int result, size;u32 value32;
@@ -799,12 +800,19 @@ acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, *value = value32;return (result ?AE_ERROR :AE_OK ); +#else +int rc; + + rc =pr_warn_once ("PCI configuration space access is not supported\n" ); +return rc ?AE_SUPPORT :AE_OK ; +#endif }acpi_status acpi_os_write_pci_configuration (struct acpi_pci_id * pci_id,u32 reg,u64 value,u32 width) { +#ifdef CONFIG_PCI int result, size;switch (width) {
@@ -826,6 +834,12 @@ acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, reg, size, value);return (result ?AE_ERROR :AE_OK ); +#else +int rc; + + rc =pr_warn_once ("PCI configuration space access is not supported\n" ); +return rc ?AE_SUPPORT :AE_OK ; +#endif }static void acpi_os_execute_deferred (struct work_struct *work)
Signature · 1 line
2.19.0
Re: [PATCH v11 2/7] ACPI / OSL: Stub out acpi_os_(read/write)_pci_configurations()
Quoted 22 lines · Sinan Kaya
Getting ready to allow
CONFIG_PCIto be unset with ACPI enabled. Stub outacpi_os_read_pci_configurationandacpi_os_write_pci_configurationfunctions whenCONFIG_PCIis not defined.Signed-off-by Sinan Kaya <[email protected]>--- drivers/acpi/osl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/acpi/osl.c +1
-0@@ -773,6 +773,7 @@ acpi_status acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, u64 *value, u32 width) { +#ifdef CONFIG_PCI int result, size;u32 value32;
drivers/acpi/osl.c acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, · line 808
Quoted 9 lines
drivers/acpi/osl.c +6
-0@@ -799,12 +800,19 @@ acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, *value = value32;return (result ?AE_ERROR :AE_OK ); +#else +int rc; + + rc =pr_warn_once ("PCI configuration space access is not supported\n" ); +return rc ?AE_SUPPORT :AE_OK ; +#endif
Normally we provide a full separate stub version. If we have enough of them in a separate file.
Re: [PATCH v11 2/7] ACPI / OSL: Stub out acpi_os_(read/write)_pci_configurations()
Quoted 7 lines · Christoph Hellwig
drivers/acpi/osl.c acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, · line 808
Quoted 4 lines
drivers/acpi/osl.c +4
-0+ + rc =pr_warn_once ("PCI configuration space access is not supported\n" ); +return rc ?AE_SUPPORT :AE_OK ; +#endif Normally we provide a full separate stub version. If we have enough of them in a separate file.
I removed the dependent functions from ACPICA and moved #ifdef outside of these two function scopes.
Got rid of the inline piece.
PATCH v11 3/7 PCI/ACPI: Allow ACPI to be built without CONFIG_PCI set
In reply to a message not in the archiveWe are compiling PCI code today for systems with ACPI and no PCI device present. Remove the useless code and reduce the tight dependency.
--- arch/x86/include/asm/pci_x86.h | 7 +++++++ drivers/acpi/Kconfig | 1 - drivers/acpi/Makefile | 2 +- drivers/acpi/internal.h | 5 +++++ drivers/pci/Makefile | 2 +- include/acpi/acpi_drivers.h | 7 +++++++ include/linux/acpi.h | 7 +++++++ include/linux/pci.h | 4 ++++ 8 files changed, 32 insertions(+), 3 deletions(-)
arch/x86/include/asm/pci_x86.h +7 -0
@@ -121,7 +121,14 @@ extern void __init dmi_check_pciprobe(void);extern void __init dmi_check_skip_isa_align (void );/* some common used subsys_initcalls */ +#ifdef CONFIG_PCI extern int __init pci_acpi_init (void ); +#else +static inline int __init pci_acpi_init (void ) +{ +return -EINVAL ; +} +#endif extern void __init pcibios_irq_init (void );extern int __init pcibios_init (void );extern int pci_legacy_init (void );
drivers/acpi/Kconfig +0 -1
@@ -9,7 +9,6 @@ config ARCH_SUPPORTS_ACPI menuconfig ACPI bool "ACPI (Advanced Configuration and Power Interface) Support" depends on ARCH_SUPPORTS_ACPI - depends on PCI select PNP default y if X86 help
drivers/acpi/Makefile +1 -1
@@ -39,7 +39,7 @@ acpi-y += processor_core.o acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o acpi-y += ec.o acpi-$(CONFIG_ACPI_DOCK) += dock.o -acpi-y += pci_root.o pci_link.o pci_irq.o +acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.o acpi-y += acpi_lpss.o acpi_apd.o acpi-y += acpi_platform.o
drivers/acpi/internal.h +5 -0
@@ -25,8 +25,13 @@ int acpi_osi_init(void);acpi_status acpi_os_initialize1 (void );void init_acpi_device_notify (void );int acpi_scan_init (void ); +#ifdef CONFIG_PCI void acpi_pci_root_init (void );void acpi_pci_link_init (void ); +#else +static inline void acpi_pci_root_init (void ) {} +static inline void acpi_pci_link_init (void ) {} +#endif void acpi_processor_init (void );void acpi_platform_init (void );void acpi_pnp_init (void );
drivers/pci/Makefile +1 -1
@@ -11,6 +11,7 @@ ifdef CONFIG_PCI obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_SYSFS) += slot.o obj-$(CONFIG_OF) += of.o +obj-$(CONFIG_ACPI) += pci-acpi.o endif obj-$(CONFIG_PCI_QUIRKS) += quirks.o
@@ -20,7 +21,6 @@ obj-$(CONFIG_PCI_MSI) += msi.o obj-$(CONFIG_PCI_ATS) += ats.o obj-$(CONFIG_PCI_IOV) += iov.o obj-$(CONFIG_PCI_BRIDGE_EMUL) += pci-bridge-emul.o -obj-$(CONFIG_ACPI) += pci-acpi.o obj-$(CONFIG_PCI_LABEL) += pci-label.o obj-$(CONFIG_X86_INTEL_MID) += pci-mid.o obj-$(CONFIG_PCI_SYSCALL) += syscall.o
include/acpi/acpi_drivers.h +7 -0
@@ -88,7 +88,14 @@ int acpi_pci_link_free_irq(acpi_handle handle);struct pci_bus ; +#ifdef CONFIG_PCI struct pci_dev *acpi_get_pci_dev (acpi_handle ); +#else +static inline struct pci_dev *acpi_get_pci_dev (acpi_handle handle) +{ +return NULL ; +} +#endif /* Arch-defined function to add a bus to the system */
include/linux/acpi.h +7 -0
@@ -340,7 +340,14 @@ struct pci_dev;int acpi_pci_irq_enable (struct pci_dev *dev);void acpi_penalize_isa_irq (int irq,int active);bool acpi_isa_irq_available (int irq); +#ifdef CONFIG_PCI void acpi_penalize_sci_irq (int irq,int trigger,int polarity); +#else +static inline void acpi_penalize_sci_irq (int irq,int trigger, +int polarity) +{ +} +#endif void acpi_pci_irq_disable (struct pci_dev *dev);extern int ec_read (u8 addr,u8 *val);
include/linux/pci.h +4 -0
@@ -1960,7 +1960,11 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);int pcibios_add_device (struct pci_dev *dev);void pcibios_release_device (struct pci_dev *dev); +#ifdef CONFIG_PCI void pcibios_penalize_isa_irq (int irq,int active); +#else +static inline void pcibios_penalize_isa_irq (int irq,int active) {} +#endif int pcibios_alloc_irq (struct pci_dev *dev);void pcibios_free_irq (struct pci_dev *dev);resource_size_t pcibios_default_alignment (void );
Signature · 1 line
2.19.0
PATCH v11 4/7 ACPICA: Remove PCI bits from ACPICA when CONFIG_PCI is unset
In reply to a message not in the archiveNow that we allow CONFIG_PCI to be unset, remove useless code from ACPICA too.
--- drivers/acpi/acpica/Makefile | 2 +- drivers/acpi/acpica/achware.h | 9 +++++++++ include/acpi/platform/aclinux.h | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-)
drivers/acpi/acpica/Makefile +1 -1
@@ -77,13 +77,13 @@ acpi-y += \ hwacpi.o \ hwesleep.o \ hwgpe.o \ - hwpci.o \ hwregs.o \ hwsleep.o \ hwvalid.o \ hwxface.o \ hwxfsleep.o +acpi-$(CONFIG_PCI) += hwpci.o acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o acpi-y += \
drivers/acpi/acpica/achware.h +9 -0
@@ -106,11 +106,20 @@ acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,struct acpi_gpe_block_info *gpe_block, void *context); +#ifdef ACPI_PCI_CONFIGURED /* * hwpci - PCI configuration support */ acpi_status acpi_hw_derive_pci_id (struct acpi_pci_id *pci_id,acpi_handle root_pci_device,acpi_handle pci_region); +#else +static inline acpi_status +acpi_hw_derive_pci_id (struct acpi_pci_id *pci_id,acpi_handle root_pci_device, +acpi_handle pci_region) +{ +return AE_SUPPORT ; +} +#endif #endif /* __ACHWARE_H__ */
include/acpi/platform/aclinux.h +4 -0
@@ -33,6 +33,10 @@/* Kernel specific ACPICA configuration */ +#ifdef CONFIG_PCI +#define ACPI_PCI_CONFIGURED +#endif +#ifdef CONFIG_ACPI_REDUCED_HARDWARE_ONLY #define ACPI_REDUCED_HARDWARE 1#endif
Signature · 1 line
2.19.0
PATCH v11 5/7 arm64: select ACPI PCI code only both features are enabled
In reply to a message not in the archiveACPI and PCI are no longer coupled to each other. Specify requirements for both when pulling in code.
--- arch/arm64/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/Kconfig +2 -2
@@ -5,7 +5,7 @@ config ARM64 select ACPI_GTDT if ACPI select ACPI_IORT if ACPI select ACPI_REDUCED_HARDWARE_ONLY if ACPI - select ACPI_MCFG if ACPI + select ACPI_MCFG if (ACPI && PCI) select ACPI_SPCR_TABLE if ACPI select ACPI_PPTT if ACPI select ARCH_CLOCKSOURCE_DATA
@@ -163,7 +163,7 @@ config ARM64 select OF select OF_EARLY_FLATTREE select OF_RESERVED_MEM - select PCI_ECAM if ACPI + select PCI_ECAM if (ACPI && PCI) select POWER_RESET select POWER_SUPPLY select REFCOUNT_FULL
Signature · 1 line
2.19.0
PATCH v11 6/7 ACPI/IORT: Stub out ACS functions when CONFIG_PCI is not set
In reply to a message not in the archiveRemove PCI dependent code out of iort.c when CONFIG_PCI is not defined. A quick search reveals the following functions:
1. pci_request_acs()
2. pci_domain_nr()
3. pci_is_root_bus()
4. to_pci_dev()
Both pci_domain_nr() and pci_is_root_bus() are defined in linux/pci.h. pci_domain_nr() is a stub function when CONFIG_PCI is not set and pci_is_root_bus() just returns a reference to a structure member which is still valid without CONFIG_PCI set.
to_pci_dev() is a macro that expands to container_of.
pci_request_acs() is the only code that gets pulled in from drivers/pci/*.c
--- drivers/acpi/arm64/iort.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/acpi/arm64/iort.c +14 -7
@@ -1435,8 +1435,14 @@ static int __init iort_add_platform_device(struct acpi_iort_node *node,return ret; } -static bool __init iort_enable_acs (struct acpi_iort_node *iort_node) +#ifdef CONFIG_PCI +static void __init iort_enable_acs (struct acpi_iort_node *iort_node) { +static bool acs_enabled__initdata ; + +if (acs_enabled) +return ; +if (iort_node->type ==ACPI_IORT_NODE_PCI_ROOT_COMPLEX ) {struct acpi_iort_node *parent;struct acpi_iort_id_mapping *map;
@@ -1458,13 +1464,16 @@ static bool __init iort_enable_acs(struct acpi_iort_node *iort_node)if ((parent->type ==ACPI_IORT_NODE_SMMU ) || (parent->type ==ACPI_IORT_NODE_SMMU_V3 )) {pci_request_acs (); -return true; + acs_enabled = true; +return ; } } } - -return false; +return ; } +#else +static inline void iort_enable_acs (struct acpi_iort_node *iort_node) { } +#endif static void __init iort_init_platform_devices (void ) {
@@ -1472,7 +1481,6 @@ static void __init iort_init_platform_devices(void)struct acpi_table_iort *iort;struct fwnode_handle *fwnode;int i, ret; -bool acs_enabled = false;const struct iort_dev_config *ops;/*
@@ -1493,8 +1501,7 @@ static void __init iort_init_platform_devices(void)return ; } -if (!acs_enabled) - acs_enabled =iort_enable_acs (iort_node); +iort_enable_acs (iort_node); ops =iort_get_dev_cfg (iort_node);if (ops) {
Signature · 1 line
2.19.0
Hanjun Guo
maintainerRe: [PATCH v11 6/7] ACPI/IORT: Stub out ACS functions when CONFIG_PCI is not set
Quoted 7 lines · Sinan Kaya
Remove PCI dependent code out of
iort.cwhenCONFIG_PCIis not defined. A quick search reveals the following functions:
1.pci_request_acs()
2.pci_domain_nr()
3.pci_is_root_bus()
4.to_pci_dev()
Quoted 8 lines
Both
pci_domain_nr()andpci_is_root_bus()are defined inlinux/pci.h.pci_domain_nr()is a stub function whenCONFIG_PCIis not set andpci_is_root_bus()just returns a reference to a structure member which is still valid withoutCONFIG_PCIset.
to_pci_dev()is a macro that expands tocontainer_of.
pci_request_acs()is the only code that gets pulled in fromdrivers/pci/*.c
Actually we have pci_for_each_dma_alias() too which is from drivers/pci/search.c without stub function in linux/pci.h, but I didn't get the compile error at link time, I think the compiler just do some optimization to remove the dead code because dev_is_pci() is obvious false.
Thanks
Hanjun
Re: [PATCH v11 6/7] ACPI/IORT: Stub out ACS functions when CONFIG_PCI is not set
In reply to Sinan KayaQuoted 7 lines · Sinan Kaya
Remove PCI dependent code out of
iort.cwhenCONFIG_PCIis not defined. A quick search reveals the following functions:
1.pci_request_acs()
2.pci_domain_nr()
3.pci_is_root_bus()
4.to_pci_dev()
Quoted 8 lines
Both
pci_domain_nr()andpci_is_root_bus()are defined inlinux/pci.h.pci_domain_nr()is a stub function whenCONFIG_PCIis not set andpci_is_root_bus()just returns a reference to a structure member which is still valid withoutCONFIG_PCIset.
to_pci_dev()is a macro that expands tocontainer_of.
pci_request_acs()is the only code that gets pulled in fromdrivers/pci/*.c
I am not a big fan of these assumptions but we can stub all code relying on those behind the CONFIG_PCI guard later, which would result in cleaner code too.
Quoted 29 lines
Signed-off-by Sinan Kaya <[email protected]>--- drivers/acpi/arm64/iort.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)drivers/acpi/arm64/iort.c +7
-1@@ -1435,8 +1435,14 @@ static int __init iort_add_platform_device(struct acpi_iort_node *node,return ret; } -static bool __init iort_enable_acs (struct acpi_iort_node *iort_node) +#ifdef CONFIG_PCI +static void __init iort_enable_acs (struct acpi_iort_node *iort_node) { +static bool acs_enabled__initdata ; + +if (acs_enabled) +return ; +if (iort_node->type ==ACPI_IORT_NODE_PCI_ROOT_COMPLEX ) {struct acpi_iort_node *parent;struct acpi_iort_id_mapping *map;@@ -1458,13 +1464,16 @@ static bool __init iort_enable_acs(struct acpi_iort_node *iort_node)if ((parent->type ==ACPI_IORT_NODE_SMMU ) || (parent->type ==ACPI_IORT_NODE_SMMU_V3 )) {
drivers/acpi/arm64/iort.c static bool __init iort_enable_acs(struct acpi_iort_node *iort_node) · line 1472
Quoted 10 lines
drivers/acpi/arm64/iort.c +3
-3pci_request_acs (); -return true; + acs_enabled = true; +return ; } } } - -return false; +return ;
Remove this return;
With that updated:
Quoted 28 lines
drivers/acpi/arm64/iort.c +4
-3} +#else +static inline void iort_enable_acs (struct acpi_iort_node *iort_node) { } +#endif static void __init iort_init_platform_devices (void ) {@@ -1472,7 +1481,6 @@ static void __init iort_init_platform_devices(void)struct acpi_table_iort *iort;struct fwnode_handle *fwnode;int i, ret; -bool acs_enabled = false;const struct iort_dev_config *ops;/* @@ -1493,8 +1501,7 @@ static void __init iort_init_platform_devices(void)return ; } -if (!acs_enabled) - acs_enabled =iort_enable_acs (iort_node); +iort_enable_acs (iort_node); ops =iort_get_dev_cfg (iort_node);if (ops) {Signature · 1 line
2.19.0
PATCH v11 7/7 ACPI: Make PCI slot detection driver depend on PCI
In reply to a message not in the archiveSince this is ACPI PCI slot detection driver for PCI, it doesn't make sense to compile this without PCI support in place.
--- drivers/acpi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/Kconfig +1 -1
@@ -369,7 +369,7 @@ config ACPI_DEBUG config ACPI_PCI_SLOT bool "PCI slot detection driver" - depends on SYSFS + depends on SYSFS && PCI help This driver creates entries in /sys/bus/pci/slots/ for all PCI slots in the system. This can help correlate PCI bus addresses,
Signature · 1 line
2.19.0