mirror of
https://github.com/torvalds/linux.git
synced 2026-04-26 02:22:28 -04:00
drm/ttm/tests: Add tests for ttm_resource and ttm_sys_man
Test initialization of ttm_resource using different memory domains. Add tests for a system memory manager and functions that can be tested without a fully-featured resource manager. Update ttm_bo_kunit_init() to initialize BO's kref and a genuine GEM drm object. Export ttm_resource_alloc for test purposes only. Signed-off-by: Karolina Stolarek <karolina.stolarek@intel.com> Tested-by: Amaranath Somalapuram <Amaranath.Somalapuram@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/68b8b293b6bf5f1170d49a1a089ccce9172e2855.1701257386.git.karolina.stolarek@intel.com Signed-off-by: Christian König <christian.koenig@amd.com>
This commit is contained in:
committed by
Christian König
parent
4350aa21cc
commit
9afc1e0aa4
@@ -29,19 +29,39 @@ struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test,
|
||||
struct ttm_test_devices *devs,
|
||||
size_t size)
|
||||
{
|
||||
struct drm_gem_object gem_obj = { .size = size };
|
||||
struct drm_gem_object gem_obj = { };
|
||||
struct ttm_buffer_object *bo;
|
||||
int err;
|
||||
|
||||
bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_NULL(test, bo);
|
||||
|
||||
bo->base = gem_obj;
|
||||
err = drm_gem_object_init(devs->drm, &bo->base, size);
|
||||
KUNIT_ASSERT_EQ(test, err, 0);
|
||||
|
||||
bo->bdev = devs->ttm_dev;
|
||||
kref_init(&bo->kref);
|
||||
|
||||
return bo;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ttm_bo_kunit_init);
|
||||
|
||||
struct ttm_place *ttm_place_kunit_init(struct kunit *test,
|
||||
uint32_t mem_type, uint32_t flags)
|
||||
{
|
||||
struct ttm_place *place;
|
||||
|
||||
place = kunit_kzalloc(test, sizeof(*place), GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_NULL(test, place);
|
||||
|
||||
place->mem_type = mem_type;
|
||||
place->flags = flags;
|
||||
|
||||
return place;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ttm_place_kunit_init);
|
||||
|
||||
struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test)
|
||||
{
|
||||
struct ttm_test_devices *devs;
|
||||
|
||||
Reference in New Issue
Block a user