From: sashiko-bot@kernel.org
To: "Mika Kuoppala" <mika.kuoppala@linux.intel.com>,
intel-xe@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 18/20] drm/xe/eudebug: Introduce per device attention scan worker
Date: Mon, 09 Nov 2026 14:24:38 +0000 [thread overview]
Message-ID: <sashiko-outbox-205088@kernel.org> (raw)
In-Reply-To: <20261109135549.4128280-19-mika.kuoppala@linux.intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/xe/eudebug: attention seqno race with discover_client()
queue create
--
commit 9b3fd09a4bd67b0862bac3d3c0bc36809193f44f
Author: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
drm/xe/eudebug: Introduce per device attention scan worker
This commit introduces a periodic per-device delayed worker to scan for EU
debugging attention bits and send DRM_XE_EUDEBUG_EVENT_EU_ATTENTION events
when an attached debugger is present, or reset the GT if no debugger will
service the halted threads.
> diff --git a/drivers/gpu/drm/xe/xe_eudebug.c b/drivers/gpu/drm/xe/xe_eudebug.c
> index 4fab8304046b3..9b1f2f97b603b 100644
> --- a/drivers/gpu/drm/xe/xe_eudebug.c
> +++ b/drivers/gpu/drm/xe/xe_eudebug.c
[ ... ]
> @@ -2218,6 +2233,362 @@ static const struct file_operations fops = {
> .compat_ioctl = compat_ptr_ioctl,
> };
>
> +/*
> + * The uapi tells userspace the attention bitmask sits 8 byte aligned within
> + * the event, so it may be scanned as u32 or u64 words. That holds today
> + * because the preceding members are u64, but a field added ahead of the
> + * array could quietly break it, so pin it down here. Only the offset can
> + * be: plain __u64 members are 4 byte aligned on i386.
> + */
> +static_assert(offsetof(struct drm_xe_eudebug_event_eu_attention, bitmask) %
> + sizeof(__u64) == 0);
> +
> +static int send_attention_event(struct xe_eudebug *d, struct xe_exec_queue *q,
> + int lrc_idx, void *bitmap, unsigned int size,
> + u64 seqno)
> +{
> + struct drm_xe_eudebug_event_eu_attention *e;
> + struct drm_xe_eudebug_event *event;
> + const u32 sz = struct_size(e, bitmask, size);
> + int h_queue, h_lrc;
> + int ret;
> +
> + if (lrc_idx < 0 || lrc_idx >= q->width)
> + return -EINVAL;
> +
> + h_queue = find_handle(d, XE_EUDEBUG_RES_TYPE_EXEC_QUEUE, q);
> + if (h_queue < 0)
> + return h_queue;
> +
> + h_lrc = find_handle(d, XE_EUDEBUG_RES_TYPE_LRC, q->lrc[lrc_idx]);
> + if (h_lrc < 0)
> + return h_lrc;
> +
> + mutex_lock(&d->lock);
> + event = xe_eudebug_prepare_event(d, DRM_XE_EUDEBUG_EVENT_EU_ATTENTION,
> + seqno, DRM_XE_EUDEBUG_EVENT_STATE_CHANGE,
> + sz);
> +
> + e = cast_event(e, event);
> + e->exec_queue_handle = h_queue;
> + e->lrc_handle = h_lrc;
> + e->bitmask_size = size;
> +
> + memcpy(e->bitmask, bitmap, size);
> + ret = xe_eudebug_queue_event(d, event);
> + mutex_unlock(&d->lock);
> +
> + return ret;
> +}
> +
> +static int relay_gt_attention(struct xe_eudebug *d, struct xe_exec_queue *q,
> + struct xe_hw_engine *hwe, int lrc_idx)
> +{
> + const u32 size = xe_gt_eu_attention_bitmap_size(q->gt);
> + void *bitmask;
> + u64 seqno;
> + int ret;
> +
> + /* If we fail at this time, assume we manage to send eventually */
> + bitmask = kvzalloc(size, GFP_KERNEL);
> + if (!bitmask)
> + return 0;
> +
> + /*
> + * Attention is state, so the event is stamped where that state is
> + * observed: as the bits are read. That is also before the handle
> + * lookups in send_attention_event(), so a handle still found there is
> + * destroyed with a later seqno. A round that ends up sending nothing
> + * leaves a gap in the numbering, which the uapi allows.
> + */
> + seqno = atomic64_inc_return(&d->events.seqno);
> +
> + ret = xe_gt_eu_attention_bitmap(q->gt, bitmask, size);
[Severity: Medium]
Can relay_gt_attention() send a DRM_XE_EUDEBUG_EVENT_EU_ATTENTION event
with a smaller seqno than the queue's DRM_XE_EUDEBUG_EVENT_CREATE event
when racing with discover_client()?
In xe_eudebug_attach(), add_debugger() publishes xef->eudebug.debugger
before discover_client() runs, and handle_gt_attention() looks up the
debugger via xe_eudebug_get_nolock() without holding xef->eudebug.ioctl_lock:
CPU0 (attention_wq) CPU1 (connect ioctl)
handle_gt_attention() xe_eudebug_attach()
d = xe_eudebug_get_nolock(...) discover_client()
relay_gt_attention() ...
seqno = atomic64_inc_return() exec_queue_create_event()
--> S1 _xe_eudebug_add_handle(LRC)
xe_gt_eu_attention_bitmap() mutex_lock(&d->lock)
__handle_insert(EXEC_QUEUE)
--> seqno = S2 (S2 > S1)
mutex_unlock(&d->lock)
send_attention_event()
find_handle(EXEC_QUEUE)
find_handle(LRC)
mutex_lock(&d->lock)
xe_eudebug_queue_event(S1)
mutex_unlock(&d->lock)
send_exec_queue_event(S2)
The attention event for q is stamped with seqno S1 < S2 and can also be
queued into d->events.fifo ahead of the EXEC_QUEUE CREATE event because
exec_queue_create_event() drops d->lock between __handle_insert() and
send_exec_queue_event(), so userspace sees an attention event for handles
that have not been created yet.
Looking up h_queue and h_lrc before stamping seqno in relay_gt_attention()
(and re-checking that the handles still exist before queueing, or holding
xef->eudebug.ioctl_lock) would ensure discovery has already assigned the
CREATE seqno first.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261109135549.4128280-1-mika.kuoppala@linux.intel.com?part=18
next prev parent reply other threads:[~2026-11-09 14:24 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 13:55 [PATCH 00/20] Intel Xe GPU Debug Support (eudebug) v11 Mika Kuoppala
2026-11-09 13:55 ` [PATCH 01/20] drm/ttm: Add ttm_bo_access_locked() Mika Kuoppala
2026-11-09 13:55 ` [PATCH 02/20] drm/xe/eudebug: Introduce eudebug interface Mika Kuoppala
2026-11-09 13:55 ` [PATCH 03/20] drm/xe/eudebug: Add documentation Mika Kuoppala
2026-11-09 13:55 ` [PATCH 04/20] drm/xe/eudebug: Add connection establishment documentation Mika Kuoppala
2026-11-09 13:55 ` [PATCH 05/20] drm/xe: Implement SR-IOV and eudebug exclusivity Mika Kuoppala
2026-11-09 13:55 ` [PATCH 06/20] drm/xe/eudebug: Introduce discovery for resources Mika Kuoppala
2026-11-09 13:55 ` [PATCH 07/20] drm/xe: Add EUDEBUG_ENABLE exec queue property Mika Kuoppala
2026-11-09 13:55 ` [PATCH 08/20] drm/xe/eudebug: Introduce exec_queue events Mika Kuoppala
2026-11-09 14:16 ` sashiko-bot
2026-11-09 13:55 ` [PATCH 09/20] drm/xe/eudebug: Mark guc contexts as debuggable Mika Kuoppala
2026-11-09 13:55 ` [PATCH 10/20] drm/xe: Introduce ADD_DEBUG_DATA and REMOVE_DEBUG_DATA vm bind ops Mika Kuoppala
2026-11-09 13:55 ` [PATCH 11/20] drm/xe/eudebug: Introduce vm bind and vm bind debug data events Mika Kuoppala
2026-11-09 14:12 ` sashiko-bot
2026-11-09 13:55 ` [PATCH 12/20] drm/xe/eudebug: Add ufence events with acks Mika Kuoppala
2026-11-09 14:22 ` sashiko-bot
2026-11-09 13:55 ` [PATCH 13/20] drm/xe/eudebug: Add vm open/pread/pwrite Mika Kuoppala
2026-11-09 14:22 ` sashiko-bot
2026-11-09 13:55 ` [PATCH 14/20] drm/xe/eudebug: Add userptr vm pread/pwrite Mika Kuoppala
2026-11-09 13:55 ` [PATCH 15/20] drm/xe/eudebug: Add hw enablement Mika Kuoppala
2026-11-09 13:55 ` [PATCH 16/20] drm/xe/eudebug: Track debuggable exec queues Mika Kuoppala
2026-11-09 13:55 ` [PATCH 17/20] drm/xe/eudebug: Introduce EU control interface Mika Kuoppala
2026-11-09 14:35 ` sashiko-bot
2026-11-09 13:55 ` [PATCH 18/20] drm/xe/eudebug: Introduce per device attention scan worker Mika Kuoppala
2026-11-09 14:24 ` sashiko-bot [this message]
2026-11-09 13:55 ` [PATCH 19/20] drm/xe/eudebug_test: Introduce eudebug live tests Mika Kuoppala
2026-11-09 13:55 ` [PATCH 20/20] drm/xe: Add xe_client_debugfs and introduce debug_data file Mika Kuoppala
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-205088@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=mika.kuoppala@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox