Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87991606A320 for ; Tue, 1 Dec 2026 09:01:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=p7VHxGC3 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 28FA910E0C0; Tue, 1 Dec 2026 09:01:03 +0000 (UTC) Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010041.outbound.protection.outlook.com [52.101.46.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 038DF10E0C0 for ; Tue, 1 Dec 2026 09:00:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CKTo/0w5/vAqzp+Q5TDNMGYqrsefbU9puqySpLbVCgsCJcS6Q1+V9zQhJSNllU8aSfd0ZWjumWyfzRrHam0PnFbfu0DT9xeKLSd0w8gwL1WnweMQKXL+RB/XGq6QQt/p8E6Ikst//oiuZ4RvbOrbHdQq8sDIGaqZWKvvEYBvFrGD532HbIMoEfV+Esm7/ZD5uV3fJLXYM6eAQTqsr+CDt37x+bxBE4Roan+9WW7e9CYKmlhjrknxY3Fn/MUXSnpB1SEzEkJeFKl3AgHAfCvAZEGh9BfhNfULdjqKJdloWAKU1AGeeP0OTxysqz7X3fibI9N0h/0Z524LxS0NGkIbMw== 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=nHw7/yOvRmNGtMrEO+PYCMx4kQssRKpNw4Jf8JgfvR4=; b=eqGUWO5oYdZLBqd6TB0Lg3Sh5NpAJrMB9I7rzFig+eDfaIIVt2S/uwtE1BpYxxGkdrgbJ3NGtHIpWtexQiPuVrGPQ5lS/xnEqiSkD9TU4ZNX3xuy7z/A9Zurh9hkd7EnRqgZTNxZtvtqDaAf2mWppkgZYsRUSIBZ5rk8RYszetVDL1Expn8UwyiK36MO1QgpcZTuqFTeRsu6f3EdDlyrUP4Hz5nibOwLFGkZdIJGEOT3D83Rf73cljNBF66NKBk+Q7KuyJfdJw2soApah4hv95PgvUgnwBfybg8PXiaUYm1oZe3QRqRCepu9rOh+XLJWLNVPN25ewlRTWm3zKd7jPA== 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=nHw7/yOvRmNGtMrEO+PYCMx4kQssRKpNw4Jf8JgfvR4=; b=p7VHxGC3BZPgZe7LOt30RHIpmNSjqE0CrT6ZYeT/2PE0ZCnTtCGBUKBZY1U3WZsbyn1Cva0tMgF2aG9MlAEZc3VQhUn3IR49hfsMhNGUCry9ScpKw5LW6zKsGaM8bhkapMxBy/eoEJt7DGduCgr9EZFO01W7LedtAMbnj53yQzI= Received: from BY5PR03CA0029.namprd03.prod.outlook.com (2603:10b6:a03:1e0::39) by DS7PR12MB6215.namprd12.prod.outlook.com (2603:10b6:8:95::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.11; Tue, 1 Dec 2026 09:00:52 +0000 Received: from SJ1PEPF000037A4.namprd04.prod.outlook.com (2603:10b6:a03:1e0:cafe::80) by BY5PR03CA0029.outlook.office365.com (2603:10b6:a03:1e0::39) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.13 via Frontend Transport; Tue, 1 Dec 2026 09:00:51 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; 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 SJ1PEPF000037A4.mail.protection.outlook.com (10.167.244.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 09:00:51 +0000 Received: from pyuan-Chachani-VN.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.57; Tue, 1 Dec 2026 03:00:46 -0600 From: Perry Yuan To: CC: , , , Subject: [PATCH 1/3] drm/amdgpu: keep PTL disable requests across GPU reset and resume Date: Tue, 1 Dec 2026 17:00:26 +0800 Message-ID: <20261201090028.86494-1-perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: SJ1PEPF000037A4:EE_|DS7PR12MB6215:EE_ X-MS-Office365-Filtering-Correlation-Id: df785d16-279c-4e26-7561-08df4f899972 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|23010399003|36860700016|1800799024|5023799004|11063799006|261009223027099003|18002099003|10067099003|56012099006|261102123227099003|261028144727099003|261021123027099003|261026121527099003|261026140227099003|261021121427099003|261022105027099003; X-Microsoft-Antispam-Message-Info: LRWg72li0tHdfrhP+Cz8lQId96pmB+TxKmXnqqGU/sAGzab1RrRH+tAxQAIM+2Zs8e3c+qa23a7IxI5aSjhhZnNq1KmhFlBsXA4XYKiFuIxWkzNWDvgGPllqDVoWEkRcyIYiFYhvhCzw71CoifH1PEHxhmpGLGOy+jKc0V1G921drS5SSpI6C0k7ptN8fiAZejOA7GPJj7W7RgRQ5rnyPmBYBsrTWHPHvp3eP2px9izgdWnNZbc+KmZvrRa6U5sB7OCbzyTPwlN0PDPvh+aedE9R7RYigeyP+peZD1XIRhElBhlBxaFUvYGeDVaZwVsaq/6t2gOgu+1UoLtTKdtdpSN4zXeRbtAbEyvYrgyndbRe5XV2n+WZxSQKCqA0pqB3yxoVUpzVdZMdjAOsrrW4Wmt0K2PySvROqixEimhLY1rQrLVuG2iBtGx9imbbJ4C8Fwk3OmaEGTP9yaZR28qvuKYNUfkw6LB5wbPqRVMxVJj9P2d4yB8qVJA5KU92zVMnq1pJD7QHjCX5V/RFtie6wBKSm3/Jo2NtsWbDfpXj7uK2QA/06vD0+/Wcp1ZQ3un6apDvUFz3Q1Lkrfq386d4InlXoD+0CG7ht3djDWIl9umLMa+BgOYsp+hIhv584IDr0iJUyq0IfLK1NPVPo/7GQBUN7qgpXBRr3hY/VoXFfr2KRPkqovWW2bl7JUIx1uckpTZnLAVK+zRQkeauEpv43g== 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)(36860700016)(1800799024)(5023799004)(11063799006)(261009223027099003)(18002099003)(10067099003)(56012099006)(261102123227099003)(261028144727099003)(261021123027099003)(261026121527099003)(261026140227099003)(261021121427099003)(261022105027099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W4MRsxn5qDMiu0ByIeUNvcLOu9VDwiJPrIHtOfxPvXwkoHyMnOu9vfUz60eVGNErv0p5fb144fnGmoIz6eyXnpIdrYc7XU2YJL5nQxeSa8V4slWgwgH+geHdrORJSbejXuMmoV4fce1xWytZ/WOTUipJRGeVZsJ18bOOMGijqrziIa2YMBtou0CIV0pF+sVmHoRKWak36ZARJDjyazWKmXA2nomOyHcikCEjLHiWBX9DifhQ9QmAqmn90VOnWD7jPJT1nvYaN6m/r4FX8Pce/D5wfpfTkAkFuRTSNTvlOz17tuI0N4oB5/2qQRK6HQHtDDrr/KJrS2Bgao8Bg8kxcB9lKb6us319HqtvG/jP5b9wDA9LbmQmQatpdGQwg3RGc+tuCPq/T7gH6ZPalMEayFcy+aAxaqX7T63OwbF0MEqCELBmiLEkRUNGQ2UdjZB7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 09:00:51.2133 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df785d16-279c-4e26-7561-08df4f899972 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: SJ1PEPF000037A4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6215 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "amd-gfx" X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 gfx_v9_4_3_perf_monitor_ptl_init() sets ptl->disable_ref to 0 every time it runs. Besides the first init, that is late_init after a GPU reset and on resume, and hw_fini on suspend. The KFD processes holding a PTL disable request survive all of these, and so do their pdd->ptl_disable_req and the AMDGPU_PTL_DISABLE_PROFILER bit. If a process holds the profiler lock across a GPU reset, its release afterwards, by unlock, exit or kill, takes disable_ref from 0 to -1. The 1 -> 0 transition that clears the PROFILER bit and enables PTL never happens, neither for this process nor for later profilers, which move the counter between -1 and 0. A write to ptl_enable is blocked by the PROFILER bit. PTL stays disabled until amdgpu is reloaded. disable_ref starts at 0 in the zeroed amdgpu_device and is balanced by the request/release pairs, so there is nothing to reset. Drop the reset so that the counter keeps matching the requests that are held. Fixes: dd61e27535a6 ("drm/amdkfd: Add PTL control IOCTL Option and unify refcount logic") Signed-off-by: Perry Yuan --- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c index e140430ce059..78ce980ac319 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c @@ -2463,7 +2463,11 @@ static int gfx_v9_4_3_perf_monitor_ptl_init(struct amdgpu_device *adev, bool ena ptl->hw_supported_state = AMDGPU_PTL_HW_SUPPORTED; - atomic_set(&ptl->disable_ref, 0); + /* + * disable_ref counts the KFD processes holding a PTL disable request. + * They survive GPU reset and suspend/resume, so it must not be reset + * here. + */ if (!enable && !amdgpu_in_reset(adev) && !adev->in_suspend) { dev_dbg(adev->dev, "PTL disabled (amdgpu.ptl=%d)\ -- 2.34.1