Skip to contentSkip to conversation

Do not register the IDE interrupt handler if host->get_lock is set.

PATCH New Michael Schmitz 2 participants 5 messages Feb 1, 2014 – Mar 6, 2014 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Do not register the IDE interrupt handler if host->get_lock is set.

The m68k Atari Falcon IDE driver shares the IDE interrupt with DMA completion, SCSI and floppy controller. The DMA controller does not provide a way to check whether it had generated an interrupt, so the shared interrupt has to be reserved for exclusive use by the respective driver.
To this end, host->get_lock was added to allow both locking the interrupt and passing the relevant interrupt handler to the machine specific interrupt code. This feature is used exclusively by the Falcon IDE driver. Unconditionally registering the IDE interrupt handler in init_irq() when host->get_lock is set does result in two calls being dispatched to the IDE handler on each IDE interrupt, and one spurious call on each SCSI, DMA or floppy interrupt.

The following patch changes init_irq() to request the IDE interrupt only if host->get_lock is not set.

Regards,

Michael Schmitz

#1 lore raw

PATCH 1/1 m68k/atari - ide: do not register interrupt if host->get_lock is set

On m68k, host->get_lock is used to both lock and register the interrupt that the IDE host shares with other device drivers. Registering the IDE interrupt handler in ide-probe.c results in duplicating the interrupt registered (once via host->get lock, and also via init_irq()), and may result in IDE accepting interrupts even when another driver has locked the interrupt hardware. This opens the whole locking scheme up to races.

host->get_lock is set on m68k only, so other drivers' behaviour is not changed.

Cc Geert Uytterhoeven <[email protected]>
Cc David S. Miller <[email protected]>
---
 drivers/ide/ide-probe.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/ide/ide-probe.c +5 -3
index 2a744a9..a3d3b17 100644
@@ -853,8 +853,9 @@ static int init_irq (ide_hwif_t *hwif)
 	if (irq_handler == NULL)
 		irq_handler = ide_intr;
 
-	if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif))
-		goto out_up;
+	if (!host->get_lock)
+		if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif))
+			goto out_up;
 
 #if !defined(__mc68000__)
 	printk(KERN_INFO "%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name,
@@ -1533,7 +1534,8 @@ static void ide_unregister(ide_hwif_t *hwif)
 
 	ide_proc_unregister_port(hwif);
 
-	free_irq(hwif->irq, hwif);
+	if (!hwif->host->get_lock)
+		free_irq(hwif->irq, hwif);
 
 	device_unregister(hwif->portdev);
 	device_unregister(&hwif->gendev);
Signature · 1 line
1.7.0.4
Applied
#2 lore raw

Re: [PATCH] m68k/atari - ide: do not register interrupt if host->get_lock is set

From: Michael Schmitz <[email protected]>
Date: Sat, 1 Feb 2014 13:48:13 +1300

Quoted 8 lines

On m68k, host->get_lock is used to both lock and register the interrupt that the IDE host shares with other device drivers. Registering the IDE interrupt handler in ide-probe.c results in duplicating the interrupt registered (once via host->get lock, and also via init_irq()), and may result in IDE accepting interrupts even when another driver has locked the interrupt hardware. This opens the whole locking scheme up to races.

Quoted 4 lines

host->get_lock is set on m68k only, so other drivers' behaviour is not changed.

It's a bit kludgy, but minimal and correct.

Applied, thank you.

#3 lore raw

Re: [PATCH] m68k/atari - ide: do not register interrupt if host->get_lock is set

Thanks Dave,

Quoted 8 lines
Quoted 8 lines

On m68k, host->get_lock is used to both lock and register the interrupt that the IDE host shares with other device drivers. Registering the IDE interrupt handler in ide-probe.c results in duplicating the interrupt registered (once via host->get lock, and also via init_irq()), and may result in IDE accepting interrupts even when another driver has locked the interrupt hardware. This opens the whole locking scheme up to races.

Quoted 6 lines
Quoted 4 lines

host->get_lock is set on m68k only, so other drivers' behaviour is not changed.

It's a bit kludgy, but minimal and correct.

Would you have preferred to use a host flag instead?

Quoted 1 line

Applied, thank you.

Thanks again,

Michael

#4 lore raw

Re: [PATCH] m68k/atari - ide: do not register interrupt if host->get_lock is set

From: Michael Schmitz <[email protected]>
Date: Thu, 6 Mar 2014 19:47:06 +1300

Quoted 13 lines

Thanks Dave,

Quoted 11 lines
Quoted 11 lines

On m68k, host->get_lock is used to both lock and register the interrupt
that the IDE host shares with other device drivers. Registering the IDE interrupt handler in ide-probe.c results in duplicating the interrupt registered (once via host->get lock, and also via init_irq()),
and may result in IDE accepting interrupts even when another driver has
locked the interrupt hardware. This opens the whole locking scheme up to races.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

host->get_lock is set on m68k only, so other drivers' behaviour is not changed.

It's a bit kludgy, but minimal and correct.

Would you have preferred to use a host flag instead?

I looked into that, we are out of host flags. We'd either need to expand the flags value to 64-bits or add another u32.

That's overkill for this.