]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/vf: Fix GuC FW check for VF migration support
authorTomasz Lis <tomasz.lis@intel.com>
Tue, 21 Oct 2025 22:48:15 +0000 (00:48 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 22 Oct 2025 14:00:47 +0000 (16:00 +0200)
The check whether GuC ABI version meets requirements shall be
performed after said version is received from GuC.

Doing it in wrong order was triggering a warning:
xe 0000:00:02.1: [drm] Assertion `gt->sriov.vf.guc_version.major` failed!

With this change, dislodge part of the VF migration support check
and moved it to after GuC handshake.

Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Tested-by: Matthew Brost <matthew.brost@intel.com> #v1
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/6349
Fixes: ff1d2b5e3d28 ("drm/xe: Read VF GMD_ID with a specifically-allocated dummy GT")
Signed-off-by: Tomasz Lis <tomasz.lis@intel.com>
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://lore.kernel.org/r/20251021224817.1593817-3-tomasz.lis@intel.com
drivers/gpu/drm/xe/xe_sriov_vf.c
drivers/gpu/drm/xe/xe_sriov_vf.h
drivers/gpu/drm/xe/xe_sriov_vf_ccs.c

index 0d8135f3927ce72acddb83b43c7148dff0f35fe6..13d6c094ae8f6633dc2fa71a1efb909ee116bedf 100644 (file)
@@ -133,7 +133,12 @@ bool xe_sriov_vf_migration_supported(struct xe_device *xe)
        return !xe->sriov.vf.migration.disabled;
 }
 
-static void vf_disable_migration(struct xe_device *xe, const char *fmt, ...)
+/**
+ * xe_sriov_vf_migration_disable - Turn off VF migration with given log message.
+ * @xe: the &xe_device instance.
+ * @fmt: format string for the log message, to be combined with following VAs.
+ */
+void xe_sriov_vf_migration_disable(struct xe_device *xe, const char *fmt, ...)
 {
        struct va_format vaf;
        va_list va_args;
@@ -156,22 +161,13 @@ static void vf_migration_init_early(struct xe_device *xe)
         * supported at production quality.
         */
        if (!IS_ENABLED(CONFIG_DRM_XE_DEBUG))
-               return vf_disable_migration(xe,
-                                           "experimental feature not available on production builds");
+               return xe_sriov_vf_migration_disable(xe,
+                               "experimental feature not available on production builds");
 
        if (GRAPHICS_VER(xe) < 20)
-               return vf_disable_migration(xe, "requires gfx version >= 20, but only %u found",
-                                           GRAPHICS_VER(xe));
-
-       if (!IS_DGFX(xe)) {
-               struct xe_uc_fw_version guc_version;
-
-               xe_gt_sriov_vf_guc_versions(xe_device_get_gt(xe, 0), NULL, &guc_version);
-               if (MAKE_GUC_VER_STRUCT(guc_version) < MAKE_GUC_VER(1, 23, 0))
-                       return vf_disable_migration(xe,
-                                                   "CCS migration requires GuC ABI >= 1.23 but only %u.%u found",
-                                                   guc_version.major, guc_version.minor);
-       }
+               return xe_sriov_vf_migration_disable(xe,
+                               "requires gfx version >= 20, but only %u found",
+                               GRAPHICS_VER(xe));
 }
 
 /**
@@ -193,12 +189,7 @@ void xe_sriov_vf_init_early(struct xe_device *xe)
  */
 int xe_sriov_vf_init_late(struct xe_device *xe)
 {
-       int err = 0;
-
-       if (xe_sriov_vf_migration_supported(xe))
-               err = xe_sriov_vf_ccs_init(xe);
-
-       return err;
+       return xe_sriov_vf_ccs_init(xe);
 }
 
 static int sa_info_vf_ccs(struct seq_file *m, void *data)
index 4df95266b26130c4298f23407b44705da5b13074..e967d4166a43777004104112abbeaa9b15996c55 100644 (file)
@@ -14,6 +14,7 @@ struct xe_device;
 void xe_sriov_vf_init_early(struct xe_device *xe);
 int xe_sriov_vf_init_late(struct xe_device *xe);
 bool xe_sriov_vf_migration_supported(struct xe_device *xe);
+void xe_sriov_vf_migration_disable(struct xe_device *xe, const char *fmt, ...);
 void xe_sriov_vf_debugfs_register(struct xe_device *xe, struct dentry *root);
 
 #endif
index 7902498013643ef82451ecaebf142914af5d844c..797a4b86622620da2d73a8abc9dd42ea3c72ab2a 100644 (file)
@@ -10,6 +10,8 @@
 #include "xe_device.h"
 #include "xe_exec_queue.h"
 #include "xe_exec_queue_types.h"
+#include "xe_gt_sriov_vf.h"
+#include "xe_guc.h"
 #include "xe_guc_submit.h"
 #include "xe_lrc.h"
 #include "xe_migrate.h"
@@ -260,6 +262,45 @@ int xe_sriov_vf_ccs_register_context(struct xe_device *xe)
        return err;
 }
 
+/*
+ * Whether GuC requires CCS copy BBs for VF migration.
+ * @xe: the &xe_device instance.
+ *
+ * Only selected platforms require VF KMD to maintain CCS copy BBs and linked LRCAs.
+ *
+ * Return: true if VF driver must participate in the CCS migration, false otherwise.
+ */
+static bool vf_migration_ccs_bb_needed(struct xe_device *xe)
+{
+       xe_assert(xe, IS_SRIOV_VF(xe));
+
+       return !IS_DGFX(xe) && xe_device_has_flat_ccs(xe);
+}
+
+/*
+ * Check for disable migration due to no CCS BBs support in GuC FW.
+ * @xe: the &xe_device instance.
+ *
+ * Performs late disable of VF migration feature in case GuC FW cannot support it.
+ *
+ * Returns: True if VF migration with CCS BBs is supported, false otherwise.
+ */
+static bool vf_migration_ccs_bb_support_check(struct xe_device *xe)
+{
+       struct xe_gt *gt = xe_root_mmio_gt(xe);
+       struct xe_uc_fw_version guc_version;
+
+       xe_gt_sriov_vf_guc_versions(gt, NULL, &guc_version);
+       if (MAKE_GUC_VER_STRUCT(guc_version) < MAKE_GUC_VER(1, 23, 0)) {
+               xe_sriov_vf_migration_disable(xe,
+                                             "CCS migration requires GuC ABI >= 1.23 but only %u.%u found",
+                                             guc_version.major, guc_version.minor);
+               return false;
+       }
+
+       return true;
+}
+
 static void xe_sriov_vf_ccs_fini(void *arg)
 {
        struct xe_sriov_vf_ccs_ctx *ctx = arg;
@@ -292,9 +333,10 @@ int xe_sriov_vf_ccs_init(struct xe_device *xe)
        int err;
 
        xe_assert(xe, IS_SRIOV_VF(xe));
-       xe_assert(xe, xe_sriov_vf_migration_supported(xe));
 
-       if (IS_DGFX(xe) || !xe_device_has_flat_ccs(xe))
+       if (!xe_sriov_vf_migration_supported(xe) ||
+           !vf_migration_ccs_bb_needed(xe) ||
+           !vf_migration_ccs_bb_support_check(xe))
                return 0;
 
        for_each_ccs_rw_ctx(ctx_id) {