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

Message ID 20231025202344.581132-12-sunilvl@ventanamicro.com
State New
Headers
Series RISC-V: ACPI: Add external interrupt controller support |

Commit Message

Sunil V L Oct. 25, 2023, 8:23 p.m. UTC
  Like pci_no_msi() used to disable MSI support, add a function to enable
system wide MSI support.

Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
---
 drivers/pci/msi/msi.c | 5 +++++
 drivers/pci/pci.h     | 2 ++
 2 files changed, 7 insertions(+)
  

Comments

Thomas Gleixner Oct. 30, 2023, 2:28 p.m. UTC | #1
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?

Thanks,

        tglx
  
Sunil V L Oct. 30, 2023, 5:54 p.m. UTC | #2
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
  
Thomas Gleixner Oct. 30, 2023, 7:29 p.m. UTC | #3
On Mon, Oct 30 2023 at 23:24, Sunil V. L. wrote:
> On Mon, Oct 30, 2023 at 03:28:53PM +0100, Thomas Gleixner wrote:
> 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.

<SNIP>

> 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.

Your taste sensors should have gone out of range ...

> 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.

That's definitely more sensible, but as I said in the other thread, Marc
is the one who did the PCI core/bridge setup magic and he is definitely
in a better position to answer that bridge->msi_domain question.

Thanks,

        tglx
  
Sunil V L Oct. 31, 2023, 2 a.m. UTC | #4
On Mon, Oct 30, 2023 at 08:29:13PM +0100, Thomas Gleixner wrote:
> On Mon, Oct 30 2023 at 23:24, Sunil V. L. wrote:
> > On Mon, Oct 30, 2023 at 03:28:53PM +0100, Thomas Gleixner wrote:
> > 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.
> 
> <SNIP>
> 
> > 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.
> 
> Your taste sensors should have gone out of range ...
> 
> > 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.
> 
> That's definitely more sensible, but as I said in the other thread, Marc
> is the one who did the PCI core/bridge setup magic and he is definitely
> in a better position to answer that bridge->msi_domain question.
> 
Thanks!. It looks like Marc introduced bridge->msi_domain in [1] for
exactly the same problem we have with RISC-V + ACPI. Let me remove this
hack and do similar to pci_host_common_probe() in next revision unless I
get objections to that approach.

Sorry, somehow my script didn't copy Marc in the series. Will make sure
I copy him explicitly in next revision.

[1] - https://lore.kernel.org/all/20210330151145.997953-12-maz@kernel.org/

Thanks!
Sunil
  

Patch

diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index ef1d8857a51b..e76ccb8b5f0b 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -913,3 +913,8 @@  void pci_no_msi(void)
 {
 	pci_msi_enable = 0;
 }
+
+void pci_set_msi(void)
+{
+	pci_msi_enable = 1;
+}
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 39a8932dc340..2f876c29f75c 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -167,8 +167,10 @@  extern unsigned int pci_pm_d3hot_delay;
 
 #ifdef CONFIG_PCI_MSI
 void pci_no_msi(void);
+void pci_set_msi(void);
 #else
 static inline void pci_no_msi(void) { }
+static inline void pci_set_msi(void) { }
 #endif
 
 void pci_realloc_get_opt(char *);