From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org,
Hans Verkuil <hans.verkuil@cisco.com>,
stable@vger.kernel.org, #@tschai.lan, for@tschai.lan,
v3.15@tschai.lan, and@tschai.lan, up@tschai.lan
Subject: Re: [PATCH for v3.17 2/2] vb2: fix vb2 state check when start_streaming fails
Date: Mon, 04 Aug 2014 12:44:52 +0200 [thread overview]
Message-ID: <4228716.VErhQhH3PE@avalon> (raw)
In-Reply-To: <1407148032-41607-3-git-send-email-hverkuil@xs4all.nl>
Hi Hans,
Thank you for the patch.
On Monday 04 August 2014 12:27:12 Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Commit bd994ddb2a12a3ff48cd549ec82cdceaea9614df (vb2: Fix stream start and
> buffer completion race) broke the buffer state check in vb2_buffer_done.
>
> So accept all three possible states there since I can no longer tell the
> difference between vb2_buffer_done called from start_streaming or from
> elsewhere.
>
> Instead add a WARN_ON at the end of start_streaming that will check whether
> any buffers were added to the done list, since that implies that the wrong
> state was used as well.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> Cc: stable@vger.kernel.org # for v3.15 and up
> Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Given that I've introduced a few vb2 bugs I hope my review still has some
value :-)
> ---
> drivers/media/v4l2-core/videobuf2-core.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c
> b/drivers/media/v4l2-core/videobuf2-core.c index d3f2a22..7f70fd52 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -1165,13 +1165,10 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum
> vb2_buffer_state state) if (WARN_ON(vb->state != VB2_BUF_STATE_ACTIVE))
> return;
>
> - if (!q->start_streaming_called) {
> - if (WARN_ON(state != VB2_BUF_STATE_QUEUED))
> - state = VB2_BUF_STATE_QUEUED;
> - } else if (WARN_ON(state != VB2_BUF_STATE_DONE &&
> - state != VB2_BUF_STATE_ERROR)) {
> - state = VB2_BUF_STATE_ERROR;
> - }
> + if (WARN_ON(state != VB2_BUF_STATE_DONE &&
> + state != VB2_BUF_STATE_ERROR &&
> + state != VB2_BUF_STATE_QUEUED))
> + state = VB2_BUF_STATE_ERROR;
>
> #ifdef CONFIG_VIDEO_ADV_DEBUG
> /*
> @@ -1783,6 +1780,12 @@ static int vb2_start_streaming(struct vb2_queue *q)
> /* Must be zero now */
> WARN_ON(atomic_read(&q->owned_by_drv_count));
> }
> + /*
> + * If done_list is not empty, then start_streaming() didn't call
> + * vb2_buffer_done(vb, VB2_BUF_STATE_QUEUED) but STATE_ERROR or
> + * STATE_DONE.
> + */
> + WARN_ON(!list_empty(&q->done_list));
> return ret;
> }
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2014-08-04 10:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-04 10:27 [PATCH for v3.17 0/2] vb2 fixes Hans Verkuil
2014-08-04 10:27 ` [PATCH for v3.17 1/2] videobuf2-core.h: fix comment Hans Verkuil
2014-08-04 10:40 ` Laurent Pinchart
2014-08-04 11:04 ` Hans Verkuil
2014-08-04 10:27 ` [PATCH for v3.17 2/2] vb2: fix vb2 state check when start_streaming fails Hans Verkuil
2014-08-04 10:44 ` Laurent Pinchart [this message]
2014-08-04 11:06 ` 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=4228716.VErhQhH3PE@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=#@tschai.lan \
--cc=and@tschai.lan \
--cc=for@tschai.lan \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=up@tschai.lan \
--cc=v3.15@tschai.lan \
/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