AMD General Hi Christian,
Thanks for the review. You were right that PRT has no BO and needs a check. v3 gates the new SYSTEM bit on AMDGPU_PTE_VALID in all three places: - gmc_v12_1_get_vm_pde(): set S only if VALID is already set. The check runs before the address-mask check can clear VALID. - gmc_v12_1_get_vm_pte(), VRAM BO branch: same check before the mem_type test. - gmc_v12_1_get_vm_pte(), NULL-BO else (SVM): same check. I chose VALID rather than testing AMDGPU_VM_PAGE_PRT in vm_flags. gmc_v12_1_get_vm_pde() does not receive vm_flags, so VALID is the only flag that reaches both helpers. A PRT update reaches get_vm_pte() with VALID clear and no BO, so it gets no S. A cleared page-directory entry and a 2 MB NPA leaf also have VALID clear by the time get_vm_pde() runs, so they keep S clear too. SVM still gets S because svm_range_get_pte_flags() sets VALID before it calls amdgpu_gmc_get_vm_pte(). PDB0 sets VALID before calling get_vm_pde(), so its entries keep S. Thanks, Zhigang > -----Original Message----- > From: Koenig, Christian <[email protected]> > Sent: Monday, November 16, 2026 4:43 AM > To: Luo, Zhigang <[email protected]>; [email protected] > Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking > <[email protected]>; Lazar, Lijo <[email protected]> > Subject: Re: [PATCH 4/7] drm/amdgpu: set the A+A VF SYSTEM bit in the GFX > 12.1 helpers > > > > On 11/13/26 15:56, Zhigang Luo wrote: > > gmc_v12_1_get_vm_pde() converts a VRAM MC address to a physical > > address and skips that conversion when AMDGPU_PTE_SYSTEM is already > > set. Set the bit after the translation so the address stays physical. > > > > gmc_v12_1_get_vm_pte() sets the bit for a VRAM buffer object. SVM > > calls it with a NULL buffer object, and svm_range_get_pte_flags() sets > > the bit only for system memory, so the NULL case sets it for SPM VRAM. > > NPA mappings are left unchanged. > > > > v2: > > - Set the bit for a VRAM BO inside if (bo), and for the SVM NULL BO > > in the else. > > > > Signed-off-by: Zhigang Luo <[email protected]> > > --- > > drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 13 +++++++++++++ > > 1 file changed, 13 insertions(+) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c > > b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c > > index 76391fca6c62..7ac0d9c6f280 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; > > @@ -758,6 +764,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", @@ -766,6 +776,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; > > Both SVM and PRT doesn't use a BO, so could be that this causes problems > with PRT. > > Please double check the VM programming guide that this is ok, if not change > the code so that PRT is excluded. > > With that done Reviewed-by: Christian König <[email protected]> > > Regards, > Christian. > > > } > > } > >
