aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amdfalconx86/recipes-kernel/linux/linux-yocto/0867-drm-amd-dal-use-new-state-in-atomic_check.patch
blob: 453bbedfa5e81ab7f7d723e149f21c2da673e8c6 (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
From bc49cc26ab36158d33f1e8923730c36e0b8170b5 Mon Sep 17 00:00:00 2001
From: Mykola Lysenko <Mykola.Lysenko@amd.com>
Date: Wed, 2 Dec 2015 19:18:59 +0800
Subject: [PATCH 0867/1050] drm/amd/dal: use new state in atomic_check

Pass new state to fill_plane_attributes functions, so fb variable is available.
We should not segfault in case target is not created in atomic_check.
Removed unneeded cast

Change-Id: I612660edb0ef1f2a80f3ee829ac640edb93a724d
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
---
 .../gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c    | 61 ++++++++++++++--------
 1 file changed, 39 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
index 2633d08..2e5f5ba 100644
--- a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
+++ b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
@@ -525,18 +525,20 @@ static void fill_gamma_from_crtc(
 
 static void fill_plane_attributes(
 			struct dc_surface *surface,
-			const struct drm_crtc *crtc)
+			struct drm_plane_state *state)
 {
 	const struct amdgpu_framebuffer *amdgpu_fb =
-		to_amdgpu_framebuffer(crtc->primary->state->fb);
-	fill_rects_from_plane_state(crtc->primary->state, surface);
+		to_amdgpu_framebuffer(state->fb);
+	const struct drm_crtc *crtc = state->crtc;
+
+	fill_rects_from_plane_state(state, surface);
 	fill_plane_attributes_from_fb(
 		surface,
 		amdgpu_fb);
 
 	/* In case of gamma set, update gamma value */
 	if (crtc->mode.private_flags &
-			AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET) {
+		AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET) {
 		fill_gamma_from_crtc(crtc, surface);
 	}
 }
@@ -647,7 +649,7 @@ static void dm_dc_surface_commit(
 			dm_state);
 
 	/* Surface programming */
-	fill_plane_attributes(dc_surface, crtc);
+	fill_plane_attributes(dc_surface, crtc->primary->state);
 	if (crtc->mode.private_flags &
 		AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET) {
 		/* reset trigger of gamma */
@@ -2088,14 +2090,15 @@ int amdgpu_dm_atomic_commit(
 		 * aconnector as needed
 		 */
 		handle_headless_hotplug(acrtc, new_state, &aconnector);
-		if (!aconnector) {
+
+		action = get_dm_commit_action(new_state);
+
+		if (!aconnector && action != DM_COMMIT_ACTION_NOTHING) {
 			DRM_ERROR("Can't find connector for crtc %d\n",
 							acrtc->crtc_id);
 			break;
 		}
 
-		action = get_dm_commit_action(new_state);
-
 		switch (action) {
 		case DM_COMMIT_ACTION_DPMS_ON:
 		case DM_COMMIT_ACTION_SET: {
@@ -2319,7 +2322,11 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 	struct drm_crtc_state *crtc_state;
 	struct drm_plane *plane;
 	struct drm_plane_state *plane_state;
-	int i, j, ret, set_count, new_target_count;
+	int i;
+	int j;
+	int ret;
+	int set_count;
+	int new_target_count;
 	struct dc_validation_set set[MAX_TARGET_NUM] = {{ 0 }};
 	struct dc_target *new_targets[MAX_TARGET_NUM] = { 0 };
 	struct amdgpu_device *adev = dev->dev_private;
@@ -2335,11 +2342,6 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 
 	ret = -EINVAL;
 
-	if (state->num_connector > MAX_TARGET_NUM) {
-		DRM_ERROR("Exceeded max targets number !\n");
-		return ret;
-	}
-
 	/* copy existing configuration */
 	new_target_count = 0;
 	set_count = 0;
@@ -2382,14 +2384,27 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 			struct dc_target *new_target = NULL;
 
 			if (!aconnector) {
-				DRM_ERROR("Can't find connector for crtc %d\n",
-								acrtc->crtc_id);
+				DRM_ERROR(
+					"%s: Can't find connector for crtc %d\n",
+					__func__,
+					acrtc->crtc_id);
 				goto connector_not_found;
 			}
+
 			new_target =
 				create_target_for_sink(
 					aconnector,
 					&mode);
+
+			if (!new_target) {
+				DRM_ERROR(
+					"%s: Can't create target for crtc %d\n",
+					__func__,
+					acrtc->crtc_id);
+				goto connector_not_found;
+
+			}
+
 			new_targets[new_target_count] = new_target;
 
 			set_count = update_in_val_sets_target(
@@ -2421,12 +2436,13 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 		for_each_plane_in_state(state, plane, plane_state, j) {
 			struct drm_plane_state *old_plane_state = plane->state;
 			struct drm_framebuffer *fb = plane_state->fb;
-			struct amdgpu_crtc *acrtc =
-					to_amdgpu_crtc(plane_state->crtc);
+			struct drm_crtc *crtc = plane_state->crtc;
+			struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
 			if (!fb || acrtc->target != set[i].target)
 				continue;
-			if (!plane_state->crtc->state->planes_changed)
+
+			if (!crtc->state->planes_changed)
 				continue;
 
 			if (!page_flip_needed(plane_state, old_plane_state)) {
@@ -2434,7 +2450,9 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 					dc_create_surface(dc);
 
 				fill_plane_attributes(
-						surface, plane_state->crtc);
+					surface,
+					plane_state);
+
 				add_val_sets_surface(
 					set,
 					set_count,
@@ -2451,8 +2469,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 connector_not_found:
 	for (i = 0; i < set_count; i++) {
 		for (j = 0; j < set[i].surface_count; j++) {
-			dc_surface_release(
-				(struct dc_surface *)set[i].surfaces[j]);
+			dc_surface_release(set[i].surfaces[j]);
 		}
 	}
 	for (i = 0; i < new_target_count; i++)
-- 
1.9.1