From: sashiko-bot@kernel.org
To: "Zhigang Luo" <Zhigang.Luo@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 4/7] drm/amdgpu: set the A+A VF SYSTEM bit in the GFX 12.1 helpers
Date: Fri, 13 Nov 2026 15:20:48 +0000 [thread overview]
Message-ID: <sashiko-outbox-213076@kernel.org> (raw)
In-Reply-To: <20261113145702.323968-4-Zhigang.Luo@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/amdgpu: gmc_v12_1_get_vm_pde() sets AMDGPU_PTE_SYSTEM on
invalid and NPA PDEs
- [Medium] drm/amdgpu: gmc_v12_1_get_vm_pte() sets AMDGPU_PTE_SYSTEM
when PTE is invalid
--
commit 914948e43f4fe117dbe355b73ada0eb4485a66d2
Author: Zhigang Luo <Zhigang.Luo@amd.com>
drm/amdgpu: set the A+A VF SYSTEM bit in the GFX 12.1 helpers
This commit sets AMDGPU_PTE_SYSTEM in gmc_v12_1_get_vm_pde() and
gmc_v12_1_get_vm_pte() when VRAM is backed by system physical memory on
SR-IOV VFs.
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
> index 57aac3a9a3b0f..1c5998fa3ad6e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
> @@ -586,6 +586,12 @@ static void gmc_v12_1_get_vm_pde(struct amdgpu_device *adev, int level,
> *addr = adev->vm_manager.vram_base_offset + *addr -
> adev->gmc.vram_start;
>
> + /* SPM VRAM is reached at a system physical address. Set S after the
> + * translation above so that translation is not skipped.
> + */
> + if (amdgpu_virt_vram_is_spm(adev))
> + *flags |= AMDGPU_PTE_SYSTEM;
> +
> if (*addr & ~adev->gmc.pte_addr_mask) {
> dev_err(adev->dev, "Invalid PDE address: %llx\n", *addr);
> *addr = 0;
[Severity: High]
Does setting AMDGPU_PTE_SYSTEM here without checking (*flags &
AMDGPU_PTE_VALID) corrupt cleared PDEs and 2MB+ NPA leaf PDEs?
On GFX 12, gmc_v12_1_get_vm_pde() always sets AMDGPU_PTE_SNOOPED, and
(AMDGPU_PTE_SYSTEM | AMDGPU_PTE_SNOOPED) on an invalid entry is
AMDGPU_VM_NORETRY_FLAGS_GFX12. When amdgpu_vm_pt_clear() clears a
non-PTB page directory (with AMDGPU_PTE_VALID == 0), this turns every
cleared PDE in a normal VM into a fatal no-retry fault entry, breaking
SVM demand paging on unpopulated ranges.
For 2MB+ AMDGPU_PL_NPA mappings updated at a leaf PDE level in
amdgpu_vm_pte_update_flags(), gmc_v12_1_get_npa_flags() clears
AMDGPU_PTE_VALID and leaves AMDGPU_PTE_SYSTEM clear (VSCT = 0011), which
amdgpu_gmc_get_vm_pde() then overwrites with AMDGPU_PTE_SYSTEM.
> @@ -753,6 +759,10 @@ static void gmc_v12_1_get_vm_pte(struct amdgpu_device *adev,
>
> if (bo) {
> mem = bo->tbo.resource;
> + if (amdgpu_virt_vram_is_spm(adev) &&
> + mem && mem->mem_type == TTM_PL_VRAM)
> + *flags |= AMDGPU_PTE_SYSTEM;
> +
> if (mem && mem->mem_type == AMDGPU_PL_NPA) {
> dev_dbg(adev->dev,
> "Setting PTE for NPA BO, mem->type: %d, mem->start: %lx, mem->size: %u, cur_flags: %llx\n",
> @@ -761,6 +771,9 @@ static void gmc_v12_1_get_vm_pte(struct amdgpu_device *adev,
> } else if (*flags & AMDGPU_PTE_VALID) {
> gmc_v12_1_get_coherence_flags(adev, bo, flags);
> }
> + } else if (amdgpu_virt_vram_is_spm(adev)) {
> + /* SVM has no BO. System memory already has S. VRAM does not. */
> + *flags |= AMDGPU_PTE_SYSTEM;
> }
> }
[Severity: Medium]
Should both branches check (*flags & AMDGPU_PTE_VALID) before setting
AMDGPU_PTE_SYSTEM?
When amdgpu_vm_handle_moved() calls amdgpu_vm_bo_update() with clear =
true after dma_resv_trylock() fails, bo->tbo.base.resv is not held and
update_flags has AMDGPU_PTE_VALID == 0. Checking mem->mem_type before
(*flags & AMDGPU_PTE_VALID) reads bo->tbo.resource without holding the
reservation lock and sets AMDGPU_PTE_SYSTEM on cleared PTEs.
In the else branch, amdgpu_vm_bo_update() also passes bo == NULL with
AMDGPU_PTE_VALID == 0 for PRT/sparse mappings (fpriv->prt_va), so
setting AMDGPU_PTE_SYSTEM unconditionally pollutes invalid non-SVM PTEs
(and forms AMDGPU_VM_NORETRY_FLAGS_GFX12 if a cleared or PRT mapping
spans a 2MB+ leaf PDE).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261113145702.323968-1-Zhigang.Luo@amd.com?part=4
next prev parent reply other threads:[~2026-11-13 15:21 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 14:56 [PATCH 1/7] Revert "drm/amdgpu: mark A+A VF VRAM mappings as system memory" Zhigang Luo
2026-11-13 14:56 ` [PATCH 2/7] Revert "drm/amdkfd: mark A+A VF VRAM PTEs " Zhigang Luo
2026-11-13 15:16 ` sashiko-bot
2026-11-13 14:56 ` [PATCH 3/7] Revert "drm/amdgpu: take the A+A VF GMC aperture from SRAT" Zhigang Luo
2026-11-13 15:20 ` sashiko-bot
2026-11-13 14:56 ` [PATCH 4/7] drm/amdgpu: set the A+A VF SYSTEM bit in the GFX 12.1 helpers Zhigang Luo
2026-11-13 15:20 ` sashiko-bot [this message]
2026-11-16 9:43 ` Christian König
2026-11-13 14:57 ` [PATCH 5/7] drm/amdgpu: fill the A+A VF PDB0 through get_vm_pde Zhigang Luo
2026-11-13 15:14 ` sashiko-bot
2026-11-16 16:12 ` Luo, Zhigang
2026-11-16 9:44 ` Christian König
2026-11-13 14:57 ` [PATCH 6/7] drm/amdgpu: align the sysvm GART start to 8GB Zhigang Luo
2026-11-13 15:05 ` sashiko-bot
2026-11-16 10:09 ` Christian König
2026-11-13 14:57 ` [PATCH 7/7] drm/amdgpu: keep the A+A VF VRAM base at the SRAT address Zhigang Luo
2026-11-13 15:29 ` sashiko-bot
2026-11-16 12:04 ` Christian König
2026-11-13 15:11 ` [PATCH 1/7] Revert "drm/amdgpu: mark A+A VF VRAM mappings as system memory" sashiko-bot
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-213076@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Zhigang.Luo@amd.com \
--cc=amd-gfx@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