Skip to content

Commit 79e419c

Browse files
committed
drm/xe/pf: Allow to stop the VF using sysfs
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
1 parent 1789935 commit 79e419c

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "xe_pm.h"
1414
#include "xe_sriov.h"
1515
#include "xe_sriov_pf.h"
16+
#include "xe_sriov_pf_control.h"
1617
#include "xe_sriov_pf_helpers.h"
1718
#include "xe_sriov_pf_provision.h"
1819
#include "xe_sriov_pf_sysfs.h"
@@ -54,6 +55,7 @@ static int emit_choice(char *buf, int choice, const char * const *array, size_t
5455
* ├── vf1/
5556
* │ ├── ...
5657
* │ ├── device -> ../../../BDF.1
58+
* │ ├── stop
5759
* │ └── profile
5860
* │ ├── exec_quantum_ms
5961
* │ ├── preempt_timeout_us
@@ -293,8 +295,55 @@ static const struct attribute_group profile_vf_attr_group = {
293295
.is_visible = profile_vf_attr_is_visible,
294296
};
295297

298+
#define DEFINE_SIMPLE_CONTROL_SRIOV_VF_ATTR(NAME) \
299+
\
300+
static ssize_t xe_sriov_vf_attr_##NAME##_store(struct xe_device *xe, unsigned int vfid, \
301+
const char *buf, size_t count) \
302+
{ \
303+
bool yes; \
304+
int err; \
305+
\
306+
if (!vfid) \
307+
return -EPERM; \
308+
\
309+
err = kstrtobool(buf, &yes); \
310+
if (err) \
311+
return err; \
312+
if (!yes) \
313+
return count; \
314+
\
315+
err = xe_sriov_pf_control_##NAME##_vf(xe, vfid); \
316+
return err ?: count; \
317+
} \
318+
\
319+
static XE_SRIOV_VF_ATTR_WO(NAME)
320+
321+
DEFINE_SIMPLE_CONTROL_SRIOV_VF_ATTR(stop);
322+
323+
static struct attribute *control_vf_attrs[] = {
324+
&xe_sriov_vf_attr_stop.attr,
325+
NULL
326+
};
327+
328+
static umode_t control_vf_attr_is_visible(struct kobject *kobj,
329+
struct attribute *attr, int index)
330+
{
331+
struct xe_sriov_kobj *vkobj = to_xe_sriov_kobj(kobj);
332+
333+
if (vkobj->vfid == PFID)
334+
return 0;
335+
336+
return attr->mode;
337+
}
338+
339+
static const struct attribute_group control_vf_attr_group = {
340+
.attrs = control_vf_attrs,
341+
.is_visible = control_vf_attr_is_visible,
342+
};
343+
296344
static const struct attribute_group *xe_sriov_vf_attr_groups[] = {
297345
&profile_vf_attr_group,
346+
&control_vf_attr_group,
298347
NULL
299348
};
300349

0 commit comments

Comments
 (0)