From: John.C.Harrison@Intel.com
To: Intel-Xe@Lists.FreeDesktop.Org
Cc: John Harrison <John.C.Harrison@Intel.com>
Subject: [PATCH v2 3/4] drm/xe: Allow freeing of a managed bo
Date: Tue, 5 Aug 2025 16:42:54 -0700 [thread overview]
Message-ID: <20250805234256.1021020-4-John.C.Harrison@Intel.com> (raw)
In-Reply-To: <20250805234256.1021020-1-John.C.Harrison@Intel.com>
From: John Harrison <John.C.Harrison@Intel.com>
If a bo is created via xe_managed_bo_create_pin_map() then it cannot be
freed by the driver using xe_bo_unpin_map_no_vm(), or indeed any other
existing function. The DRM layer will still have a pointer stashed
away for later freeing, causing a invalid memory access on driver
unload. So add a helper for releasing the DRM action as well.
v2: Drop 'xe' parameter (review feedbak from Michal W)
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
---
drivers/gpu/drm/xe/xe_bo.c | 5 +++++
drivers/gpu/drm/xe/xe_bo.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index ffca1cea5585..87aa0f5b2b2a 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -2222,6 +2222,11 @@ struct xe_bo *xe_managed_bo_create_pin_map(struct xe_device *xe, struct xe_tile
return bo;
}
+void xe_managed_bo_unpin_map_no_vm(struct xe_bo *bo)
+{
+ devm_release_action(xe_bo_device(bo)->drm.dev, __xe_bo_unpin_map_no_vm, bo);
+}
+
struct xe_bo *xe_managed_bo_create_from_data(struct xe_device *xe, struct xe_tile *tile,
const void *data, size_t size, u32 flags)
{
diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
index 8cce413b5235..298eef403505 100644
--- a/drivers/gpu/drm/xe/xe_bo.h
+++ b/drivers/gpu/drm/xe/xe_bo.h
@@ -122,6 +122,7 @@ struct xe_bo *xe_bo_create_pin_map_at_aligned(struct xe_device *xe,
u64 alignment);
struct xe_bo *xe_managed_bo_create_pin_map(struct xe_device *xe, struct xe_tile *tile,
size_t size, u32 flags);
+void xe_managed_bo_unpin_map_no_vm(struct xe_bo *bo);
struct xe_bo *xe_managed_bo_create_from_data(struct xe_device *xe, struct xe_tile *tile,
const void *data, size_t size, u32 flags);
int xe_managed_bo_reinit_in_vram(struct xe_device *xe, struct xe_tile *tile, struct xe_bo **src);
--
2.49.0
next prev parent reply other threads:[~2025-08-05 23:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 23:42 [PATCH v2 0/4] Add test for G2G communications John.C.Harrison
2025-08-05 23:42 ` [PATCH v2 1/4] drm/xe/guc: Update CSS header structures John.C.Harrison
2025-09-05 21:30 ` Daniele Ceraolo Spurio
2025-08-05 23:42 ` [PATCH v2 2/4] drm/xe/guc: Add firmware build type to available info John.C.Harrison
2025-08-05 23:42 ` John.C.Harrison [this message]
2025-09-09 22:10 ` [PATCH v2 3/4] drm/xe: Allow freeing of a managed bo Daniele Ceraolo Spurio
2025-08-05 23:42 ` [PATCH v2 4/4] drm/xe/guc: Add test for G2G communications John.C.Harrison
2025-09-05 22:20 ` Daniele Ceraolo Spurio
2025-08-06 0:58 ` ✗ CI.checkpatch: warning for Add test for G2G communications (rev2) Patchwork
2025-08-06 0:59 ` ✓ CI.KUnit: success " Patchwork
2025-08-06 1:33 ` ✓ Xe.CI.BAT: " Patchwork
2025-08-06 2:36 ` ✗ 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=20250805234256.1021020-4-John.C.Harrison@Intel.com \
--to=john.c.harrison@intel.com \
--cc=Intel-Xe@Lists.FreeDesktop.Org \
/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