Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3535517imm; Mon, 2 Jul 2018 00:27:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLtsqEBOiGhMVlHwe8RAmQ+Aya61ElF9ITy7mDqt+qI0e0Ild3foylZZMR9vkISeANM8vru X-Received: by 2002:a17:902:a508:: with SMTP id s8-v6mr25059607plq.223.1530516440264; Mon, 02 Jul 2018 00:27:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530516440; cv=none; d=google.com; s=arc-20160816; b=QADjqK6F1bqXxDvpP2ClQAotCtAfISllzxj9pfXSLOhTKFXiosP5sm8AeWyVY0y8cg Kwuj+fbqfTJj3YomDjPTMgbxUCp96eWXT+34oKemTJSF4ev6Uarrjs4oTTLAf36NQiD6 TyHnfsZO1eWtx+FiEOaLtIlOjpe05LVQ4Uuw8/JlTQYH/gJ+sQR15elPWHaBP6SmSXdS xr9qCKDEmYsIQMnmnktK7WEIzHVWeNGUTSaQBCjL3Lw2yyOL4aIR7aZWXub/o2Li3hqA oLMh9Ij3UbPKPaR9Dd0JU4K6qYkKofZVlc93pEZ8QqS7DoFC69alYxNCiz+Bq/nfdpOl FliQ== 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=creDSx181j3yPvgP0myd91aVz09eNeQxIhM0rwl7hP0=; b=W0GboHt1P5WssY/apJ/nZvZUCXwEBqLtCuDCPR3PiCDVpF8Y2txqBo9ogTNBAoZHQL adVFBPvB9VyuCpFKx1Jy8fGMgb5ZUjRYotPO0Pe3aP4wLuOWM2Cr7AhHXh5bnGKkPQ8c OeixURx9h0Jyg2RNsCdfpeBBebNoghWsZTlHlZtzP15awgoKSE5XUMQY55xsigb7ckZT u+dfwp1UDfbm18kANg+qImaCfCC4wjJqwAj5HaUDqACjLxnjT+ni5BE+v6ujm8Orohh1 WMzEasEaud3WRjiiVw4wuNpkBUfnP+81ou/9KVjWhevNJLRZ1vbbTJ+Xvva5lDo3towT 0RVg== 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 g6-v6si14909735pfh.346.2018.07.02.00.27.05; Mon, 02 Jul 2018 00:27:20 -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 S932288AbeGBHTN (ORCPT + 99 others); Mon, 2 Jul 2018 03:19:13 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9145 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752767AbeGBHTL (ORCPT ); Mon, 2 Jul 2018 03:19:11 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 59DBC40F3FD2A; Mon, 2 Jul 2018 15:18:57 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.382.0; Mon, 2 Jul 2018 15:18:50 +0800 From: Peng Li To: CC: , , , , , Subject: [PATCH V2 net-next 4/9] net: hns3: simplify hclge_cmd_csq_clean Date: Mon, 2 Jul 2018 15:50:21 +0800 Message-ID: <1530517826-69226-5-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530517826-69226-1-git-send-email-lipeng321@huawei.com> References: <1530517826-69226-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] 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 csq is used as a ring buffer, the value of the desc will be replaced in next use. This patch removes the unnecessary memset, and just updates the next_to_clean. Signed-off-by: Huazhong Tan Signed-off-by: Peng Li --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c index 054a913..0839e84 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c @@ -151,31 +151,20 @@ static int hclge_cmd_csq_clean(struct hclge_hw *hw) { struct hclge_dev *hdev = container_of(hw, struct hclge_dev, hw); struct hclge_cmq_ring *csq = &hw->cmq.csq; - u16 ntc = csq->next_to_clean; - struct hclge_desc *desc; - int clean = 0; u32 head; + int clean; - desc = &csq->desc[ntc]; head = hclge_read_dev(hw, HCLGE_NIC_CSQ_HEAD_REG); rmb(); /* Make sure head is ready before touch any data */ if (!is_valid_csq_clean_head(csq, head)) { - dev_warn(&hdev->pdev->dev, "wrong head (%d, %d-%d)\n", head, - csq->next_to_use, csq->next_to_clean); + dev_warn(&hdev->pdev->dev, "wrong cmd head (%d, %d-%d)\n", head, + csq->next_to_use, csq->next_to_clean); return 0; } - while (head != ntc) { - memset(desc, 0, sizeof(*desc)); - ntc++; - if (ntc == csq->desc_num) - ntc = 0; - desc = &csq->desc[ntc]; - clean++; - } - csq->next_to_clean = ntc; - + clean = (head - csq->next_to_clean + csq->desc_num) % csq->desc_num; + csq->next_to_clean = head; return clean; } -- 1.9.1