diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2007-10-17 07:08:48 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2007-10-17 07:11:59 -0400 |
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, | |||
475 | #define SG_ENT_PHYS_ADDRESS(SG) \ | 475 | #define SG_ENT_PHYS_ADDRESS(SG) \ |
476 | (__pa(page_address((SG)->page)) + (SG)->offset) | 476 | (__pa(page_address((SG)->page)) + (SG)->offset) |
477 | 477 | ||
478 | static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, | 478 | static void fill_sg(iopte_t *iopte, struct scatterlist *sg, |
479 | int nused, int nelems, | 479 | int nused, int nelems, |
480 | unsigned long iopte_protection) | 480 | unsigned long iopte_protection) |
481 | { | 481 | { |
482 | struct scatterlist *dma_sg = sg; | 482 | struct scatterlist *dma_sg = sg; |
483 | struct scatterlist *sg_end = sg_last(sg, nelems); | ||
484 | int i; | 483 | int i; |
485 | 484 | ||
486 | for (i = 0; i < nused; i++) { | 485 | for (i = 0; i < nused; i++) { |
@@ -516,6 +515,7 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, | |||
516 | break; | 515 | break; |
517 | } | 516 | } |
518 | sg = sg_next(sg); | 517 | sg = sg_next(sg); |
518 | nelems--; | ||
519 | } | 519 | } |
520 | 520 | ||
521 | pteval = iopte_protection | (pteval & IOPTE_PAGE); | 521 | pteval = iopte_protection | (pteval & IOPTE_PAGE); |
@@ -529,18 +529,20 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, | |||
529 | 529 | ||
530 | pteval = (pteval & IOPTE_PAGE) + len; | 530 | pteval = (pteval & IOPTE_PAGE) + len; |
531 | sg = sg_next(sg); | 531 | sg = sg_next(sg); |
532 | nelems--; | ||
532 | 533 | ||
533 | /* Skip over any tail mappings we've fully mapped, | 534 | /* Skip over any tail mappings we've fully mapped, |
534 | * adjusting pteval along the way. Stop when we | 535 | * adjusting pteval along the way. Stop when we |
535 | * detect a page crossing event. | 536 | * detect a page crossing event. |
536 | */ | 537 | */ |
537 | while (sg != sg_end && | 538 | while (nelems && |
538 | (pteval << (64 - IO_PAGE_SHIFT)) != 0UL && | 539 | (pteval << (64 - IO_PAGE_SHIFT)) != 0UL && |
539 | (pteval == SG_ENT_PHYS_ADDRESS(sg)) && | 540 | (pteval == SG_ENT_PHYS_ADDRESS(sg)) && |
540 | ((pteval ^ | 541 | ((pteval ^ |
541 | (SG_ENT_PHYS_ADDRESS(sg) + sg->length - 1UL)) >> IO_PAGE_SHIFT) == 0UL) { | 542 | (SG_ENT_PHYS_ADDRESS(sg) + sg->length - 1UL)) >> IO_PAGE_SHIFT) == 0UL) { |
542 | pteval += sg->length; | 543 | pteval += sg->length; |
543 | sg = sg_next(sg); | 544 | sg = sg_next(sg); |
545 | nelems--; | ||
544 | } | 546 | } |
545 | if ((pteval << (64 - IO_PAGE_SHIFT)) == 0UL) | 547 | if ((pteval << (64 - IO_PAGE_SHIFT)) == 0UL) |
546 | pteval = ~0UL; | 548 | pteval = ~0UL; |