{"id":832956,"url":"http://patchwork.ozlabs.org/api/1.2/patches/832956/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/1509547642-51110-4-git-send-email-lipeng321@huawei.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1509547642-51110-4-git-send-email-lipeng321@huawei.com>","list_archive_url":null,"date":"2017-11-01T14:47:16","name":"[net-next,3/9] net: hns3: Refactor the initialization of command queue","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":true,"hash":"e70453e10dffc16e783fab6e6147800076b2b16e","submitter":{"id":71468,"url":"http://patchwork.ozlabs.org/api/1.2/people/71468/?format=json","name":"lipeng (Y)","email":"lipeng321@huawei.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/1509547642-51110-4-git-send-email-lipeng321@huawei.com/mbox/","series":[{"id":11334,"url":"http://patchwork.ozlabs.org/api/1.2/series/11334/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=11334","date":"2017-11-01T14:47:14","name":"net: hns3: add support for reset","version":1,"mbox":"http://patchwork.ozlabs.org/series/11334/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/832956/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/832956/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yRr4l08qrz9sPs\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu,  2 Nov 2017 01:21:42 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1754811AbdKAOVa (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 1 Nov 2017 10:21:30 -0400","from szxga06-in.huawei.com ([45.249.212.32]:38453 \"EHLO huawei.com\"\n\trhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP\n\tid S1754707AbdKAOVO (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tWed, 1 Nov 2017 10:21:14 -0400","from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59])\n\tby Forcepoint Email with ESMTP id 2605B7DF27D73;\n\tWed,  1 Nov 2017 22:20:59 +0800 (CST)","from linux-ioko.site (10.71.200.31) by\n\tDGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP\n\tServer id 14.3.361.1; Wed, 1 Nov 2017 22:19:49 +0800"],"From":"Lipeng <lipeng321@huawei.com>","To":"<davem@davemloft.net>","CC":"<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,\n\t<linuxarm@huawei.com>, <yisen.zhuang@huawei.com>,\n\t<salil.mehta@huawei.com>, <lipeng321@huawei.com>","Subject":"[PATCH net-next 3/9] net: hns3: Refactor the initialization of\n\tcommand 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":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"From: qumingguang <qumingguang@huawei.com>\n\nThere is no necessary to reallocate the descriptor and remap the descriptor\nmemory in reset process, But there is still some other action exit in both\nreset process and initialization process.\n\nTo reuse the common interface of reset process and initialization process,\nThis patch moved out the descriptor allocate and memory maping from\ninterface cmdq_init.\n\nSigned-off-by: qumingguang <qumingguang@huawei.com>\nSigned-off-by: Lipeng <lipeng321@huawei.com>\n---\n .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 39 +++++++++++++---------\n .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h |  1 +\n .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c    |  9 ++++-\n 3 files changed, 33 insertions(+), 16 deletions(-)","diff":"diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c\nindex 60960e5..ff13d18 100644\n--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c\n+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c\n@@ -62,7 +62,7 @@ static void hclge_free_cmd_desc(struct hclge_cmq_ring *ring)\n \tring->desc = NULL;\n }\n \n-static int hclge_init_cmd_queue(struct hclge_dev *hdev, int ring_type)\n+static int hclge_alloc_cmd_queue(struct hclge_dev *hdev, int ring_type)\n {\n \tstruct hclge_hw *hw = &hdev->hw;\n \tstruct hclge_cmq_ring *ring =\n@@ -79,9 +79,6 @@ static int hclge_init_cmd_queue(struct hclge_dev *hdev, int ring_type)\n \t\treturn ret;\n \t}\n \n-\tring->next_to_clean = 0;\n-\tring->next_to_use = 0;\n-\n \treturn 0;\n }\n \n@@ -302,37 +299,52 @@ static enum hclge_cmd_status hclge_cmd_query_firmware_version(\n \treturn ret;\n }\n \n-int hclge_cmd_init(struct hclge_dev *hdev)\n+int hclge_cmd_queue_init(struct hclge_dev *hdev)\n {\n-\tu32 version;\n \tint ret;\n \n \t/* Setup the queue entries for use cmd queue */\n \thdev->hw.cmq.csq.desc_num = HCLGE_NIC_CMQ_DESC_NUM;\n \thdev->hw.cmq.crq.desc_num = HCLGE_NIC_CMQ_DESC_NUM;\n \n-\t/* Setup the lock for command queue */\n-\tspin_lock_init(&hdev->hw.cmq.csq.lock);\n-\tspin_lock_init(&hdev->hw.cmq.crq.lock);\n-\n \t/* Setup Tx write back timeout */\n \thdev->hw.cmq.tx_timeout = HCLGE_CMDQ_TX_TIMEOUT;\n \n \t/* Setup queue rings */\n-\tret = hclge_init_cmd_queue(hdev, HCLGE_TYPE_CSQ);\n+\tret = hclge_alloc_cmd_queue(hdev, HCLGE_TYPE_CSQ);\n \tif (ret) {\n \t\tdev_err(&hdev->pdev->dev,\n \t\t\t\"CSQ ring setup error %d\\n\", ret);\n \t\treturn ret;\n \t}\n \n-\tret = hclge_init_cmd_queue(hdev, HCLGE_TYPE_CRQ);\n+\tret = hclge_alloc_cmd_queue(hdev, HCLGE_TYPE_CRQ);\n \tif (ret) {\n \t\tdev_err(&hdev->pdev->dev,\n \t\t\t\"CRQ ring setup error %d\\n\", ret);\n \t\tgoto err_csq;\n \t}\n \n+\treturn 0;\n+err_csq:\n+\thclge_free_cmd_desc(&hdev->hw.cmq.csq);\n+\treturn ret;\n+}\n+\n+int hclge_cmd_init(struct hclge_dev *hdev)\n+{\n+\tu32 version;\n+\tint ret;\n+\n+\thdev->hw.cmq.csq.next_to_clean = 0;\n+\thdev->hw.cmq.csq.next_to_use = 0;\n+\thdev->hw.cmq.crq.next_to_clean = 0;\n+\thdev->hw.cmq.crq.next_to_use = 0;\n+\n+\t/* Setup the lock for command queue */\n+\tspin_lock_init(&hdev->hw.cmq.csq.lock);\n+\tspin_lock_init(&hdev->hw.cmq.crq.lock);\n+\n \thclge_cmd_init_regs(&hdev->hw);\n \n \tret = hclge_cmd_query_firmware_version(&hdev->hw, &version);\n@@ -346,9 +358,6 @@ int hclge_cmd_init(struct hclge_dev *hdev)\n \tdev_info(&hdev->pdev->dev, \"The firmware version is %08x\\n\", version);\n \n \treturn 0;\n-err_csq:\n-\thclge_free_cmd_desc(&hdev->hw.cmq.csq);\n-\treturn ret;\n }\n \n static void hclge_destroy_queue(struct hclge_cmq_ring *ring)\ndiff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h\nindex b437334..6bdc216 100644\n--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h\n+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h\n@@ -750,4 +750,5 @@ enum hclge_cmd_status hclge_cmd_mdio_read(struct hclge_hw *hw,\n \t\t\t\t\t  struct hclge_desc *desc);\n \n void hclge_destroy_cmd_queue(struct hclge_hw *hw);\n+int hclge_cmd_queue_init(struct hclge_dev *hdev);\n #endif\ndiff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c\nindex 4ef4592..a7686fe 100644\n--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c\n+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c\n@@ -4446,7 +4446,14 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)\n \t\tgoto err_pci_init;\n \t}\n \n-\t/* Command queue initialize */\n+\t/* Firmware command queue initialize */\n+\tret = hclge_cmd_queue_init(hdev);\n+\tif (ret) {\n+\t\tdev_err(&pdev->dev, \"Cmd queue init failed\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\t/* Firmware command initialize */\n \tret = hclge_cmd_init(hdev);\n \tif (ret)\n \t\tgoto err_cmd_init;\n","prefixes":["net-next","3/9"]}