Skip to content

Commit

Permalink
drm/ttm: Add common debugfs code for resource managers
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
zackr committed Apr 21, 2022
1 parent 7437397 commit 8cd9efd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions drivers/gpu/drm/ttm/ttm_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,3 +644,37 @@ ttm_kmap_iter_linear_io_fini(struct ttm_kmap_iter_linear_io *iter_io,

ttm_mem_io_free(bdev, mem);
}

#if defined(CONFIG_DEBUG_FS)

static int ttm_resource_manager_show(struct seq_file *m, void *unused)
{
struct ttm_resource_manager *man =
(struct ttm_resource_manager *)m->private;
struct drm_printer p = drm_seq_file_printer(m);
ttm_resource_manager_debug(man, &p);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(ttm_resource_manager);

#endif

/**
* ttm_resource_manager_create_debugfs - Create debugfs entry for specified
* resource manager.
* @man: The TTM resource manager for which the debugfs stats file be creates
* @parent: debugfs directory in which the file will reside
* @name: The filename to create.
*
* This function setups up a debugfs file that can be used to look
* at debug statistics of the specified ttm_resource_manager.
*/
void ttm_resource_manager_create_debugfs(struct ttm_resource_manager *man,
struct dentry * parent,
const char *name)
{
#if defined(CONFIG_DEBUG_FS)
debugfs_create_file(name, 0444, parent, man, &ttm_resource_manager_fops);
#endif
}
EXPORT_SYMBOL(ttm_resource_manager_create_debugfs);
4 changes: 4 additions & 0 deletions include/drm/ttm/ttm_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,8 @@ ttm_kmap_iter_linear_io_init(struct ttm_kmap_iter_linear_io *iter_io,
void ttm_kmap_iter_linear_io_fini(struct ttm_kmap_iter_linear_io *iter_io,
struct ttm_device *bdev,
struct ttm_resource *mem);

void ttm_resource_manager_create_debugfs(struct ttm_resource_manager *man,
struct dentry * parent,
const char *name);
#endif

0 comments on commit 8cd9efd

Please sign in to comment.