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 51921C982F7 for ; Mon, 21 Sep 2026 13:45:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C945310E3EA; Mon, 21 Sep 2026 13:45:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="SSHvSj8v"; dkim-atps=neutral Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011035.outbound.protection.outlook.com [52.101.52.35]) by gabe.freedesktop.org (Postfix) with ESMTPS id 235DC10E3EA for ; Mon, 21 Sep 2026 13:45:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MLATiXrmBujSInbb5Qd1/F5wD11r2crDncwdCaCkHvgy9AFuLMQn2i9Z7OFrq3rketVLKWkHzMDZvl9P8mnL3UFJE1Lk8m/Qca7gTu701uwh5ZsLJA+qdbDnTHCqtLjiKA/7DLzkDsZPEKpxTfUaS1FK1yUW1vmRHd1oYumLpGXOQDmAqSC5/OmDg4WfH5BtaYo9vFB80jckeMbl8cPV8CzOkSfrS+8iO3EAgqV3To2+BGe3HXLYSvxwdyul10b2igA+2MYHpHCtcFXXESdnipoYoB7y9IIl1xaEWn3YsgLKfGb1gbJoKyjrDSZ2jIla2qMpmLyH52Ee8vsnqV2Tfw== 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=UyQepYYxcbUfFh/6z37o++4mBx4MPdyVpzi1aZ2zoCc=; b=EUsRToSpQGQElVNHNtq3iPo0MY5Hi/lSsv9DUAiRO9cKqE1KwsUVwbOWf5c2Iqd6RkagKB2XsQ97rF+DymylJJNeg1eLS47rcMmxgHQnujwlJIR49qndg5zyB9v+79JuzaL16Fxo+WEWhKYx4B1pJ99aS1jgLmsT2LdW7OzNvddg6aOaho4knU6Xn+o28MUT8p/knZ2/aPxem3RmZtT4yIstrqir99SIMD/J7FCEoP91nhTY9kCkU7Yp5448aLpJoJiFKe9kvgyzpIJwhGNm9T8KX0Sduf2Dn76wZF2tC8w3FKdd4s7dbIc70CXKHQRERtYGmnHhKG0KJo4lLJTqvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.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=UyQepYYxcbUfFh/6z37o++4mBx4MPdyVpzi1aZ2zoCc=; b=SSHvSj8vYTYqx0ayreyYIKQLX//G0O31dTZt+kGb4c/Ys4npA5ejLDiIJV5cluFeJ8AIRXPZ3NqYVMh45h+W/IODOTUBDljL7qCktcQGNNSG7zz2LF/g8dFfjN/ZP29Y+SjMm5G0ptFC1s8gQulQKqfm7zX5aqLQlAgsyG7bv4Q= Received: from CH2PR10CA0009.namprd10.prod.outlook.com (2603:10b6:610:4c::19) by SA1PR12MB9247.namprd12.prod.outlook.com (2603:10b6:806:3af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.16; Mon, 21 Sep 2026 13:45:45 +0000 Received: from BN2PEPF0000A802.namprd02.prod.outlook.com (2603:10b6:610:4c:cafe::a9) by CH2PR10CA0009.outlook.office365.com (2603:10b6:610:4c::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.16 via Frontend Transport; Mon, 21 Sep 2026 13:45:45 +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 BN2PEPF0000A802.mail.protection.outlook.com (10.167.245.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Mon, 21 Sep 2026 13:45:45 +0000 Received: from work-495456.amd.com (10.180.168.240) 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.49; Mon, 21 Sep 2026 08:45:44 -0500 From: James Zhu To: , CC: , , , Srinivasan Shanmugam Subject: [PATCH v2] drm/amdgpu/userq: reserve the VM root BO around CWSR param validation Date: Mon, 21 Sep 2026 09:45:38 -0400 Message-ID: <20260921134538.3673161-1-James.Zhu@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260918200444.450067-1-James.Zhu@amd.com> References: <20260918200444.450067-1-James.Zhu@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000A802:EE_|SA1PR12MB9247:EE_ X-MS-Office365-Filtering-Correlation-Id: 09bd7773-14dc-4064-78b9-08df17e6a30a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|23010399003|1800799024|36860700016|22082099003|18002099003|56012099006|11063799006|10067099003; X-Microsoft-Antispam-Message-Info: uMI3vRSLo33DyqWie1Wa4iCR4TyEfISPhhs5abtesb/+ZciKVU12BJrRpdEN8vZcaMhWw0/aWqkMLPS2TsLjou6VUxLOFnLvHywaDlO+ZRYPrfiuNnrRMXaTLQ7dyJ/XUygMlr3GCmqvo8LsPzMEZFVi8c+41R/bzM3HvHoJyxyt0xuHgRn6cqalrKM31zY6W5mWAfo/s4RkNz6AIFDQp6AfPBjhk+uhno43eLfXkAtql/Gdc+FjYZ9bLtXPNTlaOKyUHP4NzSKIdjwv/+bPUEYYDAcYEmsY7AAnauJowZ4t6L0pedQ+ZYB8Mfv2QQ8kS2fi4kcYlToIpVCn8Ez01hSs9QeeI6X8SJNLkKK9ELnu/49KaS4QQ8Neih5YdSTafM4uTjqEFBt+ZYBQo1Ys+ujuwkup5fRIOyORJBGBxRytMAF+Uz0X9iQvBbDGWEB6D2aJbamLwYLN5I+vQbWTWJQqlRxmNs9IdNDLvtHJrSRvTPFiMJUqLZJqdqzF/rgsLcmHMRBU4951TOBb0Rxu+nPMxxgXIQ3z44pC2GMGwNuvOtDRUDdVYxM9Z8ltMXhIJKOFv8Dt5NUk4bL8c+Q76GFo2h2aQZjUE0jIuB7XHkkSsQS+LMHGG1thm8L3kuIYoCLhhMQREcMi9qPPZrnVG5WqBzaBs26mbfxWcrOlkOwjJTpNFO9ZKw937yh/mHDIUnSDEwR1KCy/macJ5P2EUg== 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)(376014)(82310400026)(23010399003)(1800799024)(36860700016)(22082099003)(18002099003)(56012099006)(11063799006)(10067099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U6CWugd3NmN9++E70Qcog4uiuvLfgmLcQkcJJnjbv7MMNzkwOgqfwgi8SWnoadQeDfuiWYIBsTXz+6zslfTF8E9HRUaTzlBbDm6kfEhI7LO7VdNeVcQ/kmH8g4IG/kWhu7wYP7/9Jzd5j7VKCunqBBsm0/dYbe4BXGoMecDBld86JracBWFKatNKWMdKl0hwyqknX7G5ILn1VaETrqZoo5Wo63dGDTej4Yznz6IurlSlBbwhxbZ6ZyaOqNNWn4rqJpcgmKjR2J5ZqUShOgfCx4qFe65N4ElE38kH4KE9LSRne+NlMax5cek3pD3EoVeIx33zhAm/ryzgdpqaU1vf16jCX4Ls2ohczwPYM9AnoEAzIZJeH/B7hkY7NbHCR+XflpDnXgJsHTJbIfo/E5DVhDJHJLpZCkwe+qQWW2He8mGGW3hwTrENnrMUyIOl3tf3 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2026 13:45:45.4761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 09bd7773-14dc-4064-78b9-08df17e6a30a 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: BN2PEPF0000A802.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB9247 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" amdgpu_userq_input_trap_params_validate() ends up in amdgpu_userq_input_va_validate(), which walks the VM mapping tree and updates bo_va->userq_va_mapped, so it requires the caller to hold the vm->root.bo reservation. The CWSR branch of mes_userq_mqd_create() called it without that reservation, tripping the dma_resv_assert_held() on every compute queue creation when trap handling is enabled: WARNING: drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c:232 at amdgpu_userq_input_va_validate+0xb9/0xd0 [amdgpu] Call Trace: mes_userq_mqd_create+0x49c/0x9e0 [amdgpu] amdgpu_userq_ioctl+0x935/0x1070 [amdgpu] drm_ioctl_kernel+0xb3/0x110 [drm] Bracket the call with amdgpu_bo_reserve()/amdgpu_bo_unreserve() like the other input VA validations in the same function. Fixes: 7ca9abf4ac38 ("drm/amdgpu: Add user save area params to mqd input") -v2: add Fixes tag Signed-off-by: James Zhu Reviewed-by: Srinivasan Shanmugam --- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c index 2150973b947d..16aa22b25098 100644 --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c @@ -508,7 +508,14 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue, trap_params.ctx_save_area_address = compute_mqd->ctx_save_area_va; trap_params.cwsr_sz = compute_mqd->ctx_save_area_size; + + r = amdgpu_bo_reserve(queue->vm->root.bo, false); + if (r) { + kfree(compute_mqd); + goto free_mqd; + } r = amdgpu_userq_input_trap_params_validate(queue, &trap_params); + amdgpu_bo_unreserve(queue->vm->root.bo); if (r) { kfree(compute_mqd); goto free_mqd; -- 2.34.1