diff options
author | Dave Airlie <airlied@linux.ie> | 2009-08-25 23:13:37 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2009-09-01 19:39:43 -0400 |
commit | fa8a123855e20068204982596b8fafceb1a67f0b (patch) | |
tree | efdfa7fb3cbff6f474cb89de289203f736aa0d81 | |
parent | 3420e74262a7d6496d0ac433d6f61c9972f015f6 (diff) |
drm/mm: add ability to dump mm lists via debugfs
This adds code to the drm_mm to talk to debugfs, and adds
support to radeon to add the VRAM and GTT mm lists to debugfs.
I tested with spinlock debugging and it doesn't give out.
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/drm_mm.c | 21 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ttm.c | 56 | ||||
-rw-r--r-- | include/drm/drm_mm.h | 4 |
3 files changed, 81 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 3e47869d6dae..c861d80fd779 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include "drmP.h" | 44 | #include "drmP.h" |
45 | #include "drm_mm.h" | 45 | #include "drm_mm.h" |
46 | #include <linux/slab.h> | 46 | #include <linux/slab.h> |
47 | #include <linux/seq_file.h> | ||
47 | 48 | ||
48 | #define MM_UNUSED_TARGET 4 | 49 | #define MM_UNUSED_TARGET 4 |
49 | 50 | ||
@@ -370,3 +371,23 @@ void drm_mm_takedown(struct drm_mm * mm) | |||
370 | BUG_ON(mm->num_unused != 0); | 371 | BUG_ON(mm->num_unused != 0); |
371 | } | 372 | } |
372 | EXPORT_SYMBOL(drm_mm_takedown); | 373 | EXPORT_SYMBOL(drm_mm_takedown); |
374 | |||
375 | #if defined(CONFIG_DEBUG_FS) | ||
376 | int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm) | ||
377 | { | ||
378 | struct drm_mm_node *entry; | ||
379 | int total_used = 0, total_free = 0, total = 0; | ||
380 | |||
381 | list_for_each_entry(entry, &mm->ml_entry, ml_entry) { | ||
382 | seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: %s\n", entry->start, entry->start + entry->size, entry->size, entry->free ? "free" : "used"); | ||
383 | total += entry->size; | ||
384 | if (entry->free) | ||
385 | total_free += entry->size; | ||
386 | else | ||
387 | total_used += entry->size; | ||
388 | } | ||
389 | seq_printf(m, "total: %d, used %d free %d\n", total, total_free, total_used); | ||
390 | return 0; | ||
391 | } | ||
392 | EXPORT_SYMBOL(drm_mm_dump_table); | ||
393 | #endif | ||
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 0a85e7b5d592..dc7a44274ea8 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c | |||
@@ -35,11 +35,14 @@ | |||
35 | #include <ttm/ttm_module.h> | 35 | #include <ttm/ttm_module.h> |
36 | #include <drm/drmP.h> | 36 | #include <drm/drmP.h> |
37 | #include <drm/radeon_drm.h> | 37 | #include <drm/radeon_drm.h> |
38 | #include <linux/seq_file.h> | ||
38 | #include "radeon_reg.h" | 39 | #include "radeon_reg.h" |
39 | #include "radeon.h" | 40 | #include "radeon.h" |
40 | 41 | ||
41 | #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) | 42 | #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) |
42 | 43 | ||
44 | static int radeon_ttm_debugfs_init(struct radeon_device *rdev); | ||
45 | |||
43 | static struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev) | 46 | static struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev) |
44 | { | 47 | { |
45 | struct radeon_mman *mman; | 48 | struct radeon_mman *mman; |
@@ -504,6 +507,12 @@ int radeon_ttm_init(struct radeon_device *rdev) | |||
504 | if (unlikely(rdev->mman.bdev.dev_mapping == NULL)) { | 507 | if (unlikely(rdev->mman.bdev.dev_mapping == NULL)) { |
505 | rdev->mman.bdev.dev_mapping = rdev->ddev->dev_mapping; | 508 | rdev->mman.bdev.dev_mapping = rdev->ddev->dev_mapping; |
506 | } | 509 | } |
510 | |||
511 | r = radeon_ttm_debugfs_init(rdev); | ||
512 | if (r) { | ||
513 | DRM_ERROR("Failed to init debugfs\n"); | ||
514 | return r; | ||
515 | } | ||
507 | return 0; | 516 | return 0; |
508 | } | 517 | } |
509 | 518 | ||
@@ -678,3 +687,50 @@ struct ttm_backend *radeon_ttm_backend_create(struct radeon_device *rdev) | |||
678 | gtt->bound = false; | 687 | gtt->bound = false; |
679 | return >t->backend; | 688 | return >t->backend; |
680 | } | 689 | } |
690 | |||
691 | #define RADEON_DEBUGFS_MEM_TYPES 2 | ||
692 | |||
693 | static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES]; | ||
694 | static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES][32]; | ||
695 | |||
696 | #if defined(CONFIG_DEBUG_FS) | ||
697 | static int radeon_mm_dump_table(struct seq_file *m, void *data) | ||
698 | { | ||
699 | struct drm_info_node *node = (struct drm_info_node *)m->private; | ||
700 | struct drm_mm *mm = (struct drm_mm *)node->info_ent->data; | ||
701 | struct drm_device *dev = node->minor->dev; | ||
702 | struct radeon_device *rdev = dev->dev_private; | ||
703 | int ret; | ||
704 | struct ttm_bo_global *glob = rdev->mman.bdev.glob; | ||
705 | |||
706 | spin_lock(&glob->lru_lock); | ||
707 | ret = drm_mm_dump_table(m, mm); | ||
708 | spin_unlock(&glob->lru_lock); | ||
709 | return ret; | ||
710 | } | ||
711 | #endif | ||
712 | |||
713 | static int radeon_ttm_debugfs_init(struct radeon_device *rdev) | ||
714 | { | ||
715 | unsigned i; | ||
716 | |||
717 | #if defined(CONFIG_DEBUG_FS) | ||
718 | for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) { | ||
719 | if (i == 0) | ||
720 | sprintf(radeon_mem_types_names[i], "radeon_vram_mm"); | ||
721 | else | ||
722 | sprintf(radeon_mem_types_names[i], "radeon_gtt_mm"); | ||
723 | radeon_mem_types_list[i].name = radeon_mem_types_names[i]; | ||
724 | radeon_mem_types_list[i].show = &radeon_mm_dump_table; | ||
725 | radeon_mem_types_list[i].driver_features = 0; | ||
726 | if (i == 0) | ||
727 | radeon_mem_types_list[i].data = &rdev->mman.bdev.man[TTM_PL_VRAM].manager; | ||
728 | else | ||
729 | radeon_mem_types_list[i].data = &rdev->mman.bdev.man[TTM_PL_TT].manager; | ||
730 | |||
731 | } | ||
732 | return radeon_debugfs_add_files(rdev, radeon_mem_types_list, RADEON_DEBUGFS_MEM_TYPES); | ||
733 | |||
734 | #endif | ||
735 | return 0; | ||
736 | } | ||
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h index f8332073d277..bc5a87e8aeea 100644 --- a/include/drm/drm_mm.h +++ b/include/drm/drm_mm.h | |||
@@ -96,4 +96,8 @@ static inline struct drm_mm *drm_get_mm(struct drm_mm_node *block) | |||
96 | return block->mm; | 96 | return block->mm; |
97 | } | 97 | } |
98 | 98 | ||
99 | #ifdef CONFIG_DEBUG_FS | ||
100 | int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm); | ||
101 | #endif | ||
102 | |||
99 | #endif | 103 | #endif |