From nobody Thu Nov 14 06:07:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36FC3EB64DB for ; Thu, 22 Jun 2023 13:14:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231272AbjFVNOK (ORCPT ); Thu, 22 Jun 2023 09:14:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231591AbjFVNOC (ORCPT ); Thu, 22 Jun 2023 09:14:02 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82FD01BD2; Thu, 22 Jun 2023 06:13:59 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7d72:676c:e745:a6ef]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id C61286607119; Thu, 22 Jun 2023 14:13:57 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439638; bh=V+z/vGA0JHcb48G7cBo9k4XKRA8Ie7dXRj1eCbEXorE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XA5h3zyGUpFXNMTpDtJqv4HvAdhzZHSFQBun+ZcIeDuWI0X+ZTiOMVi1yzagwuOBK mImSHD6b4w2uyf3x3xIlpC8ZGdmUAIJlxLlUz2plO9fQNCyHtmhptRrulJ1GtUSibC X2pUXig0SooKWNoCp5+FQRNamobpfSCEjgJTY8OVZKB3FqWCfwHN+o6vqQgv7yrvAi 92rUcuzv5z+rzsomPwmX4BQPH7hByZVLfl7rrWI8fL3yOOxvpZG8RCekHyZayF2bt4 Y26PUqWU999RKrJPfm+BdNOEc31FZObZbJKhA8lR8XWJmg+cqT0iuFd35q2kaHnCUb P4eILdB6JRoFQ== From: Benjamin Gaignard To: 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, hverkuil-cisco@xs4all.nl, 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, Benjamin Gaignard Subject: [PATCH v3 01/11] media: videobuf2: Access vb2_queue bufs array through helper functions Date: Thu, 22 Jun 2023 15:13:39 +0200 Message-Id: <20230622131349.144160-2-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230622131349.144160-1-benjamin.gaignard@collabora.com> References: <20230622131349.144160-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The first step before changing how vb2 buffers are stored into queue is to avoid direct access to bufs arrays. This patch adds 2 helpers functions to add and remove vb2 buffers from a queue. With these 2 and vb2_get_buffer(), bufs field of struct vb2_queue becomes like a private member of the structure. After each call to vb2_get_buffer() we need to be sure that we get a valid pointer so check the return value of all of them. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 215 ++++++++++++++---- .../media/common/videobuf2/videobuf2-v4l2.c | 28 ++- drivers/media/platform/amphion/vpu_dbg.c | 22 +- .../platform/mediatek/jpeg/mtk_jpeg_core.c | 6 +- .../vcodec/vdec/vdec_vp9_req_lat_if.c | 2 +- drivers/media/platform/st/sti/hva/hva-v4l2.c | 4 + drivers/media/test-drivers/visl/visl-dec.c | 28 ++- .../staging/media/atomisp/pci/atomisp_ioctl.c | 2 +- 8 files changed, 240 insertions(+), 67 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/medi= a/common/videobuf2/videobuf2-core.c index cf6727d9c81f..42fd3984c2bc 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -359,8 +359,16 @@ static void __setup_offsets(struct vb2_buffer *vb) unsigned long off =3D 0; =20 if (vb->index) { - struct vb2_buffer *prev =3D q->bufs[vb->index - 1]; - struct vb2_plane *p =3D &prev->planes[prev->num_planes - 1]; + struct vb2_buffer *prev; + struct vb2_plane *p; + + prev =3D vb2_get_buffer(q, vb->index - 1); + if (!prev) { + dprintk(q, 1, "can't find the requested buffer\n"); + return; + } + + p =3D &prev->planes[prev->num_planes - 1]; =20 off =3D PAGE_ALIGN(p->m.offset + p->length); } @@ -397,6 +405,37 @@ static void init_buffer_cache_hints(struct vb2_queue *= q, struct vb2_buffer *vb) vb->skip_cache_sync_on_finish =3D 1; } =20 +/** + * vb2_queue_add_buffer() - add a buffer to a queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @vb: pointer to &struct vb2_buffer to be added to the queue. + * @index: index where add vb2_buffer in the queue + */ +static bool vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *v= b, int index) +{ + if (index < VB2_MAX_FRAME && !q->bufs[index]) { + q->bufs[index] =3D vb; + vb->index =3D index; + vb->vb2_queue =3D q; + return true; + } + + return false; +} + +/** + * vb2_queue_remove_buffer() - remove a buffer from a queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @vb: pointer to &struct vb2_buffer to be removed from the queue. + */ +static void vb2_queue_remove_buffer(struct vb2_queue *q, struct vb2_buffer= *vb) +{ + if (vb->index < VB2_MAX_FRAME) { + q->bufs[vb->index] =3D NULL; + vb->vb2_queue =3D NULL; + } +} + /* * __vb2_queue_alloc() - allocate vb2 buffer structures and (for MMAP type) * video buffer memory for all buffers/planes on the queue and initializes= the @@ -425,9 +464,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum = vb2_memory memory, } =20 vb->state =3D VB2_BUF_STATE_DEQUEUED; - vb->vb2_queue =3D q; vb->num_planes =3D num_planes; - vb->index =3D q->num_buffers + buffer; vb->type =3D q->type; vb->memory =3D memory; init_buffer_cache_hints(q, vb); @@ -437,7 +474,11 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum= vb2_memory memory, } call_void_bufop(q, init_buffer, vb); =20 - q->bufs[vb->index] =3D vb; + if (!vb2_queue_add_buffer(q, vb, q->num_buffers + buffer)) { + dprintk(q, 1, "failed adding buffer %d to queue\n", buffer); + kfree(vb); + break; + } =20 /* Allocate video buffer memory for the MMAP type */ if (memory =3D=3D VB2_MEMORY_MMAP) { @@ -445,7 +486,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum = vb2_memory memory, if (ret) { dprintk(q, 1, "failed allocating memory for buffer %d\n", buffer); - q->bufs[vb->index] =3D NULL; + vb2_queue_remove_buffer(q, vb); kfree(vb); break; } @@ -460,7 +501,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum = vb2_memory memory, dprintk(q, 1, "buffer %d %p initialization failed\n", buffer, vb); __vb2_buf_mem_free(vb); - q->bufs[vb->index] =3D NULL; + vb2_queue_remove_buffer(q, vb); kfree(vb); break; } @@ -483,7 +524,7 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigne= d int buffers) =20 for (buffer =3D q->num_buffers - buffers; buffer < q->num_buffers; ++buffer) { - vb =3D q->bufs[buffer]; + vb =3D vb2_get_buffer(q, buffer); if (!vb) continue; =20 @@ -511,7 +552,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsig= ned int buffers) /* Call driver-provided cleanup function for each buffer, if provided */ for (buffer =3D q->num_buffers - buffers; buffer < q->num_buffers; ++buffer) { - struct vb2_buffer *vb =3D q->bufs[buffer]; + struct vb2_buffer *vb =3D vb2_get_buffer(q, buffer); =20 if (vb && vb->planes[0].mem_priv) call_void_vb_qop(vb, buf_cleanup, vb); @@ -551,15 +592,20 @@ static void __vb2_queue_free(struct vb2_queue *q, uns= igned int buffers) q->cnt_unprepare_streaming =3D 0; } for (buffer =3D 0; buffer < q->num_buffers; ++buffer) { - struct vb2_buffer *vb =3D q->bufs[buffer]; - bool unbalanced =3D vb->cnt_mem_alloc !=3D vb->cnt_mem_put || - vb->cnt_mem_prepare !=3D vb->cnt_mem_finish || - vb->cnt_mem_get_userptr !=3D vb->cnt_mem_put_userptr || - vb->cnt_mem_attach_dmabuf !=3D vb->cnt_mem_detach_dmabuf || - vb->cnt_mem_map_dmabuf !=3D vb->cnt_mem_unmap_dmabuf || - vb->cnt_buf_queue !=3D vb->cnt_buf_done || - vb->cnt_buf_prepare !=3D vb->cnt_buf_finish || - vb->cnt_buf_init !=3D vb->cnt_buf_cleanup; + struct vb2_buffer *vb =3D vb2_get_buffer(q, buffer); + bool unbalanced; + + if (!vb) + continue; + + unbalanced =3D vb->cnt_mem_alloc !=3D vb->cnt_mem_put || + vb->cnt_mem_prepare !=3D vb->cnt_mem_finish || + vb->cnt_mem_get_userptr !=3D vb->cnt_mem_put_userptr || + vb->cnt_mem_attach_dmabuf !=3D vb->cnt_mem_detach_dmabuf || + vb->cnt_mem_map_dmabuf !=3D vb->cnt_mem_unmap_dmabuf || + vb->cnt_buf_queue !=3D vb->cnt_buf_done || + vb->cnt_buf_prepare !=3D vb->cnt_buf_finish || + vb->cnt_buf_init !=3D vb->cnt_buf_cleanup; =20 if (unbalanced || debug) { pr_info(" counters for queue %p, buffer %d:%s\n", @@ -591,8 +637,13 @@ static void __vb2_queue_free(struct vb2_queue *q, unsi= gned int buffers) /* Free vb2 buffers */ for (buffer =3D q->num_buffers - buffers; buffer < q->num_buffers; ++buffer) { - kfree(q->bufs[buffer]); - q->bufs[buffer] =3D NULL; + struct vb2_buffer *vb =3D vb2_get_buffer(q, buffer); + + if (!vb) + continue; + + vb2_queue_remove_buffer(q, vb); + kfree(vb); } =20 q->num_buffers -=3D buffers; @@ -628,7 +679,12 @@ static bool __buffers_in_use(struct vb2_queue *q) { unsigned int buffer; for (buffer =3D 0; buffer < q->num_buffers; ++buffer) { - if (vb2_buffer_in_use(q, q->bufs[buffer])) + struct vb2_buffer *vb =3D vb2_get_buffer(q, buffer); + + if (!vb) + continue; + + if (vb2_buffer_in_use(q, vb)) return true; } return false; @@ -636,7 +692,10 @@ static bool __buffers_in_use(struct vb2_queue *q) =20 void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb) { - call_void_bufop(q, fill_user_buffer, q->bufs[index], pb); + struct vb2_buffer *vb =3D vb2_get_buffer(q, index); + + if (vb) + call_void_bufop(q, fill_user_buffer, vb, pb); } EXPORT_SYMBOL_GPL(vb2_core_querybuf); =20 @@ -1547,7 +1606,13 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsign= ed int index, void *pb) struct vb2_buffer *vb; int ret; =20 - vb =3D q->bufs[index]; + vb =3D vb2_get_buffer(q, index); + + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); + return -EINVAL; + } + if (vb->state !=3D VB2_BUF_STATE_DEQUEUED) { dprintk(q, 1, "invalid buffer state %s\n", vb2_state_name(vb->state)); @@ -1618,7 +1683,11 @@ static int vb2_start_streaming(struct vb2_queue *q) * correctly return them to vb2. */ for (i =3D 0; i < q->num_buffers; ++i) { - vb =3D q->bufs[i]; + vb =3D vb2_get_buffer(q, i); + + if (!vb) + continue; + if (vb->state =3D=3D VB2_BUF_STATE_ACTIVE) vb2_buffer_done(vb, VB2_BUF_STATE_QUEUED); } @@ -1646,7 +1715,12 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int = index, void *pb, return -EIO; } =20 - vb =3D q->bufs[index]; + vb =3D vb2_get_buffer(q, index); + + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); + return -EINVAL; + } =20 if (!req && vb->state !=3D VB2_BUF_STATE_IN_REQUEST && q->requires_requests) { @@ -2022,12 +2096,18 @@ static void __vb2_queue_cancel(struct vb2_queue *q) * to vb2 in stop_streaming(). */ if (WARN_ON(atomic_read(&q->owned_by_drv_count))) { - for (i =3D 0; i < q->num_buffers; ++i) - if (q->bufs[i]->state =3D=3D VB2_BUF_STATE_ACTIVE) { + for (i =3D 0; i < q->num_buffers; ++i) { + struct vb2_buffer *vb =3D vb2_get_buffer(q, i); + + if (!vb) + continue; + + if (vb->state =3D=3D VB2_BUF_STATE_ACTIVE) { pr_warn("driver bug: stop_streaming operation is leaving buf %p in act= ive state\n", - q->bufs[i]); - vb2_buffer_done(q->bufs[i], VB2_BUF_STATE_ERROR); + vb); + vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); } + } /* Must be zero now */ WARN_ON(atomic_read(&q->owned_by_drv_count)); } @@ -2061,9 +2141,14 @@ static void __vb2_queue_cancel(struct vb2_queue *q) * be changed, so we can't move the buf_finish() to __vb2_dqbuf(). */ for (i =3D 0; i < q->num_buffers; ++i) { - struct vb2_buffer *vb =3D q->bufs[i]; - struct media_request *req =3D vb->req_obj.req; + struct vb2_buffer *vb; + struct media_request *req; =20 + vb =3D vb2_get_buffer(q, i); + if (!vb) + continue; + + req =3D vb->req_obj.req; /* * If a request is associated with this buffer, then * call buf_request_cancel() to give the driver to complete() @@ -2215,7 +2300,10 @@ static int __find_plane_by_offset(struct vb2_queue *= q, unsigned long off, * return its buffer and plane numbers. */ for (buffer =3D 0; buffer < q->num_buffers; ++buffer) { - vb =3D q->bufs[buffer]; + vb =3D vb2_get_buffer(q, buffer); + + if (!vb) + continue; =20 for (plane =3D 0; plane < vb->num_planes; ++plane) { if (vb->planes[plane].m.offset =3D=3D off) { @@ -2262,7 +2350,12 @@ int vb2_core_expbuf(struct vb2_queue *q, int *fd, un= signed int type, return -EINVAL; } =20 - vb =3D q->bufs[index]; + vb =3D vb2_get_buffer(q, index); + + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); + return -EINVAL; + } =20 if (plane >=3D vb->num_planes) { dprintk(q, 1, "buffer plane out of range\n"); @@ -2339,7 +2432,13 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_str= uct *vma) if (ret) goto unlock; =20 - vb =3D q->bufs[buffer]; + vb =3D vb2_get_buffer(q, buffer); + + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); + ret =3D -EINVAL; + goto unlock; + } =20 /* * MMAP requires page_aligned buffers. @@ -2396,7 +2495,12 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue= *q, if (ret) goto unlock; =20 - vb =3D q->bufs[buffer]; + vb =3D vb2_get_buffer(q, buffer); + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); + ret =3D -EINVAL; + goto unlock; + } =20 vaddr =3D vb2_plane_vaddr(vb, plane); mutex_unlock(&q->mmap_lock); @@ -2625,6 +2729,7 @@ struct vb2_fileio_data { static int __vb2_init_fileio(struct vb2_queue *q, int read) { struct vb2_fileio_data *fileio; + struct vb2_buffer *vb; int i, ret; unsigned int count =3D 0; =20 @@ -2679,7 +2784,13 @@ static int __vb2_init_fileio(struct vb2_queue *q, in= t read) * Check if plane_count is correct * (multiplane buffers are not supported). */ - if (q->bufs[0]->num_planes !=3D 1) { + vb =3D vb2_get_buffer(q, 0); + if (!vb) { + ret =3D -EBUSY; + goto err_reqbufs; + } + + if (vb->num_planes !=3D 1) { ret =3D -EBUSY; goto err_reqbufs; } @@ -2688,12 +2799,17 @@ static int __vb2_init_fileio(struct vb2_queue *q, i= nt read) * Get kernel address of each buffer. */ for (i =3D 0; i < q->num_buffers; i++) { - fileio->bufs[i].vaddr =3D vb2_plane_vaddr(q->bufs[i], 0); + vb =3D vb2_get_buffer(q, i); + + if (!vb) + continue; + + fileio->bufs[i].vaddr =3D vb2_plane_vaddr(vb, 0); if (fileio->bufs[i].vaddr =3D=3D NULL) { ret =3D -EINVAL; goto err_reqbufs; } - fileio->bufs[i].size =3D vb2_plane_size(q->bufs[i], 0); + fileio->bufs[i].size =3D vb2_plane_size(vb, 0); } =20 /* @@ -2821,15 +2937,18 @@ static size_t __vb2_perform_fileio(struct vb2_queue= *q, char __user *data, size_ =20 fileio->cur_index =3D index; buf =3D &fileio->bufs[index]; - b =3D q->bufs[index]; + b =3D vb2_get_buffer(q, index); + + if (!b) + return -EINVAL; =20 /* * Get number of bytes filled by the driver */ buf->pos =3D 0; buf->queued =3D 0; - buf->size =3D read ? vb2_get_plane_payload(q->bufs[index], 0) - : vb2_plane_size(q->bufs[index], 0); + buf->size =3D read ? vb2_get_plane_payload(b, 0) + : vb2_plane_size(b, 0); /* Compensate for data_offset on read in the multiplanar case. */ if (is_multiplanar && read && b->planes[0].data_offset < buf->size) { @@ -2872,8 +2991,12 @@ static size_t __vb2_perform_fileio(struct vb2_queue = *q, char __user *data, size_ * Queue next buffer if required. */ if (buf->pos =3D=3D buf->size || (!read && fileio->write_immediately)) { - struct vb2_buffer *b =3D q->bufs[index]; + struct vb2_buffer *b =3D vb2_get_buffer(q, index); =20 + if (!b) { + dprintk(q, 1, "can't find the requested buffer\n"); + return -EINVAL; + } /* * Check if this is the last buffer to read. */ @@ -2899,7 +3022,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *= q, char __user *data, size_ */ buf->pos =3D 0; buf->queued =3D 1; - buf->size =3D vb2_plane_size(q->bufs[index], 0); + buf->size =3D vb2_plane_size(b, 0); fileio->q_count +=3D 1; /* * If we are queuing up buffers for the first time, then @@ -2970,7 +3093,9 @@ static int vb2_thread(void *data) * Call vb2_dqbuf to get buffer back. */ if (prequeue) { - vb =3D q->bufs[index++]; + vb =3D vb2_get_buffer(q, index++); + if (!vb) + continue; prequeue--; } else { call_void_qop(q, wait_finish, q); @@ -2979,7 +3104,7 @@ static int vb2_thread(void *data) call_void_qop(q, wait_prepare, q); dprintk(q, 5, "file io: vb2_dqbuf result: %d\n", ret); if (!ret) - vb =3D q->bufs[index]; + vb =3D vb2_get_buffer(q, index); } if (ret || threadio->stop) break; diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/medi= a/common/videobuf2/videobuf2-v4l2.c index c7a54d82a55e..724135d41f7f 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -383,8 +383,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q= , struct media_device *md return -EINVAL; } =20 - if (q->bufs[b->index] =3D=3D NULL) { - /* Should never happen */ + if (!vb2_get_buffer(q, b->index)) { dprintk(q, 1, "%s: buffer is NULL\n", opname); return -EINVAL; } @@ -394,7 +393,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q= , struct media_device *md return -EINVAL; } =20 - vb =3D q->bufs[b->index]; + vb =3D vb2_get_buffer(q, b->index); vbuf =3D to_vb2_v4l2_buffer(vb); ret =3D __verify_planes_array(vb, b); if (ret) @@ -628,11 +627,18 @@ static const struct vb2_buf_ops v4l2_buf_ops =3D { struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp) { unsigned int i; + struct vb2_buffer *vb2; =20 - for (i =3D 0; i < q->num_buffers; i++) - if (q->bufs[i]->copied_timestamp && - q->bufs[i]->timestamp =3D=3D timestamp) - return vb2_get_buffer(q, i); + for (i =3D 0; i < q->num_buffers; i++) { + vb2 =3D vb2_get_buffer(q, i); + + if (!vb2) + continue; + + if (vb2->copied_timestamp && + vb2->timestamp =3D=3D timestamp) + return vb2; + } return NULL; } EXPORT_SYMBOL_GPL(vb2_find_buffer); @@ -664,7 +670,13 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buff= er *b) dprintk(q, 1, "buffer index out of range\n"); return -EINVAL; } - vb =3D q->bufs[b->index]; + vb =3D vb2_get_buffer(q, b->index); + + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); + return -EINVAL; + } + ret =3D __verify_planes_array(vb, b); if (!ret) vb2_core_querybuf(q, b->index, b); diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platf= orm/amphion/vpu_dbg.c index 44b830ae01d8..e2c371c2fde5 100644 --- a/drivers/media/platform/amphion/vpu_dbg.c +++ b/drivers/media/platform/amphion/vpu_dbg.c @@ -133,11 +133,18 @@ static int vpu_dbg_instance(struct seq_file *s, void = *data) =20 vq =3D v4l2_m2m_get_src_vq(inst->fh.m2m_ctx); for (i =3D 0; i < vq->num_buffers; i++) { - struct vb2_buffer *vb =3D vq->bufs[i]; - struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buffer(vb); + struct vb2_buffer *vb; + struct vb2_v4l2_buffer *vbuf; + + vb =3D vb2_get_buffer(vq, i); + if (!vb) + continue; =20 if (vb->state =3D=3D VB2_BUF_STATE_DEQUEUED) continue; + + vbuf =3D to_vb2_v4l2_buffer(vb); + num =3D scnprintf(str, sizeof(str), "output [%2d] state =3D %10s, %8s\n", i, vb2_stat_name[vb->state], @@ -148,11 +155,18 @@ static int vpu_dbg_instance(struct seq_file *s, void = *data) =20 vq =3D v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); for (i =3D 0; i < vq->num_buffers; i++) { - struct vb2_buffer *vb =3D vq->bufs[i]; - struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buffer(vb); + struct vb2_buffer *vb; + struct vb2_v4l2_buffer *vbuf; + + vb =3D vb2_get_buffer(vq, i); + if (!vb) + continue; =20 if (vb->state =3D=3D VB2_BUF_STATE_DEQUEUED) continue; + + vbuf =3D to_vb2_v4l2_buffer(vb); + num =3D scnprintf(str, sizeof(str), "capture[%2d] state =3D %10s, %8s\n", i, vb2_stat_name[vb->state], diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers= /media/platform/mediatek/jpeg/mtk_jpeg_core.c index 0051f372a66c..ea37069ba355 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -603,7 +603,11 @@ static int mtk_jpeg_qbuf(struct file *file, void *priv= , struct v4l2_buffer *buf) return -EINVAL; } =20 - vb =3D vq->bufs[buf->index]; + vb =3D vb2_get_buffer(vq, buf->index); + if (!vb) { + dev_err(ctx->jpeg->dev, "buffer not found\n"); + return -EINVAL; + } jpeg_src_buf =3D mtk_jpeg_vb2_to_srcbuf(vb); jpeg_src_buf->bs_size =3D buf->m.planes[0].bytesused; =20 diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_i= f.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c index cf16cf2807f0..6532a69f1fa8 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c @@ -1701,7 +1701,7 @@ static int vdec_vp9_slice_setup_core_buffer(struct vd= ec_vp9_slice_instance *inst =20 /* update internal buffer's width/height */ for (i =3D 0; i < vq->num_buffers; i++) { - if (vb =3D=3D vq->bufs[i]) { + if (vb =3D=3D vb2_get_buffer(vq, i)) { instance->dpb[i].width =3D w; instance->dpb[i].height =3D h; break; diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/p= latform/st/sti/hva/hva-v4l2.c index 3a848ca32a0e..326be09bdb55 100644 --- a/drivers/media/platform/st/sti/hva/hva-v4l2.c +++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c @@ -577,6 +577,10 @@ static int hva_qbuf(struct file *file, void *priv, str= uct v4l2_buffer *buf) } =20 vb2_buf =3D vb2_get_buffer(vq, buf->index); + if (!vb2_buf) { + dev_dbg(dev, "%s buffer index %d not found\n", ctx->name, buf->index); + return -EINVAL; + } stream =3D to_hva_stream(to_vb2_v4l2_buffer(vb2_buf)); stream->bytesused =3D buf->bytesused; } diff --git a/drivers/media/test-drivers/visl/visl-dec.c b/drivers/media/tes= t-drivers/visl/visl-dec.c index 318d675e5668..ba20ea998d19 100644 --- a/drivers/media/test-drivers/visl/visl-dec.c +++ b/drivers/media/test-drivers/visl/visl-dec.c @@ -290,13 +290,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struc= t visl_run *run) for (i =3D 0; i < out_q->num_buffers; i++) { char entry[] =3D "index: %u, state: %s, request_fd: %d, "; u32 old_len =3D len; - char *q_status =3D visl_get_vb2_state(out_q->bufs[i]->state); + struct vb2_buffer *vb2; + char *q_status; + + vb2 =3D vb2_get_buffer(out_q, i); + if (!vb2) + continue; + + q_status =3D visl_get_vb2_state(vb2->state); =20 len +=3D scnprintf(&buf[len], TPG_STR_BUF_SZ - len, entry, i, q_status, - to_vb2_v4l2_buffer(out_q->bufs[i])->request_fd); + to_vb2_v4l2_buffer(vb2)->request_fd); =20 - len +=3D visl_fill_bytesused(to_vb2_v4l2_buffer(out_q->bufs[i]), + len +=3D visl_fill_bytesused(to_vb2_v4l2_buffer(vb2), &buf[len], TPG_STR_BUF_SZ - len); =20 @@ -342,13 +349,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struc= t visl_run *run) len =3D 0; for (i =3D 0; i < cap_q->num_buffers; i++) { u32 old_len =3D len; - char *q_status =3D visl_get_vb2_state(cap_q->bufs[i]->state); + struct vb2_buffer *vb2; + char *q_status; + + vb2 =3D vb2_get_buffer(cap_q, i); + if (!vb2) + continue; + + q_status =3D visl_get_vb2_state(vb2->state); =20 len +=3D scnprintf(&buf[len], TPG_STR_BUF_SZ - len, "index: %u, status: %s, timestamp: %llu, is_held: %d", - cap_q->bufs[i]->index, q_status, - cap_q->bufs[i]->timestamp, - to_vb2_v4l2_buffer(cap_q->bufs[i])->is_held); + vb2->index, q_status, + vb2->timestamp, + to_vb2_v4l2_buffer(vb2)->is_held); =20 tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, &buf[old_len]); frame_dprintk(ctx->dev, run->dst->sequence, "%s", &buf[old_len]); diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/st= aging/media/atomisp/pci/atomisp_ioctl.c index 384f31fc66c5..ec7e05263c8e 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -1077,7 +1077,7 @@ static int atomisp_dqbuf_wrapper(struct file *file, v= oid *fh, struct v4l2_buffer if (ret) return ret; =20 - vb =3D pipe->vb_queue.bufs[buf->index]; + vb =3D vb2_get_buffer(pipe->vb_queue, buf->index); frame =3D vb_to_frame(vb); =20 buf->reserved =3D asd->frame_status[buf->index]; --=20 2.39.2 From nobody Thu Nov 14 06:07:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78F50EB64DB for ; Thu, 22 Jun 2023 13:14:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231629AbjFVNOG (ORCPT ); Thu, 22 Jun 2023 09:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231558AbjFVNOB (ORCPT ); Thu, 22 Jun 2023 09:14:01 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2C761BD3; Thu, 22 Jun 2023 06:13:59 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7d72:676c:e745:a6ef]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 4FB41660711E; Thu, 22 Jun 2023 14:13:58 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439638; bh=t8kITWrGl0OsCDx7lvzHoBExx5sUqFU5dAXRs/EKO4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvR797bhp0zTiCSdScfhlbTHiIQr+utHyzNqQOongrdtKYpDwzUY0dWzKZPiFEqnU Vp+M7Y2JVVVAbeAA1bPTwIAWMVRo1zoQ0Jo632vU3uYP8DwzoI6ae2TvgAxP4N7hGb tC991tunarQYTHZ42wBjAFs76L3DMPSL4Z3l/u4D5NyNX/M1MdoAi2HKtFFo5zj5dv LCHML8nEK+y2kfaAqa+i4SV7jLe/BQQRK0t1vmXPQVo/UKPWsX035tkjUJO/rrc/Np rcZUErqSo9hyzmJXEaydmOtL+Wr2cCXILV8i/zNvZ5ymW326nqxtRdxJawJSvSIt07 4SjxbEmqKZYvw== From: Benjamin Gaignard To: 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, hverkuil-cisco@xs4all.nl, 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, Benjamin Gaignard Subject: [PATCH v3 02/11] media: videobuf2: Use Xarray instead of static buffers array Date: Thu, 22 Jun 2023 15:13:40 +0200 Message-Id: <20230622131349.144160-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230622131349.144160-1-benjamin.gaignard@collabora.com> References: <20230622131349.144160-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Instead of a static array change bufs to a dynamically allocated array. This will allow to store more video buffers if needed. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 38 +++++++++++-------- include/media/videobuf2-core.h | 6 +-- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/medi= a/common/videobuf2/videobuf2-core.c index 42fd3984c2bc..f1ff7af34a9f 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -409,18 +409,24 @@ static void init_buffer_cache_hints(struct vb2_queue = *q, struct vb2_buffer *vb) * vb2_queue_add_buffer() - add a buffer to a queue * @q: pointer to &struct vb2_queue with videobuf2 queue. * @vb: pointer to &struct vb2_buffer to be added to the queue. - * @index: index where add vb2_buffer in the queue */ -static bool vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *v= b, int index) +static bool vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *v= b) { - if (index < VB2_MAX_FRAME && !q->bufs[index]) { - q->bufs[index] =3D vb; - vb->index =3D index; - vb->vb2_queue =3D q; - return true; - } + struct xa_limit range =3D { + .max =3D UINT_MAX, + .min =3D q->num_buffers, + }; + u32 index; + int ret; =20 - return false; + ret =3D xa_alloc(&q->bufs, &index, vb, range, GFP_KERNEL); + if (ret) + return false; + + vb->index =3D index; + vb->vb2_queue =3D q; + + return true; } =20 /** @@ -430,10 +436,8 @@ static bool vb2_queue_add_buffer(struct vb2_queue *q, = struct vb2_buffer *vb, int */ static void vb2_queue_remove_buffer(struct vb2_queue *q, struct vb2_buffer= *vb) { - if (vb->index < VB2_MAX_FRAME) { - q->bufs[vb->index] =3D NULL; - vb->vb2_queue =3D NULL; - } + xa_erase(&q->bufs, vb->index); + vb->vb2_queue =3D NULL; } =20 /* @@ -474,7 +478,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum = vb2_memory memory, } call_void_bufop(q, init_buffer, vb); =20 - if (!vb2_queue_add_buffer(q, vb, q->num_buffers + buffer)) { + if (!vb2_queue_add_buffer(q, vb)) { dprintk(q, 1, "failed adding buffer %d to queue\n", buffer); kfree(vb); break; @@ -930,7 +934,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memo= ry memory, } =20 mutex_lock(&q->mmap_lock); - q->num_buffers =3D allocated_buffers; + q->num_buffers +=3D allocated_buffers; =20 if (ret < 0) { /* @@ -2547,6 +2551,9 @@ int vb2_core_queue_init(struct vb2_queue *q) mutex_init(&q->mmap_lock); init_waitqueue_head(&q->done_wq); =20 + xa_init_flags(&q->bufs, XA_FLAGS_ALLOC); + q->num_buffers =3D 0; + q->memory =3D VB2_MEMORY_UNKNOWN; =20 if (q->buf_struct_size =3D=3D 0) @@ -2574,6 +2581,7 @@ void vb2_core_queue_release(struct vb2_queue *q) mutex_lock(&q->mmap_lock); __vb2_queue_free(q, q->num_buffers); mutex_unlock(&q->mmap_lock); + xa_destroy(&q->bufs); } EXPORT_SYMBOL_GPL(vb2_core_queue_release); =20 diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 4b6a9d2ea372..77921cf894ef 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -619,7 +619,7 @@ struct vb2_queue { struct mutex mmap_lock; unsigned int memory; enum dma_data_direction dma_dir; - struct vb2_buffer *bufs[VB2_MAX_FRAME]; + struct xarray bufs; unsigned int num_buffers; =20 struct list_head queued_list; @@ -1239,9 +1239,7 @@ static inline void vb2_clear_last_buffer_dequeued(str= uct vb2_queue *q) static inline struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q, unsigned int index) { - if (index < q->num_buffers) - return q->bufs[index]; - return NULL; + return xa_load(&q->bufs, index); } =20 /* --=20 2.39.2 From nobody Thu Nov 14 06:07:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F29F2EB64D8 for ; Thu, 22 Jun 2023 13:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231463AbjFVNOb (ORCPT ); Thu, 22 Jun 2023 09:14:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231586AbjFVNOB (ORCPT ); Thu, 22 Jun 2023 09:14:01 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EDCF1BD7; Thu, 22 Jun 2023 06:14:00 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7d72:676c:e745:a6ef]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id CAD856607121; Thu, 22 Jun 2023 14:13:58 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439639; bh=AARgP4b8y2Xc1aS5YL8NqmR9rbb2o30p7zaaWtG32hU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZxTiNMH1hDCi1nmk94lamG1X/2drYWUgcsGIuJCmAR05Ubc5m56NTZ+iGvO/n0COj nne8y6hoklBPJ4I4t+WDe+eTO2xu+fS1eTuXPRnUScsede9aTvM654IoXdkFqk/GnG 3mlubjY9Uu2T3PqDO/7ETnGGa7FqWaMwdW5l/zCaTM9bRqXcsyj6ro6OMKhffFAnL6 jUETkWD2LsuwYKGL2MAfHw4aQEE6iuZZD+SfZ8qz1s9PM68lv2tgozf3XHVDQd3dHi k5RcUi5+R72uhu9shyNTsVUXzQDGH02zvUa16zSSJTA1JSma86yxCtjJ7lcwBFsmUI rQ2YJSV5cVQ1A== From: Benjamin Gaignard To: 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, hverkuil-cisco@xs4all.nl, 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, Benjamin Gaignard Subject: [PATCH v3 03/11] media: videobuf2: Remove VB2_MAX_FRAME limit on buffer storage Date: Thu, 22 Jun 2023 15:13:41 +0200 Message-Id: <20230622131349.144160-4-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230622131349.144160-1-benjamin.gaignard@collabora.com> References: <20230622131349.144160-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove VB2_MAX_FRAME buffer limit since Xarray allows to store more than that. Signed-off-by: Benjamin Gaignard --- drivers/media/common/videobuf2/videobuf2-core.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/medi= a/common/videobuf2/videobuf2-core.c index f1ff7af34a9f..86e1e926fa45 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -455,9 +455,9 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum = vb2_memory memory, struct vb2_buffer *vb; int ret; =20 - /* Ensure that q->num_buffers+num_buffers is below VB2_MAX_FRAME */ + /* Ensure that q->num_buffers + num_buffers is UINT_MAX */ num_buffers =3D min_t(unsigned int, num_buffers, - VB2_MAX_FRAME - q->num_buffers); + UINT_MAX - q->num_buffers); =20 for (buffer =3D 0; buffer < num_buffers; ++buffer) { /* Allocate vb2 buffer structures */ @@ -858,9 +858,9 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memo= ry memory, /* * Make sure the requested values and current defaults are sane. */ - WARN_ON(q->min_buffers_needed > VB2_MAX_FRAME); + WARN_ON(q->min_buffers_needed > UINT_MAX); num_buffers =3D max_t(unsigned int, *count, q->min_buffers_needed); - num_buffers =3D min_t(unsigned int, num_buffers, VB2_MAX_FRAME); + num_buffers =3D min_t(unsigned int, num_buffers, UINT_MAX); memset(q->alloc_devs, 0, sizeof(q->alloc_devs)); /* * Set this now to ensure that drivers see the correct q->memory value @@ -976,11 +976,6 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2= _memory memory, bool no_previous_buffers =3D !q->num_buffers; int ret; =20 - if (q->num_buffers =3D=3D VB2_MAX_FRAME) { - dprintk(q, 1, "maximum number of buffers already allocated\n"); - return -ENOBUFS; - } - if (no_previous_buffers) { if (q->waiting_in_dqbuf && *count) { dprintk(q, 1, "another dup()ped fd is waiting for a buffer\n"); @@ -1005,7 +1000,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb= 2_memory memory, return -EINVAL; } =20 - num_buffers =3D min(*count, VB2_MAX_FRAME - q->num_buffers); + num_buffers =3D min(*count, UINT_MAX - q->num_buffers); =20 if (requested_planes && requested_sizes) { num_planes =3D requested_planes; --=20 2.39.2 From nobody Thu Nov 14 06:07:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B342EB64D8 for ; Thu, 22 Jun 2023 13:14:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231150AbjFVNOX (ORCPT ); Thu, 22 Jun 2023 09:14:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231599AbjFVNOC (ORCPT ); Thu, 22 Jun 2023 09:14:02 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D98831BF5; Thu, 22 Jun 2023 06:14:00 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7d72:676c:e745:a6ef]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 4DD366607128; Thu, 22 Jun 2023 14:13:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439639; bh=Gzf/ktNZ3NOcffLCLpulGdLdygvof7OsvFbMBCI7WyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aMvDuxSN0D+ICceIa2k0/8ICJfyucHrHRy6tMCtP/unZ6iPcQKKAEFLkWsTfyZZKa tYZvz+3gLPPQgWb5r2zlBEe0pFVZEHNFtzut4Y2T929FVyI6i1VRb5DpNhpRGOljp8 8ChyFAD7r82W9PHtPu4lrMufSVdbn+TERA+ogPra54nVT1haZrF3K6Hd5NL7Po/6jX mCpx047zWZHtydN5YRQypOVaHxAxXx0tJgal/ffcKkpC6Q+o3m8R3dICGjJz6aqD98 eM0fO8vwWuZcWWfz5EyZzI2f9vUdJ0vr03/nsSOcUe3jyH+deoHQMw9RBI+u1WworB /9QEx87W6XWaA== From: Benjamin Gaignard To: 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, hverkuil-cisco@xs4all.nl, 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, Benjamin Gaignard Subject: [PATCH v3 04/11] media: videobuf2: Stop define VB2_MAX_FRAME as global Date: Thu, 22 Jun 2023 15:13:42 +0200 Message-Id: <20230622131349.144160-5-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230622131349.144160-1-benjamin.gaignard@collabora.com> References: <20230622131349.144160-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" After changing bufs arrays to a dynamic allocated array VB2_MAX_FRAME doesn't mean anything for videobuf2 core. Remove it from the core definitions but keep it for drivers internal needs. Signed-off-by: Benjamin Gaignard --- drivers/media/common/videobuf2/videobuf2-core.c | 2 ++ drivers/media/platform/amphion/vdec.c | 1 + .../media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c | 2 ++ drivers/media/platform/qcom/venus/hfi.h | 2 ++ drivers/media/platform/verisilicon/hantro_hw.h | 2 ++ drivers/staging/media/ipu3/ipu3-v4l2.c | 2 ++ include/media/videobuf2-core.h | 1 - include/media/videobuf2-v4l2.h | 4 ---- 8 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/medi= a/common/videobuf2/videobuf2-core.c index 86e1e926fa45..899783f67580 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -31,6 +31,8 @@ =20 #include =20 +#define VB2_MAX_FRAME 32 + static int debug; module_param(debug, int, 0644); =20 diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform= /amphion/vdec.c index 3fa1a74a2e20..b3219f6d17fa 100644 --- a/drivers/media/platform/amphion/vdec.c +++ b/drivers/media/platform/amphion/vdec.c @@ -28,6 +28,7 @@ =20 #define VDEC_MIN_BUFFER_CAP 8 #define VDEC_MIN_BUFFER_OUT 8 +#define VB2_MAX_FRAME 32 =20 struct vdec_fs_info { char name[8]; diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_i= f.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c index 6532a69f1fa8..a1e0f24bb91c 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c @@ -16,6 +16,8 @@ #include "../vdec_drv_if.h" #include "../vdec_vpu_if.h" =20 +#define VB2_MAX_FRAME 32 + /* reset_frame_context defined in VP9 spec */ #define VP9_RESET_FRAME_CONTEXT_NONE0 0 #define VP9_RESET_FRAME_CONTEXT_NONE1 1 diff --git a/drivers/media/platform/qcom/venus/hfi.h b/drivers/media/platfo= rm/qcom/venus/hfi.h index f25d412d6553..bd5ca5a8b945 100644 --- a/drivers/media/platform/qcom/venus/hfi.h +++ b/drivers/media/platform/qcom/venus/hfi.h @@ -10,6 +10,8 @@ =20 #include "hfi_helper.h" =20 +#define VB2_MAX_FRAME 32 + #define VIDC_SESSION_TYPE_VPE 0 #define VIDC_SESSION_TYPE_ENC 1 #define VIDC_SESSION_TYPE_DEC 2 diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media= /platform/verisilicon/hantro_hw.h index e83f0c523a30..9e8faf7ba6fb 100644 --- a/drivers/media/platform/verisilicon/hantro_hw.h +++ b/drivers/media/platform/verisilicon/hantro_hw.h @@ -15,6 +15,8 @@ #include #include =20 +#define VB2_MAX_FRAME 32 + #define DEC_8190_ALIGN_MASK 0x07U =20 #define MB_DIM 16 diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media= /ipu3/ipu3-v4l2.c index e530767e80a5..6627b5c2d4d6 100644 --- a/drivers/staging/media/ipu3/ipu3-v4l2.c +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c @@ -10,6 +10,8 @@ #include "ipu3.h" #include "ipu3-dmamap.h" =20 +#define VB2_MAX_FRAME 32 + /******************** v4l2_subdev_ops ********************/ =20 #define IPU3_RUNNING_MODE_VIDEO 0 diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 77921cf894ef..080b783d608d 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -20,7 +20,6 @@ #include #include =20 -#define VB2_MAX_FRAME (32) #define VB2_MAX_PLANES (8) =20 /** diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 5a845887850b..88a7a565170e 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -15,10 +15,6 @@ #include #include =20 -#if VB2_MAX_FRAME !=3D VIDEO_MAX_FRAME -#error VB2_MAX_FRAME !=3D VIDEO_MAX_FRAME -#endif - #if VB2_MAX_PLANES !=3D VIDEO_MAX_PLANES #error VB2_MAX_PLANES !=3D VIDEO_MAX_PLANES #endif --=20 2.39.2 From nobody Thu Nov 14 06:07:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDB80EB64DB for ; Thu, 22 Jun 2023 13:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231625AbjFVNOO (ORCPT ); Thu, 22 Jun 2023 09:14:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231607AbjFVNOD (ORCPT ); Thu, 22 Jun 2023 09:14:03 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B778910F8; Thu, 22 Jun 2023 06:14:01 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7d72:676c:e745:a6ef]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id C8242660712A; Thu, 22 Jun 2023 14:13:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439640; bh=rIFi9nI9oOmxH+BS4YnCMnkoeVakCslz/qMxBQ3B9rg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MOqdLbkq2AQHq8FAr2JuOBighmg47fId1/MSzd02Ldhp9KYzfGIUGxZBVyQS1F2Qj dRmSTQn7IKwwGoZnSIEEkb2B5qQg9dnuhxkRTmOVANLdaAV3AS2Wqqd8qDRs8e2vX5 TAQqEGHzpdpQ8AayfY17P838vZVY6EoIq5SPkMxbQRCiWqChIAiuQipzSz5Re57gi2 exfiDw8g3IVvMmiXQdyXw1ZhauNKw4qyX+HCW/njJf94u/Rm9mM+2i7ogpOlAMrxK9 MYxhXqa+5/0qN8XH6WNz4Hd0ODEyvk77T8hEhWXpKJUbM1wLFJ+/1je4anpMtkZpbs QPJti33S5Tycw== From: Benjamin Gaignard To: 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, hverkuil-cisco@xs4all.nl, 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, Benjamin Gaignard Subject: [PATCH v3 05/11] media: verisilicon: Refactor postprocessor to store more buffers Date: Thu, 22 Jun 2023 15:13:43 +0200 Message-Id: <20230622131349.144160-6-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230622131349.144160-1-benjamin.gaignard@collabora.com> References: <20230622131349.144160-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Like for vb queues remove VB2_MAX_FRAME upper limit on postprocessor buffers storage capacity. If a buffer hasn't been allocated when setting up the queue make possible to alloc it on the fly while streaming. This happens when resolution change between keyframes. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro.h | 6 +- .../media/platform/verisilicon/hantro_hw.h | 6 +- .../platform/verisilicon/hantro_postproc.c | 109 ++++++++++++------ .../media/platform/verisilicon/hantro_v4l2.c | 12 +- 4 files changed, 82 insertions(+), 51 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/pl= atform/verisilicon/hantro.h index 2989ebc631cc..bd0dca11b90a 100644 --- a/drivers/media/platform/verisilicon/hantro.h +++ b/drivers/media/platform/verisilicon/hantro.h @@ -460,12 +460,14 @@ hantro_get_dst_buf(struct hantro_ctx *ctx) =20 bool hantro_needs_postproc(const struct hantro_ctx *ctx, const struct hantro_fmt *fmt); +dma_addr_t +hantro_postproc_get_dec_buf_addr(struct hantro_ctx *ctx, int index); =20 static inline dma_addr_t hantro_get_dec_buf_addr(struct hantro_ctx *ctx, struct vb2_buffer *vb) { if (hantro_needs_postproc(ctx, ctx->vpu_dst_fmt)) - return ctx->postproc.dec_q[vb->index].dma; + return hantro_postproc_get_dec_buf_addr(ctx, vb->index); return vb2_dma_contig_plane_dma_addr(vb, 0); } =20 @@ -477,8 +479,8 @@ vb2_to_hantro_decoded_buf(struct vb2_buffer *buf) =20 void hantro_postproc_disable(struct hantro_ctx *ctx); void hantro_postproc_enable(struct hantro_ctx *ctx); +int hantro_postproc_init(struct hantro_ctx *ctx); void hantro_postproc_free(struct hantro_ctx *ctx); -int hantro_postproc_alloc(struct hantro_ctx *ctx); int hanto_postproc_enum_framesizes(struct hantro_ctx *ctx, struct v4l2_frmsizeenum *fsize); =20 diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media= /platform/verisilicon/hantro_hw.h index 9e8faf7ba6fb..5c7b6e04aded 100644 --- a/drivers/media/platform/verisilicon/hantro_hw.h +++ b/drivers/media/platform/verisilicon/hantro_hw.h @@ -15,8 +15,6 @@ #include #include =20 -#define VB2_MAX_FRAME 32 - #define DEC_8190_ALIGN_MASK 0x07U =20 #define MB_DIM 16 @@ -252,10 +250,10 @@ struct hantro_vp9_dec_hw_ctx { /** * struct hantro_postproc_ctx * - * @dec_q: References buffers, in decoder format. + * @dec_refs_xa: References buffers, in decoder format. */ struct hantro_postproc_ctx { - struct hantro_aux_buf dec_q[VB2_MAX_FRAME]; + struct xarray dec_refs_xa; }; =20 /** diff --git a/drivers/media/platform/verisilicon/hantro_postproc.c b/drivers= /media/platform/verisilicon/hantro_postproc.c index 6437423ccf3a..a6b67d0cc66c 100644 --- a/drivers/media/platform/verisilicon/hantro_postproc.c +++ b/drivers/media/platform/verisilicon/hantro_postproc.c @@ -170,36 +170,23 @@ static int hantro_postproc_g2_enum_framesizes(struct = hantro_ctx *ctx, return 0; } =20 -void hantro_postproc_free(struct hantro_ctx *ctx) +static int hantro_postproc_alloc(struct hantro_ctx *ctx, int index) { struct hantro_dev *vpu =3D ctx->dev; - unsigned int i; - - for (i =3D 0; i < VB2_MAX_FRAME; ++i) { - struct hantro_aux_buf *priv =3D &ctx->postproc.dec_q[i]; - - if (priv->cpu) { - dma_free_attrs(vpu->dev, priv->size, priv->cpu, - priv->dma, priv->attrs); - priv->cpu =3D NULL; - } - } -} - -int hantro_postproc_alloc(struct hantro_ctx *ctx) -{ - struct hantro_dev *vpu =3D ctx->dev; - struct v4l2_m2m_ctx *m2m_ctx =3D ctx->fh.m2m_ctx; - struct vb2_queue *cap_queue =3D &m2m_ctx->cap_q_ctx.q; - unsigned int num_buffers =3D cap_queue->num_buffers; struct v4l2_pix_format_mplane pix_mp; const struct hantro_fmt *fmt; - unsigned int i, buf_size; + struct hantro_aux_buf *priv; + unsigned int buf_size; + + priv =3D kzalloc(sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; =20 /* this should always pick native format */ fmt =3D hantro_get_default_fmt(ctx, false, ctx->bit_depth); if (!fmt) return -EINVAL; + v4l2_fill_pixfmt_mp(&pix_mp, fmt->fourcc, ctx->src_fmt.width, ctx->src_fmt.height); =20 @@ -214,20 +201,74 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx) buf_size +=3D hantro_hevc_mv_size(pix_mp.width, pix_mp.height); =20 - for (i =3D 0; i < num_buffers; ++i) { - struct hantro_aux_buf *priv =3D &ctx->postproc.dec_q[i]; - - /* - * The buffers on this queue are meant as intermediate - * buffers for the decoder, so no mapping is needed. - */ - priv->attrs =3D DMA_ATTR_NO_KERNEL_MAPPING; - priv->cpu =3D dma_alloc_attrs(vpu->dev, buf_size, &priv->dma, - GFP_KERNEL, priv->attrs); - if (!priv->cpu) - return -ENOMEM; - priv->size =3D buf_size; + /* + * The buffers on this queue are meant as intermediate + * buffers for the decoder, so no mapping is needed. + */ + priv->attrs =3D DMA_ATTR_NO_KERNEL_MAPPING; + priv->cpu =3D dma_alloc_attrs(vpu->dev, buf_size, &priv->dma, GFP_KERNEL,= priv->attrs); + if (!priv->cpu) + return -ENOMEM; + + priv->size =3D buf_size; + + xa_store(&ctx->postproc.dec_refs_xa, index, priv, GFP_KERNEL); + + return 0; +} + +void hantro_postproc_free(struct hantro_ctx *ctx) +{ + struct hantro_dev *vpu =3D ctx->dev; + struct hantro_aux_buf *priv; + unsigned long i; + + xa_for_each(&ctx->postproc.dec_refs_xa, i, priv) { + dma_free_attrs(vpu->dev, priv->size, priv->cpu, priv->dma, priv->attrs); + kfree(priv); + } + + xa_destroy(&ctx->postproc.dec_refs_xa); +} + +int hantro_postproc_init(struct hantro_ctx *ctx) +{ + struct v4l2_m2m_ctx *m2m_ctx =3D ctx->fh.m2m_ctx; + struct vb2_queue *cap_queue =3D &m2m_ctx->cap_q_ctx.q; + unsigned int num_buffers =3D cap_queue->num_buffers; + int i, ret =3D 0; + + xa_init_flags(&ctx->postproc.dec_refs_xa, XA_FLAGS_ALLOC); + + for (i =3D 0; i < num_buffers; i++) { + ret =3D hantro_postproc_alloc(ctx, i); + if (ret < 0) { + hantro_postproc_free(ctx); + return ret; + } } + + return ret; +} + +dma_addr_t +hantro_postproc_get_dec_buf_addr(struct hantro_ctx *ctx, int index) +{ + struct hantro_aux_buf *priv =3D xa_load(&ctx->postproc.dec_refs_xa, index= ); + int ret; + + if (priv) + return priv->dma; + + /* buffer not already allocated, try getting a new one */ + ret =3D hantro_postproc_alloc(ctx, index); + if (ret < 0) + return 0; + + priv =3D xa_load(&ctx->postproc.dec_refs_xa, index); + if (priv) + return priv->dma; + return 0; } =20 diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/med= ia/platform/verisilicon/hantro_v4l2.c index 61cfaaf4e927..0f615c1001c0 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -894,20 +894,10 @@ static int hantro_start_streaming(struct vb2_queue *q= , unsigned int count) ret =3D ctx->codec_ops->init(ctx); if (ret) return ret; - } - - if (hantro_needs_postproc(ctx, ctx->vpu_dst_fmt)) { - ret =3D hantro_postproc_alloc(ctx); - if (ret) - goto err_codec_exit; + ret =3D hantro_postproc_init(ctx); } } return ret; - -err_codec_exit: - if (ctx->codec_ops->exit) - ctx->codec_ops->exit(ctx); - return ret; } =20 static void --=20 2.39.2 From nobody Thu Nov 14 06:07:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06AE3EB64DA for ; Thu, 22 Jun 2023 13:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbjFVNO1 (ORCPT ); Thu, 22 Jun 2023 09:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231601AbjFVNOC (ORCPT ); Thu, 22 Jun 2023 09:14:02 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C519D1BD3; Thu, 22 Jun 2023 06:14:01 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7d72:676c:e745:a6ef]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 4B4B8660712D; Thu, 22 Jun 2023 14:14:00 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439640; bh=ZiJZeCrdYyJk6ji66RurI+0QVQYXWWl0hCRxE21ZIiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U0zsmGVCsQ+HRf88BblNgvRpabk8rpioN4X5sKdE9Z0Qe9DGe9cNQE0k1E8fE9HCx i0/LkBviZzhZnivGLqThkTSmEp7ueCMhIPoeQw2Xq6Yu5+Y8TalLwt7mDSlGOsy1Hm Kmf7ugd6oCy8LNL0mI2psUJUEgddM4VbBrFdqzapOKCEcyZgNpeHVkaaPoOs0XZ9H/ Lh3Dp1q/ja1beetzo7WsEbILf+X0S3GQWpf7rMypG1wEyE61OoaiLdFNReduOSmHEv quEqtqd3ja49w1clhV8+nHtlQ+oFqbO+m6lnfhva6eIeI3rZxjNy1aN+BfIwQCR6AA diw36mypgVTyA== From: Benjamin Gaignard To: 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, hverkuil-cisco@xs4all.nl, 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, Benjamin Gaignard Subject: [PATCH v3 06/11] media: verisilicon: Store chroma and motion vectors offset Date: Thu, 22 Jun 2023 15:13:44 +0200 Message-Id: <20230622131349.144160-7-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230622131349.144160-1-benjamin.gaignard@collabora.com> References: <20230622131349.144160-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Store computed values of chroma and motion vectors offset because they depends on width and height values which change if the resolution change. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro.h | 2 ++ drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/pl= atform/verisilicon/hantro.h index bd0dca11b90a..16c7e9bafde3 100644 --- a/drivers/media/platform/verisilicon/hantro.h +++ b/drivers/media/platform/verisilicon/hantro.h @@ -320,6 +320,8 @@ struct hantro_vp9_decoded_buffer_info { /* Info needed when the decoded frame serves as a reference frame. */ unsigned short width; unsigned short height; + size_t chroma_offset; + size_t mv_offset; u32 bit_depth : 4; }; =20 diff --git a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c b/drive= rs/media/platform/verisilicon/hantro_g2_vp9_dec.c index 6fc4b555517f..6db1c32fce4d 100644 --- a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c +++ b/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c @@ -158,9 +158,11 @@ static void config_output(struct hantro_ctx *ctx, =20 chroma_addr =3D luma_addr + chroma_offset(ctx, dec_params); hantro_write_addr(ctx->dev, G2_OUT_CHROMA_ADDR, chroma_addr); + dst->vp9.chroma_offset =3D chroma_offset(ctx, dec_params); =20 mv_addr =3D luma_addr + mv_offset(ctx, dec_params); hantro_write_addr(ctx->dev, G2_OUT_MV_ADDR, mv_addr); + dst->vp9.mv_offset =3D mv_offset(ctx, dec_params); } =20 struct hantro_vp9_ref_reg { @@ -195,7 +197,7 @@ static void config_ref(struct hantro_ctx *ctx, luma_addr =3D hantro_get_dec_buf_addr(ctx, &buf->base.vb.vb2_buf); hantro_write_addr(ctx->dev, ref_reg->y_base, luma_addr); =20 - chroma_addr =3D luma_addr + chroma_offset(ctx, dec_params); + chroma_addr =3D luma_addr + buf->vp9.chroma_offset; hantro_write_addr(ctx->dev, ref_reg->c_base, chroma_addr); } =20 @@ -238,7 +240,7 @@ static void config_ref_registers(struct hantro_ctx *ctx, config_ref(ctx, dst, &ref_regs[2], dec_params, dec_params->alt_frame_ts); =20 mv_addr =3D hantro_get_dec_buf_addr(ctx, &mv_ref->base.vb.vb2_buf) + - mv_offset(ctx, dec_params); + mv_ref->vp9.mv_offset; hantro_write_addr(ctx->dev, G2_REF_MV_ADDR(0), mv_addr); =20 hantro_reg_write(ctx->dev, &vp9_last_sign_bias, --=20 2.39.2 From nobody Thu Nov 14 06:07:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D958EB64D8 for ; Thu, 22 Jun 2023 13:14:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbjFVNOT (ORCPT ); Thu, 22 Jun 2023 09:14:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231608AbjFVNOD (ORCPT ); Thu, 22 Jun 2023 09:14:03 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 540B51BF6; Thu, 22 Jun 2023 06:14:02 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7d72:676c:e745:a6ef]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id C3B7D6607131; Thu, 22 Jun 2023 14:14:00 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439641; bh=UmxaSxfAyduJDEDEY4mpYf+MJsD53OV/RCS4wvgVO+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LE4QqBKgWv+1EySXMkQVSaD1dNhI+GeD3LlmDyw8BUUqAzjeWKpLgE7nYFbDxEEv9 Ati1aQFtBHhVCABtN74rxVbZAa0MJSrZwVIgrgxRkDAIImGtdfaAWTqBawHTNAbMl/ HdshjmeOvUsBxHts3OqwHdUtzM8APjBR4H8Dcl06XSpdTrsLjVDi2bXO/6Q+Z2385t AAAr8kZFEeZazGpcyPfMqlpZCv2h3C9HeJ6EXw2PfsfsK9xapfSEcEgXl7Er0SU4wE Y/3OPZhHXGACkMUixRI+7UZiu5cfz2o/DlWmXPnVxS2yL6iB1y+ma9RO+Hn7zvmTu4 8A0REHtV4T39g== From: Benjamin Gaignard To: 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, hverkuil-cisco@xs4all.nl, 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, Benjamin Gaignard Subject: [PATCH v3 07/11] media: verisilicon: vp9: Use destination buffer height to compute chroma offset Date: Thu, 22 Jun 2023 15:13:45 +0200 Message-Id: <20230622131349.144160-8-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230622131349.144160-1-benjamin.gaignard@collabora.com> References: <20230622131349.144160-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Source and destination buffer height may not be the same because alignment constraint are different. Use destination height to compute chroma offset because we target this buffer as hardware output. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c b/drive= rs/media/platform/verisilicon/hantro_g2_vp9_dec.c index 6db1c32fce4d..1f3f5e7ce978 100644 --- a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c +++ b/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c @@ -93,9 +93,7 @@ static int start_prepare_run(struct hantro_ctx *ctx, cons= t struct v4l2_ctrl_vp9_ static size_t chroma_offset(const struct hantro_ctx *ctx, const struct v4l2_ctrl_vp9_frame *dec_params) { - int bytes_per_pixel =3D dec_params->bit_depth =3D=3D 8 ? 1 : 2; - - return ctx->src_fmt.width * ctx->src_fmt.height * bytes_per_pixel; + return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth / 8; } =20 static size_t mv_offset(const struct hantro_ctx *ctx, --=20 2.39.2 From nobody Thu Nov 14 06:07:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95C95EB64DA for ; Thu, 22 Jun 2023 13:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231715AbjFVNOf (ORCPT ); Thu, 22 Jun 2023 09:14:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231611AbjFVNOD (ORCPT ); Thu, 22 Jun 2023 09:14:03 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E29CF1BD2; Thu, 22 Jun 2023 06:14:02 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7d72:676c:e745:a6ef]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 465616607134; Thu, 22 Jun 2023 14:14:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439641; bh=L/PjipZuAgM8U3/G13tgH1tvV239+bgnDOvwg/NHT0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oie9OYCVzgy392asDkxBx6pxe2/ZE5DwJwj5wC+XHaa1K50YLVzx2KFrvUnDE4Fxb bolJAeXxnDGzshzKaVttYEvDKuWJMvWDs/tnXVj2YJDdRkm1YGLQL5AKKZlonUsHhl kqJ43rCFtmcWzXqIK7gNcRlJOFy6NaHRp/jM96egbEOykqF4U5IprC1Yzk7lY41CxP rJtWH/9odTvPjI7XFgv321jDmQ01jhmTZbtv1y6RSn4ZJRCQHTCgU0CJiFeBbSX69h NtaB6tRkK34wlQgPgbUmlhb3bh4dLhcA0RhJvtfjLTIrAZZYIU8uYVFn6YB+p0mNhs nBqsle6SK92Lw== From: Benjamin Gaignard To: 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, hverkuil-cisco@xs4all.nl, 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, Benjamin Gaignard Subject: [PATCH v3 08/11] media: verisilicon: postproc: Fix down scale test Date: Thu, 22 Jun 2023 15:13:46 +0200 Message-Id: <20230622131349.144160-9-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230622131349.144160-1-benjamin.gaignard@collabora.com> References: <20230622131349.144160-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Do not allow down scaling if the source buffer resolution is smaller than destination one. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro_postproc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/verisilicon/hantro_postproc.c b/drivers= /media/platform/verisilicon/hantro_postproc.c index a6b67d0cc66c..a4f2c5e8932c 100644 --- a/drivers/media/platform/verisilicon/hantro_postproc.c +++ b/drivers/media/platform/verisilicon/hantro_postproc.c @@ -103,7 +103,10 @@ static void hantro_postproc_g1_enable(struct hantro_ct= x *ctx) =20 static int down_scale_factor(struct hantro_ctx *ctx) { - if (ctx->src_fmt.width =3D=3D ctx->dst_fmt.width) + if (ctx->src_fmt.width <=3D ctx->dst_fmt.width) + return 0; + + if (ctx->src_fmt.height <=3D ctx->dst_fmt.height) return 0; =20 return DIV_ROUND_CLOSEST(ctx->src_fmt.width, ctx->dst_fmt.width); --=20 2.39.2 From nobody Thu Nov 14 06:07:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9287EEB64D8 for ; Thu, 22 Jun 2023 13:14:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbjFVNOj (ORCPT ); Thu, 22 Jun 2023 09:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231612AbjFVNOE (ORCPT ); Thu, 22 Jun 2023 09:14:04 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BF831BD3; Thu, 22 Jun 2023 06:14:03 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7d72:676c:e745:a6ef]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id BC419660713A; Thu, 22 Jun 2023 14:14:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439642; bh=X2W06J2G0RvZ6wT6r06tbLD+//oCk/Ju0PbDrogdZys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DGz1otnaX8UAHM3bF/fnObvKgQpots9OgKyHQlYMpVuhY7HFB9K4WXhjx/xh4Hjdo wKXNP5wNgwFSN56fHkbwgjBz61Nik8UswMz0VmMTAqA2qfjxyZ5RRs9KrSalNKVi/a svqywLE+/HOl4pNFwe+5y+GPUpyZp2J8ZE8bIXwMv36/tlbJbfrwIyo5FAlGa+vYC2 CUYsKgUWCIbKJ7DAn1dFeQqdd8rZsaMpjA7687bBQB9Gw8OjPpzkSSmNd7zkhmlS6e xhsVOzJJk8C4WZlBCEhy/OyVUgr6WV9ihhUvdnEJQJtokxd19iRvruoQSt5ihx41Is SrHjNjTFBA1mA== From: Benjamin Gaignard To: 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, hverkuil-cisco@xs4all.nl, 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, Benjamin Gaignard Subject: [PATCH v3 09/11] media: verisilicon: vp9: Allow to change resolution while streaming Date: Thu, 22 Jun 2023 15:13:47 +0200 Message-Id: <20230622131349.144160-10-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230622131349.144160-1-benjamin.gaignard@collabora.com> References: <20230622131349.144160-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove all checks that prohibit to set a new format while streaming. This allow to change dynamically the resolution if the pixel format remains the same. Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_v4l2.c | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/med= ia/platform/verisilicon/hantro_v4l2.c index 0f615c1001c0..cdddfb4179aa 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -480,25 +480,14 @@ static int hantro_set_fmt_out(struct hantro_ctx *ctx, return ret; =20 if (!ctx->is_encoder) { - struct vb2_queue *peer_vq; - /* * In order to support dynamic resolution change, * the decoder admits a resolution change, as long - * as the pixelformat remains. Can't be done if streaming. - */ - if (vb2_is_streaming(vq) || (vb2_is_busy(vq) && - pix_mp->pixelformat !=3D ctx->src_fmt.pixelformat)) - return -EBUSY; - /* - * Since format change on the OUTPUT queue will reset - * the CAPTURE queue, we can't allow doing so - * when the CAPTURE queue has buffers allocated. + * as the pixelformat remains. */ - peer_vq =3D v4l2_m2m_get_vq(ctx->fh.m2m_ctx, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); - if (vb2_is_busy(peer_vq)) + if (vb2_is_streaming(vq) && pix_mp->pixelformat !=3D ctx->src_fmt.pixelf= ormat) { return -EBUSY; + } } else { /* * The encoder doesn't admit a format change if @@ -541,15 +530,8 @@ static int hantro_set_fmt_out(struct hantro_ctx *ctx, static int hantro_set_fmt_cap(struct hantro_ctx *ctx, struct v4l2_pix_format_mplane *pix_mp) { - struct vb2_queue *vq; int ret; =20 - /* Change not allowed if queue is busy. */ - vq =3D v4l2_m2m_get_vq(ctx->fh.m2m_ctx, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); - if (vb2_is_busy(vq)) - return -EBUSY; - if (ctx->is_encoder) { struct vb2_queue *peer_vq; =20 --=20 2.39.2 From nobody Thu Nov 14 06:07:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0265EB64DB for ; Thu, 22 Jun 2023 13:15:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230119AbjFVNOp (ORCPT ); Thu, 22 Jun 2023 09:14:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231617AbjFVNOF (ORCPT ); Thu, 22 Jun 2023 09:14:05 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BADA71BD7; Thu, 22 Jun 2023 06:14:03 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7d72:676c:e745:a6ef]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 3F6D2660713B; Thu, 22 Jun 2023 14:14:02 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439642; bh=OL7fqdlzrkuvJs9l9Lix1rcNanP6zAUtVjeNt919ZCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R7cClQUQp9pSc3zMg+WY+COf7GacF8mfCHrm0scP6OpVwA7Riws6UuDofLtwJ/JbA qEJp8+ipGzbDYkvjcEvWQjkddpTbdAcJyx6X9fWYl1Sm3O45Mid3C5A1Z45OSVv6MU 67R4uIFxpETpADha5jNGaJyA7RWzbcQXO2DXeCMKMvEsE270wr+Pg7N+cg/FuYe4yd brsjXgBNFcK7G+rpzgHmX6Tk8n43izogs9uezWkLRYpM5cCa1ndI2MjztoKqXmt3s4 mKdexyRI70R2JkHjM6wo++CkAYxgQFzvR285o6OyeTZKG8PnBsuciIP02NG3617hCj mYS2XPpPMMMWg== From: Benjamin Gaignard To: 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, hverkuil-cisco@xs4all.nl, 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, Benjamin Gaignard Subject: [PATCH v3 10/11] media: v4l2: Add DELETE_BUF ioctl Date: Thu, 22 Jun 2023 15:13:48 +0200 Message-Id: <20230622131349.144160-11-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230622131349.144160-1-benjamin.gaignard@collabora.com> References: <20230622131349.144160-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" VIDIOC_DELETE_BUF ioctl allows to delete a buffer from a queue. Signed-off-by: Benjamin Gaignard --- .../userspace-api/media/v4l/user-func.rst | 1 + .../media/v4l/vidioc-delete-buf.rst | 51 +++++++++++++++++++ .../media/common/videobuf2/videobuf2-core.c | 33 ++++++++++++ .../media/common/videobuf2/videobuf2-v4l2.c | 6 +++ drivers/media/v4l2-core/v4l2-dev.c | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 10 ++++ include/media/v4l2-ioctl.h | 4 ++ include/media/videobuf2-core.h | 9 ++++ include/media/videobuf2-v4l2.h | 11 ++++ include/uapi/linux/videodev2.h | 2 + 10 files changed, 128 insertions(+) create mode 100644 Documentation/userspace-api/media/v4l/vidioc-delete-buf= .rst diff --git a/Documentation/userspace-api/media/v4l/user-func.rst b/Document= ation/userspace-api/media/v4l/user-func.rst index 15ff0bf7bbe6..8c74016e12fd 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-buf vidioc-dqevent vidioc-dv-timings-cap vidioc-encoder-cmd diff --git a/Documentation/userspace-api/media/v4l/vidioc-delete-buf.rst b/= Documentation/userspace-api/media/v4l/vidioc-delete-buf.rst new file mode 100644 index 000000000000..0e7ce58f91bc --- /dev/null +++ b/Documentation/userspace-api/media/v4l/vidioc-delete-buf.rst @@ -0,0 +1,51 @@ +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later +.. c:namespace:: V4L + +.. _VIDIOC_DELETE_BUF: + +************************ +ioctl VIDIOC_DELETE_BUF +************************ + +Name +=3D=3D=3D=3D + +VIDIOC_DELETE_BUF - Delete a buffer from a queue + +Synopsis +=3D=3D=3D=3D=3D=3D=3D=3D + +.. c:macro:: VIDIOC_DELETE_BUF + +``int ioctl(int fd, VIDIOC_DELETE_BUF, struct v4l2_buffer *argp)`` + +Arguments +=3D=3D=3D=3D=3D=3D=3D=3D=3D + +``fd`` + File descriptor returned by :c:func:`open()`. + +``argp`` + Pointer to struct :c:type:`v4l2_buffer`. + +Description +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Applications can optionally call the :ref:`VIDIOC_DELETE_BUF` ioctl to +delete a buffer from a queue. + +The struct :c:type:`v4l2_buffer` structure is specified in +:ref:`buffer`. + +Return Value +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +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 ` 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/medi= a/common/videobuf2/videobuf2-core.c index 899783f67580..aa546c972c3d 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -1637,6 +1637,39 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsign= ed int index, void *pb) } EXPORT_SYMBOL_GPL(vb2_core_prepare_buf); =20 +int vb2_core_delete_buf(struct vb2_queue *q, unsigned int index) +{ + struct vb2_buffer *vb; + + vb =3D vb2_get_buffer(q, index); + if (!vb) { + dprintk(q, 1, "invalid buffer index %d\n", index); + return -EINVAL; + } + + if (vb->state !=3D VB2_BUF_STATE_DEQUEUED) { + dprintk(q, 1, "can't delete non dequeued buffer index %d\n", index); + return -EINVAL; + } + + if (vb->planes[0].mem_priv) + call_void_vb_qop(vb, buf_cleanup, vb); + + /* Free MMAP buffers or release USERPTR buffers */ + if (q->memory =3D=3D VB2_MEMORY_MMAP) + __vb2_buf_mem_free(vb); + else if (q->memory =3D=3D VB2_MEMORY_DMABUF) + __vb2_buf_dmabuf_put(vb); + else + __vb2_buf_userptr_put(vb); + + vb2_queue_remove_buffer(q, vb); + kfree(vb); + + dprintk(q, 2, "buffer %d deleted\n", index); + return 0; +} + /* * vb2_start_streaming() - Attempt to start streaming. * @q: videobuf2 queue diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/medi= a/common/videobuf2/videobuf2-v4l2.c index 724135d41f7f..cea666c17b41 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -751,6 +751,12 @@ int vb2_prepare_buf(struct vb2_queue *q, struct media_= device *mdev, } EXPORT_SYMBOL_GPL(vb2_prepare_buf); =20 +int vb2_delete_buf(struct vb2_queue *q, struct v4l2_buffer *b) +{ + return vb2_core_delete_buf(q, b->index); +} +EXPORT_SYMBOL_GPL(vb2_delete_buf); + int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *creat= e) { unsigned requested_planes =3D 1; diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v= 4l2-dev.c index f81279492682..80ace2e1e932 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -720,6 +720,7 @@ static void determine_valid_ioctls(struct video_device = *vdev) SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf); SET_VALID_IOCTL(ops, VIDIOC_STREAMON, vidioc_streamon); SET_VALID_IOCTL(ops, VIDIOC_STREAMOFF, vidioc_streamoff); + SET_VALID_IOCTL(ops, VIDIOC_DELETE_BUF, vidioc_delete_buf); } =20 if (is_vid || is_vbi || is_meta) { diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core= /v4l2-ioctl.c index a858acea6547..1c737279d3ef 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -2156,6 +2156,15 @@ static int v4l_prepare_buf(const struct v4l2_ioctl_o= ps *ops, return ret ? ret : ops->vidioc_prepare_buf(file, fh, b); } =20 +static int v4l_delete_buf(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct v4l2_buffer *b =3D arg; + int ret =3D check_fmt(file, b->type); + + return ret ? ret : ops->vidioc_delete_buf(file, fh, b); +} + static int v4l_g_parm(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { @@ -2905,6 +2914,7 @@ static const struct v4l2_ioctl_info v4l2_ioctls[] =3D= { IOCTL_INFO(VIDIOC_ENUM_FREQ_BANDS, v4l_enum_freq_bands, v4l_print_freq_ba= nd, 0), IOCTL_INFO(VIDIOC_DBG_G_CHIP_INFO, v4l_dbg_g_chip_info, v4l_print_dbg_chi= p_info, INFO_FL_CLEAR(v4l2_dbg_chip_info, match)), IOCTL_INFO(VIDIOC_QUERY_EXT_CTRL, v4l_query_ext_ctrl, v4l_print_query_ext= _ctrl, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_query_ext_ctrl, id)), + IOCTL_INFO(VIDIOC_DELETE_BUF, v4l_delete_buf, v4l_print_buffer, INFO_FL_Q= UEUE), }; #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) =20 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index edb733f21604..2f232ed884c7 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h @@ -163,6 +163,8 @@ struct v4l2_fh; * :ref:`VIDIOC_CREATE_BUFS ` ioctl * @vidioc_prepare_buf: pointer to the function that implements * :ref:`VIDIOC_PREPARE_BUF ` ioctl + * @vidioc_delete_buf: pointer to the function that implements + * :ref:`VIDIOC_DELETE_BUF ` ioctl * @vidioc_overlay: pointer to the function that implements * :ref:`VIDIOC_OVERLAY ` ioctl * @vidioc_g_fbuf: pointer to the function that implements @@ -422,6 +424,8 @@ struct v4l2_ioctl_ops { struct v4l2_create_buffers *b); int (*vidioc_prepare_buf)(struct file *file, void *fh, struct v4l2_buffer *b); + int (*vidioc_delete_buf)(struct file *file, void *fh, + struct v4l2_buffer *b); =20 int (*vidioc_overlay)(struct file *file, void *fh, unsigned int i); int (*vidioc_g_fbuf)(struct file *file, void *fh, diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 080b783d608d..0f9e68f76b77 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -840,6 +840,15 @@ 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= ); =20 +/** + * vb2_core_delete_buf() - + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @index: id number of the buffer. + * + * Return: returns zero on success; an error code otherwise. + */ +int vb2_core_delete_buf(struct vb2_queue *q, unsigned int index); + /** * vb2_core_qbuf() - Queue a buffer from userspace * diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 88a7a565170e..3beeb4c735f0 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -114,6 +114,17 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_c= reate_buffers *create); */ int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev, struct v4l2_buffer *b); +/** + * vb2_delete_buf() - Delete the buffer from the queue + * + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @b: buffer structure passed from userspace to + * &v4l2_ioctl_ops->vidioc_delete_buf handler in driver + * + * The return values from this function are intended to be directly return= ed + * from &v4l2_ioctl_ops->vidioc_delete_buf handler in driver. + */ +int vb2_delete_buf(struct vb2_queue *q, struct v4l2_buffer *b); =20 /** * vb2_qbuf() - Queue a buffer from userspace diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index aee75eb9e686..31bba1915642 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -2702,6 +2702,8 @@ struct v4l2_create_buffers { #define VIDIOC_DBG_G_CHIP_INFO _IOWR('V', 102, struct v4l2_dbg_chip_info) =20 #define VIDIOC_QUERY_EXT_CTRL _IOWR('V', 103, struct v4l2_query_ext_ctrl) +#define VIDIOC_DELETE_BUF _IOWR('V', 104, struct v4l2_buffer) + =20 /* Reminder: when adding new ioctls please add support for them to drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */ --=20 2.39.2 From nobody Thu Nov 14 06:07:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 843ABEB64DB for ; Thu, 22 Jun 2023 13:15:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231211AbjFVNPI (ORCPT ); Thu, 22 Jun 2023 09:15:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231623AbjFVNOG (ORCPT ); Thu, 22 Jun 2023 09:14:06 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46D721BF6; Thu, 22 Jun 2023 06:14:04 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7d72:676c:e745:a6ef]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id BD701660713E; Thu, 22 Jun 2023 14:14:02 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439643; bh=w7TelsLJmHPPFBbH7cdd4Q4u9mfk8qz6m8m3ILNeG3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=drrv7EArNlrMc2bqooR2UXQWYueWvIBP+Y1UDX7ZsxJ63fm9MWRTLdvcy/nd3MtmR 1tAPfYMWNjrmPUNRS0XxCwqXho+WBGpGewAnYEE2Ie+xdCEP8PrQjPE1/As1XTSeyn xo3B32kzTLEBtIyn4PJwr+EjAOq7FA6fpFlwXN2Z3uefoRQqtw9FpEHPug6LThebK/ Phxk51rtR7zmF4yR5QN7vIcsJ7/u5EPHjYGDIFfcOkODSzlshf3WIBEh+wamPxDcUG cWTeOwNzSOsFR7WozNP+PQ3eLDCtl+RCP7lgpfh103fQjpIRJovqxw58Wv7OnDvRLI iyFgvrTal3KYg== From: Benjamin Gaignard To: 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, hverkuil-cisco@xs4all.nl, 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, Benjamin Gaignard Subject: [PATCH v3 11/11] media: v4l2: Add mem2mem helpers for DELETE_BUF ioctl Date: Thu, 22 Jun 2023 15:13:49 +0200 Message-Id: <20230622131349.144160-12-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230622131349.144160-1-benjamin.gaignard@collabora.com> References: <20230622131349.144160-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Create v4l2-mem2mem helpers for VIDIOC_DELETE_BUF ioctl. Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_v4l2.c | 1 + drivers/media/test-drivers/vim2m.c | 1 + drivers/media/v4l2-core/v4l2-mem2mem.c | 20 +++++++++++++++++++ include/media/v4l2-mem2mem.h | 12 +++++++++++ 4 files changed, 34 insertions(+) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/med= ia/platform/verisilicon/hantro_v4l2.c index cdddfb4179aa..bf418191278f 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -720,6 +720,7 @@ const struct v4l2_ioctl_ops hantro_ioctl_ops =3D { .vidioc_dqbuf =3D v4l2_m2m_ioctl_dqbuf, .vidioc_prepare_buf =3D v4l2_m2m_ioctl_prepare_buf, .vidioc_create_bufs =3D v4l2_m2m_ioctl_create_bufs, + .vidioc_delete_buf =3D v4l2_m2m_ioctl_delete_buf, .vidioc_expbuf =3D v4l2_m2m_ioctl_expbuf, =20 .vidioc_subscribe_event =3D v4l2_ctrl_subscribe_event, diff --git a/drivers/media/test-drivers/vim2m.c b/drivers/media/test-driver= s/vim2m.c index 3e3b424b4860..3014b8ee13d0 100644 --- a/drivers/media/test-drivers/vim2m.c +++ b/drivers/media/test-drivers/vim2m.c @@ -960,6 +960,7 @@ static const struct v4l2_ioctl_ops vim2m_ioctl_ops =3D { .vidioc_dqbuf =3D v4l2_m2m_ioctl_dqbuf, .vidioc_prepare_buf =3D v4l2_m2m_ioctl_prepare_buf, .vidioc_create_bufs =3D v4l2_m2m_ioctl_create_bufs, + .vidioc_delete_buf =3D v4l2_m2m_ioctl_delete_buf, .vidioc_expbuf =3D v4l2_m2m_ioctl_expbuf, =20 .vidioc_streamon =3D v4l2_m2m_ioctl_streamon, diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-co= re/v4l2-mem2mem.c index 0cc30397fbad..42f51ca25379 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -831,6 +831,17 @@ int v4l2_m2m_prepare_buf(struct file *file, struct v4l= 2_m2m_ctx *m2m_ctx, } EXPORT_SYMBOL_GPL(v4l2_m2m_prepare_buf); =20 +int v4l2_m2m_delete_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, + struct v4l2_buffer *buf) +{ + struct vb2_queue *vq; + + vq =3D v4l2_m2m_get_vq(m2m_ctx, buf->type); + + return vb2_delete_buf(vq, buf); +} +EXPORT_SYMBOL_GPL(v4l2_m2m_delete_buf); + int v4l2_m2m_create_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_create_buffers *create) { @@ -1377,6 +1388,15 @@ int v4l2_m2m_ioctl_create_bufs(struct file *file, vo= id *priv, } EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_create_bufs); =20 +int v4l2_m2m_ioctl_delete_buf(struct file *file, void *priv, + struct v4l2_buffer *buf) +{ + struct v4l2_fh *fh =3D file->private_data; + + return v4l2_m2m_delete_buf(file, fh->m2m_ctx, buf); +} +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_delete_buf); + int v4l2_m2m_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *buf) { diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h index bb9de6a899e0..d062a35c8246 100644 --- a/include/media/v4l2-mem2mem.h +++ b/include/media/v4l2-mem2mem.h @@ -381,6 +381,16 @@ int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_= ctx *m2m_ctx, int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_buffer *buf); =20 +/** + * v4l2_m2m_delete_buf() - delete buffer from the queue + * + * @file: pointer to struct &file + * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2= m_ctx + * @buf: pointer to struct &v4l2_buffer + */ +int v4l2_m2m_delete_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, + struct v4l2_buffer *buf); + /** * v4l2_m2m_create_bufs() - create a source or destination buffer, dependi= ng * on the type @@ -846,6 +856,8 @@ int v4l2_m2m_ioctl_reqbufs(struct file *file, void *pri= v, struct v4l2_requestbuffers *rb); int v4l2_m2m_ioctl_create_bufs(struct file *file, void *fh, struct v4l2_create_buffers *create); +int v4l2_m2m_ioctl_delete_buf(struct file *file, void *priv, + struct v4l2_buffer *buf); int v4l2_m2m_ioctl_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf); int v4l2_m2m_ioctl_expbuf(struct file *file, void *fh, --=20 2.39.2