Skip to content

Commit 005c34a

Browse files
author
Marc Zyngier
committed
irqchip/gic: Atomically update affinity
The GIC driver uses a RMW sequence to update the affinity, and relies on the gic_lock_irqsave/gic_unlock_irqrestore sequences to update it atomically. But these sequences only expand into anything meaningful if the BL_SWITCHER option is selected, which almost never happens. It also turns out that using a RMW and locks is just as silly, as the GIC distributor supports byte accesses for the GICD_TARGETRn registers, which when used make the update atomic by definition. Drop the terminally broken code and replace it by a byte write. Fixes: 04c8b0f ("irqchip/gic: Make locking a BL_SWITCHER only feature") Cc: [email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 559fe74 commit 005c34a

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

drivers/irqchip/irq-gic.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,8 @@ static int gic_irq_set_vcpu_affinity(struct irq_data *d, void *vcpu)
329329
static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
330330
bool force)
331331
{
332-
void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + (gic_irq(d) & ~3);
333-
unsigned int cpu, shift = (gic_irq(d) % 4) * 8;
334-
u32 val, mask, bit;
335-
unsigned long flags;
332+
void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + gic_irq(d);
333+
unsigned int cpu;
336334

337335
if (!force)
338336
cpu = cpumask_any_and(mask_val, cpu_online_mask);
@@ -342,13 +340,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
342340
if (cpu >= NR_GIC_CPU_IF || cpu >= nr_cpu_ids)
343341
return -EINVAL;
344342

345-
gic_lock_irqsave(flags);
346-
mask = 0xff << shift;
347-
bit = gic_cpu_map[cpu] << shift;
348-
val = readl_relaxed(reg) & ~mask;
349-
writel_relaxed(val | bit, reg);
350-
gic_unlock_irqrestore(flags);
351-
343+
writeb_relaxed(gic_cpu_map[cpu], reg);
352344
irq_data_update_effective_affinity(d, cpumask_of(cpu));
353345

354346
return IRQ_SET_MASK_OK_DONE;

0 commit comments

Comments
 (0)