From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E01BEA0559; Tue, 17 Mar 2020 10:25:17 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4E02F1C0C2; Tue, 17 Mar 2020 10:24:29 +0100 (CET) Received: from incedge.chinasoftinc.com (unknown [114.113.233.8]) by dpdk.org (Postfix) with ESMTP id 9DDF71C025 for ; Tue, 17 Mar 2020 10:24:23 +0100 (CET) X-ASG-Debug-ID: 1584436944-0a3dd134b0001f0007-TfluYd Received: from mail.chinasoftinc.com (inccas001.ito.icss [10.168.0.51]) by incedge.chinasoftinc.com with ESMTP id eyXcfDvlUrNv3DmC (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 17 Mar 2020 17:23:05 +0800 (CST) X-Barracuda-Envelope-From: huwei013@chinasoftinc.com X-Barracuda-RBL-Trusted-Forwarder: 10.168.0.51 X-ASG-Whitelist: Client Received: from localhost.localdomain (114.119.4.74) by INCCAS001.ito.icss (10.168.0.60) with Microsoft SMTP Server id 14.3.487.0; Tue, 17 Mar 2020 17:13:15 +0800 From: "Wei Hu (Xavier)" X-Barracuda-RBL-Trusted-Forwarder: 10.168.0.60 To: Date: Tue, 17 Mar 2020 17:12:06 +0800 X-ASG-Orig-Subj: [PATCH 7/7] net/hns3: fix abnormal status after reset occurs repeatedly Message-ID: <20200317091206.34928-8-huwei013@chinasoftinc.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200317091206.34928-1-huwei013@chinasoftinc.com> References: <20200317091206.34928-1-huwei013@chinasoftinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [114.119.4.74] X-Barracuda-Connect: inccas001.ito.icss[10.168.0.51] X-Barracuda-Start-Time: 1584436984 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA X-Barracuda-URL: https://incspam.chinasofti.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at chinasoftinc.com X-Barracuda-Scan-Msg-Size: 4773 Subject: [dpdk-dev] [PATCH 7/7] net/hns3: fix abnormal status after reset occurs repeatedly X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: "Wei Hu (Xavier)" Currently, when performing the following test case: 1. Run testpmd application based on hns3 PF device. 2. Inject reset(global/IMP reset) repeatedly. After the reset, the network port can't link up. In the RESET_STAGE_DEV_INIT stage of the reset process, the driver will reinitialize the hardware. If global/IMP reset occurs at this time again, the operation of reinitialize the hardware will fail because that firmware don't respond to the configuration commands issued by driver. In current driver, when failed to reinitialize the hardware, rollback operation is done, such as clearing the relevant configuration of the command queue registers. If firmware detects that the function's command queue register is not configured correctly, it will not complete the reset related hardware configuration for this function, resulting in that driver can't detect that the hardware reset has been completed. And then the reset process of the driver exit abnormally, the hardware can not work normally after reset. This patch fixes it by avoid clearing the command queue related registers when failed to reinitialize the hardware in the RESET_STAGE_DEV_INIT stage of the reset process. Fixes: 2790c6464725 ("net/hns3: support device reset") Cc: stable@dpdk.org Signed-off-by: Hongbo Zheng Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chunsong Feng --- drivers/net/hns3/hns3_cmd.c | 2 +- drivers/net/hns3/hns3_ethdev.c | 18 ++++-------------- drivers/net/hns3/hns3_ethdev_vf.c | 16 ++++------------ 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c index c85168b31..c7993634e 100644 --- a/drivers/net/hns3/hns3_cmd.c +++ b/drivers/net/hns3/hns3_cmd.c @@ -529,7 +529,7 @@ hns3_cmd_init(struct hns3_hw *hw) return 0; err_cmd_init: - hns3_cmd_uninit(hw); + rte_atomic16_set(&hw->reset.disable_cmd, 1); return ret; } diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 0d0f5ebb7..1d57de7f9 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -4126,13 +4126,10 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) rte_intr_disable(&pci_dev->intr_handle); hns3_intr_unregister(&pci_dev->intr_handle, hns3_interrupt_handler, eth_dev); - err_intr_callback_register: - hns3_cmd_uninit(hw); - err_cmd_init: + hns3_cmd_uninit(hw); hns3_cmd_destroy_queue(hw); - err_cmd_init_queue: hw->io_base = NULL; @@ -4610,31 +4607,24 @@ hns3_reinit_dev(struct hns3_adapter *hns) ret = hns3_reset_all_queues(hns); if (ret) { hns3_err(hw, "Failed to reset all queues: %d", ret); - goto err_init; + return ret; } ret = hns3_init_hardware(hns); if (ret) { hns3_err(hw, "Failed to init hardware: %d", ret); - goto err_init; + return ret; } ret = hns3_enable_hw_error_intr(hns, true); if (ret) { hns3_err(hw, "fail to enable hw error interrupts: %d", ret); - goto err_mac_init; + return ret; } hns3_info(hw, "Reset done, driver initialization finished."); return 0; - -err_mac_init: - hns3_uninit_umv_space(hw); -err_init: - hns3_cmd_uninit(hw); - - return ret; } static bool diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 1c508f06a..2e8acfee3 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1486,11 +1486,9 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) hns3_intr_unregister(&pci_dev->intr_handle, hns3vf_interrupt_handler, eth_dev); err_intr_callback_register: - hns3_cmd_uninit(hw); - err_cmd_init: + hns3_cmd_uninit(hw); hns3_cmd_destroy_queue(hw); - err_cmd_init_queue: hw->io_base = NULL; @@ -2104,7 +2102,7 @@ hns3vf_reinit_dev(struct hns3_adapter *hns) ret = hns3_cmd_init(hw); if (ret) { hns3_err(hw, "Failed to init cmd: %d", ret); - goto err_cmd_init; + return ret; } if (hw->reset.level == HNS3_VF_FULL_RESET) { @@ -2124,22 +2122,16 @@ hns3vf_reinit_dev(struct hns3_adapter *hns) ret = hns3_reset_all_queues(hns); if (ret) { hns3_err(hw, "Failed to reset all queues: %d", ret); - goto err_init; + return ret; } ret = hns3vf_init_hardware(hns); if (ret) { hns3_err(hw, "Failed to init hardware: %d", ret); - goto err_init; + return ret; } return 0; - -err_cmd_init: - hns3vf_set_bus_master(pci_dev, false); -err_init: - hns3_cmd_uninit(hw); - return ret; } static const struct eth_dev_ops hns3vf_eth_dev_ops = { -- 2.23.0