[PATCH v10 4/9] drm/ttm/tests: Add tests with mock resource managers
Karolina Stolarek
karolina.stolarek at intel.com
Wed Apr 17 07:55:33 UTC 2024
Hi Amaranath,
Many thanks for your review and comments.
On 15.04.2024 14:10, Somalapuram, Amaranath wrote:
>> +static void ttm_bo_validate_basic(struct kunit *test)
>> +{
>> + const struct ttm_bo_validate_test_case *params = test->param_value;
>> + uint32_t fst_mem = TTM_PL_SYSTEM, snd_mem = TTM_PL_VRAM;
>> + struct ttm_operation_ctx ctx_init = { }, ctx_val = { };
>> + struct ttm_placement *fst_placement, *snd_placement;
>> + struct ttm_test_devices *priv = test->priv;
>> + struct ttm_place *fst_place, *snd_place;
>> + uint32_t size = ALIGN(SZ_8K, PAGE_SIZE);
>> + struct ttm_buffer_object *bo;
>> + int err;
>> +
>> + ttm_mock_manager_init(priv->ttm_dev, snd_mem, MANAGER_SIZE);
>> +
>> + fst_place = ttm_place_kunit_init(test, fst_mem, 0);
>> + fst_placement = ttm_placement_kunit_init(test, fst_place, 1);
>> +
>> + bo = kunit_kzalloc(test, sizeof(*bo), GFP_KERNEL);
>> + KUNIT_ASSERT_NOT_NULL(test, bo);
>> +
>> + drm_gem_private_object_init(priv->drm, &bo->base, size);
>> +
>> + err = ttm_bo_init_reserved(priv->ttm_dev, bo, params->bo_type,
>> + fst_placement, PAGE_SIZE, &ctx_init, NULL,
>> + NULL, &dummy_ttm_bo_destroy);
>> + KUNIT_EXPECT_EQ(test, err, 0);
>> +
>> + snd_place = ttm_place_kunit_init(test, snd_mem,
>> DRM_BUDDY_TOPDOWN_ALLOCATION);
>> + snd_placement = ttm_placement_kunit_init(test, snd_place, 1);
>> +
>> + err = ttm_bo_validate(bo, snd_placement, &ctx_val);
>> + dma_resv_unlock(bo->base.resv);
>> +
>> + KUNIT_EXPECT_EQ(test, err, 0);
>> + KUNIT_EXPECT_EQ(test, ctx_val.bytes_moved, bo->base.size);
>> + KUNIT_EXPECT_NOT_NULL(test, bo->ttm);
>> + KUNIT_EXPECT_TRUE(test, ttm_tt_is_populated(bo->ttm));
>> + KUNIT_EXPECT_EQ(test, bo->resource->mem_type, snd_mem);
>> + KUNIT_EXPECT_EQ(test, bo->resource->placement,
>> + DRM_BUDDY_TOPDOWN_ALLOCATION);
>> +
>> + ttm_bo_put(bo);
>> + ttm_mock_manager_fini(priv->ttm_dev, snd_mem);
>
> ttm_mock_manager_fini for fst_mem is missing ?
>
> Regards,
> S.Amarnath
For fst_mem, I'm reusing sysmem manager which gets cleaned in
ttm_device_fini(), so there's no need to call fini on it beforehand.
All the best,
Karolina
More information about the dri-devel
mailing list