From: Stuart Summers <stuart.summers@intel.com>
Cc: intel-xe@lists.freedesktop.org, rodrigo.vivi@intel.com,
matthew.brost@intel.com, umesh.nerlige.ramappa@intel.com,
Michal.Wajdeczko@intel.com, matthew.d.roper@intel.com,
daniele.ceraolospurio@intel.com, shuicheng.lin@intel.com,
Stuart Summers <stuart.summers@intel.com>
Subject: [PATCH 9/9] drm/xe: Migrate existing debug configfs entries to params infrastructure
Date: Mon, 4 May 2026 04:43:46 +0000 [thread overview]
Message-ID: <20260504044348.209625-10-stuart.summers@intel.com> (raw)
In-Reply-To: <20260504044348.209625-1-stuart.summers@intel.com>
Move the four existing debug configfs entries whose semantics fit the
generic show/store template into the new parameter list:
- enable_psmi (bool)
- enable_survivability_mode (bool)
- guc_log_level (int, validated against GUC_LOG_LEVEL_MAX,
accepting any negative value as "unset")
- guc_log_target (u8, validated against GUC_LOG_TARGET_MAX)
guc_log_level keeps its module-parameter fallback in the public getter
xe_configfs_get_guc_log_level(): a negative value stored in configfs
(the default is %XE_GUC_LOG_LEVEL_UNSET, -1) means "use the modparam";
only a value >= 0 overrides it. The validator therefore allows any
negative value through so the sentinel can be written back from
userspace.
The remaining hand-written entries (ctx_restore_mid_bb,
ctx_restore_post_bb, engines_allowed, gt_types_allowed) all have
custom string parsing or per-class indexing that does not fit the
generic template and stay as-is.
Signed-off-by: Stuart Summers <stuart.summers@intel.com>
Assisted-by: Copilot:claude-opus-4.7
---
drivers/gpu/drm/xe/xe_configfs.c | 8 --
drivers/gpu/drm/xe/xe_configfs_debug.c | 133 +-----------------
drivers/gpu/drm/xe/xe_configfs_debug_params.h | 18 ++-
drivers/gpu/drm/xe/xe_configfs_types.h | 4 -
4 files changed, 21 insertions(+), 142 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
index 59cd83c2ac53..aa4d9fbb967a 100644
--- a/drivers/gpu/drm/xe/xe_configfs.c
+++ b/drivers/gpu/drm/xe/xe_configfs.c
@@ -102,12 +102,8 @@
const struct xe_config_device xe_configfs_device_defaults = {
#if IS_ENABLED(CONFIG_DRM_XE_DEBUG)
.debug = {
- .enable_psmi = false,
- .enable_survivability_mode = false,
.engines_allowed = U64_MAX,
.gt_types_allowed = U64_MAX,
- .guc_log_level = XE_GUC_LOG_LEVEL_UNSET,
- .guc_log_target = XE_DEFAULT_GUC_LOG_TARGET,
.params = {
XE_CONFIGFS_DEBUG_PARAMS_DEFAULTS
},
@@ -430,12 +426,8 @@ static void dump_custom_dev_config(struct pci_dev *pdev,
} while (0)
#if IS_ENABLED(CONFIG_DRM_XE_DEBUG)
- PRI_CUSTOM_ATTR("%d", debug.enable_psmi);
- PRI_CUSTOM_ATTR("%d", debug.enable_survivability_mode);
PRI_CUSTOM_ATTR("%llx", debug.engines_allowed);
PRI_CUSTOM_ATTR("%llx", debug.gt_types_allowed);
- PRI_CUSTOM_ATTR("%d", debug.guc_log_level);
- PRI_CUSTOM_ATTR("%d", debug.guc_log_target);
#define _XE_PARAM_DUMP(_T, _name, _def, _val) \
PRI_CUSTOM_ATTR(XE_PARAM_FMT_##_T, debug.params._name);
XE_CONFIGFS_DEBUG_PARAMS_FOR_EACH(_XE_PARAM_DUMP)
diff --git a/drivers/gpu/drm/xe/xe_configfs_debug.c b/drivers/gpu/drm/xe/xe_configfs_debug.c
index fcd6c81de3bb..87ec6ee0f05a 100644
--- a/drivers/gpu/drm/xe/xe_configfs_debug.c
+++ b/drivers/gpu/drm/xe/xe_configfs_debug.c
@@ -288,9 +288,9 @@ bool xe_configfs_get_enable_survivability_mode(struct pci_dev *pdev)
bool mode;
if (!dev)
- return xe_configfs_device_defaults.debug.enable_survivability_mode;
+ return xe_configfs_device_defaults.debug.params.enable_survivability_mode;
- mode = dev->config.debug.enable_survivability_mode;
+ mode = dev->config.debug.params.enable_survivability_mode;
config_group_put(&dev->group);
return mode;
@@ -308,9 +308,9 @@ u8 xe_configfs_get_guc_log_target(struct pci_dev *pdev)
u8 target;
if (!dev)
- return xe_configfs_device_defaults.debug.guc_log_target;
+ return xe_configfs_device_defaults.debug.params.guc_log_target;
- target = dev->config.debug.guc_log_target;
+ target = dev->config.debug.params.guc_log_target;
config_group_put(&dev->group);
return target;
@@ -374,7 +374,7 @@ bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev)
if (!dev)
return false;
- ret = dev->config.debug.enable_psmi;
+ ret = dev->config.debug.params.enable_psmi;
config_group_put(&dev->group);
return ret;
@@ -400,8 +400,8 @@ int xe_configfs_get_guc_log_level(struct pci_dev *pdev)
if (!dev)
goto out;
- if (dev->config.debug.guc_log_level >= 0)
- level = dev->config.debug.guc_log_level;
+ if (dev->config.debug.params.guc_log_level >= 0)
+ level = dev->config.debug.params.guc_log_level;
config_group_put(&dev->group);
out:
@@ -460,33 +460,6 @@ u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev,
return len;
}
-static ssize_t enable_survivability_mode_show(struct config_item *item, char *page)
-{
- struct xe_config_device *dev = debug_to_device(item);
-
- return sprintf(page, "%d\n", dev->debug.enable_survivability_mode);
-}
-
-static ssize_t enable_survivability_mode_store(struct config_item *item, const char *page,
- size_t len)
-{
- struct xe_config_group_device *dev = debug_to_group_device(item);
- bool enable_survivability_mode;
- int ret;
-
- ret = kstrtobool(page, &enable_survivability_mode);
- if (ret)
- return ret;
-
- guard(mutex)(&dev->lock);
- if (xe_configfs_is_bound(dev))
- return -EBUSY;
-
- dev->config.debug.enable_survivability_mode = enable_survivability_mode;
-
- return len;
-}
-
static ssize_t gt_types_allowed_show(struct config_item *item, char *page)
{
struct xe_config_device *dev = debug_to_device(item);
@@ -653,61 +626,6 @@ static ssize_t engines_allowed_store(struct config_item *item, const char *page,
return len;
}
-static ssize_t enable_psmi_show(struct config_item *item, char *page)
-{
- struct xe_config_device *dev = debug_to_device(item);
-
- return sprintf(page, "%d\n", dev->debug.enable_psmi);
-}
-
-static ssize_t enable_psmi_store(struct config_item *item, const char *page, size_t len)
-{
- struct xe_config_group_device *dev = debug_to_group_device(item);
- bool val;
- int ret;
-
- ret = kstrtobool(page, &val);
- if (ret)
- return ret;
-
- guard(mutex)(&dev->lock);
- if (xe_configfs_is_bound(dev))
- return -EBUSY;
-
- dev->config.debug.enable_psmi = val;
-
- return len;
-}
-
-static ssize_t guc_log_level_show(struct config_item *item, char *page)
-{
- struct xe_config_device *dev = debug_to_device(item);
-
- return sprintf(page, "%d\n", dev->debug.guc_log_level);
-}
-
-static ssize_t guc_log_level_store(struct config_item *item, const char *page, size_t len)
-{
- struct xe_config_group_device *dev = debug_to_group_device(item);
- int val;
- int ret;
-
- ret = kstrtoint(page, 0, &val);
- if (ret)
- return ret;
-
- if (val > GUC_LOG_LEVEL_MAX)
- return -EINVAL;
-
- guard(mutex)(&dev->lock);
- if (xe_configfs_is_bound(dev))
- return -EBUSY;
-
- dev->config.debug.guc_log_level = val;
-
- return len;
-}
-
static bool wa_bb_read_advance(bool dereference, char **p,
const char *append, size_t len,
size_t *max_size)
@@ -943,43 +861,10 @@ static ssize_t ctx_restore_post_bb_store(struct config_item *item,
return wa_bb_store(dev->config.debug.ctx_restore_post_bb, dev, data, sz);
}
-static ssize_t guc_log_target_show(struct config_item *item, char *page)
-{
- struct xe_config_device *dev = debug_to_device(item);
-
- return sprintf(page, "%d\n", dev->debug.guc_log_target);
-}
-
-static ssize_t guc_log_target_store(struct config_item *item, const char *page, size_t len)
-{
- struct xe_config_group_device *dev = debug_to_group_device(item);
- u8 guc_log_target;
- int ret;
-
- ret = kstrtou8(page, 0, &guc_log_target);
- if (ret)
- return ret;
-
- if (guc_log_target > GUC_LOG_TARGET_MAX)
- return -EINVAL;
-
- guard(mutex)(&dev->lock);
- if (xe_configfs_is_bound(dev))
- return -EBUSY;
-
- dev->config.debug.guc_log_target = guc_log_target;
-
- return len;
-}
-
CONFIGFS_ATTR(, ctx_restore_mid_bb);
CONFIGFS_ATTR(, ctx_restore_post_bb);
-CONFIGFS_ATTR(, enable_psmi);
-CONFIGFS_ATTR(, enable_survivability_mode);
CONFIGFS_ATTR(, engines_allowed);
CONFIGFS_ATTR(, gt_types_allowed);
-CONFIGFS_ATTR(, guc_log_level);
-CONFIGFS_ATTR(, guc_log_target);
static bool xe_configfs_debug_is_visible(struct config_item *item,
struct configfs_attribute *attr,
@@ -1002,12 +887,8 @@ static struct configfs_group_operations xe_configfs_debug_group_ops = {
static struct configfs_attribute *xe_configfs_debug_attrs[] = {
&attr_ctx_restore_mid_bb,
&attr_ctx_restore_post_bb,
- &attr_enable_psmi,
- &attr_enable_survivability_mode,
&attr_engines_allowed,
&attr_gt_types_allowed,
- &attr_guc_log_level,
- &attr_guc_log_target,
XE_CONFIGFS_DEBUG_PARAMS_FOR_EACH(XE_PARAM_ATTR_PTR)
NULL,
};
diff --git a/drivers/gpu/drm/xe/xe_configfs_debug_params.h b/drivers/gpu/drm/xe/xe_configfs_debug_params.h
index 9cf9256eb851..a5f8766d897c 100644
--- a/drivers/gpu/drm/xe/xe_configfs_debug_params.h
+++ b/drivers/gpu/drm/xe/xe_configfs_debug_params.h
@@ -10,6 +10,10 @@
#include <linux/errno.h>
#include <linux/types.h>
+#include "abi/guc_log_abi.h"
+#include "xe_guc_fwif.h"
+#include "xe_guc_log.h"
+
/*
* Internal type/format aliases resolved by XE_CONFIGFS_DEBUG_PARAMS_FOR_EACH().
*
@@ -43,12 +47,15 @@
* acceptable, a negative errno (typically -EINVAL) otherwise.
*
* XE_PARAM_VALIDATE_NONE is the no-op validator for parameters whose
- * full type range is acceptable. Param-specific validators are defined
- * alongside the X-macro list below so that the constraints live next to
- * the entries that depend on them.
+ * full type range is acceptable.
*/
#define XE_PARAM_VALIDATE_NONE(_v) (0)
+#define XE_PARAM_VALIDATE_GUC_LOG_LEVEL(_v) \
+ ((((_v) < 0) || ((_v) <= GUC_LOG_LEVEL_MAX)) ? 0 : -EINVAL)
+#define XE_PARAM_VALIDATE_GUC_LOG_TARGET(_v) \
+ (((_v) <= GUC_LOG_TARGET_MAX) ? 0 : -EINVAL)
+
/**
* XE_CONFIGFS_DEBUG_PARAMS_FOR_EACH - iterate over debug configfs params
* @param: function-like macro called as
@@ -73,7 +80,10 @@
* at runtime if needed.
*/
#define XE_CONFIGFS_DEBUG_PARAMS_FOR_EACH(param) \
- /* No parameters yet - add entries above this line. */
+ param(bool, enable_psmi, false, XE_PARAM_VALIDATE_NONE) \
+ param(bool, enable_survivability_mode, false, XE_PARAM_VALIDATE_NONE) \
+ param(int, guc_log_level, XE_GUC_LOG_LEVEL_UNSET, XE_PARAM_VALIDATE_GUC_LOG_LEVEL) \
+ param(u8, guc_log_target, XE_DEFAULT_GUC_LOG_TARGET, XE_PARAM_VALIDATE_GUC_LOG_TARGET)
/* Generate the struct that backs all debug params in xe_config_device. */
#define _XE_PARAM_MEMBER(_T, _name, _def, _val) XE_PARAM_TYPE_##_T _name;
diff --git a/drivers/gpu/drm/xe/xe_configfs_types.h b/drivers/gpu/drm/xe/xe_configfs_types.h
index 16e91d8072f4..a84a0c8eae7b 100644
--- a/drivers/gpu/drm/xe/xe_configfs_types.h
+++ b/drivers/gpu/drm/xe/xe_configfs_types.h
@@ -34,12 +34,8 @@ struct xe_config_group_device {
struct {
struct wa_bb ctx_restore_mid_bb[XE_ENGINE_CLASS_MAX];
struct wa_bb ctx_restore_post_bb[XE_ENGINE_CLASS_MAX];
- bool enable_psmi;
- bool enable_survivability_mode;
u64 engines_allowed;
u64 gt_types_allowed;
- int guc_log_level;
- u8 guc_log_target;
struct xe_configfs_debug_params params;
} debug;
struct {
--
2.43.0
next prev parent reply other threads:[~2026-05-04 4:43 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 4:43 [PATCH 0/9] Add new debug infrastructure for configfs Stuart Summers
2026-05-04 4:43 ` [PATCH 1/9] drm/xe: Rename survivability_mode to enable_survivability_mode Stuart Summers
2026-05-04 13:29 ` Gustavo Sousa
2026-05-04 14:32 ` Summers, Stuart
2026-05-04 14:38 ` Summers, Stuart
2026-05-04 14:40 ` Summers, Stuart
2026-05-04 18:31 ` Rodrigo Vivi
2026-05-04 18:38 ` Summers, Stuart
2026-05-04 4:43 ` [PATCH 2/9] drm/xe: Sort xe_config_device fields and defaults alphabetically Stuart Summers
2026-05-04 13:58 ` Gustavo Sousa
2026-05-04 14:38 ` Summers, Stuart
2026-05-04 15:47 ` Lin, Shuicheng
2026-05-04 15:54 ` Summers, Stuart
2026-05-04 4:43 ` [PATCH 3/9] drm/xe: Split out configfs data structures Stuart Summers
2026-05-04 4:52 ` Summers, Stuart
2026-05-04 8:47 ` Jani Nikula
2026-05-04 14:24 ` Summers, Stuart
2026-05-04 21:48 ` Matthew Brost
2026-05-04 21:51 ` Summers, Stuart
2026-05-04 4:43 ` [PATCH 4/9] drm/xe: Add a new debug focused configfs group Stuart Summers
2026-05-04 15:42 ` Gustavo Sousa
2026-05-04 15:50 ` Summers, Stuart
2026-05-04 17:28 ` Gustavo Sousa
2026-05-04 17:44 ` Summers, Stuart
2026-05-04 19:04 ` Gustavo Sousa
2026-05-05 21:45 ` Summers, Stuart
2026-05-04 4:43 ` [PATCH 5/9] drm/xe: Move debug configfs entries to xe_configfs_debug.c Stuart Summers
2026-05-04 4:43 ` [PATCH 6/9] drm/xe/guc: Add configfs support for guc_log_level Stuart Summers
2026-05-05 23:54 ` Daniele Ceraolo Spurio
2026-05-04 4:43 ` [PATCH 7/9] drm/xe/guc: Add support for NPK as a GuC log target Stuart Summers
2026-05-04 4:43 ` [PATCH 8/9] drm/xe: Add infrastructure for debug configfs parameters Stuart Summers
2026-05-04 4:43 ` Stuart Summers [this message]
2026-05-04 4:54 ` [PATCH 0/9] Add new debug infrastructure for configfs Summers, Stuart
2026-05-04 5:30 ` ✗ CI.checkpatch: warning for " Patchwork
2026-05-04 5:32 ` ✓ CI.KUnit: success " Patchwork
2026-05-04 6:44 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-04 8:42 ` ✗ Xe.CI.FULL: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260504044348.209625-10-stuart.summers@intel.com \
--to=stuart.summers@intel.com \
--cc=Michal.Wajdeczko@intel.com \
--cc=daniele.ceraolospurio@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=shuicheng.lin@intel.com \
--cc=umesh.nerlige.ramappa@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox