Devicetree
 help / color / mirror / Atom feed
* [PATCH v7 0/3] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller
@ 2026-12-04 19:59 Fil Dunsky via B4 Relay
  2026-12-04 19:59 ` [PATCH v7 1/3] irqdomain: Pass temporary data to initialization callbacks Fil Dunsky via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-12-04 19:59 UTC (permalink / raw)
  To: Thomas Gleixner, Radu Rendec, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: linux-kernel, devicetree, linux-arm-kernel, Fil Dunsky

The timers, GPIO banks, I2C, MDIO, SPI and a few other low speed
peripherals of the Cortina Systems CS75xx ("Goldengate G2") SoCs share
one GIC interrupt. This series adds the binding and a chained driver for
the small controller in the peripheral register block that reports the
level of these 15 sources and masks them; each source is acknowledged in
its peripheral.

There is a second status/enable pair right behind it whose purpose I do
not know; it is not described.

The driver used to be part of a series with the GPIO, I2C and watchdog
drivers and the device tree changes. That series is now split per
subsystem. The driver depends on OF and HAS_IOMEM, with no dependency on
the platform series [1], which is under review separately. The device
tree nodes will follow with the other CS75xx dts changes once the
platform is merged.

There is no public documentation; the register layout comes from the GPL
vendor kernels and was checked on a Securifi Almond+ (CS7542), where the
GPIO and I2C interrupts of the board are delivered through this
controller. The v5 IRQ flags and normal initialization path were checked
in RAM with PROVE_LOCKING; MMIO cleanup on initialization failure was
reviewed but not fault-injected on the board.

[1] https://lore.kernel.org/all/20261122-b4-cs75xx-v9-0-1fc1b90bd097@gmail.com/

---
Changes in v7:
- Provide temporary irqdomain init_data cleared by the core before
  publication, as suggested by Thomas Gleixner.
- Initialize the generic chip in its own callback. Keep parent
  handler registration in the domain callback.
- Cross-compile the changed IRQ core and Cortina driver for ARM.
  Verify callback ordering and cleanup on a host fixture.
- On Securifi Almond+, 16 open/close cycles on the SX8650 input
  device serviced 160 I2C interrupts through hwirq 11. The count
  stayed constant in idle and the IRQ error count did not change.
- Link to v6: https://lore.kernel.org/r/20261201-cs75xx-intc-v6-0-bcd0a80afd62@gmail.com

Changes in v6:
- Instantiate the IRQ domain with its generic chip and parent handler
  initialized before the domain becomes visible (Thomas Gleixner).
- Use guard_chained_irq() and combine the two int declarations.
- Base the series on tip irq/drivers, which provides the chained IRQ guard.
- Cross-compile the corrected driver for ARM. Check the publication order,
  cleanup and dispatch with a host test using the driver source.
- Link to v5: https://patch.msgid.link/20261120-cs75xx-intc-v5-0-f2be75c5e97c@gmail.com

Changes in v5:
- replace the ARCH_CORTINA_ACCESS || COMPILE_TEST dependency and
  architecture default with OF, retaining HAS_IOMEM, so the driver can
  be merged without the platform series
- build built-in on ARM and x86-64 with COMPILE_TEST=n and without the
  platform series; check that OF and MMIO dependencies gate the option
- require HAS_IOMEM for COMPILE_TEST builds
- mark child interrupts as level-triggered and keep them non-probeable
- release the reserved MMIO region on initialization failure
- Link to v4: https://patch.msgid.link/20261117-cs75xx-intc-v4-0-0a678f35e5f3@gmail.com

Changes in v4:
- rebase on v7.4-rc1; update the platform reference to v7
- split out of "Cortina Systems CS75xx: interrupt controller, GPIO, I2C
  and TWD watchdog" so that each driver can go through its own tree; no
  longer based on the platform series
- declare the variables of the chained handler from the longest to the
  shortest line
- do not wrap lines that fit in 100 columns (Thomas)
- collect Reviewed-by tags
- Link to v3: https://patch.msgid.link/20261013-b4-cs75xx-s2-v3-0-181bb0d23f4c@gmail.com

Changes in v3:
- rebase on v6 of the platform series
- Link to v2: https://patch.msgid.link/20261013-b4-cs75xx-s2-v2-0-94f8c0a90cda@gmail.com

Changes in v2:
- rebase on v5 of the platform series
- Link to v1: https://patch.msgid.link/20261012-b4-cs75xx-s2-v1-0-8a7641b7b79c@gmail.com

To: Thomas Gleixner <tglx@kernel.org>
To: Radu Rendec <radu@rendec.net>
To: Rob Herring <robh@kernel.org>
To: Krzysztof Kozlowski <krzk+dt@kernel.org>
To: Conor Dooley <conor+dt@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: devicetree@vger.kernel.org

---
Fil Dunsky (3):
      irqdomain: Pass temporary data to initialization callbacks
      dt-bindings: interrupt-controller: Add Cortina Systems CS7542 peripheral interrupt controller
      irqchip: Add Cortina Systems CS75xx peripheral interrupt controller

 .../interrupt-controller/cortina,cs7542-intc.yaml  |  57 +++++++++
 drivers/irqchip/Kconfig                            |  12 ++
 drivers/irqchip/Makefile                           |   1 +
 drivers/irqchip/irq-cs75xx.c                       | 133 +++++++++++++++++++++
 include/linux/irqdomain.h                          |   7 ++
 kernel/irq/irqdomain.c                             |   3 +
 6 files changed, 213 insertions(+)
---
base-commit: d4673c92ff7f50ef7de22c887f0909b837c2a34a
change-id: 20261015-cs75xx-intc-b422801c7a5d

Best regards,
-- 
Fil Dunsky <filipp.dunsky@gmail.com>



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

* [PATCH v7 1/3] irqdomain: Pass temporary data to initialization callbacks
  2026-12-04 19:59 [PATCH v7 0/3] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller Fil Dunsky via B4 Relay
@ 2026-12-04 19:59 ` Fil Dunsky via B4 Relay
  2026-12-04 19:59 ` [PATCH v7 2/3] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 peripheral interrupt controller Fil Dunsky via B4 Relay
  2026-12-04 19:59 ` [PATCH v7 3/3] irqchip: Add Cortina Systems CS75xx " Fil Dunsky via B4 Relay
  2 siblings, 0 replies; 5+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-12-04 19:59 UTC (permalink / raw)
  To: Thomas Gleixner, Radu Rendec, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: linux-kernel, devicetree, linux-arm-kernel, Fil Dunsky

From: Fil Dunsky <filipp.dunsky@gmail.com>

Interrupt controller drivers may need the same temporary setup data in
both their generic chip and domain initialization callbacks. Passing it
through host_data requires managing its lifetime outside the core and
risks exposing the transient pointer with a published domain.

Add init_data for the initialization callbacks and clear it before
the domain is published. Callbacks must not retain this pointer.

Suggested-by: Thomas Gleixner <tglx@kernel.org>
Link: https://lore.kernel.org/r/87zeuoogwp.ffs@fw13
Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
 include/linux/irqdomain.h | 7 +++++++
 kernel/irq/irqdomain.c    | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index d8caafcecc..2c5b9a2fe7 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -149,6 +149,9 @@ struct irq_domain_chip_generic;
  * @gc:		Pointer to a list of generic chips. There is a helper function for
  *		setting up one or more generic chips for interrupt controllers
  *		drivers using the generic chip library which uses this pointer.
+ * @init_data:	Temporary private data for the domain and generic chip init
+ *		callbacks. It may point to stack memory and is cleared before
+ *		the domain is published. Callbacks must not retain this pointer.
  * @dev:	Pointer to the device which instantiated the irqdomain
  *		With per device irq domains this is not necessarily the same
  *		as @pm_dev.
@@ -188,6 +191,7 @@ struct irq_domain {
 	const struct msi_parent_ops	*msi_parent_ops;
 #endif
 	void				(*exit)(struct irq_domain *d);
+	void				*init_data;
 
 	/* reverse map data. The linear map gets appended to the irq_domain */
 	irq_hw_number_t			hwirq_max;
@@ -325,6 +329,8 @@ struct irq_domain_chip_generic_info;
  *			domains are added using same fwnode
  * @ops:		Domain operation callbacks
  * @host_data:		Controller private data pointer
+ * @init_data:		Temporary data for the domain and generic chip init
+ *			callbacks. It may point to stack memory.
  * @dev:		Device which creates the domain
  * @dgc_info:		Geneneric chip information structure pointer used to
  *			create generic chips for the domain if not NULL.
@@ -345,6 +351,7 @@ struct irq_domain_info {
 	const char				*name_suffix;
 	const struct irq_domain_ops		*ops;
 	void					*host_data;
+	void					*init_data;
 	struct device				*dev;
 #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
 	/**
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 4fdcb6df53..daa7894c05 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -332,6 +332,7 @@ static struct irq_domain *__irq_domain_instantiate(const struct irq_domain_info
 	domain->flags |= info->domain_flags;
 	domain->exit = info->exit;
 	domain->dev = info->dev;
+	domain->init_data = info->init_data;
 
 #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
 	if (info->parent) {
@@ -353,6 +354,8 @@ static struct irq_domain *__irq_domain_instantiate(const struct irq_domain_info
 			goto err_domain_gc_remove;
 	}
 
+	/* The temporary data may live on the caller's stack. */
+	domain->init_data = NULL;
 	__irq_domain_publish(domain);
 
 	if (cond_alloc_descs && info->virq_base > 0)

-- 
2.53.0



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

* [PATCH v7 2/3] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 peripheral interrupt controller
  2026-12-04 19:59 [PATCH v7 0/3] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller Fil Dunsky via B4 Relay
  2026-12-04 19:59 ` [PATCH v7 1/3] irqdomain: Pass temporary data to initialization callbacks Fil Dunsky via B4 Relay
@ 2026-12-04 19:59 ` Fil Dunsky via B4 Relay
  2026-12-04 19:59 ` [PATCH v7 3/3] irqchip: Add Cortina Systems CS75xx " Fil Dunsky via B4 Relay
  2 siblings, 0 replies; 5+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-12-04 19:59 UTC (permalink / raw)
  To: Thomas Gleixner, Radu Rendec, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: linux-kernel, devicetree, linux-arm-kernel, Fil Dunsky

From: Fil Dunsky <filipp.dunsky@gmail.com>

The low speed peripherals of the Cortina Systems CS75xx SoCs share one
GIC interrupt. A small controller in the peripheral register block
reports which of its 15 sources are asserted and allows masking them.

Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
 .../interrupt-controller/cortina,cs7542-intc.yaml  | 57 ++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/Documentation/devicetree/bindings/interrupt-controller/cortina,cs7542-intc.yaml b/Documentation/devicetree/bindings/interrupt-controller/cortina,cs7542-intc.yaml
new file mode 100644
index 0000000000..2963acaf7d
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/cortina,cs7542-intc.yaml
@@ -0,0 +1,57 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/cortina,cs7542-intc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cortina Systems CS7542 peripheral interrupt controller
+
+maintainers:
+  - Fil Dunsky <filipp.dunsky@gmail.com>
+
+description:
+  The low speed peripherals of the Cortina Systems CS75xx (Goldengate G2)
+  SoCs (two software interrupts, two timers, the AXI bridge, SPI, the five
+  GPIO banks, I2C, MDIO, SSP and the random number generator) share one GIC
+  interrupt. This controller has a status register showing the level of the
+  15 sources and an enable register to mask them. The sources are cleared in
+  the peripherals themselves.
+
+properties:
+  compatible:
+    const: cortina,cs7542-intc
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 1
+    description:
+      The number of the source, 0 to 14. All sources are active high level
+      interrupts.
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - "#interrupt-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    interrupt-controller@f0070004 {
+        compatible = "cortina,cs7542-intc";
+        reg = <0xf0070004 0x8>;
+        interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
+        interrupt-controller;
+        #interrupt-cells = <1>;
+    };

-- 
2.53.0



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

* [PATCH v7 3/3] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller
  2026-12-04 19:59 [PATCH v7 0/3] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller Fil Dunsky via B4 Relay
  2026-12-04 19:59 ` [PATCH v7 1/3] irqdomain: Pass temporary data to initialization callbacks Fil Dunsky via B4 Relay
  2026-12-04 19:59 ` [PATCH v7 2/3] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 peripheral interrupt controller Fil Dunsky via B4 Relay
@ 2026-12-04 19:59 ` Fil Dunsky via B4 Relay
  2026-12-04 20:14   ` sashiko-bot
  2 siblings, 1 reply; 5+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-12-04 19:59 UTC (permalink / raw)
  To: Thomas Gleixner, Radu Rendec, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: linux-kernel, devicetree, linux-arm-kernel, Fil Dunsky

From: Fil Dunsky <filipp.dunsky@gmail.com>

The timers, GPIO banks, I2C, MDIO, SPI and a few other low speed
peripherals of the Cortina Systems CS75xx SoCs share a single GIC
interrupt. A status register shows the level of the 15 sources and an
enable register masks them; there is nothing to acknowledge, each source
is cleared in its peripheral.

Add a chained driver using a generic chip on a linear domain.
The driver depends on OF and HAS_IOMEM and can be enabled independently
of the CS75xx platform support.

Use irq_domain_instantiate() to allocate and initialize the generic chip
and install the parent handler before the IRQ domain is published.
A consumer can then only map an IRQ once the chip and handler are ready.
Use guard_chained_irq() to pair chained entry and exit.

Link: https://lore.kernel.org/all/87mrqpov7z.ffs@fw13/

Pass the transient register base and parent IRQ through init_data.
Configure the generic chip in its own init callback and install the
parent handler in the domain init callback before publication.

Link: https://lore.kernel.org/r/87zeuoogwp.ffs@fw13
Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
 drivers/irqchip/Kconfig      |  12 ++++
 drivers/irqchip/Makefile     |   1 +
 drivers/irqchip/irq-cs75xx.c | 133 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 146 insertions(+)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index aafd2e625f..afe426e628 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -187,6 +187,18 @@ config BRCMSTB_L2_IRQ
 	select GENERIC_IRQ_CHIP
 	select IRQ_DOMAIN
 
+config CS75XX_INTC
+	bool "Cortina Systems CS75xx peripheral interrupt controller"
+	depends on OF
+	depends on HAS_IOMEM
+	select GENERIC_IRQ_CHIP
+	select IRQ_DOMAIN
+	help
+	  Support for the interrupt controller of the Cortina Systems
+	  CS75xx SoCs that combines the interrupts of the low speed
+	  peripherals (timers, GPIO banks, I2C, MDIO, SPI) into a single
+	  GIC interrupt. Say Y if you have a board with such an SoC.
+
 config DAVINCI_CP_INTC
 	bool
 	select GENERIC_IRQ_CHIP
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index eb539d4125..b37a55d7f7 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -136,3 +136,4 @@ 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
+obj-$(CONFIG_CS75XX_INTC)		+= irq-cs75xx.o
diff --git a/drivers/irqchip/irq-cs75xx.c b/drivers/irqchip/irq-cs75xx.c
new file mode 100644
index 0000000000..10fd2fafad
--- /dev/null
+++ b/drivers/irqchip/irq-cs75xx.c
@@ -0,0 +1,133 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Cortina Systems CS75xx peripheral interrupt controller
+ *
+ * The low speed peripherals on the register bus (timers, GPIO banks, I2C,
+ * MDIO, SPI, ...) share a single GIC interrupt. A status register shows
+ * the level of the 15 sources and an enable register masks them; there is
+ * nothing to acknowledge, the sources are cleared in the peripherals.
+ */
+
+#include <linux/bitops.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/irq.h>
+#include <linux/irqchip.h>
+#include <linux/irqchip/chained_irq.h>
+#include <linux/irqdomain.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+
+#define CS75XX_INTC_STATUS	0x00
+#define CS75XX_INTC_ENABLE	0x04
+
+#define CS75XX_INTC_NR_IRQS	15
+
+static void cs75xx_intc_handler(struct irq_desc *desc)
+{
+	struct irq_domain *domain = irq_desc_get_handler_data(desc);
+	struct irq_chip *chip = irq_desc_get_chip(desc);
+	struct irq_chip_generic *gc;
+	unsigned long pending;
+	unsigned int hwirq;
+
+	gc = irq_get_domain_generic_chip(domain, 0);
+	guard_chained_irq(chip, desc);
+
+	pending = readl(gc->reg_base + CS75XX_INTC_STATUS) & gc->mask_cache;
+	for_each_set_bit(hwirq, &pending, CS75XX_INTC_NR_IRQS)
+		generic_handle_domain_irq(domain, hwirq);
+}
+
+struct cs75xx_intc_setup {
+	void __iomem *base;
+	unsigned int parent_irq;
+};
+
+static int __init cs75xx_intc_chip_init(struct irq_chip_generic *gc)
+{
+	const struct cs75xx_intc_setup *setup = gc->domain->init_data;
+
+	gc->reg_base = setup->base;
+	gc->chip_types[0].regs.mask = CS75XX_INTC_ENABLE;
+	gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit;
+	gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit;
+
+	return 0;
+}
+
+static int __init cs75xx_intc_domain_init(struct irq_domain *domain)
+{
+	const struct cs75xx_intc_setup *setup = domain->init_data;
+
+	irq_set_chained_handler_and_data(setup->parent_irq, cs75xx_intc_handler, domain);
+	return 0;
+}
+
+static int __init cs75xx_intc_init(struct device_node *np, struct device_node *parent)
+{
+	struct cs75xx_intc_setup setup;
+	struct irq_domain_chip_generic_info gc_info = {
+		.name			= "cs75xx-intc",
+		.handler		= handle_level_irq,
+		.irqs_per_chip		= CS75XX_INTC_NR_IRQS,
+		.num_ct			= 1,
+		.irq_flags_to_clear	= IRQ_NOREQUEST,
+		.irq_flags_to_set	= IRQ_LEVEL | IRQ_NOPROBE,
+		.gc_flags		= IRQ_GC_INIT_MASK_CACHE,
+		.init		= cs75xx_intc_chip_init,
+	};
+	struct irq_domain_info info = {
+		.fwnode		= of_fwnode_handle(np),
+		.size		= CS75XX_INTC_NR_IRQS,
+		.hwirq_max	= CS75XX_INTC_NR_IRQS,
+		.ops		= &irq_generic_chip_ops,
+		.dgc_info	= &gc_info,
+		.init		= cs75xx_intc_domain_init,
+		.init_data	= &setup,
+	};
+	struct irq_domain *domain;
+	struct resource res;
+	void __iomem *base;
+	int ret, parent_irq;
+
+	ret = of_address_to_resource(np, 0, &res);
+	if (ret)
+		return ret;
+
+	base = of_io_request_and_map(np, 0, of_node_full_name(np));
+	if (IS_ERR(base)) {
+		pr_err("%pOF: unable to map registers\n", np);
+		return PTR_ERR(base);
+	}
+
+	/* Mask everything before the chained handler is installed */
+	writel(0, base + CS75XX_INTC_ENABLE);
+
+	parent_irq = irq_of_parse_and_map(np, 0);
+	if (!parent_irq) {
+		pr_err("%pOF: unable to map parent interrupt\n", np);
+		ret = -EINVAL;
+		goto err_unmap;
+	}
+
+	setup.base = base;
+	setup.parent_irq = parent_irq;
+	domain = irq_domain_instantiate(&info);
+	if (IS_ERR(domain)) {
+		ret = PTR_ERR(domain);
+		goto err_dispose;
+	}
+
+	return 0;
+
+err_dispose:
+	irq_dispose_mapping(parent_irq);
+err_unmap:
+	iounmap(base);
+	release_mem_region(res.start, resource_size(&res));
+	return ret;
+}
+
+IRQCHIP_DECLARE(cs7542_intc, "cortina,cs7542-intc", cs75xx_intc_init);

-- 
2.53.0



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

* Re: [PATCH v7 3/3] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller
  2026-12-04 19:59 ` [PATCH v7 3/3] irqchip: Add Cortina Systems CS75xx " Fil Dunsky via B4 Relay
@ 2026-12-04 20:14   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-04 20:14 UTC (permalink / raw)
  To: Fil Dunsky; +Cc: devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] irqchip/cs75xx: unlocked read of gc->mask_cache in
  cs75xx_intc_handler()
- [Low] irqchip: stray Link trailer and duplicated paragraph in commit
  message
--

commit dc49f44370a5b75de4ec7c5408183cbf6b8fb780
Author: Fil Dunsky <filipp.dunsky@gmail.com>

> irqchip: Add Cortina Systems CS75xx peripheral interrupt controller
>
> The timers, GPIO banks, I2C, MDIO, SPI and a few other low speed
> peripherals of the Cortina Systems CS75xx SoCs share a single GIC
> interrupt. A status register shows the level of the 15 sources and an
> enable register masks them; there is nothing to acknowledge, each source
> is cleared in its peripheral.
>
> Add a chained driver using a generic chip on a linear domain.
> The driver depends on OF and HAS_IOMEM and can be enabled independently
> of the CS75xx platform support.
>
> Use irq_domain_instantiate() to allocate and initialize the generic chip
> and install the parent handler before the IRQ domain is published.
> A consumer can then only map an IRQ once the chip and handler are ready.
> Use guard_chained_irq() to pair chained entry and exit.
>
> Link: https://lore.kernel.org/all/87mrqpov7z.ffs@fw13/
>
> Pass the transient register base and parent IRQ through init_data.
> Configure the generic chip in its own init callback and install the
> parent handler in the domain init callback before publication.
>
> Link: https://lore.kernel.org/r/87zeuoogwp.ffs@fw13
> Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>

[Severity: Low]
There is a Link: trailer in the middle of the commit message, followed by a
paragraph repeating the generic chip and parent handler init description.
Should those two paragraphs be merged and both Link: trailers grouped
together before Signed-off-by?

[ ... ]

> diff --git a/drivers/irqchip/irq-cs75xx.c b/drivers/irqchip/irq-cs75xx.c
> new file mode 100644
> index 0000000000000..10fd2fafad7fb
> --- /dev/null
> +++ b/drivers/irqchip/irq-cs75xx.c
> @@ -0,0 +1,133 @@

[ ... ]

> +static void cs75xx_intc_handler(struct irq_desc *desc)
> +{
> +	struct irq_domain *domain = irq_desc_get_handler_data(desc);
> +	struct irq_chip *chip = irq_desc_get_chip(desc);
> +	struct irq_chip_generic *gc;
> +	unsigned long pending;
> +	unsigned int hwirq;
> +
> +	gc = irq_get_domain_generic_chip(domain, 0);
> +	guard_chained_irq(chip, desc);
> +
> +	pending = readl(gc->reg_base + CS75XX_INTC_STATUS) & gc->mask_cache;
> +	for_each_set_bit(hwirq, &pending, CS75XX_INTC_NR_IRQS)
> +		generic_handle_domain_irq(domain, hwirq);
> +}

[Severity: Medium]
Can this unlocked read of gc->mask_cache race with concurrent mask/unmask
updates on another CPU and dispatch spurious child interrupts?

irq_gc_mask_set_bit() and irq_gc_mask_clr_bit() update gc->mask_cache under
gc->lock, while cs75xx_intc_handler() reads it unlocked.  Along with the
data race, unsynchronized reads of CS75XX_INTC_STATUS and gc->mask_cache
allow a split snapshot when another CPU unmasks an IRQF_ONESHOT child IRQ:

CPU0                              CPU1
cs75xx_intc_handler()             <threaded handler for IRQ B>
  readl(CS75XX_INTC_STATUS)
    /* bit A and bit B set */
                                    /* clears peripheral B */
                                  irq_finalize_oneshot()
                                    unmask_threaded_irq()
                                      irq_gc_mask_set_bit()
                                        gc->mask_cache |= BIT(B)
                                    unlock(&desc_B->lock)
  & gc->mask_cache  <-- data race, sees bit B set
  generic_handle_domain_irq(..., B)
    handle_level_irq(desc_B)
      handle_irq_event(desc_B)  <-- spurious IRQ

Because desc_B is already unmasked and desc_B->lock has been released by the
time handle_level_irq() runs, irq_can_handle() returns true and invokes the
handler for an already-cleared interrupt.

Wrapping the status and mask_cache read in scoped_guard(raw_spinlock,
&gc->lock) before the dispatch loop avoids both the data race and the split
snapshot.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-cs75xx-intc-v7-0-c5e6e23a1a8c@gmail.com?part=3

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

end of thread, other threads:[~2026-12-04 20:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 19:59 [PATCH v7 0/3] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller Fil Dunsky via B4 Relay
2026-12-04 19:59 ` [PATCH v7 1/3] irqdomain: Pass temporary data to initialization callbacks Fil Dunsky via B4 Relay
2026-12-04 19:59 ` [PATCH v7 2/3] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 peripheral interrupt controller Fil Dunsky via B4 Relay
2026-12-04 19:59 ` [PATCH v7 3/3] irqchip: Add Cortina Systems CS75xx " Fil Dunsky via B4 Relay
2026-12-04 20:14   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox