v4l: vb2: Fix stream start and buffer completion race
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Mon, 23 Jun 2014 21:00:22 +0000 (23:00 +0200)
committerStephane Desneux <stephane.desneux@open.eurogiciel.org>
Wed, 4 Feb 2015 10:15:25 +0000 (11:15 +0100)
commitca3f7224a718fc2ff54958e769270d947c255b13
treeb78004f410a19ea75bd3f9fc636e03edfe9544b2
parent4cffc36013a2d9508c947813a352aaf0b6cfa4c3
v4l: vb2: Fix stream start and buffer completion race

videobuf2 stores the driver streaming state internally in the queue in
the start_streaming_called variable. The state is set right after the
driver start_stream operation returns, and checked in the
vb2_buffer_done() function, typically called from the frame completion
interrupt handler. A race condition exists if the hardware finishes
processing the first frame before the start_stream operation returns.

Fix this by setting start_streaming_called to 1 before calling the
start_stream operation, and resetting it to 0 if the operation fails.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
(cherry picked from commit 752bfe5395aa0609def7292c97a37c314ace5837)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Conflicts:
drivers/media/v4l2-core/videobuf2-core.c
drivers/media/v4l2-core/videobuf2-core.c