From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 15C5AA0C43; Sun, 12 Sep 2021 12:37:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF4AE410F5; Sun, 12 Sep 2021 12:36:56 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2078.outbound.protection.outlook.com [40.107.100.78]) by mails.dpdk.org (Postfix) with ESMTP id 3A68D410E0; Sun, 12 Sep 2021 12:36:54 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TvvEVHM58LyAtYo8dPz8JylgIexjXvja3rs2T6JT0shqRW3Zlap2JdUJbfnufTAro83qxkOaBqnMvD9XlOBviWbfpONsrtmYTaIQ3fP5Xpq8XJYlzAaNKO61iMIeolwQ9bMzCvJwcvpg71HEyVAEq8A5yKXycCH06ORneEiJKAafOqHH2MYMPM3/qffT55Zahuj/vSJemVmYfSjcfme12qYIfTLdB7OvPZxGP04j3/VpF0l2jFaiHX+NjWO/DEa3F5TfLgIAh2bXqVX6xExkf3DI1uGAPrhU3RcwekLvaRTkxGaCAtF1GfHCuukD5qofhqTDgyE8RLb5Oo/hpaC23A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=s+L8ZF1yZsQ5cnYQ+rWcERmDZ/nzZuiGoyzz8a9QfQE=; b=aTb0EJbBWad+MjneHwu/zQPdriccJ76HpFe/8oUhhLNzwW3xp+DgAY9Jit2N+XTXxo2u8oGIVsKUmtNKQw35mrh75n7gz6Ul8oFmKIwT2WsiyIwT2URnhUyEU2/+WoqXLMy8gZ6G6UU0jRePqCGl68NVEHdP5s12fYnSqulkmJCS0rAvB88K2ywX+eQSFLMW158FrQ2ijCLg9uR9Vbq0jzPBmTiknKW2AnWhAO/z0iVVtIHeE0IjWzlVIenbobAVfscLUJfJWb5YWoTjRfYRSCWZs986Yp/k5gRL6rhRAxVNEmGyQv0MP6Ic6JVd8Srp0DwMvKBCoUzaJS3+Pj9QtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s+L8ZF1yZsQ5cnYQ+rWcERmDZ/nzZuiGoyzz8a9QfQE=; b=PWLgyFFbzEtYqanfwL2n/GIaw8renkxMXYsWGRRAe76RTqt4mzjHGNNR51USMsPNmPjvAgWLyXdwNw8dc26czJNwb5jKf1v9LJdq33bza7SCEiDXpqxrBBgg5iiCKLdy74JIvdbWSK1m7/GhVWWmoStNfszXYrU3IKfPgVmpSVUbtWTNuG5TcOK7dM9Cp2/1mGtQ2R86o3VpWFfDurGPa21JX5Uf6f4j9GSYA+ekmJ+OMnFzFsogY4PcjVyAGpO50wOqsz9FDfLofE/ASGfLXk3ZBTsSeIp3qEfFl8iHAtlAbqSh40QWI0li7Cfy9mKlnTw9LrxNdis9RV9CyRZdqg== Received: from DM5PR16CA0017.namprd16.prod.outlook.com (2603:10b6:3:c0::27) by MN2PR12MB4565.namprd12.prod.outlook.com (2603:10b6:208:26b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Sun, 12 Sep 2021 10:36:53 +0000 Received: from DM6NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:3:c0:cafe::9f) by DM5PR16CA0017.outlook.office365.com (2603:10b6:3:c0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Sun, 12 Sep 2021 10:36:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by DM6NAM11FT012.mail.protection.outlook.com (10.13.173.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4500.14 via Frontend Transport; Sun, 12 Sep 2021 10:36:52 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 12 Sep 2021 03:36:51 -0700 Received: from nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 12 Sep 2021 10:36:50 +0000 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , Date: Sun, 12 Sep 2021 13:36:24 +0300 Message-ID: <20210912103628.257499-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210912103628.257499-1-michaelba@nvidia.com> References: <20210831203732.3411134-1-michaelba@nvidia.com> <20210912103628.257499-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1acdba15-6150-4300-c9aa-08d975d93c39 X-MS-TrafficTypeDiagnostic: MN2PR12MB4565: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1051; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZvPIaA11aDInN8gE/dTY1ZXbJxyqxSfSe3G6pEWe7ph/r9dT3sGjSn8YPWvsqxRJrBgBnKjQkJMlUwRgkouqRJ8zi4Qh7v9Y1aQGxK2bbQMjY1hWw8xostmSXZIECJxQ6jejspVKN5SfNPb7mzuL/BMq1BUUteELdMsq9CYiFDF8kdkKYX8vl3r3HSfD5vJd4Zm+cc3yFy+PkSkA1R44h/eLt3hhGgDJUlVBdaW46BvLpsVhNhGjy7VwZklG0tibVCtHlfEsq+2v9PmfmuPYPffydMGpzm6lJHm+WKUlCC/q5Xzq4rV9rkMeubWdy03ApUApbUBkLgLyDtvHpqt0cpV9JkxFTw9Y/GP21uLi8fTM3/EkAln93V2ZJASL9k2PHgGnJ2RgoiBAH0QFe+1mumCcRb7ECCezySTT8IEsr8yteZja3yTuaDwqZ6qWhrET56qqMQKfF+ir+chpFuXic8roS6gQBsOwStIEy4Uje+UbOyD+hRNAYG79nle/16jzCs8KtP7EHQWjJH7pC543i+eWeEG0pEJWUbl+XLNDbkMw6OKoZtWDtwg0XFD+Zw9s3kfpOOmVjQEnqfi71wdp1FlYxuUS91putxdL2M+2Y3VtWjH0io8CgB8VHd6Bu6waFKiORchQmJco3dww3z2MEpgQwxBf/HcuFRQZWNxmJR3A/AiWaQ8mPJGcARG7bCCWMOKUhvR+0N/PA4l9IeBdhQ== X-Forefront-Antispam-Report: CIP:216.228.112.32; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid01.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(336012)(86362001)(316002)(2616005)(8676002)(36756003)(82310400003)(450100002)(7696005)(36860700001)(5660300002)(26005)(83380400001)(70206006)(426003)(2906002)(1076003)(186003)(16526019)(508600001)(55016002)(4326008)(47076005)(70586007)(8936002)(6666004)(7636003)(6286002)(54906003)(356005)(6916009); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2021 10:36:52.7370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1acdba15-6150-4300-c9aa-08d975d93c39 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.32]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4565 Subject: [dpdk-dev] [PATCH v2 2/6] net/mlx5: fix memory leak in PCI probe X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" During PCI probe, the internal probe function is called per PF. If one of them fails, it was missing a prober destroy for the previously probed PFs. This fixes the behavior by destroying all previously probed PFs. Fixes: 08c2772fc747 ("net/mlx5: support list of representor PF") Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 13 ++++++++++++- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 5f8766aa48..3d204f99f7 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -2700,9 +2700,20 @@ mlx5_os_pci_probe(struct rte_pci_device *pci_dev) if (eth_da.nb_ports > 0) { /* Iterate all port if devargs pf is range: "pf[0-1]vf[...]". */ - for (p = 0; p < eth_da.nb_ports; p++) + for (p = 0; p < eth_da.nb_ports; p++) { ret = mlx5_os_pci_probe_pf(pci_dev, ð_da, eth_da.ports[p]); + if (ret) + break; + } + if (ret) { + DRV_LOG(ERR, "Probe of PCI device " PCI_PRI_FMT " " + "aborted due to proding failure of PF %u", + pci_dev->addr.domain, pci_dev->addr.bus, + pci_dev->addr.devid, pci_dev->addr.function, + eth_da.ports[p]); + mlx5_net_remove(&pci_dev->device); + } } else { ret = mlx5_os_pci_probe_pf(pci_dev, ð_da, 0); } diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index f0ec2d1279..02ea2e781e 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2386,7 +2386,7 @@ mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev) * @return * 0 on success, the function cannot fail. */ -static int +int mlx5_net_remove(struct rte_device *dev) { uint16_t port_id; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index e02714e231..3581414b78 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1483,6 +1483,7 @@ int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel); uint16_t mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev); int mlx5_dev_close(struct rte_eth_dev *dev); +int mlx5_net_remove(struct rte_device *dev); bool mlx5_is_hpf(struct rte_eth_dev *dev); bool mlx5_is_sf_repr(struct rte_eth_dev *dev); void mlx5_age_event_prepare(struct mlx5_dev_ctx_shared *sh); -- 2.25.1