diff options
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index fb646c44faae..f1a206df9823 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
| @@ -1103,13 +1103,37 @@ static struct list_head *amdgpu_ttm_swap_lru_tail(struct ttm_buffer_object *tbo) | |||
| 1103 | return res; | 1103 | return res; |
| 1104 | } | 1104 | } |
| 1105 | 1105 | ||
| 1106 | static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, | ||
| 1107 | const struct ttm_place *place) | ||
| 1108 | { | ||
| 1109 | if (bo->mem.mem_type == TTM_PL_VRAM && | ||
| 1110 | bo->mem.start == AMDGPU_BO_INVALID_OFFSET) { | ||
| 1111 | unsigned long num_pages = bo->mem.num_pages; | ||
| 1112 | struct drm_mm_node *node = bo->mem.mm_node; | ||
| 1113 | |||
| 1114 | /* Check each drm MM node individually */ | ||
| 1115 | while (num_pages) { | ||
| 1116 | if (place->fpfn < (node->start + node->size) && | ||
| 1117 | !(place->lpfn && place->lpfn <= node->start)) | ||
| 1118 | return true; | ||
| 1119 | |||
| 1120 | num_pages -= node->size; | ||
| 1121 | ++node; | ||
| 1122 | } | ||
| 1123 | |||
| 1124 | return false; | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | return ttm_bo_eviction_valuable(bo, place); | ||
| 1128 | } | ||
| 1129 | |||
| 1106 | static struct ttm_bo_driver amdgpu_bo_driver = { | 1130 | static struct ttm_bo_driver amdgpu_bo_driver = { |
| 1107 | .ttm_tt_create = &amdgpu_ttm_tt_create, | 1131 | .ttm_tt_create = &amdgpu_ttm_tt_create, |
| 1108 | .ttm_tt_populate = &amdgpu_ttm_tt_populate, | 1132 | .ttm_tt_populate = &amdgpu_ttm_tt_populate, |
| 1109 | .ttm_tt_unpopulate = &amdgpu_ttm_tt_unpopulate, | 1133 | .ttm_tt_unpopulate = &amdgpu_ttm_tt_unpopulate, |
| 1110 | .invalidate_caches = &amdgpu_invalidate_caches, | 1134 | .invalidate_caches = &amdgpu_invalidate_caches, |
| 1111 | .init_mem_type = &amdgpu_init_mem_type, | 1135 | .init_mem_type = &amdgpu_init_mem_type, |
| 1112 | .eviction_valuable = ttm_bo_eviction_valuable, | 1136 | .eviction_valuable = amdgpu_ttm_bo_eviction_valuable, |
| 1113 | .evict_flags = &amdgpu_evict_flags, | 1137 | .evict_flags = &amdgpu_evict_flags, |
| 1114 | .move = &amdgpu_bo_move, | 1138 | .move = &amdgpu_bo_move, |
| 1115 | .verify_access = &amdgpu_verify_access, | 1139 | .verify_access = &amdgpu_verify_access, |
