linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Sheu <sheu@google.com>
To: linux-media@vger.kernel.org
Cc: m.chehab@samsung.com, k.debski@samsung.com, posciak@google.com,
	arun.m@samsung.com, kgene.kim@samsung.com,
	John Sheu <sheu@google.com>
Subject: [PATCH 1/4] s5p-mfc: fix encoder crash after VIDIOC_STREAMOFF
Date: Tue, 11 Mar 2014 15:52:02 -0700	[thread overview]
Message-ID: <1394578325-11298-2-git-send-email-sheu@google.com> (raw)
In-Reply-To: <1394578325-11298-1-git-send-email-sheu@google.com>

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: John Sheu <sheu@google.com>
---
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index df83cd15..04236229 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -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) {
 		spin_lock_irqsave(&dev->irqlock, flags);
-		dst_mb = list_entry(ctx->dst_queue.next,
-				struct s5p_mfc_buf, list);
-		list_del(&dst_mb->list);
-		ctx->dst_queue_cnt--;
-		vb2_set_plane_payload(dst_mb->b, 0,
-			s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev));
-		vb2_buffer_done(dst_mb->b, VB2_BUF_STATE_DONE);
+		if (!list_empty(&ctx->dst_queue)) {
+			dst_mb = list_entry(ctx->dst_queue.next,
+					struct s5p_mfc_buf, list);
+			list_del(&dst_mb->list);
+			ctx->dst_queue_cnt--;
+			vb2_set_plane_payload(dst_mb->b, 0,
+				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);
 	}
 
@@ -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",
 			  ctx->src_queue_cnt, ctx->ref_queue_cnt);
 	}
-	if (strm_size > 0) {
-		/* at least one more dest. buffers exist always  */
+	if ((ctx->dst_queue_cnt > 0) && (strm_size > 0)) {
 		mb_entry = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf,
 									list);
 		list_del(&mb_entry->list);
-- 
1.9.0.279.gdc9e3eb


  reply	other threads:[~2014-03-11 22:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-11 22:52 Upstream patches for Samsung Exynos s5p-mfc and gsc-m2m John Sheu
2014-03-11 22:52 ` John Sheu [this message]
2014-03-11 22:52 ` [PATCH 2/4] CHROMIUM: s5p-mfc: support dynamic encoding parameter changes John Sheu
2014-03-11 22:52 ` [PATCH 3/4] gsc-m2m: report correct format bytesperline and sizeimage John Sheu
2014-04-07 15:29   ` Kamil Debski
2014-04-08  6:56   ` Shaik Ameer Basha
2014-04-08  7:11     ` Shaik Ameer Basha
2014-03-11 22:52 ` [PATCH 4/4] v4l2-mem2mem: allow reqbufs(0) with "in use" MMAP buffers John Sheu
2014-04-07 14:41   ` Kamil Debski
2014-04-08 10:51     ` Marek Szyprowski
2015-11-02 18:31       ` Nicolas Dufresne
2015-11-11 21:29         ` Jean-Michel Hautbois

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394578325-11298-2-git-send-email-sheu@google.com \
    --to=sheu@google.com \
    --cc=arun.m@samsung.com \
    --cc=k.debski@samsung.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=posciak@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).