[PATCH v11 14/14] media: atomisp: Preserve the capture graph when a lens rebinds

From: Maurizio Casciano

Date: Sat Nov 21 2026 - 08:34:21 EST


The root notifier completes again when the lens subdevice is rebound.
Rebuilding the entire graph adds the original sensors a second time
and attempts to register the capture video device again.

If the capture node already exists and the sensors are unchanged,
register only missing subdevice nodes. Reject a changed sensor graph until
the driver is reinitialized. The preceding V4L2 rollback fix keeps
existing sensor nodes if new node registration fails. The X91L rebind
trial exposed the original issue. Codex drafted the notifier change.

Link: https://linuxtv.org/mailman3/hyperkitty/list/media-ci@xxxxxxxxxxx/message/2PUHZIDBEIGQKGXTJJOUXXJS2EOEMJGD/
Signed-off-by: Maurizio Casciano <mauriziocasciano7@xxxxxxxxx>
---
.../media/atomisp/pci/atomisp_csi2_bridge.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c b/drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c
index 56da454f0..72048de9b 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c
@@ -508,8 +508,23 @@ static void atomisp_notifier_unbind(struct v4l2_async_notifier *notifier,
static int atomisp_notifier_complete(struct v4l2_async_notifier *notifier)
{
struct atomisp_device *isp = notifier_to_atomisp(notifier);
+ unsigned int i;

- return atomisp_register_device_nodes(isp);
+ if (!video_is_registered(&isp->asd.video_out.vdev))
+ return atomisp_register_device_nodes(isp);
+
+ /*
+ * Completing the lens notifier again only needs a new lens node.
+ * The existing graph is valid as long as its sensors are unchanged.
+ */
+ for (i = 0; i < isp->input_cnt; i++) {
+ const struct atomisp_input_subdev *input = &isp->inputs[i];
+
+ if (input->csi_remote_source != isp->sensor_subdevs[input->port])
+ return -EBUSY;
+ }
+
+ return v4l2_device_register_subdev_nodes(&isp->v4l2_dev);
}

static const struct v4l2_async_notifier_operations atomisp_async_ops = {
--
2.53.0