[3/3] drm/amdgpu: re-validate per VM BOs if required v2

Submitted by Zhou, David(ChunMing) on March 27, 2018, 10:16 a.m.

Details

Message ID 20180327101654.1118-3-david1.zhou@amd.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Zhou, David(ChunMing) March 27, 2018, 10:16 a.m.
From: Christian König <ckoenig.leichtzumerken@gmail.com>

If a per VM BO ends up in a allowed domain it never moves back into the
prefered domain.
v2: move to refresh function, the validation order also keeps same as lru

Change-Id: Ifb3e561785d3b464da28c439b271c26825224c5e
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-and-Tested-by: Chunming Zhou <david1.zhou@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 7 +++++++
 1 file changed, 7 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 8ad2bb705765..f28a94f3d687 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1914,6 +1914,13 @@  void amdgpu_vm_refresh_lru(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 		if (bo_base->bo->shadow)
 			ttm_bo_move_to_lru_tail(&bo_base->bo->shadow->tbo);
 		spin_unlock(&glob->lru_lock);
+		/* If the BO prefers to be in VRAM, but currently isn't add it
+		 * back to the evicted list so that it gets validated again on
+		 * the next command submission.
+		 */
+		if (bo_base->bo->preferred_domains == AMDGPU_GEM_DOMAIN_VRAM &&
+		    bo_base->bo->tbo.mem.mem_type != TTM_PL_VRAM)
+			list_move_tail(&bo_base->vm_status, &vm->evicted);
 	}
 	spin_unlock(&vm->status_lock);
 }