From 8346e1117c1dd9df15fe433c5baa071394c06d81 Mon Sep 17 00:00:00 2001 From: "hyesoo.yu" Date: Fri, 18 Aug 2017 09:59:12 +0900 Subject: [PATCH] [COMMON] g2d: move setting hwfc data HWFC buffer information sholud be set from repeater driver before payload calculation. Change-Id: I1497b1673ead7fc4edcae6df1e0ce5ff095b2bdb Signed-off-by: hyesoo.yu --- drivers/gpu/exynos/g2d/g2d_uapi_process.c | 98 +++++++++++++---------- 1 file changed, 54 insertions(+), 44 deletions(-) diff --git a/drivers/gpu/exynos/g2d/g2d_uapi_process.c b/drivers/gpu/exynos/g2d/g2d_uapi_process.c index 5a4ebc1e94cd..41f874c9b36e 100644 --- a/drivers/gpu/exynos/g2d/g2d_uapi_process.c +++ b/drivers/gpu/exynos/g2d/g2d_uapi_process.c @@ -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); -- 2.20.1