From patchwork Tue Sep 19 01:06:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 112961 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4322053qgf; Mon, 18 Sep 2017 18:08:47 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBHCslE6MoRm5dpfrj1oVAlMBZKbQECP2BkLgZLgDb6ISt+ogI2tUb3CDf7bpScbrABpHcm X-Received: by 10.99.4.7 with SMTP id 7mr395293pge.400.1505783327156; Mon, 18 Sep 2017 18:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505783327; cv=none; d=google.com; s=arc-20160816; b=YSB6m6k4TKRl0senBVShgut/YHysvqws1mBJl4mLfDw9Zl38A0HBWuFne5ijPlPwiy e48awbTIY/4KQ+j0wIOn0ZlyIVAR0/5tvWNAC4qzHzmsPLPhoXlSxeHTmGzcAQpulCqT VsYlsXG9W4W7yeCB40q3G4HRPkAiuBoKt4tqRfKEDYekM65g5+3SLTFLKOpvP5LKCzGT m16KEsF1dy0SH31e+IDkG6XAGOWxKuey5SBzwtA9y22bLt7/gv1a9P5cwMMQygpNT/+r 6F3tdRS1rd1a4+F+Vd5Bea7ut/4+cK6AqLB0Pr9TgEmLFKuvDulMxuLm1p0hbfmpY+Nj 2OuA== 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=v3vSCQ/W6pNRQP8YH8CcQbp1qoox3+VEHGRAVlqwZzY=; b=fVytrsspS5ksAAwGs13CdR4iTjWiv9AmF4kWpE4HaC+v8mTsyII40LjhexgS2KOg13 AQTHwE1dqz/D//qLQobIPPRU5nRnc5DGZvOI/pxZPNIybCPnT3AXTZ+5E6jeCyzsPBsr wpbO/2VapQGbc0KOs2JSDi60Mg8sLYkaj2BSu3Wd5JVyPAI/CaeGavF4B8zlC3CRV3fU NMHB8w8C/BRhD5JHIIqV/lb2PiscWyKw3UMzq1ZS0Zw0vmaJbBw5o+R3qT7XtRyg9RQT Y+vMofyZzV9H14zKS8cNfYqY/AzDAws6kmChUsBMrKkGpGGfxb00KcuhNA6OzjK7a1Fj ssjA== 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 t74si494023pgc.205.2017.09.18.18.08.46; Mon, 18 Sep 2017 18:08:47 -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 S1751846AbdISBIp (ORCPT + 26 others); Mon, 18 Sep 2017 21:08:45 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6072 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751578AbdISBHn (ORCPT ); Mon, 18 Sep 2017 21:07:43 -0400 Received: from 172.30.72.60 (EHLO DGGEMS411-HUB.china.huawei.com) ([172.30.72.60]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DHO21307; Tue, 19 Sep 2017 09:07:41 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.47.92.71) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.301.0; Tue, 19 Sep 2017 09:07:31 +0800 From: Salil Mehta To: CC: , , , , , , , Subject: [PATCH net 7/7] net: hns3: Fixes the premature exit of loop when matching clients Date: Tue, 19 Sep 2017 02:06:28 +0100 Message-ID: <20170919010628.175732-8-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20170919010628.175732-1-salil.mehta@huawei.com> References: <20170919010628.175732-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.92.71] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.59C06DDD.01A1, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 20579b3dca37263aa01b11cb1172398e Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lipeng When register/unregister ae_dev, ae_dev should match all client in the client_list. Enet and roce can co-exists together so we should continue checking for enet and roce presence together. So break should not be there. Above caused problems in loading and unloading of modules. Signed-off-by: Lipeng Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 43 ++++++----------------------- 1 file changed, 9 insertions(+), 34 deletions(-) -- 2.11.0 diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index 59efbd605416..5bcb2238acb2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -37,20 +37,15 @@ static bool hnae3_client_match(enum hnae3_client_type client_type, } static int hnae3_match_n_instantiate(struct hnae3_client *client, - struct hnae3_ae_dev *ae_dev, - bool is_reg, bool *matched) + struct hnae3_ae_dev *ae_dev, bool is_reg) { int ret; - *matched = false; - /* check if this client matches the type of ae_dev */ if (!(hnae3_client_match(client->type, ae_dev->dev_type) && hnae_get_bit(ae_dev->flag, HNAE3_DEV_INITED_B))) { return 0; } - /* there is a match of client and dev */ - *matched = true; /* now, (un-)instantiate client by calling lower layer */ if (is_reg) { @@ -69,7 +64,6 @@ int hnae3_register_client(struct hnae3_client *client) { struct hnae3_client *client_tmp; struct hnae3_ae_dev *ae_dev; - bool matched; int ret = 0; mutex_lock(&hnae3_common_lock); @@ -86,7 +80,7 @@ int hnae3_register_client(struct hnae3_client *client) /* if the client could not be initialized on current port, for * any error reasons, move on to next available port */ - ret = hnae3_match_n_instantiate(client, ae_dev, true, &matched); + ret = hnae3_match_n_instantiate(client, ae_dev, true); if (ret) dev_err(&ae_dev->pdev->dev, "match and instantiation failed for port\n"); @@ -102,12 +96,11 @@ EXPORT_SYMBOL(hnae3_register_client); void hnae3_unregister_client(struct hnae3_client *client) { struct hnae3_ae_dev *ae_dev; - bool matched; mutex_lock(&hnae3_common_lock); /* un-initialize the client on every matched port */ list_for_each_entry(ae_dev, &hnae3_ae_dev_list, node) { - hnae3_match_n_instantiate(client, ae_dev, false, &matched); + hnae3_match_n_instantiate(client, ae_dev, false); } list_del(&client->node); @@ -124,7 +117,6 @@ int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo) const struct pci_device_id *id; struct hnae3_ae_dev *ae_dev; struct hnae3_client *client; - bool matched; int ret = 0; mutex_lock(&hnae3_common_lock); @@ -151,13 +143,10 @@ int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo) * initialize the figure out client instance */ list_for_each_entry(client, &hnae3_client_list, node) { - ret = hnae3_match_n_instantiate(client, ae_dev, true, - &matched); + ret = hnae3_match_n_instantiate(client, ae_dev, true); if (ret) dev_err(&ae_dev->pdev->dev, "match and instantiation failed\n"); - if (matched) - break; } } @@ -175,7 +164,6 @@ void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo) const struct pci_device_id *id; struct hnae3_ae_dev *ae_dev; struct hnae3_client *client; - bool matched; mutex_lock(&hnae3_common_lock); /* Check if there are matched ae_dev */ @@ -187,12 +175,8 @@ void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo) /* check the client list for the match with this ae_dev type and * un-initialize the figure out client instance */ - list_for_each_entry(client, &hnae3_client_list, node) { - hnae3_match_n_instantiate(client, ae_dev, false, - &matched); - if (matched) - break; - } + list_for_each_entry(client, &hnae3_client_list, node) + hnae3_match_n_instantiate(client, ae_dev, false); ae_algo->ops->uninit_ae_dev(ae_dev); hnae_set_bit(ae_dev->flag, HNAE3_DEV_INITED_B, 0); @@ -212,7 +196,6 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) const struct pci_device_id *id; struct hnae3_ae_algo *ae_algo; struct hnae3_client *client; - bool matched; int ret = 0; mutex_lock(&hnae3_common_lock); @@ -246,13 +229,10 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) * initialize the figure out client instance */ list_for_each_entry(client, &hnae3_client_list, node) { - ret = hnae3_match_n_instantiate(client, ae_dev, true, - &matched); + ret = hnae3_match_n_instantiate(client, ae_dev, true); if (ret) dev_err(&ae_dev->pdev->dev, "match and instantiation failed\n"); - if (matched) - break; } out_err: @@ -270,7 +250,6 @@ void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev) const struct pci_device_id *id; struct hnae3_ae_algo *ae_algo; struct hnae3_client *client; - bool matched; mutex_lock(&hnae3_common_lock); /* Check if there are matched ae_algo */ @@ -279,12 +258,8 @@ void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev) if (!id) continue; - list_for_each_entry(client, &hnae3_client_list, node) { - hnae3_match_n_instantiate(client, ae_dev, false, - &matched); - if (matched) - break; - } + list_for_each_entry(client, &hnae3_client_list, node) + hnae3_match_n_instantiate(client, ae_dev, false); ae_algo->ops->uninit_ae_dev(ae_dev); hnae_set_bit(ae_dev->flag, HNAE3_DEV_INITED_B, 0);