Test looks good.
Regards,
S.Amarnath
amar@amar-Artic:~/amar/drm_misc/drm-misc1$
./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/ttm/tests
[08:20:02] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[08:20:03] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=16
[08:20:11] Starting KUnit Kernel (1/1)...
[08:20:11] ============================================================
Running tests with:
$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt
[08:20:11] ================= ttm_device (5 subtests) ==================
[08:20:11] [PASSED] ttm_device_init_basic
[08:20:11] [PASSED] ttm_device_init_multiple
[08:20:11] [PASSED] ttm_device_fini_basic
[08:20:11] [PASSED] ttm_device_init_no_vma_man
[08:20:11] ================== ttm_device_init_pools ==================
[08:20:11] [PASSED] No DMA allocations, no DMA32 required
[08:20:11] [PASSED] DMA allocations, DMA32 required
[08:20:11] [PASSED] No DMA allocations, DMA32 required
[08:20:11] [PASSED] DMA allocations, no DMA32 required
[08:20:11] ============== [PASSED] ttm_device_init_pools ==============
[08:20:11] =================== [PASSED] ttm_device ====================
[08:20:11] ================== ttm_pool (8 subtests) ===================
[08:20:11] ================== ttm_pool_alloc_basic ===================
[08:20:11] [PASSED] One page
[08:20:11] [PASSED] More than one page
[08:20:11] [PASSED] Above the allocation limit
[08:20:11] [PASSED] One page, with coherent DMA mappings enabled
[08:20:11] [PASSED] Above the allocation limit, with coherent DMA
mappings enabled
[08:20:11] ============== [PASSED] ttm_pool_alloc_basic ===============
[08:20:11] ============== ttm_pool_alloc_basic_dma_addr ==============
[08:20:11] [PASSED] One page
[08:20:11] [PASSED] More than one page
[08:20:11] [PASSED] Above the allocation limit
[08:20:11] [PASSED] One page, with coherent DMA mappings enabled
[08:20:11] [PASSED] Above the allocation limit, with coherent DMA
mappings enabled
[08:20:11] ========== [PASSED] ttm_pool_alloc_basic_dma_addr ==========
[08:20:11] [PASSED] ttm_pool_alloc_order_caching_match
[08:20:11] [PASSED] ttm_pool_alloc_caching_mismatch
[08:20:11] [PASSED] ttm_pool_alloc_order_mismatch
[08:20:11] [PASSED] ttm_pool_free_dma_alloc
[08:20:11] [PASSED] ttm_pool_free_no_dma_alloc
[08:20:11] [PASSED] ttm_pool_fini_basic
[08:20:11] ==================== [PASSED] ttm_pool =====================
[08:20:11] ================ ttm_resource (8 subtests) =================
[08:20:11] ================= ttm_resource_init_basic =================
[08:20:11] [PASSED] Init resource in TTM_PL_SYSTEM
[08:20:11] [PASSED] Init resource in TTM_PL_VRAM
[08:20:11] [PASSED] Init resource in a private placement
[08:20:11] [PASSED] Init resource in TTM_PL_SYSTEM, set placement flags
[08:20:11] ============= [PASSED] ttm_resource_init_basic =============
[08:20:11] [PASSED] ttm_resource_init_pinned
[08:20:11] [PASSED] ttm_resource_fini_basic
[08:20:11] [PASSED] ttm_resource_manager_init_basic
[08:20:11] [PASSED] ttm_resource_manager_usage_basic
[08:20:11] [PASSED] ttm_resource_manager_set_used_basic
[08:20:11] [PASSED] ttm_sys_man_alloc_basic
[08:20:11] [PASSED] ttm_sys_man_free_basic
[08:20:11] ================== [PASSED] ttm_resource ===================
[08:20:11] =================== ttm_tt (15 subtests) ===================
[08:20:11] ==================== ttm_tt_init_basic ====================
[08:20:11] [PASSED] Page-aligned size
[08:20:11] [PASSED] Extra pages requested
[08:20:11] ================ [PASSED] ttm_tt_init_basic ================
[08:20:11] [PASSED] ttm_tt_init_misaligned
[08:20:11] [PASSED] ttm_tt_fini_basic
[08:20:11] [PASSED] ttm_tt_fini_sg
[08:20:11] [PASSED] ttm_tt_fini_shmem
[08:20:11] [PASSED] ttm_tt_create_basic
[08:20:11] [PASSED] ttm_tt_create_invalid_bo_type
[08:20:11] [PASSED] ttm_tt_create_ttm_exists
[08:20:11] [PASSED] ttm_tt_create_failed
[08:20:11] [PASSED] ttm_tt_destroy_basic
[08:20:11] [PASSED] ttm_tt_populate_null_ttm
[08:20:11] [PASSED] ttm_tt_populate_populated_ttm
[08:20:11] [PASSED] ttm_tt_unpopulate_basic
[08:20:11] [PASSED] ttm_tt_unpopulate_empty_ttm
[08:20:11] [PASSED] ttm_tt_swapin_basic
[08:20:11] ===================== [PASSED] ttm_tt ======================
[08:20:11] =================== ttm_bo (14 subtests) ===================
[08:20:11] =========== ttm_bo_reserve_optimistic_no_ticket ===========
[08:20:11] [PASSED] Cannot be interrupted and sleeps
[08:20:11] [PASSED] Cannot be interrupted, locks straight away
[08:20:11] [PASSED] Can be interrupted, sleeps
[08:20:11] ======= [PASSED] ttm_bo_reserve_optimistic_no_ticket =======
[08:20:11] [PASSED] ttm_bo_reserve_locked_no_sleep
[08:20:11] [PASSED] ttm_bo_reserve_no_wait_ticket
[08:20:11] [PASSED] ttm_bo_reserve_double_resv
[08:20:11] [PASSED] ttm_bo_reserve_interrupted
[08:20:11] [PASSED] ttm_bo_reserve_deadlock
[08:20:11] [PASSED] ttm_bo_unreserve_basic
[08:20:11] [PASSED] ttm_bo_unreserve_pinned
[08:20:11] [PASSED] ttm_bo_unreserve_bulk
[08:20:11] [PASSED] ttm_bo_put_basic
[08:20:11] [PASSED] ttm_bo_put_shared_resv
[08:20:11] [PASSED] ttm_bo_pin_basic
[08:20:11] [PASSED] ttm_bo_pin_unpin_resource
[08:20:11] [PASSED] ttm_bo_multiple_pin_one_unpin
[08:20:11] ===================== [PASSED] ttm_bo ======================
[08:20:11] ============== ttm_bo_validate (22 subtests) ===============
[08:20:11] ============== ttm_bo_init_reserved_sys_man ===============
[08:20:11] [PASSED] Buffer object for userspace
[08:20:11] [PASSED] Kernel buffer object
[08:20:11] [PASSED] Shared buffer object
[08:20:11] ========== [PASSED] ttm_bo_init_reserved_sys_man ===========
[08:20:11] ============== ttm_bo_init_reserved_mock_man ==============
[08:20:11] [PASSED] Buffer object for userspace
[08:20:11] [PASSED] Kernel buffer object
[08:20:11] [PASSED] Shared buffer object
[08:20:11] ========== [PASSED] ttm_bo_init_reserved_mock_man ==========
[08:20:11] [PASSED] ttm_bo_init_reserved_resv
[08:20:11] ================== ttm_bo_validate_basic ==================
[08:20:11] [PASSED] Buffer object for userspace
[08:20:11] [PASSED] Kernel buffer object
[08:20:11] [PASSED] Shared buffer object
[08:20:11] ============== [PASSED] ttm_bo_validate_basic ==============
[08:20:11] [PASSED] ttm_bo_validate_invalid_placement
[08:20:11] ============= ttm_bo_validate_same_placement ==============
[08:20:11] [PASSED] System manager
[08:20:11] [PASSED] VRAM manager
[08:20:11] ========= [PASSED] ttm_bo_validate_same_placement ==========
[08:20:11] [PASSED] ttm_bo_validate_failed_alloc
[08:20:11] [PASSED] ttm_bo_validate_pinned
[08:20:11] [PASSED] ttm_bo_validate_busy_placement
[08:20:11] ================ ttm_bo_validate_multihop =================
[08:20:11] [PASSED] Buffer object for userspace
[08:20:11] [PASSED] Kernel buffer object
[08:20:11] [PASSED] Shared buffer object
[08:20:11] ============ [PASSED] ttm_bo_validate_multihop =============
[08:20:11] ========== ttm_bo_validate_no_placement_signaled ==========
[08:20:11] [PASSED] Buffer object in system domain, no page vector
[08:20:11] [PASSED] Buffer object in system domain with an existing page
vector
[08:20:11] ====== [PASSED] ttm_bo_validate_no_placement_signaled ======
[08:20:11] ======== ttm_bo_validate_no_placement_not_signaled ========
[08:20:11] [PASSED] Buffer object for userspace
[08:20:11] [PASSED] Kernel buffer object
[08:20:11] [PASSED] Shared buffer object
[08:20:11] ==== [PASSED] ttm_bo_validate_no_placement_not_signaled ====
[08:20:11] [PASSED] ttm_bo_validate_move_fence_signaled
[08:20:11] ========= ttm_bo_validate_move_fence_not_signaled =========
[08:20:11] [PASSED] Waits for GPU
[08:20:11] [PASSED] Tries to lock straight away
[08:20:11] ===== [PASSED] ttm_bo_validate_move_fence_not_signaled =====
[08:20:11] [PASSED] ttm_bo_validate_swapout
[08:20:11] [PASSED] ttm_bo_validate_happy_evict
[08:20:11] [PASSED] ttm_bo_validate_all_pinned_evict
[08:20:11] [PASSED] ttm_bo_validate_allowed_only_evict
[08:20:11] [PASSED] ttm_bo_validate_deleted_evict
[08:20:11] [PASSED] ttm_bo_validate_busy_domain_evict
[08:20:11] [PASSED] ttm_bo_validate_evict_gutting
[08:20:11] [PASSED] ttm_bo_validate_recrusive_evict
[08:20:11] ================= [PASSED] ttm_bo_validate =================
[08:20:11] ============================================================
[08:20:11] Testing complete. Ran 102 tests: passed: 102
[08:20:11] Elapsed time: 9.732s total, 0.927s configuring, 8.085s
building, 0.559s running
On 5/15/2024 4:54 PM, 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
To build a kernel with TTM KUnit tests, use a UML configuration,
enable CONFIG_KUNIT, and then select CONFIG_DRM_TTM_KUNIT_TEST.
Many thanks,
Karolina
v12:
- Rewrite "drm/ttm/tests: Fix a warning in ttm_bo_unreserve_bulk" patch to
extend ttm_bo_kunit_init() helper to accept a dma_resv object and update
calls to that helper (Christian)
- Update drm_buddy_free_list() calls with an extra argument
v11:
- Delete CONFIG_DRM_KUNIT_TEST_HELPERS from .kunitconfig file, as it gets
automatically selected when TTM KUnit tests are enabled
- Call ttm_bo_put() in ttm_bo_validate_pinned() test case (Matt)
- Fix a copy-paste mistake in ttm_mem_type_cases definition (Matt)
- Update mock_move definition to do a hop on VRAM -> sysmem move and
delete a dummy multihop domain. Fix the eviction tests accordingly (Matt)
- Update ttm_bo_validate_swapout() to use TT domain instead of VRAM
- Update eviction test cases to create TT domain, so they can perform multihop
- Update TODO file, as it got outdated already
v10:
Many things have happened over the course of three months, so the series
had to be slightly reworked and expanded to accommodate these changes:
- Set DMA coherent mapping mask in the KUnit device so ttm_pool_alloc
tests can be executed
- Update ttm_bo_validate_invalid_placement() test case to check against
the right return error. It's no longer -EINVAL (which only is returned
for pinned buffers), but -ENOMEM. The behaviour has changed in
commit cc941c70df39 ("drm/ttm: improve idle/busy handling v5")
- Rework ttm_placement_kunit_init() to accept only one array of places
and update the tests that use that helper
- Set fallback flags in eviction domains defined in TTM KUnit helpers
- Fix a warning raised by ttm_bo_unreserve_bulk() test case
- Scrap all r-bs and tested-by, as many things were updated and should
be checked again
Karolina Stolarek (10):
drm/ttm/tests: Fix a warning in ttm_bo_unreserve_bulk
drm/ttm/tests: Delete unnecessary config option
drm/ttm/tests: Set DMA mask in KUnit device
drm/ttm/tests: Use an init function from the helpers lib
drm/ttm/tests: Test simple BO creation and validation
drm/ttm/tests: Add tests with mock resource managers
drm/ttm/tests: Add test cases dependent on fence signaling
drm/ttm/tests: Add eviction testing
drm/ttm/tests: Add tests for ttm_tt_populate
drm/ttm/tests: Add TODO file
drivers/gpu/drm/Kconfig | 1 +
drivers/gpu/drm/ttm/tests/.kunitconfig | 2 +-
drivers/gpu/drm/ttm/tests/Makefile | 2 +
drivers/gpu/drm/ttm/tests/TODO | 25 +
drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 40 +-
.../gpu/drm/ttm/tests/ttm_bo_validate_test.c | 1225 +++++++++++++++++
drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c | 178 ++-
drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h | 13 +-
drivers/gpu/drm/ttm/tests/ttm_mock_manager.c | 235 ++++
drivers/gpu/drm/ttm/tests/ttm_mock_manager.h | 33 +
drivers/gpu/drm/ttm/tests/ttm_pool_test.c | 4 +-
drivers/gpu/drm/ttm/tests/ttm_resource_test.c | 2 +-
drivers/gpu/drm/ttm/tests/ttm_tt_test.c | 154 ++-
drivers/gpu/drm/ttm/ttm_tt.c | 3 +
14 files changed, 1862 insertions(+), 55 deletions(-)
create mode 100644 drivers/gpu/drm/ttm/tests/TODO
create mode 100644 drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
create mode 100644 drivers/gpu/drm/ttm/tests/ttm_mock_manager.c
create mode 100644 drivers/gpu/drm/ttm/tests/ttm_mock_manager.h