Skip to contentSkip to conversation

x86/pci-dma: add "any" keyword to swiotlb= kernel parameter

RFC PATCH In review Aakarsh Jain 4 participants 7 messages Jul 8 – Aug 6

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 x86/pci-dma: add "any" keyword to swiotlb= kernel parameter

CoCo guests (AMD SEV-SNP, Intel TDX) require large swiotlb pools for streaming DMA workloads such as high-speed NIC and AI accelerator inference. The existing swiotlb pool allocator restricts placement to low memory (below 4GB by default), capping usable pool size at ~1GB even when a larger pool is requested via swiotlb=<nslabs>.

The SWIOTLB_ANY flag already exists to lift this restriction, and swiotlb_init_remap() already handles it correctly via the flags parameter (see CONFIG_SWIOTLB_DYNAMIC path: io_tlb_default_mem.phys_limit is set to virt_to_phys(high_memory-1) when SWIOTLB_ANY is set).

However, there is no way to set SWIOTLB_ANY from the command line. The only existing mechanism was via arch-specific code (e.g. powerpc SVM sets SWIOTLB_ANY in pci_iommu_init). x86 CoCo guests have no such path.

After Aneesh series ("dma-mapping: Track shared DMA state through
direct, pool and swiotlb paths", https://patchwork.kernel.org/project/linux-arm-kernel/cover/[email protected]/)
removes SWIOTLB_FORCE, x86 pci_swiotlb_detect() leaves x86_swiotlb_flags = 0 for
CoCo guests. The pool falls back to low memory and caps at ~1GB:

Without "any": pool at 0x35a9c000 (~900MB, below 4GB boundary)
With "any": pool at 0x1df9c00000 (~120GB, anywhere in RAM)
[Tested on AMD SEV-SNP guest, swiotlb=4194304]

Add "any" as a new keyword to the swiotlb= kernel parameter. This is an explicit, opt-in mechanism that sets SWIOTLB_ANY for the default pool at boot time, without touching any arch-specific code.

Devices with 32-bit DMA masks are not affected, they still use the normal low-memory bounce buffer path. The "any" option is only meaningful for workloads where all active DMA devices have 64-bit masks.

---
 Documentation/admin-guide/kernel-parameters.txt | 5 ++++-
 kernel/dma/swiotlb.c                            | 5 +++++
 2 files changed, 9 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +4 -1
index b5493a7f8f22..8a1fccbd9b25 100644
@@ -7477,7 +7477,7 @@ Kernel parameters
 			Execution Facility on pSeries.
 
 	swiotlb=	[ARM,PPC,MIPS,X86,S390,EARLY]
-			Format: { <int> [,<int>] | force | noforce }
+			Format: { <int> [,<int>] | force | noforce | any}
 			<int> -- Number of I/O TLB slabs
 			<int> -- Second integer after comma. Number of swiotlb
 				 areas with their own lock. Will be rounded up
@@ -7485,6 +7485,9 @@ Kernel parameters
 			force -- force using of bounce buffers even if they
 			         wouldn't be automatically used by the kernel
 			noforce -- Never use bounce buffers (for debugging)
+			any --  Allow the swiotlb pool to be placed anywhere in
+				system RAM, lifting the default low-memory (4GB)
+				restriction.
 
 	switches=	[HW,M68k,EARLY]
 
kernel/dma/swiotlb.c +5 -0
index 1abd3e6146f4..34773ae7c770 100644
@@ -80,6 +80,7 @@ struct io_tlb_slot {
 
 static bool swiotlb_force_bounce;
 static bool swiotlb_force_disable;
+static unsigned int swiotlb_param_flags __initdata;
 
 #ifdef CONFIG_SWIOTLB_DYNAMIC
 
@@ -198,6 +199,8 @@ setup_io_tlb_npages(char *str)
 		swiotlb_force_bounce = true;
 	else if (!strcmp(str, "noforce"))
 		swiotlb_force_disable = true;
+	else if (!strcmp(str, "any"))
+		swiotlb_param_flags |= SWIOTLB_ANY;
 
 	return 0;
 }
@@ -445,6 +448,8 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask,
 
 	io_tlb_default_mem.force_bounce = swiotlb_force_bounce;
 
+	flags |= swiotlb_param_flags;
+
 #ifdef CONFIG_SWIOTLB_DYNAMIC
 	if (!remap)
 		io_tlb_default_mem.can_grow = true;
Signature · 1 line
2.43.0
#1 lore raw
Quoted 83 lines · Aakarsh Jain

CoCo guests (AMD SEV-SNP, Intel TDX) require large swiotlb pools for streaming DMA workloads such as high-speed NIC and AI accelerator inference. The existing swiotlb pool allocator restricts placement to low memory (below 4GB by default), capping usable pool size at ~1GB even when a larger pool is requested via swiotlb=<nslabs>.

The SWIOTLB_ANY flag already exists to lift this restriction, and swiotlb_init_remap() already handles it correctly via the flags parameter (see CONFIG_SWIOTLB_DYNAMIC path: io_tlb_default_mem.phys_limit is set to virt_to_phys(high_memory-1) when SWIOTLB_ANY is set).

However, there is no way to set SWIOTLB_ANY from the command line. The only existing mechanism was via arch-specific code (e.g. powerpc SVM sets SWIOTLB_ANY in pci_iommu_init). x86 CoCo guests have no such path.

After Aneesh series ("dma-mapping: Track shared DMA state through
direct, pool and swiotlb paths", https://patchwork.kernel.org/project/linux-arm-kernel/cover/[email protected]/)
removes SWIOTLB_FORCE, x86 pci_swiotlb_detect() leaves x86_swiotlb_flags = 0 for
CoCo guests. The pool falls back to low memory and caps at ~1GB:

Without "any": pool at 0x35a9c000 (~900MB, below 4GB boundary)
With "any": pool at 0x1df9c00000 (~120GB, anywhere in RAM)
[Tested on AMD SEV-SNP guest, swiotlb=4194304]

Add "any" as a new keyword to the swiotlb= kernel parameter. This is an explicit, opt-in mechanism that sets SWIOTLB_ANY for the default pool at boot time, without touching any arch-specific code.

Devices with 32-bit DMA masks are not affected, they still use the normal low-memory bounce buffer path. The "any" option is only meaningful for workloads where all active DMA devices have 64-bit masks.

---
  Documentation/admin-guide/kernel-parameters.txt | 5 ++++-
  kernel/dma/swiotlb.c                            | 5 +++++
  2 files changed, 9 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +4 -1
index b5493a7f8f22..8a1fccbd9b25 100644
@@ -7477,7 +7477,7 @@ Kernel parameters
  			Execution Facility on pSeries.
 
  	swiotlb=	[ARM,PPC,MIPS,X86,S390,EARLY]
-			Format: { <int> [,<int>] | force | noforce }
+			Format: { <int> [,<int>] | force | noforce | any}
  			<int> -- Number of I/O TLB slabs
  			<int> -- Second integer after comma. Number of swiotlb
  				 areas with their own lock. Will be rounded up
@@ -7485,6 +7485,9 @@ Kernel parameters
  			force -- force using of bounce buffers even if they
  			         wouldn't be automatically used by the kernel
  			noforce -- Never use bounce buffers (for debugging)
+			any --  Allow the swiotlb pool to be placed anywhere in
+				system RAM, lifting the default low-memory (4GB)
+				restriction.
 
  	switches=	[HW,M68k,EARLY]
 
kernel/dma/swiotlb.c +3 -0
index 1abd3e6146f4..34773ae7c770 100644
@@ -80,6 +80,7 @@ struct io_tlb_slot {
 
  static bool swiotlb_force_bounce;
  static bool swiotlb_force_disable;
+static unsigned int swiotlb_param_flags __initdata;
 
  #ifdef CONFIG_SWIOTLB_DYNAMIC
 
@@ -198,6 +199,8 @@ setup_io_tlb_npages(char *str)
  		swiotlb_force_bounce = true;
  	else if (!strcmp(str, "noforce"))
  		swiotlb_force_disable = true;
+	else if (!strcmp(str, "any"))
+		swiotlb_param_flags |= SWIOTLB_ANY;
 
  	return 0;
  }

kernel/dma/swiotlb.c int swiotlb_init_late(size_t size, gfp_t gfp_mask, · line 455

Quoted 8 lines
kernel/dma/swiotlb.c +2 -0
@@ -445,6 +448,8 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask,
 
  	io_tlb_default_mem.force_bounce = swiotlb_force_bounce;
 
+	flags |= swiotlb_param_flags;
+
  #ifdef CONFIG_SWIOTLB_DYNAMIC
  	if (!remap)
  		io_tlb_default_mem.can_grow = true;

One correction to the commit message:

The testing was performed with:

swiotlb=4194304,any

and not:

swiotlb=4194304

The larger swiotlb pool allocation above the 4GB boundary was observed with the "any" option enabled.

From kernel dmesg logs:

root@ubuntu:/home/ubuntu# dmesg | grep -i sev
[   21.191917] Memory Encryption Features active: AMD SEV SEV-ES SEV-SNP
[   21.192883] SEV: Status: SEV SEV-ES SEV-SNP
[   21.401897] SEV: APIC: wakeup_secondary_cpu() replaced with wakeup_cpu_via_vmgexit()
[   22.117267] SEV: Using SNP CPUID table, 28 entries present.
[   22.117884] SEV: SNP running at VMPL0.
[   24.164260] SEV: SNP guest platform devices initialized.
[   28.815142] systemd[1]: Detected confidential virtualization sev-snp.
[   30.063831] sev-guest sev-guest: Initialized SEV guest driver (using VMPCK0 communication key)
root@ubuntu:/home/ubuntu# dmesg | grep -i "IO TLB"
[    6.743607] software IO TLB: area num 4.
[   24.164169] software IO TLB: mapped [mem 0x0000001df9c00000-0x0000001ff9c00000] (8192MB)
[   24.331266] software IO TLB: Memory encryption is active and system is using DMA bounce buffers

Thanks,
Aakarsh

maintainer
#2 lore raw
In reply to Aakarsh Jain
Quoted 15 lines · Aakarsh Jain

CoCo guests (AMD SEV-SNP, Intel TDX) require large swiotlb pools for streaming DMA workloads such as high-speed NIC and AI accelerator inference. The existing swiotlb pool allocator restricts placement to low memory (below 4GB by default), capping usable pool size at ~1GB even when a larger pool is requested via swiotlb=<nslabs>.

The SWIOTLB_ANY flag already exists to lift this restriction, and swiotlb_init_remap() already handles it correctly via the flags parameter (see CONFIG_SWIOTLB_DYNAMIC path: io_tlb_default_mem.phys_limit is set to virt_to_phys(high_memory-1) when SWIOTLB_ANY is set).

However, there is no way to set SWIOTLB_ANY from the command line. The only existing mechanism was via arch-specific code (e.g. powerpc SVM sets SWIOTLB_ANY in pci_iommu_init). x86 CoCo guests have no such path.

Quoted 8 lines

After Aneesh series ("dma-mapping: Track shared DMA state through
direct, pool and swiotlb paths", https://patchwork.kernel.org/project/linux-arm-kernel/cover/[email protected]/)
removes SWIOTLB_FORCE, x86 pci_swiotlb_detect() leaves x86_swiotlb_flags = 0 for
CoCo guests. The pool falls back to low memory and caps at ~1GB:

Without "any": pool at 0x35a9c000 (~900MB, below 4GB boundary)
With "any": pool at 0x1df9c00000 (~120GB, anywhere in RAM)
[Tested on AMD SEV-SNP guest, swiotlb=4194304]

Do we really need a new option for that? Doesn't this simply mean that x86_swiotlb_flags should be always set to "any" for CoCo guests?

Quoted 59 lines

Add "any" as a new keyword to the swiotlb= kernel parameter. This is an explicit, opt-in mechanism that sets SWIOTLB_ANY for the default pool at boot time, without touching any arch-specific code.

Devices with 32-bit DMA masks are not affected, they still use the normal low-memory bounce buffer path. The "any" option is only meaningful for workloads where all active DMA devices have 64-bit masks.

---
 Documentation/admin-guide/kernel-parameters.txt | 5 ++++-
 kernel/dma/swiotlb.c                            | 5 +++++
 2 files changed, 9 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +4 -1
index b5493a7f8f22..8a1fccbd9b25 100644
@@ -7477,7 +7477,7 @@ Kernel parameters
 			Execution Facility on pSeries.
 
 	swiotlb=	[ARM,PPC,MIPS,X86,S390,EARLY]
-			Format: { <int> [,<int>] | force | noforce }
+			Format: { <int> [,<int>] | force | noforce | any}
 			<int> -- Number of I/O TLB slabs
 			<int> -- Second integer after comma. Number of swiotlb
 				 areas with their own lock. Will be rounded up
@@ -7485,6 +7485,9 @@ Kernel parameters
 			force -- force using of bounce buffers even if they
 			         wouldn't be automatically used by the kernel
 			noforce -- Never use bounce buffers (for debugging)
+			any --  Allow the swiotlb pool to be placed anywhere in
+				system RAM, lifting the default low-memory (4GB)
+				restriction.
 
 	switches=	[HW,M68k,EARLY]
 
kernel/dma/swiotlb.c +3 -0
index 1abd3e6146f4..34773ae7c770 100644
@@ -80,6 +80,7 @@ struct io_tlb_slot {
 
 static bool swiotlb_force_bounce;
 static bool swiotlb_force_disable;
+static unsigned int swiotlb_param_flags __initdata;
 
 #ifdef CONFIG_SWIOTLB_DYNAMIC
 
@@ -198,6 +199,8 @@ setup_io_tlb_npages(char *str)
 		swiotlb_force_bounce = true;
 	else if (!strcmp(str, "noforce"))
 		swiotlb_force_disable = true;
+	else if (!strcmp(str, "any"))
+		swiotlb_param_flags |= SWIOTLB_ANY;
 
 	return 0;
 }

kernel/dma/swiotlb.c int swiotlb_init_late(size_t size, gfp_t gfp_mask, · line 455

Quoted 8 lines
kernel/dma/swiotlb.c +2 -0
@@ -445,6 +448,8 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask,
 
 	io_tlb_default_mem.force_bounce = swiotlb_force_bounce;
 
+	flags |= swiotlb_param_flags;
+
 #ifdef CONFIG_SWIOTLB_DYNAMIC
 	if (!remap)
 		io_tlb_default_mem.can_grow = true;

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
reviewer
#3 lore raw
In reply to Aakarsh Jain
Quoted 11 lines · Aakarsh Jain

CoCo guests (AMD SEV-SNP, Intel TDX) require large swiotlb pools for streaming DMA workloads such as high-speed NIC and AI accelerator inference. The existing swiotlb pool allocator restricts placement to low memory (below 4GB by default), capping usable pool size at ~1GB even when a larger pool is requested via swiotlb=<nslabs>.

The SWIOTLB_ANY flag already exists to lift this restriction, and swiotlb_init_remap() already handles it correctly via the flags parameter (see CONFIG_SWIOTLB_DYNAMIC path: io_tlb_default_mem.phys_limit is set to virt_to_phys(high_memory-1) when SWIOTLB_ANY is set).

Quoted 8 lines

However, there is no way to set SWIOTLB_ANY from the command line. The only existing mechanism was via arch-specific code (e.g. powerpc SVM sets SWIOTLB_ANY in pci_iommu_init). x86 CoCo guests have no such path.

After Aneesh series ("dma-mapping: Track shared DMA state through
direct, pool and swiotlb paths", https://patchwork.kernel.org/project/linux-arm-kernel/cover/[email protected]/)
removes SWIOTLB_FORCE, x86 pci_swiotlb_detect() leaves x86_swiotlb_flags = 0 for
CoCo guests. The pool falls back to low memory and caps at ~1GB:

This is entirely irrelevant; SWIOTLB_FORCE has no impact on allocation behaviour anyway. x86 wasn't passing SWIOTLB_ANY before and it still isn't, although there doesn't seem to be any particular reason why the well-reviewed patch for that hasn't been picked up:

https://lore.kernel.org/lkml/[email protected]/

Quoted 11 lines

Without "any": pool at 0x35a9c000 (~900MB, below 4GB boundary)
With "any": pool at 0x1df9c00000 (~120GB, anywhere in RAM)
[Tested on AMD SEV-SNP guest, swiotlb=4194304]

Add "any" as a new keyword to the swiotlb= kernel parameter. This is an explicit, opt-in mechanism that sets SWIOTLB_ANY for the default pool at boot time, without touching any arch-specific code.

Devices with 32-bit DMA masks are not affected, they still use the normal low-memory bounce buffer path. The "any" option is only meaningful for workloads where all active DMA devices have 64-bit masks.

That doesn't make any sense - if a user passes this option then any devices with DMA addressing limitations definitely *are* going to be affected, and quite likely broken altogether. If anything, the documentation should be even more explicit that this should only be used if you do know for sure that no devices have DMA addressing limitations.

As a general SWIOTLB-behaviour-debugging option for orthogonality with force/noforce I'm not opposed to the idea, but it is definitely not something that real CoCo use-cases should rely on - if the general consensus if that CoCo environments want a different setup by default then the arch/CoCo code should be taking care of that.

Thanks,
Robin.

Quoted 59 lines
---
  Documentation/admin-guide/kernel-parameters.txt | 5 ++++-
  kernel/dma/swiotlb.c                            | 5 +++++
  2 files changed, 9 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +4 -1
index b5493a7f8f22..8a1fccbd9b25 100644
@@ -7477,7 +7477,7 @@ Kernel parameters
  			Execution Facility on pSeries.
 
  	swiotlb=	[ARM,PPC,MIPS,X86,S390,EARLY]
-			Format: { <int> [,<int>] | force | noforce }
+			Format: { <int> [,<int>] | force | noforce | any}
  			<int> -- Number of I/O TLB slabs
  			<int> -- Second integer after comma. Number of swiotlb
  				 areas with their own lock. Will be rounded up
@@ -7485,6 +7485,9 @@ Kernel parameters
  			force -- force using of bounce buffers even if they
  			         wouldn't be automatically used by the kernel
  			noforce -- Never use bounce buffers (for debugging)
+			any --  Allow the swiotlb pool to be placed anywhere in
+				system RAM, lifting the default low-memory (4GB)
+				restriction.
 
  	switches=	[HW,M68k,EARLY]
 
kernel/dma/swiotlb.c +5 -0
index 1abd3e6146f4..34773ae7c770 100644
@@ -80,6 +80,7 @@ struct io_tlb_slot {
 
  static bool swiotlb_force_bounce;
  static bool swiotlb_force_disable;
+static unsigned int swiotlb_param_flags __initdata;
 
  #ifdef CONFIG_SWIOTLB_DYNAMIC
 
@@ -198,6 +199,8 @@ setup_io_tlb_npages(char *str)
  		swiotlb_force_bounce = true;
  	else if (!strcmp(str, "noforce"))
  		swiotlb_force_disable = true;
+	else if (!strcmp(str, "any"))
+		swiotlb_param_flags |= SWIOTLB_ANY;
 
  	return 0;
  }
@@ -445,6 +448,8 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask,
 
  	io_tlb_default_mem.force_bounce = swiotlb_force_bounce;
 
+	flags |= swiotlb_param_flags;
+
  #ifdef CONFIG_SWIOTLB_DYNAMIC
  	if (!remap)
  		io_tlb_default_mem.can_grow = true;
#4 lore raw

Thanks Robin, Marek for the review.

Quoted 16 lines · Robin Murphy
Quoted 15 lines · Aakarsh Jain

CoCo guests (AMD SEV-SNP, Intel TDX) require large swiotlb pools for streaming DMA workloads such as high-speed NIC and AI accelerator inference. The existing swiotlb pool allocator restricts placement to low memory (below 4GB by default), capping usable pool size at ~1GB even when a larger pool is requested via swiotlb=<nslabs>.

The SWIOTLB_ANY flag already exists to lift this restriction, and swiotlb_init_remap() already handles it correctly via the flags parameter (see CONFIG_SWIOTLB_DYNAMIC path: io_tlb_default_mem.phys_limit is set to virt_to_phys(high_memory-1) when SWIOTLB_ANY is set).

However, there is no way to set SWIOTLB_ANY from the command line. The only existing mechanism was via arch-specific code (e.g. powerpc SVM sets SWIOTLB_ANY in pci_iommu_init). x86 CoCo guests have no such path.

Quoted 9 lines
Quoted 4 lines

After Aneesh  series ("dma-mapping: Track shared DMA state through
direct, pool and swiotlb paths", https://patchwork.kernel.org/project/ linux-arm-kernel/cover/[email protected]/) removes SWIOTLB_FORCE, x86 pci_swiotlb_detect() leaves x86_swiotlb_flags = 0 for
CoCo guests. The pool falls back to low memory and caps at ~1GB:

This is entirely irrelevant; SWIOTLB_FORCE has no impact on allocation behaviour anyway. x86 wasn't passing SWIOTLB_ANY before and it still isn't, although there doesn't seem to be any particular reason why the well-reviewed patch for that hasn't been picked up:

https://lore.kernel.org/lkml/[email protected]/

You are right my commit message incorrectly tied SWIOTLB_FORCE removal to pool placement. SWIOTLB_FORCE only controls whether bounce buffering is forced at runtime, it has no bearing on where the pool is allocated. Placement is governed solely by SWIOTLB_ANY. I'll drop that paragraph entirely. I see both you and Marek are pointing to this patch, which fixes the issue architecturally. I'm happy to help get that landed instead of adding a user facing knob. My only hesitation is the 32-bit concern below:
auto-enabling SWIOTLB_ANY for *all* CoCo guests carries the same breakage risk for limited-mask devices, which was flagged here:
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 8 lines

   Without "any": pool at 0x35a9c000 (~900MB, below 4GB boundary) With    "any": pool at 0x1df9c00000 (~120GB, anywhere in RAM) [Tested on AMD SEV-SNP guest, swiotlb=4194304]

Add "any" as a new keyword to the swiotlb= kernel parameter. This is an explicit, opt-in mechanism that sets SWIOTLB_ANY for the default pool at boot time, without touching any arch-specific code.

Quoted 6 lines
Quoted 3 lines

Devices with 32-bit DMA masks are not affected, they still use the normal low-memory bounce buffer path. The "any" option is only meaningful for workloads where all active DMA devices have 64-bit masks.

That doesn't make any sense - if a user passes this option then any devices with DMA addressing limitations definitely *are* going to be affected, and quite likely broken altogether. If anything, the documentation should be even more explicit that this should only be used if you do know for sure that no devices have DMA addressing limitations.

You are correct here too. My statement that "32-bit devices are not affected" is wrong. There is a single default pool, once it moves above 4GB via "any", a device with a <64-bit DMA mask has no reachable bounce buffer and will break. The opt-in nature only means the admin accepted that risk, it does not make the risk go away. If this option survives at all, the documentation must state the opposite of what I wrote: use it ONLY when you are certain no device in the system has DMA addressing limitations.

Quoted 2 lines

As a general SWIOTLB-behaviour-debugging option for orthogonality with force/noforce I'm not opposed to the idea, but it is definitely not something that real CoCo use-cases should rely on - if the general consensus if that CoCo environments want a different setup by default then the arch/CoCo code should be taking care of that.

So my takeaway, this patch, if kept, is at best a debugging knob for orthogonality with force/noforce, and not something real CoCo deployments should rely on. I'm fine positioning it that way, or dropping it. Which brings me to the actual motivation behind posting this patch.
what should be recommended approach for large streaming DMA workloads in CoCo guests(high-speed NIC / AI accelerator inference)?
Is the intended direction to move such drivers to the coherent DMA path rather than growing or relocating the SWIOTLB pool?

Thanks,
Aakarsh

Quoted 54 lines

Thanks,
Robin.

Quoted 50 lines

---
  Documentation/admin-guide/kernel-parameters.txt | 5 ++++- kernel/dma/swiotlb.c                            | 5 +++++

  2 files changed, 9 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index b5493a7f8f22..8a1fccbd9b25 100644
@@ -7477,7 +7477,7 @@ Kernel parameters

              Execution Facility on pSeries.
      swiotlb=    [ARM,PPC,MIPS,X86,S390,EARLY]

-            Format: { <int> [,<int>] | force | noforce }
+            Format: { <int> [,<int>] | force | noforce | any}

              <int> -- Number of I/O TLB slabs
              <int> -- Second integer after comma. Number of swiotlb areas with their own lock. Will be rounded up

Documentation/admin-guide/kernel-parameters.txt +0 -0
@@ -7485,6 +7485,9 @@ Kernel parameters

              force -- force using of bounce buffers even if they wouldn't be automatically used by the kernel noforce -- Never use bounce buffers (for debugging) +            any --  Allow the swiotlb pool to be placed anywhere in +                system RAM, lifting the default low-memory (4GB) +                restriction.
      switches=    [HW,M68k,EARLY]

kernel/dma/swiotlb.c +5 -0
index 1abd3e6146f4..34773ae7c770 100644
@@ -80,6 +80,7 @@ struct io_tlb_slot {
   static bool swiotlb_force_bounce;
   static bool swiotlb_force_disable;
+static unsigned int swiotlb_param_flags __initdata;
   #ifdef CONFIG_SWIOTLB_DYNAMIC
@@ -198,6 +199,8 @@ setup_io_tlb_npages(char *str)
           swiotlb_force_bounce = true;
       else if (!strcmp(str, "noforce"))
           swiotlb_force_disable = true;
+    else if (!strcmp(str, "any"))
+        swiotlb_param_flags |= SWIOTLB_ANY;
       return 0;
   }
@@ -445,6 +448,8 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask,
       io_tlb_default_mem.force_bounce = swiotlb_force_bounce;
+    flags |= swiotlb_param_flags;
+
   #ifdef CONFIG_SWIOTLB_DYNAMIC
       if (!remap)
           io_tlb_default_mem.can_grow = true;
#5 lore raw
In reply to Aakarsh Jain
kernel test robot noticed the following build errors:

Hi Aakarsh,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v7.2-rc6 next-20260804] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Aakarsh-Jain/x86-pci-dma-add-any-keyword-to-swiotlb-kernel-parameter/20260805-183105
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20260708114244.246176-1-aakarsh.jain%40oss.qualcomm.com
patch subject: [RFC PATCH] x86/pci-dma: add "any" keyword to swiotlb= kernel parameter
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20260805/[email protected]/config)
compiler: powerpc64-linux-gcc (GCC) 16.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260805/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

kernel/dma/swiotlb.c: In function 'swiotlb_init_late':

>> kernel/dma/swiotlb.c:451:9: error: 'flags' undeclared (first use in this function)
     451 |         flags |= swiotlb_param_flags;
         |         ^~~~~

kernel/dma/swiotlb.c:451:9: note: each undeclared identifier is reported only once for each function it appears in

vim +/flags +451 kernel/dma/swiotlb.c

426
427 /*
428 * Systems with larger DMA zones (those that don't support ISA) can
429 * initialize the swiotlb later using the slab allocator if needed.
430 * This should be just like above, but with some error catching.
431 */
432 int swiotlb_init_late(size_t size, gfp_t gfp_mask,
433 int (*remap)(void *tlb, unsigned long nslabs))
434 {
435 struct io_tlb_pool *mem = &io_tlb_default_mem.defpool;
436 unsigned long nslabs = ALIGN(size >> IO_TLB_SHIFT, IO_TLB_SEGSIZE);
437 unsigned int nareas;
438 unsigned char *vstart = NULL;
439 unsigned int order, area_order;
440 bool retried = false;
441 int rc = 0;
442
443 if (io_tlb_default_mem.nslabs)
444 return 0;
445
446 if (swiotlb_force_disable)
447 return 0;
448
449 io_tlb_default_mem.force_bounce = swiotlb_force_bounce;
450

 > 451		flags |= swiotlb_param_flags;

452

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

#6 lore raw
In reply to Aakarsh Jain
kernel test robot noticed the following build errors:

Hi Aakarsh,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v7.2-rc6 next-20260805] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Aakarsh-Jain/x86-pci-dma-add-any-keyword-to-swiotlb-kernel-parameter/20260805-183105
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20260708114244.246176-1-aakarsh.jain%40oss.qualcomm.com
patch subject: [RFC PATCH] x86/pci-dma: add "any" keyword to swiotlb= kernel parameter
config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20260806/[email protected]/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 12df34b8469b8095359de8c249cb1b2753fadeea)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260806/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> kernel/dma/swiotlb.c:451:2: error: use of undeclared identifier 'flags'
     451 |         flags |= swiotlb_param_flags;
         |         ^~~~~

1 error generated.

vim +/flags +451 kernel/dma/swiotlb.c

426
427 /*
428 * Systems with larger DMA zones (those that don't support ISA) can
429 * initialize the swiotlb later using the slab allocator if needed.
430 * This should be just like above, but with some error catching.
431 */
432 int swiotlb_init_late(size_t size, gfp_t gfp_mask,
433 int (*remap)(void *tlb, unsigned long nslabs))
434 {
435 struct io_tlb_pool *mem = &io_tlb_default_mem.defpool;
436 unsigned long nslabs = ALIGN(size >> IO_TLB_SHIFT, IO_TLB_SEGSIZE);
437 unsigned int nareas;
438 unsigned char *vstart = NULL;
439 unsigned int order, area_order;
440 bool retried = false;
441 int rc = 0;
442
443 if (io_tlb_default_mem.nslabs)
444 return 0;
445
446 if (swiotlb_force_disable)
447 return 0;
448
449 io_tlb_default_mem.force_bounce = swiotlb_force_bounce;
450

 > 451		flags |= swiotlb_param_flags;

452

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki