From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796294172; b=a7A/qYyuUBfBshCrxMjITSMQEEqXFTUnYH4iH81MqZvi3LMk4Dd4IWBN9qnkm74oFqJy n6eDoMwRZkRQkrWzvMJBSEX4Oe4pkO1VsVjX58Luc4wHOkkdIijx7HqlqoEW4jQceEm8A rfQb6dlXRYVKnvSWL3fBE1SDPx3JQ1+eHfINXcbemY0DPoGijWwLg33UhZDDnlaY6UkNA X8R70TwjFPj+9XDij243nO1skXtQ5MjGaS4cf2F5xZrrGiz4Q2OXPrW7WVLMUFLE37j0h 7W19uR+U37U18MZk0MVyfeO6rRSqfe2j8x8DdLJe14LMoCh9QHygX3DbaVKQosqZY2A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796294172; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:Content-Language:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=MVApDyUbSLpWPjjF4xJ+wij1QAQ9nF+K6O5nEtnenBc=; b=XQVxbVqf6qzYLbMOjNBZJdr8iXr98F+0JGxuujWiooazMtHD0+3gCNruQw/rcIfjpZ82 3pAS281ojzyPpza2FhIm98lK0pnm0324oYq1/SvMHOL1qGkGRDok9Kq4mHXi01nKHCokR FvK3quGN6btde4+xW8GHrDAaRG5v4CRukbHG46ZP4dnsUDkcYW0IbVDvoRD+2Cpf6DT5z n37hVvA7UPve/D17dAzh7TjljWEOMgtzCBckU9DAR1unrcFoTZROaiYekXIX7MNWN1Okv KYpEUQMEMjwImzfhWg2rJlU6OzJOWsDUg/P/pr8TEv2f4DmRnJxMZqDpoQ7rw9QAY8g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e892RX+Y; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C5DF606A32C; Thu, 3 Dec 2026 10:36:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e892RX+Y Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DF071F000C1; Thu, 3 Dec 2026 10:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796294171; bh=MVApDyUbSLpWPjjF4xJ+wij1QAQ9nF+K6O5nEtnenBc=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=e892RX+YS475MRUQzJxYl0RucalZhQYkk84j70414gWJFzrGyELh/OeNwhSaDRuJ5 R85moGH2g3hPnv1HkFClJm+B2Zu/ps8P0uSGs++NLsAkHZ4ymu04fjslti2WuzRaT5 kHi4pFNySPeaiznSfZ/xQXOfnViTqWsdER889XkDE2KUVh46X/6E9PHjXrwjA8GQof jTPOAwqczWgFQdaz3rQizO7vLvUKETezRmjJdwiBAYOFbrDtaUxc/36aW+RnsgFoiP FY9Xzr4de6FWEByoaOwPadZDda/EM/2+l8YhHXF+dHS0lkuRk4xGszMrtCIO0Wi+It SFy6A4hwbzwig== Message-ID: <87ea11b5-54f1-4c61-9707-9ce0d0b2d0fa@kernel.org> Date: Thu, 3 Dec 2026 11:36:05 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC v2 00/16] media: Fault-Tolerant V4L2 To: Mattijs Korpershoek , Laurent Pinchart , Kieran Bingham , Sakari Ailus , Mauro Carvalho Chehab , Andy Walls , Kees Cook , "Gustavo A. R. Silva" Cc: Nicolas Dufresne , Hans de Goede , Michael Riesch , Dave Stevenson , Maxime Ripard , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Laurent Pinchart References: <20261118-v4l2-sensor-detect-v2-0-1bb1a445b556@kernel.org> From: Hans Verkuil Content-Language: en-US, nl In-Reply-To: <20261118-v4l2-sensor-detect-v2-0-1bb1a445b556@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Mattijs, On 18/11/2026 13:43, Mattijs Korpershoek wrote: > On media-centric camera pipelines, every entity is known at boot time > and described statically (for example via device-tree). > > The V4L2 framework assumes that every entity of the camera > pipeline is always present. This is a reasonable assumption for > integrated cameras in laptops or phones. However, in automotive systems, > cameras (e.g. rear-view or surround-view) can be damaged or disconnected. > When the framework assumes all sensors are present, a single missing > camera can prevent the entire pipeline from operating. > > This is a known problem and has been discussed at various conferences: > * https://www.linuxtv.org/downloads/presentations/media_summit_2026/Michael%20-%20The%20Butterfly%20Effect.pdf > * https://www.linuxtv.org/news.php?entry=2022-11-14-0.hverkuil > * https://lore.kernel.org/linux-media/20261021224119.GA383235@killaraus.ideasonboard.com/T/#u > > For example, in the following pipeline: > """ > imx219 9-0010 -> ds90ub953 7-0044 -> ds90ub960 pad0 -+ > |-- pad4 -> cdns_csi2rx -> ticsi2rx > imx219 10-0010 -> ds90ub953 7-0045 -> ds90ub960 pad1 -+ > """ > > If imx219 9-0010 fails to probe, media-ctl -p will show: > """ > ds90ub953 7-0044 -> ds90ub960 pad0 -+ > |-- pad4 -> cdns_csi2rx -> ticsi2rx > imx219 10-0010 -> ds90ub953 7-0045 -> ds90ub960 pad1 -+ > """ > > Now, if ds90ub953 7-0044 fails to probe(), media-ctl -p will only show the > following topology: > """ > cdns_csi2rx -> ticsi2rx > """ > > To solve this, we chose to go for a simple solution inspired by > DRM connectors. > > We created an ioctl for media entitities to report their current > connection status. > This allows applications to discover an entity state when discovering > the graph (using media-ctl -p, for example) > The entity status is then cached. When applications start streaming, > the status is polled on a regular basis and reported as a media event > every time it changes. > This mandates that the driver can probe even when the device is > not connected. > > This has the benefits of being fairly simple to implement, understand > and support in drivers. > > This new behaviour is opt-in. It is enabled via a module parameter > for the Media Controler: mc.fault_tolerant. > > Patch 1-9 Add event support at media device level > Patch 10-14 Add entity status and ioctls to interact with it > Patch 15-16 implement this pattern switch for the imx219 driver. > > With this, we can hot-plug the sensor and get notified via the media > device of the status: > > [root@fedora]# ./media-event-monitor > Subscribed to ENTITY_REGISTRATION and ENTITY_STATUS_CHANGE on /dev/media0 > Waiting for events (Ctrl-C to quit)... > event: type=2 (ENTITY_STATUS_CHANGE) id=0 seq=0 ts=403045107120 pending=0 > entity_id=40 status=DISCONNECTED > event: type=2 (ENTITY_STATUS_CHANGE) id=0 seq=1 ts=415292362587 pending=0 > entity_id=40 status=CONNECTED > > The code for this demo is available at: > https://gitlab.com/-/snippets/6077614 > > The media device event code is mostly Sakari's work which can be found at: > https://git.linuxtv.org/sailus/media_tree.git/log/?h=partial-reg > > Current known limitations: > * Only leaf entities (typically sensor nodes) are covered. We should > also address entities that are in the middle of the media graph > > This has been tested on a SK-AM69 board on top of the following series: > * https://lore.kernel.org/all/20260824121451.3348583-1-sakari.ailus@linux.intel.com/ > * https://lore.kernel.org/all/20261104-j721e-csi2rx-crash-sd-enable-streams-v1-1-b77ee38c8dcf@kernel.org/ Sorry for the late reply, I was ill for a bit, then very busy. So what I really want to see is an RFC post explaining the outlines of how this feature is designed. So not a patch series, that comes next. Just a high-level design document. And not just explaining the design, but also the reasons for making the choices that went into that design. I.e.: 'I decided to choose this method, because...'. The cover letter goes some way into that direction, but it is lacking the reasoning behind the choices. It also seems geared towards failing sensors. But what if a CSI bridge fails? A camera flash chip? A lens driver? A practical real-life example is also with FPGA devices where part of the video pipeline is implemented inside the FPGA. What happens if the FPGA is unloaded, for example to save power when the device goes into standby? Can this uAPI be used to signal that it is gone, and when the FPGA is reloaded later, that it is back? In other words, think big. And it is fine if we decide not to support certain use-cases, either 'at all' or 'not yet'. But what I want to see is that someone thought about it. I have loads of questions: what about critical devices that must be present for the device to work? Who decides what is critical and what failures can be tolerated? If a device does not come up, how long do you wait before deciding it is broken? Can that be implemented in the media core or is that userspace that decides? What happens when a device breaks after bring up: who decides when it is broken? And what can be tolerated and what failure is critical? And of course how to enable this mechanism. You chose a module parameter for the mc module, but that will enable it for all drivers that use the mc. I don't think that's right. It should be specific to the top-level bridge driver. A module parameter for that driver makes sense, and it can pass that on to the media device when it is created. I wonder if it has to be even more granular, i.e. select it for a specific instance of a bridge driver device. That might be overkill. Regards, Hans > > Thanks, > Mattijs > > --- > Changes in v2: > - Notifications are now done at media device level (Laurent, Nicolas) > - Connection status is tracked at entity level (Laurent) > - imx219: Fail the probe if CHIP_ID does not match (Dave) > - Dropped patch 'media: imx219: Move LP-11 state switch to power_on()' > as we did not get any feedback from cadence on this > - Replaced VIDIOC_SUBDEV_G_CONNECTION_STATUS with a media controller > ioctl instead: MEDIA_IOC_G_ENTITY_STATUS > - Do status polling in generic framework (Dave) > - Increase polling interval to 10s (Dave) > - Polling/Fault tolerance is only enabled when mc.faul_tolerance=1 > module param is set (Dave, Hans V, Sakari) > - Reworked .detect() polling to be only done when streaming is on. This > should address the privacy led blinking concerns (Dave, Hans D) > - Link to v1: https://lore.kernel.org/r/20261001-v4l2-sensor-detect-v1-0-a45993be17b8@kernel.org > > --- > Laurent Pinchart (1): > media: mc: Add per-file-handle data support > > Mattijs Korpershoek (7): > media: media.h: Add entity connection status > media: mc: Add .detect() to media_entity_operations > media: mc: Add MEDIA_IOC_G_ENTITY_STATUS ioctl > media: mc: Add MEDIA_EVENT_ENTITY_STATUS_CHANGE event > media: mc: Add detect polling helpers for drivers > media: imx219: Allow driver probe with missing sensor > media: imx219: Implement .detect() sensor operation > > Sakari Ailus (8): > media: mc: Add struct media_device_fh pointer to media device IOCTL op > v4l: event: Separate event related information from struct v4l2_fh > v4l: event: Rework data structures for separating events and V4L2 > v4l: event: Split the event framework into generic and V4L2 bits > media: mc: Maintain a list of open file handles in a media device > media: mc: Add MEDIA_IOC_DQEVENT > media: mc: Add MEDIA_EVENT_ENTITY_REGISTRATION > Documentation: media: Add Media controller event documentation > > .../userspace-api/media/mediactl/media-funcs.rst | 3 + > .../media/mediactl/media-ioc-dqevent.rst | 130 +++++++++ > .../media/mediactl/media-ioc-g-entity-status.rst | 92 ++++++ > .../media/mediactl/media-ioc-subscribe-event.rst | 112 +++++++ > drivers/media/Kconfig | 3 + > drivers/media/i2c/imx219.c | 117 +++++--- > drivers/media/mc/Kconfig | 3 + > drivers/media/mc/Makefile | 3 +- > drivers/media/mc/mc-device.c | 236 ++++++++++++++- > drivers/media/mc/mc-devnode.c | 19 +- > drivers/media/mc/mc-entity.c | 59 ++++ > drivers/media/mc/mc-evbase.c | 260 +++++++++++++++++ > drivers/media/mc/mc-event.c | 244 ++++++++++++++++ > drivers/media/pci/ivtv/ivtv-fileops.c | 2 +- > drivers/media/usb/uvc/uvc_ctrl.c | 36 ++- > drivers/media/v4l2-core/v4l2-ctrls-api.c | 16 +- > drivers/media/v4l2-core/v4l2-ctrls-core.c | 20 +- > drivers/media/v4l2-core/v4l2-event.c | 324 +++++++++------------ > drivers/media/v4l2-core/v4l2-fh.c | 12 +- > include/media/media-device.h | 24 ++ > include/media/media-devnode.h | 18 +- > include/media/media-entity.h | 77 +++++ > include/media/media-evbase.h | 200 +++++++++++++ > include/media/media-event.h | 181 ++++++++++++ > include/media/media-fh.h | 37 +++ > include/media/v4l2-event.h | 106 ++++--- > include/media/v4l2-fh.h | 32 +- > include/uapi/linux/media.h | 51 +++- > 28 files changed, 2079 insertions(+), 338 deletions(-) > --- > base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 > base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > change-id: 20260923-v4l2-sensor-detect-32a0b2936cc1 > > Best regards, > -- > Mattijs Korpershoek > >