From patchwork Wed Jul 27 10:36:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 114274 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru 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 0B182A00C4; Wed, 27 Jul 2022 12:37:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C3CD42B70; Wed, 27 Jul 2022 12:37:28 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 772FD40F19; Wed, 27 Jul 2022 12:37:26 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Lt9Bb59lMz1M8Gb; Wed, 27 Jul 2022 18:34:31 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 18:37:24 +0800 From: Dongdong Liu To: , , , CC: , Chengwen Feng , Dongdong Liu , Yisen Zhuang , Anatoly Burakov , Ferruh Yigit , Huisong Li , "Wei Hu (Xavier)" , Hao Chen , "Min Hu (Connor)" Subject: [PATCH 5/8] net/hns3: fix segment fault when secondary process access FW Date: Wed, 27 Jul 2022 18:36:13 +0800 Message-ID: <20220727103616.18596-6-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220727103616.18596-1-liudongdong3@huawei.com> References: <20220727103616.18596-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500017.china.huawei.com (7.221.188.110) 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: Chengwen Feng Currently, to prevent missing reporting of reset interrupts and quickly identify reset interrupts, the following logic is designed in the FW (firmware) command interface hns3_cmd_send: if an unprocessed interrupt exist (by checking reset registers), related reset task is scheduled. The secondary process may invoke the hns3_cmd_send interface (e.g. using proc-info query some stats). Unfortunately, the secondary process does not support reset processing, and a segment fault may occur if it schedules reset task. This patch fixes it by limit the checking and scheduling of reset under only primary process. Fixes: 2790c6464725 ("net/hns3: support device reset") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_ethdev.c | 10 +++++++++- drivers/net/hns3/hns3_ethdev_vf.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 6b1d1a5fb1..aedd17ef26 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -5601,7 +5601,15 @@ hns3_is_reset_pending(struct hns3_adapter *hns) struct hns3_hw *hw = &hns->hw; enum hns3_reset_level reset; - hns3_check_event_cause(hns, NULL); + /* + * Check the registers to confirm whether there is reset pending. + * Note: This check may lead to schedule reset task, but only primary + * process can process the reset event. Therefore, limit the + * checking under only primary process. + */ + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + hns3_check_event_cause(hns, NULL); + reset = hns3_get_reset_level(hns, &hw->reset.pending); if (reset != HNS3_NONE_RESET && hw->reset.level != HNS3_NONE_RESET && hw->reset.level < reset) { diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 18504e6926..f3167523cf 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1863,8 +1863,15 @@ hns3vf_is_reset_pending(struct hns3_adapter *hns) if (hw->reset.level == HNS3_VF_FULL_RESET) return false; - /* Check the registers to confirm whether there is reset pending */ - hns3vf_check_event_cause(hns, NULL); + /* + * Check the registers to confirm whether there is reset pending. + * Note: This check may lead to schedule reset task, but only primary + * process can process the reset event. Therefore, limit the + * checking under only primary process. + */ + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + hns3vf_check_event_cause(hns, NULL); + reset = hns3vf_get_reset_level(hw, &hw->reset.pending); if (hw->reset.level != HNS3_NONE_RESET && reset != HNS3_NONE_RESET && hw->reset.level < reset) {