From patchwork Wed Sep 20 17:26:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asmaa Mnebhi X-Patchwork-Id: 13393092 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 872CB1A58C for ; Wed, 20 Sep 2023 17:26:35 +0000 (UTC) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2063.outbound.protection.outlook.com [40.107.102.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CB9AA3 for ; Wed, 20 Sep 2023 10:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C71ldU8gwAAEbvvx2UtA77SBrgGPjItk0OhhrbgrJLPCTLybSIzkBWwhNTZdMS1q85CSjeUqwDxnCr1DT5e/PDaIGkEX9xNd4tsi+LxnHFJfvn++by8d9uCEGo6s+Cnxk7dYFzanmlXN0Af6WVd2TtZnfAWKDxRWy3wcWfeiiN9GhjXx8aBNaXaXQ1Ge9fBIx4vG67oPJp7OdYQ8mUk1cM/1VOQvAj/BToZ0Kn3V5pvCqE0eNZ8egiyasbRSCxRUjEygFDD/L9DZqt+qeujACXT4RKy6zoNGgEsHvFz9rXJVGFK0Nx12ICnVrUU4Ct8TF0zZetE0J4McR67Z4mSkMQ== 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=S8v0HFaArkSMvr8SYavrrK+r7cEQXyYKL/7DqEW8oVk=; b=Fb9qktVl/RosRtnccVN7luBjlh0QfmwohotfmXGY07PmFLBAB4LHbz2JDKSzkR4HxhZwtFgjvytdXpef9tM2LAsCvlZKOmGFM7tdR4MN350c4XLicj8CoXerrEh5ZkF8uoKOWuEAgWYevPgO5gwe9LjBTYOJ6xTvFbX4KO4iRSDj04D1rXT2Ec7dc1yCcBQP99tCa3ZU7X2srmmKc/D3qDmXcqzzRspHhUJe6apuYzVKFEj56m8Z+lZvf/MPNoZGiLEH12CLVvLczB1Bimrpku4ctVwHTwh1kfGb5hAxItNbcAf/YZVKlYCsf1egAnRvf0Qm8aDwiCH7e2bwCrqQCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=S8v0HFaArkSMvr8SYavrrK+r7cEQXyYKL/7DqEW8oVk=; b=l9MqKOFLV2jsCQfQsElYJOCsnYtgTgKK4yfTDRySbDApzLz6xmAjGUyfpjImN+rfPznOzKh4ByMifT96SaYwDK+H/gxDGqCCq4EqP+1TVLZvjpP7aqShxmTnYWmfHeTK/uPu0PnVTj//IO7RdwFxt+SWeb9aizo/61vCNGcPIuPlamH2Mlh0kh7I+WOovGhMjJMOT3MP34ZDZ74x2eWk//fhMScQFTFtsbHlWSlOfIZlqEzoMNpf892xgi8AYZge1+dVvQO0tD/qK8kCklbXabGrVf3FuSjcb9/rIRtGnWWNdH3PP4bGqFRNK/FU0CHX7EdpEET/8LIbng14r2N25w== Received: from MN2PR14CA0003.namprd14.prod.outlook.com (2603:10b6:208:23e::8) by MN6PR12MB8590.namprd12.prod.outlook.com (2603:10b6:208:47c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 20 Sep 2023 17:26:31 +0000 Received: from BL6PEPF0001AB59.namprd02.prod.outlook.com (2603:10b6:208:23e:cafe::81) by MN2PR14CA0003.outlook.office365.com (2603:10b6:208:23e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.30 via Frontend Transport; Wed, 20 Sep 2023 17:26:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL6PEPF0001AB59.mail.protection.outlook.com (10.167.241.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Wed, 20 Sep 2023 17:26:31 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 20 Sep 2023 10:26:16 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 20 Sep 2023 10:26:15 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Wed, 20 Sep 2023 10:26:14 -0700 From: Asmaa Mnebhi To: , , , , CC: Asmaa Mnebhi , , Subject: [PATCH v2 1/3] mlxbf_gige: Fix kernel panic at shutdown Date: Wed, 20 Sep 2023 13:26:07 -0400 Message-ID: <20230920172609.11929-2-asmaa@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230920172609.11929-1-asmaa@nvidia.com> References: <20230920172609.11929-1-asmaa@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB59:EE_|MN6PR12MB8590:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c893b2e-c193-4335-7e73-08dbb9febb0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BnpNbPrtCgpjBY3bt1OAz3/1qJtolxkAIbZGyJtC5EB8PfvkNWooCVP0qsqym1Utdkpv8qrUW0xVvPSxU5+XCQOHaz7m2fd+NbuMDT5lK6Ac5iIqNTdKoIZSO2WD49JMPKSBZrjr7aMnmQdlENo8WrWEedEHhcMobbvhm5UPiHqX6baoKPvuzbbZ75efrQ0FzibITT32Yyqo9cORmDDNlhR7+xMbWASiphFuX9XlUBd+X0ytV3Q5EciEcnyG8X9oXmFpeynjS1n+rm7t9mpVPETPc3fck96Sq/N5ycjgGgLs4bK47qpLQ9qQrLo4icyixFkilgbPiUKPlQYmENMaEHK+yQHLLvn9zWKIM5pritjEDHSOXoup7q3JNeV5rJ7Qf/X7uK2sBwK+nQ6/jSfMa1IQnBF6mhIzUEkO2XZi0ZqHdxNLcWrx89qnb5sd5zxTXYhbd1vtRoKBDR3GK9va7+P6gZ99R4ugA5DXKtqOxWr1aGb/Aphe9N/IxKV1ZSFkpYvSbK1HcI6IYRi8yt2Cbltpgu1d/lKz2eVLj5MGYsOj2iDVBh+CGDIGyb5QpY/+FlygYeaVNA6mWVtY/v+mYnemDPBUAGLGwoSGxPiBGpHW4AbFfRY51QSQdeOrMStF522uqOc/u7yx2hAVGFNH4lHiJzzoG06epUXW4+uQe4dLjEU6NhX3/D082jdMyCiQ9V8EdS2+BGzFKjUvx1zE/wzb4LVc/rLR2vQlMjYWaYvHOaWoPdzO+YjKhaLZg1qU X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(136003)(39860400002)(396003)(346002)(186009)(451199024)(1800799009)(82310400011)(36840700001)(40470700004)(46966006)(316002)(70586007)(70206006)(110136005)(54906003)(40480700001)(478600001)(6666004)(40460700003)(2906002)(36756003)(86362001)(41300700001)(5660300002)(4326008)(8936002)(336012)(426003)(26005)(83380400001)(2616005)(107886003)(8676002)(1076003)(36860700001)(47076005)(356005)(82740400003)(7636003)(7696005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2023 17:26:31.2237 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c893b2e-c193-4335-7e73-08dbb9febb0d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB59.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8590 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org There is a race condition happening during shutdown due to pending napi transactions. Since mlxbf_gige_poll is still running, it tries to access a NULL pointer and as a result causes a kernel panic: [ 284.074822] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000070 ... [ 284.322326] Call trace: [ 284.324757] mlxbf_gige_handle_tx_complete+0xc8/0x170 [mlxbf_gige] [ 284.330924] mlxbf_gige_poll+0x54/0x160 [mlxbf_gige] [ 284.335876] __napi_poll+0x40/0x1c8 [ 284.339353] net_rx_action+0x314/0x3a0 [ 284.343086] __do_softirq+0x128/0x334 [ 284.346734] run_ksoftirqd+0x54/0x6c [ 284.350294] smpboot_thread_fn+0x14c/0x190 [ 284.354375] kthread+0x10c/0x110 [ 284.357588] ret_from_fork+0x10/0x20 [ 284.361150] Code: 8b070000 f9000ea0 f95056c0 f86178a1 (b9407002) [ 284.367227] ---[ end trace a18340bbb9ea2fa7 ]--- To fix this, invoke mlxbf_gige_remove to disable and dequeue napi during shutdown, and also return in the case where "priv" is NULL in the poll function. Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver") Signed-off-by: Asmaa Mnebhi Reviewed-by: David Thompson --- v1-v2: - make mlxbf_gige_shutdown() the same as the mlxbf_gige_remove() .../mellanox/mlxbf_gige/mlxbf_gige_main.c | 19 +++++++------------ .../mellanox/mlxbf_gige/mlxbf_gige_rx.c | 3 +++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c index 694de9513b9f..98f75c97b500 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c @@ -471,24 +471,19 @@ static int mlxbf_gige_probe(struct platform_device *pdev) return err; } -static int mlxbf_gige_remove(struct platform_device *pdev) +static void mlxbf_gige_remove(struct platform_device *pdev) { struct mlxbf_gige *priv = platform_get_drvdata(pdev); + if (!priv) + return; + unregister_netdev(priv->netdev); phy_disconnect(priv->netdev->phydev); mlxbf_gige_mdio_remove(priv); - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static void mlxbf_gige_shutdown(struct platform_device *pdev) -{ - struct mlxbf_gige *priv = platform_get_drvdata(pdev); - writeq(0, priv->base + MLXBF_GIGE_INT_EN); mlxbf_gige_clean_port(priv); + platform_set_drvdata(pdev, NULL); } static const struct acpi_device_id __maybe_unused mlxbf_gige_acpi_match[] = { @@ -499,8 +494,8 @@ MODULE_DEVICE_TABLE(acpi, mlxbf_gige_acpi_match); static struct platform_driver mlxbf_gige_driver = { .probe = mlxbf_gige_probe, - .remove = mlxbf_gige_remove, - .shutdown = mlxbf_gige_shutdown, + .remove_new = mlxbf_gige_remove, + .shutdown = mlxbf_gige_remove, .driver = { .name = KBUILD_MODNAME, .acpi_match_table = ACPI_PTR(mlxbf_gige_acpi_match), diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c index 0d5a41a2ae01..cfb8fb957f0c 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c @@ -298,6 +298,9 @@ int mlxbf_gige_poll(struct napi_struct *napi, int budget) priv = container_of(napi, struct mlxbf_gige, napi); + if (!priv) + return 0; + mlxbf_gige_handle_tx_complete(priv); do { From patchwork Wed Sep 20 17:26:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asmaa Mnebhi X-Patchwork-Id: 13393094 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5346D1A5B8 for ; Wed, 20 Sep 2023 17:26:38 +0000 (UTC) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2079.outbound.protection.outlook.com [40.107.212.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3BE2AF for ; Wed, 20 Sep 2023 10:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AYFFiYOFUNMGR4MNxkWa8pSiIzffCYPfRYioOwkgWcFd0x1sJAxlcaWE3N2v07UP8UvsBsQH9VUJk7I+ICsc9vijMvxrvgZmu6jYMHNRn0r9pQ3rSsXl3aycOBoxIc/MwNEIMdpR9G7IRHSZpUMLB6dGwU/yu0njLWV9f/dTXJI6RnL/MkNfrKAyi3Dyj1aLysC1Evq/ZlTFtmRZ3t3YyDHTEeamdmcnkFuV7EzHYkhfJSad1Tgp1jqMtyqGYOgHkS6yFPEFveKuVpynRaWrikxKQJxAleuo4Qw9Ib2ck7JEBcboNMNiLMb1WKCTMb1qVbgwukDJr9Ax/grfFiGFgA== 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=nvYXsnBL/A1RLPfHA/vlmWyl0KzHnCBV9FTCPOcxT8I=; b=C9yLQlnZ2DyyhgUq7jQUbXCukFx285LKyP2PigwkVkfFLWDWCY/38tayTJ8+Tstcq3ARNYzZo57r4mr3ECsm5bMivO/9ldxhVYSx91LSKabVV+awc1ZyYvIUTSRUY6TyUC+wRD4wrFvyiEQhM6rWyfCQEYsKo1UTGYVugX/nCGoxYcbRaAgCIWs8PO4gBTD4kIDqMOcfOjvAvwUTi79D6kwPAG/iSnxBtmud/YyAZdVRoF1KpNVab94FuYEqYmL7MInuhdT2nOj8gMElXH1Ig0cwnYfTRkuSWQemHvB2zN///lLp4XtDAQnczlEeCYxxn7vulQUKNt9EHFn866hYNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=nvYXsnBL/A1RLPfHA/vlmWyl0KzHnCBV9FTCPOcxT8I=; b=KOsJwaLU4KfaNFTCEEB3ylgtnVk59/WVSf2E67zv29ypJUeDgWNgx5n9bohQrekaxy8cpxI9slfQ9Pq6YgWDwUatNto2CMXomrZ9c3uT3a2RhfVyDGOIuAf0rnIpCbsnKyCyCnIpkB0SugflLBV85f/458zURQYU2rvHCCJYdDmsJ4lIcO3/C14UlVd8MwD87JHUsUyMr2RgVQjbiQbzzyDJV/nDBTJdrz08r14KYwRunqTQmTlxRoZ5SFuC6zE5QWljUtzhZRKLjrScsv2NzSgLtGMY854ksmQzXvTlzTzOuq8bDW0AkJU48K6tTstDMMhUlbw/DMkenU+yGYB71Q== Received: from BL1P223CA0014.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::19) by MN2PR12MB4437.namprd12.prod.outlook.com (2603:10b6:208:26f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.19; Wed, 20 Sep 2023 17:26:34 +0000 Received: from BL6PEPF0001AB56.namprd02.prod.outlook.com (2603:10b6:208:2c4:cafe::36) by BL1P223CA0014.outlook.office365.com (2603:10b6:208:2c4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.29 via Frontend Transport; Wed, 20 Sep 2023 17:26:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL6PEPF0001AB56.mail.protection.outlook.com (10.167.241.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19 via Frontend Transport; Wed, 20 Sep 2023 17:26:34 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 20 Sep 2023 10:26:18 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 20 Sep 2023 10:26:18 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Wed, 20 Sep 2023 10:26:17 -0700 From: Asmaa Mnebhi To: , , , , CC: Asmaa Mnebhi , , Subject: [PATCH v2 2/3] mlxbf_gige: Fix intermittent no ip issue Date: Wed, 20 Sep 2023 13:26:08 -0400 Message-ID: <20230920172609.11929-3-asmaa@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230920172609.11929-1-asmaa@nvidia.com> References: <20230920172609.11929-1-asmaa@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB56:EE_|MN2PR12MB4437:EE_ X-MS-Office365-Filtering-Correlation-Id: fe07576d-9701-48eb-6381-08dbb9febcca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6X8qMobrmz4+8eEitgx3jwnziztRJFuC9nvEzaunqELExBlmaOk8MAsqjYcNkjCwS37Uec+7y3DdCLvI7vnXNGi6PTehLu2kst/Go7yJBLmP8ED2e/EdGoja9XRklemwkHQ9Wiy4wzVIt7uZgQvkiEDROUSSeB9KZz8Cbi4+1BJzpxdJ0cZbQOO9aCdmTiFkArTLO8pHh+dQjJ0OfBuq5GO4dbJdWDLt5nxPjFHvcsu4gcxWQ9GUKeY9mzEp91zN3MdpVl3pcr4c3IAY+2H0I07af/iGQeTIjTPgJ6eTL12l+nd95xjANi6yRgdKF95EjffMlUb0HK6vhTt508qsFslvzvoI0tIgsOnaw4UjSiKCyNUJIMpxDvvmOhDZJQYN/F1s5tNRRhvhoDj9jzBfYlRbzUlXfsuEKha4aBaKnYt5pslu5uTXVHLyNjJ5LH7Vwp34+Dddj58zTSt9Z9I+XyMzO+6JSiyzcLnJKm2g3rfk4B6a+UePk5yA8aUVyxg7JGh5Z1Kjefcx+gwm9YmeuyylhPktNEqH8hsm7B4QaflxEfpINhcp8rZvqX9hxsaG+whk66GQ5XFd63V9US649y8yH8ltSy0sDEXIR9/l8+3UIZb6gD61BF+TzP46U7KYWVELIsL4xwSfXs9xYpQjnqDaj+TBtZmgLxB0zwtcZG43IrVoVwB3JMxqN9Rljz3GnOdgTDZlaWWzpUkypxTJMOpLAyr2UFeC6PMJkjKq+FOAeaNTkKtHTt5TwH77J1xp X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(396003)(136003)(39860400002)(346002)(376002)(1800799009)(82310400011)(186009)(451199024)(40470700004)(46966006)(36840700001)(7696005)(6666004)(478600001)(83380400001)(8936002)(8676002)(70586007)(70206006)(54906003)(110136005)(316002)(5660300002)(40460700003)(107886003)(2616005)(36860700001)(36756003)(82740400003)(86362001)(40480700001)(4326008)(47076005)(336012)(2906002)(426003)(41300700001)(26005)(1076003)(7636003)(356005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2023 17:26:34.1394 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe07576d-9701-48eb-6381-08dbb9febcca X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB56.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4437 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Although the link is up, there is no ip assigned on a setup with high background traffic. Nothing is transmitted nor received. The RX error count keeps on increasing. After several minutes, the RX error count stagnates and the GigE interface finally gets an ip. The issue is in the mlxbf_gige_rx_init function. As soon as the RX DMA is enabled, the RX CI reaches the max of 128, and it becomes equal to RX PI. RX CI doesn't decrease since the code hasn't ran phy_start yet. The solution is to move the rx init after phy_start. Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver") Signed-off-by: Asmaa Mnebhi Reviewed-by: David Thompson --- v1->v2: - No changes .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 14 +++++++------- .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c index 98f75c97b500..f233c2c7b6c1 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c @@ -147,14 +147,14 @@ static int mlxbf_gige_open(struct net_device *netdev) */ priv->valid_polarity = 0; - err = mlxbf_gige_rx_init(priv); + phy_start(phydev); + + err = mlxbf_gige_tx_init(priv); if (err) goto free_irqs; - err = mlxbf_gige_tx_init(priv); + err = mlxbf_gige_rx_init(priv); if (err) - goto rx_deinit; - - phy_start(phydev); + goto tx_deinit; netif_napi_add(netdev, &priv->napi, mlxbf_gige_poll); napi_enable(&priv->napi); @@ -176,8 +176,8 @@ static int mlxbf_gige_open(struct net_device *netdev) return 0; -rx_deinit: - mlxbf_gige_rx_deinit(priv); +tx_deinit: + mlxbf_gige_tx_deinit(priv); free_irqs: mlxbf_gige_free_irqs(priv); diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c index cfb8fb957f0c..d82feeabb061 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c @@ -142,6 +142,9 @@ int mlxbf_gige_rx_init(struct mlxbf_gige *priv) writeq(MLXBF_GIGE_RX_MAC_FILTER_COUNT_PASS_EN, priv->base + MLXBF_GIGE_RX_MAC_FILTER_COUNT_PASS); + writeq(ilog2(priv->rx_q_entries), + priv->base + MLXBF_GIGE_RX_WQE_SIZE_LOG2); + /* Clear MLXBF_GIGE_INT_MASK 'receive pkt' bit to * indicate readiness to receive interrupts */ @@ -154,9 +157,6 @@ int mlxbf_gige_rx_init(struct mlxbf_gige *priv) data |= MLXBF_GIGE_RX_DMA_EN; writeq(data, priv->base + MLXBF_GIGE_RX_DMA); - writeq(ilog2(priv->rx_q_entries), - priv->base + MLXBF_GIGE_RX_WQE_SIZE_LOG2); - return 0; free_wqe_and_skb: From patchwork Wed Sep 20 17:26:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asmaa Mnebhi X-Patchwork-Id: 13393095 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F4C13E48A for ; Wed, 20 Sep 2023 17:26:40 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2044.outbound.protection.outlook.com [40.107.220.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CEC1B4 for ; Wed, 20 Sep 2023 10:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JjiNj7g7QSvZT5xVuKqtHFiRuUpQtQLCCNqE2XmJFWkbh/35vw2bZBRVzKIXuL4mD18vKq7ktxqGI1F1uMkFHJHmCKehDn563hsQej/3XflC9Kidt810mbSwqd62nl8ooZ4sgpokfTkmw5Ac44hV302Z2XBLg1TxcYjo/fXYNxNzlltqn27/jqywc/LPL675M1NLHn+su2TbUg+4XTQYB6WSr2YbZIsdNrhi1UwklxGxnmCJzsF/uoflFCQospzBLoi8gB2TpN3TI8LYBSpURv3Ee+LPDxCZlY6jv9mhC70vzgAACd7ZB1IGuwBate4Rb8fIpRKcVm1MkC+BoUEzNA== 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=fMbgY9PMS6DY19xauGFRbQGmn4QMn7zZYAbA3kC9f+c=; b=ce6px5SidT4FMN5cwC3BoDjdlD91Z0IvLiW7bTOhGC2pjf8tANerGpbsponbUEfz704IFz+IHdZUZkt4YUS0AVjRG+4STSU/qtde3q0yDDy0Pkn74RGIU0MiY1vIQFQdx6YtxGTjSJ5xhGW60/E0T5ZQmBQUiJjOotUU7TT0zKICKTYDjyTuNDSrEnLuKbGAfwMWxKv7IHBXKCnRuzQhJeiR1W4rNpk3gDGirY7R8s83L6ufHNySgaL2uusoQcLPe5n5xV63gAQsWHpcSGZHE4TFKOqvertfjsWpXhAD8EXEzycpGVhMrzxFzPDrhGJMTy0DHjNqHBe8DicetX13lA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=fMbgY9PMS6DY19xauGFRbQGmn4QMn7zZYAbA3kC9f+c=; b=kVm7Ci42F/NUjoDGehqtpAP59HOOAgI+ckJQi5RAWJ5RTvDEoHZZnZbBLg3g0N2GNcRyPAOd3yGVPN1eKMa+OknO4Hcr7MiVIgvTOgF+EQa8bp8pcmq4b976beFTZboa98Y/zZoLE6sBcfVrzL7K9cIW+Cs5pa6g/OsnHDSVQxuroQJFeZaHLMW0gEanwd2b+ioQQhdZArguVPMkSHxpdUPCj2ANaYOxCD5nnuoZcS83Yb/tJRks3s+aULaAo+sBNt+wHHB8K9v4vZO2MCrMw2GIFsbNpbhXnWRpyFOB0k0J1fbJqHQFoSNdGmJqH4Wls+fkkiKyDltGEvX0KpxF6w== Received: from SN6PR2101CA0017.namprd21.prod.outlook.com (2603:10b6:805:106::27) by LV2PR12MB5870.namprd12.prod.outlook.com (2603:10b6:408:175::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Wed, 20 Sep 2023 17:26:36 +0000 Received: from SA2PEPF000015CB.namprd03.prod.outlook.com (2603:10b6:805:106:cafe::ab) by SN6PR2101CA0017.outlook.office365.com (2603:10b6:805:106::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.4 via Frontend Transport; Wed, 20 Sep 2023 17:26:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF000015CB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Wed, 20 Sep 2023 17:26:36 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 20 Sep 2023 10:26:21 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 20 Sep 2023 10:26:21 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Wed, 20 Sep 2023 10:26:20 -0700 From: Asmaa Mnebhi To: , , , , CC: Asmaa Mnebhi , , Subject: [PATCH v2 3/3] mlxbf_gige: Enable the GigE port in mlxbf_gige_open Date: Wed, 20 Sep 2023 13:26:09 -0400 Message-ID: <20230920172609.11929-4-asmaa@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230920172609.11929-1-asmaa@nvidia.com> References: <20230920172609.11929-1-asmaa@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CB:EE_|LV2PR12MB5870:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a20befb-e612-4256-07f3-08dbb9febde7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wsNY3NjFJkc292A+7zyRQ3f9AKlBSG7mK/rdz3dmxYTynBVe/NfPUhs9c1zOzQFKVDYVPXEpOLOUpj7+IpUFCsx2GTGxj1nwb+XNnhjKpFmT0k/nci6x1Yke1YGTn1eDLPVgqXDQoxZEp5AtRqth+atZXSGaGkenfKSm54qupokLQsHSU385wKZlryS1sVkqn8MuOonA1/yqSXi0Wq4HWrhPn08s48H1hqNrMUkE9jEzdTzxykOzJ6YrSgthb8YR7CR8TtF8Qmw9U+eDoA+bgxGw5uqutKv8RmVqUWW06jWE/Kcc6bRZFK5RLp4YgInP2KXjQPp+iGFHn+QXcIJ3edNpL4XhtTK8hkHYHFyNUwjrOZNuE79+Aw2OwoHfA8Y4k3on7pcz8uosMTW9PfAIaLsS7f6ejMgOu+wJsNxtp1rrM8qGHi5CdVQv3XcHaGpGGfzkA8YtY+ZduPJjmwlOXUELnVO5WfXGgQLo11adlx6ausT/EWMusEkkf+sGs9ukCHsZdWQHPYdTrwlkHI1iJZLeA2ZCwBse+4TF1D2cTnk/lPZzAXiymxHZJaEspRpucqPiJNQVXBawxKB3JVXBBA/3S7I4pZnbazby5JsdR0nDkcNarAsbz3aYNw6XPZz03lLFMcOeDvjrnXDqOyNds007rGNqdLQpG2v3TNlPDAqRjU1DM+VKYuc1ieILgsgv6r6qCNU/LtBJZx3ggEuCo3dTXXnkTVbcLZptW7CwPjQdexS2WeV8A72OFkWB5arg X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(396003)(346002)(39860400002)(376002)(136003)(82310400011)(451199024)(186009)(1800799009)(40470700004)(36840700001)(46966006)(6666004)(7696005)(83380400001)(4326008)(47076005)(2616005)(2906002)(107886003)(336012)(26005)(426003)(316002)(70206006)(54906003)(1076003)(70586007)(478600001)(5660300002)(8936002)(110136005)(41300700001)(8676002)(40460700003)(82740400003)(40480700001)(356005)(36860700001)(36756003)(7636003)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2023 17:26:36.0361 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a20befb-e612-4256-07f3-08dbb9febde7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015CB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5870 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org At the moment, the GigE port is enabled in the mlxbf_gige_probe function. If the mlxbf_gige_open is not executed, this could cause pause frames to increase in the case where there is high backgroud traffic. This results in clogging the port. So move enabling the OOB port to mlxbf_gige_open. Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver") Signed-off-by: Asmaa Mnebhi Reviewed-by: David Thompson --- v1->v2: - Fix typo: "base" to "priv->base" .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c index f233c2c7b6c1..f46d94256e2c 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c @@ -130,9 +130,15 @@ static int mlxbf_gige_open(struct net_device *netdev) { struct mlxbf_gige *priv = netdev_priv(netdev); struct phy_device *phydev = netdev->phydev; + u64 control; u64 int_en; int err; + /* Perform general init of GigE block */ + control = readq(priv->base + MLXBF_GIGE_CONTROL); + control |= MLXBF_GIGE_CONTROL_PORT_EN; + writeq(control, priv->base + MLXBF_GIGE_CONTROL); + err = mlxbf_gige_request_irqs(priv); if (err) return err; @@ -365,7 +371,6 @@ static int mlxbf_gige_probe(struct platform_device *pdev) void __iomem *plu_base; void __iomem *base; int addr, phy_irq; - u64 control; int err; base = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_MAC); @@ -380,11 +385,6 @@ static int mlxbf_gige_probe(struct platform_device *pdev) if (IS_ERR(plu_base)) return PTR_ERR(plu_base); - /* Perform general init of GigE block */ - control = readq(base + MLXBF_GIGE_CONTROL); - control |= MLXBF_GIGE_CONTROL_PORT_EN; - writeq(control, base + MLXBF_GIGE_CONTROL); - netdev = devm_alloc_etherdev(&pdev->dev, sizeof(*priv)); if (!netdev) return -ENOMEM;