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 32059A034F; Fri, 8 Oct 2021 10:25:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AB4F340140; Fri, 8 Oct 2021 10:25:35 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 4EFCC40042 for ; Fri, 8 Oct 2021 10:25:34 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HQh321br1z908Y; Fri, 8 Oct 2021 16:20:46 +0800 (CST) Received: from dggema767-chm.china.huawei.com (10.1.198.209) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.8; Fri, 8 Oct 2021 16:25:31 +0800 Received: from localhost.localdomain (10.67.165.24) by dggema767-chm.china.huawei.com (10.1.198.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Fri, 8 Oct 2021 16:25:30 +0800 From: Huisong Li To: CC: , , , , , Date: Fri, 8 Oct 2021 16:21:14 +0800 Message-ID: <20211008082114.22468-1-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <1627908397-51565-1-git-send-email-lihuisong@huawei.com> References: <1627908397-51565-1-git-send-email-lihuisong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggema767-chm.china.huawei.com (10.1.198.209) X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] ethdev: fix eth device released repeatedly 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 secondary process, because it doesn't clear eth_dev->data, the "eth_dev" above will not be NULL when rte_eth_dev_close() has been called before this interface is called. In this case, Ethernet device will be released repeatedly. The state of the Ethernet device is equal to RTE_ETH_DEV_UNUSED after calling rte_eth_dev_close(). Using this state resolves problem. Fixes: 99a2dd955fba ("lib: remove librte_ prefix from directory names") Signed-off-by: Huisong Li --- RFC -> v1: * fix commit log and add a judgment for secondary process. --- lib/ethdev/ethdev_pci.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/ethdev/ethdev_pci.h b/lib/ethdev/ethdev_pci.h index 8edca82ce8..be695feefe 100644 --- a/lib/ethdev/ethdev_pci.h +++ b/lib/ethdev/ethdev_pci.h @@ -151,6 +151,20 @@ rte_eth_dev_pci_generic_remove(struct rte_pci_device *pci_dev, if (!eth_dev) return 0; + /* + * In secondary process, because it doesn't clear eth_dev->data, the + * "eth_dev" above will not be NULL when rte_eth_dev_close() has been + * called before this interface is called. + * In this case, Ethernet device will be released repeatedly. + * The state of the Ethernet device is equal to RTE_ETH_DEV_UNUSED after + * calling rte_eth_dev_close(). Using this state resolves problem. + */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY && + eth_dev->state == RTE_ETH_DEV_UNUSED) { + RTE_ETHDEV_LOG(INFO, "The ethdev port has been released."); + return 0; + } + if (dev_uninit) { ret = dev_uninit(eth_dev); if (ret) -- 2.33.0