1 |
commit: e3e2cb00d3cd51ee0e0f642dd67f6fe06bb79801 |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Sep 27 16:38:38 2017 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Sep 27 16:38:38 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=e3e2cb00 |
7 |
|
8 |
Linux patch 4.9.52 |
9 |
|
10 |
0000_README | 4 + |
11 |
1051_linux-4.9.52.patch | 3985 +++++++++++++++++++++++++++++++++++++++++++++++ |
12 |
2 files changed, 3989 insertions(+) |
13 |
|
14 |
diff --git a/0000_README b/0000_README |
15 |
index 54efac8..2ae097d 100644 |
16 |
--- a/0000_README |
17 |
+++ b/0000_README |
18 |
@@ -247,6 +247,10 @@ Patch: 1050_linux-4.9.51.patch |
19 |
From: http://www.kernel.org |
20 |
Desc: Linux 4.9.51 |
21 |
|
22 |
+Patch: 1051_linux-4.9.52.patch |
23 |
+From: http://www.kernel.org |
24 |
+Desc: Linux 4.9.52 |
25 |
+ |
26 |
Patch: 1500_XATTR_USER_PREFIX.patch |
27 |
From: https://bugs.gentoo.org/show_bug.cgi?id=470644 |
28 |
Desc: Support for namespace user.pax.* on tmpfs. |
29 |
|
30 |
diff --git a/1051_linux-4.9.52.patch b/1051_linux-4.9.52.patch |
31 |
new file mode 100644 |
32 |
index 0000000..6e49cca |
33 |
--- /dev/null |
34 |
+++ b/1051_linux-4.9.52.patch |
35 |
@@ -0,0 +1,3985 @@ |
36 |
+diff --git a/Makefile b/Makefile |
37 |
+index b48aebbe187f..c53de1e38c6a 100644 |
38 |
+--- a/Makefile |
39 |
++++ b/Makefile |
40 |
+@@ -1,6 +1,6 @@ |
41 |
+ VERSION = 4 |
42 |
+ PATCHLEVEL = 9 |
43 |
+-SUBLEVEL = 51 |
44 |
++SUBLEVEL = 52 |
45 |
+ EXTRAVERSION = |
46 |
+ NAME = Roaring Lionus |
47 |
+ |
48 |
+diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S |
49 |
+index 1eea99beecc3..85d9ea4a0acc 100644 |
50 |
+--- a/arch/arc/kernel/entry.S |
51 |
++++ b/arch/arc/kernel/entry.S |
52 |
+@@ -92,6 +92,12 @@ ENTRY(EV_MachineCheck) |
53 |
+ lr r0, [efa] |
54 |
+ mov r1, sp |
55 |
+ |
56 |
++ ; hardware auto-disables MMU, re-enable it to allow kernel vaddr |
57 |
++ ; access for say stack unwinding of modules for crash dumps |
58 |
++ lr r3, [ARC_REG_PID] |
59 |
++ or r3, r3, MMU_ENABLE |
60 |
++ sr r3, [ARC_REG_PID] |
61 |
++ |
62 |
+ lsr r3, r2, 8 |
63 |
+ bmsk r3, r3, 7 |
64 |
+ brne r3, ECR_C_MCHK_DUP_TLB, 1f |
65 |
+diff --git a/arch/arc/mm/tlb.c b/arch/arc/mm/tlb.c |
66 |
+index bdb295e09160..a4dc881da277 100644 |
67 |
+--- a/arch/arc/mm/tlb.c |
68 |
++++ b/arch/arc/mm/tlb.c |
69 |
+@@ -896,9 +896,6 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address, |
70 |
+ |
71 |
+ local_irq_save(flags); |
72 |
+ |
73 |
+- /* re-enable the MMU */ |
74 |
+- write_aux_reg(ARC_REG_PID, MMU_ENABLE | read_aux_reg(ARC_REG_PID)); |
75 |
+- |
76 |
+ /* loop thru all sets of TLB */ |
77 |
+ for (set = 0; set < mmu->sets; set++) { |
78 |
+ |
79 |
+diff --git a/arch/mips/math-emu/dp_fmax.c b/arch/mips/math-emu/dp_fmax.c |
80 |
+index fd71b8daaaf2..5bec64f2884e 100644 |
81 |
+--- a/arch/mips/math-emu/dp_fmax.c |
82 |
++++ b/arch/mips/math-emu/dp_fmax.c |
83 |
+@@ -47,14 +47,26 @@ union ieee754dp ieee754dp_fmax(union ieee754dp x, union ieee754dp y) |
84 |
+ case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): |
85 |
+ return ieee754dp_nanxcpt(x); |
86 |
+ |
87 |
+- /* numbers are preferred to NaNs */ |
88 |
++ /* |
89 |
++ * Quiet NaN handling |
90 |
++ */ |
91 |
++ |
92 |
++ /* |
93 |
++ * The case of both inputs quiet NaNs |
94 |
++ */ |
95 |
++ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
96 |
++ return x; |
97 |
++ |
98 |
++ /* |
99 |
++ * The cases of exactly one input quiet NaN (numbers |
100 |
++ * are here preferred as returned values to NaNs) |
101 |
++ */ |
102 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): |
103 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): |
104 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_QNAN): |
105 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): |
106 |
+ return x; |
107 |
+ |
108 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
109 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_ZERO): |
110 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_NORM): |
111 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_DNORM): |
112 |
+@@ -80,9 +92,7 @@ union ieee754dp ieee754dp_fmax(union ieee754dp x, union ieee754dp y) |
113 |
+ return ys ? x : y; |
114 |
+ |
115 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): |
116 |
+- if (xs == ys) |
117 |
+- return x; |
118 |
+- return ieee754dp_zero(1); |
119 |
++ return ieee754dp_zero(xs & ys); |
120 |
+ |
121 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): |
122 |
+ DPDNORMX; |
123 |
+@@ -106,16 +116,32 @@ union ieee754dp ieee754dp_fmax(union ieee754dp x, union ieee754dp y) |
124 |
+ else if (xs < ys) |
125 |
+ return x; |
126 |
+ |
127 |
+- /* Compare exponent */ |
128 |
+- if (xe > ye) |
129 |
+- return x; |
130 |
+- else if (xe < ye) |
131 |
+- return y; |
132 |
++ /* Signs of inputs are equal, let's compare exponents */ |
133 |
++ if (xs == 0) { |
134 |
++ /* Inputs are both positive */ |
135 |
++ if (xe > ye) |
136 |
++ return x; |
137 |
++ else if (xe < ye) |
138 |
++ return y; |
139 |
++ } else { |
140 |
++ /* Inputs are both negative */ |
141 |
++ if (xe > ye) |
142 |
++ return y; |
143 |
++ else if (xe < ye) |
144 |
++ return x; |
145 |
++ } |
146 |
+ |
147 |
+- /* Compare mantissa */ |
148 |
++ /* Signs and exponents of inputs are equal, let's compare mantissas */ |
149 |
++ if (xs == 0) { |
150 |
++ /* Inputs are both positive, with equal signs and exponents */ |
151 |
++ if (xm <= ym) |
152 |
++ return y; |
153 |
++ return x; |
154 |
++ } |
155 |
++ /* Inputs are both negative, with equal signs and exponents */ |
156 |
+ if (xm <= ym) |
157 |
+- return y; |
158 |
+- return x; |
159 |
++ return x; |
160 |
++ return y; |
161 |
+ } |
162 |
+ |
163 |
+ union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y) |
164 |
+@@ -147,14 +173,26 @@ union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y) |
165 |
+ case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): |
166 |
+ return ieee754dp_nanxcpt(x); |
167 |
+ |
168 |
+- /* numbers are preferred to NaNs */ |
169 |
++ /* |
170 |
++ * Quiet NaN handling |
171 |
++ */ |
172 |
++ |
173 |
++ /* |
174 |
++ * The case of both inputs quiet NaNs |
175 |
++ */ |
176 |
++ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
177 |
++ return x; |
178 |
++ |
179 |
++ /* |
180 |
++ * The cases of exactly one input quiet NaN (numbers |
181 |
++ * are here preferred as returned values to NaNs) |
182 |
++ */ |
183 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): |
184 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): |
185 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_QNAN): |
186 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): |
187 |
+ return x; |
188 |
+ |
189 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
190 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_ZERO): |
191 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_NORM): |
192 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_DNORM): |
193 |
+@@ -164,6 +202,9 @@ union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y) |
194 |
+ /* |
195 |
+ * Infinity and zero handling |
196 |
+ */ |
197 |
++ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): |
198 |
++ return ieee754dp_inf(xs & ys); |
199 |
++ |
200 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO): |
201 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_NORM): |
202 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): |
203 |
+@@ -171,7 +212,6 @@ union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y) |
204 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO): |
205 |
+ return x; |
206 |
+ |
207 |
+- case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): |
208 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF): |
209 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_INF): |
210 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF): |
211 |
+@@ -180,9 +220,7 @@ union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y) |
212 |
+ return y; |
213 |
+ |
214 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): |
215 |
+- if (xs == ys) |
216 |
+- return x; |
217 |
+- return ieee754dp_zero(1); |
218 |
++ return ieee754dp_zero(xs & ys); |
219 |
+ |
220 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): |
221 |
+ DPDNORMX; |
222 |
+@@ -207,7 +245,11 @@ union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y) |
223 |
+ return y; |
224 |
+ |
225 |
+ /* Compare mantissa */ |
226 |
+- if (xm <= ym) |
227 |
++ if (xm < ym) |
228 |
+ return y; |
229 |
+- return x; |
230 |
++ else if (xm > ym) |
231 |
++ return x; |
232 |
++ else if (xs == 0) |
233 |
++ return x; |
234 |
++ return y; |
235 |
+ } |
236 |
+diff --git a/arch/mips/math-emu/dp_fmin.c b/arch/mips/math-emu/dp_fmin.c |
237 |
+index c1072b0dfb95..a287b23818d8 100644 |
238 |
+--- a/arch/mips/math-emu/dp_fmin.c |
239 |
++++ b/arch/mips/math-emu/dp_fmin.c |
240 |
+@@ -47,14 +47,26 @@ union ieee754dp ieee754dp_fmin(union ieee754dp x, union ieee754dp y) |
241 |
+ case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): |
242 |
+ return ieee754dp_nanxcpt(x); |
243 |
+ |
244 |
+- /* numbers are preferred to NaNs */ |
245 |
++ /* |
246 |
++ * Quiet NaN handling |
247 |
++ */ |
248 |
++ |
249 |
++ /* |
250 |
++ * The case of both inputs quiet NaNs |
251 |
++ */ |
252 |
++ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
253 |
++ return x; |
254 |
++ |
255 |
++ /* |
256 |
++ * The cases of exactly one input quiet NaN (numbers |
257 |
++ * are here preferred as returned values to NaNs) |
258 |
++ */ |
259 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): |
260 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): |
261 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_QNAN): |
262 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): |
263 |
+ return x; |
264 |
+ |
265 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
266 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_ZERO): |
267 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_NORM): |
268 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_DNORM): |
269 |
+@@ -80,9 +92,7 @@ union ieee754dp ieee754dp_fmin(union ieee754dp x, union ieee754dp y) |
270 |
+ return ys ? y : x; |
271 |
+ |
272 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): |
273 |
+- if (xs == ys) |
274 |
+- return x; |
275 |
+- return ieee754dp_zero(1); |
276 |
++ return ieee754dp_zero(xs | ys); |
277 |
+ |
278 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): |
279 |
+ DPDNORMX; |
280 |
+@@ -106,16 +116,32 @@ union ieee754dp ieee754dp_fmin(union ieee754dp x, union ieee754dp y) |
281 |
+ else if (xs < ys) |
282 |
+ return y; |
283 |
+ |
284 |
+- /* Compare exponent */ |
285 |
+- if (xe > ye) |
286 |
+- return y; |
287 |
+- else if (xe < ye) |
288 |
+- return x; |
289 |
++ /* Signs of inputs are the same, let's compare exponents */ |
290 |
++ if (xs == 0) { |
291 |
++ /* Inputs are both positive */ |
292 |
++ if (xe > ye) |
293 |
++ return y; |
294 |
++ else if (xe < ye) |
295 |
++ return x; |
296 |
++ } else { |
297 |
++ /* Inputs are both negative */ |
298 |
++ if (xe > ye) |
299 |
++ return x; |
300 |
++ else if (xe < ye) |
301 |
++ return y; |
302 |
++ } |
303 |
+ |
304 |
+- /* Compare mantissa */ |
305 |
++ /* Signs and exponents of inputs are equal, let's compare mantissas */ |
306 |
++ if (xs == 0) { |
307 |
++ /* Inputs are both positive, with equal signs and exponents */ |
308 |
++ if (xm <= ym) |
309 |
++ return x; |
310 |
++ return y; |
311 |
++ } |
312 |
++ /* Inputs are both negative, with equal signs and exponents */ |
313 |
+ if (xm <= ym) |
314 |
+- return x; |
315 |
+- return y; |
316 |
++ return y; |
317 |
++ return x; |
318 |
+ } |
319 |
+ |
320 |
+ union ieee754dp ieee754dp_fmina(union ieee754dp x, union ieee754dp y) |
321 |
+@@ -147,14 +173,26 @@ union ieee754dp ieee754dp_fmina(union ieee754dp x, union ieee754dp y) |
322 |
+ case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): |
323 |
+ return ieee754dp_nanxcpt(x); |
324 |
+ |
325 |
+- /* numbers are preferred to NaNs */ |
326 |
++ /* |
327 |
++ * Quiet NaN handling |
328 |
++ */ |
329 |
++ |
330 |
++ /* |
331 |
++ * The case of both inputs quiet NaNs |
332 |
++ */ |
333 |
++ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
334 |
++ return x; |
335 |
++ |
336 |
++ /* |
337 |
++ * The cases of exactly one input quiet NaN (numbers |
338 |
++ * are here preferred as returned values to NaNs) |
339 |
++ */ |
340 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): |
341 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): |
342 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_QNAN): |
343 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): |
344 |
+ return x; |
345 |
+ |
346 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
347 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_ZERO): |
348 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_NORM): |
349 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_DNORM): |
350 |
+@@ -164,25 +202,25 @@ union ieee754dp ieee754dp_fmina(union ieee754dp x, union ieee754dp y) |
351 |
+ /* |
352 |
+ * Infinity and zero handling |
353 |
+ */ |
354 |
++ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): |
355 |
++ return ieee754dp_inf(xs | ys); |
356 |
++ |
357 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO): |
358 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_NORM): |
359 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): |
360 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO): |
361 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO): |
362 |
+- return x; |
363 |
++ return y; |
364 |
+ |
365 |
+- case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): |
366 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF): |
367 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_INF): |
368 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF): |
369 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM): |
370 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_DNORM): |
371 |
+- return y; |
372 |
++ return x; |
373 |
+ |
374 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): |
375 |
+- if (xs == ys) |
376 |
+- return x; |
377 |
+- return ieee754dp_zero(1); |
378 |
++ return ieee754dp_zero(xs | ys); |
379 |
+ |
380 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): |
381 |
+ DPDNORMX; |
382 |
+@@ -207,7 +245,11 @@ union ieee754dp ieee754dp_fmina(union ieee754dp x, union ieee754dp y) |
383 |
+ return x; |
384 |
+ |
385 |
+ /* Compare mantissa */ |
386 |
+- if (xm <= ym) |
387 |
++ if (xm < ym) |
388 |
++ return x; |
389 |
++ else if (xm > ym) |
390 |
++ return y; |
391 |
++ else if (xs == 1) |
392 |
+ return x; |
393 |
+ return y; |
394 |
+ } |
395 |
+diff --git a/arch/mips/math-emu/dp_maddf.c b/arch/mips/math-emu/dp_maddf.c |
396 |
+index 4a2d03c72959..e0d9be5fbf4c 100644 |
397 |
+--- a/arch/mips/math-emu/dp_maddf.c |
398 |
++++ b/arch/mips/math-emu/dp_maddf.c |
399 |
+@@ -14,22 +14,45 @@ |
400 |
+ |
401 |
+ #include "ieee754dp.h" |
402 |
+ |
403 |
+-enum maddf_flags { |
404 |
+- maddf_negate_product = 1 << 0, |
405 |
+-}; |
406 |
++ |
407 |
++/* 128 bits shift right logical with rounding. */ |
408 |
++void srl128(u64 *hptr, u64 *lptr, int count) |
409 |
++{ |
410 |
++ u64 low; |
411 |
++ |
412 |
++ if (count >= 128) { |
413 |
++ *lptr = *hptr != 0 || *lptr != 0; |
414 |
++ *hptr = 0; |
415 |
++ } else if (count >= 64) { |
416 |
++ if (count == 64) { |
417 |
++ *lptr = *hptr | (*lptr != 0); |
418 |
++ } else { |
419 |
++ low = *lptr; |
420 |
++ *lptr = *hptr >> (count - 64); |
421 |
++ *lptr |= (*hptr << (128 - count)) != 0 || low != 0; |
422 |
++ } |
423 |
++ *hptr = 0; |
424 |
++ } else { |
425 |
++ low = *lptr; |
426 |
++ *lptr = low >> count | *hptr << (64 - count); |
427 |
++ *lptr |= (low << (64 - count)) != 0; |
428 |
++ *hptr = *hptr >> count; |
429 |
++ } |
430 |
++} |
431 |
+ |
432 |
+ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x, |
433 |
+ union ieee754dp y, enum maddf_flags flags) |
434 |
+ { |
435 |
+ int re; |
436 |
+ int rs; |
437 |
+- u64 rm; |
438 |
+ unsigned lxm; |
439 |
+ unsigned hxm; |
440 |
+ unsigned lym; |
441 |
+ unsigned hym; |
442 |
+ u64 lrm; |
443 |
+ u64 hrm; |
444 |
++ u64 lzm; |
445 |
++ u64 hzm; |
446 |
+ u64 t; |
447 |
+ u64 at; |
448 |
+ int s; |
449 |
+@@ -48,52 +71,34 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x, |
450 |
+ |
451 |
+ ieee754_clearcx(); |
452 |
+ |
453 |
+- switch (zc) { |
454 |
+- case IEEE754_CLASS_SNAN: |
455 |
+- ieee754_setcx(IEEE754_INVALID_OPERATION); |
456 |
++ /* |
457 |
++ * Handle the cases when at least one of x, y or z is a NaN. |
458 |
++ * Order of precedence is sNaN, qNaN and z, x, y. |
459 |
++ */ |
460 |
++ if (zc == IEEE754_CLASS_SNAN) |
461 |
+ return ieee754dp_nanxcpt(z); |
462 |
+- case IEEE754_CLASS_DNORM: |
463 |
+- DPDNORMZ; |
464 |
+- /* QNAN is handled separately below */ |
465 |
+- } |
466 |
+- |
467 |
+- switch (CLPAIR(xc, yc)) { |
468 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_SNAN): |
469 |
+- case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_SNAN): |
470 |
+- case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_SNAN): |
471 |
+- case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_SNAN): |
472 |
+- case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_SNAN): |
473 |
+- return ieee754dp_nanxcpt(y); |
474 |
+- |
475 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_SNAN): |
476 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_QNAN): |
477 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_ZERO): |
478 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM): |
479 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM): |
480 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): |
481 |
++ if (xc == IEEE754_CLASS_SNAN) |
482 |
+ return ieee754dp_nanxcpt(x); |
483 |
+- |
484 |
+- case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): |
485 |
+- case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): |
486 |
+- case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_QNAN): |
487 |
+- case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): |
488 |
++ if (yc == IEEE754_CLASS_SNAN) |
489 |
++ return ieee754dp_nanxcpt(y); |
490 |
++ if (zc == IEEE754_CLASS_QNAN) |
491 |
++ return z; |
492 |
++ if (xc == IEEE754_CLASS_QNAN) |
493 |
++ return x; |
494 |
++ if (yc == IEEE754_CLASS_QNAN) |
495 |
+ return y; |
496 |
+ |
497 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
498 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_ZERO): |
499 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_NORM): |
500 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_DNORM): |
501 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_INF): |
502 |
+- return x; |
503 |
++ if (zc == IEEE754_CLASS_DNORM) |
504 |
++ DPDNORMZ; |
505 |
++ /* ZERO z cases are handled separately below */ |
506 |
+ |
507 |
++ switch (CLPAIR(xc, yc)) { |
508 |
+ |
509 |
+ /* |
510 |
+ * Infinity handling |
511 |
+ */ |
512 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO): |
513 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF): |
514 |
+- if (zc == IEEE754_CLASS_QNAN) |
515 |
+- return z; |
516 |
+ ieee754_setcx(IEEE754_INVALID_OPERATION); |
517 |
+ return ieee754dp_indef(); |
518 |
+ |
519 |
+@@ -102,9 +107,27 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x, |
520 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_NORM): |
521 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): |
522 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): |
523 |
+- if (zc == IEEE754_CLASS_QNAN) |
524 |
+- return z; |
525 |
+- return ieee754dp_inf(xs ^ ys); |
526 |
++ if ((zc == IEEE754_CLASS_INF) && |
527 |
++ ((!(flags & MADDF_NEGATE_PRODUCT) && (zs != (xs ^ ys))) || |
528 |
++ ((flags & MADDF_NEGATE_PRODUCT) && (zs == (xs ^ ys))))) { |
529 |
++ /* |
530 |
++ * Cases of addition of infinities with opposite signs |
531 |
++ * or subtraction of infinities with same signs. |
532 |
++ */ |
533 |
++ ieee754_setcx(IEEE754_INVALID_OPERATION); |
534 |
++ return ieee754dp_indef(); |
535 |
++ } |
536 |
++ /* |
537 |
++ * z is here either not an infinity, or an infinity having the |
538 |
++ * same sign as product (x*y) (in case of MADDF.D instruction) |
539 |
++ * or product -(x*y) (in MSUBF.D case). The result must be an |
540 |
++ * infinity, and its sign is determined only by the value of |
541 |
++ * (flags & MADDF_NEGATE_PRODUCT) and the signs of x and y. |
542 |
++ */ |
543 |
++ if (flags & MADDF_NEGATE_PRODUCT) |
544 |
++ return ieee754dp_inf(1 ^ (xs ^ ys)); |
545 |
++ else |
546 |
++ return ieee754dp_inf(xs ^ ys); |
547 |
+ |
548 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): |
549 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM): |
550 |
+@@ -113,32 +136,42 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x, |
551 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO): |
552 |
+ if (zc == IEEE754_CLASS_INF) |
553 |
+ return ieee754dp_inf(zs); |
554 |
+- /* Multiplication is 0 so just return z */ |
555 |
++ if (zc == IEEE754_CLASS_ZERO) { |
556 |
++ /* Handle cases +0 + (-0) and similar ones. */ |
557 |
++ if ((!(flags & MADDF_NEGATE_PRODUCT) |
558 |
++ && (zs == (xs ^ ys))) || |
559 |
++ ((flags & MADDF_NEGATE_PRODUCT) |
560 |
++ && (zs != (xs ^ ys)))) |
561 |
++ /* |
562 |
++ * Cases of addition of zeros of equal signs |
563 |
++ * or subtraction of zeroes of opposite signs. |
564 |
++ * The sign of the resulting zero is in any |
565 |
++ * such case determined only by the sign of z. |
566 |
++ */ |
567 |
++ return z; |
568 |
++ |
569 |
++ return ieee754dp_zero(ieee754_csr.rm == FPU_CSR_RD); |
570 |
++ } |
571 |
++ /* x*y is here 0, and z is not 0, so just return z */ |
572 |
+ return z; |
573 |
+ |
574 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): |
575 |
+ DPDNORMX; |
576 |
+ |
577 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): |
578 |
+- if (zc == IEEE754_CLASS_QNAN) |
579 |
+- return z; |
580 |
+- else if (zc == IEEE754_CLASS_INF) |
581 |
++ if (zc == IEEE754_CLASS_INF) |
582 |
+ return ieee754dp_inf(zs); |
583 |
+ DPDNORMY; |
584 |
+ break; |
585 |
+ |
586 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_NORM): |
587 |
+- if (zc == IEEE754_CLASS_QNAN) |
588 |
+- return z; |
589 |
+- else if (zc == IEEE754_CLASS_INF) |
590 |
++ if (zc == IEEE754_CLASS_INF) |
591 |
+ return ieee754dp_inf(zs); |
592 |
+ DPDNORMX; |
593 |
+ break; |
594 |
+ |
595 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_NORM): |
596 |
+- if (zc == IEEE754_CLASS_QNAN) |
597 |
+- return z; |
598 |
+- else if (zc == IEEE754_CLASS_INF) |
599 |
++ if (zc == IEEE754_CLASS_INF) |
600 |
+ return ieee754dp_inf(zs); |
601 |
+ /* fall through to real computations */ |
602 |
+ } |
603 |
+@@ -157,7 +190,7 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x, |
604 |
+ |
605 |
+ re = xe + ye; |
606 |
+ rs = xs ^ ys; |
607 |
+- if (flags & maddf_negate_product) |
608 |
++ if (flags & MADDF_NEGATE_PRODUCT) |
609 |
+ rs ^= 1; |
610 |
+ |
611 |
+ /* shunt to top of word */ |
612 |
+@@ -165,7 +198,7 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x, |
613 |
+ ym <<= 64 - (DP_FBITS + 1); |
614 |
+ |
615 |
+ /* |
616 |
+- * Multiply 64 bits xm, ym to give high 64 bits rm with stickness. |
617 |
++ * Multiply 64 bits xm and ym to give 128 bits result in hrm:lrm. |
618 |
+ */ |
619 |
+ |
620 |
+ /* 32 * 32 => 64 */ |
621 |
+@@ -195,78 +228,110 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x, |
622 |
+ |
623 |
+ hrm = hrm + (t >> 32); |
624 |
+ |
625 |
+- rm = hrm | (lrm != 0); |
626 |
+- |
627 |
+- /* |
628 |
+- * Sticky shift down to normal rounding precision. |
629 |
+- */ |
630 |
+- if ((s64) rm < 0) { |
631 |
+- rm = (rm >> (64 - (DP_FBITS + 1 + 3))) | |
632 |
+- ((rm << (DP_FBITS + 1 + 3)) != 0); |
633 |
++ /* Put explicit bit at bit 126 if necessary */ |
634 |
++ if ((int64_t)hrm < 0) { |
635 |
++ lrm = (hrm << 63) | (lrm >> 1); |
636 |
++ hrm = hrm >> 1; |
637 |
+ re++; |
638 |
+- } else { |
639 |
+- rm = (rm >> (64 - (DP_FBITS + 1 + 3 + 1))) | |
640 |
+- ((rm << (DP_FBITS + 1 + 3 + 1)) != 0); |
641 |
+ } |
642 |
+- assert(rm & (DP_HIDDEN_BIT << 3)); |
643 |
+ |
644 |
+- /* And now the addition */ |
645 |
+- assert(zm & DP_HIDDEN_BIT); |
646 |
++ assert(hrm & (1 << 62)); |
647 |
+ |
648 |
+- /* |
649 |
+- * Provide guard,round and stick bit space. |
650 |
+- */ |
651 |
+- zm <<= 3; |
652 |
++ if (zc == IEEE754_CLASS_ZERO) { |
653 |
++ /* |
654 |
++ * Move explicit bit from bit 126 to bit 55 since the |
655 |
++ * ieee754dp_format code expects the mantissa to be |
656 |
++ * 56 bits wide (53 + 3 rounding bits). |
657 |
++ */ |
658 |
++ srl128(&hrm, &lrm, (126 - 55)); |
659 |
++ return ieee754dp_format(rs, re, lrm); |
660 |
++ } |
661 |
++ |
662 |
++ /* Move explicit bit from bit 52 to bit 126 */ |
663 |
++ lzm = 0; |
664 |
++ hzm = zm << 10; |
665 |
++ assert(hzm & (1 << 62)); |
666 |
+ |
667 |
++ /* Make the exponents the same */ |
668 |
+ if (ze > re) { |
669 |
+ /* |
670 |
+ * Have to shift y fraction right to align. |
671 |
+ */ |
672 |
+ s = ze - re; |
673 |
+- rm = XDPSRS(rm, s); |
674 |
++ srl128(&hrm, &lrm, s); |
675 |
+ re += s; |
676 |
+ } else if (re > ze) { |
677 |
+ /* |
678 |
+ * Have to shift x fraction right to align. |
679 |
+ */ |
680 |
+ s = re - ze; |
681 |
+- zm = XDPSRS(zm, s); |
682 |
++ srl128(&hzm, &lzm, s); |
683 |
+ ze += s; |
684 |
+ } |
685 |
+ assert(ze == re); |
686 |
+ assert(ze <= DP_EMAX); |
687 |
+ |
688 |
++ /* Do the addition */ |
689 |
+ if (zs == rs) { |
690 |
+ /* |
691 |
+- * Generate 28 bit result of adding two 27 bit numbers |
692 |
+- * leaving result in xm, xs and xe. |
693 |
++ * Generate 128 bit result by adding two 127 bit numbers |
694 |
++ * leaving result in hzm:lzm, zs and ze. |
695 |
+ */ |
696 |
+- zm = zm + rm; |
697 |
+- |
698 |
+- if (zm >> (DP_FBITS + 1 + 3)) { /* carry out */ |
699 |
+- zm = XDPSRS1(zm); |
700 |
++ hzm = hzm + hrm + (lzm > (lzm + lrm)); |
701 |
++ lzm = lzm + lrm; |
702 |
++ if ((int64_t)hzm < 0) { /* carry out */ |
703 |
++ srl128(&hzm, &lzm, 1); |
704 |
+ ze++; |
705 |
+ } |
706 |
+ } else { |
707 |
+- if (zm >= rm) { |
708 |
+- zm = zm - rm; |
709 |
++ if (hzm > hrm || (hzm == hrm && lzm >= lrm)) { |
710 |
++ hzm = hzm - hrm - (lzm < lrm); |
711 |
++ lzm = lzm - lrm; |
712 |
+ } else { |
713 |
+- zm = rm - zm; |
714 |
++ hzm = hrm - hzm - (lrm < lzm); |
715 |
++ lzm = lrm - lzm; |
716 |
+ zs = rs; |
717 |
+ } |
718 |
+- if (zm == 0) |
719 |
++ if (lzm == 0 && hzm == 0) |
720 |
+ return ieee754dp_zero(ieee754_csr.rm == FPU_CSR_RD); |
721 |
+ |
722 |
+ /* |
723 |
+- * Normalize to rounding precision. |
724 |
++ * Put explicit bit at bit 126 if necessary. |
725 |
+ */ |
726 |
+- while ((zm >> (DP_FBITS + 3)) == 0) { |
727 |
+- zm <<= 1; |
728 |
+- ze--; |
729 |
++ if (hzm == 0) { |
730 |
++ /* left shift by 63 or 64 bits */ |
731 |
++ if ((int64_t)lzm < 0) { |
732 |
++ /* MSB of lzm is the explicit bit */ |
733 |
++ hzm = lzm >> 1; |
734 |
++ lzm = lzm << 63; |
735 |
++ ze -= 63; |
736 |
++ } else { |
737 |
++ hzm = lzm; |
738 |
++ lzm = 0; |
739 |
++ ze -= 64; |
740 |
++ } |
741 |
++ } |
742 |
++ |
743 |
++ t = 0; |
744 |
++ while ((hzm >> (62 - t)) == 0) |
745 |
++ t++; |
746 |
++ |
747 |
++ assert(t <= 62); |
748 |
++ if (t) { |
749 |
++ hzm = hzm << t | lzm >> (64 - t); |
750 |
++ lzm = lzm << t; |
751 |
++ ze -= t; |
752 |
+ } |
753 |
+ } |
754 |
+ |
755 |
+- return ieee754dp_format(zs, ze, zm); |
756 |
++ /* |
757 |
++ * Move explicit bit from bit 126 to bit 55 since the |
758 |
++ * ieee754dp_format code expects the mantissa to be |
759 |
++ * 56 bits wide (53 + 3 rounding bits). |
760 |
++ */ |
761 |
++ srl128(&hzm, &lzm, (126 - 55)); |
762 |
++ |
763 |
++ return ieee754dp_format(zs, ze, lzm); |
764 |
+ } |
765 |
+ |
766 |
+ union ieee754dp ieee754dp_maddf(union ieee754dp z, union ieee754dp x, |
767 |
+@@ -278,5 +343,5 @@ union ieee754dp ieee754dp_maddf(union ieee754dp z, union ieee754dp x, |
768 |
+ union ieee754dp ieee754dp_msubf(union ieee754dp z, union ieee754dp x, |
769 |
+ union ieee754dp y) |
770 |
+ { |
771 |
+- return _dp_maddf(z, x, y, maddf_negate_product); |
772 |
++ return _dp_maddf(z, x, y, MADDF_NEGATE_PRODUCT); |
773 |
+ } |
774 |
+diff --git a/arch/mips/math-emu/ieee754int.h b/arch/mips/math-emu/ieee754int.h |
775 |
+index 8bc2f6963324..dd2071f430e0 100644 |
776 |
+--- a/arch/mips/math-emu/ieee754int.h |
777 |
++++ b/arch/mips/math-emu/ieee754int.h |
778 |
+@@ -26,6 +26,10 @@ |
779 |
+ |
780 |
+ #define CLPAIR(x, y) ((x)*6+(y)) |
781 |
+ |
782 |
++enum maddf_flags { |
783 |
++ MADDF_NEGATE_PRODUCT = 1 << 0, |
784 |
++}; |
785 |
++ |
786 |
+ static inline void ieee754_clearcx(void) |
787 |
+ { |
788 |
+ ieee754_csr.cx = 0; |
789 |
+diff --git a/arch/mips/math-emu/ieee754sp.h b/arch/mips/math-emu/ieee754sp.h |
790 |
+index 8476067075fe..0f63e4202cff 100644 |
791 |
+--- a/arch/mips/math-emu/ieee754sp.h |
792 |
++++ b/arch/mips/math-emu/ieee754sp.h |
793 |
+@@ -45,6 +45,10 @@ static inline int ieee754sp_finite(union ieee754sp x) |
794 |
+ return SPBEXP(x) != SP_EMAX + 1 + SP_EBIAS; |
795 |
+ } |
796 |
+ |
797 |
++/* 64 bit right shift with rounding */ |
798 |
++#define XSPSRS64(v, rs) \ |
799 |
++ (((rs) >= 64) ? ((v) != 0) : ((v) >> (rs)) | ((v) << (64-(rs)) != 0)) |
800 |
++ |
801 |
+ /* 3bit extended single precision sticky right shift */ |
802 |
+ #define XSPSRS(v, rs) \ |
803 |
+ ((rs > (SP_FBITS+3))?1:((v) >> (rs)) | ((v) << (32-(rs)) != 0)) |
804 |
+diff --git a/arch/mips/math-emu/sp_fmax.c b/arch/mips/math-emu/sp_fmax.c |
805 |
+index 4d000844e48e..74a5a00d2f22 100644 |
806 |
+--- a/arch/mips/math-emu/sp_fmax.c |
807 |
++++ b/arch/mips/math-emu/sp_fmax.c |
808 |
+@@ -47,14 +47,26 @@ union ieee754sp ieee754sp_fmax(union ieee754sp x, union ieee754sp y) |
809 |
+ case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): |
810 |
+ return ieee754sp_nanxcpt(x); |
811 |
+ |
812 |
+- /* numbers are preferred to NaNs */ |
813 |
++ /* |
814 |
++ * Quiet NaN handling |
815 |
++ */ |
816 |
++ |
817 |
++ /* |
818 |
++ * The case of both inputs quiet NaNs |
819 |
++ */ |
820 |
++ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
821 |
++ return x; |
822 |
++ |
823 |
++ /* |
824 |
++ * The cases of exactly one input quiet NaN (numbers |
825 |
++ * are here preferred as returned values to NaNs) |
826 |
++ */ |
827 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): |
828 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): |
829 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_QNAN): |
830 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): |
831 |
+ return x; |
832 |
+ |
833 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
834 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_ZERO): |
835 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_NORM): |
836 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_DNORM): |
837 |
+@@ -80,9 +92,7 @@ union ieee754sp ieee754sp_fmax(union ieee754sp x, union ieee754sp y) |
838 |
+ return ys ? x : y; |
839 |
+ |
840 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): |
841 |
+- if (xs == ys) |
842 |
+- return x; |
843 |
+- return ieee754sp_zero(1); |
844 |
++ return ieee754sp_zero(xs & ys); |
845 |
+ |
846 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): |
847 |
+ SPDNORMX; |
848 |
+@@ -106,16 +116,32 @@ union ieee754sp ieee754sp_fmax(union ieee754sp x, union ieee754sp y) |
849 |
+ else if (xs < ys) |
850 |
+ return x; |
851 |
+ |
852 |
+- /* Compare exponent */ |
853 |
+- if (xe > ye) |
854 |
+- return x; |
855 |
+- else if (xe < ye) |
856 |
+- return y; |
857 |
++ /* Signs of inputs are equal, let's compare exponents */ |
858 |
++ if (xs == 0) { |
859 |
++ /* Inputs are both positive */ |
860 |
++ if (xe > ye) |
861 |
++ return x; |
862 |
++ else if (xe < ye) |
863 |
++ return y; |
864 |
++ } else { |
865 |
++ /* Inputs are both negative */ |
866 |
++ if (xe > ye) |
867 |
++ return y; |
868 |
++ else if (xe < ye) |
869 |
++ return x; |
870 |
++ } |
871 |
+ |
872 |
+- /* Compare mantissa */ |
873 |
++ /* Signs and exponents of inputs are equal, let's compare mantissas */ |
874 |
++ if (xs == 0) { |
875 |
++ /* Inputs are both positive, with equal signs and exponents */ |
876 |
++ if (xm <= ym) |
877 |
++ return y; |
878 |
++ return x; |
879 |
++ } |
880 |
++ /* Inputs are both negative, with equal signs and exponents */ |
881 |
+ if (xm <= ym) |
882 |
+- return y; |
883 |
+- return x; |
884 |
++ return x; |
885 |
++ return y; |
886 |
+ } |
887 |
+ |
888 |
+ union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y) |
889 |
+@@ -147,14 +173,26 @@ union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y) |
890 |
+ case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): |
891 |
+ return ieee754sp_nanxcpt(x); |
892 |
+ |
893 |
+- /* numbers are preferred to NaNs */ |
894 |
++ /* |
895 |
++ * Quiet NaN handling |
896 |
++ */ |
897 |
++ |
898 |
++ /* |
899 |
++ * The case of both inputs quiet NaNs |
900 |
++ */ |
901 |
++ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
902 |
++ return x; |
903 |
++ |
904 |
++ /* |
905 |
++ * The cases of exactly one input quiet NaN (numbers |
906 |
++ * are here preferred as returned values to NaNs) |
907 |
++ */ |
908 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): |
909 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): |
910 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_QNAN): |
911 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): |
912 |
+ return x; |
913 |
+ |
914 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
915 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_ZERO): |
916 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_NORM): |
917 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_DNORM): |
918 |
+@@ -164,6 +202,9 @@ union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y) |
919 |
+ /* |
920 |
+ * Infinity and zero handling |
921 |
+ */ |
922 |
++ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): |
923 |
++ return ieee754sp_inf(xs & ys); |
924 |
++ |
925 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO): |
926 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_NORM): |
927 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): |
928 |
+@@ -171,7 +212,6 @@ union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y) |
929 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO): |
930 |
+ return x; |
931 |
+ |
932 |
+- case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): |
933 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF): |
934 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_INF): |
935 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF): |
936 |
+@@ -180,9 +220,7 @@ union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y) |
937 |
+ return y; |
938 |
+ |
939 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): |
940 |
+- if (xs == ys) |
941 |
+- return x; |
942 |
+- return ieee754sp_zero(1); |
943 |
++ return ieee754sp_zero(xs & ys); |
944 |
+ |
945 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): |
946 |
+ SPDNORMX; |
947 |
+@@ -207,7 +245,11 @@ union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y) |
948 |
+ return y; |
949 |
+ |
950 |
+ /* Compare mantissa */ |
951 |
+- if (xm <= ym) |
952 |
++ if (xm < ym) |
953 |
+ return y; |
954 |
+- return x; |
955 |
++ else if (xm > ym) |
956 |
++ return x; |
957 |
++ else if (xs == 0) |
958 |
++ return x; |
959 |
++ return y; |
960 |
+ } |
961 |
+diff --git a/arch/mips/math-emu/sp_fmin.c b/arch/mips/math-emu/sp_fmin.c |
962 |
+index 4eb1bb9e9dec..c51385f46b09 100644 |
963 |
+--- a/arch/mips/math-emu/sp_fmin.c |
964 |
++++ b/arch/mips/math-emu/sp_fmin.c |
965 |
+@@ -47,14 +47,26 @@ union ieee754sp ieee754sp_fmin(union ieee754sp x, union ieee754sp y) |
966 |
+ case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): |
967 |
+ return ieee754sp_nanxcpt(x); |
968 |
+ |
969 |
+- /* numbers are preferred to NaNs */ |
970 |
++ /* |
971 |
++ * Quiet NaN handling |
972 |
++ */ |
973 |
++ |
974 |
++ /* |
975 |
++ * The case of both inputs quiet NaNs |
976 |
++ */ |
977 |
++ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
978 |
++ return x; |
979 |
++ |
980 |
++ /* |
981 |
++ * The cases of exactly one input quiet NaN (numbers |
982 |
++ * are here preferred as returned values to NaNs) |
983 |
++ */ |
984 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): |
985 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): |
986 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_QNAN): |
987 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): |
988 |
+ return x; |
989 |
+ |
990 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
991 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_ZERO): |
992 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_NORM): |
993 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_DNORM): |
994 |
+@@ -80,9 +92,7 @@ union ieee754sp ieee754sp_fmin(union ieee754sp x, union ieee754sp y) |
995 |
+ return ys ? y : x; |
996 |
+ |
997 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): |
998 |
+- if (xs == ys) |
999 |
+- return x; |
1000 |
+- return ieee754sp_zero(1); |
1001 |
++ return ieee754sp_zero(xs | ys); |
1002 |
+ |
1003 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): |
1004 |
+ SPDNORMX; |
1005 |
+@@ -106,16 +116,32 @@ union ieee754sp ieee754sp_fmin(union ieee754sp x, union ieee754sp y) |
1006 |
+ else if (xs < ys) |
1007 |
+ return y; |
1008 |
+ |
1009 |
+- /* Compare exponent */ |
1010 |
+- if (xe > ye) |
1011 |
+- return y; |
1012 |
+- else if (xe < ye) |
1013 |
+- return x; |
1014 |
++ /* Signs of inputs are the same, let's compare exponents */ |
1015 |
++ if (xs == 0) { |
1016 |
++ /* Inputs are both positive */ |
1017 |
++ if (xe > ye) |
1018 |
++ return y; |
1019 |
++ else if (xe < ye) |
1020 |
++ return x; |
1021 |
++ } else { |
1022 |
++ /* Inputs are both negative */ |
1023 |
++ if (xe > ye) |
1024 |
++ return x; |
1025 |
++ else if (xe < ye) |
1026 |
++ return y; |
1027 |
++ } |
1028 |
+ |
1029 |
+- /* Compare mantissa */ |
1030 |
++ /* Signs and exponents of inputs are equal, let's compare mantissas */ |
1031 |
++ if (xs == 0) { |
1032 |
++ /* Inputs are both positive, with equal signs and exponents */ |
1033 |
++ if (xm <= ym) |
1034 |
++ return x; |
1035 |
++ return y; |
1036 |
++ } |
1037 |
++ /* Inputs are both negative, with equal signs and exponents */ |
1038 |
+ if (xm <= ym) |
1039 |
+- return x; |
1040 |
+- return y; |
1041 |
++ return y; |
1042 |
++ return x; |
1043 |
+ } |
1044 |
+ |
1045 |
+ union ieee754sp ieee754sp_fmina(union ieee754sp x, union ieee754sp y) |
1046 |
+@@ -147,14 +173,26 @@ union ieee754sp ieee754sp_fmina(union ieee754sp x, union ieee754sp y) |
1047 |
+ case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): |
1048 |
+ return ieee754sp_nanxcpt(x); |
1049 |
+ |
1050 |
+- /* numbers are preferred to NaNs */ |
1051 |
++ /* |
1052 |
++ * Quiet NaN handling |
1053 |
++ */ |
1054 |
++ |
1055 |
++ /* |
1056 |
++ * The case of both inputs quiet NaNs |
1057 |
++ */ |
1058 |
++ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
1059 |
++ return x; |
1060 |
++ |
1061 |
++ /* |
1062 |
++ * The cases of exactly one input quiet NaN (numbers |
1063 |
++ * are here preferred as returned values to NaNs) |
1064 |
++ */ |
1065 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): |
1066 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): |
1067 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_QNAN): |
1068 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): |
1069 |
+ return x; |
1070 |
+ |
1071 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
1072 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_ZERO): |
1073 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_NORM): |
1074 |
+ case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_DNORM): |
1075 |
+@@ -164,25 +202,25 @@ union ieee754sp ieee754sp_fmina(union ieee754sp x, union ieee754sp y) |
1076 |
+ /* |
1077 |
+ * Infinity and zero handling |
1078 |
+ */ |
1079 |
++ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): |
1080 |
++ return ieee754sp_inf(xs | ys); |
1081 |
++ |
1082 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO): |
1083 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_NORM): |
1084 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): |
1085 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO): |
1086 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO): |
1087 |
+- return x; |
1088 |
++ return y; |
1089 |
+ |
1090 |
+- case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): |
1091 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF): |
1092 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_INF): |
1093 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF): |
1094 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM): |
1095 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_DNORM): |
1096 |
+- return y; |
1097 |
++ return x; |
1098 |
+ |
1099 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): |
1100 |
+- if (xs == ys) |
1101 |
+- return x; |
1102 |
+- return ieee754sp_zero(1); |
1103 |
++ return ieee754sp_zero(xs | ys); |
1104 |
+ |
1105 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): |
1106 |
+ SPDNORMX; |
1107 |
+@@ -207,7 +245,11 @@ union ieee754sp ieee754sp_fmina(union ieee754sp x, union ieee754sp y) |
1108 |
+ return x; |
1109 |
+ |
1110 |
+ /* Compare mantissa */ |
1111 |
+- if (xm <= ym) |
1112 |
++ if (xm < ym) |
1113 |
++ return x; |
1114 |
++ else if (xm > ym) |
1115 |
++ return y; |
1116 |
++ else if (xs == 1) |
1117 |
+ return x; |
1118 |
+ return y; |
1119 |
+ } |
1120 |
+diff --git a/arch/mips/math-emu/sp_maddf.c b/arch/mips/math-emu/sp_maddf.c |
1121 |
+index a8cd8b4f235e..7195fe785d81 100644 |
1122 |
+--- a/arch/mips/math-emu/sp_maddf.c |
1123 |
++++ b/arch/mips/math-emu/sp_maddf.c |
1124 |
+@@ -14,9 +14,6 @@ |
1125 |
+ |
1126 |
+ #include "ieee754sp.h" |
1127 |
+ |
1128 |
+-enum maddf_flags { |
1129 |
+- maddf_negate_product = 1 << 0, |
1130 |
+-}; |
1131 |
+ |
1132 |
+ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x, |
1133 |
+ union ieee754sp y, enum maddf_flags flags) |
1134 |
+@@ -24,14 +21,8 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x, |
1135 |
+ int re; |
1136 |
+ int rs; |
1137 |
+ unsigned rm; |
1138 |
+- unsigned short lxm; |
1139 |
+- unsigned short hxm; |
1140 |
+- unsigned short lym; |
1141 |
+- unsigned short hym; |
1142 |
+- unsigned lrm; |
1143 |
+- unsigned hrm; |
1144 |
+- unsigned t; |
1145 |
+- unsigned at; |
1146 |
++ uint64_t rm64; |
1147 |
++ uint64_t zm64; |
1148 |
+ int s; |
1149 |
+ |
1150 |
+ COMPXSP; |
1151 |
+@@ -48,51 +39,35 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x, |
1152 |
+ |
1153 |
+ ieee754_clearcx(); |
1154 |
+ |
1155 |
+- switch (zc) { |
1156 |
+- case IEEE754_CLASS_SNAN: |
1157 |
+- ieee754_setcx(IEEE754_INVALID_OPERATION); |
1158 |
++ /* |
1159 |
++ * Handle the cases when at least one of x, y or z is a NaN. |
1160 |
++ * Order of precedence is sNaN, qNaN and z, x, y. |
1161 |
++ */ |
1162 |
++ if (zc == IEEE754_CLASS_SNAN) |
1163 |
+ return ieee754sp_nanxcpt(z); |
1164 |
+- case IEEE754_CLASS_DNORM: |
1165 |
+- SPDNORMZ; |
1166 |
+- /* QNAN is handled separately below */ |
1167 |
+- } |
1168 |
+- |
1169 |
+- switch (CLPAIR(xc, yc)) { |
1170 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_SNAN): |
1171 |
+- case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_SNAN): |
1172 |
+- case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_SNAN): |
1173 |
+- case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_SNAN): |
1174 |
+- case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_SNAN): |
1175 |
++ if (xc == IEEE754_CLASS_SNAN) |
1176 |
++ return ieee754sp_nanxcpt(x); |
1177 |
++ if (yc == IEEE754_CLASS_SNAN) |
1178 |
+ return ieee754sp_nanxcpt(y); |
1179 |
++ if (zc == IEEE754_CLASS_QNAN) |
1180 |
++ return z; |
1181 |
++ if (xc == IEEE754_CLASS_QNAN) |
1182 |
++ return x; |
1183 |
++ if (yc == IEEE754_CLASS_QNAN) |
1184 |
++ return y; |
1185 |
+ |
1186 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_SNAN): |
1187 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_QNAN): |
1188 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_ZERO): |
1189 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM): |
1190 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM): |
1191 |
+- case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): |
1192 |
+- return ieee754sp_nanxcpt(x); |
1193 |
++ if (zc == IEEE754_CLASS_DNORM) |
1194 |
++ SPDNORMZ; |
1195 |
++ /* ZERO z cases are handled separately below */ |
1196 |
+ |
1197 |
+- case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): |
1198 |
+- case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): |
1199 |
+- case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_QNAN): |
1200 |
+- case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): |
1201 |
+- return y; |
1202 |
++ switch (CLPAIR(xc, yc)) { |
1203 |
+ |
1204 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): |
1205 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_ZERO): |
1206 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_NORM): |
1207 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_DNORM): |
1208 |
+- case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_INF): |
1209 |
+- return x; |
1210 |
+ |
1211 |
+ /* |
1212 |
+ * Infinity handling |
1213 |
+ */ |
1214 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO): |
1215 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF): |
1216 |
+- if (zc == IEEE754_CLASS_QNAN) |
1217 |
+- return z; |
1218 |
+ ieee754_setcx(IEEE754_INVALID_OPERATION); |
1219 |
+ return ieee754sp_indef(); |
1220 |
+ |
1221 |
+@@ -101,9 +76,27 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x, |
1222 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_NORM): |
1223 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): |
1224 |
+ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): |
1225 |
+- if (zc == IEEE754_CLASS_QNAN) |
1226 |
+- return z; |
1227 |
+- return ieee754sp_inf(xs ^ ys); |
1228 |
++ if ((zc == IEEE754_CLASS_INF) && |
1229 |
++ ((!(flags & MADDF_NEGATE_PRODUCT) && (zs != (xs ^ ys))) || |
1230 |
++ ((flags & MADDF_NEGATE_PRODUCT) && (zs == (xs ^ ys))))) { |
1231 |
++ /* |
1232 |
++ * Cases of addition of infinities with opposite signs |
1233 |
++ * or subtraction of infinities with same signs. |
1234 |
++ */ |
1235 |
++ ieee754_setcx(IEEE754_INVALID_OPERATION); |
1236 |
++ return ieee754sp_indef(); |
1237 |
++ } |
1238 |
++ /* |
1239 |
++ * z is here either not an infinity, or an infinity having the |
1240 |
++ * same sign as product (x*y) (in case of MADDF.D instruction) |
1241 |
++ * or product -(x*y) (in MSUBF.D case). The result must be an |
1242 |
++ * infinity, and its sign is determined only by the value of |
1243 |
++ * (flags & MADDF_NEGATE_PRODUCT) and the signs of x and y. |
1244 |
++ */ |
1245 |
++ if (flags & MADDF_NEGATE_PRODUCT) |
1246 |
++ return ieee754sp_inf(1 ^ (xs ^ ys)); |
1247 |
++ else |
1248 |
++ return ieee754sp_inf(xs ^ ys); |
1249 |
+ |
1250 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): |
1251 |
+ case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM): |
1252 |
+@@ -112,32 +105,42 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x, |
1253 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO): |
1254 |
+ if (zc == IEEE754_CLASS_INF) |
1255 |
+ return ieee754sp_inf(zs); |
1256 |
+- /* Multiplication is 0 so just return z */ |
1257 |
++ if (zc == IEEE754_CLASS_ZERO) { |
1258 |
++ /* Handle cases +0 + (-0) and similar ones. */ |
1259 |
++ if ((!(flags & MADDF_NEGATE_PRODUCT) |
1260 |
++ && (zs == (xs ^ ys))) || |
1261 |
++ ((flags & MADDF_NEGATE_PRODUCT) |
1262 |
++ && (zs != (xs ^ ys)))) |
1263 |
++ /* |
1264 |
++ * Cases of addition of zeros of equal signs |
1265 |
++ * or subtraction of zeroes of opposite signs. |
1266 |
++ * The sign of the resulting zero is in any |
1267 |
++ * such case determined only by the sign of z. |
1268 |
++ */ |
1269 |
++ return z; |
1270 |
++ |
1271 |
++ return ieee754sp_zero(ieee754_csr.rm == FPU_CSR_RD); |
1272 |
++ } |
1273 |
++ /* x*y is here 0, and z is not 0, so just return z */ |
1274 |
+ return z; |
1275 |
+ |
1276 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): |
1277 |
+ SPDNORMX; |
1278 |
+ |
1279 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): |
1280 |
+- if (zc == IEEE754_CLASS_QNAN) |
1281 |
+- return z; |
1282 |
+- else if (zc == IEEE754_CLASS_INF) |
1283 |
++ if (zc == IEEE754_CLASS_INF) |
1284 |
+ return ieee754sp_inf(zs); |
1285 |
+ SPDNORMY; |
1286 |
+ break; |
1287 |
+ |
1288 |
+ case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_NORM): |
1289 |
+- if (zc == IEEE754_CLASS_QNAN) |
1290 |
+- return z; |
1291 |
+- else if (zc == IEEE754_CLASS_INF) |
1292 |
++ if (zc == IEEE754_CLASS_INF) |
1293 |
+ return ieee754sp_inf(zs); |
1294 |
+ SPDNORMX; |
1295 |
+ break; |
1296 |
+ |
1297 |
+ case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_NORM): |
1298 |
+- if (zc == IEEE754_CLASS_QNAN) |
1299 |
+- return z; |
1300 |
+- else if (zc == IEEE754_CLASS_INF) |
1301 |
++ if (zc == IEEE754_CLASS_INF) |
1302 |
+ return ieee754sp_inf(zs); |
1303 |
+ /* fall through to real computations */ |
1304 |
+ } |
1305 |
+@@ -158,108 +161,93 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x, |
1306 |
+ |
1307 |
+ re = xe + ye; |
1308 |
+ rs = xs ^ ys; |
1309 |
+- if (flags & maddf_negate_product) |
1310 |
++ if (flags & MADDF_NEGATE_PRODUCT) |
1311 |
+ rs ^= 1; |
1312 |
+ |
1313 |
+- /* shunt to top of word */ |
1314 |
+- xm <<= 32 - (SP_FBITS + 1); |
1315 |
+- ym <<= 32 - (SP_FBITS + 1); |
1316 |
+- |
1317 |
+- /* |
1318 |
+- * Multiply 32 bits xm, ym to give high 32 bits rm with stickness. |
1319 |
+- */ |
1320 |
+- lxm = xm & 0xffff; |
1321 |
+- hxm = xm >> 16; |
1322 |
+- lym = ym & 0xffff; |
1323 |
+- hym = ym >> 16; |
1324 |
+- |
1325 |
+- lrm = lxm * lym; /* 16 * 16 => 32 */ |
1326 |
+- hrm = hxm * hym; /* 16 * 16 => 32 */ |
1327 |
++ /* Multiple 24 bit xm and ym to give 48 bit results */ |
1328 |
++ rm64 = (uint64_t)xm * ym; |
1329 |
+ |
1330 |
+- t = lxm * hym; /* 16 * 16 => 32 */ |
1331 |
+- at = lrm + (t << 16); |
1332 |
+- hrm += at < lrm; |
1333 |
+- lrm = at; |
1334 |
+- hrm = hrm + (t >> 16); |
1335 |
++ /* Shunt to top of word */ |
1336 |
++ rm64 = rm64 << 16; |
1337 |
+ |
1338 |
+- t = hxm * lym; /* 16 * 16 => 32 */ |
1339 |
+- at = lrm + (t << 16); |
1340 |
+- hrm += at < lrm; |
1341 |
+- lrm = at; |
1342 |
+- hrm = hrm + (t >> 16); |
1343 |
+- |
1344 |
+- rm = hrm | (lrm != 0); |
1345 |
+- |
1346 |
+- /* |
1347 |
+- * Sticky shift down to normal rounding precision. |
1348 |
+- */ |
1349 |
+- if ((int) rm < 0) { |
1350 |
+- rm = (rm >> (32 - (SP_FBITS + 1 + 3))) | |
1351 |
+- ((rm << (SP_FBITS + 1 + 3)) != 0); |
1352 |
++ /* Put explicit bit at bit 62 if necessary */ |
1353 |
++ if ((int64_t) rm64 < 0) { |
1354 |
++ rm64 = rm64 >> 1; |
1355 |
+ re++; |
1356 |
+- } else { |
1357 |
+- rm = (rm >> (32 - (SP_FBITS + 1 + 3 + 1))) | |
1358 |
+- ((rm << (SP_FBITS + 1 + 3 + 1)) != 0); |
1359 |
+ } |
1360 |
+- assert(rm & (SP_HIDDEN_BIT << 3)); |
1361 |
+ |
1362 |
+- /* And now the addition */ |
1363 |
++ assert(rm64 & (1 << 62)); |
1364 |
+ |
1365 |
+- assert(zm & SP_HIDDEN_BIT); |
1366 |
++ if (zc == IEEE754_CLASS_ZERO) { |
1367 |
++ /* |
1368 |
++ * Move explicit bit from bit 62 to bit 26 since the |
1369 |
++ * ieee754sp_format code expects the mantissa to be |
1370 |
++ * 27 bits wide (24 + 3 rounding bits). |
1371 |
++ */ |
1372 |
++ rm = XSPSRS64(rm64, (62 - 26)); |
1373 |
++ return ieee754sp_format(rs, re, rm); |
1374 |
++ } |
1375 |
+ |
1376 |
+- /* |
1377 |
+- * Provide guard,round and stick bit space. |
1378 |
+- */ |
1379 |
+- zm <<= 3; |
1380 |
++ /* Move explicit bit from bit 23 to bit 62 */ |
1381 |
++ zm64 = (uint64_t)zm << (62 - 23); |
1382 |
++ assert(zm64 & (1 << 62)); |
1383 |
+ |
1384 |
++ /* Make the exponents the same */ |
1385 |
+ if (ze > re) { |
1386 |
+ /* |
1387 |
+ * Have to shift r fraction right to align. |
1388 |
+ */ |
1389 |
+ s = ze - re; |
1390 |
+- rm = XSPSRS(rm, s); |
1391 |
++ rm64 = XSPSRS64(rm64, s); |
1392 |
+ re += s; |
1393 |
+ } else if (re > ze) { |
1394 |
+ /* |
1395 |
+ * Have to shift z fraction right to align. |
1396 |
+ */ |
1397 |
+ s = re - ze; |
1398 |
+- zm = XSPSRS(zm, s); |
1399 |
++ zm64 = XSPSRS64(zm64, s); |
1400 |
+ ze += s; |
1401 |
+ } |
1402 |
+ assert(ze == re); |
1403 |
+ assert(ze <= SP_EMAX); |
1404 |
+ |
1405 |
++ /* Do the addition */ |
1406 |
+ if (zs == rs) { |
1407 |
+ /* |
1408 |
+- * Generate 28 bit result of adding two 27 bit numbers |
1409 |
+- * leaving result in zm, zs and ze. |
1410 |
++ * Generate 64 bit result by adding two 63 bit numbers |
1411 |
++ * leaving result in zm64, zs and ze. |
1412 |
+ */ |
1413 |
+- zm = zm + rm; |
1414 |
+- |
1415 |
+- if (zm >> (SP_FBITS + 1 + 3)) { /* carry out */ |
1416 |
+- zm = XSPSRS1(zm); |
1417 |
++ zm64 = zm64 + rm64; |
1418 |
++ if ((int64_t)zm64 < 0) { /* carry out */ |
1419 |
++ zm64 = XSPSRS1(zm64); |
1420 |
+ ze++; |
1421 |
+ } |
1422 |
+ } else { |
1423 |
+- if (zm >= rm) { |
1424 |
+- zm = zm - rm; |
1425 |
++ if (zm64 >= rm64) { |
1426 |
++ zm64 = zm64 - rm64; |
1427 |
+ } else { |
1428 |
+- zm = rm - zm; |
1429 |
++ zm64 = rm64 - zm64; |
1430 |
+ zs = rs; |
1431 |
+ } |
1432 |
+- if (zm == 0) |
1433 |
++ if (zm64 == 0) |
1434 |
+ return ieee754sp_zero(ieee754_csr.rm == FPU_CSR_RD); |
1435 |
+ |
1436 |
+ /* |
1437 |
+- * Normalize in extended single precision |
1438 |
++ * Put explicit bit at bit 62 if necessary. |
1439 |
+ */ |
1440 |
+- while ((zm >> (SP_MBITS + 3)) == 0) { |
1441 |
+- zm <<= 1; |
1442 |
++ while ((zm64 >> 62) == 0) { |
1443 |
++ zm64 <<= 1; |
1444 |
+ ze--; |
1445 |
+ } |
1446 |
+- |
1447 |
+ } |
1448 |
++ |
1449 |
++ /* |
1450 |
++ * Move explicit bit from bit 62 to bit 26 since the |
1451 |
++ * ieee754sp_format code expects the mantissa to be |
1452 |
++ * 27 bits wide (24 + 3 rounding bits). |
1453 |
++ */ |
1454 |
++ zm = XSPSRS64(zm64, (62 - 26)); |
1455 |
++ |
1456 |
+ return ieee754sp_format(zs, ze, zm); |
1457 |
+ } |
1458 |
+ |
1459 |
+@@ -272,5 +260,5 @@ union ieee754sp ieee754sp_maddf(union ieee754sp z, union ieee754sp x, |
1460 |
+ union ieee754sp ieee754sp_msubf(union ieee754sp z, union ieee754sp x, |
1461 |
+ union ieee754sp y) |
1462 |
+ { |
1463 |
+- return _sp_maddf(z, x, y, maddf_negate_product); |
1464 |
++ return _sp_maddf(z, x, y, MADDF_NEGATE_PRODUCT); |
1465 |
+ } |
1466 |
+diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c |
1467 |
+index b2da7c8baed7..292458b694fb 100644 |
1468 |
+--- a/arch/powerpc/kernel/align.c |
1469 |
++++ b/arch/powerpc/kernel/align.c |
1470 |
+@@ -235,6 +235,28 @@ static int emulate_dcbz(struct pt_regs *regs, unsigned char __user *addr) |
1471 |
+ |
1472 |
+ #define SWIZ_PTR(p) ((unsigned char __user *)((p) ^ swiz)) |
1473 |
+ |
1474 |
++#define __get_user_or_set_dar(_regs, _dest, _addr) \ |
1475 |
++ ({ \ |
1476 |
++ int rc = 0; \ |
1477 |
++ typeof(_addr) __addr = (_addr); \ |
1478 |
++ if (__get_user_inatomic(_dest, __addr)) { \ |
1479 |
++ _regs->dar = (unsigned long)__addr; \ |
1480 |
++ rc = -EFAULT; \ |
1481 |
++ } \ |
1482 |
++ rc; \ |
1483 |
++ }) |
1484 |
++ |
1485 |
++#define __put_user_or_set_dar(_regs, _src, _addr) \ |
1486 |
++ ({ \ |
1487 |
++ int rc = 0; \ |
1488 |
++ typeof(_addr) __addr = (_addr); \ |
1489 |
++ if (__put_user_inatomic(_src, __addr)) { \ |
1490 |
++ _regs->dar = (unsigned long)__addr; \ |
1491 |
++ rc = -EFAULT; \ |
1492 |
++ } \ |
1493 |
++ rc; \ |
1494 |
++ }) |
1495 |
++ |
1496 |
+ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr, |
1497 |
+ unsigned int reg, unsigned int nb, |
1498 |
+ unsigned int flags, unsigned int instr, |
1499 |
+@@ -263,9 +285,10 @@ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr, |
1500 |
+ } else { |
1501 |
+ unsigned long pc = regs->nip ^ (swiz & 4); |
1502 |
+ |
1503 |
+- if (__get_user_inatomic(instr, |
1504 |
+- (unsigned int __user *)pc)) |
1505 |
++ if (__get_user_or_set_dar(regs, instr, |
1506 |
++ (unsigned int __user *)pc)) |
1507 |
+ return -EFAULT; |
1508 |
++ |
1509 |
+ if (swiz == 0 && (flags & SW)) |
1510 |
+ instr = cpu_to_le32(instr); |
1511 |
+ nb = (instr >> 11) & 0x1f; |
1512 |
+@@ -309,31 +332,31 @@ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr, |
1513 |
+ ((nb0 + 3) / 4) * sizeof(unsigned long)); |
1514 |
+ |
1515 |
+ for (i = 0; i < nb; ++i, ++p) |
1516 |
+- if (__get_user_inatomic(REG_BYTE(rptr, i ^ bswiz), |
1517 |
+- SWIZ_PTR(p))) |
1518 |
++ if (__get_user_or_set_dar(regs, REG_BYTE(rptr, i ^ bswiz), |
1519 |
++ SWIZ_PTR(p))) |
1520 |
+ return -EFAULT; |
1521 |
+ if (nb0 > 0) { |
1522 |
+ rptr = ®s->gpr[0]; |
1523 |
+ addr += nb; |
1524 |
+ for (i = 0; i < nb0; ++i, ++p) |
1525 |
+- if (__get_user_inatomic(REG_BYTE(rptr, |
1526 |
+- i ^ bswiz), |
1527 |
+- SWIZ_PTR(p))) |
1528 |
++ if (__get_user_or_set_dar(regs, |
1529 |
++ REG_BYTE(rptr, i ^ bswiz), |
1530 |
++ SWIZ_PTR(p))) |
1531 |
+ return -EFAULT; |
1532 |
+ } |
1533 |
+ |
1534 |
+ } else { |
1535 |
+ for (i = 0; i < nb; ++i, ++p) |
1536 |
+- if (__put_user_inatomic(REG_BYTE(rptr, i ^ bswiz), |
1537 |
+- SWIZ_PTR(p))) |
1538 |
++ if (__put_user_or_set_dar(regs, REG_BYTE(rptr, i ^ bswiz), |
1539 |
++ SWIZ_PTR(p))) |
1540 |
+ return -EFAULT; |
1541 |
+ if (nb0 > 0) { |
1542 |
+ rptr = ®s->gpr[0]; |
1543 |
+ addr += nb; |
1544 |
+ for (i = 0; i < nb0; ++i, ++p) |
1545 |
+- if (__put_user_inatomic(REG_BYTE(rptr, |
1546 |
+- i ^ bswiz), |
1547 |
+- SWIZ_PTR(p))) |
1548 |
++ if (__put_user_or_set_dar(regs, |
1549 |
++ REG_BYTE(rptr, i ^ bswiz), |
1550 |
++ SWIZ_PTR(p))) |
1551 |
+ return -EFAULT; |
1552 |
+ } |
1553 |
+ } |
1554 |
+@@ -345,29 +368,32 @@ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr, |
1555 |
+ * Only POWER6 has these instructions, and it does true little-endian, |
1556 |
+ * so we don't need the address swizzling. |
1557 |
+ */ |
1558 |
+-static int emulate_fp_pair(unsigned char __user *addr, unsigned int reg, |
1559 |
+- unsigned int flags) |
1560 |
++static int emulate_fp_pair(struct pt_regs *regs, unsigned char __user *addr, |
1561 |
++ unsigned int reg, unsigned int flags) |
1562 |
+ { |
1563 |
+ char *ptr0 = (char *) ¤t->thread.TS_FPR(reg); |
1564 |
+ char *ptr1 = (char *) ¤t->thread.TS_FPR(reg+1); |
1565 |
+- int i, ret, sw = 0; |
1566 |
++ int i, sw = 0; |
1567 |
+ |
1568 |
+ if (reg & 1) |
1569 |
+ return 0; /* invalid form: FRS/FRT must be even */ |
1570 |
+ if (flags & SW) |
1571 |
+ sw = 7; |
1572 |
+- ret = 0; |
1573 |
++ |
1574 |
+ for (i = 0; i < 8; ++i) { |
1575 |
+ if (!(flags & ST)) { |
1576 |
+- ret |= __get_user(ptr0[i^sw], addr + i); |
1577 |
+- ret |= __get_user(ptr1[i^sw], addr + i + 8); |
1578 |
++ if (__get_user_or_set_dar(regs, ptr0[i^sw], addr + i)) |
1579 |
++ return -EFAULT; |
1580 |
++ if (__get_user_or_set_dar(regs, ptr1[i^sw], addr + i + 8)) |
1581 |
++ return -EFAULT; |
1582 |
+ } else { |
1583 |
+- ret |= __put_user(ptr0[i^sw], addr + i); |
1584 |
+- ret |= __put_user(ptr1[i^sw], addr + i + 8); |
1585 |
++ if (__put_user_or_set_dar(regs, ptr0[i^sw], addr + i)) |
1586 |
++ return -EFAULT; |
1587 |
++ if (__put_user_or_set_dar(regs, ptr1[i^sw], addr + i + 8)) |
1588 |
++ return -EFAULT; |
1589 |
+ } |
1590 |
+ } |
1591 |
+- if (ret) |
1592 |
+- return -EFAULT; |
1593 |
++ |
1594 |
+ return 1; /* exception handled and fixed up */ |
1595 |
+ } |
1596 |
+ |
1597 |
+@@ -377,24 +403,27 @@ static int emulate_lq_stq(struct pt_regs *regs, unsigned char __user *addr, |
1598 |
+ { |
1599 |
+ char *ptr0 = (char *)®s->gpr[reg]; |
1600 |
+ char *ptr1 = (char *)®s->gpr[reg+1]; |
1601 |
+- int i, ret, sw = 0; |
1602 |
++ int i, sw = 0; |
1603 |
+ |
1604 |
+ if (reg & 1) |
1605 |
+ return 0; /* invalid form: GPR must be even */ |
1606 |
+ if (flags & SW) |
1607 |
+ sw = 7; |
1608 |
+- ret = 0; |
1609 |
++ |
1610 |
+ for (i = 0; i < 8; ++i) { |
1611 |
+ if (!(flags & ST)) { |
1612 |
+- ret |= __get_user(ptr0[i^sw], addr + i); |
1613 |
+- ret |= __get_user(ptr1[i^sw], addr + i + 8); |
1614 |
++ if (__get_user_or_set_dar(regs, ptr0[i^sw], addr + i)) |
1615 |
++ return -EFAULT; |
1616 |
++ if (__get_user_or_set_dar(regs, ptr1[i^sw], addr + i + 8)) |
1617 |
++ return -EFAULT; |
1618 |
+ } else { |
1619 |
+- ret |= __put_user(ptr0[i^sw], addr + i); |
1620 |
+- ret |= __put_user(ptr1[i^sw], addr + i + 8); |
1621 |
++ if (__put_user_or_set_dar(regs, ptr0[i^sw], addr + i)) |
1622 |
++ return -EFAULT; |
1623 |
++ if (__put_user_or_set_dar(regs, ptr1[i^sw], addr + i + 8)) |
1624 |
++ return -EFAULT; |
1625 |
+ } |
1626 |
+ } |
1627 |
+- if (ret) |
1628 |
+- return -EFAULT; |
1629 |
++ |
1630 |
+ return 1; /* exception handled and fixed up */ |
1631 |
+ } |
1632 |
+ #endif /* CONFIG_PPC64 */ |
1633 |
+@@ -687,9 +716,14 @@ static int emulate_vsx(unsigned char __user *addr, unsigned int reg, |
1634 |
+ for (j = 0; j < length; j += elsize) { |
1635 |
+ for (i = 0; i < elsize; ++i) { |
1636 |
+ if (flags & ST) |
1637 |
+- ret |= __put_user(ptr[i^sw], addr + i); |
1638 |
++ ret = __put_user_or_set_dar(regs, ptr[i^sw], |
1639 |
++ addr + i); |
1640 |
+ else |
1641 |
+- ret |= __get_user(ptr[i^sw], addr + i); |
1642 |
++ ret = __get_user_or_set_dar(regs, ptr[i^sw], |
1643 |
++ addr + i); |
1644 |
++ |
1645 |
++ if (ret) |
1646 |
++ return ret; |
1647 |
+ } |
1648 |
+ ptr += elsize; |
1649 |
+ #ifdef __LITTLE_ENDIAN__ |
1650 |
+@@ -739,7 +773,7 @@ int fix_alignment(struct pt_regs *regs) |
1651 |
+ unsigned int dsisr; |
1652 |
+ unsigned char __user *addr; |
1653 |
+ unsigned long p, swiz; |
1654 |
+- int ret, i; |
1655 |
++ int i; |
1656 |
+ union data { |
1657 |
+ u64 ll; |
1658 |
+ double dd; |
1659 |
+@@ -936,7 +970,7 @@ int fix_alignment(struct pt_regs *regs) |
1660 |
+ if (flags & F) { |
1661 |
+ /* Special case for 16-byte FP loads and stores */ |
1662 |
+ PPC_WARN_ALIGNMENT(fp_pair, regs); |
1663 |
+- return emulate_fp_pair(addr, reg, flags); |
1664 |
++ return emulate_fp_pair(regs, addr, reg, flags); |
1665 |
+ } else { |
1666 |
+ #ifdef CONFIG_PPC64 |
1667 |
+ /* Special case for 16-byte loads and stores */ |
1668 |
+@@ -966,15 +1000,12 @@ int fix_alignment(struct pt_regs *regs) |
1669 |
+ } |
1670 |
+ |
1671 |
+ data.ll = 0; |
1672 |
+- ret = 0; |
1673 |
+ p = (unsigned long)addr; |
1674 |
+ |
1675 |
+ for (i = 0; i < nb; i++) |
1676 |
+- ret |= __get_user_inatomic(data.v[start + i], |
1677 |
+- SWIZ_PTR(p++)); |
1678 |
+- |
1679 |
+- if (unlikely(ret)) |
1680 |
+- return -EFAULT; |
1681 |
++ if (__get_user_or_set_dar(regs, data.v[start + i], |
1682 |
++ SWIZ_PTR(p++))) |
1683 |
++ return -EFAULT; |
1684 |
+ |
1685 |
+ } else if (flags & F) { |
1686 |
+ data.ll = current->thread.TS_FPR(reg); |
1687 |
+@@ -1046,15 +1077,13 @@ int fix_alignment(struct pt_regs *regs) |
1688 |
+ break; |
1689 |
+ } |
1690 |
+ |
1691 |
+- ret = 0; |
1692 |
+ p = (unsigned long)addr; |
1693 |
+ |
1694 |
+ for (i = 0; i < nb; i++) |
1695 |
+- ret |= __put_user_inatomic(data.v[start + i], |
1696 |
+- SWIZ_PTR(p++)); |
1697 |
++ if (__put_user_or_set_dar(regs, data.v[start + i], |
1698 |
++ SWIZ_PTR(p++))) |
1699 |
++ return -EFAULT; |
1700 |
+ |
1701 |
+- if (unlikely(ret)) |
1702 |
+- return -EFAULT; |
1703 |
+ } else if (flags & F) |
1704 |
+ current->thread.TS_FPR(reg) = data.ll; |
1705 |
+ else |
1706 |
+diff --git a/arch/s390/include/asm/mmu.h b/arch/s390/include/asm/mmu.h |
1707 |
+index bea785d7f853..af85d6b12028 100644 |
1708 |
+--- a/arch/s390/include/asm/mmu.h |
1709 |
++++ b/arch/s390/include/asm/mmu.h |
1710 |
+@@ -5,6 +5,7 @@ |
1711 |
+ #include <linux/errno.h> |
1712 |
+ |
1713 |
+ typedef struct { |
1714 |
++ spinlock_t lock; |
1715 |
+ cpumask_t cpu_attach_mask; |
1716 |
+ atomic_t flush_count; |
1717 |
+ unsigned int flush_mm; |
1718 |
+@@ -25,6 +26,7 @@ typedef struct { |
1719 |
+ } mm_context_t; |
1720 |
+ |
1721 |
+ #define INIT_MM_CONTEXT(name) \ |
1722 |
++ .context.lock = __SPIN_LOCK_UNLOCKED(name.context.lock), \ |
1723 |
+ .context.pgtable_lock = \ |
1724 |
+ __SPIN_LOCK_UNLOCKED(name.context.pgtable_lock), \ |
1725 |
+ .context.pgtable_list = LIST_HEAD_INIT(name.context.pgtable_list), \ |
1726 |
+diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h |
1727 |
+index 515fea5a3fc4..f65a708ac395 100644 |
1728 |
+--- a/arch/s390/include/asm/mmu_context.h |
1729 |
++++ b/arch/s390/include/asm/mmu_context.h |
1730 |
+@@ -15,6 +15,7 @@ |
1731 |
+ static inline int init_new_context(struct task_struct *tsk, |
1732 |
+ struct mm_struct *mm) |
1733 |
+ { |
1734 |
++ spin_lock_init(&mm->context.lock); |
1735 |
+ spin_lock_init(&mm->context.pgtable_lock); |
1736 |
+ INIT_LIST_HEAD(&mm->context.pgtable_list); |
1737 |
+ spin_lock_init(&mm->context.gmap_lock); |
1738 |
+@@ -93,7 +94,6 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, |
1739 |
+ if (prev == next) |
1740 |
+ return; |
1741 |
+ cpumask_set_cpu(cpu, &next->context.cpu_attach_mask); |
1742 |
+- cpumask_set_cpu(cpu, mm_cpumask(next)); |
1743 |
+ /* Clear old ASCE by loading the kernel ASCE. */ |
1744 |
+ __ctl_load(S390_lowcore.kernel_asce, 1, 1); |
1745 |
+ __ctl_load(S390_lowcore.kernel_asce, 7, 7); |
1746 |
+@@ -111,9 +111,8 @@ static inline void finish_arch_post_lock_switch(void) |
1747 |
+ preempt_disable(); |
1748 |
+ while (atomic_read(&mm->context.flush_count)) |
1749 |
+ cpu_relax(); |
1750 |
+- |
1751 |
+- if (mm->context.flush_mm) |
1752 |
+- __tlb_flush_mm(mm); |
1753 |
++ cpumask_set_cpu(smp_processor_id(), mm_cpumask(mm)); |
1754 |
++ __tlb_flush_mm_lazy(mm); |
1755 |
+ preempt_enable(); |
1756 |
+ } |
1757 |
+ set_fs(current->thread.mm_segment); |
1758 |
+@@ -126,6 +125,7 @@ static inline void activate_mm(struct mm_struct *prev, |
1759 |
+ struct mm_struct *next) |
1760 |
+ { |
1761 |
+ switch_mm(prev, next, current); |
1762 |
++ cpumask_set_cpu(smp_processor_id(), mm_cpumask(next)); |
1763 |
+ set_user_asce(next); |
1764 |
+ } |
1765 |
+ |
1766 |
+diff --git a/arch/s390/include/asm/tlbflush.h b/arch/s390/include/asm/tlbflush.h |
1767 |
+index 39846100682a..eed927aeb08f 100644 |
1768 |
+--- a/arch/s390/include/asm/tlbflush.h |
1769 |
++++ b/arch/s390/include/asm/tlbflush.h |
1770 |
+@@ -43,23 +43,6 @@ static inline void __tlb_flush_global(void) |
1771 |
+ * Flush TLB entries for a specific mm on all CPUs (in case gmap is used |
1772 |
+ * this implicates multiple ASCEs!). |
1773 |
+ */ |
1774 |
+-static inline void __tlb_flush_full(struct mm_struct *mm) |
1775 |
+-{ |
1776 |
+- preempt_disable(); |
1777 |
+- atomic_inc(&mm->context.flush_count); |
1778 |
+- if (cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) { |
1779 |
+- /* Local TLB flush */ |
1780 |
+- __tlb_flush_local(); |
1781 |
+- } else { |
1782 |
+- /* Global TLB flush */ |
1783 |
+- __tlb_flush_global(); |
1784 |
+- /* Reset TLB flush mask */ |
1785 |
+- cpumask_copy(mm_cpumask(mm), &mm->context.cpu_attach_mask); |
1786 |
+- } |
1787 |
+- atomic_dec(&mm->context.flush_count); |
1788 |
+- preempt_enable(); |
1789 |
+-} |
1790 |
+- |
1791 |
+ static inline void __tlb_flush_mm(struct mm_struct *mm) |
1792 |
+ { |
1793 |
+ unsigned long gmap_asce; |
1794 |
+@@ -71,16 +54,18 @@ static inline void __tlb_flush_mm(struct mm_struct *mm) |
1795 |
+ */ |
1796 |
+ preempt_disable(); |
1797 |
+ atomic_inc(&mm->context.flush_count); |
1798 |
++ /* Reset TLB flush mask */ |
1799 |
++ cpumask_copy(mm_cpumask(mm), &mm->context.cpu_attach_mask); |
1800 |
++ barrier(); |
1801 |
+ gmap_asce = READ_ONCE(mm->context.gmap_asce); |
1802 |
+ if (MACHINE_HAS_IDTE && gmap_asce != -1UL) { |
1803 |
+ if (gmap_asce) |
1804 |
+ __tlb_flush_idte(gmap_asce); |
1805 |
+ __tlb_flush_idte(mm->context.asce); |
1806 |
+ } else { |
1807 |
+- __tlb_flush_full(mm); |
1808 |
++ /* Global TLB flush */ |
1809 |
++ __tlb_flush_global(); |
1810 |
+ } |
1811 |
+- /* Reset TLB flush mask */ |
1812 |
+- cpumask_copy(mm_cpumask(mm), &mm->context.cpu_attach_mask); |
1813 |
+ atomic_dec(&mm->context.flush_count); |
1814 |
+ preempt_enable(); |
1815 |
+ } |
1816 |
+@@ -94,7 +79,6 @@ static inline void __tlb_flush_kernel(void) |
1817 |
+ } |
1818 |
+ #else |
1819 |
+ #define __tlb_flush_global() __tlb_flush_local() |
1820 |
+-#define __tlb_flush_full(mm) __tlb_flush_local() |
1821 |
+ |
1822 |
+ /* |
1823 |
+ * Flush TLB entries for a specific ASCE on all CPUs. |
1824 |
+@@ -112,10 +96,12 @@ static inline void __tlb_flush_kernel(void) |
1825 |
+ |
1826 |
+ static inline void __tlb_flush_mm_lazy(struct mm_struct * mm) |
1827 |
+ { |
1828 |
++ spin_lock(&mm->context.lock); |
1829 |
+ if (mm->context.flush_mm) { |
1830 |
+- __tlb_flush_mm(mm); |
1831 |
+ mm->context.flush_mm = 0; |
1832 |
++ __tlb_flush_mm(mm); |
1833 |
+ } |
1834 |
++ spin_unlock(&mm->context.lock); |
1835 |
+ } |
1836 |
+ |
1837 |
+ /* |
1838 |
+diff --git a/block/blk-core.c b/block/blk-core.c |
1839 |
+index d1f2801ce836..95379fc83805 100644 |
1840 |
+--- a/block/blk-core.c |
1841 |
++++ b/block/blk-core.c |
1842 |
+@@ -233,7 +233,7 @@ EXPORT_SYMBOL(blk_start_queue_async); |
1843 |
+ **/ |
1844 |
+ void blk_start_queue(struct request_queue *q) |
1845 |
+ { |
1846 |
+- WARN_ON(!irqs_disabled()); |
1847 |
++ WARN_ON(!in_interrupt() && !irqs_disabled()); |
1848 |
+ |
1849 |
+ queue_flag_clear(QUEUE_FLAG_STOPPED, q); |
1850 |
+ __blk_run_queue(q); |
1851 |
+diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c |
1852 |
+index 45af0fe00f33..aaf2f810d170 100644 |
1853 |
+--- a/crypto/algif_skcipher.c |
1854 |
++++ b/crypto/algif_skcipher.c |
1855 |
+@@ -143,8 +143,10 @@ static int skcipher_alloc_sgl(struct sock *sk) |
1856 |
+ sg_init_table(sgl->sg, MAX_SGL_ENTS + 1); |
1857 |
+ sgl->cur = 0; |
1858 |
+ |
1859 |
+- if (sg) |
1860 |
++ if (sg) { |
1861 |
+ sg_chain(sg, MAX_SGL_ENTS + 1, sgl->sg); |
1862 |
++ sg_unmark_end(sg + (MAX_SGL_ENTS - 1)); |
1863 |
++ } |
1864 |
+ |
1865 |
+ list_add_tail(&sgl->list, &ctx->tsgl); |
1866 |
+ } |
1867 |
+diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c |
1868 |
+index 3822eae102db..6f78cea75103 100644 |
1869 |
+--- a/drivers/block/skd_main.c |
1870 |
++++ b/drivers/block/skd_main.c |
1871 |
+@@ -2163,6 +2163,9 @@ static void skd_send_fitmsg(struct skd_device *skdev, |
1872 |
+ */ |
1873 |
+ qcmd |= FIT_QCMD_MSGSIZE_64; |
1874 |
+ |
1875 |
++ /* Make sure skd_msg_buf is written before the doorbell is triggered. */ |
1876 |
++ smp_wmb(); |
1877 |
++ |
1878 |
+ SKD_WRITEQ(skdev, qcmd, FIT_Q_COMMAND); |
1879 |
+ |
1880 |
+ } |
1881 |
+@@ -2209,6 +2212,9 @@ static void skd_send_special_fitmsg(struct skd_device *skdev, |
1882 |
+ qcmd = skspcl->mb_dma_address; |
1883 |
+ qcmd |= FIT_QCMD_QID_NORMAL + FIT_QCMD_MSGSIZE_128; |
1884 |
+ |
1885 |
++ /* Make sure skd_msg_buf is written before the doorbell is triggered. */ |
1886 |
++ smp_wmb(); |
1887 |
++ |
1888 |
+ SKD_WRITEQ(skdev, qcmd, FIT_Q_COMMAND); |
1889 |
+ } |
1890 |
+ |
1891 |
+@@ -4622,15 +4628,16 @@ static void skd_free_disk(struct skd_device *skdev) |
1892 |
+ { |
1893 |
+ struct gendisk *disk = skdev->disk; |
1894 |
+ |
1895 |
+- if (disk != NULL) { |
1896 |
+- struct request_queue *q = disk->queue; |
1897 |
++ if (disk && (disk->flags & GENHD_FL_UP)) |
1898 |
++ del_gendisk(disk); |
1899 |
+ |
1900 |
+- if (disk->flags & GENHD_FL_UP) |
1901 |
+- del_gendisk(disk); |
1902 |
+- if (q) |
1903 |
+- blk_cleanup_queue(q); |
1904 |
+- put_disk(disk); |
1905 |
++ if (skdev->queue) { |
1906 |
++ blk_cleanup_queue(skdev->queue); |
1907 |
++ skdev->queue = NULL; |
1908 |
++ disk->queue = NULL; |
1909 |
+ } |
1910 |
++ |
1911 |
++ put_disk(disk); |
1912 |
+ skdev->disk = NULL; |
1913 |
+ } |
1914 |
+ |
1915 |
+diff --git a/drivers/crypto/ccp/ccp-crypto-aes-xts.c b/drivers/crypto/ccp/ccp-crypto-aes-xts.c |
1916 |
+index 58a4244b4752..3f26a415ef44 100644 |
1917 |
+--- a/drivers/crypto/ccp/ccp-crypto-aes-xts.c |
1918 |
++++ b/drivers/crypto/ccp/ccp-crypto-aes-xts.c |
1919 |
+@@ -1,8 +1,9 @@ |
1920 |
+ /* |
1921 |
+ * AMD Cryptographic Coprocessor (CCP) AES XTS crypto API support |
1922 |
+ * |
1923 |
+- * Copyright (C) 2013 Advanced Micro Devices, Inc. |
1924 |
++ * Copyright (C) 2013,2017 Advanced Micro Devices, Inc. |
1925 |
+ * |
1926 |
++ * Author: Gary R Hook <gary.hook@×××.com> |
1927 |
+ * Author: Tom Lendacky <thomas.lendacky@×××.com> |
1928 |
+ * |
1929 |
+ * This program is free software; you can redistribute it and/or modify |
1930 |
+@@ -164,6 +165,7 @@ static int ccp_aes_xts_crypt(struct ablkcipher_request *req, |
1931 |
+ memset(&rctx->cmd, 0, sizeof(rctx->cmd)); |
1932 |
+ INIT_LIST_HEAD(&rctx->cmd.entry); |
1933 |
+ rctx->cmd.engine = CCP_ENGINE_XTS_AES_128; |
1934 |
++ rctx->cmd.u.xts.type = CCP_AES_TYPE_128; |
1935 |
+ rctx->cmd.u.xts.action = (encrypt) ? CCP_AES_ACTION_ENCRYPT |
1936 |
+ : CCP_AES_ACTION_DECRYPT; |
1937 |
+ rctx->cmd.u.xts.unit_size = unit_size; |
1938 |
+diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c |
1939 |
+index 2c0ce5f605b3..17b19a68e269 100644 |
1940 |
+--- a/drivers/crypto/ccp/ccp-dev-v5.c |
1941 |
++++ b/drivers/crypto/ccp/ccp-dev-v5.c |
1942 |
+@@ -131,6 +131,7 @@ union ccp_function { |
1943 |
+ #define CCP_AES_MODE(p) ((p)->aes.mode) |
1944 |
+ #define CCP_AES_TYPE(p) ((p)->aes.type) |
1945 |
+ #define CCP_XTS_SIZE(p) ((p)->aes_xts.size) |
1946 |
++#define CCP_XTS_TYPE(p) ((p)->aes_xts.type) |
1947 |
+ #define CCP_XTS_ENCRYPT(p) ((p)->aes_xts.encrypt) |
1948 |
+ #define CCP_SHA_TYPE(p) ((p)->sha.type) |
1949 |
+ #define CCP_RSA_SIZE(p) ((p)->rsa.size) |
1950 |
+@@ -318,6 +319,7 @@ static int ccp5_perform_xts_aes(struct ccp_op *op) |
1951 |
+ CCP5_CMD_PROT(&desc) = 0; |
1952 |
+ |
1953 |
+ function.raw = 0; |
1954 |
++ CCP_XTS_TYPE(&function) = op->u.xts.type; |
1955 |
+ CCP_XTS_ENCRYPT(&function) = op->u.xts.action; |
1956 |
+ CCP_XTS_SIZE(&function) = op->u.xts.unit_size; |
1957 |
+ CCP5_CMD_FUNCTION(&desc) = function.raw; |
1958 |
+diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h |
1959 |
+index 8ac7ae17e1f4..e23c36c7691c 100644 |
1960 |
+--- a/drivers/crypto/ccp/ccp-dev.h |
1961 |
++++ b/drivers/crypto/ccp/ccp-dev.h |
1962 |
+@@ -187,6 +187,7 @@ |
1963 |
+ #define CCP_AES_CTX_SB_COUNT 1 |
1964 |
+ |
1965 |
+ #define CCP_XTS_AES_KEY_SB_COUNT 1 |
1966 |
++#define CCP5_XTS_AES_KEY_SB_COUNT 2 |
1967 |
+ #define CCP_XTS_AES_CTX_SB_COUNT 1 |
1968 |
+ |
1969 |
+ #define CCP_SHA_SB_COUNT 1 |
1970 |
+@@ -472,6 +473,7 @@ struct ccp_aes_op { |
1971 |
+ }; |
1972 |
+ |
1973 |
+ struct ccp_xts_aes_op { |
1974 |
++ enum ccp_aes_type type; |
1975 |
+ enum ccp_aes_action action; |
1976 |
+ enum ccp_xts_aes_unit_size unit_size; |
1977 |
+ }; |
1978 |
+diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c |
1979 |
+index 50fae4442801..64deb006c3be 100644 |
1980 |
+--- a/drivers/crypto/ccp/ccp-ops.c |
1981 |
++++ b/drivers/crypto/ccp/ccp-ops.c |
1982 |
+@@ -779,6 +779,8 @@ static int ccp_run_xts_aes_cmd(struct ccp_cmd_queue *cmd_q, |
1983 |
+ struct ccp_op op; |
1984 |
+ unsigned int unit_size, dm_offset; |
1985 |
+ bool in_place = false; |
1986 |
++ unsigned int sb_count; |
1987 |
++ enum ccp_aes_type aestype; |
1988 |
+ int ret; |
1989 |
+ |
1990 |
+ switch (xts->unit_size) { |
1991 |
+@@ -802,7 +804,9 @@ static int ccp_run_xts_aes_cmd(struct ccp_cmd_queue *cmd_q, |
1992 |
+ return -EINVAL; |
1993 |
+ } |
1994 |
+ |
1995 |
+- if (xts->key_len != AES_KEYSIZE_128) |
1996 |
++ if (xts->key_len == AES_KEYSIZE_128) |
1997 |
++ aestype = CCP_AES_TYPE_128; |
1998 |
++ else |
1999 |
+ return -EINVAL; |
2000 |
+ |
2001 |
+ if (!xts->final && (xts->src_len & (AES_BLOCK_SIZE - 1))) |
2002 |
+@@ -824,23 +828,44 @@ static int ccp_run_xts_aes_cmd(struct ccp_cmd_queue *cmd_q, |
2003 |
+ op.sb_key = cmd_q->sb_key; |
2004 |
+ op.sb_ctx = cmd_q->sb_ctx; |
2005 |
+ op.init = 1; |
2006 |
++ op.u.xts.type = aestype; |
2007 |
+ op.u.xts.action = xts->action; |
2008 |
+ op.u.xts.unit_size = xts->unit_size; |
2009 |
+ |
2010 |
+- /* All supported key sizes fit in a single (32-byte) SB entry |
2011 |
+- * and must be in little endian format. Use the 256-bit byte |
2012 |
+- * swap passthru option to convert from big endian to little |
2013 |
+- * endian. |
2014 |
++ /* A version 3 device only supports 128-bit keys, which fits into a |
2015 |
++ * single SB entry. A version 5 device uses a 512-bit vector, so two |
2016 |
++ * SB entries. |
2017 |
+ */ |
2018 |
++ if (cmd_q->ccp->vdata->version == CCP_VERSION(3, 0)) |
2019 |
++ sb_count = CCP_XTS_AES_KEY_SB_COUNT; |
2020 |
++ else |
2021 |
++ sb_count = CCP5_XTS_AES_KEY_SB_COUNT; |
2022 |
+ ret = ccp_init_dm_workarea(&key, cmd_q, |
2023 |
+- CCP_XTS_AES_KEY_SB_COUNT * CCP_SB_BYTES, |
2024 |
++ sb_count * CCP_SB_BYTES, |
2025 |
+ DMA_TO_DEVICE); |
2026 |
+ if (ret) |
2027 |
+ return ret; |
2028 |
+ |
2029 |
+- dm_offset = CCP_SB_BYTES - AES_KEYSIZE_128; |
2030 |
+- ccp_set_dm_area(&key, dm_offset, xts->key, 0, xts->key_len); |
2031 |
+- ccp_set_dm_area(&key, 0, xts->key, dm_offset, xts->key_len); |
2032 |
++ if (cmd_q->ccp->vdata->version == CCP_VERSION(3, 0)) { |
2033 |
++ /* All supported key sizes must be in little endian format. |
2034 |
++ * Use the 256-bit byte swap passthru option to convert from |
2035 |
++ * big endian to little endian. |
2036 |
++ */ |
2037 |
++ dm_offset = CCP_SB_BYTES - AES_KEYSIZE_128; |
2038 |
++ ccp_set_dm_area(&key, dm_offset, xts->key, 0, xts->key_len); |
2039 |
++ ccp_set_dm_area(&key, 0, xts->key, xts->key_len, xts->key_len); |
2040 |
++ } else { |
2041 |
++ /* Version 5 CCPs use a 512-bit space for the key: each portion |
2042 |
++ * occupies 256 bits, or one entire slot, and is zero-padded. |
2043 |
++ */ |
2044 |
++ unsigned int pad; |
2045 |
++ |
2046 |
++ dm_offset = CCP_SB_BYTES; |
2047 |
++ pad = dm_offset - xts->key_len; |
2048 |
++ ccp_set_dm_area(&key, pad, xts->key, 0, xts->key_len); |
2049 |
++ ccp_set_dm_area(&key, dm_offset + pad, xts->key, xts->key_len, |
2050 |
++ xts->key_len); |
2051 |
++ } |
2052 |
+ ret = ccp_copy_to_sb(cmd_q, &key, op.jobid, op.sb_key, |
2053 |
+ CCP_PASSTHRU_BYTESWAP_256BIT); |
2054 |
+ if (ret) { |
2055 |
+diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c |
2056 |
+index 7309c0824887..a2449d77af07 100644 |
2057 |
+--- a/drivers/devfreq/devfreq.c |
2058 |
++++ b/drivers/devfreq/devfreq.c |
2059 |
+@@ -574,7 +574,7 @@ struct devfreq *devfreq_add_device(struct device *dev, |
2060 |
+ err = device_register(&devfreq->dev); |
2061 |
+ if (err) { |
2062 |
+ mutex_unlock(&devfreq->lock); |
2063 |
+- goto err_out; |
2064 |
++ goto err_dev; |
2065 |
+ } |
2066 |
+ |
2067 |
+ devfreq->trans_table = devm_kzalloc(&devfreq->dev, sizeof(unsigned int) * |
2068 |
+@@ -618,6 +618,9 @@ struct devfreq *devfreq_add_device(struct device *dev, |
2069 |
+ mutex_unlock(&devfreq_list_lock); |
2070 |
+ |
2071 |
+ device_unregister(&devfreq->dev); |
2072 |
++err_dev: |
2073 |
++ if (devfreq) |
2074 |
++ kfree(devfreq); |
2075 |
+ err_out: |
2076 |
+ return ERR_PTR(err); |
2077 |
+ } |
2078 |
+diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c |
2079 |
+index c3b21865443e..1feec34ca9dd 100644 |
2080 |
+--- a/drivers/gpu/drm/sun4i/sun4i_drv.c |
2081 |
++++ b/drivers/gpu/drm/sun4i/sun4i_drv.c |
2082 |
+@@ -47,6 +47,13 @@ static void sun4i_drv_disable_vblank(struct drm_device *drm, unsigned int pipe) |
2083 |
+ sun4i_tcon_enable_vblank(tcon, false); |
2084 |
+ } |
2085 |
+ |
2086 |
++static void sun4i_drv_lastclose(struct drm_device *dev) |
2087 |
++{ |
2088 |
++ struct sun4i_drv *drv = dev->dev_private; |
2089 |
++ |
2090 |
++ drm_fbdev_cma_restore_mode(drv->fbdev); |
2091 |
++} |
2092 |
++ |
2093 |
+ static const struct file_operations sun4i_drv_fops = { |
2094 |
+ .owner = THIS_MODULE, |
2095 |
+ .open = drm_open, |
2096 |
+@@ -65,6 +72,7 @@ static struct drm_driver sun4i_drv_driver = { |
2097 |
+ .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC, |
2098 |
+ |
2099 |
+ /* Generic Operations */ |
2100 |
++ .lastclose = sun4i_drv_lastclose, |
2101 |
+ .fops = &sun4i_drv_fops, |
2102 |
+ .name = "sun4i-drm", |
2103 |
+ .desc = "Allwinner sun4i Display Engine", |
2104 |
+diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c |
2105 |
+index 63e82f8e8308..fb4ce0394ac7 100644 |
2106 |
+--- a/drivers/infiniband/core/addr.c |
2107 |
++++ b/drivers/infiniband/core/addr.c |
2108 |
+@@ -446,15 +446,10 @@ static int addr6_resolve(struct sockaddr_in6 *src_in, |
2109 |
+ |
2110 |
+ ret = ipv6_stub->ipv6_dst_lookup(addr->net, NULL, &dst, &fl6); |
2111 |
+ if (ret < 0) |
2112 |
+- goto put; |
2113 |
++ return ret; |
2114 |
+ |
2115 |
+ rt = (struct rt6_info *)dst; |
2116 |
+- if (ipv6_addr_any(&fl6.saddr)) { |
2117 |
+- ret = ipv6_dev_get_saddr(addr->net, ip6_dst_idev(dst)->dev, |
2118 |
+- &fl6.daddr, 0, &fl6.saddr); |
2119 |
+- if (ret) |
2120 |
+- goto put; |
2121 |
+- |
2122 |
++ if (ipv6_addr_any(&src_in->sin6_addr)) { |
2123 |
+ src_in->sin6_family = AF_INET6; |
2124 |
+ src_in->sin6_addr = fl6.saddr; |
2125 |
+ } |
2126 |
+@@ -471,9 +466,6 @@ static int addr6_resolve(struct sockaddr_in6 *src_in, |
2127 |
+ |
2128 |
+ *pdst = dst; |
2129 |
+ return 0; |
2130 |
+-put: |
2131 |
+- dst_release(dst); |
2132 |
+- return ret; |
2133 |
+ } |
2134 |
+ #else |
2135 |
+ static int addr6_resolve(struct sockaddr_in6 *src_in, |
2136 |
+diff --git a/drivers/infiniband/hw/hfi1/rc.c b/drivers/infiniband/hw/hfi1/rc.c |
2137 |
+index 4bd5b5caa243..613074e963bb 100644 |
2138 |
+--- a/drivers/infiniband/hw/hfi1/rc.c |
2139 |
++++ b/drivers/infiniband/hw/hfi1/rc.c |
2140 |
+@@ -551,7 +551,7 @@ int hfi1_make_rc_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps) |
2141 |
+ case IB_WR_RDMA_WRITE: |
2142 |
+ if (newreq && !(qp->s_flags & RVT_S_UNLIMITED_CREDIT)) |
2143 |
+ qp->s_lsn++; |
2144 |
+- /* FALLTHROUGH */ |
2145 |
++ goto no_flow_control; |
2146 |
+ case IB_WR_RDMA_WRITE_WITH_IMM: |
2147 |
+ /* If no credit, return. */ |
2148 |
+ if (!(qp->s_flags & RVT_S_UNLIMITED_CREDIT) && |
2149 |
+@@ -559,6 +559,7 @@ int hfi1_make_rc_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps) |
2150 |
+ qp->s_flags |= RVT_S_WAIT_SSN_CREDIT; |
2151 |
+ goto bail; |
2152 |
+ } |
2153 |
++no_flow_control: |
2154 |
+ put_ib_reth_vaddr( |
2155 |
+ wqe->rdma_wr.remote_addr, |
2156 |
+ &ohdr->u.rc.reth); |
2157 |
+diff --git a/drivers/infiniband/hw/qib/qib_rc.c b/drivers/infiniband/hw/qib/qib_rc.c |
2158 |
+index f3fe787c9426..c1523f9a3c12 100644 |
2159 |
+--- a/drivers/infiniband/hw/qib/qib_rc.c |
2160 |
++++ b/drivers/infiniband/hw/qib/qib_rc.c |
2161 |
+@@ -357,7 +357,7 @@ int qib_make_rc_req(struct rvt_qp *qp, unsigned long *flags) |
2162 |
+ case IB_WR_RDMA_WRITE: |
2163 |
+ if (newreq && !(qp->s_flags & RVT_S_UNLIMITED_CREDIT)) |
2164 |
+ qp->s_lsn++; |
2165 |
+- /* FALLTHROUGH */ |
2166 |
++ goto no_flow_control; |
2167 |
+ case IB_WR_RDMA_WRITE_WITH_IMM: |
2168 |
+ /* If no credit, return. */ |
2169 |
+ if (!(qp->s_flags & RVT_S_UNLIMITED_CREDIT) && |
2170 |
+@@ -365,7 +365,7 @@ int qib_make_rc_req(struct rvt_qp *qp, unsigned long *flags) |
2171 |
+ qp->s_flags |= RVT_S_WAIT_SSN_CREDIT; |
2172 |
+ goto bail; |
2173 |
+ } |
2174 |
+- |
2175 |
++no_flow_control: |
2176 |
+ ohdr->u.rc.reth.vaddr = |
2177 |
+ cpu_to_be64(wqe->rdma_wr.remote_addr); |
2178 |
+ ohdr->u.rc.reth.rkey = |
2179 |
+diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h |
2180 |
+index 5be14ad29d46..dbf09836ff30 100644 |
2181 |
+--- a/drivers/input/serio/i8042-x86ia64io.h |
2182 |
++++ b/drivers/input/serio/i8042-x86ia64io.h |
2183 |
+@@ -904,6 +904,13 @@ static const struct dmi_system_id __initconst i8042_dmi_kbdreset_table[] = { |
2184 |
+ DMI_MATCH(DMI_PRODUCT_NAME, "P34"), |
2185 |
+ }, |
2186 |
+ }, |
2187 |
++ { |
2188 |
++ /* Gigabyte P57 - Elantech touchpad */ |
2189 |
++ .matches = { |
2190 |
++ DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"), |
2191 |
++ DMI_MATCH(DMI_PRODUCT_NAME, "P57"), |
2192 |
++ }, |
2193 |
++ }, |
2194 |
+ { |
2195 |
+ /* Schenker XMG C504 - Elantech touchpad */ |
2196 |
+ .matches = { |
2197 |
+diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h |
2198 |
+index c3ea03c9a1a8..02619cabda8b 100644 |
2199 |
+--- a/drivers/md/bcache/bcache.h |
2200 |
++++ b/drivers/md/bcache/bcache.h |
2201 |
+@@ -333,6 +333,7 @@ struct cached_dev { |
2202 |
+ /* Limit number of writeback bios in flight */ |
2203 |
+ struct semaphore in_flight; |
2204 |
+ struct task_struct *writeback_thread; |
2205 |
++ struct workqueue_struct *writeback_write_wq; |
2206 |
+ |
2207 |
+ struct keybuf writeback_keys; |
2208 |
+ |
2209 |
+diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c |
2210 |
+index a37c1776f2e3..e0f1c6d534fe 100644 |
2211 |
+--- a/drivers/md/bcache/request.c |
2212 |
++++ b/drivers/md/bcache/request.c |
2213 |
+@@ -196,12 +196,12 @@ static void bch_data_insert_start(struct closure *cl) |
2214 |
+ struct data_insert_op *op = container_of(cl, struct data_insert_op, cl); |
2215 |
+ struct bio *bio = op->bio, *n; |
2216 |
+ |
2217 |
+- if (atomic_sub_return(bio_sectors(bio), &op->c->sectors_to_gc) < 0) |
2218 |
+- wake_up_gc(op->c); |
2219 |
+- |
2220 |
+ if (op->bypass) |
2221 |
+ return bch_data_invalidate(cl); |
2222 |
+ |
2223 |
++ if (atomic_sub_return(bio_sectors(bio), &op->c->sectors_to_gc) < 0) |
2224 |
++ wake_up_gc(op->c); |
2225 |
++ |
2226 |
+ /* |
2227 |
+ * Journal writes are marked REQ_PREFLUSH; if the original write was a |
2228 |
+ * flush, it'll wait on the journal write. |
2229 |
+diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c |
2230 |
+index 66669c8f4161..f4557f558b24 100644 |
2231 |
+--- a/drivers/md/bcache/super.c |
2232 |
++++ b/drivers/md/bcache/super.c |
2233 |
+@@ -1025,7 +1025,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) |
2234 |
+ } |
2235 |
+ |
2236 |
+ if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) { |
2237 |
+- bch_sectors_dirty_init(dc); |
2238 |
++ bch_sectors_dirty_init(&dc->disk); |
2239 |
+ atomic_set(&dc->has_dirty, 1); |
2240 |
+ atomic_inc(&dc->count); |
2241 |
+ bch_writeback_queue(dc); |
2242 |
+@@ -1058,6 +1058,8 @@ static void cached_dev_free(struct closure *cl) |
2243 |
+ cancel_delayed_work_sync(&dc->writeback_rate_update); |
2244 |
+ if (!IS_ERR_OR_NULL(dc->writeback_thread)) |
2245 |
+ kthread_stop(dc->writeback_thread); |
2246 |
++ if (dc->writeback_write_wq) |
2247 |
++ destroy_workqueue(dc->writeback_write_wq); |
2248 |
+ |
2249 |
+ mutex_lock(&bch_register_lock); |
2250 |
+ |
2251 |
+@@ -1229,6 +1231,7 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u) |
2252 |
+ goto err; |
2253 |
+ |
2254 |
+ bcache_device_attach(d, c, u - c->uuids); |
2255 |
++ bch_sectors_dirty_init(d); |
2256 |
+ bch_flash_dev_request_init(d); |
2257 |
+ add_disk(d->disk); |
2258 |
+ |
2259 |
+@@ -1967,6 +1970,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, |
2260 |
+ else |
2261 |
+ err = "device busy"; |
2262 |
+ mutex_unlock(&bch_register_lock); |
2263 |
++ if (!IS_ERR(bdev)) |
2264 |
++ bdput(bdev); |
2265 |
+ if (attr == &ksysfs_register_quiet) |
2266 |
+ goto out; |
2267 |
+ } |
2268 |
+diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c |
2269 |
+index b3ff57d61dde..4fbb5532f24c 100644 |
2270 |
+--- a/drivers/md/bcache/sysfs.c |
2271 |
++++ b/drivers/md/bcache/sysfs.c |
2272 |
+@@ -191,7 +191,7 @@ STORE(__cached_dev) |
2273 |
+ { |
2274 |
+ struct cached_dev *dc = container_of(kobj, struct cached_dev, |
2275 |
+ disk.kobj); |
2276 |
+- unsigned v = size; |
2277 |
++ ssize_t v = size; |
2278 |
+ struct cache_set *c; |
2279 |
+ struct kobj_uevent_env *env; |
2280 |
+ |
2281 |
+@@ -226,7 +226,7 @@ STORE(__cached_dev) |
2282 |
+ bch_cached_dev_run(dc); |
2283 |
+ |
2284 |
+ if (attr == &sysfs_cache_mode) { |
2285 |
+- ssize_t v = bch_read_string_list(buf, bch_cache_modes + 1); |
2286 |
++ v = bch_read_string_list(buf, bch_cache_modes + 1); |
2287 |
+ |
2288 |
+ if (v < 0) |
2289 |
+ return v; |
2290 |
+diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c |
2291 |
+index dde6172f3f10..eb70f6894f05 100644 |
2292 |
+--- a/drivers/md/bcache/util.c |
2293 |
++++ b/drivers/md/bcache/util.c |
2294 |
+@@ -73,24 +73,44 @@ STRTO_H(strtouint, unsigned int) |
2295 |
+ STRTO_H(strtoll, long long) |
2296 |
+ STRTO_H(strtoull, unsigned long long) |
2297 |
+ |
2298 |
++/** |
2299 |
++ * bch_hprint() - formats @v to human readable string for sysfs. |
2300 |
++ * |
2301 |
++ * @v - signed 64 bit integer |
2302 |
++ * @buf - the (at least 8 byte) buffer to format the result into. |
2303 |
++ * |
2304 |
++ * Returns the number of bytes used by format. |
2305 |
++ */ |
2306 |
+ ssize_t bch_hprint(char *buf, int64_t v) |
2307 |
+ { |
2308 |
+ static const char units[] = "?kMGTPEZY"; |
2309 |
+- char dec[4] = ""; |
2310 |
+- int u, t = 0; |
2311 |
+- |
2312 |
+- for (u = 0; v >= 1024 || v <= -1024; u++) { |
2313 |
+- t = v & ~(~0 << 10); |
2314 |
+- v >>= 10; |
2315 |
+- } |
2316 |
+- |
2317 |
+- if (!u) |
2318 |
+- return sprintf(buf, "%llu", v); |
2319 |
+- |
2320 |
+- if (v < 100 && v > -100) |
2321 |
+- snprintf(dec, sizeof(dec), ".%i", t / 100); |
2322 |
+- |
2323 |
+- return sprintf(buf, "%lli%s%c", v, dec, units[u]); |
2324 |
++ int u = 0, t; |
2325 |
++ |
2326 |
++ uint64_t q; |
2327 |
++ |
2328 |
++ if (v < 0) |
2329 |
++ q = -v; |
2330 |
++ else |
2331 |
++ q = v; |
2332 |
++ |
2333 |
++ /* For as long as the number is more than 3 digits, but at least |
2334 |
++ * once, shift right / divide by 1024. Keep the remainder for |
2335 |
++ * a digit after the decimal point. |
2336 |
++ */ |
2337 |
++ do { |
2338 |
++ u++; |
2339 |
++ |
2340 |
++ t = q & ~(~0 << 10); |
2341 |
++ q >>= 10; |
2342 |
++ } while (q >= 1000); |
2343 |
++ |
2344 |
++ if (v < 0) |
2345 |
++ /* '-', up to 3 digits, '.', 1 digit, 1 character, null; |
2346 |
++ * yields 8 bytes. |
2347 |
++ */ |
2348 |
++ return sprintf(buf, "-%llu.%i%c", q, t * 10 / 1024, units[u]); |
2349 |
++ else |
2350 |
++ return sprintf(buf, "%llu.%i%c", q, t * 10 / 1024, units[u]); |
2351 |
+ } |
2352 |
+ |
2353 |
+ ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[], |
2354 |
+diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c |
2355 |
+index e51644e503a5..4ce2b19fe120 100644 |
2356 |
+--- a/drivers/md/bcache/writeback.c |
2357 |
++++ b/drivers/md/bcache/writeback.c |
2358 |
+@@ -20,7 +20,8 @@ |
2359 |
+ static void __update_writeback_rate(struct cached_dev *dc) |
2360 |
+ { |
2361 |
+ struct cache_set *c = dc->disk.c; |
2362 |
+- uint64_t cache_sectors = c->nbuckets * c->sb.bucket_size; |
2363 |
++ uint64_t cache_sectors = c->nbuckets * c->sb.bucket_size - |
2364 |
++ bcache_flash_devs_sectors_dirty(c); |
2365 |
+ uint64_t cache_dirty_target = |
2366 |
+ div_u64(cache_sectors * dc->writeback_percent, 100); |
2367 |
+ |
2368 |
+@@ -186,7 +187,7 @@ static void write_dirty(struct closure *cl) |
2369 |
+ |
2370 |
+ closure_bio_submit(&io->bio, cl); |
2371 |
+ |
2372 |
+- continue_at(cl, write_dirty_finish, system_wq); |
2373 |
++ continue_at(cl, write_dirty_finish, io->dc->writeback_write_wq); |
2374 |
+ } |
2375 |
+ |
2376 |
+ static void read_dirty_endio(struct bio *bio) |
2377 |
+@@ -206,7 +207,7 @@ static void read_dirty_submit(struct closure *cl) |
2378 |
+ |
2379 |
+ closure_bio_submit(&io->bio, cl); |
2380 |
+ |
2381 |
+- continue_at(cl, write_dirty, system_wq); |
2382 |
++ continue_at(cl, write_dirty, io->dc->writeback_write_wq); |
2383 |
+ } |
2384 |
+ |
2385 |
+ static void read_dirty(struct cached_dev *dc) |
2386 |
+@@ -482,17 +483,17 @@ static int sectors_dirty_init_fn(struct btree_op *_op, struct btree *b, |
2387 |
+ return MAP_CONTINUE; |
2388 |
+ } |
2389 |
+ |
2390 |
+-void bch_sectors_dirty_init(struct cached_dev *dc) |
2391 |
++void bch_sectors_dirty_init(struct bcache_device *d) |
2392 |
+ { |
2393 |
+ struct sectors_dirty_init op; |
2394 |
+ |
2395 |
+ bch_btree_op_init(&op.op, -1); |
2396 |
+- op.inode = dc->disk.id; |
2397 |
++ op.inode = d->id; |
2398 |
+ |
2399 |
+- bch_btree_map_keys(&op.op, dc->disk.c, &KEY(op.inode, 0, 0), |
2400 |
++ bch_btree_map_keys(&op.op, d->c, &KEY(op.inode, 0, 0), |
2401 |
+ sectors_dirty_init_fn, 0); |
2402 |
+ |
2403 |
+- dc->disk.sectors_dirty_last = bcache_dev_sectors_dirty(&dc->disk); |
2404 |
++ d->sectors_dirty_last = bcache_dev_sectors_dirty(d); |
2405 |
+ } |
2406 |
+ |
2407 |
+ void bch_cached_dev_writeback_init(struct cached_dev *dc) |
2408 |
+@@ -516,6 +517,11 @@ void bch_cached_dev_writeback_init(struct cached_dev *dc) |
2409 |
+ |
2410 |
+ int bch_cached_dev_writeback_start(struct cached_dev *dc) |
2411 |
+ { |
2412 |
++ dc->writeback_write_wq = alloc_workqueue("bcache_writeback_wq", |
2413 |
++ WQ_MEM_RECLAIM, 0); |
2414 |
++ if (!dc->writeback_write_wq) |
2415 |
++ return -ENOMEM; |
2416 |
++ |
2417 |
+ dc->writeback_thread = kthread_create(bch_writeback_thread, dc, |
2418 |
+ "bcache_writeback"); |
2419 |
+ if (IS_ERR(dc->writeback_thread)) |
2420 |
+diff --git a/drivers/md/bcache/writeback.h b/drivers/md/bcache/writeback.h |
2421 |
+index 301eaf565167..cdf8d253209e 100644 |
2422 |
+--- a/drivers/md/bcache/writeback.h |
2423 |
++++ b/drivers/md/bcache/writeback.h |
2424 |
+@@ -14,6 +14,25 @@ static inline uint64_t bcache_dev_sectors_dirty(struct bcache_device *d) |
2425 |
+ return ret; |
2426 |
+ } |
2427 |
+ |
2428 |
++static inline uint64_t bcache_flash_devs_sectors_dirty(struct cache_set *c) |
2429 |
++{ |
2430 |
++ uint64_t i, ret = 0; |
2431 |
++ |
2432 |
++ mutex_lock(&bch_register_lock); |
2433 |
++ |
2434 |
++ for (i = 0; i < c->nr_uuids; i++) { |
2435 |
++ struct bcache_device *d = c->devices[i]; |
2436 |
++ |
2437 |
++ if (!d || !UUID_FLASH_ONLY(&c->uuids[i])) |
2438 |
++ continue; |
2439 |
++ ret += bcache_dev_sectors_dirty(d); |
2440 |
++ } |
2441 |
++ |
2442 |
++ mutex_unlock(&bch_register_lock); |
2443 |
++ |
2444 |
++ return ret; |
2445 |
++} |
2446 |
++ |
2447 |
+ static inline unsigned offset_to_stripe(struct bcache_device *d, |
2448 |
+ uint64_t offset) |
2449 |
+ { |
2450 |
+@@ -85,7 +104,7 @@ static inline void bch_writeback_add(struct cached_dev *dc) |
2451 |
+ |
2452 |
+ void bcache_dev_sectors_dirty_add(struct cache_set *, unsigned, uint64_t, int); |
2453 |
+ |
2454 |
+-void bch_sectors_dirty_init(struct cached_dev *dc); |
2455 |
++void bch_sectors_dirty_init(struct bcache_device *); |
2456 |
+ void bch_cached_dev_writeback_init(struct cached_dev *); |
2457 |
+ int bch_cached_dev_writeback_start(struct cached_dev *); |
2458 |
+ |
2459 |
+diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c |
2460 |
+index 2d826927a3bf..fb02c3979bf4 100644 |
2461 |
+--- a/drivers/md/bitmap.c |
2462 |
++++ b/drivers/md/bitmap.c |
2463 |
+@@ -1992,6 +1992,11 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks, |
2464 |
+ long pages; |
2465 |
+ struct bitmap_page *new_bp; |
2466 |
+ |
2467 |
++ if (bitmap->storage.file && !init) { |
2468 |
++ pr_info("md: cannot resize file-based bitmap\n"); |
2469 |
++ return -EINVAL; |
2470 |
++ } |
2471 |
++ |
2472 |
+ if (chunksize == 0) { |
2473 |
+ /* If there is enough space, leave the chunk size unchanged, |
2474 |
+ * else increase by factor of two until there is enough space. |
2475 |
+diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c |
2476 |
+index c2ee6e39fd0c..20397aba6849 100644 |
2477 |
+--- a/drivers/media/usb/uvc/uvc_ctrl.c |
2478 |
++++ b/drivers/media/usb/uvc/uvc_ctrl.c |
2479 |
+@@ -2002,6 +2002,13 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, |
2480 |
+ goto done; |
2481 |
+ } |
2482 |
+ |
2483 |
++ /* Validate the user-provided bit-size and offset */ |
2484 |
++ if (mapping->size > 32 || |
2485 |
++ mapping->offset + mapping->size > ctrl->info.size * 8) { |
2486 |
++ ret = -EINVAL; |
2487 |
++ goto done; |
2488 |
++ } |
2489 |
++ |
2490 |
+ list_for_each_entry(map, &ctrl->info.mappings, list) { |
2491 |
+ if (mapping->id == map->id) { |
2492 |
+ uvc_trace(UVC_TRACE_CONTROL, "Can't add mapping '%s', " |
2493 |
+diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
2494 |
+index bacecbd68a6d..dc51dd86377d 100644 |
2495 |
+--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
2496 |
++++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
2497 |
+@@ -773,7 +773,8 @@ static int put_v4l2_event32(struct v4l2_event *kp, struct v4l2_event32 __user *u |
2498 |
+ copy_to_user(&up->u, &kp->u, sizeof(kp->u)) || |
2499 |
+ put_user(kp->pending, &up->pending) || |
2500 |
+ put_user(kp->sequence, &up->sequence) || |
2501 |
+- compat_put_timespec(&kp->timestamp, &up->timestamp) || |
2502 |
++ put_user(kp->timestamp.tv_sec, &up->timestamp.tv_sec) || |
2503 |
++ put_user(kp->timestamp.tv_nsec, &up->timestamp.tv_nsec) || |
2504 |
+ put_user(kp->id, &up->id) || |
2505 |
+ copy_to_user(up->reserved, kp->reserved, 8 * sizeof(__u32))) |
2506 |
+ return -EFAULT; |
2507 |
+diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c |
2508 |
+index b57fc6d6e28a..d08dfc8b9ba9 100644 |
2509 |
+--- a/drivers/pci/hotplug/pciehp_hpc.c |
2510 |
++++ b/drivers/pci/hotplug/pciehp_hpc.c |
2511 |
+@@ -586,6 +586,14 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) |
2512 |
+ events = status & (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD | |
2513 |
+ PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_CC | |
2514 |
+ PCI_EXP_SLTSTA_DLLSC); |
2515 |
++ |
2516 |
++ /* |
2517 |
++ * If we've already reported a power fault, don't report it again |
2518 |
++ * until we've done something to handle it. |
2519 |
++ */ |
2520 |
++ if (ctrl->power_fault_detected) |
2521 |
++ events &= ~PCI_EXP_SLTSTA_PFD; |
2522 |
++ |
2523 |
+ if (!events) |
2524 |
+ return IRQ_NONE; |
2525 |
+ |
2526 |
+diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c |
2527 |
+index de0ea474fb73..e5824c7b7b6b 100644 |
2528 |
+--- a/drivers/pci/hotplug/shpchp_hpc.c |
2529 |
++++ b/drivers/pci/hotplug/shpchp_hpc.c |
2530 |
+@@ -1062,6 +1062,8 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev) |
2531 |
+ if (rc) { |
2532 |
+ ctrl_info(ctrl, "Can't get msi for the hotplug controller\n"); |
2533 |
+ ctrl_info(ctrl, "Use INTx for the hotplug controller\n"); |
2534 |
++ } else { |
2535 |
++ pci_set_master(pdev); |
2536 |
+ } |
2537 |
+ |
2538 |
+ rc = request_irq(ctrl->pci_dev->irq, shpc_isr, IRQF_SHARED, |
2539 |
+diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c |
2540 |
+index c9a146948192..a5b7bd3c9bac 100644 |
2541 |
+--- a/drivers/pinctrl/pinctrl-amd.c |
2542 |
++++ b/drivers/pinctrl/pinctrl-amd.c |
2543 |
+@@ -32,6 +32,7 @@ |
2544 |
+ #include <linux/pinctrl/pinconf.h> |
2545 |
+ #include <linux/pinctrl/pinconf-generic.h> |
2546 |
+ |
2547 |
++#include "core.h" |
2548 |
+ #include "pinctrl-utils.h" |
2549 |
+ #include "pinctrl-amd.h" |
2550 |
+ |
2551 |
+@@ -712,6 +713,69 @@ static const struct pinconf_ops amd_pinconf_ops = { |
2552 |
+ .pin_config_group_set = amd_pinconf_group_set, |
2553 |
+ }; |
2554 |
+ |
2555 |
++#ifdef CONFIG_PM_SLEEP |
2556 |
++static bool amd_gpio_should_save(struct amd_gpio *gpio_dev, unsigned int pin) |
2557 |
++{ |
2558 |
++ const struct pin_desc *pd = pin_desc_get(gpio_dev->pctrl, pin); |
2559 |
++ |
2560 |
++ if (!pd) |
2561 |
++ return false; |
2562 |
++ |
2563 |
++ /* |
2564 |
++ * Only restore the pin if it is actually in use by the kernel (or |
2565 |
++ * by userspace). |
2566 |
++ */ |
2567 |
++ if (pd->mux_owner || pd->gpio_owner || |
2568 |
++ gpiochip_line_is_irq(&gpio_dev->gc, pin)) |
2569 |
++ return true; |
2570 |
++ |
2571 |
++ return false; |
2572 |
++} |
2573 |
++ |
2574 |
++int amd_gpio_suspend(struct device *dev) |
2575 |
++{ |
2576 |
++ struct platform_device *pdev = to_platform_device(dev); |
2577 |
++ struct amd_gpio *gpio_dev = platform_get_drvdata(pdev); |
2578 |
++ struct pinctrl_desc *desc = gpio_dev->pctrl->desc; |
2579 |
++ int i; |
2580 |
++ |
2581 |
++ for (i = 0; i < desc->npins; i++) { |
2582 |
++ int pin = desc->pins[i].number; |
2583 |
++ |
2584 |
++ if (!amd_gpio_should_save(gpio_dev, pin)) |
2585 |
++ continue; |
2586 |
++ |
2587 |
++ gpio_dev->saved_regs[i] = readl(gpio_dev->base + pin*4); |
2588 |
++ } |
2589 |
++ |
2590 |
++ return 0; |
2591 |
++} |
2592 |
++ |
2593 |
++int amd_gpio_resume(struct device *dev) |
2594 |
++{ |
2595 |
++ struct platform_device *pdev = to_platform_device(dev); |
2596 |
++ struct amd_gpio *gpio_dev = platform_get_drvdata(pdev); |
2597 |
++ struct pinctrl_desc *desc = gpio_dev->pctrl->desc; |
2598 |
++ int i; |
2599 |
++ |
2600 |
++ for (i = 0; i < desc->npins; i++) { |
2601 |
++ int pin = desc->pins[i].number; |
2602 |
++ |
2603 |
++ if (!amd_gpio_should_save(gpio_dev, pin)) |
2604 |
++ continue; |
2605 |
++ |
2606 |
++ writel(gpio_dev->saved_regs[i], gpio_dev->base + pin*4); |
2607 |
++ } |
2608 |
++ |
2609 |
++ return 0; |
2610 |
++} |
2611 |
++ |
2612 |
++static const struct dev_pm_ops amd_gpio_pm_ops = { |
2613 |
++ SET_LATE_SYSTEM_SLEEP_PM_OPS(amd_gpio_suspend, |
2614 |
++ amd_gpio_resume) |
2615 |
++}; |
2616 |
++#endif |
2617 |
++ |
2618 |
+ static struct pinctrl_desc amd_pinctrl_desc = { |
2619 |
+ .pins = kerncz_pins, |
2620 |
+ .npins = ARRAY_SIZE(kerncz_pins), |
2621 |
+@@ -751,6 +815,14 @@ static int amd_gpio_probe(struct platform_device *pdev) |
2622 |
+ return -EINVAL; |
2623 |
+ } |
2624 |
+ |
2625 |
++#ifdef CONFIG_PM_SLEEP |
2626 |
++ gpio_dev->saved_regs = devm_kcalloc(&pdev->dev, amd_pinctrl_desc.npins, |
2627 |
++ sizeof(*gpio_dev->saved_regs), |
2628 |
++ GFP_KERNEL); |
2629 |
++ if (!gpio_dev->saved_regs) |
2630 |
++ return -ENOMEM; |
2631 |
++#endif |
2632 |
++ |
2633 |
+ gpio_dev->pdev = pdev; |
2634 |
+ gpio_dev->gc.direction_input = amd_gpio_direction_input; |
2635 |
+ gpio_dev->gc.direction_output = amd_gpio_direction_output; |
2636 |
+@@ -839,6 +911,9 @@ static struct platform_driver amd_gpio_driver = { |
2637 |
+ .driver = { |
2638 |
+ .name = "amd_gpio", |
2639 |
+ .acpi_match_table = ACPI_PTR(amd_gpio_acpi_match), |
2640 |
++#ifdef CONFIG_PM_SLEEP |
2641 |
++ .pm = &amd_gpio_pm_ops, |
2642 |
++#endif |
2643 |
+ }, |
2644 |
+ .probe = amd_gpio_probe, |
2645 |
+ .remove = amd_gpio_remove, |
2646 |
+diff --git a/drivers/pinctrl/pinctrl-amd.h b/drivers/pinctrl/pinctrl-amd.h |
2647 |
+index 7bfea47dbb47..e8bbb20779d0 100644 |
2648 |
+--- a/drivers/pinctrl/pinctrl-amd.h |
2649 |
++++ b/drivers/pinctrl/pinctrl-amd.h |
2650 |
+@@ -95,6 +95,7 @@ struct amd_gpio { |
2651 |
+ struct gpio_chip gc; |
2652 |
+ struct resource *res; |
2653 |
+ struct platform_device *pdev; |
2654 |
++ u32 *saved_regs; |
2655 |
+ }; |
2656 |
+ |
2657 |
+ /* KERNCZ configuration*/ |
2658 |
+diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c |
2659 |
+index d5bf36ec8a75..34367d172961 100644 |
2660 |
+--- a/drivers/s390/scsi/zfcp_dbf.c |
2661 |
++++ b/drivers/s390/scsi/zfcp_dbf.c |
2662 |
+@@ -3,7 +3,7 @@ |
2663 |
+ * |
2664 |
+ * Debug traces for zfcp. |
2665 |
+ * |
2666 |
+- * Copyright IBM Corp. 2002, 2016 |
2667 |
++ * Copyright IBM Corp. 2002, 2017 |
2668 |
+ */ |
2669 |
+ |
2670 |
+ #define KMSG_COMPONENT "zfcp" |
2671 |
+@@ -447,6 +447,7 @@ static u16 zfcp_dbf_san_res_cap_len_if_gpn_ft(char *tag, |
2672 |
+ struct fc_ct_hdr *reqh = sg_virt(ct_els->req); |
2673 |
+ struct fc_ns_gid_ft *reqn = (struct fc_ns_gid_ft *)(reqh + 1); |
2674 |
+ struct scatterlist *resp_entry = ct_els->resp; |
2675 |
++ struct fc_ct_hdr *resph; |
2676 |
+ struct fc_gpn_ft_resp *acc; |
2677 |
+ int max_entries, x, last = 0; |
2678 |
+ |
2679 |
+@@ -473,6 +474,13 @@ static u16 zfcp_dbf_san_res_cap_len_if_gpn_ft(char *tag, |
2680 |
+ return len; /* not GPN_FT response so do not cap */ |
2681 |
+ |
2682 |
+ acc = sg_virt(resp_entry); |
2683 |
++ |
2684 |
++ /* cap all but accept CT responses to at least the CT header */ |
2685 |
++ resph = (struct fc_ct_hdr *)acc; |
2686 |
++ if ((ct_els->status) || |
2687 |
++ (resph->ct_cmd != cpu_to_be16(FC_FS_ACC))) |
2688 |
++ return max(FC_CT_HDR_LEN, ZFCP_DBF_SAN_MAX_PAYLOAD); |
2689 |
++ |
2690 |
+ max_entries = (reqh->ct_mr_size * 4 / sizeof(struct fc_gpn_ft_resp)) |
2691 |
+ + 1 /* zfcp_fc_scan_ports: bytes correct, entries off-by-one |
2692 |
+ * to account for header as 1st pseudo "entry" */; |
2693 |
+@@ -555,8 +563,8 @@ void zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *sc, |
2694 |
+ rec->scsi_retries = sc->retries; |
2695 |
+ rec->scsi_allowed = sc->allowed; |
2696 |
+ rec->scsi_id = sc->device->id; |
2697 |
+- /* struct zfcp_dbf_scsi needs to be updated to handle 64bit LUNs */ |
2698 |
+ rec->scsi_lun = (u32)sc->device->lun; |
2699 |
++ rec->scsi_lun_64_hi = (u32)(sc->device->lun >> 32); |
2700 |
+ rec->host_scribble = (unsigned long)sc->host_scribble; |
2701 |
+ |
2702 |
+ memcpy(rec->scsi_opcode, sc->cmnd, |
2703 |
+@@ -564,19 +572,32 @@ void zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *sc, |
2704 |
+ |
2705 |
+ if (fsf) { |
2706 |
+ rec->fsf_req_id = fsf->req_id; |
2707 |
++ rec->pl_len = FCP_RESP_WITH_EXT; |
2708 |
+ fcp_rsp = (struct fcp_resp_with_ext *) |
2709 |
+ &(fsf->qtcb->bottom.io.fcp_rsp); |
2710 |
++ /* mandatory parts of FCP_RSP IU in this SCSI record */ |
2711 |
+ memcpy(&rec->fcp_rsp, fcp_rsp, FCP_RESP_WITH_EXT); |
2712 |
+ if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL) { |
2713 |
+ fcp_rsp_info = (struct fcp_resp_rsp_info *) &fcp_rsp[1]; |
2714 |
+ rec->fcp_rsp_info = fcp_rsp_info->rsp_code; |
2715 |
++ rec->pl_len += be32_to_cpu(fcp_rsp->ext.fr_rsp_len); |
2716 |
+ } |
2717 |
+ if (fcp_rsp->resp.fr_flags & FCP_SNS_LEN_VAL) { |
2718 |
+- rec->pl_len = min((u16)SCSI_SENSE_BUFFERSIZE, |
2719 |
+- (u16)ZFCP_DBF_PAY_MAX_REC); |
2720 |
+- zfcp_dbf_pl_write(dbf, sc->sense_buffer, rec->pl_len, |
2721 |
+- "fcp_sns", fsf->req_id); |
2722 |
++ rec->pl_len += be32_to_cpu(fcp_rsp->ext.fr_sns_len); |
2723 |
+ } |
2724 |
++ /* complete FCP_RSP IU in associated PAYload record |
2725 |
++ * but only if there are optional parts |
2726 |
++ */ |
2727 |
++ if (fcp_rsp->resp.fr_flags != 0) |
2728 |
++ zfcp_dbf_pl_write( |
2729 |
++ dbf, fcp_rsp, |
2730 |
++ /* at least one full PAY record |
2731 |
++ * but not beyond hardware response field |
2732 |
++ */ |
2733 |
++ min_t(u16, max_t(u16, rec->pl_len, |
2734 |
++ ZFCP_DBF_PAY_MAX_REC), |
2735 |
++ FSF_FCP_RSP_SIZE), |
2736 |
++ "fcp_riu", fsf->req_id); |
2737 |
+ } |
2738 |
+ |
2739 |
+ debug_event(dbf->scsi, level, rec, sizeof(*rec)); |
2740 |
+diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h |
2741 |
+index db186d44cfaf..b60667c145fd 100644 |
2742 |
+--- a/drivers/s390/scsi/zfcp_dbf.h |
2743 |
++++ b/drivers/s390/scsi/zfcp_dbf.h |
2744 |
+@@ -2,7 +2,7 @@ |
2745 |
+ * zfcp device driver |
2746 |
+ * debug feature declarations |
2747 |
+ * |
2748 |
+- * Copyright IBM Corp. 2008, 2016 |
2749 |
++ * Copyright IBM Corp. 2008, 2017 |
2750 |
+ */ |
2751 |
+ |
2752 |
+ #ifndef ZFCP_DBF_H |
2753 |
+@@ -204,7 +204,7 @@ enum zfcp_dbf_scsi_id { |
2754 |
+ * @id: unique number of recovery record type |
2755 |
+ * @tag: identifier string specifying the location of initiation |
2756 |
+ * @scsi_id: scsi device id |
2757 |
+- * @scsi_lun: scsi device logical unit number |
2758 |
++ * @scsi_lun: scsi device logical unit number, low part of 64 bit, old 32 bit |
2759 |
+ * @scsi_result: scsi result |
2760 |
+ * @scsi_retries: current retry number of scsi request |
2761 |
+ * @scsi_allowed: allowed retries |
2762 |
+@@ -214,6 +214,7 @@ enum zfcp_dbf_scsi_id { |
2763 |
+ * @host_scribble: LLD specific data attached to SCSI request |
2764 |
+ * @pl_len: length of paload stored as zfcp_dbf_pay |
2765 |
+ * @fsf_rsp: response for fsf request |
2766 |
++ * @scsi_lun_64_hi: scsi device logical unit number, high part of 64 bit |
2767 |
+ */ |
2768 |
+ struct zfcp_dbf_scsi { |
2769 |
+ u8 id; |
2770 |
+@@ -230,6 +231,7 @@ struct zfcp_dbf_scsi { |
2771 |
+ u64 host_scribble; |
2772 |
+ u16 pl_len; |
2773 |
+ struct fcp_resp_with_ext fcp_rsp; |
2774 |
++ u32 scsi_lun_64_hi; |
2775 |
+ } __packed; |
2776 |
+ |
2777 |
+ /** |
2778 |
+@@ -323,7 +325,11 @@ void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req) |
2779 |
+ { |
2780 |
+ struct fsf_qtcb *qtcb = req->qtcb; |
2781 |
+ |
2782 |
+- if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) && |
2783 |
++ if (unlikely(req->status & (ZFCP_STATUS_FSFREQ_DISMISSED | |
2784 |
++ ZFCP_STATUS_FSFREQ_ERROR))) { |
2785 |
++ zfcp_dbf_hba_fsf_resp("fs_rerr", 3, req); |
2786 |
++ |
2787 |
++ } else if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) && |
2788 |
+ (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) { |
2789 |
+ zfcp_dbf_hba_fsf_resp("fs_perr", 1, req); |
2790 |
+ |
2791 |
+@@ -401,7 +407,8 @@ void zfcp_dbf_scsi_abort(char *tag, struct scsi_cmnd *scmd, |
2792 |
+ * @flag: indicates type of reset (Target Reset, Logical Unit Reset) |
2793 |
+ */ |
2794 |
+ static inline |
2795 |
+-void zfcp_dbf_scsi_devreset(char *tag, struct scsi_cmnd *scmnd, u8 flag) |
2796 |
++void zfcp_dbf_scsi_devreset(char *tag, struct scsi_cmnd *scmnd, u8 flag, |
2797 |
++ struct zfcp_fsf_req *fsf_req) |
2798 |
+ { |
2799 |
+ char tmp_tag[ZFCP_DBF_TAG_LEN]; |
2800 |
+ |
2801 |
+@@ -411,7 +418,7 @@ void zfcp_dbf_scsi_devreset(char *tag, struct scsi_cmnd *scmnd, u8 flag) |
2802 |
+ memcpy(tmp_tag, "lr_", 3); |
2803 |
+ |
2804 |
+ memcpy(&tmp_tag[3], tag, 4); |
2805 |
+- _zfcp_dbf_scsi(tmp_tag, 1, scmnd, NULL); |
2806 |
++ _zfcp_dbf_scsi(tmp_tag, 1, scmnd, fsf_req); |
2807 |
+ } |
2808 |
+ |
2809 |
+ /** |
2810 |
+diff --git a/drivers/s390/scsi/zfcp_fc.h b/drivers/s390/scsi/zfcp_fc.h |
2811 |
+index df2b541c8287..a2275825186f 100644 |
2812 |
+--- a/drivers/s390/scsi/zfcp_fc.h |
2813 |
++++ b/drivers/s390/scsi/zfcp_fc.h |
2814 |
+@@ -4,7 +4,7 @@ |
2815 |
+ * Fibre Channel related definitions and inline functions for the zfcp |
2816 |
+ * device driver |
2817 |
+ * |
2818 |
+- * Copyright IBM Corp. 2009 |
2819 |
++ * Copyright IBM Corp. 2009, 2017 |
2820 |
+ */ |
2821 |
+ |
2822 |
+ #ifndef ZFCP_FC_H |
2823 |
+@@ -279,6 +279,10 @@ void zfcp_fc_eval_fcp_rsp(struct fcp_resp_with_ext *fcp_rsp, |
2824 |
+ !(rsp_flags & FCP_SNS_LEN_VAL) && |
2825 |
+ fcp_rsp->resp.fr_status == SAM_STAT_GOOD) |
2826 |
+ set_host_byte(scsi, DID_ERROR); |
2827 |
++ } else if (unlikely(rsp_flags & FCP_RESID_OVER)) { |
2828 |
++ /* FCP_DL was not sufficient for SCSI data length */ |
2829 |
++ if (fcp_rsp->resp.fr_status == SAM_STAT_GOOD) |
2830 |
++ set_host_byte(scsi, DID_ERROR); |
2831 |
+ } |
2832 |
+ } |
2833 |
+ |
2834 |
+diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c |
2835 |
+index 27ff38f839fc..1964391db904 100644 |
2836 |
+--- a/drivers/s390/scsi/zfcp_fsf.c |
2837 |
++++ b/drivers/s390/scsi/zfcp_fsf.c |
2838 |
+@@ -928,8 +928,8 @@ static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req) |
2839 |
+ |
2840 |
+ switch (header->fsf_status) { |
2841 |
+ case FSF_GOOD: |
2842 |
+- zfcp_dbf_san_res("fsscth2", req); |
2843 |
+ ct->status = 0; |
2844 |
++ zfcp_dbf_san_res("fsscth2", req); |
2845 |
+ break; |
2846 |
+ case FSF_SERVICE_CLASS_NOT_SUPPORTED: |
2847 |
+ zfcp_fsf_class_not_supp(req); |
2848 |
+@@ -1109,8 +1109,8 @@ static void zfcp_fsf_send_els_handler(struct zfcp_fsf_req *req) |
2849 |
+ |
2850 |
+ switch (header->fsf_status) { |
2851 |
+ case FSF_GOOD: |
2852 |
+- zfcp_dbf_san_res("fsselh1", req); |
2853 |
+ send_els->status = 0; |
2854 |
++ zfcp_dbf_san_res("fsselh1", req); |
2855 |
+ break; |
2856 |
+ case FSF_SERVICE_CLASS_NOT_SUPPORTED: |
2857 |
+ zfcp_fsf_class_not_supp(req); |
2858 |
+@@ -2258,7 +2258,8 @@ int zfcp_fsf_fcp_cmnd(struct scsi_cmnd *scsi_cmnd) |
2859 |
+ fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; |
2860 |
+ zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd, 0); |
2861 |
+ |
2862 |
+- if (scsi_prot_sg_count(scsi_cmnd)) { |
2863 |
++ if ((scsi_get_prot_op(scsi_cmnd) != SCSI_PROT_NORMAL) && |
2864 |
++ scsi_prot_sg_count(scsi_cmnd)) { |
2865 |
+ zfcp_qdio_set_data_div(qdio, &req->qdio_req, |
2866 |
+ scsi_prot_sg_count(scsi_cmnd)); |
2867 |
+ retval = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, |
2868 |
+diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c |
2869 |
+index 07ffdbb5107f..9bd9b9a29dfc 100644 |
2870 |
+--- a/drivers/s390/scsi/zfcp_scsi.c |
2871 |
++++ b/drivers/s390/scsi/zfcp_scsi.c |
2872 |
+@@ -3,7 +3,7 @@ |
2873 |
+ * |
2874 |
+ * Interface to Linux SCSI midlayer. |
2875 |
+ * |
2876 |
+- * Copyright IBM Corp. 2002, 2016 |
2877 |
++ * Copyright IBM Corp. 2002, 2017 |
2878 |
+ */ |
2879 |
+ |
2880 |
+ #define KMSG_COMPONENT "zfcp" |
2881 |
+@@ -273,25 +273,29 @@ static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags) |
2882 |
+ |
2883 |
+ zfcp_erp_wait(adapter); |
2884 |
+ ret = fc_block_scsi_eh(scpnt); |
2885 |
+- if (ret) |
2886 |
++ if (ret) { |
2887 |
++ zfcp_dbf_scsi_devreset("fiof", scpnt, tm_flags, NULL); |
2888 |
+ return ret; |
2889 |
++ } |
2890 |
+ |
2891 |
+ if (!(atomic_read(&adapter->status) & |
2892 |
+ ZFCP_STATUS_COMMON_RUNNING)) { |
2893 |
+- zfcp_dbf_scsi_devreset("nres", scpnt, tm_flags); |
2894 |
++ zfcp_dbf_scsi_devreset("nres", scpnt, tm_flags, NULL); |
2895 |
+ return SUCCESS; |
2896 |
+ } |
2897 |
+ } |
2898 |
+- if (!fsf_req) |
2899 |
++ if (!fsf_req) { |
2900 |
++ zfcp_dbf_scsi_devreset("reqf", scpnt, tm_flags, NULL); |
2901 |
+ return FAILED; |
2902 |
++ } |
2903 |
+ |
2904 |
+ wait_for_completion(&fsf_req->completion); |
2905 |
+ |
2906 |
+ if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) { |
2907 |
+- zfcp_dbf_scsi_devreset("fail", scpnt, tm_flags); |
2908 |
++ zfcp_dbf_scsi_devreset("fail", scpnt, tm_flags, fsf_req); |
2909 |
+ retval = FAILED; |
2910 |
+ } else { |
2911 |
+- zfcp_dbf_scsi_devreset("okay", scpnt, tm_flags); |
2912 |
++ zfcp_dbf_scsi_devreset("okay", scpnt, tm_flags, fsf_req); |
2913 |
+ zfcp_scsi_forget_cmnds(zfcp_sdev, tm_flags); |
2914 |
+ } |
2915 |
+ |
2916 |
+diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c |
2917 |
+index d8b1fbd4c8aa..35cbd36f8d3b 100644 |
2918 |
+--- a/drivers/scsi/megaraid/megaraid_sas_base.c |
2919 |
++++ b/drivers/scsi/megaraid/megaraid_sas_base.c |
2920 |
+@@ -1901,9 +1901,12 @@ static void megasas_complete_outstanding_ioctls(struct megasas_instance *instanc |
2921 |
+ if (cmd_fusion->sync_cmd_idx != (u32)ULONG_MAX) { |
2922 |
+ cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; |
2923 |
+ if (cmd_mfi->sync_cmd && |
2924 |
+- cmd_mfi->frame->hdr.cmd != MFI_CMD_ABORT) |
2925 |
++ (cmd_mfi->frame->hdr.cmd != MFI_CMD_ABORT)) { |
2926 |
++ cmd_mfi->frame->hdr.cmd_status = |
2927 |
++ MFI_STAT_WRONG_STATE; |
2928 |
+ megasas_complete_cmd(instance, |
2929 |
+ cmd_mfi, DID_OK); |
2930 |
++ } |
2931 |
+ } |
2932 |
+ } |
2933 |
+ } else { |
2934 |
+@@ -5290,7 +5293,8 @@ static int megasas_init_fw(struct megasas_instance *instance) |
2935 |
+ instance->throttlequeuedepth = |
2936 |
+ MEGASAS_THROTTLE_QUEUE_DEPTH; |
2937 |
+ |
2938 |
+- if (resetwaittime > MEGASAS_RESET_WAIT_TIME) |
2939 |
++ if ((resetwaittime < 1) || |
2940 |
++ (resetwaittime > MEGASAS_RESET_WAIT_TIME)) |
2941 |
+ resetwaittime = MEGASAS_RESET_WAIT_TIME; |
2942 |
+ |
2943 |
+ if ((scmd_timeout < 10) || (scmd_timeout > MEGASAS_DEFAULT_CMD_TIMEOUT)) |
2944 |
+@@ -5459,6 +5463,14 @@ megasas_register_aen(struct megasas_instance *instance, u32 seq_num, |
2945 |
+ prev_aen.word = |
2946 |
+ le32_to_cpu(instance->aen_cmd->frame->dcmd.mbox.w[1]); |
2947 |
+ |
2948 |
++ if ((curr_aen.members.class < MFI_EVT_CLASS_DEBUG) || |
2949 |
++ (curr_aen.members.class > MFI_EVT_CLASS_DEAD)) { |
2950 |
++ dev_info(&instance->pdev->dev, |
2951 |
++ "%s %d out of range class %d send by application\n", |
2952 |
++ __func__, __LINE__, curr_aen.members.class); |
2953 |
++ return 0; |
2954 |
++ } |
2955 |
++ |
2956 |
+ /* |
2957 |
+ * A class whose enum value is smaller is inclusive of all |
2958 |
+ * higher values. If a PROGRESS (= -1) was previously |
2959 |
+diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c |
2960 |
+index 8c4641b518b5..9a34afcb1c4c 100644 |
2961 |
+--- a/drivers/scsi/qla2xxx/qla_attr.c |
2962 |
++++ b/drivers/scsi/qla2xxx/qla_attr.c |
2963 |
+@@ -318,6 +318,8 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, |
2964 |
+ return -EINVAL; |
2965 |
+ if (start > ha->optrom_size) |
2966 |
+ return -EINVAL; |
2967 |
++ if (size > ha->optrom_size - start) |
2968 |
++ size = ha->optrom_size - start; |
2969 |
+ |
2970 |
+ mutex_lock(&ha->optrom_mutex); |
2971 |
+ switch (val) { |
2972 |
+@@ -343,8 +345,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, |
2973 |
+ } |
2974 |
+ |
2975 |
+ ha->optrom_region_start = start; |
2976 |
+- ha->optrom_region_size = start + size > ha->optrom_size ? |
2977 |
+- ha->optrom_size - start : size; |
2978 |
++ ha->optrom_region_size = start + size; |
2979 |
+ |
2980 |
+ ha->optrom_state = QLA_SREADING; |
2981 |
+ ha->optrom_buffer = vmalloc(ha->optrom_region_size); |
2982 |
+@@ -417,8 +418,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, |
2983 |
+ } |
2984 |
+ |
2985 |
+ ha->optrom_region_start = start; |
2986 |
+- ha->optrom_region_size = start + size > ha->optrom_size ? |
2987 |
+- ha->optrom_size - start : size; |
2988 |
++ ha->optrom_region_size = start + size; |
2989 |
+ |
2990 |
+ ha->optrom_state = QLA_SWRITING; |
2991 |
+ ha->optrom_buffer = vmalloc(ha->optrom_region_size); |
2992 |
+diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c |
2993 |
+index 3dfb54abc874..f8ae70476b3a 100644 |
2994 |
+--- a/drivers/scsi/qla2xxx/qla_mid.c |
2995 |
++++ b/drivers/scsi/qla2xxx/qla_mid.c |
2996 |
+@@ -74,7 +74,7 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha) |
2997 |
+ * ensures no active vp_list traversal while the vport is removed |
2998 |
+ * from the queue) |
2999 |
+ */ |
3000 |
+- wait_event_timeout(vha->vref_waitq, atomic_read(&vha->vref_count), |
3001 |
++ wait_event_timeout(vha->vref_waitq, !atomic_read(&vha->vref_count), |
3002 |
+ 10*HZ); |
3003 |
+ |
3004 |
+ spin_lock_irqsave(&ha->vport_slock, flags); |
3005 |
+diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c |
3006 |
+index 9236a13d5d2a..02dfbc1373e3 100644 |
3007 |
+--- a/drivers/scsi/sg.c |
3008 |
++++ b/drivers/scsi/sg.c |
3009 |
+@@ -122,7 +122,7 @@ struct sg_device; /* forward declarations */ |
3010 |
+ struct sg_fd; |
3011 |
+ |
3012 |
+ typedef struct sg_request { /* SG_MAX_QUEUE requests outstanding per file */ |
3013 |
+- struct sg_request *nextrp; /* NULL -> tail request (slist) */ |
3014 |
++ struct list_head entry; /* list entry */ |
3015 |
+ struct sg_fd *parentfp; /* NULL -> not in use */ |
3016 |
+ Sg_scatter_hold data; /* hold buffer, perhaps scatter list */ |
3017 |
+ sg_io_hdr_t header; /* scsi command+info, see <scsi/sg.h> */ |
3018 |
+@@ -146,8 +146,7 @@ typedef struct sg_fd { /* holds the state of a file descriptor */ |
3019 |
+ int timeout; /* defaults to SG_DEFAULT_TIMEOUT */ |
3020 |
+ int timeout_user; /* defaults to SG_DEFAULT_TIMEOUT_USER */ |
3021 |
+ Sg_scatter_hold reserve; /* buffer held for this file descriptor */ |
3022 |
+- unsigned save_scat_len; /* original length of trunc. scat. element */ |
3023 |
+- Sg_request *headrp; /* head of request slist, NULL->empty */ |
3024 |
++ struct list_head rq_list; /* head of request list */ |
3025 |
+ struct fasync_struct *async_qp; /* used by asynchronous notification */ |
3026 |
+ Sg_request req_arr[SG_MAX_QUEUE]; /* used as singly-linked list */ |
3027 |
+ char low_dma; /* as in parent but possibly overridden to 1 */ |
3028 |
+@@ -829,6 +828,39 @@ static int max_sectors_bytes(struct request_queue *q) |
3029 |
+ return max_sectors << 9; |
3030 |
+ } |
3031 |
+ |
3032 |
++static void |
3033 |
++sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo) |
3034 |
++{ |
3035 |
++ Sg_request *srp; |
3036 |
++ int val; |
3037 |
++ unsigned int ms; |
3038 |
++ |
3039 |
++ val = 0; |
3040 |
++ list_for_each_entry(srp, &sfp->rq_list, entry) { |
3041 |
++ if (val > SG_MAX_QUEUE) |
3042 |
++ break; |
3043 |
++ rinfo[val].req_state = srp->done + 1; |
3044 |
++ rinfo[val].problem = |
3045 |
++ srp->header.masked_status & |
3046 |
++ srp->header.host_status & |
3047 |
++ srp->header.driver_status; |
3048 |
++ if (srp->done) |
3049 |
++ rinfo[val].duration = |
3050 |
++ srp->header.duration; |
3051 |
++ else { |
3052 |
++ ms = jiffies_to_msecs(jiffies); |
3053 |
++ rinfo[val].duration = |
3054 |
++ (ms > srp->header.duration) ? |
3055 |
++ (ms - srp->header.duration) : 0; |
3056 |
++ } |
3057 |
++ rinfo[val].orphan = srp->orphan; |
3058 |
++ rinfo[val].sg_io_owned = srp->sg_io_owned; |
3059 |
++ rinfo[val].pack_id = srp->header.pack_id; |
3060 |
++ rinfo[val].usr_ptr = srp->header.usr_ptr; |
3061 |
++ val++; |
3062 |
++ } |
3063 |
++} |
3064 |
++ |
3065 |
+ static long |
3066 |
+ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) |
3067 |
+ { |
3068 |
+@@ -941,7 +973,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) |
3069 |
+ if (!access_ok(VERIFY_WRITE, ip, sizeof (int))) |
3070 |
+ return -EFAULT; |
3071 |
+ read_lock_irqsave(&sfp->rq_list_lock, iflags); |
3072 |
+- for (srp = sfp->headrp; srp; srp = srp->nextrp) { |
3073 |
++ list_for_each_entry(srp, &sfp->rq_list, entry) { |
3074 |
+ if ((1 == srp->done) && (!srp->sg_io_owned)) { |
3075 |
+ read_unlock_irqrestore(&sfp->rq_list_lock, |
3076 |
+ iflags); |
3077 |
+@@ -954,7 +986,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) |
3078 |
+ return 0; |
3079 |
+ case SG_GET_NUM_WAITING: |
3080 |
+ read_lock_irqsave(&sfp->rq_list_lock, iflags); |
3081 |
+- for (val = 0, srp = sfp->headrp; srp; srp = srp->nextrp) { |
3082 |
++ val = 0; |
3083 |
++ list_for_each_entry(srp, &sfp->rq_list, entry) { |
3084 |
+ if ((1 == srp->done) && (!srp->sg_io_owned)) |
3085 |
+ ++val; |
3086 |
+ } |
3087 |
+@@ -1022,42 +1055,15 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) |
3088 |
+ return -EFAULT; |
3089 |
+ else { |
3090 |
+ sg_req_info_t *rinfo; |
3091 |
+- unsigned int ms; |
3092 |
+ |
3093 |
+- rinfo = kmalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE, |
3094 |
+- GFP_KERNEL); |
3095 |
++ rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE, |
3096 |
++ GFP_KERNEL); |
3097 |
+ if (!rinfo) |
3098 |
+ return -ENOMEM; |
3099 |
+ read_lock_irqsave(&sfp->rq_list_lock, iflags); |
3100 |
+- for (srp = sfp->headrp, val = 0; val < SG_MAX_QUEUE; |
3101 |
+- ++val, srp = srp ? srp->nextrp : srp) { |
3102 |
+- memset(&rinfo[val], 0, SZ_SG_REQ_INFO); |
3103 |
+- if (srp) { |
3104 |
+- rinfo[val].req_state = srp->done + 1; |
3105 |
+- rinfo[val].problem = |
3106 |
+- srp->header.masked_status & |
3107 |
+- srp->header.host_status & |
3108 |
+- srp->header.driver_status; |
3109 |
+- if (srp->done) |
3110 |
+- rinfo[val].duration = |
3111 |
+- srp->header.duration; |
3112 |
+- else { |
3113 |
+- ms = jiffies_to_msecs(jiffies); |
3114 |
+- rinfo[val].duration = |
3115 |
+- (ms > srp->header.duration) ? |
3116 |
+- (ms - srp->header.duration) : 0; |
3117 |
+- } |
3118 |
+- rinfo[val].orphan = srp->orphan; |
3119 |
+- rinfo[val].sg_io_owned = |
3120 |
+- srp->sg_io_owned; |
3121 |
+- rinfo[val].pack_id = |
3122 |
+- srp->header.pack_id; |
3123 |
+- rinfo[val].usr_ptr = |
3124 |
+- srp->header.usr_ptr; |
3125 |
+- } |
3126 |
+- } |
3127 |
++ sg_fill_request_table(sfp, rinfo); |
3128 |
+ read_unlock_irqrestore(&sfp->rq_list_lock, iflags); |
3129 |
+- result = __copy_to_user(p, rinfo, |
3130 |
++ result = __copy_to_user(p, rinfo, |
3131 |
+ SZ_SG_REQ_INFO * SG_MAX_QUEUE); |
3132 |
+ result = result ? -EFAULT : 0; |
3133 |
+ kfree(rinfo); |
3134 |
+@@ -1163,7 +1169,7 @@ sg_poll(struct file *filp, poll_table * wait) |
3135 |
+ return POLLERR; |
3136 |
+ poll_wait(filp, &sfp->read_wait, wait); |
3137 |
+ read_lock_irqsave(&sfp->rq_list_lock, iflags); |
3138 |
+- for (srp = sfp->headrp; srp; srp = srp->nextrp) { |
3139 |
++ list_for_each_entry(srp, &sfp->rq_list, entry) { |
3140 |
+ /* if any read waiting, flag it */ |
3141 |
+ if ((0 == res) && (1 == srp->done) && (!srp->sg_io_owned)) |
3142 |
+ res = POLLIN | POLLRDNORM; |
3143 |
+@@ -2049,7 +2055,6 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp) |
3144 |
+ req_schp->pages = NULL; |
3145 |
+ req_schp->page_order = 0; |
3146 |
+ req_schp->sglist_len = 0; |
3147 |
+- sfp->save_scat_len = 0; |
3148 |
+ srp->res_used = 0; |
3149 |
+ /* Called without mutex lock to avoid deadlock */ |
3150 |
+ sfp->res_in_use = 0; |
3151 |
+@@ -2062,7 +2067,7 @@ sg_get_rq_mark(Sg_fd * sfp, int pack_id) |
3152 |
+ unsigned long iflags; |
3153 |
+ |
3154 |
+ write_lock_irqsave(&sfp->rq_list_lock, iflags); |
3155 |
+- for (resp = sfp->headrp; resp; resp = resp->nextrp) { |
3156 |
++ list_for_each_entry(resp, &sfp->rq_list, entry) { |
3157 |
+ /* look for requests that are ready + not SG_IO owned */ |
3158 |
+ if ((1 == resp->done) && (!resp->sg_io_owned) && |
3159 |
+ ((-1 == pack_id) || (resp->header.pack_id == pack_id))) { |
3160 |
+@@ -2080,70 +2085,45 @@ sg_add_request(Sg_fd * sfp) |
3161 |
+ { |
3162 |
+ int k; |
3163 |
+ unsigned long iflags; |
3164 |
+- Sg_request *resp; |
3165 |
+ Sg_request *rp = sfp->req_arr; |
3166 |
+ |
3167 |
+ write_lock_irqsave(&sfp->rq_list_lock, iflags); |
3168 |
+- resp = sfp->headrp; |
3169 |
+- if (!resp) { |
3170 |
+- memset(rp, 0, sizeof (Sg_request)); |
3171 |
+- rp->parentfp = sfp; |
3172 |
+- resp = rp; |
3173 |
+- sfp->headrp = resp; |
3174 |
+- } else { |
3175 |
+- if (0 == sfp->cmd_q) |
3176 |
+- resp = NULL; /* command queuing disallowed */ |
3177 |
+- else { |
3178 |
+- for (k = 0; k < SG_MAX_QUEUE; ++k, ++rp) { |
3179 |
+- if (!rp->parentfp) |
3180 |
+- break; |
3181 |
+- } |
3182 |
+- if (k < SG_MAX_QUEUE) { |
3183 |
+- memset(rp, 0, sizeof (Sg_request)); |
3184 |
+- rp->parentfp = sfp; |
3185 |
+- while (resp->nextrp) |
3186 |
+- resp = resp->nextrp; |
3187 |
+- resp->nextrp = rp; |
3188 |
+- resp = rp; |
3189 |
+- } else |
3190 |
+- resp = NULL; |
3191 |
++ if (!list_empty(&sfp->rq_list)) { |
3192 |
++ if (!sfp->cmd_q) |
3193 |
++ goto out_unlock; |
3194 |
++ |
3195 |
++ for (k = 0; k < SG_MAX_QUEUE; ++k, ++rp) { |
3196 |
++ if (!rp->parentfp) |
3197 |
++ break; |
3198 |
+ } |
3199 |
++ if (k >= SG_MAX_QUEUE) |
3200 |
++ goto out_unlock; |
3201 |
+ } |
3202 |
+- if (resp) { |
3203 |
+- resp->nextrp = NULL; |
3204 |
+- resp->header.duration = jiffies_to_msecs(jiffies); |
3205 |
+- } |
3206 |
++ memset(rp, 0, sizeof (Sg_request)); |
3207 |
++ rp->parentfp = sfp; |
3208 |
++ rp->header.duration = jiffies_to_msecs(jiffies); |
3209 |
++ list_add_tail(&rp->entry, &sfp->rq_list); |
3210 |
+ write_unlock_irqrestore(&sfp->rq_list_lock, iflags); |
3211 |
+- return resp; |
3212 |
++ return rp; |
3213 |
++out_unlock: |
3214 |
++ write_unlock_irqrestore(&sfp->rq_list_lock, iflags); |
3215 |
++ return NULL; |
3216 |
+ } |
3217 |
+ |
3218 |
+ /* Return of 1 for found; 0 for not found */ |
3219 |
+ static int |
3220 |
+ sg_remove_request(Sg_fd * sfp, Sg_request * srp) |
3221 |
+ { |
3222 |
+- Sg_request *prev_rp; |
3223 |
+- Sg_request *rp; |
3224 |
+ unsigned long iflags; |
3225 |
+ int res = 0; |
3226 |
+ |
3227 |
+- if ((!sfp) || (!srp) || (!sfp->headrp)) |
3228 |
++ if (!sfp || !srp || list_empty(&sfp->rq_list)) |
3229 |
+ return res; |
3230 |
+ write_lock_irqsave(&sfp->rq_list_lock, iflags); |
3231 |
+- prev_rp = sfp->headrp; |
3232 |
+- if (srp == prev_rp) { |
3233 |
+- sfp->headrp = prev_rp->nextrp; |
3234 |
+- prev_rp->parentfp = NULL; |
3235 |
++ if (!list_empty(&srp->entry)) { |
3236 |
++ list_del(&srp->entry); |
3237 |
++ srp->parentfp = NULL; |
3238 |
+ res = 1; |
3239 |
+- } else { |
3240 |
+- while ((rp = prev_rp->nextrp)) { |
3241 |
+- if (srp == rp) { |
3242 |
+- prev_rp->nextrp = rp->nextrp; |
3243 |
+- rp->parentfp = NULL; |
3244 |
+- res = 1; |
3245 |
+- break; |
3246 |
+- } |
3247 |
+- prev_rp = rp; |
3248 |
+- } |
3249 |
+ } |
3250 |
+ write_unlock_irqrestore(&sfp->rq_list_lock, iflags); |
3251 |
+ return res; |
3252 |
+@@ -2162,7 +2142,7 @@ sg_add_sfp(Sg_device * sdp) |
3253 |
+ |
3254 |
+ init_waitqueue_head(&sfp->read_wait); |
3255 |
+ rwlock_init(&sfp->rq_list_lock); |
3256 |
+- |
3257 |
++ INIT_LIST_HEAD(&sfp->rq_list); |
3258 |
+ kref_init(&sfp->f_ref); |
3259 |
+ mutex_init(&sfp->f_mutex); |
3260 |
+ sfp->timeout = SG_DEFAULT_TIMEOUT; |
3261 |
+@@ -2203,10 +2183,13 @@ sg_remove_sfp_usercontext(struct work_struct *work) |
3262 |
+ { |
3263 |
+ struct sg_fd *sfp = container_of(work, struct sg_fd, ew.work); |
3264 |
+ struct sg_device *sdp = sfp->parentdp; |
3265 |
++ Sg_request *srp; |
3266 |
+ |
3267 |
+ /* Cleanup any responses which were never read(). */ |
3268 |
+- while (sfp->headrp) |
3269 |
+- sg_finish_rem_req(sfp->headrp); |
3270 |
++ while (!list_empty(&sfp->rq_list)) { |
3271 |
++ srp = list_first_entry(&sfp->rq_list, Sg_request, entry); |
3272 |
++ sg_finish_rem_req(srp); |
3273 |
++ } |
3274 |
+ |
3275 |
+ if (sfp->reserve.bufflen > 0) { |
3276 |
+ SCSI_LOG_TIMEOUT(6, sg_printk(KERN_INFO, sdp, |
3277 |
+@@ -2609,7 +2592,7 @@ static int sg_proc_seq_show_devstrs(struct seq_file *s, void *v) |
3278 |
+ /* must be called while holding sg_index_lock */ |
3279 |
+ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp) |
3280 |
+ { |
3281 |
+- int k, m, new_interface, blen, usg; |
3282 |
++ int k, new_interface, blen, usg; |
3283 |
+ Sg_request *srp; |
3284 |
+ Sg_fd *fp; |
3285 |
+ const sg_io_hdr_t *hp; |
3286 |
+@@ -2629,13 +2612,11 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp) |
3287 |
+ seq_printf(s, " cmd_q=%d f_packid=%d k_orphan=%d closed=0\n", |
3288 |
+ (int) fp->cmd_q, (int) fp->force_packid, |
3289 |
+ (int) fp->keep_orphan); |
3290 |
+- for (m = 0, srp = fp->headrp; |
3291 |
+- srp != NULL; |
3292 |
+- ++m, srp = srp->nextrp) { |
3293 |
++ list_for_each_entry(srp, &fp->rq_list, entry) { |
3294 |
+ hp = &srp->header; |
3295 |
+ new_interface = (hp->interface_id == '\0') ? 0 : 1; |
3296 |
+ if (srp->res_used) { |
3297 |
+- if (new_interface && |
3298 |
++ if (new_interface && |
3299 |
+ (SG_FLAG_MMAP_IO & hp->flags)) |
3300 |
+ cp = " mmap>> "; |
3301 |
+ else |
3302 |
+@@ -2666,7 +2647,7 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp) |
3303 |
+ seq_printf(s, "ms sgat=%d op=0x%02x\n", usg, |
3304 |
+ (int) srp->data.cmd_opcode); |
3305 |
+ } |
3306 |
+- if (0 == m) |
3307 |
++ if (list_empty(&fp->rq_list)) |
3308 |
+ seq_puts(s, " No requests active\n"); |
3309 |
+ read_unlock(&fp->rq_list_lock); |
3310 |
+ } |
3311 |
+diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c |
3312 |
+index c5ab1b0037fc..2bf96d33428a 100644 |
3313 |
+--- a/drivers/scsi/storvsc_drv.c |
3314 |
++++ b/drivers/scsi/storvsc_drv.c |
3315 |
+@@ -1559,6 +1559,8 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) |
3316 |
+ ret = storvsc_do_io(dev, cmd_request); |
3317 |
+ |
3318 |
+ if (ret == -EAGAIN) { |
3319 |
++ if (payload_sz > sizeof(cmd_request->mpb)) |
3320 |
++ kfree(payload); |
3321 |
+ /* no more space */ |
3322 |
+ return SCSI_MLQUEUE_DEVICE_BUSY; |
3323 |
+ } |
3324 |
+diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c |
3325 |
+index aa80dc94ddc2..c220c2c0893f 100644 |
3326 |
+--- a/drivers/tty/tty_buffer.c |
3327 |
++++ b/drivers/tty/tty_buffer.c |
3328 |
+@@ -361,6 +361,32 @@ int tty_insert_flip_string_flags(struct tty_port *port, |
3329 |
+ } |
3330 |
+ EXPORT_SYMBOL(tty_insert_flip_string_flags); |
3331 |
+ |
3332 |
++/** |
3333 |
++ * __tty_insert_flip_char - Add one character to the tty buffer |
3334 |
++ * @port: tty port |
3335 |
++ * @ch: character |
3336 |
++ * @flag: flag byte |
3337 |
++ * |
3338 |
++ * Queue a single byte to the tty buffering, with an optional flag. |
3339 |
++ * This is the slow path of tty_insert_flip_char. |
3340 |
++ */ |
3341 |
++int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag) |
3342 |
++{ |
3343 |
++ struct tty_buffer *tb; |
3344 |
++ int flags = (flag == TTY_NORMAL) ? TTYB_NORMAL : 0; |
3345 |
++ |
3346 |
++ if (!__tty_buffer_request_room(port, 1, flags)) |
3347 |
++ return 0; |
3348 |
++ |
3349 |
++ tb = port->buf.tail; |
3350 |
++ if (~tb->flags & TTYB_NORMAL) |
3351 |
++ *flag_buf_ptr(tb, tb->used) = flag; |
3352 |
++ *char_buf_ptr(tb, tb->used++) = ch; |
3353 |
++ |
3354 |
++ return 1; |
3355 |
++} |
3356 |
++EXPORT_SYMBOL(__tty_insert_flip_char); |
3357 |
++ |
3358 |
+ /** |
3359 |
+ * tty_schedule_flip - push characters to ldisc |
3360 |
+ * @port: tty port to push from |
3361 |
+diff --git a/fs/ext4/super.c b/fs/ext4/super.c |
3362 |
+index 5fa9ba1de429..f72535e1898f 100644 |
3363 |
+--- a/fs/ext4/super.c |
3364 |
++++ b/fs/ext4/super.c |
3365 |
+@@ -2334,6 +2334,7 @@ static void ext4_orphan_cleanup(struct super_block *sb, |
3366 |
+ unsigned int s_flags = sb->s_flags; |
3367 |
+ int nr_orphans = 0, nr_truncates = 0; |
3368 |
+ #ifdef CONFIG_QUOTA |
3369 |
++ int quota_update = 0; |
3370 |
+ int i; |
3371 |
+ #endif |
3372 |
+ if (!es->s_last_orphan) { |
3373 |
+@@ -2372,14 +2373,32 @@ static void ext4_orphan_cleanup(struct super_block *sb, |
3374 |
+ #ifdef CONFIG_QUOTA |
3375 |
+ /* Needed for iput() to work correctly and not trash data */ |
3376 |
+ sb->s_flags |= MS_ACTIVE; |
3377 |
+- /* Turn on quotas so that they are updated correctly */ |
3378 |
++ |
3379 |
++ /* |
3380 |
++ * Turn on quotas which were not enabled for read-only mounts if |
3381 |
++ * filesystem has quota feature, so that they are updated correctly. |
3382 |
++ */ |
3383 |
++ if (ext4_has_feature_quota(sb) && (s_flags & MS_RDONLY)) { |
3384 |
++ int ret = ext4_enable_quotas(sb); |
3385 |
++ |
3386 |
++ if (!ret) |
3387 |
++ quota_update = 1; |
3388 |
++ else |
3389 |
++ ext4_msg(sb, KERN_ERR, |
3390 |
++ "Cannot turn on quotas: error %d", ret); |
3391 |
++ } |
3392 |
++ |
3393 |
++ /* Turn on journaled quotas used for old sytle */ |
3394 |
+ for (i = 0; i < EXT4_MAXQUOTAS; i++) { |
3395 |
+ if (EXT4_SB(sb)->s_qf_names[i]) { |
3396 |
+ int ret = ext4_quota_on_mount(sb, i); |
3397 |
+- if (ret < 0) |
3398 |
++ |
3399 |
++ if (!ret) |
3400 |
++ quota_update = 1; |
3401 |
++ else |
3402 |
+ ext4_msg(sb, KERN_ERR, |
3403 |
+ "Cannot turn on journaled " |
3404 |
+- "quota: error %d", ret); |
3405 |
++ "quota: type %d: error %d", i, ret); |
3406 |
+ } |
3407 |
+ } |
3408 |
+ #endif |
3409 |
+@@ -2438,10 +2457,12 @@ static void ext4_orphan_cleanup(struct super_block *sb, |
3410 |
+ ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up", |
3411 |
+ PLURAL(nr_truncates)); |
3412 |
+ #ifdef CONFIG_QUOTA |
3413 |
+- /* Turn quotas off */ |
3414 |
+- for (i = 0; i < EXT4_MAXQUOTAS; i++) { |
3415 |
+- if (sb_dqopt(sb)->files[i]) |
3416 |
+- dquot_quota_off(sb, i); |
3417 |
++ /* Turn off quotas if they were enabled for orphan cleanup */ |
3418 |
++ if (quota_update) { |
3419 |
++ for (i = 0; i < EXT4_MAXQUOTAS; i++) { |
3420 |
++ if (sb_dqopt(sb)->files[i]) |
3421 |
++ dquot_quota_off(sb, i); |
3422 |
++ } |
3423 |
+ } |
3424 |
+ #endif |
3425 |
+ sb->s_flags = s_flags; /* Restore MS_RDONLY status */ |
3426 |
+@@ -5365,6 +5386,9 @@ static int ext4_enable_quotas(struct super_block *sb) |
3427 |
+ DQUOT_USAGE_ENABLED | |
3428 |
+ (quota_mopt[type] ? DQUOT_LIMITS_ENABLED : 0)); |
3429 |
+ if (err) { |
3430 |
++ for (type--; type >= 0; type--) |
3431 |
++ dquot_quota_off(sb, type); |
3432 |
++ |
3433 |
+ ext4_warning(sb, |
3434 |
+ "Failed to enable quota tracking " |
3435 |
+ "(type=%d, err=%d). Please run " |
3436 |
+diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c |
3437 |
+index 0a2115084c3f..582bfee40345 100644 |
3438 |
+--- a/fs/nfs/callback.c |
3439 |
++++ b/fs/nfs/callback.c |
3440 |
+@@ -75,7 +75,10 @@ nfs4_callback_svc(void *vrqstp) |
3441 |
+ |
3442 |
+ set_freezable(); |
3443 |
+ |
3444 |
+- while (!kthread_should_stop()) { |
3445 |
++ while (!kthread_freezable_should_stop(NULL)) { |
3446 |
++ |
3447 |
++ if (signal_pending(current)) |
3448 |
++ flush_signals(current); |
3449 |
+ /* |
3450 |
+ * Listen for a request on the socket |
3451 |
+ */ |
3452 |
+@@ -84,6 +87,8 @@ nfs4_callback_svc(void *vrqstp) |
3453 |
+ continue; |
3454 |
+ svc_process(rqstp); |
3455 |
+ } |
3456 |
++ svc_exit_thread(rqstp); |
3457 |
++ module_put_and_exit(0); |
3458 |
+ return 0; |
3459 |
+ } |
3460 |
+ |
3461 |
+@@ -102,9 +107,10 @@ nfs41_callback_svc(void *vrqstp) |
3462 |
+ |
3463 |
+ set_freezable(); |
3464 |
+ |
3465 |
+- while (!kthread_should_stop()) { |
3466 |
+- if (try_to_freeze()) |
3467 |
+- continue; |
3468 |
++ while (!kthread_freezable_should_stop(NULL)) { |
3469 |
++ |
3470 |
++ if (signal_pending(current)) |
3471 |
++ flush_signals(current); |
3472 |
+ |
3473 |
+ prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE); |
3474 |
+ spin_lock_bh(&serv->sv_cb_lock); |
3475 |
+@@ -120,11 +126,13 @@ nfs41_callback_svc(void *vrqstp) |
3476 |
+ error); |
3477 |
+ } else { |
3478 |
+ spin_unlock_bh(&serv->sv_cb_lock); |
3479 |
+- schedule(); |
3480 |
++ if (!kthread_should_stop()) |
3481 |
++ schedule(); |
3482 |
+ finish_wait(&serv->sv_cb_waitq, &wq); |
3483 |
+ } |
3484 |
+- flush_signals(current); |
3485 |
+ } |
3486 |
++ svc_exit_thread(rqstp); |
3487 |
++ module_put_and_exit(0); |
3488 |
+ return 0; |
3489 |
+ } |
3490 |
+ |
3491 |
+@@ -220,14 +228,14 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv, |
3492 |
+ static struct svc_serv_ops nfs40_cb_sv_ops = { |
3493 |
+ .svo_function = nfs4_callback_svc, |
3494 |
+ .svo_enqueue_xprt = svc_xprt_do_enqueue, |
3495 |
+- .svo_setup = svc_set_num_threads, |
3496 |
++ .svo_setup = svc_set_num_threads_sync, |
3497 |
+ .svo_module = THIS_MODULE, |
3498 |
+ }; |
3499 |
+ #if defined(CONFIG_NFS_V4_1) |
3500 |
+ static struct svc_serv_ops nfs41_cb_sv_ops = { |
3501 |
+ .svo_function = nfs41_callback_svc, |
3502 |
+ .svo_enqueue_xprt = svc_xprt_do_enqueue, |
3503 |
+- .svo_setup = svc_set_num_threads, |
3504 |
++ .svo_setup = svc_set_num_threads_sync, |
3505 |
+ .svo_module = THIS_MODULE, |
3506 |
+ }; |
3507 |
+ |
3508 |
+diff --git a/fs/orangefs/acl.c b/fs/orangefs/acl.c |
3509 |
+index 7a3754488312..9409aac232f7 100644 |
3510 |
+--- a/fs/orangefs/acl.c |
3511 |
++++ b/fs/orangefs/acl.c |
3512 |
+@@ -61,9 +61,9 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type) |
3513 |
+ return acl; |
3514 |
+ } |
3515 |
+ |
3516 |
+-int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) |
3517 |
++static int __orangefs_set_acl(struct inode *inode, struct posix_acl *acl, |
3518 |
++ int type) |
3519 |
+ { |
3520 |
+- struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); |
3521 |
+ int error = 0; |
3522 |
+ void *value = NULL; |
3523 |
+ size_t size = 0; |
3524 |
+@@ -72,22 +72,6 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) |
3525 |
+ switch (type) { |
3526 |
+ case ACL_TYPE_ACCESS: |
3527 |
+ name = XATTR_NAME_POSIX_ACL_ACCESS; |
3528 |
+- if (acl) { |
3529 |
+- umode_t mode; |
3530 |
+- |
3531 |
+- error = posix_acl_update_mode(inode, &mode, &acl); |
3532 |
+- if (error) { |
3533 |
+- gossip_err("%s: posix_acl_update_mode err: %d\n", |
3534 |
+- __func__, |
3535 |
+- error); |
3536 |
+- return error; |
3537 |
+- } |
3538 |
+- |
3539 |
+- if (inode->i_mode != mode) |
3540 |
+- SetModeFlag(orangefs_inode); |
3541 |
+- inode->i_mode = mode; |
3542 |
+- mark_inode_dirty_sync(inode); |
3543 |
+- } |
3544 |
+ break; |
3545 |
+ case ACL_TYPE_DEFAULT: |
3546 |
+ name = XATTR_NAME_POSIX_ACL_DEFAULT; |
3547 |
+@@ -132,6 +116,29 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) |
3548 |
+ return error; |
3549 |
+ } |
3550 |
+ |
3551 |
++int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) |
3552 |
++{ |
3553 |
++ int error; |
3554 |
++ |
3555 |
++ if (type == ACL_TYPE_ACCESS && acl) { |
3556 |
++ umode_t mode; |
3557 |
++ |
3558 |
++ error = posix_acl_update_mode(inode, &mode, &acl); |
3559 |
++ if (error) { |
3560 |
++ gossip_err("%s: posix_acl_update_mode err: %d\n", |
3561 |
++ __func__, |
3562 |
++ error); |
3563 |
++ return error; |
3564 |
++ } |
3565 |
++ |
3566 |
++ if (inode->i_mode != mode) |
3567 |
++ SetModeFlag(ORANGEFS_I(inode)); |
3568 |
++ inode->i_mode = mode; |
3569 |
++ mark_inode_dirty_sync(inode); |
3570 |
++ } |
3571 |
++ return __orangefs_set_acl(inode, acl, type); |
3572 |
++} |
3573 |
++ |
3574 |
+ int orangefs_init_acl(struct inode *inode, struct inode *dir) |
3575 |
+ { |
3576 |
+ struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); |
3577 |
+@@ -146,13 +153,14 @@ int orangefs_init_acl(struct inode *inode, struct inode *dir) |
3578 |
+ return error; |
3579 |
+ |
3580 |
+ if (default_acl) { |
3581 |
+- error = orangefs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); |
3582 |
++ error = __orangefs_set_acl(inode, default_acl, |
3583 |
++ ACL_TYPE_DEFAULT); |
3584 |
+ posix_acl_release(default_acl); |
3585 |
+ } |
3586 |
+ |
3587 |
+ if (acl) { |
3588 |
+ if (!error) |
3589 |
+- error = orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS); |
3590 |
++ error = __orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS); |
3591 |
+ posix_acl_release(acl); |
3592 |
+ } |
3593 |
+ |
3594 |
+diff --git a/include/linux/ccp.h b/include/linux/ccp.h |
3595 |
+index edc5d04b9632..1cfe5ef3060b 100644 |
3596 |
+--- a/include/linux/ccp.h |
3597 |
++++ b/include/linux/ccp.h |
3598 |
+@@ -1,7 +1,7 @@ |
3599 |
+ /* |
3600 |
+ * AMD Cryptographic Coprocessor (CCP) driver |
3601 |
+ * |
3602 |
+- * Copyright (C) 2013,2016 Advanced Micro Devices, Inc. |
3603 |
++ * Copyright (C) 2013,2017 Advanced Micro Devices, Inc. |
3604 |
+ * |
3605 |
+ * Author: Tom Lendacky <thomas.lendacky@×××.com> |
3606 |
+ * Author: Gary R Hook <gary.hook@×××.com> |
3607 |
+@@ -222,6 +222,7 @@ enum ccp_xts_aes_unit_size { |
3608 |
+ * AES operation the new IV overwrites the old IV. |
3609 |
+ */ |
3610 |
+ struct ccp_xts_aes_engine { |
3611 |
++ enum ccp_aes_type type; |
3612 |
+ enum ccp_aes_action action; |
3613 |
+ enum ccp_xts_aes_unit_size unit_size; |
3614 |
+ |
3615 |
+diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h |
3616 |
+index 7321ae933867..102c84dcc11a 100644 |
3617 |
+--- a/include/linux/sunrpc/svc.h |
3618 |
++++ b/include/linux/sunrpc/svc.h |
3619 |
+@@ -470,6 +470,7 @@ void svc_pool_map_put(void); |
3620 |
+ struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, |
3621 |
+ struct svc_serv_ops *); |
3622 |
+ int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); |
3623 |
++int svc_set_num_threads_sync(struct svc_serv *, struct svc_pool *, int); |
3624 |
+ int svc_pool_stats_open(struct svc_serv *serv, struct file *file); |
3625 |
+ void svc_destroy(struct svc_serv *); |
3626 |
+ void svc_shutdown_net(struct svc_serv *, struct net *); |
3627 |
+diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h |
3628 |
+index c28dd523f96e..d43837f2ce3a 100644 |
3629 |
+--- a/include/linux/tty_flip.h |
3630 |
++++ b/include/linux/tty_flip.h |
3631 |
+@@ -12,6 +12,7 @@ extern int tty_prepare_flip_string(struct tty_port *port, |
3632 |
+ unsigned char **chars, size_t size); |
3633 |
+ extern void tty_flip_buffer_push(struct tty_port *port); |
3634 |
+ void tty_schedule_flip(struct tty_port *port); |
3635 |
++int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag); |
3636 |
+ |
3637 |
+ static inline int tty_insert_flip_char(struct tty_port *port, |
3638 |
+ unsigned char ch, char flag) |
3639 |
+@@ -26,7 +27,7 @@ static inline int tty_insert_flip_char(struct tty_port *port, |
3640 |
+ *char_buf_ptr(tb, tb->used++) = ch; |
3641 |
+ return 1; |
3642 |
+ } |
3643 |
+- return tty_insert_flip_string_flags(port, &ch, &flag, 1); |
3644 |
++ return __tty_insert_flip_char(port, ch, flag); |
3645 |
+ } |
3646 |
+ |
3647 |
+ static inline int tty_insert_flip_string(struct tty_port *port, |
3648 |
+diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c |
3649 |
+index 6e432ed7d0fe..53ed8ae5de1c 100644 |
3650 |
+--- a/kernel/trace/ftrace.c |
3651 |
++++ b/kernel/trace/ftrace.c |
3652 |
+@@ -2747,13 +2747,14 @@ static int ftrace_shutdown(struct ftrace_ops *ops, int command) |
3653 |
+ |
3654 |
+ if (!command || !ftrace_enabled) { |
3655 |
+ /* |
3656 |
+- * If these are per_cpu ops, they still need their |
3657 |
+- * per_cpu field freed. Since, function tracing is |
3658 |
++ * If these are dynamic or per_cpu ops, they still |
3659 |
++ * need their data freed. Since, function tracing is |
3660 |
+ * not currently active, we can just free them |
3661 |
+ * without synchronizing all CPUs. |
3662 |
+ */ |
3663 |
+- if (ops->flags & FTRACE_OPS_FL_PER_CPU) |
3664 |
+- per_cpu_ops_free(ops); |
3665 |
++ if (ops->flags & (FTRACE_OPS_FL_DYNAMIC | FTRACE_OPS_FL_PER_CPU)) |
3666 |
++ goto free_ops; |
3667 |
++ |
3668 |
+ return 0; |
3669 |
+ } |
3670 |
+ |
3671 |
+@@ -2808,6 +2809,7 @@ static int ftrace_shutdown(struct ftrace_ops *ops, int command) |
3672 |
+ if (ops->flags & (FTRACE_OPS_FL_DYNAMIC | FTRACE_OPS_FL_PER_CPU)) { |
3673 |
+ schedule_on_each_cpu(ftrace_sync); |
3674 |
+ |
3675 |
++ free_ops: |
3676 |
+ arch_ftrace_trampoline_free(ops); |
3677 |
+ |
3678 |
+ if (ops->flags & FTRACE_OPS_FL_PER_CPU) |
3679 |
+diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c |
3680 |
+index 7379f735a9f4..f95bf81529f5 100644 |
3681 |
+--- a/kernel/trace/trace.c |
3682 |
++++ b/kernel/trace/trace.c |
3683 |
+@@ -2369,11 +2369,17 @@ static char *get_trace_buf(void) |
3684 |
+ if (!buffer || buffer->nesting >= 4) |
3685 |
+ return NULL; |
3686 |
+ |
3687 |
+- return &buffer->buffer[buffer->nesting++][0]; |
3688 |
++ buffer->nesting++; |
3689 |
++ |
3690 |
++ /* Interrupts must see nesting incremented before we use the buffer */ |
3691 |
++ barrier(); |
3692 |
++ return &buffer->buffer[buffer->nesting][0]; |
3693 |
+ } |
3694 |
+ |
3695 |
+ static void put_trace_buf(void) |
3696 |
+ { |
3697 |
++ /* Don't let the decrement of nesting leak before this */ |
3698 |
++ barrier(); |
3699 |
+ this_cpu_dec(trace_percpu_buffer->nesting); |
3700 |
+ } |
3701 |
+ |
3702 |
+@@ -5658,7 +5664,7 @@ static int tracing_set_clock(struct trace_array *tr, const char *clockstr) |
3703 |
+ tracing_reset_online_cpus(&tr->trace_buffer); |
3704 |
+ |
3705 |
+ #ifdef CONFIG_TRACER_MAX_TRACE |
3706 |
+- if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer) |
3707 |
++ if (tr->max_buffer.buffer) |
3708 |
+ ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func); |
3709 |
+ tracing_reset_online_cpus(&tr->max_buffer); |
3710 |
+ #endif |
3711 |
+diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c |
3712 |
+index b0f86ea77881..ca70d11b8aa7 100644 |
3713 |
+--- a/kernel/trace/trace_selftest.c |
3714 |
++++ b/kernel/trace/trace_selftest.c |
3715 |
+@@ -272,7 +272,7 @@ static int trace_selftest_ops(struct trace_array *tr, int cnt) |
3716 |
+ goto out_free; |
3717 |
+ if (cnt > 1) { |
3718 |
+ if (trace_selftest_test_global_cnt == 0) |
3719 |
+- goto out; |
3720 |
++ goto out_free; |
3721 |
+ } |
3722 |
+ if (trace_selftest_test_dyn_cnt == 0) |
3723 |
+ goto out_free; |
3724 |
+diff --git a/mm/page_alloc.c b/mm/page_alloc.c |
3725 |
+index 2abf8d5f0ad4..7064aae8ded7 100644 |
3726 |
+--- a/mm/page_alloc.c |
3727 |
++++ b/mm/page_alloc.c |
3728 |
+@@ -2100,13 +2100,25 @@ static void unreserve_highatomic_pageblock(const struct alloc_context *ac) |
3729 |
+ continue; |
3730 |
+ |
3731 |
+ /* |
3732 |
+- * It should never happen but changes to locking could |
3733 |
+- * inadvertently allow a per-cpu drain to add pages |
3734 |
+- * to MIGRATE_HIGHATOMIC while unreserving so be safe |
3735 |
+- * and watch for underflows. |
3736 |
++ * In page freeing path, migratetype change is racy so |
3737 |
++ * we can counter several free pages in a pageblock |
3738 |
++ * in this loop althoug we changed the pageblock type |
3739 |
++ * from highatomic to ac->migratetype. So we should |
3740 |
++ * adjust the count once. |
3741 |
+ */ |
3742 |
+- zone->nr_reserved_highatomic -= min(pageblock_nr_pages, |
3743 |
+- zone->nr_reserved_highatomic); |
3744 |
++ if (get_pageblock_migratetype(page) == |
3745 |
++ MIGRATE_HIGHATOMIC) { |
3746 |
++ /* |
3747 |
++ * It should never happen but changes to |
3748 |
++ * locking could inadvertently allow a per-cpu |
3749 |
++ * drain to add pages to MIGRATE_HIGHATOMIC |
3750 |
++ * while unreserving so be safe and watch for |
3751 |
++ * underflows. |
3752 |
++ */ |
3753 |
++ zone->nr_reserved_highatomic -= min( |
3754 |
++ pageblock_nr_pages, |
3755 |
++ zone->nr_reserved_highatomic); |
3756 |
++ } |
3757 |
+ |
3758 |
+ /* |
3759 |
+ * Convert to ac->migratetype and avoid the normal |
3760 |
+diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c |
3761 |
+index 6bd150882ba4..ed9ce7c63252 100644 |
3762 |
+--- a/net/netfilter/nf_conntrack_core.c |
3763 |
++++ b/net/netfilter/nf_conntrack_core.c |
3764 |
+@@ -95,19 +95,26 @@ static struct conntrack_gc_work conntrack_gc_work; |
3765 |
+ |
3766 |
+ void nf_conntrack_lock(spinlock_t *lock) __acquires(lock) |
3767 |
+ { |
3768 |
++ /* 1) Acquire the lock */ |
3769 |
+ spin_lock(lock); |
3770 |
+- while (unlikely(nf_conntrack_locks_all)) { |
3771 |
+- spin_unlock(lock); |
3772 |
+ |
3773 |
+- /* |
3774 |
+- * Order the 'nf_conntrack_locks_all' load vs. the |
3775 |
+- * spin_unlock_wait() loads below, to ensure |
3776 |
+- * that 'nf_conntrack_locks_all_lock' is indeed held: |
3777 |
+- */ |
3778 |
+- smp_rmb(); /* spin_lock(&nf_conntrack_locks_all_lock) */ |
3779 |
+- spin_unlock_wait(&nf_conntrack_locks_all_lock); |
3780 |
+- spin_lock(lock); |
3781 |
+- } |
3782 |
++ /* 2) read nf_conntrack_locks_all, with ACQUIRE semantics |
3783 |
++ * It pairs with the smp_store_release() in nf_conntrack_all_unlock() |
3784 |
++ */ |
3785 |
++ if (likely(smp_load_acquire(&nf_conntrack_locks_all) == false)) |
3786 |
++ return; |
3787 |
++ |
3788 |
++ /* fast path failed, unlock */ |
3789 |
++ spin_unlock(lock); |
3790 |
++ |
3791 |
++ /* Slow path 1) get global lock */ |
3792 |
++ spin_lock(&nf_conntrack_locks_all_lock); |
3793 |
++ |
3794 |
++ /* Slow path 2) get the lock we want */ |
3795 |
++ spin_lock(lock); |
3796 |
++ |
3797 |
++ /* Slow path 3) release the global lock */ |
3798 |
++ spin_unlock(&nf_conntrack_locks_all_lock); |
3799 |
+ } |
3800 |
+ EXPORT_SYMBOL_GPL(nf_conntrack_lock); |
3801 |
+ |
3802 |
+@@ -148,28 +155,27 @@ static void nf_conntrack_all_lock(void) |
3803 |
+ int i; |
3804 |
+ |
3805 |
+ spin_lock(&nf_conntrack_locks_all_lock); |
3806 |
+- nf_conntrack_locks_all = true; |
3807 |
+ |
3808 |
+- /* |
3809 |
+- * Order the above store of 'nf_conntrack_locks_all' against |
3810 |
+- * the spin_unlock_wait() loads below, such that if |
3811 |
+- * nf_conntrack_lock() observes 'nf_conntrack_locks_all' |
3812 |
+- * we must observe nf_conntrack_locks[] held: |
3813 |
+- */ |
3814 |
+- smp_mb(); /* spin_lock(&nf_conntrack_locks_all_lock) */ |
3815 |
++ nf_conntrack_locks_all = true; |
3816 |
+ |
3817 |
+ for (i = 0; i < CONNTRACK_LOCKS; i++) { |
3818 |
+- spin_unlock_wait(&nf_conntrack_locks[i]); |
3819 |
++ spin_lock(&nf_conntrack_locks[i]); |
3820 |
++ |
3821 |
++ /* This spin_unlock provides the "release" to ensure that |
3822 |
++ * nf_conntrack_locks_all==true is visible to everyone that |
3823 |
++ * acquired spin_lock(&nf_conntrack_locks[]). |
3824 |
++ */ |
3825 |
++ spin_unlock(&nf_conntrack_locks[i]); |
3826 |
+ } |
3827 |
+ } |
3828 |
+ |
3829 |
+ static void nf_conntrack_all_unlock(void) |
3830 |
+ { |
3831 |
+- /* |
3832 |
+- * All prior stores must be complete before we clear |
3833 |
++ /* All prior stores must be complete before we clear |
3834 |
+ * 'nf_conntrack_locks_all'. Otherwise nf_conntrack_lock() |
3835 |
+ * might observe the false value but not the entire |
3836 |
+- * critical section: |
3837 |
++ * critical section. |
3838 |
++ * It pairs with the smp_load_acquire() in nf_conntrack_lock() |
3839 |
+ */ |
3840 |
+ smp_store_release(&nf_conntrack_locks_all, false); |
3841 |
+ spin_unlock(&nf_conntrack_locks_all_lock); |
3842 |
+diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c |
3843 |
+index 75f290bddca1..272c34551979 100644 |
3844 |
+--- a/net/sunrpc/svc.c |
3845 |
++++ b/net/sunrpc/svc.c |
3846 |
+@@ -702,59 +702,32 @@ choose_victim(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state) |
3847 |
+ return task; |
3848 |
+ } |
3849 |
+ |
3850 |
+-/* |
3851 |
+- * Create or destroy enough new threads to make the number |
3852 |
+- * of threads the given number. If `pool' is non-NULL, applies |
3853 |
+- * only to threads in that pool, otherwise round-robins between |
3854 |
+- * all pools. Caller must ensure that mutual exclusion between this and |
3855 |
+- * server startup or shutdown. |
3856 |
+- * |
3857 |
+- * Destroying threads relies on the service threads filling in |
3858 |
+- * rqstp->rq_task, which only the nfs ones do. Assumes the serv |
3859 |
+- * has been created using svc_create_pooled(). |
3860 |
+- * |
3861 |
+- * Based on code that used to be in nfsd_svc() but tweaked |
3862 |
+- * to be pool-aware. |
3863 |
+- */ |
3864 |
+-int |
3865 |
+-svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) |
3866 |
++/* create new threads */ |
3867 |
++static int |
3868 |
++svc_start_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) |
3869 |
+ { |
3870 |
+ struct svc_rqst *rqstp; |
3871 |
+ struct task_struct *task; |
3872 |
+ struct svc_pool *chosen_pool; |
3873 |
+- int error = 0; |
3874 |
+ unsigned int state = serv->sv_nrthreads-1; |
3875 |
+ int node; |
3876 |
+ |
3877 |
+- if (pool == NULL) { |
3878 |
+- /* The -1 assumes caller has done a svc_get() */ |
3879 |
+- nrservs -= (serv->sv_nrthreads-1); |
3880 |
+- } else { |
3881 |
+- spin_lock_bh(&pool->sp_lock); |
3882 |
+- nrservs -= pool->sp_nrthreads; |
3883 |
+- spin_unlock_bh(&pool->sp_lock); |
3884 |
+- } |
3885 |
+- |
3886 |
+- /* create new threads */ |
3887 |
+- while (nrservs > 0) { |
3888 |
++ do { |
3889 |
+ nrservs--; |
3890 |
+ chosen_pool = choose_pool(serv, pool, &state); |
3891 |
+ |
3892 |
+ node = svc_pool_map_get_node(chosen_pool->sp_id); |
3893 |
+ rqstp = svc_prepare_thread(serv, chosen_pool, node); |
3894 |
+- if (IS_ERR(rqstp)) { |
3895 |
+- error = PTR_ERR(rqstp); |
3896 |
+- break; |
3897 |
+- } |
3898 |
++ if (IS_ERR(rqstp)) |
3899 |
++ return PTR_ERR(rqstp); |
3900 |
+ |
3901 |
+ __module_get(serv->sv_ops->svo_module); |
3902 |
+ task = kthread_create_on_node(serv->sv_ops->svo_function, rqstp, |
3903 |
+ node, "%s", serv->sv_name); |
3904 |
+ if (IS_ERR(task)) { |
3905 |
+- error = PTR_ERR(task); |
3906 |
+ module_put(serv->sv_ops->svo_module); |
3907 |
+ svc_exit_thread(rqstp); |
3908 |
+- break; |
3909 |
++ return PTR_ERR(task); |
3910 |
+ } |
3911 |
+ |
3912 |
+ rqstp->rq_task = task; |
3913 |
+@@ -763,18 +736,103 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) |
3914 |
+ |
3915 |
+ svc_sock_update_bufs(serv); |
3916 |
+ wake_up_process(task); |
3917 |
+- } |
3918 |
++ } while (nrservs > 0); |
3919 |
++ |
3920 |
++ return 0; |
3921 |
++} |
3922 |
++ |
3923 |
++ |
3924 |
++/* destroy old threads */ |
3925 |
++static int |
3926 |
++svc_signal_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) |
3927 |
++{ |
3928 |
++ struct task_struct *task; |
3929 |
++ unsigned int state = serv->sv_nrthreads-1; |
3930 |
++ |
3931 |
+ /* destroy old threads */ |
3932 |
+- while (nrservs < 0 && |
3933 |
+- (task = choose_victim(serv, pool, &state)) != NULL) { |
3934 |
++ do { |
3935 |
++ task = choose_victim(serv, pool, &state); |
3936 |
++ if (task == NULL) |
3937 |
++ break; |
3938 |
+ send_sig(SIGINT, task, 1); |
3939 |
+ nrservs++; |
3940 |
++ } while (nrservs < 0); |
3941 |
++ |
3942 |
++ return 0; |
3943 |
++} |
3944 |
++ |
3945 |
++/* |
3946 |
++ * Create or destroy enough new threads to make the number |
3947 |
++ * of threads the given number. If `pool' is non-NULL, applies |
3948 |
++ * only to threads in that pool, otherwise round-robins between |
3949 |
++ * all pools. Caller must ensure that mutual exclusion between this and |
3950 |
++ * server startup or shutdown. |
3951 |
++ * |
3952 |
++ * Destroying threads relies on the service threads filling in |
3953 |
++ * rqstp->rq_task, which only the nfs ones do. Assumes the serv |
3954 |
++ * has been created using svc_create_pooled(). |
3955 |
++ * |
3956 |
++ * Based on code that used to be in nfsd_svc() but tweaked |
3957 |
++ * to be pool-aware. |
3958 |
++ */ |
3959 |
++int |
3960 |
++svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) |
3961 |
++{ |
3962 |
++ if (pool == NULL) { |
3963 |
++ /* The -1 assumes caller has done a svc_get() */ |
3964 |
++ nrservs -= (serv->sv_nrthreads-1); |
3965 |
++ } else { |
3966 |
++ spin_lock_bh(&pool->sp_lock); |
3967 |
++ nrservs -= pool->sp_nrthreads; |
3968 |
++ spin_unlock_bh(&pool->sp_lock); |
3969 |
+ } |
3970 |
+ |
3971 |
+- return error; |
3972 |
++ if (nrservs > 0) |
3973 |
++ return svc_start_kthreads(serv, pool, nrservs); |
3974 |
++ if (nrservs < 0) |
3975 |
++ return svc_signal_kthreads(serv, pool, nrservs); |
3976 |
++ return 0; |
3977 |
+ } |
3978 |
+ EXPORT_SYMBOL_GPL(svc_set_num_threads); |
3979 |
+ |
3980 |
++/* destroy old threads */ |
3981 |
++static int |
3982 |
++svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) |
3983 |
++{ |
3984 |
++ struct task_struct *task; |
3985 |
++ unsigned int state = serv->sv_nrthreads-1; |
3986 |
++ |
3987 |
++ /* destroy old threads */ |
3988 |
++ do { |
3989 |
++ task = choose_victim(serv, pool, &state); |
3990 |
++ if (task == NULL) |
3991 |
++ break; |
3992 |
++ kthread_stop(task); |
3993 |
++ nrservs++; |
3994 |
++ } while (nrservs < 0); |
3995 |
++ return 0; |
3996 |
++} |
3997 |
++ |
3998 |
++int |
3999 |
++svc_set_num_threads_sync(struct svc_serv *serv, struct svc_pool *pool, int nrservs) |
4000 |
++{ |
4001 |
++ if (pool == NULL) { |
4002 |
++ /* The -1 assumes caller has done a svc_get() */ |
4003 |
++ nrservs -= (serv->sv_nrthreads-1); |
4004 |
++ } else { |
4005 |
++ spin_lock_bh(&pool->sp_lock); |
4006 |
++ nrservs -= pool->sp_nrthreads; |
4007 |
++ spin_unlock_bh(&pool->sp_lock); |
4008 |
++ } |
4009 |
++ |
4010 |
++ if (nrservs > 0) |
4011 |
++ return svc_start_kthreads(serv, pool, nrservs); |
4012 |
++ if (nrservs < 0) |
4013 |
++ return svc_stop_kthreads(serv, pool, nrservs); |
4014 |
++ return 0; |
4015 |
++} |
4016 |
++EXPORT_SYMBOL_GPL(svc_set_num_threads_sync); |
4017 |
++ |
4018 |
+ /* |
4019 |
+ * Called from a server thread as it's exiting. Caller must hold the "service |
4020 |
+ * mutex" for the service. |