intel / ivsc-driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`i2c_ljca` prevents resume-from hibernate

richvdh opened this issue · comments

If I try to hibernate my machine while i2c_ljca is loaded, it freezes during resume.

If I rmmod i2c_ljca before hibernating, it resumes just fine.

Alternatively, if I echo 0 > /sys/power/pm_async before hibernating, then again it resumes just fine, even with i2c_ljca loaded.

I'm led to the conclusion there's a problem with the ljca drivers.

I can confirm it on 6.2.7-arch1-1 kernel. It freezes after hibernate or suspend. dmesg throws:

# dmesg | grep i2c
[    4.818530] ljca-i2c ljca-i2c.3.auto: hid INTC1097 uid 0 new uid1
[    4.911965] ov2740 i2c-INT3474:01: error -EINVAL: failed to check HW configuration
[    4.927408] ov2740: probe of i2c-INT3474:01 failed with error -22

I will be able to provide any details if you need some more.

I confirm this issue and was able to address it by either rmmod i2c_ljca or echo 0 > /sys/power/pm_async. However, in my case, after resume, gst-launch-1.0 icamerasrc ... ! v4l2sink device=/dev/video1 stops working with v4l2loopback. It works only after a fresh boot, not after a resume.

Before hibernation, ov2740 is used by two modules (lsmod not listing what they are :-(), but, after resume, by none. Similarly, intel_ipu6_psys by 67 modules before, but by none after.

The camera or its related devices seem to fail to wake up. Or maybe the module fails to probe the camera again. This command

gst-launch-1.0 icamerasrc buffer-count=7 ! \
        videoflip method=horizontal-flip ! \
        video/x-raw,format=NV12,width=1280,height=720 ! \
        v4l2sink device=/dev/video1

fails with

Setting pipeline to PAUSED ...
[06-13 11:40:45.91] CamHAL[INF] aiqb file name ov13b10.aiqb
[06-13 11:40:45.91] CamHAL[ERR] there is no aiqb file:ov13b10
[06-13 11:40:45.91] CamHAL[INF] aiqb file name ov13b10.aiqb
[06-13 11:40:45.91] CamHAL[ERR] there is no aiqb file:ov13b10
[06-13 11:40:45.91] CamHAL[INF] aiqb file name ov8856.aiqb
[06-13 11:40:45.91] CamHAL[ERR] there is no aiqb file:ov8856
[06-13 11:40:45.91] CamHAL[INF] aiqb file name ov8856.aiqb
[06-13 11:40:45.91] CamHAL[ERR] there is no aiqb file:ov8856
[06-13 11:40:45.91] CamHAL[INF] aiqb file name ov01a10.aiqb
[06-13 11:40:45.91] CamHAL[INF] aiqb file name ov01a10.aiqb
[06-13 11:40:45.91] CamHAL[INF] aiqb file name ov01a10.aiqb
[06-13 11:40:45.91] CamHAL[INF] aiqb file name ov01a10.aiqb
[06-13 11:40:45.91] CamHAL[INF] aiqb file name OV02C10_1BG203N3_ADL.aiqb
[06-13 11:40:45.91] CamHAL[INF] aiqb file name OV02C10_1BG203N3_ADL.aiqb
[06-13 11:40:45.91] CamHAL[INF] aiqb file name OV02C10_1SG204N3_ADL.aiqb
[06-13 11:40:45.91] CamHAL[INF] aiqb file name OV02C10_1SG204N3_ADL.aiqb
[06-13 11:40:45.91] CamHAL[INF] aiqb file name OV02C10_CIFME14_ADL.aiqb
[06-13 11:40:45.91] CamHAL[INF] aiqb file name OV02C10_CIFME14_ADL.aiqb
[06-13 11:40:45.91] CamHAL[INF] aiqb file name OV02C10_1BG203N3_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name OV02C10_1BG203N3_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name OV02C10_1SG204N3_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name OV02C10_1SG204N3_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name OV02C10_CIFME14_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name OV02C10_CIFME14_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name OV2740_CJFLE23_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name OV2740_CJFLE23_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name HM2170_1SG205N3_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name HM2170_1SG205N3_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name HM2170_CJFME18_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name HM2170_CJFME18_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name HI556_1BG502T3_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name HI556_1BG502T3_ADL.aiqb
[06-13 11:40:45.92] CamHAL[INF] aiqb file name HI556_CJFLE25_ADL.aiqb
[06-13 11:40:45.93] CamHAL[INF] aiqb file name HI556_CJFLE25_ADL.aiqb
[06-13 11:40:45.93] CamHAL[INF] aiqb file name ov01a1s.aiqb
[06-13 11:40:45.93] CamHAL[INF] aiqb file name ov01a1s.aiqb
[06-13 11:40:45.93] CamHAL[ERR] Failed to find DevName for cameraId: 0, get video node: ov13b10 , devname: /dev/v4l-subdev1
[06-13 11:40:45.95] CamHAL[ERR] MediaControl init failed
Failed to set pipeline to PAUSED.
Setting pipeline to NULL ...
Freeing pipeline ...

My device is ov2740, but the error message mentions ov13b10. Explicitly setting the device name doesn't help:

gst-launch-1.0 icamerasrc device-name=ov2740-uf buffer-count=7 ! \
        videoflip method=horizontal-flip ! \
        video/x-raw,format=NV12,width=1280,height=720 ! \
        v4l2sink device=/dev/video1
Setting pipeline to PAUSED ...
[06-13 11:55:47.322] CamHAL[INF] aiqb file name ov13b10.aiqb
[06-13 11:55:47.322] CamHAL[ERR] there is no aiqb file:ov13b10
[06-13 11:55:47.322] CamHAL[INF] aiqb file name ov13b10.aiqb
[06-13 11:55:47.322] CamHAL[ERR] there is no aiqb file:ov13b10
[06-13 11:55:47.322] CamHAL[INF] aiqb file name ov8856.aiqb
[06-13 11:55:47.322] CamHAL[ERR] there is no aiqb file:ov8856
[06-13 11:55:47.322] CamHAL[INF] aiqb file name ov8856.aiqb
[06-13 11:55:47.322] CamHAL[ERR] there is no aiqb file:ov8856
[06-13 11:55:47.322] CamHAL[INF] aiqb file name ov01a10.aiqb
[06-13 11:55:47.322] CamHAL[INF] aiqb file name ov01a10.aiqb
[06-13 11:55:47.322] CamHAL[INF] aiqb file name ov01a10.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name ov01a10.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_1BG203N3_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_1BG203N3_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_1SG204N3_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_1SG204N3_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_CIFME14_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_CIFME14_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_1BG203N3_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_1BG203N3_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_1SG204N3_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_1SG204N3_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_CIFME14_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV02C10_CIFME14_ADL.aiqb
[06-13 11:55:47.323] CamHAL[INF] aiqb file name OV2740_CJFLE23_ADL.aiqb
[06-13 11:55:47.324] CamHAL[INF] aiqb file name OV2740_CJFLE23_ADL.aiqb
[06-13 11:55:47.324] CamHAL[INF] aiqb file name HM2170_1SG205N3_ADL.aiqb
[06-13 11:55:47.324] CamHAL[INF] aiqb file name HM2170_1SG205N3_ADL.aiqb
[06-13 11:55:47.324] CamHAL[INF] aiqb file name HM2170_CJFME18_ADL.aiqb
[06-13 11:55:47.324] CamHAL[INF] aiqb file name HM2170_CJFME18_ADL.aiqb
[06-13 11:55:47.324] CamHAL[INF] aiqb file name HI556_1BG502T3_ADL.aiqb
[06-13 11:55:47.324] CamHAL[INF] aiqb file name HI556_1BG502T3_ADL.aiqb
[06-13 11:55:47.324] CamHAL[INF] aiqb file name HI556_CJFLE25_ADL.aiqb
[06-13 11:55:47.324] CamHAL[INF] aiqb file name HI556_CJFLE25_ADL.aiqb
[06-13 11:55:47.324] CamHAL[INF] aiqb file name ov01a1s.aiqb
[06-13 11:55:47.324] CamHAL[INF] aiqb file name ov01a1s.aiqb
[06-13 11:55:47.325] CamHAL[ERR] Failed to find DevName for cameraId: 12, get video node: ov2740 , devname: /dev/v4l-subdev1
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
[06-13 11:55:47.331] CamHAL[ERR] Get entity fail for calling getEntityById
[06-13 11:55:47.331] CamHAL[ERR] Get entity fail for calling getEntityById
[06-13 11:55:47.331] CamHAL[ERR] setup Link ov2740  [-1:0] ==> Intel IPU6 CSI-2  [-1x0] enable 1 failed.
[06-13 11:55:47.331] CamHAL[ERR] set MediaCtlConf McLink failed: ret = -1
[06-13 11:55:47.331] CamHAL[ERR] set up mediaCtl failed
[06-13 11:55:47.331] CamHAL[ERR] @configure Device Configure failed
[06-13 11:55:47.331] CamHAL[ERR] failed to config streams.
ERROR: from element /GstPipeline:pipeline0/Gstcamerasrc:camerasrc0: src pad: Internal data flow error.
Additional debug info:
gstcambasesrc.cpp(3143): gst_cam_base_src_loop (): /GstPipeline:pipeline0/Gstcamerasrc:camerasrc0:
streaming task paused, reason not-negotiated (-4)
Execution ended after 0:00:00.004308603
Setting pipeline to NULL ...
Freeing pipeline ...

I think this dmesg line is important:

[  195.332112] intel-ipu6-isys intel-ipu6-isys0: unbind ov2740 13-0036

If there is a way to bind back ov2740 to intel-ipu6-isys without rebooting, that may solve this issue, I guess. For our records, rmmod intel_ipu6_isys; modprobe intel_ipu6_isys fails with seg fault or hangs after resume.

commented

+1!

This PR might help?

This PR might help?

I don't think it will because it's made to work on RealSense platforms anyway. I will try if I can remove the flag requirement and somehow make this working for the main driver.

If I try to hibernate my machine while i2c_ljca is loaded, it freezes during resume.

I believe to have run into this problem repeatedly, trying to get the IPU6 webcam to work on my Lenovo ThinkPad X1 Yoga G7 running Fedora 39.

Back in August (on Fedora 38), I had to revert all changes and remove all added kernel mods for the problem to resolve. I'll quote an old reddit comment of mine:

The patched kernel appears to break wakeup from suspend. After closing the lid I'm greeted with light up keys but a black screen. Keyboard short cuts to mute/unmute don't do anything. So I assume something crashed during wakeup. I have S3 Sleep activated in BIOS. I did some testing with and without having kmod-intel-ipu6-6.4.10-200.fc38.x86_64.x86_64 installed. I'll remove the patch for the time being via:

$ sudo dnf remove kmod-intel-ipu6\*
$ sudo dnf remove akmod-intel-ipu6 akmod-v4l2loopback

EDIT: Forgot to also remove v4l2loopback via:

$ sudo dnf remove *v4l2loopback*

Sadly, I filtered my lsmod output only for ipu6 and v4l and didn't bother to investigate further:

$ lsmod | grep -iE 'ipu6|v4l'

intel_ipu6_isys       167936  0
videobuf2_dma_contig    28672  1 intel_ipu6_isys
videobuf2_v4l2         40960  1 intel_ipu6_isys
videobuf2_common       86016  4 videobuf2_dma_contig,videobuf2_v4l2,intel_ipu6_isys,videobuf2_memops
intel_ipu6_psys       126976  0
intel_ipu6            139264  2 intel_ipu6_isys,intel_ipu6_psys
v4l2_fwnode            32768  2 intel_ipu6_isys,ov2740
v4l2_async             28672  3 v4l2_fwnode,intel_ipu6_isys,ov2740
v4l2loopback           77824  1
videodev              372736  7 v4l2_async,v4l2_fwnode,videobuf2_v4l2,v4l2loopback,intel_ipu6_isys,ov2740
mc                     86016  6 v4l2_async,videodev,videobuf2_v4l2,intel_ipu6_isys,videobuf2_common,ov2740

Yesterday I gave it another try. I installed the ipu6-drivers like recommended by Hans de Goede via sudo dnf install akmod-intel-ipu6. Now my webcam is working but hibernation doesn't. Just like before.

Sadly neither # rmmod i2c_ljca, # rmmod -f i2c_ljca, # modprobe -r i2c_ljca nor # echo 0 > /sys/power/pm_async work. These are the outputs I get:

# rmmod i2c_ljca
Segmentation fault (core dumped)
# rmmod i2c_ljca
# rmmod -f i2c_ljca
# rmmod -f i2c_ljca
rmmod: ERROR: libkmod/libkmod-module.c:856 kmod_module_remove_module() could not remove 'i2c_ljca': Device or resource busy
rmmod: ERROR: could not remove module i2c_ljca: Device or resource busy
# modprobe -r i2c_ljca
modprobe: ERROR: libkmod/libkmod-module.c:856 kmod_module_remove_module() could not remove 'i2c_ljca': Device or resource busy
# echo 0 > /sys/power/pm_async

Any Ideas what causes these error messages?

Nothing works or fixes the hibernation problem. The kernel module i2c_ljca is also still loaded no matter what I do:

(base) root@thinkpad:/home/felix# lsmod | grep "i2c"
i2c_ljca               16384  -1
ljca                   40960  3 gpio_ljca,i2c_ljca,spi_ljca
i2c_i801               36864  0
i2c_smbus              20480  1 i2c_i801
i2c_algo_bit           20480  1 i915
i2c_hid_acpi           12288  0
i2c_hid                40960  1 i2c_hid_acpi

Thus, no workaround with scripts like these from @striczkof (here) will work for me.

However, I was able to circumvent the crash hibernation by switching from 'S3 Sleep' to 'suspend-to-idle' in my BIOS settings!

I have not seen this mentioned anywhere, so I wanted to share it here and have updated an old reddit comment of mine as well. I haven't read much into it but to my understanding 'suspend-to-idle' (also called s2idle) does exactly what it says and is not a real hibernation aka nothing gets unloaded (kernel, etc) and the CPU stays active in its lowest power state?!

I expect significantly worse battery drain in 'suspense' with s2idle in comparison to S3 sleep (also referred to as s2ram) after taking a look at the kernel documentation. But for now that's a compromise I can live with. Hopefully this information will be useful to people with similar problems until the issue with i2c_ljca is finally resolved (if ever).

Sadly neither # rmmod i2c_ljca, # rmmod -f i2c_ljca, # modprobe -r i2c_ljca nor # echo 0 > /sys/power/pm_async work. These are the outputs I get:

I upgraded kernel to 6.6.12 and managed to recompile the IPU6 drivers and others. Now, I'm getting the same Segmentation fault when I try to rmmod i2c_ljca, and nothing else helps either. It's worse! I had to uninstall them. I think I have to get a small USB webcam for now and wait...

For our info, I've tried the main branch, not the latest release.

Yup, this is the last time I am getting a Lenovo desktop and anything related to this useless webcam.
The whole process is broken and useless.
After 5 Lenovo business devices I am out.

If I try to hibernate my machine while i2c_ljca is loaded, it freezes during resume.

If I rmmod i2c_ljca before hibernating, it resumes just fine.

Alternatively, if I echo 0 > /sys/power/pm_async before hibernating, then again it resumes just fine, even with i2c_ljca loaded.

is the camera still working well if echo 0 > /sys/power/pm_async before hibernating

I'm led to the conclusion there's a problem with the ljca drivers.

sorry, I just realize the issue is still here.

The issue still exists/reproduced on 6.8.9-arch1-2 (clean setup) kernel. However, echo 0 > /sys/power/pm_async fixed it.

The issue is still present and can be reproduced on Debian 6.11-rc4 (experimental) kernel, with the ipu6 driver merged in the mainline kernel. As above, echoing 0 to /sys/power/pm_async fixes hibernation, but camera will be unusable until next fresh boot.