]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pf: Allow to stop the VF using sysfs
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 30 Oct 2025 22:23:47 +0000 (23:23 +0100)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 31 Oct 2025 19:01:51 +0000 (20:01 +0100)
It is expected that VFs activity will be monitored and in some
cases admin might want to silence specific VF without killing
the VM where it was attached.

Add write-only attribute to stop GuC scheduling at VFs level.

  /sys/bus/pci/drivers/xe/BDF/
  ├── sriov_admin/
      ├── vf1/
      │   └── stop [WO] bool
      ├── vf2/
      │   └── stop [WO] bool

Writing "1" or "y" (or whatever is recognized by the strtobool()
function) to this file will trigger the change of the VF state
to STOP (GuC will stop servicing the VF). To go back to a READY
state (to allow GuC to service this VF again) the VF FLR must be
triggered (which can be done by writing 1 to device/reset file).

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patch.msgid.link/20251030222348.186658-17-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c

index a3205bd1c21f0b7a069be91b50686677aafa6360..c0b767ac735cf2611f230c6a399c8f9985fdecd1 100644 (file)
@@ -13,6 +13,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_pf_provision.h"
 #include "xe_sriov_pf_sysfs.h"
@@ -54,6 +55,7 @@ static int emit_choice(char *buf, int choice, const char * const *array, size_t
  *     ├── vf1/
  *     │   ├── ...
  *     │   ├── device -> ../../../BDF.1
+ *     │   ├── stop
  *     │   └── profile
  *     │       ├── exec_quantum_ms
  *     │       ├── preempt_timeout_us
@@ -293,8 +295,55 @@ static const struct attribute_group profile_vf_attr_group = {
        .is_visible = profile_vf_attr_is_visible,
 };
 
+#define DEFINE_SIMPLE_CONTROL_SRIOV_VF_ATTR(NAME)                                      \
+                                                                                       \
+static ssize_t xe_sriov_vf_attr_##NAME##_store(struct xe_device *xe, unsigned int vfid,        \
+                                              const char *buf, size_t count)           \
+{                                                                                      \
+       bool yes;                                                                       \
+       int err;                                                                        \
+                                                                                       \
+       if (!vfid)                                                                      \
+               return -EPERM;                                                          \
+                                                                                       \
+       err = kstrtobool(buf, &yes);                                                    \
+       if (err)                                                                        \
+               return err;                                                             \
+       if (!yes)                                                                       \
+               return count;                                                           \
+                                                                                       \
+       err = xe_sriov_pf_control_##NAME##_vf(xe, vfid);                                \
+       return err ?: count;                                                            \
+}                                                                                      \
+                                                                                       \
+static XE_SRIOV_VF_ATTR_WO(NAME)
+
+DEFINE_SIMPLE_CONTROL_SRIOV_VF_ATTR(stop);
+
+static struct attribute *control_vf_attrs[] = {
+       &xe_sriov_vf_attr_stop.attr,
+       NULL
+};
+
+static umode_t control_vf_attr_is_visible(struct kobject *kobj,
+                                         struct attribute *attr, int index)
+{
+       struct xe_sriov_kobj *vkobj = to_xe_sriov_kobj(kobj);
+
+       if (vkobj->vfid == PFID)
+               return 0;
+
+       return attr->mode;
+}
+
+static const struct attribute_group control_vf_attr_group = {
+       .attrs = control_vf_attrs,
+       .is_visible = control_vf_attr_is_visible,
+};
+
 static const struct attribute_group *xe_sriov_vf_attr_groups[] = {
        &profile_vf_attr_group,
+       &control_vf_attr_group,
        NULL
 };