Skip to contentSkip to conversation

ide-probe init_irq cleanup

RFC PATCH New Manfred Spraul 1 participant 1 message Mar 17, 2003

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ide-probe init_irq cleanup

Hi all,

init_irq calls request_irq while holding the ide_lock spinlock. This can deadlock, because request_irq can sleep under some circumstances - e.g. for the allocation of the /proc/irq entries, or for randomness management structures.

The attached patch modifies init_irq and calls request_irq without the spinlock held. It also fixes a potential race between choose_drive and init_irq.

The patch is against 2.5.64-ac4, it should apply to 2.5.64 with some offsets.

--
Manfred

// $Header$
// Kernel Version:

//  VERSION = 2
//  PATCHLEVEL = 5
//  SUBLEVEL = 64
//  EXTRAVERSION = -ac4
include/linux/ide.h +13 -0
@@ -1740,6 +1740,19 @@
 extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
 
 extern spinlock_t ide_lock;
+extern struct semaphore ide_cfg_sem;
+/*
+ * Structure locking:
+ *
+ * ide_cfg_sem and ide_lock together protect changes to
+ * ide_hwif_t->{next,hwgroup}
+ * ide_drive_t->next
+ *
+ * ide_hwgroup_t->busy: ide_lock
+ * ide_hwgroup_t->hwif: ide_lock
+ * ide_hwif_t->mate: constant, no locking
+ * ide_drive_t->hwif: constant, no locking
+ */
 
 #define local_irq_set(flags)	do { local_save_flags((flags)); local_irq_enable(); } while (0)
 
drivers/ide/ide-probe.c +74 -40

167 lines not on this page · raw message

drivers/ide/ide.c +47 -19

130 lines not on this page · raw message

drivers/ide/ide-io.c +2 -2
@@ -771,8 +771,8 @@
 	/* for atari only: POSSIBLY BROKEN HERE(?) */
 	ide_get_lock(ide_intr, hwgroup);
 
-	/* necessary paranoia: ensure IRQs are masked on local CPU */
-	local_irq_disable();
+	/* caller must own ide_lock */
+	BUG_ON(!irqs_disabled());
 
 	while (!hwgroup->busy) {
 		hwgroup->busy = 1;