From patchwork Fri Oct 27 06:09:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133473 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 7D69743212; Fri, 27 Oct 2023 08:14:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D869A40A72; Fri, 27 Oct 2023 08:13:55 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id AF67D402AA for ; Fri, 27 Oct 2023 08:13:51 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SGsjW3GL9zrSn8; Fri, 27 Oct 2023 14:10:55 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 27 Oct 2023 14:13:50 +0800 From: Jie Hai To: , Yisen Zhuang , Chunsong Feng , Hao Chen , Huisong Li , Ferruh Yigit , "Min Hu (Connor)" CC: , , Subject: [PATCH 4/8] net/hns3: fix double stats for IMP and global reset Date: Fri, 27 Oct 2023 14:09:42 +0800 Message-ID: <20231027060947.3183983-5-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231027060947.3183983-1-haijie1@huawei.com> References: <20231027060947.3183983-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500020.china.huawei.com (7.221.188.8) 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: Dengdui Huang There is a stats counter for IMP and global reset in PF driver. hns3 driver has two following task to detect reset event: (1) interrupte handled task(A): triggered by interrupt and detect which reset level. And the reset service will be executed after 10us. (2) polling task(B): scan reset source register to detect if driver has to do reset. And the reset service will be executed after deferred 3s. They'll both count the number of one reset plus 1. Task(A) adds it before doing the reset service. And in the reset service, task(B) adds it if hw->reset.schedule is 'SCHEDULE_REQUESTED'. Normally, this reset counter is just added by 1 once. Unfortunately, this counter is added by 2 in the following case: 1. Task(B) detect the reset event, like IMP. hw->reset.schedule is set to 'SCHEDULE_REQUESTED'. 2. Task(A) is just triggered before running the reset service of task(B). Note: the reset counter is added by 1 at this moment before running the reset service of task(A). Additionally, the reset service of task(B) is canceled in task(A) because of schedule status being 'SCHEDULE_REQUESTED'. 3. Then the reset service of task(A) is executed at last. Note: The reset counter is added by 1 again in this step because of schedule status still being 'SCHEDULE_REQUESTED'. So this patch fix it by setting the scheduling status to 'SCHEDULE_REQUESTED' in step 2. Fixes: 2790c6464725 ("net/hns3: support device reset") Cc: stable@dpdk.org Signed-off-by: Dengdui Huang --- drivers/net/hns3/hns3_intr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c index 44a11194155a..baf5f58e9e2b 100644 --- a/drivers/net/hns3/hns3_intr.c +++ b/drivers/net/hns3/hns3_intr.c @@ -2434,8 +2434,8 @@ hns3_schedule_reset(struct hns3_adapter *hns) if (__atomic_load_n(&hw->reset.schedule, __ATOMIC_RELAXED) == SCHEDULE_DEFERRED) rte_eal_alarm_cancel(hw->reset.ops->reset_service, hns); - else - __atomic_store_n(&hw->reset.schedule, SCHEDULE_REQUESTED, + + __atomic_store_n(&hw->reset.schedule, SCHEDULE_REQUESTED, __ATOMIC_RELAXED); rte_eal_alarm_set(SWITCH_CONTEXT_US, hw->reset.ops->reset_service, hns);