Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D7B4EA4FB4 for ; Mon, 23 Feb 2026 12:09:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A81410E38B; Mon, 23 Feb 2026 12:09:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="wCRb+BTh"; dkim-atps=neutral Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) by gabe.freedesktop.org (Postfix) with ESMTPS id BCB5710E384 for ; Mon, 23 Feb 2026 12:09:37 +0000 (UTC) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id A3F094E41030; Mon, 23 Feb 2026 12:09:36 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 7A4245FD43; Mon, 23 Feb 2026 12:09:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 337E410368F91; Mon, 23 Feb 2026 13:09:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1771848575; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=3jDn4Ddbs6yLmzQCIMm4XPnlFV4TLEc8eEUohBey+G8=; b=wCRb+BThQQ3TmB8TRZZaK1vaI25eU/mrwCwpjUzKquXyC5XyHI6ae/7ArduJ0zPXpvdeVm WlqpFkXhprdDeEiTpSxpvTb65LQad/PM3/pxNRzdZUEifw4NQLS4hOpHTT6hnrkwFG7Pln a/iNhgRQakqu6d/ywNwWY1zsoskRTH8/zW045yv2XdKAhx9CFDjc+f1JqHJ3TGQMsCRV/D ZRyZUETO071KsR12WpR+ZrfxwZHzaso2gqv9p0u/phY0nKx267AWvYaShKQ2vW1xEcr8dV Pawb0K83Wta2QsW16/UdK+mUYsNs6WtUDATfJ8ogxjxA92hpKAAH+gml56MoHQ== From: Louis Chauvet Date: Mon, 23 Feb 2026 13:09:55 +0100 Subject: [PATCH i-g-t v7 48/48] tests/unigraf/unigraf_lt: Add test for link training MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260223-unigraf-integration-v7-48-73dc9143c8c1@bootlin.com> References: <20260223-unigraf-integration-v7-0-73dc9143c8c1@bootlin.com> In-Reply-To: <20260223-unigraf-integration-v7-0-73dc9143c8c1@bootlin.com> To: igt-dev@lists.freedesktop.org Cc: thomas.petazzoni@bootlin.com, luca.ceresoli@bootlin.com, kory.maincent@bootlin.com, markyacoub@google.com, khaled.almahallawy@intel.com, Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=6519; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=uZIy3Eev5ZDPksmM1li7duNvPbpbIgPaTtiS165alS4=; b=owEBiQJ2/ZANAwAIASCtLsZbECziAcsmYgBpnENtdsJES8ydAFwQHQ6CH+xbTphNJWHH+u66f QgMig4+JJaJAk8EAAEIADkWIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCaZxDbRsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMSwyLDIACgkQIK0uxlsQLOJotBAAycbECiJutu9ytMnxveYgUCqcbOotHUU iPCnoVQiIIB4rWe/U/m3IXk1BgrlIHwhImGxsW3eyynVU90m/CY8BHPekqFDNC/v4qAaOgnSYYL G89IPDtJiXGCAaqyslcdfuDrxCf/8AijoSzo+hBZ+If322wUT8amQLVCr3egiJJjsjJvuRQTBlj ZkzColBU2IPj640P2+DmJ15MGGUbxKJ7kcLnGO3BVprtfx6gx0aQ/DaKGWgO81Q4bVPQ9jsFijC ypa9nzdORgn1GjhvEuFDtF/CQwvO4poirY3MHwiLLmlS99alKWKkv681MuSC4X5hSQl374bx7RC 1P3enJluTTWZg7U8YzDqZH0SNtvVOpQw1R1xgf/LNIeEzAzO1TvslGgH92aBQjhbWg07mDdsiJb uh221s6+K4WFlukax1dnEOSrM1TQUlcxgZffUY3/YrDgKjJ0r8VFnmxsehUwCGLGtCI5/aLX0Jd w+nVryltVk4m9bG1lfrz4qoByw1LxCLNxMKcKQ+IWhhA/t6Wc7SpH6vYpFtNUoIbHp6IjIfzw1j MD5KKEQiRfqeHGkNTUNejKQ4C+D+sAj4JY6A4Dn/dcrHC5D5kaNEzZ+cWSGkve04tCISN4VOm0G WX2uhf4+NwyMiOrmZh1yqEJ013M/aB88u4L85hbpoGmY5023oB68= X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-Last-TLS-Session-Version: TLSv1.3 X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" To test link training on various situation, add multiple link training scenarios. Reviewed-by: Kory Maincent Signed-off-by: Louis Chauvet --- tests/unigraf/meson.build | 1 + tests/unigraf/unigraf_lt.c | 183 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+) diff --git a/tests/unigraf/meson.build b/tests/unigraf/meson.build index 4ef8c32151e4..22e64c0f389d 100644 --- a/tests/unigraf/meson.build +++ b/tests/unigraf/meson.build @@ -1,5 +1,6 @@ unigraf_progs = [ 'unigraf_connectivity', + 'unigraf_lt', ] foreach prog : unigraf_progs diff --git a/tests/unigraf/unigraf_lt.c b/tests/unigraf/unigraf_lt.c new file mode 100644 index 000000000000..81e6ecd3fae4 --- /dev/null +++ b/tests/unigraf/unigraf_lt.c @@ -0,0 +1,183 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright © 2026 Google + * + * Authors: + * Louis Chauvet + */ + +#include +#include +#include +#include +#include + +#include "drm_fourcc.h" +#include "drmtest.h" +#include "igt_aux.h" +#include "igt_core.h" +#include "igt_dp.h" +#include "igt_edid.h" +#include "igt_kms.h" +#include "unigraf/unigraf.h" + +/** + * TEST: unigraf link training + * Category: Core + * Description: Testing DP link training with a unigraf device + * + * SUBTEST: unigraf-dp-lane-count + * Description: Make sure that the link training goes well for different lane count + * + * SUBTEST: unigraf-dp-link-rate + * Description: Make sure that the link training goes well for different link rates + */ + +static void init_output_and_display_pattern(igt_display_t *display, igt_output_t *output) +{ + igt_crtc_t *crtc; + struct igt_fb fb; + igt_plane_t *primary; + drmModeModeInfo *mode; + int fb_id; + + igt_modeset_disable_all_outputs(display); + igt_display_reset(display); + + igt_output_set_crtc(output, 0); + crtc = igt_get_crtc_for_output(display, output); + igt_output_set_crtc(output, crtc); + + /* Get the current mode */ + mode = igt_output_get_mode(output); + igt_assert(mode); + + /* Create a framebuffer with a solid color pattern */ + fb_id = igt_create_color_pattern_fb(display->drm_fd, mode->hdisplay, + mode->vdisplay, DRM_FORMAT_XRGB8888, + DRM_FORMAT_MOD_LINEAR, 0, 0, 0, &fb); + igt_assert(fb_id > 0); + + primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); + + igt_assert(primary); + + igt_plane_set_size(primary, mode->hdisplay, mode->vdisplay); + igt_plane_set_fb(primary, &fb); + igt_output_override_mode(output, mode); + + igt_display_commit2(display, COMMIT_ATOMIC); + + /* Set the framebuffer to the plane */ + igt_plane_set_fb(primary, &fb); + + /* Set the plane properties atomically */ + igt_plane_set_prop_value(primary, IGT_PLANE_FB_ID, fb.fb_id); + igt_plane_set_prop_value(primary, IGT_PLANE_CRTC_X, 0); + igt_plane_set_prop_value(primary, IGT_PLANE_CRTC_Y, 0); + igt_plane_set_prop_value(primary, IGT_PLANE_CRTC_W, mode->hdisplay); + igt_plane_set_prop_value(primary, IGT_PLANE_CRTC_H, mode->vdisplay); + + /* Commit the changes atomically */ + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); +} + +IGT_TEST_DESCRIPTION("Test unigraf device functionality"); +int igt_main() +{ + int drm_fd = -1; + igt_display_t display; + igt_output_t *output; + drmModeConnectorPtr connector; + int i; + + igt_fixture() { + drm_fd = drm_open_driver(DRIVER_ANY); + igt_assert(drm_fd >= 0); + + igt_display_require(&display, drm_fd); + unigraf_require_device(drm_fd); + + connector = unigraf_get_connector(drm_fd); + } + + igt_subtest_with_dynamic("unigraf-dp-lane-count") { + int lane_counts[3] = {1, 2, 4}; + int current_lanes; + + for (i = 0; i < ARRAY_SIZE(lane_counts); i++) { + igt_dynamic_f("unigraf-dp-lane-count-%d", lane_counts[i]) { + unigraf_reset(); + unigraf_set_max_lane_count(lane_counts[i]); + unigraf_hpd_pulse(500000); + + igt_display_require_output(&display); + output = igt_output_from_connector(&display, connector); + igt_assert(output); + igt_dp_force_link_retrain(drm_fd, output, 2); + init_output_and_display_pattern(&display, output); + + current_lanes = igt_dp_get_current_lane_count(drm_fd, output); + igt_assert_eq(current_lanes, lane_counts[i]); + } + } + } + + igt_subtest_with_dynamic("unigraf-dp-link-rate") { + int rates[] = {UNIGRAF_RATE_1_62_GHZ, + UNIGRAF_RATE_2_7_GHZ, + UNIGRAF_RATE_5_4_GHZ, + UNIGRAF_RATE_6_75_GHZ, + UNIGRAF_RATE_8_10_GHZ}; + int current_rate; + int max_supported_rate; + + for (i = 0; i < ARRAY_SIZE(rates); i++) { + igt_dynamic_f("unigraf-dp-link-rate-%d", rates[i]) { + unigraf_reset(); + unigraf_set_max_link_rate(rates[i]); + unigraf_hpd_pulse(1000000); + igt_display_require_output(&display); + igt_display_reset(&display); + igt_display_require_output(&display); + output = igt_output_from_connector(&display, connector); + igt_assert(output); + igt_dp_force_link_retrain(drm_fd, output, 2); + + init_output_and_display_pattern(&display, output); + + current_rate = igt_dp_get_max_link_rate(drm_fd, output); + max_supported_rate = igt_dp_get_max_supported_rate(drm_fd, output); + igt_require(max_supported_rate >= unigraf_rate_to_kbs(rates[i])); + igt_assert_eq(current_rate, unigraf_rate_to_kbs(rates[i])); + } + } + } + + igt_subtest("unigraf-dp-link-suspend-resume") { + int current_rate, current_lanes; + + unigraf_reset(); + igt_display_require_output(&display); + igt_display_reset(&display); + igt_display_require_output(&display); + output = igt_output_from_connector(&display, connector); + igt_assert(output); + + /* Get initial link parameters */ + current_rate = igt_dp_get_current_link_rate(drm_fd, output); + current_lanes = igt_dp_get_current_lane_count(drm_fd, output); + + /* Suspend the system */ + igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); + + /* Verify link parameters are maintained */ + igt_assert_eq(igt_dp_get_current_link_rate(drm_fd, output), current_rate); + igt_assert_eq(igt_dp_get_current_lane_count(drm_fd, output), current_lanes); + } + + igt_fixture() { + igt_display_fini(&display); + close(drm_fd); + } +} -- 2.52.0