Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] Fix IDE locking error

This bit us a few kernels ago, and for some reason never made it's way
upstream.

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=144743
Kernel panic - not syncing: drivers/ide/pci/piix.c:231:
spin_lock(drivers/ide/ide.c:c03cef28) already locked by driver/ide/ide-iops.c/1153.

Signed-off-by: Dave Jones <davej@redhat.com>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: Dave Jones <davej@redhat.com>
Cc: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Alan Cox and committed by
Linus Torvalds
4fb0f76d b5cdccf8

+10 -2
+10 -2
drivers/ide/pci/piix.c
··· 222 222 unsigned long flags; 223 223 u16 master_data; 224 224 u8 slave_data; 225 + static DEFINE_SPINLOCK(tune_lock); 226 + 225 227 /* ISP RTC */ 226 228 u8 timings[][2] = { { 0, 0 }, 227 229 { 0, 0 }, ··· 232 230 { 2, 3 }, }; 233 231 234 232 pio = ide_get_best_pio_mode(drive, pio, 5, NULL); 235 - spin_lock_irqsave(&ide_lock, flags); 233 + 234 + /* 235 + * Master vs slave is synchronized above us but the slave register is 236 + * shared by the two hwifs so the corner case of two slave timeouts in 237 + * parallel must be locked. 238 + */ 239 + spin_lock_irqsave(&tune_lock, flags); 236 240 pci_read_config_word(dev, master_port, &master_data); 237 241 if (is_slave) { 238 242 master_data = master_data | 0x4000; ··· 258 250 pci_write_config_word(dev, master_port, master_data); 259 251 if (is_slave) 260 252 pci_write_config_byte(dev, slave_port, slave_data); 261 - spin_unlock_irqrestore(&ide_lock, flags); 253 + spin_unlock_irqrestore(&tune_lock, flags); 262 254 } 263 255 264 256 /**