]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] ppc64: iommu vmerge fix
authorBrian King <brking@us.ibm.com>
Wed, 17 Aug 2005 21:32:18 +0000 (07:32 +1000)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 17 Aug 2005 21:41:22 +0000 (14:41 -0700)
This fixes a bug in the PPC64 iommu vmerge code which results in the
potential for iommu_unmap_sg to go off unmapping more than it should.

This was found on a test system which resulted in PCI bus errors due to
PCI memory being unmapped while DMAs were still in progress.

Signed-off-by: Brian King <brking@us.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/ppc64/kernel/iommu.c

index 8316426ccaf60036c59d3cd45e18835d8e19c88a..845eebd1e28de803904778c7ed1dc39fb61a7abc 100644 (file)
@@ -242,7 +242,7 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
        dma_addr_t dma_next = 0, dma_addr;
        unsigned long flags;
        struct scatterlist *s, *outs, *segstart;
-       int outcount;
+       int outcount, incount;
        unsigned long handle;
 
        BUG_ON(direction == DMA_NONE);
@@ -252,6 +252,7 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
 
        outs = s = segstart = &sglist[0];
        outcount = 1;
+       incount = nelems;
        handle = 0;
 
        /* Init first segment length for backout at failure */
@@ -338,10 +339,10 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
 
        DBG("mapped %d elements:\n", outcount);
 
-       /* For the sake of iommu_free_sg, we clear out the length in the
+       /* For the sake of iommu_unmap_sg, we clear out the length in the
         * next entry of the sglist if we didn't fill the list completely
         */
-       if (outcount < nelems) {
+       if (outcount < incount) {
                outs++;
                outs->dma_address = DMA_ERROR_CODE;
                outs->dma_length = 0;