h0tw1r3 / dvbhdhomerun

hdhomerun dvb driver for linux with working debian packaging!
GNU General Public License v2.0
30 stars 10 forks source link

Kernel cannot add device #7

Closed fossum closed 8 years ago

fossum commented 8 years ago

After getting your code to compile and load into my computer I noticed the dmesg had some errors in it. Seems to be a bad pointer somewhere in your code. I've attached my dmesg output, hopefully you know how to decipher it.

I did see that there is a failure early on

[   16.531894] DVB: registering new adapter (HDHomeRun)
[   16.531896] vmalloc: allocation failure: 18446743833813787648 bytes
[   16.531897] userhdhomerun: page allocation failure: order:0, mode:0xd2

I tried increasing my vmalloc in grub (not sure if it worked), but I didn't increase it by 18,446,743 terabytes either.

dmesg.txt

System Info: Running in ESXi system Fresh install of Ubuntu 15.04 x64

Steps to reproduce:

  1. Install Ubuntu
  2. Install compile tools
  3. Run dpkg-buildinstall -i
Liontooth commented 8 years ago

I get exactly the same error on a Debian Jessie installation from yesterday. A workaround is to block the module from loading on boot by adding this to the file /etc/modprobe.d/blacklist-dvb_hdhomerun.conf:

install dvb_hdhomerun /bin/true

After boot, uncomment this line and try "modprobe dvb_hdhomerun" manually; that works for me. That said, I still get a kernel oops on userhdhomerun, possibly caused by the same bug, here identified as "BUG: unable to handle kernel NULL pointer dereference at 0000000000000491". It's triggered when attempting to create the device node:

Dec 21 09:19:06 durga kernel: [  528.342788] hdhomerun: userhdhomerun connected
Dec 21 09:19:06 durga kernel: [  528.342952] hdhomerun: userhdhomerun connected
Dec 21 09:19:06 durga kernel: [  528.343073] hdhomerun: creating dvb device for 103AD935-0
Dec 21 09:19:06 durga kernel: [  528.343212] BUG: unable to handle kernel NULL pointer dereference at 0000000000000491
Dec 21 09:19:06 durga kernel: [  528.343443] IP: [<ffffffff812b1fa8>] strncmp+0x8/0x50
Dec 21 09:19:06 durga kernel: [  528.343592] PGD dea9f067 PUD d98b2067 PMD 0 
Dec 21 09:19:06 durga kernel: [  528.343838] Oops: 0000 [#2] SMP 
Dec 21 09:19:06 durga kernel: [  528.344028] Modules linked in: dvb_hdhomerun_fe(O) dvb_hdhomerun(O) dvb_hdhomerun_core(O) dvb_core nfsd auth_rpcgss oid_registry nfs_acl nfs lockd fscache sunrpc xfs crc32c_generic libcrc32c kvm_amd dcdbas kvm ipmi_devintf evdev pcspkr psmouse serio_raw ttm drm_kms_helper drm amd64_edac_mod ipmi_si acpi_power_meter k10temp edac_mce_amd ipmi_msghandler edac_core tpm_tis i2c_algo_bit tpm button sp5100_tco processor shpchp i2c_piix4 thermal_sys i2c_core autofs4 ext4 crc16 mbcache jbd2 dm_mod raid1 md_mod sg sd_mod crc_t10dif crct10dif_generic crct10dif_common ata_generic ohci_pci ohci_hcd ehci_pci ehci_hcd ahci pata_atiixp libahci libata mpt2sas raid_class scsi_transport_sas usbcore scsi_mod usb_common bnx2 [last unloaded: dvb_hdhomerun_core]
Dec 21 09:19:06 durga kernel: [  528.348447] CPU: 1 PID: 1018 Comm: userhdhomerun Tainted: G      D    O  3.16.0-4-amd64 #1 Debian 3.16.7-ckt20-1+deb8u1
Dec 21 09:19:06 durga kernel: [  528.348585] Hardware name: Dell Inc. PowerEdge R415/0YFVT1, BIOS 2.3.0 10/24/2014
Dec 21 09:19:06 durga kernel: [  528.348712] task: ffff880214ed6390 ti: ffff8800d9f48000 task.ti: ffff8800d9f48000
Dec 21 09:19:06 durga kernel: [  528.348839] RIP: 0010:[<ffffffff812b1fa8>]  [<ffffffff812b1fa8>] strncmp+0x8/0x50
Dec 21 09:19:06 durga kernel: [  528.349018] RSP: 0018:ffff8800d9f4be20  EFLAGS: 00010206
Dec 21 09:19:06 durga kernel: [  528.349112] RAX: ffff880214054000 RBX: 0000000000000000 RCX: 0000000000000031
Dec 21 09:19:06 durga kernel: [  528.349213] RDX: 000000000000000a RSI: 0000000000000491 RDI: ffff8800d9f4beb5
Dec 21 09:19:06 durga kernel: [  528.349328] RBP: 00007ffed70d5ff0 R08: 0000000000000000 R09: ffff8800000ba9e0
Dec 21 09:19:06 durga kernel: [  528.349428] R10: 0000000000000418 R11: ffff8800d9f4bbee R12: 0000000000000000
Dec 21 09:19:06 durga kernel: [  528.349529] R13: 0000000000000001 R14: ffff8800d9f4beb5 R15: ffff8800d9f4beb4
Dec 21 09:19:06 durga kernel: [  528.349629] FS:  00007f00c8781740(0000) GS:ffff88021ee20000(0000) knlGS:0000000000000000
Dec 21 09:19:06 durga kernel: [  528.349758] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
Dec 21 09:19:06 durga kernel: [  528.349854] CR2: 0000000000000491 CR3: 00000000da0a4000 CR4: 00000000000007e0
Dec 21 09:19:06 durga kernel: [  528.349954] Stack:
Dec 21 09:19:06 durga kernel: [  528.350038]  ffffffffa05a538c ffff8800d9f4bea0 00007ffed70d5ff0 00000000c01c7600
Dec 21 09:19:06 durga kernel: [  528.350368]  00007ffed70d5ff0 0000000001e2e0c0 ffffffff8150b02c 0000000000000010
Dec 21 09:19:06 durga kernel: [  528.350726]  ffff8800d9f4beb0 ffff8800d9f4be70 0000000000000005 00000000c01c7600
Dec 21 09:19:06 durga kernel: [  528.351057] Call Trace:
Dec 21 09:19:06 durga kernel: [  528.351145]  [<ffffffffa05a538c>] ? dvb_hdhomerun_register_hdhomerun+0x5c/0x590 [dvb_hdhomerun]
Dec 21 09:19:06 durga kernel: [  528.351278]  [<ffffffff8150b02c>] ? printk+0x54/0x56
Dec 21 09:19:06 durga kernel: [  528.351373]  [<ffffffffa05a617f>] ? hdhomerun_control_ioctl+0x10f/0x1b0 [dvb_hdhomerun]
Dec 21 09:19:06 durga kernel: [  528.351503]  [<ffffffff811ba7ff>] ? do_vfs_ioctl+0x2cf/0x4b0
Dec 21 09:19:06 durga kernel: [  528.351600]  [<ffffffff810782c5>] ? ptrace_notify+0x55/0x80
Dec 21 09:19:06 durga kernel: [  528.351698]  [<ffffffff81020d87>] ? syscall_trace_enter+0x97/0x210
Dec 21 09:19:06 durga kernel: [  528.351823]  [<ffffffff811baa61>] ? SyS_ioctl+0x81/0xa0
Dec 21 09:19:06 durga kernel: [  528.351919]  [<ffffffff81513e7c>] ? tracesys+0x7e/0xc7
Dec 21 09:19:06 durga kernel: [  528.352013]  [<ffffffff81513edf>] ? system_call_trace_compare_end+0x10/0x15
Dec 21 09:19:06 durga kernel: [  528.352113] Code: 46 ff 75 0f 84 c0 75 eb 31 c0 c3 0f 1f 84 00 00 00 00 00 19 c0 83 c8 01 c3 66 2e 0f 1f 84 00 00 00 00 00 48 85 d2 74 38 0f b6 0f <44> 0f b6 06 44 38 c1 75 2f 84 c9 74 28 48 83 ea 01 31 c0 eb 1b 
Dec 21 09:19:06 durga kernel: [  528.355713] RIP  [<ffffffff812b1fa8>] strncmp+0x8/0x50
Dec 21 09:19:06 durga kernel: [  528.355858]  RSP <ffff8800d9f4be20>
Dec 21 09:19:06 durga kernel: [  528.355946] CR2: 0000000000000491
Dec 21 09:19:06 durga kernel: [  528.356063] ---[ end trace 14143cdbf4b3d2da ]---

So userhdhomerun correctly reads and interprets the configuration file:

Mon Dec 21 08:03:21 2015 Name of device: 103A7494-1
Mon Dec 21 08:03:21 2015 Tuner type set to "ATSC" based on conf file
Mon Dec 21 08:03:21 2015 Tuner: 1
Mon Dec 21 08:03:21 2015 Set initial pass-all filter for tuner: 1
Mon Dec 21 08:03:21 2015 
Mon Dec 21 08:03:21 2015 Registered tuner, id from kernel: 0 name: 103A7494-0

But strace shows the program hanging here:

open("/dev/hdhomerun_control", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 9
pipe([10, 11])                          = 0
open("/dev/hdhomerun_control", O_RDONLY) = 12
ioctl(12, SONYPI_IOCGBRT or SONYPI_IOCSBRT

I verified the device node is correct:

l /dev/hdhomerun_control

crw-rw---- 1 root video 10, 59 Dec 21 07:56 /dev/hdhomerun_control

Cheers, Dave

h0tw1r3 commented 8 years ago

Can you try the latest checkout (fa3795a1ce28751a34d5ee73b62ef8b24405f44b)?

I actually don't use a deb based distro anymore. Will be adding rpm support eventually.

fossum commented 8 years ago

Dear Jesus, that worked. How'd you get 4-5 commits in already!? Anywho, thanks for the support. If you need someone to attempt this on Fedora or Ubuntu, I could help out.

fossum commented 8 years ago

Umm... actually I take that back. It worked on my test fresh install box, but I'm still having issues with the production system. I'm going to update to the Silicon Dust libhdhome run and see if that helps. PS - I think Liontooth's fix is needed on top of this code update. After initial inspection, it could be due to me running 15.10 on the production box and 14.04 on the temp. I also have an existing tuner card in the production box. Any ideas on a fix?

See the creating dvb device for 13226520-1? It should get to -2 in a working system. dmesg2.txt

[    6.004480] hdhomerun: userhdhomerun connected
[    6.004500] hdhomerun: userhdhomerun connected
[    6.004508] hdhomerun: creating dvb device for 13226520-0
[    6.004590] DVB: registering new adapter (HDHomeRun)
[    6.045751] HDHomeRun HDHomeRun.0: DVB: registering adapter 0 frontend 0 (HDHomeRun ATSC)...
[    6.045787] HDHomeRun0: DVB Frontend registered
[    6.045788] HDHomeRun0: Registered DVB adapter0
[    6.045806] hdhomerun: device /dev/hdhomerun_data0 created
[    6.045846] hdhomerun: userhdhomerun connected
[    6.045849] hdhomerun: creating dvb device for 13226520-1
[    6.045879] DVB: registering new adapter (HDHomeRun)
[    6.046509] HDHomeRun HDHomeRun.1: DVB: registering adapter 1 frontend 0 (HDHomeRun ATSC)...
[    6.046525] HDHomeRun1: DVB Frontend registered
[    6.046526] HDHomeRun1: Registered DVB adapter1
[    6.046541] hdhomerun: device /dev/hdhomerun_data1 created
[    6.046554] hdhomerun: userhdhomerun connected
[    6.046556] hdhomerun: creating dvb device for 13226520-2
[    6.046573] DVB: registering new adapter (HDHomeRun)
[    6.046782] HDHomeRun HDHomeRun.2: DVB: registering adapter 2 frontend 0 (HDHomeRun ATSC)...
[    6.046800] HDHomeRun2: DVB Frontend registered
[    6.046801] HDHomeRun2: Registered DVB adapter2
[    6.046815] hdhomerun: device /dev/hdhomerun_data2 created
[    6.046855] hdhomerun: userhdhomerun connected
h0tw1r3 commented 8 years ago

I just tested 4.2.5 kernel (Fedora). Everything builds, modules load, and userspace adds the DVB devices (tested HDHR3-US).

21:02|h0tw1r3|0|6</debian/$ sudo lsdvb

            lsdvb: Simple utility to list PCI/PCIe DVB devices
            Version: 0.0.4
            Copyright (C) Manu Abraham

HDHomeRun (5:0 -1674250664:32591) on PCI Domain:-1680393416 Bus:32591 Device:2099 Function:0
    DEVICE:0 ADAPTER:0 FRONTEND:0 (HDHomeRun ATSC 103C1101-0)
             FE_ATSC Fmin=54MHz Fmax=858MHz
    DEVICE:0 ADAPTER:1 FRONTEND:0 (HDHomeRun ATSC 103C1101-1)
             FE_ATSC Fmin=54MHz Fmax=858MHz

Just a guess, but perhaps dkms did not rebuild? Try pulling master again (commit a8837cf) and rebuilding the packages. Bumped the debian version which should trigger a dkms rebuild.

fossum commented 8 years ago

K, so verified a8837cf changeset and deleted all ../hdhomerun-* files. Then dpkg-buildpackage -b, cd .., sudo dpkg -i dvbhdhomerun-*, sudo shutdown -r now, dmesg

Output: dmesg.txt

PS - I have some time on my hands and I can program. In case you'd like some help...

fossum commented 8 years ago

Seems the hdhomerun_control doesn't have the right permissions:

ericfoss@mediaserver:~$ ls -l /dev/hd*
-rw-r--r-- 1 root root 0 Dec 22 21:40 /dev/hdhomerun_control
ericfoss@mediaserver:~$

Even though I have the /lib/udev/rules.d/59-dvbhdhomerun-utils.rules file

KERNEL=="hdhomerun_data[0-9]*", GROUP="video"
KERNEL=="hdhomerun_control", GROUP="video"
h0tw1r3 commented 8 years ago

Personally verified working on Ubuntu 15.10.

Check dkms to make sure you're using the correct modules.

dvbhdhomerun, 0.0.16+nmu4, 4.2.0-22-generic, x86_64: installed

If it looks the same, try purging the installed packages, and building from source again.

Liontooth commented 8 years ago

If the device node /dev/hdhomerun_control is incorrect, remove it and reinsert the dvb_hdhomerun module to recreate it.

The patches work; I rebuilt dvbhdhomerun from the latest version on Debian Jessie with a 3.16.0-4-amd64 kernel. Running userhdhomerun works, and the devices are seen by tvheadend. Very cool!