aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0894-drm-amd-dal-allocate-structures-in-temp_params-separ.patch
blob: 0ceb1fee8abc9df775d54857184b53ccd898239e (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
From 79ec3f43623e99119beb903e1e4214744dc25f6d Mon Sep 17 00:00:00 2001
From: Eric Yang <eric.yang2@amd.com>
Date: Wed, 9 Mar 2016 17:09:53 -0500
Subject: [PATCH 0894/1110] drm/amd/dal: allocate structures in temp_params
 separately

The temp_params structure was very big (117648 bytes) and fails
to allocate on some systems in suspend/resume. This causes gamma
to not be programmed and color corruption seen on resume.

Signed-off-by: Eric Yang <eric.yang2@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/calcs/gamma_calcs.c     | 62 ++++++++++++++++++----
 .../drm/amd/dal/dc/dce110/dce110_hw_sequencer.c    | 15 ++----
 drivers/gpu/drm/amd/dal/dc/inc/gamma_calcs.h       | 14 +----
 3 files changed, 57 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/amd/dal/dc/calcs/gamma_calcs.c b/drivers/gpu/drm/amd/dal/dc/calcs/gamma_calcs.c
index 9c18bda..0ddd961 100644
--- a/drivers/gpu/drm/amd/dal/dc/calcs/gamma_calcs.c
+++ b/drivers/gpu/drm/amd/dal/dc/calcs/gamma_calcs.c
@@ -1284,22 +1284,47 @@ static bool convert_to_custom_float(
 	return true;
 }
 
-void calculate_regamma_params(struct pwl_params *params,
-		struct temp_params *temp_params,
+bool calculate_regamma_params(struct pwl_params *params,
 		const struct core_gamma *ramp,
 		const struct core_surface *surface)
 {
 	struct gamma_curve *arr_curve_points = params->arr_curve_points;
 	struct curve_points *arr_points = params->arr_points;
-	struct hw_x_point *coordinates_x = temp_params->coordinates_x;
-	struct pwl_float_data *rgb_user = temp_params->rgb_user;
-	struct pwl_float_data_ex *rgb_regamma = temp_params->rgb_regamma;
-	struct pwl_float_data *rgb_oem = temp_params->rgb_oem;
 	struct pwl_result_data *rgb_resulted = params->rgb_resulted;
 	struct dividers dividers;
-	struct gamma_pixel *axix_x_256 = temp_params->axix_x_256;
-	struct pixel_gamma_point *coeff128_oem = temp_params->coeff128_oem;
-	struct pixel_gamma_point *coeff128 = temp_params->coeff128;
+
+	struct hw_x_point *coordinates_x = NULL;
+	struct pwl_float_data *rgb_user = NULL ;
+	struct pwl_float_data_ex *rgb_regamma = NULL;
+	struct pwl_float_data *rgb_oem = NULL;
+	struct gamma_pixel *axix_x_256 = NULL;
+	struct pixel_gamma_point *coeff128_oem = NULL;
+	struct pixel_gamma_point *coeff128 = NULL;
+
+
+	bool ret = false;
+
+	coordinates_x = dm_alloc(sizeof(*coordinates_x)*(256 + 3));
+	if (!coordinates_x)
+		goto coordinates_x_alloc_fail;
+	rgb_user = dm_alloc(sizeof(*rgb_user) * (FLOAT_GAMMA_RAMP_MAX + 3));
+	if (!rgb_user)
+		goto rgb_user_alloc_fail;
+	rgb_regamma = dm_alloc(sizeof(*rgb_regamma) * (256 + 3));
+	if (!rgb_regamma)
+		goto rgb_regamma_alloc_fail;
+	rgb_oem = dm_alloc(sizeof(*rgb_oem) * (FLOAT_GAMMA_RAMP_MAX + 3));
+	if (!rgb_oem)
+		goto rgb_oem_alloc_fail;
+	axix_x_256 = dm_alloc(sizeof(*axix_x_256) * 256);
+	if (!axix_x_256)
+		goto axix_x_256_alloc_fail;
+	coeff128_oem = dm_alloc(sizeof(*coeff128_oem) * (256 + 3));
+	if (!coeff128_oem)
+		goto coeff128_oem_alloc_fail;
+	coeff128 = dm_alloc(sizeof(*coeff128) * (256 + 3));
+	if (!coeff128)
+		goto coeff128_alloc_fail;
 
 	dividers.divider1 = dal_fixed31_32_from_fraction(3, 2);
 	dividers.divider2 = dal_fixed31_32_from_int(2);
@@ -1334,5 +1359,24 @@ void calculate_regamma_params(struct pwl_params *params,
 
 	convert_to_custom_float(rgb_resulted, arr_points,
 			params->hw_points_num);
+
+	ret = true;
+
+	dm_free(coeff128);
+coeff128_alloc_fail:
+	dm_free(coeff128_oem);
+coeff128_oem_alloc_fail:
+	dm_free(axix_x_256);
+axix_x_256_alloc_fail:
+	dm_free(rgb_oem);
+rgb_oem_alloc_fail:
+	dm_free(rgb_regamma);
+rgb_regamma_alloc_fail:
+	dm_free(rgb_user);
+rgb_user_alloc_fail:
+	dm_free(coordinates_x);
+coordinates_x_alloc_fail:
+	return ret;
+
 }
 
diff --git a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c
index 80faa98..fae2f8a 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c
@@ -512,7 +512,6 @@ static bool set_gamma_ramp(
 {
 	struct ipp_prescale_params *prescale_params;
 	struct pwl_params *regamma_params;
-	struct temp_params *temp_params;
 	bool result = false;
 
 	prescale_params = dm_alloc(sizeof(struct ipp_prescale_params));
@@ -524,11 +523,6 @@ static bool set_gamma_ramp(
 	if (regamma_params == NULL)
 		goto regamma_alloc_fail;
 
-	temp_params = dm_alloc(sizeof(struct temp_params));
-
-	if (temp_params == NULL)
-		goto temp_alloc_fail;
-
 	regamma_params->hw_points_num = GAMMA_HW_POINTS_NUM;
 
 	opp->funcs->opp_power_on_regamma_lut(opp, true);
@@ -538,9 +532,8 @@ static bool set_gamma_ramp(
 		ipp->funcs->ipp_program_prescale(ipp, prescale_params);
 	}
 
-	if (ramp) {
-		calculate_regamma_params(regamma_params,
-				temp_params, ramp, surface);
+	if (ramp && calculate_regamma_params(regamma_params, ramp, surface)) {
+
 		opp->funcs->opp_program_regamma_pwl(opp, regamma_params);
 		if (ipp)
 			ipp->funcs->ipp_set_degamma(ipp, IPP_DEGAMMA_MODE_HW_sRGB);
@@ -553,12 +546,10 @@ static bool set_gamma_ramp(
 
 	opp->funcs->opp_power_on_regamma_lut(opp, false);
 
-	dm_free(temp_params);
-
 	result = true;
 
-temp_alloc_fail:
 	dm_free(regamma_params);
+
 regamma_alloc_fail:
 	dm_free(prescale_params);
 prescale_alloc_fail:
diff --git a/drivers/gpu/drm/amd/dal/dc/inc/gamma_calcs.h b/drivers/gpu/drm/amd/dal/dc/inc/gamma_calcs.h
index baab77a..2064f28 100644
--- a/drivers/gpu/drm/amd/dal/dc/inc/gamma_calcs.h
+++ b/drivers/gpu/drm/amd/dal/dc/inc/gamma_calcs.h
@@ -12,19 +12,7 @@
 #include "core_types.h"
 #include "dc.h"
 
-struct temp_params {
-	struct hw_x_point coordinates_x[256 + 3];
-	struct pwl_float_data rgb_user[FLOAT_GAMMA_RAMP_MAX + 3];
-	struct pwl_float_data_ex rgb_regamma[256 + 3];
-	struct pwl_float_data rgb_oem[FLOAT_GAMMA_RAMP_MAX + 3];
-	struct gamma_pixel axix_x_256[256];
-	struct pixel_gamma_point coeff128_oem[256 + 3];
-	struct pixel_gamma_point coeff128[256 + 3];
-
-};
-
-void calculate_regamma_params(struct pwl_params *params,
-		struct temp_params *temp_params,
+bool calculate_regamma_params(struct pwl_params *params,
 		const struct core_gamma *ramp,
 		const struct core_surface *surface);
 
-- 
2.7.4