AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: keep the address of cleared PDEs with translate further
@ 2026-11-26 10:19 Bob Zhou
  2026-11-26 10:35 ` Christian König
  2026-11-26 10:40 ` sashiko-bot
  0 siblings, 2 replies; 6+ messages in thread
From: Bob Zhou @ 2026-11-26 10:19 UTC (permalink / raw)
  To: amd-gfx, Hawking.Zhang, christian.koenig, Alexander.Deucher,
	Mukul.Joshi, Felix.Kuehling, Philip.Yang
  Cc: Bob Zhou

Commit 37a0bad677a7 ("drm/amdgpu: Update PTE flags with TF enabled")
made gmc_v9_0_get_vm_pde() set bit 12 in the address of an invalid PDB0
entry, because with translate further consecutive invalid entries which
read as 0 are considered a fault.

amdgpu_vm_pt_clear_flags() drops that address and amdgpu_vm_pt_clear()
writes 0 instead. Return both the address and the flags to the caller
and write the address again.

Fixes: 6250a8342784 ("drm/amdgpu: fix cleared PDE/PTE flag generation")
Signed-off-by: Bob Zhou <bobzhou2@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 36 ++++++++++-------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
index a6d389c08524f..8f1e0bc7d65ae 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
@@ -346,31 +346,26 @@ static void amdgpu_vm_pt_next_dfs(struct amdgpu_device *adev,
 	     amdgpu_vm_pt_continue_dfs((start), (entry));			\
 	     (entry) = (cursor).entry, amdgpu_vm_pt_next_dfs((adev), &(cursor)))
 
-/* Return the flags used for cleared PDEs/PTES */
-static uint64_t amdgpu_vm_pt_clear_flags(struct amdgpu_device *adev,
-					struct amdgpu_vm *vm,
-					unsigned int level)
+/* Set @addr and @flags for cleared PDEs/PTEs */
+static void amdgpu_vm_pt_clear_flags(struct amdgpu_device *adev,
+				     struct amdgpu_vm *vm,
+				     unsigned int level, uint64_t *addr,
+				     uint64_t *flags)
 {
-	uint64_t flags;
-
 	if (adev->asic_type < CHIP_VEGA10)
-		return 0;
+		return;
 
 	if (level != AMDGPU_VM_PTB) {
-		uint64_t value = 0;
-
-		flags = AMDGPU_PDE_PTE_FLAG(adev);
+		*flags |= AMDGPU_PDE_PTE_FLAG(adev);
 		if (vm->is_npa)
-			flags |= adev->gmc.noretry_flags;
-		amdgpu_gmc_get_vm_pde(adev, level, &value, &flags);
+			*flags |= adev->gmc.noretry_flags;
+		amdgpu_gmc_get_vm_pde(adev, level, addr, flags);
 	} else if (vm->is_npa) {
-		flags = adev->gmc.noretry_flags;
+		*flags |= adev->gmc.noretry_flags;
 	} else {
 		/* Workaround for fault priority problem on GMC9 */
-		flags = AMDGPU_PTE_EXECUTABLE | adev->gmc.init_pte_flags;
+		*flags |= AMDGPU_PTE_EXECUTABLE | adev->gmc.init_pte_flags;
 	}
-
-	return flags;
 }
 
 /**
@@ -395,7 +390,7 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	struct amdgpu_bo *ancestor = &vmbo->bo;
 	struct amdgpu_bo *bo = &vmbo->bo;
 	unsigned int entries;
-	uint64_t flags;
+	uint64_t value = 0, flags = 0;
 	int r, idx;
 
 	/* Figure out our place in the hierarchy */
@@ -430,8 +425,9 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	if (r)
 		goto exit;
 
-	flags = amdgpu_vm_pt_clear_flags(adev, vm, level);
-	r = vm->update_funcs->update(&params, vmbo, 0, 0, entries, 0, flags);
+	amdgpu_vm_pt_clear_flags(adev, vm, level, &value, &flags);
+	r = vm->update_funcs->update(&params, vmbo, 0, 0, entries, value,
+				     flags);
 	if (r)
 		goto exit;
 
@@ -724,7 +720,7 @@ static void amdgpu_vm_pte_update_flags(struct amdgpu_vm_update_params *params,
 
 	} else if (!(flags & AMDGPU_PTE_VALID) &&
 		   !(flags & AMDGPU_PTE_PRT_FLAG(params->adev))) {
-		flags |= amdgpu_vm_pt_clear_flags(adev, params->vm, level);
+		amdgpu_vm_pt_clear_flags(adev, params->vm, level, &addr, &flags);
 	}
 
 	/*
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] drm/amdgpu: keep the address of cleared PDEs with translate further
@ 2026-11-26  7:32 Bob Zhou
  2026-11-26  7:52 ` sashiko-bot
  2026-11-26  9:45 ` Christian König
  0 siblings, 2 replies; 6+ messages in thread
From: Bob Zhou @ 2026-11-26  7:32 UTC (permalink / raw)
  To: amd-gfx, Hawking.Zhang, christian.koenig, Alexander.Deucher,
	Mukul.Joshi, Felix.Kuehling, Philip.Yang
  Cc: Bob Zhou

Commit 37a0bad677a7 ("drm/amdgpu: Update PTE flags with TF enabled")
made gmc_v9_0_get_vm_pde() set bit 12 in the address of an invalid PDB0
entry, because with translate further consecutive invalid entries which
read as 0 are considered a fault.

amdgpu_vm_pt_clear_flags() drops that address and amdgpu_vm_pt_clear()
writes 0 instead.Hand the address back to the caller and write it again.

Fixes: 6250a8342784 ("drm/amdgpu: fix cleared PDE/PTE flag generation")
Signed-off-by: Bob Zhou <bobzhou2@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
index a6d389c08524f..6aabd9f5291c2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
@@ -349,7 +349,7 @@ static void amdgpu_vm_pt_next_dfs(struct amdgpu_device *adev,
 /* Return the flags used for cleared PDEs/PTES */
 static uint64_t amdgpu_vm_pt_clear_flags(struct amdgpu_device *adev,
 					struct amdgpu_vm *vm,
-					unsigned int level)
+					unsigned int level, uint64_t *addr)
 {
 	uint64_t flags;
 
@@ -357,12 +357,10 @@ static uint64_t amdgpu_vm_pt_clear_flags(struct amdgpu_device *adev,
 		return 0;
 
 	if (level != AMDGPU_VM_PTB) {
-		uint64_t value = 0;
-
 		flags = AMDGPU_PDE_PTE_FLAG(adev);
 		if (vm->is_npa)
 			flags |= adev->gmc.noretry_flags;
-		amdgpu_gmc_get_vm_pde(adev, level, &value, &flags);
+		amdgpu_gmc_get_vm_pde(adev, level, addr, &flags);
 	} else if (vm->is_npa) {
 		flags = adev->gmc.noretry_flags;
 	} else {
@@ -395,7 +393,7 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	struct amdgpu_bo *ancestor = &vmbo->bo;
 	struct amdgpu_bo *bo = &vmbo->bo;
 	unsigned int entries;
-	uint64_t flags;
+	uint64_t value = 0, flags;
 	int r, idx;
 
 	/* Figure out our place in the hierarchy */
@@ -430,8 +428,9 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	if (r)
 		goto exit;
 
-	flags = amdgpu_vm_pt_clear_flags(adev, vm, level);
-	r = vm->update_funcs->update(&params, vmbo, 0, 0, entries, 0, flags);
+	flags = amdgpu_vm_pt_clear_flags(adev, vm, level, &value);
+	r = vm->update_funcs->update(&params, vmbo, 0, 0, entries, value,
+				     flags);
 	if (r)
 		goto exit;
 
@@ -724,7 +723,8 @@ static void amdgpu_vm_pte_update_flags(struct amdgpu_vm_update_params *params,
 
 	} else if (!(flags & AMDGPU_PTE_VALID) &&
 		   !(flags & AMDGPU_PTE_PRT_FLAG(params->adev))) {
-		flags |= amdgpu_vm_pt_clear_flags(adev, params->vm, level);
+		flags |= amdgpu_vm_pt_clear_flags(adev, params->vm, level,
+						  &addr);
 	}
 
 	/*
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-26 10:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 10:19 [PATCH] drm/amdgpu: keep the address of cleared PDEs with translate further Bob Zhou
2026-11-26 10:35 ` Christian König
2026-11-26 10:40 ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-11-26  7:32 Bob Zhou
2026-11-26  7:52 ` sashiko-bot
2026-11-26  9:45 ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox