]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pf: Add top level functions to control VFs
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 30 Sep 2025 23:35:19 +0000 (01:35 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 2 Oct 2025 21:58:28 +0000 (23:58 +0200)
We already have control functions that we use to control the VF
state on the per-GT basis, but that is low level detail from the
user point of view, who rather expects VF-level functions.

For now add simple functions that just iterate over all GTs and
call per-GT control function. We will soon allow to use some of
them from the user facing interfaces like debugfs.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Michał Winiarski <michal.winiarski@intel.com>
Link: https://lore.kernel.org/r/20250930233525.201263-2-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/Makefile
drivers/gpu/drm/xe/xe_pci_sriov.c
drivers/gpu/drm/xe/xe_sriov_pf_control.c [new file with mode: 0644]
drivers/gpu/drm/xe/xe_sriov_pf_control.h [new file with mode: 0644]

index 00f7ce8e926da4ce05a77fe7a004de217b2e6550..f4b7b2bcaa593d9c8c15fe48ea1068511c4f30b9 100644 (file)
@@ -174,6 +174,7 @@ xe-$(CONFIG_PCI_IOV) += \
        xe_lmtt_ml.o \
        xe_pci_sriov.o \
        xe_sriov_pf.o \
+       xe_sriov_pf_control.o \
        xe_sriov_pf_debugfs.o \
        xe_sriov_pf_service.o \
        xe_tile_sriov_pf_debugfs.o
index af05db07162e45b0f24a5fcf0fa8b8d2de0c59ab..9c1c9e669b040bc8afcb0fd9d6072ed2ed6bc17e 100644 (file)
@@ -17,6 +17,7 @@
 #include "xe_pm.h"
 #include "xe_sriov.h"
 #include "xe_sriov_pf.h"
+#include "xe_sriov_pf_control.h"
 #include "xe_sriov_pf_helpers.h"
 #include "xe_sriov_printk.h"
 
@@ -60,13 +61,10 @@ static void pf_unprovision_vfs(struct xe_device *xe, unsigned int num_vfs)
 
 static void pf_reset_vfs(struct xe_device *xe, unsigned int num_vfs)
 {
-       struct xe_gt *gt;
-       unsigned int id;
        unsigned int n;
 
-       for_each_gt(gt, xe, id)
-               for (n = 1; n <= num_vfs; n++)
-                       xe_gt_sriov_pf_control_trigger_flr(gt, n);
+       for (n = 1; n <= num_vfs; n++)
+               xe_sriov_pf_control_reset_vf(xe, n);
 }
 
 static struct pci_dev *xe_pci_pf_get_vf_dev(struct xe_device *xe, unsigned int vf_id)
diff --git a/drivers/gpu/drm/xe/xe_sriov_pf_control.c b/drivers/gpu/drm/xe/xe_sriov_pf_control.c
new file mode 100644 (file)
index 0000000..56c0dd3
--- /dev/null
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#include "xe_device.h"
+#include "xe_gt_sriov_pf_control.h"
+#include "xe_sriov_pf_control.h"
+
+/**
+ * xe_sriov_pf_control_pause_vf() - Pause a VF on all GTs.
+ * @xe: the &xe_device
+ * @vfid: the VF identifier (can't be 0 == PFID)
+ *
+ * This function is for PF only.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int xe_sriov_pf_control_pause_vf(struct xe_device *xe, unsigned int vfid)
+{
+       struct xe_gt *gt;
+       unsigned int id;
+       int result = 0;
+       int err;
+
+       for_each_gt(gt, xe, id) {
+               err = xe_gt_sriov_pf_control_pause_vf(gt, vfid);
+               result = result ? -EUCLEAN : err;
+       }
+
+       return result;
+}
+
+/**
+ * xe_sriov_pf_control_resume_vf() - Resume a VF on all GTs.
+ * @xe: the &xe_device
+ * @vfid: the VF identifier
+ *
+ * This function is for PF only.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int xe_sriov_pf_control_resume_vf(struct xe_device *xe, unsigned int vfid)
+{
+       struct xe_gt *gt;
+       unsigned int id;
+       int result = 0;
+       int err;
+
+       for_each_gt(gt, xe, id) {
+               err = xe_gt_sriov_pf_control_resume_vf(gt, vfid);
+               result = result ? -EUCLEAN : err;
+       }
+
+       return result;
+}
+
+/**
+ * xe_sriov_pf_control_stop_vf - Stop a VF on all GTs.
+ * @xe: the &xe_device
+ * @vfid: the VF identifier
+ *
+ * This function is for PF only.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int xe_sriov_pf_control_stop_vf(struct xe_device *xe, unsigned int vfid)
+{
+       struct xe_gt *gt;
+       unsigned int id;
+       int result = 0;
+       int err;
+
+       for_each_gt(gt, xe, id) {
+               err = xe_gt_sriov_pf_control_stop_vf(gt, vfid);
+               result = result ? -EUCLEAN : err;
+       }
+
+       return result;
+}
+
+/**
+ * xe_sriov_pf_control_reset_vf() - Perform a VF reset (FLR).
+ * @xe: the &xe_device
+ * @vfid: the VF identifier
+ *
+ * This function is for PF only.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int xe_sriov_pf_control_reset_vf(struct xe_device *xe, unsigned int vfid)
+{
+       struct xe_gt *gt;
+       unsigned int id;
+       int result = 0;
+       int err;
+
+       for_each_gt(gt, xe, id) {
+               err = xe_gt_sriov_pf_control_trigger_flr(gt, vfid);
+               result = result ? -EUCLEAN : err;
+       }
+
+       return result;
+}
diff --git a/drivers/gpu/drm/xe/xe_sriov_pf_control.h b/drivers/gpu/drm/xe/xe_sriov_pf_control.h
new file mode 100644 (file)
index 0000000..9bf059f
--- /dev/null
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#ifndef _XE_SRIOV_PF_CONTROL_H_
+#define _XE_SRIOV_PF_CONTROL_H_
+
+struct xe_device;
+
+int xe_sriov_pf_control_pause_vf(struct xe_device *xe, unsigned int vfid);
+int xe_sriov_pf_control_resume_vf(struct xe_device *xe, unsigned int vfid);
+int xe_sriov_pf_control_stop_vf(struct xe_device *xe, unsigned int vfid);
+int xe_sriov_pf_control_reset_vf(struct xe_device *xe, unsigned int vfid);
+
+#endif