Skip to content

Commit 2040420

Browse files
drobnikChristianKoenigAMD
authored andcommitted
drm/ttm/tests: Add tests for ttm_pool
Add KUnit tests that exercise page allocation using page pools and freeing pages, either by returning them to the pool or freeing them. Add a basic test for ttm_pool cleanup. Introduce helpers to create a dummy ttm_buffer_object. Signed-off-by: Karolina Stolarek <[email protected]> Reviewed-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/427ea373357d0b6cb376c9d7ebc33c930bf1d28a.1691487006.git.karolina.stolarek@intel.com Signed-off-by: Christian König <[email protected]>
1 parent 24ac009 commit 2040420

File tree

4 files changed

+459
-0
lines changed

4 files changed

+459
-0
lines changed

drivers/gpu/drm/ttm/tests/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
obj-$(CONFIG_DRM_TTM_KUNIT_TEST) += \
44
ttm_device_test.o \
5+
ttm_pool_test.o \
56
ttm_kunit_helpers.o

drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ int ttm_device_kunit_init(struct ttm_test_devices *priv,
2525
}
2626
EXPORT_SYMBOL_GPL(ttm_device_kunit_init);
2727

28+
struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test,
29+
struct ttm_test_devices *devs,
30+
size_t size)
31+
{
32+
struct drm_gem_object gem_obj = { .size = size };
33+
struct ttm_buffer_object *bo;
34+
35+
bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL);
36+
KUNIT_ASSERT_NOT_NULL(test, bo);
37+
38+
bo->base = gem_obj;
39+
bo->bdev = devs->ttm_dev;
40+
41+
return bo;
42+
}
43+
EXPORT_SYMBOL_GPL(ttm_bo_kunit_init);
44+
2845
struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test)
2946
{
3047
struct ttm_test_devices *devs;

drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <drm/drm_drv.h>
99
#include <drm/ttm/ttm_device.h>
10+
#include <drm/ttm/ttm_bo.h>
1011

1112
#include <drm/drm_kunit_helpers.h>
1213
#include <kunit/test.h>
@@ -24,6 +25,9 @@ int ttm_device_kunit_init(struct ttm_test_devices *priv,
2425
struct ttm_device *ttm,
2526
bool use_dma_alloc,
2627
bool use_dma32);
28+
struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test,
29+
struct ttm_test_devices *devs,
30+
size_t size);
2731

2832
struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test);
2933
struct ttm_test_devices *ttm_test_devices_all(struct kunit *test);

0 commit comments

Comments
 (0)