{"id":833323,"url":"http://patchwork.ozlabs.org/api/1.2/patches/833323/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/1509626723-18619-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":"<1509626723-18619-4-git-send-email-lipeng321@huawei.com>","list_archive_url":null,"date":"2017-11-02T12:45:17","name":"[V2,net-next,3/9] net: hns3: Refactor the initialization of command queue","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"8d8fdd13f9d811af55678bc71de3b94147cf6e50","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/1509626723-18619-4-git-send-email-lipeng321@huawei.com/mbox/","series":[{"id":11493,"url":"http://patchwork.ozlabs.org/api/1.2/series/11493/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=11493","date":"2017-11-02T12:45:16","name":"net: hns3: add support for reset","version":2,"mbox":"http://patchwork.ozlabs.org/series/11493/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/833323/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/833323/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 3ySPLm1kpWz9ryT\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu,  2 Nov 2017 23:20:48 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1755337AbdKBMUe (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 2 Nov 2017 08:20:34 -0400","from szxga06-in.huawei.com ([45.249.212.32]:51497 \"EHLO huawei.com\"\n\trhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP\n\tid S1754837AbdKBMTH (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tThu, 2 Nov 2017 08:19:07 -0400","from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59])\n\tby Forcepoint Email with ESMTP id DC727C5F69D3;\n\tThu,  2 Nov 2017 20:18:50 +0800 (CST)","from linux-ioko.site (10.71.200.31) by\n\tDGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP\n\tServer id 14.3.361.1; Thu, 2 Nov 2017 20:17:47 +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>, <salil.mehta@huawei.com>, <lipeng321@huawei.com>","Subject":"[PATCH V2 net-next 3/9] net: hns3: Refactor the initialization of\n\tcommand queue","Date":"Thu, 2 Nov 2017 20:45:17 +0800","Message-ID":"<1509626723-18619-4-git-send-email-lipeng321@huawei.com>","X-Mailer":"git-send-email 1.9.1","In-Reply-To":"<1509626723-18619-1-git-send-email-lipeng321@huawei.com>","References":"<1509626723-18619-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":"There is no necessary to reallocate the descriptor and remap the descriptor\nmemory in reset process, But there is still some other action exist in both\nreset process and initialization process.\n\nTo reuse the common interface in reset process and initialization process,\nThis patch moves 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>\nSigned-off-by: Yunsheng Lin <linyunsheng@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 5daa8c7..cf0fafe 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, ret = %d.\\n\", ret);\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":["V2","net-next","3/9"]}