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 0FB7C606A31A for ; Tue, 1 Dec 2026 05:32:48 +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=IA0zkvuS Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F9DF10EBD8; Tue, 1 Dec 2026 05:32:42 +0000 (UTC) Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012018.outbound.protection.outlook.com [52.101.53.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04DEA10E939 for ; Tue, 1 Dec 2026 05:32:35 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AZEnkKUiFMnOSM9xf4k77t/F3MMtgLA0coyhooWjBHrpJ1I9XcnakflVdhzc3iXwSOHHl0OyrWRL0vdC8SdCDBb5+SmC3zFIrXs5+8J+XTqlLifnBozEwn1Wk5ggT6S/H4WtcFzZ+1wlv4EYmDMITXCmDYHDWRLeTEozR1m8tHK8sJGYLVRHFAWia/s+pdpP30Cf2hE6v020qSyaS+OgufhQQbz9VJGuP9fq3zHEoVBAjuU3mV6vPsLWzQabnj3gpAk/oWNbW6hW2vOnMiQjvmuuSLCLQT9PheQXyfT6KZRIngsoGc9BACuSDXfqneMtjJSvl3YzPhI89msxIHtzJA== 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=ydJsZRAjAMV4FokVH7xDeY2ShGvIvV4/Plgn46hxu/8=; b=uF/8JcAcvEhi4tEZff7Km6NWPVbVeBw2Nv2v8SfVPEGksc8WOY+M7tHRmJyzhhUe1/XXAPxeo9+MU2tnSsQWCCPcAMmm25/9Kd97uIU4fvfd7Llsu3WM0rSfPi9NgCSKurdKdR9N6Fam7rPOLajTS2J6llt1Fu5pHcaraNn6CUvMNhmCIC8DtgcE2J9BQlgL9ixXXAOE1ysIet1DLbB4UCV45/QCLoDA7sMt7b1S7d4rCDBxisggY8hKrsJ7Ij3jOQZmF3+bX+cy2Jdw2cE0FXOGvviLrrNaCcquJK70DJwhM+Yidf5m4n6lVfGzAd96a0ZNKOuQONf8nB7OXb/qqA== 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=ydJsZRAjAMV4FokVH7xDeY2ShGvIvV4/Plgn46hxu/8=; b=IA0zkvuS19rqCbeoQrCITCXeoxWuxhQEpies3W/sGYe9kbxG42hl9gbLWdTGYAwQyNR/LQowDb4IgKjPzA9TAboVHXS5pXuw7Xg9r14HJpxZ8bL1SWbf4H6Ss3RfyN79QIRjsJr+55V1JkQuExzKfVmJWWBxBJbitbs5G5PkWLU= Received: from MW4PR03CA0024.namprd03.prod.outlook.com (2603:10b6:303:8f::29) by DS3PR12MB999240.namprd12.prod.outlook.com (2603:10b6:8:38f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Tue, 1 Dec 2026 05:32:29 +0000 Received: from SJ5PEPF000001EA.namprd05.prod.outlook.com (2603:10b6:303:8f:cafe::8) by MW4PR03CA0024.outlook.office365.com (2603:10b6:303:8f::29) 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 05:32:28 +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 SJ5PEPF000001EA.mail.protection.outlook.com (10.167.242.198) 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 05:32:28 +0000 Received: from satlexmb08.amd.com (10.181.42.217) 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; Mon, 30 Nov 2026 23:32:24 -0600 Received: from JesseDEV.amd.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Mon, 30 Nov 2026 23:32:23 -0600 From: Jesse Zhang To: CC: , Christian Koenig , Srinivasan Shanmugam Subject: [PATCH v2 08/11] drm/amdgpu: Clear PASID ownership before event manager teardown Date: Tue, 1 Dec 2026 13:30:51 +0800 Message-ID: <20261201053159.2550315-9-Jesse.Zhang@amd.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20261201053159.2550315-1-Jesse.Zhang@amd.com> References: <20261201053159.2550315-1-Jesse.Zhang@amd.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001EA:EE_|DS3PR12MB999240:EE_ X-MS-Office365-Filtering-Correlation-Id: 57ed1225-a0d7-4f91-8330-08df4f6c7d52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700016|1800799024|23010399003|11063799006|6133799003|261009223027099003|18002099003|22082099003|10067099003|261028144727099003|56012099006|261026140227099003|261026121527099003|261021123027099003|261021121427099003|261022105027099003|261102123227099003; X-Microsoft-Antispam-Message-Info: sumuH39x1EOwzJR2UP/avtkE9g1i38AmR1gomnp/rCpfsn9B59atF/dA2pZNO13Lu+7nIMOXD8tDVJJ9F/7W2fik7BqYifGbOTiEpBuNixMZw9d0JNRNTt/inpd92q7iq9N/OB7CyHpNMr5jX+W/cHTRb2/g8/ZURAWi8x/84U9QCFdC3HeUoGHZQSeiPXZJKOA3xJv6snUOjkheIUpPFGy4XwxBZfkI9GaiiX31f3Hj+NS3dqDUG4kHEn4UbijpovCE/+bI/iTZ9bAQVvY1g44glCCb2frRTKJMcNwb0u6qfZE8TC8SYliIxnSmzawAmFe/x51w4B87rBxBM8ZgIllOhmkfPhWHdQuLj3YzchmWROL5NBPqSK1xj77OMaT3PpJEuYW8ygkk789QrdLGH6AEplFUGD5r1MYQgdxzT3w/ED0dry8H15cga8N1w1fMZtghgibYmF6nCHQ+RZxS0LmpDhFakK6VVcRa9HHUMtG8tjeC1OZojHGGocMqVd4YTjMkUwyi8CkJoxKDVYetADBntLPbVW4ndsB8/MrA4uCJYlpd0Df6QkwIGyZ814liaerbuwedE54Z1e1QEIt/Xi8Qt+eLXokrP4vfBO+8qF56T8jghHFbqB5LlC0kaidjvyLB3kbNiD1pvdYSvzBFHAyadpTaT/1SMkRm8Id39QSE55BweWvYdtLlzLEZupGsT1hD9fh4+uunvii3Jzag8A== 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)(36860700016)(1800799024)(23010399003)(11063799006)(6133799003)(261009223027099003)(18002099003)(22082099003)(10067099003)(261028144727099003)(56012099006)(261026140227099003)(261026121527099003)(261021123027099003)(261021121427099003)(261022105027099003)(261102123227099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BkhmslcEuTwZKmYi/LYRruxlbOD5EJZ4syxmh8nKm+lNsAdau3mjC/ia+/xs/rmx1HotOhrzaiM+jzQ478n74FrO/WeHYFclWLpZdbsSohwTOnBbwVGThzA1zcGRTWoVlMlvZl65eG+SsRV4hSDJNUj3pzOKi194vz6OOAGvv9LETBbYYquF+gS/uED88eVpM5McwvLiG/+JAiwp8jZcf2n2pg18W+a9JlMTLpn2x4+Qbdq1/VXbgA5SwrUlVa6oNJj48CWVeP0rM5Cu0OFQHg/VYXzpg4gg0H/ulWZzjH+PplapNbZ2xrt2Qg5FSKT2XwYLudRH8H4+Wu4a8z9PuElLTKqCwDukWJCLLq8mOv9VFLtB+Je/E2nNqVKhtMxc5BhEgPaCSCtBmoI7IRKW8+JZIZ3RMmynZDTxMNo3a+oI97cIpPj73AgJw9lyLFAW X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 05:32:28.6834 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57ed1225-a0d7-4f91-8330-08df4f6c7d52 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: SJ5PEPF000001EA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS3PR12MB999240 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 From: Srinivasan Shanmugam Memory-fault notifications resolve fpriv through the PASID mapping. Postclose currently destroys the event managers before the delayed PASID free path clears that mapping. Expose the existing owner-clear helper and call it before manager teardown. Its PASID lock synchronizes with active fault handlers and prevents subsequent lookups from reaching the closing file. Preserve delayed PASID release and its fence-based reuse protection. Signed-off-by: Srinivasan Shanmugam --- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c index 9c879ac68352..f35d47e1ea20 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c @@ -112,11 +112,11 @@ static void amdgpu_pasid_free_cb(struct dma_fence *fence, * * Replace the stored owner with NULL while keeping the PASID allocated. * - * This is used by the delayed PASID free path so that future PASID - * lookups cannot resolve a stale DRM file-private object while the PASID - * is still waiting for outstanding fences before being released. + * Serialize with PASID-locked users and prevent new lookups from + * finding the owner. Call before tearing down per-file event managers. + * The PASID remains allocated until the normal free path releases it. */ -static void amdgpu_pasid_clear_owner(u32 pasid) +void amdgpu_pasid_clear_owner(u32 pasid) { unsigned long flags; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h index c134000eecfd..af9947e7e0e2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h @@ -117,6 +117,7 @@ struct amdgpu_fpriv *amdgpu_pasid_get_fpriv_locked(u32 pasid); int amdgpu_pasid_drain_irq(struct amdgpu_device *adev, u32 pasid, u32 *ih_fence, unsigned long timeout); void amdgpu_pasid_drain_irq_done(u32 pasid); +void amdgpu_pasid_clear_owner(u32 pasid); void amdgpu_pasid_free(u32 pasid); void amdgpu_pasid_free_delayed(struct dma_resv *resv, u32 pasid); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 42fe741ef9ca..45061d5a8e0c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -1826,6 +1826,9 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, if (!fpriv) return; + /* Stop PASID-based notifications before tearing down the managers. */ + amdgpu_pasid_clear_owner(fpriv->vm.pasid); + /* Drop eventfd subscriptions and pending wait-event records. */ amdgpu_eventfd_mgr_fini(&fpriv->eventfd_mgr); amdgpu_wait_event_mgr_fini(&fpriv->wait_event_mgr); -- 2.50.1