drm/bridge: it6505: fix DP link traning and improve compatibility
Subsystems (3)
v3 cover drm/bridge: it6505: fix DP link traning and improve compatibility
IT6505 supports HW auto link training which will write DPCD and check training status automatically. Some DP device can not pass HW auto link training and must set link training step by step.
when HW auto link training fail, it may trigger video FIFO error, and link training process will reset to beginning, and never try step training method.
Modify training method improve compatibility to these DP devices.
---
Changes in v3:
- Patch 1/5 : add commit message for detial about changes
- Patch 2/5 : fix lost variable struct device *dev;
- Patch 3/5 : keep changes and remove refactoring
- Patch 5/5 : merge condition "it6505->step_train_only" check form if condiction into for loop.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- 1. Split [PATCH 1/3] into 3 commits
- 2. Drop non necessary variable auto_ttrain_retry
- Link to v1: https://lore.kernel.org/all/[email protected]/
---
Hermes Wu (5):
drm/bridge: it6505: fix link training state HW register reset drm/bridge: it6505: check INT_LINK_TRAIN_FAIL while link auto training drm/bridge: it6505: modify DP link auto training drm/bridge: it6505: modify DP link training work drm/bridge: it6505: skip auto training when previous try fail
drivers/gpu/drm/bridge/ite-it6505.c | 88 +++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 38 deletions(-)
---
base-commit: 938fbb16aba8f7b88e0fdcf56f315a5bbad41aad
change-id: 20250121-fix-link-training-461495494655
Best regards,
Signature · 1 line
Hermes Wu <[email protected]>
PATCH RESEND v3 1/5 drm/bridge: it6505: fix link training state HW register reset
When connect to a DP-to-HDMI device which does not connect to HDMI sink, it will report DPCD 00200h with SINK_COUNT = "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.
--- drivers/gpu/drm/bridge/ite-it6505.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +4 -2
@@ -1806,7 +1806,9 @@ static bool it6505_link_start_auto_train(struct it6505 *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 );while (timeout >0 ) {
@@ -2377,7 +2379,7 @@ static void it6505_stop_link_train(struct it6505 *it6505) { it6505->link_state =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 ); }static void it6505_link_train_ok (struct it6505 *it6505)
Signature · 1 line
2.34.1
Re: [PATCH RESEND v3 1/5] drm/bridge: it6505: fix link training state HW register reset
Quoted 9 lines · On Tue, Sep 16, 2025 at 12:47:41PM +0800, Hermes Wu via B4 Relay wrote:
From: Hermes Wu <[email protected]>
When connect to a DP-to-HDMI device which does not connect to HDMI sink, it will report DPCD 00200h with
SINK_COUNT= "0", and issueHPD_IRQwhenSINK_COUNTchange to "1".IT6505 can not recive
HPD_IRQbefore training done and driver will force HW enter training done state when connect to such devices.
Quoted 9 lines
When HW is force to training done state and restart link training, bits
FORCE_RETRAINandMANUAL_TRAINatREG_TRAIN_CTRL1must be set at the same time to reset HW state.Signed-off-by Hermes Wu <[email protected]>--- drivers/gpu/drm/bridge/ite-it6505.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Signature · 2 lines
With best wishes Dmitry
PATCH RESEND v3 2/5 drm/bridge: it6505: check INT_LINK_TRAIN_FAIL while link auto training
In reply to Hermes WuWhen 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.
--- drivers/gpu/drm/bridge/ite-it6505.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +15 -11
@@ -821,8 +821,8 @@ static void it6505_int_mask_enable(struct it6505 *it6505)it6505_write (it6505,INT_MASK_02 ,BIT (INT_AUX_CMD_FAIL ) |BIT (INT_HDCP_KSV_CHECK ) |BIT (INT_AUDIO_FIFO_ERROR )); -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 )); }static void it6505_int_mask_disable (struct it6505 *it6505)
@@ -1802,6 +1802,8 @@ static bool it6505_link_start_auto_train(struct it6505 *it6505) {int timeout =500 , link_training_state;bool state = false; +int int03; +struct device *dev = it6505->dev;mutex_lock (&it6505->aux_lock); it6505_set_bits(it6505, REG_TRAIN_CTRL0,
@@ -1814,6 +1816,17 @@ static bool it6505_link_start_auto_train(struct it6505 *it6505)while (timeout >0 ) {usleep_range (1000 ,2000 ); link_training_state =it6505_read (it6505,REG_LINK_TRAIN_STS ); + int03 =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 ; + }if (link_training_state >0 && (link_training_state &LINK_STATE_NORP )) {
@@ -2693,14 +2706,6 @@ static void it6505_irq_audio_fifo_error(struct it6505 *it6505)it6505_enable_audio (it6505); } -static void it6505_irq_link_train_fail (struct it6505 *it6505) -{ -struct device *dev = 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 unused, 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;
Signature · 1 line
2.34.1
Re: [PATCH RESEND v3 2/5] drm/bridge: it6505: check INT_LINK_TRAIN_FAIL while link auto training
Quoted 5 lines · On Tue, Sep 16, 2025 at 12:47:42PM +0800, Hermes Wu via B4 Relay wrote:
From: Hermes Wu <[email protected]>
When start link training, interrupt status
INT_LINK_TRAIN_FAILcan use to check link training fail and no need to wait until timeout.
Quoted 7 lines
it6505_irq_link_train_fail()remove from interrupt and no longer used.Signed-off-by Hermes Wu <[email protected]>--- drivers/gpu/drm/bridge/ite-it6505.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
Signature · 2 lines
With best wishes Dmitry
PATCH RESEND v3 3/5 drm/bridge: it6505: modify DP link auto training
In reply to Hermes WuIT6505 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.
--- drivers/gpu/drm/bridge/ite-it6505.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/ite-it6505.c +13 -1
@@ -1806,6 +1806,13 @@ static bool it6505_link_start_auto_train(struct it6505 *it6505)struct device *dev = it6505->dev;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 it6505 *it6505) link_training_state =it6505_read (it6505,REG_LINK_TRAIN_STS ); int03 =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 )); DRM_DEV_DEBUG_DRIVER(dev, "INT_LINK_TRAIN_FAIL(%x)!",
@@ -1837,6 +1846,9 @@ static bool it6505_link_start_auto_train(struct it6505 *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);return state;
Signature · 1 line
2.34.1
Re: [PATCH RESEND v3 3/5] drm/bridge: it6505: modify DP link auto training
Quoted 39 lines · On Tue, Sep 16, 2025 at 12:47:43PM +0800, Hermes Wu via B4 Relay wrote:
From: Hermes Wu <[email protected]>
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_ERRORtriggered 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_ERRORto avoid loop and checkINT_LINK_TRAIN_FAILevent to abort wait training done.Signed-off-by Hermes Wu <[email protected]>--- drivers/gpu/drm/bridge/ite-it6505.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/gpu/drm/bridge/ite-it6505.c +7
-0@@ -1806,6 +1806,13 @@ static bool it6505_link_start_auto_train(struct it6505 *it6505)struct device *dev = it6505->dev;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*/
drivers/gpu/drm/bridge/ite-it6505.c static bool it6505_link_start_auto_train(struct it6505 *it6505) · line 1831
Quoted 8 lines
drivers/gpu/drm/bridge/ite-it6505.c +3
-1@@ -1818,8 +1825,10 @@ static bool it6505_link_start_auto_train(struct it6505 *it6505) link_training_state =it6505_read (it6505,REG_LINK_TRAIN_STS ); int03 =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 ));
I'm really unusure about this change. Judging by the description of the problem, it's fix for the issue, but the issue gets introduced in the previous patch.
Quoted 18 lines
drivers/gpu/drm/bridge/ite-it6505.c +3
-0DRM_DEV_DEBUG_DRIVER(dev, "INT_LINK_TRAIN_FAIL(%x)!",@@ -1837,6 +1846,9 @@ static bool it6505_link_start_auto_train(struct it6505 *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);return state;Signature · 2 lines
-- 2.34.1
Signature · 2 lines
With best wishes Dmitry
RE: [PATCH RESEND v3 3/5] drm/bridge: it6505: modify DP link auto training
Quoted 52 lines
-----Original Message-----
From: Dmitry Baryshkov <[email protected]>
Sent: Tuesday, September 16, 2025 6:49 PM
To: Hermes Wu (吳佳宏) <[email protected]>
Cc: Andrzej Hajda <[email protected]>; Neil Armstrong <[email protected]>; Robert Foss <[email protected]>; Laurent Pinchart <[email protected]>; Jonas Karlman <[email protected]>; Jernej Skrabec <[email protected]>; Maarten Lankhorst <[email protected]>; Maxime Ripard <[email protected]>; Thomas Zimmermann <[email protected]>; David Airlie <[email protected]>; Simona Vetter <[email protected]>; Pet Weng (翁玉芬) <[email protected]>; Kenneth Hung (洪家倫) <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH RESEND v3 3/5] drm/bridge: it6505: modify DP link auto trainingQuoted 43 lines · On Tue, Sep 16, 2025 at 12:47:43PM +0800, Hermes Wu via B4 Relay wrote:
From: Hermes Wu <[email protected]>
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_ERRORtriggered 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_ERRORto avoid loop and checkINT_LINK_TRAIN_FAILevent to abort wait training done.Signed-off-by Hermes Wu <[email protected]>--- drivers/gpu/drm/bridge/ite-it6505.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/gpu/drm/bridge/ite-it6505.c +8
-0@@ -1806,6 +1806,13 @@ static bool it6505_link_start_auto_train(struct it6505 *it6505)struct device *dev = it6505->dev;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 it6505 *it6505) link_training_state =it6505_read (it6505,REG_LINK_TRAIN_STS ); int03 =it6505_read (it6505,INT_STATUS_03 );if (int03 &BIT (INT_LINK_TRAIN_FAIL )) { +/* Ignore INT_VID_FIFO_ERROR when auto training fail*/
Quoted 8 lines
drivers/gpu/drm/bridge/ite-it6505.c static bool it6505_link_start_auto_train(struct it6505 *it6505) · line 1831
Quoted 4 lines
drivers/gpu/drm/bridge/ite-it6505.c +2
-1it6505_write (it6505,INT_STATUS_03 , -BIT (INT_LINK_TRAIN_FAIL )); +BIT (INT_LINK_TRAIN_FAIL ) | +BIT (INT_VID_FIFO_ERROR ));I'm really unusure about this change. Judging by the description of the problem, it's fix for the issue, but the issue gets introduced in the previous patch.
In this patch serious?
This patch serious fix this FIFO error issue, it change link training algorithm first then fix wrong FIFO error status.
The link training process start after video status is stable, and when video FIFO error occurs, video stable status will also lost, link training will reset to idle and wait until video stable again.
IT6505 HW auto training will process link training automatically, which include CR/EQ DPCD setting, link status check, and try lower link rate is the 2.7G cannot pass training.
In some case, DP connect to a DP sink device which cannot pass IT6505 HW auto training.
when link auto training fail on 2.7G and IT6505 HW change link rate to 1.65G and retry training automatically, at this time video FIFO error will occur because of the link rate change(chip issue), the video signal from SOC is not lost actually.
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/bridge/ite-it6505.c +3
-0DRM_DEV_DEBUG_DRIVER(dev, "INT_LINK_TRAIN_FAIL(%x)!",@@ -1837,6 +1846,9 @@ static bool it6505_link_start_auto_train(struct it6505 *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);
Quoted 11 lines
Quoted 6 lines
drivers/gpu/drm/bridge/ite-it6505.c +0
-0return state;Signature · 2 lines
-- 2.34.1Signature · 2 lines
With best wishes Dmitry
BR.
Hermes Wu
Re: [PATCH RESEND v3 3/5] drm/bridge: it6505: modify DP link auto training
Quoted 67 lines · On Wed, Sep 17, 2025 at 08:37:10AM +0000, [email protected] wrote:
Quoted 52 lines
-----Original Message-----
From: Dmitry Baryshkov <[email protected]>
Sent: Tuesday, September 16, 2025 6:49 PM
To: Hermes Wu (吳佳宏) <[email protected]>
Cc: Andrzej Hajda <[email protected]>; Neil Armstrong <[email protected]>; Robert Foss <[email protected]>; Laurent Pinchart <[email protected]>; Jonas Karlman <[email protected]>; Jernej Skrabec <[email protected]>; Maarten Lankhorst <[email protected]>; Maxime Ripard <[email protected]>; Thomas Zimmermann <[email protected]>; David Airlie <[email protected]>; Simona Vetter <[email protected]>; Pet Weng (翁玉芬) <[email protected]>; Kenneth Hung (洪家倫) <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH RESEND v3 3/5] drm/bridge: it6505: modify DP link auto trainingQuoted 43 lines · On Tue, Sep 16, 2025 at 12:47:43PM +0800, Hermes Wu via B4 Relay wrote:
From: Hermes Wu <[email protected]>
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_ERRORtriggered 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_ERRORto avoid loop and checkINT_LINK_TRAIN_FAILevent to abort wait training done.Signed-off-by Hermes Wu <[email protected]>--- drivers/gpu/drm/bridge/ite-it6505.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/gpu/drm/bridge/ite-it6505.c +8
-0@@ -1806,6 +1806,13 @@ static bool it6505_link_start_auto_train(struct it6505 *it6505)struct device *dev = it6505->dev;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 it6505 *it6505) link_training_state =it6505_read (it6505,REG_LINK_TRAIN_STS ); int03 =it6505_read (it6505,INT_STATUS_03 );if (int03 &BIT (INT_LINK_TRAIN_FAIL )) { +/* Ignore INT_VID_FIFO_ERROR when auto training fail*/ Quoted 8 lines
drivers/gpu/drm/bridge/ite-it6505.c static bool it6505_link_start_auto_train(struct it6505 *it6505) · line 1831
Quoted 4 lines
drivers/gpu/drm/bridge/ite-it6505.c +2
-1it6505_write (it6505,INT_STATUS_03 , -BIT (INT_LINK_TRAIN_FAIL )); +BIT (INT_LINK_TRAIN_FAIL ) | +BIT (INT_VID_FIFO_ERROR ));I'm really unusure about this change. Judging by the description of the problem, it's fix for the issue, but the issue gets introduced in the previous patch.
In this patch serious?
This patch serious fix this FIFO error issue, it change link training algorithm first then fix wrong FIFO error status.
The link training process start after video status is stable, and when video FIFO error occurs, video stable status will also lost, link training will reset to idle and wait until video stable again.
Quoted 6 lines
IT6505 HW auto training will process link training automatically, which include CR/EQ DPCD setting, link status check, and try lower link rate is the 2.7G cannot pass training.
In some case, DP connect to a DP sink device which cannot pass IT6505 HW auto training.
when link auto training fail on 2.7G and IT6505 HW change link rate to 1.65G and retry training automatically, at this time video FIFO error will occur because of the link rate change(chip issue), the video signal from SOC is not lost actually.
We seems to be misunderstanding each other. I pointed out that your are fixing the code that was introduced in the previous patch. Would it make more sense to reoder or to squash the patches?
Quoted 27 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/bridge/ite-it6505.c +3
-0DRM_DEV_DEBUG_DRIVER(dev, "INT_LINK_TRAIN_FAIL(%x)!",@@ -1837,6 +1846,9 @@ static bool it6505_link_start_auto_train(struct it6505 *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);Quoted 11 lines
Quoted 6 lines
drivers/gpu/drm/bridge/ite-it6505.c +0
-0return state;Signature · 2 lines
-- 2.34.1Signature · 2 lines
With best wishes DmitryBR.
Hermes Wu
Signature · 2 lines
With best wishes Dmitry
RE: [PATCH RESEND v3 3/5] drm/bridge: it6505: modify DP link auto training
Quoted 80 lines
-----Original Message-----
From: Dmitry Baryshkov <[email protected]>
Sent: Wednesday, September 17, 2025 9:47 PM
To: Hermes Wu (吳佳宏) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Pet Weng (翁玉芬) <[email protected]>; Kenneth Hung (洪家倫) <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH RESEND v3 3/5] drm/bridge: it6505: modify DP link auto trainingQuoted 70 lines · On Wed, Sep 17, 2025 at 08:37:10AM +0000, [email protected] wrote:
Quoted 52 lines
-----Original Message-----
From: Dmitry Baryshkov <[email protected]>
Sent: Tuesday, September 16, 2025 6:49 PM
To: Hermes Wu (吳佳宏) <[email protected]>
Cc: Andrzej Hajda <[email protected]>; Neil Armstrong <[email protected]>; Robert Foss <[email protected]>; Laurent Pinchart <[email protected]>; Jonas Karlman <[email protected]>; Jernej Skrabec <[email protected]>; Maarten Lankhorst <[email protected]>; Maxime Ripard <[email protected]>; Thomas Zimmermann <[email protected]>; David Airlie <[email protected]>; Simona Vetter <[email protected]>; Pet Weng (翁玉芬) <[email protected]>; Kenneth Hung (洪家倫) <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH RESEND v3 3/5] drm/bridge: it6505: modify DP link auto trainingQuoted 43 lines · On Tue, Sep 16, 2025 at 12:47:43PM +0800, Hermes Wu via B4 Relay wrote:
From: Hermes Wu <[email protected]>
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_ERRORtriggered 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_ERRORto avoid loop and checkINT_LINK_TRAIN_FAILevent to abort wait training done.Signed-off-by Hermes Wu <[email protected]>--- drivers/gpu/drm/bridge/ite-it6505.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/gpu/drm/bridge/ite-it6505.c +8
-0@@ -1806,6 +1806,13 @@ static bool it6505_link_start_auto_train(struct it6505 *it6505)struct device *dev = it6505->dev;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 it6505 *it6505) link_training_state =it6505_read (it6505,REG_LINK_TRAIN_STS ); int03 =it6505_read (it6505,INT_STATUS_03 );if (int03 &BIT (INT_LINK_TRAIN_FAIL )) { +/* Ignore INT_VID_FIFO_ERROR when auto training fail*/ Quoted 8 lines
drivers/gpu/drm/bridge/ite-it6505.c static bool it6505_link_start_auto_train(struct it6505 *it6505) · line 1831
Quoted 4 lines
drivers/gpu/drm/bridge/ite-it6505.c +2
-1it6505_write (it6505,INT_STATUS_03 , -BIT (INT_LINK_TRAIN_FAIL )); +BIT (INT_LINK_TRAIN_FAIL ) | +BIT (INT_VID_FIFO_ERROR ));I'm really unusure about this change. Judging by the description of the problem, it's fix for the issue, but the issue gets introduced in the previous patch.
In this patch serious?
This patch serious fix this FIFO error issue, it change link training algorithm first then fix wrong FIFO error status.
The link training process start after video status is stable, and when video FIFO error occurs, video stable status will also lost, link training will reset to idle and wait until video stable again.
IT6505 HW auto training will process link training automatically, which include CR/EQ DPCD setting, link status check, and try lower link rate is the 2.7G cannot pass training.
Quoted 7 lines
Quoted 3 lines
In some case, DP connect to a DP sink device which cannot pass IT6505 HW auto training.
when link auto training fail on 2.7G and IT6505 HW change link rate to 1.65G and retry training automatically, at this time video FIFO error will occur because of the link rate change(chip issue), the video signal from SOC is not lost actually.We seems to be misunderstanding each other. I pointed out that your are fixing the code that was introduced in the previous patch. Would it make more sense to reoder or to squash the patches?
this patch can squash to previous one. they are part of auto link training fail check.
I will update in next patch serious
Quoted 31 lines
Quoted 26 lines
Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/bridge/ite-it6505.c +3
-0DRM_DEV_DEBUG_DRIVER(dev, "INT_LINK_TRAIN_FAIL(%x)!",@@ -1837,6 +1846,9 @@ static bool it6505_link_start_auto_train(struct it6505 *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);Quoted 11 lines
Quoted 6 lines
drivers/gpu/drm/bridge/ite-it6505.c +0
-0return state;Signature · 2 lines
-- 2.34.1Signature · 2 lines
With best wishes DmitryBR.
Hermes WuSignature · 2 lines
With best wishes Dmitry
PATCH RESEND v3 4/5 drm/bridge: it6505: modify DP link training work
In reply to Hermes WuThe 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.
--- drivers/gpu/drm/bridge/ite-it6505.c | 40 ++++++++++++++----------------------- 1 file changed, 15 insertions(+), 25 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +15 -25
@@ -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 offset, u8 *dpcd, int num)return 0 ; } -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 *it6505) it6505->lane_count =MAX_LANE_COUNT ; it6505->link_state =LINK_IDLE ; it6505->hdcp_desired =HDCP_DESIRED ; - it6505->auto_train_retry =AUTO_TRAIN_RETRY ; it6505->audio.select =AUDIO_SELECT ; it6505->audio.sample_rate =AUDIO_SAMPLE_RATE ; it6505->audio.channel_count =AUDIO_CHANNEL_COUNT ;
@@ -2467,7 +2465,7 @@ static void it6505_link_training_work(struct work_struct *work) { struct it6505 *it6505 = container_of(work, struct it6505, link_works);struct device *dev = it6505->dev; -int ret; +int ret, retry;DRM_DEV_DEBUG_DRIVER (dev,"it6505->sink_count: %d" , it6505->sink_count);
@@ -2475,27 +2473,22 @@ static void it6505_link_training_work(struct work_struct *work)if (!it6505_get_sink_hpd_status (it6505))return ; -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 =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 =AUTO_TRAIN_RETRY ; retry >0 ; retry--) { +it6505_link_training_setup (it6505); +it6505_reset_hdcp (it6505); +it6505_aux_reset (it6505); -if (ret) { - it6505->auto_train_retry =AUTO_TRAIN_RETRY ; -it6505_link_train_ok (it6505); - }else { - it6505->auto_train_retry--; -it6505_dump (it6505); + ret =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 ; + } } +/*After HW auto training fail, try link training step by step*/ +it6505_link_step_train_process (it6505); }static void it6505_plugged_status_to_codec (struct it6505 *it6505)
@@ -2576,7 +2569,6 @@ static int it6505_process_hpd_irq(struct it6505 *it6505) (int)ARRAY_SIZE(link_status), link_status);if (!drm_dp_channel_eq_ok (link_status, it6505->lane_count)) { - it6505->auto_train_retry =AUTO_TRAIN_RETRY ;it6505_video_reset (it6505); }
@@ -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 =AUTO_TRAIN_RETRY ;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 *it6505, const int *int_statu (unsigned int *)int_status)) || (it6505_test_bit(BIT_INT_VID_FIFO_ERROR, (unsigned int *)int_status))) { - it6505->auto_train_retry =AUTO_TRAIN_RETRY ;flush_work (&it6505->link_works);it6505_stop_hdcp (it6505);it6505_video_reset (it6505);
Signature · 1 line
2.34.1
Re: [PATCH RESEND v3 4/5] drm/bridge: it6505: modify DP link training work
Quoted 6 lines · On Tue, Sep 16, 2025 at 12:47:44PM +0800, Hermes Wu via B4 Relay wrote:
From: Hermes Wu <[email protected]>
The DP link training work include auto training and after auto training failed "
AUTO_TRAIN_RETRY" times, it switch to step training mode.
Quoted 8 lines
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_retryfrom it6505 structure, andit6505_dump()is remove from link trainig work, it takes too much time to read all register area, and is not necessary.
Nit: please fix your editor to wrap commit messages on a more typical boundary (72-75-77 chars).
Otherwise:
Quoted 6 lines
Signed-off-by Hermes Wu <[email protected]>--- drivers/gpu/drm/bridge/ite-it6505.c | 40 ++++++++++++++----------------------- 1 file changed, 15 insertions(+), 25 deletions(-)
Signature · 2 lines
With best wishes Dmitry
PATCH RESEND v3 5/5 drm/bridge: it6505: skip auto training when previous try fail
In reply to Hermes WuWhen 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.
--- drivers/gpu/drm/bridge/ite-it6505.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +6 -2
@@ -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 it6505 *it6505) ret ? "pass" : "failed", i + 1);if (ret) {it6505_link_train_ok (it6505); + it6505->step_train_only = true;return ; } }DRM_DEV_DEBUG_DRIVER (dev,"training fail" ); + it6505->step_train_only = false; it6505->link_state =LINK_IDLE ;it6505_video_reset (it6505); }
@@ -2473,14 +2476,14 @@ static void it6505_link_training_work(struct work_struct *work)if (!it6505_get_sink_hpd_status (it6505))return ; -for (retry =AUTO_TRAIN_RETRY ; retry >0 ; retry--) { +for (retry =AUTO_TRAIN_RETRY ; retry >0 && !it6505->step_train_only; retry--) {it6505_link_training_setup (it6505);it6505_reset_hdcp (it6505);it6505_aux_reset (it6505); ret =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 = false;it6505_drm_dp_link_set_power (&it6505->aux, &it6505->link,DP_SET_POWER_D0 );
Signature · 1 line
2.34.1
Re: [PATCH RESEND v3 5/5] drm/bridge: it6505: skip auto training when previous try fail
Quoted 7 lines · On Tue, Sep 16, 2025 at 12:47:45PM +0800, Hermes Wu via B4 Relay wrote:
From: Hermes Wu <[email protected]>
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.
Please expand your commit message for it to make sense to somebody who doesn't know the issue. If I understood it correctly, it should be something like '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'.
Quoted 6 lines
Signed-off-by Hermes Wu <[email protected]>--- drivers/gpu/drm/bridge/ite-it6505.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Signature · 2 lines
With best wishes Dmitry