aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_bo.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_bo.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 8f5cec67c47d..d395b0bef73b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -709,6 +709,7 @@ out:
709 709
710static int ttm_mem_evict_first(struct ttm_bo_device *bdev, 710static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
711 uint32_t mem_type, 711 uint32_t mem_type,
712 const struct ttm_place *place,
712 bool interruptible, 713 bool interruptible,
713 bool no_wait_gpu) 714 bool no_wait_gpu)
714{ 715{
@@ -720,8 +721,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
720 spin_lock(&glob->lru_lock); 721 spin_lock(&glob->lru_lock);
721 list_for_each_entry(bo, &man->lru, lru) { 722 list_for_each_entry(bo, &man->lru, lru) {
722 ret = __ttm_bo_reserve(bo, false, true, false, NULL); 723 ret = __ttm_bo_reserve(bo, false, true, false, NULL);
723 if (!ret) 724 if (!ret) {
725 if (place && (place->fpfn || place->lpfn)) {
726 /* Don't evict this BO if it's outside of the
727 * requested placement range
728 */
729 if (place->fpfn >= (bo->mem.start + bo->mem.size) ||
730 (place->lpfn && place->lpfn <= bo->mem.start)) {
731 __ttm_bo_unreserve(bo);
732 ret = -EBUSY;
733 continue;
734 }
735 }
736
724 break; 737 break;
738 }
725 } 739 }
726 740
727 if (ret) { 741 if (ret) {
@@ -782,7 +796,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
782 return ret; 796 return ret;
783 if (mem->mm_node) 797 if (mem->mm_node)
784 break; 798 break;
785 ret = ttm_mem_evict_first(bdev, mem_type, 799 ret = ttm_mem_evict_first(bdev, mem_type, place,
786 interruptible, no_wait_gpu); 800 interruptible, no_wait_gpu);
787 if (unlikely(ret != 0)) 801 if (unlikely(ret != 0))
788 return ret; 802 return ret;
@@ -994,9 +1008,9 @@ static bool ttm_bo_mem_compat(struct ttm_placement *placement,
994 1008
995 for (i = 0; i < placement->num_placement; i++) { 1009 for (i = 0; i < placement->num_placement; i++) {
996 const struct ttm_place *heap = &placement->placement[i]; 1010 const struct ttm_place *heap = &placement->placement[i];
997 if (mem->mm_node && heap->lpfn != 0 && 1011 if (mem->mm_node &&
998 (mem->start < heap->fpfn || 1012 (mem->start < heap->fpfn ||
999 mem->start + mem->num_pages > heap->lpfn)) 1013 (heap->lpfn != 0 && (mem->start + mem->num_pages) > heap->lpfn)))
1000 continue; 1014 continue;
1001 1015
1002 *new_flags = heap->flags; 1016 *new_flags = heap->flags;
@@ -1007,9 +1021,9 @@ static bool ttm_bo_mem_compat(struct ttm_placement *placement,
1007 1021
1008 for (i = 0; i < placement->num_busy_placement; i++) { 1022 for (i = 0; i < placement->num_busy_placement; i++) {
1009 const struct ttm_place *heap = &placement->busy_placement[i]; 1023 const struct ttm_place *heap = &placement->busy_placement[i];
1010 if (mem->mm_node && heap->lpfn != 0 && 1024 if (mem->mm_node &&
1011 (mem->start < heap->fpfn || 1025 (mem->start < heap->fpfn ||
1012 mem->start + mem->num_pages > heap->lpfn)) 1026 (heap->lpfn != 0 && (mem->start + mem->num_pages) > heap->lpfn)))
1013 continue; 1027 continue;
1014 1028
1015 *new_flags = heap->flags; 1029 *new_flags = heap->flags;
@@ -1233,7 +1247,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
1233 spin_lock(&glob->lru_lock); 1247 spin_lock(&glob->lru_lock);
1234 while (!list_empty(&man->lru)) { 1248 while (!list_empty(&man->lru)) {
1235 spin_unlock(&glob->lru_lock); 1249 spin_unlock(&glob->lru_lock);
1236 ret = ttm_mem_evict_first(bdev, mem_type, false, false); 1250 ret = ttm_mem_evict_first(bdev, mem_type, NULL, false, false);
1237 if (ret) { 1251 if (ret) {
1238 if (allow_errors) { 1252 if (allow_errors) {
1239 return ret; 1253 return ret;