aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0950-drm-amd-dal-check-stream-on-payload-table-update.patch
blob: dd0afa6d67d78bfd02206fb8fb96306c596889d4 (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
From 596691ce6e0086573d7fecbadfda2ad960b8c0e3 Mon Sep 17 00:00:00 2001
From: Mykola Lysenko <Mykola.Lysenko@amd.com>
Date: Mon, 14 Dec 2015 19:04:17 +0800
Subject: [PATCH 0950/1050] drm/amd/dal: check stream on payload table update

There is a situation when drm crtc moved from one connector
to another, and MST connector can lack DC target for one
commit. It should be guarded both in DM and DC

Change-Id: I85da568d8bd92beab14c575b75fbe6b84dd6028f
Signed-off-by: Mykola Lysenko <Mykola.Lysenko@amd.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Acked-by: Harry Wentland<harry.wentland@amd.com>
---
 .../gpu/drm/amd/dal/amdgpu_dm/amdgpu_dc_helpers.c  |  8 ++++
 .../drm/amd/dal/dc/dce110/dce110_link_encoder.c    | 47 ++++++++++++++--------
 2 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dc_helpers.c b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dc_helpers.c
index f2d1dc8..0230ee9 100644
--- a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dc_helpers.c
+++ b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dc_helpers.c
@@ -311,6 +311,14 @@ bool dc_helpers_dp_mst_write_payload_allocation_table(
 			 * crtc -> target -> stream -> sink
 			 */
 			crtc = aconnector->base.state->crtc;
+
+			/*
+			 * this situation can happen when crtc moved from one
+			 * connector to another for any reason
+			 */
+			if (!crtc)
+				continue;
+
 			amdgpu_crtc = to_amdgpu_crtc(crtc);
 			dc_target = amdgpu_crtc->target;
 
diff --git a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c
index 8ddccdf..d71efa9 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c
@@ -1630,6 +1630,24 @@ void dce110_link_encoder_set_dp_phy_pattern(
 	}
 }
 
+static void fill_stream_allocation_row_info(
+	const struct dp_mst_stream_allocation *stream_allocation,
+	uint32_t *src,
+	uint32_t *slots)
+{
+	const struct dc_stream *dc_stream = stream_allocation->stream;
+	struct core_stream *core_stream;
+
+	if (dc_stream) {
+		core_stream = DC_STREAM_TO_CORE(dc_stream);
+		*src = core_stream->stream_enc->id;
+		*slots = stream_allocation->slot_count;
+	} else {
+		*src = 0;
+		*slots = 0;
+	}
+}
+
 /* programs DP MST VC payload allocation */
 void dce110_link_encoder_update_mst_stream_allocation_table(
 	struct link_encoder *enc,
@@ -1642,8 +1660,6 @@ void dce110_link_encoder_update_mst_stream_allocation_table(
 	uint32_t slots = 0;
 	uint32_t src = 0;
 	uint32_t retries = 0;
-	struct core_stream *core_stream = NULL;
-
 
 	/* For CZ, there are only 3 pipes. So Virtual channel is up 3.*/
 
@@ -1657,11 +1673,10 @@ void dce110_link_encoder_update_mst_stream_allocation_table(
 	value1 = dal_read_reg(ctx, DP_REG(mmDP_MSE_SAT1));
 
 	if (table->stream_count >= 1) {
-		core_stream =
-			DC_STREAM_TO_CORE(table->stream_allocations[0].stream);
-
-		src = core_stream->stream_enc->id;
-		slots = table->stream_allocations[0].slot_count;
+		fill_stream_allocation_row_info(
+			&table->stream_allocations[0],
+			&src,
+			&slots);
 	} else {
 		src = 0;
 		slots = 0;
@@ -1680,11 +1695,10 @@ void dce110_link_encoder_update_mst_stream_allocation_table(
 		DP_MSE_SAT_SLOT_COUNT0);
 
 	if (table->stream_count >= 2) {
-		core_stream =
-			DC_STREAM_TO_CORE(table->stream_allocations[1].stream);
-
-		src = core_stream->stream_enc->id;
-		slots = table->stream_allocations[1].slot_count;
+		fill_stream_allocation_row_info(
+			&table->stream_allocations[1],
+			&src,
+			&slots);
 	} else {
 		src = 0;
 		slots = 0;
@@ -1703,11 +1717,10 @@ void dce110_link_encoder_update_mst_stream_allocation_table(
 		DP_MSE_SAT_SLOT_COUNT1);
 
 	if (table->stream_count >= 3) {
-		core_stream =
-			DC_STREAM_TO_CORE(table->stream_allocations[2].stream);
-
-		src = core_stream->stream_enc->id;
-		slots = table->stream_allocations[2].slot_count;
+		fill_stream_allocation_row_info(
+			&table->stream_allocations[2],
+			&src,
+			&slots);
 	} else {
 		src = 0;
 		slots = 0;
-- 
1.9.1