• Brandon Philips's avatar
    V4L/DVB (7493): videobuf: Avoid deadlock with QBUF and bring up to spec for empty queue · 137d1cb1
    Brandon Philips authored
    Add a waitqueue to wait on when there are no buffers in the buffer queue.
    DQBUF waits on this queue without holding vb_lock to allow a QBUF to happen.
    Once a buffer has been queued we recheck that the queue is still streaming and
    wait on the new buffer's waitqueue while holding the vb_lock.  The driver
    should come along in a timely manner and put the buffer into its next state
    finishing the DQBUF.
    
    By implementing this waitqueue it also brings the videobuf DQBUF up to spec and
    it now blocks on O_NONBLOCK even when no buffers have been queued via QBUF:
    
    "By default VIDIOC_DQBUF blocks when no buffer is in the outgoing queue."
     - V4L2 spec
    Signed-off-by: default avatarBrandon Philips <bphilips@suse.de>
    CC: Trent Piepho <xyzzy@speakeasy.org>
    CC: Carl Karsten <carl@personnelware.com>
    CC: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
    137d1cb1
videobuf-core.c 24.7 KB