Division by zero in kernel (DVB-T or USB driver issue)

Hi,

I’m trying to use USB2 DVB-T PCTV Diversity Stick Solo with my Turris Omnia router.

I was trying to reproduce it on my notebook but I didn’t succeed - everything worked perfect. With kernel 4.9 and 4.4.39 I prepared for the test.

First problem - division by zero in kernel - it seems that dib0700 driver is not much error prone and can easily get to this

[72567.294325] DiB0070 I2C read failed
[72572.293968] DiB0070 I2C write failed
[72652.308181] Division by zero in kernel.
[72652.312050] CPU: 0 PID: 4232 Comm: kdvb-ad-0-fe-0 Not tainted 4.4.39-80079e1c1e5f9ca7ad734044462a761a-4 #1
[72652.312054] Hardware name: Marvell Armada 380/385 (Device Tree)
[72652.312058] Backtrace:
[72652.312070] [<c001c604>] (dump_backtrace) from [<c001c7f4>] (show_stack+0x18/0x1c)
[72652.312073]  r6:00000000 r5:60000013 r4:c06ae224 r3:00000000
[72652.312085] [<c001c7dc>] (show_stack) from [<c02e9c04>] (dump_stack+0x98/0xac)
[72652.312090] [<c02e9b6c>] (dump_stack) from [<c001c760>] (__div0+0x1c/0x20)
[72652.312093]  r6:00000000 r5:00000000 r4:ece26000 r3:00000000
[72652.312102] [<c001c744>] (__div0) from [<c000df3c>] (Ldiv0+0x8/0x10)
[72652.312137] [<bfac34e8>] (dib7000p_set_frontend [dib7000p]) from [<bf8bf444>] (dvb_ca_en50221_thread+0x8b0/0xa10 [dvb_core])
[72652.312140]  r10:c06ce90c r9:e9798c00 r8:ece26244 r7:25ca1280 r6:00000002 r5:ece26000
[72652.312149]  r4:e9798c00
[72652.312167] [<bf8bf368>] (dvb_ca_en50221_thread [dvb_core]) from [<bf8c0388>] (dvb_frontend_sleep_until+0xc80/0xcc0 [dvb_core])
[72652.312170]  r9:e9798c00 r8:e9798db0 r7:00000000 r6:ed2edf1c r5:ece26000 r4:e9798c00
[72652.312192] [<bf8c014c>] (dvb_frontend_sleep_until [dvb_core]) from [<bf8c095c>] (dvb_frontend_thread+0x35c/0x530 [dvb_core])
[72652.312194]  r6:ed2edf1c r5:ece26000 r4:00000000
[72652.312209] [<bf8c0600>] (dvb_frontend_thread [dvb_core]) from [<c00439d8>] (kthread+0xf0/0x104)
[72652.312212]  r10:00000000 r9:00000000 r8:00000000 r7:bf8c0600 r6:ece26000 r5:00000000
[72652.312220]  r4:ed5f3e80
[72652.312227] [<c00438e8>] (kthread) from [<c0009db8>] (ret_from_fork+0x14/0x3c)
[72652.312230]  r7:00000000 r6:00000000 r5:c00438e8 r4:ed5f3e80
[73078.727324] DiB0070 I2C read failed
[73083.726962] DiB0070 I2C write failed

I tried to analyze it a bit and send mail but I got no reaction:
https://www.spinics.net/lists/linux-media/msg108524.html
and today I found even patch (which predates my mail):
https://patchwork.linuxtv.org/patch/38639/

It would be great if you could adopt it.

Second problem - there is too much of I2C read/write errors - I believe that is more related to root cause and division by zero is mere consequence of poor error handling.

My friend Oliver Neukum suspects DMA transfers and I found some upstream commits addressing DMA transfers:

426398b15d9f18ce3e7b5c4e657b4c0103dd8389
fa1ecd8dc454fe2d3075a964240f45ceb60cb9e0
bd1f976cc95b0689f889c8d93434ee61dd09b08b

Would that be possible to backport them? (It seems to apply cleanly)

The code look bad without it, but still I don’t think it is the root cause.

Do you know about any problems of USB on Turris Omnia?

Thanks in advance.

Tomáš Čech

To back theory with USB problem I digged also this:

[90617.822603] DiB0070 I2C write failed
[90619.292482] DiB0070 I2C read failed
[90619.292491] DiB0070 I2C write failed
[90620.762375] DiB0070 I2C read failed
[90620.762384] DiB0070 I2C write failed
[90622.059165] dvb-usb: Pinnacle PCTV Dual DVB-T Diversity Stick successfully deinitialized and disconnected.
[90622.342273] usb 4-1: new high-speed USB device number 7 using xhci-hcd
[90622.482793] usb 4-1: device descriptor read/all, error -71
[90622.662249] usb 4-1: new high-speed USB device number 8 using xhci-hcd
[90622.782304] usb 4-1: device descriptor read/64, error -71
[90623.032302] usb 4-1: device descriptor read/all, error -71
[90623.212203] usb 4-1: new full-speed USB device number 9 using xhci-hcd
[90623.212299] usb 4-1: Device not responding to setup address.
[90623.422272] usb 4-1: Device not responding to setup address.
[90623.632169] usb 4-1: device not accepting address 9, error -71
[90623.812161] usb 4-1: new full-speed USB device number 10 using xhci-hcd
[90623.812257] usb 4-1: Device not responding to setup address.
[90624.022231] usb 4-1: Device not responding to setup address.
[90624.232128] usb 4-1: device not accepting address 10, error -71
[90624.238105] usb usb4-port1: unable to enumerate USB device

I reached Martin Wache by e-mail and got interesting points.

  • he was using the same device as I with different ARM boards for years and he sometimes had I2C error messages but never division by zero in kernel. Last working was Cubietruck with kernel 3.16.0

  • his problems started with Intel based system with Ubuntu 16.04 (it seems to have kernel 4.4)

This makes the error less likely to be related to architecture.

@brill Any known issues with USB? Any objections regarding patches?