Bug 73361 - device or resource busy errors with linux kernel 3.14
Summary: device or resource busy errors with linux kernel 3.14
Status: RESOLVED CODE_FIX
Alias: None
Product: v4l-dvb
Classification: Unclassified
Component: saa7134 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Hans Verkuil
URL:
Keywords:
: 73031 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-04-02 06:03 UTC by Hussam Al-Tayeb
Modified: 2014-08-04 16:05 UTC (History)
6 users (show)

See Also:
Kernel Version: 3.14
Subsystem:
Regression: Yes
Bisected commit-id:


Attachments
Fix for saa7134 (1.27 KB, patch)
2014-04-16 13:32 UTC, Hans Verkuil
Details | Diff

Description Hussam Al-Tayeb 2014-04-02 06:03:25 UTC
After updating to kernel 3.14, I am having problems with the saa7134 card.
On boot, tvtime works fine.
1. I close tvtime. I open it again. 
2. I get Device or resource busy for device /dev/video0
3. I do rmmod saa7134 and modprobe saa7134.
4. tvtime works again.

I close tvtime and reopen it and it is broken again till I rmmod/modprobe the driver.

dmesg says:

[  154.247653] u32 classifier
[  154.247657]     input device check on
[  154.247658]     Actions configured
[  460.045656] perf samples too long (2501 > 2500), lowering kernel.perf_event_max_sample_rate to 50100
[  480.531689] tvtime[896]: segfault at 798 ip 0000000000408f70 sp 00007fff8809f118 error 4 in tvtime[400000+90000]
[  510.466958] tuner-simple 1-0060: destroying instance
[  515.107187] saa7130/34: v4l2 driver version 0, 2, 17 loaded
[  515.107233] saa7130[0]: found at 0000:04:05.0, rev: 1, irq: 20, latency: 32, mmio: 0xfe120000
[  515.107238] saa7130[0]: subsystem: 1131:0000, board: LifeView/Typhoon FlyVIDEO2000 [card=3,insmod option]
[  515.107256] saa7130[0]: board init: gpio is 807f
[  515.107257] saa7130[0]: there are different flyvideo cards with different tuners
saa7130[0]: out there, you might have to use the tuner=<nr> insmod
saa7130[0]: option to override the default value.
[  515.107279] Registered IR keymap rc-flyvideo
[  515.107352] input: saa7134 IR (LifeView/Typhoon Fl as /devices/pci0000:00/0000:00:1e.0/0000:04:05.0/rc/rc0/input16
[  515.107405] rc0: saa7134 IR (LifeView/Typhoon Fl as /devices/pci0000:00/0000:00:1e.0/0000:04:05.0/rc/rc0
[  515.210172] saa7130[0]: Huh, no eeprom present (err=-5)?
[  515.223296] All bytes are equal. It is not a TEA5767
[  515.223325] tuner 1-0060: Tuner -1 found with type(s) Radio TV.
[  515.229960] tuner-simple 1-0060: creating new instance
[  515.229964] tuner-simple 1-0060: type set to 5 (Philips PAL_BG (FI1216 and compatibles))
[  515.250103] saa7130[0]: registered device video0 [v4l2]
[  515.257371] saa7130[0]: registered device vbi0
[  515.257447] saa7130[0]: registered device radio0
[  528.930449] tvtime[949]: segfault at 798 ip 0000000000408f70 sp 00007fff1cceb568 error 4 in tvtime[400000+90000]
[  538.133501] tuner-simple 1-0060: destroying instance
[  539.180816] saa7130/34: v4l2 driver version 0, 2, 17 loaded
[  539.180872] saa7130[0]: found at 0000:04:05.0, rev: 1, irq: 20, latency: 32, mmio: 0xfe120000
[  539.180878] saa7130[0]: subsystem: 1131:0000, board: LifeView/Typhoon FlyVIDEO2000 [card=3,insmod option]
[  539.180898] saa7130[0]: board init: gpio is 807f
[  539.180900] saa7130[0]: there are different flyvideo cards with different tuners
saa7130[0]: out there, you might have to use the tuner=<nr> insmod
saa7130[0]: option to override the default value.
[  539.180927] Registered IR keymap rc-flyvideo
[  539.181009] input: saa7134 IR (LifeView/Typhoon Fl as /devices/pci0000:00/0000:00:1e.0/0000:04:05.0/rc/rc0/input17
[  539.181061] rc0: saa7134 IR (LifeView/Typhoon Fl as /devices/pci0000:00/0000:00:1e.0/0000:04:05.0/rc/rc0
[  539.283487] saa7130[0]: Huh, no eeprom present (err=-5)?
[  539.296626] All bytes are equal. It is not a TEA5767
[  539.296646] tuner 1-0060: Tuner -1 found with type(s) Radio TV.
[  539.303294] tuner-simple 1-0060: creating new instance
[  539.303298] tuner-simple 1-0060: type set to 5 (Philips PAL_BG (FI1216 and compatibles))
[  539.323430] saa7130[0]: registered device video0 [v4l2]
[  539.323606] saa7130[0]: registered device vbi0
[  539.323639] saa7130[0]: registered device radio0
Comment 1 Hussam Al-Tayeb 2014-04-02 06:04:59 UTC
cat /etc/modprobe.d/saa7134.conf 
options saa7134 card=3 tuner=5
Comment 2 Boyan 2014-04-06 18:45:14 UTC
I have the same problem.
My card is:

 subsystem: 5168:0138, board: LifeView FlyVIDEO3000 [card=2,insmod option]

Git bisect shows that the problem is in commit:

9db0fb182ea8a42c5bfd322b169d65728721fd71 is the first bad commit
commit 9db0fb182ea8a42c5bfd322b169d65728721fd71
Author: Hans Verkuil <hans.verkuil@cisco.com>
Date:   Sat Dec 14 08:28:23 2013 -0300

    [media] saa7134: move the queue data from saa7134_fh to saa7134_dev
    
    These fields are global, not per-filehandle.
    
    Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
    Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>



git bisect start 'drivers/media/pci/saa7134/'
# good: [d8ec26d7f8287f5788a494f56e8814210f0e64be] Linux 3.13
git bisect good d8ec26d7f8287f5788a494f56e8814210f0e64be
# bad: [455c6fdbd219161bd09b1165f11699d6d73de11c] Linux 3.14
git bisect bad 455c6fdbd219161bd09b1165f11699d6d73de11c
# bad: [95075dd01e715dbc03936e3045e95068f0126416] [media] saa7134: use V4L2_IN_ST_NO_SIGNAL instead of NO_SYNC
git bisect bad 95075dd01e715dbc03936e3045e95068f0126416
# bad: [b93a18d56057a6f8ccb79c5cd085dd31395331ff] [media] saa7134: cleanup radio/video/empress ioctl handling
git bisect bad b93a18d56057a6f8ccb79c5cd085dd31395331ff
# bad: [9db0fb182ea8a42c5bfd322b169d65728721fd71] [media] saa7134: move the queue data from saa7134_fh to saa7134_dev
git bisect bad 9db0fb182ea8a42c5bfd322b169d65728721fd71
# good: [258d2fbf874c87830664cb7ef41f9741c1abffac] Merge tag 'v3.13-rc1' into patchwork
git bisect good 258d2fbf874c87830664cb7ef41f9741c1abffac
# first bad commit: [9db0fb182ea8a42c5bfd322b169d65728721fd71] [media] saa7134: move the queue data from saa7134_fh to saa7134_dev
Comment 3 Boyan 2014-04-06 19:15:45 UTC
I'll have to make full bisect, because 3.14 with whole saa7134 directory doesn't work too.
Comment 4 Boyan 2014-04-06 20:35:33 UTC
Please ignore comment 3. I thought that compiling kernel 3.14 with whole saa7134 directory would work, but it didn't finished successfully. I'm confirming that this is the first bad commit after full bisect between 3.13 and 3.14:

9db0fb182ea8a42c5bfd322b169d65728721fd71 is the first bad commit
commit 9db0fb182ea8a42c5bfd322b169d65728721fd71
Author: Hans Verkuil <hans.verkuil@cisco.com>
Date:   Sat Dec 14 08:28:23 2013 -0300

    [media] saa7134: move the queue data from saa7134_fh to saa7134_dev
    
    These fields are global, not per-filehandle.
    
    Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
    Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Comment 5 Hans Verkuil 2014-04-16 13:32:54 UTC
Created attachment 132471 [details]
Fix for saa7134

This patch should fix the saa7134 driver.

The problem is caused by unusual tvtime behavior: when you stop it it called STREAMOFF, but then proceeds to queue new buffers for no good reason before it finally closed the file descriptor. The changes I made broke support for that behavior, causing the driver to think that streaming was still in progress since it still had buffers queued up.
Comment 6 Hans Verkuil 2014-04-16 13:54:55 UTC
*** Bug 73031 has been marked as a duplicate of this bug. ***
Comment 7 Hussam Al-Tayeb 2014-04-16 17:16:30 UTC
Sadly tvtime is no longer in development.
Comment 8 Hussam Al-Tayeb 2014-04-16 20:06:54 UTC
(In reply to Hans Verkuil from comment #5)
> Created attachment 132471 [details]
> Fix for saa7134
> 
> This patch should fix the saa7134 driver.
> 
> The problem is caused by unusual tvtime behavior: when you stop it it called
> STREAMOFF, but then proceeds to queue new buffers for no good reason before
> it finally closed the file descriptor. The changes I made broke support for
> that behavior, causing the driver to think that streaming was still in
> progress since it still had buffers queued up.

I rebuilt my kernel with that patch. it fixed the problem. thank you.
Comment 9 Hussam Al-Tayeb 2014-05-06 11:06:31 UTC
with this patch on kernel 3.14.2, i see this in systemd's journal when closing tvtime.

May 06 14:02:28 hades kernel: ------------[ cut here ]------------
May 06 14:02:28 hades kernel: WARNING: CPU: 1 PID: 3142 at kernel/power/qos.c:426 pm_qos_remove_request+0xea/0x
May 06 14:02:28 hades kernel: pm_qos_remove_request() called for unknown object
May 06 14:02:28 hades kernel: Modules linked in: nvidia(PO) w83627ehf hwmon_vid coretemp hwmon act_police sch_i
May 06 14:02:28 hades kernel:  button video processor vboxdrv(O) sg ext4 crc16 mbcache jbd2 sha256_ssse3 sha256
May 06 14:02:28 hades kernel: CPU: 1 PID: 3142 Comm: tvtime Tainted: P        W  O 3.14.2-1-ARCH #1
May 06 14:02:28 hades kernel: Hardware name:                  /DG31PR, BIOS PRG3110H.86A.0052.2008.0612.1910 06
May 06 14:02:28 hades kernel:  0000000000000000 000000003f568ede ffff8800b3a11d50 ffffffff8150984e
May 06 14:02:28 hades kernel:  ffff8800b3a11d98 ffff8800b3a11d88 ffffffff8106ab2d ffff8800aa45cf88
May 06 14:02:28 hades kernel:  ffff8800aa45cb78 ffff8800da5d6000 ffff8800ab663a00 ffff880119bf88e0
May 06 14:02:28 hades kernel: Call Trace:
May 06 14:02:28 hades kernel:  [<ffffffff8150984e>] dump_stack+0x4d/0x6f
May 06 14:02:28 hades kernel:  [<ffffffff8106ab2d>] warn_slowpath_common+0x7d/0xa0
May 06 14:02:28 hades kernel:  [<ffffffff8106abac>] warn_slowpath_fmt+0x5c/0x80
May 06 14:02:28 hades kernel:  [<ffffffff810bc28a>] pm_qos_remove_request+0xea/0x100
May 06 14:02:28 hades kernel:  [<ffffffffa06923fb>] video_release+0x2eb/0x380 [saa7134]
May 06 14:02:28 hades kernel:  [<ffffffffa065bb03>] ? videobuf_dma_free+0x73/0xc0 [videobuf_dma_sg]
May 06 14:02:28 hades kernel:  [<ffffffffa05df5d8>] v4l2_release+0x38/0x80 [videodev]
May 06 14:02:28 hades kernel:  [<ffffffff811bc4cc>] __fput+0x9c/0x240
May 06 14:02:28 hades kernel:  [<ffffffff811bc6be>] ____fput+0xe/0x10
May 06 14:02:28 hades kernel:  [<ffffffff8108c24f>] task_work_run+0xaf/0xe0
May 06 14:02:28 hades kernel:  [<ffffffff81016c55>] do_notify_resume+0x95/0xa0
May 06 14:02:28 hades kernel:  [<ffffffff81517860>] int_signal+0x12/0x17
May 06 14:02:28 hades kernel: ---[ end trace d20b9146dff8a269 ]---


I can still open tvtime again (without reloading the driver) and everything continues to work fine regardless of this error.

But it happens exactly after each time i close tvtime.
Comment 10 Boyan 2014-06-14 17:12:07 UTC
This patch worked for 3.14, but for 3.15 it doesn't help and is still not included in mainline. Still the same problem - Device or resource busy error when trying to open tvtime second time.
Comment 11 Hussam Al-Tayeb 2014-06-14 17:19:23 UTC
It works in 3.15 for me. I can open and close tvtime as many times as I want without unloading/reloading the driver.
But there is the error I see in dmesg everytime I close tvtime.
Hopefully the developers can have time to take another look by 3.16 :)
Comment 12 Boyan 2014-06-14 18:35:46 UTC
For me only kdetv doesn't break thing. With tvtime only the first time is working. I can see it pesent in 3.15rc1 from git, but I've successfully applied it in 3.15 - so it is not included, maybe reverted in final. It is not present in the patch-3.15.xz from kernel.org:

# unxz -c patch-3.15.xz |diffstat |grep saa7134
 b/drivers/media/pci/saa7134/saa7134- alsa.c                                           |    6 
 b/drivers/media/pci/saa7134/saa7134-cards.c                                          |    4 

The patch should change saa7134-video.c

I see an oops when removing saa7134-alsa in vanilla 3.15:


[ 1741.594635] BUG: unable to handle kernel NULL pointer dereference at 000001c8
[ 1741.594789] IP: [<f8110ce0>] snd_card_free+0x20/0x50 [snd]
[ 1741.594895] *pde = 00000000 
[ 1741.594936] Oops: 0002 [#1] PREEMPT SMP 
[ 1741.595006] Modules linked in: ipt_MASQUERADE iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack ip_tables w83627ehf hwmon_vid saa7134_alsa(-) tuner_simple tuner_types tuner radeon saa7134 drm_kms_helper ttm tveeprom videobuf_dma_sg videobuf_core drm v4l2_common snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel videodev snd_hda_controller i2c_piix4 snd_hda_codec i2c_algo_bit i2c_core snd_seq ohci_pci ehci_pci snd_seq_device ehci_hcd snd_pcm ohci_hcd snd_timer snd k10temp soundcore
[ 1741.596110] CPU: 0 PID: 2269 Comm: rmmod Not tainted 3.15.0 #1
[ 1741.596206] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./M3A785GXH/128M, BIOS P1.80 04/20/2010
[ 1741.596386] task: f54e0d90 ti: ef1f6000 task.ti: ef1f6000
[ 1741.596474] EIP: 0060:[<f8110ce0>] EFLAGS: 00010282 CPU: 0
[ 1741.596571] EIP is at snd_card_free+0x20/0x50 [snd]
[ 1741.596647] EAX: ef1f7f38 EBX: 00000000 ECX: f8117e94 EDX: ef1f7f3c
[ 1741.596754] ESI: 00000800 EDI: 00000000 EBP: ef1f6000 ESP: ef1f7f34
[ 1741.596861]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[ 1741.596950] CR0: 8005003b CR2: 000001c8 CR3: 2f1f0000 CR4: 000007d0
[ 1741.597056] Stack:
[ 1741.597072]  00000000 f89f0000 ef1f7f3c ef1f7f3c 00000002 f89f1573 ef1f7f5c f89f1ba0
[ 1741.597242]  c1085ddf 00000000 f89f1ba0 00000800 ef1f7f58 37616173 5f343331 61736c61
[ 1741.597410]  00000000 00000020 00000000 00000000 f534de00 f4125708 00000000 c15dbe70
[ 1741.597578] Call Trace:
[ 1741.597612]  [<f89f0000>] ? 0xf89effff
[ 1741.597670]  [<f89f1573>] ? saa7134_alsa_exit+0x13/0x40 [saa7134_alsa]
[ 1741.597786]  [<c1085ddf>] ? SyS_delete_module+0x10f/0x170
[ 1741.597879]  [<c10e4248>] ? mntput_no_expire+0x8/0x120
[ 1741.597965]  [<c1051526>] ? task_work_run+0x76/0xa0
[ 1741.598045]  [<c13f8386>] ? syscall_call+0x7/0xb
[ 1741.598115] Code: c4 10 5b 5e 5f 5d c3 8d 74 26 00 53 89 c3 b9 94 7e 11 f8 ba c1 6c 11 f8 83 ec 10 8d 44 24 04 c7 04 24 00 00 00 00 e8 10 7b f5 c8 <89> a3 c8 01 00 00 89 d8 e8 e3 fe ff ff 85 c0 89 c3 75 07 89 e0
[ 1741.598773] EIP: [<f8110ce0>] snd_card_free+0x20/0x50 [snd] SS:ESP 0068:ef1f7f34
[ 1741.598916] CR2: 00000000000001c8
[ 1741.633147] ---[ end trace 6b42b2854095019b ]---

The only changes in 3.15 for saa7134-alsa.c are in alsa_card_saa7134_create().
Comment 13 Hans Verkuil 2014-06-15 08:18:30 UTC
It's not yet in 3.15. Hopefully it will be part of a stable release of 3.15.

While 3.16 contains the fix, it also converts saa7134 to the videobuf2 framework which didn't have this particular problem.
Comment 14 Hussam Al-Tayeb 2014-08-04 16:05:41 UTC
I just updated to linux kernel 3.16 and the problem is not there. 
the error message is gone too.

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