From: Marc Zyngier <maz@kernel.org> To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mark Rutland <mark.rutland@arm.com>, Will Deacon <will@kernel.org>, Hector Martin <marcan@marcan.st>, Sven Peter <sven@svenpeter.dev>, Alyssa Rosenzweig <alyssa@rosenzweig.io>, Rob Herring <robh+dt@kernel.org>, Thomas Gleixner <tglx@linutronix.de>, Dougall <dougallj@gmail.com>, kernel-team@android.com Subject: [PATCH v3 04/10] irqchip/apple-aic: Parse FIQ affinities from device-tree Date: Tue, 14 Dec 2021 18:26:28 +0000 [thread overview] Message-ID: <20211214182634.727330-5-maz@kernel.org> (raw) In-Reply-To: <20211214182634.727330-1-maz@kernel.org> In order to be able to tell the core IRQ code about the affinity of the PMU interrupt in later patches, parse the affinities kindly provided in the device-tree. Signed-off-by: Marc Zyngier <maz@kernel.org> --- drivers/irqchip/irq-apple-aic.c | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c index 2543ef65825b..b51eb9468701 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -177,6 +177,9 @@ struct aic_irq_chip { void __iomem *base; struct irq_domain *hw_domain; struct irq_domain *ipi_domain; + struct { + cpumask_t aff; + } *fiq_aff[AIC_NR_FIQ]; int nr_hw; int ipi_hwirq; }; @@ -794,12 +797,51 @@ static struct gic_kvm_info vgic_info __initdata = { .no_hw_deactivation = true, }; +static void build_fiq_affinity(struct aic_irq_chip *ic, struct device_node *aff) +{ + int i, n; + u32 fiq; + + if (of_property_read_u32(aff, "fiq-index", &fiq) || + WARN_ON(fiq >= AIC_NR_FIQ)) + return; + + n = of_property_count_elems_of_size(aff, "affinity", sizeof(u32)); + if (WARN_ON(n < 0)) + return; + + ic->fiq_aff[fiq] = kzalloc(sizeof(ic->fiq_aff[fiq]), GFP_KERNEL); + if (!ic->fiq_aff[fiq]) + return; + + for (i = 0; i < n; i++) { + struct device_node *cpu_node; + u32 cpu_phandle; + int cpu; + + if (of_property_read_u32_index(aff, "affinity", + i, &cpu_phandle)) + continue; + + cpu_node = of_find_node_by_phandle(cpu_phandle); + if (WARN_ON(!cpu_node)) + continue; + + cpu = of_cpu_node_to_id(cpu_node); + if (WARN_ON(cpu < 0)) + continue; + + cpumask_set_cpu(cpu, &ic->fiq_aff[fiq]->aff); + } +} + static int __init aic_of_ic_init(struct device_node *node, struct device_node *parent) { int i; void __iomem *regs; u32 info; struct aic_irq_chip *irqc; + struct device_node *affs; regs = of_iomap(node, 0); if (WARN_ON(!regs)) @@ -833,6 +875,14 @@ static int __init aic_of_ic_init(struct device_node *node, struct device_node *p return -ENODEV; } + affs = of_get_child_by_name(node, "affinities"); + if (affs) { + struct device_node *chld; + + for_each_child_of_node(affs, chld) + build_fiq_affinity(irqc, chld); + } + set_handle_irq(aic_handle_irq); set_handle_fiq(aic_handle_fiq); -- 2.30.2
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org> To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mark Rutland <mark.rutland@arm.com>, Will Deacon <will@kernel.org>, Hector Martin <marcan@marcan.st>, Sven Peter <sven@svenpeter.dev>, Alyssa Rosenzweig <alyssa@rosenzweig.io>, Rob Herring <robh+dt@kernel.org>, Thomas Gleixner <tglx@linutronix.de>, Dougall <dougallj@gmail.com>, kernel-team@android.com Subject: [PATCH v3 04/10] irqchip/apple-aic: Parse FIQ affinities from device-tree Date: Tue, 14 Dec 2021 18:26:28 +0000 [thread overview] Message-ID: <20211214182634.727330-5-maz@kernel.org> (raw) In-Reply-To: <20211214182634.727330-1-maz@kernel.org> In order to be able to tell the core IRQ code about the affinity of the PMU interrupt in later patches, parse the affinities kindly provided in the device-tree. Signed-off-by: Marc Zyngier <maz@kernel.org> --- drivers/irqchip/irq-apple-aic.c | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c index 2543ef65825b..b51eb9468701 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -177,6 +177,9 @@ struct aic_irq_chip { void __iomem *base; struct irq_domain *hw_domain; struct irq_domain *ipi_domain; + struct { + cpumask_t aff; + } *fiq_aff[AIC_NR_FIQ]; int nr_hw; int ipi_hwirq; }; @@ -794,12 +797,51 @@ static struct gic_kvm_info vgic_info __initdata = { .no_hw_deactivation = true, }; +static void build_fiq_affinity(struct aic_irq_chip *ic, struct device_node *aff) +{ + int i, n; + u32 fiq; + + if (of_property_read_u32(aff, "fiq-index", &fiq) || + WARN_ON(fiq >= AIC_NR_FIQ)) + return; + + n = of_property_count_elems_of_size(aff, "affinity", sizeof(u32)); + if (WARN_ON(n < 0)) + return; + + ic->fiq_aff[fiq] = kzalloc(sizeof(ic->fiq_aff[fiq]), GFP_KERNEL); + if (!ic->fiq_aff[fiq]) + return; + + for (i = 0; i < n; i++) { + struct device_node *cpu_node; + u32 cpu_phandle; + int cpu; + + if (of_property_read_u32_index(aff, "affinity", + i, &cpu_phandle)) + continue; + + cpu_node = of_find_node_by_phandle(cpu_phandle); + if (WARN_ON(!cpu_node)) + continue; + + cpu = of_cpu_node_to_id(cpu_node); + if (WARN_ON(cpu < 0)) + continue; + + cpumask_set_cpu(cpu, &ic->fiq_aff[fiq]->aff); + } +} + static int __init aic_of_ic_init(struct device_node *node, struct device_node *parent) { int i; void __iomem *regs; u32 info; struct aic_irq_chip *irqc; + struct device_node *affs; regs = of_iomap(node, 0); if (WARN_ON(!regs)) @@ -833,6 +875,14 @@ static int __init aic_of_ic_init(struct device_node *node, struct device_node *p return -ENODEV; } + affs = of_get_child_by_name(node, "affinities"); + if (affs) { + struct device_node *chld; + + for_each_child_of_node(affs, chld) + build_fiq_affinity(irqc, chld); + } + set_handle_irq(aic_handle_irq); set_handle_fiq(aic_handle_fiq); -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-12-14 18:27 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-14 18:26 [PATCH v3 00/10] drivers/perf: CPU PMU driver for Apple M1 Marc Zyngier 2021-12-14 18:26 ` Marc Zyngier 2021-12-14 18:26 ` [PATCH v3 01/10] dt-bindings: arm-pmu: Document Apple PMU compatible strings Marc Zyngier 2021-12-14 18:26 ` Marc Zyngier 2021-12-14 18:26 ` [PATCH v3 02/10] dt-bindings: apple,aic: Add CPU PMU per-cpu pseudo-interrupts Marc Zyngier 2021-12-14 18:26 ` [PATCH v3 02/10] dt-bindings: apple, aic: " Marc Zyngier 2021-12-14 18:26 ` [PATCH v3 03/10] dt-bindings: apple,aic: Add affinity description for " Marc Zyngier 2021-12-14 18:26 ` [PATCH v3 03/10] dt-bindings: apple, aic: " Marc Zyngier 2021-12-15 21:35 ` [PATCH v3 03/10] dt-bindings: apple,aic: " Rob Herring 2021-12-15 21:35 ` Rob Herring 2021-12-14 18:26 ` Marc Zyngier [this message] 2021-12-14 18:26 ` [PATCH v3 04/10] irqchip/apple-aic: Parse FIQ affinities from device-tree Marc Zyngier 2021-12-14 18:26 ` [PATCH v3 05/10] irqchip/apple-aic: Wire PMU interrupts Marc Zyngier 2021-12-14 18:26 ` Marc Zyngier 2021-12-14 18:26 ` [PATCH v3 06/10] arm64: dts: apple: Add t8103 PMU interrupt affinities Marc Zyngier 2021-12-14 18:26 ` Marc Zyngier 2021-12-14 18:26 ` [PATCH v3 07/10] arm64: dts: apple: Add t8301 PMU nodes Marc Zyngier 2021-12-14 18:26 ` Marc Zyngier 2021-12-14 18:48 ` Alyssa Rosenzweig 2021-12-14 18:48 ` Alyssa Rosenzweig 2021-12-14 18:26 ` [PATCH v3 08/10] irqchip/apple-aic: Move PMU-specific registers to their own include file Marc Zyngier 2021-12-14 18:26 ` Marc Zyngier 2021-12-14 18:26 ` [PATCH v3 09/10] drivers/perf: arm_pmu: Handle 47 bit counters Marc Zyngier 2021-12-14 18:26 ` Marc Zyngier 2021-12-14 18:26 ` [PATCH v3 10/10] drivers/perf: Add Apple icestorm/firestorm CPU PMU driver Marc Zyngier 2021-12-14 18:26 ` Marc Zyngier
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211214182634.727330-5-maz@kernel.org \ --to=maz@kernel.org \ --cc=alyssa@rosenzweig.io \ --cc=devicetree@vger.kernel.org \ --cc=dougallj@gmail.com \ --cc=kernel-team@android.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=marcan@marcan.st \ --cc=mark.rutland@arm.com \ --cc=robh+dt@kernel.org \ --cc=sven@svenpeter.dev \ --cc=tglx@linutronix.de \ --cc=will@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.