I have an IMX8MPLUS device with several sensors I want it to support plug-and-play (Mostly ISI, not ISP).
l've set up devicetree overlays to enable the cameras, and I load them based on what's connected to the I2C bus during initramfs. (via OF overlay ConfigFS like Xilinx uses). The modules for the sensors are then loaded when systemd later does its thing.
This works fine, but we've found that if the sensor kernel-module's probe function takes too long, the cameras don't come up, as mx8-img-md Deregisters the /dev/videoX device before the sensor module calls subdev_register. I've found I need to keep my probe <200ms. I've reduced time spent in probe(), but the variability of this has lead to race-conditions and unreliable device behaviour (when an ISP based camera causes start_isp.sh to run, which further complicates things).
In any event, I could always run rmmod imx8_media_dev && modprobe imx8_media_dev and the sensor would be picked up again, but that has now stopped working in the 6.1.55 release. In the latest release, if the imx8_media_dev module is loaded before the sensors, I get some sort of loading dependency: I get the following:
root@imx8:~# dmesg | grep defer
[ 10.561551] mxc-md 32c00000.bus:camera: deferring csi device registration
[ 20.715114] mxc-md 32c00000.bus:camera: deferring csi device registration
[ 20.722440] platform 32e40000.csi: deferred probe pending
[ 20.727881] i2c 2-0038: deferred probe pending
[ 20.732351] platform 32c00000.bus:camera: deferred probe pending
[ 242.269519] mxc-md 32c00000.bus:camera: deferring csi device registration
root@imx8:~# cat /sys/kernel/debug/devices_deferred
32e40000.csi platform: supplier 2-0038 not ready
2-0038 i2c: supplier 32c00000.bus:camera not ready
32c00000.bus:camera
And reloading imx8_media_dev no longer works.
At this point I have to:
- blacklist the imx8_media_dev module from loading
- wait a few seconds, then load the imx8_media_dev module.
But this is a hacky solution, and I want it to work reliably,
What would be the correct way of handling this situation?
What causes the I2C device probe to be deferred?
Is there a clean way to make the imx8mp camera load sequence reliable?
Should I maybe patch the imx media drivers to not unload /dev/video devices?
I can't bake the sensor module into the kernel as some of them are closed source. I also like being able to unload modules for the sensors. I could potentially forcibly load the sensor kernel-modules before systemd-modules-load.service, but again, that would be hacky. Preferably the solution should work cross-platform if I wanted to use them with a imx8mm for example.