Skip to content

Commit 8cd9efd

Browse files
committed
drm/ttm: Add common debugfs code for resource managers
Drivers duplicate the code required to add debugfs entries for various ttm resource managers. To fix it add common TTM resource manager debugfs code that each driver can reuse. Specific resource managers can overwrite ttm_resource_manager_func::debug to get more information from those debugfs entries. Signed-off-by: Zack Rusin <[email protected]> Cc: Huang Rui <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Christian König <[email protected]>
1 parent 7437397 commit 8cd9efd

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

drivers/gpu/drm/ttm/ttm_resource.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,3 +644,37 @@ ttm_kmap_iter_linear_io_fini(struct ttm_kmap_iter_linear_io *iter_io,
644644

645645
ttm_mem_io_free(bdev, mem);
646646
}
647+
648+
#if defined(CONFIG_DEBUG_FS)
649+
650+
static int ttm_resource_manager_show(struct seq_file *m, void *unused)
651+
{
652+
struct ttm_resource_manager *man =
653+
(struct ttm_resource_manager *)m->private;
654+
struct drm_printer p = drm_seq_file_printer(m);
655+
ttm_resource_manager_debug(man, &p);
656+
return 0;
657+
}
658+
DEFINE_SHOW_ATTRIBUTE(ttm_resource_manager);
659+
660+
#endif
661+
662+
/**
663+
* ttm_resource_manager_create_debugfs - Create debugfs entry for specified
664+
* resource manager.
665+
* @man: The TTM resource manager for which the debugfs stats file be creates
666+
* @parent: debugfs directory in which the file will reside
667+
* @name: The filename to create.
668+
*
669+
* This function setups up a debugfs file that can be used to look
670+
* at debug statistics of the specified ttm_resource_manager.
671+
*/
672+
void ttm_resource_manager_create_debugfs(struct ttm_resource_manager *man,
673+
struct dentry * parent,
674+
const char *name)
675+
{
676+
#if defined(CONFIG_DEBUG_FS)
677+
debugfs_create_file(name, 0444, parent, man, &ttm_resource_manager_fops);
678+
#endif
679+
}
680+
EXPORT_SYMBOL(ttm_resource_manager_create_debugfs);

include/drm/ttm/ttm_resource.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,4 +381,8 @@ ttm_kmap_iter_linear_io_init(struct ttm_kmap_iter_linear_io *iter_io,
381381
void ttm_kmap_iter_linear_io_fini(struct ttm_kmap_iter_linear_io *iter_io,
382382
struct ttm_device *bdev,
383383
struct ttm_resource *mem);
384+
385+
void ttm_resource_manager_create_debugfs(struct ttm_resource_manager *man,
386+
struct dentry * parent,
387+
const char *name);
384388
#endif

0 commit comments

Comments
 (0)