Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp235333rdh; Wed, 7 Feb 2024 03:20:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV2Ozzk+ncd+Fz3/C2BC4Bair7M5xzYMvvny90Sf+urSOBixYBkKQzziIJ4n0bZWkqnR/XNsgikiwc5brasHaPhFgG6oDa4Vv18xwnsZg== X-Google-Smtp-Source: AGHT+IGXxJZVfDtQEz5rNEfoNJaXOSHshYVMubCcH598dTDiwTYh/qS2xb3mdsSMuqRkEk/xe6DI X-Received: by 2002:a05:6a20:2d2b:b0:19e:3b15:2176 with SMTP id g43-20020a056a202d2b00b0019e3b152176mr5888091pzl.38.1707304836614; Wed, 07 Feb 2024 03:20:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707304836; cv=pass; d=google.com; s=arc-20160816; b=ke6tYImV6+gGptZGJwNuB6oasfYExtWeJA2SrbQ++IKiPnNJVNSFhUINa3ftAjkW4S ditK7XVke5gKKsxDUC0DX5gLeu3XbD2LcMYwQkH2oiZjV8+9z82CJzwk2OTOTwwdJZ1j CwIShO0LvrZrp3l2u9pJcZLDCroFx1uDt4rgyBk+pbew61oV5YGksaQrZJH8I9dvXsnW 4Kj1kN2Yyhl3Y+elYzLpxGN/pTuo1apm8C3yS3eMKszoJl9l9ARmn6nZsjG73jpc/D7m wZxWt0B1/d5RH+7Di1hxZDo3SbwsoGJRcusikxOk3g8iGsc0sS5i2b5OGpKaY1sp3tWX zLKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=LD+WFRg4w4vc/AIqM6u6A/g8urDbkMQ7/mqN3V2K3ts=; fh=uwfs6jRREhwEzOzRFLLIZZZsGnG9IrssrSg+LjjqLEg=; b=V7RgKzzDyOlZSgiI6r8ylaQrcQwcopQQzu11HN0NKca/ufY3ESRnMFSJsFM71oLUfM cj388atGv++5yIebjKmhSKDoYhylYYXtopY75CsCQtOqejqGVSYIztIw2s2gURmbbe0g QzX2IT39O/+nuQZpYpgOacCaXGRywxNOBdZ6mhqZjAXAGHyVRQpzutqCH/6jzzTqjww1 KBPCAayHfg5FdYW5h0WRjRngozOPX3IGnUCqx3lqT7V/qbn8yAaAllvCnHOFO6tO2RrY vZPZsWcaYklugPfBW8N91c6yGOxh/1LWvUq20pf+9pcr3ZawjBdohBTRL+VbYcKhbIn7 yaiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-56381-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56381-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl X-Forwarded-Encrypted: i=2; AJvYcCWVVny06aKkOQVKJC9y87EU2w5DbOmP/lG6xq1uVI+71gsY2PcuMel+VJ33XfzaasFWPc7ma0opdT/ksj+CitjgpMQNY/kh3cOugiwEqQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j13-20020a17090a318d00b00295e0f76b7csi1302115pjb.172.2024.02.07.03.20.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 03:20:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56381-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-56381-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56381-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 337F22832F7 for ; Wed, 7 Feb 2024 11:20:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4072E1AACC; Wed, 7 Feb 2024 11:20:27 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8EE7817BCF; Wed, 7 Feb 2024 11:20:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707304826; cv=none; b=kwvlc4L0wQ0DERPig12oqMIJAKVAXS49eT2i38DuY4gsKLsyHf5tMI8s+dFismsGPqccmtSJKHll7Xrcevl7sc2xf5c4MsWLg36WnNHiHiyeMi9O4hOnJcnQi6okyz5lhB00+l+cUY7pAyW5bWH5FC06QZr7JACj+gXz8+ucmsw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707304826; c=relaxed/simple; bh=pYoltNanezXfhcD3sGwB0OIFlerz922KaxA/q3aT1Wc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=k2HrjPG86iUhY8iC0pckVwdtGCETpGmtiWxBKAh91zUp3Z8WusO3lWSU60b8wZTrQEoSyYyDc7HqRS5YWEUMWKa4iYm2QMqNvNSXzZaqpZ9iCjnBaBl1sacBxoHVIoG7TWbr8ztGns07krobl7M2rLaHxvzp1httP4RnINK/PQc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFF14C433C7; Wed, 7 Feb 2024 11:20:24 +0000 (UTC) Message-ID: Date: Wed, 7 Feb 2024 12:20:22 +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 v19 0/9] Add DELETE_BUF ioctl Content-Language: en-US, nl To: Benjamin Gaignard , mchehab@kernel.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, kernel@collabora.com References: <20240206080219.11951-1-benjamin.gaignard@collabora.com> <67823e2e-9d60-4c08-bdd1-c974aaf96a93@xs4all.nl> From: Hans Verkuil Autocrypt: addr=hverkuil@xs4all.nl; keydata= xsFNBFQ84W0BEAC7EF1iL4s3tY8cRTVkJT/297h0Hz0ypA+ByVM4CdU9sN6ua/YoFlr9k0K4 BFUlg7JzJoUuRbKxkYb8mmqOe722j7N3HO8+ofnio5cAP5W0WwDpM0kM84BeHU0aPSTsWiGR yw55SOK2JBSq7hueotWLfJLobMWhQii0Zd83hGT9SIt9uHaHjgwmtTH7MSTIiaY6N14nw2Ud C6Uykc1va0Wqqc2ov5ihgk/2k2SKa02ookQI3e79laOrbZl5BOXNKR9LguuOZdX4XYR3Zi6/ BsJ7pVCK9xkiVf8svlEl94IHb+sa1KrlgGv3fn5xgzDw8Z222TfFceDL/2EzUyTdWc4GaPMC E/c1B4UOle6ZHg02+I8tZicjzj5+yffv1lB5A1btG+AmoZrgf0X2O1B96fqgHx8w9PIpVERN YsmkfxvhfP3MO3oHh8UY1OLKdlKamMneCLk2up1Zlli347KMjHAVjBAiy8qOguKF9k7HOjif JCLYTkggrRiEiE1xg4tblBNj8WGyKH+u/hwwwBqCd/Px2HvhAsJQ7DwuuB3vBAp845BJYUU3 06kRihFqbO0vEt4QmcQD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8xkad KEiQTexRbM1sc/I8ACpla3N26SfQwrfg6V7TIoweP0RwDrcf5PVvwSWsRQp2LxFCkwnCXOra gYmkrmv0duG1FStpY+IIQn1TOkuXrciTVfZY1cZD0aVxwlxXBnUNZZNslldvXFtndxR0SFat sflovhDxKyhFwXOP0Rv8H378/+14TaykknRBIKEc0+lcr+EMOSUR5eg4aURb8Gc3Uc7fgQ6q UssTXzHPyj1hAyDpfu8DzAwlh4kKFTodxSsKAjI45SLjadSc94/5Gy8645Y1KgBzBPTH7Q== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 07/02/2024 12:15, Benjamin Gaignard wrote: > > Le 07/02/2024 à 10:12, Hans Verkuil a écrit : >> Hi Benjamin, >> >> On 06/02/2024 09:58, Hans Verkuil wrote: >>> On 06/02/2024 09:02, Benjamin Gaignard wrote: >>>> Unlike when resolution change on keyframes, dynamic resolution change >>>> on inter frames doesn't allow to do a stream off/on sequence because >>>> it is need to keep all previous references alive to decode inter frames. >>>> This constraint have two main problems: >>>> - more memory consumption. >>>> - more buffers in use. >>>> To solve these issue this series introduce DELETE_BUFS ioctl and remove >>>> the 32 buffers limit per queue. >>> This v19 looks good. There are three outstanding issues that I need to take a >>> look at: >>> >>> 1) Can we still signal support for DELETE_BUFS in the V4L2_BUF_CAP_ caps? >>>     It would be nice to have, but I'm not sure if and how that can be done. >> So, I came up with the following patch to add back the V4L2_BUF_CAP_SUPPORTS_DELETE_BUFS >> capability. If the DELETE_BUFS ioctl is valid, then it sets this capability >> before calling vidioc_reqbufs or vidioc_create_bufs. So right now it will set >> this for any queue. If we ever want to disable this for a specific queue, then >> either the driver has to override these two ops and clear the flag, or a new >> vb2_queue flag (e.g. disable_delete_bufs) is added and vb2_set_flags_and_caps() >> will clear that capability based on that flag. >> >> In any case, for now just set it for both queues by default. >> >> If you agree that this is a good way to proceed, then can you incorporate this >> into a v20? You can add the documentation for this cap from the v17 version. > > Do you want it to be a separate patch or included in the patch introducing DELETE_BUFS ioctl ? Up to you, whatever makes the most sense. Regards, Hans > >> >> Regards, >> >>     Hans >> >> Signed-off-by: Hans Verkuil >> --- >> diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c >> index 8e437104f9c1..64f2d662d068 100644 >> --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c >> +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c >> @@ -685,7 +685,7 @@ static void vb2_set_flags_and_caps(struct vb2_queue *q, u32 memory, >>           *flags &= V4L2_MEMORY_FLAG_NON_COHERENT; >>       } >> >> -    *caps = V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS; >> +    *caps |= V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS; >>       if (q->io_modes & VB2_MMAP) >>           *caps |= V4L2_BUF_CAP_SUPPORTS_MMAP; >>       if (q->io_modes & VB2_USERPTR) >> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c >> index a172d33edd19..45bc705e171e 100644 >> --- a/drivers/media/v4l2-core/v4l2-ioctl.c >> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c >> @@ -2100,6 +2100,7 @@ static int v4l_overlay(const struct v4l2_ioctl_ops *ops, >>   static int v4l_reqbufs(const struct v4l2_ioctl_ops *ops, >>                   struct file *file, void *fh, void *arg) >>   { >> +    struct video_device *vfd = video_devdata(file); >>       struct v4l2_requestbuffers *p = arg; >>       int ret = check_fmt(file, p->type); >> >> @@ -2108,6 +2109,9 @@ static int v4l_reqbufs(const struct v4l2_ioctl_ops *ops, >> >>       memset_after(p, 0, flags); >> >> +    if (is_valid_ioctl(vfd, VIDIOC_DELETE_BUFS)) >> +        p->capabilities = V4L2_BUF_CAP_SUPPORTS_DELETE_BUFS; >> + >>       return ops->vidioc_reqbufs(file, fh, p); >>   } >> >> @@ -2141,6 +2145,7 @@ static int v4l_dqbuf(const struct v4l2_ioctl_ops *ops, >>   static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops, >>                   struct file *file, void *fh, void *arg) >>   { >> +    struct video_device *vfd = video_devdata(file); >>       struct v4l2_create_buffers *create = arg; >>       int ret = check_fmt(file, create->format.type); >> >> @@ -2151,6 +2156,9 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops, >> >>       v4l_sanitize_format(&create->format); >> >> +    if (is_valid_ioctl(vfd, VIDIOC_DELETE_BUFS)) >> +        create->capabilities = V4L2_BUF_CAP_SUPPORTS_DELETE_BUFS; >> + >>       ret = ops->vidioc_create_bufs(file, fh, create); >> >>       if (create->format.type == V4L2_BUF_TYPE_VIDEO_CAPTURE || >> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h >> index 03443833aaaa..da307f46f903 100644 >> --- a/include/uapi/linux/videodev2.h >> +++ b/include/uapi/linux/videodev2.h >> @@ -1036,6 +1036,7 @@ struct v4l2_requestbuffers { >>   #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF    (1 << 5) >>   #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS        (1 << 6) >>   #define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS        (1 << 7) >> +#define V4L2_BUF_CAP_SUPPORTS_DELETE_BUFS        (1 << 8) >> >>   /** >>    * struct v4l2_plane - plane info for multi-planar buffers >> >> >>