drm/amdgpu: add debugfs interface for reading MQDs
Provide a debugfs interface to access the MQD. Useful for debugging issues with the CP and MES hardware scheduler. v2: fix missing unreserve/unmap when pos >= size (Alex) Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
b185c31847
commit
445d85e3c1
1 changed files with 59 additions and 0 deletions
|
@ -509,6 +509,59 @@ static const struct file_operations amdgpu_debugfs_ring_fops = {
|
||||||
.llseek = default_llseek
|
.llseek = default_llseek
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static ssize_t amdgpu_debugfs_mqd_read(struct file *f, char __user *buf,
|
||||||
|
size_t size, loff_t *pos)
|
||||||
|
{
|
||||||
|
struct amdgpu_ring *ring = file_inode(f)->i_private;
|
||||||
|
volatile u32 *mqd;
|
||||||
|
int r;
|
||||||
|
uint32_t value, result;
|
||||||
|
|
||||||
|
if (*pos & 3 || size & 3)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
r = amdgpu_bo_reserve(ring->mqd_obj, false);
|
||||||
|
if (unlikely(r != 0))
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&mqd);
|
||||||
|
if (r) {
|
||||||
|
amdgpu_bo_unreserve(ring->mqd_obj);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (size) {
|
||||||
|
if (*pos >= ring->mqd_size)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
value = mqd[*pos/4];
|
||||||
|
r = put_user(value, (uint32_t *)buf);
|
||||||
|
if (r)
|
||||||
|
goto done;
|
||||||
|
buf += 4;
|
||||||
|
result += 4;
|
||||||
|
size -= 4;
|
||||||
|
*pos += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
amdgpu_bo_kunmap(ring->mqd_obj);
|
||||||
|
mqd = NULL;
|
||||||
|
amdgpu_bo_unreserve(ring->mqd_obj);
|
||||||
|
if (r)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct file_operations amdgpu_debugfs_mqd_fops = {
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.read = amdgpu_debugfs_mqd_read,
|
||||||
|
.llseek = default_llseek
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
|
void amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
|
||||||
|
@ -524,6 +577,12 @@ void amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
|
||||||
&amdgpu_debugfs_ring_fops,
|
&amdgpu_debugfs_ring_fops,
|
||||||
ring->ring_size + 12);
|
ring->ring_size + 12);
|
||||||
|
|
||||||
|
if (ring->mqd_obj) {
|
||||||
|
sprintf(name, "amdgpu_mqd_%s", ring->name);
|
||||||
|
debugfs_create_file_size(name, S_IFREG | S_IRUGO, root, ring,
|
||||||
|
&amdgpu_debugfs_mqd_fops,
|
||||||
|
ring->mqd_size);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue