summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorBhawanpreet Lakha <bhawanpreet.lakha@amd.com>2026-07-20 16:37:38 -0400
committerAlex Deucher <alexander.deucher@amd.com>2026-08-06 09:59:11 -0400
commitbe784e161a97991fd04b3d4be361bfa9ed5c763f (patch)
treebf1da92c58b89874f643a55a58615b1fa869dadd /drivers/gpu
parent466a270202335eed7b9dceeab1525ba32d4bd5bb (diff)
drm/amd/display: Add KUnit tests for crtc set_static_screen_optimze
Add dm_test_crtc_set_static_screen_optimze_sr_entry_psr and dm_test_crtc_set_static_screen_optimze_psr_su_skips to cover the allow_sr_entry == true path of amdgpu_dm_crtc_set_static_screen_optimze(): the replay/PSR event updates when psr_version < DC_PSR_VERSION_SU_1, and skipping the PSR event update when psr_version is DC_PSR_VERSION_SU_1. Assisted-by: Copilot:Claude-Opus-4.8 Reviewed-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com> Signed-off-by: Roman Li <roman.li@amd.com> Tested-by: Dan Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c55
1 files changed, 55 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 db98e42c561b..fa4986153eda 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
@@ -756,6 +756,59 @@ static void dm_test_crtc_set_static_screen_optimze_no_sr_entry(struct kunit *tes
amdgpu_dm_crtc_set_static_screen_optimze(dm, stream, false, false);
}
+/**
+ * dm_test_crtc_set_static_screen_optimze_sr_entry_psr - Test SSO toggle drives PSR
+ * @test: The KUnit test context
+ *
+ * With self-refresh entry allowed and a PSR version below DC_PSR_VERSION_SU_1,
+ * the function must run both the replay and PSR event updates. The link has no
+ * replay/PSR feature enabled, so both event helpers short-circuit safely. Both
+ * SSO states are exercised to cover the set_vsync_event computation.
+ */
+static void dm_test_crtc_set_static_screen_optimze_sr_entry_psr(struct kunit *test)
+{
+ struct amdgpu_display_manager *dm;
+ struct dc_link *link;
+ struct dc_stream_state *stream;
+
+ dm = kunit_kzalloc(test, sizeof(*dm), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dm);
+
+ link = dm_kunit_alloc_link(test);
+ stream = dm_kunit_alloc_stream(test, link);
+
+ /* psr_version < DC_PSR_VERSION_SU_1 -> PSR event branch is taken. */
+ link->psr_settings.psr_version = DC_PSR_VERSION_1;
+
+ amdgpu_dm_crtc_set_static_screen_optimze(dm, stream, true, true);
+ amdgpu_dm_crtc_set_static_screen_optimze(dm, stream, false, true);
+}
+
+/**
+ * dm_test_crtc_set_static_screen_optimze_psr_su_skips - Test PSR SU skips PSR event
+ * @test: The KUnit test context
+ *
+ * With self-refresh entry allowed and a PSR version of DC_PSR_VERSION_SU_1, the
+ * function must update the replay event but skip the PSR event update.
+ */
+static void dm_test_crtc_set_static_screen_optimze_psr_su_skips(struct kunit *test)
+{
+ struct amdgpu_display_manager *dm;
+ struct dc_link *link;
+ struct dc_stream_state *stream;
+
+ dm = kunit_kzalloc(test, sizeof(*dm), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dm);
+
+ link = dm_kunit_alloc_link(test);
+ stream = dm_kunit_alloc_stream(test, link);
+
+ /* psr_version >= DC_PSR_VERSION_SU_1 -> PSR event branch is skipped. */
+ link->psr_settings.psr_version = DC_PSR_VERSION_SU_1;
+
+ amdgpu_dm_crtc_set_static_screen_optimze(dm, stream, true, true);
+}
+
/* Tests for amdgpu_dm_crtc_enable_vblank() */
/**
@@ -1295,6 +1348,8 @@ static struct kunit_case amdgpu_dm_crtc_tests[] = {
KUNIT_CASE(dm_test_idle_worker_enabled_runs_body),
/* amdgpu_dm_crtc_set_static_screen_optimze */
KUNIT_CASE(dm_test_crtc_set_static_screen_optimze_no_sr_entry),
+ KUNIT_CASE(dm_test_crtc_set_static_screen_optimze_sr_entry_psr),
+ KUNIT_CASE(dm_test_crtc_set_static_screen_optimze_psr_su_skips),
/* amdgpu_dm_crtc_enable_vblank */
KUNIT_CASE(dm_test_crtc_enable_vblank_rejects_unconfigured),
/* amdgpu_dm_crtc_update_crtc_active_planes */