Repository navigation
Description
Describe the bug
After updating the kernel from version 4.19.118 to 5.4.35 an attempt to get an image from the tc358743 device twice in a row (reopen device file) results to I2C timeouts. In some cases, this leads to a hang (see log1), sometimes it causes errors when working with the MMC card and a reboot (see log2).
UPD: The first message was not entirely accurate. The problem occur when the first reading process is interrupted. That is, I run yavta, press Ctrl+C and immediately got a dead kernel. I played around with yavta a bit and found out that the problem occurs either when closing /dev/video0 or when executing ioctl VIDIOC_STREAMOFF. I think the tc358743 driver is trying to command something over I2C, and everything stops working.
/UPD
[ 79.678547] ------------[ cut here ]------------
[ 79.678554] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 79.678569] tc358743 10-000f: i2c_wr: writing register 0x4 from 0xf failed
[ 79.683241] WARNING: CPU: 3 PID: 34 at drivers/firmware/raspberrypi.c:63 rpi_firmware_transaction+0xe8/0x124
[ 79.705713] Firmware transaction timeout
[ 79.705715] Modules linked in: usb_f_mass_storage usb_f_hid usb_f_acm u_serial btsdio bluetooth ecdh_generic ecc brcmfmac brcmutil cfg80211 raspberrypi_hwmon hwmon i2c_mux_pinctrl i2c_mux bcm2835_unicam i2c_bcm2835 iproc_rng200 rng_core bcm2835_codec(C) bcm2835_v4l2(C) bcm2835_isp(C) bcm2835_mmal_vchiq(C) v4l2_mem2mem videobuf2_dma_contig videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_common rpivid_mem uio_pdrv_genirq uio sch_fq_codel snd_bcm2835(C) snd_pcm snd_timer snd tc358743 v4l2_dv_timings v4l2_fwnode videodev mc cec libcomposite dwc2 udc_core drm drm_panel_orientation_quirks ip_tables x_tables ipv6 nf_defrag_ipv6
[ 79.766074] CPU: 3 PID: 34 Comm: kworker/3:1 Tainted: G C 5.4.35-1-ARCH #1
[ 79.774292] Hardware name: BCM2711
[ 79.777717] Workqueue: events dbs_work_handler
[ 79.782192] [<c0211424>] (unwind_backtrace) from [<c020c6fc>] (show_stack+0x10/0x14)
[ 79.789977] [<c020c6fc>] (show_stack) from [<c0ccc638>] (dump_stack+0x94/0xb4)
[ 79.806238] [<c0ccc638>] (dump_stack) from [<c022ceb8>] (__warn+0xd0/0xf8)
[ 79.817766] [<c022ceb8>] (__warn) from [<c022d29c>] (warn_slowpath_fmt+0x98/0xc4)
[ 79.834301] [<c022d29c>] (warn_slowpath_fmt) from [<c0b36468>] (rpi_firmware_transaction+0xe8/0x124)
[ 79.852463] [<c0b36468>] (rpi_firmware_transaction) from [<c0b36550>] (rpi_firmware_property_list+0xac/0x168)
[ 79.871582] [<c0b36550>] (rpi_firmware_property_list) from [<c0b3666c>] (rpi_firmware_property+0x60/0x108)
[ 79.890551] [<c0b3666c>] (rpi_firmware_property) from [<c0928494>] (raspberrypi_clock_property+0x48/0x78)
[ 79.909488] [<c0928494>] (raspberrypi_clock_property) from [<c09285f8>] (raspberrypi_fw_set_rate+0x44/0xb8)
[ 79.928821] [<c09285f8>] (raspberrypi_fw_set_rate) from [<c0921c94>] (clk_change_rate+0xe0/0x558)
[ 79.947361] [<c0921c94>] (clk_change_rate) from [<c0922284>] (clk_core_set_rate_nolock+0x178/0x1a0)
[ 79.966220] [<c0922284>] (clk_core_set_rate_nolock) from [<c09222dc>] (clk_set_rate+0x30/0x88)
[ 79.984877] [<c09222dc>] (clk_set_rate) from [<c0b03da8>] (dev_pm_opp_set_rate+0x364/0x460)
[ 80.003253] [<c0b03da8>] (dev_pm_opp_set_rate) from [<c0b0d0bc>] (set_target+0x2c/0x54)
[ 80.021370] [<c0b0d0bc>] (set_target) from [<c0b07e08>] (__cpufreq_driver_target+0x220/0x534)
[ 80.040342] [<c0b07e08>] (__cpufreq_driver_target) from [<c0b0b32c>] (od_dbs_update+0xb4/0x160)
[ 80.059658] [<c0b0b32c>] (od_dbs_update) from [<c0b0c4c4>] (dbs_work_handler+0x2c/0x58)
[ 80.078284] [<c0b0c4c4>] (dbs_work_handler) from [<c02489ec>] (process_one_work+0x1f0/0x588)
[ 80.097449] [<c02489ec>] (process_one_work) from [<c0248dd0>] (worker_thread+0x4c/0x528)
[ 80.116348] [<c0248dd0>] (worker_thread) from [<c024ec28>] (kthread+0x128/0x154)
[ 80.134600] [<c024ec28>] (kthread) from [<c02010d8>] (ret_from_fork+0x14/0x3c)
[ 80.152846] Exception stack(0xef2a9fb0 to 0xef2a9ff8)
[ 80.163429] 9fa0: 00000000 00000000 00000000 00000000
[ 80.182818] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 80.202646] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 80.215376] ---[ end trace 91bfd0c131224965 ]---
[ 80.226095] raspberrypi-clk firmware-clocks: Failed to change pllb frequency: -110
[ 80.718577] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 80.730213] tc358743 10-000f: i2c_rd: reading register 0x2 from 0xf failed
[ 81.758599] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 81.770193] tc358743 10-000f: i2c_wr: writing register 0x2 from 0xf failed
[ 82.798624] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 82.810166] tc358743 10-000f: i2c_wr: writing register 0x2 from 0xf failed
[ 83.838648] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 83.850108] tc358743 10-000f: i2c_wr: writing register 0x14c from 0xf failed
[ 84.878670] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 84.890186] tc358743 10-000f: i2c_wr: writing register 0x150 from 0xf failed
[ 85.918697] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 85.930211] tc358743 10-000f: i2c_wr: writing register 0x210 from 0xf failed
[ 86.958710] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 86.970186] tc358743 10-000f: i2c_wr: writing register 0x214 from 0xf failed
[ 87.998734] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 88.010264] tc358743 10-000f: i2c_wr: writing register 0x218 from 0xf failed
[ 89.038749] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 89.050252] tc358743 10-000f: i2c_wr: writing register 0x21c from 0xf failed
[ 90.078765] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 90.090261] tc358743 10-000f: i2c_wr: writing register 0x220 from 0xf failed
[ 91.118779] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 91.130418] tc358743 10-000f: i2c_wr: writing register 0x224 from 0xf failed
[ 92.158791] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 92.170372] tc358743 10-000f: i2c_wr: writing register 0x228 from 0xf failed
[ 93.198809] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[ 93.210184] tc358743 10-000f: i2c_wr: writing register 0x22c from 0xf failed
To reproduce
Set up Auvidea B101 with kernel 4.4.35, run any capture software that supports DV-timings (https://github.com/pikvm/ustreamer, yavta, etc) and stop it.
Expected behaviour
No crashes when closing the device file
Actual behaviour
Subj
System
- Which model of Raspberry Pi? e.g. Pi3B+, PiZeroW
4B 1Gb - Which OS and version (
cat /etc/rpi-issue)?
Arch Linux ARM (uses the kernel from this repo). - Which firmware version (
vcgencmd version)?
May 1 2020 17:56:42
Copyright (c) 2012 Broadcom
version 688a8f8f3d84e788f07f53c93693e1705f68c407 (clean) (release) (start_x)
- Which kernel version (
uname -a)?
Linux pikvm 5.4.35-1-ARCH #1 SMP PREEMPT Sun May 3 21:53:42 UTC 2020 armv7l GNU/Linux
Logs
Attached kernel log from tty.
Just I2C errors: log1.txt
MMC crash: log2.txt
Activity
mdevaev commentedon May 6, 2020
@6by9 I'm sorry to call you directly, but you may be interested in this issue. However, I'm not sure if this is related to the tc358743 driver, because somehow it affected the MMC card driver as well. If you need more logs, I will try to provide them to you as soon as possible.
6by9 commentedon May 6, 2020
Please provide your full configuration from config.txt.
5.4 has reworked i2c-0 to use the i2c-mux-pinctrl module to switch it between GPIOs 0&1, and whichever GPIOs the display/camera connector are attached to (either 28&29, or 44&45 dependent on variant). Any userspace messing with pinmuxing for i2c-0 should be avoided. i2c-0 is always GPIOs 0&1. i2c-10 is the camera/display.
We've also had a fairly significant update to the bcm2835-unicam driver as part of the work for libcamera, but that seems sound.
I'll have a look to see if there is anything obvious using standard v4l2-ctl commands.
MMC and the firmware blocked warnings generally mean you've managed to kill the firmware, typically a memory trample somehow.
6by9 commentedon May 6, 2020
It looks like my B101 board has died - it is recognised fine, set EDID and timings fine, but it doesn't produce any output data with either 5.4.38 or 4.19.118.
I'll see if I can get a B102 working on a CM as I don't think I have another B101 around.
6by9 commentedon May 6, 2020
OK, working fine with v4l2-ctl and yavta on a CM3L with B102, with kernel 5.4.35 and firmware 688a8f8f3d84e788f07f53c93693e1705f68c407 (rpi-update 8d64ec70 - top of tree today).
Source is 720p60 from a Pi3. Works in either RGB3 or UYVY.
More information required, particularly the source resolution and frame rate, format chosen from the B101, and what processing you're doing.
I have a suspicion that it may be a firmware change that is the problem, not the kernel. There were a few changes to the video_encoder and ISP components relatively recently.
Can you do
rpi-updateto get the latest kernel and firmware, and thensudo SKIP_KERNEL=1 rpi-update e5d3320to revert the firmware to that hash (28 Feb in this case). If that works, work forward in commits to https://github.com/Hexxeh/rpi-firmware/commits/master until it fails.mdevaev commentedon May 6, 2020
config.txt:
The last line does not affect the presence of the problem, I added it out of desperation when trying to understand what is happening. If you delete it, the problem persists.
I tried to simplify the way to reproduce the problem. The initial info about the launch of two times in a row, quite correct, the error appears upon termination of the read stream. I used yavta with EDID from your repository. Tried 720p/60Hz and 1080p/60Hz with UYVY - both resulted in a hang when pressing Ctrl+C.
By the way. This is not relevant, but as my users have found out, the B101 may burn due to an accidentally flown CSI cable.
Both 4.x and 5.x kernels used firmware 688a8f8. I am using Arch Linux and using rpi-update will completely break the system. So I installed minimal Raspbian and used same config.txt exclude initramfs and i2c_arm lines. I also updated the system and executed
rpi-update 8d64ec70. The problem was successfully reproduced wih yavta:Then I started moving through the firmware versions, as you said.
The problem was successfully reproduced again.
I assume you failed to reproduce it because you used CM3, not RPi4. Perhaps the model of the video capture board has some significance (but they seem to differ slightly from each other).
6by9 commentedon May 7, 2020
1080p60 can't be supported using a B101.
The B101 and B102 only differ in the number of CSI2 lanes that they present on the output connector, and the physical connector itself.
CM3 vs Pi4 have very few differences in the hardware blocks involved here. We're using the Unicam driver heavily for the recent libcamera work, so know that is sound over multiple runs.
I currently have no way to reproduce, so can't actually help.
Things to try (all after having provided an EDID):
raspigpio getafter the first run of yavta, and again after the second run has failed to start streaming (ideally when the second run is progress too).v4l2-ctl --set-dv-bt-timings queryv4l2-ctl --stream-mmap=3 --stream-to=/dev/null --stream-count=1000and run the stream command for second time. That is the simplest V4L2 setup going.--encode-to=file.h264from yavta. If that works then it points to an issue with H264 encode.rpi-update e1050e9482to drop back the kernel to the last 4.19 kernel and nearly latest firmware.mdevaev commentedon May 7, 2020
Sorry, probably the KDE dialog is deceiving me and we are talking about 50 Hz. I forgot about this feature.
I found a 3B+ board and tried. The problem is not reproduced on it even without
--encode-to=file.h264. I believe that the problem is still directly related to RPi4.I can't. I made a mistake in the initial diagnostics; immediately when the yavta process is interrupted, the core becomes inoperable.
Reproduced.
Not reproduced.
Given the fact that I also tested on RPi 3B+ and the problem did not reproduce there, it seems that the problem is reproduced exactly and only on 5.4 and RPi4. The problem exists on two different B101 boards and several RPi4 users I contacted.
What else could I do to help you debug this?
6by9 commentedon May 7, 2020
You can try adding
core_freq_min=250to /boot/config.txt, although I'd expect that to impact both kernel versions.v4l2-ctl --stream-mmap=3 --stream-to=/dev/null --stream-count=1000should print out a '>' for every frame received, and print an fps value each second.
You've got me fairly stumped if rpi-update e1050e9482 (4.19) works but 8d64ec7 (5.4) doesn't, and only on a Pi4.
I'll have a dig through my parts boxes to see if I have another B101. Unfortunately there isn't a way to attach a B102 to a standard Pi - the 15pin to 22pin adapters are not reversible. The FFC cable on the one that was working is fairly kinked, so if nothing else I can try swapping the cables. It'd be nice to know what the cause of the failure was, but probably just static onto the CSI lines (shame it's that sensitive).
6by9 commentedon May 7, 2020
@pelwell Any thoughts as to any setup that has changed only on Pi4 between 4.19 and 5.4 that would trip I2C this up?
We have got Maxime's updated clock driver, but that applies to both Pi3 and Pi4.
pelwell commentedon May 7, 2020
There's nothing specific to Pi 4 that I'm aware of that only affects I2C. It's probably worth making sure the EEPROM is up-to-date:
mdevaev commentedon May 7, 2020
@6by9
Made with both kernels. It didn't affect anything.
@pelwell
pelwell commentedon May 11, 2020
There are a lot of under-voltage warnings in your "i2c" log above. Either you are using a bad power supply or you are trying to power too much from your Pi.
The Pi 4 includes under-voltage detection logic because there is a real possibility your Pi will malfunction in some way or other. Every silicon die is unique in its analogue electrical properties, causing the voltage tolerance to vary between devices, but as you reduce the voltage gradually eventually the weakest link in the chain will break. If you're lucky, one of the ARM cores will panic immediately, but the failure could be memory corruption that has time to propagate and perhaps even make it to persistent storage.
You won't get support here until the under-voltage is resolved - it's not in your best interests.
mdevaev commentedon May 11, 2020
(Sorry for the deleted message, I attached the wrong log)
@pelwell Okay, good point. I changed the power supply to a more powerful one and again successfully reproduced the problem, but this time without a single report of power problems.
The terminal log is attached. Messages may differ slightly from launch to launch (as I've shown before), but it always starts with I2C messages.
screenlog.txt
mdevaev commentedon May 11, 2020
I understand that the problem looks strange. But it really exists not only for me, but for five other users that I know. All of them updated the kernel to 5.4 on RPi4 and all of them started having problems with B101 by I2C.
I have excluded all previous assumptions about the nature of this bug. How else can I help fix it?
pelwell commentedon May 11, 2020
I'm starting to think that I2C is just collateral damage caused by a firmware lockup.
Your original reports says "an attempt to get an image from the tc358743 device twice in a row (reopen device file) results [in] I2C timeouts." Let's see if we can narrow down the cause of the failure by breaking the process down into a sequence of smaller steps.
367 remaining items
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts
media: bcm2835-unicam: Always service interrupts