Lines Matching +full:kunit +full:- +full:base

1 // SPDX-License-Identifier: GPL-2.0 AND MIT
6 #include <kunit/test.h>
7 #include <kunit/visibility.h>
9 #include <linux/iosys-map.h>
26 struct kunit *test) in ccs_test_migrate()
46 fence = xe_migrate_clear(tile->migrate, bo, bo->ttm.resource, in ccs_test_migrate()
56 return -ETIME; in ccs_test_migrate()
70 timeout = dma_resv_wait_timeout(bo->ttm.base.resv, in ccs_test_migrate()
76 return -ETIME; in ccs_test_migrate()
84 ttm = bo->ttm.ttm; in ccs_test_migrate()
87 return -EINVAL; in ccs_test_migrate()
91 if (ccs_page >= ttm->num_pages) { in ccs_test_migrate()
93 return -EINVAL; in ccs_test_migrate()
96 page = ttm->pages[ccs_page]; in ccs_test_migrate()
105 ret = -EINVAL; in ccs_test_migrate()
110 offset = min_t(u32, offset, PAGE_SIZE) / sizeof(u64) - 1; in ccs_test_migrate()
116 ret = -EINVAL; in ccs_test_migrate()
127 struct kunit *test) in ccs_test_run_tile()
137 kunit_info(test, "Testing vram id %u\n", tile->id); in ccs_test_run_tile()
172 struct kunit *test = kunit_get_current_test(); in ccs_test_run_device()
177 kunit_skip(test, "non-flat-ccs device\n"); in ccs_test_run_device()
201 static void xe_ccs_migrate_kunit(struct kunit *test) in xe_ccs_migrate_kunit()
203 struct xe_device *xe = test->priv; in xe_ccs_migrate_kunit()
208 static int evict_test_run_tile(struct xe_device *xe, struct xe_tile *tile, struct kunit *test) in evict_test_run_tile()
212 struct xe_vm *vm = xe_migrate_get_vm(xe_device_get_root_tile(xe)->migrate); in evict_test_run_tile()
217 dev_name(xe->drm.dev), tile->id); in evict_test_run_tile()
262 * GT, which re-intializes such things. We could potentially in evict_test_run_tile()
284 err = -EPROTO; in evict_test_run_tile()
290 err = -EPROTO; in evict_test_run_tile()
295 down_read(&vm->lock); in evict_test_run_tile()
297 err = xe_bo_validate(bo, bo->vm, false); in evict_test_run_tile()
299 up_read(&vm->lock); in evict_test_run_tile()
348 struct kunit *test = kunit_get_current_test(); in evict_test_run_device()
353 kunit_skip(test, "non-discrete device\n"); in evict_test_run_device()
367 static void xe_bo_evict_kunit(struct kunit *test) in xe_bo_evict_kunit()
369 struct xe_device *xe = test->priv; in xe_bo_evict_kunit()
386 int ret = ttm_bo_vmap(&bo->ttm, &map); in shrink_test_fill_random()
392 for (i = 0; i < bo->ttm.base.size; i += sizeof(u32)) { in shrink_test_fill_random()
397 link->val = val; in shrink_test_fill_random()
400 ttm_bo_vunmap(&bo->ttm, &map); in shrink_test_fill_random()
404 static bool shrink_test_verify(struct kunit *test, struct xe_bo *bo, in shrink_test_verify()
409 int ret = ttm_bo_vmap(&bo->ttm, &map); in shrink_test_verify()
418 for (i = 0; i < bo->ttm.base.size; i += sizeof(u32)) { in shrink_test_verify()
426 if (i == 0 && val != link->val) in shrink_test_verify()
433 ttm_bo_vunmap(&bo->ttm, &map); in shrink_test_verify()
446 struct kunit *test = kunit_get_current_test(); in shrink_test_run_device()
478 purgeable = to_alloc - ram_and_swap; in shrink_test_run_device()
495 INIT_LIST_HEAD(&link->link); in shrink_test_run_device()
502 if (bo != ERR_PTR(-ENOMEM) && bo != ERR_PTR(-ENOSPC) && in shrink_test_run_device()
503 bo != ERR_PTR(-EINTR) && bo != ERR_PTR(-ERESTARTSYS)) in shrink_test_run_device()
510 xe_tt = container_of(bo->ttm.ttm, typeof(*xe_tt), ttm); in shrink_test_run_device()
517 xe_ttm_tt_account_subtract(xe, &xe_tt->ttm); in shrink_test_run_device()
518 xe_tt->purgeable = true; in shrink_test_run_device()
519 xe_ttm_tt_account_add(xe, &xe_tt->ttm); in shrink_test_run_device()
520 bo->ttm.priority = 0; in shrink_test_run_device()
521 spin_lock(&bo->ttm.bdev->lru_lock); in shrink_test_run_device()
522 ttm_bo_move_to_lru_tail(&bo->ttm); in shrink_test_run_device()
523 spin_unlock(&bo->ttm.bdev->lru_lock); in shrink_test_run_device()
538 mem_type = bo->ttm.resource->mem_type; in shrink_test_run_device()
540 link->bo = bo; in shrink_test_run_device()
541 list_add_tail(&link->link, &bos); in shrink_test_run_device()
545 bo->ttm.resource->mem_type); in shrink_test_run_device()
554 * Read back and destroy bos. Reset the pseudo-random seed to get an in shrink_test_run_device()
555 * identical pseudo-random number sequence for readback. in shrink_test_run_device()
560 struct xe_bo *bo = link->bo; in shrink_test_run_device()
570 /* xe_tt->purgeable is cleared on validate. */ in shrink_test_run_device()
571 xe_tt = container_of(bo->ttm.ttm, typeof(*xe_tt), ttm); in shrink_test_run_device()
572 purgeable = xe_tt->purgeable; in shrink_test_run_device()
574 ret = ttm_bo_validate(&bo->ttm, &tt_placement, &ctx); in shrink_test_run_device()
575 if (ret == -EINTR) in shrink_test_run_device()
577 } while (ret == -EINTR && !signal_pending(current)); in shrink_test_run_device()
592 xe_bo_put(link->bo); in shrink_test_run_device()
593 list_del(&link->link); in shrink_test_run_device()
602 static void xe_bo_shrink_kunit(struct kunit *test) in xe_bo_shrink_kunit()
604 struct xe_device *xe = test->priv; in xe_bo_shrink_kunit()