swiotlb: simplify swiotlb_max_segment
authorChristoph Hellwig <hch@lst.de>
Mon, 14 Feb 2022 10:44:42 +0000 (11:44 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 18 Apr 2022 05:21:09 +0000 (07:21 +0200)
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>
drivers/xen/swiotlb-xen.c
include/linux/swiotlb.h
kernel/dma/swiotlb.c

index 47aebd98f52f551718d9f66656ee57861604343a..485cd06ed39e7b5b798b2053aae6fcab44a3a81f 100644 (file)
@@ -202,7 +202,6 @@ retry:
        rc = swiotlb_late_init_with_tbl(start, nslabs);
        if (rc)
                return rc;
-       swiotlb_set_max_segment(PAGE_SIZE);
        return 0;
 error:
        if (nslabs > 1024 && repeat--) {
@@ -254,7 +253,6 @@ retry:
 
        if (swiotlb_init_with_tbl(start, nslabs, true))
                panic("Cannot allocate SWIOTLB buffer");
-       swiotlb_set_max_segment(PAGE_SIZE);
 }
 #endif /* CONFIG_X86 */
 
index f6c3638255d542a13abaef27cc2978d9349260d1..9fb3a568f0c5124d6ca3d61f5ec874ef55f11518 100644 (file)
@@ -164,7 +164,6 @@ static inline void swiotlb_adjust_size(unsigned long size)
 #endif /* CONFIG_SWIOTLB */
 
 extern void swiotlb_print_info(void);
-extern void swiotlb_set_max_segment(unsigned int);
 
 #ifdef CONFIG_DMA_RESTRICTED_POOL
 struct page *swiotlb_alloc(struct device *dev, size_t size);
index 98bb0eb44a7bf0dc031c0cc5cb669bf1e4a2e8d1..e0127e397335e60a4d68221e2f26150c867b6536 100644 (file)
@@ -68,12 +68,6 @@ struct io_tlb_mem io_tlb_default_mem;
 
 phys_addr_t swiotlb_unencrypted_base;
 
-/*
- * Max segment that we can provide which (if pages are contingous) will
- * not be bounced (unless SWIOTLB_FORCE is set).
- */
-static unsigned int max_segment;
-
 static unsigned long default_nslabs = IO_TLB_DEFAULT_SIZE >> IO_TLB_SHIFT;
 
 static int __init
@@ -97,18 +91,12 @@ early_param("swiotlb", setup_io_tlb_npages);
 
 unsigned int swiotlb_max_segment(void)
 {
-       return io_tlb_default_mem.nslabs ? max_segment : 0;
+       if (!io_tlb_default_mem.nslabs)
+               return 0;
+       return rounddown(io_tlb_default_mem.nslabs << IO_TLB_SHIFT, PAGE_SIZE);
 }
 EXPORT_SYMBOL_GPL(swiotlb_max_segment);
 
-void swiotlb_set_max_segment(unsigned int val)
-{
-       if (swiotlb_force == SWIOTLB_FORCE)
-               max_segment = 1;
-       else
-               max_segment = rounddown(val, PAGE_SIZE);
-}
-
 unsigned long swiotlb_size_or_default(void)
 {
        return default_nslabs << IO_TLB_SHIFT;
@@ -258,7 +246,6 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
 
        if (verbose)
                swiotlb_print_info();
-       swiotlb_set_max_segment(mem->nslabs << IO_TLB_SHIFT);
        return 0;
 }
 
@@ -359,7 +346,6 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
        swiotlb_init_io_tlb_mem(mem, virt_to_phys(tlb), nslabs, true);
 
        swiotlb_print_info();
-       swiotlb_set_max_segment(mem->nslabs << IO_TLB_SHIFT);
        return 0;
 }