Re: [RFC PATCH v2 11/21] PCI: MSI: Add helper function to set system wide MSI support

Sunil V L
2023-10-30T17:55:12Z

On Mon, Oct 30, 2023 at 03:28:53PM +0100, Thomas Gleixner wrote:
> On Thu, Oct 26 2023 at 01:53, Sunil V. L. wrote:
> > Like pci_no_msi() used to disable MSI support, add a function to enable
> > system wide MSI support.
>
> Why?
>
> int pci_msi_enable = 1;
>
> So this function makes it more one or what am I missing here?
>
Hi Thomas,

Just noting related discussion :
https://www.spinics.net/lists/linux-serial/msg57616.html

The MSI controller on RISC-V (IMSIC) is optional for the platform. So,
when by default pci_msi_enable = 1 and the MSI controller is not
discovered, we get stack trace like below.

[ 0.608941] [<ffffffff804d0400>] pci_msi_setup_msi_irqs+0x18/0x34
[ 0.608991] [<ffffffff804cfe04>] msix_capability_init+0x228/0x406
[ 0.609001] [<ffffffff804cfbc6>] __pci_enable_msix_range+0x1b4/0x1ca
[ 0.609011] [<ffffffff804ce8c2>]
pci_alloc_irq_vectors_affinity+0x6e/0xee
[ 0.609020] [<ffffffff8055015c>] vp_find_vqs_msix+0xfa/0x350
[ 0.609031] [<ffffffff8054ff54>] vp_find_vqs+0x36/0x144
[ 0.609040] [<ffffffff8054f7b8>] vp_modern_find_vqs+0x14/0x48
[ 0.609049] [<ffffffff8064d3fc>] init_vqs+0x362/0x4ee
[ 0.609058] [<ffffffff8064c8be>] virtnet_probe+0x672/0xa70
[ 0.609067] [<ffffffff80549d38>] virtio_dev_probe+0x194/0x200
[ 0.609075] [<ffffffff805afb52>] really_probe+0x106/0x28a
[ 0.609083] [<ffffffff805aefda>] __driver_probe_device+0x62/0xdc
[ 0.609091] [<ffffffff805af920>] driver_probe_device+0x38/0x164
[ 0.609098] [<ffffffff805af146>] __driver_attach+0xd0/0x17c
[ 0.609106] [<ffffffff805ac6e2>] bus_for_each_dev+0xd0/0x11c
[ 0.609116] [<ffffffff805af06e>] driver_attach+0x1a/0x22
[ 0.609123] [<ffffffff805ace06>] bus_add_driver+0x136/0x208
[ 0.609132] [<ffffffff805b044e>] driver_register+0x48/0xda
[ 0.609140] [<ffffffff80549594>] register_virtio_driver+0x20/0x2a
[ 0.609157] [<ffffffff80a3060e>] virtio_net_driver_init+0x76/0xa6
[ 0.609168] [<ffffffff800020ec>] do_one_initcall+0xc0/0x21e
[ 0.609176] [<ffffffff80a00f68>] do_initcall_level+0x7c/0x8e
[ 0.609186] [<ffffffff80a00eb6>] do_initcalls+0x52/0x88
[ 0.609195] [<ffffffff80a00e5c>] do_basic_setup+0x1c/0x24
[ 0.609204] [<ffffffff80a00e00>] kernel_init_freeable+0xe2/0x122
[ 0.609213] [<ffffffff8090beb4>] kernel_init+0x1a/0x18e
[ 0.609223] [<ffffffff8000383e>] ret_from_fork+0xa/0x1c

So, what I did was, by default call pci_no_msi() to disable MSI and then
call pci_set_msi() to enable when MSI controller is probed.

But I think Bjorn's suggestion to depend on PCI_BUS_FLAGS_NO_MSI may be
better idea. In that case, we need to set bridge->msi_domain to true in
pci_create_root_bus(). Let me know what do you prefer or if I am
completely missing something here.

Thanks,
Sunil