Commit 9286766b authored by Gerd Hoffmann's avatar Gerd Hoffmann

drm/vram: add vram-mm debugfs file

Wire up drm_mm_print() for vram helpers, using a new
debugfs file, so one can see how vram is used:

   # cat /sys/kernel/debug/dri/0/vram-mm
   0x0000000000000000-0x0000000000000300: 768: used
   0x0000000000000300-0x0000000000000600: 768: used
   0x0000000000000600-0x0000000000000900: 768: used
   0x0000000000000900-0x0000000000000c00: 768: used
   0x0000000000000c00-0x0000000000004000: 13312: free
   total: 16384, used 3072 free 13312
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: http://patchwork.freedesktop.org/patch/msgid/20190904054740.20817-5-kraxel@redhat.com
parent 527f6d91
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <drm/drm_debugfs.h>
#include <drm/drm_device.h> #include <drm/drm_device.h>
#include <drm/drm_file.h> #include <drm/drm_file.h>
#include <drm/drm_gem_ttm_helper.h>
#include <drm/drm_vram_mm_helper.h> #include <drm/drm_vram_mm_helper.h>
#include <drm/ttm/ttm_page_alloc.h> #include <drm/ttm/ttm_page_alloc.h>
...@@ -160,6 +162,48 @@ static struct ttm_bo_driver bo_driver = { ...@@ -160,6 +162,48 @@ static struct ttm_bo_driver bo_driver = {
* struct drm_vram_mm * struct drm_vram_mm
*/ */
#if defined(CONFIG_DEBUG_FS)
static int drm_vram_mm_debugfs(struct seq_file *m, void *data)
{
struct drm_info_node *node = (struct drm_info_node *) m->private;
struct drm_vram_mm *vmm = node->minor->dev->vram_mm;
struct drm_mm *mm = vmm->bdev.man[TTM_PL_VRAM].priv;
struct ttm_bo_global *glob = vmm->bdev.glob;
struct drm_printer p = drm_seq_file_printer(m);
spin_lock(&glob->lru_lock);
drm_mm_print(mm, &p);
spin_unlock(&glob->lru_lock);
return 0;
}
static const struct drm_info_list drm_vram_mm_debugfs_list[] = {
{ "vram-mm", drm_vram_mm_debugfs, 0, NULL },
};
#endif
/**
* drm_vram_mm_debugfs_init() - Register VRAM MM debugfs file.
*
* @minor: drm minor device.
*
* Returns:
* 0 on success, or
* a negative error code otherwise.
*/
int drm_vram_mm_debugfs_init(struct drm_minor *minor)
{
int ret = 0;
#if defined(CONFIG_DEBUG_FS)
ret = drm_debugfs_create_files(drm_vram_mm_debugfs_list,
ARRAY_SIZE(drm_vram_mm_debugfs_list),
minor->debugfs_root, minor);
#endif
return ret;
}
EXPORT_SYMBOL(drm_vram_mm_debugfs_init);
/** /**
* drm_vram_mm_init() - Initialize an instance of VRAM MM. * drm_vram_mm_init() - Initialize an instance of VRAM MM.
* @vmm: the VRAM MM instance to initialize * @vmm: the VRAM MM instance to initialize
......
...@@ -140,6 +140,7 @@ int drm_gem_vram_driver_dumb_mmap_offset(struct drm_file *file, ...@@ -140,6 +140,7 @@ int drm_gem_vram_driver_dumb_mmap_offset(struct drm_file *file,
* &struct drm_driver with default functions. * &struct drm_driver with default functions.
*/ */
#define DRM_GEM_VRAM_DRIVER \ #define DRM_GEM_VRAM_DRIVER \
.debugfs_init = drm_vram_mm_debugfs_init, \
.dumb_create = drm_gem_vram_driver_dumb_create, \ .dumb_create = drm_gem_vram_driver_dumb_create, \
.dumb_map_offset = drm_gem_vram_driver_dumb_mmap_offset, \ .dumb_map_offset = drm_gem_vram_driver_dumb_mmap_offset, \
.gem_prime_mmap = drm_gem_prime_mmap .gem_prime_mmap = drm_gem_prime_mmap
......
...@@ -64,6 +64,7 @@ static inline struct drm_vram_mm *drm_vram_mm_of_bdev( ...@@ -64,6 +64,7 @@ static inline struct drm_vram_mm *drm_vram_mm_of_bdev(
return container_of(bdev, struct drm_vram_mm, bdev); return container_of(bdev, struct drm_vram_mm, bdev);
} }
int drm_vram_mm_debugfs_init(struct drm_minor *minor);
int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev, int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
uint64_t vram_base, size_t vram_size, uint64_t vram_base, size_t vram_size,
const struct drm_vram_mm_funcs *funcs); const struct drm_vram_mm_funcs *funcs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment