public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: FUJITA Tomonori <tomof@acm.org>
To: James.Bottomley@SteelEye.com, jens.axboe@oracle.com,
	hch@infradead.org, jeff@garzik.org, gregkh@suse.de, hare@suse.de,
	linux-scsi@vger.kernel.org
Cc: fujita.tomonori@lab.ntt.co.jp
Subject: [PATCH 5/5] x86-64: pci-gart iommu uses max_segment_size
Date: Wed, 26 Sep 2007 17:58:03 +0900	[thread overview]
Message-ID: <20070925142201H.tomof@acm.org> (raw)

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


                 reply	other threads:[~2007-09-26  8:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20070925142201H.tomof@acm.org \
    --to=tomof@acm.org \
    --cc=James.Bottomley@SteelEye.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=gregkh@suse.de \
    --cc=hare@suse.de \
    --cc=hch@infradead.org \
    --cc=jeff@garzik.org \
    --cc=jens.axboe@oracle.com \
    --cc=linux-scsi@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