summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/xe/xe_bo.c
diff options
context:
space:
mode:
authorMatthew Brost <matthew.brost@intel.com>2023-06-07 18:45:20 +0300
committerRodrigo Vivi <rodrigo.vivi@intel.com>2023-12-21 19:34:53 +0300
commit7ba4c5f02763cc423bfa0c6a87a8dd5501dc3417 (patch)
treeeae2e1c715574a78895245d7ea9b0b56ae9a25fc /drivers/gpu/drm/xe/xe_bo.c
parent73c09901b0240bb6acdd957330e456e808ec52e6 (diff)
downloadlinux-7ba4c5f02763cc423bfa0c6a87a8dd5501dc3417.tar.xz
drm/xe: VM LRU bulk move
Use the TTM LRU bulk move for BOs tied to a VM. Update the bulk moves LRU position on every exec. v2: Bulk move for compute VMs, use WARN rather than BUG Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Diffstat (limited to 'drivers/gpu/drm/xe/xe_bo.c')
-rw-r--r--drivers/gpu/drm/xe/xe_bo.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 8bac1717ca78..43801994f069 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -992,6 +992,22 @@ static void xe_gem_object_free(struct drm_gem_object *obj)
ttm_bo_put(container_of(obj, struct ttm_buffer_object, base));
}
+static void xe_gem_object_close(struct drm_gem_object *obj,
+ struct drm_file *file_priv)
+{
+ struct xe_bo *bo = gem_to_xe_bo(obj);
+
+ if (bo->vm && !xe_vm_in_fault_mode(bo->vm)) {
+ struct ww_acquire_ctx ww;
+
+ XE_WARN_ON(!xe_bo_is_user(bo));
+
+ xe_bo_lock(bo, &ww, 0, false);
+ ttm_bo_set_bulk_move(&bo->ttm, NULL);
+ xe_bo_unlock(bo, &ww);
+ }
+}
+
static bool should_migrate_to_system(struct xe_bo *bo)
{
struct xe_device *xe = xe_bo_device(bo);
@@ -1047,6 +1063,7 @@ static const struct vm_operations_struct xe_gem_vm_ops = {
static const struct drm_gem_object_funcs xe_gem_object_funcs = {
.free = xe_gem_object_free,
+ .close = xe_gem_object_close,
.mmap = drm_gem_ttm_mmap,
.export = xe_gem_prime_export,
.vm_ops = &xe_gem_vm_ops,
@@ -1088,8 +1105,8 @@ void xe_bo_free(struct xe_bo *bo)
struct xe_bo *__xe_bo_create_locked(struct xe_device *xe, struct xe_bo *bo,
struct xe_tile *tile, struct dma_resv *resv,
- size_t size, enum ttm_bo_type type,
- u32 flags)
+ struct ttm_lru_bulk_move *bulk, size_t size,
+ enum ttm_bo_type type, u32 flags)
{
struct ttm_operation_ctx ctx = {
.interruptible = true,
@@ -1156,7 +1173,10 @@ struct xe_bo *__xe_bo_create_locked(struct xe_device *xe, struct xe_bo *bo,
return ERR_PTR(err);
bo->created = true;
- ttm_bo_move_to_lru_tail_unlocked(&bo->ttm);
+ if (bulk)
+ ttm_bo_set_bulk_move(&bo->ttm, bulk);
+ else
+ ttm_bo_move_to_lru_tail_unlocked(&bo->ttm);
return bo;
}
@@ -1226,7 +1246,10 @@ xe_bo_create_locked_range(struct xe_device *xe,
}
}
- bo = __xe_bo_create_locked(xe, bo, tile, vm ? &vm->resv : NULL, size,
+ bo = __xe_bo_create_locked(xe, bo, tile, vm ? &vm->resv : NULL,
+ vm && !xe_vm_in_fault_mode(vm) &&
+ flags & XE_BO_CREATE_USER_BIT ?
+ &vm->lru_bulk_move : NULL, size,
type, flags);
if (IS_ERR(bo))
return bo;