From: Hans Verkuil <hverkuil@xs4all.nl>
To: Sergey Senozhatsky <senozhatsky@chromium.org>,
Hans Verkuil <hans.verkuil@cisco.com>,
Tomasz Figa <tfiga@chromium.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Kyungmin Park <kyungmin.park@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Sakari Ailus <sakari.ailus@iki.fi>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Pawel Osciak <posciak@chromium.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 04/15] videobuf2: add queue memory consistency parameter
Date: Fri, 10 Jan 2020 10:47:04 +0100 [thread overview]
Message-ID: <77ddd5cd-affc-ad0f-829d-d624f9798055@xs4all.nl> (raw)
In-Reply-To: <20191217032034.54897-5-senozhatsky@chromium.org>
On 12/17/19 4:20 AM, Sergey Senozhatsky wrote:
> Preparations for future V4L2_FLAG_MEMORY_NON_CONSISTENT support.
>
> Extend vb2_core_reqbufs() with queue memory consistency flag.
> API permits queue's consistency attribute adjustment only if
> the queue has no allocated buffers, not busy, and does not have
> buffers waiting to be de-queued.
Actually, you can call vb2_core_reqbufs() when buffers are allocated:
it will free the old buffers, then allocate the new ones. So drop the
'has no allocated buffers' bit.
>
> If user-space attempts to allocate a buffer with consistency
> requirements which don't match queue's consistency model such
> allocation requests will be failed.
Is this last paragraph right? I don't see any code for that.
BTW, a general comment about patches 4-6: I prefer if you changes
this to two patches: one that adds videobuf2-core.c support for
this for reqbufs and create_bufs, then another that wires up the
new V4L2 flag in videobuf2-v4l2.c.
It's easier to review that way.
Regards,
Hans
>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> ---
> drivers/media/common/videobuf2/videobuf2-core.c | 17 +++++++++++++----
> drivers/media/common/videobuf2/videobuf2-v4l2.c | 4 ++--
> drivers/media/dvb-core/dvb_vb2.c | 2 +-
> include/media/videobuf2-core.h | 3 ++-
> 4 files changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
> index 4489744fbbd9..668c56df13f6 100644
> --- a/drivers/media/common/videobuf2/videobuf2-core.c
> +++ b/drivers/media/common/videobuf2/videobuf2-core.c
> @@ -664,8 +664,16 @@ int vb2_verify_memory_type(struct vb2_queue *q,
> }
> EXPORT_SYMBOL(vb2_verify_memory_type);
>
> +static void __set_queue_consistency(struct vb2_queue *q, bool consistent_mem)
> +{
> + if (consistent_mem)
> + q->dma_attrs &= ~DMA_ATTR_NON_CONSISTENT;
> + else
> + q->dma_attrs |= DMA_ATTR_NON_CONSISTENT;
> +}
> +
> int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
> - unsigned int *count)
> + bool consistent_mem, unsigned int *count)
> {
> unsigned int num_buffers, allocated_buffers, num_planes = 0;
> unsigned plane_sizes[VB2_MAX_PLANES] = { };
> @@ -720,6 +728,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
> num_buffers = min_t(unsigned int, num_buffers, VB2_MAX_FRAME);
> memset(q->alloc_devs, 0, sizeof(q->alloc_devs));
> q->memory = memory;
> + __set_queue_consistency(q, consistent_mem);
>
> /*
> * Ask the driver how many buffers and planes per buffer it requires.
> @@ -2498,7 +2507,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
> fileio->memory = VB2_MEMORY_MMAP;
> fileio->type = q->type;
> q->fileio = fileio;
> - ret = vb2_core_reqbufs(q, fileio->memory, &fileio->count);
> + ret = vb2_core_reqbufs(q, fileio->memory, true, &fileio->count);
> if (ret)
> goto err_kfree;
>
> @@ -2555,7 +2564,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
>
> err_reqbufs:
> fileio->count = 0;
> - vb2_core_reqbufs(q, fileio->memory, &fileio->count);
> + vb2_core_reqbufs(q, fileio->memory, true, &fileio->count);
>
> err_kfree:
> q->fileio = NULL;
> @@ -2575,7 +2584,7 @@ static int __vb2_cleanup_fileio(struct vb2_queue *q)
> vb2_core_streamoff(q, q->type);
> q->fileio = NULL;
> fileio->count = 0;
> - vb2_core_reqbufs(q, fileio->memory, &fileio->count);
> + vb2_core_reqbufs(q, fileio->memory, true, &fileio->count);
> kfree(fileio);
> dprintk(3, "file io emulator closed\n");
> }
> diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> index 2fccfe2a57f8..f1e88c9398c7 100644
> --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
> +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> @@ -695,7 +695,7 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
> int ret = vb2_verify_memory_type(q, req->memory, req->type);
>
> fill_buf_caps(q, &req->capabilities);
> - return ret ? ret : vb2_core_reqbufs(q, req->memory, &req->count);
> + return ret ? ret : vb2_core_reqbufs(q, req->memory, true, &req->count);
> }
> EXPORT_SYMBOL_GPL(vb2_reqbufs);
>
> @@ -945,7 +945,7 @@ int vb2_ioctl_reqbufs(struct file *file, void *priv,
> return res;
> if (vb2_queue_is_busy(vdev, file))
> return -EBUSY;
> - res = vb2_core_reqbufs(vdev->queue, p->memory, &p->count);
> + res = vb2_core_reqbufs(vdev->queue, p->memory, true, &p->count);
> /* If count == 0, then the owner has released all buffers and he
> is no longer owner of the queue. Otherwise we have a new owner. */
> if (res == 0)
> diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c
> index 6974f1731529..e60063652164 100644
> --- a/drivers/media/dvb-core/dvb_vb2.c
> +++ b/drivers/media/dvb-core/dvb_vb2.c
> @@ -342,7 +342,7 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req)
>
> ctx->buf_siz = req->size;
> ctx->buf_cnt = req->count;
> - ret = vb2_core_reqbufs(&ctx->vb_q, VB2_MEMORY_MMAP, &req->count);
> + ret = vb2_core_reqbufs(&ctx->vb_q, VB2_MEMORY_MMAP, true, &req->count);
> if (ret) {
> ctx->state = DVB_VB2_STATE_NONE;
> dprintk(1, "[%s] count=%d size=%d errno=%d\n", ctx->name,
> diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
> index 026004180440..810af5cf5742 100644
> --- a/include/media/videobuf2-core.h
> +++ b/include/media/videobuf2-core.h
> @@ -726,6 +726,7 @@ void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb);
> * vb2_core_reqbufs() - Initiate streaming.
> * @q: pointer to &struct vb2_queue with videobuf2 queue.
> * @memory: memory type, as defined by &enum vb2_memory.
> + * @consistent_mem: memory consistency model.
> * @count: requested buffer count.
> *
> * Videobuf2 core helper to implement VIDIOC_REQBUF() operation. It is called
> @@ -750,7 +751,7 @@ void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb);
> * Return: returns zero on success; an error code otherwise.
> */
> int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
> - unsigned int *count);
> + bool consistent_mem, unsigned int *count);
>
> /**
> * vb2_core_create_bufs() - Allocate buffers and any required auxiliary structs
>
next prev parent reply other threads:[~2020-01-10 9:47 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-17 3:20 [RFC][PATCH 00/15] Implement V4L2_BUF_FLAG_NO_CACHE_* flags Sergey Senozhatsky
2019-12-17 3:20 ` [RFC][PATCH 01/15] videobuf2: add cache management members Sergey Senozhatsky
2019-12-17 3:20 ` [RFC][PATCH 02/15] videobuf2: handle V4L2 buffer cache flags Sergey Senozhatsky
2020-01-10 10:24 ` Hans Verkuil
2020-01-22 1:39 ` Sergey Senozhatsky
2020-01-22 2:53 ` Sergey Senozhatsky
2020-01-28 4:35 ` Tomasz Figa
2019-12-17 3:20 ` [RFC][PATCH 03/15] videobuf2: add V4L2_FLAG_MEMORY_NON_CONSISTENT flag Sergey Senozhatsky
2020-01-10 9:36 ` Hans Verkuil
2020-01-10 9:46 ` Sergey Senozhatsky
2019-12-17 3:20 ` [RFC][PATCH 04/15] videobuf2: add queue memory consistency parameter Sergey Senozhatsky
2020-01-10 9:47 ` Hans Verkuil [this message]
2020-01-22 2:05 ` Sergey Senozhatsky
2020-01-23 11:02 ` Hans Verkuil
2020-01-24 2:04 ` Sergey Senozhatsky
2019-12-17 3:20 ` [RFC][PATCH 05/15] videobuf2: handle V4L2_FLAG_MEMORY_NON_CONSISTENT in REQBUFS Sergey Senozhatsky
2020-01-10 9:55 ` Hans Verkuil
2020-01-22 2:18 ` Sergey Senozhatsky
2020-01-22 3:48 ` Sergey Senozhatsky
2020-01-23 11:08 ` Hans Verkuil
2020-01-28 4:45 ` Tomasz Figa
2020-01-28 8:38 ` Hans Verkuil
2019-12-17 3:20 ` [RFC][PATCH 06/15] videobuf2: handle V4L2_FLAG_MEMORY_NON_CONSISTENT in CREATE_BUFS Sergey Senozhatsky
2020-01-10 9:59 ` Hans Verkuil
2020-01-23 3:41 ` Sergey Senozhatsky
2020-01-23 11:41 ` Hans Verkuil
2020-01-24 1:28 ` Sergey Senozhatsky
2019-12-17 3:20 ` [RFC][PATCH 07/15] videobuf2: factor out planes prepare/finish functions Sergey Senozhatsky
2019-12-17 3:20 ` [RFC][PATCH 08/15] videobuf2: do not sync caches when we are allowed not to Sergey Senozhatsky
2019-12-17 3:20 ` [RFC][PATCH 09/15] videobuf2: check ->synced flag in prepare() and finish() Sergey Senozhatsky
2019-12-17 3:20 ` [RFC][PATCH 10/15] videobuf2: let user-space know when driver supports cache hints Sergey Senozhatsky
2019-12-17 3:20 ` [RFC][PATCH 11/15] videobuf2: add begin/end cpu_access callbacks to dma-contig Sergey Senozhatsky
2019-12-17 3:20 ` [RFC][PATCH 12/15] videobuf2: add begin/end cpu_access callbacks to dma-sg Sergey Senozhatsky
2020-01-10 10:13 ` Hans Verkuil
2020-01-22 6:37 ` Sergey Senozhatsky
2020-01-28 4:38 ` Tomasz Figa
2020-01-28 8:36 ` Hans Verkuil
2020-01-30 11:02 ` Tomasz Figa
2020-01-30 12:18 ` Hans Verkuil
2020-02-03 10:04 ` Tomasz Figa
2020-02-04 2:50 ` Sergey Senozhatsky
2020-02-06 8:51 ` Tomasz Figa
2019-12-17 3:20 ` [RFC][PATCH 13/15] videobuf2: do not sync buffers for DMABUF queues Sergey Senozhatsky
2020-01-10 10:30 ` Hans Verkuil
2020-01-22 5:05 ` Sergey Senozhatsky
2020-01-23 11:35 ` Hans Verkuil
2020-01-24 2:25 ` Sergey Senozhatsky
2020-01-24 7:32 ` Sergey Senozhatsky
2020-01-28 7:22 ` Tomasz Figa
2020-01-28 7:34 ` Sergey Senozhatsky
2020-01-28 7:19 ` Tomasz Figa
2020-01-28 8:47 ` Hans Verkuil
2019-12-17 3:20 ` [RFC][PATCH 14/15] videobuf2: don't test db_attach in dma-contig prepare and finish Sergey Senozhatsky
2020-01-10 10:32 ` Hans Verkuil
2019-12-17 3:20 ` [RFC][PATCH 15/15] videobuf2: don't test db_attach in dma-sg " Sergey Senozhatsky
2020-01-08 2:27 ` [RFC][PATCH 00/15] Implement V4L2_BUF_FLAG_NO_CACHE_* flags Sergey Senozhatsky
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=77ddd5cd-affc-ad0f-829d-d624f9798055@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=hans.verkuil@cisco.com \
--cc=kyungmin.park@samsung.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=posciak@chromium.org \
--cc=sakari.ailus@iki.fi \
--cc=senozhatsky@chromium.org \
--cc=tfiga@chromium.org \
/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).