]> git.baikalelectronics.ru Git - kernel.git/commit
[media] vb2: fix buf_init/buf_cleanup call sequences
authorHans Verkuil <hans.verkuil@cisco.com>
Wed, 29 Jan 2014 16:36:53 +0000 (13:36 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 11 Mar 2014 09:56:40 +0000 (06:56 -0300)
commit8ebdd3aeb526e34169e7a1159df167818df5264f
tree41fd2769da937f83ceb4df8a736236b4ac519e42
parenta810c395159c0197686609071abbfc2bb2bb0089
[media] vb2: fix buf_init/buf_cleanup call sequences

Ensure that these ops are properly balanced.

There are two scenarios:

1) for MMAP buf_init is called when the buffers are created and buf_cleanup
   must be called when the queue is finally freed. This scenario was always
   working.

2) for USERPTR and DMABUF it is more complicated. When a buffer is queued
   the code checks if all planes of this buffer have been acquired before.
   If that's the case, then only buf_prepare has to be called. Otherwise
   buf_cleanup needs to be called if the buffer was acquired before, then,
   once all changed planes have been (re)acquired, buf_init has to be
   called followed by buf_prepare. Should buf_prepare fail, then buf_cleanup
   must be called on the newly acquired planes to release them in.

Finally, in __vb2_queue_free we have to check if the buffer was actually
acquired before calling buf_cleanup. While that it always true for MMAP
mode, it is not necessarily true for the other modes. E.g. if you just
call REQBUFS and close the file handle, then buffers were never queued and
so no buf_init was ever called.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/v4l2-core/videobuf2-core.c