From: Brian Starkey <brian.starkey@arm.com>
To: Gustavo Padovan <gustavo@padovan.org>
Cc: linux-media@vger.kernel.org, Hans Verkuil <hverkuil@xs4all.nl>,
Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
Shuah Khan <shuahkh@osg.samsung.com>,
Pawel Osciak <pawel@osciak.com>,
Alexandre Courbot <acourbot@chromium.org>,
Sakari Ailus <sakari.ailus@iki.fi>,
linux-kernel@vger.kernel.org,
Gustavo Padovan <gustavo.padovan@collabora.com>
Subject: Re: [RFC v4 15/17] [media] vb2: add infrastructure to support out-fences
Date: Fri, 27 Oct 2017 10:41:05 +0100 [thread overview]
Message-ID: <20171027094105.GE40170@e107564-lin.cambridge.arm.com> (raw)
In-Reply-To: <20171020215012.20646-16-gustavo@padovan.org>
Hi Gustavo,
Sorry for the sporadic review... I'm struggling to get time to look at
these.
On Fri, Oct 20, 2017 at 07:50:10PM -0200, Gustavo Padovan wrote:
>From: Gustavo Padovan <gustavo.padovan@collabora.com>
>
>Add vb2_setup_out_fence() and the needed members to struct vb2_buffer.
>
>v2: - change it to reflect fd_install at DQEVENT
> - add fence context for out-fences
>
>Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
>---
> drivers/media/v4l2-core/videobuf2-core.c | 31 +++++++++++++++++++++++++++++++
> include/media/videobuf2-core.h | 20 ++++++++++++++++++++
> 2 files changed, 51 insertions(+)
>
>diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
>index 78f369dba3e3..c7ba67bda5ac 100644
>--- a/drivers/media/v4l2-core/videobuf2-core.c
>+++ b/drivers/media/v4l2-core/videobuf2-core.c
>@@ -23,8 +23,11 @@
> #include <linux/sched.h>
> #include <linux/freezer.h>
> #include <linux/kthread.h>
>+#include <linux/sync_file.h>
>+#include <linux/dma-fence.h>
>
> #include <media/videobuf2-core.h>
>+#include <media/videobuf2-fence.h>
> #include <media/v4l2-mc.h>
>
> #include <trace/events/vb2.h>
>@@ -1316,6 +1319,34 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
> }
> EXPORT_SYMBOL_GPL(vb2_core_prepare_buf);
>
>+int vb2_setup_out_fence(struct vb2_queue *q, unsigned int index)
>+{
>+ struct vb2_buffer *vb;
>+ struct dma_fence *fence;
>+
>+ vb = q->bufs[index];
>+
>+ vb->out_fence_fd = get_unused_fd_flags(O_CLOEXEC);
>+
>+ fence = vb2_fence_alloc(q->out_fence_context);
>+ if (!fence) {
>+ put_unused_fd(vb->out_fence_fd);
>+ return -ENOMEM;
>+ }
>+
>+ vb->sync_file = sync_file_create(fence);
>+ if (!vb->sync_file) {
>+ dma_fence_put(fence);
>+ put_unused_fd(vb->out_fence_fd);
>+ return -ENOMEM;
>+ }
sync_file_create() takes an extra reference of its own, so I think you
don't need the dma_fence_get() below, or you should drop a reference
before returning.
-Brian
>+
>+ vb->out_fence = dma_fence_get(fence);
>+
>+ return 0;
>+}
>+EXPORT_SYMBOL_GPL(vb2_setup_out_fence);
>+
> /**
> * vb2_start_streaming() - Attempt to start streaming.
> * @q: videobuf2 queue
>diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
>index 624ca2dce9ea..1925ede73804 100644
>--- a/include/media/videobuf2-core.h
>+++ b/include/media/videobuf2-core.h
>@@ -259,6 +259,10 @@ struct vb2_buffer {
> * using the buffer (queueing to the driver)
> * fence_cb: fence callback information
> * fence_cb_lock: protect callback signal/remove
>+ * out_fence_fd: the out_fence_fd to be shared with userspace.
>+ * out_fence: the out-fence associated with the buffer once
>+ * it is queued to the driver.
>+ * sync_file: the sync file to wrap the out fence
> */
> enum vb2_buffer_state state;
>
>@@ -269,6 +273,10 @@ struct vb2_buffer {
> struct dma_fence_cb fence_cb;
> spinlock_t fence_cb_lock;
>
>+ int out_fence_fd;
>+ struct dma_fence *out_fence;
>+ struct sync_file *sync_file;
>+
> #ifdef CONFIG_VIDEO_ADV_DEBUG
> /*
> * Counters for how often these buffer-related ops are
>@@ -518,6 +526,7 @@ struct vb2_buf_ops {
> * @ordered_in_vb2: set by the driver to tell vb2 te guarantee the order
> * of buffer queue from userspace with QBUF() until they are
> * queued to the driver.
>+ * @out_fence_context: the fence context for the out fences
> * @last_fence: last in-fence received. Used to keep ordering.
> * @fileio: file io emulator internal data, used only if emulator is active
> * @threadio: thread io internal data, used only if thread is active
>@@ -574,6 +583,7 @@ struct vb2_queue {
> unsigned int ordered_in_driver:1;
> unsigned int ordered_in_vb2:1;
>
>+ u64 out_fence_context;
> struct dma_fence *last_fence;
>
> struct vb2_fileio_data *fileio;
>@@ -745,6 +755,16 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
> int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb);
>
> /**
>+ * vb2_setup_out_fence() - setup new out-fence
>+ * @q: The vb2_queue where to setup it
>+ * @index: index of the buffer
>+ *
>+ * Setup the file descriptor, the fence and the sync_file for the next
>+ * buffer to be queued and add everything to the tail of the q->out_fence_list.
>+ */
>+int vb2_setup_out_fence(struct vb2_queue *q, unsigned int index);
>+
>+/**
> * vb2_core_qbuf() - Queue a buffer from userspace
> *
> * @q: videobuf2 queue
>--
>2.13.6
>
next prev parent reply other threads:[~2017-10-27 9:41 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-20 21:49 [RFC v4 00/17] V4L2 Explicit Synchronization support Gustavo Padovan
2017-10-20 21:49 ` [RFC v4 01/17] [media] v4l: create v4l2_event_subscribe_v4l2() Gustavo Padovan
2017-10-24 12:51 ` Hans Verkuil
2017-10-20 21:49 ` [RFC v4 02/17] [media] v4l: use v4l2_subscribe_event_v4l2() on vtables Gustavo Padovan
2017-10-20 21:49 ` [RFC v4 03/17] [media] v4l: use v4l2_subscribe_event_v4l2() on drivers Gustavo Padovan
2017-10-20 21:49 ` [RFC v4 04/17] WIP: [media] v4l2: add v4l2_event_queue_fh_with_cb() Gustavo Padovan
2017-11-03 7:31 ` Hans Verkuil
2017-10-20 21:50 ` [RFC v4 05/17] [media] v4l: add V4L2_EVENT_OUT_FENCE event Gustavo Padovan
2017-10-24 13:09 ` Hans Verkuil
2017-10-20 21:50 ` [RFC v4 06/17] [media] vb2: add .send_out_fence() to notify userspace of out_fence_fd Gustavo Padovan
2017-10-20 21:50 ` [RFC v4 07/17] [media] vivid: assign the specific device to the vb2_queue->dev Gustavo Padovan
2017-10-20 21:50 ` [RFC v4 08/17] [media] vb2: add 'ordered_in_driver' property to queues Gustavo Padovan
2017-10-24 13:11 ` Hans Verkuil
2017-10-20 21:50 ` [RFC v4 09/17] [media] vb2: add 'ordered_in_vb2' " Gustavo Padovan
2017-11-03 7:23 ` Hans Verkuil
2017-10-20 21:50 ` [RFC v4 10/17] [media] vivid: mark vivid queues as ordered_in_driver Gustavo Padovan
2017-10-20 21:50 ` [RFC v4 11/17] [media] vb2: check earlier if stream can be started Gustavo Padovan
2017-10-20 21:50 ` [RFC v4 12/17] [media] vb2: add explicit fence user API Gustavo Padovan
2017-11-03 7:47 ` Hans Verkuil
2017-10-20 21:50 ` [RFC v4 13/17] [media] vb2: add in-fence support to QBUF Gustavo Padovan
2017-10-25 14:49 ` Brian Starkey
2017-11-10 12:38 ` Gustavo Padovan
2017-10-20 21:50 ` [RFC v4 14/17] [media] vb2: add videobuf2 dma-buf fence helpers Gustavo Padovan
2017-10-20 21:50 ` [RFC v4 15/17] [media] vb2: add infrastructure to support out-fences Gustavo Padovan
2017-10-27 9:41 ` Brian Starkey [this message]
2017-10-20 21:50 ` [RFC v4 16/17] [media] vb2: add out-fence support to QBUF Gustavo Padovan
2017-10-27 10:01 ` Brian Starkey
2017-11-03 0:03 ` Gustavo Padovan
2017-10-20 21:50 ` [RFC v4 17/17] [media] v4l: Document explicit synchronization behaviour Gustavo Padovan
2017-10-27 10:08 ` Brian Starkey
2017-11-03 7:53 ` Hans Verkuil
2017-11-03 13:32 ` Gustavo Padovan
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=20171027094105.GE40170@e107564-lin.cambridge.arm.com \
--to=brian.starkey@arm.com \
--cc=acourbot@chromium.org \
--cc=gustavo.padovan@collabora.com \
--cc=gustavo@padovan.org \
--cc=hverkuil@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@osg.samsung.com \
--cc=pawel@osciak.com \
--cc=sakari.ailus@iki.fi \
--cc=shuahkh@osg.samsung.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
all inboxes | Powered by JetHome®