public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] EM28xx - fix deadlock when unplugging and replugging a DVB adapter
@ 2011-09-24 20:54 Chris Rankin
  2011-09-25 12:49 ` Mauro Carvalho Chehab
  2011-09-25 13:00 ` Mauro Carvalho Chehab
  0 siblings, 2 replies; 9+ messages in thread
From: Chris Rankin @ 2011-09-24 20:54 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

Mauro,

Excuse me - I put my brain in backwards today and sent you a reverse diff by 
accident! Reresending...

----------------------------------------------------------------------------
This fixes the deadlock that occurs with either multiple PCTV 290e adapters or 
when a single PCTV 290e adapter is replugged.

For DVB devices, the device lock must now *not* be held when adding/removing 
either a device or an extension to the respective lists. (Because 
em28xx_init_dvb() will want to take the lock instead).

Conversely, for Audio-Only devices, the device lock *must* be held when 
adding/removing either a device or an extension to the respective lists.

Signed-off-by: Chris Rankin <ranki...@yahoo.com>

Cheers,
Chris

[-- Attachment #2: EM28xx-replug-deadlock-3.diff --]
[-- Type: text/x-patch, Size: 649 bytes --]

--- linux/drivers/media/video/em28xx/em28xx-cards.c.orig	2011-09-24 21:42:43.000000000 +0100
+++ linux/drivers/media/video/em28xx/em28xx-cards.c	2011-09-24 21:48:56.000000000 +0100
@@ -3005,7 +3005,9 @@
 		goto fail;
 	}
 
+	mutex_unlock(&dev->lock);
 	em28xx_init_extension(dev);
+	mutex_lock(&dev->lock);
 
 	/* Save some power by putting tuner to sleep */
 	v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0);
@@ -3301,10 +3303,10 @@
 		em28xx_release_resources(dev);
 	}
 
-	em28xx_close_extension(dev);
-
 	mutex_unlock(&dev->lock);
 
+	em28xx_close_extension(dev);
+
 	if (!dev->users) {
 		kfree(dev->alt_max_pkt_size);
 		kfree(dev);

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-09-25 21:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-24 20:54 [PATCH v3] EM28xx - fix deadlock when unplugging and replugging a DVB adapter Chris Rankin
2011-09-25 12:49 ` Mauro Carvalho Chehab
2011-09-25 13:20   ` Chris Rankin
2011-09-25 19:28   ` Chris Rankin
2011-09-25 19:45     ` Mauro Carvalho Chehab
2011-09-25 21:36       ` Chris Rankin
2011-09-25 13:00 ` Mauro Carvalho Chehab
2011-09-25 13:32   ` Chris Rankin
2011-09-25 19:43     ` Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox