From: John Sheu <sheu@google.com>
To: linux-media@vger.kernel.org
Cc: John Sheu <sheu@google.com>,
m.chehab@samsung.com, k.debski@samsung.com, pawel@osciak.com
Subject: [PATCH 6/6] [media] v4l2-mem2mem: allow reqbufs(0) with "in use" MMAP buffers
Date: Wed, 9 Oct 2013 16:49:49 -0700 [thread overview]
Message-ID: <1381362589-32237-7-git-send-email-sheu@google.com> (raw)
In-Reply-To: <1381362589-32237-1-git-send-email-sheu@google.com>
v4l2-mem2mem presently does not allow VIDIOC_REQBUFS to destroy
outstanding buffers if the queue is of type V4L2_MEMORY_MMAP, and if the
buffers are considered "in use". This is different behavior than for
other memory types, and prevents us for deallocating buffers in a few
cases:
* In the case that there are outstanding mmap()ed views on the buffer,
refcounting on the videobuf2 buffer backing the vm_area will track
lifetime appropriately,
* In the case that the buffer has been exported as a DMABUF, refcounting
on the videobuf2 bufer backing the DMABUF will track lifetime
appropriately.
Remove the specific check for type V4L2_MEMOMRY_MMAP when freeing all
buffers through VIDIOC_REQBUFS.
Signed-off-by: John Sheu <sheu@google.com>
---
drivers/media/v4l2-core/videobuf2-core.c | 26 +-------------------------
1 file changed, 1 insertion(+), 25 deletions(-)
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index fc8af50..3c31efb 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -369,8 +369,7 @@ static int __verify_length(struct vb2_buffer *vb, const struct v4l2_buffer *b)
}
/**
- * __buffer_in_use() - return true if the buffer is in use and
- * the queue cannot be freed (by the means of REQBUFS(0)) call
+ * __buffer_in_use() - return true if the buffer is in use.
*/
static bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb)
{
@@ -390,20 +389,6 @@ static bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb)
}
/**
- * __buffers_in_use() - return true if any buffers on the queue are in use and
- * the queue cannot be freed (by the means of REQBUFS(0)) call
- */
-static bool __buffers_in_use(struct vb2_queue *q)
-{
- unsigned int buffer;
- for (buffer = 0; buffer < q->num_buffers; ++buffer) {
- if (__buffer_in_use(q, q->bufs[buffer]))
- return true;
- }
- return false;
-}
-
-/**
* __fill_v4l2_buffer() - fill in a struct v4l2_buffer with information to be
* returned to userspace
*/
@@ -626,15 +611,6 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
}
if (req->count == 0 || q->num_buffers != 0 || q->memory != req->memory) {
- /*
- * We already have buffers allocated, so first check if they
- * are not in use and can be freed.
- */
- if (q->memory == V4L2_MEMORY_MMAP && __buffers_in_use(q)) {
- dprintk(1, "reqbufs: memory in use, cannot free\n");
- return -EBUSY;
- }
-
__vb2_queue_free(q, q->num_buffers);
/*
--
1.8.4
prev parent reply other threads:[~2013-10-09 23:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-09 23:49 [PATCH 0/6] Exynos video fixes from ChromeOS John Sheu
2013-10-09 23:49 ` [PATCH 1/6] [media] s5p-mfc: fix DISPLAY_DELAY John Sheu
2013-10-09 23:49 ` [PATCH 2/6] [media] s5p-mfc: fix encoder crash after VIDIOC_STREAMOFF John Sheu
2013-10-09 23:49 ` [PATCH 3/6] [media] s5p-mfc: add support for VIDIOC_{G,S}_CROP to encoder John Sheu
2013-10-10 6:49 ` Hans Verkuil
[not found] ` <CAErgknA-3bk1BoYa6KJAfO+863DBTi_5U8i_hh7F8O+mXfyNWg@mail.gmail.com>
2013-10-11 23:48 ` Fwd: " John Sheu
2013-10-12 8:00 ` Hans Verkuil
2013-10-12 9:08 ` John Sheu
2013-10-17 15:27 ` Tomasz Stanislawski
2013-10-17 21:46 ` John Sheu
2013-10-17 22:25 ` John Sheu
2013-10-17 22:54 ` Sylwester Nawrocki
2013-10-18 0:03 ` John Sheu
2013-11-04 10:57 ` Hans Verkuil
2013-11-04 11:29 ` Sylwester Nawrocki
2013-11-04 12:07 ` Hans Verkuil
2013-11-04 23:21 ` Sylwester Nawrocki
2013-10-09 23:49 ` [PATCH 4/6] [media] s5p-mfc: support dynamic encoding parameter changes John Sheu
2013-10-09 23:49 ` [PATCH 5/6] [media] gsc-m2m: report correct format bytesperline and sizeimage John Sheu
2013-10-09 23:49 ` John Sheu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1381362589-32237-7-git-send-email-sheu@google.com \
--to=sheu@google.com \
--cc=k.debski@samsung.com \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
--cc=pawel@osciak.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).