Lines Matching full:test

28 static struct ttm_placement *ttm_placement_kunit_init(struct kunit *test,  in ttm_placement_kunit_init()  argument
34 placement = kunit_kzalloc(test, sizeof(*placement), GFP_KERNEL); in ttm_placement_kunit_init()
35 KUNIT_ASSERT_NOT_NULL(test, placement); in ttm_placement_kunit_init()
53 static struct dma_fence *alloc_mock_fence(struct kunit *test) in alloc_mock_fence() argument
57 fence = kunit_kzalloc(test, sizeof(*fence), GFP_KERNEL); in alloc_mock_fence()
58 KUNIT_ASSERT_NOT_NULL(test, fence); in alloc_mock_fence()
65 static void dma_resv_kunit_active_fence_init(struct kunit *test, in dma_resv_kunit_active_fence_init() argument
71 fence = alloc_mock_fence(test); in dma_resv_kunit_active_fence_init()
104 static void ttm_bo_init_reserved_sys_man(struct kunit *test) in ttm_bo_init_reserved_sys_man() argument
106 const struct ttm_bo_validate_test_case *params = test->param_value; in ttm_bo_init_reserved_sys_man()
107 struct ttm_test_devices *priv = test->priv; in ttm_bo_init_reserved_sys_man()
116 bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL); in ttm_bo_init_reserved_sys_man()
117 KUNIT_ASSERT_NOT_NULL(test, bo); in ttm_bo_init_reserved_sys_man()
119 place = ttm_place_kunit_init(test, TTM_PL_SYSTEM, 0); in ttm_bo_init_reserved_sys_man()
120 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_init_reserved_sys_man()
129 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_init_reserved_sys_man()
130 KUNIT_EXPECT_EQ(test, kref_read(&bo->kref), 1); in ttm_bo_init_reserved_sys_man()
131 KUNIT_EXPECT_PTR_EQ(test, bo->bdev, priv->ttm_dev); in ttm_bo_init_reserved_sys_man()
132 KUNIT_EXPECT_EQ(test, bo->type, bo_type); in ttm_bo_init_reserved_sys_man()
133 KUNIT_EXPECT_EQ(test, bo->page_alignment, PAGE_SIZE); in ttm_bo_init_reserved_sys_man()
134 KUNIT_EXPECT_PTR_EQ(test, bo->destroy, &dummy_ttm_bo_destroy); in ttm_bo_init_reserved_sys_man()
135 KUNIT_EXPECT_EQ(test, bo->pin_count, 0); in ttm_bo_init_reserved_sys_man()
136 KUNIT_EXPECT_NULL(test, bo->bulk_move); in ttm_bo_init_reserved_sys_man()
137 KUNIT_EXPECT_NOT_NULL(test, bo->ttm); in ttm_bo_init_reserved_sys_man()
138 KUNIT_EXPECT_FALSE(test, ttm_tt_is_populated(bo->ttm)); in ttm_bo_init_reserved_sys_man()
139 KUNIT_EXPECT_NOT_NULL(test, (void *)bo->base.resv->fences); in ttm_bo_init_reserved_sys_man()
140 KUNIT_EXPECT_EQ(test, ctx.bytes_moved, size); in ttm_bo_init_reserved_sys_man()
143 KUNIT_EXPECT_TRUE(test, in ttm_bo_init_reserved_sys_man()
150 static void ttm_bo_init_reserved_mock_man(struct kunit *test) in ttm_bo_init_reserved_mock_man() argument
152 const struct ttm_bo_validate_test_case *params = test->param_value; in ttm_bo_init_reserved_mock_man()
154 struct ttm_test_devices *priv = test->priv; in ttm_bo_init_reserved_mock_man()
165 bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL); in ttm_bo_init_reserved_mock_man()
166 KUNIT_ASSERT_NOT_NULL(test, bo); in ttm_bo_init_reserved_mock_man()
168 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_init_reserved_mock_man()
169 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_init_reserved_mock_man()
178 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_init_reserved_mock_man()
179 KUNIT_EXPECT_EQ(test, kref_read(&bo->kref), 1); in ttm_bo_init_reserved_mock_man()
180 KUNIT_EXPECT_PTR_EQ(test, bo->bdev, priv->ttm_dev); in ttm_bo_init_reserved_mock_man()
181 KUNIT_EXPECT_EQ(test, bo->type, bo_type); in ttm_bo_init_reserved_mock_man()
182 KUNIT_EXPECT_EQ(test, ctx.bytes_moved, size); in ttm_bo_init_reserved_mock_man()
185 KUNIT_EXPECT_TRUE(test, in ttm_bo_init_reserved_mock_man()
193 static void ttm_bo_init_reserved_resv(struct kunit *test) in ttm_bo_init_reserved_resv() argument
196 struct ttm_test_devices *priv = test->priv; in ttm_bo_init_reserved_resv()
205 bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL); in ttm_bo_init_reserved_resv()
206 KUNIT_ASSERT_NOT_NULL(test, bo); in ttm_bo_init_reserved_resv()
208 place = ttm_place_kunit_init(test, TTM_PL_SYSTEM, 0); in ttm_bo_init_reserved_resv()
209 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_init_reserved_resv()
220 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_init_reserved_resv()
221 KUNIT_EXPECT_PTR_EQ(test, bo->base.resv, &resv); in ttm_bo_init_reserved_resv()
227 static void ttm_bo_validate_basic(struct kunit *test) in ttm_bo_validate_basic() argument
229 const struct ttm_bo_validate_test_case *params = test->param_value; in ttm_bo_validate_basic()
233 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_basic()
241 fst_place = ttm_place_kunit_init(test, fst_mem, 0); in ttm_bo_validate_basic()
242 fst_placement = ttm_placement_kunit_init(test, fst_place, 1); in ttm_bo_validate_basic()
244 bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL); in ttm_bo_validate_basic()
245 KUNIT_ASSERT_NOT_NULL(test, bo); in ttm_bo_validate_basic()
252 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_basic()
254 snd_place = ttm_place_kunit_init(test, snd_mem, DRM_BUDDY_TOPDOWN_ALLOCATION); in ttm_bo_validate_basic()
255 snd_placement = ttm_placement_kunit_init(test, snd_place, 1); in ttm_bo_validate_basic()
260 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_basic()
261 KUNIT_EXPECT_EQ(test, ctx_val.bytes_moved, bo->base.size); in ttm_bo_validate_basic()
262 KUNIT_EXPECT_NOT_NULL(test, bo->ttm); in ttm_bo_validate_basic()
263 KUNIT_EXPECT_TRUE(test, ttm_tt_is_populated(bo->ttm)); in ttm_bo_validate_basic()
264 KUNIT_EXPECT_EQ(test, bo->resource->mem_type, snd_mem); in ttm_bo_validate_basic()
265 KUNIT_EXPECT_EQ(test, bo->resource->placement, in ttm_bo_validate_basic()
272 static void ttm_bo_validate_invalid_placement(struct kunit *test) in ttm_bo_validate_invalid_placement() argument
283 place = ttm_place_kunit_init(test, unknown_mem_type, 0); in ttm_bo_validate_invalid_placement()
284 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_invalid_placement()
286 bo = ttm_bo_kunit_init(test, test->priv, size, NULL); in ttm_bo_validate_invalid_placement()
293 KUNIT_EXPECT_EQ(test, err, -ENOMEM); in ttm_bo_validate_invalid_placement()
298 static void ttm_bo_validate_failed_alloc(struct kunit *test) in ttm_bo_validate_failed_alloc() argument
301 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_failed_alloc()
310 bo = ttm_bo_kunit_init(test, test->priv, size, NULL); in ttm_bo_validate_failed_alloc()
315 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_failed_alloc()
316 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_failed_alloc()
322 KUNIT_EXPECT_EQ(test, err, -ENOMEM); in ttm_bo_validate_failed_alloc()
328 static void ttm_bo_validate_pinned(struct kunit *test) in ttm_bo_validate_pinned() argument
339 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_pinned()
340 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_pinned()
342 bo = ttm_bo_kunit_init(test, test->priv, size, NULL); in ttm_bo_validate_pinned()
350 KUNIT_EXPECT_EQ(test, err, -EINVAL); in ttm_bo_validate_pinned()
373 static void ttm_bo_validate_same_placement(struct kunit *test) in ttm_bo_validate_same_placement() argument
375 const struct ttm_bo_validate_test_case *params = test->param_value; in ttm_bo_validate_same_placement()
377 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_same_placement()
384 place = ttm_place_kunit_init(test, params->mem_type, 0); in ttm_bo_validate_same_placement()
385 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_same_placement()
390 bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL); in ttm_bo_validate_same_placement()
391 KUNIT_ASSERT_NOT_NULL(test, bo); in ttm_bo_validate_same_placement()
398 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_same_placement()
403 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_same_placement()
404 KUNIT_EXPECT_EQ(test, ctx_val.bytes_moved, 0); in ttm_bo_validate_same_placement()
412 static void ttm_bo_validate_busy_placement(struct kunit *test) in ttm_bo_validate_busy_placement() argument
418 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_busy_placement()
428 init_place = ttm_place_kunit_init(test, TTM_PL_SYSTEM, 0); in ttm_bo_validate_busy_placement()
429 placement_init = ttm_placement_kunit_init(test, init_place, 1); in ttm_bo_validate_busy_placement()
431 bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL); in ttm_bo_validate_busy_placement()
432 KUNIT_ASSERT_NOT_NULL(test, bo); in ttm_bo_validate_busy_placement()
439 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_busy_placement()
443 placement_val = ttm_placement_kunit_init(test, places, 2); in ttm_bo_validate_busy_placement()
450 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_busy_placement()
451 KUNIT_EXPECT_EQ(test, ctx_val.bytes_moved, bo->base.size); in ttm_bo_validate_busy_placement()
452 KUNIT_EXPECT_EQ(test, bo->resource->mem_type, snd_mem); in ttm_bo_validate_busy_placement()
453 KUNIT_ASSERT_TRUE(test, list_is_singular(&man->lru[bo->priority])); in ttm_bo_validate_busy_placement()
460 static void ttm_bo_validate_multihop(struct kunit *test) in ttm_bo_validate_multihop() argument
462 const struct ttm_bo_validate_test_case *params = test->param_value; in ttm_bo_validate_multihop()
466 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_multihop()
475 fst_place = ttm_place_kunit_init(test, fst_mem, 0); in ttm_bo_validate_multihop()
476 placement_init = ttm_placement_kunit_init(test, fst_place, 1); in ttm_bo_validate_multihop()
478 bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL); in ttm_bo_validate_multihop()
479 KUNIT_ASSERT_NOT_NULL(test, bo); in ttm_bo_validate_multihop()
486 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_multihop()
488 final_place = ttm_place_kunit_init(test, final_mem, 0); in ttm_bo_validate_multihop()
489 placement_val = ttm_placement_kunit_init(test, final_place, 1); in ttm_bo_validate_multihop()
494 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_multihop()
495 KUNIT_EXPECT_EQ(test, ctx_val.bytes_moved, size * 2); in ttm_bo_validate_multihop()
496 KUNIT_EXPECT_EQ(test, bo->resource->mem_type, final_mem); in ttm_bo_validate_multihop()
517 static void ttm_bo_validate_no_placement_signaled(struct kunit *test) in ttm_bo_validate_no_placement_signaled() argument
519 const struct ttm_bo_validate_test_case *params = test->param_value; in ttm_bo_validate_no_placement_signaled()
521 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_no_placement_signaled()
533 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_no_placement_signaled()
536 bo = ttm_bo_kunit_init(test, test->priv, size, NULL); in ttm_bo_validate_no_placement_signaled()
546 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_no_placement_signaled()
547 KUNIT_ASSERT_EQ(test, man->usage, size); in ttm_bo_validate_no_placement_signaled()
549 placement = kunit_kzalloc(test, sizeof(*placement), GFP_KERNEL); in ttm_bo_validate_no_placement_signaled()
550 KUNIT_ASSERT_NOT_NULL(test, placement); in ttm_bo_validate_no_placement_signaled()
556 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_no_placement_signaled()
557 KUNIT_ASSERT_EQ(test, man->usage, 0); in ttm_bo_validate_no_placement_signaled()
558 KUNIT_ASSERT_NOT_NULL(test, bo->ttm); in ttm_bo_validate_no_placement_signaled()
559 KUNIT_EXPECT_EQ(test, ctx.bytes_moved, 0); in ttm_bo_validate_no_placement_signaled()
564 KUNIT_ASSERT_PTR_EQ(test, bo->ttm, old_tt); in ttm_bo_validate_no_placement_signaled()
565 KUNIT_ASSERT_FALSE(test, flags & TTM_TT_FLAG_PRIV_POPULATED); in ttm_bo_validate_no_placement_signaled()
566 KUNIT_ASSERT_TRUE(test, flags & TTM_TT_FLAG_ZERO_ALLOC); in ttm_bo_validate_no_placement_signaled()
588 static void ttm_bo_validate_no_placement_not_signaled(struct kunit *test) in ttm_bo_validate_no_placement_not_signaled() argument
590 const struct ttm_bo_validate_test_case *params = test->param_value; in ttm_bo_validate_no_placement_not_signaled()
601 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_no_placement_not_signaled()
603 bo = ttm_bo_kunit_init(test, test->priv, size, NULL); in ttm_bo_validate_no_placement_not_signaled()
607 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_no_placement_not_signaled()
609 placement = kunit_kzalloc(test, sizeof(*placement), GFP_KERNEL); in ttm_bo_validate_no_placement_not_signaled()
610 KUNIT_ASSERT_NOT_NULL(test, placement); in ttm_bo_validate_no_placement_not_signaled()
614 dma_resv_kunit_active_fence_init(test, bo->base.resv, usage); in ttm_bo_validate_no_placement_not_signaled()
618 KUNIT_FAIL(test, "Couldn't create dma resv signal task\n"); in ttm_bo_validate_no_placement_not_signaled()
625 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_no_placement_not_signaled()
626 KUNIT_ASSERT_NOT_NULL(test, bo->ttm); in ttm_bo_validate_no_placement_not_signaled()
627 KUNIT_ASSERT_NULL(test, bo->resource); in ttm_bo_validate_no_placement_not_signaled()
628 KUNIT_ASSERT_NULL(test, bo->bulk_move); in ttm_bo_validate_no_placement_not_signaled()
629 KUNIT_EXPECT_EQ(test, ctx.bytes_moved, 0); in ttm_bo_validate_no_placement_not_signaled()
632 KUNIT_ASSERT_PTR_EQ(test, bo->base.resv, &bo->base._resv); in ttm_bo_validate_no_placement_not_signaled()
640 static void ttm_bo_validate_move_fence_signaled(struct kunit *test) in ttm_bo_validate_move_fence_signaled() argument
643 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_move_fence_signaled()
656 bo = ttm_bo_kunit_init(test, test->priv, size, NULL); in ttm_bo_validate_move_fence_signaled()
659 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_move_fence_signaled()
660 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_move_fence_signaled()
666 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_move_fence_signaled()
667 KUNIT_EXPECT_EQ(test, bo->resource->mem_type, mem_type); in ttm_bo_validate_move_fence_signaled()
668 KUNIT_EXPECT_EQ(test, ctx.bytes_moved, size); in ttm_bo_validate_move_fence_signaled()
697 static void ttm_bo_validate_move_fence_not_signaled(struct kunit *test) in ttm_bo_validate_move_fence_not_signaled() argument
699 const struct ttm_bo_validate_test_case *params = test->param_value; in ttm_bo_validate_move_fence_not_signaled()
705 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_move_fence_not_signaled()
713 init_place = ttm_place_kunit_init(test, TTM_PL_SYSTEM, 0); in ttm_bo_validate_move_fence_not_signaled()
714 placement_init = ttm_placement_kunit_init(test, init_place, 1); in ttm_bo_validate_move_fence_not_signaled()
716 bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL); in ttm_bo_validate_move_fence_not_signaled()
717 KUNIT_ASSERT_NOT_NULL(test, bo); in ttm_bo_validate_move_fence_not_signaled()
724 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_move_fence_not_signaled()
731 placement_val = ttm_placement_kunit_init(test, places, 2); in ttm_bo_validate_move_fence_not_signaled()
735 man->move = alloc_mock_fence(test); in ttm_bo_validate_move_fence_not_signaled()
739 KUNIT_FAIL(test, "Couldn't create move fence signal task\n"); in ttm_bo_validate_move_fence_not_signaled()
747 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_move_fence_not_signaled()
748 KUNIT_EXPECT_EQ(test, ctx_val.bytes_moved, size); in ttm_bo_validate_move_fence_not_signaled()
751 KUNIT_EXPECT_EQ(test, bo->resource->mem_type, snd_mem); in ttm_bo_validate_move_fence_not_signaled()
753 KUNIT_EXPECT_EQ(test, bo->resource->mem_type, fst_mem); in ttm_bo_validate_move_fence_not_signaled()
760 static void ttm_bo_validate_swapout(struct kunit *test) in ttm_bo_validate_swapout() argument
765 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_swapout()
778 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_swapout()
779 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_swapout()
781 bo_small = kunit_kzalloc(test, sizeof(*bo_small), GFP_KERNEL); in ttm_bo_validate_swapout()
782 KUNIT_ASSERT_NOT_NULL(test, bo_small); in ttm_bo_validate_swapout()
789 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_swapout()
792 bo_big = ttm_bo_kunit_init(test, priv, size_big, NULL); in ttm_bo_validate_swapout()
798 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_swapout()
799 KUNIT_EXPECT_NOT_NULL(test, bo_big->resource); in ttm_bo_validate_swapout()
800 KUNIT_EXPECT_EQ(test, bo_big->resource->mem_type, mem_type); in ttm_bo_validate_swapout()
801 KUNIT_EXPECT_EQ(test, bo_small->resource->mem_type, TTM_PL_SYSTEM); in ttm_bo_validate_swapout()
802 KUNIT_EXPECT_TRUE(test, bo_small->ttm->page_flags & TTM_TT_FLAG_SWAPPED); in ttm_bo_validate_swapout()
810 static void ttm_bo_validate_happy_evict(struct kunit *test) in ttm_bo_validate_happy_evict() argument
819 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_happy_evict()
829 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_happy_evict()
830 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_happy_evict()
832 bos = kunit_kmalloc_array(test, bo_no, sizeof(*bos), GFP_KERNEL); in ttm_bo_validate_happy_evict()
833 KUNIT_ASSERT_NOT_NULL(test, bos); in ttm_bo_validate_happy_evict()
844 bo_val = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); in ttm_bo_validate_happy_evict()
851 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_happy_evict()
852 KUNIT_EXPECT_EQ(test, bos[0].resource->mem_type, mem_type_evict); in ttm_bo_validate_happy_evict()
853 KUNIT_EXPECT_TRUE(test, bos[0].ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC); in ttm_bo_validate_happy_evict()
854 KUNIT_EXPECT_TRUE(test, bos[0].ttm->page_flags & TTM_TT_FLAG_PRIV_POPULATED); in ttm_bo_validate_happy_evict()
855 KUNIT_EXPECT_EQ(test, ctx_val.bytes_moved, small * 2 + BO_SIZE); in ttm_bo_validate_happy_evict()
856 KUNIT_EXPECT_EQ(test, bos[1].resource->mem_type, mem_type); in ttm_bo_validate_happy_evict()
866 static void ttm_bo_validate_all_pinned_evict(struct kunit *test) in ttm_bo_validate_all_pinned_evict() argument
871 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_all_pinned_evict()
880 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_all_pinned_evict()
881 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_all_pinned_evict()
883 bo_big = kunit_kzalloc(test, sizeof(*bo_big), GFP_KERNEL); in ttm_bo_validate_all_pinned_evict()
884 KUNIT_ASSERT_NOT_NULL(test, bo_big); in ttm_bo_validate_all_pinned_evict()
890 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_all_pinned_evict()
895 bo_small = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); in ttm_bo_validate_all_pinned_evict()
902 KUNIT_EXPECT_EQ(test, err, -ENOMEM); in ttm_bo_validate_all_pinned_evict()
915 static void ttm_bo_validate_allowed_only_evict(struct kunit *test) in ttm_bo_validate_allowed_only_evict() argument
922 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_allowed_only_evict()
931 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_allowed_only_evict()
932 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_allowed_only_evict()
934 bo_pinned = kunit_kzalloc(test, sizeof(*bo_pinned), GFP_KERNEL); in ttm_bo_validate_allowed_only_evict()
935 KUNIT_ASSERT_NOT_NULL(test, bo_pinned); in ttm_bo_validate_allowed_only_evict()
941 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_allowed_only_evict()
945 bo_evictable = kunit_kzalloc(test, sizeof(*bo_evictable), GFP_KERNEL); in ttm_bo_validate_allowed_only_evict()
946 KUNIT_ASSERT_NOT_NULL(test, bo_evictable); in ttm_bo_validate_allowed_only_evict()
952 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_allowed_only_evict()
955 bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); in ttm_bo_validate_allowed_only_evict()
962 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_allowed_only_evict()
963 KUNIT_EXPECT_EQ(test, bo->resource->mem_type, mem_type); in ttm_bo_validate_allowed_only_evict()
964 KUNIT_EXPECT_EQ(test, bo_pinned->resource->mem_type, mem_type); in ttm_bo_validate_allowed_only_evict()
965 KUNIT_EXPECT_EQ(test, bo_evictable->resource->mem_type, mem_type_evict); in ttm_bo_validate_allowed_only_evict()
966 KUNIT_EXPECT_EQ(test, ctx_val.bytes_moved, size * 2 + BO_SIZE); in ttm_bo_validate_allowed_only_evict()
980 static void ttm_bo_validate_deleted_evict(struct kunit *test) in ttm_bo_validate_deleted_evict() argument
986 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_deleted_evict()
996 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_deleted_evict()
997 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_deleted_evict()
999 bo_big = kunit_kzalloc(test, sizeof(*bo_big), GFP_KERNEL); in ttm_bo_validate_deleted_evict()
1000 KUNIT_ASSERT_NOT_NULL(test, bo_big); in ttm_bo_validate_deleted_evict()
1006 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_deleted_evict()
1007 KUNIT_EXPECT_EQ(test, ttm_resource_manager_usage(man), big); in ttm_bo_validate_deleted_evict()
1012 bo_small = ttm_bo_kunit_init(test, test->priv, small, NULL); in ttm_bo_validate_deleted_evict()
1019 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_deleted_evict()
1020 KUNIT_EXPECT_EQ(test, bo_small->resource->mem_type, mem_type); in ttm_bo_validate_deleted_evict()
1021 KUNIT_EXPECT_EQ(test, ttm_resource_manager_usage(man), small); in ttm_bo_validate_deleted_evict()
1022 KUNIT_EXPECT_NULL(test, bo_big->ttm); in ttm_bo_validate_deleted_evict()
1023 KUNIT_EXPECT_NULL(test, bo_big->resource); in ttm_bo_validate_deleted_evict()
1030 static void ttm_bo_validate_busy_domain_evict(struct kunit *test) in ttm_bo_validate_busy_domain_evict() argument
1035 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_busy_domain_evict()
1047 err = ttm_device_kunit_init_bad_evict(test->priv, priv->ttm_dev, false, false); in ttm_bo_validate_busy_domain_evict()
1048 KUNIT_ASSERT_EQ(test, err, 0); in ttm_bo_validate_busy_domain_evict()
1053 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_busy_domain_evict()
1054 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_busy_domain_evict()
1056 bo_init = kunit_kzalloc(test, sizeof(*bo_init), GFP_KERNEL); in ttm_bo_validate_busy_domain_evict()
1057 KUNIT_ASSERT_NOT_NULL(test, bo_init); in ttm_bo_validate_busy_domain_evict()
1063 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_busy_domain_evict()
1066 bo_val = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); in ttm_bo_validate_busy_domain_evict()
1073 KUNIT_EXPECT_EQ(test, err, -ENOMEM); in ttm_bo_validate_busy_domain_evict()
1074 KUNIT_EXPECT_EQ(test, bo_init->resource->mem_type, mem_type); in ttm_bo_validate_busy_domain_evict()
1075 KUNIT_EXPECT_NULL(test, bo_val->resource); in ttm_bo_validate_busy_domain_evict()
1084 static void ttm_bo_validate_evict_gutting(struct kunit *test) in ttm_bo_validate_evict_gutting() argument
1088 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_evict_gutting()
1097 place = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_evict_gutting()
1098 placement = ttm_placement_kunit_init(test, place, 1); in ttm_bo_validate_evict_gutting()
1100 bo_evict = kunit_kzalloc(test, sizeof(*bo_evict), GFP_KERNEL); in ttm_bo_validate_evict_gutting()
1101 KUNIT_ASSERT_NOT_NULL(test, bo_evict); in ttm_bo_validate_evict_gutting()
1107 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_evict_gutting()
1110 bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); in ttm_bo_validate_evict_gutting()
1117 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_evict_gutting()
1118 KUNIT_EXPECT_EQ(test, bo->resource->mem_type, mem_type); in ttm_bo_validate_evict_gutting()
1119 KUNIT_ASSERT_NULL(test, bo_evict->resource); in ttm_bo_validate_evict_gutting()
1120 KUNIT_ASSERT_TRUE(test, bo_evict->ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC); in ttm_bo_validate_evict_gutting()
1128 static void ttm_bo_validate_recrusive_evict(struct kunit *test) in ttm_bo_validate_recrusive_evict() argument
1135 struct ttm_test_devices *priv = test->priv; in ttm_bo_validate_recrusive_evict()
1142 place_tt = ttm_place_kunit_init(test, mem_type, 0); in ttm_bo_validate_recrusive_evict()
1143 place_mock = ttm_place_kunit_init(test, mem_type_evict, 0); in ttm_bo_validate_recrusive_evict()
1145 placement_tt = ttm_placement_kunit_init(test, place_tt, 1); in ttm_bo_validate_recrusive_evict()
1146 placement_mock = ttm_placement_kunit_init(test, place_mock, 1); in ttm_bo_validate_recrusive_evict()
1148 bo_tt = kunit_kzalloc(test, sizeof(*bo_tt), GFP_KERNEL); in ttm_bo_validate_recrusive_evict()
1149 KUNIT_ASSERT_NOT_NULL(test, bo_tt); in ttm_bo_validate_recrusive_evict()
1151 bo_mock = kunit_kzalloc(test, sizeof(*bo_mock), GFP_KERNEL); in ttm_bo_validate_recrusive_evict()
1152 KUNIT_ASSERT_NOT_NULL(test, bo_mock); in ttm_bo_validate_recrusive_evict()
1158 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_recrusive_evict()
1165 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_recrusive_evict()
1168 bo_val = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); in ttm_bo_validate_recrusive_evict()
1175 KUNIT_EXPECT_EQ(test, err, 0); in ttm_bo_validate_recrusive_evict()