patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] common/mlx5: fix PCI location address routine
@ 2020-09-13 19:55 Viacheslav Ovsiienko
  2020-10-08 12:05 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Viacheslav Ovsiienko @ 2020-09-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: rasland, matan, orika, stable

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: 79aa430721b1 ("common/mlx5: split common file under Linux directory")
Cc: stable@dpdk.org

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/common/mlx5/linux/mlx5_common_os.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c
index 7bb3ba6..0edd78e 100644
--- a/drivers/common/mlx5/linux/mlx5_common_os.c
+++ b/drivers/common/mlx5/linux/mlx5_common_os.c
@@ -39,6 +39,7 @@
 {
 	FILE *file;
 	char line[32];
+	int rc = -ENOENT;
 	MKSTR(path, "%s/device/uevent", dev_path);
 
 	file = fopen(path, "rb");
@@ -48,16 +49,19 @@
 	}
 	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="
@@ -66,11 +70,15 @@
 			   &pci_addr->bus,
 			   &pci_addr->devid,
 			   &pci_addr->function) == 4) {
+			rc = 0;
 			break;
 		}
 	}
+exit:
 	fclose(file);
-	return 0;
+	if (rc)
+		rte_errno = -rc;
+	return rc;
 }
 
 /**
-- 
1.8.3.1


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

* Re: [dpdk-stable] [PATCH] common/mlx5: fix PCI location address routine
  2020-09-13 19:55 [dpdk-stable] [PATCH] common/mlx5: fix PCI location address routine Viacheslav Ovsiienko
@ 2020-10-08 12:05 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2020-10-08 12:05 UTC (permalink / raw)
  To: Slava Ovsiienko, dev; +Cc: Matan Azrad, Ori Kam, stable

Hi,

> -----Original Message-----
> From: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> Sent: Sunday, September 13, 2020 10:55 PM
> To: dev@dpdk.org
> Cc: Raslan Darawsheh <rasland@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Ori Kam <orika@nvidia.com>; stable@dpdk.org
> Subject: [PATCH] common/mlx5: fix PCI location address routine
> 
> 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: 79aa430721b1 ("common/mlx5: split common file under Linux
> directory")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> ---
>  drivers/common/mlx5/linux/mlx5_common_os.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c
> b/drivers/common/mlx5/linux/mlx5_common_os.c
> index 7bb3ba6..0edd78e 100644
> --- a/drivers/common/mlx5/linux/mlx5_common_os.c
> +++ b/drivers/common/mlx5/linux/mlx5_common_os.c
> @@ -39,6 +39,7 @@
>  {
>  	FILE *file;
>  	char line[32];
> +	int rc = -ENOENT;
>  	MKSTR(path, "%s/device/uevent", dev_path);
> 
>  	file = fopen(path, "rb");
> @@ -48,16 +49,19 @@
>  	}
>  	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="
> @@ -66,11 +70,15 @@
>  			   &pci_addr->bus,
>  			   &pci_addr->devid,
>  			   &pci_addr->function) == 4) {
> +			rc = 0;
>  			break;
>  		}
>  	}
> +exit:
>  	fclose(file);
> -	return 0;
> +	if (rc)
> +		rte_errno = -rc;
> +	return rc;
>  }
> 
>  /**
> --
> 1.8.3.1

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2020-10-08 12:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-13 19:55 [dpdk-stable] [PATCH] common/mlx5: fix PCI location address routine Viacheslav Ovsiienko
2020-10-08 12:05 ` Raslan Darawsheh

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git