mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	mchehab@kernel.org, tfiga@chromium.org, m.szyprowski@samsung.com,
	ming.qian@nxp.com, ezequiel@vanguardiasur.com.ar,
	p.zabel@pengutronix.de, gregkh@linuxfoundation.org,
	nicolas.dufresne@collabora.com
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	linux-arm-msm@vger.kernel.org,
	linux-rockchip@lists.infradead.org,
	linux-staging@lists.linux.dev, kernel@collabora.com
Subject: Re: [PATCH v5 09/10] media: v4l2: Add DELETE_BUFS ioctl
Date: Wed, 30 Aug 2023 15:51:45 +0200	[thread overview]
Message-ID: <970e55be-d5ed-e4d5-b12a-451113b9be90@xs4all.nl> (raw)
In-Reply-To: <20230824092133.39510-10-benjamin.gaignard@collabora.com>

On 24/08/2023 11:21, Benjamin Gaignard wrote:
> VIDIOC_DELETE_BUFS ioctl allows to delete buffers from a queue.
> The number of buffers to delete in given by count field of
> struct v4l2_delete_buffers and the range start at the index
> specified in the same structure.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> ---
>  .../userspace-api/media/v4l/user-func.rst     |  1 +
>  .../media/v4l/vidioc-delete-bufs.rst          | 73 +++++++++++++++++++
>  .../media/common/videobuf2/videobuf2-core.c   | 34 +++++++++
>  .../media/common/videobuf2/videobuf2-v4l2.c   | 16 ++++
>  drivers/media/v4l2-core/v4l2-dev.c            |  1 +
>  drivers/media/v4l2-core/v4l2-ioctl.c          | 17 +++++
>  include/media/v4l2-ioctl.h                    |  4 +
>  include/media/videobuf2-core.h                |  9 +++
>  include/media/videobuf2-v4l2.h                | 11 +++
>  include/uapi/linux/videodev2.h                | 17 +++++
>  10 files changed, 183 insertions(+)
>  create mode 100644 Documentation/userspace-api/media/v4l/vidioc-delete-bufs.rst
> 
> diff --git a/Documentation/userspace-api/media/v4l/user-func.rst b/Documentation/userspace-api/media/v4l/user-func.rst
> index 15ff0bf7bbe6..3fd567695477 100644
> --- a/Documentation/userspace-api/media/v4l/user-func.rst
> +++ b/Documentation/userspace-api/media/v4l/user-func.rst
> @@ -17,6 +17,7 @@ Function Reference
>      vidioc-dbg-g-chip-info
>      vidioc-dbg-g-register
>      vidioc-decoder-cmd
> +    vidioc-delete-bufs
>      vidioc-dqevent
>      vidioc-dv-timings-cap
>      vidioc-encoder-cmd
> diff --git a/Documentation/userspace-api/media/v4l/vidioc-delete-bufs.rst b/Documentation/userspace-api/media/v4l/vidioc-delete-bufs.rst
> new file mode 100644
> index 000000000000..a55fe6331fc8
> --- /dev/null
> +++ b/Documentation/userspace-api/media/v4l/vidioc-delete-bufs.rst
> @@ -0,0 +1,73 @@
> +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
> +.. c:namespace:: V4L
> +
> +.. _VIDIOC_DELETE_BUFS:
> +
> +************************
> +ioctl VIDIOC_DELETE_BUFS
> +************************
> +
> +Name
> +====
> +
> +VIDIOC_DELETE_BUFS - Deletes buffers from a queue
> +
> +Synopsis
> +========
> +
> +.. c:macro:: VIDIOC_DELETE_BUFs
> +
> +``int ioctl(int fd, VIDIOC_DELETE_BUFs, struct v4l2_delete_buffers *argp)``
> +
> +Arguments
> +=========
> +
> +``fd``
> +    File descriptor returned by :c:func:`open()`.
> +
> +``argp``
> +    Pointer to struct :c:type:`v4l2_delete_buffers`.
> +
> +Description
> +===========
> +
> +Applications can optionally call the :ref:`VIDIOC_DELETE_BUFS` ioctl to
> +delete buffers from a queue.
> +
> +.. c:type:: v4l2_delete_buffers
> +
> +.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
> +
> +.. flat-table:: struct v4l2_delete_buffers
> +    :header-rows:  0
> +    :stub-columns: 0
> +    :widths:       1 1 2
> +
> +    * - __u32
> +      - ``index``
> +      - The starting buffer index to delete.
> +    * - __u32
> +      - ``count``
> +      - The number of buffers to be deleted.
> +    * - __u32
> +      - ``type``
> +      - Type of the stream or buffers, this is the same as the struct
> +	:c:type:`v4l2_format` ``type`` field. See
> +	:c:type:`v4l2_buf_type` for valid values.
> +    * - __u32
> +      - ``reserved``\ [13]
> +      - A place holder for future extensions. Drivers and applications
> +	must set the array to zero.
> +
> +Return Value
> +============
> +
> +On success 0 is returned, on error -1 and the ``errno`` variable is set
> +appropriately. The generic error codes are described at the
> +:ref:`Generic Error Codes <gen-errors>` chapter.
> +
> +EBUSY
> +    File I/O is in progress.
> +
> +EINVAL
> +    The buffer ``index`` doesn't exist in the queue.
> diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
> index 70e36389b704..3d915b4c33b2 100644
> --- a/drivers/media/common/videobuf2/videobuf2-core.c
> +++ b/drivers/media/common/videobuf2/videobuf2-core.c
> @@ -1634,6 +1634,40 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
>  }
>  EXPORT_SYMBOL_GPL(vb2_core_prepare_buf);
>  
> +int vb2_core_delete_buf(struct vb2_queue *q, unsigned int index)

I didn't realize this the first time I reviewed this, but I would
suggest that you change this to

vb2_core_delete_bufs(struct vb2_queue *q, unsigned int index, unsigned int count)

This is consistent with vb2_core_create_bufs, and I strongly suspect it will
help with locking (mmap_lock), since you don't need to lock for every buffer you
delete, you can do it up front.

And you can move the index/count validation to the core as well, that will help
if e.g. dvb would want to use this ioctl in the future.

Regards,

	Hans

  parent reply	other threads:[~2023-08-30 18:53 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24  9:21 [PATCH v5 00/10] Add DELETE_BUF ioctl Benjamin Gaignard
2023-08-24  9:21 ` [PATCH v5 01/10] media: videobuf2: Rework offset 'cookie' encoding pattern Benjamin Gaignard
2023-08-30 12:25   ` Hans Verkuil
2023-08-30 12:51     ` Benjamin Gaignard
2023-08-24  9:21 ` [PATCH v5 02/10] media: videobuf2: Access vb2_queue bufs array through helper functions Benjamin Gaignard
2023-08-30 13:23   ` Hans Verkuil
2023-08-30 16:24     ` Benjamin Gaignard
2023-08-30 16:36       ` Hans Verkuil
2023-08-31  7:54         ` Benjamin Gaignard
2023-08-31 10:22           ` Hans Verkuil
2023-08-31 12:06             ` Benjamin Gaignard
2023-09-01 12:29     ` Benjamin Gaignard
2023-08-24  9:21 ` [PATCH v5 03/10] media: videobuf2: Be more flexible on the number of queue stored buffers Benjamin Gaignard
2023-08-30 13:27   ` Hans Verkuil
2023-08-24  9:21 ` [PATCH v5 04/10] media: verisilicon: Refactor postprocessor to store more buffers Benjamin Gaignard
2023-08-24  9:21 ` [PATCH v5 05/10] media: verisilicon: Store chroma and motion vectors offset Benjamin Gaignard
2023-08-24  9:21 ` [PATCH v5 06/10] media: verisilicon: vp9: Use destination buffer height to compute chroma offset Benjamin Gaignard
2023-08-24  9:21 ` [PATCH v5 07/10] media: verisilicon: postproc: Fix down scale test Benjamin Gaignard
2023-08-24  9:21 ` [PATCH v5 08/10] media: verisilicon: vp9: Allow to change resolution while streaming Benjamin Gaignard
2023-08-24  9:21 ` [PATCH v5 09/10] media: v4l2: Add DELETE_BUFS ioctl Benjamin Gaignard
2023-08-30 13:45   ` Hans Verkuil
2023-08-30 13:51   ` Hans Verkuil [this message]
2023-08-24  9:21 ` [PATCH v5 10/10] media: v4l2: Add mem2mem helpers for " Benjamin Gaignard
2023-08-25 10:29   ` kernel test robot
2023-08-25 15:34     ` Benjamin Gaignard
2023-08-25 12:26   ` kernel test robot
2023-08-30 13:53   ` Hans Verkuil

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=970e55be-d5ed-e4d5-b12a-451113b9be90@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=benjamin.gaignard@collabora.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@kernel.org \
    --cc=ming.qian@nxp.com \
    --cc=nicolas.dufresne@collabora.com \
    --cc=p.zabel@pengutronix.de \
    --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

all inboxes | Powered by JetHome®