Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: fix adding eviction fence

We can't add the eviction fence without validating the BO.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Sunil Khatri <sunil.khatri@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Christian König and committed by
Alex Deucher
2c192b06 99f30a06

+24 -8
+16 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
··· 79 79 mutex_unlock(&uq_mgr->userq_mutex); 80 80 } 81 81 82 - void amdgpu_evf_mgr_attach_fence(struct amdgpu_eviction_fence_mgr *evf_mgr, 83 - struct amdgpu_bo *bo) 82 + int amdgpu_evf_mgr_attach_fence(struct amdgpu_eviction_fence_mgr *evf_mgr, 83 + struct amdgpu_bo *bo) 84 84 { 85 85 struct dma_fence *ev_fence = amdgpu_evf_mgr_get_fence(evf_mgr); 86 + struct ttm_operation_ctx ctx = { false, false }; 86 87 struct dma_resv *resv = bo->tbo.base.resv; 88 + int ret; 87 89 88 - dma_resv_add_fence(resv, ev_fence, DMA_RESV_USAGE_BOOKKEEP); 90 + if (!dma_fence_is_signaled(ev_fence)) { 91 + 92 + amdgpu_bo_placement_from_domain(bo, bo->allowed_domains); 93 + ret = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); 94 + if (!ret) 95 + dma_resv_add_fence(resv, ev_fence, 96 + DMA_RESV_USAGE_BOOKKEEP); 97 + } else { 98 + ret = 0; 99 + } 100 + 89 101 dma_fence_put(ev_fence); 102 + return ret; 90 103 } 91 104 92 105 int amdgpu_evf_mgr_rearm(struct amdgpu_eviction_fence_mgr *evf_mgr,
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.h
··· 58 58 return ev_fence; 59 59 } 60 60 61 - void amdgpu_evf_mgr_attach_fence(struct amdgpu_eviction_fence_mgr *evf_mgr, 62 - struct amdgpu_bo *bo); 61 + int amdgpu_evf_mgr_attach_fence(struct amdgpu_eviction_fence_mgr *evf_mgr, 62 + struct amdgpu_bo *bo); 63 63 int amdgpu_evf_mgr_rearm(struct amdgpu_eviction_fence_mgr *evf_mgr, 64 64 struct drm_exec *exec); 65 65 void amdgpu_evf_mgr_detach_fence(struct amdgpu_eviction_fence_mgr *evf_mgr,
+6 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
··· 258 258 259 259 amdgpu_vm_bo_update_shared(abo); 260 260 bo_va = amdgpu_vm_bo_find(vm, abo); 261 - if (!bo_va) 261 + if (!bo_va) { 262 262 bo_va = amdgpu_vm_bo_add(adev, vm, abo); 263 - else 263 + r = amdgpu_evf_mgr_attach_fence(&fpriv->evf_mgr, abo); 264 + if (r) 265 + goto out_unlock; 266 + } else { 264 267 ++bo_va->ref_count; 268 + } 265 269 266 - amdgpu_evf_mgr_attach_fence(&fpriv->evf_mgr, abo); 267 270 drm_exec_fini(&exec); 268 271 269 272 /* Validate and add eviction fence to DMABuf imports with dynamic