Skip to contentSkip to conversation

ia64: simplify code flow around swiotlb init

PATCH Superseded Sergei Trofimovich 2 participants 3 messages Mar 25, 2021 – Mar 28, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ia64: simplify code flow around swiotlb init

Before the change CONFIG_INTEL_IOMMU && !CONFIG_SWIOTLB && !CONFIG_FLATMEM

could skip set_max_mapnr(max_low_pfn); is iommu is not present on system.

---
 arch/ia64/mm/init.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/ia64/mm/init.c +5 -2
index 16d0d7d22657..a63585db94fe 100644
@@ -644,13 +644,16 @@ mem_init (void)
 	 * _before_ any drivers that may need the PCI DMA interface are
 	 * initialized or bootmem has been freed.
 	 */
+	do {
 #ifdef CONFIG_INTEL_IOMMU
-	detect_intel_iommu();
-	if (!iommu_detected)
+		detect_intel_iommu();
+		if (iommu_detected)
+			break;
 #endif
 #ifdef CONFIG_SWIOTLB
 		swiotlb_init(1);
 #endif
+	} while (0);
 
 #ifdef CONFIG_FLATMEM
 	BUG_ON(!mem_map);
Signature · 1 line
2.31.0
#1 lore raw

Hi Sergei!

Quoted 3 lines · Sergei Trofimovich

Before the change CONFIG_INTEL_IOMMU && !CONFIG_SWIOTLB && !CONFIG_FLATMEM

could skip set_max_mapnr(max_low_pfn); is iommu is not present on system.

                                           ^^
                                       typo s/is/if/

I will test this patch to make sure it doesn't break on the BL870c i4.

Adrian

Quoted 31 lines
---
 arch/ia64/mm/init.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/ia64/mm/init.c +5 -2
index 16d0d7d22657..a63585db94fe 100644
@@ -644,13 +644,16 @@ mem_init (void)
 	 * _before_ any drivers that may need the PCI DMA interface are
 	 * initialized or bootmem has been freed.
 	 */
+	do {
 #ifdef CONFIG_INTEL_IOMMU
-	detect_intel_iommu();
-	if (!iommu_detected)
+		detect_intel_iommu();
+		if (iommu_detected)
+			break;
 #endif
 #ifdef CONFIG_SWIOTLB
 		swiotlb_init(1);
 #endif
+	} while (0);
 
 #ifdef CONFIG_FLATMEM
 	BUG_ON(!mem_map);
Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#2 lore raw

PATCH v2 1/1 ia64: simplify code flow around swiotlb init

Before the change CONFIG_INTEL_IOMMU && !CONFIG_SWIOTLB && !CONFIG_FLATMEM could skip set_max_mapnr(max_low_pfn); if iommu is not present on system.

CC Andrew Morton <[email protected]>
CC John Paul Adrian Glaubitz <[email protected]>

---
Change since v1: fixed a typo in commit mesage.

 arch/ia64/mm/init.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/ia64/mm/init.c +5 -2
index 16d0d7d22657..a63585db94fe 100644
@@ -644,13 +644,16 @@ mem_init (void)
 	 * _before_ any drivers that may need the PCI DMA interface are
 	 * initialized or bootmem has been freed.
 	 */
+	do {
 #ifdef CONFIG_INTEL_IOMMU
-	detect_intel_iommu();
-	if (!iommu_detected)
+		detect_intel_iommu();
+		if (iommu_detected)
+			break;
 #endif
 #ifdef CONFIG_SWIOTLB
 		swiotlb_init(1);
 #endif
+	} while (0);
 
 #ifdef CONFIG_FLATMEM
 	BUG_ON(!mem_map);
Signature · 1 line
2.31.1