drm/tgm: tdm: change completion interface. 75/136975/3
authorJin-young Jeon <jy0.jeon@samsung.com>
Thu, 29 Jun 2017 10:11:18 +0000 (19:11 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 4 Jul 2017 02:26:06 +0000 (02:26 +0000)
Add cmd completion instead of start / stop completion.
This patch is from product kernel.

Change-Id: I09d0e61d307d619db1ebb61b8e4242edff4a4259
Signed-off-by: Jin-young Jeon <jy0.jeon@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
drivers/gpu/drm/tgm/tdm_pp.c
drivers/gpu/drm/tgm/tdm_pp.h
drivers/gpu/drm/tgm/tdm_pp_msc.c

index 8de9c66..710af83 100644 (file)
@@ -409,8 +409,6 @@ int tdm_pp_set_property(struct drm_device *drm_dev, void *data,
                        DRM_ERROR("failed to create stop work.\n");
                        goto err_free_start;
                }
-
-               init_completion(&c_node->stop_complete);
        }
 
        c_node->event_work = pp_create_event_work();
@@ -422,7 +420,8 @@ int tdm_pp_set_property(struct drm_device *drm_dev, void *data,
        mutex_init(&c_node->lock);
        mutex_init(&c_node->mem_lock);
        mutex_init(&c_node->event_lock);
-       init_completion(&c_node->start_complete);
+       init_completion(&c_node->cmd_complete);
+       complete(&c_node->cmd_complete);
 
        for_each_pp_ops(i)
                INIT_LIST_HEAD(&c_node->mem_list[i]);
@@ -837,8 +836,6 @@ static int pp_queue_buf_with_run(struct device *dev,
                } else {
                        mutex_lock(&ppdrv->drv_lock);
 
-                       reinit_completion(&c_node->start_complete);
-
                        ret = pp_start_property(ppdrv, c_node);
                        if (ret) {
                                DRM_INFO("%s:failed to start property:id[%d]\n"
@@ -899,7 +896,7 @@ int tdm_pp_queue_buf(struct drm_device *drm_dev, void *data,
                return -EINVAL;
        }
 
-       DRM_INFO("%s:prop_id[%d]ops_id[%s]buf_id[%d][%s]\n",
+       DRM_DEBUG("%s:prop_id[%d]ops_id[%s]buf_id[%d][%s]\n",
                __func__, qbuf->prop_id, qbuf->ops_id ? "dst" : "src",
                qbuf->buf_id, qbuf->buf_type ? "dq" : "eq");
 
@@ -1070,8 +1067,6 @@ int tdm_pp_cmd_ctrl(struct drm_device *drm_dev, void *data,
                } else {
                        mutex_lock(&ppdrv->drv_lock);
 
-                       reinit_completion(&c_node->start_complete);
-
                        ret = pp_start_property(ppdrv, c_node);
                        if (ret) {
                                DRM_INFO("%s:failed to start property:id[%d]\n"
@@ -1087,12 +1082,6 @@ int tdm_pp_cmd_ctrl(struct drm_device *drm_dev, void *data,
                        cmd_work = c_node->stop_work;
                        cmd_work->ctrl = cmd_ctrl->ctrl;
                        pp_handle_cmd_work(dev, ppdrv, cmd_work, c_node);
-
-                       if (!wait_for_completion_timeout(&c_node->stop_complete,
-                           msecs_to_jiffies(300))) {
-                               DRM_ERROR("timeout stop:prop_id[%d]\n",
-                                       c_node->property.prop_id);
-                       }
                } else {
                        ret = pp_stop_property(ppdrv->drm_dev, ppdrv,
                                c_node);
@@ -1116,12 +1105,6 @@ int tdm_pp_cmd_ctrl(struct drm_device *drm_dev, void *data,
                        cmd_work = c_node->stop_work;
                        cmd_work->ctrl = cmd_ctrl->ctrl;
                        pp_handle_cmd_work(dev, ppdrv, cmd_work, c_node);
-
-                       if (!wait_for_completion_timeout(&c_node->stop_complete,
-                           msecs_to_jiffies(300))) {
-                               DRM_ERROR("timeout stop:prop_id[%d]\n",
-                                       c_node->property.prop_id);
-                       }
                } else {
                        ret = pp_stop_property(ppdrv->drm_dev, ppdrv,
                                c_node);
@@ -1143,8 +1126,6 @@ int tdm_pp_cmd_ctrl(struct drm_device *drm_dev, void *data,
                } else {
                        mutex_lock(&ppdrv->drv_lock);
 
-                       reinit_completion(&c_node->start_complete);
-
                        ret = pp_start_property(ppdrv, c_node);
                        if (ret) {
                                DRM_INFO("%s:failed to start property:id[%d]\n"
@@ -1242,6 +1223,20 @@ static int pp_set_property(struct tdm_ppdrv *ppdrv,
        return 0;
 }
 
+void pp_wait_completion(struct tdm_pp_cmd_node *c_node)
+{
+       int ret;
+
+       DRM_DEBUG("%s\n", __func__);
+
+       ret = wait_for_completion_timeout(
+               &c_node->cmd_complete, msecs_to_jiffies(120));
+       if (ret < 0)
+               DRM_ERROR("failed to wait completion:ret[%d]\n", ret);
+       else if (!ret)
+               DRM_ERROR("timeout\n");
+}
+
 int pp_start_property(struct tdm_ppdrv *ppdrv,
                struct tdm_pp_cmd_node *c_node)
 {
@@ -1262,6 +1257,8 @@ int pp_start_property(struct tdm_ppdrv *ppdrv,
                goto err_unlock;
        }
 
+       reinit_completion(&c_node->cmd_complete);
+
        /* set current property in ppdrv */
        ret = pp_set_property(ppdrv, property);
        if (ret) {
@@ -1332,6 +1329,8 @@ int pp_start_property(struct tdm_ppdrv *ppdrv,
                }
        }
 
+       pp_wait_completion(c_node);
+
        return 0;
 
 err_unlock:
@@ -1349,6 +1348,8 @@ int pp_stop_property(struct drm_device *drm_dev,
 
        DRM_DEBUG_KMS("prop_id[%d]\n", property->prop_id);
 
+       pp_wait_completion(c_node);
+
        /* stop operations */
        if (ppdrv->stop)
                ppdrv->stop(ppdrv->dev, property->cmd);
@@ -1405,37 +1406,16 @@ void pp_sched_cmd(struct work_struct *work)
        case PP_CTRL_PLAY:
        case PP_CTRL_RESUME:
                ret = pp_start_property(ppdrv, c_node);
-               if (ret) {
+               if (ret)
                        DRM_ERROR("failed to start property:prop_id[%d]\n",
                                c_node->property.prop_id);
-                       goto err_unlock;
-               }
-
-               /*
-                * M2M case supports wait_completion of transfer.
-                * because M2M case supports single unit operation
-                * with multiple queue.
-                * M2M need to wait completion of data transfer.
-                */
-               if (pp_is_m2m_cmd(property->cmd)) {
-                       if (!wait_for_completion_timeout
-                           (&c_node->start_complete, msecs_to_jiffies(200))) {
-                               DRM_ERROR("timeout event:prop_id[%d]\n",
-                                       c_node->property.prop_id);
-                               goto err_unlock;
-                       }
-               }
                break;
        case PP_CTRL_STOP:
        case PP_CTRL_PAUSE:
                ret = pp_stop_property(ppdrv->drm_dev, ppdrv,
                        c_node);
-               if (ret) {
+               if (ret)
                        DRM_ERROR("failed to stop property.\n");
-                       goto err_unlock;
-               }
-
-               complete(&c_node->stop_complete);
                break;
        default:
                DRM_ERROR("unknown control type\n");
@@ -1444,7 +1424,6 @@ void pp_sched_cmd(struct work_struct *work)
 
        DRM_DEBUG_KMS("ctrl[%d] done.\n", cmd_work->ctrl);
 
-err_unlock:
        mutex_unlock(&c_node->lock);
        mutex_unlock(&ppdrv->drv_lock);
 }
@@ -1637,7 +1616,7 @@ void pp_sched_event(struct work_struct *work)
 
 err_completion:
        if (pp_is_m2m_cmd(c_node->property.cmd))
-               complete(&c_node->start_complete);
+               complete_all(&c_node->cmd_complete);
 }
 
 static int pp_subdrv_probe(struct drm_device *drm_dev, struct device *dev)
index c06d3c3..2be88ae 100644 (file)
@@ -53,8 +53,7 @@ struct tdm_pp_cmd_work {
  * @lock: lock for synchronization of access to ioctl.
  * @mem_lock: lock for synchronization of access to memory nodes.
  * @event_lock: lock for synchronization of access to scheduled event.
- * @start_complete: completion of start of command.
- * @stop_complete: completion of stop of command.
+ * @cmd_complete: completion of command.
  * @property: property information.
  * @start_work: start command work structure.
  * @stop_work: stop command work structure.
@@ -69,8 +68,7 @@ struct tdm_pp_cmd_node {
        struct mutex    lock;
        struct mutex    mem_lock;
        struct mutex    event_lock;
-       struct completion       start_complete;
-       struct completion       stop_complete;
+       struct completion       cmd_complete;
        struct tdm_pp_property  property;
        struct tdm_pp_cmd_work *start_work;
        struct tdm_pp_cmd_work *stop_work;
index e1ca999..c5db64d 100644 (file)
@@ -488,7 +488,7 @@ static int sc_sw_reset(struct sc_context *ctx)
 {
        u32 cfg;
 
-       DRM_INFO("%s\n", __func__);
+       DRM_DEBUG("%s\n", __func__);
 
        /* s/w reset */
        cfg = sc_read(SCALER_CFG);
@@ -502,7 +502,7 @@ static void sc_handle_irq(struct sc_context *ctx, bool enable)
 {
        u32 cfg;
 
-       DRM_INFO("%s:enable[%d]\n", __func__, enable);
+       DRM_DEBUG("%s:enable[%d]\n", __func__, enable);
 
        cfg = sc_read(SCALER_INT_EN);
 
@@ -537,7 +537,7 @@ static int sc_src_set_fmt_nplanar(struct sc_context *ctx, u32 fmt)
 {
        struct tdm_ppdrv *ppdrv = &ctx->ppdrv;
 
-       DRM_INFO("%s:fmt[0x%x]\n", __func__, fmt);
+       DRM_DEBUG("%s:fmt[0x%x]\n", __func__, fmt);
 
        switch (fmt) {
        case DRM_FORMAT_RGB565:
@@ -576,7 +576,7 @@ static int sc_src_set_fmt(struct device *dev, u32 fmt)
        struct tdm_ppdrv *ppdrv = &ctx->ppdrv;
        u32 cfg;
 
-       DRM_INFO("%s:fmt[0x%x]\n", __func__, fmt);
+       DRM_DEBUG("%s:fmt[0x%x]\n", __func__, fmt);
 
        cfg = sc_read(SCALER_SRC_CFG);
        cfg &= ~(SCALER_CFG_TILE_EN|SCALER_CFG_FMT_MASK);
@@ -648,7 +648,7 @@ static int sc_src_set_transf(struct device *dev,
        struct tdm_ppdrv *ppdrv = &ctx->ppdrv;
        u32 cfg;
 
-       DRM_INFO("%s:degree[%d]flip[0x%x]\n", __func__,
+       DRM_DEBUG("%s:degree[%d]flip[0x%x]\n", __func__,
                degree, flip);
 
        cfg = sc_read(SCALER_ROT_CFG);
@@ -701,7 +701,7 @@ static int sc_src_set_size(struct device *dev, int swap,
                img_pos.h = pos->w;
        }
 
-       DRM_INFO("%s:x[%d]y[%d]w[%d]h[%d]\n",
+       DRM_DEBUG("%s:x[%d]y[%d]w[%d]h[%d]\n",
                __func__, pos->x, pos->y, pos->w, pos->h);
 
        /* pixel offset */
@@ -714,7 +714,7 @@ static int sc_src_set_size(struct device *dev, int swap,
                SCALER_SRC_H(pos->h));
        sc_write(cfg, SCALER_SRC_WH);
 
-       DRM_INFO("%s:swap[%d]hsize[%d]vsize[%d]\n",
+       DRM_DEBUG("%s:swap[%d]hsize[%d]vsize[%d]\n",
                __func__, swap, sz->hsize, sz->vsize);
 
        /* span size */
@@ -756,7 +756,7 @@ static int sc_src_set_addr(struct device *dev,
                return -EINVAL;
        }
 
-       DRM_INFO("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
+       DRM_DEBUG("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
                property->prop_id, buf_id, buf_type);
 
        /* Set current buf_id */
@@ -801,7 +801,7 @@ static int sc_dst_set_fmt_nplanar(struct sc_context *ctx, u32 fmt)
        struct tdm_ppdrv *ppdrv = &ctx->ppdrv;
        u32 cfg;
 
-       DRM_INFO("%s:fmt[0x%x]\n", __func__, fmt);
+       DRM_DEBUG("%s:fmt[0x%x]\n", __func__, fmt);
 
        switch (fmt) {
        case DRM_FORMAT_RGB565:
@@ -845,7 +845,7 @@ static int sc_dst_set_fmt(struct device *dev, u32 fmt)
        struct tdm_ppdrv *ppdrv = &ctx->ppdrv;
        u32 cfg;
 
-       DRM_INFO("%s:fmt[0x%x]\n", __func__, fmt);
+       DRM_DEBUG("%s:fmt[0x%x]\n", __func__, fmt);
 
        cfg = sc_read(SCALER_DST_CFG);
        cfg &= ~(SCALER_CFG_SWAP_MASK|SCALER_CFG_FMT_MASK);
@@ -918,7 +918,7 @@ static int sc_dst_set_transf(struct device *dev,
        struct tdm_ppdrv *ppdrv = &ctx->ppdrv;
        u32 cfg;
 
-       DRM_INFO("%s:degree[%d]flip[0x%x]\n", __func__,
+       DRM_DEBUG("%s:degree[%d]flip[0x%x]\n", __func__,
                degree, flip);
 
        cfg = sc_read(SCALER_ROT_CFG);
@@ -968,7 +968,7 @@ static int sc_set_csc_coef(struct sc_context *ctx, struct sc_scaler *sc,
        u32 cfg;
        bool itu_709;
 
-       DRM_INFO("%s:sfmt[0x%x]dfmt[0x%x]range[%d]width[%d]\n", __func__,
+       DRM_DEBUG("%s:sfmt[0x%x]dfmt[0x%x]range[%d]width[%d]\n", __func__,
                fmt[TDM_OPS_SRC], fmt[TDM_OPS_DST],
                sc->range, width);
 
@@ -1023,7 +1023,7 @@ static void sc_set_scaler_ratio(struct sc_context *ctx, struct sc_scaler *sc)
 {
        u32 cfg;
 
-       DRM_INFO("%s:hratio[%ld]vratio[%ld]\n",
+       DRM_DEBUG("%s:hratio[%ld]vratio[%ld]\n",
                __func__, sc->hratio, sc->vratio);
 
        cfg = sc_read(SCALER_H_RATIO);
@@ -1042,7 +1042,7 @@ static void sc_set_h_coef(struct sc_context *ctx, int coef)
        u32 phase, tab, cnt = 0;
        u32 cfg, val_h, val_l;
 
-       DRM_INFO("%s:coef[%d]\n", __func__, coef);
+       DRM_DEBUG("%s:coef[%d]\n", __func__, coef);
 
        for (phase = 0; phase < SC_COEF_PHASE; phase++) {
                for (tab = SC_COEF_H_8T; tab > 0; tab -= 2, cnt++) {
@@ -1060,7 +1060,7 @@ static void sc_set_v_coef(struct sc_context *ctx, int coef)
        u32 phase, tab, cnt = 0;
        u32 cfg, val_h, val_l;
 
-       DRM_INFO("%s:coef[%d]\n", __func__, coef);
+       DRM_DEBUG("%s:coef[%d]\n", __func__, coef);
 
        for (phase = 0; phase < SC_COEF_PHASE; phase++) {
                for (tab = SC_COEF_V_4T; tab > 0; tab -= 2, cnt++) {
@@ -1099,7 +1099,7 @@ static int sc_set_scaler_coef(struct sc_context *ctx, struct sc_scaler *sc)
 {
        int hcoef, vcoef;
 
-       DRM_INFO("%s\n", __func__);
+       DRM_DEBUG("%s\n", __func__);
 
        hcoef = sc_get_scale_filter(sc->hratio);
        vcoef = sc_get_scale_filter(sc->vratio);
@@ -1113,7 +1113,7 @@ static int sc_set_scaler_coef(struct sc_context *ctx, struct sc_scaler *sc)
 static int sc_set_scaler(struct sc_context *ctx, struct sc_scaler *sc,
                struct tdm_pos *src, struct tdm_pos *dst)
 {
-       DRM_INFO("%s\n", __func__);
+       DRM_DEBUG("%s\n", __func__);
 
        if (ctx->rotation) {
                sc->hratio = SC_RATIO(src->h, dst->w);
@@ -1123,7 +1123,7 @@ static int sc_set_scaler(struct sc_context *ctx, struct sc_scaler *sc,
                sc->vratio = SC_RATIO(src->h, dst->h);
        }
 
-       DRM_INFO("%s:hratio[%ld]vratio[%ld]\n",
+       DRM_DEBUG("%s:hratio[%ld]vratio[%ld]\n",
                __func__, sc->hratio, sc->vratio);
 
        sc_set_scaler_coef(ctx, &ctx->sc);
@@ -1139,7 +1139,7 @@ static int sc_dst_set_size(struct device *dev, int swap,
        struct tdm_pos img_pos = *pos;
        u32 cfg;
 
-       DRM_INFO("%s:swap[%d]x[%d]y[%d]w[%d]h[%d]\n",
+       DRM_DEBUG("%s:swap[%d]x[%d]y[%d]w[%d]h[%d]\n",
                __func__, swap, pos->x, pos->y, pos->w, pos->h);
 
        if (swap) {
@@ -1156,7 +1156,7 @@ static int sc_dst_set_size(struct device *dev, int swap,
        cfg = (SCALER_DST_W(pos->w) | SCALER_DST_H(pos->h));
        sc_write(cfg, SCALER_DST_WH);
 
-       DRM_INFO("%s:hsize[%d]vsize[%d]\n",
+       DRM_DEBUG("%s:hsize[%d]vsize[%d]\n",
                __func__, sz->hsize, sz->vsize);
 
        /* span size */
@@ -1194,7 +1194,7 @@ static int sc_dst_set_addr(struct device *dev,
 
        property = &c_node->property;
 
-       DRM_INFO("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
+       DRM_DEBUG("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
                property->prop_id, buf_id, buf_type);
 
        /* Set current buf_id */
@@ -1298,7 +1298,7 @@ static irqreturn_t sc_irq_handler(int irq, void *dev_id)
        u32 cfg;
        int *buf_id = ctx->cur_buf_id;
 
-       DRM_INFO("%s\n", __func__);
+       DRM_DEBUG("%s\n", __func__);
 
 #ifdef DEBUG
        sc_print_reg(ctx);
@@ -1313,7 +1313,7 @@ static irqreturn_t sc_irq_handler(int irq, void *dev_id)
                return IRQ_HANDLED;
        }
 
-       DRM_INFO("%s:src buf_id[%d]dst buf_id[%d]\n", __func__,
+       DRM_DEBUG("%s:src buf_id[%d]dst buf_id[%d]\n", __func__,
                buf_id[TDM_OPS_SRC], buf_id[TDM_OPS_DST]);
 
        event_work->ppdrv = ppdrv;
@@ -1389,7 +1389,7 @@ static int sc_ppdrv_reset(struct device *dev)
        struct sc_scaler *sc = &ctx->sc;
        int ret;
 
-       DRM_INFO("%s\n", __func__);
+       DRM_DEBUG("%s\n", __func__);
 
        /* reset h/w block */
        ret = sc_sw_reset(ctx);
@@ -1407,7 +1407,7 @@ static int sc_ppdrv_reset(struct device *dev)
 
 static int sc_check_prepare(struct sc_context *ctx)
 {
-       DRM_INFO("%s\n", __func__);
+       DRM_DEBUG("%s\n", __func__);
 
        return 0;
 }
@@ -1424,7 +1424,7 @@ static int sc_ppdrv_start(struct device *dev, enum tdm_pp_cmd cmd)
        u32 cfg;
        int ret, i;
 
-       DRM_INFO("%s:cmd[%d]\n", __func__, cmd);
+       DRM_DEBUG("%s:cmd[%d]\n", __func__, cmd);
 
        if (!c_node) {
                DRM_ERROR("failed to get c_node.\n");
@@ -1481,7 +1481,7 @@ static void sc_ppdrv_stop(struct device *dev, enum tdm_pp_cmd cmd)
        struct sc_context *ctx = get_sc_context(dev);
        u32 cfg;
 
-       DRM_INFO("%s:cmd[%d]\n", __func__, cmd);
+       DRM_DEBUG("%s:cmd[%d]\n", __func__, cmd);
 
        switch (cmd) {
        case PP_CMD_M2M: