From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 76A5110E7B1 for ; Thu, 9 Mar 2023 08:38:20 +0000 (UTC) From: Vinod Govindapillai To: igt-dev@lists.freedesktop.org Date: Thu, 9 Mar 2023 10:37:51 +0200 Message-Id: <20230309083751.347335-3-vinod.govindapillai@intel.com> In-Reply-To: <20230309083751.347335-1-vinod.govindapillai@intel.com> References: <20230309083751.347335-1-vinod.govindapillai@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t v3 2/2] lib/igt_kms: handle spurious HPDs List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: Some panels generate long HPDs during CI execution steps even while connected to the system and cause unexpected CI execution failures. In environments like CI, we don't expect to disconnect the panels in the middle of the CI execution. There are two parts to handle this case - display driver and IGT 1. In the display driver, based on a flag, long HPDs are ignored. This flag can be set/unset using debugfs on systems where such panels are connected. 2. In IGT, add provision to set ignore long HPD debugfs entry on the driver and also set Force "on" the active connectors. With force on, the connector's detect sequences will not get initiated. This patch handles the IGT part. An enviroment variable "IGT_KMS_IGNORE_HPD" is added to differentiate systems which require such spurious HPD handling. If this variable is on, ignore long HPD debugs entry is set and active connectors are set to force "on" state. Many thanks to "Imre Deak" for the suggestions and support v2: Minor updates in the comments. v3: Updates to commit texts (Kamil) Cc: Imre Deak Signed-off-by: Vinod Govindapillai --- lib/igt_kms.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 8c7dd85b..24b7622a 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -2390,6 +2390,54 @@ static bool igt_pipe_has_valid_output(igt_display_t *display, enum pipe pipe) return false; } +/** + * igt_handle_spurious_hpd: + * @display: a pointer to igt_display_t structure + * + * Handle environment variable "IGT_KMS_IGNORE_HPD" to manage the spurious + * HPD cases in CI systems where such spurious HPDs are generated by the + * panels without any specific reasons and cause CI execution failures. + * + * This will set the i915_ignore_long_hpd debugfs entry to 1 as a cue for + * the driver to start ignoring the HPDs. + * + * Also, this will set the active connectors' force status to "on" + * so that dp/hdmi_detect routines don't get called frequently. + * + * Force status is kept on after this until it is manually reset. + */ +static void igt_handle_spurious_hpd(igt_display_t *display) +{ + igt_output_t *output; + + /* Proceed with spurious HPD handling only if the env var is set */ + if (!getenv("IGT_KMS_IGNORE_HPD")) + return; + + /* Set the ignore HPD for the driver */ + if (!igt_ignore_long_hpd(display->drm_fd, true)) { + igt_info("Unable set the ignore HPD debugfs entry \n"); + return; + } + + for_each_connected_output(display, output) { + drmModeConnector *conn = output->config.connector; + + if (!force_connector(display->drm_fd, conn, "on")) { + igt_info("Unable to force state on %s-%d\n", + kmstest_connector_type_str(conn->connector_type), + conn->connector_type_id); + continue; + } + + igt_info("Force connector ON for %s-%d\n", + kmstest_connector_type_str(conn->connector_type), + conn->connector_type_id); + } + + dump_forced_connectors(); +} + /** * igt_display_require: * @display: a pointer to an initialized #igt_display_t structure @@ -2713,11 +2761,15 @@ void igt_display_require(igt_display_t *display, int drm_fd) out: LOG_UNINDENT(display); - if (display->n_pipes && display->n_outputs) + if (display->n_pipes && display->n_outputs) { igt_enable_connectors(drm_fd); - else + + igt_handle_spurious_hpd(display); + } + else { igt_skip("No KMS driver or no outputs, pipes: %d, outputs: %d\n", display->n_pipes, display->n_outputs); + } } /** -- 2.34.1