]> err.no Git - linux-2.6/blobdiff - drivers/scsi/libata-core.c
Automatic merge of rsync://www.fr.zoreil.com/linux-2.6.git branch HEAD
[linux-2.6] / drivers / scsi / libata-core.c
index 0b5d3a5b7edab5ce17889a0e698805ce346b4d1a..63d3f70d06e17b917d1e6e0da9169a50fea340d2 100644 (file)
@@ -1253,11 +1253,11 @@ void __sata_phy_reset(struct ata_port *ap)
        unsigned long timeout = jiffies + (HZ * 5);
 
        if (ap->flags & ATA_FLAG_SATA_RESET) {
-               scr_write(ap, SCR_CONTROL, 0x301); /* issue phy wake/reset */
-               scr_read(ap, SCR_STATUS);       /* dummy read; flush */
+               /* issue phy wake/reset */
+               scr_write_flush(ap, SCR_CONTROL, 0x301);
                udelay(400);                    /* FIXME: a guess */
        }
-       scr_write(ap, SCR_CONTROL, 0x300);      /* issue phy wake/clear reset */
+       scr_write_flush(ap, SCR_CONTROL, 0x300); /* phy wake/clear reset */
 
        /* wait for phy to become ready, if necessary */
        do {
@@ -2071,7 +2071,7 @@ void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
        sg = qc->sg;
        sg->page = virt_to_page(buf);
        sg->offset = (unsigned long) buf & ~PAGE_MASK;
-       sg_dma_len(sg) = buflen;
+       sg->length = buflen;
 }
 
 void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
@@ -2101,11 +2101,12 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
        dma_addr_t dma_address;
 
        dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt,
-                                    sg_dma_len(sg), dir);
+                                    sg->length, dir);
        if (dma_mapping_error(dma_address))
                return -1;
 
        sg_dma_address(sg) = dma_address;
+       sg_dma_len(sg) = sg->length;
 
        DPRINTK("mapped buffer of %d bytes for %s\n", sg_dma_len(sg),
                qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
@@ -2310,7 +2311,7 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
        qc->cursect++;
        qc->cursg_ofs++;
 
-       if ((qc->cursg_ofs * ATA_SECT_SIZE) == sg_dma_len(&sg[qc->cursg])) {
+       if ((qc->cursg_ofs * ATA_SECT_SIZE) == (&sg[qc->cursg])->length) {
                qc->cursg++;
                qc->cursg_ofs = 0;
        }
@@ -2347,7 +2348,7 @@ next_page:
        page = nth_page(page, (offset >> PAGE_SHIFT));
        offset %= PAGE_SIZE;
 
-       count = min(sg_dma_len(sg) - qc->cursg_ofs, bytes);
+       count = min(sg->length - qc->cursg_ofs, bytes);
 
        /* don't cross page boundaries */
        count = min(count, (unsigned int)PAGE_SIZE - offset);
@@ -2358,7 +2359,7 @@ next_page:
        qc->curbytes += count;
        qc->cursg_ofs += count;
 
-       if (qc->cursg_ofs == sg_dma_len(sg)) {
+       if (qc->cursg_ofs == sg->length) {
                qc->cursg++;
                qc->cursg_ofs = 0;
        }
@@ -2371,7 +2372,7 @@ next_page:
        kunmap(page);
 
        if (bytes) {
-               if (qc->cursg_ofs < sg_dma_len(sg))
+               if (qc->cursg_ofs < sg->length)
                        goto next_page;
                goto next_sg;
        }
@@ -2539,7 +2540,7 @@ static void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
        ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer));
        qc->dma_dir = DMA_FROM_DEVICE;
 
-       memset(&qc->cdb, 0, sizeof(ap->cdb_len));
+       memset(&qc->cdb, 0, ap->cdb_len);
        qc->cdb[0] = REQUEST_SENSE;
        qc->cdb[4] = SCSI_SENSE_BUFFERSIZE;
 
@@ -2811,6 +2812,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
 
        /* call completion callback */
        rc = qc->complete_fn(qc, drv_stat);
+       qc->flags &= ~ATA_QCFLAG_ACTIVE;
 
        /* if callback indicates not to complete command (non-zero),
         * return immediately
@@ -3229,7 +3231,8 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
                        struct ata_queued_cmd *qc;
 
                        qc = ata_qc_from_tag(ap, ap->active_tag);
-                       if (qc && (!(qc->tf.ctl & ATA_NIEN)))
+                       if (qc && (!(qc->tf.ctl & ATA_NIEN)) &&
+                           (qc->flags & ATA_QCFLAG_ACTIVE))
                                handled |= ata_host_intr(ap, qc);
                }
        }