summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c
diff options
context:
space:
mode:
authorTao Zhou <tao.zhou1@amd.com>2025-02-10 15:28:37 +0800
committerAlex Deucher <alexander.deucher@amd.com>2025-02-17 14:09:30 -0500
commit8652920d2c00243e8a8ca91560a30488d95d9a1b (patch)
treecad8dfb258ce2aed4acf7a90c804787812d22aeb /drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c
parentb1118df145faab925637da0e02c53e8b3072699a (diff)
downloadlinux-stable-8652920d2c00243e8a8ca91560a30488d95d9a1b.tar.gz
linux-stable-8652920d2c00243e8a8ca91560a30488d95d9a1b.tar.bz2
linux-stable-8652920d2c00243e8a8ca91560a30488d95d9a1b.zip
drm/amdgpu: add mutex lock for cper ring
Avoid the confliction between read and write of ring buffer. Signed-off-by: Tao Zhou <tao.zhou1@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c
index b70cf13aa9c0..57775546e64b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c
@@ -440,6 +440,7 @@ void amdgpu_cper_ring_write(struct amdgpu_ring *ring,
wptr_old = ring->wptr;
+ mutex_lock(&ring->adev->cper.ring_lock);
while (count) {
ent_sz = amdgpu_cper_ring_get_ent_sz(ring, ring->wptr);
chunk = umin(ent_sz, count);
@@ -468,6 +469,7 @@ void amdgpu_cper_ring_write(struct amdgpu_ring *ring,
pos = rptr;
} while (!amdgpu_cper_is_hdr(ring, rptr));
}
+ mutex_unlock(&ring->adev->cper.ring_lock);
if (ring->count_dw >= (count >> 2))
ring->count_dw -= (count >> 2);
@@ -497,6 +499,8 @@ static int amdgpu_cper_ring_init(struct amdgpu_device *adev)
{
struct amdgpu_ring *ring = &(adev->cper.ring_buf);
+ mutex_init(&adev->cper.ring_lock);
+
ring->adev = NULL;
ring->ring_obj = NULL;
ring->use_doorbell = false;