[dpdk-stable] patch 'eal/freebsd: fix IOVA mode selection' has been queued to stable release 20.11.4

Xueming Li xuemingl at nvidia.com
Wed Nov 10 07:31:27 CET 2021


Hi,

FYI, your patch has been queued to stable release 20.11.4

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/12/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/b36c2e6dbc7d554a7dda5c4d90dca4ebd3d0890e

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From b36c2e6dbc7d554a7dda5c4d90dca4ebd3d0890e Mon Sep 17 00:00:00 2001
From: Dmitry Kozlyuk <dkozlyuk at nvidia.com>
Date: Tue, 2 Nov 2021 12:08:15 +0200
Subject: [PATCH] eal/freebsd: fix IOVA mode selection
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 9790fc2149b7dc727526a13ff2bbeab09577aaef ]

FreeBSD EAL selected IOVA mode PA even in --no-huge mode
where PA are not available. Memory zones were created with IOVA
equal to RTE_BAD_IOVA with no indication this field is not usable.

Change IOVA mode detection:
1. Always allow to force --iova-mode=va.
2. In --no-huge mode, disallow forcing --iova-mode=pa, and select VA.
3. Otherwise select IOVA mode according to bus requests, default to PA.
In case contigmem is inaccessible, memory initialization will fail
with a message indicating the cause.

Fixes: c2361bab70c5 ("eal: compute IOVA mode based on PA availability")

Signed-off-by: Dmitry Kozlyuk <dkozlyuk at nvidia.com>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
---
 lib/librte_eal/freebsd/eal.c | 37 ++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c
index d784437669..957273a9bb 100644
--- a/lib/librte_eal/freebsd/eal.c
+++ b/lib/librte_eal/freebsd/eal.c
@@ -675,6 +675,8 @@ rte_eal_init(int argc, char **argv)
 	const struct rte_config *config = rte_eal_get_configuration();
 	struct internal_config *internal_conf =
 		eal_get_internal_configuration();
+	bool has_phys_addr;
+	enum rte_iova_mode iova_mode;
 
 	/* checks if the machine is adequate */
 	if (!rte_cpu_is_supported()) {
@@ -775,19 +777,30 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	/* if no EAL option "--iova-mode=<pa|va>", use bus IOVA scheme */
-	if (internal_conf->iova_mode == RTE_IOVA_DC) {
-		/* autodetect the IOVA mapping mode (default is RTE_IOVA_PA) */
-		enum rte_iova_mode iova_mode = rte_bus_get_iommu_class();
-
-		if (iova_mode == RTE_IOVA_DC)
-			iova_mode = RTE_IOVA_PA;
-		rte_eal_get_configuration()->iova_mode = iova_mode;
-	} else {
-		rte_eal_get_configuration()->iova_mode =
-			internal_conf->iova_mode;
+	/*
+	 * PA are only available for hugepages via contigmem.
+	 * If contigmem is inaccessible, rte_eal_hugepage_init() will fail
+	 * with a message describing the cause.
+	 */
+	has_phys_addr = internal_conf->no_hugetlbfs == 0;
+	iova_mode = internal_conf->iova_mode;
+	if (iova_mode == RTE_IOVA_PA && !has_phys_addr) {
+		rte_eal_init_alert("Cannot use IOVA as 'PA' since physical addresses are not available");
+		rte_errno = EINVAL;
+		return -1;
 	}
-
+	if (iova_mode == RTE_IOVA_DC) {
+		RTE_LOG(DEBUG, EAL, "Specific IOVA mode is not requested, autodetecting\n");
+		if (has_phys_addr) {
+			RTE_LOG(DEBUG, EAL, "Selecting IOVA mode according to bus requests\n");
+			iova_mode = rte_bus_get_iommu_class();
+			if (iova_mode == RTE_IOVA_DC)
+				iova_mode = RTE_IOVA_PA;
+		} else {
+			iova_mode = RTE_IOVA_VA;
+		}
+	}
+	rte_eal_get_configuration()->iova_mode = iova_mode;
 	RTE_LOG(INFO, EAL, "Selected IOVA mode '%s'\n",
 		rte_eal_iova_mode() == RTE_IOVA_PA ? "PA" : "VA");
 
-- 
2.33.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-11-10 14:17:10.899340120 +0800
+++ 0203-eal-freebsd-fix-IOVA-mode-selection.patch	2021-11-10 14:17:02.014078251 +0800
@@ -1 +1 @@
-From 9790fc2149b7dc727526a13ff2bbeab09577aaef Mon Sep 17 00:00:00 2001
+From b36c2e6dbc7d554a7dda5c4d90dca4ebd3d0890e Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 9790fc2149b7dc727526a13ff2bbeab09577aaef ]
@@ -18 +20,0 @@
-Cc: stable at dpdk.org
@@ -23 +25 @@
- lib/eal/freebsd/eal.c | 37 +++++++++++++++++++++++++------------
+ lib/librte_eal/freebsd/eal.c | 37 ++++++++++++++++++++++++------------
@@ -26,5 +28,5 @@
-diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
-index 9935356ed4..2c2baaa691 100644
---- a/lib/eal/freebsd/eal.c
-+++ b/lib/eal/freebsd/eal.c
-@@ -677,6 +677,8 @@ rte_eal_init(int argc, char **argv)
+diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c
+index d784437669..957273a9bb 100644
+--- a/lib/librte_eal/freebsd/eal.c
++++ b/lib/librte_eal/freebsd/eal.c
+@@ -675,6 +675,8 @@ rte_eal_init(int argc, char **argv)
@@ -39 +41 @@
-@@ -777,19 +779,30 @@ rte_eal_init(int argc, char **argv)
+@@ -775,19 +777,30 @@ rte_eal_init(int argc, char **argv)


More information about the stable mailing list