accel/ivpu: Use whole user and shave ranges for preemption buffers
authorKarol Wachowski <karol.wachowski@intel.com>
Mon, 30 Sep 2024 19:53:17 +0000 (21:53 +0200)
committerJacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Fri, 11 Oct 2024 10:44:39 +0000 (12:44 +0200)
Do not restrict range for preemption buffers allocation just to the end
of user and shave ranges, use them whole instead to avoid situation
where end of range might be already allocated causing preemption buffers
allocation to fail.

Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240930195322.461209-27-jacek.lawrynowicz@linux.intel.com
Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
drivers/accel/ivpu/ivpu_job.c

index 48272bc..cd41b87 100644 (file)
@@ -33,24 +33,19 @@ static int ivpu_preemption_buffers_create(struct ivpu_device *vdev,
 {
        u64 primary_size = ALIGN(vdev->fw->primary_preempt_buf_size, PAGE_SIZE);
        u64 secondary_size = ALIGN(vdev->fw->secondary_preempt_buf_size, PAGE_SIZE);
-       struct ivpu_addr_range range;
 
        if (vdev->fw->sched_mode != VPU_SCHEDULING_MODE_HW)
                return 0;
 
-       range.start = vdev->hw->ranges.user.end - (primary_size * IVPU_NUM_CMDQS_PER_CTX);
-       range.end = vdev->hw->ranges.user.end;
-       cmdq->primary_preempt_buf = ivpu_bo_create(vdev, &file_priv->ctx, &range, primary_size,
-                                                  DRM_IVPU_BO_WC);
+       cmdq->primary_preempt_buf = ivpu_bo_create(vdev, &file_priv->ctx, &vdev->hw->ranges.user,
+                                                  primary_size, DRM_IVPU_BO_WC);
        if (!cmdq->primary_preempt_buf) {
                ivpu_err(vdev, "Failed to create primary preemption buffer\n");
                return -ENOMEM;
        }
 
-       range.start = vdev->hw->ranges.shave.end - (secondary_size * IVPU_NUM_CMDQS_PER_CTX);
-       range.end = vdev->hw->ranges.shave.end;
-       cmdq->secondary_preempt_buf = ivpu_bo_create(vdev, &file_priv->ctx, &range, secondary_size,
-                                                    DRM_IVPU_BO_WC);
+       cmdq->secondary_preempt_buf = ivpu_bo_create(vdev, &file_priv->ctx, &vdev->hw->ranges.shave,
+                                                    secondary_size, DRM_IVPU_BO_WC);
        if (!cmdq->secondary_preempt_buf) {
                ivpu_err(vdev, "Failed to create secondary preemption buffer\n");
                goto err_free_primary;