Commit e933cefa authored by John Sheu's avatar John Sheu Committed by Mauro Carvalho Chehab

[media] s5p-mfc: fix encoder crash after VIDIOC_STREAMOFF

VIDIOC_STREAMOFF clears the encoder's destination queue -- routines run
from the interrupt handler cannot assume that the queue is non-empty.
Signed-off-by: default avatarJohn Sheu <sheu@google.com>
Signed-off-by: default avatarKamil Debski <k.debski@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 535ec214
...@@ -772,13 +772,16 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx) ...@@ -772,13 +772,16 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
if (p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) { if (p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) {
spin_lock_irqsave(&dev->irqlock, flags); spin_lock_irqsave(&dev->irqlock, flags);
dst_mb = list_entry(ctx->dst_queue.next, if (!list_empty(&ctx->dst_queue)) {
struct s5p_mfc_buf, list); dst_mb = list_entry(ctx->dst_queue.next,
list_del(&dst_mb->list); struct s5p_mfc_buf, list);
ctx->dst_queue_cnt--; list_del(&dst_mb->list);
vb2_set_plane_payload(dst_mb->b, 0, ctx->dst_queue_cnt--;
s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev)); vb2_set_plane_payload(dst_mb->b, 0,
vb2_buffer_done(dst_mb->b, VB2_BUF_STATE_DONE); s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size,
dev));
vb2_buffer_done(dst_mb->b, VB2_BUF_STATE_DONE);
}
spin_unlock_irqrestore(&dev->irqlock, flags); spin_unlock_irqrestore(&dev->irqlock, flags);
} }
...@@ -883,8 +886,7 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx) ...@@ -883,8 +886,7 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
mfc_debug(2, "enc src count: %d, enc ref count: %d\n", mfc_debug(2, "enc src count: %d, enc ref count: %d\n",
ctx->src_queue_cnt, ctx->ref_queue_cnt); ctx->src_queue_cnt, ctx->ref_queue_cnt);
} }
if (strm_size > 0) { if ((ctx->dst_queue_cnt > 0) && (strm_size > 0)) {
/* at least one more dest. buffers exist always */
mb_entry = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, mb_entry = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf,
list); list);
list_del(&mb_entry->list); list_del(&mb_entry->list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment