[{"id":30887,"web_url":"https://patchwork.libcamera.org/comment/30887/","msgid":"<20240822154652.GA26081@pendragon.ideasonboard.com>","date":"2024-08-22T15:46:52","subject":"Re: [PATCH v2 0/7] media: v4l2: Improve media link validation","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"This patch series was sent to libcamera-devel instead of linux-media.\nI've now fixed that mistake, sorry the noise. Please reply to the series\nsent to the right mailing list.\n\nOn Thu, Aug 22, 2024 at 06:35:20PM +0300, Laurent Pinchart wrote:\n> Hello,\n> \n> This patch series improves the link validation helpers to make it easier\n> for drivers to validate all links in a pipeline.\n> \n> The vast majority of drivers use the v4l2_subdev_link_validate()\n> function as their .link_validate() handler for subdevs. This correctly\n> validates subdev-to-subdev links. For links between subdevs and video\n> capture devices, a few drivers implement the .link_validate() operation\n> of their video devices, while others implement manual validation in\n> their .streamon() handler, or don't implement validation at all. Links\n> between video output devices are in an even worse state, as the link\n> validation logic at pipeline start time does not call the\n> .link_validate() operation on the source side of a link, leaving manual\n> validation in .streamon() the only option. Adding insult to injury,\n> v4l2_subdev_link_validate() prints a warning when the link's source is\n> not a subdev, which forces drivers to implement a manual subdev link\n> validation handler for subdevs connected to output video nodes.\n> \n> It turns out that v4l2_subdev_link_validate() is even used in the\n> .link_validate() implementation of video devices by two drivers. This is\n> clearly wrong, and is addressed by patches 1/7 to 3/7. Note that patch\n> 3/7 should ideally implement real validation of the link between the\n> subdev and video capture device, but that requires understanding of the\n> driver's logic as well as testing, so I have left it out as an exercise\n> for the driver's maintainer. The patch doesn't introduce any regression.\n> \n> Patch 4/7 then starts refactoring the v4l2_subdev_link_validate() to\n> separate the current warning in two categories, with a WARN_ON() for an\n> issue that indicates a clear driver bug (and does not occur in any\n> driver in mainline at the moment), and keeping the pr_warn_once() for\n> other issues that are present in multiple drivers.\n> \n> Patch 5/7 continues with expanding v4l2_subdev_link_validate() to better\n> support links from video output devices to subdevs, delegating the\n> validation to the video output device's .link_validate() operation. This\n> allows using v4l2_subdev_link_validate() for all subdevs in a driver,\n> regardless of whether they are connected to other subdevs, video capture\n> devices or video output devices, and implementing all the link\n> validation for video devices in their .link_validate() operation.\n> \n> Patches 6/7 and 7/7 then address the v4l2_subdev_link_validate() warning\n> for the vsp1 driver. Patch 6/7 silences the warning. This is\n> unfortunately done with a workaround, as the ideal implementation,\n> moving all validation for video devices to their .link_validate()\n> operation as showcased in patch 7/7, breaks operation of the vsp1 unit\n> test suite. While that is fixable in the test suite, it indicates that\n> other userspace applications may also break as a result.\n> \n> To my great sadness, I had to mark patch 7/7 as [DNI]. This does not\n> make the v4l2_subdev_link_validate() improvements in patch 5/7\n> pointless, as they are useful for new drivers, as well as drivers that\n> don't include multiple video devices in a pipeline.\n> \n> Laurent Pinchart (7):\n>   media: microchip-isc: Drop v4l2_subdev_link_validate() for video\n>     devices\n>   media: sun4i_csi: Implement link validate for sun4i_csi subdev\n>   media: sun4i_csi: Don't use v4l2_subdev_link_validate() for video\n>     device\n>   media: v4l2-subdev: Refactor warnings in v4l2_subdev_link_validate()\n>   media: v4l2-subdev: Support hybrid links in\n>     v4l2_subdev_link_validate()\n>   media: renesas: vsp1: Implement .link_validate() for video devices\n>   [DNI] media: renesas: vsp1: Validate all links through\n>     .link_validate()\n> \n>  .../platform/microchip/microchip-isc-base.c   |  19 +---\n>  .../media/platform/renesas/vsp1/vsp1_video.c  | 104 +++++++++---------\n>  .../platform/sunxi/sun4i-csi/sun4i_csi.c      |  12 ++\n>  drivers/media/v4l2-core/v4l2-subdev.c         |  50 +++++++--\n>  include/media/v4l2-subdev.h                   |   6 +\n>  5 files changed, 115 insertions(+), 76 deletions(-)\n> \n> \n> base-commit: a043ea54bbb975ca9239c69fd17f430488d33522","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B2468BDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Aug 2024 15:46:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DA151633CF;\n\tThu, 22 Aug 2024 17:46:56 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 057A863369\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Aug 2024 17:46:55 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 57AF8219;\n\tThu, 22 Aug 2024 17:45:51 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"p7SqWnWo\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1724341551;\n\tbh=odocXFEfjk2fSHShpJrHq0/0iPDFPuc98DH4j03ndBU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=p7SqWnWodX/PLoXr6fs3cy4xFnBPO1NTGAQ0quIzD3yDqc30l8jTuGz1jQFJW6mTe\n\tAQYz/L78Kk7O7tnKkL90WvPk/5BZh37HMybk2MORA2/CikA9RyFcEIA5OY9LP0TpYj\n\t4cSoMVTV72zW6IbXYG0ZmGcSxRNGVH5X9/VqVmYI=","Date":"Thu, 22 Aug 2024 18:46:52 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Chen-Yu Tsai <wens@csie.org>, Eugen Hristev <eugen.hristev@collabora.com>,\n\tHans Verkuil <hverkuil-cisco@xs4all.nl>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tMaxime Ripard <mripard@kernel.org>, Sakari Ailus <sakari.ailus@iki.fi>,\n\tTomi Valkeinen <tomi.valkeinen@ideasonboard.com>,\n\tlinux-renesas-soc@vger.kernel.org, linux-sunxi@lists.linux.dev","Subject":"Re: [PATCH v2 0/7] media: v4l2: Improve media link validation","Message-ID":"<20240822154652.GA26081@pendragon.ideasonboard.com>","References":"<20240822153527.25320-1-laurent.pinchart+renesas@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240822153527.25320-1-laurent.pinchart+renesas@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]