diff options
| author | Tao Zhou <[email protected]> | 2025-02-10 07:28:37 +0000 |
|---|---|---|
| committer | Alex Deucher <[email protected]> | 2025-02-17 19:09:30 +0000 |
| commit | 8652920d2c00243e8a8ca91560a30488d95d9a1b (patch) | |
| tree | cad8dfb258ce2aed4acf7a90c804787812d22aeb /drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | |
| parent | drm/amd/pm: Limit jpeg rings as per max for jpeg_v_4_0_3 (diff) | |
| download | kernel-8652920d2c00243e8a8ca91560a30488d95d9a1b.tar.gz kernel-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 <[email protected]>
Reviewed-by: Hawking Zhang <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index cb92d41e0ae6..f53887e2f528 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c @@ -510,13 +510,18 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf, result = 0; if (*pos < 12) { + if (ring->funcs->type == AMDGPU_RING_TYPE_CPER) + mutex_lock(&ring->adev->cper.ring_lock); + early[0] = amdgpu_ring_get_rptr(ring) & ring->buf_mask; early[1] = amdgpu_ring_get_wptr(ring) & ring->buf_mask; early[2] = ring->wptr & ring->buf_mask; for (i = *pos / 4; i < 3 && size; i++) { r = put_user(early[i], (uint32_t *)buf); - if (r) - return r; + if (r) { + result = r; + goto out; + } buf += 4; result += 4; size -= 4; @@ -547,12 +552,14 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf, while (size) { if (p == early[1]) - return result; + goto out; value = ring->ring[p]; r = put_user(value, (uint32_t *)buf); - if (r) - return r; + if (r) { + result = r; + goto out; + } buf += 4; result += 4; @@ -562,6 +569,10 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf, } } +out: + if (ring->funcs->type == AMDGPU_RING_TYPE_CPER) + mutex_unlock(&ring->adev->cper.ring_lock); + return result; } |
