[media] sur40: fix occasional hard freeze due to buffer queue underrun

This patch fixes a kernel panic which occurs when buf_list is empty. This can
happen occasionally when user space is under heavy load (e.g. due to image
processing on the CPU) and new buffers aren't re-queued fast enough. In that
case, vb2_start_streaming_called can return true, but when the spinlock
is taken and sur40_poll attempts to fetch the next buffer from buf_list, the
list is in fact empty.

This patch needs to be applied on top of the queued one adding V4L2 support
to the sur40 driver.

Signed-off-by: Florian Echtler <floe@butterbrot.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
Florian Echtler 2015-03-31 06:43:28 -03:00 committed by Mauro Carvalho Chehab
parent af7f388e74
commit c2529908a1
1 changed files with 5 additions and 0 deletions

View File

@ -380,6 +380,11 @@ static void sur40_process_video(struct sur40_state *sur40)
/* get a new buffer from the list */
spin_lock(&sur40->qlock);
if (list_empty(&sur40->buf_list)) {
dev_dbg(sur40->dev, "buffer queue empty\n");
spin_unlock(&sur40->qlock);
return;
}
new_buf = list_entry(sur40->buf_list.next, struct sur40_buffer, list);
list_del(&new_buf->list);
spin_unlock(&sur40->qlock);