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 EDA29606A322 for ; Tue, 1 Dec 2026 17:22:45 +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=0zb3CQJ0 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 87F6310FB23; Tue, 1 Dec 2026 17:22:40 +0000 (UTC) Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012020.outbound.protection.outlook.com [52.101.48.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2746710FB23; Tue, 1 Dec 2026 17:22:34 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u1lKd8VyGk0UAiKnrO2TKIfk8wZqoKfRv7KufSGajiHYQC2dt/fEuqxhQ3lL3R8nYepD7MYDRuQVJBQ6RaK0x2C0R+vkHG+Rbt2PUtxayVX9z2jefd2IITOEDp0fA2IGZ6JexZRgnHZ9mfV8Tk8Uy43N9AR0TfY6MacbaswDYeEEHxBpw7ZBjibTTuPQc7MG6IFQXietiQsBgpVIgkzEe4tMR1M/a4RK0/H9E9X13lXpcaOvAVg4ZsAl9PyEizOyMwbv+OR+WAbjL0NQV5m5GcVS6yepRbJhjBm0qYYyYUr7hig9ZzRGB8mMFk9enF0AIWJORrN611Vzv92gZ3QdEA== 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=2IYdT4es75dYCGFIk1LTjWnNXAKED6Kgw1iSOsCKLWs=; b=kL2QuFZKpdjLKBKqhvxfQC9+aFFOCcgIY3z0Rmup3kgIWaI4CD3RM8Y/mScga2K9ZAN2NtDneDuS5rhLaTnuhHEghyMqp4LzVlTfIWX7DkguSq3kwzFJ8soZMCuENem8dzgQmJlAC3WuoLdi935aL1WXVnKVcT1JlkTc733PXjfDx8CCcDRWsLc0x6ctyWgiHAJlaTY1l7xubbRiM8vD1V+wjfnYaxGPquNcxA0DrBwLCsSrMZSliHzwvEZreDLqRT9Zfx3zui5WRUGuISjrbpAhKjwV5+pXCSu3xA8698DMx1agiNZ3AMN49Nl1DM/WycZZNd98sxIYJAWpniJAAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none 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=2IYdT4es75dYCGFIk1LTjWnNXAKED6Kgw1iSOsCKLWs=; b=0zb3CQJ0Jpnsu1905L9LBjFV2D5wEtiSX0PRgT4eZRl2yWF628StylvPHK7noDgDfAxj4CrdU7DmqMPwIFznPG8NUjopEb1yNmvFY8BafGD8nlV3+D4xSinelZUb5f+3sPWF9q8ilJLPT8WG6t5VpRAlqKJZx6C6wGfsOJ+uNfM= Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5167.namprd12.prod.outlook.com (2603:10b6:5:396::10) by SA1PR12MB999230.namprd12.prod.outlook.com (2603:10b6:806:4de::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Tue, 1 Dec 2026 17:22:31 +0000 Received: from DM4PR12MB5167.namprd12.prod.outlook.com ([fe80::4588:54c1:bc29:2c7c]) by DM4PR12MB5167.namprd12.prod.outlook.com ([fe80::4588:54c1:bc29:2c7c%4]) with mapi id 15.21.0688.009; Tue, 1 Dec 2026 17:22:31 +0000 Content-Type: multipart/alternative; boundary="------------fClWJ3AI7VqofvGBvOQr00Bf" Message-ID: <9ba09c61-3274-4965-9385-1a1e600c5b57@amd.com> Date: Tue, 1 Dec 2026 12:22:29 -0500 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] drm/amdgpu: Unwind UALink peer GART mappings on sw_init failure To: Lin Huiyi , alexander.deucher@amd.com, christian.koenig@amd.com Cc: airlied@gmail.com, simona@ffwll.ch, Philip.Yang@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org References: Content-Language: en-US From: Philip Yang In-Reply-To: X-ClientProxiedBy: YT4P288CA0015.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d4::15) To DM4PR12MB5167.namprd12.prod.outlook.com (2603:10b6:5:396::10) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR12MB5167:EE_|SA1PR12MB999230:EE_ X-MS-Office365-Filtering-Correlation-Id: f9a510d8-a2ba-42d2-2dfb-08df4fcfae4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|23010399003|1800799024|376014|22082099003|18002099003|10067099003|56012099006|261028144727099003|261102123227099003|261026121527099003|261026140227099003|261021123027099003|261021121427099003|261022105027099003|261009223027099003|11063799006|4143699003|13003099007|8096899003; X-Microsoft-Antispam-Message-Info: IlnqJEW+J3vWUGgFFwaEMDQ4Nwm8B0VpsUM1pgwAAJGMXF55WVY3feBreBZ3yaxLcnx2OZp0cbr9RaZwjlO7Bs8+069oBhn6XIT3d0L3/Tl3H6sGFWzs7BqNJcX93Sl764HCaN298ubHy0w8oeCvCiJj4MZopEPdoV4ZwGea8xS5DJJ0NKZIfVGCS1uzx6iPiY/Pyiu3YMPg0HeSJ/2sBsZZHob+HiRM4+LQUR84Wiq21abonKls2guVHRZfj5assk2zcrarOC9lID1xlCDWMdXIsB4irx3oEf1Al9Pa0Hp/dvzXVAWhhUmV8foVaekNdHOnQRmU8z17r95X0E8vaxyGDRSneCW+9PhunUbmKG4mPmw264ddHpLtspdQLNdvzsBh/03qUHuLdYjtQfV4pquY/46wFI+YJTKyuAr3TpuNlkn+SqB0glIiKCBnst/IYLlTCCga35eWaBjC4C3+TRV4x8Q10RRAz+N8zz5bVzkX0mzL5q6KyGIu+ObJe6SvxjbNC+N/leVvnEoapAB2SNQCyRiqgVq0cvGr+oVoMhULk59sWlCnCxxLuxe0c9nEGvmODyizS5G3jUqjWS4aLzlfOzYTzACGQQiKrIBomqKSVH4BTP1yNBiDYFn3oA8hQ+t42KPYEYAkxjHA/Ha7oJllVeB32PdQ9QZL8wc9SeA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR12MB5167.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(23010399003)(1800799024)(376014)(22082099003)(18002099003)(10067099003)(56012099006)(261028144727099003)(261102123227099003)(261026121527099003)(261026140227099003)(261021123027099003)(261021121427099003)(261022105027099003)(261009223027099003)(11063799006)(4143699003)(13003099007)(8096899003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?djZZd1RFVk1oRXBUU0p6WWhMYXdwRlRTbjRGNFY1MnllMmJsZlZmdWVwQ1Fn?= =?utf-8?B?OGk1b1JpekwwaWhoUlhRWHVLN3F6UFhNb2R4eDJINmozVmF0dm54cEV5bnFt?= =?utf-8?B?U2xrT2l3SnVTZEdVaWt4TjNhY1Zrcm95bUN4dTM5Rk1MZ0o3UjVGVnlTbEdj?= =?utf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JMS9DWGxPSlFlemcxWlo5K1pi?= =?utf-8?B?ektlS25SRXpFZnVsV3krd09KQklmbW1uSmdUZDc4ekRkUFJmdmx6ME5uRUQ4?= =?utf-8?B?dVRISzRNT005eVRURWlpV1hueVJORzB2TzZQeWZpUlVwamwvRGRtM1RXa0xo?= =?utf-8?B?S0pBU1VYWlJ0ZUkxVGErVEg5WW1vMzJDUXN5N2NMenNuUkhPKzJXRFFjZmdp?= =?utf-8?B?bWpVYjlSNDZkdHZQRE1heDMySy9qZmd0ckNlTlJZMDEyajM3dzNUdkZyeXpK?= =?utf-8?B?N0ZXcnRlcDVmbnNYanFUNktFY3VWNVJabzRYa0xZcnBTQ2twN3JKZ1Z2UC80?= =?utf-8?Q?dCShLqApLmCbzXW/kK?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9a510d8-a2ba-42d2-2dfb-08df4fcfae4c X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5167.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 17:22:31.2996 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JHhFgUxwpPMfLCDgMhIcG4s8rJj4duv7Z6SsnL5qcNeVr5gEJaqeNRhDgJpe8/bG X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB999230 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=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 --------------fClWJ3AI7VqofvGBvOQr00Bf Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026-11-30 10:15, Lin Huiyi wrote: > [Some people who received this message don't often get email fromxinghui79@qq.com. Learn why this is important athttps://aka.ms/LearnAboutSenderIdentification ] > > amdgpu_ualink_peer_remote_init() maps a set of GART ranges for every > remote peer. If one of the amdgpu_ualink_gart_map() calls fails, it > breaks out of the loop and returns an error, but the mappings created > for the peers processed so far are left behind. > > amdgpu_ualink_sw_init() then takes the out_sdma_entities_fini path, which > only tears down the SDMA entities and frees the remote structure without > calling amdgpu_ualink_peer_remote_fini(). The already-allocated > drm_mm_nodes stay registered in the shared GTT manager after the memory > that tracked them is gone, corrupting the drm_mm state and leaking GART > space on every failed activation. > > Fix this by calling amdgpu_ualink_peer_remote_fini() on the error path. > This is safe even for peers whose mappings were not created yet, since > gart_unmap() ignores unallocated nodes and mutex_destroy() copes with a > zero-initialized mutex. > > Fixes: 6e3834ceaf2f ("drm/amdgpu: Add UALink cross-GPU TLB shootdown and remote interrupt") > Signed-off-by: Lin Huiyi Reviewed-by: Philip Yang I will apply this patch to amd-staging-drm-next branch. Thanks, Philip > --- > v3: drop the mutex_init loop and keep the per-peer mutex_init as > before, since mutex_destroy() is safe on a zero-initialized mutex, > so the loop was unnecessary. Pointed out by Philip Yang. > v2: rename the existing out_sdma_entities_fini label to > out_peer_remote_fini instead of adding a second label, to avoid > -Wunused-label (Sashiko). > drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c > index b4fac5ecab..df716e2370 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c > @@ -6353,12 +6353,13 @@ int amdgpu_ualink_sw_init(struct amdgpu_device *adev) > > r = amdgpu_ualink_peer_remote_init(adev); > if (r) > - goto out_sdma_entities_fini; > + goto out_peer_remote_fini; > > dev_dbg(adev->dev, "ualink sw init succeed\n"); > return 0; > > -out_sdma_entities_fini: > +out_peer_remote_fini: > + amdgpu_ualink_peer_remote_fini(adev); > amdgpu_ualink_sdma_entities_fini(adev); > out_npa_unmap: > amdgpu_ualink_metadata_npa_unmapping(adev); > -- > 2.56.1 > --------------fClWJ3AI7VqofvGBvOQr00Bf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

On 2026-11-30 10:15, Lin Huiyi wrote:
[Some people who received this message don't often get email from xinghui79@qq.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

amdgpu_ualink_peer_remote_init() maps a set of GART ranges for every
remote peer. If one of the amdgpu_ualink_gart_map() calls fails, it
breaks out of the loop and returns an error, but the mappings created
for the peers processed so far are left behind.

amdgpu_ualink_sw_init() then takes the out_sdma_entities_fini path, which
only tears down the SDMA entities and frees the remote structure without
calling amdgpu_ualink_peer_remote_fini(). The already-allocated
drm_mm_nodes stay registered in the shared GTT manager after the memory
that tracked them is gone, corrupting the drm_mm state and leaking GART
space on every failed activation.

Fix this by calling amdgpu_ualink_peer_remote_fini() on the error path.
This is safe even for peers whose mappings were not created yet, since
gart_unmap() ignores unallocated nodes and mutex_destroy() copes with a
zero-initialized mutex.

Fixes: 6e3834ceaf2f ("drm/amdgpu: Add UALink cross-GPU TLB shootdown and remote interrupt")
Signed-off-by: Lin Huiyi <xinghui79@qq.com>
Reviewed-by: Philip Yang <philip.yang@amd.com>

I will apply this patch to amd-staging-drm-next branch.

Thanks,
Philip
---
v3: drop the mutex_init loop and keep the per-peer mutex_init as
    before, since mutex_destroy() is safe on a zero-initialized mutex,
    so the loop was unnecessary. Pointed out by Philip Yang.
v2: rename the existing out_sdma_entities_fini label to
    out_peer_remote_fini instead of adding a second label, to avoid
    -Wunused-label (Sashiko).
 drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
index b4fac5ecab..df716e2370 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
@@ -6353,12 +6353,13 @@ int amdgpu_ualink_sw_init(struct amdgpu_device *adev)

        r = amdgpu_ualink_peer_remote_init(adev);
        if (r)
-               goto out_sdma_entities_fini;
+               goto out_peer_remote_fini;

        dev_dbg(adev->dev, "ualink sw init succeed\n");
        return 0;

-out_sdma_entities_fini:
+out_peer_remote_fini:
+       amdgpu_ualink_peer_remote_fini(adev);
        amdgpu_ualink_sdma_entities_fini(adev);
 out_npa_unmap:
        amdgpu_ualink_metadata_npa_unmapping(adev);
--
2.56.1


--------------fClWJ3AI7VqofvGBvOQr00Bf--