Skip to contentSkip to conversation

Add Xilinx Versal NET SMMU CSR interrupt controller support

PATCH Superseded Tushar Nimkar 3 participants 5 messages Sep 18 – Sep 23

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Tushar Nimkar

author maintainer
#0 lore raw

v2 cover Add Xilinx Versal NET SMMU CSR interrupt controller support

On Xilinx Versal NET, the ARM SMMUv3 EVENTQ, PRIQ and GERROR interrupts are routed through a vendor-specific Control and Status Register (CSR) block, where they must be enabled, cleared and acknowledged before being forwarded to the parent GIC.
This series adds a small irqchip driver for the CSR block that chains to the standard arm-smmu-v3 driver, so the generic SMMUv3 driver needs no changes.
Patch 1 adds the DT binding.
Patch 2 adds the irqchip driver.

Changes in v2:
- Posted as a proper threaded series with a cover letter (v1 patches went out individually).
- dt-bindings (Krzysztof):
- Dropped the irrelevant arm,smmu-v3 consumer node from the example.
- Dropped the unused "smmu_irq_csr" label from the example.
- Dropped the redundant "binding" from the patch subject.
- irqchip driver (Thomas):
- Aligned kernel-doc member descriptions and used "interrupt" instead of "IRQ".
- Used guard(raw_spinlock)() in the mask/unmask/ack callbacks and addressed the comments related to lock handling.
- Thomas suggested using devm-managed allocation and irqdomain APIs; however, the driver is registered via IRQCHIP_DECLARE() and has no associated struct device, so devm APIs cannot be used. This code is left unchanged.

Link to v1:
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/

---
Anirudha Sarangi (2):
dt-bindings: interrupt-controller: Add Xilinx Versal NET SMMU CSR
irqchip: Add Xilinx Versal NET SMMU CSR interrupt controller driver

 .../xlnx,versal-net-smmu-csr.yaml                  |  75 +++++++
 MAINTAINERS                                        |  10 +
 drivers/irqchip/Kconfig                            |  10 +
 drivers/irqchip/Makefile                           |   1 +
 drivers/irqchip/irq-xilinx-smmu-csr.c              | 216 +++++++++++++++++++++
 5 files changed, 312 insertions(+)

---
base-commit: 0d9d0dbf2fddcff5859d623e90ca73c4054276e1
change-id: 20260917-smmu-changes-v2-9cf7435d6969

Best regards,

Signature · 1 line
Tushar Nimkar <[email protected]>
author maintainer
#1 lore raw

PATCH v2 1/2 dt-bindings: interrupt-controller: Add Xilinx Versal NET SMMU CSR

From: Anirudha Sarangi <[email protected]>

Add a device tree binding schema for the Xilinx Versal NET SMMU CSR (Control and Status Register) interrupt controller.

The SMMU CSR block acts as a vendor-specific interrupt controller in front of the ARM SMMUv3, providing registers to enable and clear standard SMMU interrupts such as EVENTQ, CMDQ_SYNC, GERROR and PRIQ. Interrupts must be acknowledged in this block before being forwarded to the parent interrupt controller (e.g. GIC).

---
 .../xlnx,versal-net-smmu-csr.yaml                  | 75 ++++++++++++++++++++++
 1 file changed, 75 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/xlnx,versal-net-smmu-csr.yaml new file +75 -0
new file mode 100644
index 000000000000..38b63e51b732
@@ -0,0 +1,75 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/xlnx,versal-net-smmu-csr.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Xilinx Versal NET SMMU CSR Interrupt Controller
+
+maintainers:
+  - Anirudha Sarangi <[email protected]>
+  - Tushar Nimkar <[email protected]>
+
+description: |
+  The Versal NET platform includes a Xilinx-specific SMMU CSR (Control and
+  Status Register) block that acts as an intermediate interrupt controller
+  for ARM SMMUv3.
+
+  The block provides registers to enable, disable and clear the
+  standard SMMUv3 interrupt sources (EVENTQ, CMDQ_SYNC, GERROR and PRIQ)
+  before forwarding them to the parent interrupt controller,
+  typically a GIC.
+
+  The controller receives one parent interrupt and demultiplexes CSR
+  status bits into the following child interrupt identifiers
+    0 - EVENTQ
+    1 - CMDQ_SYNC
+    2 - GERROR (GLOBAL)
+    3 - PRIQ
+
+allOf:
+  - $ref: /schemas/interrupt-controller.yaml#
+
+properties:
+  compatible:
+    const: xlnx,versal-net-smmu-csr
+
+  reg:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 1
+    description: |
+     Single cell containing the child interrupt identifier
+      0 - EVENTQ
+      1 - CMDQ_SYNC
+      2 - GERROR (GLOBAL)
+      3 - PRIQ
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupt-controller
+  - "#interrupt-cells"
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    interrupt-controller@eca10000 {
+        compatible = "xlnx,versal-net-smmu-csr";
+        reg = <0xeca10000 0x1000>;
+        interrupt-controller;
+        #interrupt-cells = <1>;
+        interrupt-parent = <&gic>;
+        interrupts = <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>;
+    };
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v2 2/2 irqchip: Add Xilinx Versal NET SMMU CSR interrupt controller driver

In reply to Tushar Nimkar

From: Anirudha Sarangi <[email protected]>

The Xilinx Versal NET SoC implements a Control and Status Register (CSR) block in front of the ARM SMMUv3 to manage EVENTQ, PRIQ and GLOBAL interrupts. Interrupts are enabled, cleared, and acknowledged through this block by writing to the relevant registers. Once an interrupt is acknowledged, it is forwarded to the parent interrupt controller for further processing.

Add an irqchip driver for the CSR block. The driver registers as an interrupt controller and chains to the upstream SMMUv3 driver, so that the standard SMMUv3 driver does not require modification while still supporting Xilinx SoCs.

The CSR block can also gate the SMMUv3 CMDQ_SYNC completion interrupt (bit 1), but it is intentionally left unsupported. The Linux arm-smmu-v3 driver signals CMDQ_SYNC completion via polling or MSI and never requests a wired CMD_SYNC interrupt, so there is no in-kernel consumer for it. Exposing it as a child line would only risk spurious, never-acked interrupts, and it is omitted from the DT binding for the same reason.

This driver is intended to operate in conjunction with the ARM SMMUv3 driver and the kernel's IOMMU DMA infrastructure. These dependencies are not selected directly in Kconfig to avoid introducing dependency recursion.

---
 MAINTAINERS                           |  10 ++
 drivers/irqchip/Kconfig               |  10 ++
 drivers/irqchip/Makefile              |   1 +
 drivers/irqchip/irq-xilinx-smmu-csr.c | 216 ++++++++++++++++++++++++++++++++++
 4 files changed, 237 insertions(+)
MAINTAINERS +10 -0
index 6e50747a621c..40ef350285a6 100644
@@ -30141,6 +30141,16 @@ F:	Documentation/misc-devices/xilinx_sdfec.rst
 F:	drivers/misc/xilinx_sdfec.c
 F:	include/uapi/misc/xilinx_sdfec.h
 
+XILINX SMMU CSR IRQ DRIVER
+M:	Anirudha Sarangi <[email protected]>
+M:	Tushar Nimkar <[email protected]>
+L:	[email protected]
+L:	[email protected]
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/interrupt-controller/xlnx,versal-net-smmu-csr.yaml
+F:	drivers/irqchip/irq-xilinx-smmu-csr.c
+
 XILINX TRNG DRIVER
 M:	Mounika Botcha <[email protected]>
 M:	Harsh Jain <[email protected]>
drivers/irqchip/Kconfig +10 -0
index a8f8c423b795..81a2c9107601 100644
@@ -842,4 +842,14 @@ config SUNPLUS_SP7021_INTC
 	  chained controller, routing all interrupt source in P-Chip to
 	  the primary controller on C-Chip.
 
+config IRQCHIP_XILINX_SMMU_CSR
+	bool "Xilinx SMMU CSR Interrupt Driver"
+	depends on ARCH_ZYNQMP
+	select IRQ_DOMAIN
+	help
+	  This driver does the initial handling of SMMU interrupts before
+	  forwarding them to the ARM SMMU v3 driver.  It is intended for
+	  ZynqMP-class platforms where a vendor CSR block mediates SMMU
+	  interrupts.
+
 endmenu
drivers/irqchip/Makefile +1 -0
index ab33cccd8471..16a5fd126c9a 100644
@@ -135,3 +135,4 @@ obj-$(CONFIG_APPLE_AIC)			+= irq-apple-aic.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
+obj-$(CONFIG_IRQCHIP_XILINX_SMMU_CSR)	+= irq-xilinx-smmu-csr.o
drivers/irqchip/irq-xilinx-smmu-csr.c new file +216 -0

216 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v2 2/2] irqchip: Add Xilinx Versal NET SMMU CSR interrupt controller driver

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] irqchip: unrecoverable interrupt storm due to unhandled CMDQ_SYNC - [Medium] irqchip: spurious…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] irqchip: unrecoverable interrupt storm due to unhandled CMDQ_SYNC
- [Medium] irqchip: spurious handling of disabled interrupts causes log spam --

commit bfa978fa90b50ee4257046a8002784c0f7fc45f7
Author: Anirudha Sarangi <[email protected]>

irqchip: Add Xilinx Versal NET SMMU CSR interrupt controller driver

The Xilinx Versal NET SoC implements a Control and Status Register (CSR) block in front of the ARM SMMUv3 to manage EVENTQ, PRIQ and GLOBAL interrupts. This commit adds an irqchip driver to demultiplex these interrupts and chain them to the upstream SMMUv3 driver.

Quoted 5 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +0 -0
new file mode 100644
index 0000000000000..d9b575c6c58b0

[ ... ]

drivers/irqchip/irq-xilinx-smmu-csr.c line 118

Quoted 12 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +12 -0
+static void xilinx_smmu_csr_irq_handler(struct irq_desc *desc)
+{
+	struct xilinx_smmu_csr *csr = irq_desc_get_handler_data(desc);
+	struct irq_chip *chip = irq_desc_get_chip(desc);
+	u32 status, pending;
+
+	chained_irq_enter(chip, desc);
+
+	status = readl(csr->base + SMMU_CSR_ISR);
+
+	/* Only service sources we support; SMMU_CSR_ISR latches raw status */
+	pending = status & SMMU_INTR_ALL;

[Severity: High]
If the CMDQ_SYNC interrupt (bit 1) was enabled or asserted by a previous boot stage like u-boot or kexec, it is filtered out of this pending mask. Because it is never cleared or acknowledged, will this cause an interrupt storm on the parent GIC line and a system hard lockup?

[Severity: Medium]
Additionally, since SMMU_CSR_ISR latches the raw status, does masking against SMMU_INTR_ALL instead of a shadow mask of actually enabled interrupts lead to processing disabled or unmapped events?

drivers/irqchip/irq-xilinx-smmu-csr.c line 127

Quoted 9 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +9 -0
+
+	while (pending) {
+		irq_hw_number_t hwirq = __ffs(pending);
+		int ret;
+
+		ret = generic_handle_domain_irq(csr->domain, hwirq);
+		if (ret)
+			pr_err_ratelimited("xilinx-smmu-csr: Failed to handle domain IRQ %lu: %d\n",
+					   hwirq, ret);

If an unmapped interrupt fires, generic_handle_domain_irq() will fail with -EINVAL and log this error. Because the driver cannot ACK an unmapped interrupt, the bit remains set in the ISR. Does this result in permanent ratelimited log spam and wasted CPU cycles on every subsequent valid interrupt?

Quoted 6 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +6 -0
+
+		pending &= ~BIT(hwirq);
+	}
+
+	chained_irq_exit(chip, desc);
+}

[ ... ]

Quoted 2 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +2 -0
+static int __init xilinx_smmu_csr_init(struct device_node *node, struct device_node *parent)
+{

[ ... ]

drivers/irqchip/irq-xilinx-smmu-csr.c line 181

Quoted 3 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +3 -0
+	/* Start from a known state: all sources disabled, latches cleared. */
+	writel(SMMU_INTR_ALL, csr->base + SMMU_CSR_IDR);
+	writel(SMMU_INTR_ALL, csr->base + SMMU_CSR_ISR);

[Severity: High]
SMMU_INTR_ALL omits bit 1 (CMDQ_SYNC). If a prior boot stage left CMDQ_SYNC enabled or pending, doesn't writing only SMMU_INTR_ALL fail to disable and clear it, setting up the interrupt storm described above?

Quoted 4 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +4 -0
+
+	csr->domain = irq_domain_create_linear(of_fwnode_handle(node), SMMU_CSR_IRQ_NR,
+					       &xilinx_smmu_csr_domain_ops,
+					       csr);

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#4 lore raw

Re: [PATCH v2 2/2] irqchip: Add Xilinx Versal NET SMMU CSR interrupt controller driver

Quoted 8 lines · On 9/18/2026 12:18 PM, [email protected] wrote:

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] irqchip: unrecoverable interrupt storm due to unhandled CMDQ_SYNC
- [Medium] irqchip: spurious handling of disabled interrupts causes log spam

Thanks Sashiko for the review,  all issues addressed in v3 and validated.

Quoted 27 lines

--

commit bfa978fa90b50ee4257046a8002784c0f7fc45f7
Author: Anirudha Sarangi <[email protected]>

irqchip: Add Xilinx Versal NET SMMU CSR interrupt controller driver

The Xilinx Versal NET SoC implements a Control and Status Register (CSR) block in front of the ARM SMMUv3 to manage EVENTQ, PRIQ and GLOBAL interrupts. This commit adds an irqchip driver to demultiplex these interrupts and chain them to the upstream SMMUv3 driver.

Quoted 5 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +0 -0
new file mode 100644
index 0000000000000..d9b575c6c58b0

[ ... ]

Quoted 9 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +9 -0
+static void xilinx_smmu_csr_irq_handler(struct irq_desc *desc)
+{
+     struct xilinx_smmu_csr *csr = irq_desc_get_handler_data(desc);
+     struct irq_chip *chip = irq_desc_get_chip(desc);
+     u32 status, pending;
+
+     chained_irq_enter(chip, desc);
+
+     status = readl(csr->base + SMMU_CSR_ISR);
Quoted 8 lines

drivers/irqchip/irq-xilinx-smmu-csr.c line 118

Quoted 3 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +3 -0
+
+     /* Only service sources we support; SMMU_CSR_ISR latches raw status */
+     pending = status & SMMU_INTR_ALL;

[Severity: High]
If the CMDQ_SYNC interrupt (bit 1) was enabled or asserted by a previous boot stage like u-boot or kexec, it is filtered out of this pending mask. Because it is never cleared or acknowledged, will this cause an interrupt storm on the parent GIC line and a system hard lockup?

Yes — fixed in v3. The handler now gates on the hardware mask register and defensively masks+clears any active source it doesn't demultiplex (e.g. CMDQ_SYNC), so it can't hold the GIC line asserted.

Quoted 4 lines

[Severity: Medium]
Additionally, since SMMU_CSR_ISR latches the raw status, does masking against SMMU_INTR_ALL instead of a shadow mask of actually enabled interrupts lead to processing disabled or unmapped events?

Fixed in v3 - dispatch is now gated on active = status & ~mask using the hardware mask register (SMMU_CSR_MASK), so masked/disabled-but-latched sources are never processed.

Quoted 6 lines
Quoted 6 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +6 -0
+
+     while (pending) {
+             irq_hw_number_t hwirq = __ffs(pending);
+             int ret;
+
+             ret = generic_handle_domain_irq(csr->domain, hwirq);
Quoted 8 lines

drivers/irqchip/irq-xilinx-smmu-csr.c line 127

Quoted 3 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +3 -0
+             if (ret)
+                     pr_err_ratelimited("xilinx-smmu-csr: Failed to handle domain IRQ %lu: %d\n",
+                                        hwirq, ret);

If an unmapped interrupt fires, generic_handle_domain_irq() will fail with -EINVAL and log this error. Because the driver cannot ACK an unmapped interrupt, the bit remains set in the ISR. Does this result in permanent ratelimited log spam and wasted CPU cycles on every subsequent valid interrupt?

Fixed in v3 -  On an error return the handler now masks+clears that source instead of logging, so the bit can't stay set

Quoted 10 lines
Quoted 6 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +6 -0
+
+             pending &= ~BIT(hwirq);
+     }
+
+     chained_irq_exit(chip, desc);
+}

[ ... ]

Quoted 2 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +2 -0
+static int __init xilinx_smmu_csr_init(struct device_node *node, struct device_node *parent)
+{

[ ... ]

Quoted 7 lines

drivers/irqchip/irq-xilinx-smmu-csr.c line 181

Quoted 3 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +3 -0
+     /* Start from a known state: all sources disabled, latches cleared. */
+     writel(SMMU_INTR_ALL, csr->base + SMMU_CSR_IDR);
+     writel(SMMU_INTR_ALL, csr->base + SMMU_CSR_ISR);

[Severity: High]
SMMU_INTR_ALL omits bit 1 (CMDQ_SYNC). If a prior boot stage left CMDQ_SYNC enabled or pending, doesn't writing only SMMU_INTR_ALL fail to disable and clear it, setting up the interrupt storm described above?

Correct — fixed in v3. Init now masks and clears every source the block implements (SMMU_INTR_HW_ALL = GENMASK(3,0)), including CMDQ_SYNC:

  writel(SMMU_INTR_HW_ALL, csr->base + SMMU_CSR_IDR); /* mask all  */ writel(SMMU_INTR_HW_ALL, csr->base + SMMU_CSR_ISR); /* clear all */

so an inherited enabled/pending CMDQ_SYNC is disabled and cleared before the parent line is enabled.

Quoted 8 lines

drivers/irqchip/irq-xilinx-smmu-csr.c line 185

Quoted 4 lines
drivers/irqchip/irq-xilinx-smmu-csr.c new file +4 -0
+
+     csr->domain = irq_domain_create_linear(of_fwnode_handle(node), SMMU_CSR_IRQ_NR,
+                                            &xilinx_smmu_csr_domain_ops,
+                                            csr);

[ ... ]

--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2

Thanks, Tushar Nimkar