Skip to content

Commit 70f694e

Browse files
akhilpo-qcomgregkh
authored andcommitted
drm/msm/a6xx: Use barriers while updating HFI Q headers
[ Upstream commit dc78b35 ] To avoid harmful compiler optimizations and IO reordering in the HW, use barriers and READ/WRITE_ONCE helpers as necessary while accessing the HFI queue index variables. Fixes: 4b565ca ("drm/msm: Add A6XX device support") Signed-off-by: Akhil P Oommen <akhilpo@oss.qualcomm.com> Patchwork: https://patchwork.freedesktop.org/patch/714653/ Message-ID: <20260327-a8xx-gpu-batch2-v2-1-2b53c38d2101@oss.qualcomm.com> Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4180d90 commit 70f694e

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

drivers/gpu/drm/msm/adreno/a6xx_hfi.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int a6xx_hfi_queue_read(struct a6xx_gmu *gmu,
3333
struct a6xx_hfi_queue_header *header = queue->header;
3434
u32 i, hdr, index = header->read_index;
3535

36-
if (header->read_index == header->write_index) {
36+
if (header->read_index == READ_ONCE(header->write_index)) {
3737
header->rx_request = 1;
3838
return 0;
3939
}
@@ -61,7 +61,10 @@ static int a6xx_hfi_queue_read(struct a6xx_gmu *gmu,
6161
if (!gmu->legacy)
6262
index = ALIGN(index, 4) % header->size;
6363

64-
header->read_index = index;
64+
/* Ensure all memory operations are complete before updating the read index */
65+
dma_mb();
66+
67+
WRITE_ONCE(header->read_index, index);
6568
return HFI_HEADER_SIZE(hdr);
6669
}
6770

@@ -73,7 +76,7 @@ static int a6xx_hfi_queue_write(struct a6xx_gmu *gmu,
7376

7477
spin_lock(&queue->lock);
7578

76-
space = CIRC_SPACE(header->write_index, header->read_index,
79+
space = CIRC_SPACE(header->write_index, READ_ONCE(header->read_index),
7780
header->size);
7881
if (space < dwords) {
7982
header->dropped++;
@@ -94,7 +97,10 @@ static int a6xx_hfi_queue_write(struct a6xx_gmu *gmu,
9497
queue->data[index] = 0xfafafafa;
9598
}
9699

97-
header->write_index = index;
100+
/* Ensure all memory operations are complete before updating the write index */
101+
dma_mb();
102+
103+
WRITE_ONCE(header->write_index, index);
98104
spin_unlock(&queue->lock);
99105

100106
gmu_write(gmu, REG_A6XX_GMU_HOST2GMU_INTR_SET, 0x01);

0 commit comments

Comments
 (0)