#
10e3685f |
| 19-Feb-2021 |
Alexandru Elisei <alexandru.elisei@arm.com> |
lib: arm/arm64: gicv2: Document existing barriers when sending IPIs
GICv2 generates IPIs with a MMIO write to the GICD_SGIR register. A common pattern for IPI usage is for the IPI receiver to read d
lib: arm/arm64: gicv2: Document existing barriers when sending IPIs
GICv2 generates IPIs with a MMIO write to the GICD_SGIR register. A common pattern for IPI usage is for the IPI receiver to read data written to memory by the sender. The armv7 and armv8 architectures implement a weakly-ordered memory model, which means that barriers are required to make sure that the expected values are observed.
Because the receiver CPU must observe the write to memory that generated the IPI when reading the GICC_IAR MMIO register, we only need to ensure ordering of memory accesses, and not completion. The same pattern can be observed in the Linux GICv2 irqchip driver (more details in commit 8adbf57fc429 ("irqchip: gic: use dmb ishst instead of dsb when raising a softirq")).
However, it turns out that no changes are needed to the way GICv2 sends IPIs because of the implicit barriers in the MMIO writel and readl functions. Writel executes a wmb() (DST ST) before the MMIO write, and readl executes a rmb() (DST LD) after the MMIO read. According to ARM DDI 0406C.d and ARM DDI 0487F.b, the DSB instruction:
"[..] acts as a stronger barrier than a DMB and all ordering that is created by a DMB with specific options is also generated by a DSB with the same options."
which means that the correct memory ordering is enforced.
It's not immediately obvious that the proper barriers are in place, so add a comment explaining that correct memory synchronization is implemented.
Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Signed-off-by: Andrew Jones <drjones@redhat.com>
show more ...
|