forked from luck/tmp_suning_uos_patched
dma-buf: allow reserving more than one shared fence slot
Let's support simultaneous submissions to multiple engines. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Huang Rui <ray.huang@amd.com> Link: https://patchwork.kernel.org/patch/10626149/
This commit is contained in:
parent
27836b641c
commit
ca05359f1e
|
@ -56,9 +56,10 @@ const char reservation_seqcount_string[] = "reservation_seqcount";
|
|||
EXPORT_SYMBOL(reservation_seqcount_string);
|
||||
|
||||
/**
|
||||
* reservation_object_reserve_shared - Reserve space to add a shared
|
||||
* fence to a reservation_object.
|
||||
* reservation_object_reserve_shared - Reserve space to add shared fences to
|
||||
* a reservation_object.
|
||||
* @obj: reservation object
|
||||
* @num_fences: number of fences we want to add
|
||||
*
|
||||
* Should be called before reservation_object_add_shared_fence(). Must
|
||||
* be called with obj->lock held.
|
||||
|
@ -66,7 +67,8 @@ EXPORT_SYMBOL(reservation_seqcount_string);
|
|||
* RETURNS
|
||||
* Zero for success, or -errno
|
||||
*/
|
||||
int reservation_object_reserve_shared(struct reservation_object *obj)
|
||||
int reservation_object_reserve_shared(struct reservation_object *obj,
|
||||
unsigned int num_fences)
|
||||
{
|
||||
struct reservation_object_list *old, *new;
|
||||
unsigned int i, j, k, max;
|
||||
|
@ -74,10 +76,11 @@ int reservation_object_reserve_shared(struct reservation_object *obj)
|
|||
old = reservation_object_get_list(obj);
|
||||
|
||||
if (old && old->shared_max) {
|
||||
if (old->shared_count < old->shared_max)
|
||||
if ((old->shared_count + num_fences) <= old->shared_max)
|
||||
return 0;
|
||||
else
|
||||
max = old->shared_max * 2;
|
||||
max = max(old->shared_count + num_fences,
|
||||
old->shared_max * 2);
|
||||
} else {
|
||||
max = 4;
|
||||
}
|
||||
|
|
|
@ -955,7 +955,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
|
|||
if (r)
|
||||
return r;
|
||||
|
||||
r = reservation_object_reserve_shared(vm->root.base.bo->tbo.resv);
|
||||
r = reservation_object_reserve_shared(vm->root.base.bo->tbo.resv, 1);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
|
|
|
@ -640,7 +640,7 @@ int amdgpu_bo_backup_to_shadow(struct amdgpu_device *adev,
|
|||
bo_addr = amdgpu_bo_gpu_offset(bo);
|
||||
shadow_addr = amdgpu_bo_gpu_offset(bo->shadow);
|
||||
|
||||
r = reservation_object_reserve_shared(bo->tbo.resv);
|
||||
r = reservation_object_reserve_shared(bo->tbo.resv, 1);
|
||||
if (r)
|
||||
goto err;
|
||||
|
||||
|
|
|
@ -772,7 +772,7 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
|
|||
|
||||
ring = container_of(vm->entity.rq->sched, struct amdgpu_ring, sched);
|
||||
|
||||
r = reservation_object_reserve_shared(bo->tbo.resv);
|
||||
r = reservation_object_reserve_shared(bo->tbo.resv, 1);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
|
@ -1839,7 +1839,7 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
|
|||
if (r)
|
||||
goto error_free;
|
||||
|
||||
r = reservation_object_reserve_shared(vm->root.base.bo->tbo.resv);
|
||||
r = reservation_object_reserve_shared(vm->root.base.bo->tbo.resv, 1);
|
||||
if (r)
|
||||
goto error_free;
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit)
|
|||
struct reservation_object *robj = bo->obj->resv;
|
||||
|
||||
if (!(bo->flags & ETNA_SUBMIT_BO_WRITE)) {
|
||||
ret = reservation_object_reserve_shared(robj);
|
||||
ret = reservation_object_reserve_shared(robj, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -892,7 +892,7 @@ static void export_fence(struct i915_vma *vma,
|
|||
reservation_object_lock(resv, NULL);
|
||||
if (flags & EXEC_OBJECT_WRITE)
|
||||
reservation_object_add_excl_fence(resv, &rq->fence);
|
||||
else if (reservation_object_reserve_shared(resv) == 0)
|
||||
else if (reservation_object_reserve_shared(resv, 1) == 0)
|
||||
reservation_object_add_shared_fence(resv, &rq->fence);
|
||||
reservation_object_unlock(resv);
|
||||
}
|
||||
|
|
|
@ -241,7 +241,8 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit)
|
|||
* strange place to call it. OTOH this is a
|
||||
* convenient can-fail point to hook it in.
|
||||
*/
|
||||
ret = reservation_object_reserve_shared(msm_obj->resv);
|
||||
ret = reservation_object_reserve_shared(msm_obj->resv,
|
||||
1);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -341,7 +341,7 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e
|
|||
int ret = 0, i;
|
||||
|
||||
if (!exclusive) {
|
||||
ret = reservation_object_reserve_shared(resv);
|
||||
ret = reservation_object_reserve_shared(resv, 1);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
|
@ -234,7 +234,7 @@ static int qxl_release_validate_bo(struct qxl_bo *bo)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = reservation_object_reserve_shared(bo->tbo.resv);
|
||||
ret = reservation_object_reserve_shared(bo->tbo.resv, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -831,7 +831,7 @@ static int radeon_vm_update_ptes(struct radeon_device *rdev,
|
|||
int r;
|
||||
|
||||
radeon_sync_resv(rdev, &ib->sync, pt->tbo.resv, true);
|
||||
r = reservation_object_reserve_shared(pt->tbo.resv);
|
||||
r = reservation_object_reserve_shared(pt->tbo.resv, 1);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
|
|
|
@ -872,7 +872,7 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
|
|||
if (fence) {
|
||||
reservation_object_add_shared_fence(bo->resv, fence);
|
||||
|
||||
ret = reservation_object_reserve_shared(bo->resv);
|
||||
ret = reservation_object_reserve_shared(bo->resv, 1);
|
||||
if (unlikely(ret))
|
||||
return ret;
|
||||
|
||||
|
@ -977,7 +977,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
|
|||
bool has_erestartsys = false;
|
||||
int i, ret;
|
||||
|
||||
ret = reservation_object_reserve_shared(bo->resv);
|
||||
ret = reservation_object_reserve_shared(bo->resv, 1);
|
||||
if (unlikely(ret))
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
|
|||
if (!entry->shared)
|
||||
continue;
|
||||
|
||||
ret = reservation_object_reserve_shared(bo->resv);
|
||||
ret = reservation_object_reserve_shared(bo->resv, 1);
|
||||
if (!ret)
|
||||
continue;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
|
|||
}
|
||||
|
||||
if (!ret && entry->shared)
|
||||
ret = reservation_object_reserve_shared(bo->resv);
|
||||
ret = reservation_object_reserve_shared(bo->resv, 1);
|
||||
|
||||
if (unlikely(ret != 0)) {
|
||||
if (ret == -EINTR)
|
||||
|
|
|
@ -305,7 +305,7 @@ v3d_lock_bo_reservations(struct drm_device *dev,
|
|||
for (i = 0; i < exec->bo_count; i++) {
|
||||
bo = to_v3d_bo(&exec->bo[i]->base);
|
||||
|
||||
ret = reservation_object_reserve_shared(bo->resv);
|
||||
ret = reservation_object_reserve_shared(bo->resv, 1);
|
||||
if (ret) {
|
||||
v3d_unlock_bo_reservations(dev, exec, acquire_ctx);
|
||||
return ret;
|
||||
|
|
|
@ -635,7 +635,7 @@ vc4_lock_bo_reservations(struct drm_device *dev,
|
|||
for (i = 0; i < exec->bo_count; i++) {
|
||||
bo = to_vc4_bo(&exec->bo[i]->base);
|
||||
|
||||
ret = reservation_object_reserve_shared(bo->resv);
|
||||
ret = reservation_object_reserve_shared(bo->resv, 1);
|
||||
if (ret) {
|
||||
vc4_unlock_bo_reservations(dev, exec, acquire_ctx);
|
||||
return ret;
|
||||
|
|
|
@ -180,7 +180,7 @@ int vgem_fence_attach_ioctl(struct drm_device *dev,
|
|||
reservation_object_lock(resv, NULL);
|
||||
if (arg->flags & VGEM_FENCE_WRITE)
|
||||
reservation_object_add_excl_fence(resv, fence);
|
||||
else if ((ret = reservation_object_reserve_shared(resv)) == 0)
|
||||
else if ((ret = reservation_object_reserve_shared(resv, 1)) == 0)
|
||||
reservation_object_add_shared_fence(resv, fence);
|
||||
reservation_object_unlock(resv);
|
||||
|
||||
|
|
|
@ -261,7 +261,8 @@ reservation_object_get_excl_rcu(struct reservation_object *obj)
|
|||
return fence;
|
||||
}
|
||||
|
||||
int reservation_object_reserve_shared(struct reservation_object *obj);
|
||||
int reservation_object_reserve_shared(struct reservation_object *obj,
|
||||
unsigned int num_fences);
|
||||
void reservation_object_add_shared_fence(struct reservation_object *obj,
|
||||
struct dma_fence *fence);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user