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 03301F46446 for ; Mon, 16 Mar 2026 10:24:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A77E310E252; Mon, 16 Mar 2026 10:24:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="iYh/508z"; 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 92EAE10E258 for ; Mon, 16 Mar 2026 10:23:48 +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 6D0DE4E426C0; Mon, 16 Mar 2026 10:23:47 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 43AF95FC4A; Mon, 16 Mar 2026 10:23:47 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C671110369F12; Mon, 16 Mar 2026 11:23:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1773656626; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=BZx0eZ+X2Jt7EA2nMQUaCpeLZ70+cv7nsxepSw4kTdE=; b=iYh/508zG9d3HlSUShsC6vBUUw/Ll3RB/15EqjW26D1Bz6G+c008MISJTeo+ORrMBO8TWw aL9NtUmPugxP9lDsWMBhmmm95rZK3Jw2GRySzhAnUL5nLGNh17IlXfKs2mkw9L+J2LK3Zq nXwR7P4lM8rketWnhuaYuUwq/2Z+IyXqxs/gXdu9pUAK2vcrEtOt3iV1FNOjl+iCRnelps 0JcjuOBkWz4X/a+dYKsJgSyXMguD71Ei42giDOG0t6bN/gqtCsg/xP8Gw2Y5Mgi1G8vYNq IIYP4xoVtcH/hu2OX+YWzHfF8jQEKjn8VrjC76ni6w7H3VzaUteyQfCFhed+Ag== From: Louis Chauvet Date: Mon, 16 Mar 2026 11:24:10 +0100 Subject: [PATCH i-g-t v8 02/49] lib/igt_kms: Add helper to wait for a specific status on a connector MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260316-unigraf-integration-v8-2-4489bf8572be@bootlin.com> References: <20260316-unigraf-integration-v8-0-4489bf8572be@bootlin.com> In-Reply-To: <20260316-unigraf-integration-v8-0-4489bf8572be@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=2563; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=FXv3d3u1y6SRBP8hFBpj3UuYZJ9AE8Kt3MSvev/Nt8w=; b=owEBiQJ2/ZANAwAIASCtLsZbECziAcsmYgBpt9pOxvKZwaPdPvigWrtUxkoHNseWcOrm8l/Dg +dSnmFssN6JAk8EAAEIADkWIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCabfaThsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMSwyLDIACgkQIK0uxlsQLOLFqg//cGq1IPAoMg+coP+jrDUKTJadsYjbqcv pe87ZPeaHtQUi4LxQK7PHCqswjhInFc0iwpMIZu8uz9oaI02xqEu8ZU49DwV4WxezC33iAN5SKE G+MxRmTyH3/wa7RWRtsdgJTN4/Rdr2E3/B4D92Zyn/U9HDNoQe6d2VreNEuXcbaOWpxKCtq1BFG YuIfGeuND1OTnkRp61Rf+HTrougX/OooQG6e+6iWblH7bMEIRY4Vy8XyHGYhrA7M9bB/GH9SKrq A0KQD0mwWtUQoWfTmXyp6FcG+EyNLGbd8y1abi8JIw/KDdwqqd0n256+P4kKAeK6Ca6A7eoZAAG bS4xwAxhKvdXiCbVgIZy1dQhLWOEGRSWG31l8lOOg+3e9XawERH125C8ws0eN3y4Ge8aaK0vMj1 IbAx4DkxVwKtbfuvWE7dK/sK97DaiwHse1RXRY9bbH3NNODt+HXCOMXZqgM/pktOehLhn+Ia6Fu XDfIxWfeE2M/7qdYt2NLtXfpYZYwQpyTL0CwGbfGFLjsvQUR6vlAHO8Ln4SAjoIMVRVWEFLPdD2 e6vVP4iV+sfc7A/5RuKpWSHCMHUEKDQu/rFhLrIWYhC3p3FQrQfJOBBoNxwGt/r/2llljVlNDcu DIasPvrcvroOJAcSGIm3Xbg0F/FbKHlOS/Um/ykgG6tAser8Wi7s= 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" During testing with chamelium, it is frequent to wait for a specific connector status. This new helper is polling the DRM API to wait for this status. This allows detecting it without notifier systems which can fail if hot plug detection is not working properly on the device under test. Reviewed-by: Kory Maincent Reviewed-by: Luca Ceresoli Signed-off-by: Louis Chauvet --- lib/igt_kms.c | 41 +++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 3 +++ 2 files changed, 44 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 692d75b70ecc..4a496ab256f0 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -8093,3 +8093,44 @@ igt_crtc_t *igt_random_crtc(igt_display_t *display) return crtcs[rand() % n]; } + +/** + * igt_wait_for_connector_status: + * @drm_fd: drm file descriptor + * @connector_id: connector to monitor + * @timeout: maximum duration to wait, in second. Use -1.0 to set the timeout + * to igt_default_detect_timeout(). + * @drm_mode: mode to wait for, see enum drmModeConnection + * + * Wait for at most @timeout that the connector @connector_id status + * become @drm_mode + * Returns: true when the status is reached, false if there is a timeout + */ +bool igt_wait_for_connector_status(int drm_fd, unsigned int connector_id, double timeout, + int drm_mode) +{ + drmModeConnector *connector; + struct timespec start, end; + + if (timeout == -1.0) + timeout = igt_default_display_detect_timeout(); + + igt_assert_eq(igt_gettime(&start), 0); + end = start; + + while (igt_time_elapsed(&start, &end) <= timeout) { + connector = drmModeGetConnector(drm_fd, connector_id); + if (connector && connector->connection == drm_mode) { + drmModeFreeConnector(connector); + return true; + } + drmModeFreeConnector(connector); + usleep(10000); + igt_assert_eq(igt_gettime(&end), 0); + } + + igt_debug("Timeout waiting for connection status %d on connector %d\n", drm_mode, + connector_id); + + return false; +} diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 081613a4b949..934f24d5915b 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -1301,4 +1301,7 @@ void igt_get_and_wait_out_fence(igt_output_t *output); igt_colorop_t *igt_find_colorop(igt_display_t *display, uint32_t id); +bool igt_wait_for_connector_status(int drm_fd, unsigned int connector_id, double timeout, + int drm_mode); + #endif /* __IGT_KMS_H__ */ -- 2.52.0