diff options
Diffstat (limited to 'arch/sparc64/kernel/iommu_common.c')
-rw-r--r-- | arch/sparc64/kernel/iommu_common.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/sparc64/kernel/iommu_common.c b/arch/sparc64/kernel/iommu_common.c index efd5dff85f60..72a4acfe8c7b 100644 --- a/arch/sparc64/kernel/iommu_common.c +++ b/arch/sparc64/kernel/iommu_common.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * Copyright (C) 1999 David S. Miller (davem@redhat.com) | 4 | * Copyright (C) 1999 David S. Miller (davem@redhat.com) |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <linux/dma-mapping.h> | ||
7 | #include "iommu_common.h" | 8 | #include "iommu_common.h" |
8 | 9 | ||
9 | /* You are _strongly_ advised to enable the following debugging code | 10 | /* You are _strongly_ advised to enable the following debugging code |
@@ -201,21 +202,24 @@ void verify_sglist(struct scatterlist *sglist, int nents, iopte_t *iopte, int np | |||
201 | } | 202 | } |
202 | #endif | 203 | #endif |
203 | 204 | ||
204 | unsigned long prepare_sg(struct scatterlist *sg, int nents) | 205 | unsigned long prepare_sg(struct device *dev, struct scatterlist *sg, int nents) |
205 | { | 206 | { |
206 | struct scatterlist *dma_sg = sg; | 207 | struct scatterlist *dma_sg = sg; |
207 | unsigned long prev; | 208 | unsigned long prev; |
208 | u32 dent_addr, dent_len; | 209 | u32 dent_addr, dent_len; |
210 | unsigned int max_seg_size; | ||
209 | 211 | ||
210 | prev = (unsigned long) sg_virt(sg); | 212 | prev = (unsigned long) sg_virt(sg); |
211 | prev += (unsigned long) (dent_len = sg->length); | 213 | prev += (unsigned long) (dent_len = sg->length); |
212 | dent_addr = (u32) ((unsigned long)(sg_virt(sg)) & (IO_PAGE_SIZE - 1UL)); | 214 | dent_addr = (u32) ((unsigned long)(sg_virt(sg)) & (IO_PAGE_SIZE - 1UL)); |
215 | max_seg_size = dma_get_max_seg_size(dev); | ||
213 | while (--nents) { | 216 | while (--nents) { |
214 | unsigned long addr; | 217 | unsigned long addr; |
215 | 218 | ||
216 | sg = sg_next(sg); | 219 | sg = sg_next(sg); |
217 | addr = (unsigned long) sg_virt(sg); | 220 | addr = (unsigned long) sg_virt(sg); |
218 | if (! VCONTIG(prev, addr)) { | 221 | if (! VCONTIG(prev, addr) || |
222 | dent_len + sg->length > max_seg_size) { | ||
219 | dma_sg->dma_address = dent_addr; | 223 | dma_sg->dma_address = dent_addr; |
220 | dma_sg->dma_length = dent_len; | 224 | dma_sg->dma_length = dent_len; |
221 | dma_sg = sg_next(dma_sg); | 225 | dma_sg = sg_next(dma_sg); |