diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c index e27f6e504395..4c6e9e5d4d72 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c @@ -1681,6 +1681,35 @@ struct dm_test_vblank_ctx { struct drm_pending_vblank_event *event; }; +static int dm_test_vblank_enable(struct drm_crtc *crtc) +{ + return 0; +} + +static void dm_test_vblank_disable(struct drm_crtc *crtc) +{ +} + +static u32 dm_test_vblank_counter(struct drm_crtc *crtc) +{ + return 0; +} + +static const struct drm_crtc_funcs dm_test_vblank_crtc_funcs = { + .enable_vblank = dm_test_vblank_enable, + .disable_vblank = dm_test_vblank_disable, + .get_vblank_counter = dm_test_vblank_counter, +}; + +static void dm_test_vblank_ctx_cleanup(void *data) +{ + struct amdgpu_crtc *acrtc = data; + + if (drm_dev_has_vblank(acrtc->base.dev)) + drm_crtc_vblank_off(&acrtc->base); + list_del_init(&acrtc->base.head); +} + /* * A CRTC with one active plane and a pending vblank event. There is no * initialised vblank, so drm_crtc_vblank_get() fails, which the function under @@ -1702,9 +1731,15 @@ static struct dm_test_vblank_ctx *dm_test_vblank_ctx_alloc(struct kunit *test) KUNIT_ASSERT_NOT_NULL(test, ctx->event); ctx->acrtc->base.dev = &ctx->adev->ddev; + ctx->acrtc->base.funcs = &dm_test_vblank_crtc_funcs; + INIT_LIST_HEAD(&ctx->acrtc->base.head); + list_add_tail(&ctx->acrtc->base.head, + &ctx->adev->ddev.mode_config.crtc_list); ctx->acrtc->base.state = &ctx->acrtc_state->base; ctx->acrtc_state->base.event = ctx->event; ctx->acrtc_state->active_planes = 1; + KUNIT_ASSERT_EQ(test, + kunit_add_action_or_reset(test, dm_test_vblank_ctx_cleanup, ctx->acrtc), 0); return ctx; } @@ -4186,7 +4221,13 @@ static struct dm_test_irq_mgmt_ctx *dm_test_irq_mgmt_ctx_alloc(struct kunit *tes ctx->adev->mode_info.num_crtc = 1; ctx->acrtc->base.dev = &ctx->adev->ddev; + ctx->acrtc->base.funcs = &dm_test_vblank_crtc_funcs; + INIT_LIST_HEAD(&ctx->acrtc->base.head); + list_add_tail(&ctx->acrtc->base.head, + &ctx->adev->ddev.mode_config.crtc_list); ctx->acrtc->crtc_id = 0; + KUNIT_ASSERT_EQ(test, + kunit_add_action_or_reset(test, dm_test_vblank_ctx_cleanup, ctx->acrtc), 0); ctx->acrtc_state->stream = dm_kunit_alloc_stream(test, NULL); timing = &ctx->acrtc_state->stream->timing;