From: Alex Hung <[email protected]>

[WHAT]
Add a KUnit test for amdgpu_dm_process_dmub_aux_transfer_sync()
covering the AUX reply timeout.

Cc: Bhawanpreet Lakha <[email protected]>
Signed-off-by: Alex Hung <[email protected]>
Signed-off-by: Chenyu Chen <[email protected]>
---
 .../amdgpu_dm/tests/amdgpu_dm_dmub_test.c     | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c
index 164071f39731..8117ae4a2aef 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c
@@ -1536,6 +1536,26 @@ static void 
dm_test_process_dmub_set_config_sync_timeout(struct kunit *test)
        KUNIT_EXPECT_EQ(test, result, SET_CONFIG_UNKNOWN_ERROR);
 }
 
+/**
+ * dm_test_process_dmub_aux_transfer_sync_timeout - Test AUX transfer reply 
timeout
+ * @test: The KUnit test context
+ *
+ * When DMUB accepts the AUX request but never signals a reply within the 10
+ * second wait, the sync helper returns -1 with AUX_RET_ERROR_TIMEOUT.
+ */
+static void dm_test_process_dmub_aux_transfer_sync_timeout(struct kunit *test)
+{
+       struct amdgpu_device *adev = dm_test_alloc_adev_with_link(test);
+       struct aux_payload payload = { 0 };
+       enum aux_return_code_type result = AUX_RET_SUCCESS;
+       int ret;
+
+       ret = amdgpu_dm_process_dmub_aux_transfer_sync(adev->dm.dc->ctx, 0, 
&payload, &result);
+
+       KUNIT_EXPECT_EQ(test, ret, -1);
+       KUNIT_EXPECT_EQ(test, result, AUX_RET_ERROR_TIMEOUT);
+}
+
 /* Tests for abort_fused_io() */
 
 /**
@@ -2164,6 +2184,7 @@ static struct kunit_case amdgpu_dm_dmub_tests[] = {
        KUNIT_CASE(dm_test_process_dmub_aux_transfer_sync_protocol_error),
        KUNIT_CASE(dm_test_process_dmub_aux_transfer_sync_copies_data),
        KUNIT_CASE(dm_test_process_dmub_aux_transfer_sync_zero_length),
+       KUNIT_CASE_SLOW(dm_test_process_dmub_aux_transfer_sync_timeout),
        /* amdgpu_dm_process_dmub_set_config_sync() */
        KUNIT_CASE(dm_test_process_dmub_set_config_sync_unknown_error),
        KUNIT_CASE(dm_test_process_dmub_set_config_sync_pending_notified),
-- 
2.43.0

Reply via email to