[PATCH v3 4/6] drm/xe/configfs: Check if device was preconfigured

Lucas De Marchi lucas.demarchi at intel.com
Thu Jul 24 15:17:15 UTC 2025


On Tue, Jul 22, 2025 at 04:10:57PM +0200, Michal Wajdeczko wrote:
>Since device configuration using configfs could be prepared long
>time prior the driver load, add a debug log whether the current
>device driver probe is using custom or default settings.
>
>Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
>Cc: Lucas De Marchi <lucas.demarchi at intel.com>
>---
> drivers/gpu/drm/xe/xe_configfs.c | 35 ++++++++++++++++++++++++++++++--
> drivers/gpu/drm/xe/xe_configfs.h |  2 ++
> drivers/gpu/drm/xe/xe_pci.c      |  3 +++
> 3 files changed, 38 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
>index 36e2b45b305f..f83e8e9f070f 100644
>--- a/drivers/gpu/drm/xe/xe_configfs.c
>+++ b/drivers/gpu/drm/xe/xe_configfs.c
>@@ -118,6 +118,17 @@ static struct xe_config_device *to_xe_config_device(struct config_item *item)
> 	return container_of(to_config_group(item), struct xe_config_device, group);
> }
>
>+static void xe_config_set_defaults(struct xe_config_device *dev)
>+{
>+	dev->engines_allowed = U64_MAX;
>+	dev->survivability_mode = false;
>+}

other places here follow the file prefix, xe_configfs. I think mixing
both is confusing.

>+
>+static bool xe_config_is_default(const struct xe_config_device *dev)
>+{
>+	return dev->engines_allowed == U64_MAX && !dev->survivability_mode;

maybe have something like below would be more maintainable? We may need
to move the attribute values to an inner struct or just set the
defaults very early.

At least aligning the variables would be good. On a first read I missed
you were checking the 2 vars.

static const struct xe_config_device defaults = {
	.engines_allowed = U64_MAX,
};

static void set_defaults(struct xe_config_device *dev)
{
	*dev = defaults;
}

static bool is_default(const struct xe_config_device *dev)
{
	/*
	 * If a new attribute is added, there should be also a check for
	 * default. Assert it's not forgotten
	 */
	static_assert(ARRAY_SIZE(xe_config_device_attrs) == 3);

	return dev->engines_allowed != defaults.engines_allowed &&
	       dev->survivability_mode != defaults.survivability_mode;
}


>+}
>+
> static ssize_t survivability_mode_show(struct config_item *item, char *page)
> {
> 	struct xe_config_device *dev = to_xe_config_device(item);
>@@ -281,8 +292,7 @@ static struct config_group *xe_config_make_device_group(struct config_group *gro
> 	if (!dev)
> 		return ERR_PTR(-ENOMEM);
>
>-	/* Default values */
>-	dev->engines_allowed = U64_MAX;
>+	xe_config_set_defaults(dev);

yeah, if we keep it here I think we don't need to an inner struct.

>
> 	config_group_init_type_name(&dev->group, name, &xe_config_device_type);
>
>@@ -323,6 +333,27 @@ static struct xe_config_device *configfs_find_group(struct pci_dev *pdev)
> 	return to_xe_config_device(item);
> }
>
>+/**
>+ * xe_configfs_check_device() - Test if device was configured by configfs
>+ * @pdev: the &pci_dev device to test
>+ *
>+ * Try to find the configfs group that belongs to the specified pci device
>+ * and print a diagnostic message if found.
>+ *
>+ * Return: true if config group is found, false otherwise
>+ */
>+bool xe_configfs_check_device(struct pci_dev *pdev)
>+{
>+	struct xe_config_device *cfg = configfs_find_group(pdev);
>+
>+	if (!cfg)
>+		return false;
>+
>+	pci_dbg(pdev, "found %s settings in configfs\n",
>+		xe_config_is_default(cfg) ? "default" : "custom");
>+	return true;

return could be void.

Lucas De Marchi

>+}
>+
> /**
>  * xe_configfs_get_survivability_mode - get configfs survivability mode attribute
>  * @pdev: pci device
>diff --git a/drivers/gpu/drm/xe/xe_configfs.h b/drivers/gpu/drm/xe/xe_configfs.h
>index fb8764008089..cdccf1f9b716 100644
>--- a/drivers/gpu/drm/xe/xe_configfs.h
>+++ b/drivers/gpu/drm/xe/xe_configfs.h
>@@ -13,12 +13,14 @@ struct pci_dev;
> #if IS_ENABLED(CONFIG_CONFIGFS_FS)
> int xe_configfs_init(void);
> void xe_configfs_exit(void);
>+bool xe_configfs_check_device(struct pci_dev *pdev);
> bool xe_configfs_get_survivability_mode(struct pci_dev *pdev);
> void xe_configfs_clear_survivability_mode(struct pci_dev *pdev);
> u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev);
> #else
> static inline int xe_configfs_init(void) { return 0; }
> static inline void xe_configfs_exit(void) { }
>+static inline bool xe_configfs_check_device(struct pci_dev *pdev) { return false; }
> static inline bool xe_configfs_get_survivability_mode(struct pci_dev *pdev) { return false; }
> static inline void xe_configfs_clear_survivability_mode(struct pci_dev *pdev) { }
> static inline u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev) { return U64_MAX; }
>diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
>index f4ea13527945..322dc52c4a0b 100644
>--- a/drivers/gpu/drm/xe/xe_pci.c
>+++ b/drivers/gpu/drm/xe/xe_pci.c
>@@ -17,6 +17,7 @@
>
> #include "display/xe_display.h"
> #include "regs/xe_gt_regs.h"
>+#include "xe_configfs.h"
> #include "xe_device.h"
> #include "xe_drv.h"
> #include "xe_gt.h"
>@@ -770,6 +771,8 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> 	struct xe_device *xe;
> 	int err;
>
>+	xe_configfs_check_device(pdev);
>+
> 	if (desc->require_force_probe && !id_forced(pdev->device)) {
> 		dev_info(&pdev->dev,
> 			 "Your graphics device %04x is not officially supported\n"
>-- 
>2.47.1
>


More information about the Intel-xe mailing list