From 2e6d5212d4795ac818317b91823fe3c281135a60 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Thu, 10 Sep 2026 10:28:11 -0600 Subject: [PATCH] drm/amd/display: Fix KUnit DM warnings [WHY] Vblank and interrupt-management tests need discoverable CRTCs with complete vblank callbacks and balanced teardown. [HOW] Add the callbacks, link the fake CRTCs, and register cleanup actions to disable vblank before unlinking. Pass the CRTC directly so cleanup does not reinterpret two different fixture types through one layout. Assisted-by: Copilot:GPT-6-Astra Reviewed-by: Bhawanpreet Lakha Signed-off-by: Alex Hung Signed-off-by: George Zhang Tested-by: Dan Wheeler Signed-off-by: Alex Deucher --- .../display/amdgpu_dm/tests/amdgpu_dm_test.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) 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;