From patchwork Wed Jan 29 00:43:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 13953382 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2049.outbound.protection.outlook.com [40.107.236.49]) (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 270F6175D39 for ; Wed, 29 Jan 2025 00:43:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738111442; cv=fail; b=OMA8zet9VMF7/HQklz/1EjF2MJP6B5FhO8kgcGIJ3pVtGqUg5IMyaQf8UYxGKC8qYn0Y7FJ004FAm0y7T26c+/JXdCP9QWVygkgTNfnNkB3qy5F/s8/Pc0EjAryXlPsSH99bE79yRc6Ik1M0JTcGf8ybyTVYOZmTOlK+aRPhbSI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738111442; c=relaxed/simple; bh=0nrY8Vd7txUNhEfoul9WliAqWsUvAuzfBlyB97kT0aw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sJrPey+D4tvJ7A/biTq4eHRFMbqKEmvrADfg9heoG+A6aoe5nBYkV+COIxx01LuYZlKnMJIweahHquMNQ/3QmqgrdiUvdNXcP/9AxXeNR6ENdrYnZZZPrVlYbhx+H3CFmLvei0KrmazDBjp+Uai++LZ/RJuhKdUWAysi9OfAM5Y= 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=WfjVGI6y; arc=fail smtp.client-ip=40.107.236.49 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="WfjVGI6y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sV6/TX+nzv62qonGUdhMQGKvp7r1M5LAS9zn4FRt1yNXGsjB+eIoxjhaEHYkhZ8BzYt36KyYtbAdIVPMMVJOIuxzzaIYoMgqkWiVFA05D3tjDVOOIhrL/a0CXd26gW/0dSR45hhRWMtyfvHRACCRjB5ufISRH1nshVbvubVAco1NjhXgtwwK+0cvtDGC2WyBzJsEslGNmkRYywpmMrcvr5PM9IEFHCBd9PzKpAKflDqcqQWnhj96kAapwuWhYOM25BoKAH2qgwdrt5Vxq+TdVsyfSfPrbKhfPF1rrdHcZuoFegVcOTxzkRb9F+Otjtza5+a7wuY8cZYgheRaixx3yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Ifneiq/8iwOEEZm2pX1GcgnIWyoBCq31ybVyvCirYuA=; b=Gcb/E5ULdyjEfU9m8cT9lSmgUeL9ckk0a/WGURhIWmMPEoFAdr8dicc4kkDMYEfSulffGliCRDZTIPOhH+cep5VR1PuFHQiVUVK0DKn17lJZCnJojhhptruaym/HRYpGBCm/OKJlBj/XUZeZ9EREyRsk98R5KJaGahqTD9+ZH9K2VnVrp02qRZnJVWaCpfIitzT+KuujkgSE4SPd3Q11zS/102yWuMHO0zISxylvdErZi0BxUUwt5iVCaavw9mSQBdaKnl5HSFkXInJd0+cT99Z6MoGt+Gz5/wESwV47yj/3Db/1dPlBrDzX3cY9qJI4K2HKuFFCoCiA8CmqiXp9Vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=Ifneiq/8iwOEEZm2pX1GcgnIWyoBCq31ybVyvCirYuA=; b=WfjVGI6yjCftblWrR3IeTTVeEnGLiNGTwRxc4aMqddrVWOYnVYBHv0T3SCYPWCB3kOmFBjtbaj0jIWQBqrAd2WhEoifiVeMmy6jYXANJ1ykL3HNtTPeGvRP7l+n3u//nlF+fEYE2kyyd5TsXwsbQlY+O8RGAbCnE1xPvgrgJJfE= Received: from MW4PR04CA0290.namprd04.prod.outlook.com (2603:10b6:303:89::25) by CY5PR12MB6060.namprd12.prod.outlook.com (2603:10b6:930:2f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.23; Wed, 29 Jan 2025 00:43:56 +0000 Received: from CO1PEPF000042A9.namprd03.prod.outlook.com (2603:10b6:303:89:cafe::64) by MW4PR04CA0290.outlook.office365.com (2603:10b6:303:89::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.20 via Frontend Transport; Wed, 29 Jan 2025 00:43:56 +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 CO1PEPF000042A9.mail.protection.outlook.com (10.167.243.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8398.14 via Frontend Transport; Wed, 29 Jan 2025 00:43:56 +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.39; Tue, 28 Jan 2025 18:43:54 -0600 From: Shannon Nelson To: , , , , , CC: , Shannon Nelson Subject: [PATCH net 1/2] pds_core: Prevent possible adminq overflow/stuck condition Date: Tue, 28 Jan 2025 16:43:36 -0800 Message-ID: <20250129004337.36898-2-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250129004337.36898-1-shannon.nelson@amd.com> References: <20250129004337.36898-1-shannon.nelson@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: CO1PEPF000042A9:EE_|CY5PR12MB6060:EE_ X-MS-Office365-Filtering-Correlation-Id: 560e0d19-9215-4e5d-fbb1-08dd3ffe0354 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: rQYTC/Gs6Y8p3dvoDsyMKGKvP58zOigymyMYhtdkybs5IrNPCdRbXkqdL4aimpSY2VRaEoTLME0/C0ViKwCqKrM7tepVuTeJW56seOdV2v5LbmHJOmyIEQhGDedJzkzDj6jTaPhbALPlW9MZSr7x5MbV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g2PzvfUwVYzBhZW8jmEpKVBkRhzIl4DE9kJMEkEYVto/7ZHzOPmj6zJqyUr7hIySn2mdc113H9NAaJsodjXwtN0r6DwMRLbfSPLVXehx+9sC+jaJTS12WS3BFU6FFEkIdFyT5OfQ0WLukeGEqgE3o6GzxbXBw4sB54uLMQvkC0EkYFyBglp+lG+kjBWCevCq2cKx8vukF2e+FePY3WKsFyuE7n1lcp2+Dkkd2tIyCOIYp1Em13uhQzGNYdIu4FnuqkwdXSlAmLPDcrXnSsqhOakdOtujM/aDL+tBLKGXM= 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:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2025 00:43:56.4903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 560e0d19-9215-4e5d-fbb1-08dd3ffe0354 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: CO1PEPF000042A9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6060 X-Patchwork-Delegate: kuba@kernel.org From: Brett Creeley The pds_core's adminq is protected by the adminq_lock, which prevents more than 1 command to be posted onto it at any one time. This makes it so the client drivers cannot simultaneously post adminq commands. However, the completions happen in a different context, which means multiple adminq commands can be posted sequentially and all waiting on completion. On the FW side, the backing adminq request queue is only 16 entries long and the retry mechanism and/or overflow/stuck prevention is lacking. This can cause the adminq to get stuck, so commands are no longer processed and completions are no longer sent by the FW. As an initial fix, prevent more than 16 outstanding adminq commands so there's no way to cause the adminq from getting stuck. This works because the backing adminq request queue will never have more than 16 pending adminq commands, so it will never overflow. This is done by reducing the adminq depth to 16. This is just the first step to fix this issue because there are already devices being used. Moving forward a new capability bit will be defined and set if the FW can gracefully handle the host driver/device having a deeper adminq. Fixes: 792d36ccc163 ("pds_core: Clean up init/uninit flows to be more readable") Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson Reviewed-by: Michal Swiatkowski --- drivers/net/ethernet/amd/pds_core/core.c | 5 +---- drivers/net/ethernet/amd/pds_core/core.h | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c index 536635e57727..4830292d5f87 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -325,10 +325,7 @@ static int pdsc_core_init(struct pdsc *pdsc) 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); + numdescs = PDSC_ADMINQ_MAX_LENGTH; err = pdsc_qcq_alloc(pdsc, PDS_CORE_QTYPE_ADMINQ, 0, "adminq", PDS_CORE_QCQ_F_CORE | PDS_CORE_QCQ_F_INTR, numdescs, diff --git a/drivers/net/ethernet/amd/pds_core/core.h b/drivers/net/ethernet/amd/pds_core/core.h index 14522d6d5f86..543097983bf6 100644 --- a/drivers/net/ethernet/amd/pds_core/core.h +++ b/drivers/net/ethernet/amd/pds_core/core.h @@ -16,7 +16,7 @@ #define PDSC_WATCHDOG_SECS 5 #define PDSC_QUEUE_NAME_MAX_SZ 16 -#define PDSC_ADMINQ_MIN_LENGTH 16 /* must be a power of two */ +#define PDSC_ADMINQ_MAX_LENGTH 16 /* must be a power of two */ #define PDSC_NOTIFYQ_LENGTH 64 /* must be a power of two */ #define PDSC_TEARDOWN_RECOVERY false #define PDSC_TEARDOWN_REMOVING true From patchwork Wed Jan 29 00:43:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 13953383 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2085.outbound.protection.outlook.com [40.107.220.85]) (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 AF1C917E472 for ; Wed, 29 Jan 2025 00:44:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738111444; cv=fail; b=p4YwNmkXInEXiCZyvHO6N0cuGqE3XeeN0Yiz+cp4xG5NNHoyXiSHnZO7maXu5zY+1HVSb7h6PZJOdKV1awWHalFVP3BN7v1zkBqJyMV37kUlOhde9hy2Emmi65EFVf+Nd2Q2d8kMKwKIdEAFuLIX6uvMebRIGufU3VJVUe4zKbg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738111444; c=relaxed/simple; bh=pjz3LNTWe7E5c52K+8G8new3YJjYSLqQnxoTDaJShsU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B70SdbX0CqEwMjVR+qHJ6QR6hayBKCaXf4/RdB5CAFBw9ycyfZaEtngdPgeXMRibrZgTkmlNHN/DLtRBbHyNSipg5uIBJ5onDaa+193kPVc1UKTwCQPlu3vb1CXPprF/rZYoPQ8oPofQVu8h+DQlEwr/CX5MVAd3TurWu+3+uLE= 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=E6gO4tOJ; arc=fail smtp.client-ip=40.107.220.85 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="E6gO4tOJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fN9CmrV32SneMZVz6DBUu7lhJFyWyhC2+MQUhicWwUxVHRzrV2pc516rs98r/5JL5hwVMpvvF40MSe9nRTVw34HkIjdQqFly9VF3sC3z64os76bafKiTWQBHu29pSM9zBy9dYURXPHUNt7026SY3y4SjQNRJk6kwfDA+mxe77jJGfZQBs/p7V57W1/rYywLbmg/dyYlrDH7WR0F4NzAv3RKXvA4/cbbbQzhTcxZche8XBG7940l0KmpGbjnehAmmiKkxkCI8nGrE7ozuaBKd5K89ILxXwnSLzG5fAds3+mos5jtlBCaiFFzZhM+Z3aKKlnSJkPWqbY1b7wJV4wr0yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=KULOvc0wL/mwkaELY6jxnY3Lngg/U0FhM1OdKt/qsOY=; b=RwNVspHbqQU7DZo3OVInSInupUiJhw2kIyG5lz5WeyFWfA+i8vvYY//xm6+nBBBDapf/P/unA3TCqDNUaRdBaOAIcO1x0mmbOP4rDCiVSYpIkl+wHHadN12XAin0Sas8AwC2fGxOLCxzZP7jlkYcinIq1t3sJtns4gut+4+33/vd5ZpRS2DmyA1/9PMc599Tf8t3D79x4vD7JpuXJnjyyc8xT8hXjNsD/CA3U92S7QvaJ2kNoO957+HHht77Yr94ybwC6Sx3k8d+afAwkrNM16ZAamV/YbwaKnOdsofDbS4V5AU5xAr9e/H8L2XPYiR8gDX6+X+rhvwm6jAFm3/paQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=KULOvc0wL/mwkaELY6jxnY3Lngg/U0FhM1OdKt/qsOY=; b=E6gO4tOJf2+tGvasmSPsSZwHYT8wxTrmW6xz8VgtqSB0A7qsogl3zNqrVZMxhJkr7l/N8xNvc9H1FK3ZocrJ0f1JAeT6VCy+OhMl3PqdWKCptzW36SjzJLX6WqOEQvQkjxAofhAbSCGRg1D+eWPoSlaTuPShk/9wFm2Xh03ypYY= Received: from MW4PR04CA0277.namprd04.prod.outlook.com (2603:10b6:303:89::12) by SA1PR12MB8946.namprd12.prod.outlook.com (2603:10b6:806:375::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.22; Wed, 29 Jan 2025 00:43:57 +0000 Received: from CO1PEPF000042A9.namprd03.prod.outlook.com (2603:10b6:303:89:cafe::b3) by MW4PR04CA0277.outlook.office365.com (2603:10b6:303:89::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.23 via Frontend Transport; Wed, 29 Jan 2025 00:43:57 +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 CO1PEPF000042A9.mail.protection.outlook.com (10.167.243.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8398.14 via Frontend Transport; Wed, 29 Jan 2025 00:43:57 +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.39; Tue, 28 Jan 2025 18:43:55 -0600 From: Shannon Nelson To: , , , , , CC: , Shannon Nelson Subject: [PATCH net 2/2] pds_core: Add a retry mechanism when the adminq is full Date: Tue, 28 Jan 2025 16:43:37 -0800 Message-ID: <20250129004337.36898-3-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250129004337.36898-1-shannon.nelson@amd.com> References: <20250129004337.36898-1-shannon.nelson@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: CO1PEPF000042A9:EE_|SA1PR12MB8946:EE_ X-MS-Office365-Filtering-Correlation-Id: 336463d8-61a7-4f68-09ef-08dd3ffe03c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014|30052699003; X-Microsoft-Antispam-Message-Info: t/8rv9MG0GcpIhfGCsiBuRwTDo5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PLsMqt//D/706T7mz/3jftwqHBr33OlYQb0w54G66hqdf8xaJs3KlP6VAnN+GeyWAv1nVwf16dN684LfHxTl1md6ItVWibQqhPLGRyDFU/u2nCNEMHb76UrakRvTMCZw0k2dlml9OFukX7cDILKollaVIinNvJySnEKmeMtoMl58AUirJlo/QArY71qmmEj8LCMtwJSxUysUVnliE+qcbO0Qk18nflCeBkBR3c0WEALqzeroCFXYh4kUILM6XyD0Q6GXRFiXq//eTypLtUsCjn9Ab5ci65l5HDBug/2hELzNZBeqefNBhS22dCq5cxPIswWlCUM0qfps/oJ3RQbeQTStv9flAh/bJy0URzuMeYPVvQfWQiJ2AD0o9ntSaFQHRhQSLCVkOArf8Ao4HI3qv345+2FEgLMVeNgdSogE9Ac0= 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:(13230040)(36860700013)(1800799024)(82310400026)(376014)(30052699003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2025 00:43:57.2403 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 336463d8-61a7-4f68-09ef-08dd3ffe03c5 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: CO1PEPF000042A9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8946 X-Patchwork-Delegate: kuba@kernel.org From: Brett Creeley If the adminq is full, the driver reports failure when trying to post new adminq commands. This is a bit aggressive and unexpected because technically the adminq post didn't fail in this case, it was just full. To harden this path add support for a bounded retry mechanism. It's possible some commands take longer than expected, maybe hundreds of milliseconds or seconds due to other processing on the device side, so to further reduce the chance of failure due to adminq full increase the PDS_CORE_DEVCMD_TIMEOUT from 5 to 10 seconds. The caller of pdsc_adminq_post() may still see -EAGAIN reported if the space in the adminq never freed up. In this case they can choose to call the function again or fail. For now, no callers will retry. Fixes: 01ba61b55b20 ("pds_core: Add adminq processing and commands") Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson Reviewed-by: Michal Swiatkowski --- drivers/net/ethernet/amd/pds_core/adminq.c | 22 ++++++++++++++++++---- include/linux/pds/pds_core_if.h | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/adminq.c b/drivers/net/ethernet/amd/pds_core/adminq.c index c83a0a80d533..387de1712827 100644 --- a/drivers/net/ethernet/amd/pds_core/adminq.c +++ b/drivers/net/ethernet/amd/pds_core/adminq.c @@ -181,7 +181,10 @@ static int __pdsc_adminq_post(struct pdsc *pdsc, else avail -= q->head_idx + 1; if (!avail) { - ret = -ENOSPC; + if (!pdsc_is_fw_running(pdsc)) + ret = -ENXIO; + else + ret = -EAGAIN; goto err_out_unlock; } @@ -251,14 +254,25 @@ int pdsc_adminq_post(struct pdsc *pdsc, } wc.qcq = &pdsc->adminqcq; - index = __pdsc_adminq_post(pdsc, &pdsc->adminqcq, cmd, comp, &wc); + time_start = jiffies; + time_limit = time_start + HZ * pdsc->devcmd_timeout; + do { + index = __pdsc_adminq_post(pdsc, &pdsc->adminqcq, cmd, comp, + &wc); + if (index != -EAGAIN) + break; + + dev_dbg(pdsc->dev, "Retrying adminq cmd opcode %u\n", + cmd->opcode); + /* Give completion processing a chance to free up space */ + msleep(1); + } while (time_before(jiffies, time_limit)); + if (index < 0) { err = index; goto err_out; } - time_start = jiffies; - time_limit = time_start + HZ * pdsc->devcmd_timeout; do { /* Timeslice the actual wait to catch IO errors etc early */ poll_jiffies = msecs_to_jiffies(poll_interval); diff --git a/include/linux/pds/pds_core_if.h b/include/linux/pds/pds_core_if.h index 17a87c1a55d7..babc6d573acd 100644 --- a/include/linux/pds/pds_core_if.h +++ b/include/linux/pds/pds_core_if.h @@ -22,7 +22,7 @@ #define PDS_CORE_BAR0_INTR_CTRL_OFFSET 0x2000 #define PDS_CORE_DEV_CMD_DONE 0x00000001 -#define PDS_CORE_DEVCMD_TIMEOUT 5 +#define PDS_CORE_DEVCMD_TIMEOUT 10 #define PDS_CORE_CLIENT_ID 0 #define PDS_CORE_ASIC_TYPE_CAPRI 0