Skip to content

Commit a5e8801

Browse files
author
Marc Zyngier
committed
irqchip/apple-aic: Parse FIQ affinities from device-tree
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>
1 parent dba07ad commit a5e8801

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

drivers/irqchip/irq-apple-aic.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ struct aic_irq_chip {
177177
void __iomem *base;
178178
struct irq_domain *hw_domain;
179179
struct irq_domain *ipi_domain;
180+
struct {
181+
cpumask_t aff;
182+
} *fiq_aff[AIC_NR_FIQ];
180183
int nr_hw;
181184
};
182185

@@ -793,12 +796,50 @@ static struct gic_kvm_info vgic_info __initdata = {
793796
.no_hw_deactivation = true,
794797
};
795798

799+
static void build_fiq_affinity(struct aic_irq_chip *ic, struct device_node *aff)
800+
{
801+
int i, n;
802+
u32 fiq;
803+
804+
if (of_property_read_u32(aff, "apple,fiq-index", &fiq) ||
805+
WARN_ON(fiq >= AIC_NR_FIQ) || ic->fiq_aff[fiq])
806+
return;
807+
808+
n = of_property_count_elems_of_size(aff, "cpus", sizeof(u32));
809+
if (WARN_ON(n < 0))
810+
return;
811+
812+
ic->fiq_aff[fiq] = kzalloc(sizeof(ic->fiq_aff[fiq]), GFP_KERNEL);
813+
if (!ic->fiq_aff[fiq])
814+
return;
815+
816+
for (i = 0; i < n; i++) {
817+
struct device_node *cpu_node;
818+
u32 cpu_phandle;
819+
int cpu;
820+
821+
if (of_property_read_u32_index(aff, "cpus", i, &cpu_phandle))
822+
continue;
823+
824+
cpu_node = of_find_node_by_phandle(cpu_phandle);
825+
if (WARN_ON(!cpu_node))
826+
continue;
827+
828+
cpu = of_cpu_node_to_id(cpu_node);
829+
if (WARN_ON(cpu < 0))
830+
continue;
831+
832+
cpumask_set_cpu(cpu, &ic->fiq_aff[fiq]->aff);
833+
}
834+
}
835+
796836
static int __init aic_of_ic_init(struct device_node *node, struct device_node *parent)
797837
{
798838
int i;
799839
void __iomem *regs;
800840
u32 info;
801841
struct aic_irq_chip *irqc;
842+
struct device_node *affs;
802843

803844
regs = of_iomap(node, 0);
804845
if (WARN_ON(!regs))
@@ -832,6 +873,14 @@ static int __init aic_of_ic_init(struct device_node *node, struct device_node *p
832873
return -ENODEV;
833874
}
834875

876+
affs = of_get_child_by_name(node, "affinities");
877+
if (affs) {
878+
struct device_node *chld;
879+
880+
for_each_child_of_node(affs, chld)
881+
build_fiq_affinity(irqc, chld);
882+
}
883+
835884
set_handle_irq(aic_handle_irq);
836885
set_handle_fiq(aic_handle_fiq);
837886

0 commit comments

Comments
 (0)