Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp277006lqh; Fri, 31 May 2024 00:28:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBCHwBIK8cuRs+7WDFln+w3K9sb/RFfQUVWRvPMSgaVBgp4uLikq0/WpkC9rcN7Zi7+uSDF/0ZizLjvqh+CgJRo8HwkyO50rL68bSqPg== X-Google-Smtp-Source: AGHT+IGuAEotCHSN3l8VpjQ/fBxDnuMLg/lhwd9+6ozWNY/pXpNSnNRz9P2qP/fRPWituLKUiGJ6 X-Received: by 2002:a17:906:7fc6:b0:a59:c62c:344d with SMTP id a640c23a62f3a-a65f093f4c7mr353692366b.9.1717140520014; Fri, 31 May 2024 00:28:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717140520; cv=pass; d=google.com; s=arc-20160816; b=PYETltRbB4BDJfMhf5LXtkAUxVcZVffkB5AaNmOJesF4pOdCz/MFOs2nc7T4ZixIoZ Ps74D+AbBCgkuLTvQ9FQjwlgizMU9KS460kxHIOto+RM08en3emT5S6mFfL3Ew2/dC/C kIzxCmWVer8RfAkhgtA0tV6wO+UpNbbIBYty6TBdJcWhRUQfbbyWmIHh12foii1xnix8 HecrA3RRfWS+ZIBwp2+taDErIyUywa3QKRtbYtg68K2VKm8NQ39GYLZee2RVrKn3CGIm 3stzhTbXx02tI/yjKuH9qU+y40Op6NaTFuJUj1EJrYGEQbxUPac6siU4kioVRjCgz43B T4Yw== 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 :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=j7eTOwrDNWEqIS3/4l15BMHAlStWxsPhvbdR5IrvUnE=; fh=EvlC+Q9YOMHYE1lNgf0GezbHMI7y5v3P+6ULQ2XjDgQ=; b=H5nPgqAJ8ezWh9zRW4MZD3BQoK35YDT+H9zLyMFQX3KYexyB9uP0G1a0w9fiLbFlRR ETv2jFeOZEFSLK0Pml815dK3iY9z3OXWd9P+8vt7xVAtkeeqqUZw+mydQ6S4EujS+0ah Qe1iX2KnUQ0bqBxOzeqwRmaQcNCrsG1VDlM5gnm7+aqJW5PnBopumVHiNqdJ1T9lVz0E qvOqC/3Yu49OWbfDRglXUQMVIux5+saSY9FU4/q+BhyFV6fLnwMMACm+zGED9w8WnR2L VwlByBzV+WYivgVsyJnMWu51QU6yZOHFIOkMmhmxEmGZXs17IjgW3ezisV/JUCHBUxsC AY0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-196405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196405-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a67ea38eb9fsi65829866b.297.2024.05.31.00.28.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 00:28:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-196405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196405-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 924121F23859 for ; Fri, 31 May 2024 07:28:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF4CC81725; Fri, 31 May 2024 07:28:29 +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 1F23A2B9AB; Fri, 31 May 2024 07:28:28 +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=1717140509; cv=none; b=awE7y0Uyo1mLPJOXO76UcF6fh59TVj/KBTjKj9ybUTFPkuhHO60lN5xmT4jBrP8nzxKmkackvonAoH/Amnucz6p3LND+JCQ32db0JXDztMbv2mzZt4AG2jppKUwYlcFcAjclIF72liLoN10XNxItxLpSAUSkXJYt4sYXJ3BghiI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717140509; c=relaxed/simple; bh=EI4hkwsMyjIOrKijWoxSrNOs2BHfED4YcSoEJWEI2Ps=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PNmx3Yt4CJCAorkz/uQi+Hd68Z+i7KyvUPa5nJ+ns4AO0Rh09jW7XNceGbsVb2Z+fEOGIQeo5ka8hW9j7puWZqSjszVpf4JPHa1fk+OfrO+clIBourIG7cYCjrLYNHgxxa+wM5Z3sM2YkqAfq51l0uZOoXnrqclu2Hf27o9IImE= 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 85AB8C116B1; Fri, 31 May 2024 07:28:27 +0000 (UTC) Message-ID: Date: Fri, 31 May 2024 09:28:25 +0200 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 v2] media: uapi: v4l: Change V4L2_TYPE_IS_CAPTURE condition To: Nas Chung , "mchehab@kernel.org" , "linux-media@vger.kernel.org" , "sebastian.fricke@collabora.com" , "m.tretter@pengutronix.de" Cc: "linux-kernel@vger.kernel.org" References: <20240528020425.4994-1-nas.chung@chipsnmedia.com> Content-Language: en-US, 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 06kRihFqbO0vEt4QmcQDcbWINeZ2zX5TK7QQ91ldHdqJn6MhXulPKcM8tCkdD8YNXXKyKqNl UVqXnarz8m2JCbHgjEkUlAJCNd6m3pfESLZwSWsLYL49R5yxIwAR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TVfZY1cZD0aVxwlxXBnUNZZNslldvXFtndxR0SFat sflovhDxKyhFwXOP0Rv8H378/+14TaykknRBIKEc0+lcr+EMOSUR5eg4aURb8Gc3Uc7fgQ6q UssTXzHPyj1hAyDpfu8DzAwlh4kKFTodxSsKAjI45SLjadSc94/5Gy8645Y1KgBzBPTH7Q== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 31/05/2024 09:03, Nas Chung wrote: > Hi, Hans. > >> -----Original Message----- >> From: Hans Verkuil >> Sent: Thursday, May 30, 2024 7:32 PM >> To: Nas Chung ; mchehab@kernel.org; linux- >> media@vger.kernel.org; sebastian.fricke@collabora.com; >> m.tretter@pengutronix.de >> Cc: linux-kernel@vger.kernel.org >> Subject: Re: [PATCH v2] media: uapi: v4l: Change V4L2_TYPE_IS_CAPTURE >> condition >> >> On 28/05/2024 04:04, Nas Chung wrote: >>> Explicitly compare a buffer type only with valid buffer types, >>> to avoid matching the buffer type outside of valid buffer >>> type set. >>> >>> Signed-off-by: Nas Chung >>> --- >>> include/uapi/linux/videodev2.h | 7 ++++++- >>> 1 file changed, 6 insertions(+), 1 deletion(-) >>> >>> diff --git a/include/uapi/linux/videodev2.h >> b/include/uapi/linux/videodev2.h >>> index fe6b67e83751..fa2b7086e480 100644 >>> --- a/include/uapi/linux/videodev2.h >>> +++ b/include/uapi/linux/videodev2.h >>> @@ -157,6 +157,10 @@ enum v4l2_buf_type { >>> V4L2_BUF_TYPE_PRIVATE = 0x80, >>> }; >>> >>> +#define V4L2_TYPE_IS_VALID(type) \ >>> + ((type) >= V4L2_BUF_TYPE_VIDEO_CAPTURE \ >>> + && (type) <= V4L2_BUF_TYPE_META_OUTPUT) >>> + >>> #define V4L2_TYPE_IS_MULTIPLANAR(type) \ >>> ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \ >>> || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) >>> @@ -171,7 +175,8 @@ enum v4l2_buf_type { >>> || (type) == V4L2_BUF_TYPE_SDR_OUTPUT \ >>> || (type) == V4L2_BUF_TYPE_META_OUTPUT) >>> >>> -#define V4L2_TYPE_IS_CAPTURE(type) (!V4L2_TYPE_IS_OUTPUT(type)) >>> +#define V4L2_TYPE_IS_CAPTURE(type) \ >>> + (V4L2_TYPE_IS_VALID(type) && !V4L2_TYPE_IS_OUTPUT(type)) >>> >>> enum v4l2_tuner_type { >>> V4L2_TUNER_RADIO = 1, >> >> This patch introduced this warning: >> >> In function 'find_format_by_index', >> inlined from 'vdec_enum_fmt' at >> drivers/media/platform/qcom/venus/vdec.c:452:8: >> drivers/media/platform/qcom/venus/vdec.c:172:32: warning: 'valid' may be >> used uninitialized [-Wmaybe-uninitialized] >> 172 | if (k == index && valid) >> | ~~~~~~~~~~~^~~~~~~~ >> drivers/media/platform/qcom/venus/vdec.c: In function 'vdec_enum_fmt': >> drivers/media/platform/qcom/venus/vdec.c:157:22: note: 'valid' was >> declared here >> 157 | bool valid; >> | ^~~~~ >> >> This driver does this: >> >> bool valid; >> >> if (V4L2_TYPE_IS_OUTPUT(type)) { >> valid = venus_helper_check_codec(inst, fmt[i].pixfmt); >> } else if (V4L2_TYPE_IS_CAPTURE(type)) { >> valid = venus_helper_check_format(inst, fmt[i].pixfmt); >> >> With your patch both V4L2_TYPE_IS_OUTPUT(type) and >> V4L2_TYPE_IS_CAPTURE(type) >> can return false, something that wasn't possible without this patch. >> >> In this driver the fix would just be to drop the second 'if' altogether, >> so just >> '} else {'. >> >> Since these defines are part of the public API, this change introduces a >> subtle >> behavior difference that can affect applications. > > Thank you for a detailed description. > >> >> That said, I do consider this an improvement. >> >> I would like some changes, though: >> >> 1) Just after "V4L2_BUF_TYPE_META_OUTPUT = 14," in enum >> v4l2_buf_type, >> add a comment saying that V4L2_TYPE_IS_VALID and (for output types) >> V4L2_TYPE_IS_OUTPUT must be updated if a new type is added. It's all >> too easy to forget that otherwise. > >> 2) Add a patch fixing the venus/vdec.c code. > > 1), 2) I will address both in v3. > >> 3) Something else I noticed, but I think this change should be in a >> separate patch: >> V4L2_TYPE_IS_OUTPUT() returns true for V4L2_BUF_TYPE_VIDEO_OVERLAY, but >> that >> definitely belongs to CAPTURE. Nobody really uses that type anymore, >> but still, >> it should be fixed. > > 3) Would you prefer this modification to be included as a separate patch > in the v3 of this patch series, or should it be submitted as a new > standalone patch ? Separate patch in this series, please. Regards, Hans > > Thanks. > Nas. > >> >> Regards, >> >> Hans >