1 /* SPDX-License-Identifier: GPL-2.0 AND MIT */ 2 /* 3 * Copyright © 2023 Intel Corporation 4 */ 5 #ifndef TTM_KUNIT_HELPERS_H 6 #define TTM_KUNIT_HELPERS_H 7 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> 12 13 #include <drm/drm_kunit_helpers.h> 14 #include <kunit/test.h> 15 16 extern struct ttm_device_funcs ttm_dev_funcs; 17 18 struct ttm_test_devices { 19 struct drm_device *drm; 20 struct device *dev; 21 struct ttm_device *ttm_dev; 22 }; 23 24 /* Building blocks for test-specific init functions */ 25 int ttm_device_kunit_init(struct ttm_test_devices *priv, 26 struct ttm_device *ttm, 27 bool use_dma_alloc, 28 bool use_dma32); 29 struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test, 30 struct ttm_test_devices *devs, 31 size_t size); 32 struct ttm_place *ttm_place_kunit_init(struct kunit *test, 33 uint32_t mem_type, uint32_t flags); 34 35 struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test); 36 struct ttm_test_devices *ttm_test_devices_all(struct kunit *test); 37 38 void ttm_test_devices_put(struct kunit *test, struct ttm_test_devices *devs); 39 40 /* Generic init/fini for tests that only need DRM/TTM devices */ 41 int ttm_test_devices_init(struct kunit *test); 42 void ttm_test_devices_fini(struct kunit *test); 43 44 #endif // TTM_KUNIT_HELPERS_H 45