[PATCH] drm/amdgpu: Check BO's requested pinning domains against its preferred_domains

Alex Deucher alexdeucher at gmail.com
Tue Jul 12 13:46:40 UTC 2022


On Tue, Jul 12, 2022 at 3:28 AM Christian König
<christian.koenig at amd.com> wrote:
>
> Am 12.07.22 um 00:44 schrieb sunpeng.li at amd.com:
> > From: Leo Li <sunpeng.li at amd.com>
> >
> > When pinning a buffer, we should check to see if there are any
> > additional restrictions imposed by bo->preferred_domains. This will
> > prevent the BO from being moved to an invalid domain when pinning.
> >
> > For example, this can happen if the user requests to create a BO in GTT
> > domain for display scanout. amdgpu_dm will allow pinning to either VRAM
> > or GTT domains, since DCN can scanout from either or. However, in
> > amdgpu_bo_pin_restricted(), pinning to VRAM is preferred if there is
> > adequate carveout. This can lead to pinning to VRAM despite the user
> > requesting GTT placement for the BO.
> >
> > Signed-off-by: Leo Li <sunpeng.li at amd.com>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 +++
> >   1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> > index 8a7b0f6162da..50400d70ef12 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> > @@ -883,6 +883,9 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
> >       if (WARN_ON_ONCE(min_offset > max_offset))
> >               return -EINVAL;
> >
> > +     /* Check domain to be pinned to against preferred domains */
> > +     domain = bo->preferred_domains & domain
>
> Please guard that with an "if (bo->preferred_domains & domain)" to
> handle the case when the kernel needs to override the pin domain. That
> can happen when we export a BO to a V4L camera (for example).
>
> Apart from that looks like a rather nice bugfix.
>
> Alex should we add a CC stable to this?

Yes, I can add a stable tag.

Alex


>
> Regards,
> Christian.
>
> > +
> >       /* A shared bo cannot be migrated to VRAM */
> >       if (bo->tbo.base.import_attach) {
> >               if (domain & AMDGPU_GEM_DOMAIN_GTT)
>


More information about the amd-gfx mailing list