From: sashiko-bot@kernel.org
To: bob <bobmcd@tuta.io>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: use the per-remote UALink generation count in Source-Alias mode
Date: Wed, 02 Dec 2026 20:06:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-246575@kernel.org> (raw)
In-Reply-To: <20261203-fix-u5-amdgpu-ualink-alias-gencount-v1-1-a2e17004b91c@tuta.io>
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 <bobmcd@tuta.io>
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 = 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;
>
> size = amdgpu_bo_ngpu_pages(exp_xa_node->bo);
> @@ -2712,9 +2716,13 @@ static void amdgpu_ualink_send_tlb_shootdown(struct amdgpu_device *adev,
>
> npa_addr = STRIP_NPA(imp_entry->npa_addr);
> npa_addr = 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 = exp_xa_node->importer_entries[remote_acc_id].generation_count;
>
> 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 = NULL;
> struct drm_exec exec;
> u64 npa_addr, size;
> - u32 remote_acc_id;
> + u32 remote_acc_id, gen_count;
> int r;
>
> size = amdgpu_bo_ngpu_pages(exp_xa_node->bo);
> @@ -2774,9 +2782,13 @@ static void amdgpu_ualink_unmap_all_npa_addr(struct amdgpu_device *adev,
> else
> imp_entry = &exp_xa_node->importer_entries[remote_acc_id];
> npa_addr = 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 = exp_xa_node->importer_entries[remote_acc_id].generation_count;
>
> 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 = 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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-fix-u5-amdgpu-ualink-alias-gencount-v1-1-a2e17004b91c@tuta.io?part=1
prev parent reply other threads:[~2026-12-02 20:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 19:56 [PATCH] drm/amdgpu: use the per-remote UALink generation count in Source-Alias mode bob via B4 Relay
2026-12-02 20:06 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-246575@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=bobmcd@tuta.io \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox