Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp362723rdb; Tue, 16 Jan 2024 02:43:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYVB+a6MAp3uo0jys2fYL3Pf1sbixH/Qtii5dFoUZLMNF/knk/gMBjbta8NbaR3uFO1BMR X-Received: by 2002:a05:6e02:12ef:b0:360:a21e:21d4 with SMTP id l15-20020a056e0212ef00b00360a21e21d4mr8019751iln.102.1705401790983; Tue, 16 Jan 2024 02:43:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705401790; cv=none; d=google.com; s=arc-20160816; b=yI8dPd7vfvRn5bvY/U0Fm8r7+9bnJp2sunJMMS298A2OfnPgKqKcllljuy7vUcEfNs 3u7RWrtbzSbHAwyNNBtBLmGAaosdeUouQDOcdpe8mjHF7ZKlZ7xGYLlu0mcxogtOvBXF OHcGRgQ/MQxFFzbond+DWwfKpwDcCVJuThvuQxT+Ba7iwT6kHbDSGsmwFr1P0VASyii8 2ytjrwTWeJWifIkDE2KDr1zHve01Mj0eL1SnrDGUEhuijLfy+acitBuMcgoICbPaFqGc QPValVHJFHE15/bXs9A4sMmhrZEf56vjBTj6zhTZmKMSEFbgVBBe6/2AhBGWi1dEJkC8 Ws3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=EF0G43Qp3lqvOPaOO052iGCpzCLK29l/CvqYqNwQcG0=; fh=Js3B84zGWAQzAGS6o/5UKARGV9H8hn85cNrn3CFJA9U=; b=qzvkaG9XwDsdJIRS0+GVWfiL3LppHrgn6WloPAMu1WLulFtPMiE5Z8MZ8vTHMvo4m+ 4VXRa9c+m/Y7h1NdFsz2gx3vqxfrNoeQgS/4Sv96K0Y/ZsJs9KNS6pbrsOULpAXiXtka 46yZ0vsnqXK9RmMEUEjRpxmqVuUVtcKh0RDrzayJ0HnTLiI5MJ+E18TSLLIiYOtriVqX P8nbnuyc1wPSTfvlmMXS7uoemCgf3o8ZniA0J7ShHL7bBBx2GREVqmkjk4K6muXb+cCY yEzBUnlAUpUPz99iZmC3ghWBmkhhpBwSrLUiJaeDmKxK/g/bfPI0LFz+cDL1NLwh0ihu QiAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=R0koWecI; spf=pass (google.com: domain of linux-kernel+bounces-27260-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27260-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i4-20020a639d04000000b00589fcc39ef1si10936293pgd.365.2024.01.16.02.43.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 02:43:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27260-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=R0koWecI; spf=pass (google.com: domain of linux-kernel+bounces-27260-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27260-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A5318B226BA for ; Tue, 16 Jan 2024 10:43:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2E4013AF1; Tue, 16 Jan 2024 10:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="R0koWecI" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DADB134DA; Tue, 16 Jan 2024 10:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1705401777; bh=QheYevpPKWLtwlqs9yJuw0+el/TYi4lzg9WtACT2oa8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=R0koWecIS+76AQMz2BNKVgqJsSFj7UiiAkg4hGSMbxc3bxLcahgGOP/b61Fwim6/H 8+UHCB1pGbqQ6gBO2hNn4LrDiMKyo09Tea1LjI3A8By+SmZgfEs076BEUXGAUVJy4m vOpEebvFnrkzqVQ0VDjPq1SLR6M5gm0HIp696729ajm7ZdztZOEPSsWj+vJm1uhNHl ZhxhiglvdpDJJ4ehGfwX+mEyRt1jH4qobhBClIWNKjGV1IOga8NpTIdRReNXqAOJGi uLi5LNf2tBBD76jvnE9MI7HVbEK9VfE1Y0AxAj3lK2LDR3ChxSVJBSuePHiuAtDOBx 4oAW2naBxPK6A== Received: from [100.93.89.217] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 4CF9437811F1; Tue, 16 Jan 2024 10:42:57 +0000 (UTC) Message-ID: <60c942d8-e0bd-4609-8fc4-1e80102ac051@collabora.com> Date: Tue, 16 Jan 2024 11:42:56 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v16 7/8] media: v4l2: Add mem2mem helpers for DELETE_BUFS ioctl Content-Language: en-US To: Hans Verkuil , mchehab@kernel.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, kernel@collabora.com References: <20231215090813.15610-1-benjamin.gaignard@collabora.com> <20231215090813.15610-8-benjamin.gaignard@collabora.com> <6b0e4c6b-493c-4916-ab3c-deeeb725fdec@xs4all.nl> From: Benjamin Gaignard In-Reply-To: <6b0e4c6b-493c-4916-ab3c-deeeb725fdec@xs4all.nl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 15/01/2024 à 17:50, Hans Verkuil a écrit : > On 15/12/2023 10:08, Benjamin Gaignard wrote: >> Create v4l2-mem2mem helpers for VIDIOC_DELETE_BUFS ioctl. >> >> Signed-off-by: Benjamin Gaignard >> --- >> .../media/platform/verisilicon/hantro_drv.c | 1 + >> .../media/platform/verisilicon/hantro_v4l2.c | 1 + >> drivers/media/test-drivers/vim2m.c | 2 ++ > The driver changes should be done in a separate patch. > >> drivers/media/v4l2-core/v4l2-mem2mem.c | 20 +++++++++++++++++++ >> include/media/v4l2-mem2mem.h | 12 +++++++++++ >> 5 files changed, 36 insertions(+) >> >> diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c >> index db3df6cc4513..f6b0a676a740 100644 >> --- a/drivers/media/platform/verisilicon/hantro_drv.c >> +++ b/drivers/media/platform/verisilicon/hantro_drv.c >> @@ -248,6 +248,7 @@ queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq) >> dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; >> dst_vq->lock = &ctx->dev->vpu_mutex; >> dst_vq->dev = ctx->dev->v4l2_dev.dev; >> + src_vq->supports_delete_bufs = true; > Isn't this something that can be supported for both queues? For me it isn't useful to support it on the both queues because only capture queue will store unused buffers after a dynamic resolution change. Output queue buffers are smaller and always recycled even after a dynamic resolution change. > >> >> return vb2_queue_init(dst_vq); >> } >> diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c >> index 941fa23c211a..34eab90e8a42 100644 >> --- a/drivers/media/platform/verisilicon/hantro_v4l2.c >> +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c >> @@ -756,6 +756,7 @@ const struct v4l2_ioctl_ops hantro_ioctl_ops = { >> .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, >> .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, >> .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, >> + .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs, >> .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, >> >> .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, >> diff --git a/drivers/media/test-drivers/vim2m.c b/drivers/media/test-drivers/vim2m.c >> index 3e3b424b4860..17213ce42059 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 = { >> .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, >> .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, >> .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, >> + .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs, >> .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, >> >> .vidioc_streamon = v4l2_m2m_ioctl_streamon, >> @@ -1133,6 +1134,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, >> dst_vq->mem_ops = &vb2_vmalloc_memops; >> dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; >> dst_vq->lock = &ctx->vb_mutex; >> + dst_vq->supports_delete_bufs = true; > Same question. I want to test something similar to what the real use case does. > >> >> return vb2_queue_init(dst_vq); >> } >> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c >> index 9e983176542b..dbc4711fc556 100644 >> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c >> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c >> @@ -834,6 +834,17 @@ int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, >> } >> EXPORT_SYMBOL_GPL(v4l2_m2m_prepare_buf); >> >> +int v4l2_m2m_delete_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, >> + struct v4l2_delete_buffers *d) >> +{ >> + struct vb2_queue *vq; >> + >> + vq = v4l2_m2m_get_vq(m2m_ctx, d->type); > These 3 lines can be combined into one. > >> + >> + return vb2_delete_bufs(vq, d); >> +} >> +EXPORT_SYMBOL_GPL(v4l2_m2m_delete_bufs); > I'm not sure we need to export this. Drivers should really just use the > v4l2_m2m_ioctl_ variant below. ok regards, Benjamin > >> + >> int v4l2_m2m_create_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, >> struct v4l2_create_buffers *create) >> { >> @@ -1380,6 +1391,15 @@ int v4l2_m2m_ioctl_create_bufs(struct file *file, void *priv, >> } >> EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_create_bufs); >> >> +int v4l2_m2m_ioctl_delete_bufs(struct file *file, void *priv, >> + struct v4l2_delete_buffers *d) >> +{ >> + struct v4l2_fh *fh = file->private_data; >> + >> + return v4l2_m2m_delete_bufs(file, fh->m2m_ctx, d); >> +} >> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_delete_bufs); >> + >> 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 7f1af1f7f912..5314952ad3d5 100644 >> --- a/include/media/v4l2-mem2mem.h >> +++ b/include/media/v4l2-mem2mem.h >> @@ -388,6 +388,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); >> >> +/** >> + * v4l2_m2m_delete_bufs() - delete buffers from the queue >> + * >> + * @file: pointer to struct &file >> + * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx >> + * @d: pointer to struct &v4l2_delete_buffers >> + */ >> +int v4l2_m2m_delete_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, >> + struct v4l2_delete_buffers *d); >> + >> /** >> * v4l2_m2m_create_bufs() - create a source or destination buffer, depending >> * on the type >> @@ -867,6 +877,8 @@ int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv, >> 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_bufs(struct file *file, void *priv, >> + struct v4l2_delete_buffers *d); >> int v4l2_m2m_ioctl_querybuf(struct file *file, void *fh, >> struct v4l2_buffer *buf); >> int v4l2_m2m_ioctl_expbuf(struct file *file, void *fh, > Regards, > > Hans >