From: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
To: intel-xe@lists.freedesktop.org, shekhar.chauhan@intel.com,
harish.chegondi@intel.com
Cc: matthew.brost@intel.com
Subject: [PATCH v9 6/7] drm/xe/oa: Free the OA buffer and the stream after the stream destroy
Date: Fri, 20 Nov 2026 18:01:52 -0800 [thread overview]
Message-ID: <20261121020145.147384-15-umesh.nerlige.ramappa@intel.com> (raw)
In-Reply-To: <20261121020145.147384-9-umesh.nerlige.ramappa@intel.com>
Free the OA buffer, destroy stream_lock and free the stream struct in
the callers, xe_oa_release() and the stream open error path, after
xe_oa_stream_destroy() and xe_oa_destroy_locked() have released the
rest of the stream.
This lets a following patch release the stream resources when the
device goes away, while keeping the stream struct and the OA buffer,
which an mmap may still reference, until the stream fd is released.
The OA buffer is still freed with a runtime PM reference held, by
xe_oa_release() or by the ioctl in the stream open error path, so that
unpinning it can't race with the pinned BO eviction of a D3cold runtime
suspend.
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
v2: Free OA buffer with runtime PM held (Sashiko)
---
drivers/gpu/drm/xe/xe_oa.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
index 3f51dca91c51..9c4c4548c4a0 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);
@@ -1769,7 +1765,6 @@ static void xe_oa_destroy_locked(struct xe_oa_stream *stream)
xe_exec_queue_put(stream->exec_q);
drm_syncobj_put(stream->ufence_syncobj);
- kfree(stream);
}
static int xe_oa_release(struct inode *inode, struct file *file)
@@ -1781,6 +1776,10 @@ static int xe_oa_release(struct inode *inode, struct file *file)
mutex_lock(>->oa.gt_lock);
xe_oa_destroy_locked(stream);
mutex_unlock(>->oa.gt_lock);
+
+ xe_oa_free_oa_buffer(stream);
+ mutex_destroy(&stream->stream_lock);
+ kfree(stream);
xe_pm_runtime_put(gt_to_xe(gt));
/* Release the reference the OA stream kept on the driver */
@@ -2051,6 +2050,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:
--
2.55.0
next prev parent reply other threads:[~2026-11-21 2:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 2:01 [PATCH v9 0/7] Cleanup OA stream on PCI unbind/remove Umesh Nerlige Ramappa
2026-11-21 2:01 ` [PATCH v9 1/7] drm/xe/oa: Ignore a HW tail pointer outside the OA buffer Umesh Nerlige Ramappa
2026-11-21 2:01 ` [PATCH v9 2/7] drm/xe/oa: Use the drm device address_space for the OA stream fd Umesh Nerlige Ramappa
2026-11-21 2:01 ` [PATCH v9 3/7] drm/xe: Reject vm_ops->access on BO mappings of an unplugged device Umesh Nerlige Ramappa
2026-11-21 2:01 ` [PATCH v9 4/7] drm/xe/oa: Wait for in-flight OA batches before stream HW teardown Umesh Nerlige Ramappa
2026-11-21 2:01 ` [PATCH v9 5/7] drm/xe/oa: Fence OA ioctls and mmap against device unplug and wedging Umesh Nerlige Ramappa
2026-11-21 2:01 ` Umesh Nerlige Ramappa [this message]
2026-11-21 2:01 ` [PATCH v9 7/7] drm/xe/oa: Quiesce OA streams on driver unbind and PCI reset Umesh Nerlige Ramappa
2026-11-21 2:09 ` ✗ CI.checkpatch: warning for Cleanup OA stream on PCI unbind/remove (rev9) Patchwork
2026-11-21 2:11 ` ✓ CI.KUnit: success " 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=20261121020145.147384-15-umesh.nerlige.ramappa@intel.com \
--to=umesh.nerlige.ramappa@intel.com \
--cc=harish.chegondi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=shekhar.chauhan@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.