ttm_kunit_helpers.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include <drm/drm_drv.h>
  8. #include <drm/ttm/ttm_device.h>
  9. #include <drm/ttm/ttm_bo.h>
  10. #include <drm/ttm/ttm_placement.h>
  11. #include <drm/drm_kunit_helpers.h>
  12. #include <kunit/test.h>
  13. #define TTM_PL_MOCK1 (TTM_PL_PRIV + 1)
  14. #define TTM_PL_MOCK2 (TTM_PL_PRIV + 2)
  15. extern struct ttm_device_funcs ttm_dev_funcs;
  16. extern struct ttm_device_funcs ttm_dev_funcs_bad_evict;
  17. struct ttm_test_devices {
  18. struct drm_device *drm;
  19. struct device *dev;
  20. struct ttm_device *ttm_dev;
  21. };
  22. /* Building blocks for test-specific init functions */
  23. int ttm_device_kunit_init(struct ttm_test_devices *priv,
  24. struct ttm_device *ttm,
  25. bool use_dma_alloc,
  26. bool use_dma32);
  27. int ttm_device_kunit_init_bad_evict(struct ttm_test_devices *priv,
  28. struct ttm_device *ttm,
  29. bool use_dma_alloc,
  30. bool use_dma32);
  31. struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test,
  32. struct ttm_test_devices *devs,
  33. size_t size,
  34. struct dma_resv *obj);
  35. struct ttm_place *ttm_place_kunit_init(struct kunit *test, u32 mem_type,
  36. u32 flags);
  37. void dummy_ttm_bo_destroy(struct ttm_buffer_object *bo);
  38. struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test);
  39. struct ttm_test_devices *ttm_test_devices_all(struct kunit *test);
  40. void ttm_test_devices_put(struct kunit *test, struct ttm_test_devices *devs);
  41. /* Generic init/fini for tests that only need DRM/TTM devices */
  42. int ttm_test_devices_init(struct kunit *test);
  43. int ttm_test_devices_all_init(struct kunit *test);
  44. void ttm_test_devices_fini(struct kunit *test);
  45. #endif // TTM_KUNIT_HELPERS_H