Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ipu6-isys probe improvements #214

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jwrdegoede
Copy link
Contributor

Here is a set of improvements to the ipu6-isys probe() code which I wrote while working on fixing #205

@EmilienMottet
Copy link

EmilienMottet commented Mar 8, 2024

this works fine for me in kernel 6.7.7 but no in 6.7.9

In 6.7.9 have this. Before your fix I have the same in 6.7.7. I have recompile with 6.7.9 kernel

int3472-discrete INT3472:06: cannot find GPIO chip INTC1096:00, deferring
int3472-discrete INT3472:05: cannot find GPIO chip INTC1096:00, deferring

when I boot on 6.7.7, I have this

i2c i2c-INT3474:01: deferred probe pending

after reload mod with :

sudo rmmod -f intel_ipu6_psys intel_ipu6_isys intel_ipu6 && sudo modprobe -a intel_ipu6 intel_ipu6_isys intel_ipu6_
psys

I can access to my camera :)

intel-ipu6 0000:00:05.0: Device 0xa75d (rev: 0x0)
intel-ipu6 0000:00:05.0: physical base address 0x603c000000
intel-ipu6 0000:00:05.0: mapped as: 0x000000009cb09c25
intel-ipu6 0000:00:05.0: IPU in secure mode
intel-ipu6 0000:00:05.0: IPU secure touch = 0x0
intel-ipu6 0000:00:05.0: IPU camera mask = 0xff
intel-ipu6 0000:00:05.0: IPC reset done
intel-ipu6 0000:00:05.0: cpd file name: intel/ipu6ep_fw.bin
Loading firmware: intel/ipu6ep_fw.bin
intel-ipu6 0000:00:05.0: FW version: 20230102
intel-ipu6 0000:00:05.0: Found supported sensor INT3474:01
intel-ipu6 0000:00:05.0: Connected 1 cameras
intel-ipu6 0000:00:05.0: Sending BOOT_LOAD to CSE
intel-ipu6 0000:00:05.0: Sending AUTHENTICATE_RUN to CSE
intel-ipu6 0000:00:05.0: CSE authenticate_run done
intel-ipu6 0000:00:05.0: IPU6-v3 driver version 1.0
intel-ipu6-psys intel-ipu6-psys0: pkg_dir entry count:8
intel-ipu6-psys intel-ipu6-psys0: psys probe minor: 0
intel-ipu6-isys intel-ipu6-isys0: bind ov2740 2-0036 nlanes is 2 port is 1
intel-ipu6-isys intel-ipu6-isys0: All sensor registration completed.

@kupietz
Copy link

kupietz commented Mar 8, 2024

this works fine for me in kernel 6.7.7 but no in 6.7.9

In 6.7.9 have this. Before your fix I have the same in 6.7.7. I have recompile with 6.7.9 kernel

int3472-discrete INT3472:06: cannot find GPIO chip INTC1096:00, deferring
int3472-discrete INT3472:05: cannot find GPIO chip INTC1096:00, deferring

I get exactly this already with kernel 6.7.7-200.fc39.

@EmilienMottet
Copy link

@kupietz

I solve this issue with

sudo rm -rf /lib/modules/6.7.10-gentoo-dist/updates/*ljca*.ko.xz
sudo modprobe -r intel_ipu6_psys intel_ipu6_isys intel_ipu6 && sudo modprobe -a intel_ipu6 intel_ipu6_isys intel_ip
u6_psys
sudo depmod -a

after deleting the external module you have to rebuild the dep module graph

@kupietz
Copy link

kupietz commented Mar 19, 2024

@kupietz

I solve this issue with

sudo rm -rf /lib/modules/6.7.10-gentoo-dist/updates/*ljca*.ko.xz
sudo modprobe -r intel_ipu6_psys intel_ipu6_isys intel_ipu6 && sudo modprobe -a intel_ipu6 intel_ipu6_isys intel_ip
u6_psys
sudo depmod -a

after deleting the external module you have to rebuild the dep module graph

Thanks! This got @jwrdegoede 's COPR/ipu6-softisp kernel working for my X1 Carbon Gen 11, but apparently does not help with kernel-6.7.9-200.fc39.x86_64.

When I delete all duplicate ljca modules on f39:

# find /usr/lib/modules/6.7.9-200.fc39.x86_64/kernel/drivers/ -name "*ljca.ko*" -print -delete
/usr/lib/modules/6.7.9-200.fc39.x86_64/kernel/drivers/gpio/gpio-ljca.ko.xz
/usr/lib/modules/6.7.9-200.fc39.x86_64/kernel/drivers/i2c/busses/i2c-ljca.ko.xz
/usr/lib/modules/6.7.9-200.fc39.x86_64/kernel/drivers/spi/spi-ljca.ko.xz
/usr/lib/modules/6.7.9-200.fc39.x86_64/kernel/drivers/usb/misc/usb-ljca.ko.xz
# depmod -a
# shutdown -r now

I still get:

# dmesg  |grep GPIO
[    7.586806] int3472-discrete INT3472:05: cannot find GPIO chip INTC1096:00, deferring
[    7.593085] int3472-discrete INT3472:06: cannot find GPIO chip INTC1096:00, deferring
[    7.595558] int3472-discrete INT3472:05: cannot find GPIO chip INTC1096:00, deferring
[    7.601181] int3472-discrete INT3472:06: cannot find GPIO chip INTC1096:00, deferring
[    7.604324] int3472-discrete INT3472:05: cannot find GPIO chip INTC1096:00, deferring
[    7.608102] int3472-discrete INT3472:06: cannot find GPIO chip INTC1096:00, deferring

EDIT: but indeed, afterwards, something happens:

$ sudo dmesg | grep -iE '(gpio|ipu6|ov2)'
…
[   10.608570] intel-ipu6 0000:00:05.0: cpd file name: intel/ipu6ep_fw.bin
[   10.609996] intel-ipu6 0000:00:05.0: FW version: 20230102
[   10.613838] intel-ipu6 0000:00:05.0: Found supported sensor INT3474:01
[   10.614016] intel-ipu6 0000:00:05.0: Connected 1 cameras
[   10.614842] intel-ipu6 0000:00:05.0: Sending BOOT_LOAD to CSE
[   10.624400] intel-ipu6 0000:00:05.0: Sending AUTHENTICATE_RUN to CSE
[   10.692881] intel-ipu6 0000:00:05.0: CSE authenticate_run done
[   10.693360] intel-ipu6 0000:00:05.0: IPU6-v3 driver version 1.0
[   10.694380]  isys_unregister_subdevices+0x36/0x80 [intel_ipu6_isys]
[   10.694395]  isys_probe+0x565/0x9b0 [intel_ipu6_isys]
[   10.694415]  ipu_bus_probe+0x5c/0x100 [intel_ipu6]
[   10.694483] Modules linked in: uvcvideo(+) nft_chain_nat uvc nf_nat videobuf2_vmalloc nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ip_set cdc_ether usbnet nf_tables nfnetlink bnep gpio_ljca(OE) spi_ljca(OE) i2c_ljca(OE) btusb btrtl btintel uas btbcm btmtk bluetooth ljca(OE) r8152 mii usb_storage qrtr snd_usb_audio snd_usbmidi_lib snd_ump snd_rawmidi snd_ctl_led snd_soc_skl_hda_dsp snd_soc_hdac_hdmi snd_sof_probes snd_soc_intel_hda_dsp_common snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic sunrpc snd_soc_dmic snd_sof_pci_intel_tgl snd_sof_intel_hda_common soundwire_intel snd_sof_intel_hda_mlink soundwire_cadence snd_sof_intel_hda snd_sof_pci snd_sof_xtensa_dsp iwlmvm snd_sof intel_uncore_frequency intel_uncore_frequency_common intel_tcc_cooling x86_pkg_temp_thermal snd_sof_utils snd_soc_hdac_hda intel_powerclamp binfmt_misc snd_hda_ext_core coretemp iTCO_wdt snd_soc_acpi_intel_match intel_pmc_bxt snd_soc_acpi iTCO_vendor_support spi_nor mei_pxp mei_hdcp kvm_intel mtd mac80211 soundwire_generic_allocation
[   10.694529]  pmt_telemetry pmt_class intel_rapl_msr soundwire_bus kvm snd_soc_core libarc4 snd_compress ac97_bus irqbypass snd_pcm_dmaengine rapl snd_hda_intel intel_cstate snd_intel_dspcfg snd_intel_sdw_acpi snd_hda_codec intel_uncore snd_hda_core think_lmi(+) iwlwifi snd_hwdep firmware_attributes_class vfat wmi_bmof intel_ipu6_isys(OE) snd_seq fat pcspkr videobuf2_dma_contig snd_seq_device i2c_i801 videobuf2_memops snd_pcm videobuf2_v4l2 i2c_smbus spi_intel_pci cfg80211 iosm spi_intel snd_timer videobuf2_common processor_thermal_device_pci processor_thermal_device thunderbolt(+) mei_me intel_ipu6_psys(OE) processor_thermal_wt_hint idma64 processor_thermal_rfim intel_vsec processor_thermal_rapl intel_rapl_common intel_ipu6(OE) processor_thermal_wt_req processor_thermal_power_floor nxp_nci_i2c processor_thermal_mbox thinkpad_acpi nxp_nci ledtrig_audio mei_vsc(OE) nci platform_profile intel_skl_int3472_tps68470 snd int3403_thermal mei tps68470_regulator nfc soundcore soc_button_array int340x_thermal_zone clk_tps68470
[   10.694572]  rfkill ov2740(OE) v4l2_fwnode int3400_thermal intel_hid intel_skl_int3472_discrete v4l2_async acpi_thermal_rel sparse_keymap acpi_tad acpi_pad joydev loop hid_sensor_hub intel_ishtp_hid i915 crct10dif_pclmul crc32_pclmul i2c_algo_bit crc32c_intel polyval_clmulni drm_buddy polyval_generic ttm nvme ghash_clmulni_intel nvme_core drm_display_helper sha512_ssse3 intel_ish_ipc hid_multitouch sha256_ssse3 ucsi_acpi typec_ucsi sha1_ssse3 intel_ishtp cec typec nvme_auth video i2c_hid_acpi i2c_hid wmi pinctrl_tigerlake serio_raw hid_cmedia v4l2loopback(OE) videodev mc fuse i2c_dev
[   10.699695] ov2740 i2c-INT3474:01: chip id mismatch: 2740!=0
[   10.699701] ov2740 i2c-INT3474:01: failed to find sensor: -6

@EmilienMottet
Copy link

Ok looks good :
Doyou kernel have config ?

zgrep -i 2740 /proc/config.gz 
CONFIG_VIDEO_OV2740=m
zgrep  CONFIG_INTEL_VSC /proc/config.gz
CONFIG_INTEL_VSC=m

@kupietz
Copy link

kupietz commented Mar 21, 2024

Fedora kernels don't support /proc/config anymore, but:

$ grep -E '2740|CONFIG_INTEL_VSC' /boot/config-$(uname -r)
# CONFIG_INTEL_VSC is not set
# CONFIG_VIDEO_OV2740 is not set

Should they be selected as modules, or just to avoid clashes with the ipu6-driver modules?

@EmilienMottet
Copy link

In my case, yes

@kupietz
Copy link

kupietz commented Mar 28, 2024

In my case, yes

It does also work for me on fc39 without the module selection after these steps. However, I often have to reboot to get it working.

jwrdegoede added 3 commits May 1, 2024 11:22
Add error logging to various probe() error paths to make it easier to
debug probe() failures.

Signed-off-by: Hans de Goede <[email protected]>
Calling isys_unregister_subdevices() on errors in
isys_register_subdevices() leads to not yet registered subdevs
getting unregistered resulting in a NULL pointer deref:

[  143.100638] BUG: kernel NULL pointer dereference, address: 0000000000000000
...
[  143.100655] RIP: 0010:__wake_up_common+0x2a/0xa0
...
[  143.100672] Call Trace:
[  143.100674]  <TASK>
[  143.100676]  ? __die+0x23/0x70
[  143.100680]  ? page_fault_oops+0x171/0x4e0
[  143.100684]  ? exc_page_fault+0x7f/0x180
[  143.100687]  ? asm_exc_page_fault+0x26/0x30
[  143.100690]  ? __wake_up_common+0x2a/0xa0
[  143.100692]  __wake_up+0x36/0x60
[  143.100697]  __vb2_queue_cancel+0xd2/0x290 [videobuf2_common]
[  143.100706]  vb2_core_queue_release+0x22/0x50 [videobuf2_common]
[  143.100714]  isys_unregister_subdevices+0x49/0xb0 [intel_ipu6_isys]
[  143.100723]  isys_probe+0x59c/0xa30 [intel_ipu6_isys]

Fix this by only cleaning up subdevs which have actually been registered.

Signed-off-by: Hans de Goede <[email protected]>
Add a bunch of missing resource cleanups to ipu_isys_probe()'s
error exit path.

Add a missing mutex_destroy() to isys_remove() and drop the always true
"if (isp->ipu_dir)" check before calling debugfs_remove_recursive().
This likely should have checked the debugfs_remove_recursive() argument
is not NULL but that is not necessary, debugfs_remove_recursive() checks
this itself.

Signed-off-by: Hans de Goede <[email protected]>
@jwrdegoede
Copy link
Contributor Author

These patches are still relevant/useful. I'm pushing a new version rebased on the latest master branch now.

@jwrdegoede jwrdegoede force-pushed the ipu6-probe-improvements branch from baf00fd to ab8b8be Compare May 1, 2024 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants