Skip to contentSkip to conversation

swiotlb: don't override user specified size in swiotlb_adjust_size

PATCH In review Christoph Hellwig 3 participants 3 messages Apr 29, 2021 DMA mapping helpers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 swiotlb: don't override user specified size in swiotlb_adjust_size

If the user already specified a swiotlb size on the command line, swiotlb_adjust_size shoul not overwrite it.

Fixes 2cbc2776efe4 ("swiotlb: remove swiotlb_nr_tbl")
---
 kernel/dma/swiotlb.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/dma/swiotlb.c +2 -0
index 8635a57f88e9..8ca7d505d61c 100644
@@ -118,6 +118,8 @@ void __init swiotlb_adjust_size(unsigned long size)
 	 * architectures such as those supporting memory encryption to
 	 * adjust/expand SWIOTLB size for their use.
 	 */
+	if (default_nslabs != IO_TLB_DEFAULT_SIZE >> IO_TLB_SHIFT)
+		return;
 	size = ALIGN(size, IO_TLB_SIZE);
 	default_nslabs = ALIGN(size >> IO_TLB_SHIFT, IO_TLB_SEGSIZE);
 	pr_info("SWIOTLB bounce buffer size adjusted to %luMB", size >> 20);
Signature · 6 lines
2.30.2

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Tested-by on v1 1/1
#1 lore raw
Quoted 5 lines · Christoph Hellwig

If the user already specified a swiotlb size on the command line, swiotlb_adjust_size shoul not overwrite it.

Fixes 2cbc2776efe4 ("swiotlb: remove swiotlb_nr_tbl")

Thanks, Christoph!

Quoted 11 lines
---
 kernel/dma/swiotlb.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/dma/swiotlb.c +0 -0
index 8635a57f88e9..8ca7d505d61c 100644

kernel/dma/swiotlb.c void __init swiotlb_adjust_size(unsigned long size) · line 125

Quoted 8 lines
kernel/dma/swiotlb.c +2 -0
@@ -118,6 +118,8 @@ void __init swiotlb_adjust_size(unsigned long size)
 	 * architectures such as those supporting memory encryption to
 	 * adjust/expand SWIOTLB size for their use.
 	 */
+	if (default_nslabs != IO_TLB_DEFAULT_SIZE >> IO_TLB_SHIFT)
+		return;
 	size = ALIGN(size, IO_TLB_SIZE);
 	default_nslabs = ALIGN(size >> IO_TLB_SHIFT, IO_TLB_SEGSIZE);
 	pr_info("SWIOTLB bounce buffer size adjusted to %luMB", size >> 20);

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#2 lore raw
Quoted 10 lines · Tom Lendacky
Quoted 5 lines · Christoph Hellwig

If the user already specified a swiotlb size on the command line, swiotlb_adjust_size shoul not overwrite it.

Fixes 2cbc2776efe4 ("swiotlb: remove swiotlb_nr_tbl")

Thanks, Christoph!

Awesome! I put on the stable/for-linus-5.13 and will send a GIT PULL to Linus later on this week.

Thank you!

Quoted 6 lines
Quoted 6 lines
---
 kernel/dma/swiotlb.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 14 lines
Quoted 6 lines
kernel/dma/swiotlb.c +0 -0
index 8635a57f88e9..8ca7d505d61c 100644

kernel/dma/swiotlb.c void __init swiotlb_adjust_size(unsigned long size) · line 125

Quoted 8 lines
kernel/dma/swiotlb.c +2 -0
@@ -118,6 +118,8 @@ void __init swiotlb_adjust_size(unsigned long size)
 	 * architectures such as those supporting memory encryption to
 	 * adjust/expand SWIOTLB size for their use.
 	 */
+	if (default_nslabs != IO_TLB_DEFAULT_SIZE >> IO_TLB_SHIFT)
+		return;
 	size = ALIGN(size, IO_TLB_SIZE);
 	default_nslabs = ALIGN(size >> IO_TLB_SHIFT, IO_TLB_SEGSIZE);
 	pr_info("SWIOTLB bounce buffer size adjusted to %luMB", size >> 20);

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu