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 C357FF53D6D for ; Mon, 16 Mar 2026 16:23:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75E8E10E29A; Mon, 16 Mar 2026 16:23:46 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="e4YAZNjc"; dkim-atps=neutral Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id E8AA010E2B5 for ; Mon, 16 Mar 2026 16:23:19 +0000 (UTC) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id DD0CE1A2E70; Mon, 16 Mar 2026 16:23:18 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B4CFE5FC4A; Mon, 16 Mar 2026 16:23:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 445FA10372210; Mon, 16 Mar 2026 17:23:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1773678198; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Z5ajQaRUsIJiJU87/cVFtKJLdfKUzq20jkt1ca81vMk=; b=e4YAZNjcP/wWwoXXHBD1mI7TpjDkmLUpyyaUHU3scsYPDfp4u3hldAXhAAmpy07/G3NDSl UsTpondKZEOb+fphJHoWv2Dxd6Dn6oWxoBQq/MGdAYy1TBchf+MYHGLpSnJs/ovF+7227A D5iuE5EbhiOdTayy+7tnyfxRxjAqeZXA6AZXiVdeJ9g/LWZDyqhwEDyEx9ntlOSMgltEAi Rac9w2fPvUcXUzuCsYjGjaGuUr0iWtOC+V1aOkpYxkdfmg9yOcncjlxH5l7COkLOnWd7G6 g/zPsOWlSgbDYD/2G97QZzp6v5QzSST0mtPnzkSsxdtD+gtEc7hCjQ0aaEmh0w== From: Louis Chauvet Date: Mon, 16 Mar 2026 17:17:32 +0100 Subject: [PATCH i-g-t v9 11/49] lib/igt_debugfs: Move debugfs helpers to the proper location MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260316-unigraf-integration-v9-11-a01dffc3b0cb@bootlin.com> References: <20260316-unigraf-integration-v9-0-a01dffc3b0cb@bootlin.com> In-Reply-To: <20260316-unigraf-integration-v9-0-a01dffc3b0cb@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=7734; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=x4DNomkQbGDgBRiaaDNXCV0OQ2u4JYv7MCZEGaGU3NY=; b=owEBiQJ2/ZANAwAIASCtLsZbECziAcsmYgBpuC6KqpLjb9Fjhpf2yYQ8pHT61tCbpP0Rr+t1g kYq1NYqvESJAk8EAAEIADkWIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCabguihsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMSwyLDIACgkQIK0uxlsQLOI+/BAAk+f4TUqZH9QiRnjHjjvrWDUwmDyKrco Adp7PCccmv5EkEc+0jhMM3BPdJrPSw3vOiWBPBTii3ySva1ifv4Hy6z3ZGTJcr9oTMF9X/rQeVp qS4PGbTlcLVBD1eONlNwvNc3nt6IAKMP9XQGnI+sgLyFlQYeMSuDseJ/q0JCgcRzWAi+Hmv+vny emfE59NnbBpXYEQBG04BGj8ucsSNuMM2HVdcph7gzma5QgTX6nTjEjj5spIcd7Z7KHZf40vKaJ4 7AUPpjGt6XOWL7bpk71FYzDV0XdR2mzcNa4o/FYEKSlvMx742An3dBWndN1p7DX2OHchuKP9HDh +OFEuRBq5b713cCZM58rHEUPBLJ5kt2cT7qJroN0A9R5sYxxLqIi2sXGcFlgxUo6C8+no9M4k1w P4DPSDQTHJuBA6TZhphVIH9uD6rVrXz+T4cZjjoQFuG+kNy1HIFkEahfAdOHg9BHI+hgdreC6Rm AMWST8VZRHQJLYtQK15c2aIOIR1eA4kRp6YRsZHnbq12I9cMpXO6GSIUpkcEsnY4Zx9lDV+HuXr qXnso5mM64bX1ryQoHAQHmkCbAp6nLoyupJ6AMzVe/q4mf8gmOeI7HbfwsGfwnnRtL9COZxsbjF 3BRSdcxADsaWboyV4xfsCCBVVHTamS1o8BHv2eAF09u/pt5hXqZU= 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" igt_debugfs_read_connector_file and igt_debugfs_write_connector_file are debugfs related helpers. To avoid mixing everything in igt_kms, move them to igt_debugfs. Reviewed-by: Kory Maincent Reviewed-by: Luca Ceresoli Signed-off-by: Louis Chauvet --- lib/igt_debugfs.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_debugfs.h | 13 ++++++++ lib/igt_kms.c | 93 ------------------------------------------------------ 3 files changed, 107 insertions(+), 93 deletions(-) diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index 11f5ee9984ee..6072d7d68025 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -43,6 +43,7 @@ #include "igt_aux.h" #include "igt_kms.h" #include "igt_debugfs.h" +#include "igt_device.h" #include "igt_sysfs.h" /** @@ -776,3 +777,96 @@ void __igt_debugfs_dump(int device, const char *filename, int level) igt_log(IGT_LOG_DOMAIN, level, "%s:\n%s\n", filename, contents); free(contents); } + +/** + * igt_debugfs_read_connector_file: + * @drm_fd: A drm file descriptor + * @conn_name: Name of the output connector + * @filename: The file to read from in the connector's directory + * @buf: Buffer to store the read content + * @buf_size: Size of the buffer + * + * Reads from a specific file in the connector's debugfs directory. + * + * Returns: 0 on success, -1 on failure. + */ +int igt_debugfs_read_connector_file(int drm_fd, char *conn_name, + const char *filename, char *buf, + size_t buf_size) +{ + int dir, res; + + dir = igt_debugfs_connector_dir(drm_fd, conn_name, O_RDONLY); + igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector %s\n", conn_name); + + res = igt_debugfs_simple_read(dir, filename, buf, buf_size); + close(dir); + + if (res < 0) + return -1; + + return 0; +} + +/** + * igt_debugfs_write_connector_file: + * @drm_fd: A drm file descriptor + * @conn_name: Name of the output connector + * @filename: The file to write to in the connector's directory + * @data: Data to write to the file + * @data_size: Size of the data to write + * + * Writes to a specific file in the connector's debugfs directory. + * + * Returns: 0 on success, -1 on failure. + */ +int igt_debugfs_write_connector_file(int drm_fd, char *conn_name, + const char *filename, const char *data, + size_t data_size) +{ + int dir, res; + + dir = igt_debugfs_connector_dir(drm_fd, conn_name, O_RDONLY); + igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector %s\n", + conn_name); + + res = igt_sysfs_write(dir, filename, data, data_size); + close(dir); + + if (res < 0) + return -1; + + return 0; +} + +bool connector_attr_set_debugfs(int drm_fd, + drmModeConnector *connector, + const char *attr, const char *value, + const char *reset_value, + bool force_reset) +{ + char name[80]; + int idx, dir; + + idx = igt_device_get_card_index(drm_fd); + if (idx < 0 || idx > 63) + return false; + + snprintf(name, sizeof(name), "%s-%d", + kmstest_connector_type_str(connector->connector_type), + connector->connector_type_id); + + dir = igt_debugfs_connector_dir(drm_fd, name, O_DIRECTORY); + if (dir < 0) + return false; + + if (!connector_attr_set(idx, connector, dir, + igt_sysfs_set, attr, + value, reset_value, + force_reset)) + return false; + + igt_info("Connector %s/%s is now %s\n", name, attr, value); + + return true; +} diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h index 2c546f299a43..49fbadd2a74c 100644 --- a/lib/igt_debugfs.h +++ b/lib/igt_debugfs.h @@ -28,6 +28,7 @@ #include #include #include +#include const char *igt_debugfs_mount(void); char *igt_debugfs_path(int device, char *path, int pathlen); @@ -176,4 +177,16 @@ int igt_get_stable_obj_count(int driver); void __igt_debugfs_dump(int device, const char *filename, int level); #define igt_debugfs_dump(d, f) __igt_debugfs_dump(d, f, IGT_LOG_DEBUG) +int igt_debugfs_read_connector_file(int drm_fd, char *conn_name, + const char *filename, char *buf, + size_t buf_size); +int igt_debugfs_write_connector_file(int drm_fd, char *conn_name, + const char *filename, const char *data, + size_t data_size); +bool connector_attr_set_debugfs(int drm_fd, + drmModeConnector *connector, + const char *attr, const char *value, + const char *reset_value, + bool force_reset); + #endif /* __IGT_DEBUGFS_H__ */ diff --git a/lib/igt_kms.c b/lib/igt_kms.c index ce9f70f31f64..97292c5c3dfa 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1755,38 +1755,6 @@ static bool connector_attr_set_sysfs(int drm_fd, return true; } -static bool connector_attr_set_debugfs(int drm_fd, - drmModeConnector *connector, - const char *attr, const char *value, - const char *reset_value, - bool force_reset) -{ - char name[80]; - int idx, dir; - - idx = igt_device_get_card_index(drm_fd); - if (idx < 0 || idx > 63) - return false; - - snprintf(name, sizeof(name), "%s-%d", - kmstest_connector_type_str(connector->connector_type), - connector->connector_type_id); - - dir = igt_debugfs_connector_dir(drm_fd, name, O_DIRECTORY); - if (dir < 0) - return false; - - if (!connector_attr_set(idx, connector, dir, - igt_sysfs_set, attr, - value, reset_value, - force_reset)) - return false; - - igt_info("Connector %s/%s is now %s\n", name, attr, value); - - return true; -} - /** * dump_connector_attrs: Display on debug log all the connector attributes */ @@ -7516,67 +7484,6 @@ static int igt_parse_marked_value(const char *buf, char marked_char, int *result return -1; } -/** - * igt_debugfs_read_connector_file: - * @drm_fd: A drm file descriptor - * @conn_name: Name of the output connector - * @filename: The file to read from in the connector's directory - * @buf: Buffer to store the read content - * @buf_size: Size of the buffer - * - * Reads from a specific file in the connector's debugfs directory. - * - * Returns: 0 on success, -1 on failure. - */ -static int igt_debugfs_read_connector_file(int drm_fd, char *conn_name, - const char *filename, char *buf, - size_t buf_size) -{ - int dir, res; - - dir = igt_debugfs_connector_dir(drm_fd, conn_name, O_RDONLY); - igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector %s\n", conn_name); - - res = igt_debugfs_simple_read(dir, filename, buf, buf_size); - close(dir); - - if (res < 0) - return -1; - - return 0; -} - -/** - * igt_debugfs_write_connector_file: - * @drm_fd: A drm file descriptor - * @conn_name: Name of the output connector - * @filename: The file to write to in the connector's directory - * @data: Data to write to the file - * @data_size: Size of the data to write - * - * Writes to a specific file in the connector's debugfs directory. - * - * Returns: 0 on success, -1 on failure. - */ -static int igt_debugfs_write_connector_file(int drm_fd, char *conn_name, - const char *filename, const char *data, - size_t data_size) -{ - int dir, res; - - dir = igt_debugfs_connector_dir(drm_fd, conn_name, O_RDONLY); - igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector %s\n", - conn_name); - - res = igt_sysfs_write(dir, filename, data, data_size); - close(dir); - - if (res < 0) - return -1; - - return 0; -} - /** * igt_get_current_link_rate: * @drm_fd: A drm file descriptor -- 2.52.0