diff mbox series

[RFC] riscv: Fix PCI warning by enabling PCI_MSI_ARCH_FALLBACKS

Message ID 20241213115704.353665-1-alexghiti@rivosinc.com (mailing list archive)
State Handled Elsewhere
Headers show
Series [RFC] riscv: Fix PCI warning by enabling PCI_MSI_ARCH_FALLBACKS | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR fail PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh took 106.17s
conchuod/patch-1-test-2 fail .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh took 1052.86s
conchuod/patch-1-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh took 1222.10s
conchuod/patch-1-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh took 15.91s
conchuod/patch-1-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh took 17.63s
conchuod/patch-1-test-6 success .github/scripts/patches/tests/checkpatch.sh took 0.33s
conchuod/patch-1-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh took 37.09s
conchuod/patch-1-test-8 success .github/scripts/patches/tests/header_inline.sh took 0.00s
conchuod/patch-1-test-9 success .github/scripts/patches/tests/kdoc.sh took 0.46s
conchuod/patch-1-test-10 success .github/scripts/patches/tests/module_param.sh took 0.01s
conchuod/patch-1-test-11 success .github/scripts/patches/tests/verify_fixes.sh took 0.00s
conchuod/patch-1-test-12 success .github/scripts/patches/tests/verify_signedoff.sh took 0.02s

Commit Message

Alexandre Ghiti Dec. 13, 2024, 11:57 a.m. UTC
When the interrupt controller is not using the IMSIC and ACPI is enabled,
the following warning appears:

[    0.866401] WARNING: CPU: 1 PID: 1 at drivers/pci/msi/msi.h:121 pci_msi_setup_msi_irqs+0x2c/0x32
[    0.867071] Modules linked in:
[    0.867389] CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.13.0-rc2-00001-g795582ce7e24-dirty #44
[    0.867538] Hardware name: QEMU QEMU Virtual Machine, BIOS
[    0.867672] epc : pci_msi_setup_msi_irqs+0x2c/0x32
[    0.867738]  ra : __pci_enable_msix_range+0x30c/0x596
[    0.867783] epc : ffffffff8050af80 ra : ffffffff8050a66e sp : ff20000000023750
[    0.867809]  gp : ffffffff815153b0 tp : ff60000080108000 t0 : ff60000081109600
[    0.867833]  t1 : 0000000000000228 t2 : 0000000000000004 s0 : ff20000000023860
[    0.867857]  s1 : ff60000080de1000 a0 : ff60000080de1000 a1 : 0000000000000005
[    0.867880]  a2 : 0000000000000011 a3 : 0000000000000000 a4 : 0000000000000000
[    0.867902]  a5 : 0000000000000000 a6 : ff600000806368f0 a7 : fffffffffffffff0
[    0.867925]  s2 : 0000000000000005 s3 : ffffffffffffffff s4 : 0000000000000000
[    0.867948]  s5 : ff60000080de10c0 s6 : 0000000000000005 s7 : 0000000000000005
[    0.867970]  s8 : ff20000000023a08 s9 : ff600000811093c0 s10: 000000000000002c
[    0.867993]  s11: ff60000081109410 t3 : 0000000000000001 t4 : ff600000803a2878
[    0.868014]  t5 : 0000000000000004 t6 : ff60000080357450
[    0.868036] status: 0000000200000120 badaddr: ffffffff8050af80 cause: 0000000000000003
[    0.868186] [<ffffffff8050af80>] pci_msi_setup_msi_irqs+0x2c/0x32
[    0.868339] [<ffffffff80509172>] pci_alloc_irq_vectors_affinity+0xb8/0xe2
[    0.868362] [<ffffffff8059d62c>] vp_find_vqs_msix+0x12a/0x370
[    0.868385] [<ffffffff8059d8a0>] vp_find_vqs+0x2e/0x1de
[    0.868402] [<ffffffff8059bd80>] vp_modern_find_vqs+0x12/0x4e
[    0.868425] [<ffffffff80624a50>] init_vq+0x2b4/0x336
[    0.868448] [<ffffffff80624c36>] virtblk_probe+0xd4/0x90e
[    0.868469] [<ffffffff80594e02>] virtio_dev_probe+0x14a/0x1e6
[    0.868488] [<ffffffff805fe04c>] really_probe+0x86/0x234
[    0.868509] [<ffffffff805fe256>] __driver_probe_device+0x5c/0xda
[    0.868529] [<ffffffff805fe392>] driver_probe_device+0x2c/0xb2
[    0.868549] [<ffffffff805fe512>] __driver_attach+0x6c/0x11a
[    0.868569] [<ffffffff805fc17e>] bus_for_each_dev+0x60/0xae
[    0.868588] [<ffffffff805fda7c>] driver_attach+0x1a/0x22
[    0.868607] [<ffffffff805fd398>] bus_add_driver+0xce/0x1d6
[    0.868627] [<ffffffff805ff0b2>] driver_register+0x3e/0xd8
[    0.868647] [<ffffffff80594614>] __register_virtio_driver+0x1e/0x2c
[    0.868694] [<ffffffff80a31b82>] virtio_blk_init+0x6a/0x9e
[    0.868733] [<ffffffff8000f128>] do_one_initcall+0x58/0x194
[    0.868755] [<ffffffff80a011b0>] kernel_init_freeable+0x224/0x28e
[    0.868775] [<ffffffff809e4e48>] kernel_init+0x1e/0x13a
[    0.868795] [<ffffffff809ed952>] ret_from_fork+0xe/0x18

So enable PCI_MSI_ARCH_FALLBACKS to get rid of this.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
---

This is an RFC as I'm really not sure this is the right fix,
Anup/Sunil/Thomas if you have any idea, please step in! Thanks

 arch/riscv/Kconfig | 1 +
 1 file changed, 1 insertion(+)

Comments

Thomas Gleixner Dec. 13, 2024, 1:12 p.m. UTC | #1
On Fri, Dec 13 2024 at 12:57, Alexandre Ghiti wrote:
> When the interrupt controller is not using the IMSIC and ACPI is enabled,
> the following warning appears:
>
> [    0.866401] WARNING: CPU: 1 PID: 1 at drivers/pci/msi/msi.h:121 pci_msi_setup_msi_irqs+0x2c/0x32
> [    0.867071] Modules linked in:
> [    0.867389] CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.13.0-rc2-00001-g795582ce7e24-dirty #44
> [    0.867538] Hardware name: QEMU QEMU Virtual Machine, BIOS
> [    0.867672] epc : pci_msi_setup_msi_irqs+0x2c/0x32
> [    0.867738]  ra : __pci_enable_msix_range+0x30c/0x596

Removing a ton of badly formatted stack trace:

https://www.kernel.org/doc/html/latest/process/submitting-patches.html#backtraces-in-commit-messages

>
> So enable PCI_MSI_ARCH_FALLBACKS to get rid of this.

No. PCI_MSI_ARCH_FALLBACKS is really only meant for architectures which
implement the legacy fallbacks and not to paper over the underlying
logic bug in the pci/msi code. Of course the loongson folks ran into the
same problem two years ago and went for the sloppy fix without talking
to anyone...

Thanks for bringing it up instead of silently slapping it into the RISCV
tree !

The uncompiled patch below should fix this for real.

Thanks,

        tglx
---
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -185,7 +185,6 @@ config LOONGARCH
 	select PCI_DOMAINS_GENERIC
 	select PCI_ECAM if ACPI
 	select PCI_LOONGSON
-	select PCI_MSI_ARCH_FALLBACKS
 	select PCI_QUIRKS
 	select PERF_USE_VMALLOC
 	select RTC_LIB
--- a/drivers/pci/msi/irqdomain.c
+++ b/drivers/pci/msi/irqdomain.c
@@ -350,8 +350,11 @@ bool pci_msi_domain_supports(struct pci_
 
 	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)) {
 		/*
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -442,6 +442,10 @@ int __pci_enable_msi_range(struct pci_de
 	if (nvec > maxvec)
 		nvec = maxvec;
 
+	/* Test for the availability of MSI support */
+	if (!pci_msi_domain_supports(dev, 0, ALLOW_LEGACY))
+		return -ENOTSUPP;
+
 	rc = pci_setup_msi_context(dev);
 	if (rc)
 		return rc;
Alexandre Ghiti Dec. 13, 2024, 1:51 p.m. UTC | #2
Hi Thomas,

On Fri, Dec 13, 2024 at 2:12 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> On Fri, Dec 13 2024 at 12:57, Alexandre Ghiti wrote:
> > When the interrupt controller is not using the IMSIC and ACPI is enabled,
> > the following warning appears:
> >
> > [    0.866401] WARNING: CPU: 1 PID: 1 at drivers/pci/msi/msi.h:121 pci_msi_setup_msi_irqs+0x2c/0x32
> > [    0.867071] Modules linked in:
> > [    0.867389] CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.13.0-rc2-00001-g795582ce7e24-dirty #44
> > [    0.867538] Hardware name: QEMU QEMU Virtual Machine, BIOS
> > [    0.867672] epc : pci_msi_setup_msi_irqs+0x2c/0x32
> > [    0.867738]  ra : __pci_enable_msix_range+0x30c/0x596
>
> Removing a ton of badly formatted stack trace:
>
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html#backtraces-in-commit-messages

Thanks for the pointer.

>
> >
> > So enable PCI_MSI_ARCH_FALLBACKS to get rid of this.
>
> No. PCI_MSI_ARCH_FALLBACKS is really only meant for architectures which
> implement the legacy fallbacks and not to paper over the underlying
> logic bug in the pci/msi code. Of course the loongson folks ran into the
> same problem two years ago and went for the sloppy fix without talking
> to anyone...
>
> Thanks for bringing it up instead of silently slapping it into the RISCV
> tree !
>
> The uncompiled patch below should fix this for real.

It does, when applied the warning disappears (on riscv at least). You can add:

Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com> # riscv

Thanks for your quick answer!

Alex

>
> Thanks,
>
>         tglx
> ---
> --- a/arch/loongarch/Kconfig
> +++ b/arch/loongarch/Kconfig
> @@ -185,7 +185,6 @@ config LOONGARCH
>         select PCI_DOMAINS_GENERIC
>         select PCI_ECAM if ACPI
>         select PCI_LOONGSON
> -       select PCI_MSI_ARCH_FALLBACKS
>         select PCI_QUIRKS
>         select PERF_USE_VMALLOC
>         select RTC_LIB
> --- a/drivers/pci/msi/irqdomain.c
> +++ b/drivers/pci/msi/irqdomain.c
> @@ -350,8 +350,11 @@ bool pci_msi_domain_supports(struct pci_
>
>         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)) {
>                 /*
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -442,6 +442,10 @@ int __pci_enable_msi_range(struct pci_de
>         if (nvec > maxvec)
>                 nvec = maxvec;
>
> +       /* Test for the availability of MSI support */
> +       if (!pci_msi_domain_supports(dev, 0, ALLOW_LEGACY))
> +               return -ENOTSUPP;
> +
>         rc = pci_setup_msi_context(dev);
>         if (rc)
>                 return rc;
diff mbox series

Patch

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index d4a7ca0388c0..40d51feac2bb 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -199,6 +199,7 @@  config RISCV
 	select PCI_DOMAINS_GENERIC if PCI
 	select PCI_ECAM if (ACPI && PCI)
 	select PCI_MSI if PCI
+	select PCI_MSI_ARCH_FALLBACKS if PCI
 	select RISCV_ALTERNATIVE if !XIP_KERNEL
 	select RISCV_APLIC
 	select RISCV_IMSIC