Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anoop, Vijay" <anoop.c.vijay@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v4 1/4] drm/xe/sysctrl: Add System Controller get application status
Date: Thu, 03 Sep 2026 14:16:12 +0000	[thread overview]
Message-ID: <20260903141612.8CA091F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <20260903140340.83500-7-anoop.c.vijay@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] If the firmware responds with more data than expected, `sysctrl_receive_frames()` exits its read loop early, permanently hanging the mailbox state machine.
--

commit b13ca50e46d24c8dd84b548f2ea15d17ffc919a8
Author: Anoop Vijay <anoop.c.vijay@intel.com>

drm/xe/sysctrl: Add System Controller get application status

Add support for querying System Controller firmware application
status. This allows callers to determine whether a given firmware
application has completed boot and post-boot initialization.

Link: https://lore.kernel.org/intel-xe/20260814095306.2482289-5-anoop.c.vijay@intel.com/
Link: https://lore.kernel.org/intel-xe/20260814095306.2482289-6-anoop.c.vijay@intel.com/

> diff --git a/drivers/gpu/drm/xe/xe_sysctrl.c b/drivers/gpu/drm/xe/xe_sysctrl.c
> index 62ccc9be71b45..5da591ade4e4b 100644
> --- a/drivers/gpu/drm/xe/xe_sysctrl.c
> +++ b/drivers/gpu/drm/xe/xe_sysctrl.c

[ ... ]

> @@ -125,3 +127,83 @@ void xe_sysctrl_pm_resume(struct xe_device *xe)
>  
>  	xe->soc_remapper.set_sysctrl_region(xe, SYSCTRL_MAILBOX_INDEX);
>  }
> +
> +static enum xe_sysctrl_fw_status
> +xe_sysctrl_check_app_status(struct xe_device *xe, enum xe_sysctrl_app_id app_id)
> +{
> +	struct xe_sysctrl_app_status_req req = {};
> +	struct xe_sysctrl_app_status_resp resp = {};
> +	struct xe_sysctrl_mailbox_command cmd = {};
> +	size_t out_len = 0;
> +	u32 flags;
> +	int ret;
> +
> +	if (!xe->info.has_sysctrl)
> +		return XE_SYSCTRL_FIRMWARE_APP_NOTSUPP;
> +
> +	req.app_id = (u8)app_id;
> +
> +	xe_sysctrl_create_command(&cmd, XE_SYSCTRL_GROUP_CORE, XE_SYSCTRL_CMD_GET_APP_STATUS_BY_ID,
> +				  &req, sizeof(req), &resp, sizeof(resp));
> +
> +	ret = xe_sysctrl_send_command(&xe->sc, &cmd, &out_len);

[Severity: High]
This isn't a bug introduced by this patch, but calling
xe_sysctrl_send_command() here exposes a pre-existing severe logic flaw in
the mailbox protocol handler.

If the firmware responds to this command with more data than expected, the
driver will permanently hang the mailbox state machine.

In drivers/gpu/drm/xe/xe_sysctrl_mailbox.c:sysctrl_receive_frames():

	while (!done && remain) {
		frame_size = min_t(size_t, remain, XE_SYSCTRL_MB_FRAME_SIZE);

		ret = sysctrl_process_frame(sc, out, frame_size, timeout_ms,
					    &done);
		if (ret)
			return ret;

		remain -= frame_size;
		out += frame_size;
	}

If the response payload is larger than the requested data_out_len,
sysctrl_receive_frames() strictly bounds its read loop by remain. When
remain drops to 0, the loop terminates before done is set.

This causes the host to stop reading the remaining frames and stop clearing
SYSCTRL_MB_CTRL_RUN_BUSY_OUT. The firmware is left waiting indefinitely
for the host to acknowledge the next frame, which will cause all subsequent
mailbox commands to time out or corrupt the mailbox state.

Does this need to be fixed in sysctrl_receive_frames() to properly drain
unexpected trailing data instead of abandoning the transaction?

> +	if (ret)
> +		return XE_SYSCTRL_FIRMWARE_COMM_FAILURE;
> +
> +	if (out_len != sizeof(resp)) {
> +		xe_err(xe, "sysctrl: unexpected get app status response length %zu (expected %zu)\n",
> +		       out_len, sizeof(resp));
> +		return XE_SYSCTRL_FIRMWARE_COMM_FAILURE;
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903140340.83500-6-anoop.c.vijay@intel.com?part=1

  reply	other threads:[~2026-09-03 14:16 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 [this message]
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 ` [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=20260903141612.8CA091F00AC4@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