]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Force user context allocations in user VRAM
authorPiotr Piórkowski <piotr.piorkowski@intel.com>
Fri, 3 Oct 2025 16:26:17 +0000 (18:26 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 6 Oct 2025 06:33:49 +0000 (08:33 +0200)
In general, kernel structures should be allocated in the kernel-dedicated
VRAM region. However, userspace context data - while used by the kernel -
does not need to reside there.
Let's force the allocation of such data in the general-purpose VRAM region
accessible to userspace.

Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://lore.kernel.org/r/20251003162619.1984236-4-piotr.piorkowski@intel.com
drivers/gpu/drm/xe/xe_exec_queue.c
drivers/gpu/drm/xe/xe_lrc.c
drivers/gpu/drm/xe/xe_lrc.h
drivers/gpu/drm/xe/xe_pt.c

index 9a251abe85f99449462ff6e5bfa65f5924af3ff8..df82463b19f6cae0cafacca9453744cadbacc075 100644 (file)
@@ -183,7 +183,7 @@ static struct xe_exec_queue *__xe_exec_queue_alloc(struct xe_device *xe,
        return q;
 }
 
-static int __xe_exec_queue_init(struct xe_exec_queue *q)
+static int __xe_exec_queue_init(struct xe_exec_queue *q, u32 exec_queue_flags)
 {
        int i, err;
        u32 flags = 0;
@@ -202,6 +202,9 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q)
                        flags |= XE_LRC_CREATE_RUNALONE;
        }
 
+       if (!(exec_queue_flags & EXEC_QUEUE_FLAG_KERNEL))
+               flags |= XE_LRC_CREATE_USER_CTX;
+
        for (i = 0; i < q->width; ++i) {
                q->lrc[i] = xe_lrc_create(q->hwe, q->vm, SZ_16K, q->msix_vec, flags);
                if (IS_ERR(q->lrc[i])) {
@@ -248,7 +251,7 @@ struct xe_exec_queue *xe_exec_queue_create(struct xe_device *xe, struct xe_vm *v
        if (IS_ERR(q))
                return q;
 
-       err = __xe_exec_queue_init(q);
+       err = __xe_exec_queue_init(q, flags);
        if (err)
                goto err_post_alloc;
 
index 47e9df7750725a42dc532b584070aed09bf52b73..c88e90175f59c98da7c5e93525062f602ad9dc98 100644 (file)
@@ -1415,6 +1415,9 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
        if (vm && vm->xef) /* userspace */
                bo_flags |= XE_BO_FLAG_PINNED_LATE_RESTORE;
 
+       if (init_flags & XE_LRC_CREATE_USER_CTX)
+               bo_flags |= XE_BO_FLAG_FORCE_USER_VRAM;
+
        lrc->bo = xe_bo_create_pin_map_novm(xe, tile,
                                            bo_size,
                                            ttm_bo_type_kernel,
index 1885654657795258668cc60b15deb5a5219b7f69..21a3daab0154184452f02c9d28d3920a16bd0b93 100644 (file)
@@ -44,8 +44,10 @@ struct xe_lrc_snapshot {
 
 #define LRC_WA_BB_SIZE SZ_4K
 
-#define XE_LRC_CREATE_RUNALONE 0x1
-#define XE_LRC_CREATE_PXP 0x2
+#define XE_LRC_CREATE_RUNALONE         BIT(0)
+#define XE_LRC_CREATE_PXP              BIT(1)
+#define XE_LRC_CREATE_USER_CTX         BIT(2)
+
 struct xe_lrc *xe_lrc_create(struct xe_hw_engine *hwe, struct xe_vm *vm,
                             u32 ring_size, u16 msix_vec, u32 flags);
 void xe_lrc_destroy(struct kref *ref);
index a1c88f9a6c7635e964a8715492d58e4809bc25eb..e39da95f3a057af922e65d95f4e3e2c980a13909 100644 (file)
@@ -122,7 +122,7 @@ struct xe_pt *xe_pt_create(struct xe_vm *vm, struct xe_tile *tile,
                   XE_BO_FLAG_IGNORE_MIN_PAGE_SIZE |
                   XE_BO_FLAG_NO_RESV_EVICT | XE_BO_FLAG_PAGETABLE;
        if (vm->xef) /* userspace */
-               bo_flags |= XE_BO_FLAG_PINNED_LATE_RESTORE;
+               bo_flags |= XE_BO_FLAG_PINNED_LATE_RESTORE | XE_BO_FLAG_FORCE_USER_VRAM;
 
        pt->level = level;