Skip to content

Commit 077ee78

Browse files
committed
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
1 parent 2c681e6 commit 077ee78

10 files changed

Lines changed: 40 additions & 6 deletions

File tree

arch/ia64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ config IA64
5656
select NEED_DMA_MAP_STATE
5757
select NEED_SG_DMA_LENGTH
5858
select NUMA if !FLATMEM
59+
select PCI_MSI_ARCH_FALLBACKS
5960
default y
6061
help
6162
The Itanium Processor Family is Intel's 64-bit successor to

arch/mips/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ config MIPS
8686
select MODULES_USE_ELF_REL if MODULES
8787
select MODULES_USE_ELF_RELA if MODULES && 64BIT
8888
select PERF_USE_VMALLOC
89+
select PCI_MSI_ARCH_FALLBACKS
8990
select RTC_LIB
9091
select SYSCTL_EXCEPTION_TRACE
9192
select VIRT_TO_BUS

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ config PPC
246246
select OLD_SIGACTION if PPC32
247247
select OLD_SIGSUSPEND
248248
select PCI_DOMAINS if PCI
249+
select PCI_MSI_ARCH_FALLBACKS
249250
select PCI_SYSCALL if PCI
250251
select PPC_DAWR if PPC64
251252
select RTC_LIB

arch/s390/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ config S390
185185
select OLD_SIGSUSPEND3
186186
select PCI_DOMAINS if PCI
187187
select PCI_MSI if PCI
188+
select PCI_MSI_ARCH_FALLBACKS
188189
select SPARSE_IRQ
189190
select SYSCTL_EXCEPTION_TRACE
190191
select THREAD_INFO_IN_TASK

arch/sparc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ config SPARC
4343
select GENERIC_STRNLEN_USER
4444
select MODULES_USE_ELF_RELA
4545
select PCI_SYSCALL if PCI
46+
select PCI_MSI_ARCH_FALLBACKS
4647
select ODD_RT_SIGACTION
4748
select OLD_SIGSUSPEND
4849
select CPU_NO_EFFICIENT_FFS

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ config X86
225225
select NEED_SG_DMA_LENGTH
226226
select PCI_DOMAINS if PCI
227227
select PCI_LOCKLESS_CONFIG if PCI
228+
select PCI_MSI_ARCH_FALLBACKS
228229
select PERF_EVENTS
229230
select RTC_LIB
230231
select RTC_MC146818_LIB

drivers/pci/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ config PCI_MSI_IRQ_DOMAIN
5656
depends on PCI_MSI
5757
select GENERIC_MSI_IRQ_DOMAIN
5858

59+
config PCI_MSI_ARCH_FALLBACKS
60+
bool
61+
5962
config PCI_QUIRKS
6063
default y
6164
bool "Enable PCI quirk workarounds" if EXPERT

drivers/pci/controller/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ config PCI_TEGRA
4141
bool "NVIDIA Tegra PCIe controller"
4242
depends on ARCH_TEGRA || COMPILE_TEST
4343
depends on PCI_MSI_IRQ_DOMAIN
44+
select PCI_MSI_ARCH_FALLBACKS
4445
help
4546
Say Y here if you want support for the PCIe host controller found
4647
on NVIDIA Tegra SoCs.
@@ -67,6 +68,7 @@ config PCIE_RCAR_HOST
6768
bool "Renesas R-Car PCIe host controller"
6869
depends on ARCH_RENESAS || COMPILE_TEST
6970
depends on PCI_MSI_IRQ_DOMAIN
71+
select PCI_MSI_ARCH_FALLBACKS
7072
help
7173
Say Y here if you want PCIe controller support on R-Car SoCs in host
7274
mode.
@@ -95,6 +97,7 @@ config PCI_HOST_GENERIC
9597
config PCIE_XILINX
9698
bool "Xilinx AXI PCIe host bridge support"
9799
depends on OF || COMPILE_TEST
100+
select PCI_MSI_ARCH_FALLBACKS
98101
help
99102
Say 'Y' here if you want kernel to support the Xilinx AXI PCIe
100103
Host Bridge driver.

drivers/pci/msi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ static void pci_msi_teardown_msi_irqs(struct pci_dev *dev)
5858
#define pci_msi_teardown_msi_irqs arch_teardown_msi_irqs
5959
#endif
6060

61+
#ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS
6162
/* Arch hooks */
62-
6363
int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
6464
{
6565
struct msi_controller *chip = dev->bus->msi;
@@ -132,6 +132,7 @@ void __weak arch_teardown_msi_irqs(struct pci_dev *dev)
132132
{
133133
return default_teardown_msi_irqs(dev);
134134
}
135+
#endif /* CONFIG_PCI_MSI_ARCH_FALLBACKS */
135136

136137
static void default_restore_msi_irq(struct pci_dev *dev, int irq)
137138
{

include/linux/msi.h

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,38 @@ void pci_msi_mask_irq(struct irq_data *data);
193193
void pci_msi_unmask_irq(struct irq_data *data);
194194

195195
/*
196-
* The arch hooks to setup up msi irqs. Those functions are
197-
* implemented as weak symbols so that they /can/ be overriden by
198-
* architecture specific code if needed.
196+
* The arch hooks to setup up msi irqs. Default functions are implemented
197+
* as weak symbols so that they /can/ be overriden by architecture specific
198+
* code if needed. These hooks must be enabled by the architecture or by
199+
* drivers which depend on them via msi_controller based MSI handling.
200+
*
201+
* If CONFIG_PCI_MSI_ARCH_FALLBACKS is not selected they are replaced by
202+
* stubs with warnings.
199203
*/
204+
#ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS
200205
int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc);
201206
void arch_teardown_msi_irq(unsigned int irq);
202207
int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
203208
void arch_teardown_msi_irqs(struct pci_dev *dev);
204-
void arch_restore_msi_irqs(struct pci_dev *dev);
205-
206209
void default_teardown_msi_irqs(struct pci_dev *dev);
210+
#else
211+
static inline int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
212+
{
213+
WARN_ON_ONCE(1);
214+
return -ENODEV;
215+
}
216+
217+
static inline void arch_teardown_msi_irqs(struct pci_dev *dev)
218+
{
219+
WARN_ON_ONCE(1);
220+
}
221+
#endif
222+
223+
/*
224+
* The restore hooks are still available as they are useful even
225+
* for fully irq domain based setups. Courtesy to XEN/X86.
226+
*/
227+
void arch_restore_msi_irqs(struct pci_dev *dev);
207228
void default_restore_msi_irqs(struct pci_dev *dev);
208229

209230
struct msi_controller {

0 commit comments

Comments
 (0)