PCI/MSI: Make arch_.*_msi_irq[s] fallbacks selectable

The arch_.*_msi_irq[s] fallbacks are compiled in whether an architecture
requires them or not. Architectures which are fully utilizing hierarchical
irq domains should never call into that code.

It's not only architectures which depend on that by implementing one or
more of the weak functions, there is also a bunch of drivers which relies
on the weak functions which invoke msi_controller::setup_irq[s] and
msi_controller::teardown_irq.

Make the architectures and drivers which rely on them select them in Kconfig
and if not selected replace them by stub functions which emit a warning and
fail the PCI/MSI interrupt allocation.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20200826112333.992429909@linutronix.de
This commit is contained in:
Thomas Gleixner 2020-08-26 13:17:02 +02:00
parent 2c681e6b37
commit 077ee78e39
10 changed files with 40 additions and 6 deletions

View File

@ -56,6 +56,7 @@ config IA64
select NEED_DMA_MAP_STATE select NEED_DMA_MAP_STATE
select NEED_SG_DMA_LENGTH select NEED_SG_DMA_LENGTH
select NUMA if !FLATMEM select NUMA if !FLATMEM
select PCI_MSI_ARCH_FALLBACKS
default y default y
help help
The Itanium Processor Family is Intel's 64-bit successor to The Itanium Processor Family is Intel's 64-bit successor to

View File

@ -86,6 +86,7 @@ config MIPS
select MODULES_USE_ELF_REL if MODULES select MODULES_USE_ELF_REL if MODULES
select MODULES_USE_ELF_RELA if MODULES && 64BIT select MODULES_USE_ELF_RELA if MODULES && 64BIT
select PERF_USE_VMALLOC select PERF_USE_VMALLOC
select PCI_MSI_ARCH_FALLBACKS
select RTC_LIB select RTC_LIB
select SYSCTL_EXCEPTION_TRACE select SYSCTL_EXCEPTION_TRACE
select VIRT_TO_BUS select VIRT_TO_BUS

View File

@ -246,6 +246,7 @@ config PPC
select OLD_SIGACTION if PPC32 select OLD_SIGACTION if PPC32
select OLD_SIGSUSPEND select OLD_SIGSUSPEND
select PCI_DOMAINS if PCI select PCI_DOMAINS if PCI
select PCI_MSI_ARCH_FALLBACKS
select PCI_SYSCALL if PCI select PCI_SYSCALL if PCI
select PPC_DAWR if PPC64 select PPC_DAWR if PPC64
select RTC_LIB select RTC_LIB

View File

@ -185,6 +185,7 @@ config S390
select OLD_SIGSUSPEND3 select OLD_SIGSUSPEND3
select PCI_DOMAINS if PCI select PCI_DOMAINS if PCI
select PCI_MSI if PCI select PCI_MSI if PCI
select PCI_MSI_ARCH_FALLBACKS
select SPARSE_IRQ select SPARSE_IRQ
select SYSCTL_EXCEPTION_TRACE select SYSCTL_EXCEPTION_TRACE
select THREAD_INFO_IN_TASK select THREAD_INFO_IN_TASK

View File

@ -43,6 +43,7 @@ config SPARC
select GENERIC_STRNLEN_USER select GENERIC_STRNLEN_USER
select MODULES_USE_ELF_RELA select MODULES_USE_ELF_RELA
select PCI_SYSCALL if PCI select PCI_SYSCALL if PCI
select PCI_MSI_ARCH_FALLBACKS
select ODD_RT_SIGACTION select ODD_RT_SIGACTION
select OLD_SIGSUSPEND select OLD_SIGSUSPEND
select CPU_NO_EFFICIENT_FFS select CPU_NO_EFFICIENT_FFS

View File

@ -225,6 +225,7 @@ config X86
select NEED_SG_DMA_LENGTH select NEED_SG_DMA_LENGTH
select PCI_DOMAINS if PCI select PCI_DOMAINS if PCI
select PCI_LOCKLESS_CONFIG if PCI select PCI_LOCKLESS_CONFIG if PCI
select PCI_MSI_ARCH_FALLBACKS
select PERF_EVENTS select PERF_EVENTS
select RTC_LIB select RTC_LIB
select RTC_MC146818_LIB select RTC_MC146818_LIB

View File

@ -56,6 +56,9 @@ config PCI_MSI_IRQ_DOMAIN
depends on PCI_MSI depends on PCI_MSI
select GENERIC_MSI_IRQ_DOMAIN select GENERIC_MSI_IRQ_DOMAIN
config PCI_MSI_ARCH_FALLBACKS
bool
config PCI_QUIRKS config PCI_QUIRKS
default y default y
bool "Enable PCI quirk workarounds" if EXPERT bool "Enable PCI quirk workarounds" if EXPERT

View File

@ -41,6 +41,7 @@ config PCI_TEGRA
bool "NVIDIA Tegra PCIe controller" bool "NVIDIA Tegra PCIe controller"
depends on ARCH_TEGRA || COMPILE_TEST depends on ARCH_TEGRA || COMPILE_TEST
depends on PCI_MSI_IRQ_DOMAIN depends on PCI_MSI_IRQ_DOMAIN
select PCI_MSI_ARCH_FALLBACKS
help help
Say Y here if you want support for the PCIe host controller found Say Y here if you want support for the PCIe host controller found
on NVIDIA Tegra SoCs. on NVIDIA Tegra SoCs.
@ -67,6 +68,7 @@ config PCIE_RCAR_HOST
bool "Renesas R-Car PCIe host controller" bool "Renesas R-Car PCIe host controller"
depends on ARCH_RENESAS || COMPILE_TEST depends on ARCH_RENESAS || COMPILE_TEST
depends on PCI_MSI_IRQ_DOMAIN depends on PCI_MSI_IRQ_DOMAIN
select PCI_MSI_ARCH_FALLBACKS
help help
Say Y here if you want PCIe controller support on R-Car SoCs in host Say Y here if you want PCIe controller support on R-Car SoCs in host
mode. mode.
@ -95,6 +97,7 @@ config PCI_HOST_GENERIC
config PCIE_XILINX config PCIE_XILINX
bool "Xilinx AXI PCIe host bridge support" bool "Xilinx AXI PCIe host bridge support"
depends on OF || COMPILE_TEST depends on OF || COMPILE_TEST
select PCI_MSI_ARCH_FALLBACKS
help help
Say 'Y' here if you want kernel to support the Xilinx AXI PCIe Say 'Y' here if you want kernel to support the Xilinx AXI PCIe
Host Bridge driver. Host Bridge driver.

View File

@ -58,8 +58,8 @@ static void pci_msi_teardown_msi_irqs(struct pci_dev *dev)
#define pci_msi_teardown_msi_irqs arch_teardown_msi_irqs #define pci_msi_teardown_msi_irqs arch_teardown_msi_irqs
#endif #endif
#ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS
/* Arch hooks */ /* Arch hooks */
int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
{ {
struct msi_controller *chip = dev->bus->msi; struct msi_controller *chip = dev->bus->msi;
@ -132,6 +132,7 @@ void __weak arch_teardown_msi_irqs(struct pci_dev *dev)
{ {
return default_teardown_msi_irqs(dev); return default_teardown_msi_irqs(dev);
} }
#endif /* CONFIG_PCI_MSI_ARCH_FALLBACKS */
static void default_restore_msi_irq(struct pci_dev *dev, int irq) static void default_restore_msi_irq(struct pci_dev *dev, int irq)
{ {

View File

@ -193,17 +193,38 @@ void pci_msi_mask_irq(struct irq_data *data);
void pci_msi_unmask_irq(struct irq_data *data); void pci_msi_unmask_irq(struct irq_data *data);
/* /*
* The arch hooks to setup up msi irqs. Those functions are * The arch hooks to setup up msi irqs. Default functions are implemented
* implemented as weak symbols so that they /can/ be overriden by * as weak symbols so that they /can/ be overriden by architecture specific
* architecture specific code if needed. * code if needed. These hooks must be enabled by the architecture or by
* drivers which depend on them via msi_controller based MSI handling.
*
* If CONFIG_PCI_MSI_ARCH_FALLBACKS is not selected they are replaced by
* stubs with warnings.
*/ */
#ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS
int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc); int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc);
void arch_teardown_msi_irq(unsigned int irq); void arch_teardown_msi_irq(unsigned int irq);
int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
void arch_teardown_msi_irqs(struct pci_dev *dev); void arch_teardown_msi_irqs(struct pci_dev *dev);
void arch_restore_msi_irqs(struct pci_dev *dev);
void default_teardown_msi_irqs(struct pci_dev *dev); void default_teardown_msi_irqs(struct pci_dev *dev);
#else
static inline int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
WARN_ON_ONCE(1);
return -ENODEV;
}
static inline void arch_teardown_msi_irqs(struct pci_dev *dev)
{
WARN_ON_ONCE(1);
}
#endif
/*
* The restore hooks are still available as they are useful even
* for fully irq domain based setups. Courtesy to XEN/X86.
*/
void arch_restore_msi_irqs(struct pci_dev *dev);
void default_restore_msi_irqs(struct pci_dev *dev); void default_restore_msi_irqs(struct pci_dev *dev);
struct msi_controller { struct msi_controller {