summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/mesa
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2017-07-05 18:36:27 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-08 13:34:45 +0100
commit4f93b8528b4f35d8a3f30c5bbb194d52d9e1c0d3 (patch)
tree920e88260bdd0cccb2696942d5f798ffcd241404 /meta/recipes-graphics/mesa
parent103c12221493e799333e69bab5fb72d742c43ddf (diff)
downloadpoky-4f93b8528b4f35d8a3f30c5bbb194d52d9e1c0d3.tar.gz
mesa: etnaviv: fix shader miscompilation with more than 16 labels
The labels array may change its virtual address on a reallocation, so it is invalid to cache pointers into the array. Rather than using the pointer directly, remember the array index. Fixes miscompilation of shaders in glmark2 ideas, leading to GPU hangs. This is a backport from 17.1.5. (From OE-Core rev: 7a0ababb9f5c7f09bf072412e0744dcf69534129) Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-graphics/mesa')
-rw-r--r--meta/recipes-graphics/mesa/files/etnaviv_fix-shader-miscompilation.patch220
-rw-r--r--meta/recipes-graphics/mesa/mesa_17.1.4.bb1
2 files changed, 221 insertions, 0 deletions
diff --git a/meta/recipes-graphics/mesa/files/etnaviv_fix-shader-miscompilation.patch b/meta/recipes-graphics/mesa/files/etnaviv_fix-shader-miscompilation.patch
new file mode 100644
index 0000000000..0354e2a57f
--- /dev/null
+++ b/meta/recipes-graphics/mesa/files/etnaviv_fix-shader-miscompilation.patch
@@ -0,0 +1,220 @@
1From ec43605189907fa327a4a7f457aa3c822cfdea5d Mon Sep 17 00:00:00 2001
2From: Lucas Stach <l.stach@pengutronix.de>
3Date: Mon, 26 Jun 2017 18:24:31 +0200
4Subject: etnaviv: fix shader miscompilation with more than 16 labels
5
6The labels array may change its virtual address on a reallocation, so
7it is invalid to cache pointers into the array. Rather than using the
8pointer directly, remember the array index.
9
10Fixes miscompilation of shaders in glmark2 ideas, leading to GPU hangs.
11
12Fixes: c9e8b49b (etnaviv: gallium driver for Vivante GPUs)
13Cc: mesa-stable@lists.freedesktop.org
14Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
15Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
16
17Upstream-Status: Backport [17.1.5]
18
19diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
20index eafb511..af0f76b 100644
21--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
22+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
23@@ -119,10 +119,10 @@ enum etna_compile_frame_type {
24 */
25 struct etna_compile_frame {
26 enum etna_compile_frame_type type;
27- struct etna_compile_label *lbl_else;
28- struct etna_compile_label *lbl_endif;
29- struct etna_compile_label *lbl_loop_bgn;
30- struct etna_compile_label *lbl_loop_end;
31+ int lbl_else_idx;
32+ int lbl_endif_idx;
33+ int lbl_loop_bgn_idx;
34+ int lbl_loop_end_idx;
35 };
36
37 struct etna_compile_file {
38@@ -178,7 +178,7 @@ struct etna_compile {
39 /* Fields for handling nested conditionals */
40 struct etna_compile_frame frame_stack[ETNA_MAX_DEPTH];
41 int frame_sp;
42- struct etna_compile_label *lbl_usage[ETNA_MAX_INSTRUCTIONS];
43+ int lbl_usage[ETNA_MAX_INSTRUCTIONS];
44
45 unsigned labels_count, labels_sz;
46 struct etna_compile_label *labels;
47@@ -990,7 +990,7 @@ etna_src_uniforms_conflict(struct etna_inst_src a, struct etna_inst_src b)
48 }
49
50 /* create a new label */
51-static struct etna_compile_label *
52+static unsigned int
53 alloc_new_label(struct etna_compile *c)
54 {
55 struct etna_compile_label label = {
56@@ -999,7 +999,7 @@ alloc_new_label(struct etna_compile *c)
57
58 array_insert(c->labels, label);
59
60- return &c->labels[c->labels_count - 1];
61+ return c->labels_count - 1;
62 }
63
64 /* place label at current instruction pointer */
65@@ -1015,10 +1015,10 @@ label_place(struct etna_compile *c, struct etna_compile_label *label)
66 * as the value becomes known.
67 */
68 static void
69-label_mark_use(struct etna_compile *c, struct etna_compile_label *label)
70+label_mark_use(struct etna_compile *c, int lbl_idx)
71 {
72 assert(c->inst_ptr < ETNA_MAX_INSTRUCTIONS);
73- c->lbl_usage[c->inst_ptr] = label;
74+ c->lbl_usage[c->inst_ptr] = lbl_idx;
75 }
76
77 /* walk the frame stack and return first frame with matching type */
78@@ -1099,8 +1099,8 @@ trans_if(const struct instr_translater *t, struct etna_compile *c,
79 /* push IF to stack */
80 f->type = ETNA_COMPILE_FRAME_IF;
81 /* create "else" label */
82- f->lbl_else = alloc_new_label(c);
83- f->lbl_endif = NULL;
84+ f->lbl_else_idx = alloc_new_label(c);
85+ f->lbl_endif_idx = -1;
86
87 /* We need to avoid the emit_inst() below becoming two instructions */
88 if (etna_src_uniforms_conflict(src[0], imm_0))
89@@ -1108,7 +1108,7 @@ trans_if(const struct instr_translater *t, struct etna_compile *c,
90
91 /* mark position in instruction stream of label reference so that it can be
92 * filled in in next pass */
93- label_mark_use(c, f->lbl_else);
94+ label_mark_use(c, f->lbl_else_idx);
95
96 /* create conditional branch to label if src0 EQ 0 */
97 emit_inst(c, &(struct etna_inst){
98@@ -1129,8 +1129,8 @@ trans_else(const struct instr_translater *t, struct etna_compile *c,
99 assert(f->type == ETNA_COMPILE_FRAME_IF);
100
101 /* create "endif" label, and branch to endif label */
102- f->lbl_endif = alloc_new_label(c);
103- label_mark_use(c, f->lbl_endif);
104+ f->lbl_endif_idx = alloc_new_label(c);
105+ label_mark_use(c, f->lbl_endif_idx);
106 emit_inst(c, &(struct etna_inst) {
107 .opcode = INST_OPCODE_BRANCH,
108 .cond = INST_CONDITION_TRUE,
109@@ -1138,7 +1138,7 @@ trans_else(const struct instr_translater *t, struct etna_compile *c,
110 });
111
112 /* mark "else" label at this position in instruction stream */
113- label_place(c, f->lbl_else);
114+ label_place(c, &c->labels[f->lbl_else_idx]);
115 }
116
117 static void
118@@ -1151,10 +1151,10 @@ trans_endif(const struct instr_translater *t, struct etna_compile *c,
119
120 /* assign "endif" or "else" (if no ELSE) label to current position in
121 * instruction stream, pop IF */
122- if (f->lbl_endif != NULL)
123- label_place(c, f->lbl_endif);
124+ if (f->lbl_endif_idx != -1)
125+ label_place(c, &c->labels[f->lbl_endif_idx]);
126 else
127- label_place(c, f->lbl_else);
128+ label_place(c, &c->labels[f->lbl_else_idx]);
129 }
130
131 static void
132@@ -1166,10 +1166,10 @@ trans_loop_bgn(const struct instr_translater *t, struct etna_compile *c,
133
134 /* push LOOP to stack */
135 f->type = ETNA_COMPILE_FRAME_LOOP;
136- f->lbl_loop_bgn = alloc_new_label(c);
137- f->lbl_loop_end = alloc_new_label(c);
138+ f->lbl_loop_bgn_idx = alloc_new_label(c);
139+ f->lbl_loop_end_idx = alloc_new_label(c);
140
141- label_place(c, f->lbl_loop_bgn);
142+ label_place(c, &c->labels[f->lbl_loop_bgn_idx]);
143
144 c->num_loops++;
145 }
146@@ -1185,7 +1185,7 @@ trans_loop_end(const struct instr_translater *t, struct etna_compile *c,
147
148 /* mark position in instruction stream of label reference so that it can be
149 * filled in in next pass */
150- label_mark_use(c, f->lbl_loop_bgn);
151+ label_mark_use(c, f->lbl_loop_bgn_idx);
152
153 /* create branch to loop_bgn label */
154 emit_inst(c, &(struct etna_inst) {
155@@ -1195,7 +1195,7 @@ trans_loop_end(const struct instr_translater *t, struct etna_compile *c,
156 /* imm is filled in later */
157 });
158
159- label_place(c, f->lbl_loop_end);
160+ label_place(c, &c->labels[f->lbl_loop_end_idx]);
161 }
162
163 static void
164@@ -1207,7 +1207,7 @@ trans_brk(const struct instr_translater *t, struct etna_compile *c,
165
166 /* mark position in instruction stream of label reference so that it can be
167 * filled in in next pass */
168- label_mark_use(c, f->lbl_loop_end);
169+ label_mark_use(c, f->lbl_loop_end_idx);
170
171 /* create branch to loop_end label */
172 emit_inst(c, &(struct etna_inst) {
173@@ -1227,7 +1227,7 @@ trans_cont(const struct instr_translater *t, struct etna_compile *c,
174
175 /* mark position in instruction stream of label reference so that it can be
176 * filled in in next pass */
177- label_mark_use(c, f->lbl_loop_bgn);
178+ label_mark_use(c, f->lbl_loop_bgn_idx);
179
180 /* create branch to loop_end label */
181 emit_inst(c, &(struct etna_inst) {
182@@ -1998,8 +1998,9 @@ static void
183 etna_compile_fill_in_labels(struct etna_compile *c)
184 {
185 for (int idx = 0; idx < c->inst_ptr; ++idx) {
186- if (c->lbl_usage[idx])
187- etna_assemble_set_imm(&c->code[idx * 4], c->lbl_usage[idx]->inst_idx);
188+ if (c->lbl_usage[idx] != -1)
189+ etna_assemble_set_imm(&c->code[idx * 4],
190+ c->labels[c->lbl_usage[idx]].inst_idx);
191 }
192 }
193
194@@ -2301,6 +2302,8 @@ etna_compile_shader(struct etna_shader_variant *v)
195 if (!c)
196 return false;
197
198+ memset(&c->lbl_usage, -1, ARRAY_SIZE(c->lbl_usage));
199+
200 const struct tgsi_token *tokens = v->shader->tokens;
201
202 c->specs = specs;
203@@ -2430,12 +2433,13 @@ etna_compile_shader(struct etna_shader_variant *v)
204 etna_compile_add_z_div_if_needed(c);
205 etna_compile_frag_rb_swap(c);
206 etna_compile_add_nop_if_needed(c);
207- etna_compile_fill_in_labels(c);
208
209 ret = etna_compile_check_limits(c);
210 if (!ret)
211 goto out;
212
213+ etna_compile_fill_in_labels(c);
214+
215 /* fill in output structure */
216 v->processor = c->info.processor;
217 v->code_size = c->inst_ptr * 4;
218--
219cgit v0.10.2
220
diff --git a/meta/recipes-graphics/mesa/mesa_17.1.4.bb b/meta/recipes-graphics/mesa/mesa_17.1.4.bb
index 2a1ecd3124..3289cd63a9 100644
--- a/meta/recipes-graphics/mesa/mesa_17.1.4.bb
+++ b/meta/recipes-graphics/mesa/mesa_17.1.4.bb
@@ -3,6 +3,7 @@ require ${BPN}.inc
3SRC_URI = "https://mesa.freedesktop.org/archive/mesa-${PV}.tar.xz \ 3SRC_URI = "https://mesa.freedesktop.org/archive/mesa-${PV}.tar.xz \
4 file://replace_glibc_check_with_linux.patch \ 4 file://replace_glibc_check_with_linux.patch \
5 file://disable-asm-on-non-gcc.patch \ 5 file://disable-asm-on-non-gcc.patch \
6 file://etnaviv_fix-shader-miscompilation.patch \
6 file://0001-Use-wayland-scanner-in-the-path.patch \ 7 file://0001-Use-wayland-scanner-in-the-path.patch \
7 file://0002-hardware-gloat.patch \ 8 file://0002-hardware-gloat.patch \
8" 9"