eal: choose IOVA mode according to compilation flags

Message ID 20230412171949.27665-1-viacheslavo@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series eal: choose IOVA mode according to compilation flags |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Slava Ovsiienko April 12, 2023, 5:19 p.m. UTC
  The DPDK can be compiled to be run in IOVA VA mode with
'enable_iova_as_pa=false' meson option. If there is no
explicit EAL --iova-mode parameter specified in the command
line the rte_eal_init() tried to deduce  VA or PA mode without
taking into account the above mentioned compile time option,
resulting into initialization failure.

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 lib/eal/linux/eal.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Morten Brørup April 12, 2023, 7:12 p.m. UTC | #1
> From: Viacheslav Ovsiienko [mailto:viacheslavo@nvidia.com]
> Sent: Wednesday, 12 April 2023 19.20
> 
> The DPDK can be compiled to be run in IOVA VA mode with
> 'enable_iova_as_pa=false' meson option. If there is no
> explicit EAL --iova-mode parameter specified in the command
> line the rte_eal_init() tried to deduce  VA or PA mode without
> taking into account the above mentioned compile time option,
> resulting into initialization failure.
> 
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> ---
>  lib/eal/linux/eal.c | 5 ++++-

This patch is close to being a bugfix. Good catch!

You could also consider another patch, logging warnings in rte_bus_get_iommu_class() [1] for the busses that want IOVA as PA when !RTE_IOVA_IN_MBUF.

[1]: https://elixir.bootlin.com/dpdk/v23.03/source/lib/eal/common/eal_common_bus.c#L224

>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
> index c37868b7f0..4481bc4ad8 100644
> --- a/lib/eal/linux/eal.c
> +++ b/lib/eal/linux/eal.c
> @@ -1080,7 +1080,10 @@ rte_eal_init(int argc, char **argv)
>  		if (iova_mode == RTE_IOVA_DC) {
>  			RTE_LOG(DEBUG, EAL, "Buses did not request a specific
> IOVA mode.\n");
> 
> -			if (!phys_addrs) {
> +			if (!RTE_IOVA_IN_MBUF) {
> +				iova_mode = RTE_IOVA_VA;
> +				RTE_LOG(DEBUG, EAL, "IOVA VA mode is forced by
> build option.\n");

Minor detail regarding conventions: "IOVA VA " -> "IOVA as VA"

> +			} else if (!phys_addrs) {
>  				/* if we have no access to physical addresses,
>  				 * pick IOVA as VA mode.
>  				 */
> --
> 2.18.1

Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
  
Slava Ovsiienko April 13, 2023, 9:42 a.m. UTC | #2
> -----Original Message-----
> From: Morten Brørup <mb@smartsharesystems.com>
> Sent: среда, 12 апреля 2023 г. 22:12
> To: Slava Ovsiienko <viacheslavo@nvidia.com>; dev@dpdk.org
> Cc: NBU-Contact-Thomas Monjalon (EXTERNAL) <thomas@monjalon.net>;
> david.marchand@redhat.com
> Subject: RE: [PATCH] eal: choose IOVA mode according to compilation flags
> 
> > From: Viacheslav Ovsiienko [mailto:viacheslavo@nvidia.com]
> > Sent: Wednesday, 12 April 2023 19.20
> >
> > The DPDK can be compiled to be run in IOVA VA mode with
> > 'enable_iova_as_pa=false' meson option. If there is no explicit EAL
> > --iova-mode parameter specified in the command line the rte_eal_init()
> > tried to deduce  VA or PA mode without taking into account the above
> > mentioned compile time option, resulting into initialization failure.
> >
> > Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> > ---
> >  lib/eal/linux/eal.c | 5 ++++-
> 
> This patch is close to being a bugfix. Good catch!
> 
> You could also consider another patch, logging warnings in
> rte_bus_get_iommu_class() [1] for the busses that want IOVA as PA when
> !RTE_IOVA_IN_MBUF.

Yes, looks reasonable, thank you.
Let me gather the comments first, then will update the patch.

> 
> [1]:
> https://elixir.bootlin.com/dpdk/v23.03/source/lib/eal/common/eal_common_
> bus.c#L224
> 
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index
> > c37868b7f0..4481bc4ad8 100644
> > --- a/lib/eal/linux/eal.c
> > +++ b/lib/eal/linux/eal.c
> > @@ -1080,7 +1080,10 @@ rte_eal_init(int argc, char **argv)
> >  		if (iova_mode == RTE_IOVA_DC) {
> >  			RTE_LOG(DEBUG, EAL, "Buses did not request a
> specific IOVA
> > mode.\n");
> >
> > -			if (!phys_addrs) {
> > +			if (!RTE_IOVA_IN_MBUF) {
> > +				iova_mode = RTE_IOVA_VA;
> > +				RTE_LOG(DEBUG, EAL, "IOVA VA mode is
> forced by
> > build option.\n");
> 
> Minor detail regarding conventions: "IOVA VA " -> "IOVA as VA"
> 
> > +			} else if (!phys_addrs) {
> >  				/* if we have no access to physical addresses,
> >  				 * pick IOVA as VA mode.
> >  				 */
> > --
> > 2.18.1
> 
> Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
  

Patch

diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index c37868b7f0..4481bc4ad8 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1080,7 +1080,10 @@  rte_eal_init(int argc, char **argv)
 		if (iova_mode == RTE_IOVA_DC) {
 			RTE_LOG(DEBUG, EAL, "Buses did not request a specific IOVA mode.\n");
 
-			if (!phys_addrs) {
+			if (!RTE_IOVA_IN_MBUF) {
+				iova_mode = RTE_IOVA_VA;
+				RTE_LOG(DEBUG, EAL, "IOVA 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.
 				 */