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 07EB2A04A2 for ; Sat, 25 Dec 2021 11:58:45 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 28A7641140; Sat, 25 Dec 2021 11:58:44 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id D249F4068F for ; Sat, 25 Dec 2021 11:58:41 +0100 (CET) Received: from kwepemi100010.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4JLgnV6Kf5z1DK3c; Sat, 25 Dec 2021 18:55:26 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by kwepemi100010.china.huawei.com (7.221.188.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Sat, 25 Dec 2021 18:58:39 +0800 Received: from localhost.localdomain (10.67.165.24) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Sat, 25 Dec 2021 18:58:39 +0800 From: Huisong Li To: , CC: , Subject: [PATCH 19.11 2/4] net/hns3: fix secondary process reference count Date: Sat, 25 Dec 2021 18:53:42 +0800 Message-ID: <20211225105344.28355-3-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211225105344.28355-1-lihuisong@huawei.com> References: <20211225105344.28355-1-lihuisong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit 323263717774df318d8a6e64ac8bfe546e03b8f6 ] The "secondary_cnt" will be increased when a secondary process initialized. But the value of this variable is not decreased when the secondary process exits, which causes the primary process senses that the secondary process still exists. As a result, the primary process fails to send messages to the secondary process after the secondary process exits. Fixes: 23d4b61fee5d ("net/hns3: support multiple process") Signed-off-by: Huisong Li Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.c | 5 +++-- drivers/net/hns3/hns3_ethdev_vf.c | 6 ++++-- drivers/net/hns3/hns3_mp.c | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index a2676f84b0..d245c5db8b 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -4749,6 +4749,7 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) { rte_free(eth_dev->process_private); eth_dev->process_private = NULL; + __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); return; } @@ -5437,8 +5438,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) "process, ret = %d", ret); goto err_mp_init_secondary; } - - hw->secondary_cnt++; + __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); return 0; } @@ -5551,6 +5551,7 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) { rte_free(eth_dev->process_private); eth_dev->process_private = NULL; + __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); return 0; } diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 790e76a0db..972a6f00e4 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1653,6 +1653,8 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) { rte_free(eth_dev->process_private); + eth_dev->process_private = NULL; + __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); return; } @@ -2291,8 +2293,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) "process, ret = %d", ret); goto err_mp_init_secondary; } - - hw->secondary_cnt++; + __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); return 0; } @@ -2386,6 +2387,7 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) { rte_free(eth_dev->process_private); eth_dev->process_private = NULL; + __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); return 0; } diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c index a03f2cf13c..9b5ff475a9 100644 --- a/drivers/net/hns3/hns3_mp.c +++ b/drivers/net/hns3/hns3_mp.c @@ -132,7 +132,8 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum hns3_mp_req_type type) int ret; int i; - if (rte_eal_process_type() == RTE_PROC_SECONDARY || !hw->secondary_cnt) + if (rte_eal_process_type() == RTE_PROC_SECONDARY || + __atomic_load_n(&hw->secondary_cnt, __ATOMIC_RELAXED) == 0) return; if (type != HNS3_MP_REQ_START_RXTX && type != HNS3_MP_REQ_STOP_RXTX) { hns3_err(hw, "port %u unknown request (req_type %d)", -- 2.33.0