hdmi_frl_perform_link_training_with_fallback() lowers the rate after any
failed attempt, even when the sink never answered. The enable path,
hdmi_frl_perform_link_training_with_retries(), tries the same rate again
instead.

After waking up, a Samsung QE65Q80T (2020) can stay silent at
10 Gbps x 4 for a few seconds and then train in about 33 ms. Link
verification moves to a lower rate before that happens.

After a timeout, try the same rate again, up to max_retries times per
verification, as the enable path does. A sink that never answers costs
up to three extra attempts.

Fixes: cbb8e2044b9e ("drm/amd/display: Add DC link support for FRL")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Andrzej Piątyszek <[email protected]>
---
 .../amd/display/dc/link/protocols/link_hdmi_frl.c  | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c 
b/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c
index 97b2b9b74..129834d6d 100644
--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c
+++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c
@@ -818,9 +818,14 @@ enum link_result 
hdmi_frl_perform_link_training_with_fallback(
        enum clock_source_id frl_phy_clock_source_id)
 {
        enum link_result status = LINK_RESULT_UNKNOWN;
+       unsigned int retries = 0;
+       unsigned int max_retries = 3;
 
        DC_LOGGER_INIT(link->ctx->logger);
 
+       if (link->preferred_hdmi_frl_settings.valid)
+               max_retries = link->preferred_hdmi_frl_settings.max_retries;
+
        /* FRL Link Training */
        while (status != LINK_RESULT_FALLBACK) {
                if (link->frl_link_settings.frl_link_rate ==
@@ -846,6 +851,15 @@ enum link_result 
hdmi_frl_perform_link_training_with_fallback(
                if (status == LINK_RESULT_SUCCESS)
                        break;
 
+               /*
+                * A sink that is still waking up may not answer at all. Retry 
the
+                * same rate before going lower, as many times as link enable 
does.
+                */
+               if (status == LINK_RESULT_TIMEOUT && retries < max_retries) {
+                       retries++;
+                       continue;
+               }
+
                link->frl_link_settings.frl_link_rate--;
                if (link->frl_link_settings.frl_link_rate <
                                HDMI_FRL_LINK_RATE_6GBPS_4LANE)
-- 
2.56.0

Reply via email to