aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorFUJITA Tomonori <tomof@acm.org>2008-02-05 01:27:57 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-05 12:44:10 -0500
commit740c3ce66700640a6e6136ff679b067e92125794 (patch)
tree720f3d4c847e4576ed8a5df325d12701adde6616 /arch
parent42d00284e16bf998f8f93ce5d061df81b0ff283e (diff)
iommu sg merging: ppc: make iommu respect the segment size limits
This patch makes iommu respect segment size limits when merging sg lists. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Jeff Garzik <jeff@garzik.org> Cc: James Bottomley <James.Bottomley@steeleye.com> Acked-by: Jens Axboe <jens.axboe@oracle.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/kernel/dma_64.c2
-rw-r--r--arch/powerpc/kernel/iommu.c8
2 files changed, 7 insertions, 3 deletions
diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 84239076a5b8..f9de2fddf4d6 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -68,7 +68,7 @@ static void dma_iommu_unmap_single(struct device *dev, dma_addr_t dma_handle,
68static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist, 68static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
69 int nelems, enum dma_data_direction direction) 69 int nelems, enum dma_data_direction direction)
70{ 70{
71 return iommu_map_sg(dev->archdata.dma_data, sglist, nelems, 71 return iommu_map_sg(dev, sglist, nelems,
72 device_to_mask(dev), direction); 72 device_to_mask(dev), direction);
73} 73}
74 74
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index a3c406aca664..d0e6fac4ef42 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -270,16 +270,18 @@ static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
270 spin_unlock_irqrestore(&(tbl->it_lock), flags); 270 spin_unlock_irqrestore(&(tbl->it_lock), flags);
271} 271}
272 272
273int iommu_map_sg(struct iommu_table *tbl, struct scatterlist *sglist, 273int iommu_map_sg(struct device *dev, struct scatterlist *sglist,
274 int nelems, unsigned long mask, 274 int nelems, unsigned long mask,
275 enum dma_data_direction direction) 275 enum dma_data_direction direction)
276{ 276{
277 struct iommu_table *tbl = dev->archdata.dma_data;
277 dma_addr_t dma_next = 0, dma_addr; 278 dma_addr_t dma_next = 0, dma_addr;
278 unsigned long flags; 279 unsigned long flags;
279 struct scatterlist *s, *outs, *segstart; 280 struct scatterlist *s, *outs, *segstart;
280 int outcount, incount, i; 281 int outcount, incount, i;
281 unsigned int align; 282 unsigned int align;
282 unsigned long handle; 283 unsigned long handle;
284 unsigned int max_seg_size;
283 285
284 BUG_ON(direction == DMA_NONE); 286 BUG_ON(direction == DMA_NONE);
285 287
@@ -298,6 +300,7 @@ int iommu_map_sg(struct iommu_table *tbl, struct scatterlist *sglist,
298 300
299 spin_lock_irqsave(&(tbl->it_lock), flags); 301 spin_lock_irqsave(&(tbl->it_lock), flags);
300 302
303 max_seg_size = dma_get_max_seg_size(dev);
301 for_each_sg(sglist, s, nelems, i) { 304 for_each_sg(sglist, s, nelems, i) {
302 unsigned long vaddr, npages, entry, slen; 305 unsigned long vaddr, npages, entry, slen;
303 306
@@ -344,7 +347,8 @@ int iommu_map_sg(struct iommu_table *tbl, struct scatterlist *sglist,
344 /* We cannot merge if: 347 /* We cannot merge if:
345 * - allocated dma_addr isn't contiguous to previous allocation 348 * - allocated dma_addr isn't contiguous to previous allocation
346 */ 349 */
347 if (novmerge || (dma_addr != dma_next)) { 350 if (novmerge || (dma_addr != dma_next) ||
351 (outs->dma_length + s->length > max_seg_size)) {
348 /* Can't merge: create a new segment */ 352 /* Can't merge: create a new segment */
349 segstart = s; 353 segstart = s;
350 outcount++; 354 outcount++;