From patchwork Sun Oct 11 13:32:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Barak X-Patchwork-Id: 7368991 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6FAC29F1D5 for ; Sun, 11 Oct 2015 13:32:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1241520623 for ; Sun, 11 Oct 2015 13:32:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7644203F3 for ; Sun, 11 Oct 2015 13:32:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752105AbbJKNcg (ORCPT ); Sun, 11 Oct 2015 09:32:36 -0400 Received: from mail-am1on0085.outbound.protection.outlook.com ([157.56.112.85]:36672 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751606AbbJKNce (ORCPT ); Sun, 11 Oct 2015 09:32:34 -0400 Received: from DB3PR05CA0019.eurprd05.prod.outlook.com (10.160.41.147) by DB4PR05MB367.eurprd05.prod.outlook.com (10.242.192.149) with Microsoft SMTP Server (TLS) id 15.1.293.16; Sun, 11 Oct 2015 13:32:30 +0000 Received: from AM1FFO11FD007.protection.gbl (2a01:111:f400:7e00::162) by DB3PR05CA0019.outlook.office365.com (2a01:111:e400:9428::19) with Microsoft SMTP Server (TLS) id 15.1.293.16 via Frontend Transport; Sun, 11 Oct 2015 13:32:30 +0000 Authentication-Results: spf=pass (sender IP is 193.47.165.134) smtp.mailfrom=mellanox.com; Avagotech.com; dkim=none (message not signed) header.d=none; Avagotech.com; dmarc=pass action=none header.from=mellanox.com; Received-SPF: Pass (protection.outlook.com: domain of mellanox.com designates 193.47.165.134 as permitted sender) receiver=protection.outlook.com; client-ip=193.47.165.134; helo=mtlcas13.mtl.com; Received: from mtlcas13.mtl.com (193.47.165.134) by AM1FFO11FD007.mail.protection.outlook.com (10.174.64.69) with Microsoft SMTP Server (TLS) id 15.1.293.9 via Frontend Transport; Sun, 11 Oct 2015 13:32:28 +0000 Received: from MTLCAS13.mtl.com (10.0.8.78) by mtlcas13.mtl.com (10.0.8.78) with Microsoft SMTP Server (TLS) id 15.0.775.38; Sun, 11 Oct 2015 16:32:27 +0300 Received: from MTLCAS01.mtl.com (10.0.8.71) by MTLCAS13.mtl.com (10.0.8.78) with Microsoft SMTP Server (TLS) id 15.0.775.38 via Frontend Transport; Sun, 11 Oct 2015 16:32:27 +0300 Received: from [10.223.0.82] (10.223.0.82) by MTLCAS01.mtl.com (10.0.8.71) with Microsoft SMTP Server (TLS) id 14.3.123.3; Sun, 11 Oct 2015 16:32:26 +0300 Subject: Re: [PATCH for-next 02/10] IB/mlx5: Support IB device's callback for getting its netdev To: Achiad Shochat , Doug Ledford References: <1440089189-3361-1-git-send-email-achiad@mellanox.com> <1440089189-3361-3-git-send-email-achiad@mellanox.com> CC: , Jason Gunthorpe , Or Gerlitz , Haggai Eran , Somnath Kotur From: Matan Barak Message-ID: <561A64E9.1070906@mellanox.com> Date: Sun, 11 Oct 2015 16:32:25 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1440089189-3361-3-git-send-email-achiad@mellanox.com> X-Originating-IP: [10.223.0.82] X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD007; 1:rXluyJLG8Gd9vHvokNzeGkyElrhZ7YebShhryJE1GiPevW3b9Q+xGYRO0IDrWrh8bXf7mpi/raeVka2Ra69SQIu/GqKVJSrH8wI1DtqUmyhdH36zUNXQ7oJQlmCax7vy9grC+JLQUyYedIRKEsgvv4aNwHxU5KQYrDESsX3yMaAV97IpsJ95SxrL+eAPi9h2OdX3LUp6DQRO1w1ukUmKiYKGHoOWAo1GiL0I0VL5VUa37XRXCYs4+kjT1UvhYfUSeE3kDS4ftwIriTZzqdTcSrN54japBah5wXmU4KiasHhFrl+lfQ6YY5Ke/UNhSfRbS+rzpPSXVZ/d6iPylWlBQ72jA0SvWNeTlvgJYWmfE8jqXgytZSsm9Ffw+5PmYmNKDh7j1j6odvT1PTRgOtetNw== X-Forefront-Antispam-Report: CIP:193.47.165.134; CTRY:IL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(479174004)(164054003)(377454003)(199003)(24454002)(189002)(64126003)(50466002)(47776003)(65956001)(59896002)(189998001)(5007970100001)(64706001)(92566002)(5004730100002)(5008740100001)(2950100001)(46102003)(50986999)(87936001)(54356999)(6806005)(97736004)(83506001)(65816999)(23746002)(65806001)(86362001)(4001350100001)(5001770100001)(33656002)(19580395003)(19580405001)(80316001)(106466001)(77096005)(87266999)(11100500001)(36756003)(76176999)(3940600001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB4PR05MB367; H:mtlcas13.mtl.com; FPR:; SPF:Pass; PTR:ErrorRetry; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB367; 2:ugwZvf1T36hyOZ8eFsA3sN9wDExY1LfBU3lZI1JJLzefF5DBE/94WhriCBrDaOsaYpoAb87AwBOL9fVujnCAieVNh79dh3pw1a8h8yTC6q24GuDheTAQvj3fwr+soEDHmAWPaBc3xNY1QZ+cewMNeIyooGx2Jj/xKNtkqRALqps=; 3:WIZO4fV+xr//YVvzH0FlsOSKRAmvB73zt92YJOedgluzjhYc8M5KC7YoWgOAC/KwPZnD0LPG8h6R/wfdlSJ8neznBvx5z4qn5DZbgivnNahxN+GT86/SigskWWkxI/po1MDkJkIl0s6LBYra3MTm7zBC8NWZ8FEqtG7gpnu0VRWDAOFboKaepkMufy7yM4gDgeU3YHB2GyS37bsVk9VPy8FwW0Rv1fpQ2qCYn/Uwl6Va69Pt64EFo0536cMeTwNpNgtDuTC/BU6veIJGkcO8wA==; 25:dbVQ4YBA2jjCXYUneqASHV/cRozu4DO46WPgMyY+ayKSfwINaCVYzXriYngih3Bnhu2FSIMSVgizAPdyuoH1VWi2x3NnBI8caUf/MlUnPFAPG3Y5VvcInXRu47ApnGnGJh9BFBZMPxpTSLQ01d3+62UeylBeOrVD+cYsm5Sa9Kni7GzlxqloIepO1gRCoGtOnUun2a0wAWcGf2OjE0FqA2ozvV9NJpyypCWdqlzD0qGWtAii3xQzmvkaUtm/XCmt1f5wKzzWC9AoDNJ7pJd5NQ== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:DB4PR05MB367; X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB367; 20:eoBoQHqoZv5GhLk8Ff5TqknbioWsjNHDcjDERwSRKyUK7J7sIzx2IEV6tTJZ95IYfn4j7CWeP0OYotI7XhowqLoNMJRpNRtJH0u6Q/xtlsSNmQeLWmx0NfG1V+fEJtb9hxRbNeKLKi+0L3H9uZ3zAtxcWMrivRuWVhpNwZrnoqRvck7wp3d+lYdRiGrDs6dlQ2N+k2d1GQpTSWDW/BT58Zyqg/jRVRveTrP0tCZ5gBxIWqPUg4weBiPdAcqYu1TEV+832oMn4si8w302rEnLDpn0fGrJjg+K4aQJyPC7o6Ggx3HX+9cic/7QHCuY2THWbJRddMaAIhvvQ1ekTsH9H2d33ZT0o8kxnO5N6GjwcSSLcoOn9RY3875ZlE7dNwmmsm/W6LXl+COux5tnD7A8MqFYEhSm4p8g6brfARDHvZCqFm3Tq2AVMeAGi8It5eNvwSRYmkCy9MZ5sFOq9GlHWIHULZGlh7NKRsdKHiK5Qhz8j8LSTvsgeXQuz87/9glP; 4:j4mtCQ1wT6lETt5FmLD2kkFHRGEDWMQk5cDyn9i3oPnG9ycvv68AqApabGN75ljtgeWmGfn+RcudAijSj67e7GS3Fglp7R0MfZb74H8NYAuoCobtz57uL/GEOdKdNcA15IiGLWhTafKI71ibhm9RYH/D970b4pJ2uCcVuuI83MJ6eugVktNBP5LPcZmrde0+wiPcRcNkf2qtUW6PSuuQWfX2pCaMcE0Jb0kwMb+qM0kfR1pLVkgFGFprr275fe8TBs7RInv2l0WVTA09Yp3UWwOG8GFfPEXXT8S4X6SCPgc/WSkMWQ/cmzXAD8jbqLpJ/KsOLJjCZdtKeYBDw/7/O95fOpT3Jm4p+HsfcHaBDsM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(34787635062028); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001); SRVR:DB4PR05MB367; BCL:0; PCL:0; RULEID:; SRVR:DB4PR05MB367; X-Forefront-PRVS: 0726B2D7A6 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; DB4PR05MB367; 23:dFT1nWH1Kxq/2dEi9KBPn8vpxM0r0jYQ+/0vwI?= =?Windows-1252?Q?+IlbP4UcrL5DqWAWGRhG53jiX8YWaY9pGJ3nrKT9UWU8MGChKaw2+hAv?= =?Windows-1252?Q?jNmKY5IuI9bbGQMHstxCws64zV5wDmDqpvm9mFjHBlMoxWrgKKGGiHCA?= =?Windows-1252?Q?7dnsyFDW9XrHlqHK/OPSMBJqn9SLKMnoTEjhhhIq5BxN5GGsYpkODHcs?= =?Windows-1252?Q?g61r4rj3KDx5uiNLWFvdkukDhWovAG0GHHvMcgUFzBypvsWgRlSlRU0Y?= =?Windows-1252?Q?VGUuLv/BGgIn5/vuRi4l/2m0SxN2Hg5wGxZlqFvTRfM080dpHp91dzv7?= =?Windows-1252?Q?QBMZLo7kVjDx/l7aFfXvyQx4eUjmbQREIwax20CPV6CS9yuB1LJXQwvF?= =?Windows-1252?Q?VOalrgrsmiwl/yRrjhEdf/pBmRBEekUh3FyPX7fNAB0V7pkFsEXrcru/?= =?Windows-1252?Q?XpvuWR4YFnRlFhIjHd5UgXlfFL9bKMamHAeE68RGFkxi1FtFrLvGTRaD?= =?Windows-1252?Q?SnV+Ryq1A0/NXhaNmZBmyR89x2SDYuY7sIMpJ7eCJoOyXoQqaZbpBzJh?= =?Windows-1252?Q?hoRxXoZtCZHETz1W6KO6d+CNLHpKA5cluL9pDMYqcHOZQZEfqvMgLrKr?= =?Windows-1252?Q?VR7AzlGKk6phKzfqKU9YWRt5z9ExfoowJ1MEPYuJj1Q+lkVoXxPKr47Y?= =?Windows-1252?Q?JFLb2bUJd4oGnqat+SJh6bFBuptMsSMx91L8Sk5BQM6RK4+JFCcO0aMM?= =?Windows-1252?Q?lBQlB+RP8AmY5nED/jwiMwIxKiFG1G6LEmO8L6ozzocCuJ7G65W2g/jP?= =?Windows-1252?Q?1rfmcUzF64ky+A2YkBEEOkltpGHFsvRz5kx4RPVAx1A91edXztRKbeAG?= =?Windows-1252?Q?5yhijWehTYUZD+XF/o/cKVeFUhdw0GmlPpX3miE4wmhuPauegrkqRC3u?= =?Windows-1252?Q?eziZ2qiUWxDgCa85SFAU7IGBu31oLXePSzoiJRgrd88y1x8tX8zqHH6d?= =?Windows-1252?Q?xgu2+n9lNaiuhlsOz5CUz8sbM1O9t6kOz/ZyzjpsiC9CYP+l1HjngcLC?= =?Windows-1252?Q?Dwqf+bIvzWzjtSzkHfFe0sKGR1Wh7B5GIHyrX64ZBezqxplj0w/bMGpw?= =?Windows-1252?Q?5vdAMfw5bHmHZ1v947pZ793UUQQoh0k614M6ByhWV02SzYmwIwB+sHUB?= =?Windows-1252?Q?MR24LeIqxpsmsxypJJ2BDCkJc5mMjhFuVBBT8041/D0hnkvleKRBotlf?= =?Windows-1252?Q?1SzObxSza9MRGn7TtwEzk0s9E7kQ1zT92CfiZ7MwDTECa8N/VO2qUU8b?= =?Windows-1252?Q?mr?= X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB367; 5:nRvquECS/ZW5kt04vQUmg3PYMwVMnc2220rkfUgXp4k8iyiy7FvR2LAHoNcUcNlNesjQNLtfeBlVxabYM8PgXNcvmUeyvLBXPInCG+1xO89OZVM42TfccplgjmIwnGp/ULXY9x2Iiq5tSLwmt0CbFA==; 24:W0rtWuuQw+i47aaqe4Xqx+mfUBzjwYJZTo92f4VZ6ItDSaRNZQLB5KW2YPyNRFT0vfufIsximmNn+DqU2Ny6AS5K81cqVXBtXpI/deaIkVM=; 20:eRCBJKhXLwthICPKR3+KiQn7QUjhES93yZk06FtzaVbtEkZhl/Chs+7ZGVTmYZn7Usx7omMMZ42Bag9lg8WILQ== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2015 13:32:28.7642 (UTC) X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a652971c-7d2e-4d9b-a6a4-d149256f461b; Ip=[193.47.165.134]; Helo=[mtlcas13.mtl.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR05MB367 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 8/20/2015 7:46 PM, Achiad Shochat wrote: > For Eth ports only. > Maintain a net device pointer in mlx5_ib_device and update it > upon NETDEV_REGISTER and NETDEV_UNREGISTER events if the > net-device and IB device have the same PCI parent device. > Implement the get_netdev callback to return this net device. > > Signed-off-by: Achiad Shochat > --- > drivers/infiniband/hw/mlx5/main.c | 64 +++++++++++++++++++++++++++++++++++- > drivers/infiniband/hw/mlx5/mlx5_ib.h | 10 ++++++ > 2 files changed, 73 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c > index 8540e00..5a176d7 100644 > --- a/drivers/infiniband/hw/mlx5/main.c > +++ b/drivers/infiniband/hw/mlx5/main.c > @@ -85,6 +85,41 @@ mlx5_ib_port_link_layer(struct ib_device *device, u8 port_num) > return mlx5_port_type_cap_to_rdma_ll(port_type_cap); > } > > +static int mlx5_netdev_event(struct notifier_block *this, > + unsigned long event, void *ptr) > +{ > + struct net_device *ndev = netdev_notifier_info_to_dev(ptr); > + struct mlx5_ib_dev *ibdev = container_of(this, struct mlx5_ib_dev, > + roce.nb); > + > + if ((event != NETDEV_UNREGISTER) && (event != NETDEV_REGISTER)) > + return NOTIFY_DONE; > + > + write_lock(&ibdev->roce.netdev_lock); > + if (ndev->dev.parent == &ibdev->mdev->pdev->dev) > + ibdev->roce.netdev = (event == NETDEV_UNREGISTER) ? NULL : ndev; > + write_unlock(&ibdev->roce.netdev_lock); > + > + return NOTIFY_DONE; > +} > + > +static struct net_device *mlx5_ib_get_netdev(struct ib_device *device, > + u8 port_num) > +{ > + struct mlx5_ib_dev *ibdev = to_mdev(device); > + struct net_device *ndev; > + > + /* Ensure ndev does not disappear before we invoke dev_hold() > + */ > + read_lock(&ibdev->roce.netdev_lock); > + ndev = ibdev->roce.netdev; > + if (ndev) > + dev_hold(ndev); > + read_unlock(&ibdev->roce.netdev_lock); > + > + return ndev; > +} > + > static int mlx5_use_mad_ifc(struct mlx5_ib_dev *dev) > { > return !dev->mdev->issi; > @@ -1398,6 +1433,18 @@ static int mlx5_port_immutable(struct ib_device *ibdev, u8 port_num, > return 0; > } > > +static int mlx5_enable_roce(struct mlx5_ib_dev *dev) > +{ > + rwlock_init(&dev->roce.netdev_lock); > + dev->roce.nb.notifier_call = mlx5_netdev_event; > + return register_netdevice_notifier(&dev->roce.nb); > +} > + > +static void mlx5_disable_roce(struct mlx5_ib_dev *dev) > +{ > + unregister_netdevice_notifier(&dev->roce.nb); > +} > + > static void *mlx5_ib_add(struct mlx5_core_dev *mdev) > { > struct mlx5_ib_dev *dev; > @@ -1471,6 +1518,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) > dev->ib_dev.query_device = mlx5_ib_query_device; > dev->ib_dev.query_port = mlx5_ib_query_port; > dev->ib_dev.get_link_layer = mlx5_ib_port_link_layer; > + if (ll == IB_LINK_LAYER_ETHERNET) > + dev->ib_dev.get_netdev = mlx5_ib_get_netdev; > dev->ib_dev.query_gid = mlx5_ib_query_gid; > dev->ib_dev.query_pkey = mlx5_ib_query_pkey; > dev->ib_dev.modify_device = mlx5_ib_modify_device; > @@ -1530,9 +1579,15 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) > > mutex_init(&dev->cap_mask_mutex); > > + if (ll == IB_LINK_LAYER_ETHERNET) { > + err = mlx5_enable_roce(dev); > + if (err) > + goto err_dealloc; > + } > + > err = create_dev_resources(&dev->devr); > if (err) > - goto err_dealloc; > + goto err_disable_roce; > > err = mlx5_ib_odp_init_one(dev); > if (err) > @@ -1569,6 +1624,10 @@ err_odp: > err_rsrc: > destroy_dev_resources(&dev->devr); > > +err_disable_roce: > + if (ll == IB_LINK_LAYER_ETHERNET) > + mlx5_disable_roce(dev); > + > err_dealloc: > ib_dealloc_device((struct ib_device *)dev); > > @@ -1578,11 +1637,14 @@ err_dealloc: > static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context) > { > struct mlx5_ib_dev *dev = context; > + enum rdma_link_layer ll = mlx5_ib_port_link_layer(&dev->ib_dev, 1); > > ib_unregister_device(&dev->ib_dev); > destroy_umrc_res(dev); > mlx5_ib_odp_remove_one(dev); > destroy_dev_resources(&dev->devr); > + if (ll == IB_LINK_LAYER_ETHERNET) > + mlx5_disable_roce(dev); > ib_dealloc_device(&dev->ib_dev); > } > > diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h > index 7cae098..81df6d4 100644 > --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h > +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h > @@ -418,9 +418,19 @@ struct mlx5_ib_resources { > struct ib_srq *s1; > }; > > +struct mlx5_roce { > + /* Protect mlx5_ib_get_netdev from invoking dev_hold() with a NULL > + * netdev pointer > + */ > + rwlock_t netdev_lock; > + struct net_device *netdev; > + struct notifier_block nb; > +}; > + > struct mlx5_ib_dev { > struct ib_device ib_dev; > struct mlx5_core_dev *mdev; > + struct mlx5_roce roce; > MLX5_DECLARE_DOORBELL_LOCK(uar_lock); > int num_ports; > /* serialize update of capability mask > Hi, We've found a bug in this patch - the rwlock is used before it's initialized. Here is a quick fix to this patch. If you prefer, we could re-spin this series. From f6a851452016dcb5a4513bf195857c4e4ec4969a Mon Sep 17 00:00:00 2001 From: Achiad Shochat Date: Thu, 17 Sep 2015 13:01:47 +0300 Subject: [PATCH for-next] IB/mlx5: Avoid using un-initialized rwlock Upon IB device creation, we try to acquire the rwlock protecting net device before it was initialized. The flow is: mlx5_ib_add()->get_port_caps()->mlx5_ib_query_port()-> mlx5_query_port_roce()->mlx5_ib_get_netdev() So we moved the rwlock initialization to be before invoking get_port_caps(). Fixes: 6583d240c73d ('IB/mlx5: Support IB device's callback for getting its netdev') Signed-off-by: Achiad Shochat --- drivers/infiniband/hw/mlx5/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index e8d2d01..8ad647e 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -1611,9 +1611,15 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) dev->mdev = mdev; + if (ll == IB_LINK_LAYER_ETHERNET) { + err = mlx5_enable_roce(dev); + if (err) + goto err_dealloc; + } + err = get_port_caps(dev); if (err) - goto err_dealloc; + goto err_disable_roce; if (mlx5_use_mad_ifc(dev)) get_ext_port_caps(dev); @@ -1718,16 +1724,10 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) err = init_node_data(dev); if (err) - goto err_dealloc; + goto err_disable_roce; mutex_init(&dev->cap_mask_mutex); - if (ll == IB_LINK_LAYER_ETHERNET) { - err = mlx5_enable_roce(dev); - if (err) - goto err_dealloc; - } - err = create_dev_resources(&dev->devr); if (err) goto err_disable_roce;