Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.4/0112-4.4.13-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2811 - (hide annotations) (download)
Fri Jun 17 10:51:10 2016 UTC (7 years, 11 months ago) by niro
File size: 118061 byte(s)
-linux-4.4.13
1 niro 2811 diff --git a/Documentation/devicetree/bindings/clock/imx35-clock.txt b/Documentation/devicetree/bindings/clock/imx35-clock.txt
2     index a70356452a82..f49783213c56 100644
3     --- a/Documentation/devicetree/bindings/clock/imx35-clock.txt
4     +++ b/Documentation/devicetree/bindings/clock/imx35-clock.txt
5     @@ -94,6 +94,7 @@ clocks and IDs.
6     csi_sel 79
7     iim_gate 80
8     gpu2d_gate 81
9     + ckli_gate 82
10    
11     Examples:
12    
13     diff --git a/Documentation/sysctl/fs.txt b/Documentation/sysctl/fs.txt
14     index 88152f214f48..302b5ed616a6 100644
15     --- a/Documentation/sysctl/fs.txt
16     +++ b/Documentation/sysctl/fs.txt
17     @@ -32,6 +32,8 @@ Currently, these files are in /proc/sys/fs:
18     - nr_open
19     - overflowuid
20     - overflowgid
21     +- pipe-user-pages-hard
22     +- pipe-user-pages-soft
23     - protected_hardlinks
24     - protected_symlinks
25     - suid_dumpable
26     @@ -159,6 +161,27 @@ The default is 65534.
27    
28     ==============================================================
29    
30     +pipe-user-pages-hard:
31     +
32     +Maximum total number of pages a non-privileged user may allocate for pipes.
33     +Once this limit is reached, no new pipes may be allocated until usage goes
34     +below the limit again. When set to 0, no limit is applied, which is the default
35     +setting.
36     +
37     +==============================================================
38     +
39     +pipe-user-pages-soft:
40     +
41     +Maximum total number of pages a non-privileged user may allocate for pipes
42     +before the pipe size gets limited to a single page. Once this limit is reached,
43     +new pipes will be limited to a single page in size for this user in order to
44     +limit total memory usage, and trying to increase them using fcntl() will be
45     +denied until usage goes below the limit again. The default value allows to
46     +allocate up to 1024 pipes at their default size. When set to 0, no limit is
47     +applied.
48     +
49     +==============================================================
50     +
51     protected_hardlinks:
52    
53     A long-standing class of security issues is the hardlink-based
54     diff --git a/Makefile b/Makefile
55     index a1fbd691a36e..f4b33cdf991a 100644
56     --- a/Makefile
57     +++ b/Makefile
58     @@ -1,6 +1,6 @@
59     VERSION = 4
60     PATCHLEVEL = 4
61     -SUBLEVEL = 12
62     +SUBLEVEL = 13
63     EXTRAVERSION =
64     NAME = Blurry Fish Butt
65    
66     @@ -364,7 +364,7 @@ AFLAGS_MODULE =
67     LDFLAGS_MODULE =
68     CFLAGS_KERNEL =
69     AFLAGS_KERNEL =
70     -CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
71     +CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im
72    
73    
74     # Use USERINCLUDE when you must reference the UAPI directories only.
75     diff --git a/arch/arm/boot/dts/armada-385-linksys.dtsi b/arch/arm/boot/dts/armada-385-linksys.dtsi
76     index 85d2c377c332..8450944b28e6 100644
77     --- a/arch/arm/boot/dts/armada-385-linksys.dtsi
78     +++ b/arch/arm/boot/dts/armada-385-linksys.dtsi
79     @@ -245,7 +245,7 @@
80     button@2 {
81     label = "Factory Reset Button";
82     linux,code = <KEY_RESTART>;
83     - gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
84     + gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;
85     };
86     };
87    
88     @@ -260,7 +260,7 @@
89     };
90    
91     sata {
92     - gpios = <&gpio1 22 GPIO_ACTIVE_HIGH>;
93     + gpios = <&gpio1 22 GPIO_ACTIVE_LOW>;
94     default-state = "off";
95     };
96     };
97     @@ -313,7 +313,7 @@
98    
99     &pinctrl {
100     keys_pin: keys-pin {
101     - marvell,pins = "mpp24", "mpp47";
102     + marvell,pins = "mpp24", "mpp29";
103     marvell,function = "gpio";
104     };
105    
106     diff --git a/arch/arm/boot/dts/armada-xp-linksys-mamba.dts b/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
107     index b89e6cf1271a..7a461541ce50 100644
108     --- a/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
109     +++ b/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
110     @@ -304,13 +304,13 @@
111     button@1 {
112     label = "WPS";
113     linux,code = <KEY_WPS_BUTTON>;
114     - gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
115     + gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
116     };
117    
118     button@2 {
119     label = "Factory Reset Button";
120     linux,code = <KEY_RESTART>;
121     - gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;
122     + gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
123     };
124     };
125    
126     diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
127     index a50be640f1b0..59411e447fa0 100644
128     --- a/arch/arm/boot/dts/exynos4210-trats.dts
129     +++ b/arch/arm/boot/dts/exynos4210-trats.dts
130     @@ -298,6 +298,8 @@
131     compatible = "maxim,max8997-pmic";
132    
133     reg = <0x66>;
134     + interrupt-parent = <&gpx0>;
135     + interrupts = <7 0>;
136    
137     max8997,pmic-buck1-uses-gpio-dvs;
138     max8997,pmic-buck2-uses-gpio-dvs;
139     diff --git a/arch/arm/boot/dts/sama5d2-pinfunc.h b/arch/arm/boot/dts/sama5d2-pinfunc.h
140     index b0c912feaa2f..8a394f336003 100644
141     --- a/arch/arm/boot/dts/sama5d2-pinfunc.h
142     +++ b/arch/arm/boot/dts/sama5d2-pinfunc.h
143     @@ -837,8 +837,8 @@
144     #define PIN_PD23__ISC_FIELD PINMUX_PIN(PIN_PD23, 6, 4)
145     #define PIN_PD24 120
146     #define PIN_PD24__GPIO PINMUX_PIN(PIN_PD24, 0, 0)
147     -#define PIN_PD24__UTXD2 PINMUX_PIN(PIN_PD23, 1, 2)
148     -#define PIN_PD24__FLEXCOM4_IO3 PINMUX_PIN(PIN_PD23, 3, 3)
149     +#define PIN_PD24__UTXD2 PINMUX_PIN(PIN_PD24, 1, 2)
150     +#define PIN_PD24__FLEXCOM4_IO3 PINMUX_PIN(PIN_PD24, 3, 3)
151     #define PIN_PD25 121
152     #define PIN_PD25__GPIO PINMUX_PIN(PIN_PD25, 0, 0)
153     #define PIN_PD25__SPI1_SPCK PINMUX_PIN(PIN_PD25, 1, 3)
154     diff --git a/arch/mips/ath79/early_printk.c b/arch/mips/ath79/early_printk.c
155     index b955fafc58ba..d1adc59af5bf 100644
156     --- a/arch/mips/ath79/early_printk.c
157     +++ b/arch/mips/ath79/early_printk.c
158     @@ -31,13 +31,15 @@ static inline void prom_putchar_wait(void __iomem *reg, u32 mask, u32 val)
159     } while (1);
160     }
161    
162     +#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
163     +
164     static void prom_putchar_ar71xx(unsigned char ch)
165     {
166     void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE));
167    
168     - prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE);
169     + prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
170     __raw_writel(ch, base + UART_TX * 4);
171     - prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE);
172     + prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
173     }
174    
175     static void prom_putchar_ar933x(unsigned char ch)
176     diff --git a/arch/mips/include/asm/asmmacro.h b/arch/mips/include/asm/asmmacro.h
177     index 867f924b05c7..e689b894353c 100644
178     --- a/arch/mips/include/asm/asmmacro.h
179     +++ b/arch/mips/include/asm/asmmacro.h
180     @@ -298,21 +298,21 @@
181     .set pop
182     .endm
183    
184     - .macro copy_u_w ws, n
185     + .macro copy_s_w ws, n
186     .set push
187     .set mips32r2
188     .set fp=64
189     .set msa
190     - copy_u.w $1, $w\ws[\n]
191     + copy_s.w $1, $w\ws[\n]
192     .set pop
193     .endm
194    
195     - .macro copy_u_d ws, n
196     + .macro copy_s_d ws, n
197     .set push
198     .set mips64r2
199     .set fp=64
200     .set msa
201     - copy_u.d $1, $w\ws[\n]
202     + copy_s.d $1, $w\ws[\n]
203     .set pop
204     .endm
205    
206     @@ -346,8 +346,8 @@
207     #define STH_MSA_INSN 0x5800081f
208     #define STW_MSA_INSN 0x5800082f
209     #define STD_MSA_INSN 0x5800083f
210     -#define COPY_UW_MSA_INSN 0x58f00056
211     -#define COPY_UD_MSA_INSN 0x58f80056
212     +#define COPY_SW_MSA_INSN 0x58b00056
213     +#define COPY_SD_MSA_INSN 0x58b80056
214     #define INSERT_W_MSA_INSN 0x59300816
215     #define INSERT_D_MSA_INSN 0x59380816
216     #else
217     @@ -361,8 +361,8 @@
218     #define STH_MSA_INSN 0x78000825
219     #define STW_MSA_INSN 0x78000826
220     #define STD_MSA_INSN 0x78000827
221     -#define COPY_UW_MSA_INSN 0x78f00059
222     -#define COPY_UD_MSA_INSN 0x78f80059
223     +#define COPY_SW_MSA_INSN 0x78b00059
224     +#define COPY_SD_MSA_INSN 0x78b80059
225     #define INSERT_W_MSA_INSN 0x79300819
226     #define INSERT_D_MSA_INSN 0x79380819
227     #endif
228     @@ -393,7 +393,7 @@
229     .set push
230     .set noat
231     SET_HARDFLOAT
232     - addu $1, \base, \off
233     + PTR_ADDU $1, \base, \off
234     .word LDB_MSA_INSN | (\wd << 6)
235     .set pop
236     .endm
237     @@ -402,7 +402,7 @@
238     .set push
239     .set noat
240     SET_HARDFLOAT
241     - addu $1, \base, \off
242     + PTR_ADDU $1, \base, \off
243     .word LDH_MSA_INSN | (\wd << 6)
244     .set pop
245     .endm
246     @@ -411,7 +411,7 @@
247     .set push
248     .set noat
249     SET_HARDFLOAT
250     - addu $1, \base, \off
251     + PTR_ADDU $1, \base, \off
252     .word LDW_MSA_INSN | (\wd << 6)
253     .set pop
254     .endm
255     @@ -420,7 +420,7 @@
256     .set push
257     .set noat
258     SET_HARDFLOAT
259     - addu $1, \base, \off
260     + PTR_ADDU $1, \base, \off
261     .word LDD_MSA_INSN | (\wd << 6)
262     .set pop
263     .endm
264     @@ -429,7 +429,7 @@
265     .set push
266     .set noat
267     SET_HARDFLOAT
268     - addu $1, \base, \off
269     + PTR_ADDU $1, \base, \off
270     .word STB_MSA_INSN | (\wd << 6)
271     .set pop
272     .endm
273     @@ -438,7 +438,7 @@
274     .set push
275     .set noat
276     SET_HARDFLOAT
277     - addu $1, \base, \off
278     + PTR_ADDU $1, \base, \off
279     .word STH_MSA_INSN | (\wd << 6)
280     .set pop
281     .endm
282     @@ -447,7 +447,7 @@
283     .set push
284     .set noat
285     SET_HARDFLOAT
286     - addu $1, \base, \off
287     + PTR_ADDU $1, \base, \off
288     .word STW_MSA_INSN | (\wd << 6)
289     .set pop
290     .endm
291     @@ -456,26 +456,26 @@
292     .set push
293     .set noat
294     SET_HARDFLOAT
295     - addu $1, \base, \off
296     + PTR_ADDU $1, \base, \off
297     .word STD_MSA_INSN | (\wd << 6)
298     .set pop
299     .endm
300    
301     - .macro copy_u_w ws, n
302     + .macro copy_s_w ws, n
303     .set push
304     .set noat
305     SET_HARDFLOAT
306     .insn
307     - .word COPY_UW_MSA_INSN | (\n << 16) | (\ws << 11)
308     + .word COPY_SW_MSA_INSN | (\n << 16) | (\ws << 11)
309     .set pop
310     .endm
311    
312     - .macro copy_u_d ws, n
313     + .macro copy_s_d ws, n
314     .set push
315     .set noat
316     SET_HARDFLOAT
317     .insn
318     - .word COPY_UD_MSA_INSN | (\n << 16) | (\ws << 11)
319     + .word COPY_SD_MSA_INSN | (\n << 16) | (\ws << 11)
320     .set pop
321     .endm
322    
323     diff --git a/arch/mips/include/asm/cacheflush.h b/arch/mips/include/asm/cacheflush.h
324     index 723229f4cf27..176de586a71a 100644
325     --- a/arch/mips/include/asm/cacheflush.h
326     +++ b/arch/mips/include/asm/cacheflush.h
327     @@ -51,7 +51,6 @@ extern void (*flush_cache_range)(struct vm_area_struct *vma,
328     unsigned long start, unsigned long end);
329     extern void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, unsigned long pfn);
330     extern void __flush_dcache_page(struct page *page);
331     -extern void __flush_icache_page(struct vm_area_struct *vma, struct page *page);
332    
333     #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
334     static inline void flush_dcache_page(struct page *page)
335     @@ -77,11 +76,6 @@ static inline void flush_anon_page(struct vm_area_struct *vma,
336     static inline void flush_icache_page(struct vm_area_struct *vma,
337     struct page *page)
338     {
339     - if (!cpu_has_ic_fills_f_dc && (vma->vm_flags & VM_EXEC) &&
340     - Page_dcache_dirty(page)) {
341     - __flush_icache_page(vma, page);
342     - ClearPageDcacheDirty(page);
343     - }
344     }
345    
346     extern void (*flush_icache_range)(unsigned long start, unsigned long end);
347     diff --git a/arch/mips/include/asm/msa.h b/arch/mips/include/asm/msa.h
348     index bbb85fe21642..6e4effa6f626 100644
349     --- a/arch/mips/include/asm/msa.h
350     +++ b/arch/mips/include/asm/msa.h
351     @@ -147,6 +147,19 @@ static inline void restore_msa(struct task_struct *t)
352     _restore_msa(t);
353     }
354    
355     +static inline void init_msa_upper(void)
356     +{
357     + /*
358     + * Check cpu_has_msa only if it's a constant. This will allow the
359     + * compiler to optimise out code for CPUs without MSA without adding
360     + * an extra redundant check for CPUs with MSA.
361     + */
362     + if (__builtin_constant_p(cpu_has_msa) && !cpu_has_msa)
363     + return;
364     +
365     + _init_msa_upper();
366     +}
367     +
368     #ifdef TOOLCHAIN_SUPPORTS_MSA
369    
370     #define __BUILD_MSA_CTL_REG(name, cs) \
371     diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
372     index 18826aa15a7c..4e68c644acc5 100644
373     --- a/arch/mips/include/asm/pgtable.h
374     +++ b/arch/mips/include/asm/pgtable.h
375     @@ -127,10 +127,14 @@ do { \
376     } \
377     } while(0)
378    
379     +static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
380     + pte_t *ptep, pte_t pteval);
381     +
382     #if defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32)
383    
384     #define pte_none(pte) (!(((pte).pte_high) & ~_PAGE_GLOBAL))
385     #define pte_present(pte) ((pte).pte_low & _PAGE_PRESENT)
386     +#define pte_no_exec(pte) ((pte).pte_low & _PAGE_NO_EXEC)
387    
388     static inline void set_pte(pte_t *ptep, pte_t pte)
389     {
390     @@ -148,7 +152,6 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
391     buddy->pte_high |= _PAGE_GLOBAL;
392     }
393     }
394     -#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
395    
396     static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
397     {
398     @@ -166,6 +169,7 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt
399    
400     #define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))
401     #define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
402     +#define pte_no_exec(pte) (pte_val(pte) & _PAGE_NO_EXEC)
403    
404     /*
405     * Certain architectures need to do special things when pte's
406     @@ -218,7 +222,6 @@ static inline void set_pte(pte_t *ptep, pte_t pteval)
407     }
408     #endif
409     }
410     -#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
411    
412     static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
413     {
414     @@ -234,6 +237,22 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt
415     }
416     #endif
417    
418     +static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
419     + pte_t *ptep, pte_t pteval)
420     +{
421     + extern void __update_cache(unsigned long address, pte_t pte);
422     +
423     + if (!pte_present(pteval))
424     + goto cache_sync_done;
425     +
426     + if (pte_present(*ptep) && (pte_pfn(*ptep) == pte_pfn(pteval)))
427     + goto cache_sync_done;
428     +
429     + __update_cache(addr, pteval);
430     +cache_sync_done:
431     + set_pte(ptep, pteval);
432     +}
433     +
434     /*
435     * (pmds are folded into puds so this doesn't get actually called,
436     * but the define is needed for a generic inline function.)
437     @@ -430,15 +449,12 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
438    
439     extern void __update_tlb(struct vm_area_struct *vma, unsigned long address,
440     pte_t pte);
441     -extern void __update_cache(struct vm_area_struct *vma, unsigned long address,
442     - pte_t pte);
443    
444     static inline void update_mmu_cache(struct vm_area_struct *vma,
445     unsigned long address, pte_t *ptep)
446     {
447     pte_t pte = *ptep;
448     __update_tlb(vma, address, pte);
449     - __update_cache(vma, address, pte);
450     }
451    
452     static inline void update_mmu_cache_pmd(struct vm_area_struct *vma,
453     diff --git a/arch/mips/include/asm/switch_to.h b/arch/mips/include/asm/switch_to.h
454     index 28b5d84a5022..ebb5c0f2f90d 100644
455     --- a/arch/mips/include/asm/switch_to.h
456     +++ b/arch/mips/include/asm/switch_to.h
457     @@ -105,7 +105,7 @@ do { \
458     __clear_software_ll_bit(); \
459     if (cpu_has_userlocal) \
460     write_c0_userlocal(task_thread_info(next)->tp_value); \
461     - __restore_watch(); \
462     + __restore_watch(next); \
463     (last) = resume(prev, next, task_thread_info(next)); \
464     } while (0)
465    
466     diff --git a/arch/mips/include/asm/watch.h b/arch/mips/include/asm/watch.h
467     index 20126ec79359..6ffe3eadf105 100644
468     --- a/arch/mips/include/asm/watch.h
469     +++ b/arch/mips/include/asm/watch.h
470     @@ -12,21 +12,21 @@
471    
472     #include <asm/mipsregs.h>
473    
474     -void mips_install_watch_registers(void);
475     +void mips_install_watch_registers(struct task_struct *t);
476     void mips_read_watch_registers(void);
477     void mips_clear_watch_registers(void);
478     void mips_probe_watch_registers(struct cpuinfo_mips *c);
479    
480     #ifdef CONFIG_HARDWARE_WATCHPOINTS
481     -#define __restore_watch() do { \
482     +#define __restore_watch(task) do { \
483     if (unlikely(test_bit(TIF_LOAD_WATCH, \
484     - &current_thread_info()->flags))) { \
485     - mips_install_watch_registers(); \
486     + &task_thread_info(task)->flags))) { \
487     + mips_install_watch_registers(task); \
488     } \
489     } while (0)
490    
491     #else
492     -#define __restore_watch() do {} while (0)
493     +#define __restore_watch(task) do {} while (0)
494     #endif
495    
496     #endif /* _ASM_WATCH_H */
497     diff --git a/arch/mips/include/uapi/asm/siginfo.h b/arch/mips/include/uapi/asm/siginfo.h
498     index 2cb7fdead570..e2b5337e840f 100644
499     --- a/arch/mips/include/uapi/asm/siginfo.h
500     +++ b/arch/mips/include/uapi/asm/siginfo.h
501     @@ -28,7 +28,7 @@
502    
503     #define __ARCH_SIGSYS
504    
505     -#include <uapi/asm-generic/siginfo.h>
506     +#include <asm-generic/siginfo.h>
507    
508     /* We can't use generic siginfo_t, because our si_code and si_errno are swapped */
509     typedef struct siginfo {
510     @@ -42,13 +42,13 @@ typedef struct siginfo {
511    
512     /* kill() */
513     struct {
514     - pid_t _pid; /* sender's pid */
515     + __kernel_pid_t _pid; /* sender's pid */
516     __ARCH_SI_UID_T _uid; /* sender's uid */
517     } _kill;
518    
519     /* POSIX.1b timers */
520     struct {
521     - timer_t _tid; /* timer id */
522     + __kernel_timer_t _tid; /* timer id */
523     int _overrun; /* overrun count */
524     char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
525     sigval_t _sigval; /* same as below */
526     @@ -57,26 +57,26 @@ typedef struct siginfo {
527    
528     /* POSIX.1b signals */
529     struct {
530     - pid_t _pid; /* sender's pid */
531     + __kernel_pid_t _pid; /* sender's pid */
532     __ARCH_SI_UID_T _uid; /* sender's uid */
533     sigval_t _sigval;
534     } _rt;
535    
536     /* SIGCHLD */
537     struct {
538     - pid_t _pid; /* which child */
539     + __kernel_pid_t _pid; /* which child */
540     __ARCH_SI_UID_T _uid; /* sender's uid */
541     int _status; /* exit code */
542     - clock_t _utime;
543     - clock_t _stime;
544     + __kernel_clock_t _utime;
545     + __kernel_clock_t _stime;
546     } _sigchld;
547    
548     /* IRIX SIGCHLD */
549     struct {
550     - pid_t _pid; /* which child */
551     - clock_t _utime;
552     + __kernel_pid_t _pid; /* which child */
553     + __kernel_clock_t _utime;
554     int _status; /* exit code */
555     - clock_t _stime;
556     + __kernel_clock_t _stime;
557     } _irix_sigchld;
558    
559     /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
560     @@ -118,6 +118,4 @@ typedef struct siginfo {
561     #define SI_TIMER __SI_CODE(__SI_TIMER, -3) /* sent by timer expiration */
562     #define SI_MESGQ __SI_CODE(__SI_MESGQ, -4) /* sent by real time mesq state change */
563    
564     -#include <asm-generic/siginfo.h>
565     -
566     #endif /* _UAPI_ASM_SIGINFO_H */
567     diff --git a/arch/mips/kernel/mips-r2-to-r6-emul.c b/arch/mips/kernel/mips-r2-to-r6-emul.c
568     index 1f5aac7f9ec3..4674a74a08b5 100644
569     --- a/arch/mips/kernel/mips-r2-to-r6-emul.c
570     +++ b/arch/mips/kernel/mips-r2-to-r6-emul.c
571     @@ -28,6 +28,7 @@
572     #include <asm/inst.h>
573     #include <asm/mips-r2-to-r6-emul.h>
574     #include <asm/local.h>
575     +#include <asm/mipsregs.h>
576     #include <asm/ptrace.h>
577     #include <asm/uaccess.h>
578    
579     @@ -1251,10 +1252,10 @@ fpu_emul:
580     " j 10b\n"
581     " .previous\n"
582     " .section __ex_table,\"a\"\n"
583     - " .word 1b,8b\n"
584     - " .word 2b,8b\n"
585     - " .word 3b,8b\n"
586     - " .word 4b,8b\n"
587     + STR(PTR) " 1b,8b\n"
588     + STR(PTR) " 2b,8b\n"
589     + STR(PTR) " 3b,8b\n"
590     + STR(PTR) " 4b,8b\n"
591     " .previous\n"
592     " .set pop\n"
593     : "+&r"(rt), "=&r"(rs),
594     @@ -1326,10 +1327,10 @@ fpu_emul:
595     " j 10b\n"
596     " .previous\n"
597     " .section __ex_table,\"a\"\n"
598     - " .word 1b,8b\n"
599     - " .word 2b,8b\n"
600     - " .word 3b,8b\n"
601     - " .word 4b,8b\n"
602     + STR(PTR) " 1b,8b\n"
603     + STR(PTR) " 2b,8b\n"
604     + STR(PTR) " 3b,8b\n"
605     + STR(PTR) " 4b,8b\n"
606     " .previous\n"
607     " .set pop\n"
608     : "+&r"(rt), "=&r"(rs),
609     @@ -1397,10 +1398,10 @@ fpu_emul:
610     " j 9b\n"
611     " .previous\n"
612     " .section __ex_table,\"a\"\n"
613     - " .word 1b,8b\n"
614     - " .word 2b,8b\n"
615     - " .word 3b,8b\n"
616     - " .word 4b,8b\n"
617     + STR(PTR) " 1b,8b\n"
618     + STR(PTR) " 2b,8b\n"
619     + STR(PTR) " 3b,8b\n"
620     + STR(PTR) " 4b,8b\n"
621     " .previous\n"
622     " .set pop\n"
623     : "+&r"(rt), "=&r"(rs),
624     @@ -1467,10 +1468,10 @@ fpu_emul:
625     " j 9b\n"
626     " .previous\n"
627     " .section __ex_table,\"a\"\n"
628     - " .word 1b,8b\n"
629     - " .word 2b,8b\n"
630     - " .word 3b,8b\n"
631     - " .word 4b,8b\n"
632     + STR(PTR) " 1b,8b\n"
633     + STR(PTR) " 2b,8b\n"
634     + STR(PTR) " 3b,8b\n"
635     + STR(PTR) " 4b,8b\n"
636     " .previous\n"
637     " .set pop\n"
638     : "+&r"(rt), "=&r"(rs),
639     @@ -1582,14 +1583,14 @@ fpu_emul:
640     " j 9b\n"
641     " .previous\n"
642     " .section __ex_table,\"a\"\n"
643     - " .word 1b,8b\n"
644     - " .word 2b,8b\n"
645     - " .word 3b,8b\n"
646     - " .word 4b,8b\n"
647     - " .word 5b,8b\n"
648     - " .word 6b,8b\n"
649     - " .word 7b,8b\n"
650     - " .word 0b,8b\n"
651     + STR(PTR) " 1b,8b\n"
652     + STR(PTR) " 2b,8b\n"
653     + STR(PTR) " 3b,8b\n"
654     + STR(PTR) " 4b,8b\n"
655     + STR(PTR) " 5b,8b\n"
656     + STR(PTR) " 6b,8b\n"
657     + STR(PTR) " 7b,8b\n"
658     + STR(PTR) " 0b,8b\n"
659     " .previous\n"
660     " .set pop\n"
661     : "+&r"(rt), "=&r"(rs),
662     @@ -1701,14 +1702,14 @@ fpu_emul:
663     " j 9b\n"
664     " .previous\n"
665     " .section __ex_table,\"a\"\n"
666     - " .word 1b,8b\n"
667     - " .word 2b,8b\n"
668     - " .word 3b,8b\n"
669     - " .word 4b,8b\n"
670     - " .word 5b,8b\n"
671     - " .word 6b,8b\n"
672     - " .word 7b,8b\n"
673     - " .word 0b,8b\n"
674     + STR(PTR) " 1b,8b\n"
675     + STR(PTR) " 2b,8b\n"
676     + STR(PTR) " 3b,8b\n"
677     + STR(PTR) " 4b,8b\n"
678     + STR(PTR) " 5b,8b\n"
679     + STR(PTR) " 6b,8b\n"
680     + STR(PTR) " 7b,8b\n"
681     + STR(PTR) " 0b,8b\n"
682     " .previous\n"
683     " .set pop\n"
684     : "+&r"(rt), "=&r"(rs),
685     @@ -1820,14 +1821,14 @@ fpu_emul:
686     " j 9b\n"
687     " .previous\n"
688     " .section __ex_table,\"a\"\n"
689     - " .word 1b,8b\n"
690     - " .word 2b,8b\n"
691     - " .word 3b,8b\n"
692     - " .word 4b,8b\n"
693     - " .word 5b,8b\n"
694     - " .word 6b,8b\n"
695     - " .word 7b,8b\n"
696     - " .word 0b,8b\n"
697     + STR(PTR) " 1b,8b\n"
698     + STR(PTR) " 2b,8b\n"
699     + STR(PTR) " 3b,8b\n"
700     + STR(PTR) " 4b,8b\n"
701     + STR(PTR) " 5b,8b\n"
702     + STR(PTR) " 6b,8b\n"
703     + STR(PTR) " 7b,8b\n"
704     + STR(PTR) " 0b,8b\n"
705     " .previous\n"
706     " .set pop\n"
707     : "+&r"(rt), "=&r"(rs),
708     @@ -1938,14 +1939,14 @@ fpu_emul:
709     " j 9b\n"
710     " .previous\n"
711     " .section __ex_table,\"a\"\n"
712     - " .word 1b,8b\n"
713     - " .word 2b,8b\n"
714     - " .word 3b,8b\n"
715     - " .word 4b,8b\n"
716     - " .word 5b,8b\n"
717     - " .word 6b,8b\n"
718     - " .word 7b,8b\n"
719     - " .word 0b,8b\n"
720     + STR(PTR) " 1b,8b\n"
721     + STR(PTR) " 2b,8b\n"
722     + STR(PTR) " 3b,8b\n"
723     + STR(PTR) " 4b,8b\n"
724     + STR(PTR) " 5b,8b\n"
725     + STR(PTR) " 6b,8b\n"
726     + STR(PTR) " 7b,8b\n"
727     + STR(PTR) " 0b,8b\n"
728     " .previous\n"
729     " .set pop\n"
730     : "+&r"(rt), "=&r"(rs),
731     @@ -2000,7 +2001,7 @@ fpu_emul:
732     "j 2b\n"
733     ".previous\n"
734     ".section __ex_table,\"a\"\n"
735     - ".word 1b, 3b\n"
736     + STR(PTR) " 1b,3b\n"
737     ".previous\n"
738     : "=&r"(res), "+&r"(err)
739     : "r"(vaddr), "i"(SIGSEGV)
740     @@ -2058,7 +2059,7 @@ fpu_emul:
741     "j 2b\n"
742     ".previous\n"
743     ".section __ex_table,\"a\"\n"
744     - ".word 1b, 3b\n"
745     + STR(PTR) " 1b,3b\n"
746     ".previous\n"
747     : "+&r"(res), "+&r"(err)
748     : "r"(vaddr), "i"(SIGSEGV));
749     @@ -2119,7 +2120,7 @@ fpu_emul:
750     "j 2b\n"
751     ".previous\n"
752     ".section __ex_table,\"a\"\n"
753     - ".word 1b, 3b\n"
754     + STR(PTR) " 1b,3b\n"
755     ".previous\n"
756     : "=&r"(res), "+&r"(err)
757     : "r"(vaddr), "i"(SIGSEGV)
758     @@ -2182,7 +2183,7 @@ fpu_emul:
759     "j 2b\n"
760     ".previous\n"
761     ".section __ex_table,\"a\"\n"
762     - ".word 1b, 3b\n"
763     + STR(PTR) " 1b,3b\n"
764     ".previous\n"
765     : "+&r"(res), "+&r"(err)
766     : "r"(vaddr), "i"(SIGSEGV));
767     diff --git a/arch/mips/kernel/pm.c b/arch/mips/kernel/pm.c
768     index fefdf39d3df3..dc814892133c 100644
769     --- a/arch/mips/kernel/pm.c
770     +++ b/arch/mips/kernel/pm.c
771     @@ -56,7 +56,7 @@ static void mips_cpu_restore(void)
772     write_c0_userlocal(current_thread_info()->tp_value);
773    
774     /* Restore watch registers */
775     - __restore_watch();
776     + __restore_watch(current);
777     }
778    
779     /**
780     diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
781     index f2975d4d1e44..89847bee2b53 100644
782     --- a/arch/mips/kernel/process.c
783     +++ b/arch/mips/kernel/process.c
784     @@ -457,7 +457,7 @@ unsigned long notrace unwind_stack_by_address(unsigned long stack_page,
785     *sp + sizeof(*regs) <= stack_page + THREAD_SIZE - 32) {
786     regs = (struct pt_regs *)*sp;
787     pc = regs->cp0_epc;
788     - if (__kernel_text_address(pc)) {
789     + if (!user_mode(regs) && __kernel_text_address(pc)) {
790     *sp = regs->regs[29];
791     *ra = regs->regs[31];
792     return pc;
793     @@ -603,6 +603,9 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
794     if (!(value & PR_FP_MODE_FR) && cpu_has_fpu && cpu_has_mips_r6)
795     return -EOPNOTSUPP;
796    
797     + /* Proceed with the mode switch */
798     + preempt_disable();
799     +
800     /* Save FP & vector context, then disable FPU & MSA */
801     if (task->signal == current->signal)
802     lose_fpu(1);
803     @@ -661,6 +664,7 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
804    
805     /* Allow threads to use FP again */
806     atomic_set(&task->mm->context.fp_mode_switching, 0);
807     + preempt_enable();
808    
809     return 0;
810     }
811     diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
812     index 4f0ac78d17f1..74d581569778 100644
813     --- a/arch/mips/kernel/ptrace.c
814     +++ b/arch/mips/kernel/ptrace.c
815     @@ -57,8 +57,7 @@ static void init_fp_ctx(struct task_struct *target)
816     /* Begin with data registers set to all 1s... */
817     memset(&target->thread.fpu.fpr, ~0, sizeof(target->thread.fpu.fpr));
818    
819     - /* ...and FCSR zeroed */
820     - target->thread.fpu.fcr31 = 0;
821     + /* FCSR has been preset by `mips_set_personality_nan'. */
822    
823     /*
824     * Record that the target has "used" math, such that the context
825     @@ -80,6 +79,22 @@ void ptrace_disable(struct task_struct *child)
826     }
827    
828     /*
829     + * Poke at FCSR according to its mask. Don't set the cause bits as
830     + * this is currently not handled correctly in FP context restoration
831     + * and will cause an oops if a corresponding enable bit is set.
832     + */
833     +static void ptrace_setfcr31(struct task_struct *child, u32 value)
834     +{
835     + u32 fcr31;
836     + u32 mask;
837     +
838     + value &= ~FPU_CSR_ALL_X;
839     + fcr31 = child->thread.fpu.fcr31;
840     + mask = boot_cpu_data.fpu_msk31;
841     + child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask);
842     +}
843     +
844     +/*
845     * Read a general register set. We always use the 64-bit format, even
846     * for 32-bit kernels and for 32-bit processes on a 64-bit kernel.
847     * Registers are sign extended to fill the available space.
848     @@ -159,9 +174,7 @@ int ptrace_setfpregs(struct task_struct *child, __u32 __user *data)
849     {
850     union fpureg *fregs;
851     u64 fpr_val;
852     - u32 fcr31;
853     u32 value;
854     - u32 mask;
855     int i;
856    
857     if (!access_ok(VERIFY_READ, data, 33 * 8))
858     @@ -176,9 +189,7 @@ int ptrace_setfpregs(struct task_struct *child, __u32 __user *data)
859     }
860    
861     __get_user(value, data + 64);
862     - fcr31 = child->thread.fpu.fcr31;
863     - mask = boot_cpu_data.fpu_msk31;
864     - child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask);
865     + ptrace_setfcr31(child, value);
866    
867     /* FIR may not be written. */
868    
869     @@ -808,7 +819,7 @@ long arch_ptrace(struct task_struct *child, long request,
870     break;
871     #endif
872     case FPC_CSR:
873     - child->thread.fpu.fcr31 = data & ~FPU_CSR_ALL_X;
874     + ptrace_setfcr31(child, data);
875     break;
876     case DSP_BASE ... DSP_BASE + 5: {
877     dspreg_t *dregs;
878     diff --git a/arch/mips/kernel/r4k_fpu.S b/arch/mips/kernel/r4k_fpu.S
879     index f09546ee2cdc..bc74485ec805 100644
880     --- a/arch/mips/kernel/r4k_fpu.S
881     +++ b/arch/mips/kernel/r4k_fpu.S
882     @@ -244,17 +244,17 @@ LEAF(\name)
883     .set push
884     .set noat
885     #ifdef CONFIG_64BIT
886     - copy_u_d \wr, 1
887     + copy_s_d \wr, 1
888     EX sd $1, \off(\base)
889     #elif defined(CONFIG_CPU_LITTLE_ENDIAN)
890     - copy_u_w \wr, 2
891     + copy_s_w \wr, 2
892     EX sw $1, \off(\base)
893     - copy_u_w \wr, 3
894     + copy_s_w \wr, 3
895     EX sw $1, (\off+4)(\base)
896     #else /* CONFIG_CPU_BIG_ENDIAN */
897     - copy_u_w \wr, 2
898     + copy_s_w \wr, 2
899     EX sw $1, (\off+4)(\base)
900     - copy_u_w \wr, 3
901     + copy_s_w \wr, 3
902     EX sw $1, \off(\base)
903     #endif
904     .set pop
905     diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
906     index 66aac55df349..8acae316f26b 100644
907     --- a/arch/mips/kernel/setup.c
908     +++ b/arch/mips/kernel/setup.c
909     @@ -706,6 +706,9 @@ static void __init arch_mem_init(char **cmdline_p)
910     for_each_memblock(reserved, reg)
911     if (reg->size != 0)
912     reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
913     +
914     + reserve_bootmem_region(__pa_symbol(&__nosave_begin),
915     + __pa_symbol(&__nosave_end)); /* Reserve for hibernation */
916     }
917    
918     static void __init resource_init(void)
919     diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
920     index bf792e2839a6..9e35b6b26aa8 100644
921     --- a/arch/mips/kernel/signal.c
922     +++ b/arch/mips/kernel/signal.c
923     @@ -195,6 +195,9 @@ static int restore_msa_extcontext(void __user *buf, unsigned int size)
924     unsigned int csr;
925     int i, err;
926    
927     + if (!config_enabled(CONFIG_CPU_HAS_MSA))
928     + return SIGSYS;
929     +
930     if (size != sizeof(*msa))
931     return -EINVAL;
932    
933     @@ -398,8 +401,8 @@ int protected_restore_fp_context(void __user *sc)
934     }
935    
936     fp_done:
937     - if (used & USED_EXTCONTEXT)
938     - err |= restore_extcontext(sc_to_extcontext(sc));
939     + if (!err && (used & USED_EXTCONTEXT))
940     + err = restore_extcontext(sc_to_extcontext(sc));
941    
942     return err ?: sig;
943     }
944     @@ -767,15 +770,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
945     sigset_t *oldset = sigmask_to_save();
946     int ret;
947     struct mips_abi *abi = current->thread.abi;
948     -#ifdef CONFIG_CPU_MICROMIPS
949     - void *vdso;
950     - unsigned long tmp = (unsigned long)current->mm->context.vdso;
951     -
952     - set_isa16_mode(tmp);
953     - vdso = (void *)tmp;
954     -#else
955     void *vdso = current->mm->context.vdso;
956     -#endif
957    
958     if (regs->regs[0]) {
959     switch(regs->regs[2]) {
960     diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
961     index ca9a81007489..99a402231f4d 100644
962     --- a/arch/mips/kernel/traps.c
963     +++ b/arch/mips/kernel/traps.c
964     @@ -144,7 +144,7 @@ static void show_backtrace(struct task_struct *task, const struct pt_regs *regs)
965     if (!task)
966     task = current;
967    
968     - if (raw_show_trace || !__kernel_text_address(pc)) {
969     + if (raw_show_trace || user_mode(regs) || !__kernel_text_address(pc)) {
970     show_raw_backtrace(sp);
971     return;
972     }
973     @@ -1241,7 +1241,7 @@ static int enable_restore_fp_context(int msa)
974     err = init_fpu();
975     if (msa && !err) {
976     enable_msa();
977     - _init_msa_upper();
978     + init_msa_upper();
979     set_thread_flag(TIF_USEDMSA);
980     set_thread_flag(TIF_MSA_CTX_LIVE);
981     }
982     @@ -1304,7 +1304,7 @@ static int enable_restore_fp_context(int msa)
983     */
984     prior_msa = test_and_set_thread_flag(TIF_MSA_CTX_LIVE);
985     if (!prior_msa && was_fpu_owner) {
986     - _init_msa_upper();
987     + init_msa_upper();
988    
989     goto out;
990     }
991     @@ -1321,7 +1321,7 @@ static int enable_restore_fp_context(int msa)
992     * of each vector register such that it cannot see data left
993     * behind by another task.
994     */
995     - _init_msa_upper();
996     + init_msa_upper();
997     } else {
998     /* We need to restore the vector context. */
999     restore_msa(current);
1000     diff --git a/arch/mips/kernel/watch.c b/arch/mips/kernel/watch.c
1001     index 2a03abb5bd2c..9b78e375118e 100644
1002     --- a/arch/mips/kernel/watch.c
1003     +++ b/arch/mips/kernel/watch.c
1004     @@ -15,10 +15,9 @@
1005     * Install the watch registers for the current thread. A maximum of
1006     * four registers are installed although the machine may have more.
1007     */
1008     -void mips_install_watch_registers(void)
1009     +void mips_install_watch_registers(struct task_struct *t)
1010     {
1011     - struct mips3264_watch_reg_state *watches =
1012     - &current->thread.watch.mips3264;
1013     + struct mips3264_watch_reg_state *watches = &t->thread.watch.mips3264;
1014     switch (current_cpu_data.watch_reg_use_cnt) {
1015     default:
1016     BUG();
1017     diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c
1018     index beb80f316095..927dc94a030f 100644
1019     --- a/arch/mips/lib/ashldi3.c
1020     +++ b/arch/mips/lib/ashldi3.c
1021     @@ -2,7 +2,7 @@
1022    
1023     #include "libgcc.h"
1024    
1025     -long long __ashldi3(long long u, word_type b)
1026     +long long notrace __ashldi3(long long u, word_type b)
1027     {
1028     DWunion uu, w;
1029     word_type bm;
1030     diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c
1031     index c884a912b660..9fdf1a598428 100644
1032     --- a/arch/mips/lib/ashrdi3.c
1033     +++ b/arch/mips/lib/ashrdi3.c
1034     @@ -2,7 +2,7 @@
1035    
1036     #include "libgcc.h"
1037    
1038     -long long __ashrdi3(long long u, word_type b)
1039     +long long notrace __ashrdi3(long long u, word_type b)
1040     {
1041     DWunion uu, w;
1042     word_type bm;
1043     diff --git a/arch/mips/lib/bswapdi.c b/arch/mips/lib/bswapdi.c
1044     index 77e5f9c1f005..e3e77aa52c95 100644
1045     --- a/arch/mips/lib/bswapdi.c
1046     +++ b/arch/mips/lib/bswapdi.c
1047     @@ -1,6 +1,6 @@
1048     #include <linux/module.h>
1049    
1050     -unsigned long long __bswapdi2(unsigned long long u)
1051     +unsigned long long notrace __bswapdi2(unsigned long long u)
1052     {
1053     return (((u) & 0xff00000000000000ull) >> 56) |
1054     (((u) & 0x00ff000000000000ull) >> 40) |
1055     diff --git a/arch/mips/lib/bswapsi.c b/arch/mips/lib/bswapsi.c
1056     index 2b302ff121d2..530a8afe6fda 100644
1057     --- a/arch/mips/lib/bswapsi.c
1058     +++ b/arch/mips/lib/bswapsi.c
1059     @@ -1,6 +1,6 @@
1060     #include <linux/module.h>
1061    
1062     -unsigned int __bswapsi2(unsigned int u)
1063     +unsigned int notrace __bswapsi2(unsigned int u)
1064     {
1065     return (((u) & 0xff000000) >> 24) |
1066     (((u) & 0x00ff0000) >> 8) |
1067     diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c
1068     index 8c1306437ed1..06857da96993 100644
1069     --- a/arch/mips/lib/cmpdi2.c
1070     +++ b/arch/mips/lib/cmpdi2.c
1071     @@ -2,7 +2,7 @@
1072    
1073     #include "libgcc.h"
1074    
1075     -word_type __cmpdi2(long long a, long long b)
1076     +word_type notrace __cmpdi2(long long a, long long b)
1077     {
1078     const DWunion au = {
1079     .ll = a
1080     diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c
1081     index dcf8d6810b7c..364547449c65 100644
1082     --- a/arch/mips/lib/lshrdi3.c
1083     +++ b/arch/mips/lib/lshrdi3.c
1084     @@ -2,7 +2,7 @@
1085    
1086     #include "libgcc.h"
1087    
1088     -long long __lshrdi3(long long u, word_type b)
1089     +long long notrace __lshrdi3(long long u, word_type b)
1090     {
1091     DWunion uu, w;
1092     word_type bm;
1093     diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c
1094     index bb4cb2f828ea..bd599f58234c 100644
1095     --- a/arch/mips/lib/ucmpdi2.c
1096     +++ b/arch/mips/lib/ucmpdi2.c
1097     @@ -2,7 +2,7 @@
1098    
1099     #include "libgcc.h"
1100    
1101     -word_type __ucmpdi2(unsigned long long a, unsigned long long b)
1102     +word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b)
1103     {
1104     const DWunion au = {.ll = a};
1105     const DWunion bu = {.ll = b};
1106     diff --git a/arch/mips/loongson64/loongson-3/numa.c b/arch/mips/loongson64/loongson-3/numa.c
1107     index 6f9e010cec4d..282c5a8c2fcd 100644
1108     --- a/arch/mips/loongson64/loongson-3/numa.c
1109     +++ b/arch/mips/loongson64/loongson-3/numa.c
1110     @@ -213,10 +213,10 @@ static void __init node_mem_init(unsigned int node)
1111     BOOTMEM_DEFAULT);
1112    
1113     if (node == 0 && node_end_pfn(0) >= (0xffffffff >> PAGE_SHIFT)) {
1114     - /* Reserve 0xff800000~0xffffffff for RS780E integrated GPU */
1115     + /* Reserve 0xfe000000~0xffffffff for RS780E integrated GPU */
1116     reserve_bootmem_node(NODE_DATA(node),
1117     - (node_addrspace_offset | 0xff800000),
1118     - 8 << 20, BOOTMEM_DEFAULT);
1119     + (node_addrspace_offset | 0xfe000000),
1120     + 32 << 20, BOOTMEM_DEFAULT);
1121     }
1122    
1123     sparse_memory_present_with_active_regions(node);
1124     diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
1125     index 32f0e19a0d7f..734a2c7665ec 100644
1126     --- a/arch/mips/math-emu/cp1emu.c
1127     +++ b/arch/mips/math-emu/cp1emu.c
1128     @@ -445,9 +445,11 @@ static int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
1129     case spec_op:
1130     switch (insn.r_format.func) {
1131     case jalr_op:
1132     - regs->regs[insn.r_format.rd] =
1133     - regs->cp0_epc + dec_insn.pc_inc +
1134     - dec_insn.next_pc_inc;
1135     + if (insn.r_format.rd != 0) {
1136     + regs->regs[insn.r_format.rd] =
1137     + regs->cp0_epc + dec_insn.pc_inc +
1138     + dec_insn.next_pc_inc;
1139     + }
1140     /* Fall through */
1141     case jr_op:
1142     /* For R6, JR already emulated in jalr_op */
1143     diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
1144     index aab218c36e0d..e87bccd6e0aa 100644
1145     --- a/arch/mips/mm/cache.c
1146     +++ b/arch/mips/mm/cache.c
1147     @@ -16,6 +16,7 @@
1148     #include <linux/mm.h>
1149    
1150     #include <asm/cacheflush.h>
1151     +#include <asm/highmem.h>
1152     #include <asm/processor.h>
1153     #include <asm/cpu.h>
1154     #include <asm/cpu-features.h>
1155     @@ -83,8 +84,6 @@ void __flush_dcache_page(struct page *page)
1156     struct address_space *mapping = page_mapping(page);
1157     unsigned long addr;
1158    
1159     - if (PageHighMem(page))
1160     - return;
1161     if (mapping && !mapping_mapped(mapping)) {
1162     SetPageDcacheDirty(page);
1163     return;
1164     @@ -95,8 +94,15 @@ void __flush_dcache_page(struct page *page)
1165     * case is for exec env/arg pages and those are %99 certainly going to
1166     * get faulted into the tlb (and thus flushed) anyways.
1167     */
1168     - addr = (unsigned long) page_address(page);
1169     + if (PageHighMem(page))
1170     + addr = (unsigned long)kmap_atomic(page);
1171     + else
1172     + addr = (unsigned long)page_address(page);
1173     +
1174     flush_data_cache_page(addr);
1175     +
1176     + if (PageHighMem(page))
1177     + __kunmap_atomic((void *)addr);
1178     }
1179    
1180     EXPORT_SYMBOL(__flush_dcache_page);
1181     @@ -119,33 +125,28 @@ void __flush_anon_page(struct page *page, unsigned long vmaddr)
1182    
1183     EXPORT_SYMBOL(__flush_anon_page);
1184    
1185     -void __flush_icache_page(struct vm_area_struct *vma, struct page *page)
1186     -{
1187     - unsigned long addr;
1188     -
1189     - if (PageHighMem(page))
1190     - return;
1191     -
1192     - addr = (unsigned long) page_address(page);
1193     - flush_data_cache_page(addr);
1194     -}
1195     -EXPORT_SYMBOL_GPL(__flush_icache_page);
1196     -
1197     -void __update_cache(struct vm_area_struct *vma, unsigned long address,
1198     - pte_t pte)
1199     +void __update_cache(unsigned long address, pte_t pte)
1200     {
1201     struct page *page;
1202     unsigned long pfn, addr;
1203     - int exec = (vma->vm_flags & VM_EXEC) && !cpu_has_ic_fills_f_dc;
1204     + int exec = !pte_no_exec(pte) && !cpu_has_ic_fills_f_dc;
1205    
1206     pfn = pte_pfn(pte);
1207     if (unlikely(!pfn_valid(pfn)))
1208     return;
1209     page = pfn_to_page(pfn);
1210     - if (page_mapping(page) && Page_dcache_dirty(page)) {
1211     - addr = (unsigned long) page_address(page);
1212     + if (Page_dcache_dirty(page)) {
1213     + if (PageHighMem(page))
1214     + addr = (unsigned long)kmap_atomic(page);
1215     + else
1216     + addr = (unsigned long)page_address(page);
1217     +
1218     if (exec || pages_do_alias(addr, address & PAGE_MASK))
1219     flush_data_cache_page(addr);
1220     +
1221     + if (PageHighMem(page))
1222     + __kunmap_atomic((void *)addr);
1223     +
1224     ClearPageDcacheDirty(page);
1225     }
1226     }
1227     diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
1228     index 14568900fc1d..090393aa0f20 100644
1229     --- a/arch/mips/vdso/Makefile
1230     +++ b/arch/mips/vdso/Makefile
1231     @@ -5,10 +5,12 @@ obj-vdso-y := elf.o gettimeofday.o sigreturn.o
1232     ccflags-vdso := \
1233     $(filter -I%,$(KBUILD_CFLAGS)) \
1234     $(filter -E%,$(KBUILD_CFLAGS)) \
1235     + $(filter -mmicromips,$(KBUILD_CFLAGS)) \
1236     $(filter -march=%,$(KBUILD_CFLAGS))
1237     cflags-vdso := $(ccflags-vdso) \
1238     $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
1239     - -O2 -g -fPIC -fno-common -fno-builtin -G 0 -DDISABLE_BRANCH_PROFILING \
1240     + -O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
1241     + -DDISABLE_BRANCH_PROFILING \
1242     $(call cc-option, -fno-stack-protector)
1243     aflags-vdso := $(ccflags-vdso) \
1244     $(filter -I%,$(KBUILD_CFLAGS)) \
1245     diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
1246     index 40e4d4a27663..b34e8a54f7db 100644
1247     --- a/arch/powerpc/kernel/eeh.c
1248     +++ b/arch/powerpc/kernel/eeh.c
1249     @@ -1072,7 +1072,7 @@ void eeh_add_device_early(struct pci_dn *pdn)
1250     struct pci_controller *phb;
1251     struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
1252    
1253     - if (!edev || !eeh_enabled())
1254     + if (!edev)
1255     return;
1256    
1257     if (!eeh_has_flag(EEH_PROBE_MODE_DEVTREE))
1258     diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
1259     index 52c1e273f8cd..247a0dc012f1 100644
1260     --- a/arch/powerpc/kernel/eeh_driver.c
1261     +++ b/arch/powerpc/kernel/eeh_driver.c
1262     @@ -166,6 +166,16 @@ static void *eeh_dev_save_state(void *data, void *userdata)
1263     if (!edev)
1264     return NULL;
1265    
1266     + /*
1267     + * We cannot access the config space on some adapters.
1268     + * Otherwise, it will cause fenced PHB. We don't save
1269     + * the content in their config space and will restore
1270     + * from the initial config space saved when the EEH
1271     + * device is created.
1272     + */
1273     + if (edev->pe && (edev->pe->state & EEH_PE_CFG_RESTRICTED))
1274     + return NULL;
1275     +
1276     pdev = eeh_dev_to_pci_dev(edev);
1277     if (!pdev)
1278     return NULL;
1279     @@ -305,6 +315,19 @@ static void *eeh_dev_restore_state(void *data, void *userdata)
1280     if (!edev)
1281     return NULL;
1282    
1283     + /*
1284     + * The content in the config space isn't saved because
1285     + * the blocked config space on some adapters. We have
1286     + * to restore the initial saved config space when the
1287     + * EEH device is created.
1288     + */
1289     + if (edev->pe && (edev->pe->state & EEH_PE_CFG_RESTRICTED)) {
1290     + if (list_is_last(&edev->list, &edev->pe->edevs))
1291     + eeh_pe_restore_bars(edev->pe);
1292     +
1293     + return NULL;
1294     + }
1295     +
1296     pdev = eeh_dev_to_pci_dev(edev);
1297     if (!pdev)
1298     return NULL;
1299     @@ -504,9 +527,6 @@ int eeh_pe_reset_and_recover(struct eeh_pe *pe)
1300     /* Save states */
1301     eeh_pe_dev_traverse(pe, eeh_dev_save_state, NULL);
1302    
1303     - /* Report error */
1304     - eeh_pe_dev_traverse(pe, eeh_report_error, &result);
1305     -
1306     /* Issue reset */
1307     ret = eeh_reset_pe(pe);
1308     if (ret) {
1309     diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
1310     index 0a0399c2af11..b81ccc5fb32d 100644
1311     --- a/arch/powerpc/kernel/exceptions-64s.S
1312     +++ b/arch/powerpc/kernel/exceptions-64s.S
1313     @@ -962,11 +962,6 @@ hv_facility_unavailable_relon_trampoline:
1314     #endif
1315     STD_RELON_EXCEPTION_PSERIES(0x5700, 0x1700, altivec_assist)
1316    
1317     - /* Other future vectors */
1318     - .align 7
1319     - .globl __end_interrupts
1320     -__end_interrupts:
1321     -
1322     .align 7
1323     system_call_entry:
1324     b system_call_common
1325     @@ -1253,6 +1248,17 @@ __end_handlers:
1326     STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable)
1327     STD_RELON_EXCEPTION_HV_OOL(0xf80, hv_facility_unavailable)
1328    
1329     + /*
1330     + * The __end_interrupts marker must be past the out-of-line (OOL)
1331     + * handlers, so that they are copied to real address 0x100 when running
1332     + * a relocatable kernel. This ensures they can be reached from the short
1333     + * trampoline handlers (like 0x4f00, 0x4f20, etc.) which branch
1334     + * directly, without using LOAD_HANDLER().
1335     + */
1336     + .align 7
1337     + .globl __end_interrupts
1338     +__end_interrupts:
1339     +
1340     #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
1341     /*
1342     * Data area reserved for FWNMI option.
1343     diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
1344     index 7ab29518a3b9..e345891450c3 100644
1345     --- a/arch/x86/xen/setup.c
1346     +++ b/arch/x86/xen/setup.c
1347     @@ -393,6 +393,9 @@ static unsigned long __init xen_set_identity_and_remap_chunk(
1348     unsigned long i = 0;
1349     unsigned long n = end_pfn - start_pfn;
1350    
1351     + if (remap_pfn == 0)
1352     + remap_pfn = nr_pages;
1353     +
1354     while (i < n) {
1355     unsigned long cur_pfn = start_pfn + i;
1356     unsigned long left = n - i;
1357     @@ -438,17 +441,29 @@ static unsigned long __init xen_set_identity_and_remap_chunk(
1358     return remap_pfn;
1359     }
1360    
1361     -static void __init xen_set_identity_and_remap(unsigned long nr_pages)
1362     +static unsigned long __init xen_count_remap_pages(
1363     + unsigned long start_pfn, unsigned long end_pfn, unsigned long nr_pages,
1364     + unsigned long remap_pages)
1365     +{
1366     + if (start_pfn >= nr_pages)
1367     + return remap_pages;
1368     +
1369     + return remap_pages + min(end_pfn, nr_pages) - start_pfn;
1370     +}
1371     +
1372     +static unsigned long __init xen_foreach_remap_area(unsigned long nr_pages,
1373     + unsigned long (*func)(unsigned long start_pfn, unsigned long end_pfn,
1374     + unsigned long nr_pages, unsigned long last_val))
1375     {
1376     phys_addr_t start = 0;
1377     - unsigned long last_pfn = nr_pages;
1378     + unsigned long ret_val = 0;
1379     const struct e820entry *entry = xen_e820_map;
1380     int i;
1381    
1382     /*
1383     * Combine non-RAM regions and gaps until a RAM region (or the
1384     - * end of the map) is reached, then set the 1:1 map and
1385     - * remap the memory in those non-RAM regions.
1386     + * end of the map) is reached, then call the provided function
1387     + * to perform its duty on the non-RAM region.
1388     *
1389     * The combined non-RAM regions are rounded to a whole number
1390     * of pages so any partial pages are accessible via the 1:1
1391     @@ -466,14 +481,13 @@ static void __init xen_set_identity_and_remap(unsigned long nr_pages)
1392     end_pfn = PFN_UP(entry->addr);
1393    
1394     if (start_pfn < end_pfn)
1395     - last_pfn = xen_set_identity_and_remap_chunk(
1396     - start_pfn, end_pfn, nr_pages,
1397     - last_pfn);
1398     + ret_val = func(start_pfn, end_pfn, nr_pages,
1399     + ret_val);
1400     start = end;
1401     }
1402     }
1403    
1404     - pr_info("Released %ld page(s)\n", xen_released_pages);
1405     + return ret_val;
1406     }
1407    
1408     /*
1409     @@ -596,35 +610,6 @@ static void __init xen_ignore_unusable(void)
1410     }
1411     }
1412    
1413     -static unsigned long __init xen_count_remap_pages(unsigned long max_pfn)
1414     -{
1415     - unsigned long extra = 0;
1416     - unsigned long start_pfn, end_pfn;
1417     - const struct e820entry *entry = xen_e820_map;
1418     - int i;
1419     -
1420     - end_pfn = 0;
1421     - for (i = 0; i < xen_e820_map_entries; i++, entry++) {
1422     - start_pfn = PFN_DOWN(entry->addr);
1423     - /* Adjacent regions on non-page boundaries handling! */
1424     - end_pfn = min(end_pfn, start_pfn);
1425     -
1426     - if (start_pfn >= max_pfn)
1427     - return extra + max_pfn - end_pfn;
1428     -
1429     - /* Add any holes in map to result. */
1430     - extra += start_pfn - end_pfn;
1431     -
1432     - end_pfn = PFN_UP(entry->addr + entry->size);
1433     - end_pfn = min(end_pfn, max_pfn);
1434     -
1435     - if (entry->type != E820_RAM)
1436     - extra += end_pfn - start_pfn;
1437     - }
1438     -
1439     - return extra;
1440     -}
1441     -
1442     bool __init xen_is_e820_reserved(phys_addr_t start, phys_addr_t size)
1443     {
1444     struct e820entry *entry;
1445     @@ -804,7 +789,7 @@ char * __init xen_memory_setup(void)
1446     max_pages = xen_get_max_pages();
1447    
1448     /* How many extra pages do we need due to remapping? */
1449     - max_pages += xen_count_remap_pages(max_pfn);
1450     + max_pages += xen_foreach_remap_area(max_pfn, xen_count_remap_pages);
1451    
1452     if (max_pages > max_pfn)
1453     extra_pages += max_pages - max_pfn;
1454     @@ -922,7 +907,9 @@ char * __init xen_memory_setup(void)
1455     * Set identity map on non-RAM pages and prepare remapping the
1456     * underlying RAM.
1457     */
1458     - xen_set_identity_and_remap(max_pfn);
1459     + xen_foreach_remap_area(max_pfn, xen_set_identity_and_remap_chunk);
1460     +
1461     + pr_info("Released %ld page(s)\n", xen_released_pages);
1462    
1463     return "Xen";
1464     }
1465     diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
1466     index 1710c26ba097..ae60e6357d7b 100644
1467     --- a/drivers/base/power/main.c
1468     +++ b/drivers/base/power/main.c
1469     @@ -1262,14 +1262,15 @@ int dpm_suspend_late(pm_message_t state)
1470     error = device_suspend_late(dev);
1471    
1472     mutex_lock(&dpm_list_mtx);
1473     + if (!list_empty(&dev->power.entry))
1474     + list_move(&dev->power.entry, &dpm_late_early_list);
1475     +
1476     if (error) {
1477     pm_dev_err(dev, state, " late", error);
1478     dpm_save_failed_dev(dev_name(dev));
1479     put_device(dev);
1480     break;
1481     }
1482     - if (!list_empty(&dev->power.entry))
1483     - list_move(&dev->power.entry, &dpm_late_early_list);
1484     put_device(dev);
1485    
1486     if (async_error)
1487     diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
1488     index e1a10a03df8e..9796a1a15ef6 100644
1489     --- a/drivers/base/power/runtime.c
1490     +++ b/drivers/base/power/runtime.c
1491     @@ -1468,11 +1468,16 @@ int pm_runtime_force_resume(struct device *dev)
1492     goto out;
1493     }
1494    
1495     - ret = callback(dev);
1496     + ret = pm_runtime_set_active(dev);
1497     if (ret)
1498     goto out;
1499    
1500     - pm_runtime_set_active(dev);
1501     + ret = callback(dev);
1502     + if (ret) {
1503     + pm_runtime_set_suspended(dev);
1504     + goto out;
1505     + }
1506     +
1507     pm_runtime_mark_last_busy(dev);
1508     out:
1509     pm_runtime_enable(dev);
1510     diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c
1511     index 30cf4623184f..aa30af5f0f2b 100644
1512     --- a/drivers/char/hw_random/exynos-rng.c
1513     +++ b/drivers/char/hw_random/exynos-rng.c
1514     @@ -89,6 +89,7 @@ static int exynos_read(struct hwrng *rng, void *buf,
1515     struct exynos_rng, rng);
1516     u32 *data = buf;
1517     int retry = 100;
1518     + int ret = 4;
1519    
1520     pm_runtime_get_sync(exynos_rng->dev);
1521    
1522     @@ -97,17 +98,20 @@ static int exynos_read(struct hwrng *rng, void *buf,
1523     while (!(exynos_rng_readl(exynos_rng,
1524     EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE) && --retry)
1525     cpu_relax();
1526     - if (!retry)
1527     - return -ETIMEDOUT;
1528     + if (!retry) {
1529     + ret = -ETIMEDOUT;
1530     + goto out;
1531     + }
1532    
1533     exynos_rng_writel(exynos_rng, PRNG_DONE, EXYNOS_PRNG_STATUS_OFFSET);
1534    
1535     *data = exynos_rng_readl(exynos_rng, EXYNOS_PRNG_OUT1_OFFSET);
1536    
1537     +out:
1538     pm_runtime_mark_last_busy(exynos_rng->dev);
1539     pm_runtime_put_sync_autosuspend(exynos_rng->dev);
1540    
1541     - return 4;
1542     + return ret;
1543     }
1544    
1545     static int exynos_rng_probe(struct platform_device *pdev)
1546     diff --git a/drivers/clk/at91/clk-h32mx.c b/drivers/clk/at91/clk-h32mx.c
1547     index 61566bcefa53..a165230e7eda 100644
1548     --- a/drivers/clk/at91/clk-h32mx.c
1549     +++ b/drivers/clk/at91/clk-h32mx.c
1550     @@ -116,7 +116,7 @@ void __init of_sama5d4_clk_h32mx_setup(struct device_node *np,
1551     h32mxclk->pmc = pmc;
1552    
1553     clk = clk_register(NULL, &h32mxclk->hw);
1554     - if (!clk) {
1555     + if (IS_ERR(clk)) {
1556     kfree(h32mxclk);
1557     return;
1558     }
1559     diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
1560     index 185a4d859638..6029313aa995 100644
1561     --- a/drivers/clk/bcm/clk-bcm2835.c
1562     +++ b/drivers/clk/bcm/clk-bcm2835.c
1563     @@ -890,8 +890,14 @@ static void bcm2835_pll_off(struct clk_hw *hw)
1564     struct bcm2835_cprman *cprman = pll->cprman;
1565     const struct bcm2835_pll_data *data = pll->data;
1566    
1567     - cprman_write(cprman, data->cm_ctrl_reg, CM_PLL_ANARST);
1568     - cprman_write(cprman, data->a2w_ctrl_reg, A2W_PLL_CTRL_PWRDN);
1569     + spin_lock(&cprman->regs_lock);
1570     + cprman_write(cprman, data->cm_ctrl_reg,
1571     + cprman_read(cprman, data->cm_ctrl_reg) |
1572     + CM_PLL_ANARST);
1573     + cprman_write(cprman, data->a2w_ctrl_reg,
1574     + cprman_read(cprman, data->a2w_ctrl_reg) |
1575     + A2W_PLL_CTRL_PWRDN);
1576     + spin_unlock(&cprman->regs_lock);
1577     }
1578    
1579     static int bcm2835_pll_on(struct clk_hw *hw)
1580     @@ -901,6 +907,10 @@ static int bcm2835_pll_on(struct clk_hw *hw)
1581     const struct bcm2835_pll_data *data = pll->data;
1582     ktime_t timeout;
1583    
1584     + cprman_write(cprman, data->a2w_ctrl_reg,
1585     + cprman_read(cprman, data->a2w_ctrl_reg) &
1586     + ~A2W_PLL_CTRL_PWRDN);
1587     +
1588     /* Take the PLL out of reset. */
1589     cprman_write(cprman, data->cm_ctrl_reg,
1590     cprman_read(cprman, data->cm_ctrl_reg) & ~CM_PLL_ANARST);
1591     @@ -1171,8 +1181,9 @@ static u32 bcm2835_clock_choose_div(struct clk_hw *hw,
1592     div &= ~unused_frac_mask;
1593     }
1594    
1595     - /* Clamp to the limits. */
1596     - div = max(div, unused_frac_mask + 1);
1597     + /* clamp to min divider of 1 */
1598     + div = max_t(u32, div, 1 << CM_DIV_FRAC_BITS);
1599     + /* clamp to the highest possible fractional divider */
1600     div = min_t(u32, div, GENMASK(data->int_bits + CM_DIV_FRAC_BITS - 1,
1601     CM_DIV_FRAC_BITS - data->frac_bits));
1602    
1603     diff --git a/drivers/clk/imx/clk-imx35.c b/drivers/clk/imx/clk-imx35.c
1604     index a71d24cb4c06..b0978d3b83e2 100644
1605     --- a/drivers/clk/imx/clk-imx35.c
1606     +++ b/drivers/clk/imx/clk-imx35.c
1607     @@ -66,7 +66,7 @@ static const char *std_sel[] = {"ppll", "arm"};
1608     static const char *ipg_per_sel[] = {"ahb_per_div", "arm_per_div"};
1609    
1610     enum mx35_clks {
1611     - ckih, ckil, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg,
1612     + ckih, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg,
1613     arm_per_div, ahb_per_div, ipg_per, uart_sel, uart_div, esdhc_sel,
1614     esdhc1_div, esdhc2_div, esdhc3_div, spdif_sel, spdif_div_pre,
1615     spdif_div_post, ssi_sel, ssi1_div_pre, ssi1_div_post, ssi2_div_pre,
1616     @@ -79,7 +79,7 @@ enum mx35_clks {
1617     rtc_gate, rtic_gate, scc_gate, sdma_gate, spba_gate, spdif_gate,
1618     ssi1_gate, ssi2_gate, uart1_gate, uart2_gate, uart3_gate, usbotg_gate,
1619     wdog_gate, max_gate, admux_gate, csi_gate, csi_div, csi_sel, iim_gate,
1620     - gpu2d_gate, clk_max
1621     + gpu2d_gate, ckil, clk_max
1622     };
1623    
1624     static struct clk *clk[clk_max];
1625     diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
1626     index 17a6dc0e2111..d40b2c077746 100644
1627     --- a/drivers/cpuidle/cpuidle.c
1628     +++ b/drivers/cpuidle/cpuidle.c
1629     @@ -214,7 +214,7 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
1630     tick_broadcast_exit();
1631     }
1632    
1633     - if (!cpuidle_state_is_coupled(drv, entered_state))
1634     + if (!cpuidle_state_is_coupled(drv, index))
1635     local_irq_enable();
1636    
1637     diff = ktime_to_us(ktime_sub(time_end, time_start));
1638     @@ -433,6 +433,8 @@ static void __cpuidle_unregister_device(struct cpuidle_device *dev)
1639     list_del(&dev->device_list);
1640     per_cpu(cpuidle_devices, dev->cpu) = NULL;
1641     module_put(drv->owner);
1642     +
1643     + dev->registered = 0;
1644     }
1645    
1646     static void __cpuidle_device_init(struct cpuidle_device *dev)
1647     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1648     index 119cdc2c43e7..7ef2c13921b4 100644
1649     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1650     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1651     @@ -194,12 +194,12 @@ int amdgpu_connector_get_monitor_bpc(struct drm_connector *connector)
1652     bpc = 8;
1653     DRM_DEBUG("%s: HDMI deep color 10 bpc exceeds max tmds clock. Using %d bpc.\n",
1654     connector->name, bpc);
1655     - } else if (bpc > 8) {
1656     - /* max_tmds_clock missing, but hdmi spec mandates it for deep color. */
1657     - DRM_DEBUG("%s: Required max tmds clock for HDMI deep color missing. Using 8 bpc.\n",
1658     - connector->name);
1659     - bpc = 8;
1660     }
1661     + } else if (bpc > 8) {
1662     + /* max_tmds_clock missing, but hdmi spec mandates it for deep color. */
1663     + DRM_DEBUG("%s: Required max tmds clock for HDMI deep color missing. Using 8 bpc.\n",
1664     + connector->name);
1665     + bpc = 8;
1666     }
1667     }
1668    
1669     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
1670     index 7b7f4aba60c0..fe36caf1b7d7 100644
1671     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
1672     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
1673     @@ -150,7 +150,7 @@ u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
1674     list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
1675     amdgpu_crtc = to_amdgpu_crtc(crtc);
1676     if (crtc->enabled && amdgpu_crtc->enabled && amdgpu_crtc->hw_mode.clock) {
1677     - vrefresh = amdgpu_crtc->hw_mode.vrefresh;
1678     + vrefresh = drm_mode_vrefresh(&amdgpu_crtc->hw_mode);
1679     break;
1680     }
1681     }
1682     diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
1683     index aeee083c7f95..aed2e3f8a1a2 100644
1684     --- a/drivers/gpu/drm/drm_atomic.c
1685     +++ b/drivers/gpu/drm/drm_atomic.c
1686     @@ -150,7 +150,7 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
1687     for (i = 0; i < state->num_connector; i++) {
1688     struct drm_connector *connector = state->connectors[i];
1689    
1690     - if (!connector)
1691     + if (!connector || !connector->funcs)
1692     continue;
1693    
1694     /*
1695     diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
1696     index 69cbab5e5c81..5ad036741b99 100644
1697     --- a/drivers/gpu/drm/drm_fb_helper.c
1698     +++ b/drivers/gpu/drm/drm_fb_helper.c
1699     @@ -1899,7 +1899,6 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
1700     int n, int width, int height)
1701     {
1702     int c, o;
1703     - struct drm_device *dev = fb_helper->dev;
1704     struct drm_connector *connector;
1705     const struct drm_connector_helper_funcs *connector_funcs;
1706     struct drm_encoder *encoder;
1707     @@ -1918,7 +1917,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
1708     if (modes[n] == NULL)
1709     return best_score;
1710    
1711     - crtcs = kzalloc(dev->mode_config.num_connector *
1712     + crtcs = kzalloc(fb_helper->connector_count *
1713     sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL);
1714     if (!crtcs)
1715     return best_score;
1716     @@ -1964,7 +1963,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
1717     if (score > best_score) {
1718     best_score = score;
1719     memcpy(best_crtcs, crtcs,
1720     - dev->mode_config.num_connector *
1721     + fb_helper->connector_count *
1722     sizeof(struct drm_fb_helper_crtc *));
1723     }
1724     }
1725     diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c
1726     index 6b43ae3ffd73..1616af209bfc 100644
1727     --- a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c
1728     +++ b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c
1729     @@ -72,7 +72,7 @@ static const char *const dsi_errors[] = {
1730     "RX Prot Violation",
1731     "HS Generic Write FIFO Full",
1732     "LP Generic Write FIFO Full",
1733     - "Generic Read Data Avail"
1734     + "Generic Read Data Avail",
1735     "Special Packet Sent",
1736     "Tearing Effect",
1737     };
1738     diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
1739     index 4fd5fdfef6bd..c0c094d5b822 100644
1740     --- a/drivers/gpu/drm/i915/intel_fbdev.c
1741     +++ b/drivers/gpu/drm/i915/intel_fbdev.c
1742     @@ -362,12 +362,12 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
1743     uint64_t conn_configured = 0, mask;
1744     int pass = 0;
1745    
1746     - save_enabled = kcalloc(dev->mode_config.num_connector, sizeof(bool),
1747     + save_enabled = kcalloc(fb_helper->connector_count, sizeof(bool),
1748     GFP_KERNEL);
1749     if (!save_enabled)
1750     return false;
1751    
1752     - memcpy(save_enabled, enabled, dev->mode_config.num_connector);
1753     + memcpy(save_enabled, enabled, fb_helper->connector_count);
1754     mask = (1 << fb_helper->connector_count) - 1;
1755     retry:
1756     for (i = 0; i < fb_helper->connector_count; i++) {
1757     @@ -501,7 +501,7 @@ retry:
1758     if (fallback) {
1759     bail:
1760     DRM_DEBUG_KMS("Not using firmware configuration\n");
1761     - memcpy(enabled, save_enabled, dev->mode_config.num_connector);
1762     + memcpy(enabled, save_enabled, fb_helper->connector_count);
1763     kfree(save_enabled);
1764     return false;
1765     }
1766     diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
1767     index 0a68d2ec89dc..62284e45d531 100644
1768     --- a/drivers/gpu/drm/i915/intel_pm.c
1769     +++ b/drivers/gpu/drm/i915/intel_pm.c
1770     @@ -3880,6 +3880,8 @@ static void ilk_pipe_wm_get_hw_state(struct drm_crtc *crtc)
1771     if (IS_HASWELL(dev) || IS_BROADWELL(dev))
1772     hw->wm_linetime[pipe] = I915_READ(PIPE_WM_LINETIME(pipe));
1773    
1774     + memset(active, 0, sizeof(*active));
1775     +
1776     active->pipe_enabled = intel_crtc->active;
1777    
1778     if (active->pipe_enabled) {
1779     diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
1780     index 7b990b4e96d2..5378bdc3bbf9 100644
1781     --- a/drivers/gpu/drm/imx/imx-drm-core.c
1782     +++ b/drivers/gpu/drm/imx/imx-drm-core.c
1783     @@ -26,6 +26,7 @@
1784     #include <drm/drm_fb_cma_helper.h>
1785     #include <drm/drm_plane_helper.h>
1786     #include <drm/drm_of.h>
1787     +#include <video/imx-ipu-v3.h>
1788    
1789     #include "imx-drm.h"
1790    
1791     @@ -504,6 +505,13 @@ static int compare_of(struct device *dev, void *data)
1792     {
1793     struct device_node *np = data;
1794    
1795     + /* Special case for DI, dev->of_node may not be set yet */
1796     + if (strcmp(dev->driver->name, "imx-ipuv3-crtc") == 0) {
1797     + struct ipu_client_platformdata *pdata = dev->platform_data;
1798     +
1799     + return pdata->of_node == np;
1800     + }
1801     +
1802     /* Special case for LDB, one device for two channels */
1803     if (of_node_cmp(np->name, "lvds-channel") == 0) {
1804     np = of_get_parent(np);
1805     diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
1806     index 4ab841eebee1..9b0abd44b751 100644
1807     --- a/drivers/gpu/drm/imx/ipuv3-crtc.c
1808     +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
1809     @@ -369,7 +369,7 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
1810    
1811     ret = imx_drm_add_crtc(drm, &ipu_crtc->base, &ipu_crtc->imx_crtc,
1812     &ipu_crtc->plane[0]->base, &ipu_crtc_helper_funcs,
1813     - ipu_crtc->dev->of_node);
1814     + pdata->of_node);
1815     if (ret) {
1816     dev_err(ipu_crtc->dev, "adding crtc failed with %d.\n", ret);
1817     goto err_put_resources;
1818     diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
1819     index 5da5de0cb522..4948c1529836 100644
1820     --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
1821     +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
1822     @@ -3273,19 +3273,19 @@ static const struct vmw_cmd_entry vmw_cmd_entries[SVGA_3D_CMD_MAX] = {
1823     &vmw_cmd_dx_cid_check, true, false, true),
1824     VMW_CMD_DEF(SVGA_3D_CMD_DX_DEFINE_QUERY, &vmw_cmd_dx_define_query,
1825     true, false, true),
1826     - VMW_CMD_DEF(SVGA_3D_CMD_DX_DESTROY_QUERY, &vmw_cmd_ok,
1827     + VMW_CMD_DEF(SVGA_3D_CMD_DX_DESTROY_QUERY, &vmw_cmd_dx_cid_check,
1828     true, false, true),
1829     VMW_CMD_DEF(SVGA_3D_CMD_DX_BIND_QUERY, &vmw_cmd_dx_bind_query,
1830     true, false, true),
1831     VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_QUERY_OFFSET,
1832     - &vmw_cmd_ok, true, false, true),
1833     - VMW_CMD_DEF(SVGA_3D_CMD_DX_BEGIN_QUERY, &vmw_cmd_ok,
1834     + &vmw_cmd_dx_cid_check, true, false, true),
1835     + VMW_CMD_DEF(SVGA_3D_CMD_DX_BEGIN_QUERY, &vmw_cmd_dx_cid_check,
1836     true, false, true),
1837     - VMW_CMD_DEF(SVGA_3D_CMD_DX_END_QUERY, &vmw_cmd_ok,
1838     + VMW_CMD_DEF(SVGA_3D_CMD_DX_END_QUERY, &vmw_cmd_dx_cid_check,
1839     true, false, true),
1840     VMW_CMD_DEF(SVGA_3D_CMD_DX_READBACK_QUERY, &vmw_cmd_invalid,
1841     true, false, true),
1842     - VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_PREDICATION, &vmw_cmd_invalid,
1843     + VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_PREDICATION, &vmw_cmd_dx_cid_check,
1844     true, false, true),
1845     VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_VIEWPORTS, &vmw_cmd_dx_cid_check,
1846     true, false, true),
1847     diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
1848     index 3b1faf7862a5..679a4cb98ee3 100644
1849     --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
1850     +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
1851     @@ -573,9 +573,9 @@ static int vmw_fb_set_par(struct fb_info *info)
1852     mode = old_mode;
1853     old_mode = NULL;
1854     } else if (!vmw_kms_validate_mode_vram(vmw_priv,
1855     - mode->hdisplay *
1856     - (var->bits_per_pixel + 7) / 8,
1857     - mode->vdisplay)) {
1858     + mode->hdisplay *
1859     + DIV_ROUND_UP(var->bits_per_pixel, 8),
1860     + mode->vdisplay)) {
1861     drm_mode_destroy(vmw_priv->dev, mode);
1862     return -EINVAL;
1863     }
1864     diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
1865     index 0585fd2031dd..5030cba4a581 100644
1866     --- a/drivers/gpu/ipu-v3/ipu-common.c
1867     +++ b/drivers/gpu/ipu-v3/ipu-common.c
1868     @@ -997,7 +997,7 @@ struct ipu_platform_reg {
1869     };
1870    
1871     /* These must be in the order of the corresponding device tree port nodes */
1872     -static const struct ipu_platform_reg client_reg[] = {
1873     +static struct ipu_platform_reg client_reg[] = {
1874     {
1875     .pdata = {
1876     .csi = 0,
1877     @@ -1048,7 +1048,7 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
1878     mutex_unlock(&ipu_client_id_mutex);
1879    
1880     for (i = 0; i < ARRAY_SIZE(client_reg); i++) {
1881     - const struct ipu_platform_reg *reg = &client_reg[i];
1882     + struct ipu_platform_reg *reg = &client_reg[i];
1883     struct platform_device *pdev;
1884     struct device_node *of_node;
1885    
1886     @@ -1070,6 +1070,7 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
1887    
1888     pdev->dev.parent = dev;
1889    
1890     + reg->pdata.of_node = of_node;
1891     ret = platform_device_add_data(pdev, &reg->pdata,
1892     sizeof(reg->pdata));
1893     if (!ret)
1894     diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
1895     index 6c99ee7bafa3..ee396ff167d9 100644
1896     --- a/drivers/hwmon/ads7828.c
1897     +++ b/drivers/hwmon/ads7828.c
1898     @@ -120,6 +120,7 @@ static int ads7828_probe(struct i2c_client *client,
1899     unsigned int vref_mv = ADS7828_INT_VREF_MV;
1900     bool diff_input = false;
1901     bool ext_vref = false;
1902     + unsigned int regval;
1903    
1904     data = devm_kzalloc(dev, sizeof(struct ads7828_data), GFP_KERNEL);
1905     if (!data)
1906     @@ -154,6 +155,15 @@ static int ads7828_probe(struct i2c_client *client,
1907     if (!diff_input)
1908     data->cmd_byte |= ADS7828_CMD_SD_SE;
1909    
1910     + /*
1911     + * Datasheet specifies internal reference voltage is disabled by
1912     + * default. The internal reference voltage needs to be enabled and
1913     + * voltage needs to settle before getting valid ADC data. So perform a
1914     + * dummy read to enable the internal reference voltage.
1915     + */
1916     + if (!ext_vref)
1917     + regmap_read(data->regmap, data->cmd_byte, &regval);
1918     +
1919     hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
1920     data,
1921     ads7828_groups);
1922     diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
1923     index 5adbcedcb81c..2bb4c8633d3b 100644
1924     --- a/drivers/input/misc/uinput.c
1925     +++ b/drivers/input/misc/uinput.c
1926     @@ -893,9 +893,15 @@ static long uinput_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1927     }
1928    
1929     #ifdef CONFIG_COMPAT
1930     +
1931     +#define UI_SET_PHYS_COMPAT _IOW(UINPUT_IOCTL_BASE, 108, compat_uptr_t)
1932     +
1933     static long uinput_compat_ioctl(struct file *file,
1934     unsigned int cmd, unsigned long arg)
1935     {
1936     + if (cmd == UI_SET_PHYS_COMPAT)
1937     + cmd = UI_SET_PHYS;
1938     +
1939     return uinput_ioctl_handler(file, cmd, arg, compat_ptr(arg));
1940     }
1941     #endif
1942     diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
1943     index f38c076752ce..109f687d1cbd 100644
1944     --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
1945     +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
1946     @@ -280,7 +280,8 @@ static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user
1947     static int put_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_buffers32 __user *up)
1948     {
1949     if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_create_buffers32)) ||
1950     - copy_to_user(up, kp, offsetof(struct v4l2_create_buffers32, format)))
1951     + copy_to_user(up, kp, offsetof(struct v4l2_create_buffers32, format)) ||
1952     + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
1953     return -EFAULT;
1954     return __put_v4l2_format32(&kp->format, &up->format);
1955     }
1956     diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
1957     index 68aa31ae553a..88e80ec772f6 100644
1958     --- a/drivers/mfd/intel-lpss.c
1959     +++ b/drivers/mfd/intel-lpss.c
1960     @@ -33,6 +33,7 @@
1961     #define LPSS_DEV_SIZE 0x200
1962     #define LPSS_PRIV_OFFSET 0x200
1963     #define LPSS_PRIV_SIZE 0x100
1964     +#define LPSS_PRIV_REG_COUNT (LPSS_PRIV_SIZE / 4)
1965     #define LPSS_IDMA64_OFFSET 0x800
1966     #define LPSS_IDMA64_SIZE 0x800
1967    
1968     @@ -75,6 +76,7 @@ struct intel_lpss {
1969     const struct mfd_cell *cell;
1970     struct device *dev;
1971     void __iomem *priv;
1972     + u32 priv_ctx[LPSS_PRIV_REG_COUNT];
1973     int devid;
1974     u32 caps;
1975     u32 active_ltr;
1976     @@ -485,6 +487,16 @@ EXPORT_SYMBOL_GPL(intel_lpss_prepare);
1977    
1978     int intel_lpss_suspend(struct device *dev)
1979     {
1980     + struct intel_lpss *lpss = dev_get_drvdata(dev);
1981     + unsigned int i;
1982     +
1983     + /* Save device context */
1984     + for (i = 0; i < LPSS_PRIV_REG_COUNT; i++)
1985     + lpss->priv_ctx[i] = readl(lpss->priv + i * 4);
1986     +
1987     + /* Put the device into reset state */
1988     + writel(0, lpss->priv + LPSS_PRIV_RESETS);
1989     +
1990     return 0;
1991     }
1992     EXPORT_SYMBOL_GPL(intel_lpss_suspend);
1993     @@ -492,8 +504,13 @@ EXPORT_SYMBOL_GPL(intel_lpss_suspend);
1994     int intel_lpss_resume(struct device *dev)
1995     {
1996     struct intel_lpss *lpss = dev_get_drvdata(dev);
1997     + unsigned int i;
1998    
1999     - intel_lpss_init_dev(lpss);
2000     + intel_lpss_deassert_reset(lpss);
2001     +
2002     + /* Restore device context */
2003     + for (i = 0; i < LPSS_PRIV_REG_COUNT; i++)
2004     + writel(lpss->priv_ctx[i], lpss->priv + i * 4);
2005    
2006     return 0;
2007     }
2008     diff --git a/drivers/mfd/intel_soc_pmic_core.c b/drivers/mfd/intel_soc_pmic_core.c
2009     index d9e15cf7c6c8..12d6ebb4ae5d 100644
2010     --- a/drivers/mfd/intel_soc_pmic_core.c
2011     +++ b/drivers/mfd/intel_soc_pmic_core.c
2012     @@ -35,6 +35,7 @@ static struct gpiod_lookup_table panel_gpio_table = {
2013     .table = {
2014     /* Panel EN/DISABLE */
2015     GPIO_LOOKUP("gpio_crystalcove", 94, "panel", GPIO_ACTIVE_HIGH),
2016     + { },
2017     },
2018     };
2019    
2020     diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
2021     index 0947cc271e69..531de256d58d 100644
2022     --- a/drivers/net/wireless/ath/ath10k/core.c
2023     +++ b/drivers/net/wireless/ath/ath10k/core.c
2024     @@ -1681,6 +1681,10 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode)
2025     goto err_hif_stop;
2026     }
2027    
2028     + ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1;
2029     +
2030     + INIT_LIST_HEAD(&ar->arvifs);
2031     +
2032     /* we don't care about HTT in UTF mode */
2033     if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
2034     status = ath10k_htt_setup(&ar->htt);
2035     @@ -1694,10 +1698,6 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode)
2036     if (status)
2037     goto err_hif_stop;
2038    
2039     - ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1;
2040     -
2041     - INIT_LIST_HEAD(&ar->arvifs);
2042     -
2043     return 0;
2044    
2045     err_hif_stop:
2046     diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
2047     index 6cc1aa3449c8..1a88a24ffeac 100644
2048     --- a/drivers/net/wireless/ath/ath10k/debug.c
2049     +++ b/drivers/net/wireless/ath/ath10k/debug.c
2050     @@ -1986,7 +1986,12 @@ static ssize_t ath10k_write_pktlog_filter(struct file *file,
2051     goto out;
2052     }
2053    
2054     - if (filter && (filter != ar->debug.pktlog_filter)) {
2055     + if (filter == ar->debug.pktlog_filter) {
2056     + ret = count;
2057     + goto out;
2058     + }
2059     +
2060     + if (filter) {
2061     ret = ath10k_wmi_pdev_pktlog_enable(ar, filter);
2062     if (ret) {
2063     ath10k_warn(ar, "failed to enable pktlog filter %x: %d\n",
2064     diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
2065     index 95a55405ebf0..1e1bef349487 100644
2066     --- a/drivers/net/wireless/ath/ath10k/mac.c
2067     +++ b/drivers/net/wireless/ath/ath10k/mac.c
2068     @@ -4456,7 +4456,10 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
2069     goto err_vdev_delete;
2070     }
2071    
2072     - if (ar->cfg_tx_chainmask) {
2073     + /* Configuring number of spatial stream for monitor interface is causing
2074     + * target assert in qca9888 and qca6174.
2075     + */
2076     + if (ar->cfg_tx_chainmask && (vif->type != NL80211_IFTYPE_MONITOR)) {
2077     u16 nss = get_nss_from_chainmask(ar->cfg_tx_chainmask);
2078    
2079     vdev_param = ar->wmi.vdev_param->nss;
2080     @@ -6416,7 +6419,13 @@ ath10k_mac_update_rx_channel(struct ath10k *ar,
2081     def = &vifs[0].new_ctx->def;
2082    
2083     ar->rx_channel = def->chan;
2084     - } else if (ctx && ath10k_mac_num_chanctxs(ar) == 0) {
2085     + } else if ((ctx && ath10k_mac_num_chanctxs(ar) == 0) ||
2086     + (ctx && (ar->state == ATH10K_STATE_RESTARTED))) {
2087     + /* During driver restart due to firmware assert, since mac80211
2088     + * already has valid channel context for given radio, channel
2089     + * context iteration return num_chanctx > 0. So fix rx_channel
2090     + * when restart is in progress.
2091     + */
2092     ar->rx_channel = ctx->def.chan;
2093     } else {
2094     ar->rx_channel = NULL;
2095     diff --git a/drivers/net/wireless/ath/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c
2096     index 803030fd17d3..6a2a16856763 100644
2097     --- a/drivers/net/wireless/ath/ath5k/led.c
2098     +++ b/drivers/net/wireless/ath/ath5k/led.c
2099     @@ -77,7 +77,7 @@ static const struct pci_device_id ath5k_led_devices[] = {
2100     /* HP Compaq CQ60-206US (ddreggors@jumptv.com) */
2101     { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137a), ATH_LED(3, 1) },
2102     /* HP Compaq C700 (nitrousnrg@gmail.com) */
2103     - { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 1) },
2104     + { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 0) },
2105     /* LiteOn AR5BXB63 (magooz@salug.it) */
2106     { ATH_SDEVICE(PCI_VENDOR_ID_ATHEROS, 0x3067), ATH_LED(3, 0) },
2107     /* IBM-specific AR5212 (all others) */
2108     diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
2109     index 2e2b92ba96b8..1bdeacf7b257 100644
2110     --- a/drivers/net/wireless/ath/ath9k/init.c
2111     +++ b/drivers/net/wireless/ath/ath9k/init.c
2112     @@ -49,6 +49,10 @@ int ath9k_led_blink;
2113     module_param_named(blink, ath9k_led_blink, int, 0444);
2114     MODULE_PARM_DESC(blink, "Enable LED blink on activity");
2115    
2116     +static int ath9k_led_active_high = -1;
2117     +module_param_named(led_active_high, ath9k_led_active_high, int, 0444);
2118     +MODULE_PARM_DESC(led_active_high, "Invert LED polarity");
2119     +
2120     static int ath9k_btcoex_enable;
2121     module_param_named(btcoex_enable, ath9k_btcoex_enable, int, 0444);
2122     MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence");
2123     @@ -600,6 +604,9 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
2124     if (ret)
2125     return ret;
2126    
2127     + if (ath9k_led_active_high != -1)
2128     + ah->config.led_active_high = ath9k_led_active_high == 1;
2129     +
2130     /*
2131     * Enable WLAN/BT RX Antenna diversity only when:
2132     *
2133     diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
2134     index e6fef1be9977..7cdaf40c3057 100644
2135     --- a/drivers/net/wireless/ath/ath9k/pci.c
2136     +++ b/drivers/net/wireless/ath/ath9k/pci.c
2137     @@ -28,6 +28,16 @@ static const struct pci_device_id ath_pci_id_table[] = {
2138     { PCI_VDEVICE(ATHEROS, 0x0024) }, /* PCI-E */
2139     { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */
2140     { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI */
2141     +
2142     +#ifdef CONFIG_ATH9K_PCOEM
2143     + /* Mini PCI AR9220 MB92 cards: Compex WLM200NX, Wistron DNMA-92 */
2144     + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
2145     + 0x0029,
2146     + PCI_VENDOR_ID_ATHEROS,
2147     + 0x2096),
2148     + .driver_data = ATH9K_PCI_LED_ACT_HI },
2149     +#endif
2150     +
2151     { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */
2152    
2153     #ifdef CONFIG_ATH9K_PCOEM
2154     diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
2155     index 0517a4f2d3f2..7a40d8dffa36 100644
2156     --- a/drivers/net/wireless/realtek/rtlwifi/base.c
2157     +++ b/drivers/net/wireless/realtek/rtlwifi/base.c
2158     @@ -1660,9 +1660,9 @@ void rtl_watchdog_wq_callback(void *data)
2159     if (((rtlpriv->link_info.num_rx_inperiod +
2160     rtlpriv->link_info.num_tx_inperiod) > 8) ||
2161     (rtlpriv->link_info.num_rx_inperiod > 2))
2162     - rtl_lps_enter(hw);
2163     - else
2164     rtl_lps_leave(hw);
2165     + else
2166     + rtl_lps_enter(hw);
2167     }
2168    
2169     rtlpriv->link_info.num_rx_inperiod = 0;
2170     diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
2171     index f2b9d11adc9e..e85f1652ce55 100644
2172     --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
2173     +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
2174     @@ -1203,7 +1203,6 @@ static void btc8723b2ant_set_ant_path(struct btc_coexist *btcoexist,
2175    
2176     /* Force GNT_BT to low */
2177     btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0);
2178     - btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
2179    
2180     if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) {
2181     /* tell firmware "no antenna inverse" */
2182     @@ -1211,19 +1210,25 @@ static void btc8723b2ant_set_ant_path(struct btc_coexist *btcoexist,
2183     h2c_parameter[1] = 1; /* ext switch type */
2184     btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
2185     h2c_parameter);
2186     + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
2187     } else {
2188     /* tell firmware "antenna inverse" */
2189     h2c_parameter[0] = 1;
2190     h2c_parameter[1] = 1; /* ext switch type */
2191     btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
2192     h2c_parameter);
2193     + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
2194     }
2195     }
2196    
2197     /* ext switch setting */
2198     if (use_ext_switch) {
2199     /* fixed internal switch S1->WiFi, S0->BT */
2200     - btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
2201     + if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
2202     + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
2203     + else
2204     + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
2205     +
2206     switch (antpos_type) {
2207     case BTC_ANT_WIFI_AT_MAIN:
2208     /* ext switch main at wifi */
2209     diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
2210     index b2791c893417..babd1490f20c 100644
2211     --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
2212     +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
2213     @@ -965,13 +965,38 @@ void exhalbtc_set_chip_type(u8 chip_type)
2214     }
2215     }
2216    
2217     -void exhalbtc_set_ant_num(u8 type, u8 ant_num)
2218     +void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
2219     {
2220     if (BT_COEX_ANT_TYPE_PG == type) {
2221     gl_bt_coexist.board_info.pg_ant_num = ant_num;
2222     gl_bt_coexist.board_info.btdm_ant_num = ant_num;
2223     + /* The antenna position:
2224     + * Main (default) or Aux for pgAntNum=2 && btdmAntNum =1.
2225     + * The antenna position should be determined by
2226     + * auto-detect mechanism.
2227     + * The following is assumed to main,
2228     + * and those must be modified
2229     + * if y auto-detect mechanism is ready
2230     + */
2231     + if ((gl_bt_coexist.board_info.pg_ant_num == 2) &&
2232     + (gl_bt_coexist.board_info.btdm_ant_num == 1))
2233     + gl_bt_coexist.board_info.btdm_ant_pos =
2234     + BTC_ANTENNA_AT_MAIN_PORT;
2235     + else
2236     + gl_bt_coexist.board_info.btdm_ant_pos =
2237     + BTC_ANTENNA_AT_MAIN_PORT;
2238     } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
2239     gl_bt_coexist.board_info.btdm_ant_num = ant_num;
2240     + gl_bt_coexist.board_info.btdm_ant_pos =
2241     + BTC_ANTENNA_AT_MAIN_PORT;
2242     + } else if (type == BT_COEX_ANT_TYPE_DETECTED) {
2243     + gl_bt_coexist.board_info.btdm_ant_num = ant_num;
2244     + if (rtlpriv->cfg->mod_params->ant_sel == 1)
2245     + gl_bt_coexist.board_info.btdm_ant_pos =
2246     + BTC_ANTENNA_AT_AUX_PORT;
2247     + else
2248     + gl_bt_coexist.board_info.btdm_ant_pos =
2249     + BTC_ANTENNA_AT_MAIN_PORT;
2250     }
2251     }
2252    
2253     diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
2254     index 0a903ea179ef..f41ca57dd8a7 100644
2255     --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
2256     +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
2257     @@ -535,7 +535,7 @@ void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version);
2258     void exhalbtc_update_min_bt_rssi(char bt_rssi);
2259     void exhalbtc_set_bt_exist(bool bt_exist);
2260     void exhalbtc_set_chip_type(u8 chip_type);
2261     -void exhalbtc_set_ant_num(u8 type, u8 ant_num);
2262     +void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num);
2263     void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist);
2264     void exhalbtc_signal_compensation(struct btc_coexist *btcoexist,
2265     u8 *rssi_wifi, u8 *rssi_bt);
2266     diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
2267     index b9b0cb7af8ea..d3fd9211b3a4 100644
2268     --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
2269     +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
2270     @@ -72,7 +72,10 @@ void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
2271     __func__, bt_type);
2272     exhalbtc_set_chip_type(bt_type);
2273    
2274     - exhalbtc_set_ant_num(BT_COEX_ANT_TYPE_PG, ant_num);
2275     + if (rtlpriv->cfg->mod_params->ant_sel == 1)
2276     + exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_DETECTED, 1);
2277     + else
2278     + exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num);
2279     }
2280    
2281     void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)
2282     diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
2283     index 7f471bff435c..5b4048041147 100644
2284     --- a/drivers/net/wireless/realtek/rtlwifi/pci.c
2285     +++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
2286     @@ -1573,7 +1573,7 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
2287     true,
2288     HW_DESC_TXBUFF_ADDR),
2289     skb->len, PCI_DMA_TODEVICE);
2290     - kfree_skb(skb);
2291     + dev_kfree_skb_irq(skb);
2292     ring->idx = (ring->idx + 1) % ring->entries;
2293     }
2294     ring->idx = 0;
2295     diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
2296     index c983d2fe147f..5a3df9198ddf 100644
2297     --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
2298     +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
2299     @@ -2684,6 +2684,7 @@ void rtl8723be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw,
2300     bool auto_load_fail, u8 *hwinfo)
2301     {
2302     struct rtl_priv *rtlpriv = rtl_priv(hw);
2303     + struct rtl_mod_params *mod_params = rtlpriv->cfg->mod_params;
2304     u8 value;
2305     u32 tmpu_32;
2306    
2307     @@ -2702,6 +2703,10 @@ void rtl8723be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw,
2308     rtlpriv->btcoexist.btc_info.ant_num = ANT_X2;
2309     }
2310    
2311     + /* override ant_num / ant_path */
2312     + if (mod_params->ant_sel)
2313     + rtlpriv->btcoexist.btc_info.ant_num =
2314     + (mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1);
2315     }
2316    
2317     void rtl8723be_bt_reg_init(struct ieee80211_hw *hw)
2318     diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
2319     index a78eaeda0008..2101793438ed 100644
2320     --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
2321     +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
2322     @@ -273,6 +273,7 @@ static struct rtl_mod_params rtl8723be_mod_params = {
2323     .msi_support = false,
2324     .disable_watchdog = false,
2325     .debug = DBG_EMERG,
2326     + .ant_sel = 0,
2327     };
2328    
2329     static struct rtl_hal_cfg rtl8723be_hal_cfg = {
2330     @@ -394,6 +395,7 @@ module_param_named(fwlps, rtl8723be_mod_params.fwctrl_lps, bool, 0444);
2331     module_param_named(msi, rtl8723be_mod_params.msi_support, bool, 0444);
2332     module_param_named(disable_watchdog, rtl8723be_mod_params.disable_watchdog,
2333     bool, 0444);
2334     +module_param_named(ant_sel, rtl8723be_mod_params.ant_sel, int, 0444);
2335     MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n");
2336     MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n");
2337     MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n");
2338     @@ -402,6 +404,7 @@ MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 0)\n");
2339     MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)");
2340     MODULE_PARM_DESC(disable_watchdog,
2341     "Set to 1 to disable the watchdog (default 0)\n");
2342     +MODULE_PARM_DESC(ant_sel, "Set to 1 or 2 to force antenna number (default 0)\n");
2343    
2344     static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume);
2345    
2346     diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h
2347     index 4544752a2ba8..b6faf624480e 100644
2348     --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
2349     +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
2350     @@ -2252,6 +2252,9 @@ struct rtl_mod_params {
2351    
2352     /* default 0: 1 means do not disable interrupts */
2353     bool int_clear;
2354     +
2355     + /* select antenna */
2356     + int ant_sel;
2357     };
2358    
2359     struct rtl_hal_usbint_cfg {
2360     diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
2361     index 7aafb5fb9336..9757cf9037a2 100644
2362     --- a/drivers/pci/probe.c
2363     +++ b/drivers/pci/probe.c
2364     @@ -179,9 +179,6 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
2365     u16 orig_cmd;
2366     struct pci_bus_region region, inverted_region;
2367    
2368     - if (dev->non_compliant_bars)
2369     - return 0;
2370     -
2371     mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
2372    
2373     /* No printks while decoding is disabled! */
2374     @@ -322,6 +319,9 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
2375     {
2376     unsigned int pos, reg;
2377    
2378     + if (dev->non_compliant_bars)
2379     + return;
2380     +
2381     for (pos = 0; pos < howmany; pos++) {
2382     struct resource *res = &dev->resource[pos];
2383     reg = PCI_BASE_ADDRESS_0 + (pos << 2);
2384     diff --git a/drivers/pinctrl/samsung/pinctrl-exynos5440.c b/drivers/pinctrl/samsung/pinctrl-exynos5440.c
2385     index 82dc109f7ed4..3149a877c51f 100644
2386     --- a/drivers/pinctrl/samsung/pinctrl-exynos5440.c
2387     +++ b/drivers/pinctrl/samsung/pinctrl-exynos5440.c
2388     @@ -107,6 +107,7 @@ struct exynos5440_pmx_func {
2389     * @nr_groups: number of pin groups available.
2390     * @pmx_functions: list of pin functions parsed from device tree.
2391     * @nr_functions: number of pin functions available.
2392     + * @range: gpio range to register with pinctrl
2393     */
2394     struct exynos5440_pinctrl_priv_data {
2395     void __iomem *reg_base;
2396     @@ -117,6 +118,7 @@ struct exynos5440_pinctrl_priv_data {
2397     unsigned int nr_groups;
2398     const struct exynos5440_pmx_func *pmx_functions;
2399     unsigned int nr_functions;
2400     + struct pinctrl_gpio_range range;
2401     };
2402    
2403     /**
2404     @@ -742,7 +744,6 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev,
2405     struct pinctrl_desc *ctrldesc;
2406     struct pinctrl_dev *pctl_dev;
2407     struct pinctrl_pin_desc *pindesc, *pdesc;
2408     - struct pinctrl_gpio_range grange;
2409     char *pin_names;
2410     int pin, ret;
2411    
2412     @@ -794,12 +795,12 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev,
2413     return PTR_ERR(pctl_dev);
2414     }
2415    
2416     - grange.name = "exynos5440-pctrl-gpio-range";
2417     - grange.id = 0;
2418     - grange.base = 0;
2419     - grange.npins = EXYNOS5440_MAX_PINS;
2420     - grange.gc = priv->gc;
2421     - pinctrl_add_gpio_range(pctl_dev, &grange);
2422     + priv->range.name = "exynos5440-pctrl-gpio-range";
2423     + priv->range.id = 0;
2424     + priv->range.base = 0;
2425     + priv->range.npins = EXYNOS5440_MAX_PINS;
2426     + priv->range.gc = priv->gc;
2427     + pinctrl_add_gpio_range(pctl_dev, &priv->range);
2428     return 0;
2429     }
2430    
2431     diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
2432     index d044f3f273be..467773033a20 100644
2433     --- a/drivers/scsi/aacraid/aacraid.h
2434     +++ b/drivers/scsi/aacraid/aacraid.h
2435     @@ -29,6 +29,7 @@ enum {
2436     #define AAC_INT_MODE_MSI (1<<1)
2437     #define AAC_INT_MODE_AIF (1<<2)
2438     #define AAC_INT_MODE_SYNC (1<<3)
2439     +#define AAC_INT_MODE_MSIX (1<<16)
2440    
2441     #define AAC_INT_ENABLE_TYPE1_INTX 0xfffffffb
2442     #define AAC_INT_ENABLE_TYPE1_MSIX 0xfffffffa
2443     diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
2444     index 0e954e37f0b5..0d351cd3191b 100644
2445     --- a/drivers/scsi/aacraid/comminit.c
2446     +++ b/drivers/scsi/aacraid/comminit.c
2447     @@ -37,6 +37,7 @@
2448     #include <linux/spinlock.h>
2449     #include <linux/slab.h>
2450     #include <linux/blkdev.h>
2451     +#include <linux/delay.h>
2452     #include <linux/completion.h>
2453     #include <linux/mm.h>
2454     #include <scsi/scsi_host.h>
2455     @@ -47,6 +48,20 @@ struct aac_common aac_config = {
2456     .irq_mod = 1
2457     };
2458    
2459     +static inline int aac_is_msix_mode(struct aac_dev *dev)
2460     +{
2461     + u32 status;
2462     +
2463     + status = src_readl(dev, MUnit.OMR);
2464     + return (status & AAC_INT_MODE_MSIX);
2465     +}
2466     +
2467     +static inline void aac_change_to_intx(struct aac_dev *dev)
2468     +{
2469     + aac_src_access_devreg(dev, AAC_DISABLE_MSIX);
2470     + aac_src_access_devreg(dev, AAC_ENABLE_INTX);
2471     +}
2472     +
2473     static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long commsize, unsigned long commalign)
2474     {
2475     unsigned char *base;
2476     @@ -425,6 +440,15 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
2477     dev->comm_interface = AAC_COMM_PRODUCER;
2478     dev->raw_io_interface = dev->raw_io_64 = 0;
2479    
2480     +
2481     + /*
2482     + * Enable INTX mode, if not done already Enabled
2483     + */
2484     + if (aac_is_msix_mode(dev)) {
2485     + aac_change_to_intx(dev);
2486     + dev_info(&dev->pdev->dev, "Changed firmware to INTX mode");
2487     + }
2488     +
2489     if ((!aac_adapter_sync_cmd(dev, GET_ADAPTER_PROPERTIES,
2490     0, 0, 0, 0, 0, 0,
2491     status+0, status+1, status+2, status+3, NULL)) &&
2492     diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
2493     index 4cbf54928640..8c758c36fc70 100644
2494     --- a/drivers/scsi/aacraid/commsup.c
2495     +++ b/drivers/scsi/aacraid/commsup.c
2496     @@ -611,10 +611,10 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
2497     }
2498     return -EFAULT;
2499     }
2500     - /* We used to udelay() here but that absorbed
2501     - * a CPU when a timeout occured. Not very
2502     - * useful. */
2503     - cpu_relax();
2504     + /*
2505     + * Allow other processes / CPUS to use core
2506     + */
2507     + schedule();
2508     }
2509     } else if (down_interruptible(&fibptr->event_wait)) {
2510     /* Do nothing ... satisfy
2511     @@ -1970,6 +1970,10 @@ int aac_command_thread(void *data)
2512     if (difference <= 0)
2513     difference = 1;
2514     set_current_state(TASK_INTERRUPTIBLE);
2515     +
2516     + if (kthread_should_stop())
2517     + break;
2518     +
2519     schedule_timeout(difference);
2520    
2521     if (kthread_should_stop())
2522     diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
2523     index 73190f5d2832..71d26c8e1b8f 100644
2524     --- a/drivers/tty/serial/ucc_uart.c
2525     +++ b/drivers/tty/serial/ucc_uart.c
2526     @@ -1478,6 +1478,9 @@ static const struct of_device_id ucc_uart_match[] = {
2527     .type = "serial",
2528     .compatible = "ucc_uart",
2529     },
2530     + {
2531     + .compatible = "fsl,t1040-ucc-uart",
2532     + },
2533     {},
2534     };
2535     MODULE_DEVICE_TABLE(of, ucc_uart_match);
2536     diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
2537     index 44367783f07a..83ec7b89d308 100644
2538     --- a/drivers/xen/events/events_base.c
2539     +++ b/drivers/xen/events/events_base.c
2540     @@ -487,7 +487,8 @@ static void eoi_pirq(struct irq_data *data)
2541     if (!VALID_EVTCHN(evtchn))
2542     return;
2543    
2544     - if (unlikely(irqd_is_setaffinity_pending(data))) {
2545     + if (unlikely(irqd_is_setaffinity_pending(data)) &&
2546     + likely(!irqd_irq_disabled(data))) {
2547     int masked = test_and_set_mask(evtchn);
2548    
2549     clear_evtchn(evtchn);
2550     @@ -1370,7 +1371,8 @@ static void ack_dynirq(struct irq_data *data)
2551     if (!VALID_EVTCHN(evtchn))
2552     return;
2553    
2554     - if (unlikely(irqd_is_setaffinity_pending(data))) {
2555     + if (unlikely(irqd_is_setaffinity_pending(data)) &&
2556     + likely(!irqd_irq_disabled(data))) {
2557     int masked = test_and_set_mask(evtchn);
2558    
2559     clear_evtchn(evtchn);
2560     diff --git a/fs/affs/super.c b/fs/affs/super.c
2561     index 5b50c4ca43a7..f90c535703ce 100644
2562     --- a/fs/affs/super.c
2563     +++ b/fs/affs/super.c
2564     @@ -528,7 +528,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
2565     char *prefix = NULL;
2566    
2567     new_opts = kstrdup(data, GFP_KERNEL);
2568     - if (!new_opts)
2569     + if (data && !new_opts)
2570     return -ENOMEM;
2571    
2572     pr_debug("%s(flags=0x%x,opts=\"%s\")\n", __func__, *flags, data);
2573     @@ -546,7 +546,8 @@ affs_remount(struct super_block *sb, int *flags, char *data)
2574     }
2575    
2576     flush_delayed_work(&sbi->sb_work);
2577     - replace_mount_options(sb, new_opts);
2578     + if (new_opts)
2579     + replace_mount_options(sb, new_opts);
2580    
2581     sbi->s_flags = mount_flags;
2582     sbi->s_mode = mode;
2583     diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
2584     index 53f2b98a69f3..5388207d2832 100644
2585     --- a/fs/ext4/ialloc.c
2586     +++ b/fs/ext4/ialloc.c
2587     @@ -1143,25 +1143,20 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
2588     unsigned long max_ino = le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count);
2589     ext4_group_t block_group;
2590     int bit;
2591     - struct buffer_head *bitmap_bh;
2592     + struct buffer_head *bitmap_bh = NULL;
2593     struct inode *inode = NULL;
2594     - long err = -EIO;
2595     + int err = -EFSCORRUPTED;
2596    
2597     - /* Error cases - e2fsck has already cleaned up for us */
2598     - if (ino > max_ino) {
2599     - ext4_warning(sb, "bad orphan ino %lu! e2fsck was run?", ino);
2600     - err = -EFSCORRUPTED;
2601     - goto error;
2602     - }
2603     + if (ino < EXT4_FIRST_INO(sb) || ino > max_ino)
2604     + goto bad_orphan;
2605    
2606     block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
2607     bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
2608     bitmap_bh = ext4_read_inode_bitmap(sb, block_group);
2609     if (IS_ERR(bitmap_bh)) {
2610     - err = PTR_ERR(bitmap_bh);
2611     - ext4_warning(sb, "inode bitmap error %ld for orphan %lu",
2612     - ino, err);
2613     - goto error;
2614     + ext4_error(sb, "inode bitmap error %ld for orphan %lu",
2615     + ino, PTR_ERR(bitmap_bh));
2616     + return (struct inode *) bitmap_bh;
2617     }
2618    
2619     /* Having the inode bit set should be a 100% indicator that this
2620     @@ -1172,15 +1167,21 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
2621     goto bad_orphan;
2622    
2623     inode = ext4_iget(sb, ino);
2624     - if (IS_ERR(inode))
2625     - goto iget_failed;
2626     + if (IS_ERR(inode)) {
2627     + err = PTR_ERR(inode);
2628     + ext4_error(sb, "couldn't read orphan inode %lu (err %d)",
2629     + ino, err);
2630     + return inode;
2631     + }
2632    
2633     /*
2634     - * If the orphans has i_nlinks > 0 then it should be able to be
2635     - * truncated, otherwise it won't be removed from the orphan list
2636     - * during processing and an infinite loop will result.
2637     + * If the orphans has i_nlinks > 0 then it should be able to
2638     + * be truncated, otherwise it won't be removed from the orphan
2639     + * list during processing and an infinite loop will result.
2640     + * Similarly, it must not be a bad inode.
2641     */
2642     - if (inode->i_nlink && !ext4_can_truncate(inode))
2643     + if ((inode->i_nlink && !ext4_can_truncate(inode)) ||
2644     + is_bad_inode(inode))
2645     goto bad_orphan;
2646    
2647     if (NEXT_ORPHAN(inode) > max_ino)
2648     @@ -1188,29 +1189,25 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
2649     brelse(bitmap_bh);
2650     return inode;
2651    
2652     -iget_failed:
2653     - err = PTR_ERR(inode);
2654     - inode = NULL;
2655     bad_orphan:
2656     - ext4_warning(sb, "bad orphan inode %lu! e2fsck was run?", ino);
2657     - printk(KERN_WARNING "ext4_test_bit(bit=%d, block=%llu) = %d\n",
2658     - bit, (unsigned long long)bitmap_bh->b_blocknr,
2659     - ext4_test_bit(bit, bitmap_bh->b_data));
2660     - printk(KERN_WARNING "inode=%p\n", inode);
2661     + ext4_error(sb, "bad orphan inode %lu", ino);
2662     + if (bitmap_bh)
2663     + printk(KERN_ERR "ext4_test_bit(bit=%d, block=%llu) = %d\n",
2664     + bit, (unsigned long long)bitmap_bh->b_blocknr,
2665     + ext4_test_bit(bit, bitmap_bh->b_data));
2666     if (inode) {
2667     - printk(KERN_WARNING "is_bad_inode(inode)=%d\n",
2668     + printk(KERN_ERR "is_bad_inode(inode)=%d\n",
2669     is_bad_inode(inode));
2670     - printk(KERN_WARNING "NEXT_ORPHAN(inode)=%u\n",
2671     + printk(KERN_ERR "NEXT_ORPHAN(inode)=%u\n",
2672     NEXT_ORPHAN(inode));
2673     - printk(KERN_WARNING "max_ino=%lu\n", max_ino);
2674     - printk(KERN_WARNING "i_nlink=%u\n", inode->i_nlink);
2675     + printk(KERN_ERR "max_ino=%lu\n", max_ino);
2676     + printk(KERN_ERR "i_nlink=%u\n", inode->i_nlink);
2677     /* Avoid freeing blocks if we got a bad deleted inode */
2678     if (inode->i_nlink == 0)
2679     inode->i_blocks = 0;
2680     iput(inode);
2681     }
2682     brelse(bitmap_bh);
2683     -error:
2684     return ERR_PTR(err);
2685     }
2686    
2687     diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
2688     index 61eaf74dca37..cf734170daa9 100644
2689     --- a/fs/ext4/mballoc.c
2690     +++ b/fs/ext4/mballoc.c
2691     @@ -1259,6 +1259,7 @@ static void ext4_mb_unload_buddy(struct ext4_buddy *e4b)
2692     static int mb_find_order_for_block(struct ext4_buddy *e4b, int block)
2693     {
2694     int order = 1;
2695     + int bb_incr = 1 << (e4b->bd_blkbits - 1);
2696     void *bb;
2697    
2698     BUG_ON(e4b->bd_bitmap == e4b->bd_buddy);
2699     @@ -1271,7 +1272,8 @@ static int mb_find_order_for_block(struct ext4_buddy *e4b, int block)
2700     /* this block is part of buddy of order 'order' */
2701     return order;
2702     }
2703     - bb += 1 << (e4b->bd_blkbits - order);
2704     + bb += bb_incr;
2705     + bb_incr >>= 1;
2706     order++;
2707     }
2708     return 0;
2709     @@ -2576,7 +2578,7 @@ int ext4_mb_init(struct super_block *sb)
2710     {
2711     struct ext4_sb_info *sbi = EXT4_SB(sb);
2712     unsigned i, j;
2713     - unsigned offset;
2714     + unsigned offset, offset_incr;
2715     unsigned max;
2716     int ret;
2717    
2718     @@ -2605,11 +2607,13 @@ int ext4_mb_init(struct super_block *sb)
2719    
2720     i = 1;
2721     offset = 0;
2722     + offset_incr = 1 << (sb->s_blocksize_bits - 1);
2723     max = sb->s_blocksize << 2;
2724     do {
2725     sbi->s_mb_offsets[i] = offset;
2726     sbi->s_mb_maxs[i] = max;
2727     - offset += 1 << (sb->s_blocksize_bits - i);
2728     + offset += offset_incr;
2729     + offset_incr = offset_incr >> 1;
2730     max = max >> 1;
2731     i++;
2732     } while (i <= sb->s_blocksize_bits + 1);
2733     diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
2734     index a969ab39f302..91bf36f22dbf 100644
2735     --- a/fs/ext4/namei.c
2736     +++ b/fs/ext4/namei.c
2737     @@ -2809,7 +2809,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
2738     * list entries can cause panics at unmount time.
2739     */
2740     mutex_lock(&sbi->s_orphan_lock);
2741     - list_del(&EXT4_I(inode)->i_orphan);
2742     + list_del_init(&EXT4_I(inode)->i_orphan);
2743     mutex_unlock(&sbi->s_orphan_lock);
2744     }
2745     }
2746     diff --git a/fs/pipe.c b/fs/pipe.c
2747     index 42cf8ddf0e55..ab8dad3ccb6a 100644
2748     --- a/fs/pipe.c
2749     +++ b/fs/pipe.c
2750     @@ -38,6 +38,12 @@ unsigned int pipe_max_size = 1048576;
2751     */
2752     unsigned int pipe_min_size = PAGE_SIZE;
2753    
2754     +/* Maximum allocatable pages per user. Hard limit is unset by default, soft
2755     + * matches default values.
2756     + */
2757     +unsigned long pipe_user_pages_hard;
2758     +unsigned long pipe_user_pages_soft = PIPE_DEF_BUFFERS * INR_OPEN_CUR;
2759     +
2760     /*
2761     * We use a start+len construction, which provides full use of the
2762     * allocated memory.
2763     @@ -583,20 +589,49 @@ pipe_fasync(int fd, struct file *filp, int on)
2764     return retval;
2765     }
2766    
2767     +static void account_pipe_buffers(struct pipe_inode_info *pipe,
2768     + unsigned long old, unsigned long new)
2769     +{
2770     + atomic_long_add(new - old, &pipe->user->pipe_bufs);
2771     +}
2772     +
2773     +static bool too_many_pipe_buffers_soft(struct user_struct *user)
2774     +{
2775     + return pipe_user_pages_soft &&
2776     + atomic_long_read(&user->pipe_bufs) >= pipe_user_pages_soft;
2777     +}
2778     +
2779     +static bool too_many_pipe_buffers_hard(struct user_struct *user)
2780     +{
2781     + return pipe_user_pages_hard &&
2782     + atomic_long_read(&user->pipe_bufs) >= pipe_user_pages_hard;
2783     +}
2784     +
2785     struct pipe_inode_info *alloc_pipe_info(void)
2786     {
2787     struct pipe_inode_info *pipe;
2788    
2789     pipe = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL);
2790     if (pipe) {
2791     - pipe->bufs = kzalloc(sizeof(struct pipe_buffer) * PIPE_DEF_BUFFERS, GFP_KERNEL);
2792     + unsigned long pipe_bufs = PIPE_DEF_BUFFERS;
2793     + struct user_struct *user = get_current_user();
2794     +
2795     + if (!too_many_pipe_buffers_hard(user)) {
2796     + if (too_many_pipe_buffers_soft(user))
2797     + pipe_bufs = 1;
2798     + pipe->bufs = kzalloc(sizeof(struct pipe_buffer) * pipe_bufs, GFP_KERNEL);
2799     + }
2800     +
2801     if (pipe->bufs) {
2802     init_waitqueue_head(&pipe->wait);
2803     pipe->r_counter = pipe->w_counter = 1;
2804     - pipe->buffers = PIPE_DEF_BUFFERS;
2805     + pipe->buffers = pipe_bufs;
2806     + pipe->user = user;
2807     + account_pipe_buffers(pipe, 0, pipe_bufs);
2808     mutex_init(&pipe->mutex);
2809     return pipe;
2810     }
2811     + free_uid(user);
2812     kfree(pipe);
2813     }
2814    
2815     @@ -607,6 +642,8 @@ void free_pipe_info(struct pipe_inode_info *pipe)
2816     {
2817     int i;
2818    
2819     + account_pipe_buffers(pipe, pipe->buffers, 0);
2820     + free_uid(pipe->user);
2821     for (i = 0; i < pipe->buffers; i++) {
2822     struct pipe_buffer *buf = pipe->bufs + i;
2823     if (buf->ops)
2824     @@ -998,6 +1035,7 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long nr_pages)
2825     memcpy(bufs + head, pipe->bufs, tail * sizeof(struct pipe_buffer));
2826     }
2827    
2828     + account_pipe_buffers(pipe, pipe->buffers, nr_pages);
2829     pipe->curbuf = 0;
2830     kfree(pipe->bufs);
2831     pipe->bufs = bufs;
2832     @@ -1069,6 +1107,11 @@ long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
2833     if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) {
2834     ret = -EPERM;
2835     goto out;
2836     + } else if ((too_many_pipe_buffers_hard(pipe->user) ||
2837     + too_many_pipe_buffers_soft(pipe->user)) &&
2838     + !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) {
2839     + ret = -EPERM;
2840     + goto out;
2841     }
2842     ret = pipe_set_size(pipe, nr_pages);
2843     break;
2844     diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
2845     index 3479294c1d58..e1e7fe3b5424 100644
2846     --- a/fs/xfs/libxfs/xfs_alloc.c
2847     +++ b/fs/xfs/libxfs/xfs_alloc.c
2848     @@ -535,6 +535,7 @@ xfs_agfl_write_verify(
2849     }
2850    
2851     const struct xfs_buf_ops xfs_agfl_buf_ops = {
2852     + .name = "xfs_agfl",
2853     .verify_read = xfs_agfl_read_verify,
2854     .verify_write = xfs_agfl_write_verify,
2855     };
2856     @@ -2339,6 +2340,7 @@ xfs_agf_write_verify(
2857     }
2858    
2859     const struct xfs_buf_ops xfs_agf_buf_ops = {
2860     + .name = "xfs_agf",
2861     .verify_read = xfs_agf_read_verify,
2862     .verify_write = xfs_agf_write_verify,
2863     };
2864     diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
2865     index 90de071dd4c2..eb8bbfe85484 100644
2866     --- a/fs/xfs/libxfs/xfs_alloc_btree.c
2867     +++ b/fs/xfs/libxfs/xfs_alloc_btree.c
2868     @@ -379,6 +379,7 @@ xfs_allocbt_write_verify(
2869     }
2870    
2871     const struct xfs_buf_ops xfs_allocbt_buf_ops = {
2872     + .name = "xfs_allocbt",
2873     .verify_read = xfs_allocbt_read_verify,
2874     .verify_write = xfs_allocbt_write_verify,
2875     };
2876     diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
2877     index aa187f7ba2dd..01a5ecfedfcf 100644
2878     --- a/fs/xfs/libxfs/xfs_attr_leaf.c
2879     +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
2880     @@ -328,6 +328,7 @@ xfs_attr3_leaf_read_verify(
2881     }
2882    
2883     const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = {
2884     + .name = "xfs_attr3_leaf",
2885     .verify_read = xfs_attr3_leaf_read_verify,
2886     .verify_write = xfs_attr3_leaf_write_verify,
2887     };
2888     diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
2889     index 5ab95ffa4ae9..f3ed9bf0b065 100644
2890     --- a/fs/xfs/libxfs/xfs_attr_remote.c
2891     +++ b/fs/xfs/libxfs/xfs_attr_remote.c
2892     @@ -201,6 +201,7 @@ xfs_attr3_rmt_write_verify(
2893     }
2894    
2895     const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = {
2896     + .name = "xfs_attr3_rmt",
2897     .verify_read = xfs_attr3_rmt_read_verify,
2898     .verify_write = xfs_attr3_rmt_write_verify,
2899     };
2900     diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
2901     index 6b0cf6546a82..1637c37bfbaa 100644
2902     --- a/fs/xfs/libxfs/xfs_bmap_btree.c
2903     +++ b/fs/xfs/libxfs/xfs_bmap_btree.c
2904     @@ -720,6 +720,7 @@ xfs_bmbt_write_verify(
2905     }
2906    
2907     const struct xfs_buf_ops xfs_bmbt_buf_ops = {
2908     + .name = "xfs_bmbt",
2909     .verify_read = xfs_bmbt_read_verify,
2910     .verify_write = xfs_bmbt_write_verify,
2911     };
2912     diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
2913     index e89a0f8f827c..097bf7717d80 100644
2914     --- a/fs/xfs/libxfs/xfs_da_btree.c
2915     +++ b/fs/xfs/libxfs/xfs_da_btree.c
2916     @@ -245,6 +245,7 @@ xfs_da3_node_read_verify(
2917     }
2918    
2919     const struct xfs_buf_ops xfs_da3_node_buf_ops = {
2920     + .name = "xfs_da3_node",
2921     .verify_read = xfs_da3_node_read_verify,
2922     .verify_write = xfs_da3_node_write_verify,
2923     };
2924     diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
2925     index 9c10e2b8cfcb..aa17cb788946 100644
2926     --- a/fs/xfs/libxfs/xfs_dir2_block.c
2927     +++ b/fs/xfs/libxfs/xfs_dir2_block.c
2928     @@ -123,6 +123,7 @@ xfs_dir3_block_write_verify(
2929     }
2930    
2931     const struct xfs_buf_ops xfs_dir3_block_buf_ops = {
2932     + .name = "xfs_dir3_block",
2933     .verify_read = xfs_dir3_block_read_verify,
2934     .verify_write = xfs_dir3_block_write_verify,
2935     };
2936     diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
2937     index af71a84f343c..725fc7841fde 100644
2938     --- a/fs/xfs/libxfs/xfs_dir2_data.c
2939     +++ b/fs/xfs/libxfs/xfs_dir2_data.c
2940     @@ -305,11 +305,13 @@ xfs_dir3_data_write_verify(
2941     }
2942    
2943     const struct xfs_buf_ops xfs_dir3_data_buf_ops = {
2944     + .name = "xfs_dir3_data",
2945     .verify_read = xfs_dir3_data_read_verify,
2946     .verify_write = xfs_dir3_data_write_verify,
2947     };
2948    
2949     static const struct xfs_buf_ops xfs_dir3_data_reada_buf_ops = {
2950     + .name = "xfs_dir3_data_reada",
2951     .verify_read = xfs_dir3_data_reada_verify,
2952     .verify_write = xfs_dir3_data_write_verify,
2953     };
2954     diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
2955     index 3923e1f94697..b887fb2a2bcf 100644
2956     --- a/fs/xfs/libxfs/xfs_dir2_leaf.c
2957     +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
2958     @@ -245,11 +245,13 @@ xfs_dir3_leafn_write_verify(
2959     }
2960    
2961     const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops = {
2962     + .name = "xfs_dir3_leaf1",
2963     .verify_read = xfs_dir3_leaf1_read_verify,
2964     .verify_write = xfs_dir3_leaf1_write_verify,
2965     };
2966    
2967     const struct xfs_buf_ops xfs_dir3_leafn_buf_ops = {
2968     + .name = "xfs_dir3_leafn",
2969     .verify_read = xfs_dir3_leafn_read_verify,
2970     .verify_write = xfs_dir3_leafn_write_verify,
2971     };
2972     diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
2973     index 70b0cb2fd556..63ee03db796c 100644
2974     --- a/fs/xfs/libxfs/xfs_dir2_node.c
2975     +++ b/fs/xfs/libxfs/xfs_dir2_node.c
2976     @@ -150,6 +150,7 @@ xfs_dir3_free_write_verify(
2977     }
2978    
2979     const struct xfs_buf_ops xfs_dir3_free_buf_ops = {
2980     + .name = "xfs_dir3_free",
2981     .verify_read = xfs_dir3_free_read_verify,
2982     .verify_write = xfs_dir3_free_write_verify,
2983     };
2984     diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
2985     index 5331b7f0460c..3cc3cf767474 100644
2986     --- a/fs/xfs/libxfs/xfs_dquot_buf.c
2987     +++ b/fs/xfs/libxfs/xfs_dquot_buf.c
2988     @@ -54,7 +54,7 @@ xfs_dqcheck(
2989     xfs_dqid_t id,
2990     uint type, /* used only when IO_dorepair is true */
2991     uint flags,
2992     - char *str)
2993     + const char *str)
2994     {
2995     xfs_dqblk_t *d = (xfs_dqblk_t *)ddq;
2996     int errs = 0;
2997     @@ -207,7 +207,8 @@ xfs_dquot_buf_verify_crc(
2998     STATIC bool
2999     xfs_dquot_buf_verify(
3000     struct xfs_mount *mp,
3001     - struct xfs_buf *bp)
3002     + struct xfs_buf *bp,
3003     + int warn)
3004     {
3005     struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr;
3006     xfs_dqid_t id = 0;
3007     @@ -240,8 +241,7 @@ xfs_dquot_buf_verify(
3008     if (i == 0)
3009     id = be32_to_cpu(ddq->d_id);
3010    
3011     - error = xfs_dqcheck(mp, ddq, id + i, 0, XFS_QMOPT_DOWARN,
3012     - "xfs_dquot_buf_verify");
3013     + error = xfs_dqcheck(mp, ddq, id + i, 0, warn, __func__);
3014     if (error)
3015     return false;
3016     }
3017     @@ -256,7 +256,7 @@ xfs_dquot_buf_read_verify(
3018    
3019     if (!xfs_dquot_buf_verify_crc(mp, bp))
3020     xfs_buf_ioerror(bp, -EFSBADCRC);
3021     - else if (!xfs_dquot_buf_verify(mp, bp))
3022     + else if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN))
3023     xfs_buf_ioerror(bp, -EFSCORRUPTED);
3024    
3025     if (bp->b_error)
3026     @@ -264,6 +264,25 @@ xfs_dquot_buf_read_verify(
3027     }
3028    
3029     /*
3030     + * readahead errors are silent and simply leave the buffer as !done so a real
3031     + * read will then be run with the xfs_dquot_buf_ops verifier. See
3032     + * xfs_inode_buf_verify() for why we use EIO and ~XBF_DONE here rather than
3033     + * reporting the failure.
3034     + */
3035     +static void
3036     +xfs_dquot_buf_readahead_verify(
3037     + struct xfs_buf *bp)
3038     +{
3039     + struct xfs_mount *mp = bp->b_target->bt_mount;
3040     +
3041     + if (!xfs_dquot_buf_verify_crc(mp, bp) ||
3042     + !xfs_dquot_buf_verify(mp, bp, 0)) {
3043     + xfs_buf_ioerror(bp, -EIO);
3044     + bp->b_flags &= ~XBF_DONE;
3045     + }
3046     +}
3047     +
3048     +/*
3049     * we don't calculate the CRC here as that is done when the dquot is flushed to
3050     * the buffer after the update is done. This ensures that the dquot in the
3051     * buffer always has an up-to-date CRC value.
3052     @@ -274,7 +293,7 @@ xfs_dquot_buf_write_verify(
3053     {
3054     struct xfs_mount *mp = bp->b_target->bt_mount;
3055    
3056     - if (!xfs_dquot_buf_verify(mp, bp)) {
3057     + if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN)) {
3058     xfs_buf_ioerror(bp, -EFSCORRUPTED);
3059     xfs_verifier_error(bp);
3060     return;
3061     @@ -282,7 +301,13 @@ xfs_dquot_buf_write_verify(
3062     }
3063    
3064     const struct xfs_buf_ops xfs_dquot_buf_ops = {
3065     + .name = "xfs_dquot",
3066     .verify_read = xfs_dquot_buf_read_verify,
3067     .verify_write = xfs_dquot_buf_write_verify,
3068     };
3069    
3070     +const struct xfs_buf_ops xfs_dquot_buf_ra_ops = {
3071     + .name = "xfs_dquot_ra",
3072     + .verify_read = xfs_dquot_buf_readahead_verify,
3073     + .verify_write = xfs_dquot_buf_write_verify,
3074     +};
3075     diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
3076     index 70c1db99f6a7..66d702e6b9ff 100644
3077     --- a/fs/xfs/libxfs/xfs_ialloc.c
3078     +++ b/fs/xfs/libxfs/xfs_ialloc.c
3079     @@ -2572,6 +2572,7 @@ xfs_agi_write_verify(
3080     }
3081    
3082     const struct xfs_buf_ops xfs_agi_buf_ops = {
3083     + .name = "xfs_agi",
3084     .verify_read = xfs_agi_read_verify,
3085     .verify_write = xfs_agi_write_verify,
3086     };
3087     diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
3088     index f39b285beb19..6dd44f9ea727 100644
3089     --- a/fs/xfs/libxfs/xfs_ialloc_btree.c
3090     +++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
3091     @@ -304,6 +304,7 @@ xfs_inobt_write_verify(
3092     }
3093    
3094     const struct xfs_buf_ops xfs_inobt_buf_ops = {
3095     + .name = "xfs_inobt",
3096     .verify_read = xfs_inobt_read_verify,
3097     .verify_write = xfs_inobt_write_verify,
3098     };
3099     diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
3100     index 65485cfc4ade..1aabfda669b0 100644
3101     --- a/fs/xfs/libxfs/xfs_inode_buf.c
3102     +++ b/fs/xfs/libxfs/xfs_inode_buf.c
3103     @@ -68,6 +68,8 @@ xfs_inobp_check(
3104     * recovery and we don't get unnecssary panics on debug kernels. We use EIO here
3105     * because all we want to do is say readahead failed; there is no-one to report
3106     * the error to, so this will distinguish it from a non-ra verifier failure.
3107     + * Changes to this readahead error behavour also need to be reflected in
3108     + * xfs_dquot_buf_readahead_verify().
3109     */
3110     static void
3111     xfs_inode_buf_verify(
3112     @@ -134,11 +136,13 @@ xfs_inode_buf_write_verify(
3113     }
3114    
3115     const struct xfs_buf_ops xfs_inode_buf_ops = {
3116     + .name = "xfs_inode",
3117     .verify_read = xfs_inode_buf_read_verify,
3118     .verify_write = xfs_inode_buf_write_verify,
3119     };
3120    
3121     const struct xfs_buf_ops xfs_inode_buf_ra_ops = {
3122     + .name = "xxfs_inode_ra",
3123     .verify_read = xfs_inode_buf_readahead_verify,
3124     .verify_write = xfs_inode_buf_write_verify,
3125     };
3126     diff --git a/fs/xfs/libxfs/xfs_quota_defs.h b/fs/xfs/libxfs/xfs_quota_defs.h
3127     index 1b0a08379759..f51078f1e92a 100644
3128     --- a/fs/xfs/libxfs/xfs_quota_defs.h
3129     +++ b/fs/xfs/libxfs/xfs_quota_defs.h
3130     @@ -153,7 +153,7 @@ typedef __uint16_t xfs_qwarncnt_t;
3131     #define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
3132    
3133     extern int xfs_dqcheck(struct xfs_mount *mp, xfs_disk_dquot_t *ddq,
3134     - xfs_dqid_t id, uint type, uint flags, char *str);
3135     + xfs_dqid_t id, uint type, uint flags, const char *str);
3136     extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
3137    
3138     #endif /* __XFS_QUOTA_H__ */
3139     diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
3140     index a0b071d881a0..8a53eaa349f4 100644
3141     --- a/fs/xfs/libxfs/xfs_sb.c
3142     +++ b/fs/xfs/libxfs/xfs_sb.c
3143     @@ -679,11 +679,13 @@ xfs_sb_write_verify(
3144     }
3145    
3146     const struct xfs_buf_ops xfs_sb_buf_ops = {
3147     + .name = "xfs_sb",
3148     .verify_read = xfs_sb_read_verify,
3149     .verify_write = xfs_sb_write_verify,
3150     };
3151    
3152     const struct xfs_buf_ops xfs_sb_quiet_buf_ops = {
3153     + .name = "xfs_sb_quiet",
3154     .verify_read = xfs_sb_quiet_read_verify,
3155     .verify_write = xfs_sb_write_verify,
3156     };
3157     diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
3158     index 5be529707903..15c3ceb845b9 100644
3159     --- a/fs/xfs/libxfs/xfs_shared.h
3160     +++ b/fs/xfs/libxfs/xfs_shared.h
3161     @@ -49,6 +49,7 @@ extern const struct xfs_buf_ops xfs_inobt_buf_ops;
3162     extern const struct xfs_buf_ops xfs_inode_buf_ops;
3163     extern const struct xfs_buf_ops xfs_inode_buf_ra_ops;
3164     extern const struct xfs_buf_ops xfs_dquot_buf_ops;
3165     +extern const struct xfs_buf_ops xfs_dquot_buf_ra_ops;
3166     extern const struct xfs_buf_ops xfs_sb_buf_ops;
3167     extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;
3168     extern const struct xfs_buf_ops xfs_symlink_buf_ops;
3169     diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
3170     index cb6fd20a4d3d..2e2c6716b623 100644
3171     --- a/fs/xfs/libxfs/xfs_symlink_remote.c
3172     +++ b/fs/xfs/libxfs/xfs_symlink_remote.c
3173     @@ -168,6 +168,7 @@ xfs_symlink_write_verify(
3174     }
3175    
3176     const struct xfs_buf_ops xfs_symlink_buf_ops = {
3177     + .name = "xfs_symlink",
3178     .verify_read = xfs_symlink_read_verify,
3179     .verify_write = xfs_symlink_write_verify,
3180     };
3181     diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
3182     index c79b717d9b88..c75721acd867 100644
3183     --- a/fs/xfs/xfs_buf.h
3184     +++ b/fs/xfs/xfs_buf.h
3185     @@ -132,6 +132,7 @@ struct xfs_buf_map {
3186     struct xfs_buf_map (map) = { .bm_bn = (blkno), .bm_len = (numblk) };
3187    
3188     struct xfs_buf_ops {
3189     + char *name;
3190     void (*verify_read)(struct xfs_buf *);
3191     void (*verify_write)(struct xfs_buf *);
3192     };
3193     diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
3194     index 74d0e5966ebc..88693a98fac5 100644
3195     --- a/fs/xfs/xfs_error.c
3196     +++ b/fs/xfs/xfs_error.c
3197     @@ -164,9 +164,9 @@ xfs_verifier_error(
3198     {
3199     struct xfs_mount *mp = bp->b_target->bt_mount;
3200    
3201     - xfs_alert(mp, "Metadata %s detected at %pF, block 0x%llx",
3202     + xfs_alert(mp, "Metadata %s detected at %pF, %s block 0x%llx",
3203     bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
3204     - __return_address, bp->b_bn);
3205     + __return_address, bp->b_ops->name, bp->b_bn);
3206    
3207     xfs_alert(mp, "Unmount and run xfs_repair");
3208    
3209     diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
3210     index ee3aaa0a5317..ca0d3eb44925 100644
3211     --- a/fs/xfs/xfs_fsops.c
3212     +++ b/fs/xfs/xfs_fsops.c
3213     @@ -243,8 +243,8 @@ xfs_growfs_data_private(
3214     agf->agf_roots[XFS_BTNUM_CNTi] = cpu_to_be32(XFS_CNT_BLOCK(mp));
3215     agf->agf_levels[XFS_BTNUM_BNOi] = cpu_to_be32(1);
3216     agf->agf_levels[XFS_BTNUM_CNTi] = cpu_to_be32(1);
3217     - agf->agf_flfirst = 0;
3218     - agf->agf_fllast = cpu_to_be32(XFS_AGFL_SIZE(mp) - 1);
3219     + agf->agf_flfirst = cpu_to_be32(1);
3220     + agf->agf_fllast = 0;
3221     agf->agf_flcount = 0;
3222     tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp);
3223     agf->agf_freeblks = cpu_to_be32(tmpsize);
3224     diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
3225     index 8ee393996b7d..f0ce28cd311d 100644
3226     --- a/fs/xfs/xfs_inode.c
3227     +++ b/fs/xfs/xfs_inode.c
3228     @@ -3220,13 +3220,14 @@ xfs_iflush_cluster(
3229     * We need to check under the i_flags_lock for a valid inode
3230     * here. Skip it if it is not valid or the wrong inode.
3231     */
3232     - spin_lock(&ip->i_flags_lock);
3233     - if (!ip->i_ino ||
3234     + spin_lock(&iq->i_flags_lock);
3235     + if (!iq->i_ino ||
3236     + __xfs_iflags_test(iq, XFS_ISTALE) ||
3237     (XFS_INO_TO_AGINO(mp, iq->i_ino) & mask) != first_index) {
3238     - spin_unlock(&ip->i_flags_lock);
3239     + spin_unlock(&iq->i_flags_lock);
3240     continue;
3241     }
3242     - spin_unlock(&ip->i_flags_lock);
3243     + spin_unlock(&iq->i_flags_lock);
3244    
3245     /*
3246     * Do an un-protected check to see if the inode is dirty and
3247     @@ -3342,7 +3343,7 @@ xfs_iflush(
3248     struct xfs_buf **bpp)
3249     {
3250     struct xfs_mount *mp = ip->i_mount;
3251     - struct xfs_buf *bp;
3252     + struct xfs_buf *bp = NULL;
3253     struct xfs_dinode *dip;
3254     int error;
3255    
3256     @@ -3384,14 +3385,22 @@ xfs_iflush(
3257     }
3258    
3259     /*
3260     - * Get the buffer containing the on-disk inode.
3261     + * Get the buffer containing the on-disk inode. We are doing a try-lock
3262     + * operation here, so we may get an EAGAIN error. In that case, we
3263     + * simply want to return with the inode still dirty.
3264     + *
3265     + * If we get any other error, we effectively have a corruption situation
3266     + * and we cannot flush the inode, so we treat it the same as failing
3267     + * xfs_iflush_int().
3268     */
3269     error = xfs_imap_to_bp(mp, NULL, &ip->i_imap, &dip, &bp, XBF_TRYLOCK,
3270     0);
3271     - if (error || !bp) {
3272     + if (error == -EAGAIN) {
3273     xfs_ifunlock(ip);
3274     return error;
3275     }
3276     + if (error)
3277     + goto corrupt_out;
3278    
3279     /*
3280     * First flush out the inode that xfs_iflush was called with.
3281     @@ -3419,7 +3428,8 @@ xfs_iflush(
3282     return 0;
3283    
3284     corrupt_out:
3285     - xfs_buf_relse(bp);
3286     + if (bp)
3287     + xfs_buf_relse(bp);
3288     xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
3289     cluster_corrupt_out:
3290     error = -EFSCORRUPTED;
3291     diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
3292     index c5ecaacdd218..5991cdcb9040 100644
3293     --- a/fs/xfs/xfs_log_recover.c
3294     +++ b/fs/xfs/xfs_log_recover.c
3295     @@ -3204,6 +3204,7 @@ xlog_recover_dquot_ra_pass2(
3296     struct xfs_disk_dquot *recddq;
3297     struct xfs_dq_logformat *dq_f;
3298     uint type;
3299     + int len;
3300    
3301    
3302     if (mp->m_qflags == 0)
3303     @@ -3224,8 +3225,12 @@ xlog_recover_dquot_ra_pass2(
3304     ASSERT(dq_f);
3305     ASSERT(dq_f->qlf_len == 1);
3306    
3307     - xfs_buf_readahead(mp->m_ddev_targp, dq_f->qlf_blkno,
3308     - XFS_FSB_TO_BB(mp, dq_f->qlf_len), NULL);
3309     + len = XFS_FSB_TO_BB(mp, dq_f->qlf_len);
3310     + if (xlog_peek_buffer_cancelled(log, dq_f->qlf_blkno, len, 0))
3311     + return;
3312     +
3313     + xfs_buf_readahead(mp->m_ddev_targp, dq_f->qlf_blkno, len,
3314     + &xfs_dquot_buf_ra_ops);
3315     }
3316    
3317     STATIC void
3318     diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
3319     index 36bd8825bfb0..ef64a1e1a66a 100644
3320     --- a/fs/xfs/xfs_super.c
3321     +++ b/fs/xfs/xfs_super.c
3322     @@ -1233,6 +1233,16 @@ xfs_fs_remount(
3323     return -EINVAL;
3324     }
3325    
3326     + if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 &&
3327     + xfs_sb_has_ro_compat_feature(sbp,
3328     + XFS_SB_FEAT_RO_COMPAT_UNKNOWN)) {
3329     + xfs_warn(mp,
3330     +"ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem",
3331     + (sbp->sb_features_ro_compat &
3332     + XFS_SB_FEAT_RO_COMPAT_UNKNOWN));
3333     + return -EINVAL;
3334     + }
3335     +
3336     mp->m_flags &= ~XFS_MOUNT_RDONLY;
3337    
3338     /*
3339     diff --git a/include/linux/mm.h b/include/linux/mm.h
3340     index fb8b20e5d021..f24df9c0b9df 100644
3341     --- a/include/linux/mm.h
3342     +++ b/include/linux/mm.h
3343     @@ -1696,7 +1696,7 @@ extern void free_highmem_page(struct page *page);
3344     extern void adjust_managed_page_count(struct page *page, long count);
3345     extern void mem_init_print_info(const char *str);
3346    
3347     -extern void reserve_bootmem_region(unsigned long start, unsigned long end);
3348     +extern void reserve_bootmem_region(phys_addr_t start, phys_addr_t end);
3349    
3350     /* Free the reserved page into the buddy system, so it gets managed. */
3351     static inline void __free_reserved_page(struct page *page)
3352     diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
3353     index eb8b8ac6df3c..24f5470d3944 100644
3354     --- a/include/linux/pipe_fs_i.h
3355     +++ b/include/linux/pipe_fs_i.h
3356     @@ -42,6 +42,7 @@ struct pipe_buffer {
3357     * @fasync_readers: reader side fasync
3358     * @fasync_writers: writer side fasync
3359     * @bufs: the circular array of pipe buffers
3360     + * @user: the user who created this pipe
3361     **/
3362     struct pipe_inode_info {
3363     struct mutex mutex;
3364     @@ -57,6 +58,7 @@ struct pipe_inode_info {
3365     struct fasync_struct *fasync_readers;
3366     struct fasync_struct *fasync_writers;
3367     struct pipe_buffer *bufs;
3368     + struct user_struct *user;
3369     };
3370    
3371     /*
3372     @@ -123,6 +125,8 @@ void pipe_unlock(struct pipe_inode_info *);
3373     void pipe_double_lock(struct pipe_inode_info *, struct pipe_inode_info *);
3374    
3375     extern unsigned int pipe_max_size, pipe_min_size;
3376     +extern unsigned long pipe_user_pages_hard;
3377     +extern unsigned long pipe_user_pages_soft;
3378     int pipe_proc_fn(struct ctl_table *, int, void __user *, size_t *, loff_t *);
3379    
3380    
3381     diff --git a/include/linux/sched.h b/include/linux/sched.h
3382     index 21a6e9649012..1c0193baea2a 100644
3383     --- a/include/linux/sched.h
3384     +++ b/include/linux/sched.h
3385     @@ -831,6 +831,7 @@ struct user_struct {
3386     #endif
3387     unsigned long locked_shm; /* How many pages of mlocked shm ? */
3388     unsigned long unix_inflight; /* How many files in flight in unix sockets */
3389     + atomic_long_t pipe_bufs; /* how many pages are allocated in pipe buffers */
3390    
3391     #ifdef CONFIG_KEYS
3392     struct key *uid_keyring; /* UID specific keyring */
3393     diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
3394     index eeba75395f7d..c8529ce28a3f 100644
3395     --- a/include/video/imx-ipu-v3.h
3396     +++ b/include/video/imx-ipu-v3.h
3397     @@ -16,6 +16,7 @@
3398     #include <linux/videodev2.h>
3399     #include <linux/bitmap.h>
3400     #include <linux/fb.h>
3401     +#include <linux/of.h>
3402     #include <media/v4l2-mediabus.h>
3403     #include <video/videomode.h>
3404    
3405     @@ -344,6 +345,7 @@ struct ipu_client_platformdata {
3406     int dc;
3407     int dp;
3408     int dma[2];
3409     + struct device_node *of_node;
3410     };
3411    
3412     #endif /* __DRM_IPU_H__ */
3413     diff --git a/kernel/exit.c b/kernel/exit.c
3414     index 07110c6020a0..ffba5df4abd5 100644
3415     --- a/kernel/exit.c
3416     +++ b/kernel/exit.c
3417     @@ -918,17 +918,28 @@ static int eligible_pid(struct wait_opts *wo, struct task_struct *p)
3418     task_pid_type(p, wo->wo_type) == wo->wo_pid;
3419     }
3420    
3421     -static int eligible_child(struct wait_opts *wo, struct task_struct *p)
3422     +static int
3423     +eligible_child(struct wait_opts *wo, bool ptrace, struct task_struct *p)
3424     {
3425     if (!eligible_pid(wo, p))
3426     return 0;
3427     - /* Wait for all children (clone and not) if __WALL is set;
3428     - * otherwise, wait for clone children *only* if __WCLONE is
3429     - * set; otherwise, wait for non-clone children *only*. (Note:
3430     - * A "clone" child here is one that reports to its parent
3431     - * using a signal other than SIGCHLD.) */
3432     - if (((p->exit_signal != SIGCHLD) ^ !!(wo->wo_flags & __WCLONE))
3433     - && !(wo->wo_flags & __WALL))
3434     +
3435     + /*
3436     + * Wait for all children (clone and not) if __WALL is set or
3437     + * if it is traced by us.
3438     + */
3439     + if (ptrace || (wo->wo_flags & __WALL))
3440     + return 1;
3441     +
3442     + /*
3443     + * Otherwise, wait for clone children *only* if __WCLONE is set;
3444     + * otherwise, wait for non-clone children *only*.
3445     + *
3446     + * Note: a "clone" child here is one that reports to its parent
3447     + * using a signal other than SIGCHLD, or a non-leader thread which
3448     + * we can only see if it is traced by us.
3449     + */
3450     + if ((p->exit_signal != SIGCHLD) ^ !!(wo->wo_flags & __WCLONE))
3451     return 0;
3452    
3453     return 1;
3454     @@ -1301,7 +1312,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
3455     if (unlikely(exit_state == EXIT_DEAD))
3456     return 0;
3457    
3458     - ret = eligible_child(wo, p);
3459     + ret = eligible_child(wo, ptrace, p);
3460     if (!ret)
3461     return ret;
3462    
3463     diff --git a/kernel/sysctl.c b/kernel/sysctl.c
3464     index dc6858d6639e..2781141a89f9 100644
3465     --- a/kernel/sysctl.c
3466     +++ b/kernel/sysctl.c
3467     @@ -1735,6 +1735,20 @@ static struct ctl_table fs_table[] = {
3468     .proc_handler = &pipe_proc_fn,
3469     .extra1 = &pipe_min_size,
3470     },
3471     + {
3472     + .procname = "pipe-user-pages-hard",
3473     + .data = &pipe_user_pages_hard,
3474     + .maxlen = sizeof(pipe_user_pages_hard),
3475     + .mode = 0644,
3476     + .proc_handler = proc_doulongvec_minmax,
3477     + },
3478     + {
3479     + .procname = "pipe-user-pages-soft",
3480     + .data = &pipe_user_pages_soft,
3481     + .maxlen = sizeof(pipe_user_pages_soft),
3482     + .mode = 0644,
3483     + .proc_handler = proc_doulongvec_minmax,
3484     + },
3485     { }
3486     };
3487    
3488     diff --git a/lib/dma-debug.c b/lib/dma-debug.c
3489     index 4a1515f4b452..51a76af25c66 100644
3490     --- a/lib/dma-debug.c
3491     +++ b/lib/dma-debug.c
3492     @@ -657,9 +657,9 @@ static struct dma_debug_entry *dma_entry_alloc(void)
3493     spin_lock_irqsave(&free_entries_lock, flags);
3494    
3495     if (list_empty(&free_entries)) {
3496     - pr_err("DMA-API: debugging out of memory - disabling\n");
3497     global_disable = true;
3498     spin_unlock_irqrestore(&free_entries_lock, flags);
3499     + pr_err("DMA-API: debugging out of memory - disabling\n");
3500     return NULL;
3501     }
3502    
3503     diff --git a/mm/page_alloc.c b/mm/page_alloc.c
3504     index 6cf5cadeaef7..99c1738684ec 100644
3505     --- a/mm/page_alloc.c
3506     +++ b/mm/page_alloc.c
3507     @@ -951,7 +951,7 @@ static inline void init_reserved_page(unsigned long pfn)
3508     * marks the pages PageReserved. The remaining valid pages are later
3509     * sent to the buddy page allocator.
3510     */
3511     -void __meminit reserve_bootmem_region(unsigned long start, unsigned long end)
3512     +void __meminit reserve_bootmem_region(phys_addr_t start, phys_addr_t end)
3513     {
3514     unsigned long start_pfn = PFN_DOWN(start);
3515     unsigned long end_pfn = PFN_UP(end);
3516     diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
3517     index 1095be9c80ab..4605dc73def6 100644
3518     --- a/net/sunrpc/auth_gss/svcauth_gss.c
3519     +++ b/net/sunrpc/auth_gss/svcauth_gss.c
3520     @@ -857,8 +857,8 @@ unwrap_integ_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct g
3521     goto out;
3522     if (svc_getnl(&buf->head[0]) != seq)
3523     goto out;
3524     - /* trim off the mic at the end before returning */
3525     - xdr_buf_trim(buf, mic.len + 4);
3526     + /* trim off the mic and padding at the end before returning */
3527     + xdr_buf_trim(buf, round_up_to_quad(mic.len) + 4);
3528     stat = 0;
3529     out:
3530     kfree(mic.data);
3531     diff --git a/scripts/package/Makefile b/scripts/package/Makefile
3532     index 1aca224e8597..493e226356ca 100644
3533     --- a/scripts/package/Makefile
3534     +++ b/scripts/package/Makefile
3535     @@ -52,7 +52,7 @@ rpm-pkg rpm: FORCE
3536     $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
3537     $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
3538     mv -f $(objtree)/.tmp_version $(objtree)/.version
3539     - rpmbuild --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
3540     + rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
3541     rm $(KERNELPATH).tar.gz kernel.spec
3542    
3543     # binrpm-pkg
3544     @@ -63,7 +63,7 @@ binrpm-pkg: FORCE
3545     $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
3546     mv -f $(objtree)/.tmp_version $(objtree)/.version
3547    
3548     - rpmbuild --define "_builddir $(objtree)" --target \
3549     + rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
3550     $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
3551     rm binkernel.spec
3552    
3553     diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
3554     index cda27c22812a..eb8fe212e163 100644
3555     --- a/sound/soc/codecs/ak4642.c
3556     +++ b/sound/soc/codecs/ak4642.c
3557     @@ -560,6 +560,7 @@ static const struct regmap_config ak4642_regmap = {
3558     .max_register = FIL1_3,
3559     .reg_defaults = ak4642_reg,
3560     .num_reg_defaults = NUM_AK4642_REG_DEFAULTS,
3561     + .cache_type = REGCACHE_RBTREE,
3562     };
3563    
3564     static const struct regmap_config ak4643_regmap = {
3565     @@ -568,6 +569,7 @@ static const struct regmap_config ak4643_regmap = {
3566     .max_register = SPK_MS,
3567     .reg_defaults = ak4643_reg,
3568     .num_reg_defaults = ARRAY_SIZE(ak4643_reg),
3569     + .cache_type = REGCACHE_RBTREE,
3570     };
3571    
3572     static const struct regmap_config ak4648_regmap = {
3573     @@ -576,6 +578,7 @@ static const struct regmap_config ak4648_regmap = {
3574     .max_register = EQ_FBEQE,
3575     .reg_defaults = ak4648_reg,
3576     .num_reg_defaults = ARRAY_SIZE(ak4648_reg),
3577     + .cache_type = REGCACHE_RBTREE,
3578     };
3579    
3580     static const struct ak4642_drvdata ak4642_drvdata = {