From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B1C0FD4F11 for ; Tue, 10 Mar 2026 18:01:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A0FEA10E774; Tue, 10 Mar 2026 18:01:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="bEM9aT9f"; dkim-atps=neutral Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013011.outbound.protection.outlook.com [40.93.196.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 08EDB10E774 for ; Tue, 10 Mar 2026 18:01:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lmYkyHnDQtHuLGcyU8N9JQWwfK6s2Kp41vYkg51IpPNxgAyJ6DAPH3JJm+w+3HSgthoXGH6hqLm/sEq14vS4LNeVuB2logMZ2SCdp5jJBLLqPNzsMa0pwXtc33R1/uNsjPvPX43qvpa9Ys1hts5cOY//U+SRF17WKRapXNn4mifUOinXSRah1bBSOqywOr2huY5q6DnqDIbF9Pvi7lDDx4mh5eeuZIX5a5GO/GUvDib/lwabtqp1ruFJUTcXGJy17cvxBs9BFPtjJ2p0UozC8I+24ISocbZN8zhZ9xxB0yESzqhWl2WJxQYyU7I8KxvN69MEYvS4+dIPZVNudYP1HA== 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=AkCbFtLe1YdJAeR8uTWeaUk2Mk3SCqnRLr0iBEtRIFQ=; b=VulBvq2CCCp1yqyAftwBNq11uurC3JvulZiQPTCuiJh5p03RtLne6YGAI/8DTLWW6Buw3YVIXkytYcoxcANkQ6gYgMDcOmdh2yNH6ATZtTXhRRdX2GZALTnvJMe2b09lY+ZxMERoSKUlsAKgFVTWlTqoD/v3Tdn4A0fZunWh3Inq3a9nsYZxOdmw7r0D53AFLL+DUGj45XK7K769xU4aYa3yDtPO+MeshtPEUMi7x56Bd8bcLL5+xvwV+nGL44GeOE4E9Y8C4sRYoYSOouhTy7I7OJVeh0pnNgY4LUzYlt7iFZcYkWooy4FjfC2ae11efWEWF4n4FTB/emYcuHdy6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=AkCbFtLe1YdJAeR8uTWeaUk2Mk3SCqnRLr0iBEtRIFQ=; b=bEM9aT9fWLqd/m3XtNp0IHV0J7Sju1DsUn5XkDXsawAwLnRsVN8+5NhBpG4pHTa5yWAGUVYcGPUnaLZLAQ1fBWzbMVD2kh9mmwKoQQ3CdI2zU6mn03r4Xq78TEEtnBJrVAZRVPKHq+/KRF0TI1Kr2Ycvv6Hx1YCIkvtV+NPIxP0= Received: from SJ0PR05CA0010.namprd05.prod.outlook.com (2603:10b6:a03:33b::15) by CYXPR12MB9277.namprd12.prod.outlook.com (2603:10b6:930:d8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.11; Tue, 10 Mar 2026 18:01:03 +0000 Received: from SJ1PEPF00001CE0.namprd05.prod.outlook.com (2603:10b6:a03:33b:cafe::f) by SJ0PR05CA0010.outlook.office365.com (2603:10b6:a03:33b::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.25 via Frontend Transport; Tue, 10 Mar 2026 18:01:03 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by SJ1PEPF00001CE0.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Tue, 10 Mar 2026 18:01:02 +0000 Received: from Satlexmb09.amd.com (10.181.42.218) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 10 Mar 2026 13:01:00 -0500 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb09.amd.com (10.181.42.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 10 Mar 2026 11:01:00 -0700 Received: from xsjlizhih51.xilinx.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Tue, 10 Mar 2026 13:01:00 -0500 From: Lizhi Hou To: , , , , CC: Lizhi Hou , , , Subject: [PATCH V2] accel/amdxdna: Fix runtime suspend deadlock when there is pending job Date: Tue, 10 Mar 2026 11:00:58 -0700 Message-ID: <20260310180058.336348-1-lizhi.hou@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE0:EE_|CYXPR12MB9277:EE_ X-MS-Office365-Filtering-Correlation-Id: 71739994-89a8-4b84-a39b-08de7ecefe71 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|376014|82310400026|1800799024|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: rfPtJ03qpFbk0slrVLx0XTn3cAObkmGOyRvlBSUBXw9/Vk0hiYoHDBShiV0jK6Y7cUiAgYELqpQTMR5UAOHjYt7R2gRRYOxNty3oVTobQ/6uZJlFh8/5dDtfZNP4Okbeyzv7YhOQb1PBgwIrJYhje9xthkXaAIYvGvvQFDF6bbL0x1hFMCkAAaYCJ3qVfPz9XUFATZAgpQjo8XHg8RFk7CLssmLudYg7rxJ5HEwFtzYooLqIBrBq4AeXIy1MS8OqJ3Mnf6Z8eMaWwLzB5+4Xj20mTnCP/V/dOHvvIBUChbiMv5UdTmpomzBWcctcOcTUXYgUdrEUrI+W0M3Bsf0XjLfJtrF+PyhJzU6vFtNJfnvYD9NRwQ5DvlZOTFBKOxa9kbQXro84aJneOWiHqB9ssToLUPnNdKVtNdHRfj66egjVKt2Vr7NEEJAFlCZGacEwTzCYXOsR+181VFjTGVSFkvyg1qr/r7rVtFOVtMndK4+pfmCwXRYLF4nnqC+/lxkj6UPP2jCGomjXZdUB+M4eNPOnlw+W8+fEYAl65NqTvnbavhNCEdNFbCRN8ITQjl1qj6Dj+BJumW73pA6CBMn0zjM/lB1xbCUKbs1/QwUqtL0z3kblF9fF7Jja8oc0VCsqdQjlE1wE14C8OvDK/K38FSC0HRSYm0xt+Xmwjs3bfK7Um5OyXOyyA/rFmoklFbjVskrFXGC/acMUIqtyZdvTf6xhhjV6VWxYC7qrQz4Q1cectkYYdczlz8Nv8zv1oiPWIVDerrGXuLGgabJRk/+35Q== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700016)(376014)(82310400026)(1800799024)(18002099003)(56012099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: x+u18HPj9EJRmFcamffp5AyVdI5ZYFYcMPKatw4YFGCGsrgGHrPZJwNqh1I2Twc8Uk5UnQG2XXr/j5D93kZYri/A1/7p5h7yEepzUpJAqwZW7lIYuGkOKLNlHYN1hJTs2H4UQFij378xqsNiYOv4sBEpssLRR5NVGgeMkLpAuwj4PI5TJ/WdcQ2ubnM3TcVYLDhUYbr5FtQRPCI53kLdQSJpS2TGHMYkX43WCYuY5E/VrNRKFAnPPQY/A1IyjTiDqoFuCo8PpQzCgtlaJ/fMM1odHfEp6xmpDPS8lQql8v/VQCu3hBdQ0hjPCHBgqPoNihqjbX+twpHjG5GrLgYinYVS8FV4B/Snt2VKLKUE3yCmWhoInm6hIZyIoTfn7yUoPzFZcly7/SSibfpEpbFF3+s+w+Emu0yKsKkUgGcscOrJz6Db/9jcOgi4ghYpc+rt X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2026 18:01:02.8905 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71739994-89a8-4b84-a39b-08de7ecefe71 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CE0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR12MB9277 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The runtime suspend callback drains the running job workqueue before suspending the device. If a job is still executing and calls pm_runtime_resume_and_get(), it can deadlock with the runtime suspend path. Fix this by moving pm_runtime_resume_and_get() from the job execution routine to the job submission routine, ensuring the device is resumed before the job is queued and avoiding the deadlock during runtime suspend. Fixes: 063db451832b ("accel/amdxdna: Enhance runtime power management") Signed-off-by: Lizhi Hou --- drivers/accel/amdxdna/aie2_ctx.c | 14 ++------------ drivers/accel/amdxdna/amdxdna_ctx.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c index afee5e667f77..c0d348884f74 100644 --- a/drivers/accel/amdxdna/aie2_ctx.c +++ b/drivers/accel/amdxdna/aie2_ctx.c @@ -165,7 +165,6 @@ aie2_sched_notify(struct amdxdna_sched_job *job) trace_xdna_job(&job->base, job->hwctx->name, "signaled fence", job->seq); - amdxdna_pm_suspend_put(job->hwctx->client->xdna); job->hwctx->priv->completed++; dma_fence_signal(fence); @@ -290,19 +289,11 @@ aie2_sched_job_run(struct drm_sched_job *sched_job) struct dma_fence *fence; int ret; - ret = amdxdna_pm_resume_get(hwctx->client->xdna); - if (ret) + if (!hwctx->priv->mbox_chann) return NULL; - if (!hwctx->priv->mbox_chann) { - amdxdna_pm_suspend_put(hwctx->client->xdna); - return NULL; - } - - if (!mmget_not_zero(job->mm)) { - amdxdna_pm_suspend_put(hwctx->client->xdna); + if (!mmget_not_zero(job->mm)) return ERR_PTR(-ESRCH); - } kref_get(&job->refcnt); fence = dma_fence_get(job->fence); @@ -333,7 +324,6 @@ aie2_sched_job_run(struct drm_sched_job *sched_job) out: if (ret) { - amdxdna_pm_suspend_put(hwctx->client->xdna); dma_fence_put(job->fence); aie2_job_put(job); mmput(job->mm); diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/amdxdna_ctx.c index 666dfd7b2a80..838430903a3e 100644 --- a/drivers/accel/amdxdna/amdxdna_ctx.c +++ b/drivers/accel/amdxdna/amdxdna_ctx.c @@ -17,6 +17,7 @@ #include "amdxdna_ctx.h" #include "amdxdna_gem.h" #include "amdxdna_pci_drv.h" +#include "amdxdna_pm.h" #define MAX_HWCTX_ID 255 #define MAX_ARG_COUNT 4095 @@ -445,6 +446,7 @@ amdxdna_arg_bos_lookup(struct amdxdna_client *client, void amdxdna_sched_job_cleanup(struct amdxdna_sched_job *job) { trace_amdxdna_debug_point(job->hwctx->name, job->seq, "job release"); + amdxdna_pm_suspend_put(job->hwctx->client->xdna); amdxdna_arg_bos_put(job); amdxdna_gem_put_obj(job->cmd_bo); dma_fence_put(job->fence); @@ -482,6 +484,12 @@ int amdxdna_cmd_submit(struct amdxdna_client *client, goto cmd_put; } + ret = amdxdna_pm_resume_get(xdna); + if (ret) { + XDNA_ERR(xdna, "Resume failed, ret %d", ret); + goto put_bos; + } + idx = srcu_read_lock(&client->hwctx_srcu); hwctx = xa_load(&client->hwctx_xa, hwctx_hdl); if (!hwctx) { @@ -522,6 +530,8 @@ int amdxdna_cmd_submit(struct amdxdna_client *client, dma_fence_put(job->fence); unlock_srcu: srcu_read_unlock(&client->hwctx_srcu, idx); + amdxdna_pm_suspend_put(xdna); +put_bos: amdxdna_arg_bos_put(job); cmd_put: amdxdna_gem_put_obj(job->cmd_bo); -- 2.34.1