[COMMON] media: mfc: delete the src buffer of strange consumed size
authorAyoung Sim <a.sim@samsung.com>
Wed, 1 Aug 2018 07:42:04 +0000 (16:42 +0900)
committerhskang <hs1218.kang@samsung.com>
Sun, 9 Sep 2018 21:39:09 +0000 (06:39 +0900)
Change-Id: I8595ae5d408ca4ed02eb10ecf77335344dd41ece
Signed-off-by: Ayoung Sim <a.sim@samsung.com>
drivers/media/platform/exynos/mfc/mfc_isr.c
drivers/media/platform/exynos/mfc/mfc_queue.c

index afc3ea4bfae239499a783d90204b6361d44cf3f0..24abce01bb15cce81da0933d3f4c94a1491ff4a9 100644 (file)
@@ -469,6 +469,7 @@ static void __mfc_handle_frame_error(struct mfc_ctx *ctx,
 
                mfc_debug(2, "MFC needs next buffer\n");
                dec->consumed = 0;
+               dec->remained_size = 0;
 
                if (call_cop(ctx, get_buf_ctrls_val, ctx, &ctx->src_ctrls[index]) < 0)
                        mfc_err_ctx("failed in get_buf_ctrls_val\n");
index eff0319284efa3e8c17313812c390d6013d8df9e..93cdf96f6f2d4f510ee31a9055c26985dc0e9149 100644 (file)
@@ -94,6 +94,7 @@ struct mfc_buf *mfc_get_del_if_consumed(struct mfc_ctx *ctx, struct mfc_buf_queu
        struct mfc_buf *mfc_buf = NULL;
        struct mfc_dec *dec = ctx->dec_priv;
        unsigned long remained;
+       bool exceed = false;
 
        spin_lock_irqsave(&ctx->buf_queue_lock, flags);
 
@@ -107,16 +108,22 @@ struct mfc_buf *mfc_get_del_if_consumed(struct mfc_ctx *ctx, struct mfc_buf_queu
 
        mfc_debug(2, "addr[0]: 0x%08llx\n", mfc_buf->addr[0][0]);
 
-       if (dec->remained_size)
+       if (dec->remained_size) {
                remained = dec->remained_size - consumed;
-       else
+               if (consumed > dec->remained_size)
+                       exceed = true;
+       } else {
                remained = mfc_buf->vb.vb2_buf.planes[0].bytesused - consumed;
+               if (consumed > mfc_buf->vb.vb2_buf.planes[0].bytesused)
+                       exceed = true;
+       }
 
        mfc_debug(2, "[MULTIFRAME] Total Size: %d, consumed: %ld, remained: %ld\n",
                mfc_buf->vb.vb2_buf.planes[0].bytesused, consumed, remained);
+       if (exceed == true)
+               mfc_err_ctx("[MULTIFRAME] consumed size exceeded the total remained size\n");
 
-       if ((consumed > 0) && (remained > min_bytes) && (error == 0) &&
-                       (mfc_buf->vb.vb2_buf.planes[0].bytesused > consumed)){
+       if ((consumed > 0) && (remained > min_bytes) && (error == 0) && (exceed == false)) {
                /* do not delete from queue */
                *deleted = 0;
        } else {