]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/configfs: Add sriov.admin_only_pf attribute
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 21 Jan 2026 21:42:16 +0000 (22:42 +0100)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 3 Feb 2026 11:03:50 +0000 (12:03 +0100)
Instead of relying on fixed relation to the display probe flag,
add configfs attribute to allow an administrator to configure
desired PF operation mode in a more flexible way.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patch.msgid.link/20260121214218.2817-6-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_configfs.c
drivers/gpu/drm/xe/xe_configfs.h
drivers/gpu/drm/xe/xe_defaults.h
drivers/gpu/drm/xe/xe_sriov_pf.c

index 5a54ca67d3dcc946352e803ab7441153a62d05de..d8c3fbe81aa62645cb16d90bab10796393b90c68 100644 (file)
@@ -264,6 +264,7 @@ struct xe_config_group_device {
                bool enable_psmi;
                struct {
                        unsigned int max_vfs;
+                       bool admin_only_pf;
                } sriov;
        } config;
 
@@ -282,6 +283,7 @@ static const struct xe_config_device device_defaults = {
        .enable_psmi = false,
        .sriov = {
                .max_vfs = XE_DEFAULT_MAX_VFS,
+               .admin_only_pf = XE_DEFAULT_ADMIN_ONLY_PF,
        },
 };
 
@@ -897,10 +899,40 @@ static ssize_t sriov_max_vfs_store(struct config_item *item, const char *page, s
        return len;
 }
 
+static ssize_t sriov_admin_only_pf_show(struct config_item *item, char *page)
+{
+       struct xe_config_group_device *dev = to_xe_config_group_device(item->ci_parent);
+
+       guard(mutex)(&dev->lock);
+
+       return sprintf(page, "%s\n", str_yes_no(dev->config.sriov.admin_only_pf));
+}
+
+static ssize_t sriov_admin_only_pf_store(struct config_item *item, const char *page, size_t len)
+{
+       struct xe_config_group_device *dev = to_xe_config_group_device(item->ci_parent);
+       bool admin_only_pf;
+       int ret;
+
+       guard(mutex)(&dev->lock);
+
+       if (is_bound(dev))
+               return -EBUSY;
+
+       ret = kstrtobool(page, &admin_only_pf);
+       if (ret)
+               return ret;
+
+       dev->config.sriov.admin_only_pf = admin_only_pf;
+       return len;
+}
+
 CONFIGFS_ATTR(sriov_, max_vfs);
+CONFIGFS_ATTR(sriov_, admin_only_pf);
 
 static struct configfs_attribute *xe_config_sriov_attrs[] = {
        &sriov_attr_max_vfs,
+       &sriov_attr_admin_only_pf,
        NULL,
 };
 
@@ -911,6 +943,8 @@ static bool xe_config_sriov_is_visible(struct config_item *item,
 
        if (attr == &sriov_attr_max_vfs && dev->mode != XE_SRIOV_MODE_PF)
                return false;
+       if (attr == &sriov_attr_admin_only_pf && dev->mode != XE_SRIOV_MODE_PF)
+               return false;
 
        return true;
 }
@@ -1064,6 +1098,7 @@ static void dump_custom_dev_config(struct pci_dev *pdev,
        PRI_CUSTOM_ATTR("%llx", engines_allowed);
        PRI_CUSTOM_ATTR("%d", enable_psmi);
        PRI_CUSTOM_ATTR("%d", survivability_mode);
+       PRI_CUSTOM_ATTR("%u", sriov.admin_only_pf);
 
 #undef PRI_CUSTOM_ATTR
 }
@@ -1242,6 +1277,32 @@ u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev,
 }
 
 #ifdef CONFIG_PCI_IOV
+/**
+ * xe_configfs_admin_only_pf() - Get PF's operational mode.
+ * @pdev: the &pci_dev device
+ *
+ * Find the configfs group that belongs to the PCI device and return a flag
+ * whether the PF driver should be dedicated for VFs management only.
+ *
+ * If configfs group is not present, use driver's default value.
+ *
+ * Return: true if PF driver is dedicated for VFs administration only.
+ */
+bool xe_configfs_admin_only_pf(struct pci_dev *pdev)
+{
+       struct xe_config_group_device *dev = find_xe_config_group_device(pdev);
+       bool admin_only_pf;
+
+       if (!dev)
+               return XE_DEFAULT_ADMIN_ONLY_PF;
+
+       scoped_guard(mutex, &dev->lock)
+               admin_only_pf = dev->config.sriov.admin_only_pf;
+
+       config_group_put(&dev->group);
+
+       return admin_only_pf;
+}
 /**
  * xe_configfs_get_max_vfs() - Get number of VFs that could be managed
  * @pdev: the &pci_dev device
index e0a555b871b3da6445155f26c59194689a68be29..487531269511db5ff747d3a72ee6fac1b1239825 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/limits.h>
 #include <linux/types.h>
 
+#include "xe_defaults.h"
 #include "xe_hw_engine_types.h"
 #include "xe_module.h"
 
@@ -28,6 +29,7 @@ u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_cla
                                        const u32 **cs);
 #ifdef CONFIG_PCI_IOV
 unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev);
+bool xe_configfs_admin_only_pf(struct pci_dev *pdev);
 #endif
 #else
 static inline int xe_configfs_init(void) { return 0; }
@@ -47,6 +49,10 @@ static inline unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev)
 {
        return xe_modparam.max_vfs;
 }
+static inline bool xe_configfs_admin_only_pf(struct pci_dev *pdev)
+{
+       return XE_DEFAULT_ADMIN_ONLY_PF;
+}
 #endif
 #endif
 
index 9183d05b96e17c9462e6b65589b6d9b1107bac37..5d5d41d067c514cf8c3fd1a7abcc3e446269ed92 100644 (file)
@@ -18,6 +18,7 @@
 #define XE_DEFAULT_FORCE_PROBE                 CONFIG_DRM_XE_FORCE_PROBE
 #define XE_DEFAULT_MAX_VFS                     ~0
 #define XE_DEFAULT_MAX_VFS_STR                 "unlimited"
+#define XE_DEFAULT_ADMIN_ONLY_PF               false
 #define XE_DEFAULT_WEDGED_MODE                 XE_WEDGED_MODE_UPON_CRITICAL_ERROR
 #define XE_DEFAULT_WEDGED_MODE_STR             "upon-critical-error"
 #define XE_DEFAULT_SVM_NOTIFIER_SIZE           512
index 919f176a19eb1de555212f77461d4c3f8ab98300..47a6e0fd66e0ffdbc69eddadeb65643a756a194a 100644 (file)
@@ -22,7 +22,7 @@
 
 static bool wanted_admin_only(struct xe_device *xe)
 {
-       return !xe->info.probe_display;
+       return xe_configfs_admin_only_pf(to_pci_dev(xe->drm.dev));
 }
 
 static unsigned int wanted_max_vfs(struct xe_device *xe)