@@ -1248,10 +1248,25 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
* next command submission.
*/
if (amdgpu_vm_is_bo_always_valid(vm, bo)) {
- uint32_t mem_type = bo->tbo.resource->mem_type;
+ unsigned current_domain =
+ amdgpu_mem_type_to_domain(bo->tbo.resource->mem_type);
+ bool move_to_evict = false;
- if (!(bo->preferred_domains &
- amdgpu_mem_type_to_domain(mem_type)))
+ if (!(bo->preferred_domains & current_domain)) {
+ move_to_evict = true;
+ } else if ((bo->preferred_domains & AMDGPU_GEM_DOMAIN_MASK) ==
+ (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT) &&
+ current_domain != AMDGPU_GEM_DOMAIN_VRAM) {
+ /*
+ * If userspace has provided a list of possible
+ * placements equal to VRAM+GTT, we assume VRAM is *the*
+ * preferred placement and so try to move it back there
+ * on the next submission.
+ */
+ move_to_evict = true;
+ }
+
+ if (move_to_evict)
amdgpu_vm_bo_evicted(&bo_va->base);
else
amdgpu_vm_bo_idle(&bo_va->base);