Re: [PATCH 8/12] x86-64: update iommu/dma mapping functions to sg helpers

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jens Axboe
Date: Monday, May 21, 2007 - 12:13 am

On Mon, May 21 2007, Benny Halevy wrote:

Did you see this one, I cooked it up after sending that mail out. Please
review :-)

diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index 2e22a3a..b16384f 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -381,7 +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;
-	struct scatterlist *s, *ps, *start_sg;
+	struct scatterlist *s, *ps, *start_sg, *sgmap;
 
 	if (nents == 0) 
 		return 0;
@@ -391,7 +391,7 @@ int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
 
 	out = 0;
 	start = 0;
-	start_sg = sg;
+	start_sg = sgmap = sg;
 	ps = NULL; /* shut up gcc */
 	for_each_sg(sg, s, nents, i) {
 		dma_addr_t addr = page_to_phys(s->page) + s->offset;
@@ -405,11 +405,12 @@ 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 ||
-			    (ps->offset + ps->length) % PAGE_SIZE) { 
-				if (dma_map_cont(start_sg, i - start, sg+out,
+			    (ps->offset + ps->length) % PAGE_SIZE) {
+				if (dma_map_cont(start_sg, i - start, sgmap,
 						  pages, need) < 0)
 					goto error;
 				out++;
+				sgmap = sg_next(sgmap);
 				pages = 0;
 				start = i;
 				start_sg = s;
@@ -420,7 +421,7 @@ int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
 		pages += to_pages(s->offset, s->length);
 		ps = s;
 	}
-	if (dma_map_cont(start_sg, i - start, sg+out, pages, need) < 0)
+	if (dma_map_cont(start_sg, i - start, sgmap, pages, need) < 0)
 		goto error;
 	out++;
 	flush_gart();

-- 
Jens Axboe

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 3/12] libata: convert to using sg helpers, Jens Axboe, (Thu May 10, 4:40 am)
[PATCH 4/12] block: convert to using sg helpers, Jens Axboe, (Thu May 10, 4:40 am)
[PATCH 5/12] scsi: convert to using sg helpers, Jens Axboe, (Thu May 10, 4:40 am)
[PATCH 9/12] x86-64: enable sg chaining, Jens Axboe, (Thu May 10, 4:40 am)
[PATCH 10/12] scsi: simplify scsi_free_sgtable(), Jens Axboe, (Thu May 10, 4:40 am)
Re: [PATCH 8/12] x86-64: update iommu/dma mapping function ..., Jens Axboe, (Mon May 21, 12:13 am)