From: "Anoop, Vijay" <anoop.c.vijay@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: umesh.nerlige.ramappa@intel.com, badal.nilawar@intel.com,
rodrigo.vivi@intel.com, aravind.iddamsetty@intel.com,
riana.tauro@intel.com, anshuman.gupta@intel.com,
matthew.d.roper@intel.com, michael.j.ruhl@intel.com,
paul.e.luse@intel.com, mohamed.mansoor.v@intel.com,
kam.nasim@intel.com, anoop.c.vijay@intel.com
Subject: [PATCH v4 4/4] drm/xe/sysctrl: Add generic mailbox passthrough debugfs entry
Date: Thu, 3 Sep 2026 07:03:44 -0700 [thread overview]
Message-ID: <20260903140340.83500-10-anoop.c.vijay@intel.com> (raw)
In-Reply-To: <20260903140340.83500-6-anoop.c.vijay@intel.com>
From: Anoop Vijay <anoop.c.vijay@intel.com>
Add a "mailbox" debugfs entry that allows any System Controller
mailbox command to be issued for bring-up and debug.
group and command are supplied by the caller as the
first two tokens of every write, e.g.:
echo "<group> <command> [byte0 byte1 ...]" > mailbox
cat mailbox
Signed-off-by: Anoop Vijay <anoop.c.vijay@intel.com>
---
v4:
- Added a generic mailbox debugfs entry
---
drivers/gpu/drm/xe/xe_sysctrl_debugfs.c | 122 ++++++++++++++++++++++++
drivers/gpu/drm/xe/xe_sysctrl_types.h | 3 +
2 files changed, 125 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c b/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c
index 258479d605cb..e5bc0a5dc31f 100644
--- a/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c
@@ -258,6 +258,125 @@ static void xe_sysctrl_register_entry(struct dentry *root, struct xe_sysctrl_deb
debugfs_create_file(name, 0644, root, entry, fops);
}
+static ssize_t xe_sysctrl_mailbox_write(struct file *file, const char __user *ubuf,
+ size_t len, loff_t *offp)
+{
+ char *kbuf __free(kfree) = NULL;
+ u8 *input __free(kfree) = NULL;
+ struct seq_file *m = file->private_data;
+ struct xe_sysctrl_debugfs_entry *entry = m->private;
+ struct xe_device *xe = sc_to_xe(entry->sc);
+ struct xe_sysctrl_mailbox_command cmd = {};
+ char *token, *tmp;
+ unsigned long val;
+ size_t input_len = 0;
+ size_t max_input;
+ size_t out_len = 0;
+ u8 group, command;
+
+ if (len == 0 || len >= PAGE_SIZE)
+ return -EINVAL;
+
+ kbuf = kmalloc(len + 1, GFP_KERNEL);
+ if (!kbuf)
+ return -ENOMEM;
+
+ max_input = min_t(size_t, len, XE_SYSCTRL_MB_MAX_MESSAGE_SIZE);
+ input = kmalloc(max_input, GFP_KERNEL);
+ if (!input)
+ return -ENOMEM;
+
+ if (copy_from_user(kbuf, ubuf, len))
+ return -EFAULT;
+ kbuf[len] = '\0';
+
+ tmp = kbuf;
+
+ token = strsep(&tmp, " \t\n");
+ if (!token || kstrtoul(token, 0, &val) || val > 0xFF) {
+ xe_err(xe, "sysctrl: invalid mailbox group id\n");
+ return -EINVAL;
+ }
+ group = (u8)val;
+
+ token = strsep(&tmp, " \t\n");
+ if (!token || kstrtoul(token, 0, &val) || val > 0xFF) {
+ xe_err(xe, "sysctrl: invalid mailbox command id\n");
+ return -EINVAL;
+ }
+ command = (u8)val;
+
+ while ((token = strsep(&tmp, " \t\n")) != NULL) {
+ if (*token == '\0')
+ continue;
+
+ if (input_len >= max_input) {
+ xe_err(xe, "sysctrl: mailbox payload too large (max %d bytes)\n",
+ XE_SYSCTRL_MB_MAX_MESSAGE_SIZE);
+ return -EINVAL;
+ }
+
+ if (kstrtoul(token, 0, &val) || val > 0xFF) {
+ xe_err(xe, "sysctrl: invalid mailbox payload byte '%s'\n", token);
+ return -EINVAL;
+ }
+
+ input[input_len++] = (u8)val;
+ }
+
+ entry->group = group;
+ entry->command = command;
+
+ xe_sysctrl_create_command(&cmd, group, command, input_len ? input : NULL, input_len,
+ entry->response_buf, XE_SYSCTRL_MB_MAX_MESSAGE_SIZE);
+
+ guard(xe_pm_runtime)(xe);
+ entry->status = xe_sysctrl_send_command(entry->sc, &cmd, &out_len);
+ entry->response_len = entry->status ? 0 : out_len;
+
+ return entry->status ? entry->status : len;
+}
+
+static int xe_sysctrl_mailbox_show(struct seq_file *m, void *data)
+{
+ struct xe_sysctrl_debugfs_entry *entry = m->private;
+ size_t i;
+
+ seq_printf(m, "Command: group=0x%02x cmd=0x%02x\n", entry->group, entry->command);
+ seq_printf(m, "Status: %d (%s)\n", entry->status, entry->status ? "FAILED" : "SUCCESS");
+ seq_printf(m, "Response: %zu bytes\n", entry->response_len);
+
+ if (entry->response_len) {
+ seq_puts(m, "Response data:\n");
+ for (i = 0; i < entry->response_len; i++) {
+ if (i && (i % 16) == 0)
+ seq_putc(m, '\n');
+ seq_printf(m, "%02x ", entry->response_buf[i]);
+ }
+ seq_putc(m, '\n');
+ }
+
+ seq_puts(m, "\nUsage:\n");
+ seq_puts(m, " echo \"<group> <command> [byte0 byte1 ...]\" > mailbox\n");
+ seq_puts(m, " cat mailbox\n");
+
+ return 0;
+}
+
+static int xe_sysctrl_mailbox_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, xe_sysctrl_mailbox_show, inode->i_private);
+}
+
+static const struct file_operations xe_sysctrl_mailbox_fops = {
+ .owner = THIS_MODULE,
+ .open = xe_sysctrl_mailbox_open,
+ .read = seq_read,
+ .write = xe_sysctrl_mailbox_write,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
/**
* xe_sysctrl_debugfs_register - Register debugfs entries for System Controller
* @sc: xe_sysctrl instance
@@ -280,4 +399,7 @@ void xe_sysctrl_debugfs_register(struct xe_sysctrl *sc, struct dentry *parent)
xe_sysctrl_register_entry(root, &sc->debugfs.ras_error_inject, sc, "ras_error_inject",
XE_SYSCTRL_GROUP_DIAG, XE_SYSCTRL_CMD_DIAG_RAS_ERR_INJECT,
&xe_sysctrl_ras_error_inject_fops);
+
+ xe_sysctrl_register_entry(root, &sc->debugfs.mailbox, sc, "mailbox", 0, 0,
+ &xe_sysctrl_mailbox_fops);
}
diff --git a/drivers/gpu/drm/xe/xe_sysctrl_types.h b/drivers/gpu/drm/xe/xe_sysctrl_types.h
index 595be477f750..c47eb3ac0e98 100644
--- a/drivers/gpu/drm/xe/xe_sysctrl_types.h
+++ b/drivers/gpu/drm/xe/xe_sysctrl_types.h
@@ -68,6 +68,9 @@ struct xe_sysctrl {
/** @debugfs.ras_error_inject: RAS error injection test entry */
struct xe_sysctrl_debugfs_entry ras_error_inject;
+
+ /** @debugfs.mailbox: Generic, user-parameterized mailbox entry */
+ struct xe_sysctrl_debugfs_entry mailbox;
} debugfs;
};
--
2.43.0
next prev parent reply other threads:[~2026-09-03 14:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 14:03 [PATCH v4 0/4] drm/xe/sysctrl: Add System Controller debugfs Anoop, Vijay
2026-09-03 14:03 ` [PATCH v4 1/4] drm/xe/sysctrl: Add System Controller get application status Anoop, Vijay
2026-09-03 14:16 ` sashiko-bot
2026-09-03 19:17 ` Umesh Nerlige Ramappa
2026-09-03 20:12 ` Anoop Vijay
2026-09-03 20:42 ` Ruhl, Michael J
2026-09-04 3:13 ` Anoop Vijay
2026-09-03 14:03 ` [PATCH v4 2/4] drm/xe/sysctrl: Add sysctrl debugfs infrastructure and loopback test interface Anoop, Vijay
2026-09-03 14:13 ` sashiko-bot
2026-09-03 14:03 ` [PATCH v4 3/4] drm/xe/sysctrl: Add RAS error injection debugfs interface Anoop, Vijay
2026-09-03 14:13 ` sashiko-bot
2026-09-03 14:03 ` Anoop, Vijay [this message]
2026-09-03 14:12 ` [PATCH v4 4/4] drm/xe/sysctrl: Add generic mailbox passthrough debugfs entry sashiko-bot
2026-09-03 14:10 ` ✗ CI.checkpatch: warning for drm/xe/sysctrl: Add System Controller debugfs (rev4) Patchwork
2026-09-03 14:12 ` ✓ CI.KUnit: success " Patchwork
2026-09-03 15:02 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-04 1:27 ` ✓ Xe.CI.FULL: " 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=20260903140340.83500-10-anoop.c.vijay@intel.com \
--to=anoop.c.vijay@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=aravind.iddamsetty@intel.com \
--cc=badal.nilawar@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=kam.nasim@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=michael.j.ruhl@intel.com \
--cc=mohamed.mansoor.v@intel.com \
--cc=paul.e.luse@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@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