modify the IO_TLB_SEGSIZE and IO_TLB_DEFAULT_SIZE configurable as flexible requirement about SW-IOMMU.
Subsystems (6)
PATCH v5 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 andio_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
Documentation/kernel-parameters.txt | 9 ++++- 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 | 68 +++++++++++++++++++++++++--------- 6 files changed, 65 insertions(+), 30 deletions(-)
Documentation/kernel-parameters.txt +8 -1
@@ -3438,10 +3438,17 @@ 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. + Using "," to separate them one by one. + Example: + BOARD_KERNEL_CMDLINE += swiotlb=32768,force,512,268435456 + io_tlb_nslabs=32768, swiotlb_force=1, + io_tlb_segsize=512, io_tlb_default_size=268435456 switches= [HW,M68k]
arch/mips/cavium-octeon/dma-octeon.c +1 -1
@@ -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
@@ -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
@@ -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
@@ -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 +51 -17
154 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Quoted 18 lines · Wang Xiaoming
The maximum of SW-IOMMU is limited to 2^11*128 = 256K.
And the size ofIO_TLB_DEFAULT_SIZEis limited to (64UL<<20) 64M now. While in different platform and different requirement this seems improper. So modifing theIO_TLB_SEGSIZEtoio_tlb_segsizeandIO_TLB_DEFAULT_SIZEtoio_tlb_default_sizewhich can configure by kernel cmdline. This can meet different requirement.Signed-off-by Chuansheng Liu <[email protected]>Signed-off-by Zhang Dongxing <[email protected]>Signed-off-by Wang Xiaoming <[email protected]>---
patch v1 make this change atKconfig
which needs to edit the .config manually.
https://lkml.org/lkml/2015/1/25/571patch v2 only change
IO_TLB_SEGSIZEconfigurable.
https://lkml.org/lkml/2015/2/5/812
Quoted 6 lines
patch v3 parsing
io_tlb_segsizeandio_tlb_default_sizeindependently.
https://lkml.org/lkml/2015/2/15/217patch v4 hasn't validated the data from
command line.
Thank you for redoing this per review.
Quoted 15 lines
https://lkml.org/lkml/2015/2/17/114
Documentation/kernel-parameters.txt | 9 ++++- 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 | 68 +++++++++++++++++++++++++--------- 6 files changed, 65 insertions(+), 30 deletions(-)Documentation/kernel-parameters.txt +0
-0
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3441
Quoted 5 lines
Documentation/kernel-parameters.txt +1
-1@@ -3438,10 +3438,17 @@ 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>}
,
s/|/,/
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3447
Quoted 6 lines
Documentation/kernel-parameters.txt +3
-0<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. + Using "," to separate them one by one.
"Use ',' to seperate them."
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3451
Quoted 4 lines
Documentation/kernel-parameters.txt +4
-0+ Example: + BOARD_KERNEL_CMDLINE += swiotlb=32768,force,512,268435456 + io_tlb_nslabs=32768, swiotlb_force=1, + io_tlb_segsize=512, io_tlb_default_size=268435456
I think you can remove the example - and just have it in the C code.
Quoted 81 lines
Documentation/kernel-parameters.txt +0
-0switches= [HW,M68k]arch/mips/cavium-octeon/dma-octeon.c +1
-1@@ -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@@ -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@@ -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@@ -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 +0
-0@@ -56,6 +56,24 @@int swiotlb_force;
lib/swiotlb.c line 66
Quoted 10 lines
lib/swiotlb.c +8
-0/* +* default to 128 +* Maximum allowable number of contiguous slabs to map, +* must be a power of 2. What is the appropriate value ? +* define io_tlb_segsize as a parameter +* which can be changed dynamically in config file for special usage. +* The complexity of {map,unmap}_single is linearly dependent on this value. +*/ +#define IO_TLB_SEGSIZE 128
Add the tab back please.
lib/swiotlb.c line 71
Quoted 5 lines
lib/swiotlb.c +5
-0+int io_tlb_segsize =IO_TLB_SEGSIZE ; + +/* default to 64MB +* define io_tlb_default_size as a parameter +* which can be changed dynamically in config file for special usage.
.. or as a parameter during bootup.
Quoted 12 lines
lib/swiotlb.c +5
-0+*/ +#define IO_TLB_DEFAULT_SIZE (64UL<<20) +static unsigned long io_tlb_default_size =IO_TLB_DEFAULT_SIZE ; + +/* * Used to do a quick range check in swiotlb_tbl_unmap_single and * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this * API. @@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 );
lib/swiotlb.c setup_io_tlb_npages(char *str) · line 128
Quoted 10 lines
lib/swiotlb.c +3
-3-/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); }if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }
So the format is now:
Format: { <int> | force | <int> | <int>}which means I can do
32,22323,force
Or
force,32
Or
32,force
I think you need to make function be inside a loop to deal with 'force' being at odd locations.
Quoted 130 lines
lib/swiotlb.c +30
-14+if (*str ==',' ) + ++str; +if (isdigit (*str)) { +int n =0 ; + io_tlb_segsize =simple_strtoul (str, &str,0 ); + io_tlb_segsize =ALIGN (io_tlb_segsize,IO_TLB_SEGSIZE ); +while ((io_tlb_segsize -1 ) >> n) + n++; + io_tlb_segsize = (1 << n); + } +if (*str ==',' ) + ++str; +if (isdigit (*str)) { + io_tlb_default_size =simple_strtoul (str, &str,0 ); + io_tlb_default_size =ALIGN (io_tlb_default_size,IO_TLB_DEFAULT_SIZE ); + } + +/* avoid tail segment of size < io_tlb_segsize */ + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize);return 0 ; }@@ -120,15 +157,13 @@ unsigned long swiotlb_nr_tbl(void) }EXPORT_SYMBOL_GPL (swiotlb_nr_tbl); -/* default to 64MB */ -#define IO_TLB_DEFAULT_SIZE (64UL<<20)unsigned long swiotlb_size_or_default (void ) {unsigned long size; size = io_tlb_nslabs <<IO_TLB_SHIFT ; -return size ? size : (IO_TLB_DEFAULT_SIZE ); +return size ? size : (io_tlb_default_size); }/* Note that this doesn't work with highmem page */ @@ -183,7 +218,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)/* * Allocate and initialize the free list array. This array is used -* to find contiguous free memory regions of size up to IO_TLB_SEGSIZE +* to find contiguous free memory regions of size up to io_tlb_segsize * between io_tlb_start and io_tlb_end. */ io_tlb_list = memblock_virt_alloc(@@ -193,7 +228,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)PAGE_ALIGN (io_tlb_nslabs *sizeof (phys_addr_t)), PAGE_SIZE);for (i =0 ; i < io_tlb_nslabs; i++) { - io_tlb_list[i] =IO_TLB_SEGSIZE -OFFSET (i,IO_TLB_SEGSIZE ); + io_tlb_list[i] = io_tlb_segsize -OFFSET (i, io_tlb_segsize); io_tlb_orig_addr[i] =INVALID_PHYS_ADDR ; } io_tlb_index =0 ;@@ -211,13 +246,12 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)void __init swiotlb_init (int verbose) { -size_t default_size =IO_TLB_DEFAULT_SIZE ;unsigned char *vstart;unsigned long bytes;if (!io_tlb_nslabs) { - io_tlb_nslabs = (default_size >>IO_TLB_SHIFT ); - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); + io_tlb_nslabs = (io_tlb_default_size >>IO_TLB_SHIFT ); + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize); } bytes = io_tlb_nslabs <<IO_TLB_SHIFT ;@@ -249,7 +283,7 @@ swiotlb_late_init_with_default_size(size_t default_size)if (!io_tlb_nslabs) { io_tlb_nslabs = (default_size >>IO_TLB_SHIFT ); - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize); }/* @@ -308,7 +342,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)/* * Allocate and initialize the free list array. This array is used -* to find contiguous free memory regions of size up to IO_TLB_SEGSIZE +* to find contiguous free memory regions of size up to io_tlb_segsize * between io_tlb_start and io_tlb_end. */ io_tlb_list = (unsigned int *)__get_free_pages(GFP_KERNEL,@@ -324,7 +358,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs) goto cleanup4;for (i =0 ; i < io_tlb_nslabs; i++) { - io_tlb_list[i] =IO_TLB_SEGSIZE -OFFSET (i,IO_TLB_SEGSIZE ); + io_tlb_list[i] = io_tlb_segsize -OFFSET (i, io_tlb_segsize); io_tlb_orig_addr[i] =INVALID_PHYS_ADDR ; } io_tlb_index =0 ;@@ -493,7 +527,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,for (i = index; i < (int ) (index + nslots); i++) io_tlb_list[i] =0 ; -for (i = index -1 ; (OFFSET (i,IO_TLB_SEGSIZE ) !=IO_TLB_SEGSIZE -1 ) && io_tlb_list[i]; i--) +for (i = index -1 ; (OFFSET (i, io_tlb_segsize) != io_tlb_segsize -1 ) && io_tlb_list[i]; i--) io_tlb_list[i] = ++count; tlb_addr = io_tlb_start + (index <<IO_TLB_SHIFT );@@ -571,7 +605,7 @@ void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr,*/ spin_lock_irqsave (&io_tlb_lock, flags); { - count = ((index + nslots) <ALIGN (index +1 ,IO_TLB_SEGSIZE ) ? + count = ((index + nslots) <ALIGN (index +1 , io_tlb_segsize) ? io_tlb_list[index + nslots] :0 );/* * Step 1: return the slots to the free list, merging the @@ -585,7 +619,7 @@ void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr,* Step 2: merge the returned slots with the preceding slots, * if available (non zero) */ -for (i = index -1 ; (OFFSET (i,IO_TLB_SEGSIZE ) !=IO_TLB_SEGSIZE -1 ) && io_tlb_list[i]; i--) +for (i = index -1 ; (OFFSET (i, io_tlb_segsize) != io_tlb_segsize -1 ) && io_tlb_list[i]; i--) io_tlb_list[i] = ++count; }spin_unlock_irqrestore (&io_tlb_lock, flags);Signature · 1 line
1.7.9.5
Quoted 63 lines
-----Original Message-----
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Thursday, March 5, 2015 3:43 AM
To: Wang, Xiaoming
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Liu, Chuansheng; [email protected]; Zhang, Dongxing; [email protected]; [email protected]; [email protected]; [email protected]; xen- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v5] modify theIO_TLB_SEGSIZEandIO_TLB_DEFAULT_SIZEconfigurable as flexible requirement about SW- IOMMU.Quoted 5 lines · Wang Xiaoming
The maximum of SW-IOMMU is limited to 2^11*128 = 256K.
And the size ofIO_TLB_DEFAULT_SIZEis limited to (64UL<<20) 64M now. While in different platform and different requirement this seems improper. So modifing theIO_TLB_SEGSIZEtoio_tlb_segsizeandIO_TLB_DEFAULT_SIZEtoio_tlb_default_sizewhich can configure bykernel cmdline.
Quoted 10 lines
This can meet different requirement.
Signed-off-by Chuansheng Liu <[email protected]>Signed-off-by Zhang Dongxing <[email protected]>Signed-off-by Wang Xiaoming <[email protected]>---
patch v1 make this change atKconfig
which needs to edit the .config manually.
https://lkml.org/lkml/2015/1/25/571Quoted 8 lines
patch v2 only change
IO_TLB_SEGSIZEconfigurable.
https://lkml.org/lkml/2015/2/5/812patch v3 parsing
io_tlb_segsizeandio_tlb_default_sizeindependently.
https://lkml.org/lkml/2015/2/15/217patch v4 hasn't validated the data from command line.
Thank you for redoing this per review.
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can
Quoted 16 lines
https://lkml.org/lkml/2015/2/17/114
Documentation/kernel-parameters.txt | 9 ++++- 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 | 68 +++++++++++++++++++++++++--------- 6 files changed, 65 insertions(+), 30 deletions(-)Documentation/kernel-parameters.txt +0
-0@@ -3438,10 +3438,17 @@ bytes respectively. Such letter suffixes canalso be entirely omitted.
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can · line 3438
Quoted 1 line
Documentation/kernel-parameters.txt +0
-0it if 0 is given (See
Quoted 9 lines
Documentation/cgroups/memory.txt)Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3441
Quoted 4 lines
Documentation/kernel-parameters.txt +1
-1swiotlb= [ARM,IA-64,PPC,MIPS,X86] - Format: { <int> | force } + Format: { <int> | force | <int> | <int>},s/|/,/
How about change the Format to
Format: { <int>,force,<int>,<int>}Force the parameter input in consecutive order.
Quoted 154 lines
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted.
Quoted 4 lines
Documentation/kernel-parameters.txt +1
-0<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 contiguousslabs to map
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3447
Quoted 2 lines
Documentation/kernel-parameters.txt +2
-0+ <int> -- The size of SW-MMU mapped. + Using "," to separate them one by one."Use ',' to seperate them."
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can · line 3448
Quoted 2 lines
Documentation/kernel-parameters.txt +2
-0+ Example: + BOARD_KERNEL_CMDLINE +=swiotlb=32768,force,512,268435456
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3451
Quoted 2 lines
Documentation/kernel-parameters.txt +2
-0+ io_tlb_nslabs=32768, swiotlb_force=1, + io_tlb_segsize=512, io_tlb_default_size=268435456I think you can remove the example - and just have it in the C code.
drivers/xen/swiotlb-xen.c xen_swiotlb_fixup(void *buf, size_t size,
Quoted 36 lines
Documentation/kernel-parameters.txt +0
-0switches= [HW,M68k]arch/mips/cavium-octeon/dma-octeon.c +1
-1@@ -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@@ -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 +0
-0@@ -164,11 +164,11 @@ xen_swiotlb_fixup(void *buf, size_t size,unsigned long nslabs)
drivers/xen/swiotlb-xen.c xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
Quoted 4 lines
drivers/xen/swiotlb-xen.c +0
-1dma_addr_t dma_handle;phys_addr_t p =virt_to_phys (buf); - dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) +
PAGE_SHIFT;drivers/xen/swiotlb-xen.c xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
Quoted 9 lines
drivers/xen/swiotlb-xen.c +2
-1+ 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
drivers/xen/swiotlb-xen.c static unsigned long xen_set_nslabs(unsigned long nr_tbl)
Quoted 4 lines
unsigned long
xen_set_nslabs(unsigned long nr_tbl){drivers/xen/swiotlb-xen.c +0
-1if (!nr_tbl) { xen_io_tlb_nslabs = (64 *1024 *1024 >>IO_TLB_SHIFT ); - xen_io_tlb_nslabs = ALIGN(xen_io_tlb_nslabs,
IO_TLB_SEGSIZE);Quoted 9 lines
drivers/xen/swiotlb-xen.c +1
-0+ xen_io_tlb_nslabs =ALIGN (xen_io_tlb_nslabs, io_tlb_segsize); }else xen_io_tlb_nslabs = nr_tbl;include/linux/swiotlb.h index renamed from include/linux/swiotlb.h +0
-0e7a018e..13506db 100644
include/linux/swiotlb.h struct dma_attrs; · line 15
Quoted 8 lines
include/linux/swiotlb.h +0
-5@@ -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.
Quoted 11 lines
include/linux/swiotlb.h +1
-2-*/ -#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 diff --git
a/lib/swiotlb.cb/lib/swiotlb.cindex 4abda07..3b71afd 100644lib/swiotlb.c line 64
Quoted 9 lines
lib/swiotlb.c +6
-0@@ -56,6 +56,24 @@int swiotlb_force;/* +* default to 128 +* Maximum allowable number of contiguous slabs to map, +* must be a power of 2. What is the appropriate value ? +* define io_tlb_segsize as a parameter +* which can be changed dynamically in config file for special usage. +* The complexity of {map,unmap}_single is linearly dependent on this value.
lib/swiotlb.c line 66
Quoted 2 lines
lib/swiotlb.c +2
-0+*/ +#define IO_TLB_SEGSIZE 128Add the tab back please.
lib/swiotlb.c line 71
Quoted 5 lines
lib/swiotlb.c +5
-0+int io_tlb_segsize =IO_TLB_SEGSIZE ; + +/* default to 64MB +* define io_tlb_default_size as a parameter +* which can be changed dynamically in config file for special usage. .. or as a parameter during bootup.
lib/swiotlb.c
Quoted 7 lines
lib/swiotlb.c +5
-0+*/ +#define IO_TLB_DEFAULT_SIZE (64UL<<20) static unsigned long +io_tlb_default_size =IO_TLB_DEFAULT_SIZE ; + +/* * Used to do a quick range check in swiotlb_tbl_unmap_single and * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this
Quoted 4 lines
lib/swiotlb.c +0
-0* API. @@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 );lib/swiotlb.c setup_io_tlb_npages(char *str) { · line 127
Quoted 10 lines
lib/swiotlb.c +3
-3-/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); }if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }So the format is now:
Format: { <int> | force | <int> | <int>}
Quoted 9 lines
which means I can do
32,22323,forceOr
force,32Or
32,force
If I use Format: { <int>,force,<int>,<int>}
32,22323,force can't acceptable.
There are three <int> here, if there are out of order, that will cause confuse.
Only 32,force,32323
Or 32,,32323,2322
Or ,,323222,3232
Are available.
Quoted 20 lines
I think you need to make function be inside a loop to deal with 'force' being at odd locations.
Quoted 5 lines
lib/swiotlb.c +5
-0+if (*str ==',' ) + ++str; +if (isdigit (*str)) { +int n =0 ; + io_tlb_segsize =simple_strtoul (str, &str,0 );lib/swiotlb.c setup_io_tlb_npages(char *str)
Quoted 10 lines
lib/swiotlb.c +10
-0+ io_tlb_segsize =ALIGN (io_tlb_segsize,IO_TLB_SEGSIZE ); +while ((io_tlb_segsize -1 ) >> n) + n++; + io_tlb_segsize = (1 << n); + } +if (*str ==',' ) + ++str; +if (isdigit (*str)) { + io_tlb_default_size =simple_strtoul (str, &str,0 ); + io_tlb_default_size = ALIGN(io_tlb_default_size,
IO_TLB_DEFAULT_SIZE);
Quoted 5 lines
lib/swiotlb.c setup_io_tlb_npages(char *str) · line 148
Quoted 5 lines
lib/swiotlb.c +4
-0+ } + +/* avoid tail segment of size < io_tlb_segsize */ + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize);
Here has a leakage if io_tlb_nslabs hasn't set before it will be set to io_tlb_segsize. I will fix it in next version.
Quoted 125 lines
Quoted 20 lines
lib/swiotlb.c +1
-3return 0 ; }@@ -120,15 +157,13 @@ unsigned long swiotlb_nr_tbl(void) }EXPORT_SYMBOL_GPL (swiotlb_nr_tbl); -/* default to 64MB */ -#define IO_TLB_DEFAULT_SIZE (64UL<<20) unsigned longswiotlb_size_or_default (void) {unsigned long size; size = io_tlb_nslabs <<IO_TLB_SHIFT ; -return size ? size : (IO_TLB_DEFAULT_SIZE ); +return size ? size : (io_tlb_default_size); } /* Note that this doesn't work with highmem page */ @@ -183,7 +218,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs,int verbose)lib/swiotlb.c int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
Quoted 3 lines
lib/swiotlb.c +0
-1/* * Allocate and initialize the free list array. This array is used -* to find contiguous free memory regions of size up to
IO_TLB_SEGSIZElib/swiotlb.c int __init swiotlb_init_with_tbl(char *tlb, unsigned
Quoted 6 lines
lib/swiotlb.c +2
-0+* to find contiguous free memory regions of size up to +io_tlb_segsize * between io_tlb_start and io_tlb_end. */ io_tlb_list = memblock_virt_alloc(@@ -193,7 +228,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsignedlong nslabs, int verbose)
lib/swiotlb.c int __init swiotlb_init_with_tbl(char *tlb, unsigned · line 228
Quoted 1 line
lib/swiotlb.c +0
-0PAGE_ALIGN(io_tlb_nslabs *
sizeof(phys_addr_t)),Quoted 32 lines
lib/swiotlb.c +1
-1PAGE_SIZE);for (i =0 ; i < io_tlb_nslabs; i++) { - io_tlb_list[i] =IO_TLB_SEGSIZE -OFFSET (i,IO_TLB_SEGSIZE ); + io_tlb_list[i] = io_tlb_segsize -OFFSET (i, io_tlb_segsize); io_tlb_orig_addr[i] =INVALID_PHYS_ADDR ; } io_tlb_index =0 ;@@ -211,13 +246,12 @@ int __init swiotlb_init_with_tbl(char *tlb,unsigned long nslabs, int verbose) void
__initswiotlb_init(int verbose){lib/swiotlb.c +2
-3-size_t default_size =IO_TLB_DEFAULT_SIZE ;unsigned char *vstart;unsigned long bytes;if (!io_tlb_nslabs) { - io_tlb_nslabs = (default_size >>IO_TLB_SHIFT ); - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); + io_tlb_nslabs = (io_tlb_default_size >>IO_TLB_SHIFT ); + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize); } bytes = io_tlb_nslabs << IO_TLB_SHIFT; @@ -249,7 +283,7 @@
swiotlb_late_init_with_default_size(size_t default_size)lib/swiotlb.c +1
-1if (!io_tlb_nslabs) { io_tlb_nslabs = (default_size >>IO_TLB_SHIFT ); - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize); }/* lib/swiotlb.c swiotlb_late_init_with_tbl(char *tlb, unsigned · line 312
Quoted 5 lines
lib/swiotlb.c +0
-1@@ -308,7 +342,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)/* * Allocate and initialize the free list array. This array is used -* to find contiguous free memory regions of size up to
IO_TLB_SEGSIZElib/swiotlb.c swiotlb_late_init_with_tbl(char *tlb, unsigned
Quoted 5 lines
lib/swiotlb.c +2
-0+* to find contiguous free memory regions of size up to +io_tlb_segsize * between io_tlb_start and io_tlb_end. */ io_tlb_list = (unsigned int *)__get_free_pages(GFP_KERNEL, @@ -324,7
Quoted 10 lines
+358,7 @@
swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)lib/swiotlb.c +1
-1goto cleanup4;for (i =0 ; i < io_tlb_nslabs; i++) { - io_tlb_list[i] =IO_TLB_SEGSIZE -OFFSET (i,IO_TLB_SEGSIZE ); + io_tlb_list[i] = io_tlb_segsize -OFFSET (i, io_tlb_segsize); io_tlb_orig_addr[i] =INVALID_PHYS_ADDR ; } io_tlb_index =0 ;lib/swiotlb.c phys_addr_t swiotlb_tbl_map_single(struct device · line 497
Quoted 5 lines
lib/swiotlb.c +0
-1@@ -493,7 +527,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, for (i = index; i < (int) (index + nslots); i++) io_tlb_list[i] =0 ; - for (i = index - 1; (OFFSET(i, IO_TLB_SEGSIZE) !=
IO_TLB_SEGSIZE- 1) && io_tlb_list[i]; i--)lib/swiotlb.c phys_addr_t swiotlb_tbl_map_single(struct device · line 531
Quoted 1 line
lib/swiotlb.c +1
-0+ for (i = index - 1; (OFFSET(i, io_tlb_segsize) !=
io_tlb_segsize-lib/swiotlb.c void swiotlb_tbl_unmap_single(struct device
Quoted 5 lines
lib/swiotlb.c +1
-0+1) && io_tlb_list[i]; i--) io_tlb_list[i] = ++count; tlb_addr = io_tlb_start + (index <<IO_TLB_SHIFT );@@ -571,7 +605,7 @@ void swiotlb_tbl_unmap_single(struct device*hwdev,
phys_addr_ttlb_addr,lib/swiotlb.c void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr,
Quoted 8 lines
lib/swiotlb.c +1
-1*/ spin_lock_irqsave (&io_tlb_lock, flags); { - count = ((index + nslots) <ALIGN (index +1 ,IO_TLB_SEGSIZE ) ? + count = ((index + nslots) <ALIGN (index +1 , io_tlb_segsize) ? io_tlb_list[index + nslots] :0 );/* * Step 1: return the slots to the free list, merging the @@ - 585,7
Quoted 1 line
+619,7 @@ void swiotlb_tbl_unmap_single(struct device *hwdev,
phys_addr_ttlb_addr,lib/swiotlb.c void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr,
Quoted 4 lines
lib/swiotlb.c +0
-1* Step 2: merge the returned slots with the preceding slots, * if available (non zero) */ - for (i = index - 1; (OFFSET(i, IO_TLB_SEGSIZE) !=
IO_TLB_SEGSIZE-1) && io_tlb_list[i]; i--)Quoted 8 lines
lib/swiotlb.c +2
-1+for (i = index -1 ; (OFFSET (i, io_tlb_segsize) != io_tlb_segsize +-1 ) && io_tlb_list[i]; i--) io_tlb_list[i] = ++count; }spin_unlock_irqrestore (&io_tlb_lock, flags); --1.7.9.5
Quoted 31 lines
Quoted 22 lines
Quoted 1 line · On 05.03.15 at 04:53, <[email protected]> wrote:
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Thursday, March 5, 2015 3:43 AMlib/swiotlb.c setup_io_tlb_npages(char *str) { · line 127
Quoted 13 lines · Wang Xiaoming
lib/swiotlb.c +3
-3@@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 ); -/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); }if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }So the format is now:
Format: { <int> | force | <int> | <int>}Quoted 9 lines
which means I can do
32,22323,forceOr
force,32Or
32,force
Quoted 8 lines
If I use Format: { <int>,force,<int>,<int>}
32,22323,force can't acceptable.
There are three <int> here, if there are out of order, that will cause confuse.
Only 32,force,32323
Or 32,,32323,2322
Or ,,323222,3232
Are available.
You need to make sure that all previously valid variants are still usable, i.e. force alone, a number alone, force,<number> and <number>,force. How many variants you want to support with your additions is mostly up to you; I'd recommend permitting force in any position.
Jan
Dear Jan
Quoted 55 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, March 5, 2015 4:40 PM
To: Wang, Xiaoming
Cc: [email protected]; [email protected]; chris@chris- wilson.co.uk; [email protected]; [email protected]; [email protected]; [email protected]; Liu, Chuansheng; Zhang, Dongxing; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; Konrad Rzeszutek Wilk; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v5] modify theIO_TLB_SEGSIZEandIO_TLB_DEFAULT_SIZEconfigurable as flexible requirement about SW- IOMMU.Quoted 31 lines
Quoted 22 lines
Quoted 1 line · On 05.03.15 at 04:53, <[email protected]> wrote:
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Thursday, March 5, 2015 3:43 AM On Tue, Mar 03, 2015 atlib/swiotlb.c setup_io_tlb_npages(char *str) { · line 127
Quoted 13 lines · Wang Xiaoming
lib/swiotlb.c +3
-3@@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 ); -/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); }if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }So the format is now:
Format: { <int> | force | <int> | <int>}Quoted 9 lines
which means I can do
32,22323,forceOr
force,32Or
32,forceQuoted 8 lines
If I use Format: { <int>,force,<int>,<int>} 32,22323,force can't acceptable.
There are three <int> here, if there are out of order, that will cause confuse.
Only 32,force,32323
Or 32,,32323,2322
Or ,,323222,3232
Are available.
Quoted 5 lines
You need to make sure that all previously valid variants are still usable, i.e. force alone, a number alone, force,<number> and <number>,force. How many variants you want to support with your additions is mostly up to you; I'd recommend permitting force in any position.
I don't think it's suitable to accept that "force" in any position. If we defined Format: { <int>,force,<int>,<int>}
"force" must be located in second position.
And we add comment for each <int> also.
Every position may be defined specifically.
Quoted 1 line
Jan
Quoted 49 lines
Quoted 43 lines
Quoted 1 line · On 05.03.15 at 09:52, <[email protected]> wrote:
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, March 5, 2015 4:40 PMQuoted 31 lines
Quoted 22 lines
Quoted 1 line · On 05.03.15 at 04:53, <[email protected]> wrote:
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Thursday, March 5, 2015 3:43 AM On Tue, Mar 03, 2015 atlib/swiotlb.c setup_io_tlb_npages(char *str) { · line 127
Quoted 13 lines · Wang Xiaoming
lib/swiotlb.c +3
-3@@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 ); -/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); }if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }So the format is now:
Format: { <int> | force | <int> | <int>}Quoted 9 lines
which means I can do
32,22323,forceOr
force,32Or
32,forceQuoted 8 lines
If I use Format: { <int>,force,<int>,<int>} 32,22323,force can't acceptable.
There are three <int> here, if there are out of order, that will cause confuse.
Only 32,force,32323
Or 32,,32323,2322
Or ,,323222,3232
Are available.Quoted 1 line
You need to make sure that all previously valid variants are still usable,
i.e.
Quoted 4 lines
force alone, a number alone, force,<number> and <number>,force. How many variants you want to support with your additions is mostly up to you; I'd recommend permitting force in any position.
Quoted 5 lines
I don't think it's suitable to accept that "force" in any position. If we defined Format: { <int>,force,<int>,<int>}
"force" must be located in second position.
And we add comment for each <int> also.
Every position may be defined specifically.
As said, with the old format allowing force in either first or second position, you have to at least accept that in the new version too. Accepting force in any position would be a (desirable) courtesy to the user.
Jan
Dear Jan
Quoted 72 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, March 5, 2015 5:00 PM
To: Wang, Xiaoming
Cc: [email protected]; [email protected]; chris@chris- wilson.co.uk; [email protected]; [email protected]; [email protected]; [email protected]; Liu, Chuansheng; Zhang, Dongxing; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; Konrad RzeszutekWilk; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v5] modify theIO_TLB_SEGSIZEandIO_TLB_DEFAULT_SIZEconfigurable as flexible requirement about SW- IOMMU.Quoted 4 lines
Quoted 4 lines
Quoted 1 line · On 05.03.15 at 09:52, <[email protected]> wrote:
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, March 5, 2015 4:40 PMQuoted 1 line
Quoted 1 line
Quoted 1 line · On 05.03.15 at 04:53, <[email protected]> wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Thursday, March 5, 2015 3:43 AM On Tue, Mar 03, 2015 atlib/swiotlb.c setup_io_tlb_npages(char *str) { · line 104
Quoted 5 lines · Wang Xiaoming
lib/swiotlb.c +0
-2@@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 ); -/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs = ALIGN(io_tlb_nslabs,
IO_TLB_SEGSIZE);Quoted 38 lines
Quoted 31 lines
Quoted 22 lines
Quoted 13 lines
lib/swiotlb.c setup_io_tlb_npages(char *str) · line 128
Quoted 8 lines
lib/swiotlb.c +3
-1}if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }So the format is now:
Format: { <int> | force | <int> | <int>}Quoted 9 lines
which means I can do
32,22323,forceOr
force,32Or
32,forceQuoted 8 lines
If I use Format: { <int>,force,<int>,<int>} 32,22323,force can't acceptable.
There are three <int> here, if there are out of order, that will cause confuse.
Only 32,force,32323
Or 32,,32323,2322
Or ,,323222,3232
Are available.Quoted 2 lines
You need to make sure that all previously valid variants are still usable,
i.e.
Quoted 4 lines
force alone, a number alone, force,<number> and <number>,force. How many variants you want to support with your additions is mostly up to you; I'd recommend permitting force in any position.
Quoted 5 lines
I don't think it's suitable to accept that "force" in any position. If we defined Format: { <int>,force,<int>,<int>} "force" must be located in second position.
And we add comment for each <int> also.
Every position may be defined specifically.
Quoted 4 lines
As said, with the old format allowing force in either first or second position, you have to at least accept that in the new version too.
Accepting force in any position would be a (desirable) courtesy to the user.
I have checked the code and do some test.
First "|" in Format means *or* in Documentation/kernel-parameters.txt For example:
acpi= [HW,ACPI,X86]
Advanced Configuration and Power Interface
Format: { force | off | strict | noirq | rsdt }
acpi_sci= [HW,ACPI] ACPI System Control Interrupt trigger mode
Format: { level | edge | high | low }
Second the code in lib/swiotlb.c can't realize the function that "force" in either first or second position with the Format
swiotlb= [ARM,IA-64,PPC,MIPS,X86]
Format: { <int> | force }
<int> -- Number of I/O TLB slabsI test with parameterBOARD_KERNEL_CMDLINE += swiotlb=force,500
The result is io_tlb_nslabs=32768, swiotlb_force=0x0, io_tlb_nslabs=32768 because that if io_tlb_nslabs can't get from early_param("swiotlb", setup_io_tlb_npages);
It will be valued at swiotlb_init with default.
So both "<int>" and "force" can't recognized with original code below.
static int __initsetup_io_tlb_npages(char *str)
{
if (isdigit(*str)) {
io_tlb_nslabs = simple_strtoul(str, &str, 0);
/* avoid tail segment of size < IO_TLB_SEGSIZE */
io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
}
if (*str == ',')
++str;
if (!strcmp(str, "force"))
swiotlb_force = 1;
return 0;
}early_param("swiotlb", setup_io_tlb_npages);
So we can't use Format: { <int> | force | <int> | <int>} any more as there are four parameters.
Format: { <int>,force,<int>,<int>} is suitable I think.
And fixing "force" is follow the code design previously in setup_io_tlb_npages.
Quoted 1 line
Jan
Dear Jan
Quoted 72 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, March 5, 2015 5:00 PM
To: Wang, Xiaoming
Cc: [email protected]; [email protected]; chris@chris- wilson.co.uk; [email protected]; [email protected]; [email protected]; [email protected]; Liu, Chuansheng; Zhang, Dongxing; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; Konrad RzeszutekWilk; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v5] modify theIO_TLB_SEGSIZEandIO_TLB_DEFAULT_SIZEconfigurable as flexible requirement about SW- IOMMU.Quoted 4 lines
Quoted 4 lines
Quoted 1 line · On 05.03.15 at 09:52, <[email protected]> wrote:
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, March 5, 2015 4:40 PMQuoted 1 line
Quoted 1 line
Quoted 1 line · On 05.03.15 at 04:53, <[email protected]> wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Thursday, March 5, 2015 3:43 AM On Tue, Mar 03, 2015 atlib/swiotlb.c setup_io_tlb_npages(char *str) { · line 104
Quoted 5 lines · Wang Xiaoming
lib/swiotlb.c +0
-2@@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 ); -/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs = ALIGN(io_tlb_nslabs,
IO_TLB_SEGSIZE);Quoted 38 lines
Quoted 31 lines
Quoted 22 lines
Quoted 13 lines
lib/swiotlb.c setup_io_tlb_npages(char *str) · line 128
Quoted 8 lines
lib/swiotlb.c +3
-1}if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }So the format is now:
Format: { <int> | force | <int> | <int>}Quoted 9 lines
which means I can do
32,22323,forceOr
force,32Or
32,forceQuoted 8 lines
If I use Format: { <int>,force,<int>,<int>} 32,22323,force can't acceptable.
There are three <int> here, if there are out of order, that will cause confuse.
Only 32,force,32323
Or 32,,32323,2322
Or ,,323222,3232
Are available.Quoted 2 lines
You need to make sure that all previously valid variants are still usable,
i.e.
Quoted 4 lines
force alone, a number alone, force,<number> and <number>,force. How many variants you want to support with your additions is mostly up to you; I'd recommend permitting force in any position.
Quoted 5 lines
I don't think it's suitable to accept that "force" in any position. If we defined Format: { <int>,force,<int>,<int>} "force" must be located in second position.
And we add comment for each <int> also.
Every position may be defined specifically.
Quoted 4 lines
As said, with the old format allowing force in either first or second position, you have to at least accept that in the new version too.
Accepting force in any position would be a (desirable) courtesy to the user.
I have checked the code and do some test.
First "|" in Format means *or* in Documentation/kernel-parameters.txt For example:
acpi= [HW,ACPI,X86]
Advanced Configuration and Power Interface
Format: { force | off | strict | noirq | rsdt }
acpi_sci= [HW,ACPI] ACPI System Control Interrupt trigger mode
Format: { level | edge | high | low }
Second the code in lib/swiotlb.c can't realize the function that "force" in either first or second position with the Format
swiotlb= [ARM,IA-64,PPC,MIPS,X86]
Format: { <int> | force }
<int> -- Number of I/O TLB slabsI test with parameterBOARD_KERNEL_CMDLINE += swiotlb=force,500
The result is io_tlb_nslabs=32768, swiotlb_force=0x0, io_tlb_nslabs=32768 because that if io_tlb_nslabs can't get from early_param("swiotlb", setup_io_tlb_npages);
It will be valued at swiotlb_init with default.
So both "<int>" and "force" can't recognized with original code below.
static int __initsetup_io_tlb_npages(char *str)
{
if (isdigit(*str)) {
io_tlb_nslabs = simple_strtoul(str, &str, 0);
/* avoid tail segment of size < IO_TLB_SEGSIZE */
io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
}
if (*str == ',')
++str;
if (!strcmp(str, "force"))
swiotlb_force = 1;
return 0;
}early_param("swiotlb", setup_io_tlb_npages);
So we can't use Format: { <int> | force | <int> | <int>} any more as there are four parameters.
Format: { <int>,force,<int>,<int>} is suitable I think.
And fixing "force" is follow the code design previously in setup_io_tlb_npages.
Quoted 1 line
Jan
. snip..
Quoted 2 lines
Format: { <int>,force,<int>,<int>} is suitable I think.
And fixing "force" is follow the code design previously insetup_io_tlb_npages.
It is a bug. It should have been smart enough to deal with the 'force' being in any order.
If you are willing to make a patch to fix this - either folded into this patch I am responding to or as a seperate one - that would be most excellent!
However, I can also do it - but my plate is full so it will take me some time to get to it.
Quoted 21 lines
-----Original Message-----
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Friday, March 6, 2015 11:20 PM
To: Wang, Xiaoming
Cc: Jan Beulich; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Liu, Chuansheng; Zhang, Dongxing; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v5] modify theIO_TLB_SEGSIZEandIO_TLB_DEFAULT_SIZEconfigurable as flexible requirement about SW- IOMMU.. snip..
Quoted 2 lines
Format: { <int>,force,<int>,<int>} is suitable I think. And fixing "force" is follow the code design previously in
Quoted 8 lines
setup_io_tlb_npages.It is a bug. It should have been smart enough to deal with the 'force' being in any order.
If you are willing to make a patch to fix this - either folded into this patch I am responding to or as a seperate one - that would be most excellent!
OK, I will try to make a patch to deal with the 'force' in any order.
Quoted 2 lines
However, I can also do it - but my plate is full so it will take me some time to get to it.
Quoted 21 lines
-----Original Message-----
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Friday, March 6, 2015 11:20 PM
To: Wang, Xiaoming
Cc: Jan Beulich; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Liu, Chuansheng; Zhang, Dongxing; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v5] modify theIO_TLB_SEGSIZEandIO_TLB_DEFAULT_SIZEconfigurable as flexible requirement about SW- IOMMU.. snip..
Quoted 2 lines
Format: { <int>,force,<int>,<int>} is suitable I think. And fixing "force" is follow the code design previously in
Quoted 8 lines
setup_io_tlb_npages.It is a bug. It should have been smart enough to deal with the 'force' being in any order.
If you are willing to make a patch to fix this - either folded into this patch I am responding to or as a seperate one - that would be most excellent!
OK, I will try to make a patch to deal with the 'force' in any order.
Quoted 2 lines
However, I can also do it - but my plate is full so it will take me some time to get to it.
. snip..
Quoted 2 lines
Format: { <int>,force,<int>,<int>} is suitable I think.
And fixing "force" is follow the code design previously insetup_io_tlb_npages.
It is a bug. It should have been smart enough to deal with the 'force' being in any order.
If you are willing to make a patch to fix this - either folded into this patch I am responding to or as a seperate one - that would be most excellent!
However, I can also do it - but my plate is full so it will take me some time to get to it.
Quoted 49 lines
Quoted 43 lines
Quoted 1 line · On 05.03.15 at 09:52, <[email protected]> wrote:
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, March 5, 2015 4:40 PMQuoted 31 lines
Quoted 22 lines
Quoted 1 line · On 05.03.15 at 04:53, <[email protected]> wrote:
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Thursday, March 5, 2015 3:43 AM On Tue, Mar 03, 2015 atlib/swiotlb.c setup_io_tlb_npages(char *str) { · line 127
Quoted 13 lines · Wang Xiaoming
lib/swiotlb.c +3
-3@@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 ); -/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); }if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }So the format is now:
Format: { <int> | force | <int> | <int>}Quoted 9 lines
which means I can do
32,22323,forceOr
force,32Or
32,forceQuoted 8 lines
If I use Format: { <int>,force,<int>,<int>} 32,22323,force can't acceptable.
There are three <int> here, if there are out of order, that will cause confuse.
Only 32,force,32323
Or 32,,32323,2322
Or ,,323222,3232
Are available.Quoted 1 line
You need to make sure that all previously valid variants are still usable,
i.e.
Quoted 4 lines
force alone, a number alone, force,<number> and <number>,force. How many variants you want to support with your additions is mostly up to you; I'd recommend permitting force in any position.
Quoted 5 lines
I don't think it's suitable to accept that "force" in any position. If we defined Format: { <int>,force,<int>,<int>}
"force" must be located in second position.
And we add comment for each <int> also.
Every position may be defined specifically.
As said, with the old format allowing force in either first or second position, you have to at least accept that in the new version too. Accepting force in any position would be a (desirable) courtesy to the user.
Jan
Dear Jan
Quoted 55 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, March 5, 2015 4:40 PM
To: Wang, Xiaoming
Cc: [email protected]; [email protected]; chris@chris- wilson.co.uk; [email protected]; [email protected]; [email protected]; [email protected]; Liu, Chuansheng; Zhang, Dongxing; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; Konrad Rzeszutek Wilk; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v5] modify theIO_TLB_SEGSIZEandIO_TLB_DEFAULT_SIZEconfigurable as flexible requirement about SW- IOMMU.Quoted 31 lines
Quoted 22 lines
Quoted 1 line · On 05.03.15 at 04:53, <[email protected]> wrote:
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Thursday, March 5, 2015 3:43 AM On Tue, Mar 03, 2015 atlib/swiotlb.c setup_io_tlb_npages(char *str) { · line 127
Quoted 13 lines · Wang Xiaoming
lib/swiotlb.c +3
-3@@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 ); -/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); }if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }So the format is now:
Format: { <int> | force | <int> | <int>}Quoted 9 lines
which means I can do
32,22323,forceOr
force,32Or
32,forceQuoted 8 lines
If I use Format: { <int>,force,<int>,<int>} 32,22323,force can't acceptable.
There are three <int> here, if there are out of order, that will cause confuse.
Only 32,force,32323
Or 32,,32323,2322
Or ,,323222,3232
Are available.
Quoted 5 lines
You need to make sure that all previously valid variants are still usable, i.e. force alone, a number alone, force,<number> and <number>,force. How many variants you want to support with your additions is mostly up to you; I'd recommend permitting force in any position.
I don't think it's suitable to accept that "force" in any position. If we defined Format: { <int>,force,<int>,<int>}
"force" must be located in second position.
And we add comment for each <int> also.
Every position may be defined specifically.
Quoted 1 line
Jan
Quoted 31 lines
Quoted 22 lines
Quoted 1 line · On 05.03.15 at 04:53, <[email protected]> wrote:
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Thursday, March 5, 2015 3:43 AMlib/swiotlb.c setup_io_tlb_npages(char *str) { · line 127
Quoted 13 lines · Wang Xiaoming
lib/swiotlb.c +3
-3@@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 ); -/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); }if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }So the format is now:
Format: { <int> | force | <int> | <int>}Quoted 9 lines
which means I can do
32,22323,forceOr
force,32Or
32,force
Quoted 8 lines
If I use Format: { <int>,force,<int>,<int>}
32,22323,force can't acceptable.
There are three <int> here, if there are out of order, that will cause confuse.
Only 32,force,32323
Or 32,,32323,2322
Or ,,323222,3232
Are available.
You need to make sure that all previously valid variants are still usable, i.e. force alone, a number alone, force,<number> and <number>,force. How many variants you want to support with your additions is mostly up to you; I'd recommend permitting force in any position.
Jan
Quoted 63 lines
-----Original Message-----
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Thursday, March 5, 2015 3:43 AM
To: Wang, Xiaoming
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Liu, Chuansheng; [email protected]; Zhang, Dongxing; [email protected]; [email protected]; [email protected]; [email protected]; xen- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v5] modify theIO_TLB_SEGSIZEandIO_TLB_DEFAULT_SIZEconfigurable as flexible requirement about SW- IOMMU.Quoted 5 lines · Wang Xiaoming
The maximum of SW-IOMMU is limited to 2^11*128 = 256K.
And the size ofIO_TLB_DEFAULT_SIZEis limited to (64UL<<20) 64M now. While in different platform and different requirement this seems improper. So modifing theIO_TLB_SEGSIZEtoio_tlb_segsizeandIO_TLB_DEFAULT_SIZEtoio_tlb_default_sizewhich can configure bykernel cmdline.
Quoted 10 lines
This can meet different requirement.
Signed-off-by Chuansheng Liu <[email protected]>Signed-off-by Zhang Dongxing <[email protected]>Signed-off-by Wang Xiaoming <[email protected]>---
patch v1 make this change atKconfig
which needs to edit the .config manually.
https://lkml.org/lkml/2015/1/25/571Quoted 8 lines
patch v2 only change
IO_TLB_SEGSIZEconfigurable.
https://lkml.org/lkml/2015/2/5/812patch v3 parsing
io_tlb_segsizeandio_tlb_default_sizeindependently.
https://lkml.org/lkml/2015/2/15/217patch v4 hasn't validated the data from command line.
Thank you for redoing this per review.
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can
Quoted 16 lines
https://lkml.org/lkml/2015/2/17/114
Documentation/kernel-parameters.txt | 9 ++++- 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 | 68 +++++++++++++++++++++++++--------- 6 files changed, 65 insertions(+), 30 deletions(-)Documentation/kernel-parameters.txt +0
-0@@ -3438,10 +3438,17 @@ bytes respectively. Such letter suffixes canalso be entirely omitted.
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can · line 3438
Quoted 1 line
Documentation/kernel-parameters.txt +0
-0it if 0 is given (See
Quoted 9 lines
Documentation/cgroups/memory.txt)Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3441
Quoted 4 lines
Documentation/kernel-parameters.txt +1
-1swiotlb= [ARM,IA-64,PPC,MIPS,X86] - Format: { <int> | force } + Format: { <int> | force | <int> | <int>},s/|/,/
How about change the Format to
Format: { <int>,force,<int>,<int>}Force the parameter input in consecutive order.
Quoted 154 lines
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted.
Quoted 4 lines
Documentation/kernel-parameters.txt +1
-0<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 contiguousslabs to map
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3447
Quoted 2 lines
Documentation/kernel-parameters.txt +2
-0+ <int> -- The size of SW-MMU mapped. + Using "," to separate them one by one."Use ',' to seperate them."
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can · line 3448
Quoted 2 lines
Documentation/kernel-parameters.txt +2
-0+ Example: + BOARD_KERNEL_CMDLINE +=swiotlb=32768,force,512,268435456
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3451
Quoted 2 lines
Documentation/kernel-parameters.txt +2
-0+ io_tlb_nslabs=32768, swiotlb_force=1, + io_tlb_segsize=512, io_tlb_default_size=268435456I think you can remove the example - and just have it in the C code.
drivers/xen/swiotlb-xen.c xen_swiotlb_fixup(void *buf, size_t size,
Quoted 36 lines
Documentation/kernel-parameters.txt +0
-0switches= [HW,M68k]arch/mips/cavium-octeon/dma-octeon.c +1
-1@@ -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@@ -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 +0
-0@@ -164,11 +164,11 @@ xen_swiotlb_fixup(void *buf, size_t size,unsigned long nslabs)
drivers/xen/swiotlb-xen.c xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
Quoted 4 lines
drivers/xen/swiotlb-xen.c +0
-1dma_addr_t dma_handle;phys_addr_t p =virt_to_phys (buf); - dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) +
PAGE_SHIFT;drivers/xen/swiotlb-xen.c xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
Quoted 9 lines
drivers/xen/swiotlb-xen.c +2
-1+ 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
drivers/xen/swiotlb-xen.c static unsigned long xen_set_nslabs(unsigned long nr_tbl)
Quoted 4 lines
unsigned long
xen_set_nslabs(unsigned long nr_tbl){drivers/xen/swiotlb-xen.c +0
-1if (!nr_tbl) { xen_io_tlb_nslabs = (64 *1024 *1024 >>IO_TLB_SHIFT ); - xen_io_tlb_nslabs = ALIGN(xen_io_tlb_nslabs,
IO_TLB_SEGSIZE);Quoted 9 lines
drivers/xen/swiotlb-xen.c +1
-0+ xen_io_tlb_nslabs =ALIGN (xen_io_tlb_nslabs, io_tlb_segsize); }else xen_io_tlb_nslabs = nr_tbl;include/linux/swiotlb.h index renamed from include/linux/swiotlb.h +0
-0e7a018e..13506db 100644
include/linux/swiotlb.h struct dma_attrs; · line 15
Quoted 8 lines
include/linux/swiotlb.h +0
-5@@ -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.
Quoted 11 lines
include/linux/swiotlb.h +1
-2-*/ -#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 diff --git
a/lib/swiotlb.cb/lib/swiotlb.cindex 4abda07..3b71afd 100644lib/swiotlb.c line 64
Quoted 9 lines
lib/swiotlb.c +6
-0@@ -56,6 +56,24 @@int swiotlb_force;/* +* default to 128 +* Maximum allowable number of contiguous slabs to map, +* must be a power of 2. What is the appropriate value ? +* define io_tlb_segsize as a parameter +* which can be changed dynamically in config file for special usage. +* The complexity of {map,unmap}_single is linearly dependent on this value.
lib/swiotlb.c line 66
Quoted 2 lines
lib/swiotlb.c +2
-0+*/ +#define IO_TLB_SEGSIZE 128Add the tab back please.
lib/swiotlb.c line 71
Quoted 5 lines
lib/swiotlb.c +5
-0+int io_tlb_segsize =IO_TLB_SEGSIZE ; + +/* default to 64MB +* define io_tlb_default_size as a parameter +* which can be changed dynamically in config file for special usage. .. or as a parameter during bootup.
lib/swiotlb.c
Quoted 7 lines
lib/swiotlb.c +5
-0+*/ +#define IO_TLB_DEFAULT_SIZE (64UL<<20) static unsigned long +io_tlb_default_size =IO_TLB_DEFAULT_SIZE ; + +/* * Used to do a quick range check in swiotlb_tbl_unmap_single and * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this
Quoted 4 lines
lib/swiotlb.c +0
-0* API. @@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 );lib/swiotlb.c setup_io_tlb_npages(char *str) { · line 127
Quoted 10 lines
lib/swiotlb.c +3
-3-/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); }if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }So the format is now:
Format: { <int> | force | <int> | <int>}
Quoted 9 lines
which means I can do
32,22323,forceOr
force,32Or
32,force
If I use Format: { <int>,force,<int>,<int>}
32,22323,force can't acceptable.
There are three <int> here, if there are out of order, that will cause confuse.
Only 32,force,32323
Or 32,,32323,2322
Or ,,323222,3232
Are available.
Quoted 20 lines
I think you need to make function be inside a loop to deal with 'force' being at odd locations.
Quoted 5 lines
lib/swiotlb.c +5
-0+if (*str ==',' ) + ++str; +if (isdigit (*str)) { +int n =0 ; + io_tlb_segsize =simple_strtoul (str, &str,0 );lib/swiotlb.c setup_io_tlb_npages(char *str)
Quoted 10 lines
lib/swiotlb.c +10
-0+ io_tlb_segsize =ALIGN (io_tlb_segsize,IO_TLB_SEGSIZE ); +while ((io_tlb_segsize -1 ) >> n) + n++; + io_tlb_segsize = (1 << n); + } +if (*str ==',' ) + ++str; +if (isdigit (*str)) { + io_tlb_default_size =simple_strtoul (str, &str,0 ); + io_tlb_default_size = ALIGN(io_tlb_default_size,
IO_TLB_DEFAULT_SIZE);
Quoted 5 lines
lib/swiotlb.c setup_io_tlb_npages(char *str) · line 148
Quoted 5 lines
lib/swiotlb.c +4
-0+ } + +/* avoid tail segment of size < io_tlb_segsize */ + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize);
Here has a leakage if io_tlb_nslabs hasn't set before it will be set to io_tlb_segsize. I will fix it in next version.
Quoted 125 lines
Quoted 20 lines
lib/swiotlb.c +1
-3return 0 ; }@@ -120,15 +157,13 @@ unsigned long swiotlb_nr_tbl(void) }EXPORT_SYMBOL_GPL (swiotlb_nr_tbl); -/* default to 64MB */ -#define IO_TLB_DEFAULT_SIZE (64UL<<20) unsigned longswiotlb_size_or_default (void) {unsigned long size; size = io_tlb_nslabs <<IO_TLB_SHIFT ; -return size ? size : (IO_TLB_DEFAULT_SIZE ); +return size ? size : (io_tlb_default_size); } /* Note that this doesn't work with highmem page */ @@ -183,7 +218,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs,int verbose)lib/swiotlb.c int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
Quoted 3 lines
lib/swiotlb.c +0
-1/* * Allocate and initialize the free list array. This array is used -* to find contiguous free memory regions of size up to
IO_TLB_SEGSIZElib/swiotlb.c int __init swiotlb_init_with_tbl(char *tlb, unsigned
Quoted 6 lines
lib/swiotlb.c +2
-0+* to find contiguous free memory regions of size up to +io_tlb_segsize * between io_tlb_start and io_tlb_end. */ io_tlb_list = memblock_virt_alloc(@@ -193,7 +228,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsignedlong nslabs, int verbose)
lib/swiotlb.c int __init swiotlb_init_with_tbl(char *tlb, unsigned · line 228
Quoted 1 line
lib/swiotlb.c +0
-0PAGE_ALIGN(io_tlb_nslabs *
sizeof(phys_addr_t)),Quoted 32 lines
lib/swiotlb.c +1
-1PAGE_SIZE);for (i =0 ; i < io_tlb_nslabs; i++) { - io_tlb_list[i] =IO_TLB_SEGSIZE -OFFSET (i,IO_TLB_SEGSIZE ); + io_tlb_list[i] = io_tlb_segsize -OFFSET (i, io_tlb_segsize); io_tlb_orig_addr[i] =INVALID_PHYS_ADDR ; } io_tlb_index =0 ;@@ -211,13 +246,12 @@ int __init swiotlb_init_with_tbl(char *tlb,unsigned long nslabs, int verbose) void
__initswiotlb_init(int verbose){lib/swiotlb.c +2
-3-size_t default_size =IO_TLB_DEFAULT_SIZE ;unsigned char *vstart;unsigned long bytes;if (!io_tlb_nslabs) { - io_tlb_nslabs = (default_size >>IO_TLB_SHIFT ); - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); + io_tlb_nslabs = (io_tlb_default_size >>IO_TLB_SHIFT ); + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize); } bytes = io_tlb_nslabs << IO_TLB_SHIFT; @@ -249,7 +283,7 @@
swiotlb_late_init_with_default_size(size_t default_size)lib/swiotlb.c +1
-1if (!io_tlb_nslabs) { io_tlb_nslabs = (default_size >>IO_TLB_SHIFT ); - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize); }/* lib/swiotlb.c swiotlb_late_init_with_tbl(char *tlb, unsigned · line 312
Quoted 5 lines
lib/swiotlb.c +0
-1@@ -308,7 +342,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)/* * Allocate and initialize the free list array. This array is used -* to find contiguous free memory regions of size up to
IO_TLB_SEGSIZElib/swiotlb.c swiotlb_late_init_with_tbl(char *tlb, unsigned
Quoted 5 lines
lib/swiotlb.c +2
-0+* to find contiguous free memory regions of size up to +io_tlb_segsize * between io_tlb_start and io_tlb_end. */ io_tlb_list = (unsigned int *)__get_free_pages(GFP_KERNEL, @@ -324,7
Quoted 10 lines
+358,7 @@
swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)lib/swiotlb.c +1
-1goto cleanup4;for (i =0 ; i < io_tlb_nslabs; i++) { - io_tlb_list[i] =IO_TLB_SEGSIZE -OFFSET (i,IO_TLB_SEGSIZE ); + io_tlb_list[i] = io_tlb_segsize -OFFSET (i, io_tlb_segsize); io_tlb_orig_addr[i] =INVALID_PHYS_ADDR ; } io_tlb_index =0 ;lib/swiotlb.c phys_addr_t swiotlb_tbl_map_single(struct device · line 497
Quoted 5 lines
lib/swiotlb.c +0
-1@@ -493,7 +527,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, for (i = index; i < (int) (index + nslots); i++) io_tlb_list[i] =0 ; - for (i = index - 1; (OFFSET(i, IO_TLB_SEGSIZE) !=
IO_TLB_SEGSIZE- 1) && io_tlb_list[i]; i--)lib/swiotlb.c phys_addr_t swiotlb_tbl_map_single(struct device · line 531
Quoted 1 line
lib/swiotlb.c +1
-0+ for (i = index - 1; (OFFSET(i, io_tlb_segsize) !=
io_tlb_segsize-lib/swiotlb.c void swiotlb_tbl_unmap_single(struct device
Quoted 5 lines
lib/swiotlb.c +1
-0+1) && io_tlb_list[i]; i--) io_tlb_list[i] = ++count; tlb_addr = io_tlb_start + (index <<IO_TLB_SHIFT );@@ -571,7 +605,7 @@ void swiotlb_tbl_unmap_single(struct device*hwdev,
phys_addr_ttlb_addr,lib/swiotlb.c void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr,
Quoted 8 lines
lib/swiotlb.c +1
-1*/ spin_lock_irqsave (&io_tlb_lock, flags); { - count = ((index + nslots) <ALIGN (index +1 ,IO_TLB_SEGSIZE ) ? + count = ((index + nslots) <ALIGN (index +1 , io_tlb_segsize) ? io_tlb_list[index + nslots] :0 );/* * Step 1: return the slots to the free list, merging the @@ - 585,7
Quoted 1 line
+619,7 @@ void swiotlb_tbl_unmap_single(struct device *hwdev,
phys_addr_ttlb_addr,lib/swiotlb.c void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr,
Quoted 4 lines
lib/swiotlb.c +0
-1* Step 2: merge the returned slots with the preceding slots, * if available (non zero) */ - for (i = index - 1; (OFFSET(i, IO_TLB_SEGSIZE) !=
IO_TLB_SEGSIZE-1) && io_tlb_list[i]; i--)Quoted 8 lines
lib/swiotlb.c +2
-1+for (i = index -1 ; (OFFSET (i, io_tlb_segsize) != io_tlb_segsize +-1 ) && io_tlb_list[i]; i--) io_tlb_list[i] = ++count; }spin_unlock_irqrestore (&io_tlb_lock, flags); --1.7.9.5
Quoted 18 lines · Wang Xiaoming
The maximum of SW-IOMMU is limited to 2^11*128 = 256K.
And the size ofIO_TLB_DEFAULT_SIZEis limited to (64UL<<20) 64M now. While in different platform and different requirement this seems improper. So modifing theIO_TLB_SEGSIZEtoio_tlb_segsizeandIO_TLB_DEFAULT_SIZEtoio_tlb_default_sizewhich can configure by kernel cmdline. This can meet different requirement.Signed-off-by Chuansheng Liu <[email protected]>Signed-off-by Zhang Dongxing <[email protected]>Signed-off-by Wang Xiaoming <[email protected]>---
patch v1 make this change atKconfig
which needs to edit the .config manually.
https://lkml.org/lkml/2015/1/25/571patch v2 only change
IO_TLB_SEGSIZEconfigurable.
https://lkml.org/lkml/2015/2/5/812
Quoted 6 lines
patch v3 parsing
io_tlb_segsizeandio_tlb_default_sizeindependently.
https://lkml.org/lkml/2015/2/15/217patch v4 hasn't validated the data from
command line.
Thank you for redoing this per review.
Quoted 15 lines
https://lkml.org/lkml/2015/2/17/114
Documentation/kernel-parameters.txt | 9 ++++- 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 | 68 +++++++++++++++++++++++++--------- 6 files changed, 65 insertions(+), 30 deletions(-)Documentation/kernel-parameters.txt +0
-0
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3441
Quoted 5 lines
Documentation/kernel-parameters.txt +1
-1@@ -3438,10 +3438,17 @@ 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>}
,
s/|/,/
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3447
Quoted 6 lines
Documentation/kernel-parameters.txt +3
-0<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. + Using "," to separate them one by one.
"Use ',' to seperate them."
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3451
Quoted 4 lines
Documentation/kernel-parameters.txt +4
-0+ Example: + BOARD_KERNEL_CMDLINE += swiotlb=32768,force,512,268435456 + io_tlb_nslabs=32768, swiotlb_force=1, + io_tlb_segsize=512, io_tlb_default_size=268435456
I think you can remove the example - and just have it in the C code.
Quoted 81 lines
Documentation/kernel-parameters.txt +0
-0switches= [HW,M68k]arch/mips/cavium-octeon/dma-octeon.c +1
-1@@ -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@@ -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@@ -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@@ -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 +0
-0@@ -56,6 +56,24 @@int swiotlb_force;
lib/swiotlb.c line 66
Quoted 10 lines
lib/swiotlb.c +8
-0/* +* default to 128 +* Maximum allowable number of contiguous slabs to map, +* must be a power of 2. What is the appropriate value ? +* define io_tlb_segsize as a parameter +* which can be changed dynamically in config file for special usage. +* The complexity of {map,unmap}_single is linearly dependent on this value. +*/ +#define IO_TLB_SEGSIZE 128
Add the tab back please.
lib/swiotlb.c line 71
Quoted 5 lines
lib/swiotlb.c +5
-0+int io_tlb_segsize =IO_TLB_SEGSIZE ; + +/* default to 64MB +* define io_tlb_default_size as a parameter +* which can be changed dynamically in config file for special usage.
.. or as a parameter during bootup.
Quoted 12 lines
lib/swiotlb.c +5
-0+*/ +#define IO_TLB_DEFAULT_SIZE (64UL<<20) +static unsigned long io_tlb_default_size =IO_TLB_DEFAULT_SIZE ; + +/* * Used to do a quick range check in swiotlb_tbl_unmap_single and * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this * API. @@ -101,13 +119,32 @@ setup_io_tlb_npages(char *str) {if (isdigit (*str)) { io_tlb_nslabs =simple_strtoul (str, &str,0 );
lib/swiotlb.c setup_io_tlb_npages(char *str) · line 128
Quoted 10 lines
lib/swiotlb.c +3
-3-/* avoid tail segment of size < IO_TLB_SEGSIZE */ - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); }if (*str ==',' ) ++str; -if (!strcmp (str,"force" )) +if (!strncmp (str,"force" ,5 )) { swiotlb_force =1 ; + str +=5 ; + }
So the format is now:
Format: { <int> | force | <int> | <int>}which means I can do
32,22323,force
Or
force,32
Or
32,force
I think you need to make function be inside a loop to deal with 'force' being at odd locations.
Quoted 130 lines
lib/swiotlb.c +30
-14+if (*str ==',' ) + ++str; +if (isdigit (*str)) { +int n =0 ; + io_tlb_segsize =simple_strtoul (str, &str,0 ); + io_tlb_segsize =ALIGN (io_tlb_segsize,IO_TLB_SEGSIZE ); +while ((io_tlb_segsize -1 ) >> n) + n++; + io_tlb_segsize = (1 << n); + } +if (*str ==',' ) + ++str; +if (isdigit (*str)) { + io_tlb_default_size =simple_strtoul (str, &str,0 ); + io_tlb_default_size =ALIGN (io_tlb_default_size,IO_TLB_DEFAULT_SIZE ); + } + +/* avoid tail segment of size < io_tlb_segsize */ + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize);return 0 ; }@@ -120,15 +157,13 @@ unsigned long swiotlb_nr_tbl(void) }EXPORT_SYMBOL_GPL (swiotlb_nr_tbl); -/* default to 64MB */ -#define IO_TLB_DEFAULT_SIZE (64UL<<20)unsigned long swiotlb_size_or_default (void ) {unsigned long size; size = io_tlb_nslabs <<IO_TLB_SHIFT ; -return size ? size : (IO_TLB_DEFAULT_SIZE ); +return size ? size : (io_tlb_default_size); }/* Note that this doesn't work with highmem page */ @@ -183,7 +218,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)/* * Allocate and initialize the free list array. This array is used -* to find contiguous free memory regions of size up to IO_TLB_SEGSIZE +* to find contiguous free memory regions of size up to io_tlb_segsize * between io_tlb_start and io_tlb_end. */ io_tlb_list = memblock_virt_alloc(@@ -193,7 +228,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)PAGE_ALIGN (io_tlb_nslabs *sizeof (phys_addr_t)), PAGE_SIZE);for (i =0 ; i < io_tlb_nslabs; i++) { - io_tlb_list[i] =IO_TLB_SEGSIZE -OFFSET (i,IO_TLB_SEGSIZE ); + io_tlb_list[i] = io_tlb_segsize -OFFSET (i, io_tlb_segsize); io_tlb_orig_addr[i] =INVALID_PHYS_ADDR ; } io_tlb_index =0 ;@@ -211,13 +246,12 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)void __init swiotlb_init (int verbose) { -size_t default_size =IO_TLB_DEFAULT_SIZE ;unsigned char *vstart;unsigned long bytes;if (!io_tlb_nslabs) { - io_tlb_nslabs = (default_size >>IO_TLB_SHIFT ); - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); + io_tlb_nslabs = (io_tlb_default_size >>IO_TLB_SHIFT ); + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize); } bytes = io_tlb_nslabs <<IO_TLB_SHIFT ;@@ -249,7 +283,7 @@ swiotlb_late_init_with_default_size(size_t default_size)if (!io_tlb_nslabs) { io_tlb_nslabs = (default_size >>IO_TLB_SHIFT ); - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); + io_tlb_nslabs =ALIGN (io_tlb_nslabs, io_tlb_segsize); }/* @@ -308,7 +342,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)/* * Allocate and initialize the free list array. This array is used -* to find contiguous free memory regions of size up to IO_TLB_SEGSIZE +* to find contiguous free memory regions of size up to io_tlb_segsize * between io_tlb_start and io_tlb_end. */ io_tlb_list = (unsigned int *)__get_free_pages(GFP_KERNEL,@@ -324,7 +358,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs) goto cleanup4;for (i =0 ; i < io_tlb_nslabs; i++) { - io_tlb_list[i] =IO_TLB_SEGSIZE -OFFSET (i,IO_TLB_SEGSIZE ); + io_tlb_list[i] = io_tlb_segsize -OFFSET (i, io_tlb_segsize); io_tlb_orig_addr[i] =INVALID_PHYS_ADDR ; } io_tlb_index =0 ;@@ -493,7 +527,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,for (i = index; i < (int ) (index + nslots); i++) io_tlb_list[i] =0 ; -for (i = index -1 ; (OFFSET (i,IO_TLB_SEGSIZE ) !=IO_TLB_SEGSIZE -1 ) && io_tlb_list[i]; i--) +for (i = index -1 ; (OFFSET (i, io_tlb_segsize) != io_tlb_segsize -1 ) && io_tlb_list[i]; i--) io_tlb_list[i] = ++count; tlb_addr = io_tlb_start + (index <<IO_TLB_SHIFT );@@ -571,7 +605,7 @@ void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr,*/ spin_lock_irqsave (&io_tlb_lock, flags); { - count = ((index + nslots) <ALIGN (index +1 ,IO_TLB_SEGSIZE ) ? + count = ((index + nslots) <ALIGN (index +1 , io_tlb_segsize) ? io_tlb_list[index + nslots] :0 );/* * Step 1: return the slots to the free list, merging the @@ -585,7 +619,7 @@ void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr,* Step 2: merge the returned slots with the preceding slots, * if available (non zero) */ -for (i = index -1 ; (OFFSET (i,IO_TLB_SEGSIZE ) !=IO_TLB_SEGSIZE -1 ) && io_tlb_list[i]; i--) +for (i = index -1 ; (OFFSET (i, io_tlb_segsize) != io_tlb_segsize -1 ) && io_tlb_list[i]; i--) io_tlb_list[i] = ++count; }spin_unlock_irqrestore (&io_tlb_lock, flags);Signature · 1 line
1.7.9.5