diff options
author | Jerome Glisse <jglisse@redhat.com> | 2009-12-09 15:55:10 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-12-10 00:28:13 -0500 |
commit | fb53f8621a3fab88776ae2450a1f3afc7920231b (patch) | |
tree | 1fd5a0ee4612a13872824dab0c473d3eed149d95 /drivers | |
parent | 99d7e48e8cb867f303439ad40e995e203841bd94 (diff) |
drm/ttm: Print debug information on memory manager when eviction fails
This add helper function to print information on eviction placements
and memory manager status when eviction fails to allocate memory
space.
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo.c | 70 |
1 files changed, 57 insertions, 13 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index cf8834779f55..a835b6fe42a1 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -59,6 +59,60 @@ static struct attribute ttm_bo_count = { | |||
59 | .mode = S_IRUGO | 59 | .mode = S_IRUGO |
60 | }; | 60 | }; |
61 | 61 | ||
62 | static inline int ttm_mem_type_from_flags(uint32_t flags, uint32_t *mem_type) | ||
63 | { | ||
64 | int i; | ||
65 | |||
66 | for (i = 0; i <= TTM_PL_PRIV5; i++) | ||
67 | if (flags & (1 << i)) { | ||
68 | *mem_type = i; | ||
69 | return 0; | ||
70 | } | ||
71 | return -EINVAL; | ||
72 | } | ||
73 | |||
74 | static void ttm_mem_type_manager_debug(struct ttm_bo_global *glob, | ||
75 | struct ttm_mem_type_manager *man) | ||
76 | { | ||
77 | printk(KERN_ERR TTM_PFX " has_type: %d\n", man->has_type); | ||
78 | printk(KERN_ERR TTM_PFX " use_type: %d\n", man->use_type); | ||
79 | printk(KERN_ERR TTM_PFX " flags: 0x%08X\n", man->flags); | ||
80 | printk(KERN_ERR TTM_PFX " gpu_offset: 0x%08lX\n", man->gpu_offset); | ||
81 | printk(KERN_ERR TTM_PFX " io_offset: 0x%08lX\n", man->io_offset); | ||
82 | printk(KERN_ERR TTM_PFX " io_size: %ld\n", man->io_size); | ||
83 | printk(KERN_ERR TTM_PFX " size: %ld\n", (unsigned long)man->size); | ||
84 | printk(KERN_ERR TTM_PFX " available_caching: 0x%08X\n", | ||
85 | man->available_caching); | ||
86 | printk(KERN_ERR TTM_PFX " default_caching: 0x%08X\n", | ||
87 | man->default_caching); | ||
88 | spin_lock(&glob->lru_lock); | ||
89 | drm_mm_debug_table(&man->manager, TTM_PFX); | ||
90 | spin_unlock(&glob->lru_lock); | ||
91 | } | ||
92 | |||
93 | static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo, | ||
94 | struct ttm_placement *placement) | ||
95 | { | ||
96 | struct ttm_bo_device *bdev = bo->bdev; | ||
97 | struct ttm_bo_global *glob = bo->glob; | ||
98 | struct ttm_mem_type_manager *man; | ||
99 | int i, ret, mem_type; | ||
100 | |||
101 | printk(KERN_ERR TTM_PFX "No space for %p (%ld pages, %ldK, %ldM)\n", | ||
102 | bo, bo->mem.num_pages, bo->mem.size >> 10, | ||
103 | bo->mem.size >> 20); | ||
104 | for (i = 0; i < placement->num_placement; i++) { | ||
105 | ret = ttm_mem_type_from_flags(placement->placement[i], | ||
106 | &mem_type); | ||
107 | if (ret) | ||
108 | return; | ||
109 | man = &bdev->man[mem_type]; | ||
110 | printk(KERN_ERR TTM_PFX " placement[%d]=0x%08X (%d)\n", | ||
111 | i, placement->placement[i], mem_type); | ||
112 | ttm_mem_type_manager_debug(glob, man); | ||
113 | } | ||
114 | } | ||
115 | |||
62 | static ssize_t ttm_bo_global_show(struct kobject *kobj, | 116 | static ssize_t ttm_bo_global_show(struct kobject *kobj, |
63 | struct attribute *attr, | 117 | struct attribute *attr, |
64 | char *buffer) | 118 | char *buffer) |
@@ -592,10 +646,12 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible, | |||
592 | ret = ttm_bo_mem_space(bo, &placement, &evict_mem, interruptible, | 646 | ret = ttm_bo_mem_space(bo, &placement, &evict_mem, interruptible, |
593 | no_wait); | 647 | no_wait); |
594 | if (ret) { | 648 | if (ret) { |
595 | if (ret != -ERESTARTSYS) | 649 | if (ret != -ERESTARTSYS) { |
596 | printk(KERN_ERR TTM_PFX | 650 | printk(KERN_ERR TTM_PFX |
597 | "Failed to find memory space for " | 651 | "Failed to find memory space for " |
598 | "buffer 0x%p eviction.\n", bo); | 652 | "buffer 0x%p eviction.\n", bo); |
653 | ttm_bo_mem_space_debug(bo, &placement); | ||
654 | } | ||
599 | goto out; | 655 | goto out; |
600 | } | 656 | } |
601 | 657 | ||
@@ -768,18 +824,6 @@ static bool ttm_bo_mt_compatible(struct ttm_mem_type_manager *man, | |||
768 | return true; | 824 | return true; |
769 | } | 825 | } |
770 | 826 | ||
771 | static inline int ttm_mem_type_from_flags(uint32_t flags, uint32_t *mem_type) | ||
772 | { | ||
773 | int i; | ||
774 | |||
775 | for (i = 0; i <= TTM_PL_PRIV5; i++) | ||
776 | if (flags & (1 << i)) { | ||
777 | *mem_type = i; | ||
778 | return 0; | ||
779 | } | ||
780 | return -EINVAL; | ||
781 | } | ||
782 | |||
783 | /** | 827 | /** |
784 | * Creates space for memory region @mem according to its type. | 828 | * Creates space for memory region @mem according to its type. |
785 | * | 829 | * |