From patchwork Fri Jan 26 17:42:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13533069 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) (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 BCD17208A7; Fri, 26 Jan 2024 17:43:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290995; cv=fail; b=EBIKX0zAriVpUeVU7nXAHeptUvZ1WZ30wzeWI9ftHL07WI0L12REm+wCCsyDsdwcqJsiLnDJHTbiggI/QwhdgtDF2CidprYXQv0rFv+S/6DY7zLU55FLiiUxjSLzg0QpqZ7vybHO2fjtBnDEI59CoI6fIVcGu0hfdq6aVggrRDE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290995; c=relaxed/simple; bh=XQMiXJfaUtT56COvtVhZxFo1hdhPfoUV/HtoKERZ6Po=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UpglAkFkLIZqYuZJ6AQmCvySTnXyjFGUsyNh4E73Hlb6X3TGF1IGIQrgZ2sJx/qF8sXW9Cb0LkMz15cBBSXvJ8l5PJN897k1jzj8olJgk/g+fW93pon7s4LYIyKxLzZgXj4pH1A4i6YrvwX1lwLrkU8iJ72DiUBsVHoXt2qVdjY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=DqAiE/ZY; arc=fail smtp.client-ip=40.107.220.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="DqAiE/ZY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=My5QMyLHGRi/mqDDHr+DeNsNJjtDz4wu5p8uDfbXVBTqW1h16TlHCmfyRNa0ADewmU3mUS2a2ab6vgItc3ZwXJ+sWM2UEl5a2hh2fQngUuo+7ELbl7qxx7daqqVa5g6LOng6aD6asAgTSWxftCgbmqwxyONk5M0BJwb8gYiBFI7/eLGyUvXntmvpGWozb3z7zO3mqWJeY5+SQYuZjPJvsJqEhPWGGJ63wZTY35bg06HLSEjYhCbEV11iV5QNWn7+T4TOrHgBFfturr7yrsdWqKwZll/UObxq7QfmBgyte+pRiB53TRkdWK0jmo+2Diej1QAKiHqSM0gz+TepvFN6sw== 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=MxgoXnPkLxGZlU2vaf/rtJlJBaW7MnSbgYX7qyp9DUQ=; b=TvYUYUrZGVSXCpiLopyiYbuCSSzMs4h0AMyhdzqkpL1TKaH19IaLfP8MNEFmFJ7S71Qb7fhefOxut8iDAL3SWo1H9a+E6o0uzCCImfP91aLptfrAJJL7Sp+A1FGSYX2Z7bAkW/fXrmNoynSFeeAMapDFWyFA1BF0R/Dja5TBvVfxEtvh6zEVqOGSVqe7tfPgF1Gwm+pgZMJLAeWa8JV+dB2igFH+lBEcngjA4GsxjdkDebAaSxjUq2UFelQvFbqwYh9PqZk9Jn1Yv64bWYbldNoHL+/z5o8mlReMMMlur1tNYuIfWscPSCXRonRkz2Wc+umTlU1tOjRPrWlbng6j7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MxgoXnPkLxGZlU2vaf/rtJlJBaW7MnSbgYX7qyp9DUQ=; b=DqAiE/ZY/rJJKXeM1+fc4d+9vqrwLX6f36F2lWU46etOa5jkEAs60hB6lloqCCprlnAbaE5W/vxZWiJWNKyfOjMJh6wvYVPh2DjW74HlaZ9+UJ5/a1YHi98ZT2UZSftZnrC3vBtERlrLc98mJEhs/PoqZkmrQoGVL+jxpp7KHzo= Received: from BN9PR03CA0633.namprd03.prod.outlook.com (2603:10b6:408:13b::8) by MN0PR12MB6197.namprd12.prod.outlook.com (2603:10b6:208:3c6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.39; Fri, 26 Jan 2024 17:43:09 +0000 Received: from BN3PEPF0000B06B.namprd21.prod.outlook.com (2603:10b6:408:13b:cafe::da) by BN9PR03CA0633.outlook.office365.com (2603:10b6:408:13b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Fri, 26 Jan 2024 17:43:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B06B.mail.protection.outlook.com (10.167.243.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.0 via Frontend Transport; Fri, 26 Jan 2024 17:43:08 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 26 Jan 2024 11:43:07 -0600 From: Brett Creeley To: , , , , , CC: , Subject: [PATCH v2 net-next 01/10] pds_core: Prevent health thread from running during reset/remove Date: Fri, 26 Jan 2024 09:42:46 -0800 Message-ID: <20240126174255.17052-2-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126174255.17052-1-brett.creeley@amd.com> References: <20240126174255.17052-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06B:EE_|MN0PR12MB6197:EE_ X-MS-Office365-Filtering-Correlation-Id: db6a6493-ed05-4418-a22d-08dc1e96424f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5UErYTCJmrGAhcW/NXEFc4e7QDxfQZEHU1CR7zxs1OMMbGUZf8QUFrkdR4m+w0PWw+Ete7oTQ/Ura8VI6LMkbEwNYdcvxBQlFSSTdg4vxLGvPlPYOYj/5i87uC3qRemJdu01Tb8X85DSBNswEMUH34ayPJKK4+R0s+gul+WpZXTewqYvy0nzY0fhh4RKzNz8SKT56pT3bIn26qokGEzx072pL2jFkKz9JdHbvN5VSNifslm563Xy6/pwa7QTiegIEF52B0pzdo32uJ2cY/Y3wjzaFZofC49segKPkINvgE/GpBdZYK9kIQXP58v/QPh8JMbPfG8N1glBejZAIRRZIa4SYHccqes/lCoP540K01QSl/JQPITWZCYAVuRjPVgTLwcsHX+PzUMq5MbZgPRHfz+Vimkc60ju8ittETediBmeS6rhkdKcfuV2of4XSZHS0DLnNr63XIdSTUH+st6uVNZmpOXhGMhCkIivwhTzaD9WJeFvg7lzA8GOExf2wAncYDzjomgMepayi5v/XdAErgjRueT7WE5ciiBclcUJDfBZ3oOjkbqz0V3zgbexUfzsQeTzaDl0iVkKpL12e/7x26eCMNkGaUuzoswpu06gnSjrW5CW13Z9yEPYCY/mecvdKMqaAmnjOi6sTpdsu0Jao5tth/3EH25VL4vdg+Bx0CwOK2WgZi4XUz1LbzHEAAyWxImZ8GCaSaoFheGySdqZQsAdUFpa1j0eDJZae0QgtSbb8JadTokj8dPdzUjurVbQyCssxX7Ki5/t+dP0sxGGnQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(136003)(346002)(396003)(376002)(230922051799003)(451199024)(1800799012)(82310400011)(64100799003)(186009)(36840700001)(46966006)(40470700004)(40460700003)(41300700001)(83380400001)(2616005)(16526019)(47076005)(1076003)(336012)(426003)(82740400003)(36860700001)(2906002)(8936002)(4326008)(8676002)(5660300002)(316002)(70206006)(6666004)(478600001)(54906003)(110136005)(44832011)(70586007)(26005)(86362001)(356005)(36756003)(81166007)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 17:43:08.5741 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db6a6493-ed05-4418-a22d-08dc1e96424f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B06B.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6197 X-Patchwork-Delegate: kuba@kernel.org The PCIe reset handlers can run at the same time as the health thread. This can cause the health thread to stomp on the PCIe reset. Fix this by preventing the health thread from running while a PCIe reset is happening. As part of this use timer_shutdown_sync() during reset and remove to make sure the timer doesn't ever get rearmed. Signed-off-by: Brett Creeley Reviewed-by: Shannon Nelson Reviewed-by: Przemek Kitszel --- drivers/net/ethernet/amd/pds_core/main.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c index 3080898d7b95..5172a5ad8ec6 100644 --- a/drivers/net/ethernet/amd/pds_core/main.c +++ b/drivers/net/ethernet/amd/pds_core/main.c @@ -293,7 +293,7 @@ static int pdsc_init_pf(struct pdsc *pdsc) err_out_teardown: pdsc_teardown(pdsc, PDSC_TEARDOWN_REMOVING); err_out_unmap_bars: - del_timer_sync(&pdsc->wdtimer); + timer_shutdown_sync(&pdsc->wdtimer); if (pdsc->wq) destroy_workqueue(pdsc->wq); mutex_destroy(&pdsc->config_lock); @@ -420,7 +420,7 @@ static void pdsc_remove(struct pci_dev *pdev) */ pdsc_sriov_configure(pdev, 0); - del_timer_sync(&pdsc->wdtimer); + timer_shutdown_sync(&pdsc->wdtimer); if (pdsc->wq) destroy_workqueue(pdsc->wq); @@ -445,10 +445,24 @@ static void pdsc_remove(struct pci_dev *pdev) devlink_free(dl); } +static void pdsc_stop_health_thread(struct pdsc *pdsc) +{ + timer_shutdown_sync(&pdsc->wdtimer); + if (pdsc->health_work.func) + cancel_work_sync(&pdsc->health_work); +} + +static void pdsc_restart_health_thread(struct pdsc *pdsc) +{ + timer_setup(&pdsc->wdtimer, pdsc_wdtimer_cb, 0); + mod_timer(&pdsc->wdtimer, jiffies + 1); +} + void pdsc_reset_prepare(struct pci_dev *pdev) { struct pdsc *pdsc = pci_get_drvdata(pdev); + pdsc_stop_health_thread(pdsc); pdsc_fw_down(pdsc); pci_free_irq_vectors(pdev); @@ -486,6 +500,7 @@ void pdsc_reset_done(struct pci_dev *pdev) } pdsc_fw_up(pdsc); + pdsc_restart_health_thread(pdsc); } static const struct pci_error_handlers pdsc_err_handler = { From patchwork Fri Jan 26 17:42:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13533071 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2071.outbound.protection.outlook.com [40.107.237.71]) (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 37E12208D4; Fri, 26 Jan 2024 17:43:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290996; cv=fail; b=rJtx8qzqn7TjoExJ4s+NkCc6w+MXuqysOQd54z0Ytz3s5cgo9brOvQFNUzNyBrDrzGjwXB7+YtNPqM8CDVaNP+v3HYKw87t4jNola2FEdxUSwVUHFe7uL4djbIzf9+6Tmv3KkGe0lHP/GEK4KW5EYLB8frzlfPSTVm4oiy0M57Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290996; c=relaxed/simple; bh=ZItyvVlvA6t9o/lw/UYWGe6vLQzXEpEpp3YXxdELk3c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gqAfV6Q8QOOCa9hMiJL5sNO+49uYZ8lSvKUJPVZEr4RvFIx6sA1O9Z129izF/aI1YywjJo6V0CmDJErpLrYU2vaGlCk536crFqyfZkghkrXaitW0Sd7pf8Lyao3RxM3qQAPaHS33Re9qx/1UQ1nYptlD95NedW1M3OEomlLaYsY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=VYosjYss; arc=fail smtp.client-ip=40.107.237.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="VYosjYss" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ilkg6YoyEC5KgueA25drsjIS1kC9FVYG12Chcfj8YrJ6drUV7SCZj2tyJ3sFQ9mCZmUJst0FUu0PAAye4whKmnbnPaaALgaYuZEMYZM/x97w6CXTYcZWUqqhY6fstas2UefgXlo0LkNyFuUNPVRO5HnE8M5faWTHjL1CAPtfhyOjHkOK1xZmWFu0/04lW4lPyhT/qtDM7EXIb6O3+YHhGppOJyB/5oMc2UXwCUJ75GPkQAJDsdsr/ncC+MH7NyLe2ekM2M+9ge+F7fyOMbor9m1rXcZ3QgPFeWgz6WFNC5S/kp4R2OXNHM60vkQ4w2MtCMNkuWaIYhwTYx/UEDaJPQ== 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=/yjdSOX9Fj9+55tcoiGVAKOjLsrEbqq9KpSCeyrHSj4=; b=AF9iMiJm6IyeBo6bq6YgLAlRN32s+kGcB/ceFgxIIJNG9Uz7S0S1ujLbSRciS63U7eH9PS9e8S81tDHIwq5mCLzGCjKQbXFmK7KFGXwb+hTcRYbWuwIFvm7AHh/h1xsYnAyCiVowMwtem3dxLrC3ixlBAM3kFSuCv0BLytGrJP8FLFt4/XbBqJNgExVJzbhR5lZ8RvKgz5RXLeeHBj680seM83jWm8ptuCicm7cTleUdfVVf72d1N8dXSg0tUSfUeTVg3EiEQoJL1uGWxytZEA8Axlzf2FXudJDbFKQgtgMn8Ck1d4dRyiP8eVKY5nawygCPwSpkQMz7EZ4CjbObWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/yjdSOX9Fj9+55tcoiGVAKOjLsrEbqq9KpSCeyrHSj4=; b=VYosjYss38yagAHTu3Pi2q9SD7+ogSOLdLXqHzE/UTILbikY5n6DvTXRn2NdOp+pQhXNVkMx0TIKXJbqdE2LsWFp2gj9fieH5XBaoD98UwESVTlzeQm5Jn0kpWK2NzclHxSt410XqDfPZTx3bl3GjBjJYxvDEyh3EUCKYkxAfO8= Received: from BN9PR03CA0655.namprd03.prod.outlook.com (2603:10b6:408:13b::30) by BL1PR12MB5874.namprd12.prod.outlook.com (2603:10b6:208:396::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Fri, 26 Jan 2024 17:43:09 +0000 Received: from BN3PEPF0000B06B.namprd21.prod.outlook.com (2603:10b6:408:13b:cafe::c1) by BN9PR03CA0655.outlook.office365.com (2603:10b6:408:13b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Fri, 26 Jan 2024 17:43:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B06B.mail.protection.outlook.com (10.167.243.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.0 via Frontend Transport; Fri, 26 Jan 2024 17:43:09 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 26 Jan 2024 11:43:08 -0600 From: Brett Creeley To: , , , , , CC: , Subject: [PATCH v2 net-next 02/10] pds_core: Cancel AQ work on teardown Date: Fri, 26 Jan 2024 09:42:47 -0800 Message-ID: <20240126174255.17052-3-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126174255.17052-1-brett.creeley@amd.com> References: <20240126174255.17052-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06B:EE_|BL1PR12MB5874:EE_ X-MS-Office365-Filtering-Correlation-Id: b6b6a3c4-fb61-42ee-d7cb-08dc1e9642c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m9l6Bp73bHscW1CHWl/beT4mC/gpaDb0wm9daklMsfr/VjCq9L3iG18tLUA4BJF8fxe8cLwjetVqbm3OE0N5UcXrqLfHjgkQhO6bk8SXqG4ThxG1bOKg32JHEygA7PT/ehQWFqahBISpm8erOloTRaniZU7sNUc1WQfn1GLwOiDk9YQ9Z1Amf+9HtIQJvdGeL/Zwph1yI/fFHVX0mnI1IcOeeJX3rJeg4MOn6cvn2pKDi2H3qAnOJWi6VxmiezfjuhvCvAcViMaatfbzPuMifyxmk0kPUxWAxJP5xzOSH2MY9EKPIkx6KGPkxGsVz67eCvp8y5DTMX+xCy2kq9aSFPdEeGhxSPhV8BlmhG5SZms7790TR1cFIILvXPDBIa0oi9bKORPaZ1nzy2wGuyUuf1a7rJSqVNKP4XYnP7zaSRVELph/5MEmiXd/u7UVz7ncuroTVTxAlzfUrVgnG4NcKvJuAtY3fFlfh+FkN6iKuiSRhTpTC4Jd1tsWNtm5g/mtbBNIo5+wg0VuiHB54MBGhtgQvwycyROz3NMk3vDsyQKPTlK+FU3+oXWZ42ADhS3B/Lpp8OzpylcHk+l8u6k1fqylV/rQI0Flue1Wj81Vr3XKSm7aBCTq99OhByS/9fgwiQdeTeERW8hAT9SRObq1uyQbrarpMe4nZ1rs0evdJc1NScp6KG27H0BpLTiaANe81rEs0tCLiXqld3qhwtNWYTfg7517qzaK0sRTS9IkBD6YiTlhQUbicv4wU9D9xhCsScVWXkz05CoqP4DPCtNxnQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(396003)(346002)(376002)(39860400002)(230922051799003)(1800799012)(186009)(64100799003)(82310400011)(451199024)(36840700001)(46966006)(40470700004)(110136005)(82740400003)(70586007)(70206006)(4326008)(36756003)(8936002)(86362001)(356005)(44832011)(8676002)(316002)(54906003)(81166007)(40480700001)(40460700003)(5660300002)(36860700001)(47076005)(2906002)(83380400001)(41300700001)(426003)(336012)(16526019)(26005)(1076003)(2616005)(478600001)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 17:43:09.3554 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6b6a3c4-fb61-42ee-d7cb-08dc1e9642c6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B06B.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5874 X-Patchwork-Delegate: kuba@kernel.org There is a small window where pdsc_work_thread() calls pdsc_process_adminq() and pdsc_process_adminq() passes the PDSC_S_STOPPING_DRIVER check and starts to process adminq/notifyq work and then the driver starts a fw_down cycle. This could cause some undefined behavior if the notifyqcq/adminqcq are free'd while pdsc_process_adminq() is running. Use cancel_work_sync() on the adminqcq's work struct to make sure any pending work items are cancelled and any in progress work items are completed. Also, make sure to not call cancel_work_sync() if the work item has not be initialized. Without this, traces will happen in cases where a reset fails and teardown is called again or if reset fails and the driver is removed. Signed-off-by: Brett Creeley Reviewed-by: Shannon Nelson Reviewed-by: Przemek Kitszel --- drivers/net/ethernet/amd/pds_core/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c index 0d2091e9eb28..b582729331eb 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -464,6 +464,8 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing) if (!pdsc->pdev->is_virtfn) pdsc_devcmd_reset(pdsc); + if (pdsc->adminqcq.work.func) + cancel_work_sync(&pdsc->adminqcq.work); pdsc_qcq_free(pdsc, &pdsc->notifyqcq); pdsc_qcq_free(pdsc, &pdsc->adminqcq); From patchwork Fri Jan 26 17:42:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13533070 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2086.outbound.protection.outlook.com [40.107.100.86]) (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 C2CD8208BD; Fri, 26 Jan 2024 17:43:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290996; cv=fail; b=e8Poy03pIiDblsnKcuL+XFXNNFeGic2+avxAKi//f75GG1/jmoJkq2o4B4gN/NLGFn2A5Hob/M1II4mynt7bVLdsxnYUy8L/5heftNkWkWMXZQk416v0nfNY0LKHJw1OvZPVlEX6BDyBhKGg87NskhB5SZV2Fq9xMWZcAV6Io4g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290996; c=relaxed/simple; bh=nbXDOebMxEMoAvk/jKfMqXGFruDw5Uh7NJQ7ZmUvQw8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JPigCTNrfVppF47NEB82ypjq9WdIKO/eidcxyzohNUTMMk+PKNtY7DORbe3MgS7N2QfJpSzeWQ4aJwoaJxO/131i00bk/HLRQt5FwdRe+YfSKyYcxXaSXu43EyySD3UG6ja68T0LZUnqGuJsN8KsAkAtGdWuLFpaQOqvIyYHqis= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Zrh6AGUl; arc=fail smtp.client-ip=40.107.100.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Zrh6AGUl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ArEUWOLBIzai38G/NN1dG8JbBa2FTRhZ6b2BZ1ZbEjB2foPpCEPrvnK0Zw24zGLPofCUoVAYCpyvxbOBd82spnuLwqz7qs81kXB+M+O6EDMKu38G/Be1mvJiOg5u3E2MM0dBdJ/8clriN0xr6NABtRLI4kVkNBixmoijtjhSSILGZfXN9frTqoDc5YXcPbj81B4wA9JV4mxfgPcvZ9jntspmBnfN1r2Rlk3Z4iAAb68X53T6gXYDBzW2AJ3GfufIdhpTqsqbNOksQ02s4JdUUlPPvhaUTO3NnqY/Fw+3bs5T1yKzyvDfGIk5hATm+6TPuyUh4oaMH3XW1DCwYvi9qg== 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=CKoOIUEnMgqqw4s8GRzKeUTAwwzf8cGWK8hq0P6QnZk=; b=P98Km5cjMGn4UvMeTbTnTnCGEwLXHaMNmFCPP+O+FcjdXaKlLHc2DuvvhicN3hMT4UmL1sCZD5umc7jsptuwXl9234SI6g1NZHyMUeWzBFnuwPI/u2W7LIrwvS/9QZJzX8XfxU9HSF76izIq38VQ2D92qO+UBBOOz/EhOmWuMZ9ezzYkHSQqdA+RHVAso76GDSGEHrh7wIpKbZTIVlpdI2D5NExctQJ6C0zONvV/nSaIGqGItL1JHrjzUoAg0qWVrYKFRicFlKPVMxVnYHAXNhakZSmAL2W99WmwqdNuuv2ow7LQH2J3rrw/BOxb1Wdtm0StthcoZTw1LxU3P868cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CKoOIUEnMgqqw4s8GRzKeUTAwwzf8cGWK8hq0P6QnZk=; b=Zrh6AGUlrUdsaqZICGDnuxzJ3/jkvHPW33WBauWEOyEQXMV01KBFMN90HnI9iXagAHywSp5socz3eTEZISTN/hTvJNg/xdpnLVH4EYgu9Gmm9oxEoL0wN3QKWqN2ypQB2P3IJnJNywWiYILXPolmwoPvIcOTtbtiSlIiIppcQAQ= Received: from BN9PR03CA0637.namprd03.prod.outlook.com (2603:10b6:408:13b::12) by DM6PR12MB4466.namprd12.prod.outlook.com (2603:10b6:5:2ae::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Fri, 26 Jan 2024 17:43:12 +0000 Received: from BN3PEPF0000B06B.namprd21.prod.outlook.com (2603:10b6:408:13b:cafe::31) by BN9PR03CA0637.outlook.office365.com (2603:10b6:408:13b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Fri, 26 Jan 2024 17:43:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B06B.mail.protection.outlook.com (10.167.243.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.0 via Frontend Transport; Fri, 26 Jan 2024 17:43:11 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 26 Jan 2024 11:43:09 -0600 From: Brett Creeley To: , , , , , CC: , Subject: [PATCH v2 net-next 03/10] pds_core: Use struct pdsc for the pdsc_adminq_isr private data Date: Fri, 26 Jan 2024 09:42:48 -0800 Message-ID: <20240126174255.17052-4-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126174255.17052-1-brett.creeley@amd.com> References: <20240126174255.17052-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06B:EE_|DM6PR12MB4466:EE_ X-MS-Office365-Filtering-Correlation-Id: d26ebde7-1caa-48b8-1507-08dc1e964449 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6XxT2zWjzeJnTltDBAuFlJQiks+8VypwEaxOUevwrtM7ETheZGVZ0Wvtn9iRC5BCq1/zU80sAlJhfjyxAdr7wjEjEkzJcRkDsE6TOuxodg7+VX8WMxbDUvV9FZLJQWQ8aFG7zQVGgREkK+k5iw77RhsxmYEOY1q3Obbx7CWFoufQdjEyu0VrRqsf2x+uRRS3O+GtfQTmi7/CD5s+OF097nS0ZzQCaDykhvcxj0wQL99pzpc7atZ0eBFkSuMUsD/ffES00ld1td+/PYGEVmYn/SXyWaMgnYXhPzhyBheVW3SlmfFEBY2XSqJIgTRYtk+yU163K4PHb0CbQ1T0WwxkDUmNqNVMrnsDVxHXsCGlMi6yvjwF02XqwkYsMNGiYNiEsvN1ep7aytHK3Uqx/gfggSq62s6uv4BRLP4eIVL/Udanupe9pGJZB2DmGfRmsuVYz/kxLsKpWhgKh2wnmqFBtNc5CZi8P40TeCK8yT4+Wc/J0IQFD2/A1WirZ6L+y5Ov472y1mY02h5PS+E8qA/F6CL25KM6B6PuKajtWm4wopXa4i3LHXbCu2UPSoy6aX1KIMKiMIfwOr8qy83zh50m11MzTQkXDbnpT7T/Lf77uJwvQooY4eR2K2z3maqSWpLED4s2DSzctaZ+yx8sAulXY9sGh45iGlHJMfoO/3zbzMNYZUXzBWvlDo5ikLy3jT8Exdk+cnb360RJIaYtHbundBGuB1FDmJkFiTAOlWYNKQIhdjnFzphT54MPpARUPMxUYJsAqUY/0jYToXlc9dEKkg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(376002)(136003)(396003)(346002)(230922051799003)(1800799012)(451199024)(82310400011)(186009)(64100799003)(40470700004)(46966006)(36840700001)(83380400001)(47076005)(2616005)(16526019)(426003)(336012)(1076003)(26005)(44832011)(81166007)(36860700001)(4326008)(5660300002)(8936002)(8676002)(478600001)(54906003)(2906002)(70206006)(82740400003)(70586007)(316002)(6666004)(110136005)(41300700001)(86362001)(36756003)(356005)(40480700001)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 17:43:11.8866 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d26ebde7-1caa-48b8-1507-08dc1e964449 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B06B.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4466 X-Patchwork-Delegate: kuba@kernel.org The initial design for the adminq interrupt was done based on client drivers having their own adminq and adminq interrupt. So, each client driver's adminq isr would use their specific adminqcq for the private data struct. For the time being the design has changed to only use a single adminq for all clients. So, instead use the struct pdsc for the private data to simplify things a bit. This also has the benefit of not dereferencing the adminqcq to access the pdsc struct when the PDSC_S_STOPPING_DRIVER bit is set and the adminqcq has actually been cleared/freed. Signed-off-by: Brett Creeley Reviewed-by: Shannon Nelson Reviewed-by: Przemek Kitszel --- drivers/net/ethernet/amd/pds_core/adminq.c | 5 +++-- drivers/net/ethernet/amd/pds_core/core.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/adminq.c b/drivers/net/ethernet/amd/pds_core/adminq.c index 5beadabc2136..68be5ea251fc 100644 --- a/drivers/net/ethernet/amd/pds_core/adminq.c +++ b/drivers/net/ethernet/amd/pds_core/adminq.c @@ -135,8 +135,8 @@ void pdsc_work_thread(struct work_struct *work) irqreturn_t pdsc_adminq_isr(int irq, void *data) { - struct pdsc_qcq *qcq = data; - struct pdsc *pdsc = qcq->pdsc; + struct pdsc *pdsc = data; + struct pdsc_qcq *qcq; /* Don't process AdminQ when shutting down */ if (pdsc->state & BIT_ULL(PDSC_S_STOPPING_DRIVER)) { @@ -145,6 +145,7 @@ irqreturn_t pdsc_adminq_isr(int irq, void *data) return IRQ_HANDLED; } + qcq = &pdsc->adminqcq; queue_work(pdsc->wq, &qcq->work); pds_core_intr_mask(&pdsc->intr_ctrl[qcq->intx], PDS_CORE_INTR_MASK_CLEAR); diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c index b582729331eb..0356e56a6e99 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -125,7 +125,7 @@ static int pdsc_qcq_intr_alloc(struct pdsc *pdsc, struct pdsc_qcq *qcq) snprintf(name, sizeof(name), "%s-%d-%s", PDS_CORE_DRV_NAME, pdsc->pdev->bus->number, qcq->q.name); - index = pdsc_intr_alloc(pdsc, name, pdsc_adminq_isr, qcq); + index = pdsc_intr_alloc(pdsc, name, pdsc_adminq_isr, pdsc); if (index < 0) return index; qcq->intx = index; From patchwork Fri Jan 26 17:42:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13533076 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060.outbound.protection.outlook.com [40.107.220.60]) (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 865D1225AC; Fri, 26 Jan 2024 17:43:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706291003; cv=fail; b=QGlcsCyxpdIKF1EGYDOJmT4LcLRmZwzK3UR/TcdQJJoUwgJkZ/lqo5GXA8MJd40IuFsYRBvUhVuZw14I7l74yW56dbxUOo8fMSlXT5OiR8KDanhMQiFGvNsh8UXpxugns01iREIBpa4Rn9frqOjKwXPMa9YBSNLrzpPo2sVZ1K4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706291003; c=relaxed/simple; bh=Yt/iWHCRy7Zpz5dz46oPIvSEIPgTdiFsOIj1Lua1lhE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p4MgeZJwKoEs3r+iRbeLsMRdDMVw3LAHvvFicR1f2MrLEgakvaxnvQ+QwqwgsfIcpqNk4zwPOh9HmuaUJ0nlNi1SJjUcmfF9P+XVOaPho3BkE/wZFqQydnR5GH1bLptc7OgiSGUx2iUT5BlZKedagftDjzdglT5rhi96wJeKkqo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=bRPr3Mu/; arc=fail smtp.client-ip=40.107.220.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="bRPr3Mu/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q5UkmVdBD6nJ5tqKIF0pumAV74NDT3ElAhGL614SgIJ3e5LzbJqx9vOCPuS0Xx1V55G45NEEclWif0Ojbr5a7liUsQARGEn+eedWOopl6xMPfe5p+w3gDfXWgnsuSF0lM4isJ112iKIv712bpFshOvPV9WqaGDF4xxdfL2c8Zr9qsIuroU6XVV+wLT6vHWemtjZqTsdIeguJB4wPPEe3ok6Xu/sFg3ZVle0Vb4ToCbcABs+tiXI1wNoASTkYyEdK4hrdecieyiiX35OHuZBVUdLhZVIPvk+jUaBQZe635iZTJrBsHJCtIdVpwrVCqp5uT08+33GYEHXj4Lmsd1DOpQ== 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=MmsQyTgxUi/VSrFtNrqRVSmeh8weWgeO5L5FzqtbSJc=; b=PfMsI2MMcUL4yyeRoQ2UiyupuGX8zV5n+d6g7jWzBXszaV0SdvT9pNNMgpqMFADu4aKROXmweuzSmC7y4DHSJFUsU0qFTsjwhso/Em9hVmL4Z9efFz4kEJ1B2YDzAjfyTduMWOn33DVjAlJ1a7j4mk4nSvYBzNRVE00cs3HOq9lq57WsC2QyoRS6Mw3HxyLQP4hWijtvFkDSIzvJRrm1pgDQQoYJWQQunVOHDnuAyBNGaGDiyuEtbt2xdx8BwjKpablbCYd7hD96u5P/PqmNVzjAJGAQUJhFLtOJe41W2FzpZBqhhJIDfR/Cc85WrRURUVk8+oRkdBNVd1vwfai92Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MmsQyTgxUi/VSrFtNrqRVSmeh8weWgeO5L5FzqtbSJc=; b=bRPr3Mu/bBhSFY8L/nhihv2dbeIojJ04AJCukmRNHap2Nd7t6saYggorZgGnLhTL2fCIZ5TahaRt5KAcJR71otqw3Xoh1TFcJpllhTcPgYD4bEZgX/GLy1xETadJtT2GAFlEUFks6hPfzQdJfEXNExN91sS2jFuJ0n4PDmXUCIw= Received: from BN9PR03CA0633.namprd03.prod.outlook.com (2603:10b6:408:13b::8) by SJ0PR12MB6735.namprd12.prod.outlook.com (2603:10b6:a03:479::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Fri, 26 Jan 2024 17:43:12 +0000 Received: from BN3PEPF0000B06B.namprd21.prod.outlook.com (2603:10b6:408:13b:cafe::f3) by BN9PR03CA0633.outlook.office365.com (2603:10b6:408:13b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Fri, 26 Jan 2024 17:43:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B06B.mail.protection.outlook.com (10.167.243.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.0 via Frontend Transport; Fri, 26 Jan 2024 17:43:12 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 26 Jan 2024 11:43:10 -0600 From: Brett Creeley To: , , , , , CC: , Subject: [PATCH v2 net-next 04/10] pds_core: Prevent race issues involving the adminq Date: Fri, 26 Jan 2024 09:42:49 -0800 Message-ID: <20240126174255.17052-5-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126174255.17052-1-brett.creeley@amd.com> References: <20240126174255.17052-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06B:EE_|SJ0PR12MB6735:EE_ X-MS-Office365-Filtering-Correlation-Id: fe47bb1d-2271-45e0-ae4e-08dc1e9644a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gMMdkOxZ6ju9PO0C9fV9Pq1A5wmhceYfT5olHrFUOizeI3fWg1nIAOfOz40uz/ZP6QQqWlmBXbt2g6vvIcJOGd0c3loHppiAEVH9679zRt2/cdxpabQIYgQpNoq93viFq4VdbIksJCfmFflXHNj93dLUSMOU7TB3pIRb/IcIT5wPlQ8XqDgch1zf30BugVVqmgQF6f/YR+4NgOuvyWvdvW3T7fKVHVY4FX2/WQIY2Yd3Oxun8fDoUT/4aexhXwZWqM05rDoY6SAlMyH49xaIrXIp6xrAwyUXIuYtXNY0q41RhnjTuXho5Z99R3Y4Q5PVvQVoDDPAeRVLv8TK/7lAI6BRjQvQg3pr1pRMC/x98GSDwii5lHo0iO+X5+5fqrlCXFNylZQZfdV93Gi1GjSZ1p+5tVaMaqhYboh4PtLITj5IoLlFwIcz3YzRm5qmtnZNXReHPBsNxnDbRumGf/ug2a78znsisbrclN0KM4k2BmTDnAGrwDZ55t0tP1VPqmNg9EqPF8BdTWU8cPvwrPuwVsoOejVklHexsVb7GqSc9AfDtoFHHWz5UJcdSSy+2TkufybR0SVTfXLtdXCJcilEh3C5hzu4dXEKI78Jdtv/nV9csmBG8UGb4f0kOgXTVKaTNp3i2Rb8yitRpTKCrdSJSkYEpqWwaL5/ys5sIx1AerUTMyCDm2IoQ9JOUqZM5SG8oOVzK3IddZRuGsyzMpU9Pa1q7rEK+A5MNu1wLIc7YLGEbUfakWoaPzDp25coCBTgAqdo9vWiLJNhf6L887k7Dg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(136003)(396003)(376002)(346002)(230922051799003)(186009)(64100799003)(1800799012)(451199024)(82310400011)(46966006)(40470700004)(36840700001)(82740400003)(26005)(16526019)(356005)(1076003)(44832011)(5660300002)(336012)(40480700001)(36860700001)(40460700003)(47076005)(426003)(81166007)(2616005)(83380400001)(6666004)(86362001)(478600001)(54906003)(8676002)(4326008)(110136005)(70206006)(316002)(70586007)(8936002)(36756003)(41300700001)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 17:43:12.4960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe47bb1d-2271-45e0-ae4e-08dc1e9644a3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B06B.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6735 X-Patchwork-Delegate: kuba@kernel.org There are multiple paths that can result in using the pdsc's adminq. [1] pdsc_adminq_isr and the resulting work from queue_work(), i.e. pdsc_work_thread()->pdsc_process_adminq() [2] pdsc_adminq_post() When the device goes through reset via PCIe reset and/or a fw_down/fw_up cycle due to bad PCIe state or bad device state the adminq is destroyed and recreated. A NULL pointer dereference can happen if [1] or [2] happens after the adminq is already destroyed. In order to fix this, add some further state checks and implement reference counting for adminq uses. Reference counting was used because multiple threads can attempt to access the adminq at the same time via [1] or [2]. Additionally, multiple clients (i.e. pds-vfio-pci) can be using [2] at the same time. The adminq_refcnt is initialized to 1 when the adminq has been allocated and is ready to use. Users/clients of the adminq (i.e. [1] and [2]) will increment the refcnt when they are using the adminq. When the driver goes into a fw_down cycle it will set the PDSC_S_FW_DEAD bit and then wait for the adminq_refcnt to hit 1. Setting the PDSC_S_FW_DEAD before waiting will prevent any further adminq_refcnt increments. Waiting for the adminq_refcnt to hit 1 allows for any current users of the adminq to finish before the driver frees the adminq. Once the adminq_refcnt hits 1 the driver clears the refcnt to signify that the adminq is deleted and cannot be used. On the fw_up cycle the driver will once again initialize the adminq_refcnt to 1 allowing the adminq to be used again. Signed-off-by: Brett Creeley Reviewed-by: Shannon Nelson Reviewed-by: Przemek Kitszel --- drivers/net/ethernet/amd/pds_core/adminq.c | 31 +++++++++++++++++----- drivers/net/ethernet/amd/pds_core/core.c | 21 +++++++++++++++ drivers/net/ethernet/amd/pds_core/core.h | 1 + 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/adminq.c b/drivers/net/ethernet/amd/pds_core/adminq.c index 68be5ea251fc..5edff33d56f3 100644 --- a/drivers/net/ethernet/amd/pds_core/adminq.c +++ b/drivers/net/ethernet/amd/pds_core/adminq.c @@ -63,6 +63,15 @@ static int pdsc_process_notifyq(struct pdsc_qcq *qcq) return nq_work; } +static bool pdsc_adminq_inc_if_up(struct pdsc *pdsc) +{ + if (pdsc->state & BIT_ULL(PDSC_S_STOPPING_DRIVER) || + pdsc->state & BIT_ULL(PDSC_S_FW_DEAD)) + return false; + + return refcount_inc_not_zero(&pdsc->adminq_refcnt); +} + void pdsc_process_adminq(struct pdsc_qcq *qcq) { union pds_core_adminq_comp *comp; @@ -75,9 +84,9 @@ void pdsc_process_adminq(struct pdsc_qcq *qcq) int aq_work = 0; int credits; - /* Don't process AdminQ when shutting down */ - if (pdsc->state & BIT_ULL(PDSC_S_STOPPING_DRIVER)) { - dev_err(pdsc->dev, "%s: called while PDSC_S_STOPPING_DRIVER\n", + /* Don't process AdminQ when it's not up */ + if (!pdsc_adminq_inc_if_up(pdsc)) { + dev_err(pdsc->dev, "%s: called while adminq is unavailable\n", __func__); return; } @@ -124,6 +133,7 @@ void pdsc_process_adminq(struct pdsc_qcq *qcq) pds_core_intr_credits(&pdsc->intr_ctrl[qcq->intx], credits, PDS_CORE_INTR_CRED_REARM); + refcount_dec(&pdsc->adminq_refcnt); } void pdsc_work_thread(struct work_struct *work) @@ -138,9 +148,9 @@ irqreturn_t pdsc_adminq_isr(int irq, void *data) struct pdsc *pdsc = data; struct pdsc_qcq *qcq; - /* Don't process AdminQ when shutting down */ - if (pdsc->state & BIT_ULL(PDSC_S_STOPPING_DRIVER)) { - dev_err(pdsc->dev, "%s: called while PDSC_S_STOPPING_DRIVER\n", + /* Don't process AdminQ when it's not up */ + if (!pdsc_adminq_inc_if_up(pdsc)) { + dev_err(pdsc->dev, "%s: called while adminq is unavailable\n", __func__); return IRQ_HANDLED; } @@ -148,6 +158,7 @@ irqreturn_t pdsc_adminq_isr(int irq, void *data) qcq = &pdsc->adminqcq; queue_work(pdsc->wq, &qcq->work); pds_core_intr_mask(&pdsc->intr_ctrl[qcq->intx], PDS_CORE_INTR_MASK_CLEAR); + refcount_dec(&pdsc->adminq_refcnt); return IRQ_HANDLED; } @@ -231,6 +242,12 @@ int pdsc_adminq_post(struct pdsc *pdsc, int err = 0; int index; + if (!pdsc_adminq_inc_if_up(pdsc)) { + dev_dbg(pdsc->dev, "%s: preventing adminq cmd %u\n", + __func__, cmd->opcode); + return -ENXIO; + } + wc.qcq = &pdsc->adminqcq; index = __pdsc_adminq_post(pdsc, &pdsc->adminqcq, cmd, comp, &wc); if (index < 0) { @@ -286,6 +303,8 @@ int pdsc_adminq_post(struct pdsc *pdsc, queue_work(pdsc->wq, &pdsc->health_work); } + refcount_dec(&pdsc->adminq_refcnt); + return err; } EXPORT_SYMBOL_GPL(pdsc_adminq_post); diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c index 0356e56a6e99..f44333bd1256 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -450,6 +450,7 @@ int pdsc_setup(struct pdsc *pdsc, bool init) pdsc_debugfs_add_viftype(pdsc); } + refcount_set(&pdsc->adminq_refcnt, 1); clear_bit(PDSC_S_FW_DEAD, &pdsc->state); return 0; @@ -514,6 +515,24 @@ void pdsc_stop(struct pdsc *pdsc) PDS_CORE_INTR_MASK_SET); } +static void pdsc_adminq_wait_and_dec_once_unused(struct pdsc *pdsc) +{ + /* The driver initializes the adminq_refcnt to 1 when the adminq is + * allocated and ready for use. Other users/requesters will increment + * the refcnt while in use. If the refcnt is down to 1 then the adminq + * is not in use and the refcnt can be cleared and adminq freed. Before + * calling this function the driver will set PDSC_S_FW_DEAD, which + * prevent subsequent attempts to use the adminq and increment the + * refcnt to fail. This guarantees that this function will eventually + * exit. + */ + while (!refcount_dec_if_one(&pdsc->adminq_refcnt)) { + dev_dbg_ratelimited(pdsc->dev, "%s: adminq in use\n", + __func__); + cpu_relax(); + } +} + void pdsc_fw_down(struct pdsc *pdsc) { union pds_core_notifyq_comp reset_event = { @@ -529,6 +548,8 @@ void pdsc_fw_down(struct pdsc *pdsc) if (pdsc->pdev->is_virtfn) return; + pdsc_adminq_wait_and_dec_once_unused(pdsc); + /* Notify clients of fw_down */ if (pdsc->fw_reporter) devlink_health_report(pdsc->fw_reporter, "FW down reported", pdsc); diff --git a/drivers/net/ethernet/amd/pds_core/core.h b/drivers/net/ethernet/amd/pds_core/core.h index e35d3e7006bf..cbd5716f46e6 100644 --- a/drivers/net/ethernet/amd/pds_core/core.h +++ b/drivers/net/ethernet/amd/pds_core/core.h @@ -184,6 +184,7 @@ struct pdsc { struct mutex devcmd_lock; /* lock for dev_cmd operations */ struct mutex config_lock; /* lock for configuration operations */ spinlock_t adminq_lock; /* lock for adminq operations */ + refcount_t adminq_refcnt; struct pds_core_dev_info_regs __iomem *info_regs; struct pds_core_dev_cmd_regs __iomem *cmd_regs; struct pds_core_intr __iomem *intr_ctrl; From patchwork Fri Jan 26 17:42:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13533072 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2083.outbound.protection.outlook.com [40.107.244.83]) (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 B99A220B21; Fri, 26 Jan 2024 17:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290997; cv=fail; b=Y1dUg6DkoBXyzjUGcfJoi0hSbBMf2KMa7xBH2N8xQsvLtV3XbP+hN3QkFGe1i0B4nTwzvUWsT/Wn6eCbETauKoISGedDLYTiD6DjPDVFWi2Tk7qj4SHxqGdaaDM6HWuXDa62WDTeo85sm1hCz3hBWXSgEu6qMgGLZ2RDrbDYY/Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290997; c=relaxed/simple; bh=E48HFYY0unp4Iao9V+BF8Nds2Io55gi3kZ3S1Ogek4g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B6SuprQOnEcEAgVE92O/Dkk1P+HWjbra+QM40pkeio3tr6lWrm/TxwxZRSkGam20rtI2k2cSbal/hd/pdHbsho4NOrVVxQdmSRKVoVLVQQkYsrtW5595hAa09feNWO4GY/Vd0quC+lPyWC93kLBMWVHaUXqwxLtjBoVWo60Twxs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=WRjIFoxL; arc=fail smtp.client-ip=40.107.244.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="WRjIFoxL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NHQXfN4HKR0SVMdlPbtBqVK9/yM2ErtpJ4TpWjaU08KoT/Yx4UC7B0iZeaJHBGlR8zRDU8B/+9+H7xnPdTxfA3MyvC+XIgbM1TAbsOPhU1Q5VeMCgJiBq8LeF64JCtKspPEnOweE72wXIkgAFjI0e8a8OG0oikw9zgalhwLszCoyrRxZXLFqTkFbgNvFMULQYZagd7O2oFcgX9P3VpaOv1KksWFpq+waHpCoKbrpyJI2sq8FjFDzAreDn46BrRUHKJBDH8qMDoiiZ0Y+KvX6+8m1ETXYV9zXD3Aol1cy8ydFMKymYCkYImNb6ATLSB+eJBEgmh1jEydhUfJ1qVHkgQ== 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=bppOiY3C41yERXnK78IcQEdDUMHLRbfnf+jL2CRYZ6E=; b=RkrhofcQaELT/hmQYlcRiZVuleJEz6NKIhIq/WbMnuXT+CThEc4fCEEA7YRkThS3XBCBZq+SX8nZYNaXIibZ1NW024YtEOitnUyIxTXo9lSILNhmxu4auo1FxEc3UmmxfghnU4/zDAbCbDNbZ6iczhG6a5nm71NBSLwoL9yB2nCodCoNx6N5wbounr/PZujKkFJ8a/n8NiLLh63/TMnBLZ9qpE2tZP3xg/xv/3UP7HXQnROJ7OPiTaoIdr1XYlf3Ygu5VMFu0daiVv4hpQHjYNV9kneXAMEt4ghoA350foo+OvWwG0gZBy+OGRr342U0plIuoBybtTdCmJZn9uNoAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bppOiY3C41yERXnK78IcQEdDUMHLRbfnf+jL2CRYZ6E=; b=WRjIFoxL55Lz0e7VMsGblR6YouRNmNUjf8GeBPbhefOLo6LUQiX23JFLmfUEXdzKZL8V1u1dhyJ+vCHtzaJtQD8xH9INQ1E/Tta5IsaDyUVoTAkgS8nhioJ1unpR4xnOkldAOVDEOIU5AEbiuLD6/DVMRMfxCf6j0C01ABtZVKg= Received: from BN9PR03CA0632.namprd03.prod.outlook.com (2603:10b6:408:13b::7) by DS0PR12MB7679.namprd12.prod.outlook.com (2603:10b6:8:134::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Fri, 26 Jan 2024 17:43:13 +0000 Received: from BN3PEPF0000B06B.namprd21.prod.outlook.com (2603:10b6:408:13b:cafe::dd) by BN9PR03CA0632.outlook.office365.com (2603:10b6:408:13b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26 via Frontend Transport; Fri, 26 Jan 2024 17:43:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B06B.mail.protection.outlook.com (10.167.243.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.0 via Frontend Transport; Fri, 26 Jan 2024 17:43:13 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 26 Jan 2024 11:43:11 -0600 From: Brett Creeley To: , , , , , CC: , Subject: [PATCH v2 net-next 05/10] pds_core: Clear BARs on reset Date: Fri, 26 Jan 2024 09:42:50 -0800 Message-ID: <20240126174255.17052-6-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126174255.17052-1-brett.creeley@amd.com> References: <20240126174255.17052-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06B:EE_|DS0PR12MB7679:EE_ X-MS-Office365-Filtering-Correlation-Id: 7615052d-a83e-44dd-47f6-08dc1e9644fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R8JnWZMbijQCrA4icpa6d1dXcW7NOL9KjlDkNRy9SSx4jhHWvZDVFxdJz9ua5QxuWPH68mhWAlVAoksl+YfBoHhGihR1/rszjcfnxIc+ZBjzI0WF9x5AhMjNZzQQqwowVBz83vNfFoPQ8x4N2bEtFMmn4q/cmVv+SrFjHJI9nCuDD8XTfBZlkMmo0kClvgaITh1+V/XPgDv/NZ1i0gDqBltFxxdr4TQHn/UxcgIGLSYUpXTiWOSlD2Ca+CeqeoCFKIRLwnPiPZ2loosb+ABI44yacYOI+MXLk2PBZXZJXO4pYt9ZJAivPt9/yZEa70Urooixti634FWgt+Evb6j1ATGfPlJYl4MyjToeG79TtTPeTDXDpNFMrchNvim7JKNVWYJ/08EgtCrxOvmcBOgfHeCNcvMES63/TzLQBCDXdxO1WfsfAaGy6Gn/hJJ6Sy7CxO+cM1rynOOp1PzDxT2GKbH4oaQnXhd4yn/trFCV5PHB7EWpna76hWL8UynPI/siEWT0lxAEehAj3GUcG9aCn/VyNx7t37qpQEVR8JYbT6FZ1ft+4C+IO7uSMdmWkOBlH7y1MxnzlsfThPpvDpS1YiHnBybUk5MYIIJVXhugSHdvQNawYAfq3lno6GohO2n6cahoXHVqUSyC+kntnzjoD3pFGonDOf4NjSF+ViLueMIXQrUN699gf1hNSOfvu6iySXMUMwd0xrkbqBT4tzpzjWnKRIE2lf6qxamDDpVqARFEanlZEjbhrtGFn+dhF5BF8kXVlTwVbwjXdRqKfasDqA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(396003)(136003)(346002)(39860400002)(230922051799003)(186009)(1800799012)(82310400011)(451199024)(64100799003)(40470700004)(46966006)(36840700001)(5660300002)(8936002)(4326008)(40460700003)(8676002)(40480700001)(44832011)(2906002)(36756003)(316002)(54906003)(70206006)(70586007)(110136005)(26005)(86362001)(336012)(6666004)(1076003)(426003)(2616005)(478600001)(81166007)(16526019)(41300700001)(82740400003)(356005)(83380400001)(36860700001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 17:43:13.0898 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7615052d-a83e-44dd-47f6-08dc1e9644fe X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B06B.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7679 X-Patchwork-Delegate: kuba@kernel.org During reset the BARs might be accessed when they are unmapped. This can cause unexpected issues, so fix it by clearing the cached BAR values so they are not accessed until they are re-mapped. Also, make sure any places that can access the BARs when they are NULL are prevented. Signed-off-by: Brett Creeley Reviewed-by: Shannon Nelson Reviewed-by: Przemek Kitszel --- drivers/net/ethernet/amd/pds_core/adminq.c | 28 +++++++++++++++------ drivers/net/ethernet/amd/pds_core/core.c | 8 +++++- drivers/net/ethernet/amd/pds_core/dev.c | 9 ++++++- drivers/net/ethernet/amd/pds_core/devlink.c | 3 ++- drivers/net/ethernet/amd/pds_core/fw.c | 3 +++ drivers/net/ethernet/amd/pds_core/main.c | 5 ++++ 6 files changed, 45 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/adminq.c b/drivers/net/ethernet/amd/pds_core/adminq.c index 5edff33d56f3..ea773cfa0af6 100644 --- a/drivers/net/ethernet/amd/pds_core/adminq.c +++ b/drivers/net/ethernet/amd/pds_core/adminq.c @@ -191,10 +191,16 @@ static int __pdsc_adminq_post(struct pdsc *pdsc, /* Check that the FW is running */ if (!pdsc_is_fw_running(pdsc)) { - u8 fw_status = ioread8(&pdsc->info_regs->fw_status); - - dev_info(pdsc->dev, "%s: post failed - fw not running %#02x:\n", - __func__, fw_status); + if (pdsc->info_regs) { + u8 fw_status = + ioread8(&pdsc->info_regs->fw_status); + + dev_info(pdsc->dev, "%s: post failed - fw not running %#02x:\n", + __func__, fw_status); + } else { + dev_info(pdsc->dev, "%s: post failed - BARs not setup\n", + __func__); + } ret = -ENXIO; goto err_out_unlock; @@ -266,10 +272,16 @@ int pdsc_adminq_post(struct pdsc *pdsc, break; if (!pdsc_is_fw_running(pdsc)) { - u8 fw_status = ioread8(&pdsc->info_regs->fw_status); - - dev_dbg(pdsc->dev, "%s: post wait failed - fw not running %#02x:\n", - __func__, fw_status); + if (pdsc->info_regs) { + u8 fw_status = + ioread8(&pdsc->info_regs->fw_status); + + dev_dbg(pdsc->dev, "%s: post wait failed - fw not running %#02x:\n", + __func__, fw_status); + } else { + dev_dbg(pdsc->dev, "%s: post wait failed - BARs not setup\n", + __func__); + } err = -ENXIO; break; } diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c index f44333bd1256..65c8a7072e35 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -600,7 +600,13 @@ void pdsc_fw_up(struct pdsc *pdsc) static void pdsc_check_pci_health(struct pdsc *pdsc) { - u8 fw_status = ioread8(&pdsc->info_regs->fw_status); + u8 fw_status; + + /* some sort of teardown already in progress */ + if (!pdsc->info_regs) + return; + + fw_status = ioread8(&pdsc->info_regs->fw_status); /* is PCI broken? */ if (fw_status != PDS_RC_BAD_PCI) diff --git a/drivers/net/ethernet/amd/pds_core/dev.c b/drivers/net/ethernet/amd/pds_core/dev.c index 31940b857e0e..62a38e0a8454 100644 --- a/drivers/net/ethernet/amd/pds_core/dev.c +++ b/drivers/net/ethernet/amd/pds_core/dev.c @@ -57,6 +57,9 @@ int pdsc_err_to_errno(enum pds_core_status_code code) bool pdsc_is_fw_running(struct pdsc *pdsc) { + if (!pdsc->info_regs) + return false; + pdsc->fw_status = ioread8(&pdsc->info_regs->fw_status); pdsc->last_fw_time = jiffies; pdsc->last_hb = ioread32(&pdsc->info_regs->fw_heartbeat); @@ -182,13 +185,17 @@ int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd, { int err; + if (!pdsc->cmd_regs) + return -ENXIO; + memcpy_toio(&pdsc->cmd_regs->cmd, cmd, sizeof(*cmd)); pdsc_devcmd_dbell(pdsc); err = pdsc_devcmd_wait(pdsc, cmd->opcode, max_seconds); - memcpy_fromio(comp, &pdsc->cmd_regs->comp, sizeof(*comp)); if ((err == -ENXIO || err == -ETIMEDOUT) && pdsc->wq) queue_work(pdsc->wq, &pdsc->health_work); + else + memcpy_fromio(comp, &pdsc->cmd_regs->comp, sizeof(*comp)); return err; } diff --git a/drivers/net/ethernet/amd/pds_core/devlink.c b/drivers/net/ethernet/amd/pds_core/devlink.c index e9948ea5bbcd..54864f27c87a 100644 --- a/drivers/net/ethernet/amd/pds_core/devlink.c +++ b/drivers/net/ethernet/amd/pds_core/devlink.c @@ -111,7 +111,8 @@ int pdsc_dl_info_get(struct devlink *dl, struct devlink_info_req *req, mutex_lock(&pdsc->devcmd_lock); err = pdsc_devcmd_locked(pdsc, &cmd, &comp, pdsc->devcmd_timeout * 2); - memcpy_fromio(&fw_list, pdsc->cmd_regs->data, sizeof(fw_list)); + if (!err) + memcpy_fromio(&fw_list, pdsc->cmd_regs->data, sizeof(fw_list)); mutex_unlock(&pdsc->devcmd_lock); if (err && err != -EIO) return err; diff --git a/drivers/net/ethernet/amd/pds_core/fw.c b/drivers/net/ethernet/amd/pds_core/fw.c index 90a811f3878a..fa626719e68d 100644 --- a/drivers/net/ethernet/amd/pds_core/fw.c +++ b/drivers/net/ethernet/amd/pds_core/fw.c @@ -107,6 +107,9 @@ int pdsc_firmware_update(struct pdsc *pdsc, const struct firmware *fw, dev_info(pdsc->dev, "Installing firmware\n"); + if (!pdsc->cmd_regs) + return -ENXIO; + dl = priv_to_devlink(pdsc); devlink_flash_update_status_notify(dl, "Preparing to flash", NULL, 0, 0); diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c index 5172a5ad8ec6..05fdeb235e5f 100644 --- a/drivers/net/ethernet/amd/pds_core/main.c +++ b/drivers/net/ethernet/amd/pds_core/main.c @@ -37,6 +37,11 @@ static void pdsc_unmap_bars(struct pdsc *pdsc) struct pdsc_dev_bar *bars = pdsc->bars; unsigned int i; + pdsc->info_regs = NULL; + pdsc->cmd_regs = NULL; + pdsc->intr_status = NULL; + pdsc->intr_ctrl = NULL; + for (i = 0; i < PDS_CORE_BARS_MAX; i++) { if (bars[i].vaddr) pci_iounmap(pdsc->pdev, bars[i].vaddr); From patchwork Fri Jan 26 17:42:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13533073 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2048.outbound.protection.outlook.com [40.107.223.48]) (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 39F8B20B3D; Fri, 26 Jan 2024 17:43:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290997; cv=fail; b=j+79zkI5YttEwkwkhejxLX37TGj9gVFqAYzTRTfOAGRRJ0VF/PNHysFA/AwKEE50lZy1yGxcKnUUdAAp0hyxFCbeUtffZfPi1j/IQSKC0A2r7LLVFGrT0ylWGynT+rmYbJDHUG5N81SqpSykoPQXgLdhoH+SdunuB4JxDEU1kG4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290997; c=relaxed/simple; bh=OcihoKLnFzEjF+DoPWaTm2RPO77zkUL8IQBfQ3SxmA4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LM3rF7qrkbMm4y9O6fy4efM/FQAfhHMfBEyTXrGXwqV2o0TYNvbvxBO+ye6PhuCPcKw5vJwUKelecgNkMv+pjnmA6mqiJqjL7iRIcmbGG08RlqyYg9INDBfaGP2fRYOY3ScxsMiq2YZZNJ3PwOEK+jUFaejiTJYAtR1dZQj2XcU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=AYnhay2l; arc=fail smtp.client-ip=40.107.223.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AYnhay2l" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b5zcb1rurCvoSGKrN4vVnRh0aqX0gYOGkFPxvANblbcHPtNGSThIGQzXgI7t4YGHHbNdn9z2B8YfoAwVNyGT+gsUM4E3l5qVeQ9aKyNgTm7ndeAhyvVGzfd97e22UDBld1QNKiUf059M6D9lDYJdp03HSePihfwqOoboDhoGPIR7IijkzMvODOXdAbOblnzVVxXvzs45EGdFjMpSGsr4AKa+43yPBbBQucnq98EqDs0133RsRTjQ4wV7wzVh/3j5W95oGHoNEoOXdodxnLz1inNA1fr8pMIPu2RdQgqmJCfCIG36OBA/+8MEkN6t0iEwUtBarljoCnoQT7DNobU+3w== 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=hT2A6oQ43hhRBwlGJPnzjjs8HzMfRfhrNXe8X+thyTw=; b=MNlEIouPNLnMfCy25scW/l5AD/OuG2zfcQRVDJddG/LlJt3xkfoSyD+XAMPBpi+E8qAkoTmgFQnQ1F6DnZYrBy4o/zDuxzVl19Xw2QKgm13EVPckVDf8if+WQdYQxqiX4iF2BQsgcsmXxkGBeEjnoR12P4Eozt/49xXaLBBgWK/FRkweyERIa/TlZ/O2L+XrlMsntzNw8tuNONqyPpOtJFz0qVomM/U6BVi7VnuTFqWSp6gDre9bJ+K+t2+CVyCIGmGfkOR2zNRaEwsrdPbct7y1qsBE9ZDEJBg0FufNav/sH9FuUDEX8pvuLEvQTjlE6HJtG0H14XAiPoCC1E1XdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hT2A6oQ43hhRBwlGJPnzjjs8HzMfRfhrNXe8X+thyTw=; b=AYnhay2lnJ46FMP2AAbUvcYmn8ZCPF/A2W0EY4Xs0Nts4GwC0Okgc/ez+HnzqR4l3j/gi25THOtzw7yr17MOInFZLxpOD0OM4MVkqeq68VKJ6JcC4Eleevw1yvIApbLImLf0OiJaQvyWhIApRYKUSuRkFyfrA3TatRzPjzaR6TI= Received: from BN9PR03CA0658.namprd03.prod.outlook.com (2603:10b6:408:13b::33) by PH7PR12MB7427.namprd12.prod.outlook.com (2603:10b6:510:202::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Fri, 26 Jan 2024 17:43:13 +0000 Received: from BN3PEPF0000B06B.namprd21.prod.outlook.com (2603:10b6:408:13b:cafe::92) by BN9PR03CA0658.outlook.office365.com (2603:10b6:408:13b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Fri, 26 Jan 2024 17:43:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B06B.mail.protection.outlook.com (10.167.243.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.0 via Frontend Transport; Fri, 26 Jan 2024 17:43:13 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 26 Jan 2024 11:43:12 -0600 From: Brett Creeley To: , , , , , CC: , Subject: [PATCH v2 net-next 06/10] pds_core: Don't assign interrupt index/bound_intr to notifyq Date: Fri, 26 Jan 2024 09:42:51 -0800 Message-ID: <20240126174255.17052-7-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126174255.17052-1-brett.creeley@amd.com> References: <20240126174255.17052-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06B:EE_|PH7PR12MB7427:EE_ X-MS-Office365-Filtering-Correlation-Id: f6ed66b8-ae34-422d-a71e-08dc1e96453e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WH+QADN86ZErcIwgVEC7gRQW8cOP8DK03l6+MMNlnGzKKjS5VdD28FCoeQq6mdD8oyggKnmUGAaPUqlEaXREOLZMYmPF82fTLoWczh7o1uGx1eYesZwyGUXjQa1E6AQTUe/sT7y6yRBZd18xHUjiBQIkeBiQwJzf+/qjvsrx9zHLnJBfSF/5y6vjtchFLtYXZbx4egPhI3K1M8Dipwv2DaahjOBqKSUddlbIm8jwHGYCAW5PDs9QhVjiUwDGBdVZhl2I/EVDK91wwWwH2vDujB7H+9Tue4xLeN+DBz2Zx0zLNUsyGYPxzhGeUUWhLNcz9ZhyRAqzNstHQJYEki55bP/AhuTlqLxYxOx3oBhmOZNWZ+7OdlQpxgchdF0SddR9Y36F6UWzLaz8Igq0UZj31rjS7ZwszPkyTBgs/RDgoUDYQ7op+zD0YyaKE3eayNbrMUrI8SdeCKeEmb/kFDFqFId34aNKqo5PPlDJOP9Sk75ljQSxto0paR//uknM6fob6RBi2M9IuSLy2M4R8Ei6ga4OO2EgETW0ZdiTles6NndinKfYL1lnOWP3RYNm6zAr3KhTHMG27ufhy58mv1Nvz28xAODv2zpMJTsWUR6VWE/myptH9La2LAph1utKyI+rQwJH3CDHcbu6kpg/2pNrbJ+/MuQH6T4bvdWoE/+4WALd0mdeqtaQtGW2u3LDreFdwWLPrHj/7O+krBetfCOwxvsrjA0ZzYhIgZM7BBQNrqFzgQR2np8Q0YepPQHREfY4nNG0N/Hdf069DXblLLeVLA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(346002)(376002)(136003)(396003)(230922051799003)(1800799012)(451199024)(82310400011)(64100799003)(186009)(46966006)(36840700001)(40470700004)(5660300002)(2906002)(41300700001)(356005)(81166007)(82740400003)(86362001)(36756003)(478600001)(16526019)(2616005)(1076003)(426003)(26005)(336012)(6666004)(36860700001)(47076005)(83380400001)(4326008)(8676002)(8936002)(44832011)(70206006)(70586007)(110136005)(316002)(54906003)(40480700001)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 17:43:13.4960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6ed66b8-ae34-422d-a71e-08dc1e96453e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B06B.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7427 X-Patchwork-Delegate: kuba@kernel.org The notifyq rides on the adminq's interrupt, so there's no need to setup and/or access the notifyq's interrupt index or bound_intr. The driver sets the bound_intr using qcq->intx = -1 for the notifyq, but luckily nothing accesses that field for notifyq. Instead of expecting that remains the case, just clean up the notifyq's interrupt index and bound_intr fields. Signed-off-by: Brett Creeley Reviewed-by: Shannon Nelson Reviewed-by: Przemek Kitszel --- drivers/net/ethernet/amd/pds_core/core.c | 5 +---- drivers/net/ethernet/amd/pds_core/debugfs.c | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c index 65c8a7072e35..fe7e1d10224c 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -129,6 +129,7 @@ static int pdsc_qcq_intr_alloc(struct pdsc *pdsc, struct pdsc_qcq *qcq) if (index < 0) return index; qcq->intx = index; + qcq->cq.bound_intr = &pdsc->intr_info[index]; return 0; } @@ -222,7 +223,6 @@ int pdsc_qcq_alloc(struct pdsc *pdsc, unsigned int type, unsigned int index, goto err_out_free_irq; } - qcq->cq.bound_intr = &pdsc->intr_info[qcq->intx]; qcq->cq.num_descs = num_descs; qcq->cq.desc_size = cq_desc_size; qcq->cq.tail_idx = 0; @@ -433,9 +433,6 @@ int pdsc_setup(struct pdsc *pdsc, bool init) if (err) goto err_out_teardown; - /* NotifyQ rides on the AdminQ interrupt */ - pdsc->notifyqcq.intx = pdsc->adminqcq.intx; - /* Set up the Core with the AdminQ and NotifyQ info */ err = pdsc_core_init(pdsc); if (err) diff --git a/drivers/net/ethernet/amd/pds_core/debugfs.c b/drivers/net/ethernet/amd/pds_core/debugfs.c index 8ec392299b7d..dd6aaeecfe0a 100644 --- a/drivers/net/ethernet/amd/pds_core/debugfs.c +++ b/drivers/net/ethernet/amd/pds_core/debugfs.c @@ -105,7 +105,6 @@ void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq) struct dentry *qcq_dentry, *q_dentry, *cq_dentry; struct dentry *intr_dentry; struct debugfs_regset32 *intr_ctrl_regset; - struct pdsc_intr_info *intr = &pdsc->intr_info[qcq->intx]; struct pdsc_queue *q = &qcq->q; struct pdsc_cq *cq = &qcq->cq; @@ -143,6 +142,8 @@ void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq) debugfs_create_u16("tail", 0400, cq_dentry, &cq->tail_idx); if (qcq->flags & PDS_CORE_QCQ_F_INTR) { + struct pdsc_intr_info *intr = &pdsc->intr_info[qcq->intx]; + intr_dentry = debugfs_create_dir("intr", qcq->dentry); if (IS_ERR_OR_NULL(intr_dentry)) return; From patchwork Fri Jan 26 17:42:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13533075 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) (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 F209821A1A; Fri, 26 Jan 2024 17:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706291000; cv=fail; b=dQv9vf5N+V13DuMDNCU0st3PFA83LIlPRrOtTBYOZA/W/etzfbleaG8hhEXNicUoSyz//68pBXvRXjWLJwEEbYYPB+hTcglw4Xxzw9h5hKIgo4xQGQQ9bI+M4m2gIScl69xn/tCzKyqCjWv3+y6Ldy3hYmdkHldNd3Y+MXJGh7s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706291000; c=relaxed/simple; bh=U6xPfMRjJEuLVn/pfcA4LRFtqgl6iM5I1JOTTyqSCzM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N+oPBF3/AvJyw4Wi9eUeVeN79TyKAUpV5WHLHPDOpLfPfN5P/+FMhmFy2dXcj4y9ETYyeKu1Lc4CiarNa2ay+PH2a4wKU6ZmWp0/dnuonLMq6cO6THrj1F3edRhISXfo1i/A7u2/xPGyE52Ls2gmIRSgE1LOB0HdxsupYKnn5qM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=jlyXhMlW; arc=fail smtp.client-ip=40.107.92.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="jlyXhMlW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UJ+sIIw8jVtrH7ZwhYn14P2+1tQ8D/QT0GOnVsXV/w+fEK25CyP2XdbjXV5OHcAk9H4iGvLk4KwuBaYfCDtlmDUXqzvKdo8Vtv4Eye16FVN8TPZmEU7cJ6rG+iyft5mpEdq1PhFAtqIiU6+TRyCf1Ql3iy4ok6IdIuV0lMnWRv9S7rtvyb2A0ExHO9lXUqD5CMZNBORjjyg7K12H1SU8vMmBqBI98Ank9fp4iNJ87poCxUC9wXZGNHBS2L+hhuwFIr9GNa9xum4A8e/wUKJKVAv5C8HR4FYRM9IqTUhfrZ+Dho0CBihbramOFcwUloomXk6ijrIlnssrzkvPMwwScA== 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=T2Z2QMGoaFhEwOf6ddByjZdN3SIzdKkrE8cQnwvgOZk=; b=GZV9yK+QQSysRj2PtOgx9/7krbwJ7l7+NyKMD2xK5QeQBcpHVpaMY+uQqGUWeJlvEyhQgPK2uuKtyXQ4ow7qLyd1U2uUlE1MgJTLCV9WzUsVQR9mIcE8KSboL9Kcb5vJIsN6IFS+sWjTHyGFoWBhk4q9Kd6BRUASxbVsAgvN5H9Cyo9RlMvtxwF1fpHYOX7e0s0YzdPZW1v46+zZWNXlyN8VsqBpYyjHdwGV1QHMJjnjVlveKanQd+7z50M2SnA9jeDwDxv+sTUoiL2VAw6rZACmOmG0MOEnSWXFiBWVl82J37yewWqk3EtZIqhEgtscQ/5vO8wHzSlrOloyrKRp2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T2Z2QMGoaFhEwOf6ddByjZdN3SIzdKkrE8cQnwvgOZk=; b=jlyXhMlWKttgMs2pPEcgDAZXyKz/IdY8NzN6tfvlh8jlu1AVi2Te/uAIRrbUWivA6jsFselrcQGwCZ499rQ1m2hy9kkuLc/ZEWpNr/Q3RhrdetUrrtao1t+/tJW8UKivFy9phbSmz0lh3BsV3qnArvnbIBO5NM6LcEhmyYaymkc= Received: from BN9PR03CA0649.namprd03.prod.outlook.com (2603:10b6:408:13b::24) by PH7PR12MB6563.namprd12.prod.outlook.com (2603:10b6:510:211::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26; Fri, 26 Jan 2024 17:43:14 +0000 Received: from BN3PEPF0000B06B.namprd21.prod.outlook.com (2603:10b6:408:13b:cafe::f8) by BN9PR03CA0649.outlook.office365.com (2603:10b6:408:13b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24 via Frontend Transport; Fri, 26 Jan 2024 17:43:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B06B.mail.protection.outlook.com (10.167.243.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.0 via Frontend Transport; Fri, 26 Jan 2024 17:43:14 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 26 Jan 2024 11:43:12 -0600 From: Brett Creeley To: , , , , , CC: , Subject: [PATCH v2 net-next 07/10] pds_core: Unmask adminq interrupt in work thread Date: Fri, 26 Jan 2024 09:42:52 -0800 Message-ID: <20240126174255.17052-8-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126174255.17052-1-brett.creeley@amd.com> References: <20240126174255.17052-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06B:EE_|PH7PR12MB6563:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f977373-b65b-4525-de6c-08dc1e964596 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EEP393KoWddaXTsEKVUfDglAstH66wN81XmrlHb7cr5xJRoBl4+AagxD7nDUZxpPoyEUXrHfAGv+KROP2oYIIcgUY/nsJfgLVzTf29pDuUBx61zdn1mD3JJuTGty0+Shan8oPT5iX+Tkh46i/zSaOSpkQaJM54mRNB9XMSTEKq0MeoOFE2EO2UwZMPVfbYewYKDe0YUTsXWJB7C3OVl6sA/z84UTqgCFwR1wfQYE68YwUZ5GkCirsmR3H+L2+dJI64yqn/WP5Gld6dJ/IwsKy/yxGtQ5z+IVh3yEP4KJZnQVXu96Q5nxT+wN9ZOx+l7fKnD7OZERY7MfMiXsNUh3d3imh9EkJm7KRXMvYPE3fXpth/EC7rMf1kG+3CHMUaN7GY37SYw7i7k1mUEgH9iiB5Uwg8Dpqu5U4330OslrfHQEfAxpm0GYQz3qg8FDkaDaNSXo5O6rvDLe7OQ2oZdoDJHASPllSwlmNkaCH/II5Dw/Fl4f50KMmnT1mt+LJQuM7pID6kZLKMc6REqd4ttgIgbUwbQgSPexT6JiEHmc/OZMYXSxCguIKVujxMiNFEN9TjLba2sESh4Mpnrc4vi2UA1h9YyXESqoPrSN47MIopg9QNNn6zNzOj+Whf/NfrgcAkLn7d7NSFNC9umQxvPWoqJPc2aoHGdl6drxHIkbBrIuEGjt5ZKi/p0QrRR4e+04gtoWKcd9Q37jP7rrNf/MDAHARG61qsM+hhUjHzgE3s+mnRZn/DUfWx73tBB1g04wxaFkPBrqyuBsuXn6n2Absg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(396003)(376002)(346002)(136003)(230922051799003)(1800799012)(82310400011)(451199024)(64100799003)(186009)(46966006)(40470700004)(36840700001)(40480700001)(40460700003)(336012)(426003)(83380400001)(47076005)(86362001)(1076003)(2906002)(36860700001)(41300700001)(81166007)(16526019)(6666004)(36756003)(2616005)(4326008)(478600001)(82740400003)(8676002)(8936002)(26005)(316002)(54906003)(70206006)(70586007)(44832011)(5660300002)(110136005)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 17:43:14.0741 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f977373-b65b-4525-de6c-08dc1e964596 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B06B.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6563 X-Patchwork-Delegate: kuba@kernel.org Unmasking the interrupt during the pdsc_adminq_isr is a bit early and could cause unnecessary interrupts. Instead always unmask after processing the adminq and notifyq in pdsc_work_thread()->pdsc_process_adminq(). Also, since we are always unmasking, there's no need for the local credits variable in pdsc_process_adminq(). Signed-off-by: Brett Creeley Reviewed-by: Shannon Nelson Reviewed-by: Przemek Kitszel --- drivers/net/ethernet/amd/pds_core/adminq.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/adminq.c b/drivers/net/ethernet/amd/pds_core/adminq.c index ea773cfa0af6..c83a0a80d533 100644 --- a/drivers/net/ethernet/amd/pds_core/adminq.c +++ b/drivers/net/ethernet/amd/pds_core/adminq.c @@ -82,7 +82,6 @@ void pdsc_process_adminq(struct pdsc_qcq *qcq) unsigned long irqflags; int nq_work = 0; int aq_work = 0; - int credits; /* Don't process AdminQ when it's not up */ if (!pdsc_adminq_inc_if_up(pdsc)) { @@ -128,11 +127,9 @@ void pdsc_process_adminq(struct pdsc_qcq *qcq) credits: /* Return the interrupt credits, one for each completion */ - credits = nq_work + aq_work; - if (credits) - pds_core_intr_credits(&pdsc->intr_ctrl[qcq->intx], - credits, - PDS_CORE_INTR_CRED_REARM); + pds_core_intr_credits(&pdsc->intr_ctrl[qcq->intx], + nq_work + aq_work, + PDS_CORE_INTR_CRED_REARM); refcount_dec(&pdsc->adminq_refcnt); } @@ -157,7 +154,6 @@ irqreturn_t pdsc_adminq_isr(int irq, void *data) qcq = &pdsc->adminqcq; queue_work(pdsc->wq, &qcq->work); - pds_core_intr_mask(&pdsc->intr_ctrl[qcq->intx], PDS_CORE_INTR_MASK_CLEAR); refcount_dec(&pdsc->adminq_refcnt); return IRQ_HANDLED; From patchwork Fri Jan 26 17:42:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13533074 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2089.outbound.protection.outlook.com [40.107.243.89]) (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 320A6219E0; Fri, 26 Jan 2024 17:43:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290999; cv=fail; b=rfqPQbedfhMl0m+0oWPSAIp7RjQXQupZ1tyVw5APqsAyHRtHK1y6NJmn51E+E9/8wKfuFG8OpRTakQKnQQB99mvpP9oakcidyTUKEHAM/rFWtgnOgpf5We1fv7L4E0SmNjKQ+7znQxfcvqGMbJM/j9gVyXyDG2Gp5MNOELqWUsA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706290999; c=relaxed/simple; bh=VqWB1kkSrvJyzbf+GfkH9BEeo9DF45blLgCZVzfVck8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oNHkC0pX1uols7ipNqjhBaLz19J9cdJJ/m9ku6WZ7e3kd/ungssLqDpQ8nLBIHVTCgtRFYvPEYHkTZu/Wzo1jXNn4Ua+XrEkxcRZ5g+OKJ7zsezQVsH4WgWkCVt0bMNcWS1BfFgIbU4KrqQ4hwMeXTF8rzX2DUmzvs9pLEAbAig= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=s+2XPMlQ; arc=fail smtp.client-ip=40.107.243.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="s+2XPMlQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AE2rYYuumi1kFBwWF92EgLejgO8lWtdVenoQ8l3TkvOJ0KqZDhnlLvrfuYYQDSdgo9ni7JnyVADwj03sxFOjKpzspzl5d7zURWnt90MSZBpqNVqpEht9brREfhmIO+Ffa0pwq3TzxtPdanEatYfImtcnUxkyeXQEERfekkLge+S22nTWcPOj1TTAP5+XVHgaxLcwfqrdZ5KRqPf+wLb5EH2K7Aopmtvr5R03WelmUGs6B9oi5nA2ISWghUI29XdO8DVZg70saBzRPmy7J3jVWhDWqURSDkhIjmWCvUA6Vm+LiIBimshw07dSqF4eoRqmvXbTKAN8ybejDKcVkRO8Jw== 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=VK48TDjo5Ij7e6tm+AyS2U+SvbbvXi4xGAc71IdoQKE=; b=du1jJcErbUJAH6PgPPIi7DWPY5RsPBf6qzVK82nUGyAjKEqLvweKc6KrLrf+rAXiebmNewL+qrx292k8NrJFsHKKNxpG6Xuub3XCQdjxGNhHYlmgB8YkvlOyXzRfN5xxbaTl5gxqzSL9nvbCQ8+dAMP5GB2zm0GPlWOul6d7cCPcQRNIJVIew63GqfeHRC8XczEm4kiiztZlnML75gCl32Kjcr2P/RX6j2ucrAHBs0JTuZDVU7Jv+5UHXVWE6o43pik7f/RhDGdWMELER4+Y/BkQXvKHiVFq5YuZK6R9dliuoaL/9E3MEIB0/XEeL8DxdzfOAIXHOPLeK9cCvQ6VHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VK48TDjo5Ij7e6tm+AyS2U+SvbbvXi4xGAc71IdoQKE=; b=s+2XPMlQEnv+bG01GmZWshIpmuw0gUXUg8s5BGxwl5q4bOWgbLR3BlAy6c/8+ZcEASC9zwPU0Wx3x+GwsQEAvCn5uzCDWlyIuZCN0gWxBPlY9XKjMP6OOlKw5XfMCIKJJsHeW30jJEh49eSuKAsfKRYVM3bnHGmZM9scRjcqdjQ= Received: from BN9PR03CA0365.namprd03.prod.outlook.com (2603:10b6:408:f7::10) by DS0PR12MB7828.namprd12.prod.outlook.com (2603:10b6:8:14b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26; Fri, 26 Jan 2024 17:43:15 +0000 Received: from BN3PEPF0000B06F.namprd21.prod.outlook.com (2603:10b6:408:f7:cafe::97) by BN9PR03CA0365.outlook.office365.com (2603:10b6:408:f7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Fri, 26 Jan 2024 17:43:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B06F.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.0 via Frontend Transport; Fri, 26 Jan 2024 17:43:15 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 26 Jan 2024 11:43:14 -0600 From: Brett Creeley To: , , , , , CC: , Subject: [PATCH v2 net-next 08/10] pds_core: Fix up some minor issues Date: Fri, 26 Jan 2024 09:42:53 -0800 Message-ID: <20240126174255.17052-9-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126174255.17052-1-brett.creeley@amd.com> References: <20240126174255.17052-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06F:EE_|DS0PR12MB7828:EE_ X-MS-Office365-Filtering-Correlation-Id: 19264248-ac0d-4d1f-dcac-08dc1e96464a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k7IRl+CjilliTT6of8NxJvZMBAQTfNwZNUP/xXR7AhcvV/p9lyh3IKRkWnnoyCPP3tMrzK1UNr3pOn3epzjXKBkibvDSKyaJ993caUYzrAo6cOyeEIgHOYrhoXQS74eWls0pMiSvQl/JzSba+rwMzwhr2dCBVglQdEsAomwfT/OMOzkFPlj9P62YmPOWm0MI/w9Gn/D4Knb5YeY3bRVnfIjwl2/akUHTWbgkotLjbs+qIGY44ivxkuhthyCD9vNPqFdpidVedPlmBQW+W7ThLqPfRuj8mQM15lSlu1kUX/2/nYTU62AO3OVayQlp4WOKti9q+CZKUcisXiSt/iLUCWmx4lcOTVOJH1qZpts1bwSwpoaN5KnjRzUJwYDtPjM0SGFI6wH9O+Td1SfWbTiAD0+gy9gsALqUgt06ki0V+kpRW2SoVhFLCczlinJcB9O6SjGqZyesEBH6SyHcrHMi8aA/pb0N0LIkYnH+ubPBdoc4X9AxTZiqsaOjsH63gN4un2/QMc+gRTuhs3BVIEEnKPhSCKBXDnNm20h8sxY5UvzpEVj0mdKQC3WoWWHOWJypThvY7kiy7jeG6P9Vmo57XSE9i7zvR1SkLQdgB+LWt+vd41As1gCIsDxXGgT191g9WBhOGSnsKnY4KTZccdk3S5hfRBqNr0cin2/HZOkI80luAdZ52pJk6tlwtrhIA8R8fZ83NAG80oAjdFThA8rGTS+A/A0WJIR2btzsZtlLth0= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(39860400002)(136003)(346002)(376002)(230922051799003)(1800799012)(186009)(451199024)(82310400011)(64100799003)(46966006)(36840700001)(40470700004)(40460700003)(40480700001)(41300700001)(83380400001)(36756003)(86362001)(4326008)(36860700001)(81166007)(2616005)(16526019)(1076003)(26005)(426003)(336012)(82740400003)(356005)(110136005)(478600001)(2906002)(8936002)(5660300002)(316002)(70206006)(6666004)(70586007)(54906003)(44832011)(47076005)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 17:43:15.2538 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 19264248-ac0d-4d1f-dcac-08dc1e96464a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B06F.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7828 X-Patchwork-Delegate: kuba@kernel.org Running xmastree.py against the driver found some RCT issues, so fix them. Also, if allocating pdsc->intr_info in pdsc_dev_init() fails the driver still tries to free pdsc->intr_info. Fix this by just returning -ENOMEM since there's nothing to free at this point of failure. Signed-off-by: Brett Creeley Reviewed-by: Shannon Nelson --- drivers/net/ethernet/amd/pds_core/debugfs.c | 5 ++--- drivers/net/ethernet/amd/pds_core/dev.c | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/debugfs.c b/drivers/net/ethernet/amd/pds_core/debugfs.c index dd6aaeecfe0a..d56fdbb4cdb9 100644 --- a/drivers/net/ethernet/amd/pds_core/debugfs.c +++ b/drivers/net/ethernet/amd/pds_core/debugfs.c @@ -32,8 +32,8 @@ void pdsc_debugfs_del_dev(struct pdsc *pdsc) static int identity_show(struct seq_file *seq, void *v) { - struct pdsc *pdsc = seq->private; struct pds_core_dev_identity *ident; + struct pdsc *pdsc = seq->private; int vt; ident = &pdsc->dev_ident; @@ -102,8 +102,7 @@ static const struct debugfs_reg32 intr_ctrl_regs[] = { void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq) { - struct dentry *qcq_dentry, *q_dentry, *cq_dentry; - struct dentry *intr_dentry; + struct dentry *qcq_dentry, *q_dentry, *cq_dentry, *intr_dentry; struct debugfs_regset32 *intr_ctrl_regset; struct pdsc_queue *q = &qcq->q; struct pdsc_cq *cq = &qcq->cq; diff --git a/drivers/net/ethernet/amd/pds_core/dev.c b/drivers/net/ethernet/amd/pds_core/dev.c index 62a38e0a8454..b237cea65a5e 100644 --- a/drivers/net/ethernet/amd/pds_core/dev.c +++ b/drivers/net/ethernet/amd/pds_core/dev.c @@ -348,10 +348,8 @@ int pdsc_dev_init(struct pdsc *pdsc) /* Get intr_info struct array for tracking */ pdsc->intr_info = kcalloc(nintrs, sizeof(*pdsc->intr_info), GFP_KERNEL); - if (!pdsc->intr_info) { - err = -ENOMEM; - goto err_out; - } + if (!pdsc->intr_info) + return -ENOMEM; err = pci_alloc_irq_vectors(pdsc->pdev, nintrs, nintrs, PCI_IRQ_MSIX); if (err != nintrs) { From patchwork Fri Jan 26 17:42:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13533078 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2061.outbound.protection.outlook.com [40.107.220.61]) (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 2CDBC22638; Fri, 26 Jan 2024 17:43:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706291004; cv=fail; b=U+WAEY7j8AO8CdMtuOIkfytl0tEySeLGgYehJs64CHs6UR8I6T08npx7s/2yhcYSmACWk7DwDihsQ5gNYFWGEEtuUwWsXalt85u1Ii4j5R+E0OAKxYZ8F7n3x1dMkX+eAkUkSKpwGALA+RR1kg2CqMQnl1jl3CxLkEP9eK0SvmE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706291004; c=relaxed/simple; bh=ZT3zWW4sUMnqUE1Q4HxG92WEAz4elCEDCDJr9KilCDY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HL6zuZtVROPknpknI8g7y7jJOMICF59aVqlwNW/bD9CqubpFRIWj4MHkHG9PGbrqYlI5O8bBKySbz3P01zjyKaPfwEhtQ4Q3zKhMzwpsKCYGTb3JYIgcPa9rV0aHk+TB7s5e1sJdHCdyVEMinjo/y48nsvP1wRMX2Blz4a5RvVo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=vd+klN+x; arc=fail smtp.client-ip=40.107.220.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="vd+klN+x" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JsBs65pMFo8Anf3as2MRCuAhvfDHx4aUjuZnYyxP0skKSA8/yB7TqZOPX4RJlKzi6YrY2LlAcgIMJpRiqiIxwD8THMn2HwjRC16qFpQ0FcA4Q70Xfl7oPEHuHJC3MG9fZ3QbIDTWQXzY2uz/gxRonNfYwFqocIhYdSIJ1SPzFW61iJFnXTQChuOjZxE8zFyYrTTvtpjb5z/dAbUKPJOF02E22pEURrz2ySmXnlOt8A7H4dA6yHRMk90T1J+cfcyb/xuRd7lmgvzyLXlJlrQcgIjnBuQmPyZ+Zu7BKRMUA9mcJIkO4qygkMS472tSwxhAQqCbK1gnMEsTsVdtSrZmWg== 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=XNN3W/sE5pSa2TgPoy2nMr8kiPuQif8o6FDPA+HPwKw=; b=fhggeM3is3U5N3a2Jv2BX+gBdG2OMeaHWDV+P4BNCJ7liwWPrIaSwajBbXDhqjuG77xwUZHbttrT+ocmvlAerx+Sh2PJVbvG1ToV0Zdii8vyTm211ihF/E7weF7/cN8OzwmJJnjfZxWbRMPqV1PQLM38LIKyA/PnhXgKR2ZgpPy6GRBqw0AIsYlcO2rWf2TB6rEon5BG6TsuoPMulnz61M+Gifl+QewdHz98rSK2aaCeX870XU7KzUea8xWpLYMIvjaA1sA0nLzAuQdxUbPfoaW7AEklOYbPyOSqo2RbHeSWtXZD/xH4S5fMX8pUF73gZn4OCvg4ieB/DyYNODxU0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XNN3W/sE5pSa2TgPoy2nMr8kiPuQif8o6FDPA+HPwKw=; b=vd+klN+xXS6AiHZBdUNFsX/rGN1/z3B1TR/pjTFSLwOD4fcqfPcdMOLqwF1bywtdZKrj0Wg87HtamJg3yvuKudMtU9frt743Z2PkbfkJ9hLOfuHYyVrVLACJKFPGX2aenTcwv1B363RhvrIhyyOzDTlkOyzGNrDr7K7K4+TRuSg= Received: from BN8PR15CA0049.namprd15.prod.outlook.com (2603:10b6:408:80::26) by SJ0PR12MB7460.namprd12.prod.outlook.com (2603:10b6:a03:48d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Fri, 26 Jan 2024 17:43:18 +0000 Received: from BN2PEPF000044A8.namprd04.prod.outlook.com (2603:10b6:408:80:cafe::a3) by BN8PR15CA0049.outlook.office365.com (2603:10b6:408:80::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27 via Frontend Transport; Fri, 26 Jan 2024 17:43:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A8.mail.protection.outlook.com (10.167.243.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7228.16 via Frontend Transport; Fri, 26 Jan 2024 17:43:17 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 26 Jan 2024 11:43:15 -0600 From: Brett Creeley To: , , , , , CC: , Subject: [PATCH v2 net-next 09/10] pds_core: Rework teardown/setup flow to be more common Date: Fri, 26 Jan 2024 09:42:54 -0800 Message-ID: <20240126174255.17052-10-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126174255.17052-1-brett.creeley@amd.com> References: <20240126174255.17052-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A8:EE_|SJ0PR12MB7460:EE_ X-MS-Office365-Filtering-Correlation-Id: 05be430c-7841-445b-0373-08dc1e9647a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ogZiutZ12aVBatXQ35HD1k6ZHpasNPiKl/ClaFikaX3N62CG8IdU392UlEDOE7+VekK8p4JgU2FQnlr7QAsweNnh8NRT1M9yOj3EVIleQ+YCu0v0FIMKaG0P2YXbS3UZ+ZDIa+8Gkfwqynh6/z/2CeFOGwX3jzk6dikSU02Zcrj9d0PwGbhKWVjwv+euxr9+eZPODo+rIpF+Wauc+BTa5he3WfLq/Fbt3kmtB2qhXwn7UfeaJTr57l4xUBUsogwn+XacwDa3u1sU9saGYpuwgeVHQBTA4QHdOCY+cqlCo8bRjvIBwpDQigV9ZwEBuQnv3QIE0bc0Mo3pm9OYvRp6EuM6YkAwdC9i+Jb8XAX2DYMKs1AfThp6KjT1EgqwOTtI4+zI+5wGD/C9X0XYXfzPlUrZGYASy9zF7MCm9NLXZqb2QGdBAx2jKw9MrXW1FbDP/7GbWlfn7vVr+ppCEQvRV44rQurvtLfuUdVyFriU7tiLzCnROuPDgHvimR5cQMyltxBzy6J/ocs/ggEcoozt5utZRXC0LdPh+eaSEzWMMmFQFIxQ7nS9fUybCvgEyVA7pNaTXmt2f/EVRPG4FJvJrd66P09C0GqfqStV7yw2hxUXmdkjhaz2K0nx4pr0G4x7pRlEAMFysmhgmxIjASQlW9/TCzUfYGztvCOyvqxF9QKBv2WAYWCv25muRrHyedct/W71T/6u6rh5VOxiSN80pTlDT6qPwkybWRBu/piGtPo5Lck+LMDx8y5vG5Aa8rkl+xka66zi0XLryt3SiCQGdQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(376002)(346002)(136003)(39860400002)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(82310400011)(40470700004)(36840700001)(46966006)(40460700003)(40480700001)(44832011)(426003)(8676002)(4326008)(336012)(1076003)(2616005)(83380400001)(5660300002)(70586007)(110136005)(54906003)(316002)(478600001)(70206006)(8936002)(16526019)(26005)(6666004)(2906002)(36756003)(36860700001)(47076005)(356005)(82740400003)(81166007)(41300700001)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 17:43:17.4961 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05be430c-7841-445b-0373-08dc1e9647a1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A8.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7460 X-Patchwork-Delegate: kuba@kernel.org Currently the teardown/setup flow for driver probe/remove is quite a bit different from the reset flows in pdsc_fw_down()/pdsc_fw_up(). One key piece that's missing are the calls to pci_alloc_irq_vectors() and pci_free_irq_vectors(). The pcie reset case is calling pci_free_irq_vectors() on reset_prepare, but not calling the corresponding pci_alloc_irq_vectors() on reset_done. This is causing unexpected/unwanted interrupt behavior due to the adminq interrupt being accidentally put into legacy interrupt mode. Also, the pci_alloc_irq_vectors()/pci_free_irq_vectors() functions are being called directly in probe/remove respectively. Fix this inconsistency by making the following changes: 1. Always call pdsc_dev_init() in pdsc_setup(), which calls pci_alloc_irq_vectors() and get rid of the now unused pds_dev_reinit(). 2. Always free/clear the pdsc->intr_info in pdsc_teardown() since this structure will get re-alloced in pdsc_setup(). 3. Move the calls of pci_free_irq_vectors() to pdsc_teardown() since pci_alloc_irq_vectors() will always be called in pdsc_setup()->pdsc_dev_init() for both the probe/remove and reset flows. 4. Make sure to only create the debugfs "identity" entry when it doesn't already exist, which it will in the reset case because it's already been created in the initial call to pdsc_dev_init(). Signed-off-by: Brett Creeley Reviewed-by: Shannon Nelson --- drivers/net/ethernet/amd/pds_core/core.c | 13 +++++-------- drivers/net/ethernet/amd/pds_core/core.h | 1 - drivers/net/ethernet/amd/pds_core/debugfs.c | 4 ++++ drivers/net/ethernet/amd/pds_core/dev.c | 7 ------- drivers/net/ethernet/amd/pds_core/main.c | 2 -- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c index fe7e1d10224c..41507ade3570 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -404,10 +404,7 @@ int pdsc_setup(struct pdsc *pdsc, bool init) int numdescs; int err; - if (init) - err = pdsc_dev_init(pdsc); - else - err = pdsc_dev_reinit(pdsc); + err = pdsc_dev_init(pdsc); if (err) return err; @@ -476,10 +473,9 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing) for (i = 0; i < pdsc->nintrs; i++) pdsc_intr_free(pdsc, i); - if (removing) { - kfree(pdsc->intr_info); - pdsc->intr_info = NULL; - } + kfree(pdsc->intr_info); + pdsc->intr_info = NULL; + pdsc->nintrs = 0; } if (pdsc->kern_dbpage) { @@ -487,6 +483,7 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing) pdsc->kern_dbpage = NULL; } + pci_free_irq_vectors(pdsc->pdev); set_bit(PDSC_S_FW_DEAD, &pdsc->state); } diff --git a/drivers/net/ethernet/amd/pds_core/core.h b/drivers/net/ethernet/amd/pds_core/core.h index cbd5716f46e6..110c4b826b22 100644 --- a/drivers/net/ethernet/amd/pds_core/core.h +++ b/drivers/net/ethernet/amd/pds_core/core.h @@ -281,7 +281,6 @@ int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd, union pds_core_dev_comp *comp, int max_seconds); int pdsc_devcmd_init(struct pdsc *pdsc); int pdsc_devcmd_reset(struct pdsc *pdsc); -int pdsc_dev_reinit(struct pdsc *pdsc); int pdsc_dev_init(struct pdsc *pdsc); void pdsc_reset_prepare(struct pci_dev *pdev); diff --git a/drivers/net/ethernet/amd/pds_core/debugfs.c b/drivers/net/ethernet/amd/pds_core/debugfs.c index d56fdbb4cdb9..6bdd02b7aa6d 100644 --- a/drivers/net/ethernet/amd/pds_core/debugfs.c +++ b/drivers/net/ethernet/amd/pds_core/debugfs.c @@ -64,6 +64,10 @@ DEFINE_SHOW_ATTRIBUTE(identity); void pdsc_debugfs_add_ident(struct pdsc *pdsc) { + /* This file will already exist in the reset flow */ + if (debugfs_lookup("identity", pdsc->dentry)) + return; + debugfs_create_file("identity", 0400, pdsc->dentry, pdsc, &identity_fops); } diff --git a/drivers/net/ethernet/amd/pds_core/dev.c b/drivers/net/ethernet/amd/pds_core/dev.c index b237cea65a5e..7dc102a31185 100644 --- a/drivers/net/ethernet/amd/pds_core/dev.c +++ b/drivers/net/ethernet/amd/pds_core/dev.c @@ -316,13 +316,6 @@ static int pdsc_identify(struct pdsc *pdsc) return 0; } -int pdsc_dev_reinit(struct pdsc *pdsc) -{ - pdsc_init_devinfo(pdsc); - - return pdsc_identify(pdsc); -} - int pdsc_dev_init(struct pdsc *pdsc) { unsigned int nintrs; diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c index 05fdeb235e5f..cdbf053b5376 100644 --- a/drivers/net/ethernet/amd/pds_core/main.c +++ b/drivers/net/ethernet/amd/pds_core/main.c @@ -438,7 +438,6 @@ static void pdsc_remove(struct pci_dev *pdev) mutex_destroy(&pdsc->config_lock); mutex_destroy(&pdsc->devcmd_lock); - pci_free_irq_vectors(pdev); pdsc_unmap_bars(pdsc); pci_release_regions(pdev); } @@ -470,7 +469,6 @@ void pdsc_reset_prepare(struct pci_dev *pdev) pdsc_stop_health_thread(pdsc); pdsc_fw_down(pdsc); - pci_free_irq_vectors(pdev); pdsc_unmap_bars(pdsc); pci_release_regions(pdev); pci_disable_device(pdev); From patchwork Fri Jan 26 17:42:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13533077 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2063.outbound.protection.outlook.com [40.107.93.63]) (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 C25222261D; Fri, 26 Jan 2024 17:43:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706291004; cv=fail; b=q652tEYs6qlpplIxW89QYfuuiCpdIy9T6YdqrPczGZvuShfSZNik8OvuaJGF323N1CICVN2ynp4Tu0wjoi3upoEkKi/TGmyGBTni0Qtxa5AryvSSVhxQX5qpZRBzQpoH5VXrt86dIynQk77B98xyTeLPfGcUaaASBDAqMCwzqM4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706291004; c=relaxed/simple; bh=5/XxhSKJ5dyBZqh96AqTlrkzcwfIdMcmwQoh51Qwxuk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ExE6BLiizYZaGR3RPcVGNmgk3fFOXA4lgH0pjS3Ih1AXv+3+ejeiIn9TZU+QrWZKq1TqAjBLcf0mvYsFgZx1I0YOLRc1Z/+8xfaRSumXRS/4cajx5ZcGEe2pbArkrTG3hrugSQwsf2EFkpNSfcSv8Ff5Hyc4uB+HQ5hVZNUNaAE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=v37abj/3; arc=fail smtp.client-ip=40.107.93.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="v37abj/3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kxYstIsXvk27/Qfdy2q1XAGtclS/BKonm81QxI0y9hBxbgezz9Z7XBhgZjwJ2OfWM5TZAY70NaHHCHEMHeLNbV8MEHZZditteBPrYTg+QETVDJ3jearI9rsiANkLi3I863XFz9Y7UkuANH8RDBHeEzKqZC6veqZv3sJM2BBwlFd4DgenMs3GsczPUGXkUHfiXzpZwIn02B5IE/onGc6ILUr7P9UM9ZLMSoqIa1J0y/0zyOE+qY4ko8RlITojCjdj/skyVJYIF5CAexMDl95N2OHy/sggA5iRWAsSLSfyEUZO6I0PQIuwFuv1LuCHlTXHhpLZPtPtHGyA/weHJqfd0Q== 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=QJmn4DLpo0vKobqZwL6OFsEod8Q1UUZ0FYjc6MqS7ds=; b=cZj9oXVgOKu976e7JcCVK2RCRt7WvAyIYuX/9x6fUN8RpMpNrB7AKUUHVvBbfT77NnWqkf8S+ciBieUkEQhVtYQTodgmwwTLVORNNt9R1JEU/m9rDq5b40Aj7shsXRp0tPeW7a4N/+wDcK+x5gsbP7001DFfBjkY/M5vwYv/JHuxhWloFHdGnBt0jvjnuObf0uJonn2N4ky3JujnR6nXLitO8qlz0irIRPzxqVovGc2Cm5Ozm0+isKt6myaUAhhDPreYsrU4zNy0OVEphhxCqaYyOpw9oJcVkWRUl1ANAf1Fe87dwMDj16wAoVMM2KX/Won9YwyvBSdQFvGyYHk4OQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QJmn4DLpo0vKobqZwL6OFsEod8Q1UUZ0FYjc6MqS7ds=; b=v37abj/3UnoRMlndK3gbHTP6SHnGBlnSAk+KUvbxeVG50DcqADHLGhCZu05nHiUOI+bPC967Bqw464qeTRu6Y+7EsD9Yack6Ivp/9mmEmqXMHvPH4KFq3kPlpYSvav8c4r9hGvLb/0G7PyA1Rcnr2+g6fHyR68276UpBQYL0CwI= Received: from BN8PR15CA0070.namprd15.prod.outlook.com (2603:10b6:408:80::47) by MW4PR12MB6705.namprd12.prod.outlook.com (2603:10b6:303:1e3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Fri, 26 Jan 2024 17:43:20 +0000 Received: from BN2PEPF000044A8.namprd04.prod.outlook.com (2603:10b6:408:80:cafe::d7) by BN8PR15CA0070.outlook.office365.com (2603:10b6:408:80::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26 via Frontend Transport; Fri, 26 Jan 2024 17:43:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044A8.mail.protection.outlook.com (10.167.243.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7228.16 via Frontend Transport; Fri, 26 Jan 2024 17:43:18 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 26 Jan 2024 11:43:16 -0600 From: Brett Creeley To: , , , , , CC: , Subject: [PATCH v2 net-next 10/10] pds_core: Clean up init/uninit flows to be more readable Date: Fri, 26 Jan 2024 09:42:55 -0800 Message-ID: <20240126174255.17052-11-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126174255.17052-1-brett.creeley@amd.com> References: <20240126174255.17052-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A8:EE_|MW4PR12MB6705:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b9da0d2-6a58-4052-5c00-08dc1e96487c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: brbTWsO0xD0Z7Ds16vOlNVRmEAHuIlPINfbo1qqCmtdQD/NVx0+E41DJk7jrSqfkhB7LcWILUu4UlQwjcTQHYZ9ij7Mh/MKgGaRtwZr26O39dyJF3t7IYVkl1YO/BUOwNoycdqWEZc0YifsKynx8Fo9PdF/g2mGJ7mUcaYff1oXXXciQlAfBSwXocwAkYxwIh7SLQKV2x43VUaECP98ZkwV59bnZ+qZrrg/HNO5F6l0IymICn3bgICPkQbV+6q+hD5fl2OIDxPt2LbPTOeedahgJ0s//oUWnRVsBHP8mvQnAGzX4kZc5qvh1O55Eeou0DUYQnx4skWwjm5VZHh2lh1+MXD77kg5asaBvx/BzdXQipdbX9F2GIRzsN54H1HLek+885QJJB11Xc0T9XaUvbi+tRpx+bXqasLXU5rkBB9Vtp4pOKVOfyv0Wk2xZ5dzD2Y4RF+3tok5cH9W6Umc1/1HPoPAhv3IU7pl/BmxB96QAbzjJx0Tw1Z85Vgs0ZVlPqNoMOu2L0PgNhiFabPFIRcnEUhDREQcb8AoiyrmkEo7dHZfMcqZuOG6TUcUD4xWEfcMyEWEy/NMKsIZD/cuxFe+702zf2m2f+KocwyLO26HKbu1RMowE5buNs2cN3LKflHvgu0kuD0UWkgHxPu6Akbwx61zQ/E9oSpx7rThHiwTAeWXE1S9lTFAUIYNCk5kn/dQ0iD+4RijLG2WkunFSsUXPJ+XRGHwM3u5B0KfFxGl0o+w6z3lHE50yY7tmXDx2Ir+1weIZDk9Mex8I/xdjjg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(346002)(136003)(39860400002)(396003)(230922051799003)(186009)(64100799003)(82310400011)(451199024)(1800799012)(40470700004)(36840700001)(46966006)(47076005)(36756003)(82740400003)(41300700001)(356005)(44832011)(5660300002)(54906003)(1076003)(6666004)(70206006)(316002)(40460700003)(70586007)(110136005)(40480700001)(83380400001)(2906002)(426003)(336012)(8936002)(478600001)(2616005)(8676002)(4326008)(36860700001)(86362001)(26005)(81166007)(16526019)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 17:43:18.9336 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b9da0d2-6a58-4052-5c00-08dc1e96487c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A8.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6705 X-Patchwork-Delegate: kuba@kernel.org The setup and teardown flows are somewhat hard to follow regarding pdsc_core_init()/pdsc_dev_init() and their corresponding teardown flows being in pdsc_teardown(). Improve the readability by adding new pdsc_core_uninit()/pdsc_dev_unint() functions that mirror their init counterparts. Also, move the notify and admin qcq allocations into pdsc_core_init(), so they can be freed in pdsc_core_uninit(). Signed-off-by: Brett Creeley Reviewed-by: Shannon Nelson --- drivers/net/ethernet/amd/pds_core/core.c | 87 ++++++++++++------------ drivers/net/ethernet/amd/pds_core/core.h | 1 + drivers/net/ethernet/amd/pds_core/dev.c | 16 +++++ 3 files changed, 61 insertions(+), 43 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c index 41507ade3570..1234a4a8a4ae 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -300,6 +300,17 @@ int pdsc_qcq_alloc(struct pdsc *pdsc, unsigned int type, unsigned int index, return err; } +static void pdsc_core_uninit(struct pdsc *pdsc) +{ + pdsc_qcq_free(pdsc, &pdsc->notifyqcq); + pdsc_qcq_free(pdsc, &pdsc->adminqcq); + + if (pdsc->kern_dbpage) { + iounmap(pdsc->kern_dbpage); + pdsc->kern_dbpage = NULL; + } +} + static int pdsc_core_init(struct pdsc *pdsc) { union pds_core_dev_comp comp = {}; @@ -310,9 +321,32 @@ static int pdsc_core_init(struct pdsc *pdsc) struct pds_core_dev_init_data_in cidi; u32 dbid_count; u32 dbpage_num; + int numdescs; size_t sz; int err; + /* Scale the descriptor ring length based on number of CPUs and VFs */ + numdescs = max_t(int, PDSC_ADMINQ_MIN_LENGTH, num_online_cpus()); + numdescs += 2 * pci_sriov_get_totalvfs(pdsc->pdev); + numdescs = roundup_pow_of_two(numdescs); + err = pdsc_qcq_alloc(pdsc, PDS_CORE_QTYPE_ADMINQ, 0, "adminq", + PDS_CORE_QCQ_F_CORE | PDS_CORE_QCQ_F_INTR, + numdescs, + sizeof(union pds_core_adminq_cmd), + sizeof(union pds_core_adminq_comp), + 0, &pdsc->adminqcq); + if (err) + return err; + + err = pdsc_qcq_alloc(pdsc, PDS_CORE_QTYPE_NOTIFYQ, 0, "notifyq", + PDS_CORE_QCQ_F_NOTIFYQ, + PDSC_NOTIFYQ_LENGTH, + sizeof(struct pds_core_notifyq_cmd), + sizeof(union pds_core_notifyq_comp), + 0, &pdsc->notifyqcq); + if (err) + goto err_out_uninit; + cidi.adminq_q_base = cpu_to_le64(pdsc->adminqcq.q_base_pa); cidi.adminq_cq_base = cpu_to_le64(pdsc->adminqcq.cq_base_pa); cidi.notifyq_cq_base = cpu_to_le64(pdsc->notifyqcq.cq.base_pa); @@ -336,7 +370,7 @@ static int pdsc_core_init(struct pdsc *pdsc) if (err) { dev_err(pdsc->dev, "Device init command failed: %pe\n", ERR_PTR(err)); - return err; + goto err_out_uninit; } pdsc->hw_index = le32_to_cpu(cido.core_hw_index); @@ -346,7 +380,8 @@ static int pdsc_core_init(struct pdsc *pdsc) pdsc->kern_dbpage = pdsc_map_dbpage(pdsc, dbpage_num); if (!pdsc->kern_dbpage) { dev_err(pdsc->dev, "Cannot map dbpage, aborting\n"); - return -ENOMEM; + err = -ENOMEM; + goto err_out_uninit; } pdsc->adminqcq.q.hw_type = cido.adminq_hw_type; @@ -359,6 +394,10 @@ static int pdsc_core_init(struct pdsc *pdsc) pdsc->last_eid = 0; + return 0; + +err_out_uninit: + pdsc_core_uninit(pdsc); return err; } @@ -401,35 +440,12 @@ static int pdsc_viftypes_init(struct pdsc *pdsc) int pdsc_setup(struct pdsc *pdsc, bool init) { - int numdescs; int err; err = pdsc_dev_init(pdsc); if (err) return err; - /* Scale the descriptor ring length based on number of CPUs and VFs */ - numdescs = max_t(int, PDSC_ADMINQ_MIN_LENGTH, num_online_cpus()); - numdescs += 2 * pci_sriov_get_totalvfs(pdsc->pdev); - numdescs = roundup_pow_of_two(numdescs); - err = pdsc_qcq_alloc(pdsc, PDS_CORE_QTYPE_ADMINQ, 0, "adminq", - PDS_CORE_QCQ_F_CORE | PDS_CORE_QCQ_F_INTR, - numdescs, - sizeof(union pds_core_adminq_cmd), - sizeof(union pds_core_adminq_comp), - 0, &pdsc->adminqcq); - if (err) - goto err_out_teardown; - - err = pdsc_qcq_alloc(pdsc, PDS_CORE_QTYPE_NOTIFYQ, 0, "notifyq", - PDS_CORE_QCQ_F_NOTIFYQ, - PDSC_NOTIFYQ_LENGTH, - sizeof(struct pds_core_notifyq_cmd), - sizeof(union pds_core_notifyq_comp), - 0, &pdsc->notifyqcq); - if (err) - goto err_out_teardown; - /* Set up the Core with the AdminQ and NotifyQ info */ err = pdsc_core_init(pdsc); if (err) @@ -455,35 +471,20 @@ int pdsc_setup(struct pdsc *pdsc, bool init) void pdsc_teardown(struct pdsc *pdsc, bool removing) { - int i; - if (!pdsc->pdev->is_virtfn) pdsc_devcmd_reset(pdsc); if (pdsc->adminqcq.work.func) cancel_work_sync(&pdsc->adminqcq.work); - pdsc_qcq_free(pdsc, &pdsc->notifyqcq); - pdsc_qcq_free(pdsc, &pdsc->adminqcq); + + pdsc_core_uninit(pdsc); if (removing) { kfree(pdsc->viftype_status); pdsc->viftype_status = NULL; } - if (pdsc->intr_info) { - for (i = 0; i < pdsc->nintrs; i++) - pdsc_intr_free(pdsc, i); - - kfree(pdsc->intr_info); - pdsc->intr_info = NULL; - pdsc->nintrs = 0; - } - - if (pdsc->kern_dbpage) { - iounmap(pdsc->kern_dbpage); - pdsc->kern_dbpage = NULL; - } + pdsc_dev_uninit(pdsc); - pci_free_irq_vectors(pdsc->pdev); set_bit(PDSC_S_FW_DEAD, &pdsc->state); } diff --git a/drivers/net/ethernet/amd/pds_core/core.h b/drivers/net/ethernet/amd/pds_core/core.h index 110c4b826b22..3468a63f5ae9 100644 --- a/drivers/net/ethernet/amd/pds_core/core.h +++ b/drivers/net/ethernet/amd/pds_core/core.h @@ -282,6 +282,7 @@ int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd, int pdsc_devcmd_init(struct pdsc *pdsc); int pdsc_devcmd_reset(struct pdsc *pdsc); int pdsc_dev_init(struct pdsc *pdsc); +void pdsc_dev_uninit(struct pdsc *pdsc); void pdsc_reset_prepare(struct pci_dev *pdev); void pdsc_reset_done(struct pci_dev *pdev); diff --git a/drivers/net/ethernet/amd/pds_core/dev.c b/drivers/net/ethernet/amd/pds_core/dev.c index 7dc102a31185..e494e1298dc9 100644 --- a/drivers/net/ethernet/amd/pds_core/dev.c +++ b/drivers/net/ethernet/amd/pds_core/dev.c @@ -316,6 +316,22 @@ static int pdsc_identify(struct pdsc *pdsc) return 0; } +void pdsc_dev_uninit(struct pdsc *pdsc) +{ + if (pdsc->intr_info) { + int i; + + for (i = 0; i < pdsc->nintrs; i++) + pdsc_intr_free(pdsc, i); + + kfree(pdsc->intr_info); + pdsc->intr_info = NULL; + pdsc->nintrs = 0; + } + + pci_free_irq_vectors(pdsc->pdev); +} + int pdsc_dev_init(struct pdsc *pdsc) { unsigned int nintrs;