diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2007-10-17 04:08:48 -0700 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2007-10-17 13:11:59 +0200 |
commit | 5804509e652fd26227f6da732d5445af444730d3 (patch) | |
tree | 2d518870a85913d0a3483eecadbc07be85e9a2cf /arch/sparc64/kernel/iommu.c | |
parent | 60573b874b03d22678614ca1e73f6b15c1b53b40 (diff) |
Fix loop terminating conditions in fill_sg().
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'arch/sparc64/kernel/iommu.c')
-rw-r--r-- | arch/sparc64/kernel/iommu.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/arch/sparc64/kernel/iommu.c b/arch/sparc64/kernel/iommu.c index 5d4e96dba412..29af777d7ac9 100644 --- a/arch/sparc64/kernel/iommu.c +++ b/arch/sparc64/kernel/iommu.c @@ -475,12 +475,11 @@ static void dma_4u_unmap_single(struct device *dev, dma_addr_t bus_addr, #define SG_ENT_PHYS_ADDRESS(SG) \ (__pa(page_address((SG)->page)) + (SG)->offset) -static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, - int nused, int nelems, - unsigned long iopte_protection) +static void fill_sg(iopte_t *iopte, struct scatterlist *sg, + int nused, int nelems, + unsigned long iopte_protection) { struct scatterlist *dma_sg = sg; - struct scatterlist *sg_end = sg_last(sg, nelems); int i; for (i = 0; i < nused; i++) { @@ -516,6 +515,7 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, break; } sg = sg_next(sg); + nelems--; } pteval = iopte_protection | (pteval & IOPTE_PAGE); @@ -529,18 +529,20 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, pteval = (pteval & IOPTE_PAGE) + len; sg = sg_next(sg); + nelems--; /* Skip over any tail mappings we've fully mapped, * adjusting pteval along the way. Stop when we * detect a page crossing event. */ - while (sg != sg_end && + while (nelems && (pteval << (64 - IO_PAGE_SHIFT)) != 0UL && (pteval == SG_ENT_PHYS_ADDRESS(sg)) && ((pteval ^ (SG_ENT_PHYS_ADDRESS(sg) + sg->length - 1UL)) >> IO_PAGE_SHIFT) == 0UL) { pteval += sg->length; sg = sg_next(sg); + nelems--; } if ((pteval << (64 - IO_PAGE_SHIFT)) == 0UL) pteval = ~0UL; |