Skip to content

Commit 4113602

Browse files
committed
accel/ivpu: Reserve all non-command bo's using DMA_RESV_USAGE_BOOKKEEP
Use DMA_RESV_USAGE_BOOKKEEP reservation for buffer objects, except for command buffers for which we use DMA_RESV_USAGE_WRITE (since VPU can write to command buffer context save area). Fixes: 0ec8671 ("accel/ivpu: Fix S3 system suspend when not idle") Reviewed-by: Jeffrey Hugo <[email protected]> Signed-off-by: Stanislaw Gruszka <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 50d3004 commit 4113602

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

drivers/accel/ivpu/ivpu_job.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ ivpu_job_prepare_bos_for_submit(struct drm_file *file, struct ivpu_job *job, u32
431431
struct ivpu_file_priv *file_priv = file->driver_priv;
432432
struct ivpu_device *vdev = file_priv->vdev;
433433
struct ww_acquire_ctx acquire_ctx;
434+
enum dma_resv_usage usage;
434435
struct ivpu_bo *bo;
435436
int ret;
436437
u32 i;
@@ -461,22 +462,28 @@ ivpu_job_prepare_bos_for_submit(struct drm_file *file, struct ivpu_job *job, u32
461462

462463
job->cmd_buf_vpu_addr = bo->vpu_addr + commands_offset;
463464

464-
ret = drm_gem_lock_reservations((struct drm_gem_object **)job->bos, 1, &acquire_ctx);
465+
ret = drm_gem_lock_reservations((struct drm_gem_object **)job->bos, buf_count,
466+
&acquire_ctx);
465467
if (ret) {
466468
ivpu_warn(vdev, "Failed to lock reservations: %d\n", ret);
467469
return ret;
468470
}
469471

470-
ret = dma_resv_reserve_fences(bo->base.resv, 1);
471-
if (ret) {
472-
ivpu_warn(vdev, "Failed to reserve fences: %d\n", ret);
473-
goto unlock_reservations;
472+
for (i = 0; i < buf_count; i++) {
473+
ret = dma_resv_reserve_fences(job->bos[i]->base.resv, 1);
474+
if (ret) {
475+
ivpu_warn(vdev, "Failed to reserve fences: %d\n", ret);
476+
goto unlock_reservations;
477+
}
474478
}
475479

476-
dma_resv_add_fence(bo->base.resv, job->done_fence, DMA_RESV_USAGE_WRITE);
480+
for (i = 0; i < buf_count; i++) {
481+
usage = (i == CMD_BUF_IDX) ? DMA_RESV_USAGE_WRITE : DMA_RESV_USAGE_BOOKKEEP;
482+
dma_resv_add_fence(job->bos[i]->base.resv, job->done_fence, usage);
483+
}
477484

478485
unlock_reservations:
479-
drm_gem_unlock_reservations((struct drm_gem_object **)job->bos, 1, &acquire_ctx);
486+
drm_gem_unlock_reservations((struct drm_gem_object **)job->bos, buf_count, &acquire_ctx);
480487

481488
wmb(); /* Flush write combining buffers */
482489

0 commit comments

Comments
 (0)