* [PATCH 0/2] Add support for Microchip PIC64-HPSC/HX NVM interrupt controller
@ 2026-12-01 16:06 Charles Perry
2026-12-01 16:06 ` [PATCH 1/2] dt-bindings: interrupt-controller: document Microchip PIC64-HPSC/HX NVM intc Charles Perry
2026-12-01 16:06 ` [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller Charles Perry
0 siblings, 2 replies; 6+ messages in thread
From: Charles Perry @ 2026-12-01 16:06 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: Romain Caritey, linux-kernel, devicetree, Charles Perry
Hello,
This series add support for a small wired interrupt controller present in
PIC64-HPSC/HX SoCs [1]
Microchip PIC64-HPSC has 4 NVM subsystems. Each one has a NAND, an xSPI
and a pflash controller. PIC64-HX has 2 NVM subsystems with the same
controllers, plus an eMMC/SD controller.
On both SoCs, the interrupts from the NAND, xSPI and eMMC/SD controllers
in a subsystem do not go straight to the APLIC. They go through a small
interrupt controller local to that NVM subsystem, which then signals the
APLIC.
All source interrupts in a subsystem share a single APLIC line, so their
affinity cannot be set individually. The driver therefore registers a
regular IRQ handler rather than a chained handler. This lets userspace set
the affinity of the parent NVM interrupt, which then applies to all the
sources behind it.
[1]: https://www.microchip.com/en-us/products/microprocessors/64-bit-mpus
Signed-off-by: Charles Perry <charles.perry@microchip.com>
---
Charles Perry (1):
dt-bindings: interrupt-controller: document Microchip PIC64-HPSC/HX NVM intc
Romain Caritey (1):
irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller
.../microchip,pic64hpsc-nvm-intc.yaml | 59 ++++++
MAINTAINERS | 2 +
drivers/irqchip/Kconfig | 8 +
drivers/irqchip/Makefile | 1 +
drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c | 226 +++++++++++++++++++++
5 files changed, 296 insertions(+)
---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
change-id: 20261127-linux-7-4-rc4-pic64hpsc-nvm-intc-2fb4f2ab7673
Best regards,
--
Thanks,
Charles
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2] dt-bindings: interrupt-controller: document Microchip PIC64-HPSC/HX NVM intc 2026-12-01 16:06 [PATCH 0/2] Add support for Microchip PIC64-HPSC/HX NVM interrupt controller Charles Perry @ 2026-12-01 16:06 ` Charles Perry 2026-12-01 18:13 ` Conor Dooley 2026-12-01 16:06 ` [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller Charles Perry 1 sibling, 1 reply; 6+ messages in thread From: Charles Perry @ 2026-12-01 16:06 UTC (permalink / raw) To: Thomas Gleixner, Radu Rendec, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: Romain Caritey, linux-kernel, devicetree, Charles Perry Microchip PIC64-HPSC features 4 NVM subsystems, each composed of a NAND, xSPI and pflash controller. PIC64-HX features 2 NVM subsystems, each composed of the same controllers as for PIC64-HPSC, with the addition of an eMMC/SD controller. For each of these SoCs, the interrupts of each of the NAND, xSPI and eMMC/SD controllers go through a local NVM interrupt controller which then connects to the APLIC. Document PIC64-HPSC/HX NVM interrupt controller. Signed-off-by: Charles Perry <charles.perry@microchip.com> --- .../microchip,pic64hpsc-nvm-intc.yaml | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Documentation/devicetree/bindings/interrupt-controller/microchip,pic64hpsc-nvm-intc.yaml b/Documentation/devicetree/bindings/interrupt-controller/microchip,pic64hpsc-nvm-intc.yaml new file mode 100644 index 000000000000..3c5241a6724f --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/microchip,pic64hpsc-nvm-intc.yaml @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/microchip,pic64hpsc-nvm-intc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip PIC64-HPSC/HX NVM interrupt controller + +maintainers: + - Charles Perry <charles.perry@microchip.com> + +description: + The PIC64-HPSC/HX NVM interrupt controller is an on-chip controller that + aggregates interrupts from the xSPI, NAND and eMMC/SD controllers. + +properties: + compatible: + oneOf: + - const: microchip,pic64hpsc-nvm-intc + - items: + - const: microchip,pic64hx-nvm-intc + - const: microchip,pic64hpsc-nvm-intc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + interrupt-controller: true + + "#interrupt-cells": + const: 1 + +required: + - compatible + - reg + - interrupts + - interrupt-controller + - "#interrupt-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + bus { + #address-cells = <2>; + #size-cells = <2>; + + nvm_intc: interrupt-controller@4001c020000 { + compatible = "microchip,pic64hpsc-nvm-intc"; + reg = <0x400 0x1c020000 0x0 0x518>; + interrupts = <80 IRQ_TYPE_LEVEL_HIGH>; + interrupt-controller; + #interrupt-cells = <1>; + }; + }; -- 2.53.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: interrupt-controller: document Microchip PIC64-HPSC/HX NVM intc 2026-12-01 16:06 ` [PATCH 1/2] dt-bindings: interrupt-controller: document Microchip PIC64-HPSC/HX NVM intc Charles Perry @ 2026-12-01 18:13 ` Conor Dooley 0 siblings, 0 replies; 6+ messages in thread From: Conor Dooley @ 2026-12-01 18:13 UTC (permalink / raw) To: Charles Perry Cc: Thomas Gleixner, Radu Rendec, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Romain Caritey, linux-kernel, devicetree [-- Attachment #1: Type: text/plain, Size: 2863 bytes --] On Tue, Dec 01, 2026 at 11:06:26AM -0500, Charles Perry wrote: > Microchip PIC64-HPSC features 4 NVM subsystems, each composed of a NAND, > xSPI and pflash controller. PIC64-HX features 2 NVM subsystems, each > composed of the same controllers as for PIC64-HPSC, with the addition of an > eMMC/SD controller. > > For each of these SoCs, the interrupts of each of the NAND, xSPI and > eMMC/SD controllers go through a local NVM interrupt controller which then > connects to the APLIC. > > Document PIC64-HPSC/HX NVM interrupt controller. > > Signed-off-by: Charles Perry <charles.perry@microchip.com> > --- > .../microchip,pic64hpsc-nvm-intc.yaml | 59 ++++++++++++++++++++++ > 1 file changed, 59 insertions(+) > > diff --git a/Documentation/devicetree/bindings/interrupt-controller/microchip,pic64hpsc-nvm-intc.yaml b/Documentation/devicetree/bindings/interrupt-controller/microchip,pic64hpsc-nvm-intc.yaml > new file mode 100644 > index 000000000000..3c5241a6724f > --- /dev/null > +++ b/Documentation/devicetree/bindings/interrupt-controller/microchip,pic64hpsc-nvm-intc.yaml > @@ -0,0 +1,59 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/interrupt-controller/microchip,pic64hpsc-nvm-intc.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Microchip PIC64-HPSC/HX NVM interrupt controller > + > +maintainers: > + - Charles Perry <charles.perry@microchip.com> > + > +description: > + The PIC64-HPSC/HX NVM interrupt controller is an on-chip controller that > + aggregates interrupts from the xSPI, NAND and eMMC/SD controllers. > + > +properties: > + compatible: > + oneOf: > + - const: microchip,pic64hpsc-nvm-intc > + - items: > + - const: microchip,pic64hx-nvm-intc > + - const: microchip,pic64hpsc-nvm-intc > + > + reg: > + maxItems: 1 > + > + interrupts: > + maxItems: 1 > + > + interrupt-controller: true > + > + "#interrupt-cells": > + const: 1 > + > +required: > + - compatible > + - reg > + - interrupts > + - interrupt-controller > + - "#interrupt-cells" Is this block actually unclocked? Otherwise, it seems fine to me. Cheers, Conor. > + > +additionalProperties: false > + > +examples: > + - | > + #include <dt-bindings/interrupt-controller/irq.h> > + > + bus { > + #address-cells = <2>; > + #size-cells = <2>; > + > + nvm_intc: interrupt-controller@4001c020000 { > + compatible = "microchip,pic64hpsc-nvm-intc"; > + reg = <0x400 0x1c020000 0x0 0x518>; > + interrupts = <80 IRQ_TYPE_LEVEL_HIGH>; > + interrupt-controller; > + #interrupt-cells = <1>; > + }; > + }; > > -- > 2.53.0 > > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller 2026-12-01 16:06 [PATCH 0/2] Add support for Microchip PIC64-HPSC/HX NVM interrupt controller Charles Perry 2026-12-01 16:06 ` [PATCH 1/2] dt-bindings: interrupt-controller: document Microchip PIC64-HPSC/HX NVM intc Charles Perry @ 2026-12-01 16:06 ` Charles Perry 2026-12-01 16:21 ` sashiko-bot 2026-12-01 19:31 ` Thomas Gleixner 1 sibling, 2 replies; 6+ messages in thread From: Charles Perry @ 2026-12-01 16:06 UTC (permalink / raw) To: Thomas Gleixner, Radu Rendec, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: Romain Caritey, linux-kernel, devicetree, Charles Perry From: Romain Caritey <romain.caritey@microchip.com> Microchip PIC64-HPSC features 4 NVM subsystems, each composed of a NAND, xSPI and pflash controller. PIC64-HX features 2 NVM subsystems, each composed of the same controllers as for PIC64-HPSC, with the addition of an eMMC/SD controller. For each of these SoCs, the interrupts of each of the NAND, xSPI and eMMC/SD controllers go through a local NVM interrupt controller which then connects to the APLIC. All source interrupts in a subsystem share a single APLIC line, so their affinity cannot be set individually. The driver therefore registers a regular IRQ handler rather than a chained handler. This lets userspace set the affinity of the parent NVM interrupt, which then applies to all the sources behind it. Signed-off-by: Romain Caritey <romain.caritey@microchip.com> Signed-off-by: Charles Perry <charles.perry@microchip.com> --- MAINTAINERS | 2 + drivers/irqchip/Kconfig | 8 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c | 226 ++++++++++++++++++++++++++ 4 files changed, 237 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 44540a1eb2b8..ecd8ba4f83c2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18432,7 +18432,9 @@ F: drivers/tty/serial/8250/8250_pci1xxxx.c MICROCHIP PIC64-HPSC/HX DRIVERS M: Charles Perry <charles.perry@microchip.com> S: Supported +F: Documentation/devicetree/bindings/interrupt-controller/microchip,pic64hpsc-nvm-intc.yaml F: Documentation/devicetree/bindings/net/microchip,pic64hpsc-mdio.yaml +F: drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c F: drivers/net/mdio/mdio-pic64hpsc.c MICROCHIP POLARFIRE FPGA DRIVERS diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 136bab41f801..f72a3648f585 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -821,6 +821,14 @@ config MCHP_EIC help Support for Microchip External Interrupt Controller. +config PIC64HPSC_NVM_INTC + bool "Microchip PIC64-HPSC/HX NVM interrupt controller" + depends on OF + depends on ARCH_MICROCHIP || COMPILE_TEST + select IRQ_DOMAIN + help + Support for Microchip PIC64-HPSC/HX NVM interrupt controller. + config SOPHGO_SG2042_MSI bool "Sophgo SG2042 MSI Controller" depends on ARCH_SOPHGO || COMPILE_TEST diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 16a5fd126c9a..26b13b1075e3 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -133,6 +133,7 @@ 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_MCHP_EIC) += irq-mchp-eic.o +obj-$(CONFIG_PIC64HPSC_NVM_INTC) += irq-mchp-pic64hpsc-nvm-intc.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 diff --git a/drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c b/drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c new file mode 100644 index 000000000000..84e4cfdbc5e7 --- /dev/null +++ b/drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c @@ -0,0 +1,226 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Microchip PIC64-HPSC/HX NVM interrupt controller. + * + * Copyright (C) 2026 Microchip Technology Inc. All rights reserved. + * Author: Romain Caritey <romain.caritey@microchip.com> + */ + +#include <linux/bitops.h> +#include <linux/device.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/irqdomain.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/seq_file.h> +#include <linux/spinlock.h> + +#define P64H_NVM_INTC_STATUS 0x500 +#define P64H_NVM_INTC_ENABLE 0x504 +#define P64H_NVM_INTC_VALUE 0x508 + +#define P64H_NVM_INTC_NUM_IRQS 7 +#define P64H_NVM_INTC_VALID_MASK GENMASK(P64H_NVM_INTC_NUM_IRQS - 1, 0) + +struct p64h_nvm_intc { + struct device *dev; + void __iomem *base; + struct irq_domain *domain; + raw_spinlock_t lock; +}; + +static inline bool p64h_nvm_intc_hwirq_is_valid(irq_hw_number_t hwirq) +{ + return hwirq < P64H_NVM_INTC_NUM_IRQS; +} + +static void p64h_nvm_intc_update_enable(struct p64h_nvm_intc *intc, u32 clear, + u32 set) +{ + unsigned long flags; + u32 enable; + + raw_spin_lock_irqsave(&intc->lock, flags); + enable = readl(intc->base + P64H_NVM_INTC_ENABLE); + enable &= ~clear; + enable |= set; + writel(enable, intc->base + P64H_NVM_INTC_ENABLE); + + raw_spin_unlock_irqrestore(&intc->lock, flags); +} + +static void p64h_nvm_intc_irq_ack(struct irq_data *d) +{ + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); + + writel(BIT(d->hwirq), intc->base + P64H_NVM_INTC_STATUS); +} + +static void p64h_nvm_intc_irq_mask(struct irq_data *d) +{ + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); + + p64h_nvm_intc_update_enable(intc, BIT(d->hwirq), 0); +} + +static void p64h_nvm_intc_irq_unmask(struct irq_data *d) +{ + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); + + p64h_nvm_intc_update_enable(intc, 0, BIT(d->hwirq)); +} + +static int p64h_nvm_intc_irq_set_type(struct irq_data *d, unsigned int type) +{ + if ((type & IRQ_TYPE_SENSE_MASK) != IRQ_TYPE_LEVEL_HIGH) + return -EINVAL; + + return 0; +} + +static void p64h_nvm_intc_irq_print_chip(struct irq_data *d, struct seq_file *p) +{ + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); + + seq_printf(p, "nvm-intc-%s", dev_name(intc->dev)); +} + +static const struct irq_chip p64h_nvm_intc_irq_chip = { + .irq_print_chip = p64h_nvm_intc_irq_print_chip, + .irq_ack = p64h_nvm_intc_irq_ack, + .irq_disable = p64h_nvm_intc_irq_mask, + .irq_mask = p64h_nvm_intc_irq_mask, + .irq_unmask = p64h_nvm_intc_irq_unmask, + .irq_set_type = p64h_nvm_intc_irq_set_type, +}; + +static int p64h_nvm_intc_domain_map(struct irq_domain *domain, + unsigned int virq, irq_hw_number_t hwirq) +{ + if (!p64h_nvm_intc_hwirq_is_valid(hwirq)) + return -EINVAL; + + irq_set_chip_data(virq, domain->host_data); + irq_set_chip_and_handler(virq, &p64h_nvm_intc_irq_chip, + handle_level_irq); + irq_set_noprobe(virq); + + return 0; +} + +static void p64h_nvm_intc_domain_unmap(struct irq_domain *domain, + unsigned int virq) +{ + irq_set_chip_and_handler(virq, NULL, NULL); + irq_set_chip_data(virq, NULL); +} + +static int p64h_nvm_intc_domain_xlate(struct irq_domain *domain, + struct device_node *controller, + const u32 *intspec, unsigned int intsize, + unsigned long *out_hwirq, + unsigned int *out_type) +{ + if (intsize != 1 || !p64h_nvm_intc_hwirq_is_valid(intspec[0])) + return -EINVAL; + + *out_hwirq = intspec[0]; + *out_type = IRQ_TYPE_LEVEL_HIGH; + + return 0; +} + +static const struct irq_domain_ops p64h_nvm_intc_domain_ops = { + .map = p64h_nvm_intc_domain_map, + .unmap = p64h_nvm_intc_domain_unmap, + .xlate = p64h_nvm_intc_domain_xlate, +}; + +static irqreturn_t p64h_nvm_intc_handler(int irq, void *data) +{ + struct p64h_nvm_intc *intc = data; + unsigned long pending; + unsigned int hwirq; + + pending = readl(intc->base + P64H_NVM_INTC_STATUS) & + readl(intc->base + P64H_NVM_INTC_ENABLE) & + P64H_NVM_INTC_VALID_MASK; + + if (!pending) + return IRQ_NONE; + + /* + * STATUS may hold a stale edge, already handled while masked. + * Clear it, then dispatch only the sources whose line is still high. + */ + writel(pending, intc->base + P64H_NVM_INTC_STATUS); + + pending &= readl(intc->base + P64H_NVM_INTC_VALUE); + + for_each_set_bit(hwirq, &pending, P64H_NVM_INTC_NUM_IRQS) + generic_handle_domain_irq(intc->domain, hwirq); + + return IRQ_HANDLED; +} + +static int p64h_nvm_intc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct p64h_nvm_intc *intc; + int parent_irq; + int ret; + + intc = devm_kzalloc(dev, sizeof(*intc), GFP_KERNEL); + if (!intc) + return -ENOMEM; + + intc->dev = dev; + raw_spin_lock_init(&intc->lock); + + intc->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(intc->base)) + return PTR_ERR(intc->base); + + parent_irq = platform_get_irq(pdev, 0); + if (parent_irq < 0) + return parent_irq; + + writel(0, intc->base + P64H_NVM_INTC_ENABLE); + writel(P64H_NVM_INTC_VALID_MASK, intc->base + P64H_NVM_INTC_STATUS); + + intc->domain = irq_domain_create_linear(dev_fwnode(dev), + P64H_NVM_INTC_NUM_IRQS, + &p64h_nvm_intc_domain_ops, + intc); + if (!intc->domain) + return dev_err_probe(dev, -ENOMEM, + "failed to create IRQ domain\n"); + + ret = devm_request_irq(dev, parent_irq, p64h_nvm_intc_handler, + IRQF_NO_THREAD, dev_name(dev), intc); + if (ret) { + irq_domain_remove(intc->domain); + return dev_err_probe(dev, ret, "failed to request IRQ %d\n", + parent_irq); + } + + return 0; +} + +static const struct of_device_id p64h_nvm_intc_of_match[] = { + { .compatible = "microchip,pic64hpsc-nvm-intc" }, + {} +}; + +static struct platform_driver p64h_nvm_intc_driver = { + .probe = p64h_nvm_intc_probe, + .driver = { + .name = "pic64hpsc-nvm-intc", + .of_match_table = p64h_nvm_intc_of_match, + .suppress_bind_attrs = true, + }, +}; +builtin_platform_driver(p64h_nvm_intc_driver); -- 2.53.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller 2026-12-01 16:06 ` [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller Charles Perry @ 2026-12-01 16:21 ` sashiko-bot 2026-12-01 19:31 ` Thomas Gleixner 1 sibling, 0 replies; 6+ messages in thread From: sashiko-bot @ 2026-12-01 16:21 UTC (permalink / raw) To: Charles Perry; +Cc: devicetree, robh, conor+dt Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] irqchip: pic64hpsc-nvm-intc: premature STATUS clear loses level IRQs -- commit 73f24bc314fe5e84231bc25d702188d9731ab0ca Author: Romain Caritey <romain.caritey@microchip.com> irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller This commit adds an irqchip driver for the local NVM interrupt controller found on Microchip PIC64-HPSC and PIC64-HX SoCs. > diff --git a/drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c b/drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c > new file mode 100644 > index 0000000000000..84e4cfdbc5e7f > --- /dev/null > +++ b/drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c [ ... ] > +static void p64h_nvm_intc_irq_ack(struct irq_data *d) > +{ > + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); > + > + writel(BIT(d->hwirq), intc->base + P64H_NVM_INTC_STATUS); > +} > + > +static void p64h_nvm_intc_irq_mask(struct irq_data *d) > +{ > + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); > + > + p64h_nvm_intc_update_enable(intc, BIT(d->hwirq), 0); > +} > + > +static void p64h_nvm_intc_irq_unmask(struct irq_data *d) > +{ > + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); > + > + p64h_nvm_intc_update_enable(intc, 0, BIT(d->hwirq)); > +} [ ... ] > +static irqreturn_t p64h_nvm_intc_handler(int irq, void *data) > +{ > + struct p64h_nvm_intc *intc = data; > + unsigned long pending; > + unsigned int hwirq; > + > + pending = readl(intc->base + P64H_NVM_INTC_STATUS) & > + readl(intc->base + P64H_NVM_INTC_ENABLE) & > + P64H_NVM_INTC_VALID_MASK; > + > + if (!pending) > + return IRQ_NONE; > + > + /* > + * STATUS may hold a stale edge, already handled while masked. > + * Clear it, then dispatch only the sources whose line is still high. > + */ > + writel(pending, intc->base + P64H_NVM_INTC_STATUS); > + > + pending &= readl(intc->base + P64H_NVM_INTC_VALUE); > + > + for_each_set_bit(hwirq, &pending, P64H_NVM_INTC_NUM_IRQS) > + generic_handle_domain_irq(intc->domain, hwirq); > + > + return IRQ_HANDLED; > +} [Severity: High] Can clearing P64H_NVM_INTC_STATUS before the child device deasserts its level-high interrupt line permanently lose level interrupts? From the comment and handling in p64h_nvm_intc_handler(), P64H_NVM_INTC_VALUE reflects the live level of the child lines, whereas P64H_NVM_INTC_STATUS latches rising edges and gates the parent APLIC line together with P64H_NVM_INTC_ENABLE. However, P64H_NVM_INTC_STATUS is cleared in p64h_nvm_intc_handler() and again in p64h_nvm_intc_irq_ack() via handle_level_irq() -> mask_ack_irq() before the child handler services the device, while the child line in P64H_NVM_INTC_VALUE is still high. If the child line stays continuously high without dropping low and rising again (for example, when a controller has another pending event keeping its line asserted after handle_irq_event(), or when handle_level_irq() bails out at !irq_can_handle(desc) while the IRQ is disabled), P64H_NVM_INTC_STATUS remains 0 when p64h_nvm_intc_irq_unmask() re-enables the line, and the interrupt never fires again. Unconditionally clearing P64H_NVM_INTC_STATUS in p64h_nvm_intc_probe() has the same problem for any child line already asserted high at probe time. Conversely, if a transient edge latches into P64H_NVM_INTC_STATUS while the child IRQ is masked (such as during an IRQF_ONESHOT threaded handler) and is already cleared at the device before unmasking, p64h_nvm_intc_irq_unmask() leaves the stale bit set in P64H_NVM_INTC_STATUS, immediately triggering a spurious parent interrupt where pending &= readl(... + P64H_NVM_INTC_VALUE) is 0. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261201-linux-7-4-rc4-pic64hpsc-nvm-intc-v1-0-e87ed786dc1b@microchip.com?part=2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller 2026-12-01 16:06 ` [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller Charles Perry 2026-12-01 16:21 ` sashiko-bot @ 2026-12-01 19:31 ` Thomas Gleixner 1 sibling, 0 replies; 6+ messages in thread From: Thomas Gleixner @ 2026-12-01 19:31 UTC (permalink / raw) To: Charles Perry, Radu Rendec, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: Romain Caritey, linux-kernel, devicetree, Charles Perry On Tue, Dec 01 2026 at 11:06, Charles Perry wrote: > +struct p64h_nvm_intc { > + struct device *dev; > + void __iomem *base; > + struct irq_domain *domain; > + raw_spinlock_t lock; Tabular formatting please: https://docs.kernel.org/process/maintainer-tip.html > +}; > + > +static inline bool p64h_nvm_intc_hwirq_is_valid(irq_hw_number_t hwirq) > +{ > + return hwirq < P64H_NVM_INTC_NUM_IRQS; > +} > + > +static void p64h_nvm_intc_update_enable(struct p64h_nvm_intc *intc, u32 clear, > + u32 set) > +{ > + unsigned long flags; > + u32 enable; > + > + raw_spin_lock_irqsave(&intc->lock, flags); guard(raw_spinlock)(&intc->lock); irqsave is not required because this is invoked from mask/unmask() which are invoked by the core code with the interrupt descriptor lock held and interrupts disabled. > + enable = readl(intc->base + P64H_NVM_INTC_ENABLE); > + enable &= ~clear; > + enable |= set; As you hold the lock, you can cache the enabled state in @intc and spare the read back. > + writel(enable, intc->base + P64H_NVM_INTC_ENABLE); > + > + raw_spin_unlock_irqrestore(&intc->lock, flags); > +} > +static void p64h_nvm_intc_irq_print_chip(struct irq_data *d, struct seq_file *p) > +{ > + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); > + > + seq_printf(p, "nvm-intc-%s", dev_name(intc->dev)); What's the value of this print function? Why is a constant name for the interrupt chip not sufficient? > +} > + > +static const struct irq_chip p64h_nvm_intc_irq_chip = { > + .irq_print_chip = p64h_nvm_intc_irq_print_chip, > + .irq_ack = p64h_nvm_intc_irq_ack, > + .irq_disable = p64h_nvm_intc_irq_mask, Why do you need a disable callback, which just points at mask()? The core uses the mask() callback if there is no disable callback provided. > + .irq_mask = p64h_nvm_intc_irq_mask, > + .irq_unmask = p64h_nvm_intc_irq_unmask, > + .irq_set_type = p64h_nvm_intc_irq_set_type, Formatting > +}; > + > +static int p64h_nvm_intc_domain_map(struct irq_domain *domain, > + unsigned int virq, irq_hw_number_t hwirq) > +{ > + if (!p64h_nvm_intc_hwirq_is_valid(hwirq)) > + return -EINVAL; > + > + irq_set_chip_data(virq, domain->host_data); > + irq_set_chip_and_handler(virq, &p64h_nvm_intc_irq_chip, > + handle_level_irq); No line break required. You have 100 characters. (all over the place) > + irq_set_noprobe(virq); > + > + return 0; > +} > +static irqreturn_t p64h_nvm_intc_handler(int irq, void *data) > +{ > + struct p64h_nvm_intc *intc = data; > + unsigned long pending; > + unsigned int hwirq; > + > + pending = readl(intc->base + P64H_NVM_INTC_STATUS) & > + readl(intc->base + P64H_NVM_INTC_ENABLE) & I you cache the enabled bits, then you can spare the readout. No locking required as this demux handler and the mask/unmask operations of the individual interrupts are not serializable. Just use WRITE_ONCE() to update the cached bits under the lock and use READ_ONCE() here. The effect is the same as with reading the hardware. It reads either the old or the new value. > + P64H_NVM_INTC_VALID_MASK; > + > + if (!pending) > + return IRQ_NONE; > + > + /* > + * STATUS may hold a stale edge, already handled while masked. That's confusing at best. How is a level controller having an edge and how is it handled while masked? > + * Clear it, then dispatch only the sources whose line is still high. > + */ > + writel(pending, intc->base + P64H_NVM_INTC_STATUS); What happens in the case that there is only BIT(N) pending in STATUS and that bit is not set in ENABLED? The above !pending check will return. But the stale status bit is still there. Does that cause the demux handler to be invoked again? If so, you need to fix it. If not, please add a comment so people/tools who don't have the hardware documentation handy won't ask the same question. > + writel(0, intc->base + P64H_NVM_INTC_ENABLE); > + writel(P64H_NVM_INTC_VALID_MASK, intc->base + P64H_NVM_INTC_STATUS); > + > + intc->domain = irq_domain_create_linear(dev_fwnode(dev), > + P64H_NVM_INTC_NUM_IRQS, > + &p64h_nvm_intc_domain_ops, > + intc); devm_irq_domain_create_linear() > + if (!intc->domain) > + return dev_err_probe(dev, -ENOMEM, > + "failed to create IRQ domain\n"); Either remove the line break or you need to have curly brackets there. See documentation. Thanks, tglx ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-01 19:31 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-01 16:06 [PATCH 0/2] Add support for Microchip PIC64-HPSC/HX NVM interrupt controller Charles Perry 2026-12-01 16:06 ` [PATCH 1/2] dt-bindings: interrupt-controller: document Microchip PIC64-HPSC/HX NVM intc Charles Perry 2026-12-01 18:13 ` Conor Dooley 2026-12-01 16:06 ` [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller Charles Perry 2026-12-01 16:21 ` sashiko-bot 2026-12-01 19:31 ` Thomas Gleixner
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox