{"id":815640,"url":"http://patchwork.ozlabs.org/api/patches/815640/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170919161716.92680-8-salil.mehta@huawei.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/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":"<20170919161716.92680-8-salil.mehta@huawei.com>","list_archive_url":null,"date":"2017-09-19T16:17:16","name":"[V2,net,7/7] net: hns3: Fixes the premature exit of loop when matching clients","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"b65dcabedd57678b59c42918e118b770249edc4f","submitter":{"id":67454,"url":"http://patchwork.ozlabs.org/api/people/67454/?format=json","name":"Salil Mehta","email":"salil.mehta@huawei.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170919161716.92680-8-salil.mehta@huawei.com/mbox/","series":[{"id":3921,"url":"http://patchwork.ozlabs.org/api/series/3921/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=3921","date":"2017-09-19T16:17:16","name":"Bug fixes for the HNS3 Ethernet Driver for Hip08 SoC","version":2,"mbox":"http://patchwork.ozlabs.org/series/3921/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815640/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815640/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 3xxSjQ0CTNz9sPk\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 20 Sep 2017 02:18:34 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751946AbdISQSX (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 19 Sep 2017 12:18:23 -0400","from szxga04-in.huawei.com ([45.249.212.190]:6499 \"EHLO\n\tszxga04-in.huawei.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751903AbdISQSV (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Tue, 19 Sep 2017 12:18:21 -0400","from 172.30.72.59 (EHLO DGGEMS414-HUB.china.huawei.com)\n\t([172.30.72.59])\n\tby dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued)\n\twith ESMTP id DHO40868; Wed, 20 Sep 2017 00:18:18 +0800 (CST)","from S00293818-DELL1.china.huawei.com (10.203.181.154) by\n\tDGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP\n\tServer id 14.3.301.0; Wed, 20 Sep 2017 00:18:11 +0800"],"From":"Salil Mehta <salil.mehta@huawei.com>","To":"<davem@davemloft.net>","CC":"<salil.mehta@huawei.com>, <yisen.zhuang@huawei.com>,\n\t<lipeng321@huawei.com>, <mehta.salil.lnk@gmail.com>,\n\t<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,\n\t<linux-rdma@vger.kernel.org>, <linuxarm@huawei.com>","Subject":"[PATCH V2 net 7/7] net: hns3: Fixes the premature exit of loop when\n\tmatching clients","Date":"Tue, 19 Sep 2017 17:17:16 +0100","Message-ID":"<20170919161716.92680-8-salil.mehta@huawei.com>","X-Mailer":"git-send-email 2.8.3","In-Reply-To":"<20170919161716.92680-1-salil.mehta@huawei.com>","References":"<20170919161716.92680-1-salil.mehta@huawei.com>","MIME-Version":"1.0","Content-Type":"text/plain","X-Originating-IP":"[10.203.181.154]","X-CFilter-Loop":"Reflected","X-Mirapoint-Virus-RAPID-Raw":"score=unknown(0),\n\trefid=str=0001.0A020203.59C1434A.0118, 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":"05a096c747ebff15824aa32be7bd6476","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"From: Lipeng <lipeng321@huawei.com>\n\nWhen register/unregister ae_dev, ae_dev should match all client\nin the client_list. Enet and roce can co-exists together so we\nshould continue checking for enet and roce presence together.\nSo break should not be there.\n\nAbove caused problems in loading and unloading of modules.\n\nFixes: 38eddd126772 (\"net: hns3: Add support of the HNAE3 framework\")\nSigned-off-by: Lipeng <lipeng321@huawei.com>\nSigned-off-by: Salil Mehta <salil.mehta@huawei.com>\n---\n drivers/net/ethernet/hisilicon/hns3/hnae3.c | 43 ++++++-----------------------\n 1 file changed, 9 insertions(+), 34 deletions(-)","diff":"diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c\nindex 59efbd6..5bcb223 100644\n--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c\n+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c\n@@ -37,20 +37,15 @@ static bool hnae3_client_match(enum hnae3_client_type client_type,\n }\n \n static int hnae3_match_n_instantiate(struct hnae3_client *client,\n-\t\t\t\t     struct hnae3_ae_dev *ae_dev,\n-\t\t\t\t     bool is_reg, bool *matched)\n+\t\t\t\t     struct hnae3_ae_dev *ae_dev, bool is_reg)\n {\n \tint ret;\n \n-\t*matched = false;\n-\n \t/* check if this client matches the type of ae_dev */\n \tif (!(hnae3_client_match(client->type, ae_dev->dev_type) &&\n \t      hnae_get_bit(ae_dev->flag, HNAE3_DEV_INITED_B))) {\n \t\treturn 0;\n \t}\n-\t/* there is a match of client and dev */\n-\t*matched = true;\n \n \t/* now, (un-)instantiate client by calling lower layer */\n \tif (is_reg) {\n@@ -69,7 +64,6 @@ int hnae3_register_client(struct hnae3_client *client)\n {\n \tstruct hnae3_client *client_tmp;\n \tstruct hnae3_ae_dev *ae_dev;\n-\tbool matched;\n \tint ret = 0;\n \n \tmutex_lock(&hnae3_common_lock);\n@@ -86,7 +80,7 @@ int hnae3_register_client(struct hnae3_client *client)\n \t\t/* if the client could not be initialized on current port, for\n \t\t * any error reasons, move on to next available port\n \t\t */\n-\t\tret = hnae3_match_n_instantiate(client, ae_dev, true, &matched);\n+\t\tret = hnae3_match_n_instantiate(client, ae_dev, true);\n \t\tif (ret)\n \t\t\tdev_err(&ae_dev->pdev->dev,\n \t\t\t\t\"match and instantiation failed for port\\n\");\n@@ -102,12 +96,11 @@ EXPORT_SYMBOL(hnae3_register_client);\n void hnae3_unregister_client(struct hnae3_client *client)\n {\n \tstruct hnae3_ae_dev *ae_dev;\n-\tbool matched;\n \n \tmutex_lock(&hnae3_common_lock);\n \t/* un-initialize the client on every matched port */\n \tlist_for_each_entry(ae_dev, &hnae3_ae_dev_list, node) {\n-\t\thnae3_match_n_instantiate(client, ae_dev, false, &matched);\n+\t\thnae3_match_n_instantiate(client, ae_dev, false);\n \t}\n \n \tlist_del(&client->node);\n@@ -124,7 +117,6 @@ int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo)\n \tconst struct pci_device_id *id;\n \tstruct hnae3_ae_dev *ae_dev;\n \tstruct hnae3_client *client;\n-\tbool matched;\n \tint ret = 0;\n \n \tmutex_lock(&hnae3_common_lock);\n@@ -151,13 +143,10 @@ int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo)\n \t\t * initialize the figure out client instance\n \t\t */\n \t\tlist_for_each_entry(client, &hnae3_client_list, node) {\n-\t\t\tret = hnae3_match_n_instantiate(client, ae_dev, true,\n-\t\t\t\t\t\t\t&matched);\n+\t\t\tret = hnae3_match_n_instantiate(client, ae_dev, true);\n \t\t\tif (ret)\n \t\t\t\tdev_err(&ae_dev->pdev->dev,\n \t\t\t\t\t\"match and instantiation failed\\n\");\n-\t\t\tif (matched)\n-\t\t\t\tbreak;\n \t\t}\n \t}\n \n@@ -175,7 +164,6 @@ void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo)\n \tconst struct pci_device_id *id;\n \tstruct hnae3_ae_dev *ae_dev;\n \tstruct hnae3_client *client;\n-\tbool matched;\n \n \tmutex_lock(&hnae3_common_lock);\n \t/* Check if there are matched ae_dev */\n@@ -187,12 +175,8 @@ void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo)\n \t\t/* check the client list for the match with this ae_dev type and\n \t\t * un-initialize the figure out client instance\n \t\t */\n-\t\tlist_for_each_entry(client, &hnae3_client_list, node) {\n-\t\t\thnae3_match_n_instantiate(client, ae_dev, false,\n-\t\t\t\t\t\t  &matched);\n-\t\t\tif (matched)\n-\t\t\t\tbreak;\n-\t\t}\n+\t\tlist_for_each_entry(client, &hnae3_client_list, node)\n+\t\t\thnae3_match_n_instantiate(client, ae_dev, false);\n \n \t\tae_algo->ops->uninit_ae_dev(ae_dev);\n \t\thnae_set_bit(ae_dev->flag, HNAE3_DEV_INITED_B, 0);\n@@ -212,7 +196,6 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)\n \tconst struct pci_device_id *id;\n \tstruct hnae3_ae_algo *ae_algo;\n \tstruct hnae3_client *client;\n-\tbool matched;\n \tint ret = 0;\n \n \tmutex_lock(&hnae3_common_lock);\n@@ -246,13 +229,10 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)\n \t * initialize the figure out client instance\n \t */\n \tlist_for_each_entry(client, &hnae3_client_list, node) {\n-\t\tret = hnae3_match_n_instantiate(client, ae_dev, true,\n-\t\t\t\t\t\t&matched);\n+\t\tret = hnae3_match_n_instantiate(client, ae_dev, true);\n \t\tif (ret)\n \t\t\tdev_err(&ae_dev->pdev->dev,\n \t\t\t\t\"match and instantiation failed\\n\");\n-\t\tif (matched)\n-\t\t\tbreak;\n \t}\n \n out_err:\n@@ -270,7 +250,6 @@ void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev)\n \tconst struct pci_device_id *id;\n \tstruct hnae3_ae_algo *ae_algo;\n \tstruct hnae3_client *client;\n-\tbool matched;\n \n \tmutex_lock(&hnae3_common_lock);\n \t/* Check if there are matched ae_algo */\n@@ -279,12 +258,8 @@ void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev)\n \t\tif (!id)\n \t\t\tcontinue;\n \n-\t\tlist_for_each_entry(client, &hnae3_client_list, node) {\n-\t\t\thnae3_match_n_instantiate(client, ae_dev, false,\n-\t\t\t\t\t\t  &matched);\n-\t\t\tif (matched)\n-\t\t\t\tbreak;\n-\t\t}\n+\t\tlist_for_each_entry(client, &hnae3_client_list, node)\n+\t\t\thnae3_match_n_instantiate(client, ae_dev, false);\n \n \t\tae_algo->ops->uninit_ae_dev(ae_dev);\n \t\thnae_set_bit(ae_dev->flag, HNAE3_DEV_INITED_B, 0);\n","prefixes":["V2","net","7/7"]}