irqchip: add EyeQ5 PCIe MSI controller
Subsystems (4)
Gregory CLEMENT
maintainerv5 cover irqchip: add EyeQ5 PCIe MSI controller
Hello,
This series adds support for the MSI controller present in the Mobileye EyeQ5 PCIe ports.
Although the driver uses the standard MSI library, the EyeQ5 hardware has several specific features. First, each PCIe port has its own MSI controller, which snoops the MSI write TLPs that the port receives. A port supports a maximum of 4 MSI vectors, and the memory-region property gives the base address of the doorbell window. In addition, the GCSR mode selects the role: in root complex mode the driver registers a PCI MSI parent, while in endpoint mode it registers a platform MSI parent. The last specific point is that the driver uses the snooper domain as a chained controller on one GIC interrupt.
The series adds the binding document, the irqchip driver, the EyeQ5 DTS changes, and the MAINTAINERS entry. In particular, the DTS changes add the two MSI controllers to the EyeQ5 SoC.
I tested the series on two EyeQ5 SoCs that have a PCIe link. One SoC acted as the host and the other SoC acted as the endpoint. The pci_endpoint_test kselftest passed the MSI-X and DOORBELL_TEST cases. The MSI test uses one vector because the controller does not support standard Multi-MSI. An additional test made sure that each MSI-X vector uses its target CPU (using affinity).
This fifth series fixes the issues pointed out by Sashiko. I also ran a Sashiko-like tool, which pointed out three more potential issues that I fixed too. I hope that with this extra step, there are no more corner cases to fix.
As a side note, I am still a little annoyed by having to add an empty function as an irq_ack callback. I saw that a few other drivers do the same. Could we do better?
First, I was thinking of adding a flag so that in handle_edge_irq() we would not try to use the callback if the flag is set. The drawback is adding an extra test; I do not know if it is really sensible here. At least we could provide this empty function in kernel/irq/chip.c, so each driver could use it instead of declaring its own empty function. These are just suggestions and they do not affect the current series.
Grégory
---
Changes in v5:
- irqchip: fix the MSI loss. Mask the vector on disable_irq() with IRQ_DISABLE_UNLAZY so the MSI stays pending in GCSR_IRQSTATUS until enable_irq(). (sashiko)
- irqchip: filter GCSR_IRQSTATUS with GCSR_IRQMASK in eyeq_msi_isr()
so a masked vector is not dispatched when a sibling fires. (sashiko)
- irqchip: clear GCSR_IRQSTATUS on vector alloc and free, so a reused vector does not deliver a stale MSI to its new owner.
- irqchip: program the hardware before creating the IRQ domain, so no vector can be allocated before the hardware is ready.
- irqchip: bound the ISR loop, so a device that keeps setting a vector cannot hang a CPU.
- Link to v4: https://patch.msgid.link/[email protected]
Changes in v4:
- irqchip: use a plain raw_spinlock() in the mask/unmask callbacks, which run with interrupts disabled.
- irqchip: use guard_chained_irq() to balance the chained handler on every return path.
- irqchip: simplify the domain alloc/free callbacks now that nr_irqs is always 1.
- irqchip: reformat the MSI flag macros and use a distinct "EYEQ-P-" prefix for the platform MSI parent.
- MIPS: move the EYEQ5_MSI selection into a separate MIPS patch, out of the irqchip driver patch.
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- Address review comments from sashiko.
- dt-bindings: drop the interrupt-controller, #interrupt-cells and label properties.
- irqchip: use handle_edge_irq() with an ack callback instead of handle_simple_irq(), so a vector is masked while disabled and a second MSI is not lost while the first is in progress. For this one, I ran some tests to confirm that the issue was real (it was) and that the fix resolves it.
- irqchip: convert to a platform driver because the node is no longer an interrupt controller and is no longer probed by of_irq_init().
- irqchip: stop parsing the label property and use the node full name in the boot message.
- MIPS: dts: update the MSI nodes according to the binding changes.
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Address review comments from Krzysztof Kozlowski, Thomas Gleixner and sashiko.
- dt-bindings: drop the num-vectors property (all ports have four vectors) and simplify the example.
- irqchip: use the fixed four-vector count, add lockdep assertions, and dispatch through generic_handle_demux_domain_irq() with a redirect-based irq_set_affinity() callback.
- irqchip: drop MSI_FLAG_MULTI_PCI_MSI (standard Multi-MSI cannot work with the address-based vector decoding) and MSI_FLAG_NO_AFFINITY; add MSI_FLAG_PCI_MSI_MASK_PARENT.
- irqchip: keep vectors masked during allocation, mask all vectors and clear pending status before installing the chained handler, and reject of_irq_get() returning 0.
- MIPS: dts: drop the num-vectors property from both MSI nodes.
- Reformat the driver for the 100-column limit.
- Link to v1: https://patch.msgid.link/[email protected]
To: Vladimir Kondratiev <[email protected]>
To: Benoît Monin <[email protected]>
To: Gregory CLEMENT <[email protected]>
To: Théo Lebrun <[email protected]>
To: Thomas Gleixner <[email protected]>
To: Radu Rendec <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: Thomas Bogendoerfer <[email protected]>
Cc: Thomas Petazzoni <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Gregory CLEMENT (5):
dt-bindings: interrupt-controller: add Mobileye EyeQ5 PCIe MSI controller
irqchip: irq-eyeq5-msi: add EyeQ5 PCIe MSI controller driver
MIPS: eyeq: select the EyeQ5 MSI controller
MIPS: dts: eyeq5: add MSI controllers
MAINTAINERS: add EyeQ5 MSI controller entry
.../interrupt-controller/mobileye,eyeq5-msi.yaml | 76 ++++ MAINTAINERS | 2 + arch/mips/Kconfig | 1 + arch/mips/boot/dts/mobileye/eyeq5.dtsi | 22 + drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-eyeq5-msi.c | 475 +++++++++++++++++++++ 7 files changed, 582 insertions(+)
---
base-commit: 08b814ca0a6945b8effc1a0d64999d562f24c923
change-id: 20261028-eyeq5_msi-86aa1d590684
Best regards,
Signature · 3 lines
Grégory CLEMENT, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Gregory CLEMENT
maintainerPATCH v5 1/5 dt-bindings: interrupt-controller: add Mobileye EyeQ5 PCIe MSI controller
Add binding for the Mobileye EyeQ5 PCIe MSI controller.
--- .../interrupt-controller/mobileye,eyeq5-msi.yaml | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/mobileye,eyeq5-msi.yaml new file +76 -0
@@ -0,0 +1,76 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/mobileye,eyeq5-msi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mobileye EyeQ5 PCIe MSI controller + +maintainers: + - Gregory CLEMENT <[email protected]> + +description: | + The Mobileye EyeQ5 PCIe MSI controller snoops the MSI write TLPs of a + PCIe port. The controller signals the parent interrupt controller when a + vector is pending. The memory-region property gives the base address of + the doorbell window. A port supports a maximum of 4 MSI vectors. + + This node is an MSI parent for the PCIe port. The driver chains the + controller interrupt to the parent interrupt controller. + +allOf: + - $ref: /schemas/interrupt-controller/msi-controller.yaml# + +properties: + compatible: + const: mobileye,eyeq5-msi + + reg: + items: + - description: GCSR block of the PCIe port + - description: MSI vector control block + + interrupts: + maxItems: 1 + + msi-controller: true + + '#msi-cells': + const: 0 + + memory-region: + maxItems: 1 + description: + Reserved-memory region. The hardware uses its base address as the MSI + doorbell window. + +required: + - compatible + - reg + - interrupts + - msi-controller + - '#msi-cells' + - memory-region + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/mips-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + msi-controller@5840000 { + compatible = "mobileye,eyeq5-msi"; + reg = <0x0 0x05840000 0x0 0x10>, + <0x0 0x05840040 0x0 0x20>; + interrupt-parent = <&gic>; + interrupts = <GIC_SHARED 7 IRQ_TYPE_LEVEL_HIGH>; + msi-controller; + #msi-cells = <0>; + memory-region = <&pci0_msi_reserved>; + }; + };
Signature · 1 line
2.53.0
Gregory CLEMENT
maintainerPATCH v5 2/5 irqchip: irq-eyeq5-msi: add EyeQ5 PCIe MSI controller driver
In reply to Gregory CLEMENTEach EyeQ5 PCIe port has its own MSI controller. The controller snoops the MSI write TLPs that the port receives. It raises an interrupt when a write targets the doorbell window. A port supports a maximum of 4 MSI vectors.
The driver supports two roles, selected by the GCSR mode. In root complex mode, it registers a PCI MSI parent. In endpoint mode, it registers a platform MSI parent. The driver chains the snooper domain to one GIC interrupt.
--- drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-eyeq5-msi.c | 475 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 481 insertions(+)
drivers/irqchip/Kconfig +5 -0
@@ -827,6 +827,11 @@ config APPLE_AIC Support for the Apple Interrupt Controller found on Apple Silicon SoCs, such as the M1. +config EYEQ5_MSI + bool + select IRQ_DOMAIN + select IRQ_MSI_LIB + config MCHP_EIC bool "Microchip External Interrupt Controller" depends on ARCH_AT91 || COMPILE_TEST
drivers/irqchip/Makefile +1 -0
@@ -132,6 +132,7 @@ obj-$(CONFIG_MACH_REALTEK_RTL) += irq-realtek-rtl.o obj-$(CONFIG_WPCM450_AIC) += irq-wpcm450-aic.o obj-$(CONFIG_IRQ_IDT3243X) += irq-idt3243x.o obj-$(CONFIG_APPLE_AIC) += irq-apple-aic.o +obj-$(CONFIG_EYEQ5_MSI) += irq-eyeq5-msi.o obj-$(CONFIG_MCHP_EIC) += irq-mchp-eic.o obj-$(CONFIG_SOPHGO_SG2042_MSI) += irq-sg2042-msi.o obj-$(CONFIG_SUNPLUS_SP7021_INTC) += irq-sp7021-intc.o
drivers/irqchip/irq-eyeq5-msi.c new file +475 -0
475 lines not on this page · raw message
Signature · 1 line
2.53.0
Gregory CLEMENT
maintainerPATCH v5 3/5 MIPS: eyeq: select the EyeQ5 MSI controller
In reply to Gregory CLEMENTThe MSI controller is part of the EyeQ SoC. This change selects it by default.
--- arch/mips/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/mips/Kconfig +1 -0
@@ -632,6 +632,7 @@ config EYEQ select CPU_MIPSR2_IRQ_VI select CSRC_R4K select DMA_NONCOHERENT + select EYEQ5_MSI select HAVE_PCI select IRQ_MIPS_CPU select MIPS_AUTO_PFN_OFFSET
Signature · 1 line
2.53.0
Gregory CLEMENT
maintainerPATCH v5 4/5 MIPS: dts: eyeq5: add MSI controllers
In reply to Gregory CLEMENTAdd the two EyeQ5 MSI controllers. They use reserved-memory regions as their doorbell windows.
--- arch/mips/boot/dts/mobileye/eyeq5.dtsi | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/mips/boot/dts/mobileye/eyeq5.dtsi +22 -0
@@ -309,6 +309,28 @@ gpio1: gpio@1500000 { resets = <&olb 0 26>; }; + msi0: msi-controller@5840000 { + compatible = "mobileye,eyeq5-msi"; + reg = <0x0 0x05840000 0x0 0x10>, + <0x0 0x05840040 0x0 0x20>; + interrupt-parent = <&gic>; + msi-controller; + #msi-cells = <0>; + interrupts = <GIC_SHARED 7 IRQ_TYPE_LEVEL_HIGH>; + memory-region = <&pci0_msi_reserved>; + }; + + msi1: msi-controller@5840010 { + compatible = "mobileye,eyeq5-msi"; + reg = <0x0 0x05840010 0x0 0x10>, + <0x0 0x05840060 0x0 0x20>; + interrupt-parent = <&gic>; + msi-controller; + #msi-cells = <0>; + interrupts = <GIC_SHARED 48 IRQ_TYPE_LEVEL_HIGH>; + memory-region = <&pci1_msi_reserved>; + }; + iocu-bus { compatible = "simple-bus"; #address-cells = <2>;
Signature · 1 line
2.53.0
Gregory CLEMENT
maintainerPATCH v5 5/5 MAINTAINERS: add EyeQ5 MSI controller entry
In reply to Gregory CLEMENTAdd the EyeQ5 MSI controller binding document and driver.
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -18769,12 +18769,14 @@ M: Gregory CLEMENT <[email protected]> M: Théo Lebrun <[email protected]> L: [email protected] S: Maintained +F: Documentation/devicetree/bindings/interrupt-controller/mobileye,eyeq5-msi.yaml F: Documentation/devicetree/bindings/mips/mobileye.yaml F: Documentation/devicetree/bindings/soc/mobileye/ F: arch/mips/boot/dts/mobileye/ F: arch/mips/configs/eyeq*_defconfig F: arch/mips/mobileye/board-epm5.its.S F: drivers/clk/clk-eyeq.c +F: drivers/irqchip/irq-eyeq5-msi.c F: drivers/phy/phy-eyeq5-eth.c F: drivers/pinctrl/pinctrl-eyeq5.c F: drivers/reset/reset-eyeq.c
Signature · 1 line
2.53.0