All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: linux-media@vger.kernel.org
Cc: pawel@osciak.com, s.nawrocki@samsung.com,
	m.szyprowski@samsung.com, Hans Verkuil <hans.verkuil@cisco.com>
Subject: [RFCv3 PATCH 09/10] vivi: correctly cleanup after a start_streaming failure.
Date: Thu, 13 Feb 2014 10:40:49 +0100	[thread overview]
Message-ID: <1392284450-41019-10-git-send-email-hverkuil@xs4all.nl> (raw)
In-Reply-To: <1392284450-41019-1-git-send-email-hverkuil@xs4all.nl>

From: Hans Verkuil <hans.verkuil@cisco.com>

If start_streaming fails then any queued buffers must be given back
to the vb2 core.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/vivi.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index 2d4e73b..6085e2f 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -901,8 +901,19 @@ static void buffer_queue(struct vb2_buffer *vb)
 static int start_streaming(struct vb2_queue *vq, unsigned int count)
 {
 	struct vivi_dev *dev = vb2_get_drv_priv(vq);
+	int err;
+
 	dprintk(dev, 1, "%s\n", __func__);
-	return vivi_start_generating(dev);
+	err = vivi_start_generating(dev);
+	if (err) {
+		struct vivi_buffer *buf, *tmp;
+
+		list_for_each_entry_safe(buf, tmp, &dev->vidq.active, list) {
+			list_del(&buf->list);
+			vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED);
+		}
+	}
+	return err;
 }
 
 /* abort streaming and wait for last buffer */
-- 
1.8.4.rc3


  parent reply	other threads:[~2014-02-13  9:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13  9:40 [RFCv3 PATCH 00/10] vb2: fixes, balancing callbacks Hans Verkuil
2014-02-13  9:40 ` [RFCv3 PATCH 01/10] vb2: add debugging code to check for unbalanced ops Hans Verkuil
2014-02-13  9:40 ` [RFCv3 PATCH 02/10] vb2: change result code of buf_finish to void Hans Verkuil
2014-02-14  1:30   ` Pawel Osciak
2014-02-13  9:40 ` [RFCv3 PATCH 03/10] vb2: add note that buf_finish can be called with !vb2_is_streaming() Hans Verkuil
2014-02-14  1:32   ` Pawel Osciak
2014-02-13  9:40 ` [RFCv3 PATCH 04/10] vb2: call buf_finish from __dqbuf Hans Verkuil
2014-02-14  1:35   ` Pawel Osciak
2014-02-13  9:40 ` [RFCv3 PATCH 05/10] vb2: fix buf_init/buf_cleanup call sequences Hans Verkuil
2014-02-14  4:40   ` Pawel Osciak
2014-02-14 10:28     ` Hans Verkuil
2014-02-13  9:40 ` [RFCv3 PATCH 06/10] vb2: fix read/write regression Hans Verkuil
2014-02-14  4:49   ` Pawel Osciak
2014-02-14 10:29     ` Hans Verkuil
2014-02-13  9:40 ` [RFCv3 PATCH 07/10] vb2: rename queued_count to owned_by_drv_count Hans Verkuil
2014-02-14  4:49   ` Pawel Osciak
2014-02-13  9:40 ` [RFCv3 PATCH 08/10] vb2: only call start_streaming if sufficient buffers are queued Hans Verkuil
2014-02-14  5:13   ` Pawel Osciak
2014-02-14 10:31     ` Hans Verkuil
2014-02-13  9:40 ` Hans Verkuil [this message]
2014-02-13  9:40 ` [RFCv3 PATCH 10/10] v4l2-ioctl: add CREATE_BUFS sanity checks Hans Verkuil

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=1392284450-41019-10-git-send-email-hverkuil@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=pawel@osciak.com \
    --cc=s.nawrocki@samsung.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.