Magellan Linux

Contents of /trunk/kernel-alx/patches-3.18/0110-3.18.11-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2611 - (show annotations) (download)
Mon Jul 13 08:28:35 2015 UTC (8 years, 9 months ago) by niro
File size: 118605 byte(s)
-linux-3.18.11
1 diff --git a/Makefile b/Makefile
2 index d4ce2cb674c8..da8dc1350de3 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 3
7 PATCHLEVEL = 18
8 -SUBLEVEL = 10
9 +SUBLEVEL = 11
10 EXTRAVERSION =
11 NAME = Diseased Newt
12
13 diff --git a/arch/arm/boot/dts/am33xx-clocks.dtsi b/arch/arm/boot/dts/am33xx-clocks.dtsi
14 index 712edce7d6fb..071b56aa0c7e 100644
15 --- a/arch/arm/boot/dts/am33xx-clocks.dtsi
16 +++ b/arch/arm/boot/dts/am33xx-clocks.dtsi
17 @@ -99,7 +99,7 @@
18 ehrpwm0_tbclk: ehrpwm0_tbclk@44e10664 {
19 #clock-cells = <0>;
20 compatible = "ti,gate-clock";
21 - clocks = <&dpll_per_m2_ck>;
22 + clocks = <&l4ls_gclk>;
23 ti,bit-shift = <0>;
24 reg = <0x0664>;
25 };
26 @@ -107,7 +107,7 @@
27 ehrpwm1_tbclk: ehrpwm1_tbclk@44e10664 {
28 #clock-cells = <0>;
29 compatible = "ti,gate-clock";
30 - clocks = <&dpll_per_m2_ck>;
31 + clocks = <&l4ls_gclk>;
32 ti,bit-shift = <1>;
33 reg = <0x0664>;
34 };
35 @@ -115,7 +115,7 @@
36 ehrpwm2_tbclk: ehrpwm2_tbclk@44e10664 {
37 #clock-cells = <0>;
38 compatible = "ti,gate-clock";
39 - clocks = <&dpll_per_m2_ck>;
40 + clocks = <&l4ls_gclk>;
41 ti,bit-shift = <2>;
42 reg = <0x0664>;
43 };
44 diff --git a/arch/arm/boot/dts/am43xx-clocks.dtsi b/arch/arm/boot/dts/am43xx-clocks.dtsi
45 index c7dc9dab93a4..cfb49686ab6a 100644
46 --- a/arch/arm/boot/dts/am43xx-clocks.dtsi
47 +++ b/arch/arm/boot/dts/am43xx-clocks.dtsi
48 @@ -107,7 +107,7 @@
49 ehrpwm0_tbclk: ehrpwm0_tbclk {
50 #clock-cells = <0>;
51 compatible = "ti,gate-clock";
52 - clocks = <&dpll_per_m2_ck>;
53 + clocks = <&l4ls_gclk>;
54 ti,bit-shift = <0>;
55 reg = <0x0664>;
56 };
57 @@ -115,7 +115,7 @@
58 ehrpwm1_tbclk: ehrpwm1_tbclk {
59 #clock-cells = <0>;
60 compatible = "ti,gate-clock";
61 - clocks = <&dpll_per_m2_ck>;
62 + clocks = <&l4ls_gclk>;
63 ti,bit-shift = <1>;
64 reg = <0x0664>;
65 };
66 @@ -123,7 +123,7 @@
67 ehrpwm2_tbclk: ehrpwm2_tbclk {
68 #clock-cells = <0>;
69 compatible = "ti,gate-clock";
70 - clocks = <&dpll_per_m2_ck>;
71 + clocks = <&l4ls_gclk>;
72 ti,bit-shift = <2>;
73 reg = <0x0664>;
74 };
75 @@ -131,7 +131,7 @@
76 ehrpwm3_tbclk: ehrpwm3_tbclk {
77 #clock-cells = <0>;
78 compatible = "ti,gate-clock";
79 - clocks = <&dpll_per_m2_ck>;
80 + clocks = <&l4ls_gclk>;
81 ti,bit-shift = <4>;
82 reg = <0x0664>;
83 };
84 @@ -139,7 +139,7 @@
85 ehrpwm4_tbclk: ehrpwm4_tbclk {
86 #clock-cells = <0>;
87 compatible = "ti,gate-clock";
88 - clocks = <&dpll_per_m2_ck>;
89 + clocks = <&l4ls_gclk>;
90 ti,bit-shift = <5>;
91 reg = <0x0664>;
92 };
93 @@ -147,7 +147,7 @@
94 ehrpwm5_tbclk: ehrpwm5_tbclk {
95 #clock-cells = <0>;
96 compatible = "ti,gate-clock";
97 - clocks = <&dpll_per_m2_ck>;
98 + clocks = <&l4ls_gclk>;
99 ti,bit-shift = <6>;
100 reg = <0x0664>;
101 };
102 diff --git a/arch/arm/boot/dts/dra7xx-clocks.dtsi b/arch/arm/boot/dts/dra7xx-clocks.dtsi
103 index 2c05b3f017fa..64c0f75b5444 100644
104 --- a/arch/arm/boot/dts/dra7xx-clocks.dtsi
105 +++ b/arch/arm/boot/dts/dra7xx-clocks.dtsi
106 @@ -243,10 +243,18 @@
107 ti,invert-autoidle-bit;
108 };
109
110 + dpll_core_byp_mux: dpll_core_byp_mux {
111 + #clock-cells = <0>;
112 + compatible = "ti,mux-clock";
113 + clocks = <&sys_clkin1>, <&dpll_abe_m3x2_ck>;
114 + ti,bit-shift = <23>;
115 + reg = <0x012c>;
116 + };
117 +
118 dpll_core_ck: dpll_core_ck {
119 #clock-cells = <0>;
120 compatible = "ti,omap4-dpll-core-clock";
121 - clocks = <&sys_clkin1>, <&dpll_abe_m3x2_ck>;
122 + clocks = <&sys_clkin1>, <&dpll_core_byp_mux>;
123 reg = <0x0120>, <0x0124>, <0x012c>, <0x0128>;
124 };
125
126 @@ -309,10 +317,18 @@
127 clock-div = <1>;
128 };
129
130 + dpll_dsp_byp_mux: dpll_dsp_byp_mux {
131 + #clock-cells = <0>;
132 + compatible = "ti,mux-clock";
133 + clocks = <&sys_clkin1>, <&dsp_dpll_hs_clk_div>;
134 + ti,bit-shift = <23>;
135 + reg = <0x0240>;
136 + };
137 +
138 dpll_dsp_ck: dpll_dsp_ck {
139 #clock-cells = <0>;
140 compatible = "ti,omap4-dpll-clock";
141 - clocks = <&sys_clkin1>, <&dsp_dpll_hs_clk_div>;
142 + clocks = <&sys_clkin1>, <&dpll_dsp_byp_mux>;
143 reg = <0x0234>, <0x0238>, <0x0240>, <0x023c>;
144 };
145
146 @@ -335,10 +351,18 @@
147 clock-div = <1>;
148 };
149
150 + dpll_iva_byp_mux: dpll_iva_byp_mux {
151 + #clock-cells = <0>;
152 + compatible = "ti,mux-clock";
153 + clocks = <&sys_clkin1>, <&iva_dpll_hs_clk_div>;
154 + ti,bit-shift = <23>;
155 + reg = <0x01ac>;
156 + };
157 +
158 dpll_iva_ck: dpll_iva_ck {
159 #clock-cells = <0>;
160 compatible = "ti,omap4-dpll-clock";
161 - clocks = <&sys_clkin1>, <&iva_dpll_hs_clk_div>;
162 + clocks = <&sys_clkin1>, <&dpll_iva_byp_mux>;
163 reg = <0x01a0>, <0x01a4>, <0x01ac>, <0x01a8>;
164 };
165
166 @@ -361,10 +385,18 @@
167 clock-div = <1>;
168 };
169
170 + dpll_gpu_byp_mux: dpll_gpu_byp_mux {
171 + #clock-cells = <0>;
172 + compatible = "ti,mux-clock";
173 + clocks = <&sys_clkin1>, <&dpll_abe_m3x2_ck>;
174 + ti,bit-shift = <23>;
175 + reg = <0x02e4>;
176 + };
177 +
178 dpll_gpu_ck: dpll_gpu_ck {
179 #clock-cells = <0>;
180 compatible = "ti,omap4-dpll-clock";
181 - clocks = <&sys_clkin1>, <&dpll_abe_m3x2_ck>;
182 + clocks = <&sys_clkin1>, <&dpll_gpu_byp_mux>;
183 reg = <0x02d8>, <0x02dc>, <0x02e4>, <0x02e0>;
184 };
185
186 @@ -398,10 +430,18 @@
187 clock-div = <1>;
188 };
189
190 + dpll_ddr_byp_mux: dpll_ddr_byp_mux {
191 + #clock-cells = <0>;
192 + compatible = "ti,mux-clock";
193 + clocks = <&sys_clkin1>, <&dpll_abe_m3x2_ck>;
194 + ti,bit-shift = <23>;
195 + reg = <0x021c>;
196 + };
197 +
198 dpll_ddr_ck: dpll_ddr_ck {
199 #clock-cells = <0>;
200 compatible = "ti,omap4-dpll-clock";
201 - clocks = <&sys_clkin1>, <&dpll_abe_m3x2_ck>;
202 + clocks = <&sys_clkin1>, <&dpll_ddr_byp_mux>;
203 reg = <0x0210>, <0x0214>, <0x021c>, <0x0218>;
204 };
205
206 @@ -416,10 +456,18 @@
207 ti,invert-autoidle-bit;
208 };
209
210 + dpll_gmac_byp_mux: dpll_gmac_byp_mux {
211 + #clock-cells = <0>;
212 + compatible = "ti,mux-clock";
213 + clocks = <&sys_clkin1>, <&dpll_abe_m3x2_ck>;
214 + ti,bit-shift = <23>;
215 + reg = <0x02b4>;
216 + };
217 +
218 dpll_gmac_ck: dpll_gmac_ck {
219 #clock-cells = <0>;
220 compatible = "ti,omap4-dpll-clock";
221 - clocks = <&sys_clkin1>, <&dpll_abe_m3x2_ck>;
222 + clocks = <&sys_clkin1>, <&dpll_gmac_byp_mux>;
223 reg = <0x02a8>, <0x02ac>, <0x02b4>, <0x02b0>;
224 };
225
226 @@ -482,10 +530,18 @@
227 clock-div = <1>;
228 };
229
230 + dpll_eve_byp_mux: dpll_eve_byp_mux {
231 + #clock-cells = <0>;
232 + compatible = "ti,mux-clock";
233 + clocks = <&sys_clkin1>, <&eve_dpll_hs_clk_div>;
234 + ti,bit-shift = <23>;
235 + reg = <0x0290>;
236 + };
237 +
238 dpll_eve_ck: dpll_eve_ck {
239 #clock-cells = <0>;
240 compatible = "ti,omap4-dpll-clock";
241 - clocks = <&sys_clkin1>, <&eve_dpll_hs_clk_div>;
242 + clocks = <&sys_clkin1>, <&dpll_eve_byp_mux>;
243 reg = <0x0284>, <0x0288>, <0x0290>, <0x028c>;
244 };
245
246 @@ -1249,10 +1305,18 @@
247 clock-div = <1>;
248 };
249
250 + dpll_per_byp_mux: dpll_per_byp_mux {
251 + #clock-cells = <0>;
252 + compatible = "ti,mux-clock";
253 + clocks = <&sys_clkin1>, <&per_dpll_hs_clk_div>;
254 + ti,bit-shift = <23>;
255 + reg = <0x014c>;
256 + };
257 +
258 dpll_per_ck: dpll_per_ck {
259 #clock-cells = <0>;
260 compatible = "ti,omap4-dpll-clock";
261 - clocks = <&sys_clkin1>, <&per_dpll_hs_clk_div>;
262 + clocks = <&sys_clkin1>, <&dpll_per_byp_mux>;
263 reg = <0x0140>, <0x0144>, <0x014c>, <0x0148>;
264 };
265
266 @@ -1275,10 +1339,18 @@
267 clock-div = <1>;
268 };
269
270 + dpll_usb_byp_mux: dpll_usb_byp_mux {
271 + #clock-cells = <0>;
272 + compatible = "ti,mux-clock";
273 + clocks = <&sys_clkin1>, <&usb_dpll_hs_clk_div>;
274 + ti,bit-shift = <23>;
275 + reg = <0x018c>;
276 + };
277 +
278 dpll_usb_ck: dpll_usb_ck {
279 #clock-cells = <0>;
280 compatible = "ti,omap4-dpll-j-type-clock";
281 - clocks = <&sys_clkin1>, <&usb_dpll_hs_clk_div>;
282 + clocks = <&sys_clkin1>, <&dpll_usb_byp_mux>;
283 reg = <0x0180>, <0x0184>, <0x018c>, <0x0188>;
284 };
285
286 diff --git a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
287 index baf2f00d519a..b57e554dba4e 100644
288 --- a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
289 +++ b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
290 @@ -35,6 +35,7 @@
291 regulator-max-microvolt = <5000000>;
292 gpio = <&gpio3 22 0>;
293 enable-active-high;
294 + vin-supply = <&swbst_reg>;
295 };
296
297 reg_usb_h1_vbus: regulator@1 {
298 @@ -45,6 +46,7 @@
299 regulator-max-microvolt = <5000000>;
300 gpio = <&gpio1 29 0>;
301 enable-active-high;
302 + vin-supply = <&swbst_reg>;
303 };
304
305 reg_audio: regulator@2 {
306 diff --git a/arch/arm/crypto/aesbs-core.S_shipped b/arch/arm/crypto/aesbs-core.S_shipped
307 index 71e5fc7cfb18..1d1800f71c5b 100644
308 --- a/arch/arm/crypto/aesbs-core.S_shipped
309 +++ b/arch/arm/crypto/aesbs-core.S_shipped
310 @@ -58,14 +58,18 @@
311 # define VFP_ABI_FRAME 0
312 # define BSAES_ASM_EXTENDED_KEY
313 # define XTS_CHAIN_TWEAK
314 -# define __ARM_ARCH__ 7
315 +# define __ARM_ARCH__ __LINUX_ARM_ARCH__
316 +# define __ARM_MAX_ARCH__ 7
317 #endif
318
319 #ifdef __thumb__
320 # define adrl adr
321 #endif
322
323 -#if __ARM_ARCH__>=7
324 +#if __ARM_MAX_ARCH__>=7
325 +.arch armv7-a
326 +.fpu neon
327 +
328 .text
329 .syntax unified @ ARMv7-capable assembler is expected to handle this
330 #ifdef __thumb2__
331 @@ -74,8 +78,6 @@
332 .code 32
333 #endif
334
335 -.fpu neon
336 -
337 .type _bsaes_decrypt8,%function
338 .align 4
339 _bsaes_decrypt8:
340 @@ -2095,9 +2097,11 @@ bsaes_xts_decrypt:
341 vld1.8 {q8}, [r0] @ initial tweak
342 adr r2, .Lxts_magic
343
344 +#ifndef XTS_CHAIN_TWEAK
345 tst r9, #0xf @ if not multiple of 16
346 it ne @ Thumb2 thing, sanity check in ARM
347 subne r9, #0x10 @ subtract another 16 bytes
348 +#endif
349 subs r9, #0x80
350
351 blo .Lxts_dec_short
352 diff --git a/arch/arm/crypto/bsaes-armv7.pl b/arch/arm/crypto/bsaes-armv7.pl
353 index be068db960ee..a4d3856e7d24 100644
354 --- a/arch/arm/crypto/bsaes-armv7.pl
355 +++ b/arch/arm/crypto/bsaes-armv7.pl
356 @@ -701,14 +701,18 @@ $code.=<<___;
357 # define VFP_ABI_FRAME 0
358 # define BSAES_ASM_EXTENDED_KEY
359 # define XTS_CHAIN_TWEAK
360 -# define __ARM_ARCH__ 7
361 +# define __ARM_ARCH__ __LINUX_ARM_ARCH__
362 +# define __ARM_MAX_ARCH__ 7
363 #endif
364
365 #ifdef __thumb__
366 # define adrl adr
367 #endif
368
369 -#if __ARM_ARCH__>=7
370 +#if __ARM_MAX_ARCH__>=7
371 +.arch armv7-a
372 +.fpu neon
373 +
374 .text
375 .syntax unified @ ARMv7-capable assembler is expected to handle this
376 #ifdef __thumb2__
377 @@ -717,8 +721,6 @@ $code.=<<___;
378 .code 32
379 #endif
380
381 -.fpu neon
382 -
383 .type _bsaes_decrypt8,%function
384 .align 4
385 _bsaes_decrypt8:
386 @@ -2076,9 +2078,11 @@ bsaes_xts_decrypt:
387 vld1.8 {@XMM[8]}, [r0] @ initial tweak
388 adr $magic, .Lxts_magic
389
390 +#ifndef XTS_CHAIN_TWEAK
391 tst $len, #0xf @ if not multiple of 16
392 it ne @ Thumb2 thing, sanity check in ARM
393 subne $len, #0x10 @ subtract another 16 bytes
394 +#endif
395 subs $len, #0x80
396
397 blo .Lxts_dec_short
398 diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
399 index c5101dcb4fb0..1d4df3b70ebc 100644
400 --- a/arch/arm/mach-at91/pm.h
401 +++ b/arch/arm/mach-at91/pm.h
402 @@ -45,7 +45,7 @@ static inline void at91rm9200_standby(void)
403 " mcr p15, 0, %0, c7, c0, 4\n\t"
404 " str %5, [%1, %2]"
405 :
406 - : "r" (0), "r" (AT91_BASE_SYS), "r" (AT91RM9200_SDRAMC_LPR),
407 + : "r" (0), "r" (at91_ramc_base[0]), "r" (AT91RM9200_SDRAMC_LPR),
408 "r" (1), "r" (AT91RM9200_SDRAMC_SRR),
409 "r" (lpr));
410 }
411 diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
412 index a82c0c5c8b52..53d9c354219f 100644
413 --- a/arch/arm64/include/asm/tlb.h
414 +++ b/arch/arm64/include/asm/tlb.h
415 @@ -19,10 +19,6 @@
416 #ifndef __ASM_TLB_H
417 #define __ASM_TLB_H
418
419 -#define __tlb_remove_pmd_tlb_entry __tlb_remove_pmd_tlb_entry
420 -
421 -#include <asm-generic/tlb.h>
422 -
423 #include <linux/pagemap.h>
424 #include <linux/swap.h>
425
426 @@ -37,71 +33,23 @@ static inline void __tlb_remove_table(void *_table)
427 #define tlb_remove_entry(tlb, entry) tlb_remove_page(tlb, entry)
428 #endif /* CONFIG_HAVE_RCU_TABLE_FREE */
429
430 -/*
431 - * There's three ways the TLB shootdown code is used:
432 - * 1. Unmapping a range of vmas. See zap_page_range(), unmap_region().
433 - * tlb->fullmm = 0, and tlb_start_vma/tlb_end_vma will be called.
434 - * 2. Unmapping all vmas. See exit_mmap().
435 - * tlb->fullmm = 1, and tlb_start_vma/tlb_end_vma will be called.
436 - * Page tables will be freed.
437 - * 3. Unmapping argument pages. See shift_arg_pages().
438 - * tlb->fullmm = 0, but tlb_start_vma/tlb_end_vma will not be called.
439 - */
440 +#include <asm-generic/tlb.h>
441 +
442 static inline void tlb_flush(struct mmu_gather *tlb)
443 {
444 if (tlb->fullmm) {
445 flush_tlb_mm(tlb->mm);
446 - } else if (tlb->end > 0) {
447 + } else {
448 struct vm_area_struct vma = { .vm_mm = tlb->mm, };
449 flush_tlb_range(&vma, tlb->start, tlb->end);
450 - tlb->start = TASK_SIZE;
451 - tlb->end = 0;
452 - }
453 -}
454 -
455 -static inline void tlb_add_flush(struct mmu_gather *tlb, unsigned long addr)
456 -{
457 - if (!tlb->fullmm) {
458 - tlb->start = min(tlb->start, addr);
459 - tlb->end = max(tlb->end, addr + PAGE_SIZE);
460 - }
461 -}
462 -
463 -/*
464 - * Memorize the range for the TLB flush.
465 - */
466 -static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep,
467 - unsigned long addr)
468 -{
469 - tlb_add_flush(tlb, addr);
470 -}
471 -
472 -/*
473 - * In the case of tlb vma handling, we can optimise these away in the
474 - * case where we're doing a full MM flush. When we're doing a munmap,
475 - * the vmas are adjusted to only cover the region to be torn down.
476 - */
477 -static inline void tlb_start_vma(struct mmu_gather *tlb,
478 - struct vm_area_struct *vma)
479 -{
480 - if (!tlb->fullmm) {
481 - tlb->start = TASK_SIZE;
482 - tlb->end = 0;
483 }
484 }
485
486 -static inline void tlb_end_vma(struct mmu_gather *tlb,
487 - struct vm_area_struct *vma)
488 -{
489 - if (!tlb->fullmm)
490 - tlb_flush(tlb);
491 -}
492 -
493 static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
494 unsigned long addr)
495 {
496 + __flush_tlb_pgtable(tlb->mm, addr);
497 pgtable_page_dtor(pte);
498 - tlb_add_flush(tlb, addr);
499 tlb_remove_entry(tlb, pte);
500 }
501
502 @@ -109,7 +57,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
503 static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
504 unsigned long addr)
505 {
506 - tlb_add_flush(tlb, addr);
507 + __flush_tlb_pgtable(tlb->mm, addr);
508 tlb_remove_entry(tlb, virt_to_page(pmdp));
509 }
510 #endif
511 @@ -118,15 +66,9 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
512 static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp,
513 unsigned long addr)
514 {
515 - tlb_add_flush(tlb, addr);
516 + __flush_tlb_pgtable(tlb->mm, addr);
517 tlb_remove_entry(tlb, virt_to_page(pudp));
518 }
519 #endif
520
521 -static inline void __tlb_remove_pmd_tlb_entry(struct mmu_gather *tlb, pmd_t *pmdp,
522 - unsigned long address)
523 -{
524 - tlb_add_flush(tlb, address);
525 -}
526 -
527 #endif
528 diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
529 index 73f0ce570fb3..8b8d8cb46e01 100644
530 --- a/arch/arm64/include/asm/tlbflush.h
531 +++ b/arch/arm64/include/asm/tlbflush.h
532 @@ -149,6 +149,19 @@ static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end
533 }
534
535 /*
536 + * Used to invalidate the TLB (walk caches) corresponding to intermediate page
537 + * table levels (pgd/pud/pmd).
538 + */
539 +static inline void __flush_tlb_pgtable(struct mm_struct *mm,
540 + unsigned long uaddr)
541 +{
542 + unsigned long addr = uaddr >> 12 | ((unsigned long)ASID(mm) << 48);
543 +
544 + dsb(ishst);
545 + asm("tlbi vae1is, %0" : : "r" (addr));
546 + dsb(ish);
547 +}
548 +/*
549 * On AArch64, the cache coherency is handled via the set_pte_at() function.
550 */
551 static inline void update_mmu_cache(struct vm_area_struct *vma,
552 diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
553 index d92094203913..df34a70caca1 100644
554 --- a/arch/arm64/mm/dma-mapping.c
555 +++ b/arch/arm64/mm/dma-mapping.c
556 @@ -51,7 +51,7 @@ static int __init early_coherent_pool(char *p)
557 }
558 early_param("coherent_pool", early_coherent_pool);
559
560 -static void *__alloc_from_pool(size_t size, struct page **ret_page)
561 +static void *__alloc_from_pool(size_t size, struct page **ret_page, gfp_t flags)
562 {
563 unsigned long val;
564 void *ptr = NULL;
565 @@ -67,6 +67,8 @@ static void *__alloc_from_pool(size_t size, struct page **ret_page)
566
567 *ret_page = phys_to_page(phys);
568 ptr = (void *)val;
569 + if (flags & __GFP_ZERO)
570 + memset(ptr, 0, size);
571 }
572
573 return ptr;
574 @@ -101,6 +103,7 @@ static void *__dma_alloc_coherent(struct device *dev, size_t size,
575 flags |= GFP_DMA;
576 if (IS_ENABLED(CONFIG_DMA_CMA) && (flags & __GFP_WAIT)) {
577 struct page *page;
578 + void *addr;
579
580 size = PAGE_ALIGN(size);
581 page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT,
582 @@ -109,7 +112,10 @@ static void *__dma_alloc_coherent(struct device *dev, size_t size,
583 return NULL;
584
585 *dma_handle = phys_to_dma(dev, page_to_phys(page));
586 - return page_address(page);
587 + addr = page_address(page);
588 + if (flags & __GFP_ZERO)
589 + memset(addr, 0, size);
590 + return addr;
591 } else {
592 return swiotlb_alloc_coherent(dev, size, dma_handle, flags);
593 }
594 @@ -145,7 +151,7 @@ static void *__dma_alloc_noncoherent(struct device *dev, size_t size,
595
596 if (!(flags & __GFP_WAIT)) {
597 struct page *page = NULL;
598 - void *addr = __alloc_from_pool(size, &page);
599 + void *addr = __alloc_from_pool(size, &page, flags);
600
601 if (addr)
602 *dma_handle = phys_to_dma(dev, page_to_phys(page));
603 diff --git a/arch/microblaze/include/asm/tlb.h b/arch/microblaze/include/asm/tlb.h
604 index 8aa97817cc8c..99b6ded54849 100644
605 --- a/arch/microblaze/include/asm/tlb.h
606 +++ b/arch/microblaze/include/asm/tlb.h
607 @@ -14,7 +14,6 @@
608 #define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
609
610 #include <linux/pagemap.h>
611 -#include <asm-generic/tlb.h>
612
613 #ifdef CONFIG_MMU
614 #define tlb_start_vma(tlb, vma) do { } while (0)
615 @@ -22,4 +21,6 @@
616 #define __tlb_remove_tlb_entry(tlb, pte, address) do { } while (0)
617 #endif
618
619 +#include <asm-generic/tlb.h>
620 +
621 #endif /* _ASM_MICROBLAZE_TLB_H */
622 diff --git a/arch/powerpc/include/asm/pgalloc.h b/arch/powerpc/include/asm/pgalloc.h
623 index e9a9f60e596d..fc3ee06eab87 100644
624 --- a/arch/powerpc/include/asm/pgalloc.h
625 +++ b/arch/powerpc/include/asm/pgalloc.h
626 @@ -3,7 +3,6 @@
627 #ifdef __KERNEL__
628
629 #include <linux/mm.h>
630 -#include <asm-generic/tlb.h>
631
632 #ifdef CONFIG_PPC_BOOK3E
633 extern void tlb_flush_pgtable(struct mmu_gather *tlb, unsigned long address);
634 @@ -14,6 +13,8 @@ static inline void tlb_flush_pgtable(struct mmu_gather *tlb,
635 }
636 #endif /* !CONFIG_PPC_BOOK3E */
637
638 +extern void tlb_remove_table(struct mmu_gather *tlb, void *table);
639 +
640 #ifdef CONFIG_PPC64
641 #include <asm/pgalloc-64.h>
642 #else
643 diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tlb.h
644 index e2b428b0f7ba..20733fa518ae 100644
645 --- a/arch/powerpc/include/asm/tlb.h
646 +++ b/arch/powerpc/include/asm/tlb.h
647 @@ -27,6 +27,7 @@
648
649 #define tlb_start_vma(tlb, vma) do { } while (0)
650 #define tlb_end_vma(tlb, vma) do { } while (0)
651 +#define __tlb_remove_tlb_entry __tlb_remove_tlb_entry
652
653 extern void tlb_flush(struct mmu_gather *tlb);
654
655 diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
656 index 7e70ae968e5f..6a4a5fcb9730 100644
657 --- a/arch/powerpc/mm/hugetlbpage.c
658 +++ b/arch/powerpc/mm/hugetlbpage.c
659 @@ -517,8 +517,6 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshif
660 for (i = 0; i < num_hugepd; i++, hpdp++)
661 hpdp->pd = 0;
662
663 - tlb->need_flush = 1;
664 -
665 #ifdef CONFIG_PPC_FSL_BOOK3E
666 hugepd_free(tlb, hugepte);
667 #else
668 diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
669 index ced09d8738b4..49e4d64ff74d 100644
670 --- a/arch/s390/kvm/kvm-s390.c
671 +++ b/arch/s390/kvm/kvm-s390.c
672 @@ -152,7 +152,6 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
673 case KVM_CAP_ONE_REG:
674 case KVM_CAP_ENABLE_CAP:
675 case KVM_CAP_S390_CSS_SUPPORT:
676 - case KVM_CAP_IRQFD:
677 case KVM_CAP_IOEVENTFD:
678 case KVM_CAP_DEVICE_CTRL:
679 case KVM_CAP_ENABLE_CAP_VM:
680 diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
681 index 46a5e4508752..af53c25da2e7 100644
682 --- a/arch/sparc/kernel/perf_event.c
683 +++ b/arch/sparc/kernel/perf_event.c
684 @@ -960,6 +960,8 @@ out:
685 cpuc->pcr[0] |= cpuc->event[0]->hw.config_base;
686 }
687
688 +static void sparc_pmu_start(struct perf_event *event, int flags);
689 +
690 /* On this PMU each PIC has it's own PCR control register. */
691 static void calculate_multiple_pcrs(struct cpu_hw_events *cpuc)
692 {
693 @@ -972,20 +974,13 @@ static void calculate_multiple_pcrs(struct cpu_hw_events *cpuc)
694 struct perf_event *cp = cpuc->event[i];
695 struct hw_perf_event *hwc = &cp->hw;
696 int idx = hwc->idx;
697 - u64 enc;
698
699 if (cpuc->current_idx[i] != PIC_NO_INDEX)
700 continue;
701
702 - sparc_perf_event_set_period(cp, hwc, idx);
703 cpuc->current_idx[i] = idx;
704
705 - enc = perf_event_get_enc(cpuc->events[i]);
706 - cpuc->pcr[idx] &= ~mask_for_index(idx);
707 - if (hwc->state & PERF_HES_STOPPED)
708 - cpuc->pcr[idx] |= nop_for_index(idx);
709 - else
710 - cpuc->pcr[idx] |= event_encoding(enc, idx);
711 + sparc_pmu_start(cp, PERF_EF_RELOAD);
712 }
713 out:
714 for (i = 0; i < cpuc->n_events; i++) {
715 @@ -1101,7 +1096,6 @@ static void sparc_pmu_del(struct perf_event *event, int _flags)
716 int i;
717
718 local_irq_save(flags);
719 - perf_pmu_disable(event->pmu);
720
721 for (i = 0; i < cpuc->n_events; i++) {
722 if (event == cpuc->event[i]) {
723 @@ -1127,7 +1121,6 @@ static void sparc_pmu_del(struct perf_event *event, int _flags)
724 }
725 }
726
727 - perf_pmu_enable(event->pmu);
728 local_irq_restore(flags);
729 }
730
731 @@ -1361,7 +1354,6 @@ static int sparc_pmu_add(struct perf_event *event, int ef_flags)
732 unsigned long flags;
733
734 local_irq_save(flags);
735 - perf_pmu_disable(event->pmu);
736
737 n0 = cpuc->n_events;
738 if (n0 >= sparc_pmu->max_hw_events)
739 @@ -1394,7 +1386,6 @@ nocheck:
740
741 ret = 0;
742 out:
743 - perf_pmu_enable(event->pmu);
744 local_irq_restore(flags);
745 return ret;
746 }
747 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
748 index 0be7bf978cb1..46a59643bb1c 100644
749 --- a/arch/sparc/kernel/process_64.c
750 +++ b/arch/sparc/kernel/process_64.c
751 @@ -287,6 +287,8 @@ void arch_trigger_all_cpu_backtrace(bool include_self)
752 printk(" TPC[%lx] O7[%lx] I7[%lx] RPC[%lx]\n",
753 gp->tpc, gp->o7, gp->i7, gp->rpc);
754 }
755 +
756 + touch_nmi_watchdog();
757 }
758
759 memset(global_cpu_snapshot, 0, sizeof(global_cpu_snapshot));
760 @@ -362,6 +364,8 @@ static void pmu_snapshot_all_cpus(void)
761 (cpu == this_cpu ? '*' : ' '), cpu,
762 pp->pcr[0], pp->pcr[1], pp->pcr[2], pp->pcr[3],
763 pp->pic[0], pp->pic[1], pp->pic[2], pp->pic[3]);
764 +
765 + touch_nmi_watchdog();
766 }
767
768 memset(global_cpu_snapshot, 0, sizeof(global_cpu_snapshot));
769 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
770 index c85403d0496c..30e7ddb27a3a 100644
771 --- a/arch/sparc/kernel/sys_sparc_64.c
772 +++ b/arch/sparc/kernel/sys_sparc_64.c
773 @@ -333,7 +333,7 @@ SYSCALL_DEFINE6(sparc_ipc, unsigned int, call, int, first, unsigned long, second
774 long err;
775
776 /* No need for backward compatibility. We can start fresh... */
777 - if (call <= SEMCTL) {
778 + if (call <= SEMTIMEDOP) {
779 switch (call) {
780 case SEMOP:
781 err = sys_semtimedop(first, ptr,
782 diff --git a/arch/sparc/lib/memmove.S b/arch/sparc/lib/memmove.S
783 index b7f6334e159f..857ad4f8905f 100644
784 --- a/arch/sparc/lib/memmove.S
785 +++ b/arch/sparc/lib/memmove.S
786 @@ -8,9 +8,11 @@
787
788 .text
789 ENTRY(memmove) /* o0=dst o1=src o2=len */
790 - mov %o0, %g1
791 + brz,pn %o2, 99f
792 + mov %o0, %g1
793 +
794 cmp %o0, %o1
795 - bleu,pt %xcc, memcpy
796 + bleu,pt %xcc, 2f
797 add %o1, %o2, %g7
798 cmp %g7, %o0
799 bleu,pt %xcc, memcpy
800 @@ -24,7 +26,34 @@ ENTRY(memmove) /* o0=dst o1=src o2=len */
801 stb %g7, [%o0]
802 bne,pt %icc, 1b
803 sub %o0, 1, %o0
804 -
805 +99:
806 retl
807 mov %g1, %o0
808 +
809 + /* We can't just call memcpy for these memmove cases. On some
810 + * chips the memcpy uses cache initializing stores and when dst
811 + * and src are close enough, those can clobber the source data
812 + * before we've loaded it in.
813 + */
814 +2: or %o0, %o1, %g7
815 + or %o2, %g7, %g7
816 + andcc %g7, 0x7, %g0
817 + bne,pn %xcc, 4f
818 + nop
819 +
820 +3: ldx [%o1], %g7
821 + add %o1, 8, %o1
822 + subcc %o2, 8, %o2
823 + add %o0, 8, %o0
824 + bne,pt %icc, 3b
825 + stx %g7, [%o0 - 0x8]
826 + ba,a,pt %xcc, 99b
827 +
828 +4: ldub [%o1], %g7
829 + add %o1, 1, %o1
830 + subcc %o2, 1, %o2
831 + add %o0, 1, %o0
832 + bne,pt %icc, 4b
833 + stb %g7, [%o0 - 0x1]
834 + ba,a,pt %xcc, 99b
835 ENDPROC(memmove)
836 diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
837 index be65f035d18a..5cbc96d801ff 100644
838 --- a/arch/sparc/mm/srmmu.c
839 +++ b/arch/sparc/mm/srmmu.c
840 @@ -460,10 +460,12 @@ static void __init sparc_context_init(int numctx)
841 void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm,
842 struct task_struct *tsk)
843 {
844 + unsigned long flags;
845 +
846 if (mm->context == NO_CONTEXT) {
847 - spin_lock(&srmmu_context_spinlock);
848 + spin_lock_irqsave(&srmmu_context_spinlock, flags);
849 alloc_context(old_mm, mm);
850 - spin_unlock(&srmmu_context_spinlock);
851 + spin_unlock_irqrestore(&srmmu_context_spinlock, flags);
852 srmmu_ctxd_set(&srmmu_context_table[mm->context], mm->pgd);
853 }
854
855 @@ -986,14 +988,15 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
856
857 void destroy_context(struct mm_struct *mm)
858 {
859 + unsigned long flags;
860
861 if (mm->context != NO_CONTEXT) {
862 flush_cache_mm(mm);
863 srmmu_ctxd_set(&srmmu_context_table[mm->context], srmmu_swapper_pg_dir);
864 flush_tlb_mm(mm);
865 - spin_lock(&srmmu_context_spinlock);
866 + spin_lock_irqsave(&srmmu_context_spinlock, flags);
867 free_context(mm->context);
868 - spin_unlock(&srmmu_context_spinlock);
869 + spin_unlock_irqrestore(&srmmu_context_spinlock, flags);
870 mm->context = NO_CONTEXT;
871 }
872 }
873 diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
874 index 70fece226d17..5a93783a8a0d 100644
875 --- a/arch/x86/crypto/aesni-intel_glue.c
876 +++ b/arch/x86/crypto/aesni-intel_glue.c
877 @@ -1137,7 +1137,7 @@ static int __driver_rfc4106_decrypt(struct aead_request *req)
878 src = kmalloc(req->cryptlen + req->assoclen, GFP_ATOMIC);
879 if (!src)
880 return -ENOMEM;
881 - assoc = (src + req->cryptlen + auth_tag_len);
882 + assoc = (src + req->cryptlen);
883 scatterwalk_map_and_copy(src, req->src, 0, req->cryptlen, 0);
884 scatterwalk_map_and_copy(assoc, req->assoc, 0,
885 req->assoclen, 0);
886 @@ -1162,7 +1162,7 @@ static int __driver_rfc4106_decrypt(struct aead_request *req)
887 scatterwalk_done(&src_sg_walk, 0, 0);
888 scatterwalk_done(&assoc_sg_walk, 0, 0);
889 } else {
890 - scatterwalk_map_and_copy(dst, req->dst, 0, req->cryptlen, 1);
891 + scatterwalk_map_and_copy(dst, req->dst, 0, tempCipherLen, 1);
892 kfree(src);
893 }
894 return retval;
895 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
896 index e97622f57722..f895358db0ab 100644
897 --- a/arch/x86/include/asm/fpu-internal.h
898 +++ b/arch/x86/include/asm/fpu-internal.h
899 @@ -368,7 +368,7 @@ static inline void drop_fpu(struct task_struct *tsk)
900 preempt_disable();
901 tsk->thread.fpu_counter = 0;
902 __drop_fpu(tsk);
903 - clear_used_math();
904 + clear_stopped_child_used_math(tsk);
905 preempt_enable();
906 }
907
908 diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c
909 index 4128b5fcb559..2aaee79fb129 100644
910 --- a/arch/x86/kernel/apic/apic_numachip.c
911 +++ b/arch/x86/kernel/apic/apic_numachip.c
912 @@ -40,7 +40,7 @@ static unsigned int get_apic_id(unsigned long x)
913 unsigned int id;
914
915 rdmsrl(MSR_FAM10H_NODE_ID, value);
916 - id = ((x >> 24) & 0xffU) | ((value << 2) & 0x3f00U);
917 + id = ((x >> 24) & 0xffU) | ((value << 2) & 0xff00U);
918
919 return id;
920 }
921 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
922 index 0de1fae2bdf0..8be1e1711203 100644
923 --- a/arch/x86/kernel/xsave.c
924 +++ b/arch/x86/kernel/xsave.c
925 @@ -378,7 +378,7 @@ int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size)
926 * thread's fpu state, reconstruct fxstate from the fsave
927 * header. Sanitize the copied state etc.
928 */
929 - struct xsave_struct *xsave = &tsk->thread.fpu.state->xsave;
930 + struct fpu *fpu = &tsk->thread.fpu;
931 struct user_i387_ia32_struct env;
932 int err = 0;
933
934 @@ -392,14 +392,15 @@ int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size)
935 */
936 drop_fpu(tsk);
937
938 - if (__copy_from_user(xsave, buf_fx, state_size) ||
939 + if (__copy_from_user(&fpu->state->xsave, buf_fx, state_size) ||
940 __copy_from_user(&env, buf, sizeof(env))) {
941 + fpu_finit(fpu);
942 err = -1;
943 } else {
944 sanitize_restored_xstate(tsk, &env, xstate_bv, fx_only);
945 - set_used_math();
946 }
947
948 + set_used_math();
949 if (use_eager_fpu()) {
950 preempt_disable();
951 math_state_restore();
952 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
953 index 8b92cf4b165a..a38dd816015b 100644
954 --- a/arch/x86/kvm/x86.c
955 +++ b/arch/x86/kvm/x86.c
956 @@ -2713,7 +2713,6 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
957 case KVM_CAP_USER_NMI:
958 case KVM_CAP_REINJECT_CONTROL:
959 case KVM_CAP_IRQ_INJECT_STATUS:
960 - case KVM_CAP_IRQFD:
961 case KVM_CAP_IOEVENTFD:
962 case KVM_CAP_IOEVENTFD_NO_LENGTH:
963 case KVM_CAP_PIT2:
964 diff --git a/arch/x86/vdso/vdso32/sigreturn.S b/arch/x86/vdso/vdso32/sigreturn.S
965 index 31776d0efc8c..d7ec4e251c0a 100644
966 --- a/arch/x86/vdso/vdso32/sigreturn.S
967 +++ b/arch/x86/vdso/vdso32/sigreturn.S
968 @@ -17,6 +17,7 @@
969 .text
970 .globl __kernel_sigreturn
971 .type __kernel_sigreturn,@function
972 + nop /* this guy is needed for .LSTARTFDEDLSI1 below (watch for HACK) */
973 ALIGN
974 __kernel_sigreturn:
975 .LSTART_sigreturn:
976 diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c
977 index 7d1c540fa26a..3f187a529e92 100644
978 --- a/drivers/char/tpm/tpm_i2c_stm_st33.c
979 +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
980 @@ -397,7 +397,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
981 */
982 static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
983 {
984 - int size = 0, burstcnt, len;
985 + int size = 0, burstcnt, len, ret;
986 struct i2c_client *client;
987
988 client = (struct i2c_client *)TPM_VPRIV(chip);
989 @@ -406,13 +406,15 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
990 wait_for_stat(chip,
991 TPM_STS_DATA_AVAIL | TPM_STS_VALID,
992 chip->vendor.timeout_c,
993 - &chip->vendor.read_queue)
994 - == 0) {
995 + &chip->vendor.read_queue) == 0) {
996 burstcnt = get_burstcount(chip);
997 if (burstcnt < 0)
998 return burstcnt;
999 len = min_t(int, burstcnt, count - size);
1000 - I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len);
1001 + ret = I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len);
1002 + if (ret < 0)
1003 + return ret;
1004 +
1005 size += len;
1006 }
1007 return size;
1008 diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
1009 index eff9d5870034..102463ba745d 100644
1010 --- a/drivers/char/tpm/tpm_ibmvtpm.c
1011 +++ b/drivers/char/tpm/tpm_ibmvtpm.c
1012 @@ -124,7 +124,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
1013 {
1014 struct ibmvtpm_dev *ibmvtpm;
1015 struct ibmvtpm_crq crq;
1016 - u64 *word = (u64 *) &crq;
1017 + __be64 *word = (__be64 *)&crq;
1018 int rc;
1019
1020 ibmvtpm = (struct ibmvtpm_dev *)TPM_VPRIV(chip);
1021 @@ -145,11 +145,11 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
1022 memcpy((void *)ibmvtpm->rtce_buf, (void *)buf, count);
1023 crq.valid = (u8)IBMVTPM_VALID_CMD;
1024 crq.msg = (u8)VTPM_TPM_COMMAND;
1025 - crq.len = (u16)count;
1026 - crq.data = ibmvtpm->rtce_dma_handle;
1027 + crq.len = cpu_to_be16(count);
1028 + crq.data = cpu_to_be32(ibmvtpm->rtce_dma_handle);
1029
1030 - rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(word[0]),
1031 - cpu_to_be64(word[1]));
1032 + rc = ibmvtpm_send_crq(ibmvtpm->vdev, be64_to_cpu(word[0]),
1033 + be64_to_cpu(word[1]));
1034 if (rc != H_SUCCESS) {
1035 dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc);
1036 rc = 0;
1037 diff --git a/drivers/char/tpm/tpm_ibmvtpm.h b/drivers/char/tpm/tpm_ibmvtpm.h
1038 index bd82a791f995..b2c231b1beec 100644
1039 --- a/drivers/char/tpm/tpm_ibmvtpm.h
1040 +++ b/drivers/char/tpm/tpm_ibmvtpm.h
1041 @@ -22,9 +22,9 @@
1042 struct ibmvtpm_crq {
1043 u8 valid;
1044 u8 msg;
1045 - u16 len;
1046 - u32 data;
1047 - u64 reserved;
1048 + __be16 len;
1049 + __be32 data;
1050 + __be64 reserved;
1051 } __attribute__((packed, aligned(8)));
1052
1053 struct ibmvtpm_crq_queue {
1054 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
1055 index cf7a561fad7c..6e09c1dac2b7 100644
1056 --- a/drivers/char/virtio_console.c
1057 +++ b/drivers/char/virtio_console.c
1058 @@ -142,6 +142,7 @@ struct ports_device {
1059 * notification
1060 */
1061 struct work_struct control_work;
1062 + struct work_struct config_work;
1063
1064 struct list_head ports;
1065
1066 @@ -1832,10 +1833,21 @@ static void config_intr(struct virtio_device *vdev)
1067
1068 portdev = vdev->priv;
1069
1070 + if (!use_multiport(portdev))
1071 + schedule_work(&portdev->config_work);
1072 +}
1073 +
1074 +static void config_work_handler(struct work_struct *work)
1075 +{
1076 + struct ports_device *portdev;
1077 +
1078 + portdev = container_of(work, struct ports_device, control_work);
1079 if (!use_multiport(portdev)) {
1080 + struct virtio_device *vdev;
1081 struct port *port;
1082 u16 rows, cols;
1083
1084 + vdev = portdev->vdev;
1085 virtio_cread(vdev, struct virtio_console_config, cols, &cols);
1086 virtio_cread(vdev, struct virtio_console_config, rows, &rows);
1087
1088 @@ -2026,12 +2038,14 @@ static int virtcons_probe(struct virtio_device *vdev)
1089
1090 virtio_device_ready(portdev->vdev);
1091
1092 + INIT_WORK(&portdev->config_work, &config_work_handler);
1093 + INIT_WORK(&portdev->control_work, &control_work_handler);
1094 +
1095 if (multiport) {
1096 unsigned int nr_added_bufs;
1097
1098 spin_lock_init(&portdev->c_ivq_lock);
1099 spin_lock_init(&portdev->c_ovq_lock);
1100 - INIT_WORK(&portdev->control_work, &control_work_handler);
1101
1102 nr_added_bufs = fill_queue(portdev->c_ivq,
1103 &portdev->c_ivq_lock);
1104 @@ -2099,6 +2113,8 @@ static void virtcons_remove(struct virtio_device *vdev)
1105 /* Finish up work that's lined up */
1106 if (use_multiport(portdev))
1107 cancel_work_sync(&portdev->control_work);
1108 + else
1109 + cancel_work_sync(&portdev->config_work);
1110
1111 list_for_each_entry_safe(port, port2, &portdev->ports, list)
1112 unplug_port(port);
1113 @@ -2150,6 +2166,7 @@ static int virtcons_freeze(struct virtio_device *vdev)
1114
1115 virtqueue_disable_cb(portdev->c_ivq);
1116 cancel_work_sync(&portdev->control_work);
1117 + cancel_work_sync(&portdev->config_work);
1118 /*
1119 * Once more: if control_work_handler() was running, it would
1120 * enable the cb as the last step.
1121 diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
1122 index e79c8d3700d8..da41ad42d3a6 100644
1123 --- a/drivers/gpu/drm/drm_crtc.c
1124 +++ b/drivers/gpu/drm/drm_crtc.c
1125 @@ -42,9 +42,10 @@
1126 #include "drm_crtc_internal.h"
1127 #include "drm_internal.h"
1128
1129 -static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
1130 - struct drm_mode_fb_cmd2 *r,
1131 - struct drm_file *file_priv);
1132 +static struct drm_framebuffer *
1133 +internal_framebuffer_create(struct drm_device *dev,
1134 + struct drm_mode_fb_cmd2 *r,
1135 + struct drm_file *file_priv);
1136
1137 /* Avoid boilerplate. I'm tired of typing. */
1138 #define DRM_ENUM_NAME_FN(fnname, list) \
1139 @@ -2739,13 +2740,11 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
1140 */
1141 if (req->flags & DRM_MODE_CURSOR_BO) {
1142 if (req->handle) {
1143 - fb = add_framebuffer_internal(dev, &fbreq, file_priv);
1144 + fb = internal_framebuffer_create(dev, &fbreq, file_priv);
1145 if (IS_ERR(fb)) {
1146 DRM_DEBUG_KMS("failed to wrap cursor buffer in drm framebuffer\n");
1147 return PTR_ERR(fb);
1148 }
1149 -
1150 - drm_framebuffer_reference(fb);
1151 } else {
1152 fb = NULL;
1153 }
1154 @@ -3114,9 +3113,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
1155 return 0;
1156 }
1157
1158 -static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
1159 - struct drm_mode_fb_cmd2 *r,
1160 - struct drm_file *file_priv)
1161 +static struct drm_framebuffer *
1162 +internal_framebuffer_create(struct drm_device *dev,
1163 + struct drm_mode_fb_cmd2 *r,
1164 + struct drm_file *file_priv)
1165 {
1166 struct drm_mode_config *config = &dev->mode_config;
1167 struct drm_framebuffer *fb;
1168 @@ -3148,12 +3148,6 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
1169 return fb;
1170 }
1171
1172 - mutex_lock(&file_priv->fbs_lock);
1173 - r->fb_id = fb->base.id;
1174 - list_add(&fb->filp_head, &file_priv->fbs);
1175 - DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
1176 - mutex_unlock(&file_priv->fbs_lock);
1177 -
1178 return fb;
1179 }
1180
1181 @@ -3175,15 +3169,24 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
1182 int drm_mode_addfb2(struct drm_device *dev,
1183 void *data, struct drm_file *file_priv)
1184 {
1185 + struct drm_mode_fb_cmd2 *r = data;
1186 struct drm_framebuffer *fb;
1187
1188 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1189 return -EINVAL;
1190
1191 - fb = add_framebuffer_internal(dev, data, file_priv);
1192 + fb = internal_framebuffer_create(dev, r, file_priv);
1193 if (IS_ERR(fb))
1194 return PTR_ERR(fb);
1195
1196 + /* Transfer ownership to the filp for reaping on close */
1197 +
1198 + DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
1199 + mutex_lock(&file_priv->fbs_lock);
1200 + r->fb_id = fb->base.id;
1201 + list_add(&fb->filp_head, &file_priv->fbs);
1202 + mutex_unlock(&file_priv->fbs_lock);
1203 +
1204 return 0;
1205 }
1206
1207 diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
1208 index dce0d3918fa7..9f0e62529c46 100644
1209 --- a/drivers/gpu/drm/radeon/atombios_crtc.c
1210 +++ b/drivers/gpu/drm/radeon/atombios_crtc.c
1211 @@ -1405,6 +1405,9 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
1212 (x << 16) | y);
1213 viewport_w = crtc->mode.hdisplay;
1214 viewport_h = (crtc->mode.vdisplay + 1) & ~1;
1215 + if ((rdev->family >= CHIP_BONAIRE) &&
1216 + (crtc->mode.flags & DRM_MODE_FLAG_INTERLACE))
1217 + viewport_h *= 2;
1218 WREG32(EVERGREEN_VIEWPORT_SIZE + radeon_crtc->crtc_offset,
1219 (viewport_w << 16) | viewport_h);
1220
1221 diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
1222 index 5f395be9b3e3..0c6fbc0198a5 100644
1223 --- a/drivers/gpu/drm/radeon/cik.c
1224 +++ b/drivers/gpu/drm/radeon/cik.c
1225 @@ -7555,6 +7555,9 @@ int cik_irq_set(struct radeon_device *rdev)
1226 WREG32(DC_HPD5_INT_CONTROL, hpd5);
1227 WREG32(DC_HPD6_INT_CONTROL, hpd6);
1228
1229 + /* posting read */
1230 + RREG32(SRBM_STATUS);
1231 +
1232 return 0;
1233 }
1234
1235 diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
1236 index 85995b4e3338..c674f63d7f14 100644
1237 --- a/drivers/gpu/drm/radeon/evergreen.c
1238 +++ b/drivers/gpu/drm/radeon/evergreen.c
1239 @@ -4589,6 +4589,9 @@ int evergreen_irq_set(struct radeon_device *rdev)
1240 WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, afmt5);
1241 WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, afmt6);
1242
1243 + /* posting read */
1244 + RREG32(SRBM_STATUS);
1245 +
1246 return 0;
1247 }
1248
1249 diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
1250 index cdf6e2149539..a959cc1e7c8e 100644
1251 --- a/drivers/gpu/drm/radeon/r100.c
1252 +++ b/drivers/gpu/drm/radeon/r100.c
1253 @@ -728,6 +728,10 @@ int r100_irq_set(struct radeon_device *rdev)
1254 tmp |= RADEON_FP2_DETECT_MASK;
1255 }
1256 WREG32(RADEON_GEN_INT_CNTL, tmp);
1257 +
1258 + /* read back to post the write */
1259 + RREG32(RADEON_GEN_INT_CNTL);
1260 +
1261 return 0;
1262 }
1263
1264 diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
1265 index 56b02927cd3d..ee0868dec2f4 100644
1266 --- a/drivers/gpu/drm/radeon/r600.c
1267 +++ b/drivers/gpu/drm/radeon/r600.c
1268 @@ -3787,6 +3787,9 @@ int r600_irq_set(struct radeon_device *rdev)
1269 WREG32(RV770_CG_THERMAL_INT, thermal_int);
1270 }
1271
1272 + /* posting read */
1273 + RREG32(R_000E50_SRBM_STATUS);
1274 +
1275 return 0;
1276 }
1277
1278 diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
1279 index 6f377de099f9..a5b7f6f98f5f 100644
1280 --- a/drivers/gpu/drm/radeon/radeon_cs.c
1281 +++ b/drivers/gpu/drm/radeon/radeon_cs.c
1282 @@ -275,11 +275,13 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
1283 u32 ring = RADEON_CS_RING_GFX;
1284 s32 priority = 0;
1285
1286 + INIT_LIST_HEAD(&p->validated);
1287 +
1288 if (!cs->num_chunks) {
1289 return 0;
1290 }
1291 +
1292 /* get chunks */
1293 - INIT_LIST_HEAD(&p->validated);
1294 p->idx = 0;
1295 p->ib.sa_bo = NULL;
1296 p->ib.semaphore = NULL;
1297 diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
1298 index 995167025282..8569afaba688 100644
1299 --- a/drivers/gpu/drm/radeon/radeon_fence.c
1300 +++ b/drivers/gpu/drm/radeon/radeon_fence.c
1301 @@ -1029,37 +1029,59 @@ static inline bool radeon_test_signaled(struct radeon_fence *fence)
1302 return test_bit(FENCE_FLAG_SIGNALED_BIT, &fence->base.flags);
1303 }
1304
1305 +struct radeon_wait_cb {
1306 + struct fence_cb base;
1307 + struct task_struct *task;
1308 +};
1309 +
1310 +static void
1311 +radeon_fence_wait_cb(struct fence *fence, struct fence_cb *cb)
1312 +{
1313 + struct radeon_wait_cb *wait =
1314 + container_of(cb, struct radeon_wait_cb, base);
1315 +
1316 + wake_up_process(wait->task);
1317 +}
1318 +
1319 static signed long radeon_fence_default_wait(struct fence *f, bool intr,
1320 signed long t)
1321 {
1322 struct radeon_fence *fence = to_radeon_fence(f);
1323 struct radeon_device *rdev = fence->rdev;
1324 - bool signaled;
1325 + struct radeon_wait_cb cb;
1326
1327 - fence_enable_sw_signaling(&fence->base);
1328 + cb.task = current;
1329
1330 - /*
1331 - * This function has to return -EDEADLK, but cannot hold
1332 - * exclusive_lock during the wait because some callers
1333 - * may already hold it. This means checking needs_reset without
1334 - * lock, and not fiddling with any gpu internals.
1335 - *
1336 - * The callback installed with fence_enable_sw_signaling will
1337 - * run before our wait_event_*timeout call, so we will see
1338 - * both the signaled fence and the changes to needs_reset.
1339 - */
1340 + if (fence_add_callback(f, &cb.base, radeon_fence_wait_cb))
1341 + return t;
1342 +
1343 + while (t > 0) {
1344 + if (intr)
1345 + set_current_state(TASK_INTERRUPTIBLE);
1346 + else
1347 + set_current_state(TASK_UNINTERRUPTIBLE);
1348 +
1349 + /*
1350 + * radeon_test_signaled must be called after
1351 + * set_current_state to prevent a race with wake_up_process
1352 + */
1353 + if (radeon_test_signaled(fence))
1354 + break;
1355 +
1356 + if (rdev->needs_reset) {
1357 + t = -EDEADLK;
1358 + break;
1359 + }
1360 +
1361 + t = schedule_timeout(t);
1362 +
1363 + if (t > 0 && intr && signal_pending(current))
1364 + t = -ERESTARTSYS;
1365 + }
1366 +
1367 + __set_current_state(TASK_RUNNING);
1368 + fence_remove_callback(f, &cb.base);
1369
1370 - if (intr)
1371 - t = wait_event_interruptible_timeout(rdev->fence_queue,
1372 - ((signaled = radeon_test_signaled(fence)) ||
1373 - rdev->needs_reset), t);
1374 - else
1375 - t = wait_event_timeout(rdev->fence_queue,
1376 - ((signaled = radeon_test_signaled(fence)) ||
1377 - rdev->needs_reset), t);
1378 -
1379 - if (t > 0 && !signaled)
1380 - return -EDEADLK;
1381 return t;
1382 }
1383
1384 diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
1385 index 194f6245c379..2a7ba30165c7 100644
1386 --- a/drivers/gpu/drm/radeon/radeon_object.c
1387 +++ b/drivers/gpu/drm/radeon/radeon_object.c
1388 @@ -151,19 +151,6 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
1389 else
1390 rbo->placements[i].lpfn = 0;
1391 }
1392 -
1393 - /*
1394 - * Use two-ended allocation depending on the buffer size to
1395 - * improve fragmentation quality.
1396 - * 512kb was measured as the most optimal number.
1397 - */
1398 - if (!((rbo->flags & RADEON_GEM_CPU_ACCESS) &&
1399 - (rbo->placements[i].flags & TTM_PL_FLAG_VRAM)) &&
1400 - rbo->tbo.mem.size > 512 * 1024) {
1401 - for (i = 0; i < c; i++) {
1402 - rbo->placements[i].flags |= TTM_PL_FLAG_TOPDOWN;
1403 - }
1404 - }
1405 }
1406
1407 int radeon_bo_create(struct radeon_device *rdev,
1408 diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
1409 index 74bce91aecc1..039660662ee8 100644
1410 --- a/drivers/gpu/drm/radeon/rs600.c
1411 +++ b/drivers/gpu/drm/radeon/rs600.c
1412 @@ -693,6 +693,10 @@ int rs600_irq_set(struct radeon_device *rdev)
1413 WREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL, hpd2);
1414 if (ASIC_IS_DCE2(rdev))
1415 WREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL, hdmi0);
1416 +
1417 + /* posting read */
1418 + RREG32(R_000040_GEN_INT_CNTL);
1419 +
1420 return 0;
1421 }
1422
1423 diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
1424 index 7d5083dc4acb..1c3d90c17cb3 100644
1425 --- a/drivers/gpu/drm/radeon/si.c
1426 +++ b/drivers/gpu/drm/radeon/si.c
1427 @@ -6192,6 +6192,9 @@ int si_irq_set(struct radeon_device *rdev)
1428
1429 WREG32(CG_THERMAL_INT, thermal_int);
1430
1431 + /* posting read */
1432 + RREG32(SRBM_STATUS);
1433 +
1434 return 0;
1435 }
1436
1437 @@ -7112,8 +7115,7 @@ int si_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk)
1438 WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_BYPASS_EN_MASK, ~UPLL_BYPASS_EN_MASK);
1439
1440 if (!vclk || !dclk) {
1441 - /* keep the Bypass mode, put PLL to sleep */
1442 - WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_SLEEP_MASK, ~UPLL_SLEEP_MASK);
1443 + /* keep the Bypass mode */
1444 return 0;
1445 }
1446
1447 @@ -7129,8 +7131,7 @@ int si_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk)
1448 /* set VCO_MODE to 1 */
1449 WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_VCO_MODE_MASK, ~UPLL_VCO_MODE_MASK);
1450
1451 - /* toggle UPLL_SLEEP to 1 then back to 0 */
1452 - WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_SLEEP_MASK, ~UPLL_SLEEP_MASK);
1453 + /* disable sleep mode */
1454 WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_SLEEP_MASK);
1455
1456 /* deassert UPLL_RESET */
1457 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
1458 index 810dac80179c..0426b5bed8fc 100644
1459 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
1460 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
1461 @@ -725,32 +725,6 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
1462 goto out_err1;
1463 }
1464
1465 - ret = ttm_bo_init_mm(&dev_priv->bdev, TTM_PL_VRAM,
1466 - (dev_priv->vram_size >> PAGE_SHIFT));
1467 - if (unlikely(ret != 0)) {
1468 - DRM_ERROR("Failed initializing memory manager for VRAM.\n");
1469 - goto out_err2;
1470 - }
1471 -
1472 - dev_priv->has_gmr = true;
1473 - if (((dev_priv->capabilities & (SVGA_CAP_GMR | SVGA_CAP_GMR2)) == 0) ||
1474 - refuse_dma || ttm_bo_init_mm(&dev_priv->bdev, VMW_PL_GMR,
1475 - VMW_PL_GMR) != 0) {
1476 - DRM_INFO("No GMR memory available. "
1477 - "Graphics memory resources are very limited.\n");
1478 - dev_priv->has_gmr = false;
1479 - }
1480 -
1481 - if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS) {
1482 - dev_priv->has_mob = true;
1483 - if (ttm_bo_init_mm(&dev_priv->bdev, VMW_PL_MOB,
1484 - VMW_PL_MOB) != 0) {
1485 - DRM_INFO("No MOB memory available. "
1486 - "3D will be disabled.\n");
1487 - dev_priv->has_mob = false;
1488 - }
1489 - }
1490 -
1491 dev_priv->mmio_mtrr = arch_phys_wc_add(dev_priv->mmio_start,
1492 dev_priv->mmio_size);
1493
1494 @@ -813,6 +787,33 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
1495 goto out_no_fman;
1496 }
1497
1498 +
1499 + ret = ttm_bo_init_mm(&dev_priv->bdev, TTM_PL_VRAM,
1500 + (dev_priv->vram_size >> PAGE_SHIFT));
1501 + if (unlikely(ret != 0)) {
1502 + DRM_ERROR("Failed initializing memory manager for VRAM.\n");
1503 + goto out_no_vram;
1504 + }
1505 +
1506 + dev_priv->has_gmr = true;
1507 + if (((dev_priv->capabilities & (SVGA_CAP_GMR | SVGA_CAP_GMR2)) == 0) ||
1508 + refuse_dma || ttm_bo_init_mm(&dev_priv->bdev, VMW_PL_GMR,
1509 + VMW_PL_GMR) != 0) {
1510 + DRM_INFO("No GMR memory available. "
1511 + "Graphics memory resources are very limited.\n");
1512 + dev_priv->has_gmr = false;
1513 + }
1514 +
1515 + if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS) {
1516 + dev_priv->has_mob = true;
1517 + if (ttm_bo_init_mm(&dev_priv->bdev, VMW_PL_MOB,
1518 + VMW_PL_MOB) != 0) {
1519 + DRM_INFO("No MOB memory available. "
1520 + "3D will be disabled.\n");
1521 + dev_priv->has_mob = false;
1522 + }
1523 + }
1524 +
1525 vmw_kms_save_vga(dev_priv);
1526
1527 /* Start kms and overlay systems, needs fifo. */
1528 @@ -838,6 +839,12 @@ out_no_fifo:
1529 vmw_kms_close(dev_priv);
1530 out_no_kms:
1531 vmw_kms_restore_vga(dev_priv);
1532 + if (dev_priv->has_mob)
1533 + (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
1534 + if (dev_priv->has_gmr)
1535 + (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
1536 + (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
1537 +out_no_vram:
1538 vmw_fence_manager_takedown(dev_priv->fman);
1539 out_no_fman:
1540 if (dev_priv->capabilities & SVGA_CAP_IRQMASK)
1541 @@ -853,12 +860,6 @@ out_err4:
1542 iounmap(dev_priv->mmio_virt);
1543 out_err3:
1544 arch_phys_wc_del(dev_priv->mmio_mtrr);
1545 - if (dev_priv->has_mob)
1546 - (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
1547 - if (dev_priv->has_gmr)
1548 - (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
1549 - (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
1550 -out_err2:
1551 (void)ttm_bo_device_release(&dev_priv->bdev);
1552 out_err1:
1553 vmw_ttm_global_release(dev_priv);
1554 @@ -888,6 +889,13 @@ static int vmw_driver_unload(struct drm_device *dev)
1555 }
1556 vmw_kms_close(dev_priv);
1557 vmw_overlay_close(dev_priv);
1558 +
1559 + if (dev_priv->has_mob)
1560 + (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
1561 + if (dev_priv->has_gmr)
1562 + (void)ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
1563 + (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
1564 +
1565 vmw_fence_manager_takedown(dev_priv->fman);
1566 if (dev_priv->capabilities & SVGA_CAP_IRQMASK)
1567 drm_irq_uninstall(dev_priv->dev);
1568 @@ -899,11 +907,6 @@ static int vmw_driver_unload(struct drm_device *dev)
1569 ttm_object_device_release(&dev_priv->tdev);
1570 iounmap(dev_priv->mmio_virt);
1571 arch_phys_wc_del(dev_priv->mmio_mtrr);
1572 - if (dev_priv->has_mob)
1573 - (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
1574 - if (dev_priv->has_gmr)
1575 - (void)ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
1576 - (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
1577 (void)ttm_bo_device_release(&dev_priv->bdev);
1578 vmw_ttm_global_release(dev_priv);
1579
1580 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
1581 index 596cd6dafd33..50b52802f470 100644
1582 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
1583 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
1584 @@ -2778,13 +2778,11 @@ int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
1585 NULL, arg->command_size, arg->throttle_us,
1586 (void __user *)(unsigned long)arg->fence_rep,
1587 NULL);
1588 -
1589 + ttm_read_unlock(&dev_priv->reservation_sem);
1590 if (unlikely(ret != 0))
1591 - goto out_unlock;
1592 + return ret;
1593
1594 vmw_kms_cursor_post_execbuf(dev_priv);
1595
1596 -out_unlock:
1597 - ttm_read_unlock(&dev_priv->reservation_sem);
1598 - return ret;
1599 + return 0;
1600 }
1601 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
1602 index fddd53335237..173ec3377e4f 100644
1603 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
1604 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
1605 @@ -2033,23 +2033,17 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
1606 int i;
1607 struct drm_mode_config *mode_config = &dev->mode_config;
1608
1609 - ret = ttm_read_lock(&dev_priv->reservation_sem, true);
1610 - if (unlikely(ret != 0))
1611 - return ret;
1612 -
1613 if (!arg->num_outputs) {
1614 struct drm_vmw_rect def_rect = {0, 0, 800, 600};
1615 vmw_du_update_layout(dev_priv, 1, &def_rect);
1616 - goto out_unlock;
1617 + return 0;
1618 }
1619
1620 rects_size = arg->num_outputs * sizeof(struct drm_vmw_rect);
1621 rects = kcalloc(arg->num_outputs, sizeof(struct drm_vmw_rect),
1622 GFP_KERNEL);
1623 - if (unlikely(!rects)) {
1624 - ret = -ENOMEM;
1625 - goto out_unlock;
1626 - }
1627 + if (unlikely(!rects))
1628 + return -ENOMEM;
1629
1630 user_rects = (void __user *)(unsigned long)arg->rects;
1631 ret = copy_from_user(rects, user_rects, rects_size);
1632 @@ -2074,7 +2068,5 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
1633
1634 out_free:
1635 kfree(rects);
1636 -out_unlock:
1637 - ttm_read_unlock(&dev_priv->reservation_sem);
1638 return ret;
1639 }
1640 diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
1641 index f43b4e11647a..17a1853c6c2f 100644
1642 --- a/drivers/i2c/i2c-core.c
1643 +++ b/drivers/i2c/i2c-core.c
1644 @@ -665,9 +665,6 @@ static int i2c_device_remove(struct device *dev)
1645 status = driver->remove(client);
1646 }
1647
1648 - if (dev->of_node)
1649 - irq_dispose_mapping(client->irq);
1650 -
1651 dev_pm_domain_detach(&client->dev, true);
1652 return status;
1653 }
1654 diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
1655 index 6a2e168c3ab0..41ac85af043e 100644
1656 --- a/drivers/irqchip/irq-armada-370-xp.c
1657 +++ b/drivers/irqchip/irq-armada-370-xp.c
1658 @@ -67,6 +67,7 @@
1659 static void __iomem *per_cpu_int_base;
1660 static void __iomem *main_int_base;
1661 static struct irq_domain *armada_370_xp_mpic_domain;
1662 +static int parent_irq;
1663 #ifdef CONFIG_PCI_MSI
1664 static struct irq_domain *armada_370_xp_msi_domain;
1665 static DECLARE_BITMAP(msi_used, PCI_MSI_DOORBELL_NR);
1666 @@ -354,6 +355,7 @@ static int armada_xp_mpic_secondary_init(struct notifier_block *nfb,
1667 {
1668 if (action == CPU_STARTING || action == CPU_STARTING_FROZEN)
1669 armada_xp_mpic_smp_cpu_init();
1670 +
1671 return NOTIFY_OK;
1672 }
1673
1674 @@ -362,6 +364,20 @@ static struct notifier_block armada_370_xp_mpic_cpu_notifier = {
1675 .priority = 100,
1676 };
1677
1678 +static int mpic_cascaded_secondary_init(struct notifier_block *nfb,
1679 + unsigned long action, void *hcpu)
1680 +{
1681 + if (action == CPU_STARTING || action == CPU_STARTING_FROZEN)
1682 + enable_percpu_irq(parent_irq, IRQ_TYPE_NONE);
1683 +
1684 + return NOTIFY_OK;
1685 +}
1686 +
1687 +static struct notifier_block mpic_cascaded_cpu_notifier = {
1688 + .notifier_call = mpic_cascaded_secondary_init,
1689 + .priority = 100,
1690 +};
1691 +
1692 #endif /* CONFIG_SMP */
1693
1694 static struct irq_domain_ops armada_370_xp_mpic_irq_ops = {
1695 @@ -489,7 +505,7 @@ static int __init armada_370_xp_mpic_of_init(struct device_node *node,
1696 struct device_node *parent)
1697 {
1698 struct resource main_int_res, per_cpu_int_res;
1699 - int parent_irq, nr_irqs, i;
1700 + int nr_irqs, i;
1701 u32 control;
1702
1703 BUG_ON(of_address_to_resource(node, 0, &main_int_res));
1704 @@ -537,6 +553,9 @@ static int __init armada_370_xp_mpic_of_init(struct device_node *node,
1705 register_cpu_notifier(&armada_370_xp_mpic_cpu_notifier);
1706 #endif
1707 } else {
1708 +#ifdef CONFIG_SMP
1709 + register_cpu_notifier(&mpic_cascaded_cpu_notifier);
1710 +#endif
1711 irq_set_chained_handler(parent_irq,
1712 armada_370_xp_mpic_handle_cascade_irq);
1713 }
1714 diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
1715 index 96b0b1d27df1..bc677362bc73 100644
1716 --- a/drivers/mtd/nand/pxa3xx_nand.c
1717 +++ b/drivers/mtd/nand/pxa3xx_nand.c
1718 @@ -480,6 +480,42 @@ static void disable_int(struct pxa3xx_nand_info *info, uint32_t int_mask)
1719 nand_writel(info, NDCR, ndcr | int_mask);
1720 }
1721
1722 +static void drain_fifo(struct pxa3xx_nand_info *info, void *data, int len)
1723 +{
1724 + if (info->ecc_bch) {
1725 + int timeout;
1726 +
1727 + /*
1728 + * According to the datasheet, when reading from NDDB
1729 + * with BCH enabled, after each 32 bytes reads, we
1730 + * have to make sure that the NDSR.RDDREQ bit is set.
1731 + *
1732 + * Drain the FIFO 8 32 bits reads at a time, and skip
1733 + * the polling on the last read.
1734 + */
1735 + while (len > 8) {
1736 + __raw_readsl(info->mmio_base + NDDB, data, 8);
1737 +
1738 + for (timeout = 0;
1739 + !(nand_readl(info, NDSR) & NDSR_RDDREQ);
1740 + timeout++) {
1741 + if (timeout >= 5) {
1742 + dev_err(&info->pdev->dev,
1743 + "Timeout on RDDREQ while draining the FIFO\n");
1744 + return;
1745 + }
1746 +
1747 + mdelay(1);
1748 + }
1749 +
1750 + data += 32;
1751 + len -= 8;
1752 + }
1753 + }
1754 +
1755 + __raw_readsl(info->mmio_base + NDDB, data, len);
1756 +}
1757 +
1758 static void handle_data_pio(struct pxa3xx_nand_info *info)
1759 {
1760 unsigned int do_bytes = min(info->data_size, info->chunk_size);
1761 @@ -496,14 +532,14 @@ static void handle_data_pio(struct pxa3xx_nand_info *info)
1762 DIV_ROUND_UP(info->oob_size, 4));
1763 break;
1764 case STATE_PIO_READING:
1765 - __raw_readsl(info->mmio_base + NDDB,
1766 - info->data_buff + info->data_buff_pos,
1767 - DIV_ROUND_UP(do_bytes, 4));
1768 + drain_fifo(info,
1769 + info->data_buff + info->data_buff_pos,
1770 + DIV_ROUND_UP(do_bytes, 4));
1771
1772 if (info->oob_size > 0)
1773 - __raw_readsl(info->mmio_base + NDDB,
1774 - info->oob_buff + info->oob_buff_pos,
1775 - DIV_ROUND_UP(info->oob_size, 4));
1776 + drain_fifo(info,
1777 + info->oob_buff + info->oob_buff_pos,
1778 + DIV_ROUND_UP(info->oob_size, 4));
1779 break;
1780 default:
1781 dev_err(&info->pdev->dev, "%s: invalid state %d\n", __func__,
1782 diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
1783 index 4b008c9c738d..573b53b38af4 100644
1784 --- a/drivers/net/can/dev.c
1785 +++ b/drivers/net/can/dev.c
1786 @@ -500,6 +500,10 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
1787 skb->pkt_type = PACKET_BROADCAST;
1788 skb->ip_summed = CHECKSUM_UNNECESSARY;
1789
1790 + skb_reset_mac_header(skb);
1791 + skb_reset_network_header(skb);
1792 + skb_reset_transport_header(skb);
1793 +
1794 can_skb_reserve(skb);
1795 can_skb_prv(skb)->ifindex = dev->ifindex;
1796
1797 @@ -524,6 +528,10 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
1798 skb->pkt_type = PACKET_BROADCAST;
1799 skb->ip_summed = CHECKSUM_UNNECESSARY;
1800
1801 + skb_reset_mac_header(skb);
1802 + skb_reset_network_header(skb);
1803 + skb_reset_transport_header(skb);
1804 +
1805 can_skb_reserve(skb);
1806 can_skb_prv(skb)->ifindex = dev->ifindex;
1807
1808 diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
1809 index 8b255e777cc7..5d777956ae1f 100644
1810 --- a/drivers/net/can/usb/kvaser_usb.c
1811 +++ b/drivers/net/can/usb/kvaser_usb.c
1812 @@ -12,6 +12,7 @@
1813 * Copyright (C) 2012 Olivier Sobrie <olivier@sobrie.be>
1814 */
1815
1816 +#include <linux/kernel.h>
1817 #include <linux/completion.h>
1818 #include <linux/module.h>
1819 #include <linux/netdevice.h>
1820 @@ -403,8 +404,15 @@ static int kvaser_usb_wait_msg(const struct kvaser_usb *dev, u8 id,
1821 while (pos <= actual_len - MSG_HEADER_LEN) {
1822 tmp = buf + pos;
1823
1824 - if (!tmp->len)
1825 - break;
1826 + /* Handle messages crossing the USB endpoint max packet
1827 + * size boundary. Check kvaser_usb_read_bulk_callback()
1828 + * for further details.
1829 + */
1830 + if (tmp->len == 0) {
1831 + pos = round_up(pos,
1832 + dev->bulk_in->wMaxPacketSize);
1833 + continue;
1834 + }
1835
1836 if (pos + tmp->len > actual_len) {
1837 dev_err(dev->udev->dev.parent,
1838 @@ -983,8 +991,19 @@ static void kvaser_usb_read_bulk_callback(struct urb *urb)
1839 while (pos <= urb->actual_length - MSG_HEADER_LEN) {
1840 msg = urb->transfer_buffer + pos;
1841
1842 - if (!msg->len)
1843 - break;
1844 + /* The Kvaser firmware can only read and write messages that
1845 + * does not cross the USB's endpoint wMaxPacketSize boundary.
1846 + * If a follow-up command crosses such boundary, firmware puts
1847 + * a placeholder zero-length command in its place then aligns
1848 + * the real command to the next max packet size.
1849 + *
1850 + * Handle such cases or we're going to miss a significant
1851 + * number of events in case of a heavy rx load on the bus.
1852 + */
1853 + if (msg->len == 0) {
1854 + pos = round_up(pos, dev->bulk_in->wMaxPacketSize);
1855 + continue;
1856 + }
1857
1858 if (pos + msg->len > urb->actual_length) {
1859 dev_err(dev->udev->dev.parent, "Format error\n");
1860 @@ -992,7 +1011,6 @@ static void kvaser_usb_read_bulk_callback(struct urb *urb)
1861 }
1862
1863 kvaser_usb_handle_message(dev, msg);
1864 -
1865 pos += msg->len;
1866 }
1867
1868 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
1869 index 74fbf9ea7bd8..710eb5793eb3 100644
1870 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
1871 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
1872 @@ -12711,6 +12711,9 @@ static int bnx2x_init_dev(struct bnx2x *bp, struct pci_dev *pdev,
1873 pci_write_config_dword(bp->pdev, PCICFG_GRC_ADDRESS,
1874 PCICFG_VENDOR_ID_OFFSET);
1875
1876 + /* Set PCIe reset type to fundamental for EEH recovery */
1877 + pdev->needs_freset = 1;
1878 +
1879 /* AER (Advanced Error reporting) configuration */
1880 rc = pci_enable_pcie_error_reporting(pdev);
1881 if (!rc)
1882 diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
1883 index 3dca494797bd..96ba23e90111 100644
1884 --- a/drivers/net/ethernet/freescale/fec_main.c
1885 +++ b/drivers/net/ethernet/freescale/fec_main.c
1886 @@ -1464,8 +1464,7 @@ fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
1887
1888 vlan_packet_rcvd = true;
1889
1890 - skb_copy_to_linear_data_offset(skb, VLAN_HLEN,
1891 - data, (2 * ETH_ALEN));
1892 + memmove(skb->data + VLAN_HLEN, data, ETH_ALEN * 2);
1893 skb_pull(skb, VLAN_HLEN);
1894 }
1895
1896 diff --git a/drivers/net/usb/cx82310_eth.c b/drivers/net/usb/cx82310_eth.c
1897 index 3eed708a6182..fe48f4c51373 100644
1898 --- a/drivers/net/usb/cx82310_eth.c
1899 +++ b/drivers/net/usb/cx82310_eth.c
1900 @@ -300,9 +300,18 @@ static const struct driver_info cx82310_info = {
1901 .tx_fixup = cx82310_tx_fixup,
1902 };
1903
1904 +#define USB_DEVICE_CLASS(vend, prod, cl, sc, pr) \
1905 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
1906 + USB_DEVICE_ID_MATCH_DEV_INFO, \
1907 + .idVendor = (vend), \
1908 + .idProduct = (prod), \
1909 + .bDeviceClass = (cl), \
1910 + .bDeviceSubClass = (sc), \
1911 + .bDeviceProtocol = (pr)
1912 +
1913 static const struct usb_device_id products[] = {
1914 {
1915 - USB_DEVICE_AND_INTERFACE_INFO(0x0572, 0xcb01, 0xff, 0, 0),
1916 + USB_DEVICE_CLASS(0x0572, 0xcb01, 0xff, 0, 0),
1917 .driver_info = (unsigned long) &cx82310_info
1918 },
1919 { },
1920 diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
1921 index b0bc8ead47de..484ecce78025 100644
1922 --- a/drivers/net/virtio_net.c
1923 +++ b/drivers/net/virtio_net.c
1924 @@ -1452,8 +1452,10 @@ static void virtnet_free_queues(struct virtnet_info *vi)
1925 {
1926 int i;
1927
1928 - for (i = 0; i < vi->max_queue_pairs; i++)
1929 + for (i = 0; i < vi->max_queue_pairs; i++) {
1930 + napi_hash_del(&vi->rq[i].napi);
1931 netif_napi_del(&vi->rq[i].napi);
1932 + }
1933
1934 kfree(vi->rq);
1935 kfree(vi->sq);
1936 @@ -1939,11 +1941,8 @@ static int virtnet_freeze(struct virtio_device *vdev)
1937 cancel_delayed_work_sync(&vi->refill);
1938
1939 if (netif_running(vi->dev)) {
1940 - for (i = 0; i < vi->max_queue_pairs; i++) {
1941 + for (i = 0; i < vi->max_queue_pairs; i++)
1942 napi_disable(&vi->rq[i].napi);
1943 - napi_hash_del(&vi->rq[i].napi);
1944 - netif_napi_del(&vi->rq[i].napi);
1945 - }
1946 }
1947
1948 remove_vq_common(vi);
1949 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
1950 index 2c6643fdc0cf..eb1543841e39 100644
1951 --- a/drivers/pci/pci-sysfs.c
1952 +++ b/drivers/pci/pci-sysfs.c
1953 @@ -515,7 +515,8 @@ static ssize_t driver_override_store(struct device *dev,
1954 struct pci_dev *pdev = to_pci_dev(dev);
1955 char *driver_override, *old = pdev->driver_override, *cp;
1956
1957 - if (count > PATH_MAX)
1958 + /* We need to keep extra room for a newline */
1959 + if (count >= (PAGE_SIZE - 1))
1960 return -EINVAL;
1961
1962 driver_override = kstrndup(buf, count, GFP_KERNEL);
1963 @@ -543,7 +544,7 @@ static ssize_t driver_override_show(struct device *dev,
1964 {
1965 struct pci_dev *pdev = to_pci_dev(dev);
1966
1967 - return sprintf(buf, "%s\n", pdev->driver_override);
1968 + return snprintf(buf, PAGE_SIZE, "%s\n", pdev->driver_override);
1969 }
1970 static DEVICE_ATTR_RW(driver_override);
1971
1972 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
1973 index fc6fb5422b6f..d92612c51657 100644
1974 --- a/drivers/regulator/core.c
1975 +++ b/drivers/regulator/core.c
1976 @@ -1841,10 +1841,12 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
1977 }
1978
1979 if (rdev->ena_pin) {
1980 - ret = regulator_ena_gpio_ctrl(rdev, true);
1981 - if (ret < 0)
1982 - return ret;
1983 - rdev->ena_gpio_state = 1;
1984 + if (!rdev->ena_gpio_state) {
1985 + ret = regulator_ena_gpio_ctrl(rdev, true);
1986 + if (ret < 0)
1987 + return ret;
1988 + rdev->ena_gpio_state = 1;
1989 + }
1990 } else if (rdev->desc->ops->enable) {
1991 ret = rdev->desc->ops->enable(rdev);
1992 if (ret < 0)
1993 @@ -1941,10 +1943,12 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
1994 trace_regulator_disable(rdev_get_name(rdev));
1995
1996 if (rdev->ena_pin) {
1997 - ret = regulator_ena_gpio_ctrl(rdev, false);
1998 - if (ret < 0)
1999 - return ret;
2000 - rdev->ena_gpio_state = 0;
2001 + if (rdev->ena_gpio_state) {
2002 + ret = regulator_ena_gpio_ctrl(rdev, false);
2003 + if (ret < 0)
2004 + return ret;
2005 + rdev->ena_gpio_state = 0;
2006 + }
2007
2008 } else if (rdev->desc->ops->disable) {
2009 ret = rdev->desc->ops->disable(rdev);
2010 @@ -3659,12 +3663,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
2011 config->ena_gpio, ret);
2012 goto wash;
2013 }
2014 -
2015 - if (config->ena_gpio_flags & GPIOF_OUT_INIT_HIGH)
2016 - rdev->ena_gpio_state = 1;
2017 -
2018 - if (config->ena_gpio_invert)
2019 - rdev->ena_gpio_state = !rdev->ena_gpio_state;
2020 }
2021
2022 /* set regulator constraints */
2023 @@ -3837,9 +3835,11 @@ int regulator_suspend_finish(void)
2024 list_for_each_entry(rdev, &regulator_list, list) {
2025 mutex_lock(&rdev->mutex);
2026 if (rdev->use_count > 0 || rdev->constraints->always_on) {
2027 - error = _regulator_do_enable(rdev);
2028 - if (error)
2029 - ret = error;
2030 + if (!_regulator_is_enabled(rdev)) {
2031 + error = _regulator_do_enable(rdev);
2032 + if (error)
2033 + ret = error;
2034 + }
2035 } else {
2036 if (!have_full_constraints())
2037 goto unlock;
2038 diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
2039 index 196a5c8838c4..b019956ba5dd 100644
2040 --- a/drivers/regulator/rk808-regulator.c
2041 +++ b/drivers/regulator/rk808-regulator.c
2042 @@ -184,6 +184,7 @@ static const struct regulator_desc rk808_reg[] = {
2043 .vsel_mask = RK808_LDO_VSEL_MASK,
2044 .enable_reg = RK808_LDO_EN_REG,
2045 .enable_mask = BIT(0),
2046 + .enable_time = 400,
2047 .owner = THIS_MODULE,
2048 }, {
2049 .name = "LDO_REG2",
2050 @@ -198,6 +199,7 @@ static const struct regulator_desc rk808_reg[] = {
2051 .vsel_mask = RK808_LDO_VSEL_MASK,
2052 .enable_reg = RK808_LDO_EN_REG,
2053 .enable_mask = BIT(1),
2054 + .enable_time = 400,
2055 .owner = THIS_MODULE,
2056 }, {
2057 .name = "LDO_REG3",
2058 @@ -212,6 +214,7 @@ static const struct regulator_desc rk808_reg[] = {
2059 .vsel_mask = RK808_BUCK4_VSEL_MASK,
2060 .enable_reg = RK808_LDO_EN_REG,
2061 .enable_mask = BIT(2),
2062 + .enable_time = 400,
2063 .owner = THIS_MODULE,
2064 }, {
2065 .name = "LDO_REG4",
2066 @@ -226,6 +229,7 @@ static const struct regulator_desc rk808_reg[] = {
2067 .vsel_mask = RK808_LDO_VSEL_MASK,
2068 .enable_reg = RK808_LDO_EN_REG,
2069 .enable_mask = BIT(3),
2070 + .enable_time = 400,
2071 .owner = THIS_MODULE,
2072 }, {
2073 .name = "LDO_REG5",
2074 @@ -240,6 +244,7 @@ static const struct regulator_desc rk808_reg[] = {
2075 .vsel_mask = RK808_LDO_VSEL_MASK,
2076 .enable_reg = RK808_LDO_EN_REG,
2077 .enable_mask = BIT(4),
2078 + .enable_time = 400,
2079 .owner = THIS_MODULE,
2080 }, {
2081 .name = "LDO_REG6",
2082 @@ -254,6 +259,7 @@ static const struct regulator_desc rk808_reg[] = {
2083 .vsel_mask = RK808_LDO_VSEL_MASK,
2084 .enable_reg = RK808_LDO_EN_REG,
2085 .enable_mask = BIT(5),
2086 + .enable_time = 400,
2087 .owner = THIS_MODULE,
2088 }, {
2089 .name = "LDO_REG7",
2090 @@ -268,6 +274,7 @@ static const struct regulator_desc rk808_reg[] = {
2091 .vsel_mask = RK808_LDO_VSEL_MASK,
2092 .enable_reg = RK808_LDO_EN_REG,
2093 .enable_mask = BIT(6),
2094 + .enable_time = 400,
2095 .owner = THIS_MODULE,
2096 }, {
2097 .name = "LDO_REG8",
2098 @@ -282,6 +289,7 @@ static const struct regulator_desc rk808_reg[] = {
2099 .vsel_mask = RK808_LDO_VSEL_MASK,
2100 .enable_reg = RK808_LDO_EN_REG,
2101 .enable_mask = BIT(7),
2102 + .enable_time = 400,
2103 .owner = THIS_MODULE,
2104 }, {
2105 .name = "SWITCH_REG1",
2106 diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
2107 index 806072238c00..22a612b06742 100644
2108 --- a/drivers/rtc/rtc-s3c.c
2109 +++ b/drivers/rtc/rtc-s3c.c
2110 @@ -849,6 +849,7 @@ static struct s3c_rtc_data const s3c2443_rtc_data = {
2111
2112 static struct s3c_rtc_data const s3c6410_rtc_data = {
2113 .max_user_freq = 32768,
2114 + .needs_src_clk = true,
2115 .irq_handler = s3c6410_rtc_irq,
2116 .set_freq = s3c6410_rtc_setfreq,
2117 .enable_tick = s3c6410_rtc_enable_tick,
2118 diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
2119 index 62b58d38ce2e..60de66252fa2 100644
2120 --- a/drivers/scsi/libsas/sas_discover.c
2121 +++ b/drivers/scsi/libsas/sas_discover.c
2122 @@ -500,6 +500,7 @@ static void sas_revalidate_domain(struct work_struct *work)
2123 struct sas_discovery_event *ev = to_sas_discovery_event(work);
2124 struct asd_sas_port *port = ev->port;
2125 struct sas_ha_struct *ha = port->ha;
2126 + struct domain_device *ddev = port->port_dev;
2127
2128 /* prevent revalidation from finding sata links in recovery */
2129 mutex_lock(&ha->disco_mutex);
2130 @@ -514,8 +515,9 @@ static void sas_revalidate_domain(struct work_struct *work)
2131 SAS_DPRINTK("REVALIDATING DOMAIN on port %d, pid:%d\n", port->id,
2132 task_pid_nr(current));
2133
2134 - if (port->port_dev)
2135 - res = sas_ex_revalidate_domain(port->port_dev);
2136 + if (ddev && (ddev->dev_type == SAS_FANOUT_EXPANDER_DEVICE ||
2137 + ddev->dev_type == SAS_EDGE_EXPANDER_DEVICE))
2138 + res = sas_ex_revalidate_domain(ddev);
2139
2140 SAS_DPRINTK("done REVALIDATING DOMAIN on port %d, pid:%d, res 0x%x\n",
2141 port->id, task_pid_nr(current), res);
2142 diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
2143 index 113c83f44b5c..4bf337aa4fd5 100644
2144 --- a/drivers/spi/spi-atmel.c
2145 +++ b/drivers/spi/spi-atmel.c
2146 @@ -775,17 +775,17 @@ static void atmel_spi_pdc_next_xfer(struct spi_master *master,
2147 (unsigned long long)xfer->rx_dma);
2148 }
2149
2150 - /* REVISIT: We're waiting for ENDRX before we start the next
2151 + /* REVISIT: We're waiting for RXBUFF before we start the next
2152 * transfer because we need to handle some difficult timing
2153 - * issues otherwise. If we wait for ENDTX in one transfer and
2154 - * then starts waiting for ENDRX in the next, it's difficult
2155 - * to tell the difference between the ENDRX interrupt we're
2156 - * actually waiting for and the ENDRX interrupt of the
2157 + * issues otherwise. If we wait for TXBUFE in one transfer and
2158 + * then starts waiting for RXBUFF in the next, it's difficult
2159 + * to tell the difference between the RXBUFF interrupt we're
2160 + * actually waiting for and the RXBUFF interrupt of the
2161 * previous transfer.
2162 *
2163 * It should be doable, though. Just not now...
2164 */
2165 - spi_writel(as, IER, SPI_BIT(ENDRX) | SPI_BIT(OVRES));
2166 + spi_writel(as, IER, SPI_BIT(RXBUFF) | SPI_BIT(OVRES));
2167 spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN));
2168 }
2169
2170 diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
2171 index efff55537d8a..1417f96546ce 100644
2172 --- a/drivers/spi/spi-dw-mid.c
2173 +++ b/drivers/spi/spi-dw-mid.c
2174 @@ -151,6 +151,9 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
2175 1,
2176 DMA_MEM_TO_DEV,
2177 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
2178 + if (!txdesc)
2179 + return NULL;
2180 +
2181 txdesc->callback = dw_spi_dma_done;
2182 txdesc->callback_param = dws;
2183
2184 @@ -173,6 +176,9 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
2185 1,
2186 DMA_DEV_TO_MEM,
2187 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
2188 + if (!rxdesc)
2189 + return NULL;
2190 +
2191 rxdesc->callback = dw_spi_dma_done;
2192 rxdesc->callback_param = dws;
2193
2194 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
2195 index fc2dd8441608..11e18342bc4f 100644
2196 --- a/drivers/spi/spi-pl022.c
2197 +++ b/drivers/spi/spi-pl022.c
2198 @@ -534,12 +534,12 @@ static void giveback(struct pl022 *pl022)
2199 pl022->cur_msg = NULL;
2200 pl022->cur_transfer = NULL;
2201 pl022->cur_chip = NULL;
2202 - spi_finalize_current_message(pl022->master);
2203
2204 /* disable the SPI/SSP operation */
2205 writew((readw(SSP_CR1(pl022->virtbase)) &
2206 (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase));
2207
2208 + spi_finalize_current_message(pl022->master);
2209 }
2210
2211 /**
2212 diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
2213 index 73e58d22e325..6446490854cb 100644
2214 --- a/drivers/target/iscsi/iscsi_target.c
2215 +++ b/drivers/target/iscsi/iscsi_target.c
2216 @@ -4220,11 +4220,17 @@ int iscsit_close_connection(
2217 pr_debug("Closing iSCSI connection CID %hu on SID:"
2218 " %u\n", conn->cid, sess->sid);
2219 /*
2220 - * Always up conn_logout_comp just in case the RX Thread is sleeping
2221 - * and the logout response never got sent because the connection
2222 - * failed.
2223 + * Always up conn_logout_comp for the traditional TCP case just in case
2224 + * the RX Thread in iscsi_target_rx_opcode() is sleeping and the logout
2225 + * response never got sent because the connection failed.
2226 + *
2227 + * However for iser-target, isert_wait4logout() is using conn_logout_comp
2228 + * to signal logout response TX interrupt completion. Go ahead and skip
2229 + * this for iser since isert_rx_opcode() does not wait on logout failure,
2230 + * and to avoid iscsi_conn pointer dereference in iser-target code.
2231 */
2232 - complete(&conn->conn_logout_comp);
2233 + if (conn->conn_transport->transport_type == ISCSI_TCP)
2234 + complete(&conn->conn_logout_comp);
2235
2236 iscsi_release_thread_set(conn);
2237
2238 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
2239 index 24fa5d1999af..9e0f5d3b3ebf 100644
2240 --- a/drivers/target/target_core_device.c
2241 +++ b/drivers/target/target_core_device.c
2242 @@ -1598,8 +1598,6 @@ int target_configure_device(struct se_device *dev)
2243 ret = dev->transport->configure_device(dev);
2244 if (ret)
2245 goto out;
2246 - dev->dev_flags |= DF_CONFIGURED;
2247 -
2248 /*
2249 * XXX: there is not much point to have two different values here..
2250 */
2251 @@ -1661,6 +1659,8 @@ int target_configure_device(struct se_device *dev)
2252 list_add_tail(&dev->g_dev_node, &g_device_list);
2253 mutex_unlock(&g_device_mutex);
2254
2255 + dev->dev_flags |= DF_CONFIGURED;
2256 +
2257 return 0;
2258
2259 out_free_alua:
2260 diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
2261 index 7c8291f0bbbc..9a54381e23c6 100644
2262 --- a/drivers/target/target_core_pscsi.c
2263 +++ b/drivers/target/target_core_pscsi.c
2264 @@ -1120,7 +1120,7 @@ static u32 pscsi_get_device_type(struct se_device *dev)
2265 struct pscsi_dev_virt *pdv = PSCSI_DEV(dev);
2266 struct scsi_device *sd = pdv->pdv_sd;
2267
2268 - return sd->type;
2269 + return (sd) ? sd->type : TYPE_NO_LUN;
2270 }
2271
2272 static sector_t pscsi_get_blocks(struct se_device *dev)
2273 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
2274 index be877bf6f730..2e0998420254 100644
2275 --- a/drivers/target/target_core_transport.c
2276 +++ b/drivers/target/target_core_transport.c
2277 @@ -2389,6 +2389,10 @@ int target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd,
2278 list_add_tail(&se_cmd->se_cmd_list, &se_sess->sess_cmd_list);
2279 out:
2280 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
2281 +
2282 + if (ret && ack_kref)
2283 + target_put_sess_cmd(se_sess, se_cmd);
2284 +
2285 return ret;
2286 }
2287 EXPORT_SYMBOL(target_get_sess_cmd);
2288 diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
2289 index beea6ca73ee5..a69e31e3410f 100644
2290 --- a/drivers/tty/serial/8250/8250_dw.c
2291 +++ b/drivers/tty/serial/8250/8250_dw.c
2292 @@ -111,7 +111,10 @@ static void dw8250_serial_out(struct uart_port *p, int offset, int value)
2293 dw8250_force_idle(p);
2294 writeb(value, p->membase + (UART_LCR << p->regshift));
2295 }
2296 - dev_err(p->dev, "Couldn't set LCR to %d\n", value);
2297 + /*
2298 + * FIXME: this deadlocks if port->lock is already held
2299 + * dev_err(p->dev, "Couldn't set LCR to %d\n", value);
2300 + */
2301 }
2302 }
2303
2304 @@ -148,7 +151,10 @@ static void dw8250_serial_out32(struct uart_port *p, int offset, int value)
2305 dw8250_force_idle(p);
2306 writel(value, p->membase + (UART_LCR << p->regshift));
2307 }
2308 - dev_err(p->dev, "Couldn't set LCR to %d\n", value);
2309 + /*
2310 + * FIXME: this deadlocks if port->lock is already held
2311 + * dev_err(p->dev, "Couldn't set LCR to %d\n", value);
2312 + */
2313 }
2314 }
2315
2316 diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
2317 index beb9d71cd47a..439bd1a5d00c 100644
2318 --- a/drivers/tty/serial/8250/8250_pci.c
2319 +++ b/drivers/tty/serial/8250/8250_pci.c
2320 @@ -69,7 +69,7 @@ static void moan_device(const char *str, struct pci_dev *dev)
2321 "Please send the output of lspci -vv, this\n"
2322 "message (0x%04x,0x%04x,0x%04x,0x%04x), the\n"
2323 "manufacturer and name of serial board or\n"
2324 - "modem board to rmk+serial@arm.linux.org.uk.\n",
2325 + "modem board to <linux-serial@vger.kernel.org>.\n",
2326 pci_name(dev), str, dev->vendor, dev->device,
2327 dev->subsystem_vendor, dev->subsystem_device);
2328 }
2329 diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
2330 index 08048613eed6..db2becd31a51 100644
2331 --- a/drivers/usb/gadget/legacy/inode.c
2332 +++ b/drivers/usb/gadget/legacy/inode.c
2333 @@ -565,7 +565,6 @@ static ssize_t ep_copy_to_user(struct kiocb_priv *priv)
2334 if (total == 0)
2335 break;
2336 }
2337 -
2338 return len;
2339 }
2340
2341 @@ -584,6 +583,7 @@ static void ep_user_copy_worker(struct work_struct *work)
2342 aio_complete(iocb, ret, ret);
2343
2344 kfree(priv->buf);
2345 + kfree(priv->iv);
2346 kfree(priv);
2347 }
2348
2349 @@ -604,6 +604,7 @@ static void ep_aio_complete(struct usb_ep *ep, struct usb_request *req)
2350 */
2351 if (priv->iv == NULL || unlikely(req->actual == 0)) {
2352 kfree(req->buf);
2353 + kfree(priv->iv);
2354 kfree(priv);
2355 iocb->private = NULL;
2356 /* aio_complete() reports bytes-transferred _and_ faults */
2357 @@ -639,7 +640,7 @@ ep_aio_rwtail(
2358 struct usb_request *req;
2359 ssize_t value;
2360
2361 - priv = kmalloc(sizeof *priv, GFP_KERNEL);
2362 + priv = kzalloc(sizeof *priv, GFP_KERNEL);
2363 if (!priv) {
2364 value = -ENOMEM;
2365 fail:
2366 @@ -648,7 +649,14 @@ fail:
2367 }
2368 iocb->private = priv;
2369 priv->iocb = iocb;
2370 - priv->iv = iv;
2371 + if (iv) {
2372 + priv->iv = kmemdup(iv, nr_segs * sizeof(struct iovec),
2373 + GFP_KERNEL);
2374 + if (!priv->iv) {
2375 + kfree(priv);
2376 + goto fail;
2377 + }
2378 + }
2379 priv->nr_segs = nr_segs;
2380 INIT_WORK(&priv->work, ep_user_copy_worker);
2381
2382 @@ -688,6 +696,7 @@ fail:
2383 mutex_unlock(&epdata->lock);
2384
2385 if (unlikely(value)) {
2386 + kfree(priv->iv);
2387 kfree(priv);
2388 put_ep(epdata);
2389 } else
2390 diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
2391 index b4bca2d4a7e5..70fba973a107 100644
2392 --- a/drivers/xen/events/events_base.c
2393 +++ b/drivers/xen/events/events_base.c
2394 @@ -526,20 +526,26 @@ static unsigned int __startup_pirq(unsigned int irq)
2395 pirq_query_unmask(irq);
2396
2397 rc = set_evtchn_to_irq(evtchn, irq);
2398 - if (rc != 0) {
2399 - pr_err("irq%d: Failed to set port to irq mapping (%d)\n",
2400 - irq, rc);
2401 - xen_evtchn_close(evtchn);
2402 - return 0;
2403 - }
2404 + if (rc)
2405 + goto err;
2406 +
2407 bind_evtchn_to_cpu(evtchn, 0);
2408 info->evtchn = evtchn;
2409
2410 + rc = xen_evtchn_port_setup(info);
2411 + if (rc)
2412 + goto err;
2413 +
2414 out:
2415 unmask_evtchn(evtchn);
2416 eoi_pirq(irq_get_irq_data(irq));
2417
2418 return 0;
2419 +
2420 +err:
2421 + pr_err("irq%d: Failed to set port to irq mapping (%d)\n", irq, rc);
2422 + xen_evtchn_close(evtchn);
2423 + return 0;
2424 }
2425
2426 static unsigned int startup_pirq(struct irq_data *data)
2427 diff --git a/drivers/xen/xen-pciback/conf_space.c b/drivers/xen/xen-pciback/conf_space.c
2428 index 46ae0f9f02ad..75fe3d466515 100644
2429 --- a/drivers/xen/xen-pciback/conf_space.c
2430 +++ b/drivers/xen/xen-pciback/conf_space.c
2431 @@ -16,7 +16,7 @@
2432 #include "conf_space.h"
2433 #include "conf_space_quirks.h"
2434
2435 -static bool permissive;
2436 +bool permissive;
2437 module_param(permissive, bool, 0644);
2438
2439 /* This is where xen_pcibk_read_config_byte, xen_pcibk_read_config_word,
2440 diff --git a/drivers/xen/xen-pciback/conf_space.h b/drivers/xen/xen-pciback/conf_space.h
2441 index e56c934ad137..2e1d73d1d5d0 100644
2442 --- a/drivers/xen/xen-pciback/conf_space.h
2443 +++ b/drivers/xen/xen-pciback/conf_space.h
2444 @@ -64,6 +64,8 @@ struct config_field_entry {
2445 void *data;
2446 };
2447
2448 +extern bool permissive;
2449 +
2450 #define OFFSET(cfg_entry) ((cfg_entry)->base_offset+(cfg_entry)->field->offset)
2451
2452 /* Add fields to a device - the add_fields macro expects to get a pointer to
2453 diff --git a/drivers/xen/xen-pciback/conf_space_header.c b/drivers/xen/xen-pciback/conf_space_header.c
2454 index c5ee82587e8c..2d7369391472 100644
2455 --- a/drivers/xen/xen-pciback/conf_space_header.c
2456 +++ b/drivers/xen/xen-pciback/conf_space_header.c
2457 @@ -11,6 +11,10 @@
2458 #include "pciback.h"
2459 #include "conf_space.h"
2460
2461 +struct pci_cmd_info {
2462 + u16 val;
2463 +};
2464 +
2465 struct pci_bar_info {
2466 u32 val;
2467 u32 len_val;
2468 @@ -20,22 +24,36 @@ struct pci_bar_info {
2469 #define is_enable_cmd(value) ((value)&(PCI_COMMAND_MEMORY|PCI_COMMAND_IO))
2470 #define is_master_cmd(value) ((value)&PCI_COMMAND_MASTER)
2471
2472 -static int command_read(struct pci_dev *dev, int offset, u16 *value, void *data)
2473 +/* Bits guests are allowed to control in permissive mode. */
2474 +#define PCI_COMMAND_GUEST (PCI_COMMAND_MASTER|PCI_COMMAND_SPECIAL| \
2475 + PCI_COMMAND_INVALIDATE|PCI_COMMAND_VGA_PALETTE| \
2476 + PCI_COMMAND_WAIT|PCI_COMMAND_FAST_BACK)
2477 +
2478 +static void *command_init(struct pci_dev *dev, int offset)
2479 {
2480 - int i;
2481 - int ret;
2482 -
2483 - ret = xen_pcibk_read_config_word(dev, offset, value, data);
2484 - if (!pci_is_enabled(dev))
2485 - return ret;
2486 -
2487 - for (i = 0; i < PCI_ROM_RESOURCE; i++) {
2488 - if (dev->resource[i].flags & IORESOURCE_IO)
2489 - *value |= PCI_COMMAND_IO;
2490 - if (dev->resource[i].flags & IORESOURCE_MEM)
2491 - *value |= PCI_COMMAND_MEMORY;
2492 + struct pci_cmd_info *cmd = kmalloc(sizeof(*cmd), GFP_KERNEL);
2493 + int err;
2494 +
2495 + if (!cmd)
2496 + return ERR_PTR(-ENOMEM);
2497 +
2498 + err = pci_read_config_word(dev, PCI_COMMAND, &cmd->val);
2499 + if (err) {
2500 + kfree(cmd);
2501 + return ERR_PTR(err);
2502 }
2503
2504 + return cmd;
2505 +}
2506 +
2507 +static int command_read(struct pci_dev *dev, int offset, u16 *value, void *data)
2508 +{
2509 + int ret = pci_read_config_word(dev, offset, value);
2510 + const struct pci_cmd_info *cmd = data;
2511 +
2512 + *value &= PCI_COMMAND_GUEST;
2513 + *value |= cmd->val & ~PCI_COMMAND_GUEST;
2514 +
2515 return ret;
2516 }
2517
2518 @@ -43,6 +61,8 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
2519 {
2520 struct xen_pcibk_dev_data *dev_data;
2521 int err;
2522 + u16 val;
2523 + struct pci_cmd_info *cmd = data;
2524
2525 dev_data = pci_get_drvdata(dev);
2526 if (!pci_is_enabled(dev) && is_enable_cmd(value)) {
2527 @@ -83,6 +103,19 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
2528 }
2529 }
2530
2531 + cmd->val = value;
2532 +
2533 + if (!permissive && (!dev_data || !dev_data->permissive))
2534 + return 0;
2535 +
2536 + /* Only allow the guest to control certain bits. */
2537 + err = pci_read_config_word(dev, offset, &val);
2538 + if (err || val == value)
2539 + return err;
2540 +
2541 + value &= PCI_COMMAND_GUEST;
2542 + value |= val & ~PCI_COMMAND_GUEST;
2543 +
2544 return pci_write_config_word(dev, offset, value);
2545 }
2546
2547 @@ -282,6 +315,8 @@ static const struct config_field header_common[] = {
2548 {
2549 .offset = PCI_COMMAND,
2550 .size = 2,
2551 + .init = command_init,
2552 + .release = bar_release,
2553 .u.w.read = command_read,
2554 .u.w.write = command_write,
2555 },
2556 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
2557 index ca887314aba9..f2bbb8513360 100644
2558 --- a/fs/fuse/dev.c
2559 +++ b/fs/fuse/dev.c
2560 @@ -814,8 +814,8 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
2561
2562 newpage = buf->page;
2563
2564 - if (WARN_ON(!PageUptodate(newpage)))
2565 - return -EIO;
2566 + if (!PageUptodate(newpage))
2567 + SetPageUptodate(newpage);
2568
2569 ClearPageMappedToDisk(newpage);
2570
2571 @@ -1721,6 +1721,9 @@ copy_finish:
2572 static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code,
2573 unsigned int size, struct fuse_copy_state *cs)
2574 {
2575 + /* Don't try to move pages (yet) */
2576 + cs->move_pages = 0;
2577 +
2578 switch (code) {
2579 case FUSE_NOTIFY_POLL:
2580 return fuse_notify_poll(fc, size, cs);
2581 diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
2582 index 469086b9f99b..0c3f303baf32 100644
2583 --- a/fs/nilfs2/segment.c
2584 +++ b/fs/nilfs2/segment.c
2585 @@ -1907,6 +1907,7 @@ static void nilfs_segctor_drop_written_files(struct nilfs_sc_info *sci,
2586 struct the_nilfs *nilfs)
2587 {
2588 struct nilfs_inode_info *ii, *n;
2589 + int during_mount = !(sci->sc_super->s_flags & MS_ACTIVE);
2590 int defer_iput = false;
2591
2592 spin_lock(&nilfs->ns_inode_lock);
2593 @@ -1919,10 +1920,10 @@ static void nilfs_segctor_drop_written_files(struct nilfs_sc_info *sci,
2594 brelse(ii->i_bh);
2595 ii->i_bh = NULL;
2596 list_del_init(&ii->i_dirty);
2597 - if (!ii->vfs_inode.i_nlink) {
2598 + if (!ii->vfs_inode.i_nlink || during_mount) {
2599 /*
2600 - * Defer calling iput() to avoid a deadlock
2601 - * over I_SYNC flag for inodes with i_nlink == 0
2602 + * Defer calling iput() to avoid deadlocks if
2603 + * i_nlink == 0 or mount is not yet finished.
2604 */
2605 list_add_tail(&ii->i_dirty, &sci->sc_iput_queue);
2606 defer_iput = true;
2607 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
2608 index e8972bcddfb4..69aa378e60d9 100644
2609 --- a/fs/proc/task_mmu.c
2610 +++ b/fs/proc/task_mmu.c
2611 @@ -1291,6 +1291,9 @@ out:
2612
2613 static int pagemap_open(struct inode *inode, struct file *file)
2614 {
2615 + /* do not disclose physical addresses: attack vector */
2616 + if (!capable(CAP_SYS_ADMIN))
2617 + return -EPERM;
2618 pr_warn_once("Bits 55-60 of /proc/PID/pagemap entries are about "
2619 "to stop being page-shift some time soon. See the "
2620 "linux/Documentation/vm/pagemap.txt for details.\n");
2621 diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
2622 index 5672d7ea1fa0..08848050922e 100644
2623 --- a/include/asm-generic/tlb.h
2624 +++ b/include/asm-generic/tlb.h
2625 @@ -96,10 +96,9 @@ struct mmu_gather {
2626 #endif
2627 unsigned long start;
2628 unsigned long end;
2629 - unsigned int need_flush : 1, /* Did free PTEs */
2630 /* we are in the middle of an operation to clear
2631 * a full mm and can make some optimizations */
2632 - fullmm : 1,
2633 + unsigned int fullmm : 1,
2634 /* we have performed an operation which
2635 * requires a complete flush of the tlb */
2636 need_flush_all : 1;
2637 @@ -128,16 +127,54 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
2638 tlb_flush_mmu(tlb);
2639 }
2640
2641 +static inline void __tlb_adjust_range(struct mmu_gather *tlb,
2642 + unsigned long address)
2643 +{
2644 + tlb->start = min(tlb->start, address);
2645 + tlb->end = max(tlb->end, address + PAGE_SIZE);
2646 +}
2647 +
2648 +static inline void __tlb_reset_range(struct mmu_gather *tlb)
2649 +{
2650 + tlb->start = TASK_SIZE;
2651 + tlb->end = 0;
2652 +}
2653 +
2654 +/*
2655 + * In the case of tlb vma handling, we can optimise these away in the
2656 + * case where we're doing a full MM flush. When we're doing a munmap,
2657 + * the vmas are adjusted to only cover the region to be torn down.
2658 + */
2659 +#ifndef tlb_start_vma
2660 +#define tlb_start_vma(tlb, vma) do { } while (0)
2661 +#endif
2662 +
2663 +#define __tlb_end_vma(tlb, vma) \
2664 + do { \
2665 + if (!tlb->fullmm && tlb->end) { \
2666 + tlb_flush(tlb); \
2667 + __tlb_reset_range(tlb); \
2668 + } \
2669 + } while (0)
2670 +
2671 +#ifndef tlb_end_vma
2672 +#define tlb_end_vma __tlb_end_vma
2673 +#endif
2674 +
2675 +#ifndef __tlb_remove_tlb_entry
2676 +#define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0)
2677 +#endif
2678 +
2679 /**
2680 * tlb_remove_tlb_entry - remember a pte unmapping for later tlb invalidation.
2681 *
2682 - * Record the fact that pte's were really umapped in ->need_flush, so we can
2683 - * later optimise away the tlb invalidate. This helps when userspace is
2684 - * unmapping already-unmapped pages, which happens quite a lot.
2685 + * Record the fact that pte's were really unmapped by updating the range,
2686 + * so we can later optimise away the tlb invalidate. This helps when
2687 + * userspace is unmapping already-unmapped pages, which happens quite a lot.
2688 */
2689 #define tlb_remove_tlb_entry(tlb, ptep, address) \
2690 do { \
2691 - tlb->need_flush = 1; \
2692 + __tlb_adjust_range(tlb, address); \
2693 __tlb_remove_tlb_entry(tlb, ptep, address); \
2694 } while (0)
2695
2696 @@ -151,27 +188,27 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
2697
2698 #define tlb_remove_pmd_tlb_entry(tlb, pmdp, address) \
2699 do { \
2700 - tlb->need_flush = 1; \
2701 + __tlb_adjust_range(tlb, address); \
2702 __tlb_remove_pmd_tlb_entry(tlb, pmdp, address); \
2703 } while (0)
2704
2705 #define pte_free_tlb(tlb, ptep, address) \
2706 do { \
2707 - tlb->need_flush = 1; \
2708 + __tlb_adjust_range(tlb, address); \
2709 __pte_free_tlb(tlb, ptep, address); \
2710 } while (0)
2711
2712 #ifndef __ARCH_HAS_4LEVEL_HACK
2713 #define pud_free_tlb(tlb, pudp, address) \
2714 do { \
2715 - tlb->need_flush = 1; \
2716 + __tlb_adjust_range(tlb, address); \
2717 __pud_free_tlb(tlb, pudp, address); \
2718 } while (0)
2719 #endif
2720
2721 #define pmd_free_tlb(tlb, pmdp, address) \
2722 do { \
2723 - tlb->need_flush = 1; \
2724 + __tlb_adjust_range(tlb, address); \
2725 __pmd_free_tlb(tlb, pmdp, address); \
2726 } while (0)
2727
2728 diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
2729 index b996e6cde6bb..9eb54f41623e 100644
2730 --- a/include/linux/workqueue.h
2731 +++ b/include/linux/workqueue.h
2732 @@ -70,7 +70,8 @@ enum {
2733 /* data contains off-queue information when !WORK_STRUCT_PWQ */
2734 WORK_OFFQ_FLAG_BASE = WORK_STRUCT_COLOR_SHIFT,
2735
2736 - WORK_OFFQ_CANCELING = (1 << WORK_OFFQ_FLAG_BASE),
2737 + __WORK_OFFQ_CANCELING = WORK_OFFQ_FLAG_BASE,
2738 + WORK_OFFQ_CANCELING = (1 << __WORK_OFFQ_CANCELING),
2739
2740 /*
2741 * When a work item is off queue, its high bits point to the last
2742 diff --git a/kernel/cpuset.c b/kernel/cpuset.c
2743 index 1f107c74087b..672310e1597e 100644
2744 --- a/kernel/cpuset.c
2745 +++ b/kernel/cpuset.c
2746 @@ -538,9 +538,6 @@ static void update_domain_attr_tree(struct sched_domain_attr *dattr,
2747
2748 rcu_read_lock();
2749 cpuset_for_each_descendant_pre(cp, pos_css, root_cs) {
2750 - if (cp == root_cs)
2751 - continue;
2752 -
2753 /* skip the whole subtree if @cp doesn't have any CPU */
2754 if (cpumask_empty(cp->cpus_allowed)) {
2755 pos_css = css_rightmost_descendant(pos_css);
2756 @@ -863,7 +860,7 @@ static void update_cpumasks_hier(struct cpuset *cs, struct cpumask *new_cpus)
2757 * If it becomes empty, inherit the effective mask of the
2758 * parent, which is guaranteed to have some CPUs.
2759 */
2760 - if (cpumask_empty(new_cpus))
2761 + if (cgroup_on_dfl(cp->css.cgroup) && cpumask_empty(new_cpus))
2762 cpumask_copy(new_cpus, parent->effective_cpus);
2763
2764 /* Skip the whole subtree if the cpumask remains the same. */
2765 @@ -1119,7 +1116,7 @@ static void update_nodemasks_hier(struct cpuset *cs, nodemask_t *new_mems)
2766 * If it becomes empty, inherit the effective mask of the
2767 * parent, which is guaranteed to have some MEMs.
2768 */
2769 - if (nodes_empty(*new_mems))
2770 + if (cgroup_on_dfl(cp->css.cgroup) && nodes_empty(*new_mems))
2771 *new_mems = parent->effective_mems;
2772
2773 /* Skip the whole subtree if the nodemask remains the same. */
2774 @@ -1991,7 +1988,9 @@ static int cpuset_css_online(struct cgroup_subsys_state *css)
2775
2776 mutex_lock(&callback_mutex);
2777 cs->mems_allowed = parent->mems_allowed;
2778 + cs->effective_mems = parent->mems_allowed;
2779 cpumask_copy(cs->cpus_allowed, parent->cpus_allowed);
2780 + cpumask_copy(cs->effective_cpus, parent->cpus_allowed);
2781 mutex_unlock(&callback_mutex);
2782 out_unlock:
2783 mutex_unlock(&cpuset_mutex);
2784 diff --git a/kernel/printk/console_cmdline.h b/kernel/printk/console_cmdline.h
2785 index cbd69d842341..2ca4a8b5fe57 100644
2786 --- a/kernel/printk/console_cmdline.h
2787 +++ b/kernel/printk/console_cmdline.h
2788 @@ -3,7 +3,7 @@
2789
2790 struct console_cmdline
2791 {
2792 - char name[8]; /* Name of the driver */
2793 + char name[16]; /* Name of the driver */
2794 int index; /* Minor dev. to use */
2795 char *options; /* Options for the driver */
2796 #ifdef CONFIG_A11Y_BRAILLE_CONSOLE
2797 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
2798 index ced2b84b1cb7..bf95fdad4d96 100644
2799 --- a/kernel/printk/printk.c
2800 +++ b/kernel/printk/printk.c
2801 @@ -2440,6 +2440,7 @@ void register_console(struct console *newcon)
2802 for (i = 0, c = console_cmdline;
2803 i < MAX_CMDLINECONSOLES && c->name[0];
2804 i++, c++) {
2805 + BUILD_BUG_ON(sizeof(c->name) != sizeof(newcon->name));
2806 if (strcmp(c->name, newcon->name) != 0)
2807 continue;
2808 if (newcon->index >= 0 &&
2809 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
2810 index 124e2c702ead..d1eff3dd8a02 100644
2811 --- a/kernel/trace/ftrace.c
2812 +++ b/kernel/trace/ftrace.c
2813 @@ -1053,6 +1053,12 @@ static __init void ftrace_profile_debugfs(struct dentry *d_tracer)
2814
2815 static struct pid * const ftrace_swapper_pid = &init_struct_pid;
2816
2817 +#ifdef CONFIG_FUNCTION_GRAPH_TRACER
2818 +static int ftrace_graph_active;
2819 +#else
2820 +# define ftrace_graph_active 0
2821 +#endif
2822 +
2823 #ifdef CONFIG_DYNAMIC_FTRACE
2824
2825 static struct ftrace_ops *removed_ops;
2826 @@ -1849,8 +1855,12 @@ static int ftrace_check_record(struct dyn_ftrace *rec, int enable, int update)
2827 if (!ftrace_rec_count(rec))
2828 rec->flags = 0;
2829 else
2830 - /* Just disable the record (keep REGS state) */
2831 - rec->flags &= ~FTRACE_FL_ENABLED;
2832 + /*
2833 + * Just disable the record, but keep the ops TRAMP
2834 + * and REGS states. The _EN flags must be disabled though.
2835 + */
2836 + rec->flags &= ~(FTRACE_FL_ENABLED | FTRACE_FL_TRAMP_EN |
2837 + FTRACE_FL_REGS_EN);
2838 }
2839
2840 return FTRACE_UPDATE_MAKE_NOP;
2841 @@ -2482,24 +2492,36 @@ static int ftrace_shutdown(struct ftrace_ops *ops, int command)
2842
2843 static void ftrace_startup_sysctl(void)
2844 {
2845 + int command;
2846 +
2847 if (unlikely(ftrace_disabled))
2848 return;
2849
2850 /* Force update next time */
2851 saved_ftrace_func = NULL;
2852 /* ftrace_start_up is true if we want ftrace running */
2853 - if (ftrace_start_up)
2854 - ftrace_run_update_code(FTRACE_UPDATE_CALLS);
2855 + if (ftrace_start_up) {
2856 + command = FTRACE_UPDATE_CALLS;
2857 + if (ftrace_graph_active)
2858 + command |= FTRACE_START_FUNC_RET;
2859 + ftrace_startup_enable(command);
2860 + }
2861 }
2862
2863 static void ftrace_shutdown_sysctl(void)
2864 {
2865 + int command;
2866 +
2867 if (unlikely(ftrace_disabled))
2868 return;
2869
2870 /* ftrace_start_up is true if ftrace is running */
2871 - if (ftrace_start_up)
2872 - ftrace_run_update_code(FTRACE_DISABLE_CALLS);
2873 + if (ftrace_start_up) {
2874 + command = FTRACE_DISABLE_CALLS;
2875 + if (ftrace_graph_active)
2876 + command |= FTRACE_STOP_FUNC_RET;
2877 + ftrace_run_update_code(command);
2878 + }
2879 }
2880
2881 static cycle_t ftrace_update_time;
2882 @@ -5303,12 +5325,12 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
2883
2884 if (ftrace_enabled) {
2885
2886 - ftrace_startup_sysctl();
2887 -
2888 /* we are starting ftrace again */
2889 if (ftrace_ops_list != &ftrace_list_end)
2890 update_ftrace_function();
2891
2892 + ftrace_startup_sysctl();
2893 +
2894 } else {
2895 /* stopping ftrace calls (just send to ftrace_stub) */
2896 ftrace_trace_function = ftrace_stub;
2897 @@ -5334,8 +5356,6 @@ static struct ftrace_ops graph_ops = {
2898 ASSIGN_OPS_HASH(graph_ops, &global_ops.local_hash)
2899 };
2900
2901 -static int ftrace_graph_active;
2902 -
2903 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
2904 {
2905 return 0;
2906 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
2907 index 66940a53d128..2273f534b01a 100644
2908 --- a/kernel/workqueue.c
2909 +++ b/kernel/workqueue.c
2910 @@ -2710,19 +2710,57 @@ bool flush_work(struct work_struct *work)
2911 }
2912 EXPORT_SYMBOL_GPL(flush_work);
2913
2914 +struct cwt_wait {
2915 + wait_queue_t wait;
2916 + struct work_struct *work;
2917 +};
2918 +
2919 +static int cwt_wakefn(wait_queue_t *wait, unsigned mode, int sync, void *key)
2920 +{
2921 + struct cwt_wait *cwait = container_of(wait, struct cwt_wait, wait);
2922 +
2923 + if (cwait->work != key)
2924 + return 0;
2925 + return autoremove_wake_function(wait, mode, sync, key);
2926 +}
2927 +
2928 static bool __cancel_work_timer(struct work_struct *work, bool is_dwork)
2929 {
2930 + static DECLARE_WAIT_QUEUE_HEAD(cancel_waitq);
2931 unsigned long flags;
2932 int ret;
2933
2934 do {
2935 ret = try_to_grab_pending(work, is_dwork, &flags);
2936 /*
2937 - * If someone else is canceling, wait for the same event it
2938 - * would be waiting for before retrying.
2939 + * If someone else is already canceling, wait for it to
2940 + * finish. flush_work() doesn't work for PREEMPT_NONE
2941 + * because we may get scheduled between @work's completion
2942 + * and the other canceling task resuming and clearing
2943 + * CANCELING - flush_work() will return false immediately
2944 + * as @work is no longer busy, try_to_grab_pending() will
2945 + * return -ENOENT as @work is still being canceled and the
2946 + * other canceling task won't be able to clear CANCELING as
2947 + * we're hogging the CPU.
2948 + *
2949 + * Let's wait for completion using a waitqueue. As this
2950 + * may lead to the thundering herd problem, use a custom
2951 + * wake function which matches @work along with exclusive
2952 + * wait and wakeup.
2953 */
2954 - if (unlikely(ret == -ENOENT))
2955 - flush_work(work);
2956 + if (unlikely(ret == -ENOENT)) {
2957 + struct cwt_wait cwait;
2958 +
2959 + init_wait(&cwait.wait);
2960 + cwait.wait.func = cwt_wakefn;
2961 + cwait.work = work;
2962 +
2963 + prepare_to_wait_exclusive(&cancel_waitq, &cwait.wait,
2964 + TASK_UNINTERRUPTIBLE);
2965 + if (work_is_canceling(work))
2966 + schedule();
2967 + finish_wait(&cancel_waitq, &cwait.wait);
2968 + }
2969 } while (unlikely(ret < 0));
2970
2971 /* tell other tasks trying to grab @work to back off */
2972 @@ -2731,6 +2769,16 @@ static bool __cancel_work_timer(struct work_struct *work, bool is_dwork)
2973
2974 flush_work(work);
2975 clear_work_data(work);
2976 +
2977 + /*
2978 + * Paired with prepare_to_wait() above so that either
2979 + * waitqueue_active() is visible here or !work_is_canceling() is
2980 + * visible there.
2981 + */
2982 + smp_mb();
2983 + if (waitqueue_active(&cancel_waitq))
2984 + __wake_up(&cancel_waitq, TASK_NORMAL, 1, work);
2985 +
2986 return ret;
2987 }
2988
2989 diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c
2990 index 7a85967060a5..f0f5c5c3de12 100644
2991 --- a/lib/lz4/lz4_decompress.c
2992 +++ b/lib/lz4/lz4_decompress.c
2993 @@ -139,6 +139,9 @@ static int lz4_uncompress(const char *source, char *dest, int osize)
2994 /* Error: request to write beyond destination buffer */
2995 if (cpy > oend)
2996 goto _output_error;
2997 + if ((ref + COPYLENGTH) > oend ||
2998 + (op + COPYLENGTH) > oend)
2999 + goto _output_error;
3000 LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));
3001 while (op < cpy)
3002 *op++ = *ref++;
3003 diff --git a/mm/memory.c b/mm/memory.c
3004 index 4ffa7b571fb8..90fb265b32b6 100644
3005 --- a/mm/memory.c
3006 +++ b/mm/memory.c
3007 @@ -220,9 +220,6 @@ void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long
3008 /* Is it from 0 to ~0? */
3009 tlb->fullmm = !(start | (end+1));
3010 tlb->need_flush_all = 0;
3011 - tlb->start = start;
3012 - tlb->end = end;
3013 - tlb->need_flush = 0;
3014 tlb->local.next = NULL;
3015 tlb->local.nr = 0;
3016 tlb->local.max = ARRAY_SIZE(tlb->__pages);
3017 @@ -232,15 +229,20 @@ void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long
3018 #ifdef CONFIG_HAVE_RCU_TABLE_FREE
3019 tlb->batch = NULL;
3020 #endif
3021 +
3022 + __tlb_reset_range(tlb);
3023 }
3024
3025 static void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb)
3026 {
3027 - tlb->need_flush = 0;
3028 + if (!tlb->end)
3029 + return;
3030 +
3031 tlb_flush(tlb);
3032 #ifdef CONFIG_HAVE_RCU_TABLE_FREE
3033 tlb_table_flush(tlb);
3034 #endif
3035 + __tlb_reset_range(tlb);
3036 }
3037
3038 static void tlb_flush_mmu_free(struct mmu_gather *tlb)
3039 @@ -256,8 +258,6 @@ static void tlb_flush_mmu_free(struct mmu_gather *tlb)
3040
3041 void tlb_flush_mmu(struct mmu_gather *tlb)
3042 {
3043 - if (!tlb->need_flush)
3044 - return;
3045 tlb_flush_mmu_tlbonly(tlb);
3046 tlb_flush_mmu_free(tlb);
3047 }
3048 @@ -292,7 +292,7 @@ int __tlb_remove_page(struct mmu_gather *tlb, struct page *page)
3049 {
3050 struct mmu_gather_batch *batch;
3051
3052 - VM_BUG_ON(!tlb->need_flush);
3053 + VM_BUG_ON(!tlb->end);
3054
3055 batch = tlb->active;
3056 batch->pages[batch->nr++] = page;
3057 @@ -359,8 +359,6 @@ void tlb_remove_table(struct mmu_gather *tlb, void *table)
3058 {
3059 struct mmu_table_batch **batch = &tlb->batch;
3060
3061 - tlb->need_flush = 1;
3062 -
3063 /*
3064 * When there's less then two users of this mm there cannot be a
3065 * concurrent page-table walk.
3066 @@ -1186,20 +1184,8 @@ again:
3067 arch_leave_lazy_mmu_mode();
3068
3069 /* Do the actual TLB flush before dropping ptl */
3070 - if (force_flush) {
3071 - unsigned long old_end;
3072 -
3073 - /*
3074 - * Flush the TLB just for the previous segment,
3075 - * then update the range to be the remaining
3076 - * TLB range.
3077 - */
3078 - old_end = tlb->end;
3079 - tlb->end = addr;
3080 + if (force_flush)
3081 tlb_flush_mmu_tlbonly(tlb);
3082 - tlb->start = addr;
3083 - tlb->end = old_end;
3084 - }
3085 pte_unmap_unlock(start_pte, ptl);
3086
3087 /*
3088 diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
3089 index 43f750e88e19..765c78110fa8 100644
3090 --- a/net/caif/caif_socket.c
3091 +++ b/net/caif/caif_socket.c
3092 @@ -281,7 +281,7 @@ static int caif_seqpkt_recvmsg(struct kiocb *iocb, struct socket *sock,
3093 int copylen;
3094
3095 ret = -EOPNOTSUPP;
3096 - if (m->msg_flags&MSG_OOB)
3097 + if (flags & MSG_OOB)
3098 goto read_error;
3099
3100 skb = skb_recv_datagram(sk, flags, 0 , &ret);
3101 diff --git a/net/can/af_can.c b/net/can/af_can.c
3102 index ce82337521f6..d6030d6949df 100644
3103 --- a/net/can/af_can.c
3104 +++ b/net/can/af_can.c
3105 @@ -262,6 +262,9 @@ int can_send(struct sk_buff *skb, int loop)
3106 goto inval_skb;
3107 }
3108
3109 + skb->ip_summed = CHECKSUM_UNNECESSARY;
3110 +
3111 + skb_reset_mac_header(skb);
3112 skb_reset_network_header(skb);
3113 skb_reset_transport_header(skb);
3114
3115 diff --git a/net/compat.c b/net/compat.c
3116 index c48930373e65..53e933eb78b8 100644
3117 --- a/net/compat.c
3118 +++ b/net/compat.c
3119 @@ -71,6 +71,13 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
3120 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
3121 __get_user(kmsg->msg_flags, &umsg->msg_flags))
3122 return -EFAULT;
3123 +
3124 + if (!tmp1)
3125 + kmsg->msg_namelen = 0;
3126 +
3127 + if (kmsg->msg_namelen < 0)
3128 + return -EINVAL;
3129 +
3130 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
3131 kmsg->msg_namelen = sizeof(struct sockaddr_storage);
3132 kmsg->msg_name = compat_ptr(tmp1);
3133 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
3134 index cf9cd13509a7..e731c96eac4b 100644
3135 --- a/net/core/sysctl_net_core.c
3136 +++ b/net/core/sysctl_net_core.c
3137 @@ -25,6 +25,8 @@
3138 static int zero = 0;
3139 static int one = 1;
3140 static int ushort_max = USHRT_MAX;
3141 +static int min_sndbuf = SOCK_MIN_SNDBUF;
3142 +static int min_rcvbuf = SOCK_MIN_RCVBUF;
3143
3144 #ifdef CONFIG_RPS
3145 static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
3146 @@ -223,7 +225,7 @@ static struct ctl_table net_core_table[] = {
3147 .maxlen = sizeof(int),
3148 .mode = 0644,
3149 .proc_handler = proc_dointvec_minmax,
3150 - .extra1 = &one,
3151 + .extra1 = &min_sndbuf,
3152 },
3153 {
3154 .procname = "rmem_max",
3155 @@ -231,7 +233,7 @@ static struct ctl_table net_core_table[] = {
3156 .maxlen = sizeof(int),
3157 .mode = 0644,
3158 .proc_handler = proc_dointvec_minmax,
3159 - .extra1 = &one,
3160 + .extra1 = &min_rcvbuf,
3161 },
3162 {
3163 .procname = "wmem_default",
3164 @@ -239,7 +241,7 @@ static struct ctl_table net_core_table[] = {
3165 .maxlen = sizeof(int),
3166 .mode = 0644,
3167 .proc_handler = proc_dointvec_minmax,
3168 - .extra1 = &one,
3169 + .extra1 = &min_sndbuf,
3170 },
3171 {
3172 .procname = "rmem_default",
3173 @@ -247,7 +249,7 @@ static struct ctl_table net_core_table[] = {
3174 .maxlen = sizeof(int),
3175 .mode = 0644,
3176 .proc_handler = proc_dointvec_minmax,
3177 - .extra1 = &one,
3178 + .extra1 = &min_rcvbuf,
3179 },
3180 {
3181 .procname = "dev_weight",
3182 diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
3183 index e34dccbc4d70..4eeba4e497a0 100644
3184 --- a/net/ipv4/inet_diag.c
3185 +++ b/net/ipv4/inet_diag.c
3186 @@ -71,6 +71,20 @@ static inline void inet_diag_unlock_handler(
3187 mutex_unlock(&inet_diag_table_mutex);
3188 }
3189
3190 +static size_t inet_sk_attr_size(void)
3191 +{
3192 + return nla_total_size(sizeof(struct tcp_info))
3193 + + nla_total_size(1) /* INET_DIAG_SHUTDOWN */
3194 + + nla_total_size(1) /* INET_DIAG_TOS */
3195 + + nla_total_size(1) /* INET_DIAG_TCLASS */
3196 + + nla_total_size(sizeof(struct inet_diag_meminfo))
3197 + + nla_total_size(sizeof(struct inet_diag_msg))
3198 + + nla_total_size(SK_MEMINFO_VARS * sizeof(u32))
3199 + + nla_total_size(TCP_CA_NAME_MAX)
3200 + + nla_total_size(sizeof(struct tcpvegas_info))
3201 + + 64;
3202 +}
3203 +
3204 int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
3205 struct sk_buff *skb, struct inet_diag_req_v2 *req,
3206 struct user_namespace *user_ns,
3207 @@ -324,9 +338,7 @@ int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *in_s
3208 if (err)
3209 goto out;
3210
3211 - rep = nlmsg_new(sizeof(struct inet_diag_msg) +
3212 - sizeof(struct inet_diag_meminfo) +
3213 - sizeof(struct tcp_info) + 64, GFP_KERNEL);
3214 + rep = nlmsg_new(inet_sk_attr_size(), GFP_KERNEL);
3215 if (!rep) {
3216 err = -ENOMEM;
3217 goto out;
3218 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
3219 index c2df40ba553f..022ecbc9322d 100644
3220 --- a/net/ipv4/tcp_output.c
3221 +++ b/net/ipv4/tcp_output.c
3222 @@ -2739,15 +2739,11 @@ void tcp_send_fin(struct sock *sk)
3223 } else {
3224 /* Socket is locked, keep trying until memory is available. */
3225 for (;;) {
3226 - skb = alloc_skb_fclone(MAX_TCP_HEADER,
3227 - sk->sk_allocation);
3228 + skb = sk_stream_alloc_skb(sk, 0, sk->sk_allocation);
3229 if (skb)
3230 break;
3231 yield();
3232 }
3233 -
3234 - /* Reserve space for headers and prepare control bits. */
3235 - skb_reserve(skb, MAX_TCP_HEADER);
3236 /* FIN eats a sequence byte, write_seq advanced by tcp_queue_skb(). */
3237 tcp_init_nondata_skb(skb, tp->write_seq,
3238 TCPHDR_ACK | TCPHDR_FIN);
3239 @@ -2998,9 +2994,9 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
3240 {
3241 struct tcp_sock *tp = tcp_sk(sk);
3242 struct tcp_fastopen_request *fo = tp->fastopen_req;
3243 - int syn_loss = 0, space, i, err = 0, iovlen = fo->data->msg_iovlen;
3244 - struct sk_buff *syn_data = NULL, *data;
3245 + int syn_loss = 0, space, err = 0;
3246 unsigned long last_syn_loss = 0;
3247 + struct sk_buff *syn_data;
3248
3249 tp->rx_opt.mss_clamp = tp->advmss; /* If MSS is not cached */
3250 tcp_fastopen_cache_get(sk, &tp->rx_opt.mss_clamp, &fo->cookie,
3251 @@ -3031,48 +3027,40 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
3252 /* limit to order-0 allocations */
3253 space = min_t(size_t, space, SKB_MAX_HEAD(MAX_TCP_HEADER));
3254
3255 - syn_data = skb_copy_expand(syn, MAX_TCP_HEADER, space,
3256 - sk->sk_allocation);
3257 - if (syn_data == NULL)
3258 + syn_data = sk_stream_alloc_skb(sk, space, sk->sk_allocation);
3259 + if (!syn_data)
3260 + goto fallback;
3261 + syn_data->ip_summed = CHECKSUM_PARTIAL;
3262 + memcpy(syn_data->cb, syn->cb, sizeof(syn->cb));
3263 + if (unlikely(memcpy_fromiovecend(skb_put(syn_data, space),
3264 + fo->data->msg_iov, 0, space))) {
3265 + kfree_skb(syn_data);
3266 goto fallback;
3267 + }
3268
3269 - for (i = 0; i < iovlen && syn_data->len < space; ++i) {
3270 - struct iovec *iov = &fo->data->msg_iov[i];
3271 - unsigned char __user *from = iov->iov_base;
3272 - int len = iov->iov_len;
3273 + /* No more data pending in inet_wait_for_connect() */
3274 + if (space == fo->size)
3275 + fo->data = NULL;
3276 + fo->copied = space;
3277
3278 - if (syn_data->len + len > space)
3279 - len = space - syn_data->len;
3280 - else if (i + 1 == iovlen)
3281 - /* No more data pending in inet_wait_for_connect() */
3282 - fo->data = NULL;
3283 + tcp_connect_queue_skb(sk, syn_data);
3284
3285 - if (skb_add_data(syn_data, from, len))
3286 - goto fallback;
3287 - }
3288 + err = tcp_transmit_skb(sk, syn_data, 1, sk->sk_allocation);
3289
3290 - /* Queue a data-only packet after the regular SYN for retransmission */
3291 - data = pskb_copy(syn_data, sk->sk_allocation);
3292 - if (data == NULL)
3293 - goto fallback;
3294 - TCP_SKB_CB(data)->seq++;
3295 - TCP_SKB_CB(data)->tcp_flags &= ~TCPHDR_SYN;
3296 - TCP_SKB_CB(data)->tcp_flags = (TCPHDR_ACK|TCPHDR_PSH);
3297 - tcp_connect_queue_skb(sk, data);
3298 - fo->copied = data->len;
3299 -
3300 - /* syn_data is about to be sent, we need to take current time stamps
3301 - * for the packets that are in write queue : SYN packet and DATA
3302 - */
3303 - skb_mstamp_get(&syn->skb_mstamp);
3304 - data->skb_mstamp = syn->skb_mstamp;
3305 + syn->skb_mstamp = syn_data->skb_mstamp;
3306
3307 - if (tcp_transmit_skb(sk, syn_data, 0, sk->sk_allocation) == 0) {
3308 + /* Now full SYN+DATA was cloned and sent (or not),
3309 + * remove the SYN from the original skb (syn_data)
3310 + * we keep in write queue in case of a retransmit, as we
3311 + * also have the SYN packet (with no data) in the same queue.
3312 + */
3313 + TCP_SKB_CB(syn_data)->seq++;
3314 + TCP_SKB_CB(syn_data)->tcp_flags = TCPHDR_ACK | TCPHDR_PSH;
3315 + if (!err) {
3316 tp->syn_data = (fo->copied > 0);
3317 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPORIGDATASENT);
3318 goto done;
3319 }
3320 - syn_data = NULL;
3321
3322 fallback:
3323 /* Send a regular SYN with Fast Open cookie request option */
3324 @@ -3081,7 +3069,6 @@ fallback:
3325 err = tcp_transmit_skb(sk, syn, 1, sk->sk_allocation);
3326 if (err)
3327 tp->syn_fastopen = 0;
3328 - kfree_skb(syn_data);
3329 done:
3330 fo->cookie.len = -1; /* Exclude Fast Open option for SYN retries */
3331 return err;
3332 @@ -3101,13 +3088,10 @@ int tcp_connect(struct sock *sk)
3333 return 0;
3334 }
3335
3336 - buff = alloc_skb_fclone(MAX_TCP_HEADER + 15, sk->sk_allocation);
3337 - if (unlikely(buff == NULL))
3338 + buff = sk_stream_alloc_skb(sk, 0, sk->sk_allocation);
3339 + if (unlikely(!buff))
3340 return -ENOBUFS;
3341
3342 - /* Reserve space for headers. */
3343 - skb_reserve(buff, MAX_TCP_HEADER);
3344 -
3345 tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN);
3346 tp->retrans_stamp = tcp_time_stamp;
3347 tcp_connect_queue_skb(sk, buff);
3348 diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
3349 index b4d5e1d97c1b..27ca79682efb 100644
3350 --- a/net/ipv6/fib6_rules.c
3351 +++ b/net/ipv6/fib6_rules.c
3352 @@ -104,6 +104,7 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
3353 goto again;
3354 flp6->saddr = saddr;
3355 }
3356 + err = rt->dst.error;
3357 goto out;
3358 }
3359 again:
3360 diff --git a/net/rds/iw_rdma.c b/net/rds/iw_rdma.c
3361 index a817705ce2d0..dba8d0864f18 100644
3362 --- a/net/rds/iw_rdma.c
3363 +++ b/net/rds/iw_rdma.c
3364 @@ -88,7 +88,9 @@ static unsigned int rds_iw_unmap_fastreg_list(struct rds_iw_mr_pool *pool,
3365 int *unpinned);
3366 static void rds_iw_destroy_fastreg(struct rds_iw_mr_pool *pool, struct rds_iw_mr *ibmr);
3367
3368 -static int rds_iw_get_device(struct rds_sock *rs, struct rds_iw_device **rds_iwdev, struct rdma_cm_id **cm_id)
3369 +static int rds_iw_get_device(struct sockaddr_in *src, struct sockaddr_in *dst,
3370 + struct rds_iw_device **rds_iwdev,
3371 + struct rdma_cm_id **cm_id)
3372 {
3373 struct rds_iw_device *iwdev;
3374 struct rds_iw_cm_id *i_cm_id;
3375 @@ -112,15 +114,15 @@ static int rds_iw_get_device(struct rds_sock *rs, struct rds_iw_device **rds_iwd
3376 src_addr->sin_port,
3377 dst_addr->sin_addr.s_addr,
3378 dst_addr->sin_port,
3379 - rs->rs_bound_addr,
3380 - rs->rs_bound_port,
3381 - rs->rs_conn_addr,
3382 - rs->rs_conn_port);
3383 + src->sin_addr.s_addr,
3384 + src->sin_port,
3385 + dst->sin_addr.s_addr,
3386 + dst->sin_port);
3387 #ifdef WORKING_TUPLE_DETECTION
3388 - if (src_addr->sin_addr.s_addr == rs->rs_bound_addr &&
3389 - src_addr->sin_port == rs->rs_bound_port &&
3390 - dst_addr->sin_addr.s_addr == rs->rs_conn_addr &&
3391 - dst_addr->sin_port == rs->rs_conn_port) {
3392 + if (src_addr->sin_addr.s_addr == src->sin_addr.s_addr &&
3393 + src_addr->sin_port == src->sin_port &&
3394 + dst_addr->sin_addr.s_addr == dst->sin_addr.s_addr &&
3395 + dst_addr->sin_port == dst->sin_port) {
3396 #else
3397 /* FIXME - needs to compare the local and remote
3398 * ipaddr/port tuple, but the ipaddr is the only
3399 @@ -128,7 +130,7 @@ static int rds_iw_get_device(struct rds_sock *rs, struct rds_iw_device **rds_iwd
3400 * zero'ed. It doesn't appear to be properly populated
3401 * during connection setup...
3402 */
3403 - if (src_addr->sin_addr.s_addr == rs->rs_bound_addr) {
3404 + if (src_addr->sin_addr.s_addr == src->sin_addr.s_addr) {
3405 #endif
3406 spin_unlock_irq(&iwdev->spinlock);
3407 *rds_iwdev = iwdev;
3408 @@ -180,19 +182,13 @@ int rds_iw_update_cm_id(struct rds_iw_device *rds_iwdev, struct rdma_cm_id *cm_i
3409 {
3410 struct sockaddr_in *src_addr, *dst_addr;
3411 struct rds_iw_device *rds_iwdev_old;
3412 - struct rds_sock rs;
3413 struct rdma_cm_id *pcm_id;
3414 int rc;
3415
3416 src_addr = (struct sockaddr_in *)&cm_id->route.addr.src_addr;
3417 dst_addr = (struct sockaddr_in *)&cm_id->route.addr.dst_addr;
3418
3419 - rs.rs_bound_addr = src_addr->sin_addr.s_addr;
3420 - rs.rs_bound_port = src_addr->sin_port;
3421 - rs.rs_conn_addr = dst_addr->sin_addr.s_addr;
3422 - rs.rs_conn_port = dst_addr->sin_port;
3423 -
3424 - rc = rds_iw_get_device(&rs, &rds_iwdev_old, &pcm_id);
3425 + rc = rds_iw_get_device(src_addr, dst_addr, &rds_iwdev_old, &pcm_id);
3426 if (rc)
3427 rds_iw_remove_cm_id(rds_iwdev, cm_id);
3428
3429 @@ -598,9 +594,17 @@ void *rds_iw_get_mr(struct scatterlist *sg, unsigned long nents,
3430 struct rds_iw_device *rds_iwdev;
3431 struct rds_iw_mr *ibmr = NULL;
3432 struct rdma_cm_id *cm_id;
3433 + struct sockaddr_in src = {
3434 + .sin_addr.s_addr = rs->rs_bound_addr,
3435 + .sin_port = rs->rs_bound_port,
3436 + };
3437 + struct sockaddr_in dst = {
3438 + .sin_addr.s_addr = rs->rs_conn_addr,
3439 + .sin_port = rs->rs_conn_port,
3440 + };
3441 int ret;
3442
3443 - ret = rds_iw_get_device(rs, &rds_iwdev, &cm_id);
3444 + ret = rds_iw_get_device(&src, &dst, &rds_iwdev, &cm_id);
3445 if (ret || !cm_id) {
3446 ret = -ENODEV;
3447 goto out;
3448 diff --git a/net/rxrpc/ar-recvmsg.c b/net/rxrpc/ar-recvmsg.c
3449 index e9aaa65c0778..0df95463c650 100644
3450 --- a/net/rxrpc/ar-recvmsg.c
3451 +++ b/net/rxrpc/ar-recvmsg.c
3452 @@ -87,7 +87,7 @@ int rxrpc_recvmsg(struct kiocb *iocb, struct socket *sock,
3453 if (!skb) {
3454 /* nothing remains on the queue */
3455 if (copied &&
3456 - (msg->msg_flags & MSG_PEEK || timeo == 0))
3457 + (flags & MSG_PEEK || timeo == 0))
3458 goto out;
3459
3460 /* wait for a message to turn up */
3461 diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
3462 index 0472909bb014..b78d81f5ffda 100644
3463 --- a/net/sched/cls_u32.c
3464 +++ b/net/sched/cls_u32.c
3465 @@ -78,8 +78,11 @@ struct tc_u_hnode {
3466 struct tc_u_common *tp_c;
3467 int refcnt;
3468 unsigned int divisor;
3469 - struct tc_u_knode __rcu *ht[1];
3470 struct rcu_head rcu;
3471 + /* The 'ht' field MUST be the last field in structure to allow for
3472 + * more entries allocated at end of structure.
3473 + */
3474 + struct tc_u_knode __rcu *ht[1];
3475 };
3476
3477 struct tc_u_common {
3478 diff --git a/sound/core/control.c b/sound/core/control.c
3479 index b9611344ff9e..82a638a01b24 100644
3480 --- a/sound/core/control.c
3481 +++ b/sound/core/control.c
3482 @@ -1167,6 +1167,10 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
3483
3484 if (info->count < 1)
3485 return -EINVAL;
3486 + if (!*info->id.name)
3487 + return -EINVAL;
3488 + if (strnlen(info->id.name, sizeof(info->id.name)) >= sizeof(info->id.name))
3489 + return -EINVAL;
3490 access = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE :
3491 (info->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE|
3492 SNDRV_CTL_ELEM_ACCESS_INACTIVE|
3493 diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
3494 index 84c94301bfaf..20aa52b14b84 100644
3495 --- a/sound/pci/hda/hda_controller.c
3496 +++ b/sound/pci/hda/hda_controller.c
3497 @@ -1160,7 +1160,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
3498 }
3499 }
3500
3501 - if (!bus->no_response_fallback)
3502 + if (bus->no_response_fallback)
3503 return -1;
3504
3505 if (!chip->polling_mode && chip->poll_count < 2) {
3506 diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
3507 index 64220c08bd98..6c6e35aba989 100644
3508 --- a/sound/pci/hda/hda_generic.c
3509 +++ b/sound/pci/hda/hda_generic.c
3510 @@ -637,12 +637,45 @@ static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid,
3511 return val;
3512 }
3513
3514 +/* is this a stereo widget or a stereo-to-mono mix? */
3515 +static bool is_stereo_amps(struct hda_codec *codec, hda_nid_t nid, int dir)
3516 +{
3517 + unsigned int wcaps = get_wcaps(codec, nid);
3518 + hda_nid_t conn;
3519 +
3520 + if (wcaps & AC_WCAP_STEREO)
3521 + return true;
3522 + if (dir != HDA_INPUT || get_wcaps_type(wcaps) != AC_WID_AUD_MIX)
3523 + return false;
3524 + if (snd_hda_get_num_conns(codec, nid) != 1)
3525 + return false;
3526 + if (snd_hda_get_connections(codec, nid, &conn, 1) < 0)
3527 + return false;
3528 + return !!(get_wcaps(codec, conn) & AC_WCAP_STEREO);
3529 +}
3530 +
3531 /* initialize the amp value (only at the first time) */
3532 static void init_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx)
3533 {
3534 unsigned int caps = query_amp_caps(codec, nid, dir);
3535 int val = get_amp_val_to_activate(codec, nid, dir, caps, false);
3536 - snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val);
3537 +
3538 + if (is_stereo_amps(codec, nid, dir))
3539 + snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val);
3540 + else
3541 + snd_hda_codec_amp_init(codec, nid, 0, dir, idx, 0xff, val);
3542 +}
3543 +
3544 +/* update the amp, doing in stereo or mono depending on NID */
3545 +static int update_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx,
3546 + unsigned int mask, unsigned int val)
3547 +{
3548 + if (is_stereo_amps(codec, nid, dir))
3549 + return snd_hda_codec_amp_stereo(codec, nid, dir, idx,
3550 + mask, val);
3551 + else
3552 + return snd_hda_codec_amp_update(codec, nid, 0, dir, idx,
3553 + mask, val);
3554 }
3555
3556 /* calculate amp value mask we can modify;
3557 @@ -682,7 +715,7 @@ static void activate_amp(struct hda_codec *codec, hda_nid_t nid, int dir,
3558 return;
3559
3560 val &= mask;
3561 - snd_hda_codec_amp_stereo(codec, nid, dir, idx, mask, val);
3562 + update_amp(codec, nid, dir, idx, mask, val);
3563 }
3564
3565 static void activate_amp_out(struct hda_codec *codec, struct nid_path *path,
3566 @@ -4331,13 +4364,11 @@ static void mute_all_mixer_nid(struct hda_codec *codec, hda_nid_t mix)
3567 has_amp = nid_has_mute(codec, mix, HDA_INPUT);
3568 for (i = 0; i < nums; i++) {
3569 if (has_amp)
3570 - snd_hda_codec_amp_stereo(codec, mix,
3571 - HDA_INPUT, i,
3572 - 0xff, HDA_AMP_MUTE);
3573 + update_amp(codec, mix, HDA_INPUT, i,
3574 + 0xff, HDA_AMP_MUTE);
3575 else if (nid_has_volume(codec, conn[i], HDA_OUTPUT))
3576 - snd_hda_codec_amp_stereo(codec, conn[i],
3577 - HDA_OUTPUT, 0,
3578 - 0xff, HDA_AMP_MUTE);
3579 + update_amp(codec, conn[i], HDA_OUTPUT, 0,
3580 + 0xff, HDA_AMP_MUTE);
3581 }
3582 }
3583
3584 diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
3585 index ce5a6da83419..05e19f78b4cb 100644
3586 --- a/sound/pci/hda/hda_proc.c
3587 +++ b/sound/pci/hda/hda_proc.c
3588 @@ -134,13 +134,38 @@ static void print_amp_caps(struct snd_info_buffer *buffer,
3589 (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT);
3590 }
3591
3592 +/* is this a stereo widget or a stereo-to-mono mix? */
3593 +static bool is_stereo_amps(struct hda_codec *codec, hda_nid_t nid,
3594 + int dir, unsigned int wcaps, int indices)
3595 +{
3596 + hda_nid_t conn;
3597 +
3598 + if (wcaps & AC_WCAP_STEREO)
3599 + return true;
3600 + /* check for a stereo-to-mono mix; it must be:
3601 + * only a single connection, only for input, and only a mixer widget
3602 + */
3603 + if (indices != 1 || dir != HDA_INPUT ||
3604 + get_wcaps_type(wcaps) != AC_WID_AUD_MIX)
3605 + return false;
3606 +
3607 + if (snd_hda_get_raw_connections(codec, nid, &conn, 1) < 0)
3608 + return false;
3609 + /* the connection source is a stereo? */
3610 + wcaps = snd_hda_param_read(codec, conn, AC_PAR_AUDIO_WIDGET_CAP);
3611 + return !!(wcaps & AC_WCAP_STEREO);
3612 +}
3613 +
3614 static void print_amp_vals(struct snd_info_buffer *buffer,
3615 struct hda_codec *codec, hda_nid_t nid,
3616 - int dir, int stereo, int indices)
3617 + int dir, unsigned int wcaps, int indices)
3618 {
3619 unsigned int val;
3620 + bool stereo;
3621 int i;
3622
3623 + stereo = is_stereo_amps(codec, nid, dir, wcaps, indices);
3624 +
3625 dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
3626 for (i = 0; i < indices; i++) {
3627 snd_iprintf(buffer, " [");
3628 @@ -757,12 +782,10 @@ static void print_codec_info(struct snd_info_entry *entry,
3629 (codec->single_adc_amp &&
3630 wid_type == AC_WID_AUD_IN))
3631 print_amp_vals(buffer, codec, nid, HDA_INPUT,
3632 - wid_caps & AC_WCAP_STEREO,
3633 - 1);
3634 + wid_caps, 1);
3635 else
3636 print_amp_vals(buffer, codec, nid, HDA_INPUT,
3637 - wid_caps & AC_WCAP_STEREO,
3638 - conn_len);
3639 + wid_caps, conn_len);
3640 }
3641 if (wid_caps & AC_WCAP_OUT_AMP) {
3642 snd_iprintf(buffer, " Amp-Out caps: ");
3643 @@ -771,11 +794,10 @@ static void print_codec_info(struct snd_info_entry *entry,
3644 if (wid_type == AC_WID_PIN &&
3645 codec->pin_amp_workaround)
3646 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
3647 - wid_caps & AC_WCAP_STEREO,
3648 - conn_len);
3649 + wid_caps, conn_len);
3650 else
3651 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
3652 - wid_caps & AC_WCAP_STEREO, 1);
3653 + wid_caps, 1);
3654 }
3655
3656 switch (wid_type) {
3657 diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
3658 index 1589c9bcce3e..dd2b3d92071f 100644
3659 --- a/sound/pci/hda/patch_cirrus.c
3660 +++ b/sound/pci/hda/patch_cirrus.c
3661 @@ -393,6 +393,7 @@ static const struct snd_pci_quirk cs420x_fixup_tbl[] = {
3662 SND_PCI_QUIRK(0x106b, 0x1c00, "MacBookPro 8,1", CS420X_MBP81),
3663 SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122),
3664 SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101),
3665 + SND_PCI_QUIRK(0x106b, 0x5600, "MacBookAir 5,2", CS420X_MBP81),
3666 SND_PCI_QUIRK(0x106b, 0x5b00, "MacBookAir 4,2", CS420X_MBA42),
3667 SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE),
3668 {} /* terminator */
3669 @@ -584,6 +585,7 @@ static int patch_cs420x(struct hda_codec *codec)
3670 return -ENOMEM;
3671
3672 spec->gen.automute_hook = cs_automute;
3673 + codec->single_adc_amp = 1;
3674
3675 snd_hda_pick_fixup(codec, cs420x_models, cs420x_fixup_tbl,
3676 cs420x_fixups);
3677 diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
3678 index e9ebc7bd752c..1b1e8c68edd6 100644
3679 --- a/sound/pci/hda/patch_conexant.c
3680 +++ b/sound/pci/hda/patch_conexant.c
3681 @@ -223,6 +223,7 @@ enum {
3682 CXT_PINCFG_LENOVO_TP410,
3683 CXT_PINCFG_LEMOTE_A1004,
3684 CXT_PINCFG_LEMOTE_A1205,
3685 + CXT_PINCFG_COMPAQ_CQ60,
3686 CXT_FIXUP_STEREO_DMIC,
3687 CXT_FIXUP_INC_MIC_BOOST,
3688 CXT_FIXUP_HEADPHONE_MIC_PIN,
3689 @@ -660,6 +661,15 @@ static const struct hda_fixup cxt_fixups[] = {
3690 .type = HDA_FIXUP_PINS,
3691 .v.pins = cxt_pincfg_lemote,
3692 },
3693 + [CXT_PINCFG_COMPAQ_CQ60] = {
3694 + .type = HDA_FIXUP_PINS,
3695 + .v.pins = (const struct hda_pintbl[]) {
3696 + /* 0x17 was falsely set up as a mic, it should 0x1d */
3697 + { 0x17, 0x400001f0 },
3698 + { 0x1d, 0x97a70120 },
3699 + { }
3700 + }
3701 + },
3702 [CXT_FIXUP_STEREO_DMIC] = {
3703 .type = HDA_FIXUP_FUNC,
3704 .v.func = cxt_fixup_stereo_dmic,
3705 @@ -769,6 +779,7 @@ static const struct hda_model_fixup cxt5047_fixup_models[] = {
3706 };
3707
3708 static const struct snd_pci_quirk cxt5051_fixups[] = {
3709 + SND_PCI_QUIRK(0x103c, 0x360b, "Compaq CQ60", CXT_PINCFG_COMPAQ_CQ60),
3710 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200),
3711 {}
3712 };
3713 diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
3714 index 83bddbdb90e9..5293b5ac8b9d 100644
3715 --- a/sound/usb/quirks-table.h
3716 +++ b/sound/usb/quirks-table.h
3717 @@ -1773,6 +1773,36 @@ YAMAHA_DEVICE(0x7010, "UB99"),
3718 }
3719 }
3720 },
3721 +{
3722 + USB_DEVICE(0x0582, 0x0159),
3723 + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
3724 + /* .vendor_name = "Roland", */
3725 + /* .product_name = "UA-22", */
3726 + .ifnum = QUIRK_ANY_INTERFACE,
3727 + .type = QUIRK_COMPOSITE,
3728 + .data = (const struct snd_usb_audio_quirk[]) {
3729 + {
3730 + .ifnum = 0,
3731 + .type = QUIRK_AUDIO_STANDARD_INTERFACE
3732 + },
3733 + {
3734 + .ifnum = 1,
3735 + .type = QUIRK_AUDIO_STANDARD_INTERFACE
3736 + },
3737 + {
3738 + .ifnum = 2,
3739 + .type = QUIRK_MIDI_FIXED_ENDPOINT,
3740 + .data = & (const struct snd_usb_midi_endpoint_info) {
3741 + .out_cables = 0x0001,
3742 + .in_cables = 0x0001
3743 + }
3744 + },
3745 + {
3746 + .ifnum = -1
3747 + }
3748 + }
3749 + }
3750 +},
3751 /* this catches most recent vendor-specific Roland devices */
3752 {
3753 .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
3754 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
3755 index 3cee7b167052..cfbe0e7d1c45 100644
3756 --- a/virt/kvm/kvm_main.c
3757 +++ b/virt/kvm/kvm_main.c
3758 @@ -2417,6 +2417,7 @@ static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg)
3759 case KVM_CAP_SIGNAL_MSI:
3760 #endif
3761 #ifdef CONFIG_HAVE_KVM_IRQFD
3762 + case KVM_CAP_IRQFD:
3763 case KVM_CAP_IRQFD_RESAMPLE:
3764 #endif
3765 case KVM_CAP_CHECK_EXTENSION_VM: