mirror of https://gitee.com/openkylin/linux.git
drm/amd/amdgpu: Convert ring debugfs entries to binary
They now emit ring data in binary which will be read/written by the userspace tool umr shortly. Signed-off-by: Tom St Denis <tom.stdenis@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
8491999285
commit
4f4824b556
|
@ -28,6 +28,7 @@
|
||||||
*/
|
*/
|
||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/debugfs.h>
|
||||||
#include <drm/drmP.h>
|
#include <drm/drmP.h>
|
||||||
#include <drm/amdgpu_drm.h>
|
#include <drm/amdgpu_drm.h>
|
||||||
#include "amdgpu.h"
|
#include "amdgpu.h"
|
||||||
|
@ -368,57 +369,62 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring)
|
||||||
*/
|
*/
|
||||||
#if defined(CONFIG_DEBUG_FS)
|
#if defined(CONFIG_DEBUG_FS)
|
||||||
|
|
||||||
static int amdgpu_debugfs_ring_info(struct seq_file *m, void *data)
|
/* Layout of file is 12 bytes consisting of
|
||||||
|
* - rptr
|
||||||
|
* - wptr
|
||||||
|
* - driver's copy of wptr
|
||||||
|
*
|
||||||
|
* followed by n-words of ring data
|
||||||
|
*/
|
||||||
|
static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf,
|
||||||
|
size_t size, loff_t *pos)
|
||||||
{
|
{
|
||||||
struct drm_info_node *node = (struct drm_info_node *) m->private;
|
struct amdgpu_ring *ring = (struct amdgpu_ring*)f->f_inode->i_private;
|
||||||
struct drm_device *dev = node->minor->dev;
|
int r, i;
|
||||||
struct amdgpu_device *adev = dev->dev_private;
|
uint32_t value, result, early[3];
|
||||||
int roffset = (unsigned long)node->info_ent->data;
|
|
||||||
struct amdgpu_ring *ring = (void *)(((uint8_t*)adev) + roffset);
|
|
||||||
uint32_t rptr, wptr, rptr_next;
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
wptr = amdgpu_ring_get_wptr(ring);
|
if (*pos & 3)
|
||||||
seq_printf(m, "wptr: 0x%08x [%5d]\n", wptr, wptr);
|
return -EINVAL;
|
||||||
|
|
||||||
rptr = amdgpu_ring_get_rptr(ring);
|
result = 0;
|
||||||
rptr_next = le32_to_cpu(*ring->next_rptr_cpu_addr);
|
|
||||||
|
|
||||||
seq_printf(m, "rptr: 0x%08x [%5d]\n", rptr, rptr);
|
if (*pos < 12) {
|
||||||
|
early[0] = amdgpu_ring_get_rptr(ring);
|
||||||
seq_printf(m, "driver's copy of the wptr: 0x%08x [%5d]\n",
|
early[1] = amdgpu_ring_get_wptr(ring);
|
||||||
ring->wptr, ring->wptr);
|
early[2] = ring->wptr;
|
||||||
|
for (i = *pos / 4; i < 3 && size; i++) {
|
||||||
if (!ring->ready)
|
r = put_user(early[i], (uint32_t *)buf);
|
||||||
return 0;
|
if (r)
|
||||||
|
return r;
|
||||||
/* print 8 dw before current rptr as often it's the last executed
|
buf += 4;
|
||||||
* packet that is the root issue
|
result += 4;
|
||||||
*/
|
size -= 4;
|
||||||
i = (rptr + ring->ptr_mask + 1 - 32) & ring->ptr_mask;
|
*pos += 4;
|
||||||
while (i != rptr) {
|
}
|
||||||
seq_printf(m, "r[%5d]=0x%08x", i, ring->ring[i]);
|
|
||||||
if (i == rptr)
|
|
||||||
seq_puts(m, " *");
|
|
||||||
if (i == rptr_next)
|
|
||||||
seq_puts(m, " #");
|
|
||||||
seq_puts(m, "\n");
|
|
||||||
i = (i + 1) & ring->ptr_mask;
|
|
||||||
}
|
}
|
||||||
while (i != wptr) {
|
|
||||||
seq_printf(m, "r[%5d]=0x%08x", i, ring->ring[i]);
|
while (size) {
|
||||||
if (i == rptr)
|
if (*pos >= (ring->ring_size + 12))
|
||||||
seq_puts(m, " *");
|
return result;
|
||||||
if (i == rptr_next)
|
|
||||||
seq_puts(m, " #");
|
value = ring->ring[(*pos - 12)/4];
|
||||||
seq_puts(m, "\n");
|
r = put_user(value, (uint32_t*)buf);
|
||||||
i = (i + 1) & ring->ptr_mask;
|
if (r)
|
||||||
|
return r;
|
||||||
|
buf += 4;
|
||||||
|
result += 4;
|
||||||
|
size -= 4;
|
||||||
|
*pos += 4;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct drm_info_list amdgpu_debugfs_ring_info_list[AMDGPU_MAX_RINGS];
|
static const struct file_operations amdgpu_debugfs_ring_fops = {
|
||||||
static char amdgpu_debugfs_ring_names[AMDGPU_MAX_RINGS][32];
|
.owner = THIS_MODULE,
|
||||||
|
.read = amdgpu_debugfs_ring_read,
|
||||||
|
.llseek = default_llseek
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -426,28 +432,19 @@ static int amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
|
||||||
struct amdgpu_ring *ring)
|
struct amdgpu_ring *ring)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_DEBUG_FS)
|
#if defined(CONFIG_DEBUG_FS)
|
||||||
unsigned offset = (uint8_t*)ring - (uint8_t*)adev;
|
struct drm_minor *minor = adev->ddev->primary;
|
||||||
unsigned i;
|
struct dentry *ent, *root = minor->debugfs_root;
|
||||||
struct drm_info_list *info;
|
char name[32];
|
||||||
char *name;
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(amdgpu_debugfs_ring_info_list); ++i) {
|
|
||||||
info = &amdgpu_debugfs_ring_info_list[i];
|
|
||||||
if (!info->data)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == ARRAY_SIZE(amdgpu_debugfs_ring_info_list))
|
|
||||||
return -ENOSPC;
|
|
||||||
|
|
||||||
name = &amdgpu_debugfs_ring_names[i][0];
|
|
||||||
sprintf(name, "amdgpu_ring_%s", ring->name);
|
sprintf(name, "amdgpu_ring_%s", ring->name);
|
||||||
info->name = name;
|
|
||||||
info->show = amdgpu_debugfs_ring_info;
|
|
||||||
info->driver_features = 0;
|
|
||||||
info->data = (void*)(uintptr_t)offset;
|
|
||||||
|
|
||||||
return amdgpu_debugfs_add_files(adev, info, 1);
|
ent = debugfs_create_file(name,
|
||||||
|
S_IFREG | S_IRUGO, root,
|
||||||
|
ring, &amdgpu_debugfs_ring_fops);
|
||||||
|
if (IS_ERR(ent))
|
||||||
|
return PTR_ERR(ent);
|
||||||
|
|
||||||
|
i_size_write(ent->d_inode, ring->ring_size + 12);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue