diff options
Diffstat (limited to 'arch/sparc64/kernel/pci_sun4v.c')
-rw-r--r-- | arch/sparc64/kernel/pci_sun4v.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c index cacacfae5451..fe46ace3e59f 100644 --- a/arch/sparc64/kernel/pci_sun4v.c +++ b/arch/sparc64/kernel/pci_sun4v.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/irq.h> | 13 | #include <linux/irq.h> |
14 | #include <linux/msi.h> | 14 | #include <linux/msi.h> |
15 | #include <linux/log2.h> | 15 | #include <linux/log2.h> |
16 | #include <linux/scatterlist.h> | ||
17 | 16 | ||
18 | #include <asm/iommu.h> | 17 | #include <asm/iommu.h> |
19 | #include <asm/irq.h> | 18 | #include <asm/irq.h> |
@@ -369,12 +368,11 @@ static void dma_4v_unmap_single(struct device *dev, dma_addr_t bus_addr, | |||
369 | #define SG_ENT_PHYS_ADDRESS(SG) \ | 368 | #define SG_ENT_PHYS_ADDRESS(SG) \ |
370 | (__pa(page_address((SG)->page)) + (SG)->offset) | 369 | (__pa(page_address((SG)->page)) + (SG)->offset) |
371 | 370 | ||
372 | static inline long fill_sg(long entry, struct device *dev, | 371 | static long fill_sg(long entry, struct device *dev, |
373 | struct scatterlist *sg, | 372 | struct scatterlist *sg, |
374 | int nused, int nelems, unsigned long prot) | 373 | int nused, int nelems, unsigned long prot) |
375 | { | 374 | { |
376 | struct scatterlist *dma_sg = sg; | 375 | struct scatterlist *dma_sg = sg; |
377 | struct scatterlist *sg_end = sg_last(sg, nelems); | ||
378 | unsigned long flags; | 376 | unsigned long flags; |
379 | int i; | 377 | int i; |
380 | 378 | ||
@@ -415,6 +413,7 @@ static inline long fill_sg(long entry, struct device *dev, | |||
415 | break; | 413 | break; |
416 | } | 414 | } |
417 | sg = sg_next(sg); | 415 | sg = sg_next(sg); |
416 | nelems--; | ||
418 | } | 417 | } |
419 | 418 | ||
420 | pteval = (pteval & IOPTE_PAGE); | 419 | pteval = (pteval & IOPTE_PAGE); |
@@ -433,19 +432,20 @@ static inline long fill_sg(long entry, struct device *dev, | |||
433 | 432 | ||
434 | pteval = (pteval & IOPTE_PAGE) + len; | 433 | pteval = (pteval & IOPTE_PAGE) + len; |
435 | sg = sg_next(sg); | 434 | sg = sg_next(sg); |
435 | nelems--; | ||
436 | 436 | ||
437 | /* Skip over any tail mappings we've fully mapped, | 437 | /* Skip over any tail mappings we've fully mapped, |
438 | * adjusting pteval along the way. Stop when we | 438 | * adjusting pteval along the way. Stop when we |
439 | * detect a page crossing event. | 439 | * detect a page crossing event. |
440 | */ | 440 | */ |
441 | while ((pteval << (64 - IO_PAGE_SHIFT)) != 0UL && | 441 | while (nelems && |
442 | (pteval << (64 - IO_PAGE_SHIFT)) != 0UL && | ||
442 | (pteval == SG_ENT_PHYS_ADDRESS(sg)) && | 443 | (pteval == SG_ENT_PHYS_ADDRESS(sg)) && |
443 | ((pteval ^ | 444 | ((pteval ^ |
444 | (SG_ENT_PHYS_ADDRESS(sg) + sg->length - 1UL)) >> IO_PAGE_SHIFT) == 0UL) { | 445 | (SG_ENT_PHYS_ADDRESS(sg) + sg->length - 1UL)) >> IO_PAGE_SHIFT) == 0UL) { |
445 | pteval += sg->length; | 446 | pteval += sg->length; |
446 | if (sg == sg_end) | ||
447 | break; | ||
448 | sg = sg_next(sg); | 447 | sg = sg_next(sg); |
448 | nelems--; | ||
449 | } | 449 | } |
450 | if ((pteval << (64 - IO_PAGE_SHIFT)) == 0UL) | 450 | if ((pteval << (64 - IO_PAGE_SHIFT)) == 0UL) |
451 | pteval = ~0UL; | 451 | pteval = ~0UL; |