From f9c68b9c62f651652bfe6cbe7de0f1c18effd63e Mon Sep 17 00:00:00 2001 From: Leon Silcott Date: Thu, 3 Sep 2026 09:46:02 +0100 Subject: [PATCH] dmaengine: qcom: gpi: order event ring pointer reads The device writes event elements into coherent memory before publishing its event ring read pointer. Both gpi_process_events() and gpi_mark_stale_events() read that pointer through readl_relaxed() and then consume the event memory without an ordering guarantee. On architectures such as arm64, this can expose a published event before all its fields are visible. Denali QSPI exposed this as an accepted completion whose length was observed as zero. Use ordered MMIO reads only for the event pointer. Keep all other register accesses relaxed. This follows the ordered ioread32() pattern used by the Qualcomm IPA GSI event-ring consumer. Fixes: 5d0c3533a19f ("dmaengine: qcom: Add GPI dma driver") Signed-off-by: Leon Silcott (cherry picked from commit bd9f5e29b2a8f865d73ec3f6f641ee66e914bb7b) --- drivers/dma/qcom/gpi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c index b7678b174ecfa6..47bebc5bfa3757 100644 --- a/drivers/dma/qcom/gpi.c +++ b/drivers/dma/qcom/gpi.c @@ -662,8 +662,14 @@ static inline u32 gpi_read_reg(struct gpii *gpii, void __iomem *addr) static phys_addr_t gpi_read_ev_rp(struct gpii *gpii) { - u32 lsb = gpi_read_reg(gpii, gpii->ev_ring_rp_lsb_reg); - u32 msb; + u32 lsb, msb; + + /* + * The event read pointer publishes entries written by the device into + * coherent memory. Use ordered MMIO reads so those writes are visible + * before the caller consumes an event from the ring. + */ + lsb = readl(gpii->ev_ring_rp_lsb_reg); /* * Denali publishes and may inspect the event ring before either QSPI @@ -674,7 +680,7 @@ static phys_addr_t gpi_read_ev_rp(struct gpii *gpii) if (!gpii_has_denali_qspi(gpii)) return lsb; - msb = gpi_read_reg(gpii, gpii->ev_ring_rp_lsb_reg + 4); + msb = readl(gpii->ev_ring_rp_lsb_reg + 4); return ((phys_addr_t)msb << 32) | lsb; }