From patchwork Mon Jul 16 15:36:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 142030 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2568311ljj; Mon, 16 Jul 2018 08:37:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcmsTBRT7rysoaY8XqItfEIsmZI5jnc64xoV/Ya7u94eYUSAN4CUG2zCFWUUWD+xbtoKpOR X-Received: by 2002:a63:aa44:: with SMTP id x4-v6mr16263352pgo.120.1531755445232; Mon, 16 Jul 2018 08:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531755445; cv=none; d=google.com; s=arc-20160816; b=fAceOn0sP3J1xUEjGBsoANN6b4Y3s/drpdxmcy2ahETXfhOaHgCyBz3bA/pqAHND4A 0uYg9tjKMaRHtzweWYS+3VwGOmDa+uzm55cx8kulc6ih37bC2sio9c62gYVTfNYuxiSS ov4jAifB2zZNn9HNpYwTgxXBEt55gy1mva8tX/SZjBp9klFVi5nDJvZwUGMteCggur75 sag3Gd0AK12sqkwT7zAvuJpdScCzv4IuO4DgOUtKZg2UwLvJeTWyNFK0rvG/j/H34Cq9 Kq49zHk06iEzlNbPQkCX5vc7AZE66unVgqR7yRg3laX/IfzDIfrPMgdBChLCGelKI+TZ KTgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=n+o2RF3TpgKg1cnWCkYBCbVYu4cnzCDocFISmKMIm3I=; b=gIhZuhq+La/yPse/RCCjJTob55wRW01Uu00ly8rQ9LjdpTRyO9bqqNhoDMtlonPk4r WoWrHGZ3fUKimAK1h8t0uUsuQ3bAG1ZWBG1CxyqqhvhSGsjhrygbtGOm1wWcHrtP22Jw Do+pI4GRu/prlemOr5oyWFwdMVxFvJRZ+t/ZkCZuYS3x/s8+++P3pSeAG3WbIWz6lDt8 Q2CCoUR0/+eGoHpXmCu4fR1aamHLecYJDH2V9w+xG55Rt/S84LRlwL5DbeX9g6CeANlv 288iMBYhFPsn40ib5cOiPqHp6orOcoeP0G7OlOHSPb33S4CHeuP6klW1oJitxH/grVw/ vIog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k91-v6si31061405pld.248.2018.07.16.08.37.24; Mon, 16 Jul 2018 08:37:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729552AbeGPQFT (ORCPT + 31 others); Mon, 16 Jul 2018 12:05:19 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:46263 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727653AbeGPQFT (ORCPT ); Mon, 16 Jul 2018 12:05:19 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id AFF36F0AC063D; Mon, 16 Jul 2018 23:37:18 +0800 (CST) Received: from S00293818-DELL1.huawei.com (10.202.226.54) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.382.0; Mon, 16 Jul 2018 23:37:10 +0800 From: Salil Mehta To: CC: , , , , , , , Huazhong Tan Subject: [PATCH net-next 3/9] net: hns3: Prevent to request reset frequently Date: Mon, 16 Jul 2018 16:36:21 +0100 Message-ID: <20180716153627.476-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180716153627.476-1-salil.mehta@huawei.com> References: <20180716153627.476-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huazhong Tan Netdevice reset should not be requested frequently, a new one must wait a moment since there may be some work not completed. Signed-off-by: Huazhong Tan Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 3886290..a1886a3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2819,7 +2819,10 @@ static void hclge_clear_reset_cause(struct hclge_dev *hdev) static void hclge_reset(struct hclge_dev *hdev) { + struct hnae3_handle *handle; + /* perform reset of the stack & ae device for a client */ + handle = &hdev->vport[0].nic; rtnl_lock(); hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); @@ -2836,6 +2839,7 @@ static void hclge_reset(struct hclge_dev *hdev) } hclge_notify_client(hdev, HNAE3_UP_CLIENT); + handle->last_reset_time = jiffies; rtnl_unlock(); } @@ -2849,8 +2853,13 @@ static void hclge_reset_event(struct hnae3_handle *handle) * know this if last reset request did not occur very recently (watchdog * timer = 5*HZ, let us check after sufficiently large time, say 4*5*Hz) * In case of new request we reset the "reset level" to PF reset. + * And if it is a repeat reset request of the most recent one then we + * want to make sure we throttle the reset request. Therefore, we will + * not allow it again before 3*HZ times. */ - if (time_after(jiffies, (handle->last_reset_time + 4 * 5 * HZ))) + if (time_before(jiffies, (handle->last_reset_time + 3 * HZ))) + return; + else if (time_after(jiffies, (handle->last_reset_time + 4 * 5 * HZ))) handle->reset_level = HNAE3_FUNC_RESET; dev_info(&hdev->pdev->dev, "received reset event , reset type is %d", @@ -2862,8 +2871,6 @@ static void hclge_reset_event(struct hnae3_handle *handle) if (handle->reset_level < HNAE3_GLOBAL_RESET) handle->reset_level++; - - handle->last_reset_time = jiffies; } static void hclge_reset_subtask(struct hclge_dev *hdev)