]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pf: Allow to change VFs VRAM quota using sysfs
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 18 Feb 2026 20:55:46 +0000 (21:55 +0100)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 20 Feb 2026 14:50:02 +0000 (15:50 +0100)
On current discrete platforms, PF will provision all VFs with a fair
amount of the VRAM (LMEM) during VFs enabling. However, in some cases
this automatic VRAM provisioning might be either non-reproducible or
sub-optimal. This could break VF's migration or impact performance.

Expose per-VF VRAM quota read-write sysfs attributes to allow admin
change default VRAM provisioning performed by the PF.

 /sys/bus/pci/drivers/xe/BDF/
 ├── sriov_admin/
     ├── .bulk_profile
     │   └── vram_quota                 [RW] unsigned integer
     ├── vf1/
     │   └── profile
     │       └── vram_quota             [RW] unsigned integer
     ├── vf2/
     │   └── profile
     │       └── vram_quota             [RW] unsigned integer

Above values represent total provisioned VRAM from all tiles where
VFs were assigned, and currently it's from all tiles always.

Note that changing VRAM provisioning is only possible when VF is
not running, otherwise GuC will complain. To make sure that given
VF is idle, triggering VF FLR might be needed.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patch.msgid.link/20260218205553.3561-5-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c

index 82a1055985ba79d992c31591edec7c1706f2d881..aa05c143a4d6d526e6b809f93bfb3af460dd4201 100644 (file)
@@ -9,6 +9,7 @@
 #include <drm/drm_managed.h>
 
 #include "xe_assert.h"
+#include "xe_device.h"
 #include "xe_pci_sriov.h"
 #include "xe_pm.h"
 #include "xe_sriov.h"
@@ -44,7 +45,8 @@ static int emit_choice(char *buf, int choice, const char * const *array, size_t
  *     ├── .bulk_profile
  *     │   ├── exec_quantum_ms
  *     │   ├── preempt_timeout_us
- *     │   └── sched_priority
+ *     │   ├── sched_priority
+ *     │   └── vram_quota
  *     ├── pf/
  *     │   ├── ...
  *     │   ├── device -> ../../../BDF
@@ -59,7 +61,8 @@ static int emit_choice(char *buf, int choice, const char * const *array, size_t
  *     │   └── profile
  *     │       ├── exec_quantum_ms
  *     │       ├── preempt_timeout_us
- *     │       └── sched_priority
+ *     │       ├── sched_priority
+ *     │       └── vram_quota
  *     ├── vf2/
  *     :
  *     └── vfN/
@@ -132,6 +135,7 @@ static XE_SRIOV_DEV_ATTR_WO(NAME)
 
 DEFINE_SIMPLE_BULK_PROVISIONING_SRIOV_DEV_ATTR_WO(exec_quantum_ms, eq, u32);
 DEFINE_SIMPLE_BULK_PROVISIONING_SRIOV_DEV_ATTR_WO(preempt_timeout_us, pt, u32);
+DEFINE_SIMPLE_BULK_PROVISIONING_SRIOV_DEV_ATTR_WO(vram_quota, vram, u64);
 
 static const char * const sched_priority_names[] = {
        [GUC_SCHED_PRIORITY_LOW] = "low",
@@ -181,12 +185,26 @@ static struct attribute *bulk_profile_dev_attrs[] = {
        &xe_sriov_dev_attr_exec_quantum_ms.attr,
        &xe_sriov_dev_attr_preempt_timeout_us.attr,
        &xe_sriov_dev_attr_sched_priority.attr,
+       &xe_sriov_dev_attr_vram_quota.attr,
        NULL
 };
 
+static umode_t profile_dev_attr_is_visible(struct kobject *kobj,
+                                          struct attribute *attr, int index)
+{
+       struct xe_sriov_kobj *vkobj = to_xe_sriov_kobj(kobj);
+
+       if (attr == &xe_sriov_dev_attr_vram_quota.attr &&
+           !xe_device_has_lmtt(vkobj->xe))
+               return 0;
+
+       return attr->mode;
+}
+
 static const struct attribute_group bulk_profile_dev_attr_group = {
        .name = ".bulk_profile",
        .attrs = bulk_profile_dev_attrs,
+       .is_visible = profile_dev_attr_is_visible,
 };
 
 static const struct attribute_group *xe_sriov_dev_attr_groups[] = {
@@ -228,6 +246,7 @@ static XE_SRIOV_VF_ATTR(NAME)
 
 DEFINE_SIMPLE_PROVISIONING_SRIOV_VF_ATTR(exec_quantum_ms, eq, u32, "%u\n");
 DEFINE_SIMPLE_PROVISIONING_SRIOV_VF_ATTR(preempt_timeout_us, pt, u32, "%u\n");
+DEFINE_SIMPLE_PROVISIONING_SRIOV_VF_ATTR(vram_quota, vram, u64, "%llu\n");
 
 static ssize_t xe_sriov_vf_attr_sched_priority_show(struct xe_device *xe, unsigned int vfid,
                                                    char *buf)
@@ -274,6 +293,7 @@ static struct attribute *profile_vf_attrs[] = {
        &xe_sriov_vf_attr_exec_quantum_ms.attr,
        &xe_sriov_vf_attr_preempt_timeout_us.attr,
        &xe_sriov_vf_attr_sched_priority.attr,
+       &xe_sriov_vf_attr_vram_quota.attr,
        NULL
 };
 
@@ -286,6 +306,13 @@ static umode_t profile_vf_attr_is_visible(struct kobject *kobj,
            !sched_priority_change_allowed(vkobj->vfid))
                return attr->mode & 0444;
 
+       if (attr == &xe_sriov_vf_attr_vram_quota.attr) {
+               if (!IS_DGFX(vkobj->xe) || vkobj->vfid == PFID)
+                       return 0;
+               if (!xe_device_has_lmtt(vkobj->xe))
+                       return attr->mode & 0444;
+       }
+
        return attr->mode;
 }