Magellan Linux

Contents of /trunk/kernel-magellan/patches-4.5/0106-4.5.7-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2814 - (show annotations) (download)
Fri Jun 24 09:01:56 2016 UTC (7 years, 10 months ago) by niro
File size: 130275 byte(s)
-linux-4.5.7
1 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/Makefile b/Makefile
14 index 07a1786f695a..90e4bd904d36 100644
15 --- a/Makefile
16 +++ b/Makefile
17 @@ -1,6 +1,6 @@
18 VERSION = 4
19 PATCHLEVEL = 5
20 -SUBLEVEL = 6
21 +SUBLEVEL = 7
22 EXTRAVERSION =
23 NAME = Blurry Fish Butt
24
25 @@ -364,7 +364,7 @@ AFLAGS_MODULE =
26 LDFLAGS_MODULE =
27 CFLAGS_KERNEL =
28 AFLAGS_KERNEL =
29 -CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
30 +CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im
31
32
33 # Use USERINCLUDE when you must reference the UAPI directories only.
34 diff --git a/arch/arm/boot/dts/armada-385-linksys.dtsi b/arch/arm/boot/dts/armada-385-linksys.dtsi
35 index 85d2c377c332..8450944b28e6 100644
36 --- a/arch/arm/boot/dts/armada-385-linksys.dtsi
37 +++ b/arch/arm/boot/dts/armada-385-linksys.dtsi
38 @@ -245,7 +245,7 @@
39 button@2 {
40 label = "Factory Reset Button";
41 linux,code = <KEY_RESTART>;
42 - gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
43 + gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;
44 };
45 };
46
47 @@ -260,7 +260,7 @@
48 };
49
50 sata {
51 - gpios = <&gpio1 22 GPIO_ACTIVE_HIGH>;
52 + gpios = <&gpio1 22 GPIO_ACTIVE_LOW>;
53 default-state = "off";
54 };
55 };
56 @@ -313,7 +313,7 @@
57
58 &pinctrl {
59 keys_pin: keys-pin {
60 - marvell,pins = "mpp24", "mpp47";
61 + marvell,pins = "mpp24", "mpp29";
62 marvell,function = "gpio";
63 };
64
65 diff --git a/arch/arm/boot/dts/armada-xp-linksys-mamba.dts b/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
66 index b89e6cf1271a..7a461541ce50 100644
67 --- a/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
68 +++ b/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
69 @@ -304,13 +304,13 @@
70 button@1 {
71 label = "WPS";
72 linux,code = <KEY_WPS_BUTTON>;
73 - gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
74 + gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
75 };
76
77 button@2 {
78 label = "Factory Reset Button";
79 linux,code = <KEY_RESTART>;
80 - gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;
81 + gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
82 };
83 };
84
85 diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
86 index a50be640f1b0..59411e447fa0 100644
87 --- a/arch/arm/boot/dts/exynos4210-trats.dts
88 +++ b/arch/arm/boot/dts/exynos4210-trats.dts
89 @@ -298,6 +298,8 @@
90 compatible = "maxim,max8997-pmic";
91
92 reg = <0x66>;
93 + interrupt-parent = <&gpx0>;
94 + interrupts = <7 0>;
95
96 max8997,pmic-buck1-uses-gpio-dvs;
97 max8997,pmic-buck2-uses-gpio-dvs;
98 diff --git a/arch/arm/boot/dts/sama5d2-pinfunc.h b/arch/arm/boot/dts/sama5d2-pinfunc.h
99 index b0c912feaa2f..8a394f336003 100644
100 --- a/arch/arm/boot/dts/sama5d2-pinfunc.h
101 +++ b/arch/arm/boot/dts/sama5d2-pinfunc.h
102 @@ -837,8 +837,8 @@
103 #define PIN_PD23__ISC_FIELD PINMUX_PIN(PIN_PD23, 6, 4)
104 #define PIN_PD24 120
105 #define PIN_PD24__GPIO PINMUX_PIN(PIN_PD24, 0, 0)
106 -#define PIN_PD24__UTXD2 PINMUX_PIN(PIN_PD23, 1, 2)
107 -#define PIN_PD24__FLEXCOM4_IO3 PINMUX_PIN(PIN_PD23, 3, 3)
108 +#define PIN_PD24__UTXD2 PINMUX_PIN(PIN_PD24, 1, 2)
109 +#define PIN_PD24__FLEXCOM4_IO3 PINMUX_PIN(PIN_PD24, 3, 3)
110 #define PIN_PD25 121
111 #define PIN_PD25__GPIO PINMUX_PIN(PIN_PD25, 0, 0)
112 #define PIN_PD25__SPI1_SPCK PINMUX_PIN(PIN_PD25, 1, 3)
113 diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
114 index 2c8f5e6ad905..bf70d0ae93ce 100644
115 --- a/arch/arm/boot/dts/sun4i-a10.dtsi
116 +++ b/arch/arm/boot/dts/sun4i-a10.dtsi
117 @@ -96,7 +96,7 @@
118 allwinner,pipeline = "de_fe0-de_be0-lcd0-tve0";
119 clocks = <&pll5 1>, <&ahb_gates 34>, <&ahb_gates 36>,
120 <&ahb_gates 44>, <&ahb_gates 46>,
121 - <&dram_gates 25>, <&dram_gates 26>;
122 + <&dram_gates 5>, <&dram_gates 25>, <&dram_gates 26>;
123 status = "disabled";
124 };
125 };
126 diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
127 index 0940a788f824..ee4e8e7d3e30 100644
128 --- a/arch/arm/boot/dts/sun7i-a20.dtsi
129 +++ b/arch/arm/boot/dts/sun7i-a20.dtsi
130 @@ -85,8 +85,9 @@
131 compatible = "allwinner,simple-framebuffer",
132 "simple-framebuffer";
133 allwinner,pipeline = "de_be0-lcd0-tve0";
134 - clocks = <&pll5 1>, <&ahb_gates 34>, <&ahb_gates 36>,
135 - <&ahb_gates 44>, <&dram_gates 26>;
136 + clocks = <&pll5 1>,
137 + <&ahb_gates 34>, <&ahb_gates 36>, <&ahb_gates 44>,
138 + <&dram_gates 5>, <&dram_gates 26>;
139 status = "disabled";
140 };
141 };
142 diff --git a/arch/mips/ath79/early_printk.c b/arch/mips/ath79/early_printk.c
143 index b955fafc58ba..d1adc59af5bf 100644
144 --- a/arch/mips/ath79/early_printk.c
145 +++ b/arch/mips/ath79/early_printk.c
146 @@ -31,13 +31,15 @@ static inline void prom_putchar_wait(void __iomem *reg, u32 mask, u32 val)
147 } while (1);
148 }
149
150 +#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
151 +
152 static void prom_putchar_ar71xx(unsigned char ch)
153 {
154 void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE));
155
156 - prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE);
157 + prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
158 __raw_writel(ch, base + UART_TX * 4);
159 - prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE);
160 + prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
161 }
162
163 static void prom_putchar_ar933x(unsigned char ch)
164 diff --git a/arch/mips/include/asm/asmmacro.h b/arch/mips/include/asm/asmmacro.h
165 index 867f924b05c7..e689b894353c 100644
166 --- a/arch/mips/include/asm/asmmacro.h
167 +++ b/arch/mips/include/asm/asmmacro.h
168 @@ -298,21 +298,21 @@
169 .set pop
170 .endm
171
172 - .macro copy_u_w ws, n
173 + .macro copy_s_w ws, n
174 .set push
175 .set mips32r2
176 .set fp=64
177 .set msa
178 - copy_u.w $1, $w\ws[\n]
179 + copy_s.w $1, $w\ws[\n]
180 .set pop
181 .endm
182
183 - .macro copy_u_d ws, n
184 + .macro copy_s_d ws, n
185 .set push
186 .set mips64r2
187 .set fp=64
188 .set msa
189 - copy_u.d $1, $w\ws[\n]
190 + copy_s.d $1, $w\ws[\n]
191 .set pop
192 .endm
193
194 @@ -346,8 +346,8 @@
195 #define STH_MSA_INSN 0x5800081f
196 #define STW_MSA_INSN 0x5800082f
197 #define STD_MSA_INSN 0x5800083f
198 -#define COPY_UW_MSA_INSN 0x58f00056
199 -#define COPY_UD_MSA_INSN 0x58f80056
200 +#define COPY_SW_MSA_INSN 0x58b00056
201 +#define COPY_SD_MSA_INSN 0x58b80056
202 #define INSERT_W_MSA_INSN 0x59300816
203 #define INSERT_D_MSA_INSN 0x59380816
204 #else
205 @@ -361,8 +361,8 @@
206 #define STH_MSA_INSN 0x78000825
207 #define STW_MSA_INSN 0x78000826
208 #define STD_MSA_INSN 0x78000827
209 -#define COPY_UW_MSA_INSN 0x78f00059
210 -#define COPY_UD_MSA_INSN 0x78f80059
211 +#define COPY_SW_MSA_INSN 0x78b00059
212 +#define COPY_SD_MSA_INSN 0x78b80059
213 #define INSERT_W_MSA_INSN 0x79300819
214 #define INSERT_D_MSA_INSN 0x79380819
215 #endif
216 @@ -393,7 +393,7 @@
217 .set push
218 .set noat
219 SET_HARDFLOAT
220 - addu $1, \base, \off
221 + PTR_ADDU $1, \base, \off
222 .word LDB_MSA_INSN | (\wd << 6)
223 .set pop
224 .endm
225 @@ -402,7 +402,7 @@
226 .set push
227 .set noat
228 SET_HARDFLOAT
229 - addu $1, \base, \off
230 + PTR_ADDU $1, \base, \off
231 .word LDH_MSA_INSN | (\wd << 6)
232 .set pop
233 .endm
234 @@ -411,7 +411,7 @@
235 .set push
236 .set noat
237 SET_HARDFLOAT
238 - addu $1, \base, \off
239 + PTR_ADDU $1, \base, \off
240 .word LDW_MSA_INSN | (\wd << 6)
241 .set pop
242 .endm
243 @@ -420,7 +420,7 @@
244 .set push
245 .set noat
246 SET_HARDFLOAT
247 - addu $1, \base, \off
248 + PTR_ADDU $1, \base, \off
249 .word LDD_MSA_INSN | (\wd << 6)
250 .set pop
251 .endm
252 @@ -429,7 +429,7 @@
253 .set push
254 .set noat
255 SET_HARDFLOAT
256 - addu $1, \base, \off
257 + PTR_ADDU $1, \base, \off
258 .word STB_MSA_INSN | (\wd << 6)
259 .set pop
260 .endm
261 @@ -438,7 +438,7 @@
262 .set push
263 .set noat
264 SET_HARDFLOAT
265 - addu $1, \base, \off
266 + PTR_ADDU $1, \base, \off
267 .word STH_MSA_INSN | (\wd << 6)
268 .set pop
269 .endm
270 @@ -447,7 +447,7 @@
271 .set push
272 .set noat
273 SET_HARDFLOAT
274 - addu $1, \base, \off
275 + PTR_ADDU $1, \base, \off
276 .word STW_MSA_INSN | (\wd << 6)
277 .set pop
278 .endm
279 @@ -456,26 +456,26 @@
280 .set push
281 .set noat
282 SET_HARDFLOAT
283 - addu $1, \base, \off
284 + PTR_ADDU $1, \base, \off
285 .word STD_MSA_INSN | (\wd << 6)
286 .set pop
287 .endm
288
289 - .macro copy_u_w ws, n
290 + .macro copy_s_w ws, n
291 .set push
292 .set noat
293 SET_HARDFLOAT
294 .insn
295 - .word COPY_UW_MSA_INSN | (\n << 16) | (\ws << 11)
296 + .word COPY_SW_MSA_INSN | (\n << 16) | (\ws << 11)
297 .set pop
298 .endm
299
300 - .macro copy_u_d ws, n
301 + .macro copy_s_d ws, n
302 .set push
303 .set noat
304 SET_HARDFLOAT
305 .insn
306 - .word COPY_UD_MSA_INSN | (\n << 16) | (\ws << 11)
307 + .word COPY_SD_MSA_INSN | (\n << 16) | (\ws << 11)
308 .set pop
309 .endm
310
311 diff --git a/arch/mips/include/asm/cacheflush.h b/arch/mips/include/asm/cacheflush.h
312 index 723229f4cf27..176de586a71a 100644
313 --- a/arch/mips/include/asm/cacheflush.h
314 +++ b/arch/mips/include/asm/cacheflush.h
315 @@ -51,7 +51,6 @@ extern void (*flush_cache_range)(struct vm_area_struct *vma,
316 unsigned long start, unsigned long end);
317 extern void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, unsigned long pfn);
318 extern void __flush_dcache_page(struct page *page);
319 -extern void __flush_icache_page(struct vm_area_struct *vma, struct page *page);
320
321 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
322 static inline void flush_dcache_page(struct page *page)
323 @@ -77,11 +76,6 @@ static inline void flush_anon_page(struct vm_area_struct *vma,
324 static inline void flush_icache_page(struct vm_area_struct *vma,
325 struct page *page)
326 {
327 - if (!cpu_has_ic_fills_f_dc && (vma->vm_flags & VM_EXEC) &&
328 - Page_dcache_dirty(page)) {
329 - __flush_icache_page(vma, page);
330 - ClearPageDcacheDirty(page);
331 - }
332 }
333
334 extern void (*flush_icache_range)(unsigned long start, unsigned long end);
335 diff --git a/arch/mips/include/asm/msa.h b/arch/mips/include/asm/msa.h
336 index bbb85fe21642..6e4effa6f626 100644
337 --- a/arch/mips/include/asm/msa.h
338 +++ b/arch/mips/include/asm/msa.h
339 @@ -147,6 +147,19 @@ static inline void restore_msa(struct task_struct *t)
340 _restore_msa(t);
341 }
342
343 +static inline void init_msa_upper(void)
344 +{
345 + /*
346 + * Check cpu_has_msa only if it's a constant. This will allow the
347 + * compiler to optimise out code for CPUs without MSA without adding
348 + * an extra redundant check for CPUs with MSA.
349 + */
350 + if (__builtin_constant_p(cpu_has_msa) && !cpu_has_msa)
351 + return;
352 +
353 + _init_msa_upper();
354 +}
355 +
356 #ifdef TOOLCHAIN_SUPPORTS_MSA
357
358 #define __BUILD_MSA_CTL_REG(name, cs) \
359 diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
360 index 9a4fe0133ff1..65bf2c065db5 100644
361 --- a/arch/mips/include/asm/pgtable.h
362 +++ b/arch/mips/include/asm/pgtable.h
363 @@ -127,10 +127,14 @@ do { \
364 } \
365 } while(0)
366
367 +static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
368 + pte_t *ptep, pte_t pteval);
369 +
370 #if defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32)
371
372 #define pte_none(pte) (!(((pte).pte_high) & ~_PAGE_GLOBAL))
373 #define pte_present(pte) ((pte).pte_low & _PAGE_PRESENT)
374 +#define pte_no_exec(pte) ((pte).pte_low & _PAGE_NO_EXEC)
375
376 static inline void set_pte(pte_t *ptep, pte_t pte)
377 {
378 @@ -148,7 +152,6 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
379 buddy->pte_high |= _PAGE_GLOBAL;
380 }
381 }
382 -#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
383
384 static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
385 {
386 @@ -166,6 +169,7 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt
387
388 #define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))
389 #define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
390 +#define pte_no_exec(pte) (pte_val(pte) & _PAGE_NO_EXEC)
391
392 /*
393 * Certain architectures need to do special things when pte's
394 @@ -218,7 +222,6 @@ static inline void set_pte(pte_t *ptep, pte_t pteval)
395 }
396 #endif
397 }
398 -#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
399
400 static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
401 {
402 @@ -234,6 +237,22 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt
403 }
404 #endif
405
406 +static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
407 + pte_t *ptep, pte_t pteval)
408 +{
409 + extern void __update_cache(unsigned long address, pte_t pte);
410 +
411 + if (!pte_present(pteval))
412 + goto cache_sync_done;
413 +
414 + if (pte_present(*ptep) && (pte_pfn(*ptep) == pte_pfn(pteval)))
415 + goto cache_sync_done;
416 +
417 + __update_cache(addr, pteval);
418 +cache_sync_done:
419 + set_pte(ptep, pteval);
420 +}
421 +
422 /*
423 * (pmds are folded into puds so this doesn't get actually called,
424 * but the define is needed for a generic inline function.)
425 @@ -430,15 +449,12 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
426
427 extern void __update_tlb(struct vm_area_struct *vma, unsigned long address,
428 pte_t pte);
429 -extern void __update_cache(struct vm_area_struct *vma, unsigned long address,
430 - pte_t pte);
431
432 static inline void update_mmu_cache(struct vm_area_struct *vma,
433 unsigned long address, pte_t *ptep)
434 {
435 pte_t pte = *ptep;
436 __update_tlb(vma, address, pte);
437 - __update_cache(vma, address, pte);
438 }
439
440 static inline void update_mmu_cache_pmd(struct vm_area_struct *vma,
441 diff --git a/arch/mips/include/asm/switch_to.h b/arch/mips/include/asm/switch_to.h
442 index 28b5d84a5022..ebb5c0f2f90d 100644
443 --- a/arch/mips/include/asm/switch_to.h
444 +++ b/arch/mips/include/asm/switch_to.h
445 @@ -105,7 +105,7 @@ do { \
446 __clear_software_ll_bit(); \
447 if (cpu_has_userlocal) \
448 write_c0_userlocal(task_thread_info(next)->tp_value); \
449 - __restore_watch(); \
450 + __restore_watch(next); \
451 (last) = resume(prev, next, task_thread_info(next)); \
452 } while (0)
453
454 diff --git a/arch/mips/include/asm/watch.h b/arch/mips/include/asm/watch.h
455 index 20126ec79359..6ffe3eadf105 100644
456 --- a/arch/mips/include/asm/watch.h
457 +++ b/arch/mips/include/asm/watch.h
458 @@ -12,21 +12,21 @@
459
460 #include <asm/mipsregs.h>
461
462 -void mips_install_watch_registers(void);
463 +void mips_install_watch_registers(struct task_struct *t);
464 void mips_read_watch_registers(void);
465 void mips_clear_watch_registers(void);
466 void mips_probe_watch_registers(struct cpuinfo_mips *c);
467
468 #ifdef CONFIG_HARDWARE_WATCHPOINTS
469 -#define __restore_watch() do { \
470 +#define __restore_watch(task) do { \
471 if (unlikely(test_bit(TIF_LOAD_WATCH, \
472 - &current_thread_info()->flags))) { \
473 - mips_install_watch_registers(); \
474 + &task_thread_info(task)->flags))) { \
475 + mips_install_watch_registers(task); \
476 } \
477 } while (0)
478
479 #else
480 -#define __restore_watch() do {} while (0)
481 +#define __restore_watch(task) do {} while (0)
482 #endif
483
484 #endif /* _ASM_WATCH_H */
485 diff --git a/arch/mips/include/uapi/asm/siginfo.h b/arch/mips/include/uapi/asm/siginfo.h
486 index 2cb7fdead570..e2b5337e840f 100644
487 --- a/arch/mips/include/uapi/asm/siginfo.h
488 +++ b/arch/mips/include/uapi/asm/siginfo.h
489 @@ -28,7 +28,7 @@
490
491 #define __ARCH_SIGSYS
492
493 -#include <uapi/asm-generic/siginfo.h>
494 +#include <asm-generic/siginfo.h>
495
496 /* We can't use generic siginfo_t, because our si_code and si_errno are swapped */
497 typedef struct siginfo {
498 @@ -42,13 +42,13 @@ typedef struct siginfo {
499
500 /* kill() */
501 struct {
502 - pid_t _pid; /* sender's pid */
503 + __kernel_pid_t _pid; /* sender's pid */
504 __ARCH_SI_UID_T _uid; /* sender's uid */
505 } _kill;
506
507 /* POSIX.1b timers */
508 struct {
509 - timer_t _tid; /* timer id */
510 + __kernel_timer_t _tid; /* timer id */
511 int _overrun; /* overrun count */
512 char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
513 sigval_t _sigval; /* same as below */
514 @@ -57,26 +57,26 @@ typedef struct siginfo {
515
516 /* POSIX.1b signals */
517 struct {
518 - pid_t _pid; /* sender's pid */
519 + __kernel_pid_t _pid; /* sender's pid */
520 __ARCH_SI_UID_T _uid; /* sender's uid */
521 sigval_t _sigval;
522 } _rt;
523
524 /* SIGCHLD */
525 struct {
526 - pid_t _pid; /* which child */
527 + __kernel_pid_t _pid; /* which child */
528 __ARCH_SI_UID_T _uid; /* sender's uid */
529 int _status; /* exit code */
530 - clock_t _utime;
531 - clock_t _stime;
532 + __kernel_clock_t _utime;
533 + __kernel_clock_t _stime;
534 } _sigchld;
535
536 /* IRIX SIGCHLD */
537 struct {
538 - pid_t _pid; /* which child */
539 - clock_t _utime;
540 + __kernel_pid_t _pid; /* which child */
541 + __kernel_clock_t _utime;
542 int _status; /* exit code */
543 - clock_t _stime;
544 + __kernel_clock_t _stime;
545 } _irix_sigchld;
546
547 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
548 @@ -118,6 +118,4 @@ typedef struct siginfo {
549 #define SI_TIMER __SI_CODE(__SI_TIMER, -3) /* sent by timer expiration */
550 #define SI_MESGQ __SI_CODE(__SI_MESGQ, -4) /* sent by real time mesq state change */
551
552 -#include <asm-generic/siginfo.h>
553 -
554 #endif /* _UAPI_ASM_SIGINFO_H */
555 diff --git a/arch/mips/kernel/mips-r2-to-r6-emul.c b/arch/mips/kernel/mips-r2-to-r6-emul.c
556 index 1f5aac7f9ec3..4674a74a08b5 100644
557 --- a/arch/mips/kernel/mips-r2-to-r6-emul.c
558 +++ b/arch/mips/kernel/mips-r2-to-r6-emul.c
559 @@ -28,6 +28,7 @@
560 #include <asm/inst.h>
561 #include <asm/mips-r2-to-r6-emul.h>
562 #include <asm/local.h>
563 +#include <asm/mipsregs.h>
564 #include <asm/ptrace.h>
565 #include <asm/uaccess.h>
566
567 @@ -1251,10 +1252,10 @@ fpu_emul:
568 " j 10b\n"
569 " .previous\n"
570 " .section __ex_table,\"a\"\n"
571 - " .word 1b,8b\n"
572 - " .word 2b,8b\n"
573 - " .word 3b,8b\n"
574 - " .word 4b,8b\n"
575 + STR(PTR) " 1b,8b\n"
576 + STR(PTR) " 2b,8b\n"
577 + STR(PTR) " 3b,8b\n"
578 + STR(PTR) " 4b,8b\n"
579 " .previous\n"
580 " .set pop\n"
581 : "+&r"(rt), "=&r"(rs),
582 @@ -1326,10 +1327,10 @@ fpu_emul:
583 " j 10b\n"
584 " .previous\n"
585 " .section __ex_table,\"a\"\n"
586 - " .word 1b,8b\n"
587 - " .word 2b,8b\n"
588 - " .word 3b,8b\n"
589 - " .word 4b,8b\n"
590 + STR(PTR) " 1b,8b\n"
591 + STR(PTR) " 2b,8b\n"
592 + STR(PTR) " 3b,8b\n"
593 + STR(PTR) " 4b,8b\n"
594 " .previous\n"
595 " .set pop\n"
596 : "+&r"(rt), "=&r"(rs),
597 @@ -1397,10 +1398,10 @@ fpu_emul:
598 " j 9b\n"
599 " .previous\n"
600 " .section __ex_table,\"a\"\n"
601 - " .word 1b,8b\n"
602 - " .word 2b,8b\n"
603 - " .word 3b,8b\n"
604 - " .word 4b,8b\n"
605 + STR(PTR) " 1b,8b\n"
606 + STR(PTR) " 2b,8b\n"
607 + STR(PTR) " 3b,8b\n"
608 + STR(PTR) " 4b,8b\n"
609 " .previous\n"
610 " .set pop\n"
611 : "+&r"(rt), "=&r"(rs),
612 @@ -1467,10 +1468,10 @@ fpu_emul:
613 " j 9b\n"
614 " .previous\n"
615 " .section __ex_table,\"a\"\n"
616 - " .word 1b,8b\n"
617 - " .word 2b,8b\n"
618 - " .word 3b,8b\n"
619 - " .word 4b,8b\n"
620 + STR(PTR) " 1b,8b\n"
621 + STR(PTR) " 2b,8b\n"
622 + STR(PTR) " 3b,8b\n"
623 + STR(PTR) " 4b,8b\n"
624 " .previous\n"
625 " .set pop\n"
626 : "+&r"(rt), "=&r"(rs),
627 @@ -1582,14 +1583,14 @@ fpu_emul:
628 " j 9b\n"
629 " .previous\n"
630 " .section __ex_table,\"a\"\n"
631 - " .word 1b,8b\n"
632 - " .word 2b,8b\n"
633 - " .word 3b,8b\n"
634 - " .word 4b,8b\n"
635 - " .word 5b,8b\n"
636 - " .word 6b,8b\n"
637 - " .word 7b,8b\n"
638 - " .word 0b,8b\n"
639 + STR(PTR) " 1b,8b\n"
640 + STR(PTR) " 2b,8b\n"
641 + STR(PTR) " 3b,8b\n"
642 + STR(PTR) " 4b,8b\n"
643 + STR(PTR) " 5b,8b\n"
644 + STR(PTR) " 6b,8b\n"
645 + STR(PTR) " 7b,8b\n"
646 + STR(PTR) " 0b,8b\n"
647 " .previous\n"
648 " .set pop\n"
649 : "+&r"(rt), "=&r"(rs),
650 @@ -1701,14 +1702,14 @@ fpu_emul:
651 " j 9b\n"
652 " .previous\n"
653 " .section __ex_table,\"a\"\n"
654 - " .word 1b,8b\n"
655 - " .word 2b,8b\n"
656 - " .word 3b,8b\n"
657 - " .word 4b,8b\n"
658 - " .word 5b,8b\n"
659 - " .word 6b,8b\n"
660 - " .word 7b,8b\n"
661 - " .word 0b,8b\n"
662 + STR(PTR) " 1b,8b\n"
663 + STR(PTR) " 2b,8b\n"
664 + STR(PTR) " 3b,8b\n"
665 + STR(PTR) " 4b,8b\n"
666 + STR(PTR) " 5b,8b\n"
667 + STR(PTR) " 6b,8b\n"
668 + STR(PTR) " 7b,8b\n"
669 + STR(PTR) " 0b,8b\n"
670 " .previous\n"
671 " .set pop\n"
672 : "+&r"(rt), "=&r"(rs),
673 @@ -1820,14 +1821,14 @@ fpu_emul:
674 " j 9b\n"
675 " .previous\n"
676 " .section __ex_table,\"a\"\n"
677 - " .word 1b,8b\n"
678 - " .word 2b,8b\n"
679 - " .word 3b,8b\n"
680 - " .word 4b,8b\n"
681 - " .word 5b,8b\n"
682 - " .word 6b,8b\n"
683 - " .word 7b,8b\n"
684 - " .word 0b,8b\n"
685 + STR(PTR) " 1b,8b\n"
686 + STR(PTR) " 2b,8b\n"
687 + STR(PTR) " 3b,8b\n"
688 + STR(PTR) " 4b,8b\n"
689 + STR(PTR) " 5b,8b\n"
690 + STR(PTR) " 6b,8b\n"
691 + STR(PTR) " 7b,8b\n"
692 + STR(PTR) " 0b,8b\n"
693 " .previous\n"
694 " .set pop\n"
695 : "+&r"(rt), "=&r"(rs),
696 @@ -1938,14 +1939,14 @@ fpu_emul:
697 " j 9b\n"
698 " .previous\n"
699 " .section __ex_table,\"a\"\n"
700 - " .word 1b,8b\n"
701 - " .word 2b,8b\n"
702 - " .word 3b,8b\n"
703 - " .word 4b,8b\n"
704 - " .word 5b,8b\n"
705 - " .word 6b,8b\n"
706 - " .word 7b,8b\n"
707 - " .word 0b,8b\n"
708 + STR(PTR) " 1b,8b\n"
709 + STR(PTR) " 2b,8b\n"
710 + STR(PTR) " 3b,8b\n"
711 + STR(PTR) " 4b,8b\n"
712 + STR(PTR) " 5b,8b\n"
713 + STR(PTR) " 6b,8b\n"
714 + STR(PTR) " 7b,8b\n"
715 + STR(PTR) " 0b,8b\n"
716 " .previous\n"
717 " .set pop\n"
718 : "+&r"(rt), "=&r"(rs),
719 @@ -2000,7 +2001,7 @@ fpu_emul:
720 "j 2b\n"
721 ".previous\n"
722 ".section __ex_table,\"a\"\n"
723 - ".word 1b, 3b\n"
724 + STR(PTR) " 1b,3b\n"
725 ".previous\n"
726 : "=&r"(res), "+&r"(err)
727 : "r"(vaddr), "i"(SIGSEGV)
728 @@ -2058,7 +2059,7 @@ fpu_emul:
729 "j 2b\n"
730 ".previous\n"
731 ".section __ex_table,\"a\"\n"
732 - ".word 1b, 3b\n"
733 + STR(PTR) " 1b,3b\n"
734 ".previous\n"
735 : "+&r"(res), "+&r"(err)
736 : "r"(vaddr), "i"(SIGSEGV));
737 @@ -2119,7 +2120,7 @@ fpu_emul:
738 "j 2b\n"
739 ".previous\n"
740 ".section __ex_table,\"a\"\n"
741 - ".word 1b, 3b\n"
742 + STR(PTR) " 1b,3b\n"
743 ".previous\n"
744 : "=&r"(res), "+&r"(err)
745 : "r"(vaddr), "i"(SIGSEGV)
746 @@ -2182,7 +2183,7 @@ fpu_emul:
747 "j 2b\n"
748 ".previous\n"
749 ".section __ex_table,\"a\"\n"
750 - ".word 1b, 3b\n"
751 + STR(PTR) " 1b,3b\n"
752 ".previous\n"
753 : "+&r"(res), "+&r"(err)
754 : "r"(vaddr), "i"(SIGSEGV));
755 diff --git a/arch/mips/kernel/pm.c b/arch/mips/kernel/pm.c
756 index fefdf39d3df3..dc814892133c 100644
757 --- a/arch/mips/kernel/pm.c
758 +++ b/arch/mips/kernel/pm.c
759 @@ -56,7 +56,7 @@ static void mips_cpu_restore(void)
760 write_c0_userlocal(current_thread_info()->tp_value);
761
762 /* Restore watch registers */
763 - __restore_watch();
764 + __restore_watch(current);
765 }
766
767 /**
768 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
769 index eddd5fd6fdfa..0c0456f0c217 100644
770 --- a/arch/mips/kernel/process.c
771 +++ b/arch/mips/kernel/process.c
772 @@ -455,7 +455,7 @@ unsigned long notrace unwind_stack_by_address(unsigned long stack_page,
773 *sp + sizeof(*regs) <= stack_page + THREAD_SIZE - 32) {
774 regs = (struct pt_regs *)*sp;
775 pc = regs->cp0_epc;
776 - if (__kernel_text_address(pc)) {
777 + if (!user_mode(regs) && __kernel_text_address(pc)) {
778 *sp = regs->regs[29];
779 *ra = regs->regs[31];
780 return pc;
781 @@ -601,6 +601,9 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
782 if (!(value & PR_FP_MODE_FR) && cpu_has_fpu && cpu_has_mips_r6)
783 return -EOPNOTSUPP;
784
785 + /* Proceed with the mode switch */
786 + preempt_disable();
787 +
788 /* Save FP & vector context, then disable FPU & MSA */
789 if (task->signal == current->signal)
790 lose_fpu(1);
791 @@ -659,6 +662,7 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
792
793 /* Allow threads to use FP again */
794 atomic_set(&task->mm->context.fp_mode_switching, 0);
795 + preempt_enable();
796
797 return 0;
798 }
799 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
800 index a5279b2f3198..4285d8b7c566 100644
801 --- a/arch/mips/kernel/ptrace.c
802 +++ b/arch/mips/kernel/ptrace.c
803 @@ -57,8 +57,7 @@ static void init_fp_ctx(struct task_struct *target)
804 /* Begin with data registers set to all 1s... */
805 memset(&target->thread.fpu.fpr, ~0, sizeof(target->thread.fpu.fpr));
806
807 - /* ...and FCSR zeroed */
808 - target->thread.fpu.fcr31 = 0;
809 + /* FCSR has been preset by `mips_set_personality_nan'. */
810
811 /*
812 * Record that the target has "used" math, such that the context
813 @@ -80,6 +79,22 @@ void ptrace_disable(struct task_struct *child)
814 }
815
816 /*
817 + * Poke at FCSR according to its mask. Don't set the cause bits as
818 + * this is currently not handled correctly in FP context restoration
819 + * and will cause an oops if a corresponding enable bit is set.
820 + */
821 +static void ptrace_setfcr31(struct task_struct *child, u32 value)
822 +{
823 + u32 fcr31;
824 + u32 mask;
825 +
826 + value &= ~FPU_CSR_ALL_X;
827 + fcr31 = child->thread.fpu.fcr31;
828 + mask = boot_cpu_data.fpu_msk31;
829 + child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask);
830 +}
831 +
832 +/*
833 * Read a general register set. We always use the 64-bit format, even
834 * for 32-bit kernels and for 32-bit processes on a 64-bit kernel.
835 * Registers are sign extended to fill the available space.
836 @@ -159,9 +174,7 @@ int ptrace_setfpregs(struct task_struct *child, __u32 __user *data)
837 {
838 union fpureg *fregs;
839 u64 fpr_val;
840 - u32 fcr31;
841 u32 value;
842 - u32 mask;
843 int i;
844
845 if (!access_ok(VERIFY_READ, data, 33 * 8))
846 @@ -176,9 +189,7 @@ int ptrace_setfpregs(struct task_struct *child, __u32 __user *data)
847 }
848
849 __get_user(value, data + 64);
850 - fcr31 = child->thread.fpu.fcr31;
851 - mask = boot_cpu_data.fpu_msk31;
852 - child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask);
853 + ptrace_setfcr31(child, value);
854
855 /* FIR may not be written. */
856
857 @@ -805,7 +816,7 @@ long arch_ptrace(struct task_struct *child, long request,
858 break;
859 #endif
860 case FPC_CSR:
861 - child->thread.fpu.fcr31 = data & ~FPU_CSR_ALL_X;
862 + ptrace_setfcr31(child, data);
863 break;
864 case DSP_BASE ... DSP_BASE + 5: {
865 dspreg_t *dregs;
866 diff --git a/arch/mips/kernel/r4k_fpu.S b/arch/mips/kernel/r4k_fpu.S
867 index 17732f876eff..56d86b09c917 100644
868 --- a/arch/mips/kernel/r4k_fpu.S
869 +++ b/arch/mips/kernel/r4k_fpu.S
870 @@ -244,17 +244,17 @@ LEAF(\name)
871 .set push
872 .set noat
873 #ifdef CONFIG_64BIT
874 - copy_u_d \wr, 1
875 + copy_s_d \wr, 1
876 EX sd $1, \off(\base)
877 #elif defined(CONFIG_CPU_LITTLE_ENDIAN)
878 - copy_u_w \wr, 2
879 + copy_s_w \wr, 2
880 EX sw $1, \off(\base)
881 - copy_u_w \wr, 3
882 + copy_s_w \wr, 3
883 EX sw $1, (\off+4)(\base)
884 #else /* CONFIG_CPU_BIG_ENDIAN */
885 - copy_u_w \wr, 2
886 + copy_s_w \wr, 2
887 EX sw $1, (\off+4)(\base)
888 - copy_u_w \wr, 3
889 + copy_s_w \wr, 3
890 EX sw $1, \off(\base)
891 #endif
892 .set pop
893 diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
894 index 5fdaf8bdcd2e..6f68cddc0573 100644
895 --- a/arch/mips/kernel/setup.c
896 +++ b/arch/mips/kernel/setup.c
897 @@ -706,6 +706,9 @@ static void __init arch_mem_init(char **cmdline_p)
898 for_each_memblock(reserved, reg)
899 if (reg->size != 0)
900 reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
901 +
902 + reserve_bootmem_region(__pa_symbol(&__nosave_begin),
903 + __pa_symbol(&__nosave_end)); /* Reserve for hibernation */
904 }
905
906 static void __init resource_init(void)
907 diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
908 index bf792e2839a6..9e35b6b26aa8 100644
909 --- a/arch/mips/kernel/signal.c
910 +++ b/arch/mips/kernel/signal.c
911 @@ -195,6 +195,9 @@ static int restore_msa_extcontext(void __user *buf, unsigned int size)
912 unsigned int csr;
913 int i, err;
914
915 + if (!config_enabled(CONFIG_CPU_HAS_MSA))
916 + return SIGSYS;
917 +
918 if (size != sizeof(*msa))
919 return -EINVAL;
920
921 @@ -398,8 +401,8 @@ int protected_restore_fp_context(void __user *sc)
922 }
923
924 fp_done:
925 - if (used & USED_EXTCONTEXT)
926 - err |= restore_extcontext(sc_to_extcontext(sc));
927 + if (!err && (used & USED_EXTCONTEXT))
928 + err = restore_extcontext(sc_to_extcontext(sc));
929
930 return err ?: sig;
931 }
932 @@ -767,15 +770,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
933 sigset_t *oldset = sigmask_to_save();
934 int ret;
935 struct mips_abi *abi = current->thread.abi;
936 -#ifdef CONFIG_CPU_MICROMIPS
937 - void *vdso;
938 - unsigned long tmp = (unsigned long)current->mm->context.vdso;
939 -
940 - set_isa16_mode(tmp);
941 - vdso = (void *)tmp;
942 -#else
943 void *vdso = current->mm->context.vdso;
944 -#endif
945
946 if (regs->regs[0]) {
947 switch(regs->regs[2]) {
948 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
949 index bf14da9f3e33..58a7cad0381b 100644
950 --- a/arch/mips/kernel/traps.c
951 +++ b/arch/mips/kernel/traps.c
952 @@ -144,7 +144,7 @@ static void show_backtrace(struct task_struct *task, const struct pt_regs *regs)
953 if (!task)
954 task = current;
955
956 - if (raw_show_trace || !__kernel_text_address(pc)) {
957 + if (raw_show_trace || user_mode(regs) || !__kernel_text_address(pc)) {
958 show_raw_backtrace(sp);
959 return;
960 }
961 @@ -1242,7 +1242,7 @@ static int enable_restore_fp_context(int msa)
962 err = init_fpu();
963 if (msa && !err) {
964 enable_msa();
965 - _init_msa_upper();
966 + init_msa_upper();
967 set_thread_flag(TIF_USEDMSA);
968 set_thread_flag(TIF_MSA_CTX_LIVE);
969 }
970 @@ -1305,7 +1305,7 @@ static int enable_restore_fp_context(int msa)
971 */
972 prior_msa = test_and_set_thread_flag(TIF_MSA_CTX_LIVE);
973 if (!prior_msa && was_fpu_owner) {
974 - _init_msa_upper();
975 + init_msa_upper();
976
977 goto out;
978 }
979 @@ -1322,7 +1322,7 @@ static int enable_restore_fp_context(int msa)
980 * of each vector register such that it cannot see data left
981 * behind by another task.
982 */
983 - _init_msa_upper();
984 + init_msa_upper();
985 } else {
986 /* We need to restore the vector context. */
987 restore_msa(current);
988 diff --git a/arch/mips/kernel/watch.c b/arch/mips/kernel/watch.c
989 index 2a03abb5bd2c..9b78e375118e 100644
990 --- a/arch/mips/kernel/watch.c
991 +++ b/arch/mips/kernel/watch.c
992 @@ -15,10 +15,9 @@
993 * Install the watch registers for the current thread. A maximum of
994 * four registers are installed although the machine may have more.
995 */
996 -void mips_install_watch_registers(void)
997 +void mips_install_watch_registers(struct task_struct *t)
998 {
999 - struct mips3264_watch_reg_state *watches =
1000 - &current->thread.watch.mips3264;
1001 + struct mips3264_watch_reg_state *watches = &t->thread.watch.mips3264;
1002 switch (current_cpu_data.watch_reg_use_cnt) {
1003 default:
1004 BUG();
1005 diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c
1006 index beb80f316095..927dc94a030f 100644
1007 --- a/arch/mips/lib/ashldi3.c
1008 +++ b/arch/mips/lib/ashldi3.c
1009 @@ -2,7 +2,7 @@
1010
1011 #include "libgcc.h"
1012
1013 -long long __ashldi3(long long u, word_type b)
1014 +long long notrace __ashldi3(long long u, word_type b)
1015 {
1016 DWunion uu, w;
1017 word_type bm;
1018 diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c
1019 index c884a912b660..9fdf1a598428 100644
1020 --- a/arch/mips/lib/ashrdi3.c
1021 +++ b/arch/mips/lib/ashrdi3.c
1022 @@ -2,7 +2,7 @@
1023
1024 #include "libgcc.h"
1025
1026 -long long __ashrdi3(long long u, word_type b)
1027 +long long notrace __ashrdi3(long long u, word_type b)
1028 {
1029 DWunion uu, w;
1030 word_type bm;
1031 diff --git a/arch/mips/lib/bswapdi.c b/arch/mips/lib/bswapdi.c
1032 index 77e5f9c1f005..e3e77aa52c95 100644
1033 --- a/arch/mips/lib/bswapdi.c
1034 +++ b/arch/mips/lib/bswapdi.c
1035 @@ -1,6 +1,6 @@
1036 #include <linux/module.h>
1037
1038 -unsigned long long __bswapdi2(unsigned long long u)
1039 +unsigned long long notrace __bswapdi2(unsigned long long u)
1040 {
1041 return (((u) & 0xff00000000000000ull) >> 56) |
1042 (((u) & 0x00ff000000000000ull) >> 40) |
1043 diff --git a/arch/mips/lib/bswapsi.c b/arch/mips/lib/bswapsi.c
1044 index 2b302ff121d2..530a8afe6fda 100644
1045 --- a/arch/mips/lib/bswapsi.c
1046 +++ b/arch/mips/lib/bswapsi.c
1047 @@ -1,6 +1,6 @@
1048 #include <linux/module.h>
1049
1050 -unsigned int __bswapsi2(unsigned int u)
1051 +unsigned int notrace __bswapsi2(unsigned int u)
1052 {
1053 return (((u) & 0xff000000) >> 24) |
1054 (((u) & 0x00ff0000) >> 8) |
1055 diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c
1056 index 8c1306437ed1..06857da96993 100644
1057 --- a/arch/mips/lib/cmpdi2.c
1058 +++ b/arch/mips/lib/cmpdi2.c
1059 @@ -2,7 +2,7 @@
1060
1061 #include "libgcc.h"
1062
1063 -word_type __cmpdi2(long long a, long long b)
1064 +word_type notrace __cmpdi2(long long a, long long b)
1065 {
1066 const DWunion au = {
1067 .ll = a
1068 diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c
1069 index dcf8d6810b7c..364547449c65 100644
1070 --- a/arch/mips/lib/lshrdi3.c
1071 +++ b/arch/mips/lib/lshrdi3.c
1072 @@ -2,7 +2,7 @@
1073
1074 #include "libgcc.h"
1075
1076 -long long __lshrdi3(long long u, word_type b)
1077 +long long notrace __lshrdi3(long long u, word_type b)
1078 {
1079 DWunion uu, w;
1080 word_type bm;
1081 diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c
1082 index bb4cb2f828ea..bd599f58234c 100644
1083 --- a/arch/mips/lib/ucmpdi2.c
1084 +++ b/arch/mips/lib/ucmpdi2.c
1085 @@ -2,7 +2,7 @@
1086
1087 #include "libgcc.h"
1088
1089 -word_type __ucmpdi2(unsigned long long a, unsigned long long b)
1090 +word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b)
1091 {
1092 const DWunion au = {.ll = a};
1093 const DWunion bu = {.ll = b};
1094 diff --git a/arch/mips/loongson64/Platform b/arch/mips/loongson64/Platform
1095 index 85d808924c94..0fce4608aa88 100644
1096 --- a/arch/mips/loongson64/Platform
1097 +++ b/arch/mips/loongson64/Platform
1098 @@ -31,7 +31,7 @@ cflags-$(CONFIG_CPU_LOONGSON3) += -Wa,--trap
1099 # can't easily be used safely within the kbuild framework.
1100 #
1101 ifeq ($(call cc-ifversion, -ge, 0409, y), y)
1102 - ifeq ($(call ld-ifversion, -ge, 22500000, y), y)
1103 + ifeq ($(call ld-ifversion, -ge, 225000000, y), y)
1104 cflags-$(CONFIG_CPU_LOONGSON3) += \
1105 $(call cc-option,-march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64)
1106 else
1107 diff --git a/arch/mips/loongson64/loongson-3/numa.c b/arch/mips/loongson64/loongson-3/numa.c
1108 index 6f9e010cec4d..282c5a8c2fcd 100644
1109 --- a/arch/mips/loongson64/loongson-3/numa.c
1110 +++ b/arch/mips/loongson64/loongson-3/numa.c
1111 @@ -213,10 +213,10 @@ static void __init node_mem_init(unsigned int node)
1112 BOOTMEM_DEFAULT);
1113
1114 if (node == 0 && node_end_pfn(0) >= (0xffffffff >> PAGE_SHIFT)) {
1115 - /* Reserve 0xff800000~0xffffffff for RS780E integrated GPU */
1116 + /* Reserve 0xfe000000~0xffffffff for RS780E integrated GPU */
1117 reserve_bootmem_node(NODE_DATA(node),
1118 - (node_addrspace_offset | 0xff800000),
1119 - 8 << 20, BOOTMEM_DEFAULT);
1120 + (node_addrspace_offset | 0xfe000000),
1121 + 32 << 20, BOOTMEM_DEFAULT);
1122 }
1123
1124 sparse_memory_present_with_active_regions(node);
1125 diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
1126 index cdfd44ffa51c..41d3e0e7defa 100644
1127 --- a/arch/mips/math-emu/cp1emu.c
1128 +++ b/arch/mips/math-emu/cp1emu.c
1129 @@ -445,9 +445,11 @@ static int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
1130 case spec_op:
1131 switch (insn.r_format.func) {
1132 case jalr_op:
1133 - regs->regs[insn.r_format.rd] =
1134 - regs->cp0_epc + dec_insn.pc_inc +
1135 - dec_insn.next_pc_inc;
1136 + if (insn.r_format.rd != 0) {
1137 + regs->regs[insn.r_format.rd] =
1138 + regs->cp0_epc + dec_insn.pc_inc +
1139 + dec_insn.next_pc_inc;
1140 + }
1141 /* Fall through */
1142 case jr_op:
1143 /* For R6, JR already emulated in jalr_op */
1144 diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
1145 index 3f159caf6dbc..bf04c6c479a4 100644
1146 --- a/arch/mips/mm/cache.c
1147 +++ b/arch/mips/mm/cache.c
1148 @@ -16,6 +16,7 @@
1149 #include <linux/mm.h>
1150
1151 #include <asm/cacheflush.h>
1152 +#include <asm/highmem.h>
1153 #include <asm/processor.h>
1154 #include <asm/cpu.h>
1155 #include <asm/cpu-features.h>
1156 @@ -83,8 +84,6 @@ void __flush_dcache_page(struct page *page)
1157 struct address_space *mapping = page_mapping(page);
1158 unsigned long addr;
1159
1160 - if (PageHighMem(page))
1161 - return;
1162 if (mapping && !mapping_mapped(mapping)) {
1163 SetPageDcacheDirty(page);
1164 return;
1165 @@ -95,8 +94,15 @@ void __flush_dcache_page(struct page *page)
1166 * case is for exec env/arg pages and those are %99 certainly going to
1167 * get faulted into the tlb (and thus flushed) anyways.
1168 */
1169 - addr = (unsigned long) page_address(page);
1170 + if (PageHighMem(page))
1171 + addr = (unsigned long)kmap_atomic(page);
1172 + else
1173 + addr = (unsigned long)page_address(page);
1174 +
1175 flush_data_cache_page(addr);
1176 +
1177 + if (PageHighMem(page))
1178 + __kunmap_atomic((void *)addr);
1179 }
1180
1181 EXPORT_SYMBOL(__flush_dcache_page);
1182 @@ -119,33 +125,28 @@ void __flush_anon_page(struct page *page, unsigned long vmaddr)
1183
1184 EXPORT_SYMBOL(__flush_anon_page);
1185
1186 -void __flush_icache_page(struct vm_area_struct *vma, struct page *page)
1187 -{
1188 - unsigned long addr;
1189 -
1190 - if (PageHighMem(page))
1191 - return;
1192 -
1193 - addr = (unsigned long) page_address(page);
1194 - flush_data_cache_page(addr);
1195 -}
1196 -EXPORT_SYMBOL_GPL(__flush_icache_page);
1197 -
1198 -void __update_cache(struct vm_area_struct *vma, unsigned long address,
1199 - pte_t pte)
1200 +void __update_cache(unsigned long address, pte_t pte)
1201 {
1202 struct page *page;
1203 unsigned long pfn, addr;
1204 - int exec = (vma->vm_flags & VM_EXEC) && !cpu_has_ic_fills_f_dc;
1205 + int exec = !pte_no_exec(pte) && !cpu_has_ic_fills_f_dc;
1206
1207 pfn = pte_pfn(pte);
1208 if (unlikely(!pfn_valid(pfn)))
1209 return;
1210 page = pfn_to_page(pfn);
1211 - if (page_mapping(page) && Page_dcache_dirty(page)) {
1212 - addr = (unsigned long) page_address(page);
1213 + if (Page_dcache_dirty(page)) {
1214 + if (PageHighMem(page))
1215 + addr = (unsigned long)kmap_atomic(page);
1216 + else
1217 + addr = (unsigned long)page_address(page);
1218 +
1219 if (exec || pages_do_alias(addr, address & PAGE_MASK))
1220 flush_data_cache_page(addr);
1221 +
1222 + if (PageHighMem(page))
1223 + __kunmap_atomic((void *)addr);
1224 +
1225 ClearPageDcacheDirty(page);
1226 }
1227 }
1228 diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
1229 index ee3617c0c5e2..f37e6ba40f52 100644
1230 --- a/arch/mips/vdso/Makefile
1231 +++ b/arch/mips/vdso/Makefile
1232 @@ -5,10 +5,12 @@ obj-vdso-y := elf.o gettimeofday.o sigreturn.o
1233 ccflags-vdso := \
1234 $(filter -I%,$(KBUILD_CFLAGS)) \
1235 $(filter -E%,$(KBUILD_CFLAGS)) \
1236 + $(filter -mmicromips,$(KBUILD_CFLAGS)) \
1237 $(filter -march=%,$(KBUILD_CFLAGS))
1238 cflags-vdso := $(ccflags-vdso) \
1239 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
1240 - -O2 -g -fPIC -fno-common -fno-builtin -G 0 -DDISABLE_BRANCH_PROFILING \
1241 + -O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
1242 + -DDISABLE_BRANCH_PROFILING \
1243 $(call cc-option, -fno-stack-protector)
1244 aflags-vdso := $(ccflags-vdso) \
1245 $(filter -I%,$(KBUILD_CFLAGS)) \
1246 diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
1247 index 40e4d4a27663..b34e8a54f7db 100644
1248 --- a/arch/powerpc/kernel/eeh.c
1249 +++ b/arch/powerpc/kernel/eeh.c
1250 @@ -1072,7 +1072,7 @@ void eeh_add_device_early(struct pci_dn *pdn)
1251 struct pci_controller *phb;
1252 struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
1253
1254 - if (!edev || !eeh_enabled())
1255 + if (!edev)
1256 return;
1257
1258 if (!eeh_has_flag(EEH_PROBE_MODE_DEVTREE))
1259 diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
1260 index 650cfb31ea3d..54958282604a 100644
1261 --- a/arch/powerpc/kernel/eeh_driver.c
1262 +++ b/arch/powerpc/kernel/eeh_driver.c
1263 @@ -166,6 +166,16 @@ static void *eeh_dev_save_state(void *data, void *userdata)
1264 if (!edev)
1265 return NULL;
1266
1267 + /*
1268 + * We cannot access the config space on some adapters.
1269 + * Otherwise, it will cause fenced PHB. We don't save
1270 + * the content in their config space and will restore
1271 + * from the initial config space saved when the EEH
1272 + * device is created.
1273 + */
1274 + if (edev->pe && (edev->pe->state & EEH_PE_CFG_RESTRICTED))
1275 + return NULL;
1276 +
1277 pdev = eeh_dev_to_pci_dev(edev);
1278 if (!pdev)
1279 return NULL;
1280 @@ -305,6 +315,19 @@ static void *eeh_dev_restore_state(void *data, void *userdata)
1281 if (!edev)
1282 return NULL;
1283
1284 + /*
1285 + * The content in the config space isn't saved because
1286 + * the blocked config space on some adapters. We have
1287 + * to restore the initial saved config space when the
1288 + * EEH device is created.
1289 + */
1290 + if (edev->pe && (edev->pe->state & EEH_PE_CFG_RESTRICTED)) {
1291 + if (list_is_last(&edev->list, &edev->pe->edevs))
1292 + eeh_pe_restore_bars(edev->pe);
1293 +
1294 + return NULL;
1295 + }
1296 +
1297 pdev = eeh_dev_to_pci_dev(edev);
1298 if (!pdev)
1299 return NULL;
1300 @@ -504,9 +527,6 @@ int eeh_pe_reset_and_recover(struct eeh_pe *pe)
1301 /* Save states */
1302 eeh_pe_dev_traverse(pe, eeh_dev_save_state, NULL);
1303
1304 - /* Report error */
1305 - eeh_pe_dev_traverse(pe, eeh_report_error, &result);
1306 -
1307 /* Issue reset */
1308 ret = eeh_reset_pe(pe);
1309 if (ret) {
1310 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
1311 index 7716cebf4b8e..2b66f25d40db 100644
1312 --- a/arch/powerpc/kernel/exceptions-64s.S
1313 +++ b/arch/powerpc/kernel/exceptions-64s.S
1314 @@ -953,11 +953,6 @@ hv_facility_unavailable_relon_trampoline:
1315 #endif
1316 STD_RELON_EXCEPTION_PSERIES(0x5700, 0x1700, altivec_assist)
1317
1318 - /* Other future vectors */
1319 - .align 7
1320 - .globl __end_interrupts
1321 -__end_interrupts:
1322 -
1323 .align 7
1324 system_call_entry:
1325 b system_call_common
1326 @@ -1244,6 +1239,17 @@ __end_handlers:
1327 STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable)
1328 STD_RELON_EXCEPTION_HV_OOL(0xf80, hv_facility_unavailable)
1329
1330 + /*
1331 + * The __end_interrupts marker must be past the out-of-line (OOL)
1332 + * handlers, so that they are copied to real address 0x100 when running
1333 + * a relocatable kernel. This ensures they can be reached from the short
1334 + * trampoline handlers (like 0x4f00, 0x4f20, etc.) which branch
1335 + * directly, without using LOAD_HANDLER().
1336 + */
1337 + .align 7
1338 + .globl __end_interrupts
1339 +__end_interrupts:
1340 +
1341 #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
1342 /*
1343 * Data area reserved for FWNMI option.
1344 diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
1345 index 7ab29518a3b9..e345891450c3 100644
1346 --- a/arch/x86/xen/setup.c
1347 +++ b/arch/x86/xen/setup.c
1348 @@ -393,6 +393,9 @@ static unsigned long __init xen_set_identity_and_remap_chunk(
1349 unsigned long i = 0;
1350 unsigned long n = end_pfn - start_pfn;
1351
1352 + if (remap_pfn == 0)
1353 + remap_pfn = nr_pages;
1354 +
1355 while (i < n) {
1356 unsigned long cur_pfn = start_pfn + i;
1357 unsigned long left = n - i;
1358 @@ -438,17 +441,29 @@ static unsigned long __init xen_set_identity_and_remap_chunk(
1359 return remap_pfn;
1360 }
1361
1362 -static void __init xen_set_identity_and_remap(unsigned long nr_pages)
1363 +static unsigned long __init xen_count_remap_pages(
1364 + unsigned long start_pfn, unsigned long end_pfn, unsigned long nr_pages,
1365 + unsigned long remap_pages)
1366 +{
1367 + if (start_pfn >= nr_pages)
1368 + return remap_pages;
1369 +
1370 + return remap_pages + min(end_pfn, nr_pages) - start_pfn;
1371 +}
1372 +
1373 +static unsigned long __init xen_foreach_remap_area(unsigned long nr_pages,
1374 + unsigned long (*func)(unsigned long start_pfn, unsigned long end_pfn,
1375 + unsigned long nr_pages, unsigned long last_val))
1376 {
1377 phys_addr_t start = 0;
1378 - unsigned long last_pfn = nr_pages;
1379 + unsigned long ret_val = 0;
1380 const struct e820entry *entry = xen_e820_map;
1381 int i;
1382
1383 /*
1384 * Combine non-RAM regions and gaps until a RAM region (or the
1385 - * end of the map) is reached, then set the 1:1 map and
1386 - * remap the memory in those non-RAM regions.
1387 + * end of the map) is reached, then call the provided function
1388 + * to perform its duty on the non-RAM region.
1389 *
1390 * The combined non-RAM regions are rounded to a whole number
1391 * of pages so any partial pages are accessible via the 1:1
1392 @@ -466,14 +481,13 @@ static void __init xen_set_identity_and_remap(unsigned long nr_pages)
1393 end_pfn = PFN_UP(entry->addr);
1394
1395 if (start_pfn < end_pfn)
1396 - last_pfn = xen_set_identity_and_remap_chunk(
1397 - start_pfn, end_pfn, nr_pages,
1398 - last_pfn);
1399 + ret_val = func(start_pfn, end_pfn, nr_pages,
1400 + ret_val);
1401 start = end;
1402 }
1403 }
1404
1405 - pr_info("Released %ld page(s)\n", xen_released_pages);
1406 + return ret_val;
1407 }
1408
1409 /*
1410 @@ -596,35 +610,6 @@ static void __init xen_ignore_unusable(void)
1411 }
1412 }
1413
1414 -static unsigned long __init xen_count_remap_pages(unsigned long max_pfn)
1415 -{
1416 - unsigned long extra = 0;
1417 - unsigned long start_pfn, end_pfn;
1418 - const struct e820entry *entry = xen_e820_map;
1419 - int i;
1420 -
1421 - end_pfn = 0;
1422 - for (i = 0; i < xen_e820_map_entries; i++, entry++) {
1423 - start_pfn = PFN_DOWN(entry->addr);
1424 - /* Adjacent regions on non-page boundaries handling! */
1425 - end_pfn = min(end_pfn, start_pfn);
1426 -
1427 - if (start_pfn >= max_pfn)
1428 - return extra + max_pfn - end_pfn;
1429 -
1430 - /* Add any holes in map to result. */
1431 - extra += start_pfn - end_pfn;
1432 -
1433 - end_pfn = PFN_UP(entry->addr + entry->size);
1434 - end_pfn = min(end_pfn, max_pfn);
1435 -
1436 - if (entry->type != E820_RAM)
1437 - extra += end_pfn - start_pfn;
1438 - }
1439 -
1440 - return extra;
1441 -}
1442 -
1443 bool __init xen_is_e820_reserved(phys_addr_t start, phys_addr_t size)
1444 {
1445 struct e820entry *entry;
1446 @@ -804,7 +789,7 @@ char * __init xen_memory_setup(void)
1447 max_pages = xen_get_max_pages();
1448
1449 /* How many extra pages do we need due to remapping? */
1450 - max_pages += xen_count_remap_pages(max_pfn);
1451 + max_pages += xen_foreach_remap_area(max_pfn, xen_count_remap_pages);
1452
1453 if (max_pages > max_pfn)
1454 extra_pages += max_pages - max_pfn;
1455 @@ -922,7 +907,9 @@ char * __init xen_memory_setup(void)
1456 * Set identity map on non-RAM pages and prepare remapping the
1457 * underlying RAM.
1458 */
1459 - xen_set_identity_and_remap(max_pfn);
1460 + xen_foreach_remap_area(max_pfn, xen_set_identity_and_remap_chunk);
1461 +
1462 + pr_info("Released %ld page(s)\n", xen_released_pages);
1463
1464 return "Xen";
1465 }
1466 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
1467 index 6e7c3ccea24b..27aea96036c4 100644
1468 --- a/drivers/base/power/main.c
1469 +++ b/drivers/base/power/main.c
1470 @@ -1267,14 +1267,15 @@ int dpm_suspend_late(pm_message_t state)
1471 error = device_suspend_late(dev);
1472
1473 mutex_lock(&dpm_list_mtx);
1474 + if (!list_empty(&dev->power.entry))
1475 + list_move(&dev->power.entry, &dpm_late_early_list);
1476 +
1477 if (error) {
1478 pm_dev_err(dev, state, " late", error);
1479 dpm_save_failed_dev(dev_name(dev));
1480 put_device(dev);
1481 break;
1482 }
1483 - if (!list_empty(&dev->power.entry))
1484 - list_move(&dev->power.entry, &dpm_late_early_list);
1485 put_device(dev);
1486
1487 if (async_error)
1488 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
1489 index 4c7055009bd6..b74690418504 100644
1490 --- a/drivers/base/power/runtime.c
1491 +++ b/drivers/base/power/runtime.c
1492 @@ -1506,11 +1506,16 @@ int pm_runtime_force_resume(struct device *dev)
1493 goto out;
1494 }
1495
1496 - ret = callback(dev);
1497 + ret = pm_runtime_set_active(dev);
1498 if (ret)
1499 goto out;
1500
1501 - pm_runtime_set_active(dev);
1502 + ret = callback(dev);
1503 + if (ret) {
1504 + pm_runtime_set_suspended(dev);
1505 + goto out;
1506 + }
1507 +
1508 pm_runtime_mark_last_busy(dev);
1509 out:
1510 pm_runtime_enable(dev);
1511 diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c
1512 index 30cf4623184f..aa30af5f0f2b 100644
1513 --- a/drivers/char/hw_random/exynos-rng.c
1514 +++ b/drivers/char/hw_random/exynos-rng.c
1515 @@ -89,6 +89,7 @@ static int exynos_read(struct hwrng *rng, void *buf,
1516 struct exynos_rng, rng);
1517 u32 *data = buf;
1518 int retry = 100;
1519 + int ret = 4;
1520
1521 pm_runtime_get_sync(exynos_rng->dev);
1522
1523 @@ -97,17 +98,20 @@ static int exynos_read(struct hwrng *rng, void *buf,
1524 while (!(exynos_rng_readl(exynos_rng,
1525 EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE) && --retry)
1526 cpu_relax();
1527 - if (!retry)
1528 - return -ETIMEDOUT;
1529 + if (!retry) {
1530 + ret = -ETIMEDOUT;
1531 + goto out;
1532 + }
1533
1534 exynos_rng_writel(exynos_rng, PRNG_DONE, EXYNOS_PRNG_STATUS_OFFSET);
1535
1536 *data = exynos_rng_readl(exynos_rng, EXYNOS_PRNG_OUT1_OFFSET);
1537
1538 +out:
1539 pm_runtime_mark_last_busy(exynos_rng->dev);
1540 pm_runtime_put_sync_autosuspend(exynos_rng->dev);
1541
1542 - return 4;
1543 + return ret;
1544 }
1545
1546 static int exynos_rng_probe(struct platform_device *pdev)
1547 diff --git a/drivers/clk/at91/clk-h32mx.c b/drivers/clk/at91/clk-h32mx.c
1548 index 61566bcefa53..a165230e7eda 100644
1549 --- a/drivers/clk/at91/clk-h32mx.c
1550 +++ b/drivers/clk/at91/clk-h32mx.c
1551 @@ -116,7 +116,7 @@ void __init of_sama5d4_clk_h32mx_setup(struct device_node *np,
1552 h32mxclk->pmc = pmc;
1553
1554 clk = clk_register(NULL, &h32mxclk->hw);
1555 - if (!clk) {
1556 + if (IS_ERR(clk)) {
1557 kfree(h32mxclk);
1558 return;
1559 }
1560 diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
1561 index dd2856b5633c..af19245e6a61 100644
1562 --- a/drivers/clk/bcm/clk-bcm2835.c
1563 +++ b/drivers/clk/bcm/clk-bcm2835.c
1564 @@ -51,6 +51,7 @@
1565 #define CM_GNRICCTL 0x000
1566 #define CM_GNRICDIV 0x004
1567 # define CM_DIV_FRAC_BITS 12
1568 +# define CM_DIV_FRAC_MASK GENMASK(CM_DIV_FRAC_BITS - 1, 0)
1569
1570 #define CM_VPUCTL 0x008
1571 #define CM_VPUDIV 0x00c
1572 @@ -115,6 +116,7 @@
1573 # define CM_GATE BIT(CM_GATE_BIT)
1574 # define CM_BUSY BIT(7)
1575 # define CM_BUSYD BIT(8)
1576 +# define CM_FRAC BIT(9)
1577 # define CM_SRC_SHIFT 0
1578 # define CM_SRC_BITS 4
1579 # define CM_SRC_MASK 0xf
1580 @@ -634,6 +636,7 @@ struct bcm2835_clock_data {
1581 u32 frac_bits;
1582
1583 bool is_vpu_clock;
1584 + bool is_mash_clock;
1585 };
1586
1587 static const char *const bcm2835_clock_per_parents[] = {
1588 @@ -815,6 +818,7 @@ static const struct bcm2835_clock_data bcm2835_clock_pwm_data = {
1589 .div_reg = CM_PWMDIV,
1590 .int_bits = 12,
1591 .frac_bits = 12,
1592 + .is_mash_clock = true,
1593 };
1594
1595 struct bcm2835_pll {
1596 @@ -900,8 +904,14 @@ static void bcm2835_pll_off(struct clk_hw *hw)
1597 struct bcm2835_cprman *cprman = pll->cprman;
1598 const struct bcm2835_pll_data *data = pll->data;
1599
1600 - cprman_write(cprman, data->cm_ctrl_reg, CM_PLL_ANARST);
1601 - cprman_write(cprman, data->a2w_ctrl_reg, A2W_PLL_CTRL_PWRDN);
1602 + spin_lock(&cprman->regs_lock);
1603 + cprman_write(cprman, data->cm_ctrl_reg,
1604 + cprman_read(cprman, data->cm_ctrl_reg) |
1605 + CM_PLL_ANARST);
1606 + cprman_write(cprman, data->a2w_ctrl_reg,
1607 + cprman_read(cprman, data->a2w_ctrl_reg) |
1608 + A2W_PLL_CTRL_PWRDN);
1609 + spin_unlock(&cprman->regs_lock);
1610 }
1611
1612 static int bcm2835_pll_on(struct clk_hw *hw)
1613 @@ -911,6 +921,10 @@ static int bcm2835_pll_on(struct clk_hw *hw)
1614 const struct bcm2835_pll_data *data = pll->data;
1615 ktime_t timeout;
1616
1617 + cprman_write(cprman, data->a2w_ctrl_reg,
1618 + cprman_read(cprman, data->a2w_ctrl_reg) &
1619 + ~A2W_PLL_CTRL_PWRDN);
1620 +
1621 /* Take the PLL out of reset. */
1622 cprman_write(cprman, data->cm_ctrl_reg,
1623 cprman_read(cprman, data->cm_ctrl_reg) & ~CM_PLL_ANARST);
1624 @@ -1173,7 +1187,7 @@ static u32 bcm2835_clock_choose_div(struct clk_hw *hw,
1625 GENMASK(CM_DIV_FRAC_BITS - data->frac_bits, 0) >> 1;
1626 u64 temp = (u64)parent_rate << CM_DIV_FRAC_BITS;
1627 u64 rem;
1628 - u32 div;
1629 + u32 div, mindiv, maxdiv;
1630
1631 rem = do_div(temp, rate);
1632 div = temp;
1633 @@ -1183,10 +1197,23 @@ static u32 bcm2835_clock_choose_div(struct clk_hw *hw,
1634 div += unused_frac_mask + 1;
1635 div &= ~unused_frac_mask;
1636
1637 - /* Clamp to the limits. */
1638 - div = max(div, unused_frac_mask + 1);
1639 - div = min_t(u32, div, GENMASK(data->int_bits + CM_DIV_FRAC_BITS - 1,
1640 - CM_DIV_FRAC_BITS - data->frac_bits));
1641 + /* different clamping limits apply for a mash clock */
1642 + if (data->is_mash_clock) {
1643 + /* clamp to min divider of 2 */
1644 + mindiv = 2 << CM_DIV_FRAC_BITS;
1645 + /* clamp to the highest possible integer divider */
1646 + maxdiv = (BIT(data->int_bits) - 1) << CM_DIV_FRAC_BITS;
1647 + } else {
1648 + /* clamp to min divider of 1 */
1649 + mindiv = 1 << CM_DIV_FRAC_BITS;
1650 + /* clamp to the highest possible fractional divider */
1651 + maxdiv = GENMASK(data->int_bits + CM_DIV_FRAC_BITS - 1,
1652 + CM_DIV_FRAC_BITS - data->frac_bits);
1653 + }
1654 +
1655 + /* apply the clamping limits */
1656 + div = max_t(u32, div, mindiv);
1657 + div = min_t(u32, div, maxdiv);
1658
1659 return div;
1660 }
1661 @@ -1280,9 +1307,26 @@ static int bcm2835_clock_set_rate(struct clk_hw *hw,
1662 struct bcm2835_cprman *cprman = clock->cprman;
1663 const struct bcm2835_clock_data *data = clock->data;
1664 u32 div = bcm2835_clock_choose_div(hw, rate, parent_rate, false);
1665 + u32 ctl;
1666 +
1667 + spin_lock(&cprman->regs_lock);
1668 +
1669 + /*
1670 + * Setting up frac support
1671 + *
1672 + * In principle it is recommended to stop/start the clock first,
1673 + * but as we set CLK_SET_RATE_GATE during registration of the
1674 + * clock this requirement should be take care of by the
1675 + * clk-framework.
1676 + */
1677 + ctl = cprman_read(cprman, data->ctl_reg) & ~CM_FRAC;
1678 + ctl |= (div & CM_DIV_FRAC_MASK) ? CM_FRAC : 0;
1679 + cprman_write(cprman, data->ctl_reg, ctl);
1680
1681 cprman_write(cprman, data->div_reg, div);
1682
1683 + spin_unlock(&cprman->regs_lock);
1684 +
1685 return 0;
1686 }
1687
1688 diff --git a/drivers/clk/imx/clk-imx35.c b/drivers/clk/imx/clk-imx35.c
1689 index a71d24cb4c06..b0978d3b83e2 100644
1690 --- a/drivers/clk/imx/clk-imx35.c
1691 +++ b/drivers/clk/imx/clk-imx35.c
1692 @@ -66,7 +66,7 @@ static const char *std_sel[] = {"ppll", "arm"};
1693 static const char *ipg_per_sel[] = {"ahb_per_div", "arm_per_div"};
1694
1695 enum mx35_clks {
1696 - ckih, ckil, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg,
1697 + ckih, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg,
1698 arm_per_div, ahb_per_div, ipg_per, uart_sel, uart_div, esdhc_sel,
1699 esdhc1_div, esdhc2_div, esdhc3_div, spdif_sel, spdif_div_pre,
1700 spdif_div_post, ssi_sel, ssi1_div_pre, ssi1_div_post, ssi2_div_pre,
1701 @@ -79,7 +79,7 @@ enum mx35_clks {
1702 rtc_gate, rtic_gate, scc_gate, sdma_gate, spba_gate, spdif_gate,
1703 ssi1_gate, ssi2_gate, uart1_gate, uart2_gate, uart3_gate, usbotg_gate,
1704 wdog_gate, max_gate, admux_gate, csi_gate, csi_div, csi_sel, iim_gate,
1705 - gpu2d_gate, clk_max
1706 + gpu2d_gate, ckil, clk_max
1707 };
1708
1709 static struct clk *clk[clk_max];
1710 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
1711 index f996efc56605..0db185762a10 100644
1712 --- a/drivers/cpuidle/cpuidle.c
1713 +++ b/drivers/cpuidle/cpuidle.c
1714 @@ -214,7 +214,7 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
1715 tick_broadcast_exit();
1716 }
1717
1718 - if (!cpuidle_state_is_coupled(drv, entered_state))
1719 + if (!cpuidle_state_is_coupled(drv, index))
1720 local_irq_enable();
1721
1722 diff = ktime_to_us(ktime_sub(time_end, time_start));
1723 @@ -433,6 +433,8 @@ static void __cpuidle_unregister_device(struct cpuidle_device *dev)
1724 list_del(&dev->device_list);
1725 per_cpu(cpuidle_devices, dev->cpu) = NULL;
1726 module_put(drv->owner);
1727 +
1728 + dev->registered = 0;
1729 }
1730
1731 static void __cpuidle_device_init(struct cpuidle_device *dev)
1732 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1733 index 119cdc2c43e7..7ef2c13921b4 100644
1734 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1735 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1736 @@ -194,12 +194,12 @@ int amdgpu_connector_get_monitor_bpc(struct drm_connector *connector)
1737 bpc = 8;
1738 DRM_DEBUG("%s: HDMI deep color 10 bpc exceeds max tmds clock. Using %d bpc.\n",
1739 connector->name, bpc);
1740 - } else if (bpc > 8) {
1741 - /* max_tmds_clock missing, but hdmi spec mandates it for deep color. */
1742 - DRM_DEBUG("%s: Required max tmds clock for HDMI deep color missing. Using 8 bpc.\n",
1743 - connector->name);
1744 - bpc = 8;
1745 }
1746 + } else if (bpc > 8) {
1747 + /* max_tmds_clock missing, but hdmi spec mandates it for deep color. */
1748 + DRM_DEBUG("%s: Required max tmds clock for HDMI deep color missing. Using 8 bpc.\n",
1749 + connector->name);
1750 + bpc = 8;
1751 }
1752 }
1753
1754 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
1755 index 7b7f4aba60c0..fe36caf1b7d7 100644
1756 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
1757 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
1758 @@ -150,7 +150,7 @@ u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
1759 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
1760 amdgpu_crtc = to_amdgpu_crtc(crtc);
1761 if (crtc->enabled && amdgpu_crtc->enabled && amdgpu_crtc->hw_mode.clock) {
1762 - vrefresh = amdgpu_crtc->hw_mode.vrefresh;
1763 + vrefresh = drm_mode_vrefresh(&amdgpu_crtc->hw_mode);
1764 break;
1765 }
1766 }
1767 diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
1768 index 9a7b44616b55..ee9914d0e5c6 100644
1769 --- a/drivers/gpu/drm/drm_atomic.c
1770 +++ b/drivers/gpu/drm/drm_atomic.c
1771 @@ -138,7 +138,7 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
1772 for (i = 0; i < state->num_connector; i++) {
1773 struct drm_connector *connector = state->connectors[i];
1774
1775 - if (!connector)
1776 + if (!connector || !connector->funcs)
1777 continue;
1778
1779 /*
1780 diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
1781 index 1e103c4c6ee0..f8e07477b273 100644
1782 --- a/drivers/gpu/drm/drm_fb_helper.c
1783 +++ b/drivers/gpu/drm/drm_fb_helper.c
1784 @@ -1899,7 +1899,6 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
1785 int n, int width, int height)
1786 {
1787 int c, o;
1788 - struct drm_device *dev = fb_helper->dev;
1789 struct drm_connector *connector;
1790 const struct drm_connector_helper_funcs *connector_funcs;
1791 struct drm_encoder *encoder;
1792 @@ -1918,7 +1917,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
1793 if (modes[n] == NULL)
1794 return best_score;
1795
1796 - crtcs = kzalloc(dev->mode_config.num_connector *
1797 + crtcs = kzalloc(fb_helper->connector_count *
1798 sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL);
1799 if (!crtcs)
1800 return best_score;
1801 @@ -1964,7 +1963,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
1802 if (score > best_score) {
1803 best_score = score;
1804 memcpy(best_crtcs, crtcs,
1805 - dev->mode_config.num_connector *
1806 + fb_helper->connector_count *
1807 sizeof(struct drm_fb_helper_crtc *));
1808 }
1809 }
1810 diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c
1811 index 6b43ae3ffd73..1616af209bfc 100644
1812 --- a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c
1813 +++ b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c
1814 @@ -72,7 +72,7 @@ static const char *const dsi_errors[] = {
1815 "RX Prot Violation",
1816 "HS Generic Write FIFO Full",
1817 "LP Generic Write FIFO Full",
1818 - "Generic Read Data Avail"
1819 + "Generic Read Data Avail",
1820 "Special Packet Sent",
1821 "Tearing Effect",
1822 };
1823 diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
1824 index d0b1c9afa35e..6314446f58fa 100644
1825 --- a/drivers/gpu/drm/i915/intel_atomic.c
1826 +++ b/drivers/gpu/drm/i915/intel_atomic.c
1827 @@ -96,7 +96,8 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc)
1828 crtc_state->update_pipe = false;
1829 crtc_state->disable_lp_wm = false;
1830 crtc_state->disable_cxsr = false;
1831 - crtc_state->wm_changed = false;
1832 + crtc_state->update_wm_pre = false;
1833 + crtc_state->update_wm_post = false;
1834
1835 return &crtc_state->base;
1836 }
1837 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
1838 index 39b00b9daf2d..207391e89599 100644
1839 --- a/drivers/gpu/drm/i915/intel_display.c
1840 +++ b/drivers/gpu/drm/i915/intel_display.c
1841 @@ -4816,7 +4816,7 @@ static void intel_post_plane_update(struct intel_crtc *crtc)
1842
1843 crtc->wm.cxsr_allowed = true;
1844
1845 - if (pipe_config->wm_changed && pipe_config->base.active)
1846 + if (pipe_config->update_wm_post && pipe_config->base.active)
1847 intel_update_watermarks(&crtc->base);
1848
1849 if (atomic->update_fbc)
1850 @@ -4850,7 +4850,7 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)
1851 intel_set_memory_cxsr(dev_priv, false);
1852 }
1853
1854 - if (!needs_modeset(&pipe_config->base) && pipe_config->wm_changed)
1855 + if (!needs_modeset(&pipe_config->base) && pipe_config->update_wm_pre)
1856 intel_update_watermarks(&crtc->base);
1857 }
1858
1859 @@ -6229,6 +6229,7 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc)
1860
1861 intel_crtc_load_lut(crtc);
1862
1863 + intel_update_watermarks(crtc);
1864 intel_enable_pipe(intel_crtc);
1865
1866 assert_vblank_disabled(crtc);
1867 @@ -11881,8 +11882,14 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
1868 plane->base.id, was_visible, visible,
1869 turn_off, turn_on, mode_changed);
1870
1871 - if (turn_on || turn_off) {
1872 - pipe_config->wm_changed = true;
1873 + if (turn_on) {
1874 + pipe_config->update_wm_pre = true;
1875 +
1876 + /* must disable cxsr around plane enable/disable */
1877 + if (plane->type != DRM_PLANE_TYPE_CURSOR)
1878 + pipe_config->disable_cxsr = true;
1879 + } else if (turn_off) {
1880 + pipe_config->update_wm_post = true;
1881
1882 /* must disable cxsr around plane enable/disable */
1883 if (plane->type != DRM_PLANE_TYPE_CURSOR) {
1884 @@ -11891,7 +11898,9 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
1885 pipe_config->disable_cxsr = true;
1886 }
1887 } else if (intel_wm_need_update(plane, plane_state)) {
1888 - pipe_config->wm_changed = true;
1889 + /* FIXME bollocks */
1890 + pipe_config->update_wm_pre = true;
1891 + pipe_config->update_wm_post = true;
1892 }
1893
1894 if (visible || was_visible)
1895 @@ -12036,7 +12045,7 @@ static int intel_crtc_atomic_check(struct drm_crtc *crtc,
1896 }
1897
1898 if (mode_changed && !crtc_state->active)
1899 - pipe_config->wm_changed = true;
1900 + pipe_config->update_wm_post = true;
1901
1902 if (mode_changed && crtc_state->enable &&
1903 dev_priv->display.crtc_compute_clock &&
1904 diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
1905 index 1ae61f488987..c6f045ecb15a 100644
1906 --- a/drivers/gpu/drm/i915/intel_drv.h
1907 +++ b/drivers/gpu/drm/i915/intel_drv.h
1908 @@ -367,7 +367,7 @@ struct intel_crtc_state {
1909
1910 bool update_pipe; /* can a fast modeset be performed? */
1911 bool disable_cxsr;
1912 - bool wm_changed; /* watermarks are updated */
1913 + bool update_wm_pre, update_wm_post; /* watermarks are updated */
1914
1915 /* Pipe source size (ie. panel fitter input size)
1916 * All planes will be positioned inside this space,
1917 diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
1918 index bea75cafc623..1281cfce1343 100644
1919 --- a/drivers/gpu/drm/i915/intel_fbdev.c
1920 +++ b/drivers/gpu/drm/i915/intel_fbdev.c
1921 @@ -368,12 +368,12 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
1922 uint64_t conn_configured = 0, mask;
1923 int pass = 0;
1924
1925 - save_enabled = kcalloc(dev->mode_config.num_connector, sizeof(bool),
1926 + save_enabled = kcalloc(fb_helper->connector_count, sizeof(bool),
1927 GFP_KERNEL);
1928 if (!save_enabled)
1929 return false;
1930
1931 - memcpy(save_enabled, enabled, dev->mode_config.num_connector);
1932 + memcpy(save_enabled, enabled, fb_helper->connector_count);
1933 mask = (1 << fb_helper->connector_count) - 1;
1934 retry:
1935 for (i = 0; i < fb_helper->connector_count; i++) {
1936 @@ -507,7 +507,7 @@ retry:
1937 if (fallback) {
1938 bail:
1939 DRM_DEBUG_KMS("Not using firmware configuration\n");
1940 - memcpy(enabled, save_enabled, dev->mode_config.num_connector);
1941 + memcpy(enabled, save_enabled, fb_helper->connector_count);
1942 kfree(save_enabled);
1943 return false;
1944 }
1945 diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
1946 index 0eae3994e5e3..52bb509a1025 100644
1947 --- a/drivers/gpu/drm/i915/intel_pm.c
1948 +++ b/drivers/gpu/drm/i915/intel_pm.c
1949 @@ -3812,6 +3812,8 @@ static void ilk_pipe_wm_get_hw_state(struct drm_crtc *crtc)
1950 if (IS_HASWELL(dev) || IS_BROADWELL(dev))
1951 hw->wm_linetime[pipe] = I915_READ(PIPE_WM_LINETIME(pipe));
1952
1953 + memset(active, 0, sizeof(*active));
1954 +
1955 active->pipe_enabled = intel_crtc->active;
1956
1957 if (active->pipe_enabled) {
1958 diff --git a/drivers/gpu/drm/i915/intel_psr.c b/drivers/gpu/drm/i915/intel_psr.c
1959 index 9ccff3011523..ab0e4b69ce21 100644
1960 --- a/drivers/gpu/drm/i915/intel_psr.c
1961 +++ b/drivers/gpu/drm/i915/intel_psr.c
1962 @@ -275,19 +275,58 @@ static void hsw_psr_enable_source(struct intel_dp *intel_dp)
1963 * with the 5 or 6 idle patterns.
1964 */
1965 uint32_t idle_frames = max(6, dev_priv->vbt.psr.idle_frames);
1966 - uint32_t val = 0x0;
1967 + uint32_t val = EDP_PSR_ENABLE;
1968 +
1969 + val |= max_sleep_time << EDP_PSR_MAX_SLEEP_TIME_SHIFT;
1970 + val |= idle_frames << EDP_PSR_IDLE_FRAME_SHIFT;
1971
1972 if (IS_HASWELL(dev))
1973 val |= EDP_PSR_MIN_LINK_ENTRY_TIME_8_LINES;
1974
1975 - I915_WRITE(EDP_PSR_CTL, val |
1976 - max_sleep_time << EDP_PSR_MAX_SLEEP_TIME_SHIFT |
1977 - idle_frames << EDP_PSR_IDLE_FRAME_SHIFT |
1978 - EDP_PSR_ENABLE);
1979 + if (dev_priv->vbt.psr.tp1_wakeup_time > 5)
1980 + val |= EDP_PSR_TP1_TIME_2500us;
1981 + else if (dev_priv->vbt.psr.tp1_wakeup_time > 1)
1982 + val |= EDP_PSR_TP1_TIME_500us;
1983 + else if (dev_priv->vbt.psr.tp1_wakeup_time > 0)
1984 + val |= EDP_PSR_TP1_TIME_100us;
1985 + else
1986 + val |= EDP_PSR_TP1_TIME_0us;
1987 +
1988 + if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
1989 + val |= EDP_PSR_TP2_TP3_TIME_2500us;
1990 + else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
1991 + val |= EDP_PSR_TP2_TP3_TIME_500us;
1992 + else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
1993 + val |= EDP_PSR_TP2_TP3_TIME_100us;
1994 + else
1995 + val |= EDP_PSR_TP2_TP3_TIME_0us;
1996 +
1997 + if (intel_dp_source_supports_hbr2(intel_dp) &&
1998 + drm_dp_tps3_supported(intel_dp->dpcd))
1999 + val |= EDP_PSR_TP1_TP3_SEL;
2000 + else
2001 + val |= EDP_PSR_TP1_TP2_SEL;
2002 +
2003 + I915_WRITE(EDP_PSR_CTL, val);
2004 +
2005 + if (!dev_priv->psr.psr2_support)
2006 + return;
2007 +
2008 + /* FIXME: selective update is probably totally broken because it doesn't
2009 + * mesh at all with our frontbuffer tracking. And the hw alone isn't
2010 + * good enough. */
2011 + val = EDP_PSR2_ENABLE | EDP_SU_TRACK_ENABLE;
2012 +
2013 + if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
2014 + val |= EDP_PSR2_TP2_TIME_2500;
2015 + else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
2016 + val |= EDP_PSR2_TP2_TIME_500;
2017 + else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
2018 + val |= EDP_PSR2_TP2_TIME_100;
2019 + else
2020 + val |= EDP_PSR2_TP2_TIME_50;
2021
2022 - if (dev_priv->psr.psr2_support)
2023 - I915_WRITE(EDP_PSR2_CTL, EDP_PSR2_ENABLE |
2024 - EDP_SU_TRACK_ENABLE | EDP_PSR2_TP2_TIME_100);
2025 + I915_WRITE(EDP_PSR2_CTL, val);
2026 }
2027
2028 static bool intel_psr_match_conditions(struct intel_dp *intel_dp)
2029 diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
2030 index 2f57d7967417..286f539e0038 100644
2031 --- a/drivers/gpu/drm/imx/imx-drm-core.c
2032 +++ b/drivers/gpu/drm/imx/imx-drm-core.c
2033 @@ -26,6 +26,7 @@
2034 #include <drm/drm_fb_cma_helper.h>
2035 #include <drm/drm_plane_helper.h>
2036 #include <drm/drm_of.h>
2037 +#include <video/imx-ipu-v3.h>
2038
2039 #include "imx-drm.h"
2040
2041 @@ -498,6 +499,13 @@ static int compare_of(struct device *dev, void *data)
2042 {
2043 struct device_node *np = data;
2044
2045 + /* Special case for DI, dev->of_node may not be set yet */
2046 + if (strcmp(dev->driver->name, "imx-ipuv3-crtc") == 0) {
2047 + struct ipu_client_platformdata *pdata = dev->platform_data;
2048 +
2049 + return pdata->of_node == np;
2050 + }
2051 +
2052 /* Special case for LDB, one device for two channels */
2053 if (of_node_cmp(np->name, "lvds-channel") == 0) {
2054 np = of_get_parent(np);
2055 diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
2056 index 287226311413..8fc4f6d11339 100644
2057 --- a/drivers/gpu/drm/imx/ipuv3-crtc.c
2058 +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
2059 @@ -371,7 +371,7 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
2060
2061 ret = imx_drm_add_crtc(drm, &ipu_crtc->base, &ipu_crtc->imx_crtc,
2062 &ipu_crtc->plane[0]->base, &ipu_crtc_helper_funcs,
2063 - ipu_crtc->dev->of_node);
2064 + pdata->of_node);
2065 if (ret) {
2066 dev_err(ipu_crtc->dev, "adding crtc failed with %d.\n", ret);
2067 goto err_put_resources;
2068 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
2069 index 5da5de0cb522..4948c1529836 100644
2070 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
2071 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
2072 @@ -3273,19 +3273,19 @@ static const struct vmw_cmd_entry vmw_cmd_entries[SVGA_3D_CMD_MAX] = {
2073 &vmw_cmd_dx_cid_check, true, false, true),
2074 VMW_CMD_DEF(SVGA_3D_CMD_DX_DEFINE_QUERY, &vmw_cmd_dx_define_query,
2075 true, false, true),
2076 - VMW_CMD_DEF(SVGA_3D_CMD_DX_DESTROY_QUERY, &vmw_cmd_ok,
2077 + VMW_CMD_DEF(SVGA_3D_CMD_DX_DESTROY_QUERY, &vmw_cmd_dx_cid_check,
2078 true, false, true),
2079 VMW_CMD_DEF(SVGA_3D_CMD_DX_BIND_QUERY, &vmw_cmd_dx_bind_query,
2080 true, false, true),
2081 VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_QUERY_OFFSET,
2082 - &vmw_cmd_ok, true, false, true),
2083 - VMW_CMD_DEF(SVGA_3D_CMD_DX_BEGIN_QUERY, &vmw_cmd_ok,
2084 + &vmw_cmd_dx_cid_check, true, false, true),
2085 + VMW_CMD_DEF(SVGA_3D_CMD_DX_BEGIN_QUERY, &vmw_cmd_dx_cid_check,
2086 true, false, true),
2087 - VMW_CMD_DEF(SVGA_3D_CMD_DX_END_QUERY, &vmw_cmd_ok,
2088 + VMW_CMD_DEF(SVGA_3D_CMD_DX_END_QUERY, &vmw_cmd_dx_cid_check,
2089 true, false, true),
2090 VMW_CMD_DEF(SVGA_3D_CMD_DX_READBACK_QUERY, &vmw_cmd_invalid,
2091 true, false, true),
2092 - VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_PREDICATION, &vmw_cmd_invalid,
2093 + VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_PREDICATION, &vmw_cmd_dx_cid_check,
2094 true, false, true),
2095 VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_VIEWPORTS, &vmw_cmd_dx_cid_check,
2096 true, false, true),
2097 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
2098 index 3b1faf7862a5..679a4cb98ee3 100644
2099 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
2100 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
2101 @@ -573,9 +573,9 @@ static int vmw_fb_set_par(struct fb_info *info)
2102 mode = old_mode;
2103 old_mode = NULL;
2104 } else if (!vmw_kms_validate_mode_vram(vmw_priv,
2105 - mode->hdisplay *
2106 - (var->bits_per_pixel + 7) / 8,
2107 - mode->vdisplay)) {
2108 + mode->hdisplay *
2109 + DIV_ROUND_UP(var->bits_per_pixel, 8),
2110 + mode->vdisplay)) {
2111 drm_mode_destroy(vmw_priv->dev, mode);
2112 return -EINVAL;
2113 }
2114 diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
2115 index abb98c77bad2..99dcacf05b99 100644
2116 --- a/drivers/gpu/ipu-v3/ipu-common.c
2117 +++ b/drivers/gpu/ipu-v3/ipu-common.c
2118 @@ -997,7 +997,7 @@ struct ipu_platform_reg {
2119 };
2120
2121 /* These must be in the order of the corresponding device tree port nodes */
2122 -static const struct ipu_platform_reg client_reg[] = {
2123 +static struct ipu_platform_reg client_reg[] = {
2124 {
2125 .pdata = {
2126 .csi = 0,
2127 @@ -1048,7 +1048,7 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
2128 mutex_unlock(&ipu_client_id_mutex);
2129
2130 for (i = 0; i < ARRAY_SIZE(client_reg); i++) {
2131 - const struct ipu_platform_reg *reg = &client_reg[i];
2132 + struct ipu_platform_reg *reg = &client_reg[i];
2133 struct platform_device *pdev;
2134 struct device_node *of_node;
2135
2136 @@ -1070,6 +1070,7 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
2137
2138 pdev->dev.parent = dev;
2139
2140 + reg->pdata.of_node = of_node;
2141 ret = platform_device_add_data(pdev, &reg->pdata,
2142 sizeof(reg->pdata));
2143 if (!ret)
2144 diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
2145 index 6c99ee7bafa3..ee396ff167d9 100644
2146 --- a/drivers/hwmon/ads7828.c
2147 +++ b/drivers/hwmon/ads7828.c
2148 @@ -120,6 +120,7 @@ static int ads7828_probe(struct i2c_client *client,
2149 unsigned int vref_mv = ADS7828_INT_VREF_MV;
2150 bool diff_input = false;
2151 bool ext_vref = false;
2152 + unsigned int regval;
2153
2154 data = devm_kzalloc(dev, sizeof(struct ads7828_data), GFP_KERNEL);
2155 if (!data)
2156 @@ -154,6 +155,15 @@ static int ads7828_probe(struct i2c_client *client,
2157 if (!diff_input)
2158 data->cmd_byte |= ADS7828_CMD_SD_SE;
2159
2160 + /*
2161 + * Datasheet specifies internal reference voltage is disabled by
2162 + * default. The internal reference voltage needs to be enabled and
2163 + * voltage needs to settle before getting valid ADC data. So perform a
2164 + * dummy read to enable the internal reference voltage.
2165 + */
2166 + if (!ext_vref)
2167 + regmap_read(data->regmap, data->cmd_byte, &regval);
2168 +
2169 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
2170 data,
2171 ads7828_groups);
2172 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
2173 index e8a84d12b7ff..03c7ecfc5732 100644
2174 --- a/drivers/input/joystick/xpad.c
2175 +++ b/drivers/input/joystick/xpad.c
2176 @@ -455,6 +455,10 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
2177 static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev,
2178 u16 cmd, unsigned char *data)
2179 {
2180 + /* valid pad data */
2181 + if (data[0] != 0x00)
2182 + return;
2183 +
2184 /* digital pad */
2185 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
2186 /* dpad as buttons (left, right, up, down) */
2187 @@ -754,6 +758,7 @@ static bool xpad_prepare_next_out_packet(struct usb_xpad *xpad)
2188 if (packet) {
2189 memcpy(xpad->odata, packet->data, packet->len);
2190 xpad->irq_out->transfer_buffer_length = packet->len;
2191 + packet->pending = false;
2192 return true;
2193 }
2194
2195 @@ -795,7 +800,6 @@ static void xpad_irq_out(struct urb *urb)
2196 switch (status) {
2197 case 0:
2198 /* success */
2199 - xpad->out_packets[xpad->last_out_packet].pending = false;
2200 xpad->irq_out_active = xpad_prepare_next_out_packet(xpad);
2201 break;
2202
2203 diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
2204 index 4eb9e4d94f46..79338f4bdecb 100644
2205 --- a/drivers/input/misc/uinput.c
2206 +++ b/drivers/input/misc/uinput.c
2207 @@ -981,9 +981,15 @@ static long uinput_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2208 }
2209
2210 #ifdef CONFIG_COMPAT
2211 +
2212 +#define UI_SET_PHYS_COMPAT _IOW(UINPUT_IOCTL_BASE, 108, compat_uptr_t)
2213 +
2214 static long uinput_compat_ioctl(struct file *file,
2215 unsigned int cmd, unsigned long arg)
2216 {
2217 + if (cmd == UI_SET_PHYS_COMPAT)
2218 + cmd = UI_SET_PHYS;
2219 +
2220 return uinput_ioctl_handler(file, cmd, arg, compat_ptr(arg));
2221 }
2222 #endif
2223 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
2224 index 019644ff627d..bacecbd68a6d 100644
2225 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
2226 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
2227 @@ -280,7 +280,8 @@ static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user
2228 static int put_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_buffers32 __user *up)
2229 {
2230 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_create_buffers32)) ||
2231 - copy_to_user(up, kp, offsetof(struct v4l2_create_buffers32, format)))
2232 + copy_to_user(up, kp, offsetof(struct v4l2_create_buffers32, format)) ||
2233 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
2234 return -EFAULT;
2235 return __put_v4l2_format32(&kp->format, &up->format);
2236 }
2237 diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
2238 index 1bbbe877ba7e..807a3e3ec29a 100644
2239 --- a/drivers/mfd/intel-lpss.c
2240 +++ b/drivers/mfd/intel-lpss.c
2241 @@ -34,6 +34,7 @@
2242 #define LPSS_DEV_SIZE 0x200
2243 #define LPSS_PRIV_OFFSET 0x200
2244 #define LPSS_PRIV_SIZE 0x100
2245 +#define LPSS_PRIV_REG_COUNT (LPSS_PRIV_SIZE / 4)
2246 #define LPSS_IDMA64_OFFSET 0x800
2247 #define LPSS_IDMA64_SIZE 0x800
2248
2249 @@ -76,6 +77,7 @@ struct intel_lpss {
2250 struct mfd_cell *cell;
2251 struct device *dev;
2252 void __iomem *priv;
2253 + u32 priv_ctx[LPSS_PRIV_REG_COUNT];
2254 int devid;
2255 u32 caps;
2256 u32 active_ltr;
2257 @@ -493,6 +495,16 @@ EXPORT_SYMBOL_GPL(intel_lpss_prepare);
2258
2259 int intel_lpss_suspend(struct device *dev)
2260 {
2261 + struct intel_lpss *lpss = dev_get_drvdata(dev);
2262 + unsigned int i;
2263 +
2264 + /* Save device context */
2265 + for (i = 0; i < LPSS_PRIV_REG_COUNT; i++)
2266 + lpss->priv_ctx[i] = readl(lpss->priv + i * 4);
2267 +
2268 + /* Put the device into reset state */
2269 + writel(0, lpss->priv + LPSS_PRIV_RESETS);
2270 +
2271 return 0;
2272 }
2273 EXPORT_SYMBOL_GPL(intel_lpss_suspend);
2274 @@ -500,8 +512,13 @@ EXPORT_SYMBOL_GPL(intel_lpss_suspend);
2275 int intel_lpss_resume(struct device *dev)
2276 {
2277 struct intel_lpss *lpss = dev_get_drvdata(dev);
2278 + unsigned int i;
2279
2280 - intel_lpss_init_dev(lpss);
2281 + intel_lpss_deassert_reset(lpss);
2282 +
2283 + /* Restore device context */
2284 + for (i = 0; i < LPSS_PRIV_REG_COUNT; i++)
2285 + writel(lpss->priv_ctx[i], lpss->priv + i * 4);
2286
2287 return 0;
2288 }
2289 diff --git a/drivers/mfd/intel_soc_pmic_core.c b/drivers/mfd/intel_soc_pmic_core.c
2290 index d9e15cf7c6c8..12d6ebb4ae5d 100644
2291 --- a/drivers/mfd/intel_soc_pmic_core.c
2292 +++ b/drivers/mfd/intel_soc_pmic_core.c
2293 @@ -35,6 +35,7 @@ static struct gpiod_lookup_table panel_gpio_table = {
2294 .table = {
2295 /* Panel EN/DISABLE */
2296 GPIO_LOOKUP("gpio_crystalcove", 94, "panel", GPIO_ACTIVE_HIGH),
2297 + { },
2298 },
2299 };
2300
2301 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
2302 index b41eb3f4ee56..8dd0a15dd6e0 100644
2303 --- a/drivers/net/wireless/ath/ath10k/core.c
2304 +++ b/drivers/net/wireless/ath/ath10k/core.c
2305 @@ -1687,6 +1687,10 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode)
2306 goto err_hif_stop;
2307 }
2308
2309 + ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1;
2310 +
2311 + INIT_LIST_HEAD(&ar->arvifs);
2312 +
2313 /* we don't care about HTT in UTF mode */
2314 if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
2315 status = ath10k_htt_setup(&ar->htt);
2316 @@ -1700,10 +1704,6 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode)
2317 if (status)
2318 goto err_hif_stop;
2319
2320 - ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1;
2321 -
2322 - INIT_LIST_HEAD(&ar->arvifs);
2323 -
2324 return 0;
2325
2326 err_hif_stop:
2327 diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
2328 index 2bdf5408b0d9..5d621428a8cb 100644
2329 --- a/drivers/net/wireless/ath/ath10k/debug.c
2330 +++ b/drivers/net/wireless/ath/ath10k/debug.c
2331 @@ -2011,7 +2011,12 @@ static ssize_t ath10k_write_pktlog_filter(struct file *file,
2332 goto out;
2333 }
2334
2335 - if (filter && (filter != ar->debug.pktlog_filter)) {
2336 + if (filter == ar->debug.pktlog_filter) {
2337 + ret = count;
2338 + goto out;
2339 + }
2340 +
2341 + if (filter) {
2342 ret = ath10k_wmi_pdev_pktlog_enable(ar, filter);
2343 if (ret) {
2344 ath10k_warn(ar, "failed to enable pktlog filter %x: %d\n",
2345 diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
2346 index 6146a293601a..aaae4941a5df 100644
2347 --- a/drivers/net/wireless/ath/ath10k/mac.c
2348 +++ b/drivers/net/wireless/ath/ath10k/mac.c
2349 @@ -4474,7 +4474,10 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
2350 goto err_vdev_delete;
2351 }
2352
2353 - if (ar->cfg_tx_chainmask) {
2354 + /* Configuring number of spatial stream for monitor interface is causing
2355 + * target assert in qca9888 and qca6174.
2356 + */
2357 + if (ar->cfg_tx_chainmask && (vif->type != NL80211_IFTYPE_MONITOR)) {
2358 u16 nss = get_nss_from_chainmask(ar->cfg_tx_chainmask);
2359
2360 vdev_param = ar->wmi.vdev_param->nss;
2361 @@ -6434,7 +6437,13 @@ ath10k_mac_update_rx_channel(struct ath10k *ar,
2362 def = &vifs[0].new_ctx->def;
2363
2364 ar->rx_channel = def->chan;
2365 - } else if (ctx && ath10k_mac_num_chanctxs(ar) == 0) {
2366 + } else if ((ctx && ath10k_mac_num_chanctxs(ar) == 0) ||
2367 + (ctx && (ar->state == ATH10K_STATE_RESTARTED))) {
2368 + /* During driver restart due to firmware assert, since mac80211
2369 + * already has valid channel context for given radio, channel
2370 + * context iteration return num_chanctx > 0. So fix rx_channel
2371 + * when restart is in progress.
2372 + */
2373 ar->rx_channel = ctx->def.chan;
2374 } else {
2375 ar->rx_channel = NULL;
2376 diff --git a/drivers/net/wireless/ath/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c
2377 index 803030fd17d3..6a2a16856763 100644
2378 --- a/drivers/net/wireless/ath/ath5k/led.c
2379 +++ b/drivers/net/wireless/ath/ath5k/led.c
2380 @@ -77,7 +77,7 @@ static const struct pci_device_id ath5k_led_devices[] = {
2381 /* HP Compaq CQ60-206US (ddreggors@jumptv.com) */
2382 { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137a), ATH_LED(3, 1) },
2383 /* HP Compaq C700 (nitrousnrg@gmail.com) */
2384 - { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 1) },
2385 + { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 0) },
2386 /* LiteOn AR5BXB63 (magooz@salug.it) */
2387 { ATH_SDEVICE(PCI_VENDOR_ID_ATHEROS, 0x3067), ATH_LED(3, 0) },
2388 /* IBM-specific AR5212 (all others) */
2389 diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
2390 index ab7a1ac37849..b66a30e25616 100644
2391 --- a/drivers/net/wireless/ath/ath9k/init.c
2392 +++ b/drivers/net/wireless/ath/ath9k/init.c
2393 @@ -49,6 +49,10 @@ int ath9k_led_blink;
2394 module_param_named(blink, ath9k_led_blink, int, 0444);
2395 MODULE_PARM_DESC(blink, "Enable LED blink on activity");
2396
2397 +static int ath9k_led_active_high = -1;
2398 +module_param_named(led_active_high, ath9k_led_active_high, int, 0444);
2399 +MODULE_PARM_DESC(led_active_high, "Invert LED polarity");
2400 +
2401 static int ath9k_btcoex_enable;
2402 module_param_named(btcoex_enable, ath9k_btcoex_enable, int, 0444);
2403 MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence");
2404 @@ -600,6 +604,9 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
2405 if (ret)
2406 return ret;
2407
2408 + if (ath9k_led_active_high != -1)
2409 + ah->config.led_active_high = ath9k_led_active_high == 1;
2410 +
2411 /*
2412 * Enable WLAN/BT RX Antenna diversity only when:
2413 *
2414 diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
2415 index e6fef1be9977..7cdaf40c3057 100644
2416 --- a/drivers/net/wireless/ath/ath9k/pci.c
2417 +++ b/drivers/net/wireless/ath/ath9k/pci.c
2418 @@ -28,6 +28,16 @@ static const struct pci_device_id ath_pci_id_table[] = {
2419 { PCI_VDEVICE(ATHEROS, 0x0024) }, /* PCI-E */
2420 { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */
2421 { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI */
2422 +
2423 +#ifdef CONFIG_ATH9K_PCOEM
2424 + /* Mini PCI AR9220 MB92 cards: Compex WLM200NX, Wistron DNMA-92 */
2425 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
2426 + 0x0029,
2427 + PCI_VENDOR_ID_ATHEROS,
2428 + 0x2096),
2429 + .driver_data = ATH9K_PCI_LED_ACT_HI },
2430 +#endif
2431 +
2432 { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */
2433
2434 #ifdef CONFIG_ATH9K_PCOEM
2435 diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
2436 index 0517a4f2d3f2..7a40d8dffa36 100644
2437 --- a/drivers/net/wireless/realtek/rtlwifi/base.c
2438 +++ b/drivers/net/wireless/realtek/rtlwifi/base.c
2439 @@ -1660,9 +1660,9 @@ void rtl_watchdog_wq_callback(void *data)
2440 if (((rtlpriv->link_info.num_rx_inperiod +
2441 rtlpriv->link_info.num_tx_inperiod) > 8) ||
2442 (rtlpriv->link_info.num_rx_inperiod > 2))
2443 - rtl_lps_enter(hw);
2444 - else
2445 rtl_lps_leave(hw);
2446 + else
2447 + rtl_lps_enter(hw);
2448 }
2449
2450 rtlpriv->link_info.num_rx_inperiod = 0;
2451 diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
2452 index c43ab59a690a..77cbd10e807d 100644
2453 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
2454 +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
2455 @@ -1203,7 +1203,6 @@ static void btc8723b2ant_set_ant_path(struct btc_coexist *btcoexist,
2456
2457 /* Force GNT_BT to low */
2458 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0);
2459 - btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
2460
2461 if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) {
2462 /* tell firmware "no antenna inverse" */
2463 @@ -1211,19 +1210,25 @@ static void btc8723b2ant_set_ant_path(struct btc_coexist *btcoexist,
2464 h2c_parameter[1] = 1; /* ext switch type */
2465 btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
2466 h2c_parameter);
2467 + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
2468 } else {
2469 /* tell firmware "antenna inverse" */
2470 h2c_parameter[0] = 1;
2471 h2c_parameter[1] = 1; /* ext switch type */
2472 btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
2473 h2c_parameter);
2474 + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
2475 }
2476 }
2477
2478 /* ext switch setting */
2479 if (use_ext_switch) {
2480 /* fixed internal switch S1->WiFi, S0->BT */
2481 - btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
2482 + if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
2483 + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
2484 + else
2485 + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
2486 +
2487 switch (antpos_type) {
2488 case BTC_ANT_WIFI_AT_MAIN:
2489 /* ext switch main at wifi */
2490 diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
2491 index b2791c893417..babd1490f20c 100644
2492 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
2493 +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
2494 @@ -965,13 +965,38 @@ void exhalbtc_set_chip_type(u8 chip_type)
2495 }
2496 }
2497
2498 -void exhalbtc_set_ant_num(u8 type, u8 ant_num)
2499 +void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
2500 {
2501 if (BT_COEX_ANT_TYPE_PG == type) {
2502 gl_bt_coexist.board_info.pg_ant_num = ant_num;
2503 gl_bt_coexist.board_info.btdm_ant_num = ant_num;
2504 + /* The antenna position:
2505 + * Main (default) or Aux for pgAntNum=2 && btdmAntNum =1.
2506 + * The antenna position should be determined by
2507 + * auto-detect mechanism.
2508 + * The following is assumed to main,
2509 + * and those must be modified
2510 + * if y auto-detect mechanism is ready
2511 + */
2512 + if ((gl_bt_coexist.board_info.pg_ant_num == 2) &&
2513 + (gl_bt_coexist.board_info.btdm_ant_num == 1))
2514 + gl_bt_coexist.board_info.btdm_ant_pos =
2515 + BTC_ANTENNA_AT_MAIN_PORT;
2516 + else
2517 + gl_bt_coexist.board_info.btdm_ant_pos =
2518 + BTC_ANTENNA_AT_MAIN_PORT;
2519 } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
2520 gl_bt_coexist.board_info.btdm_ant_num = ant_num;
2521 + gl_bt_coexist.board_info.btdm_ant_pos =
2522 + BTC_ANTENNA_AT_MAIN_PORT;
2523 + } else if (type == BT_COEX_ANT_TYPE_DETECTED) {
2524 + gl_bt_coexist.board_info.btdm_ant_num = ant_num;
2525 + if (rtlpriv->cfg->mod_params->ant_sel == 1)
2526 + gl_bt_coexist.board_info.btdm_ant_pos =
2527 + BTC_ANTENNA_AT_AUX_PORT;
2528 + else
2529 + gl_bt_coexist.board_info.btdm_ant_pos =
2530 + BTC_ANTENNA_AT_MAIN_PORT;
2531 }
2532 }
2533
2534 diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
2535 index 0a903ea179ef..f41ca57dd8a7 100644
2536 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
2537 +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
2538 @@ -535,7 +535,7 @@ void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version);
2539 void exhalbtc_update_min_bt_rssi(char bt_rssi);
2540 void exhalbtc_set_bt_exist(bool bt_exist);
2541 void exhalbtc_set_chip_type(u8 chip_type);
2542 -void exhalbtc_set_ant_num(u8 type, u8 ant_num);
2543 +void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num);
2544 void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist);
2545 void exhalbtc_signal_compensation(struct btc_coexist *btcoexist,
2546 u8 *rssi_wifi, u8 *rssi_bt);
2547 diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
2548 index b9b0cb7af8ea..d3fd9211b3a4 100644
2549 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
2550 +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
2551 @@ -72,7 +72,10 @@ void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
2552 __func__, bt_type);
2553 exhalbtc_set_chip_type(bt_type);
2554
2555 - exhalbtc_set_ant_num(BT_COEX_ANT_TYPE_PG, ant_num);
2556 + if (rtlpriv->cfg->mod_params->ant_sel == 1)
2557 + exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_DETECTED, 1);
2558 + else
2559 + exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num);
2560 }
2561
2562 void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)
2563 diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
2564 index 7f471bff435c..5b4048041147 100644
2565 --- a/drivers/net/wireless/realtek/rtlwifi/pci.c
2566 +++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
2567 @@ -1573,7 +1573,7 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
2568 true,
2569 HW_DESC_TXBUFF_ADDR),
2570 skb->len, PCI_DMA_TODEVICE);
2571 - kfree_skb(skb);
2572 + dev_kfree_skb_irq(skb);
2573 ring->idx = (ring->idx + 1) % ring->entries;
2574 }
2575 ring->idx = 0;
2576 diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
2577 index c983d2fe147f..5a3df9198ddf 100644
2578 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
2579 +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
2580 @@ -2684,6 +2684,7 @@ void rtl8723be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw,
2581 bool auto_load_fail, u8 *hwinfo)
2582 {
2583 struct rtl_priv *rtlpriv = rtl_priv(hw);
2584 + struct rtl_mod_params *mod_params = rtlpriv->cfg->mod_params;
2585 u8 value;
2586 u32 tmpu_32;
2587
2588 @@ -2702,6 +2703,10 @@ void rtl8723be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw,
2589 rtlpriv->btcoexist.btc_info.ant_num = ANT_X2;
2590 }
2591
2592 + /* override ant_num / ant_path */
2593 + if (mod_params->ant_sel)
2594 + rtlpriv->btcoexist.btc_info.ant_num =
2595 + (mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1);
2596 }
2597
2598 void rtl8723be_bt_reg_init(struct ieee80211_hw *hw)
2599 diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
2600 index a78eaeda0008..2101793438ed 100644
2601 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
2602 +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
2603 @@ -273,6 +273,7 @@ static struct rtl_mod_params rtl8723be_mod_params = {
2604 .msi_support = false,
2605 .disable_watchdog = false,
2606 .debug = DBG_EMERG,
2607 + .ant_sel = 0,
2608 };
2609
2610 static struct rtl_hal_cfg rtl8723be_hal_cfg = {
2611 @@ -394,6 +395,7 @@ module_param_named(fwlps, rtl8723be_mod_params.fwctrl_lps, bool, 0444);
2612 module_param_named(msi, rtl8723be_mod_params.msi_support, bool, 0444);
2613 module_param_named(disable_watchdog, rtl8723be_mod_params.disable_watchdog,
2614 bool, 0444);
2615 +module_param_named(ant_sel, rtl8723be_mod_params.ant_sel, int, 0444);
2616 MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n");
2617 MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n");
2618 MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n");
2619 @@ -402,6 +404,7 @@ MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 0)\n");
2620 MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)");
2621 MODULE_PARM_DESC(disable_watchdog,
2622 "Set to 1 to disable the watchdog (default 0)\n");
2623 +MODULE_PARM_DESC(ant_sel, "Set to 1 or 2 to force antenna number (default 0)\n");
2624
2625 static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume);
2626
2627 diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h
2628 index 84397b190cc0..3c18902d21be 100644
2629 --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
2630 +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
2631 @@ -2251,6 +2251,9 @@ struct rtl_mod_params {
2632
2633 /* default 0: 1 means do not disable interrupts */
2634 bool int_clear;
2635 +
2636 + /* select antenna */
2637 + int ant_sel;
2638 };
2639
2640 struct rtl_hal_usbint_cfg {
2641 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
2642 index 6b0056e9c33e..6e3feecf0301 100644
2643 --- a/drivers/pci/probe.c
2644 +++ b/drivers/pci/probe.c
2645 @@ -179,9 +179,6 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
2646 u16 orig_cmd;
2647 struct pci_bus_region region, inverted_region;
2648
2649 - if (dev->non_compliant_bars)
2650 - return 0;
2651 -
2652 mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
2653
2654 /* No printks while decoding is disabled! */
2655 @@ -322,6 +319,9 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
2656 {
2657 unsigned int pos, reg;
2658
2659 + if (dev->non_compliant_bars)
2660 + return;
2661 +
2662 for (pos = 0; pos < howmany; pos++) {
2663 struct resource *res = &dev->resource[pos];
2664 reg = PCI_BASE_ADDRESS_0 + (pos << 2);
2665 diff --git a/drivers/pinctrl/samsung/pinctrl-exynos5440.c b/drivers/pinctrl/samsung/pinctrl-exynos5440.c
2666 index 00ab63abf1d9..dbbdf652c34a 100644
2667 --- a/drivers/pinctrl/samsung/pinctrl-exynos5440.c
2668 +++ b/drivers/pinctrl/samsung/pinctrl-exynos5440.c
2669 @@ -107,6 +107,7 @@ struct exynos5440_pmx_func {
2670 * @nr_groups: number of pin groups available.
2671 * @pmx_functions: list of pin functions parsed from device tree.
2672 * @nr_functions: number of pin functions available.
2673 + * @range: gpio range to register with pinctrl
2674 */
2675 struct exynos5440_pinctrl_priv_data {
2676 void __iomem *reg_base;
2677 @@ -117,6 +118,7 @@ struct exynos5440_pinctrl_priv_data {
2678 unsigned int nr_groups;
2679 const struct exynos5440_pmx_func *pmx_functions;
2680 unsigned int nr_functions;
2681 + struct pinctrl_gpio_range range;
2682 };
2683
2684 /**
2685 @@ -742,7 +744,6 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev,
2686 struct pinctrl_desc *ctrldesc;
2687 struct pinctrl_dev *pctl_dev;
2688 struct pinctrl_pin_desc *pindesc, *pdesc;
2689 - struct pinctrl_gpio_range grange;
2690 char *pin_names;
2691 int pin, ret;
2692
2693 @@ -794,12 +795,12 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev,
2694 return PTR_ERR(pctl_dev);
2695 }
2696
2697 - grange.name = "exynos5440-pctrl-gpio-range";
2698 - grange.id = 0;
2699 - grange.base = 0;
2700 - grange.npins = EXYNOS5440_MAX_PINS;
2701 - grange.gc = priv->gc;
2702 - pinctrl_add_gpio_range(pctl_dev, &grange);
2703 + priv->range.name = "exynos5440-pctrl-gpio-range";
2704 + priv->range.id = 0;
2705 + priv->range.base = 0;
2706 + priv->range.npins = EXYNOS5440_MAX_PINS;
2707 + priv->range.gc = priv->gc;
2708 + pinctrl_add_gpio_range(pctl_dev, &priv->range);
2709 return 0;
2710 }
2711
2712 diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
2713 index d044f3f273be..467773033a20 100644
2714 --- a/drivers/scsi/aacraid/aacraid.h
2715 +++ b/drivers/scsi/aacraid/aacraid.h
2716 @@ -29,6 +29,7 @@ enum {
2717 #define AAC_INT_MODE_MSI (1<<1)
2718 #define AAC_INT_MODE_AIF (1<<2)
2719 #define AAC_INT_MODE_SYNC (1<<3)
2720 +#define AAC_INT_MODE_MSIX (1<<16)
2721
2722 #define AAC_INT_ENABLE_TYPE1_INTX 0xfffffffb
2723 #define AAC_INT_ENABLE_TYPE1_MSIX 0xfffffffa
2724 diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
2725 index 0e954e37f0b5..0d351cd3191b 100644
2726 --- a/drivers/scsi/aacraid/comminit.c
2727 +++ b/drivers/scsi/aacraid/comminit.c
2728 @@ -37,6 +37,7 @@
2729 #include <linux/spinlock.h>
2730 #include <linux/slab.h>
2731 #include <linux/blkdev.h>
2732 +#include <linux/delay.h>
2733 #include <linux/completion.h>
2734 #include <linux/mm.h>
2735 #include <scsi/scsi_host.h>
2736 @@ -47,6 +48,20 @@ struct aac_common aac_config = {
2737 .irq_mod = 1
2738 };
2739
2740 +static inline int aac_is_msix_mode(struct aac_dev *dev)
2741 +{
2742 + u32 status;
2743 +
2744 + status = src_readl(dev, MUnit.OMR);
2745 + return (status & AAC_INT_MODE_MSIX);
2746 +}
2747 +
2748 +static inline void aac_change_to_intx(struct aac_dev *dev)
2749 +{
2750 + aac_src_access_devreg(dev, AAC_DISABLE_MSIX);
2751 + aac_src_access_devreg(dev, AAC_ENABLE_INTX);
2752 +}
2753 +
2754 static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long commsize, unsigned long commalign)
2755 {
2756 unsigned char *base;
2757 @@ -425,6 +440,15 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
2758 dev->comm_interface = AAC_COMM_PRODUCER;
2759 dev->raw_io_interface = dev->raw_io_64 = 0;
2760
2761 +
2762 + /*
2763 + * Enable INTX mode, if not done already Enabled
2764 + */
2765 + if (aac_is_msix_mode(dev)) {
2766 + aac_change_to_intx(dev);
2767 + dev_info(&dev->pdev->dev, "Changed firmware to INTX mode");
2768 + }
2769 +
2770 if ((!aac_adapter_sync_cmd(dev, GET_ADAPTER_PROPERTIES,
2771 0, 0, 0, 0, 0, 0,
2772 status+0, status+1, status+2, status+3, NULL)) &&
2773 diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
2774 index 4cbf54928640..8c758c36fc70 100644
2775 --- a/drivers/scsi/aacraid/commsup.c
2776 +++ b/drivers/scsi/aacraid/commsup.c
2777 @@ -611,10 +611,10 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
2778 }
2779 return -EFAULT;
2780 }
2781 - /* We used to udelay() here but that absorbed
2782 - * a CPU when a timeout occured. Not very
2783 - * useful. */
2784 - cpu_relax();
2785 + /*
2786 + * Allow other processes / CPUS to use core
2787 + */
2788 + schedule();
2789 }
2790 } else if (down_interruptible(&fibptr->event_wait)) {
2791 /* Do nothing ... satisfy
2792 @@ -1970,6 +1970,10 @@ int aac_command_thread(void *data)
2793 if (difference <= 0)
2794 difference = 1;
2795 set_current_state(TASK_INTERRUPTIBLE);
2796 +
2797 + if (kthread_should_stop())
2798 + break;
2799 +
2800 schedule_timeout(difference);
2801
2802 if (kthread_should_stop())
2803 diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c
2804 index 4fb3581d4614..3fa65338d3f5 100644
2805 --- a/drivers/scsi/lpfc/lpfc_mem.c
2806 +++ b/drivers/scsi/lpfc/lpfc_mem.c
2807 @@ -231,13 +231,15 @@ lpfc_mem_free(struct lpfc_hba *phba)
2808 if (phba->lpfc_hbq_pool)
2809 pci_pool_destroy(phba->lpfc_hbq_pool);
2810 phba->lpfc_hbq_pool = NULL;
2811 - mempool_destroy(phba->rrq_pool);
2812 +
2813 + if (phba->rrq_pool)
2814 + mempool_destroy(phba->rrq_pool);
2815 phba->rrq_pool = NULL;
2816
2817 /* Free NLP memory pool */
2818 mempool_destroy(phba->nlp_mem_pool);
2819 phba->nlp_mem_pool = NULL;
2820 - if (phba->sli_rev == LPFC_SLI_REV4) {
2821 + if (phba->sli_rev == LPFC_SLI_REV4 && phba->active_rrq_pool) {
2822 mempool_destroy(phba->active_rrq_pool);
2823 phba->active_rrq_pool = NULL;
2824 }
2825 diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
2826 index 1a7dc3c590b1..481eb2989a1e 100644
2827 --- a/drivers/tty/serial/ucc_uart.c
2828 +++ b/drivers/tty/serial/ucc_uart.c
2829 @@ -1478,6 +1478,9 @@ static const struct of_device_id ucc_uart_match[] = {
2830 .type = "serial",
2831 .compatible = "ucc_uart",
2832 },
2833 + {
2834 + .compatible = "fsl,t1040-ucc-uart",
2835 + },
2836 {},
2837 };
2838 MODULE_DEVICE_TABLE(of, ucc_uart_match);
2839 diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
2840 index 44367783f07a..83ec7b89d308 100644
2841 --- a/drivers/xen/events/events_base.c
2842 +++ b/drivers/xen/events/events_base.c
2843 @@ -487,7 +487,8 @@ static void eoi_pirq(struct irq_data *data)
2844 if (!VALID_EVTCHN(evtchn))
2845 return;
2846
2847 - if (unlikely(irqd_is_setaffinity_pending(data))) {
2848 + if (unlikely(irqd_is_setaffinity_pending(data)) &&
2849 + likely(!irqd_irq_disabled(data))) {
2850 int masked = test_and_set_mask(evtchn);
2851
2852 clear_evtchn(evtchn);
2853 @@ -1370,7 +1371,8 @@ static void ack_dynirq(struct irq_data *data)
2854 if (!VALID_EVTCHN(evtchn))
2855 return;
2856
2857 - if (unlikely(irqd_is_setaffinity_pending(data))) {
2858 + if (unlikely(irqd_is_setaffinity_pending(data)) &&
2859 + likely(!irqd_irq_disabled(data))) {
2860 int masked = test_and_set_mask(evtchn);
2861
2862 clear_evtchn(evtchn);
2863 diff --git a/fs/affs/super.c b/fs/affs/super.c
2864 index 2a6713b6b9f4..d6384863192c 100644
2865 --- a/fs/affs/super.c
2866 +++ b/fs/affs/super.c
2867 @@ -528,7 +528,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
2868 char *prefix = NULL;
2869
2870 new_opts = kstrdup(data, GFP_KERNEL);
2871 - if (!new_opts)
2872 + if (data && !new_opts)
2873 return -ENOMEM;
2874
2875 pr_debug("%s(flags=0x%x,opts=\"%s\")\n", __func__, *flags, data);
2876 @@ -546,7 +546,8 @@ affs_remount(struct super_block *sb, int *flags, char *data)
2877 }
2878
2879 flush_delayed_work(&sbi->sb_work);
2880 - replace_mount_options(sb, new_opts);
2881 + if (new_opts)
2882 + replace_mount_options(sb, new_opts);
2883
2884 sbi->s_flags = mount_flags;
2885 sbi->s_mode = mode;
2886 diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
2887 index f6dac40f87ff..6442a31c2119 100644
2888 --- a/fs/btrfs/backref.c
2889 +++ b/fs/btrfs/backref.c
2890 @@ -1995,7 +1995,7 @@ struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root,
2891
2892 ifp = kmalloc(sizeof(*ifp), GFP_NOFS);
2893 if (!ifp) {
2894 - kfree(fspath);
2895 + vfree(fspath);
2896 return ERR_PTR(-ENOMEM);
2897 }
2898
2899 diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
2900 index 6661ad8b4088..7c9a9c026e21 100644
2901 --- a/fs/btrfs/ctree.h
2902 +++ b/fs/btrfs/ctree.h
2903 @@ -4089,6 +4089,7 @@ void btrfs_test_inode_set_ops(struct inode *inode);
2904
2905 /* ioctl.c */
2906 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2907 +long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2908 void btrfs_update_iflags(struct inode *inode);
2909 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2910 int btrfs_is_empty_uuid(u8 *uuid);
2911 diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
2912 index e2287c7c10be..95e57320dd75 100644
2913 --- a/fs/btrfs/extent-tree.c
2914 +++ b/fs/btrfs/extent-tree.c
2915 @@ -4620,7 +4620,7 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig,
2916
2917 /* Calc the number of the pages we need flush for space reservation */
2918 items = calc_reclaim_items_nr(root, to_reclaim);
2919 - to_reclaim = items * EXTENT_SIZE_PER_ITEM;
2920 + to_reclaim = (u64)items * EXTENT_SIZE_PER_ITEM;
2921
2922 trans = (struct btrfs_trans_handle *)current->journal_info;
2923 block_rsv = &root->fs_info->delalloc_block_rsv;
2924 diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
2925 index 392592dc7010..b5ff48d6a0c5 100644
2926 --- a/fs/btrfs/extent_io.c
2927 +++ b/fs/btrfs/extent_io.c
2928 @@ -875,8 +875,14 @@ __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
2929 bits |= EXTENT_FIRST_DELALLOC;
2930 again:
2931 if (!prealloc && gfpflags_allow_blocking(mask)) {
2932 + /*
2933 + * Don't care for allocation failure here because we might end
2934 + * up not needing the pre-allocated extent state at all, which
2935 + * is the case if we only have in the tree extent states that
2936 + * cover our input range and don't cover too any other range.
2937 + * If we end up needing a new extent state we allocate it later.
2938 + */
2939 prealloc = alloc_extent_state(mask);
2940 - BUG_ON(!prealloc);
2941 }
2942
2943 spin_lock(&tree->lock);
2944 @@ -4385,8 +4391,12 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2945 if (ret < 0) {
2946 btrfs_free_path(path);
2947 return ret;
2948 + } else {
2949 + WARN_ON(!ret);
2950 + if (ret == 1)
2951 + ret = 0;
2952 }
2953 - WARN_ON(!ret);
2954 +
2955 path->slots[0]--;
2956 btrfs_item_key_to_cpu(path->nodes[0], &found_key, path->slots[0]);
2957 found_type = found_key.type;
2958 diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
2959 index 5d956b869e03..187fa7b9bae7 100644
2960 --- a/fs/btrfs/file.c
2961 +++ b/fs/btrfs/file.c
2962 @@ -2931,7 +2931,7 @@ const struct file_operations btrfs_file_operations = {
2963 .fallocate = btrfs_fallocate,
2964 .unlocked_ioctl = btrfs_ioctl,
2965 #ifdef CONFIG_COMPAT
2966 - .compat_ioctl = btrfs_ioctl,
2967 + .compat_ioctl = btrfs_compat_ioctl,
2968 #endif
2969 .copy_file_range = btrfs_copy_file_range,
2970 .clone_file_range = btrfs_clone_file_range,
2971 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
2972 index f407e487c687..0db33cb4a2ac 100644
2973 --- a/fs/btrfs/inode.c
2974 +++ b/fs/btrfs/inode.c
2975 @@ -10088,7 +10088,7 @@ static const struct file_operations btrfs_dir_file_operations = {
2976 .iterate = btrfs_real_readdir,
2977 .unlocked_ioctl = btrfs_ioctl,
2978 #ifdef CONFIG_COMPAT
2979 - .compat_ioctl = btrfs_ioctl,
2980 + .compat_ioctl = btrfs_compat_ioctl,
2981 #endif
2982 .release = btrfs_release_file,
2983 .fsync = btrfs_sync_file,
2984 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
2985 index e3791f268489..4b035cc7ed54 100644
2986 --- a/fs/btrfs/ioctl.c
2987 +++ b/fs/btrfs/ioctl.c
2988 @@ -4849,8 +4849,8 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
2989 /* update qgroup status and info */
2990 err = btrfs_run_qgroups(trans, root->fs_info);
2991 if (err < 0)
2992 - btrfs_std_error(root->fs_info, ret,
2993 - "failed to update qgroup status and info\n");
2994 + btrfs_std_error(root->fs_info, err,
2995 + "failed to update qgroup status and info");
2996 err = btrfs_end_transaction(trans, root);
2997 if (err && !ret)
2998 ret = err;
2999 @@ -5397,9 +5397,15 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg)
3000 if (ret)
3001 return ret;
3002
3003 + ret = mnt_want_write_file(file);
3004 + if (ret)
3005 + return ret;
3006 +
3007 trans = btrfs_start_transaction(root, 0);
3008 - if (IS_ERR(trans))
3009 - return PTR_ERR(trans);
3010 + if (IS_ERR(trans)) {
3011 + ret = PTR_ERR(trans);
3012 + goto out_drop_write;
3013 + }
3014
3015 spin_lock(&root->fs_info->super_lock);
3016 newflags = btrfs_super_compat_flags(super_block);
3017 @@ -5418,7 +5424,11 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg)
3018 btrfs_set_super_incompat_flags(super_block, newflags);
3019 spin_unlock(&root->fs_info->super_lock);
3020
3021 - return btrfs_commit_transaction(trans, root);
3022 + ret = btrfs_commit_transaction(trans, root);
3023 +out_drop_write:
3024 + mnt_drop_write_file(file);
3025 +
3026 + return ret;
3027 }
3028
3029 long btrfs_ioctl(struct file *file, unsigned int
3030 @@ -5555,3 +5565,24 @@ long btrfs_ioctl(struct file *file, unsigned int
3031
3032 return -ENOTTY;
3033 }
3034 +
3035 +#ifdef CONFIG_COMPAT
3036 +long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
3037 +{
3038 + switch (cmd) {
3039 + case FS_IOC32_GETFLAGS:
3040 + cmd = FS_IOC_GETFLAGS;
3041 + break;
3042 + case FS_IOC32_SETFLAGS:
3043 + cmd = FS_IOC_SETFLAGS;
3044 + break;
3045 + case FS_IOC32_GETVERSION:
3046 + cmd = FS_IOC_GETVERSION;
3047 + break;
3048 + default:
3049 + return -ENOIOCTLCMD;
3050 + }
3051 +
3052 + return btrfs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
3053 +}
3054 +#endif
3055 diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
3056 index 92bf5ee732fb..2b7986e9df03 100644
3057 --- a/fs/btrfs/scrub.c
3058 +++ b/fs/btrfs/scrub.c
3059 @@ -2125,6 +2125,8 @@ static void scrub_missing_raid56_end_io(struct bio *bio)
3060 if (bio->bi_error)
3061 sblock->no_io_error_seen = 0;
3062
3063 + bio_put(bio);
3064 +
3065 btrfs_queue_work(fs_info->scrub_workers, &sblock->work);
3066 }
3067
3068 @@ -2177,7 +2179,7 @@ static void scrub_missing_raid56_pages(struct scrub_block *sblock)
3069 struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info;
3070 u64 length = sblock->page_count * PAGE_SIZE;
3071 u64 logical = sblock->pagev[0]->logical;
3072 - struct btrfs_bio *bbio;
3073 + struct btrfs_bio *bbio = NULL;
3074 struct bio *bio;
3075 struct btrfs_raid_bio *rbio;
3076 int ret;
3077 @@ -2858,7 +2860,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
3078 int extent_mirror_num;
3079 int stop_loop = 0;
3080
3081 - nsectors = map->stripe_len / root->sectorsize;
3082 + nsectors = div_u64(map->stripe_len, root->sectorsize);
3083 bitmap_len = scrub_calc_parity_bitmap_len(nsectors);
3084 sparity = kzalloc(sizeof(struct scrub_parity) + 2 * bitmap_len,
3085 GFP_NOFS);
3086 @@ -2978,6 +2980,7 @@ again:
3087 extent_len);
3088
3089 mapped_length = extent_len;
3090 + bbio = NULL;
3091 ret = btrfs_map_block(fs_info, READ, extent_logical,
3092 &mapped_length, &bbio, 0);
3093 if (!ret) {
3094 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
3095 index d41e09fe8e38..468e988d8110 100644
3096 --- a/fs/btrfs/super.c
3097 +++ b/fs/btrfs/super.c
3098 @@ -2024,6 +2024,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
3099 struct btrfs_block_rsv *block_rsv = &fs_info->global_block_rsv;
3100 int ret;
3101 u64 thresh = 0;
3102 + int mixed = 0;
3103
3104 /*
3105 * holding chunk_muext to avoid allocating new chunks, holding
3106 @@ -2049,8 +2050,17 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
3107 }
3108 }
3109 }
3110 - if (found->flags & BTRFS_BLOCK_GROUP_METADATA)
3111 - total_free_meta += found->disk_total - found->disk_used;
3112 +
3113 + /*
3114 + * Metadata in mixed block goup profiles are accounted in data
3115 + */
3116 + if (!mixed && found->flags & BTRFS_BLOCK_GROUP_METADATA) {
3117 + if (found->flags & BTRFS_BLOCK_GROUP_DATA)
3118 + mixed = 1;
3119 + else
3120 + total_free_meta += found->disk_total -
3121 + found->disk_used;
3122 + }
3123
3124 total_used += found->disk_used;
3125 }
3126 @@ -2063,7 +2073,11 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
3127
3128 /* Account global block reserve as used, it's in logical size already */
3129 spin_lock(&block_rsv->lock);
3130 - buf->f_bfree -= block_rsv->size >> bits;
3131 + /* Mixed block groups accounting is not byte-accurate, avoid overflow */
3132 + if (buf->f_bfree >= block_rsv->size >> bits)
3133 + buf->f_bfree -= block_rsv->size >> bits;
3134 + else
3135 + buf->f_bfree = 0;
3136 spin_unlock(&block_rsv->lock);
3137
3138 buf->f_bavail = div_u64(total_free_data, factor);
3139 @@ -2088,7 +2102,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
3140 */
3141 thresh = 4 * 1024 * 1024;
3142
3143 - if (total_free_meta - thresh < block_rsv->size)
3144 + if (!mixed && total_free_meta - thresh < block_rsv->size)
3145 buf->f_bavail = 0;
3146
3147 buf->f_type = BTRFS_SUPER_MAGIC;
3148 diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
3149 index 539e7b5e3f86..3d14618ce54b 100644
3150 --- a/fs/btrfs/sysfs.c
3151 +++ b/fs/btrfs/sysfs.c
3152 @@ -120,6 +120,9 @@ static ssize_t btrfs_feature_attr_store(struct kobject *kobj,
3153 if (!fs_info)
3154 return -EPERM;
3155
3156 + if (fs_info->sb->s_flags & MS_RDONLY)
3157 + return -EROFS;
3158 +
3159 ret = kstrtoul(skip_spaces(buf), 0, &val);
3160 if (ret)
3161 return ret;
3162 @@ -374,6 +377,9 @@ static ssize_t btrfs_label_store(struct kobject *kobj,
3163 struct btrfs_fs_info *fs_info = to_fs_info(kobj);
3164 size_t p_len;
3165
3166 + if (!fs_info)
3167 + return -EPERM;
3168 +
3169 if (fs_info->sb->s_flags & MS_RDONLY)
3170 return -EROFS;
3171
3172 diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
3173 index 58ae0a2ce65c..a2cd42107945 100644
3174 --- a/fs/btrfs/tree-log.c
3175 +++ b/fs/btrfs/tree-log.c
3176 @@ -5157,7 +5157,7 @@ process_leaf:
3177 }
3178
3179 ctx->log_new_dentries = false;
3180 - if (type == BTRFS_FT_DIR)
3181 + if (type == BTRFS_FT_DIR || type == BTRFS_FT_SYMLINK)
3182 log_mode = LOG_INODE_ALL;
3183 btrfs_release_path(path);
3184 ret = btrfs_log_inode(trans, root, di_inode,
3185 @@ -5277,11 +5277,16 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
3186 if (IS_ERR(dir_inode))
3187 continue;
3188
3189 + if (ctx)
3190 + ctx->log_new_dentries = false;
3191 ret = btrfs_log_inode(trans, root, dir_inode,
3192 LOG_INODE_ALL, 0, LLONG_MAX, ctx);
3193 if (!ret &&
3194 btrfs_must_commit_transaction(trans, dir_inode))
3195 ret = 1;
3196 + if (!ret && ctx && ctx->log_new_dentries)
3197 + ret = log_new_dir_dentries(trans, root,
3198 + dir_inode, ctx);
3199 iput(dir_inode);
3200 if (ret)
3201 goto out;
3202 @@ -5651,11 +5656,9 @@ void btrfs_record_unlink_dir(struct btrfs_trans_handle *trans,
3203 * into the file. When the file is logged we check it and
3204 * don't log the parents if the file is fully on disk.
3205 */
3206 - if (S_ISREG(inode->i_mode)) {
3207 - mutex_lock(&BTRFS_I(inode)->log_mutex);
3208 - BTRFS_I(inode)->last_unlink_trans = trans->transid;
3209 - mutex_unlock(&BTRFS_I(inode)->log_mutex);
3210 - }
3211 + mutex_lock(&BTRFS_I(inode)->log_mutex);
3212 + BTRFS_I(inode)->last_unlink_trans = trans->transid;
3213 + mutex_unlock(&BTRFS_I(inode)->log_mutex);
3214
3215 /*
3216 * if this directory was already logged any new
3217 diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
3218 index 366b335946fa..542c04388ba5 100644
3219 --- a/fs/btrfs/volumes.c
3220 +++ b/fs/btrfs/volumes.c
3221 @@ -1971,11 +1971,8 @@ void btrfs_rm_dev_replace_remove_srcdev(struct btrfs_fs_info *fs_info,
3222 if (srcdev->missing)
3223 fs_devices->missing_devices--;
3224
3225 - if (srcdev->writeable) {
3226 + if (srcdev->writeable)
3227 fs_devices->rw_devices--;
3228 - /* zero out the old super if it is writable */
3229 - btrfs_scratch_superblocks(srcdev->bdev, srcdev->name->str);
3230 - }
3231
3232 if (srcdev->bdev)
3233 fs_devices->open_devices--;
3234 @@ -1986,6 +1983,10 @@ void btrfs_rm_dev_replace_free_srcdev(struct btrfs_fs_info *fs_info,
3235 {
3236 struct btrfs_fs_devices *fs_devices = srcdev->fs_devices;
3237
3238 + if (srcdev->writeable) {
3239 + /* zero out the old super if it is writable */
3240 + btrfs_scratch_superblocks(srcdev->bdev, srcdev->name->str);
3241 + }
3242 call_rcu(&srcdev->rcu, free_device);
3243
3244 /*
3245 @@ -2023,10 +2024,9 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
3246
3247 btrfs_sysfs_rm_device_link(fs_info->fs_devices, tgtdev);
3248
3249 - if (tgtdev->bdev) {
3250 - btrfs_scratch_superblocks(tgtdev->bdev, tgtdev->name->str);
3251 + if (tgtdev->bdev)
3252 fs_info->fs_devices->open_devices--;
3253 - }
3254 +
3255 fs_info->fs_devices->num_devices--;
3256
3257 next_device = list_entry(fs_info->fs_devices->devices.next,
3258 @@ -2037,10 +2037,18 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
3259 fs_info->fs_devices->latest_bdev = next_device->bdev;
3260 list_del_rcu(&tgtdev->dev_list);
3261
3262 - call_rcu(&tgtdev->rcu, free_device);
3263 -
3264 mutex_unlock(&fs_info->fs_devices->device_list_mutex);
3265 mutex_unlock(&uuid_mutex);
3266 +
3267 + /*
3268 + * The update_dev_time() with in btrfs_scratch_superblocks()
3269 + * may lead to a call to btrfs_show_devname() which will try
3270 + * to hold device_list_mutex. And here this device
3271 + * is already out of device list, so we don't have to hold
3272 + * the device_list_mutex lock.
3273 + */
3274 + btrfs_scratch_superblocks(tgtdev->bdev, tgtdev->name->str);
3275 + call_rcu(&tgtdev->rcu, free_device);
3276 }
3277
3278 static int btrfs_find_device_by_path(struct btrfs_root *root, char *device_path,
3279 @@ -3401,6 +3409,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
3280 u32 count_meta = 0;
3281 u32 count_sys = 0;
3282 int chunk_reserved = 0;
3283 + u64 bytes_used = 0;
3284
3285 /* step one make some room on all the devices */
3286 devices = &fs_info->fs_devices->devices;
3287 @@ -3539,7 +3548,13 @@ again:
3288 goto loop;
3289 }
3290
3291 - if ((chunk_type & BTRFS_BLOCK_GROUP_DATA) && !chunk_reserved) {
3292 + ASSERT(fs_info->data_sinfo);
3293 + spin_lock(&fs_info->data_sinfo->lock);
3294 + bytes_used = fs_info->data_sinfo->bytes_used;
3295 + spin_unlock(&fs_info->data_sinfo->lock);
3296 +
3297 + if ((chunk_type & BTRFS_BLOCK_GROUP_DATA) &&
3298 + !chunk_reserved && !bytes_used) {
3299 trans = btrfs_start_transaction(chunk_root, 0);
3300 if (IS_ERR(trans)) {
3301 mutex_unlock(&fs_info->delete_unused_bgs_mutex);
3302 @@ -3692,10 +3707,8 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
3303 num_devices--;
3304 }
3305 btrfs_dev_replace_unlock(&fs_info->dev_replace);
3306 - allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE;
3307 - if (num_devices == 1)
3308 - allowed |= BTRFS_BLOCK_GROUP_DUP;
3309 - else if (num_devices > 1)
3310 + allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE | BTRFS_BLOCK_GROUP_DUP;
3311 + if (num_devices > 1)
3312 allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1);
3313 if (num_devices > 2)
3314 allowed |= BTRFS_BLOCK_GROUP_RAID5;
3315 @@ -5277,7 +5290,15 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
3316 stripe_nr = div64_u64(stripe_nr, stripe_len);
3317
3318 stripe_offset = stripe_nr * stripe_len;
3319 - BUG_ON(offset < stripe_offset);
3320 + if (offset < stripe_offset) {
3321 + btrfs_crit(fs_info, "stripe math has gone wrong, "
3322 + "stripe_offset=%llu, offset=%llu, start=%llu, "
3323 + "logical=%llu, stripe_len=%llu",
3324 + stripe_offset, offset, em->start, logical,
3325 + stripe_len);
3326 + free_extent_map(em);
3327 + return -EINVAL;
3328 + }
3329
3330 /* stripe_offset is the offset of this block in its stripe*/
3331 stripe_offset = offset - stripe_offset;
3332 @@ -5516,7 +5537,13 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
3333 &stripe_index);
3334 mirror_num = stripe_index + 1;
3335 }
3336 - BUG_ON(stripe_index >= map->num_stripes);
3337 + if (stripe_index >= map->num_stripes) {
3338 + btrfs_crit(fs_info, "stripe index math went horribly wrong, "
3339 + "got stripe_index=%u, num_stripes=%u",
3340 + stripe_index, map->num_stripes);
3341 + ret = -EINVAL;
3342 + goto out;
3343 + }
3344
3345 num_alloc_stripes = num_stripes;
3346 if (dev_replace_is_ongoing) {
3347 @@ -6237,7 +6264,7 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
3348 "invalid chunk length %llu", length);
3349 return -EIO;
3350 }
3351 - if (!is_power_of_2(stripe_len)) {
3352 + if (!is_power_of_2(stripe_len) || stripe_len != BTRFS_STRIPE_LEN) {
3353 btrfs_err(root->fs_info, "invalid chunk stripe length: %llu",
3354 stripe_len);
3355 return -EIO;
3356 diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
3357 index 1939ebde63df..7507be74f7da 100644
3358 --- a/fs/btrfs/volumes.h
3359 +++ b/fs/btrfs/volumes.h
3360 @@ -347,7 +347,7 @@ struct map_lookup {
3361 u64 type;
3362 int io_align;
3363 int io_width;
3364 - int stripe_len;
3365 + u64 stripe_len;
3366 int sector_size;
3367 int num_stripes;
3368 int sub_stripes;
3369 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
3370 index acc0ad56bf2f..50c0c540a2cf 100644
3371 --- a/fs/ext4/ialloc.c
3372 +++ b/fs/ext4/ialloc.c
3373 @@ -1150,25 +1150,20 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
3374 unsigned long max_ino = le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count);
3375 ext4_group_t block_group;
3376 int bit;
3377 - struct buffer_head *bitmap_bh;
3378 + struct buffer_head *bitmap_bh = NULL;
3379 struct inode *inode = NULL;
3380 - long err = -EIO;
3381 + int err = -EFSCORRUPTED;
3382
3383 - /* Error cases - e2fsck has already cleaned up for us */
3384 - if (ino > max_ino) {
3385 - ext4_warning(sb, "bad orphan ino %lu! e2fsck was run?", ino);
3386 - err = -EFSCORRUPTED;
3387 - goto error;
3388 - }
3389 + if (ino < EXT4_FIRST_INO(sb) || ino > max_ino)
3390 + goto bad_orphan;
3391
3392 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
3393 bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
3394 bitmap_bh = ext4_read_inode_bitmap(sb, block_group);
3395 if (IS_ERR(bitmap_bh)) {
3396 - err = PTR_ERR(bitmap_bh);
3397 - ext4_warning(sb, "inode bitmap error %ld for orphan %lu",
3398 - ino, err);
3399 - goto error;
3400 + ext4_error(sb, "inode bitmap error %ld for orphan %lu",
3401 + ino, PTR_ERR(bitmap_bh));
3402 + return (struct inode *) bitmap_bh;
3403 }
3404
3405 /* Having the inode bit set should be a 100% indicator that this
3406 @@ -1179,15 +1174,21 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
3407 goto bad_orphan;
3408
3409 inode = ext4_iget(sb, ino);
3410 - if (IS_ERR(inode))
3411 - goto iget_failed;
3412 + if (IS_ERR(inode)) {
3413 + err = PTR_ERR(inode);
3414 + ext4_error(sb, "couldn't read orphan inode %lu (err %d)",
3415 + ino, err);
3416 + return inode;
3417 + }
3418
3419 /*
3420 - * If the orphans has i_nlinks > 0 then it should be able to be
3421 - * truncated, otherwise it won't be removed from the orphan list
3422 - * during processing and an infinite loop will result.
3423 + * If the orphans has i_nlinks > 0 then it should be able to
3424 + * be truncated, otherwise it won't be removed from the orphan
3425 + * list during processing and an infinite loop will result.
3426 + * Similarly, it must not be a bad inode.
3427 */
3428 - if (inode->i_nlink && !ext4_can_truncate(inode))
3429 + if ((inode->i_nlink && !ext4_can_truncate(inode)) ||
3430 + is_bad_inode(inode))
3431 goto bad_orphan;
3432
3433 if (NEXT_ORPHAN(inode) > max_ino)
3434 @@ -1195,29 +1196,25 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
3435 brelse(bitmap_bh);
3436 return inode;
3437
3438 -iget_failed:
3439 - err = PTR_ERR(inode);
3440 - inode = NULL;
3441 bad_orphan:
3442 - ext4_warning(sb, "bad orphan inode %lu! e2fsck was run?", ino);
3443 - printk(KERN_WARNING "ext4_test_bit(bit=%d, block=%llu) = %d\n",
3444 - bit, (unsigned long long)bitmap_bh->b_blocknr,
3445 - ext4_test_bit(bit, bitmap_bh->b_data));
3446 - printk(KERN_WARNING "inode=%p\n", inode);
3447 + ext4_error(sb, "bad orphan inode %lu", ino);
3448 + if (bitmap_bh)
3449 + printk(KERN_ERR "ext4_test_bit(bit=%d, block=%llu) = %d\n",
3450 + bit, (unsigned long long)bitmap_bh->b_blocknr,
3451 + ext4_test_bit(bit, bitmap_bh->b_data));
3452 if (inode) {
3453 - printk(KERN_WARNING "is_bad_inode(inode)=%d\n",
3454 + printk(KERN_ERR "is_bad_inode(inode)=%d\n",
3455 is_bad_inode(inode));
3456 - printk(KERN_WARNING "NEXT_ORPHAN(inode)=%u\n",
3457 + printk(KERN_ERR "NEXT_ORPHAN(inode)=%u\n",
3458 NEXT_ORPHAN(inode));
3459 - printk(KERN_WARNING "max_ino=%lu\n", max_ino);
3460 - printk(KERN_WARNING "i_nlink=%u\n", inode->i_nlink);
3461 + printk(KERN_ERR "max_ino=%lu\n", max_ino);
3462 + printk(KERN_ERR "i_nlink=%u\n", inode->i_nlink);
3463 /* Avoid freeing blocks if we got a bad deleted inode */
3464 if (inode->i_nlink == 0)
3465 inode->i_blocks = 0;
3466 iput(inode);
3467 }
3468 brelse(bitmap_bh);
3469 -error:
3470 return ERR_PTR(err);
3471 }
3472
3473 diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
3474 index eae5917c534e..0acf8cacb2be 100644
3475 --- a/fs/ext4/ioctl.c
3476 +++ b/fs/ext4/ioctl.c
3477 @@ -365,7 +365,7 @@ static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
3478 struct dquot *transfer_to[MAXQUOTAS] = { };
3479
3480 transfer_to[PRJQUOTA] = dqget(sb, make_kqid_projid(kprojid));
3481 - if (transfer_to[PRJQUOTA]) {
3482 + if (!IS_ERR(transfer_to[PRJQUOTA])) {
3483 err = __dquot_transfer(inode, transfer_to);
3484 dqput(transfer_to[PRJQUOTA]);
3485 if (err)
3486 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
3487 index 4424b7bf8ac6..da07228035c7 100644
3488 --- a/fs/ext4/mballoc.c
3489 +++ b/fs/ext4/mballoc.c
3490 @@ -1259,6 +1259,7 @@ static void ext4_mb_unload_buddy(struct ext4_buddy *e4b)
3491 static int mb_find_order_for_block(struct ext4_buddy *e4b, int block)
3492 {
3493 int order = 1;
3494 + int bb_incr = 1 << (e4b->bd_blkbits - 1);
3495 void *bb;
3496
3497 BUG_ON(e4b->bd_bitmap == e4b->bd_buddy);
3498 @@ -1271,7 +1272,8 @@ static int mb_find_order_for_block(struct ext4_buddy *e4b, int block)
3499 /* this block is part of buddy of order 'order' */
3500 return order;
3501 }
3502 - bb += 1 << (e4b->bd_blkbits - order);
3503 + bb += bb_incr;
3504 + bb_incr >>= 1;
3505 order++;
3506 }
3507 return 0;
3508 @@ -2576,7 +2578,7 @@ int ext4_mb_init(struct super_block *sb)
3509 {
3510 struct ext4_sb_info *sbi = EXT4_SB(sb);
3511 unsigned i, j;
3512 - unsigned offset;
3513 + unsigned offset, offset_incr;
3514 unsigned max;
3515 int ret;
3516
3517 @@ -2605,11 +2607,13 @@ int ext4_mb_init(struct super_block *sb)
3518
3519 i = 1;
3520 offset = 0;
3521 + offset_incr = 1 << (sb->s_blocksize_bits - 1);
3522 max = sb->s_blocksize << 2;
3523 do {
3524 sbi->s_mb_offsets[i] = offset;
3525 sbi->s_mb_maxs[i] = max;
3526 - offset += 1 << (sb->s_blocksize_bits - i);
3527 + offset += offset_incr;
3528 + offset_incr = offset_incr >> 1;
3529 max = max >> 1;
3530 i++;
3531 } while (i <= sb->s_blocksize_bits + 1);
3532 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
3533 index 48e4b8907826..fdd151f91522 100644
3534 --- a/fs/ext4/namei.c
3535 +++ b/fs/ext4/namei.c
3536 @@ -2828,7 +2828,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
3537 * list entries can cause panics at unmount time.
3538 */
3539 mutex_lock(&sbi->s_orphan_lock);
3540 - list_del(&EXT4_I(inode)->i_orphan);
3541 + list_del_init(&EXT4_I(inode)->i_orphan);
3542 mutex_unlock(&sbi->s_orphan_lock);
3543 }
3544 }
3545 diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
3546 index 81ac6480f9e7..c6dd0c4005cb 100644
3547 --- a/fs/nfs/pnfs_nfs.c
3548 +++ b/fs/nfs/pnfs_nfs.c
3549 @@ -246,6 +246,23 @@ void pnfs_fetch_commit_bucket_list(struct list_head *pages,
3550
3551 }
3552
3553 +/* Helper function for pnfs_generic_commit_pagelist to catch an empty
3554 + * page list. This can happen when two commits race. */
3555 +static bool
3556 +pnfs_generic_commit_cancel_empty_pagelist(struct list_head *pages,
3557 + struct nfs_commit_data *data,
3558 + struct nfs_commit_info *cinfo)
3559 +{
3560 + if (list_empty(pages)) {
3561 + if (atomic_dec_and_test(&cinfo->mds->rpcs_out))
3562 + wake_up_atomic_t(&cinfo->mds->rpcs_out);
3563 + nfs_commitdata_release(data);
3564 + return true;
3565 + }
3566 +
3567 + return false;
3568 +}
3569 +
3570 /* This follows nfs_commit_list pretty closely */
3571 int
3572 pnfs_generic_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
3573 @@ -280,6 +297,11 @@ pnfs_generic_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
3574 list_for_each_entry_safe(data, tmp, &list, pages) {
3575 list_del_init(&data->pages);
3576 if (data->ds_commit_index < 0) {
3577 + /* another commit raced with us */
3578 + if (pnfs_generic_commit_cancel_empty_pagelist(mds_pages,
3579 + data, cinfo))
3580 + continue;
3581 +
3582 nfs_init_commit(data, mds_pages, NULL, cinfo);
3583 nfs_initiate_commit(NFS_CLIENT(inode), data,
3584 NFS_PROTO(data->inode),
3585 @@ -288,6 +310,12 @@ pnfs_generic_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
3586 LIST_HEAD(pages);
3587
3588 pnfs_fetch_commit_bucket_list(&pages, data, cinfo);
3589 +
3590 + /* another commit raced with us */
3591 + if (pnfs_generic_commit_cancel_empty_pagelist(&pages,
3592 + data, cinfo))
3593 + continue;
3594 +
3595 nfs_init_commit(data, &pages, data->lseg, cinfo);
3596 initiate_commit(data, how);
3597 }
3598 diff --git a/fs/nfs/write.c b/fs/nfs/write.c
3599 index 5754835a2886..505bf3e69677 100644
3600 --- a/fs/nfs/write.c
3601 +++ b/fs/nfs/write.c
3602 @@ -1709,6 +1709,10 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how,
3603 {
3604 struct nfs_commit_data *data;
3605
3606 + /* another commit raced with us */
3607 + if (list_empty(head))
3608 + return 0;
3609 +
3610 data = nfs_commitdata_alloc();
3611
3612 if (!data)
3613 diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
3614 index ee3aaa0a5317..ca0d3eb44925 100644
3615 --- a/fs/xfs/xfs_fsops.c
3616 +++ b/fs/xfs/xfs_fsops.c
3617 @@ -243,8 +243,8 @@ xfs_growfs_data_private(
3618 agf->agf_roots[XFS_BTNUM_CNTi] = cpu_to_be32(XFS_CNT_BLOCK(mp));
3619 agf->agf_levels[XFS_BTNUM_BNOi] = cpu_to_be32(1);
3620 agf->agf_levels[XFS_BTNUM_CNTi] = cpu_to_be32(1);
3621 - agf->agf_flfirst = 0;
3622 - agf->agf_fllast = cpu_to_be32(XFS_AGFL_SIZE(mp) - 1);
3623 + agf->agf_flfirst = cpu_to_be32(1);
3624 + agf->agf_fllast = 0;
3625 agf->agf_flcount = 0;
3626 tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp);
3627 agf->agf_freeblks = cpu_to_be32(tmpsize);
3628 diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
3629 index ceba1a83cacc..c738a5297147 100644
3630 --- a/fs/xfs/xfs_inode.c
3631 +++ b/fs/xfs/xfs_inode.c
3632 @@ -3225,13 +3225,14 @@ xfs_iflush_cluster(
3633 * We need to check under the i_flags_lock for a valid inode
3634 * here. Skip it if it is not valid or the wrong inode.
3635 */
3636 - spin_lock(&ip->i_flags_lock);
3637 - if (!ip->i_ino ||
3638 + spin_lock(&iq->i_flags_lock);
3639 + if (!iq->i_ino ||
3640 + __xfs_iflags_test(iq, XFS_ISTALE) ||
3641 (XFS_INO_TO_AGINO(mp, iq->i_ino) & mask) != first_index) {
3642 - spin_unlock(&ip->i_flags_lock);
3643 + spin_unlock(&iq->i_flags_lock);
3644 continue;
3645 }
3646 - spin_unlock(&ip->i_flags_lock);
3647 + spin_unlock(&iq->i_flags_lock);
3648
3649 /*
3650 * Do an un-protected check to see if the inode is dirty and
3651 @@ -3347,7 +3348,7 @@ xfs_iflush(
3652 struct xfs_buf **bpp)
3653 {
3654 struct xfs_mount *mp = ip->i_mount;
3655 - struct xfs_buf *bp;
3656 + struct xfs_buf *bp = NULL;
3657 struct xfs_dinode *dip;
3658 int error;
3659
3660 @@ -3389,14 +3390,22 @@ xfs_iflush(
3661 }
3662
3663 /*
3664 - * Get the buffer containing the on-disk inode.
3665 + * Get the buffer containing the on-disk inode. We are doing a try-lock
3666 + * operation here, so we may get an EAGAIN error. In that case, we
3667 + * simply want to return with the inode still dirty.
3668 + *
3669 + * If we get any other error, we effectively have a corruption situation
3670 + * and we cannot flush the inode, so we treat it the same as failing
3671 + * xfs_iflush_int().
3672 */
3673 error = xfs_imap_to_bp(mp, NULL, &ip->i_imap, &dip, &bp, XBF_TRYLOCK,
3674 0);
3675 - if (error || !bp) {
3676 + if (error == -EAGAIN) {
3677 xfs_ifunlock(ip);
3678 return error;
3679 }
3680 + if (error)
3681 + goto corrupt_out;
3682
3683 /*
3684 * First flush out the inode that xfs_iflush was called with.
3685 @@ -3424,7 +3433,8 @@ xfs_iflush(
3686 return 0;
3687
3688 corrupt_out:
3689 - xfs_buf_relse(bp);
3690 + if (bp)
3691 + xfs_buf_relse(bp);
3692 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
3693 cluster_corrupt_out:
3694 error = -EFSCORRUPTED;
3695 diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
3696 index 59c9b7bd958d..5cc9ae6107af 100644
3697 --- a/fs/xfs/xfs_super.c
3698 +++ b/fs/xfs/xfs_super.c
3699 @@ -1233,6 +1233,16 @@ xfs_fs_remount(
3700 return -EINVAL;
3701 }
3702
3703 + if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 &&
3704 + xfs_sb_has_ro_compat_feature(sbp,
3705 + XFS_SB_FEAT_RO_COMPAT_UNKNOWN)) {
3706 + xfs_warn(mp,
3707 +"ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem",
3708 + (sbp->sb_features_ro_compat &
3709 + XFS_SB_FEAT_RO_COMPAT_UNKNOWN));
3710 + return -EINVAL;
3711 + }
3712 +
3713 mp->m_flags &= ~XFS_MOUNT_RDONLY;
3714
3715 /*
3716 diff --git a/include/linux/mm.h b/include/linux/mm.h
3717 index e4e59f9d82f1..5eaac6decb2b 100644
3718 --- a/include/linux/mm.h
3719 +++ b/include/linux/mm.h
3720 @@ -1763,7 +1763,7 @@ extern void free_highmem_page(struct page *page);
3721 extern void adjust_managed_page_count(struct page *page, long count);
3722 extern void mem_init_print_info(const char *str);
3723
3724 -extern void reserve_bootmem_region(unsigned long start, unsigned long end);
3725 +extern void reserve_bootmem_region(phys_addr_t start, phys_addr_t end);
3726
3727 /* Free the reserved page into the buddy system, so it gets managed. */
3728 static inline void __free_reserved_page(struct page *page)
3729 diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
3730 index eeba75395f7d..c8529ce28a3f 100644
3731 --- a/include/video/imx-ipu-v3.h
3732 +++ b/include/video/imx-ipu-v3.h
3733 @@ -16,6 +16,7 @@
3734 #include <linux/videodev2.h>
3735 #include <linux/bitmap.h>
3736 #include <linux/fb.h>
3737 +#include <linux/of.h>
3738 #include <media/v4l2-mediabus.h>
3739 #include <video/videomode.h>
3740
3741 @@ -344,6 +345,7 @@ struct ipu_client_platformdata {
3742 int dc;
3743 int dp;
3744 int dma[2];
3745 + struct device_node *of_node;
3746 };
3747
3748 #endif /* __DRM_IPU_H__ */
3749 diff --git a/kernel/exit.c b/kernel/exit.c
3750 index 10e088237fed..c112abb736f6 100644
3751 --- a/kernel/exit.c
3752 +++ b/kernel/exit.c
3753 @@ -916,17 +916,28 @@ static int eligible_pid(struct wait_opts *wo, struct task_struct *p)
3754 task_pid_type(p, wo->wo_type) == wo->wo_pid;
3755 }
3756
3757 -static int eligible_child(struct wait_opts *wo, struct task_struct *p)
3758 +static int
3759 +eligible_child(struct wait_opts *wo, bool ptrace, struct task_struct *p)
3760 {
3761 if (!eligible_pid(wo, p))
3762 return 0;
3763 - /* Wait for all children (clone and not) if __WALL is set;
3764 - * otherwise, wait for clone children *only* if __WCLONE is
3765 - * set; otherwise, wait for non-clone children *only*. (Note:
3766 - * A "clone" child here is one that reports to its parent
3767 - * using a signal other than SIGCHLD.) */
3768 - if (((p->exit_signal != SIGCHLD) ^ !!(wo->wo_flags & __WCLONE))
3769 - && !(wo->wo_flags & __WALL))
3770 +
3771 + /*
3772 + * Wait for all children (clone and not) if __WALL is set or
3773 + * if it is traced by us.
3774 + */
3775 + if (ptrace || (wo->wo_flags & __WALL))
3776 + return 1;
3777 +
3778 + /*
3779 + * Otherwise, wait for clone children *only* if __WCLONE is set;
3780 + * otherwise, wait for non-clone children *only*.
3781 + *
3782 + * Note: a "clone" child here is one that reports to its parent
3783 + * using a signal other than SIGCHLD, or a non-leader thread which
3784 + * we can only see if it is traced by us.
3785 + */
3786 + if ((p->exit_signal != SIGCHLD) ^ !!(wo->wo_flags & __WCLONE))
3787 return 0;
3788
3789 return 1;
3790 @@ -1298,7 +1309,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
3791 if (unlikely(exit_state == EXIT_DEAD))
3792 return 0;
3793
3794 - ret = eligible_child(wo, p);
3795 + ret = eligible_child(wo, ptrace, p);
3796 if (!ret)
3797 return ret;
3798
3799 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
3800 index 4a1515f4b452..51a76af25c66 100644
3801 --- a/lib/dma-debug.c
3802 +++ b/lib/dma-debug.c
3803 @@ -657,9 +657,9 @@ static struct dma_debug_entry *dma_entry_alloc(void)
3804 spin_lock_irqsave(&free_entries_lock, flags);
3805
3806 if (list_empty(&free_entries)) {
3807 - pr_err("DMA-API: debugging out of memory - disabling\n");
3808 global_disable = true;
3809 spin_unlock_irqrestore(&free_entries_lock, flags);
3810 + pr_err("DMA-API: debugging out of memory - disabling\n");
3811 return NULL;
3812 }
3813
3814 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
3815 index 629ce645cffd..1d11790639f0 100644
3816 --- a/mm/page_alloc.c
3817 +++ b/mm/page_alloc.c
3818 @@ -971,7 +971,7 @@ static inline void init_reserved_page(unsigned long pfn)
3819 * marks the pages PageReserved. The remaining valid pages are later
3820 * sent to the buddy page allocator.
3821 */
3822 -void __meminit reserve_bootmem_region(unsigned long start, unsigned long end)
3823 +void __meminit reserve_bootmem_region(phys_addr_t start, phys_addr_t end)
3824 {
3825 unsigned long start_pfn = PFN_DOWN(start);
3826 unsigned long end_pfn = PFN_UP(end);
3827 diff --git a/mm/rmap.c b/mm/rmap.c
3828 index 79f3bf047f38..be84cde3b48d 100644
3829 --- a/mm/rmap.c
3830 +++ b/mm/rmap.c
3831 @@ -1112,6 +1112,8 @@ void page_move_anon_rmap(struct page *page,
3832
3833 VM_BUG_ON_PAGE(!PageLocked(page), page);
3834 VM_BUG_ON_VMA(!anon_vma, vma);
3835 + if (IS_ENABLED(CONFIG_DEBUG_VM) && PageTransHuge(page))
3836 + address &= HPAGE_PMD_MASK;
3837 VM_BUG_ON_PAGE(page->index != linear_page_index(vma, address), page);
3838
3839 anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
3840 diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
3841 index 8a4cc2f7f0db..e45cb9155039 100644
3842 --- a/net/bluetooth/6lowpan.c
3843 +++ b/net/bluetooth/6lowpan.c
3844 @@ -431,15 +431,18 @@ static int setup_header(struct sk_buff *skb, struct net_device *netdev,
3845 bdaddr_t *peer_addr, u8 *peer_addr_type)
3846 {
3847 struct in6_addr ipv6_daddr;
3848 + struct ipv6hdr *hdr;
3849 struct lowpan_dev *dev;
3850 struct lowpan_peer *peer;
3851 bdaddr_t addr, *any = BDADDR_ANY;
3852 u8 *daddr = any->b;
3853 int err, status = 0;
3854
3855 + hdr = ipv6_hdr(skb);
3856 +
3857 dev = lowpan_dev(netdev);
3858
3859 - memcpy(&ipv6_daddr, &lowpan_cb(skb)->addr, sizeof(ipv6_daddr));
3860 + memcpy(&ipv6_daddr, &hdr->daddr, sizeof(ipv6_daddr));
3861
3862 if (ipv6_addr_is_multicast(&ipv6_daddr)) {
3863 lowpan_cb(skb)->chan = NULL;
3864 @@ -489,15 +492,9 @@ static int header_create(struct sk_buff *skb, struct net_device *netdev,
3865 unsigned short type, const void *_daddr,
3866 const void *_saddr, unsigned int len)
3867 {
3868 - struct ipv6hdr *hdr;
3869 -
3870 if (type != ETH_P_IPV6)
3871 return -EINVAL;
3872
3873 - hdr = ipv6_hdr(skb);
3874 -
3875 - memcpy(&lowpan_cb(skb)->addr, &hdr->daddr, sizeof(struct in6_addr));
3876 -
3877 return 0;
3878 }
3879
3880 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
3881 index 1095be9c80ab..4605dc73def6 100644
3882 --- a/net/sunrpc/auth_gss/svcauth_gss.c
3883 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
3884 @@ -857,8 +857,8 @@ unwrap_integ_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct g
3885 goto out;
3886 if (svc_getnl(&buf->head[0]) != seq)
3887 goto out;
3888 - /* trim off the mic at the end before returning */
3889 - xdr_buf_trim(buf, mic.len + 4);
3890 + /* trim off the mic and padding at the end before returning */
3891 + xdr_buf_trim(buf, round_up_to_quad(mic.len) + 4);
3892 stat = 0;
3893 out:
3894 kfree(mic.data);
3895 diff --git a/scripts/package/Makefile b/scripts/package/Makefile
3896 index c2c7389bfbab..71b4a8af9d4d 100644
3897 --- a/scripts/package/Makefile
3898 +++ b/scripts/package/Makefile
3899 @@ -52,7 +52,7 @@ rpm-pkg rpm: FORCE
3900 $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
3901 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
3902 mv -f $(objtree)/.tmp_version $(objtree)/.version
3903 - rpmbuild --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
3904 + rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
3905 rm $(KERNELPATH).tar.gz kernel.spec
3906
3907 # binrpm-pkg
3908 @@ -63,7 +63,7 @@ binrpm-pkg: FORCE
3909 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
3910 mv -f $(objtree)/.tmp_version $(objtree)/.version
3911
3912 - rpmbuild --define "_builddir $(objtree)" --target \
3913 + rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
3914 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
3915 rm binkernel.spec
3916
3917 diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
3918 index cda27c22812a..eb8fe212e163 100644
3919 --- a/sound/soc/codecs/ak4642.c
3920 +++ b/sound/soc/codecs/ak4642.c
3921 @@ -560,6 +560,7 @@ static const struct regmap_config ak4642_regmap = {
3922 .max_register = FIL1_3,
3923 .reg_defaults = ak4642_reg,
3924 .num_reg_defaults = NUM_AK4642_REG_DEFAULTS,
3925 + .cache_type = REGCACHE_RBTREE,
3926 };
3927
3928 static const struct regmap_config ak4643_regmap = {
3929 @@ -568,6 +569,7 @@ static const struct regmap_config ak4643_regmap = {
3930 .max_register = SPK_MS,
3931 .reg_defaults = ak4643_reg,
3932 .num_reg_defaults = ARRAY_SIZE(ak4643_reg),
3933 + .cache_type = REGCACHE_RBTREE,
3934 };
3935
3936 static const struct regmap_config ak4648_regmap = {
3937 @@ -576,6 +578,7 @@ static const struct regmap_config ak4648_regmap = {
3938 .max_register = EQ_FBEQE,
3939 .reg_defaults = ak4648_reg,
3940 .num_reg_defaults = ARRAY_SIZE(ak4648_reg),
3941 + .cache_type = REGCACHE_RBTREE,
3942 };
3943
3944 static const struct ak4642_drvdata ak4642_drvdata = {