[2/4] ide: Handle irq disabling consistently

Message ID 20180504142446.30525-3-bigeasy@linutronix.de
State Accepted
Delegated to: David Miller
Headers show
Series
  • avoid disabling interrupts where it is not required
Related show

Commit Message

Sebastian Andrzej Siewior May 4, 2018, 2:24 p.m.
ide_timer_expiry() disables interrupt at function entry when acquiring
hwif->lock. Before disabling the device interrupt it unlocks hwif->lock,
but interrupts stay disabled. After the call to disable_irq() interrupts
are disabled again, which is a pointless exercise.

After the device irq handler has been invoked with interrupts disabled,
hwif->lock is acquired again with spin_lock_irq() because the device irq
handler might have reenabled interrupts. This is not documented and
confusing for the casual reader.

Remove the redundant local_irq_disable() and add a comment which explains
why hwif->lock has to be reacquired with spin_lock_irq().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/ide/ide-io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

David Miller May 4, 2018, 5:38 p.m. | #1
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Fri,  4 May 2018 16:24:44 +0200

> ide_timer_expiry() disables interrupt at function entry when acquiring
> hwif->lock. Before disabling the device interrupt it unlocks hwif->lock,
> but interrupts stay disabled. After the call to disable_irq() interrupts
> are disabled again, which is a pointless exercise.
> 
> After the device irq handler has been invoked with interrupts disabled,
> hwif->lock is acquired again with spin_lock_irq() because the device irq
> handler might have reenabled interrupts. This is not documented and
> confusing for the casual reader.
> 
> Remove the redundant local_irq_disable() and add a comment which explains
> why hwif->lock has to be reacquired with spin_lock_irq().
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Acked-by: David S. Miller <davem@davemloft.net>
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 6f25da56a169..a444bad7a2aa 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -659,8 +659,7 @@  void ide_timer_expiry (struct timer_list *t)
 		spin_unlock(&hwif->lock);
 		/* disable_irq_nosync ?? */
 		disable_irq(hwif->irq);
-		/* local CPU only, as if we were handling an interrupt */
-		local_irq_disable();
+
 		if (hwif->polling) {
 			startstop = handler(drive);
 		} else if (drive_is_ready(drive)) {
@@ -679,6 +678,7 @@  void ide_timer_expiry (struct timer_list *t)
 				startstop = ide_error(drive, "irq timeout",
 					hwif->tp_ops->read_status(hwif));
 		}
+		/* Disable interrupts again, `handler' might have enabled it */
 		spin_lock_irq(&hwif->lock);
 		enable_irq(hwif->irq);
 		if (startstop == ide_stopped && hwif->polling == 0) {