linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Benny Halevy <bhalevy@panasas.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 8/12] x86-64: update iommu/dma mapping functions to sg   helpers
Date: Mon, 21 May 2007 09:13:22 +0200	[thread overview]
Message-ID: <20070521071322.GK14746@kernel.dk> (raw)
In-Reply-To: <465145BB.7050301@panasas.com>

On Mon, May 21 2007, Benny Halevy wrote:
> Jens Axboe wrote:
> > On Thu, May 10 2007, Benny Halevy wrote:
> >> @@ -411,12 +406,13 @@ int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
> >>  			   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(sg, start, i, sg+out, pages,
> >> -						 need) < 0)
> >> +				if (dma_map_cont(start_sg, i - start, sg+out,
> >> +						  pages, need) < 0)
> >>  					goto error;
> >>  				out++;
> >>  				pages = 0;
> >> -				start = i;	
> >> +				start = i;
> >> +				start_sg = s;
> >>  			}
> >>  		}
> >>  
> >> @@ -424,7 +420,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(sg, start, i, sg+out, pages, need) < 0)
> >> +	if (dma_map_cont(start_sg, i - start, sg+out, pages, need) < 0)
> >>  		goto error;
> >>  	out++;
> >>  	flush_gart();
> > 
> > Your patch is (very) buggy, the whole premise of doing chained sg
> > entries makes sg + int illegal!
> > 
> 
> You're right.  I'll send a fix asap.

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


  reply	other threads:[~2007-05-21  7:14 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-10 11:40 [PATCH 0/12] Chaining sg lists for bio IO commands v4 Jens Axboe
2007-05-10 11:40 ` [PATCH 1/12] crypto: don't pollute the global namespace with sg_next() Jens Axboe
2007-05-10 13:55   ` Benny Halevy
2007-05-10 21:37     ` Jens Axboe
2007-05-11  5:20       ` Benny Halevy
2007-05-12  2:34         ` Herbert Xu
2007-05-10 11:40 ` [PATCH 2/12] Add sg helpers for iterating over a scatterlist table Jens Axboe
2007-05-10 11:40 ` [PATCH 3/12] libata: convert to using sg helpers Jens Axboe
2007-05-10 11:40 ` [PATCH 4/12] block: " Jens Axboe
2007-05-10 11:40 ` [PATCH 5/12] scsi: " Jens Axboe
2007-05-10 11:40 ` [PATCH 6/12] i386 dma_map_sg: " Jens Axboe
2007-05-10 11:40 ` [PATCH 7/12] i386 sg: add support for chaining scatterlists Jens Axboe
2007-05-10 13:00   ` Satyam Sharma
2007-05-10 13:23   ` Satyam Sharma
2007-05-10 11:40 ` [PATCH 8/12] x86-64: update iommu/dma mapping functions to sg helpers Jens Axboe
2007-05-10 13:48   ` Benny Halevy
2007-05-10 21:38     ` Jens Axboe
2007-05-21  6:32     ` Jens Axboe
2007-05-21  7:09       ` Benny Halevy
2007-05-21  7:13         ` Jens Axboe [this message]
2007-05-10 11:40 ` [PATCH 9/12] x86-64: enable sg chaining Jens Axboe
2007-05-10 11:40 ` [PATCH 10/12] scsi: simplify scsi_free_sgtable() Jens Axboe
2007-05-10 11:40 ` [PATCH 11/12] SCSI: support for allocating large scatterlists Jens Axboe
2007-05-10 11:40 ` [PATCH 12/12] ll_rw_blk: temporarily enable max_segments tweaking Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070521071322.GK14746@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=bhalevy@panasas.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).