@@ -1070,6 +1070,7 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc)
struct ata_eh_info *ehi = &dev->link->eh_info;
unsigned int ireason, bc_lo, bc_hi, bytes;
int i_write, do_write = (qc->tf.flags & ATA_TFLAG_WRITE) ? 1 : 0;
+ u8 stat;
/* Abuse qc->result_tf for temp storage of intermediate TF
* here to save some kernel stack usage.
@@ -1099,6 +1100,21 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc)
if (unlikely(__atapi_pio_bytes(qc, bytes)))
goto err_out;
+
+ /* this really should be done only after the final transfer is complete */
+ stat = ata_sff_altstatus(ap);
+ if (stat & ATA_DRQ) {
+ int count;
+
+ ata_port_printk(ap, KERN_INFO, "stat=%x after atapi_pio_bytes\n", stat);
+
+ for (count = 0; (ap->ops->sff_check_status(ap) & ATA_DRQ)
+ && count < 65536; count += 2)
+ ioread16(ap->ioaddr.data_addr);
+ if (count)
+ ata_port_printk(ap, KERN_DEBUG,
+ "drained %d bytes to clear DRQ.\n", count);
+ }
ata_sff_sync(ap); /* flush */
return;