[Intel-xe] [RFC PATCH] drm/xe: Use Xe BO pin / unpin functions for FB pin

Matthew Auld matthew.william.auld at gmail.com
Wed Apr 5 15:40:07 UTC 2023


On Wed, 5 Apr 2023 at 15:37, Matthew Brost <matthew.brost at intel.com> wrote:
>
> Need to use XE BO pin / unpin for suspend / resume to work properly.
> Part this fix too is too allow xe_bo_pin to be called more than once.
>
> v2:
>   - (Matthew Auld) fixup unpin
>
> Signed-off-by: Matthew Brost <matthew.brost at intel.com>

Tried to reload the module on DG2 with display enabled and it didn't
blow, so I guess we are good,
Reviewed-by: Matthew Auld <matthew.auld at intel.com>

> ---
>  drivers/gpu/drm/xe/display/xe_fb_pin.c | 4 ++--
>  drivers/gpu/drm/xe/xe_bo.c             | 8 +++++---
>  2 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> index 65c0bc28a3d1..c7c849be288f 100644
> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> @@ -205,7 +205,7 @@ static struct i915_vma *__xe_pin_fb_vma(struct intel_framebuffer *fb,
>
>         ret = xe_bo_validate(bo, NULL, true);
>         if (!ret)
> -               ttm_bo_pin(&bo->ttm);
> +               xe_bo_pin(bo);
>         ttm_bo_unreserve(&bo->ttm);
>         if (ret)
>                 goto err;
> @@ -222,7 +222,7 @@ static struct i915_vma *__xe_pin_fb_vma(struct intel_framebuffer *fb,
>
>  err_unpin:
>         ttm_bo_reserve(&bo->ttm, false, false, NULL);
> -       ttm_bo_unpin(&bo->ttm);
> +       xe_bo_unpin(bo);
>         ttm_bo_unreserve(&bo->ttm);
>  err:
>         kfree(vma);
> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> index 3a482c61c3ec..2cf112bedc92 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -1278,8 +1278,8 @@ int xe_bo_pin(struct xe_bo *bo)
>          */
>         XE_BUG_ON(bo->ttm.base.import_attach);
>
> -       /* We only expect at most 1 pin */
> -       XE_BUG_ON(xe_bo_is_pinned(bo));
> +       if (xe_bo_is_pinned(bo))
> +               goto pin;
>
>         err = xe_bo_validate(bo, NULL, false);
>         if (err)
> @@ -1308,6 +1308,7 @@ int xe_bo_pin(struct xe_bo *bo)
>                 }
>         }
>
> +pin:
>         ttm_bo_pin(&bo->ttm);
>
>         /*
> @@ -1359,7 +1360,8 @@ void xe_bo_unpin(struct xe_bo *bo)
>         XE_BUG_ON(bo->ttm.base.import_attach);
>         XE_BUG_ON(!xe_bo_is_pinned(bo));
>
> -       if (IS_DGFX(xe) && !(IS_ENABLED(CONFIG_DRM_XE_DEBUG) &&
> +       if (bo->ttm.pin_count == 1 && IS_DGFX(xe) &&
> +           !(IS_ENABLED(CONFIG_DRM_XE_DEBUG) &&
>             bo->flags & XE_BO_INTERNAL_TEST)) {
>                 struct ttm_place *place = &(bo->placements[0]);
>
> --
> 2.34.1
>


More information about the Intel-xe mailing list