dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] accel/ivpu: Reserve all non-command bo's using DMA_RESV_USAGE_BOOKKEEP
@ 2023-04-13  6:38 Stanislaw Gruszka
  2023-05-11  0:23 ` Jeffrey Hugo
  2023-06-06 12:52 ` Stanislaw Gruszka
  0 siblings, 2 replies; 3+ messages in thread
From: Stanislaw Gruszka @ 2023-04-13  6:38 UTC (permalink / raw)
  To: dri-devel; +Cc: Stanislaw Gruszka, Oded Gabbay, Jeffrey Hugo, Jacek Lawrynowicz

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: 0ec8671837a6 ("accel/ivpu: Fix S3 system suspend when not idle")
Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
---
 drivers/accel/ivpu/ivpu_job.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c
index 3c6f1e16cf2f..d45be0615b47 100644
--- a/drivers/accel/ivpu/ivpu_job.c
+++ b/drivers/accel/ivpu/ivpu_job.c
@@ -431,6 +431,7 @@ ivpu_job_prepare_bos_for_submit(struct drm_file *file, struct ivpu_job *job, u32
 	struct ivpu_file_priv *file_priv = file->driver_priv;
 	struct ivpu_device *vdev = file_priv->vdev;
 	struct ww_acquire_ctx acquire_ctx;
+	enum dma_resv_usage usage;
 	struct ivpu_bo *bo;
 	int ret;
 	u32 i;
@@ -461,22 +462,28 @@ ivpu_job_prepare_bos_for_submit(struct drm_file *file, struct ivpu_job *job, u32
 
 	job->cmd_buf_vpu_addr = bo->vpu_addr + commands_offset;
 
-	ret = drm_gem_lock_reservations((struct drm_gem_object **)job->bos, 1, &acquire_ctx);
+	ret = drm_gem_lock_reservations((struct drm_gem_object **)job->bos, buf_count,
+					&acquire_ctx);
 	if (ret) {
 		ivpu_warn(vdev, "Failed to lock reservations: %d\n", ret);
 		return ret;
 	}
 
-	ret = dma_resv_reserve_fences(bo->base.resv, 1);
-	if (ret) {
-		ivpu_warn(vdev, "Failed to reserve fences: %d\n", ret);
-		goto unlock_reservations;
+	for (i = 0; i < buf_count; i++) {
+		ret = dma_resv_reserve_fences(job->bos[i]->base.resv, 1);
+		if (ret) {
+			ivpu_warn(vdev, "Failed to reserve fences: %d\n", ret);
+			goto unlock_reservations;
+		}
 	}
 
-	dma_resv_add_fence(bo->base.resv, job->done_fence, DMA_RESV_USAGE_WRITE);
+	for (i = 0; i < buf_count; i++) {
+		usage = (i == CMD_BUF_IDX) ? DMA_RESV_USAGE_WRITE : DMA_RESV_USAGE_BOOKKEEP;
+		dma_resv_add_fence(job->bos[i]->base.resv, job->done_fence, usage);
+	}
 
 unlock_reservations:
-	drm_gem_unlock_reservations((struct drm_gem_object **)job->bos, 1, &acquire_ctx);
+	drm_gem_unlock_reservations((struct drm_gem_object **)job->bos, buf_count, &acquire_ctx);
 
 	wmb(); /* Flush write combining buffers */
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] accel/ivpu: Reserve all non-command bo's using DMA_RESV_USAGE_BOOKKEEP
  2023-04-13  6:38 [PATCH] accel/ivpu: Reserve all non-command bo's using DMA_RESV_USAGE_BOOKKEEP Stanislaw Gruszka
@ 2023-05-11  0:23 ` Jeffrey Hugo
  2023-06-06 12:52 ` Stanislaw Gruszka
  1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey Hugo @ 2023-05-11  0:23 UTC (permalink / raw)
  To: Stanislaw Gruszka, dri-devel; +Cc: Oded Gabbay, Jacek Lawrynowicz

On 4/13/2023 12:38 AM, Stanislaw Gruszka wrote:
> 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: 0ec8671837a6 ("accel/ivpu: Fix S3 system suspend when not idle")
> Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>

I'm pretty new to fences, but this seems sane based on what Daniel 
suggested and what I'm seeing in code.

Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] accel/ivpu: Reserve all non-command bo's using DMA_RESV_USAGE_BOOKKEEP
  2023-04-13  6:38 [PATCH] accel/ivpu: Reserve all non-command bo's using DMA_RESV_USAGE_BOOKKEEP Stanislaw Gruszka
  2023-05-11  0:23 ` Jeffrey Hugo
@ 2023-06-06 12:52 ` Stanislaw Gruszka
  1 sibling, 0 replies; 3+ messages in thread
From: Stanislaw Gruszka @ 2023-06-06 12:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Oded Gabbay, Jeffrey Hugo, Jacek Lawrynowicz

On Thu, Apr 13, 2023 at 08:38:10AM +0200, Stanislaw Gruszka wrote:
> 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: 0ec8671837a6 ("accel/ivpu: Fix S3 system suspend when not idle")
> Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Applied to drm-misc-fixes


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-06 12:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13  6:38 [PATCH] accel/ivpu: Reserve all non-command bo's using DMA_RESV_USAGE_BOOKKEEP Stanislaw Gruszka
2023-05-11  0:23 ` Jeffrey Hugo
2023-06-06 12:52 ` Stanislaw Gruszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).