Commit 20404204 authored by Karolina Stolarek's avatar Karolina Stolarek Committed by Christian König

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: default avatarKarolina Stolarek <karolina.stolarek@intel.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/427ea373357d0b6cb376c9d7ebc33c930bf1d28a.1691487006.git.karolina.stolarek@intel.comSigned-off-by: default avatarChristian König <christian.koenig@amd.com>
parent 24ac009e
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
obj-$(CONFIG_DRM_TTM_KUNIT_TEST) += \ obj-$(CONFIG_DRM_TTM_KUNIT_TEST) += \
ttm_device_test.o \ ttm_device_test.o \
ttm_pool_test.o \
ttm_kunit_helpers.o ttm_kunit_helpers.o
...@@ -25,6 +25,23 @@ int ttm_device_kunit_init(struct ttm_test_devices *priv, ...@@ -25,6 +25,23 @@ int ttm_device_kunit_init(struct ttm_test_devices *priv,
} }
EXPORT_SYMBOL_GPL(ttm_device_kunit_init); EXPORT_SYMBOL_GPL(ttm_device_kunit_init);
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 ttm_buffer_object *bo;
bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, bo);
bo->base = gem_obj;
bo->bdev = devs->ttm_dev;
return bo;
}
EXPORT_SYMBOL_GPL(ttm_bo_kunit_init);
struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test) struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test)
{ {
struct ttm_test_devices *devs; struct ttm_test_devices *devs;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <drm/drm_drv.h> #include <drm/drm_drv.h>
#include <drm/ttm/ttm_device.h> #include <drm/ttm/ttm_device.h>
#include <drm/ttm/ttm_bo.h>
#include <drm/drm_kunit_helpers.h> #include <drm/drm_kunit_helpers.h>
#include <kunit/test.h> #include <kunit/test.h>
...@@ -24,6 +25,9 @@ int ttm_device_kunit_init(struct ttm_test_devices *priv, ...@@ -24,6 +25,9 @@ int ttm_device_kunit_init(struct ttm_test_devices *priv,
struct ttm_device *ttm, struct ttm_device *ttm,
bool use_dma_alloc, bool use_dma_alloc,
bool use_dma32); bool use_dma32);
struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test,
struct ttm_test_devices *devs,
size_t size);
struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test); struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test);
struct ttm_test_devices *ttm_test_devices_all(struct kunit *test); struct ttm_test_devices *ttm_test_devices_all(struct kunit *test);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment