Date: Fri, 21 Aug 1998 00:32:54 +0200 (CEST)
From: Geert Uytterhoeven <Geert.Uytterhoeven@cs.kuleuven.ac.be>
To: LUTHER Sven <LUTHERSV@e-i.com>
cc: "'linux-apus@sunsite.auc.dk'" <linux-apus@SunSITE.auc.dk>,
        Linux/m68k <linux-m68k@lists.linux-m68k.org>
Subject: L68K: Re: TR: IDE shared interrupt patch 
In-Reply-To: <A5C7DA6579CBD0118B5D00AA00ACBA3C03481B7F@smail.e-i.net>
Sender: owner-linux-m68k@phil.uni-sb.de

On Thu, 20 Aug 1998, LUTHER Sven wrote:
> > you will find here the patch for the ide stuff :
> > 
> > Friendly,
> > 
> > Sven 
> > 
> > --- drivers/block/ide.c.orig	Thu Aug 20 14:58:56 1998
> > +++ drivers/block/ide.c	Thu Aug 20 15:00:20 1998
> > @@ -1406,8 +1406,12 @@
> >  			 * Probably not a shared PCI interrupt,
> >  			 * so we can safely try to do something about it:
> >  			 */
> > -			(void)ide_ack_intr(hwif);
> > -			unexpected_intr(irq, hwgroup);
> > +			/* But don't forget that there are other
> > architectures
> > +			 * than i386, so better test the result of
> > +			 * ide_ack_intr(hwif).
> > +			 */
> > +			if (ide_ack_intr(hwif))
> > +				unexpected_intr(irq, hwgroup) ;
> >  		}
> >  		spin_unlock_irqrestore(&hwgroup->spinlock, flags);
> >  		return;

Actually Michael was right: we should always check the result of
ide_ack_intr(). If we don't do that, hwgroup->handler() is still called if the
IDE driver expected an interrupt but some other device generated one. Probably
this explains the other IDE related messages we sometimes see on our consoles.

The patch is untested, I already have more than enough troubles with the latest
IDE integration patches (will we make it before 2.2? Let's hope so).

--- jes-2.1.115/drivers/block/ide.c	Sun Aug  9 21:47:47 1998
+++ m68k/drivers/block/ide.c	Fri Aug 21 00:26:21 1998
@@ -1385,6 +1385,11 @@
 	__cli();	/* local CPU only */
 	spin_lock_irqsave(&hwgroup->spinlock, flags);
 	hwif = hwgroup->hwif;
+	if (!ide_ack_intr(hwif)) {
+		spin_unlock_irqrestore(&hwgroup->spinlock, flags);
+		return;
+	}
+
 	if ((handler = hwgroup->handler) == NULL || hwgroup->poll_timeout != 0) {
 		/*
 		 * Not expecting an interrupt from this drive.
@@ -1406,7 +1411,6 @@
 			 * Probably not a shared PCI interrupt,
 			 * so we can safely try to do something about it:
 			 */
-			(void)ide_ack_intr(hwif);
 			unexpected_intr(irq, hwgroup);
 		}
 		spin_unlock_irqrestore(&hwgroup->spinlock, flags);
@@ -1418,7 +1422,6 @@
 		return;
 	}
 	hwgroup->handler = NULL;
-	(void)ide_ack_intr(hwif);
 	del_timer(&(hwgroup->timer));
 	spin_unlock_irqrestore(&hwgroup->spinlock, flags);
 	if (drive->unmask)

Greetings,

						Geert

--
Geert Uytterhoeven                     Geert.Uytterhoeven@cs.kuleuven.ac.be
Wavelets, Linux/{m68k~Amiga,PPC~CHRP}  http://www.cs.kuleuven.ac.be/~geert/
Department of Computer Science -- Katholieke Universiteit Leuven -- Belgium

