[PATCH] drm/xe/vf: Fix up GGTT on S4 resume under SR-IOV
Satyanarayana K V P
satyanarayana.k.v.p at intel.com
Wed Aug 20 08:44:53 UTC 2025
With SRIOV enabled, while resuming from S4, there is a possibility that,
the VM might have been suspended on one VF and resumed on another VF.
Since GGTT space is not virtualized, we need to fixup all the GGTT
references while resuming.
While resuming from S4, check whether the GGTT space is same or not for
the given VF and fix-up if it is different.
Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p at intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
Cc: Michal Winiarski <michal.winiarski at intel.com>
Cc: Matthew Brost <matthew.brost at intel.com>
Cc: Tomasz Lis <tomasz.lis at intel.com>
---
drivers/gpu/drm/xe/xe_pm.c | 8 +++++++
drivers/gpu/drm/xe/xe_sriov_vf.c | 36 ++++++++++++++++++++++++++++++++
drivers/gpu/drm/xe/xe_sriov_vf.h | 1 +
3 files changed, 45 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index 51934d5dc44f..821e796e91e2 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -23,6 +23,7 @@
#include "xe_irq.h"
#include "xe_pcode.h"
#include "xe_pxp.h"
+#include "xe_sriov_vf.h"
#include "xe_sriov_vf_ccs.h"
#include "xe_trace.h"
#include "xe_wa.h"
@@ -186,6 +187,13 @@ int xe_pm_resume(struct xe_device *xe)
xe_display_pm_resume_early(xe);
+ /* GGTT fixups (if needed) have to be done before restoring BOs */
+ if (IS_SRIOV_VF(xe)) {
+ err = xe_sriov_vf_fixup_ggtt(xe);
+ if (err)
+ return err;
+ }
+
/*
* This only restores pinned memory which is the memory required for the
* GT(s) to resume.
diff --git a/drivers/gpu/drm/xe/xe_sriov_vf.c b/drivers/gpu/drm/xe/xe_sriov_vf.c
index 5de81f213d83..1540a444f921 100644
--- a/drivers/gpu/drm/xe/xe_sriov_vf.c
+++ b/drivers/gpu/drm/xe/xe_sriov_vf.c
@@ -10,6 +10,7 @@
#include "xe_gt.h"
#include "xe_gt_sriov_printk.h"
#include "xe_gt_sriov_vf.h"
+#include "xe_guc.h"
#include "xe_guc_ct.h"
#include "xe_guc_submit.h"
#include "xe_irq.h"
@@ -378,3 +379,38 @@ void xe_sriov_vf_start_migration_recovery(struct xe_device *xe)
drm_info(&xe->drm, "VF migration recovery %s\n", started ?
"scheduled" : "already in progress");
}
+
+/**
+ * xe_sriov_vf_fixup_ggtt - Fix up GGTT on resume from S4.
+ * @xe: the &xe_device to start on resume.
+ *
+ * This function shall be called only by VF.
+ * Main GT and media GT share the same GGTT space. So, fixups are needed
+ * only for Main GT.
+ *
+ * Returns: 0 if the operation completed successfully, or a negative error
+ * code otherwise.
+ */
+int xe_sriov_vf_fixup_ggtt(struct xe_device *xe)
+{
+ struct xe_gt *gt;
+ int err = 0;
+ u8 id;
+
+ for_each_gt(gt, xe, id) {
+ if (gt->info.type != XE_GT_TYPE_MAIN)
+ continue;
+
+ xe_guc_comm_init_early(>->uc.guc);
+ err = xe_gt_sriov_vf_bootstrap(gt);
+ if (err)
+ goto out;
+
+ err = gt_vf_post_migration_fixups(gt);
+ if (err)
+ goto out;
+ }
+
+out:
+ return err;
+}
diff --git a/drivers/gpu/drm/xe/xe_sriov_vf.h b/drivers/gpu/drm/xe/xe_sriov_vf.h
index 7b8622cff2b7..4c2a6cb825fc 100644
--- a/drivers/gpu/drm/xe/xe_sriov_vf.h
+++ b/drivers/gpu/drm/xe/xe_sriov_vf.h
@@ -10,5 +10,6 @@ struct xe_device;
void xe_sriov_vf_init_early(struct xe_device *xe);
void xe_sriov_vf_start_migration_recovery(struct xe_device *xe);
+int xe_sriov_vf_fixup_ggtt(struct xe_device *xe);
#endif
--
2.43.0
More information about the Intel-xe
mailing list