From: sashiko-bot@kernel.org
To: "Umesh Nerlige Ramappa" <umesh.nerlige.ramappa@intel.com>,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v8 7/8] drm/xe/oa: Free the OA buffer and the stream after the stream destroy
Date: Thu, 19 Nov 2026 00:48:10 +0000 [thread overview]
Message-ID: <sashiko-outbox-222265@kernel.org> (raw)
In-Reply-To: <20261119002737.3899877-17-umesh.nerlige.ramappa@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/xe/oa: xe_oa_free_oa_buffer() without rpm ref races with
D3cold evict
--
commit e0096ecf7691779fa66e916b1237581810b85b60
Author: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
drm/xe/oa: Free the OA buffer and the stream after the stream destroy
This commit moves freeing the OA buffer, destroying stream_lock, and
freeing the stream structure from xe_oa_stream_destroy() and
xe_oa_destroy_locked() to their callers, xe_oa_release() and the error
path in xe_oa_stream_open_ioctl_locked().
> diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
> index f3eceeb34e7b6..223419347eb7b 100644
> --- a/drivers/gpu/drm/xe/xe_oa.c
> +++ b/drivers/gpu/drm/xe/xe_oa.c
> @@ -929,8 +929,6 @@ static void xe_oa_stream_destroy(struct xe_oa_stream *stream)
>
> WRITE_ONCE(u->exclusive_stream, NULL);
>
> - mutex_destroy(&stream->stream_lock);
> -
> xe_oa_stream_drain(stream);
>
> if (stream->sample)
> @@ -939,8 +937,6 @@ static void xe_oa_stream_destroy(struct xe_oa_stream *stream)
> xe_oa_disable_metric_set(stream);
> xe_exec_queue_put(stream->k_exec_q);
>
> - xe_oa_free_oa_buffer(stream);
> -
> xe_force_wake_put(gt_to_fw(gt), stream->fw_ref);
> xe_pm_runtime_put(stream->oa->xe);
>
> @@ -1772,7 +1768,6 @@ static void xe_oa_destroy_locked(struct xe_oa_stream *stream)
>
> drm_syncobj_put(stream->ufence_syncobj);
> xe_pm_runtime_put(gt_to_xe(stream->gt));
> - kfree(stream);
> }
>
> static int xe_oa_release(struct inode *inode, struct file *file)
> @@ -1784,6 +1779,10 @@ static int xe_oa_release(struct inode *inode, struct file *file)
> xe_oa_destroy_locked(stream);
> mutex_unlock(>->oa.gt_lock);
>
> + xe_oa_free_oa_buffer(stream);
> + mutex_destroy(&stream->stream_lock);
> + kfree(stream);
> +
> /* Release the reference the OA stream kept on the driver */
> drm_dev_put(>_to_xe(gt)->drm);
>
> @@ -2052,6 +2051,8 @@ static int xe_oa_stream_open_ioctl_locked(struct xe_oa *oa,
> xe_oa_disable_locked(stream);
> err_destroy:
> xe_oa_stream_destroy(stream);
> + xe_oa_free_oa_buffer(stream);
> + mutex_destroy(&stream->stream_lock);
> err_free:
> kfree(stream);
> err_syncobj:
[Severity: Medium]
Can calling xe_oa_free_oa_buffer() after the stream's runtime PM
references have been dropped race with D3cold pinned-BO eviction and
restoration?
stream->oa_buffer.bo is pinned with XE_BO_FLAG_GGTT, which places it on
xe->pinned.early.kernel_bo_present. When D3cold is allowed,
xe_pm_runtime_suspend() and xe_pm_runtime_resume() walk the pinned lists
via xe_bo_apply_to_pinned(), which drops xe->pinned.lock before locking
the BO:
CPU0 CPU1
xe_oa_release() xe_pm_runtime_suspend()
xe_oa_destroy_locked() xe_bo_evict_all()
xe_pm_runtime_put() xe_bo_apply_to_pinned()
spin_lock(&xe->pinned.lock)
xe_bo_get(bo)
list_move_tail(&bo->pinned_link, ...)
spin_unlock(&xe->pinned.lock)
xe_oa_free_oa_buffer()
xe_bo_unpin_map_no_vm(bo)
xe_bo_lock(bo, false)
xe_bo_unpin(bo)
xe_bo_unlock(bo)
xe_bo_evict_pinned(bo)
xe_bo_lock(bo, false)
WARN_ON(!xe_bo_is_pinned(bo))
<-- returns -EINVAL
If runtime suspend finishes first and a subsequent runtime resume races
with xe_oa_free_oa_buffer() on platforms where mert_wa_14026633728 places
the OA buffer in VRAM, xe_bo_restore_pinned() also reads bo->backup_obj
before acquiring xe_bo_lock(bo, false), racing with xe_bo_unpin() freeing
bo->backup_obj.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119002737.3899877-10-umesh.nerlige.ramappa@intel.com?part=7
next prev parent reply other threads:[~2026-11-19 0:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 0:27 [PATCH v8 0/8] Cleanup OA stream on PCI unbind/remove Umesh Nerlige Ramappa
2026-11-19 0:27 ` [PATCH v8 1/8] drm/xe/oa: Ignore a HW tail pointer outside the OA buffer Umesh Nerlige Ramappa
2026-11-19 0:39 ` sashiko-bot
2026-11-20 7:21 ` Shekhar Chauhan
2026-11-19 0:27 ` [PATCH v8 2/8] drm/xe/oa: Use the drm device address_space for the OA stream fd Umesh Nerlige Ramappa
2026-11-19 0:39 ` sashiko-bot
2026-11-20 7:23 ` Shekhar Chauhan
2026-11-19 0:27 ` [PATCH v8 3/8] drm/xe/oa: Wait for in-flight OA batches before stream HW teardown Umesh Nerlige Ramappa
2026-11-20 7:24 ` Shekhar Chauhan
2026-11-19 0:27 ` [PATCH v8 4/8] drm/xe: Reject vm_ops->access on BO mappings of an unplugged device Umesh Nerlige Ramappa
2026-11-19 0:39 ` sashiko-bot
2026-11-19 22:36 ` Matthew Brost
2026-11-19 0:27 ` [PATCH v8 5/8] drm/xe/oa: Fence OA ioctls and mmap against device unplug and wedging Umesh Nerlige Ramappa
2026-11-20 7:25 ` Shekhar Chauhan
2026-11-19 0:27 ` [PATCH v8 6/8] drm/xe/oa: Take the runtime PM reference in xe_oa_destroy_locked() Umesh Nerlige Ramappa
2026-11-20 7:27 ` Shekhar Chauhan
2026-11-19 0:27 ` [PATCH v8 7/8] drm/xe/oa: Free the OA buffer and the stream after the stream destroy Umesh Nerlige Ramappa
2026-11-19 0:48 ` sashiko-bot [this message]
2026-11-20 7:29 ` Shekhar Chauhan
2026-11-19 0:27 ` [PATCH v8 8/8] drm/xe/oa: Quiesce OA streams on driver unbind and PCI reset Umesh Nerlige Ramappa
2026-11-19 1:11 ` sashiko-bot
2026-11-20 7:31 ` Shekhar Chauhan
2026-11-19 6:05 ` ✓ CI.KUnit: success for Cleanup OA stream on PCI unbind/remove (rev8) Patchwork
2026-11-19 6:46 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-20 9:31 ` ✗ Xe.CI.FULL: failure " 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-222265@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.