From patchwork Wed Jul 27 17:03:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12930648 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32BEEC04A68 for ; Wed, 27 Jul 2022 17:59:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243114AbiG0R7n (ORCPT ); Wed, 27 Jul 2022 13:59:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236179AbiG0R7a (ORCPT ); Wed, 27 Jul 2022 13:59:30 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2046.outbound.protection.outlook.com [40.107.95.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD2F25727B for ; Wed, 27 Jul 2022 10:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IZlbS9Asq3maVFZFeU/gkmzXmYbalDynF1MQVO3RcS0ZCUiNHEMlg51ek5wWV0b3YJUrE69Rx9RrotjXlfeL2JCYPJH1KtV3Ez36fYTTcIadSsV+2ymnOphbN3oBvgYIzp/4lgexBH/SkFOuJ7htKqqxeaZBZZaU0aboGLMh4vrXZCxlvX25qZavkjSmkPhA6DUUF233t2Rdf8L/e1mj/MRDUjhc/Dbwdsq2EEtvfMPRG166oevfmVZB1JOcPOlKzkDIXS0gU8ZYdCEyH+jp5k7xlHnzGSMIg7HakTmn3H0UO96CikeaXqYGQJSgw58BeJduadoJ0vg4Hh7tCC9Alw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yeJXMKcBMdpNzAokRg7vvsmikx3Qbya8C1mc6KG0ea8=; b=MvnxOAHkPXT9aacVpL8mME7B3sW4h3LivtEw47GB4FMrqIU4zoejRvdNOcEH+WLoA1ZxZiUTxD3QD2JKJhy5DkWw2Ghn0d/eTeuz5bL8lpcY5/Bw8Zmt6CmcVuM2Png5PpbMXQ3ejt8v//XunzoMMIZyyFgk4dVhNoRD7Yyqm8e/yh2nvP2KswKvEg/O6RAjSJQQ6tr8R8+p4PXxJPEanWNIrI5yF9yCDV6cpaObb25l99gtNpkMxYO25+nQqkyT0zTdJkKr8FBO4nB/kb4N6bxOPcbz7uzOMckSGOIm8LhYoAGti1SOJmwf+6+9D5bPzYgHOywLQR/hFIlLi4SGtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=google.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yeJXMKcBMdpNzAokRg7vvsmikx3Qbya8C1mc6KG0ea8=; b=YdpAGyg+52US8I47qHHcuobzYnxAaWTibvmBy9ntiXlJl6+EqvHM9wkJFkS2vOidar1Hxtr9geRTiVZAq3oPDwXhTuLTl3bVqhAqMbaW7SfzKVnEKbhJvWE/yZI/T/6m7E0rYWI40bCfWMn6Za62RDWoLJcEu/XsGkpayW2DxwqLmARvWYHpZTnvVq+pmSvLFm7BOrLHl+q27l+9rVwUV/YM4yOgDPHHoprwbRk7C9apP9aAYUK4MW8O7NGeQzP1A1eiJKTbnXimrbYPLFHLkNqihQkFxxAOjfb9M/Ip9iDlaBd7cuduqAHIiy/alc10Y0OjgMEV7KdlcQtDJPDDJQ== Received: from MW4PR03CA0317.namprd03.prod.outlook.com (2603:10b6:303:dd::22) by MN2PR12MB4189.namprd12.prod.outlook.com (2603:10b6:208:1d8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Wed, 27 Jul 2022 17:04:08 +0000 Received: from CO1NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dd:cafe::fa) by MW4PR03CA0317.outlook.office365.com (2603:10b6:303:dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.25 via Frontend Transport; Wed, 27 Jul 2022 17:04:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT034.mail.protection.outlook.com (10.13.174.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Wed, 27 Jul 2022 17:04:08 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 27 Jul 2022 17:04:07 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 27 Jul 2022 10:04:06 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Wed, 27 Jul 2022 10:04:04 -0700 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski , Saeed Mahameed , Leon Romanovsky , "Tariq Toukan" , Eric Dumazet , Paolo Abeni CC: Jiri Pirko , Subject: [PATCH net-next 1/9] net: devlink: remove region snapshot ID tracking dependency on devlink->lock Date: Wed, 27 Jul 2022 20:03:28 +0300 Message-ID: <1658941416-74393-2-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1658941416-74393-1-git-send-email-moshe@nvidia.com> References: <1658941416-74393-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ff9e80a3-5719-44cb-7315-08da6ff204e3 X-MS-TrafficTypeDiagnostic: MN2PR12MB4189:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9SI9fhcp13OTZYqRmXveaO99SvPMWeAWBP1+ETugRx3YwyidaFqD2qos26MU4qzO7csj/lVkywqVGrwhNqjk5nu9s9Mu2Ik3hfaW4XLrhZ98G36vBj6KDADR7DyCR3nCGAqaixirRHU4S+lUvfFa1SUUNGKJZGtKmMBfo/swenu/bhcTpLA15I42VqEHFW0m/x+u29PHX+TbgfqkqZ+xXA3bKyrf7dXUu4RH+CcANRG6352OcSE2dzLLolFDf96TSqGGUtduOYBkmxH77n23dUfChLHSTjQnotbOLbAURVdmc0YrgNeT9Dk2bcPh+IiBv+PVyrjdMGNFNIjULpD1SqKoBYSvujJXBSuVEJ6PNmAb+mYlDMdDVmbDYUz18GPLBiHmTfiuOTjuKa0ofIbpcNrk6LLeng+QxHwrvrg2cagpwwzJwFfcB4n2aZWcLKsf/4Pq61ojuBpmL8DBN3RpUrxbdJdPOmuOWCA2SE6oJGcdXUgPmJ0wf4F4MxGtFSziumqHbDjnOUeIk1EivYHmeKW356kQuO6bxJJ/0nYAf4WSZlJLsdEKq/uM6rRxO+Ymcy0FTEKp7GxRrTouThuPhS03xGMEkrPMpweXAAYtd5dJx2paOp7WIPs8MhZmnbwTjDRplHgF4Cpipt8oXUyi3wM6cEzWqF0sgM7I/vLU1RA7r7eVZKKaR4icP0YNnOK86jUurIpxR3NirlOV39kuI3/0GbiOZ0yXiqgMDcE7OarK02J2fog9yjvX1VZYC+g8jIgPazpT0UAQl/3BcQ+2BTPQQY73MxKl3uM6pcpf52pxVakYdZJy5gO0utPYf6REVrerXclrc5+WwXZlfnQKHA== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(136003)(376002)(396003)(346002)(39860400002)(46966006)(36840700001)(40470700004)(7696005)(478600001)(316002)(110136005)(54906003)(86362001)(40460700003)(2906002)(41300700001)(36756003)(6666004)(8936002)(5660300002)(26005)(2616005)(336012)(356005)(40480700001)(426003)(81166007)(47076005)(186003)(8676002)(4326008)(36860700001)(82740400003)(82310400005)(70206006)(83380400001)(70586007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2022 17:04:08.0036 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff9e80a3-5719-44cb-7315-08da6ff204e3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4189 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko After mlx4 driver is converted to do locked reload, functions to get/put regions snapshot ID may be called from both locked and unlocked context. So resolve this by removing dependency on devlink->lock for region snapshot ID tracking by using internal xa_lock() to maintain shapshot_ids xa_array consistency. Signed-off-by: Jiri Pirko --- net/core/devlink.c | 64 ++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index 698b2d6e0ec7..da002791e300 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -5691,21 +5691,28 @@ static int __devlink_snapshot_id_increment(struct devlink *devlink, u32 id) { unsigned long count; void *p; + int err; - devl_assert_locked(devlink); - + xa_lock(&devlink->snapshot_ids); p = xa_load(&devlink->snapshot_ids, id); - if (WARN_ON(!p)) - return -EINVAL; + if (WARN_ON(!p)) { + err = -EINVAL; + goto unlock; + } - if (WARN_ON(!xa_is_value(p))) - return -EINVAL; + if (WARN_ON(!xa_is_value(p))) { + err = -EINVAL; + goto unlock; + } count = xa_to_value(p); count++; - return xa_err(xa_store(&devlink->snapshot_ids, id, xa_mk_value(count), - GFP_KERNEL)); + err = xa_err(__xa_store(&devlink->snapshot_ids, id, xa_mk_value(count), + GFP_KERNEL)); +unlock: + xa_unlock(&devlink->snapshot_ids); + return err; } /** @@ -5728,25 +5735,26 @@ static void __devlink_snapshot_id_decrement(struct devlink *devlink, u32 id) unsigned long count; void *p; - devl_assert_locked(devlink); - + xa_lock(&devlink->snapshot_ids); p = xa_load(&devlink->snapshot_ids, id); if (WARN_ON(!p)) - return; + goto unlock; if (WARN_ON(!xa_is_value(p))) - return; + goto unlock; count = xa_to_value(p); if (count > 1) { count--; - xa_store(&devlink->snapshot_ids, id, xa_mk_value(count), - GFP_KERNEL); + __xa_store(&devlink->snapshot_ids, id, xa_mk_value(count), + GFP_KERNEL); } else { /* If this was the last user, we can erase this id */ - xa_erase(&devlink->snapshot_ids, id); + __xa_erase(&devlink->snapshot_ids, id); } +unlock: + xa_unlock(&devlink->snapshot_ids); } /** @@ -5767,13 +5775,17 @@ static void __devlink_snapshot_id_decrement(struct devlink *devlink, u32 id) */ static int __devlink_snapshot_id_insert(struct devlink *devlink, u32 id) { - devl_assert_locked(devlink); + int err; - if (xa_load(&devlink->snapshot_ids, id)) + xa_lock(&devlink->snapshot_ids); + if (xa_load(&devlink->snapshot_ids, id)) { + xa_unlock(&devlink->snapshot_ids); return -EEXIST; - - return xa_err(xa_store(&devlink->snapshot_ids, id, xa_mk_value(0), - GFP_KERNEL)); + } + err = xa_err(__xa_store(&devlink->snapshot_ids, id, xa_mk_value(0), + GFP_KERNEL)); + xa_unlock(&devlink->snapshot_ids); + return err; } /** @@ -5794,8 +5806,6 @@ static int __devlink_snapshot_id_insert(struct devlink *devlink, u32 id) */ static int __devlink_region_snapshot_id_get(struct devlink *devlink, u32 *id) { - devl_assert_locked(devlink); - return xa_alloc(&devlink->snapshot_ids, id, xa_mk_value(1), xa_limit_32b, GFP_KERNEL); } @@ -11227,13 +11237,7 @@ EXPORT_SYMBOL_GPL(devlink_region_destroy); */ int devlink_region_snapshot_id_get(struct devlink *devlink, u32 *id) { - int err; - - devl_lock(devlink); - err = __devlink_region_snapshot_id_get(devlink, id); - devl_unlock(devlink); - - return err; + return __devlink_region_snapshot_id_get(devlink, id); } EXPORT_SYMBOL_GPL(devlink_region_snapshot_id_get); @@ -11249,9 +11253,7 @@ EXPORT_SYMBOL_GPL(devlink_region_snapshot_id_get); */ void devlink_region_snapshot_id_put(struct devlink *devlink, u32 id) { - devl_lock(devlink); __devlink_snapshot_id_decrement(devlink, id); - devl_unlock(devlink); } EXPORT_SYMBOL_GPL(devlink_region_snapshot_id_put); From patchwork Wed Jul 27 17:03:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12930650 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6841C04A68 for ; Wed, 27 Jul 2022 17:59:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243208AbiG0R7z (ORCPT ); Wed, 27 Jul 2022 13:59:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242492AbiG0R7c (ORCPT ); Wed, 27 Jul 2022 13:59:32 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2065.outbound.protection.outlook.com [40.107.102.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A36E65924E for ; Wed, 27 Jul 2022 10:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k+r60p0RRtoNRN1Umx1xZGZJNfJ96eE7O6ChgBeVWGu83S4MglFRSRJQI4eNP8PNXAMPsdSRseIid1bNXeETtGUBEi69q7nylmJH/6dKNeVZY0AvLGgKc5TQhRo9u7xuLfa/BAPa7IR6Yrhqtbg5cIEJOuvfWRbTJ1M60Z4uHkLUJ6jQ+WKuDCwxWn6rVFjcvBPfwfLyCk+ivfxmdcje4I29Wv+RiQrczZkuM3J8glaBzf9ajLZVOcu/FlLKSHpbvkJsGUEqdKXSnj+WBtP58P54bYVHPxYNjpxa9YmENOWGm6B5dOPzCDsMBUhPWoZeKvqAFcd9QFhIKPkV+Avwlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7YntpIuMv29X53sdaORpBfKCJfU0s7O1wUzYlFy8sZg=; b=GzgcHCg0x438piygR0WSKCNjVFGyvLWHA17CKwfIp99ewnvC5VDmyR9W86sydMmnKItFsSqx96cIQPtWHlnbzea2zEsz+uEOLTSYStRdU2Y1trSN0+HUhWTBsvNrknajFSlXBxFVWd6f0AgZokddjR9VQeT4QMyhYqdoviU5IyjPVLh5OyyDpCoPZzj3ynzPYkxCc4wcZBWlVGnPQ6VT7d5ZhBHdhxdsmTWLeuGj/y1YldJLdNa6toiFKQmkm2uUP9YUy//jZN1TxD+HfqqtlNsJp2k1q6dA10IxertxHgWVx8sNUM/EaJ7D0Sej1JeQ3+jgBog99NjUTNnmKhJoRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=google.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7YntpIuMv29X53sdaORpBfKCJfU0s7O1wUzYlFy8sZg=; b=QVII/RdoHp9PN1idUhdwlYScKZBCwztb4vr/vONM6PJdLnfwLyNq0r8GdmIBkFlrw/dHdyRQvij7KQP1GaigBL8IgkGMMQ3No4qSGt3jmQlpwe9C/kJUJCGNfEaubpaHhK1n7/MyZWnlVb37ZFHL1TjhlOzLt9JVu8oIAhRaa58lgPW9WFtPfsGO/vB/JHlpV7qFUnb3/BdWplQbmeGHboyPAmhhXbYWewlL2F9lJkwWsEFC8KxO3+LvfyntfRwDw5/GPfaFcDiFcb6TQEedRqc4nA2eHGT9FHa6/nXhXFL6an9fKyehhDRCbVa4HR7eXhwkuHGQ9kV/8SmnGQy6Vg== Received: from BN7PR06CA0051.namprd06.prod.outlook.com (2603:10b6:408:34::28) by BN8PR12MB3603.namprd12.prod.outlook.com (2603:10b6:408:4a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Wed, 27 Jul 2022 17:04:12 +0000 Received: from BN8NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:408:34:cafe::97) by BN7PR06CA0051.outlook.office365.com (2603:10b6:408:34::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20 via Frontend Transport; Wed, 27 Jul 2022 17:04:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by BN8NAM11FT057.mail.protection.outlook.com (10.13.177.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Wed, 27 Jul 2022 17:04:11 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 27 Jul 2022 17:04:10 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 27 Jul 2022 10:04:09 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Wed, 27 Jul 2022 10:04:07 -0700 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski , Saeed Mahameed , Leon Romanovsky , "Tariq Toukan" , Eric Dumazet , Paolo Abeni CC: Jiri Pirko , Subject: [PATCH net-next 2/9] net: devlink: remove region snapshots list dependency on devlink->lock Date: Wed, 27 Jul 2022 20:03:29 +0300 Message-ID: <1658941416-74393-3-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1658941416-74393-1-git-send-email-moshe@nvidia.com> References: <1658941416-74393-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fa3bd2fc-074f-4138-0479-08da6ff20731 X-MS-TrafficTypeDiagnostic: BN8PR12MB3603:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f7+RQPkJXx/9D7uNzChbk5fhmlg2eAhWmkNWPE8yQskUJhZen3Af0mWsYkZcc6ie42PAlt6NZiCe5iyKpwrVZsHWXO5WpMb71yZYDmKqMWcnAeTXxvAUW+DdzcytjcFcpmw4Oun8yTW0XQiOYbhtoDg6U4dQ7NC7f/jOmo7U0qGXdD2YDZDSwtOqn4CfFJTiBdfD5+IxN7YQIt58bqzf6v1V4YuUAbCD1zXSdLbfzgty6oLjhXeMAmaPwhhs1j+V9ZVC7wAdF+S1cL64tw0QF4f5TRw+n3b79C3LfORgwizpE1aBUEqo1/GKuYWNTLkS65lW8CFs3nRa/rJMSDDQQvsxyOApnIUeNObWYBcgxX+5/zoJ5cQD65itm6xZsZXx1fwVI2ssapEiyTx5NGSdlfxGDhOTPig89TbbEJaodkplzg2Qm/mTVGOZvVcutWmJMdqyGzH7944z3LVFWIFC0QGHtkt38kAQkGdqZKqOl88rwpmakKwqZqY+/oPe59AM6HX2f5iptJzwNboGyir8zJ8p7euHNTK88YAAJqYfo3qWFV1bj1mLZcum3QU36GVJMwyf7ExrlqSSdlsxKbnNlOE633OW7cBnfhPUwjeb23XD9Z7GFkc54e6bMvcQ7Z5QbNEja6pQwEMbD9hcc+Vqv3Dpth7wNkxyqBRobqrQ4L7nE4cTQVFchl8xzaGizgEFTFLT2Pl1U+ehLpRNhQVAXlgpM2CfTsz3r4brKBDLN9MBFxNJmuAVX9y7c1/gADQj0EPm5r24cQPALocggMYcFGcckDyOxMgpVLlzuw1g2JUcWGK1kMoK3iKirQactBqG3seRxhBMf0LVrxhxpcVXAg== X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(346002)(376002)(396003)(136003)(39860400002)(36840700001)(46966006)(40470700004)(36756003)(2906002)(82310400005)(40480700001)(356005)(8676002)(8936002)(4326008)(86362001)(5660300002)(70206006)(70586007)(110136005)(316002)(54906003)(40460700003)(7696005)(47076005)(426003)(336012)(6666004)(2616005)(478600001)(186003)(26005)(41300700001)(81166007)(83380400001)(36860700001)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2022 17:04:11.7112 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa3bd2fc-074f-4138-0479-08da6ff20731 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3603 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko After mlx4 driver is converted to do locked reload, devlink_region_snapshot_create() may be called from both locked and unlocked context. So resolve this by removing dependency on devlink->lock for region snapshots list consistency and introduce new mutex to ensure it. Signed-off-by: Jiri Pirko --- net/core/devlink.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index da002791e300..4de1f93053a2 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -695,6 +695,10 @@ struct devlink_region { const struct devlink_region_ops *ops; const struct devlink_port_region_ops *port_ops; }; + struct mutex snapshot_lock; /* protects snapshot_list, + * max_snapshots and cur_snapshots + * consistency. + */ struct list_head snapshot_list; u32 max_snapshots; u32 cur_snapshots; @@ -5818,7 +5822,7 @@ static int __devlink_region_snapshot_id_get(struct devlink *devlink, u32 *id) * Multiple snapshots can be created on a region. * The @snapshot_id should be obtained using the getter function. * - * Must be called only while holding the devlink instance lock. + * Must be called only while holding the region snapshot lock. * * @region: devlink region of the snapshot * @data: snapshot data @@ -5832,7 +5836,7 @@ __devlink_region_snapshot_create(struct devlink_region *region, struct devlink_snapshot *snapshot; int err; - devl_assert_locked(devlink); + lockdep_assert_held(®ion->snapshot_lock); /* check if region can hold one more snapshot */ if (region->cur_snapshots == region->max_snapshots) @@ -5870,7 +5874,7 @@ static void devlink_region_snapshot_del(struct devlink_region *region, { struct devlink *devlink = region->devlink; - devl_assert_locked(devlink); + lockdep_assert_held(®ion->snapshot_lock); devlink_nl_region_notify(region, snapshot, DEVLINK_CMD_REGION_DEL); region->cur_snapshots--; @@ -6049,11 +6053,15 @@ static int devlink_nl_cmd_region_del(struct sk_buff *skb, if (!region) return -EINVAL; + mutex_lock(®ion->snapshot_lock); snapshot = devlink_region_snapshot_get_by_id(region, snapshot_id); - if (!snapshot) + if (!snapshot) { + mutex_unlock(®ion->snapshot_lock); return -EINVAL; + } devlink_region_snapshot_del(region, snapshot); + mutex_unlock(®ion->snapshot_lock); return 0; } @@ -6101,9 +6109,12 @@ devlink_nl_cmd_region_new(struct sk_buff *skb, struct genl_info *info) return -EOPNOTSUPP; } + mutex_lock(®ion->snapshot_lock); + if (region->cur_snapshots == region->max_snapshots) { NL_SET_ERR_MSG_MOD(info->extack, "The region has reached the maximum number of stored snapshots"); - return -ENOSPC; + err = -ENOSPC; + goto unlock; } snapshot_id_attr = info->attrs[DEVLINK_ATTR_REGION_SNAPSHOT_ID]; @@ -6112,17 +6123,18 @@ devlink_nl_cmd_region_new(struct sk_buff *skb, struct genl_info *info) if (devlink_region_snapshot_get_by_id(region, snapshot_id)) { NL_SET_ERR_MSG_MOD(info->extack, "The requested snapshot id is already in use"); - return -EEXIST; + err = -EEXIST; + goto unlock; } err = __devlink_snapshot_id_insert(devlink, snapshot_id); if (err) - return err; + goto unlock; } else { err = __devlink_region_snapshot_id_get(devlink, &snapshot_id); if (err) { NL_SET_ERR_MSG_MOD(info->extack, "Failed to allocate a new snapshot id"); - return err; + goto unlock; } } @@ -6160,16 +6172,20 @@ devlink_nl_cmd_region_new(struct sk_buff *skb, struct genl_info *info) goto err_notify; } + mutex_unlock(®ion->snapshot_lock); return 0; err_snapshot_create: region->ops->destructor(data); err_snapshot_capture: __devlink_snapshot_id_decrement(devlink, snapshot_id); + mutex_unlock(®ion->snapshot_lock); return err; err_notify: devlink_region_snapshot_del(region, snapshot); +unlock: + mutex_unlock(®ion->snapshot_lock); return err; } @@ -11095,6 +11111,7 @@ struct devlink_region *devl_region_create(struct devlink *devlink, region->ops = ops; region->size = region_size; INIT_LIST_HEAD(®ion->snapshot_list); + mutex_init(®ion->snapshot_lock); list_add_tail(®ion->list, &devlink->region_list); devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW); @@ -11168,6 +11185,7 @@ devlink_port_region_create(struct devlink_port *port, region->port_ops = ops; region->size = region_size; INIT_LIST_HEAD(®ion->snapshot_list); + mutex_init(®ion->snapshot_lock); list_add_tail(®ion->list, &port->region_list); devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW); @@ -11197,6 +11215,7 @@ void devl_region_destroy(struct devlink_region *region) devlink_region_snapshot_del(region, snapshot); list_del(®ion->list); + mutex_destroy(®ion->snapshot_lock); devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_DEL); kfree(region); @@ -11272,13 +11291,11 @@ EXPORT_SYMBOL_GPL(devlink_region_snapshot_id_put); int devlink_region_snapshot_create(struct devlink_region *region, u8 *data, u32 snapshot_id) { - struct devlink *devlink = region->devlink; int err; - devl_lock(devlink); + mutex_lock(®ion->snapshot_lock); err = __devlink_region_snapshot_create(region, data, snapshot_id); - devl_unlock(devlink); - + mutex_unlock(®ion->snapshot_lock); return err; } EXPORT_SYMBOL_GPL(devlink_region_snapshot_create); From patchwork Wed Jul 27 17:03:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12930649 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D42DEC19F28 for ; Wed, 27 Jul 2022 17:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242628AbiG0R74 (ORCPT ); Wed, 27 Jul 2022 13:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241780AbiG0R7d (ORCPT ); Wed, 27 Jul 2022 13:59:33 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2054.outbound.protection.outlook.com [40.107.243.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CFC359259 for ; Wed, 27 Jul 2022 10:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GaPUYnLbF/03Vk4TFeVHjJI3VLwPjEHfLzex3LSVx/8SQAVvQZMSjc+aNHuZMzr0lMYtoWYMozNr/+UgC7bS0OuwK3fvEDpe1w/6NOnG+H8gPoaNkcqqWXnD1du1ZSvlx9UOfOePq5G10Wz89K8jF1h++fhpH9tVikPr4sANkU49eVeQcD5t9us4BHNznYH0Ce0FydLN772uYy3V8bbfPBbQ4deRHKB7c8dudv6UyhJUkmkNft/FEygVfASZsJnpCNKno68TrRre9zwadi8XWyaS9qkmlO+CSQR9mGiMMHPeXCrDblRekWXLahR+BJvkcsut6nX4gmySt+OWaxpI+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ofFoM3AA0XT/yno49TXfQs6cY2VrsYsd0wHbsS3jR/g=; b=NR2hKeH7szNzFkP7Fd9NzA6fO5AKAIA8dbn9xV6y+TdmmpEUQI/ifaAuLqe1jwCdyPAetsY0qneb8zhNL4ojpCmmO7aS7D36Uw26nfaZwxNaVYDMSfp+errgwbzwJ73VibyRz2BUqGFla4vZcoP7b2mxKbfu/M+yw9TINKoR3KB89dIw9Jr49Gq4qhUoOx47hEz9xGGc+GtZiqw49D3046S3sRrwyRXUt9oKo0Y5KHMKjXAjaeW9ruZp2hyQQNW0aVWfDK7F9Ldcvk1rbXx8iuLHl8c+H335BH9sSpkaE2kiXKPLJW3KssaCEA7pTPpn763tbfQmxFdg7QhSQ4kXIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=google.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ofFoM3AA0XT/yno49TXfQs6cY2VrsYsd0wHbsS3jR/g=; b=N/yjOc9wT1Rg0C1e0MwmOBtsfu9ZISNl1Ti5EfXxw/7oCHDrGjC29YpykKJA3JOjh/Y3VU4mQ05PZ1Gg4g8jHSJU+/Sh5wSY3AHxRho/tyyF6tLkq98JdP4JsuoD5Nx/MnHkx9xhvu0GXSNu5IibjtUTV89SEir0Xg32Diop8kohyyyiw/WfogY4Sy3AUvaVbuzyBhe06fgUhAaDydPH6VYC61O+/hFAR65fYTFF8xl2so9JKXId+LW+vVouP2oL/0D/4nYuIOU+4X1DHKyHPG6FX/astUdEehU4TJriMng0V4qVG7HeaWwAFYG+63ewrTFegc/zTuUWX54o7MGx2g== Received: from MW4PR03CA0156.namprd03.prod.outlook.com (2603:10b6:303:8d::11) by BN6PR12MB1138.namprd12.prod.outlook.com (2603:10b6:404:20::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Wed, 27 Jul 2022 17:04:14 +0000 Received: from CO1NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::98) by MW4PR03CA0156.outlook.office365.com (2603:10b6:303:8d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.20 via Frontend Transport; Wed, 27 Jul 2022 17:04:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.236) by CO1NAM11FT026.mail.protection.outlook.com (10.13.175.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Wed, 27 Jul 2022 17:04:13 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 27 Jul 2022 17:04:13 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 27 Jul 2022 10:04:12 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Wed, 27 Jul 2022 10:04:10 -0700 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski , Saeed Mahameed , Leon Romanovsky , "Tariq Toukan" , Eric Dumazet , Paolo Abeni CC: Jiri Pirko , , Moshe Shemesh Subject: [PATCH net-next 3/9] net/mlx5: Move fw reset unload to mlx5_fw_reset_complete_reload Date: Wed, 27 Jul 2022 20:03:30 +0300 Message-ID: <1658941416-74393-4-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1658941416-74393-1-git-send-email-moshe@nvidia.com> References: <1658941416-74393-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6ea8fbd5-eff1-4271-ff36-08da6ff2083b X-MS-TrafficTypeDiagnostic: BN6PR12MB1138:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PGruSFtCvGdm8xOI2ocV9juoOdvAyx7Q1ANyYHVcCl45IJxpaZ9DWHNB6HknCUDPcLEgyDseI3of3eQ26PRYF/eCJx4PcsFD1wyN/X5jq24A3eikptqQgsYC8lTe7qDxQHTp3gKpGIQYSj1siOPGYAHYbdHyD5kBxofVjBUh9keBRBdutwSNHb6MQKXpZ4hE8HPjxPO5iq+sQIV50n/Yybzc90+3b5jCWwCRacIam3keDz/QSIvBkbJ+xefe8l/RlQOdNPFCwyNsvB3m0s7iKDtd+qVE/m+37hS2YQVLRFLQQoYAwzR9fr+VsqtKlIDa9EyqJAgls/NWgTfGM2lVlXAkHdTxGbJ/4JJjM/T7PrzOVQuNWVWU/zD88GRvWSDYl//s79qrKS3sgtD/r5AgDfUn2/1KQ25Z9pUxLdIpOOmcYNoEMUCROeP8LeCEpX5BKuCbEDpZ866OdwvYhvsEdIo3WJ0Meoudit7/FJ5Y1TlpJ2OGRFWsrHRokAzywLSZmefd8XGAH0HU66dosKeuLDp8HDze4XOmPgK7xUu3RTM62N+U9Led462rBBD0X1cmWaR00Yw8AVccMSEwuXjI5Zjr83Kq1OfWkdCCt72jNzFf3FnJqCgKvQMv5lOtrj6zvn2nkyQTFu5cwQxJ7oS9yh0e/2IPAAM+DMRosTisVHGgkxHmfuKGEVKuRhsm+KrFR3IcDPe/HrDc75n4ky8pPwIVM7mMBpcMLIpXRLHaLMajJa3rExs4Bi1q4ZqoEOTgOkgfoVGi6+1nkRjr0XVplSju7dSY22C/cILay03paPdnUQTP3iPqWc4Zm9x4vavwnqUp7YhLC70Ut1KCmM3k4g== X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(346002)(396003)(376002)(136003)(36840700001)(40470700004)(46966006)(82310400005)(110136005)(54906003)(7696005)(83380400001)(107886003)(426003)(47076005)(82740400003)(70206006)(70586007)(4326008)(8676002)(81166007)(356005)(316002)(40460700003)(40480700001)(8936002)(5660300002)(478600001)(36756003)(36860700001)(6666004)(186003)(2906002)(41300700001)(26005)(336012)(86362001)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2022 17:04:13.6171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ea8fbd5-eff1-4271-ff36-08da6ff2083b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1138 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Refactor fw reset code to have the unload driver part done on mlx5_fw_reset_complete_reload(), so if it was called by the PF which initiated the reload fw activate flow, the unload part will be handled by the mlx5_devlink_reload_fw_activate() callback itself and not by the reset event work. This will be used by the downstream patch to invoke devlink reload callbacks with devlink lock held. Signed-off-by: Moshe Shemesh Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 11 ++++++++++- drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 10 +++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index f85166e587f2..41bb50d94caa 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -104,7 +104,16 @@ static int mlx5_devlink_reload_fw_activate(struct devlink *devlink, struct netli if (err) return err; - return mlx5_fw_reset_wait_reset_done(dev); + err = mlx5_fw_reset_wait_reset_done(dev); + if (err) + return err; + + mlx5_unload_one(dev); + err = mlx5_health_wait_pci_up(dev); + if (err) + NL_SET_ERR_MSG_MOD(extack, "FW activate aborted, PCI reads fail after reset"); + + return err; } static int mlx5_devlink_trigger_fw_live_patch(struct devlink *devlink, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c index 052af4901c0b..e8896f368362 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c @@ -149,6 +149,9 @@ static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev) if (test_bit(MLX5_FW_RESET_FLAGS_PENDING_COMP, &fw_reset->reset_flags)) { complete(&fw_reset->done); } else { + mlx5_unload_one(dev); + if (mlx5_health_wait_pci_up(dev)) + mlx5_core_err(dev, "reset reload flow aborted, PCI reads still not working\n"); mlx5_load_one(dev, false); devlink_remote_reload_actions_performed(priv_to_devlink(dev), 0, BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT) | @@ -183,15 +186,9 @@ static void mlx5_sync_reset_reload_work(struct work_struct *work) struct mlx5_fw_reset *fw_reset = container_of(work, struct mlx5_fw_reset, reset_reload_work); struct mlx5_core_dev *dev = fw_reset->dev; - int err; mlx5_sync_reset_clear_reset_requested(dev, false); mlx5_enter_error_state(dev, true); - mlx5_unload_one(dev); - err = mlx5_health_wait_pci_up(dev); - if (err) - mlx5_core_err(dev, "reset reload flow aborted, PCI reads still not working\n"); - fw_reset->ret = err; mlx5_fw_reset_complete_reload(dev); } @@ -395,7 +392,6 @@ static void mlx5_sync_reset_now_event(struct work_struct *work) } mlx5_enter_error_state(dev, true); - mlx5_unload_one(dev); done: fw_reset->ret = err; mlx5_fw_reset_complete_reload(dev); From patchwork Wed Jul 27 17:03:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12930654 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 074ECC04A68 for ; Wed, 27 Jul 2022 18:00:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243215AbiG0SAJ (ORCPT ); Wed, 27 Jul 2022 14:00:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242758AbiG0R7g (ORCPT ); Wed, 27 Jul 2022 13:59:36 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2051.outbound.protection.outlook.com [40.107.243.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0577D59264 for ; Wed, 27 Jul 2022 10:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WZ+K0hSonVJoKF9P1pfWP8yrTxRbjMzi7GxCdHaj4lruyZpS4WcRcgFjmPMTMeEboAWcTgkNfX6lMoJsIVSchkKRL/tihVbrH9y5f6Hzfpk7YXqHvBwaQcAN/LAIwkIRI4aTbvrh7USK9p45LbtcOR8ZdvxYQD7JeOIicsNwR5n0hexJfQb4v9+bKczOz0/kh3nt5k3DymTuGn/DXCTiwBvtb+MGm1STXKnn+QyANWEB6heNsJWhYsY9QlZq5/rF1AzIURRGibV/wQYreN1+atzeCmW6TRZL40MUDOgDBkbtcM3La0rw7QTYxbK9cCb1oSKYeZxezYP2J4YqM+mq3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=p8D+dIvNBnYIuuwEElDEylQuGbF0gsqEGpG7oc+cFNE=; b=buSVavJXha8wXc3GePHWBKAoZ/dCb4fn1dRocgHkUpBMKVPD3x6oWfoEC9u5a22COtFPgbmXM0el9ddCUMXeN8sJy4euoJm+hpheDQHOHpXZinSA8mL7lCQCzJsVOy0S3Iv+IT/wEm1Flh+wXRQe0TNUFBMWi0dOa0SM7n1CVVHMnjM53cFkqYU+cvGxrxH1vEGTD/borD6/ep7yUBJSTevAFHIptgGKzTtzX2rhj6o3vLuWRX6qgSex9fzY8cm5tuclZ8OEnBYxsNkRkwytOwbPx6KKoFQ748Kg3iyCl9uXn7y/BhF6AdU9+45rMgI+zbPwvpGJKPuB2vrkC6Tk5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=google.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p8D+dIvNBnYIuuwEElDEylQuGbF0gsqEGpG7oc+cFNE=; b=r3yTjImqjOnDVq9nT7AFmkXNJQBBBGKvwpGsBAHT+qj9jUxSF6T6o5DjM6PvZVOLonANJGe+GRxGkRoX5mXyeRVQLItSt7dsiIwv8kRODi+SF9riATf4PkKzaQ3lPQCmx/lpHQbek/KARyxoFmX9fMN+UROJUQS+romJVlqbFoZIRBYVFz/rmWn9cY7sA+w+OkezNPOt7sLXHbNSUcIu+xte6iNU53eKm5w6rTOcWenCQBffLudvxSTYS2mdJpoz7Ktv6aCMBZW4YZp5jyEmbp38pYxJkJzAoWNCz730DmafNQeBQsAr6amf+SqZ3luYdNiI38AmSxoz0t8uJNslzQ== Received: from MW4PR04CA0033.namprd04.prod.outlook.com (2603:10b6:303:6a::8) by BYAPR12MB3269.namprd12.prod.outlook.com (2603:10b6:a03:12f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.20; Wed, 27 Jul 2022 17:04:17 +0000 Received: from CO1NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6a:cafe::57) by MW4PR04CA0033.outlook.office365.com (2603:10b6:303:6a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20 via Frontend Transport; Wed, 27 Jul 2022 17:04:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT029.mail.protection.outlook.com (10.13.174.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Wed, 27 Jul 2022 17:04:16 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 27 Jul 2022 17:04:16 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 27 Jul 2022 10:04:15 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Wed, 27 Jul 2022 10:04:13 -0700 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski , Saeed Mahameed , Leon Romanovsky , "Tariq Toukan" , Eric Dumazet , Paolo Abeni CC: Jiri Pirko , , Moshe Shemesh Subject: [PATCH net-next 4/9] net/mlx5: Lock mlx5 devlink reload callbacks Date: Wed, 27 Jul 2022 20:03:31 +0300 Message-ID: <1658941416-74393-5-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1658941416-74393-1-git-send-email-moshe@nvidia.com> References: <1658941416-74393-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a12ba81a-c5d2-404c-3d8e-08da6ff20a1e X-MS-TrafficTypeDiagnostic: BYAPR12MB3269:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eJkZCwFa8Eba2GRtaejuQXKqFb5hW1lwUyWoAgBku0pHc/XxW091l8MKqHDgN72QN1tvRrzvSIvpwhSycj6i3eyJ3Ny/XpIHl6CIV5c1b78ioOw4v66zFfL2S18ABlaW/sby4kCJZxqltrKRrLh69njWF0zGMBX9CowTGkd0OugOhGW9aOkhpOoKK3E2ciABjsUmbAXHyCMHjYazSthziheD7De3C4B0ylBAbvUP6DxXNQ042uxMZS/bfS+cIsr1EidhOONC6U3OqRaBveKjY6dfoKpWaXBlZ97094HdPBi2icz/YrLTwKlAd7JHO3QV0iG6jy3r/jkEgrcxDoVbbhnPs4Gebd8Ut3u/3serTe5agTFRGgCVJVAXofL1sFQzpIXXQ7PHhQIjb0IWHGZukzFP5nMUvAjiZnOTtKh7KKO40AI7E4fFRoUm+xjobiYUSwxYc0myt1rUA3drsOiCaFwTSX3MH7I4CENxoaHUAlXa3NGZ6g5HtuOD5uBkdFl3emiTxp4Dhcm5MmUjrNLAnQ83vdJzjKuzXnEf+P8he2xqXeS1YA+bnhPEwtX9hhhtxOJthh/1IPSlFcrBHkYgMU8ODp5HTu8ojQZ3mrsfudXB1kh2KGlra8GgLAsebgPcYRqbzy50UdNjJ+nXRBW236aFjgPhKMcbH/MwMT86LaAiuTY9W/GUvSaYECgWPrk7KDq6/24awjcaESD0vlya90Tii2i+JrgRrCZCM6QKaBxXnMw1AhkJu53p4ZasOaZF0LebqAHHPG6o0wC9czRaEb5pznEfJiT+dHQaQfFldVw6iGm8GmRjilnsivLn03NAIGTOQrK3RHIpwgvI59MURw== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(396003)(39860400002)(136003)(376002)(346002)(40470700004)(36840700001)(46966006)(8936002)(82740400003)(36860700001)(30864003)(5660300002)(83380400001)(41300700001)(426003)(2906002)(40460700003)(40480700001)(7696005)(2616005)(54906003)(6666004)(36756003)(316002)(81166007)(356005)(86362001)(47076005)(4326008)(70586007)(478600001)(82310400005)(8676002)(186003)(26005)(110136005)(70206006)(107886003)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2022 17:04:16.7463 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a12ba81a-c5d2-404c-3d8e-08da6ff20a1e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3269 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Change devlink instance locks in mlx5 driver to have devlink reload callbacks locked, while keeping all driver paths which lead to devl_ API functions called by the driver locked. Add mlx5_load_one_devl_locked() and mlx5_unload_one_devl_locked() which are used by the paths which are already locked such as devlink reload callbacks. This patch makes the driver use devl_ API also for traps register as these functions are called from the driver paths parallel to reload that requires locking now. Signed-off-by: Moshe Shemesh Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 19 ++----- .../net/ethernet/mellanox/mlx5/core/devlink.c | 50 ++++++++++++------- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 18 ++----- .../net/ethernet/mellanox/mlx5/core/main.c | 34 ++++++++++++- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 2 + .../net/ethernet/mellanox/mlx5/core/sriov.c | 6 +++ 6 files changed, 79 insertions(+), 50 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c index ccf2068d2e79..0571e40c6ee5 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c @@ -335,13 +335,12 @@ static void del_adev(struct auxiliary_device *adev) int mlx5_attach_device(struct mlx5_core_dev *dev) { - struct devlink *devlink = priv_to_devlink(dev); struct mlx5_priv *priv = &dev->priv; struct auxiliary_device *adev; struct auxiliary_driver *adrv; int ret = 0, i; - devl_lock(devlink); + devl_assert_locked(priv_to_devlink(dev)); mutex_lock(&mlx5_intf_mutex); priv->flags &= ~MLX5_PRIV_FLAGS_DETACH; priv->flags |= MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW; @@ -394,20 +393,18 @@ int mlx5_attach_device(struct mlx5_core_dev *dev) } priv->flags &= ~MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW; mutex_unlock(&mlx5_intf_mutex); - devl_unlock(devlink); return ret; } void mlx5_detach_device(struct mlx5_core_dev *dev) { - struct devlink *devlink = priv_to_devlink(dev); struct mlx5_priv *priv = &dev->priv; struct auxiliary_device *adev; struct auxiliary_driver *adrv; pm_message_t pm = {}; int i; - devl_lock(devlink); + devl_assert_locked(priv_to_devlink(dev)); mutex_lock(&mlx5_intf_mutex); priv->flags |= MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW; for (i = ARRAY_SIZE(mlx5_adev_devices) - 1; i >= 0; i--) { @@ -441,21 +438,17 @@ void mlx5_detach_device(struct mlx5_core_dev *dev) priv->flags &= ~MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW; priv->flags |= MLX5_PRIV_FLAGS_DETACH; mutex_unlock(&mlx5_intf_mutex); - devl_unlock(devlink); } int mlx5_register_device(struct mlx5_core_dev *dev) { - struct devlink *devlink; int ret; - devlink = priv_to_devlink(dev); - devl_lock(devlink); + devl_assert_locked(priv_to_devlink(dev)); mutex_lock(&mlx5_intf_mutex); dev->priv.flags &= ~MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV; ret = mlx5_rescan_drivers_locked(dev); mutex_unlock(&mlx5_intf_mutex); - devl_unlock(devlink); if (ret) mlx5_unregister_device(dev); @@ -464,15 +457,11 @@ int mlx5_register_device(struct mlx5_core_dev *dev) void mlx5_unregister_device(struct mlx5_core_dev *dev) { - struct devlink *devlink; - - devlink = priv_to_devlink(dev); - devl_lock(devlink); + devl_assert_locked(priv_to_devlink(dev)); mutex_lock(&mlx5_intf_mutex); dev->priv.flags = MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV; mlx5_rescan_drivers_locked(dev); mutex_unlock(&mlx5_intf_mutex); - devl_unlock(devlink); } static int add_drivers(struct mlx5_core_dev *dev) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index 41bb50d94caa..1c05a7091698 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -108,7 +108,7 @@ static int mlx5_devlink_reload_fw_activate(struct devlink *devlink, struct netli if (err) return err; - mlx5_unload_one(dev); + mlx5_unload_one_devl_locked(dev); err = mlx5_health_wait_pci_up(dev); if (err) NL_SET_ERR_MSG_MOD(extack, "FW activate aborted, PCI reads fail after reset"); @@ -143,6 +143,7 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change, struct mlx5_core_dev *dev = devlink_priv(devlink); struct pci_dev *pdev = dev->pdev; bool sf_dev_allocated; + int ret = 0; sf_dev_allocated = mlx5_sf_dev_allocated(dev); if (sf_dev_allocated) { @@ -163,19 +164,25 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change, NL_SET_ERR_MSG_MOD(extack, "reload while VFs are present is unfavorable"); } + devl_lock(devlink); switch (action) { case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: - mlx5_unload_one(dev); - return 0; + mlx5_unload_one_devl_locked(dev); + break; case DEVLINK_RELOAD_ACTION_FW_ACTIVATE: if (limit == DEVLINK_RELOAD_LIMIT_NO_RESET) - return mlx5_devlink_trigger_fw_live_patch(devlink, extack); - return mlx5_devlink_reload_fw_activate(devlink, extack); + ret = mlx5_devlink_trigger_fw_live_patch(devlink, extack); + else + ret = mlx5_devlink_reload_fw_activate(devlink, extack); + break; default: /* Unsupported action should not get to this function */ WARN_ON(1); - return -EOPNOTSUPP; + ret = -EOPNOTSUPP; } + + devl_unlock(devlink); + return ret; } static int mlx5_devlink_reload_up(struct devlink *devlink, enum devlink_reload_action action, @@ -183,24 +190,29 @@ static int mlx5_devlink_reload_up(struct devlink *devlink, enum devlink_reload_a struct netlink_ext_ack *extack) { struct mlx5_core_dev *dev = devlink_priv(devlink); + int ret = 0; + devl_lock(devlink); *actions_performed = BIT(action); switch (action) { case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: - return mlx5_load_one(dev, false); + ret = mlx5_load_one_devl_locked(dev, false); + break; case DEVLINK_RELOAD_ACTION_FW_ACTIVATE: if (limit == DEVLINK_RELOAD_LIMIT_NO_RESET) break; /* On fw_activate action, also driver is reloaded and reinit performed */ *actions_performed |= BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT); - return mlx5_load_one(dev, false); + ret = mlx5_load_one_devl_locked(dev, false); + break; default: /* Unsupported action should not get to this function */ WARN_ON(1); - return -EOPNOTSUPP; + ret = -EOPNOTSUPP; } - return 0; + devl_unlock(devlink); + return ret; } static struct mlx5_devlink_trap *mlx5_find_trap_by_id(struct mlx5_core_dev *dev, int trap_id) @@ -837,28 +849,28 @@ static int mlx5_devlink_traps_register(struct devlink *devlink) struct mlx5_core_dev *core_dev = devlink_priv(devlink); int err; - err = devlink_trap_groups_register(devlink, mlx5_trap_groups_arr, - ARRAY_SIZE(mlx5_trap_groups_arr)); + err = devl_trap_groups_register(devlink, mlx5_trap_groups_arr, + ARRAY_SIZE(mlx5_trap_groups_arr)); if (err) return err; - err = devlink_traps_register(devlink, mlx5_traps_arr, ARRAY_SIZE(mlx5_traps_arr), - &core_dev->priv); + err = devl_traps_register(devlink, mlx5_traps_arr, ARRAY_SIZE(mlx5_traps_arr), + &core_dev->priv); if (err) goto err_trap_group; return 0; err_trap_group: - devlink_trap_groups_unregister(devlink, mlx5_trap_groups_arr, - ARRAY_SIZE(mlx5_trap_groups_arr)); + devl_trap_groups_unregister(devlink, mlx5_trap_groups_arr, + ARRAY_SIZE(mlx5_trap_groups_arr)); return err; } static void mlx5_devlink_traps_unregister(struct devlink *devlink) { - devlink_traps_unregister(devlink, mlx5_traps_arr, ARRAY_SIZE(mlx5_traps_arr)); - devlink_trap_groups_unregister(devlink, mlx5_trap_groups_arr, - ARRAY_SIZE(mlx5_trap_groups_arr)); + devl_traps_unregister(devlink, mlx5_traps_arr, ARRAY_SIZE(mlx5_traps_arr)); + devl_trap_groups_unregister(devlink, mlx5_trap_groups_arr, + ARRAY_SIZE(mlx5_trap_groups_arr)); } int mlx5_devlink_register(struct devlink *devlink) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index 30a6c9fbf1b6..6aa58044b949 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c @@ -1300,20 +1300,19 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int num_vfs) */ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) { - struct devlink *devlink; bool toggle_lag; int ret; if (!mlx5_esw_allowed(esw)) return 0; + devl_assert_locked(priv_to_devlink(esw->dev)); + toggle_lag = !mlx5_esw_is_fdb_created(esw); if (toggle_lag) mlx5_lag_disable_change(esw->dev); - devlink = priv_to_devlink(esw->dev); - devl_lock(devlink); down_write(&esw->mode_lock); if (!mlx5_esw_is_fdb_created(esw)) { ret = mlx5_eswitch_enable_locked(esw, num_vfs); @@ -1327,7 +1326,6 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) esw->esw_funcs.num_vfs = num_vfs; } up_write(&esw->mode_lock); - devl_unlock(devlink); if (toggle_lag) mlx5_lag_enable_change(esw->dev); @@ -1338,13 +1336,10 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) /* When disabling sriov, free driver level resources. */ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw, bool clear_vf) { - struct devlink *devlink; - if (!mlx5_esw_allowed(esw)) return; - devlink = priv_to_devlink(esw->dev); - devl_lock(devlink); + devl_assert_locked(priv_to_devlink(esw->dev)); down_write(&esw->mode_lock); /* If driver is unloaded, this function is called twice by remove_one() * and mlx5_unload(). Prevent the second call. @@ -1373,7 +1368,6 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw, bool clear_vf) unlock: up_write(&esw->mode_lock); - devl_unlock(devlink); } /* Free resources for corresponding eswitch mode. It is called by devlink @@ -1407,18 +1401,14 @@ void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw) void mlx5_eswitch_disable(struct mlx5_eswitch *esw) { - struct devlink *devlink; - if (!mlx5_esw_allowed(esw)) return; + devl_assert_locked(priv_to_devlink(esw->dev)); mlx5_lag_disable_change(esw->dev); - devlink = priv_to_devlink(esw->dev); - devl_lock(devlink); down_write(&esw->mode_lock); mlx5_eswitch_disable_locked(esw); up_write(&esw->mode_lock); - devl_unlock(devlink); mlx5_lag_enable_change(esw->dev); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 8b621c1ddd14..01fcb23eb69a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1304,8 +1304,10 @@ static void mlx5_unload(struct mlx5_core_dev *dev) int mlx5_init_one(struct mlx5_core_dev *dev) { + struct devlink *devlink = priv_to_devlink(dev); int err = 0; + devl_lock(devlink); mutex_lock(&dev->intf_state_mutex); dev->state = MLX5_DEVICE_STATE_UP; @@ -1334,6 +1336,7 @@ int mlx5_init_one(struct mlx5_core_dev *dev) goto err_register; mutex_unlock(&dev->intf_state_mutex); + devl_unlock(devlink); return 0; err_register: @@ -1348,11 +1351,15 @@ int mlx5_init_one(struct mlx5_core_dev *dev) err_function: dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR; mutex_unlock(&dev->intf_state_mutex); + devl_unlock(devlink); return err; } void mlx5_uninit_one(struct mlx5_core_dev *dev) { + struct devlink *devlink = priv_to_devlink(dev); + + devl_lock(devlink); mutex_lock(&dev->intf_state_mutex); mlx5_unregister_device(dev); @@ -1371,13 +1378,15 @@ void mlx5_uninit_one(struct mlx5_core_dev *dev) mlx5_function_teardown(dev, true); out: mutex_unlock(&dev->intf_state_mutex); + devl_unlock(devlink); } -int mlx5_load_one(struct mlx5_core_dev *dev, bool recovery) +int mlx5_load_one_devl_locked(struct mlx5_core_dev *dev, bool recovery) { int err = 0; u64 timeout; + devl_assert_locked(priv_to_devlink(dev)); mutex_lock(&dev->intf_state_mutex); if (test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state)) { mlx5_core_warn(dev, "interface is up, NOP\n"); @@ -1419,8 +1428,20 @@ int mlx5_load_one(struct mlx5_core_dev *dev, bool recovery) return err; } -void mlx5_unload_one(struct mlx5_core_dev *dev) +int mlx5_load_one(struct mlx5_core_dev *dev, bool recovery) { + struct devlink *devlink = priv_to_devlink(dev); + int ret; + + devl_lock(devlink); + ret = mlx5_load_one_devl_locked(dev, recovery); + devl_unlock(devlink); + return ret; +} + +void mlx5_unload_one_devl_locked(struct mlx5_core_dev *dev) +{ + devl_assert_locked(priv_to_devlink(dev)); mutex_lock(&dev->intf_state_mutex); mlx5_detach_device(dev); @@ -1438,6 +1459,15 @@ void mlx5_unload_one(struct mlx5_core_dev *dev) mutex_unlock(&dev->intf_state_mutex); } +void mlx5_unload_one(struct mlx5_core_dev *dev) +{ + struct devlink *devlink = priv_to_devlink(dev); + + devl_lock(devlink); + mlx5_unload_one_devl_locked(dev); + devl_unlock(devlink); +} + static const int types[] = { MLX5_CAP_GENERAL, MLX5_CAP_GENERAL_2, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h index 9cc7afea2758..ad61b86d5769 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -290,7 +290,9 @@ void mlx5_mdev_uninit(struct mlx5_core_dev *dev); int mlx5_init_one(struct mlx5_core_dev *dev); void mlx5_uninit_one(struct mlx5_core_dev *dev); void mlx5_unload_one(struct mlx5_core_dev *dev); +void mlx5_unload_one_devl_locked(struct mlx5_core_dev *dev); int mlx5_load_one(struct mlx5_core_dev *dev, bool recovery); +int mlx5_load_one_devl_locked(struct mlx5_core_dev *dev, bool recovery); int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c index 5757cd6e1819..ee2e1b7c1310 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c @@ -154,13 +154,16 @@ mlx5_device_disable_sriov(struct mlx5_core_dev *dev, int num_vfs, bool clear_vf) static int mlx5_sriov_enable(struct pci_dev *pdev, int num_vfs) { struct mlx5_core_dev *dev = pci_get_drvdata(pdev); + struct devlink *devlink = priv_to_devlink(dev); int err; + devl_lock(devlink); err = mlx5_device_enable_sriov(dev, num_vfs); if (err) { mlx5_core_warn(dev, "mlx5_device_enable_sriov failed : %d\n", err); return err; } + devl_unlock(devlink); err = pci_enable_sriov(pdev, num_vfs); if (err) { @@ -173,10 +176,13 @@ static int mlx5_sriov_enable(struct pci_dev *pdev, int num_vfs) void mlx5_sriov_disable(struct pci_dev *pdev) { struct mlx5_core_dev *dev = pci_get_drvdata(pdev); + struct devlink *devlink = priv_to_devlink(dev); int num_vfs = pci_num_vf(dev->pdev); pci_disable_sriov(pdev); + devl_lock(devlink); mlx5_device_disable_sriov(dev, num_vfs, true); + devl_unlock(devlink); } int mlx5_core_sriov_configure(struct pci_dev *pdev, int num_vfs) From patchwork Wed Jul 27 17:03:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12930651 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0783C19F2C for ; Wed, 27 Jul 2022 18:00:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242668AbiG0R76 (ORCPT ); Wed, 27 Jul 2022 13:59:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242661AbiG0R7e (ORCPT ); Wed, 27 Jul 2022 13:59:34 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2061.outbound.protection.outlook.com [40.107.100.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA2034D155 for ; Wed, 27 Jul 2022 10:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nGPGz2Y91bnfdyO8srWVzAOujbjdApFW6NnI41YftvahZqMOnj3e0ufz4J6Sj8wAUwOGBBhKR1WTOjEI5i2xqs6r8VxYQD4yjoTpCPci2Plv3myEajATeHY5G8UupyUhs9di0xeFPeGIk/Haw0Voqnl3DsD/6p8/1VNyFaN6/yUPBhD2Iy02n5oBYx2CDIUzzLtCIltF6klLOsEQdAeD+23dWIYGo05A29g9UYElQ/M1Awk1CPQ2tl9R3xn/gOKq/qzeYS5aSov3fDckSVr1lA1fBO/iZcTvF2ceWM0u5qr3RQPu4fcsZUmRG6s6vndc4S2Hbbn23hs6NU5OuRPH/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rBd3BcZj08RceBhH3bji32iNEFiFZ7UoVVwv8ZHjr6s=; b=iePe4KbUm2fNFT8AB61pyloSEgDlPwETZ9lgKdp1sA9pe8FMlU4VsSyX0tt2c/PGXUdfimD8/eEwfkdwrWttnC3qlxaBigcFvTW1Vgz8yUMs3yNnSaoHr4CxJjlcv0JbDwv79mkGyv5+ts1UdHMDzhJ9YtwgaQBkZdBCDwoC/pNDBbK0vFkAyBWy3V4ZvYj0y+H1uwMbXu7PwFU3v0JarwMUAEaSTh0dyG31GAlBQWKoE5IVUH6QqdjfJyH+vww3pkbSiuk3Gi8F6hIBhOm3Xz37cNCLD8f3VHw7L9QYbO0lh3uHSLIi2UAEhn33XRJGSlA71AeEhTacEPK192NyqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=google.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rBd3BcZj08RceBhH3bji32iNEFiFZ7UoVVwv8ZHjr6s=; b=DkRBLTAVtqEiLVPbk3eUM3p1ZBHaY7lMSuFm0G0SGQGHm97Vg+dgPmdMm6pM1j3IB0RmOJ2+MoftQljr556jjcnLU/Qn2DAdPVx6l9UN+mu612bTmQ9NTlmvps4ENbQdi5c8LNtNAp4xxRA1YEaubSPQgeerG1PIkj8eS0lKya+egilWIBlJyd+zouhqGX3Q0R6F28qfj21YKNRyzJIXadC9JfMF9+cpO1Ant3vlfaBVk/cLRVOcQimCqJLLjy7MU0jXNqNG7yZLrL7xqKqR/hYBbtT8V6g3FjvPIhdUEECmtUKPx0PbznCFxlFgo7qGRQT6GfQL2brhKI7lXnnoYA== Received: from BN9PR03CA0151.namprd03.prod.outlook.com (2603:10b6:408:f4::6) by BL0PR12MB4866.namprd12.prod.outlook.com (2603:10b6:208:1cf::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Wed, 27 Jul 2022 17:04:20 +0000 Received: from BN8NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f4:cafe::61) by BN9PR03CA0151.outlook.office365.com (2603:10b6:408:f4::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.7 via Frontend Transport; Wed, 27 Jul 2022 17:04:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by BN8NAM11FT047.mail.protection.outlook.com (10.13.177.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Wed, 27 Jul 2022 17:04:19 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 27 Jul 2022 17:04:19 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 27 Jul 2022 10:04:18 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Wed, 27 Jul 2022 10:04:16 -0700 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski , Saeed Mahameed , Leon Romanovsky , "Tariq Toukan" , Eric Dumazet , Paolo Abeni CC: Jiri Pirko , , Moshe Shemesh Subject: [PATCH net-next 5/9] net/mlx4: Use devl_ API for devlink region create / destroy Date: Wed, 27 Jul 2022 20:03:32 +0300 Message-ID: <1658941416-74393-6-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1658941416-74393-1-git-send-email-moshe@nvidia.com> References: <1658941416-74393-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8a2a7e9b-962b-409e-19b0-08da6ff20c13 X-MS-TrafficTypeDiagnostic: BL0PR12MB4866:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /VlfNDpnxIKYpU3q4H7IEvwqbBtuyfjfFzNsoVPHuI4edY/uC104g7rYuDOZAGZ88mTrNhVeKZ3G+vP5McLTR7NcG4MN5h3E05YuX5gbxERtbpTImFHORc0y29dnsl2fBMeZspk4RLLQWckPlu6TFnL5e+I7oNvHrCYzD57g39lyv4s7mF+MWmFsE2oRPNLUhw7Nrr3YrmBCw9rzIgD9s52Rs4ZU8ZU34BNPOj8rp8Cj18erZFGVHFpy/J11ZMKDUtxy8I4PhmZl1ja9v5kylinycnTUcQyVJoqWzEUdsvqlC37m1YrCuT/t6/njd4DU0BF8y29DKxsxfUJ5vBm1+q9g+4f4CbE36tCNDaRSJeHkd1I17NFs1wFIrwwpWpZmzd7s/W6OPKQxQwQtOw8ts2oXKNBOt1Hx+mPyAVx9aytqPLqLGLrW2mcuzt47QybRPQ5ybNGWln/94B9iwxZUzjh+Jyb+0dLO7cEuaOkES60DMiiD/eN8Mr0KyN+62tiFmxyVpn22h3w1ULFROBvZRab30zRizC/G6B+ZjDCMvpt4Fa8QxW4LZ7C3M9kpqokssZYbyqr9f6fssZpFYzBRkI2C+DxEl5YHlSLg2eQ5ZgPaY+Uqy0IF28/58qFW4TiY7haGKnoYSEUc1xB1+6kxoemsZUgUXehirqgrIks2+l72ss8ZZHKw8FWjKheyuKOjnMUEMmzjq/qoe31arCida1xFlSGt+FruQl4Gj/Ugdw84bUGbSDYU+BchGF1bxlRzkCyGYh/2BWdeKZCwvU7bX+xpVrbnCA0MkI5A/jis4wqv1+9RklAMernBlF9HDWTzsPdGxwLyt3LpgJjfy/H7uQ== X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(396003)(376002)(136003)(346002)(39860400002)(40470700004)(46966006)(36840700001)(86362001)(36860700001)(2906002)(82740400003)(26005)(356005)(81166007)(478600001)(40460700003)(82310400005)(8676002)(70586007)(70206006)(40480700001)(316002)(4326008)(54906003)(336012)(426003)(47076005)(8936002)(5660300002)(83380400001)(186003)(6666004)(110136005)(7696005)(41300700001)(2616005)(107886003)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2022 17:04:19.9974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a2a7e9b-962b-409e-19b0-08da6ff20c13 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4866 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Use devl_ API to call devl_region_create() and devl_region_destroy() instead of devlink_region_create() and devlink_region_destroy(). Add devlink instance lock in mlx4 driver paths to these functions. This will be used by the downstream patch to invoke mlx4 devlink reload callbacks with devlink lock held. Signed-off-by: Moshe Shemesh Reviewed-by: Tariq Toukan Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlx4/crdump.c | 20 ++++++++++---------- drivers/net/ethernet/mellanox/mlx4/main.c | 7 +++++++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/crdump.c b/drivers/net/ethernet/mellanox/mlx4/crdump.c index ac5468b77488..82a07a31cde7 100644 --- a/drivers/net/ethernet/mellanox/mlx4/crdump.c +++ b/drivers/net/ethernet/mellanox/mlx4/crdump.c @@ -226,10 +226,10 @@ int mlx4_crdump_init(struct mlx4_dev *dev) /* Create cr-space region */ crdump->region_crspace = - devlink_region_create(devlink, - ®ion_cr_space_ops, - MAX_NUM_OF_DUMPS_TO_STORE, - pci_resource_len(pdev, 0)); + devl_region_create(devlink, + ®ion_cr_space_ops, + MAX_NUM_OF_DUMPS_TO_STORE, + pci_resource_len(pdev, 0)); if (IS_ERR(crdump->region_crspace)) mlx4_warn(dev, "crdump: create devlink region %s err %ld\n", region_cr_space_str, @@ -237,10 +237,10 @@ int mlx4_crdump_init(struct mlx4_dev *dev) /* Create fw-health region */ crdump->region_fw_health = - devlink_region_create(devlink, - ®ion_fw_health_ops, - MAX_NUM_OF_DUMPS_TO_STORE, - HEALTH_BUFFER_SIZE); + devl_region_create(devlink, + ®ion_fw_health_ops, + MAX_NUM_OF_DUMPS_TO_STORE, + HEALTH_BUFFER_SIZE); if (IS_ERR(crdump->region_fw_health)) mlx4_warn(dev, "crdump: create devlink region %s err %ld\n", region_fw_health_str, @@ -253,6 +253,6 @@ void mlx4_crdump_end(struct mlx4_dev *dev) { struct mlx4_fw_crdump *crdump = &dev->persist->crdump; - devlink_region_destroy(crdump->region_fw_health); - devlink_region_destroy(crdump->region_crspace); + devl_region_destroy(crdump->region_fw_health); + devl_region_destroy(crdump->region_crspace); } diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index b187c210d4d6..f3d13190b959 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c @@ -3732,6 +3732,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data, int prb_vf[MLX4_MAX_PORTS + 1] = {0, 0, 0}; const int param_map[MLX4_MAX_PORTS + 1][MLX4_MAX_PORTS + 1] = { {2, 0, 0}, {0, 1, 2}, {0, 1, 2} }; + struct devlink *devlink = priv_to_devlink(priv); unsigned total_vfs = 0; unsigned int i; @@ -3844,7 +3845,9 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data, } } + devl_lock(devlink); err = mlx4_crdump_init(&priv->dev); + devl_unlock(devlink); if (err) goto err_release_regions; @@ -3862,7 +3865,9 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data, mlx4_catas_end(&priv->dev); err_crdump: + devl_lock(devlink); mlx4_crdump_end(&priv->dev); + devl_unlock(devlink); err_release_regions: pci_release_regions(pdev); @@ -4161,7 +4166,9 @@ static void mlx4_remove_one(struct pci_dev *pdev) else mlx4_info(dev, "%s: interface is down\n", __func__); mlx4_catas_end(dev); + devl_lock(devlink); mlx4_crdump_end(dev); + devl_unlock(devlink); if (dev->flags & MLX4_FLAG_SRIOV && !active_vfs) { mlx4_warn(dev, "Disabling SR-IOV\n"); pci_disable_sriov(pdev); From patchwork Wed Jul 27 17:03:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12930653 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5F24C04A68 for ; Wed, 27 Jul 2022 18:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243214AbiG0SAG (ORCPT ); Wed, 27 Jul 2022 14:00:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242742AbiG0R7g (ORCPT ); Wed, 27 Jul 2022 13:59:36 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2089.outbound.protection.outlook.com [40.107.220.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E79F57278 for ; Wed, 27 Jul 2022 10:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U70Cm43uLP6PpNBpiRx6jgN4XumwwAoxAJkRBWJHMsm1uQ13hg2oK/aDueqZYIltJG0O1m2RO3pn6J1LewB/c0xsW840JScAEdRzbQYXS50JYaM1Wav5Otzwq7mUBCr7XFe5FTckRjmYZZ1BuMJkpBYE4ldCWmuX04Px5mQb4FZwnKDXo3KsOE6z7YBe+mIO8b3cia7ez+lbTAP8UiCF3kJMP8lLU+/g3tsA0y9/imrQg8SVaJsmAYPpC0oERIbWin8R7qafdtx+jOVhRv5vuVph+x5GJqyT10DVnIYdfQMUPizqelRTZE8HJy4ZU/3alC57vfNavxknSUmG6wg7UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9FEdLw1sTXVoRDHrceXmgLjIk69yv3hyzZqPDftRQUY=; b=Sgt/A15cCZ/fbiG4LMMF+B4mKNz4NjrHNXL9tbKOyBc7d9hNivhF1q4kGVLvPpuubkQufMYLDQbwCEp+erXu79eQwgQaYzRfeVfIizdC+xBTf7cuJsDEmDOPcXtDiADNiSVokCLAw2LLPQ1OmPfUbIXS78h05eBmaasRNX6DsRFjwZqaRlEJhT4TZEYgsfA6shWq9o91TZXoZLPkSs7wqRUWNEz0WHTB9QdfvlTkdHexx7tzOoh80ACsW2FVm9pscilq6xU+wbyzGuSp2z0/7B54rrvCCTjDnaOoRvfIn0t5ZYzRmD2jyFywzCwvw1A3fynP4ZcV8kBtMw1+nEA5wA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=google.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9FEdLw1sTXVoRDHrceXmgLjIk69yv3hyzZqPDftRQUY=; b=TN1FFbULQcpSeH3yKfnIW8H3s/RSZKT5Kg9rbG9xLd0BEf2YdE1Zk6/hoywmTzdqKVi2LC4Q4dtJQ939TCzH1cudYbdoGUDAh9FhecjxRvKHO/2qp7NVV14ur4xrE+uRLVcZZj0krG2t6erDSh0e8G1eoFjcq4EGTohgdGzTgH2bxfLmw+nf4ySvKvgqEf+A3dxxadp1oANGwN70FvwOpsJXse4YdPxqNwAv/zYpmFJGGDGz3pnhKSU9EWc19LQlrlaMQaDhQkBLCRLiC8szD30bh9Tquh8cFYuJpGkZA1QzS0h+FZ21PRjbj8UashKm5vUQskpFHAtGpsjLspEvRQ== Received: from DM6PR11CA0050.namprd11.prod.outlook.com (2603:10b6:5:14c::27) by CH2PR12MB3990.namprd12.prod.outlook.com (2603:10b6:610:28::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Wed, 27 Jul 2022 17:04:23 +0000 Received: from DM6NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:5:14c:cafe::94) by DM6PR11CA0050.outlook.office365.com (2603:10b6:5:14c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19 via Frontend Transport; Wed, 27 Jul 2022 17:04:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.235) by DM6NAM11FT064.mail.protection.outlook.com (10.13.172.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Wed, 27 Jul 2022 17:04:22 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 27 Jul 2022 17:04:22 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 27 Jul 2022 10:04:21 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Wed, 27 Jul 2022 10:04:19 -0700 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski , Saeed Mahameed , Leon Romanovsky , "Tariq Toukan" , Eric Dumazet , Paolo Abeni CC: Jiri Pirko , , Moshe Shemesh Subject: [PATCH net-next 6/9] net/mlx4: Use devl_ API for devlink port register / unregister Date: Wed, 27 Jul 2022 20:03:33 +0300 Message-ID: <1658941416-74393-7-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1658941416-74393-1-git-send-email-moshe@nvidia.com> References: <1658941416-74393-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e5c02b6-a705-4e48-e20a-08da6ff20dab X-MS-TrafficTypeDiagnostic: CH2PR12MB3990:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ewGh6QxZXaHwFkxJogHPXUbmk+HeFAvOEUIHnCoieNK4yZ6ra0kOnsRhB8Jh5gtUuLrrg4B+lrh8Xq3+/CHn7SQP0U4agjVBFBI3f0XruaSPlPMlrVjXIU4UFFM7wXnGAg0Y78TqiILeYicAqyJrLTOi7fy1k3jjwCvaHFemTIcSXEUEvcPnp4304TlLKrhidOZ2SNeBIoDv9YdyAkQqc0dX3n+n8WM3a4HnSzHgt1bvg2Vnsh0XpVhHxhSGqhD62h3HYp+mGjcGeOrRKGeufesjppcthBoTa/ZVp8LlUly3EUJmToRFJzZz+LHZ+Lc3fIPTKHXdcsW+mGvwnPrnr2EFyWXSit52gNHHGTMh4VhzlU5KToiiCcG4z7f2XUQQQXpKzpQo7ATCO2eF3D152jxi+on9xtbaY0yU3RXkYmbefQogpuIIB4aGMgwYiGWVI1jGcarnKURCvHK9wtV+CNp3wAjh1KGGnxOSbjTxNNFmZ1n7XtDunganWTeyFRay6nE5wIqTiaFq0kEJSkQ0xTM8Aw+JD7wK7piPezZaQ2FnH7WU11Ej2UrvgknNYeGmMhp5S9PfK85OiChRKwEio33QCElLXsblzjbs1pQJp1r/T88X1bXHupwkG6R9om8D+niwGvrPYiJaLBn/buEy5Yi/CjkNzkSfS1gOXvL/UeNKNbbTbEBulxtZba2y8OdnZNmsrQIy+znPAMmuPDTT1wQfe+uI4Y4JfXkhFpUf7XNUe58zMA+enD+hMssmRGHjGeIm8iXFor0ZjONHvq1QZyNo3m92Uxi7YZRZ1Ad4YOVMRi2xp3W5mZulhpb79szmq7i842tPPblhRGonNsgjVQ== X-Forefront-Antispam-Report: CIP:12.22.5.235;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(346002)(376002)(136003)(39860400002)(396003)(46966006)(36840700001)(40470700004)(478600001)(336012)(8676002)(47076005)(8936002)(426003)(83380400001)(5660300002)(4326008)(40480700001)(7696005)(40460700003)(70586007)(26005)(186003)(356005)(70206006)(2616005)(107886003)(54906003)(41300700001)(81166007)(82740400003)(6666004)(110136005)(36756003)(2906002)(316002)(86362001)(82310400005)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2022 17:04:22.7389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e5c02b6-a705-4e48-e20a-08da6ff20dab X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.235];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3990 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Use devl_ API to call devl_port_register() and devl_port_unregister() instead of devlink_port_register() and devlink_port_unregister(). Add devlink instance lock in mlx4 driver paths to these functions. This will be used by the downstream patch to invoke mlx4 devlink reload callbacks with devlink lock held. Signed-off-by: Moshe Shemesh Reviewed-by: Tariq Toukan Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlx4/main.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index f3d13190b959..0166d003f22c 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c @@ -3033,7 +3033,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port) struct mlx4_port_info *info = &mlx4_priv(dev)->port[port]; int err; - err = devlink_port_register(devlink, &info->devlink_port, port); + err = devl_port_register(devlink, &info->devlink_port, port); if (err) return err; @@ -3071,7 +3071,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port) err = device_create_file(&dev->persist->pdev->dev, &info->port_attr); if (err) { mlx4_err(dev, "Failed to create file for port %d\n", port); - devlink_port_unregister(&info->devlink_port); + devl_port_unregister(&info->devlink_port); info->port = -1; return err; } @@ -3093,7 +3093,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port) mlx4_err(dev, "Failed to create mtu file for port %d\n", port); device_remove_file(&info->dev->persist->pdev->dev, &info->port_attr); - devlink_port_unregister(&info->devlink_port); + devl_port_unregister(&info->devlink_port); info->port = -1; return err; } @@ -3109,7 +3109,7 @@ static void mlx4_cleanup_port_info(struct mlx4_port_info *info) device_remove_file(&info->dev->persist->pdev->dev, &info->port_attr); device_remove_file(&info->dev->persist->pdev->dev, &info->port_mtu_attr); - devlink_port_unregister(&info->devlink_port); + devl_port_unregister(&info->devlink_port); #ifdef CONFIG_RFS_ACCEL free_irq_cpu_rmap(info->rmap); @@ -3333,6 +3333,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data, int total_vfs, int *nvfs, struct mlx4_priv *priv, int reset_flow) { + struct devlink *devlink = priv_to_devlink(priv); struct mlx4_dev *dev; unsigned sum = 0; int err; @@ -3629,6 +3630,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data, } } + devl_lock(devlink); for (port = 1; port <= dev->caps.num_ports; port++) { err = mlx4_init_port_info(dev, port); if (err) @@ -3642,6 +3644,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data, if (err) goto err_port; + devl_unlock(devlink); mlx4_request_modules(dev); mlx4_sense_init(dev); @@ -3658,6 +3661,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data, err_port: for (--port; port >= 1; --port) mlx4_cleanup_port_info(&priv->port[port]); + devl_unlock(devlink); mlx4_cleanup_default_counters(dev); if (!mlx4_is_slave(dev)) @@ -4061,8 +4065,10 @@ static void mlx4_unload_one(struct pci_dev *pdev) struct mlx4_dev *dev = persist->dev; struct mlx4_priv *priv = mlx4_priv(dev); int pci_dev_data; + struct devlink *devlink; int p, i; + devlink = priv_to_devlink(priv); if (priv->removed) return; @@ -4078,10 +4084,12 @@ static void mlx4_unload_one(struct pci_dev *pdev) mlx4_stop_sense(dev); mlx4_unregister_device(dev); + devl_lock(devlink); for (p = 1; p <= dev->caps.num_ports; p++) { mlx4_cleanup_port_info(&priv->port[p]); mlx4_CLOSE_PORT(dev, p); } + devl_unlock(devlink); if (mlx4_is_master(dev)) mlx4_free_resource_tracker(dev, From patchwork Wed Jul 27 17:03:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12930652 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58C4DC04A68 for ; Wed, 27 Jul 2022 18:00:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243213AbiG0SAC (ORCPT ); Wed, 27 Jul 2022 14:00:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242766AbiG0R7g (ORCPT ); Wed, 27 Jul 2022 13:59:36 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2053.outbound.protection.outlook.com [40.107.102.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB8159260 for ; Wed, 27 Jul 2022 10:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NFrp5Q6iKFA4eJjEKfEe9DghS99n9Nez4yhRjtEUhEuJq4KwPEL97+VC9MSNsZcu82tdEUAOqrJwtTO0i1yz3+JRK6zHQNTZn28u6PorznsG+sQNfijnGao1DTrNIVs12NvYrc2QfQHqQUgiaEeZ0UTGpzJKRtiLYDIgnQZo0i0d8VW6cTV2Hfw5Q+DKhJxZDBYr+BtaxYVxMOs5bmBZuqlhWejNB8IhOq/JO7wRRb863Y8FhJXT6VhuzE6vSz+B5ZN0eQxp0z4dXBzDpfkVTf5iY3LwltY00kTxMqVkzOapeu6d22KdbuGRvctXbr3Rk9hL3RqnrlM+k3YjR/TfSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h0cZGKYG9E8NpSw2GnfDJ+ak5jSuh9+0zYJ6WQGZBwU=; b=dsqnV44Nweov5uWLnfHD917JtFHxiNJEo5t9h5x7iDGYXuuLINnQEbG6Jb16aFg+Z9ZZcwBgdON40RRRf1q2rF2B1C2XkrJhbOlV+wh3RP4C9QQ+YHFQlBd+rZkpfQkMoZi+BWuIkHaAfasR4J0s+6Q0nN+f5HTs0EmnjQkFZ1/qLOUVa4nI1kcV7JtMXNTKIP0CwtHsYCSqsTYG+WC+fgQN51HmsX699AdvjiWlKrFQvAuwPZEBadLYeJwdOcHEEK5RJKbjdYc6fOsT6l+p5HPlOh3zGoL92LrV5kOkCCDhOBVsNKFVmQMACA8/Yu8z315GZAcZON3TlAOcPqSrFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=google.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h0cZGKYG9E8NpSw2GnfDJ+ak5jSuh9+0zYJ6WQGZBwU=; b=UbBGyakXDip0cgmUGm+CqiIi88v+4gx5f6rOY2dhy980vEEykg9BXahA9vUO1ox1Bo76+G25qSwHDTNCNxsT7jnfT0EJBKfxoqdSfXxjC4k8ocRd7e97WJbo7LUoCpNiZR8BG520FcyFxGysAkRKE3FIoPZ1QqVTpbiVJyRMsKlD1xTlRyWWtcHPttr695mQPd+/pPYXoO6wYy8+hYnUPV9s8XN+y1zDjYaP23FZU66QQS/v0k664rSbLBZ0hSEYrS9zInbkpW3Hm6N+njp/u/O+AWAqy/DIyHAKzF+em5/CJcxt61n1K0WRprONydMw6s7n0hj9JImVg9Wm6B6PDQ== Received: from MW4PR04CA0264.namprd04.prod.outlook.com (2603:10b6:303:88::29) by CH0PR12MB5236.namprd12.prod.outlook.com (2603:10b6:610:d3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Wed, 27 Jul 2022 17:04:26 +0000 Received: from CO1NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:303:88:cafe::c9) by MW4PR04CA0264.outlook.office365.com (2603:10b6:303:88::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19 via Frontend Transport; Wed, 27 Jul 2022 17:04:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT050.mail.protection.outlook.com (10.13.174.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Wed, 27 Jul 2022 17:04:25 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 27 Jul 2022 17:04:25 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 27 Jul 2022 10:04:24 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Wed, 27 Jul 2022 10:04:22 -0700 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski , Saeed Mahameed , Leon Romanovsky , "Tariq Toukan" , Eric Dumazet , Paolo Abeni CC: Jiri Pirko , , Moshe Shemesh Subject: [PATCH net-next 7/9] net/mlx4: Lock mlx4 devlink reload callback Date: Wed, 27 Jul 2022 20:03:34 +0300 Message-ID: <1658941416-74393-8-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1658941416-74393-1-git-send-email-moshe@nvidia.com> References: <1658941416-74393-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 210f000e-89b5-48fe-55d5-08da6ff20f5a X-MS-TrafficTypeDiagnostic: CH0PR12MB5236:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NrvSyu//7E8YxVaFTyQ6wRTcnAGq2Gydjdo/dHMtPaDjMC6ioELNNS8l30kuEfp5aeLLX5C/7xKgAV2/U5t52rsGjI6YeuZf4gLNlHZLK8wU7Ua9w92OlMVXq77WOLiUmY2grtTiUk/gGeaLQZqTQ2dPXRHmLB+CIc42xbgrZsJc3/XqZ6P3FMUZVRbz+nuqJo8c4yB98WrKJZ+7Wnli+FbOTwsxcuanyLBxrCmni5Iv2RRRJ3onQuJ3FNVd4BYXI+5wLu//GQcNb9JWK8LMbOGm2zcsEJ7wikPX8P+bTfUKYti3958Ucq+Ak6eZqawEC1GpYlDgzqsfFXl65o16drQ+InmzhhjcmTluSvevJvi+k2O7xYZU1wmeyh6a90b1Jf1SON35YGDgXq52/0WfHOTifPOlt7mnAFil7Xb1xqRsD/Z4SngcQBGhNtU9npsSuEMzMdufTf7hmfxXcT3vKmO3MBVXGvrMB5GkFt0OM8qPG8p5nOWJbaNN1nwfaGUrXvcO3N1ZtRgen9LQ65btjCs5tdBf0icQ4bSrUxuas0soerK5A2D6py3d0yqXGtHgsHkM4XQgIlifh/i6MPSEYjUU6fV8BD8HCnOXnxOf0A9s5vOPTqzjgp/OUJpeWLBkyu4ckZwswaff8cirKeTsK8g/rfSE0dNtXFnV5w9XU6rv+MVJacHJQomNa5NAELBRnMgmd1KCs4Fy5xfHm/Nlvd0iy0TlCPwbFegOuDr9s89Usz1OnE4iKe19tuIqa8tzSm9U/IMQAx4GW8I+Qb2nBcqvfWgG48hmUj3IJaSOlA4r7tqR0OZ1M9Qjg1RWoMxUQNOpE55MfVskGBmoillwDw== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(396003)(136003)(346002)(376002)(39860400002)(36840700001)(46966006)(40470700004)(336012)(36756003)(8936002)(70206006)(5660300002)(41300700001)(8676002)(70586007)(40480700001)(4326008)(110136005)(82740400003)(186003)(86362001)(54906003)(356005)(107886003)(2616005)(81166007)(36860700001)(478600001)(47076005)(426003)(7696005)(83380400001)(6666004)(316002)(40460700003)(26005)(2906002)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2022 17:04:25.5287 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 210f000e-89b5-48fe-55d5-08da6ff20f5a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5236 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Change devlink instance locks in mlx4 driver to have devlink reload callback locked, while keeping all driver paths which leads to devl_ API functions called by the mlx4 driver locked. Signed-off-by: Moshe Shemesh Reviewed-by: Tariq Toukan Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlx4/catas.c | 5 +++ drivers/net/ethernet/mellanox/mlx4/main.c | 45 +++++++++++++++------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/catas.c b/drivers/net/ethernet/mellanox/mlx4/catas.c index 5b11557f1ae4..0eb7b83637d8 100644 --- a/drivers/net/ethernet/mellanox/mlx4/catas.c +++ b/drivers/net/ethernet/mellanox/mlx4/catas.c @@ -204,9 +204,13 @@ void mlx4_enter_error_state(struct mlx4_dev_persistent *persist) static void mlx4_handle_error_state(struct mlx4_dev_persistent *persist) { + struct mlx4_dev *dev = persist->dev; + struct devlink *devlink; int err = 0; mlx4_enter_error_state(persist); + devlink = priv_to_devlink(mlx4_priv(dev)); + devl_lock(devlink); mutex_lock(&persist->interface_state_mutex); if (persist->interface_state & MLX4_INTERFACE_STATE_UP && !(persist->interface_state & MLX4_INTERFACE_STATE_DELETION)) { @@ -215,6 +219,7 @@ static void mlx4_handle_error_state(struct mlx4_dev_persistent *persist) err); } mutex_unlock(&persist->interface_state_mutex); + devl_unlock(devlink); } static void dump_err_buf(struct mlx4_dev *dev) diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 0166d003f22c..2c764d1d897d 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c @@ -3342,6 +3342,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data, struct mlx4_dev_cap *dev_cap = NULL; int existing_vfs = 0; + devl_assert_locked(devlink); dev = &priv->dev; INIT_LIST_HEAD(&priv->ctx_list); @@ -3630,7 +3631,6 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data, } } - devl_lock(devlink); for (port = 1; port <= dev->caps.num_ports; port++) { err = mlx4_init_port_info(dev, port); if (err) @@ -3644,7 +3644,6 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data, if (err) goto err_port; - devl_unlock(devlink); mlx4_request_modules(dev); mlx4_sense_init(dev); @@ -3661,7 +3660,6 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data, err_port: for (--port; port >= 1; --port) mlx4_cleanup_port_info(&priv->port[port]); - devl_unlock(devlink); mlx4_cleanup_default_counters(dev); if (!mlx4_is_slave(dev)) @@ -3736,7 +3734,6 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data, int prb_vf[MLX4_MAX_PORTS + 1] = {0, 0, 0}; const int param_map[MLX4_MAX_PORTS + 1][MLX4_MAX_PORTS + 1] = { {2, 0, 0}, {0, 1, 2}, {0, 1, 2} }; - struct devlink *devlink = priv_to_devlink(priv); unsigned total_vfs = 0; unsigned int i; @@ -3849,9 +3846,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data, } } - devl_lock(devlink); err = mlx4_crdump_init(&priv->dev); - devl_unlock(devlink); if (err) goto err_release_regions; @@ -3869,9 +3864,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data, mlx4_catas_end(&priv->dev); err_crdump: - devl_lock(devlink); mlx4_crdump_end(&priv->dev); - devl_unlock(devlink); err_release_regions: pci_release_regions(pdev); @@ -3965,9 +3958,11 @@ static int mlx4_devlink_reload_down(struct devlink *devlink, bool netns_change, NL_SET_ERR_MSG_MOD(extack, "Namespace change is not supported"); return -EOPNOTSUPP; } + devl_lock(devlink); if (persist->num_vfs) mlx4_warn(persist->dev, "Reload performed on PF, will cause reset on operating Virtual Functions\n"); mlx4_restart_one_down(persist->pdev); + devl_unlock(devlink); return 0; } @@ -3980,8 +3975,10 @@ static int mlx4_devlink_reload_up(struct devlink *devlink, enum devlink_reload_a struct mlx4_dev_persistent *persist = dev->persist; int err; + devl_lock(devlink); *actions_performed = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT); err = mlx4_restart_one_up(persist->pdev, true, devlink); + devl_unlock(devlink); if (err) mlx4_err(persist->dev, "mlx4_restart_one_up failed, ret=%d\n", err); @@ -4008,6 +4005,7 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) devlink = devlink_alloc(&mlx4_devlink_ops, sizeof(*priv), &pdev->dev); if (!devlink) return -ENOMEM; + devl_lock(devlink); priv = devlink_priv(devlink); dev = &priv->dev; @@ -4035,6 +4033,7 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) pci_save_state(pdev); devlink_set_features(devlink, DEVLINK_F_RELOAD); + devl_unlock(devlink); devlink_register(devlink); return 0; @@ -4044,6 +4043,7 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) err_devlink_unregister: kfree(dev->persist); err_devlink_free: + devl_unlock(devlink); devlink_free(devlink); return ret; } @@ -4069,6 +4069,7 @@ static void mlx4_unload_one(struct pci_dev *pdev) int p, i; devlink = priv_to_devlink(priv); + devl_assert_locked(devlink); if (priv->removed) return; @@ -4084,12 +4085,10 @@ static void mlx4_unload_one(struct pci_dev *pdev) mlx4_stop_sense(dev); mlx4_unregister_device(dev); - devl_lock(devlink); for (p = 1; p <= dev->caps.num_ports; p++) { mlx4_cleanup_port_info(&priv->port[p]); mlx4_CLOSE_PORT(dev, p); } - devl_unlock(devlink); if (mlx4_is_master(dev)) mlx4_free_resource_tracker(dev, @@ -4150,6 +4149,7 @@ static void mlx4_remove_one(struct pci_dev *pdev) devlink_unregister(devlink); + devl_lock(devlink); if (mlx4_is_slave(dev)) persist->interface_state |= MLX4_INTERFACE_STATE_NOWAIT; @@ -4174,9 +4174,7 @@ static void mlx4_remove_one(struct pci_dev *pdev) else mlx4_info(dev, "%s: interface is down\n", __func__); mlx4_catas_end(dev); - devl_lock(devlink); mlx4_crdump_end(dev); - devl_unlock(devlink); if (dev->flags & MLX4_FLAG_SRIOV && !active_vfs) { mlx4_warn(dev, "Disabling SR-IOV\n"); pci_disable_sriov(pdev); @@ -4187,6 +4185,7 @@ static void mlx4_remove_one(struct pci_dev *pdev) devlink_params_unregister(devlink, mlx4_devlink_params, ARRAY_SIZE(mlx4_devlink_params)); kfree(dev->persist); + devl_unlock(devlink); devlink_free(devlink); } @@ -4307,15 +4306,20 @@ static pci_ers_result_t mlx4_pci_err_detected(struct pci_dev *pdev, pci_channel_state_t state) { struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev); + struct mlx4_dev *dev = persist->dev; + struct devlink *devlink; mlx4_err(persist->dev, "mlx4_pci_err_detected was called\n"); mlx4_enter_error_state(persist); + devlink = priv_to_devlink(mlx4_priv(dev)); + devl_lock(devlink); mutex_lock(&persist->interface_state_mutex); if (persist->interface_state & MLX4_INTERFACE_STATE_UP) mlx4_unload_one(pdev); mutex_unlock(&persist->interface_state_mutex); + devl_unlock(devlink); if (state == pci_channel_io_perm_failure) return PCI_ERS_RESULT_DISCONNECT; @@ -4348,6 +4352,7 @@ static void mlx4_pci_resume(struct pci_dev *pdev) struct mlx4_dev *dev = persist->dev; struct mlx4_priv *priv = mlx4_priv(dev); int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0}; + struct devlink *devlink; int total_vfs; int err; @@ -4355,6 +4360,8 @@ static void mlx4_pci_resume(struct pci_dev *pdev) total_vfs = dev->persist->num_vfs; memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs)); + devlink = priv_to_devlink(priv); + devl_lock(devlink); mutex_lock(&persist->interface_state_mutex); if (!(persist->interface_state & MLX4_INTERFACE_STATE_UP)) { err = mlx4_load_one(pdev, priv->pci_dev_data, total_vfs, nvfs, @@ -4373,19 +4380,23 @@ static void mlx4_pci_resume(struct pci_dev *pdev) } end: mutex_unlock(&persist->interface_state_mutex); - + devl_unlock(devlink); } static void mlx4_shutdown(struct pci_dev *pdev) { struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev); struct mlx4_dev *dev = persist->dev; + struct devlink *devlink; mlx4_info(persist->dev, "mlx4_shutdown was called\n"); + devlink = priv_to_devlink(mlx4_priv(dev)); + devl_lock(devlink); mutex_lock(&persist->interface_state_mutex); if (persist->interface_state & MLX4_INTERFACE_STATE_UP) mlx4_unload_one(pdev); mutex_unlock(&persist->interface_state_mutex); + devl_unlock(devlink); mlx4_pci_disable_device(dev); } @@ -4400,12 +4411,16 @@ static int __maybe_unused mlx4_suspend(struct device *dev_d) struct pci_dev *pdev = to_pci_dev(dev_d); struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev); struct mlx4_dev *dev = persist->dev; + struct devlink *devlink; mlx4_err(dev, "suspend was called\n"); + devlink = priv_to_devlink(mlx4_priv(dev)); + devl_lock(devlink); mutex_lock(&persist->interface_state_mutex); if (persist->interface_state & MLX4_INTERFACE_STATE_UP) mlx4_unload_one(pdev); mutex_unlock(&persist->interface_state_mutex); + devl_unlock(devlink); return 0; } @@ -4417,6 +4432,7 @@ static int __maybe_unused mlx4_resume(struct device *dev_d) struct mlx4_dev *dev = persist->dev; struct mlx4_priv *priv = mlx4_priv(dev); int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0}; + struct devlink *devlink; int total_vfs; int ret = 0; @@ -4424,6 +4440,8 @@ static int __maybe_unused mlx4_resume(struct device *dev_d) total_vfs = dev->persist->num_vfs; memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs)); + devlink = priv_to_devlink(priv); + devl_lock(devlink); mutex_lock(&persist->interface_state_mutex); if (!(persist->interface_state & MLX4_INTERFACE_STATE_UP)) { ret = mlx4_load_one(pdev, priv->pci_dev_data, total_vfs, @@ -4437,6 +4455,7 @@ static int __maybe_unused mlx4_resume(struct device *dev_d) } } mutex_unlock(&persist->interface_state_mutex); + devl_unlock(devlink); return ret; } From patchwork Wed Jul 27 17:03:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12930656 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37B89C04A68 for ; Wed, 27 Jul 2022 18:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243056AbiG0SAl (ORCPT ); Wed, 27 Jul 2022 14:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243042AbiG0R7k (ORCPT ); Wed, 27 Jul 2022 13:59:40 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2058.outbound.protection.outlook.com [40.107.243.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 380ED6E2D0 for ; Wed, 27 Jul 2022 10:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R58Z/qEZeZbvC2hOeOXyYABHIIa1FPBFb4k6vSGVOegxaONcT/pj14Mi9X3K0SFib3LLXUSWvunyExIVKwzF9OlcneDr/1buzPxWve74BZ14f72TP/mz5/yOj1KmN2nsct+wHpWtDBo4ALKJeA3kHtCX1bs0m6ExuVsFg3Da8nVWvyZjgVe/9GTz3tJxV4chlJj/rb4LIXPfvGXqRaXIoBwq5yboInb+kIAlkEF6EoqHRJs1E2m5rH65i2UrEUjPTc7ffPg3nwyrdvf6JoXkma5AhhAHjiERRYmoxAqsoFO3VLn3dTa2GquCG/hTZjdHU4ieppQcZn3mtKQKxfrYjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=quyUkZizyYtOzRciYm91kfZ2cP/PklOd+7XHeOAFvG8=; b=iFHDgqUaws6rbhmt0DflRRDrhkMu0ZrcrqBWPvybws7wGJalFH5zaCxOI5LMqIH5V4AzWkEPzD2swubSOTHSymkNjvUwX5GJnVQtZN/GuJnbGqWRhvnVMs233uKFsSealHLwwmDKTS7PQIDMygOmuaTVw45bHMczmSNPP/v/WO5ZYwzisfJh6J70Pch9YziwCQYmN9ahJRSs++TjCBqu+sJpypnUiBUnmS05AishTmMcOBbZpLydDqiD899tlJoZAmJBa9KcYYsug+I22Q2qZ1LbmdMpFSI+yNDcwl/DIyfw6PbVpd7LeXDsESInkzKacvuY+Y6YE5r7KP4dxEFlRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=google.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=quyUkZizyYtOzRciYm91kfZ2cP/PklOd+7XHeOAFvG8=; b=Dd9+0hD5+z9xv6dczHdUJ087hxLRNBKcI/5iqx9oew1s8060y+cP7jOC0FQmSbzLh8rEYZBEvZWgInl8hPnVY2k73tpC1UWSYvAf8zdYf+KFOpLdaWYy4gH0caAC2j/7D4VdbkWMDAp62r1BIovwZAKoGYURjW1rYttJLAG1ndK9y6r+xA487PZ+lHJnJAdtsl5un63FRm0wgF82PWoVaRI45AFg4DK44oKkjzhbWsYuiA31y4SDKJPoYl6w3Gxyyx9GAzNtmr95xXxoO52IsmDj53YW50dnyHYenfzg2w0jmzeFvRUJxYL2zhU4bOhcngRSn7wDM/6lR7W9IJajnw== Received: from BN1PR13CA0022.namprd13.prod.outlook.com (2603:10b6:408:e2::27) by IA1PR12MB6532.namprd12.prod.outlook.com (2603:10b6:208:3a3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Wed, 27 Jul 2022 17:04:29 +0000 Received: from BN8NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e2:cafe::a2) by BN1PR13CA0022.outlook.office365.com (2603:10b6:408:e2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.7 via Frontend Transport; Wed, 27 Jul 2022 17:04:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by BN8NAM11FT049.mail.protection.outlook.com (10.13.177.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Wed, 27 Jul 2022 17:04:28 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 27 Jul 2022 17:04:28 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 27 Jul 2022 10:04:27 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Wed, 27 Jul 2022 10:04:25 -0700 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski , Saeed Mahameed , Leon Romanovsky , "Tariq Toukan" , Eric Dumazet , Paolo Abeni CC: Jiri Pirko , , Moshe Shemesh Subject: [PATCH net-next 8/9] net/mlx5: Lock mlx5 devlink health recovery callback Date: Wed, 27 Jul 2022 20:03:35 +0300 Message-ID: <1658941416-74393-9-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1658941416-74393-1-git-send-email-moshe@nvidia.com> References: <1658941416-74393-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cfb2ff3e-7a53-4ba0-a398-08da6ff21166 X-MS-TrafficTypeDiagnostic: IA1PR12MB6532:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zFg2uTXJb8uvcon1oneJ+i/jrOLMr18qq1xRuS3ChsuUQyDJwJm6sJW8cHqSPlLDn8TDhaJXnwp0SYy1f5yqSaKkrW/uLWJzPW12SE9bXL3emvJ4HZCrkQxf7qxr5Ls157XDZyoW4lTZ3EIL/8dX9PU3NwfovRv6JUz0UNMtTV4ov1FCtCwhc2OCZLYQKCutwaiFHSrTANqoiFOw69FxsyGj+ENyb1zuppAE5C/8FMboC4YTJ1y7D76ymEjEuF62+1IiX2ja9yZbHn4vAulJk5eq3V8Y7UnXr8b9i0Cu+YQp6I7jFnVj57urI+Tm7YSOeVSzw7JSSBxNYbNiaIeF3euKIADm13xx/wIypP4PGHuJaMXiI3y9PY5uyKwCRUGvBXonCV8yXdojTj+UdBYuWz68cKpNoiwl5p7d5HRM06Qmk6OTRX7ibIbjxKBpdggcI0w53K00yt36G64Ee4wN/1QH+biJGeoWg5Qh4JVefs+xyHUKDYh0/mxwgd2fEJu1UNciumB5DaDyd+x2eiROkApkgpAnBNbRy6jDZKs/eeiQSTLVfxg4trGzs63cxMfey6BNHaq5TeFw8DuYodBuyJAubP5I8kCDukFmt/52Yh0nq7mKkyDb0Gjp+jpZmF6OHvxLz4SO+Jjjz/UVWiCieCGO6MiPTPumXkRSM4yrT/FQNu5y+ReoCjhMRqZNtHsKUAQYkHKNBjlpFA2Nhex/ZH59hQVrWJVRlQ9FACYgbX0555NSWeDbCUfZ859Z9FH9Kk9BoA25nhuuxzUfiFTzblRzrhnyenRYePVBpqqxgHf2tbEiAHwwNr0GiXyu8DR7OQJ5v+x0Jj/0HXdENplXrQ== X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(396003)(136003)(376002)(39860400002)(346002)(46966006)(40470700004)(36840700001)(8676002)(70206006)(70586007)(4326008)(40480700001)(82740400003)(426003)(8936002)(47076005)(36860700001)(336012)(82310400005)(478600001)(26005)(6666004)(40460700003)(41300700001)(316002)(7696005)(54906003)(107886003)(2906002)(81166007)(86362001)(2616005)(186003)(110136005)(36756003)(356005)(5660300002)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2022 17:04:28.9179 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cfb2ff3e-7a53-4ba0-a398-08da6ff21166 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6532 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Change devlink instance locks in mlx5 driver to have devlink health recovery callback locked, while keeping all driver paths which lead to devl_ API functions called by the driver locked. Signed-off-by: Moshe Shemesh Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlx5/core/health.c | 12 +++++++++++- drivers/net/ethernet/mellanox/mlx5/core/main.c | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c index 659021c31cbd..6e154b5c2bc6 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/health.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c @@ -622,8 +622,14 @@ mlx5_fw_fatal_reporter_recover(struct devlink_health_reporter *reporter, struct netlink_ext_ack *extack) { struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter); + struct devlink *devlink = priv_to_devlink(dev); + int ret; - return mlx5_health_try_recover(dev); + devl_lock(devlink); + ret = mlx5_health_try_recover(dev); + devl_unlock(devlink); + + return ret; } static int @@ -666,16 +672,20 @@ static void mlx5_fw_fatal_reporter_err_work(struct work_struct *work) struct mlx5_fw_reporter_ctx fw_reporter_ctx; struct mlx5_core_health *health; struct mlx5_core_dev *dev; + struct devlink *devlink; struct mlx5_priv *priv; health = container_of(work, struct mlx5_core_health, fatal_report_work); priv = container_of(health, struct mlx5_priv, health); dev = container_of(priv, struct mlx5_core_dev, priv); + devlink = priv_to_devlink(dev); enter_error_state(dev, false); if (IS_ERR_OR_NULL(health->fw_fatal_reporter)) { + devl_lock(devlink); if (mlx5_health_try_recover(dev)) mlx5_core_err(dev, "health recovery failed\n"); + devl_unlock(devlink); return; } fw_reporter_ctx.err_synd = health->synd; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 01fcb23eb69a..1de9b39a6359 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1932,7 +1932,7 @@ MODULE_DEVICE_TABLE(pci, mlx5_core_pci_table); void mlx5_disable_device(struct mlx5_core_dev *dev) { mlx5_error_sw_reset(dev); - mlx5_unload_one(dev); + mlx5_unload_one_devl_locked(dev); } int mlx5_recover_device(struct mlx5_core_dev *dev) @@ -1943,7 +1943,7 @@ int mlx5_recover_device(struct mlx5_core_dev *dev) return -EIO; } - return mlx5_load_one(dev, true); + return mlx5_load_one_devl_locked(dev, true); } static struct pci_driver mlx5_core_driver = { From patchwork Wed Jul 27 17:03:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12930655 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 417A5C19F2B for ; Wed, 27 Jul 2022 18:00:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242842AbiG0SAY (ORCPT ); Wed, 27 Jul 2022 14:00:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242835AbiG0R7h (ORCPT ); Wed, 27 Jul 2022 13:59:37 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CC6E59265 for ; Wed, 27 Jul 2022 10:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MgYo34YMqLDKkSBF9vMsai0+MaYQbCTdesRcHI4g5auK//24nOvIQG/9M5gKrTMiVCgAi+uh9ThaL8A/wNlwtSfcgAVP152asqaUR18llJopLQ5N9KymnX5SOkSVQ3LwqdfgjAGevKo+UEAoSw+OjJ+uKXQG7e5yieGrNFPSKpbeGLfqwYVsn8wRu/BxqJ7oVgaMtkPiKeI96hajuJNEu38oo4c1VcU7x3WmMf6uWXK3JbfTMFX+gBCLrHcxySU+n+djuG+OVuw86TZNLQNsnrmmO/JYBETsPeD4LF3pUeOl1AEgK6mkzBPudgP2DQ9qaWpfTZ+XKOa75BoVtQFAxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AeYAgSsKJ845VRknfG3ODHOqZQzS+15OHqeL8jheL+E=; b=FdHeA5dOD/KJyFjWs5SmWdTFxMp+Y77FLc54oEgP/F3ZnKMQ5aH0sRq6sM+JLcozsSAxy5wLhxY1+QGREqa1rj7eEnjZKpnbtv8+yCx5UYZnp/oyJ1XDpo/s2Xt4fHgzKj1skt4f4NcbrxbzW8NrdYM8rFekC47b4HFVGt+OKWmH8QZNt2U2Hv8zMAwQnvXDI039FggzAR1jOOCFVRlg5nekPlSY2EPjrd3FYHwomGewCkH59DG+W1mByhrFA0WvI2zPfIkVjpsvs8RDsJQIU6V21dKvhgLLwF8E6BWuwg1AeATr+g0akNT6CKDfcGaxqyza7DXzx3GGnUlyWcXJ6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=google.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AeYAgSsKJ845VRknfG3ODHOqZQzS+15OHqeL8jheL+E=; b=eQhbClYZaXJa8rB+Ins6NicNzCcUS6mijhrJw5CCuBu8pL1lSfoP/CH3SG67WoNenamxKf5z4yRjAlXdB7bEfhvbzlkkQBSX0SQSv7GFN1wQGSMLX9RBTWqIeNifGjVgpkOrn/hqdXAhlV+obwv/XpL6aidM/eJaSfyrwD2myTEy3Cg555Nm08Zug23wTjgVSgSZi+36b93ureGxgjG3B2xZHm2tdS9xj6kkB0G93P3XTPO5RXMvDoVUMzkvwI+ZToO96LOX5jfOfjSu9d5f8nr3zX9jO96ls/IxBo5b/BsczSh2pv/0hgoygdp20Kti6jDt/drFSl9GHTz71jhhdQ== Received: from MW4P220CA0024.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::29) by MN2PR12MB3120.namprd12.prod.outlook.com (2603:10b6:208:cf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Wed, 27 Jul 2022 17:04:32 +0000 Received: from CO1NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:303:115:cafe::84) by MW4P220CA0024.outlook.office365.com (2603:10b6:303:115::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23 via Frontend Transport; Wed, 27 Jul 2022 17:04:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT057.mail.protection.outlook.com (10.13.174.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Wed, 27 Jul 2022 17:04:31 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 27 Jul 2022 17:04:31 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 27 Jul 2022 10:04:30 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Wed, 27 Jul 2022 10:04:28 -0700 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski , Saeed Mahameed , Leon Romanovsky , "Tariq Toukan" , Eric Dumazet , Paolo Abeni CC: Jiri Pirko , , Moshe Shemesh Subject: [PATCH net-next 9/9] devlink: Hold the instance lock in health callbacks Date: Wed, 27 Jul 2022 20:03:36 +0300 Message-ID: <1658941416-74393-10-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1658941416-74393-1-git-send-email-moshe@nvidia.com> References: <1658941416-74393-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ad23209f-93c8-4e17-a665-08da6ff21301 X-MS-TrafficTypeDiagnostic: MN2PR12MB3120:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1MwXPz+df1Ly9NHkG47TT7fo0MDs/EKKtxhGFSCe6XBEY4RrRRhbtLc6YiS4Q2VQzEkepm+cZqQ38HFXR9o4MJG1jS5pllUryy/9Pkgb+a4EnzV3FiDa7m9ETHM3jqEOYcuIer0f8OdQ15UUl/616EsKdczxnu/rCA+cXnH2yvF0hwCQm3toou9iDUCnUvyPjO3HE2aRuMQrzoorNmVENpY2EPDcG7aUdNrADE6R8FvYMMwETdU1kgZmBoqiT38z7CpMVsnsaP9U3GGaT2GhSf7gQTaVsXdjLVD0rkx9nh6mHb9oXHmHLcR9O0+ZJTCVTBPpFJrFJoqSIWQ0rQt2FVaqbR4LCxLUUxLCI1z457E1CrjO+ETpdjuMg6gWbaTVuzXE5wiAJHk5zb2Yvn/C+6lsLpDPscN763C+LBfFzkW32c1ldoSfRsMhoPQ879Jk2gVDcAjMZ1DB9cCdYLod83rMpCoH5k7Kd0W/ZZKBpCY+eF6o2PZ7LfiQZTnicM62BLLARyzRrA/yHMU+ZlS6YY1CgYYmkwhQ/TLnbzaAHLYtbpmcCeerHyjNsc5/l/dutgGENbrc1jibnaxhQUyk1rQ/4Hba2r9qdyYB7aRmTNVLf5G7J6w18h0Ex9Dus/hi0EH9yw2dxtXIuueFbI5l5uS5dmUfJMtzy4jlR8rEXWekvJq/wt54dFkG9lTX00goO2aNkaW9DKN8fsgRD005NfcLiX7MdXRjk50oqGKfDKoUgFqpuvxAUQTyGNHZOgKAvHm9Rx5mnA7+J0CPpQMEH1ei7cvfc3fw9u8mh9a+uyO5TjskAefVlmO5divt7FZJ44yOpzx/PKdhYpZvQ6bS/g== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(396003)(376002)(346002)(39860400002)(136003)(40470700004)(46966006)(36840700001)(47076005)(36756003)(478600001)(86362001)(40460700003)(186003)(5660300002)(2616005)(426003)(8936002)(54906003)(110136005)(83380400001)(336012)(36860700001)(40480700001)(107886003)(356005)(82740400003)(70206006)(81166007)(26005)(4326008)(7696005)(41300700001)(70586007)(82310400005)(2906002)(316002)(8676002)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2022 17:04:31.6896 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad23209f-93c8-4e17-a665-08da6ff21301 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3120 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Let the core take the devlink instance lock around health callbacks and remove the now redundant locking in the drivers. Signed-off-by: Moshe Shemesh Reviewed-by: Jiri Pirko --- .../net/ethernet/mellanox/mlx5/core/health.c | 8 +------- net/core/devlink.c | 18 ++++++------------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c index 6e154b5c2bc6..2cf2c9948446 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/health.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c @@ -622,14 +622,8 @@ mlx5_fw_fatal_reporter_recover(struct devlink_health_reporter *reporter, struct netlink_ext_ack *extack) { struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter); - struct devlink *devlink = priv_to_devlink(dev); - int ret; - devl_lock(devlink); - ret = mlx5_health_try_recover(dev); - devl_unlock(devlink); - - return ret; + return mlx5_health_try_recover(dev); } static int diff --git a/net/core/devlink.c b/net/core/devlink.c index 4de1f93053a2..e4bacc6d2cd8 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -9265,8 +9265,7 @@ static const struct genl_small_ops devlink_nl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = devlink_nl_cmd_health_reporter_get_doit, .dumpit = devlink_nl_cmd_health_reporter_get_dumpit, - .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | - DEVLINK_NL_FLAG_NO_LOCK, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT, /* can be retrieved by unprivileged users */ }, { @@ -9274,24 +9273,21 @@ static const struct genl_small_ops devlink_nl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = devlink_nl_cmd_health_reporter_set_doit, .flags = GENL_ADMIN_PERM, - .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | - DEVLINK_NL_FLAG_NO_LOCK, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT, }, { .cmd = DEVLINK_CMD_HEALTH_REPORTER_RECOVER, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = devlink_nl_cmd_health_reporter_recover_doit, .flags = GENL_ADMIN_PERM, - .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | - DEVLINK_NL_FLAG_NO_LOCK, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT, }, { .cmd = DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = devlink_nl_cmd_health_reporter_diagnose_doit, .flags = GENL_ADMIN_PERM, - .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | - DEVLINK_NL_FLAG_NO_LOCK, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT, }, { .cmd = DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET, @@ -9305,16 +9301,14 @@ static const struct genl_small_ops devlink_nl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = devlink_nl_cmd_health_reporter_dump_clear_doit, .flags = GENL_ADMIN_PERM, - .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | - DEVLINK_NL_FLAG_NO_LOCK, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT, }, { .cmd = DEVLINK_CMD_HEALTH_REPORTER_TEST, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = devlink_nl_cmd_health_reporter_test_doit, .flags = GENL_ADMIN_PERM, - .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT | - DEVLINK_NL_FLAG_NO_LOCK, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT, }, { .cmd = DEVLINK_CMD_FLASH_UPDATE,