DPDK patches and discussions
 help / color / mirror / Atom feed
From: christian.ehrhardt@canonical.com
To: dev <dev@dpdk.org>
Cc: Luca Boccassi <bluca@debian.org>,
	David Wilder <dwilder@us.ibm.com>,
	Christian Ehrhardt <christian.ehrhardt@canonical.com>
Subject: [PATCH v2] eal/linux: force iova-mode va without pa available
Date: Fri, 24 Nov 2023 11:09:04 +0100	[thread overview]
Message-ID: <20231124100904.388453-1-christian.ehrhardt@canonical.com> (raw)

From: David Wilder <dwilder@us.ibm.com>

When using --no-huge option physical address are not guaranteed
to be persistent.

This change effectively makes "--no-huge" the same as
"--no-huge --iova-mode=va".

When --no-huge is used (or any other condition making physical
addresses unavailable) setting --iova-mode=pa will have no effect.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
---
 doc/guides/prog_guide/env_abstraction_layer.rst |  9 ++++++---
 lib/eal/linux/eal.c                             | 16 ++++++++++------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst b/doc/guides/prog_guide/env_abstraction_layer.rst
index 6debf54efb..20c7355e0f 100644
--- a/doc/guides/prog_guide/env_abstraction_layer.rst
+++ b/doc/guides/prog_guide/env_abstraction_layer.rst
@@ -559,9 +559,12 @@ IOVA Mode is selected by considering what the current usable Devices on the
 system require and/or support.
 
 On FreeBSD, RTE_IOVA_PA is always the default. On Linux, the IOVA mode is
-detected based on a 2-step heuristic detailed below.
+detected based on a heuristic detailed below.
 
-For the first step, EAL asks each bus its requirement in terms of IOVA mode
+For the first step, if no Physical Addresses are available RTE_IOVA_VA is
+selected.
+
+Then EAL asks each bus its requirement in terms of IOVA mode
 and decides on a preferred IOVA mode.
 
 - if all buses report RTE_IOVA_PA, then the preferred IOVA mode is RTE_IOVA_PA,
@@ -575,7 +578,7 @@ and decides on a preferred IOVA mode.
 If the buses have expressed no preference on which IOVA mode to pick, then a
 default is selected using the following logic:
 
-- if physical addresses are not available, RTE_IOVA_VA mode is used
+- if enable_iova_as_pa was not set at build RTE_IOVA_VA mode is used
 - if /sys/kernel/iommu_groups is not empty, RTE_IOVA_VA mode is used
 - otherwise, RTE_IOVA_PA mode is used
 
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 57da058cec..2f1fce3c54 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1067,6 +1067,16 @@ rte_eal_init(int argc, char **argv)
 
 	phys_addrs = rte_eal_using_phys_addrs() != 0;
 
+	if (!phys_addrs) {
+		/* if we have no access to physical addresses, pick IOVA as VA mode. */
+		if (internal_conf->iova_mode == RTE_IOVA_PA)
+			RTE_LOG(WARNING, EAL, "WARNING: --iova-mode=pa, but Physical addresses are unavailable, selecting IOVA as VA mode.\n");
+		else
+			RTE_LOG(DEBUG, EAL, "Physical addresses are unavailable, selecting IOVA as VA mode.\n");
+		internal_conf->iova_mode = RTE_IOVA_VA;
+		rte_eal_get_configuration()->iova_mode = internal_conf->iova_mode;
+	}
+
 	/* 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 */
@@ -1078,12 +1088,6 @@ rte_eal_init(int argc, char **argv)
 			if (!RTE_IOVA_IN_MBUF) {
 				iova_mode = RTE_IOVA_VA;
 				RTE_LOG(DEBUG, EAL, "IOVA as VA mode is forced by build option.\n");
-			} else if (!phys_addrs) {
-				/* if we have no access to physical addresses,
-				 * pick IOVA as VA mode.
-				 */
-				iova_mode = RTE_IOVA_VA;
-				RTE_LOG(DEBUG, EAL, "Physical addresses are unavailable, selecting IOVA as VA mode.\n");
 			} else if (is_iommu_enabled()) {
 				/* we have an IOMMU, pick IOVA as VA mode */
 				iova_mode = RTE_IOVA_VA;
-- 
2.34.1


             reply	other threads:[~2023-11-24 10:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-24 10:09 christian.ehrhardt [this message]
2023-11-24 10:29 ` Dmitry Kozlyuk
2023-11-28 14:39   ` Christian Ehrhardt
2023-11-29 21:50 ` David Christensen
2023-11-30 13:48   ` Christian Ehrhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231124100904.388453-1-christian.ehrhardt@canonical.com \
    --to=christian.ehrhardt@canonical.com \
    --cc=--no-chain-reply-to@dpdk.org \
    --cc=bluca@debian.org \
    --cc=dev@dpdk.org \
    --cc=dwilder@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).