* [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(¶ms, vmbo, 0, 0, entries, 0, flags);
+ amdgpu_vm_pt_clear_flags(adev, vm, level, &value, &flags);
+ r = vm->update_funcs->update(¶ms, 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* Re: [PATCH] drm/amdgpu: keep the address of cleared PDEs with translate further
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
1 sibling, 0 replies; 6+ messages in thread
From: Christian König @ 2026-11-26 10:35 UTC (permalink / raw)
To: Bob Zhou, amd-gfx, Hawking.Zhang, Alexander.Deucher, Mukul.Joshi,
Felix.Kuehling, Philip.Yang
On 11/26/26 11:19, Bob Zhou wrote:
> 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>
Reviewed-by: Christian König <christian.koenig@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(¶ms, vmbo, 0, 0, entries, 0, flags);
> + amdgpu_vm_pt_clear_flags(adev, vm, level, &value, &flags);
> + r = vm->update_funcs->update(¶ms, 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);
> }
>
> /*
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] drm/amdgpu: keep the address of cleared PDEs with translate further
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
1 sibling, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-26 10:40 UTC (permalink / raw)
To: Bob Zhou, amd-gfx
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/amdgpu: cleared PDE addr passed as incr in
amdgpu_vm_pt_clear()
--
commit d99a4183771402011e83a09490a1a9e68c1c93f4
Author: Bob Zhou <bobzhou2@amd.com>
drm/amdgpu: keep the address of cleared PDEs with translate further
This commit changes amdgpu_vm_pt_clear_flags() to output both the address and
flags for cleared PDEs/PTEs and passes the address to vm->update_funcs->update()
in amdgpu_vm_pt_clear().
> 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
[ ... ]
> @@ -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(¶ms, vmbo, 0, 0, entries, 0, flags);
> + amdgpu_vm_pt_clear_flags(adev, vm, level, &value, &flags);
> + r = vm->update_funcs->update(¶ms, vmbo, 0, 0, entries, value,
> + flags);
[Severity: High]
Does this pass value as the incr argument of vm->update_funcs->update()
instead of the addr argument?
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h:amdgpu_vm_update_funcs {
...
int (*update)(struct amdgpu_vm_update_params *p,
struct amdgpu_bo_vm *bo, uint64_t pe, uint64_t addr,
unsigned count, uint32_t incr, uint64_t flags);
...
}
When clearing a PDB0 page directory with translate_further enabled on GMC9,
gmc_v9_0_get_vm_pde() sets bit 12 (0x1000) in value and clears
AMDGPU_PDE_PTE from flags. Passing 0 for addr and value for incr makes
both the CPU and SDMA updaters write (0 + i * 0x1000) | flags to entry i,
so entry 0 still reads as 0 and subsequent entries get incrementing
addresses rather than a constant 0x1000, triggering VM faults on hardware
page table walks.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126101946.2651048-1-bobzhou2@amd.com?part=1
^ permalink raw reply [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(¶ms, vmbo, 0, 0, entries, 0, flags);
+ flags = amdgpu_vm_pt_clear_flags(adev, vm, level, &value);
+ r = vm->update_funcs->update(¶ms, 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* Re: [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
1 sibling, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-26 7:52 UTC (permalink / raw)
To: Bob Zhou, amd-gfx
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/amdgpu: cleared PDE addr passed as incr in
amdgpu_vm_pt_clear()
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] drm/amdgpu: unchecked update() return in
amdgpu_vm_pte_update_flags() [1]
--
commit 989da6857bfdb3b7b6591cb250770217b86c1b11
Author: Bob Zhou <bobzhou2@amd.com>
drm/amdgpu: keep the address of cleared PDEs with translate further
This commit passes an address pointer into amdgpu_vm_pt_clear_flags() so
that callers receive the PDE address generated by amdgpu_gmc_get_vm_pde()
when clearing page directories.
> 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
[ ... ]
> @@ -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(¶ms, vmbo, 0, 0, entries, 0, flags);
> + flags = amdgpu_vm_pt_clear_flags(adev, vm, level, &value);
> + r = vm->update_funcs->update(¶ms, vmbo, 0, 0, entries, value,
> + flags);
> if (r)
> goto exit;
>
[Severity: High]
Does this pass value as the incr argument instead of the addr argument to
vm->update_funcs->update()?
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h:struct amdgpu_vm_update_funcs {
...
int (*update)(struct amdgpu_vm_update_params *p,
struct amdgpu_bo_vm *bo, uint64_t pe, uint64_t addr,
unsigned count, uint32_t incr, uint64_t flags);
...
}
Because addr is left at 0 and value is passed as incr, entry 0 of a
cleared PDB0 on GMC v9 with translate_further enabled is still written with
address 0, and subsequent entries increment by 0x1000 per entry (leaving
bit 12 clear on all even entries) instead of writing value to every entry,
causing GPU VM faults during page table walks.
Should value be passed as the fourth argument (addr) and 0 as the sixth
argument (incr)?
> @@ -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);
> }
>
> /*
[Severity: Critical]
This problem wasn't introduced by this patch, but can
amdgpu_vm_pte_update_flags() cause a NULL pointer dereference on
params->job [1] by ignoring the return value of
params->vm->update_funcs->update()?
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c:amdgpu_vm_sdma_update() {
...
if (ndw < 32) {
r = amdgpu_vm_sdma_commit(p, NULL);
if (r)
return r;
r = amdgpu_vm_sdma_alloc_job(p, count,
AMDGPU_KERNEL_JOB_ID_VM_UPDATE);
if (r)
return r;
}
...
pte = (uint64_t *)&(p->job->ibs->ptr[p->num_dw_left]);
...
}
When amdgpu_vm_sdma_commit() runs during amdgpu_vm_sdma_update() and the
subsequent amdgpu_vm_sdma_alloc_job() fails, p->job is left NULL. Because
amdgpu_vm_pte_update_flags() returns void and discards the error, the loop
in amdgpu_vm_ptes_update() continues and the next call to
amdgpu_vm_sdma_update() or amdgpu_vm_sdma_commit() dereferences the NULL
p->job pointer.
[1] https://sashiko.dev/#/bug/linux-1897ae3a-7a03-49b7-b2ae-54c63b21478f
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126073232.2108102-1-bobzhou2@amd.com?part=1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [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
1 sibling, 0 replies; 6+ messages in thread
From: Christian König @ 2026-11-26 9:45 UTC (permalink / raw)
To: Bob Zhou, amd-gfx, Hawking.Zhang, Alexander.Deucher, Mukul.Joshi,
Felix.Kuehling, Philip.Yang
On 11/26/26 08:32, Bob Zhou wrote:
> 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.
^^ we should probably stop doing such hacks.
>
> 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)
If we need multiple return values please make amdgpu_vm_pt_clear_flags() return void and give flags as parameter.
Apart from that looks good to me.
Thanks a lot for figuring that out,
Christian.
> {
> 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(¶ms, vmbo, 0, 0, entries, 0, flags);
> + flags = amdgpu_vm_pt_clear_flags(adev, vm, level, &value);
> + r = vm->update_funcs->update(¶ms, 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);
> }
>
> /*
^ permalink raw reply [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