drm/xe: Do not rely on GGTT internals in xe_guc_buf kunit tests

Add a function to init ggtt for kunit, and use the GGTT function for
initialising the GGTT node without populating it. This
prevents the test from ever knowing about struct xe_ggtt.

Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://lore.kernel.org/r/20250505121924.921544-11-dev@lankhorst.se
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
This commit is contained in:
Maarten Lankhorst
2025-05-05 14:19:23 +02:00
parent e0096fdcf8
commit b2d6fd7ac5
3 changed files with 24 additions and 11 deletions

View File

@@ -42,10 +42,8 @@ static struct xe_bo *replacement_xe_managed_bo_create_pin_map(struct xe_device *
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, bo->ggtt_node[tile->id]);
KUNIT_ASSERT_EQ(test, 0,
drm_mm_insert_node_in_range(&ggtt->mm,
&bo->ggtt_node[tile->id]->base,
bo->size, SZ_4K,
0, 0, U64_MAX, 0));
xe_ggtt_node_insert(bo->ggtt_node[tile->id],
bo->size, SZ_4K));
}
return bo;
@@ -67,8 +65,9 @@ static int guc_buf_test_init(struct kunit *test)
ggtt = xe_device_get_root_tile(test->priv)->mem.ggtt;
guc = &xe_device_get_gt(test->priv, 0)->uc.guc;
drm_mm_init(&ggtt->mm, DUT_GGTT_START, DUT_GGTT_SIZE);
mutex_init(&ggtt->lock);
KUNIT_ASSERT_EQ(test, 0,
xe_ggtt_init_kunit(ggtt, DUT_GGTT_START,
DUT_GGTT_START + DUT_GGTT_SIZE));
kunit_activate_static_stub(test, xe_managed_bo_create_pin_map,
replacement_xe_managed_bo_create_pin_map);