[PATCH v2 15/16] drm/xe/sriov: Convert pf_provision_vf_lmem for exhaustive eviction
Matthew Brost
matthew.brost at intel.com
Fri Aug 22 19:35:28 UTC 2025
On Fri, Aug 22, 2025 at 11:40:29AM +0200, Thomas Hellström wrote:
> Open-code since this is the only identified instance of pinning
> without mapping.
>
> v2:
> - Break out this patch from the previous one.
>
> Signed-off-by: Thomas Hellström <thomas.hellstrom at linux.intel.com>
> ---
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 51 ++++++++++++++--------
> 1 file changed, 33 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index 906011671b60..c9e3c811c35b 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -1452,11 +1452,12 @@ static bool pf_release_vf_config_lmem(struct xe_gt *gt, struct xe_gt_sriov_confi
> static int pf_provision_vf_lmem(struct xe_gt *gt, unsigned int vfid, u64 size)
> {
> struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
> - struct drm_exec *exec = XE_VALIDATION_UNIMPLEMENTED;
> struct xe_device *xe = gt_to_xe(gt);
> struct xe_tile *tile = gt_to_tile(gt);
> + struct xe_validation_ctx ctx;
> + struct drm_exec exec;
> struct xe_bo *bo;
> - int err;
> + int err = 0;
>
> xe_gt_assert(gt, vfid);
> xe_gt_assert(gt, IS_DGFX(xe));
> @@ -1479,23 +1480,37 @@ static int pf_provision_vf_lmem(struct xe_gt *gt, unsigned int vfid, u64 size)
> return 0;
>
> xe_gt_assert(gt, pf_get_lmem_alignment(gt) == SZ_2M);
> - bo = xe_bo_create_locked(xe, tile, NULL,
> - ALIGN(size, PAGE_SIZE),
> - ttm_bo_type_kernel,
> - XE_BO_FLAG_VRAM_IF_DGFX(tile) |
> - XE_BO_FLAG_NEEDS_2M |
> - XE_BO_FLAG_PINNED |
> - XE_BO_FLAG_PINNED_LATE_RESTORE,
> - exec);
> - if (IS_ERR(bo))
> - return PTR_ERR(bo);
> -
> - err = xe_bo_pin(bo, exec);
> - xe_bo_unlock(bo);
> - if (unlikely(err)) {
> - xe_bo_put(bo);
> - return err;
> +
> + /*
> + * Open-code for now, since this is the only instance of
> + * pinning without mapping.
> + */
> + xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {.exclusive = true}, err) {
> + bo = xe_bo_create_locked(xe, tile, NULL,
> + ALIGN(size, PAGE_SIZE),
> + ttm_bo_type_kernel,
> + XE_BO_FLAG_VRAM_IF_DGFX(tile) |
> + XE_BO_FLAG_NEEDS_2M |
> + XE_BO_FLAG_PINNED |
> + XE_BO_FLAG_PINNED_LATE_RESTORE,
> + &exec);
> + if (IS_ERR(bo)) {
> + drm_exec_retry_on_contention(&exec);
> + err = PTR_ERR(bo);
> + xe_validation_retry_on_oom(&ctx, &err);
> + return PTR_ERR(bo);
> + }
> +
> + err = xe_bo_pin(bo, &exec);
> + xe_bo_unlock(bo);
> + if (err) {
> + xe_bo_put(bo);
> + drm_exec_retry_on_contention(&exec);
> + xe_validation_retry_on_oom(&ctx, &err);
I think you can do 'return err;' here.
Matt
> + }
> }
> + if (err)
> + return err;
>
> config->lmem_obj = bo;
>
> --
> 2.50.1
>
More information about the Intel-xe
mailing list