]> git.hungrycats.org Git - linux/commitdiff
[PATCH] make ATAPI PIO work
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Mon, 18 Oct 2004 13:49:29 +0000 (09:49 -0400)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Mon, 18 Oct 2004 13:49:29 +0000 (09:49 -0400)
If "BSY=0, DRQ=0" condition happens on ATAPI just
complete the command as this condition happens for:
* the end of the PIO transfer (ie. REQUEST_SENSE
  seems to return only 18 of 96 requested bytes)
* unsupported ATAPI commands (ie. REPORT_LUNS)

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/scsi/libata-core.c

index 92ee0ab2f3676dac866b4f5e732b9329b04c92aa..cc18aa14c71b0c077ea6a32453179d42a3dd9934 100644 (file)
@@ -2297,19 +2297,30 @@ static void ata_pio_block(struct ata_port *ap)
                }
        }
 
-       /* handle BSY=0, DRQ=0 as error */
-       if ((status & ATA_DRQ) == 0) {
-               ap->pio_task_state = PIO_ST_ERR;
-               return;
-       }
-
        qc = ata_qc_from_tag(ap, ap->active_tag);
        assert(qc != NULL);
 
-       if (is_atapi_taskfile(&qc->tf))
+       if (is_atapi_taskfile(&qc->tf)) {
+               /* no more data to transfer or unsupported ATAPI command */
+               if ((status & ATA_DRQ) == 0) {
+                       ap->pio_task_state = PIO_ST_IDLE;
+
+                       ata_irq_on(ap);
+
+                       ata_qc_complete(qc, status);
+                       return;
+               }
+
                atapi_pio_bytes(qc);
-       else
+       } else {
+               /* handle BSY=0, DRQ=0 as error */
+               if ((status & ATA_DRQ) == 0) {
+                       ap->pio_task_state = PIO_ST_ERR;
+                       return;
+               }
+
                ata_pio_sector(qc);
+       }
 }
 
 static void ata_pio_error(struct ata_port *ap)