From: sashiko-bot@kernel.org
To: "Anoop, Vijay" <anoop.c.vijay@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v4 3/4] drm/xe/sysctrl: Add RAS error injection debugfs interface
Date: Thu, 03 Sep 2026 14:13:29 +0000 [thread overview]
Message-ID: <20260903141330.0E5941F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260903140340.83500-9-anoop.c.vijay@intel.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Missing PM runtime resume before accessing hardware in debugfs open and show callbacks causes system hangs.
- [Low] Jumping over a `guard()` declaration using `goto` causes compilation errors and violates cleanup subsystem rules.
- [Low] Concurrent writes to the debugfs file will race on `entry->status`, causing the `write` syscall to return the result of another thread's command.
--
commit 69962a1ffd2b865557dbedee272e0256b239b328
Author: Anoop Vijay <anoop.c.vijay@intel.com>
drm/xe/sysctrl: Add RAS error injection debugfs interface
This commit adds a debugfs interface for exercising the System Controller's
RAS error injection command. The command is used to validate RAS error
detection and recovery paths, and its access is gated on the diagnostic
firmware being ready.
> diff --git a/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c b/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c
> index 2144d9d43fba5..258479d605cbe 100644
> --- a/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c
[ ... ]
> @@ -122,6 +123,127 @@ static const struct file_operations xe_sysctrl_loopback_fops = {
> +static ssize_t xe_sysctrl_ras_error_inject_write(struct file *file, const char __user *ubuf,
> + size_t len, loff_t *offp)
> +{
[ ... ]
> + tmp = kbuf;
> + while ((token = strsep(&tmp, " \t\n")) != NULL) {
> + if (*token == '\0')
> + continue;
> +
> + if (kstrtoul(token, 0, &val))
> + goto inval;
[ ... ]
> + xe_sysctrl_create_command(&cmd, entry->group, entry->command,
> + &req, sizeof(req), resp_hdr_only,
> + sizeof(resp_hdr_only));
> +
> + guard(xe_pm_runtime)(xe);
> + entry->status = xe_sysctrl_send_command(entry->sc, &cmd, &out_len);
> +
> + return entry->status ? entry->status : len;
[Severity: Low]
Can concurrent writes race on the shared entry->status field here?
Because multiple threads can write to the ras_error_inject debugfs file at
the same time, Thread A's status could be overwritten by Thread B before
Thread A returns. This would cause an incorrect syscall return value for one
of the threads. Could this status be stored in a local variable instead of
the shared entry struct?
> +
> +inval:
> + xe_err(xe, "sysctrl: invalid ras_error_inject token '%s'\n", token);
> + return -EINVAL;
[Severity: Low]
Does this goto inval branch jump over the guard(xe_pm_runtime)(xe)
initialization?
Jumping into the scope of a variable declared with __attribute__((cleanup))
leaves it uninitialized, causing the cleanup function to execute on garbage
memory when returning. GCC and Clang will typically reject this with a build
error. This also violates the kernel cleanup subsystem guidelines against
mixing goto and guard() in the same function.
> +}
> +
> +static int xe_sysctrl_ras_error_inject_show(struct seq_file *m, void *data)
> +{
> + struct xe_sysctrl_debugfs_entry *entry = m->private;
> + struct xe_device *xe = sc_to_xe(entry->sc);
> +
> + seq_printf(m, "Command: group=0x%02x cmd=0x%02x\n", entry->group, entry->command);
> + seq_printf(m, "Diag firmware ready: %s\n",
> + str_yes_no(xe_sysctrl_is_diag_fw_ready(xe)));
[Severity: High]
Does checking xe_sysctrl_is_diag_fw_ready(xe) here access hardware MMIO
without first resuming the device?
The xe_sysctrl_is_diag_fw_ready() function sends a mailbox command, which
uses guard(xe_pm_runtime_noresume). Without a prior xe_pm_runtime_get_sync()
(which is correctly used in the .write callback via guard(xe_pm_runtime)),
accessing this when the GPU is in D3cold can cause a system hang or abort.
> + seq_printf(m, "Status: %d (%s)\n", entry->status, entry->status ? "FAILED" : "SUCCESS");
> +
> + seq_puts(m, "\nUsage:\n");
> + seq_puts(m, " echo \"<ras_block_id> <ras_sub_block_id> <err_type> [params]\" > ras_error_inject\n");
> + seq_puts(m, " cat ras_error_inject\n");
> +
> + return 0;
> +}
> +
> +static int xe_sysctrl_ras_error_inject_open(struct inode *inode, struct file *file)
> +{
> + struct xe_sysctrl_debugfs_entry *entry = inode->i_private;
> + struct xe_device *xe = sc_to_xe(entry->sc);
> +
> + if (!xe_sysctrl_is_diag_fw_ready(xe)) {
[Severity: High]
Are we also missing a PM runtime resume here in the open callback?
Similar to the .show callback above, this calls xe_sysctrl_is_diag_fw_ready()
which issues an MMIO command. A user opening this file when the device is
suspended could trigger a hang.
> + xe_err(xe, "sysctrl: diag firmware not ready, ras_error_inject unavailable\n");
> + return -ENODEV;
> + }
> +
> + return single_open(file, xe_sysctrl_ras_error_inject_show, inode->i_private);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260903140340.83500-6-anoop.c.vijay@intel.com?part=3
next prev parent reply other threads:[~2026-09-03 14:13 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 [this message]
2026-09-03 14:03 ` [PATCH v4 4/4] drm/xe/sysctrl: Add generic mailbox passthrough debugfs entry Anoop, Vijay
2026-09-03 14:12 ` 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=20260903141330.0E5941F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=anoop.c.vijay@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/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