aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0945-drm-amd-dal-split-selection-of-connector-in-commit.patch
blob: 70221e565d9ec037ce4adf5ffbefcf25d59bbb4f (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
From 5f512613798ec70594de754ab1f0bcbb2889427d Mon Sep 17 00:00:00 2001
From: Mykola Lysenko <Mykola.Lysenko@amd.com>
Date: Thu, 10 Dec 2015 20:20:48 +0800
Subject: [PATCH 0945/1050] drm/amd/dal: split selection of connector in commit

During commit there could be situation when there are two connectors
in state. For SET mode action new connector should be used.
For RESET mode action old connector should be used.

In old code there was a situation when OLD connector sink
used for SET mode.

Also it uses new and old connector to update MST semaphore properly

Change-Id: I73a2f95ec8bd41fb6940e927f53dd2ded984ad1c
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    | 45 +++++++++++++---------
 1 file changed, 26 insertions(+), 19 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 e073f20..60e800f 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
@@ -2119,7 +2119,8 @@ int amdgpu_dm_atomic_commit(
 	/* update changed items */
 	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
 		struct amdgpu_crtc *acrtc;
-		struct amdgpu_connector *aconnector = NULL;
+		struct amdgpu_connector *aconnector_new = NULL;
+		struct amdgpu_connector *aconnector_old = NULL;
 		enum dm_commit_action action;
 		struct drm_crtc_state *new_state = crtc->state;
 		struct drm_connector *connector;
@@ -2127,20 +2128,30 @@ int amdgpu_dm_atomic_commit(
 
 		acrtc = to_amdgpu_crtc(crtc);
 
-		for_each_connector_in_state(state,
-				connector, old_con_state, j) {
+		for_each_connector_in_state(
+			state,
+			connector,
+			old_con_state,
+			j) {
 			if (connector->state->crtc == crtc) {
-				aconnector = to_amdgpu_connector(connector);
+				aconnector_new = to_amdgpu_connector(connector);
 				break;
 			}
+		}
 
+		for_each_connector_in_state(
+			state,
+			connector,
+			old_con_state,
+			j) {
 			/*
-			 * this is the case when reset occur, connector is
-			 * removed from new crtc state. We need to update
-			 * connector state anyway. Access it from old_con_state
+			 * this is the case when reset occur, connector
+			 * is removed from new crtc state. We need to
+			 * update connector state anyway. Access it from
+			 * old_con_state
 			 */
 			if (old_con_state->crtc == crtc) {
-				aconnector = to_amdgpu_connector(connector);
+				aconnector_old = to_amdgpu_connector(connector);
 				break;
 			}
 		}
@@ -2148,24 +2159,20 @@ int amdgpu_dm_atomic_commit(
 		/* handles headless hotplug case, updating new_state and
 		 * aconnector as needed
 		 */
-		handle_headless_hotplug(acrtc, new_state, &aconnector);
+		handle_headless_hotplug(acrtc, new_state, &aconnector_new);
 
 		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;
-		}
-
 		switch (action) {
 		case DM_COMMIT_ACTION_DPMS_ON:
 		case DM_COMMIT_ACTION_SET: {
 			struct dc_target *new_target =
 				create_target_for_sink(
-					aconnector,
+					aconnector_new,
 					&crtc->state->mode);
+
 			DRM_DEBUG_KMS("Atomic commit: SET.\n");
+
 			if (!new_target) {
 				/*
 				 * this could happen because of issues with
@@ -2191,7 +2198,7 @@ int amdgpu_dm_atomic_commit(
 				/* this is the update mode case */
 				dc_target_release(acrtc->target);
 				acrtc->target = NULL;
-				up(&aconnector->mst_sem);
+				up(&aconnector_old->mst_sem);
 			}
 
 			/*
@@ -2205,7 +2212,7 @@ int amdgpu_dm_atomic_commit(
 			acrtc->target = new_target;
 			acrtc->enabled = true;
 
-			down(&aconnector->mst_sem);
+			down(&aconnector_new->mst_sem);
 			break;
 		}
 
@@ -2223,7 +2230,7 @@ int amdgpu_dm_atomic_commit(
 				acrtc->target = NULL;
 				acrtc->enabled = false;
 
-				up(&aconnector->mst_sem);
+				up(&aconnector_old->mst_sem);
 			}
 			break;
 		} /* switch() */
-- 
1.9.1