From patchwork Fri Sep 22 17:36:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asmaa Mnebhi X-Patchwork-Id: 13396162 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 98B7B436A3 for ; Fri, 22 Sep 2023 17:36:49 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2085.outbound.protection.outlook.com [40.107.243.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05D0A99 for ; Fri, 22 Sep 2023 10:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nvFTbDAhMHK1C5Zvf54DC3LidwZarSxJBS6JZ/Hk37o2zYUaY/PS0pa5Iv1YwmR/ojSOIKeTED2Hg4BW349oyy0STnTh6pSryNJhyIrxfEeTSWUq2bby30CMipeLntd4I02DJ/SBaImXFY4leODt0TTaU0+5OIk99m2jiDfHGgy2k63l580rnON/IT+zpPchtCGtBbyXHkTMrrRN+yJRt58yXlXYHySwfsSkBUjMx8A8B6SmOyOlQxwCcfNP3Qmj284lkgafUWhtihyichDYeGjSqmZJoeINsAC/8sbOnEYTpsKuXmqtkljv+XedY4VxnXbaK/M2oersFcKLPJQPHQ== 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=9DF+Lt4Enup8LYliIx9yQvDj2u5yAJKBo89URmoEK38=; b=QizMYtNBwmlTvV5FNCM1jZPrFo9FpVJ1ggCBFQJ/9B0jyDofmzq7nMB15XbWhCcwdauSKFtTRLDSiKFmcvj2VA0rTdVvTvNJNhhSqLHq8LBCfqwyC9hPQnI6aANnl9jl9+aPOmu3fuInGWkIrjJorJtr30VHLyxjeFwDJWTepuLrq301tMjeMuysbkfym+XD6e8lEQKS+PXj6rGzrGAEYnB9LyE9Sa7My7dEoiS4MPxdK7p4Ib1JM+SQKX2bQ5VO1QFhEfhOO2uXccEHivxkgEOqZNrAWtXaYA5G8YIRLQ2uCyzUn+N5pkzSzS4yeSeAWG95W1Q4/9x7Cp2TTxiQ0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=9DF+Lt4Enup8LYliIx9yQvDj2u5yAJKBo89URmoEK38=; b=ly4tTXYK1Wbkj7IPhRSBYXcTdNjcWvfD5vlaJvSruHLfw7meo2+DucE/vXNe28NWmuF46zk+k9sWnaPv5mwv6Wc0XyReVC+f6Xgg52B3pNzYIvutH+C9QHZhF6/oXNEznzgCf/NJkgBnZLhd/u51C6nW1dCk4rSkFQP7yGDRQl1QmK7d6x/VxM5dBadVsZYuTwaOBDBqQZccuwYwicpiWivDr+rMpVcaxXJJ4PCTcOO5YGriwVzzDpOqUWMty+frhkCJYS5OVzfAbexXr/8BOFziTS2Y6r98M14SXZo6broD4C/ApGJMiT+Q2c+3BkS7i1sqilZAsFYRNxd2AnxhDg== Received: from BN8PR03CA0021.namprd03.prod.outlook.com (2603:10b6:408:94::34) by CY5PR12MB6346.namprd12.prod.outlook.com (2603:10b6:930:21::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Fri, 22 Sep 2023 17:36:44 +0000 Received: from SA2PEPF0000150B.namprd04.prod.outlook.com (2603:10b6:408:94:cafe::48) by BN8PR03CA0021.outlook.office365.com (2603:10b6:408:94::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.32 via Frontend Transport; Fri, 22 Sep 2023 17:36:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SA2PEPF0000150B.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Fri, 22 Sep 2023 17:36:44 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 22 Sep 2023 10:36:32 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 22 Sep 2023 10:36:31 -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.41 via Frontend Transport; Fri, 22 Sep 2023 10:36:30 -0700 From: Asmaa Mnebhi To: , , , , CC: Asmaa Mnebhi , , Subject: [PATCH v3 1/3] mlxbf_gige: Fix kernel panic at shutdown Date: Fri, 22 Sep 2023 13:36:24 -0400 Message-ID: <20230922173626.23790-2-asmaa@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230922173626.23790-1-asmaa@nvidia.com> References: <20230922173626.23790-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: SA2PEPF0000150B:EE_|CY5PR12MB6346:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e535613-e34d-40ac-4fc0-08dbbb927d19 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +ax+acN929xZMBR2onSETZciOKxSKrOB16388XB5H/KNuwq28ZjGdBBGfbcQfc/8OWVVAkgb+fkp8kRKPG4JlR60Yzophlnh2bxIxELUCba1oAKg7EZIpknuLK4tkUeiH60Q8af98Xcosd1MIYD3qqsPNGVesq66TB502x6sSk0WOKdN7sg2U+Ydq0B+tAP+v/KjEfXWTcneM6F6Z0pIdfqE4FMq4KHJXryk5a+NXPj5K/53Zo3CfRVJiGajpCgNNRvciDkqJXR1UZewN5AX1Sj+Nnru+VqCfTo2N6C16uaY30uZ24XvrckVmjMmiyOoaT22YIXO+H4kdvxpSWTBBtndS9oxZXsssCP1jReyhM6IBPjyuIIbI4dAcvJq8s/+QsKh2HrbAgFGH7WCpmCX9otPjG7R0qxVdOCLu1hTeAkW34R3e4+vLqpHOkGLGQ7PI+2uOD9U2VWcum0gvC+aULOoGYrG6SrpZSrozhpMnNWPNMPSX9VxWqCvedBsevuGcI5vYXckWIqOf45yGhWDVZJNoPJyvB4t+6Jc5G33csC0O09016uXZWQinrzJbwPxrPk68JsaqYxZhh+gR9s/x5lmXVDMbcGQCgyo8i7XtbZjmufvW09bSHdtcqCJU3kForEsWutg+L7/FuLA51TqjO5lRPkznx/AGDAlQK/q+CNwuJaG/334nzYFdvnDAs6gpRjBUknYKMPKLxBb/6vp5lZAlfJKX3ns1Fm6NSfeAg61dpOuaKfsGQHpkFKg3jyNx/tRAZ2cchRclzk1kQJsxg== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(136003)(39860400002)(346002)(396003)(1800799009)(230921699003)(186009)(82310400011)(451199024)(36840700001)(46966006)(40470700004)(107886003)(8936002)(40460700003)(5660300002)(336012)(83380400001)(1076003)(2616005)(26005)(36860700001)(47076005)(70206006)(54906003)(478600001)(110136005)(70586007)(316002)(41300700001)(8676002)(7696005)(6666004)(82740400003)(426003)(4326008)(356005)(2906002)(7636003)(86362001)(36756003)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2023 17:36:44.0237 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e535613-e34d-40ac-4fc0-08dbbb927d19 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6346 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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED 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 --- v2->v3: - Add the logic to clean the port to the remove() function v1-v2: - make mlxbf_gige_shutdown() the same as the mlxbf_gige_remove() .../mellanox/mlxbf_gige/mlxbf_gige_main.c | 21 ++++++++----------- .../mellanox/mlxbf_gige/mlxbf_gige_rx.c | 3 +++ 2 files changed, 12 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..74185b02daa0 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,21 @@ 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; + + writeq(0, priv->base + MLXBF_GIGE_INT_EN); + mlxbf_gige_clean_port(priv); 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 +496,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 Fri Sep 22 17:36:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asmaa Mnebhi X-Patchwork-Id: 13396161 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 16F6127709 for ; Fri, 22 Sep 2023 17:36:48 +0000 (UTC) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2078.outbound.protection.outlook.com [40.107.102.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AFFACA for ; Fri, 22 Sep 2023 10:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ndyi2ZOq5VYz1aXkrdb4dCuGAeG4+Y4j04YloN5/dTOU1e78D877+Bb4vnyUPIS9TOUvOKPyFzfyuw2wooZ0TYwkHxa+HIQ20LN7ZoOFRagqRkyPtGLXJPpAAqaDnRKLkOiEEZTc7lI/PygVkFw1CuzEDi4g65fr5BpGsbnHG2JtxqV2Bug/P2NpCV0RiLSQc4kaMinNj7LxxVv2b4Uvbta3g3CEYQWC9UzTv7zoxomdLHwPZZ6WeD17yALCZQhgoDQY1TydBwLVG710OwKxzOOUZesFS7mjBnKf++7PHldQcR5IkmUq47bxKi7rIL2eSPjh+bJsdh8iQIHSyZTodg== 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=kftcsyrSR/iwqsPInWpSLKsnh0Zng68hHYcuTpB41zk=; b=PrmCB2G4ic5ZU5TZeBCN3VN19bcUQ3JL6bziqbLECtvvZcgJlGSkT8n8jIwl/hXqpHH0o+hJI/vQz4p0j+1jADGnMXqGF7K40WFo5C5f/pGWEw5SaAOHVgpwHE7PLqx3BbgwfkH1Jkp0rrqAPzmDrSZ1ZLM7qliRZQ33Rd4sx77YdL5BXrIh2zEZIHmHfhsBwZu0QD+LDTEf/HtLts3PXdfVpqovCa+k4FXiL42i/9QbAKVddl5H5kZBe//2XkTpJIJscoqSbHf+FQPEo4oaBzIDQeWPjKhYRKAvn1YK+fmSCBELsdEfcoGZLuWq3Xchouxk9VJFiM4T41Sgn1B+dg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=kftcsyrSR/iwqsPInWpSLKsnh0Zng68hHYcuTpB41zk=; b=Aw5L1HTNuypVAFl49X/b5GyX2n1Bj4UQEbNZV1XuYkIPSDHu0Gwq4jvdJQAXWsCMn/fm6PYRbZM+M8FE/zIKTDdpdEo5Tm/2QvzCYEwfRBn/45YkQPJbiuQm7d4CNXrYADxSrUD6bGEpgglDUr9B73xcBRVkbsWCCv1aG9a0bZgJEm8SzXYF8I1D4w4N7rIodSVEjdLLWQF8jelFk2oefR0FDzUnuTJmVY3VfBnk3Xai+vRwLx2vQ2WR/1MWDxrkF3xuer0W81EmAkBbUsxLZUcAT1sB4491I/CzmMfXEekrFiTG+dfRVvlbdSe3/Rekvnb/S+2KJcMnfo0ZIzTSHA== Received: from MN2PR17CA0021.namprd17.prod.outlook.com (2603:10b6:208:15e::34) by SN7PR12MB6690.namprd12.prod.outlook.com (2603:10b6:806:272::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.23; Fri, 22 Sep 2023 17:36:45 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:208:15e:cafe::ab) by MN2PR17CA0021.outlook.office365.com (2603:10b6:208:15e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.31 via Frontend Transport; Fri, 22 Sep 2023 17:36:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Fri, 22 Sep 2023 17:36:44 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 22 Sep 2023 10:36:34 -0700 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.41; Fri, 22 Sep 2023 10:36:34 -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.41 via Frontend Transport; Fri, 22 Sep 2023 10:36:33 -0700 From: Asmaa Mnebhi To: , , , , CC: Asmaa Mnebhi , , Subject: [PATCH v3 2/3] mlxbf_gige: Fix intermittent no ip issue Date: Fri, 22 Sep 2023 13:36:25 -0400 Message-ID: <20230922173626.23790-3-asmaa@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230922173626.23790-1-asmaa@nvidia.com> References: <20230922173626.23790-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: BL6PEPF0001AB78:EE_|SN7PR12MB6690:EE_ X-MS-Office365-Filtering-Correlation-Id: 80c20f3c-896d-4277-f416-08dbbb927d5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hzwt7jF+Glwn3xsuCQ3QQyEesqniGFVuuaaQ4N26l2P1l+0SZ2WOQokzKeV51ZdFwOahS7p+oQWltuE7s3/GrI8GMBCatBV4YUO3xCjueePpMde6LEbB9/SKEt1zKe0l9h0ozAAQvDdOrmO2pK+r2GvF358lx97UV3BedEIovEdWJNR1HonK5tUp3Rj3eAO4H9siOWYbwFFFFMyikiNxutKRWWlSz+61/i0xbxj6kqy7j90xeVbsK6w7la1KTKNe7iaWVbLwzInwVL8PrPVWQqOKyf+1/qnaGset4AFHzVWh3jnS4BzO0bEok7gr5GLxidSnvBA495n/NMiGzjKglUD8MZ95cfHaCFuF1D6WROYvXIpfs5N0PZ0Um/SGcvOeRwdj47AmsIB3z62tQIgXSlsM8tCVRXU0IIEkmUquFSOFJvDV/N0gxMME1aNRcFKuIVzVnEqYeojocai45kXmE0dsSSBmOmpfHISCP0mmUETi4RoEUv07FBLMFQAIsOEHqUsszl3seBdXUDP7n3RNg7Fh1d1JmEa9ooBhFygtqkFeGiWg7qbss1STdRubfEHTQGJ2lQaTOy2ojkN1VAP/jMy0RY99LwXxebiAtSSYjWMQNh7acta0yFf2sV/JhOU3Xxvnuce88bmsGhnhTvKrcjbxq4AW6Wq+hJy+gMg5YtUTcs65b47WkpSiu4pqfQNp+Rsfjf2HrQ1Vvkf2y+4tJKW/lMU4MT81yoBhT3hLWFaSFWMmnJwjEFqrf6/8u/OeFjW7yYhmDnQ6l+cDFXtsCA== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(346002)(136003)(39860400002)(396003)(186009)(451199024)(230921699003)(82310400011)(1800799009)(46966006)(40470700004)(36840700001)(70206006)(2906002)(5660300002)(8936002)(8676002)(4326008)(110136005)(70586007)(478600001)(6666004)(7696005)(1076003)(107886003)(316002)(2616005)(26005)(40460700003)(426003)(336012)(41300700001)(54906003)(83380400001)(47076005)(7636003)(82740400003)(36756003)(86362001)(356005)(40480700001)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2023 17:36:44.3979 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80c20f3c-896d-4277-f416-08dbbb927d5b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6690 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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED 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 --- v2->v3: - No changes 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 74185b02daa0..fd4fac1ca26c 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 Fri Sep 22 17:36:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asmaa Mnebhi X-Patchwork-Id: 13396163 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 3955E436BC for ; Fri, 22 Sep 2023 17:36:52 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2047.outbound.protection.outlook.com [40.107.223.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01932BB for ; Fri, 22 Sep 2023 10:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MeAi9UwZ/RPdUs/JWALsi6EPD4Xb2B3X1KqNd9LBDB096o6pDYXXf6fo64emAcx9z5guFLMnzXI687rJCyRefPoaqCnfghV1mrx487yuhQW6/MSoCCPRbhHrDMoFV5hrWluZsC7GU8ZQ7Cx1gNSjvu3U3ChvfUrxIgfnqrNA6PwamR/rohrQA8l5gdRqP0HDrAGnMswMajjAv9vJIii4uJ84wN5auYRlZErJ/LqkEmY1lriDqaNIoIbQbAkyOAJutEXGo87iacTv0sGxPLyo7akkYHLHH6E9vXwNBn3RznQ0XJE9RZmIHLpw5Eb8rQiuP4msRQB9nQG+tkCgOLE4WQ== 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=9KuBG0U57bFsw1LscDqWRGJSctwVGzm3KbiudP6gOlM=; b=PA5th01J3WWziWmsJdq9bXuYVA/crlJNKClN87ARBFopFyyegCk9mWMmMgOnbjBAmWBn6SBSZYbAHWV4VQKG8WYjMXt3NnQv4nHifgZ7wVperTt+vC/oxIeHVzlzj0ipiSLu4oECwDyIMVLVs5rBoPApRaN3EzKXKQx9MFWx9TifRae361PRgutV0Z00LV4m3V+DGN5K5LMoDhi+Ko01QAc3uV8AXsCDuh5JDw+ep+9KFrUYGtP1yH0qzBieDxft27PQLpVZOTFIL/v61OS6lfUhrM5RJO0707S2QnGNHRdzUcUsqHJ8YmtwjAls1R0K3jqFrHNz1b9vHCUbFeYX6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=9KuBG0U57bFsw1LscDqWRGJSctwVGzm3KbiudP6gOlM=; b=gAgRhTTuSzTeIpKBhgjm56ab4uJVo0KB8lSvjbjk/nEAy7SDza/XPlA+2E6WaZJsrjV0hel4ZjW4K+LyX9rUBFPG6uI9tb3cXDUyRMXsNRkEEwDxR/ZzbwDjDNIuwbekYkQbQh9oSsWAT4HA9t8i9VA377qz/OjoZw4Mz4ZXEeaZdWofOfIEQRTc/c8wfLJRffbKVtOZe43utNy/9SEV2m2rwp9ZamKDLihYP+NdeW+Mt+10N7eXBgkSaSpS51uLhWT0KEGPpaeiBmGtAcCEGr/SAwxGjf6XBTfndDwDrf/j2HdfsJsje1MALynrQO5SPjAiB6ohT56By5QVzL1yMA== Received: from MN2PR17CA0027.namprd17.prod.outlook.com (2603:10b6:208:15e::40) by DS0PR12MB8246.namprd12.prod.outlook.com (2603:10b6:8:de::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.21; Fri, 22 Sep 2023 17:36:47 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:208:15e:cafe::8a) by MN2PR17CA0027.outlook.office365.com (2603:10b6:208:15e::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.32 via Frontend Transport; Fri, 22 Sep 2023 17:36:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Fri, 22 Sep 2023 17:36:47 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 22 Sep 2023 10:36:36 -0700 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.41; Fri, 22 Sep 2023 10:36:36 -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.41 via Frontend Transport; Fri, 22 Sep 2023 10:36:35 -0700 From: Asmaa Mnebhi To: , , , , CC: Asmaa Mnebhi , , Subject: [PATCH v3 3/3] mlxbf_gige: Enable the GigE port in mlxbf_gige_open Date: Fri, 22 Sep 2023 13:36:26 -0400 Message-ID: <20230922173626.23790-4-asmaa@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230922173626.23790-1-asmaa@nvidia.com> References: <20230922173626.23790-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: BL6PEPF0001AB78:EE_|DS0PR12MB8246:EE_ X-MS-Office365-Filtering-Correlation-Id: e78f8e46-9d0c-4749-079d-08dbbb927f53 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AsVFGYpTJPpB45wUOnUAmULoGbnOPpzwCaJ7BLpEBihOFU5qmkGis47FCqkPJS4RWdfJVWF0oIQPO9OgApiXzlcxsuXGQ7a76f6zD8jhO6yMO060k+olMuqWPVRUSBw2EZau1n+Cq9gvOAJbEwvesK8Jplx2sJVPwnvE75hhYHo4JHXxj784nX0mt0kMVulyiNbMxydyAlLnmOHc1f8J5O7HOfIGxbIGi2syFChID7iqHxsNGKCBfVEkziR+4WjHyapv/5yq0u5xyhQupd0KKpv/NQZXHjyR3pL4ZiL5deQsQOYQLLYdFsg5aaT9skrqVlVrM/tEuuKP9ZDzOoVmjKv65vGZPpCz+TQVrcVA//FE12+lnMBc7KmhgTbwHhloaaJJPsiZECElqfZb0vuoW6BlVKSNLoyJ+DdORv5WqfPTe5woEazrDqIfMC/DCiq000cJz3nv3/h+3gdqFcCMu58U/JMV2ZjkbTiN8qsVv7fIAC3ipmwHMKHJdbiCHJJCU7xJC1PV9OIxKpvAhwc2Y94mKdJliKuU3S2kphIxZmkRHYX48mlLBGo0/KJE31kXU2cCs5Bj7eNp22zEiTypqEhMkGCV84okrMsma1GtgkvVSgGi9bSWqDP5TpplnJyJFiqk1uBFk8glEV243fikCP9wYHObnrBBX0ITervKcoUWRSV0shYANU/QUZ1zHYntm3wpzmo9oKVRGeixKEXxA4oFMIxJe7S/A5xQzzkxDkdGaNJzHmnfmcMAfkJuxVj5kvd+EQZOX2FX7pqP+ecuhQ== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(346002)(376002)(136003)(39860400002)(396003)(1800799009)(186009)(451199024)(230921699003)(82310400011)(46966006)(36840700001)(40470700004)(83380400001)(82740400003)(36756003)(356005)(47076005)(86362001)(40460700003)(5660300002)(41300700001)(478600001)(7636003)(7696005)(6666004)(8676002)(40480700001)(4326008)(110136005)(70206006)(8936002)(2906002)(54906003)(1076003)(70586007)(107886003)(2616005)(36860700001)(316002)(336012)(26005)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2023 17:36:47.6793 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e78f8e46-9d0c-4749-079d-08dbbb927f53 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8246 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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED 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 Reviewed-by: Florian Fainelli --- v2->v3: - No changes 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 fd4fac1ca26c..e74946b802a9 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;