[{"id":1797626,"web_url":"http://patchwork.ozlabs.org/comment/1797626/","msgid":"<18549b04-468a-02c6-209a-15fd939bf4b6@huawei.com>","list_archive_url":null,"date":"2017-11-02T03:31:32","subject":"Re: [PATCH net-next 3/9] net: hns3: Refactor the initialization of\n\tcommand queue","submitter":{"id":71804,"url":"http://patchwork.ozlabs.org/api/people/71804/","name":"Yunsheng Lin","email":"linyunsheng@huawei.com"},"content":"Hi, Lipeng\n\nOn 2017/11/1 22:47, Lipeng wrote:\n> From: qumingguang <qumingguang@huawei.com>\n> \n> There is no necessary to reallocate the descriptor and remap the descriptor\n> memory in reset process, But there is still some other action exit in both\n\nexit -> exist\n\n> reset process and initialization process.\n> \n> To reuse the common interface of reset process and initialization process,\n\nof -> in\n\n> This patch moved out the descriptor allocate and memory maping from\n\nThis -> this, moved -> moves\n\n> interface cmdq_init.\n> \n> Signed-off-by: qumingguang <qumingguang@huawei.com>\n> Signed-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(-)\n> \n> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c\n> index 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)\n> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h\n> index 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\n> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c\n> index 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>","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 3yS9dC6wt8z9t34\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu,  2 Nov 2017 14:32:31 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S934140AbdKBDcU (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 1 Nov 2017 23:32:20 -0400","from szxga05-in.huawei.com ([45.249.212.191]:9997 \"EHLO\n\tszxga05-in.huawei.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S934030AbdKBDcT (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 1 Nov 2017 23:32:19 -0400","from 172.30.72.58 (EHLO DGGEMS405-HUB.china.huawei.com)\n\t([172.30.72.58])\n\tby dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued)\n\twith ESMTP id DKG59735; Thu, 02 Nov 2017 11:32:13 +0800 (CST)","from [127.0.0.1] (10.74.191.121) by DGGEMS405-HUB.china.huawei.com\n\t(10.3.19.205) with Microsoft SMTP Server id 14.3.361.1;\n\tThu, 2 Nov 2017 11:31:43 +0800"],"Subject":"Re: [PATCH net-next 3/9] net: hns3: Refactor the initialization of\n\tcommand queue","To":"Lipeng <lipeng321@huawei.com>, <davem@davemloft.net>","CC":"<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,\n\t<linuxarm@huawei.com>","References":"<1509547642-51110-1-git-send-email-lipeng321@huawei.com>\n\t<1509547642-51110-4-git-send-email-lipeng321@huawei.com>","From":"Yunsheng Lin <linyunsheng@huawei.com>","Message-ID":"<18549b04-468a-02c6-209a-15fd939bf4b6@huawei.com>","Date":"Thu, 2 Nov 2017 11:31:32 +0800","User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.0","MIME-Version":"1.0","In-Reply-To":"<1509547642-51110-4-git-send-email-lipeng321@huawei.com>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Originating-IP":"[10.74.191.121]","X-CFilter-Loop":"Reflected","X-Mirapoint-Virus-RAPID-Raw":"score=unknown(0),\n\trefid=str=0001.0A020205.59FA91BE.00EE, ss=1, re=0.000, recu=0.000,\n\treip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0,\n\tso=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32","X-Mirapoint-Loop-Id":"c9b99210af1cb8e6241766165071de66","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"}}]