drm/xe/pf: Move VFs reprovisioning to worker
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Sat, 25 Jan 2025 21:55:05 +0000 (22:55 +0100)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 27 Jan 2025 19:34:18 +0000 (20:34 +0100)
Since the GuC is reset during GT reset, we need to re-send the
entire SR-IOV provisioning configuration to the GuC. But since
this whole configuration is protected by the PF master mutex and
we can't avoid making allocations under this mutex (like during
LMEM provisioning), we can't do this reprovisioning from gt-reset
path if we want to be reclaim-safe. Move VFs reprovisioning to a
async worker that we will start from the gt-reset path.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Stuart Summers <stuart.summers@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250125215505.720-1-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_gt_sriov_pf.c
drivers/gpu/drm/xe/xe_gt_sriov_pf_types.h

index 6f906c8e8108ba55c9bd4afd0e98b2c78f07e91c..d66478deab989347f5ef9d68a5453a34634ef92a 100644 (file)
 #include "xe_gt_sriov_pf_helpers.h"
 #include "xe_gt_sriov_pf_migration.h"
 #include "xe_gt_sriov_pf_service.h"
+#include "xe_gt_sriov_printk.h"
 #include "xe_mmio.h"
+#include "xe_pm.h"
+
+static void pf_worker_restart_func(struct work_struct *w);
 
 /*
  * VF's metadata is maintained in the flexible array where:
@@ -41,6 +45,11 @@ static int pf_alloc_metadata(struct xe_gt *gt)
        return 0;
 }
 
+static void pf_init_workers(struct xe_gt *gt)
+{
+       INIT_WORK(&gt->sriov.pf.workers.restart, pf_worker_restart_func);
+}
+
 /**
  * xe_gt_sriov_pf_init_early - Prepare SR-IOV PF data structures on PF.
  * @gt: the &xe_gt to initialize
@@ -65,6 +74,8 @@ int xe_gt_sriov_pf_init_early(struct xe_gt *gt)
        if (err)
                return err;
 
+       pf_init_workers(gt);
+
        return 0;
 }
 
@@ -155,6 +166,35 @@ void xe_gt_sriov_pf_sanitize_hw(struct xe_gt *gt, unsigned int vfid)
        pf_clear_vf_scratch_regs(gt, vfid);
 }
 
+static void pf_restart(struct xe_gt *gt)
+{
+       struct xe_device *xe = gt_to_xe(gt);
+
+       xe_pm_runtime_get(xe);
+       xe_gt_sriov_pf_config_restart(gt);
+       xe_gt_sriov_pf_control_restart(gt);
+       xe_pm_runtime_put(xe);
+
+       xe_gt_sriov_dbg(gt, "restart completed\n");
+}
+
+static void pf_worker_restart_func(struct work_struct *w)
+{
+       struct xe_gt *gt = container_of(w, typeof(*gt), sriov.pf.workers.restart);
+
+       pf_restart(gt);
+}
+
+static void pf_queue_restart(struct xe_gt *gt)
+{
+       struct xe_device *xe = gt_to_xe(gt);
+
+       xe_gt_assert(gt, IS_SRIOV_PF(xe));
+
+       if (!queue_work(xe->sriov.wq, &gt->sriov.pf.workers.restart))
+               xe_gt_sriov_dbg(gt, "restart already in queue!\n");
+}
+
 /**
  * xe_gt_sriov_pf_restart - Restart SR-IOV support after a GT reset.
  * @gt: the &xe_gt
@@ -163,6 +203,5 @@ void xe_gt_sriov_pf_sanitize_hw(struct xe_gt *gt, unsigned int vfid)
  */
 void xe_gt_sriov_pf_restart(struct xe_gt *gt)
 {
-       xe_gt_sriov_pf_config_restart(gt);
-       xe_gt_sriov_pf_control_restart(gt);
+       pf_queue_restart(gt);
 }
index 0426b1a77069aca522d689a64ad58dedf8ba2338..a64a6835ad6564146837379a0f9f11671dc3ad57 100644 (file)
@@ -35,8 +35,17 @@ struct xe_gt_sriov_metadata {
        struct xe_gt_sriov_state_snapshot snapshot;
 };
 
+/**
+ * struct xe_gt_sriov_pf_workers - GT level workers used by the PF.
+ */
+struct xe_gt_sriov_pf_workers {
+       /** @restart: worker that executes actions post GT reset */
+       struct work_struct restart;
+};
+
 /**
  * struct xe_gt_sriov_pf - GT level PF virtualization data.
+ * @workers: workers data.
  * @service: service data.
  * @control: control data.
  * @policy: policy data.
@@ -45,6 +54,7 @@ struct xe_gt_sriov_metadata {
  * @vfs: metadata for all VFs.
  */
 struct xe_gt_sriov_pf {
+       struct xe_gt_sriov_pf_workers workers;
        struct xe_gt_sriov_pf_service service;
        struct xe_gt_sriov_pf_control control;
        struct xe_gt_sriov_pf_policy policy;