From patchwork Tue Sep 24 07:36:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 1988799 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XCWsL10jHz1xst for ; Tue, 24 Sep 2024 17:37:10 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1st06Y-0003k2-JF; Tue, 24 Sep 2024 07:37:02 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1st06S-0003g7-9V for kernel-team@lists.ubuntu.com; Tue, 24 Sep 2024 07:36:56 +0000 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 223673F129 for ; Tue, 24 Sep 2024 07:36:56 +0000 (UTC) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-206f405f453so54486235ad.1 for ; Tue, 24 Sep 2024 00:36:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727163414; x=1727768214; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x/0rXFu0KBcNgdfrDPwXeTDxAr5wKn/x3L6M22BlqJE=; b=cteqruxdQjrshiDYcXwF+gCwE929NUQ/THQOGqbkmKTYXQUs/OhmCnXcqeQP9HfmXi KUjMZE4p/NryrfqAaFlMQlGUQqeRYODSzw6n0KYPMVYFdpvZK2bMV2aFmvJLHyj83G3X F9xKmgDX0llDMQ5GupYuDrSc5Olic0rVk0LvpKpls5L4tWrEAZsnTgfU/PoxT3HYfcnf +AZRiOksU7GEXE0oxu3+mkcW8M996JtbNxEO/gksgtAsuKe5ItnbCB4AzZCRiGOyakc6 kElOuSRifPUXTDB1CDj7n3StmDhQe0haoQQSsvMntb/cTk1XE/HQthAzKjjMsilW3prS nYww== X-Gm-Message-State: AOJu0Yy5Fxoq7VP9o4T/GX1PSEHjIeXYNkpWDOIP/q9iRF1iMXUvqkwb 1A49Lf9ZsRZkp4Z5r2jg3VmpPnvJCjmeVuc7WmuuhIRWKSUB9ryqlqKJDFLJR5/v+vRPI1vRdhT MUEEirfLnF8KsJIGEkMg1lQdJob28K3BGYfFl3bZwo3kpSSjBE9CJbLxNh0Gt1EoZp9enh1i3Ti P6yeDjLhAHGw== X-Received: by 2002:a17:902:6b02:b0:206:c776:4f04 with SMTP id d9443c01a7336-208d83fcc22mr155324735ad.42.1727163414480; Tue, 24 Sep 2024 00:36:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwIb4iH8vSMTZ19M4w4+y/kufn2vXkem3MFwrJ4aEQYL2E7yad2QJtrfNqgx6fZjlvbs7h2A== X-Received: by 2002:a17:902:6b02:b0:206:c776:4f04 with SMTP id d9443c01a7336-208d83fcc22mr155324605ad.42.1727163413995; Tue, 24 Sep 2024 00:36:53 -0700 (PDT) Received: from localhost.localdomain (114-36-223-64.dynamic-ip.hinet.net. [114.36.223.64]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20af1863562sm5581595ad.298.2024.09.24.00.36.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 00:36:53 -0700 (PDT) From: Chris Chiu To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH 3/3] drm/i915/dp_mst: Fix MST state after a sink reset Date: Tue, 24 Sep 2024 15:36:46 +0800 Message-Id: <20240924073646.1036150-4-chris.chiu@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924073646.1036150-1-chris.chiu@canonical.com> References: <20240924073646.1036150-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Imre Deak BugLink: https://bugs.launchpad.net/bugs/2081786 In some cases the sink can reset itself after it was configured into MST mode, without the driver noticing the disconnected state. For instance the reset may happen in the middle of a modeset, or the (long) HPD pulse generated may be not long enough for the encoder detect handler to observe the HPD's deasserted state. In this case the sink's DPCD register programmed to enable MST will be reset, while the driver still assumes MST is still enabled. Detect this condition, which will tear down and recreate/re-enable the MST topology. v2: - Add a code comment about adjusting the expected DP_MSTM_CTRL register value for SST + SideBand. (Suraj, Jani) - Print a debug message about detecting the link reset. (Jani) - Verify the DPCD MST state only if it wasn't already determined that the sink is disconnected. Cc: stable@vger.kernel.org Cc: Jani Nikula Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11195 Reviewed-by: Suraj Kandpal (v1) Signed-off-by: Imre Deak Link: https://patchwork.freedesktop.org/patch/msgid/20240823162918.1211875-1-imre.deak@intel.com (backported from commit 594cf78dc36f31c0c7e0de4567e644f406d46bae) [Chris Chiu: remove un-necessary intel_dp_mst_prepare_probe()] Signed-off-by: Chris Chiu --- drivers/gpu/drm/i915/display/intel_dp.c | 12 +++++++ drivers/gpu/drm/i915/display/intel_dp_mst.c | 40 +++++++++++++++++++++ drivers/gpu/drm/i915/display/intel_dp_mst.h | 1 + 3 files changed, 53 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index 75a5ace58b80..424b449ddd13 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -5702,6 +5702,18 @@ intel_dp_detect(struct drm_connector *connector, else status = connector_status_disconnected; + if (status != connector_status_disconnected && + !intel_dp_mst_verify_dpcd_state(intel_dp)) + /* + * This requires retrying detection for instance to re-enable + * the MST mode that got reset via a long HPD pulse. The retry + * will happen either via the hotplug handler's retry logic, + * ensured by setting the connector here to SST/disconnected, + * or via a userspace connector probing in response to the + * hotplug uevent sent when removing the MST connectors. + */ + status = connector_status_disconnected; + if (status == connector_status_disconnected) { memset(&intel_dp->compliance, 0, sizeof(intel_dp->compliance)); memset(intel_connector->dp.dsc_dpcd, 0, sizeof(intel_connector->dp.dsc_dpcd)); diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c index e0f171012fcb..c64f82557233 100644 --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c @@ -1872,3 +1872,43 @@ bool intel_dp_mst_crtc_needs_modeset(struct intel_atomic_state *state, return false; } + +/* + * intel_dp_mst_verify_dpcd_state - verify the MST SW enabled state wrt. the DPCD + * @intel_dp: DP port object + * + * Verify if @intel_dp's MST enabled SW state matches the corresponding DPCD + * state. A long HPD pulse - not long enough to be detected as a disconnected + * state - could've reset the DPCD state, which requires tearing + * down/recreating the MST topology. + * + * Returns %true if the SW MST enabled and DPCD states match, %false + * otherwise. + */ +bool intel_dp_mst_verify_dpcd_state(struct intel_dp *intel_dp) +{ + struct intel_display *display = to_intel_display(intel_dp); + struct intel_connector *connector = intel_dp->attached_connector; + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); + struct intel_encoder *encoder = &dig_port->base; + int ret; + u8 val; + + if (!intel_dp->is_mst) + return true; + + ret = drm_dp_dpcd_readb(intel_dp->mst_mgr.aux, DP_MSTM_CTRL, &val); + + /* Adjust the expected register value for SST + SideBand. */ + if (ret < 0 || val != (DP_MST_EN | DP_UP_REQ_EN | DP_UPSTREAM_IS_SRC)) { + drm_dbg_kms(display->drm, + "[CONNECTOR:%d:%s][ENCODER:%d:%s] MST mode got reset, removing topology (ret=%d, ctrl=0x%02x)\n", + connector->base.base.id, connector->base.name, + encoder->base.base.id, encoder->base.name, + ret, val); + + return false; + } + + return true; +} diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.h b/drivers/gpu/drm/i915/display/intel_dp_mst.h index 8ca1d599091c..9e4c7679f1c3 100644 --- a/drivers/gpu/drm/i915/display/intel_dp_mst.h +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.h @@ -27,5 +27,6 @@ int intel_dp_mst_atomic_check_link(struct intel_atomic_state *state, struct intel_link_bw_limits *limits); bool intel_dp_mst_crtc_needs_modeset(struct intel_atomic_state *state, struct intel_crtc *crtc); +bool intel_dp_mst_verify_dpcd_state(struct intel_dp *intel_dp); #endif /* __INTEL_DP_MST_H__ */