Skip to contentSkip to conversation

swiotlb: Check nslabs after initialization in the swiotlb_init_remap()

PATCH In review Tianyu Lan 2 participants 2 messages Jul 13, 2022 DMA mapping helpers

lore
Share & tools
lore

Tianyu Lan

author
#0 lore raw

PATCH 1/1 swiotlb: Check nslabs after initialization in the swiotlb_init_remap()

From: Tianyu Lan <[email protected]>

The check of nslabs less than IO_TLB_MIN_SLABS should be later than initialization. Fix it.

---
 kernel/dma/swiotlb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/dma/swiotlb.c +3 -3
index 0ffb23c0e0e8..c39483bf067d 100644
@@ -308,9 +308,6 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
 	if (swiotlb_force_disable)
 		return;
 
-	if (nslabs < IO_TLB_MIN_SLABS)
-		panic("%s: nslabs = %lu too small\n", __func__, nslabs);
-
 	/*
 	 * default_nslabs maybe changed when adjust area number.
 	 * So allocate bounce buffer after adjusting area number.
@@ -320,6 +317,9 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
 
 	nslabs = default_nslabs;
 
+	if (nslabs < IO_TLB_MIN_SLABS)
+		panic("%s: nslabs = %lu too small\n", __func__, nslabs);
+
 	/*
 	 * By default allocate the bounce buffer memory from low memory, but
 	 * allow to pick a location everywhere for hypervisors with guest
Signature · 1 line
2.25.1