BACKPORT: UPSTREAM: media: videobuf2-v4l2: set last_buffer_dequeued in dqbuf

last_buffer_dequeued was set to true in __fill_v4l2_buffer, but this
is called for qbuf as well. Move it to vb2_dqbuf.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

BUG=b:139002356
TEST=tast run guado video.DecodeAccelVP8

In the video.DecodeAccelVP8 test we were hitting a case where we were
setting 'struct vb2_queue.last_buffer_dequeued' during buffer submission
via

vb2_core_qbuf()
  __fill_v4l2_buffer()

Then when we later tried to dequeue the buffer in

vb2_core_dqbuf()
  __vb2_get_done_vb()
    __vb2_wait_for_done_vb()

We would reject the command with -EPIPE because the queue had been
closed.  This resulted in a livelock where userspace kept polling,
getting (POLLIN|POLLRDNORM) because the queue isn't empty, then getting
-EPIPE in response to its commands.

(cherry picked from commit 26989c2725a571ef74cb5ac8f9badb8de113147e)
Change-Id: I0754f89867c3772bc33268b88cd2302942642f52
Signed-off-by: Ross Zwisler <zwisler@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1842301
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
1 file changed