drm/nouveau: debugfs: implement DRM GPU VA debugfs
authorDanilo Krummrich <dakr@redhat.com>
Fri, 4 Aug 2023 18:23:52 +0000 (20:23 +0200)
committerDanilo Krummrich <dakr@redhat.com>
Fri, 4 Aug 2023 18:34:45 +0000 (20:34 +0200)
Provide the driver indirection iterating over all DRM GPU VA spaces to
enable the common 'gpuvas' debugfs file for dumping DRM GPU VA spaces.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230804182406.5222-13-dakr@redhat.com
drivers/gpu/drm/nouveau/nouveau_debugfs.c

index 99d022a91afc565a9ee9e3bf584369e64ba81ec1..053f703f2f68d73a8bb7b2357735cfa77c2d9a63 100644 (file)
@@ -203,6 +203,44 @@ nouveau_debugfs_pstate_open(struct inode *inode, struct file *file)
        return single_open(file, nouveau_debugfs_pstate_get, inode->i_private);
 }
 
+static void
+nouveau_debugfs_gpuva_regions(struct seq_file *m, struct nouveau_uvmm *uvmm)
+{
+       MA_STATE(mas, &uvmm->region_mt, 0, 0);
+       struct nouveau_uvma_region *reg;
+
+       seq_puts  (m, " VA regions  | start              | range              | end                \n");
+       seq_puts  (m, "----------------------------------------------------------------------------\n");
+       mas_for_each(&mas, reg, ULONG_MAX)
+               seq_printf(m, "             | 0x%016llx | 0x%016llx | 0x%016llx\n",
+                          reg->va.addr, reg->va.range, reg->va.addr + reg->va.range);
+}
+
+static int
+nouveau_debugfs_gpuva(struct seq_file *m, void *data)
+{
+       struct drm_info_node *node = (struct drm_info_node *) m->private;
+       struct nouveau_drm *drm = nouveau_drm(node->minor->dev);
+       struct nouveau_cli *cli;
+
+       mutex_lock(&drm->clients_lock);
+       list_for_each_entry(cli, &drm->clients, head) {
+               struct nouveau_uvmm *uvmm = nouveau_cli_uvmm(cli);
+
+               if (!uvmm)
+                       continue;
+
+               nouveau_uvmm_lock(uvmm);
+               drm_debugfs_gpuva_info(m, &uvmm->umgr);
+               seq_puts(m, "\n");
+               nouveau_debugfs_gpuva_regions(m, uvmm);
+               nouveau_uvmm_unlock(uvmm);
+       }
+       mutex_unlock(&drm->clients_lock);
+
+       return 0;
+}
+
 static const struct file_operations nouveau_pstate_fops = {
        .owner = THIS_MODULE,
        .open = nouveau_debugfs_pstate_open,
@@ -214,6 +252,7 @@ static const struct file_operations nouveau_pstate_fops = {
 static struct drm_info_list nouveau_debugfs_list[] = {
        { "vbios.rom",  nouveau_debugfs_vbios_image, 0, NULL },
        { "strap_peek", nouveau_debugfs_strap_peek, 0, NULL },
+       DRM_DEBUGFS_GPUVA_INFO(nouveau_debugfs_gpuva, NULL),
 };
 #define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list)