@@ -1222,7 +1222,7 @@ static void xe_ttm_bo_destroy(struct ttm_buffer_object *ttm_bo)
xe_drm_client_remove_bo(bo);
#endif
- if (bo->vm && xe_bo_is_user(bo))
+ if (bo->vm && (xe_bo_is_user(bo) || bo->flags & XE_BO_FLAG_CPU_ADDR_MIRROR))
xe_vm_put(bo->vm);
mutex_lock(&xe->mem_access.vram_userfault.lock);
@@ -1418,7 +1418,8 @@ struct xe_bo *___xe_bo_create_locked(struct xe_device *xe, struct xe_bo *bo,
int err;
/* Only kernel objects should set GT */
- xe_assert(xe, !tile || type == ttm_bo_type_kernel);
+ xe_assert(xe, !tile || type == ttm_bo_type_kernel ||
+ flags & XE_BO_FLAG_CPU_ADDR_MIRROR);
if (XE_WARN_ON(!size)) {
xe_bo_free(bo);
@@ -1614,7 +1615,7 @@ __xe_bo_create_locked(struct xe_device *xe,
* by having all the vm's bo refereferences released at vm close
* time.
*/
- if (vm && xe_bo_is_user(bo))
+ if (vm && (xe_bo_is_user(bo) || bo->flags & XE_BO_FLAG_CPU_ADDR_MIRROR))
xe_vm_get(vm);
bo->vm = vm;
@@ -2465,8 +2466,11 @@ bool xe_bo_needs_ccs_pages(struct xe_bo *bo)
* system memory (i.e., it allows XE_PL_TT placement), FlatCCS
* can't be used since there's no CCS storage associated with
* non-VRAM addresses.
+ *
+ * XXX: Can we support CCS with CPU address mirroring?
*/
- if (IS_DGFX(xe) && (bo->flags & XE_BO_FLAG_SYSTEM))
+ if (IS_DGFX(xe) && ((bo->flags & XE_BO_FLAG_SYSTEM) ||
+ (bo->flags & XE_BO_FLAG_CPU_ADDR_MIRROR)))
return false;
return true;
@@ -47,6 +47,7 @@
XE_BO_FLAG_GGTT1 | \
XE_BO_FLAG_GGTT2 | \
XE_BO_FLAG_GGTT3)
+#define XE_BO_FLAG_CPU_ADDR_MIRROR BIT(22)
/* this one is trigger internally only */
#define XE_BO_FLAG_INTERNAL_TEST BIT(30)
Add XE_BO_FLAG_CPU_ADDR_MIRROR to indicate BO is tied to SVM range. While these BO's are kernel allocations, we need a VM reference in this case which this flag indicates. In addition, we do not support CCS on these BO's either. The later can be revisited later. v2: - Take VM ref for system allocator BOs v3: - s/XE_BO_FLAG_SYSTEM_ALLOC/XE_BO_FLAG_CPU_ADDR_MIRROR (Thomas) - Better commit message (Thomas) - Drop XE_BO_FLAG_SKIP_CLEAR for now - Add comment about possibly supporting CCS (Thomas) Signed-off-by: Matthew Brost <matthew.brost@intel.com> --- drivers/gpu/drm/xe/xe_bo.c | 12 ++++++++---- drivers/gpu/drm/xe/xe_bo.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-)