aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2010-08-03 22:07:08 -0400
committerBen Skeggs <bskeggs@redhat.com>2010-10-04 20:00:34 -0400
commit42311ff90dc8746bd81427b2ed6efda9af791b77 (patch)
treef41e0b9703463f712e1af5a817f0c81639336a9b /drivers/gpu/drm/ttm
parenta845fff841b13678b2d80f10425aba87db840e4a (diff)
drm/ttm: introduce utility function to free an allocated memory node
Existing core code/drivers call drm_mm_put_block on ttm_mem_reg.mm_node directly. Future patches will modify TTM behaviour in such a way that ttm_mem_reg.mm_node doesn't necessarily belong to drm_mm. Reviewed-by: Jerome Glisse <jglisse@redhat.com> Acked-by: Thomas Hellström <thellstrom@vmware.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/ttm')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c26
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_util.c9
2 files changed, 16 insertions, 19 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index cb4cf7ef4d1e..80d37b460a8c 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -475,11 +475,8 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, bool remove_all)
475 list_del_init(&bo->ddestroy); 475 list_del_init(&bo->ddestroy);
476 ++put_count; 476 ++put_count;
477 } 477 }
478 if (bo->mem.mm_node) {
479 drm_mm_put_block(bo->mem.mm_node);
480 bo->mem.mm_node = NULL;
481 }
482 spin_unlock(&glob->lru_lock); 478 spin_unlock(&glob->lru_lock);
479 ttm_bo_mem_put(bo, &bo->mem);
483 480
484 atomic_set(&bo->reserved, 0); 481 atomic_set(&bo->reserved, 0);
485 482
@@ -621,7 +618,6 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
621 bool no_wait_reserve, bool no_wait_gpu) 618 bool no_wait_reserve, bool no_wait_gpu)
622{ 619{
623 struct ttm_bo_device *bdev = bo->bdev; 620 struct ttm_bo_device *bdev = bo->bdev;
624 struct ttm_bo_global *glob = bo->glob;
625 struct ttm_mem_reg evict_mem; 621 struct ttm_mem_reg evict_mem;
626 struct ttm_placement placement; 622 struct ttm_placement placement;
627 int ret = 0; 623 int ret = 0;
@@ -667,12 +663,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
667 if (ret) { 663 if (ret) {
668 if (ret != -ERESTARTSYS) 664 if (ret != -ERESTARTSYS)
669 printk(KERN_ERR TTM_PFX "Buffer eviction failed\n"); 665 printk(KERN_ERR TTM_PFX "Buffer eviction failed\n");
670 spin_lock(&glob->lru_lock); 666 ttm_bo_mem_put(bo, &evict_mem);
671 if (evict_mem.mm_node) {
672 drm_mm_put_block(evict_mem.mm_node);
673 evict_mem.mm_node = NULL;
674 }
675 spin_unlock(&glob->lru_lock);
676 goto out; 667 goto out;
677 } 668 }
678 bo->evicted = true; 669 bo->evicted = true;
@@ -769,6 +760,19 @@ static int ttm_bo_man_get_node(struct ttm_buffer_object *bo,
769 return 0; 760 return 0;
770} 761}
771 762
763void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem)
764{
765 struct ttm_bo_global *glob = bo->glob;
766
767 if (mem->mm_node) {
768 spin_lock(&glob->lru_lock);
769 drm_mm_put_block(mem->mm_node);
770 spin_unlock(&glob->lru_lock);
771 mem->mm_node = NULL;
772 }
773}
774EXPORT_SYMBOL(ttm_bo_mem_put);
775
772/** 776/**
773 * Repeatedly evict memory from the LRU for @mem_type until we create enough 777 * Repeatedly evict memory from the LRU for @mem_type until we create enough
774 * space, or we've evicted everything and there isn't enough space. 778 * space, or we've evicted everything and there isn't enough space.
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 7cffb3e04232..0ebfe0d94931 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -39,14 +39,7 @@
39 39
40void ttm_bo_free_old_node(struct ttm_buffer_object *bo) 40void ttm_bo_free_old_node(struct ttm_buffer_object *bo)
41{ 41{
42 struct ttm_mem_reg *old_mem = &bo->mem; 42 ttm_bo_mem_put(bo, &bo->mem);
43
44 if (old_mem->mm_node) {
45 spin_lock(&bo->glob->lru_lock);
46 drm_mm_put_block(old_mem->mm_node);
47 spin_unlock(&bo->glob->lru_lock);
48 }
49 old_mem->mm_node = NULL;
50} 43}
51 44
52int ttm_bo_move_ttm(struct ttm_buffer_object *bo, 45int ttm_bo_move_ttm(struct ttm_buffer_object *bo,