drm/xe/pf: Restart VFs provisioning after GT reset
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 1 Jul 2024 10:27:37 +0000 (12:27 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 1 Jul 2024 17:43:52 +0000 (19:43 +0200)
Any prior configurations pushed to the GuC are lost when the GT
is reset. Push again all non-empty VF configurations to the GuC
as part of the GuC reset procedure.

This will also help restore early manual provisioning, when the
PF was in the meantime suspended and then resumed.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240701102738.934-3-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_gt.c
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_config.c
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h

index 759634c..29e8ea9 100644 (file)
@@ -683,6 +683,9 @@ static int do_gt_restart(struct xe_gt *gt)
        /* Restore GT freq to expected values */
        xe_gt_sanitize_freq(gt);
 
+       if (IS_SRIOV_PF(gt_to_xe(gt)))
+               xe_gt_sriov_pf_restart(gt);
+
        return 0;
 }
 
index 7decf71..9dbba9a 100644 (file)
@@ -8,6 +8,7 @@
 #include "regs/xe_sriov_regs.h"
 
 #include "xe_gt_sriov_pf.h"
+#include "xe_gt_sriov_pf_config.h"
 #include "xe_gt_sriov_pf_helpers.h"
 #include "xe_gt_sriov_pf_service.h"
 #include "xe_mmio.h"
@@ -82,3 +83,14 @@ void xe_gt_sriov_pf_init_hw(struct xe_gt *gt)
 
        xe_gt_sriov_pf_service_update(gt);
 }
+
+/**
+ * xe_gt_sriov_pf_restart - Restart SR-IOV support after a GT reset.
+ * @gt: the &xe_gt
+ *
+ * This function can only be called on PF.
+ */
+void xe_gt_sriov_pf_restart(struct xe_gt *gt)
+{
+       xe_gt_sriov_pf_config_restart(gt);
+}
index 37d7d6c..f0cb726 100644 (file)
@@ -11,6 +11,7 @@ struct xe_gt;
 #ifdef CONFIG_PCI_IOV
 int xe_gt_sriov_pf_init_early(struct xe_gt *gt);
 void xe_gt_sriov_pf_init_hw(struct xe_gt *gt);
+void xe_gt_sriov_pf_restart(struct xe_gt *gt);
 #else
 static inline int xe_gt_sriov_pf_init_early(struct xe_gt *gt)
 {
@@ -20,6 +21,10 @@ static inline int xe_gt_sriov_pf_init_early(struct xe_gt *gt)
 static inline void xe_gt_sriov_pf_init_hw(struct xe_gt *gt)
 {
 }
+
+static inline void xe_gt_sriov_pf_restart(struct xe_gt *gt)
+{
+}
 #endif
 
 #endif
index 810b579..db6c213 100644 (file)
@@ -1970,6 +1970,36 @@ bool xe_gt_sriov_pf_config_is_empty(struct xe_gt *gt, unsigned int vfid)
        return empty;
 }
 
+/**
+ * xe_gt_sriov_pf_config_restart - Restart SR-IOV configurations after a GT reset.
+ * @gt: the &xe_gt
+ *
+ * Any prior configurations pushed to GuC are lost when the GT is reset.
+ * Push again all non-empty VF configurations to the GuC.
+ *
+ * This function can only be called on PF.
+ */
+void xe_gt_sriov_pf_config_restart(struct xe_gt *gt)
+{
+       unsigned int n, total_vfs = xe_sriov_pf_get_totalvfs(gt_to_xe(gt));
+       unsigned int fail = 0, skip = 0;
+
+       for (n = 1; n <= total_vfs; n++) {
+               if (xe_gt_sriov_pf_config_is_empty(gt, n))
+                       skip++;
+               else if (xe_gt_sriov_pf_config_push(gt, n, false))
+                       fail++;
+       }
+
+       if (fail)
+               xe_gt_sriov_notice(gt, "Failed to push %u of %u VF%s configurations\n",
+                                  fail, total_vfs - skip, str_plural(total_vfs));
+
+       if (fail != total_vfs)
+               xe_gt_sriov_dbg(gt, "pushed %u skip %u of %u VF%s configurations\n",
+                               total_vfs - skip - fail, skip, total_vfs, str_plural(total_vfs));
+}
+
 /**
  * xe_gt_sriov_pf_config_print_ggtt - Print GGTT configurations.
  * @gt: the &xe_gt
index 58c8f87..c0e6e47 100644 (file)
@@ -55,6 +55,8 @@ int xe_gt_sriov_pf_config_push(struct xe_gt *gt, unsigned int vfid, bool refresh
 
 bool xe_gt_sriov_pf_config_is_empty(struct xe_gt *gt, unsigned int vfid);
 
+void xe_gt_sriov_pf_config_restart(struct xe_gt *gt);
+
 int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p);
 int xe_gt_sriov_pf_config_print_ctxs(struct xe_gt *gt, struct drm_printer *p);
 int xe_gt_sriov_pf_config_print_dbs(struct xe_gt *gt, struct drm_printer *p);