Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

swiotlb: simplify swiotlb_max_segment

Remove the bogus Xen override that was usually larger than the actual
size and just calculate the value on demand. Note that
swiotlb_max_segment still doesn't make sense as an interface and should
eventually be removed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

+3 -20
-2
drivers/xen/swiotlb-xen.c
··· 202 202 rc = swiotlb_late_init_with_tbl(start, nslabs); 203 203 if (rc) 204 204 return rc; 205 - swiotlb_set_max_segment(PAGE_SIZE); 206 205 return 0; 207 206 error: 208 207 if (nslabs > 1024 && repeat--) { ··· 253 254 254 255 if (swiotlb_init_with_tbl(start, nslabs, true)) 255 256 panic("Cannot allocate SWIOTLB buffer"); 256 - swiotlb_set_max_segment(PAGE_SIZE); 257 257 } 258 258 #endif /* CONFIG_X86 */ 259 259
-1
include/linux/swiotlb.h
··· 164 164 #endif /* CONFIG_SWIOTLB */ 165 165 166 166 extern void swiotlb_print_info(void); 167 - extern void swiotlb_set_max_segment(unsigned int); 168 167 169 168 #ifdef CONFIG_DMA_RESTRICTED_POOL 170 169 struct page *swiotlb_alloc(struct device *dev, size_t size);
+3 -17
kernel/dma/swiotlb.c
··· 68 68 69 69 phys_addr_t swiotlb_unencrypted_base; 70 70 71 - /* 72 - * Max segment that we can provide which (if pages are contingous) will 73 - * not be bounced (unless SWIOTLB_FORCE is set). 74 - */ 75 - static unsigned int max_segment; 76 - 77 71 static unsigned long default_nslabs = IO_TLB_DEFAULT_SIZE >> IO_TLB_SHIFT; 78 72 79 73 static int __init ··· 91 97 92 98 unsigned int swiotlb_max_segment(void) 93 99 { 94 - return io_tlb_default_mem.nslabs ? max_segment : 0; 100 + if (!io_tlb_default_mem.nslabs) 101 + return 0; 102 + return rounddown(io_tlb_default_mem.nslabs << IO_TLB_SHIFT, PAGE_SIZE); 95 103 } 96 104 EXPORT_SYMBOL_GPL(swiotlb_max_segment); 97 - 98 - void swiotlb_set_max_segment(unsigned int val) 99 - { 100 - if (swiotlb_force == SWIOTLB_FORCE) 101 - max_segment = 1; 102 - else 103 - max_segment = rounddown(val, PAGE_SIZE); 104 - } 105 105 106 106 unsigned long swiotlb_size_or_default(void) 107 107 { ··· 246 258 247 259 if (verbose) 248 260 swiotlb_print_info(); 249 - swiotlb_set_max_segment(mem->nslabs << IO_TLB_SHIFT); 250 261 return 0; 251 262 } 252 263 ··· 346 359 swiotlb_init_io_tlb_mem(mem, virt_to_phys(tlb), nslabs, true); 347 360 348 361 swiotlb_print_info(); 349 - swiotlb_set_max_segment(mem->nslabs << IO_TLB_SHIFT); 350 362 return 0; 351 363 } 352 364