Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: do not use drm middle layer for debugfs

Use debugfs API directly instead of drm middle layer.

This also includes following debugfs file output changes:
1 amdgpu_evict_vram/amdgpu_evict_gtt output will not contain any braces.
e.g. (0) --> 0
2 amdgpu_gpu_recover output will print return value of
amdgpu_device_gpu_recover() instead of not so important "gpu recover"
message.

v2: * checkpatch.pl: use '0444' instead of S_IRUGO.
* remove S_IFREG from mode.
* remove mode variable.

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Nirmoy Das and committed by
Alex Deucher
98d28ac2 373720f7

+177 -215
+1 -2
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 791 791 bool accel_working; 792 792 struct notifier_block acpi_nb; 793 793 struct amdgpu_i2c_chan *i2c_bus[AMDGPU_MAX_I2C_BUS]; 794 - struct amdgpu_debugfs debugfs[AMDGPU_DEBUGFS_MAX_COMPONENTS]; 795 - unsigned debugfs_count; 794 + struct debugfs_blob_wrapper debugfs_vbios_blob; 796 795 struct amdgpu_atif *atif; 797 796 struct amdgpu_atcs atcs; 798 797 struct mutex srbm_mutex;
+49 -107
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
··· 28 28 #include <linux/uaccess.h> 29 29 #include <linux/pm_runtime.h> 30 30 #include <linux/poll.h> 31 - #include <drm/drm_debugfs.h> 32 31 33 32 #include "amdgpu.h" 34 33 #include "amdgpu_pm.h" ··· 36 37 #include "amdgpu_rap.h" 37 38 #include "amdgpu_securedisplay.h" 38 39 #include "amdgpu_fw_attestation.h" 39 - 40 - /** 41 - * amdgpu_debugfs_add_files - Add simple debugfs entries 42 - * 43 - * @adev: Device to attach debugfs entries to 44 - * @files: Array of function callbacks that respond to reads 45 - * @nfiles: Number of callbacks to register 46 - * 47 - */ 48 - int amdgpu_debugfs_add_files(struct amdgpu_device *adev, 49 - const struct drm_info_list *files, 50 - unsigned nfiles) 51 - { 52 - unsigned i; 53 - 54 - for (i = 0; i < adev->debugfs_count; i++) { 55 - if (adev->debugfs[i].files == files) { 56 - /* Already registered */ 57 - return 0; 58 - } 59 - } 60 - 61 - i = adev->debugfs_count + 1; 62 - if (i > AMDGPU_DEBUGFS_MAX_COMPONENTS) { 63 - DRM_ERROR("Reached maximum number of debugfs components.\n"); 64 - DRM_ERROR("Report so we increase " 65 - "AMDGPU_DEBUGFS_MAX_COMPONENTS.\n"); 66 - return -EINVAL; 67 - } 68 - adev->debugfs[adev->debugfs_count].files = files; 69 - adev->debugfs[adev->debugfs_count].num_files = nfiles; 70 - adev->debugfs_count = i; 71 - #if defined(CONFIG_DEBUG_FS) 72 - drm_debugfs_create_files(files, nfiles, 73 - adev_to_drm(adev)->primary->debugfs_root, 74 - adev_to_drm(adev)->primary); 75 - #endif 76 - return 0; 77 - } 78 40 79 41 int amdgpu_debugfs_wait_dump(struct amdgpu_device *adev) 80 42 { ··· 1193 1233 return 0; 1194 1234 } 1195 1235 1196 - static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data) 1236 + static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) 1197 1237 { 1198 - struct drm_info_node *node = (struct drm_info_node *) m->private; 1199 - struct drm_device *dev = node->minor->dev; 1200 - struct amdgpu_device *adev = drm_to_adev(dev); 1238 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 1239 + struct drm_device *dev = adev_to_drm(adev); 1201 1240 int r = 0, i; 1202 1241 1203 1242 r = pm_runtime_get_sync(dev->dev); 1204 1243 if (r < 0) { 1205 - pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); 1244 + pm_runtime_put_autosuspend(dev->dev); 1206 1245 return r; 1207 1246 } 1208 1247 ··· 1243 1284 return 0; 1244 1285 } 1245 1286 1246 - static int amdgpu_debugfs_get_vbios_dump(struct seq_file *m, void *data) 1287 + static int amdgpu_debugfs_evict_vram(void *data, u64 *val) 1247 1288 { 1248 - struct drm_info_node *node = (struct drm_info_node *) m->private; 1249 - struct drm_device *dev = node->minor->dev; 1250 - struct amdgpu_device *adev = drm_to_adev(dev); 1251 - 1252 - seq_write(m, adev->bios, adev->bios_size); 1253 - return 0; 1254 - } 1255 - 1256 - static int amdgpu_debugfs_evict_vram(struct seq_file *m, void *data) 1257 - { 1258 - struct drm_info_node *node = (struct drm_info_node *)m->private; 1259 - struct drm_device *dev = node->minor->dev; 1260 - struct amdgpu_device *adev = drm_to_adev(dev); 1289 + struct amdgpu_device *adev = (struct amdgpu_device *)data; 1290 + struct drm_device *dev = adev_to_drm(adev); 1261 1291 int r; 1262 1292 1263 1293 r = pm_runtime_get_sync(dev->dev); 1264 1294 if (r < 0) { 1265 - pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); 1295 + pm_runtime_put_autosuspend(dev->dev); 1266 1296 return r; 1267 1297 } 1268 1298 1269 - seq_printf(m, "(%d)\n", amdgpu_bo_evict_vram(adev)); 1299 + *val = amdgpu_bo_evict_vram(adev); 1270 1300 1271 1301 pm_runtime_mark_last_busy(dev->dev); 1272 1302 pm_runtime_put_autosuspend(dev->dev); ··· 1263 1315 return 0; 1264 1316 } 1265 1317 1266 - static int amdgpu_debugfs_evict_gtt(struct seq_file *m, void *data) 1318 + 1319 + static int amdgpu_debugfs_evict_gtt(void *data, u64 *val) 1267 1320 { 1268 - struct drm_info_node *node = (struct drm_info_node *)m->private; 1269 - struct drm_device *dev = node->minor->dev; 1270 - struct amdgpu_device *adev = drm_to_adev(dev); 1321 + struct amdgpu_device *adev = (struct amdgpu_device *)data; 1322 + struct drm_device *dev = adev_to_drm(adev); 1271 1323 struct ttm_resource_manager *man; 1272 1324 int r; 1273 1325 ··· 1278 1330 } 1279 1331 1280 1332 man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT); 1281 - r = ttm_resource_manager_evict_all(&adev->mman.bdev, man); 1282 - seq_printf(m, "(%d)\n", r); 1333 + *val = ttm_resource_manager_evict_all(&adev->mman.bdev, man); 1283 1334 1284 1335 pm_runtime_mark_last_busy(dev->dev); 1285 1336 pm_runtime_put_autosuspend(dev->dev); ··· 1286 1339 return 0; 1287 1340 } 1288 1341 1289 - static int amdgpu_debugfs_vm_info(struct seq_file *m, void *data) 1342 + 1343 + static int amdgpu_debugfs_vm_info_show(struct seq_file *m, void *unused) 1290 1344 { 1291 - struct drm_info_node *node = (struct drm_info_node *)m->private; 1292 - struct drm_device *dev = node->minor->dev; 1345 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 1346 + struct drm_device *dev = adev_to_drm(adev); 1293 1347 struct drm_file *file; 1294 1348 int r; 1295 1349 ··· 1316 1368 return r; 1317 1369 } 1318 1370 1319 - static const struct drm_info_list amdgpu_debugfs_list[] = { 1320 - {"amdgpu_vbios", amdgpu_debugfs_get_vbios_dump}, 1321 - {"amdgpu_test_ib", &amdgpu_debugfs_test_ib}, 1322 - {"amdgpu_evict_vram", &amdgpu_debugfs_evict_vram}, 1323 - {"amdgpu_evict_gtt", &amdgpu_debugfs_evict_gtt}, 1324 - {"amdgpu_vm_info", &amdgpu_debugfs_vm_info}, 1325 - }; 1371 + DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_test_ib); 1372 + DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_vm_info); 1373 + DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_evict_vram_fops, amdgpu_debugfs_evict_vram, 1374 + NULL, "%lld\n"); 1375 + DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_evict_gtt_fops, amdgpu_debugfs_evict_gtt, 1376 + NULL, "%lld\n"); 1326 1377 1327 1378 static void amdgpu_ib_preempt_fences_swap(struct amdgpu_ring *ring, 1328 1379 struct dma_fence **fences) ··· 1540 1593 1541 1594 int amdgpu_debugfs_init(struct amdgpu_device *adev) 1542 1595 { 1596 + struct dentry *root = adev_to_drm(adev)->primary->debugfs_root; 1543 1597 struct dentry *ent; 1544 1598 int r, i; 1545 1599 1546 - ent = debugfs_create_file("amdgpu_preempt_ib", 0600, 1547 - adev_to_drm(adev)->primary->debugfs_root, adev, 1600 + 1601 + 1602 + ent = debugfs_create_file("amdgpu_preempt_ib", 0600, root, adev, 1548 1603 &fops_ib_preempt); 1549 1604 if (!ent) { 1550 1605 DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n"); 1551 1606 return -EIO; 1552 1607 } 1553 1608 1554 - ent = debugfs_create_file("amdgpu_force_sclk", 0200, 1555 - adev_to_drm(adev)->primary->debugfs_root, adev, 1609 + ent = debugfs_create_file("amdgpu_force_sclk", 0200, root, adev, 1556 1610 &fops_sclk_set); 1557 1611 if (!ent) { 1558 1612 DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n"); ··· 1561 1613 } 1562 1614 1563 1615 /* Register debugfs entries for amdgpu_ttm */ 1564 - r = amdgpu_ttm_debugfs_init(adev); 1565 - if (r) { 1566 - DRM_ERROR("Failed to init debugfs\n"); 1567 - return r; 1568 - } 1569 - 1616 + amdgpu_ttm_debugfs_init(adev); 1570 1617 amdgpu_debugfs_pm_init(adev); 1571 - 1572 - if (amdgpu_debugfs_sa_init(adev)) { 1573 - dev_err(adev->dev, "failed to register debugfs file for SA\n"); 1574 - } 1575 - 1576 - if (amdgpu_debugfs_fence_init(adev)) 1577 - dev_err(adev->dev, "fence debugfs file creation failed\n"); 1578 - 1579 - r = amdgpu_debugfs_gem_init(adev); 1580 - if (r) 1581 - DRM_ERROR("registering gem debugfs failed (%d).\n", r); 1618 + amdgpu_debugfs_sa_init(adev); 1619 + amdgpu_debugfs_fence_init(adev); 1620 + amdgpu_debugfs_gem_init(adev); 1582 1621 1583 1622 r = amdgpu_debugfs_regs_init(adev); 1584 1623 if (r) 1585 1624 DRM_ERROR("registering register debugfs failed (%d).\n", r); 1586 1625 1587 - r = amdgpu_debugfs_firmware_init(adev); 1588 - if (r) 1589 - DRM_ERROR("registering firmware debugfs failed (%d).\n", r); 1626 + amdgpu_debugfs_firmware_init(adev); 1590 1627 1591 1628 #if defined(CONFIG_DRM_AMD_DC) 1592 1629 if (amdgpu_device_has_dc_support(adev)) ··· 1590 1657 } 1591 1658 1592 1659 amdgpu_ras_debugfs_create_all(adev); 1593 - 1594 1660 amdgpu_debugfs_autodump_init(adev); 1595 - 1596 1661 amdgpu_rap_debugfs_init(adev); 1597 - 1598 1662 amdgpu_securedisplay_debugfs_init(adev); 1599 - 1600 1663 amdgpu_fw_attestation_debugfs_init(adev); 1601 1664 1602 - return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_list, 1603 - ARRAY_SIZE(amdgpu_debugfs_list)); 1665 + debugfs_create_file("amdgpu_evict_vram", 0444, root, adev, 1666 + &amdgpu_evict_vram_fops); 1667 + debugfs_create_file("amdgpu_evict_gtt", 0444, root, adev, 1668 + &amdgpu_evict_gtt_fops); 1669 + debugfs_create_file("amdgpu_test_ib", 0444, root, adev, 1670 + &amdgpu_debugfs_test_ib_fops); 1671 + debugfs_create_file("amdgpu_vm_info", 0444, root, adev, 1672 + &amdgpu_debugfs_vm_info_fops); 1673 + 1674 + adev->debugfs_vbios_blob.data = adev->bios; 1675 + adev->debugfs_vbios_blob.size = adev->bios_size; 1676 + debugfs_create_blob("amdgpu_vbios", 0444, root, 1677 + &adev->debugfs_vbios_blob); 1678 + 1679 + return 0; 1604 1680 } 1605 1681 1606 1682 #else
+3 -11
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.h
··· 26 26 /* 27 27 * Debugfs 28 28 */ 29 - struct amdgpu_debugfs { 30 - const struct drm_info_list *files; 31 - unsigned num_files; 32 - }; 33 - 34 29 struct amdgpu_autodump { 35 30 struct completion dumping; 36 31 struct wait_queue_head gpu_hang; ··· 34 39 int amdgpu_debugfs_regs_init(struct amdgpu_device *adev); 35 40 int amdgpu_debugfs_init(struct amdgpu_device *adev); 36 41 void amdgpu_debugfs_fini(struct amdgpu_device *adev); 37 - int amdgpu_debugfs_add_files(struct amdgpu_device *adev, 38 - const struct drm_info_list *files, 39 - unsigned nfiles); 40 - int amdgpu_debugfs_fence_init(struct amdgpu_device *adev); 41 - int amdgpu_debugfs_firmware_init(struct amdgpu_device *adev); 42 - int amdgpu_debugfs_gem_init(struct amdgpu_device *adev); 42 + void amdgpu_debugfs_fence_init(struct amdgpu_device *adev); 43 + void amdgpu_debugfs_firmware_init(struct amdgpu_device *adev); 44 + void amdgpu_debugfs_gem_init(struct amdgpu_device *adev); 43 45 int amdgpu_debugfs_wait_dump(struct amdgpu_device *adev);
+19 -27
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
··· 36 36 #include <linux/firmware.h> 37 37 #include <linux/pm_runtime.h> 38 38 39 - #include <drm/drm_debugfs.h> 40 - 41 39 #include "amdgpu.h" 42 40 #include "amdgpu_trace.h" 43 41 ··· 695 697 * Fence debugfs 696 698 */ 697 699 #if defined(CONFIG_DEBUG_FS) 698 - static int amdgpu_debugfs_fence_info(struct seq_file *m, void *data) 700 + static int amdgpu_debugfs_fence_info_show(struct seq_file *m, void *unused) 699 701 { 700 - struct drm_info_node *node = (struct drm_info_node *)m->private; 701 - struct drm_device *dev = node->minor->dev; 702 - struct amdgpu_device *adev = drm_to_adev(dev); 702 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 703 703 int i; 704 704 705 705 for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { ··· 742 746 * 743 747 * Manually trigger a gpu reset at the next fence wait. 744 748 */ 745 - static int amdgpu_debugfs_gpu_recover(struct seq_file *m, void *data) 749 + static int gpu_recover_get(void *data, u64 *val) 746 750 { 747 - struct drm_info_node *node = (struct drm_info_node *) m->private; 748 - struct drm_device *dev = node->minor->dev; 749 - struct amdgpu_device *adev = drm_to_adev(dev); 751 + struct amdgpu_device *adev = (struct amdgpu_device *)data; 752 + struct drm_device *dev = adev_to_drm(adev); 750 753 int r; 751 754 752 755 r = pm_runtime_get_sync(dev->dev); ··· 754 759 return 0; 755 760 } 756 761 757 - seq_printf(m, "gpu recover\n"); 758 - amdgpu_device_gpu_recover(adev, NULL); 762 + *val = amdgpu_device_gpu_recover(adev, NULL); 759 763 760 764 pm_runtime_mark_last_busy(dev->dev); 761 765 pm_runtime_put_autosuspend(dev->dev); ··· 762 768 return 0; 763 769 } 764 770 765 - static const struct drm_info_list amdgpu_debugfs_fence_list[] = { 766 - {"amdgpu_fence_info", &amdgpu_debugfs_fence_info, 0, NULL}, 767 - {"amdgpu_gpu_recover", &amdgpu_debugfs_gpu_recover, 0, NULL} 768 - }; 771 + DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_fence_info); 772 + DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_debugfs_gpu_recover_fops, gpu_recover_get, NULL, 773 + "%lld\n"); 769 774 770 - static const struct drm_info_list amdgpu_debugfs_fence_list_sriov[] = { 771 - {"amdgpu_fence_info", &amdgpu_debugfs_fence_info, 0, NULL}, 772 - }; 773 775 #endif 774 776 775 - int amdgpu_debugfs_fence_init(struct amdgpu_device *adev) 777 + void amdgpu_debugfs_fence_init(struct amdgpu_device *adev) 776 778 { 777 779 #if defined(CONFIG_DEBUG_FS) 778 - if (amdgpu_sriov_vf(adev)) 779 - return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_fence_list_sriov, 780 - ARRAY_SIZE(amdgpu_debugfs_fence_list_sriov)); 781 - return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_fence_list, 782 - ARRAY_SIZE(amdgpu_debugfs_fence_list)); 783 - #else 784 - return 0; 780 + struct drm_minor *minor = adev_to_drm(adev)->primary; 781 + struct dentry *root = minor->debugfs_root; 782 + 783 + debugfs_create_file("amdgpu_fence_info", 0444, root, adev, 784 + &amdgpu_debugfs_fence_info_fops); 785 + 786 + if (!amdgpu_sriov_vf(adev)) 787 + debugfs_create_file("amdgpu_gpu_recover", 0444, root, adev, 788 + &amdgpu_debugfs_gpu_recover_fops); 785 789 #endif 786 790 } 787 791
+11 -11
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
··· 32 32 #include <linux/dma-buf.h> 33 33 34 34 #include <drm/amdgpu_drm.h> 35 - #include <drm/drm_debugfs.h> 36 35 #include <drm/drm_gem_ttm_helper.h> 37 36 38 37 #include "amdgpu.h" ··· 854 855 } 855 856 856 857 #if defined(CONFIG_DEBUG_FS) 857 - static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data) 858 + static int amdgpu_debugfs_gem_info_show(struct seq_file *m, void *unused) 858 859 { 859 - struct drm_info_node *node = (struct drm_info_node *)m->private; 860 - struct drm_device *dev = node->minor->dev; 860 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 861 + struct drm_device *dev = adev_to_drm(adev); 861 862 struct drm_file *file; 862 863 int r; 863 864 ··· 895 896 return 0; 896 897 } 897 898 898 - static const struct drm_info_list amdgpu_debugfs_gem_list[] = { 899 - {"amdgpu_gem_info", &amdgpu_debugfs_gem_info, 0, NULL}, 900 - }; 899 + DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_gem_info); 900 + 901 901 #endif 902 902 903 - int amdgpu_debugfs_gem_init(struct amdgpu_device *adev) 903 + void amdgpu_debugfs_gem_init(struct amdgpu_device *adev) 904 904 { 905 905 #if defined(CONFIG_DEBUG_FS) 906 - return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_gem_list, 907 - ARRAY_SIZE(amdgpu_debugfs_gem_list)); 906 + struct drm_minor *minor = adev_to_drm(adev)->primary; 907 + struct dentry *root = minor->debugfs_root; 908 + 909 + debugfs_create_file("amdgpu_gem_info", 0444, root, adev, 910 + &amdgpu_debugfs_gem_info_fops); 908 911 #endif 909 - return 0; 910 912 }
+10 -13
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
··· 30 30 #include <linux/slab.h> 31 31 32 32 #include <drm/amdgpu_drm.h> 33 - #include <drm/drm_debugfs.h> 34 33 35 34 #include "amdgpu.h" 36 35 #include "atom.h" ··· 452 453 */ 453 454 #if defined(CONFIG_DEBUG_FS) 454 455 455 - static int amdgpu_debugfs_sa_info(struct seq_file *m, void *data) 456 + static int amdgpu_debugfs_sa_info_show(struct seq_file *m, void *unused) 456 457 { 457 - struct drm_info_node *node = (struct drm_info_node *) m->private; 458 - struct drm_device *dev = node->minor->dev; 459 - struct amdgpu_device *adev = drm_to_adev(dev); 458 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 460 459 461 460 seq_printf(m, "--------------------- DELAYED --------------------- \n"); 462 461 amdgpu_sa_bo_dump_debug_info(&adev->ib_pools[AMDGPU_IB_POOL_DELAYED], ··· 468 471 return 0; 469 472 } 470 473 471 - static const struct drm_info_list amdgpu_debugfs_sa_list[] = { 472 - {"amdgpu_sa_info", &amdgpu_debugfs_sa_info, 0, NULL}, 473 - }; 474 + DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_sa_info); 474 475 475 476 #endif 476 477 477 - int amdgpu_debugfs_sa_init(struct amdgpu_device *adev) 478 + void amdgpu_debugfs_sa_init(struct amdgpu_device *adev) 478 479 { 479 480 #if defined(CONFIG_DEBUG_FS) 480 - return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_sa_list, 481 - ARRAY_SIZE(amdgpu_debugfs_sa_list)); 482 - #else 483 - return 0; 481 + struct drm_minor *minor = adev_to_drm(adev)->primary; 482 + struct dentry *root = minor->debugfs_root; 483 + 484 + debugfs_create_file("amdgpu_sa_info", 0444, root, adev, 485 + &amdgpu_debugfs_sa_info_fops); 486 + 484 487 #endif 485 488 }
+11 -13
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
··· 27 27 */ 28 28 29 29 #include "amdgpu.h" 30 - #include <drm/drm_debugfs.h> 31 30 #include <drm/amdgpu_drm.h> 32 31 #include "amdgpu_uvd.h" 33 32 #include "amdgpu_vce.h" ··· 1263 1264 */ 1264 1265 #if defined(CONFIG_DEBUG_FS) 1265 1266 1266 - static int amdgpu_debugfs_firmware_info(struct seq_file *m, void *data) 1267 + static int amdgpu_debugfs_firmware_info_show(struct seq_file *m, void *unused) 1267 1268 { 1268 - struct drm_info_node *node = (struct drm_info_node *) m->private; 1269 - struct drm_device *dev = node->minor->dev; 1270 - struct amdgpu_device *adev = drm_to_adev(dev); 1269 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 1271 1270 struct drm_amdgpu_info_firmware fw_info; 1272 1271 struct drm_amdgpu_query_fw query_fw; 1273 1272 struct atom_context *ctx = adev->mode_info.atom_context; ··· 1471 1474 return 0; 1472 1475 } 1473 1476 1474 - static const struct drm_info_list amdgpu_firmware_info_list[] = { 1475 - {"amdgpu_firmware_info", amdgpu_debugfs_firmware_info, 0, NULL}, 1476 - }; 1477 + DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_firmware_info); 1478 + 1477 1479 #endif 1478 1480 1479 - int amdgpu_debugfs_firmware_init(struct amdgpu_device *adev) 1481 + void amdgpu_debugfs_firmware_init(struct amdgpu_device *adev) 1480 1482 { 1481 1483 #if defined(CONFIG_DEBUG_FS) 1482 - return amdgpu_debugfs_add_files(adev, amdgpu_firmware_info_list, 1483 - ARRAY_SIZE(amdgpu_firmware_info_list)); 1484 - #else 1485 - return 0; 1484 + struct drm_minor *minor = adev_to_drm(adev)->primary; 1485 + struct dentry *root = minor->debugfs_root; 1486 + 1487 + debugfs_create_file("amdgpu_firmware_info", 0444, root, 1488 + adev, &amdgpu_debugfs_firmware_info_fops); 1489 + 1486 1490 #endif 1487 1491 }
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
··· 329 329 struct seq_file *m); 330 330 u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct seq_file *m); 331 331 #endif 332 - int amdgpu_debugfs_sa_init(struct amdgpu_device *adev); 332 + void amdgpu_debugfs_sa_init(struct amdgpu_device *adev); 333 333 334 334 bool amdgpu_bo_support_uswc(u64 bo_flags); 335 335
+71 -29
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
··· 47 47 #include <drm/ttm/ttm_bo_driver.h> 48 48 #include <drm/ttm/ttm_placement.h> 49 49 50 - #include <drm/drm_debugfs.h> 51 50 #include <drm/amdgpu_drm.h> 52 51 53 52 #include "amdgpu.h" ··· 2190 2191 2191 2192 #if defined(CONFIG_DEBUG_FS) 2192 2193 2193 - static int amdgpu_mm_dump_table(struct seq_file *m, void *data) 2194 + static int amdgpu_mm_vram_table_show(struct seq_file *m, void *unused) 2194 2195 { 2195 - struct drm_info_node *node = (struct drm_info_node *)m->private; 2196 - unsigned ttm_pl = (uintptr_t)node->info_ent->data; 2197 - struct drm_device *dev = node->minor->dev; 2198 - struct amdgpu_device *adev = drm_to_adev(dev); 2199 - struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, ttm_pl); 2196 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 2197 + struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, 2198 + TTM_PL_VRAM); 2200 2199 struct drm_printer p = drm_seq_file_printer(m); 2201 2200 2202 2201 man->func->debug(man, &p); 2203 2202 return 0; 2204 2203 } 2205 2204 2206 - static int amdgpu_ttm_pool_debugfs(struct seq_file *m, void *data) 2205 + static int amdgpu_ttm_page_pool_show(struct seq_file *m, void *unused) 2207 2206 { 2208 - struct drm_info_node *node = (struct drm_info_node *)m->private; 2209 - struct drm_device *dev = node->minor->dev; 2210 - struct amdgpu_device *adev = drm_to_adev(dev); 2207 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 2211 2208 2212 2209 return ttm_pool_debugfs(&adev->mman.bdev.pool, m); 2213 2210 } 2214 2211 2215 - static const struct drm_info_list amdgpu_ttm_debugfs_list[] = { 2216 - {"amdgpu_vram_mm", amdgpu_mm_dump_table, 0, (void *)TTM_PL_VRAM}, 2217 - {"amdgpu_gtt_mm", amdgpu_mm_dump_table, 0, (void *)TTM_PL_TT}, 2218 - {"amdgpu_gds_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_GDS}, 2219 - {"amdgpu_gws_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_GWS}, 2220 - {"amdgpu_oa_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_OA}, 2221 - {"ttm_page_pool", amdgpu_ttm_pool_debugfs, 0, NULL}, 2222 - }; 2212 + static int amdgpu_mm_tt_table_show(struct seq_file *m, void *unused) 2213 + { 2214 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 2215 + struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, 2216 + TTM_PL_TT); 2217 + struct drm_printer p = drm_seq_file_printer(m); 2218 + 2219 + man->func->debug(man, &p); 2220 + return 0; 2221 + } 2222 + 2223 + static int amdgpu_mm_gds_table_show(struct seq_file *m, void *unused) 2224 + { 2225 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 2226 + struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, 2227 + AMDGPU_PL_GDS); 2228 + struct drm_printer p = drm_seq_file_printer(m); 2229 + 2230 + man->func->debug(man, &p); 2231 + return 0; 2232 + } 2233 + 2234 + static int amdgpu_mm_gws_table_show(struct seq_file *m, void *unused) 2235 + { 2236 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 2237 + struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, 2238 + AMDGPU_PL_GWS); 2239 + struct drm_printer p = drm_seq_file_printer(m); 2240 + 2241 + man->func->debug(man, &p); 2242 + return 0; 2243 + } 2244 + 2245 + static int amdgpu_mm_oa_table_show(struct seq_file *m, void *unused) 2246 + { 2247 + struct amdgpu_device *adev = (struct amdgpu_device *)m->private; 2248 + struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, 2249 + AMDGPU_PL_OA); 2250 + struct drm_printer p = drm_seq_file_printer(m); 2251 + 2252 + man->func->debug(man, &p); 2253 + return 0; 2254 + } 2255 + 2256 + DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_vram_table); 2257 + DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_tt_table); 2258 + DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_gds_table); 2259 + DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_gws_table); 2260 + DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_oa_table); 2261 + DEFINE_SHOW_ATTRIBUTE(amdgpu_ttm_page_pool); 2223 2262 2224 2263 /* 2225 2264 * amdgpu_ttm_vram_read - Linear read access to VRAM ··· 2461 2424 2462 2425 #endif 2463 2426 2464 - int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) 2427 + void amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) 2465 2428 { 2466 2429 #if defined(CONFIG_DEBUG_FS) 2467 - unsigned count; 2468 - 2469 2430 struct drm_minor *minor = adev_to_drm(adev)->primary; 2470 - umode_t mode = S_IFREG | S_IRUGO; 2471 2431 struct dentry *root = minor->debugfs_root; 2472 2432 2473 - debugfs_create_file_size("amdgpu_vram", mode, root, adev, 2433 + debugfs_create_file_size("amdgpu_vram", 0444, root, adev, 2474 2434 &amdgpu_ttm_vram_fops, adev->gmc.mc_vram_size); 2475 - debugfs_create_file("amdgpu_iomem", mode, root, adev, 2435 + debugfs_create_file("amdgpu_iomem", 0444, root, adev, 2476 2436 &amdgpu_ttm_iomem_fops); 2477 - count = ARRAY_SIZE(amdgpu_ttm_debugfs_list); 2478 - return amdgpu_debugfs_add_files(adev, amdgpu_ttm_debugfs_list, count); 2479 - #else 2480 - return 0; 2437 + debugfs_create_file("amdgpu_vram_mm", 0444, root, adev, 2438 + &amdgpu_mm_vram_table_fops); 2439 + debugfs_create_file("amdgpu_gtt_mm", 0444, root, adev, 2440 + &amdgpu_mm_tt_table_fops); 2441 + debugfs_create_file("amdgpu_gds_mm", 0444, root, adev, 2442 + &amdgpu_mm_gds_table_fops); 2443 + debugfs_create_file("amdgpu_gws_mm", 0444, root, adev, 2444 + &amdgpu_mm_gws_table_fops); 2445 + debugfs_create_file("amdgpu_oa_mm", 0444, root, adev, 2446 + &amdgpu_mm_oa_table_fops); 2447 + debugfs_create_file("ttm_page_pool", 0444, root, adev, 2448 + &amdgpu_ttm_page_pool_fops); 2481 2449 #endif 2482 2450 }
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
··· 182 182 uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, 183 183 struct ttm_resource *mem); 184 184 185 - int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev); 185 + void amdgpu_ttm_debugfs_init(struct amdgpu_device *adev); 186 186 187 187 #endif