From patchwork Thu Jul 28 15:53:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12931508 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 AE23FC04A68 for ; Thu, 28 Jul 2022 15:54:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbiG1Py3 (ORCPT ); Thu, 28 Jul 2022 11:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbiG1Py1 (ORCPT ); Thu, 28 Jul 2022 11:54:27 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2083.outbound.protection.outlook.com [40.107.220.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 828726BD44 for ; Thu, 28 Jul 2022 08:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rsm2ZE3Ui8fY/UzhXHTZUdQn4tTVB7kONd1hj/ql4/6T8o68XGraHTgJfhauET8d76HyKE5WIDvYD01GBa8bvLEW+czixj/Gt+oi6z4hfeWgX7Q/lRFusFHOqUrjQ5znhS2WJakS9JQ5twaMsmTLxB0uSH6yuvaUK9gRPDUzwRRLUhpRqySrEkU2C8Sr1vxDS4Np2sM69n3LLMJHHueeUnXWHi5lYNP4EeFDwHIef0MSAyJIA7o0BCQmpVz6ogb+oTIqtRJX5Qa8Abi3tiI/EKdRi8Qgk6WbgLnlDLzof+LuMbFYDbr2pIAH461av50PdCKB3LcC59hLPbst6TQsSQ== 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=+Yo9z+sDwfXNadmkr8cfPA7+7a1diRD8S3rqm+RrixY=; b=M4dTbqK8kSI1X7WS/Ba0Dtoth2F3CNR8cu1cTB0UsKACr87DXEnZ1jOy6oJhSqL8J8wkSQCkojutMG9iwU/PfGlmW1KDID7p2i1zdwdODIBx7iU0FVA0YHd3pLSLd5e2M/Y2RGaJCJx2pqoYQEXoK2GLeywwbmV1Q0/VU8WxYBHh8w7rPa2jf/jk3RaHNguhNXmv4HtFguzS1HPYyjdagGFzozZ7GjpO9x/ybt5luZibOsg/wC6SDw1RLLWDpUmvlbHJeZS2+9Q3G8WzNlCNWRmDvDvcW2bgdzlDjZjsCk24SL7tFxridEJQCty7uSGJVG2HcAwdKiW0wi3m0DN6JA== 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=+Yo9z+sDwfXNadmkr8cfPA7+7a1diRD8S3rqm+RrixY=; b=CBV2O4DA36KLykppFgwFmAsJiDXLlveKkioy9AcOIsyiqvbZUwwRLopWJGWtDVHITDl54ZrwffGCsCgZuuI+40PkH1pjKQndFIhUit0a3ysWksb4QqgOR37GhvPdpDALMld1aFk+0uESqlpyzUDp1Y4rF3SpaUyWkM8Z2UTdmQt+8za1ct/Ui/8TAZMQCwNOunq7+xUcjNFKgcO9sUtiT71l9SjEXwGABAW844XAPYJEbFENYCuaJi0b8otSJnVA66d3c0DFqxOudkga1g/nIOH5QpxzvBC0s81k/UwNRP9s8H1FSu0A4KJnTJP2vbj8/nj0DkzqoIX+BDtHtJmezA== Received: from DM6PR08CA0003.namprd08.prod.outlook.com (2603:10b6:5:80::16) by SA0PR12MB4432.namprd12.prod.outlook.com (2603:10b6:806:98::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Thu, 28 Jul 2022 15:54:24 +0000 Received: from DM6NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:5:80:cafe::81) by DM6PR08CA0003.outlook.office365.com (2603:10b6:5:80::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18 via Frontend Transport; Thu, 28 Jul 2022 15:54:24 +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 DM6NAM11FT050.mail.protection.outlook.com (10.13.173.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 15:54:24 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Thu, 28 Jul 2022 15:54:23 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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; Thu, 28 Jul 2022 08:54:23 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Thu, 28 Jul 2022 08:54:21 -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 v2 1/9] net: devlink: remove region snapshot ID tracking dependency on devlink->lock Date: Thu, 28 Jul 2022 18:53:42 +0300 Message-ID: <1659023630-32006-2-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1659023630-32006-1-git-send-email-moshe@nvidia.com> References: <1659023630-32006-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 167c0023-0e06-4a62-1a32-08da70b171aa X-MS-TrafficTypeDiagnostic: SA0PR12MB4432:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IN2ZXLXhIbWdzchb7yXzQz3tiUwJTtWbQb64DrmYV+61XXdwckRJ9eTROpVBt00ufJLcP954Mczh7bdKknPuL0fjb2J4G/gV5PHmUBoJgdamt8sLFbuDz0TuP5VspvQIoM61dAOxVv15TrLg3FIawzfZzPanYzEz6v0QgUwgTsGWn9lKUgQV/SkqQ8i6JG5uHVA/nSVuoICth0oxYuRmS60eDPv/CjtL9+e43k5HKFX9Lhjsm9WS7+Sy+2EfIlvvP0drpmXnWfXkA+ZTrIEdp2OgrekudHvTdTAWhKgmu0VvbJqKADspy6a/DgmHNw2+McsGw6iqAbH/BfegSpXGeRHXPh5P3WwU0nGRyIL4ijgTX54Rm4RLxE5lSjtQPOHh3MRTxS4Aj3qkVAGwGNqNO5e7cZgUlZLUBJWd4Q3oLmozrKiTq97Q7ASVb1Ncvvvfjrt+aPomWRKx2f+mEQ0C0GzsrwtNRqujlYUXtbLXkeJz95yD/wUIvO4KZ2HJ7A1ko/Trvgp4UHD+1GkxnAxrAMoz88JJfi8fOIH/kZZI3uoSGhkMHP9NPyiwusCdOwdQAMB5s2Mh8bB9BnvllFboyLQizJnWYunX7z3oSILgZwjH5lArFkFrpXoARgkpsTDlVYzrNV9pmKGZ5fh4dlph0twnvIPGW+siB6OHKLb7Lux74Z0dDQdoF0EJmn3q2YG2JDHyV+e6F5MsPYhQfFUYzH6NTDCFUneENIdW8L/KpegUg777f1QDm3J9XOplPhaSoTzQsUp5TSxYfqVAHzlVrIKAw2il1yuUsCcRqedT1XzyRK+Xlu2JBHFCjLZsVVMMyx/R+84u315kE7IuJaP14Q== 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)(136003)(346002)(376002)(396003)(39860400002)(36840700001)(40470700004)(46966006)(83380400001)(426003)(81166007)(8936002)(2906002)(5660300002)(82740400003)(47076005)(336012)(356005)(36860700001)(186003)(41300700001)(7696005)(478600001)(26005)(54906003)(36756003)(316002)(6666004)(2616005)(110136005)(4326008)(86362001)(70206006)(70586007)(8676002)(40460700003)(82310400005)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 15:54:24.3748 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 167c0023-0e06-4a62-1a32-08da70b171aa 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: DM6NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4432 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 --- v1->v2: - changed GFP_KERNEL to GFP_ATOMIC in __xa_store() calls --- 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 ca4c9939d569..64d150516e45 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -5690,21 +5690,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_ATOMIC)); +unlock: + xa_unlock(&devlink->snapshot_ids); + return err; } /** @@ -5727,25 +5734,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_ATOMIC); } 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); } /** @@ -5766,13 +5774,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_ATOMIC)); + xa_unlock(&devlink->snapshot_ids); + return err; } /** @@ -5793,8 +5805,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); } @@ -11226,13 +11236,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); @@ -11248,9 +11252,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 Thu Jul 28 15:53:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12931509 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 980C6C04A68 for ; Thu, 28 Jul 2022 15:54:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231630AbiG1Pye (ORCPT ); Thu, 28 Jul 2022 11:54:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230127AbiG1Pya (ORCPT ); Thu, 28 Jul 2022 11:54:30 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2070.outbound.protection.outlook.com [40.107.93.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B2A16BD64 for ; Thu, 28 Jul 2022 08:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gGpHmIfueSB3nDrWPx1quxsG5t/TP7jgm2L90kj/RKvv7jb+3KrW/F+XJiGMo728RuoErOnl0Mk9R+De7uUBl1DoBHletlnx7Dvawc70NHyXEYECcs1JA+KpHbx7A0YPICLb4rAdfLoxfXm0DQvYz+QLFz9SvoZl3FuTaBL2TcupqbNBrCKxYGPpMLt8mIvuNEPcEN86EvE4D8mzRoIOhiVbOXX641h71dgDahlvuXX1X7t/uKCU1uJeJLkOBFRD9EDJlIfrwsG1GdkxWKlXKjetV53fWAwsbp7ilVnU0OeyN0kb9hTlU2h01AzxleklAgJPw6N+iGLXkvIs0hwuUQ== 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=48U8P8DfAzqcHemHFepGsX3gL0xGFg1FXWX+kEDtIe0=; b=fu8C1RDjPGGFEM3yxgshWNx0fKld8+stTcA4r8dvYmRpCwzO1ANP64mCo5eTsZFF+8enhCLieyDfDo5HuW/u7BDX0OJqdYtNZPEjTPudUq46HanPGZnc2iSwLbx7qQJ4vy37Hxc6RLI8RQMfsOA9HMXb+1PYoAMIQ4V5gQtfju90SWdiEWkjKrps88HtggYk3tSsGXRnyJRmx9GBc41ncklaQQv15oDGsWrczOwNa9gcbiC36RcH3RfEG0lYotvesExy6rloXMiP6xKv4KQXs3SfQhs3HsR5KBWO1ZeIHwbafAbaYx99zW4V9umPPLvUYLRHIZoX9tPjlBU01ShFEA== 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=48U8P8DfAzqcHemHFepGsX3gL0xGFg1FXWX+kEDtIe0=; b=bWsXGLXa4rMa7cOPM2te/7zO1JnWHRVSPL1JOs4CZM3C30lllexjdWbZufwMg3IO1t7fSKPJjyEkBUCxTtwJca6VNiBkU0SvgRNx1cUmIzC7kVVyWgv4adxJH+PG1wgWAyHuaJ2bxwuZGZif2G96Z4CfVawtWhXfaFhxsKpO1UhC7eZ0EUv27+67Zvcf8qOPOvJa+080EJ/5X0o8pUn6yINZVhmoaBlk1KRhnN8EOuDtESsCRRygw18HTjoEDs7AmYEcqSVo7R1ewjNEPUr3ktQok7ynuCvOy0zO5My4FfNaUfYZSEVVBo5I3x5rfES7nFDaJzBO9GSltzThAdwRDg== Received: from DM6PR14CA0068.namprd14.prod.outlook.com (2603:10b6:5:18f::45) by BYAPR12MB2983.namprd12.prod.outlook.com (2603:10b6:a03:d6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.21; Thu, 28 Jul 2022 15:54:27 +0000 Received: from DM6NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:5:18f:cafe::2) by DM6PR14CA0068.outlook.office365.com (2603:10b6:5:18f::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.23 via Frontend Transport; Thu, 28 Jul 2022 15:54:27 +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 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; Thu, 28 Jul 2022 15:54:27 +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; Thu, 28 Jul 2022 15:54:26 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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; Thu, 28 Jul 2022 08:54:26 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Thu, 28 Jul 2022 08:54:23 -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 v2 2/9] net: devlink: remove region snapshots list dependency on devlink->lock Date: Thu, 28 Jul 2022 18:53:43 +0300 Message-ID: <1659023630-32006-3-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1659023630-32006-1-git-send-email-moshe@nvidia.com> References: <1659023630-32006-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d18cdd2-b2b0-4db3-98b6-08da70b1736c X-MS-TrafficTypeDiagnostic: BYAPR12MB2983:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BL3tZYcLwpkNbiiUNAvy5V/L5i5pTKeNsuP+cJvHRtV4nrSfUnl2KgQ/Z9JAVJuSuk1yAla//SFBU+oJowciW35sxB3Xj2FXC6WbnS6I+GF9KBGRFK4YQbIhpgC2wKj/ZBw2oZegmSdNxMZ15dkEnZtEnAeSF87eDet/l1gEVtkKx9H89qRZAz8OvSWUXwW78oK+AeEMrw+uqFb9C+K1dEXLTpoTVmBWGP14XvrE+gIJSJHgu8/Gwmyw9wdarRHKZuCZ816BhaZl+j5oxyB5uA7wC0KyukTxbXJjscok/qYFMg3mwDz1lpBKTaJsVj9K6wmLvy8AK03ed9YQH9XQ2DSPOrQQFHkx9ayrYCM1vNTBmMzo9MW5CZJa9rzVbT1WBJHvjAMjbmipe4kCI/7Gbzw7g/TlVlL476X41qzBc0LFeFhRfPwMs5HoLdbwLQQM12zg0kzBXzRPQ7Z5mEuQkjsutA3A7jkF6/YVEW600USkOR5CtXNw42C7juArCUeVDcQiqheAByFPVEykmR2RRykDjOwv9YLKqBysGaonjlsJaoib+Ae+a81E/sIY44CkrbnGIuUSo0upLISmUc36Av9CqopsuVwUGT/PDqioIz9XeNGxsMRRAUwaRHv5HTi9CUd9vflyyk31zLQnfRM5KO/Xn6kNifsLp/B+HnGl+bU4QZqDLQD87GBrCKp+2y5/XQr3uTDKsHayqyQQJuwiyF7imI9r1Mw/e69wDdbSNMrwNaHXo0uOgoICf2SK9xsa4OAUxqvKTCqgb8vT0nACOZVb7XfXPvTVJ+DKbFpmblyjLuH9KNuihiut552hF/sdvd+YcFcc9IHtQLeCdwBsYQ== 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)(376002)(346002)(396003)(39860400002)(136003)(36840700001)(46966006)(40470700004)(83380400001)(2906002)(8936002)(40460700003)(54906003)(356005)(40480700001)(26005)(186003)(2616005)(478600001)(7696005)(336012)(426003)(5660300002)(6666004)(47076005)(41300700001)(82740400003)(82310400005)(70586007)(110136005)(316002)(8676002)(36756003)(4326008)(81166007)(86362001)(36860700001)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 15:54:27.3115 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d18cdd2-b2b0-4db3-98b6-08da70b1736c 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: DM6NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2983 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. Note that in mlx4 region snapshots could be created on any command failure. That can happen in any flow that involves commands to FW, which means most of the driver flows. 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 --- v1->v2: - enhanced patch description --- 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 64d150516e45..274dafd8a594 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; @@ -5817,7 +5821,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 @@ -5831,7 +5835,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) @@ -5869,7 +5873,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--; @@ -6048,11 +6052,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; } @@ -6100,9 +6108,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]; @@ -6111,17 +6122,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; } } @@ -6159,16 +6171,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; } @@ -11094,6 +11110,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); @@ -11167,6 +11184,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); @@ -11196,6 +11214,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); @@ -11271,13 +11290,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 Thu Jul 28 15:53:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12931511 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 78416C04A68 for ; Thu, 28 Jul 2022 15:54:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231670AbiG1Pyq (ORCPT ); Thu, 28 Jul 2022 11:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230127AbiG1Pye (ORCPT ); Thu, 28 Jul 2022 11:54:34 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2082.outbound.protection.outlook.com [40.107.223.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6C9D6C105 for ; Thu, 28 Jul 2022 08:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=obi4Sn7Yf3nXiDuLgd9Tu8nfePxln9t/V77Ud66ybg3Z3aracgMeu1KeZKtxwmNnTC+S1VjXSbAEjg1YfzyXZsJ8ujUMmB2W4/DMeihOyIIL64n8HQ5FKsZtCZT1fsnZJ88XpLUMYDe052zWBscDBZSQ8BEaku9id1s11uDr7cEYXATSlKiougqVKexWL634V1e8RQTIZneXxuENjMziNMWD7+bkznwzzQSqWcldLD79xn2/hQgh2gP9cuXvLuW5y3JT+eELQaxte64m/E39egcxwLWi7Z1Qf97HJhDaG+jbHUazzFvxD3wfuSpJAOHXw7eqLqbYSoQStKRDCM4mOA== 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=TyijQIVdgDLk3o3m5oWjFoHIQRuKIbPQlvXWO2Nrp2sKc6aiYhugf3WVP1frcQ+G1mefOmQZ24NHw+PI8hutIrnqgNhKS63lSQYSYG24befT77dY6wk1Al0unGuesnrxNb9vK66Z7TuOmllcY+PWP0UawVGKkM3HpdNER/cxZ3YxLbV0r9WJuUVPxbfytk9VGOc4Zw33V1bmhVZjl5oug7arq3xQF1BzbfnTSSZdbCQYsw33/MfygHfPdBjvpFliC0xZwYTsU61mCGaB2zQ43AzXS/qRIAseAOfV93liMyJEXuAVzJnDYAgm3LdJpFb6j581tKADcWB1GGrLdGsKxw== 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=ofFoM3AA0XT/yno49TXfQs6cY2VrsYsd0wHbsS3jR/g=; b=sY54rTUi/J58MzdVyXbYGVPZacF3C8lhY+4gcnsbBnixMf0dvR3fzxje+XGWHAanctfzHphWU4YFTubYxKXAYtyhDjTOXFPTQos2hs/PPhGC/9Ua2pzWlcav2vNY8GLBrav/+i3+qY3crw/iFQyVOqyNvDUlBaJU6tIdVTLomimc5tqWNGDiEIE1QoDtQsVEX/Nnbu8Oq04kMMzZIoGrPoJQ+omgtIS28npLgIx56SXIEfuIAUh1tl1KEeZy1b/b1CcRJw7aHeg30q3VRjhiR4wK+uNAZgBQYrVnSY9hxMH7ZfxmPivqh/7tct3l7f2ouoErIQRsGjNeaodRRf+afg== Received: from BN9P222CA0009.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::14) by DM6PR12MB3145.namprd12.prod.outlook.com (2603:10b6:5:3a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Thu, 28 Jul 2022 15:54:31 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::55) by BN9P222CA0009.outlook.office365.com (2603:10b6:408:10c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.7 via Frontend Transport; Thu, 28 Jul 2022 15:54:30 +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 BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 15:54:30 +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; Thu, 28 Jul 2022 15:54:29 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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; Thu, 28 Jul 2022 08:54:29 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Thu, 28 Jul 2022 08:54:26 -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 v2 3/9] net/mlx5: Move fw reset unload to mlx5_fw_reset_complete_reload Date: Thu, 28 Jul 2022 18:53:44 +0300 Message-ID: <1659023630-32006-4-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1659023630-32006-1-git-send-email-moshe@nvidia.com> References: <1659023630-32006-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 937efff0-8401-4f61-1179-08da70b17551 X-MS-TrafficTypeDiagnostic: DM6PR12MB3145:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SeWETMV7eD9I4pr5UZevSFugiggwxm3L1VN12T4pCXWxEHs73KHLIq9SEMYjaEMpNQVBuJ1XvhvTf/ZvF2bO6i3TJ9zo6a7F5vwQyCobKpwoh+hAAbQwRtgCGYYxpSPAcobFbykceXP45p/6KpBi19788UydeQaUlZCToGkUisP8buWAWNtqHRff/vBeCW2mntgi3SxoQ6Bu6XgwXf+tB4ueiCKX9zaABO4ayWLc1skrAm7kiSTPd2o67DpRAY0d6yVZt359jvC5cNpThZM2mrEftZFneCZvBb+Bf21snK/uO6W776ZN6BjWgqvGJB1svEK7C1eb7qOWeZZ/a76H7XgZUBSmAJNyYQvYT66gK2OwNhSq6yoqsQrDpu4PBKjfBRpLciIn5PoH6FoxKHVM9wzWLloj5vSgIA5Uy1yjHM7X122IIQwgQywcsuoaQbHbUy0gi0XanSNpvlG654E6vR3L7gsOhQL/eqTdMh2WFjI9qijnFDfQZF1nK8cCnaK4UduR7ln91jzKfJcn4LwtKks+tDn0DA0W/sekpHHDO7ERFKIVYvKMlwIHRYOEgIY+h3WobN74d70jCQQ01yHBCTzUFebrkdRWm3EzMp4yC3E55kiOKmyZOkaNvSgxV1V4cX4Dmpp0GirTB3Tv5YhGBh3mCFVQOFmNKLDof69/rIAGIS07qGN7WsLevj5ZKvKSDymYWV1E0XO77su+XvwZFHyGKAOSickPdmxAlnPEIL5coJEyXKAUVAGjovrvwCW5hsPMDzXNcW5VIHoWXPnC3hghxppX1jBcUbe/90Oq362USkE37EmXw4trJjL71ZV5EnpFeyJ3z5vFj4eBJ1V40CZFobbHG5I+8XnkkcK3MLLfhof1z/gxZsMsYVtnTpoucOszetOktR1VJI6B2Dn+Cg== 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)(136003)(39860400002)(376002)(396003)(36840700001)(40470700004)(46966006)(40480700001)(6666004)(54906003)(86362001)(41300700001)(2616005)(478600001)(7696005)(81166007)(26005)(36860700001)(82740400003)(83380400001)(40460700003)(316002)(110136005)(107886003)(426003)(47076005)(336012)(8936002)(82310400005)(5660300002)(36756003)(70586007)(2906002)(356005)(4326008)(70206006)(8676002)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 15:54:30.4241 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 937efff0-8401-4f61-1179-08da70b17551 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: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3145 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 Thu Jul 28 15:53:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12931512 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 A47EAC3F6B0 for ; Thu, 28 Jul 2022 15:54:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231430AbiG1Pyr (ORCPT ); Thu, 28 Jul 2022 11:54:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230194AbiG1Pyg (ORCPT ); Thu, 28 Jul 2022 11:54:36 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2067.outbound.protection.outlook.com [40.107.243.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6655E6BD71 for ; Thu, 28 Jul 2022 08:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=afy4m/DNciZYfOA7XZFGAFSVAqQiHK5hkHYDmksSNfBk+Db/jCKWLiNwAflqmT86YJCAhSdsqrtLIMm899pJXd/DdBb+1t9r4gjrZeYlMl+VDM+USJ+3ihG4wJuy49OAfQSQGS8lhWyur9E/07sOqc969fNHLbiOp1Cor4AYgqdk4ZUGTjmq7DT3uTbClxhjBCZJaoU0/9YA05KowngV8JruACCkH9pOjI57KGbO8yypWA3KeIogSq5Oq6T/OlXD4+hi+newv0K1d6hqjlliBosaGqy4w41Z6rEJR4gG8RwQ2oXsOunf0A7wbS5a9xnAOzx/WiLu7Myi3EG4Ksw9Bg== 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=ZIJLIzvcZYV4zyKHZCt4vP1ZpSBwXwMDQTs1vBmJLyVRXkzKI2ookofmi32Jun9I2guteslGI1Gv2/yNc7fPt6JOXkwGT0pKG/U121EpCwdqKJBIYSXOw2w5RkgaEHHctZlrzPndd77lUJDcVIN0VPJIVbn4MM7p8Nn703l/D4rHBkvaHgQPn8EaWV8HItbDdB+wfNxgkthfgSSMvBO4N3itWjVG88NFrcBbtbw75enS4DSa9qlNC6dXdQg2u9dqOwiI48k9de9zQXACUSkaMEdbj5VORAIdHwKlh4oebFKglZiUA5gihcTKNtXcZ2/UeJb5WhtL7+Sb87af8RNprw== 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=p8D+dIvNBnYIuuwEElDEylQuGbF0gsqEGpG7oc+cFNE=; b=dOKwrsq9+ndM9UYeatacg88cr5mhOnkOYevAfs6ESwuf0ve+vYvkCNh9EJRARGP60d3+NyD/JVAFjRNIHtuOhtaP468ZVmQXnFulZ4MYxzOpDzx4DLv2c78X86ccm712GZFKzwAJWN45dBUPVxmY/dk2lepJh7arT7FZXNqRdjdrQq1KaqFBUJ+NxB4uFHHN2/XB8kQwlUUz6hzWUWrDEgcBArrLUEx7b2NbCz1DJYB+29l2Z3DghKHiZuKLzNDl6tnJJxNl3xEco1e357Z7p1GngXEOzqqXm1BYeAysxxtPqBGCmFYEUxRkkGFhXyZJtYSqoSqQFuR+s4uyCSUfEA== Received: from DS7PR06CA0024.namprd06.prod.outlook.com (2603:10b6:8:2a::8) by DM4PR12MB6085.namprd12.prod.outlook.com (2603:10b6:8:b3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Thu, 28 Jul 2022 15:54:33 +0000 Received: from DM6NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2a:cafe::30) by DS7PR06CA0024.outlook.office365.com (2603:10b6:8:2a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 15:54:33 +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 DM6NAM11FT059.mail.protection.outlook.com (10.13.172.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 15:54:33 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Thu, 28 Jul 2022 15:54:32 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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; Thu, 28 Jul 2022 08:54:32 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Thu, 28 Jul 2022 08:54:29 -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 v2 4/9] net/mlx5: Lock mlx5 devlink reload callbacks Date: Thu, 28 Jul 2022 18:53:45 +0300 Message-ID: <1659023630-32006-5-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1659023630-32006-1-git-send-email-moshe@nvidia.com> References: <1659023630-32006-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 05af87b5-14f5-4765-a473-08da70b17719 X-MS-TrafficTypeDiagnostic: DM4PR12MB6085:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0Vy7aPsXuhOGNH+1mLBqrPynLaeeWvmYhT637dJZHb5vXnBP2TJVJRc4cECmeKbm/vOlBRJFZe6V2f5Z/ig3k+Xm6k/5n71AsojANGTELsyJC/iw+1Ju5R5XoQ5SFwUs6X99zTG2IHy7daAXEH2XT7wYEe7xd/Gyc8HZtEmGtyFtv4MoLu0m5H2Yg5ELIdc0Q3bsNRio3lC7wsUEuNWDKpYDvN2PkhB//DP6IoTSIwtQriuj1q1buvOM08aQK+6PBmn9MGh03LimUKOINEqrJjH2PQBkQBwmuGHShQX5nEU/3NjG2ldu/3YrBImvgSsvF7pOUsJr51QijKRUkztER6neCVlAySnlk8b151NCR5LkjB8A5RSeD7rznTlfqvKdJYD7tdKoLsuE9MHyp8GyRDxW16epHDFbhbO5qQykblC1qxt4KqDdTszCzT3aT7cot1vHHpqsNFBw7DJSqPoukCpENoacZ9GcFoh5zl/R8PoiMwKS3KUX1VeADE33p0efdcdVk4qrqal0+kFOhnENoNdl0d6EPTLcsSIQxRqTjzcu8fKmWvlyuV7jxtwKfAdxm4P0Q+pCZ70FQf0xB/LJsBgEVNP04A9BZn71KA4xtu6+inB+4UCu9G6exG5oDIcbaFhV7VJcwrR2StSpjmpSUx1ixTmuqHjBMW799Q+6ld1biUSrTFkiW8YqZY3uf8UMrxUMaN9NClr1TlUaRPFrFsuC1XWmzvAcIBX2cnrrz6wuZsSIqFnF/jpTFl0k3xNsrqPjAqitc7LBG8aIgBWy0jL9MfWmofaNLZcYVhl06Vt3SCtg09OKu0aCCdXKnIxeNMvqGQmINP/XRbPMme+jl0+gQGGKr/FOa84eQB5Y9SXzoxyrIQqjdR2rE0Ivqe389ZuB+XgJtiMtyjun3/NFmQ== 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)(136003)(376002)(39860400002)(396003)(346002)(40470700004)(36840700001)(46966006)(336012)(6666004)(426003)(47076005)(4326008)(7696005)(186003)(107886003)(82740400003)(8676002)(81166007)(316002)(26005)(83380400001)(70586007)(478600001)(30864003)(36860700001)(41300700001)(82310400005)(110136005)(40460700003)(2616005)(8936002)(2906002)(40480700001)(356005)(36756003)(5660300002)(86362001)(70206006)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 15:54:33.4475 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05af87b5-14f5-4765-a473-08da70b17719 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: DM6NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6085 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 Thu Jul 28 15:53:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12931513 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 06A5AC04A68 for ; Thu, 28 Jul 2022 15:54:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231757AbiG1Pys (ORCPT ); Thu, 28 Jul 2022 11:54:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231979AbiG1Pyj (ORCPT ); Thu, 28 Jul 2022 11:54:39 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2067.outbound.protection.outlook.com [40.107.95.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5604F6D2DC for ; Thu, 28 Jul 2022 08:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bkb9wBXor+Ag5P9D8lQTdxpPS9wTeXo5eOhTF7eHei7C28zwJe2M10jTIQC53ETV3FutCE8S3nkxC1y//XJmY05x0PUniR8fXdPqPyTkOX/j1g6LiAkRXSKfR+nlDWaz/IMNL9kx8xhn78g5D39h53eBzCy5XBrrKrjrgB/jkLOoMRg0dj8/0ZniMSySJ/0+mE3apAfKDWjdMR68yOz+8+66wgokrvTuqRZwme0jQ0J8PutCa+ZhKAKxOJC0cg1Qv/A7BDBSmFIMbB1nKKJa0Oby2afHc0aanIltaLMP+ZzpHBpx2fYxvbT7QNj7y0snWFFKJmE49heb5KSAPDidqw== 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=MXoZ0bdVtEijqw0TiWxwxmRq0JpJda99gXSQbW/lCpu1JsNCeBQe8B3039v72pwaWFRREsN+IwDltCcjkv/UR4x+rMpDVXyugcJgtCFUIUGF7ZEg+EqmOZbMOhW9W/cg5iRIuwdpnmvshDz2Pn/rMx9x2FYmmE+WBXhRgLk4riP51jGCZAkpqYV8FNOUCdX9cGsnrpOQwQsT6RxD6Eye8PbJe6OiuQXx+mJ6CqMB5bsGQSAq9TjkY8noIN1ZDmHXAYtE6FqzvIyCdAZdO/r2MBtlYwjseI6fbmOpJlvETHvLp2FXl5KMUKPaVOGz+1AjE6FhG4E3k+zo2a17jhXyog== 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=rBd3BcZj08RceBhH3bji32iNEFiFZ7UoVVwv8ZHjr6s=; b=HcniUUFpnTeuM4Jr/TPyj/mpmAQ1Ad5o99noZ5PQz1ZzbcfNoaWTp1dSgf55rWjh/BQ2BybMAAOrj/Ti/HlpGKd3A2X7gzXGYBYr3/2Gka1YMLBIFCZtxgEU1VJRJWoQo7qiXbJpxswYJYhFOUckqGF+COCZOQrrohbec6tbpigsAutysUs2bBcHkE6cfDs/iKsdBkku+eB5rN8CqFd/cGK6YqgCyGRzwFP8lKu1vxCdrhVXU8ptw0kKqaBOc9D83w74qNs/wyFI3L2wNiHM7LLY6NVwS8IorVuN1pcVrm6lFCyFPrQ57XnjQ85LuT4QyNyQaMFKuaMN7ybHKyV0sA== Received: from DS7PR05CA0060.namprd05.prod.outlook.com (2603:10b6:8:2f::13) by LV2PR12MB5967.namprd12.prod.outlook.com (2603:10b6:408:170::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Thu, 28 Jul 2022 15:54:36 +0000 Received: from DM6NAM11FT062.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2f:cafe::d) by DS7PR05CA0060.outlook.office365.com (2603:10b6:8:2f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.1 via Frontend Transport; Thu, 28 Jul 2022 15:54:36 +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 DM6NAM11FT062.mail.protection.outlook.com (10.13.173.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 15:54:36 +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; Thu, 28 Jul 2022 15:54:35 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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; Thu, 28 Jul 2022 08:54:35 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Thu, 28 Jul 2022 08:54:32 -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 v2 5/9] net/mlx4: Use devl_ API for devlink region create / destroy Date: Thu, 28 Jul 2022 18:53:46 +0300 Message-ID: <1659023630-32006-6-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1659023630-32006-1-git-send-email-moshe@nvidia.com> References: <1659023630-32006-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f031e1ad-31a2-478d-fe61-08da70b178bc X-MS-TrafficTypeDiagnostic: LV2PR12MB5967:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NzAB0iBNz2w+8l4JbL78UQPzN5I7C8vBk9S5uUIagDh+O6taGnEguYCBeKVmByCwN58eKfD12MsvM1EUJMW5Yx4QIAzvFlP7qqyW+sp0y2VuG9RKhKkyfMyL98PS5tF2WJY3U1IML5qdnhI7tY8qCKSoEQ5FPtopjfMzwQzsdadb3gTDjkIJJAHasxOby5aixD/GzR9j2B5lthrUCc6s7QbrWNAzl24iJ0mQYIZz/DeWZgRnC1U9XSrYvkl5uHvkhHbOU7GyglTutDWm8dF4TQ8r60dJoYU0g7/D8xIlA/mL7x+yPo/l97o0OWhVF9FH4ksTsKYm6yQMsV0g3o1dN912bKJvs4OyMa7n1XY/Jcz7Bt6hnXWXE0/iF0AYTiSddwIxSRMzke3lk1pSGVhBbhBXCNizAGJG71/E2ASspwbhzeO768Ifk+/mEX9U1uHWGGTF7xiPNPe6WO0blFsEVceAGERxqQHXqsOM/QOFgRiB3uW3dgasCmMiElIeTycd08HdIySreCv2WvjSQppmMPL7fShf3pEa3wkz+871UeQWNGKqfTr8Bjtpx0IIeu9OyV6GUtXXvtGObUQHYQs1TC2NyBtXRgWMMl1PFmBNCUFwWVuH8mzEJOLU9cv7lIuDe6LjCkmoA6zLS2NwDMnR8uoZ70mYF1m9sqiSviZGwRd2Ibn2aTX6ZFMiWmVWwWA02sipNbuVt+I5miKVDO2cnO3o2XCLWpmfzFq+RWyLnwzIBIrUgbFRcugGq60wgG2eDrASXzrbk/UZ/ax3jEcN4f+W7TWCfXbp6S4pMvmyTe48sAkVZZslxOm5Ryj10Snnjj4vwVVfW9beZz5h1ZdN8w== 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)(136003)(376002)(39860400002)(396003)(346002)(36840700001)(40470700004)(46966006)(7696005)(107886003)(5660300002)(26005)(186003)(6666004)(2616005)(41300700001)(336012)(40460700003)(2906002)(82310400005)(82740400003)(356005)(83380400001)(81166007)(47076005)(54906003)(36860700001)(40480700001)(426003)(110136005)(86362001)(478600001)(70586007)(36756003)(70206006)(4326008)(8676002)(8936002)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 15:54:36.2426 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f031e1ad-31a2-478d-fe61-08da70b178bc 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: DM6NAM11FT062.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5967 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 Thu Jul 28 15:53:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12931516 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 94549C19F2C for ; Thu, 28 Jul 2022 15:56:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230344AbiG1Pzp (ORCPT ); Thu, 28 Jul 2022 11:55:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232341AbiG1PzB (ORCPT ); Thu, 28 Jul 2022 11:55:01 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2067.outbound.protection.outlook.com [40.107.92.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 243E26D567 for ; Thu, 28 Jul 2022 08:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AZ5P6fntGh1FD0heJ7m+Y+YQMhfABt0UwW561SLxkc+lpTHfYhgU7nxObz/KclydWthnVwRX+B4/27woqZ+FXzxGxG9QgZtfm/81ETHGjN2o+QwF+w8J+W95IyxQCgAhJSJkg68GPByCOmcFMy2dE+JBSdiytMz8wD9e0xu/aax9gKkXCQtZPjTS/ekJSqkc8EyqPL80+dviESIhkrhkrJQLOXD+B5XNW8D/cZlihsb4madsGgrHNMyBBoF3D4UG9+GOV/8X5EPWldERXVEJhMCBa/PSgTXbA/r8geApHFPChw2Ke3ibjatp7evhMIIuK23rW/K9UlRjOhiZIA22fA== 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=NifJuEKhrcY9uf0uHgqRvPZOgcUkUj+uh2wmZRQwpJbdIK0eckQVNncf6icRkKkNZ1SA2dlb4nth+V+5H4gjA8jQ+tL3krfcK4f4QFLK7s5/Ar+Ajaljm5BeBM0Y0s9yF1mu8/gvJ6BJytuR3X8hBzI0VBA+AfhLxOqIslVuabDujFMYWO3ijMlX5cMaiYmcEE4oDVaw1A98u25dA1gMZGVhFcSBQ5WhHqpxVsx/K9uLou38XjxRq/kkmOJQBWTZWAYhDmbix0Q8De4eY+UNU7u3xpHH4LkidAw8CGFHJE85zcXmZLKqI3IW0TE93G10nKhEnyMkNKF14mAsQ6HbGw== 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=9FEdLw1sTXVoRDHrceXmgLjIk69yv3hyzZqPDftRQUY=; b=ZmewPgO7xIBJgeEwjGEzOjERxccdIqqJs4B2aWbFRF8x4M5iA5P9vsrSt54ZGX4dfTHbJwYkIdvx/WObvMDpxRdbMJjWBHAUsYG4XcQsW7rMbocEC0sVoF0buohAlcdwUeDLWpWXsPWz3VVB9d83tLPN0/JxYqXodbeOBpAiMLKz7Ka7FTfbcCq3aaCrMABVjz88Xg3q9i6ryuMOdwSyQdGKIhE0AYBAUqoyz2VmTCxUU8WIQHR0gGd7zU53Mit1Umy9cE3FDtQ8Js6T0DYG+mcD9kzYEVndAtLdlWXBuycUi0PAlrqTAlXTHpaFxZ2bKFRwfPoLeIn+ERNe5AGkuw== Received: from DM6PR07CA0070.namprd07.prod.outlook.com (2603:10b6:5:74::47) by BN8PR12MB3362.namprd12.prod.outlook.com (2603:10b6:408:44::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Thu, 28 Jul 2022 15:54:48 +0000 Received: from DM6NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::d9) by DM6PR07CA0070.outlook.office365.com (2603:10b6:5:74::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.20 via Frontend Transport; Thu, 28 Jul 2022 15:54:48 +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 DM6NAM11FT060.mail.protection.outlook.com (10.13.173.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 15:54:47 +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; Thu, 28 Jul 2022 15:54:38 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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; Thu, 28 Jul 2022 08:54:38 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Thu, 28 Jul 2022 08:54:35 -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 v2 6/9] net/mlx4: Use devl_ API for devlink port register / unregister Date: Thu, 28 Jul 2022 18:53:47 +0300 Message-ID: <1659023630-32006-7-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1659023630-32006-1-git-send-email-moshe@nvidia.com> References: <1659023630-32006-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b63de526-45a2-4326-43ff-08da70b17f76 X-MS-TrafficTypeDiagnostic: BN8PR12MB3362:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iOxwKR+fQrk7QNg9Sv0CG8oyLJxLzQbrzo8MGvWW40E5H0XbVLufhpQG7WJwtFxpvoZRflxiamhQocIwduOYryaO2yJoKktvGRIXsdFyd2IA/DOdZXwVstKmsARZlvc37xeqHHVLfnxzdq7NcZWIUCiz5zRKWxF4vKBWkxWUh49x+KGg+mzVSzHYza33xoG4DClIr42tjOzpyMjPhlXN6PULGtNz/lDp06t/fYcv1S7Xw/JifpGqd1+625gI1EPY81kUQ9NB/0+l4EdeWBdWrnnTJBJw2Ctkhl1SfaR6dpA3NMwZ/lAa4mq38IV7DSZuOZgr6GaqZgqzOpOoYAX6sJ8ww8yoWrZWbdbgwHVfKzwscVfzA7XE0GYskenJ96gXHpbykBf6GGkz2Iej1xqK7+g4ZXOUsAXuYURNRYEXlgkni9RH9ZgcghNvYertJnpIosVy2nDAbDstPNQf75eGAvBL4jfmIkV9v48McNDIlMNlGH9F2eFA1QrckCJJ+oMuB2Rw48mdHNvxVo/5zg3b1w9XHnWzZLFc3UFaZsb4vnAl0k530aVpZIAxu5vI/ALa3D+ZmnUV3WscUPF7Ez5dyqm7Vtzh42uadyerL7YjQ2QScQiPvyN8PjE+NUsDpFhOPaWI1YGWz6VDXbSkL+ZOd43g9/B8a8cj7aHiMmMyV+dX5x3997L0ZCKhdGJkhfCpG/dqnrfiLu8JnxfvjsHsYcH4MEQ6iV3k3YGDty3JioF+m0bH40CEKwENI/5j22j3C9S7kwtm2oyZqROzHRtRtSlOAqdJCSI8/2Qhye+QrdnwjTuTMMybadbqL1Us5RzhwNFE3KjjvhNwkhoYUIu5wQ== 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)(346002)(39860400002)(396003)(136003)(376002)(46966006)(40470700004)(36840700001)(47076005)(107886003)(426003)(7696005)(186003)(41300700001)(6666004)(2906002)(336012)(26005)(2616005)(86362001)(82310400005)(40460700003)(81166007)(356005)(82740400003)(83380400001)(40480700001)(8936002)(110136005)(4326008)(316002)(54906003)(478600001)(5660300002)(70586007)(8676002)(70206006)(36756003)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 15:54:47.4607 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b63de526-45a2-4326-43ff-08da70b17f76 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: DM6NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3362 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 Thu Jul 28 15:53:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12931514 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 AC89FC19F2B for ; Thu, 28 Jul 2022 15:55:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231671AbiG1PzF (ORCPT ); Thu, 28 Jul 2022 11:55:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231759AbiG1Pys (ORCPT ); Thu, 28 Jul 2022 11:54:48 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2044.outbound.protection.outlook.com [40.107.244.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2686B6D2C9 for ; Thu, 28 Jul 2022 08:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EkHGKvTWMBRriZAx9b7cGGvtbeFcp0wckiGPB9SKe/d+0FpX7KmGoQ8Bh9VtxNiLPIqkE+fbJiZq3ON5TKAnULxpEZvUKiws9B59hACKFEuQ0CkHZj2C8n7k15BqIDNZ793hlfDKoVAfvwYNqIgd5LeYNmC9HIVdUkUuBghsc+WTkxuzpj/c/iGiFnPsO12b8ZWnsFzAZ21FnVKzEI5jUPk7BsRPlVE/s/62/rtaNL5TdfzTfgZJQIhhjylDHo8XS+fUJA61Pk0TEvQzMIcWbHzh7PcLNMXMKVl9ZOMAYLAkNzEuf9LF96m0kQ1HNhNGWqTdf9tuVuA2wWeAtzsXNQ== 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=GgL5RaKKPYD44qKcV+6VsVRH1GtfYYFkEZ0cWgov1i1DugnJxtv+klw5+wg0THQ3SyO3EcEY5/RV9BJvAJBjcLBfmzRb14OJWMiaiND6b/oQIaOm1GRTC30n2zIbnlyXq5ABFT8EjsKjnx3TG/BcF4nUJyXlxAdxwxsy2e/MvFNAXyLUAJ9gNwol7wCoSbocYxYjUlNYFSYQiGFVmAkIPXE2UKpwaV7aueo23QEgGl2v4dykhUWh1rR/CfKprbxqTS03NrD1YUlotjSfNGzV1+lneGwFEl4mwfOLKVyQIlP5SF9uw6/iWd5UEcaTbJPkypxNAMeWW7JgO+Dlu+GZHQ== 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=h0cZGKYG9E8NpSw2GnfDJ+ak5jSuh9+0zYJ6WQGZBwU=; b=DrV23S279Pz0nPr2K/g3XgTQpsmRUelxGPQG139j9NFz9ajrF/ewyIA2LRPWiMOZujvHUf3n7nqebu+xZtJ4S7AM7UxndsL1b9P4fQiVDiNVnvjEF6poJlzBt7QgL6a1NP90QD97BVhAg6pHDPZ+8MM5VqSJl+CjB4RI7bTnbBVO6GGboNsFjrkGB7cVJ+vnYjIc9s0T+R/5Z5MPp3vYZWpQ9udrflL3C39ZsjbCnp8EMvyHf+8YQj6FU+n1PVlzeP7PZKEz2VNwjdi7HvG8yOdubjHMRQLCzBb/v/M6O+Nxh/I1nLv+QD1AnuET/CNc2wVGgLWSbwXHHWAsl81lLQ== Received: from BN9PR03CA0180.namprd03.prod.outlook.com (2603:10b6:408:f4::35) by BYAPR12MB3223.namprd12.prod.outlook.com (2603:10b6:a03:138::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Thu, 28 Jul 2022 15:54:43 +0000 Received: from BN8NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f4:cafe::83) by BN9PR03CA0180.outlook.office365.com (2603:10b6:408:f4::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19 via Frontend Transport; Thu, 28 Jul 2022 15:54:42 +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 BN8NAM11FT019.mail.protection.outlook.com (10.13.176.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 15:54:42 +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; Thu, 28 Jul 2022 15:54:41 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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; Thu, 28 Jul 2022 08:54:41 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Thu, 28 Jul 2022 08:54:38 -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 v2 7/9] net/mlx4: Lock mlx4 devlink reload callback Date: Thu, 28 Jul 2022 18:53:48 +0300 Message-ID: <1659023630-32006-8-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1659023630-32006-1-git-send-email-moshe@nvidia.com> References: <1659023630-32006-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c19cf84-35e9-497a-2b68-08da70b17c7f X-MS-TrafficTypeDiagnostic: BYAPR12MB3223:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8uBAaSUAtdSwqLjJXqmY9KDBKuqj52MOgh3BLrZj92jaxS/gHLJJfImo5+TheUrlGZLHDGtbxnTCUp++Ztik2UoXgXbV02kWgbEEKe4tM5icpR7ls4d0e6lOrqz6RpHh3i9MOIzGGvfU1QZHImKfLc4/bf1hxxgKpfT5ERw3PK3iUW0eXuH9+3mTW39dKPucdMjZnY4gkDb/q3/RiwEeZhigDeZLxPdDMJUmfOK8tpCk9lkK3HQVXEFTm3GbzZC1kL0+zJQGE+IrOSiEBOdwcXP8e097UN22lbgoaLzExSNUDikVvMs9ytjnzqMvPCGzBYZw73Uc6pNOXp+yTfAiK1KoMVvmWA3Zx+MT27hj94cW9ohBvIEIfCI4Khoq4BfaA6WHIHpIDaP4R7xxMYmrgRVzFdj5kKy2ti6oFmjCXt75aO3mGJLdWNlXcSBwC3iM/QKOhPy2WPyzviXwGOQdQ3liTl+kAEN5qfT1fXPox7IPVCCJYOxrh/kt6UOA9FOXUjLO+h8anLLoCrLUI0ZOn8U2YIW9PX74tEg+PqFk4LavjTfF3wEjQDLFvOHn3pI7KiLEk6MQwAA5KW/APVgSlOUFYr4Z5XAF+SOCG15zL2LzDU3otYqd57kRdPGfskfXQk9rOSXcL/Gn0Ws0Ck/hblhxtRnwSWe3etDxEvFTMjRxLHyhvctn+MgyTQKXrb92GyNWaus2Xp2rlld3zfIG8ZsHL3j3zJpD/0OzsbSRWH27bfY7JsPYdR5h/LS3Gb8z2K24y/aDjEAyVcWGu2ZHSegy4JDBM3Ol5dfvP7XSy/CGqbZdiyXFtLHfeO0Se1E/gduxFNNz3cHU34I+638lAA== 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)(136003)(396003)(376002)(39860400002)(36840700001)(46966006)(40470700004)(86362001)(54906003)(4326008)(110136005)(8676002)(478600001)(316002)(81166007)(70586007)(356005)(40460700003)(70206006)(82310400005)(5660300002)(40480700001)(82740400003)(8936002)(186003)(36860700001)(2616005)(36756003)(107886003)(83380400001)(426003)(47076005)(336012)(26005)(41300700001)(2906002)(7696005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 15:54:42.4077 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c19cf84-35e9-497a-2b68-08da70b17c7f 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: BN8NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3223 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 Thu Jul 28 15:53:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12931515 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 7166AC19F29 for ; Thu, 28 Jul 2022 15:56:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbiG1Pzn (ORCPT ); Thu, 28 Jul 2022 11:55:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbiG1Pyv (ORCPT ); Thu, 28 Jul 2022 11:54:51 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2061.outbound.protection.outlook.com [40.107.95.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28B836D555 for ; Thu, 28 Jul 2022 08:54:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q2N5zwFFWYdYMU/Dr13AfUleOqr6psDmrH8OAQG1Xl2/9kuO5C7utYbm8d4/FKAmv4GC3K2rD019LVEV6NfFP9KuwO+jQoKWlVhn3gMJM5bFwA//oRwFIricu1X+T3/wlzO7nIUHaz4vStS8htMhdnQ7/78SQAC06rJr1lygG7ELt6y76JOLyKPoZNDKqp8D6eOnl4FzsXvHWnWCCiN4fXXCY2em4dRu6o880hOiLGGhan24d56m97y7HXPGBAm+kj/IIQv/ITnzewnDw9A9Kx/wr+uHJpezLuUXi386oNet+bXwAFNS0s3EPSCf4t0URwQxtfQj01UsIZuV7O/Jow== 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=nnuTTtQTAr9bHO9Cq/QAV1deSUUn/5f9tdr+cE/ZFl6zevPnApJggKxxC48bX3HukY7Wnttk3uVrlf+0Cvt00wRoWbdEyJF8+0/0vNdMvjs1yAgMOiJUhUYpykj0pNgQZYL5xzBJ8kgM1l43TmMg0ZnDvtZgOijSTzPNA3evZo+vQA2HumkElNFa0XbvrI+iRNePfBH7qSgKW6CZI0ZeIOFo2ynf5K2lEfzX1ufOjMJawRcIJKxkF2Wotu6dtG5MW0O8+syajOYifCntTfZaGWSnB5wi0NpuJRF9gljCymnaWefkcwGDn+q2s6SrhFZie8cywnoA2LWcN8MbUxrf3g== 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=Q2Fg9ApzlPb6NQIcO8UlrUSTRen+FF/rDDY8csfuJle8n1Y7QA7sQDDY5AcC5tExUUEo/i4ji6Ngq6C5OH411QDzwvKS5B5O2+VSaFg0XPCeM8aN00aoRmQMA2LpUrAGOPD7g5qRzzNlRcDQ4/giH1LG2S2ijTckU0DGOgNtq3Mwd4UznBl45Yvd5XlQ/u8KzjEPz8ZIj9abxnpsWAo3vfU2gkLymUWDmdVYsvwN94ADlgi8v8udtpxn3Rq+IY4rzhMtiisX+AdYPv4UzaZ4GGACwFOcDa2N4zXqMZWf1MbILqJGY38SpTpETx3jXjXZAsPOIlZ8JL/bUqBq8fDltA== Received: from BN9PR03CA0161.namprd03.prod.outlook.com (2603:10b6:408:f4::16) by DM6PR12MB4451.namprd12.prod.outlook.com (2603:10b6:5:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Thu, 28 Jul 2022 15:54:46 +0000 Received: from BN8NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f4:cafe::aa) by BN9PR03CA0161.outlook.office365.com (2603:10b6:408:f4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.23 via Frontend Transport; Thu, 28 Jul 2022 15:54:45 +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 BN8NAM11FT042.mail.protection.outlook.com (10.13.177.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 15:54:45 +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; Thu, 28 Jul 2022 15:54:44 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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; Thu, 28 Jul 2022 08:54:44 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Thu, 28 Jul 2022 08:54:41 -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 v2 8/9] net/mlx5: Lock mlx5 devlink health recovery callback Date: Thu, 28 Jul 2022 18:53:49 +0300 Message-ID: <1659023630-32006-9-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1659023630-32006-1-git-send-email-moshe@nvidia.com> References: <1659023630-32006-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3057ba9-b921-4fb2-48bb-08da70b17e4c X-MS-TrafficTypeDiagnostic: DM6PR12MB4451:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nkPeB0APtRbwFGrFhrZyH9s1NzOioJ+GxJKPVV86AT1aGX/NhtDWSVE6M9sd65o9JlWEpxY6D+tI7tMhLd3ShdY925FHDBC5NVSVCZSGCAniAlKsUWYyGrSVIgPP5dEWSFlFp7uA+B/f+MFXKnpFioFXUuD+UrmIRd8E//R6c6REh4Kxn4WhADIe3WD/IAfMrjcIXmvJilBIDywiOEuYpjbMeqKT3zLF+kwWPogbNXrdBalqLmlPF3ecyiovPcR4SRGi6DIRkjgGag9sGFqdAsYtohBIra6v0BjHN5dGeuSdU/8isr2/WGYRh8AtYUk9EsQh7kX/SqHT6kg09cfD/DtuQCG1UnUV/6hrUYKLRgW8rFxTl9M3/etnGmUvxQDvwK3xu6IcPWTIEj6T46BDUEJLKk9UZTZRZ43FED9ma9uCt70GsxZ2yy6a8qyYfOUApxFay3TCzGB7zuM0TVPKHxNsTuIuR2Hmuq2OpWOaMzYN97VhqECnXb6NOzpt/2csg0fCl3FMr8R3Epfc/dHyOLBDzSEKorID/oo2x7hAVQ+9fyg1Eqjr8d3lCnEdUoNHdLCa5ESvPy34AUizvYP421aPobSQnNyow7rce4iGppbOI3+JlKK0oA7jfAgC2fZhdywE4Q7cnknwh40+YdN5XRI1HA5FpsQ8SgEmM+xFKRf8XcEeeNrnzvtsLvtODuy2gVrxeFnOOzcBElf57XUQPvnmudszNTSmnx+us0AjBBdCU0LspFEmWLjR6wnC9AKn4EzBg4EHZMexp+Z0efi69WThUwOKf6XDcRgwFfcwszGUuabs6yTAuIK6duwhNMC+TsLX7L0QazEOM9OSqrYLRg== 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)(39860400002)(396003)(346002)(376002)(136003)(46966006)(36840700001)(40470700004)(40480700001)(186003)(26005)(478600001)(107886003)(82310400005)(2616005)(7696005)(336012)(86362001)(40460700003)(81166007)(82740400003)(83380400001)(41300700001)(356005)(426003)(5660300002)(70206006)(70586007)(8676002)(4326008)(8936002)(316002)(36756003)(36860700001)(110136005)(47076005)(2906002)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 15:54:45.4922 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3057ba9-b921-4fb2-48bb-08da70b17e4c 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: BN8NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4451 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 Thu Jul 28 15:53:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moshe Shemesh X-Patchwork-Id: 12931517 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 A43E6C19F2B for ; Thu, 28 Jul 2022 15:56:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231751AbiG1Pzr (ORCPT ); Thu, 28 Jul 2022 11:55:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232731AbiG1PzG (ORCPT ); Thu, 28 Jul 2022 11:55:06 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2070.outbound.protection.outlook.com [40.107.100.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1E5E6C105 for ; Thu, 28 Jul 2022 08:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S8uG48YaRaxXwWHon8nrPWTpY9I6ILUA53H28C/93GznxZ5VFaBMX3GFwTrDsM195dw5wxAJTELtAZSOxX9YvXLS0zHyQmBKSMzKN1gvNzfTqDetdCN3R2LSJUt3mhgn6KZhCZvayetEZ69Rf2lpeYji6EIamJWs/+gPv/OxYZ+6TSD5n0KUW7J8KSqrh18EBueLNOFUpY8xakxZ8nQhho8KF/+pXBuYXTvTu8M2k0+pRfWrxo5gC5rbW/keVdzF3Xl3EmkV0CzLJf4x1twABqe+rrYnRs+4LyBFVCh/1NQeZRiZlFU1Aa9ewCqde8Q9QAYr44ShDFCv2phoTnvK6w== 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=3JhtGYuoGv2zg3iA6zsYuH3rk7l0VxjXZlOr891Z6V0=; b=ocFQGvNhXJJYhQQ1xURvIBqZqdrJ2F5PbAQbWWZA7jdEJAfcw3fDnTI0DYzRqhzk9QlQFlfmLcJgM0livGZMiUUaKs1u2ZT8ZqXng7ENB5uNRSJYgG/S3bvFJJ7KG8eMk9MFpx1gJVkarsRavqhWn2106x5SGKCCZLWXAhgYD/8xo4BwJFR4qZUsvKvtayBBETmiSwgHguS2nseCO0zw5bHaD6i2K4+kcOLgUEh3+O3TaiU/NPPsgY6t+LfIgZTNTGk/Eh9bFgp3r0bh0NXWnB4twGLTDTNEbMwoDbFPLX2j77JrclGNfpGhLdYRfSTdesE2GN+ZqJI7YZNEjYStoQ== 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=3JhtGYuoGv2zg3iA6zsYuH3rk7l0VxjXZlOr891Z6V0=; b=PEVjIkci9JQRmbhlqcuky/lEuDzLOUXgF35LeYRrVIFNzSA/PKkNZGiqqkadCngv2VEO3dvxaZAzcLGfNNyYXcQ2VdeCDejnpIhP94NoFxnIcVz8UJtS/mxkdJZiKDLieBYPSLv6R9JA0o2BoJLGUzGrPA2ws11Dunqdo/MBruLGkqbkMjcnH46EBk4Hxa3ndfPj12/soL5P9VvA++22LvsxLDyCx71sl2wq7HdsXdongyvogKdWY5/eXwH6kDbobrDrAO+gF+bRpcoygJ4cqwziLqbvoGblZFzMPpSDtU1PAqQ49v7QjnlnP8apNigSEvseKaXVPyr13iS9yoKprg== Received: from DS7PR03CA0051.namprd03.prod.outlook.com (2603:10b6:5:3b5::26) by DM5PR12MB1324.namprd12.prod.outlook.com (2603:10b6:3:76::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Thu, 28 Jul 2022 15:55:03 +0000 Received: from DM6NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b5:cafe::c3) by DS7PR03CA0051.outlook.office365.com (2603:10b6:5:3b5::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.24 via Frontend Transport; Thu, 28 Jul 2022 15:55:03 +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 DM6NAM11FT020.mail.protection.outlook.com (10.13.172.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 15:55:02 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Thu, 28 Jul 2022 15:54:47 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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; Thu, 28 Jul 2022 08:54:47 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Thu, 28 Jul 2022 08:54:44 -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 v2 9/9] devlink: Hold the instance lock in health callbacks Date: Thu, 28 Jul 2022 18:53:50 +0300 Message-ID: <1659023630-32006-10-git-send-email-moshe@nvidia.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1659023630-32006-1-git-send-email-moshe@nvidia.com> References: <1659023630-32006-1-git-send-email-moshe@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b46f6d6-703e-472e-100e-08da70b18833 X-MS-TrafficTypeDiagnostic: DM5PR12MB1324:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wMZerd5d+2Sz08pZKto/4XJGk3AaTj4NNWCUSi1ameOVs/5pnGgGZWSPzoS7fZU5ZrzvaNG+qLR6gN/SHOLOYkc0NUytpSxpe9G5Tnes8iZ+DlaVtkLx1P26Q9tf5xsBdIl/dzcH+jly0TEyw/KlJ5rk2MYIiR5+iW1YALDruTkDITNKgnpp2aTFNMuN2hzOdVbRkXn6OF3V57OmQoZpj7fibYa43QvcKb8s29g43oqI92ThKVR7bxV2vy/0ZpS6UKdjkTKulBEjCrMkfMFg4n6GIGrSJJXX5PLR6ae7S/OfNLDZWHfWnYLaXgWBLU89a9s64AdvHukvUAaZ+Ad16oQ4s2trVKPniWny7esO42ceigQ1akauTIfmbGFcXxUw0lLHLNt01KdNUqAFY/Ag7LFAUK4/YIokQy24YJFSXnFECj/SDClVD3IVGRS0pj+/HYb0jDCWCu9F08saWRZjQN3Gkyr+k3LA4JrO1CV9GUWJ2etr6cO2CylOJZGqmTLtzuConesaHX8m4rvun8YR1/ehezlvHOBIOLhrXNX780an2uF2TejO258iO0SRE15hZtZQiRS4Bj8kL6tGrCma2sOoNB5ueH72YtZWejSwfb/VQ0bOqMDm6V+Pqq8GQOldKPi4pevCyVQgSXpmVDsGjORtzSu4w0xDGhy+rhP3XBB+rEi9XZvrMSD9gq3q78TY1FhCpJQRpYi+oBpoQ4iGSVVLkkSg70RIEgROUmmZhuAAL+OD7iafXheM0rqymeNMC9uMy2BzQUHJEOAmE+VdWoFRh+mrmkkFcGCwLtdmboGdexO3ICHuwd6B1RXkVIogdbPgWkaDziHFOox7fQq2zA== 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)(346002)(396003)(39860400002)(136003)(376002)(36840700001)(46966006)(40470700004)(316002)(40480700001)(36860700001)(5660300002)(82740400003)(82310400005)(70206006)(70586007)(4326008)(356005)(36756003)(81166007)(2906002)(336012)(6666004)(8676002)(186003)(54906003)(26005)(426003)(86362001)(40460700003)(110136005)(47076005)(107886003)(8936002)(2616005)(41300700001)(7696005)(83380400001)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 15:55:02.0416 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b46f6d6-703e-472e-100e-08da70b18833 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: DM6NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1324 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 --- v1->v2: - added lock while calling devlink_health_reporter_recover() from devlink core (bug found by test) --- .../net/ethernet/mellanox/mlx5/core/health.c | 8 +---- net/core/devlink.c | 30 +++++++++---------- 2 files changed, 15 insertions(+), 23 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 274dafd8a594..ee9cbc4f755e 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -7553,6 +7553,7 @@ int devlink_health_report(struct devlink_health_reporter *reporter, enum devlink_health_reporter_state prev_health_state; struct devlink *devlink = reporter->devlink; unsigned long recover_ts_threshold; + int ret; /* write a log message of the current error */ WARN_ON(!msg); @@ -7586,11 +7587,14 @@ int devlink_health_report(struct devlink_health_reporter *reporter, mutex_unlock(&reporter->dump_lock); } - if (reporter->auto_recover) - return devlink_health_reporter_recover(reporter, - priv_ctx, NULL); + if (!reporter->auto_recover) + return 0; - return 0; + devl_lock(devlink); + ret = devlink_health_reporter_recover(reporter, priv_ctx, NULL); + devl_unlock(devlink); + + return ret; } EXPORT_SYMBOL_GPL(devlink_health_report); @@ -9264,8 +9268,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 */ }, { @@ -9273,24 +9276,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, @@ -9304,16 +9304,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,