History

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

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.

Jagadeesh Pagadala committed 4 months ago

Commit 3cf67bb1 parent 01886163 files · +33 −4Browse files

Showing the changes to kernel (1 of 3 files). Show all

Unified · Split

kernel/dma/Kconfig+22−0
@@ -86,6 +86,28 @@ config SWIOTLB · 85 unmodified lines
86 bool86 bool
87 select NEED_DMA_MAP_STATE87 select NEED_DMA_MAP_STATE
88 88
89config SWIOTLB_DEFAULT_SIZE_MB
90 int "Default SWIOTLB bounce buffer size in MB"
91 depends on SWIOTLB
92 range 1 64
93 default 64
94 help
95 Sets the default size of the software IO TLB (SWIOTLB) bounce buffer
96 pool allocated at boot time. The default is 64 MB.
97
98 On memory-constrained embedded or mobile platforms (e.g., those with
99 a hardware IOMMU such as ARM SMMU covering most DMA-capable devices),
100 a smaller value such as 4 or 8 MB may be sufficient. The SWIOTLB is
101 then only needed for devices that bypass the IOMMU or have restricted
102 DMA address ranges.
103
104 The minimum allowed value is 1 MB. This compile-time default can be
105 overridden at runtime using the "swiotlb=<nslabs>" kernel command line
106 parameter. Refer to Documentation/admin-guide/kernel-parameters.txt
107 for details.
108
109 If unsure, leave at the default value of 64.
110
89config SWIOTLB_DYNAMIC111config SWIOTLB_DYNAMIC
90 bool "Dynamic allocation of DMA bounce buffers"112 bool "Dynamic allocation of DMA bounce buffers"
91 default n113 default n

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t