On Mon, Nov 3, 2025 at 2:11 PM Christian König <[email protected]> wrote:
>
>
>
> On 11/3/25 16:24, Saleemkhan Jamadar wrote:
> > This should not be used indiviually, use amdgpu_bo_gpu_offset
> > with bo reserved.
> >
> > Signed-off-by: Saleemkhan Jamadar <[email protected]>
> > Suggested-by: Christian König <[email protected]>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c |  2 +-
> >  drivers/gpu/drm/amd/amdgpu/mes_userqueue.c       | 10 +++++++++-
> >  2 files changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c
> > index 3040437d99c2..bc7858567321 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c
> > @@ -129,7 +129,7 @@ uint32_t amdgpu_doorbell_index_on_bar(struct 
> > amdgpu_device *adev,
> >  {
> >       int db_bo_offset;
> >
> > -     db_bo_offset = amdgpu_bo_gpu_offset_no_check(db_bo);
> > +     db_bo_offset = amdgpu_bo_gpu_offset(db_bo);
> >
> >       /* doorbell index is 32 bit but doorbell's size can be 32 bit
> >        * or 64 bit, so *db_size(in byte)/4 for alignment.
> > diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c 
> > b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> > index b1ee9473d628..0a244f80426c 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> > @@ -93,7 +93,15 @@ mes_userq_create_wptr_mapping(struct amdgpu_userq_mgr 
> > *uq_mgr,
> >               return ret;
> >       }
> >
> > -     queue->wptr_obj.gpu_addr = 
> > amdgpu_bo_gpu_offset_no_check(wptr_obj->obj);
> > +     ret = amdgpu_bo_reserve(wptr_obj->obj, true);
> > +     if (ret) {
> > +             DRM_ERROR("Failed to reserve wptr bo\n");
> > +             return ret;
> > +     }
> > +
> > +     queue->wptr_obj.gpu_addr = amdgpu_bo_gpu_offset(wptr_obj->obj);
> > +     amdgpu_bo_unreserve(wptr_obj->obj);
>
> The problem here is that the return value of amdgpu_bo_gpu_offset() can 
> change as soon as you unlock the BO.
>
> So that wptr BO either need to be pinned or fenced for this to work.

amdgpu_amdkfd_map_gtt_bo_to_gart() and mes_userq_map_gtt_bo_to_gart()
differ in how they handle this.  amdgpu_amdkfd_map_gtt_bo_to_gart()
pins the BO while mes_userq_map_gtt_bo_to_gart() does not.

Alex

>
> Regards,
> Christian.
>
> > +
> >       return 0;
> >  }
> >
>

Reply via email to