[dpdk-stable] patch 'common/mlx5: fix PCI address lookup' has been queued to stable release 19.11.6

luca.boccassi at gmail.com luca.boccassi at gmail.com
Wed Oct 28 11:44:47 CET 2020


Hi,

FYI, your patch has been queued to stable release 19.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 10/30/20. 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.

Thanks.

Luca Boccassi

---
>From 9f5bb85bf418674e339ab0a631d0d6a271230b49 Mon Sep 17 00:00:00 2001
From: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
Date: Sun, 13 Sep 2020 19:55:06 +0000
Subject: [PATCH] common/mlx5: fix PCI address lookup

[ upstream commit 482a1d34b60e7b918a39b2ccd32e06638f8c5aa4 ]

mlx5 PMDs use the mlx5_dev_to_pci_addr() routine to convert
Infiniband device name to the Bus-Device-Function location
on the PCI bus. The routine returned success even in case of
not found identification string. On caller side it likely
caused the wrong match with the BDF of previous device
resulting in wrong representor and master recognitions.

Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")

Signed-off-by: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
---
 drivers/net/mlx4/mlx4.c        | 18 ++++++++++++------
 drivers/net/mlx5/mlx5_ethdev.c | 18 ++++++++++++------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 55398e4d01..9dda4ef330 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -465,6 +465,7 @@ mlx4_ibv_device_to_pci_addr(const struct ibv_device *device,
 {
 	FILE *file;
 	char line[32];
+	int rc = -ENOENT;
 	MKSTR(path, "%s/device/uevent", device->ibdev_path);
 
 	file = fopen(path, "rb");
@@ -474,16 +475,18 @@ mlx4_ibv_device_to_pci_addr(const struct ibv_device *device,
 	}
 	while (fgets(line, sizeof(line), file) == line) {
 		size_t len = strlen(line);
-		int ret;
 
 		/* Truncate long lines. */
-		if (len == (sizeof(line) - 1))
+		if (len == (sizeof(line) - 1)) {
 			while (line[(len - 1)] != '\n') {
-				ret = fgetc(file);
+				int ret = fgetc(file);
 				if (ret == EOF)
-					break;
+					goto exit;
 				line[(len - 1)] = ret;
 			}
+			/* No match for long lines. */
+			continue;
+		}
 		/* Extract information. */
 		if (sscanf(line,
 			   "PCI_SLOT_NAME="
@@ -492,12 +495,15 @@ mlx4_ibv_device_to_pci_addr(const struct ibv_device *device,
 			   &pci_addr->bus,
 			   &pci_addr->devid,
 			   &pci_addr->function) == 4) {
-			ret = 0;
+			rc = 0;
 			break;
 		}
 	}
+exit:
 	fclose(file);
-	return 0;
+	if (rc)
+		rte_errno = -rc;
+	return rc;
 }
 
 /**
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 92773dca28..ef332536ee 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1226,6 +1226,7 @@ mlx5_dev_to_pci_addr(const char *dev_path,
 {
 	FILE *file;
 	char line[32];
+	int rc = -ENOENT;
 	MKSTR(path, "%s/device/uevent", dev_path);
 
 	file = fopen(path, "rb");
@@ -1235,16 +1236,18 @@ mlx5_dev_to_pci_addr(const char *dev_path,
 	}
 	while (fgets(line, sizeof(line), file) == line) {
 		size_t len = strlen(line);
-		int ret;
 
 		/* Truncate long lines. */
-		if (len == (sizeof(line) - 1))
+		if (len == (sizeof(line) - 1)) {
 			while (line[(len - 1)] != '\n') {
-				ret = fgetc(file);
+				int ret = fgetc(file);
 				if (ret == EOF)
-					break;
+					goto exit;
 				line[(len - 1)] = ret;
 			}
+			/* No match for long lines. */
+			continue;
+		}
 		/* Extract information. */
 		if (sscanf(line,
 			   "PCI_SLOT_NAME="
@@ -1253,12 +1256,15 @@ mlx5_dev_to_pci_addr(const char *dev_path,
 			   &pci_addr->bus,
 			   &pci_addr->devid,
 			   &pci_addr->function) == 4) {
-			ret = 0;
+			rc = 0;
 			break;
 		}
 	}
+exit:
 	fclose(file);
-	return 0;
+	if (rc)
+		rte_errno = -rc;
+	return rc;
 }
 
 /**
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-10-28 10:35:15.724987039 +0000
+++ 0128-common-mlx5-fix-PCI-address-lookup.patch	2020-10-28 10:35:11.696832850 +0000
@@ -1,8 +1,10 @@
-From 482a1d34b60e7b918a39b2ccd32e06638f8c5aa4 Mon Sep 17 00:00:00 2001
+From 9f5bb85bf418674e339ab0a631d0d6a271230b49 Mon Sep 17 00:00:00 2001
 From: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
 Date: Sun, 13 Sep 2020 19:55:06 +0000
 Subject: [PATCH] common/mlx5: fix PCI address lookup
 
+[ upstream commit 482a1d34b60e7b918a39b2ccd32e06638f8c5aa4 ]
+
 mlx5 PMDs use the mlx5_dev_to_pci_addr() routine to convert
 Infiniband device name to the Bus-Device-Function location
 on the PCI bus. The routine returned success even in case of
@@ -11,18 +13,71 @@
 resulting in wrong representor and master recognitions.
 
 Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")
-Cc: stable at dpdk.org
 
 Signed-off-by: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
 ---
- drivers/common/mlx5/linux/mlx5_common_os.c | 18 +++++++++++++-----
- 1 file changed, 13 insertions(+), 5 deletions(-)
+ drivers/net/mlx4/mlx4.c        | 18 ++++++++++++------
+ drivers/net/mlx5/mlx5_ethdev.c | 18 ++++++++++++------
+ 2 files changed, 24 insertions(+), 12 deletions(-)
 
-diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c
-index 7bb3ba6f82..0edd78ea6d 100644
---- a/drivers/common/mlx5/linux/mlx5_common_os.c
-+++ b/drivers/common/mlx5/linux/mlx5_common_os.c
-@@ -39,6 +39,7 @@ mlx5_dev_to_pci_addr(const char *dev_path,
+diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
+index 55398e4d01..9dda4ef330 100644
+--- a/drivers/net/mlx4/mlx4.c
++++ b/drivers/net/mlx4/mlx4.c
+@@ -465,6 +465,7 @@ mlx4_ibv_device_to_pci_addr(const struct ibv_device *device,
+ {
+ 	FILE *file;
+ 	char line[32];
++	int rc = -ENOENT;
+ 	MKSTR(path, "%s/device/uevent", device->ibdev_path);
+ 
+ 	file = fopen(path, "rb");
+@@ -474,16 +475,18 @@ mlx4_ibv_device_to_pci_addr(const struct ibv_device *device,
+ 	}
+ 	while (fgets(line, sizeof(line), file) == line) {
+ 		size_t len = strlen(line);
+-		int ret;
+ 
+ 		/* Truncate long lines. */
+-		if (len == (sizeof(line) - 1))
++		if (len == (sizeof(line) - 1)) {
+ 			while (line[(len - 1)] != '\n') {
+-				ret = fgetc(file);
++				int ret = fgetc(file);
+ 				if (ret == EOF)
+-					break;
++					goto exit;
+ 				line[(len - 1)] = ret;
+ 			}
++			/* No match for long lines. */
++			continue;
++		}
+ 		/* Extract information. */
+ 		if (sscanf(line,
+ 			   "PCI_SLOT_NAME="
+@@ -492,12 +495,15 @@ mlx4_ibv_device_to_pci_addr(const struct ibv_device *device,
+ 			   &pci_addr->bus,
+ 			   &pci_addr->devid,
+ 			   &pci_addr->function) == 4) {
+-			ret = 0;
++			rc = 0;
+ 			break;
+ 		}
+ 	}
++exit:
+ 	fclose(file);
+-	return 0;
++	if (rc)
++		rte_errno = -rc;
++	return rc;
+ }
+ 
+ /**
+diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
+index 92773dca28..ef332536ee 100644
+--- a/drivers/net/mlx5/mlx5_ethdev.c
++++ b/drivers/net/mlx5/mlx5_ethdev.c
+@@ -1226,6 +1226,7 @@ mlx5_dev_to_pci_addr(const char *dev_path,
  {
  	FILE *file;
  	char line[32];
@@ -30,7 +85,7 @@
  	MKSTR(path, "%s/device/uevent", dev_path);
  
  	file = fopen(path, "rb");
-@@ -48,16 +49,19 @@ mlx5_dev_to_pci_addr(const char *dev_path,
+@@ -1235,16 +1236,18 @@ mlx5_dev_to_pci_addr(const char *dev_path,
  	}
  	while (fgets(line, sizeof(line), file) == line) {
  		size_t len = strlen(line);
@@ -42,7 +97,6 @@
  			while (line[(len - 1)] != '\n') {
 -				ret = fgetc(file);
 +				int ret = fgetc(file);
-+
  				if (ret == EOF)
 -					break;
 +					goto exit;
@@ -54,10 +108,11 @@
  		/* Extract information. */
  		if (sscanf(line,
  			   "PCI_SLOT_NAME="
-@@ -66,11 +70,15 @@ mlx5_dev_to_pci_addr(const char *dev_path,
+@@ -1253,12 +1256,15 @@ mlx5_dev_to_pci_addr(const char *dev_path,
  			   &pci_addr->bus,
  			   &pci_addr->devid,
  			   &pci_addr->function) == 4) {
+-			ret = 0;
 +			rc = 0;
  			break;
  		}


More information about the stable mailing list