summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Hung <alex.hung@amd.com>2026-09-10 10:28:10 -0600
committerAlex Deucher <alexander.deucher@amd.com>2026-09-23 13:43:35 -0400
commitcbb329ca3b386399fb33947275cf3368890ad23a (patch)
tree85ae4323437688451bcbcdd738405f68a44fd19b
parentc7a6a646807b3c210474a4f3c7c296d22e7e5ef1 (diff)
downloadlinux-next-cbb329ca3b386399fb33947275cf3368890ad23a.tar.gz
linux-next-cbb329ca3b386399fb33947275cf3368890ad23a.zip
drm/amd/display: Fix KUnit CRTC warnings
[WHY] Incomplete CRTC callbacks and vblank teardown cause DRM warnings in CRTC tests. [HOW] Provide the required CRTC callbacks, link fake CRTCs for vblank lookup, and register cleanup actions to disable vblank before unlinking them. Assisted-by: Copilot:GPT-6-Astra Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com> Signed-off-by: Alex Hung <alex.hung@amd.com> Signed-off-by: George Zhang <george.zhang@amd.com> Tested-by: Dan Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
index 4668dc362544..e4396ad8934e 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
@@ -877,10 +877,39 @@ static bool dm_test_crtc_get_vblank_timestamp(struct drm_crtc *crtc,
return false;
}
+static int dm_test_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+ return 0;
+}
+
+static void dm_test_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+}
+
+static u32 dm_test_crtc_get_vblank_counter(struct drm_crtc *crtc)
+{
+ return 0;
+}
+
static const struct drm_crtc_funcs dm_test_crtc_funcs = {
+ .destroy = amdgpu_dm_crtc_destroy,
+ .atomic_duplicate_state = amdgpu_dm_crtc_duplicate_state,
+ .atomic_destroy_state = amdgpu_dm_crtc_destroy_state,
+ .enable_vblank = dm_test_crtc_enable_vblank,
+ .disable_vblank = dm_test_crtc_disable_vblank,
+ .get_vblank_counter = dm_test_crtc_get_vblank_counter,
.get_vblank_timestamp = dm_test_crtc_get_vblank_timestamp,
};
+static void dm_test_crtc_cleanup(void *data)
+{
+ struct amdgpu_crtc *acrtc = data;
+
+ if (acrtc->base.dev && drm_dev_has_vblank(acrtc->base.dev))
+ drm_crtc_vblank_off(&acrtc->base);
+ list_del_init(&acrtc->base.head);
+}
+
/*
* dm_test_crtc_arm_irq_src - Prime an IRQ source so get()/put() short-circuit.
* @test: The KUnit test context
@@ -947,8 +976,13 @@ dm_test_crtc_setup_enable(struct kunit *test, struct amdgpu_device **adev_out,
acrtc = kunit_kzalloc(test, sizeof(*acrtc), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, acrtc);
acrtc->base.dev = &adev->ddev;
+ acrtc->base.funcs = &dm_test_crtc_funcs;
acrtc->base.enabled = true;
acrtc->crtc_id = 0;
+ INIT_LIST_HEAD(&acrtc->base.head);
+ list_add_tail(&acrtc->base.head, &adev->ddev.mode_config.crtc_list);
+ KUNIT_ASSERT_EQ(test,
+ kunit_add_action_or_reset(test, dm_test_crtc_cleanup, acrtc), 0);
link = dm_kunit_alloc_link(test);
stream = dm_kunit_alloc_stream(test, link);
@@ -1782,6 +1816,11 @@ static void dm_test_crtc_handle_vblank_skips_when_flip_submitted(struct kunit *t
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, event);
acrtc->base.dev = &adev->ddev;
+ acrtc->base.funcs = &dm_test_crtc_funcs;
+ INIT_LIST_HEAD(&acrtc->base.head);
+ list_add_tail(&acrtc->base.head, &adev->ddev.mode_config.crtc_list);
+ KUNIT_ASSERT_EQ(test,
+ kunit_add_action_or_reset(test, dm_test_crtc_cleanup, acrtc), 0);
acrtc->event = event;
acrtc->pflip_status = AMDGPU_FLIP_SUBMITTED;
@@ -1818,6 +1857,11 @@ static void dm_test_crtc_handle_vblank_completes_cursor_only(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, event);
acrtc->base.dev = &adev->ddev;
+ acrtc->base.funcs = &dm_test_crtc_funcs;
+ INIT_LIST_HEAD(&acrtc->base.head);
+ list_add_tail(&acrtc->base.head, &adev->ddev.mode_config.crtc_list);
+ KUNIT_ASSERT_EQ(test,
+ kunit_add_action_or_reset(test, dm_test_crtc_cleanup, acrtc), 0);
acrtc->event = event;
acrtc->pflip_status = AMDGPU_FLIP_NONE;