aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0437-drm-amd-display-Unify-loop-for-surface-update-and-pa.patch
blob: 815c3793d16a575539b39841fd22e6ed57dbb7b7 (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
From e6a11de519591103b97e3317b7c65f4131b26716 Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Date: Mon, 15 May 2017 18:55:38 -0400
Subject: [PATCH 0437/4131] drm/amd/display: Unify loop for surface update and
 page flip.

Remove extra loop we have for page flips and do flips in same loop we do
for surface create/update.
Add documentation for synchronization between commits on different crtcs.
Rename function to have DM prefix.

Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c    | 88 +++++++++++-----------
 1 file changed, 42 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
index c0f2699..03f05a7 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
@@ -2559,10 +2559,11 @@ static void amdgpu_dm_do_flip(
 						 acrtc->crtc_id);
 }
 
-void dc_commit_surfaces(struct drm_atomic_state *state,
+static void amdgpu_dm_commit_surfaces(struct drm_atomic_state *state,
 			struct drm_device *dev,
 			struct amdgpu_display_manager *dm,
-			struct drm_crtc *pcrtc)
+			struct drm_crtc *pcrtc,
+			bool *wait_for_vblank)
 {
 	uint32_t i;
 	struct drm_plane *plane;
@@ -2575,10 +2576,11 @@ void dc_commit_surfaces(struct drm_atomic_state *state,
 	for_each_plane_in_state(state, plane, old_plane_state, i) {
 		struct drm_plane_state *plane_state = plane->state;
 		struct drm_crtc *crtc = plane_state->crtc;
+		struct amdgpu_crtc *acrtc_attach = to_amdgpu_crtc(crtc);
 		struct drm_framebuffer *fb = plane_state->fb;
 		struct drm_connector *connector;
 		struct dm_connector_state *dm_state = NULL;
-		struct amdgpu_crtc *acrtc_attach;
+
 		enum dm_commit_action action;
 		bool pflip_needed;
 
@@ -2587,13 +2589,13 @@ void dc_commit_surfaces(struct drm_atomic_state *state,
 
 		action = get_dm_commit_action(crtc->state);
 
-		/* Surfaces are created under two scenarios:
-		 * 1. This commit is not a page flip.
-		 * 2. This commit is a page flip, and streams are created.
+		/*
+		 * TODO - TO decide if it's a flip or surface update
+		 * stop relying on allow_modeset flag and query DC
+		 * using dc_check_update_surfaces_for_stream.
 		 */
 		pflip_needed = !state->allow_modeset;
-		if (!pflip_needed || action == DM_COMMIT_ACTION_DPMS_ON
-				|| action == DM_COMMIT_ACTION_SET) {
+		if (!pflip_needed) {
 			list_for_each_entry(connector,
 					    &dev->mode_config.connector_list,
 					    head) {
@@ -2623,11 +2625,23 @@ void dc_commit_surfaces(struct drm_atomic_state *state,
 			if (crtc == pcrtc) {
 				add_surface(dm->dc, crtc, plane,
 					    &dc_surfaces_constructed[planes_count]);
-				acrtc_attach = to_amdgpu_crtc(crtc);
 				dc_stream_attach = acrtc_attach->stream;
 				planes_count++;
 			}
+		} else if (crtc->state->planes_changed) {
+			*wait_for_vblank =
+				acrtc_attach->flip_flags & DRM_MODE_PAGE_FLIP_ASYNC ?
+				false : true;
+
+			amdgpu_dm_do_flip(
+				crtc,
+				fb,
+				drm_crtc_vblank_count(crtc) + *wait_for_vblank);
+
+			/*clean up the flags for next usage*/
+			acrtc_attach->flip_flags = 0;
 		}
+
 	}
 
 	if (planes_count) {
@@ -2649,8 +2663,6 @@ void amdgpu_dm_atomic_commit_tail(
 	struct drm_device *dev = state->dev;
 	struct amdgpu_device *adev = dev->dev_private;
 	struct amdgpu_display_manager *dm = &adev->dm;
-	struct drm_plane *plane;
-	struct drm_plane_state *old_plane_state;
 	uint32_t i, j;
 	uint32_t commit_streams_count = 0;
 	uint32_t new_crtcs_count = 0;
@@ -2815,7 +2827,7 @@ void amdgpu_dm_atomic_commit_tail(
 
 	/* update planes when needed per crtc*/
 	for_each_crtc_in_state(state, pcrtc, old_crtc_state, j)
-		dc_commit_surfaces(state, dev, dm, pcrtc);
+		amdgpu_dm_commit_surfaces(state, dev, dm, pcrtc, &wait_for_vblank);
 
 	for (i = 0; i < new_crtcs_count; i++) {
 		/*
@@ -2829,34 +2841,6 @@ void amdgpu_dm_atomic_commit_tail(
 
 		manage_dm_interrupts(adev, acrtc, true);
 		dm_crtc_cursor_reset(&acrtc->base);
-
-	}
-
-	for_each_plane_in_state(state, plane, old_plane_state, i) {
-		struct drm_plane_state *plane_state = plane->state;
-		struct drm_crtc *crtc = plane_state->crtc;
-		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
-		struct drm_framebuffer *fb = plane_state->fb;
-		bool pflip_needed;
-
-		if (!fb || !crtc || !crtc->state->planes_changed ||
-			!crtc->state->active)
-			continue;
-		pflip_needed = !state->allow_modeset;
-
-		if (pflip_needed) {
-			wait_for_vblank =
-				acrtc->flip_flags & DRM_MODE_PAGE_FLIP_ASYNC ?
-				false : true;
-
-			amdgpu_dm_do_flip(
-				crtc,
-				fb,
-				drm_crtc_vblank_count(crtc) + wait_for_vblank);
-
-			/*clean up the flags for next usage*/
-			acrtc->flip_flags = 0;
-		}
 	}
 
 
@@ -3079,7 +3063,11 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 	struct dc *dc = adev->dm.dc;
 	bool need_to_validate = false;
 	struct validate_context *context;
-	bool wait_4_prev_commits = false;
+	/*
+	 * This bool will be set for true for any modeset/reset
+	 * or surface update which implies non fast surfae update.
+	 */
+	bool wait_for_prev_commits = false;
 
 	ret = drm_atomic_helper_check(dev, state);
 
@@ -3156,7 +3144,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 
 			new_stream_count++;
 			need_to_validate = true;
-			wait_4_prev_commits = true;
+			wait_for_prev_commits = true;
 			break;
 		}
 
@@ -3202,7 +3190,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 
 			new_stream_count++;
 			need_to_validate = true;
-			wait_4_prev_commits = true;
+			wait_for_prev_commits = true;
 
 			break;
 		}
@@ -3214,7 +3202,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 						set,
 						set_count,
 						acrtc->stream);
-				wait_4_prev_commits = true;
+				wait_for_prev_commits = true;
 			}
 			break;
 		}
@@ -3310,8 +3298,16 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 	if (need_to_validate == false || set_count == 0 || context) {
 
 		ret = 0;
-
-		if (wait_4_prev_commits) {
+		/*
+		 * For full updates case when
+		 * removing/adding/updateding  streams on once CRTC while flipping
+		 * on another CRTC,
+		 * Adding all current active CRTC's states to the atomic commit in
+		 * amdgpu_dm_atomic_check will guarantee that any such full update commit
+		 * will wait for completion of any outstanding flip using DRMs
+		 * synchronization events.
+		 */
+		if (wait_for_prev_commits) {
 			list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
 				struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 				struct drm_crtc_state *crtc_state;
-- 
2.7.4