[PATCH -mm 03/11] x86: make pci-gart iommu respect the segment size limits

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <akpm@...>
Cc: <linux-kernel@...>, <linux-scsi@...>, <muli@...>, <fujita.tomonori@...>
Date: Wednesday, October 24, 2007 - 6:48 am

This patch makes pci-gart iommu respect segment size limits when
merging sg lists.

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

diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index c56e9ee..dfe3828 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -384,6 +384,8 @@ static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents,
 	int start;
 	unsigned long pages = 0;
 	int need = 0, nextneed;
+	unsigned int seg_size;
+	unsigned int max_seg_size;
 	struct scatterlist *s, *ps, *start_sg, *sgmap;
 
 	if (nents == 0) 
@@ -395,6 +397,8 @@ static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents,
 	out = 0;
 	start = 0;
 	start_sg = sgmap = sg;
+	seg_size = 0;
+	max_seg_size = dma_get_max_seg_size(dev);
 	ps = NULL; /* shut up gcc */
 	for_each_sg(sg, s, nents, i) {
 		dma_addr_t addr = sg_phys(s);
@@ -408,11 +412,13 @@ static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents,
 			/* 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 ||
+			    (s->length + seg_size > max_seg_size) ||
 			    (ps->offset + ps->length) % PAGE_SIZE) {
 				if (dma_map_cont(start_sg, i - start, sgmap,
 						  pages, need) < 0)
 					goto error;
 				out++;
+				seg_size = 0;
 				sgmap = sg_next(sgmap);
 				pages = 0;
 				start = i;
@@ -420,6 +426,7 @@ static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents,
 			}
 		}
 
+		seg_size += s->length;
 		need = nextneed;
 		pages += to_pages(s->offset, s->length);
 		ps = s;
-- 
1.5.2.4

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

Messages in current thread:
[PATCH -mm 0/11] fix iommu sg merging problem, FUJITA Tomonori, (Wed Oct 24, 6:47 am)
Re: [PATCH -mm 0/11] fix iommu sg merging problem, Jens Axboe, (Wed Oct 24, 9:24 am)
Re: [PATCH -mm 0/11] fix iommu sg merging problem, Jeff Garzik, (Wed Oct 24, 7:40 am)
Re: [PATCH -mm 0/11] fix iommu sg merging problem, FUJITA Tomonori, (Wed Oct 24, 10:32 am)
[PATCH -mm 01/11] add device_dma_parameters structure, FUJITA Tomonori, (Wed Oct 24, 6:48 am)
[PATCH -mm 02/11] PCI: add device_dma_parameters support, FUJITA Tomonori, (Wed Oct 24, 6:48 am)
Re: [PATCH -mm 02/11] PCI: add device_dma_parameters support, FUJITA Tomonori, (Wed Oct 24, 9:41 am)
[PATCH -mm 03/11] x86: make pci-gart iommu respect the segme..., FUJITA Tomonori, (Wed Oct 24, 6:48 am)
[PATCH -mm 11/11] aacraid: use pci_set_dma_max_seg_size, FUJITA Tomonori, (Wed Oct 24, 6:48 am)
RE: [PATCH -mm 11/11] aacraid: use pci_set_dma_max_seg_size, FUJITA Tomonori, (Wed Oct 24, 12:21 pm)
Re: [PATCH -mm 11/11] aacraid: use pci_set_dma_max_seg_size, FUJITA Tomonori, (Wed Oct 24, 7:35 am)