Some devices raise irq early before clearing the BSY.
This patch waits up to 10 microseconds to workaround the early irq problem.

Signed-off-by: Albert Lee <[EMAIL PROTECTED]>
---
In additional to the pata_via SET FEATURES XFER problem reported by Matthieu,
we also see the early irq problem with ICH4 + AOpen CD-936E on READ under PIO 
mode 4.

The following is a port of the pata_via_fix to the libata core.
Patch against 2.6.19-rc6. For your review, thanks.


--- linux-2.6.19-rc6/include/linux/libata.h     2006-11-28 11:14:52.000000000 
+0800
+++ linux-2.6.19-rc6-early_irq/include/linux/libata.h   2006-11-28 
13:31:07.565194648 +0800
@@ -1039,6 +1039,30 @@ static inline void ata_pause(struct ata_
        ndelay(400);
 }
 
+/**
+ *     ata_busy_wait_alt - Wait for a port alt status register
+ *     @ap: Port to wait for.
+ *
+ *     Waits up to max microseconds for the selected bits in the port's
+ *     alt status register to be cleared.
+ *     Returns final value of alt status register.
+ *
+ *     LOCKING:
+ *     Inherited from caller.
+ */
+static inline u8 ata_busy_wait_alt(struct ata_port *ap, unsigned int bits,
+                                  unsigned int max)
+{
+       u8 status = ata_altstatus(ap);
+
+       while ((status & bits) && (max > 0)) {
+               udelay(1);
+               status = ata_altstatus(ap);
+               max--;
+       };
+
+       return status;
+}
 
 /**
  *     ata_busy_wait - Wait for a port status register
--- linux-2.6.19-rc6/drivers/ata/libata-core.c  2006-11-28 11:14:38.000000000 
+0800
+++ linux-2.6.19-rc6-early_irq/drivers/ata/libata-core.c        2006-11-28 
13:31:31.275590120 +0800
@@ -4828,8 +4828,10 @@ inline unsigned int ata_host_intr (struc
                goto idle_irq;
        }
 
-       /* check altstatus */
-       status = ata_altstatus(ap);
+       /* check altstatus.
+        * Waits up to 10 microseconds for early irq.
+        */
+       status = ata_busy_wait_alt(ap, ATA_BUSY, 10);
        if (status & ATA_BUSY)
                goto idle_irq;
 


-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to