Instead of truncating ggtt_size to be below GUC_GGTT_TOP, ensure that all allocations to GGTT are only ever below GUC_GGTT_TOP.
This will allow the initial display GGTT to be reserved and cleared in the next patch, even if it is placed at the top of GGTT. By default this area will stay unused, but it will be cleared in xe_ggtt_init and reported in xe_ggtt_size() now. Signed-off-by: Maarten Lankhorst <[email protected]> --- drivers/gpu/drm/xe/xe_ggtt.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c index 8ec23862477fc..e6a3c621c04b1 100644 --- a/drivers/gpu/drm/xe/xe_ggtt.c +++ b/drivers/gpu/drm/xe/xe_ggtt.c @@ -423,9 +423,6 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt) if (IS_DGFX(xe) && xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K) ggtt->flags |= XE_GGTT_FLAGS_64K; - if (ggtt_size + ggtt_start > GUC_GGTT_TOP) - ggtt_size = GUC_GGTT_TOP - ggtt_start; - if (GRAPHICS_VERx100(xe) >= 1270) ggtt->pt_ops = (ggtt->tile->media_gt && XE_GT_WA(ggtt->tile->media_gt, 22019338487)) || @@ -615,11 +612,18 @@ void xe_ggtt_shift_nodes(struct xe_ggtt *ggtt, u64 new_start) WRITE_ONCE(ggtt->start, new_start); } +static int xe_ggtt_insert_node_in_range_locked(struct xe_ggtt_node *node, u32 size, + u32 align, u32 start, u64 end, u32 mm_flags) +{ + return drm_mm_insert_node_in_range(&node->ggtt->mm, &node->base, size, align, + 0, start, end, mm_flags); +} + static int xe_ggtt_insert_node_locked(struct xe_ggtt_node *node, u32 size, u32 align, u32 mm_flags) { - return drm_mm_insert_node_generic(&node->ggtt->mm, &node->base, size, align, 0, - mm_flags); + return xe_ggtt_insert_node_in_range_locked(node, size, align, 0, + GUC_GGTT_TOP - node->ggtt->start, mm_flags); } static struct xe_ggtt_node *ggtt_node_init(struct xe_ggtt *ggtt) @@ -834,8 +838,8 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo, xe_tile_assert(ggtt->tile, end >= start + xe_bo_size(bo)); - err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node[tile_id]->base, - xe_bo_size(bo), alignment, 0, start, end, 0); + err = xe_ggtt_insert_node_in_range_locked(bo->ggtt_node[tile_id], xe_bo_size(bo), alignment, + start, end, 0); if (err) { ggtt_node_fini(bo->ggtt_node[tile_id]); bo->ggtt_node[tile_id] = NULL; @@ -884,7 +888,7 @@ int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo, int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo, struct drm_exec *exec) { - return __xe_ggtt_insert_bo_at(ggtt, bo, 0, U64_MAX, exec); + return __xe_ggtt_insert_bo_at(ggtt, bo, 0, GUC_GGTT_TOP, exec); } /** -- 2.53.0
