Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp659541imm; Fri, 29 Jun 2018 04:23:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI3EDiQu7Coe9y+nty6MpZhUvabaf7MF9qAJjO3+x34dLla80/gWt0T+LpD6KRPLCfAierP X-Received: by 2002:a63:7b1b:: with SMTP id w27-v6mr11791173pgc.199.1530271381364; Fri, 29 Jun 2018 04:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530271381; cv=none; d=google.com; s=arc-20160816; b=jf33jD1vBumW5bc61mOSG6LTX233GLBE5MzZ/A+HoGeosF9EpUWW3+KzyU/vok+i38 vv2yjjeg6cgWz4OHb3YCrb0rui6ZhtX5SBCzSRqy5EFk0ala0aQRGaqanLdXrK6mRXMy RHcJz92ylSJaDd4UVGwCk/aeCmn4+On3+1sFz5eAICcCBxb95YLSAFQBq/ZfIf+KXexL ZvVmWbqDUPnv5A6mxlkaPnRZy1sWNXTTBIAQEh8KEDZ/2+iQixtxfiluCDLXGwvDbBCG Xe9GCcNTkhnL6lhX4vf1owAcmcC8k0hg96ATwXAlMJOn8WHf3b8zGCE9Y4vGVjwTox/a n/Mw== 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=x+ubLdz1eSvg7Ij1ye9VecSIRJoz5db3Nm1PFtQX05hAlanYmw2eBWc6zFeyZJ/c69 O4rM1F95Tja5OLQjoc8YXgOp1dBvnRRJiXkM1W4lCkN/8mOfWrDl/AVRzXWR/34AS37K xlbyw/8C6HiF1A0xKpbidzeprurjllVQOpuw445LVaoVtXv3lUUu5NmV3lBjQs2ZNges +GmXh2vaS+OUF7VfiyaeB+wvCafE4k31bXS7OfmBOz8eagYLWKyO0iMGTHDEh/jX6XAt 792h5+87ZoFxS2P721o32s49FgiN5KPJjVvoZ1TyyoV3Nj3JHiVNx2onfBUNsiGNWS+E s2RA== 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 p1-v6si8792755pld.218.2018.06.29.04.22.46; Fri, 29 Jun 2018 04:23:01 -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 S1753441AbeF2Kyj (ORCPT + 99 others); Fri, 29 Jun 2018 06:54:39 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:59877 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750761AbeF2Kyi (ORCPT ); Fri, 29 Jun 2018 06:54:38 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id EF7C6EBE85CF0; Fri, 29 Jun 2018 18:54:13 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.382.0; Fri, 29 Jun 2018 18:51:23 +0800 From: Peng Li To: CC: , , , , , Subject: [PATCH net-next 04/10] net: hns3: simplify hclge_cmd_csq_clean Date: Fri, 29 Jun 2018 19:22:59 +0800 Message-ID: <1530271385-49668-5-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530271385-49668-1-git-send-email-lipeng321@huawei.com> References: <1530271385-49668-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