From patchwork Fri Dec 8 07:44:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 134954 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 1C5A6436A6; Fri, 8 Dec 2023 08:48:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B01C142FD7; Fri, 8 Dec 2023 08:48:03 +0100 (CET) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id 65D1B42E8D for ; Fri, 8 Dec 2023 08:47:59 +0100 (CET) Received: from kwepemd100004.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Smjt35jXJz14L4m for ; Fri, 8 Dec 2023 15:47:55 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemd100004.china.huawei.com (7.221.188.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Fri, 8 Dec 2023 15:47:57 +0800 From: Jie Hai To: , Yisen Zhuang , Dengdui Huang CC: , , , Subject: [PATCH v3 3/3] net/hns3: fix incorrect reset level comparison Date: Fri, 8 Dec 2023 15:44:16 +0800 Message-ID: <20231208074416.2890279-4-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231208074416.2890279-1-haijie1@huawei.com> References: <20231111015915.2776769-1-haijie1@huawei.com> <20231208074416.2890279-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd100004.china.huawei.com (7.221.188.31) 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 Currently, there are two problems in hns3vf_is_reset_pending(): 1. The new detect reset level is not HNS3_NONE_RESET, but the last reset level is HNS3_NONE_RESET, this function returns false. 2. Comparison between last_req and new_req is opposite. In addition, the reset level comparison in hns3_detect_reset_event() is similar to the hns3vf_is_reset_pending(). So this patch fixes above the problems and merges the logic of reset level comparison. Fixes: 5be38fc6c0fc ("net/hns3: fix multiple reset detected log") Cc: stable@dpdk.org Signed-off-by: Dengdui Huang Signed-off-by: Jie Hai --- drivers/net/hns3/hns3_ethdev.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 76fc401bd62c..b8f7e408d1e0 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -5545,27 +5545,15 @@ is_pf_reset_done(struct hns3_hw *hw) static enum hns3_reset_level hns3_detect_reset_event(struct hns3_hw *hw) { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); enum hns3_reset_level new_req = HNS3_NONE_RESET; - enum hns3_reset_level last_req; uint32_t vector0_intr_state; - last_req = hns3_get_reset_level(hns, &hw->reset.pending); vector0_intr_state = hns3_read_dev(hw, HNS3_VECTOR0_OTHER_INT_STS_REG); if (BIT(HNS3_VECTOR0_IMPRESET_INT_B) & vector0_intr_state) new_req = HNS3_IMP_RESET; else if (BIT(HNS3_VECTOR0_GLOBALRESET_INT_B) & vector0_intr_state) new_req = HNS3_GLOBAL_RESET; - if (new_req == HNS3_NONE_RESET) - return HNS3_NONE_RESET; - - if (last_req == HNS3_NONE_RESET || last_req < new_req) { - __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); - hns3_schedule_delayed_reset(hns); - hns3_warn(hw, "High level reset detected, delay do reset"); - } - return new_req; } @@ -5584,10 +5572,14 @@ hns3_is_reset_pending(struct hns3_adapter *hns) return false; new_req = hns3_detect_reset_event(hw); + if (new_req == HNS3_NONE_RESET) + return false; + last_req = hns3_get_reset_level(hns, &hw->reset.pending); - if (last_req != HNS3_NONE_RESET && new_req != HNS3_NONE_RESET && - new_req < last_req) { - hns3_warn(hw, "High level reset %d is pending", last_req); + if (last_req == HNS3_NONE_RESET || last_req < new_req) { + __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); + hns3_schedule_delayed_reset(hns); + hns3_warn(hw, "High level reset detected, delay do reset"); return true; } last_req = hns3_get_reset_level(hns, &hw->reset.request);