From patchwork Wed Jan 13 16:28:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 86485 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C070BA04B5; Wed, 13 Jan 2021 17:29:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA5CF140E2A; Wed, 13 Jan 2021 17:29:13 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id AADF5140E2A for ; Wed, 13 Jan 2021 17:29:12 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from michaelba@nvidia.com) with SMTP; 13 Jan 2021 18:29:10 +0200 Received: from nvidia.com (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10DGSxID008426; Wed, 13 Jan 2021 18:29:09 +0200 From: Michael Baum To: dev@dpdk.org Cc: Matan Azrad , Raslan Darawsheh , David Marchand , stable@dpdk.org Date: Wed, 13 Jan 2021 16:28:52 +0000 Message-Id: <1610555333-18961-2-git-send-email-michaelba@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1610555333-18961-1-git-send-email-michaelba@nvidia.com> References: <1610555333-18961-1-git-send-email-michaelba@nvidia.com> Subject: [dpdk-dev] [PATCH 1/2] net/mlx4: fix device detach 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" When mlx4 device is probed, 2 different ethdev ports may be created for the 2 physical ports of the device. Wrongly, when the device is removed, the created ports are not released. Close and release the ethdev ports in remove process. Fixes: 7fae69eeff13 ("mlx4: new poll mode driver") Cc: stable@dpdk.org Reported-by: David Marchand Signed-off-by: Michael Baum Acked-by: Matan Azrad Tested-by: David Marchand --- drivers/net/mlx4/mlx4.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index d5d8c96..7460afa 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -375,8 +375,10 @@ struct mlx4_conf { struct mlx4_priv *priv = dev->data->dev_private; unsigned int i; - if (rte_eal_process_type() != RTE_PROC_PRIMARY) + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { + rte_eth_dev_release_port(dev); return 0; + } DEBUG("%p: closing device \"%s\"", (void *)dev, ((priv->ctx != NULL) ? priv->ctx->device->name : "")); @@ -1123,6 +1125,36 @@ struct mlx4_conf { return -err; } +/** + * DPDK callback to remove a PCI device. + * + * This function removes all Ethernet devices belong to a given PCI device. + * + * @param[in] pci_dev + * Pointer to the PCI device. + * + * @return + * 0 on success, the function cannot fail. + */ +static int +mlx4_pci_remove(struct rte_pci_device *pci_dev) +{ + uint16_t port_id; + int ret = 0; + + RTE_ETH_FOREACH_DEV_OF(port_id, &pci_dev->device) { + /* + * mlx4_dev_close() is not registered to secondary process, + * call the close function explicitly for secondary process. + */ + if (rte_eal_process_type() == RTE_PROC_SECONDARY) + ret |= mlx4_dev_close(&rte_eth_devices[port_id]); + else + ret |= rte_eth_dev_close(port_id); + } + return ret == 0 ? 0 : -EIO; +} + static const struct rte_pci_id mlx4_pci_id_map[] = { { RTE_PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, @@ -1147,6 +1179,7 @@ struct mlx4_conf { }, .id_table = mlx4_pci_id_map, .probe = mlx4_pci_probe, + .remove = mlx4_pci_remove, .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV, };