Skip to contentSkip to conversation

swiotlb: introduce Kconfig option for compile-time default pool size

PATCH Applied [email protected] 3 participants 4 messages Jul 2 – Aug 4

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

PATCH v2 1/1 swiotlb: introduce Kconfig option for compile-time default pool size

From: Jagadeesh Pagadala <[email protected]>

The SWIOTLB bounce buffer pool size is hardcoded at 64 MB via IO_TLB_DEFAULT_SIZE with no compile-time knob to adjust it. On memory-constrained embedded or mobile platforms equipped with a hardware IOMMU (e.g., ARM SMMU) covering most DMA-capable devices, reserving 64 MB at boot is unnecessarily wasteful — the SWIOTLB is only exercised for devices that bypass the IOMMU or have restricted DMA address ranges.

Introduce CONFIG_SWIOTLB_DEFAULT_SIZE_MB, an integer Kconfig option (range 1–64 MB, default 64) that allows platforms to set a smaller compile-time default. IO_TLB_DEFAULT_SIZE is updated to derive from this value when CONFIG_SWIOTLB is enabled, preserving the existing 64 MB default when the option is not configured.

The runtime "swiotlb=<nslabs>" kernel parameter override remains fully supported and takes precedence over the compile-time default.

---
The SWIOTLB bounce buffer pool size is hardcoded at 64 MB. On memory-constrained platforms with a hardware IOMMU (e.g., ARM SMMU), this reservation is wasteful as SWIOTLB is only needed for devices that bypass the IOMMU or have restricted DMA address ranges.

Introduce CONFIG_SWIOTLB_DEFAULT_SIZE_MB (range 1–64 MB, default 64) to allow a smaller compile-time default. The runtime "swiotlb=" parameter override remains supported and takes precedence.

Before (default 64 MB):

  [    0.000000] software IO TLB: area num 8.
  [    0.000000] software IO TLB: mapped [mem 0x00000000fbfff000-0x00000000fffff000] (64MB)

After (CONFIG_SWIOTLB_DEFAULT_SIZE_MB=1, 8 CPUs):

  [    0.000000] software IO TLB: area num 8.
  [    0.000000] software IO TLB: SWIOTLB bounce buffer size roundup to 2MB
  [    0.000000] software IO TLB: mapped [mem 0x00000000ffdff000-0x00000000fffff000] (2MB)

After (CONFIG_SWIOTLB_DEFAULT_SIZE_MB=2, 8 CPUs):

  [    0.000000] software IO TLB: area num 8.
  [    0.000000] software IO TLB: mapped [mem 0x00000000ffdff000-0x00000000fffff000] (2MB)

---
Changes in v2:
- Fix incorrect boot log label in cover letter: the roundup message is produced by CONFIG_SWIOTLB_DEFAULT_SIZE_MB=1 (not =2) with 8 CPUs.
- Update Documentation/core-api/swiotlb.rst to mention CONFIG_SWIOTLB_DEFAULT_SIZE_MB as per Michael's suggestion.
- Link to v1: https://patch.msgid.link/[email protected]

To: Jonathan Corbet <[email protected]>
To: Shuah Khan <[email protected]>
To: Marek Szyprowski <[email protected]>
To: Robin Murphy <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 Documentation/core-api/swiotlb.rst |  7 +++++--
 include/linux/swiotlb.h            |  8 ++++++--
 kernel/dma/Kconfig                 | 22 ++++++++++++++++++++++
 3 files changed, 33 insertions(+), 4 deletions(-)
Documentation/core-api/swiotlb.rst +5 -2
index 9e0fe027dd3b..71b4e4c27eb5 100644
@@ -140,8 +140,11 @@ Data structures concepts
 ------------------------
 Memory used for swiotlb bounce buffers is allocated from overall system memory
 as one or more "pools". The default pool is allocated during system boot with a
-default size of 64 MiB. The default pool size may be modified with the
-"swiotlb=" kernel boot line parameter. The default size may also be adjusted
+default size of 64 MiB, which can be changed at compile time via
+CONFIG_SWIOTLB_DEFAULT_SIZE_MB. The default pool size may also be
+modified at runtime with the "swiotlb=" kernel boot line parameter,
+which takes precedence over the compile-time default. The default size
+may also be adjusted
 due to other conditions, such as running in a CoCo VM, as described above. If
 CONFIG_SWIOTLB_DYNAMIC is enabled, additional pools may be allocated later in
 the life of the system. Each pool must be a contiguous range of physical
include/linux/swiotlb.h +6 -2
index 3dae0f592063..1665a9ce8f94 100644
@@ -32,8 +32,12 @@ struct scatterlist;
 #define IO_TLB_SHIFT 11
 #define IO_TLB_SIZE (1 << IO_TLB_SHIFT)
 
-/* default to 64MB */
-#define IO_TLB_DEFAULT_SIZE (64UL<<20)
+/* compile-time default; overridable via CONFIG_SWIOTLB_DEFAULT_SIZE_MB */
+#ifdef CONFIG_SWIOTLB
+#define IO_TLB_DEFAULT_SIZE ((unsigned long)CONFIG_SWIOTLB_DEFAULT_SIZE_MB << 20)
+#else
+#define IO_TLB_DEFAULT_SIZE (64UL << 20)
+#endif
 
 unsigned long swiotlb_size_or_default(void);
 void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
kernel/dma/Kconfig +22 -0
index 0a4ba21a57a7..3830a63ae032 100644
@@ -86,6 +86,28 @@ config SWIOTLB
 	bool
 	select NEED_DMA_MAP_STATE
 
+config SWIOTLB_DEFAULT_SIZE_MB
+	int "Default SWIOTLB bounce buffer size in MB"
+	depends on SWIOTLB
+	range 1 64
+	default 64
+	help
+	  Sets the default size of the software IO TLB (SWIOTLB) bounce buffer
+	  pool allocated at boot time. The default is 64 MB.
+
+	  On memory-constrained embedded or mobile platforms (e.g., those with
+	  a hardware IOMMU such as ARM SMMU covering most DMA-capable devices),
+	  a smaller value such as 4 or 8 MB may be sufficient. The SWIOTLB is
+	  then only needed for devices that bypass the IOMMU or have restricted
+	  DMA address ranges.
+
+	  The minimum allowed value is 1 MB. This compile-time default can be
+	  overridden at runtime using the "swiotlb=<nslabs>" kernel command line
+	  parameter. Refer to Documentation/admin-guide/kernel-parameters.txt
+	  for details.
+
+	  If unsure, leave at the default value of 64.
+
 config SWIOTLB_DYNAMIC
 	bool "Dynamic allocation of DMA bounce buffers"
 	default n

---
base-commit: 4fa3f5fabb30bf00d7475d5a33459ea83d639bf9
change-id: 20260617-swiotlb-c215ce0b23f7

Best regards,

Signature · 1 line
Bibek Kumar Patro <[email protected]>
Reviewed-by on v2 1/1
#1 lore raw

From: [email protected] <[email protected]> Sent: Thursday, July 2, 2026 7:09 AM

Quoted 140 lines

From: Jagadeesh Pagadala <[email protected]>

The SWIOTLB bounce buffer pool size is hardcoded at 64 MB via IO_TLB_DEFAULT_SIZE with no compile-time knob to adjust it. On memory-constrained embedded or mobile platforms equipped with a hardware IOMMU (e.g., ARM SMMU) covering most DMA-capable devices, reserving 64 MB at boot is unnecessarily wasteful — the SWIOTLB is only exercised for devices that bypass the IOMMU or have restricted DMA address ranges.

Introduce CONFIG_SWIOTLB_DEFAULT_SIZE_MB, an integer Kconfig option (range 1–64 MB, default 64) that allows platforms to set a smaller compile-time default. IO_TLB_DEFAULT_SIZE is updated to derive from this value when CONFIG_SWIOTLB is enabled, preserving the existing 64 MB default when the option is not configured.

The runtime "swiotlb=<nslabs>" kernel parameter override remains fully supported and takes precedence over the compile-time default.

---
The SWIOTLB bounce buffer pool size is hardcoded at 64 MB. On memory-constrained platforms with a hardware IOMMU (e.g., ARM SMMU), this reservation is wasteful as SWIOTLB is only needed for devices that bypass the IOMMU or have restricted DMA address ranges.

Introduce CONFIG_SWIOTLB_DEFAULT_SIZE_MB (range 1–64 MB, default 64) to allow a smaller compile-time default. The runtime "swiotlb=" parameter override remains supported and takes precedence.

Before (default 64 MB):

  [    0.000000] software IO TLB: area num 8.
  [    0.000000] software IO TLB: mapped [mem 0x00000000fbfff000-0x00000000fffff000] (64MB)

After (CONFIG_SWIOTLB_DEFAULT_SIZE_MB=1, 8 CPUs):

  [    0.000000] software IO TLB: area num 8.
  [    0.000000] software IO TLB: SWIOTLB bounce buffer size roundup to 2MB
  [    0.000000] software IO TLB: mapped [mem 0x00000000ffdff000-0x00000000fffff000] (2MB)

After (CONFIG_SWIOTLB_DEFAULT_SIZE_MB=2, 8 CPUs):

  [    0.000000] software IO TLB: area num 8.
  [    0.000000] software IO TLB: mapped [mem 0x00000000ffdff000-0x00000000fffff000] (2MB)

---
Changes in v2:
- Fix incorrect boot log label in cover letter: the roundup message is produced by CONFIG_SWIOTLB_DEFAULT_SIZE_MB=1 (not =2) with 8 CPUs.
- Update Documentation/core-api/swiotlb.rst to mention CONFIG_SWIOTLB_DEFAULT_SIZE_MB as per Michael's suggestion.
- Link to v1: https://patch.msgid.link/[email protected]

To: Jonathan Corbet <[email protected]>
To: Shuah Khan <[email protected]>
To: Marek Szyprowski <[email protected]>
To: Robin Murphy <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 Documentation/core-api/swiotlb.rst |  7 +++++--
 include/linux/swiotlb.h            |  8 ++++++--
 kernel/dma/Kconfig                 | 22 ++++++++++++++++++++++
 3 files changed, 33 insertions(+), 4 deletions(-)
Documentation/core-api/swiotlb.rst +5 -2
index 9e0fe027dd3b..71b4e4c27eb5 100644
@@ -140,8 +140,11 @@ Data structures concepts
 ------------------------
 Memory used for swiotlb bounce buffers is allocated from overall system memory
 as one or more "pools". The default pool is allocated during system boot with a
-default size of 64 MiB. The default pool size may be modified with the
-"swiotlb=" kernel boot line parameter. The default size may also be adjusted
+default size of 64 MiB, which can be changed at compile time via
+CONFIG_SWIOTLB_DEFAULT_SIZE_MB. The default pool size may also be
+modified at runtime with the "swiotlb=" kernel boot line parameter,
+which takes precedence over the compile-time default. The default size
+may also be adjusted
 due to other conditions, such as running in a CoCo VM, as described above. If
 CONFIG_SWIOTLB_DYNAMIC is enabled, additional pools may be allocated later in
 the life of the system. Each pool must be a contiguous range of physical
include/linux/swiotlb.h +6 -2
index 3dae0f592063..1665a9ce8f94 100644
@@ -32,8 +32,12 @@ struct scatterlist;
 #define IO_TLB_SHIFT 11
 #define IO_TLB_SIZE (1 << IO_TLB_SHIFT)
 
-/* default to 64MB */
-#define IO_TLB_DEFAULT_SIZE (64UL<<20)
+/* compile-time default; overridable via CONFIG_SWIOTLB_DEFAULT_SIZE_MB */
+#ifdef CONFIG_SWIOTLB
+#define IO_TLB_DEFAULT_SIZE ((unsigned long)CONFIG_SWIOTLB_DEFAULT_SIZE_MB << 20)
+#else
+#define IO_TLB_DEFAULT_SIZE (64UL << 20)
+#endif
 
 unsigned long swiotlb_size_or_default(void);
 void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
kernel/dma/Kconfig +22 -1
index 0a4ba21a57a7..3830a63ae032 100644
@@ -86,6 +86,28 @@ config SWIOTLB
 	bool
 	select NEED_DMA_MAP_STATE
 
+config SWIOTLB_DEFAULT_SIZE_MB
+	int "Default SWIOTLB bounce buffer size in MB"
+	depends on SWIOTLB
+	range 1 64
+	default 64
+	help
+	  Sets the default size of the software IO TLB (SWIOTLB) bounce buffer
+	  pool allocated at boot time. The default is 64 MB.
+
+	  On memory-constrained embedded or mobile platforms (e.g., those with
+	  a hardware IOMMU such as ARM SMMU covering most DMA-capable devices),
+	  a smaller value such as 4 or 8 MB may be sufficient. The SWIOTLB is
+	  then only needed for devices that bypass the IOMMU or have restricted
+	  DMA address ranges.
+
+	  The minimum allowed value is 1 MB. This compile-time default can be
+	  overridden at runtime using the "swiotlb=<nslabs>" kernel command line
+	  parameter. Refer to Documentation/admin-guide/kernel-parameters.txt
+	  for details.
+
+	  If unsure, leave at the default value of 64.
+
 config SWIOTLB_DYNAMIC
 	bool "Dynamic allocation of DMA bounce buffers"
 	default n
 
---

base-commit: 4fa3f5fabb30bf00d7475d5a33459ea83d639bf9
change-id: 20260617-swiotlb-c215ce0b23f7

Quoted 3 lines

Best regards,
--
Bibek Kumar Patro <[email protected]>

maintainer
#2 lore raw
In reply to [email protected]
Quoted 58 lines · On 02.07.2026 16:09, [email protected] wrote:

From: Jagadeesh Pagadala <[email protected]>

The SWIOTLB bounce buffer pool size is hardcoded at 64 MB via IO_TLB_DEFAULT_SIZE with no compile-time knob to adjust it. On memory-constrained embedded or mobile platforms equipped with a hardware IOMMU (e.g., ARM SMMU) covering most DMA-capable devices, reserving 64 MB at boot is unnecessarily wasteful — the SWIOTLB is only exercised for devices that bypass the IOMMU or have restricted DMA address ranges.

Introduce CONFIG_SWIOTLB_DEFAULT_SIZE_MB, an integer Kconfig option (range 1–64 MB, default 64) that allows platforms to set a smaller compile-time default. IO_TLB_DEFAULT_SIZE is updated to derive from this value when CONFIG_SWIOTLB is enabled, preserving the existing 64 MB default when the option is not configured.

The runtime "swiotlb=<nslabs>" kernel parameter override remains fully supported and takes precedence over the compile-time default.

---
The SWIOTLB bounce buffer pool size is hardcoded at 64 MB. On memory-constrained platforms with a hardware IOMMU (e.g., ARM SMMU), this reservation is wasteful as SWIOTLB is only needed for devices that bypass the IOMMU or have restricted DMA address ranges.

Introduce CONFIG_SWIOTLB_DEFAULT_SIZE_MB (range 1–64 MB, default 64) to allow a smaller compile-time default. The runtime "swiotlb=" parameter override remains supported and takes precedence.

Before (default 64 MB):

  [    0.000000] software IO TLB: area num 8.
  [    0.000000] software IO TLB: mapped [mem 0x00000000fbfff000-0x00000000fffff000] (64MB)

After (CONFIG_SWIOTLB_DEFAULT_SIZE_MB=1, 8 CPUs):

  [    0.000000] software IO TLB: area num 8.
  [    0.000000] software IO TLB: SWIOTLB bounce buffer size roundup to 2MB
  [    0.000000] software IO TLB: mapped [mem 0x00000000ffdff000-0x00000000fffff000] (2MB)

After (CONFIG_SWIOTLB_DEFAULT_SIZE_MB=2, 8 CPUs):

  [    0.000000] software IO TLB: area num 8.
  [    0.000000] software IO TLB: mapped [mem 0x00000000ffdff000-0x00000000fffff000] (2MB)

---
Changes in v2:
- Fix incorrect boot log label in cover letter: the roundup message is
produced by CONFIG_SWIOTLB_DEFAULT_SIZE_MB=1 (not =2) with 8 CPUs.
- Update Documentation/core-api/swiotlb.rst to mention
CONFIG_SWIOTLB_DEFAULT_SIZE_MB as per Michael's suggestion.
- Link to v1: https://protect2.fireeye.com/v1/url?k=7033f7b3-114e1d30-70327cfc-74fe48600158-fc2eb93dd6453735&q=1&e=44bf9751-f859-48d6-aee0-ebe8bab9d273&u=https%3A%2F%2Fpatch.msgid.link%2F20260617-swiotlb-v1-1-abfee3faf4ea%40oss.qualcomm.com

To: Jonathan Corbet <[email protected]>
To: Shuah Khan <[email protected]>
To: Marek Szyprowski <[email protected]>
To: Robin Murphy <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Quoted 2 lines
---
 Documentation/core-api/swiotlb.rst |  7 +++++--

Jonathan: could You ack the Documentation change, so I will take this to dma-mapping-for-next ?

Quoted 79 lines
 include/linux/swiotlb.h            |  8 ++++++--
 kernel/dma/Kconfig                 | 22 ++++++++++++++++++++++
 3 files changed, 33 insertions(+), 4 deletions(-)
Documentation/core-api/swiotlb.rst +5 -2
index 9e0fe027dd3b..71b4e4c27eb5 100644
@@ -140,8 +140,11 @@ Data structures concepts
 ------------------------
 Memory used for swiotlb bounce buffers is allocated from overall system memory
 as one or more "pools". The default pool is allocated during system boot with a
-default size of 64 MiB. The default pool size may be modified with the
-"swiotlb=" kernel boot line parameter. The default size may also be adjusted
+default size of 64 MiB, which can be changed at compile time via
+CONFIG_SWIOTLB_DEFAULT_SIZE_MB. The default pool size may also be
+modified at runtime with the "swiotlb=" kernel boot line parameter,
+which takes precedence over the compile-time default. The default size
+may also be adjusted
 due to other conditions, such as running in a CoCo VM, as described above. If
 CONFIG_SWIOTLB_DYNAMIC is enabled, additional pools may be allocated later in
 the life of the system. Each pool must be a contiguous range of physical
include/linux/swiotlb.h +6 -2
index 3dae0f592063..1665a9ce8f94 100644
@@ -32,8 +32,12 @@ struct scatterlist;
 #define IO_TLB_SHIFT 11
 #define IO_TLB_SIZE (1 << IO_TLB_SHIFT)
 
-/* default to 64MB */
-#define IO_TLB_DEFAULT_SIZE (64UL<<20)
+/* compile-time default; overridable via CONFIG_SWIOTLB_DEFAULT_SIZE_MB */
+#ifdef CONFIG_SWIOTLB
+#define IO_TLB_DEFAULT_SIZE ((unsigned long)CONFIG_SWIOTLB_DEFAULT_SIZE_MB << 20)
+#else
+#define IO_TLB_DEFAULT_SIZE (64UL << 20)
+#endif
 
 unsigned long swiotlb_size_or_default(void);
 void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
kernel/dma/Kconfig +22 -1
index 0a4ba21a57a7..3830a63ae032 100644
@@ -86,6 +86,28 @@ config SWIOTLB
 	bool
 	select NEED_DMA_MAP_STATE
 
+config SWIOTLB_DEFAULT_SIZE_MB
+	int "Default SWIOTLB bounce buffer size in MB"
+	depends on SWIOTLB
+	range 1 64
+	default 64
+	help
+	  Sets the default size of the software IO TLB (SWIOTLB) bounce buffer
+	  pool allocated at boot time. The default is 64 MB.
+
+	  On memory-constrained embedded or mobile platforms (e.g., those with
+	  a hardware IOMMU such as ARM SMMU covering most DMA-capable devices),
+	  a smaller value such as 4 or 8 MB may be sufficient. The SWIOTLB is
+	  then only needed for devices that bypass the IOMMU or have restricted
+	  DMA address ranges.
+
+	  The minimum allowed value is 1 MB. This compile-time default can be
+	  overridden at runtime using the "swiotlb=<nslabs>" kernel command line
+	  parameter. Refer to Documentation/admin-guide/kernel-parameters.txt
+	  for details.
+
+	  If unsure, leave at the default value of 64.
+
 config SWIOTLB_DYNAMIC
 	bool "Dynamic allocation of DMA bounce buffers"
 	default n
 
---

base-commit: 4fa3f5fabb30bf00d7475d5a33459ea83d639bf9
change-id: 20260617-swiotlb-c215ce0b23f7

Quoted 5 lines

Best regards,

Signature · 1 line
Bibek Kumar Patro <[email protected]>

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
maintainer Applied
#3 lore raw
In reply to [email protected]
Quoted 16 lines · On 02.07.2026 16:09, [email protected] wrote:

From: Jagadeesh Pagadala <[email protected]>

The SWIOTLB bounce buffer pool size is hardcoded at 64 MB via IO_TLB_DEFAULT_SIZE with no compile-time knob to adjust it. On memory-constrained embedded or mobile platforms equipped with a hardware IOMMU (e.g., ARM SMMU) covering most DMA-capable devices, reserving 64 MB at boot is unnecessarily wasteful — the SWIOTLB is only exercised for devices that bypass the IOMMU or have restricted DMA address ranges.

Introduce CONFIG_SWIOTLB_DEFAULT_SIZE_MB, an integer Kconfig option (range 1–64 MB, default 64) that allows platforms to set a smaller compile-time default. IO_TLB_DEFAULT_SIZE is updated to derive from this value when CONFIG_SWIOTLB is enabled, preserving the existing 64 MB default when the option is not configured.

Quoted 5 lines

The runtime "swiotlb=<nslabs>" kernel parameter override remains fully supported and takes precedence over the compile-time default.

Applied to dma-mapping-for-next, thanks!

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland