From: Alan Cox 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 Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton --- drivers/ide/pci/piix.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff -puN drivers/ide/pci/piix.c~fix-ide-locking-error drivers/ide/pci/piix.c --- devel/drivers/ide/pci/piix.c~fix-ide-locking-error 2006-02-17 00:06:10.000000000 -0800 +++ devel-akpm/drivers/ide/pci/piix.c 2006-02-17 00:06:10.000000000 -0800 @@ -204,6 +204,8 @@ static u8 piix_dma_2_pio (u8 xfer_rate) } } +static spinlock_t tune_lock = SPIN_LOCK_UNLOCKED; + /** * piix_tune_drive - tune a drive attached to a PIIX * @drive: drive to tune @@ -230,7 +232,12 @@ static void piix_tune_drive (ide_drive_t { 2, 3 }, }; pio = ide_get_best_pio_mode(drive, pio, 5, NULL); - spin_lock_irqsave(&ide_lock, flags); + + /* Master v slave is synchronized above us but the slave register is + shared by the two hwifs so the corner case of two slave timeouts in + parallel must be locked */ + + spin_lock_irqsave(&tune_lock, flags); pci_read_config_word(dev, master_port, &master_data); if (is_slave) { master_data = master_data | 0x4000; @@ -250,7 +257,7 @@ static void piix_tune_drive (ide_drive_t pci_write_config_word(dev, master_port, master_data); if (is_slave) pci_write_config_byte(dev, slave_port, slave_data); - spin_unlock_irqrestore(&ide_lock, flags); + spin_unlock_irqrestore(&tune_lock, flags); } /** _