From nobody Tue Jun 23 06:13:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73187C43217 for ; Wed, 9 Mar 2022 19:22:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237742AbiCITXY (ORCPT ); Wed, 9 Mar 2022 14:23:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238190AbiCITXH (ORCPT ); Wed, 9 Mar 2022 14:23:07 -0500 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB339114779; Wed, 9 Mar 2022 11:22:07 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hector@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id BA1DD4218A; Wed, 9 Mar 2022 19:22:02 +0000 (UTC) From: Hector Martin To: Thomas Gleixner , Marc Zyngier , Rob Herring Cc: Hector Martin , Sven Peter , Alyssa Rosenzweig , Mark Kettenis , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 1/7] PCI: apple: Change MSI handling to handle 4-cell AIC fwspec form Date: Thu, 10 Mar 2022 04:21:17 +0900 Message-Id: <20220309192123.152028-2-marcan@marcan.st> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220309192123.152028-1-marcan@marcan.st> References: <20220309192123.152028-1-marcan@marcan.st> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" AIC2 changes the IRQ fwspec to add a cell. Always use the second-to-last cell for the MSI handling, so it will work for both AIC1 and AIC2 devices. Signed-off-by: Hector Martin --- drivers/pci/controller/pcie-apple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/p= cie-apple.c index 854d95163112..a2c3c207a04b 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -219,7 +219,7 @@ static int apple_msi_domain_alloc(struct irq_domain *do= main, unsigned int virq, if (hwirq < 0) return -ENOSPC; =20 - fwspec.param[1] +=3D hwirq; + fwspec.param[fwspec.param_count - 2] +=3D hwirq; =20 ret =3D irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, &fwspec); if (ret) --=20 2.33.0 From nobody Tue Jun 23 06:13:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E1CFC43217 for ; Wed, 9 Mar 2022 19:22:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237693AbiCITX2 (ORCPT ); Wed, 9 Mar 2022 14:23:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238257AbiCITXK (ORCPT ); Wed, 9 Mar 2022 14:23:10 -0500 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44990111085; Wed, 9 Mar 2022 11:22:10 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hector@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 10F9A425BB; Wed, 9 Mar 2022 19:22:05 +0000 (UTC) From: Hector Martin To: Thomas Gleixner , Marc Zyngier , Rob Herring Cc: Hector Martin , Sven Peter , Alyssa Rosenzweig , Mark Kettenis , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 2/7] dt-bindings: interrupt-controller: apple,aic2: New binding for AICv2 Date: Thu, 10 Mar 2022 04:21:18 +0900 Message-Id: <20220309192123.152028-3-marcan@marcan.st> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220309192123.152028-1-marcan@marcan.st> References: <20220309192123.152028-1-marcan@marcan.st> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This new incompatible revision of the AIC peripheral introduces multi-die support. This binding is based on apple,aic, but changes interrupt-cells to add a new die argument. Also adds a second reg entry to specify the offset of the event register. Inexplicably, the capability registers allow us to compute other register offsets, but not this one. This allows us to keep forward-compatibility with future SoCs that will likely implement different die counts, thus shifting the event register. Apple also specify the offset explicitly in their their device tree... Signed-off-by: Hector Martin Reviewed-by: Rob Herring --- .../interrupt-controller/apple,aic2.yaml | 98 +++++++++++++++++++ MAINTAINERS | 2 +- 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/= apple,aic2.yaml diff --git a/Documentation/devicetree/bindings/interrupt-controller/apple,a= ic2.yaml b/Documentation/devicetree/bindings/interrupt-controller/apple,aic= 2.yaml new file mode 100644 index 000000000000..47a78a167aba --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/apple,aic2.yaml @@ -0,0 +1,98 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/apple,aic2.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Interrupt Controller 2 + +maintainers: + - Hector Martin + +description: | + The Apple Interrupt Controller 2 is a simple interrupt controller presen= t on + Apple ARM SoC platforms starting with t600x (M1 Pro and Max). + + It provides the following features: + + - Level-triggered hardware IRQs wired to SoC blocks + - Single mask bit per IRQ + - Automatic masking on event delivery (auto-ack) + - Software triggering (ORed with hw line) + - Automatic prioritization (single event/ack register per CPU, lower IRQ= s =3D + higher priority) + - Automatic masking on ack + - Support for multiple dies + + This device also represents the FIQ interrupt sources on platforms using= AIC, + which do not go through a discrete interrupt controller. It also handles + FIQ-based Fast IPIs. + +properties: + compatible: + items: + - const: apple,t6000-aic + - const: apple,aic2 + + interrupt-controller: true + + '#interrupt-cells': + const: 4 + description: | + The 1st cell contains the interrupt type: + - 0: Hardware IRQ + - 1: FIQ + + The 2nd cell contains the die ID. + + The next cell contains the interrupt number. + - HW IRQs: interrupt number + - FIQs: + - 0: physical HV timer + - 1: virtual HV timer + - 2: physical guest timer + - 3: virtual guest timer + + The last cell contains the interrupt flags. This is normally + IRQ_TYPE_LEVEL_HIGH (4). + + reg: + items: + - description: Address and size of the main AIC2 registers. + - description: Address and size of the AIC2 Event register. + + reg-names: + items: + - const: core + - const: event + + power-domains: + maxItems: 1 + +required: + - compatible + - '#interrupt-cells' + - interrupt-controller + - reg + - reg-names + +additionalProperties: false + +allOf: + - $ref: /schemas/interrupt-controller.yaml# + +examples: + - | + soc { + #address-cells =3D <2>; + #size-cells =3D <2>; + + aic: interrupt-controller@28e100000 { + compatible =3D "apple,t6000-aic", "apple,aic2"; + #interrupt-cells =3D <4>; + interrupt-controller; + reg =3D <0x2 0x8e100000 0x0 0xc000>, + <0x2 0x8e10c000 0x0 0x4>; + reg-names =3D "core", "event"; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 69a2935daf6c..7a920a2a5c7a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1767,7 +1767,7 @@ T: git https://github.com/AsahiLinux/linux.git F: Documentation/devicetree/bindings/arm/apple.yaml F: Documentation/devicetree/bindings/arm/apple/* F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml -F: Documentation/devicetree/bindings/interrupt-controller/apple,aic.yaml +F: Documentation/devicetree/bindings/interrupt-controller/apple,* F: Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml F: Documentation/devicetree/bindings/pci/apple,pcie.yaml F: Documentation/devicetree/bindings/pinctrl/apple,pinctrl.yaml --=20 2.33.0 From nobody Tue Jun 23 06:13:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59185C433EF for ; Wed, 9 Mar 2022 19:22:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234655AbiCITXk (ORCPT ); Wed, 9 Mar 2022 14:23:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238312AbiCITXN (ORCPT ); Wed, 9 Mar 2022 14:23:13 -0500 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAE7843498; Wed, 9 Mar 2022 11:22:13 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hector@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 5B51F425C8; Wed, 9 Mar 2022 19:22:09 +0000 (UTC) From: Hector Martin To: Thomas Gleixner , Marc Zyngier , Rob Herring Cc: Hector Martin , Sven Peter , Alyssa Rosenzweig , Mark Kettenis , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 3/7] irqchip/apple-aic: Add Fast IPI support Date: Thu, 10 Mar 2022 04:21:19 +0900 Message-Id: <20220309192123.152028-4-marcan@marcan.st> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220309192123.152028-1-marcan@marcan.st> References: <20220309192123.152028-1-marcan@marcan.st> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The newer AICv2 present in t600x SoCs does not have legacy IPI support at all. Since t8103 also supports Fast IPIs, implement support for this first. The legacy IPI code is left as a fallback, so it can be potentially used by older SoCs in the future. The vIPI code is shared; only the IPI firing/acking bits change for Fast IPIs. Signed-off-by: Hector Martin --- drivers/irqchip/irq-apple-aic.c | 122 ++++++++++++++++++++++++++++---- 1 file changed, 109 insertions(+), 13 deletions(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-ai= c.c index 38091ebb9403..613e0ebdabdc 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -24,7 +24,7 @@ * - Default "this CPU" register view and explicit per-CPU views * * In addition, this driver also handles FIQs, as these are routed to the = same - * IRQ vector. These are used for Fast IPIs (TODO), the ARMv8 timer IRQs, = and + * IRQ vector. These are used for Fast IPIs, the ARMv8 timer IRQs, and * performance counters (TODO). * * Implementation notes: @@ -52,9 +52,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -106,7 +108,6 @@ =20 /* * IMP-DEF sysregs that control FIQ sources - * Note: sysreg-based IPIs are not supported yet. */ =20 /* Core PMC control register */ @@ -155,6 +156,10 @@ #define SYS_IMP_APL_UPMSR_EL1 sys_reg(3, 7, 15, 6, 4) #define UPMSR_IACT BIT(0) =20 +/* MPIDR fields */ +#define MPIDR_CPU(x) MPIDR_AFFINITY_LEVEL(x, 0) +#define MPIDR_CLUSTER(x) MPIDR_AFFINITY_LEVEL(x, 1) + #define AIC_NR_FIQ 4 #define AIC_NR_SWIPI 32 =20 @@ -173,11 +178,44 @@ #define AIC_TMR_EL02_PHYS AIC_TMR_GUEST_PHYS #define AIC_TMR_EL02_VIRT AIC_TMR_GUEST_VIRT =20 +DEFINE_STATIC_KEY_TRUE(use_fast_ipi); + +struct aic_info { + int version; + + /* Features */ + bool fast_ipi; +}; + +static const struct aic_info aic1_info =3D { + .version =3D 1, +}; + +static const struct aic_info aic1_fipi_info =3D { + .version =3D 1, + + .fast_ipi =3D true, +}; + +static const struct of_device_id aic_info_match[] =3D { + { + .compatible =3D "apple,t8103-aic", + .data =3D &aic1_fipi_info, + }, + { + .compatible =3D "apple,aic", + .data =3D &aic1_info, + }, + {} +}; + struct aic_irq_chip { void __iomem *base; struct irq_domain *hw_domain; struct irq_domain *ipi_domain; int nr_hw; + + struct aic_info info; }; =20 static DEFINE_PER_CPU(uint32_t, aic_fiq_unmasked); @@ -386,8 +424,12 @@ static void __exception_irq_entry aic_handle_fiq(struc= t pt_regs *regs) */ =20 if (read_sysreg_s(SYS_IMP_APL_IPI_SR_EL1) & IPI_SR_PENDING) { - pr_err_ratelimited("Fast IPI fired. Acking.\n"); - write_sysreg_s(IPI_SR_PENDING, SYS_IMP_APL_IPI_SR_EL1); + if (static_branch_likely(&use_fast_ipi)) { + aic_handle_ipi(regs); + } else { + pr_err_ratelimited("Fast IPI fired. Acking.\n"); + write_sysreg_s(IPI_SR_PENDING, SYS_IMP_APL_IPI_SR_EL1); + } } =20 if (TIMER_FIRING(read_sysreg(cntp_ctl_el0))) @@ -563,6 +605,22 @@ static const struct irq_domain_ops aic_irq_domain_ops = =3D { * IPI irqchip */ =20 +static void aic_ipi_send_fast(int cpu) +{ + u64 mpidr =3D cpu_logical_map(cpu); + u64 my_mpidr =3D read_cpuid_mpidr(); + u64 cluster =3D MPIDR_CLUSTER(mpidr); + u64 idx =3D MPIDR_CPU(mpidr); + + if (MPIDR_CLUSTER(my_mpidr) =3D=3D cluster) + write_sysreg_s(FIELD_PREP(IPI_RR_CPU, idx), + SYS_IMP_APL_IPI_RR_LOCAL_EL1); + else + write_sysreg_s(FIELD_PREP(IPI_RR_CPU, idx) | FIELD_PREP(IPI_RR_CLUSTER, = cluster), + SYS_IMP_APL_IPI_RR_GLOBAL_EL1); + isb(); +} + static void aic_ipi_mask(struct irq_data *d) { u32 irq_bit =3D BIT(irqd_to_hwirq(d)); @@ -588,8 +646,12 @@ static void aic_ipi_unmask(struct irq_data *d) * If a pending vIPI was unmasked, raise a HW IPI to ourselves. * No barriers needed here since this is a self-IPI. */ - if (atomic_read(this_cpu_ptr(&aic_vipi_flag)) & irq_bit) - aic_ic_write(ic, AIC_IPI_SEND, AIC_IPI_SEND_CPU(smp_processor_id())); + if (atomic_read(this_cpu_ptr(&aic_vipi_flag)) & irq_bit) { + if (static_branch_likely(&use_fast_ipi)) + aic_ipi_send_fast(smp_processor_id()); + else + aic_ic_write(ic, AIC_IPI_SEND, AIC_IPI_SEND_CPU(smp_processor_id())); + } } =20 static void aic_ipi_send_mask(struct irq_data *d, const struct cpumask *ma= sk) @@ -617,8 +679,12 @@ static void aic_ipi_send_mask(struct irq_data *d, cons= t struct cpumask *mask) smp_mb__after_atomic(); =20 if (!(pending & irq_bit) && - (atomic_read(per_cpu_ptr(&aic_vipi_enable, cpu)) & irq_bit)) - send |=3D AIC_IPI_SEND_CPU(cpu); + (atomic_read(per_cpu_ptr(&aic_vipi_enable, cpu)) & irq_bit)) { + if (static_branch_likely(&use_fast_ipi)) + aic_ipi_send_fast(cpu); + else + send |=3D AIC_IPI_SEND_CPU(cpu); + } } =20 /* @@ -650,8 +716,16 @@ static void aic_handle_ipi(struct pt_regs *regs) /* * Ack the IPI. We need to order this after the AIC event read, but * that is enforced by normal MMIO ordering guarantees. + * + * For the Fast IPI case, this needs to be ordered before the vIPI + * handling below, so we need to isb(); */ - aic_ic_write(aic_irqc, AIC_IPI_ACK, AIC_IPI_OTHER); + if (static_branch_likely(&use_fast_ipi)) { + write_sysreg_s(IPI_SR_PENDING, SYS_IMP_APL_IPI_SR_EL1); + isb(); + } else { + aic_ic_write(aic_irqc, AIC_IPI_ACK, AIC_IPI_OTHER); + } =20 /* * The mask read does not need to be ordered. Only we can change @@ -679,7 +753,8 @@ static void aic_handle_ipi(struct pt_regs *regs) * No ordering needed here; at worst this just changes the timing of * when the next IPI will be delivered. */ - aic_ic_write(aic_irqc, AIC_IPI_MASK_CLR, AIC_IPI_OTHER); + if (!static_branch_likely(&use_fast_ipi)) + aic_ic_write(aic_irqc, AIC_IPI_MASK_CLR, AIC_IPI_OTHER); } =20 static int aic_ipi_alloc(struct irq_domain *d, unsigned int virq, @@ -776,10 +851,15 @@ static int aic_init_cpu(unsigned int cpu) /* * Always keep IPIs unmasked at the hardware level (except auto-masking * by AIC during processing). We manage masks at the vIPI level. + * These registers only exist on AICv1, AICv2 always uses fast IPIs. */ aic_ic_write(aic_irqc, AIC_IPI_ACK, AIC_IPI_SELF | AIC_IPI_OTHER); - aic_ic_write(aic_irqc, AIC_IPI_MASK_SET, AIC_IPI_SELF); - aic_ic_write(aic_irqc, AIC_IPI_MASK_CLR, AIC_IPI_OTHER); + if (static_branch_likely(&use_fast_ipi)) { + aic_ic_write(aic_irqc, AIC_IPI_MASK_SET, AIC_IPI_SELF | AIC_IPI_OTHER); + } else { + aic_ic_write(aic_irqc, AIC_IPI_MASK_SET, AIC_IPI_SELF); + aic_ic_write(aic_irqc, AIC_IPI_MASK_CLR, AIC_IPI_OTHER); + } =20 /* Initialize the local mask state */ __this_cpu_write(aic_fiq_unmasked, 0); @@ -799,6 +879,7 @@ static int __init aic_of_ic_init(struct device_node *no= de, struct device_node *p void __iomem *regs; u32 info; struct aic_irq_chip *irqc; + const struct of_device_id *match; =20 regs =3D of_iomap(node, 0); if (WARN_ON(!regs)) @@ -808,12 +889,24 @@ static int __init aic_of_ic_init(struct device_node *= node, struct device_node *p if (!irqc) return -ENOMEM; =20 - aic_irqc =3D irqc; irqc->base =3D regs; =20 + match =3D of_match_node(aic_info_match, node); + if (!match) + return -ENODEV; + + irqc->info =3D *(struct aic_info *)match->data; + + aic_irqc =3D irqc; + info =3D aic_ic_read(irqc, AIC_INFO); irqc->nr_hw =3D FIELD_GET(AIC_INFO_NR_HW, info); =20 + if (irqc->info.fast_ipi) + static_branch_enable(&use_fast_ipi); + else + static_branch_disable(&use_fast_ipi); + irqc->hw_domain =3D irq_domain_create_linear(of_node_to_fwnode(node), irqc->nr_hw + AIC_NR_FIQ, &aic_irq_domain_ops, irqc); @@ -845,6 +938,9 @@ static int __init aic_of_ic_init(struct device_node *no= de, struct device_node *p if (!is_kernel_in_hyp_mode()) pr_info("Kernel running in EL1, mapping interrupts"); =20 + if (static_branch_likely(&use_fast_ipi)) + pr_info("Using Fast IPIs"); + cpuhp_setup_state(CPUHP_AP_IRQ_APPLE_AIC_STARTING, "irqchip/apple-aic/ipi:starting", aic_init_cpu, NULL); --=20 2.33.0 From nobody Tue Jun 23 06:13:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83D61C433F5 for ; Wed, 9 Mar 2022 19:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237756AbiCITXf (ORCPT ); Wed, 9 Mar 2022 14:23:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238347AbiCITXQ (ORCPT ); Wed, 9 Mar 2022 14:23:16 -0500 Received: from mail.marcansoft.com (marcansoft.com [IPv6:2a01:298:fe:f::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E3312AE; Wed, 9 Mar 2022 11:22:17 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hector@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id EBEED425EA; Wed, 9 Mar 2022 19:22:12 +0000 (UTC) From: Hector Martin To: Thomas Gleixner , Marc Zyngier , Rob Herring Cc: Hector Martin , Sven Peter , Alyssa Rosenzweig , Mark Kettenis , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 4/7] irqchip/apple-aic: Switch to irq_domain_create_tree and sparse hwirqs Date: Thu, 10 Mar 2022 04:21:20 +0900 Message-Id: <20220309192123.152028-5-marcan@marcan.st> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220309192123.152028-1-marcan@marcan.st> References: <20220309192123.152028-1-marcan@marcan.st> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This allows us to directly use the hardware event number as the hwirq number. Since IRQ events have bit 16 set (type=3D1), FIQs now move to starting at hwirq number 0. This will become more important once multi-die support is introduced in a later commit. Signed-off-by: Hector Martin --- drivers/irqchip/irq-apple-aic.c | 71 ++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-ai= c.c index 613e0ebdabdc..96480389195d 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -68,7 +68,7 @@ */ =20 #define AIC_INFO 0x0004 -#define AIC_INFO_NR_HW GENMASK(15, 0) +#define AIC_INFO_NR_IRQ GENMASK(15, 0) =20 #define AIC_CONFIG 0x0010 =20 @@ -77,7 +77,8 @@ #define AIC_EVENT_TYPE GENMASK(31, 16) #define AIC_EVENT_NUM GENMASK(15, 0) =20 -#define AIC_EVENT_TYPE_HW 1 +#define AIC_EVENT_TYPE_FIQ 0 /* Software use */ +#define AIC_EVENT_TYPE_IRQ 1 #define AIC_EVENT_TYPE_IPI 4 #define AIC_EVENT_IPI_OTHER 1 #define AIC_EVENT_IPI_SELF 2 @@ -160,6 +161,11 @@ #define MPIDR_CPU(x) MPIDR_AFFINITY_LEVEL(x, 0) #define MPIDR_CLUSTER(x) MPIDR_AFFINITY_LEVEL(x, 1) =20 +#define AIC_IRQ_HWIRQ(x) (FIELD_PREP(AIC_EVENT_TYPE, AIC_EVENT_TYPE_IRQ) |= \ + FIELD_PREP(AIC_EVENT_NUM, x)) +#define AIC_FIQ_HWIRQ(x) (FIELD_PREP(AIC_EVENT_TYPE, AIC_EVENT_TYPE_FIQ) |= \ + FIELD_PREP(AIC_EVENT_NUM, x)) +#define AIC_HWIRQ_IRQ(x) FIELD_GET(AIC_EVENT_NUM, x) #define AIC_NR_FIQ 4 #define AIC_NR_SWIPI 32 =20 @@ -213,7 +219,7 @@ struct aic_irq_chip { void __iomem *base; struct irq_domain *hw_domain; struct irq_domain *ipi_domain; - int nr_hw; + int nr_irq; =20 struct aic_info info; }; @@ -243,18 +249,22 @@ static void aic_ic_write(struct aic_irq_chip *ic, u32= reg, u32 val) =20 static void aic_irq_mask(struct irq_data *d) { + irq_hw_number_t hwirq =3D irqd_to_hwirq(d); struct aic_irq_chip *ic =3D irq_data_get_irq_chip_data(d); =20 - aic_ic_write(ic, AIC_MASK_SET + MASK_REG(irqd_to_hwirq(d)), - MASK_BIT(irqd_to_hwirq(d))); + u32 irq =3D AIC_HWIRQ_IRQ(hwirq); + + aic_ic_write(ic, AIC_MASK_SET + MASK_REG(irq), MASK_BIT(irq)); } =20 static void aic_irq_unmask(struct irq_data *d) { + irq_hw_number_t hwirq =3D irqd_to_hwirq(d); struct aic_irq_chip *ic =3D irq_data_get_irq_chip_data(d); =20 - aic_ic_write(ic, AIC_MASK_CLR + MASK_REG(d->hwirq), - MASK_BIT(irqd_to_hwirq(d))); + u32 irq =3D AIC_HWIRQ_IRQ(hwirq); + + aic_ic_write(ic, AIC_MASK_CLR + MASK_REG(irq), MASK_BIT(irq)); } =20 static void aic_irq_eoi(struct irq_data *d) @@ -281,8 +291,8 @@ static void __exception_irq_entry aic_handle_irq(struct= pt_regs *regs) type =3D FIELD_GET(AIC_EVENT_TYPE, event); irq =3D FIELD_GET(AIC_EVENT_NUM, event); =20 - if (type =3D=3D AIC_EVENT_TYPE_HW) - generic_handle_domain_irq(aic_irqc->hw_domain, irq); + if (type =3D=3D AIC_EVENT_TYPE_IRQ) + generic_handle_domain_irq(aic_irqc->hw_domain, event); else if (type =3D=3D AIC_EVENT_TYPE_IPI && irq =3D=3D 1) aic_handle_ipi(regs); else if (event !=3D 0) @@ -314,7 +324,7 @@ static int aic_irq_set_affinity(struct irq_data *d, else cpu =3D cpumask_any_and(mask_val, cpu_online_mask); =20 - aic_ic_write(ic, AIC_TARGET_CPU + hwirq * 4, BIT(cpu)); + aic_ic_write(ic, AIC_TARGET_CPU + AIC_HWIRQ_IRQ(hwirq) * 4, BIT(cpu)); irq_data_update_effective_affinity(d, cpumask_of(cpu)); =20 return IRQ_SET_MASK_OK; @@ -344,9 +354,7 @@ static struct irq_chip aic_chip =3D { =20 static unsigned long aic_fiq_get_idx(struct irq_data *d) { - struct aic_irq_chip *ic =3D irq_data_get_irq_chip_data(d); - - return irqd_to_hwirq(d) - ic->nr_hw; + return AIC_HWIRQ_IRQ(irqd_to_hwirq(d)); } =20 static void aic_fiq_set_mask(struct irq_data *d) @@ -434,11 +442,11 @@ static void __exception_irq_entry aic_handle_fiq(stru= ct pt_regs *regs) =20 if (TIMER_FIRING(read_sysreg(cntp_ctl_el0))) generic_handle_domain_irq(aic_irqc->hw_domain, - aic_irqc->nr_hw + AIC_TMR_EL0_PHYS); + AIC_FIQ_HWIRQ(AIC_TMR_EL0_PHYS)); =20 if (TIMER_FIRING(read_sysreg(cntv_ctl_el0))) generic_handle_domain_irq(aic_irqc->hw_domain, - aic_irqc->nr_hw + AIC_TMR_EL0_VIRT); + AIC_FIQ_HWIRQ(AIC_TMR_EL0_VIRT)); =20 if (is_kernel_in_hyp_mode()) { uint64_t enabled =3D read_sysreg_s(SYS_IMP_APL_VM_TMR_FIQ_ENA_EL2); @@ -446,12 +454,12 @@ static void __exception_irq_entry aic_handle_fiq(stru= ct pt_regs *regs) if ((enabled & VM_TMR_FIQ_ENABLE_P) && TIMER_FIRING(read_sysreg_s(SYS_CNTP_CTL_EL02))) generic_handle_domain_irq(aic_irqc->hw_domain, - aic_irqc->nr_hw + AIC_TMR_EL02_PHYS); + AIC_FIQ_HWIRQ(AIC_TMR_EL02_PHYS)); =20 if ((enabled & VM_TMR_FIQ_ENABLE_V) && TIMER_FIRING(read_sysreg_s(SYS_CNTV_CTL_EL02))) generic_handle_domain_irq(aic_irqc->hw_domain, - aic_irqc->nr_hw + AIC_TMR_EL02_VIRT); + AIC_FIQ_HWIRQ(AIC_TMR_EL02_VIRT)); } =20 if ((read_sysreg_s(SYS_IMP_APL_PMCR0_EL1) & (PMCR0_IMODE | PMCR0_IACT)) = =3D=3D @@ -496,9 +504,9 @@ static struct irq_chip fiq_chip =3D { static int aic_irq_domain_map(struct irq_domain *id, unsigned int irq, irq_hw_number_t hw) { - struct aic_irq_chip *ic =3D id->host_data; + u32 type =3D FIELD_GET(AIC_EVENT_TYPE, hw); =20 - if (hw < ic->nr_hw) { + if (type =3D=3D AIC_EVENT_TYPE_IRQ) { irq_domain_set_info(id, irq, hw, &aic_chip, id->host_data, handle_fasteoi_irq, NULL, NULL); irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(irq))); @@ -523,14 +531,14 @@ static int aic_irq_domain_translate(struct irq_domain= *id, =20 switch (fwspec->param[0]) { case AIC_IRQ: - if (fwspec->param[1] >=3D ic->nr_hw) + if (fwspec->param[1] >=3D ic->nr_irq) return -EINVAL; - *hwirq =3D fwspec->param[1]; + *hwirq =3D AIC_IRQ_HWIRQ(fwspec->param[1]); break; case AIC_FIQ: if (fwspec->param[1] >=3D AIC_NR_FIQ) return -EINVAL; - *hwirq =3D ic->nr_hw + fwspec->param[1]; + *hwirq =3D AIC_FIQ_HWIRQ(fwspec->param[1]); =20 /* * In EL1 the non-redirected registers are the guest's, @@ -539,10 +547,10 @@ static int aic_irq_domain_translate(struct irq_domain= *id, if (!is_kernel_in_hyp_mode()) { switch (fwspec->param[1]) { case AIC_TMR_GUEST_PHYS: - *hwirq =3D ic->nr_hw + AIC_TMR_EL0_PHYS; + *hwirq =3D AIC_FIQ_HWIRQ(AIC_TMR_EL0_PHYS); break; case AIC_TMR_GUEST_VIRT: - *hwirq =3D ic->nr_hw + AIC_TMR_EL0_VIRT; + *hwirq =3D AIC_FIQ_HWIRQ(AIC_TMR_EL0_VIRT); break; case AIC_TMR_HV_PHYS: case AIC_TMR_HV_VIRT: @@ -900,16 +908,15 @@ static int __init aic_of_ic_init(struct device_node *= node, struct device_node *p aic_irqc =3D irqc; =20 info =3D aic_ic_read(irqc, AIC_INFO); - irqc->nr_hw =3D FIELD_GET(AIC_INFO_NR_HW, info); + irqc->nr_irq =3D FIELD_GET(AIC_INFO_NR_IRQ, info); =20 if (irqc->info.fast_ipi) static_branch_enable(&use_fast_ipi); else static_branch_disable(&use_fast_ipi); =20 - irqc->hw_domain =3D irq_domain_create_linear(of_node_to_fwnode(node), - irqc->nr_hw + AIC_NR_FIQ, - &aic_irq_domain_ops, irqc); + irqc->hw_domain =3D irq_domain_create_tree(of_node_to_fwnode(node), + &aic_irq_domain_ops, irqc); if (WARN_ON(!irqc->hw_domain)) { iounmap(irqc->base); kfree(irqc); @@ -928,11 +935,11 @@ static int __init aic_of_ic_init(struct device_node *= node, struct device_node *p set_handle_irq(aic_handle_irq); set_handle_fiq(aic_handle_fiq); =20 - for (i =3D 0; i < BITS_TO_U32(irqc->nr_hw); i++) + for (i =3D 0; i < BITS_TO_U32(irqc->nr_irq); i++) aic_ic_write(irqc, AIC_MASK_SET + i * 4, U32_MAX); - for (i =3D 0; i < BITS_TO_U32(irqc->nr_hw); i++) + for (i =3D 0; i < BITS_TO_U32(irqc->nr_irq); i++) aic_ic_write(irqc, AIC_SW_CLR + i * 4, U32_MAX); - for (i =3D 0; i < irqc->nr_hw; i++) + for (i =3D 0; i < irqc->nr_irq; i++) aic_ic_write(irqc, AIC_TARGET_CPU + i * 4, 1); =20 if (!is_kernel_in_hyp_mode()) @@ -948,7 +955,7 @@ static int __init aic_of_ic_init(struct device_node *no= de, struct device_node *p vgic_set_kvm_info(&vgic_info); =20 pr_info("Initialized with %d IRQs, %d FIQs, %d vIPIs\n", - irqc->nr_hw, AIC_NR_FIQ, AIC_NR_SWIPI); + irqc->nr_irq, AIC_NR_FIQ, AIC_NR_SWIPI); =20 return 0; } --=20 2.33.0 From nobody Tue Jun 23 06:13:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7346DC4332F for ; Wed, 9 Mar 2022 19:22:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237771AbiCITXm (ORCPT ); Wed, 9 Mar 2022 14:23:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238375AbiCITXT (ORCPT ); Wed, 9 Mar 2022 14:23:19 -0500 Received: from mail.marcansoft.com (marcansoft.com [IPv6:2a01:298:fe:f::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F8F72AE; Wed, 9 Mar 2022 11:22:20 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hector@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 4299241EA7; Wed, 9 Mar 2022 19:22:16 +0000 (UTC) From: Hector Martin To: Thomas Gleixner , Marc Zyngier , Rob Herring Cc: Hector Martin , Sven Peter , Alyssa Rosenzweig , Mark Kettenis , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 5/7] irqchip/apple-aic: Dynamically compute register offsets Date: Thu, 10 Mar 2022 04:21:21 +0900 Message-Id: <20220309192123.152028-6-marcan@marcan.st> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220309192123.152028-1-marcan@marcan.st> References: <20220309192123.152028-1-marcan@marcan.st> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This allows us to support AIC variants with different numbers of IRQs based on capability registers. Signed-off-by: Hector Martin --- drivers/irqchip/irq-apple-aic.c | 72 +++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-ai= c.c index 96480389195d..4b1ba732f476 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -64,7 +64,7 @@ #include =20 /* - * AIC registers (MMIO) + * AIC v1 registers (MMIO) */ =20 #define AIC_INFO 0x0004 @@ -94,16 +94,14 @@ #define AIC_IPI_SELF BIT(31) =20 #define AIC_TARGET_CPU 0x3000 -#define AIC_SW_SET 0x4000 -#define AIC_SW_CLR 0x4080 -#define AIC_MASK_SET 0x4100 -#define AIC_MASK_CLR 0x4180 =20 #define AIC_CPU_IPI_SET(cpu) (0x5008 + ((cpu) << 7)) #define AIC_CPU_IPI_CLR(cpu) (0x500c + ((cpu) << 7)) #define AIC_CPU_IPI_MASK_SET(cpu) (0x5024 + ((cpu) << 7)) #define AIC_CPU_IPI_MASK_CLR(cpu) (0x5028 + ((cpu) << 7)) =20 +#define AIC_MAX_IRQ 0x400 + #define MASK_REG(x) (4 * ((x) >> 5)) #define MASK_BIT(x) BIT((x) & GENMASK(4, 0)) =20 @@ -189,17 +187,31 @@ DEFINE_STATIC_KEY_TRUE(use_fast_ipi); struct aic_info { int version; =20 + /* Register offsets */ + u32 event; + u32 target_cpu; + u32 sw_set; + u32 sw_clr; + u32 mask_set; + u32 mask_clr; + /* Features */ bool fast_ipi; }; =20 static const struct aic_info aic1_info =3D { .version =3D 1, + + .event =3D AIC_EVENT, + .target_cpu =3D AIC_TARGET_CPU, }; =20 static const struct aic_info aic1_fipi_info =3D { .version =3D 1, =20 + .event =3D AIC_EVENT, + .target_cpu =3D AIC_TARGET_CPU, + .fast_ipi =3D true, }; =20 @@ -219,7 +231,9 @@ struct aic_irq_chip { void __iomem *base; struct irq_domain *hw_domain; struct irq_domain *ipi_domain; + int nr_irq; + int max_irq; =20 struct aic_info info; }; @@ -254,7 +268,7 @@ static void aic_irq_mask(struct irq_data *d) =20 u32 irq =3D AIC_HWIRQ_IRQ(hwirq); =20 - aic_ic_write(ic, AIC_MASK_SET + MASK_REG(irq), MASK_BIT(irq)); + aic_ic_write(ic, ic->info.mask_set + MASK_REG(irq), MASK_BIT(irq)); } =20 static void aic_irq_unmask(struct irq_data *d) @@ -264,7 +278,7 @@ static void aic_irq_unmask(struct irq_data *d) =20 u32 irq =3D AIC_HWIRQ_IRQ(hwirq); =20 - aic_ic_write(ic, AIC_MASK_CLR + MASK_REG(irq), MASK_BIT(irq)); + aic_ic_write(ic, ic->info.mask_clr + MASK_REG(irq), MASK_BIT(irq)); } =20 static void aic_irq_eoi(struct irq_data *d) @@ -287,7 +301,7 @@ static void __exception_irq_entry aic_handle_irq(struct= pt_regs *regs) * We cannot use a relaxed read here, as reads from DMA buffers * need to be ordered after the IRQ fires. */ - event =3D readl(ic->base + AIC_EVENT); + event =3D readl(ic->base + ic->info.event); type =3D FIELD_GET(AIC_EVENT_TYPE, event); irq =3D FIELD_GET(AIC_EVENT_NUM, event); =20 @@ -319,12 +333,14 @@ static int aic_irq_set_affinity(struct irq_data *d, struct aic_irq_chip *ic =3D irq_data_get_irq_chip_data(d); int cpu; =20 + BUG_ON(!ic->info.target_cpu); + if (force) cpu =3D cpumask_first(mask_val); else cpu =3D cpumask_any_and(mask_val, cpu_online_mask); =20 - aic_ic_write(ic, AIC_TARGET_CPU + AIC_HWIRQ_IRQ(hwirq) * 4, BIT(cpu)); + aic_ic_write(ic, ic->info.target_cpu + AIC_HWIRQ_IRQ(hwirq) * 4, BIT(cpu)= ); irq_data_update_effective_affinity(d, cpumask_of(cpu)); =20 return IRQ_SET_MASK_OK; @@ -884,8 +900,8 @@ static struct gic_kvm_info vgic_info __initdata =3D { static int __init aic_of_ic_init(struct device_node *node, struct device_n= ode *parent) { int i; + u32 off; void __iomem *regs; - u32 info; struct aic_irq_chip *irqc; const struct of_device_id *match; =20 @@ -907,8 +923,30 @@ static int __init aic_of_ic_init(struct device_node *n= ode, struct device_node *p =20 aic_irqc =3D irqc; =20 - info =3D aic_ic_read(irqc, AIC_INFO); - irqc->nr_irq =3D FIELD_GET(AIC_INFO_NR_IRQ, info); + switch (irqc->info.version) { + case 1: { + u32 info; + + info =3D aic_ic_read(irqc, AIC_INFO); + irqc->nr_irq =3D FIELD_GET(AIC_INFO_NR_IRQ, info); + irqc->max_irq =3D AIC_MAX_IRQ; + + off =3D irqc->info.target_cpu; + off +=3D sizeof(u32) * irqc->max_irq; /* TARGET_CPU */ + + break; + } + } + + irqc->info.sw_set =3D off; + off +=3D sizeof(u32) * (irqc->max_irq >> 5); /* SW_SET */ + irqc->info.sw_clr =3D off; + off +=3D sizeof(u32) * (irqc->max_irq >> 5); /* SW_CLR */ + irqc->info.mask_set =3D off; + off +=3D sizeof(u32) * (irqc->max_irq >> 5); /* MASK_SET */ + irqc->info.mask_clr =3D off; + off +=3D sizeof(u32) * (irqc->max_irq >> 5); /* MASK_CLR */ + off +=3D sizeof(u32) * (irqc->max_irq >> 5); /* HW_STATE */ =20 if (irqc->info.fast_ipi) static_branch_enable(&use_fast_ipi); @@ -936,11 +974,11 @@ static int __init aic_of_ic_init(struct device_node *= node, struct device_node *p set_handle_fiq(aic_handle_fiq); =20 for (i =3D 0; i < BITS_TO_U32(irqc->nr_irq); i++) - aic_ic_write(irqc, AIC_MASK_SET + i * 4, U32_MAX); + aic_ic_write(irqc, irqc->info.mask_set + i * 4, U32_MAX); for (i =3D 0; i < BITS_TO_U32(irqc->nr_irq); i++) - aic_ic_write(irqc, AIC_SW_CLR + i * 4, U32_MAX); + aic_ic_write(irqc, irqc->info.sw_clr + i * 4, U32_MAX); for (i =3D 0; i < irqc->nr_irq; i++) - aic_ic_write(irqc, AIC_TARGET_CPU + i * 4, 1); + aic_ic_write(irqc, irqc->info.target_cpu + i * 4, 1); =20 if (!is_kernel_in_hyp_mode()) pr_info("Kernel running in EL1, mapping interrupts"); @@ -954,8 +992,8 @@ static int __init aic_of_ic_init(struct device_node *no= de, struct device_node *p =20 vgic_set_kvm_info(&vgic_info); =20 - pr_info("Initialized with %d IRQs, %d FIQs, %d vIPIs\n", - irqc->nr_irq, AIC_NR_FIQ, AIC_NR_SWIPI); + pr_info("Initialized with %d/%d IRQs, %d FIQs, %d vIPIs", + irqc->nr_irq, irqc->max_irq, AIC_NR_FIQ, AIC_NR_SWIPI); =20 return 0; } --=20 2.33.0 From nobody Tue Jun 23 06:13:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88915C433EF for ; Wed, 9 Mar 2022 19:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237830AbiCITXq (ORCPT ); Wed, 9 Mar 2022 14:23:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237736AbiCITXY (ORCPT ); Wed, 9 Mar 2022 14:23:24 -0500 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E655743498; Wed, 9 Mar 2022 11:22:23 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hector@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 8DE7B4218A; Wed, 9 Mar 2022 19:22:19 +0000 (UTC) From: Hector Martin To: Thomas Gleixner , Marc Zyngier , Rob Herring Cc: Hector Martin , Sven Peter , Alyssa Rosenzweig , Mark Kettenis , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 6/7] irqchip/apple-aic: Support multiple dies Date: Thu, 10 Mar 2022 04:21:22 +0900 Message-Id: <20220309192123.152028-7-marcan@marcan.st> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220309192123.152028-1-marcan@marcan.st> References: <20220309192123.152028-1-marcan@marcan.st> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Multi-die support in AICv2 uses several sets of IRQ registers. Introduce a die count and compute the register group offset based on the die ID field of the hwirq number, as reported by the hardware. Signed-off-by: Hector Martin --- drivers/irqchip/irq-apple-aic.c | 77 +++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 23 deletions(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-ai= c.c index 4b1ba732f476..93c622435ba2 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -74,7 +74,8 @@ =20 #define AIC_WHOAMI 0x2000 #define AIC_EVENT 0x2004 -#define AIC_EVENT_TYPE GENMASK(31, 16) +#define AIC_EVENT_DIE GENMASK(31, 24) +#define AIC_EVENT_TYPE GENMASK(23, 16) #define AIC_EVENT_NUM GENMASK(15, 0) =20 #define AIC_EVENT_TYPE_FIQ 0 /* Software use */ @@ -159,11 +160,13 @@ #define MPIDR_CPU(x) MPIDR_AFFINITY_LEVEL(x, 0) #define MPIDR_CLUSTER(x) MPIDR_AFFINITY_LEVEL(x, 1) =20 -#define AIC_IRQ_HWIRQ(x) (FIELD_PREP(AIC_EVENT_TYPE, AIC_EVENT_TYPE_IRQ) |= \ - FIELD_PREP(AIC_EVENT_NUM, x)) +#define AIC_IRQ_HWIRQ(die, irq) (FIELD_PREP(AIC_EVENT_DIE, die) | \ + FIELD_PREP(AIC_EVENT_TYPE, AIC_EVENT_TYPE_IRQ) | \ + FIELD_PREP(AIC_EVENT_NUM, irq)) #define AIC_FIQ_HWIRQ(x) (FIELD_PREP(AIC_EVENT_TYPE, AIC_EVENT_TYPE_FIQ) |= \ FIELD_PREP(AIC_EVENT_NUM, x)) #define AIC_HWIRQ_IRQ(x) FIELD_GET(AIC_EVENT_NUM, x) +#define AIC_HWIRQ_DIE(x) FIELD_GET(AIC_EVENT_DIE, x) #define AIC_NR_FIQ 4 #define AIC_NR_SWIPI 32 =20 @@ -195,6 +198,8 @@ struct aic_info { u32 mask_set; u32 mask_clr; =20 + u32 die_stride; + /* Features */ bool fast_ipi; }; @@ -234,6 +239,8 @@ struct aic_irq_chip { =20 int nr_irq; int max_irq; + int nr_die; + int max_die; =20 struct aic_info info; }; @@ -266,9 +273,10 @@ static void aic_irq_mask(struct irq_data *d) irq_hw_number_t hwirq =3D irqd_to_hwirq(d); struct aic_irq_chip *ic =3D irq_data_get_irq_chip_data(d); =20 + u32 off =3D AIC_HWIRQ_DIE(hwirq) * ic->info.die_stride; u32 irq =3D AIC_HWIRQ_IRQ(hwirq); =20 - aic_ic_write(ic, ic->info.mask_set + MASK_REG(irq), MASK_BIT(irq)); + aic_ic_write(ic, ic->info.mask_set + off + MASK_REG(irq), MASK_BIT(irq)); } =20 static void aic_irq_unmask(struct irq_data *d) @@ -276,9 +284,10 @@ static void aic_irq_unmask(struct irq_data *d) irq_hw_number_t hwirq =3D irqd_to_hwirq(d); struct aic_irq_chip *ic =3D irq_data_get_irq_chip_data(d); =20 + u32 off =3D AIC_HWIRQ_DIE(hwirq) * ic->info.die_stride; u32 irq =3D AIC_HWIRQ_IRQ(hwirq); =20 - aic_ic_write(ic, ic->info.mask_clr + MASK_REG(irq), MASK_BIT(irq)); + aic_ic_write(ic, ic->info.mask_clr + off + MASK_REG(irq), MASK_BIT(irq)); } =20 static void aic_irq_eoi(struct irq_data *d) @@ -541,27 +550,41 @@ static int aic_irq_domain_translate(struct irq_domain= *id, unsigned int *type) { struct aic_irq_chip *ic =3D id->host_data; + u32 *args; + u32 die =3D 0; =20 - if (fwspec->param_count !=3D 3 || !is_of_node(fwspec->fwnode)) + if (fwspec->param_count < 3 || fwspec->param_count > 4 || + !is_of_node(fwspec->fwnode)) return -EINVAL; =20 + args =3D &fwspec->param[1]; + + if (fwspec->param_count =3D=3D 4) { + die =3D args[0]; + args++; + } + switch (fwspec->param[0]) { case AIC_IRQ: - if (fwspec->param[1] >=3D ic->nr_irq) + if (die >=3D ic->nr_die) return -EINVAL; - *hwirq =3D AIC_IRQ_HWIRQ(fwspec->param[1]); + if (args[0] >=3D ic->nr_irq) + return -EINVAL; + *hwirq =3D AIC_IRQ_HWIRQ(die, args[0]); break; case AIC_FIQ: - if (fwspec->param[1] >=3D AIC_NR_FIQ) + if (die !=3D 0) + return -EINVAL; + if (args[0] >=3D AIC_NR_FIQ) return -EINVAL; - *hwirq =3D AIC_FIQ_HWIRQ(fwspec->param[1]); + *hwirq =3D AIC_FIQ_HWIRQ(args[0]); =20 /* * In EL1 the non-redirected registers are the guest's, * not EL2's, so remap the hwirqs to match. */ if (!is_kernel_in_hyp_mode()) { - switch (fwspec->param[1]) { + switch (args[0]) { case AIC_TMR_GUEST_PHYS: *hwirq =3D AIC_FIQ_HWIRQ(AIC_TMR_EL0_PHYS); break; @@ -580,7 +603,7 @@ static int aic_irq_domain_translate(struct irq_domain *= id, return -EINVAL; } =20 - *type =3D fwspec->param[2] & IRQ_TYPE_SENSE_MASK; + *type =3D args[1] & IRQ_TYPE_SENSE_MASK; =20 return 0; } @@ -899,8 +922,8 @@ static struct gic_kvm_info vgic_info __initdata =3D { =20 static int __init aic_of_ic_init(struct device_node *node, struct device_n= ode *parent) { - int i; - u32 off; + int i, die; + u32 off, start_off; void __iomem *regs; struct aic_irq_chip *irqc; const struct of_device_id *match; @@ -930,8 +953,9 @@ static int __init aic_of_ic_init(struct device_node *no= de, struct device_node *p info =3D aic_ic_read(irqc, AIC_INFO); irqc->nr_irq =3D FIELD_GET(AIC_INFO_NR_IRQ, info); irqc->max_irq =3D AIC_MAX_IRQ; + irqc->nr_die =3D irqc->max_die =3D 1; =20 - off =3D irqc->info.target_cpu; + off =3D start_off =3D irqc->info.target_cpu; off +=3D sizeof(u32) * irqc->max_irq; /* TARGET_CPU */ =20 break; @@ -953,6 +977,8 @@ static int __init aic_of_ic_init(struct device_node *no= de, struct device_node *p else static_branch_disable(&use_fast_ipi); =20 + irqc->info.die_stride =3D off - start_off; + irqc->hw_domain =3D irq_domain_create_tree(of_node_to_fwnode(node), &aic_irq_domain_ops, irqc); if (WARN_ON(!irqc->hw_domain)) { @@ -973,12 +999,17 @@ static int __init aic_of_ic_init(struct device_node *= node, struct device_node *p set_handle_irq(aic_handle_irq); set_handle_fiq(aic_handle_fiq); =20 - for (i =3D 0; i < BITS_TO_U32(irqc->nr_irq); i++) - aic_ic_write(irqc, irqc->info.mask_set + i * 4, U32_MAX); - for (i =3D 0; i < BITS_TO_U32(irqc->nr_irq); i++) - aic_ic_write(irqc, irqc->info.sw_clr + i * 4, U32_MAX); - for (i =3D 0; i < irqc->nr_irq; i++) - aic_ic_write(irqc, irqc->info.target_cpu + i * 4, 1); + off =3D 0; + for (die =3D 0; die < irqc->nr_die; die++) { + for (i =3D 0; i < BITS_TO_U32(irqc->nr_irq); i++) + aic_ic_write(irqc, irqc->info.mask_set + off + i * 4, U32_MAX); + for (i =3D 0; i < BITS_TO_U32(irqc->nr_irq); i++) + aic_ic_write(irqc, irqc->info.sw_clr + off + i * 4, U32_MAX); + if (irqc->info.target_cpu) + for (i =3D 0; i < irqc->nr_irq; i++) + aic_ic_write(irqc, irqc->info.target_cpu + off + i * 4, 1); + off +=3D irqc->info.die_stride; + } =20 if (!is_kernel_in_hyp_mode()) pr_info("Kernel running in EL1, mapping interrupts"); @@ -992,8 +1023,8 @@ static int __init aic_of_ic_init(struct device_node *n= ode, struct device_node *p =20 vgic_set_kvm_info(&vgic_info); =20 - pr_info("Initialized with %d/%d IRQs, %d FIQs, %d vIPIs", - irqc->nr_irq, irqc->max_irq, AIC_NR_FIQ, AIC_NR_SWIPI); + pr_info("Initialized with %d/%d IRQs * %d/%d die(s), %d FIQs, %d vIPIs", + irqc->nr_irq, irqc->max_irq, irqc->nr_die, irqc->max_die, AIC_NR_FIQ, AI= C_NR_SWIPI); =20 return 0; } --=20 2.33.0 From nobody Tue Jun 23 06:13:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36002C433EF for ; Wed, 9 Mar 2022 19:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237743AbiCITXt (ORCPT ); Wed, 9 Mar 2022 14:23:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237741AbiCITX0 (ORCPT ); Wed, 9 Mar 2022 14:23:26 -0500 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E73C6CA76; Wed, 9 Mar 2022 11:22:27 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hector@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id D89DA425BB; Wed, 9 Mar 2022 19:22:22 +0000 (UTC) From: Hector Martin To: Thomas Gleixner , Marc Zyngier , Rob Herring Cc: Hector Martin , Sven Peter , Alyssa Rosenzweig , Mark Kettenis , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 7/7] irqchip/apple-aic: Add support for AICv2 Date: Thu, 10 Mar 2022 04:21:23 +0900 Message-Id: <20220309192123.152028-8-marcan@marcan.st> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220309192123.152028-1-marcan@marcan.st> References: <20220309192123.152028-1-marcan@marcan.st> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Introduce support for the new AICv2 hardware block in t6000/t6001 SoCs. It seems these blocks are missing the information required to compute the event register offset in the capability registers, so we specify that in the DT as a second reg entry. Signed-off-by: Hector Martin --- drivers/irqchip/irq-apple-aic.c | 181 ++++++++++++++++++++++++++------ 1 file changed, 148 insertions(+), 33 deletions(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-ai= c.c index 93c622435ba2..ba2dff70dff5 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -103,6 +103,58 @@ =20 #define AIC_MAX_IRQ 0x400 =20 +/* + * AIC v2 registers (MMIO) + */ + +#define AIC2_VERSION 0x0000 +#define AIC2_VERSION_VER GENMASK(7, 0) + +#define AIC2_INFO1 0x0004 +#define AIC2_INFO1_NR_IRQ GENMASK(15, 0) +#define AIC2_INFO1_LAST_DIE GENMASK(27, 24) + +#define AIC2_INFO2 0x0008 + +#define AIC2_INFO3 0x000c +#define AIC2_INFO3_MAX_IRQ GENMASK(15, 0) +#define AIC2_INFO3_MAX_DIE GENMASK(27, 24) + +#define AIC2_RESET 0x0010 +#define AIC2_RESET_RESET BIT(0) + +#define AIC2_CONFIG 0x0014 +#define AIC2_CONFIG_ENABLE BIT(0) +#define AIC2_CONFIG_PREFER_PCPU BIT(28) + +#define AIC2_TIMEOUT 0x0028 +#define AIC2_CLUSTER_PRIO 0x0030 +#define AIC2_DELAY_GROUPS 0x0100 + +#define AIC2_IRQ_CFG 0x2000 + +/* + * AIC2 registers are laid out like this, starting at AIC2_IRQ_CFG: + * + * Repeat for each die: + * IRQ_CFG: u32 * MAX_IRQS + * SW_SET: u32 * (MAX_IRQS / 32) + * SW_CLR: u32 * (MAX_IRQS / 32) + * MASK_SET: u32 * (MAX_IRQS / 32) + * MASK_CLR: u32 * (MAX_IRQS / 32) + * HW_STATE: u32 * (MAX_IRQS / 32) + * + * This is followed by a set of event registers, each 16K page aligned. + * The first one is the AP event register we will use. Unfortunately, + * the actual implemented die count is not specified anywhere in the + * capability registers, so we have to explicitly specify the event + * register as a second reg entry in the device tree to remain + * forward-compatible. + */ + +#define AIC2_IRQ_CFG_TARGET GENMASK(3, 0) +#define AIC2_IRQ_CFG_DELAY_IDX GENMASK(7, 5) + #define MASK_REG(x) (4 * ((x) >> 5)) #define MASK_BIT(x) BIT((x) & GENMASK(4, 0)) =20 @@ -193,6 +245,7 @@ struct aic_info { /* Register offsets */ u32 event; u32 target_cpu; + u32 irq_cfg; u32 sw_set; u32 sw_clr; u32 mask_set; @@ -220,6 +273,14 @@ static const struct aic_info aic1_fipi_info =3D { .fast_ipi =3D true, }; =20 +static const struct aic_info aic2_info =3D { + .version =3D 2, + + .irq_cfg =3D AIC2_IRQ_CFG, + + .fast_ipi =3D true, +}; + static const struct of_device_id aic_info_match[] =3D { { .compatible =3D "apple,t8103-aic", @@ -229,11 +290,16 @@ static const struct of_device_id aic_info_match[] =3D= { .compatible =3D "apple,aic", .data =3D &aic1_info, }, + { + .compatible =3D "apple,aic2", + .data =3D &aic2_info, + }, {} }; =20 struct aic_irq_chip { void __iomem *base; + void __iomem *event; struct irq_domain *hw_domain; struct irq_domain *ipi_domain; =20 @@ -310,7 +376,7 @@ static void __exception_irq_entry aic_handle_irq(struct= pt_regs *regs) * We cannot use a relaxed read here, as reads from DMA buffers * need to be ordered after the IRQ fires. */ - event =3D readl(ic->base + ic->info.event); + event =3D readl(ic->event + ic->info.event); type =3D FIELD_GET(AIC_EVENT_TYPE, event); irq =3D FIELD_GET(AIC_EVENT_NUM, event); =20 @@ -373,6 +439,14 @@ static struct irq_chip aic_chip =3D { .irq_set_type =3D aic_irq_set_type, }; =20 +static struct irq_chip aic2_chip =3D { + .name =3D "AIC2", + .irq_mask =3D aic_irq_mask, + .irq_unmask =3D aic_irq_unmask, + .irq_eoi =3D aic_irq_eoi, + .irq_set_type =3D aic_irq_set_type, +}; + /* * FIQ irqchip */ @@ -529,10 +603,15 @@ static struct irq_chip fiq_chip =3D { static int aic_irq_domain_map(struct irq_domain *id, unsigned int irq, irq_hw_number_t hw) { + struct aic_irq_chip *ic =3D id->host_data; u32 type =3D FIELD_GET(AIC_EVENT_TYPE, hw); + struct irq_chip *chip =3D &aic_chip; + + if (ic->info.version =3D=3D 2) + chip =3D &aic2_chip; =20 if (type =3D=3D AIC_EVENT_TYPE_IRQ) { - irq_domain_set_info(id, irq, hw, &aic_chip, id->host_data, + irq_domain_set_info(id, irq, hw, chip, id->host_data, handle_fasteoi_irq, NULL, NULL); irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(irq))); } else { @@ -888,24 +967,26 @@ static int aic_init_cpu(unsigned int cpu) /* Commit all of the above */ isb(); =20 - /* - * Make sure the kernel's idea of logical CPU order is the same as AIC's - * If we ever end up with a mismatch here, we will have to introduce - * a mapping table similar to what other irqchip drivers do. - */ - WARN_ON(aic_ic_read(aic_irqc, AIC_WHOAMI) !=3D smp_processor_id()); + if (aic_irqc->info.version =3D=3D 1) { + /* + * Make sure the kernel's idea of logical CPU order is the same as AIC's + * If we ever end up with a mismatch here, we will have to introduce + * a mapping table similar to what other irqchip drivers do. + */ + WARN_ON(aic_ic_read(aic_irqc, AIC_WHOAMI) !=3D smp_processor_id()); =20 - /* - * Always keep IPIs unmasked at the hardware level (except auto-masking - * by AIC during processing). We manage masks at the vIPI level. - * These registers only exist on AICv1, AICv2 always uses fast IPIs. - */ - aic_ic_write(aic_irqc, AIC_IPI_ACK, AIC_IPI_SELF | AIC_IPI_OTHER); - if (static_branch_likely(&use_fast_ipi)) { - aic_ic_write(aic_irqc, AIC_IPI_MASK_SET, AIC_IPI_SELF | AIC_IPI_OTHER); - } else { - aic_ic_write(aic_irqc, AIC_IPI_MASK_SET, AIC_IPI_SELF); - aic_ic_write(aic_irqc, AIC_IPI_MASK_CLR, AIC_IPI_OTHER); + /* + * Always keep IPIs unmasked at the hardware level (except auto-masking + * by AIC during processing). We manage masks at the vIPI level. + * These registers only exist on AICv1, AICv2 always uses fast IPIs. + */ + aic_ic_write(aic_irqc, AIC_IPI_ACK, AIC_IPI_SELF | AIC_IPI_OTHER); + if (static_branch_likely(&use_fast_ipi)) { + aic_ic_write(aic_irqc, AIC_IPI_MASK_SET, AIC_IPI_SELF | AIC_IPI_OTHER); + } else { + aic_ic_write(aic_irqc, AIC_IPI_MASK_SET, AIC_IPI_SELF); + aic_ic_write(aic_irqc, AIC_IPI_MASK_CLR, AIC_IPI_OTHER); + } } =20 /* Initialize the local mask state */ @@ -933,14 +1014,16 @@ static int __init aic_of_ic_init(struct device_node = *node, struct device_node *p return -EIO; =20 irqc =3D kzalloc(sizeof(*irqc), GFP_KERNEL); - if (!irqc) + if (!irqc) { + iounmap(regs); return -ENOMEM; + } =20 irqc->base =3D regs; =20 match =3D of_match_node(aic_info_match, node); if (!match) - return -ENODEV; + goto err_unmap; =20 irqc->info =3D *(struct aic_info *)match->data; =20 @@ -958,6 +1041,28 @@ static int __init aic_of_ic_init(struct device_node *= node, struct device_node *p off =3D start_off =3D irqc->info.target_cpu; off +=3D sizeof(u32) * irqc->max_irq; /* TARGET_CPU */ =20 + irqc->event =3D irqc->base; + + break; + } + case 2: { + u32 info1, info3; + + info1 =3D aic_ic_read(irqc, AIC2_INFO1); + info3 =3D aic_ic_read(irqc, AIC2_INFO3); + + irqc->nr_irq =3D FIELD_GET(AIC2_INFO1_NR_IRQ, info1); + irqc->max_irq =3D FIELD_GET(AIC2_INFO3_MAX_IRQ, info3); + irqc->nr_die =3D FIELD_GET(AIC2_INFO1_LAST_DIE, info1) + 1; + irqc->max_die =3D FIELD_GET(AIC2_INFO3_MAX_DIE, info3); + + off =3D start_off =3D irqc->info.irq_cfg; + off +=3D sizeof(u32) * irqc->max_irq; /* IRQ_CFG */ + + irqc->event =3D of_iomap(node, 1); + if (WARN_ON(!irqc->event)) + goto err_unmap; + break; } } @@ -981,20 +1086,13 @@ static int __init aic_of_ic_init(struct device_node = *node, struct device_node *p =20 irqc->hw_domain =3D irq_domain_create_tree(of_node_to_fwnode(node), &aic_irq_domain_ops, irqc); - if (WARN_ON(!irqc->hw_domain)) { - iounmap(irqc->base); - kfree(irqc); - return -ENODEV; - } + if (WARN_ON(!irqc->hw_domain)) + goto err_unmap; =20 irq_domain_update_bus_token(irqc->hw_domain, DOMAIN_BUS_WIRED); =20 - if (aic_init_smp(irqc, node)) { - irq_domain_remove(irqc->hw_domain); - iounmap(irqc->base); - kfree(irqc); - return -ENODEV; - } + if (aic_init_smp(irqc, node)) + goto err_remove_domain; =20 set_handle_irq(aic_handle_irq); set_handle_fiq(aic_handle_fiq); @@ -1011,6 +1109,13 @@ static int __init aic_of_ic_init(struct device_node = *node, struct device_node *p off +=3D irqc->info.die_stride; } =20 + if (irqc->info.version =3D=3D 2) { + u32 config =3D aic_ic_read(irqc, AIC2_CONFIG); + + config |=3D AIC2_CONFIG_ENABLE; + aic_ic_write(irqc, AIC2_CONFIG, config); + } + if (!is_kernel_in_hyp_mode()) pr_info("Kernel running in EL1, mapping interrupts"); =20 @@ -1027,6 +1132,16 @@ static int __init aic_of_ic_init(struct device_node = *node, struct device_node *p irqc->nr_irq, irqc->max_irq, irqc->nr_die, irqc->max_die, AIC_NR_FIQ, AI= C_NR_SWIPI); =20 return 0; + +err_remove_domain: + irq_domain_remove(irqc->hw_domain); +err_unmap: + if (irqc->event && irqc->event !=3D irqc->base) + iounmap(irqc->event); + iounmap(irqc->base); + kfree(irqc); + return -ENODEV; } =20 -IRQCHIP_DECLARE(apple_m1_aic, "apple,aic", aic_of_ic_init); +IRQCHIP_DECLARE(apple_aic, "apple,aic", aic_of_ic_init); +IRQCHIP_DECLARE(apple_aic2, "apple,aic2", aic_of_ic_init); --=20 2.33.0