Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2475942imm; Mon, 16 Jul 2018 08:38:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdV+lq58pq3NZVlL0GQA5hnKZTtPdtN0J28qeue7hzkRPk0W/+1G/GNE7OMczP8Tlu+03Bb X-Received: by 2002:a65:468e:: with SMTP id h14-v6mr15423294pgr.89.1531755496792; Mon, 16 Jul 2018 08:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531755496; cv=none; d=google.com; s=arc-20160816; b=oHRyVJ4xOEaIfTdLB8jFzP/mlMso1CKXNNMVw7YsNWgxzkWqqo0GW16WJxuQtRSul4 vjc3hVfw4mDYhpFE76FXJfsUb4hfe6BB/dqpWLgXrIzXA70eovH8NpSl/TsaPngteu9B tGdufcpJmymy7RFDAiGfU4GJvypE2Y4728wJa/Bms+mOqW5dCqZmP7f6KZgScCh8Lk45 UiL75UjzE2Ze0WECvKYtU5lztgmWGvYKhgmrPNwSektQy5Qlo8+C0rThwNnQNAEtKelo ImQTcLjWNwC+fDm4UqbAKF5BH/B0vspT9g/gXKta5P3GuRSW6xGmp7m9ZX5Q2m9VDMPB 666w== 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 z125-v6si15899716pfz.10.2018.07.16.08.38.01; Mon, 16 Jul 2018 08:38:16 -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 S1728833AbeGPQFT (ORCPT + 99 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 Content-Type: text/plain 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(-) 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) -- 2.7.4