[COMMON] g2d: move setting hwfc data
authorhyesoo.yu <hyesoo.yu@samsung.com>
Fri, 18 Aug 2017 00:59:12 +0000 (09:59 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:22:14 +0000 (20:22 +0300)
HWFC buffer information sholud be set from
repeater driver before payload calculation.

Change-Id: I1497b1673ead7fc4edcae6df1e0ce5ff095b2bdb
Signed-off-by: hyesoo.yu <hyesoo.yu@samsung.com>
drivers/gpu/exynos/g2d/g2d_uapi_process.c

index 5a4ebc1e94cd683bb5f8b401d859342de8c34a98..41f874c9b36e7994290ed52287fe3299783a2388 100644 (file)
@@ -209,50 +209,8 @@ static int g2d_get_dmabuf(struct g2d_task *task,
                        return PTR_ERR(dmabuf);
                }
        } else {
-               struct g2d_task *ptask;
-               unsigned long flags;
-               u32 idx;
-
-               /*
-                * The index from repeater driver used on both buffer index and
-                * job id, and this index is managed by repeater driver to
-                * avoid overwriting the buffer index and job id while MFC is
-                * running.
-                */
-               hwfc_get_valid_buffer(&idx);
-               BUG_ON(idx >= ctx->hwfc_info->buffer_count);
-
-               spin_lock_irqsave(&task->g2d_dev->lock_task, flags);
-
-               ptask = task->g2d_dev->tasks;
-
-               while (ptask != NULL) {
-                       if (ptask == task) {
-                               ptask = ptask->next;
-                               continue;
-                       }
-                       if ((ptask->job_id == idx) &&
-                                       !is_task_state_idle(ptask)) {
-                               dev_err(dev, "%s: The task using that job #%d is not idle\n",
-                               __func__, idx);
-
-                               spin_unlock_irqrestore(
-                                       &task->g2d_dev->lock_task, flags);
-                               return ret;
-                       }
-                       ptask = ptask->next;
-               }
-               task->job_id = idx;
-
-               spin_unlock_irqrestore(&task->g2d_dev->lock_task, flags);
-
-               dmabuf = ctx->hwfc_info->bufs[idx];
+               dmabuf = ctx->hwfc_info->bufs[task->job_id];
                get_dma_buf(dmabuf);
-
-               data->dmabuf.offset = 0;
-               data->length = dmabuf->size;
-
-               g2d_stamp_task(task, G2D_STAMP_STATE_HWFCBUF);
        }
 
        if (dmabuf->size < data->dmabuf.offset) {
@@ -687,9 +645,61 @@ static int g2d_get_target(struct g2d_device *g2d_dev, struct g2d_context *ctx,
                return -EINVAL;
        }
 
-       if (IS_HWFC(task->flags))
+       if (IS_HWFC(task->flags)) {
+               struct g2d_task *ptask;
+               unsigned long flags;
+               u32 idx;
+
                target->buffer_type = G2D_BUFTYPE_DMABUF;
 
+               /*
+                * The index from repeater driver used on both buffer index and
+                * job id, and this index is managed by repeater driver to
+                * avoid overwriting the buffer index and job id while MFC is
+                * running.
+                */
+               ret = hwfc_get_valid_buffer(&idx);
+               if (ret < 0) {
+                       dev_err(dev, "%s: Failed to get valid buffer from repeater\n",
+                               __func__);
+                       return ret;
+               }
+
+               BUG_ON(idx >= ctx->hwfc_info->buffer_count);
+
+               spin_lock_irqsave(&task->g2d_dev->lock_task, flags);
+
+               ptask = task->g2d_dev->tasks;
+
+               while (ptask != NULL) {
+                       if (ptask == task) {
+                               ptask = ptask->next;
+                               continue;
+                       }
+                       if ((ptask->job_id == idx) &&
+                                       !is_task_state_idle(ptask)) {
+                               dev_err(dev, "%s: The %d task is not idle\n",
+                               __func__, idx);
+
+                               spin_unlock_irqrestore(
+                                       &task->g2d_dev->lock_task, flags);
+
+                               return -EINVAL;
+                       }
+                       ptask = ptask->next;
+               }
+
+               task->job_id = idx;
+
+               spin_unlock_irqrestore(&task->g2d_dev->lock_task, flags);
+
+               data->num_buffers = 1;
+               data->buffer[0].dmabuf.offset = 0;
+               data->buffer[0].length = ctx->hwfc_info->bufs[idx]->size;
+
+               g2d_stamp_task(task, G2D_STAMP_STATE_HWFCBUF);
+       }
+
        if (target->buffer_type == G2D_BUFTYPE_EMPTY) {
                dev_err(dev, "%s: target has no buffer - flags: %#x\n",
                        __func__, task->flags);