From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCHv17 29/34] v4l2-mem2mem: add vb2_m2m_request_queue
Date: Mon, 13 Aug 2018 12:02:32 -0300 [thread overview]
Message-ID: <20180813120149.1040f6f7@coco.lan> (raw)
In-Reply-To: <20180804124526.46206-30-hverkuil@xs4all.nl>
Em Sat, 4 Aug 2018 14:45:21 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> For mem2mem devices we have to make sure that v4l2_m2m_try_schedule()
> is called whenever a request is queued.
>
> We do that by creating a vb2_m2m_request_queue() helper that should
> be used instead of the 'normal' vb2_request_queue() helper. The m2m
> helper function will call v4l2_m2m_try_schedule() as needed.
>
> In addition we also avoid calling v4l2_m2m_try_schedule() when preparing
> or queueing a buffer for a request since that is no longer needed.
> Instead this helper function will do that when the request is actually
> queued.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
But please notice below that there's another change on patch 1/34 due
to this patchset.
> ---
> drivers/media/v4l2-core/v4l2-mem2mem.c | 59 ++++++++++++++++++++++----
> include/media/v4l2-mem2mem.h | 4 ++
> 2 files changed, 55 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
> index b09494174eb4..56a16cfef6f8 100644
> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c
> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
> @@ -369,7 +369,7 @@ static void v4l2_m2m_cancel_job(struct v4l2_m2m_ctx *m2m_ctx)
> spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags);
> if (m2m_dev->m2m_ops->job_abort)
> m2m_dev->m2m_ops->job_abort(m2m_ctx->priv);
> - dprintk("m2m_ctx %p running, will wait to complete", m2m_ctx);
> + dprintk("m2m_ctx %p running, will wait to complete\n", m2m_ctx);
> wait_event(m2m_ctx->finished,
> !(m2m_ctx->job_flags & TRANS_RUNNING));
> } else if (m2m_ctx->job_flags & TRANS_QUEUED) {
> @@ -460,8 +460,14 @@ int v4l2_m2m_qbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
> int ret;
>
> vq = v4l2_m2m_get_vq(m2m_ctx, buf->type);
> + if (!V4L2_TYPE_IS_OUTPUT(vq->type) &&
> + (buf->flags & V4L2_BUF_FLAG_REQUEST_FD)) {
> + dprintk("%s: requests cannot be used with capture buffers\n",
> + __func__);
I had to double-check the documentation at patch 01/34. While on one
part is says the same, saying that -EPERM is the error code, on
another part, it says:
+Note that there is typically no need to use the Request API for CAPTURE buffers
+since there are no per-frame settings to report there.
"typically" means that the normal usecase is to now allow, but gives
it open to implementations doing it.
Please fix that paragraph on patch 01/34 to reflect that no CAPTURE
buffers should be used with request API for m2m, in order to
reflect the code's implementation.
> + return -EPERM;
> + }
> ret = vb2_qbuf(vq, vdev->v4l2_dev->mdev, buf);
> - if (!ret)
> + if (!ret && !(buf->flags & V4L2_BUF_FLAG_IN_REQUEST))
> v4l2_m2m_try_schedule(m2m_ctx);
>
> return ret;
> @@ -483,14 +489,9 @@ int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
> {
> struct video_device *vdev = video_devdata(file);
> struct vb2_queue *vq;
> - int ret;
>
> vq = v4l2_m2m_get_vq(m2m_ctx, buf->type);
> - ret = vb2_prepare_buf(vq, vdev->v4l2_dev->mdev, buf);
> - if (!ret)
> - v4l2_m2m_try_schedule(m2m_ctx);
> -
> - return ret;
> + return vb2_prepare_buf(vq, vdev->v4l2_dev->mdev, buf);
> }
> EXPORT_SYMBOL_GPL(v4l2_m2m_prepare_buf);
>
> @@ -934,6 +935,48 @@ void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx,
> }
> EXPORT_SYMBOL_GPL(v4l2_m2m_buf_queue);
>
> +void vb2_m2m_request_queue(struct media_request *req)
> +{
> + struct media_request_object *obj, *obj_safe;
> + struct v4l2_m2m_ctx *m2m_ctx = NULL;
> +
> + /* Queue all non-buffer objects */
> + list_for_each_entry_safe(obj, obj_safe, &req->objects, list)
> + if (obj->ops->queue && !vb2_request_object_is_buffer(obj))
> + obj->ops->queue(obj);
> +
> + /* Queue all buffer objects */
> + list_for_each_entry_safe(obj, obj_safe, &req->objects, list) {
> + struct v4l2_m2m_ctx *m2m_ctx_obj;
> + struct vb2_buffer *vb;
> +
> + if (!obj->ops->queue || !vb2_request_object_is_buffer(obj))
> + continue;
> +
> + /* Sanity checks */
> + vb = container_of(obj, struct vb2_buffer, req_obj);
> + WARN_ON(!V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type));
> + m2m_ctx_obj = container_of(vb->vb2_queue,
> + struct v4l2_m2m_ctx,
> + out_q_ctx.q);
> + WARN_ON(m2m_ctx && m2m_ctx_obj != m2m_ctx);
> + m2m_ctx = m2m_ctx_obj;
> +
> + /*
> + * The buffer we queue here can in theory be immediately
> + * unbound, hence the use of list_for_each_entry_safe()
> + * above and why we call the queue op last.
> + */
> + obj->ops->queue(obj);
> + }
> +
> + WARN_ON(!m2m_ctx);
> +
> + if (m2m_ctx)
> + v4l2_m2m_try_schedule(m2m_ctx);
> +}
> +EXPORT_SYMBOL_GPL(vb2_m2m_request_queue);
> +
> /* Videobuf2 ioctl helpers */
>
> int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv,
> diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
> index d655720e16a1..58c1ecf3d648 100644
> --- a/include/media/v4l2-mem2mem.h
> +++ b/include/media/v4l2-mem2mem.h
> @@ -622,6 +622,10 @@ v4l2_m2m_dst_buf_remove_by_idx(struct v4l2_m2m_ctx *m2m_ctx, unsigned int idx)
> return v4l2_m2m_buf_remove_by_idx(&m2m_ctx->cap_q_ctx, idx);
> }
>
> +/* v4l2 request helper */
> +
> +void vb2_m2m_request_queue(struct media_request *req);
> +
> /* v4l2 ioctl helpers */
>
> int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv,
Thanks,
Mauro
next prev parent reply other threads:[~2018-08-13 17:45 UTC|newest]
Thread overview: 106+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-04 12:44 [PATCHv17 00/34] Request API Hans Verkuil
2018-08-04 12:44 ` [PATCHv17 01/34] Documentation: v4l: document request API Hans Verkuil
2018-08-06 23:44 ` Pavel Machek
2018-08-09 17:43 ` Mauro Carvalho Chehab
2018-08-10 7:20 ` Hans Verkuil
2018-08-14 8:21 ` Mauro Carvalho Chehab
2018-08-14 7:57 ` Hans Verkuil
2018-08-14 8:48 ` Mauro Carvalho Chehab
2018-08-14 9:51 ` Hans Verkuil
2018-08-14 12:18 ` Mauro Carvalho Chehab
2018-08-04 12:44 ` [PATCHv17 02/34] uapi/linux/media.h: add " Hans Verkuil
2018-08-09 17:53 ` Mauro Carvalho Chehab
2018-08-10 7:21 ` Hans Verkuil
2018-08-14 8:46 ` Mauro Carvalho Chehab
2018-08-14 9:57 ` Hans Verkuil
2018-08-14 12:34 ` Mauro Carvalho Chehab
2018-08-04 12:44 ` [PATCHv17 03/34] media-request: implement media requests Hans Verkuil
2018-08-09 18:37 ` Mauro Carvalho Chehab
2018-08-10 7:28 ` Hans Verkuil
2018-08-14 13:33 ` Hans Verkuil
2018-08-04 12:44 ` [PATCHv17 04/34] media: doc: Add media-request.h header to documentation build Hans Verkuil
2018-08-09 18:43 ` Mauro Carvalho Chehab
2018-08-04 12:44 ` [PATCHv17 05/34] media-request: add media_request_get_by_fd Hans Verkuil
2018-08-09 19:55 ` Mauro Carvalho Chehab
2018-08-10 7:32 ` Hans Verkuil
2018-08-14 9:00 ` Mauro Carvalho Chehab
2018-08-04 12:44 ` [PATCHv17 06/34] media-request: add media_request_object_find Hans Verkuil
2018-08-09 19:56 ` Mauro Carvalho Chehab
2018-08-04 12:44 ` [PATCHv17 07/34] v4l2-device.h: add v4l2_device_supports_requests() helper Hans Verkuil
2018-08-09 19:57 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 08/34] v4l2-dev: lock req_queue_mutex Hans Verkuil
2018-08-09 20:03 ` Mauro Carvalho Chehab
2018-08-10 7:39 ` Hans Verkuil
2018-08-14 8:09 ` Mauro Carvalho Chehab
2018-08-14 12:00 ` Hans Verkuil
2018-08-14 12:39 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 09/34] videodev2.h: add request_fd field to v4l2_ext_controls Hans Verkuil
2018-08-09 20:04 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 10/34] v4l2-ctrls: v4l2_ctrl_add_handler: add from_other_dev Hans Verkuil
2018-08-09 20:10 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 11/34] v4l2-ctrls: prepare internal structs for request API Hans Verkuil
2018-08-09 20:16 ` Mauro Carvalho Chehab
2018-08-10 7:41 ` Hans Verkuil
2018-08-04 12:45 ` [PATCHv17 12/34] v4l2-ctrls: alloc memory for p_req Hans Verkuil
2018-08-09 20:19 ` Mauro Carvalho Chehab
2018-08-10 7:41 ` Hans Verkuil
2018-08-04 12:45 ` [PATCHv17 13/34] v4l2-ctrls: use ref in helper instead of ctrl Hans Verkuil
2018-08-09 20:22 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 14/34] v4l2-ctrls: add core request support Hans Verkuil
2018-08-13 10:55 ` Mauro Carvalho Chehab
2018-08-14 8:34 ` Hans Verkuil
2018-08-14 8:59 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 15/34] v4l2-ctrls: support g/s_ext_ctrls for requests Hans Verkuil
2018-08-13 11:05 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 16/34] v4l2-ctrls: add v4l2_ctrl_request_hdl_find/put/ctrl_find functions Hans Verkuil
2018-08-13 11:07 ` Mauro Carvalho Chehab
2018-08-14 8:45 ` Hans Verkuil
2018-08-14 8:55 ` Mauro Carvalho Chehab
2018-08-14 10:50 ` Hans Verkuil
2018-08-04 12:45 ` [PATCHv17 17/34] vb2: store userspace data in vb2_v4l2_buffer Hans Verkuil
2018-08-13 11:15 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 18/34] davinci_vpfe: remove bogus vb2->state check Hans Verkuil
2018-08-13 11:17 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 19/34] vb2: drop VB2_BUF_STATE_PREPARED, use bool prepared/synced instead Hans Verkuil
2018-08-13 11:30 ` Mauro Carvalho Chehab
2018-08-14 8:58 ` Hans Verkuil
2018-08-14 9:06 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 20/34] videodev2.h: Add request_fd field to v4l2_buffer Hans Verkuil
2018-08-13 11:41 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 21/34] vb2: add init_buffer buffer op Hans Verkuil
2018-08-13 11:56 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 22/34] videobuf2-core: embed media_request_object Hans Verkuil
2018-08-13 11:58 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 23/34] videobuf2-core: integrate with media requests Hans Verkuil
2018-08-13 12:09 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 24/34] videobuf2-v4l2: " Hans Verkuil
2018-08-13 14:30 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 25/34] videobuf2-core: add request helper functions Hans Verkuil
2018-08-13 14:50 ` Mauro Carvalho Chehab
2018-08-14 7:22 ` Hans Verkuil
2018-08-04 12:45 ` [PATCHv17 26/34] videobuf2-v4l2: add vb2_request_queue/validate helpers Hans Verkuil
2018-08-13 14:53 ` Mauro Carvalho Chehab
2018-08-14 7:19 ` Hans Verkuil
2018-08-14 7:49 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 27/34] videobuf2-core: add uses_requests/qbuf flags Hans Verkuil
2018-08-13 14:55 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 28/34] videobuf2-v4l2: refuse qbuf if queue uses requests or vv Hans Verkuil
2018-08-13 14:56 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 29/34] v4l2-mem2mem: add vb2_m2m_request_queue Hans Verkuil
2018-08-13 15:02 ` Mauro Carvalho Chehab [this message]
2018-08-14 7:26 ` Hans Verkuil
2018-08-04 12:45 ` [PATCHv17 30/34] vim2m: use workqueue Hans Verkuil
2018-08-13 15:05 ` Mauro Carvalho Chehab
2018-08-14 7:28 ` Hans Verkuil
2018-08-14 7:41 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 31/34] vim2m: support requests Hans Verkuil
2018-08-06 21:02 ` Ezequiel Garcia
2018-08-13 15:08 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 32/34] vivid: add mc Hans Verkuil
2018-08-13 15:09 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 33/34] vivid: add request support Hans Verkuil
2018-08-13 15:11 ` Mauro Carvalho Chehab
2018-08-04 12:45 ` [PATCHv17 34/34] RFC: media-requests: add debugfs node Hans Verkuil
2018-08-13 15:15 ` Mauro Carvalho Chehab
2018-08-14 7:33 ` Hans Verkuil
2018-08-14 7:43 ` Mauro Carvalho Chehab
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=20180813120149.1040f6f7@coco.lan \
--to=mchehab+samsung@kernel.org \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.