Commit 47c07e46 authored by Maíra Canal's avatar Maíra Canal Committed by Maíra Canal

drm/vc4: replace drm_gem_dma_object for drm_gem_object in vc4_exec_info

The array of BOs that are lookup at the start of exec doesn't need
to be instantiated as drm_gem_dma_object, as it doesn't benefit
from its attributes. So, simplify the code by replacing the array of
drm_gem_dma_object for an array of drm_gem_object in the struct
vc4_exec_info.
Suggested-by: default avatarMelissa Wen <mwen@igalia.com>
Signed-off-by: default avatarMaíra Canal <mcanal@igalia.com>
Reviewed-by: default avatarAndré Almeida <andrealmeid@igalia.com>
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Signed-off-by: default avatarMaíra Canal <mairacanal@riseup.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20230202111943.111757-2-mcanal@igalia.com
parent e0106ac9
...@@ -690,7 +690,7 @@ struct vc4_exec_info { ...@@ -690,7 +690,7 @@ struct vc4_exec_info {
/* This is the array of BOs that were looked up at the start of exec. /* This is the array of BOs that were looked up at the start of exec.
* Command validation will use indices into this array. * Command validation will use indices into this array.
*/ */
struct drm_gem_dma_object **bo; struct drm_gem_object **bo;
uint32_t bo_count; uint32_t bo_count;
/* List of BOs that are being written by the RCL. Other than /* List of BOs that are being written by the RCL. Other than
......
...@@ -199,7 +199,7 @@ vc4_save_hang_state(struct drm_device *dev) ...@@ -199,7 +199,7 @@ vc4_save_hang_state(struct drm_device *dev)
continue; continue;
for (j = 0; j < exec[i]->bo_count; j++) { for (j = 0; j < exec[i]->bo_count; j++) {
bo = to_vc4_bo(&exec[i]->bo[j]->base); bo = to_vc4_bo(exec[i]->bo[j]);
/* Retain BOs just in case they were marked purgeable. /* Retain BOs just in case they were marked purgeable.
* This prevents the BO from being purged before * This prevents the BO from being purged before
...@@ -207,8 +207,8 @@ vc4_save_hang_state(struct drm_device *dev) ...@@ -207,8 +207,8 @@ vc4_save_hang_state(struct drm_device *dev)
*/ */
WARN_ON(!refcount_read(&bo->usecnt)); WARN_ON(!refcount_read(&bo->usecnt));
refcount_inc(&bo->usecnt); refcount_inc(&bo->usecnt);
drm_gem_object_get(&exec[i]->bo[j]->base); drm_gem_object_get(exec[i]->bo[j]);
kernel_state->bo[k++] = &exec[i]->bo[j]->base; kernel_state->bo[k++] = exec[i]->bo[j];
} }
list_for_each_entry(bo, &exec[i]->unref_list, unref_head) { list_for_each_entry(bo, &exec[i]->unref_list, unref_head) {
...@@ -558,7 +558,7 @@ vc4_update_bo_seqnos(struct vc4_exec_info *exec, uint64_t seqno) ...@@ -558,7 +558,7 @@ vc4_update_bo_seqnos(struct vc4_exec_info *exec, uint64_t seqno)
unsigned i; unsigned i;
for (i = 0; i < exec->bo_count; i++) { for (i = 0; i < exec->bo_count; i++) {
bo = to_vc4_bo(&exec->bo[i]->base); bo = to_vc4_bo(exec->bo[i]);
bo->seqno = seqno; bo->seqno = seqno;
dma_resv_add_fence(bo->base.base.resv, exec->fence, dma_resv_add_fence(bo->base.base.resv, exec->fence,
...@@ -585,11 +585,8 @@ vc4_unlock_bo_reservations(struct drm_device *dev, ...@@ -585,11 +585,8 @@ vc4_unlock_bo_reservations(struct drm_device *dev,
{ {
int i; int i;
for (i = 0; i < exec->bo_count; i++) { for (i = 0; i < exec->bo_count; i++)
struct drm_gem_object *bo = &exec->bo[i]->base; dma_resv_unlock(exec->bo[i]->resv);
dma_resv_unlock(bo->resv);
}
ww_acquire_fini(acquire_ctx); ww_acquire_fini(acquire_ctx);
} }
...@@ -614,7 +611,7 @@ vc4_lock_bo_reservations(struct drm_device *dev, ...@@ -614,7 +611,7 @@ vc4_lock_bo_reservations(struct drm_device *dev,
retry: retry:
if (contended_lock != -1) { if (contended_lock != -1) {
bo = &exec->bo[contended_lock]->base; bo = exec->bo[contended_lock];
ret = dma_resv_lock_slow_interruptible(bo->resv, acquire_ctx); ret = dma_resv_lock_slow_interruptible(bo->resv, acquire_ctx);
if (ret) { if (ret) {
ww_acquire_done(acquire_ctx); ww_acquire_done(acquire_ctx);
...@@ -626,19 +623,19 @@ vc4_lock_bo_reservations(struct drm_device *dev, ...@@ -626,19 +623,19 @@ vc4_lock_bo_reservations(struct drm_device *dev,
if (i == contended_lock) if (i == contended_lock)
continue; continue;
bo = &exec->bo[i]->base; bo = exec->bo[i];
ret = dma_resv_lock_interruptible(bo->resv, acquire_ctx); ret = dma_resv_lock_interruptible(bo->resv, acquire_ctx);
if (ret) { if (ret) {
int j; int j;
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
bo = &exec->bo[j]->base; bo = exec->bo[j];
dma_resv_unlock(bo->resv); dma_resv_unlock(bo->resv);
} }
if (contended_lock != -1 && contended_lock >= i) { if (contended_lock != -1 && contended_lock >= i) {
bo = &exec->bo[contended_lock]->base; bo = exec->bo[contended_lock];
dma_resv_unlock(bo->resv); dma_resv_unlock(bo->resv);
} }
...@@ -659,7 +656,7 @@ vc4_lock_bo_reservations(struct drm_device *dev, ...@@ -659,7 +656,7 @@ vc4_lock_bo_reservations(struct drm_device *dev,
* before we commit the CL to the hardware. * before we commit the CL to the hardware.
*/ */
for (i = 0; i < exec->bo_count; i++) { for (i = 0; i < exec->bo_count; i++) {
bo = &exec->bo[i]->base; bo = exec->bo[i];
ret = dma_resv_reserve_fences(bo->resv, 1); ret = dma_resv_reserve_fences(bo->resv, 1);
if (ret) { if (ret) {
...@@ -797,7 +794,7 @@ vc4_cl_lookup_bos(struct drm_device *dev, ...@@ -797,7 +794,7 @@ vc4_cl_lookup_bos(struct drm_device *dev,
} }
drm_gem_object_get(bo); drm_gem_object_get(bo);
exec->bo[i] = (struct drm_gem_dma_object *)bo; exec->bo[i] = bo;
} }
spin_unlock(&file_priv->table_lock); spin_unlock(&file_priv->table_lock);
...@@ -805,7 +802,7 @@ vc4_cl_lookup_bos(struct drm_device *dev, ...@@ -805,7 +802,7 @@ vc4_cl_lookup_bos(struct drm_device *dev,
goto fail_put_bo; goto fail_put_bo;
for (i = 0; i < exec->bo_count; i++) { for (i = 0; i < exec->bo_count; i++) {
ret = vc4_bo_inc_usecnt(to_vc4_bo(&exec->bo[i]->base)); ret = vc4_bo_inc_usecnt(to_vc4_bo(exec->bo[i]));
if (ret) if (ret)
goto fail_dec_usecnt; goto fail_dec_usecnt;
} }
...@@ -823,12 +820,12 @@ vc4_cl_lookup_bos(struct drm_device *dev, ...@@ -823,12 +820,12 @@ vc4_cl_lookup_bos(struct drm_device *dev,
* step. * step.
*/ */
for (i-- ; i >= 0; i--) for (i-- ; i >= 0; i--)
vc4_bo_dec_usecnt(to_vc4_bo(&exec->bo[i]->base)); vc4_bo_dec_usecnt(to_vc4_bo(exec->bo[i]));
fail_put_bo: fail_put_bo:
/* Release any reference to acquired objects. */ /* Release any reference to acquired objects. */
for (i = 0; i < exec->bo_count && exec->bo[i]; i++) for (i = 0; i < exec->bo_count && exec->bo[i]; i++)
drm_gem_object_put(&exec->bo[i]->base); drm_gem_object_put(exec->bo[i]);
fail: fail:
kvfree(handles); kvfree(handles);
...@@ -974,10 +971,10 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) ...@@ -974,10 +971,10 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
if (exec->bo) { if (exec->bo) {
for (i = 0; i < exec->bo_count; i++) { for (i = 0; i < exec->bo_count; i++) {
struct vc4_bo *bo = to_vc4_bo(&exec->bo[i]->base); struct vc4_bo *bo = to_vc4_bo(exec->bo[i]);
vc4_bo_dec_usecnt(bo); vc4_bo_dec_usecnt(bo);
drm_gem_object_put(&exec->bo[i]->base); drm_gem_object_put(exec->bo[i]);
} }
kvfree(exec->bo); kvfree(exec->bo);
} }
......
...@@ -117,7 +117,7 @@ vc4_use_bo(struct vc4_exec_info *exec, uint32_t hindex) ...@@ -117,7 +117,7 @@ vc4_use_bo(struct vc4_exec_info *exec, uint32_t hindex)
hindex, exec->bo_count); hindex, exec->bo_count);
return NULL; return NULL;
} }
obj = exec->bo[hindex]; obj = to_drm_gem_dma_obj(exec->bo[hindex]);
bo = to_vc4_bo(&obj->base); bo = to_vc4_bo(&obj->base);
if (bo->validated_shader) { if (bo->validated_shader) {
...@@ -810,7 +810,7 @@ validate_gl_shader_rec(struct drm_device *dev, ...@@ -810,7 +810,7 @@ validate_gl_shader_rec(struct drm_device *dev,
return -EINVAL; return -EINVAL;
} }
bo[i] = exec->bo[src_handles[i]]; bo[i] = to_drm_gem_dma_obj(exec->bo[src_handles[i]]);
if (!bo[i]) if (!bo[i])
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment