Bug 194171 - em28xx DVB-T2 USB card can't be unplugged and fails to hibernate/resume
Summary: em28xx DVB-T2 USB card can't be unplugged and fails to hibernate/resume
Status: NEW
Alias: None
Product: v4l-dvb
Classification: Unclassified
Component: em28xx (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: em28xx
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-06 20:02 UTC by bjoernv
Modified: 2017-11-01 15:22 UTC (History)
1 user (show)

See Also:
Kernel Version: 4.13.9
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Recording a TV show; unplugging the device; Kernel crash with general protection fault (20.55 KB, text/x-log)
2017-02-06 20:02 UTC, bjoernv
Details
Recording a TV show; unloading the em28xx modules with "chvt 10;modprobe -v -r em28xx_dvb; modprobe -v -r em28xx_rc"; Kernel crash with Oops in dvb_frontend_stop (8.94 KB, text/x-log)
2017-02-06 20:06 UTC, bjoernv
Details
Patch for Kernel 4.10.1 which introduces NULL pointer checks and some debugging code (1.09 KB, patch)
2017-03-01 19:41 UTC, bjoernv
Details | Diff
Kernel 4.10.1 with patch (only logging, no NULL pointer check); stopping DVB media player; switching to console 10; removing device (8.17 KB, text/plain)
2017-03-01 19:49 UTC, bjoernv
Details
The updated patch adds two new checks to avoid NPEs (1.33 KB, patch)
2017-03-04 21:41 UTC, bjoernv
Details | Diff
Kernel 4.13.9 with patch (logging, NULL pointer check); suspend/resume; removing device (80.94 KB, text/plain)
2017-10-30 21:41 UTC, bjoernv
Details

Description bjoernv 2017-02-06 20:02:44 UTC
Created attachment 254341 [details]
Recording a TV show; unplugging the device; Kernel crash with general protection fault

The Hauppauge WinTV-soloHD card with em28178 chipset (an external USB TV device) works correctly in normal use.

But several actions with this USB device fail.

1) The device is not waked up correctly after hibernate and resume. There are no log messages, but the DVB software can't tune a channel anymore after that.

2) If the USB device is unplugged, the Kernel often freezes. The freezes occur regardless, if the device is unplugged physically or with the "unplug simulation". It is much more likely, that the Kernel freezes, if the device is in use, e.g. recording a TV show or fetching EIT (Event Information Table) data.

Testing:
- Record a show
- physical unplug the device
- unplugging with a simulation

  lsusb -t
  # e.g. the em28xx device is listed on 3-1.3
  echo 3-1.3 > /sys/bus/usb/drivers/usb/unbind

3) The driver often can't be unloaded without a Kernel freeze. Unloading the em28xx modules can be used to work-around the hibernate/resume problem. But often unloading fails.

I attach "dmesg" output for actions 2) and 3). For 1) I could not get a stacktrace until now.
Comment 1 bjoernv 2017-02-06 20:06:00 UTC
Created attachment 254351 [details]
Recording a TV show; unloading the em28xx modules with "chvt 10;modprobe -v -r em28xx_dvb; modprobe -v -r em28xx_rc"; Kernel crash with Oops in dvb_frontend_stop
Comment 2 bjoernv 2017-03-01 19:40:27 UTC
Debugging shows, that the pointers fepriv and fe->dvb in dvb_frontend_stop are sometimes NULL, if the USB device is removed or if the kernel module is removed. This causes null pointer exceptions. A possible reason is, that the DVB frontend is stopped first time, if the media player stops accessing the DVB card. Later the card is stopped a second time with dvb_frontend_stop.

I wrote a patch which logs the pointers fepriv and fe->dvb and some other variables. The patch also introduces NULL pointer checks for fepriv and fe->dvd.

At least the crashes for my setup are fixed with the patch.
Comment 3 bjoernv 2017-03-01 19:41:34 UTC
Created attachment 255027 [details]
Patch for Kernel 4.10.1 which introduces NULL pointer checks and some debugging code
Comment 4 bjoernv 2017-03-01 19:49:47 UTC
Created attachment 255029 [details]
Kernel 4.10.1 with patch (only logging, no NULL pointer check); stopping DVB media player; switching to console 10; removing device
Comment 5 Walther Pelser 2017-03-02 17:20:15 UTC
Please look at:
https://bugzilla.kernel.org/show_bug.cgi?id=109521
https://bugzilla.kernel.org/show_bug.cgi?id=191891
https://bugzilla.kernel.org/show_bug.cgi?id=193901
All the same problems
I wrote today to
linux-usb@vger.kernel.org

"Hallo!

I have the same problems with my DVB-T2 USB-Stick.
August DVB-T210 (V 2.0) is detected by kernel as

Mygica T230 DVB-T/T2/C

which is the same as Geniatech 230.

Tested: Kernel 4.10.1.:
"....no frontend was attached...."

Latest working kernel for me is Kernel 4.4.X. with firmware from openELEC.(dvb-demod-si2168-b40-01.fw  (V 11) and dvb-tuner-si2158-a20-01.fw).

W.Pelser"

My working around to solve the hibernate-Problem is building my own kernel with build-in firmware. Only up to kernel 4.4.x

W.Pelser
Comment 6 bjoernv 2017-03-04 21:41:22 UTC
Created attachment 255077 [details]
The updated patch adds two new checks to avoid NPEs
Comment 7 Walther Pelser 2017-03-20 13:42:01 UTC
Hibernating-problem of Mygica T230 DVB-T/T2/C is solved with kernel 4.11-rc2.
Comment 8 Walther Pelser 2017-03-20 13:49:37 UTC
Kernel does not crash after disconnection Mygica T230 DVB-T/T2/C during recording since version 4.11-rc2.
Comment 9 bjoernv 2017-10-30 21:41:32 UTC
Created attachment 260445 [details]
Kernel 4.13.9 with patch (logging, NULL pointer check); suspend/resume; removing device

Unfortunately also with my patches, sometimes unloading this em28xx modules still fails. The dmesg log is made with Kernel 4.13.9. I remove the em28xx directly after resume from suspend, because otherwise (without removing and loading) the module with not work after suspend/resume.

Note You need to log in before you can comment on or make changes to this bug.