Magellan Linux

Annotation of /trunk/kernel-alx/patches-3.18/0114-3.18.15-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2615 - (hide annotations) (download)
Mon Jul 13 08:28:58 2015 UTC (8 years, 10 months ago) by niro
File size: 210489 byte(s)
-linux-3.18.15
1 niro 2615 diff --git a/Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt b/Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt
2     index a4873e5e3e36..e30e184f50c7 100644
3     --- a/Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt
4     +++ b/Documentation/devicetree/bindings/dma/fsl-mxs-dma.txt
5     @@ -38,7 +38,7 @@ dma_apbx: dma-apbx@80024000 {
6     80 81 68 69
7     70 71 72 73
8     74 75 76 77>;
9     - interrupt-names = "auart4-rx", "aurat4-tx", "spdif-tx", "empty",
10     + interrupt-names = "auart4-rx", "auart4-tx", "spdif-tx", "empty",
11     "saif0", "saif1", "i2c0", "i2c1",
12     "auart0-rx", "auart0-tx", "auart1-rx", "auart1-tx",
13     "auart2-rx", "auart2-tx", "auart3-rx", "auart3-tx";
14     diff --git a/Documentation/virtual/kvm/mmu.txt b/Documentation/virtual/kvm/mmu.txt
15     index 53838d9c6295..c59bd9bc41ef 100644
16     --- a/Documentation/virtual/kvm/mmu.txt
17     +++ b/Documentation/virtual/kvm/mmu.txt
18     @@ -169,6 +169,10 @@ Shadow pages contain the following information:
19     Contains the value of cr4.smep && !cr0.wp for which the page is valid
20     (pages for which this is true are different from other pages; see the
21     treatment of cr0.wp=0 below).
22     + role.smap_andnot_wp:
23     + Contains the value of cr4.smap && !cr0.wp for which the page is valid
24     + (pages for which this is true are different from other pages; see the
25     + treatment of cr0.wp=0 below).
26     gfn:
27     Either the guest page table containing the translations shadowed by this
28     page, or the base page frame for linear translations. See role.direct.
29     @@ -344,10 +348,16 @@ on fault type:
30    
31     (user write faults generate a #PF)
32    
33     -In the first case there is an additional complication if CR4.SMEP is
34     -enabled: since we've turned the page into a kernel page, the kernel may now
35     -execute it. We handle this by also setting spte.nx. If we get a user
36     -fetch or read fault, we'll change spte.u=1 and spte.nx=gpte.nx back.
37     +In the first case there are two additional complications:
38     +- if CR4.SMEP is enabled: since we've turned the page into a kernel page,
39     + the kernel may now execute it. We handle this by also setting spte.nx.
40     + If we get a user fetch or read fault, we'll change spte.u=1 and
41     + spte.nx=gpte.nx back.
42     +- if CR4.SMAP is disabled: since the page has been changed to a kernel
43     + page, it can not be reused when CR4.SMAP is enabled. We set
44     + CR4.SMAP && !CR0.WP into shadow page's role to avoid this case. Note,
45     + here we do not care the case that CR4.SMAP is enabled since KVM will
46     + directly inject #PF to guest due to failed permission check.
47    
48     To prevent an spte that was converted into a kernel page with cr0.wp=0
49     from being written by the kernel after cr0.wp has changed to 1, we make
50     diff --git a/Makefile b/Makefile
51     index 43377eb8a4e5..cda98de8cd31 100644
52     --- a/Makefile
53     +++ b/Makefile
54     @@ -1,6 +1,6 @@
55     VERSION = 3
56     PATCHLEVEL = 18
57     -SUBLEVEL = 14
58     +SUBLEVEL = 15
59     EXTRAVERSION =
60     NAME = Diseased Newt
61    
62     diff --git a/arch/arc/include/asm/atomic.h b/arch/arc/include/asm/atomic.h
63     index 067551b6920a..9917a45fc430 100644
64     --- a/arch/arc/include/asm/atomic.h
65     +++ b/arch/arc/include/asm/atomic.h
66     @@ -99,7 +99,7 @@ static inline void atomic_##op(int i, atomic_t *v) \
67     atomic_ops_unlock(flags); \
68     }
69    
70     -#define ATOMIC_OP_RETURN(op, c_op) \
71     +#define ATOMIC_OP_RETURN(op, c_op, asm_op) \
72     static inline int atomic_##op##_return(int i, atomic_t *v) \
73     { \
74     unsigned long flags; \
75     diff --git a/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts b/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
76     index 4e5a59ee1501..db06fa397f79 100644
77     --- a/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
78     +++ b/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
79     @@ -71,6 +71,10 @@
80     };
81    
82     internal-regs {
83     + rtc@10300 {
84     + /* No crystal connected to the internal RTC */
85     + status = "disabled";
86     + };
87     serial@12000 {
88     status = "okay";
89     };
90     diff --git a/arch/arm/boot/dts/imx23-olinuxino.dts b/arch/arm/boot/dts/imx23-olinuxino.dts
91     index 7e6eef2488e8..82045398bf1f 100644
92     --- a/arch/arm/boot/dts/imx23-olinuxino.dts
93     +++ b/arch/arm/boot/dts/imx23-olinuxino.dts
94     @@ -12,6 +12,7 @@
95     */
96    
97     /dts-v1/;
98     +#include <dt-bindings/gpio/gpio.h>
99     #include "imx23.dtsi"
100    
101     / {
102     @@ -93,6 +94,7 @@
103    
104     ahb@80080000 {
105     usb0: usb@80080000 {
106     + dr_mode = "host";
107     vbus-supply = <&reg_usb0_vbus>;
108     status = "okay";
109     };
110     @@ -122,7 +124,7 @@
111    
112     user {
113     label = "green";
114     - gpios = <&gpio2 1 1>;
115     + gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>;
116     };
117     };
118     };
119     diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
120     index e4d3aecc4ed2..677f81d9dcd5 100644
121     --- a/arch/arm/boot/dts/imx25.dtsi
122     +++ b/arch/arm/boot/dts/imx25.dtsi
123     @@ -428,6 +428,7 @@
124    
125     pwm4: pwm@53fc8000 {
126     compatible = "fsl,imx25-pwm", "fsl,imx27-pwm";
127     + #pwm-cells = <2>;
128     reg = <0x53fc8000 0x4000>;
129     clocks = <&clks 108>, <&clks 52>;
130     clock-names = "ipg", "per";
131     diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
132     index 107d713e1cbe..12ac5f7e0a2e 100644
133     --- a/arch/arm/boot/dts/imx27.dtsi
134     +++ b/arch/arm/boot/dts/imx27.dtsi
135     @@ -531,7 +531,7 @@
136    
137     fec: ethernet@1002b000 {
138     compatible = "fsl,imx27-fec";
139     - reg = <0x1002b000 0x4000>;
140     + reg = <0x1002b000 0x1000>;
141     interrupts = <50>;
142     clocks = <&clks IMX27_CLK_FEC_IPG_GATE>,
143     <&clks IMX27_CLK_FEC_AHB_GATE>;
144     diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
145     index 47f68ac868d4..5ed245a3f9ac 100644
146     --- a/arch/arm/boot/dts/imx28.dtsi
147     +++ b/arch/arm/boot/dts/imx28.dtsi
148     @@ -900,7 +900,7 @@
149     80 81 68 69
150     70 71 72 73
151     74 75 76 77>;
152     - interrupt-names = "auart4-rx", "aurat4-tx", "spdif-tx", "empty",
153     + interrupt-names = "auart4-rx", "auart4-tx", "spdif-tx", "empty",
154     "saif0", "saif1", "i2c0", "i2c1",
155     "auart0-rx", "auart0-tx", "auart1-rx", "auart1-tx",
156     "auart2-rx", "auart2-tx", "auart3-rx", "auart3-tx";
157     diff --git a/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi b/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi
158     index 0e50bb0a6b94..413569752422 100644
159     --- a/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi
160     +++ b/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi
161     @@ -31,6 +31,7 @@
162     regulator-min-microvolt = <5000000>;
163     regulator-max-microvolt = <5000000>;
164     gpio = <&gpio4 15 0>;
165     + enable-active-high;
166     };
167    
168     reg_usb_h1_vbus: regulator@1 {
169     @@ -40,6 +41,7 @@
170     regulator-min-microvolt = <5000000>;
171     regulator-max-microvolt = <5000000>;
172     gpio = <&gpio1 0 0>;
173     + enable-active-high;
174     };
175     };
176    
177     diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
178     index bc82a12d4c2c..ae630a928acd 100644
179     --- a/arch/arm/boot/dts/omap3-n900.dts
180     +++ b/arch/arm/boot/dts/omap3-n900.dts
181     @@ -445,6 +445,8 @@
182     DRVDD-supply = <&vmmc2>;
183     IOVDD-supply = <&vio>;
184     DVDD-supply = <&vio>;
185     +
186     + ai3x-micbias-vg = <1>;
187     };
188    
189     tlv320aic3x_aux: tlv320aic3x@19 {
190     @@ -456,6 +458,8 @@
191     DRVDD-supply = <&vmmc2>;
192     IOVDD-supply = <&vio>;
193     DVDD-supply = <&vio>;
194     +
195     + ai3x-micbias-vg = <2>;
196     };
197    
198     tsl2563: tsl2563@29 {
199     diff --git a/arch/arm/boot/dts/ste-dbx5x0.dtsi b/arch/arm/boot/dts/ste-dbx5x0.dtsi
200     index 9d2323020d34..563640f59a41 100644
201     --- a/arch/arm/boot/dts/ste-dbx5x0.dtsi
202     +++ b/arch/arm/boot/dts/ste-dbx5x0.dtsi
203     @@ -995,23 +995,6 @@
204     status = "disabled";
205     };
206    
207     - vmmci: regulator-gpio {
208     - compatible = "regulator-gpio";
209     -
210     - regulator-min-microvolt = <1800000>;
211     - regulator-max-microvolt = <2900000>;
212     - regulator-name = "mmci-reg";
213     - regulator-type = "voltage";
214     -
215     - startup-delay-us = <100>;
216     - enable-active-high;
217     -
218     - states = <1800000 0x1
219     - 2900000 0x0>;
220     -
221     - status = "disabled";
222     - };
223     -
224     mcde@a0350000 {
225     compatible = "stericsson,mcde";
226     reg = <0xa0350000 0x1000>, /* MCDE */
227     diff --git a/arch/arm/boot/dts/ste-href.dtsi b/arch/arm/boot/dts/ste-href.dtsi
228     index bf8f0eddc2c0..744c1e3a744d 100644
229     --- a/arch/arm/boot/dts/ste-href.dtsi
230     +++ b/arch/arm/boot/dts/ste-href.dtsi
231     @@ -111,6 +111,21 @@
232     pinctrl-1 = <&i2c3_sleep_mode>;
233     };
234    
235     + vmmci: regulator-gpio {
236     + compatible = "regulator-gpio";
237     +
238     + regulator-min-microvolt = <1800000>;
239     + regulator-max-microvolt = <2900000>;
240     + regulator-name = "mmci-reg";
241     + regulator-type = "voltage";
242     +
243     + startup-delay-us = <100>;
244     + enable-active-high;
245     +
246     + states = <1800000 0x1
247     + 2900000 0x0>;
248     + };
249     +
250     // External Micro SD slot
251     sdi0_per1@80126000 {
252     arm,primecell-periphid = <0x10480180>;
253     diff --git a/arch/arm/boot/dts/ste-snowball.dts b/arch/arm/boot/dts/ste-snowball.dts
254     index 3e97a669f15e..17c4422def0e 100644
255     --- a/arch/arm/boot/dts/ste-snowball.dts
256     +++ b/arch/arm/boot/dts/ste-snowball.dts
257     @@ -146,8 +146,21 @@
258     };
259    
260     vmmci: regulator-gpio {
261     + compatible = "regulator-gpio";
262     +
263     gpios = <&gpio7 4 0x4>;
264     enable-gpio = <&gpio6 25 0x4>;
265     +
266     + regulator-min-microvolt = <1800000>;
267     + regulator-max-microvolt = <2900000>;
268     + regulator-name = "mmci-reg";
269     + regulator-type = "voltage";
270     +
271     + startup-delay-us = <100>;
272     + enable-active-high;
273     +
274     + states = <1800000 0x1
275     + 2900000 0x0>;
276     };
277    
278     // External Micro SD slot
279     diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
280     index 38ddd9f83d0e..03120e656aea 100644
281     --- a/arch/arm/kernel/Makefile
282     +++ b/arch/arm/kernel/Makefile
283     @@ -97,7 +97,7 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
284    
285     obj-$(CONFIG_ARM_VIRT_EXT) += hyp-stub.o
286     ifeq ($(CONFIG_ARM_PSCI),y)
287     -obj-y += psci.o
288     +obj-y += psci.o psci-call.o
289     obj-$(CONFIG_SMP) += psci_smp.o
290     endif
291    
292     diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
293     index 6bb09d4abdea..eb6f1927b2c7 100644
294     --- a/arch/arm/kernel/entry-common.S
295     +++ b/arch/arm/kernel/entry-common.S
296     @@ -33,7 +33,9 @@ ret_fast_syscall:
297     UNWIND(.fnstart )
298     UNWIND(.cantunwind )
299     disable_irq @ disable interrupts
300     - ldr r1, [tsk, #TI_FLAGS]
301     + ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing
302     + tst r1, #_TIF_SYSCALL_WORK
303     + bne __sys_trace_return
304     tst r1, #_TIF_WORK_MASK
305     bne fast_work_pending
306     asm_trace_hardirqs_on
307     diff --git a/arch/arm/kernel/psci-call.S b/arch/arm/kernel/psci-call.S
308     new file mode 100644
309     index 000000000000..a78e9e1e206d
310     --- /dev/null
311     +++ b/arch/arm/kernel/psci-call.S
312     @@ -0,0 +1,31 @@
313     +/*
314     + * This program is free software; you can redistribute it and/or modify
315     + * it under the terms of the GNU General Public License version 2 as
316     + * published by the Free Software Foundation.
317     + *
318     + * This program is distributed in the hope that it will be useful,
319     + * but WITHOUT ANY WARRANTY; without even the implied warranty of
320     + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
321     + * GNU General Public License for more details.
322     + *
323     + * Copyright (C) 2015 ARM Limited
324     + *
325     + * Author: Mark Rutland <mark.rutland@arm.com>
326     + */
327     +
328     +#include <linux/linkage.h>
329     +
330     +#include <asm/opcodes-sec.h>
331     +#include <asm/opcodes-virt.h>
332     +
333     +/* int __invoke_psci_fn_hvc(u32 function_id, u32 arg0, u32 arg1, u32 arg2) */
334     +ENTRY(__invoke_psci_fn_hvc)
335     + __HVC(0)
336     + bx lr
337     +ENDPROC(__invoke_psci_fn_hvc)
338     +
339     +/* int __invoke_psci_fn_smc(u32 function_id, u32 arg0, u32 arg1, u32 arg2) */
340     +ENTRY(__invoke_psci_fn_smc)
341     + __SMC(0)
342     + bx lr
343     +ENDPROC(__invoke_psci_fn_smc)
344     diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
345     index f73891b6b730..f90fdf4ce7c7 100644
346     --- a/arch/arm/kernel/psci.c
347     +++ b/arch/arm/kernel/psci.c
348     @@ -23,8 +23,6 @@
349    
350     #include <asm/compiler.h>
351     #include <asm/errno.h>
352     -#include <asm/opcodes-sec.h>
353     -#include <asm/opcodes-virt.h>
354     #include <asm/psci.h>
355     #include <asm/system_misc.h>
356    
357     @@ -33,6 +31,9 @@ struct psci_operations psci_ops;
358     static int (*invoke_psci_fn)(u32, u32, u32, u32);
359     typedef int (*psci_initcall_t)(const struct device_node *);
360    
361     +asmlinkage int __invoke_psci_fn_hvc(u32, u32, u32, u32);
362     +asmlinkage int __invoke_psci_fn_smc(u32, u32, u32, u32);
363     +
364     enum psci_function {
365     PSCI_FN_CPU_SUSPEND,
366     PSCI_FN_CPU_ON,
367     @@ -71,40 +72,6 @@ static u32 psci_power_state_pack(struct psci_power_state state)
368     & PSCI_0_2_POWER_STATE_AFFL_MASK);
369     }
370    
371     -/*
372     - * The following two functions are invoked via the invoke_psci_fn pointer
373     - * and will not be inlined, allowing us to piggyback on the AAPCS.
374     - */
375     -static noinline int __invoke_psci_fn_hvc(u32 function_id, u32 arg0, u32 arg1,
376     - u32 arg2)
377     -{
378     - asm volatile(
379     - __asmeq("%0", "r0")
380     - __asmeq("%1", "r1")
381     - __asmeq("%2", "r2")
382     - __asmeq("%3", "r3")
383     - __HVC(0)
384     - : "+r" (function_id)
385     - : "r" (arg0), "r" (arg1), "r" (arg2));
386     -
387     - return function_id;
388     -}
389     -
390     -static noinline int __invoke_psci_fn_smc(u32 function_id, u32 arg0, u32 arg1,
391     - u32 arg2)
392     -{
393     - asm volatile(
394     - __asmeq("%0", "r0")
395     - __asmeq("%1", "r1")
396     - __asmeq("%2", "r2")
397     - __asmeq("%3", "r3")
398     - __SMC(0)
399     - : "+r" (function_id)
400     - : "r" (arg0), "r" (arg1), "r" (arg2));
401     -
402     - return function_id;
403     -}
404     -
405     static int psci_get_version(void)
406     {
407     int err;
408     diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
409     index 2ffccd4eb084..01efe130912e 100644
410     --- a/arch/arm/mach-mvebu/coherency.c
411     +++ b/arch/arm/mach-mvebu/coherency.c
412     @@ -448,8 +448,9 @@ static int __init coherency_late_init(void)
413     armada_375_coherency_init_wa();
414     }
415    
416     - bus_register_notifier(&platform_bus_type,
417     - &mvebu_hwcc_nb);
418     + if (coherency_available())
419     + bus_register_notifier(&platform_bus_type,
420     + &mvebu_hwcc_nb);
421    
422     return 0;
423     }
424     diff --git a/arch/arm/mach-omap2/prm-regbits-34xx.h b/arch/arm/mach-omap2/prm-regbits-34xx.h
425     index cbefbd7cfdb5..661d753df584 100644
426     --- a/arch/arm/mach-omap2/prm-regbits-34xx.h
427     +++ b/arch/arm/mach-omap2/prm-regbits-34xx.h
428     @@ -112,6 +112,7 @@
429     #define OMAP3430_VC_CMD_ONLP_SHIFT 16
430     #define OMAP3430_VC_CMD_RET_SHIFT 8
431     #define OMAP3430_VC_CMD_OFF_SHIFT 0
432     +#define OMAP3430_SREN_MASK (1 << 4)
433     #define OMAP3430_HSEN_MASK (1 << 3)
434     #define OMAP3430_MCODE_MASK (0x7 << 0)
435     #define OMAP3430_VALID_MASK (1 << 24)
436     diff --git a/arch/arm/mach-omap2/prm-regbits-44xx.h b/arch/arm/mach-omap2/prm-regbits-44xx.h
437     index b1c7a33e00e7..e794828dee55 100644
438     --- a/arch/arm/mach-omap2/prm-regbits-44xx.h
439     +++ b/arch/arm/mach-omap2/prm-regbits-44xx.h
440     @@ -35,6 +35,7 @@
441     #define OMAP4430_GLOBAL_WARM_SW_RST_SHIFT 1
442     #define OMAP4430_GLOBAL_WUEN_MASK (1 << 16)
443     #define OMAP4430_HSMCODE_MASK (0x7 << 0)
444     +#define OMAP4430_SRMODEEN_MASK (1 << 4)
445     #define OMAP4430_HSMODEEN_MASK (1 << 3)
446     #define OMAP4430_HSSCLL_SHIFT 24
447     #define OMAP4430_ICEPICK_RST_SHIFT 9
448     diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
449     index d1dedc8195ed..eafd120b53f1 100644
450     --- a/arch/arm/mach-omap2/sleep34xx.S
451     +++ b/arch/arm/mach-omap2/sleep34xx.S
452     @@ -203,23 +203,8 @@ save_context_wfi:
453     */
454     ldr r1, kernel_flush
455     blx r1
456     - /*
457     - * The kernel doesn't interwork: v7_flush_dcache_all in particluar will
458     - * always return in Thumb state when CONFIG_THUMB2_KERNEL is enabled.
459     - * This sequence switches back to ARM. Note that .align may insert a
460     - * nop: bx pc needs to be word-aligned in order to work.
461     - */
462     - THUMB( .thumb )
463     - THUMB( .align )
464     - THUMB( bx pc )
465     - THUMB( nop )
466     - .arm
467     -
468     b omap3_do_wfi
469     -
470     -/*
471     - * Local variables
472     - */
473     +ENDPROC(omap34xx_cpu_suspend)
474     omap3_do_wfi_sram_addr:
475     .word omap3_do_wfi_sram
476     kernel_flush:
477     @@ -364,10 +349,7 @@ exit_nonoff_modes:
478     * ===================================
479     */
480     ldmfd sp!, {r4 - r11, pc} @ restore regs and return
481     -
482     -/*
483     - * Local variables
484     - */
485     +ENDPROC(omap3_do_wfi)
486     sdrc_power:
487     .word SDRC_POWER_V
488     cm_idlest1_core:
489     diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
490     index be9ef834fa81..076fd20d7e5a 100644
491     --- a/arch/arm/mach-omap2/vc.c
492     +++ b/arch/arm/mach-omap2/vc.c
493     @@ -316,7 +316,8 @@ static void __init omap3_vc_init_pmic_signaling(struct voltagedomain *voltdm)
494     * idle. And we can also scale voltages to zero for off-idle.
495     * Note that no actual voltage scaling during off-idle will
496     * happen unless the board specific twl4030 PMIC scripts are
497     - * loaded.
498     + * loaded. See also omap_vc_i2c_init for comments regarding
499     + * erratum i531.
500     */
501     val = voltdm->read(OMAP3_PRM_VOLTCTRL_OFFSET);
502     if (!(val & OMAP3430_PRM_VOLTCTRL_SEL_OFF)) {
503     @@ -704,9 +705,16 @@ static void __init omap_vc_i2c_init(struct voltagedomain *voltdm)
504     return;
505     }
506    
507     + /*
508     + * Note that for omap3 OMAP3430_SREN_MASK clears SREN to work around
509     + * erratum i531 "Extra Power Consumed When Repeated Start Operation
510     + * Mode Is Enabled on I2C Interface Dedicated for Smart Reflex (I2C4)".
511     + * Otherwise I2C4 eventually leads into about 23mW extra power being
512     + * consumed even during off idle using VMODE.
513     + */
514     i2c_high_speed = voltdm->pmic->i2c_high_speed;
515     if (i2c_high_speed)
516     - voltdm->rmw(vc->common->i2c_cfg_hsen_mask,
517     + voltdm->rmw(vc->common->i2c_cfg_clear_mask,
518     vc->common->i2c_cfg_hsen_mask,
519     vc->common->i2c_cfg_reg);
520    
521     diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h
522     index cdbdd78e755e..89b83b7ff3ec 100644
523     --- a/arch/arm/mach-omap2/vc.h
524     +++ b/arch/arm/mach-omap2/vc.h
525     @@ -34,6 +34,7 @@ struct voltagedomain;
526     * @cmd_ret_shift: RET field shift in PRM_VC_CMD_VAL_* register
527     * @cmd_off_shift: OFF field shift in PRM_VC_CMD_VAL_* register
528     * @i2c_cfg_reg: I2C configuration register offset
529     + * @i2c_cfg_clear_mask: high-speed mode bit clear mask in I2C config register
530     * @i2c_cfg_hsen_mask: high-speed mode bit field mask in I2C config register
531     * @i2c_mcode_mask: MCODE field mask for I2C config register
532     *
533     @@ -52,6 +53,7 @@ struct omap_vc_common {
534     u8 cmd_ret_shift;
535     u8 cmd_off_shift;
536     u8 i2c_cfg_reg;
537     + u8 i2c_cfg_clear_mask;
538     u8 i2c_cfg_hsen_mask;
539     u8 i2c_mcode_mask;
540     };
541     diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c
542     index 75bc4aa22b3a..71d74c9172c1 100644
543     --- a/arch/arm/mach-omap2/vc3xxx_data.c
544     +++ b/arch/arm/mach-omap2/vc3xxx_data.c
545     @@ -40,6 +40,7 @@ static struct omap_vc_common omap3_vc_common = {
546     .cmd_onlp_shift = OMAP3430_VC_CMD_ONLP_SHIFT,
547     .cmd_ret_shift = OMAP3430_VC_CMD_RET_SHIFT,
548     .cmd_off_shift = OMAP3430_VC_CMD_OFF_SHIFT,
549     + .i2c_cfg_clear_mask = OMAP3430_SREN_MASK | OMAP3430_HSEN_MASK,
550     .i2c_cfg_hsen_mask = OMAP3430_HSEN_MASK,
551     .i2c_cfg_reg = OMAP3_PRM_VC_I2C_CFG_OFFSET,
552     .i2c_mcode_mask = OMAP3430_MCODE_MASK,
553     diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c
554     index 085e5d6a04fd..2abd5fa8a697 100644
555     --- a/arch/arm/mach-omap2/vc44xx_data.c
556     +++ b/arch/arm/mach-omap2/vc44xx_data.c
557     @@ -42,6 +42,7 @@ static const struct omap_vc_common omap4_vc_common = {
558     .cmd_ret_shift = OMAP4430_RET_SHIFT,
559     .cmd_off_shift = OMAP4430_OFF_SHIFT,
560     .i2c_cfg_reg = OMAP4_PRM_VC_CFG_I2C_MODE_OFFSET,
561     + .i2c_cfg_clear_mask = OMAP4430_SRMODEEN_MASK | OMAP4430_HSMODEEN_MASK,
562     .i2c_cfg_hsen_mask = OMAP4430_HSMODEEN_MASK,
563     .i2c_mcode_mask = OMAP4430_HSMCODE_MASK,
564     };
565     diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
566     index 9f98cec7fe1e..fb9d305c874b 100644
567     --- a/arch/arm/mm/mmu.c
568     +++ b/arch/arm/mm/mmu.c
569     @@ -1118,22 +1118,22 @@ void __init sanity_check_meminfo(void)
570     }
571    
572     /*
573     - * Find the first non-section-aligned page, and point
574     + * Find the first non-pmd-aligned page, and point
575     * memblock_limit at it. This relies on rounding the
576     - * limit down to be section-aligned, which happens at
577     - * the end of this function.
578     + * limit down to be pmd-aligned, which happens at the
579     + * end of this function.
580     *
581     * With this algorithm, the start or end of almost any
582     - * bank can be non-section-aligned. The only exception
583     - * is that the start of the bank 0 must be section-
584     + * bank can be non-pmd-aligned. The only exception is
585     + * that the start of the bank 0 must be section-
586     * aligned, since otherwise memory would need to be
587     * allocated when mapping the start of bank 0, which
588     * occurs before any free memory is mapped.
589     */
590     if (!memblock_limit) {
591     - if (!IS_ALIGNED(block_start, SECTION_SIZE))
592     + if (!IS_ALIGNED(block_start, PMD_SIZE))
593     memblock_limit = block_start;
594     - else if (!IS_ALIGNED(block_end, SECTION_SIZE))
595     + else if (!IS_ALIGNED(block_end, PMD_SIZE))
596     memblock_limit = arm_lowmem_limit;
597     }
598    
599     @@ -1143,12 +1143,12 @@ void __init sanity_check_meminfo(void)
600     high_memory = __va(arm_lowmem_limit - 1) + 1;
601    
602     /*
603     - * Round the memblock limit down to a section size. This
604     + * Round the memblock limit down to a pmd size. This
605     * helps to ensure that we will allocate memory from the
606     - * last full section, which should be mapped.
607     + * last full pmd, which should be mapped.
608     */
609     if (memblock_limit)
610     - memblock_limit = round_down(memblock_limit, SECTION_SIZE);
611     + memblock_limit = round_down(memblock_limit, PMD_SIZE);
612     if (!memblock_limit)
613     memblock_limit = arm_lowmem_limit;
614    
615     diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
616     index e1268f905026..f412b53ed268 100644
617     --- a/arch/arm/net/bpf_jit_32.c
618     +++ b/arch/arm/net/bpf_jit_32.c
619     @@ -449,10 +449,21 @@ static inline void emit_udiv(u8 rd, u8 rm, u8 rn, struct jit_ctx *ctx)
620     return;
621     }
622     #endif
623     - if (rm != ARM_R0)
624     - emit(ARM_MOV_R(ARM_R0, rm), ctx);
625     +
626     + /*
627     + * For BPF_ALU | BPF_DIV | BPF_K instructions, rm is ARM_R4
628     + * (r_A) and rn is ARM_R0 (r_scratch) so load rn first into
629     + * ARM_R1 to avoid accidentally overwriting ARM_R0 with rm
630     + * before using it as a source for ARM_R1.
631     + *
632     + * For BPF_ALU | BPF_DIV | BPF_X rm is ARM_R4 (r_A) and rn is
633     + * ARM_R5 (r_X) so there is no particular register overlap
634     + * issues.
635     + */
636     if (rn != ARM_R1)
637     emit(ARM_MOV_R(ARM_R1, rn), ctx);
638     + if (rm != ARM_R0)
639     + emit(ARM_MOV_R(ARM_R0, rm), ctx);
640    
641     ctx->seen |= SEEN_CALL;
642     emit_mov_i(ARM_R3, (u32)jit_udiv, ctx);
643     diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
644     index edba042b2325..dc6a4842683a 100644
645     --- a/arch/arm64/net/bpf_jit_comp.c
646     +++ b/arch/arm64/net/bpf_jit_comp.c
647     @@ -487,7 +487,7 @@ emit_cond_jmp:
648     return -EINVAL;
649     }
650    
651     - imm64 = (u64)insn1.imm << 32 | imm;
652     + imm64 = (u64)insn1.imm << 32 | (u32)imm;
653     emit_a64_mov_i64(dst, imm64, ctx);
654    
655     return 1;
656     diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
657     index 3391d061eccc..78c9fd32c554 100644
658     --- a/arch/parisc/include/asm/elf.h
659     +++ b/arch/parisc/include/asm/elf.h
660     @@ -348,6 +348,10 @@ struct pt_regs; /* forward declaration... */
661    
662     #define ELF_HWCAP 0
663    
664     +#define STACK_RND_MASK (is_32bit_task() ? \
665     + 0x7ff >> (PAGE_SHIFT - 12) : \
666     + 0x3ffff >> (PAGE_SHIFT - 12))
667     +
668     struct mm_struct;
669     extern unsigned long arch_randomize_brk(struct mm_struct *);
670     #define arch_randomize_brk arch_randomize_brk
671     diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
672     index e1ffea2f9a0b..5aba01ac457f 100644
673     --- a/arch/parisc/kernel/sys_parisc.c
674     +++ b/arch/parisc/kernel/sys_parisc.c
675     @@ -77,6 +77,9 @@ static unsigned long mmap_upper_limit(void)
676     if (stack_base > STACK_SIZE_MAX)
677     stack_base = STACK_SIZE_MAX;
678    
679     + /* Add space for stack randomization. */
680     + stack_base += (STACK_RND_MASK << PAGE_SHIFT);
681     +
682     return PAGE_ALIGN(STACK_TOP - stack_base);
683     }
684    
685     diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
686     index f096e72262f4..1db685104ffc 100644
687     --- a/arch/powerpc/kernel/vmlinux.lds.S
688     +++ b/arch/powerpc/kernel/vmlinux.lds.S
689     @@ -213,6 +213,7 @@ SECTIONS
690     *(.opd)
691     }
692    
693     + . = ALIGN(256);
694     .got : AT(ADDR(.got) - LOAD_OFFSET) {
695     __toc_start = .;
696     #ifndef CONFIG_RELOCATABLE
697     diff --git a/arch/s390/crypto/ghash_s390.c b/arch/s390/crypto/ghash_s390.c
698     index 7940dc90e80b..b258110da952 100644
699     --- a/arch/s390/crypto/ghash_s390.c
700     +++ b/arch/s390/crypto/ghash_s390.c
701     @@ -16,11 +16,12 @@
702     #define GHASH_DIGEST_SIZE 16
703    
704     struct ghash_ctx {
705     - u8 icv[16];
706     - u8 key[16];
707     + u8 key[GHASH_BLOCK_SIZE];
708     };
709    
710     struct ghash_desc_ctx {
711     + u8 icv[GHASH_BLOCK_SIZE];
712     + u8 key[GHASH_BLOCK_SIZE];
713     u8 buffer[GHASH_BLOCK_SIZE];
714     u32 bytes;
715     };
716     @@ -28,8 +29,10 @@ struct ghash_desc_ctx {
717     static int ghash_init(struct shash_desc *desc)
718     {
719     struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
720     + struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm);
721    
722     memset(dctx, 0, sizeof(*dctx));
723     + memcpy(dctx->key, ctx->key, GHASH_BLOCK_SIZE);
724    
725     return 0;
726     }
727     @@ -45,7 +48,6 @@ static int ghash_setkey(struct crypto_shash *tfm,
728     }
729    
730     memcpy(ctx->key, key, GHASH_BLOCK_SIZE);
731     - memset(ctx->icv, 0, GHASH_BLOCK_SIZE);
732    
733     return 0;
734     }
735     @@ -54,7 +56,6 @@ static int ghash_update(struct shash_desc *desc,
736     const u8 *src, unsigned int srclen)
737     {
738     struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
739     - struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm);
740     unsigned int n;
741     u8 *buf = dctx->buffer;
742     int ret;
743     @@ -70,7 +71,7 @@ static int ghash_update(struct shash_desc *desc,
744     src += n;
745    
746     if (!dctx->bytes) {
747     - ret = crypt_s390_kimd(KIMD_GHASH, ctx, buf,
748     + ret = crypt_s390_kimd(KIMD_GHASH, dctx, buf,
749     GHASH_BLOCK_SIZE);
750     if (ret != GHASH_BLOCK_SIZE)
751     return -EIO;
752     @@ -79,7 +80,7 @@ static int ghash_update(struct shash_desc *desc,
753    
754     n = srclen & ~(GHASH_BLOCK_SIZE - 1);
755     if (n) {
756     - ret = crypt_s390_kimd(KIMD_GHASH, ctx, src, n);
757     + ret = crypt_s390_kimd(KIMD_GHASH, dctx, src, n);
758     if (ret != n)
759     return -EIO;
760     src += n;
761     @@ -94,7 +95,7 @@ static int ghash_update(struct shash_desc *desc,
762     return 0;
763     }
764    
765     -static int ghash_flush(struct ghash_ctx *ctx, struct ghash_desc_ctx *dctx)
766     +static int ghash_flush(struct ghash_desc_ctx *dctx)
767     {
768     u8 *buf = dctx->buffer;
769     int ret;
770     @@ -104,24 +105,24 @@ static int ghash_flush(struct ghash_ctx *ctx, struct ghash_desc_ctx *dctx)
771    
772     memset(pos, 0, dctx->bytes);
773    
774     - ret = crypt_s390_kimd(KIMD_GHASH, ctx, buf, GHASH_BLOCK_SIZE);
775     + ret = crypt_s390_kimd(KIMD_GHASH, dctx, buf, GHASH_BLOCK_SIZE);
776     if (ret != GHASH_BLOCK_SIZE)
777     return -EIO;
778     +
779     + dctx->bytes = 0;
780     }
781    
782     - dctx->bytes = 0;
783     return 0;
784     }
785    
786     static int ghash_final(struct shash_desc *desc, u8 *dst)
787     {
788     struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
789     - struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm);
790     int ret;
791    
792     - ret = ghash_flush(ctx, dctx);
793     + ret = ghash_flush(dctx);
794     if (!ret)
795     - memcpy(dst, ctx->icv, GHASH_BLOCK_SIZE);
796     + memcpy(dst, dctx->icv, GHASH_BLOCK_SIZE);
797     return ret;
798     }
799    
800     diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
801     index 57c882761dea..b0373b44b320 100644
802     --- a/arch/s390/include/asm/pgtable.h
803     +++ b/arch/s390/include/asm/pgtable.h
804     @@ -582,7 +582,7 @@ static inline int pmd_large(pmd_t pmd)
805     return (pmd_val(pmd) & _SEGMENT_ENTRY_LARGE) != 0;
806     }
807    
808     -static inline int pmd_pfn(pmd_t pmd)
809     +static inline unsigned long pmd_pfn(pmd_t pmd)
810     {
811     unsigned long origin_mask;
812    
813     diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
814     index 6ed0c30d6a0c..6c0709ff2f38 100644
815     --- a/arch/x86/include/asm/kvm_host.h
816     +++ b/arch/x86/include/asm/kvm_host.h
817     @@ -201,6 +201,7 @@ union kvm_mmu_page_role {
818     unsigned nxe:1;
819     unsigned cr0_wp:1;
820     unsigned smep_andnot_wp:1;
821     + unsigned smap_andnot_wp:1;
822     };
823     };
824    
825     @@ -392,6 +393,7 @@ struct kvm_vcpu_arch {
826     struct kvm_mmu_memory_cache mmu_page_header_cache;
827    
828     struct fpu guest_fpu;
829     + bool eager_fpu;
830     u64 xcr0;
831     u64 guest_supported_xcr0;
832     u32 guest_xstate_size;
833     @@ -707,6 +709,7 @@ struct kvm_x86_ops {
834     void (*cache_reg)(struct kvm_vcpu *vcpu, enum kvm_reg reg);
835     unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
836     void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
837     + void (*fpu_activate)(struct kvm_vcpu *vcpu);
838     void (*fpu_deactivate)(struct kvm_vcpu *vcpu);
839    
840     void (*tlb_flush)(struct kvm_vcpu *vcpu);
841     diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
842     index 958b90f761e5..40b35a55ce8b 100644
843     --- a/arch/x86/include/asm/mce.h
844     +++ b/arch/x86/include/asm/mce.h
845     @@ -34,6 +34,10 @@
846     #define MCI_STATUS_S (1ULL<<56) /* Signaled machine check */
847     #define MCI_STATUS_AR (1ULL<<55) /* Action required */
848    
849     +/* AMD-specific bits */
850     +#define MCI_STATUS_DEFERRED (1ULL<<44) /* declare an uncorrected error */
851     +#define MCI_STATUS_POISON (1ULL<<43) /* access poisonous data */
852     +
853     /*
854     * Note that the full MCACOD field of IA32_MCi_STATUS MSR is
855     * bits 15:0. But bit 12 is the 'F' bit, defined for corrected
856     diff --git a/arch/x86/kernel/cpu/mcheck/mce-internal.h b/arch/x86/kernel/cpu/mcheck/mce-internal.h
857     index 09edd0b65fef..10b46906767f 100644
858     --- a/arch/x86/kernel/cpu/mcheck/mce-internal.h
859     +++ b/arch/x86/kernel/cpu/mcheck/mce-internal.h
860     @@ -3,6 +3,8 @@
861    
862     enum severity_level {
863     MCE_NO_SEVERITY,
864     + MCE_DEFERRED_SEVERITY,
865     + MCE_UCNA_SEVERITY = MCE_DEFERRED_SEVERITY,
866     MCE_KEEP_SEVERITY,
867     MCE_SOME_SEVERITY,
868     MCE_AO_SEVERITY,
869     @@ -21,7 +23,7 @@ struct mce_bank {
870     char attrname[ATTR_LEN]; /* attribute name */
871     };
872    
873     -int mce_severity(struct mce *a, int tolerant, char **msg);
874     +int mce_severity(struct mce *a, int tolerant, char **msg, bool is_excp);
875     struct dentry *mce_get_debugfs_dir(void);
876    
877     extern struct mce_bank *mce_banks;
878     diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c
879     index c370e1c4468b..8bb433043a7f 100644
880     --- a/arch/x86/kernel/cpu/mcheck/mce-severity.c
881     +++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c
882     @@ -31,6 +31,7 @@
883    
884     enum context { IN_KERNEL = 1, IN_USER = 2 };
885     enum ser { SER_REQUIRED = 1, NO_SER = 2 };
886     +enum exception { EXCP_CONTEXT = 1, NO_EXCP = 2 };
887    
888     static struct severity {
889     u64 mask;
890     @@ -40,6 +41,7 @@ static struct severity {
891     unsigned char mcgres;
892     unsigned char ser;
893     unsigned char context;
894     + unsigned char excp;
895     unsigned char covered;
896     char *msg;
897     } severities[] = {
898     @@ -48,6 +50,8 @@ static struct severity {
899     #define USER .context = IN_USER
900     #define SER .ser = SER_REQUIRED
901     #define NOSER .ser = NO_SER
902     +#define EXCP .excp = EXCP_CONTEXT
903     +#define NOEXCP .excp = NO_EXCP
904     #define BITCLR(x) .mask = x, .result = 0
905     #define BITSET(x) .mask = x, .result = x
906     #define MCGMASK(x, y) .mcgmask = x, .mcgres = y
907     @@ -62,7 +66,7 @@ static struct severity {
908     ),
909     MCESEV(
910     NO, "Not enabled",
911     - BITCLR(MCI_STATUS_EN)
912     + EXCP, BITCLR(MCI_STATUS_EN)
913     ),
914     MCESEV(
915     PANIC, "Processor context corrupt",
916     @@ -71,16 +75,20 @@ static struct severity {
917     /* When MCIP is not set something is very confused */
918     MCESEV(
919     PANIC, "MCIP not set in MCA handler",
920     - MCGMASK(MCG_STATUS_MCIP, 0)
921     + EXCP, MCGMASK(MCG_STATUS_MCIP, 0)
922     ),
923     /* Neither return not error IP -- no chance to recover -> PANIC */
924     MCESEV(
925     PANIC, "Neither restart nor error IP",
926     - MCGMASK(MCG_STATUS_RIPV|MCG_STATUS_EIPV, 0)
927     + EXCP, MCGMASK(MCG_STATUS_RIPV|MCG_STATUS_EIPV, 0)
928     ),
929     MCESEV(
930     PANIC, "In kernel and no restart IP",
931     - KERNEL, MCGMASK(MCG_STATUS_RIPV, 0)
932     + EXCP, KERNEL, MCGMASK(MCG_STATUS_RIPV, 0)
933     + ),
934     + MCESEV(
935     + DEFERRED, "Deferred error",
936     + NOSER, MASK(MCI_STATUS_UC|MCI_STATUS_DEFERRED|MCI_STATUS_POISON, MCI_STATUS_DEFERRED)
937     ),
938     MCESEV(
939     KEEP, "Corrected error",
940     @@ -89,7 +97,7 @@ static struct severity {
941    
942     /* ignore OVER for UCNA */
943     MCESEV(
944     - KEEP, "Uncorrected no action required",
945     + UCNA, "Uncorrected no action required",
946     SER, MASK(MCI_UC_SAR, MCI_STATUS_UC)
947     ),
948     MCESEV(
949     @@ -178,8 +186,9 @@ static int error_context(struct mce *m)
950     return ((m->cs & 3) == 3) ? IN_USER : IN_KERNEL;
951     }
952    
953     -int mce_severity(struct mce *m, int tolerant, char **msg)
954     +int mce_severity(struct mce *m, int tolerant, char **msg, bool is_excp)
955     {
956     + enum exception excp = (is_excp ? EXCP_CONTEXT : NO_EXCP);
957     enum context ctx = error_context(m);
958     struct severity *s;
959    
960     @@ -194,6 +203,8 @@ int mce_severity(struct mce *m, int tolerant, char **msg)
961     continue;
962     if (s->context && ctx != s->context)
963     continue;
964     + if (s->excp && excp != s->excp)
965     + continue;
966     if (msg)
967     *msg = s->msg;
968     s->covered = 1;
969     diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
970     index 61a9668cebfd..b5c2276317e2 100644
971     --- a/arch/x86/kernel/cpu/mcheck/mce.c
972     +++ b/arch/x86/kernel/cpu/mcheck/mce.c
973     @@ -660,6 +660,7 @@ static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp,
974     struct pt_regs *regs)
975     {
976     int i, ret = 0;
977     + char *tmp;
978    
979     for (i = 0; i < mca_cfg.banks; i++) {
980     m->status = mce_rdmsrl(MSR_IA32_MCx_STATUS(i));
981     @@ -668,8 +669,11 @@ static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp,
982     if (quirk_no_way_out)
983     quirk_no_way_out(i, m, regs);
984     }
985     - if (mce_severity(m, mca_cfg.tolerant, msg) >= MCE_PANIC_SEVERITY)
986     +
987     + if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) {
988     + *msg = tmp;
989     ret = 1;
990     + }
991     }
992     return ret;
993     }
994     @@ -754,7 +758,7 @@ static void mce_reign(void)
995     for_each_possible_cpu(cpu) {
996     int severity = mce_severity(&per_cpu(mces_seen, cpu),
997     mca_cfg.tolerant,
998     - &nmsg);
999     + &nmsg, true);
1000     if (severity > global_worst) {
1001     msg = nmsg;
1002     global_worst = severity;
1003     @@ -1095,13 +1099,14 @@ void do_machine_check(struct pt_regs *regs, long error_code)
1004     */
1005     add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE);
1006    
1007     - severity = mce_severity(&m, cfg->tolerant, NULL);
1008     + severity = mce_severity(&m, cfg->tolerant, NULL, true);
1009    
1010     /*
1011     - * When machine check was for corrected handler don't touch,
1012     - * unless we're panicing.
1013     + * When machine check was for corrected/deferred handler don't
1014     + * touch, unless we're panicing.
1015     */
1016     - if (severity == MCE_KEEP_SEVERITY && !no_way_out)
1017     + if ((severity == MCE_KEEP_SEVERITY ||
1018     + severity == MCE_UCNA_SEVERITY) && !no_way_out)
1019     continue;
1020     __set_bit(i, toclear);
1021     if (severity == MCE_NO_SEVERITY) {
1022     diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
1023     index 8c256749882c..611d821eac1a 100644
1024     --- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
1025     +++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
1026     @@ -664,6 +664,7 @@ static int __init rapl_pmu_init(void)
1027     break;
1028     case 60: /* Haswell */
1029     case 69: /* Haswell-Celeron */
1030     + case 61: /* Broadwell */
1031     rapl_cntr_mask = RAPL_IDX_HSW;
1032     rapl_pmu_events_group.attrs = rapl_events_hsw_attr;
1033     break;
1034     diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
1035     index a9a4229f6161..ae0fdc86b7b6 100644
1036     --- a/arch/x86/kernel/i387.c
1037     +++ b/arch/x86/kernel/i387.c
1038     @@ -155,6 +155,21 @@ static void init_thread_xstate(void)
1039     xstate_size = sizeof(struct i387_fxsave_struct);
1040     else
1041     xstate_size = sizeof(struct i387_fsave_struct);
1042     +
1043     + /*
1044     + * Quirk: we don't yet handle the XSAVES* instructions
1045     + * correctly, as we don't correctly convert between
1046     + * standard and compacted format when interfacing
1047     + * with user-space - so disable it for now.
1048     + *
1049     + * The difference is small: with recent CPUs the
1050     + * compacted format is only marginally smaller than
1051     + * the standard FPU state format.
1052     + *
1053     + * ( This is easy to backport while we are fixing
1054     + * XSAVES* support. )
1055     + */
1056     + setup_clear_cpu_cap(X86_FEATURE_XSAVES);
1057     }
1058    
1059     /*
1060     diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
1061     index 88f92014ba6b..81c6d541d98a 100644
1062     --- a/arch/x86/kvm/cpuid.c
1063     +++ b/arch/x86/kvm/cpuid.c
1064     @@ -16,6 +16,8 @@
1065     #include <linux/module.h>
1066     #include <linux/vmalloc.h>
1067     #include <linux/uaccess.h>
1068     +#include <asm/i387.h> /* For use_eager_fpu. Ugh! */
1069     +#include <asm/fpu-internal.h> /* For use_eager_fpu. Ugh! */
1070     #include <asm/user.h>
1071     #include <asm/xsave.h>
1072     #include "cpuid.h"
1073     @@ -88,6 +90,8 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu)
1074     xstate_required_size(vcpu->arch.xcr0);
1075     }
1076    
1077     + vcpu->arch.eager_fpu = guest_cpuid_has_mpx(vcpu);
1078     +
1079     /*
1080     * The existing code assumes virtual address is 48-bit in the canonical
1081     * address checks; exit if it is ever changed.
1082     diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h
1083     index 4452eedfaedd..9bec2b8cdced 100644
1084     --- a/arch/x86/kvm/cpuid.h
1085     +++ b/arch/x86/kvm/cpuid.h
1086     @@ -111,4 +111,12 @@ static inline bool guest_cpuid_has_rtm(struct kvm_vcpu *vcpu)
1087     best = kvm_find_cpuid_entry(vcpu, 7, 0);
1088     return best && (best->ebx & bit(X86_FEATURE_RTM));
1089     }
1090     +
1091     +static inline bool guest_cpuid_has_mpx(struct kvm_vcpu *vcpu)
1092     +{
1093     + struct kvm_cpuid_entry2 *best;
1094     +
1095     + best = kvm_find_cpuid_entry(vcpu, 7, 0);
1096     + return best && (best->ebx & bit(X86_FEATURE_MPX));
1097     +}
1098     #endif
1099     diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
1100     index 9c12e63c653f..8bd81f5a7e07 100644
1101     --- a/arch/x86/kvm/mmu.c
1102     +++ b/arch/x86/kvm/mmu.c
1103     @@ -3625,8 +3625,8 @@ static void reset_rsvds_bits_mask_ept(struct kvm_vcpu *vcpu,
1104     }
1105     }
1106    
1107     -void update_permission_bitmask(struct kvm_vcpu *vcpu,
1108     - struct kvm_mmu *mmu, bool ept)
1109     +static void update_permission_bitmask(struct kvm_vcpu *vcpu,
1110     + struct kvm_mmu *mmu, bool ept)
1111     {
1112     unsigned bit, byte, pfec;
1113     u8 map;
1114     @@ -3807,6 +3807,7 @@ static void init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
1115     void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context)
1116     {
1117     bool smep = kvm_read_cr4_bits(vcpu, X86_CR4_SMEP);
1118     + bool smap = kvm_read_cr4_bits(vcpu, X86_CR4_SMAP);
1119     ASSERT(vcpu);
1120     ASSERT(!VALID_PAGE(vcpu->arch.mmu.root_hpa));
1121    
1122     @@ -3824,6 +3825,8 @@ void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context)
1123     vcpu->arch.mmu.base_role.cr0_wp = is_write_protection(vcpu);
1124     vcpu->arch.mmu.base_role.smep_andnot_wp
1125     = smep && !is_write_protection(vcpu);
1126     + context->base_role.smap_andnot_wp
1127     + = smap && !is_write_protection(vcpu);
1128     }
1129     EXPORT_SYMBOL_GPL(kvm_init_shadow_mmu);
1130    
1131     @@ -4095,12 +4098,18 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
1132     const u8 *new, int bytes)
1133     {
1134     gfn_t gfn = gpa >> PAGE_SHIFT;
1135     - union kvm_mmu_page_role mask = { .word = 0 };
1136     struct kvm_mmu_page *sp;
1137     LIST_HEAD(invalid_list);
1138     u64 entry, gentry, *spte;
1139     int npte;
1140     bool remote_flush, local_flush, zap_page;
1141     + union kvm_mmu_page_role mask = (union kvm_mmu_page_role) {
1142     + .cr0_wp = 1,
1143     + .cr4_pae = 1,
1144     + .nxe = 1,
1145     + .smep_andnot_wp = 1,
1146     + .smap_andnot_wp = 1,
1147     + };
1148    
1149     /*
1150     * If we don't have indirect shadow pages, it means no page is
1151     @@ -4126,7 +4135,6 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
1152     ++vcpu->kvm->stat.mmu_pte_write;
1153     kvm_mmu_audit(vcpu, AUDIT_PRE_PTE_WRITE);
1154    
1155     - mask.cr0_wp = mask.cr4_pae = mask.nxe = 1;
1156     for_each_gfn_indirect_valid_sp(vcpu->kvm, sp, gfn) {
1157     if (detect_write_misaligned(sp, gpa, bytes) ||
1158     detect_write_flooding(sp)) {
1159     diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
1160     index bde8ee725754..a6b876443302 100644
1161     --- a/arch/x86/kvm/mmu.h
1162     +++ b/arch/x86/kvm/mmu.h
1163     @@ -84,8 +84,6 @@ int handle_mmio_page_fault_common(struct kvm_vcpu *vcpu, u64 addr, bool direct);
1164     void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context);
1165     void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context,
1166     bool execonly);
1167     -void update_permission_bitmask(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
1168     - bool ept);
1169    
1170     static inline unsigned int kvm_mmu_available_pages(struct kvm *kvm)
1171     {
1172     @@ -179,6 +177,8 @@ static inline bool permission_fault(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
1173     int index = (pfec >> 1) +
1174     (smap >> (X86_EFLAGS_AC_BIT - PFERR_RSVD_BIT + 1));
1175    
1176     + WARN_ON(pfec & PFERR_RSVD_MASK);
1177     +
1178     return (mmu->permissions[index] >> pte_access) & 1;
1179     }
1180    
1181     diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
1182     index fd49c867b25a..6e6d115fe9b5 100644
1183     --- a/arch/x86/kvm/paging_tmpl.h
1184     +++ b/arch/x86/kvm/paging_tmpl.h
1185     @@ -718,6 +718,13 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr, u32 error_code,
1186     mmu_is_nested(vcpu));
1187     if (likely(r != RET_MMIO_PF_INVALID))
1188     return r;
1189     +
1190     + /*
1191     + * page fault with PFEC.RSVD = 1 is caused by shadow
1192     + * page fault, should not be used to walk guest page
1193     + * table.
1194     + */
1195     + error_code &= ~PFERR_RSVD_MASK;
1196     };
1197    
1198     r = mmu_topup_memory_caches(vcpu);
1199     diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
1200     index 7527cefc5a43..f7eaee1cbc54 100644
1201     --- a/arch/x86/kvm/svm.c
1202     +++ b/arch/x86/kvm/svm.c
1203     @@ -4370,6 +4370,7 @@ static struct kvm_x86_ops svm_x86_ops = {
1204     .cache_reg = svm_cache_reg,
1205     .get_rflags = svm_get_rflags,
1206     .set_rflags = svm_set_rflags,
1207     + .fpu_activate = svm_fpu_activate,
1208     .fpu_deactivate = svm_fpu_deactivate,
1209    
1210     .tlb_flush = svm_flush_tlb,
1211     diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
1212     index 47843b04d60f..54bda28e6a12 100644
1213     --- a/arch/x86/kvm/vmx.c
1214     +++ b/arch/x86/kvm/vmx.c
1215     @@ -9120,6 +9120,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
1216     .cache_reg = vmx_cache_reg,
1217     .get_rflags = vmx_get_rflags,
1218     .set_rflags = vmx_set_rflags,
1219     + .fpu_activate = vmx_fpu_activate,
1220     .fpu_deactivate = vmx_fpu_deactivate,
1221    
1222     .tlb_flush = vmx_flush_tlb,
1223     diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
1224     index 5369ec6a8094..0bb431c3f74e 100644
1225     --- a/arch/x86/kvm/x86.c
1226     +++ b/arch/x86/kvm/x86.c
1227     @@ -678,8 +678,9 @@ EXPORT_SYMBOL_GPL(kvm_set_xcr);
1228     int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
1229     {
1230     unsigned long old_cr4 = kvm_read_cr4(vcpu);
1231     - unsigned long pdptr_bits = X86_CR4_PGE | X86_CR4_PSE |
1232     - X86_CR4_PAE | X86_CR4_SMEP;
1233     + unsigned long pdptr_bits = X86_CR4_PGE | X86_CR4_PSE | X86_CR4_PAE |
1234     + X86_CR4_SMEP | X86_CR4_SMAP;
1235     +
1236     if (cr4 & CR4_RESERVED_BITS)
1237     return 1;
1238    
1239     @@ -720,9 +721,6 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
1240     (!(cr4 & X86_CR4_PCIDE) && (old_cr4 & X86_CR4_PCIDE)))
1241     kvm_mmu_reset_context(vcpu);
1242    
1243     - if ((cr4 ^ old_cr4) & X86_CR4_SMAP)
1244     - update_permission_bitmask(vcpu, vcpu->arch.walk_mmu, false);
1245     -
1246     if ((cr4 ^ old_cr4) & X86_CR4_OSXSAVE)
1247     kvm_update_cpuid(vcpu);
1248    
1249     @@ -6139,6 +6137,8 @@ void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu)
1250     return;
1251    
1252     page = gfn_to_page(vcpu->kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT);
1253     + if (is_error_page(page))
1254     + return;
1255     kvm_x86_ops->set_apic_access_page_addr(vcpu, page_to_phys(page));
1256    
1257     /*
1258     @@ -6993,7 +6993,9 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
1259     fpu_save_init(&vcpu->arch.guest_fpu);
1260     __kernel_fpu_end();
1261     ++vcpu->stat.fpu_reload;
1262     - kvm_make_request(KVM_REQ_DEACTIVATE_FPU, vcpu);
1263     + if (!vcpu->arch.eager_fpu)
1264     + kvm_make_request(KVM_REQ_DEACTIVATE_FPU, vcpu);
1265     +
1266     trace_kvm_fpu(0);
1267     }
1268    
1269     @@ -7009,11 +7011,21 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
1270     struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
1271     unsigned int id)
1272     {
1273     + struct kvm_vcpu *vcpu;
1274     +
1275     if (check_tsc_unstable() && atomic_read(&kvm->online_vcpus) != 0)
1276     printk_once(KERN_WARNING
1277     "kvm: SMP vm created on host with unstable TSC; "
1278     "guest TSC will not be reliable\n");
1279     - return kvm_x86_ops->vcpu_create(kvm, id);
1280     +
1281     + vcpu = kvm_x86_ops->vcpu_create(kvm, id);
1282     +
1283     + /*
1284     + * Activate fpu unconditionally in case the guest needs eager FPU. It will be
1285     + * deactivated soon if it doesn't.
1286     + */
1287     + kvm_x86_ops->fpu_activate(vcpu);
1288     + return vcpu;
1289     }
1290    
1291     int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
1292     diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
1293     index b193f8425999..ff6d8adc9cda 100644
1294     --- a/drivers/acpi/acpi_pnp.c
1295     +++ b/drivers/acpi/acpi_pnp.c
1296     @@ -304,6 +304,8 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
1297     {"PNPb006"},
1298     /* cs423x-pnpbios */
1299     {"CSC0100"},
1300     + {"CSC0103"},
1301     + {"CSC0110"},
1302     {"CSC0000"},
1303     {"GIM0100"}, /* Guillemot Turtlebeach something appears to be cs4232 compatible */
1304     /* es18xx-pnpbios */
1305     diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
1306     index 4bceb11c7380..624cbb3b5683 100644
1307     --- a/drivers/acpi/acpica/acmacros.h
1308     +++ b/drivers/acpi/acpica/acmacros.h
1309     @@ -63,23 +63,12 @@
1310     #define ACPI_SET64(ptr, val) (*ACPI_CAST64 (ptr) = (u64) (val))
1311    
1312     /*
1313     - * printf() format helpers. These macros are workarounds for the difficulties
1314     + * printf() format helper. This macros is a workaround for the difficulties
1315     * with emitting 64-bit integers and 64-bit pointers with the same code
1316     * for both 32-bit and 64-bit hosts.
1317     */
1318     #define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i), ACPI_LODWORD(i)
1319    
1320     -#if ACPI_MACHINE_WIDTH == 64
1321     -#define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i)
1322     -#define ACPI_FORMAT_TO_UINT(i) ACPI_FORMAT_UINT64(i)
1323     -#define ACPI_PRINTF_UINT "0x%8.8X%8.8X"
1324     -
1325     -#else
1326     -#define ACPI_FORMAT_NATIVE_UINT(i) 0, (u32) (i)
1327     -#define ACPI_FORMAT_TO_UINT(i) (u32) (i)
1328     -#define ACPI_PRINTF_UINT "0x%8.8X"
1329     -#endif
1330     -
1331     /*
1332     * Macros for moving data around to/from buffers that are possibly unaligned.
1333     * If the hardware supports the transfer of unaligned data, just do the store.
1334     diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
1335     index 6c0759c0db47..5e7c7c301c5c 100644
1336     --- a/drivers/acpi/acpica/dsopcode.c
1337     +++ b/drivers/acpi/acpica/dsopcode.c
1338     @@ -446,7 +446,7 @@ acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
1339    
1340     ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
1341     obj_desc,
1342     - ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address),
1343     + ACPI_FORMAT_UINT64(obj_desc->region.address),
1344     obj_desc->region.length));
1345    
1346     /* Now the address and length are valid for this opregion */
1347     @@ -539,13 +539,12 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
1348     return_ACPI_STATUS(AE_NOT_EXIST);
1349     }
1350    
1351     - obj_desc->region.address =
1352     - (acpi_physical_address) ACPI_TO_INTEGER(table);
1353     + obj_desc->region.address = ACPI_PTR_TO_PHYSADDR(table);
1354     obj_desc->region.length = table->length;
1355    
1356     ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
1357     obj_desc,
1358     - ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address),
1359     + ACPI_FORMAT_UINT64(obj_desc->region.address),
1360     obj_desc->region.length));
1361    
1362     /* Now the address and length are valid for this opregion */
1363     diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
1364     index 8eb8575e8c16..9ce53980201c 100644
1365     --- a/drivers/acpi/acpica/evregion.c
1366     +++ b/drivers/acpi/acpica/evregion.c
1367     @@ -272,7 +272,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
1368     ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
1369     "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
1370     &region_obj->region.handler->address_space, handler,
1371     - ACPI_FORMAT_NATIVE_UINT(address),
1372     + ACPI_FORMAT_UINT64(address),
1373     acpi_ut_get_region_name(region_obj->region.
1374     space_id)));
1375    
1376     diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
1377     index 0f23c3f2678e..16b4909a8b90 100644
1378     --- a/drivers/acpi/acpica/exdump.c
1379     +++ b/drivers/acpi/acpica/exdump.c
1380     @@ -767,8 +767,8 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
1381     acpi_os_printf("\n");
1382     } else {
1383     acpi_os_printf(" base %8.8X%8.8X Length %X\n",
1384     - ACPI_FORMAT_NATIVE_UINT(obj_desc->region.
1385     - address),
1386     + ACPI_FORMAT_UINT64(obj_desc->region.
1387     + address),
1388     obj_desc->region.length);
1389     }
1390     break;
1391     diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
1392     index 1d1b27a96c5b..58ea85e42bfc 100644
1393     --- a/drivers/acpi/acpica/exfldio.c
1394     +++ b/drivers/acpi/acpica/exfldio.c
1395     @@ -263,17 +263,15 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
1396     }
1397    
1398     ACPI_DEBUG_PRINT_RAW((ACPI_DB_BFIELD,
1399     - " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %p\n",
1400     + " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %8.8X%8.8X\n",
1401     acpi_ut_get_region_name(rgn_desc->region.
1402     space_id),
1403     rgn_desc->region.space_id,
1404     obj_desc->common_field.access_byte_width,
1405     obj_desc->common_field.base_byte_offset,
1406     - field_datum_byte_offset, ACPI_CAST_PTR(void,
1407     - (rgn_desc->
1408     - region.
1409     - address +
1410     - region_offset))));
1411     + field_datum_byte_offset,
1412     + ACPI_FORMAT_UINT64(rgn_desc->region.address +
1413     + region_offset)));
1414    
1415     /* Invoke the appropriate address_space/op_region handler */
1416    
1417     diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
1418     index cd5288a257a9..be51d3ed4d0f 100644
1419     --- a/drivers/acpi/acpica/exregion.c
1420     +++ b/drivers/acpi/acpica/exregion.c
1421     @@ -181,7 +181,7 @@ acpi_ex_system_memory_space_handler(u32 function,
1422     if (!mem_info->mapped_logical_address) {
1423     ACPI_ERROR((AE_INFO,
1424     "Could not map memory at 0x%8.8X%8.8X, size %u",
1425     - ACPI_FORMAT_NATIVE_UINT(address),
1426     + ACPI_FORMAT_UINT64(address),
1427     (u32) map_length));
1428     mem_info->mapped_length = 0;
1429     return_ACPI_STATUS(AE_NO_MEMORY);
1430     @@ -202,8 +202,7 @@ acpi_ex_system_memory_space_handler(u32 function,
1431    
1432     ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1433     "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
1434     - bit_width, function,
1435     - ACPI_FORMAT_NATIVE_UINT(address)));
1436     + bit_width, function, ACPI_FORMAT_UINT64(address)));
1437    
1438     /*
1439     * Perform the memory read or write
1440     @@ -318,8 +317,7 @@ acpi_ex_system_io_space_handler(u32 function,
1441    
1442     ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1443     "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
1444     - bit_width, function,
1445     - ACPI_FORMAT_NATIVE_UINT(address)));
1446     + bit_width, function, ACPI_FORMAT_UINT64(address)));
1447    
1448     /* Decode the function parameter */
1449    
1450     diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c
1451     index 6b919127cd9d..dabf754ea4a4 100644
1452     --- a/drivers/acpi/acpica/hwvalid.c
1453     +++ b/drivers/acpi/acpica/hwvalid.c
1454     @@ -142,17 +142,17 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width)
1455     byte_width = ACPI_DIV_8(bit_width);
1456     last_address = address + byte_width - 1;
1457    
1458     - ACPI_DEBUG_PRINT((ACPI_DB_IO, "Address %p LastAddress %p Length %X",
1459     - ACPI_CAST_PTR(void, address), ACPI_CAST_PTR(void,
1460     - last_address),
1461     - byte_width));
1462     + ACPI_DEBUG_PRINT((ACPI_DB_IO,
1463     + "Address %8.8X%8.8X LastAddress %8.8X%8.8X Length %X",
1464     + ACPI_FORMAT_UINT64(address),
1465     + ACPI_FORMAT_UINT64(last_address), byte_width));
1466    
1467     /* Maximum 16-bit address in I/O space */
1468    
1469     if (last_address > ACPI_UINT16_MAX) {
1470     ACPI_ERROR((AE_INFO,
1471     - "Illegal I/O port address/length above 64K: %p/0x%X",
1472     - ACPI_CAST_PTR(void, address), byte_width));
1473     + "Illegal I/O port address/length above 64K: %8.8X%8.8X/0x%X",
1474     + ACPI_FORMAT_UINT64(address), byte_width));
1475     return_ACPI_STATUS(AE_LIMIT);
1476     }
1477    
1478     @@ -181,8 +181,8 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width)
1479    
1480     if (acpi_gbl_osi_data >= port_info->osi_dependency) {
1481     ACPI_DEBUG_PRINT((ACPI_DB_IO,
1482     - "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)",
1483     - ACPI_CAST_PTR(void, address),
1484     + "Denied AML access to port 0x%8.8X%8.8X/%X (%s 0x%.4X-0x%.4X)",
1485     + ACPI_FORMAT_UINT64(address),
1486     byte_width, port_info->name,
1487     port_info->start,
1488     port_info->end));
1489     diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
1490     index 3d88ef4a3e0d..809ed52de9c8 100644
1491     --- a/drivers/acpi/acpica/nsdump.c
1492     +++ b/drivers/acpi/acpica/nsdump.c
1493     @@ -271,12 +271,11 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
1494     switch (type) {
1495     case ACPI_TYPE_PROCESSOR:
1496    
1497     - acpi_os_printf("ID %02X Len %02X Addr %p\n",
1498     + acpi_os_printf("ID %02X Len %02X Addr %8.8X%8.8X\n",
1499     obj_desc->processor.proc_id,
1500     obj_desc->processor.length,
1501     - ACPI_CAST_PTR(void,
1502     - obj_desc->processor.
1503     - address));
1504     + ACPI_FORMAT_UINT64(obj_desc->processor.
1505     + address));
1506     break;
1507    
1508     case ACPI_TYPE_DEVICE:
1509     @@ -347,8 +346,9 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
1510     space_id));
1511     if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
1512     acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n",
1513     - ACPI_FORMAT_NATIVE_UINT
1514     - (obj_desc->region.address),
1515     + ACPI_FORMAT_UINT64(obj_desc->
1516     + region.
1517     + address),
1518     obj_desc->region.length);
1519     } else {
1520     acpi_os_printf
1521     diff --git a/drivers/acpi/acpica/tbdata.c b/drivers/acpi/acpica/tbdata.c
1522     index f499c10ceb4a..a078053ff473 100644
1523     --- a/drivers/acpi/acpica/tbdata.c
1524     +++ b/drivers/acpi/acpica/tbdata.c
1525     @@ -113,9 +113,9 @@ acpi_tb_acquire_table(struct acpi_table_desc *table_desc,
1526     case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
1527     case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
1528    
1529     - table =
1530     - ACPI_CAST_PTR(struct acpi_table_header,
1531     - table_desc->address);
1532     + table = ACPI_CAST_PTR(struct acpi_table_header,
1533     + ACPI_PHYSADDR_TO_PTR(table_desc->
1534     + address));
1535     break;
1536    
1537     default:
1538     @@ -214,7 +214,8 @@ acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,
1539     case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
1540     case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
1541    
1542     - table_header = ACPI_CAST_PTR(struct acpi_table_header, address);
1543     + table_header = ACPI_CAST_PTR(struct acpi_table_header,
1544     + ACPI_PHYSADDR_TO_PTR(address));
1545     if (!table_header) {
1546     return (AE_NO_MEMORY);
1547     }
1548     @@ -398,14 +399,14 @@ acpi_tb_verify_temp_table(struct acpi_table_desc * table_desc, char *signature)
1549     table_desc->length);
1550     if (ACPI_FAILURE(status)) {
1551     ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
1552     - "%4.4s " ACPI_PRINTF_UINT
1553     + "%4.4s 0x%8.8X%8.8X"
1554     " Attempted table install failed",
1555     acpi_ut_valid_acpi_name(table_desc->
1556     signature.
1557     ascii) ?
1558     table_desc->signature.ascii : "????",
1559     - ACPI_FORMAT_TO_UINT(table_desc->
1560     - address)));
1561     + ACPI_FORMAT_UINT64(table_desc->
1562     + address)));
1563     goto invalidate_and_exit;
1564     }
1565     }
1566     diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
1567     index c0b39f304ea3..8e1a43ae2f9b 100644
1568     --- a/drivers/acpi/acpica/tbinstal.c
1569     +++ b/drivers/acpi/acpica/tbinstal.c
1570     @@ -187,8 +187,9 @@ acpi_tb_install_fixed_table(acpi_physical_address address,
1571     status = acpi_tb_acquire_temp_table(&new_table_desc, address,
1572     ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL);
1573     if (ACPI_FAILURE(status)) {
1574     - ACPI_ERROR((AE_INFO, "Could not acquire table length at %p",
1575     - ACPI_CAST_PTR(void, address)));
1576     + ACPI_ERROR((AE_INFO,
1577     + "Could not acquire table length at %8.8X%8.8X",
1578     + ACPI_FORMAT_UINT64(address)));
1579     return_ACPI_STATUS(status);
1580     }
1581    
1582     @@ -246,8 +247,9 @@ acpi_tb_install_standard_table(acpi_physical_address address,
1583    
1584     status = acpi_tb_acquire_temp_table(&new_table_desc, address, flags);
1585     if (ACPI_FAILURE(status)) {
1586     - ACPI_ERROR((AE_INFO, "Could not acquire table length at %p",
1587     - ACPI_CAST_PTR(void, address)));
1588     + ACPI_ERROR((AE_INFO,
1589     + "Could not acquire table length at %8.8X%8.8X",
1590     + ACPI_FORMAT_UINT64(address)));
1591     return_ACPI_STATUS(status);
1592     }
1593    
1594     @@ -258,9 +260,10 @@ acpi_tb_install_standard_table(acpi_physical_address address,
1595     if (!reload &&
1596     acpi_gbl_disable_ssdt_table_install &&
1597     ACPI_COMPARE_NAME(&new_table_desc.signature, ACPI_SIG_SSDT)) {
1598     - ACPI_INFO((AE_INFO, "Ignoring installation of %4.4s at %p",
1599     - new_table_desc.signature.ascii, ACPI_CAST_PTR(void,
1600     - address)));
1601     + ACPI_INFO((AE_INFO,
1602     + "Ignoring installation of %4.4s at %8.8X%8.8X",
1603     + new_table_desc.signature.ascii,
1604     + ACPI_FORMAT_UINT64(address)));
1605     goto release_and_exit;
1606     }
1607    
1608     @@ -428,11 +431,11 @@ finish_override:
1609     return;
1610     }
1611    
1612     - ACPI_INFO((AE_INFO, "%4.4s " ACPI_PRINTF_UINT
1613     - " %s table override, new table: " ACPI_PRINTF_UINT,
1614     + ACPI_INFO((AE_INFO, "%4.4s 0x%8.8X%8.8X"
1615     + " %s table override, new table: 0x%8.8X%8.8X",
1616     old_table_desc->signature.ascii,
1617     - ACPI_FORMAT_TO_UINT(old_table_desc->address),
1618     - override_type, ACPI_FORMAT_TO_UINT(new_table_desc.address)));
1619     + ACPI_FORMAT_UINT64(old_table_desc->address),
1620     + override_type, ACPI_FORMAT_UINT64(new_table_desc.address)));
1621    
1622     /* We can now uninstall the original table */
1623    
1624     @@ -516,7 +519,7 @@ void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc)
1625    
1626     if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
1627     ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) {
1628     - ACPI_FREE(ACPI_CAST_PTR(void, table_desc->address));
1629     + ACPI_FREE(ACPI_PHYSADDR_TO_PTR(table_desc->address));
1630     }
1631    
1632     table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL);
1633     diff --git a/drivers/acpi/acpica/tbprint.c b/drivers/acpi/acpica/tbprint.c
1634     index df3bb20ea325..a23bdaec6040 100644
1635     --- a/drivers/acpi/acpica/tbprint.c
1636     +++ b/drivers/acpi/acpica/tbprint.c
1637     @@ -127,18 +127,12 @@ acpi_tb_print_table_header(acpi_physical_address address,
1638     {
1639     struct acpi_table_header local_header;
1640    
1641     - /*
1642     - * The reason that we use ACPI_PRINTF_UINT and ACPI_FORMAT_TO_UINT is to
1643     - * support both 32-bit and 64-bit hosts/addresses in a consistent manner.
1644     - * The %p specifier does not emit uniform output on all hosts. On some,
1645     - * leading zeros are not supported.
1646     - */
1647     if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) {
1648    
1649     /* FACS only has signature and length fields */
1650    
1651     - ACPI_INFO((AE_INFO, "%-4.4s " ACPI_PRINTF_UINT " %06X",
1652     - header->signature, ACPI_FORMAT_TO_UINT(address),
1653     + ACPI_INFO((AE_INFO, "%-4.4s 0x%8.8X%8.8X %06X",
1654     + header->signature, ACPI_FORMAT_UINT64(address),
1655     header->length));
1656     } else if (ACPI_VALIDATE_RSDP_SIG(header->signature)) {
1657    
1658     @@ -149,9 +143,8 @@ acpi_tb_print_table_header(acpi_physical_address address,
1659     header)->oem_id, ACPI_OEM_ID_SIZE);
1660     acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE);
1661    
1662     - ACPI_INFO((AE_INFO,
1663     - "RSDP " ACPI_PRINTF_UINT " %06X (v%.2d %-6.6s)",
1664     - ACPI_FORMAT_TO_UINT(address),
1665     + ACPI_INFO((AE_INFO, "RSDP 0x%8.8X%8.8X %06X (v%.2d %-6.6s)",
1666     + ACPI_FORMAT_UINT64(address),
1667     (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
1668     revision >
1669     0) ? ACPI_CAST_PTR(struct acpi_table_rsdp,
1670     @@ -165,9 +158,9 @@ acpi_tb_print_table_header(acpi_physical_address address,
1671     acpi_tb_cleanup_table_header(&local_header, header);
1672    
1673     ACPI_INFO((AE_INFO,
1674     - "%-4.4s " ACPI_PRINTF_UINT
1675     + "%-4.4s 0x%8.8X%8.8X"
1676     " %06X (v%.2d %-6.6s %-8.8s %08X %-4.4s %08X)",
1677     - local_header.signature, ACPI_FORMAT_TO_UINT(address),
1678     + local_header.signature, ACPI_FORMAT_UINT64(address),
1679     local_header.length, local_header.revision,
1680     local_header.oem_id, local_header.oem_table_id,
1681     local_header.oem_revision,
1682     diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
1683     index 43a54af2b548..89772b3fe55a 100644
1684     --- a/drivers/acpi/acpica/tbxfroot.c
1685     +++ b/drivers/acpi/acpica/tbxfroot.c
1686     @@ -142,7 +142,7 @@ acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp * rsdp)
1687     *
1688     ******************************************************************************/
1689    
1690     -acpi_status __init acpi_find_root_pointer(acpi_size *table_address)
1691     +acpi_status __init acpi_find_root_pointer(acpi_physical_address * table_address)
1692     {
1693     u8 *table_ptr;
1694     u8 *mem_rover;
1695     @@ -200,7 +200,8 @@ acpi_status __init acpi_find_root_pointer(acpi_size *table_address)
1696     physical_address +=
1697     (u32) ACPI_PTR_DIFF(mem_rover, table_ptr);
1698    
1699     - *table_address = physical_address;
1700     + *table_address =
1701     + (acpi_physical_address) physical_address;
1702     return_ACPI_STATUS(AE_OK);
1703     }
1704     }
1705     @@ -233,7 +234,7 @@ acpi_status __init acpi_find_root_pointer(acpi_size *table_address)
1706     (ACPI_HI_RSDP_WINDOW_BASE +
1707     ACPI_PTR_DIFF(mem_rover, table_ptr));
1708    
1709     - *table_address = physical_address;
1710     + *table_address = (acpi_physical_address) physical_address;
1711     return_ACPI_STATUS(AE_OK);
1712     }
1713    
1714     diff --git a/drivers/acpi/acpica/utaddress.c b/drivers/acpi/acpica/utaddress.c
1715     index a1acec9d2ef3..65985036c5c3 100644
1716     --- a/drivers/acpi/acpica/utaddress.c
1717     +++ b/drivers/acpi/acpica/utaddress.c
1718     @@ -107,10 +107,10 @@ acpi_ut_add_address_range(acpi_adr_space_type space_id,
1719     acpi_gbl_address_range_list[space_id] = range_info;
1720    
1721     ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
1722     - "\nAdded [%4.4s] address range: 0x%p-0x%p\n",
1723     + "\nAdded [%4.4s] address range: 0x%8.8X%8.8X-0x%8.8X%8.8X\n",
1724     acpi_ut_get_node_name(range_info->region_node),
1725     - ACPI_CAST_PTR(void, address),
1726     - ACPI_CAST_PTR(void, range_info->end_address)));
1727     + ACPI_FORMAT_UINT64(address),
1728     + ACPI_FORMAT_UINT64(range_info->end_address)));
1729    
1730     (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
1731     return_ACPI_STATUS(AE_OK);
1732     @@ -160,15 +160,13 @@ acpi_ut_remove_address_range(acpi_adr_space_type space_id,
1733     }
1734    
1735     ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
1736     - "\nRemoved [%4.4s] address range: 0x%p-0x%p\n",
1737     + "\nRemoved [%4.4s] address range: 0x%8.8X%8.8X-0x%8.8X%8.8X\n",
1738     acpi_ut_get_node_name(range_info->
1739     region_node),
1740     - ACPI_CAST_PTR(void,
1741     - range_info->
1742     - start_address),
1743     - ACPI_CAST_PTR(void,
1744     - range_info->
1745     - end_address)));
1746     + ACPI_FORMAT_UINT64(range_info->
1747     + start_address),
1748     + ACPI_FORMAT_UINT64(range_info->
1749     + end_address)));
1750    
1751     ACPI_FREE(range_info);
1752     return_VOID;
1753     @@ -245,16 +243,14 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id,
1754     region_node);
1755    
1756     ACPI_WARNING((AE_INFO,
1757     - "%s range 0x%p-0x%p conflicts with OpRegion 0x%p-0x%p (%s)",
1758     + "%s range 0x%8.8X%8.8X-0x%8.8X%8.8X conflicts with OpRegion 0x%8.8X%8.8X-0x%8.8X%8.8X (%s)",
1759     acpi_ut_get_region_name(space_id),
1760     - ACPI_CAST_PTR(void, address),
1761     - ACPI_CAST_PTR(void, end_address),
1762     - ACPI_CAST_PTR(void,
1763     - range_info->
1764     - start_address),
1765     - ACPI_CAST_PTR(void,
1766     - range_info->
1767     - end_address),
1768     + ACPI_FORMAT_UINT64(address),
1769     + ACPI_FORMAT_UINT64(end_address),
1770     + ACPI_FORMAT_UINT64(range_info->
1771     + start_address),
1772     + ACPI_FORMAT_UINT64(range_info->
1773     + end_address),
1774     pathname));
1775     ACPI_FREE(pathname);
1776     }
1777     diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
1778     index 9964f70be98d..838359818228 100644
1779     --- a/drivers/acpi/osl.c
1780     +++ b/drivers/acpi/osl.c
1781     @@ -182,7 +182,7 @@ static void __init acpi_request_region (struct acpi_generic_address *gas,
1782     request_mem_region(addr, length, desc);
1783     }
1784    
1785     -static int __init acpi_reserve_resources(void)
1786     +static void __init acpi_reserve_resources(void)
1787     {
1788     acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length,
1789     "ACPI PM1a_EVT_BLK");
1790     @@ -211,10 +211,7 @@ static int __init acpi_reserve_resources(void)
1791     if (!(acpi_gbl_FADT.gpe1_block_length & 0x1))
1792     acpi_request_region(&acpi_gbl_FADT.xgpe1_block,
1793     acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK");
1794     -
1795     - return 0;
1796     }
1797     -device_initcall(acpi_reserve_resources);
1798    
1799     void acpi_os_printf(const char *fmt, ...)
1800     {
1801     @@ -1839,6 +1836,7 @@ acpi_status __init acpi_os_initialize(void)
1802    
1803     acpi_status __init acpi_os_initialize1(void)
1804     {
1805     + acpi_reserve_resources();
1806     kacpid_wq = alloc_workqueue("kacpid", 0, 1);
1807     kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1);
1808     kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0);
1809     diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
1810     index 26e5b5060523..bf034f8b7c1a 100644
1811     --- a/drivers/acpi/sbshc.c
1812     +++ b/drivers/acpi/sbshc.c
1813     @@ -14,6 +14,7 @@
1814     #include <linux/delay.h>
1815     #include <linux/module.h>
1816     #include <linux/interrupt.h>
1817     +#include <linux/dmi.h>
1818     #include "sbshc.h"
1819    
1820     #define PREFIX "ACPI: "
1821     @@ -87,6 +88,8 @@ enum acpi_smb_offset {
1822     ACPI_SMB_ALARM_DATA = 0x26, /* 2 bytes alarm data */
1823     };
1824    
1825     +static bool macbook;
1826     +
1827     static inline int smb_hc_read(struct acpi_smb_hc *hc, u8 address, u8 *data)
1828     {
1829     return ec_read(hc->offset + address, data);
1830     @@ -132,6 +135,8 @@ static int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol,
1831     }
1832    
1833     mutex_lock(&hc->lock);
1834     + if (macbook)
1835     + udelay(5);
1836     if (smb_hc_read(hc, ACPI_SMB_PROTOCOL, &temp))
1837     goto end;
1838     if (temp) {
1839     @@ -257,12 +262,29 @@ extern int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
1840     acpi_handle handle, acpi_ec_query_func func,
1841     void *data);
1842    
1843     +static int macbook_dmi_match(const struct dmi_system_id *d)
1844     +{
1845     + pr_debug("Detected MacBook, enabling workaround\n");
1846     + macbook = true;
1847     + return 0;
1848     +}
1849     +
1850     +static struct dmi_system_id acpi_smbus_dmi_table[] = {
1851     + { macbook_dmi_match, "Apple MacBook", {
1852     + DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1853     + DMI_MATCH(DMI_PRODUCT_NAME, "MacBook") },
1854     + },
1855     + { },
1856     +};
1857     +
1858     static int acpi_smbus_hc_add(struct acpi_device *device)
1859     {
1860     int status;
1861     unsigned long long val;
1862     struct acpi_smb_hc *hc;
1863    
1864     + dmi_check_system(acpi_smbus_dmi_table);
1865     +
1866     if (!device)
1867     return -EINVAL;
1868    
1869     diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
1870     index 49f1e6890587..73187771836c 100644
1871     --- a/drivers/ata/ahci.c
1872     +++ b/drivers/ata/ahci.c
1873     @@ -66,6 +66,7 @@ enum board_ids {
1874     board_ahci_yes_fbs,
1875    
1876     /* board IDs for specific chipsets in alphabetical order */
1877     + board_ahci_avn,
1878     board_ahci_mcp65,
1879     board_ahci_mcp77,
1880     board_ahci_mcp89,
1881     @@ -84,6 +85,8 @@ enum board_ids {
1882     static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
1883     static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
1884     unsigned long deadline);
1885     +static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
1886     + unsigned long deadline);
1887     static void ahci_mcp89_apple_enable(struct pci_dev *pdev);
1888     static bool is_mcp89_apple(struct pci_dev *pdev);
1889     static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
1890     @@ -107,6 +110,11 @@ static struct ata_port_operations ahci_p5wdh_ops = {
1891     .hardreset = ahci_p5wdh_hardreset,
1892     };
1893    
1894     +static struct ata_port_operations ahci_avn_ops = {
1895     + .inherits = &ahci_ops,
1896     + .hardreset = ahci_avn_hardreset,
1897     +};
1898     +
1899     static const struct ata_port_info ahci_port_info[] = {
1900     /* by features */
1901     [board_ahci] = {
1902     @@ -151,6 +159,12 @@ static const struct ata_port_info ahci_port_info[] = {
1903     .port_ops = &ahci_ops,
1904     },
1905     /* by chipsets */
1906     + [board_ahci_avn] = {
1907     + .flags = AHCI_FLAG_COMMON,
1908     + .pio_mask = ATA_PIO4,
1909     + .udma_mask = ATA_UDMA6,
1910     + .port_ops = &ahci_avn_ops,
1911     + },
1912     [board_ahci_mcp65] = {
1913     AHCI_HFLAGS (AHCI_HFLAG_NO_FPDMA_AA | AHCI_HFLAG_NO_PMP |
1914     AHCI_HFLAG_YES_NCQ),
1915     @@ -290,14 +304,14 @@ static const struct pci_device_id ahci_pci_tbl[] = {
1916     { PCI_VDEVICE(INTEL, 0x1f27), board_ahci }, /* Avoton RAID */
1917     { PCI_VDEVICE(INTEL, 0x1f2e), board_ahci }, /* Avoton RAID */
1918     { PCI_VDEVICE(INTEL, 0x1f2f), board_ahci }, /* Avoton RAID */
1919     - { PCI_VDEVICE(INTEL, 0x1f32), board_ahci }, /* Avoton AHCI */
1920     - { PCI_VDEVICE(INTEL, 0x1f33), board_ahci }, /* Avoton AHCI */
1921     - { PCI_VDEVICE(INTEL, 0x1f34), board_ahci }, /* Avoton RAID */
1922     - { PCI_VDEVICE(INTEL, 0x1f35), board_ahci }, /* Avoton RAID */
1923     - { PCI_VDEVICE(INTEL, 0x1f36), board_ahci }, /* Avoton RAID */
1924     - { PCI_VDEVICE(INTEL, 0x1f37), board_ahci }, /* Avoton RAID */
1925     - { PCI_VDEVICE(INTEL, 0x1f3e), board_ahci }, /* Avoton RAID */
1926     - { PCI_VDEVICE(INTEL, 0x1f3f), board_ahci }, /* Avoton RAID */
1927     + { PCI_VDEVICE(INTEL, 0x1f32), board_ahci_avn }, /* Avoton AHCI */
1928     + { PCI_VDEVICE(INTEL, 0x1f33), board_ahci_avn }, /* Avoton AHCI */
1929     + { PCI_VDEVICE(INTEL, 0x1f34), board_ahci_avn }, /* Avoton RAID */
1930     + { PCI_VDEVICE(INTEL, 0x1f35), board_ahci_avn }, /* Avoton RAID */
1931     + { PCI_VDEVICE(INTEL, 0x1f36), board_ahci_avn }, /* Avoton RAID */
1932     + { PCI_VDEVICE(INTEL, 0x1f37), board_ahci_avn }, /* Avoton RAID */
1933     + { PCI_VDEVICE(INTEL, 0x1f3e), board_ahci_avn }, /* Avoton RAID */
1934     + { PCI_VDEVICE(INTEL, 0x1f3f), board_ahci_avn }, /* Avoton RAID */
1935     { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Wellsburg RAID */
1936     { PCI_VDEVICE(INTEL, 0x2827), board_ahci }, /* Wellsburg RAID */
1937     { PCI_VDEVICE(INTEL, 0x8d02), board_ahci }, /* Wellsburg AHCI */
1938     @@ -671,6 +685,79 @@ static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
1939     return rc;
1940     }
1941    
1942     +/*
1943     + * ahci_avn_hardreset - attempt more aggressive recovery of Avoton ports.
1944     + *
1945     + * It has been observed with some SSDs that the timing of events in the
1946     + * link synchronization phase can leave the port in a state that can not
1947     + * be recovered by a SATA-hard-reset alone. The failing signature is
1948     + * SStatus.DET stuck at 1 ("Device presence detected but Phy
1949     + * communication not established"). It was found that unloading and
1950     + * reloading the driver when this problem occurs allows the drive
1951     + * connection to be recovered (DET advanced to 0x3). The critical
1952     + * component of reloading the driver is that the port state machines are
1953     + * reset by bouncing "port enable" in the AHCI PCS configuration
1954     + * register. So, reproduce that effect by bouncing a port whenever we
1955     + * see DET==1 after a reset.
1956     + */
1957     +static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
1958     + unsigned long deadline)
1959     +{
1960     + const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
1961     + struct ata_port *ap = link->ap;
1962     + struct ahci_port_priv *pp = ap->private_data;
1963     + struct ahci_host_priv *hpriv = ap->host->private_data;
1964     + u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
1965     + unsigned long tmo = deadline - jiffies;
1966     + struct ata_taskfile tf;
1967     + bool online;
1968     + int rc, i;
1969     +
1970     + DPRINTK("ENTER\n");
1971     +
1972     + ahci_stop_engine(ap);
1973     +
1974     + for (i = 0; i < 2; i++) {
1975     + u16 val;
1976     + u32 sstatus;
1977     + int port = ap->port_no;
1978     + struct ata_host *host = ap->host;
1979     + struct pci_dev *pdev = to_pci_dev(host->dev);
1980     +
1981     + /* clear D2H reception area to properly wait for D2H FIS */
1982     + ata_tf_init(link->device, &tf);
1983     + tf.command = ATA_BUSY;
1984     + ata_tf_to_fis(&tf, 0, 0, d2h_fis);
1985     +
1986     + rc = sata_link_hardreset(link, timing, deadline, &online,
1987     + ahci_check_ready);
1988     +
1989     + if (sata_scr_read(link, SCR_STATUS, &sstatus) != 0 ||
1990     + (sstatus & 0xf) != 1)
1991     + break;
1992     +
1993     + ata_link_printk(link, KERN_INFO, "avn bounce port%d\n",
1994     + port);
1995     +
1996     + pci_read_config_word(pdev, 0x92, &val);
1997     + val &= ~(1 << port);
1998     + pci_write_config_word(pdev, 0x92, val);
1999     + ata_msleep(ap, 1000);
2000     + val |= 1 << port;
2001     + pci_write_config_word(pdev, 0x92, val);
2002     + deadline += tmo;
2003     + }
2004     +
2005     + hpriv->start_engine(ap);
2006     +
2007     + if (online)
2008     + *class = ahci_dev_classify(ap);
2009     +
2010     + DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class);
2011     + return rc;
2012     +}
2013     +
2014     +
2015     #ifdef CONFIG_PM
2016     static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
2017     {
2018     diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
2019     index 97683e45ab04..de88999521b7 100644
2020     --- a/drivers/ata/libahci.c
2021     +++ b/drivers/ata/libahci.c
2022     @@ -1707,8 +1707,7 @@ static void ahci_handle_port_interrupt(struct ata_port *ap,
2023     if (unlikely(resetting))
2024     status &= ~PORT_IRQ_BAD_PMP;
2025    
2026     - /* if LPM is enabled, PHYRDY doesn't mean anything */
2027     - if (ap->link.lpm_policy > ATA_LPM_MAX_POWER) {
2028     + if (sata_lpm_ignore_phy_events(&ap->link)) {
2029     status &= ~PORT_IRQ_PHYRDY;
2030     ahci_scr_write(&ap->link, SCR_ERROR, SERR_PHYRDY_CHG);
2031     }
2032     diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
2033     index 485f7eab0d4b..64af3bf2b4c7 100644
2034     --- a/drivers/ata/libata-core.c
2035     +++ b/drivers/ata/libata-core.c
2036     @@ -6747,6 +6747,38 @@ u32 ata_wait_register(struct ata_port *ap, void __iomem *reg, u32 mask, u32 val,
2037     return tmp;
2038     }
2039    
2040     +/**
2041     + * sata_lpm_ignore_phy_events - test if PHY event should be ignored
2042     + * @link: Link receiving the event
2043     + *
2044     + * Test whether the received PHY event has to be ignored or not.
2045     + *
2046     + * LOCKING:
2047     + * None:
2048     + *
2049     + * RETURNS:
2050     + * True if the event has to be ignored.
2051     + */
2052     +bool sata_lpm_ignore_phy_events(struct ata_link *link)
2053     +{
2054     + unsigned long lpm_timeout = link->last_lpm_change +
2055     + msecs_to_jiffies(ATA_TMOUT_SPURIOUS_PHY);
2056     +
2057     + /* if LPM is enabled, PHYRDY doesn't mean anything */
2058     + if (link->lpm_policy > ATA_LPM_MAX_POWER)
2059     + return true;
2060     +
2061     + /* ignore the first PHY event after the LPM policy changed
2062     + * as it is might be spurious
2063     + */
2064     + if ((link->flags & ATA_LFLAG_CHANGED) &&
2065     + time_before(jiffies, lpm_timeout))
2066     + return true;
2067     +
2068     + return false;
2069     +}
2070     +EXPORT_SYMBOL_GPL(sata_lpm_ignore_phy_events);
2071     +
2072     /*
2073     * Dummy port_ops
2074     */
2075     diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
2076     index dad83df555c4..4ec95b76f6a1 100644
2077     --- a/drivers/ata/libata-eh.c
2078     +++ b/drivers/ata/libata-eh.c
2079     @@ -3490,6 +3490,9 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
2080     }
2081     }
2082    
2083     + link->last_lpm_change = jiffies;
2084     + link->flags |= ATA_LFLAG_CHANGED;
2085     +
2086     return 0;
2087    
2088     fail:
2089     diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
2090     index 51b7e3a36e37..c2359a1ea6b3 100644
2091     --- a/drivers/edac/mce_amd.h
2092     +++ b/drivers/edac/mce_amd.h
2093     @@ -32,9 +32,6 @@
2094     #define R4(x) (((x) >> 4) & 0xf)
2095     #define R4_MSG(x) ((R4(x) < 9) ? rrrr_msgs[R4(x)] : "Wrong R4!")
2096    
2097     -#define MCI_STATUS_DEFERRED BIT_64(44)
2098     -#define MCI_STATUS_POISON BIT_64(43)
2099     -
2100     extern const char * const pp_msgs[];
2101    
2102     enum tt_ids {
2103     diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
2104     index 17afc51f3054..35286fe52823 100644
2105     --- a/drivers/firmware/dmi_scan.c
2106     +++ b/drivers/firmware/dmi_scan.c
2107     @@ -489,6 +489,10 @@ static int __init dmi_present(const u8 *buf)
2108     buf += 16;
2109    
2110     if (memcmp(buf, "_DMI_", 5) == 0 && dmi_checksum(buf, 15)) {
2111     + if (smbios_ver)
2112     + dmi_ver = smbios_ver;
2113     + else
2114     + dmi_ver = (buf[14] & 0xF0) << 4 | (buf[14] & 0x0F);
2115     dmi_num = (buf[13] << 8) | buf[12];
2116     dmi_len = (buf[7] << 8) | buf[6];
2117     dmi_base = (buf[11] << 24) | (buf[10] << 16) |
2118     @@ -496,12 +500,9 @@ static int __init dmi_present(const u8 *buf)
2119    
2120     if (dmi_walk_early(dmi_decode) == 0) {
2121     if (smbios_ver) {
2122     - dmi_ver = smbios_ver;
2123     pr_info("SMBIOS %d.%d present.\n",
2124     dmi_ver >> 8, dmi_ver & 0xFF);
2125     } else {
2126     - dmi_ver = (buf[14] & 0xF0) << 4 |
2127     - (buf[14] & 0x0F);
2128     pr_info("Legacy DMI %d.%d present.\n",
2129     dmi_ver >> 8, dmi_ver & 0xFF);
2130     }
2131     diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
2132     index fd150adeebf9..86a60079d316 100644
2133     --- a/drivers/gpio/gpio-kempld.c
2134     +++ b/drivers/gpio/gpio-kempld.c
2135     @@ -117,7 +117,7 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
2136     = container_of(chip, struct kempld_gpio_data, chip);
2137     struct kempld_device_data *pld = gpio->pld;
2138    
2139     - return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
2140     + return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
2141     }
2142    
2143     static int kempld_gpio_pincount(struct kempld_device_data *pld)
2144     diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
2145     index aed7dd6e9dca..d9fa798560b2 100644
2146     --- a/drivers/gpio/gpiolib-sysfs.c
2147     +++ b/drivers/gpio/gpiolib-sysfs.c
2148     @@ -519,6 +519,7 @@ static struct class gpio_class = {
2149     */
2150     int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
2151     {
2152     + struct gpio_chip *chip;
2153     unsigned long flags;
2154     int status;
2155     const char *ioname = NULL;
2156     @@ -536,8 +537,16 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
2157     return -EINVAL;
2158     }
2159    
2160     + chip = desc->chip;
2161     +
2162     mutex_lock(&sysfs_lock);
2163    
2164     + /* check if chip is being removed */
2165     + if (!chip || !chip->exported) {
2166     + status = -ENODEV;
2167     + goto fail_unlock;
2168     + }
2169     +
2170     spin_lock_irqsave(&gpio_lock, flags);
2171     if (!test_bit(FLAG_REQUESTED, &desc->flags) ||
2172     test_bit(FLAG_EXPORT, &desc->flags)) {
2173     @@ -766,12 +775,15 @@ void gpiochip_unexport(struct gpio_chip *chip)
2174     {
2175     int status;
2176     struct device *dev;
2177     + struct gpio_desc *desc;
2178     + unsigned int i;
2179    
2180     mutex_lock(&sysfs_lock);
2181     dev = class_find_device(&gpio_class, NULL, chip, match_export);
2182     if (dev) {
2183     put_device(dev);
2184     device_unregister(dev);
2185     + /* prevent further gpiod exports */
2186     chip->exported = false;
2187     status = 0;
2188     } else
2189     @@ -780,6 +792,13 @@ void gpiochip_unexport(struct gpio_chip *chip)
2190    
2191     if (status)
2192     chip_dbg(chip, "%s: status %d\n", __func__, status);
2193     +
2194     + /* unregister gpiod class devices owned by sysfs */
2195     + for (i = 0; i < chip->ngpio; i++) {
2196     + desc = &chip->desc[i];
2197     + if (test_and_clear_bit(FLAG_SYSFS, &desc->flags))
2198     + gpiod_free(desc);
2199     + }
2200     }
2201    
2202     static int __init gpiolib_sysfs_init(void)
2203     diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
2204     index c4edea907f8f..7d64d22486e9 100644
2205     --- a/drivers/gpu/drm/drm_irq.c
2206     +++ b/drivers/gpu/drm/drm_irq.c
2207     @@ -131,12 +131,11 @@ static void drm_update_vblank_count(struct drm_device *dev, int crtc)
2208    
2209     /* Reinitialize corresponding vblank timestamp if high-precision query
2210     * available. Skip this step if query unsupported or failed. Will
2211     - * reinitialize delayed at next vblank interrupt in that case.
2212     + * reinitialize delayed at next vblank interrupt in that case and
2213     + * assign 0 for now, to mark the vblanktimestamp as invalid.
2214     */
2215     - if (rc) {
2216     - tslot = atomic_read(&vblank->count) + diff;
2217     - vblanktimestamp(dev, crtc, tslot) = t_vblank;
2218     - }
2219     + tslot = atomic_read(&vblank->count) + diff;
2220     + vblanktimestamp(dev, crtc, tslot) = rc ? t_vblank : (struct timeval) {0, 0};
2221    
2222     smp_mb__before_atomic();
2223     atomic_add(diff, &vblank->count);
2224     diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
2225     index 740d9ebbebde..a29db0a1da42 100644
2226     --- a/drivers/gpu/drm/i915/intel_dp.c
2227     +++ b/drivers/gpu/drm/i915/intel_dp.c
2228     @@ -1037,7 +1037,7 @@ intel_dp_compute_config(struct intel_encoder *encoder,
2229    
2230     pipe_config->has_dp_encoder = true;
2231     pipe_config->has_drrs = false;
2232     - pipe_config->has_audio = intel_dp->has_audio;
2233     + pipe_config->has_audio = intel_dp->has_audio && port != PORT_A;
2234    
2235     if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
2236     intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
2237     @@ -1879,8 +1879,8 @@ static void intel_dp_get_config(struct intel_encoder *encoder,
2238     int dotclock;
2239    
2240     tmp = I915_READ(intel_dp->output_reg);
2241     - if (tmp & DP_AUDIO_OUTPUT_ENABLE)
2242     - pipe_config->has_audio = true;
2243     +
2244     + pipe_config->has_audio = tmp & DP_AUDIO_OUTPUT_ENABLE && port != PORT_A;
2245    
2246     if ((port == PORT_A) || !HAS_PCH_CPT(dev)) {
2247     if (tmp & DP_SYNC_HS_HIGH)
2248     diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
2249     index c0bbf2172446..b7e80bf190f8 100644
2250     --- a/drivers/gpu/drm/i915/intel_lvds.c
2251     +++ b/drivers/gpu/drm/i915/intel_lvds.c
2252     @@ -809,12 +809,28 @@ static int intel_dual_link_lvds_callback(const struct dmi_system_id *id)
2253     static const struct dmi_system_id intel_dual_link_lvds[] = {
2254     {
2255     .callback = intel_dual_link_lvds_callback,
2256     - .ident = "Apple MacBook Pro (Core i5/i7 Series)",
2257     + .ident = "Apple MacBook Pro 15\" (2010)",
2258     + .matches = {
2259     + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
2260     + DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro6,2"),
2261     + },
2262     + },
2263     + {
2264     + .callback = intel_dual_link_lvds_callback,
2265     + .ident = "Apple MacBook Pro 15\" (2011)",
2266     .matches = {
2267     DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
2268     DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro8,2"),
2269     },
2270     },
2271     + {
2272     + .callback = intel_dual_link_lvds_callback,
2273     + .ident = "Apple MacBook Pro 15\" (2012)",
2274     + .matches = {
2275     + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
2276     + DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro9,1"),
2277     + },
2278     + },
2279     { } /* terminating entry */
2280     };
2281    
2282     diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
2283     index 5d73e5f3845d..4f9ec36698f7 100644
2284     --- a/drivers/gpu/drm/radeon/atombios_crtc.c
2285     +++ b/drivers/gpu/drm/radeon/atombios_crtc.c
2286     @@ -1789,7 +1789,9 @@ static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc)
2287     if ((crtc->mode.clock == test_crtc->mode.clock) &&
2288     (adjusted_clock == test_adjusted_clock) &&
2289     (radeon_crtc->ss_enabled == test_radeon_crtc->ss_enabled) &&
2290     - (test_radeon_crtc->pll_id != ATOM_PPLL_INVALID))
2291     + (test_radeon_crtc->pll_id != ATOM_PPLL_INVALID) &&
2292     + (drm_detect_monitor_audio(radeon_connector_edid(test_radeon_crtc->connector)) ==
2293     + drm_detect_monitor_audio(radeon_connector_edid(radeon_crtc->connector))))
2294     return test_radeon_crtc->pll_id;
2295     }
2296     }
2297     diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
2298     index 5bf825dfaa09..ceab25d54233 100644
2299     --- a/drivers/gpu/drm/radeon/atombios_dp.c
2300     +++ b/drivers/gpu/drm/radeon/atombios_dp.c
2301     @@ -405,19 +405,21 @@ bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector)
2302     {
2303     struct radeon_connector_atom_dig *dig_connector = radeon_connector->con_priv;
2304     u8 msg[DP_DPCD_SIZE];
2305     - int ret;
2306     + int ret, i;
2307    
2308     - ret = drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_DPCD_REV, msg,
2309     - DP_DPCD_SIZE);
2310     - if (ret > 0) {
2311     - memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE);
2312     + for (i = 0; i < 7; i++) {
2313     + ret = drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_DPCD_REV, msg,
2314     + DP_DPCD_SIZE);
2315     + if (ret == DP_DPCD_SIZE) {
2316     + memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE);
2317    
2318     - DRM_DEBUG_KMS("DPCD: %*ph\n", (int)sizeof(dig_connector->dpcd),
2319     - dig_connector->dpcd);
2320     + DRM_DEBUG_KMS("DPCD: %*ph\n", (int)sizeof(dig_connector->dpcd),
2321     + dig_connector->dpcd);
2322    
2323     - radeon_dp_probe_oui(radeon_connector);
2324     + radeon_dp_probe_oui(radeon_connector);
2325    
2326     - return true;
2327     + return true;
2328     + }
2329     }
2330     dig_connector->dpcd[0] = 0;
2331     return false;
2332     diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
2333     index 0c6fbc0198a5..63e8bff5d47a 100644
2334     --- a/drivers/gpu/drm/radeon/cik.c
2335     +++ b/drivers/gpu/drm/radeon/cik.c
2336     @@ -5764,7 +5764,7 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev)
2337     /* restore context1-15 */
2338     /* set vm size, must be a multiple of 4 */
2339     WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0);
2340     - WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn);
2341     + WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn - 1);
2342     for (i = 1; i < 16; i++) {
2343     if (i < 8)
2344     WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2),
2345     diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
2346     index 8a83c917cf53..a019ba246e39 100644
2347     --- a/drivers/gpu/drm/radeon/ni.c
2348     +++ b/drivers/gpu/drm/radeon/ni.c
2349     @@ -1269,7 +1269,8 @@ static int cayman_pcie_gart_enable(struct radeon_device *rdev)
2350     */
2351     for (i = 1; i < 8; i++) {
2352     WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR + (i << 2), 0);
2353     - WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR + (i << 2), rdev->vm_manager.max_pfn);
2354     + WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR + (i << 2),
2355     + rdev->vm_manager.max_pfn - 1);
2356     WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2),
2357     rdev->vm_manager.saved_table_addr[i]);
2358     }
2359     diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c
2360     index ed0e10eee2dc..c34ceb8d3d27 100644
2361     --- a/drivers/gpu/drm/radeon/radeon_asic.c
2362     +++ b/drivers/gpu/drm/radeon/radeon_asic.c
2363     @@ -1190,7 +1190,7 @@ static struct radeon_asic rs780_asic = {
2364     static struct radeon_asic_ring rv770_uvd_ring = {
2365     .ib_execute = &uvd_v1_0_ib_execute,
2366     .emit_fence = &uvd_v2_2_fence_emit,
2367     - .emit_semaphore = &uvd_v1_0_semaphore_emit,
2368     + .emit_semaphore = &uvd_v2_2_semaphore_emit,
2369     .cs_parse = &radeon_uvd_cs_parse,
2370     .ring_test = &uvd_v1_0_ring_test,
2371     .ib_test = &uvd_v1_0_ib_test,
2372     diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
2373     index 0c1da2bf1fb4..6dd68f663181 100644
2374     --- a/drivers/gpu/drm/radeon/radeon_asic.h
2375     +++ b/drivers/gpu/drm/radeon/radeon_asic.h
2376     @@ -908,6 +908,10 @@ void uvd_v1_0_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
2377     int uvd_v2_2_resume(struct radeon_device *rdev);
2378     void uvd_v2_2_fence_emit(struct radeon_device *rdev,
2379     struct radeon_fence *fence);
2380     +bool uvd_v2_2_semaphore_emit(struct radeon_device *rdev,
2381     + struct radeon_ring *ring,
2382     + struct radeon_semaphore *semaphore,
2383     + bool emit_wait);
2384    
2385     /* uvd v3.1 */
2386     bool uvd_v3_1_semaphore_emit(struct radeon_device *rdev,
2387     diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
2388     index 9ab8e2694602..13f69472e716 100644
2389     --- a/drivers/gpu/drm/radeon/radeon_ttm.c
2390     +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
2391     @@ -568,8 +568,7 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
2392     {
2393     struct radeon_device *rdev = radeon_get_rdev(ttm->bdev);
2394     struct radeon_ttm_tt *gtt = (void *)ttm;
2395     - struct scatterlist *sg;
2396     - int i;
2397     + struct sg_page_iter sg_iter;
2398    
2399     int write = !(gtt->userflags & RADEON_GEM_USERPTR_READONLY);
2400     enum dma_data_direction direction = write ?
2401     @@ -582,9 +581,8 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
2402     /* free the sg table and pages again */
2403     dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
2404    
2405     - for_each_sg(ttm->sg->sgl, sg, ttm->sg->nents, i) {
2406     - struct page *page = sg_page(sg);
2407     -
2408     + for_each_sg_page(ttm->sg->sgl, &sg_iter, ttm->sg->nents, 0) {
2409     + struct page *page = sg_page_iter_page(&sg_iter);
2410     if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY))
2411     set_page_dirty(page);
2412    
2413     diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
2414     index 11b662469253..db6536f722f2 100644
2415     --- a/drivers/gpu/drm/radeon/radeon_uvd.c
2416     +++ b/drivers/gpu/drm/radeon/radeon_uvd.c
2417     @@ -396,6 +396,29 @@ static int radeon_uvd_cs_msg_decode(uint32_t *msg, unsigned buf_sizes[])
2418     return 0;
2419     }
2420    
2421     +static int radeon_uvd_validate_codec(struct radeon_cs_parser *p,
2422     + unsigned stream_type)
2423     +{
2424     + switch (stream_type) {
2425     + case 0: /* H264 */
2426     + case 1: /* VC1 */
2427     + /* always supported */
2428     + return 0;
2429     +
2430     + case 3: /* MPEG2 */
2431     + case 4: /* MPEG4 */
2432     + /* only since UVD 3 */
2433     + if (p->rdev->family >= CHIP_PALM)
2434     + return 0;
2435     +
2436     + /* fall through */
2437     + default:
2438     + DRM_ERROR("UVD codec not supported by hardware %d!\n",
2439     + stream_type);
2440     + return -EINVAL;
2441     + }
2442     +}
2443     +
2444     static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
2445     unsigned offset, unsigned buf_sizes[])
2446     {
2447     @@ -436,50 +459,70 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
2448     return -EINVAL;
2449     }
2450    
2451     - if (msg_type == 1) {
2452     - /* it's a decode msg, calc buffer sizes */
2453     - r = radeon_uvd_cs_msg_decode(msg, buf_sizes);
2454     - /* calc image size (width * height) */
2455     - img_size = msg[6] * msg[7];
2456     + switch (msg_type) {
2457     + case 0:
2458     + /* it's a create msg, calc image size (width * height) */
2459     + img_size = msg[7] * msg[8];
2460     +
2461     + r = radeon_uvd_validate_codec(p, msg[4]);
2462     + radeon_bo_kunmap(bo);
2463     + if (r)
2464     + return r;
2465     +
2466     + /* try to alloc a new handle */
2467     + for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
2468     + if (atomic_read(&p->rdev->uvd.handles[i]) == handle) {
2469     + DRM_ERROR("Handle 0x%x already in use!\n", handle);
2470     + return -EINVAL;
2471     + }
2472     +
2473     + if (!atomic_cmpxchg(&p->rdev->uvd.handles[i], 0, handle)) {
2474     + p->rdev->uvd.filp[i] = p->filp;
2475     + p->rdev->uvd.img_size[i] = img_size;
2476     + return 0;
2477     + }
2478     + }
2479     +
2480     + DRM_ERROR("No more free UVD handles!\n");
2481     + return -EINVAL;
2482     +
2483     + case 1:
2484     + /* it's a decode msg, validate codec and calc buffer sizes */
2485     + r = radeon_uvd_validate_codec(p, msg[4]);
2486     + if (!r)
2487     + r = radeon_uvd_cs_msg_decode(msg, buf_sizes);
2488     radeon_bo_kunmap(bo);
2489     if (r)
2490     return r;
2491    
2492     - } else if (msg_type == 2) {
2493     + /* validate the handle */
2494     + for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
2495     + if (atomic_read(&p->rdev->uvd.handles[i]) == handle) {
2496     + if (p->rdev->uvd.filp[i] != p->filp) {
2497     + DRM_ERROR("UVD handle collision detected!\n");
2498     + return -EINVAL;
2499     + }
2500     + return 0;
2501     + }
2502     + }
2503     +
2504     + DRM_ERROR("Invalid UVD handle 0x%x!\n", handle);
2505     + return -ENOENT;
2506     +
2507     + case 2:
2508     /* it's a destroy msg, free the handle */
2509     for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i)
2510     atomic_cmpxchg(&p->rdev->uvd.handles[i], handle, 0);
2511     radeon_bo_kunmap(bo);
2512     return 0;
2513     - } else {
2514     - /* it's a create msg, calc image size (width * height) */
2515     - img_size = msg[7] * msg[8];
2516     - radeon_bo_kunmap(bo);
2517    
2518     - if (msg_type != 0) {
2519     - DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
2520     - return -EINVAL;
2521     - }
2522     -
2523     - /* it's a create msg, no special handling needed */
2524     - }
2525     -
2526     - /* create or decode, validate the handle */
2527     - for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
2528     - if (atomic_read(&p->rdev->uvd.handles[i]) == handle)
2529     - return 0;
2530     - }
2531     + default:
2532    
2533     - /* handle not found try to alloc a new one */
2534     - for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
2535     - if (!atomic_cmpxchg(&p->rdev->uvd.handles[i], 0, handle)) {
2536     - p->rdev->uvd.filp[i] = p->filp;
2537     - p->rdev->uvd.img_size[i] = img_size;
2538     - return 0;
2539     - }
2540     + DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
2541     + return -EINVAL;
2542     }
2543    
2544     - DRM_ERROR("No more free UVD handles!\n");
2545     + BUG();
2546     return -EINVAL;
2547     }
2548    
2549     diff --git a/drivers/gpu/drm/radeon/radeon_vce.c b/drivers/gpu/drm/radeon/radeon_vce.c
2550     index 9e85757d5599..1c0022a49486 100644
2551     --- a/drivers/gpu/drm/radeon/radeon_vce.c
2552     +++ b/drivers/gpu/drm/radeon/radeon_vce.c
2553     @@ -493,18 +493,27 @@ int radeon_vce_cs_reloc(struct radeon_cs_parser *p, int lo, int hi,
2554     *
2555     * @p: parser context
2556     * @handle: handle to validate
2557     + * @allocated: allocated a new handle?
2558     *
2559     * Validates the handle and return the found session index or -EINVAL
2560     * we we don't have another free session index.
2561     */
2562     -int radeon_vce_validate_handle(struct radeon_cs_parser *p, uint32_t handle)
2563     +static int radeon_vce_validate_handle(struct radeon_cs_parser *p,
2564     + uint32_t handle, bool *allocated)
2565     {
2566     unsigned i;
2567    
2568     + *allocated = false;
2569     +
2570     /* validate the handle */
2571     for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i) {
2572     - if (atomic_read(&p->rdev->vce.handles[i]) == handle)
2573     + if (atomic_read(&p->rdev->vce.handles[i]) == handle) {
2574     + if (p->rdev->vce.filp[i] != p->filp) {
2575     + DRM_ERROR("VCE handle collision detected!\n");
2576     + return -EINVAL;
2577     + }
2578     return i;
2579     + }
2580     }
2581    
2582     /* handle not found try to alloc a new one */
2583     @@ -512,6 +521,7 @@ int radeon_vce_validate_handle(struct radeon_cs_parser *p, uint32_t handle)
2584     if (!atomic_cmpxchg(&p->rdev->vce.handles[i], 0, handle)) {
2585     p->rdev->vce.filp[i] = p->filp;
2586     p->rdev->vce.img_size[i] = 0;
2587     + *allocated = true;
2588     return i;
2589     }
2590     }
2591     @@ -529,10 +539,10 @@ int radeon_vce_validate_handle(struct radeon_cs_parser *p, uint32_t handle)
2592     int radeon_vce_cs_parse(struct radeon_cs_parser *p)
2593     {
2594     int session_idx = -1;
2595     - bool destroyed = false;
2596     + bool destroyed = false, created = false, allocated = false;
2597     uint32_t tmp, handle = 0;
2598     uint32_t *size = &tmp;
2599     - int i, r;
2600     + int i, r = 0;
2601    
2602     while (p->idx < p->chunks[p->chunk_ib_idx].length_dw) {
2603     uint32_t len = radeon_get_ib_value(p, p->idx);
2604     @@ -540,18 +550,21 @@ int radeon_vce_cs_parse(struct radeon_cs_parser *p)
2605    
2606     if ((len < 8) || (len & 3)) {
2607     DRM_ERROR("invalid VCE command length (%d)!\n", len);
2608     - return -EINVAL;
2609     + r = -EINVAL;
2610     + goto out;
2611     }
2612    
2613     if (destroyed) {
2614     DRM_ERROR("No other command allowed after destroy!\n");
2615     - return -EINVAL;
2616     + r = -EINVAL;
2617     + goto out;
2618     }
2619    
2620     switch (cmd) {
2621     case 0x00000001: // session
2622     handle = radeon_get_ib_value(p, p->idx + 2);
2623     - session_idx = radeon_vce_validate_handle(p, handle);
2624     + session_idx = radeon_vce_validate_handle(p, handle,
2625     + &allocated);
2626     if (session_idx < 0)
2627     return session_idx;
2628     size = &p->rdev->vce.img_size[session_idx];
2629     @@ -561,6 +574,13 @@ int radeon_vce_cs_parse(struct radeon_cs_parser *p)
2630     break;
2631    
2632     case 0x01000001: // create
2633     + created = true;
2634     + if (!allocated) {
2635     + DRM_ERROR("Handle already in use!\n");
2636     + r = -EINVAL;
2637     + goto out;
2638     + }
2639     +
2640     *size = radeon_get_ib_value(p, p->idx + 8) *
2641     radeon_get_ib_value(p, p->idx + 10) *
2642     8 * 3 / 2;
2643     @@ -577,12 +597,12 @@ int radeon_vce_cs_parse(struct radeon_cs_parser *p)
2644     r = radeon_vce_cs_reloc(p, p->idx + 10, p->idx + 9,
2645     *size);
2646     if (r)
2647     - return r;
2648     + goto out;
2649    
2650     r = radeon_vce_cs_reloc(p, p->idx + 12, p->idx + 11,
2651     *size / 3);
2652     if (r)
2653     - return r;
2654     + goto out;
2655     break;
2656    
2657     case 0x02000001: // destroy
2658     @@ -593,7 +613,7 @@ int radeon_vce_cs_parse(struct radeon_cs_parser *p)
2659     r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2,
2660     *size * 2);
2661     if (r)
2662     - return r;
2663     + goto out;
2664     break;
2665    
2666     case 0x05000004: // video bitstream buffer
2667     @@ -601,36 +621,47 @@ int radeon_vce_cs_parse(struct radeon_cs_parser *p)
2668     r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2,
2669     tmp);
2670     if (r)
2671     - return r;
2672     + goto out;
2673     break;
2674    
2675     case 0x05000005: // feedback buffer
2676     r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2,
2677     4096);
2678     if (r)
2679     - return r;
2680     + goto out;
2681     break;
2682    
2683     default:
2684     DRM_ERROR("invalid VCE command (0x%x)!\n", cmd);
2685     - return -EINVAL;
2686     + r = -EINVAL;
2687     + goto out;
2688     }
2689    
2690     if (session_idx == -1) {
2691     DRM_ERROR("no session command at start of IB\n");
2692     - return -EINVAL;
2693     + r = -EINVAL;
2694     + goto out;
2695     }
2696    
2697     p->idx += len / 4;
2698     }
2699    
2700     - if (destroyed) {
2701     - /* IB contains a destroy msg, free the handle */
2702     + if (allocated && !created) {
2703     + DRM_ERROR("New session without create command!\n");
2704     + r = -ENOENT;
2705     + }
2706     +
2707     +out:
2708     + if ((!r && destroyed) || (r && allocated)) {
2709     + /*
2710     + * IB contains a destroy msg or we have allocated an
2711     + * handle and got an error, anyway free the handle
2712     + */
2713     for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i)
2714     atomic_cmpxchg(&p->rdev->vce.handles[i], handle, 0);
2715     }
2716    
2717     - return 0;
2718     + return r;
2719     }
2720    
2721     /**
2722     diff --git a/drivers/gpu/drm/radeon/rv770d.h b/drivers/gpu/drm/radeon/rv770d.h
2723     index 3cf1e2921545..9ef2064b1c9c 100644
2724     --- a/drivers/gpu/drm/radeon/rv770d.h
2725     +++ b/drivers/gpu/drm/radeon/rv770d.h
2726     @@ -989,6 +989,9 @@
2727     ((n) & 0x3FFF) << 16)
2728    
2729     /* UVD */
2730     +#define UVD_SEMA_ADDR_LOW 0xef00
2731     +#define UVD_SEMA_ADDR_HIGH 0xef04
2732     +#define UVD_SEMA_CMD 0xef08
2733     #define UVD_GPCOM_VCPU_CMD 0xef0c
2734     #define UVD_GPCOM_VCPU_DATA0 0xef10
2735     #define UVD_GPCOM_VCPU_DATA1 0xef14
2736     diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
2737     index 1c3d90c17cb3..3ad2e07fb48e 100644
2738     --- a/drivers/gpu/drm/radeon/si.c
2739     +++ b/drivers/gpu/drm/radeon/si.c
2740     @@ -4285,7 +4285,7 @@ static int si_pcie_gart_enable(struct radeon_device *rdev)
2741     /* empty context1-15 */
2742     /* set vm size, must be a multiple of 4 */
2743     WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0);
2744     - WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn);
2745     + WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn - 1);
2746     /* Assign the pt base to something valid for now; the pts used for
2747     * the VMs are determined by the application and setup and assigned
2748     * on the fly in the vm part of radeon_gart.c
2749     diff --git a/drivers/gpu/drm/radeon/uvd_v1_0.c b/drivers/gpu/drm/radeon/uvd_v1_0.c
2750     index e72b3cb59358..c6b1cbca47fc 100644
2751     --- a/drivers/gpu/drm/radeon/uvd_v1_0.c
2752     +++ b/drivers/gpu/drm/radeon/uvd_v1_0.c
2753     @@ -466,18 +466,8 @@ bool uvd_v1_0_semaphore_emit(struct radeon_device *rdev,
2754     struct radeon_semaphore *semaphore,
2755     bool emit_wait)
2756     {
2757     - uint64_t addr = semaphore->gpu_addr;
2758     -
2759     - radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_LOW, 0));
2760     - radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF);
2761     -
2762     - radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_HIGH, 0));
2763     - radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF);
2764     -
2765     - radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0));
2766     - radeon_ring_write(ring, emit_wait ? 1 : 0);
2767     -
2768     - return true;
2769     + /* disable semaphores for UVD V1 hardware */
2770     + return false;
2771     }
2772    
2773     /**
2774     diff --git a/drivers/gpu/drm/radeon/uvd_v2_2.c b/drivers/gpu/drm/radeon/uvd_v2_2.c
2775     index 89193519f8a1..7ed778cec7c6 100644
2776     --- a/drivers/gpu/drm/radeon/uvd_v2_2.c
2777     +++ b/drivers/gpu/drm/radeon/uvd_v2_2.c
2778     @@ -60,6 +60,35 @@ void uvd_v2_2_fence_emit(struct radeon_device *rdev,
2779     }
2780    
2781     /**
2782     + * uvd_v2_2_semaphore_emit - emit semaphore command
2783     + *
2784     + * @rdev: radeon_device pointer
2785     + * @ring: radeon_ring pointer
2786     + * @semaphore: semaphore to emit commands for
2787     + * @emit_wait: true if we should emit a wait command
2788     + *
2789     + * Emit a semaphore command (either wait or signal) to the UVD ring.
2790     + */
2791     +bool uvd_v2_2_semaphore_emit(struct radeon_device *rdev,
2792     + struct radeon_ring *ring,
2793     + struct radeon_semaphore *semaphore,
2794     + bool emit_wait)
2795     +{
2796     + uint64_t addr = semaphore->gpu_addr;
2797     +
2798     + radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_LOW, 0));
2799     + radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF);
2800     +
2801     + radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_HIGH, 0));
2802     + radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF);
2803     +
2804     + radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0));
2805     + radeon_ring_write(ring, emit_wait ? 1 : 0);
2806     +
2807     + return true;
2808     +}
2809     +
2810     +/**
2811     * uvd_v2_2_resume - memory controller programming
2812     *
2813     * @rdev: radeon_device pointer
2814     diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
2815     index 7710f4694ba1..718953bb657f 100644
2816     --- a/drivers/hwmon/nct6683.c
2817     +++ b/drivers/hwmon/nct6683.c
2818     @@ -439,6 +439,7 @@ nct6683_create_attr_group(struct device *dev, struct sensor_template_group *tg,
2819     (*t)->dev_attr.attr.name, tg->base + i);
2820     if ((*t)->s2) {
2821     a2 = &su->u.a2;
2822     + sysfs_attr_init(&a2->dev_attr.attr);
2823     a2->dev_attr.attr.name = su->name;
2824     a2->nr = (*t)->u.s.nr + i;
2825     a2->index = (*t)->u.s.index;
2826     @@ -449,6 +450,7 @@ nct6683_create_attr_group(struct device *dev, struct sensor_template_group *tg,
2827     *attrs = &a2->dev_attr.attr;
2828     } else {
2829     a = &su->u.a1;
2830     + sysfs_attr_init(&a->dev_attr.attr);
2831     a->dev_attr.attr.name = su->name;
2832     a->index = (*t)->u.index + i;
2833     a->dev_attr.attr.mode =
2834     diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
2835     index 504cbddbdd90..6461964f49a8 100644
2836     --- a/drivers/hwmon/nct6775.c
2837     +++ b/drivers/hwmon/nct6775.c
2838     @@ -985,6 +985,7 @@ nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
2839     (*t)->dev_attr.attr.name, tg->base + i);
2840     if ((*t)->s2) {
2841     a2 = &su->u.a2;
2842     + sysfs_attr_init(&a2->dev_attr.attr);
2843     a2->dev_attr.attr.name = su->name;
2844     a2->nr = (*t)->u.s.nr + i;
2845     a2->index = (*t)->u.s.index;
2846     @@ -995,6 +996,7 @@ nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
2847     *attrs = &a2->dev_attr.attr;
2848     } else {
2849     a = &su->u.a1;
2850     + sysfs_attr_init(&a->dev_attr.attr);
2851     a->dev_attr.attr.name = su->name;
2852     a->index = (*t)->u.index + i;
2853     a->dev_attr.attr.mode =
2854     diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
2855     index 4ff89b2482e4..31597c504879 100644
2856     --- a/drivers/hwmon/ntc_thermistor.c
2857     +++ b/drivers/hwmon/ntc_thermistor.c
2858     @@ -239,8 +239,10 @@ static struct ntc_thermistor_platform_data *
2859     ntc_thermistor_parse_dt(struct platform_device *pdev)
2860     {
2861     struct iio_channel *chan;
2862     + enum iio_chan_type type;
2863     struct device_node *np = pdev->dev.of_node;
2864     struct ntc_thermistor_platform_data *pdata;
2865     + int ret;
2866    
2867     if (!np)
2868     return NULL;
2869     @@ -253,6 +255,13 @@ ntc_thermistor_parse_dt(struct platform_device *pdev)
2870     if (IS_ERR(chan))
2871     return ERR_CAST(chan);
2872    
2873     + ret = iio_get_channel_type(chan, &type);
2874     + if (ret < 0)
2875     + return ERR_PTR(ret);
2876     +
2877     + if (type != IIO_VOLTAGE)
2878     + return ERR_PTR(-EINVAL);
2879     +
2880     if (of_property_read_u32(np, "pullup-uv", &pdata->pullup_uv))
2881     return ERR_PTR(-ENODEV);
2882     if (of_property_read_u32(np, "pullup-ohm", &pdata->pullup_ohm))
2883     diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
2884     index a221f7329b79..ce93bd8e3f68 100644
2885     --- a/drivers/iio/adc/xilinx-xadc-core.c
2886     +++ b/drivers/iio/adc/xilinx-xadc-core.c
2887     @@ -856,6 +856,7 @@ static int xadc_read_raw(struct iio_dev *indio_dev,
2888     switch (chan->address) {
2889     case XADC_REG_VCCINT:
2890     case XADC_REG_VCCAUX:
2891     + case XADC_REG_VREFP:
2892     case XADC_REG_VCCBRAM:
2893     case XADC_REG_VCCPINT:
2894     case XADC_REG_VCCPAUX:
2895     @@ -996,7 +997,7 @@ static const struct iio_event_spec xadc_voltage_events[] = {
2896     .num_event_specs = (_alarm) ? ARRAY_SIZE(xadc_voltage_events) : 0, \
2897     .scan_index = (_scan_index), \
2898     .scan_type = { \
2899     - .sign = 'u', \
2900     + .sign = ((_addr) == XADC_REG_VREFN) ? 's' : 'u', \
2901     .realbits = 12, \
2902     .storagebits = 16, \
2903     .shift = 4, \
2904     @@ -1008,7 +1009,7 @@ static const struct iio_event_spec xadc_voltage_events[] = {
2905     static const struct iio_chan_spec xadc_channels[] = {
2906     XADC_CHAN_TEMP(0, 8, XADC_REG_TEMP),
2907     XADC_CHAN_VOLTAGE(0, 9, XADC_REG_VCCINT, "vccint", true),
2908     - XADC_CHAN_VOLTAGE(1, 10, XADC_REG_VCCINT, "vccaux", true),
2909     + XADC_CHAN_VOLTAGE(1, 10, XADC_REG_VCCAUX, "vccaux", true),
2910     XADC_CHAN_VOLTAGE(2, 14, XADC_REG_VCCBRAM, "vccbram", true),
2911     XADC_CHAN_VOLTAGE(3, 5, XADC_REG_VCCPINT, "vccpint", true),
2912     XADC_CHAN_VOLTAGE(4, 6, XADC_REG_VCCPAUX, "vccpaux", true),
2913     diff --git a/drivers/iio/adc/xilinx-xadc.h b/drivers/iio/adc/xilinx-xadc.h
2914     index c7487e8d7f80..54adc5087210 100644
2915     --- a/drivers/iio/adc/xilinx-xadc.h
2916     +++ b/drivers/iio/adc/xilinx-xadc.h
2917     @@ -145,9 +145,9 @@ static inline int xadc_write_adc_reg(struct xadc *xadc, unsigned int reg,
2918     #define XADC_REG_MAX_VCCPINT 0x28
2919     #define XADC_REG_MAX_VCCPAUX 0x29
2920     #define XADC_REG_MAX_VCCO_DDR 0x2a
2921     -#define XADC_REG_MIN_VCCPINT 0x2b
2922     -#define XADC_REG_MIN_VCCPAUX 0x2c
2923     -#define XADC_REG_MIN_VCCO_DDR 0x2d
2924     +#define XADC_REG_MIN_VCCPINT 0x2c
2925     +#define XADC_REG_MIN_VCCPAUX 0x2d
2926     +#define XADC_REG_MIN_VCCO_DDR 0x2e
2927    
2928     #define XADC_REG_CONF0 0x40
2929     #define XADC_REG_CONF1 0x41
2930     diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
2931     index f5a514698fd8..d403c988463c 100644
2932     --- a/drivers/iio/light/hid-sensor-prox.c
2933     +++ b/drivers/iio/light/hid-sensor-prox.c
2934     @@ -43,8 +43,6 @@ struct prox_state {
2935     static const struct iio_chan_spec prox_channels[] = {
2936     {
2937     .type = IIO_PROXIMITY,
2938     - .modified = 1,
2939     - .channel2 = IIO_NO_MOD,
2940     .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
2941     .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
2942     BIT(IIO_CHAN_INFO_SCALE) |
2943     diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
2944     index 764928682df2..127db532f35c 100644
2945     --- a/drivers/iio/pressure/hid-sensor-press.c
2946     +++ b/drivers/iio/pressure/hid-sensor-press.c
2947     @@ -47,8 +47,6 @@ struct press_state {
2948     static const struct iio_chan_spec press_channels[] = {
2949     {
2950     .type = IIO_PRESSURE,
2951     - .modified = 1,
2952     - .channel2 = IIO_NO_MOD,
2953     .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
2954     .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
2955     BIT(IIO_CHAN_INFO_SCALE) |
2956     diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
2957     index d570030d899c..06441a43c3aa 100644
2958     --- a/drivers/infiniband/core/cma.c
2959     +++ b/drivers/infiniband/core/cma.c
2960     @@ -859,19 +859,27 @@ static void cma_save_ib_info(struct rdma_cm_id *id, struct rdma_cm_id *listen_id
2961     memcpy(&ib->sib_addr, &path->dgid, 16);
2962     }
2963    
2964     +static __be16 ss_get_port(const struct sockaddr_storage *ss)
2965     +{
2966     + if (ss->ss_family == AF_INET)
2967     + return ((struct sockaddr_in *)ss)->sin_port;
2968     + else if (ss->ss_family == AF_INET6)
2969     + return ((struct sockaddr_in6 *)ss)->sin6_port;
2970     + BUG();
2971     +}
2972     +
2973     static void cma_save_ip4_info(struct rdma_cm_id *id, struct rdma_cm_id *listen_id,
2974     struct cma_hdr *hdr)
2975     {
2976     - struct sockaddr_in *listen4, *ip4;
2977     + struct sockaddr_in *ip4;
2978    
2979     - listen4 = (struct sockaddr_in *) &listen_id->route.addr.src_addr;
2980     ip4 = (struct sockaddr_in *) &id->route.addr.src_addr;
2981     - ip4->sin_family = listen4->sin_family;
2982     + ip4->sin_family = AF_INET;
2983     ip4->sin_addr.s_addr = hdr->dst_addr.ip4.addr;
2984     - ip4->sin_port = listen4->sin_port;
2985     + ip4->sin_port = ss_get_port(&listen_id->route.addr.src_addr);
2986    
2987     ip4 = (struct sockaddr_in *) &id->route.addr.dst_addr;
2988     - ip4->sin_family = listen4->sin_family;
2989     + ip4->sin_family = AF_INET;
2990     ip4->sin_addr.s_addr = hdr->src_addr.ip4.addr;
2991     ip4->sin_port = hdr->port;
2992     }
2993     @@ -879,16 +887,15 @@ static void cma_save_ip4_info(struct rdma_cm_id *id, struct rdma_cm_id *listen_i
2994     static void cma_save_ip6_info(struct rdma_cm_id *id, struct rdma_cm_id *listen_id,
2995     struct cma_hdr *hdr)
2996     {
2997     - struct sockaddr_in6 *listen6, *ip6;
2998     + struct sockaddr_in6 *ip6;
2999    
3000     - listen6 = (struct sockaddr_in6 *) &listen_id->route.addr.src_addr;
3001     ip6 = (struct sockaddr_in6 *) &id->route.addr.src_addr;
3002     - ip6->sin6_family = listen6->sin6_family;
3003     + ip6->sin6_family = AF_INET6;
3004     ip6->sin6_addr = hdr->dst_addr.ip6;
3005     - ip6->sin6_port = listen6->sin6_port;
3006     + ip6->sin6_port = ss_get_port(&listen_id->route.addr.src_addr);
3007    
3008     ip6 = (struct sockaddr_in6 *) &id->route.addr.dst_addr;
3009     - ip6->sin6_family = listen6->sin6_family;
3010     + ip6->sin6_family = AF_INET6;
3011     ip6->sin6_addr = hdr->src_addr.ip6;
3012     ip6->sin6_port = hdr->port;
3013     }
3014     diff --git a/drivers/infiniband/core/iwpm_msg.c b/drivers/infiniband/core/iwpm_msg.c
3015     index b85ddbc979e0..e5558b2660f2 100644
3016     --- a/drivers/infiniband/core/iwpm_msg.c
3017     +++ b/drivers/infiniband/core/iwpm_msg.c
3018     @@ -33,7 +33,7 @@
3019    
3020     #include "iwpm_util.h"
3021    
3022     -static const char iwpm_ulib_name[] = "iWarpPortMapperUser";
3023     +static const char iwpm_ulib_name[IWPM_ULIBNAME_SIZE] = "iWarpPortMapperUser";
3024     static int iwpm_ulib_version = 3;
3025     static int iwpm_user_pid = IWPM_PID_UNDEFINED;
3026     static atomic_t echo_nlmsg_seq;
3027     diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
3028     index 6590558d1d31..ed70f1e72b24 100644
3029     --- a/drivers/lguest/core.c
3030     +++ b/drivers/lguest/core.c
3031     @@ -173,7 +173,7 @@ static void unmap_switcher(void)
3032     bool lguest_address_ok(const struct lguest *lg,
3033     unsigned long addr, unsigned long len)
3034     {
3035     - return (addr+len) / PAGE_SIZE < lg->pfn_limit && (addr+len >= addr);
3036     + return addr+len <= lg->pfn_limit * PAGE_SIZE && (addr+len >= addr);
3037     }
3038    
3039     /*
3040     diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
3041     index a9f2266049af..08981be7baa1 100644
3042     --- a/drivers/md/dm-crypt.c
3043     +++ b/drivers/md/dm-crypt.c
3044     @@ -920,10 +920,11 @@ static int crypt_convert(struct crypt_config *cc,
3045    
3046     switch (r) {
3047     /* async */
3048     - case -EINPROGRESS:
3049     case -EBUSY:
3050     wait_for_completion(&ctx->restart);
3051     reinit_completion(&ctx->restart);
3052     + /* fall through*/
3053     + case -EINPROGRESS:
3054     ctx->req = NULL;
3055     ctx->cc_sector++;
3056     continue;
3057     @@ -1314,8 +1315,10 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
3058     struct dm_crypt_io *io = container_of(ctx, struct dm_crypt_io, ctx);
3059     struct crypt_config *cc = io->cc;
3060    
3061     - if (error == -EINPROGRESS)
3062     + if (error == -EINPROGRESS) {
3063     + complete(&ctx->restart);
3064     return;
3065     + }
3066    
3067     if (!error && cc->iv_gen_ops && cc->iv_gen_ops->post)
3068     error = cc->iv_gen_ops->post(cc, iv_of_dmreq(cc, dmreq), dmreq);
3069     @@ -1326,15 +1329,12 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
3070     crypt_free_req(cc, req_of_dmreq(cc, dmreq), io->base_bio);
3071    
3072     if (!atomic_dec_and_test(&ctx->cc_pending))
3073     - goto done;
3074     + return;
3075    
3076     if (bio_data_dir(io->base_bio) == READ)
3077     kcryptd_crypt_read_done(io);
3078     else
3079     kcryptd_crypt_write_io_submit(io, 1);
3080     -done:
3081     - if (!completion_done(&ctx->restart))
3082     - complete(&ctx->restart);
3083     }
3084    
3085     static void kcryptd_crypt(struct work_struct *work)
3086     diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
3087     index 8577cc7db47e..e421016bab77 100644
3088     --- a/drivers/md/raid5.c
3089     +++ b/drivers/md/raid5.c
3090     @@ -1936,7 +1936,8 @@ static int resize_stripes(struct r5conf *conf, int newsize)
3091    
3092     conf->slab_cache = sc;
3093     conf->active_name = 1-conf->active_name;
3094     - conf->pool_size = newsize;
3095     + if (!err)
3096     + conf->pool_size = newsize;
3097     return err;
3098     }
3099    
3100     diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
3101     index a11451f4f408..a19a18f0058a 100644
3102     --- a/drivers/mmc/card/block.c
3103     +++ b/drivers/mmc/card/block.c
3104     @@ -1025,6 +1025,18 @@ static inline void mmc_blk_reset_success(struct mmc_blk_data *md, int type)
3105     md->reset_done &= ~type;
3106     }
3107    
3108     +int mmc_access_rpmb(struct mmc_queue *mq)
3109     +{
3110     + struct mmc_blk_data *md = mq->data;
3111     + /*
3112     + * If this is a RPMB partition access, return ture
3113     + */
3114     + if (md && md->part_type == EXT_CSD_PART_CONFIG_ACC_RPMB)
3115     + return true;
3116     +
3117     + return false;
3118     +}
3119     +
3120     static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
3121     {
3122     struct mmc_blk_data *md = mq->data;
3123     diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
3124     index cfa6110632c3..7a41a221d248 100644
3125     --- a/drivers/mmc/card/queue.c
3126     +++ b/drivers/mmc/card/queue.c
3127     @@ -38,7 +38,7 @@ static int mmc_prep_request(struct request_queue *q, struct request *req)
3128     return BLKPREP_KILL;
3129     }
3130    
3131     - if (mq && mmc_card_removed(mq->card))
3132     + if (mq && (mmc_card_removed(mq->card) || mmc_access_rpmb(mq)))
3133     return BLKPREP_KILL;
3134    
3135     req->cmd_flags |= REQ_DONTPREP;
3136     diff --git a/drivers/mmc/card/queue.h b/drivers/mmc/card/queue.h
3137     index 5752d50049a3..99e6521e6169 100644
3138     --- a/drivers/mmc/card/queue.h
3139     +++ b/drivers/mmc/card/queue.h
3140     @@ -73,4 +73,6 @@ extern void mmc_queue_bounce_post(struct mmc_queue_req *);
3141     extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *);
3142     extern void mmc_packed_clean(struct mmc_queue *);
3143    
3144     +extern int mmc_access_rpmb(struct mmc_queue *);
3145     +
3146     #endif
3147     diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
3148     index f26a5f1d926d..297b4f912c2d 100644
3149     --- a/drivers/mmc/core/core.c
3150     +++ b/drivers/mmc/core/core.c
3151     @@ -2615,6 +2615,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,
3152     switch (mode) {
3153     case PM_HIBERNATION_PREPARE:
3154     case PM_SUSPEND_PREPARE:
3155     + case PM_RESTORE_PREPARE:
3156     spin_lock_irqsave(&host->lock, flags);
3157     host->rescan_disable = 1;
3158     spin_unlock_irqrestore(&host->lock, flags);
3159     diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
3160     index 77250d4b1979..6423083c5238 100644
3161     --- a/drivers/mmc/host/atmel-mci.c
3162     +++ b/drivers/mmc/host/atmel-mci.c
3163     @@ -1295,7 +1295,7 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
3164    
3165     if (ios->clock) {
3166     unsigned int clock_min = ~0U;
3167     - u32 clkdiv;
3168     + int clkdiv;
3169    
3170     clk_prepare(host->mck);
3171     unprepare_clk = true;
3172     @@ -1324,7 +1324,12 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
3173     /* Calculate clock divider */
3174     if (host->caps.has_odd_clk_div) {
3175     clkdiv = DIV_ROUND_UP(host->bus_hz, clock_min) - 2;
3176     - if (clkdiv > 511) {
3177     + if (clkdiv < 0) {
3178     + dev_warn(&mmc->class_dev,
3179     + "clock %u too fast; using %lu\n",
3180     + clock_min, host->bus_hz / 2);
3181     + clkdiv = 0;
3182     + } else if (clkdiv > 511) {
3183     dev_warn(&mmc->class_dev,
3184     "clock %u too slow; using %lu\n",
3185     clock_min, host->bus_hz / (511 + 2));
3186     diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
3187     index 7d9d6a321521..5165ae75d540 100644
3188     --- a/drivers/mmc/host/sh_mmcif.c
3189     +++ b/drivers/mmc/host/sh_mmcif.c
3190     @@ -1402,7 +1402,7 @@ static int sh_mmcif_probe(struct platform_device *pdev)
3191     host = mmc_priv(mmc);
3192     host->mmc = mmc;
3193     host->addr = reg;
3194     - host->timeout = msecs_to_jiffies(1000);
3195     + host->timeout = msecs_to_jiffies(10000);
3196     host->ccs_enable = !pd || !pd->ccs_unsupported;
3197     host->clk_ctrl2_enable = pd && pd->clk_ctrl2_present;
3198    
3199     diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
3200     index dd2f3f8baa9d..c943baa4e9f1 100644
3201     --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
3202     +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
3203     @@ -5,8 +5,8 @@
3204     *
3205     * GPL LICENSE SUMMARY
3206     *
3207     - * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
3208     - * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
3209     + * Copyright(c) 2007 - 2015 Intel Corporation. All rights reserved.
3210     + * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
3211     *
3212     * This program is free software; you can redistribute it and/or modify
3213     * it under the terms of version 2 of the GNU General Public License as
3214     @@ -31,8 +31,8 @@
3215     *
3216     * BSD LICENSE
3217     *
3218     - * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
3219     - * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
3220     + * Copyright(c) 2005 - 2015 Intel Corporation. All rights reserved.
3221     + * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
3222     * All rights reserved.
3223     *
3224     * Redistribution and use in source and binary forms, with or without
3225     @@ -98,7 +98,7 @@ static void iwl_pcie_free_fw_monitor(struct iwl_trans *trans)
3226     static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans)
3227     {
3228     struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
3229     - struct page *page;
3230     + struct page *page = NULL;
3231     dma_addr_t phys;
3232     u32 size;
3233     u8 power;
3234     @@ -125,6 +125,7 @@ static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans)
3235     DMA_FROM_DEVICE);
3236     if (dma_mapping_error(trans->dev, phys)) {
3237     __free_pages(page, order);
3238     + page = NULL;
3239     continue;
3240     }
3241     IWL_INFO(trans,
3242     diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
3243     index 8444313eabe2..8694dddcce9a 100644
3244     --- a/drivers/net/wireless/rt2x00/rt2800usb.c
3245     +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
3246     @@ -1040,6 +1040,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
3247     { USB_DEVICE(0x07d1, 0x3c17) },
3248     { USB_DEVICE(0x2001, 0x3317) },
3249     { USB_DEVICE(0x2001, 0x3c1b) },
3250     + { USB_DEVICE(0x2001, 0x3c25) },
3251     /* Draytek */
3252     { USB_DEVICE(0x07fa, 0x7712) },
3253     /* DVICO */
3254     diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
3255     index 46ee956d0235..27cd6cabf6c5 100644
3256     --- a/drivers/net/wireless/rtlwifi/usb.c
3257     +++ b/drivers/net/wireless/rtlwifi/usb.c
3258     @@ -126,7 +126,7 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request,
3259    
3260     do {
3261     status = usb_control_msg(udev, pipe, request, reqtype, value,
3262     - index, pdata, len, 0); /*max. timeout*/
3263     + index, pdata, len, 1000);
3264     if (status < 0) {
3265     /* firmware download is checksumed, don't retry */
3266     if ((value >= FW_8192C_START_ADDRESS &&
3267     diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
3268     index 89dca77ca038..18ee2089df4a 100644
3269     --- a/drivers/pinctrl/core.c
3270     +++ b/drivers/pinctrl/core.c
3271     @@ -1110,7 +1110,7 @@ void devm_pinctrl_put(struct pinctrl *p)
3272     EXPORT_SYMBOL_GPL(devm_pinctrl_put);
3273    
3274     int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps,
3275     - bool dup, bool locked)
3276     + bool dup)
3277     {
3278     int i, ret;
3279     struct pinctrl_maps *maps_node;
3280     @@ -1178,11 +1178,9 @@ int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps,
3281     maps_node->maps = maps;
3282     }
3283    
3284     - if (!locked)
3285     - mutex_lock(&pinctrl_maps_mutex);
3286     + mutex_lock(&pinctrl_maps_mutex);
3287     list_add_tail(&maps_node->node, &pinctrl_maps);
3288     - if (!locked)
3289     - mutex_unlock(&pinctrl_maps_mutex);
3290     + mutex_unlock(&pinctrl_maps_mutex);
3291    
3292     return 0;
3293     }
3294     @@ -1197,7 +1195,7 @@ int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps,
3295     int pinctrl_register_mappings(struct pinctrl_map const *maps,
3296     unsigned num_maps)
3297     {
3298     - return pinctrl_register_map(maps, num_maps, true, false);
3299     + return pinctrl_register_map(maps, num_maps, true);
3300     }
3301    
3302     void pinctrl_unregister_map(struct pinctrl_map const *map)
3303     diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
3304     index 75476b3d87da..b24ea846c867 100644
3305     --- a/drivers/pinctrl/core.h
3306     +++ b/drivers/pinctrl/core.h
3307     @@ -183,7 +183,7 @@ static inline struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev,
3308     }
3309    
3310     int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps,
3311     - bool dup, bool locked);
3312     + bool dup);
3313     void pinctrl_unregister_map(struct pinctrl_map const *map);
3314    
3315     extern int pinctrl_force_sleep(struct pinctrl_dev *pctldev);
3316     diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
3317     index eda13de2e7c0..0bbf7d71b281 100644
3318     --- a/drivers/pinctrl/devicetree.c
3319     +++ b/drivers/pinctrl/devicetree.c
3320     @@ -92,7 +92,7 @@ static int dt_remember_or_free_map(struct pinctrl *p, const char *statename,
3321     dt_map->num_maps = num_maps;
3322     list_add_tail(&dt_map->node, &p->dt_maps);
3323    
3324     - return pinctrl_register_map(map, num_maps, false, true);
3325     + return pinctrl_register_map(map, num_maps, false);
3326     }
3327    
3328     struct pinctrl_dev *of_pinctrl_get(struct device_node *np)
3329     diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
3330     index 3cb36693343a..80d490da9a45 100644
3331     --- a/drivers/power/reset/at91-reset.c
3332     +++ b/drivers/power/reset/at91-reset.c
3333     @@ -205,9 +205,9 @@ static int at91_reset_platform_probe(struct platform_device *pdev)
3334     res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1 );
3335     at91_ramc_base[idx] = devm_ioremap(&pdev->dev, res->start,
3336     resource_size(res));
3337     - if (IS_ERR(at91_ramc_base[idx])) {
3338     + if (!at91_ramc_base[idx]) {
3339     dev_err(&pdev->dev, "Could not map ram controller address\n");
3340     - return PTR_ERR(at91_ramc_base[idx]);
3341     + return -ENOMEM;
3342     }
3343     }
3344    
3345     diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
3346     index 7a4d88c91069..ce382e858452 100644
3347     --- a/drivers/scsi/sd.c
3348     +++ b/drivers/scsi/sd.c
3349     @@ -1634,6 +1634,7 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
3350     {
3351     u64 start_lba = blk_rq_pos(scmd->request);
3352     u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512);
3353     + u64 factor = scmd->device->sector_size / 512;
3354     u64 bad_lba;
3355     int info_valid;
3356     /*
3357     @@ -1655,16 +1656,9 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
3358     if (scsi_bufflen(scmd) <= scmd->device->sector_size)
3359     return 0;
3360    
3361     - if (scmd->device->sector_size < 512) {
3362     - /* only legitimate sector_size here is 256 */
3363     - start_lba <<= 1;
3364     - end_lba <<= 1;
3365     - } else {
3366     - /* be careful ... don't want any overflows */
3367     - unsigned int factor = scmd->device->sector_size / 512;
3368     - do_div(start_lba, factor);
3369     - do_div(end_lba, factor);
3370     - }
3371     + /* be careful ... don't want any overflows */
3372     + do_div(start_lba, factor);
3373     + do_div(end_lba, factor);
3374    
3375     /* The bad lba was reported incorrectly, we have no idea where
3376     * the error is.
3377     @@ -2231,8 +2225,7 @@ got_data:
3378     if (sector_size != 512 &&
3379     sector_size != 1024 &&
3380     sector_size != 2048 &&
3381     - sector_size != 4096 &&
3382     - sector_size != 256) {
3383     + sector_size != 4096) {
3384     sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n",
3385     sector_size);
3386     /*
3387     @@ -2287,8 +2280,6 @@ got_data:
3388     sdkp->capacity <<= 2;
3389     else if (sector_size == 1024)
3390     sdkp->capacity <<= 1;
3391     - else if (sector_size == 256)
3392     - sdkp->capacity >>= 1;
3393    
3394     blk_queue_physical_block_size(sdp->request_queue,
3395     sdkp->physical_block_size);
3396     diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
3397     index 4534d9debcdc..e511e3406cfa 100644
3398     --- a/drivers/scsi/storvsc_drv.c
3399     +++ b/drivers/scsi/storvsc_drv.c
3400     @@ -1623,8 +1623,7 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
3401     break;
3402     default:
3403     vm_srb->data_in = UNKNOWN_TYPE;
3404     - vm_srb->win8_extension.srb_flags |= (SRB_FLAGS_DATA_IN |
3405     - SRB_FLAGS_DATA_OUT);
3406     + vm_srb->win8_extension.srb_flags |= SRB_FLAGS_NO_DATA_TRANSFER;
3407     break;
3408     }
3409    
3410     diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c
3411     index b5b063a738f8..fe410445a1af 100644
3412     --- a/drivers/staging/gdm724x/gdm_mux.c
3413     +++ b/drivers/staging/gdm724x/gdm_mux.c
3414     @@ -158,7 +158,7 @@ static int up_to_host(struct mux_rx *r)
3415     unsigned int start_flag;
3416     unsigned int payload_size;
3417     unsigned short packet_type;
3418     - int dummy_cnt;
3419     + int total_len;
3420     u32 packet_size_sum = r->offset;
3421     int index;
3422     int ret = TO_HOST_INVALID_PACKET;
3423     @@ -176,10 +176,10 @@ static int up_to_host(struct mux_rx *r)
3424     break;
3425     }
3426    
3427     - dummy_cnt = ALIGN(MUX_HEADER_SIZE + payload_size, 4);
3428     + total_len = ALIGN(MUX_HEADER_SIZE + payload_size, 4);
3429    
3430     if (len - packet_size_sum <
3431     - MUX_HEADER_SIZE + payload_size + dummy_cnt) {
3432     + total_len) {
3433     pr_err("invalid payload : %d %d %04x\n",
3434     payload_size, len, packet_type);
3435     break;
3436     @@ -202,7 +202,7 @@ static int up_to_host(struct mux_rx *r)
3437     break;
3438     }
3439    
3440     - packet_size_sum += MUX_HEADER_SIZE + payload_size + dummy_cnt;
3441     + packet_size_sum += total_len;
3442     if (len - packet_size_sum <= MUX_HEADER_SIZE + 2) {
3443     ret = r->callback(NULL,
3444     0,
3445     @@ -361,7 +361,6 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index,
3446     struct mux_pkt_header *mux_header;
3447     struct mux_tx *t = NULL;
3448     static u32 seq_num = 1;
3449     - int dummy_cnt;
3450     int total_len;
3451     int ret;
3452     unsigned long flags;
3453     @@ -374,9 +373,7 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index,
3454    
3455     spin_lock_irqsave(&mux_dev->write_lock, flags);
3456    
3457     - dummy_cnt = ALIGN(MUX_HEADER_SIZE + len, 4);
3458     -
3459     - total_len = len + MUX_HEADER_SIZE + dummy_cnt;
3460     + total_len = ALIGN(MUX_HEADER_SIZE + len, 4);
3461    
3462     t = alloc_mux_tx(total_len);
3463     if (!t) {
3464     @@ -392,7 +389,8 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index,
3465     mux_header->packet_type = __cpu_to_le16(packet_type[tty_index]);
3466    
3467     memcpy(t->buf+MUX_HEADER_SIZE, data, len);
3468     - memset(t->buf+MUX_HEADER_SIZE+len, 0, dummy_cnt);
3469     + memset(t->buf+MUX_HEADER_SIZE+len, 0, total_len - MUX_HEADER_SIZE -
3470     + len);
3471    
3472     t->len = total_len;
3473     t->callback = cb;
3474     diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
3475     index ea5140ab2b41..b3500fd31394 100644
3476     --- a/drivers/staging/vt6656/rxtx.c
3477     +++ b/drivers/staging/vt6656/rxtx.c
3478     @@ -800,10 +800,18 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
3479     vnt_schedule_command(priv, WLAN_CMD_SETPOWER);
3480     }
3481    
3482     - if (current_rate > RATE_11M)
3483     - pkt_type = priv->packet_type;
3484     - else
3485     + if (current_rate > RATE_11M) {
3486     + if (info->band == IEEE80211_BAND_5GHZ) {
3487     + pkt_type = PK_TYPE_11A;
3488     + } else {
3489     + if (tx_rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
3490     + pkt_type = PK_TYPE_11GB;
3491     + else
3492     + pkt_type = PK_TYPE_11GA;
3493     + }
3494     + } else {
3495     pkt_type = PK_TYPE_11B;
3496     + }
3497    
3498     spin_lock_irqsave(&priv->lock, flags);
3499    
3500     diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
3501     index 9a54381e23c6..3ee77db03cb7 100644
3502     --- a/drivers/target/target_core_pscsi.c
3503     +++ b/drivers/target/target_core_pscsi.c
3504     @@ -520,6 +520,7 @@ static int pscsi_configure_device(struct se_device *dev)
3505     " pdv_host_id: %d\n", pdv->pdv_host_id);
3506     return -EINVAL;
3507     }
3508     + pdv->pdv_lld_host = sh;
3509     }
3510     } else {
3511     if (phv->phv_mode == PHV_VIRTUAL_HOST_ID) {
3512     @@ -602,6 +603,8 @@ static void pscsi_free_device(struct se_device *dev)
3513     if ((phv->phv_mode == PHV_LLD_SCSI_HOST_NO) &&
3514     (phv->phv_lld_host != NULL))
3515     scsi_host_put(phv->phv_lld_host);
3516     + else if (pdv->pdv_lld_host)
3517     + scsi_host_put(pdv->pdv_lld_host);
3518    
3519     if ((sd->type == TYPE_DISK) || (sd->type == TYPE_ROM))
3520     scsi_device_put(sd);
3521     diff --git a/drivers/target/target_core_pscsi.h b/drivers/target/target_core_pscsi.h
3522     index 1bd757dff8ee..820d3052b775 100644
3523     --- a/drivers/target/target_core_pscsi.h
3524     +++ b/drivers/target/target_core_pscsi.h
3525     @@ -45,6 +45,7 @@ struct pscsi_dev_virt {
3526     int pdv_lun_id;
3527     struct block_device *pdv_bd;
3528     struct scsi_device *pdv_sd;
3529     + struct Scsi_Host *pdv_lld_host;
3530     } ____cacheline_aligned;
3531    
3532     typedef enum phv_modes {
3533     diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
3534     index 9d1420acb391..e6f1acc71996 100644
3535     --- a/drivers/thermal/armada_thermal.c
3536     +++ b/drivers/thermal/armada_thermal.c
3537     @@ -240,9 +240,9 @@ static const struct armada_thermal_data armada380_data = {
3538     .is_valid_shift = 10,
3539     .temp_shift = 0,
3540     .temp_mask = 0x3ff,
3541     - .coef_b = 1169498786UL,
3542     - .coef_m = 2000000UL,
3543     - .coef_div = 4289,
3544     + .coef_b = 2931108200UL,
3545     + .coef_m = 5000000UL,
3546     + .coef_div = 10502,
3547     .inverted = true,
3548     };
3549    
3550     diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
3551     index f1e57425e39f..7a3d146a5f0e 100644
3552     --- a/drivers/tty/hvc/hvc_xen.c
3553     +++ b/drivers/tty/hvc/hvc_xen.c
3554     @@ -289,7 +289,7 @@ static int xen_initial_domain_console_init(void)
3555     return -ENOMEM;
3556     }
3557    
3558     - info->irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
3559     + info->irq = bind_virq_to_irq(VIRQ_CONSOLE, 0, false);
3560     info->vtermno = HVC_COOKIE;
3561    
3562     spin_lock(&xencons_lock);
3563     @@ -299,11 +299,27 @@ static int xen_initial_domain_console_init(void)
3564     return 0;
3565     }
3566    
3567     +static void xen_console_update_evtchn(struct xencons_info *info)
3568     +{
3569     + if (xen_hvm_domain()) {
3570     + uint64_t v;
3571     + int err;
3572     +
3573     + err = hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN, &v);
3574     + if (!err && v)
3575     + info->evtchn = v;
3576     + } else
3577     + info->evtchn = xen_start_info->console.domU.evtchn;
3578     +}
3579     +
3580     void xen_console_resume(void)
3581     {
3582     struct xencons_info *info = vtermno_to_xencons(HVC_COOKIE);
3583     - if (info != NULL && info->irq)
3584     + if (info != NULL && info->irq) {
3585     + if (!xen_initial_domain())
3586     + xen_console_update_evtchn(info);
3587     rebind_evtchn_irq(info->evtchn, info->irq);
3588     + }
3589     }
3590    
3591     static void xencons_disconnect_backend(struct xencons_info *info)
3592     diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
3593     index c4343764cc5b..bce16e405d59 100644
3594     --- a/drivers/tty/n_gsm.c
3595     +++ b/drivers/tty/n_gsm.c
3596     @@ -3170,7 +3170,7 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int state)
3597     return gsmtty_modem_update(dlci, encode);
3598     }
3599    
3600     -static void gsmtty_remove(struct tty_driver *driver, struct tty_struct *tty)
3601     +static void gsmtty_cleanup(struct tty_struct *tty)
3602     {
3603     struct gsm_dlci *dlci = tty->driver_data;
3604     struct gsm_mux *gsm = dlci->gsm;
3605     @@ -3178,7 +3178,6 @@ static void gsmtty_remove(struct tty_driver *driver, struct tty_struct *tty)
3606     dlci_put(dlci);
3607     dlci_put(gsm->dlci[0]);
3608     mux_put(gsm);
3609     - driver->ttys[tty->index] = NULL;
3610     }
3611    
3612     /* Virtual ttys for the demux */
3613     @@ -3199,7 +3198,7 @@ static const struct tty_operations gsmtty_ops = {
3614     .tiocmget = gsmtty_tiocmget,
3615     .tiocmset = gsmtty_tiocmset,
3616     .break_ctl = gsmtty_break_ctl,
3617     - .remove = gsmtty_remove,
3618     + .cleanup = gsmtty_cleanup,
3619     };
3620    
3621    
3622     diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
3623     index 28d3dd3637b3..a7e1a96e69a5 100644
3624     --- a/drivers/usb/gadget/configfs.c
3625     +++ b/drivers/usb/gadget/configfs.c
3626     @@ -1295,6 +1295,7 @@ static void purge_configs_funcs(struct gadget_info *gi)
3627     }
3628     }
3629     c->next_interface_id = 0;
3630     + memset(c->interface, 0, sizeof(c->interface));
3631     c->superspeed = 0;
3632     c->highspeed = 0;
3633     c->fullspeed = 0;
3634     diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
3635     index 3307e161c100..9848a67ddbbe 100644
3636     --- a/drivers/usb/host/xhci-ring.c
3637     +++ b/drivers/usb/host/xhci-ring.c
3638     @@ -2037,8 +2037,13 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
3639     break;
3640     case COMP_DEV_ERR:
3641     case COMP_STALL:
3642     + frame->status = -EPROTO;
3643     + skip_td = true;
3644     + break;
3645     case COMP_TX_ERR:
3646     frame->status = -EPROTO;
3647     + if (event_trb != td->last_trb)
3648     + return 0;
3649     skip_td = true;
3650     break;
3651     case COMP_STOP:
3652     @@ -2651,7 +2656,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
3653     xhci_halt(xhci);
3654     hw_died:
3655     spin_unlock(&xhci->lock);
3656     - return -ESHUTDOWN;
3657     + return IRQ_HANDLED;
3658     }
3659    
3660     /*
3661     diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
3662     index 94251141adae..54f386f80970 100644
3663     --- a/drivers/usb/host/xhci.h
3664     +++ b/drivers/usb/host/xhci.h
3665     @@ -1267,7 +1267,7 @@ union xhci_trb {
3666     * since the command ring is 64-byte aligned.
3667     * It must also be greater than 16.
3668     */
3669     -#define TRBS_PER_SEGMENT 64
3670     +#define TRBS_PER_SEGMENT 256
3671     /* Allow two commands + a link TRB, along with any reserved command TRBs */
3672     #define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3)
3673     #define TRB_SEGMENT_SIZE (TRBS_PER_SEGMENT*16)
3674     diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
3675     index 84ce2d74894c..9031750e7404 100644
3676     --- a/drivers/usb/serial/cp210x.c
3677     +++ b/drivers/usb/serial/cp210x.c
3678     @@ -127,6 +127,7 @@ static const struct usb_device_id id_table[] = {
3679     { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */
3680     { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */
3681     { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */
3682     + { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */
3683     { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
3684     { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
3685     { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
3686     diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
3687     index 0f872e6b2c87..534c308c6b33 100644
3688     --- a/drivers/usb/serial/pl2303.c
3689     +++ b/drivers/usb/serial/pl2303.c
3690     @@ -61,7 +61,6 @@ static const struct usb_device_id id_table[] = {
3691     { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) },
3692     { USB_DEVICE(SITECOM_VENDOR_ID, SITECOM_PRODUCT_ID) },
3693     { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) },
3694     - { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) },
3695     { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_SX1),
3696     .driver_info = PL2303_QUIRK_UART_STATE_IDX0 },
3697     { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65),
3698     diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
3699     index 71fd9da1d6e7..e3b7af8adfb7 100644
3700     --- a/drivers/usb/serial/pl2303.h
3701     +++ b/drivers/usb/serial/pl2303.h
3702     @@ -62,10 +62,6 @@
3703     #define ALCATEL_VENDOR_ID 0x11f7
3704     #define ALCATEL_PRODUCT_ID 0x02df
3705    
3706     -/* Samsung I330 phone cradle */
3707     -#define SAMSUNG_VENDOR_ID 0x04e8
3708     -#define SAMSUNG_PRODUCT_ID 0x8001
3709     -
3710     #define SIEMENS_VENDOR_ID 0x11f5
3711     #define SIEMENS_PRODUCT_ID_SX1 0x0001
3712     #define SIEMENS_PRODUCT_ID_X65 0x0003
3713     diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
3714     index bf2bd40e5f2a..60afb39eb73c 100644
3715     --- a/drivers/usb/serial/visor.c
3716     +++ b/drivers/usb/serial/visor.c
3717     @@ -95,7 +95,7 @@ static const struct usb_device_id id_table[] = {
3718     .driver_info = (kernel_ulong_t)&palm_os_4_probe },
3719     { USB_DEVICE(ACER_VENDOR_ID, ACER_S10_ID),
3720     .driver_info = (kernel_ulong_t)&palm_os_4_probe },
3721     - { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID),
3722     + { USB_DEVICE_INTERFACE_CLASS(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID, 0xff),
3723     .driver_info = (kernel_ulong_t)&palm_os_4_probe },
3724     { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID),
3725     .driver_info = (kernel_ulong_t)&palm_os_4_probe },
3726     diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
3727     index 8adb53044079..300ef9b817ed 100644
3728     --- a/drivers/usb/storage/unusual_devs.h
3729     +++ b/drivers/usb/storage/unusual_devs.h
3730     @@ -766,6 +766,13 @@ UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000,
3731     USB_SC_DEVICE, USB_PR_DEVICE, NULL,
3732     US_FL_GO_SLOW ),
3733    
3734     +/* Reported by Christian Schaller <cschalle@redhat.com> */
3735     +UNUSUAL_DEV( 0x059f, 0x0651, 0x0000, 0x0000,
3736     + "LaCie",
3737     + "External HDD",
3738     + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
3739     + US_FL_NO_WP_DETECT ),
3740     +
3741     /* Submitted by Joel Bourquard <numlock@freesurf.ch>
3742     * Some versions of this device need the SubClass and Protocol overrides
3743     * while others don't.
3744     diff --git a/drivers/xen/events/events_2l.c b/drivers/xen/events/events_2l.c
3745     index 5db43fc100a4..7dd46312c180 100644
3746     --- a/drivers/xen/events/events_2l.c
3747     +++ b/drivers/xen/events/events_2l.c
3748     @@ -345,6 +345,15 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)
3749     return IRQ_HANDLED;
3750     }
3751    
3752     +static void evtchn_2l_resume(void)
3753     +{
3754     + int i;
3755     +
3756     + for_each_online_cpu(i)
3757     + memset(per_cpu(cpu_evtchn_mask, i), 0, sizeof(xen_ulong_t) *
3758     + EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD);
3759     +}
3760     +
3761     static const struct evtchn_ops evtchn_ops_2l = {
3762     .max_channels = evtchn_2l_max_channels,
3763     .nr_channels = evtchn_2l_max_channels,
3764     @@ -356,6 +365,7 @@ static const struct evtchn_ops evtchn_ops_2l = {
3765     .mask = evtchn_2l_mask,
3766     .unmask = evtchn_2l_unmask,
3767     .handle_events = evtchn_2l_handle_events,
3768     + .resume = evtchn_2l_resume,
3769     };
3770    
3771     void __init xen_evtchn_2l_init(void)
3772     diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
3773     index 70fba973a107..38387950490e 100644
3774     --- a/drivers/xen/events/events_base.c
3775     +++ b/drivers/xen/events/events_base.c
3776     @@ -529,8 +529,8 @@ static unsigned int __startup_pirq(unsigned int irq)
3777     if (rc)
3778     goto err;
3779    
3780     - bind_evtchn_to_cpu(evtchn, 0);
3781     info->evtchn = evtchn;
3782     + bind_evtchn_to_cpu(evtchn, 0);
3783    
3784     rc = xen_evtchn_port_setup(info);
3785     if (rc)
3786     @@ -957,7 +957,7 @@ unsigned xen_evtchn_nr_channels(void)
3787     }
3788     EXPORT_SYMBOL_GPL(xen_evtchn_nr_channels);
3789    
3790     -int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
3791     +int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu)
3792     {
3793     struct evtchn_bind_virq bind_virq;
3794     int evtchn, irq, ret;
3795     @@ -971,8 +971,12 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
3796     if (irq < 0)
3797     goto out;
3798    
3799     - irq_set_chip_and_handler_name(irq, &xen_percpu_chip,
3800     - handle_percpu_irq, "virq");
3801     + if (percpu)
3802     + irq_set_chip_and_handler_name(irq, &xen_percpu_chip,
3803     + handle_percpu_irq, "virq");
3804     + else
3805     + irq_set_chip_and_handler_name(irq, &xen_dynamic_chip,
3806     + handle_edge_irq, "virq");
3807    
3808     bind_virq.virq = virq;
3809     bind_virq.vcpu = cpu;
3810     @@ -1062,7 +1066,7 @@ int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu,
3811     {
3812     int irq, retval;
3813    
3814     - irq = bind_virq_to_irq(virq, cpu);
3815     + irq = bind_virq_to_irq(virq, cpu, irqflags & IRQF_PERCPU);
3816     if (irq < 0)
3817     return irq;
3818     retval = request_irq(irq, handler, irqflags, devname, dev_id);
3819     @@ -1279,8 +1283,9 @@ void rebind_evtchn_irq(int evtchn, int irq)
3820    
3821     mutex_unlock(&irq_mapping_update_lock);
3822    
3823     - /* new event channels are always bound to cpu 0 */
3824     - irq_set_affinity(irq, cpumask_of(0));
3825     + bind_evtchn_to_cpu(evtchn, info->cpu);
3826     + /* This will be deferred until interrupt is processed */
3827     + irq_set_affinity(irq, cpumask_of(info->cpu));
3828    
3829     /* Unmask the event channel. */
3830     enable_irq(irq);
3831     diff --git a/drivers/xen/xen-pciback/conf_space.c b/drivers/xen/xen-pciback/conf_space.c
3832     index 75fe3d466515..9c234209d8b5 100644
3833     --- a/drivers/xen/xen-pciback/conf_space.c
3834     +++ b/drivers/xen/xen-pciback/conf_space.c
3835     @@ -16,8 +16,8 @@
3836     #include "conf_space.h"
3837     #include "conf_space_quirks.h"
3838    
3839     -bool permissive;
3840     -module_param(permissive, bool, 0644);
3841     +bool xen_pcibk_permissive;
3842     +module_param_named(permissive, xen_pcibk_permissive, bool, 0644);
3843    
3844     /* This is where xen_pcibk_read_config_byte, xen_pcibk_read_config_word,
3845     * xen_pcibk_write_config_word, and xen_pcibk_write_config_byte are created. */
3846     @@ -262,7 +262,7 @@ int xen_pcibk_config_write(struct pci_dev *dev, int offset, int size, u32 value)
3847     * This means that some fields may still be read-only because
3848     * they have entries in the config_field list that intercept
3849     * the write and do nothing. */
3850     - if (dev_data->permissive || permissive) {
3851     + if (dev_data->permissive || xen_pcibk_permissive) {
3852     switch (size) {
3853     case 1:
3854     err = pci_write_config_byte(dev, offset,
3855     diff --git a/drivers/xen/xen-pciback/conf_space.h b/drivers/xen/xen-pciback/conf_space.h
3856     index 2e1d73d1d5d0..62461a8ba1d6 100644
3857     --- a/drivers/xen/xen-pciback/conf_space.h
3858     +++ b/drivers/xen/xen-pciback/conf_space.h
3859     @@ -64,7 +64,7 @@ struct config_field_entry {
3860     void *data;
3861     };
3862    
3863     -extern bool permissive;
3864     +extern bool xen_pcibk_permissive;
3865    
3866     #define OFFSET(cfg_entry) ((cfg_entry)->base_offset+(cfg_entry)->field->offset)
3867    
3868     diff --git a/drivers/xen/xen-pciback/conf_space_header.c b/drivers/xen/xen-pciback/conf_space_header.c
3869     index 2d7369391472..f8baf463dd35 100644
3870     --- a/drivers/xen/xen-pciback/conf_space_header.c
3871     +++ b/drivers/xen/xen-pciback/conf_space_header.c
3872     @@ -105,7 +105,7 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
3873    
3874     cmd->val = value;
3875    
3876     - if (!permissive && (!dev_data || !dev_data->permissive))
3877     + if (!xen_pcibk_permissive && (!dev_data || !dev_data->permissive))
3878     return 0;
3879    
3880     /* Only allow the guest to control certain bits. */
3881     diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
3882     index 564b31584860..5390a674b5e3 100644
3883     --- a/drivers/xen/xenbus/xenbus_probe.c
3884     +++ b/drivers/xen/xenbus/xenbus_probe.c
3885     @@ -57,6 +57,7 @@
3886     #include <xen/xen.h>
3887     #include <xen/xenbus.h>
3888     #include <xen/events.h>
3889     +#include <xen/xen-ops.h>
3890     #include <xen/page.h>
3891    
3892     #include <xen/hvm.h>
3893     @@ -735,6 +736,30 @@ static int __init xenstored_local_init(void)
3894     return err;
3895     }
3896    
3897     +static int xenbus_resume_cb(struct notifier_block *nb,
3898     + unsigned long action, void *data)
3899     +{
3900     + int err = 0;
3901     +
3902     + if (xen_hvm_domain()) {
3903     + uint64_t v;
3904     +
3905     + err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
3906     + if (!err && v)
3907     + xen_store_evtchn = v;
3908     + else
3909     + pr_warn("Cannot update xenstore event channel: %d\n",
3910     + err);
3911     + } else
3912     + xen_store_evtchn = xen_start_info->store_evtchn;
3913     +
3914     + return err;
3915     +}
3916     +
3917     +static struct notifier_block xenbus_resume_nb = {
3918     + .notifier_call = xenbus_resume_cb,
3919     +};
3920     +
3921     static int __init xenbus_init(void)
3922     {
3923     int err = 0;
3924     @@ -793,6 +818,10 @@ static int __init xenbus_init(void)
3925     goto out_error;
3926     }
3927    
3928     + if ((xen_store_domain_type != XS_LOCAL) &&
3929     + (xen_store_domain_type != XS_UNKNOWN))
3930     + xen_resume_notifier_register(&xenbus_resume_nb);
3931     +
3932     #ifdef CONFIG_XEN_COMPAT_XENFS
3933     /*
3934     * Create xenfs mountpoint in /proc for compatibility with
3935     diff --git a/fs/coredump.c b/fs/coredump.c
3936     index b5c86ffd5033..4c5866b948e7 100644
3937     --- a/fs/coredump.c
3938     +++ b/fs/coredump.c
3939     @@ -657,7 +657,7 @@ void do_coredump(const siginfo_t *siginfo)
3940     */
3941     if (!uid_eq(inode->i_uid, current_fsuid()))
3942     goto close_fail;
3943     - if (!cprm.file->f_op->write)
3944     + if (!(cprm.file->f_mode & FMODE_CAN_WRITE))
3945     goto close_fail;
3946     if (do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file))
3947     goto close_fail;
3948     diff --git a/fs/dcache.c b/fs/dcache.c
3949     index 03dca3cad918..e0750b8f51aa 100644
3950     --- a/fs/dcache.c
3951     +++ b/fs/dcache.c
3952     @@ -1094,13 +1094,13 @@ ascend:
3953     /* might go back up the wrong parent if we have had a rename. */
3954     if (need_seqretry(&rename_lock, seq))
3955     goto rename_retry;
3956     - next = child->d_child.next;
3957     - while (unlikely(child->d_flags & DCACHE_DENTRY_KILLED)) {
3958     + /* go into the first sibling still alive */
3959     + do {
3960     + next = child->d_child.next;
3961     if (next == &this_parent->d_subdirs)
3962     goto ascend;
3963     child = list_entry(next, struct dentry, d_child);
3964     - next = next->next;
3965     - }
3966     + } while (unlikely(child->d_flags & DCACHE_DENTRY_KILLED));
3967     rcu_read_unlock();
3968     goto resume;
3969     }
3970     diff --git a/fs/exec.c b/fs/exec.c
3971     index 2e83209016ec..b7a5f46181b0 100644
3972     --- a/fs/exec.c
3973     +++ b/fs/exec.c
3974     @@ -658,6 +658,9 @@ int setup_arg_pages(struct linux_binprm *bprm,
3975     if (stack_base > STACK_SIZE_MAX)
3976     stack_base = STACK_SIZE_MAX;
3977    
3978     + /* Add space for stack randomization. */
3979     + stack_base += (STACK_RND_MASK << PAGE_SHIFT);
3980     +
3981     /* Make sure we didn't let the argument array grow too large. */
3982     if (vma->vm_end - vma->vm_start > stack_base)
3983     return -ENOMEM;
3984     diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
3985     index 3445035c7e01..d41843181818 100644
3986     --- a/fs/ext4/ext4_jbd2.c
3987     +++ b/fs/ext4/ext4_jbd2.c
3988     @@ -87,6 +87,12 @@ int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle)
3989     ext4_put_nojournal(handle);
3990     return 0;
3991     }
3992     +
3993     + if (!handle->h_transaction) {
3994     + err = jbd2_journal_stop(handle);
3995     + return handle->h_err ? handle->h_err : err;
3996     + }
3997     +
3998     sb = handle->h_transaction->t_journal->j_private;
3999     err = handle->h_err;
4000     rc = jbd2_journal_stop(handle);
4001     diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
4002     index 6cfacbb0f928..b5fcb1ac0dd7 100644
4003     --- a/fs/ext4/extents.c
4004     +++ b/fs/ext4/extents.c
4005     @@ -377,7 +377,7 @@ static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext)
4006     ext4_lblk_t lblock = le32_to_cpu(ext->ee_block);
4007     ext4_lblk_t last = lblock + len - 1;
4008    
4009     - if (lblock > last)
4010     + if (len == 0 || lblock > last)
4011     return 0;
4012     return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len);
4013     }
4014     diff --git a/fs/fhandle.c b/fs/fhandle.c
4015     index 999ff5c3cab0..d59712dfa3e7 100644
4016     --- a/fs/fhandle.c
4017     +++ b/fs/fhandle.c
4018     @@ -195,8 +195,9 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
4019     goto out_err;
4020     }
4021     /* copy the full handle */
4022     - if (copy_from_user(handle, ufh,
4023     - sizeof(struct file_handle) +
4024     + *handle = f_handle;
4025     + if (copy_from_user(&handle->f_handle,
4026     + &ufh->f_handle,
4027     f_handle.handle_bytes)) {
4028     retval = -EFAULT;
4029     goto out_handle;
4030     diff --git a/fs/fs_pin.c b/fs/fs_pin.c
4031     index 9368236ca100..569bbd10e374 100644
4032     --- a/fs/fs_pin.c
4033     +++ b/fs/fs_pin.c
4034     @@ -20,8 +20,8 @@ void pin_put(struct fs_pin *p)
4035     void pin_remove(struct fs_pin *pin)
4036     {
4037     spin_lock(&pin_lock);
4038     - hlist_del(&pin->m_list);
4039     - hlist_del(&pin->s_list);
4040     + hlist_del_init(&pin->m_list);
4041     + hlist_del_init(&pin->s_list);
4042     spin_unlock(&pin_lock);
4043     }
4044    
4045     diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
4046     index bcbef08a4d8f..a5f72a36c6c8 100644
4047     --- a/fs/jbd2/recovery.c
4048     +++ b/fs/jbd2/recovery.c
4049     @@ -839,15 +839,23 @@ static int scan_revoke_records(journal_t *journal, struct buffer_head *bh,
4050     {
4051     jbd2_journal_revoke_header_t *header;
4052     int offset, max;
4053     + int csum_size = 0;
4054     + __u32 rcount;
4055     int record_len = 4;
4056    
4057     header = (jbd2_journal_revoke_header_t *) bh->b_data;
4058     offset = sizeof(jbd2_journal_revoke_header_t);
4059     - max = be32_to_cpu(header->r_count);
4060     + rcount = be32_to_cpu(header->r_count);
4061    
4062     if (!jbd2_revoke_block_csum_verify(journal, header))
4063     return -EINVAL;
4064    
4065     + if (jbd2_journal_has_csum_v2or3(journal))
4066     + csum_size = sizeof(struct jbd2_journal_revoke_tail);
4067     + if (rcount > journal->j_blocksize - csum_size)
4068     + return -EINVAL;
4069     + max = rcount;
4070     +
4071     if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
4072     record_len = 8;
4073    
4074     diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
4075     index c6cbaef2bda1..14214da80eb8 100644
4076     --- a/fs/jbd2/revoke.c
4077     +++ b/fs/jbd2/revoke.c
4078     @@ -577,7 +577,7 @@ static void write_one_revoke_record(journal_t *journal,
4079     {
4080     int csum_size = 0;
4081     struct buffer_head *descriptor;
4082     - int offset;
4083     + int sz, offset;
4084     journal_header_t *header;
4085    
4086     /* If we are already aborting, this all becomes a noop. We
4087     @@ -594,9 +594,14 @@ static void write_one_revoke_record(journal_t *journal,
4088     if (jbd2_journal_has_csum_v2or3(journal))
4089     csum_size = sizeof(struct jbd2_journal_revoke_tail);
4090    
4091     + if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
4092     + sz = 8;
4093     + else
4094     + sz = 4;
4095     +
4096     /* Make sure we have a descriptor with space left for the record */
4097     if (descriptor) {
4098     - if (offset >= journal->j_blocksize - csum_size) {
4099     + if (offset + sz > journal->j_blocksize - csum_size) {
4100     flush_descriptor(journal, descriptor, offset, write_op);
4101     descriptor = NULL;
4102     }
4103     @@ -619,16 +624,13 @@ static void write_one_revoke_record(journal_t *journal,
4104     *descriptorp = descriptor;
4105     }
4106    
4107     - if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT)) {
4108     + if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
4109     * ((__be64 *)(&descriptor->b_data[offset])) =
4110     cpu_to_be64(record->blocknr);
4111     - offset += 8;
4112     -
4113     - } else {
4114     + else
4115     * ((__be32 *)(&descriptor->b_data[offset])) =
4116     cpu_to_be32(record->blocknr);
4117     - offset += 4;
4118     - }
4119     + offset += sz;
4120    
4121     *offsetp = offset;
4122     }
4123     diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
4124     index 5f09370c90a8..ff2f2e6ad311 100644
4125     --- a/fs/jbd2/transaction.c
4126     +++ b/fs/jbd2/transaction.c
4127     @@ -551,7 +551,6 @@ int jbd2_journal_extend(handle_t *handle, int nblocks)
4128     int result;
4129     int wanted;
4130    
4131     - WARN_ON(!transaction);
4132     if (is_handle_aborted(handle))
4133     return -EROFS;
4134     journal = transaction->t_journal;
4135     @@ -627,7 +626,6 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask)
4136     tid_t tid;
4137     int need_to_start, ret;
4138    
4139     - WARN_ON(!transaction);
4140     /* If we've had an abort of any type, don't even think about
4141     * actually doing the restart! */
4142     if (is_handle_aborted(handle))
4143     @@ -785,7 +783,6 @@ do_get_write_access(handle_t *handle, struct journal_head *jh,
4144     int need_copy = 0;
4145     unsigned long start_lock, time_lock;
4146    
4147     - WARN_ON(!transaction);
4148     if (is_handle_aborted(handle))
4149     return -EROFS;
4150     journal = transaction->t_journal;
4151     @@ -1051,7 +1048,6 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
4152     int err;
4153    
4154     jbd_debug(5, "journal_head %p\n", jh);
4155     - WARN_ON(!transaction);
4156     err = -EROFS;
4157     if (is_handle_aborted(handle))
4158     goto out;
4159     @@ -1266,7 +1262,6 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
4160     struct journal_head *jh;
4161     int ret = 0;
4162    
4163     - WARN_ON(!transaction);
4164     if (is_handle_aborted(handle))
4165     return -EROFS;
4166     journal = transaction->t_journal;
4167     @@ -1397,7 +1392,6 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
4168     int err = 0;
4169     int was_modified = 0;
4170    
4171     - WARN_ON(!transaction);
4172     if (is_handle_aborted(handle))
4173     return -EROFS;
4174     journal = transaction->t_journal;
4175     @@ -1530,8 +1524,22 @@ int jbd2_journal_stop(handle_t *handle)
4176     tid_t tid;
4177     pid_t pid;
4178    
4179     - if (!transaction)
4180     - goto free_and_exit;
4181     + if (!transaction) {
4182     + /*
4183     + * Handle is already detached from the transaction so
4184     + * there is nothing to do other than decrease a refcount,
4185     + * or free the handle if refcount drops to zero
4186     + */
4187     + if (--handle->h_ref > 0) {
4188     + jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1,
4189     + handle->h_ref);
4190     + return err;
4191     + } else {
4192     + if (handle->h_rsv_handle)
4193     + jbd2_free_handle(handle->h_rsv_handle);
4194     + goto free_and_exit;
4195     + }
4196     + }
4197     journal = transaction->t_journal;
4198    
4199     J_ASSERT(journal_current_handle() == handle);
4200     @@ -2373,7 +2381,6 @@ int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode)
4201     transaction_t *transaction = handle->h_transaction;
4202     journal_t *journal;
4203    
4204     - WARN_ON(!transaction);
4205     if (is_handle_aborted(handle))
4206     return -EROFS;
4207     journal = transaction->t_journal;
4208     diff --git a/fs/namei.c b/fs/namei.c
4209     index 890d3580bf0e..d20f061cddd3 100644
4210     --- a/fs/namei.c
4211     +++ b/fs/namei.c
4212     @@ -3197,7 +3197,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
4213    
4214     if (unlikely(file->f_flags & __O_TMPFILE)) {
4215     error = do_tmpfile(dfd, pathname, nd, flags, op, file, &opened);
4216     - goto out;
4217     + goto out2;
4218     }
4219    
4220     error = path_init(dfd, pathname->name, flags | LOOKUP_PARENT, nd, &base);
4221     @@ -3235,6 +3235,7 @@ out:
4222     path_put(&nd->root);
4223     if (base)
4224     fput(base);
4225     +out2:
4226     if (!(opened & FILE_OPENED)) {
4227     BUG_ON(!error);
4228     put_filp(file);
4229     diff --git a/fs/namespace.c b/fs/namespace.c
4230     index 07ba424181a5..8b60287a488b 100644
4231     --- a/fs/namespace.c
4232     +++ b/fs/namespace.c
4233     @@ -1675,8 +1675,11 @@ struct vfsmount *collect_mounts(struct path *path)
4234     {
4235     struct mount *tree;
4236     namespace_lock();
4237     - tree = copy_tree(real_mount(path->mnt), path->dentry,
4238     - CL_COPY_ALL | CL_PRIVATE);
4239     + if (!check_mnt(real_mount(path->mnt)))
4240     + tree = ERR_PTR(-EINVAL);
4241     + else
4242     + tree = copy_tree(real_mount(path->mnt), path->dentry,
4243     + CL_COPY_ALL | CL_PRIVATE);
4244     namespace_unlock();
4245     if (IS_ERR(tree))
4246     return ERR_CAST(tree);
4247     @@ -3137,6 +3140,12 @@ bool fs_fully_visible(struct file_system_type *type)
4248     if (mnt->mnt.mnt_sb->s_type != type)
4249     continue;
4250    
4251     + /* This mount is not fully visible if it's root directory
4252     + * is not the root directory of the filesystem.
4253     + */
4254     + if (mnt->mnt.mnt_root != mnt->mnt.mnt_sb->s_root)
4255     + continue;
4256     +
4257     /* This mount is not fully visible if there are any child mounts
4258     * that cover anything except for empty directories.
4259     */
4260     diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
4261     index 4460d45ae138..58f98ad93828 100644
4262     --- a/fs/nfsd/nfs4state.c
4263     +++ b/fs/nfsd/nfs4state.c
4264     @@ -4385,10 +4385,17 @@ static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_s
4265     return nfserr_old_stateid;
4266     }
4267    
4268     +static __be32 nfsd4_check_openowner_confirmed(struct nfs4_ol_stateid *ols)
4269     +{
4270     + if (ols->st_stateowner->so_is_open_owner &&
4271     + !(openowner(ols->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED))
4272     + return nfserr_bad_stateid;
4273     + return nfs_ok;
4274     +}
4275     +
4276     static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid)
4277     {
4278     struct nfs4_stid *s;
4279     - struct nfs4_ol_stateid *ols;
4280     __be32 status = nfserr_bad_stateid;
4281    
4282     if (ZERO_STATEID(stateid) || ONE_STATEID(stateid))
4283     @@ -4418,13 +4425,7 @@ static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid)
4284     break;
4285     case NFS4_OPEN_STID:
4286     case NFS4_LOCK_STID:
4287     - ols = openlockstateid(s);
4288     - if (ols->st_stateowner->so_is_open_owner
4289     - && !(openowner(ols->st_stateowner)->oo_flags
4290     - & NFS4_OO_CONFIRMED))
4291     - status = nfserr_bad_stateid;
4292     - else
4293     - status = nfs_ok;
4294     + status = nfsd4_check_openowner_confirmed(openlockstateid(s));
4295     break;
4296     default:
4297     printk("unknown stateid type %x\n", s->sc_type);
4298     @@ -4516,8 +4517,8 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
4299     status = nfs4_check_fh(current_fh, stp);
4300     if (status)
4301     goto out;
4302     - if (stp->st_stateowner->so_is_open_owner
4303     - && !(openowner(stp->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED))
4304     + status = nfsd4_check_openowner_confirmed(stp);
4305     + if (status)
4306     goto out;
4307     status = nfs4_check_openmode(stp, flags);
4308     if (status)
4309     diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
4310     index ecdbae19a766..090d8ce25bd1 100644
4311     --- a/fs/nilfs2/btree.c
4312     +++ b/fs/nilfs2/btree.c
4313     @@ -388,7 +388,7 @@ static int nilfs_btree_root_broken(const struct nilfs_btree_node *node,
4314     nchildren = nilfs_btree_node_get_nchildren(node);
4315    
4316     if (unlikely(level < NILFS_BTREE_LEVEL_NODE_MIN ||
4317     - level > NILFS_BTREE_LEVEL_MAX ||
4318     + level >= NILFS_BTREE_LEVEL_MAX ||
4319     nchildren < 0 ||
4320     nchildren > NILFS_BTREE_ROOT_NCHILDREN_MAX)) {
4321     pr_crit("NILFS: bad btree root (inode number=%lu): level = %d, flags = 0x%x, nchildren = %d\n",
4322     diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
4323     index 215e41abf101..9ec1eea7c3a3 100644
4324     --- a/fs/ocfs2/dlm/dlmmaster.c
4325     +++ b/fs/ocfs2/dlm/dlmmaster.c
4326     @@ -765,6 +765,19 @@ lookup:
4327     if (tmpres) {
4328     spin_unlock(&dlm->spinlock);
4329     spin_lock(&tmpres->spinlock);
4330     +
4331     + /*
4332     + * Right after dlm spinlock was released, dlm_thread could have
4333     + * purged the lockres. Check if lockres got unhashed. If so
4334     + * start over.
4335     + */
4336     + if (hlist_unhashed(&tmpres->hash_node)) {
4337     + spin_unlock(&tmpres->spinlock);
4338     + dlm_lockres_put(tmpres);
4339     + tmpres = NULL;
4340     + goto lookup;
4341     + }
4342     +
4343     /* Wait on the thread that is mastering the resource */
4344     if (tmpres->owner == DLM_LOCK_RES_OWNER_UNKNOWN) {
4345     __dlm_wait_on_lockres(tmpres);
4346     diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
4347     index 138321b0c6c2..454111a3308e 100644
4348     --- a/fs/omfs/inode.c
4349     +++ b/fs/omfs/inode.c
4350     @@ -306,7 +306,8 @@ static const struct super_operations omfs_sops = {
4351     */
4352     static int omfs_get_imap(struct super_block *sb)
4353     {
4354     - unsigned int bitmap_size, count, array_size;
4355     + unsigned int bitmap_size, array_size;
4356     + int count;
4357     struct omfs_sb_info *sbi = OMFS_SB(sb);
4358     struct buffer_head *bh;
4359     unsigned long **ptr;
4360     @@ -359,7 +360,7 @@ nomem:
4361     }
4362    
4363     enum {
4364     - Opt_uid, Opt_gid, Opt_umask, Opt_dmask, Opt_fmask
4365     + Opt_uid, Opt_gid, Opt_umask, Opt_dmask, Opt_fmask, Opt_err
4366     };
4367    
4368     static const match_table_t tokens = {
4369     @@ -368,6 +369,7 @@ static const match_table_t tokens = {
4370     {Opt_umask, "umask=%o"},
4371     {Opt_dmask, "dmask=%o"},
4372     {Opt_fmask, "fmask=%o"},
4373     + {Opt_err, NULL},
4374     };
4375    
4376     static int parse_options(char *options, struct omfs_sb_info *sbi)
4377     diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
4378     index b1f73dbbf3d8..b7cd0a0541af 100644
4379     --- a/fs/xfs/libxfs/xfs_attr_leaf.c
4380     +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
4381     @@ -500,8 +500,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
4382     * After the last attribute is removed revert to original inode format,
4383     * making all literal area available to the data fork once more.
4384     */
4385     -STATIC void
4386     -xfs_attr_fork_reset(
4387     +void
4388     +xfs_attr_fork_remove(
4389     struct xfs_inode *ip,
4390     struct xfs_trans *tp)
4391     {
4392     @@ -567,7 +567,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
4393     (mp->m_flags & XFS_MOUNT_ATTR2) &&
4394     (dp->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
4395     !(args->op_flags & XFS_DA_OP_ADDNAME)) {
4396     - xfs_attr_fork_reset(dp, args->trans);
4397     + xfs_attr_fork_remove(dp, args->trans);
4398     } else {
4399     xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
4400     dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
4401     @@ -830,7 +830,7 @@ xfs_attr3_leaf_to_shortform(
4402     if (forkoff == -1) {
4403     ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2);
4404     ASSERT(dp->i_d.di_format != XFS_DINODE_FMT_BTREE);
4405     - xfs_attr_fork_reset(dp, args->trans);
4406     + xfs_attr_fork_remove(dp, args->trans);
4407     goto out;
4408     }
4409    
4410     diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h
4411     index e2929da7c3ba..4f3a60aa93d4 100644
4412     --- a/fs/xfs/libxfs/xfs_attr_leaf.h
4413     +++ b/fs/xfs/libxfs/xfs_attr_leaf.h
4414     @@ -53,7 +53,7 @@ int xfs_attr_shortform_remove(struct xfs_da_args *args);
4415     int xfs_attr_shortform_list(struct xfs_attr_list_context *context);
4416     int xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
4417     int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes);
4418     -
4419     +void xfs_attr_fork_remove(struct xfs_inode *ip, struct xfs_trans *tp);
4420    
4421     /*
4422     * Internal routines when attribute fork size == XFS_LBSIZE(mp).
4423     diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c
4424     index aa2a8b1838a2..0687b67741b7 100644
4425     --- a/fs/xfs/xfs_attr_inactive.c
4426     +++ b/fs/xfs/xfs_attr_inactive.c
4427     @@ -382,23 +382,31 @@ xfs_attr3_root_inactive(
4428     return error;
4429     }
4430    
4431     +/*
4432     + * xfs_attr_inactive kills all traces of an attribute fork on an inode. It
4433     + * removes both the on-disk and in-memory inode fork. Note that this also has to
4434     + * handle the condition of inodes without attributes but with an attribute fork
4435     + * configured, so we can't use xfs_inode_hasattr() here.
4436     + *
4437     + * The in-memory attribute fork is removed even on error.
4438     + */
4439     int
4440     -xfs_attr_inactive(xfs_inode_t *dp)
4441     +xfs_attr_inactive(
4442     + struct xfs_inode *dp)
4443     {
4444     - xfs_trans_t *trans;
4445     - xfs_mount_t *mp;
4446     - int error;
4447     + struct xfs_trans *trans;
4448     + struct xfs_mount *mp;
4449     + int cancel_flags = 0;
4450     + int lock_mode = XFS_ILOCK_SHARED;
4451     + int error = 0;
4452    
4453     mp = dp->i_mount;
4454     ASSERT(! XFS_NOT_DQATTACHED(mp, dp));
4455    
4456     - xfs_ilock(dp, XFS_ILOCK_SHARED);
4457     - if (!xfs_inode_hasattr(dp) ||
4458     - dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
4459     - xfs_iunlock(dp, XFS_ILOCK_SHARED);
4460     - return 0;
4461     - }
4462     - xfs_iunlock(dp, XFS_ILOCK_SHARED);
4463     + xfs_ilock(dp, lock_mode);
4464     + if (!XFS_IFORK_Q(dp))
4465     + goto out_destroy_fork;
4466     + xfs_iunlock(dp, lock_mode);
4467    
4468     /*
4469     * Start our first transaction of the day.
4470     @@ -410,13 +418,18 @@ xfs_attr_inactive(xfs_inode_t *dp)
4471     * the inode in every transaction to let it float upward through
4472     * the log.
4473     */
4474     + lock_mode = 0;
4475     trans = xfs_trans_alloc(mp, XFS_TRANS_ATTRINVAL);
4476     error = xfs_trans_reserve(trans, &M_RES(mp)->tr_attrinval, 0, 0);
4477     - if (error) {
4478     - xfs_trans_cancel(trans, 0);
4479     - return error;
4480     - }
4481     - xfs_ilock(dp, XFS_ILOCK_EXCL);
4482     + if (error)
4483     + goto out_cancel;
4484     +
4485     + lock_mode = XFS_ILOCK_EXCL;
4486     + cancel_flags = XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT;
4487     + xfs_ilock(dp, lock_mode);
4488     +
4489     + if (!XFS_IFORK_Q(dp))
4490     + goto out_cancel;
4491    
4492     /*
4493     * No need to make quota reservations here. We expect to release some
4494     @@ -424,29 +437,31 @@ xfs_attr_inactive(xfs_inode_t *dp)
4495     */
4496     xfs_trans_ijoin(trans, dp, 0);
4497    
4498     - /*
4499     - * Decide on what work routines to call based on the inode size.
4500     - */
4501     - if (!xfs_inode_hasattr(dp) ||
4502     - dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
4503     - error = 0;
4504     - goto out;
4505     + /* invalidate and truncate the attribute fork extents */
4506     + if (dp->i_d.di_aformat != XFS_DINODE_FMT_LOCAL) {
4507     + error = xfs_attr3_root_inactive(&trans, dp);
4508     + if (error)
4509     + goto out_cancel;
4510     +
4511     + error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK, 0);
4512     + if (error)
4513     + goto out_cancel;
4514     }
4515     - error = xfs_attr3_root_inactive(&trans, dp);
4516     - if (error)
4517     - goto out;
4518    
4519     - error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK, 0);
4520     - if (error)
4521     - goto out;
4522     + /* Reset the attribute fork - this also destroys the in-core fork */
4523     + xfs_attr_fork_remove(dp, trans);
4524    
4525     error = xfs_trans_commit(trans, XFS_TRANS_RELEASE_LOG_RES);
4526     - xfs_iunlock(dp, XFS_ILOCK_EXCL);
4527     -
4528     + xfs_iunlock(dp, lock_mode);
4529     return error;
4530    
4531     -out:
4532     - xfs_trans_cancel(trans, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
4533     - xfs_iunlock(dp, XFS_ILOCK_EXCL);
4534     +out_cancel:
4535     + xfs_trans_cancel(trans, cancel_flags);
4536     +out_destroy_fork:
4537     + /* kill the in-core attr fork before we drop the inode lock */
4538     + if (dp->i_afp)
4539     + xfs_idestroy_fork(dp, XFS_ATTR_FORK);
4540     + if (lock_mode)
4541     + xfs_iunlock(dp, lock_mode);
4542     return error;
4543     }
4544     diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
4545     index b28f0d680cb5..ba8b158a618a 100644
4546     --- a/fs/xfs/xfs_file.c
4547     +++ b/fs/xfs/xfs_file.c
4548     @@ -127,7 +127,7 @@ xfs_iozero(
4549     status = 0;
4550     } while (count);
4551    
4552     - return (-status);
4553     + return status;
4554     }
4555    
4556     /*
4557     diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
4558     index 3cc309a19ea8..32e95c76cbd0 100644
4559     --- a/fs/xfs/xfs_inode.c
4560     +++ b/fs/xfs/xfs_inode.c
4561     @@ -1894,21 +1894,17 @@ xfs_inactive(
4562     /*
4563     * If there are attributes associated with the file then blow them away
4564     * now. The code calls a routine that recursively deconstructs the
4565     - * attribute fork. We need to just commit the current transaction
4566     - * because we can't use it for xfs_attr_inactive().
4567     + * attribute fork. If also blows away the in-core attribute fork.
4568     */
4569     - if (ip->i_d.di_anextents > 0) {
4570     - ASSERT(ip->i_d.di_forkoff != 0);
4571     -
4572     + if (XFS_IFORK_Q(ip)) {
4573     error = xfs_attr_inactive(ip);
4574     if (error)
4575     return;
4576     }
4577    
4578     - if (ip->i_afp)
4579     - xfs_idestroy_fork(ip, XFS_ATTR_FORK);
4580     -
4581     + ASSERT(!ip->i_afp);
4582     ASSERT(ip->i_d.di_anextents == 0);
4583     + ASSERT(ip->i_d.di_forkoff == 0);
4584    
4585     /*
4586     * Free the inode.
4587     diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
4588     index ab2acf629a64..0747006ba2b0 100644
4589     --- a/include/acpi/acpixf.h
4590     +++ b/include/acpi/acpixf.h
4591     @@ -431,13 +431,13 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_status __init acpi_load_tables(void))
4592     ACPI_EXTERNAL_RETURN_STATUS(acpi_status __init acpi_reallocate_root_table(void))
4593    
4594     ACPI_EXTERNAL_RETURN_STATUS(acpi_status __init
4595     - acpi_find_root_pointer(acpi_size * rsdp_address))
4596     -
4597     + acpi_find_root_pointer(acpi_physical_address *
4598     + rsdp_address))
4599     ACPI_EXTERNAL_RETURN_STATUS(acpi_status
4600     - acpi_get_table_header(acpi_string signature,
4601     - u32 instance,
4602     - struct acpi_table_header
4603     - *out_table_header))
4604     + acpi_get_table_header(acpi_string signature,
4605     + u32 instance,
4606     + struct acpi_table_header
4607     + *out_table_header))
4608     ACPI_EXTERNAL_RETURN_STATUS(acpi_status
4609     acpi_get_table(acpi_string signature, u32 instance,
4610     struct acpi_table_header
4611     diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
4612     index 2dd405c9be78..45c39a37f924 100644
4613     --- a/include/drm/drm_pciids.h
4614     +++ b/include/drm/drm_pciids.h
4615     @@ -186,6 +186,7 @@
4616     {0x1002, 0x6658, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \
4617     {0x1002, 0x665c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \
4618     {0x1002, 0x665d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \
4619     + {0x1002, 0x665f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \
4620     {0x1002, 0x6660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
4621     {0x1002, 0x6663, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
4622     {0x1002, 0x6664, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
4623     diff --git a/include/linux/ktime.h b/include/linux/ktime.h
4624     index c9d645ad98ff..039bbe5f59df 100644
4625     --- a/include/linux/ktime.h
4626     +++ b/include/linux/ktime.h
4627     @@ -166,9 +166,34 @@ static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2)
4628     }
4629    
4630     #if BITS_PER_LONG < 64
4631     -extern u64 ktime_divns(const ktime_t kt, s64 div);
4632     +extern s64 __ktime_divns(const ktime_t kt, s64 div);
4633     +static inline s64 ktime_divns(const ktime_t kt, s64 div)
4634     +{
4635     + /*
4636     + * Negative divisors could cause an inf loop,
4637     + * so bug out here.
4638     + */
4639     + BUG_ON(div < 0);
4640     + if (__builtin_constant_p(div) && !(div >> 32)) {
4641     + s64 ns = kt.tv64;
4642     + u64 tmp = ns < 0 ? -ns : ns;
4643     +
4644     + do_div(tmp, div);
4645     + return ns < 0 ? -tmp : tmp;
4646     + } else {
4647     + return __ktime_divns(kt, div);
4648     + }
4649     +}
4650     #else /* BITS_PER_LONG < 64 */
4651     -# define ktime_divns(kt, div) (u64)((kt).tv64 / (div))
4652     +static inline s64 ktime_divns(const ktime_t kt, s64 div)
4653     +{
4654     + /*
4655     + * 32-bit implementation cannot handle negative divisors,
4656     + * so catch them on 64bit as well.
4657     + */
4658     + WARN_ON(div < 0);
4659     + return kt.tv64 / div;
4660     +}
4661     #endif
4662    
4663     static inline s64 ktime_to_us(const ktime_t kt)
4664     diff --git a/include/linux/libata.h b/include/linux/libata.h
4665     index fe0bf8dc83bb..b3a816f4c0c4 100644
4666     --- a/include/linux/libata.h
4667     +++ b/include/linux/libata.h
4668     @@ -204,6 +204,7 @@ enum {
4669     ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */
4670     ATA_LFLAG_NO_LPM = (1 << 8), /* disable LPM on this link */
4671     ATA_LFLAG_RST_ONCE = (1 << 9), /* limit recovery to one reset */
4672     + ATA_LFLAG_CHANGED = (1 << 10), /* LPM state changed on this link */
4673    
4674     /* struct ata_port flags */
4675     ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */
4676     @@ -308,6 +309,12 @@ enum {
4677     */
4678     ATA_TMOUT_PMP_SRST_WAIT = 5000,
4679    
4680     + /* When the LPM policy is set to ATA_LPM_MAX_POWER, there might
4681     + * be a spurious PHY event, so ignore the first PHY event that
4682     + * occurs within 10s after the policy change.
4683     + */
4684     + ATA_TMOUT_SPURIOUS_PHY = 10000,
4685     +
4686     /* ATA bus states */
4687     BUS_UNKNOWN = 0,
4688     BUS_DMA = 1,
4689     @@ -786,6 +793,8 @@ struct ata_link {
4690     struct ata_eh_context eh_context;
4691    
4692     struct ata_device device[ATA_MAX_DEVICES];
4693     +
4694     + unsigned long last_lpm_change; /* when last LPM change happened */
4695     };
4696     #define ATA_LINK_CLEAR_BEGIN offsetof(struct ata_link, active_tag)
4697     #define ATA_LINK_CLEAR_END offsetof(struct ata_link, device[0])
4698     @@ -1199,6 +1208,7 @@ extern struct ata_device *ata_dev_pair(struct ata_device *adev);
4699     extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
4700     extern void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap);
4701     extern void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, struct list_head *eh_q);
4702     +extern bool sata_lpm_ignore_phy_events(struct ata_link *link);
4703    
4704     extern int ata_cable_40wire(struct ata_port *ap);
4705     extern int ata_cable_80wire(struct ata_port *ap);
4706     diff --git a/include/linux/nilfs2_fs.h b/include/linux/nilfs2_fs.h
4707     index ff3fea3194c6..9abb763e4b86 100644
4708     --- a/include/linux/nilfs2_fs.h
4709     +++ b/include/linux/nilfs2_fs.h
4710     @@ -460,7 +460,7 @@ struct nilfs_btree_node {
4711     /* level */
4712     #define NILFS_BTREE_LEVEL_DATA 0
4713     #define NILFS_BTREE_LEVEL_NODE_MIN (NILFS_BTREE_LEVEL_DATA + 1)
4714     -#define NILFS_BTREE_LEVEL_MAX 14
4715     +#define NILFS_BTREE_LEVEL_MAX 14 /* Max level (exclusive) */
4716    
4717     /**
4718     * struct nilfs_palloc_group_desc - block group descriptor
4719     diff --git a/include/linux/sched/rt.h b/include/linux/sched/rt.h
4720     index 6341f5be6e24..a30b172df6e1 100644
4721     --- a/include/linux/sched/rt.h
4722     +++ b/include/linux/sched/rt.h
4723     @@ -18,7 +18,7 @@ static inline int rt_task(struct task_struct *p)
4724     #ifdef CONFIG_RT_MUTEXES
4725     extern int rt_mutex_getprio(struct task_struct *p);
4726     extern void rt_mutex_setprio(struct task_struct *p, int prio);
4727     -extern int rt_mutex_check_prio(struct task_struct *task, int newprio);
4728     +extern int rt_mutex_get_effective_prio(struct task_struct *task, int newprio);
4729     extern struct task_struct *rt_mutex_get_top_task(struct task_struct *task);
4730     extern void rt_mutex_adjust_pi(struct task_struct *p);
4731     static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
4732     @@ -31,9 +31,10 @@ static inline int rt_mutex_getprio(struct task_struct *p)
4733     return p->normal_prio;
4734     }
4735    
4736     -static inline int rt_mutex_check_prio(struct task_struct *task, int newprio)
4737     +static inline int rt_mutex_get_effective_prio(struct task_struct *task,
4738     + int newprio)
4739     {
4740     - return 0;
4741     + return newprio;
4742     }
4743    
4744     static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *task)
4745     diff --git a/include/net/dst.h b/include/net/dst.h
4746     index a8ae4e760778..0fb99a26e973 100644
4747     --- a/include/net/dst.h
4748     +++ b/include/net/dst.h
4749     @@ -481,6 +481,7 @@ void dst_init(void);
4750     enum {
4751     XFRM_LOOKUP_ICMP = 1 << 0,
4752     XFRM_LOOKUP_QUEUE = 1 << 1,
4753     + XFRM_LOOKUP_KEEP_DST_REF = 1 << 2,
4754     };
4755    
4756     struct flowi;
4757     diff --git a/include/xen/events.h b/include/xen/events.h
4758     index 5321cd9636e6..7d95fdf9cf3e 100644
4759     --- a/include/xen/events.h
4760     +++ b/include/xen/events.h
4761     @@ -17,7 +17,7 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn,
4762     irq_handler_t handler,
4763     unsigned long irqflags, const char *devname,
4764     void *dev_id);
4765     -int bind_virq_to_irq(unsigned int virq, unsigned int cpu);
4766     +int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu);
4767     int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu,
4768     irq_handler_t handler,
4769     unsigned long irqflags, const char *devname,
4770     diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
4771     index 41d53e515914..1929ee2291f2 100644
4772     --- a/kernel/locking/rtmutex.c
4773     +++ b/kernel/locking/rtmutex.c
4774     @@ -265,15 +265,17 @@ struct task_struct *rt_mutex_get_top_task(struct task_struct *task)
4775     }
4776    
4777     /*
4778     - * Called by sched_setscheduler() to check whether the priority change
4779     - * is overruled by a possible priority boosting.
4780     + * Called by sched_setscheduler() to get the priority which will be
4781     + * effective after the change.
4782     */
4783     -int rt_mutex_check_prio(struct task_struct *task, int newprio)
4784     +int rt_mutex_get_effective_prio(struct task_struct *task, int newprio)
4785     {
4786     if (!task_has_pi_waiters(task))
4787     - return 0;
4788     + return newprio;
4789    
4790     - return task_top_pi_waiter(task)->task->prio <= newprio;
4791     + if (task_top_pi_waiter(task)->task->prio <= newprio)
4792     + return task_top_pi_waiter(task)->task->prio;
4793     + return newprio;
4794     }
4795    
4796     /*
4797     diff --git a/kernel/module.c b/kernel/module.c
4798     index 88cec1ddb1e3..c353707bbbd5 100644
4799     --- a/kernel/module.c
4800     +++ b/kernel/module.c
4801     @@ -3307,6 +3307,9 @@ static int load_module(struct load_info *info, const char __user *uargs,
4802     module_bug_cleanup(mod);
4803     mutex_unlock(&module_mutex);
4804    
4805     + blocking_notifier_call_chain(&module_notify_list,
4806     + MODULE_STATE_GOING, mod);
4807     +
4808     /* we can't deallocate the module until we clear memory protection */
4809     unset_module_init_ro_nx(mod);
4810     unset_module_core_ro_nx(mod);
4811     diff --git a/kernel/sched/core.c b/kernel/sched/core.c
4812     index b794bde3f5e1..6810e572eda5 100644
4813     --- a/kernel/sched/core.c
4814     +++ b/kernel/sched/core.c
4815     @@ -3327,15 +3327,18 @@ static void __setscheduler_params(struct task_struct *p,
4816    
4817     /* Actually do priority change: must hold pi & rq lock. */
4818     static void __setscheduler(struct rq *rq, struct task_struct *p,
4819     - const struct sched_attr *attr)
4820     + const struct sched_attr *attr, bool keep_boost)
4821     {
4822     __setscheduler_params(p, attr);
4823    
4824     /*
4825     - * If we get here, there was no pi waiters boosting the
4826     - * task. It is safe to use the normal prio.
4827     + * Keep a potential priority boosting if called from
4828     + * sched_setscheduler().
4829     */
4830     - p->prio = normal_prio(p);
4831     + if (keep_boost)
4832     + p->prio = rt_mutex_get_effective_prio(p, normal_prio(p));
4833     + else
4834     + p->prio = normal_prio(p);
4835    
4836     if (dl_prio(p->prio))
4837     p->sched_class = &dl_sched_class;
4838     @@ -3421,7 +3424,7 @@ static int __sched_setscheduler(struct task_struct *p,
4839     int newprio = dl_policy(attr->sched_policy) ? MAX_DL_PRIO - 1 :
4840     MAX_RT_PRIO - 1 - attr->sched_priority;
4841     int retval, oldprio, oldpolicy = -1, queued, running;
4842     - int policy = attr->sched_policy;
4843     + int new_effective_prio, policy = attr->sched_policy;
4844     unsigned long flags;
4845     const struct sched_class *prev_class;
4846     struct rq *rq;
4847     @@ -3603,15 +3606,14 @@ change:
4848     oldprio = p->prio;
4849    
4850     /*
4851     - * Special case for priority boosted tasks.
4852     - *
4853     - * If the new priority is lower or equal (user space view)
4854     - * than the current (boosted) priority, we just store the new
4855     + * Take priority boosted tasks into account. If the new
4856     + * effective priority is unchanged, we just store the new
4857     * normal parameters and do not touch the scheduler class and
4858     * the runqueue. This will be done when the task deboost
4859     * itself.
4860     */
4861     - if (rt_mutex_check_prio(p, newprio)) {
4862     + new_effective_prio = rt_mutex_get_effective_prio(p, newprio);
4863     + if (new_effective_prio == oldprio) {
4864     __setscheduler_params(p, attr);
4865     task_rq_unlock(rq, p, &flags);
4866     return 0;
4867     @@ -3625,7 +3627,7 @@ change:
4868     put_prev_task(rq, p);
4869    
4870     prev_class = p->sched_class;
4871     - __setscheduler(rq, p, attr);
4872     + __setscheduler(rq, p, attr, true);
4873    
4874     if (running)
4875     p->sched_class->set_curr_task(rq);
4876     @@ -7237,7 +7239,7 @@ static void normalize_task(struct rq *rq, struct task_struct *p)
4877     queued = task_on_rq_queued(p);
4878     if (queued)
4879     dequeue_task(rq, p, 0);
4880     - __setscheduler(rq, p, &attr);
4881     + __setscheduler(rq, p, &attr, false);
4882     if (queued) {
4883     enqueue_task(rq, p, 0);
4884     resched_curr(rq);
4885     diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
4886     index d8c724cda37b..210b84882935 100644
4887     --- a/kernel/time/hrtimer.c
4888     +++ b/kernel/time/hrtimer.c
4889     @@ -266,23 +266,25 @@ lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
4890     /*
4891     * Divide a ktime value by a nanosecond value
4892     */
4893     -u64 ktime_divns(const ktime_t kt, s64 div)
4894     +s64 __ktime_divns(const ktime_t kt, s64 div)
4895     {
4896     - u64 dclc;
4897     int sft = 0;
4898     + s64 dclc;
4899     + u64 tmp;
4900    
4901     dclc = ktime_to_ns(kt);
4902     + tmp = dclc < 0 ? -dclc : dclc;
4903     +
4904     /* Make sure the divisor is less than 2^32: */
4905     while (div >> 32) {
4906     sft++;
4907     div >>= 1;
4908     }
4909     - dclc >>= sft;
4910     - do_div(dclc, (unsigned long) div);
4911     -
4912     - return dclc;
4913     + tmp >>= sft;
4914     + do_div(tmp, (unsigned long) div);
4915     + return dclc < 0 ? -tmp : tmp;
4916     }
4917     -EXPORT_SYMBOL_GPL(ktime_divns);
4918     +EXPORT_SYMBOL_GPL(__ktime_divns);
4919     #endif /* BITS_PER_LONG >= 64 */
4920    
4921     /*
4922     diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
4923     index a28df5206d95..11649615c505 100644
4924     --- a/lib/strnlen_user.c
4925     +++ b/lib/strnlen_user.c
4926     @@ -57,7 +57,8 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count,
4927     return res + find_zero(data) + 1 - align;
4928     }
4929     res += sizeof(unsigned long);
4930     - if (unlikely(max < sizeof(unsigned long)))
4931     + /* We already handled 'unsigned long' bytes. Did we do it all ? */
4932     + if (unlikely(max <= sizeof(unsigned long)))
4933     break;
4934     max -= sizeof(unsigned long);
4935     if (unlikely(__get_user(c,(unsigned long __user *)(src+res))))
4936     diff --git a/mm/memory-failure.c b/mm/memory-failure.c
4937     index 3415e7ad3973..22f047fbaa33 100644
4938     --- a/mm/memory-failure.c
4939     +++ b/mm/memory-failure.c
4940     @@ -1153,10 +1153,10 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
4941     * The check (unnecessarily) ignores LRU pages being isolated and
4942     * walked by the page reclaim code, however that's not a big loss.
4943     */
4944     - if (!PageHuge(p) && !PageTransTail(p)) {
4945     - if (!PageLRU(p))
4946     - shake_page(p, 0);
4947     - if (!PageLRU(p)) {
4948     + if (!PageHuge(p)) {
4949     + if (!PageLRU(hpage))
4950     + shake_page(hpage, 0);
4951     + if (!PageLRU(hpage)) {
4952     /*
4953     * shake_page could have turned it free.
4954     */
4955     @@ -1733,12 +1733,12 @@ int soft_offline_page(struct page *page, int flags)
4956     } else if (ret == 0) { /* for free pages */
4957     if (PageHuge(page)) {
4958     set_page_hwpoison_huge_page(hpage);
4959     - dequeue_hwpoisoned_huge_page(hpage);
4960     - atomic_long_add(1 << compound_order(hpage),
4961     + if (!dequeue_hwpoisoned_huge_page(hpage))
4962     + atomic_long_add(1 << compound_order(hpage),
4963     &num_poisoned_pages);
4964     } else {
4965     - SetPageHWPoison(page);
4966     - atomic_long_inc(&num_poisoned_pages);
4967     + if (!TestSetPageHWPoison(page))
4968     + atomic_long_inc(&num_poisoned_pages);
4969     }
4970     }
4971     unset_migratetype_isolate(page, MIGRATE_MOVABLE);
4972     diff --git a/mm/mempolicy.c b/mm/mempolicy.c
4973     index e58725aff7e9..39198cb78c6f 100644
4974     --- a/mm/mempolicy.c
4975     +++ b/mm/mempolicy.c
4976     @@ -2548,7 +2548,7 @@ static void __init check_numabalancing_enable(void)
4977     if (numabalancing_override)
4978     set_numabalancing_state(numabalancing_override == 1);
4979    
4980     - if (nr_node_ids > 1 && !numabalancing_override) {
4981     + if (num_online_nodes() > 1 && !numabalancing_override) {
4982     pr_info("%s automatic NUMA balancing. "
4983     "Configure with numa_balancing= or the "
4984     "kernel.numa_balancing sysctl",
4985     diff --git a/mm/page-writeback.c b/mm/page-writeback.c
4986     index c8abd208432d..b9aaa16dcf85 100644
4987     --- a/mm/page-writeback.c
4988     +++ b/mm/page-writeback.c
4989     @@ -580,7 +580,7 @@ static long long pos_ratio_polynom(unsigned long setpoint,
4990     long x;
4991    
4992     x = div64_s64(((s64)setpoint - (s64)dirty) << RATELIMIT_CALC_SHIFT,
4993     - limit - setpoint + 1);
4994     + (limit - setpoint) | 1);
4995     pos_ratio = x;
4996     pos_ratio = pos_ratio * x >> RATELIMIT_CALC_SHIFT;
4997     pos_ratio = pos_ratio * x >> RATELIMIT_CALC_SHIFT;
4998     @@ -807,7 +807,7 @@ static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
4999     * scale global setpoint to bdi's:
5000     * bdi_setpoint = setpoint * bdi_thresh / thresh
5001     */
5002     - x = div_u64((u64)bdi_thresh << 16, thresh + 1);
5003     + x = div_u64((u64)bdi_thresh << 16, thresh | 1);
5004     bdi_setpoint = setpoint * (u64)x >> 16;
5005     /*
5006     * Use span=(8*write_bw) in single bdi case as indicated by
5007     @@ -822,7 +822,7 @@ static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
5008    
5009     if (bdi_dirty < x_intercept - span / 4) {
5010     pos_ratio = div64_u64(pos_ratio * (x_intercept - bdi_dirty),
5011     - x_intercept - bdi_setpoint + 1);
5012     + (x_intercept - bdi_setpoint) | 1);
5013     } else
5014     pos_ratio /= 4;
5015    
5016     diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
5017     index b0cf1f287aed..e242f96550bd 100644
5018     --- a/net/ceph/osd_client.c
5019     +++ b/net/ceph/osd_client.c
5020     @@ -1263,8 +1263,6 @@ static void __unregister_linger_request(struct ceph_osd_client *osdc,
5021     if (list_empty(&req->r_osd_item))
5022     req->r_osd = NULL;
5023     }
5024     -
5025     - list_del_init(&req->r_req_lru_item); /* can be on notarget */
5026     ceph_osdc_put_request(req);
5027     }
5028    
5029     @@ -1974,20 +1972,29 @@ static void kick_requests(struct ceph_osd_client *osdc, bool force_resend,
5030     err = __map_request(osdc, req,
5031     force_resend || force_resend_writes);
5032     dout("__map_request returned %d\n", err);
5033     - if (err == 0)
5034     - continue; /* no change and no osd was specified */
5035     if (err < 0)
5036     continue; /* hrm! */
5037     - if (req->r_osd == NULL) {
5038     - dout("tid %llu maps to no valid osd\n", req->r_tid);
5039     - needmap++; /* request a newer map */
5040     - continue;
5041     - }
5042     + if (req->r_osd == NULL || err > 0) {
5043     + if (req->r_osd == NULL) {
5044     + dout("lingering %p tid %llu maps to no osd\n",
5045     + req, req->r_tid);
5046     + /*
5047     + * A homeless lingering request makes
5048     + * no sense, as it's job is to keep
5049     + * a particular OSD connection open.
5050     + * Request a newer map and kick the
5051     + * request, knowing that it won't be
5052     + * resent until we actually get a map
5053     + * that can tell us where to send it.
5054     + */
5055     + needmap++;
5056     + }
5057    
5058     - dout("kicking lingering %p tid %llu osd%d\n", req, req->r_tid,
5059     - req->r_osd ? req->r_osd->o_osd : -1);
5060     - __register_request(osdc, req);
5061     - __unregister_linger_request(osdc, req);
5062     + dout("kicking lingering %p tid %llu osd%d\n", req,
5063     + req->r_tid, req->r_osd ? req->r_osd->o_osd : -1);
5064     + __register_request(osdc, req);
5065     + __unregister_linger_request(osdc, req);
5066     + }
5067     }
5068     reset_changed_osds(osdc);
5069     mutex_unlock(&osdc->request_mutex);
5070     diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
5071     index 91c1aca65ae9..aed656d18b23 100644
5072     --- a/net/mac80211/ieee80211_i.h
5073     +++ b/net/mac80211/ieee80211_i.h
5074     @@ -204,6 +204,8 @@ enum ieee80211_packet_rx_flags {
5075     * @IEEE80211_RX_CMNTR: received on cooked monitor already
5076     * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
5077     * to cfg80211_report_obss_beacon().
5078     + * @IEEE80211_RX_REORDER_TIMER: this frame is released by the
5079     + * reorder buffer timeout timer, not the normal RX path
5080     *
5081     * These flags are used across handling multiple interfaces
5082     * for a single frame.
5083     @@ -211,6 +213,7 @@ enum ieee80211_packet_rx_flags {
5084     enum ieee80211_rx_flags {
5085     IEEE80211_RX_CMNTR = BIT(0),
5086     IEEE80211_RX_BEACON_REPORTED = BIT(1),
5087     + IEEE80211_RX_REORDER_TIMER = BIT(2),
5088     };
5089    
5090     struct ieee80211_rx_data {
5091     diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
5092     index 631d59f540d1..a578c5717112 100644
5093     --- a/net/mac80211/rx.c
5094     +++ b/net/mac80211/rx.c
5095     @@ -2000,7 +2000,8 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
5096     /* deliver to local stack */
5097     skb->protocol = eth_type_trans(skb, dev);
5098     memset(skb->cb, 0, sizeof(skb->cb));
5099     - if (rx->local->napi)
5100     + if (!(rx->flags & IEEE80211_RX_REORDER_TIMER) &&
5101     + rx->local->napi)
5102     napi_gro_receive(rx->local->napi, skb);
5103     else
5104     netif_receive_skb(skb);
5105     @@ -3070,7 +3071,7 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid)
5106     /* This is OK -- must be QoS data frame */
5107     .security_idx = tid,
5108     .seqno_idx = tid,
5109     - .flags = 0,
5110     + .flags = IEEE80211_RX_REORDER_TIMER,
5111     };
5112     struct tid_ampdu_rx *tid_agg_rx;
5113    
5114     diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
5115     index 9181fb6d6437..837b7b1bb310 100644
5116     --- a/net/mac80211/wep.c
5117     +++ b/net/mac80211/wep.c
5118     @@ -98,8 +98,7 @@ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local,
5119    
5120     hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
5121    
5122     - if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN ||
5123     - skb_headroom(skb) < IEEE80211_WEP_IV_LEN))
5124     + if (WARN_ON(skb_headroom(skb) < IEEE80211_WEP_IV_LEN))
5125     return NULL;
5126    
5127     hdrlen = ieee80211_hdrlen(hdr->frame_control);
5128     @@ -169,6 +168,9 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local,
5129     size_t len;
5130     u8 rc4key[3 + WLAN_KEY_LEN_WEP104];
5131    
5132     + if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN))
5133     + return -1;
5134     +
5135     iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx);
5136     if (!iv)
5137     return -1;
5138     diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.c b/net/sunrpc/auth_gss/gss_rpc_xdr.c
5139     index 1ec19f6f0c2b..eeeba5adee6d 100644
5140     --- a/net/sunrpc/auth_gss/gss_rpc_xdr.c
5141     +++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c
5142     @@ -793,20 +793,26 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp,
5143     {
5144     u32 value_follows;
5145     int err;
5146     + struct page *scratch;
5147     +
5148     + scratch = alloc_page(GFP_KERNEL);
5149     + if (!scratch)
5150     + return -ENOMEM;
5151     + xdr_set_scratch_buffer(xdr, page_address(scratch), PAGE_SIZE);
5152    
5153     /* res->status */
5154     err = gssx_dec_status(xdr, &res->status);
5155     if (err)
5156     - return err;
5157     + goto out_free;
5158    
5159     /* res->context_handle */
5160     err = gssx_dec_bool(xdr, &value_follows);
5161     if (err)
5162     - return err;
5163     + goto out_free;
5164     if (value_follows) {
5165     err = gssx_dec_ctx(xdr, res->context_handle);
5166     if (err)
5167     - return err;
5168     + goto out_free;
5169     } else {
5170     res->context_handle = NULL;
5171     }
5172     @@ -814,11 +820,11 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp,
5173     /* res->output_token */
5174     err = gssx_dec_bool(xdr, &value_follows);
5175     if (err)
5176     - return err;
5177     + goto out_free;
5178     if (value_follows) {
5179     err = gssx_dec_buffer(xdr, res->output_token);
5180     if (err)
5181     - return err;
5182     + goto out_free;
5183     } else {
5184     res->output_token = NULL;
5185     }
5186     @@ -826,14 +832,17 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp,
5187     /* res->delegated_cred_handle */
5188     err = gssx_dec_bool(xdr, &value_follows);
5189     if (err)
5190     - return err;
5191     + goto out_free;
5192     if (value_follows) {
5193     /* we do not support upcall servers sending this data. */
5194     - return -EINVAL;
5195     + err = -EINVAL;
5196     + goto out_free;
5197     }
5198    
5199     /* res->options */
5200     err = gssx_dec_option_array(xdr, &res->options);
5201    
5202     +out_free:
5203     + __free_page(scratch);
5204     return err;
5205     }
5206     diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
5207     index 88bf289abdc9..f62fd2c5d836 100644
5208     --- a/net/xfrm/xfrm_policy.c
5209     +++ b/net/xfrm/xfrm_policy.c
5210     @@ -2264,11 +2264,9 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
5211     * have the xfrm_state's. We need to wait for KM to
5212     * negotiate new SA's or bail out with error.*/
5213     if (net->xfrm.sysctl_larval_drop) {
5214     - dst_release(dst);
5215     - xfrm_pols_put(pols, drop_pols);
5216     XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTNOSTATES);
5217     -
5218     - return ERR_PTR(-EREMOTE);
5219     + err = -EREMOTE;
5220     + goto error;
5221     }
5222    
5223     err = -EAGAIN;
5224     @@ -2319,7 +2317,8 @@ nopol:
5225     error:
5226     dst_release(dst);
5227     dropdst:
5228     - dst_release(dst_orig);
5229     + if (!(flags & XFRM_LOOKUP_KEEP_DST_REF))
5230     + dst_release(dst_orig);
5231     xfrm_pols_put(pols, drop_pols);
5232     return ERR_PTR(err);
5233     }
5234     @@ -2333,7 +2332,8 @@ struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,
5235     struct sock *sk, int flags)
5236     {
5237     struct dst_entry *dst = xfrm_lookup(net, dst_orig, fl, sk,
5238     - flags | XFRM_LOOKUP_QUEUE);
5239     + flags | XFRM_LOOKUP_QUEUE |
5240     + XFRM_LOOKUP_KEEP_DST_REF);
5241    
5242     if (IS_ERR(dst) && PTR_ERR(dst) == -EREMOTE)
5243     return make_blackhole(net, dst_orig->ops->family, dst_orig);
5244     diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c
5245     index c0eea1dfe90f..f19da4b47c1d 100644
5246     --- a/sound/oss/sequencer.c
5247     +++ b/sound/oss/sequencer.c
5248     @@ -681,13 +681,8 @@ static int seq_timing_event(unsigned char *event_rec)
5249     break;
5250    
5251     case TMR_ECHO:
5252     - if (seq_mode == SEQ_2)
5253     - seq_copy_to_input(event_rec, 8);
5254     - else
5255     - {
5256     - parm = (parm << 8 | SEQ_ECHO);
5257     - seq_copy_to_input((unsigned char *) &parm, 4);
5258     - }
5259     + parm = (parm << 8 | SEQ_ECHO);
5260     + seq_copy_to_input((unsigned char *) &parm, 4);
5261     break;
5262    
5263     default:;
5264     @@ -1324,7 +1319,6 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, void __user *a
5265     int mode = translate_mode(file);
5266     struct synth_info inf;
5267     struct seq_event_rec event_rec;
5268     - unsigned long flags;
5269     int __user *p = arg;
5270    
5271     orig_dev = dev = dev >> 4;
5272     @@ -1479,9 +1473,7 @@ int sequencer_ioctl(int dev, struct file *file, unsigned int cmd, void __user *a
5273     case SNDCTL_SEQ_OUTOFBAND:
5274     if (copy_from_user(&event_rec, arg, sizeof(event_rec)))
5275     return -EFAULT;
5276     - spin_lock_irqsave(&lock,flags);
5277     play_event(event_rec.arr);
5278     - spin_unlock_irqrestore(&lock,flags);
5279     return 0;
5280    
5281     case SNDCTL_MIDI_INFO:
5282     diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
5283     index 8413797ba38d..ddfc8a891db4 100644
5284     --- a/sound/pci/hda/hda_intel.c
5285     +++ b/sound/pci/hda/hda_intel.c
5286     @@ -272,43 +272,52 @@ enum {
5287     AZX_NUM_DRIVERS, /* keep this as last entry */
5288     };
5289    
5290     +#define azx_get_snoop_type(chip) \
5291     + (((chip)->driver_caps & AZX_DCAPS_SNOOP_MASK) >> 10)
5292     +#define AZX_DCAPS_SNOOP_TYPE(type) ((AZX_SNOOP_TYPE_ ## type) << 10)
5293     +
5294     /* quirks for Intel PCH */
5295     #define AZX_DCAPS_INTEL_PCH_NOPM \
5296     - (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_BUFSIZE | \
5297     - AZX_DCAPS_COUNT_LPIB_DELAY | AZX_DCAPS_REVERSE_ASSIGN)
5298     + (AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY |\
5299     + AZX_DCAPS_REVERSE_ASSIGN | AZX_DCAPS_SNOOP_TYPE(SCH))
5300    
5301     #define AZX_DCAPS_INTEL_PCH \
5302     (AZX_DCAPS_INTEL_PCH_NOPM | AZX_DCAPS_PM_RUNTIME)
5303    
5304     #define AZX_DCAPS_INTEL_HASWELL \
5305     - (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_ALIGN_BUFSIZE | \
5306     - AZX_DCAPS_COUNT_LPIB_DELAY | AZX_DCAPS_PM_RUNTIME | \
5307     - AZX_DCAPS_I915_POWERWELL)
5308     + (AZX_DCAPS_ALIGN_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY |\
5309     + AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_POWERWELL |\
5310     + AZX_DCAPS_SNOOP_TYPE(SCH))
5311    
5312     /* Broadwell HDMI can't use position buffer reliably, force to use LPIB */
5313     #define AZX_DCAPS_INTEL_BROADWELL \
5314     - (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_ALIGN_BUFSIZE | \
5315     - AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_PM_RUNTIME | \
5316     - AZX_DCAPS_I915_POWERWELL)
5317     + (AZX_DCAPS_ALIGN_BUFSIZE | AZX_DCAPS_POSFIX_LPIB |\
5318     + AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_POWERWELL |\
5319     + AZX_DCAPS_SNOOP_TYPE(SCH))
5320    
5321     /* quirks for ATI SB / AMD Hudson */
5322     #define AZX_DCAPS_PRESET_ATI_SB \
5323     - (AZX_DCAPS_ATI_SNOOP | AZX_DCAPS_NO_TCSEL | \
5324     - AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB)
5325     + (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB |\
5326     + AZX_DCAPS_SNOOP_TYPE(ATI))
5327    
5328     /* quirks for ATI/AMD HDMI */
5329     #define AZX_DCAPS_PRESET_ATI_HDMI \
5330     (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB|\
5331     AZX_DCAPS_NO_MSI64)
5332    
5333     +/* quirks for ATI HDMI with snoop off */
5334     +#define AZX_DCAPS_PRESET_ATI_HDMI_NS \
5335     + (AZX_DCAPS_PRESET_ATI_HDMI | AZX_DCAPS_SNOOP_OFF)
5336     +
5337     /* quirks for Nvidia */
5338     #define AZX_DCAPS_PRESET_NVIDIA \
5339     - (AZX_DCAPS_NVIDIA_SNOOP | AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI |\
5340     - AZX_DCAPS_ALIGN_BUFSIZE | AZX_DCAPS_NO_64BIT |\
5341     - AZX_DCAPS_CORBRP_SELF_CLEAR)
5342     + (AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI | AZX_DCAPS_ALIGN_BUFSIZE |\
5343     + AZX_DCAPS_NO_64BIT | AZX_DCAPS_CORBRP_SELF_CLEAR |\
5344     + AZX_DCAPS_SNOOP_TYPE(NVIDIA))
5345    
5346     #define AZX_DCAPS_PRESET_CTHDA \
5347     - (AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY)
5348     + (AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB |\
5349     + AZX_DCAPS_4K_BDLE_BOUNDARY | AZX_DCAPS_SNOOP_OFF)
5350    
5351     /*
5352     * VGA-switcher support
5353     @@ -437,6 +446,8 @@ static void update_pci_byte(struct pci_dev *pci, unsigned int reg,
5354    
5355     static void azx_init_pci(struct azx *chip)
5356     {
5357     + int snoop_type = azx_get_snoop_type(chip);
5358     +
5359     /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
5360     * TCSEL == Traffic Class Select Register, which sets PCI express QOS
5361     * Ensuring these bits are 0 clears playback static on some HD Audio
5362     @@ -451,7 +462,7 @@ static void azx_init_pci(struct azx *chip)
5363     /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio,
5364     * we need to enable snoop.
5365     */
5366     - if (chip->driver_caps & AZX_DCAPS_ATI_SNOOP) {
5367     + if (snoop_type == AZX_SNOOP_TYPE_ATI) {
5368     dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n",
5369     azx_snoop(chip));
5370     update_pci_byte(chip->pci,
5371     @@ -460,7 +471,7 @@ static void azx_init_pci(struct azx *chip)
5372     }
5373    
5374     /* For NVIDIA HDA, enable snoop */
5375     - if (chip->driver_caps & AZX_DCAPS_NVIDIA_SNOOP) {
5376     + if (snoop_type == AZX_SNOOP_TYPE_NVIDIA) {
5377     dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n",
5378     azx_snoop(chip));
5379     update_pci_byte(chip->pci,
5380     @@ -475,7 +486,7 @@ static void azx_init_pci(struct azx *chip)
5381     }
5382    
5383     /* Enable SCH/PCH snoop if needed */
5384     - if (chip->driver_caps & AZX_DCAPS_SCH_SNOOP) {
5385     + if (snoop_type == AZX_SNOOP_TYPE_SCH) {
5386     unsigned short snoop;
5387     pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop);
5388     if ((!azx_snoop(chip) && !(snoop & INTEL_SCH_HDA_DEVC_NOSNOOP)) ||
5389     @@ -1363,8 +1374,8 @@ static void azx_check_snoop_available(struct azx *chip)
5390     {
5391     bool snoop = chip->snoop;
5392    
5393     - switch (chip->driver_type) {
5394     - case AZX_DRIVER_VIA:
5395     + if (azx_get_snoop_type(chip) == AZX_SNOOP_TYPE_NONE &&
5396     + chip->driver_type == AZX_DRIVER_VIA) {
5397     /* force to non-snoop mode for a new VIA controller
5398     * when BIOS is set
5399     */
5400     @@ -1374,17 +1385,11 @@ static void azx_check_snoop_available(struct azx *chip)
5401     if (!(val & 0x80) && chip->pci->revision == 0x30)
5402     snoop = false;
5403     }
5404     - break;
5405     - case AZX_DRIVER_ATIHDMI_NS:
5406     - /* new ATI HDMI requires non-snoop */
5407     - snoop = false;
5408     - break;
5409     - case AZX_DRIVER_CTHDA:
5410     - case AZX_DRIVER_CMEDIA:
5411     - snoop = false;
5412     - break;
5413     }
5414    
5415     + if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF)
5416     + snoop = false;
5417     +
5418     if (snoop != chip->snoop) {
5419     dev_info(chip->card->dev, "Force to %s mode\n",
5420     snoop ? "snoop" : "non-snoop");
5421     @@ -2131,13 +2136,15 @@ static const struct pci_device_id azx_ids[] = {
5422     { PCI_DEVICE(0x1002, 0xaa98),
5423     .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI },
5424     { PCI_DEVICE(0x1002, 0x9902),
5425     - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
5426     + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
5427     { PCI_DEVICE(0x1002, 0xaaa0),
5428     - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
5429     + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
5430     { PCI_DEVICE(0x1002, 0xaaa8),
5431     - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
5432     + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
5433     { PCI_DEVICE(0x1002, 0xaab0),
5434     - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
5435     + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
5436     + { PCI_DEVICE(0x1002, 0xaac8),
5437     + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
5438     /* VIA VT8251/VT8237A */
5439     { PCI_DEVICE(0x1106, 0x3288),
5440     .driver_data = AZX_DRIVER_VIA | AZX_DCAPS_POSFIX_VIA },
5441     @@ -2184,7 +2191,7 @@ static const struct pci_device_id azx_ids[] = {
5442     /* CM8888 */
5443     { PCI_DEVICE(0x13f6, 0x5011),
5444     .driver_data = AZX_DRIVER_CMEDIA |
5445     - AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB },
5446     + AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_SNOOP_OFF },
5447     /* Vortex86MX */
5448     { PCI_DEVICE(0x17f3, 0x3010), .driver_data = AZX_DRIVER_GENERIC },
5449     /* VMware HDAudio */
5450     diff --git a/sound/pci/hda/hda_priv.h b/sound/pci/hda/hda_priv.h
5451     index 5016014e57f2..a09703a2b2c1 100644
5452     --- a/sound/pci/hda/hda_priv.h
5453     +++ b/sound/pci/hda/hda_priv.h
5454     @@ -152,9 +152,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
5455     /* bits 0-7 are used for indicating driver type */
5456     #define AZX_DCAPS_NO_TCSEL (1 << 8) /* No Intel TCSEL bit */
5457     #define AZX_DCAPS_NO_MSI (1 << 9) /* No MSI support */
5458     -#define AZX_DCAPS_ATI_SNOOP (1 << 10) /* ATI snoop enable */
5459     -#define AZX_DCAPS_NVIDIA_SNOOP (1 << 11) /* Nvidia snoop enable */
5460     -#define AZX_DCAPS_SCH_SNOOP (1 << 12) /* SCH/PCH snoop enable */
5461     +#define AZX_DCAPS_SNOOP_MASK (3 << 10) /* snoop type mask */
5462     +#define AZX_DCAPS_SNOOP_OFF (1 << 12) /* snoop default off */
5463     #define AZX_DCAPS_RIRB_DELAY (1 << 13) /* Long delay in read loop */
5464     #define AZX_DCAPS_RIRB_PRE_DELAY (1 << 14) /* Put a delay before read */
5465     #define AZX_DCAPS_CTX_WORKAROUND (1 << 15) /* X-Fi workaround */
5466     @@ -173,6 +172,13 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
5467     #define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28) /* CORBRP clears itself after reset */
5468     #define AZX_DCAPS_NO_MSI64 (1 << 29) /* Stick to 32-bit MSIs */
5469    
5470     +enum {
5471     + AZX_SNOOP_TYPE_NONE ,
5472     + AZX_SNOOP_TYPE_SCH,
5473     + AZX_SNOOP_TYPE_ATI,
5474     + AZX_SNOOP_TYPE_NVIDIA,
5475     +};
5476     +
5477     /* HD Audio class code */
5478     #define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
5479    
5480     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
5481     index e3ad4a4d8d14..fca6d06f4bec 100644
5482     --- a/sound/pci/hda/patch_realtek.c
5483     +++ b/sound/pci/hda/patch_realtek.c
5484     @@ -880,6 +880,8 @@ static struct alc_codec_rename_pci_table rename_pci_tbl[] = {
5485     { 0x10ec0668, 0x1028, 0, "ALC3661" },
5486     { 0x10ec0275, 0x1028, 0, "ALC3260" },
5487     { 0x10ec0899, 0x1028, 0, "ALC3861" },
5488     + { 0x10ec0298, 0x1028, 0, "ALC3266" },
5489     + { 0x10ec0256, 0x1028, 0, "ALC3246" },
5490     { 0x10ec0670, 0x1025, 0, "ALC669X" },
5491     { 0x10ec0676, 0x1025, 0, "ALC679X" },
5492     { 0x10ec0282, 0x1043, 0, "ALC3229" },
5493     @@ -3476,6 +3478,14 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
5494     WRITE_COEF(0x32, 0x42a3),
5495     {}
5496     };
5497     + static struct coef_fw coef0288[] = {
5498     + UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
5499     + UPDATE_COEF(0x50, 0x2000, 0x2000),
5500     + UPDATE_COEF(0x56, 0x0006, 0x0006),
5501     + UPDATE_COEF(0x66, 0x0008, 0),
5502     + UPDATE_COEF(0x67, 0x2000, 0),
5503     + {}
5504     + };
5505     static struct coef_fw coef0292[] = {
5506     WRITE_COEF(0x76, 0x000e),
5507     WRITE_COEF(0x6c, 0x2400),
5508     @@ -3500,12 +3510,18 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
5509    
5510     switch (codec->vendor_id) {
5511     case 0x10ec0255:
5512     + case 0x10ec0256:
5513     alc_process_coef_fw(codec, coef0255);
5514     break;
5515     case 0x10ec0233:
5516     case 0x10ec0283:
5517     alc_process_coef_fw(codec, coef0233);
5518     break;
5519     + case 0x10ec0286:
5520     + case 0x10ec0288:
5521     + case 0x10ec0298:
5522     + alc_process_coef_fw(codec, coef0288);
5523     + break;
5524     case 0x10ec0292:
5525     alc_process_coef_fw(codec, coef0292);
5526     break;
5527     @@ -3535,6 +3551,14 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
5528     WRITE_COEF(0x26, 0x008c),
5529     {}
5530     };
5531     + static struct coef_fw coef0288[] = {
5532     + UPDATE_COEF(0x50, 0x2000, 0),
5533     + UPDATE_COEF(0x56, 0x0006, 0),
5534     + UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
5535     + UPDATE_COEF(0x66, 0x0008, 0x0008),
5536     + UPDATE_COEF(0x67, 0x2000, 0x2000),
5537     + {}
5538     + };
5539     static struct coef_fw coef0292[] = {
5540     WRITE_COEF(0x19, 0xa208),
5541     WRITE_COEF(0x2e, 0xacf0),
5542     @@ -3555,6 +3579,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
5543    
5544     switch (codec->vendor_id) {
5545     case 0x10ec0255:
5546     + case 0x10ec0256:
5547     alc_write_coef_idx(codec, 0x45, 0xc489);
5548     snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5549     alc_process_coef_fw(codec, coef0255);
5550     @@ -3567,6 +3592,14 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
5551     alc_process_coef_fw(codec, coef0233);
5552     snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5553     break;
5554     + case 0x10ec0286:
5555     + case 0x10ec0288:
5556     + case 0x10ec0298:
5557     + alc_update_coef_idx(codec, 0x4f, 0x000c, 0);
5558     + snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5559     + alc_process_coef_fw(codec, coef0288);
5560     + snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5561     + break;
5562     case 0x10ec0292:
5563     snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5564     alc_process_coef_fw(codec, coef0292);
5565     @@ -3578,6 +3611,10 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
5566     alc_process_coef_fw(codec, coef0293);
5567     snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5568     break;
5569     + case 0x10ec0662:
5570     + snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5571     + snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5572     + break;
5573     case 0x10ec0668:
5574     alc_write_coef_idx(codec, 0x11, 0x0001);
5575     snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5576     @@ -3602,6 +3639,14 @@ static void alc_headset_mode_default(struct hda_codec *codec)
5577     WRITE_COEF(0x32, 0x4ea3),
5578     {}
5579     };
5580     + static struct coef_fw coef0288[] = {
5581     + UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */
5582     + UPDATE_COEF(0x50, 0x2000, 0x2000),
5583     + UPDATE_COEF(0x56, 0x0006, 0x0006),
5584     + UPDATE_COEF(0x66, 0x0008, 0),
5585     + UPDATE_COEF(0x67, 0x2000, 0),
5586     + {}
5587     + };
5588     static struct coef_fw coef0292[] = {
5589     WRITE_COEF(0x76, 0x000e),
5590     WRITE_COEF(0x6c, 0x2400),
5591     @@ -3624,12 +3669,18 @@ static void alc_headset_mode_default(struct hda_codec *codec)
5592    
5593     switch (codec->vendor_id) {
5594     case 0x10ec0255:
5595     + case 0x10ec0256:
5596     alc_process_coef_fw(codec, coef0255);
5597     break;
5598     case 0x10ec0233:
5599     case 0x10ec0283:
5600     alc_process_coef_fw(codec, coef0233);
5601     break;
5602     + case 0x10ec0286:
5603     + case 0x10ec0288:
5604     + case 0x10ec0298:
5605     + alc_process_coef_fw(codec, coef0288);
5606     + break;
5607     case 0x10ec0292:
5608     alc_process_coef_fw(codec, coef0292);
5609     break;
5610     @@ -3658,6 +3709,13 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
5611     WRITE_COEF(0x32, 0x4ea3),
5612     {}
5613     };
5614     + static struct coef_fw coef0288[] = {
5615     + UPDATE_COEF(0x50, 0x2000, 0x2000),
5616     + UPDATE_COEF(0x56, 0x0006, 0x0006),
5617     + UPDATE_COEF(0x66, 0x0008, 0),
5618     + UPDATE_COEF(0x67, 0x2000, 0),
5619     + {}
5620     + };
5621     static struct coef_fw coef0292[] = {
5622     WRITE_COEF(0x6b, 0xd429),
5623     WRITE_COEF(0x76, 0x0008),
5624     @@ -3678,12 +3736,22 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
5625    
5626     switch (codec->vendor_id) {
5627     case 0x10ec0255:
5628     + case 0x10ec0256:
5629     alc_process_coef_fw(codec, coef0255);
5630     break;
5631     case 0x10ec0233:
5632     case 0x10ec0283:
5633     alc_process_coef_fw(codec, coef0233);
5634     break;
5635     + case 0x10ec0298:
5636     + alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);/* Headset output enable */
5637     + /* ALC298 jack type setting is the same with ALC286/ALC288 */
5638     + case 0x10ec0286:
5639     + case 0x10ec0288:
5640     + alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5641     + msleep(300);
5642     + alc_process_coef_fw(codec, coef0288);
5643     + break;
5644     case 0x10ec0292:
5645     alc_process_coef_fw(codec, coef0292);
5646     break;
5647     @@ -3712,6 +3780,13 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
5648     WRITE_COEF(0x32, 0x4ea3),
5649     {}
5650     };
5651     + static struct coef_fw coef0288[] = {
5652     + UPDATE_COEF(0x50, 0x2000, 0x2000),
5653     + UPDATE_COEF(0x56, 0x0006, 0x0006),
5654     + UPDATE_COEF(0x66, 0x0008, 0),
5655     + UPDATE_COEF(0x67, 0x2000, 0),
5656     + {}
5657     + };
5658     static struct coef_fw coef0292[] = {
5659     WRITE_COEF(0x6b, 0xe429),
5660     WRITE_COEF(0x76, 0x0008),
5661     @@ -3732,12 +3807,22 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
5662    
5663     switch (codec->vendor_id) {
5664     case 0x10ec0255:
5665     + case 0x10ec0256:
5666     alc_process_coef_fw(codec, coef0255);
5667     break;
5668     case 0x10ec0233:
5669     case 0x10ec0283:
5670     alc_process_coef_fw(codec, coef0233);
5671     break;
5672     + case 0x10ec0298:
5673     + alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
5674     + /* ALC298 jack type setting is the same with ALC286/ALC288 */
5675     + case 0x10ec0286:
5676     + case 0x10ec0288:
5677     + alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5678     + msleep(300);
5679     + alc_process_coef_fw(codec, coef0288);
5680     + break;
5681     case 0x10ec0292:
5682     alc_process_coef_fw(codec, coef0292);
5683     break;
5684     @@ -3762,6 +3847,10 @@ static void alc_determine_headset_type(struct hda_codec *codec)
5685     conteol) */
5686     {}
5687     };
5688     + static struct coef_fw coef0288[] = {
5689     + UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */
5690     + {}
5691     + };
5692     static struct coef_fw coef0293[] = {
5693     UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
5694     WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
5695     @@ -3777,6 +3866,7 @@ static void alc_determine_headset_type(struct hda_codec *codec)
5696    
5697     switch (codec->vendor_id) {
5698     case 0x10ec0255:
5699     + case 0x10ec0256:
5700     alc_process_coef_fw(codec, coef0255);
5701     msleep(300);
5702     val = alc_read_coef_idx(codec, 0x46);
5703     @@ -3789,6 +3879,16 @@ static void alc_determine_headset_type(struct hda_codec *codec)
5704     val = alc_read_coef_idx(codec, 0x46);
5705     is_ctia = (val & 0x0070) == 0x0070;
5706     break;
5707     + case 0x10ec0298:
5708     + alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020); /* Headset output enable */
5709     + /* ALC298 check jack type is the same with ALC286/ALC288 */
5710     + case 0x10ec0286:
5711     + case 0x10ec0288:
5712     + alc_process_coef_fw(codec, coef0288);
5713     + msleep(350);
5714     + val = alc_read_coef_idx(codec, 0x50);
5715     + is_ctia = (val & 0x0070) == 0x0070;
5716     + break;
5717     case 0x10ec0292:
5718     alc_write_coef_idx(codec, 0x6b, 0xd429);
5719     msleep(300);
5720     @@ -3863,7 +3963,7 @@ static void alc_update_headset_mode(struct hda_codec *codec)
5721     if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
5722     snd_hda_set_pin_ctl_cache(codec, hp_pin,
5723     AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
5724     - if (spec->headphone_mic_pin)
5725     + if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
5726     snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
5727     PIN_VREFHIZ);
5728     }
5729     @@ -4038,6 +4138,23 @@ static void alc_fixup_dell_xps13(struct hda_codec *codec,
5730     }
5731     }
5732    
5733     +static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
5734     + const struct hda_fixup *fix, int action)
5735     +{
5736     + struct alc_spec *spec = codec->spec;
5737     +
5738     + if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5739     + spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5740     + spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
5741     +
5742     + /* Disable boost for mic-in permanently. (This code is only called
5743     + from quirks that guarantee that the headphone is at NID 0x1b.) */
5744     + snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
5745     + snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
5746     + } else
5747     + alc_fixup_headset_mode(codec, fix, action);
5748     +}
5749     +
5750     static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
5751     const struct hda_fixup *fix, int action)
5752     {
5753     @@ -4886,6 +5003,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5754     SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
5755     SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
5756     SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
5757     + SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
5758     SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
5759     SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
5760     SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC),
5761     @@ -4915,6 +5033,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5762     SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
5763     SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK),
5764     SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK),
5765     + SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
5766     SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
5767     SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
5768     SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
5769     @@ -5003,6 +5122,16 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
5770     {0x1b, 0x411111f0}, \
5771     {0x1e, 0x411111f0}
5772    
5773     +#define ALC256_STANDARD_PINS \
5774     + {0x12, 0x90a60140}, \
5775     + {0x14, 0x90170110}, \
5776     + {0x19, 0x411111f0}, \
5777     + {0x1a, 0x411111f0}, \
5778     + {0x1b, 0x411111f0}, \
5779     + {0x1d, 0x40700001}, \
5780     + {0x1e, 0x411111f0}, \
5781     + {0x21, 0x02211020}
5782     +
5783     #define ALC282_STANDARD_PINS \
5784     {0x14, 0x90170110}, \
5785     {0x18, 0x411111f0}, \
5786     @@ -5095,6 +5224,19 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
5787     {0x17, 0x40000000},
5788     {0x1d, 0x40700001},
5789     {0x21, 0x02211050}),
5790     + SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5791     + ALC255_STANDARD_PINS,
5792     + {0x12, 0x90a60180},
5793     + {0x14, 0x90170130},
5794     + {0x17, 0x40000000},
5795     + {0x1d, 0x40700001},
5796     + {0x21, 0x02211040}),
5797     + SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5798     + ALC256_STANDARD_PINS,
5799     + {0x13, 0x40000000}),
5800     + SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5801     + ALC256_STANDARD_PINS,
5802     + {0x13, 0x411111f0}),
5803     SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
5804     {0x12, 0x90a60130},
5805     {0x13, 0x40000000},
5806     @@ -5828,7 +5970,9 @@ enum {
5807     ALC662_FIXUP_NO_JACK_DETECT,
5808     ALC662_FIXUP_ZOTAC_Z68,
5809     ALC662_FIXUP_INV_DMIC,
5810     + ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
5811     ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
5812     + ALC662_FIXUP_HEADSET_MODE,
5813     ALC668_FIXUP_HEADSET_MODE,
5814     ALC662_FIXUP_BASS_MODE4_CHMAP,
5815     ALC662_FIXUP_BASS_16,
5816     @@ -6021,6 +6165,20 @@ static const struct hda_fixup alc662_fixups[] = {
5817     .chained = true,
5818     .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
5819     },
5820     + [ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
5821     + .type = HDA_FIXUP_PINS,
5822     + .v.pins = (const struct hda_pintbl[]) {
5823     + { 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
5824     + /* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
5825     + { }
5826     + },
5827     + .chained = true,
5828     + .chain_id = ALC662_FIXUP_HEADSET_MODE
5829     + },
5830     + [ALC662_FIXUP_HEADSET_MODE] = {
5831     + .type = HDA_FIXUP_FUNC,
5832     + .v.func = alc_fixup_headset_mode_alc662,
5833     + },
5834     [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
5835     .type = HDA_FIXUP_PINS,
5836     .v.pins = (const struct hda_pintbl[]) {
5837     @@ -6172,6 +6330,18 @@ static const struct hda_model_fixup alc662_fixup_models[] = {
5838     };
5839    
5840     static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
5841     + SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
5842     + {0x12, 0x4004c000},
5843     + {0x14, 0x01014010},
5844     + {0x15, 0x411111f0},
5845     + {0x16, 0x411111f0},
5846     + {0x18, 0x01a19020},
5847     + {0x19, 0x411111f0},
5848     + {0x1a, 0x0181302f},
5849     + {0x1b, 0x0221401f},
5850     + {0x1c, 0x411111f0},
5851     + {0x1d, 0x4054c601},
5852     + {0x1e, 0x411111f0}),
5853     SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
5854     {0x12, 0x99a30130},
5855     {0x14, 0x90170110},
5856     diff --git a/sound/pci/hda/thinkpad_helper.c b/sound/pci/hda/thinkpad_helper.c
5857     index 2341fc334163..6ba0b5517c40 100644
5858     --- a/sound/pci/hda/thinkpad_helper.c
5859     +++ b/sound/pci/hda/thinkpad_helper.c
5860     @@ -72,7 +72,6 @@ static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
5861     if (led_set_func(TPACPI_LED_MUTE, false) >= 0) {
5862     old_vmaster_hook = spec->vmaster_mute.hook;
5863     spec->vmaster_mute.hook = update_tpacpi_mute_led;
5864     - spec->vmaster_mute_enum = 1;
5865     removefunc = false;
5866     }
5867     if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) {
5868     diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c
5869     index 71f775aad7c7..2f98417b16b7 100644
5870     --- a/sound/soc/codecs/mc13783.c
5871     +++ b/sound/soc/codecs/mc13783.c
5872     @@ -623,14 +623,14 @@ static int mc13783_probe(struct snd_soc_codec *codec)
5873     AUDIO_SSI_SEL, 0);
5874     else
5875     mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_CODEC,
5876     - 0, AUDIO_SSI_SEL);
5877     + AUDIO_SSI_SEL, AUDIO_SSI_SEL);
5878    
5879     if (priv->dac_ssi_port == MC13783_SSI1_PORT)
5880     mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_DAC,
5881     AUDIO_SSI_SEL, 0);
5882     else
5883     mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_DAC,
5884     - 0, AUDIO_SSI_SEL);
5885     + AUDIO_SSI_SEL, AUDIO_SSI_SEL);
5886    
5887     return 0;
5888     }
5889     diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
5890     index ab9931c280b2..34a18a910113 100644
5891     --- a/sound/soc/codecs/wm8960.c
5892     +++ b/sound/soc/codecs/wm8960.c
5893     @@ -392,7 +392,7 @@ static const struct snd_soc_dapm_route audio_paths[] = {
5894     { "Right Input Mixer", "Boost Switch", "Right Boost Mixer", },
5895     { "Right Input Mixer", NULL, "RINPUT1", }, /* Really Boost Switch */
5896     { "Right Input Mixer", NULL, "RINPUT2" },
5897     - { "Right Input Mixer", NULL, "LINPUT3" },
5898     + { "Right Input Mixer", NULL, "RINPUT3" },
5899    
5900     { "Left ADC", NULL, "Left Input Mixer" },
5901     { "Right ADC", NULL, "Right Input Mixer" },
5902     diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
5903     index 1fcb9f3f3097..e5f14c878636 100644
5904     --- a/sound/soc/codecs/wm8994.c
5905     +++ b/sound/soc/codecs/wm8994.c
5906     @@ -2753,7 +2753,7 @@ static struct {
5907     };
5908    
5909     static int fs_ratios[] = {
5910     - 64, 128, 192, 256, 348, 512, 768, 1024, 1408, 1536
5911     + 64, 128, 192, 256, 384, 512, 768, 1024, 1408, 1536
5912     };
5913    
5914     static int bclk_divs[] = {
5915     diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
5916     index c61cb9cedbcd..943e6a9a6319 100644
5917     --- a/sound/soc/soc-dapm.c
5918     +++ b/sound/soc/soc-dapm.c
5919     @@ -3076,11 +3076,16 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
5920     }
5921    
5922     prefix = soc_dapm_prefix(dapm);
5923     - if (prefix)
5924     + if (prefix) {
5925     w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name);
5926     - else
5927     + if (widget->sname)
5928     + w->sname = kasprintf(GFP_KERNEL, "%s %s", prefix,
5929     + widget->sname);
5930     + } else {
5931     w->name = kasprintf(GFP_KERNEL, "%s", widget->name);
5932     -
5933     + if (widget->sname)
5934     + w->sname = kasprintf(GFP_KERNEL, "%s", widget->sname);
5935     + }
5936     if (w->name == NULL) {
5937     kfree(w);
5938     return NULL;
5939     diff --git a/sound/usb/clock.c b/sound/usb/clock.c
5940     index 03fed6611d9e..2ed260b10f6d 100644
5941     --- a/sound/usb/clock.c
5942     +++ b/sound/usb/clock.c
5943     @@ -303,6 +303,11 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface,
5944     return err;
5945     }
5946    
5947     + /* Don't check the sample rate for devices which we know don't
5948     + * support reading */
5949     + if (snd_usb_get_sample_rate_quirk(chip))
5950     + return 0;
5951     +
5952     if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR,
5953     USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_IN,
5954     UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep,
5955     diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
5956     index c62a1659106d..0d8aba5fe1a8 100644
5957     --- a/sound/usb/pcm.c
5958     +++ b/sound/usb/pcm.c
5959     @@ -482,6 +482,11 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
5960     /* set interface */
5961     if (subs->interface != fmt->iface ||
5962     subs->altset_idx != fmt->altset_idx) {
5963     +
5964     + err = snd_usb_select_mode_quirk(subs, fmt);
5965     + if (err < 0)
5966     + return -EIO;
5967     +
5968     err = usb_set_interface(dev, fmt->iface, fmt->altsetting);
5969     if (err < 0) {
5970     dev_err(&dev->dev,
5971     diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
5972     index 5293b5ac8b9d..fde5b6e3c8e5 100644
5973     --- a/sound/usb/quirks-table.h
5974     +++ b/sound/usb/quirks-table.h
5975     @@ -3145,6 +3145,46 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
5976    
5977     {
5978     /*
5979     + * ZOOM R16/24 in audio interface mode.
5980     + * Mixer descriptors are garbage, further quirks will be needed
5981     + * to make any of it functional, thus disabled for now.
5982     + * Playback stream appears to start and run fine but no sound
5983     + * is produced, so also disabled for now.
5984     + */
5985     + USB_DEVICE(0x1686, 0x00dd),
5986     + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
5987     + .ifnum = QUIRK_ANY_INTERFACE,
5988     + .type = QUIRK_COMPOSITE,
5989     + .data = (const struct snd_usb_audio_quirk[]) {
5990     + {
5991     + /* Mixer */
5992     + .ifnum = 0,
5993     + .type = QUIRK_IGNORE_INTERFACE,
5994     + },
5995     + {
5996     + /* Playback */
5997     + .ifnum = 1,
5998     + .type = QUIRK_IGNORE_INTERFACE,
5999     + },
6000     + {
6001     + /* Capture */
6002     + .ifnum = 2,
6003     + .type = QUIRK_AUDIO_STANDARD_INTERFACE,
6004     + },
6005     + {
6006     + /* Midi */
6007     + .ifnum = 3,
6008     + .type = QUIRK_MIDI_STANDARD_INTERFACE
6009     + },
6010     + {
6011     + .ifnum = -1
6012     + },
6013     + }
6014     + }
6015     +},
6016     +
6017     +{
6018     + /*
6019     * Some USB MIDI devices don't have an audio control interface,
6020     * so we have to grab MIDI streaming interfaces here.
6021     */
6022     diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
6023     index 60dfe0d28771..05ad944dc5c8 100644
6024     --- a/sound/usb/quirks.c
6025     +++ b/sound/usb/quirks.c
6026     @@ -1102,6 +1102,65 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
6027     }
6028     }
6029    
6030     +bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
6031     +{
6032     + /* devices which do not support reading the sample rate. */
6033     + switch (chip->usb_id) {
6034     + case USB_ID(0x045E, 0x075D): /* MS Lifecam Cinema */
6035     + case USB_ID(0x045E, 0x076D): /* MS Lifecam HD-5000 */
6036     + case USB_ID(0x045E, 0x0772): /* MS Lifecam Studio */
6037     + case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */
6038     + case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */
6039     + return true;
6040     + }
6041     + return false;
6042     +}
6043     +
6044     +/* Marantz/Denon USB DACs need a vendor cmd to switch
6045     + * between PCM and native DSD mode
6046     + */
6047     +static bool is_marantz_denon_dac(unsigned int id)
6048     +{
6049     + switch (id) {
6050     + case USB_ID(0x154e, 0x1003): /* Denon DA-300USB */
6051     + case USB_ID(0x154e, 0x3005): /* Marantz HD-DAC1 */
6052     + case USB_ID(0x154e, 0x3006): /* Marantz SA-14S1 */
6053     + return true;
6054     + }
6055     + return false;
6056     +}
6057     +
6058     +int snd_usb_select_mode_quirk(struct snd_usb_substream *subs,
6059     + struct audioformat *fmt)
6060     +{
6061     + struct usb_device *dev = subs->dev;
6062     + int err;
6063     +
6064     + if (is_marantz_denon_dac(subs->stream->chip->usb_id)) {
6065     + /* First switch to alt set 0, otherwise the mode switch cmd
6066     + * will not be accepted by the DAC
6067     + */
6068     + err = usb_set_interface(dev, fmt->iface, 0);
6069     + if (err < 0)
6070     + return err;
6071     +
6072     + mdelay(20); /* Delay needed after setting the interface */
6073     +
6074     + switch (fmt->altsetting) {
6075     + case 2: /* DSD mode requested */
6076     + case 1: /* PCM mode requested */
6077     + err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0,
6078     + USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_INTERFACE,
6079     + fmt->altsetting - 1, 1, NULL, 0);
6080     + if (err < 0)
6081     + return err;
6082     + break;
6083     + }
6084     + mdelay(20);
6085     + }
6086     + return 0;
6087     +}
6088     +
6089     void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep)
6090     {
6091     /*
6092     @@ -1150,16 +1209,18 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
6093     /* Marantz/Denon devices with USB DAC functionality need a delay
6094     * after each class compliant request
6095     */
6096     - if ((le16_to_cpu(dev->descriptor.idVendor) == 0x154e) &&
6097     - (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) {
6098     + if (is_marantz_denon_dac(USB_ID(le16_to_cpu(dev->descriptor.idVendor),
6099     + le16_to_cpu(dev->descriptor.idProduct)))
6100     + && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
6101     + mdelay(20);
6102    
6103     - switch (le16_to_cpu(dev->descriptor.idProduct)) {
6104     - case 0x3005: /* Marantz HD-DAC1 */
6105     - case 0x3006: /* Marantz SA-14S1 */
6106     - mdelay(20);
6107     - break;
6108     - }
6109     - }
6110     + /* Zoom R16/24 needs a tiny delay here, otherwise requests like
6111     + * get/set frequency return as failed despite actually succeeding.
6112     + */
6113     + if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1686) &&
6114     + (le16_to_cpu(dev->descriptor.idProduct) == 0x00dd) &&
6115     + (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
6116     + mdelay(1);
6117     }
6118    
6119     /*
6120     @@ -1190,8 +1251,9 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
6121    
6122     /* XMOS based USB DACs */
6123     switch (chip->usb_id) {
6124     - /* iFi Audio micro/nano iDSD */
6125     - case USB_ID(0x20b1, 0x3008):
6126     + case USB_ID(0x20b1, 0x3008): /* iFi Audio micro/nano iDSD */
6127     + case USB_ID(0x20b1, 0x2008): /* Matrix Audio X-Sabre */
6128     + case USB_ID(0x20b1, 0x300a): /* Matrix Audio Mini-i Pro */
6129     if (fp->altsetting == 2)
6130     return SNDRV_PCM_FMTBIT_DSD_U32_BE;
6131     break;
6132     @@ -1204,5 +1266,11 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
6133     break;
6134     }
6135    
6136     + /* Denon/Marantz devices with USB DAC functionality */
6137     + if (is_marantz_denon_dac(chip->usb_id)) {
6138     + if (fp->altsetting == 2)
6139     + return SNDRV_PCM_FMTBIT_DSD_U32_BE;
6140     + }
6141     +
6142     return 0;
6143     }
6144     diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h
6145     index 665e972a1b40..2cd71ed1201f 100644
6146     --- a/sound/usb/quirks.h
6147     +++ b/sound/usb/quirks.h
6148     @@ -21,6 +21,8 @@ int snd_usb_apply_boot_quirk(struct usb_device *dev,
6149     void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
6150     struct audioformat *fmt);
6151    
6152     +bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip);
6153     +
6154     int snd_usb_is_big_endian_format(struct snd_usb_audio *chip,
6155     struct audioformat *fp);
6156    
6157     @@ -31,6 +33,9 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
6158     __u8 request, __u8 requesttype, __u16 value,
6159     __u16 index, void *data, __u16 size);
6160    
6161     +int snd_usb_select_mode_quirk(struct snd_usb_substream *subs,
6162     + struct audioformat *fmt);
6163     +
6164     u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
6165     struct audioformat *fp,
6166     unsigned int sample_bytes);
6167     diff --git a/tools/vm/Makefile b/tools/vm/Makefile
6168     index 3d907dacf2ac..c604f3ec628a 100644
6169     --- a/tools/vm/Makefile
6170     +++ b/tools/vm/Makefile
6171     @@ -3,7 +3,7 @@
6172     TARGETS=page-types slabinfo
6173    
6174     LIB_DIR = ../lib/api
6175     -LIBS = $(LIB_DIR)/libapikfs.a
6176     +LIBS = $(LIB_DIR)/libapi.a
6177    
6178     CC = $(CROSS_COMPILE)gcc
6179     CFLAGS = -Wall -Wextra -I../lib/