All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Umesh Nerlige Ramappa" <umesh.nerlige.ramappa@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v10 5/7] drm/xe/oa: Fence OA ioctls and mmap against device unplug and wedging
Date: Tue, 24 Nov 2026 20:35:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-231992@kernel.org> (raw)
In-Reply-To: <20261124201150.405479-14-umesh.nerlige.ramappa@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/xe/oa: unlocked xe_wedged() check and batch submission on
  wedged device
--

commit f0e81809543121dd60748a7d8cd0758e2b8d3805
Author: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>

drm/xe/oa: Fence OA ioctls and mmap against device unplug and wedging

This commit guards OA ioctls and stream mmap with drm_dev_enter(), fails
stream fd ioctls on a wedged device, and stops waiting for or submitting
certain OA batches once the device is unplugged or wedged.

> diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
> index 7241cf18b3252..9ce96cac3bf67 100644
> --- a/drivers/gpu/drm/xe/xe_oa.c
> +++ b/drivers/gpu/drm/xe/xe_oa.c
[ ... ]
> @@ -1722,11 +1741,20 @@ static long xe_oa_ioctl(struct file *file,
>  			unsigned long arg)
>  {
>  	struct xe_oa_stream *stream = file->private_data;
> -	long ret;
> +	struct xe_device *xe = gt_to_xe(stream->gt);
> +	long ret = -ECANCELED;
> +	int idx;
>  
> -	mutex_lock(&stream->stream_lock);
> -	ret = xe_oa_ioctl_locked(stream, cmd, arg);
> -	mutex_unlock(&stream->stream_lock);
> +	if (!drm_dev_enter(&xe->drm, &idx))
> +		return -ENODEV;
> +
> +	if (!xe_wedged(xe)) {
> +		mutex_lock(&stream->stream_lock);
> +		ret = xe_oa_ioctl_locked(stream, cmd, arg);
> +		mutex_unlock(&stream->stream_lock);
> +	}

[Severity: Medium]
Can an ioctl waiting on stream->stream_lock still run on a wedged device
because xe_wedged(xe) is checked before mutex_lock(&stream->stream_lock)?

If one thread holds stream_lock in xe_oa_emit_oa_config() and a second
thread calls xe_oa_ioctl(), the second thread passes !xe_wedged(xe) and
blocks on stream_lock.  When the device wedges, the first thread breaks
out of its wait loop and releases stream_lock, allowing the second thread
to run xe_oa_ioctl_locked() on the wedged device.

The same issue occurs in xe_oa_stream_open_ioctl(), where xe_wedged() is
only checked on entry to xe_drm_ioctl() before acquiring gt_lock or
allocating the OA buffer.  Neither xe_oa_configure_oa_context() nor
xe_oa_emit_oa_config() checks xe_wedged() before calling
xe_oa_submit_bb(), so an open or config ioctl that was already in flight
when the device wedged still submits batches to stream->exec_q or
stream->k_exec_q (which on a long-running queue without TDR will never
complete and will keep the queue alive), and when output syncs are passed
(num_signal > 0), xe_oa_emit_oa_config() skips the wait loop and returns 0
on a wedged device.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124201150.405479-9-umesh.nerlige.ramappa@intel.com?part=5

  reply	other threads:[~2026-11-24 20:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 20:11 [PATCH v10 0/7] Cleanup OA stream on PCI unbind/remove Umesh Nerlige Ramappa
2026-11-24 20:11 ` [PATCH v10 1/7] drm/xe/oa: Ignore a HW tail pointer outside the OA buffer Umesh Nerlige Ramappa
2026-11-24 20:11 ` [PATCH v10 2/7] drm/xe/oa: Use the drm device address_space for the OA stream fd Umesh Nerlige Ramappa
2026-11-24 20:11 ` [PATCH v10 3/7] drm/xe: Reject vm_ops->access on BO mappings of an unplugged device Umesh Nerlige Ramappa
2026-11-24 20:11 ` [PATCH v10 4/7] drm/xe/oa: Wait for in-flight OA batches before stream HW teardown Umesh Nerlige Ramappa
2026-11-24 20:22   ` sashiko-bot
2026-11-24 20:11 ` [PATCH v10 5/7] drm/xe/oa: Fence OA ioctls and mmap against device unplug and wedging Umesh Nerlige Ramappa
2026-11-24 20:35   ` sashiko-bot [this message]
2026-11-30 18:07     ` Umesh Nerlige Ramappa
2026-11-25  6:34   ` Shekhar Chauhan
2026-11-24 20:11 ` [PATCH v10 6/7] drm/xe/oa: Free the OA buffer and the stream after the stream destroy Umesh Nerlige Ramappa
2026-11-24 20:11 ` [PATCH v10 7/7] drm/xe/oa: Quiesce OA streams on driver unbind and PCI reset Umesh Nerlige Ramappa
2026-11-24 21:02   ` sashiko-bot
2026-11-25  6:36   ` Shekhar Chauhan
2026-11-24 21:29 ` ✓ CI.KUnit: success for Cleanup OA stream on PCI unbind/remove (rev10) Patchwork
2026-11-24 22:21 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-25  1:00 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-11-30 18:14   ` Umesh Nerlige Ramappa

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-231992@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 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.