From nobody Thu Oct 2 03:27:32 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 5225A30F546 for ; Tue, 23 Sep 2025 06:23:19 +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=1758608599; cv=none; b=LWQT4T2Bn4OImk91BeAfWy0oCO1UG0mcoc3I+olCppOq+yKx7nUq+WW/c9PwvSw0ruTDZb4+4vKIcageqhQpPMuANWFxns8X7fzdqRTxApRdGwF5X6h+HMM5B3iCRJkrrySGPSvHLtn8RsErjHRvnIdb9Lb/4Jw6UB1c8ZGzs7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758608599; c=relaxed/simple; bh=2Phu2egmghoPfL6y1RTRkWn4vN4ATsYrUz9yWVyMvvc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DM2FxX++Cb/3Z5oqkFeVBw0+ELrBh9N4nmY9bT1KbY97dAq6ZVZEnVWayVEE4Ed7dRJOF8C4ml1RV0rElCVNinlNF3rgYXhEd3W0fXRZCteWmAv7pU1FGCGxdv7vTR3LhX5sKEM0H0wdn/ymxGmi8guk2pxqMSql8oTRgJkkzos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cQo/YsiW; 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="cQo/YsiW" Received: by smtp.kernel.org (Postfix) with ESMTPS id E3D18C116B1; Tue, 23 Sep 2025 06:23:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758608599; bh=2Phu2egmghoPfL6y1RTRkWn4vN4ATsYrUz9yWVyMvvc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cQo/YsiWa2tejcSwS7Zz45gLFdTuk/1yOJM1PDMTSsUje1cIg3q6JhLx30OUSqYGG rwGMZTUNfP1+dmvcAH1L/dyzJ26HshKP+EEiYeAphYsEt+IhLVSKt9qxFQ16QYZDKK DeGph1SWuhfJ5z6Qp7YgCUY7Ff0ET8y0r+W7F+iv6+1HcHyidryRBkcXDmRTto/XYr dhTuOwkmhvmFmLXLFKi6y4WuVMIIQsdrQJQUjEGVKJe4RfmpSaCSELFwhYrtXYxDXR 93wyK0KPO9dKpjqS//9wiF9tszNky+GXNP/aBB2z560/E8R6+n+JXE0jgMyzPXvM7M tJK0RS4/PVjlg== 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 D27A4CAC5A5; Tue, 23 Sep 2025 06:23:18 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Tue, 23 Sep 2025 14:23:41 +0800 Subject: [PATCH v4 1/4] 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: <20250923-fix-link-training-v4-1-7c18f5d3891e@ite.com.tw> References: <20250923-fix-link-training-v4-0-7c18f5d3891e@ite.com.tw> In-Reply-To: <20250923-fix-link-training-v4-0-7c18f5d3891e@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 , AngeloGioacchino Del Regno , Allen Chen , Hermes Wu 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 , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1758608643; l=1890; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=qgBUHkzuf4hAHpGTg2Rk6XpngHItzj84KgxjHfNDNYQ=; b=8MEYUYtNzt1UrC9NDCNt1Zln0R2+1n3rBKsdQP9iyuRSlQcL7uyzqyrcLP75cbwQ3y60gorEi ZNNZjxr6gyLCWsAupEuGiqORx9jEv3sE7XaVc2KrjymOi2BHUpZn5w0 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. Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") Reviewed-by: Dmitry Baryshkov Signed-off-by: Hermes Wu --- 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 03:27:32 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 6282D30F549 for ; Tue, 23 Sep 2025 06:23:19 +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=1758608599; cv=none; b=OwHGZgOshTQOQoPZY/0dOy2aZw/5ksZTD6JwAXzATf4PO3+kwM/FgoivlzmvOV7Z4eTcsNieq1rkN/nYzM3seG/Cgkhn83gjKxZZoGXs3D2spBv//DCsBmx3x/LKIxtKvW6moBcZLAODodXoXFFh12NddFE3LQzbtBVvru1sUOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758608599; c=relaxed/simple; bh=3T0yczr8TB2m6N5nAkwbEWrdKvje7HKixCcAVKSkNIc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rJRcSIeJYTtWFri8QXE9ZnAcPiYsCrh8ZdCGWXqMtGyyV9IUWCwKfdLDaDbSsXF6sQSifflZWbd5Xn0dXSQrFHUH2z3CMV11nsE19EOEEk7/k85HRv04IPCXwRa1WWgF1outRSzsnfW8ftLKSAauQ0uU03caNSX9mo6hnB8jgyY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SRLpyUmJ; 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="SRLpyUmJ" Received: by smtp.kernel.org (Postfix) with ESMTPS id F2122C4CEF7; Tue, 23 Sep 2025 06:23:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758608599; bh=3T0yczr8TB2m6N5nAkwbEWrdKvje7HKixCcAVKSkNIc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=SRLpyUmJfbFEdJQu2EdCKiIaSKV5WaYmnmHgGHXkZDEfoGLx+mlo4GGTCfxMVOhHk XwvlmlLx13lcxeUacbSklXVhwGrS8J9XNJ6i+YcRXMJkWJAYsfDKFR8n3E3lwa5BTp 1dJCYzs5O9DAr9udNycHCswGrhPETXDgmzAk2G4GEbja5mXK1CsO8z1SHwoNVXeYdk BMvWFTR9Mo3kwiVHsvoQdR9Kmh82n6IEWBF91IC9EhAGc2phQm+DanuPMnSINo7axR qL5ZyJx/ugBQWyfV22JpZCh/ji9lPjT69q+7RUpui+36QYM6IWP4seC/4i8c+RqwtO 4IvFs2oNOxkNQ== 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 E2572CAC5B1; Tue, 23 Sep 2025 06:23:18 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Tue, 23 Sep 2025 14:23:42 +0800 Subject: [PATCH v4 2/4] drm/bridge: it6505: add INT status check 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: <20250923-fix-link-training-v4-2-7c18f5d3891e@ite.com.tw> References: <20250923-fix-link-training-v4-0-7c18f5d3891e@ite.com.tw> In-Reply-To: <20250923-fix-link-training-v4-0-7c18f5d3891e@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 , AngeloGioacchino Del Regno , Allen Chen , Hermes Wu 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=1758608643; l=4260; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=rwRZdmFdmrU1FhWpEwDA7kOBSoYE4/nfSqSQTPeMCi0=; b=poEtWQy7mhu+Z/LCibk4wk/XwpT46+hYyVohtyt7gXykgRDGyxHCH7RoU8Uf6WtyHklIdvt5K F6fC4MKcmWcD+4Zn/NZR567H3L+Qq4Zyn0kYTfI+213JaVCue4FDU6L 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. IT6505 HW auto 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. when start link auto training, 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 Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/ite-it6505.c | 38 ++++++++++++++++++++++++++-------= ---- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index b47042dc06bb1e1dfd92bc0dc6d69dc918a140ba..f9b99c70789eea6beb3c6513155= c9a4ca103d219 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,8 +1802,17 @@ static bool it6505_link_start_auto_train(struct it65= 05 *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); + + /* 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*/ @@ -1814,6 +1823,19 @@ 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)) { + /* Ignore INT_VID_FIFO_ERROR when auto training fail*/ + it6505_write(it6505, INT_STATUS_03, + BIT(INT_LINK_TRAIN_FAIL) | + BIT(INT_VID_FIFO_ERROR)); + + DRM_DEV_DEBUG_DRIVER(dev, + "INT_LINK_TRAIN_FAIL(%x)!", + int03); + + break; + } =20 if (link_training_state > 0 && (link_training_state & LINK_STATE_NORP)) { @@ -1824,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; @@ -2693,14 +2718,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 +2782,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 03:27:32 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 6289E30F54A for ; Tue, 23 Sep 2025 06:23:19 +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=1758608599; cv=none; b=ZkJWJ4xNfBoG7a0iFU3TW7hgI8o1Avcu3ofbRjGDpYbKt6bWsD/u1UoFCC9kEk1xcWwAjpHkWect2rIihdBH4RD5uCQrQtEY3klqsSvbNmz4itSZs1GDjFs6hBObeMaYV/DRbkZM1neiwM4xCDXmgP2UXReavB7GlEBfCKzBKAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758608599; c=relaxed/simple; bh=xyeGddU8HV7f9Dpf8HpwJptt9/1K5HGt8xU0CjdPxEo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=glsIUsEFUWqg41/AOe+a9yJXFbVVyrFuvnIjHBGg9VOivOYX7YDkEHgWmOGN1I7U87RTySxXbCZq/bDVuWMjT/CovG9lz/Wx0VgAAZyFjpZ57vwo/vAOYMpBJDhSrNZku1CAbg6YhrU+rXUHBR+QkM8Wnq2rmYdb28L5n6epSQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eysGKJ+D; 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="eysGKJ+D" Received: by smtp.kernel.org (Postfix) with ESMTPS id 07BBBC16AAE; Tue, 23 Sep 2025 06:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758608599; bh=xyeGddU8HV7f9Dpf8HpwJptt9/1K5HGt8xU0CjdPxEo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=eysGKJ+Dif31eN5di0SzH+oLsEtzZB/QToH+b1p1N87ZED7fAfyLbIfXxSOLi/6Uk dx/222siDfJKNgZFpSX5Pj+E02qQrIlLcjuGMWU2e2khysL5N/YVn6Uce1sEwGylAf NJWXlgrZUd/3KHmS+fTN0wvBtaevF9AdpIbn51GP55Pm8YXwY0gEBjlg7dZd+9FJ0E KGk4dlU6pmhghtIiclJAStLoTZG/koBAN+AyO+tXTcNOpQGH3WkpHMvkS+ilOW+woO KB+L8TTJq/n9l07qonwMavHWfP/rRISP43HcS6+33G+2TVOcgn0VBrMvW0vn4I/9Rz DtCFHfw8ucXmg== 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 F155ACAC5A7; Tue, 23 Sep 2025 06:23:18 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Tue, 23 Sep 2025 14:23:43 +0800 Subject: [PATCH v4 3/4] 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: <20250923-fix-link-training-v4-3-7c18f5d3891e@ite.com.tw> References: <20250923-fix-link-training-v4-0-7c18f5d3891e@ite.com.tw> In-Reply-To: <20250923-fix-link-training-v4-0-7c18f5d3891e@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 , AngeloGioacchino Del Regno , Allen Chen , Hermes Wu 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 , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1758608643; l=4440; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=aNgX8ku/g4Npw+XBkXl6a6rbjnMD1KIDhBrcFoowf7Q=; b=6iVQ3WRxt+eduB8Aurtfy0iGusCK+mvOmhDQaMiHl/MtO2YAKGgPSj8I1Xfrg0QQIRtYvRosp WeeGBqdS13uAbsu1YcQsIhxQNFvqz072WTmbo1PAspPMggcV5L+6+e3 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 start with auto training and after auto training failed "AUTO_TRAIN_RETRY" times, it switch to step training mode. It will more efficiency that finish link tranining without 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. Reviewed-by: Dmitry Baryshkov Signed-off-by: Hermes Wu --- 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 03:27:32 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 627B230F547 for ; Tue, 23 Sep 2025 06:23:19 +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=1758608599; cv=none; b=qJJZHUsJKCpoSg/m9jFpJPgPZOfz4HXyO69syPv6bosVJT7CrpOzKf9gd5GVe4NCTylxMvfJMW+MF2jpJMQ8kQdJomSsRa/nZRmILby/AN6aQ+9bHcOlcZ6zv/jIA319iisLM7EM978li8AO3bPHGMShwjLDiOv09xpHcfuyxJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758608599; c=relaxed/simple; bh=cWnQGLilBBjKI7djoZVI5Gg96hkxeT4tcLnwx4uRXx0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kD9F6jb9hmHQQq2nLvpyDl+AEZFIQ3eyr3bxL9d/Ud8SM/CiMUZpZxSyZ76m4Dn9YDZVw2+/62EUuzMXx4wtXzlZSUR8UMP8J14z5kyfLFCVn55LgMoymr9GNL+z242kn7l8fkCDobjiYzWOoX+P36AmNtc4oyYtas8tBZzPsw4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EAeGrsMX; 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="EAeGrsMX" Received: by smtp.kernel.org (Postfix) with ESMTPS id 15A71C116C6; Tue, 23 Sep 2025 06:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758608599; bh=cWnQGLilBBjKI7djoZVI5Gg96hkxeT4tcLnwx4uRXx0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=EAeGrsMXHhz79Qp/w9ZqHVg5CI00AnbMrpKh2+CsvUZhbD3frXpHZy/B4gFK4kZ3O LW4m3jFmZYRXg8AhsFbm6luwSYIMfymoh/f//UXhkfFGYY2VsBNQ/pLNcuTQBqaAey JMSx0mTR4ianCGZB2z4Rv7RBcqsMcAjcOD13UXbM3kb66KqLIk3JoEWmA+RHEetAui zDJLPIlhSCYCGySKxlpOMylHJeZHqVSAjRlRHm6fSERn55qnYzOt/KZiy7vsaZ7pBg +HiBhsyrYSePdmipXUOUC4/FN7YhYnmkCbuJRavbpjMiesogluo5JN4ePI80zuNOFa H1PVrKroqV6yw== 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 0B8FBCAC5B3; Tue, 23 Sep 2025 06:23:19 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Tue, 23 Sep 2025 14:23:44 +0800 Subject: [PATCH v4 4/4] 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: <20250923-fix-link-training-v4-4-7c18f5d3891e@ite.com.tw> References: <20250923-fix-link-training-v4-0-7c18f5d3891e@ite.com.tw> In-Reply-To: <20250923-fix-link-training-v4-0-7c18f5d3891e@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 , AngeloGioacchino Del Regno , Allen Chen , Hermes Wu 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=1758608643; l=2348; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=J5b5WPJ7hvbZmjjTr9M8fRPj8438cxaJVtGe5HFZY60=; b=Sx8vlMWf/s/oSkfadrua/DXzQHvxStMg/UTBAmsB3GzAyYR5hPbUBZCFhQJ7U7BzNBUyZ/hLg HlTbYt489+nADZqnk5Kc7FeJBqtMDgDF/TLeQO6VucCu4qcYBTTLjvd 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 that can only training done by step training, skip auto training when link training restart before unplug device. The driver performs a full cycle of attempting auto link training and then manual link training on each modeset. Save time by skipping the auto training if it failed previously for this monitor Signed-off-by: Hermes Wu Reviewed-by: Dmitry Baryshkov --- 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