From: Matthew Brost Date: Wed, 8 Oct 2025 21:45:09 +0000 (-0700) Subject: drm/xe/vf: Remove memory allocations from VF post migration recovery X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98e78e0c8b1bbb388d5ee702d2eb0013c2f9060a;p=thirdparty%2Fkernel%2Flinux.git drm/xe/vf: Remove memory allocations from VF post migration recovery VF post migration recovery is the path of dma-fence signaling / reclaim, avoid memory allocations in this path. v3: - s/lrc_wa_bb/scratch (Tomasz) Signed-off-by: Matthew Brost Reviewed-by: Tomasz Lis Link: https://lore.kernel.org/r/20251008214532.3442967-12-matthew.brost@intel.com --- diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c index 93612ea5029fb..737243fd3d40a 100644 --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c @@ -1165,17 +1165,13 @@ static size_t post_migration_scratch_size(struct xe_device *xe) static int vf_post_migration_fixups(struct xe_gt *gt) { + void *buf = gt->sriov.vf.migration.scratch; s64 shift; - void *buf; int err; - buf = kmalloc(post_migration_scratch_size(gt_to_xe(gt)), GFP_ATOMIC); - if (!buf) - return -ENOMEM; - err = xe_gt_sriov_vf_query_config(gt); if (err) - goto out; + return err; shift = xe_gt_sriov_vf_ggtt_shift(gt); if (shift) { @@ -1183,12 +1179,10 @@ static int vf_post_migration_fixups(struct xe_gt *gt) xe_gt_sriov_vf_default_lrcs_hwsp_rebase(gt); err = xe_guc_contexts_hwsp_rebase(>->uc.guc, buf); if (err) - goto out; + return err; } -out: - kfree(buf); - return err; + return 0; } static void vf_post_migration_kickstart(struct xe_gt *gt) @@ -1273,9 +1267,18 @@ static void migration_worker_func(struct work_struct *w) */ int xe_gt_sriov_vf_init_early(struct xe_gt *gt) { + void *buf; + if (!xe_sriov_vf_migration_supported(gt_to_xe(gt))) return 0; + buf = drmm_kmalloc(>_to_xe(gt)->drm, + post_migration_scratch_size(gt_to_xe(gt)), + GFP_KERNEL); + if (!buf) + return -ENOMEM; + + gt->sriov.vf.migration.scratch = buf; spin_lock_init(>->sriov.vf.migration.lock); INIT_WORK(>->sriov.vf.migration.worker, migration_worker_func); diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h b/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h index b2c8e8c89c301..e753646debc4d 100644 --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h @@ -55,6 +55,8 @@ struct xe_gt_sriov_vf_migration { struct work_struct worker; /** @lock: Protects recovery_queued */ spinlock_t lock; + /** @scratch: Scratch memory for VF recovery */ + void *scratch; /** @recovery_queued: VF post migration recovery in queued */ bool recovery_queued; /** @recovery_inprogress: VF post migration recovery in progress */