[PATCH v1 2/4] drm/xe: Introduce new BO flag XE_BO_FLAG_FORCE_USER_VRAM

Piórkowski, Piotr piotr.piorkowski at intel.com
Fri Jul 18 08:17:50 UTC 2025


From: Piotr Piórkowski <piotr.piorkowski at intel.com>

When using a separate VRAM region for kernel allocations,
some kernel structures, such as context userspace data,
should not reside in the VRAM region dedicated to the kernel.
To support this, we need a mechanism to explicitly force such
allocations.
Let's add a new BO flag that forces BO allocation in
the general-purpose VRAM region accessible to userspace.

Signed-off-by: Piotr Piórkowski <piotr.piorkowski at intel.com>
---
 drivers/gpu/drm/xe/xe_bo.c | 5 +++--
 drivers/gpu/drm/xe/xe_bo.h | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 12e899726534..997ebb6fdfaa 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -224,7 +224,7 @@ static u32 bo_vram_flags_to_vram_placement(struct xe_device *xe, u32 bo_flags, u
 
 	xe_assert(xe, tile_id < xe->info.tile_count);
 
-	if (type == ttm_bo_type_kernel)
+	if (type == ttm_bo_type_kernel && !(bo_flags & XE_BO_FLAG_FORCE_USER_VRAM))
 		return xe->tiles[tile_id].mem.kernel_vram->placement;
 	else
 		return xe->tiles[tile_id].mem.vram->placement;
@@ -2035,7 +2035,8 @@ __xe_bo_create_locked(struct xe_device *xe,
 	 * that we are using unified VRAM and we need fix VRAM BO flags.
 	 */
 	if (tile && type == ttm_bo_type_kernel && xe_tile_has_separate_kernel_vram(tile) &&
-	    (flags & XE_BO_FLAG_VRAM_MASK) && tile->mem.vram->id != tile->mem.kernel_vram->id) {
+	    (flags & XE_BO_FLAG_VRAM_MASK) && tile->mem.vram->id != tile->mem.kernel_vram->id &&
+	    !(flags & XE_BO_FLAG_FORCE_USER_VRAM)) {
 		flags &= ~XE_BO_FLAG_VRAM_MASK;
 		flags |= (XE_BO_FLAG_VRAM0 << tile->mem.kernel_vram->id);
 	}
diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
index dde8e0274ff2..46c36f656ad7 100644
--- a/drivers/gpu/drm/xe/xe_bo.h
+++ b/drivers/gpu/drm/xe/xe_bo.h
@@ -48,6 +48,7 @@
 #define XE_BO_FLAG_GGTT2		BIT(22)
 #define XE_BO_FLAG_GGTT3		BIT(23)
 #define XE_BO_FLAG_CPU_ADDR_MIRROR	BIT(24)
+#define XE_BO_FLAG_FORCE_USER_VRAM	BIT(25)
 
 /* this one is trigger internally only */
 #define XE_BO_FLAG_INTERNAL_TEST	BIT(30)
-- 
2.34.1



More information about the Intel-xe mailing list