patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v2 1/3] eal/freebsd: fix IOVA mode selection
       [not found] ` <20211101073701.825389-1-dkozlyuk@nvidia.com>
@ 2021-11-01  7:36   ` Dmitry Kozlyuk
  2021-11-01 16:21     ` Bruce Richardson
       [not found]   ` <20211102100817.916303-1-dkozlyuk@nvidia.com>
  1 sibling, 1 reply; 3+ messages in thread
From: Dmitry Kozlyuk @ 2021-11-01  7:36 UTC (permalink / raw)
  To: dev; +Cc: Anatoly Burakov, benjamin.walker, stable, Bruce Richardson

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")
Cc: benjamin.walker@intel.com
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
---
 lib/eal/freebsd/eal.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 9935356ed4..519a645344 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -677,6 +677,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()) {
@@ -777,21 +779,32 @@ 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_LOG(INFO, EAL, "Selected IOVA mode '%s'\n",
 		rte_eal_iova_mode() == RTE_IOVA_PA ? "PA" : "VA");
+	rte_eal_get_configuration()->iova_mode = iova_mode;
 
 	if (internal_conf->no_hugetlbfs == 0) {
 		/* rte_config isn't initialized yet */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH v2 1/3] eal/freebsd: fix IOVA mode selection
  2021-11-01  7:36   ` [dpdk-stable] [PATCH v2 1/3] eal/freebsd: fix IOVA mode selection Dmitry Kozlyuk
@ 2021-11-01 16:21     ` Bruce Richardson
  0 siblings, 0 replies; 3+ messages in thread
From: Bruce Richardson @ 2021-11-01 16:21 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: dev, Anatoly Burakov, benjamin.walker, stable

On Mon, Nov 01, 2021 at 09:36:59AM +0200, Dmitry Kozlyuk wrote:
> 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")
> Cc: benjamin.walker@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> ---
>  lib/eal/freebsd/eal.c | 37 +++++++++++++++++++++++++------------
>  1 file changed, 25 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
> index 9935356ed4..519a645344 100644
> --- a/lib/eal/freebsd/eal.c
> +++ b/lib/eal/freebsd/eal.c
> @@ -677,6 +677,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()) {
> @@ -777,21 +779,32 @@ 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_LOG(INFO, EAL, "Selected IOVA mode '%s'\n",
>  		rte_eal_iova_mode() == RTE_IOVA_PA ? "PA" : "VA");
> +	rte_eal_get_configuration()->iova_mode = iova_mode;
>  

This line needs to come before the log, or else the log statement needs to
be changed to use iova_mode rather than rte_eal_iova_mode(). I'd suggest
the former option.

With that change, you can add my ack to v2:

Acked-by: Bruce Richardson <bruce.richardson@intel.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-stable] [PATCH v3 1/3] eal/freebsd: fix IOVA mode selection
       [not found]   ` <20211102100817.916303-1-dkozlyuk@nvidia.com>
@ 2021-11-02 10:08     ` Dmitry Kozlyuk
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Kozlyuk @ 2021-11-02 10:08 UTC (permalink / raw)
  To: dev; +Cc: benjamin.walker, stable, Bruce Richardson

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")
Cc: benjamin.walker@intel.com
Cc: stable@dpdk.org

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

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)
 	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()) {
@@ -777,19 +779,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.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-02 10:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20211029084051.679233-1-dkozlyuk@nvidia.com>
     [not found] ` <20211101073701.825389-1-dkozlyuk@nvidia.com>
2021-11-01  7:36   ` [dpdk-stable] [PATCH v2 1/3] eal/freebsd: fix IOVA mode selection Dmitry Kozlyuk
2021-11-01 16:21     ` Bruce Richardson
     [not found]   ` <20211102100817.916303-1-dkozlyuk@nvidia.com>
2021-11-02 10:08     ` [dpdk-stable] [PATCH v3 " Dmitry Kozlyuk

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).