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

Reviewed-by: Christian König <[email protected]>

> ---
>  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);
>       }
>  
>       /*

Reply via email to