From nobody Thu Oct 2 14:26:16 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 23E1A21B9DB for ; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757998064; cv=none; b=kR2ER4IRZqnH3QXbdq4LQm5yB8KtPEoEeGwY2T7D/tYkb8KCDgFvg2UGhbHx+KKKQUnL5xKDoGcFq6uPlUX1g7t16491KtpeEPzXanqVBWeY2ZhZDHQpd+thFAd/dQWoODOQdnjbpNRHu01JIvhE7RBWF8KcThXW+Uwij5emV+Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757998064; c=relaxed/simple; bh=zEgF7zl+qaVDn5TiUTBaHD0fanWnAVJNnO4sgNc2+7E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IAM2nMNvUBgtcTpRlo3ow7LsqKpvPBrJhFokdymGfztB4grnMELXmltyEFEIca5ZR713+sdPs8Htze7DJI7+bJgzuby/H7lS28uaQFZ+/Gbnuf9735FOvmGqVo2etH1xa+37YVx7yYLGTxpTpJZcn6UR9hYbRV+UHq/Mc3y8lIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h+mmapbN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h+mmapbN" Received: by smtp.kernel.org (Postfix) with ESMTPS id BFE75C4CEF7; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757998063; bh=zEgF7zl+qaVDn5TiUTBaHD0fanWnAVJNnO4sgNc2+7E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=h+mmapbNiV0c6avSZsCWxHHzQglVJcd8Un5UG9q1kIXggnsYq+CpA0c7q4WrXy6CY +EKjnXdn9Q525Fgu/vpPXAWQHeQvbQSV5uFN5+rp6hfebTlCVCMowjXGno43FYRTZE 6r4lTSSfMTMm6AfIHkNWG0B0jNwXuYjdgq6N8ydRN3UWQTT+3+9wlxppBbnQ5vjXs9 JFAeuxWSUSyjXRGVJ44D8AMhcZI17HB5kUOE50pNgai3fDdLyRuqbtc0zzKJYW+gYL qNzFnd2Cf8nLkKE6zTjU9mtH0wKRzmbXYkuGKDsWrgoncQHqMQDVGmaQ7Q5s2CFSF8 hG6Q4+7IHYx1A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0E0CCAC592; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Tue, 16 Sep 2025 12:47:41 +0800 Subject: [PATCH RESEND v3 1/5] drm/bridge: it6505: fix link training state HW register reset Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250916-fix-link-training-v3-1-0f55bfdb272a@ite.com.tw> References: <20250916-fix-link-training-v3-0-0f55bfdb272a@ite.com.tw> In-Reply-To: <20250916-fix-link-training-v3-0-0f55bfdb272a@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Pet.Weng@ite.com.tw, Kenneth.Hung@ite.com.tw, treapking@chromium.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757998107; l=1768; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=L0iJ7cK8igir/+LkaX0VG1u/Z4JkZspdyQ1kUW040to=; b=qiDOEQ6FjWuN8gXvTTOIszAJR4zUYvTqBqa/Xyxjd2g2r8MStb5O8B50VGA64jiyuABeZpYil /XJvzLR8TFyD/Db5cwHhe4L/F2nmvnRyMYmyvf1R6aODzv8Wk0xX88P X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=qho5Dawp2WWj9CGyjtJ6/Y10xH8odjRdS6SXDaDAerU= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241230 with auth_id=310 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw From: Hermes Wu When connect to a DP-to-HDMI device which does not connect to HDMI sink, it will report DPCD 00200h with SINK_COUNT =3D "0", and issue HPD_IRQ when SINK_COUNT change to "1". IT6505 can not recive HPD_IRQ before training done and driver will force HW enter training done state when connect to such devices. When HW is force to training done state and restart link training, bits FORCE_RETRAIN and MANUAL_TRAIN at REG_TRAIN_CTRL1 must be set at the same time to reset HW state. Signed-off-by: Hermes Wu Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/ite-it6505.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index 88ef76a37fe6accacdd343839ff2569b31b18ceb..b47042dc06bb1e1dfd92bc0dc6d= 69dc918a140ba 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -1806,7 +1806,9 @@ static bool it6505_link_start_auto_train(struct it650= 5 *it6505) mutex_lock(&it6505->aux_lock); it6505_set_bits(it6505, REG_TRAIN_CTRL0, FORCE_CR_DONE | FORCE_EQ_DONE, 0x00); - it6505_write(it6505, REG_TRAIN_CTRL1, FORCE_RETRAIN); + /* reset link state machine and re start training*/ + it6505_write(it6505, REG_TRAIN_CTRL1, + FORCE_RETRAIN | MANUAL_TRAIN); it6505_write(it6505, REG_TRAIN_CTRL1, AUTO_TRAIN); =20 while (timeout > 0) { @@ -2377,7 +2379,7 @@ static void it6505_stop_link_train(struct it6505 *it6= 505) { it6505->link_state =3D LINK_IDLE; cancel_work_sync(&it6505->link_works); - it6505_write(it6505, REG_TRAIN_CTRL1, FORCE_RETRAIN); + it6505_write(it6505, REG_TRAIN_CTRL1, FORCE_RETRAIN | MANUAL_TRAIN); } =20 static void it6505_link_train_ok(struct it6505 *it6505) --=20 2.34.1 From nobody Thu Oct 2 14:26:16 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 23D3C2135B8 for ; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757998064; cv=none; b=YbVH6UKPDzCGotGRsizqvemYA5fScYERHVBsA6Pqt+BtBHyuoPQjZuBRGLJuROJBsxg74z0pCuDwIZRJ6UEbDA+9rnDsW8Un6k7NZYrQbER44jF7sHYwhVT2zfMXAECLSYCL531i4eVOvApDvT70Jp+E8SWnNWwbsAxsGYIcBk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757998064; c=relaxed/simple; bh=Sv32eWrLlAonnSTDakaOBa/sXD+tsT+ZOUml/oxxLoo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gumJBiPRsy5BzmU8+rU0R3UbJq3/Tvo/OA/aSpQ2gm3ym/oC7b271FLXRZ5J1PmPZmcAZN9636gav/rBuHAzP1eYoTfZW5X4HN47PYhlPZD65Tj+JiIeA1v0HKMC/e3YiG4wRTFwNsDQE5MkQIZSBSYC4X3I3uZlr+7etmBQaYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p2/PYgmo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p2/PYgmo" Received: by smtp.kernel.org (Postfix) with ESMTPS id CD821C4CEFA; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757998063; bh=Sv32eWrLlAonnSTDakaOBa/sXD+tsT+ZOUml/oxxLoo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=p2/PYgmoLWgpsGDdmwnzMt+vIocnncSEBJoOS7zy0Xm3lRCTSR6DOZSY/RJ0KiyKb k7VbVNfS/pta8Qpwq/x6N3Qo8pMeWovULdpRF9+khpDOJ2aHlIZk57uQA4M7Y6cb9B ejJR72oe47seF616hZd+WDzBhLpoICtbtZsI4M+dQ1AGyrqd0UxcaAp4nA3uI2pOJv TVyuzOLOSccJ93BV6/p8jTelIDXTBpig79nN3Hv3jGRHzxPRlLSpLx7pOAAC7FzmL1 QleM4YrDogS1Om/teHRoj4HPN3ZxDMAeD10R04ZHReJPlLnJaFKBVvtyLwyqc5lNr1 sVczqKrEBec9A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE51DCAC59B; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Tue, 16 Sep 2025 12:47:42 +0800 Subject: [PATCH RESEND v3 2/5] drm/bridge: it6505: check INT_LINK_TRAIN_FAIL while link auto training Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250916-fix-link-training-v3-2-0f55bfdb272a@ite.com.tw> References: <20250916-fix-link-training-v3-0-0f55bfdb272a@ite.com.tw> In-Reply-To: <20250916-fix-link-training-v3-0-0f55bfdb272a@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Pet.Weng@ite.com.tw, Kenneth.Hung@ite.com.tw, treapking@chromium.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757998107; l=2919; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=jMRBMAfZXvgPInoi2ZG2fBNx0MmsnJGVHvslLR/IkmI=; b=T9SmPE4rzwxkt7minVSirH2lNbREqXWJrFQAl1Rn6bq7YENYu6/UwsQdADRcRUZKdOVxSHi1o TWYfM6uA304Cj0nsS7HjhchJ1B5+V+Lzk8LJbU10lNvTor2h3z6mdXE X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=qho5Dawp2WWj9CGyjtJ6/Y10xH8odjRdS6SXDaDAerU= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241230 with auth_id=310 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw From: Hermes Wu When start link training, interrupt status INT_LINK_TRAIN_FAIL can use to check link training fail and no need to wait until timeout. it6505_irq_link_train_fail() remove from interrupt and no longer used. Signed-off-by: Hermes Wu Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/ite-it6505.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index b47042dc06bb1e1dfd92bc0dc6d69dc918a140ba..7f6227c278a51358c70a3de9345= 4aafeef64f2bb 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -821,8 +821,8 @@ static void it6505_int_mask_enable(struct it6505 *it650= 5) it6505_write(it6505, INT_MASK_02, BIT(INT_AUX_CMD_FAIL) | BIT(INT_HDCP_KSV_CHECK) | BIT(INT_AUDIO_FIFO_ERROR)); =20 - it6505_write(it6505, INT_MASK_03, BIT(INT_LINK_TRAIN_FAIL) | - BIT(INT_VID_FIFO_ERROR) | BIT(INT_IO_LATCH_FIFO_OVERFLOW)); + it6505_write(it6505, INT_MASK_03, BIT(INT_VID_FIFO_ERROR) | + BIT(INT_IO_LATCH_FIFO_OVERFLOW)); } =20 static void it6505_int_mask_disable(struct it6505 *it6505) @@ -1802,6 +1802,8 @@ static bool it6505_link_start_auto_train(struct it650= 5 *it6505) { int timeout =3D 500, link_training_state; bool state =3D false; + int int03; + struct device *dev =3D it6505->dev; =20 mutex_lock(&it6505->aux_lock); it6505_set_bits(it6505, REG_TRAIN_CTRL0, @@ -1814,6 +1816,17 @@ static bool it6505_link_start_auto_train(struct it65= 05 *it6505) while (timeout > 0) { usleep_range(1000, 2000); link_training_state =3D it6505_read(it6505, REG_LINK_TRAIN_STS); + int03 =3D it6505_read(it6505, INT_STATUS_03); + if (int03 & BIT(INT_LINK_TRAIN_FAIL)) { + it6505_write(it6505, INT_STATUS_03, + BIT(INT_LINK_TRAIN_FAIL)); + + DRM_DEV_DEBUG_DRIVER(dev, + "INT_LINK_TRAIN_FAIL(%x)!", + int03); + + break; + } =20 if (link_training_state > 0 && (link_training_state & LINK_STATE_NORP)) { @@ -2693,14 +2706,6 @@ static void it6505_irq_audio_fifo_error(struct it650= 5 *it6505) it6505_enable_audio(it6505); } =20 -static void it6505_irq_link_train_fail(struct it6505 *it6505) -{ - struct device *dev =3D it6505->dev; - - DRM_DEV_DEBUG_DRIVER(dev, "link training fail interrupt"); - schedule_work(&it6505->link_works); -} - static bool it6505_test_bit(unsigned int bit, const unsigned int *addr) { return 1 & (addr[bit / BITS_PER_BYTE] >> (bit % BITS_PER_BYTE)); @@ -2765,7 +2770,6 @@ static irqreturn_t it6505_int_threaded_handler(int un= used, void *data) { BIT_INT_AUX_CMD_FAIL, it6505_irq_aux_cmd_fail }, { BIT_INT_HDCP_KSV_CHECK, it6505_irq_hdcp_ksv_check }, { BIT_INT_AUDIO_FIFO_ERROR, it6505_irq_audio_fifo_error }, - { BIT_INT_LINK_TRAIN_FAIL, it6505_irq_link_train_fail }, }; int int_status[3], i; =20 --=20 2.34.1 From nobody Thu Oct 2 14:26:16 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 23DBA21770A for ; Tue, 16 Sep 2025 04:47:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757998064; cv=none; b=OR53bwYIX/8s9eJUR12K6O0dNAjoXiMv7QyXrBPrORFiShMwRVRSSj7F+iuJWU30gS0mY2OKLlTcyJGJexm9yW9aWrb9OFD2Wpjzd+BtGKzDXNDW9Lmog1QLwx+UeH4PgkK/Xh/YpZ/W3J02mfuDOropN9X8T1q4riDSda7LTcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757998064; c=relaxed/simple; bh=y9xM5x/9mDBXXIijOs8N9ZcgaLGefpK4A6S03ho3yEw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u4DFH5oyUV5FzzvqGgtbgH1FYGozM333FUtEjkE1SmhdExzzI5XJlWpawbih65KjIb/03C3ONxYMWmA+xwQYlNO7n+wehmBgMYWO65Z99NQgWP2FPVweGOjzSuQOT4a8CefSnODYTYGFCAMWTYfti0CYrga5Lz0J/k+Uh6Y8e8I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=peU/3QfE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="peU/3QfE" Received: by smtp.kernel.org (Postfix) with ESMTPS id D7FB4C4CEFC; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757998063; bh=y9xM5x/9mDBXXIijOs8N9ZcgaLGefpK4A6S03ho3yEw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=peU/3QfEOma4QuTKDgqjflnMzRuHPg5l9jOG5qVjxlA2HU6fe7EJMDU1TsIjJFWJS Vd85rpd/RdZH2oF0AQxiuzmOIn+EuALwP/pA+tF4GymbnA2DBZ4p/QlzuNenHizTJr Dgs/JuhLwFLypfesxSPt8A/NZffInPAO6KRx8aMp0qBgmz0UAgWi7ifgRiDK9YkxU5 LqQajQZKC6hzgrtlayxFU3KK1VkDWFRSOxhGksa/itUEf/cU+LvtMVJ7sNpIWnc2z9 En1p+mqws/PxvTk+fj8GhzehOTyYitg1Y6HUe2u33lwKG9TKmfMWJD4UYocqF44Wg3 PiNDsxmWQmamA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAD4BCAC59E; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Tue, 16 Sep 2025 12:47:43 +0800 Subject: [PATCH RESEND v3 3/5] drm/bridge: it6505: modify DP link auto training Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250916-fix-link-training-v3-3-0f55bfdb272a@ite.com.tw> References: <20250916-fix-link-training-v3-0-0f55bfdb272a@ite.com.tw> In-Reply-To: <20250916-fix-link-training-v3-0-0f55bfdb272a@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Pet.Weng@ite.com.tw, Kenneth.Hung@ite.com.tw, treapking@chromium.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757998107; l=2426; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=w0mjd1b/vD9l754Z7HEk7/mi9+TqCrQ9as279Ea9bf8=; b=IO78MXtKw2LNi4+s8tj6sHGMURIF+yDdF7Kq8Xfe2p+lN6zAV80lQHrkBUlWaC/cDhdEkEomZ CRWoEaKbz+tAMASNTGDAmXuM794aJOBhgpLmeN0213Uduk+FTrY2j9u X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=qho5Dawp2WWj9CGyjtJ6/Y10xH8odjRdS6SXDaDAerU= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241230 with auth_id=310 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw From: Hermes Wu IT6505 supports HW link training which will write DPCD and check training status automatically. In the case that driver set link rate at 2.7G and HW fail to training, it will change link configuration and try 1.65G. And this will cause INT_VID_FIFO_ERROR triggered when link clock is changed. When video error occurs, video logic is reset and link training restart, this will cause endless auto link training. Modify link auto training with disable INT_VID_FIFO_ERROR to avoid loop and check INT_LINK_TRAIN_FAIL event to abort wait training done. Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index 7f6227c278a51358c70a3de93454aafeef64f2bb..f9b99c70789eea6beb3c6513155= c9a4ca103d219 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -1806,6 +1806,13 @@ static bool it6505_link_start_auto_train(struct it65= 05 *it6505) struct device *dev =3D it6505->dev; =20 mutex_lock(&it6505->aux_lock); + + /* Disable FIFO error interrupt trigger */ + /* to prevent training fail loop issue */ + it6505_set_bits(it6505, INT_MASK_03, BIT(INT_VID_FIFO_ERROR), 0); + + it6505_write(it6505, INT_STATUS_03, + BIT(INT_LINK_TRAIN_FAIL) | BIT(INT_VID_FIFO_ERROR)); it6505_set_bits(it6505, REG_TRAIN_CTRL0, FORCE_CR_DONE | FORCE_EQ_DONE, 0x00); /* reset link state machine and re start training*/ @@ -1818,8 +1825,10 @@ static bool it6505_link_start_auto_train(struct it65= 05 *it6505) link_training_state =3D it6505_read(it6505, REG_LINK_TRAIN_STS); int03 =3D it6505_read(it6505, INT_STATUS_03); if (int03 & BIT(INT_LINK_TRAIN_FAIL)) { + /* Ignore INT_VID_FIFO_ERROR when auto training fail*/ it6505_write(it6505, INT_STATUS_03, - BIT(INT_LINK_TRAIN_FAIL)); + BIT(INT_LINK_TRAIN_FAIL) | + BIT(INT_VID_FIFO_ERROR)); =20 DRM_DEV_DEBUG_DRIVER(dev, "INT_LINK_TRAIN_FAIL(%x)!", @@ -1837,6 +1846,9 @@ static bool it6505_link_start_auto_train(struct it650= 5 *it6505) timeout--; } unlock: + /* recover interrupt trigger*/ + it6505_set_bits(it6505, INT_MASK_03, + BIT(INT_VID_FIFO_ERROR), BIT(INT_VID_FIFO_ERROR)); mutex_unlock(&it6505->aux_lock); =20 return state; --=20 2.34.1 From nobody Thu Oct 2 14:26:16 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4DDA92222B4 for ; Tue, 16 Sep 2025 04:47:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757998064; cv=none; b=TeQckirhUIBQZuHqUmPQfrhdTm89O+ZJTVEwngPgQbxVWbT/WrjxdVAf/Vge/MGbR6bHToUDWfyAqc5UcSv9X7dEI8lRPNX5cvP1Ryns1ze/Lg/cXv8QVGCBCHTgBgHKwSx85wHADOvT5b2BEzQpQZDcX06ZSCPfrmxRUNnVZoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757998064; c=relaxed/simple; bh=U307vnMWojAerVe285TOQokdoRu/COAOi7wfwD1JzQ4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h8LLjpxHKNFvbU6vG2ClNIPKiCRPXThh7p7Du2wJ6BIpraqtLAvlfZOojCsec0POzj7yOOP+5e5Efnhz0HzJ94q5ZkH5aerhX1+uOOaUS5BSrR9EexoDa3MQbvQpgng96KGQUYpH7G5+jpND3m+oW9hYHLMeGgyGiZMVV6hJOQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TpCLVeKZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TpCLVeKZ" Received: by smtp.kernel.org (Postfix) with ESMTPS id E3E45C4CEFE; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757998063; bh=U307vnMWojAerVe285TOQokdoRu/COAOi7wfwD1JzQ4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=TpCLVeKZJPYIpZEaAOU4LI/bVz7NMJbiz6TFFi//20jnoUv4Ad4nvIP2Es3/mB5Ln 9gfL7k90Upq9PU81JLtpE8BKutFxNS6VtLfEXmauG/pcg3XB+Und4T6JJpggY2+Bic 4PJ4tMoIQSPPzZuQRwOorep8dMm9wqsqCqubNAkATc11QBfbisSYLnY82cuN40ZIJz F9rKtDJYPbrX8AK2dYPrxAYaxLhcRCmn4Kk1j3L5jHCCEXEkwdBQDMM0LTXrrXdtHo bnI3kB6DkQmHfKFyfJ96hKMx5JqJuqox+sFx5b9znJUXWkK7kQpB0uZkFvqAJmpWiX COpmnJ0M18xwg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9E04CAC59F; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Tue, 16 Sep 2025 12:47:44 +0800 Subject: [PATCH RESEND v3 4/5] drm/bridge: it6505: modify DP link training work Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250916-fix-link-training-v3-4-0f55bfdb272a@ite.com.tw> References: <20250916-fix-link-training-v3-0-0f55bfdb272a@ite.com.tw> In-Reply-To: <20250916-fix-link-training-v3-0-0f55bfdb272a@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Pet.Weng@ite.com.tw, Kenneth.Hung@ite.com.tw, treapking@chromium.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757998107; l=4425; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=TrGpepzaBAnnyoq5JGYSZoDhoJy0fLdUbAxvQi7h/Xg=; b=vS9xwGPTIu7CGMxwxRM5YPSzv5UJGuS/LwLqvNLOpcGY4y5oAl42byrd04Rc9jxdfcdIG2sWD H4Op71hD5GAC9LhhRNrMpyVpzcwx16rACDbTP9TLIZtzQU+TacnlAyr X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=qho5Dawp2WWj9CGyjtJ6/Y10xH8odjRdS6SXDaDAerU= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241230 with auth_id=310 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw From: Hermes Wu The DP link training work include auto training and after auto training failed "AUTO_TRAIN_RETRY" times, it switch to step training mode. It will more efficiency that finish link auto training, include retry, and step training in a work, rather than re-schedule train work when each training fail. Drop auto_train_retry from it6505 structure, and it6505_dump() is remove from link trainig work, it takes too much time to read all register area, and is not necessary. Signed-off-by: Hermes Wu Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/ite-it6505.c | 40 ++++++++++++++-------------------= ---- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index f9b99c70789eea6beb3c6513155c9a4ca103d219..bff5f18fb5ae7192242308f034b= 60af9807c192c 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -467,7 +467,6 @@ struct it6505 { struct delayed_work hdcp_work; struct work_struct hdcp_wait_ksv_list; struct completion extcon_completion; - u8 auto_train_retry; bool hdcp_desired; bool is_repeater; u8 hdcp_down_stream_count; @@ -666,7 +665,7 @@ static int it6505_get_dpcd(struct it6505 *it6505, int o= ffset, u8 *dpcd, int num) return 0; } =20 -static void it6505_dump(struct it6505 *it6505) +static void __maybe_unused it6505_dump(struct it6505 *it6505) { unsigned int i, j; u8 regs[16]; @@ -1399,7 +1398,6 @@ static void it6505_variable_config(struct it6505 *it6= 505) it6505->lane_count =3D MAX_LANE_COUNT; it6505->link_state =3D LINK_IDLE; it6505->hdcp_desired =3D HDCP_DESIRED; - it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; it6505->audio.select =3D AUDIO_SELECT; it6505->audio.sample_rate =3D AUDIO_SAMPLE_RATE; it6505->audio.channel_count =3D AUDIO_CHANNEL_COUNT; @@ -2467,7 +2465,7 @@ static void it6505_link_training_work(struct work_str= uct *work) { struct it6505 *it6505 =3D container_of(work, struct it6505, link_works); struct device *dev =3D it6505->dev; - int ret; + int ret, retry; =20 DRM_DEV_DEBUG_DRIVER(dev, "it6505->sink_count: %d", it6505->sink_count); @@ -2475,27 +2473,22 @@ static void it6505_link_training_work(struct work_s= truct *work) if (!it6505_get_sink_hpd_status(it6505)) return; =20 - it6505_link_training_setup(it6505); - it6505_reset_hdcp(it6505); - it6505_aux_reset(it6505); - - if (it6505->auto_train_retry < 1) { - it6505_link_step_train_process(it6505); - return; - } - - ret =3D it6505_link_start_auto_train(it6505); - DRM_DEV_DEBUG_DRIVER(dev, "auto train %s, auto_train_retry: %d", - ret ? "pass" : "failed", it6505->auto_train_retry); + for (retry =3D AUTO_TRAIN_RETRY; retry > 0; retry--) { + it6505_link_training_setup(it6505); + it6505_reset_hdcp(it6505); + it6505_aux_reset(it6505); =20 - if (ret) { - it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; - it6505_link_train_ok(it6505); - } else { - it6505->auto_train_retry--; - it6505_dump(it6505); + ret =3D it6505_link_start_auto_train(it6505); + DRM_DEV_DEBUG_DRIVER(dev, "auto train %s,", + ret ? "pass" : "failed"); + if (ret) { + it6505_link_train_ok(it6505); + return; + } } =20 + /*After HW auto training fail, try link training step by step*/ + it6505_link_step_train_process(it6505); } =20 static void it6505_plugged_status_to_codec(struct it6505 *it6505) @@ -2576,7 +2569,6 @@ static int it6505_process_hpd_irq(struct it6505 *it65= 05) (int)ARRAY_SIZE(link_status), link_status); =20 if (!drm_dp_channel_eq_ok(link_status, it6505->lane_count)) { - it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; it6505_video_reset(it6505); } =20 @@ -2602,7 +2594,6 @@ static void it6505_irq_hpd(struct it6505 *it6505) it6505_variable_config(it6505); it6505_parse_link_capabilities(it6505); } - it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; =20 it6505_drm_dp_link_set_power(&it6505->aux, &it6505->link, DP_SET_POWER_D0); @@ -2739,7 +2730,6 @@ static void it6505_irq_video_handler(struct it6505 *i= t6505, const int *int_statu (unsigned int *)int_status)) || (it6505_test_bit(BIT_INT_VID_FIFO_ERROR, (unsigned int *)int_status))) { - it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; flush_work(&it6505->link_works); it6505_stop_hdcp(it6505); it6505_video_reset(it6505); --=20 2.34.1 From nobody Thu Oct 2 14:26:16 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7B7F022E3F0 for ; Tue, 16 Sep 2025 04:47:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757998064; cv=none; b=Oc4OL0LTgyleBcC+TqFkR1/Nfw1BTGel6C9bfacFt6sXOsv7r/bNmxjGQUU0cet73V0PObd07eSmHn8ZZJmjAHXKzGyH+2HjNgobiL/SKC7D2yTY8leYfAFB1evYC4OGnq2rT57sJodtUT8qHT2uchrp6H/xipT10j3qlSUS8u8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757998064; c=relaxed/simple; bh=vT4jRgNOKJGO9pduYqW5rUZpbUZTqMnVAbx3caTHA90=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QdOxUp909PXZ3O3W6FChQANP4yTgZiCsTOSoiUBT9GCQHegTrPij0hvD7N/z293yDPWUmcqdpBxNygBNhTytm7yPcDfGVJZ59xq4W5L/PRLJbFCbZk44B4nlGnoTmzfYmdW55tWlC+J0Ytl2d3ZXOrENUWvCEcfhiiDAvEJA4+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YbmqKM+a; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YbmqKM+a" Received: by smtp.kernel.org (Postfix) with ESMTPS id F08E7C4CEF9; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757998064; bh=vT4jRgNOKJGO9pduYqW5rUZpbUZTqMnVAbx3caTHA90=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YbmqKM+aJFiPL/CEkd9DKxwMtH57EeTk3TkqlPvcFOhmMjRQJ77IvAsJ/Nn7UeIG9 R55ZvXf7GQC5fIj6QHz3/EctXKdAnMDadTJwzoltTgeRigr3P3Q44IS8NoC5xjdol5 iIKmxg6OGvW/k5h5+DfXGRl16c+dbVQanItA1z/jjNtvPyuBo1rc2Ywk+Z7agi1Flp aDYR0EXiDujCt8mGx8unxtdzUQt9/kFhL0SYZ4e6TVLXCzu+iUyAGfGXkoGI3IipMj EDzjYtASKvBG+/aiR5HLwem5oOmZ1Z2Kim5TjvrH6vYf0a/LJ2qqQzKTC05AJV/tcx ysLGeJiZbxcmA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9441CAC599; Tue, 16 Sep 2025 04:47:43 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Tue, 16 Sep 2025 12:47:45 +0800 Subject: [PATCH RESEND v3 5/5] drm/bridge: it6505: skip auto training when previous try fail Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250916-fix-link-training-v3-5-0f55bfdb272a@ite.com.tw> References: <20250916-fix-link-training-v3-0-0f55bfdb272a@ite.com.tw> In-Reply-To: <20250916-fix-link-training-v3-0-0f55bfdb272a@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Pet.Weng@ite.com.tw, Kenneth.Hung@ite.com.tw, treapking@chromium.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757998107; l=2181; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=pLytI76dbGjTNwcbsSYeds6mdd5OwXNWVjluMga6s9U=; b=JY8tgX+eYXvPeTbxNaV7UrIwPK91wF7/U5zi8MM9ecEKoV2Bl2728E4KvmmBeAPdGcyAZrKS7 PS+CLxRC/6jDOShl424eq7Mu0xWPm6aPsdfVu2xsvX2W6xKc5+B/AcH X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=qho5Dawp2WWj9CGyjtJ6/Y10xH8odjRdS6SXDaDAerU= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241230 with auth_id=310 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw From: Hermes Wu When connect to device which can only training done by step training, skip auto training when link training restart, usually happen when display resolution is changed. Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index bff5f18fb5ae7192242308f034b60af9807c192c..20eae23cb46a4cb3fc18dd2ed3b= 764f2265262ca 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -467,6 +467,7 @@ struct it6505 { struct delayed_work hdcp_work; struct work_struct hdcp_wait_ksv_list; struct completion extcon_completion; + u8 step_train_only; bool hdcp_desired; bool is_repeater; u8 hdcp_down_stream_count; @@ -2452,11 +2453,13 @@ static void it6505_link_step_train_process(struct i= t6505 *it6505) ret ? "pass" : "failed", i + 1); if (ret) { it6505_link_train_ok(it6505); + it6505->step_train_only =3D true; return; } } =20 DRM_DEV_DEBUG_DRIVER(dev, "training fail"); + it6505->step_train_only =3D false; it6505->link_state =3D LINK_IDLE; it6505_video_reset(it6505); } @@ -2473,14 +2476,14 @@ static void it6505_link_training_work(struct work_s= truct *work) if (!it6505_get_sink_hpd_status(it6505)) return; =20 - for (retry =3D AUTO_TRAIN_RETRY; retry > 0; retry--) { + for (retry =3D AUTO_TRAIN_RETRY; retry > 0 && !it6505->step_train_only; r= etry--) { it6505_link_training_setup(it6505); it6505_reset_hdcp(it6505); it6505_aux_reset(it6505); =20 ret =3D it6505_link_start_auto_train(it6505); DRM_DEV_DEBUG_DRIVER(dev, "auto train %s,", - ret ? "pass" : "failed"); + ret ? "pass" : "failed"); if (ret) { it6505_link_train_ok(it6505); return; @@ -2594,6 +2597,7 @@ static void it6505_irq_hpd(struct it6505 *it6505) it6505_variable_config(it6505); it6505_parse_link_capabilities(it6505); } + it6505->step_train_only =3D false; =20 it6505_drm_dp_link_set_power(&it6505->aux, &it6505->link, DP_SET_POWER_D0); --=20 2.34.1