1 /* SPDX-License-Identifier: GPL-2.0 AND MIT */
3 * Copyright © 2023 Intel Corporation
5 #ifndef TTM_KUNIT_HELPERS_H
6 #define TTM_KUNIT_HELPERS_H
8 #include <drm/drm_drv.h>
9 #include <drm/ttm/ttm_device.h>
10 #include <drm/ttm/ttm_bo.h>
11 #include <drm/ttm/ttm_placement.h>
13 #include <drm/drm_kunit_helpers.h>
14 #include <kunit/test.h>
16 #define TTM_PL_MOCK1 (TTM_PL_PRIV + 1)
17 #define TTM_PL_MOCK2 (TTM_PL_PRIV + 2)
19 extern struct ttm_device_funcs ttm_dev_funcs;
20 extern struct ttm_device_funcs ttm_dev_funcs_bad_evict;
22 struct ttm_test_devices {
23 struct drm_device *drm;
25 struct ttm_device *ttm_dev;
28 /* Building blocks for test-specific init functions */
29 int ttm_device_kunit_init(struct ttm_test_devices *priv,
30 struct ttm_device *ttm,
33 int ttm_device_kunit_init_bad_evict(struct ttm_test_devices *priv,
34 struct ttm_device *ttm,
37 struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test,
38 struct ttm_test_devices *devs,
40 struct dma_resv *obj);
41 struct ttm_place *ttm_place_kunit_init(struct kunit *test, u32 mem_type,
43 void dummy_ttm_bo_destroy(struct ttm_buffer_object *bo);
45 struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test);
46 struct ttm_test_devices *ttm_test_devices_all(struct kunit *test);
48 void ttm_test_devices_put(struct kunit *test, struct ttm_test_devices *devs);
50 /* Generic init/fini for tests that only need DRM/TTM devices */
51 int ttm_test_devices_init(struct kunit *test);
52 int ttm_test_devices_all_init(struct kunit *test);
53 void ttm_test_devices_fini(struct kunit *test);
55 #endif // TTM_KUNIT_HELPERS_H