irqchip: aspeed: backport AST2700 A2 support
Subsystems (3)
cover irqchip: aspeed: backport AST2700 A2 support
Backport six upstream Linux ASPEED interrupt-controller commits to OpenBMC dev-6.18 to add AST2700 A2 bindings, interrupt routing and KUnit tests, and remove AST2700 A0 support.
Include the two follow-up fixes for allocation in atomic IRQ context and incomplete interrupt merge-bank disabling at probe, so the A2 support and its fixes can be backported together.
Michael Pesa (1):
irqchip/ast2700-intc: Disable all interrupt merge banks on probe
Ryan Chen (5):
dt-bindings: interrupt-controller: Describe AST2700-A2 hardware
instead of A0
irqchip/ast2700-intc: Add AST2700-A2 support irqchip/ast2700-intc: Add KUnit tests for route resolution irqchip/aspeed-intc: Remove AST2700-A0 support irqchip/ast2700-intc: Avoid allocating in the irq_domain activate()
callback
.../aspeed,ast2700-intc.yaml | 86 --- .../aspeed,ast2700-interrupt.yaml | 188 ++++++ drivers/irqchip/.kunitconfig | 5 + drivers/irqchip/Kconfig | 23 + drivers/irqchip/Makefile | 3 +- drivers/irqchip/irq-aspeed-intc.c | 139 ----- drivers/irqchip/irq-ast2700-intc0-test.c | 473 ++++++++++++++ drivers/irqchip/irq-ast2700-intc0.c | 582 ++++++++++++++++++ drivers/irqchip/irq-ast2700-intc1.c | 281 +++++++++ drivers/irqchip/irq-ast2700.c | 107 ++++ drivers/irqchip/irq-ast2700.h | 48 ++ 11 files changed, 1709 insertions(+), 226 deletions(-) delete mode 100644 Documentation/devicetree/bindings/interrupt-controller/aspeed,ast2700-intc.yaml create mode 100644 Documentation/devicetree/bindings/interrupt-controller/aspeed,ast2700-interrupt.yaml create mode 100644 drivers/irqchip/.kunitconfig delete mode 100644 drivers/irqchip/irq-aspeed-intc.c create mode 100644 drivers/irqchip/irq-ast2700-intc0-test.c create mode 100644 drivers/irqchip/irq-ast2700-intc0.c create mode 100644 drivers/irqchip/irq-ast2700-intc1.c create mode 100644 drivers/irqchip/irq-ast2700.c create mode 100644 drivers/irqchip/irq-ast2700.h
Signature · 1 line
2.43.0
PATCH 1/6 dt-bindings: interrupt-controller: Describe AST2700-A2 hardware instead of A0
From: Ryan Chen <[email protected]>
Introduce a new binding describing the AST2700 interrupt controller architecture implemented in the A2 production silicon.
The AST2700 SoC has undergone multiple silicon revisions (A0, A1, A2) prior to mass production. The interrupt architecture was substantially reworked after the A0 revision for A1, and the A1 design is retained unchanged in the A2 production silicon.
The existing AST2700 interrupt controller binding ("aspeed,ast2700-intc-ic") was written against the pre-production A0 design.
That binding does not accurately describe the interrupt hierarchy and routing model present in A1/A2, where interrupts can be routed to multiple processor-local interrupt controllers (Primary Service Processor (PSP) GIC, Secondary Service Processor (SSP)/Tertiary Service Processor (TSP) NVICs, and BootMCU APLIC) depending on the execution context.
Remove the binding for the pre-production A0 design in favour of the binding for the A2 production design. There is no significant user impact from the removal as there are no existing devicetrees in any of Linux, u-boot or Zephyr that make use of the A0 binding.
Hardware connectivity between interrupt controllers is expressed using the aspeed,interrupt-ranges property.
--- .../aspeed,ast2700-intc.yaml | 86 -------- .../aspeed,ast2700-interrupt.yaml | 188 ++++++++++++++++++ 2 files changed, 188 insertions(+), 86 deletions(-) delete mode 100644 Documentation/devicetree/bindings/interrupt-controller/aspeed,ast2700-intc.yaml create mode 100644 Documentation/devicetree/bindings/interrupt-controller/aspeed,ast2700-interrupt.yaml
Documentation/devicetree/bindings/interrupt-controller/aspeed,ast2700-intc.yaml deleted +0 -86
@@ -1,86 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause -%YAML 1.2 ---- -$id: http://devicetree.org/schemas/interrupt-controller/aspeed,ast2700-intc.yaml# -$schema: http://devicetree.org/meta-schemas/core.yaml# - -title: Aspeed AST2700 Interrupt Controller - -description: - This interrupt controller hardware is second level interrupt controller that - is hooked to a parent interrupt controller. It's useful to combine multiple - interrupt sources into 1 interrupt to parent interrupt controller. - -maintainers: - - Kevin Chen <[email protected]> - -properties: - compatible: - enum: - - aspeed,ast2700-intc-ic - - reg: - maxItems: 1 - - interrupt-controller: true - - '#interrupt-cells': - const: 2 - description: - The first cell is the IRQ number, the second cell is the trigger - type as defined in interrupt.txt in this directory. - - interrupts: - maxItems: 6 - description: | - Depend to which INTC0 or INTC1 used. - INTC0 and INTC1 are two kinds of interrupt controller with enable and raw - status registers for use. - INTC0 is used to assert GIC if interrupt in INTC1 asserted. - INTC1 is used to assert INTC0 if interrupt of modules asserted. - +-----+ +-------+ +---------+---module0 - | GIC |---| INTC0 |--+--| INTC1_0 |---module2 - | | | | | | |---... - +-----+ +-------+ | +---------+---module31 - | - | +---------+---module0 - +---| INTC1_1 |---module2 - | | |---... - | +---------+---module31 - ... - | +---------+---module0 - +---| INTC1_5 |---module2 - | |---... - +---------+---module31 - - -required: - - compatible - - reg - - interrupt-controller - - '#interrupt-cells' - - interrupts - -additionalProperties: false - -examples: - - | - #include <dt-bindings/interrupt-controller/arm-gic.h> - - bus { - #address-cells = <2>; - #size-cells = <2>; - - interrupt-controller@12101b00 { - compatible = "aspeed,ast2700-intc-ic"; - reg = <0 0x12101b00 0 0x10>; - #interrupt-cells = <2>; - interrupt-controller; - interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>, - <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>, - <GIC_SPI 194 IRQ_TYPE_LEVEL_HIGH>, - <GIC_SPI 195 IRQ_TYPE_LEVEL_HIGH>, - <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>, - <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>; - }; - };
Documentation/devicetree/bindings/interrupt-controller/aspeed,ast2700-interrupt.yaml new file +188 -0
188 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 2/6 irqchip/ast2700-intc: Add AST2700-A2 support
In reply to Vince ChangFrom: Ryan Chen <[email protected]>
The AST2700 interrupt fabric is shared by multiple integrated processors (PSP/SSP/TSP/BootMCU), each with its own interrupt controller and its own devicetree view of the system. As a result, interrupt routing cannot be treated as fixed: the valid route for a peripheral interrupt depends on which processor is consuming it.
The INTC0 driver models this by creating a hierarchical irqdomain under the upstream interrupt controller selected by the interrupt-parent property in the devicetree. Information derived from this relationship is incorporated into the route resolution logic for the controller.
The INTC1 driver implements the banked INTM-fed controller and forwards interrupts toward INTC0, without embedding assumptions about the final destination processor.
--- drivers/irqchip/Kconfig | 12 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-ast2700-intc0.c | 581 ++++++++++++++++++++++++++++ drivers/irqchip/irq-ast2700-intc1.c | 280 ++++++++++++++ drivers/irqchip/irq-ast2700.c | 107 +++++ drivers/irqchip/irq-ast2700.h | 48 +++ 6 files changed, 1029 insertions(+) create mode 100644 drivers/irqchip/irq-ast2700-intc0.c create mode 100644 drivers/irqchip/irq-ast2700-intc1.c create mode 100644 drivers/irqchip/irq-ast2700.c create mode 100644 drivers/irqchip/irq-ast2700.h
drivers/irqchip/Kconfig +12 -0
@@ -111,6 +111,18 @@ config AL_FIC help Support Amazon's Annapurna Labs Fabric Interrupt Controller. +config ASPEED_AST2700_INTC + bool "ASPEED AST2700 Interrupt Controller support" + depends on OF + depends on ARCH_ASPEED || COMPILE_TEST + select IRQ_DOMAIN_HIERARCHY + help + Enable support for the ASPEED AST2700 interrupt controller. + This driver handles interrupt, routing and merged interrupt + sources to upstream parent interrupt controllers. + + If unsure, say N. + config ATMEL_AIC_IRQ bool select GENERIC_IRQ_CHIP
drivers/irqchip/Makefile +1 -0
@@ -89,6 +89,7 @@ obj-$(CONFIG_MVEBU_PIC) += irq-mvebu-pic.o obj-$(CONFIG_MVEBU_SEI) += irq-mvebu-sei.o obj-$(CONFIG_LS_EXTIRQ) += irq-ls-extirq.o obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o +obj-$(CONFIG_ASPEED_AST2700_INTC) += irq-ast2700.o irq-ast2700-intc0.o irq-ast2700-intc1.o obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o irq-aspeed-scu-ic.o obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-intc.o obj-$(CONFIG_STM32MP_EXTI) += irq-stm32mp-exti.o
drivers/irqchip/irq-ast2700-intc0.c new file +581 -0
581 lines not on this page · raw message
drivers/irqchip/irq-ast2700-intc1.c new file +280 -0
280 lines not on this page · raw message
drivers/irqchip/irq-ast2700.c new file +107 -0
107 lines not on this page · raw message
drivers/irqchip/irq-ast2700.h new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 3/6 irqchip/ast2700-intc: Add KUnit tests for route resolution
In reply to Vince ChangFrom: Ryan Chen <[email protected]>
Add a KUnit suite for aspeed_intc0_resolve_route().
Cover invalid arguments, invalid domain/range data, connected and disconnected mappings, and malformed upstream range cases.
--- drivers/irqchip/.kunitconfig | 5 + drivers/irqchip/Kconfig | 11 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-ast2700-intc0-test.c | 473 +++++++++++++++++++++++ drivers/irqchip/irq-ast2700-intc0.c | 3 +- 5 files changed, 492 insertions(+), 1 deletion(-) create mode 100644 drivers/irqchip/.kunitconfig create mode 100644 drivers/irqchip/irq-ast2700-intc0-test.c
drivers/irqchip/.kunitconfig new file +5 -0
@@ -0,0 +1,5 @@ +CONFIG_KUNIT=y +CONFIG_OF=y +CONFIG_COMPILE_TEST=y +CONFIG_ASPEED_AST2700_INTC=y +CONFIG_ASPEED_AST2700_INTC_TEST=y
drivers/irqchip/Kconfig +11 -0
@@ -123,6 +123,17 @@ config ASPEED_AST2700_INTC If unsure, say N. +config ASPEED_AST2700_INTC_TEST + bool "Tests for the ASPEED AST2700 Interrupt Controller" + depends on ASPEED_AST2700_INTC && KUNIT=y + default KUNIT_ALL_TESTS + help + Enable KUnit tests for AST2700 INTC route resolution. + The tests exercise error handling and route selection paths. + This option is intended for test builds. + + If unsure, say N. + config ATMEL_AIC_IRQ bool select GENERIC_IRQ_CHIP
drivers/irqchip/Makefile +1 -0
@@ -90,6 +90,7 @@ obj-$(CONFIG_MVEBU_SEI) += irq-mvebu-sei.o obj-$(CONFIG_LS_EXTIRQ) += irq-ls-extirq.o obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o obj-$(CONFIG_ASPEED_AST2700_INTC) += irq-ast2700.o irq-ast2700-intc0.o irq-ast2700-intc1.o +obj-$(CONFIG_ASPEED_AST2700_INTC_TEST) += irq-ast2700-intc0-test.o obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o irq-aspeed-scu-ic.o obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-intc.o obj-$(CONFIG_STM32MP_EXTI) += irq-stm32mp-exti.o
drivers/irqchip/irq-ast2700-intc0-test.c new file +473 -0
473 lines not on this page · raw message
drivers/irqchip/irq-ast2700-intc0.c +2 -1
@@ -311,7 +311,8 @@ int aspeed_intc0_resolve_route(const struct irq_domain *c0domain, size_t nc1outsif (nc1outs ==0 || nc1ranges ==0 )return -ENOENT ; -if (!fwnode_device_is_compatible (c0domain->fwnode,"aspeed,ast2700-intc0" )) +if (!IS_ENABLED (CONFIG_ASPEED_AST2700_INTC_TEST ) && + !fwnode_device_is_compatible (c0domain->fwnode,"aspeed,ast2700-intc0" ))return -ENODEV ; intc0 = c0domain->host_data;
Signature · 1 line
2.43.0
PATCH 4/6 irqchip/aspeed-intc: Remove AST2700-A0 support
In reply to Vince ChangFrom: Ryan Chen <[email protected]>
The existing AST2700 interrupt controller driver ("aspeed,ast2700-intc-ic") was written against the A0 pre-production design.
From A1 onwards (retained in the A2 production silicon), the interrupt fabric was re-architected: interrupt routing is programmable and interrupt outputs can be directed to multiple upstream controllers (PSP GIC, Secondary Service Processor (SSP) NVIC, Tertiary Service Processor (TSP) NVIC, and Boot MCU interrupt controller). This design requires route resolution and a controller hierarchy model which the A0 driver cannot represent.
Remove driver support for A0 in favour of the driver for the A2 production design.
--- drivers/irqchip/Makefile | 1 - drivers/irqchip/irq-aspeed-intc.c | 139 ------------------------------ 2 files changed, 140 deletions(-) delete mode 100644 drivers/irqchip/irq-aspeed-intc.c
drivers/irqchip/Makefile +0 -1
@@ -92,7 +92,6 @@ obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o obj-$(CONFIG_ASPEED_AST2700_INTC) += irq-ast2700.o irq-ast2700-intc0.o irq-ast2700-intc1.o obj-$(CONFIG_ASPEED_AST2700_INTC_TEST) += irq-ast2700-intc0-test.o obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o irq-aspeed-scu-ic.o -obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-intc.o obj-$(CONFIG_STM32MP_EXTI) += irq-stm32mp-exti.o obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o
drivers/irqchip/irq-aspeed-intc.c deleted +0 -139
139 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 5/6 irqchip/ast2700-intc: Avoid allocating in the irq_domain activate() callback
In reply to Vince ChangFrom: Ryan Chen <[email protected]>
The interrupt core calls the irq_domain_activate() callback from __setup_irq() with desc->lock held and interrupts disabled. Both aspeed_intc1_irq_domain_activate() and aspeed_intc0_resolve_route() test a compatible string with fwnode_device_is_compatible().
fwnode_device_is_compatible() invokes fwnode_property_match_string(), which allocates with GFP_KERNEL. That's obviously not possible with interrupts disabled and a raw spinlock held.
Both call sites are only ever handed OF nodes, so use of_device_is_compatible() instead: it walks the property in place and does not allocate.
--- drivers/irqchip/irq-ast2700-intc0.c | 2 +- drivers/irqchip/irq-ast2700-intc1.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/irqchip/irq-ast2700-intc0.c +1 -1
@@ -312,7 +312,7 @@ int aspeed_intc0_resolve_route(const struct irq_domain *c0domain, size_t nc1outsreturn -ENOENT ;if (!IS_ENABLED (CONFIG_ASPEED_AST2700_INTC_TEST ) && - !fwnode_device_is_compatible (c0domain->fwnode,"aspeed,ast2700-intc0" )) + !of_device_is_compatible (to_of_node (c0domain->fwnode),"aspeed,ast2700-intc0" ))return -ENODEV ; intc0 = c0domain->host_data;
drivers/irqchip/irq-ast2700-intc1.c +2 -1
@@ -157,7 +157,8 @@ static int aspeed_intc1_irq_domain_activate(struct irq_domain *domain, intc1->ranges.nranges, intc1->ranges.ranges, &resolved);if (rc <0 ) { -if (!fwnode_device_is_compatible (intc1->upstream->fwnode,"riscv,aplic" )) { +if (!of_device_is_compatible (to_of_node (intc1->upstream->fwnode), +"riscv,aplic" )) {dev_warn (intc1->dev,"Failed to resolve interrupt route for hwirq %lu in domain %s\n" , data->hwirq, domain->name);
Signature · 1 line
2.43.0
PATCH 6/6 irqchip/ast2700-intc: Disable all interrupt merge banks on probe
In reply to Vince ChangFrom: Michael Pesa <[email protected]>
The INTC0 interrupt-merge (INTM) space has 50 sources at 10 per bank, i.e. INTC0_INTM_NUM / INTM_IRQS_PER_BANK = 5 banks. This is reflected everywhere the banks are indexed: the aspeed_intc0_intm_routes[] table has 5 valid entries, and the mask/unmask/eoi paths compute the bank as (hwirq - INTM_BASE) / INTM_IRQS_PER_BANK, spanning banks 0-4.
However, INTC0_INTM_BANK_NUM is hardcoded to 3, so aspeed_intc0_disable_intm() only clears IER for banks 0-2 at probe. Banks 3 and 4 are left in whatever state the firmware configured them , which can leave interrupts enabled before a handler is installed.
Derive the bank count from the source count so the probe-time disable covers every bank.
--- drivers/irqchip/irq-ast2700-intc0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-ast2700-intc0.c +1 -1
@@ -48,9 +48,9 @@#define INTC0_INTMX_IER 0x1b00#define INTC0_INTMX_ISR 0x1b04#define INTC0_INTMX_BANK_SIZE 0x10 -#define INTC0_INTM_BANK_NUM 3#define INTC0_IRQS_PER_BANK 32#define INTM_IRQS_PER_BANK 10 +#define INTC0_INTM_BANK_NUM (INTC0_INTM_NUM / INTM_IRQS_PER_BANK)#define INTC0_SEL_BASE 0x200#define INTC0_SEL_BANK_SIZE 0x4#define INTC0_SEL_ROUTE_SIZE 0x100
Signature · 1 line
2.43.0
Quoted 8 lines · Vince Chang
Backport six upstream Linux ASPEED interrupt-controller commits to OpenBMC dev-6.18 to add AST2700 A2 bindings, interrupt routing and KUnit tests, and remove AST2700 A0 support.
Include the two follow-up fixes for allocation in atomic IRQ context and incomplete interrupt merge-bank disabling at probe, so the A2 support and its fixes can be backported together.
Applied, thanks.
Andrew