]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/amdgpu: Use TTM builtin resource manager debugfs code
authorZack Rusin <zackr@vmware.com>
Tue, 12 Apr 2022 03:35:24 +0000 (23:35 -0400)
committerZack Rusin <zackr@vmware.com>
Thu, 21 Apr 2022 01:06:02 +0000 (21:06 -0400)
Switch to using the TTM resource manager debugfs helpers. It's
exactly the same functionality but the debugfs code is shared with
other drivers.

The TTM resource managers need to stay valid for as long as the
drm debugfs_root is valid.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Felix Kuehling <Felix.Kuehling@amd.com>
Cc: Nirmoy Das <nirmoy.das@amd.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: amd-gfx@lists.freedesktop.org
Link: https://patchwork.freedesktop.org/patch/msgid/20220412033526.369115-4-zack@kde.org
Reviewed-by: Christian König <christian.koenig@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 49ffad312d5d5015090801028bd5678204e9ceb1..ec26edd4f4d818e1c373edb432e13b46f93d61a0 100644 (file)
@@ -2161,17 +2161,6 @@ int amdgpu_ttm_evict_resources(struct amdgpu_device *adev, int mem_type)
 
 #if defined(CONFIG_DEBUG_FS)
 
-static int amdgpu_mm_vram_table_show(struct seq_file *m, void *unused)
-{
-       struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
-       struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev,
-                                                           TTM_PL_VRAM);
-       struct drm_printer p = drm_seq_file_printer(m);
-
-       ttm_resource_manager_debug(man, &p);
-       return 0;
-}
-
 static int amdgpu_ttm_page_pool_show(struct seq_file *m, void *unused)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
@@ -2179,55 +2168,6 @@ static int amdgpu_ttm_page_pool_show(struct seq_file *m, void *unused)
        return ttm_pool_debugfs(&adev->mman.bdev.pool, m);
 }
 
-static int amdgpu_mm_tt_table_show(struct seq_file *m, void *unused)
-{
-       struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
-       struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev,
-                                                           TTM_PL_TT);
-       struct drm_printer p = drm_seq_file_printer(m);
-
-       ttm_resource_manager_debug(man, &p);
-       return 0;
-}
-
-static int amdgpu_mm_gds_table_show(struct seq_file *m, void *unused)
-{
-       struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
-       struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev,
-                                                           AMDGPU_PL_GDS);
-       struct drm_printer p = drm_seq_file_printer(m);
-
-       ttm_resource_manager_debug(man, &p);
-       return 0;
-}
-
-static int amdgpu_mm_gws_table_show(struct seq_file *m, void *unused)
-{
-       struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
-       struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev,
-                                                           AMDGPU_PL_GWS);
-       struct drm_printer p = drm_seq_file_printer(m);
-
-       ttm_resource_manager_debug(man, &p);
-       return 0;
-}
-
-static int amdgpu_mm_oa_table_show(struct seq_file *m, void *unused)
-{
-       struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
-       struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev,
-                                                           AMDGPU_PL_OA);
-       struct drm_printer p = drm_seq_file_printer(m);
-
-       ttm_resource_manager_debug(man, &p);
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_vram_table);
-DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_tt_table);
-DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_gds_table);
-DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_gws_table);
-DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_oa_table);
 DEFINE_SHOW_ATTRIBUTE(amdgpu_ttm_page_pool);
 
 /*
@@ -2437,17 +2377,23 @@ void amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
                                 &amdgpu_ttm_vram_fops, adev->gmc.mc_vram_size);
        debugfs_create_file("amdgpu_iomem", 0444, root, adev,
                            &amdgpu_ttm_iomem_fops);
-       debugfs_create_file("amdgpu_vram_mm", 0444, root, adev,
-                           &amdgpu_mm_vram_table_fops);
-       debugfs_create_file("amdgpu_gtt_mm", 0444, root, adev,
-                           &amdgpu_mm_tt_table_fops);
-       debugfs_create_file("amdgpu_gds_mm", 0444, root, adev,
-                           &amdgpu_mm_gds_table_fops);
-       debugfs_create_file("amdgpu_gws_mm", 0444, root, adev,
-                           &amdgpu_mm_gws_table_fops);
-       debugfs_create_file("amdgpu_oa_mm", 0444, root, adev,
-                           &amdgpu_mm_oa_table_fops);
        debugfs_create_file("ttm_page_pool", 0444, root, adev,
                            &amdgpu_ttm_page_pool_fops);
+       ttm_resource_manager_create_debugfs(ttm_manager_type(&adev->mman.bdev,
+                                                            TTM_PL_VRAM),
+                                           root, "amdgpu_vram_mm");
+       ttm_resource_manager_create_debugfs(ttm_manager_type(&adev->mman.bdev,
+                                                            TTM_PL_TT),
+                                           root, "amdgpu_gtt_mm");
+       ttm_resource_manager_create_debugfs(ttm_manager_type(&adev->mman.bdev,
+                                                            AMDGPU_PL_GDS),
+                                           root, "amdgpu_gds_mm");
+       ttm_resource_manager_create_debugfs(ttm_manager_type(&adev->mman.bdev,
+                                                            AMDGPU_PL_GWS),
+                                           root, "amdgpu_gws_mm");
+       ttm_resource_manager_create_debugfs(ttm_manager_type(&adev->mman.bdev,
+                                                            AMDGPU_PL_OA),
+                                           root, "amdgpu_oa_mm");
+
 #endif
 }