From nobody Sat Feb 7 15:26:34 2026 Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19B4C33A008 for ; Tue, 6 Jan 2026 17:02:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767718951; cv=none; b=lBYmrx2jmJ2eAQQ6MSxMD+Td8SfPC8KJ9IGlNxJ5hvpXR/mQa/qGtLKl32MD2KOIXUpggBK5Pmbcf+bNvMlCggHolxCiIIekTuCYkmiWf/9VuHcaTmoL0IM3KMOk2uLEqp/H5YKEnfhurGz5qyNSF8BIxrbgT3L9a273xEpgunI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767718951; c=relaxed/simple; bh=I3KNYxT+fXdhIqzKLtsjIt8o8F1mB/+g/X3g5/chlAw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rEelzHstRYdVRi8739EzFjNTpIpQG0u8d7RD3Un7Gd2jeosNPKQS80z3lnldv2PtxiO02lCazVkji1vRYVHA/LXmEwyErvooSU3S72DEFDTbIf3DsXcIhIGaZfPyP/lMjxF7NhULw8ViYrR6ZITOWX/BGPq60c57FwNRkNzTjzc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=o35fJd3z; arc=none smtp.client-ip=95.215.58.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="o35fJd3z" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1767718948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=946vhw3zYbTSZObcCUOe4GKWrWXeYCq7idjeOFNDEeY=; b=o35fJd3zIcYk31Cd2zMQUz6uySvXFmA91qZ5gqowY7rbrPgSwiJdqGEolZlI4dKkAxmK6j Xpho1j0GvMOuKOGzrveF0lRfGboFfmlKAYbEOClmCnishJKwFx1sKy3d7AHqoQMgpPh0ww +0kbpYOLWxtoFCbQSAVAq5Ic2rezZk4= From: Sean Anderson To: Laurent Pinchart , Tomi Valkeinen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org Cc: David Airlie , Michal Simek , Simona Vetter , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sean Anderson Subject: [PATCH v3 3/3] drm: zynqmp_dp: Retrain link after HPD if necessary Date: Tue, 6 Jan 2026 12:01:36 -0500 Message-Id: <20260106170136.501044-4-sean.anderson@linux.dev> In-Reply-To: <20260106170136.501044-1-sean.anderson@linux.dev> References: <20260106170136.501044-1-sean.anderson@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Section 5.1.4 of the v1.2 DisplayPort standard says > The Source device shall respond to Hot Plug event/Hot Re-plug event by > first reading DPCD Link/Sink Device Status registers at DPCD 00200h > through 00205h.... If the link is unstable or lost, the Source device > then reads the DPCD Receiver Capabilities registers at DPCD 00000h > through 0000Fh to determine the appropriate information needed to > train the link. The Source device shall then initiate link training. However, zynqmp_dp_hpd_work_func does not check the link status. This may prevent the sink from detecting the source if, for example, the user disconnects the cable and then reconnects it. I encountered this problem when testing a mini DP connector (although I had no problem when using a full-size connector with the existing driver). Follow the spec by checking the link status after a HPD event and retraining if necessary. Simplify the condition a bit since drm_dp_channel_eq_ok checks a superset of drm_dp_clock_recovery_ok. Fixes: d76271d22694 ("drm: xlnx: DRM/KMS driver for Xilinx ZynqMP DisplayPo= rt Subsystem") Signed-off-by: Sean Anderson --- Changes in v3: - Simplify HPD retrain condition Changes in v2: - needs_retain -> needs_retrain - Actually retrain the loop (accidentally removed while rebasing) drivers/gpu/drm/xlnx/zynqmp_dp.c | 36 +++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp= _dp.c index caf2e0ce3644..c7b31bb10276 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c @@ -1677,6 +1677,22 @@ static int zynqmp_dp_bridge_atomic_check(struct drm_= bridge *bridge, return 0; } =20 +static bool zynqmp_hpd_needs_retrain(struct zynqmp_dp *dp) +{ + u8 status[DP_LINK_STATUS_SIZE + 2]; + int err; + + err =3D drm_dp_dpcd_read(&dp->aux, DP_SINK_COUNT, status, + DP_LINK_STATUS_SIZE + 2); + if (err < 0) { + dev_dbg_ratelimited(dp->dev, + "could not read sink status: %d\n", err); + return false; + } + + return !drm_dp_channel_eq_ok(&status[2], dp->mode.lane_cnt); +} + static enum drm_connector_status __zynqmp_dp_bridge_detect(struct zynqmp_d= p *dp) { struct zynqmp_dp_link_config *link_config =3D &dp->link_config; @@ -1698,6 +1714,9 @@ static enum drm_connector_status __zynqmp_dp_bridge_d= etect(struct zynqmp_dp *dp) =20 if (state & ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_HPD) { WRITE_ONCE(dp->status, connector_status_connected); + if (!zynqmp_hpd_needs_retrain(dp)) + return connector_status_connected; + ret =3D drm_dp_dpcd_read(&dp->aux, 0x0, dp->dpcd, sizeof(dp->dpcd)); if (ret < 0) { @@ -1712,6 +1731,7 @@ static enum drm_connector_status __zynqmp_dp_bridge_d= etect(struct zynqmp_dp *dp) drm_dp_max_lane_count(dp->dpcd), dp->num_lanes); =20 + zynqmp_dp_train_loop(dp); return connector_status_connected; } =20 @@ -2335,25 +2355,13 @@ static void zynqmp_dp_hpd_irq_work_func(struct work= _struct *work) { struct zynqmp_dp *dp =3D container_of(work, struct zynqmp_dp, hpd_irq_work); - u8 status[DP_LINK_STATUS_SIZE + 2]; - int err; =20 guard(mutex)(&dp->lock); if (dp->ignore_hpd) return; =20 - err =3D drm_dp_dpcd_read(&dp->aux, DP_SINK_COUNT, status, - DP_LINK_STATUS_SIZE + 2); - if (err < 0) { - dev_dbg_ratelimited(dp->dev, - "could not read sink status: %d\n", err); - } else { - if (status[4] & DP_LINK_STATUS_UPDATED || - !drm_dp_clock_recovery_ok(&status[2], dp->mode.lane_cnt) || - !drm_dp_channel_eq_ok(&status[2], dp->mode.lane_cnt)) { - zynqmp_dp_train_loop(dp); - } - } + if (zynqmp_hpd_needs_retrain(dp)) + zynqmp_dp_train_loop(dp); } =20 static irqreturn_t zynqmp_dp_irq_handler(int irq, void *data) --=20 2.35.1.1320.gc452695387.dirty