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 BAF7AA055C; Fri, 27 May 2022 04:37:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AD2F0410DC; Fri, 27 May 2022 04:37:13 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id CD3ED40DF7; Fri, 27 May 2022 04:37:11 +0200 (CEST) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4L8TTr1wFPzDqRY; Fri, 27 May 2022 10:37:04 +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; Fri, 27 May 2022 10:37:09 +0800 From: "Min Hu (Connor)" To: CC: Min Hu , , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Anatoly Burakov , Ajit Khaparde Subject: [PATCH] ethdev: fix dev close in secondary process Date: Fri, 27 May 2022 10:35:53 +0800 Message-ID: <20220527023553.48177-1-humin29@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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 Shared memory like port private resources should only be reserved by primary process. Secondary process should not start dev, and the state of 'dev_started' is only meaningful to primary process. While secondary process need to close dev to release process private resources. This patch limited the scope of 'dev_started'. Fixes: febc855b358e ("ethdev: forbid closing started device") Cc: stable@dpdk.org Signed-off-by: Min Hu --- lib/ethdev/rte_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 09abee6345..f34c6580a4 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -1574,7 +1574,8 @@ 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) { + 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