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 <[email protected]>

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(&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);

[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/[email protected]?part=1

Reply via email to