drm/xe: Map initial FB at the same place in GGTT too
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Tue, 24 Jan 2023 17:28:03 +0000 (18:28 +0100)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 19 Dec 2023 23:27:44 +0000 (18:27 -0500)
I saw a flicker when booting xe, and it's very likely that the original
FB was not mapped at the same place when inheriting, fix it.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_bo.c
drivers/gpu/drm/xe/xe_ggtt.c
drivers/gpu/drm/xe/xe_ggtt.h

index f07d1cd63fddff3f733a419e994f3d8b4f9e153f..1fcde1e933012f84bfd0e470393415cd0b67cd63 100644 (file)
@@ -1110,7 +1110,12 @@ xe_bo_create_locked_range(struct xe_device *xe,
 
                XE_BUG_ON(!gt);
 
-               err = xe_ggtt_insert_bo(gt->mem.ggtt, bo);
+               if (flags & XE_BO_CREATE_STOLEN_BIT &&
+                   flags & XE_BO_FIXED_PLACEMENT_BIT) {
+                       err = xe_ggtt_insert_bo_at(gt->mem.ggtt, bo, start);
+               } else {
+                       err = xe_ggtt_insert_bo(gt->mem.ggtt, bo);
+               }
                if (err)
                        goto err_unlock_put_bo;
        }
index 0018c84417470b1852588e1c20b47da6f396ab3a..b1b9fc57a5db169c5d4640f1d8e4732b89c21158 100644 (file)
@@ -256,7 +256,7 @@ void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
        xe_ggtt_invalidate(ggtt->gt);
 }
 
-int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
+static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo, u64 start, u64 end)
 {
        int err;
 
@@ -271,12 +271,22 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
                return err;
 
        mutex_lock(&ggtt->lock);
-       err = drm_mm_insert_node(&ggtt->mm, &bo->ggtt_node, bo->size);
+       err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node, bo->size, 0, 0, start, end, 0);
        if (!err)
                xe_ggtt_map_bo(ggtt, bo);
        mutex_unlock(&ggtt->lock);
 
-       return 0;
+       return err;
+}
+
+int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo, u64 ofs)
+{
+       return __xe_ggtt_insert_bo_at(ggtt, bo, ofs, ofs + bo->size);
+}
+
+int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
+{
+       return __xe_ggtt_insert_bo_at(ggtt, bo, 0, U64_MAX);
 }
 
 void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node)
index 289c6852ad1a230558932f8a310b627f04e61ec3..ab9cfdab5cca157f70debdfa97f2442a33c62412 100644 (file)
@@ -23,6 +23,7 @@ int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt,
 void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node);
 void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
 int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
+int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo, u64 ofs);
 void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
 
 #endif