Hi Christian and Amaranath,
On 12.06.2024 14:02, Karolina Stolarek wrote:
Introduce tests for ttm_bo_validate()/ttm_bo_init_validate() that exercise
simple BO placement as well as eviction (including the case where the evict
domain also requires eviction to fit the incoming buffer). Prepare KUnit
helpers to handle such scenarios and add a mock VRAM manager. This series also
includes some updates to the helpers and more definitions used to define
"special" memory domains (e.g., one that can't allocate resources or is busy),
as well as drive-by fixes for the tests.
There are a couple of areas in which this test suite can be improved.
Suggestions for future work can be found in the TODO file.
Use kunit_tool script to manually run all the tests:
$ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/ttm/tests
I collected r-bs for all patches in the series, they apply cleanly on
the top of drm-misc and drm-tip and all the tests pass[1]. Would it be
possible to merge them?
In other news, we enabled TTM KUnit tests in CI for Xe driver, the
results can be seen on patchwork. For example:
https://patchwork.freedesktop.org/series/134956/
(see CI.KUnit step)
All the best,
Karolina
--------------------------------------------------------------
[1]:
$ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/ttm/tests
[10:49:50] Configuring KUnit Kernel ...
[10:49:50] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=8
[10:49:53] Starting KUnit Kernel (1/1)...
[10:49:53] ============================================================
Running tests with:
$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt
[10:49:53] ================= ttm_device (5 subtests) ==================
[10:49:53] [PASSED] ttm_device_init_basic
[10:49:53] [PASSED] ttm_device_init_multiple
[10:49:53] [PASSED] ttm_device_fini_basic
[10:49:53] [PASSED] ttm_device_init_no_vma_man
[10:49:53] ================== ttm_device_init_pools ==================
[10:49:53] [PASSED] No DMA allocations, no DMA32 required
[10:49:53] [PASSED] DMA allocations, DMA32 required
[10:49:53] [PASSED] No DMA allocations, DMA32 required
[10:49:53] [PASSED] DMA allocations, no DMA32 required
[10:49:53] ============== [PASSED] ttm_device_init_pools ==============
[10:49:53] =================== [PASSED] ttm_device ====================
[10:49:53] ================== ttm_pool (8 subtests) ===================
[10:49:53] ================== ttm_pool_alloc_basic ===================
[10:49:53] [PASSED] One page
[10:49:53] [PASSED] More than one page
[10:49:53] [PASSED] Above the allocation limit
[10:49:53] [PASSED] One page, with coherent DMA mappings enabled
[10:49:53] [PASSED] Above the allocation limit, with coherent DMA
mappings enabled
[10:49:53] ============== [PASSED] ttm_pool_alloc_basic ===============
[10:49:53] ============== ttm_pool_alloc_basic_dma_addr ==============
[10:49:53] [PASSED] One page
[10:49:53] [PASSED] More than one page
[10:49:53] [PASSED] Above the allocation limit
[10:49:53] [PASSED] One page, with coherent DMA mappings enabled
[10:49:53] [PASSED] Above the allocation limit, with coherent DMA
mappings enabled
[10:49:53] ========== [PASSED] ttm_pool_alloc_basic_dma_addr ==========
[10:49:53] [PASSED] ttm_pool_alloc_order_caching_match
[10:49:53] [PASSED] ttm_pool_alloc_caching_mismatch
[10:49:53] [PASSED] ttm_pool_alloc_order_mismatch
[10:49:53] [PASSED] ttm_pool_free_dma_alloc
[10:49:53] [PASSED] ttm_pool_free_no_dma_alloc
[10:49:53] [PASSED] ttm_pool_fini_basic
[10:49:53] ==================== [PASSED] ttm_pool =====================
[10:49:53] ================ ttm_resource (8 subtests) =================
[10:49:53] ================= ttm_resource_init_basic =================
[10:49:53] [PASSED] Init resource in TTM_PL_SYSTEM
[10:49:53] [PASSED] Init resource in TTM_PL_VRAM
[10:49:53] [PASSED] Init resource in a private placement
[10:49:53] [PASSED] Init resource in TTM_PL_SYSTEM, set placement flags
[10:49:53] ============= [PASSED] ttm_resource_init_basic =============
[10:49:53] [PASSED] ttm_resource_init_pinned
[10:49:53] [PASSED] ttm_resource_fini_basic
[10:49:53] [PASSED] ttm_resource_manager_init_basic
[10:49:53] [PASSED] ttm_resource_manager_usage_basic
[10:49:53] [PASSED] ttm_resource_manager_set_used_basic
[10:49:53] [PASSED] ttm_sys_man_alloc_basic
[10:49:53] [PASSED] ttm_sys_man_free_basic
[10:49:53] ================== [PASSED] ttm_resource ===================
[10:49:53] =================== ttm_tt (15 subtests) ===================
[10:49:53] ==================== ttm_tt_init_basic ====================
[10:49:53] [PASSED] Page-aligned size
[10:49:53] [PASSED] Extra pages requested
[10:49:53] ================ [PASSED] ttm_tt_init_basic ================
[10:49:53] [PASSED] ttm_tt_init_misaligned
[10:49:53] [PASSED] ttm_tt_fini_basic
[10:49:53] [PASSED] ttm_tt_fini_sg
[10:49:53] [PASSED] ttm_tt_fini_shmem
[10:49:53] [PASSED] ttm_tt_create_basic
[10:49:53] [PASSED] ttm_tt_create_invalid_bo_type
[10:49:53] [PASSED] ttm_tt_create_ttm_exists
[10:49:53] [PASSED] ttm_tt_create_failed
[10:49:53] [PASSED] ttm_tt_destroy_basic
[10:49:53] [PASSED] ttm_tt_populate_null_ttm
[10:49:53] [PASSED] ttm_tt_populate_populated_ttm
[10:49:53] [PASSED] ttm_tt_unpopulate_basic
[10:49:53] [PASSED] ttm_tt_unpopulate_empty_ttm
[10:49:53] [PASSED] ttm_tt_swapin_basic
[10:49:53] ===================== [PASSED] ttm_tt ======================
[10:49:53] =================== ttm_bo (14 subtests) ===================
[10:49:53] =========== ttm_bo_reserve_optimistic_no_ticket ===========
[10:49:53] [PASSED] Cannot be interrupted and sleeps
[10:49:53] [PASSED] Cannot be interrupted, locks straight away
[10:49:53] [PASSED] Can be interrupted, sleeps
[10:49:53] ======= [PASSED] ttm_bo_reserve_optimistic_no_ticket =======
[10:49:53] [PASSED] ttm_bo_reserve_locked_no_sleep
[10:49:53] [PASSED] ttm_bo_reserve_no_wait_ticket
[10:49:53] [PASSED] ttm_bo_reserve_double_resv
[10:49:53] [PASSED] ttm_bo_reserve_interrupted
[10:49:53] [PASSED] ttm_bo_reserve_deadlock
[10:49:53] [PASSED] ttm_bo_unreserve_basic
[10:49:53] [PASSED] ttm_bo_unreserve_pinned
[10:49:53] [PASSED] ttm_bo_unreserve_bulk
[10:49:53] [PASSED] ttm_bo_put_basic
[10:49:53] [PASSED] ttm_bo_put_shared_resv
[10:49:53] [PASSED] ttm_bo_pin_basic
[10:49:53] [PASSED] ttm_bo_pin_unpin_resource
[10:49:53] [PASSED] ttm_bo_multiple_pin_one_unpin
[10:49:53] ===================== [PASSED] ttm_bo ======================
[10:49:53] ============== ttm_bo_validate (22 subtests) ===============
[10:49:53] ============== ttm_bo_init_reserved_sys_man ===============
[10:49:53] [PASSED] Buffer object for userspace
[10:49:53] [PASSED] Kernel buffer object
[10:49:53] [PASSED] Shared buffer object
[10:49:53] ========== [PASSED] ttm_bo_init_reserved_sys_man ===========
[10:49:53] ============== ttm_bo_init_reserved_mock_man ==============
[10:49:53] [PASSED] Buffer object for userspace
[10:49:53] [PASSED] Kernel buffer object
[10:49:53] [PASSED] Shared buffer object
[10:49:53] ========== [PASSED] ttm_bo_init_reserved_mock_man ==========
[10:49:53] [PASSED] ttm_bo_init_reserved_resv
[10:49:53] ================== ttm_bo_validate_basic ==================
[10:49:53] [PASSED] Buffer object for userspace
[10:49:53] [PASSED] Kernel buffer object
[10:49:53] [PASSED] Shared buffer object
[10:49:53] ============== [PASSED] ttm_bo_validate_basic ==============
[10:49:53] [PASSED] ttm_bo_validate_invalid_placement
[10:49:53] ============= ttm_bo_validate_same_placement ==============
[10:49:53] [PASSED] System manager
[10:49:53] [PASSED] VRAM manager
[10:49:53] ========= [PASSED] ttm_bo_validate_same_placement ==========
[10:49:53] [PASSED] ttm_bo_validate_failed_alloc
[10:49:53] [PASSED] ttm_bo_validate_pinned
[10:49:53] [PASSED] ttm_bo_validate_busy_placement
[10:49:53] ================ ttm_bo_validate_multihop =================
[10:49:53] [PASSED] Buffer object for userspace
[10:49:53] [PASSED] Kernel buffer object
[10:49:53] [PASSED] Shared buffer object
[10:49:53] ============ [PASSED] ttm_bo_validate_multihop =============
[10:49:53] ========== ttm_bo_validate_no_placement_signaled ==========
[10:49:53] [PASSED] Buffer object in system domain, no page vector
[10:49:53] [PASSED] Buffer object in system domain with an existing page
vector
[10:49:53] ====== [PASSED] ttm_bo_validate_no_placement_signaled ======
[10:49:53] ======== ttm_bo_validate_no_placement_not_signaled ========
[10:49:53] [PASSED] Buffer object for userspace
[10:49:53] [PASSED] Kernel buffer object
[10:49:53] [PASSED] Shared buffer object
[10:49:53] ==== [PASSED] ttm_bo_validate_no_placement_not_signaled ====
[10:49:53] [PASSED] ttm_bo_validate_move_fence_signaled
[10:49:53] ========= ttm_bo_validate_move_fence_not_signaled =========
[10:49:53] [PASSED] Waits for GPU
[10:49:53] [PASSED] Tries to lock straight away
[10:49:53] ===== [PASSED] ttm_bo_validate_move_fence_not_signaled =====
[10:49:53] [PASSED] ttm_bo_validate_swapout
[10:49:53] [PASSED] ttm_bo_validate_happy_evict
[10:49:53] [PASSED] ttm_bo_validate_all_pinned_evict
[10:49:53] [PASSED] ttm_bo_validate_allowed_only_evict
[10:49:53] [PASSED] ttm_bo_validate_deleted_evict
[10:49:53] [PASSED] ttm_bo_validate_busy_domain_evict
[10:49:53] [PASSED] ttm_bo_validate_evict_gutting
[10:49:53] [PASSED] ttm_bo_validate_recrusive_evict
[10:49:53] ================= [PASSED] ttm_bo_validate =================
[10:49:53] ============================================================
[10:49:53] Testing complete. Ran 102 tests: passed: 102
[10:49:53] Elapsed time: 3.305s total, 0.002s configuring, 2.635s
building, 0.572s running