From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 512AFA04DD for ; Wed, 28 Oct 2020 11:53:01 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 43472CA06; Wed, 28 Oct 2020 11:53:00 +0100 (CET) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id D1E22C9FA for ; Wed, 28 Oct 2020 11:52:57 +0100 (CET) Received: by mail-wm1-f68.google.com with SMTP id c16so4313206wmd.2 for ; Wed, 28 Oct 2020 03:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g7auQTJVT52bByu/t7LrzLhVBKZUPC1e+hReRijCkaM=; b=iTyEcNvnlGIfSHn9eS3ANNM2oHGxS+tD32qOprYeRsfH+dSI/xoBPohHFHDd/NTeCH NEfC7g8Gwaethc2QJXJqmEXiKGwufbMeZQ7MMH0Ou5/RHOtskU52bsKRApQCX06Qt1iU KZtmZI8hiDRpq9YTDUB05x9q31Kde+XT/NBdgYhmhV5wfF86XlkmJGJ2LEyFXemowzfz ONSNjRO3vU5nTGHuiqv+drmvziwNkDNX8SJkAVmIRVGKgsXXpIE1dzqQJg+YkufUQ/7T nmkMAagni+AoNafuDwaqLMgpn4FqzQxcqego3ZAZRffixm1DM3ZwS0pdzEMJGARE4jMw j15A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g7auQTJVT52bByu/t7LrzLhVBKZUPC1e+hReRijCkaM=; b=IdFd0zaGcl6iEuVy+2nHMlslkQE/Fn6qRqEYyCkPYdNQeaqb5dvSy668aHDkTmUKXt 99PQk3C3vpDjF3rt5uXgUTqYfP2P8cUrnx4I3786rYfjAQzhRqcUUfiwWL9FxQTmhc+W EGwMofQDPspG/4AhSE4dl7AAlPDACaTYZtN4eC0oY/alLQYGa0w8R/pWJWBWl7PQJWtv 9gI4fRDWFVWpOXifGKv75WdCUB95wwXpZOxjxnF9eyIUAZqX3KyGE1utxnBsoOwbeBWu fbY69caqH9K+ziMssGa4Nk2TOHfSZWFPPIzqBw0UNbjq9YT3g6CNgkQQEqLo91P3LXco FGPg== X-Gm-Message-State: AOAM531VSLdzhCUCyYZrpzR4Dwin/EJPDzLKKYHx142MKxFFtDysauLr dSp9/QTOsqls6oXXQReAj5iCGsJpN+DFIiTV X-Google-Smtp-Source: ABdhPJxstvqFrkeVM9uzFcwsKCJG41STZxankeMOWhSby3A177BrJznUDePUWS1r2YA3Wi+/9Tlyqg== X-Received: by 2002:a1c:4e0e:: with SMTP id g14mr7433986wmh.69.1603882376524; Wed, 28 Oct 2020 03:52:56 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id 30sm6402180wrs.84.2020.10.28.03.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 03:52:55 -0700 (PDT) From: luca.boccassi@gmail.com To: Viacheslav Ovsiienko Cc: dpdk stable Date: Wed, 28 Oct 2020 10:44:47 +0000 Message-Id: <20201028104606.3504127-128-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028104606.3504127-1-luca.boccassi@gmail.com> References: <20201028104606.3504127-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'common/mlx5: fix PCI address lookup' has been queued to stable release 19.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 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 --- 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 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@dpdk.org Signed-off-by: Viacheslav Ovsiienko --- - 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; }