From: Chenyu Chen <chen-yu.chen@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
Leo Li <sunpeng.li@amd.com>,
Aurabindo Pillai <aurabindo.pillai@amd.com>,
Roman Li <roman.li@amd.com>, Wayne Lin <wayne.lin@amd.com>,
Tom Chung <chiahsuan.chung@amd.com>,
"Fangzhi Zuo" <jerry.zuo@amd.com>,
Dan Wheeler <daniel.wheeler@amd.com>, Ray Wu <Ray.Wu@amd.com>,
Ivan Lipski <ivan.lipski@amd.com>, Alex Hung <alex.hung@amd.com>,
James Lin <PingLei.Lin@amd.com>,
Chenyu Chen <Chen-Yu.Chen@amd.com>,
Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>,
"Chenyu Chen" <chen-yu.chen@amd.com>
Subject: [PATCH 20/27] drm/amd/display: Test amdgpu_dm_dmub SET_CONFIG sync wait
Date: Wed, 25 Nov 2026 14:55:09 +0800 [thread overview]
Message-ID: <20261125065631.3889665-21-chen-yu.chen@amd.com> (raw)
In-Reply-To: <20261125065631.3889665-1-chen-yu.chen@amd.com>
From: Alex Hung <alex.hung@amd.com>
[WHAT]
Add KUnit tests for amdgpu_dm_process_dmub_set_config_sync() covering
a pending command completed by a DMUB notification, and the reply
timeout.
Cc: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Chenyu Chen <chen-yu.chen@amd.com>
---
.../amdgpu_dm/tests/amdgpu_dm_dmub_test.c | 97 +++++++++++++++++++
1 file changed, 97 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 1a4fa8c7e00c..164071f39731 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
@@ -925,6 +925,33 @@ static void dm_test_dmub_hw_init_alt_channel_rejected(struct kunit *test)
}
}
+static void dm_test_free_dc_dmub_srv(void *data)
+{
+ struct dc_context *ctx = data;
+
+ kfree(ctx->dmub_srv);
+ ctx->dmub_srv = NULL;
+}
+
+/*
+ * Build an amdgpu_device whose DC DMUB service runs on the fake DMUB, so
+ * commands complete instantly and replies echo the submitted command.
+ */
+static struct amdgpu_device *dm_test_alloc_adev_with_dc_dmub(struct kunit *test)
+{
+ struct amdgpu_device *adev = dm_test_alloc_adev_with_dmub(test);
+ struct dc_context *ctx = adev->dm.dc->ctx;
+
+ spin_lock_init(&adev->dm.dmub_lock);
+ mutex_init(&adev->dm.dpia_aux_lock);
+
+ KUNIT_ASSERT_EQ(test, dm_dmub_hw_init(adev), 0);
+ KUNIT_ASSERT_NOT_NULL(test, ctx->dmub_srv);
+ KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, dm_test_free_dc_dmub_srv, ctx), 0);
+
+ return adev;
+}
+
/* Tests for dm_dmub_hw_resume() */
/**
@@ -1441,6 +1468,74 @@ static void dm_test_process_dmub_set_config_sync_unknown_error(struct kunit *tes
KUNIT_EXPECT_EQ(test, result, SET_CONFIG_UNKNOWN_ERROR);
}
+static struct amdgpu_device *dm_test_alloc_adev_with_link(struct kunit *test)
+{
+ struct amdgpu_device *adev = dm_test_alloc_adev_with_dc_dmub(test);
+ struct dc_link *link;
+
+ link = kunit_kzalloc(test, sizeof(*link), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, link);
+
+ link->ddc = kunit_kzalloc(test, sizeof(*link->ddc), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, link->ddc);
+
+ link->ctx = adev->dm.dc->ctx;
+ adev->dm.dc->links[0] = link;
+ adev->dm.dc->link_count = 1;
+
+ adev->dm.dmub_notify = kunit_kzalloc(test, sizeof(struct dmub_notification), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, adev->dm.dmub_notify);
+
+ init_completion(&adev->dm.dmub_aux_transfer_done);
+
+ return adev;
+}
+
+/**
+ * dm_test_process_dmub_set_config_sync_pending_notified - Test a pending SET_CONFIG completes
+ * @test: The KUnit test context
+ *
+ * When DMUB accepts the command without an immediate status, the sync helper
+ * waits for the outbox notification, reports its status and rearms the
+ * completion for the next request.
+ */
+static void dm_test_process_dmub_set_config_sync_pending_notified(struct kunit *test)
+{
+ struct amdgpu_device *adev = dm_test_alloc_adev_with_link(test);
+ struct set_config_cmd_payload payload = { 0 };
+ enum set_config_status result = SET_CONFIG_PENDING;
+ int ret;
+
+ adev->dm.dmub_notify->sc_status = SET_CONFIG_ACK_RECEIVED;
+ complete(&adev->dm.dmub_aux_transfer_done);
+
+ ret = amdgpu_dm_process_dmub_set_config_sync(adev->dm.dc->ctx, 0, &payload, &result);
+
+ KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, result, SET_CONFIG_ACK_RECEIVED);
+ KUNIT_EXPECT_FALSE(test, completion_done(&adev->dm.dmub_aux_transfer_done));
+}
+
+/**
+ * dm_test_process_dmub_set_config_sync_timeout - Test a pending SET_CONFIG times out
+ * @test: The KUnit test context
+ *
+ * When DMUB accepts the command but no notification arrives within the 10
+ * second wait, the sync helper returns -1 with SET_CONFIG_UNKNOWN_ERROR.
+ */
+static void dm_test_process_dmub_set_config_sync_timeout(struct kunit *test)
+{
+ struct amdgpu_device *adev = dm_test_alloc_adev_with_link(test);
+ struct set_config_cmd_payload payload = { 0 };
+ enum set_config_status result = SET_CONFIG_PENDING;
+ int ret;
+
+ ret = amdgpu_dm_process_dmub_set_config_sync(adev->dm.dc->ctx, 0, &payload, &result);
+
+ KUNIT_EXPECT_EQ(test, ret, -1);
+ KUNIT_EXPECT_EQ(test, result, SET_CONFIG_UNKNOWN_ERROR);
+}
+
/* Tests for abort_fused_io() */
/**
@@ -2071,6 +2166,8 @@ static struct kunit_case amdgpu_dm_dmub_tests[] = {
KUNIT_CASE(dm_test_process_dmub_aux_transfer_sync_zero_length),
/* 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),
+ KUNIT_CASE_SLOW(dm_test_process_dmub_set_config_sync_timeout),
/* abort_fused_io() */
KUNIT_CASE(dm_test_abort_fused_io_no_dmub_srv),
{}
--
2.43.0
next prev parent reply other threads:[~2026-11-25 6:58 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 6:54 [PATCH 00/27] DC Patches Nov 30 2026 Chenyu Chen
2026-11-25 6:54 ` [PATCH 01/27] drm/amd/display: Avoid per-entry long division in __drm_lut32_to_dc_gamma Chenyu Chen
2026-11-25 6:54 ` [PATCH 02/27] drm/amd/display: Capture more diagnostic register state Chenyu Chen
2026-11-25 6:54 ` [PATCH 03/27] drm/amd/display: Add debug option to force DP link rate Chenyu Chen
2026-11-25 6:54 ` [PATCH 04/27] drm/amd/display: Reject Replay activation on an inactive link Chenyu Chen
2026-11-25 6:54 ` [PATCH 05/27] drm/amd/display: Decouple PROGRAM_CURSOR_UPDATE_NOW from dc and pipe_ctx Chenyu Chen
2026-11-25 6:54 ` [PATCH 06/27] drm/amd/display: Add DPMS-v2 init Chenyu Chen
2026-11-25 6:54 ` [PATCH 07/27] drm/amd/display: Expose per-CRTC pstate method in connector debugfs Chenyu Chen
2026-11-25 6:54 ` [PATCH 08/27] drm/amd/display: Add DPMS-v2 tx init Chenyu Chen
2026-11-25 6:54 ` [PATCH 09/27] drm/amd/display: Derive DCN6 DSCCLK range from DISPCLK Chenyu Chen
2026-11-25 6:54 ` [PATCH 10/27] drm/amd/display: Carry the stream and plane update bits in update_flags Chenyu Chen
2026-11-25 6:55 ` [PATCH 11/27] drm/amd/display: Add the vsync flip to the DC2 seamless update Chenyu Chen
2026-11-25 6:55 ` [PATCH 12/27] drm/amd/display: Preserve bandwidth floors in overrides Chenyu Chen
2026-11-25 6:55 ` [PATCH 13/27] drm/amd/display: Set HDMI bypass earlier Chenyu Chen
2026-11-25 6:55 ` [PATCH 14/27] drm/amd/display: Add DMUB timer reference clock to ref_clocks Chenyu Chen
2026-11-25 6:55 ` [PATCH 15/27] drm/amd/display: Guard connector I2C transfer without DDC pin Chenyu Chen
2026-11-28 9:43 ` Eren Özen
2026-11-25 6:55 ` [PATCH 16/27] drm/amd/display: Refactor ABM_SET_PIPE and ABM_SET_IMMEDIATE_DISABLE Chenyu Chen
2026-11-25 6:55 ` [PATCH 17/27] drm/amd/display: Implement link_set_dpms_off_v2 Chenyu Chen
2026-11-25 6:55 ` [PATCH 18/27] drm/amd/display: Add the immediate flip to the DC2 seamless update Chenyu Chen
2026-11-25 6:55 ` [PATCH 19/27] drm/amd/display: Test amdgpu_dm_dmub alt-ch apertures Chenyu Chen
2026-11-25 6:55 ` Chenyu Chen [this message]
2026-11-25 6:55 ` [PATCH 21/27] drm/amd/display: Test amdgpu_dm_dmub AUX transfer timeout Chenyu Chen
2026-11-25 6:55 ` [PATCH 22/27] drm/amd/display: Test amdgpu_dm_dmub fused IO replies Chenyu Chen
2026-11-25 6:55 ` [PATCH 23/27] drm/amd/display: Use Z8 enter plus exit for vblank reserve Chenyu Chen
2026-11-25 6:55 ` [PATCH 24/27] drm/amd/display: Fix two streams sharing one OTG Chenyu Chen
2026-11-25 6:55 ` [PATCH 25/27] drm/amd/display: Count planes, not pipes, in the surface check Chenyu Chen
2026-11-25 6:55 ` [PATCH 26/27] drm/amd/display: [FW Promotion] Release 0.1.86.0 Chenyu Chen
2026-11-25 6:55 ` [PATCH 27/27] drm/amd/display: Promote DC to 3.2.409 Chenyu Chen
2026-11-27 5:44 ` [PATCH 00/27] DC Patches Nov 30 2026 Chung, ChiaHsuan (Tom)
2026-11-30 14:10 ` Wheeler, Daniel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125065631.3889665-21-chen-yu.chen@amd.com \
--to=chen-yu.chen@amd.com \
--cc=PingLei.Lin@amd.com \
--cc=Ray.Wu@amd.com \
--cc=alex.hung@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=aurabindo.pillai@amd.com \
--cc=bhawanpreet.lakha@amd.com \
--cc=chiahsuan.chung@amd.com \
--cc=daniel.wheeler@amd.com \
--cc=harry.wentland@amd.com \
--cc=ivan.lipski@amd.com \
--cc=jerry.zuo@amd.com \
--cc=roman.li@amd.com \
--cc=sunpeng.li@amd.com \
--cc=wayne.lin@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.