From nobody Thu Jan 30 17:23:29 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 37A671D47D9 for ; Fri, 24 Jan 2025 02:29:24 +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=1737685765; cv=none; b=XaUqQhCx/dYOV1ll1oCMGmisLaWAYrjQLnooAmB1+kYMKfyV5H5lOujtnKtfZnst2tHPUOaAVSMrpo35cJ+4UY0+A7esq/m6I5IsqoNFQbicmhcSthxltT6FT080QVTzpIEBclFe7u5uwi7+CUdTkbhN5smcaKuQvIJ62NsdPiw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737685765; c=relaxed/simple; bh=B1sdhsClRyrIWFlB2n2+GfiC/tMmbaroZFCL7NTvbC8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ewz81w50QJNr+wY996JByj0aYbzLFBfPrXVEw7kDClvapETWXgX0yrfJY915O+WB8eWvo7s0ctRRpO9YsOqfV751z2GVOhzMglpz8skqpNAesyhfYTAZ6TjCaTJXIvEkbw4zLIX/EvGkoq4+Sz0ZsgPTah3XwyP5cAYi9nZaRbw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H3iO5XNI; 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="H3iO5XNI" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8BF93C4CEE0; Fri, 24 Jan 2025 02:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737685764; bh=B1sdhsClRyrIWFlB2n2+GfiC/tMmbaroZFCL7NTvbC8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=H3iO5XNIPolLutR6lPw+Fitsp6UfdQF7lTVErff170QV4VUGC6uv/bLmLBvF/z1h7 fvRwQFXaqf4jy5m6B6XAkyWdsDe4Br7qYYgPmHVTBt607EzDyHinnnDJX+i1SdTKmY u2iKUfFoUlNMpFi9vfh9NKyNPyNT5fQCeEIbe4qmoEVXumFj/Sf+G+/sbdLIs/HauG 4gVq/nX1jaW//TjGXH1qlvDMgp5HxhZwW930/Z8wKqT5Vaz+zG/ht+9VG9PAoxJQFG iAMgaWJC0sajzz5ScLRU9ORQdx0wyWW+kNHElv6M6njG/2hno6GJq45G6BAFi9M9Dt icKkc2O2hN8Aw== 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 6A7D2C0218C; Fri, 24 Jan 2025 02:29:24 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Fri, 24 Jan 2025 10:29:50 +0800 Subject: [PATCH 1/3] 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: <20250124-fix-link-training-v1-1-09511050bb2c@ite.com.tw> References: <20250124-fix-link-training-v1-0-09511050bb2c@ite.com.tw> In-Reply-To: <20250124-fix-link-training-v1-0-09511050bb2c@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=1737685792; l=4987; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=54tlhkHj+pxYl9kznBsAM5796RL+l7b8tF/1hdi0qzs=; b=FehmlgQ5oHH00ZpCfQpwKs0q4XVm5Hm7rf4IkmcCBcfKqraYkk8CP4VmXOVaaSV/jJ58R/dZ7 yiZWQvKVzlKAM3wdr7NNZsWCZfL1ErcVuzwmiguSMzLhz70mLAejM0C 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. Since INT_LINK_TRAIN_FAIL is checked when auto training, it is remove from it6505_int_threaded_handler() In order to reset HW link auto training state, bits FORCE_RETRAIN and MANUAL_TRAIN at REG_TRAIN_CTRL1 must be set at the same time. Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 61 +++++++++++++++++++++++++--------= ---- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index 88ef76a37fe6accacdd343839ff2569b31b18ceb..dc1179c8338e27866f6adda4ef8= fb2950336221b 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -821,7 +821,7 @@ 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) | + it6505_write(it6505, INT_MASK_03, BIT(INT_VID_FIFO_ERROR) | BIT(INT_IO_LATCH_FIFO_OVERFLOW)); } =20 @@ -1800,30 +1800,62 @@ static void it6505_link_training_setup(struct it650= 5 *it6505) =20 static bool it6505_link_start_auto_train(struct it6505 *it6505) { - int timeout =3D 500, link_training_state; + int link_training_state; bool state =3D false; + struct device *dev =3D it6505->dev; + int int03; + unsigned long timeout; + + guard(mutex)(&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)); + int03 =3D it6505_read(it6505, INT_STATUS_03); =20 - 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) { + timeout =3D jiffies + msecs_to_jiffies(100) + 1; + for (;;) { 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)); + + if (int03 & BIT(INT_VID_FIFO_ERROR)) { + DRM_DEV_DEBUG_DRIVER(dev, + "video fifo error when training fail (%x)!", + int03); + } + + break; + } =20 if (link_training_state > 0 && (link_training_state & LINK_STATE_NORP)) { state =3D true; - goto unlock; + break; } =20 - timeout--; + if (time_after(jiffies, timeout)) + break; } -unlock: - mutex_unlock(&it6505->aux_lock); =20 + /* recover interrupt trigger*/ + it6505_set_bits(it6505, INT_MASK_03, + BIT(INT_VID_FIFO_ERROR), BIT(INT_VID_FIFO_ERROR)); return state; } =20 @@ -2377,7 +2409,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) @@ -2691,14 +2723,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)); @@ -2763,7 +2787,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 Jan 30 17:23:29 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 39C9D1D5146 for ; Fri, 24 Jan 2025 02:29:24 +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=1737685765; cv=none; b=Twc5ms3EXmCt7Hl8ORcbqra9pjksJbNenS/u8OAdArl2mv2ViVizhcx6Mk+n48qYlDoAH7ejsQWDlvKODlMWhgzjNlCZ2hv2cqxX1jCKdG2PjUK3H5wouSWI8MVpmyOVgSDIxVSUUxc48TSoUucu1hgqS3RkUx2sxSgFTn/8Fgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737685765; c=relaxed/simple; bh=XjpJATAQwVIRHRXGlMiNdqzLMiErwOFwlEhNbhbQjwo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=a+ublG3FtT2Jjf6aNlh4N/ejZn0SmD7yn/jpnZWCcFQP72tTddtgXd+uZ2P6h7edKWvdKG26DEq+r4K1yCUl0ItWzH+OB7BX9YNbsDiiWAl7nsvJPtMxIWyTY2uaPvuIAC2BHpo9otIhYBxmrkzAxi83xT2ALJ/ivJkXd6TNxlQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GyRfj3Md; 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="GyRfj3Md" Received: by smtp.kernel.org (Postfix) with ESMTPS id AA7AEC4CEDF; Fri, 24 Jan 2025 02:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737685764; bh=XjpJATAQwVIRHRXGlMiNdqzLMiErwOFwlEhNbhbQjwo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=GyRfj3Md0gpTxYWswN+fkyzY++ZBWi5yqvhmPQherIu5MouSaIEela0X3C0PcsTiR 6yUiQ+xjh7ejMe4aZsXJH/wi7Laz8d13j2tf/SdV/Kj+jPcA8LvhUqxa1NvADzWj5P Ii270V7fYr+bnjg3GLwm3HJu/TXNz2lM6B4hQoR7W4ENyKz8c6F4FXpIkoyqJXK0Yz E/xKjmmW83Cu7YsPAqHR8Tk7IDrCvcatUEQJWZf6mri4tMuMMm0qq83q1W4jdFlA9c SlrnJCX8kDUHIBGGWJVfq8UQmiP5SFEzlxXNCPRu/b3may/K4rJA7MA6Ax4MeqMa1l 3JhQG31xYP1Mg== 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 9EE86C02182; Fri, 24 Jan 2025 02:29:24 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Fri, 24 Jan 2025 10:29:51 +0800 Subject: [PATCH 2/3] 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: <20250124-fix-link-training-v1-2-09511050bb2c@ite.com.tw> References: <20250124-fix-link-training-v1-0-09511050bb2c@ite.com.tw> In-Reply-To: <20250124-fix-link-training-v1-0-09511050bb2c@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=1737685792; l=2681; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=llpaVHPsyMc2Qs3dtoETLe0MUHFLEKcOWtYQxLf0olo=; b=iamjb+1HL6+R3IgsZnzUNIm69ju78BBQPKPnYPhakuDe2N42U4MP2ML4bbyw9+xJ8PiqvX9nG ghR273mWvJuCsjGHrxsoabjbgyMkaiL/L/WHzxh7dmAMKptOIbQT9/4 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. 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 --- drivers/gpu/drm/bridge/ite-it6505.c | 35 ++++++++++++++++-----------------= -- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index dc1179c8338e27866f6adda4ef8fb2950336221b..11231a642bbe185c4f36bf5f2a0= b115fa056213b 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -666,7 +666,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]; @@ -2472,7 +2472,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); @@ -2480,26 +2480,23 @@ 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; - } + retry =3D it6505->auto_train_retry; + do { + 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, auto_train_retry: %d", + 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); + if (ret) { + it6505_link_train_ok(it6505); + return; + } + } while (retry--); =20 - if (ret) { - it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; - it6505_link_train_ok(it6505); - } else { - it6505->auto_train_retry--; - it6505_dump(it6505); - } + /*After HW auto training fail, try link training step by step*/ + it6505_link_step_train_process(it6505); =20 } =20 --=20 2.34.1 From nobody Thu Jan 30 17:23:29 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 37A0F1D3582 for ; Fri, 24 Jan 2025 02:29:24 +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=1737685765; cv=none; b=DVZxErR1tKADmu8/DvkOjcexU7YV5zqhAJbnjJmCOnV3bEgaaFgRC1asJuEe5ClXTWbpvtoJWPiFTWkAhi9vSurcI6LWjNLDOX2JYGnEoJ5lzVD//+WACC2xLmD3ieLWM4ANMCBZPXaromSijFcZRpopVWxF925v2+G53GkziC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737685765; c=relaxed/simple; bh=4mDtKJNOvXzo04STzoLEDzk08HuB8UCxRKC60TOOa6c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XBCFW6LEvlix7mZsPvDdKOfDzR7wM1E84sAGk3HYWOFHA9RiELNtCynQkeiyomJJ7RP6PXHLSJX2mbBQ+S9nd6ShcwEPBjHM5VEokoy0OUJoTwGvI/L1jjrgA84paC+Wr6rl+SbWmj1ZN+VXlymtOTmkb7dp3+Jb49/LYoESzf8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P99gJVvE; 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="P99gJVvE" Received: by smtp.kernel.org (Postfix) with ESMTPS id C397AC4AF0B; Fri, 24 Jan 2025 02:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737685764; bh=4mDtKJNOvXzo04STzoLEDzk08HuB8UCxRKC60TOOa6c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=P99gJVvE1XxGljWYnzdTMrh+SAxE00R18hLOFQl/hb82eSaDT4BEPoZjKmJVwtkeZ 3HVnu4BwZp7T5kQlbt+Fp6hoD/hFec6rm3koyyQ10GCGzVrfUdk2vASzj910YUVQLY EIOFtd405kh/2YGBHx2IzvUjVAn776xMPGtolBVMsqUkRJeCxjqiT4e79bB2YfKlaY 5ElypLsQtla2IVkYwEVcQH6OtsDU2YlcnQwNQsgzSP8S43euy7XKDadKfl3Yz3ysEg yCEbbyAAjkhSVPaq47QZ1cbfcIUXQ1LoBk9RUZ/PTPlWGBub2G8/HDMc6KP6hr7X3g 2SKU30NyPL95Q== 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 B4DE2C0218B; Fri, 24 Jan 2025 02:29:24 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Fri, 24 Jan 2025 10:29:52 +0800 Subject: [PATCH 3/3] 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: <20250124-fix-link-training-v1-3-09511050bb2c@ite.com.tw> References: <20250124-fix-link-training-v1-0-09511050bb2c@ite.com.tw> In-Reply-To: <20250124-fix-link-training-v1-0-09511050bb2c@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=1737685792; l=2801; i=Hermes.wu@ite.com.tw; s=20241230; h=from:subject:message-id; bh=JH5TB+6KMos7mGcxiEmqDSjWU1p596CHLwJaILJm+RQ=; b=gXdNFv910hf0FF8myxOgVbYKQXZOItlk/m9x4G2/vhbNJ2J2mq7Jl5s3XPYZjzGW+gfQg8z+r +MLx3OxKsewDK2slp+NFS2yx6vPlduwM79JeJxZhh73fsT+ywN/qVy/ 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 | 36 +++++++++++++++++++++------------= --- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index 11231a642bbe185c4f36bf5f2a0b115fa056213b..730481a9446ff00a54ef70e86b4= c28ff0a3f417e 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -468,6 +468,7 @@ struct it6505 { struct work_struct hdcp_wait_ksv_list; struct completion extcon_completion; u8 auto_train_retry; + u8 step_train_only; bool hdcp_desired; bool is_repeater; u8 hdcp_down_stream_count; @@ -2459,11 +2460,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); } @@ -2479,21 +2482,23 @@ static void it6505_link_training_work(struct work_s= truct *work) =20 if (!it6505_get_sink_hpd_status(it6505)) return; - - retry =3D it6505->auto_train_retry; - do { - it6505_link_training_setup(it6505); - it6505_reset_hdcp(it6505); - it6505_aux_reset(it6505); - - 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); - if (ret) { - it6505_link_train_ok(it6505); - return; - } - } while (retry--); + /* skip auto training if previous auto train is fail*/ + if (!it6505->step_train_only) { + retry =3D it6505->auto_train_retry; + do { + it6505_link_training_setup(it6505); + it6505_reset_hdcp(it6505); + it6505_aux_reset(it6505); + + 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); + if (ret) { + it6505_link_train_ok(it6505); + return; + } + } while (retry--); + } =20 /*After HW auto training fail, try link training step by step*/ it6505_link_step_train_process(it6505); @@ -2605,6 +2610,7 @@ static void it6505_irq_hpd(struct it6505 *it6505) it6505_parse_link_capabilities(it6505); } it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; + 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