]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iommu/riscv: Skip IRQ count check when using MSI interrupts
authorYaxing Guo <guoyaxing@bosc.ac.cn>
Fri, 30 Jan 2026 06:54:20 +0000 (14:54 +0800)
committerJoerg Roedel <joerg.roedel@amd.com>
Tue, 17 Mar 2026 12:12:17 +0000 (13:12 +0100)
In RISC-V IOMMU platform devices that use MSI interrupts (indicated by the
presence of 'msi-parent' in the device tree), there are no wired interrupt
lines, so calling platform_get_irq_count() returns 0 or -ENXIO, causing the
driver to fail during probe.

However, MSI interrupts are allocated dynamically via the MSI subsystem and
do not appear in the device tree 'interrupts' property. Therefore, the
driver should not require a non-zero IRQ count when 'msi-parent' is present.

This patch fixes the bug where probe fails when using MSI interrupts
 (which do not have an 'interrupts' property in the device tree)..

Fixes: <d5f88acdd6ff> ("iommu/riscv: Add support for platform msi")
Signed-off-by: Yaxing Guo <guoyaxing@bosc.ac.cn>
Reviewed-by: Andrew Jones <andrew.jones@oss.qualcomm.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/riscv/iommu-platform.c

index 83a28c83f99145ad0fcd4b4877ba104a76d9ab14..8f15b06e8499741153407da8743a723f2215aa01 100644 (file)
@@ -68,12 +68,7 @@ static int riscv_iommu_platform_probe(struct platform_device *pdev)
        iommu->caps = riscv_iommu_readq(iommu, RISCV_IOMMU_REG_CAPABILITIES);
        iommu->fctl = riscv_iommu_readl(iommu, RISCV_IOMMU_REG_FCTL);
 
-       iommu->irqs_count = platform_irq_count(pdev);
-       if (iommu->irqs_count <= 0)
-               return dev_err_probe(dev, -ENODEV,
-                                    "no IRQ resources provided\n");
-       if (iommu->irqs_count > RISCV_IOMMU_INTR_COUNT)
-               iommu->irqs_count = RISCV_IOMMU_INTR_COUNT;
+       iommu->irqs_count = RISCV_IOMMU_INTR_COUNT;
 
        igs = FIELD_GET(RISCV_IOMMU_CAPABILITIES_IGS, iommu->caps);
        switch (igs) {
@@ -120,6 +115,13 @@ msi_fail:
                fallthrough;
 
        case RISCV_IOMMU_CAPABILITIES_IGS_WSI:
+               iommu->irqs_count = platform_irq_count(pdev);
+               if (iommu->irqs_count <= 0)
+                       return dev_err_probe(dev, -ENODEV,
+                                            "no IRQ resources provided\n");
+               if (iommu->irqs_count > RISCV_IOMMU_INTR_COUNT)
+                       iommu->irqs_count = RISCV_IOMMU_INTR_COUNT;
+
                for (vec = 0; vec < iommu->irqs_count; vec++)
                        iommu->irqs[vec] = platform_get_irq(pdev, vec);