Commit 231c4110 authored by Matthew Brost's avatar Matthew Brost Committed by Maarten Lankhorst
Browse files

drm/xe: Add XE_BO_GGTT_INVALIDATE flag



Add XE_BO_GGTT_INVALIDATE flag which indicates the GGTT should be
invalidated when a BO is added / removed from the GGTT. This is
typically set when a BO is used by the GuC as the GuC has GGTT TLBs.

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarMatthew Brost <matthew.brost@intel.com>
[mlankhorst: Small fix to only inherit GGTT_INVALIDATE from src bo]
[mlankhorst: Remove _BIT from name]
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240306052002.311196-4-matthew.brost@intel.com
parent 72bae5c2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma)
		xe_bo_unpin_map_no_vm(vma->dpt);
	else if (!drm_mm_node_allocated(&vma->bo->ggtt_node) ||
		 vma->bo->ggtt_node.start != vma->node.start)
		xe_ggtt_remove_node(ggtt, &vma->node);
		xe_ggtt_remove_node(ggtt, &vma->node, false);

	ttm_bo_reserve(&vma->bo->ttm, false, false, NULL);
	ttm_bo_unpin(&vma->bo->ttm);
+5 −3
Original line number Diff line number Diff line
@@ -1580,13 +1580,15 @@ struct xe_bo *xe_managed_bo_create_from_data(struct xe_device *xe, struct xe_til
int xe_managed_bo_reinit_in_vram(struct xe_device *xe, struct xe_tile *tile, struct xe_bo **src)
{
	struct xe_bo *bo;
	u32 dst_flags = XE_BO_CREATE_VRAM_IF_DGFX(tile) | XE_BO_CREATE_GGTT_BIT;

	dst_flags |= (*src)->flags & XE_BO_GGTT_INVALIDATE;

	xe_assert(xe, IS_DGFX(xe));
	xe_assert(xe, !(*src)->vmap.is_iomem);

	bo = xe_managed_bo_create_from_data(xe, tile, (*src)->vmap.vaddr, (*src)->size,
					    XE_BO_CREATE_VRAM_IF_DGFX(tile) |
					    XE_BO_CREATE_GGTT_BIT);
	bo = xe_managed_bo_create_from_data(xe, tile, (*src)->vmap.vaddr,
					    (*src)->size, dst_flags);
	if (IS_ERR(bo))
		return PTR_ERR(bo);

+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#define XE_BO_NEEDS_CPU_ACCESS		BIT(13)
#define XE_BO_NEEDS_UC			BIT(14)
#define XE_BO_NEEDS_64K			BIT(15)
#define XE_BO_GGTT_INVALIDATE		BIT(16)
/* this one is trigger internally only */
#define XE_BO_INTERNAL_TEST		BIT(30)
#define XE_BO_INTERNAL_64K		BIT(31)
+8 −4
Original line number Diff line number Diff line
@@ -390,6 +390,7 @@ void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
		xe_ggtt_set_pte(ggtt, start + offset, pte);
	}

	if (bo->flags & XE_BO_GGTT_INVALIDATE)
		xe_ggtt_invalidate(ggtt);
}

@@ -435,7 +436,8 @@ 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)
void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
			 bool invalidate)
{
	xe_device_mem_access_get(tile_to_xe(ggtt->tile));
	mutex_lock(&ggtt->lock);
@@ -444,6 +446,7 @@ void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node)
	drm_mm_remove_node(node);
	node->size = 0;

	if (invalidate)
		xe_ggtt_invalidate(ggtt);

	mutex_unlock(&ggtt->lock);
@@ -458,7 +461,8 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
	/* This BO is not currently in the GGTT */
	xe_tile_assert(ggtt->tile, bo->ggtt_node.size == bo->size);

	xe_ggtt_remove_node(ggtt, &bo->ggtt_node);
	xe_ggtt_remove_node(ggtt, &bo->ggtt_node,
			    bo->flags & XE_BO_GGTT_INVALIDATE);
}

int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p)
+2 −1
Original line number Diff line number Diff line
@@ -23,7 +23,8 @@ int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt,
				       struct drm_mm_node *node,
				       u32 size, u32 align, u32 mm_flags);
void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node);
void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
			 bool invalidate);
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,
Loading