imx8mp ISI sensor startup sequence with imx8_media_dev module

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

imx8mp ISI sensor startup sequence with imx8_media_dev module

1,189 次查看
KobusGvid
Contributor II

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:

  1. blacklist the imx8_media_dev module from loading
  2. 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. 

标记 (3)
0 项奖励
回复
6 回复数

774 次查看
k-sasaki
Contributor I

Has this problem already been resolved?
If you have the cause and solution, please post.


0 项奖励
回复

762 次查看
KobusGvid
Contributor II

the only 'solution' I could come up with was to add a delay to /opt/imx8-isp/bin/run.sh

1,135 次查看
joanxie
NXP TechSupport
NXP TechSupport

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.

> what other event do you mean? you mean other imx8 processor or other bsp version? this issue is only for imx8mp 6.1.55 bsp, right?

0 项奖励
回复

1,126 次查看
KobusGvid
Contributor II

Sorry, 'in any event' here just means 'regardless'. 

Which is to say there's 2 issues: 

- The bigger issue is the sequencing issue: i.e. needing sensors to probe before imx8_media_dev is loaded, has always been an issue. 

- The minor issue is that in 6.1.55 BSP release, reloading the imx8_media_dev mod no longer fixes this. 

 

I've done some more testing. Loading my sensor drivers earlier does not help. Even if I load them in the initramfs, the 'probe' function doesn't get called until about 12s after the initramfs exits. Seeing as this is an I2C module, I presume the probe runs only when the I2C bus runs 'bus_probe_device'. I'm guessing the kernel does one early scan of the I2C bus, and another later one once everything else in the kernel is finished... Or is it perhaps that the second scan is triggered by udev from the OS? 

0 项奖励
回复

1,086 次查看
joanxie
NXP TechSupport
NXP TechSupport

yes I know this is 'regardless' mean, I mean reload imx8_media_dev issue is only with 6.1.55? the kernel load sequence is that imx8_media_dev  is after camera driver load, let me reproduce this on 6.1.55

0 项奖励
回复

981 次查看
KobusGvid
Contributor II

Yes, reloading the imx8_media_dev module still works on the 6.1.22 release. 
You should be able to reproduce this issue by:
1. building the OV5640 module as loadable instead of built-in

2. adding a long delay to its probe function

0 项奖励
回复