]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pf: Make sure PF is ready to configure VFs
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 1 Aug 2025 14:28:21 +0000 (16:28 +0200)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Mon, 4 Aug 2025 15:59:06 +0000 (11:59 -0400)
The PF driver might be resumed just to configure VFs, but since
it is doing some asynchronous GuC reconfigurations after fresh
reset, we should wait until all pending works are completed.

This is especially important in case of LMEM provisioning, since
we also need to update the LMTT and send invalidation requests
to all GuCs, which are expected to be already in the VGT mode.

Fixes: 68ae022278a1 ("drm/xe/pf: Force GuC virtualization mode")
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
Link: https://lore.kernel.org/r/20250801142822.180530-3-michal.wajdeczko@intel.com
(cherry picked from commit c6c86441c465ea440dfb5039f1c26e629a6fd64c)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_gt_sriov_pf.c
drivers/gpu/drm/xe/xe_gt_sriov_pf.h
drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
drivers/gpu/drm/xe/xe_pci_sriov.c
drivers/gpu/drm/xe/xe_sriov_pf.c
drivers/gpu/drm/xe/xe_sriov_pf.h

index 2ea81d81c0aeb4d8aff8c090efe016e3ac0e987e..bdbd15f3afe384df5c29d1f674ba6d56beab4340 100644 (file)
@@ -16,6 +16,7 @@
 #include "xe_gt_sriov_pf_migration.h"
 #include "xe_gt_sriov_pf_service.h"
 #include "xe_gt_sriov_printk.h"
+#include "xe_guc_submit.h"
 #include "xe_mmio.h"
 #include "xe_pm.h"
 
@@ -260,3 +261,27 @@ void xe_gt_sriov_pf_restart(struct xe_gt *gt)
 {
        pf_queue_restart(gt);
 }
+
+static void pf_flush_restart(struct xe_gt *gt)
+{
+       xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
+       flush_work(&gt->sriov.pf.workers.restart);
+}
+
+/**
+ * xe_gt_sriov_pf_wait_ready() - Wait until per-GT PF SR-IOV support is ready.
+ * @gt: the &xe_gt
+ *
+ * This function can only be called on PF.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int xe_gt_sriov_pf_wait_ready(struct xe_gt *gt)
+{
+       /* don't wait if there is another ongoing reset */
+       if (xe_guc_read_stopped(&gt->uc.guc))
+               return -EBUSY;
+
+       pf_flush_restart(gt);
+       return 0;
+}
index e2b2ff8132dc58d9f50609127b9109440c780bef..e7fde3f9937af282d3aea45e1a53bd282fdfbc79 100644 (file)
@@ -11,6 +11,7 @@ struct xe_gt;
 #ifdef CONFIG_PCI_IOV
 int xe_gt_sriov_pf_init_early(struct xe_gt *gt);
 int xe_gt_sriov_pf_init(struct xe_gt *gt);
+int xe_gt_sriov_pf_wait_ready(struct xe_gt *gt);
 void xe_gt_sriov_pf_init_hw(struct xe_gt *gt);
 void xe_gt_sriov_pf_sanitize_hw(struct xe_gt *gt, unsigned int vfid);
 void xe_gt_sriov_pf_stop_prepare(struct xe_gt *gt);
index bf679b21f48529545bfa522bf6af16a4ddbf916a..3ed245e04d0cfec5cfeb7b23883463b7cc29848c 100644 (file)
@@ -22,6 +22,7 @@
 #include "xe_gt_sriov_pf_policy.h"
 #include "xe_gt_sriov_pf_service.h"
 #include "xe_pm.h"
+#include "xe_sriov_pf.h"
 
 /*
  *      /sys/kernel/debug/dri/0/
@@ -205,7 +206,8 @@ static int CONFIG##_set(void *data, u64 val)                                        \
                return -EOVERFLOW;                                              \
                                                                                \
        xe_pm_runtime_get(xe);                                                  \
-       err = xe_gt_sriov_pf_config_set_##CONFIG(gt, vfid, val);                \
+       err = xe_sriov_pf_wait_ready(xe) ?:                                     \
+             xe_gt_sriov_pf_config_set_##CONFIG(gt, vfid, val);                \
        xe_pm_runtime_put(xe);                                                  \
                                                                                \
        return err;                                                             \
index 8813efdcafbb19cfad3782d0dd662d272b09d30d..447a7867eecbaffb9055eeb76afb6fa6e2e145dc 100644 (file)
@@ -12,6 +12,7 @@
 #include "xe_pci_sriov.h"
 #include "xe_pm.h"
 #include "xe_sriov.h"
+#include "xe_sriov_pf.h"
 #include "xe_sriov_pf_helpers.h"
 #include "xe_sriov_printk.h"
 
@@ -138,6 +139,10 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
        xe_assert(xe, num_vfs <= total_vfs);
        xe_sriov_dbg(xe, "enabling %u VF%s\n", num_vfs, str_plural(num_vfs));
 
+       err = xe_sriov_pf_wait_ready(xe);
+       if (err)
+               goto out;
+
        /*
         * We must hold additional reference to the runtime PM to keep PF in D0
         * during VFs lifetime, as our VFs do not implement the PM capability.
@@ -169,7 +174,7 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
 failed:
        pf_unprovision_vfs(xe, num_vfs);
        xe_pm_runtime_put(xe);
-
+out:
        xe_sriov_notice(xe, "Failed to enable %u VF%s (%pe)\n",
                        num_vfs, str_plural(num_vfs), ERR_PTR(err));
        return err;
index afbdd894bd6ee78c3e8437d96817cf3f3cc7f2b9..27ddf3cc80e9c47738f6df4aa865c5962743c794 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "xe_assert.h"
 #include "xe_device.h"
+#include "xe_gt_sriov_pf.h"
 #include "xe_module.h"
 #include "xe_sriov.h"
 #include "xe_sriov_pf.h"
@@ -102,6 +103,32 @@ int xe_sriov_pf_init_early(struct xe_device *xe)
        return 0;
 }
 
+/**
+ * xe_sriov_pf_wait_ready() - Wait until PF is ready to operate.
+ * @xe: the &xe_device to test
+ *
+ * This function can only be called on PF.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int xe_sriov_pf_wait_ready(struct xe_device *xe)
+{
+       struct xe_gt *gt;
+       unsigned int id;
+       int err;
+
+       if (xe_device_wedged(xe))
+               return -ECANCELED;
+
+       for_each_gt(gt, xe, id) {
+               err = xe_gt_sriov_pf_wait_ready(gt);
+               if (err)
+                       return err;
+       }
+
+       return 0;
+}
+
 /**
  * xe_sriov_pf_print_vfs_summary - Print SR-IOV PF information.
  * @xe: the &xe_device to print info from
index c392c3fcf0852d6f2b4cdc5f70caf4b1eab5102f..e3b34f8f5e0467d1f34a4c70ce81ce8ec3282f3a 100644 (file)
@@ -15,6 +15,7 @@ struct xe_device;
 #ifdef CONFIG_PCI_IOV
 bool xe_sriov_pf_readiness(struct xe_device *xe);
 int xe_sriov_pf_init_early(struct xe_device *xe);
+int xe_sriov_pf_wait_ready(struct xe_device *xe);
 void xe_sriov_pf_debugfs_register(struct xe_device *xe, struct dentry *root);
 void xe_sriov_pf_print_vfs_summary(struct xe_device *xe, struct drm_printer *p);
 #else