From mboxrd@z Thu Jan 1 00:00:00 1970 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 7A531606A322 for ; Wed, 2 Dec 2026 20:06:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XS0M5Pih Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7333F112499; Wed, 2 Dec 2026 20:06:44 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id A463E10E011; Wed, 2 Dec 2026 20:06:37 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id A76E761805; Wed, 2 Dec 2026 20:06:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 440AC1F000C1; Wed, 2 Dec 2026 20:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796241996; bh=s2Q/99dgaw8zW5M4rZtWVGmn5nS8hwie7hjY384I3Ok=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=XS0M5Piha1+gmvWGWQkiyznd3weqMn/RdxWSI0ioEJuKDOMjgb32z1GS1+0YaZeY+ TswQgITUPi+2ZqRtm0UgREnIPbjjNQBk85MCE81cpy/kByMlxVlXZerFzA9aCTMfm3 i8045YXaLNSOoS6CU8km46RpfoWgeGAjibE49/PXvvaoTAY6LPrgoxhZCs22vgLjyq kldr3VWJHNFsIyGuZ24z7eVgV3FceTOGfRR9chQNPzBu8W8lsxZtRdXGeupgXdN1d8 sILeu83VOUts/6dmd8r47wAHwZvaafrqAupRd4QZMl2V4fBd+SFWU2aw8G7r/D9+Ur Ye9+6Io1FeojQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] drm/amdgpu: use the per-remote UALink generation count in Source-Alias mode To: bob Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org In-Reply-To: <20261203-fix-u5-amdgpu-ualink-alias-gencount-v1-1-a2e17004b91c@tuta.io> References: <20261203-fix-u5-amdgpu-ualink-alias-gencount-v1-1-a2e17004b91c@tuta.io> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 20:06:35 +0000 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: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "amd-gfx" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/amdgpu: skipped NPA VM unmap in amdgpu_ualink_unmap_all_npa_addr() -- commit b97443989d15a388f71900159633c07744fbba8b Author: bob drm/amdgpu: use the per-remote UALink generation count in Source-Alias mode This commit uses the remote importer's own generation_count rather than importer_entries[0].generation_count when checking connection state and handling connection resets during UALink export cleanup in Source-Alias mode. > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm= /amd/amdgpu/amdgpu_ualink.c > index d025b4183b296..1546c5d5c6758 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c [ ... ] > @@ -2695,7 +2699,7 @@ static void amdgpu_ualink_send_tlb_shootdown(struct= amdgpu_device *adev, > u32 accel_id =3D adev->ualink.info->ppod.accel_id; > struct amdgpu_ualink_importer_entry *imp_entry; > u64 npa_addr, size; > - u32 remote_acc_id; > + u32 remote_acc_id, gen_count; > int r; > =20 > size =3D amdgpu_bo_ngpu_pages(exp_xa_node->bo); > @@ -2712,9 +2716,13 @@ static void amdgpu_ualink_send_tlb_shootdown(struc= t amdgpu_device *adev, > =20 > npa_addr =3D STRIP_NPA(imp_entry->npa_addr); > npa_addr =3D GENERATE_NPA(npa_addr, accel_id); > + /* The generation count is per remote, also in Source-Alias > + * mode where imp_entry is the shared importer_entries[0]. > + */ > + gen_count =3D exp_xa_node->importer_entries[remote_acc_id].generation_= count; > =20 > if (!amdgpu_ualink_check_conn_ready(adev, remote_acc_id, > - imp_entry->generation_count)) { > + gen_count)) { > clear_bit(remote_acc_id, > exp_xa_node->importers_bitmap); > continue; > @@ -2737,7 +2745,7 @@ static void amdgpu_ualink_send_tlb_shootdown(struct= amdgpu_device *adev, > */ > amdgpu_ualink_handle_connection_reset(adev, remote_acc_id, > AMDGPU_UALINK_CONN_NOT_READY, > - imp_entry->generation_count); > + gen_count); > } > } > } > @@ -2755,7 +2763,7 @@ static void amdgpu_ualink_unmap_all_npa_addr(struct= amdgpu_device *adev, > struct dma_fence *fence =3D NULL; > struct drm_exec exec; > u64 npa_addr, size; > - u32 remote_acc_id; > + u32 remote_acc_id, gen_count; > int r; > =20 > size =3D amdgpu_bo_ngpu_pages(exp_xa_node->bo); > @@ -2774,9 +2782,13 @@ static void amdgpu_ualink_unmap_all_npa_addr(struc= t amdgpu_device *adev, > else > imp_entry =3D &exp_xa_node->importer_entries[remote_acc_id]; > npa_addr =3D imp_entry->npa_addr; > + /* The generation count is per remote, also in Source-Alias > + * mode where imp_entry is the shared importer_entries[0]. > + */ > + gen_count =3D exp_xa_node->importer_entries[remote_acc_id].generation_= count; > =20 > if (!amdgpu_ualink_check_conn_ready(adev, remote_acc_id, > - imp_entry->generation_count)) { > + gen_count)) { > clear_bit(remote_acc_id, > exp_xa_node->importers_bitmap); > continue; [Severity: High] Can this leave stale valid PTEs in adev->ualink.npa_vm pointing to freed VRAM pages when an importer fails TLB shootdown or reconnects? Before queuing amdgpu_ualink_exp_cleanup_worker(), amdgpu_ualink_revoke_exported_memory() unlinks every imp_entry->list from adev->ualink.exp_handles_list, so a later connection reset cannot find or unmap exp_xa_node via amdgpu_ualink_cleanup_exp_xa_entries(). In Source-Alias mode when accelerator 0 had not imported the handle, imp_entry->generation_count was previously 0, so amdgpu_ualink_handle_connection_reset() did not match the established connection's non-zero generation and amdgpu_ualink_check_conn_ready() treated 0 as a wildcard and still unmapped the shared NPA range. With gen_count set to the remote's generation, a failed amdgpu_ualink_remote_shootdown() marks conn_state[remote_acc_id] as AMDGPU_UALINK_CONN_NOT_READY (or a prior reconnect mismatches gen_count and clears remote_acc_id from exp_xa_node->importers_bitmap). When amdgpu_ualink_unmap_all_npa_addr() then runs, no importer passes amdgpu_ualink_check_conn_ready(), so amdgpu_vm_update_range() is skipped. amdgpu_ualink_exp_cleanup_worker() still unpins and unreferences exp_xa_node->bo and calls amdgpu_ualink_free_all_npa_va() with orig_importers_bitmap, freeing the BO and the NPA VA range while the PTEs (with PTE.X =3D 1 set by amdgpu_ualink_force_retry_rpcs()) remain mapped in adev->ualink.npa_vm. Unmapping the local NPA VM mappings unconditionally for all allocated NPA ranges, regardless of remote connection state, would avoid leaving stale PTEs behind. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-fix-u5-amd= gpu-ualink-alias-gencount-v1-1-a2e17004b91c@tuta.io?part=3D1