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 #define TTM_PL_MOCK1 (TTM_PL_PRIV + 1) 17 #define TTM_PL_MOCK2 (TTM_PL_PRIV + 2) 18 19 extern struct ttm_device_funcs ttm_dev_funcs; 20 extern struct ttm_device_funcs ttm_dev_funcs_bad_evict; 21 22 struct ttm_test_devices { 23 struct drm_device *drm; 24 struct device *dev; 25 struct ttm_device *ttm_dev; 26 }; 27 28 /* Building blocks for test-specific init functions */ 29 int ttm_device_kunit_init(struct ttm_test_devices *priv, 30 struct ttm_device *ttm, 31 bool use_dma_alloc, 32 bool use_dma32); 33 int ttm_device_kunit_init_bad_evict(struct ttm_test_devices *priv, 34 struct ttm_device *ttm, 35 bool use_dma_alloc, 36 bool use_dma32); 37 struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test, 38 struct ttm_test_devices *devs, 39 size_t size, 40 struct dma_resv *obj); 41 struct ttm_place *ttm_place_kunit_init(struct kunit *test, u32 mem_type, 42 u32 flags); 43 void dummy_ttm_bo_destroy(struct ttm_buffer_object *bo); 44 45 struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test); 46 struct ttm_test_devices *ttm_test_devices_all(struct kunit *test); 47 48 void ttm_test_devices_put(struct kunit *test, struct ttm_test_devices *devs); 49 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); 54 55 #endif // TTM_KUNIT_HELPERS_H 56