[PATCH -mm 2/2] SPARC64: remove unused calc_npages() in iommu_common.h

Previous thread: none

Next thread: [PATCH 0/4 v4] dma: dma_{un}map_{single|sg}_attrs() interface by akepner on Wednesday, March 12, 2008 - 9:00 pm. (5 messages)
From: FUJITA Tomonori
Date: Wednesday, March 12, 2008 - 8:47 pm

Some IOMMUs allocate memory areas spanning LLD's segment boundary
limit. It forces low level drivers to have a workaround to adjust
scatter lists that the IOMMU builds. We are in the process of making
all the IOMMUs respect the segment boundary limits to remove such work
around in LLDs.

SPARC64 IOMMUs were rewritten to use the IOMMU helper functions and
the commit 89c94f2f70d093f59b55d3ea8042d13889169346 made the IOMMUs
not allocate memory areas spanning the segment boundary limit.

However, SPARC64 IOMMUs allocate memory areas first then try to merge
them (while some IOMMUs walk through all the sg entries to see how
they can be merged first and allocate memory areas). So SPARC64 IOMMUs
also need the boundary limit checking when they try to merge sg
entries.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Miller <davem@davemloft.net>
---
 arch/sparc64/kernel/iommu.c        |   12 ++++++++++--
 arch/sparc64/kernel/iommu_common.h |   13 +++++++++++++
 arch/sparc64/kernel/pci_sun4v.c    |   12 ++++++++++--
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/arch/sparc64/kernel/iommu.c b/arch/sparc64/kernel/iommu.c
index fbaab34..e009a14 100644
--- a/arch/sparc64/kernel/iommu.c
+++ b/arch/sparc64/kernel/iommu.c
@@ -516,9 +516,11 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
 	unsigned long flags, handle, prot, ctx;
 	dma_addr_t dma_next = 0, dma_addr;
 	unsigned int max_seg_size;
+	unsigned long seg_boundary_size;
 	int outcount, incount, i;
 	struct strbuf *strbuf;
 	struct iommu *iommu;
+	unsigned long base_shift;
 
 	BUG_ON(direction == DMA_NONE);
 
@@ -549,8 +551,11 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
 	outs->dma_length = 0;
 
 	max_seg_size = dma_get_max_seg_size(dev);
+	seg_boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
+				  IO_PAGE_SIZE) >> IO_PAGE_SHIFT;
+	base_shift = iommu->page_table_map_base >> ...
From: FUJITA Tomonori
Date: Wednesday, March 12, 2008 - 8:47 pm

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Miller <davem@davemloft.net>
---
 arch/sparc64/kernel/iommu_common.h |   13 -------------
 1 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/arch/sparc64/kernel/iommu_common.h b/arch/sparc64/kernel/iommu_common.h
index 87ace49..f3575a6 100644
--- a/arch/sparc64/kernel/iommu_common.h
+++ b/arch/sparc64/kernel/iommu_common.h
@@ -46,19 +46,6 @@ static inline unsigned long iommu_num_pages(unsigned long vaddr,
 	return npages;
 }
 
-static inline unsigned long calc_npages(struct scatterlist *sglist, int nelems)
-{
-	unsigned long i, npages = 0;
-	struct scatterlist *sg;
-
-	for_each_sg(sglist, sg, nelems, i) {
-		unsigned long paddr = SG_ENT_PHYS_ADDRESS(sg);
-		npages += iommu_num_pages(paddr, sg->length);
-	}
-
-	return npages;
-}
-
 static inline int is_span_boundary(unsigned long entry,
 				   unsigned long shift,
 				   unsigned long boundary_size,
-- 
1.5.3.6

--

From: David Miller
Date: Saturday, March 22, 2008 - 5:23 pm

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Acked-by: David S. Miller <davem@davemloft.net>
--

From: David Miller
Date: Saturday, March 22, 2008 - 5:23 pm

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Acked-by: David S. Miller <davem@davemloft.net>
--

Previous thread: none

Next thread: [PATCH 0/4 v4] dma: dma_{un}map_{single|sg}_attrs() interface by akepner on Wednesday, March 12, 2008 - 9:00 pm. (5 messages)