cleanup swiotlb initialization v5
Subsystems (23)
Hi all,
this series tries to clean up the swiotlb initialization, including that of swiotlb-xen. To get there is also removes the x86 iommu table infrastructure that massively obsfucates the initialization path.
Git tree:
git://git.infradead.org/users/hch/misc.git swiotlb-init-cleanup
Gitweb:
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/swiotlb-init-cleanup
Changes since v5:
- split a patch into three
- fix setting x86_swiotlb_enable for Xen
- fix a comment about forced bounce buffering for guest memory encryption
- remove the xen_initial_domain check from xen_create_contiguous_region
Changes since v3:
- fix a compilation issue on some powerpc configfs
- fix and cleanup how forced bounce buffering is enabled for guest memory encryption
Changes since v2:
- make ppc_swiotlb_flags actually work again
- also force enable swiotlb for guest encrypted memory to cater to hyperv which doesn't set the host encrypted memory flag
Changes since v1:
- skip IOMMU initialization on Xen PV kernels
- various small whitespace / typo fixes
Diffstat:
arch/ia64/include/asm/iommu_table.h | 7 - arch/x86/include/asm/iommu_table.h | 102 ------------------ arch/x86/include/asm/swiotlb.h | 30 ----- arch/x86/kernel/pci-iommu_table.c | 77 ------------- arch/x86/kernel/pci-swiotlb.c | 77 ------------- arch/x86/xen/pci-swiotlb-xen.c | 96 ----------------- b/arch/arm/mm/init.c | 6 - b/arch/arm/xen/mm.c | 26 ++-- b/arch/arm64/mm/init.c | 6 - b/arch/ia64/mm/init.c | 4 b/arch/mips/cavium-octeon/dma-octeon.c | 15 -- b/arch/mips/loongson64/dma.c | 2 b/arch/mips/pci/pci-octeon.c | 2 b/arch/mips/sibyte/common/dma.c | 2 b/arch/powerpc/include/asm/svm.h | 4 b/arch/powerpc/include/asm/swiotlb.h | 1 b/arch/powerpc/kernel/dma-swiotlb.c | 1 b/arch/powerpc/mm/mem.c | 6 - b/arch/powerpc/platforms/pseries/setup.c | 3 b/arch/powerpc/platforms/pseries/svm.c | 26 ---- b/arch/riscv/mm/init.c | 8 - b/arch/s390/mm/init.c | 3 b/arch/x86/include/asm/dma-mapping.h | 12 -- b/arch/x86/include/asm/gart.h | 5 b/arch/x86/include/asm/iommu.h | 8 + b/arch/x86/include/asm/xen/page.h | 5 b/arch/x86/include/asm/xen/swiotlb-xen.h | 2 b/arch/x86/kernel/Makefile | 2 b/arch/x86/kernel/amd_gart_64.c | 5 b/arch/x86/kernel/aperture_64.c | 14 -- b/arch/x86/kernel/cpu/mshyperv.c | 8 - b/arch/x86/kernel/pci-dma.c | 113 ++++++++++++++++---- b/arch/x86/kernel/tboot.c | 1 b/arch/x86/kernel/vmlinux.lds.S | 12 -- b/arch/x86/mm/mem_encrypt_amd.c | 3 b/arch/x86/pci/sta2x11-fixup.c | 2 b/arch/x86/xen/Makefile | 2 b/drivers/iommu/amd/init.c | 6 - b/drivers/iommu/amd/iommu.c | 5 b/drivers/iommu/intel/dmar.c | 6 - b/drivers/xen/swiotlb-xen.c | 132 ----------------------- b/include/linux/dmar.h | 6 - b/include/linux/swiotlb.h | 22 +-- b/include/trace/events/swiotlb.h | 29 +---- b/include/xen/arm/page.h | 1 b/include/xen/swiotlb-xen.h | 8 + b/kernel/dma/direct.h | 2 b/kernel/dma/swiotlb.c | 175 +++++++++++++++---------------- 48 files changed, 264 insertions(+), 826 deletions(-)
PATCH 1/15 dma-direct: use is_swiotlb_active in dma_direct_map_page
Use the more specific is_swiotlb_active check instead of checking the global swiotlb_force variable.
--- kernel/dma/direct.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/dma/direct.h +1 -1
@@ -91,7 +91,7 @@ static inline dma_addr_t dma_direct_map_page(struct device *dev,return swiotlb_map (dev, phys, size, dir, attrs);if (unlikely (!dma_capable (dev, dma_addr, size, true))) { -if (swiotlb_force !=SWIOTLB_NO_FORCE ) +if (is_swiotlb_active (dev))return swiotlb_map (dev, phys, size, dir, attrs); dev_WARN_ONCE(dev, 1,
Signature · 1 line
2.30.2
PATCH 2/15 swiotlb: make swiotlb_exit a no-op if SWIOTLB_FORCE is set
In reply to Christoph HellwigIf force bouncing is enabled we can't release the buffers.
--- kernel/dma/swiotlb.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/dma/swiotlb.c +3 -0
@@ -369,6 +369,9 @@ void __init swiotlb_exit(void)unsigned long tbl_vaddr;size_t tbl_size, slots_size; +if (swiotlb_force =SWIOTLB_FORCE ) +return ; +if (!mem->nslabs)return ;
Signature · 1 line
2.30.2
PATCH 3/15 swiotlb: simplify swiotlb_max_segment
In reply to Christoph HellwigRemove 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.
--- drivers/xen/swiotlb-xen.c | 2 -- include/linux/swiotlb.h | 1 - kernel/dma/swiotlb.c | 20 +++----------------- 3 files changed, 3 insertions(+), 20 deletions(-)
drivers/xen/swiotlb-xen.c +0 -2
@@ -202,7 +202,6 @@ int xen_swiotlb_init(void) 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 @@ void __init xen_swiotlb_init_early(void)if (swiotlb_init_with_tbl (start, nslabs, true)) panic("Cannot allocate SWIOTLB buffer"); - swiotlb_set_max_segment(PAGE_SIZE); }#endif /* CONFIG_X86 */
include/linux/swiotlb.h +0 -1
@@ -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);
kernel/dma/swiotlb.c +3 -17
@@ -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 ; }
Signature · 1 line
2.30.2
PATCH 4/15 swiotlb: rename swiotlb_late_init_with_default_size
In reply to Christoph Hellwigswiotlb_late_init_with_default_size is an overly verbose name that doesn't even catch what the function is doing, given that the size is not just a default but the actual requested size.
Rename it to swiotlb_init_late.
--- arch/x86/pci/sta2x11-fixup.c | 2 +- include/linux/swiotlb.h | 2 +- kernel/dma/swiotlb.c | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-)
arch/x86/pci/sta2x11-fixup.c +1 -1
@@ -57,7 +57,7 @@ static void sta2x11_new_instance(struct pci_dev *pdev)int size =STA2X11_SWIOTLB_SIZE ;/* First instance: register your own swiotlb area */ dev_info (&pdev->dev,"Using SWIOTLB (size %i)\n" , size); -if (swiotlb_late_init_with_default_size (size)) +if (swiotlb_init_late (size))dev_emerg (&pdev->dev,"init swiotlb failed\n" ); }list_add (&instance->list, &sta2x11_instance_list);
include/linux/swiotlb.h +1 -1
@@ -40,7 +40,7 @@ extern void swiotlb_init(int verbose);int swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,int verbose);unsigned long swiotlb_size_or_default (void );extern int swiotlb_late_init_with_tbl (char *tlb,unsigned long nslabs); -extern int swiotlb_late_init_with_default_size (size_t default_size); +int swiotlb_init_late (size_t size);extern void __init swiotlb_update_mem_attributes (void ); phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t phys,
kernel/dma/swiotlb.c +2 -3
@@ -281,11 +281,9 @@ swiotlb_init(int verbose)* initialize the swiotlb later using the slab allocator if needed. * This should be just like above, but with some error catching. */ -int -swiotlb_late_init_with_default_size (size_t default_size) +int swiotlb_init_late (size_t size) { - unsigned long nslabs - ALIGN(default_size >> IO_TLB_SHIFT, IO_TLB_SEGSIZE); +unsigned long nslabs =ALIGN (size >>IO_TLB_SHIFT ,IO_TLB_SEGSIZE );unsigned long bytes;unsigned char *vstart =NULL ;unsigned int order;
Signature · 1 line
2.30.2
PATCH 5/15 arm/xen: don't check for xen_initial_domain() in xen_create_contiguous_region
In reply to Christoph HellwigFrom: Stefano Stabellini <[email protected]>
It used to be that Linux enabled swiotlb-xen when running a dom0 on ARM. Since f5079a9a2a31 "xen/arm: introduce XENFEAT_direct_mapped and XENFEAT_not_direct_mapped", Linux detects whether to enable or disable swiotlb-xen based on the new feature flags: XENFEAT_direct_mapped and XENFEAT_not_direct_mapped.
However, there is still a leftover xen_initial_domain() check in xen_create_contiguous_region. Remove the check as xen_create_contiguous_region is only called by swiotlb-xen during initialization. If xen_create_contiguous_region is called, we know Linux is running 1:1 mapped so there is no need for additional checks.
Also update the in-code comment.
--- arch/arm/xen/mm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/arm/xen/mm.c +1 -4
@@ -122,10 +122,7 @@ int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,unsigned int address_bits, dma_addr_t *dma_handle) { -if (!xen_initial_domain ()) -return -EINVAL ; - -/* we assume that dom0 is mapped 1:1 for now */ +/* the domain is 1:1 mapped to use swiotlb-xen */ *dma_handle = pstart;return 0 ; }
Signature · 1 line
2.30.2
PATCH 6/15 MIPS/octeon: use swiotlb_init instead of open coding it
In reply to Christoph HellwigUse the generic swiotlb initialization helper instead of open coding it.
--- arch/mips/cavium-octeon/dma-octeon.c | 15 ++------------- arch/mips/pci/pci-octeon.c | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-)
arch/mips/cavium-octeon/dma-octeon.c +2 -13
@@ -186,15 +186,12 @@ phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)return daddr; } -char *octeon_swiotlb; -void __init plat_swiotlb_setup (void ) {phys_addr_t start, end;phys_addr_t max_addr;phys_addr_t addr_size;size_t swiotlbsize; -unsigned long swiotlb_nslabs;u64 i; max_addr =0 ;
@@ -236,15 +233,7 @@ void __init plat_swiotlb_setup(void)if (OCTEON_IS_OCTEON2 () && max_addr >=0x100000000ul ) swiotlbsize =64 * (1 <<20 );#endif - swiotlb_nslabs = swiotlbsize >>IO_TLB_SHIFT ; - swiotlb_nslabs =ALIGN (swiotlb_nslabs,IO_TLB_SEGSIZE ); - swiotlbsize = swiotlb_nslabs <<IO_TLB_SHIFT ; - - octeon_swiotlb =memblock_alloc_low (swiotlbsize,PAGE_SIZE ); -if (!octeon_swiotlb) -panic ("%s: Failed to allocate %zu bytes align=%lx\n" , - __func__, swiotlbsize,PAGE_SIZE ); -if (swiotlb_init_with_tbl (octeon_swiotlb, swiotlb_nslabs,1 ) = -ENOMEM ) -panic ("Cannot allocate SWIOTLB buffer" ); +swiotlb_adjust_size (swiotlbsize); +swiotlb_init (1 ); }
arch/mips/pci/pci-octeon.c +1 -0
@@ -664,7 +664,7 @@ static int __init octeon_pci_setup(void)/* BAR1 movable regions contiguous to cover the swiotlb */ octeon_bar1_pci_phys -virt_to_phys (octeon_swiotlb) & ~((1ull <<22 ) -1 ); + io_tlb_default_mem.start & ~((1ull <<22 ) -1 );for (index =0 ; index <32 ; index++) {union cvmx_pci_bar1_indexx bar1_index;
Signature · 1 line
2.30.2
PATCH 7/15 x86: remove the IOMMU table infrastructure
In reply to Christoph HellwigThe IOMMU table tries to separate the different IOMMUs into different backends, but actually requires various cross calls.
Rewrite the code to do the generic swiotlb/swiotlb-xen setup directly in pci-dma.c and then just call into the IOMMU drivers.
--- arch/ia64/include/asm/iommu_table.h | 7 -- arch/x86/include/asm/dma-mapping.h | 1 - arch/x86/include/asm/gart.h | 5 +- arch/x86/include/asm/iommu.h | 6 ++ arch/x86/include/asm/iommu_table.h | 102 ----------------------- arch/x86/include/asm/swiotlb.h | 30 ------- arch/x86/include/asm/xen/swiotlb-xen.h | 2 - arch/x86/kernel/Makefile | 2 - arch/x86/kernel/amd_gart_64.c | 5 +- arch/x86/kernel/aperture_64.c | 14 ++-- arch/x86/kernel/pci-dma.c | 107 ++++++++++++++++++++----- arch/x86/kernel/pci-iommu_table.c | 77 ------------------ arch/x86/kernel/pci-swiotlb.c | 77 ------------------ arch/x86/kernel/tboot.c | 1 - arch/x86/kernel/vmlinux.lds.S | 12 --- arch/x86/xen/Makefile | 2 - arch/x86/xen/pci-swiotlb-xen.c | 96 ---------------------- drivers/iommu/amd/init.c | 6 -- drivers/iommu/amd/iommu.c | 5 +- drivers/iommu/intel/dmar.c | 6 +- include/linux/dmar.h | 6 +- 21 files changed, 110 insertions(+), 459 deletions(-) delete mode 100644 arch/ia64/include/asm/iommu_table.h delete mode 100644 arch/x86/include/asm/iommu_table.h delete mode 100644 arch/x86/include/asm/swiotlb.h delete mode 100644 arch/x86/kernel/pci-iommu_table.c delete mode 100644 arch/x86/kernel/pci-swiotlb.c delete mode 100644 arch/x86/xen/pci-swiotlb-xen.c
arch/ia64/include/asm/iommu_table.h deleted +0 -7
@@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_IA64_IOMMU_TABLE_H -#define _ASM_IA64_IOMMU_TABLE_H - -#define IOMMU_INIT_POST (_detect) - -#endif /* _ASM_IA64_IOMMU_TABLE_H */
arch/x86/include/asm/dma-mapping.h +0 -1
@@ -9,7 +9,6 @@#include <linux/scatterlist.h> #include <asm/io.h> -#include <asm/swiotlb.h> extern int iommu_merge;extern int panic_on_overflow;
arch/x86/include/asm/gart.h +2 -3
@@ -38,7 +38,7 @@ extern int gart_iommu_aperture_disabled;extern void early_gart_iommu_check (void );extern int gart_iommu_init (void );extern void __init gart_parse_options (char *); -extern int gart_iommu_hole_init (void ); +void gart_iommu_hole_init (void );#else #define gart_iommu_aperture 0
@@ -51,9 +51,8 @@ static inline void early_gart_iommu_check(void)static inline void gart_parse_options (char *options) { } -static inline int gart_iommu_hole_init (void ) +static inline void gart_iommu_hole_init (void ) { -return -ENODEV ; }#endif
arch/x86/include/asm/iommu.h +6 -0
@@ -9,6 +9,12 @@extern int force_iommu, no_iommu;extern int iommu_detected; +#ifdef CONFIG_SWIOTLB +extern bool x86_swiotlb_enable; +#else +#define x86_swiotlb_enable false +#endif +/* 10 seconds */ #define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000)
arch/x86/include/asm/iommu_table.h deleted +0 -102
102 lines not on this page · raw message
arch/x86/include/asm/swiotlb.h deleted +0 -30
@@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_X86_SWIOTLB_H -#define _ASM_X86_SWIOTLB_H - -#include <linux/swiotlb.h> - -#ifdef CONFIG_SWIOTLB -extern int swiotlb; -extern int __init pci_swiotlb_detect_override (void ); -extern int __init pci_swiotlb_detect_4gb (void ); -extern void __init pci_swiotlb_init (void ); -extern void __init pci_swiotlb_late_init (void ); -#else -#define swiotlb 0 -static inline int pci_swiotlb_detect_override (void ) -{ -return 0 ; -} -static inline int pci_swiotlb_detect_4gb (void ) -{ -return 0 ; -} -static inline void pci_swiotlb_init (void ) -{ -} -static inline void pci_swiotlb_late_init (void ) -{ -} -#endif -#endif /* _ASM_X86_SWIOTLB_H */
arch/x86/include/asm/xen/swiotlb-xen.h +0 -2
@@ -3,10 +3,8 @@#define _ASM_X86_SWIOTLB_XEN_H#ifdef CONFIG_SWIOTLB_XEN -extern int __init pci_xen_swiotlb_detect (void );extern int pci_xen_swiotlb_init_late (void );#else -#define pci_xen_swiotlb_detect NULLstatic inline int pci_xen_swiotlb_init_late (void ) {return -ENXIO ; }#endif
arch/x86/kernel/Makefile +0 -2
@@ -71,7 +71,6 @@ obj-y += bootflag.o e820.o obj-y += pci-dma.o quirks.o topology.o kdebugfs.o obj-y += alternative.o i8253.o hw_breakpoint.o obj-y += tsc.o tsc_msr.o io_delay.o rtc.o -obj-y += pci-iommu_table.o obj-y += resource.o obj-y += irqflags.o obj-y += static_call.o
@@ -136,7 +135,6 @@ obj-$(CONFIG_PCSPKR_PLATFORM) += pcspeaker.o obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o -obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o obj-$(CONFIG_OF) += devicetree.o obj-$(CONFIG_UPROBES) += uprobes.o
arch/x86/kernel/amd_gart_64.c +1 -4
@@ -38,11 +38,9 @@#include <asm/iommu.h> #include <asm/gart.h> #include <asm/set_memory.h> -#include <asm/swiotlb.h> #include <asm/dma.h> #include <asm/amd_nb.h> #include <asm/x86_init.h> -#include <asm/iommu_table.h> static unsigned long iommu_bus_base;/* GART remapping area (physical) */ static unsigned long iommu_size;/* size of remapping area bytes */
@@ -808,7 +806,7 @@ int __init gart_iommu_init(void)flush_gart (); dma_ops = &gart_dma_ops; x86_platform.iommu_shutdown = gart_iommu_shutdown; - swiotlb =0 ; + x86_swiotlb_enable = false;return 0 ; }
@@ -842,4 +840,3 @@ void __init gart_parse_options(char *p) } } } -IOMMU_INIT_POST (gart_iommu_hole_init);
arch/x86/kernel/aperture_64.c +5 -9
@@ -392,7 +392,7 @@ void __init early_gart_iommu_check(void)static int __initdata printed_gart_size_msg; -int __init gart_iommu_hole_init (void ) +void __init gart_iommu_hole_init (void ) {u32 agp_aper_base =0 , agp_aper_order =0 ;u32 aper_size, aper_alloc =0 , aper_order =0 , last_aper_order =0 ;
@@ -401,11 +401,11 @@ int __init gart_iommu_hole_init(void)int i, node;if (!amd_gart_present ()) -return -ENODEV ; +return ;if (gart_iommu_aperture_disabled || !fix_aperture || !early_pci_allowed ()) -return -ENODEV ; +return ;pr_info ("Checking aperture...\n" );
@@ -491,10 +491,8 @@ int __init gart_iommu_hole_init(void)* and fixed up the northbridge */ exclude_from_core (last_aper_base, last_aper_order); - -return 1 ; } -return 0 ; +return ; }if (!fallback_aper_force) {
@@ -527,7 +525,7 @@ int __init gart_iommu_hole_init(void)panic ("Not enough memory for aperture" ); } }else { -return 0 ; +return ; }/*
@@ -561,6 +559,4 @@ int __init gart_iommu_hole_init(void) }set_up_gart_resume (aper_order, aper_alloc); - -return 1 ; }
arch/x86/kernel/pci-dma.c +86 -21
144 lines not on this page · raw message
arch/x86/kernel/pci-iommu_table.c deleted +0 -77
77 lines not on this page · raw message
arch/x86/kernel/pci-swiotlb.c deleted +0 -77
77 lines not on this page · raw message
arch/x86/kernel/tboot.c +0 -1
@@ -24,7 +24,6 @@#include <asm/processor.h> #include <asm/bootparam.h> #include <asm/pgalloc.h> -#include <asm/swiotlb.h> #include <asm/fixmap.h> #include <asm/proto.h> #include <asm/setup.h>
arch/x86/kernel/vmlinux.lds.S +0 -12
@@ -306,18 +306,6 @@ SECTIONS *(.altinstr_replacement) } - /* - * struct iommu_table_entry entries are injected in this section. - * It is an array of IOMMUs which during run time gets sorted depending - * on its dependency order. After rootfs_initcall is complete - * this section can be safely removed. - */ - .iommu_table : AT(ADDR(.iommu_table) - LOAD_OFFSET) { - __iommu_table = .; - *(.iommu_table) - __iommu_table_end = .; - } - . = ALIGN(8); .apicdrivers : AT(ADDR(.apicdrivers) - LOAD_OFFSET) { __apicdrivers = .;
arch/x86/xen/Makefile +0 -2
@@ -47,6 +47,4 @@ obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o obj-$(CONFIG_XEN_PV_DOM0) += vga.o -obj-$(CONFIG_SWIOTLB_XEN) += pci-swiotlb-xen.o - obj-$(CONFIG_XEN_EFI) += efi.o
arch/x86/xen/pci-swiotlb-xen.c deleted +0 -96
96 lines not on this page · raw message
drivers/iommu/amd/init.c +0 -6
@@ -26,7 +26,6 @@#include <asm/apic.h> #include <asm/gart.h> #include <asm/x86_init.h> -#include <asm/iommu_table.h> #include <asm/io_apic.h> #include <asm/irq_remapping.h> #include <asm/set_memory.h>
@@ -3235,11 +3234,6 @@ __setup("ivrs_ioapic", parse_ivrs_ioapic);__setup ("ivrs_hpet" , parse_ivrs_hpet);__setup ("ivrs_acpihid" , parse_ivrs_acpihid); -IOMMU_INIT_FINISH (amd_iommu_detect, - gart_iommu_hole_init, -NULL , -NULL ); -bool amd_iommu_v2_supported (void ) {return amd_iommu_v2_present;
drivers/iommu/amd/iommu.c +4 -1
@@ -1834,7 +1834,10 @@ void amd_iommu_domain_update(struct protection_domain *domain)static void __init amd_iommu_init_dma_ops (void ) { - swiotlb = (iommu_default_passthrough () || sme_me_mask) ?1 :0 ; +if (iommu_default_passthrough () || sme_me_mask) + x86_swiotlb_enable = true; +else + x86_swiotlb_enable = false; }int __init amd_iommu_init_api (void )
drivers/iommu/intel/dmar.c +1 -5
@@ -30,7 +30,6 @@#include <linux/numa.h> #include <linux/limits.h> #include <asm/irq_remapping.h> -#include <asm/iommu_table.h> #include <trace/events/intel_iommu.h> #include "../irq_remapping.h"
@@ -913,7 +912,7 @@ dmar_validate_one_drhd(struct acpi_dmar_header *entry, void *arg)return 0 ; } -int __init detect_intel_iommu (void ) +void __init detect_intel_iommu (void ) {int ret;struct dmar_res_callback validate_drhd_cb = {
@@ -946,8 +945,6 @@ int __init detect_intel_iommu(void) dmar_tbl =NULL ; }up_write (&dmar_global_lock); - -return ret ? ret :1 ; }static void unmap_iommu (struct intel_iommu *iommu)
@@ -2165,7 +2162,6 @@ static int __init dmar_free_unused_resources(void) }late_initcall (dmar_free_unused_resources); -IOMMU_INIT_POST (detect_intel_iommu);/* * DMAR Hotplug Support
include/linux/dmar.h +5 -1
@@ -121,7 +121,7 @@ extern int dmar_remove_dev_scope(struct dmar_pci_notify_info *info, u16 segment, struct dmar_dev_scope *devices, int count);/* Intel IOMMU detection */ -extern int detect_intel_iommu (void ); +void detect_intel_iommu (void );extern int enable_drhd_fault_handling (void );extern int dmar_device_add (acpi_handle handle);extern int dmar_device_remove (acpi_handle handle);
@@ -197,6 +197,10 @@ static inline bool dmar_platform_optin(void)return false; } +static inline void detect_intel_iommu (void ) +{ +} +#endif /* CONFIG_DMAR_TABLE */ struct irte {
Signature · 1 line
2.30.2
PATCH 8/15 x86: centralize setting SWIOTLB_FORCE when guest memory encryption is enabled
In reply to Christoph HellwigMove enabling SWIOTLB_FORCE for guest memory encryption into common code.
--- arch/x86/kernel/cpu/mshyperv.c | 8 -------- arch/x86/kernel/pci-dma.c | 8 ++++++++ arch/x86/mm/mem_encrypt_amd.c | 3 --- 3 files changed, 8 insertions(+), 11 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +0 -8
@@ -336,14 +336,6 @@ static void __init ms_hyperv_init_platform(void) swiotlb_unencrypted_base = ms_hyperv.shared_gpa_boundary;#endif } - -#ifdef CONFIG_SWIOTLB -/* -* Enable swiotlb force mode in Isolation VM to -* use swiotlb bounce buffer for dma transaction. -*/ - swiotlb_force =SWIOTLB_FORCE ; -#endif }if (hv_max_functions_eax >=HYPERV_CPUID_NESTED_FEATURES ) {
arch/x86/kernel/pci-dma.c +8 -0
@@ -53,6 +53,14 @@ static void __init pci_swiotlb_detect(void)if (cc_platform_has (CC_ATTR_HOST_MEM_ENCRYPT )) x86_swiotlb_enable = true; +/* +* Guest with guest memory encryption currently perform all DMA through +* bounce buffers as the hypervisor can't access arbitrary VM memory +* that is not explicitly shared with it. +*/ +if (cc_platform_has (CC_ATTR_GUEST_MEM_ENCRYPT )) + swiotlb_force =SWIOTLB_FORCE ; +if (swiotlb_force =SWIOTLB_FORCE ) x86_swiotlb_enable = true; }
arch/x86/mm/mem_encrypt_amd.c +0 -3
@@ -191,9 +191,6 @@ void __init sme_early_init(void)/* Update the protection map with memory encryption mask */ for (i =0 ; i <ARRAY_SIZE (protection_map); i++) protection_map[i] =pgprot_encrypted (protection_map[i]); - -if (cc_platform_has (CC_ATTR_GUEST_MEM_ENCRYPT )) - swiotlb_force =SWIOTLB_FORCE ; }void __init sev_setup_arch (void )
Signature · 1 line
2.30.2
PATCH 9/15 swiotlb: make the swiotlb_init interface more useful
In reply to Christoph HellwigPass a bool to pass if swiotlb needs to be enabled based on the addressing needs and replace the verbose argument with a set of flags, including one to force enable bounce buffering.
Note that this patch removes the possibility to force xen-swiotlb use using swiotlb=force on the command line on x86 (arm and arm64 never supported that), but this interface will be restored shortly.
--- arch/arm/mm/init.c | 6 +---- arch/arm64/mm/init.c | 6 +---- arch/ia64/mm/init.c | 4 +-- arch/mips/cavium-octeon/dma-octeon.c | 2 +- arch/mips/loongson64/dma.c | 2 +- arch/mips/sibyte/common/dma.c | 2 +- arch/powerpc/mm/mem.c | 3 ++- arch/powerpc/platforms/pseries/setup.c | 3 --- arch/riscv/mm/init.c | 8 +----- arch/s390/mm/init.c | 3 +-- arch/x86/kernel/pci-dma.c | 15 ++++++----- drivers/xen/swiotlb-xen.c | 4 +-- include/linux/swiotlb.h | 15 ++++++----- include/trace/events/swiotlb.h | 29 ++++++++------------- kernel/dma/swiotlb.c | 35 ++++++++++++++------------ 15 files changed, 55 insertions(+), 82 deletions(-)
arch/arm/mm/init.c +1 -5
@@ -312,11 +312,7 @@ static void __init free_highpages(void)void __init mem_init (void ) {#ifdef CONFIG_ARM_LPAE -if (swiotlb_force =SWIOTLB_FORCE || - max_pfn > arm_dma_pfn_limit) -swiotlb_init (1 ); -else - swiotlb_force =SWIOTLB_NO_FORCE ; +swiotlb_init (max_pfn > arm_dma_pfn_limit,SWIOTLB_VERBOSE );#endif set_max_mapnr (pfn_to_page (max_pfn) - mem_map);
arch/arm64/mm/init.c +1 -5
@@ -373,11 +373,7 @@ void __init bootmem_init(void)*/ void __init mem_init (void ) { -if (swiotlb_force =SWIOTLB_FORCE || - max_pfn >PFN_DOWN (arm64_dma_phys_limit)) -swiotlb_init (1 ); -else if (!xen_swiotlb_detect ()) - swiotlb_force =SWIOTLB_NO_FORCE ; +swiotlb_init (max_pfn >PFN_DOWN (arm64_dma_phys_limit),SWIOTLB_VERBOSE );/* this will put all unused low memory onto the freelists */ memblock_free_all ();
arch/ia64/mm/init.c +1 -3
@@ -437,9 +437,7 @@ mem_init (void)if (iommu_detected)break ;#endif -#ifdef CONFIG_SWIOTLB -swiotlb_init (1 ); -#endif +swiotlb_init (true,SWIOTLB_VERBOSE ); }while (0 );#ifdef CONFIG_FLATMEM
arch/mips/cavium-octeon/dma-octeon.c +1 -1
@@ -235,5 +235,5 @@ void __init plat_swiotlb_setup(void)#endif swiotlb_adjust_size (swiotlbsize); -swiotlb_init (1 ); +swiotlb_init (true,SWIOTLB_VERBOSE ); }
arch/mips/loongson64/dma.c +1 -1
@@ -24,5 +24,5 @@ phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)void __init plat_swiotlb_setup (void ) { -swiotlb_init (1 ); +swiotlb_init (true,SWIOTLB_VERBOSE ); }
arch/mips/sibyte/common/dma.c +1 -1
@@ -10,5 +10,5 @@void __init plat_swiotlb_setup (void ) { -swiotlb_init (1 ); +swiotlb_init (true,SWIOTLB_VERBOSE ); }
arch/powerpc/mm/mem.c +2 -1
@@ -17,6 +17,7 @@#include <linux/suspend.h> #include <linux/dma-direct.h> +#include <asm/swiotlb.h> #include <asm/machdep.h> #include <asm/rtas.h> #include <asm/kasan.h>
@@ -251,7 +252,7 @@ void __init mem_init(void)if (is_secure_guest ())svm_swiotlb_init ();else -swiotlb_init (0 ); +swiotlb_init (ppc_swiotlb_enable,0 );#endif high_memory = (void *)__va (max_low_pfn *PAGE_SIZE );
arch/powerpc/platforms/pseries/setup.c +0 -3
@@ -838,9 +838,6 @@ static void __init pSeries_setup_arch(void) } ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare; - -if (swiotlb_force =SWIOTLB_FORCE ) - ppc_swiotlb_enable =1 ; }static void pseries_panic (char *str)
arch/riscv/mm/init.c +1 -7
@@ -118,13 +118,7 @@ void __init mem_init(void)BUG_ON (!mem_map);#endif /* CONFIG_FLATMEM */ -#ifdef CONFIG_SWIOTLB -if (swiotlb_force =SWIOTLB_FORCE || - max_pfn >PFN_DOWN (dma32_phys_limit)) -swiotlb_init (1 ); -else - swiotlb_force =SWIOTLB_NO_FORCE ; -#endif +swiotlb_init (max_pfn >PFN_DOWN (dma32_phys_limit),SWIOTLB_VERBOSE ); high_memory = (void *)(__va (PFN_PHYS (max_low_pfn)));memblock_free_all ();
arch/s390/mm/init.c +1 -2
@@ -185,8 +185,7 @@ static void pv_init(void)return ;/* make sure bounce buffers are shared */ - swiotlb_force =SWIOTLB_FORCE ; -swiotlb_init (1 ); +swiotlb_init (true,SWIOTLB_FORCE |SWIOTLB_VERBOSE );swiotlb_update_mem_attributes (); }
arch/x86/kernel/pci-dma.c +7 -8
@@ -39,6 +39,7 @@ int iommu_detected __read_mostly = 0;#ifdef CONFIG_SWIOTLB bool x86_swiotlb_enable; +static unsigned int x86_swiotlb_flags;static void __init pci_swiotlb_detect (void ) {
@@ -58,16 +59,16 @@ static void __init pci_swiotlb_detect(void)* bounce buffers as the hypervisor can't access arbitrary VM memory * that is not explicitly shared with it. */ -if (cc_platform_has (CC_ATTR_GUEST_MEM_ENCRYPT )) - swiotlb_force =SWIOTLB_FORCE ; - -if (swiotlb_force =SWIOTLB_FORCE ) +if (cc_platform_has (CC_ATTR_GUEST_MEM_ENCRYPT )) { x86_swiotlb_enable = true; + x86_swiotlb_flags |=SWIOTLB_FORCE ; + } }#else static inline void __init pci_swiotlb_detect (void ) { } +#define x86_swiotlb_flags 0#endif /* CONFIG_SWIOTLB */ #ifdef CONFIG_SWIOTLB_XEN
@@ -75,8 +76,7 @@ static bool xen_swiotlb;static void __init pci_xen_swiotlb_init (void ) { -if (!xen_initial_domain () && !x86_swiotlb_enable && - swiotlb_force !=SWIOTLB_FORCE ) +if (!xen_initial_domain () && !x86_swiotlb_enable)return ; x86_swiotlb_enable = true; xen_swiotlb = true;
@@ -120,8 +120,7 @@ void __init pci_iommu_alloc(void)gart_iommu_hole_init ();amd_iommu_detect ();detect_intel_iommu (); -if (x86_swiotlb_enable) -swiotlb_init (0 ); +swiotlb_init (x86_swiotlb_enable, x86_swiotlb_flags); }/*
drivers/xen/swiotlb-xen.c +2 -2
@@ -251,7 +251,7 @@ void __init xen_swiotlb_init_early(void) panic("%s (rc:%d)", xen_swiotlb_error(XEN_SWIOTLB_EFIXUP), rc); } -if (swiotlb_init_with_tbl (start, nslabs, true)) +if (swiotlb_init_with_tbl (start, nslabs,SWIOTLB_VERBOSE ))panic ("Cannot allocate SWIOTLB buffer" ); }#endif /* CONFIG_X86 */
@@ -376,7 +376,7 @@ static dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,/* * Oh well, have to allocate and map a bounce buffer. */ -trace_swiotlb_bounced (dev, dev_addr, size, swiotlb_force); +trace_swiotlb_bounced (dev, dev_addr, size); map =swiotlb_tbl_map_single (dev, phys, size, size,0 , dir, attrs);if (map = (phys_addr_t )DMA_MAPPING_ERROR )
include/linux/swiotlb.h +7 -8
@@ -13,11 +13,8 @@ struct device;struct page ;struct scatterlist ; -enum swiotlb_force { -SWIOTLB_NORMAL ,/* Default - depending on HW DMA mask etc. */ -SWIOTLB_FORCE ,/* swiotlb=force */ -SWIOTLB_NO_FORCE ,/* swiotlb=noforce */ -}; +#define SWIOTLB_VERBOSE (1 << 0)/* verbose initialization */ +#define SWIOTLB_FORCE (1 << 1)/* force bounce buffering */ /* * Maximum allowable number of contiguous slabs to map,
@@ -36,8 +33,7 @@ enum swiotlb_force {/* default to 64MB */ #define IO_TLB_DEFAULT_SIZE (64UL<<20) -extern void swiotlb_init (int verbose); -int swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,int verbose); +int swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,unsigned int flags);unsigned long swiotlb_size_or_default (void );extern int swiotlb_late_init_with_tbl (char *tlb,unsigned long nslabs);int swiotlb_init_late (size_t size);
@@ -126,13 +122,16 @@ static inline bool is_swiotlb_force_bounce(struct device *dev) return mem && mem->force_bounce; } +void swiotlb_init (bool addressing_limited,unsigned int flags);void __init swiotlb_exit (void );unsigned int swiotlb_max_segment (void );size_t swiotlb_max_mapping_size (struct device *dev);bool is_swiotlb_active (struct device *dev);void __init swiotlb_adjust_size (unsigned long size);#else -#define swiotlb_force SWIOTLB_NO_FORCE +static inline void swiotlb_init (bool addressing_limited,unsigned int flags) +{ +}static inline bool is_swiotlb_buffer (struct device *dev,phys_addr_t paddr) {return false;
include/trace/events/swiotlb.h +10 -19
@@ -8,20 +8,15 @@#include <linux/tracepoint.h> TRACE_EVENT(swiotlb_bounced, - - TP_PROTO(struct device *dev, - dma_addr_t dev_addr, - size_t size, - enum swiotlb_force swiotlb_force), - - TP_ARGS(dev, dev_addr, size, swiotlb_force), + TP_PROTO(struct device *dev, dma_addr_t dev_addr, size_t size), + TP_ARGS(dev, dev_addr, size), TP_STRUCT__entry( - __string( dev_name, dev_name(dev) ) - __field( u64, dma_mask ) - __field( dma_addr_t, dev_addr ) - __field( size_t, size ) - __field( enum swiotlb_force, swiotlb_force ) + __string(dev_name, dev_name(dev)) + __field(u64, dma_mask) + __field(dma_addr_t, dev_addr) + __field(size_t, size) + __field(bool, force) ), TP_fast_assign(
@@ -29,19 +24,15 @@ TRACE_EVENT(swiotlb_bounced, __entry->dma_mask = (dev->dma_mask ? *dev->dma_mask :0 ); __entry->dev_addr = dev_addr; __entry->size = size; - __entry->swiotlb_force = swiotlb_force; + __entry->force =is_swiotlb_force_bounce (dev); ), -TP_printk ("dev_name: %s dma_mask=%llx dev_addr=%llx " -"size=%zu %s" , +TP_printk ("dev_name: %s dma_mask=%llx dev_addr=%llx size=%zu %s" ,__get_str (dev_name), __entry->dma_mask, (unsigned long long )__entry->dev_addr, __entry->size, -__print_symbolic (__entry->swiotlb_force, - { SWIOTLB_NORMAL, "NORMAL" }, - { SWIOTLB_FORCE, "FORCE" }, - { SWIOTLB_NO_FORCE, "NO_FORCE" })) + __entry->force ?"FORCE" :"NORMAL" ) );#endif /* _TRACE_SWIOTLB_H */
kernel/dma/swiotlb.c +19 -16
@@ -62,7 +62,8 @@#define INVALID_PHYS_ADDR (~(phys_addr_t)0) -enum swiotlb_force swiotlb_force; +static bool swiotlb_force_bounce; +static bool swiotlb_force_disable;struct io_tlb_mem io_tlb_default_mem;
@@ -81,9 +82,9 @@ setup_io_tlb_npages(char *str)if (*str =',' ) ++str;if (!strcmp (str,"force" )) - swiotlb_force =SWIOTLB_FORCE ; + swiotlb_force_bounce = true;else if (!strcmp (str,"noforce" )) - swiotlb_force =SWIOTLB_NO_FORCE ; + swiotlb_force_disable = true;return 0 ; }
@@ -202,7 +203,7 @@ static void swiotlb_init_io_tlb_mem(struct io_tlb_mem *mem, phys_addr_t start, mem->index =0 ; mem->late_alloc = late_alloc; -if (swiotlb_force =SWIOTLB_FORCE ) +if (swiotlb_force_bounce) mem->force_bounce = true;spin_lock_init (&mem->lock);
@@ -224,12 +225,13 @@ static void swiotlb_init_io_tlb_mem(struct io_tlb_mem *mem, phys_addr_t start,return ; } -int __init swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,int verbose) +int __init swiotlb_init_with_tbl (char *tlb,unsigned long nslabs, +unsigned int flags) {struct io_tlb_mem *mem = &io_tlb_default_mem;size_t alloc_size; -if (swiotlb_force =SWIOTLB_NO_FORCE ) +if (swiotlb_force_disable)return 0 ;/* protect against double initialization */
@@ -243,8 +245,9 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) __func__, alloc_size, PAGE_SIZE);swiotlb_init_io_tlb_mem (mem,__pa (tlb), nslabs, false); + mem->force_bounce = flags &SWIOTLB_FORCE ; -if (verbose) +if (flags &SWIOTLB_VERBOSE )swiotlb_print_info ();return 0 ; }
@@ -253,20 +256,21 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)* Statically reserve bounce buffer space and initialize bounce buffer data * structures for the software IO TLB used to implement the DMA API. */ -void __init -swiotlb_init (int verbose) +void __init swiotlb_init (bool addressing_limit,unsigned int flags) {size_t bytes =PAGE_ALIGN (default_nslabs <<IO_TLB_SHIFT );void *tlb; -if (swiotlb_force =SWIOTLB_NO_FORCE ) +if (!addressing_limit && !swiotlb_force_bounce) +return ; +if (swiotlb_force_disable)return ;/* Get IO TLB memory from the low pages */ tlb =memblock_alloc_low (bytes,PAGE_SIZE );if (!tlb) goto fail; -if (swiotlb_init_with_tbl (tlb, default_nslabs, verbose)) +if (swiotlb_init_with_tbl (tlb, default_nslabs, flags)) goto fail_free_mem;return ;
@@ -289,7 +293,7 @@ int swiotlb_init_late(size_t size)unsigned int order;int rc =0 ; -if (swiotlb_force =SWIOTLB_NO_FORCE ) +if (swiotlb_force_disable)return 0 ;/*
@@ -328,7 +332,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)struct io_tlb_mem *mem = &io_tlb_default_mem;unsigned long bytes = nslabs <<IO_TLB_SHIFT ; -if (swiotlb_force =SWIOTLB_NO_FORCE ) +if (swiotlb_force_disable)return 0 ;/* protect against double initialization */
@@ -353,7 +357,7 @@ void __init swiotlb_exit(void)unsigned long tbl_vaddr;size_t tbl_size, slots_size; -if (swiotlb_force =SWIOTLB_FORCE ) +if (swiotlb_force_bounce)return ;if (!mem->nslabs)
@@ -699,8 +703,7 @@ dma_addr_t swiotlb_map(struct device *dev, phys_addr_t paddr, size_t size,phys_addr_t swiotlb_addr;dma_addr_t dma_addr; -trace_swiotlb_bounced (dev,phys_to_dma (dev, paddr), size, - swiotlb_force); +trace_swiotlb_bounced (dev,phys_to_dma (dev, paddr), size); swiotlb_addr =swiotlb_tbl_map_single (dev, paddr, size, size,0 , dir, attrs);
Signature · 1 line
2.30.2
PATCH 10/15 swiotlb: add a SWIOTLB_ANY flag to lift the low memory restriction
In reply to Christoph HellwigPower SVM wants to allocate a swiotlb buffer that is not restricted to low memory for the trusted hypervisor scheme. Consolidate the support for this into the swiotlb_init interface by adding a new flag.
--- arch/powerpc/include/asm/svm.h | 4 ---- arch/powerpc/include/asm/swiotlb.h | 1 + arch/powerpc/kernel/dma-swiotlb.c | 1 + arch/powerpc/mm/mem.c | 5 +---- arch/powerpc/platforms/pseries/svm.c | 26 +------------------------- include/linux/swiotlb.h | 1 + kernel/dma/swiotlb.c | 11 +++++++++-- 7 files changed, 14 insertions(+), 35 deletions(-)
arch/powerpc/include/asm/svm.h +0 -4
@@ -15,8 +15,6 @@ static inline bool is_secure_guest(void)return mfmsr () &MSR_S ; } -void __init svm_swiotlb_init (void ); -void dtl_cache_ctor (void *addr);#define get_dtl_cache_ctor () (is_secure_guest() ? dtl_cache_ctor : NULL)
@@ -27,8 +25,6 @@ static inline bool is_secure_guest(void) return false; } -static inline void svm_swiotlb_init (void ) {} -#define get_dtl_cache_ctor () NULL#endif /* CONFIG_PPC_SVM */
arch/powerpc/include/asm/swiotlb.h +1 -0
@@ -9,6 +9,7 @@#include <linux/swiotlb.h> extern unsigned int ppc_swiotlb_enable; +extern unsigned int ppc_swiotlb_flags;#ifdef CONFIG_SWIOTLB void swiotlb_detect_4g (void );
arch/powerpc/kernel/dma-swiotlb.c +1 -0
@@ -10,6 +10,7 @@#include <asm/swiotlb.h> unsigned int ppc_swiotlb_enable; +unsigned int ppc_swiotlb_flags;void __init swiotlb_detect_4g (void ) {
arch/powerpc/mm/mem.c +1 -4
@@ -249,10 +249,7 @@ void __init mem_init(void)* back to to-down. */ memblock_set_bottom_up (true); -if (is_secure_guest ()) -svm_swiotlb_init (); -else -swiotlb_init (ppc_swiotlb_enable,0 ); +swiotlb_init (ppc_swiotlb_enable, ppc_swiotlb_flags);#endif high_memory = (void *)__va (max_low_pfn *PAGE_SIZE );
arch/powerpc/platforms/pseries/svm.c +1 -25
@@ -28,7 +28,7 @@ static int __init init_svm(void)* need to use the SWIOTLB buffer for DMA even if dma_capable() says * otherwise. */ - swiotlb_force =SWIOTLB_FORCE ; + ppc_swiotlb_flags |=SWIOTLB_ANY |SWIOTLB_FORCE ;/* Share the SWIOTLB buffer with the host. */ swiotlb_update_mem_attributes ();
@@ -37,30 +37,6 @@ static int __init init_svm(void) }machine_early_initcall (pseries, init_svm); -/* -* Initialize SWIOTLB. Essentially the same as swiotlb_init(), except that it -* can allocate the buffer anywhere in memory. Since the hypervisor doesn't have -* any addressing limitation, we don't need to allocate it in low addresses. -*/ -void __init svm_swiotlb_init (void ) -{ -unsigned char *vstart; -unsigned long bytes, io_tlb_nslabs; - - io_tlb_nslabs = (swiotlb_size_or_default () >>IO_TLB_SHIFT ); - io_tlb_nslabs =ALIGN (io_tlb_nslabs,IO_TLB_SEGSIZE ); - - bytes = io_tlb_nslabs <<IO_TLB_SHIFT ; - - vstart =memblock_alloc (PAGE_ALIGN (bytes),PAGE_SIZE ); -if (vstart && !swiotlb_init_with_tbl (vstart, io_tlb_nslabs, false)) -return ; - - -memblock_free (vstart,PAGE_ALIGN (io_tlb_nslabs <<IO_TLB_SHIFT )); -panic ("SVM: Cannot allocate SWIOTLB buffer" ); -} -int set_memory_encrypted (unsigned long addr,int numpages) {if (!cc_platform_has (CC_ATTR_MEM_ENCRYPT ))
include/linux/swiotlb.h +1 -0
@@ -15,6 +15,7 @@ struct scatterlist;#define SWIOTLB_VERBOSE (1 << 0)/* verbose initialization */ #define SWIOTLB_FORCE (1 << 1)/* force bounce buffering */ +#define SWIOTLB_ANY (1 << 2)/* allow any memory for the buffer */ /* * Maximum allowable number of contiguous slabs to map,
kernel/dma/swiotlb.c +9 -2
@@ -266,8 +266,15 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)if (swiotlb_force_disable)return ; -/* Get IO TLB memory from the low pages */ - tlb =memblock_alloc_low (bytes,PAGE_SIZE ); +/* +* By default allocate the bounce buffer memory from low memory, but +* allow to pick a location everywhere for hypervisors with guest +* memory encryption. +*/ +if (flags &SWIOTLB_ANY ) + tlb =memblock_alloc (bytes,PAGE_SIZE ); +else + tlb =memblock_alloc_low (bytes,PAGE_SIZE );if (!tlb) goto fail;if (swiotlb_init_with_tbl (tlb, default_nslabs, flags))
Signature · 1 line
2.30.2
PATCH 11/15 swiotlb: pass a gfp_mask argument to swiotlb_init_late
In reply to Christoph HellwigLet the caller chose a zone to allocate from. This will be used later on by the xen-swiotlb initialization on arm.
--- arch/x86/pci/sta2x11-fixup.c | 2 +- include/linux/swiotlb.h | 2 +- kernel/dma/swiotlb.c | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-)
arch/x86/pci/sta2x11-fixup.c +1 -1
@@ -57,7 +57,7 @@ static void sta2x11_new_instance(struct pci_dev *pdev)int size =STA2X11_SWIOTLB_SIZE ;/* First instance: register your own swiotlb area */ dev_info (&pdev->dev,"Using SWIOTLB (size %i)\n" , size); -if (swiotlb_init_late (size)) +if (swiotlb_init_late (size,GFP_DMA ))dev_emerg (&pdev->dev,"init swiotlb failed\n" ); }list_add (&instance->list, &sta2x11_instance_list);
include/linux/swiotlb.h +1 -1
@@ -37,7 +37,7 @@ struct scatterlist;int swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,unsigned int flags);unsigned long swiotlb_size_or_default (void );extern int swiotlb_late_init_with_tbl (char *tlb,unsigned long nslabs); -int swiotlb_init_late (size_t size); +int swiotlb_init_late (size_t size,gfp_t gfp_mask);extern void __init swiotlb_update_mem_attributes (void ); phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t phys,
kernel/dma/swiotlb.c +2 -5
@@ -292,7 +292,7 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)* initialize the swiotlb later using the slab allocator if needed. * This should be just like above, but with some error catching. */ -int swiotlb_init_late (size_t size) +int swiotlb_init_late (size_t size,gfp_t gfp_mask) {unsigned long nslabs =ALIGN (size >>IO_TLB_SHIFT ,IO_TLB_SEGSIZE );unsigned long bytes;
@@ -303,15 +303,12 @@ int swiotlb_init_late(size_t size)if (swiotlb_force_disable)return 0 ; -/* -* Get IO TLB memory from the low pages -*/ order =get_order (nslabs <<IO_TLB_SHIFT ); nslabs =SLABS_PER_PAGE << order; bytes = nslabs <<IO_TLB_SHIFT ;while ((SLABS_PER_PAGE << order) >IO_TLB_MIN_SLABS ) { - vstart = (void *)__get_free_pages (GFP_DMA | __GFP_NOWARN, + vstart = (void *)__get_free_pages (gfp_mask | __GFP_NOWARN, order);if (vstart)break ;
Signature · 1 line
2.30.2
PATCH 12/15 swiotlb: provide swiotlb_init variants that remap the buffer
In reply to Christoph HellwigTo shared more code between swiotlb and xen-swiotlb, offer a swiotlb_init_remap interface and add a remap callback to swiotlb_init_late that will allow Xen to remap the buffer the buffer without duplicating much of the logic.
--- arch/x86/pci/sta2x11-fixup.c | 2 +- include/linux/swiotlb.h | 5 ++++- kernel/dma/swiotlb.c | 38 +++++++++++++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 5 deletions(-)
arch/x86/pci/sta2x11-fixup.c +1 -1
@@ -57,7 +57,7 @@ static void sta2x11_new_instance(struct pci_dev *pdev)int size =STA2X11_SWIOTLB_SIZE ;/* First instance: register your own swiotlb area */ dev_info (&pdev->dev,"Using SWIOTLB (size %i)\n" , size); -if (swiotlb_init_late (size,GFP_DMA )) +if (swiotlb_init_late (size,GFP_DMA ,NULL ))dev_emerg (&pdev->dev,"init swiotlb failed\n" ); }list_add (&instance->list, &sta2x11_instance_list);
include/linux/swiotlb.h +4 -1
@@ -36,8 +36,11 @@ struct scatterlist;int swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,unsigned int flags);unsigned long swiotlb_size_or_default (void ); +void __init swiotlb_init_remap (bool addressing_limit,unsigned int flags, +int (*remap)(void *tlb,unsigned long nslabs)); +int swiotlb_init_late (size_t size,gfp_t gfp_mask, +int (*remap)(void *tlb,unsigned long nslabs));extern int swiotlb_late_init_with_tbl (char *tlb,unsigned long nslabs); -int swiotlb_init_late (size_t size,gfp_t gfp_mask);extern void __init swiotlb_update_mem_attributes (void ); phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t phys,
kernel/dma/swiotlb.c +35 -3
@@ -256,9 +256,11 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs,* Statically reserve bounce buffer space and initialize bounce buffer data * structures for the software IO TLB used to implement the DMA API. */ -void __init swiotlb_init (bool addressing_limit,unsigned int flags) +void __init swiotlb_init_remap (bool addressing_limit,unsigned int flags, +int (*remap)(void *tlb,unsigned long nslabs)) { -size_t bytes =PAGE_ALIGN (default_nslabs <<IO_TLB_SHIFT ); +unsigned long nslabs = default_nslabs; +size_t bytes;void *tlb;if (!addressing_limit && !swiotlb_force_bounce)
@@ -271,12 +273,24 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)* allow to pick a location everywhere for hypervisors with guest * memory encryption. */ +retry: + bytes =PAGE_ALIGN (default_nslabs <<IO_TLB_SHIFT );if (flags &SWIOTLB_ANY ) tlb =memblock_alloc (bytes,PAGE_SIZE );else tlb =memblock_alloc_low (bytes,PAGE_SIZE );if (!tlb) goto fail; +if (remap &&remap (tlb, nslabs) <0 ) { +memblock_free (tlb,PAGE_ALIGN (bytes)); + +/* Min is 2MB */ +if (nslabs <=1024 ) +panic ("%s: Failed to remap %zu bytes\n" , + __func__, bytes); + nslabs =max (1024UL ,ALIGN (nslabs >>1 ,IO_TLB_SEGSIZE )); + goto retry; + }if (swiotlb_init_with_tbl (tlb, default_nslabs, flags)) goto fail_free_mem;return ;
@@ -287,12 +301,18 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)pr_warn ("Cannot allocate buffer" ); } +void __init swiotlb_init (bool addressing_limit,unsigned int flags) +{ +return swiotlb_init_remap (addressing_limit, flags,NULL ); +} +/* * Systems with larger DMA zones (those that don't support ISA) can * initialize the swiotlb later using the slab allocator if needed. * This should be just like above, but with some error catching. */ -int swiotlb_init_late (size_t size,gfp_t gfp_mask) +int swiotlb_init_late (size_t size,gfp_t gfp_mask, +int (*remap)(void *tlb,unsigned long nslabs)) {unsigned long nslabs =ALIGN (size >>IO_TLB_SHIFT ,IO_TLB_SEGSIZE );unsigned long bytes;
@@ -303,6 +323,7 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask)if (swiotlb_force_disable)return 0 ; +retry: order =get_order (nslabs <<IO_TLB_SHIFT ); nslabs =SLABS_PER_PAGE << order; bytes = nslabs <<IO_TLB_SHIFT ;
@@ -317,6 +338,17 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask)if (!vstart)return -ENOMEM ; +if (remap) + rc =remap (vstart, nslabs); +if (rc) { +free_pages ((unsigned long )vstart, order); + +/* Min is 2MB */ +if (nslabs <=1024 ) +return rc; + nslabs =max (1024UL ,ALIGN (nslabs >>1 ,IO_TLB_SEGSIZE )); + goto retry; + }if (order !=get_order (bytes)) { pr_warn("only able to allocate %ld MB\n",
Signature · 1 line
2.30.2
Boris Ostrovsky
reviewerRe: [PATCH 12/15] swiotlb: provide swiotlb_init variants that remap the buffer
Quoted 17 lines · Christoph Hellwig
kernel/dma/swiotlb.c +6
-2-void __init swiotlb_init (bool addressing_limit,unsigned int flags) +void __init swiotlb_init_remap (bool addressing_limit,unsigned int flags, +int (*remap)(void *tlb,unsigned long nslabs)) { -size_t bytes =PAGE_ALIGN (default_nslabs <<IO_TLB_SHIFT ); +unsigned long nslabs = default_nslabs; +size_t bytes;void *tlb;if (!addressing_limit && !swiotlb_force_bounce)@@ -271,12 +273,24 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)* allow to pick a location everywhere for hypervisors with guest * memory encryption. */ +retry: + bytes =PAGE_ALIGN (default_nslabs <<IO_TLB_SHIFT );if (flags &SWIOTLB_ANY )
kernel/dma/swiotlb.c void __init swiotlb_init(bool addressing_limit, unsigned int flags) · line 288
Quoted 10 lines
kernel/dma/swiotlb.c +5
-0tlb =memblock_alloc (bytes,PAGE_SIZE ); else tlb =memblock_alloc_low (bytes,PAGE_SIZE );if (!tlb) goto fail; +if (remap &&remap (tlb, nslabs) <0 ) { +memblock_free (tlb,PAGE_ALIGN (bytes)); + +/* Min is 2MB */ +if (nslabs <=1024 )
This is IO_TLB_MIN_SLABS, isn't it? (Xen code didn't say so but that's what it meant to say I believe)
Quoted 15 lines
kernel/dma/swiotlb.c +6
-0+panic ("%s: Failed to remap %zu bytes\n" , + __func__, bytes); + nslabs =max (1024UL ,ALIGN (nslabs >>1 ,IO_TLB_SEGSIZE )); + goto retry; + }@@ -303,6 +323,7 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask)if (swiotlb_force_disable)return 0 ; +retry: order =get_order (nslabs <<IO_TLB_SHIFT ); nslabs =SLABS_PER_PAGE << order; bytes = nslabs <<IO_TLB_SHIFT ;
kernel/dma/swiotlb.c int swiotlb_init_late(size_t size, gfp_t gfp_mask) · line 347
Quoted 10 lines
kernel/dma/swiotlb.c +7
-0@@ -317,6 +338,17 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask)if (!vstart)return -ENOMEM ; +if (remap) + rc =remap (vstart, nslabs); +if (rc) { +free_pages ((unsigned long )vstart, order); + +/* Min is 2MB */ +if (nslabs <=1024 )
Same here.
-boris
Quoted 7 lines
kernel/dma/swiotlb.c +4
-0+return rc; + nslabs =max (1024UL ,ALIGN (nslabs >>1 ,IO_TLB_SEGSIZE )); + goto retry; + }if (order !=get_order (bytes)) { pr_warn("only able to allocate %ld MB\n",
Re: [PATCH 12/15] swiotlb: provide swiotlb_init variants that remap the buffer
Quoted 1 line · Boris Ostrovsky
This is
IO_TLB_MIN_SLABS, isn't it? (Xen code didn't say so but that's what it meant to say I believe)
Yes, that makes much more sense. I've switched the patch to use IO_TLB_MIN_SLABS and drop the 2MB comment in both places.
Can I get a review with that fixed up?
---
From 153085bf3e6e69d676bef0fb96395a86fb8122f5 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <[email protected]>
Date: Mon, 14 Mar 2022 08:02:57 +0100
Subject: swiotlb: provide swiotlb_init variants that remap the buffer
To shared more code between swiotlb and xen-swiotlb, offer a swiotlb_init_remap interface and add a remap callback to swiotlb_init_late that will allow Xen to remap the buffer the buffer without duplicating much of the logic.
--- arch/x86/pci/sta2x11-fixup.c | 2 +- include/linux/swiotlb.h | 5 ++++- kernel/dma/swiotlb.c | 36 +++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 5 deletions(-)
arch/x86/pci/sta2x11-fixup.c +1 -1
@@ -57,7 +57,7 @@ static void sta2x11_new_instance(struct pci_dev *pdev)int size =STA2X11_SWIOTLB_SIZE ;/* First instance: register your own swiotlb area */ dev_info (&pdev->dev,"Using SWIOTLB (size %i)\n" , size); -if (swiotlb_init_late (size,GFP_DMA )) +if (swiotlb_init_late (size,GFP_DMA ,NULL ))dev_emerg (&pdev->dev,"init swiotlb failed\n" ); }list_add (&instance->list, &sta2x11_instance_list);
include/linux/swiotlb.h +4 -1
@@ -36,8 +36,11 @@ struct scatterlist;int swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,unsigned int flags);unsigned long swiotlb_size_or_default (void ); +void __init swiotlb_init_remap (bool addressing_limit,unsigned int flags, +int (*remap)(void *tlb,unsigned long nslabs)); +int swiotlb_init_late (size_t size,gfp_t gfp_mask, +int (*remap)(void *tlb,unsigned long nslabs));extern int swiotlb_late_init_with_tbl (char *tlb,unsigned long nslabs); -int swiotlb_init_late (size_t size,gfp_t gfp_mask);extern void __init swiotlb_update_mem_attributes (void ); phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t phys,
kernel/dma/swiotlb.c +33 -3
@@ -256,9 +256,11 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs,* Statically reserve bounce buffer space and initialize bounce buffer data * structures for the software IO TLB used to implement the DMA API. */ -void __init swiotlb_init (bool addressing_limit,unsigned int flags) +void __init swiotlb_init_remap (bool addressing_limit,unsigned int flags, +int (*remap)(void *tlb,unsigned long nslabs)) { -size_t bytes =PAGE_ALIGN (default_nslabs <<IO_TLB_SHIFT ); +unsigned long nslabs = default_nslabs; +size_t bytes;void *tlb;if (!addressing_limit && !swiotlb_force_bounce)
@@ -271,12 +273,23 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)* allow to pick a location everywhere for hypervisors with guest * memory encryption. */ +retry: + bytes =PAGE_ALIGN (default_nslabs <<IO_TLB_SHIFT );if (flags &SWIOTLB_ANY ) tlb =memblock_alloc (bytes,PAGE_SIZE );else tlb =memblock_alloc_low (bytes,PAGE_SIZE );if (!tlb) goto fail; +if (remap &&remap (tlb, nslabs) <0 ) { +memblock_free (tlb,PAGE_ALIGN (bytes)); + +if (nslabs <=IO_TLB_MIN_SLABS ) +panic ("%s: Failed to remap %zu bytes\n" , + __func__, bytes); + nslabs =max (1024UL ,ALIGN (nslabs >>1 ,IO_TLB_SEGSIZE )); + goto retry; + }if (swiotlb_init_with_tbl (tlb, default_nslabs, flags)) goto fail_free_mem;return ;
@@ -287,12 +300,18 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)pr_warn ("Cannot allocate buffer" ); } +void __init swiotlb_init (bool addressing_limit,unsigned int flags) +{ +return swiotlb_init_remap (addressing_limit, flags,NULL ); +} +/* * Systems with larger DMA zones (those that don't support ISA) can * initialize the swiotlb later using the slab allocator if needed. * This should be just like above, but with some error catching. */ -int swiotlb_init_late (size_t size,gfp_t gfp_mask) +int swiotlb_init_late (size_t size,gfp_t gfp_mask, +int (*remap)(void *tlb,unsigned long nslabs)) {unsigned long nslabs =ALIGN (size >>IO_TLB_SHIFT ,IO_TLB_SEGSIZE );unsigned long bytes;
@@ -303,6 +322,7 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask)if (swiotlb_force_disable)return 0 ; +retry: order =get_order (nslabs <<IO_TLB_SHIFT ); nslabs =SLABS_PER_PAGE << order; bytes = nslabs <<IO_TLB_SHIFT ;
@@ -317,6 +337,16 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask)if (!vstart)return -ENOMEM ; +if (remap) + rc =remap (vstart, nslabs); +if (rc) { +free_pages ((unsigned long )vstart, order); + +if (IO_TLB_MIN_SLABS <=1024 ) +return rc; + nslabs =max (1024UL ,ALIGN (nslabs >>1 ,IO_TLB_SEGSIZE )); + goto retry; + }if (order !=get_order (bytes)) { pr_warn("only able to allocate %ld MB\n",
Signature · 1 line
2.30.2
Boris Ostrovsky
reviewerRe: [PATCH 12/15] swiotlb: provide swiotlb_init variants that remap the buffer
Quoted 9 lines · Christoph Hellwig
kernel/dma/swiotlb.c +2
-0@@ -271,12 +273,23 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)* allow to pick a location everywhere for hypervisors with guest * memory encryption. */ +retry: + bytes =PAGE_ALIGN (default_nslabs <<IO_TLB_SHIFT );if (flags &SWIOTLB_ANY ) tlb =memblock_alloc (bytes,PAGE_SIZE );else
kernel/dma/swiotlb.c void __init swiotlb_init(bool addressing_limit, unsigned int flags) · line 290
Quoted 10 lines
kernel/dma/swiotlb.c +7
-0tlb =memblock_alloc_low (bytes,PAGE_SIZE );if (!tlb) goto fail; +if (remap &&remap (tlb, nslabs) <0 ) { +memblock_free (tlb,PAGE_ALIGN (bytes)); + +if (nslabs <=IO_TLB_MIN_SLABS ) +panic ("%s: Failed to remap %zu bytes\n" , + __func__, bytes); + nslabs =max (1024UL ,ALIGN (nslabs >>1 ,IO_TLB_SEGSIZE ));
I spoke with Konrad (who wrote the original patch --- f4b2f07b2ed9b469ead87e06fc2fc3d12663a725) and apparently the reason for 2MB was to optimize for Xen's slab allocator, it had nothing to do with IO_TLB_MIN_SLABS. Since this is now common code we should not expose Xen-specific optimizations here and smaller values will still work so IO_TLB_MIN_SLABS is fine.
I think this should be mentioned in the commit message though, probably best in the next patch where you switch to this code.
As far as the hunk above, I don't think we need the max() here: with IO_TLB_MIN_SLABS being 512 we may get stuck in an infinite loop. Something like
nslabs = ALIGN(nslabs >> 1, IO_TLB_SEGSIZE); if (nslabs <= IO_TLB_MIN_SLABS) panic()
should be sufficient.
Quoted 35 lines
kernel/dma/swiotlb.c +10
-1+ goto retry; + }if (swiotlb_init_with_tbl (tlb, default_nslabs, flags)) goto fail_free_mem;return ;@@ -287,12 +300,18 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)pr_warn ("Cannot allocate buffer" ); } +void __init swiotlb_init (bool addressing_limit,unsigned int flags) +{ +return swiotlb_init_remap (addressing_limit, flags,NULL ); +} +/* * Systems with larger DMA zones (those that don't support ISA) can * initialize the swiotlb later using the slab allocator if needed. * This should be just like above, but with some error catching. */ -int swiotlb_init_late (size_t size,gfp_t gfp_mask) +int swiotlb_init_late (size_t size,gfp_t gfp_mask, +int (*remap)(void *tlb,unsigned long nslabs)) {unsigned long nslabs =ALIGN (size >>IO_TLB_SHIFT ,IO_TLB_SEGSIZE );unsigned long bytes;@@ -303,6 +322,7 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask)if (swiotlb_force_disable)return 0 ; +retry: order =get_order (nslabs <<IO_TLB_SHIFT ); nslabs =SLABS_PER_PAGE << order; bytes = nslabs <<IO_TLB_SHIFT ;@@ -317,6 +337,16 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask)
kernel/dma/swiotlb.c int swiotlb_init_late(size_t size, gfp_t gfp_mask) · line 347
Quoted 10 lines
kernel/dma/swiotlb.c +8
-0if (!vstart)return -ENOMEM ; +if (remap) + rc =remap (vstart, nslabs); +if (rc) { +free_pages ((unsigned long )vstart, order); + +if (IO_TLB_MIN_SLABS <=1024 ) +return rc; + nslabs =max (1024UL ,ALIGN (nslabs >>1 ,IO_TLB_SEGSIZE ));
Same here. (The 'if' check above is wrong anyway).
Patches 13 and 14 look good.
-boris
Quoted 5 lines
kernel/dma/swiotlb.c +2
-0+ goto retry; + }if (order !=get_order (bytes)) { pr_warn("only able to allocate %ld MB\n",
PATCH 13/15 swiotlb: merge swiotlb-xen initialization into swiotlb
In reply to Christoph HellwigReuse the generic swiotlb initialization for xen-swiotlb. For ARM/ARM64 this works trivially, while for x86 xen_swiotlb_fixup needs to be passed as the remap argument to swiotlb_init_remap/swiotlb_init_late.
--- arch/arm/xen/mm.c | 21 +++--- arch/x86/include/asm/xen/page.h | 5 -- arch/x86/kernel/pci-dma.c | 19 +++-- drivers/xen/swiotlb-xen.c | 128 +------------------------------- include/xen/arm/page.h | 1 - include/xen/swiotlb-xen.h | 8 +- 6 files changed, 27 insertions(+), 155 deletions(-)
arch/arm/xen/mm.c +11 -10
@@ -23,22 +23,20 @@#include <asm/xen/hypercall.h> #include <asm/xen/interface.h> -unsigned long xen_get_swiotlb_free_pages (unsigned int order) +static gfp_t xen_swiotlb_gfp (void ) {phys_addr_t base; -gfp_t flags = __GFP_NOWARN|__GFP_KSWAPD_RECLAIM;u64 i;for_each_mem_range (i, &base,NULL ) {if (base < (phys_addr_t )0xffffffff ) {if (IS_ENABLED (CONFIG_ZONE_DMA32 )) - flags |= __GFP_DMA32; -else - flags |= __GFP_DMA; -break ; +return __GFP_DMA32; +return __GFP_DMA; } } -return __get_free_pages (flags, order); + +return GFP_KERNEL ; }static bool hypercall_cflush = false;
@@ -140,10 +138,13 @@ static int __init xen_mm_init(void)if (!xen_swiotlb_detect ())return 0 ; - rc =xen_swiotlb_init ();/* we can work with the default swiotlb */ -if (rc <0 && rc != -EEXIST ) -return rc; +if (!io_tlb_default_mem.nslabs) { + rc =swiotlb_init_late (swiotlb_size_or_default (), +xen_swiotlb_gfp (),NULL ); +if (rc <0 ) +return rc; + } cflush.op =0 ; cflush.a.dev_bus_addr =0 ;
arch/x86/include/asm/xen/page.h +0 -5
@@ -357,9 +357,4 @@ static inline bool xen_arch_need_swiotlb(struct device *dev, return false; } -static inline unsigned long xen_get_swiotlb_free_pages (unsigned int order) -{ -return __get_free_pages (__GFP_NOWARN, order); -} -#endif /* _ASM_X86_XEN_PAGE_H */
arch/x86/kernel/pci-dma.c +9 -10
@@ -72,15 +72,12 @@ static inline void __init pci_swiotlb_detect(void)#endif /* CONFIG_SWIOTLB */ #ifdef CONFIG_SWIOTLB_XEN -static bool xen_swiotlb; -static void __init pci_xen_swiotlb_init (void ) {if (!xen_initial_domain () && !x86_swiotlb_enable)return ; x86_swiotlb_enable = true; - xen_swiotlb = true; -xen_swiotlb_init_early (); +swiotlb_init_remap (true, x86_swiotlb_flags, xen_swiotlb_fixup); dma_ops = &xen_swiotlb_dma_ops;if (IS_ENABLED (CONFIG_PCI ))pci_request_acs ();
@@ -88,14 +85,16 @@ static void __init pci_xen_swiotlb_init(void)int pci_xen_swiotlb_init_late (void ) { -int rc; - -if (xen_swiotlb) +if (dma_ops = &xen_swiotlb_dma_ops)return 0 ; - rc =xen_swiotlb_init (); -if (rc) -return rc; +/* we can work with the default swiotlb */ +if (!io_tlb_default_mem.nslabs) { +int rc =swiotlb_init_late (swiotlb_size_or_default (), +GFP_KERNEL , xen_swiotlb_fixup); +if (rc <0 ) +return rc; + }/* XXX: this switches the dma ops under live devices! */ dma_ops = &xen_swiotlb_dma_ops;
drivers/xen/swiotlb-xen.c +1 -127
140 lines not on this page · raw message
include/xen/arm/page.h +0 -1
@@ -115,6 +115,5 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)bool xen_arch_need_swiotlb (struct device *dev,phys_addr_t phys,dma_addr_t dev_addr); -unsigned long xen_get_swiotlb_free_pages (unsigned int order);#endif /* _ASM_ARM_XEN_PAGE_H */
include/xen/swiotlb-xen.h +6 -2
@@ -10,8 +10,12 @@ void xen_dma_sync_for_cpu(struct device *dev, dma_addr_t handle,void xen_dma_sync_for_device (struct device *dev,dma_addr_t handle,size_t size,enum dma_data_direction dir); -int xen_swiotlb_init (void ); -void __init xen_swiotlb_init_early (void ); +#ifdef CONFIG_SWIOTLB_XEN +int xen_swiotlb_fixup (void *buf,unsigned long nslabs); +#else +#define xen_swiotlb_fixup NULL +#endif +extern const struct dma_map_ops xen_swiotlb_dma_ops;#endif /* __LINUX_SWIOTLB_XEN_H */
Signature · 1 line
2.30.2
Boris Ostrovsky
reviewerRe: [PATCH 13/15] swiotlb: merge swiotlb-xen initialization into swiotlb
arch/x86/kernel/pci-dma.c static inline void __init pci_swiotlb_detect(void) · line 80
Quoted 9 lines · Christoph Hellwig
arch/x86/kernel/pci-dma.c +1
-3-static void __init pci_xen_swiotlb_init (void ) {if (!xen_initial_domain () && !x86_swiotlb_enable)return ; x86_swiotlb_enable = true; - xen_swiotlb = true; -xen_swiotlb_init_early (); +swiotlb_init_remap (true, x86_swiotlb_flags, xen_swiotlb_fixup);
I think we need to have SWIOTLB_ANY set in x86_swiotlb_flags here.
Quoted 10 lines
dma_ops = &xen_swiotlb_dma_ops; if (IS_ENABLED(CONFIG_PCI)) pci_request_acs();arch/x86/kernel/pci-dma.c +0
-3@@ -88,14 +85,16 @@ static void __init pci_xen_swiotlb_init(void)int pci_xen_swiotlb_init_late (void ) { -int rc; - -if (xen_swiotlb)
arch/x86/kernel/pci-dma.c static void __init pci_xen_swiotlb_init(void) · line 94
Quoted 10 lines
arch/x86/kernel/pci-dma.c +5
-3+if (dma_ops = &xen_swiotlb_dma_ops)return 0 ; - rc =xen_swiotlb_init (); -if (rc) -return rc; +/* we can work with the default swiotlb */ +if (!io_tlb_default_mem.nslabs) { +int rc =swiotlb_init_late (swiotlb_size_or_default (), +GFP_KERNEL , xen_swiotlb_fixup);
This may be comment for previous patch but looking at swiotlb_init_late():
retry:
order = get_order(nslabs << IO_TLB_SHIFT); nslabs = SLABS_PER_PAGE << order; bytes = nslabs << IO_TLB_SHIFT;
while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) { vstart = (void *)__get_free_pages(gfp_mask | __GFP_NOWARN, order);
if (vstart)
break;
order--;
}
if (!vstart)
return -ENOMEM;
if (remap)
rc = remap(vstart, nslabs);
if (rc) {
free_pages((unsigned long)vstart, order);
/* Min is 2MB */
if (nslabs <= 1024)
return rc;
nslabs = max(1024UL, ALIGN(nslabs >> 1, IO_TLB_SEGSIZE)); goto retry;
}
if (order != get_order(bytes)) {
pr_warn("only able to allocate %ld MB\n", (PAGE_SIZE << order) >> 20); nslabs = SLABS_PER_PAGE << order; <=== }
rc = swiotlb_late_init_with_tbl(vstart, nslabs);
Notice that we don't do remap() after final update to nslabs. We should.
-boris
Christoph Hellwig
Reviewed-by Stefano StabelliniRe: [PATCH 13/15] swiotlb: merge swiotlb-xen initialization into swiotlb
Quoted 4 lines · Boris Ostrovsky
Review
Quoted 1 line
(quoted diff) +1
-0+ swiotlb_init_remap(true, x86_swiotlb_flags, xen_swiotlb_fixup);I think we need to have
SWIOTLB_ANYset inx86_swiotlb_flagshere.
Yes.
Quoted 1 line
Notice that we don't do
remap()after final update to nslabs. We should.
Indeed. I've pushed the fixed patches to the git tree and attached the patches 12, 13 and 14 in case that is easier:
From 6d72b98620281984ae778659cedeb369e82af8d8 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <[email protected]>
Date: Mon, 14 Mar 2022 08:02:57 +0100
Subject: swiotlb: provide swiotlb_init variants that remap the buffer
To shared more code between swiotlb and xen-swiotlb, offer a swiotlb_init_remap interface and add a remap callback to swiotlb_init_late that will allow Xen to remap the buffer the buffer without duplicating much of the logic.
--- arch/x86/pci/sta2x11-fixup.c | 2 +- include/linux/swiotlb.h | 5 ++++- kernel/dma/swiotlb.c | 36 +++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 5 deletions(-)
arch/x86/pci/sta2x11-fixup.c +1 -1
@@ -57,7 +57,7 @@ static void sta2x11_new_instance(struct pci_dev *pdev)int size =STA2X11_SWIOTLB_SIZE ;/* First instance: register your own swiotlb area */ dev_info (&pdev->dev,"Using SWIOTLB (size %i)\n" , size); -if (swiotlb_init_late (size,GFP_DMA )) +if (swiotlb_init_late (size,GFP_DMA ,NULL ))dev_emerg (&pdev->dev,"init swiotlb failed\n" ); }list_add (&instance->list, &sta2x11_instance_list);
include/linux/swiotlb.h +4 -1
@@ -36,8 +36,11 @@ struct scatterlist;int swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,unsigned int flags);unsigned long swiotlb_size_or_default (void ); +void __init swiotlb_init_remap (bool addressing_limit,unsigned int flags, +int (*remap)(void *tlb,unsigned long nslabs)); +int swiotlb_init_late (size_t size,gfp_t gfp_mask, +int (*remap)(void *tlb,unsigned long nslabs));extern int swiotlb_late_init_with_tbl (char *tlb,unsigned long nslabs); -int swiotlb_init_late (size_t size,gfp_t gfp_mask);extern void __init swiotlb_update_mem_attributes (void ); phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t phys,
kernel/dma/swiotlb.c +33 -3
@@ -256,9 +256,11 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs,* Statically reserve bounce buffer space and initialize bounce buffer data * structures for the software IO TLB used to implement the DMA API. */ -void __init swiotlb_init (bool addressing_limit,unsigned int flags) +void __init swiotlb_init_remap (bool addressing_limit,unsigned int flags, +int (*remap)(void *tlb,unsigned long nslabs)) { -size_t bytes =PAGE_ALIGN (default_nslabs <<IO_TLB_SHIFT ); +unsigned long nslabs = default_nslabs; +size_t bytes;void *tlb;if (!addressing_limit && !swiotlb_force_bounce)
@@ -271,12 +273,23 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)* allow to pick a location everywhere for hypervisors with guest * memory encryption. */ +retry: + bytes =PAGE_ALIGN (default_nslabs <<IO_TLB_SHIFT );if (flags &SWIOTLB_ANY ) tlb =memblock_alloc (bytes,PAGE_SIZE );else tlb =memblock_alloc_low (bytes,PAGE_SIZE );if (!tlb) goto fail; +if (remap &&remap (tlb, nslabs) <0 ) { +memblock_free (tlb,PAGE_ALIGN (bytes)); + +if (nslabs <=IO_TLB_MIN_SLABS ) +panic ("%s: Failed to remap %zu bytes\n" , + __func__, bytes); + nslabs =max (1024UL ,ALIGN (nslabs >>1 ,IO_TLB_SEGSIZE )); + goto retry; + }if (swiotlb_init_with_tbl (tlb, default_nslabs, flags)) goto fail_free_mem;return ;
@@ -287,12 +300,18 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)pr_warn ("Cannot allocate buffer" ); } +void __init swiotlb_init (bool addressing_limit,unsigned int flags) +{ +return swiotlb_init_remap (addressing_limit, flags,NULL ); +} +/* * Systems with larger DMA zones (those that don't support ISA) can * initialize the swiotlb later using the slab allocator if needed. * This should be just like above, but with some error catching. */ -int swiotlb_init_late (size_t size,gfp_t gfp_mask) +int swiotlb_init_late (size_t size,gfp_t gfp_mask, +int (*remap)(void *tlb,unsigned long nslabs)) {unsigned long nslabs =ALIGN (size >>IO_TLB_SHIFT ,IO_TLB_SEGSIZE );unsigned long bytes;
@@ -303,6 +322,7 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask)if (swiotlb_force_disable)return 0 ; +retry: order =get_order (nslabs <<IO_TLB_SHIFT ); nslabs =SLABS_PER_PAGE << order; bytes = nslabs <<IO_TLB_SHIFT ;
@@ -323,6 +343,16 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask) (PAGE_SIZE << order) >> 20); nslabs =SLABS_PER_PAGE << order; } +if (remap) + rc =remap (vstart, nslabs); +if (rc) { +free_pages ((unsigned long )vstart, order); + +if (IO_TLB_MIN_SLABS <=1024 ) +return rc; + nslabs =max (1024UL ,ALIGN (nslabs >>1 ,IO_TLB_SEGSIZE )); + goto retry; + } rc =swiotlb_late_init_with_tbl (vstart, nslabs);if (rc)free_pages ((unsigned long )vstart, order);
Signature · 1 line
2.30.2
From abfe30ed0a7cd3ca97824d9062a655215ddee7f2 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <[email protected]>
Date: Mon, 14 Mar 2022 07:58:45 +0100
Subject: swiotlb: merge swiotlb-xen initialization into swiotlb
Reuse the generic swiotlb initialization for xen-swiotlb. For ARM/ARM64 this works trivially, while for x86 xen_swiotlb_fixup needs to be passed as the remap argument to swiotlb_init_remap/swiotlb_init_late.
--- arch/arm/xen/mm.c | 21 +++--- arch/x86/include/asm/xen/page.h | 5 -- arch/x86/kernel/pci-dma.c | 20 ++--- drivers/xen/swiotlb-xen.c | 128 +------------------------------- include/xen/arm/page.h | 1 - include/xen/swiotlb-xen.h | 8 +- 6 files changed, 28 insertions(+), 155 deletions(-)
arch/arm/xen/mm.c +11 -10
@@ -23,22 +23,20 @@#include <asm/xen/hypercall.h> #include <asm/xen/interface.h> -unsigned long xen_get_swiotlb_free_pages (unsigned int order) +static gfp_t xen_swiotlb_gfp (void ) {phys_addr_t base; -gfp_t flags = __GFP_NOWARN|__GFP_KSWAPD_RECLAIM;u64 i;for_each_mem_range (i, &base,NULL ) {if (base < (phys_addr_t )0xffffffff ) {if (IS_ENABLED (CONFIG_ZONE_DMA32 )) - flags |= __GFP_DMA32; -else - flags |= __GFP_DMA; -break ; +return __GFP_DMA32; +return __GFP_DMA; } } -return __get_free_pages (flags, order); + +return GFP_KERNEL ; }static bool hypercall_cflush = false;
@@ -140,10 +138,13 @@ static int __init xen_mm_init(void)if (!xen_swiotlb_detect ())return 0 ; - rc =xen_swiotlb_init ();/* we can work with the default swiotlb */ -if (rc <0 && rc != -EEXIST ) -return rc; +if (!io_tlb_default_mem.nslabs) { + rc =swiotlb_init_late (swiotlb_size_or_default (), +xen_swiotlb_gfp (),NULL ); +if (rc <0 ) +return rc; + } cflush.op =0 ; cflush.a.dev_bus_addr =0 ;
arch/x86/include/asm/xen/page.h +0 -5
@@ -357,9 +357,4 @@ static inline bool xen_arch_need_swiotlb(struct device *dev, return false; } -static inline unsigned long xen_get_swiotlb_free_pages (unsigned int order) -{ -return __get_free_pages (__GFP_NOWARN, order); -} -#endif /* _ASM_X86_XEN_PAGE_H */
arch/x86/kernel/pci-dma.c +10 -10
@@ -72,15 +72,13 @@ static inline void __init pci_swiotlb_detect(void)#endif /* CONFIG_SWIOTLB */ #ifdef CONFIG_SWIOTLB_XEN -static bool xen_swiotlb; -static void __init pci_xen_swiotlb_init (void ) {if (!xen_initial_domain () && !x86_swiotlb_enable)return ; x86_swiotlb_enable = true; - xen_swiotlb = true; -xen_swiotlb_init_early (); + x86_swiotlb_flags |=SWIOTLB_ANY ; +swiotlb_init_remap (true, x86_swiotlb_flags, xen_swiotlb_fixup); dma_ops = &xen_swiotlb_dma_ops;if (IS_ENABLED (CONFIG_PCI ))pci_request_acs ();
@@ -88,14 +86,16 @@ static void __init pci_xen_swiotlb_init(void)int pci_xen_swiotlb_init_late (void ) { -int rc; - -if (xen_swiotlb) +if (dma_ops == &xen_swiotlb_dma_ops)return 0 ; - rc =xen_swiotlb_init (); -if (rc) -return rc; +/* we can work with the default swiotlb */ +if (!io_tlb_default_mem.nslabs) { +int rc =swiotlb_init_late (swiotlb_size_or_default (), +GFP_KERNEL , xen_swiotlb_fixup); +if (rc <0 ) +return rc; + }/* XXX: this switches the dma ops under live devices! */ dma_ops = &xen_swiotlb_dma_ops;
drivers/xen/swiotlb-xen.c +1 -127
140 lines not on this page · raw message
include/xen/arm/page.h +0 -1
@@ -115,6 +115,5 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)bool xen_arch_need_swiotlb (struct device *dev,phys_addr_t phys,dma_addr_t dev_addr); -unsigned long xen_get_swiotlb_free_pages (unsigned int order);#endif /* _ASM_ARM_XEN_PAGE_H */
include/xen/swiotlb-xen.h +6 -2
@@ -10,8 +10,12 @@ void xen_dma_sync_for_cpu(struct device *dev, dma_addr_t handle,void xen_dma_sync_for_device (struct device *dev,dma_addr_t handle,size_t size,enum dma_data_direction dir); -int xen_swiotlb_init (void ); -void __init xen_swiotlb_init_early (void ); +#ifdef CONFIG_SWIOTLB_XEN +int xen_swiotlb_fixup (void *buf,unsigned long nslabs); +#else +#define xen_swiotlb_fixup NULL +#endif +extern const struct dma_map_ops xen_swiotlb_dma_ops;#endif /* __LINUX_SWIOTLB_XEN_H */
Signature · 1 line
2.30.2
From 2e7a39f16760d3c0076691a3358d3c7499805687 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <[email protected]>
Date: Tue, 15 Mar 2022 07:41:04 +0100
Subject: swiotlb: remove swiotlb_init_with_tbl and swiotlb_init_late_with_tbl
No users left.
--- include/linux/swiotlb.h | 2 -- kernel/dma/swiotlb.c | 77 +++++++++++------------------------------ 2 files changed, 20 insertions(+), 59 deletions(-)
include/linux/swiotlb.h +0 -2
@@ -34,13 +34,11 @@ struct scatterlist;/* default to 64MB */ #define IO_TLB_DEFAULT_SIZE (64UL<<20) -int swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,unsigned int flags);unsigned long swiotlb_size_or_default (void );void __init swiotlb_init_remap (bool addressing_limit,unsigned int flags,int (*remap)(void *tlb,unsigned long nslabs));int swiotlb_init_late (size_t size,gfp_t gfp_mask,int (*remap)(void *tlb,unsigned long nslabs)); -extern int swiotlb_late_init_with_tbl (char *tlb,unsigned long nslabs);extern void __init swiotlb_update_mem_attributes (void ); phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t phys,
kernel/dma/swiotlb.c +20 -57
120 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH 13/15] swiotlb: merge swiotlb-xen initialization into swiotlb
In reply to Christoph HellwigQuoted 5 lines · Christoph Hellwig
Reuse the generic swiotlb initialization for xen-swiotlb. For ARM/ARM64 this works trivially, while for x86
xen_swiotlb_fixupneeds to be passed as the remap argument to swiotlb_init_remap/swiotlb_init_late.Signed-off-by Christoph Hellwig <[email protected]>
For arch/arm/xen and drivers/xen/swiotlb-xen.c
PATCH 14/15 swiotlb: remove swiotlb_init_with_tbl and swiotlb_init_late_with_tbl
In reply to Christoph HellwigNo users left.
--- include/linux/swiotlb.h | 2 - kernel/dma/swiotlb.c | 85 +++++++++++++++-------------------------- 2 files changed, 30 insertions(+), 57 deletions(-)
include/linux/swiotlb.h +0 -2
@@ -34,13 +34,11 @@ struct scatterlist;/* default to 64MB */ #define IO_TLB_DEFAULT_SIZE (64UL<<20) -int swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,unsigned int flags);unsigned long swiotlb_size_or_default (void );void __init swiotlb_init_remap (bool addressing_limit,unsigned int flags,int (*remap)(void *tlb,unsigned long nslabs));int swiotlb_init_late (size_t size,gfp_t gfp_mask,int (*remap)(void *tlb,unsigned long nslabs)); -extern int swiotlb_late_init_with_tbl (char *tlb,unsigned long nslabs);extern void __init swiotlb_update_mem_attributes (void ); phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t phys,
kernel/dma/swiotlb.c +30 -55
130 lines not on this page · raw message
Signature · 1 line
2.30.2
Boris Ostrovsky
reviewerRe: [PATCH 14/15] swiotlb: remove swiotlb_init_with_tbl and swiotlb_init_late_with_tbl
Quoted 31 lines · Christoph Hellwig
kernel/dma/swiotlb.c +5
-14@@ -314,6 +293,7 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)int swiotlb_init_late (size_t size,gfp_t gfp_mask,int (*remap)(void *tlb,unsigned long nslabs)) { +struct io_tlb_mem *mem = &io_tlb_default_mem;unsigned long nslabs =ALIGN (size >>IO_TLB_SHIFT ,IO_TLB_SEGSIZE );unsigned long bytes;unsigned char *vstart =NULL ;@@ -355,33 +335,28 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask, (PAGE_SIZE << order) >> 20); nslabs =SLABS_PER_PAGE << order; } - rc =swiotlb_late_init_with_tbl (vstart, nslabs); -if (rc) -free_pages ((unsigned long )vstart, order); - -return rc; -} - -int -swiotlb_late_init_with_tbl (char *tlb,unsigned long nslabs) -{ -struct io_tlb_mem *mem = &io_tlb_default_mem; -unsigned long bytes = nslabs <<IO_TLB_SHIFT ; -if (swiotlb_force_disable) -return 0 ; +if (remap) + rc =remap (vstart, nslabs); +if (rc) { +free_pages ((unsigned long )vstart, order);
kernel/dma/swiotlb.c int swiotlb_init_late(size_t size, gfp_t gfp_mask, · line 349
Quoted 10 lines
kernel/dma/swiotlb.c +6
-3-/* protect against double initialization */ -if (WARN_ON_ONCE (mem->nslabs)) -return -ENOMEM ; +/* Min is 2MB */ +if (nslabs <=1024 ) +return rc; + nslabs =max (1024UL ,ALIGN (nslabs >>1 ,IO_TLB_SEGSIZE )); + goto retry; + }
We now end up with two attempts to remap. I think this second one is what we want since it solves the problem I pointed in previous patch.
-boris
PATCH 15/15 x86: remove cruft from <asm/dma-mapping.h>
In reply to Christoph Hellwig<asm/dma-mapping.h> gets pulled in by all drivers using the DMA API. Remove x86 internal variables and unnecessary includes from it.
--- arch/x86/include/asm/dma-mapping.h | 11 ----------- arch/x86/include/asm/iommu.h | 2 ++ 2 files changed, 2 insertions(+), 11 deletions(-)
arch/x86/include/asm/dma-mapping.h +0 -11
@@ -2,17 +2,6 @@#ifndef _ASM_X86_DMA_MAPPING_H#define _ASM_X86_DMA_MAPPING_H -/* -* IOMMU interface. See Documentation/core-api/dma-api-howto.rst and -* Documentation/core-api/dma-api.rst for documentation. -*/ - -#include <linux/scatterlist.h> -#include <asm/io.h> - -extern int iommu_merge; -extern int panic_on_overflow; -extern const struct dma_map_ops *dma_ops;static inline const struct dma_map_ops *get_arch_dma_ops (struct bus_type *bus)
arch/x86/include/asm/iommu.h +2 -0
@@ -8,6 +8,8 @@extern int force_iommu, no_iommu;extern int iommu_detected; +extern int iommu_merge; +extern int panic_on_overflow;#ifdef CONFIG_SWIOTLB extern bool x86_swiotlb_enable;
Signature · 1 line
2.30.2