Skip to content

Commit 9058a4e

Browse files
author
Marc Zyngier
committed
irqchip/gic-v4.1: Ensure mutual exclusion betwen invalidations on the same RD
The GICv4.1 spec says that it is CONTRAINED UNPREDICTABLE to write to any of the GICR_INV{LPI,ALL}R registers if GICR_SYNCR.Busy == 1. To deal with it, we must ensure that only a single invalidation can happen at a time for a given redistributor. Add a per-RD lock to that effect and take it around the invalidation/syncr-read to deal with this. Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Zenghui Yu <yuzenghui@huawei.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Link: https://lore.kernel.org/r/20200304203330.4967-6-maz@kernel.org
1 parent b978c25 commit 9058a4e

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎drivers/irqchip/irq-gic-v3-its.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,10 +1373,12 @@ static void direct_lpi_inv(struct irq_data *d)
13731373

13741374
/* Target the redistributor this LPI is currently routed to */
13751375
cpu = irq_to_cpuid_lock(d, &flags);
1376+
raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock);
13761377
rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base;
13771378
gic_write_lpir(val, rdbase + GICR_INVLPIR);
13781379

13791380
wait_for_syncr(rdbase);
1381+
raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock);
13801382
irq_to_cpuid_unlock(d, flags);
13811383
}
13821384

@@ -3662,9 +3664,11 @@ static void its_vpe_send_inv(struct irq_data *d)
36623664
void __iomem *rdbase;
36633665

36643666
/* Target the redistributor this VPE is currently known on */
3667+
raw_spin_lock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
36653668
rdbase = per_cpu_ptr(gic_rdists->rdist, vpe->col_idx)->rd_base;
36663669
gic_write_lpir(d->parent_data->hwirq, rdbase + GICR_INVLPIR);
36673670
wait_for_syncr(rdbase);
3671+
raw_spin_unlock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
36683672
} else {
36693673
its_vpe_send_cmd(vpe, its_send_inv);
36703674
}
@@ -3825,10 +3829,12 @@ static void its_vpe_4_1_invall(struct its_vpe *vpe)
38253829
val |= FIELD_PREP(GICR_INVALLR_VPEID, vpe->vpe_id);
38263830

38273831
/* Target the redistributor this vPE is currently known on */
3832+
raw_spin_lock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
38283833
rdbase = per_cpu_ptr(gic_rdists->rdist, vpe->col_idx)->rd_base;
38293834
gic_write_lpir(val, rdbase + GICR_INVALLR);
38303835

38313836
wait_for_syncr(rdbase);
3837+
raw_spin_unlock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
38323838
}
38333839

38343840
static int its_vpe_4_1_set_vcpu_affinity(struct irq_data *d, void *vcpu_info)

‎drivers/irqchip/irq-gic-v3.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr)
834834
typer = gic_read_typer(ptr + GICR_TYPER);
835835
if ((typer >> 32) == aff) {
836836
u64 offset = ptr - region->redist_base;
837+
raw_spin_lock_init(&gic_data_rdist()->rd_lock);
837838
gic_data_rdist_rd_base() = ptr;
838839
gic_data_rdist()->phys_base = region->phys_base + offset;
839840

‎include/linux/irqchip/arm-gic-v3.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@
652652

653653
struct rdists {
654654
struct {
655+
raw_spinlock_t rd_lock;
655656
void __iomem *rd_base;
656657
struct page *pend_page;
657658
phys_addr_t phys_base;

0 commit comments

Comments
 (0)