Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/amdgpu: ignored WPTR mapping offsets in userqueue
  synchronization [1]
--

commit c736ecb92e4ba4e91728f33ea27cd11d90100ae5
Author: Benjamin Cheng <[email protected]>

drm/amdgpu/userq: remove extra fence request when locking PD

This commit changes amdgpu_vm_lock_pd() calls in
amdgpu_userq_fence_read_wptr() and mes_userq_create_wptr_mapping() to
request zero fence slots instead of one.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> index 6d1f5811d39c3..07a0af9feaf08 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> @@ -380,7 +380,7 @@ static int amdgpu_userq_fence_read_wptr(struct 
> amdgpu_device *adev,
>  
>       drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 2);
>       drm_exec_until_all_locked(&exec) {
> -             ret = amdgpu_vm_lock_pd(queue->vm, &exec, 1);
> +             ret = amdgpu_vm_lock_pd(queue->vm, &exec, 0);
>               drm_exec_retry_on_contention(&exec);
>               if (unlikely(ret))
>                       goto lock_error;
> diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c 
> b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> index 7abb9d95ef59a..8b07e21d26862 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> @@ -48,7 +48,7 @@ mes_userq_create_wptr_mapping(struct amdgpu_device *adev,
>  
>       drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 2);
>       drm_exec_until_all_locked(&exec) {
> -             ret = amdgpu_vm_lock_pd(vm, &exec, 1);
> +             ret = amdgpu_vm_lock_pd(vm, &exec, 0);
>               drm_exec_retry_on_contention(&exec);
>               if (unlikely(ret))
>                       goto fail_lock;

[Severity: High]
This problem wasn't introduced by this patch, but does
mes_userq_create_wptr_mapping() ignore the internal mapping and sub-page
offset when setting queue->wptr_obj.gpu_addr [1]?

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c:mes_userq_create_wptr_mapping() {
    ...
        queue->wptr_obj.gpu_addr = amdgpu_bo_gpu_offset(wptr_obj->obj);
    ...
}

When a usermode queue places its WPTR at a non-zero offset within the
backing BO, mes_userq_create_wptr_mapping() sets queue->wptr_obj.gpu_addr
to the base GPU offset of wptr_obj->obj without adding the mapping and
sub-page offsets (and if amdgpu_userq_fence_read_wptr() reads *ptr at
offset 0 directly, it misses the offset on the CPU side as well).  This
causes the firmware and CPU fence polling to read the wrong memory address,
leading to premature fence signaling or command submission deadlocks.

[1] https://sashiko.dev/#/bug/linux-485b27a5-4aad-464a-b5b7-ad02f7bafded

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=5

Reply via email to