[PATCH v7 0/8] Improve test coverage of TTM

Somalapuram, Amaranath asomalap at amd.com
Sat Nov 18 13:32:35 UTC 2023


On 11/17/2023 7:01 PM, Christian König wrote:
> No idea how you managed to do this, but now Amar is CCed on the 
> patches he already tested and *not* CCed on the new ones and the cover 
> letter :)
>
> @Amar can you pick up the latest patches from the mailing list and 
> give them another round of testing?
>
Looks good.

rtg at rtg-Artic:~/amar/git/drm-misc1$ ./tools/testing/kunit/kunit.py run 
--kunitconfig=drivers/gpu/drm/ttm/tests

[18:57:39] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[18:57:44] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=16
[18:58:41] Starting KUnit Kernel (1/1)...
[18:58:41] ============================================================
[18:58:41] ======================= ttm_device ========================
[18:58:41] [PASSED] ttm_device_init_basic
[18:58:41] [PASSED] ttm_device_init_multiple
[18:58:41] [PASSED] ttm_device_fini_basic
[18:58:41] [PASSED] ttm_device_init_no_vma_man
[18:58:41] ================== ttm_device_init_pools ==================
[18:58:41] [PASSED] No DMA allocations, no DMA32 required
[18:58:41] [PASSED] DMA allocations, DMA32 required
[18:58:41] [PASSED] No DMA allocations, DMA32 required
[18:58:41] [PASSED] DMA allocations, no DMA32 required
[18:58:41] ============== [PASSED] ttm_device_init_pools ==============
[18:58:41] =================== [PASSED] ttm_device ====================
[18:58:41] ======================== ttm_pool =========================
[18:58:41] ================== ttm_pool_alloc_basic ===================
[18:58:41] [PASSED] One page
[18:58:41] [PASSED] More than one page
[18:58:41] [PASSED] Above the allocation limit
[18:58:41] [PASSED] One page, with coherent DMA mappings enabled
[18:58:41] [PASSED] Above the allocation limit, with coherent DMA 
mappings enabled
[18:58:41] ============== [PASSED] ttm_pool_alloc_basic ===============
[18:58:41] ============== ttm_pool_alloc_basic_dma_addr ==============
[18:58:41] [PASSED] One page
[18:58:41] [PASSED] More than one page
[18:58:41] [PASSED] Above the allocation limit
[18:58:41] [PASSED] One page, with coherent DMA mappings enabled
[18:58:41] [PASSED] Above the allocation limit, with coherent DMA 
mappings enabled
[18:58:41] ========== [PASSED] ttm_pool_alloc_basic_dma_addr ==========
[18:58:41] [PASSED] ttm_pool_alloc_order_caching_match
[18:58:41] [PASSED] ttm_pool_alloc_caching_mismatch
[18:58:41] [PASSED] ttm_pool_alloc_order_mismatch
[18:58:41] [PASSED] ttm_pool_free_dma_alloc
[18:58:41] [PASSED] ttm_pool_free_no_dma_alloc
[18:58:41] [PASSED] ttm_pool_fini_basic
[18:58:41] ==================== [PASSED] ttm_pool =====================
[18:58:41] ====================== ttm_resource =======================
[18:58:41] ================= ttm_resource_init_basic =================
[18:58:41] [PASSED] Init resource in TTM_PL_SYSTEM
[18:58:41] [PASSED] Init resource in TTM_PL_VRAM
[18:58:41] [PASSED] Init resource in a private placement
[18:58:41] [PASSED] Init resource in TTM_PL_SYSTEM, set placement flags
[18:58:41] ============= [PASSED] ttm_resource_init_basic =============
[18:58:41] [PASSED] ttm_resource_init_pinned
[18:58:41] [PASSED] ttm_resource_fini_basic
[18:58:41] [PASSED] ttm_resource_manager_init_basic
[18:58:41] [PASSED] ttm_resource_manager_usage_basic
[18:58:41] [PASSED] ttm_resource_manager_set_used_basic
[18:58:41] [PASSED] ttm_sys_man_alloc_basic
[18:58:41] [PASSED] ttm_sys_man_free_basic
[18:58:41] ================== [PASSED] ttm_resource ===================
[18:58:41] ========================= ttm_tt ==========================
[18:58:41] ==================== ttm_tt_init_basic ====================
[18:58:41] [PASSED] Page-aligned size
[18:58:41] [PASSED] Extra pages requested
[18:58:41] ================ [PASSED] ttm_tt_init_basic ================
[18:58:41] [PASSED] ttm_tt_init_misaligned
[18:58:41] [PASSED] ttm_tt_fini_basic
[18:58:41] [PASSED] ttm_tt_fini_sg
[18:58:41] [PASSED] ttm_tt_fini_shmem
[18:58:41] [PASSED] ttm_tt_create_basic
[18:58:41] [PASSED] ttm_tt_create_invalid_bo_type
[18:58:41] [PASSED] ttm_tt_create_ttm_exists
[18:58:41] [PASSED] ttm_tt_create_failed
[18:58:41] [PASSED] ttm_tt_destroy_basic
[18:58:41] ===================== [PASSED] ttm_tt ======================
[18:58:41] ========================= ttm_bo ==========================
[18:58:41] =========== ttm_bo_reserve_optimistic_no_ticket ===========
[18:58:41] [PASSED] Cannot be interrupted and sleeps
[18:58:41] [PASSED] Cannot be interrupted, locks straight away
[18:58:41] [PASSED] Can be interrupted, sleeps
[18:58:41] ======= [PASSED] ttm_bo_reserve_optimistic_no_ticket =======
[18:58:41] [PASSED] ttm_bo_reserve_locked_no_sleep
[18:58:41] [PASSED] ttm_bo_reserve_no_wait_ticket
[18:58:41] [PASSED] ttm_bo_reserve_double_resv
[18:58:41] [PASSED] ttm_bo_reserve_interrupted
[18:58:41] [PASSED] ttm_bo_reserve_deadlock
[18:58:41] [PASSED] ttm_bo_unreserve_basic
[18:58:41] [PASSED] ttm_bo_unreserve_pinned
[18:58:41] [PASSED] ttm_bo_unreserve_bulk
[18:58:41] [PASSED] ttm_bo_put_basic
[18:58:41] [PASSED] ttm_bo_put_shared_resv
[18:58:41] [PASSED] ttm_bo_pin_basic
[18:58:41] [PASSED] ttm_bo_pin_unpin_resource
[18:58:41] [PASSED] ttm_bo_multiple_pin_one_unpin
[18:58:41] ===================== [PASSED] ttm_bo ======================
[18:58:41] ===================== ttm_bo_validate =====================
[18:58:41] ============== ttm_bo_init_reserved_sys_man ===============
[18:58:41] [PASSED] Buffer object for userspace
[18:58:41] [PASSED] Kernel buffer object
[18:58:41] [PASSED] Shared buffer object
[18:58:41] ========== [PASSED] ttm_bo_init_reserved_sys_man ===========
[18:58:41] ============== ttm_bo_init_reserved_mock_man ==============
[18:58:41] [PASSED] Buffer object for userspace
[18:58:41] [PASSED] Kernel buffer object
[18:58:41] [PASSED] Shared buffer object
[18:58:41] ========== [PASSED] ttm_bo_init_reserved_mock_man ==========
[18:58:41] [PASSED] ttm_bo_init_reserved_resv
[18:58:41] ================== ttm_bo_validate_basic ==================
[18:58:41] [PASSED] Buffer object for userspace
[18:58:41] [PASSED] Kernel buffer object
[18:58:41] [PASSED] Shared buffer object
[18:58:41] ============== [PASSED] ttm_bo_validate_basic ==============
[18:58:41] [PASSED] ttm_bo_validate_invalid_placement
[18:58:41] ============= ttm_bo_validate_same_placement ==============
[18:58:41] [PASSED] System manager
[18:58:41] [PASSED] VRAM manager
[18:58:41] ========= [PASSED] ttm_bo_validate_same_placement ==========
[18:58:41] [PASSED] ttm_bo_validate_failed_alloc
[18:58:41] [PASSED] ttm_bo_validate_pinned
[18:58:41] [PASSED] ttm_bo_validate_busy_placement
[18:58:41] ================ ttm_bo_validate_multihop =================
[18:58:41] [PASSED] Buffer object for userspace
[18:58:41] [PASSED] Kernel buffer object
[18:58:41] [PASSED] Shared buffer object
[18:58:41] ============ [PASSED] ttm_bo_validate_multihop =============
[18:58:41] ========== ttm_bo_validate_no_placement_signaled ==========
[18:58:41] [PASSED] Buffer object in system domain, no page vector
[18:58:41] [PASSED] Buffer object in system domain with an existing page 
vector
[18:58:41] ====== [PASSED] ttm_bo_validate_no_placement_signaled ======
[18:58:41] ======== ttm_bo_validate_no_placement_not_signaled ========
[18:58:41] [PASSED] Buffer object for userspace
[18:58:41] [PASSED] Kernel buffer object
[18:58:41] [PASSED] Shared buffer object
[18:58:41] ==== [PASSED] ttm_bo_validate_no_placement_not_signaled ====
[18:58:41] [PASSED] ttm_bo_validate_move_fence_signaled
[18:58:41] ========= ttm_bo_validate_move_fence_not_signaled =========
[18:58:41] [PASSED] Waits for GPU
[18:58:41] [PASSED] Tries to lock straight away
[18:58:41] ===== [PASSED] ttm_bo_validate_move_fence_not_signaled =====
[18:58:41] ================= [PASSED] ttm_bo_validate =================
[18:58:41] ============================================================
[18:58:41] Testing complete. Ran 89 tests: passed: 89
[18:58:41] Elapsed time: 62.274s total, 5.111s configuring, 56.844s 
building, 0.282s running

> I will try to find time to give that some review.
>
> Thanks,
> Christian.
>
> Am 17.11.23 um 09:49 schrieb Karolina Stolarek:
>> Add tests for building blocks of the TTM subsystem, such as 
>> ttm_resource,
>> ttm_resource_manager, ttm_tt and ttm_buffer_object. This series covers
>> basic functions such as initialization, allocation and clean-up of each
>> struct. Testing of ttm_buffer_object also includes locking and unlocking
>> the object for validation, with special scenarios such as an interrupted
>> wait or deadlock.
>>
>> Some of the test cases check the bulk move mechanism and how it 
>> interacts
>> with pinned buffers. This is to be seen if we want to add dedicated 
>> testing
>> for bulk move or not. The resource allocation subtests use 
>> ttm_sys_manager
>> for now. Resources that don't use system memory will be indirectly 
>> tested
>> via tests for ttm_bo_validate()/ttm_bo_init_validate(), using a mock
>> resource manager.
>>
>> 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, first enable CONFIG_KUNIT, and
>> then CONFIG_DRM_TTM_KUNIT_TEST.
>>
>> Many thanks,
>> Karolina
>>
>> v7:
>>   - Drop size argument from ttm_place_kunit_init(), it's no longer 
>> needed
>>   - Delete a TODO comment from ttm_bo_validate_tests.c
>>   - First evict BOs before calling ttm_resource_manager_set_used() in
>>     ttm_mock_manager_fini()
>>   - Stop calling ttm_resource_manager_cleanup() as a part of the mock 
>> manager
>>     fini sequence. It frees a move fence that is allocated via KUnit 
>> allocator,
>>     which gets freed again as a part of the test cleanup
>>   - Set use_tt to true in mock manager and stop passing in the flag 
>> for it
>>   - Make ttm_dev_empty_funcs static
>>     (drivers/gpu/drm/ttm/tests/ttm_tt_test.c:232:25: sparse: sparse:
>>     symbol 'ttm_dev_empty_funcs' was not declared. Should it be static?)
>>   - Cast bo->base.resv->fences to a generic pointer before it's 
>> checked by
>>     KUnit (drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c:98:9:
>>     sparse: sparse: incompatible types in comparison expression 
>> (different
>>     base types))
>>   - Clean up mock managers in ttm_bo_validate_move_fence_not_signaled 
>> subtest
>>
>> v6:
>>    - Include tests for ttm_bo_init_reserved() and ttm_bo_validate(), 
>> with
>>      a mock resource manager (patches 6-8; no eviction testing)
>>    - Add ttm_test_devices_all_init() helper to also init ttm_device 
>> instance
>>    - Remove fpfn and lpfn from ttm_place_kunit_init() helper -- these 
>> fields
>>      are neither used nor tested
>>
>> v5:
>>    - Actually use the page_flags parameter in ttm_tt_simple_create()
>>
>> v4:
>>    - First unreserve the object before calling ww_acquire_fini() in
>>      ttm_bo_reserve_double_resv subtest
>>    - Silence lockdep in ttm_bo_reserve_deadlock subtest (open to 
>> suggestions
>>      how to fix it in a different way)
>>    - Use a genuine GEM object in ttm_buffer_object instead of an 
>> empty one
>>
>> v3:
>>    - Instead of modifying the main TTM Makefile, use
>>      EXPORT_SYMBOL_FOR_TESTS_ONLY() macro for symbols that are tested 
>> but
>>      not widely exported. Thanks to this change, TTM tests can be built
>>      as modules, even when non-exported functions are used
>>    - Change the description of a patch that fixes 
>> ttm_pool_pre_populated()
>>
>> v2:
>>    - Remove Makefile for KUnit tests and move the definitions to the
>>      TTM's one
>>    - Switch on CONFIG_DRM_TTM_KUNIT_TEST=m so the tests and TTM module
>>      are built as one. This allows building the tests as a module, even
>>      if it uses functions that are not exported
>>    - Fix ttm_pool_pre_populated(); a wrong flag was passed to
>>      ttm_tt_kunit_init() function
>>
>> Karolina Stolarek (8):
>>    drm/ttm/tests: Add tests for ttm_resource and ttm_sys_man
>>    drm/ttm/tests: Add tests for ttm_tt
>>    drm/ttm/tests: Add tests for ttm_bo functions
>>    drm/ttm/tests: Fix argument in ttm_tt_kunit_init()
>>    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
>>
>>   drivers/gpu/drm/Kconfig                       |   1 +
>>   drivers/gpu/drm/ttm/tests/.kunitconfig        |   1 +
>>   drivers/gpu/drm/ttm/tests/Makefile            |   5 +
>>   drivers/gpu/drm/ttm/tests/ttm_bo_test.c       | 619 ++++++++++++++
>>   .../gpu/drm/ttm/tests/ttm_bo_validate_test.c  | 795 ++++++++++++++++++
>>   drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c | 109 ++-
>>   drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h |   7 +
>>   drivers/gpu/drm/ttm/tests/ttm_mock_manager.c  | 206 +++++
>>   drivers/gpu/drm/ttm/tests/ttm_mock_manager.h  |  31 +
>>   drivers/gpu/drm/ttm/tests/ttm_pool_test.c     |   3 +-
>>   drivers/gpu/drm/ttm/tests/ttm_resource_test.c | 335 ++++++++
>>   drivers/gpu/drm/ttm/tests/ttm_tt_test.c       | 282 +++++++
>>   drivers/gpu/drm/ttm/ttm_resource.c            |   3 +
>>   drivers/gpu/drm/ttm/ttm_tt.c                  |   3 +
>>   14 files changed, 2397 insertions(+), 3 deletions(-)
>>   create mode 100644 drivers/gpu/drm/ttm/tests/ttm_bo_test.c
>>   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
>>   create mode 100644 drivers/gpu/drm/ttm/tests/ttm_resource_test.c
>>   create mode 100644 drivers/gpu/drm/ttm/tests/ttm_tt_test.c
>>
>


More information about the dri-devel mailing list