All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Raag Jadav" <raag.jadav@intel.com>, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v6 6/7] drm/xe: Introduce xe_wedge
Date: Wed, 14 Oct 2026 06:05:17 +0000	[thread overview]
Message-ID: <sashiko-outbox-170850@kernel.org> (raw)
In-Reply-To: <20261014055215.330408-7-raag.jadav@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] drm/xe: data race and inconsistent GT state in xe_wedge_set_mode()
- [Low] perf: xe_wedged() out-of-lining adds function call overhead in hot paths
--

commit 6fd8783d76a985325bbdd99f638c5f6528cd1918
Author: Raag Jadav <raag.jadav@intel.com>

drm/xe: Introduce xe_wedge

This commit consolidates the wedging implementation into a dedicated xe_wedge
component for better maintainability. It moves the wedged state tracking and
related helpers out of xe_device and renames them to match the new component
namespace.

> diff --git a/drivers/gpu/drm/xe/xe_wedge.c b/drivers/gpu/drm/xe/xe_wedge.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_wedge.c

[ ... ]

> +/**
> + * xe_wedged() - Check for wedged device
> + * @xe: xe device instance
> + *
> + * Returns: %true if device is wedged, %false otherwise.
> + */
> +bool xe_wedged(struct xe_device *xe)
> +{
> +	return atomic_read(&xe->wedged.flag);
> +}

[Severity: Low]
Does moving this trivial atomic read out-of-line introduce unnecessary
overhead?

Hot paths like xe_bo_cpu_fault() and g2h_read() check xe_wedged() on every
invocation. Previously, xe_device_wedged() was a static inline function in
a header, allowing the compiler to optimize it. Moving it to xe_wedge.c
forces a function call for a single memory read. Should this be moved back
to a header file as a static inline?

[ ... ]

> +static int wedge_mode_set_reset_policy(struct xe_device *xe, enum xe_wedged_mode mode)
> +{
> +	struct xe_gt *gt;
> +	int ret;
> +	u8 id;
> +
> +	guard(xe_pm_runtime)(xe);
> +	for_each_gt(gt, xe, id) {
> +		ret = __wedge_mode_set_reset_policy(gt, mode);
> +		if (ret) {
> +			if (id > 0) {
> +				xe->wedged.inconsistent_reset = true;
> +				xe_err(xe, "Inconsistent reset policy state between GTs\n");
> +			}
> +			return ret;
> +		}
> +	}
> +
> +	xe->wedged.inconsistent_reset = false;
> +
> +	return 0;
> +}

[Severity: Medium]
Is there a risk of concurrent writers leaving the GTs in an inconsistent
state here?

Multiple user-space threads could simultaneously write conflicting modes to
/sys/kernel/debug/dri/*/wedged_mode, as the fops->write handler for debugfs
does not serialize concurrent invocations. If their updates to
__wedge_mode_set_reset_policy() interleave, it could leave hardware in a
mixed state (e.g., one GT configured for engine resets and another not)
while still erroneously clearing the xe->wedged.inconsistent_reset flag.

[ ... ]

> +int xe_wedge_set_mode(struct xe_device *xe, enum xe_wedged_mode mode)
> +{
> +	int ret;
> +
> +	ret = wedge_validate_mode(xe, mode);
> +	if (ret)
> +		return ret;
> +
> +	if (wedge_mode_needs_policy_update(xe, mode)) {
> +		ret = wedge_mode_set_reset_policy(xe, mode);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	xe->wedged.mode = mode;

[Severity: Medium]
Could this assignment cause a data race?

Without a lock protecting xe->wedged.mode, concurrent writes could result
in the stored mode no longer matching the actual hardware state set on the
GTs. Should these updates be synchronized to protect both the variable and
the GT policy updates?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014055215.330408-1-raag.jadav@intel.com?part=6

  reply	other threads:[~2026-10-14  6:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14  5:51 [PATCH v6 0/7] Introduce xe_wedge Raag Jadav
2026-10-14  5:51 ` [PATCH v6 1/7] drm/xe/gt: Use GT ordered workqueue for wedging Raag Jadav
2026-10-14  6:14   ` sashiko-bot
2026-10-14  5:51 ` [PATCH v6 2/7] drm/xe: Drop xe_device_set_wedged_method() Raag Jadav
2026-10-14  5:51 ` [PATCH v6 3/7] drm/xe: Move xe_device_wedged_fini() registration to xe_device_probe_early() Raag Jadav
2026-10-14  5:51 ` [PATCH v6 4/7] drm/xe: Make xe_device_declare_wedged() IRQ safe Raag Jadav
2026-10-14  6:13   ` sashiko-bot
2026-10-14  5:51 ` [PATCH v6 5/7] drm/xe/pci_error: Flush GT wedge worker before bus reset Raag Jadav
2026-10-14  5:51 ` [PATCH v6 6/7] drm/xe: Introduce xe_wedge Raag Jadav
2026-10-14  6:05   ` sashiko-bot [this message]
2026-10-14  5:51 ` [PATCH v6 7/7] drm/xe/ras: Move xe_ras_process_errors() to xe_ras Raag Jadav
2026-10-14  6:14   ` sashiko-bot
2026-10-14  5:59 ` ✗ CI.checkpatch: warning for Introduce xe_wedge (rev5) Patchwork
2026-10-14  6:02 ` ✓ CI.KUnit: success " Patchwork
2026-10-14 11:33 ` ✓ Xe.CI.BAT: " 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=sashiko-outbox-170850@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=raag.jadav@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.