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 7/9] drm/xe/guc: Add support for NPK as a GuC log target
Date: Mon, 4 May 2026 04:43:44 +0000 [thread overview]
Message-ID: <20260504044348.209625-8-stuart.summers@intel.com> (raw)
In-Reply-To: <20260504044348.209625-1-stuart.summers@intel.com>
GuC provides the ability to gather logs through a hardware interface
called NPK. For certain debugging scenarios this can be advantageous
over getting logs from memory (or in addition to).
Add a hook for this alternate debugging mode via a configfs. This
translates into a parameter passed to GuC during load time.
v2: Convert to configfs from modparam (Matt)
v3: Configfs documentation formatting (Shuicheng)
Kerneldoc/comment add + configfs entry ordering
Only set the guc_log_target when GuC log is enabled (Daniele)
Signed-off-by: Stuart Summers <stuart.summers@intel.com>
Assisted-by: Copilot:claude-opus-4.7
---
drivers/gpu/drm/xe/abi/guc_log_abi.h | 8 ++++
drivers/gpu/drm/xe/xe_configfs.c | 2 +
drivers/gpu/drm/xe/xe_configfs_debug.c | 64 +++++++++++++++++++++++++-
drivers/gpu/drm/xe/xe_configfs_debug.h | 5 ++
drivers/gpu/drm/xe/xe_configfs_types.h | 1 +
drivers/gpu/drm/xe/xe_defaults.h | 2 +
drivers/gpu/drm/xe/xe_guc.c | 11 +++--
7 files changed, 89 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/xe/abi/guc_log_abi.h b/drivers/gpu/drm/xe/abi/guc_log_abi.h
index fbf212d59a40..e1b121bff549 100644
--- a/drivers/gpu/drm/xe/abi/guc_log_abi.h
+++ b/drivers/gpu/drm/xe/abi/guc_log_abi.h
@@ -51,6 +51,14 @@ enum guc_log_type {
#define GUC_LOG_BUFFER_TYPE_MAX 3
+enum guc_log_target {
+ GUC_LOG_TARGET_MEM = 0,
+ GUC_LOG_TARGET_NPK,
+ GUC_LOG_TARGET_MEM_AND_NPK,
+};
+
+#define GUC_LOG_TARGET_MAX GUC_LOG_TARGET_MEM_AND_NPK
+
/**
* struct guc_log_buffer_state - GuC log buffer state
*
diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
index babe33e84af2..4a5bd53af443 100644
--- a/drivers/gpu/drm/xe/xe_configfs.c
+++ b/drivers/gpu/drm/xe/xe_configfs.c
@@ -107,6 +107,7 @@ const struct xe_config_device xe_configfs_device_defaults = {
.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,
},
#endif
.sriov = {
@@ -431,6 +432,7 @@ static void dump_custom_dev_config(struct pci_dev *pdev,
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);
#endif
PRI_CUSTOM_ATTR("%u", sriov.admin_only_pf);
diff --git a/drivers/gpu/drm/xe/xe_configfs_debug.c b/drivers/gpu/drm/xe/xe_configfs_debug.c
index b5c06d1ec7c9..af4ee420cf6f 100644
--- a/drivers/gpu/drm/xe/xe_configfs_debug.c
+++ b/drivers/gpu/drm/xe/xe_configfs_debug.c
@@ -45,7 +45,8 @@
* ├── enable_survivability_mode
* ├── engines_allowed
* ├── gt_types_allowed
- * └── guc_log_level
+ * ├── guc_log_level
+ * └── guc_log_target
*
* Configure Attributes
* ====================
@@ -209,6 +210,16 @@
*
* This attribute can only be set before binding to the device.
*
+ * GuC log target:
+ * ---------------
+ *
+ * Set the destination for the GuC log. 0 - memory only (default),
+ * 1 - NPK only, 2 - memory + NPK. Example::
+ *
+ * # echo 2 > /sys/kernel/config/xe/0000:03:00.0/debug/guc_log_target
+ *
+ * This attribute can only be set before binding to the device.
+ *
*/
struct engine_info {
@@ -284,6 +295,26 @@ bool xe_configfs_get_enable_survivability_mode(struct pci_dev *pdev)
return mode;
}
+/**
+ * xe_configfs_get_guc_log_target - get configfs GuC log target attribute
+ * @pdev: pci device
+ *
+ * Return: guc_log_target attribute in configfs
+ */
+u8 xe_configfs_get_guc_log_target(struct pci_dev *pdev)
+{
+ struct xe_config_group_device *dev = xe_configfs_find_device(pdev);
+ u8 target;
+
+ if (!dev)
+ return xe_configfs_device_defaults.debug.guc_log_target;
+
+ target = dev->config.debug.guc_log_target;
+ config_group_put(&dev->group);
+
+ return target;
+}
+
/**
* xe_configfs_primary_gt_allowed - determine whether primary GTs are supported
* @pdev: pci device
@@ -911,6 +942,35 @@ 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);
@@ -918,6 +978,7 @@ 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,
@@ -945,6 +1006,7 @@ static struct configfs_attribute *xe_configfs_debug_attrs[] = {
&attr_engines_allowed,
&attr_gt_types_allowed,
&attr_guc_log_level,
+ &attr_guc_log_target,
NULL,
};
diff --git a/drivers/gpu/drm/xe/xe_configfs_debug.h b/drivers/gpu/drm/xe/xe_configfs_debug.h
index b29c739435c5..68e34307b560 100644
--- a/drivers/gpu/drm/xe/xe_configfs_debug.h
+++ b/drivers/gpu/drm/xe/xe_configfs_debug.h
@@ -15,6 +15,7 @@ struct pci_dev;
#if IS_ENABLED(CONFIG_DRM_XE_DEBUG) && IS_ENABLED(CONFIG_CONFIGFS_FS)
bool xe_configfs_get_enable_survivability_mode(struct pci_dev *pdev);
+u8 xe_configfs_get_guc_log_target(struct pci_dev *pdev);
bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev);
bool xe_configfs_media_gt_allowed(struct pci_dev *pdev);
u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev);
@@ -32,6 +33,10 @@ u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev,
* wrapped in CONFIG_DRM_XE_DEBUG.
*/
static inline bool xe_configfs_get_enable_survivability_mode(struct pci_dev *pdev) { return false; }
+static inline u8 xe_configfs_get_guc_log_target(struct pci_dev *pdev)
+{
+ return XE_DEFAULT_GUC_LOG_TARGET;
+}
static inline bool xe_configfs_primary_gt_allowed(struct pci_dev *pdev) { return true; }
static inline bool xe_configfs_media_gt_allowed(struct pci_dev *pdev) { return true; }
static inline u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev) { return U64_MAX; }
diff --git a/drivers/gpu/drm/xe/xe_configfs_types.h b/drivers/gpu/drm/xe/xe_configfs_types.h
index ba920c37c44d..8773adeffd4e 100644
--- a/drivers/gpu/drm/xe/xe_configfs_types.h
+++ b/drivers/gpu/drm/xe/xe_configfs_types.h
@@ -38,6 +38,7 @@ struct xe_config_group_device {
u64 engines_allowed;
u64 gt_types_allowed;
int guc_log_level;
+ u8 guc_log_target;
} debug;
struct {
bool admin_only_pf;
diff --git a/drivers/gpu/drm/xe/xe_defaults.h b/drivers/gpu/drm/xe/xe_defaults.h
index df88078e84b8..9330e08727a8 100644
--- a/drivers/gpu/drm/xe/xe_defaults.h
+++ b/drivers/gpu/drm/xe/xe_defaults.h
@@ -5,6 +5,7 @@
#ifndef _XE_DEFAULTS_H_
#define _XE_DEFAULTS_H_
+#include "abi/guc_log_abi.h"
#include "xe_device_types.h"
#if IS_ENABLED(CONFIG_DRM_XE_DEBUG)
@@ -12,6 +13,7 @@
#else
#define XE_DEFAULT_GUC_LOG_LEVEL 1
#endif
+#define XE_DEFAULT_GUC_LOG_TARGET GUC_LOG_TARGET_MEM
/* Sentinel value for guc_log_level configfs: not set, fall back to module param */
#define XE_GUC_LOG_LEVEL_UNSET -1
diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index e520afbf1f22..c486b9641178 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -74,13 +74,18 @@ static u32 guc_bo_ggtt_addr(struct xe_guc *guc,
static u32 guc_ctl_debug_flags(struct xe_guc *guc)
{
+ struct pci_dev *pdev = to_pci_dev(guc_to_xe(guc)->drm.dev);
u32 level = xe_guc_log_get_level(&guc->log);
u32 flags = 0;
- if (!GUC_LOG_LEVEL_IS_VERBOSE(level))
+ if (!GUC_LOG_LEVEL_IS_VERBOSE(level)) {
flags |= GUC_LOG_DISABLED;
- else
- flags |= FIELD_PREP(GUC_LOG_VERBOSITY, GUC_LOG_LEVEL_TO_VERBOSITY(level));
+ } else {
+ flags |= FIELD_PREP(GUC_LOG_VERBOSITY,
+ GUC_LOG_LEVEL_TO_VERBOSITY(level));
+ flags |= FIELD_PREP(GUC_LOG_DESTINATION,
+ xe_configfs_get_guc_log_target(pdev));
+ }
return flags;
}
--
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 ` Stuart Summers [this message]
2026-05-04 4:43 ` [PATCH 8/9] drm/xe: Add infrastructure for debug configfs parameters Stuart Summers
2026-05-04 4:43 ` [PATCH 9/9] drm/xe: Migrate existing debug configfs entries to params infrastructure Stuart Summers
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-8-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