[PATCH 2/2] drm/amd/display: Add KUnit tests for the MST last link check on logical ports

From: Karol Baryła

Date: Mon Nov 16 2026 - 06:12:30 EST


Check that a logical port accepts a DSC mode even when its
DP_LINK_BW_SET describes a link too slow for the uncompressed stream,
and that port 7, the highest physical port number, is still rejected.

Signed-off-by: Karol Baryła <git@xxxxxxxxxx>
---
.../amdgpu_dm/tests/amdgpu_dm_mst_types_test.c | 47 ++++++++++++++++++++++
1 file changed, 47 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_mst_types_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_mst_types_test.c
index e624eb55cae1..e33a9daaebde 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_mst_types_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_mst_types_test.c
@@ -2943,6 +2943,51 @@ static void dm_mst_test_port_mode_last_link_synaptics_quirk(struct kunit *test)
KUNIT_EXPECT_EQ(test, (u32)ctx.stream->timing.flags.DSC, 1U);
}

+/**
+ * dm_mst_test_port_mode_logical_port_skips_last_link_check - logical ports have no last link
+ * @test: KUnit test context
+ *
+ * A logical port is the branch device's own internal sink, so no DP link
+ * follows it. A DP_LINK_BW_SET too slow for the uncompressed stream must not
+ * reject the mode, and the link settings are not read.
+ */
+static void dm_mst_test_port_mode_logical_port_skips_last_link_check(struct kunit *test)
+{
+ struct dm_mst_test_port_mode_ctx ctx;
+
+ dm_mst_test_init_port_mode_ctx(test, &ctx, 2500000, 1000, 100000);
+ dm_mst_test_enable_dsc(test, &ctx);
+ ctx.port->pdt = DP_PEER_DEVICE_SST_SINK;
+ ctx.port->port_num = DP_MST_LOGICAL_PORT_0;
+ dm_mst_test_set_link_settings(DP_LINK_BW_1_62, 1, DP_8b_10b_ENCODING);
+
+ KUNIT_EXPECT_EQ(test, dm_dp_mst_is_port_support_mode(ctx.aconnector, ctx.stream), DC_OK);
+ KUNIT_EXPECT_EQ(test, (u32)ctx.stream->timing.flags.DSC, 1U);
+ KUNIT_EXPECT_EQ(test, ctx.aconnector->mst_local_bw, 0U);
+}
+
+/**
+ * dm_mst_test_port_mode_highest_physical_port_last_link_checked - port 7 is physical
+ * @test: KUnit test context
+ *
+ * Port numbers 0-7 are physical and only 8 and above are logical, so a too
+ * slow last link behind port 7 still rejects the mode.
+ */
+static void dm_mst_test_port_mode_highest_physical_port_last_link_checked(struct kunit *test)
+{
+ struct dm_mst_test_port_mode_ctx ctx;
+
+ dm_mst_test_init_port_mode_ctx(test, &ctx, 2500000, 1000, 100000);
+ dm_mst_test_enable_dsc(test, &ctx);
+ ctx.port->pdt = DP_PEER_DEVICE_SST_SINK;
+ ctx.port->port_num = DP_MST_LOGICAL_PORT_0 - 1;
+ dm_mst_test_set_link_settings(DP_LINK_BW_1_62, 1, DP_8b_10b_ENCODING);
+
+ KUNIT_EXPECT_EQ(test, dm_dp_mst_is_port_support_mode(ctx.aconnector, ctx.stream),
+ DC_FAIL_BANDWIDTH_VALIDATE);
+ KUNIT_EXPECT_EQ(test, ctx.aconnector->mst_local_bw, 1257120U);
+}
+
/**
* dm_mst_test_port_mode_upstream_vc_too_small - the upstream hop is the bottleneck
* @test: KUnit test context
@@ -4143,6 +4188,8 @@ static struct kunit_case dm_mst_types_test_cases[] = {
KUNIT_CASE(dm_mst_test_port_mode_last_link_too_slow),
KUNIT_CASE(dm_mst_test_port_mode_last_link_cached_bw),
KUNIT_CASE(dm_mst_test_port_mode_last_link_synaptics_quirk),
+ KUNIT_CASE(dm_mst_test_port_mode_logical_port_skips_last_link_check),
+ KUNIT_CASE(dm_mst_test_port_mode_highest_physical_port_last_link_checked),
KUNIT_CASE(dm_mst_test_port_mode_upstream_vc_too_small),
KUNIT_CASE(dm_mst_test_port_mode_branch_throughput_exceeded),
/* get_conv_frl_bw tests */

--
2.56.1