drm/amd/display: test native cursor mode on a disabled CRTC

[why]
Upstream has no KUnit coverage for amdgpu_dm_crtc_get_cursor_mode(),
which is why the fix in the previous commit came with no test. The
disabled-CRTC path is easy to regress again: it has already been lost
once to a refactor.

[how]
Add a test whose plane setup would otherwise select overlay mode, and
check that a disabled CRTC still reports native mode. Reverting the
previous commit makes only this test fail.

Reviewed-by: Wayne Lin <wayne.lin@amd.com>
Signed-off-by: Tom Chung <chiahsuan.chung@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Tom Chung 2026-08-07 13:22:03 +08:00 committed by Alex Deucher
parent d24695f377
commit 22183b73a0

View File

@ -498,6 +498,27 @@ static void dm_test_plane_color_pipeline_ignores_other_plane(struct kunit *test)
/* Tests for amdgpu_dm_crtc_get_cursor_mode() */
/**
* dm_test_crtc_get_cursor_mode_disabled_crtc - Test a disabled CRTC uses native cursor
* @test: The KUnit test context
*
* A disabled CRTC must report native mode regardless of what the planes look
* like, so that a commit disabling the CRTC is not rejected. The plane setup
* here would otherwise select overlay mode.
*/
static void dm_test_crtc_get_cursor_mode_disabled_crtc(struct kunit *test)
{
struct dm_cursor_mode_fixture fixture = dm_test_alloc_cursor_mode_fixture(test);
enum amdgpu_dm_cursor_mode cursor_mode = DM_CURSOR_OVERLAY_MODE;
fixture.dm_crtc_state->base.enable = false;
fixture.old_primary_state->crtc_w = 1280;
fixture.primary_state->crtc_w = 1280;
KUNIT_EXPECT_EQ(test, dm_test_get_cursor_mode(&fixture, &cursor_mode), 0);
KUNIT_EXPECT_EQ(test, cursor_mode, DM_CURSOR_NATIVE_MODE);
}
/**
* dm_test_crtc_get_cursor_mode_new_hardware - Test new hardware always uses native mode
* @test: The KUnit test context
@ -923,6 +944,7 @@ static struct kunit_case amdgpu_dm_cursor_tests[] = {
KUNIT_CASE(dm_test_plane_color_pipeline_active),
KUNIT_CASE(dm_test_plane_color_pipeline_ignores_other_plane),
/* amdgpu_dm_crtc_get_cursor_mode */
KUNIT_CASE(dm_test_crtc_get_cursor_mode_disabled_crtc),
KUNIT_CASE(dm_test_crtc_get_cursor_mode_new_hardware),
KUNIT_CASE(dm_test_crtc_get_cursor_mode_no_change),
KUNIT_CASE(dm_test_crtc_get_cursor_mode_disabled_cursor),