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 E9A20A0C58; Tue, 31 Aug 2021 22:38:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0728A41145; Tue, 31 Aug 2021 22:38:06 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2079.outbound.protection.outlook.com [40.107.244.79]) by mails.dpdk.org (Postfix) with ESMTP id C19EC410FA; Tue, 31 Aug 2021 22:38:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WMcjqkVShJwxNOP16FyCSqWTV+4PCfUiw462A+OIMIK7P3dxymW36lJzadIqCprA79y8NGaCciBYux7tMIZl5uw7se29E8H6zCeqeUsYLCfyGElSv0cCzCBWkH95B7A/k3VZKoVz76Ur2t3z29QARWh6DZnHTlV2gDtjzLSfEw5N3F8/90wRWymvV0G4o5Gx+pQ51lZsGE2BDhHKO/9O/c5MCHOHgC9RoNdGmWJKWqgM6lf0/PRxCUwIuRrCgeT6VCjJqawVhH5es/te49S70aHjK61K/jaMojtZP23zhxnH487QhxlMKJnhA0hexGslLVSdBzkiqTtOPsGvAuPZvQ== 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:X-MS-Exchange-SenderADCheck; bh=B1HFx0KjCksIhz1cOLOsjRQyo3M8oNgjsbuwGXwkQP4=; b=dhaYWudDAuwAwX/caoTuzKu0Zg7yz+3IOT6Pa7ovLYT+QwdUgE7c7tbkBFYwK4v+FmGfN21t+0gS5ACSdhsV9AC0HFOeGAquGVQBR/IJLf50VOy+ArSFNOMqrbo7FR65fZbTPpijb+Iprk3sRpUwUZQYACz2LJSnddLg+h1GnnIDNBMVb1eQ5sDlH/2Ehjlj697toiIoM8urRGsYnlEaEDIulbpx322hSOq0PSA3nk6r6IM9kOmLm+Rrcx976qCtAGUd/I3AIAGzTF+K6M3EQ+OoALVxiVZ7sBLLa/WyfnpkGKKWVWz9brkuwpZIN79NnmUO8bBG07zlWt+X5WbSiw== 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=B1HFx0KjCksIhz1cOLOsjRQyo3M8oNgjsbuwGXwkQP4=; b=T+ZEBO+gL6dQTMZQb/RMDs+Y/URHBhjnYMivZyTMuA2+xn1VnhkXrSc1SYjHk3KjDF46F9XgKBUNkKdIId7K1lNfxhrZuHPrthgytX+ADjFyUfIlqaud0vI13KoDvz8XO83adEdBSB5K3CXL21EtXfIyU8gKCfswwBhbkV/tkcUBjS2Bmhm44QtKwpmIEEs60cpq66Yn6F/ozOGfGhZnNrt/y1kYfrZP9LxA/br7W6O91fkSaS0ZRerZTu1KLxWyo94Ht1rcH08nJuHL2EnbdUfCxACfDJhb+NQcymmHJ+tsIZ7j8liqX55RtpsQYPWqmj2cgVDRnPLYRiMJOa7aEg== Received: from MWHPR22CA0037.namprd22.prod.outlook.com (2603:10b6:300:69::23) by MN2PR12MB3375.namprd12.prod.outlook.com (2603:10b6:208:cc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17; Tue, 31 Aug 2021 20:38:01 +0000 Received: from CO1NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:300:69:cafe::93) by MWHPR22CA0037.outlook.office365.com (2603:10b6:300:69::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Tue, 31 Aug 2021 20:38:00 +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 CO1NAM11FT059.mail.protection.outlook.com (10.13.174.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 31 Aug 2021 20:38:00 +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.2; Tue, 31 Aug 2021 13:38:00 -0700 Received: from nvidia.com (172.20.187.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 31 Aug 2021 20:37:58 +0000 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , Date: Tue, 31 Aug 2021 23:37:28 +0300 Message-ID: <20210831203732.3411134-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210831203732.3411134-1-michaelba@nvidia.com> References: <20210831203732.3411134-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 91bcfa42-b4c4-4b60-4f5f-08d96cbf3977 X-MS-TrafficTypeDiagnostic: MN2PR12MB3375: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j5rF29GiSan0OwYH3xtRuuUJF+1CZacbPLmiI6UPDL63r9J5J87OUvdLaqrOMyahB3gY9iu+3GNie8fb/KJnzo6bEtDaB40pDrQqDUQs8tSvSPWFvyd8cwM70NHpYrMgSGvbsCx35v7Y59CFopio3ze4X7kUCHjKR4TjlqDTfHykRNIk7v1cUG+F/Nrd/3cYPBrNG/GQvGZAKx/dIOfUh13R/ZY4Cp6F+t95jU9Fl5Y/9hUyf7kPJY22VoUxFPYz4oYyX6KhGn4GCPh3JcGPZRGqdFyU78QTk/bQDTJePMAeabN/JEweVXDVMFJauYsUPz+eeidMpcc+MZ7b3MDLLubMF+W2XIBVtvBt0N9RQNokJDCJJIKzKGzvhkWMdfwMgsz1FZuCoBaa8NMHzY7W84ixNCNH8f1ydMPXp8U1CZ7m9LbwtgeHPFm+1ua0E5K/i9qP4eSfz6aVAIbZhKP4csY8btVZI4LM6lJOxOKnSOrEQFmLlEbE26nlaCoPw+4mTj0gmD6O/niYKjqlSOiRa613Z84pjs/PvXnrn1LtN232n5CzNLYuPdcOBI0SjKWV+5BBFyywo1cSHDeS+Vuu0Pz0KYXbl63M8l/j6FXWuq3tJaKReEBce6Wv+IaJbkGZUlK+79t5nSAEIozA55WmokJQozgbYhMBeetgz/xGPK8ii4OvXGSkwMmmxkJTvjADhvjlatD5Nu8nYvrd5dfrMQ== 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)(346002)(39860400002)(396003)(376002)(136003)(46966006)(36840700001)(6286002)(83380400001)(36860700001)(316002)(8676002)(7636003)(86362001)(82310400003)(6666004)(5660300002)(54906003)(426003)(7696005)(47076005)(2906002)(82740400003)(16526019)(186003)(70586007)(450100002)(8936002)(1076003)(4326008)(36756003)(336012)(6916009)(26005)(478600001)(356005)(2616005)(70206006)(55016002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2021 20:38:00.7170 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91bcfa42-b4c4-4b60-4f5f-08d96cbf3977 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: CO1NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3375 Subject: [dpdk-dev] [PATCH 2/6] net/mlx5: fix PCI probing error flow 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" In PCI probing, there is internal probe function that is called several times for several PFs. When one of them fails, the previous PFs are not destroyed what may cause a memory leak. Destroy them. Fixes: 08c2772fc747 ("net/mlx5: support list of representor PF") Cc: stable@dpdk.org Signed-off-by: Michael Baum --- 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