Received: by 10.223.164.221 with SMTP id h29csp907023wrb; Wed, 1 Nov 2017 07:22:34 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SoKGECLr5iq2+I36puh1jom91wiNSYYtfmY8aw/efAgQd63XPlB4PmV4GHoG/D/p82h63m X-Received: by 10.98.212.70 with SMTP id u6mr7125238pfl.321.1509546154217; Wed, 01 Nov 2017 07:22:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509546154; cv=none; d=google.com; s=arc-20160816; b=mugG7Oxl2nXrfwgHFh0U2VWIBnbO6bKPMxHDWSfS16pjcXnF5XG0nhMpCzWztnZ47J Bpv0P/S5sXYNDN44UWLq0ln9OwenmIUEnVdYD0UP6uV4IPe/vt5Qgz2Ea9HT0Cavkyfv T5rZRzT2Pu5iTZ+oeYHSW9hZHtCQyVpJ5m/4HcGdzHXkcHMU61ZQlH9nGL/K+J7VcSmY 4f3fAtqGx/P3YzjT664gNOoxT5JICG3V58aLYeS4gRdZL5M+tAnV7Hv427Hy4Zy126o3 o+aKXRXwpL7Fm8FgP4H4mJ/K7tAYvDJQ7qe8nOMRD4UN7GkI1iIHGBMJH0enbkajQH2Q 6zjw== 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=9uC4YoQXYVuhL0p5imm9gqwRKu6BV2Fp9DSHPRNeHxQ=; b=0SBvslIEgWEqbMGMm5eyp555uIpWicmdbB+w8V9Fl1kKWR9Tm2wILFeKNnvDbxsOij H47pH7x7ixEdsP8APrw359/rGdK383zJlYcDnXJyZXVbWbdGsQUo217+51ufz0VSxE2r opAfBuO+4NJaiLOoZKjRB2v4ShjJmSNMeuPCOrDkgzWeiule7/mnwpz5VcnMo1NgZpdQ 9nUfzjblvziPoJpUePR8La60YQm1IvISgtrHpiky+wVhikOj2f9n9yvfLyVCORRcVRFu mhqbQK2LgkR8xp+LDm5YWjpLmgWNrm0WZK2n0pQwOZM7JE8yjynzlxRpdrlszq/6Yrtl NTXA== 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 26si1071859pfp.127.2017.11.01.07.22.20; Wed, 01 Nov 2017 07:22:34 -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 S1754819AbdKAOVa (ORCPT + 99 others); Wed, 1 Nov 2017 10:21:30 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:38453 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754707AbdKAOVO (ORCPT ); Wed, 1 Nov 2017 10:21:14 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 2605B7DF27D73; Wed, 1 Nov 2017 22:20:59 +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.361.1; Wed, 1 Nov 2017 22:19:49 +0800 From: Lipeng To: CC: , , , , , Subject: [PATCH net-next 3/9] net: hns3: Refactor the initialization of command queue Date: Wed, 1 Nov 2017 22:47:16 +0800 Message-ID: <1509547642-51110-4-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509547642-51110-1-git-send-email-lipeng321@huawei.com> References: <1509547642-51110-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: qumingguang There is no necessary to reallocate the descriptor and remap the descriptor memory in reset process, But there is still some other action exit in both reset process and initialization process. To reuse the common interface of reset process and initialization process, This patch moved out the descriptor allocate and memory maping from interface cmdq_init. Signed-off-by: qumingguang Signed-off-by: Lipeng --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 39 +++++++++++++--------- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 1 + .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 9 ++++- 3 files changed, 33 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 60960e5..ff13d18 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c @@ -62,7 +62,7 @@ static void hclge_free_cmd_desc(struct hclge_cmq_ring *ring) ring->desc = NULL; } -static int hclge_init_cmd_queue(struct hclge_dev *hdev, int ring_type) +static int hclge_alloc_cmd_queue(struct hclge_dev *hdev, int ring_type) { struct hclge_hw *hw = &hdev->hw; struct hclge_cmq_ring *ring = @@ -79,9 +79,6 @@ static int hclge_init_cmd_queue(struct hclge_dev *hdev, int ring_type) return ret; } - ring->next_to_clean = 0; - ring->next_to_use = 0; - return 0; } @@ -302,37 +299,52 @@ static enum hclge_cmd_status hclge_cmd_query_firmware_version( return ret; } -int hclge_cmd_init(struct hclge_dev *hdev) +int hclge_cmd_queue_init(struct hclge_dev *hdev) { - u32 version; int ret; /* Setup the queue entries for use cmd queue */ hdev->hw.cmq.csq.desc_num = HCLGE_NIC_CMQ_DESC_NUM; hdev->hw.cmq.crq.desc_num = HCLGE_NIC_CMQ_DESC_NUM; - /* Setup the lock for command queue */ - spin_lock_init(&hdev->hw.cmq.csq.lock); - spin_lock_init(&hdev->hw.cmq.crq.lock); - /* Setup Tx write back timeout */ hdev->hw.cmq.tx_timeout = HCLGE_CMDQ_TX_TIMEOUT; /* Setup queue rings */ - ret = hclge_init_cmd_queue(hdev, HCLGE_TYPE_CSQ); + ret = hclge_alloc_cmd_queue(hdev, HCLGE_TYPE_CSQ); if (ret) { dev_err(&hdev->pdev->dev, "CSQ ring setup error %d\n", ret); return ret; } - ret = hclge_init_cmd_queue(hdev, HCLGE_TYPE_CRQ); + ret = hclge_alloc_cmd_queue(hdev, HCLGE_TYPE_CRQ); if (ret) { dev_err(&hdev->pdev->dev, "CRQ ring setup error %d\n", ret); goto err_csq; } + return 0; +err_csq: + hclge_free_cmd_desc(&hdev->hw.cmq.csq); + return ret; +} + +int hclge_cmd_init(struct hclge_dev *hdev) +{ + u32 version; + int ret; + + hdev->hw.cmq.csq.next_to_clean = 0; + hdev->hw.cmq.csq.next_to_use = 0; + hdev->hw.cmq.crq.next_to_clean = 0; + hdev->hw.cmq.crq.next_to_use = 0; + + /* Setup the lock for command queue */ + spin_lock_init(&hdev->hw.cmq.csq.lock); + spin_lock_init(&hdev->hw.cmq.crq.lock); + hclge_cmd_init_regs(&hdev->hw); ret = hclge_cmd_query_firmware_version(&hdev->hw, &version); @@ -346,9 +358,6 @@ int hclge_cmd_init(struct hclge_dev *hdev) dev_info(&hdev->pdev->dev, "The firmware version is %08x\n", version); return 0; -err_csq: - hclge_free_cmd_desc(&hdev->hw.cmq.csq); - return ret; } static void hclge_destroy_queue(struct hclge_cmq_ring *ring) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h index b437334..6bdc216 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h @@ -750,4 +750,5 @@ enum hclge_cmd_status hclge_cmd_mdio_read(struct hclge_hw *hw, struct hclge_desc *desc); void hclge_destroy_cmd_queue(struct hclge_hw *hw); +int hclge_cmd_queue_init(struct hclge_dev *hdev); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 4ef4592..a7686fe 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -4446,7 +4446,14 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) goto err_pci_init; } - /* Command queue initialize */ + /* Firmware command queue initialize */ + ret = hclge_cmd_queue_init(hdev); + if (ret) { + dev_err(&pdev->dev, "Cmd queue init failed\n"); + return ret; + } + + /* Firmware command initialize */ ret = hclge_cmd_init(hdev); if (ret) goto err_cmd_init; -- 1.9.1 From 1583309492852827941@xxx Mon Nov 06 09:46:38 +0000 2017 X-GM-THRID: 1583309492852827941 X-Gmail-Labels: Inbox,Category Promotions,HistoricalUnread