mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 07:03:03 +02:00
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:
parent
e0096fdcf8
commit
b2d6fd7ac5
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "xe_ggtt.h"
|
||||
|
||||
#include <kunit/visibility.h>
|
||||
#include <linux/fault-inject.h>
|
||||
#include <linux/io-64-nonatomic-lo-hi.h>
|
||||
#include <linux/sizes.h>
|
||||
|
|
@ -221,6 +222,22 @@ static const struct xe_ggtt_pt_ops xelpg_pt_wa_ops = {
|
|||
.ggtt_set_pte = xe_ggtt_set_pte_and_flush,
|
||||
};
|
||||
|
||||
static void __xe_ggtt_init_early(struct xe_ggtt *ggtt, u32 reserved)
|
||||
{
|
||||
drm_mm_init(&ggtt->mm, reserved,
|
||||
ggtt->size - reserved);
|
||||
mutex_init(&ggtt->lock);
|
||||
primelockdep(ggtt);
|
||||
}
|
||||
|
||||
int xe_ggtt_init_kunit(struct xe_ggtt *ggtt, u32 reserved, u32 size)
|
||||
{
|
||||
ggtt->size = size;
|
||||
__xe_ggtt_init_early(ggtt, reserved);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_IF_KUNIT(xe_ggtt_init_kunit);
|
||||
|
||||
/**
|
||||
* xe_ggtt_init_early - Early GGTT initialization
|
||||
* @ggtt: the &xe_ggtt to be initialized
|
||||
|
|
@ -267,11 +284,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
|
|||
ggtt->pt_ops = &xelp_pt_ops;
|
||||
|
||||
ggtt->wq = alloc_workqueue("xe-ggtt-wq", 0, WQ_MEM_RECLAIM);
|
||||
|
||||
drm_mm_init(&ggtt->mm, xe_wopcm_size(xe),
|
||||
ggtt->size - xe_wopcm_size(xe));
|
||||
mutex_init(&ggtt->lock);
|
||||
primelockdep(ggtt);
|
||||
__xe_ggtt_init_early(ggtt, xe_wopcm_size(xe));
|
||||
|
||||
err = drmm_add_action_or_reset(&xe->drm, ggtt_fini_early, ggtt);
|
||||
if (err)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ struct xe_tile;
|
|||
|
||||
struct xe_ggtt *xe_ggtt_alloc(struct xe_tile *tile);
|
||||
int xe_ggtt_init_early(struct xe_ggtt *ggtt);
|
||||
int xe_ggtt_init_kunit(struct xe_ggtt *ggtt, u32 reserved, u32 size);
|
||||
int xe_ggtt_init(struct xe_ggtt *ggtt);
|
||||
|
||||
struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user