Skip to content

Commit 8e0d1ed

Browse files
Yang Wangalexdeucher
authored andcommitted
drm/amd/amdgpu: fix missing lock for cper.ring->rptr/wptr access
Add lock protection for 'ring->wptr'/'ring->rptr' to ensure the correct execution. Fixes: 8652920 ("drm/amdgpu: add mutex lock for cper ring") Signed-off-by: Yang Wang <[email protected]> Reviewed-by: Tao Zhou <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent dfe9707 commit 8e0d1ed

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ static u32 amdgpu_cper_ring_get_ent_sz(struct amdgpu_ring *ring, u64 pos)
459459

460460
void amdgpu_cper_ring_write(struct amdgpu_ring *ring, void *src, int count)
461461
{
462-
u64 pos, wptr_old, rptr = *ring->rptr_cpu_addr & ring->ptr_mask;
462+
u64 pos, wptr_old, rptr;
463463
int rec_cnt_dw = count >> 2;
464464
u32 chunk, ent_sz;
465465
u8 *s = (u8 *)src;
@@ -472,9 +472,11 @@ void amdgpu_cper_ring_write(struct amdgpu_ring *ring, void *src, int count)
472472
return;
473473
}
474474

475+
mutex_lock(&ring->adev->cper.ring_lock);
476+
475477
wptr_old = ring->wptr;
478+
rptr = *ring->rptr_cpu_addr & ring->ptr_mask;
476479

477-
mutex_lock(&ring->adev->cper.ring_lock);
478480
while (count) {
479481
ent_sz = amdgpu_cper_ring_get_ent_sz(ring, ring->wptr);
480482
chunk = umin(ent_sz, count);

0 commit comments

Comments
 (0)