Skip to contentSkip to conversation

modify the IO_TLB_SEGSIZE and IO_TLB_DEFAULT_SIZE configurable as flexible requirement about SW-IOMMU.

PATCH New Wang Xiaoming 1 participant 1 message Mar 9, 2015

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 modify the IO_TLB_SEGSIZE and IO_TLB_DEFAULT_SIZE configurable as flexible requirement about SW-IOMMU.

The maximum of SW-IOMMU is limited to 2^11*128 = 256K.
And the size of IO_TLB_DEFAULT_SIZE is limited to (64UL<<20) 64M now. While in different platform and different requirement this seems improper. So modifing the IO_TLB_SEGSIZE to io_tlb_segsize and IO_TLB_DEFAULT_SIZE to io_tlb_default_size which can configure by kernel cmdline. This can meet different requirement.

---
patch v1 make this change at Kconfig
which needs to edit the .config manually.
https://lkml.org/lkml/2015/1/25/571

patch v2 only change IO_TLB_SEGSIZE configurable.
https://lkml.org/lkml/2015/2/5/812

patch v3 parsing io_tlb_segsize and
io_tlb_default_size independently.
https://lkml.org/lkml/2015/2/15/217

patch v4 hasn't validated the data from
command line.
https://lkml.org/lkml/2015/2/17/114

patch v5 fix the postion of 'force'.
https://lkml.org/lkml/2015/3/3/84

 Documentation/kernel-parameters.txt  |    5 +-
 arch/mips/cavium-octeon/dma-octeon.c |    2 +-
 arch/mips/netlogic/common/nlm-dma.c  |    2 +-
 drivers/xen/swiotlb-xen.c            |    6 +--
 include/linux/swiotlb.h              |    8 +--
 lib/swiotlb.c                        |   99 ++++++++++++++++++++++++++--------
 6 files changed, 87 insertions(+), 35 deletions(-)
Documentation/kernel-parameters.txt +4 -1
index 4df73da..8463ef4 100644
@@ -3438,10 +3438,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			it if 0 is given (See Documentation/cgroups/memory.txt)
 
 	swiotlb=	[ARM,IA-64,PPC,MIPS,X86]
-			Format: { <int> | force }
+			Format: { <int>,force,<int>,<int>}
 			<int> -- Number of I/O TLB slabs
 			force -- force using of bounce buffers even if they
 			         wouldn't be automatically used by the kernel
+			<int> -- Maximum allowable number of contiguous slabs to map
+			<int> -- The size of SW-MMU mapped.
+			"Use ',' to seperate them."
 
 	switches=	[HW,M68k]
 
arch/mips/cavium-octeon/dma-octeon.c +1 -1
index 3778655..a521af6 100644
@@ -312,7 +312,7 @@ void __init plat_swiotlb_setup(void)
 		swiotlbsize = 64 * (1<<20);
 #endif
 	swiotlb_nslabs = swiotlbsize >> IO_TLB_SHIFT;
-	swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE);
+	swiotlb_nslabs = ALIGN(swiotlb_nslabs, io_tlb_segsize);
 	swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT;
 
 	octeon_swiotlb = alloc_bootmem_low_pages(swiotlbsize);
arch/mips/netlogic/common/nlm-dma.c +1 -1
index f3d4ae8..eeffa8f 100644
@@ -99,7 +99,7 @@ void __init plat_swiotlb_setup(void)
 
 	swiotlbsize = 1 << 20; /* 1 MB for now */
 	swiotlb_nslabs = swiotlbsize >> IO_TLB_SHIFT;
-	swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE);
+	swiotlb_nslabs = ALIGN(swiotlb_nslabs, io_tlb_segsize);
 	swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT;
 
 	nlm_swiotlb = alloc_bootmem_low_pages(swiotlbsize);
drivers/xen/swiotlb-xen.c +3 -3
index 810ad41..3b3e9fe 100644
@@ -164,11 +164,11 @@ xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
 	dma_addr_t dma_handle;
 	phys_addr_t p = virt_to_phys(buf);
 
-	dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT;
+	dma_bits = get_order(io_tlb_segsize << IO_TLB_SHIFT) + PAGE_SHIFT;
 
 	i = 0;
 	do {
-		int slabs = min(nslabs - i, (unsigned long)IO_TLB_SEGSIZE);
+		int slabs = min(nslabs - i, (unsigned long)io_tlb_segsize);
 
 		do {
 			rc = xen_create_contiguous_region(
@@ -187,7 +187,7 @@ static unsigned long xen_set_nslabs(unsigned long nr_tbl)
 {
 	if (!nr_tbl) {
 		xen_io_tlb_nslabs = (64 * 1024 * 1024 >> IO_TLB_SHIFT);
-		xen_io_tlb_nslabs = ALIGN(xen_io_tlb_nslabs, IO_TLB_SEGSIZE);
+		xen_io_tlb_nslabs = ALIGN(xen_io_tlb_nslabs, io_tlb_segsize);
 	} else
 		xen_io_tlb_nslabs = nr_tbl;
 
include/linux/swiotlb.h +1 -7
index e7a018e..13506db 100644
@@ -8,13 +8,7 @@ struct dma_attrs;
 struct scatterlist;
 
 extern int swiotlb_force;
-
-/*
- * Maximum allowable number of contiguous slabs to map,
- * must be a power of 2.  What is the appropriate value ?
- * The complexity of {map,unmap}_single is linearly dependent on this value.
- */
-#define IO_TLB_SEGSIZE	128
+extern int io_tlb_segsize;
 
 /*
  * log of the size of each IO TLB slab.  The number of slabs is command line
lib/swiotlb.c +77 -22

185 lines not on this page · raw message

Signature · 1 line
1.7.9.5