Skip to content

Commit a2daa27

Browse files
author
Christoph Hellwig
committed
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 <[email protected]> Reviewed-by: Anshuman Khandual <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Tested-by: Boris Ostrovsky <[email protected]>
1 parent 3469d36 commit a2daa27

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

drivers/xen/swiotlb-xen.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ int xen_swiotlb_init(void)
202202
rc = swiotlb_late_init_with_tbl(start, nslabs);
203203
if (rc)
204204
return rc;
205-
swiotlb_set_max_segment(PAGE_SIZE);
206205
return 0;
207206
error:
208207
if (nslabs > 1024 && repeat--) {
@@ -254,7 +253,6 @@ void __init xen_swiotlb_init_early(void)
254253

255254
if (swiotlb_init_with_tbl(start, nslabs, true))
256255
panic("Cannot allocate SWIOTLB buffer");
257-
swiotlb_set_max_segment(PAGE_SIZE);
258256
}
259257
#endif /* CONFIG_X86 */
260258

include/linux/swiotlb.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ static inline void swiotlb_adjust_size(unsigned long size)
164164
#endif /* CONFIG_SWIOTLB */
165165

166166
extern void swiotlb_print_info(void);
167-
extern void swiotlb_set_max_segment(unsigned int);
168167

169168
#ifdef CONFIG_DMA_RESTRICTED_POOL
170169
struct page *swiotlb_alloc(struct device *dev, size_t size);

kernel/dma/swiotlb.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,6 @@ struct io_tlb_mem io_tlb_default_mem;
6868

6969
phys_addr_t swiotlb_unencrypted_base;
7070

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-
7771
static unsigned long default_nslabs = IO_TLB_DEFAULT_SIZE >> IO_TLB_SHIFT;
7872

7973
static int __init
@@ -97,18 +91,12 @@ early_param("swiotlb", setup_io_tlb_npages);
9791

9892
unsigned int swiotlb_max_segment(void)
9993
{
100-
return io_tlb_default_mem.nslabs ? max_segment : 0;
94+
if (!io_tlb_default_mem.nslabs)
95+
return 0;
96+
return rounddown(io_tlb_default_mem.nslabs << IO_TLB_SHIFT, PAGE_SIZE);
10197
}
10298
EXPORT_SYMBOL_GPL(swiotlb_max_segment);
10399

104-
void swiotlb_set_max_segment(unsigned int val)
105-
{
106-
if (swiotlb_force == SWIOTLB_FORCE)
107-
max_segment = 1;
108-
else
109-
max_segment = rounddown(val, PAGE_SIZE);
110-
}
111-
112100
unsigned long swiotlb_size_or_default(void)
113101
{
114102
return default_nslabs << IO_TLB_SHIFT;
@@ -258,7 +246,6 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
258246

259247
if (verbose)
260248
swiotlb_print_info();
261-
swiotlb_set_max_segment(mem->nslabs << IO_TLB_SHIFT);
262249
return 0;
263250
}
264251

@@ -359,7 +346,6 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
359346
swiotlb_init_io_tlb_mem(mem, virt_to_phys(tlb), nslabs, true);
360347

361348
swiotlb_print_info();
362-
swiotlb_set_max_segment(mem->nslabs << IO_TLB_SHIFT);
363349
return 0;
364350
}
365351

0 commit comments

Comments
 (0)