Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
On Tue, 2011-05-24 at 21:03 -0500, Jonathan Nieder wrote: [...] Thanks again. This and related problems should be fixed by - 8a317a87 ([media] cx88: protect per-device driver list with device lock) - 1fe70e96 ([media] cx88: fix locking of sub-driver operations) - 1d6213ab ([media] cx88: hold device lock during sub-driver initialization) - 344d6c6b ([media] cx88: protect cx8802_devlist with a mutex) - 579b2b45 ([media] cx88: gracefully reject attempts to use unregistered cx88-blackbird driver) - f4bd4be8 ([media] cx88: don't use atomic_t for core-mpeg_users) which are as of yesterday part of Linus's master branch fwiw. Now also in 2.6.39.1 and queued for 2.6.39-2, thanks. Ben. -- Ben Hutchings Once a job is fouled up, anything done to improve it makes it worse. signature.asc Description: This is a digitally signed message part
Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
tags 619827 = upstream fixed-upstream quit Hi, Ben Hutchings wrote: On Sun, 2011-03-27 at 17:06 +0200, Huber Andreas wrote: Processes that try to open a cx88-blackbird driven MPEG device will hang up. [...] Could you test whether this patch fixes the problem? Thanks again. This and related problems should be fixed by - 8a317a87 ([media] cx88: protect per-device driver list with device lock) - 1fe70e96 ([media] cx88: fix locking of sub-driver operations) - 1d6213ab ([media] cx88: hold device lock during sub-driver initialization) - 344d6c6b ([media] cx88: protect cx8802_devlist with a mutex) - 579b2b45 ([media] cx88: gracefully reject attempts to use unregistered cx88-blackbird driver) - f4bd4be8 ([media] cx88: don't use atomic_t for core-mpeg_users) which are as of yesterday part of Linus's master branch fwiw. -- To UNSUBSCRIBE, email to debian-kernel-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20110525020350.GA8870@elie
Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
Jonathan has provided a new patch set. (RFC in progress.) And while testing it today an unrelated issue occurred which needs to be resolved ... The driver's active_ref count may become negative which leads to unpredictable behavior. (MPEG video device inaccessible, etc ...) Here's a possible fix ... diff -Nur a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c --- a/drivers/media/video/cx88/cx88-mpeg.c 2011-04-02 14:34:21.456569849 +0200 +++ b/drivers/media/video/cx88/cx88-mpeg.c 2011-04-02 14:32:55.467038000 +0200 @@ -642,12 +642,16 @@ { struct cx88_core *core = drv-core; + mpeg_dbg(1,"%s active driver references before release attempt: %d\n",core-name,core-active_ref); + if (drv-advise_release --core-active_ref == 0) { drv-advise_release(drv); core-active_type_id = CX88_BOARD_NONE; mpeg_dbg(1,"%s() Post release GPIO=%x\n", __func__, cx_read(MO_GP0_IO)); } + + if(core-active_ref0) core-active_ref=0; // prevent us from getting negative ref counts! return 0; } Tests done on amd64 hardware with 2 Hauppauge HVR1300 TV cards: Both were independently able to tune channels and stream encoded video through their MPEG encoder devices. Andi. -- To UNSUBSCRIBE, email to debian-kernel-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/4d9732a3.20...@gmx.at
Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
On Sat, 2011-04-02 at 16:28 +0200, Andreas Huber wrote: Jonathan has provided a new patch set. (RFC in progress.) And while testing it today an unrelated issue occurred which needs to be resolved ... [...] I'm not going to spend more time looking at this in detail. Please let us know when a complete fix has been accepted upstream. Ben. -- Ben Hutchings Once a job is fouled up, anything done to improve it makes it worse. signature.asc Description: This is a digitally signed message part
Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
On 02.04.2011 17:18, Ben Hutchings wrote: [...] I'm not going to spend more time looking at this in detail. Please let us know when a complete fix has been accepted upstream. Ben. Just for clarification, what I think is going wrong in cx88-mpeg.c, it's very simple, see the comments ... static int cx8802_request_release(struct cx8802_driver *drv) { struct cx88_core *core = drv-core; if (drv-advise_release --core-active_ref == 0) // REF COUNT MAY BECOME NEGATIVE !! { drv-advise_release(drv); core-active_type_id = CX88_BOARD_NONE; mpeg_dbg(1,%s() Post release GPIO=%x\n, __func__, cx_read(MO_GP0_IO)); } if(core-active_ref0) core-active_ref=0; // THIS IS A POSSIBLE FIX ! return 0; } please review this simple fix! regards Andi -- To UNSUBSCRIBE, email to debian-kernel-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/4d97646b.1060...@gmx.at
Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
On Sat, Apr 02, 2011 at 08:01:15PM +0200, Andreas Huber wrote: please review this simple fix! Please let us know when a complete fix has been accepted upstream. Groeten Geert Stappers -- And is there a policy on top-posting vs. bottom-posting? Yes. signature.asc Description: Digital signature
Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
Continuing Ben's work, I fixed all remaining issues. Patch was uploaded to https://bugzilla.kernel.org/show_bug.cgi?id=31962 Everything works fine for me now. regards Andi -- To UNSUBSCRIBE, email to debian-kernel-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/4d957020.1040...@gmx.at
Re: Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
Continuing Ben's work, I fixed all remaining issues. Patch was uploaded to https://bugzilla.kernel.org/show_bug.cgi?id=31962 Everything works fine for me now. regards Andi -- To UNSUBSCRIBE, email to debian-kernel-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/loom.20110401t082954...@post.gmane.org
Re: Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
Ben Hutchings ben at decadent.org.uk writes: On Sun, 2011-03-27 at 17:06 +0200, Huber Andreas wrote: Package: linux-source-2.6.38 Version: 2.6.38-1 Severity: important Tags: upstream [Symptom] Processes that try to open a cx88-blackbird driven MPEG device will hang up. [Cause] Nestet mutex_locks (which are not allowed) result in a deadlock. Could you test whether this patch fixes the problem? Instructions for rebuilding the kernel package are at http://kernel-handbook.alioth.debian.org/ch-common-tasks.html#s-common-official. Ben. Hi Ben, this patch fixes the deadlock during opening of the MPEG device, thanks. But I did some testing and ran into another deadlock while unloading the (patched) driver ... rmmod cx88_blackbird ... cx88/2: unregistering cx8802 driver, type: blackbird access: shared cx88[0]/2: subsystem: 0070:9601, board: Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder [card=56] cx88[1]/2: subsystem: 0070:9601, board: Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder [card=56] INFO: task rmmod:11233 blocked for more than 120 seconds. ... rmmod D 88005e9086c0 0 11233 5297 0x ... Call Trace: [8131fae5] ? __mutex_lock_common.clone.5+0x12a/0x195 [810eb3d9] ? kfree+0xc1/0xda [8131f9a2] ? mutex_lock+0x1a/0x33 [a0b3a809] ? cx8802_blackbird_remove+0x27/0x3d [cx88_blackbird] [a08671f2] ? cx8802_unregister_driver+0xf1/0x1bd [cx8802] [810730a9] ? sys_delete_module+0x1df/0x251 [81009912] ? system_call_fastpath+0x16/0x1b ... And there seems to be a new problem: I have 2 identical WinTV-HVR1300 Cards ... [6.876614] cx88[0]/0: registered device video0 [v4l2] [6.889815] cx88[1]/0: registered device video1 [v4l2] [ 10.161998] cx88[0]/2: registered device video2 [mpeg] [ 13.286062] cx88[1]/2: registered device video3 [mpeg] Here's what I experienced so far: 1) booting kernel 2.6.36-trunk-amd64 from debian both cards are able to stream their mpeg encoded tv streams through the mpeg devices (in my case /dev/video2 and /dev/video3) 2) after reboot into kernel 2.6.38 /dev/video2 still works fine; tuning to different channels works! /dev/video3 is inaccessible (after doing exactly the same initialization as before) ... dd if=/dev/video3 of=/tmp/test.mpg dd: reading `/dev/video3': Input/output error 0+0 records in 0+0 records out 0 bytes (0 B) copied, 2.74267 s, 0.0 kB/s Do you think this behavior could be BKL conversion related? -- To UNSUBSCRIBE, email to debian-kernel-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/loom.20110330t202348-...@post.gmane.org
Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
Ok, thanks! On 30.03.2011 23:43, Ben Hutchings wrote: All mail regarding Debian bugs should be cc'd to the bug address (in this case, 619...@bugs.debian.org). I am not going to spend more time trying to fix this, as I don't know the media/DVB system well and do not have the hardware in question. I will forward your information to the upstream developers. Ben. -- To UNSUBSCRIBE, email to debian-kernel-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/4d93a59b.2080...@gmx.at
Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
On Sun, 2011-03-27 at 17:06 +0200, Huber Andreas wrote: Package: linux-source-2.6.38 Version: 2.6.38-1 Severity: important Tags: upstream [Symptom] Processes that try to open a cx88-blackbird driven MPEG device will hang up. [Cause] Nestet mutex_locks (which are not allowed) result in a deadlock. Could you test whether this patch fixes the problem? Instructions for rebuilding the kernel package are at http://kernel-handbook.alioth.debian.org/ch-common-tasks.html#s-common-official. Ben. -- Ben Hutchings Once a job is fouled up, anything done to improve it makes it worse. From 9b33bf237c5b0910efa7a20d3ebc45ba4f5cd2cf Mon Sep 17 00:00:00 2001 From: Ben Hutchings b...@decadent.org.uk Date: Tue, 29 Mar 2011 03:25:15 +0100 Subject: [PATCH] cx88: Try to fix locking of sub-driver operations and device lists The BKL conversion of this family of drivers seems to have gone wrong. Opening cx88-blackbird will deadlock. Various other uses of the sub-device and driver lists appear to be subject to race conditions. Add and use a mutex to protect the device list. Note which driver functions require the device core lock, and make the callers (many of which already need it) lock. Compile-tested only. Signed-off-by: Ben Hutchings b...@decadent.org.uk --- drivers/media/video/cx88/cx88-blackbird.c |4 +++- drivers/media/video/cx88/cx88-dvb.c |2 ++ drivers/media/video/cx88/cx88-mpeg.c | 25 ++--- drivers/media/video/cx88/cx88.h |4 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index bca307e..201cdfc 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c @@ -1120,15 +1120,17 @@ static int mpeg_release(struct file *file) videobuf_mmap_free(fh-mpegq); mutex_lock(dev-core-lock); + file-private_data = NULL; kfree(fh); - mutex_unlock(dev-core-lock); /* Make sure we release the hardware */ drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); if (drv) drv-request_release(drv); + mutex_unlock(dev-core-lock); + atomic_dec(dev-core-mpeg_users); return 0; diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index 90717ee..5eccd02 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c @@ -132,6 +132,7 @@ static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire) return -EINVAL; } + mutex_lock(dev-core-lock); drv = cx8802_get_driver(dev, CX88_MPEG_DVB); if (drv) { if (acquire){ @@ -142,6 +143,7 @@ static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire) dev-frontends.active_fe_id = 0; } } + mutex_unlock(dev-core-lock); return ret; } diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index addf954..57b08c6 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c @@ -78,6 +78,7 @@ static void flush_request_modules(struct cx8802_dev *dev) static LIST_HEAD(cx8802_devlist); +static DEFINE_MUTEX(cx8802_mutex); /* -- */ static int cx8802_start_dma(struct cx8802_dev*dev, @@ -624,13 +625,11 @@ static int cx8802_request_acquire(struct cx8802_driver *drv) if (drv-advise_acquire) { - mutex_lock(drv-core-lock); core-active_ref++; if (core-active_type_id == CX88_BOARD_NONE) { core-active_type_id = drv-type_id; drv-advise_acquire(drv); } - mutex_unlock(drv-core-lock); mpeg_dbg(1,%s() Post acquire GPIO=%x\n, __func__, cx_read(MO_GP0_IO)); } @@ -643,14 +642,12 @@ static int cx8802_request_release(struct cx8802_driver *drv) { struct cx88_core *core = drv-core; - mutex_lock(drv-core-lock); if (drv-advise_release --core-active_ref == 0) { drv-advise_release(drv); core-active_type_id = CX88_BOARD_NONE; mpeg_dbg(1,%s() Post release GPIO=%x\n, __func__, cx_read(MO_GP0_IO)); } - mutex_unlock(drv-core-lock); return 0; } @@ -693,6 +690,8 @@ int cx8802_register_driver(struct cx8802_driver *drv) return err; } + mutex_lock(cx8802_mutex); + list_for_each_entry(dev, cx8802_devlist, devlist) { printk(KERN_INFO %s/2: subsystem: %04x:%04x, board: %s [card=%d]\n, @@ -702,8 +701,10 @@ int cx8802_register_driver(struct cx8802_driver *drv) /* Bring up a new struct for each driver instance */ driver = kzalloc(sizeof(*drv),GFP_KERNEL); - if (driver == NULL) - return -ENOMEM; + if (driver == NULL) { + err = -ENOMEM; + goto out; + } /* Snapshot of the driver registration data */ drv-core = dev-core; @@ -727,7 +728,10 @@ int cx8802_register_driver(struct cx8802_driver *drv) } - return i ? 0 : -ENODEV; + err = i ? 0 : -ENODEV; +out: + mutex_unlock(cx8802_mutex); + return err; } int cx8802_unregister_driver(struct cx8802_driver *drv) @@ -741,6
Bug#619827: linux-source-2.6.38: [linux-dvb] cx88-blackbird broken (since 2.6.37)
Package: linux-source-2.6.38 Version: 2.6.38-1 Severity: important Tags: upstream [Symptom] Processes that try to open a cx88-blackbird driven MPEG device will hang up. [Cause] Nestet mutex_locks (which are not allowed) result in a deadlock. [Details] There has been resent work on removing BKL (BigKernelLock) calls from kernel code. (see http://kernelnewbies.org/BigKernelLock) This was not properly done for the cx88-blackbird driver: Source-File: drivers/media/video/cx88/cx88-blackbird.c Function: int mpeg_open(struct file *file) Problem: the calls to drv-request_acquire(drv); and drv-request_release(drv); will hang because they try to lock a mutex that has already been locked by a previouse call to mutex_lock(dev-core-lock) ... 1050 static int mpeg_open(struct file *file) 1051 { [...] 1060 mutex_lock(dev-core-lock); // MUTEX LOCKED 1061 1062 /* Make sure we can acquire the hardware */ 1063 drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); 1064 if (drv) { 1065 err = drv-request_acquire(drv); // HANGS !!! 1066 if(err != 0) { 1067 dprintk(1,%s: Unable to acquire hardware, %d\n, __func__, err); 1068 mutex_unlock(dev-core-lock);; 1069 return err; 1070 } 1071 } [...] Here's the relevant kernel log extract (Linux version 2.6.38-1-amd64 (Debian 2.6.38-1)) ... Mar 24 21:25:10 xen kernel: [ 241.472067] INFO: task v4l_id:1000 blocked for more than 120 seconds. Mar 24 21:25:10 xen kernel: [ 241.478845] echo 0 /proc/sys/kernel/hung_task_timeout_secs disables this message. Mar 24 21:25:10 xen kernel: [ 241.482412] v4l_id D 88006bcb6540 0 1000 1 0x Mar 24 21:25:10 xen kernel: [ 241.486031] 88006bcb6540 0086 8801 88006981c380 Mar 24 21:25:10 xen kernel: [ 241.489694] 00013700 88006be5bfd8 88006be5bfd8 00013700 Mar 24 21:25:10 xen kernel: [ 241.493301] 88006bcb6540 88006be5a010 88006bcb6540 00016be5a000 Mar 24 21:25:10 xen kernel: [ 241.496766] Call Trace: Mar 24 21:25:10 xen kernel: [ 241.500145] [81321c4a] ? __mutex_lock_common+0x127/0x193 Mar 24 21:25:10 xen kernel: [ 241.503630] [81321d82] ? mutex_lock+0x1a/0x33 Mar 24 21:25:10 xen kernel: [ 241.507145] [a09dd155] ? cx8802_request_acquire+0x66/0xc6 [cx8802] Mar 24 21:25:10 xen kernel: [ 241.510699] [a0aab7f2] ? mpeg_open+0x7a/0x1fc [cx88_blackbird] Mar 24 21:25:10 xen kernel: [ 241.514279] [8123bfb6] ? kobj_lookup+0x139/0x173 Mar 24 21:25:10 xen kernel: [ 241.517856] [a062d5fd] ? v4l2_open+0xb3/0xdf [videodev] regards Andi Huber -- System Information: Debian Release: wheezy/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 2.6.36-trunk-amd64 (SMP w/2 CPU cores) Locale: LANG=en_US.ISO-8859-15, LC_CTYPE=en_US.ISO-8859-15 (charmap=ISO-8859-15) Shell: /bin/sh linked to /bin/dash Versions of packages linux-source-2.6.38 depends on: ii binutils 2.20.1-16 The GNU assembler, linker and bina ii bzip2 1.0.5-6high-quality block-sorting file co Versions of packages linux-source-2.6.38 recommends: ii gcc 4:4.4.5-1 The GNU C compiler ii libc6-dev [libc-dev] 2.11.2-10 Embedded GNU C Library: Developmen ii make 3.81-8 An utility for Directing compilati Versions of packages linux-source-2.6.38 suggests: pn kernel-packagenone (no description available) ii libncurses5-dev [ncurses- 5.8+20110307-1 developer's libraries for ncurses pn libqt3-mt-dev none (no description available) -- no debconf information -- To UNSUBSCRIBE, email to debian-kernel-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20110327150610.4029.95961.report...@xen.corax.at