aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0975-drm-amd-dal-Add-retry-mechanism-for-link-training.patch
blob: aa1fea72da47ffdd3f32bcac15a1509f2be76f1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
From fa0758869eb00cfbe31058880581bbcdfd0b6195 Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Date: Wed, 16 Mar 2016 15:29:35 -0400
Subject: [PATCH 0975/1110] drm/amd/dal: Add retry mechanism for link training.

On some displays the training sequence succeedes only
after several consecutive tries.

Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/dal/dc/core/dc_link.c    |  6 +++-
 drivers/gpu/drm/amd/dal/dc/core/dc_link_dp.c | 51 +++++++++++++++++-----------
 drivers/gpu/drm/amd/dal/dc/inc/dc_link_dp.h  |  5 +--
 3 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc_link.c b/drivers/gpu/drm/amd/dal/dc/core/dc_link.c
index fd406f9..97d6f93 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc_link.c
@@ -1178,7 +1178,11 @@ static enum dc_status enable_link_dp(struct pipe_ctx *pipe_ctx)
 	if (link_settings.link_rate == LINK_RATE_LOW)
 			skip_video_pattern = false;
 
-	if (perform_link_training(link, &link_settings, skip_video_pattern)) {
+	if (perform_link_training_with_retries(
+			link,
+			&link_settings,
+			skip_video_pattern,
+			3)) {
 		link->public.cur_link_settings = link_settings;
 		status = DC_OK;
 	}
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/dal/dc/core/dc_link_dp.c
index 282a56b..8fe0314 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc_link_dp.c
@@ -1040,6 +1040,31 @@ bool perform_link_training(
 	return status;
 }
 
+
+bool perform_link_training_with_retries(
+	struct core_link *link,
+	const struct dc_link_settings *link_setting,
+	bool skip_video_pattern,
+	unsigned int retires)
+{
+	uint8_t j;
+	uint8_t delay_between_retries = 10;
+
+	for (j = 0; j < retires; ++j) {
+
+		if (perform_link_training(
+				link,
+				link_setting,
+				skip_video_pattern))
+			return true;
+
+		msleep(delay_between_retries);
+		delay_between_retries += 10;
+	}
+
+	return false;
+}
+
 /*TODO add more check to see if link support request link configuration */
 static bool is_link_setting_supported(
 	const struct dc_link_settings *link_setting,
@@ -1150,23 +1175,11 @@ bool dp_hbr_verify_link_cap(
 		if (skip_link_training)
 			success = true;
 		else {
-			uint8_t num_retries = 3;
-			uint8_t j;
-			uint8_t delay_between_retries = 10;
-
-			for (j = 0; j < num_retries; ++j) {
-				success = perform_link_training(
-					link,
-					cur,
-					skip_video_pattern);
-
-				if (success)
-					break;
-
-				msleep(delay_between_retries);
-
-				delay_between_retries += 10;
-			}
+			success = perform_link_training_with_retries(
+								link,
+								cur,
+								skip_video_pattern,
+								3);
 		}
 
 		if (success)
@@ -1527,8 +1540,8 @@ bool dc_link_handle_hpd_rx_irq(const struct dc_link *dc_link)
 	if (hpd_rx_irq_check_link_loss_status(
 		link,
 		&hpd_irq_dpcd_data)) {
-		perform_link_training(link,
-			&link->public.cur_link_settings, true);
+		perform_link_training_with_retries(link,
+			&link->public.cur_link_settings, true, 3);
 		status = false;
 	}
 
diff --git a/drivers/gpu/drm/amd/dal/dc/inc/dc_link_dp.h b/drivers/gpu/drm/amd/dal/dc/inc/dc_link_dp.h
index a0ab6b3..b9fb8b9 100644
--- a/drivers/gpu/drm/amd/dal/dc/inc/dc_link_dp.h
+++ b/drivers/gpu/drm/amd/dal/dc/inc/dc_link_dp.h
@@ -42,10 +42,11 @@ void decide_link_settings(
 	struct core_stream *stream,
 	struct dc_link_settings *link_setting);
 
-bool perform_link_training(
+bool perform_link_training_with_retries(
 	struct core_link *link,
 	const struct dc_link_settings *link_setting,
-	bool skip_video_pattern);
+	bool skip_video_pattern,
+	unsigned int  retires);
 
 bool is_mst_supported(struct core_link *link);
 
-- 
2.7.4