public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5/5] x86-64: pci-gart iommu uses max_segment_size
@ 2007-09-26  8:58 FUJITA Tomonori
  0 siblings, 0 replies; only message in thread
From: FUJITA Tomonori @ 2007-09-26  8:58 UTC (permalink / raw)
  To: James.Bottomley, jens.axboe, hch, jeff, gregkh, hare, linux-scsi
  Cc: fujita.tomonori

This enables pci-gart iommu to merge sg lists properly about lld's max
segment size limit.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 arch/x86_64/kernel/pci-gart.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index 4918c57..be98341 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -381,6 +381,7 @@ int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
 	int start;
 	unsigned long pages = 0;
 	int need = 0, nextneed;
+	unsigned len;
 
 	if (nents == 0) 
 		return 0;
@@ -390,6 +391,7 @@ int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
 
 	out = 0;
 	start = 0;
+	len = 0;
 	for (i = 0; i < nents; i++) {
 		struct scatterlist *s = &sg[i];
 		dma_addr_t addr = page_to_phys(s->page) + s->offset;
@@ -404,16 +406,20 @@ int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
 			/* Can only merge when the last chunk ends on a page 
 			   boundary and the new one doesn't have an offset. */
 			if (!iommu_merge || !nextneed || !need || s->offset ||
+			    (dev->max_segment_size &&
+			     dev->max_segment_size < s->length + len) ||
 			    (ps->offset + ps->length) % PAGE_SIZE) { 
 				if (dma_map_cont(sg, start, i, sg+out, pages,
 						 need) < 0)
 					goto error;
 				out++;
+				len = 0;
 				pages = 0;
 				start = i;	
 			}
 		}
 
+		len += s->length;
 		need = nextneed;
 		pages += to_pages(s->offset, s->length);
 	}
-- 
1.5.2.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-09-26  8:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-26  8:58 [PATCH 5/5] x86-64: pci-gart iommu uses max_segment_size FUJITA Tomonori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox