diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2009-02-27 03:35:43 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2009-03-05 07:24:57 -0500 |
commit | 5825627c9463581fd9e70f8285685889ae5bb9bb (patch) | |
tree | 321a20a0e25aee8f32254b13730f423f6b434486 | |
parent | e7d3ef13d52a126438f687a1a32da65ff926ed57 (diff) |
libata: fix dma_unmap_sg misuse
libata passes the returned value of dma_map_sg() to
dma_unmap_sg(),which is the misuse of dma_unmap_sg().
DMA-mapping.txt says:
To unmap a scatterlist, just call:
pci_unmap_sg(pdev, sglist, nents, direction);
Again, make sure DMA activity has already finished.
PLEASE NOTE: The 'nents' argument to the pci_unmap_sg call must be
the _same_ one you passed into the pci_map_sg call,
it should _NOT_ be the 'count' value _returned_ from the
pci_map_sg call.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
-rw-r--r-- | drivers/ata/libata-core.c | 4 | ||||
-rw-r--r-- | include/linux/libata.h | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 9fbf0595f3d4..5e324cea3019 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -4612,7 +4612,7 @@ void ata_sg_clean(struct ata_queued_cmd *qc) | |||
4612 | VPRINTK("unmapping %u sg elements\n", qc->n_elem); | 4612 | VPRINTK("unmapping %u sg elements\n", qc->n_elem); |
4613 | 4613 | ||
4614 | if (qc->n_elem) | 4614 | if (qc->n_elem) |
4615 | dma_unmap_sg(ap->dev, sg, qc->n_elem, dir); | 4615 | dma_unmap_sg(ap->dev, sg, qc->orig_n_elem, dir); |
4616 | 4616 | ||
4617 | qc->flags &= ~ATA_QCFLAG_DMAMAP; | 4617 | qc->flags &= ~ATA_QCFLAG_DMAMAP; |
4618 | qc->sg = NULL; | 4618 | qc->sg = NULL; |
@@ -4727,7 +4727,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
4727 | return -1; | 4727 | return -1; |
4728 | 4728 | ||
4729 | DPRINTK("%d sg elements mapped\n", n_elem); | 4729 | DPRINTK("%d sg elements mapped\n", n_elem); |
4730 | 4730 | qc->orig_n_elem = qc->n_elem; | |
4731 | qc->n_elem = n_elem; | 4731 | qc->n_elem = n_elem; |
4732 | qc->flags |= ATA_QCFLAG_DMAMAP; | 4732 | qc->flags |= ATA_QCFLAG_DMAMAP; |
4733 | 4733 | ||
diff --git a/include/linux/libata.h b/include/linux/libata.h index dd818c7decd7..fbf064e13ad5 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -530,6 +530,7 @@ struct ata_queued_cmd { | |||
530 | unsigned long flags; /* ATA_QCFLAG_xxx */ | 530 | unsigned long flags; /* ATA_QCFLAG_xxx */ |
531 | unsigned int tag; | 531 | unsigned int tag; |
532 | unsigned int n_elem; | 532 | unsigned int n_elem; |
533 | unsigned int orig_n_elem; | ||
533 | 534 | ||
534 | int dma_dir; | 535 | int dma_dir; |
535 | 536 | ||