]> Git Repo - J-linux.git/commitdiff
PCI/MSI: Handle lack of irqdomain gracefully
authorThomas Gleixner <[email protected]>
Sat, 14 Dec 2024 11:50:18 +0000 (12:50 +0100)
committerThomas Gleixner <[email protected]>
Mon, 16 Dec 2024 09:59:47 +0000 (10:59 +0100)
Alexandre observed a warning emitted from pci_msi_setup_msi_irqs() on a
RISCV platform which does not provide PCI/MSI support:

 WARNING: CPU: 1 PID: 1 at drivers/pci/msi/msi.h:121 pci_msi_setup_msi_irqs+0x2c/0x32
 __pci_enable_msix_range+0x30c/0x596
 pci_msi_setup_msi_irqs+0x2c/0x32
 pci_alloc_irq_vectors_affinity+0xb8/0xe2

RISCV uses hierarchical interrupt domains and correctly does not implement
the legacy fallback. The warning triggers from the legacy fallback stub.

That warning is bogus as the PCI/MSI layer knows whether a PCI/MSI parent
domain is associated with the device or not. There is a check for MSI-X,
which has a legacy assumption. But that legacy fallback assumption is only
valid when legacy support is enabled, but otherwise the check should simply
return -ENOTSUPP.

Loongarch tripped over the same problem and blindly enabled legacy support
without implementing the legacy fallbacks. There are weak implementations
which return an error, so the problem was papered over.

Correct pci_msi_domain_supports() to evaluate the legacy mode and add
the missing supported check into the MSI enable path to complete it.

Fixes: d2a463b29741 ("PCI/MSI: Reject multi-MSI early")
Reported-by: Alexandre Ghiti <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Tested-by: Alexandre Ghiti <[email protected]>
Cc: [email protected]
Link: https://lore.kernel.org/all/87ed2a8ow5.ffs@tglx
drivers/pci/msi/irqdomain.c
drivers/pci/msi/msi.c

index 569125726b3e19593357c349151b5a0a721c6485..d7ba8795d60f81622744c58f44db6dada5e8d7e9 100644 (file)
@@ -350,8 +350,11 @@ bool pci_msi_domain_supports(struct pci_dev *pdev, unsigned int feature_mask,
 
        domain = dev_get_msi_domain(&pdev->dev);
 
-       if (!domain || !irq_domain_is_hierarchy(domain))
-               return mode == ALLOW_LEGACY;
+       if (!domain || !irq_domain_is_hierarchy(domain)) {
+               if (IS_ENABLED(CONFIG_PCI_MSI_ARCH_FALLBACKS))
+                       return mode == ALLOW_LEGACY;
+               return false;
+       }
 
        if (!irq_domain_is_msi_parent(domain)) {
                /*
index 3a45879d85db9613d112b6d888d3e9211cbcb705..2f647cac4cae3484276ecdf658537d9006a7f3d7 100644 (file)
@@ -433,6 +433,10 @@ int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
        if (WARN_ON_ONCE(dev->msi_enabled))
                return -EINVAL;
 
+       /* Test for the availability of MSI support */
+       if (!pci_msi_domain_supports(dev, 0, ALLOW_LEGACY))
+               return -ENOTSUPP;
+
        nvec = pci_msi_vec_count(dev);
        if (nvec < 0)
                return nvec;
This page took 0.051733 seconds and 4 git commands to generate.