Magellan Linux

Contents of /trunk/kernel-alx-legacy/patches-4.9/0361-4.9.262-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3663 - (show annotations) (download)
Mon Oct 24 14:07:40 2022 UTC (19 months ago) by niro
File size: 97676 byte(s)
-linux-4.9.262
1 diff --git a/Makefile b/Makefile
2 index 7a233c641906c..be5eac0a12d37 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 4
7 PATCHLEVEL = 9
8 -SUBLEVEL = 261
9 +SUBLEVEL = 262
10 EXTRAVERSION =
11 NAME = Roaring Lionus
12
13 diff --git a/arch/alpha/include/asm/uaccess.h b/arch/alpha/include/asm/uaccess.h
14 index 94f587535deed..181254a20a2a2 100644
15 --- a/arch/alpha/include/asm/uaccess.h
16 +++ b/arch/alpha/include/asm/uaccess.h
17 @@ -341,45 +341,17 @@ __asm__ __volatile__("1: stb %r2,%1\n" \
18 * Complex access routines
19 */
20
21 -/* This little bit of silliness is to get the GP loaded for a function
22 - that ordinarily wouldn't. Otherwise we could have it done by the macro
23 - directly, which can be optimized the linker. */
24 -#ifdef MODULE
25 -#define __module_address(sym) "r"(sym),
26 -#define __module_call(ra, arg, sym) "jsr $" #ra ",(%" #arg ")," #sym
27 -#else
28 -#define __module_address(sym)
29 -#define __module_call(ra, arg, sym) "bsr $" #ra "," #sym " !samegp"
30 -#endif
31 -
32 -extern void __copy_user(void);
33 -
34 -extern inline long
35 -__copy_tofrom_user_nocheck(void *to, const void *from, long len)
36 -{
37 - register void * __cu_to __asm__("$6") = to;
38 - register const void * __cu_from __asm__("$7") = from;
39 - register long __cu_len __asm__("$0") = len;
40 -
41 - __asm__ __volatile__(
42 - __module_call(28, 3, __copy_user)
43 - : "=r" (__cu_len), "=r" (__cu_from), "=r" (__cu_to)
44 - : __module_address(__copy_user)
45 - "0" (__cu_len), "1" (__cu_from), "2" (__cu_to)
46 - : "$1", "$2", "$3", "$4", "$5", "$28", "memory");
47 -
48 - return __cu_len;
49 -}
50 +extern long __copy_user(void *to, const void *from, long len);
51
52 -#define __copy_to_user(to, from, n) \
53 -({ \
54 - __chk_user_ptr(to); \
55 - __copy_tofrom_user_nocheck((__force void *)(to), (from), (n)); \
56 +#define __copy_to_user(to, from, n) \
57 +({ \
58 + __chk_user_ptr(to); \
59 + __copy_user((__force void *)(to), (from), (n)); \
60 })
61 -#define __copy_from_user(to, from, n) \
62 -({ \
63 - __chk_user_ptr(from); \
64 - __copy_tofrom_user_nocheck((to), (__force void *)(from), (n)); \
65 +#define __copy_from_user(to, from, n) \
66 +({ \
67 + __chk_user_ptr(from); \
68 + __copy_user((to), (__force void *)(from), (n)); \
69 })
70
71 #define __copy_to_user_inatomic __copy_to_user
72 @@ -389,7 +361,7 @@ extern inline long
73 copy_to_user(void __user *to, const void *from, long n)
74 {
75 if (likely(__access_ok((unsigned long)to, n, get_fs())))
76 - n = __copy_tofrom_user_nocheck((__force void *)to, from, n);
77 + n = __copy_user((__force void *)to, from, n);
78 return n;
79 }
80
81 @@ -404,21 +376,7 @@ copy_from_user(void *to, const void __user *from, long n)
82 return res;
83 }
84
85 -extern void __do_clear_user(void);
86 -
87 -extern inline long
88 -__clear_user(void __user *to, long len)
89 -{
90 - register void __user * __cl_to __asm__("$6") = to;
91 - register long __cl_len __asm__("$0") = len;
92 - __asm__ __volatile__(
93 - __module_call(28, 2, __do_clear_user)
94 - : "=r"(__cl_len), "=r"(__cl_to)
95 - : __module_address(__do_clear_user)
96 - "0"(__cl_len), "1"(__cl_to)
97 - : "$1", "$2", "$3", "$4", "$5", "$28", "memory");
98 - return __cl_len;
99 -}
100 +extern long __clear_user(void __user *to, long len);
101
102 extern inline long
103 clear_user(void __user *to, long len)
104 @@ -428,9 +386,6 @@ clear_user(void __user *to, long len)
105 return len;
106 }
107
108 -#undef __module_address
109 -#undef __module_call
110 -
111 #define user_addr_max() \
112 (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)
113
114 diff --git a/arch/alpha/lib/Makefile b/arch/alpha/lib/Makefile
115 index 59660743237cc..a808159603645 100644
116 --- a/arch/alpha/lib/Makefile
117 +++ b/arch/alpha/lib/Makefile
118 @@ -20,12 +20,8 @@ lib-y = __divqu.o __remqu.o __divlu.o __remlu.o \
119 checksum.o \
120 csum_partial_copy.o \
121 $(ev67-y)strlen.o \
122 - $(ev67-y)strcat.o \
123 - strcpy.o \
124 - $(ev67-y)strncat.o \
125 - strncpy.o \
126 - $(ev6-y)stxcpy.o \
127 - $(ev6-y)stxncpy.o \
128 + stycpy.o \
129 + styncpy.o \
130 $(ev67-y)strchr.o \
131 $(ev67-y)strrchr.o \
132 $(ev6-y)memchr.o \
133 @@ -46,11 +42,20 @@ AFLAGS___remqu.o = -DREM
134 AFLAGS___divlu.o = -DDIV -DINTSIZE
135 AFLAGS___remlu.o = -DREM -DINTSIZE
136
137 -$(obj)/__divqu.o: $(obj)/$(ev6-y)divide.S
138 - $(cmd_as_o_S)
139 -$(obj)/__remqu.o: $(obj)/$(ev6-y)divide.S
140 - $(cmd_as_o_S)
141 -$(obj)/__divlu.o: $(obj)/$(ev6-y)divide.S
142 - $(cmd_as_o_S)
143 -$(obj)/__remlu.o: $(obj)/$(ev6-y)divide.S
144 - $(cmd_as_o_S)
145 +$(addprefix $(obj)/,__divqu.o __remqu.o __divlu.o __remlu.o): \
146 + $(src)/$(ev6-y)divide.S FORCE
147 + $(call if_changed_rule,as_o_S)
148 +
149 +# There are direct branches between {str*cpy,str*cat} and stx*cpy.
150 +# Ensure the branches are within range by merging these objects.
151 +
152 +LDFLAGS_stycpy.o := -r
153 +LDFLAGS_styncpy.o := -r
154 +
155 +$(obj)/stycpy.o: $(obj)/strcpy.o $(obj)/$(ev67-y)strcat.o \
156 + $(obj)/$(ev6-y)stxcpy.o FORCE
157 + $(call if_changed,ld)
158 +
159 +$(obj)/styncpy.o: $(obj)/strncpy.o $(obj)/$(ev67-y)strncat.o \
160 + $(obj)/$(ev6-y)stxncpy.o FORCE
161 + $(call if_changed,ld)
162 diff --git a/arch/alpha/lib/clear_user.S b/arch/alpha/lib/clear_user.S
163 index bf5b931866ba1..006f469fef73a 100644
164 --- a/arch/alpha/lib/clear_user.S
165 +++ b/arch/alpha/lib/clear_user.S
166 @@ -8,21 +8,6 @@
167 * right "bytes left to zero" value (and that it is updated only _after_
168 * a successful copy). There is also some rather minor exception setup
169 * stuff.
170 - *
171 - * NOTE! This is not directly C-callable, because the calling semantics
172 - * are different:
173 - *
174 - * Inputs:
175 - * length in $0
176 - * destination address in $6
177 - * exception pointer in $7
178 - * return address in $28 (exceptions expect it there)
179 - *
180 - * Outputs:
181 - * bytes left to copy in $0
182 - *
183 - * Clobbers:
184 - * $1,$2,$3,$4,$5,$6
185 */
186 #include <asm/export.h>
187
188 @@ -38,62 +23,63 @@
189 .set noreorder
190 .align 4
191
192 - .globl __do_clear_user
193 - .ent __do_clear_user
194 - .frame $30, 0, $28
195 + .globl __clear_user
196 + .ent __clear_user
197 + .frame $30, 0, $26
198 .prologue 0
199
200 $loop:
201 and $1, 3, $4 # e0 :
202 beq $4, 1f # .. e1 :
203
204 -0: EX( stq_u $31, 0($6) ) # e0 : zero one word
205 +0: EX( stq_u $31, 0($16) ) # e0 : zero one word
206 subq $0, 8, $0 # .. e1 :
207 subq $4, 1, $4 # e0 :
208 - addq $6, 8, $6 # .. e1 :
209 + addq $16, 8, $16 # .. e1 :
210 bne $4, 0b # e1 :
211 unop # :
212
213 1: bic $1, 3, $1 # e0 :
214 beq $1, $tail # .. e1 :
215
216 -2: EX( stq_u $31, 0($6) ) # e0 : zero four words
217 +2: EX( stq_u $31, 0($16) ) # e0 : zero four words
218 subq $0, 8, $0 # .. e1 :
219 - EX( stq_u $31, 8($6) ) # e0 :
220 + EX( stq_u $31, 8($16) ) # e0 :
221 subq $0, 8, $0 # .. e1 :
222 - EX( stq_u $31, 16($6) ) # e0 :
223 + EX( stq_u $31, 16($16) ) # e0 :
224 subq $0, 8, $0 # .. e1 :
225 - EX( stq_u $31, 24($6) ) # e0 :
226 + EX( stq_u $31, 24($16) ) # e0 :
227 subq $0, 8, $0 # .. e1 :
228 subq $1, 4, $1 # e0 :
229 - addq $6, 32, $6 # .. e1 :
230 + addq $16, 32, $16 # .. e1 :
231 bne $1, 2b # e1 :
232
233 $tail:
234 bne $2, 1f # e1 : is there a tail to do?
235 - ret $31, ($28), 1 # .. e1 :
236 + ret $31, ($26), 1 # .. e1 :
237
238 -1: EX( ldq_u $5, 0($6) ) # e0 :
239 +1: EX( ldq_u $5, 0($16) ) # e0 :
240 clr $0 # .. e1 :
241 nop # e1 :
242 mskqh $5, $0, $5 # e0 :
243 - EX( stq_u $5, 0($6) ) # e0 :
244 - ret $31, ($28), 1 # .. e1 :
245 + EX( stq_u $5, 0($16) ) # e0 :
246 + ret $31, ($26), 1 # .. e1 :
247
248 -__do_clear_user:
249 - and $6, 7, $4 # e0 : find dest misalignment
250 +__clear_user:
251 + and $17, $17, $0
252 + and $16, 7, $4 # e0 : find dest misalignment
253 beq $0, $zerolength # .. e1 :
254 addq $0, $4, $1 # e0 : bias counter
255 and $1, 7, $2 # e1 : number of bytes in tail
256 srl $1, 3, $1 # e0 :
257 beq $4, $loop # .. e1 :
258
259 - EX( ldq_u $5, 0($6) ) # e0 : load dst word to mask back in
260 + EX( ldq_u $5, 0($16) ) # e0 : load dst word to mask back in
261 beq $1, $oneword # .. e1 : sub-word store?
262
263 - mskql $5, $6, $5 # e0 : take care of misaligned head
264 - addq $6, 8, $6 # .. e1 :
265 - EX( stq_u $5, -8($6) ) # e0 :
266 + mskql $5, $16, $5 # e0 : take care of misaligned head
267 + addq $16, 8, $16 # .. e1 :
268 + EX( stq_u $5, -8($16) ) # e0 :
269 addq $0, $4, $0 # .. e1 : bytes left -= 8 - misalignment
270 subq $1, 1, $1 # e0 :
271 subq $0, 8, $0 # .. e1 :
272 @@ -101,15 +87,15 @@ __do_clear_user:
273 unop # :
274
275 $oneword:
276 - mskql $5, $6, $4 # e0 :
277 + mskql $5, $16, $4 # e0 :
278 mskqh $5, $2, $5 # e0 :
279 or $5, $4, $5 # e1 :
280 - EX( stq_u $5, 0($6) ) # e0 :
281 + EX( stq_u $5, 0($16) ) # e0 :
282 clr $0 # .. e1 :
283
284 $zerolength:
285 $exception:
286 - ret $31, ($28), 1 # .. e1 :
287 + ret $31, ($26), 1 # .. e1 :
288
289 - .end __do_clear_user
290 - EXPORT_SYMBOL(__do_clear_user)
291 + .end __clear_user
292 + EXPORT_SYMBOL(__clear_user)
293 diff --git a/arch/alpha/lib/copy_user.S b/arch/alpha/lib/copy_user.S
294 index 509f62b653110..159f1b7e6e495 100644
295 --- a/arch/alpha/lib/copy_user.S
296 +++ b/arch/alpha/lib/copy_user.S
297 @@ -9,21 +9,6 @@
298 * contains the right "bytes left to copy" value (and that it is updated
299 * only _after_ a successful copy). There is also some rather minor
300 * exception setup stuff..
301 - *
302 - * NOTE! This is not directly C-callable, because the calling semantics are
303 - * different:
304 - *
305 - * Inputs:
306 - * length in $0
307 - * destination address in $6
308 - * source address in $7
309 - * return address in $28
310 - *
311 - * Outputs:
312 - * bytes left to copy in $0
313 - *
314 - * Clobbers:
315 - * $1,$2,$3,$4,$5,$6,$7
316 */
317
318 #include <asm/export.h>
319 @@ -49,58 +34,59 @@
320 .ent __copy_user
321 __copy_user:
322 .prologue 0
323 - and $6,7,$3
324 + and $18,$18,$0
325 + and $16,7,$3
326 beq $0,$35
327 beq $3,$36
328 subq $3,8,$3
329 .align 4
330 $37:
331 - EXI( ldq_u $1,0($7) )
332 - EXO( ldq_u $2,0($6) )
333 - extbl $1,$7,$1
334 - mskbl $2,$6,$2
335 - insbl $1,$6,$1
336 + EXI( ldq_u $1,0($17) )
337 + EXO( ldq_u $2,0($16) )
338 + extbl $1,$17,$1
339 + mskbl $2,$16,$2
340 + insbl $1,$16,$1
341 addq $3,1,$3
342 bis $1,$2,$1
343 - EXO( stq_u $1,0($6) )
344 + EXO( stq_u $1,0($16) )
345 subq $0,1,$0
346 - addq $6,1,$6
347 - addq $7,1,$7
348 + addq $16,1,$16
349 + addq $17,1,$17
350 beq $0,$41
351 bne $3,$37
352 $36:
353 - and $7,7,$1
354 + and $17,7,$1
355 bic $0,7,$4
356 beq $1,$43
357 beq $4,$48
358 - EXI( ldq_u $3,0($7) )
359 + EXI( ldq_u $3,0($17) )
360 .align 4
361 $50:
362 - EXI( ldq_u $2,8($7) )
363 + EXI( ldq_u $2,8($17) )
364 subq $4,8,$4
365 - extql $3,$7,$3
366 - extqh $2,$7,$1
367 + extql $3,$17,$3
368 + extqh $2,$17,$1
369 bis $3,$1,$1
370 - EXO( stq $1,0($6) )
371 - addq $7,8,$7
372 + EXO( stq $1,0($16) )
373 + addq $17,8,$17
374 subq $0,8,$0
375 - addq $6,8,$6
376 + addq $16,8,$16
377 bis $2,$2,$3
378 bne $4,$50
379 $48:
380 beq $0,$41
381 .align 4
382 $57:
383 - EXI( ldq_u $1,0($7) )
384 - EXO( ldq_u $2,0($6) )
385 - extbl $1,$7,$1
386 - mskbl $2,$6,$2
387 - insbl $1,$6,$1
388 + EXI( ldq_u $1,0($17) )
389 + EXO( ldq_u $2,0($16) )
390 + extbl $1,$17,$1
391 + mskbl $2,$16,$2
392 + insbl $1,$16,$1
393 bis $1,$2,$1
394 - EXO( stq_u $1,0($6) )
395 + EXO( stq_u $1,0($16) )
396 subq $0,1,$0
397 - addq $6,1,$6
398 - addq $7,1,$7
399 + addq $16,1,$16
400 + addq $17,1,$17
401 bne $0,$57
402 br $31,$41
403 .align 4
404 @@ -108,27 +94,27 @@ $43:
405 beq $4,$65
406 .align 4
407 $66:
408 - EXI( ldq $1,0($7) )
409 + EXI( ldq $1,0($17) )
410 subq $4,8,$4
411 - EXO( stq $1,0($6) )
412 - addq $7,8,$7
413 + EXO( stq $1,0($16) )
414 + addq $17,8,$17
415 subq $0,8,$0
416 - addq $6,8,$6
417 + addq $16,8,$16
418 bne $4,$66
419 $65:
420 beq $0,$41
421 - EXI( ldq $2,0($7) )
422 - EXO( ldq $1,0($6) )
423 + EXI( ldq $2,0($17) )
424 + EXO( ldq $1,0($16) )
425 mskql $2,$0,$2
426 mskqh $1,$0,$1
427 bis $2,$1,$2
428 - EXO( stq $2,0($6) )
429 + EXO( stq $2,0($16) )
430 bis $31,$31,$0
431 $41:
432 $35:
433 $exitin:
434 $exitout:
435 - ret $31,($28),1
436 + ret $31,($26),1
437
438 .end __copy_user
439 EXPORT_SYMBOL(__copy_user)
440 diff --git a/arch/alpha/lib/ev6-clear_user.S b/arch/alpha/lib/ev6-clear_user.S
441 index 05bef6b505984..e179e4757ef89 100644
442 --- a/arch/alpha/lib/ev6-clear_user.S
443 +++ b/arch/alpha/lib/ev6-clear_user.S
444 @@ -9,21 +9,6 @@
445 * a successful copy). There is also some rather minor exception setup
446 * stuff.
447 *
448 - * NOTE! This is not directly C-callable, because the calling semantics
449 - * are different:
450 - *
451 - * Inputs:
452 - * length in $0
453 - * destination address in $6
454 - * exception pointer in $7
455 - * return address in $28 (exceptions expect it there)
456 - *
457 - * Outputs:
458 - * bytes left to copy in $0
459 - *
460 - * Clobbers:
461 - * $1,$2,$3,$4,$5,$6
462 - *
463 * Much of the information about 21264 scheduling/coding comes from:
464 * Compiler Writer's Guide for the Alpha 21264
465 * abbreviated as 'CWG' in other comments here
466 @@ -56,14 +41,15 @@
467 .set noreorder
468 .align 4
469
470 - .globl __do_clear_user
471 - .ent __do_clear_user
472 - .frame $30, 0, $28
473 + .globl __clear_user
474 + .ent __clear_user
475 + .frame $30, 0, $26
476 .prologue 0
477
478 # Pipeline info : Slotting & Comments
479 -__do_clear_user:
480 - and $6, 7, $4 # .. E .. .. : find dest head misalignment
481 +__clear_user:
482 + and $17, $17, $0
483 + and $16, 7, $4 # .. E .. .. : find dest head misalignment
484 beq $0, $zerolength # U .. .. .. : U L U L
485
486 addq $0, $4, $1 # .. .. .. E : bias counter
487 @@ -75,14 +61,14 @@ __do_clear_user:
488
489 /*
490 * Head is not aligned. Write (8 - $4) bytes to head of destination
491 - * This means $6 is known to be misaligned
492 + * This means $16 is known to be misaligned
493 */
494 - EX( ldq_u $5, 0($6) ) # .. .. .. L : load dst word to mask back in
495 + EX( ldq_u $5, 0($16) ) # .. .. .. L : load dst word to mask back in
496 beq $1, $onebyte # .. .. U .. : sub-word store?
497 - mskql $5, $6, $5 # .. U .. .. : take care of misaligned head
498 - addq $6, 8, $6 # E .. .. .. : L U U L
499 + mskql $5, $16, $5 # .. U .. .. : take care of misaligned head
500 + addq $16, 8, $16 # E .. .. .. : L U U L
501
502 - EX( stq_u $5, -8($6) ) # .. .. .. L :
503 + EX( stq_u $5, -8($16) ) # .. .. .. L :
504 subq $1, 1, $1 # .. .. E .. :
505 addq $0, $4, $0 # .. E .. .. : bytes left -= 8 - misalignment
506 subq $0, 8, $0 # E .. .. .. : U L U L
507 @@ -93,11 +79,11 @@ __do_clear_user:
508 * values upon initial entry to the loop
509 * $1 is number of quadwords to clear (zero is a valid value)
510 * $2 is number of trailing bytes (0..7) ($2 never used...)
511 - * $6 is known to be aligned 0mod8
512 + * $16 is known to be aligned 0mod8
513 */
514 $headalign:
515 subq $1, 16, $4 # .. .. .. E : If < 16, we can not use the huge loop
516 - and $6, 0x3f, $2 # .. .. E .. : Forward work for huge loop
517 + and $16, 0x3f, $2 # .. .. E .. : Forward work for huge loop
518 subq $2, 0x40, $3 # .. E .. .. : bias counter (huge loop)
519 blt $4, $trailquad # U .. .. .. : U L U L
520
521 @@ -114,21 +100,21 @@ $headalign:
522 beq $3, $bigalign # U .. .. .. : U L U L : Aligned 0mod64
523
524 $alignmod64:
525 - EX( stq_u $31, 0($6) ) # .. .. .. L
526 + EX( stq_u $31, 0($16) ) # .. .. .. L
527 addq $3, 8, $3 # .. .. E ..
528 subq $0, 8, $0 # .. E .. ..
529 nop # E .. .. .. : U L U L
530
531 nop # .. .. .. E
532 subq $1, 1, $1 # .. .. E ..
533 - addq $6, 8, $6 # .. E .. ..
534 + addq $16, 8, $16 # .. E .. ..
535 blt $3, $alignmod64 # U .. .. .. : U L U L
536
537 $bigalign:
538 /*
539 * $0 is the number of bytes left
540 * $1 is the number of quads left
541 - * $6 is aligned 0mod64
542 + * $16 is aligned 0mod64
543 * we know that we'll be taking a minimum of one trip through
544 * CWG Section 3.7.6: do not expect a sustained store rate of > 1/cycle
545 * We are _not_ going to update $0 after every single store. That
546 @@ -145,39 +131,39 @@ $bigalign:
547 nop # E :
548 nop # E :
549 nop # E :
550 - bis $6,$6,$3 # E : U L U L : Initial wh64 address is dest
551 + bis $16,$16,$3 # E : U L U L : Initial wh64 address is dest
552 /* This might actually help for the current trip... */
553
554 $do_wh64:
555 wh64 ($3) # .. .. .. L1 : memory subsystem hint
556 subq $1, 16, $4 # .. .. E .. : Forward calculation - repeat the loop?
557 - EX( stq_u $31, 0($6) ) # .. L .. ..
558 + EX( stq_u $31, 0($16) ) # .. L .. ..
559 subq $0, 8, $0 # E .. .. .. : U L U L
560
561 - addq $6, 128, $3 # E : Target address of wh64
562 - EX( stq_u $31, 8($6) ) # L :
563 - EX( stq_u $31, 16($6) ) # L :
564 + addq $16, 128, $3 # E : Target address of wh64
565 + EX( stq_u $31, 8($16) ) # L :
566 + EX( stq_u $31, 16($16) ) # L :
567 subq $0, 16, $0 # E : U L L U
568
569 nop # E :
570 - EX( stq_u $31, 24($6) ) # L :
571 - EX( stq_u $31, 32($6) ) # L :
572 + EX( stq_u $31, 24($16) ) # L :
573 + EX( stq_u $31, 32($16) ) # L :
574 subq $0, 168, $5 # E : U L L U : two trips through the loop left?
575 /* 168 = 192 - 24, since we've already completed some stores */
576
577 subq $0, 16, $0 # E :
578 - EX( stq_u $31, 40($6) ) # L :
579 - EX( stq_u $31, 48($6) ) # L :
580 - cmovlt $5, $6, $3 # E : U L L U : Latency 2, extra mapping cycle
581 + EX( stq_u $31, 40($16) ) # L :
582 + EX( stq_u $31, 48($16) ) # L :
583 + cmovlt $5, $16, $3 # E : U L L U : Latency 2, extra mapping cycle
584
585 subq $1, 8, $1 # E :
586 subq $0, 16, $0 # E :
587 - EX( stq_u $31, 56($6) ) # L :
588 + EX( stq_u $31, 56($16) ) # L :
589 nop # E : U L U L
590
591 nop # E :
592 subq $0, 8, $0 # E :
593 - addq $6, 64, $6 # E :
594 + addq $16, 64, $16 # E :
595 bge $4, $do_wh64 # U : U L U L
596
597 $trailquad:
598 @@ -190,14 +176,14 @@ $trailquad:
599 beq $1, $trailbytes # U .. .. .. : U L U L : Only 0..7 bytes to go
600
601 $onequad:
602 - EX( stq_u $31, 0($6) ) # .. .. .. L
603 + EX( stq_u $31, 0($16) ) # .. .. .. L
604 subq $1, 1, $1 # .. .. E ..
605 subq $0, 8, $0 # .. E .. ..
606 nop # E .. .. .. : U L U L
607
608 nop # .. .. .. E
609 nop # .. .. E ..
610 - addq $6, 8, $6 # .. E .. ..
611 + addq $16, 8, $16 # .. E .. ..
612 bgt $1, $onequad # U .. .. .. : U L U L
613
614 # We have an unknown number of bytes left to go.
615 @@ -211,9 +197,9 @@ $trailbytes:
616 # so we will use $0 as the loop counter
617 # We know for a fact that $0 > 0 zero due to previous context
618 $onebyte:
619 - EX( stb $31, 0($6) ) # .. .. .. L
620 + EX( stb $31, 0($16) ) # .. .. .. L
621 subq $0, 1, $0 # .. .. E .. :
622 - addq $6, 1, $6 # .. E .. .. :
623 + addq $16, 1, $16 # .. E .. .. :
624 bgt $0, $onebyte # U .. .. .. : U L U L
625
626 $zerolength:
627 @@ -221,6 +207,6 @@ $exception: # Destination for exception recovery(?)
628 nop # .. .. .. E :
629 nop # .. .. E .. :
630 nop # .. E .. .. :
631 - ret $31, ($28), 1 # L0 .. .. .. : L U L U
632 - .end __do_clear_user
633 - EXPORT_SYMBOL(__do_clear_user)
634 + ret $31, ($26), 1 # L0 .. .. .. : L U L U
635 + .end __clear_user
636 + EXPORT_SYMBOL(__clear_user)
637 diff --git a/arch/alpha/lib/ev6-copy_user.S b/arch/alpha/lib/ev6-copy_user.S
638 index be720b518af9e..35e6710d07005 100644
639 --- a/arch/alpha/lib/ev6-copy_user.S
640 +++ b/arch/alpha/lib/ev6-copy_user.S
641 @@ -12,21 +12,6 @@
642 * only _after_ a successful copy). There is also some rather minor
643 * exception setup stuff..
644 *
645 - * NOTE! This is not directly C-callable, because the calling semantics are
646 - * different:
647 - *
648 - * Inputs:
649 - * length in $0
650 - * destination address in $6
651 - * source address in $7
652 - * return address in $28
653 - *
654 - * Outputs:
655 - * bytes left to copy in $0
656 - *
657 - * Clobbers:
658 - * $1,$2,$3,$4,$5,$6,$7
659 - *
660 * Much of the information about 21264 scheduling/coding comes from:
661 * Compiler Writer's Guide for the Alpha 21264
662 * abbreviated as 'CWG' in other comments here
663 @@ -60,10 +45,11 @@
664 # Pipeline info: Slotting & Comments
665 __copy_user:
666 .prologue 0
667 - subq $0, 32, $1 # .. E .. .. : Is this going to be a small copy?
668 + andq $18, $18, $0
669 + subq $18, 32, $1 # .. E .. .. : Is this going to be a small copy?
670 beq $0, $zerolength # U .. .. .. : U L U L
671
672 - and $6,7,$3 # .. .. .. E : is leading dest misalignment
673 + and $16,7,$3 # .. .. .. E : is leading dest misalignment
674 ble $1, $onebyteloop # .. .. U .. : 1st branch : small amount of data
675 beq $3, $destaligned # .. U .. .. : 2nd (one cycle fetcher stall)
676 subq $3, 8, $3 # E .. .. .. : L U U L : trip counter
677 @@ -73,17 +59,17 @@ __copy_user:
678 * We know we have at least one trip through this loop
679 */
680 $aligndest:
681 - EXI( ldbu $1,0($7) ) # .. .. .. L : Keep loads separate from stores
682 - addq $6,1,$6 # .. .. E .. : Section 3.8 in the CWG
683 + EXI( ldbu $1,0($17) ) # .. .. .. L : Keep loads separate from stores
684 + addq $16,1,$16 # .. .. E .. : Section 3.8 in the CWG
685 addq $3,1,$3 # .. E .. .. :
686 nop # E .. .. .. : U L U L
687
688 /*
689 - * the -1 is to compensate for the inc($6) done in a previous quadpack
690 + * the -1 is to compensate for the inc($16) done in a previous quadpack
691 * which allows us zero dependencies within either quadpack in the loop
692 */
693 - EXO( stb $1,-1($6) ) # .. .. .. L :
694 - addq $7,1,$7 # .. .. E .. : Section 3.8 in the CWG
695 + EXO( stb $1,-1($16) ) # .. .. .. L :
696 + addq $17,1,$17 # .. .. E .. : Section 3.8 in the CWG
697 subq $0,1,$0 # .. E .. .. :
698 bne $3, $aligndest # U .. .. .. : U L U L
699
700 @@ -92,29 +78,29 @@ $aligndest:
701 * If we arrived via branch, we have a minimum of 32 bytes
702 */
703 $destaligned:
704 - and $7,7,$1 # .. .. .. E : Check _current_ source alignment
705 + and $17,7,$1 # .. .. .. E : Check _current_ source alignment
706 bic $0,7,$4 # .. .. E .. : number bytes as a quadword loop
707 - EXI( ldq_u $3,0($7) ) # .. L .. .. : Forward fetch for fallthrough code
708 + EXI( ldq_u $3,0($17) ) # .. L .. .. : Forward fetch for fallthrough code
709 beq $1,$quadaligned # U .. .. .. : U L U L
710
711 /*
712 - * In the worst case, we've just executed an ldq_u here from 0($7)
713 + * In the worst case, we've just executed an ldq_u here from 0($17)
714 * and we'll repeat it once if we take the branch
715 */
716
717 /* Misaligned quadword loop - not unrolled. Leave it that way. */
718 $misquad:
719 - EXI( ldq_u $2,8($7) ) # .. .. .. L :
720 + EXI( ldq_u $2,8($17) ) # .. .. .. L :
721 subq $4,8,$4 # .. .. E .. :
722 - extql $3,$7,$3 # .. U .. .. :
723 - extqh $2,$7,$1 # U .. .. .. : U U L L
724 + extql $3,$17,$3 # .. U .. .. :
725 + extqh $2,$17,$1 # U .. .. .. : U U L L
726
727 bis $3,$1,$1 # .. .. .. E :
728 - EXO( stq $1,0($6) ) # .. .. L .. :
729 - addq $7,8,$7 # .. E .. .. :
730 + EXO( stq $1,0($16) ) # .. .. L .. :
731 + addq $17,8,$17 # .. E .. .. :
732 subq $0,8,$0 # E .. .. .. : U L L U
733
734 - addq $6,8,$6 # .. .. .. E :
735 + addq $16,8,$16 # .. .. .. E :
736 bis $2,$2,$3 # .. .. E .. :
737 nop # .. E .. .. :
738 bne $4,$misquad # U .. .. .. : U L U L
739 @@ -125,8 +111,8 @@ $misquad:
740 beq $0,$zerolength # U .. .. .. : U L U L
741
742 /* We know we have at least one trip through the byte loop */
743 - EXI ( ldbu $2,0($7) ) # .. .. .. L : No loads in the same quad
744 - addq $6,1,$6 # .. .. E .. : as the store (Section 3.8 in CWG)
745 + EXI ( ldbu $2,0($17) ) # .. .. .. L : No loads in the same quad
746 + addq $16,1,$16 # .. .. E .. : as the store (Section 3.8 in CWG)
747 nop # .. E .. .. :
748 br $31, $dirtyentry # L0 .. .. .. : L U U L
749 /* Do the trailing byte loop load, then hop into the store part of the loop */
750 @@ -136,8 +122,8 @@ $misquad:
751 * Based upon the usage context, it's worth the effort to unroll this loop
752 * $0 - number of bytes to be moved
753 * $4 - number of bytes to move as quadwords
754 - * $6 is current destination address
755 - * $7 is current source address
756 + * $16 is current destination address
757 + * $17 is current source address
758 */
759 $quadaligned:
760 subq $4, 32, $2 # .. .. .. E : do not unroll for small stuff
761 @@ -155,29 +141,29 @@ $quadaligned:
762 * instruction memory hint instruction).
763 */
764 $unroll4:
765 - EXI( ldq $1,0($7) ) # .. .. .. L
766 - EXI( ldq $2,8($7) ) # .. .. L ..
767 + EXI( ldq $1,0($17) ) # .. .. .. L
768 + EXI( ldq $2,8($17) ) # .. .. L ..
769 subq $4,32,$4 # .. E .. ..
770 nop # E .. .. .. : U U L L
771
772 - addq $7,16,$7 # .. .. .. E
773 - EXO( stq $1,0($6) ) # .. .. L ..
774 - EXO( stq $2,8($6) ) # .. L .. ..
775 + addq $17,16,$17 # .. .. .. E
776 + EXO( stq $1,0($16) ) # .. .. L ..
777 + EXO( stq $2,8($16) ) # .. L .. ..
778 subq $0,16,$0 # E .. .. .. : U L L U
779
780 - addq $6,16,$6 # .. .. .. E
781 - EXI( ldq $1,0($7) ) # .. .. L ..
782 - EXI( ldq $2,8($7) ) # .. L .. ..
783 + addq $16,16,$16 # .. .. .. E
784 + EXI( ldq $1,0($17) ) # .. .. L ..
785 + EXI( ldq $2,8($17) ) # .. L .. ..
786 subq $4, 32, $3 # E .. .. .. : U U L L : is there enough for another trip?
787
788 - EXO( stq $1,0($6) ) # .. .. .. L
789 - EXO( stq $2,8($6) ) # .. .. L ..
790 + EXO( stq $1,0($16) ) # .. .. .. L
791 + EXO( stq $2,8($16) ) # .. .. L ..
792 subq $0,16,$0 # .. E .. ..
793 - addq $7,16,$7 # E .. .. .. : U L L U
794 + addq $17,16,$17 # E .. .. .. : U L L U
795
796 nop # .. .. .. E
797 nop # .. .. E ..
798 - addq $6,16,$6 # .. E .. ..
799 + addq $16,16,$16 # .. E .. ..
800 bgt $3,$unroll4 # U .. .. .. : U L U L
801
802 nop
803 @@ -186,14 +172,14 @@ $unroll4:
804 beq $4, $noquads
805
806 $onequad:
807 - EXI( ldq $1,0($7) )
808 + EXI( ldq $1,0($17) )
809 subq $4,8,$4
810 - addq $7,8,$7
811 + addq $17,8,$17
812 nop
813
814 - EXO( stq $1,0($6) )
815 + EXO( stq $1,0($16) )
816 subq $0,8,$0
817 - addq $6,8,$6
818 + addq $16,8,$16
819 bne $4,$onequad
820
821 $noquads:
822 @@ -207,23 +193,23 @@ $noquads:
823 * There's no point in doing a lot of complex alignment calculations to try to
824 * to quadword stuff for a small amount of data.
825 * $0 - remaining number of bytes left to copy
826 - * $6 - current dest addr
827 - * $7 - current source addr
828 + * $16 - current dest addr
829 + * $17 - current source addr
830 */
831
832 $onebyteloop:
833 - EXI ( ldbu $2,0($7) ) # .. .. .. L : No loads in the same quad
834 - addq $6,1,$6 # .. .. E .. : as the store (Section 3.8 in CWG)
835 + EXI ( ldbu $2,0($17) ) # .. .. .. L : No loads in the same quad
836 + addq $16,1,$16 # .. .. E .. : as the store (Section 3.8 in CWG)
837 nop # .. E .. .. :
838 nop # E .. .. .. : U L U L
839
840 $dirtyentry:
841 /*
842 - * the -1 is to compensate for the inc($6) done in a previous quadpack
843 + * the -1 is to compensate for the inc($16) done in a previous quadpack
844 * which allows us zero dependencies within either quadpack in the loop
845 */
846 - EXO ( stb $2,-1($6) ) # .. .. .. L :
847 - addq $7,1,$7 # .. .. E .. : quadpack as the load
848 + EXO ( stb $2,-1($16) ) # .. .. .. L :
849 + addq $17,1,$17 # .. .. E .. : quadpack as the load
850 subq $0,1,$0 # .. E .. .. : change count _after_ copy
851 bgt $0,$onebyteloop # U .. .. .. : U L U L
852
853 @@ -233,7 +219,7 @@ $exitout: # Destination for exception recovery(?)
854 nop # .. .. .. E
855 nop # .. .. E ..
856 nop # .. E .. ..
857 - ret $31,($28),1 # L0 .. .. .. : L U L U
858 + ret $31,($26),1 # L0 .. .. .. : L U L U
859
860 .end __copy_user
861 EXPORT_SYMBOL(__copy_user)
862 diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
863 index b5ce1e81f945a..16615ae6e2574 100644
864 --- a/arch/arm/kvm/mmu.c
865 +++ b/arch/arm/kvm/mmu.c
866 @@ -1834,7 +1834,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
867 * Prevent userspace from creating a memory region outside of the IPA
868 * space addressable by the KVM guest IPA space.
869 */
870 - if (memslot->base_gfn + memslot->npages >=
871 + if (memslot->base_gfn + memslot->npages >
872 (KVM_PHYS_SIZE >> PAGE_SHIFT))
873 return -EFAULT;
874
875 diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h
876 index ab934f8232bd8..985fa005c1df7 100644
877 --- a/arch/powerpc/include/asm/code-patching.h
878 +++ b/arch/powerpc/include/asm/code-patching.h
879 @@ -46,7 +46,7 @@ void __patch_exception(int exc, unsigned long addr);
880 #endif
881
882 #define OP_RT_RA_MASK 0xffff0000UL
883 -#define LIS_R2 0x3c020000UL
884 +#define LIS_R2 0x3c400000UL
885 #define ADDIS_R2_R12 0x3c4c0000UL
886 #define ADDI_R2_R2 0x38420000UL
887
888 diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
889 index 1f1ac446ace9a..f2d8f35c181f7 100644
890 --- a/arch/powerpc/perf/core-book3s.c
891 +++ b/arch/powerpc/perf/core-book3s.c
892 @@ -2010,7 +2010,17 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
893 left += period;
894 if (left <= 0)
895 left = period;
896 - record = siar_valid(regs);
897 +
898 + /*
899 + * If address is not requested in the sample via
900 + * PERF_SAMPLE_IP, just record that sample irrespective
901 + * of SIAR valid check.
902 + */
903 + if (event->attr.sample_type & PERF_SAMPLE_IP)
904 + record = siar_valid(regs);
905 + else
906 + record = 1;
907 +
908 event->hw.last_period = event->hw.sample_period;
909 }
910 if (left < 0x80000000LL)
911 @@ -2028,9 +2038,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
912 * MMCR2. Check attr.exclude_kernel and address to drop the sample in
913 * these cases.
914 */
915 - if (event->attr.exclude_kernel && record)
916 - if (is_kernel_addr(mfspr(SPRN_SIAR)))
917 - record = 0;
918 + if (event->attr.exclude_kernel &&
919 + (event->attr.sample_type & PERF_SAMPLE_IP) &&
920 + is_kernel_addr(mfspr(SPRN_SIAR)))
921 + record = 0;
922
923 /*
924 * Finally record data if requested.
925 diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
926 index cba8e56cd63db..54eb8fe95212d 100644
927 --- a/arch/s390/kernel/smp.c
928 +++ b/arch/s390/kernel/smp.c
929 @@ -727,7 +727,7 @@ static int smp_add_core(struct sclp_core_entry *core, cpumask_t *avail,
930 static int __smp_rescan_cpus(struct sclp_core_info *info, bool early)
931 {
932 struct sclp_core_entry *core;
933 - cpumask_t avail;
934 + static cpumask_t avail;
935 bool configured;
936 u16 core_id;
937 int nr, i;
938 diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
939 index 97b678c0ea136..4ab96c7f8fd70 100644
940 --- a/drivers/block/rsxx/core.c
941 +++ b/drivers/block/rsxx/core.c
942 @@ -892,6 +892,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
943 card->event_wq = create_singlethread_workqueue(DRIVER_NAME"_event");
944 if (!card->event_wq) {
945 dev_err(CARD_TO_DEV(card), "Failed card event setup.\n");
946 + st = -ENOMEM;
947 goto failed_event_handler;
948 }
949
950 diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
951 index 841f2428e84a3..293d1184976b3 100644
952 --- a/drivers/hwmon/lm90.c
953 +++ b/drivers/hwmon/lm90.c
954 @@ -186,6 +186,7 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
955 #define LM90_HAVE_EMERGENCY_ALARM (1 << 5)/* emergency alarm */
956 #define LM90_HAVE_TEMP3 (1 << 6) /* 3rd temperature sensor */
957 #define LM90_HAVE_BROKEN_ALERT (1 << 7) /* Broken alert */
958 +#define LM90_PAUSE_FOR_CONFIG (1 << 8) /* Pause conversion for config */
959
960 /* LM90 status */
961 #define LM90_STATUS_LTHRM (1 << 0) /* local THERM limit tripped */
962 @@ -286,6 +287,7 @@ static const struct lm90_params lm90_params[] = {
963 .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
964 },
965 [max6657] = {
966 + .flags = LM90_PAUSE_FOR_CONFIG,
967 .alert_alarms = 0x7c,
968 .max_convrate = 8,
969 .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
970 @@ -486,6 +488,38 @@ static inline int lm90_select_remote_channel(struct i2c_client *client,
971 return 0;
972 }
973
974 +static int lm90_write_convrate(struct i2c_client *client,
975 + struct lm90_data *data, int val)
976 +{
977 + int err;
978 + int config_orig, config_stop;
979 +
980 + /* Save config and pause conversion */
981 + if (data->flags & LM90_PAUSE_FOR_CONFIG) {
982 + config_orig = lm90_read_reg(client, LM90_REG_R_CONFIG1);
983 + if (config_orig < 0)
984 + return config_orig;
985 + config_stop = config_orig | 0x40;
986 + if (config_orig != config_stop) {
987 + err = i2c_smbus_write_byte_data(client,
988 + LM90_REG_W_CONFIG1,
989 + config_stop);
990 + if (err < 0)
991 + return err;
992 + }
993 + }
994 +
995 + /* Set conv rate */
996 + err = i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, val);
997 +
998 + /* Revert change to config */
999 + if (data->flags & LM90_PAUSE_FOR_CONFIG && config_orig != config_stop)
1000 + i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
1001 + config_orig);
1002 +
1003 + return err;
1004 +}
1005 +
1006 /*
1007 * Set conversion rate.
1008 * client->update_lock must be held when calling this function (unless we are
1009 @@ -506,7 +540,7 @@ static int lm90_set_convrate(struct i2c_client *client, struct lm90_data *data,
1010 if (interval >= update_interval * 3 / 4)
1011 break;
1012
1013 - err = i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, i);
1014 + err = lm90_write_convrate(client, data, i);
1015 data->update_interval = DIV_ROUND_CLOSEST(update_interval, 64);
1016 return err;
1017 }
1018 @@ -1512,8 +1546,7 @@ static void lm90_restore_conf(void *_data)
1019 struct i2c_client *client = data->client;
1020
1021 /* Restore initial configuration */
1022 - i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE,
1023 - data->convrate_orig);
1024 + lm90_write_convrate(client, data, data->convrate_orig);
1025 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
1026 data->config_orig);
1027 }
1028 @@ -1530,12 +1563,13 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
1029 /*
1030 * Start the conversions.
1031 */
1032 - lm90_set_convrate(client, data, 500); /* 500ms; 2Hz conversion rate */
1033 config = lm90_read_reg(client, LM90_REG_R_CONFIG1);
1034 if (config < 0)
1035 return config;
1036 data->config_orig = config;
1037
1038 + lm90_set_convrate(client, data, 500); /* 500ms; 2Hz conversion rate */
1039 +
1040 /* Check Temperature Range Select */
1041 if (data->kind == adt7461 || data->kind == tmp451) {
1042 if (config & 0x04)
1043 diff --git a/drivers/iio/imu/adis16400_buffer.c b/drivers/iio/imu/adis16400_buffer.c
1044 index 90c24a23c679b..c0eb9dfd1c454 100644
1045 --- a/drivers/iio/imu/adis16400_buffer.c
1046 +++ b/drivers/iio/imu/adis16400_buffer.c
1047 @@ -37,8 +37,11 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev,
1048 return -ENOMEM;
1049
1050 adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL);
1051 - if (!adis->buffer)
1052 + if (!adis->buffer) {
1053 + kfree(adis->xfer);
1054 + adis->xfer = NULL;
1055 return -ENOMEM;
1056 + }
1057
1058 tx = adis->buffer + burst_length;
1059 tx[0] = ADIS_READ_REG(ADIS16400_GLOB_CMD);
1060 diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c
1061 index 36607d52fee06..9de553e8c214f 100644
1062 --- a/drivers/iio/imu/adis_buffer.c
1063 +++ b/drivers/iio/imu/adis_buffer.c
1064 @@ -39,8 +39,11 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,
1065 return -ENOMEM;
1066
1067 adis->buffer = kzalloc(indio_dev->scan_bytes * 2, GFP_KERNEL);
1068 - if (!adis->buffer)
1069 + if (!adis->buffer) {
1070 + kfree(adis->xfer);
1071 + adis->xfer = NULL;
1072 return -ENOMEM;
1073 + }
1074
1075 rx = adis->buffer;
1076 tx = rx + scan_count;
1077 diff --git a/drivers/media/usb/usbtv/usbtv-audio.c b/drivers/media/usb/usbtv/usbtv-audio.c
1078 index 9db31db7d9ac2..df593d643d53f 100644
1079 --- a/drivers/media/usb/usbtv/usbtv-audio.c
1080 +++ b/drivers/media/usb/usbtv/usbtv-audio.c
1081 @@ -398,7 +398,7 @@ void usbtv_audio_free(struct usbtv *usbtv)
1082 cancel_work_sync(&usbtv->snd_trigger);
1083
1084 if (usbtv->snd && usbtv->udev) {
1085 - snd_card_free(usbtv->snd);
1086 + snd_card_free_when_closed(usbtv->snd);
1087 usbtv->snd = NULL;
1088 }
1089 }
1090 diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
1091 index 97e51309d7afc..e76455024d8b3 100644
1092 --- a/drivers/mmc/core/mmc.c
1093 +++ b/drivers/mmc/core/mmc.c
1094 @@ -423,10 +423,6 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
1095
1096 /* EXT_CSD value is in units of 10ms, but we store in ms */
1097 card->ext_csd.part_time = 10 * ext_csd[EXT_CSD_PART_SWITCH_TIME];
1098 - /* Some eMMC set the value too low so set a minimum */
1099 - if (card->ext_csd.part_time &&
1100 - card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME)
1101 - card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME;
1102
1103 /* Sleep / awake timeout in 100ns units */
1104 if (sa_shift > 0 && sa_shift <= 0x17)
1105 @@ -610,6 +606,17 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
1106 card->ext_csd.data_sector_size = 512;
1107 }
1108
1109 + /*
1110 + * GENERIC_CMD6_TIME is to be used "unless a specific timeout is defined
1111 + * when accessing a specific field", so use it here if there is no
1112 + * PARTITION_SWITCH_TIME.
1113 + */
1114 + if (!card->ext_csd.part_time)
1115 + card->ext_csd.part_time = card->ext_csd.generic_cmd6_time;
1116 + /* Some eMMC set the value too low so set a minimum */
1117 + if (card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME)
1118 + card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME;
1119 +
1120 /* eMMC v5 or later */
1121 if (card->ext_csd.rev >= 7) {
1122 memcpy(card->ext_csd.fwrev, &ext_csd[EXT_CSD_FIRMWARE_VERSION],
1123 diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
1124 index 7fc6ce3811421..125c06a10455c 100644
1125 --- a/drivers/mmc/host/mtk-sd.c
1126 +++ b/drivers/mmc/host/mtk-sd.c
1127 @@ -741,13 +741,13 @@ static void msdc_track_cmd_data(struct msdc_host *host,
1128 static void msdc_request_done(struct msdc_host *host, struct mmc_request *mrq)
1129 {
1130 unsigned long flags;
1131 - bool ret;
1132
1133 - ret = cancel_delayed_work(&host->req_timeout);
1134 - if (!ret) {
1135 - /* delay work already running */
1136 - return;
1137 - }
1138 + /*
1139 + * No need check the return value of cancel_delayed_work, as only ONE
1140 + * path will go here!
1141 + */
1142 + cancel_delayed_work(&host->req_timeout);
1143 +
1144 spin_lock_irqsave(&host->lock, flags);
1145 host->mrq = NULL;
1146 spin_unlock_irqrestore(&host->lock, flags);
1147 @@ -765,7 +765,7 @@ static bool msdc_cmd_done(struct msdc_host *host, int events,
1148 bool done = false;
1149 bool sbc_error;
1150 unsigned long flags;
1151 - u32 *rsp = cmd->resp;
1152 + u32 *rsp;
1153
1154 if (mrq->sbc && cmd == mrq->cmd &&
1155 (events & (MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR
1156 @@ -786,6 +786,7 @@ static bool msdc_cmd_done(struct msdc_host *host, int events,
1157
1158 if (done)
1159 return true;
1160 + rsp = cmd->resp;
1161
1162 sdr_clr_bits(host->base + MSDC_INTEN, cmd_ints_mask);
1163
1164 @@ -968,7 +969,7 @@ static void msdc_data_xfer_next(struct msdc_host *host,
1165 static bool msdc_data_xfer_done(struct msdc_host *host, u32 events,
1166 struct mmc_request *mrq, struct mmc_data *data)
1167 {
1168 - struct mmc_command *stop = data->stop;
1169 + struct mmc_command *stop;
1170 unsigned long flags;
1171 bool done;
1172 unsigned int check_data = events &
1173 @@ -984,6 +985,7 @@ static bool msdc_data_xfer_done(struct msdc_host *host, u32 events,
1174
1175 if (done)
1176 return true;
1177 + stop = data->stop;
1178
1179 if (check_data || (stop && stop->error)) {
1180 dev_dbg(host->dev, "DMA status: 0x%8X\n",
1181 diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
1182 index c8b8ac66ff7e3..687fd68fbbcd1 100644
1183 --- a/drivers/mmc/host/mxs-mmc.c
1184 +++ b/drivers/mmc/host/mxs-mmc.c
1185 @@ -651,7 +651,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
1186
1187 ret = mmc_of_parse(mmc);
1188 if (ret)
1189 - goto out_clk_disable;
1190 + goto out_free_dma;
1191
1192 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
1193
1194 diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
1195 index 6b866d0451b21..b18bb0334ded6 100644
1196 --- a/drivers/net/can/flexcan.c
1197 +++ b/drivers/net/can/flexcan.c
1198 @@ -383,7 +383,7 @@ static int flexcan_chip_freeze(struct flexcan_priv *priv)
1199 u32 reg;
1200
1201 reg = flexcan_read(&regs->mcr);
1202 - reg |= FLEXCAN_MCR_HALT;
1203 + reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT;
1204 flexcan_write(reg, &regs->mcr);
1205
1206 while (timeout-- && !(flexcan_read(&regs->mcr) & FLEXCAN_MCR_FRZ_ACK))
1207 @@ -1098,10 +1098,14 @@ static int register_flexcandev(struct net_device *dev)
1208 if (err)
1209 goto out_chip_disable;
1210
1211 - /* set freeze, halt and activate FIFO, restrict register access */
1212 + /* set freeze, halt */
1213 + err = flexcan_chip_freeze(priv);
1214 + if (err)
1215 + goto out_chip_disable;
1216 +
1217 + /* activate FIFO, restrict register access */
1218 reg = flexcan_read(&regs->mcr);
1219 - reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT |
1220 - FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV;
1221 + reg |= FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV;
1222 flexcan_write(reg, &regs->mcr);
1223
1224 /* Currently we only support newer versions of this core
1225 diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
1226 index 2a5bb1012385e..9de0f9f5b11ca 100644
1227 --- a/drivers/net/ethernet/atheros/alx/main.c
1228 +++ b/drivers/net/ethernet/atheros/alx/main.c
1229 @@ -1694,13 +1694,19 @@ static int alx_resume(struct device *dev)
1230 struct pci_dev *pdev = to_pci_dev(dev);
1231 struct alx_priv *alx = pci_get_drvdata(pdev);
1232 struct alx_hw *hw = &alx->hw;
1233 + int err;
1234
1235 alx_reset_phy(hw);
1236
1237 if (!netif_running(alx->dev))
1238 return 0;
1239 +
1240 + err = __alx_open(alx, true);
1241 + if (err)
1242 + return err;
1243 +
1244 netif_device_attach(alx->dev);
1245 - return __alx_open(alx, true);
1246 + return 0;
1247 }
1248
1249 static SIMPLE_DEV_PM_OPS(alx_pm_ops, alx_suspend, alx_resume);
1250 diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
1251 index f45385f5c6e58..f1e4cde963d8f 100644
1252 --- a/drivers/net/ethernet/davicom/dm9000.c
1253 +++ b/drivers/net/ethernet/davicom/dm9000.c
1254 @@ -143,6 +143,8 @@ struct board_info {
1255 u32 wake_state;
1256
1257 int ip_summed;
1258 +
1259 + struct regulator *power_supply;
1260 };
1261
1262 /* debug code */
1263 @@ -1459,7 +1461,7 @@ dm9000_probe(struct platform_device *pdev)
1264 if (ret) {
1265 dev_err(dev, "failed to request reset gpio %d: %d\n",
1266 reset_gpios, ret);
1267 - return -ENODEV;
1268 + goto out_regulator_disable;
1269 }
1270
1271 /* According to manual PWRST# Low Period Min 1ms */
1272 @@ -1471,8 +1473,10 @@ dm9000_probe(struct platform_device *pdev)
1273
1274 if (!pdata) {
1275 pdata = dm9000_parse_dt(&pdev->dev);
1276 - if (IS_ERR(pdata))
1277 - return PTR_ERR(pdata);
1278 + if (IS_ERR(pdata)) {
1279 + ret = PTR_ERR(pdata);
1280 + goto out_regulator_disable;
1281 + }
1282 }
1283
1284 /* Init network device */
1285 @@ -1489,6 +1493,8 @@ dm9000_probe(struct platform_device *pdev)
1286
1287 db->dev = &pdev->dev;
1288 db->ndev = ndev;
1289 + if (!IS_ERR(power))
1290 + db->power_supply = power;
1291
1292 spin_lock_init(&db->lock);
1293 mutex_init(&db->addr_lock);
1294 @@ -1715,6 +1721,10 @@ out:
1295 dm9000_release_board(pdev, db);
1296 free_netdev(ndev);
1297
1298 +out_regulator_disable:
1299 + if (!IS_ERR(power))
1300 + regulator_disable(power);
1301 +
1302 return ret;
1303 }
1304
1305 @@ -1774,10 +1784,13 @@ static int
1306 dm9000_drv_remove(struct platform_device *pdev)
1307 {
1308 struct net_device *ndev = platform_get_drvdata(pdev);
1309 + struct board_info *dm = to_dm9000_board(ndev);
1310
1311 unregister_netdev(ndev);
1312 - dm9000_release_board(pdev, netdev_priv(ndev));
1313 + dm9000_release_board(pdev, dm);
1314 free_netdev(ndev); /* free device structure */
1315 + if (dm->power_supply)
1316 + regulator_disable(dm->power_supply);
1317
1318 dev_dbg(&pdev->dev, "released and freed device\n");
1319 return 0;
1320 diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1321 index 6068e7c4fc7e9..d1224d33ecfab 100644
1322 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1323 +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1324 @@ -47,7 +47,7 @@
1325 #define EN_ETHTOOL_SHORT_MASK cpu_to_be16(0xffff)
1326 #define EN_ETHTOOL_WORD_MASK cpu_to_be32(0xffffffff)
1327
1328 -static int mlx4_en_moderation_update(struct mlx4_en_priv *priv)
1329 +int mlx4_en_moderation_update(struct mlx4_en_priv *priv)
1330 {
1331 int i;
1332 int err = 0;
1333 diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
1334 index 1cfa30e86328f..543f30dec4a0c 100644
1335 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
1336 +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
1337 @@ -3459,6 +3459,8 @@ int mlx4_en_reset_config(struct net_device *dev,
1338 en_err(priv, "Failed starting port\n");
1339 }
1340
1341 + if (!err)
1342 + err = mlx4_en_moderation_update(priv);
1343 out:
1344 mutex_unlock(&mdev->state_lock);
1345 kfree(tmp);
1346 diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
1347 index 93780f63192af..2e8c138beaf72 100644
1348 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
1349 +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
1350 @@ -773,6 +773,7 @@ void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev);
1351 #define DEV_FEATURE_CHANGED(dev, new_features, feature) \
1352 ((dev->features & feature) ^ (new_features & feature))
1353
1354 +int mlx4_en_moderation_update(struct mlx4_en_priv *priv);
1355 int mlx4_en_reset_config(struct net_device *dev,
1356 struct hwtstamp_config ts_config,
1357 netdev_features_t new_features);
1358 diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
1359 index 7458b1a70e5d6..0e5b1935af50e 100644
1360 --- a/drivers/net/ethernet/renesas/sh_eth.c
1361 +++ b/drivers/net/ethernet/renesas/sh_eth.c
1362 @@ -526,6 +526,8 @@ static struct sh_eth_cpu_data r7s72100_data = {
1363 EESR_TDE | EESR_ECI,
1364 .fdr_value = 0x0000070f,
1365
1366 + .trscer_err_mask = DESC_I_RINT8 | DESC_I_RINT5,
1367 +
1368 .no_psr = 1,
1369 .apr = 1,
1370 .mpr = 1,
1371 diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
1372 index ef746ba74ab4c..666bbacb8cb49 100644
1373 --- a/drivers/net/wan/lapbether.c
1374 +++ b/drivers/net/wan/lapbether.c
1375 @@ -286,7 +286,6 @@ static int lapbeth_open(struct net_device *dev)
1376 return -ENODEV;
1377 }
1378
1379 - netif_start_queue(dev);
1380 return 0;
1381 }
1382
1383 @@ -294,8 +293,6 @@ static int lapbeth_close(struct net_device *dev)
1384 {
1385 int err;
1386
1387 - netif_stop_queue(dev);
1388 -
1389 if ((err = lapb_unregister(dev)) != LAPB_OK)
1390 pr_err("lapb_unregister error: %d\n", err);
1391
1392 diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
1393 index 7bda18c61eb6e..beaeb5d07c7e3 100644
1394 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
1395 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
1396 @@ -179,7 +179,8 @@ struct ath_frame_info {
1397 s8 txq;
1398 u8 keyix;
1399 u8 rtscts_rate;
1400 - u8 retries : 7;
1401 + u8 retries : 6;
1402 + u8 dyn_smps : 1;
1403 u8 baw_tracked : 1;
1404 u8 tx_power;
1405 enum ath9k_key_type keytype:2;
1406 diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
1407 index 0ef27d99bef33..101bd6547265a 100644
1408 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1409 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1410 @@ -1255,6 +1255,11 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,
1411 is_40, is_sgi, is_sp);
1412 if (rix < 8 && (tx_info->flags & IEEE80211_TX_CTL_STBC))
1413 info->rates[i].RateFlags |= ATH9K_RATESERIES_STBC;
1414 + if (rix >= 8 && fi->dyn_smps) {
1415 + info->rates[i].RateFlags |=
1416 + ATH9K_RATESERIES_RTS_CTS;
1417 + info->flags |= ATH9K_TXDESC_CTSENA;
1418 + }
1419
1420 info->txpower[i] = ath_get_rate_txpower(sc, bf, rix,
1421 is_40, false);
1422 @@ -2158,6 +2163,7 @@ static void setup_frame_info(struct ieee80211_hw *hw,
1423 fi->keyix = an->ps_key;
1424 else
1425 fi->keyix = ATH9K_TXKEYIX_INVALID;
1426 + fi->dyn_smps = sta && sta->smps_mode == IEEE80211_SMPS_DYNAMIC;
1427 fi->keytype = keytype;
1428 fi->framelen = framelen;
1429 fi->tx_power = txpower;
1430 diff --git a/drivers/pci/host/pci-xgene-msi.c b/drivers/pci/host/pci-xgene-msi.c
1431 index a6456b5782692..b6a099371ad24 100644
1432 --- a/drivers/pci/host/pci-xgene-msi.c
1433 +++ b/drivers/pci/host/pci-xgene-msi.c
1434 @@ -393,13 +393,9 @@ static int xgene_msi_hwirq_alloc(unsigned int cpu)
1435 if (!msi_group->gic_irq)
1436 continue;
1437
1438 - irq_set_chained_handler(msi_group->gic_irq,
1439 - xgene_msi_isr);
1440 - err = irq_set_handler_data(msi_group->gic_irq, msi_group);
1441 - if (err) {
1442 - pr_err("failed to register GIC IRQ handler\n");
1443 - return -EINVAL;
1444 - }
1445 + irq_set_chained_handler_and_data(msi_group->gic_irq,
1446 + xgene_msi_isr, msi_group);
1447 +
1448 /*
1449 * Statically allocate MSI GIC IRQs to each CPU core.
1450 * With 8-core X-Gene v1, 2 MSI GIC IRQs are allocated
1451 diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
1452 index 0da246505f70f..b72d4243bfb9b 100644
1453 --- a/drivers/s390/block/dasd.c
1454 +++ b/drivers/s390/block/dasd.c
1455 @@ -3399,8 +3399,6 @@ void dasd_generic_remove(struct ccw_device *cdev)
1456 struct dasd_device *device;
1457 struct dasd_block *block;
1458
1459 - cdev->handler = NULL;
1460 -
1461 device = dasd_device_from_cdev(cdev);
1462 if (IS_ERR(device)) {
1463 dasd_remove_sysfs_files(cdev);
1464 @@ -3419,6 +3417,7 @@ void dasd_generic_remove(struct ccw_device *cdev)
1465 * no quite down yet.
1466 */
1467 dasd_set_target_state(device, DASD_STATE_NEW);
1468 + cdev->handler = NULL;
1469 /* dasd_delete_device destroys the device reference. */
1470 block = device->block;
1471 dasd_delete_device(device);
1472 diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
1473 index b9c924bb6e3dd..50e2943c33377 100644
1474 --- a/drivers/scsi/libiscsi.c
1475 +++ b/drivers/scsi/libiscsi.c
1476 @@ -1568,14 +1568,9 @@ check_mgmt:
1477 }
1478 rc = iscsi_prep_scsi_cmd_pdu(conn->task);
1479 if (rc) {
1480 - if (rc == -ENOMEM || rc == -EACCES) {
1481 - spin_lock_bh(&conn->taskqueuelock);
1482 - list_add_tail(&conn->task->running,
1483 - &conn->cmdqueue);
1484 - conn->task = NULL;
1485 - spin_unlock_bh(&conn->taskqueuelock);
1486 - goto done;
1487 - } else
1488 + if (rc == -ENOMEM || rc == -EACCES)
1489 + fail_scsi_task(conn->task, DID_IMM_RETRY);
1490 + else
1491 fail_scsi_task(conn->task, DID_ABORT);
1492 spin_lock_bh(&conn->taskqueuelock);
1493 continue;
1494 diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c
1495 index 536a135cd00b3..9058ef473c336 100644
1496 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c
1497 +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c
1498 @@ -269,6 +269,7 @@ static irqreturn_t apci1032_interrupt(int irq, void *d)
1499 struct apci1032_private *devpriv = dev->private;
1500 struct comedi_subdevice *s = dev->read_subdev;
1501 unsigned int ctrl;
1502 + unsigned short val;
1503
1504 /* check interrupt is from this device */
1505 if ((inl(devpriv->amcc_iobase + AMCC_OP_REG_INTCSR) &
1506 @@ -284,7 +285,8 @@ static irqreturn_t apci1032_interrupt(int irq, void *d)
1507 outl(ctrl & ~APCI1032_CTRL_INT_ENA, dev->iobase + APCI1032_CTRL_REG);
1508
1509 s->state = inl(dev->iobase + APCI1032_STATUS_REG) & 0xffff;
1510 - comedi_buf_write_samples(s, &s->state, 1);
1511 + val = s->state;
1512 + comedi_buf_write_samples(s, &val, 1);
1513 comedi_handle_events(dev, s);
1514
1515 /* enable the interrupt */
1516 diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c
1517 index c4e36fb6df9d5..1f25f565041cb 100644
1518 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c
1519 +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c
1520 @@ -217,7 +217,7 @@ static irqreturn_t apci1500_interrupt(int irq, void *d)
1521 struct comedi_device *dev = d;
1522 struct apci1500_private *devpriv = dev->private;
1523 struct comedi_subdevice *s = dev->read_subdev;
1524 - unsigned int status = 0;
1525 + unsigned short status = 0;
1526 unsigned int val;
1527
1528 val = inl(devpriv->amcc + AMCC_OP_REG_INTCSR);
1529 @@ -247,14 +247,14 @@ static irqreturn_t apci1500_interrupt(int irq, void *d)
1530 *
1531 * Mask Meaning
1532 * ---------- ------------------------------------------
1533 - * 0x00000001 Event 1 has occurred
1534 - * 0x00000010 Event 2 has occurred
1535 - * 0x00000100 Counter/timer 1 has run down (not implemented)
1536 - * 0x00001000 Counter/timer 2 has run down (not implemented)
1537 - * 0x00010000 Counter 3 has run down (not implemented)
1538 - * 0x00100000 Watchdog has run down (not implemented)
1539 - * 0x01000000 Voltage error
1540 - * 0x10000000 Short-circuit error
1541 + * 0b00000001 Event 1 has occurred
1542 + * 0b00000010 Event 2 has occurred
1543 + * 0b00000100 Counter/timer 1 has run down (not implemented)
1544 + * 0b00001000 Counter/timer 2 has run down (not implemented)
1545 + * 0b00010000 Counter 3 has run down (not implemented)
1546 + * 0b00100000 Watchdog has run down (not implemented)
1547 + * 0b01000000 Voltage error
1548 + * 0b10000000 Short-circuit error
1549 */
1550 comedi_buf_write_samples(s, &status, 1);
1551 comedi_handle_events(dev, s);
1552 diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c
1553 index 385e14269870d..2b408c893ed63 100644
1554 --- a/drivers/staging/comedi/drivers/adv_pci1710.c
1555 +++ b/drivers/staging/comedi/drivers/adv_pci1710.c
1556 @@ -299,11 +299,11 @@ static int pci1710_ai_eoc(struct comedi_device *dev,
1557 static int pci1710_ai_read_sample(struct comedi_device *dev,
1558 struct comedi_subdevice *s,
1559 unsigned int cur_chan,
1560 - unsigned int *val)
1561 + unsigned short *val)
1562 {
1563 const struct boardtype *board = dev->board_ptr;
1564 struct pci1710_private *devpriv = dev->private;
1565 - unsigned int sample;
1566 + unsigned short sample;
1567 unsigned int chan;
1568
1569 sample = inw(dev->iobase + PCI171X_AD_DATA_REG);
1570 @@ -344,7 +344,7 @@ static int pci1710_ai_insn_read(struct comedi_device *dev,
1571 pci1710_ai_setup_chanlist(dev, s, &insn->chanspec, 1, 1);
1572
1573 for (i = 0; i < insn->n; i++) {
1574 - unsigned int val;
1575 + unsigned short val;
1576
1577 /* start conversion */
1578 outw(0, dev->iobase + PCI171X_SOFTTRG_REG);
1579 @@ -394,7 +394,7 @@ static void pci1710_handle_every_sample(struct comedi_device *dev,
1580 {
1581 struct comedi_cmd *cmd = &s->async->cmd;
1582 unsigned int status;
1583 - unsigned int val;
1584 + unsigned short val;
1585 int ret;
1586
1587 status = inw(dev->iobase + PCI171X_STATUS_REG);
1588 @@ -454,7 +454,7 @@ static void pci1710_handle_fifo(struct comedi_device *dev,
1589 }
1590
1591 for (i = 0; i < devpriv->max_samples; i++) {
1592 - unsigned int val;
1593 + unsigned short val;
1594 int ret;
1595
1596 ret = pci1710_ai_read_sample(dev, s, s->async->cur_chan, &val);
1597 diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c
1598 index 0fdf5e02182fb..c27dbd55564c9 100644
1599 --- a/drivers/staging/comedi/drivers/das6402.c
1600 +++ b/drivers/staging/comedi/drivers/das6402.c
1601 @@ -195,7 +195,7 @@ static irqreturn_t das6402_interrupt(int irq, void *d)
1602 if (status & DAS6402_STATUS_FFULL) {
1603 async->events |= COMEDI_CB_OVERFLOW;
1604 } else if (status & DAS6402_STATUS_FFNE) {
1605 - unsigned int val;
1606 + unsigned short val;
1607
1608 val = das6402_ai_read_sample(dev, s);
1609 comedi_buf_write_samples(s, &val, 1);
1610 diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c
1611 index fd4cb4911671c..3bdaedc6d864e 100644
1612 --- a/drivers/staging/comedi/drivers/das800.c
1613 +++ b/drivers/staging/comedi/drivers/das800.c
1614 @@ -436,7 +436,7 @@ static irqreturn_t das800_interrupt(int irq, void *d)
1615 struct comedi_cmd *cmd;
1616 unsigned long irq_flags;
1617 unsigned int status;
1618 - unsigned int val;
1619 + unsigned short val;
1620 bool fifo_empty;
1621 bool fifo_overflow;
1622 int i;
1623 diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c
1624 index b8606ded06232..a2e3240b66a8c 100644
1625 --- a/drivers/staging/comedi/drivers/dmm32at.c
1626 +++ b/drivers/staging/comedi/drivers/dmm32at.c
1627 @@ -413,7 +413,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
1628 {
1629 struct comedi_device *dev = d;
1630 unsigned char intstat;
1631 - unsigned int val;
1632 + unsigned short val;
1633 int i;
1634
1635 if (!dev->attached) {
1636 diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c
1637 index 15a53204a36a5..4fe856128870b 100644
1638 --- a/drivers/staging/comedi/drivers/me4000.c
1639 +++ b/drivers/staging/comedi/drivers/me4000.c
1640 @@ -933,7 +933,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
1641 struct comedi_subdevice *s = dev->read_subdev;
1642 int i;
1643 int c = 0;
1644 - unsigned int lval;
1645 + unsigned short lval;
1646
1647 if (!dev->attached)
1648 return IRQ_NONE;
1649 diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c
1650 index 3774daa9d6615..e1334733abe77 100644
1651 --- a/drivers/staging/comedi/drivers/pcl711.c
1652 +++ b/drivers/staging/comedi/drivers/pcl711.c
1653 @@ -193,7 +193,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)
1654 struct comedi_device *dev = d;
1655 struct comedi_subdevice *s = dev->read_subdev;
1656 struct comedi_cmd *cmd = &s->async->cmd;
1657 - unsigned int data;
1658 + unsigned short data;
1659
1660 if (!dev->attached) {
1661 dev_err(dev->class_dev, "spurious interrupt\n");
1662 diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c
1663 index 5aeed44dff706..f062417123087 100644
1664 --- a/drivers/staging/comedi/drivers/pcl818.c
1665 +++ b/drivers/staging/comedi/drivers/pcl818.c
1666 @@ -422,7 +422,7 @@ static int pcl818_ai_eoc(struct comedi_device *dev,
1667
1668 static bool pcl818_ai_write_sample(struct comedi_device *dev,
1669 struct comedi_subdevice *s,
1670 - unsigned int chan, unsigned int val)
1671 + unsigned int chan, unsigned short val)
1672 {
1673 struct pcl818_private *devpriv = dev->private;
1674 struct comedi_cmd *cmd = &s->async->cmd;
1675 diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
1676 index b2b4fa4c38342..498ea7754dccf 100644
1677 --- a/drivers/staging/ks7010/ks_wlan_net.c
1678 +++ b/drivers/staging/ks7010/ks_wlan_net.c
1679 @@ -1404,6 +1404,7 @@ static int ks_wlan_set_scan(struct net_device *dev,
1680 struct ks_wlan_private *priv =
1681 (struct ks_wlan_private *)netdev_priv(dev);
1682 struct iw_scan_req *req = NULL;
1683 + int len;
1684 DPRINTK(2, "\n");
1685
1686 if (priv->sleep_mode == SLP_SLEEP) {
1687 @@ -1415,8 +1416,9 @@ static int ks_wlan_set_scan(struct net_device *dev,
1688 if (wrqu->data.length == sizeof(struct iw_scan_req)
1689 && wrqu->data.flags & IW_SCAN_THIS_ESSID) {
1690 req = (struct iw_scan_req *)extra;
1691 - priv->scan_ssid_len = req->essid_len;
1692 - memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len);
1693 + len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE);
1694 + priv->scan_ssid_len = len;
1695 + memcpy(priv->scan_ssid, req->essid, len);
1696 } else {
1697 priv->scan_ssid_len = 0;
1698 }
1699 diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c
1700 index 6513ace1fce6c..7dd6b7f19bf6e 100644
1701 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c
1702 +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
1703 @@ -917,6 +917,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
1704 /* SSID */
1705 p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_));
1706 if (p && ie_len > 0) {
1707 + ie_len = min_t(int, ie_len, sizeof(pbss_network->Ssid.Ssid));
1708 memset(&pbss_network->Ssid, 0, sizeof(struct ndis_802_11_ssid));
1709 memcpy(pbss_network->Ssid.Ssid, (p + 2), ie_len);
1710 pbss_network->Ssid.SsidLength = ie_len;
1711 @@ -935,6 +936,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
1712 /* get supported rates */
1713 p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_));
1714 if (p) {
1715 + ie_len = min_t(int, ie_len, NDIS_802_11_LENGTH_RATES_EX);
1716 memcpy(supportRate, p + 2, ie_len);
1717 supportRateNum = ie_len;
1718 }
1719 @@ -942,6 +944,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
1720 /* get ext_supported rates */
1721 p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_);
1722 if (p) {
1723 + ie_len = min_t(int, ie_len,
1724 + NDIS_802_11_LENGTH_RATES_EX - supportRateNum);
1725 memcpy(supportRate + supportRateNum, p + 2, ie_len);
1726 supportRateNum += ie_len;
1727 }
1728 @@ -1057,6 +1061,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
1729 pht_cap->mcs.rx_mask[0] = 0xff;
1730 pht_cap->mcs.rx_mask[1] = 0x0;
1731 }
1732 + ie_len = min_t(int, ie_len, sizeof(pmlmepriv->htpriv.ht_cap));
1733 memcpy(&pmlmepriv->htpriv.ht_cap, p+2, ie_len);
1734 }
1735
1736 diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
1737 index 50793c9df1b37..866f9a571813d 100644
1738 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
1739 +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
1740 @@ -1172,9 +1172,11 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
1741 break;
1742 }
1743 sec_len = *(pos++); len -= 1;
1744 - if (sec_len > 0 && sec_len <= len) {
1745 + if (sec_len > 0 &&
1746 + sec_len <= len &&
1747 + sec_len <= 32) {
1748 ssid[ssid_index].SsidLength = sec_len;
1749 - memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength);
1750 + memcpy(ssid[ssid_index].Ssid, pos, sec_len);
1751 ssid_index++;
1752 }
1753 pos += sec_len;
1754 diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
1755 index 7413a100ca197..fb3291dde3ae4 100644
1756 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
1757 +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
1758 @@ -419,9 +419,10 @@ static int _rtl92e_wx_set_scan(struct net_device *dev,
1759 struct iw_scan_req *req = (struct iw_scan_req *)b;
1760
1761 if (req->essid_len) {
1762 - ieee->current_network.ssid_len = req->essid_len;
1763 - memcpy(ieee->current_network.ssid, req->essid,
1764 - req->essid_len);
1765 + int len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE);
1766 +
1767 + ieee->current_network.ssid_len = len;
1768 + memcpy(ieee->current_network.ssid, req->essid, len);
1769 }
1770 }
1771
1772 diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c
1773 index d2f2f246063fe..65aec3c2f574f 100644
1774 --- a/drivers/staging/rtl8192u/r8192U_wx.c
1775 +++ b/drivers/staging/rtl8192u/r8192U_wx.c
1776 @@ -333,8 +333,10 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
1777 struct iw_scan_req *req = (struct iw_scan_req *)b;
1778
1779 if (req->essid_len) {
1780 - ieee->current_network.ssid_len = req->essid_len;
1781 - memcpy(ieee->current_network.ssid, req->essid, req->essid_len);
1782 + int len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE);
1783 +
1784 + ieee->current_network.ssid_len = len;
1785 + memcpy(ieee->current_network.ssid, req->essid, len);
1786 }
1787 }
1788
1789 diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c
1790 index b7ee5e63af33a..166f5151e2b8c 100644
1791 --- a/drivers/staging/rtl8712/rtl871x_cmd.c
1792 +++ b/drivers/staging/rtl8712/rtl871x_cmd.c
1793 @@ -239,8 +239,10 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
1794 psurveyPara->ss_ssidlen = 0;
1795 memset(psurveyPara->ss_ssid, 0, IW_ESSID_MAX_SIZE + 1);
1796 if ((pssid != NULL) && (pssid->SsidLength)) {
1797 - memcpy(psurveyPara->ss_ssid, pssid->Ssid, pssid->SsidLength);
1798 - psurveyPara->ss_ssidlen = cpu_to_le32(pssid->SsidLength);
1799 + int len = min_t(int, pssid->SsidLength, IW_ESSID_MAX_SIZE);
1800 +
1801 + memcpy(psurveyPara->ss_ssid, pssid->Ssid, len);
1802 + psurveyPara->ss_ssidlen = cpu_to_le32(len);
1803 }
1804 set_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
1805 r8712_enqueue_cmd(pcmdpriv, ph2c);
1806 diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
1807 index 2d26f9a30fcf7..af190b3863c8f 100644
1808 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
1809 +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
1810 @@ -932,7 +932,7 @@ static int r871x_wx_set_priv(struct net_device *dev,
1811 struct iw_point *dwrq = (struct iw_point *)awrq;
1812
1813 len = dwrq->length;
1814 - ext = memdup_user(dwrq->pointer, len);
1815 + ext = strndup_user(dwrq->pointer, len);
1816 if (IS_ERR(ext))
1817 return PTR_ERR(ext);
1818
1819 diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
1820 index a251514a0ee95..9f1a1a318a3df 100644
1821 --- a/drivers/usb/class/cdc-acm.c
1822 +++ b/drivers/usb/class/cdc-acm.c
1823 @@ -1883,6 +1883,11 @@ static const struct usb_device_id acm_ids[] = {
1824 .driver_info = SEND_ZERO_PACKET,
1825 },
1826
1827 + /* Exclude Goodix Fingerprint Reader */
1828 + { USB_DEVICE(0x27c6, 0x5395),
1829 + .driver_info = IGNORE_DEVICE,
1830 + },
1831 +
1832 /* control interfaces without any protocol set */
1833 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
1834 USB_CDC_PROTO_NONE) },
1835 diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
1836 index af7fd0185a44e..62a38fabd2b56 100644
1837 --- a/drivers/usb/gadget/function/f_uac2.c
1838 +++ b/drivers/usb/gadget/function/f_uac2.c
1839 @@ -997,7 +997,7 @@ static int set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
1840 }
1841
1842 max_size_bw = num_channels(chmask) * ssize *
1843 - DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1)));
1844 + ((srate / (factor / (1 << (ep_desc->bInterval - 1)))) + 1);
1845 ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_size_bw,
1846 max_size_ep));
1847
1848 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
1849 index b0e1d3da2e7ed..809f5f2b0dd9f 100644
1850 --- a/drivers/usb/host/xhci.c
1851 +++ b/drivers/usb/host/xhci.c
1852 @@ -1022,6 +1022,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1853 struct usb_hcd *secondary_hcd;
1854 int retval = 0;
1855 bool comp_timer_running = false;
1856 + bool pending_portevent = false;
1857
1858 if (!hcd->state)
1859 return 0;
1860 @@ -1155,13 +1156,22 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1861
1862 done:
1863 if (retval == 0) {
1864 - /* Resume root hubs only when have pending events. */
1865 - if (xhci_pending_portevent(xhci)) {
1866 + /*
1867 + * Resume roothubs only if there are pending events.
1868 + * USB 3 devices resend U3 LFPS wake after a 100ms delay if
1869 + * the first wake signalling failed, give it that chance.
1870 + */
1871 + pending_portevent = xhci_pending_portevent(xhci);
1872 + if (!pending_portevent) {
1873 + msleep(120);
1874 + pending_portevent = xhci_pending_portevent(xhci);
1875 + }
1876 +
1877 + if (pending_portevent) {
1878 usb_hcd_resume_root_hub(xhci->shared_hcd);
1879 usb_hcd_resume_root_hub(hcd);
1880 }
1881 }
1882 -
1883 /*
1884 * If system is subject to the Quirk, Compliance Mode Timer needs to
1885 * be re-initialized Always after a system resume. Ports are subject
1886 diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c
1887 index 8db4ca7d5d451..e8b0a9c34d725 100644
1888 --- a/drivers/usb/renesas_usbhs/pipe.c
1889 +++ b/drivers/usb/renesas_usbhs/pipe.c
1890 @@ -746,6 +746,8 @@ struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv,
1891
1892 void usbhs_pipe_free(struct usbhs_pipe *pipe)
1893 {
1894 + usbhsp_pipe_select(pipe);
1895 + usbhsp_pipe_cfg_set(pipe, 0xFFFF, 0);
1896 usbhsp_put_pipe(pipe);
1897 }
1898
1899 diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
1900 index fc1c8f4f34c18..c6ff79360302f 100644
1901 --- a/drivers/usb/serial/ch341.c
1902 +++ b/drivers/usb/serial/ch341.c
1903 @@ -75,6 +75,7 @@ static const struct usb_device_id id_table[] = {
1904 { USB_DEVICE(0x1a86, 0x7522) },
1905 { USB_DEVICE(0x1a86, 0x7523) },
1906 { USB_DEVICE(0x4348, 0x5523) },
1907 + { USB_DEVICE(0x9986, 0x7523) },
1908 { },
1909 };
1910 MODULE_DEVICE_TABLE(usb, id_table);
1911 diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
1912 index 1847074b4d819..7eb83a1a43c26 100644
1913 --- a/drivers/usb/serial/cp210x.c
1914 +++ b/drivers/usb/serial/cp210x.c
1915 @@ -143,6 +143,7 @@ static const struct usb_device_id id_table[] = {
1916 { USB_DEVICE(0x10C4, 0x8857) }, /* CEL EM357 ZigBee USB Stick */
1917 { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */
1918 { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */
1919 + { USB_DEVICE(0x10C4, 0x88D8) }, /* Acuity Brands nLight Air Adapter */
1920 { USB_DEVICE(0x10C4, 0x88FB) }, /* CESINEL MEDCAL STII Network Analyzer */
1921 { USB_DEVICE(0x10C4, 0x8938) }, /* CESINEL MEDCAL S II Network Analyzer */
1922 { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */
1923 @@ -199,6 +200,8 @@ static const struct usb_device_id id_table[] = {
1924 { USB_DEVICE(0x1901, 0x0194) }, /* GE Healthcare Remote Alarm Box */
1925 { USB_DEVICE(0x1901, 0x0195) }, /* GE B850/B650/B450 CP2104 DP UART interface */
1926 { USB_DEVICE(0x1901, 0x0196) }, /* GE B850 CP2105 DP UART interface */
1927 + { USB_DEVICE(0x1901, 0x0197) }, /* GE CS1000 Display serial interface */
1928 + { USB_DEVICE(0x1901, 0x0198) }, /* GE CS1000 M.2 Key E serial interface */
1929 { USB_DEVICE(0x199B, 0xBA30) }, /* LORD WSDA-200-USB */
1930 { USB_DEVICE(0x19CF, 0x3000) }, /* Parrot NMEA GPS Flight Recorder */
1931 { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
1932 diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
1933 index 77555242e2595..ceece1f52c8a7 100644
1934 --- a/drivers/usb/serial/io_edgeport.c
1935 +++ b/drivers/usb/serial/io_edgeport.c
1936 @@ -2959,26 +2959,32 @@ static int edge_startup(struct usb_serial *serial)
1937 response = -ENODEV;
1938 }
1939
1940 - usb_free_urb(edge_serial->interrupt_read_urb);
1941 - kfree(edge_serial->interrupt_in_buffer);
1942 -
1943 - usb_free_urb(edge_serial->read_urb);
1944 - kfree(edge_serial->bulk_in_buffer);
1945 -
1946 - kfree(edge_serial);
1947 -
1948 - return response;
1949 + goto error;
1950 }
1951
1952 /* start interrupt read for this edgeport this interrupt will
1953 * continue as long as the edgeport is connected */
1954 response = usb_submit_urb(edge_serial->interrupt_read_urb,
1955 GFP_KERNEL);
1956 - if (response)
1957 + if (response) {
1958 dev_err(ddev, "%s - Error %d submitting control urb\n",
1959 __func__, response);
1960 +
1961 + goto error;
1962 + }
1963 }
1964 return response;
1965 +
1966 +error:
1967 + usb_free_urb(edge_serial->interrupt_read_urb);
1968 + kfree(edge_serial->interrupt_in_buffer);
1969 +
1970 + usb_free_urb(edge_serial->read_urb);
1971 + kfree(edge_serial->bulk_in_buffer);
1972 +
1973 + kfree(edge_serial);
1974 +
1975 + return response;
1976 }
1977
1978
1979 diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
1980 index a5a6a114219ad..6b643e6c8f0bd 100644
1981 --- a/drivers/usb/usbip/stub_dev.c
1982 +++ b/drivers/usb/usbip/stub_dev.c
1983 @@ -60,6 +60,8 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
1984 int sockfd = 0;
1985 struct socket *socket;
1986 int rv;
1987 + struct task_struct *tcp_rx = NULL;
1988 + struct task_struct *tcp_tx = NULL;
1989
1990 if (!sdev) {
1991 dev_err(dev, "sdev is null\n");
1992 @@ -83,23 +85,47 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
1993 }
1994
1995 socket = sockfd_lookup(sockfd, &err);
1996 - if (!socket)
1997 + if (!socket) {
1998 + dev_err(dev, "failed to lookup sock");
1999 goto err;
2000 + }
2001
2002 - sdev->ud.tcp_socket = socket;
2003 - sdev->ud.sockfd = sockfd;
2004 + if (socket->type != SOCK_STREAM) {
2005 + dev_err(dev, "Expecting SOCK_STREAM - found %d",
2006 + socket->type);
2007 + goto sock_err;
2008 + }
2009
2010 + /* unlock and create threads and get tasks */
2011 spin_unlock_irq(&sdev->ud.lock);
2012 + tcp_rx = kthread_create(stub_rx_loop, &sdev->ud, "stub_rx");
2013 + if (IS_ERR(tcp_rx)) {
2014 + sockfd_put(socket);
2015 + return -EINVAL;
2016 + }
2017 + tcp_tx = kthread_create(stub_tx_loop, &sdev->ud, "stub_tx");
2018 + if (IS_ERR(tcp_tx)) {
2019 + kthread_stop(tcp_rx);
2020 + sockfd_put(socket);
2021 + return -EINVAL;
2022 + }
2023
2024 - sdev->ud.tcp_rx = kthread_get_run(stub_rx_loop, &sdev->ud,
2025 - "stub_rx");
2026 - sdev->ud.tcp_tx = kthread_get_run(stub_tx_loop, &sdev->ud,
2027 - "stub_tx");
2028 + /* get task structs now */
2029 + get_task_struct(tcp_rx);
2030 + get_task_struct(tcp_tx);
2031
2032 + /* lock and update sdev->ud state */
2033 spin_lock_irq(&sdev->ud.lock);
2034 + sdev->ud.tcp_socket = socket;
2035 + sdev->ud.sockfd = sockfd;
2036 + sdev->ud.tcp_rx = tcp_rx;
2037 + sdev->ud.tcp_tx = tcp_tx;
2038 sdev->ud.status = SDEV_ST_USED;
2039 spin_unlock_irq(&sdev->ud.lock);
2040
2041 + wake_up_process(sdev->ud.tcp_rx);
2042 + wake_up_process(sdev->ud.tcp_tx);
2043 +
2044 } else {
2045 dev_info(dev, "stub down\n");
2046
2047 @@ -114,6 +140,8 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
2048
2049 return count;
2050
2051 +sock_err:
2052 + sockfd_put(socket);
2053 err:
2054 spin_unlock_irq(&sdev->ud.lock);
2055 return -EINVAL;
2056 diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
2057 index e8a008de8dbc8..ca00d38d22afd 100644
2058 --- a/drivers/usb/usbip/vhci_sysfs.c
2059 +++ b/drivers/usb/usbip/vhci_sysfs.c
2060 @@ -278,6 +278,8 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
2061 struct vhci_device *vdev;
2062 int err;
2063 unsigned long flags;
2064 + struct task_struct *tcp_rx = NULL;
2065 + struct task_struct *tcp_tx = NULL;
2066
2067 /*
2068 * @rhport: port number of vhci_hcd
2069 @@ -309,12 +311,35 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
2070
2071 /* Extract socket from fd. */
2072 socket = sockfd_lookup(sockfd, &err);
2073 - if (!socket)
2074 + if (!socket) {
2075 + dev_err(dev, "failed to lookup sock");
2076 return -EINVAL;
2077 + }
2078 + if (socket->type != SOCK_STREAM) {
2079 + dev_err(dev, "Expecting SOCK_STREAM - found %d",
2080 + socket->type);
2081 + sockfd_put(socket);
2082 + return -EINVAL;
2083 + }
2084 +
2085 + /* create threads before locking */
2086 + tcp_rx = kthread_create(vhci_rx_loop, &vdev->ud, "vhci_rx");
2087 + if (IS_ERR(tcp_rx)) {
2088 + sockfd_put(socket);
2089 + return -EINVAL;
2090 + }
2091 + tcp_tx = kthread_create(vhci_tx_loop, &vdev->ud, "vhci_tx");
2092 + if (IS_ERR(tcp_tx)) {
2093 + kthread_stop(tcp_rx);
2094 + sockfd_put(socket);
2095 + return -EINVAL;
2096 + }
2097
2098 - /* now need lock until setting vdev status as used */
2099 + /* get task structs now */
2100 + get_task_struct(tcp_rx);
2101 + get_task_struct(tcp_tx);
2102
2103 - /* begin a lock */
2104 + /* now begin lock until setting vdev status set */
2105 spin_lock_irqsave(&vhci->lock, flags);
2106 spin_lock(&vdev->ud.lock);
2107
2108 @@ -324,6 +349,8 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
2109 spin_unlock_irqrestore(&vhci->lock, flags);
2110
2111 sockfd_put(socket);
2112 + kthread_stop_put(tcp_rx);
2113 + kthread_stop_put(tcp_tx);
2114
2115 dev_err(dev, "port %d already used\n", rhport);
2116 return -EINVAL;
2117 @@ -338,14 +365,16 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
2118 vdev->speed = speed;
2119 vdev->ud.sockfd = sockfd;
2120 vdev->ud.tcp_socket = socket;
2121 + vdev->ud.tcp_rx = tcp_rx;
2122 + vdev->ud.tcp_tx = tcp_tx;
2123 vdev->ud.status = VDEV_ST_NOTASSIGNED;
2124
2125 spin_unlock(&vdev->ud.lock);
2126 spin_unlock_irqrestore(&vhci->lock, flags);
2127 /* end the lock */
2128
2129 - vdev->ud.tcp_rx = kthread_get_run(vhci_rx_loop, &vdev->ud, "vhci_rx");
2130 - vdev->ud.tcp_tx = kthread_get_run(vhci_tx_loop, &vdev->ud, "vhci_tx");
2131 + wake_up_process(vdev->ud.tcp_rx);
2132 + wake_up_process(vdev->ud.tcp_tx);
2133
2134 rh_port_connect(vdev, speed);
2135
2136 diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
2137 index 7efa374a49703..e3f7c76d19562 100644
2138 --- a/drivers/usb/usbip/vudc_sysfs.c
2139 +++ b/drivers/usb/usbip/vudc_sysfs.c
2140 @@ -24,6 +24,7 @@
2141 #include <linux/usb/ch9.h>
2142 #include <linux/sysfs.h>
2143 #include <linux/kthread.h>
2144 +#include <linux/file.h>
2145 #include <linux/byteorder/generic.h>
2146
2147 #include "usbip_common.h"
2148 @@ -150,6 +151,13 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
2149 goto unlock_ud;
2150 }
2151
2152 + if (socket->type != SOCK_STREAM) {
2153 + dev_err(dev, "Expecting SOCK_STREAM - found %d",
2154 + socket->type);
2155 + ret = -EINVAL;
2156 + goto sock_err;
2157 + }
2158 +
2159 udc->ud.tcp_socket = socket;
2160
2161 spin_unlock_irq(&udc->ud.lock);
2162 @@ -189,6 +197,8 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
2163
2164 return count;
2165
2166 +sock_err:
2167 + sockfd_put(socket);
2168 unlock_ud:
2169 spin_unlock_irq(&udc->ud.lock);
2170 unlock:
2171 diff --git a/drivers/xen/events/events_2l.c b/drivers/xen/events/events_2l.c
2172 index c31c08a708be5..ec3417a9e1a4d 100644
2173 --- a/drivers/xen/events/events_2l.c
2174 +++ b/drivers/xen/events/events_2l.c
2175 @@ -46,6 +46,11 @@ static unsigned evtchn_2l_max_channels(void)
2176 return EVTCHN_2L_NR_CHANNELS;
2177 }
2178
2179 +static void evtchn_2l_remove(evtchn_port_t evtchn, unsigned int cpu)
2180 +{
2181 + clear_bit(evtchn, BM(per_cpu(cpu_evtchn_mask, cpu)));
2182 +}
2183 +
2184 static void evtchn_2l_bind_to_cpu(struct irq_info *info, unsigned cpu)
2185 {
2186 clear_bit(info->evtchn, BM(per_cpu(cpu_evtchn_mask, info->cpu)));
2187 @@ -70,12 +75,6 @@ static bool evtchn_2l_is_pending(unsigned port)
2188 return sync_test_bit(port, BM(&s->evtchn_pending[0]));
2189 }
2190
2191 -static bool evtchn_2l_test_and_set_mask(unsigned port)
2192 -{
2193 - struct shared_info *s = HYPERVISOR_shared_info;
2194 - return sync_test_and_set_bit(port, BM(&s->evtchn_mask[0]));
2195 -}
2196 -
2197 static void evtchn_2l_mask(unsigned port)
2198 {
2199 struct shared_info *s = HYPERVISOR_shared_info;
2200 @@ -353,18 +352,27 @@ static void evtchn_2l_resume(void)
2201 EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD);
2202 }
2203
2204 +static int evtchn_2l_percpu_deinit(unsigned int cpu)
2205 +{
2206 + memset(per_cpu(cpu_evtchn_mask, cpu), 0, sizeof(xen_ulong_t) *
2207 + EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD);
2208 +
2209 + return 0;
2210 +}
2211 +
2212 static const struct evtchn_ops evtchn_ops_2l = {
2213 .max_channels = evtchn_2l_max_channels,
2214 .nr_channels = evtchn_2l_max_channels,
2215 + .remove = evtchn_2l_remove,
2216 .bind_to_cpu = evtchn_2l_bind_to_cpu,
2217 .clear_pending = evtchn_2l_clear_pending,
2218 .set_pending = evtchn_2l_set_pending,
2219 .is_pending = evtchn_2l_is_pending,
2220 - .test_and_set_mask = evtchn_2l_test_and_set_mask,
2221 .mask = evtchn_2l_mask,
2222 .unmask = evtchn_2l_unmask,
2223 .handle_events = evtchn_2l_handle_events,
2224 .resume = evtchn_2l_resume,
2225 + .percpu_deinit = evtchn_2l_percpu_deinit,
2226 };
2227
2228 void __init xen_evtchn_2l_init(void)
2229 diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
2230 index 5308bc1e0189d..2adf541196776 100644
2231 --- a/drivers/xen/events/events_base.c
2232 +++ b/drivers/xen/events/events_base.c
2233 @@ -99,6 +99,7 @@ static DEFINE_RWLOCK(evtchn_rwlock);
2234 * evtchn_rwlock
2235 * IRQ-desc lock
2236 * percpu eoi_list_lock
2237 + * irq_info->lock
2238 */
2239
2240 static LIST_HEAD(xen_irq_list_head);
2241 @@ -220,6 +221,8 @@ static int xen_irq_info_common_setup(struct irq_info *info,
2242 info->irq = irq;
2243 info->evtchn = evtchn;
2244 info->cpu = cpu;
2245 + info->mask_reason = EVT_MASK_REASON_EXPLICIT;
2246 + spin_lock_init(&info->lock);
2247
2248 ret = set_evtchn_to_irq(evtchn, irq);
2249 if (ret < 0)
2250 @@ -286,6 +289,7 @@ static int xen_irq_info_pirq_setup(unsigned irq,
2251 static void xen_irq_info_cleanup(struct irq_info *info)
2252 {
2253 set_evtchn_to_irq(info->evtchn, -1);
2254 + xen_evtchn_port_remove(info->evtchn, info->cpu);
2255 info->evtchn = 0;
2256 }
2257
2258 @@ -366,6 +370,34 @@ unsigned int cpu_from_evtchn(unsigned int evtchn)
2259 return ret;
2260 }
2261
2262 +static void do_mask(struct irq_info *info, u8 reason)
2263 +{
2264 + unsigned long flags;
2265 +
2266 + spin_lock_irqsave(&info->lock, flags);
2267 +
2268 + if (!info->mask_reason)
2269 + mask_evtchn(info->evtchn);
2270 +
2271 + info->mask_reason |= reason;
2272 +
2273 + spin_unlock_irqrestore(&info->lock, flags);
2274 +}
2275 +
2276 +static void do_unmask(struct irq_info *info, u8 reason)
2277 +{
2278 + unsigned long flags;
2279 +
2280 + spin_lock_irqsave(&info->lock, flags);
2281 +
2282 + info->mask_reason &= ~reason;
2283 +
2284 + if (!info->mask_reason)
2285 + unmask_evtchn(info->evtchn);
2286 +
2287 + spin_unlock_irqrestore(&info->lock, flags);
2288 +}
2289 +
2290 #ifdef CONFIG_X86
2291 static bool pirq_check_eoi_map(unsigned irq)
2292 {
2293 @@ -501,7 +533,7 @@ static void xen_irq_lateeoi_locked(struct irq_info *info, bool spurious)
2294 }
2295
2296 info->eoi_time = 0;
2297 - unmask_evtchn(evtchn);
2298 + do_unmask(info, EVT_MASK_REASON_EOI_PENDING);
2299 }
2300
2301 static void xen_irq_lateeoi_worker(struct work_struct *work)
2302 @@ -670,6 +702,12 @@ static void xen_evtchn_close(unsigned int port)
2303 BUG();
2304 }
2305
2306 +static void event_handler_exit(struct irq_info *info)
2307 +{
2308 + smp_store_release(&info->is_active, 0);
2309 + clear_evtchn(info->evtchn);
2310 +}
2311 +
2312 static void pirq_query_unmask(int irq)
2313 {
2314 struct physdev_irq_status_query irq_status;
2315 @@ -688,7 +726,8 @@ static void pirq_query_unmask(int irq)
2316
2317 static void eoi_pirq(struct irq_data *data)
2318 {
2319 - int evtchn = evtchn_from_irq(data->irq);
2320 + struct irq_info *info = info_for_irq(data->irq);
2321 + int evtchn = info ? info->evtchn : 0;
2322 struct physdev_eoi eoi = { .irq = pirq_from_irq(data->irq) };
2323 int rc = 0;
2324
2325 @@ -697,16 +736,15 @@ static void eoi_pirq(struct irq_data *data)
2326
2327 if (unlikely(irqd_is_setaffinity_pending(data)) &&
2328 likely(!irqd_irq_disabled(data))) {
2329 - int masked = test_and_set_mask(evtchn);
2330 + do_mask(info, EVT_MASK_REASON_TEMPORARY);
2331
2332 - clear_evtchn(evtchn);
2333 + event_handler_exit(info);
2334
2335 irq_move_masked_irq(data);
2336
2337 - if (!masked)
2338 - unmask_evtchn(evtchn);
2339 + do_unmask(info, EVT_MASK_REASON_TEMPORARY);
2340 } else
2341 - clear_evtchn(evtchn);
2342 + event_handler_exit(info);
2343
2344 if (pirq_needs_eoi(data->irq)) {
2345 rc = HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi);
2346 @@ -757,7 +795,8 @@ static unsigned int __startup_pirq(unsigned int irq)
2347 goto err;
2348
2349 out:
2350 - unmask_evtchn(evtchn);
2351 + do_unmask(info, EVT_MASK_REASON_EXPLICIT);
2352 +
2353 eoi_pirq(irq_get_irq_data(irq));
2354
2355 return 0;
2356 @@ -784,7 +823,7 @@ static void shutdown_pirq(struct irq_data *data)
2357 if (!VALID_EVTCHN(evtchn))
2358 return;
2359
2360 - mask_evtchn(evtchn);
2361 + do_mask(info, EVT_MASK_REASON_EXPLICIT);
2362 xen_evtchn_close(evtchn);
2363 xen_irq_info_cleanup(info);
2364 }
2365 @@ -1541,6 +1580,8 @@ void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl)
2366 }
2367
2368 info = info_for_irq(irq);
2369 + if (xchg_acquire(&info->is_active, 1))
2370 + return;
2371
2372 if (ctrl->defer_eoi) {
2373 info->eoi_cpu = smp_processor_id();
2374 @@ -1647,8 +1688,8 @@ void rebind_evtchn_irq(int evtchn, int irq)
2375 static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
2376 {
2377 struct evtchn_bind_vcpu bind_vcpu;
2378 - int evtchn = evtchn_from_irq(irq);
2379 - int masked;
2380 + struct irq_info *info = info_for_irq(irq);
2381 + int evtchn = info ? info->evtchn : 0;
2382
2383 if (!VALID_EVTCHN(evtchn))
2384 return -1;
2385 @@ -1664,7 +1705,7 @@ static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
2386 * Mask the event while changing the VCPU binding to prevent
2387 * it being delivered on an unexpected VCPU.
2388 */
2389 - masked = test_and_set_mask(evtchn);
2390 + do_mask(info, EVT_MASK_REASON_TEMPORARY);
2391
2392 /*
2393 * If this fails, it usually just indicates that we're dealing with a
2394 @@ -1674,8 +1715,7 @@ static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
2395 if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0)
2396 bind_evtchn_to_cpu(evtchn, tcpu);
2397
2398 - if (!masked)
2399 - unmask_evtchn(evtchn);
2400 + do_unmask(info, EVT_MASK_REASON_TEMPORARY);
2401
2402 return 0;
2403 }
2404 @@ -1690,39 +1730,41 @@ static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest,
2405
2406 static void enable_dynirq(struct irq_data *data)
2407 {
2408 - int evtchn = evtchn_from_irq(data->irq);
2409 + struct irq_info *info = info_for_irq(data->irq);
2410 + evtchn_port_t evtchn = info ? info->evtchn : 0;
2411
2412 if (VALID_EVTCHN(evtchn))
2413 - unmask_evtchn(evtchn);
2414 + do_unmask(info, EVT_MASK_REASON_EXPLICIT);
2415 }
2416
2417 static void disable_dynirq(struct irq_data *data)
2418 {
2419 - int evtchn = evtchn_from_irq(data->irq);
2420 + struct irq_info *info = info_for_irq(data->irq);
2421 + evtchn_port_t evtchn = info ? info->evtchn : 0;
2422
2423 if (VALID_EVTCHN(evtchn))
2424 - mask_evtchn(evtchn);
2425 + do_mask(info, EVT_MASK_REASON_EXPLICIT);
2426 }
2427
2428 static void ack_dynirq(struct irq_data *data)
2429 {
2430 - int evtchn = evtchn_from_irq(data->irq);
2431 + struct irq_info *info = info_for_irq(data->irq);
2432 + evtchn_port_t evtchn = info ? info->evtchn : 0;
2433
2434 if (!VALID_EVTCHN(evtchn))
2435 return;
2436
2437 if (unlikely(irqd_is_setaffinity_pending(data)) &&
2438 likely(!irqd_irq_disabled(data))) {
2439 - int masked = test_and_set_mask(evtchn);
2440 + do_mask(info, EVT_MASK_REASON_TEMPORARY);
2441
2442 - clear_evtchn(evtchn);
2443 + event_handler_exit(info);
2444
2445 irq_move_masked_irq(data);
2446
2447 - if (!masked)
2448 - unmask_evtchn(evtchn);
2449 + do_unmask(info, EVT_MASK_REASON_TEMPORARY);
2450 } else
2451 - clear_evtchn(evtchn);
2452 + event_handler_exit(info);
2453 }
2454
2455 static void mask_ack_dynirq(struct irq_data *data)
2456 @@ -1731,18 +1773,39 @@ static void mask_ack_dynirq(struct irq_data *data)
2457 ack_dynirq(data);
2458 }
2459
2460 +static void lateeoi_ack_dynirq(struct irq_data *data)
2461 +{
2462 + struct irq_info *info = info_for_irq(data->irq);
2463 + evtchn_port_t evtchn = info ? info->evtchn : 0;
2464 +
2465 + if (VALID_EVTCHN(evtchn)) {
2466 + do_mask(info, EVT_MASK_REASON_EOI_PENDING);
2467 + event_handler_exit(info);
2468 + }
2469 +}
2470 +
2471 +static void lateeoi_mask_ack_dynirq(struct irq_data *data)
2472 +{
2473 + struct irq_info *info = info_for_irq(data->irq);
2474 + evtchn_port_t evtchn = info ? info->evtchn : 0;
2475 +
2476 + if (VALID_EVTCHN(evtchn)) {
2477 + do_mask(info, EVT_MASK_REASON_EXPLICIT);
2478 + event_handler_exit(info);
2479 + }
2480 +}
2481 +
2482 static int retrigger_dynirq(struct irq_data *data)
2483 {
2484 - unsigned int evtchn = evtchn_from_irq(data->irq);
2485 - int masked;
2486 + struct irq_info *info = info_for_irq(data->irq);
2487 + evtchn_port_t evtchn = info ? info->evtchn : 0;
2488
2489 if (!VALID_EVTCHN(evtchn))
2490 return 0;
2491
2492 - masked = test_and_set_mask(evtchn);
2493 + do_mask(info, EVT_MASK_REASON_TEMPORARY);
2494 set_evtchn(evtchn);
2495 - if (!masked)
2496 - unmask_evtchn(evtchn);
2497 + do_unmask(info, EVT_MASK_REASON_TEMPORARY);
2498
2499 return 1;
2500 }
2501 @@ -1837,10 +1900,11 @@ static void restore_cpu_ipis(unsigned int cpu)
2502 /* Clear an irq's pending state, in preparation for polling on it */
2503 void xen_clear_irq_pending(int irq)
2504 {
2505 - int evtchn = evtchn_from_irq(irq);
2506 + struct irq_info *info = info_for_irq(irq);
2507 + evtchn_port_t evtchn = info ? info->evtchn : 0;
2508
2509 if (VALID_EVTCHN(evtchn))
2510 - clear_evtchn(evtchn);
2511 + event_handler_exit(info);
2512 }
2513 EXPORT_SYMBOL(xen_clear_irq_pending);
2514 void xen_set_irq_pending(int irq)
2515 @@ -1949,8 +2013,8 @@ static struct irq_chip xen_lateeoi_chip __read_mostly = {
2516 .irq_mask = disable_dynirq,
2517 .irq_unmask = enable_dynirq,
2518
2519 - .irq_ack = mask_ack_dynirq,
2520 - .irq_mask_ack = mask_ack_dynirq,
2521 + .irq_ack = lateeoi_ack_dynirq,
2522 + .irq_mask_ack = lateeoi_mask_ack_dynirq,
2523
2524 .irq_set_affinity = set_affinity_irq,
2525 .irq_retrigger = retrigger_dynirq,
2526 diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c
2527 index 0a4fece5fd8d3..3f7d325d2be4e 100644
2528 --- a/drivers/xen/events/events_fifo.c
2529 +++ b/drivers/xen/events/events_fifo.c
2530 @@ -209,12 +209,6 @@ static bool evtchn_fifo_is_pending(unsigned port)
2531 return sync_test_bit(EVTCHN_FIFO_BIT(PENDING, word), BM(word));
2532 }
2533
2534 -static bool evtchn_fifo_test_and_set_mask(unsigned port)
2535 -{
2536 - event_word_t *word = event_word_from_port(port);
2537 - return sync_test_and_set_bit(EVTCHN_FIFO_BIT(MASKED, word), BM(word));
2538 -}
2539 -
2540 static void evtchn_fifo_mask(unsigned port)
2541 {
2542 event_word_t *word = event_word_from_port(port);
2543 @@ -421,7 +415,6 @@ static const struct evtchn_ops evtchn_ops_fifo = {
2544 .clear_pending = evtchn_fifo_clear_pending,
2545 .set_pending = evtchn_fifo_set_pending,
2546 .is_pending = evtchn_fifo_is_pending,
2547 - .test_and_set_mask = evtchn_fifo_test_and_set_mask,
2548 .mask = evtchn_fifo_mask,
2549 .unmask = evtchn_fifo_unmask,
2550 .handle_events = evtchn_fifo_handle_events,
2551 diff --git a/drivers/xen/events/events_internal.h b/drivers/xen/events/events_internal.h
2552 index b9b4f59198930..3df6f28b75e69 100644
2553 --- a/drivers/xen/events/events_internal.h
2554 +++ b/drivers/xen/events/events_internal.h
2555 @@ -35,13 +35,19 @@ struct irq_info {
2556 struct list_head eoi_list;
2557 short refcnt;
2558 short spurious_cnt;
2559 - enum xen_irq_type type; /* type */
2560 + short type; /* type */
2561 + u8 mask_reason; /* Why is event channel masked */
2562 +#define EVT_MASK_REASON_EXPLICIT 0x01
2563 +#define EVT_MASK_REASON_TEMPORARY 0x02
2564 +#define EVT_MASK_REASON_EOI_PENDING 0x04
2565 + u8 is_active; /* Is event just being handled? */
2566 unsigned irq;
2567 unsigned int evtchn; /* event channel */
2568 unsigned short cpu; /* cpu bound */
2569 unsigned short eoi_cpu; /* EOI must happen on this cpu */
2570 unsigned int irq_epoch; /* If eoi_cpu valid: irq_epoch of event */
2571 u64 eoi_time; /* Time in jiffies when to EOI. */
2572 + spinlock_t lock;
2573
2574 union {
2575 unsigned short virq;
2576 @@ -67,12 +73,12 @@ struct evtchn_ops {
2577 unsigned (*nr_channels)(void);
2578
2579 int (*setup)(struct irq_info *info);
2580 + void (*remove)(evtchn_port_t port, unsigned int cpu);
2581 void (*bind_to_cpu)(struct irq_info *info, unsigned cpu);
2582
2583 void (*clear_pending)(unsigned port);
2584 void (*set_pending)(unsigned port);
2585 bool (*is_pending)(unsigned port);
2586 - bool (*test_and_set_mask)(unsigned port);
2587 void (*mask)(unsigned port);
2588 void (*unmask)(unsigned port);
2589
2590 @@ -109,6 +115,13 @@ static inline int xen_evtchn_port_setup(struct irq_info *info)
2591 return 0;
2592 }
2593
2594 +static inline void xen_evtchn_port_remove(evtchn_port_t evtchn,
2595 + unsigned int cpu)
2596 +{
2597 + if (evtchn_ops->remove)
2598 + evtchn_ops->remove(evtchn, cpu);
2599 +}
2600 +
2601 static inline void xen_evtchn_port_bind_to_cpu(struct irq_info *info,
2602 unsigned cpu)
2603 {
2604 @@ -130,11 +143,6 @@ static inline bool test_evtchn(unsigned port)
2605 return evtchn_ops->is_pending(port);
2606 }
2607
2608 -static inline bool test_and_set_mask(unsigned port)
2609 -{
2610 - return evtchn_ops->test_and_set_mask(port);
2611 -}
2612 -
2613 static inline void mask_evtchn(unsigned port)
2614 {
2615 return evtchn_ops->mask(port);
2616 diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
2617 index f842261ce9738..2bda9245cabe5 100644
2618 --- a/fs/binfmt_misc.c
2619 +++ b/fs/binfmt_misc.c
2620 @@ -695,12 +695,24 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
2621 struct super_block *sb = file_inode(file)->i_sb;
2622 struct dentry *root = sb->s_root, *dentry;
2623 int err = 0;
2624 + struct file *f = NULL;
2625
2626 e = create_entry(buffer, count);
2627
2628 if (IS_ERR(e))
2629 return PTR_ERR(e);
2630
2631 + if (e->flags & MISC_FMT_OPEN_FILE) {
2632 + f = open_exec(e->interpreter);
2633 + if (IS_ERR(f)) {
2634 + pr_notice("register: failed to install interpreter file %s\n",
2635 + e->interpreter);
2636 + kfree(e);
2637 + return PTR_ERR(f);
2638 + }
2639 + e->interp_file = f;
2640 + }
2641 +
2642 inode_lock(d_inode(root));
2643 dentry = lookup_one_len(e->name, root, strlen(e->name));
2644 err = PTR_ERR(dentry);
2645 @@ -724,21 +736,6 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
2646 goto out2;
2647 }
2648
2649 - if (e->flags & MISC_FMT_OPEN_FILE) {
2650 - struct file *f;
2651 -
2652 - f = open_exec(e->interpreter);
2653 - if (IS_ERR(f)) {
2654 - err = PTR_ERR(f);
2655 - pr_notice("register: failed to install interpreter file %s\n", e->interpreter);
2656 - simple_release_fs(&bm_mnt, &entry_count);
2657 - iput(inode);
2658 - inode = NULL;
2659 - goto out2;
2660 - }
2661 - e->interp_file = f;
2662 - }
2663 -
2664 e->dentry = dget(dentry);
2665 inode->i_private = e;
2666 inode->i_fop = &bm_entry_operations;
2667 @@ -755,6 +752,8 @@ out:
2668 inode_unlock(d_inode(root));
2669
2670 if (err) {
2671 + if (f)
2672 + filp_close(f, NULL);
2673 kfree(e);
2674 return err;
2675 }
2676 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
2677 index be84d49f24063..375ccd209206a 100644
2678 --- a/fs/cifs/cifsfs.c
2679 +++ b/fs/cifs/cifsfs.c
2680 @@ -208,7 +208,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
2681 rc = server->ops->queryfs(xid, tcon, buf);
2682
2683 free_xid(xid);
2684 - return 0;
2685 + return rc;
2686 }
2687
2688 static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len)
2689 diff --git a/fs/configfs/file.c b/fs/configfs/file.c
2690 index 7285440bc62e8..896e90dc91936 100644
2691 --- a/fs/configfs/file.c
2692 +++ b/fs/configfs/file.c
2693 @@ -392,7 +392,7 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type
2694
2695 attr = to_attr(dentry);
2696 if (!attr)
2697 - goto out_put_item;
2698 + goto out_free_buffer;
2699
2700 if (type & CONFIGFS_ITEM_BIN_ATTR) {
2701 buffer->bin_attr = to_bin_attr(dentry);
2702 @@ -405,7 +405,7 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type
2703 /* Grab the module reference for this attribute if we have one */
2704 error = -ENODEV;
2705 if (!try_module_get(buffer->owner))
2706 - goto out_put_item;
2707 + goto out_free_buffer;
2708
2709 error = -EACCES;
2710 if (!buffer->item->ci_type)
2711 @@ -449,8 +449,6 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type
2712
2713 out_put_module:
2714 module_put(buffer->owner);
2715 -out_put_item:
2716 - config_item_put(buffer->item);
2717 out_free_buffer:
2718 up_read(&frag->frag_sem);
2719 kfree(buffer);
2720 diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
2721 index 2abdb2070c879..0cebe0ca03b2a 100644
2722 --- a/fs/nfs/nfs4proc.c
2723 +++ b/fs/nfs/nfs4proc.c
2724 @@ -5218,7 +5218,7 @@ static int _nfs4_get_security_label(struct inode *inode, void *buf,
2725 return ret;
2726 if (!(fattr.valid & NFS_ATTR_FATTR_V4_SECURITY_LABEL))
2727 return -ENOENT;
2728 - return 0;
2729 + return label.len;
2730 }
2731
2732 static int nfs4_get_security_label(struct inode *inode, void *buf,
2733 diff --git a/fs/udf/inode.c b/fs/udf/inode.c
2734 index 149baf5f3d195..50607673a6a92 100644
2735 --- a/fs/udf/inode.c
2736 +++ b/fs/udf/inode.c
2737 @@ -548,11 +548,14 @@ static int udf_do_extend_file(struct inode *inode,
2738
2739 udf_write_aext(inode, last_pos, &last_ext->extLocation,
2740 last_ext->extLength, 1);
2741 +
2742 /*
2743 - * We've rewritten the last extent but there may be empty
2744 - * indirect extent after it - enter it.
2745 + * We've rewritten the last extent. If we are going to add
2746 + * more extents, we may need to enter possible following
2747 + * empty indirect extent.
2748 */
2749 - udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0);
2750 + if (new_block_bytes || prealloc_len)
2751 + udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0);
2752 }
2753
2754 /* Managed to do everything necessary? */
2755 diff --git a/include/linux/can/skb.h b/include/linux/can/skb.h
2756 index 1a2111c775ae1..0e7350973e0e5 100644
2757 --- a/include/linux/can/skb.h
2758 +++ b/include/linux/can/skb.h
2759 @@ -48,8 +48,12 @@ static inline void can_skb_reserve(struct sk_buff *skb)
2760
2761 static inline void can_skb_set_owner(struct sk_buff *skb, struct sock *sk)
2762 {
2763 - if (sk) {
2764 - sock_hold(sk);
2765 + /* If the socket has already been closed by user space, the
2766 + * refcount may already be 0 (and the socket will be freed
2767 + * after the last TX skb has been freed). So only increase
2768 + * socket refcount if the refcount is > 0.
2769 + */
2770 + if (sk && atomic_inc_not_zero(&sk->sk_refcnt)) {
2771 skb->destructor = sock_efree;
2772 skb->sk = sk;
2773 }
2774 diff --git a/include/uapi/linux/netfilter/nfnetlink_cthelper.h b/include/uapi/linux/netfilter/nfnetlink_cthelper.h
2775 index 33659f6fad3ee..30557bade9354 100644
2776 --- a/include/uapi/linux/netfilter/nfnetlink_cthelper.h
2777 +++ b/include/uapi/linux/netfilter/nfnetlink_cthelper.h
2778 @@ -4,7 +4,7 @@
2779 #define NFCT_HELPER_STATUS_DISABLED 0
2780 #define NFCT_HELPER_STATUS_ENABLED 1
2781
2782 -enum nfnl_acct_msg_types {
2783 +enum nfnl_cthelper_msg_types {
2784 NFNL_MSG_CTHELPER_NEW,
2785 NFNL_MSG_CTHELPER_GET,
2786 NFNL_MSG_CTHELPER_DEL,
2787 diff --git a/mm/slub.c b/mm/slub.c
2788 index 5c48a8a0524a2..0b13135fd5719 100644
2789 --- a/mm/slub.c
2790 +++ b/mm/slub.c
2791 @@ -1833,7 +1833,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n,
2792
2793 t = acquire_slab(s, n, page, object == NULL, &objects);
2794 if (!t)
2795 - continue; /* cmpxchg raced */
2796 + break;
2797
2798 available += objects;
2799 if (!object) {
2800 diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
2801 index f4f616eaaeb81..b1b43d7da91ba 100644
2802 --- a/net/ipv4/udp_offload.c
2803 +++ b/net/ipv4/udp_offload.c
2804 @@ -265,7 +265,7 @@ struct sk_buff **udp_gro_receive(struct sk_buff **head, struct sk_buff *skb,
2805 struct sock *sk;
2806
2807 if (NAPI_GRO_CB(skb)->encap_mark ||
2808 - (skb->ip_summed != CHECKSUM_PARTIAL &&
2809 + (uh->check && skb->ip_summed != CHECKSUM_PARTIAL &&
2810 NAPI_GRO_CB(skb)->csum_cnt == 0 &&
2811 !NAPI_GRO_CB(skb)->csum_valid))
2812 goto out;
2813 diff --git a/net/mpls/mpls_gso.c b/net/mpls/mpls_gso.c
2814 index b4da6d8e8632c..2129856b59330 100644
2815 --- a/net/mpls/mpls_gso.c
2816 +++ b/net/mpls/mpls_gso.c
2817 @@ -18,6 +18,7 @@
2818 #include <linux/netdev_features.h>
2819 #include <linux/netdevice.h>
2820 #include <linux/skbuff.h>
2821 +#include <net/mpls.h>
2822
2823 static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
2824 netdev_features_t features)
2825 @@ -31,6 +32,8 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
2826
2827 skb_reset_network_header(skb);
2828 mpls_hlen = skb_inner_network_header(skb) - skb_network_header(skb);
2829 + if (unlikely(!mpls_hlen || mpls_hlen % MPLS_HLEN))
2830 + goto out;
2831 if (unlikely(!pskb_may_pull(skb, mpls_hlen)))
2832 goto out;
2833
2834 diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
2835 index e065140d0c93b..cef5674ea434c 100644
2836 --- a/net/netfilter/x_tables.c
2837 +++ b/net/netfilter/x_tables.c
2838 @@ -272,6 +272,7 @@ static int match_revfn(u8 af, const char *name, u8 revision, int *bestp)
2839 const struct xt_match *m;
2840 int have_rev = 0;
2841
2842 + mutex_lock(&xt[af].mutex);
2843 list_for_each_entry(m, &xt[af].match, list) {
2844 if (strcmp(m->name, name) == 0) {
2845 if (m->revision > *bestp)
2846 @@ -280,6 +281,7 @@ static int match_revfn(u8 af, const char *name, u8 revision, int *bestp)
2847 have_rev = 1;
2848 }
2849 }
2850 + mutex_unlock(&xt[af].mutex);
2851
2852 if (af != NFPROTO_UNSPEC && !have_rev)
2853 return match_revfn(NFPROTO_UNSPEC, name, revision, bestp);
2854 @@ -292,6 +294,7 @@ static int target_revfn(u8 af, const char *name, u8 revision, int *bestp)
2855 const struct xt_target *t;
2856 int have_rev = 0;
2857
2858 + mutex_lock(&xt[af].mutex);
2859 list_for_each_entry(t, &xt[af].target, list) {
2860 if (strcmp(t->name, name) == 0) {
2861 if (t->revision > *bestp)
2862 @@ -300,6 +303,7 @@ static int target_revfn(u8 af, const char *name, u8 revision, int *bestp)
2863 have_rev = 1;
2864 }
2865 }
2866 + mutex_unlock(&xt[af].mutex);
2867
2868 if (af != NFPROTO_UNSPEC && !have_rev)
2869 return target_revfn(NFPROTO_UNSPEC, name, revision, bestp);
2870 @@ -313,12 +317,10 @@ int xt_find_revision(u8 af, const char *name, u8 revision, int target,
2871 {
2872 int have_rev, best = -1;
2873
2874 - mutex_lock(&xt[af].mutex);
2875 if (target == 1)
2876 have_rev = target_revfn(af, name, revision, &best);
2877 else
2878 have_rev = match_revfn(af, name, revision, &best);
2879 - mutex_unlock(&xt[af].mutex);
2880
2881 /* Nothing at all? Return 0 to try loading module. */
2882 if (best == -1) {
2883 diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
2884 index 45038c837eab4..98d88386d6d51 100644
2885 --- a/net/sched/sch_api.c
2886 +++ b/net/sched/sch_api.c
2887 @@ -1789,7 +1789,7 @@ static int tc_dump_tclass_qdisc(struct Qdisc *q, struct sk_buff *skb,
2888
2889 static int tc_dump_tclass_root(struct Qdisc *root, struct sk_buff *skb,
2890 struct tcmsg *tcm, struct netlink_callback *cb,
2891 - int *t_p, int s_t)
2892 + int *t_p, int s_t, bool recur)
2893 {
2894 struct Qdisc *q;
2895 int b;
2896 @@ -1800,7 +1800,7 @@ static int tc_dump_tclass_root(struct Qdisc *root, struct sk_buff *skb,
2897 if (tc_dump_tclass_qdisc(root, skb, tcm, cb, t_p, s_t) < 0)
2898 return -1;
2899
2900 - if (!qdisc_dev(root))
2901 + if (!qdisc_dev(root) || !recur)
2902 return 0;
2903
2904 hash_for_each(qdisc_dev(root)->qdisc_hash, b, q, hash) {
2905 @@ -1828,13 +1828,13 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
2906 s_t = cb->args[0];
2907 t = 0;
2908
2909 - if (tc_dump_tclass_root(dev->qdisc, skb, tcm, cb, &t, s_t) < 0)
2910 + if (tc_dump_tclass_root(dev->qdisc, skb, tcm, cb, &t, s_t, true) < 0)
2911 goto done;
2912
2913 dev_queue = dev_ingress_queue(dev);
2914 if (dev_queue &&
2915 tc_dump_tclass_root(dev_queue->qdisc_sleeping, skb, tcm, cb,
2916 - &t, s_t) < 0)
2917 + &t, s_t, false) < 0)
2918 goto done;
2919
2920 done:
2921 diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
2922 index 9972141f11aa3..5adff21316c6d 100644
2923 --- a/scripts/recordmcount.c
2924 +++ b/scripts/recordmcount.c
2925 @@ -362,7 +362,7 @@ static uint32_t (*w2)(uint16_t);
2926 static int
2927 is_mcounted_section_name(char const *const txtname)
2928 {
2929 - return strcmp(".text", txtname) == 0 ||
2930 + return strncmp(".text", txtname, 5) == 0 ||
2931 strcmp(".ref.text", txtname) == 0 ||
2932 strcmp(".sched.text", txtname) == 0 ||
2933 strcmp(".spinlock.text", txtname) == 0 ||
2934 diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
2935 index fb0d25ced2fb3..113c7a0718108 100755
2936 --- a/scripts/recordmcount.pl
2937 +++ b/scripts/recordmcount.pl
2938 @@ -140,6 +140,11 @@ my %text_sections = (
2939 ".text.unlikely" => 1,
2940 );
2941
2942 +# Acceptable section-prefixes to record.
2943 +my %text_section_prefixes = (
2944 + ".text." => 1,
2945 +);
2946 +
2947 # Note: we are nice to C-programmers here, thus we skip the '||='-idiom.
2948 $objdump = 'objdump' if (!$objdump);
2949 $objcopy = 'objcopy' if (!$objcopy);
2950 @@ -505,6 +510,14 @@ while (<IN>) {
2951
2952 # Only record text sections that we know are safe
2953 $read_function = defined($text_sections{$1});
2954 + if (!$read_function) {
2955 + foreach my $prefix (keys %text_section_prefixes) {
2956 + if (substr($1, 0, length $prefix) eq $prefix) {
2957 + $read_function = 1;
2958 + last;
2959 + }
2960 + }
2961 + }
2962 # print out any recorded offsets
2963 update_funcs();
2964
2965 diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c
2966 index d0d6dfbfcfdf8..f25c2c43c5626 100644
2967 --- a/sound/pci/hda/hda_bind.c
2968 +++ b/sound/pci/hda/hda_bind.c
2969 @@ -46,6 +46,10 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev)
2970 if (codec->bus->shutdown)
2971 return;
2972
2973 + /* ignore unsol events during system suspend/resume */
2974 + if (codec->core.dev.power.power_state.event != PM_EVENT_ON)
2975 + return;
2976 +
2977 if (codec->patch_ops.unsol_event)
2978 codec->patch_ops.unsol_event(codec, ev);
2979 }
2980 diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
2981 index ba0c3a381933e..8b240a55cb89f 100644
2982 --- a/sound/pci/hda/patch_hdmi.c
2983 +++ b/sound/pci/hda/patch_hdmi.c
2984 @@ -2156,6 +2156,18 @@ static void generic_hdmi_free(struct hda_codec *codec)
2985 }
2986
2987 #ifdef CONFIG_PM
2988 +static int generic_hdmi_suspend(struct hda_codec *codec)
2989 +{
2990 + struct hdmi_spec *spec = codec->spec;
2991 + int pin_idx;
2992 +
2993 + for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
2994 + struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
2995 + cancel_delayed_work_sync(&per_pin->work);
2996 + }
2997 + return 0;
2998 +}
2999 +
3000 static int generic_hdmi_resume(struct hda_codec *codec)
3001 {
3002 struct hdmi_spec *spec = codec->spec;
3003 @@ -2179,6 +2191,7 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = {
3004 .build_controls = generic_hdmi_build_controls,
3005 .unsol_event = hdmi_unsol_event,
3006 #ifdef CONFIG_PM
3007 + .suspend = generic_hdmi_suspend,
3008 .resume = generic_hdmi_resume,
3009 #endif
3010 };
3011 diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
3012 index 66b7ccb33c7b1..664aff41f0718 100644
3013 --- a/sound/usb/quirks.c
3014 +++ b/sound/usb/quirks.c
3015 @@ -1153,6 +1153,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
3016 case USB_ID(0x1de7, 0x0114): /* Phoenix Audio MT202pcs */
3017 case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */
3018 case USB_ID(0x2912, 0x30c8): /* Audioengine D1 */
3019 + case USB_ID(0x413c, 0xa506): /* Dell AE515 sound bar */
3020 return true;
3021 }
3022 return false;