linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] riscv: Kconfig: do not select PCI_MSI if CONIFG_PCI is enabled
@ 2021-07-09  3:12 Vincent Chen
  2021-07-20  8:05 ` Vincent Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Chen @ 2021-07-09  3:12 UTC (permalink / raw)
  To: linux-riscv, palmer; +Cc: Vincent Chen

The CONFIG_PCI_MSI is used to allow device drivers to enable MSI. The MSI
enables a device to generate an interrupt using an inbound Memory Write
on its PCI bus instead of asserting a device IRQ pin. The whole mechanism
needs support from the PCI controller or generic interrupt controller and
the corresponding software driver.

The RISC-V Kconfig file actively selects the PCI_MSI  if users enable
CONFIG_PCI. However, the RISC-V specification does not require every RISC-V
platform shall have MSI support. In other words, Kconfig enables CONFIG_PCI
to allow PCI devices to use MSI, but due to lack of MSI support, the kernel
may not have any function to deal with the MSI from PCI devices. When this
case happens, it leads to the following warning message displayed in
booting a v5.10~v5.12 kernel.

------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at include/linux/msi.h:219 __pci_enable_msix_range+0x4b6/0x50e
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.34 #76
epc: ffffffe0004fa1e0 ra : ffffffe0004fa02e sp : ffffffe07fea7920
 gp : ffffffe0010e25c0 tp : ffffffe07fea8000 t0 : ffffffe0808c3180
 t1 : ffffffd000239000 t2 : 0000000000000400 s0 : ffffffe07fea79e0
 s1 : ffffffe080803000 a0 : 0000000000000000 a1 : ffffffe080803210
 a2 : ffffffe0808c30c0 a3 : 0000000000000101 a4 : ffffffe0808c30c0
 a5 : 0000000000000010 a6 : ffffffe0004dcf98 a7 : ffffffe07fe0f010
 s2 : 0000000000000002 s3 : 0000000000000014 s4 : 0000000000000000
 s5 : ffffffe080803210 s6 : 0000000000000000 s7 : ffffffe0808c3120
 s8 : ffffffe0808c30c0 s9 : 0000000000000000 s10: 0000000000000002
 s11: ffffffe0808030b0 t3 : 0000000000001000 t4 : 0000000000001000
 t5 : ffffffd040239000 t6 : ffffffe07ff8b2c0
status: 0000000000000120 badaddr: 0000000000000000 cause: 0000000000000003

A simple reproduce way is to use defconfig to configure the 64-bit riscv
v5.10 ~ v5.12 kernel but disable CONFIG_PCIE_XILINX, and then booting this
kernel on the QEMU virt platform with virtio-mouse-pci.

ARM's implementation may be a good sample for this case. Its Kconfig file
does not select CONFIG_PCI_MSI. Instead, It makes the selection of
CONFIG_PCI_MSI depends on the capability of the interrupt controller. This
way seems to be more straightforward. Therefore, this patch follows the
same way to remove the dependency between CONFIG_PCI and CONFIG_PCI_MSI
from Kconfig, which allows users to enable or disable CONFIG_PCI_MSI
according to the capabilities of the platform.

(note) Why does this warning message only happen in the v5.10 to v5.12 kernel?
When the kernel wants to register the MSI ID of the first PCI device, if
the PCI device does not belong to any MSI domain and there is no valid
arch_setup_msi_irqs() defined by architecture or PCI controller, the
generic arch_setup_msi_irqs() will be called to display this warning
message. However, before v5.10, this flow is different. A valid and weak
arch_setup_msi_irqs() is defined in driver/pci/msi.c. The kernel can use
this arch_setup_msi_irqs() to set up the MSI. Therefore, it will not
encounter any problems even if the architecture and PCI controller does
not define it. After v5.13, the kernel uses the MSI domain to deal with
all the setup of MSI issues. Only some old PCI controller still uses
arch_setup_msi_irqs(). Through the hierarchy of the MSI domain, the kernel
can know the bus used by the PCI device has MSI support or not before
doing the MSI setup. In this condition, the kernel will return early before
calling the generic arch_setup_msi_irqs(), which will trigger the warning
message.

Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
---
 arch/riscv/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 469a70bd8da6..563d550cb682 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -97,7 +97,6 @@ config RISCV
 	select OF_EARLY_FLATTREE
 	select OF_IRQ
 	select PCI_DOMAINS_GENERIC if PCI
-	select PCI_MSI if PCI
 	select RISCV_INTC
 	select RISCV_TIMER if RISCV_SBI
 	select SPARSE_IRQ
-- 
2.7.4


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] riscv: Kconfig: do not select PCI_MSI if CONIFG_PCI is enabled
  2021-07-09  3:12 [RFC PATCH] riscv: Kconfig: do not select PCI_MSI if CONIFG_PCI is enabled Vincent Chen
@ 2021-07-20  8:05 ` Vincent Chen
  2021-07-20 14:25   ` Jisheng Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Chen @ 2021-07-20  8:05 UTC (permalink / raw)
  To: linux-riscv, Palmer Dabbelt

Just a gentle ping.
Does anyone have any comments on this RFC patch? If not, I will remove
the "note" part from the git description and resend it as a formal
patch. Thank you.

On Fri, Jul 9, 2021 at 11:12 AM Vincent Chen <vincent.chen@sifive.com> wrote:
>
> The CONFIG_PCI_MSI is used to allow device drivers to enable MSI. The MSI
> enables a device to generate an interrupt using an inbound Memory Write
> on its PCI bus instead of asserting a device IRQ pin. The whole mechanism
> needs support from the PCI controller or generic interrupt controller and
> the corresponding software driver.
>
> The RISC-V Kconfig file actively selects the PCI_MSI  if users enable
> CONFIG_PCI. However, the RISC-V specification does not require every RISC-V
> platform shall have MSI support. In other words, Kconfig enables CONFIG_PCI
> to allow PCI devices to use MSI, but due to lack of MSI support, the kernel
> may not have any function to deal with the MSI from PCI devices. When this
> case happens, it leads to the following warning message displayed in
> booting a v5.10~v5.12 kernel.
>
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 1 at include/linux/msi.h:219 __pci_enable_msix_range+0x4b6/0x50e
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.34 #76
> epc: ffffffe0004fa1e0 ra : ffffffe0004fa02e sp : ffffffe07fea7920
>  gp : ffffffe0010e25c0 tp : ffffffe07fea8000 t0 : ffffffe0808c3180
>  t1 : ffffffd000239000 t2 : 0000000000000400 s0 : ffffffe07fea79e0
>  s1 : ffffffe080803000 a0 : 0000000000000000 a1 : ffffffe080803210
>  a2 : ffffffe0808c30c0 a3 : 0000000000000101 a4 : ffffffe0808c30c0
>  a5 : 0000000000000010 a6 : ffffffe0004dcf98 a7 : ffffffe07fe0f010
>  s2 : 0000000000000002 s3 : 0000000000000014 s4 : 0000000000000000
>  s5 : ffffffe080803210 s6 : 0000000000000000 s7 : ffffffe0808c3120
>  s8 : ffffffe0808c30c0 s9 : 0000000000000000 s10: 0000000000000002
>  s11: ffffffe0808030b0 t3 : 0000000000001000 t4 : 0000000000001000
>  t5 : ffffffd040239000 t6 : ffffffe07ff8b2c0
> status: 0000000000000120 badaddr: 0000000000000000 cause: 0000000000000003
>
> A simple reproduce way is to use defconfig to configure the 64-bit riscv
> v5.10 ~ v5.12 kernel but disable CONFIG_PCIE_XILINX, and then booting this
> kernel on the QEMU virt platform with virtio-mouse-pci.
>
> ARM's implementation may be a good sample for this case. Its Kconfig file
> does not select CONFIG_PCI_MSI. Instead, It makes the selection of
> CONFIG_PCI_MSI depends on the capability of the interrupt controller. This
> way seems to be more straightforward. Therefore, this patch follows the
> same way to remove the dependency between CONFIG_PCI and CONFIG_PCI_MSI
> from Kconfig, which allows users to enable or disable CONFIG_PCI_MSI
> according to the capabilities of the platform.
>
> (note) Why does this warning message only happen in the v5.10 to v5.12 kernel?
> When the kernel wants to register the MSI ID of the first PCI device, if
> the PCI device does not belong to any MSI domain and there is no valid
> arch_setup_msi_irqs() defined by architecture or PCI controller, the
> generic arch_setup_msi_irqs() will be called to display this warning
> message. However, before v5.10, this flow is different. A valid and weak
> arch_setup_msi_irqs() is defined in driver/pci/msi.c. The kernel can use
> this arch_setup_msi_irqs() to set up the MSI. Therefore, it will not
> encounter any problems even if the architecture and PCI controller does
> not define it. After v5.13, the kernel uses the MSI domain to deal with
> all the setup of MSI issues. Only some old PCI controller still uses
> arch_setup_msi_irqs(). Through the hierarchy of the MSI domain, the kernel
> can know the bus used by the PCI device has MSI support or not before
> doing the MSI setup. In this condition, the kernel will return early before
> calling the generic arch_setup_msi_irqs(), which will trigger the warning
> message.
>
> Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
> ---
>  arch/riscv/Kconfig | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 469a70bd8da6..563d550cb682 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -97,7 +97,6 @@ config RISCV
>         select OF_EARLY_FLATTREE
>         select OF_IRQ
>         select PCI_DOMAINS_GENERIC if PCI
> -       select PCI_MSI if PCI
>         select RISCV_INTC
>         select RISCV_TIMER if RISCV_SBI
>         select SPARSE_IRQ
> --
> 2.7.4
>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] riscv: Kconfig: do not select PCI_MSI if CONIFG_PCI is enabled
  2021-07-20  8:05 ` Vincent Chen
@ 2021-07-20 14:25   ` Jisheng Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Jisheng Zhang @ 2021-07-20 14:25 UTC (permalink / raw)
  To: Vincent Chen; +Cc: linux-riscv, Palmer Dabbelt

On Tue, 20 Jul 2021 16:05:33 +0800
Vincent Chen <vincent.chen@sifive.com> wrote:

> Just a gentle ping.
> Does anyone have any comments on this RFC patch? If not, I will remove
> the "note" part from the git description and resend it as a formal
> patch. Thank you.
> 
> On Fri, Jul 9, 2021 at 11:12 AM Vincent Chen <vincent.chen@sifive.com> wrote:
> >
> > The CONFIG_PCI_MSI is used to allow device drivers to enable MSI. The MSI
> > enables a device to generate an interrupt using an inbound Memory Write
> > on its PCI bus instead of asserting a device IRQ pin. The whole mechanism
> > needs support from the PCI controller or generic interrupt controller and
> > the corresponding software driver.
> >
> > The RISC-V Kconfig file actively selects the PCI_MSI  if users enable
> > CONFIG_PCI. However, the RISC-V specification does not require every RISC-V
> > platform shall have MSI support. In other words, Kconfig enables CONFIG_PCI
> > to allow PCI devices to use MSI, but due to lack of MSI support, the kernel
> > may not have any function to deal with the MSI from PCI devices. When this
> > case happens, it leads to the following warning message displayed in
> > booting a v5.10~v5.12 kernel.
> >
> > ------------[ cut here ]------------
> > WARNING: CPU: 0 PID: 1 at include/linux/msi.h:219 __pci_enable_msix_range+0x4b6/0x50e
> > Modules linked in:
> > CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.34 #76
> > epc: ffffffe0004fa1e0 ra : ffffffe0004fa02e sp : ffffffe07fea7920
> >  gp : ffffffe0010e25c0 tp : ffffffe07fea8000 t0 : ffffffe0808c3180
> >  t1 : ffffffd000239000 t2 : 0000000000000400 s0 : ffffffe07fea79e0
> >  s1 : ffffffe080803000 a0 : 0000000000000000 a1 : ffffffe080803210
> >  a2 : ffffffe0808c30c0 a3 : 0000000000000101 a4 : ffffffe0808c30c0
> >  a5 : 0000000000000010 a6 : ffffffe0004dcf98 a7 : ffffffe07fe0f010
> >  s2 : 0000000000000002 s3 : 0000000000000014 s4 : 0000000000000000
> >  s5 : ffffffe080803210 s6 : 0000000000000000 s7 : ffffffe0808c3120
> >  s8 : ffffffe0808c30c0 s9 : 0000000000000000 s10: 0000000000000002
> >  s11: ffffffe0808030b0 t3 : 0000000000001000 t4 : 0000000000001000
> >  t5 : ffffffd040239000 t6 : ffffffe07ff8b2c0
> > status: 0000000000000120 badaddr: 0000000000000000 cause: 0000000000000003
> >
> > A simple reproduce way is to use defconfig to configure the 64-bit riscv
> > v5.10 ~ v5.12 kernel but disable CONFIG_PCIE_XILINX, and then booting this
> > kernel on the QEMU virt platform with virtio-mouse-pci.
> >
> > ARM's implementation may be a good sample for this case. Its Kconfig file
> > does not select CONFIG_PCI_MSI. Instead, It makes the selection of
> > CONFIG_PCI_MSI depends on the capability of the interrupt controller. This
> > way seems to be more straightforward. Therefore, this patch follows the
> > same way to remove the dependency between CONFIG_PCI and CONFIG_PCI_MSI
> > from Kconfig, which allows users to enable or disable CONFIG_PCI_MSI
> > according to the capabilities of the platform.
> >
> > (note) Why does this warning message only happen in the v5.10 to v5.12 kernel?
> > When the kernel wants to register the MSI ID of the first PCI device, if
> > the PCI device does not belong to any MSI domain and there is no valid
> > arch_setup_msi_irqs() defined by architecture or PCI controller, the
> > generic arch_setup_msi_irqs() will be called to display this warning
> > message. However, before v5.10, this flow is different. A valid and weak
> > arch_setup_msi_irqs() is defined in driver/pci/msi.c. The kernel can use
> > this arch_setup_msi_irqs() to set up the MSI. Therefore, it will not
> > encounter any problems even if the architecture and PCI controller does
> > not define it. After v5.13, the kernel uses the MSI domain to deal with
> > all the setup of MSI issues. Only some old PCI controller still uses
> > arch_setup_msi_irqs(). Through the hierarchy of the MSI domain, the kernel
> > can know the bus used by the PCI device has MSI support or not before
> > doing the MSI setup. In this condition, the kernel will return early before
> > calling the generic arch_setup_msi_irqs(), which will trigger the warning
> > message.
> >
> > Signed-off-by: Vincent Chen <vincent.chen@sifive.com>

Reviewed-by: Jisheng Zhang <jszhang@kernel.org>

> > ---
> >  arch/riscv/Kconfig | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > index 469a70bd8da6..563d550cb682 100644
> > --- a/arch/riscv/Kconfig
> > +++ b/arch/riscv/Kconfig
> > @@ -97,7 +97,6 @@ config RISCV
> >         select OF_EARLY_FLATTREE
> >         select OF_IRQ
> >         select PCI_DOMAINS_GENERIC if PCI
> > -       select PCI_MSI if PCI
> >         select RISCV_INTC
> >         select RISCV_TIMER if RISCV_SBI
> >         select SPARSE_IRQ
> > --
> > 2.7.4
> >  
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-20 14:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-09  3:12 [RFC PATCH] riscv: Kconfig: do not select PCI_MSI if CONIFG_PCI is enabled Vincent Chen
2021-07-20  8:05 ` Vincent Chen
2021-07-20 14:25   ` Jisheng Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).