diff options
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bo.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ttm.c | 18 | ||||
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo.c | 26 | ||||
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo_util.c | 9 | ||||
-rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 4 |
5 files changed, 24 insertions, 47 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 4e813638bdb7..f685f392c226 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c | |||
@@ -693,12 +693,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr, | |||
693 | 693 | ||
694 | ret = ttm_bo_move_ttm(bo, evict, no_wait_reserve, no_wait_gpu, new_mem); | 694 | ret = ttm_bo_move_ttm(bo, evict, no_wait_reserve, no_wait_gpu, new_mem); |
695 | out: | 695 | out: |
696 | if (tmp_mem.mm_node) { | 696 | ttm_bo_mem_put(bo, &tmp_mem); |
697 | spin_lock(&bo->bdev->glob->lru_lock); | ||
698 | drm_mm_put_block(tmp_mem.mm_node); | ||
699 | spin_unlock(&bo->bdev->glob->lru_lock); | ||
700 | } | ||
701 | |||
702 | return ret; | 697 | return ret; |
703 | } | 698 | } |
704 | 699 | ||
@@ -731,12 +726,7 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr, | |||
731 | goto out; | 726 | goto out; |
732 | 727 | ||
733 | out: | 728 | out: |
734 | if (tmp_mem.mm_node) { | 729 | ttm_bo_mem_put(bo, &tmp_mem); |
735 | spin_lock(&bo->bdev->glob->lru_lock); | ||
736 | drm_mm_put_block(tmp_mem.mm_node); | ||
737 | spin_unlock(&bo->bdev->glob->lru_lock); | ||
738 | } | ||
739 | |||
740 | return ret; | 730 | return ret; |
741 | } | 731 | } |
742 | 732 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 84c53e41a88f..cc19aba9bb74 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c | |||
@@ -326,14 +326,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo, | |||
326 | } | 326 | } |
327 | r = ttm_bo_move_ttm(bo, true, no_wait_reserve, no_wait_gpu, new_mem); | 327 | r = ttm_bo_move_ttm(bo, true, no_wait_reserve, no_wait_gpu, new_mem); |
328 | out_cleanup: | 328 | out_cleanup: |
329 | if (tmp_mem.mm_node) { | 329 | ttm_bo_mem_put(bo, &tmp_mem); |
330 | struct ttm_bo_global *glob = rdev->mman.bdev.glob; | ||
331 | |||
332 | spin_lock(&glob->lru_lock); | ||
333 | drm_mm_put_block(tmp_mem.mm_node); | ||
334 | spin_unlock(&glob->lru_lock); | ||
335 | return r; | ||
336 | } | ||
337 | return r; | 330 | return r; |
338 | } | 331 | } |
339 | 332 | ||
@@ -372,14 +365,7 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo, | |||
372 | goto out_cleanup; | 365 | goto out_cleanup; |
373 | } | 366 | } |
374 | out_cleanup: | 367 | out_cleanup: |
375 | if (tmp_mem.mm_node) { | 368 | ttm_bo_mem_put(bo, &tmp_mem); |
376 | struct ttm_bo_global *glob = rdev->mman.bdev.glob; | ||
377 | |||
378 | spin_lock(&glob->lru_lock); | ||
379 | drm_mm_put_block(tmp_mem.mm_node); | ||
380 | spin_unlock(&glob->lru_lock); | ||
381 | return r; | ||
382 | } | ||
383 | return r; | 369 | return r; |
384 | } | 370 | } |
385 | 371 | ||
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 | ||
763 | void 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 | } | ||
774 | EXPORT_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 | ||
40 | void ttm_bo_free_old_node(struct ttm_buffer_object *bo) | 40 | void 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 | ||
52 | int ttm_bo_move_ttm(struct ttm_buffer_object *bo, | 45 | int ttm_bo_move_ttm(struct ttm_buffer_object *bo, |
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index b87504235f18..6c694d86e03d 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
@@ -649,6 +649,10 @@ extern int ttm_bo_mem_space(struct ttm_buffer_object *bo, | |||
649 | struct ttm_mem_reg *mem, | 649 | struct ttm_mem_reg *mem, |
650 | bool interruptible, | 650 | bool interruptible, |
651 | bool no_wait_reserve, bool no_wait_gpu); | 651 | bool no_wait_reserve, bool no_wait_gpu); |
652 | |||
653 | extern void ttm_bo_mem_put(struct ttm_buffer_object *bo, | ||
654 | struct ttm_mem_reg *mem); | ||
655 | |||
652 | /** | 656 | /** |
653 | * ttm_bo_wait_for_cpu | 657 | * ttm_bo_wait_for_cpu |
654 | * | 658 | * |