diff options
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/4723-drm-amdgpu-explicitely-sync-to-VM-updates-v2.patch')
-rw-r--r-- | meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/4723-drm-amdgpu-explicitely-sync-to-VM-updates-v2.patch | 359 |
1 files changed, 359 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/4723-drm-amdgpu-explicitely-sync-to-VM-updates-v2.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/4723-drm-amdgpu-explicitely-sync-to-VM-updates-v2.patch new file mode 100644 index 00000000..d97d306d --- /dev/null +++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/4723-drm-amdgpu-explicitely-sync-to-VM-updates-v2.patch @@ -0,0 +1,359 @@ +From df1e3b51e41af0ed53e425f748a2a63cefcfa62d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com> +Date: Fri, 29 Nov 2019 11:33:54 +0100 +Subject: [PATCH 4723/4736] drm/amdgpu: explicitely sync to VM updates v2 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Allows us to reduce the overhead while syncing to fences a bit. + +v2: also drop adev parameter from the functions + +Change-Id: I0828d0691fb87f0b9ae9205b15e18e6509c86d61 +Signed-off-by: Christian König <christian.koenig@amd.com> +Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> +Signed-off-by: Rahul Kumar <rahul.kumar1@amd.com> +--- + .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 8 ++-- + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 19 +++------- + drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 13 +++---- + drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 3 +- + drivers/gpu/drm/amd/amdgpu/amdgpu_sem.c | 2 +- + drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 38 ++++++++++++++----- + drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h | 8 ++-- + drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 2 +- + 8 files changed, 52 insertions(+), 41 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +index 3d7d6b5f423e..a21201e579b1 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +@@ -392,7 +392,7 @@ static int vm_update_pds(struct amdgpu_vm *vm, struct amdgpu_sync *sync) + if (ret) + return ret; + +- return amdgpu_sync_fence(NULL, sync, vm->last_update, false); ++ return amdgpu_sync_fence(sync, vm->last_update, false); + } + + static uint64_t get_pte_flags(struct amdgpu_device *adev, struct kgd_mem *mem) +@@ -807,7 +807,7 @@ static int unmap_bo_from_gpuvm(struct amdgpu_device *adev, + + amdgpu_vm_clear_freed(adev, vm, &bo_va->last_pt_update); + +- amdgpu_sync_fence(NULL, sync, bo_va->last_pt_update, false); ++ amdgpu_sync_fence(sync, bo_va->last_pt_update, false); + + return 0; + } +@@ -826,7 +826,7 @@ static int update_gpuvm_pte(struct amdgpu_device *adev, + return ret; + } + +- return amdgpu_sync_fence(NULL, sync, bo_va->last_pt_update, false); ++ return amdgpu_sync_fence(sync, bo_va->last_pt_update, false); + } + + static int map_bo_to_gpuvm(struct amdgpu_device *adev, +@@ -2337,7 +2337,7 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef) + pr_debug("Memory eviction: Validate BOs failed. Try again\n"); + goto validate_map_fail; + } +- ret = amdgpu_sync_fence(NULL, &sync_obj, bo->tbo.moving, false); ++ ret = amdgpu_sync_fence(&sync_obj, bo->tbo.moving, false); + if (ret) { + pr_debug("Memory eviction: Sync BO fence failed. Try again\n"); + goto validate_map_fail; +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +index e8dfbcfad034..2c570274b5a6 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +@@ -790,29 +790,23 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p) + if (r) + return r; + +- r = amdgpu_sync_fence(adev, &p->job->sync, +- fpriv->prt_va->last_pt_update, false); ++ r = amdgpu_sync_vm_fence(&p->job->sync, fpriv->prt_va->last_pt_update); + if (r) + return r; + + if (amdgpu_mcbp || amdgpu_sriov_vf(adev)) { +- struct dma_fence *f; +- + bo_va = fpriv->csa_va; + BUG_ON(!bo_va); + r = amdgpu_vm_bo_update(adev, bo_va, false); + if (r) + return r; + +- f = bo_va->last_pt_update; +- r = amdgpu_sync_fence(adev, &p->job->sync, f, false); ++ r = amdgpu_sync_vm_fence(&p->job->sync, bo_va->last_pt_update); + if (r) + return r; + } + + amdgpu_bo_list_for_each_entry(e, p->bo_list) { +- struct dma_fence *f; +- + /* ignore duplicates */ + bo = ttm_to_amdgpu_bo(e->tv.bo); + if (!bo) +@@ -826,8 +820,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p) + if (r) + return r; + +- f = bo_va->last_pt_update; +- r = amdgpu_sync_fence(adev, &p->job->sync, f, false); ++ r = amdgpu_sync_vm_fence(&p->job->sync, bo_va->last_pt_update); + if (r) + return r; + } +@@ -840,7 +833,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p) + if (r) + return r; + +- r = amdgpu_sync_fence(adev, &p->job->sync, vm->last_update, false); ++ r = amdgpu_sync_vm_fence(&p->job->sync, vm->last_update); + if (r) + return r; + +@@ -982,7 +975,7 @@ static int amdgpu_cs_process_fence_dep(struct amdgpu_cs_parser *p, + dma_fence_put(old); + } + +- r = amdgpu_sync_fence(p->adev, &p->job->sync, fence, true); ++ r = amdgpu_sync_fence(&p->job->sync, fence, true); + dma_fence_put(fence); + if (r) + return r; +@@ -1003,7 +996,7 @@ static int amdgpu_syncobj_lookup_and_add_to_sync(struct amdgpu_cs_parser *p, + + return r; + } +- r = amdgpu_sync_fence(p->adev, &p->job->sync, fence, true); ++ r = amdgpu_sync_fence(&p->job->sync, fence, true); + dma_fence_put(fence); + + return r; +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +index dfe155566571..dc2ea2b60ed8 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +@@ -206,7 +206,7 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm, + int r; + + if (ring->vmid_wait && !dma_fence_is_signaled(ring->vmid_wait)) +- return amdgpu_sync_fence(adev, sync, ring->vmid_wait, false); ++ return amdgpu_sync_fence(sync, ring->vmid_wait, false); + + fences = kmalloc_array(sizeof(void *), id_mgr->num_ids, GFP_KERNEL); + if (!fences) +@@ -241,7 +241,7 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm, + return -ENOMEM; + } + +- r = amdgpu_sync_fence(adev, sync, &array->base, false); ++ r = amdgpu_sync_fence(sync, &array->base, false); + dma_fence_put(ring->vmid_wait); + ring->vmid_wait = &array->base; + return r; +@@ -294,7 +294,7 @@ static int amdgpu_vmid_grab_reserved(struct amdgpu_vm *vm, + tmp = amdgpu_sync_peek_fence(&(*id)->active, ring); + if (tmp) { + *id = NULL; +- r = amdgpu_sync_fence(adev, sync, tmp, false); ++ r = amdgpu_sync_fence(sync, tmp, false); + return r; + } + needs_flush = true; +@@ -303,7 +303,7 @@ static int amdgpu_vmid_grab_reserved(struct amdgpu_vm *vm, + /* Good we can use this VMID. Remember this submission as + * user of the VMID. + */ +- r = amdgpu_sync_fence(ring->adev, &(*id)->active, fence, false); ++ r = amdgpu_sync_fence(&(*id)->active, fence, false); + if (r) + return r; + +@@ -375,7 +375,7 @@ static int amdgpu_vmid_grab_used(struct amdgpu_vm *vm, + /* Good, we can use this VMID. Remember this submission as + * user of the VMID. + */ +- r = amdgpu_sync_fence(ring->adev, &(*id)->active, fence, false); ++ r = amdgpu_sync_fence(&(*id)->active, fence, false); + if (r) + return r; + +@@ -435,8 +435,7 @@ int amdgpu_vmid_grab(struct amdgpu_vm *vm, struct amdgpu_ring *ring, + id = idle; + + /* Remember this submission as user of the VMID */ +- r = amdgpu_sync_fence(ring->adev, &id->active, +- fence, false); ++ r = amdgpu_sync_fence(&id->active, fence, false); + if (r) + goto error; + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +index 71fd9bb7ead7..8b7fce7c811f 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +@@ -193,8 +193,7 @@ static struct dma_fence *amdgpu_job_dependency(struct drm_sched_job *sched_job, + fence = amdgpu_sync_get_fence(&job->sync, &explicit); + if (fence && explicit) { + if (drm_sched_dependency_optimized(fence, s_entity)) { +- r = amdgpu_sync_fence(ring->adev, &job->sched_sync, +- fence, false); ++ r = amdgpu_sync_fence(&job->sched_sync, fence, false); + if (r) + DRM_ERROR("Error adding fence (%d)\n", r); + } +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.c +index 3d5beb00b0db..a467b177543b 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.c +@@ -408,7 +408,7 @@ int amdgpu_sem_add_cs(struct amdgpu_ctx *ctx, struct drm_sched_entity *entity, + mutex_lock(¢ity->sem_lock); + list_for_each_entry_safe(dep, tmp, ¢ity->sem_dep_list, + list) { +- r = amdgpu_sync_fence(ctx->adev, sync, dep->fence, true); ++ r = amdgpu_sync_fence(sync, dep->fence, true); + if (r) + goto err; + dma_fence_put(dep->fence); +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +index 2d6f5ec77a68..17f017fc8fcb 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +@@ -130,7 +130,8 @@ static void amdgpu_sync_keep_later(struct dma_fence **keep, + * Tries to add the fence to an existing hash entry. Returns true when an entry + * was found, false otherwise. + */ +-static bool amdgpu_sync_add_later(struct amdgpu_sync *sync, struct dma_fence *f, bool explicit) ++static bool amdgpu_sync_add_later(struct amdgpu_sync *sync, struct dma_fence *f, ++ bool explicit) + { + struct amdgpu_sync_entry *e; + +@@ -152,19 +153,18 @@ static bool amdgpu_sync_add_later(struct amdgpu_sync *sync, struct dma_fence *f, + * amdgpu_sync_fence - remember to sync to this fence + * + * @sync: sync object to add fence to +- * @fence: fence to sync to ++ * @f: fence to sync to ++ * @explicit: if this is an explicit dependency + * ++ * Add the fence to the sync object. + */ +-int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync, +- struct dma_fence *f, bool explicit) ++int amdgpu_sync_fence(struct amdgpu_sync *sync, struct dma_fence *f, ++ bool explicit) + { + struct amdgpu_sync_entry *e; + + if (!f) + return 0; +- if (amdgpu_sync_same_dev(adev, f) && +- amdgpu_sync_get_owner(f) == AMDGPU_FENCE_OWNER_VM) +- amdgpu_sync_keep_later(&sync->last_vm_update, f); + + if (amdgpu_sync_add_later(sync, f, explicit)) + return 0; +@@ -180,6 +180,24 @@ int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync, + return 0; + } + ++/** ++ * amdgpu_sync_vm_fence - remember to sync to this VM fence ++ * ++ * @adev: amdgpu device ++ * @sync: sync object to add fence to ++ * @fence: the VM fence to add ++ * ++ * Add the fence to the sync object and remember it as VM update. ++ */ ++int amdgpu_sync_vm_fence(struct amdgpu_sync *sync, struct dma_fence *fence) ++{ ++ if (!fence) ++ return 0; ++ ++ amdgpu_sync_keep_later(&sync->last_vm_update, fence); ++ return amdgpu_sync_fence(sync, fence, false); ++} ++ + /** + * amdgpu_sync_resv - sync to a reservation object + * +@@ -205,7 +223,7 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, + + /* always sync to the exclusive fence */ + f = reservation_object_get_excl(resv); +- r = amdgpu_sync_fence(adev, sync, f, false); ++ r = amdgpu_sync_fence(sync, f, false); + + flist = reservation_object_get_list(resv); + if (!flist || r) +@@ -240,7 +258,7 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, + continue; + } + +- r = amdgpu_sync_fence(adev, sync, f, false); ++ r = amdgpu_sync_fence(sync, f, false); + if (r) + break; + } +@@ -341,7 +359,7 @@ int amdgpu_sync_clone(struct amdgpu_sync *source, struct amdgpu_sync *clone) + hash_for_each_safe(source->fences, i, tmp, e, node) { + f = e->fence; + if (!dma_fence_is_signaled(f)) { +- r = amdgpu_sync_fence(NULL, clone, f, e->explicit); ++ r = amdgpu_sync_fence(clone, f, e->explicit); + if (r) + return r; + } else { +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h +index 10cf23a57f17..7ca71b306301 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h +@@ -40,8 +40,9 @@ struct amdgpu_sync { + }; + + void amdgpu_sync_create(struct amdgpu_sync *sync); +-int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync, +- struct dma_fence *f, bool explicit); ++int amdgpu_sync_fence(struct amdgpu_sync *sync, struct dma_fence *f, ++ bool explicit); ++int amdgpu_sync_vm_fence(struct amdgpu_sync *sync, struct dma_fence *fence); + int amdgpu_sync_resv(struct amdgpu_device *adev, + struct amdgpu_sync *sync, + struct reservation_object *resv, +@@ -49,7 +50,8 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, + bool explicit_sync); + struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync, + struct amdgpu_ring *ring); +-struct dma_fence *amdgpu_sync_get_fence(struct amdgpu_sync *sync, bool *explicit); ++struct dma_fence *amdgpu_sync_get_fence(struct amdgpu_sync *sync, ++ bool *explicit); + int amdgpu_sync_clone(struct amdgpu_sync *source, struct amdgpu_sync *clone); + int amdgpu_sync_wait(struct amdgpu_sync *sync, bool intr); + void amdgpu_sync_free(struct amdgpu_sync *sync); +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +index e8db1467a71d..107def9c3611 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +@@ -71,7 +71,7 @@ static int amdgpu_vm_sdma_prepare(struct amdgpu_vm_update_params *p, + p->num_dw_left = ndw; + + /* Wait for moves to be completed */ +- r = amdgpu_sync_fence(p->adev, &p->job->sync, exclusive, false); ++ r = amdgpu_sync_fence(&p->job->sync, exclusive, false); + if (r) + return r; + +-- +2.17.1 + |