On Fri Jan 9, 2026 at 2:07 PM CET, Boris Brezillon wrote:
> When the VM is protected with the root object resv, evicted extobjs
> are not inserted in the evict list.

I'd rather say: "When the evicted object list is protected with the root object
reservation lock, ...".

> Make sure we record when the extobj
> list contains evicted BOs that are not already in the evict list so we
> can validate those when drm_gpuvm_validate() is called.

Why is this necessary in the first place? drm_gpuvm_prepare_objects() picks up
the affected external objects already.

> Signed-off-by: Boris Brezillon <[email protected]>
> ---
>  drivers/gpu/drm/drm_gpuvm.c | 23 ++++++++++++++++++++++-
>  include/drm/drm_gpuvm.h     |  6 ++++++
>  2 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c
> index 0bb115b6b59c..95f0a1c843ad 100644
> --- a/drivers/gpu/drm/drm_gpuvm.c
> +++ b/drivers/gpu/drm/drm_gpuvm.c
> @@ -1505,6 +1505,22 @@ drm_gpuvm_validate_locked(struct drm_gpuvm *gpuvm, 
> struct drm_exec *exec)
>                       drm_gpuvm_bo_list_del_init(vm_bo, evict, false);
>       }
>  
> +     if (READ_ONCE(gpuvm->extobj.check_evicted)) {
> +             list_for_each_entry_safe(vm_bo, next, &gpuvm->extobj.list,
> +                                      list.entry.extobj) {

Running the external object list (again) seems wasteful given that this case can
never happen when drm_gpuvm_prepare_objects() is called before (which has to be
the case, given that somehow the objects have to be locked).

And even if for some reason you open code this, it would be much better to add a
helper doing the check when the object is locked.

> +                     dma_resv_assert_held(vm_bo->obj->resv);
> +
> +                     if (!vm_bo->evicted)
> +                             continue;
> +
> +                     ret = ops->vm_bo_validate(vm_bo, exec);
> +                     if (ret)
> +                             break;
> +             }
> +
> +             WRITE_ONCE(gpuvm->extobj.check_evicted, false);

Why do we need READ_ONCE() and WRITE_ONCE() here? Don't we hold the object's
reservation lock whenever we touch check_evicted anyways?

Reply via email to