Skip to content

Commit 5a14282

Browse files
Tao Zhoualexdeucher
authored andcommitted
drm/amdgpu: read CPER ring via debugfs
We read CPER data from read pointer to write pointer without changing the pointers. Signed-off-by: Tao Zhou <[email protected]> Reviewed-by: Hawking Zhang <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 4d614ce commit 5a14282

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

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

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf,
500500
{
501501
struct amdgpu_ring *ring = file_inode(f)->i_private;
502502
uint32_t value, result, early[3];
503+
uint64_t p;
503504
loff_t i;
504505
int r;
505506

@@ -523,18 +524,42 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf,
523524
}
524525
}
525526

526-
while (size) {
527-
if (*pos >= (ring->ring_size + 12))
528-
return result;
527+
if (ring->funcs->type != AMDGPU_RING_TYPE_CPER) {
528+
while (size) {
529+
if (*pos >= (ring->ring_size + 12))
530+
return result;
529531

530-
value = ring->ring[(*pos - 12)/4];
531-
r = put_user(value, (uint32_t *)buf);
532-
if (r)
533-
return r;
534-
buf += 4;
535-
result += 4;
536-
size -= 4;
537-
*pos += 4;
532+
value = ring->ring[(*pos - 12)/4];
533+
r = put_user(value, (uint32_t *)buf);
534+
if (r)
535+
return r;
536+
buf += 4;
537+
result += 4;
538+
size -= 4;
539+
*pos += 4;
540+
}
541+
} else {
542+
p = early[0];
543+
if (early[0] <= early[1])
544+
size = (early[1] - early[0]);
545+
else
546+
size = ring->ring_size - (early[0] - early[1]);
547+
548+
while (size) {
549+
if (p == early[1])
550+
return result;
551+
552+
value = ring->ring[p];
553+
r = put_user(value, (uint32_t *)buf);
554+
if (r)
555+
return r;
556+
557+
buf += 4;
558+
result += 4;
559+
size--;
560+
p++;
561+
p &= ring->ptr_mask;
562+
}
538563
}
539564

540565
return result;

0 commit comments

Comments
 (0)