[v2,1/3] eal/linux: select iova-mode va with no-huge option

Message ID 20200219011007.8611-2-dwilder@us.ibm.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series add travis ci support for ppc64le |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/Intel-compilation fail apply issues

Commit Message

David Wilder Feb. 19, 2020, 1:10 a.m. UTC
  If --no-huge is set and iova-mode has not been specified force VA mode.
If --no-huge and --iova-mode=PA is requested error out as this is
an impossible configuration.

Signed-off-by: David Wilder <dwilder@us.ibm.com>
---
 lib/librte_eal/linux/eal/eal.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
  

Patch

diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 9530ee55f..d3a0a1731 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -1062,9 +1062,16 @@  rte_eal_init(int argc, char **argv)
 
 	/* if no EAL option "--iova-mode=<pa|va>", use bus IOVA scheme */
 	if (internal_config.iova_mode == RTE_IOVA_DC) {
+
 		/* autodetect the IOVA mapping mode */
 		enum rte_iova_mode iova_mode = rte_bus_get_iommu_class();
 
+		if (iova_mode == RTE_IOVA_PA && !rte_eal_has_hugepages()) {
+			iova_mode = RTE_IOVA_VA;
+			RTE_LOG(WARNING, EAL, "Some buses want 'PA' but forcing 'VA' because --no-huge is requested.\n");
+			RTE_LOG(WARNING, EAL, "Not all buses may be able to initialize.\n");
+		}
+
 		if (iova_mode == RTE_IOVA_DC) {
 			RTE_LOG(DEBUG, EAL, "Buses did not request a specific IOVA mode.\n");
 
@@ -1111,6 +1118,13 @@  rte_eal_init(int argc, char **argv)
 			internal_config.iova_mode;
 	}
 
+	if (rte_eal_iova_mode() == RTE_IOVA_PA &&
+	    rte_eal_has_hugepages() == 0) {
+		rte_eal_init_alert("Cannot use IOVA as 'PA' with --no-huge");
+		rte_errno = EINVAL;
+		return -1;
+	}
+
 	if (rte_eal_iova_mode() == RTE_IOVA_PA && !phys_addrs) {
 		rte_eal_init_alert("Cannot use IOVA as 'PA' since physical addresses are not available");
 		rte_errno = EINVAL;