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 21335A0552; Wed, 1 Jun 2022 05:16:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BFAE740A84; Wed, 1 Jun 2022 05:16:35 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 384FF40150 for ; Wed, 1 Jun 2022 05:16:33 +0200 (CEST) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LCZ5815PzzfZwj for ; Wed, 1 Jun 2022 11:14:52 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 1 Jun 2022 11:16:31 +0800 From: "Min Hu (Connor)" To: Subject: [PATCH v3] ethdev: fix dev close in secondary process Date: Wed, 1 Jun 2022 11:15:13 +0800 Message-ID: <20220601031513.49108-1-humin29@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220527023553.48177-1-humin29@huawei.com> References: <20220527023553.48177-1-humin29@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected 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 From: Min Hu Secondary process need to close dev to release process private resources. But secondary process should not be obliged to wait for device stop before closing ethdev. This patch fixed it. Fixes: febc855b358e ("ethdev: forbid closing started device") Cc: stable@dpdk.org Signed-off-by: Min Hu --- v3: * add comment in the code. v2: * fixed comment. --- lib/ethdev/rte_ethdev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 09abee6345..902ff96889 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -1574,7 +1574,13 @@ rte_eth_dev_close(uint16_t port_id) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; - if (dev->data->dev_started) { + /* + * Secondary process need to close dev to release process private + * resources. But secondary process should not be obliged to wait + * for device stop before closing ethdev. + */ + if (rte_eal_process_type() == RTE_PROC_PRIMARY && + dev->data->dev_started) { RTE_ETHDEV_LOG(ERR, "Cannot close started device (port %u)\n", port_id); return -EINVAL; -- 2.33.0