Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r2773 - genpatches-2.6/trunk/3.14
Date: Tue, 06 May 2014 18:21:05
Message-Id: 20140506182100.63AF12004C@flycatcher.gentoo.org
1 Author: mpagano
2 Date: 2014-05-06 18:21:00 +0000 (Tue, 06 May 2014)
3 New Revision: 2773
4
5 Added:
6 genpatches-2.6/trunk/3.14/1002_linux-3.14.3.patch
7 Modified:
8 genpatches-2.6/trunk/3.14/0000_README
9 Log:
10 Linux patch 3.14.3
11
12 Modified: genpatches-2.6/trunk/3.14/0000_README
13 ===================================================================
14 --- genpatches-2.6/trunk/3.14/0000_README 2014-05-05 14:28:48 UTC (rev 2772)
15 +++ genpatches-2.6/trunk/3.14/0000_README 2014-05-06 18:21:00 UTC (rev 2773)
16 @@ -50,6 +50,10 @@
17 From: http://www.kernel.org
18 Desc: Linux 3.14.2
19
20 +Patch: 1002_linux-3.14.3.patch
21 +From: http://www.kernel.org
22 +Desc: Linux 3.14.3
23 +
24 Patch: 1500_XATTR_USER_PREFIX.patch
25 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
26 Desc: Support for namespace user.pax.* on tmpfs.
27
28 Added: genpatches-2.6/trunk/3.14/1002_linux-3.14.3.patch
29 ===================================================================
30 --- genpatches-2.6/trunk/3.14/1002_linux-3.14.3.patch (rev 0)
31 +++ genpatches-2.6/trunk/3.14/1002_linux-3.14.3.patch 2014-05-06 18:21:00 UTC (rev 2773)
32 @@ -0,0 +1,5996 @@
33 +diff --git a/Documentation/devicetree/bindings/spi/efm32-spi.txt b/Documentation/devicetree/bindings/spi/efm32-spi.txt
34 +index a590ca51be75..f762e11bfe11 100644
35 +--- a/Documentation/devicetree/bindings/spi/efm32-spi.txt
36 ++++ b/Documentation/devicetree/bindings/spi/efm32-spi.txt
37 +@@ -3,7 +3,7 @@
38 + Required properties:
39 + - #address-cells: see spi-bus.txt
40 + - #size-cells: see spi-bus.txt
41 +-- compatible: should be "efm32,spi"
42 ++- compatible: should be "energymicro,efm32-spi"
43 + - reg: Offset and length of the register set for the controller
44 + - interrupts: pair specifying rx and tx irq
45 + - clocks: phandle to the spi clock
46 +@@ -15,7 +15,7 @@ Example:
47 + spi1: spi@0x4000c400 { /* USART1 */
48 + #address-cells = <1>;
49 + #size-cells = <0>;
50 +- compatible = "efm32,spi";
51 ++ compatible = "energymicro,efm32-spi";
52 + reg = <0x4000c400 0x400>;
53 + interrupts = <15 16>;
54 + clocks = <&cmu 20>;
55 +diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
56 +index e55124e7c40c..855d9b37bf76 100644
57 +--- a/Documentation/sysctl/kernel.txt
58 ++++ b/Documentation/sysctl/kernel.txt
59 +@@ -317,6 +317,7 @@ for more than this value report a warning.
60 + This file shows up if CONFIG_DETECT_HUNG_TASK is enabled.
61 +
62 + 0: means infinite timeout - no checking done.
63 ++Possible values to set are in range {0..LONG_MAX/HZ}.
64 +
65 + ==============================================================
66 +
67 +diff --git a/Documentation/video4linux/gspca.txt b/Documentation/video4linux/gspca.txt
68 +index 1e6b6531bbcc..d2ba80bb7af5 100644
69 +--- a/Documentation/video4linux/gspca.txt
70 ++++ b/Documentation/video4linux/gspca.txt
71 +@@ -55,6 +55,7 @@ zc3xx 0458:700f Genius VideoCam Web V2
72 + sonixj 0458:7025 Genius Eye 311Q
73 + sn9c20x 0458:7029 Genius Look 320s
74 + sonixj 0458:702e Genius Slim 310 NB
75 ++sn9c20x 0458:7045 Genius Look 1320 V2
76 + sn9c20x 0458:704a Genius Slim 1320
77 + sn9c20x 0458:704c Genius i-Look 1321
78 + sn9c20x 045e:00f4 LifeCam VX-6000 (SN9C20x + OV9650)
79 +diff --git a/Makefile b/Makefile
80 +index b2f7de81e9a2..eed07f3f9308 100644
81 +--- a/Makefile
82 ++++ b/Makefile
83 +@@ -1,6 +1,6 @@
84 + VERSION = 3
85 + PATCHLEVEL = 14
86 +-SUBLEVEL = 2
87 ++SUBLEVEL = 3
88 + EXTRAVERSION =
89 + NAME = Shuffling Zombie Juror
90 +
91 +diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
92 +index 15949459611f..44298add8a48 100644
93 +--- a/arch/arm/Kconfig
94 ++++ b/arch/arm/Kconfig
95 +@@ -898,7 +898,7 @@ config ARCH_MULTI_V5
96 + bool "ARMv5 based platforms (ARM926T, XSCALE, PJ1, ...)"
97 + depends on !ARCH_MULTI_V6_V7
98 + select ARCH_MULTI_V4_V5
99 +- select CPU_ARM926T if (!CPU_ARM946E || CPU_ARM1020 || \
100 ++ select CPU_ARM926T if !(CPU_ARM946E || CPU_ARM1020 || \
101 + CPU_ARM1020E || CPU_ARM1022 || CPU_ARM1026 || \
102 + CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK || CPU_FEROCEON)
103 +
104 +diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
105 +index e3f27ec31718..2e7d932887b5 100644
106 +--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
107 ++++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
108 +@@ -183,7 +183,7 @@
109 + &usb {
110 + status = "okay";
111 +
112 +- control@44e10000 {
113 ++ control@44e10620 {
114 + status = "okay";
115 + };
116 +
117 +@@ -204,7 +204,7 @@
118 + dr_mode = "host";
119 + };
120 +
121 +- dma-controller@07402000 {
122 ++ dma-controller@47402000 {
123 + status = "okay";
124 + };
125 + };
126 +diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts
127 +index 7e6c64ed966d..801055a42998 100644
128 +--- a/arch/arm/boot/dts/am335x-evm.dts
129 ++++ b/arch/arm/boot/dts/am335x-evm.dts
130 +@@ -325,7 +325,7 @@
131 + &usb {
132 + status = "okay";
133 +
134 +- control@44e10000 {
135 ++ control@44e10620 {
136 + status = "okay";
137 + };
138 +
139 +@@ -346,7 +346,7 @@
140 + dr_mode = "host";
141 + };
142 +
143 +- dma-controller@07402000 {
144 ++ dma-controller@47402000 {
145 + status = "okay";
146 + };
147 + };
148 +diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts
149 +index 486880b74831..dd142bc677ca 100644
150 +--- a/arch/arm/boot/dts/am335x-evmsk.dts
151 ++++ b/arch/arm/boot/dts/am335x-evmsk.dts
152 +@@ -334,7 +334,7 @@
153 + &usb {
154 + status = "okay";
155 +
156 +- control@44e10000 {
157 ++ control@44e10620 {
158 + status = "okay";
159 + };
160 +
161 +diff --git a/arch/arm/boot/dts/am335x-igep0033.dtsi b/arch/arm/boot/dts/am335x-igep0033.dtsi
162 +index 7063311a58d9..5942e7dab94f 100644
163 +--- a/arch/arm/boot/dts/am335x-igep0033.dtsi
164 ++++ b/arch/arm/boot/dts/am335x-igep0033.dtsi
165 +@@ -202,7 +202,7 @@
166 + &usb {
167 + status = "okay";
168 +
169 +- control@44e10000 {
170 ++ control@44e10620 {
171 + status = "okay";
172 + };
173 +
174 +@@ -223,7 +223,7 @@
175 + dr_mode = "host";
176 + };
177 +
178 +- dma-controller@07402000 {
179 ++ dma-controller@47402000 {
180 + status = "okay";
181 + };
182 + };
183 +diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
184 +index 6d95d3df33c7..79087ccf64bc 100644
185 +--- a/arch/arm/boot/dts/am33xx.dtsi
186 ++++ b/arch/arm/boot/dts/am33xx.dtsi
187 +@@ -448,7 +448,7 @@
188 + ti,hwmods = "usb_otg_hs";
189 + status = "disabled";
190 +
191 +- usb_ctrl_mod: control@44e10000 {
192 ++ usb_ctrl_mod: control@44e10620 {
193 + compatible = "ti,am335x-usb-ctrl-module";
194 + reg = <0x44e10620 0x10
195 + 0x44e10648 0x4>;
196 +@@ -551,7 +551,7 @@
197 + "tx14", "tx15";
198 + };
199 +
200 +- cppi41dma: dma-controller@07402000 {
201 ++ cppi41dma: dma-controller@47402000 {
202 + compatible = "ti,am3359-cppi41";
203 + reg = <0x47400000 0x1000
204 + 0x47402000 0x1000
205 +diff --git a/arch/arm/boot/dts/armada-370-xp.dtsi b/arch/arm/boot/dts/armada-370-xp.dtsi
206 +index 74b5964430ac..e5d4902c630f 100644
207 +--- a/arch/arm/boot/dts/armada-370-xp.dtsi
208 ++++ b/arch/arm/boot/dts/armada-370-xp.dtsi
209 +@@ -226,6 +226,7 @@
210 + #size-cells = <0>;
211 + compatible = "marvell,orion-mdio";
212 + reg = <0x72004 0x4>;
213 ++ clocks = <&gateclk 4>;
214 + };
215 +
216 + eth1: ethernet@74000 {
217 +diff --git a/arch/arm/boot/dts/exynos5250-arndale.dts b/arch/arm/boot/dts/exynos5250-arndale.dts
218 +index b42e658876e5..457112d659ea 100644
219 +--- a/arch/arm/boot/dts/exynos5250-arndale.dts
220 ++++ b/arch/arm/boot/dts/exynos5250-arndale.dts
221 +@@ -287,6 +287,7 @@
222 + regulator-name = "vdd_g3d";
223 + regulator-min-microvolt = <1000000>;
224 + regulator-max-microvolt = <1000000>;
225 ++ regulator-always-on;
226 + regulator-boot-on;
227 + op_mode = <1>;
228 + };
229 +diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
230 +index d3f8a6e8ca20..69409f7e05dc 100644
231 +--- a/arch/arm/boot/dts/omap4.dtsi
232 ++++ b/arch/arm/boot/dts/omap4.dtsi
233 +@@ -275,6 +275,8 @@
234 + gpmc,num-waitpins = <4>;
235 + ti,hwmods = "gpmc";
236 + ti,no-idle-on-init;
237 ++ clocks = <&l3_div_ck>;
238 ++ clock-names = "fck";
239 + };
240 +
241 + uart1: serial@4806a000 {
242 +diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
243 +index a72813a9663e..7a16647c76f4 100644
244 +--- a/arch/arm/boot/dts/omap5.dtsi
245 ++++ b/arch/arm/boot/dts/omap5.dtsi
246 +@@ -302,6 +302,8 @@
247 + gpmc,num-cs = <8>;
248 + gpmc,num-waitpins = <4>;
249 + ti,hwmods = "gpmc";
250 ++ clocks = <&l3_iclk_div>;
251 ++ clock-names = "fck";
252 + };
253 +
254 + i2c1: i2c@48070000 {
255 +diff --git a/arch/arm/boot/dts/tegra124.dtsi b/arch/arm/boot/dts/tegra124.dtsi
256 +index ec0698a8354a..9c2ba74a8b60 100644
257 +--- a/arch/arm/boot/dts/tegra124.dtsi
258 ++++ b/arch/arm/boot/dts/tegra124.dtsi
259 +@@ -164,19 +164,6 @@
260 + status = "disabled";
261 + };
262 +
263 +- serial@70006400 {
264 +- compatible = "nvidia,tegra124-uart", "nvidia,tegra20-uart";
265 +- reg = <0x70006400 0x40>;
266 +- reg-shift = <2>;
267 +- interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>;
268 +- clocks = <&tegra_car TEGRA124_CLK_UARTE>;
269 +- resets = <&tegra_car 66>;
270 +- reset-names = "serial";
271 +- dmas = <&apbdma 20>, <&apbdma 20>;
272 +- dma-names = "rx", "tx";
273 +- status = "disabled";
274 +- };
275 +-
276 + pwm@7000a000 {
277 + compatible = "nvidia,tegra124-pwm", "nvidia,tegra20-pwm";
278 + reg = <0x7000a000 0x100>;
279 +diff --git a/arch/arm/include/asm/div64.h b/arch/arm/include/asm/div64.h
280 +index 191ada6e4d2d..662c7bd06108 100644
281 +--- a/arch/arm/include/asm/div64.h
282 ++++ b/arch/arm/include/asm/div64.h
283 +@@ -156,7 +156,7 @@
284 + /* Select the best insn combination to perform the */ \
285 + /* actual __m * __n / (__p << 64) operation. */ \
286 + if (!__c) { \
287 +- asm ( "umull %Q0, %R0, %1, %Q2\n\t" \
288 ++ asm ( "umull %Q0, %R0, %Q1, %Q2\n\t" \
289 + "mov %Q0, #0" \
290 + : "=&r" (__res) \
291 + : "r" (__m), "r" (__n) \
292 +diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
293 +index e42cf597f6e6..2aff798fbef4 100644
294 +--- a/arch/arm/include/asm/futex.h
295 ++++ b/arch/arm/include/asm/futex.h
296 +@@ -3,11 +3,6 @@
297 +
298 + #ifdef __KERNEL__
299 +
300 +-#if defined(CONFIG_CPU_USE_DOMAINS) && defined(CONFIG_SMP)
301 +-/* ARM doesn't provide unprivileged exclusive memory accessors */
302 +-#include <asm-generic/futex.h>
303 +-#else
304 +-
305 + #include <linux/futex.h>
306 + #include <linux/uaccess.h>
307 + #include <asm/errno.h>
308 +@@ -164,6 +159,5 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
309 + return ret;
310 + }
311 +
312 +-#endif /* !(CPU_USE_DOMAINS && SMP) */
313 + #endif /* __KERNEL__ */
314 + #endif /* _ASM_ARM_FUTEX_H */
315 +diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
316 +index dfff709fda3c..219ac88a9542 100644
317 +--- a/arch/arm/include/asm/pgtable-2level.h
318 ++++ b/arch/arm/include/asm/pgtable-2level.h
319 +@@ -140,6 +140,7 @@
320 + #define L_PTE_MT_DEV_NONSHARED (_AT(pteval_t, 0x0c) << 2) /* 1100 */
321 + #define L_PTE_MT_DEV_WC (_AT(pteval_t, 0x09) << 2) /* 1001 */
322 + #define L_PTE_MT_DEV_CACHED (_AT(pteval_t, 0x0b) << 2) /* 1011 */
323 ++#define L_PTE_MT_VECTORS (_AT(pteval_t, 0x0f) << 2) /* 1111 */
324 + #define L_PTE_MT_MASK (_AT(pteval_t, 0x0f) << 2)
325 +
326 + #ifndef __ASSEMBLY__
327 +diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h
328 +index acabef1a75df..43876245fc57 100644
329 +--- a/arch/arm/include/asm/unistd.h
330 ++++ b/arch/arm/include/asm/unistd.h
331 +@@ -48,6 +48,5 @@
332 + */
333 + #define __IGNORE_fadvise64_64
334 + #define __IGNORE_migrate_pages
335 +-#define __IGNORE_kcmp
336 +
337 + #endif /* __ASM_ARM_UNISTD_H */
338 +diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
339 +index f0d180d8b29f..8cf0996aa1a8 100644
340 +--- a/arch/arm/kernel/machine_kexec.c
341 ++++ b/arch/arm/kernel/machine_kexec.c
342 +@@ -184,3 +184,10 @@ void machine_kexec(struct kimage *image)
343 +
344 + soft_restart(reboot_entry_phys);
345 + }
346 ++
347 ++void arch_crash_save_vmcoreinfo(void)
348 ++{
349 ++#ifdef CONFIG_ARM_LPAE
350 ++ VMCOREINFO_CONFIG(ARM_LPAE);
351 ++#endif
352 ++}
353 +diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c
354 +index e022a869bff2..6037a9a01ed5 100644
355 +--- a/arch/arm/mach-omap2/irq.c
356 ++++ b/arch/arm/mach-omap2/irq.c
357 +@@ -222,6 +222,7 @@ void __init ti81xx_init_irq(void)
358 + static inline void omap_intc_handle_irq(void __iomem *base_addr, struct pt_regs *regs)
359 + {
360 + u32 irqnr;
361 ++ int handled_irq = 0;
362 +
363 + do {
364 + irqnr = readl_relaxed(base_addr + 0x98);
365 +@@ -249,8 +250,15 @@ out:
366 + if (irqnr) {
367 + irqnr = irq_find_mapping(domain, irqnr);
368 + handle_IRQ(irqnr, regs);
369 ++ handled_irq = 1;
370 + }
371 + } while (irqnr);
372 ++
373 ++ /* If an irq is masked or deasserted while active, we will
374 ++ * keep ending up here with no irq handled. So remove it from
375 ++ * the INTC with an ack.*/
376 ++ if (!handled_irq)
377 ++ omap_ack_irq(NULL);
378 + }
379 +
380 + asmlinkage void __exception_irq_entry omap2_intc_handle_irq(struct pt_regs *regs)
381 +diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
382 +index 1f33f5db10d5..66c60fe1104c 100644
383 +--- a/arch/arm/mach-omap2/omap_hwmod.c
384 ++++ b/arch/arm/mach-omap2/omap_hwmod.c
385 +@@ -2546,11 +2546,12 @@ static int __init _init(struct omap_hwmod *oh, void *data)
386 + return -EINVAL;
387 + }
388 +
389 +- if (np)
390 ++ if (np) {
391 + if (of_find_property(np, "ti,no-reset-on-init", NULL))
392 + oh->flags |= HWMOD_INIT_NO_RESET;
393 + if (of_find_property(np, "ti,no-idle-on-init", NULL))
394 + oh->flags |= HWMOD_INIT_NO_IDLE;
395 ++ }
396 +
397 + oh->_state = _HWMOD_STATE_INITIALIZED;
398 +
399 +diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
400 +index 4c3b1e6df508..ea4643abbe61 100644
401 +--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
402 ++++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
403 +@@ -1968,7 +1968,7 @@ static struct omap_hwmod_irq_info omap3xxx_usb_host_hs_irqs[] = {
404 + static struct omap_hwmod omap3xxx_usb_host_hs_hwmod = {
405 + .name = "usb_host_hs",
406 + .class = &omap3xxx_usb_host_hs_hwmod_class,
407 +- .clkdm_name = "l3_init_clkdm",
408 ++ .clkdm_name = "usbhost_clkdm",
409 + .mpu_irqs = omap3xxx_usb_host_hs_irqs,
410 + .main_clk = "usbhost_48m_fck",
411 + .prcm = {
412 +@@ -2053,7 +2053,7 @@ static struct omap_hwmod_irq_info omap3xxx_usb_tll_hs_irqs[] = {
413 + static struct omap_hwmod omap3xxx_usb_tll_hs_hwmod = {
414 + .name = "usb_tll_hs",
415 + .class = &omap3xxx_usb_tll_hs_hwmod_class,
416 +- .clkdm_name = "l3_init_clkdm",
417 ++ .clkdm_name = "core_l4_clkdm",
418 + .mpu_irqs = omap3xxx_usb_tll_hs_irqs,
419 + .main_clk = "usbtll_fck",
420 + .prcm = {
421 +diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
422 +index 7bdd22afce69..d4d0fce325c7 100644
423 +--- a/arch/arm/mach-omap2/pm.h
424 ++++ b/arch/arm/mach-omap2/pm.h
425 +@@ -103,7 +103,7 @@ static inline void enable_omap3630_toggle_l2_on_restore(void) { }
426 +
427 + #define PM_OMAP4_ROM_SMP_BOOT_ERRATUM_GICD (1 << 0)
428 +
429 +-#if defined(CONFIG_ARCH_OMAP4)
430 ++#if defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP4)
431 + extern u16 pm44xx_errata;
432 + #define IS_PM44XX_ERRATUM(id) (pm44xx_errata & (id))
433 + #else
434 +diff --git a/arch/arm/mach-pxa/include/mach/hx4700.h b/arch/arm/mach-pxa/include/mach/hx4700.h
435 +index 8bc02913517c..0e1bb46264f9 100644
436 +--- a/arch/arm/mach-pxa/include/mach/hx4700.h
437 ++++ b/arch/arm/mach-pxa/include/mach/hx4700.h
438 +@@ -14,6 +14,7 @@
439 +
440 + #include <linux/gpio.h>
441 + #include <linux/mfd/asic3.h>
442 ++#include "irqs.h" /* PXA_NR_BUILTIN_GPIO */
443 +
444 + #define HX4700_ASIC3_GPIO_BASE PXA_NR_BUILTIN_GPIO
445 + #define HX4700_EGPIO_BASE (HX4700_ASIC3_GPIO_BASE + ASIC3_NUM_GPIOS)
446 +diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
447 +index 1f8fed94c2a4..ca8ecdee47d8 100644
448 +--- a/arch/arm/mm/Kconfig
449 ++++ b/arch/arm/mm/Kconfig
450 +@@ -446,7 +446,6 @@ config CPU_32v5
451 +
452 + config CPU_32v6
453 + bool
454 +- select CPU_USE_DOMAINS if CPU_V6 && MMU
455 + select TLS_REG_EMUL if !CPU_32v6K && !MMU
456 +
457 + config CPU_32v6K
458 +@@ -671,7 +670,7 @@ config ARM_VIRT_EXT
459 +
460 + config SWP_EMULATE
461 + bool "Emulate SWP/SWPB instructions"
462 +- depends on !CPU_USE_DOMAINS && CPU_V7
463 ++ depends on CPU_V7
464 + default y if SMP
465 + select HAVE_PROC_CPU if PROC_FS
466 + help
467 +diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
468 +index a623cb3ad012..b68c6b22e1c8 100644
469 +--- a/arch/arm/mm/mmu.c
470 ++++ b/arch/arm/mm/mmu.c
471 +@@ -516,6 +516,16 @@ static void __init build_mem_type_table(void)
472 + s2_device_pgprot = mem_types[MT_DEVICE].prot_pte_s2;
473 +
474 + /*
475 ++ * We don't use domains on ARMv6 (since this causes problems with
476 ++ * v6/v7 kernels), so we must use a separate memory type for user
477 ++ * r/o, kernel r/w to map the vectors page.
478 ++ */
479 ++#ifndef CONFIG_ARM_LPAE
480 ++ if (cpu_arch == CPU_ARCH_ARMv6)
481 ++ vecs_pgprot |= L_PTE_MT_VECTORS;
482 ++#endif
483 ++
484 ++ /*
485 + * ARMv6 and above have extended page tables.
486 + */
487 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
488 +diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S
489 +index e3c48a3fe063..ee1d80593958 100644
490 +--- a/arch/arm/mm/proc-macros.S
491 ++++ b/arch/arm/mm/proc-macros.S
492 +@@ -112,13 +112,9 @@
493 + * 100x 1 0 1 r/o no acc
494 + * 10x0 1 0 1 r/o no acc
495 + * 1011 0 0 1 r/w no acc
496 +- * 110x 0 1 0 r/w r/o
497 +- * 11x0 0 1 0 r/w r/o
498 +- * 1111 0 1 1 r/w r/w
499 +- *
500 +- * If !CONFIG_CPU_USE_DOMAINS, the following permissions are changed:
501 + * 110x 1 1 1 r/o r/o
502 + * 11x0 1 1 1 r/o r/o
503 ++ * 1111 0 1 1 r/w r/w
504 + */
505 + .macro armv6_mt_table pfx
506 + \pfx\()_mt_table:
507 +@@ -137,7 +133,7 @@
508 + .long PTE_EXT_TEX(2) @ L_PTE_MT_DEV_NONSHARED
509 + .long 0x00 @ unused
510 + .long 0x00 @ unused
511 +- .long 0x00 @ unused
512 ++ .long PTE_CACHEABLE | PTE_BUFFERABLE | PTE_EXT_APX @ L_PTE_MT_VECTORS
513 + .endm
514 +
515 + .macro armv6_set_pte_ext pfx
516 +@@ -158,24 +154,21 @@
517 +
518 + tst r1, #L_PTE_USER
519 + orrne r3, r3, #PTE_EXT_AP1
520 +-#ifdef CONFIG_CPU_USE_DOMAINS
521 +- @ allow kernel read/write access to read-only user pages
522 + tstne r3, #PTE_EXT_APX
523 +- bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
524 +-#endif
525 ++
526 ++ @ user read-only -> kernel read-only
527 ++ bicne r3, r3, #PTE_EXT_AP0
528 +
529 + tst r1, #L_PTE_XN
530 + orrne r3, r3, #PTE_EXT_XN
531 +
532 +- orr r3, r3, r2
533 ++ eor r3, r3, r2
534 +
535 + tst r1, #L_PTE_YOUNG
536 + tstne r1, #L_PTE_PRESENT
537 + moveq r3, #0
538 +-#ifndef CONFIG_CPU_USE_DOMAINS
539 + tstne r1, #L_PTE_NONE
540 + movne r3, #0
541 +-#endif
542 +
543 + str r3, [r0]
544 + mcr p15, 0, r0, c7, c10, 1 @ flush_pte
545 +diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
546 +index bdd3be4be77a..1f52915f2b28 100644
547 +--- a/arch/arm/mm/proc-v7-2level.S
548 ++++ b/arch/arm/mm/proc-v7-2level.S
549 +@@ -90,21 +90,14 @@ ENTRY(cpu_v7_set_pte_ext)
550 +
551 + tst r1, #L_PTE_USER
552 + orrne r3, r3, #PTE_EXT_AP1
553 +-#ifdef CONFIG_CPU_USE_DOMAINS
554 +- @ allow kernel read/write access to read-only user pages
555 +- tstne r3, #PTE_EXT_APX
556 +- bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
557 +-#endif
558 +
559 + tst r1, #L_PTE_XN
560 + orrne r3, r3, #PTE_EXT_XN
561 +
562 + tst r1, #L_PTE_YOUNG
563 + tstne r1, #L_PTE_VALID
564 +-#ifndef CONFIG_CPU_USE_DOMAINS
565 + eorne r1, r1, #L_PTE_NONE
566 + tstne r1, #L_PTE_NONE
567 +-#endif
568 + moveq r3, #0
569 +
570 + ARM( str r3, [r0, #2048]! )
571 +diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
572 +index aa3917c8b623..acb17e0d5e24 100644
573 +--- a/arch/arm64/include/asm/pgtable.h
574 ++++ b/arch/arm64/include/asm/pgtable.h
575 +@@ -199,7 +199,7 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
576 + pte_t *ptep, pte_t pte)
577 + {
578 + if (pte_valid_user(pte)) {
579 +- if (pte_exec(pte))
580 ++ if (!pte_special(pte) && pte_exec(pte))
581 + __sync_icache_dcache(pte, addr);
582 + if (pte_dirty(pte) && pte_write(pte))
583 + pte_val(pte) &= ~PTE_RDONLY;
584 +@@ -286,11 +286,11 @@ static inline int has_transparent_hugepage(void)
585 + * Mark the prot value as uncacheable and unbufferable.
586 + */
587 + #define pgprot_noncached(prot) \
588 +- __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRnE))
589 ++ __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRnE) | PTE_PXN | PTE_UXN)
590 + #define pgprot_writecombine(prot) \
591 +- __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC))
592 ++ __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN)
593 + #define pgprot_dmacoherent(prot) \
594 +- __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC))
595 ++ __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN)
596 + #define __HAVE_PHYS_MEM_ACCESS_PROT
597 + struct file;
598 + extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
599 +diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h
600 +index bb8eb8a78e67..faa0e1ce59df 100644
601 +--- a/arch/arm64/include/asm/unistd32.h
602 ++++ b/arch/arm64/include/asm/unistd32.h
603 +@@ -404,7 +404,7 @@ __SYSCALL(379, sys_finit_module)
604 + __SYSCALL(380, sys_sched_setattr)
605 + __SYSCALL(381, sys_sched_getattr)
606 +
607 +-#define __NR_compat_syscalls 379
608 ++#define __NR_compat_syscalls 382
609 +
610 + /*
611 + * Compat syscall numbers used by the AArch64 kernel.
612 +diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
613 +index fa9aaf7144b7..1d4706114a45 100644
614 +--- a/arch/s390/include/asm/atomic.h
615 ++++ b/arch/s390/include/asm/atomic.h
616 +@@ -15,23 +15,29 @@
617 +
618 + #include <linux/compiler.h>
619 + #include <linux/types.h>
620 ++#include <asm/barrier.h>
621 + #include <asm/cmpxchg.h>
622 +
623 + #define ATOMIC_INIT(i) { (i) }
624 +
625 ++#define __ATOMIC_NO_BARRIER "\n"
626 ++
627 + #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
628 +
629 + #define __ATOMIC_OR "lao"
630 + #define __ATOMIC_AND "lan"
631 + #define __ATOMIC_ADD "laa"
632 ++#define __ATOMIC_BARRIER "bcr 14,0\n"
633 +
634 +-#define __ATOMIC_LOOP(ptr, op_val, op_string) \
635 ++#define __ATOMIC_LOOP(ptr, op_val, op_string, __barrier) \
636 + ({ \
637 + int old_val; \
638 + \
639 + typecheck(atomic_t *, ptr); \
640 + asm volatile( \
641 ++ __barrier \
642 + op_string " %0,%2,%1\n" \
643 ++ __barrier \
644 + : "=d" (old_val), "+Q" ((ptr)->counter) \
645 + : "d" (op_val) \
646 + : "cc", "memory"); \
647 +@@ -43,8 +49,9 @@
648 + #define __ATOMIC_OR "or"
649 + #define __ATOMIC_AND "nr"
650 + #define __ATOMIC_ADD "ar"
651 ++#define __ATOMIC_BARRIER "\n"
652 +
653 +-#define __ATOMIC_LOOP(ptr, op_val, op_string) \
654 ++#define __ATOMIC_LOOP(ptr, op_val, op_string, __barrier) \
655 + ({ \
656 + int old_val, new_val; \
657 + \
658 +@@ -82,7 +89,7 @@ static inline void atomic_set(atomic_t *v, int i)
659 +
660 + static inline int atomic_add_return(int i, atomic_t *v)
661 + {
662 +- return __ATOMIC_LOOP(v, i, __ATOMIC_ADD) + i;
663 ++ return __ATOMIC_LOOP(v, i, __ATOMIC_ADD, __ATOMIC_BARRIER) + i;
664 + }
665 +
666 + static inline void atomic_add(int i, atomic_t *v)
667 +@@ -94,12 +101,10 @@ static inline void atomic_add(int i, atomic_t *v)
668 + : "+Q" (v->counter)
669 + : "i" (i)
670 + : "cc", "memory");
671 +- } else {
672 +- atomic_add_return(i, v);
673 ++ return;
674 + }
675 +-#else
676 +- atomic_add_return(i, v);
677 + #endif
678 ++ __ATOMIC_LOOP(v, i, __ATOMIC_ADD, __ATOMIC_NO_BARRIER);
679 + }
680 +
681 + #define atomic_add_negative(_i, _v) (atomic_add_return(_i, _v) < 0)
682 +@@ -115,12 +120,12 @@ static inline void atomic_add(int i, atomic_t *v)
683 +
684 + static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
685 + {
686 +- __ATOMIC_LOOP(v, ~mask, __ATOMIC_AND);
687 ++ __ATOMIC_LOOP(v, ~mask, __ATOMIC_AND, __ATOMIC_NO_BARRIER);
688 + }
689 +
690 + static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
691 + {
692 +- __ATOMIC_LOOP(v, mask, __ATOMIC_OR);
693 ++ __ATOMIC_LOOP(v, mask, __ATOMIC_OR, __ATOMIC_NO_BARRIER);
694 + }
695 +
696 + #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
697 +@@ -157,19 +162,24 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
698 +
699 + #ifdef CONFIG_64BIT
700 +
701 ++#define __ATOMIC64_NO_BARRIER "\n"
702 ++
703 + #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
704 +
705 + #define __ATOMIC64_OR "laog"
706 + #define __ATOMIC64_AND "lang"
707 + #define __ATOMIC64_ADD "laag"
708 ++#define __ATOMIC64_BARRIER "bcr 14,0\n"
709 +
710 +-#define __ATOMIC64_LOOP(ptr, op_val, op_string) \
711 ++#define __ATOMIC64_LOOP(ptr, op_val, op_string, __barrier) \
712 + ({ \
713 + long long old_val; \
714 + \
715 + typecheck(atomic64_t *, ptr); \
716 + asm volatile( \
717 ++ __barrier \
718 + op_string " %0,%2,%1\n" \
719 ++ __barrier \
720 + : "=d" (old_val), "+Q" ((ptr)->counter) \
721 + : "d" (op_val) \
722 + : "cc", "memory"); \
723 +@@ -181,8 +191,9 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
724 + #define __ATOMIC64_OR "ogr"
725 + #define __ATOMIC64_AND "ngr"
726 + #define __ATOMIC64_ADD "agr"
727 ++#define __ATOMIC64_BARRIER "\n"
728 +
729 +-#define __ATOMIC64_LOOP(ptr, op_val, op_string) \
730 ++#define __ATOMIC64_LOOP(ptr, op_val, op_string, __barrier) \
731 + ({ \
732 + long long old_val, new_val; \
733 + \
734 +@@ -220,17 +231,32 @@ static inline void atomic64_set(atomic64_t *v, long long i)
735 +
736 + static inline long long atomic64_add_return(long long i, atomic64_t *v)
737 + {
738 +- return __ATOMIC64_LOOP(v, i, __ATOMIC64_ADD) + i;
739 ++ return __ATOMIC64_LOOP(v, i, __ATOMIC64_ADD, __ATOMIC64_BARRIER) + i;
740 ++}
741 ++
742 ++static inline void atomic64_add(long long i, atomic64_t *v)
743 ++{
744 ++#ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
745 ++ if (__builtin_constant_p(i) && (i > -129) && (i < 128)) {
746 ++ asm volatile(
747 ++ "agsi %0,%1\n"
748 ++ : "+Q" (v->counter)
749 ++ : "i" (i)
750 ++ : "cc", "memory");
751 ++ return;
752 ++ }
753 ++#endif
754 ++ __ATOMIC64_LOOP(v, i, __ATOMIC64_ADD, __ATOMIC64_NO_BARRIER);
755 + }
756 +
757 + static inline void atomic64_clear_mask(unsigned long mask, atomic64_t *v)
758 + {
759 +- __ATOMIC64_LOOP(v, ~mask, __ATOMIC64_AND);
760 ++ __ATOMIC64_LOOP(v, ~mask, __ATOMIC64_AND, __ATOMIC64_NO_BARRIER);
761 + }
762 +
763 + static inline void atomic64_set_mask(unsigned long mask, atomic64_t *v)
764 + {
765 +- __ATOMIC64_LOOP(v, mask, __ATOMIC64_OR);
766 ++ __ATOMIC64_LOOP(v, mask, __ATOMIC64_OR, __ATOMIC64_NO_BARRIER);
767 + }
768 +
769 + #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
770 +@@ -334,25 +360,13 @@ static inline void atomic64_clear_mask(unsigned long long mask, atomic64_t *v)
771 + } while (atomic64_cmpxchg(v, old, new) != old);
772 + }
773 +
774 +-#endif /* CONFIG_64BIT */
775 +-
776 + static inline void atomic64_add(long long i, atomic64_t *v)
777 + {
778 +-#ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
779 +- if (__builtin_constant_p(i) && (i > -129) && (i < 128)) {
780 +- asm volatile(
781 +- "agsi %0,%1\n"
782 +- : "+Q" (v->counter)
783 +- : "i" (i)
784 +- : "cc", "memory");
785 +- } else {
786 +- atomic64_add_return(i, v);
787 +- }
788 +-#else
789 + atomic64_add_return(i, v);
790 +-#endif
791 + }
792 +
793 ++#endif /* CONFIG_64BIT */
794 ++
795 + static inline int atomic64_add_unless(atomic64_t *v, long long i, long long u)
796 + {
797 + long long c, old;
798 +diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h
799 +index 6e6ad0680829..4e206123b439 100644
800 +--- a/arch/s390/include/asm/bitops.h
801 ++++ b/arch/s390/include/asm/bitops.h
802 +@@ -47,14 +47,18 @@
803 +
804 + #include <linux/typecheck.h>
805 + #include <linux/compiler.h>
806 ++#include <asm/barrier.h>
807 ++
808 ++#define __BITOPS_NO_BARRIER "\n"
809 +
810 + #ifndef CONFIG_64BIT
811 +
812 + #define __BITOPS_OR "or"
813 + #define __BITOPS_AND "nr"
814 + #define __BITOPS_XOR "xr"
815 ++#define __BITOPS_BARRIER "\n"
816 +
817 +-#define __BITOPS_LOOP(__addr, __val, __op_string) \
818 ++#define __BITOPS_LOOP(__addr, __val, __op_string, __barrier) \
819 + ({ \
820 + unsigned long __old, __new; \
821 + \
822 +@@ -67,7 +71,7 @@
823 + " jl 0b" \
824 + : "=&d" (__old), "=&d" (__new), "+Q" (*(__addr))\
825 + : "d" (__val) \
826 +- : "cc"); \
827 ++ : "cc", "memory"); \
828 + __old; \
829 + })
830 +
831 +@@ -78,17 +82,20 @@
832 + #define __BITOPS_OR "laog"
833 + #define __BITOPS_AND "lang"
834 + #define __BITOPS_XOR "laxg"
835 ++#define __BITOPS_BARRIER "bcr 14,0\n"
836 +
837 +-#define __BITOPS_LOOP(__addr, __val, __op_string) \
838 ++#define __BITOPS_LOOP(__addr, __val, __op_string, __barrier) \
839 + ({ \
840 + unsigned long __old; \
841 + \
842 + typecheck(unsigned long *, (__addr)); \
843 + asm volatile( \
844 ++ __barrier \
845 + __op_string " %0,%2,%1\n" \
846 ++ __barrier \
847 + : "=d" (__old), "+Q" (*(__addr)) \
848 + : "d" (__val) \
849 +- : "cc"); \
850 ++ : "cc", "memory"); \
851 + __old; \
852 + })
853 +
854 +@@ -97,8 +104,9 @@
855 + #define __BITOPS_OR "ogr"
856 + #define __BITOPS_AND "ngr"
857 + #define __BITOPS_XOR "xgr"
858 ++#define __BITOPS_BARRIER "\n"
859 +
860 +-#define __BITOPS_LOOP(__addr, __val, __op_string) \
861 ++#define __BITOPS_LOOP(__addr, __val, __op_string, __barrier) \
862 + ({ \
863 + unsigned long __old, __new; \
864 + \
865 +@@ -111,7 +119,7 @@
866 + " jl 0b" \
867 + : "=&d" (__old), "=&d" (__new), "+Q" (*(__addr))\
868 + : "d" (__val) \
869 +- : "cc"); \
870 ++ : "cc", "memory"); \
871 + __old; \
872 + })
873 +
874 +@@ -149,12 +157,12 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *ptr)
875 + "oi %0,%b1\n"
876 + : "+Q" (*caddr)
877 + : "i" (1 << (nr & 7))
878 +- : "cc");
879 ++ : "cc", "memory");
880 + return;
881 + }
882 + #endif
883 + mask = 1UL << (nr & (BITS_PER_LONG - 1));
884 +- __BITOPS_LOOP(addr, mask, __BITOPS_OR);
885 ++ __BITOPS_LOOP(addr, mask, __BITOPS_OR, __BITOPS_NO_BARRIER);
886 + }
887 +
888 + static inline void clear_bit(unsigned long nr, volatile unsigned long *ptr)
889 +@@ -170,12 +178,12 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *ptr)
890 + "ni %0,%b1\n"
891 + : "+Q" (*caddr)
892 + : "i" (~(1 << (nr & 7)))
893 +- : "cc");
894 ++ : "cc", "memory");
895 + return;
896 + }
897 + #endif
898 + mask = ~(1UL << (nr & (BITS_PER_LONG - 1)));
899 +- __BITOPS_LOOP(addr, mask, __BITOPS_AND);
900 ++ __BITOPS_LOOP(addr, mask, __BITOPS_AND, __BITOPS_NO_BARRIER);
901 + }
902 +
903 + static inline void change_bit(unsigned long nr, volatile unsigned long *ptr)
904 +@@ -191,12 +199,12 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *ptr)
905 + "xi %0,%b1\n"
906 + : "+Q" (*caddr)
907 + : "i" (1 << (nr & 7))
908 +- : "cc");
909 ++ : "cc", "memory");
910 + return;
911 + }
912 + #endif
913 + mask = 1UL << (nr & (BITS_PER_LONG - 1));
914 +- __BITOPS_LOOP(addr, mask, __BITOPS_XOR);
915 ++ __BITOPS_LOOP(addr, mask, __BITOPS_XOR, __BITOPS_NO_BARRIER);
916 + }
917 +
918 + static inline int
919 +@@ -206,8 +214,7 @@ test_and_set_bit(unsigned long nr, volatile unsigned long *ptr)
920 + unsigned long old, mask;
921 +
922 + mask = 1UL << (nr & (BITS_PER_LONG - 1));
923 +- old = __BITOPS_LOOP(addr, mask, __BITOPS_OR);
924 +- barrier();
925 ++ old = __BITOPS_LOOP(addr, mask, __BITOPS_OR, __BITOPS_BARRIER);
926 + return (old & mask) != 0;
927 + }
928 +
929 +@@ -218,8 +225,7 @@ test_and_clear_bit(unsigned long nr, volatile unsigned long *ptr)
930 + unsigned long old, mask;
931 +
932 + mask = ~(1UL << (nr & (BITS_PER_LONG - 1)));
933 +- old = __BITOPS_LOOP(addr, mask, __BITOPS_AND);
934 +- barrier();
935 ++ old = __BITOPS_LOOP(addr, mask, __BITOPS_AND, __BITOPS_BARRIER);
936 + return (old & ~mask) != 0;
937 + }
938 +
939 +@@ -230,8 +236,7 @@ test_and_change_bit(unsigned long nr, volatile unsigned long *ptr)
940 + unsigned long old, mask;
941 +
942 + mask = 1UL << (nr & (BITS_PER_LONG - 1));
943 +- old = __BITOPS_LOOP(addr, mask, __BITOPS_XOR);
944 +- barrier();
945 ++ old = __BITOPS_LOOP(addr, mask, __BITOPS_XOR, __BITOPS_BARRIER);
946 + return (old & mask) != 0;
947 + }
948 +
949 +diff --git a/arch/s390/include/asm/ccwdev.h b/arch/s390/include/asm/ccwdev.h
950 +index f201af8be580..31b5ca8f8c3d 100644
951 +--- a/arch/s390/include/asm/ccwdev.h
952 ++++ b/arch/s390/include/asm/ccwdev.h
953 +@@ -219,7 +219,7 @@ extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
954 + #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
955 + #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
956 +
957 +-extern struct ccw_device *ccw_device_probe_console(void);
958 ++extern struct ccw_device *ccw_device_probe_console(struct ccw_driver *);
959 + extern void ccw_device_wait_idle(struct ccw_device *);
960 + extern int ccw_device_force_console(struct ccw_device *);
961 +
962 +diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
963 +index f6be6087a0e9..a48bc79a111f 100644
964 +--- a/arch/s390/kernel/ptrace.c
965 ++++ b/arch/s390/kernel/ptrace.c
966 +@@ -64,7 +64,7 @@ void update_cr_regs(struct task_struct *task)
967 + if (task->thread.per_flags & PER_FLAG_NO_TE)
968 + cr_new &= ~(1UL << 55);
969 + if (cr_new != cr)
970 +- __ctl_load(cr, 0, 0);
971 ++ __ctl_load(cr_new, 0, 0);
972 + /* Set or clear transaction execution TDC bits 62 and 63. */
973 + __ctl_store(cr, 2, 2);
974 + cr_new = cr & ~3UL;
975 +diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
976 +index e0676f390d57..95f4a976c160 100644
977 +--- a/arch/s390/kvm/kvm-s390.c
978 ++++ b/arch/s390/kvm/kvm-s390.c
979 +@@ -753,7 +753,8 @@ static int vcpu_post_run(struct kvm_vcpu *vcpu, int exit_reason)
980 +
981 + if (rc == 0) {
982 + if (kvm_is_ucontrol(vcpu->kvm))
983 +- rc = -EOPNOTSUPP;
984 ++ /* Don't exit for host interrupts. */
985 ++ rc = vcpu->arch.sie_block->icptcode ? -EOPNOTSUPP : 0;
986 + else
987 + rc = kvm_handle_sie_intercept(vcpu);
988 + }
989 +diff --git a/arch/sh/kernel/dumpstack.c b/arch/sh/kernel/dumpstack.c
990 +index b959f5592604..8dfe645bcc4b 100644
991 +--- a/arch/sh/kernel/dumpstack.c
992 ++++ b/arch/sh/kernel/dumpstack.c
993 +@@ -115,7 +115,7 @@ static int print_trace_stack(void *data, char *name)
994 + */
995 + static void print_trace_address(void *data, unsigned long addr, int reliable)
996 + {
997 +- printk(data);
998 ++ printk("%s", (char *)data);
999 + printk_address(addr, reliable);
1000 + }
1001 +
1002 +diff --git a/arch/x86/Makefile b/arch/x86/Makefile
1003 +index eeda43abed6e..f8842c444560 100644
1004 +--- a/arch/x86/Makefile
1005 ++++ b/arch/x86/Makefile
1006 +@@ -152,6 +152,7 @@ cfi-sections := $(call as-instr,.cfi_sections .debug_frame,-DCONFIG_AS_CFI_SECTI
1007 +
1008 + # does binutils support specific instructions?
1009 + asinstr := $(call as-instr,fxsaveq (%rax),-DCONFIG_AS_FXSAVEQ=1)
1010 ++asinstr += $(call as-instr,crc32l %eax$(comma)%eax,-DCONFIG_AS_CRC32=1)
1011 + avx_instr := $(call as-instr,vxorps %ymm0$(comma)%ymm1$(comma)%ymm2,-DCONFIG_AS_AVX=1)
1012 + avx2_instr :=$(call as-instr,vpbroadcastb %xmm0$(comma)%ymm1,-DCONFIG_AS_AVX2=1)
1013 +
1014 +diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
1015 +index a7677babf946..78cbb2db5a85 100644
1016 +--- a/arch/x86/boot/compressed/eboot.c
1017 ++++ b/arch/x86/boot/compressed/eboot.c
1018 +@@ -425,6 +425,9 @@ void setup_graphics(struct boot_params *boot_params)
1019 + * Because the x86 boot code expects to be passed a boot_params we
1020 + * need to create one ourselves (usually the bootloader would create
1021 + * one for us).
1022 ++ *
1023 ++ * The caller is responsible for filling out ->code32_start in the
1024 ++ * returned boot_params.
1025 + */
1026 + struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table)
1027 + {
1028 +@@ -483,8 +486,6 @@ struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table)
1029 + hdr->vid_mode = 0xffff;
1030 + hdr->boot_flag = 0xAA55;
1031 +
1032 +- hdr->code32_start = (__u64)(unsigned long)image->image_base;
1033 +-
1034 + hdr->type_of_loader = 0x21;
1035 +
1036 + /* Convert unicode cmdline to ascii */
1037 +diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
1038 +index 9116aac232c7..f45ab7a36fb6 100644
1039 +--- a/arch/x86/boot/compressed/head_32.S
1040 ++++ b/arch/x86/boot/compressed/head_32.S
1041 +@@ -50,6 +50,13 @@ ENTRY(efi_pe_entry)
1042 + pushl %eax
1043 + pushl %esi
1044 + pushl %ecx
1045 ++
1046 ++ call reloc
1047 ++reloc:
1048 ++ popl %ecx
1049 ++ subl reloc, %ecx
1050 ++ movl %ecx, BP_code32_start(%eax)
1051 ++
1052 + sub $0x4, %esp
1053 +
1054 + ENTRY(efi_stub_entry)
1055 +@@ -63,12 +70,7 @@ ENTRY(efi_stub_entry)
1056 + hlt
1057 + jmp 1b
1058 + 2:
1059 +- call 3f
1060 +-3:
1061 +- popl %eax
1062 +- subl $3b, %eax
1063 +- subl BP_pref_address(%esi), %eax
1064 +- add BP_code32_start(%esi), %eax
1065 ++ movl BP_code32_start(%esi), %eax
1066 + leal preferred_addr(%eax), %eax
1067 + jmp *%eax
1068 +
1069 +diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
1070 +index c5c1ae0997e7..b10fa66a2540 100644
1071 +--- a/arch/x86/boot/compressed/head_64.S
1072 ++++ b/arch/x86/boot/compressed/head_64.S
1073 +@@ -217,6 +217,8 @@ ENTRY(efi_pe_entry)
1074 + cmpq $0,%rax
1075 + je 1f
1076 + mov %rax, %rdx
1077 ++ leaq startup_32(%rip), %rax
1078 ++ movl %eax, BP_code32_start(%rdx)
1079 + popq %rsi
1080 + popq %rdi
1081 +
1082 +@@ -230,12 +232,7 @@ ENTRY(efi_stub_entry)
1083 + hlt
1084 + jmp 1b
1085 + 2:
1086 +- call 3f
1087 +-3:
1088 +- popq %rax
1089 +- subq $3b, %rax
1090 +- subq BP_pref_address(%rsi), %rax
1091 +- add BP_code32_start(%esi), %eax
1092 ++ movl BP_code32_start(%esi), %eax
1093 + leaq preferred_addr(%rax), %rax
1094 + jmp *%rax
1095 +
1096 +diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
1097 +index e099f9502ace..5f1296872aed 100644
1098 +--- a/arch/x86/include/asm/cpufeature.h
1099 ++++ b/arch/x86/include/asm/cpufeature.h
1100 +@@ -217,9 +217,13 @@
1101 + #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
1102 + #define X86_FEATURE_RTM (9*32+11) /* Restricted Transactional Memory */
1103 + #define X86_FEATURE_MPX (9*32+14) /* Memory Protection Extension */
1104 ++#define X86_FEATURE_AVX512F (9*32+16) /* AVX-512 Foundation */
1105 + #define X86_FEATURE_RDSEED (9*32+18) /* The RDSEED instruction */
1106 + #define X86_FEATURE_ADX (9*32+19) /* The ADCX and ADOX instructions */
1107 + #define X86_FEATURE_SMAP (9*32+20) /* Supervisor Mode Access Prevention */
1108 ++#define X86_FEATURE_AVX512PF (9*32+26) /* AVX-512 Prefetch */
1109 ++#define X86_FEATURE_AVX512ER (9*32+27) /* AVX-512 Exponential and Reciprocal */
1110 ++#define X86_FEATURE_AVX512CD (9*32+28) /* AVX-512 Conflict Detection */
1111 +
1112 + /*
1113 + * BUG word(s)
1114 +diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
1115 +index 554738963b28..6c1d7411eb00 100644
1116 +--- a/arch/x86/include/asm/xsave.h
1117 ++++ b/arch/x86/include/asm/xsave.h
1118 +@@ -6,11 +6,14 @@
1119 +
1120 + #define XSTATE_CPUID 0x0000000d
1121 +
1122 +-#define XSTATE_FP 0x1
1123 +-#define XSTATE_SSE 0x2
1124 +-#define XSTATE_YMM 0x4
1125 +-#define XSTATE_BNDREGS 0x8
1126 +-#define XSTATE_BNDCSR 0x10
1127 ++#define XSTATE_FP 0x1
1128 ++#define XSTATE_SSE 0x2
1129 ++#define XSTATE_YMM 0x4
1130 ++#define XSTATE_BNDREGS 0x8
1131 ++#define XSTATE_BNDCSR 0x10
1132 ++#define XSTATE_OPMASK 0x20
1133 ++#define XSTATE_ZMM_Hi256 0x40
1134 ++#define XSTATE_Hi16_ZMM 0x80
1135 +
1136 + #define XSTATE_FPSSE (XSTATE_FP | XSTATE_SSE)
1137 +
1138 +@@ -23,7 +26,8 @@
1139 + #define XSAVE_YMM_OFFSET (XSAVE_HDR_SIZE + XSAVE_HDR_OFFSET)
1140 +
1141 + /* Supported features which support lazy state saving */
1142 +-#define XSTATE_LAZY (XSTATE_FP | XSTATE_SSE | XSTATE_YMM)
1143 ++#define XSTATE_LAZY (XSTATE_FP | XSTATE_SSE | XSTATE_YMM \
1144 ++ | XSTATE_OPMASK | XSTATE_ZMM_Hi256 | XSTATE_Hi16_ZMM)
1145 +
1146 + /* Supported features which require eager state saving */
1147 + #define XSTATE_EAGER (XSTATE_BNDREGS | XSTATE_BNDCSR)
1148 +diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
1149 +index e6253195a301..1ffc32dbe450 100644
1150 +--- a/arch/x86/kernel/ftrace.c
1151 ++++ b/arch/x86/kernel/ftrace.c
1152 +@@ -659,8 +659,8 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
1153 + ret = -EPERM;
1154 + goto out;
1155 + }
1156 +- run_sync();
1157 + out:
1158 ++ run_sync();
1159 + return ret;
1160 +
1161 + fail_update:
1162 +diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
1163 +index ebc987398923..af1d14a9ebda 100644
1164 +--- a/arch/x86/kernel/ldt.c
1165 ++++ b/arch/x86/kernel/ldt.c
1166 +@@ -229,6 +229,17 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
1167 + }
1168 + }
1169 +
1170 ++ /*
1171 ++ * On x86-64 we do not support 16-bit segments due to
1172 ++ * IRET leaking the high bits of the kernel stack address.
1173 ++ */
1174 ++#ifdef CONFIG_X86_64
1175 ++ if (!ldt_info.seg_32bit) {
1176 ++ error = -EINVAL;
1177 ++ goto out_unlock;
1178 ++ }
1179 ++#endif
1180 ++
1181 + fill_ldt(&ldt, &ldt_info);
1182 + if (oldmode)
1183 + ldt.avl = 0;
1184 +diff --git a/arch/x86/lib/hash.c b/arch/x86/lib/hash.c
1185 +index 3056702e81fb..060cc4415bd9 100644
1186 +--- a/arch/x86/lib/hash.c
1187 ++++ b/arch/x86/lib/hash.c
1188 +@@ -39,7 +39,11 @@
1189 +
1190 + static inline u32 crc32_u32(u32 crc, u32 val)
1191 + {
1192 ++#ifdef CONFIG_AS_CRC32
1193 + asm ("crc32l %1,%0\n" : "+r" (crc) : "rm" (val));
1194 ++#else
1195 ++ asm (".byte 0xf2, 0x0f, 0x38, 0xf1, 0xc1" : "+a" (crc) : "c" (val));
1196 ++#endif
1197 + return crc;
1198 + }
1199 +
1200 +diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
1201 +index a05afff50eb9..b6f6863c07f9 100644
1202 +--- a/drivers/acpi/acpica/nsrepair.c
1203 ++++ b/drivers/acpi/acpica/nsrepair.c
1204 +@@ -207,13 +207,30 @@ acpi_ns_simple_repair(struct acpi_evaluate_info *info,
1205 + * this predefined name. Either one return value is expected, or none,
1206 + * for both methods and other objects.
1207 + *
1208 +- * Exit now if there is no return object. Warning if one was expected.
1209 ++ * Try to fix if there was no return object. Warning if failed to fix.
1210 + */
1211 + if (!return_object) {
1212 + if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) {
1213 +- ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
1214 +- ACPI_WARN_ALWAYS,
1215 +- "Missing expected return value"));
1216 ++ if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
1217 ++ ACPI_WARN_PREDEFINED((AE_INFO,
1218 ++ info->full_pathname,
1219 ++ ACPI_WARN_ALWAYS,
1220 ++ "Found unexpected NULL package element"));
1221 ++
1222 ++ status =
1223 ++ acpi_ns_repair_null_element(info,
1224 ++ expected_btypes,
1225 ++ package_index,
1226 ++ return_object_ptr);
1227 ++ if (ACPI_SUCCESS(status)) {
1228 ++ return (AE_OK); /* Repair was successful */
1229 ++ }
1230 ++ } else {
1231 ++ ACPI_WARN_PREDEFINED((AE_INFO,
1232 ++ info->full_pathname,
1233 ++ ACPI_WARN_ALWAYS,
1234 ++ "Missing expected return value"));
1235 ++ }
1236 +
1237 + return (AE_AML_NO_RETURN_VALUE);
1238 + }
1239 +diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
1240 +index d777bb7cea93..a8939b98f9c3 100644
1241 +--- a/drivers/block/mtip32xx/mtip32xx.c
1242 ++++ b/drivers/block/mtip32xx/mtip32xx.c
1243 +@@ -252,38 +252,45 @@ static void mtip_async_complete(struct mtip_port *port,
1244 + void *data,
1245 + int status)
1246 + {
1247 +- struct mtip_cmd *command;
1248 ++ struct mtip_cmd *cmd;
1249 + struct driver_data *dd = data;
1250 +- int cb_status = status ? -EIO : 0;
1251 ++ int unaligned, cb_status = status ? -EIO : 0;
1252 ++ void (*func)(void *, int);
1253 +
1254 + if (unlikely(!dd) || unlikely(!port))
1255 + return;
1256 +
1257 +- command = &port->commands[tag];
1258 ++ cmd = &port->commands[tag];
1259 +
1260 + if (unlikely(status == PORT_IRQ_TF_ERR)) {
1261 + dev_warn(&port->dd->pdev->dev,
1262 + "Command tag %d failed due to TFE\n", tag);
1263 + }
1264 +
1265 ++ /* Clear the active flag */
1266 ++ atomic_set(&port->commands[tag].active, 0);
1267 ++
1268 + /* Upper layer callback */
1269 +- if (likely(command->async_callback))
1270 +- command->async_callback(command->async_data, cb_status);
1271 ++ func = cmd->async_callback;
1272 ++ if (likely(func && cmpxchg(&cmd->async_callback, func, 0) == func)) {
1273 +
1274 +- command->async_callback = NULL;
1275 +- command->comp_func = NULL;
1276 ++ /* Unmap the DMA scatter list entries */
1277 ++ dma_unmap_sg(&dd->pdev->dev,
1278 ++ cmd->sg,
1279 ++ cmd->scatter_ents,
1280 ++ cmd->direction);
1281 +
1282 +- /* Unmap the DMA scatter list entries */
1283 +- dma_unmap_sg(&dd->pdev->dev,
1284 +- command->sg,
1285 +- command->scatter_ents,
1286 +- command->direction);
1287 ++ func(cmd->async_data, cb_status);
1288 ++ unaligned = cmd->unaligned;
1289 +
1290 +- /* Clear the allocated and active bits for the command */
1291 +- atomic_set(&port->commands[tag].active, 0);
1292 +- release_slot(port, tag);
1293 ++ /* Clear the allocated bit for the command */
1294 ++ release_slot(port, tag);
1295 +
1296 +- up(&port->cmd_slot);
1297 ++ if (unlikely(unaligned))
1298 ++ up(&port->cmd_slot_unal);
1299 ++ else
1300 ++ up(&port->cmd_slot);
1301 ++ }
1302 + }
1303 +
1304 + /*
1305 +@@ -660,11 +667,12 @@ static void mtip_timeout_function(unsigned long int data)
1306 + {
1307 + struct mtip_port *port = (struct mtip_port *) data;
1308 + struct host_to_dev_fis *fis;
1309 +- struct mtip_cmd *command;
1310 +- int tag, cmdto_cnt = 0;
1311 ++ struct mtip_cmd *cmd;
1312 ++ int unaligned, tag, cmdto_cnt = 0;
1313 + unsigned int bit, group;
1314 + unsigned int num_command_slots;
1315 + unsigned long to, tagaccum[SLOTBITS_IN_LONGS];
1316 ++ void (*func)(void *, int);
1317 +
1318 + if (unlikely(!port))
1319 + return;
1320 +@@ -694,8 +702,8 @@ static void mtip_timeout_function(unsigned long int data)
1321 + group = tag >> 5;
1322 + bit = tag & 0x1F;
1323 +
1324 +- command = &port->commands[tag];
1325 +- fis = (struct host_to_dev_fis *) command->command;
1326 ++ cmd = &port->commands[tag];
1327 ++ fis = (struct host_to_dev_fis *) cmd->command;
1328 +
1329 + set_bit(tag, tagaccum);
1330 + cmdto_cnt++;
1331 +@@ -709,27 +717,30 @@ static void mtip_timeout_function(unsigned long int data)
1332 + */
1333 + writel(1 << bit, port->completed[group]);
1334 +
1335 +- /* Call the async completion callback. */
1336 +- if (likely(command->async_callback))
1337 +- command->async_callback(command->async_data,
1338 +- -EIO);
1339 +- command->async_callback = NULL;
1340 +- command->comp_func = NULL;
1341 ++ /* Clear the active flag for the command */
1342 ++ atomic_set(&port->commands[tag].active, 0);
1343 +
1344 +- /* Unmap the DMA scatter list entries */
1345 +- dma_unmap_sg(&port->dd->pdev->dev,
1346 +- command->sg,
1347 +- command->scatter_ents,
1348 +- command->direction);
1349 ++ func = cmd->async_callback;
1350 ++ if (func &&
1351 ++ cmpxchg(&cmd->async_callback, func, 0) == func) {
1352 +
1353 +- /*
1354 +- * Clear the allocated bit and active tag for the
1355 +- * command.
1356 +- */
1357 +- atomic_set(&port->commands[tag].active, 0);
1358 +- release_slot(port, tag);
1359 ++ /* Unmap the DMA scatter list entries */
1360 ++ dma_unmap_sg(&port->dd->pdev->dev,
1361 ++ cmd->sg,
1362 ++ cmd->scatter_ents,
1363 ++ cmd->direction);
1364 +
1365 +- up(&port->cmd_slot);
1366 ++ func(cmd->async_data, -EIO);
1367 ++ unaligned = cmd->unaligned;
1368 ++
1369 ++ /* Clear the allocated bit for the command. */
1370 ++ release_slot(port, tag);
1371 ++
1372 ++ if (unaligned)
1373 ++ up(&port->cmd_slot_unal);
1374 ++ else
1375 ++ up(&port->cmd_slot);
1376 ++ }
1377 + }
1378 + }
1379 +
1380 +@@ -4213,6 +4224,7 @@ skip_create_disk:
1381 + blk_queue_max_hw_sectors(dd->queue, 0xffff);
1382 + blk_queue_max_segment_size(dd->queue, 0x400000);
1383 + blk_queue_io_min(dd->queue, 4096);
1384 ++ blk_queue_bounce_limit(dd->queue, dd->pdev->dma_mask);
1385 +
1386 + /*
1387 + * write back cache is not supported in the device. FUA depends on
1388 +diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h
1389 +index 54174cb32feb..ffb955e7ccb9 100644
1390 +--- a/drivers/block/mtip32xx/mtip32xx.h
1391 ++++ b/drivers/block/mtip32xx/mtip32xx.h
1392 +@@ -92,7 +92,7 @@
1393 +
1394 + /* Driver name and version strings */
1395 + #define MTIP_DRV_NAME "mtip32xx"
1396 +-#define MTIP_DRV_VERSION "1.3.0"
1397 ++#define MTIP_DRV_VERSION "1.3.1"
1398 +
1399 + /* Maximum number of minor device numbers per device. */
1400 + #define MTIP_MAX_MINORS 16
1401 +diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c
1402 +index 00a3abe103a5..27c83e45eaed 100644
1403 +--- a/drivers/clk/clk-s2mps11.c
1404 ++++ b/drivers/clk/clk-s2mps11.c
1405 +@@ -130,7 +130,7 @@ static struct device_node *s2mps11_clk_parse_dt(struct platform_device *pdev)
1406 + int i;
1407 +
1408 + if (!iodev->dev->of_node)
1409 +- return NULL;
1410 ++ return ERR_PTR(-EINVAL);
1411 +
1412 + clk_np = of_find_node_by_name(iodev->dev->of_node, "clocks");
1413 + if (!clk_np) {
1414 +diff --git a/drivers/clk/tegra/clk-tegra124.c b/drivers/clk/tegra/clk-tegra124.c
1415 +index 166e02f16c8a..cc37c342c4cb 100644
1416 +--- a/drivers/clk/tegra/clk-tegra124.c
1417 ++++ b/drivers/clk/tegra/clk-tegra124.c
1418 +@@ -764,7 +764,6 @@ static struct tegra_clk tegra124_clks[tegra_clk_max] __initdata = {
1419 + [tegra_clk_sdmmc2_8] = { .dt_id = TEGRA124_CLK_SDMMC2, .present = true },
1420 + [tegra_clk_i2s1] = { .dt_id = TEGRA124_CLK_I2S1, .present = true },
1421 + [tegra_clk_i2c1] = { .dt_id = TEGRA124_CLK_I2C1, .present = true },
1422 +- [tegra_clk_ndflash] = { .dt_id = TEGRA124_CLK_NDFLASH, .present = true },
1423 + [tegra_clk_sdmmc1_8] = { .dt_id = TEGRA124_CLK_SDMMC1, .present = true },
1424 + [tegra_clk_sdmmc4_8] = { .dt_id = TEGRA124_CLK_SDMMC4, .present = true },
1425 + [tegra_clk_pwm] = { .dt_id = TEGRA124_CLK_PWM, .present = true },
1426 +@@ -809,7 +808,6 @@ static struct tegra_clk tegra124_clks[tegra_clk_max] __initdata = {
1427 + [tegra_clk_trace] = { .dt_id = TEGRA124_CLK_TRACE, .present = true },
1428 + [tegra_clk_soc_therm] = { .dt_id = TEGRA124_CLK_SOC_THERM, .present = true },
1429 + [tegra_clk_dtv] = { .dt_id = TEGRA124_CLK_DTV, .present = true },
1430 +- [tegra_clk_ndspeed] = { .dt_id = TEGRA124_CLK_NDSPEED, .present = true },
1431 + [tegra_clk_i2cslow] = { .dt_id = TEGRA124_CLK_I2CSLOW, .present = true },
1432 + [tegra_clk_dsib] = { .dt_id = TEGRA124_CLK_DSIB, .present = true },
1433 + [tegra_clk_tsec] = { .dt_id = TEGRA124_CLK_TSEC, .present = true },
1434 +@@ -952,7 +950,6 @@ static struct tegra_clk tegra124_clks[tegra_clk_max] __initdata = {
1435 + [tegra_clk_clk_out_3_mux] = { .dt_id = TEGRA124_CLK_CLK_OUT_3_MUX, .present = true },
1436 + [tegra_clk_dsia_mux] = { .dt_id = TEGRA124_CLK_DSIA_MUX, .present = true },
1437 + [tegra_clk_dsib_mux] = { .dt_id = TEGRA124_CLK_DSIB_MUX, .present = true },
1438 +- [tegra_clk_uarte] = { .dt_id = TEGRA124_CLK_UARTE, .present = true },
1439 + };
1440 +
1441 + static struct tegra_devclk devclks[] __initdata = {
1442 +diff --git a/drivers/clk/ti/clk-44xx.c b/drivers/clk/ti/clk-44xx.c
1443 +index ae00218b5da3..02517a8206bd 100644
1444 +--- a/drivers/clk/ti/clk-44xx.c
1445 ++++ b/drivers/clk/ti/clk-44xx.c
1446 +@@ -222,7 +222,6 @@ static struct ti_dt_clk omap44xx_clks[] = {
1447 + DT_CLK(NULL, "auxclk5_src_ck", "auxclk5_src_ck"),
1448 + DT_CLK(NULL, "auxclk5_ck", "auxclk5_ck"),
1449 + DT_CLK(NULL, "auxclkreq5_ck", "auxclkreq5_ck"),
1450 +- DT_CLK("50000000.gpmc", "fck", "dummy_ck"),
1451 + DT_CLK("omap_i2c.1", "ick", "dummy_ck"),
1452 + DT_CLK("omap_i2c.2", "ick", "dummy_ck"),
1453 + DT_CLK("omap_i2c.3", "ick", "dummy_ck"),
1454 +diff --git a/drivers/clk/ti/clk-54xx.c b/drivers/clk/ti/clk-54xx.c
1455 +index 0ef9f581286b..08f3d1b915b3 100644
1456 +--- a/drivers/clk/ti/clk-54xx.c
1457 ++++ b/drivers/clk/ti/clk-54xx.c
1458 +@@ -182,7 +182,6 @@ static struct ti_dt_clk omap54xx_clks[] = {
1459 + DT_CLK(NULL, "auxclk3_src_ck", "auxclk3_src_ck"),
1460 + DT_CLK(NULL, "auxclk3_ck", "auxclk3_ck"),
1461 + DT_CLK(NULL, "auxclkreq3_ck", "auxclkreq3_ck"),
1462 +- DT_CLK(NULL, "gpmc_ck", "dummy_ck"),
1463 + DT_CLK("omap_i2c.1", "ick", "dummy_ck"),
1464 + DT_CLK("omap_i2c.2", "ick", "dummy_ck"),
1465 + DT_CLK("omap_i2c.3", "ick", "dummy_ck"),
1466 +diff --git a/drivers/clk/ti/clk-7xx.c b/drivers/clk/ti/clk-7xx.c
1467 +index 9977653f2d63..f7e40734c819 100644
1468 +--- a/drivers/clk/ti/clk-7xx.c
1469 ++++ b/drivers/clk/ti/clk-7xx.c
1470 +@@ -262,7 +262,6 @@ static struct ti_dt_clk dra7xx_clks[] = {
1471 + DT_CLK(NULL, "vip1_gclk_mux", "vip1_gclk_mux"),
1472 + DT_CLK(NULL, "vip2_gclk_mux", "vip2_gclk_mux"),
1473 + DT_CLK(NULL, "vip3_gclk_mux", "vip3_gclk_mux"),
1474 +- DT_CLK(NULL, "gpmc_ck", "dummy_ck"),
1475 + DT_CLK("omap_i2c.1", "ick", "dummy_ck"),
1476 + DT_CLK("omap_i2c.2", "ick", "dummy_ck"),
1477 + DT_CLK("omap_i2c.3", "ick", "dummy_ck"),
1478 +diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c
1479 +index b6bffbfd3be7..3a74def216a5 100644
1480 +--- a/drivers/firmware/efi/efi-stub-helper.c
1481 ++++ b/drivers/firmware/efi/efi-stub-helper.c
1482 +@@ -468,7 +468,7 @@ grow:
1483 + chunksize = EFI_READ_CHUNK_SIZE;
1484 + else
1485 + chunksize = size;
1486 +- status = efi_call_phys3(fh->read,
1487 ++ status = efi_call_phys3(files[j].handle->read,
1488 + files[j].handle,
1489 + &chunksize,
1490 + (void *)addr);
1491 +@@ -480,7 +480,7 @@ grow:
1492 + size -= chunksize;
1493 + }
1494 +
1495 +- efi_call_phys1(fh->close, files[j].handle);
1496 ++ efi_call_phys1(files[j].handle->close, files[j].handle);
1497 + }
1498 +
1499 + }
1500 +@@ -497,7 +497,7 @@ free_file_total:
1501 +
1502 + close_handles:
1503 + for (k = j; k < i; k++)
1504 +- efi_call_phys1(fh->close, files[k].handle);
1505 ++ efi_call_phys1(files[k].handle->close, files[k].handle);
1506 + free_files:
1507 + efi_call_phys1(sys_table_arg->boottime->free_pool, files);
1508 + fail:
1509 +diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
1510 +index d8e398275ca8..66a492aa4f1e 100644
1511 +--- a/drivers/gpu/drm/armada/armada_crtc.c
1512 ++++ b/drivers/gpu/drm/armada/armada_crtc.c
1513 +@@ -678,6 +678,7 @@ static void armada_load_cursor_argb(void __iomem *base, uint32_t *pix,
1514 + base + LCD_SPU_SRAM_WRDAT);
1515 + writel_relaxed(addr | SRAM_WRITE,
1516 + base + LCD_SPU_SRAM_CTRL);
1517 ++ readl_relaxed(base + LCD_SPU_HWC_OVSA_HPXL_VLN);
1518 + addr += 1;
1519 + if ((addr & 0x00ff) == 0)
1520 + addr += 0xf00;
1521 +diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
1522 +index f2d7bf90c9fe..2e7801af466e 100644
1523 +--- a/drivers/hv/connection.c
1524 ++++ b/drivers/hv/connection.c
1525 +@@ -55,6 +55,9 @@ static __u32 vmbus_get_next_version(__u32 current_version)
1526 + case (VERSION_WIN8):
1527 + return VERSION_WIN7;
1528 +
1529 ++ case (VERSION_WIN8_1):
1530 ++ return VERSION_WIN8;
1531 ++
1532 + case (VERSION_WS2008):
1533 + default:
1534 + return VERSION_INVAL;
1535 +@@ -77,7 +80,7 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo,
1536 + msg->interrupt_page = virt_to_phys(vmbus_connection.int_page);
1537 + msg->monitor_page1 = virt_to_phys(vmbus_connection.monitor_pages[0]);
1538 + msg->monitor_page2 = virt_to_phys(vmbus_connection.monitor_pages[1]);
1539 +- if (version == VERSION_WIN8)
1540 ++ if (version == VERSION_WIN8_1)
1541 + msg->target_vcpu = hv_context.vp_index[smp_processor_id()];
1542 +
1543 + /*
1544 +diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
1545 +index 5b1aa027c034..bbba014c9939 100644
1546 +--- a/drivers/iio/adc/at91_adc.c
1547 ++++ b/drivers/iio/adc/at91_adc.c
1548 +@@ -765,14 +765,17 @@ static int at91_adc_probe_pdata(struct at91_adc_state *st,
1549 + if (!pdata)
1550 + return -EINVAL;
1551 +
1552 ++ st->caps = (struct at91_adc_caps *)
1553 ++ platform_get_device_id(pdev)->driver_data;
1554 ++
1555 + st->use_external = pdata->use_external_triggers;
1556 + st->vref_mv = pdata->vref;
1557 + st->channels_mask = pdata->channels_used;
1558 +- st->num_channels = pdata->num_channels;
1559 ++ st->num_channels = st->caps->num_channels;
1560 + st->startup_time = pdata->startup_time;
1561 + st->trigger_number = pdata->trigger_number;
1562 + st->trigger_list = pdata->trigger_list;
1563 +- st->registers = pdata->registers;
1564 ++ st->registers = &st->caps->registers;
1565 +
1566 + return 0;
1567 + }
1568 +@@ -1101,7 +1104,6 @@ static int at91_adc_remove(struct platform_device *pdev)
1569 + return 0;
1570 + }
1571 +
1572 +-#ifdef CONFIG_OF
1573 + static struct at91_adc_caps at91sam9260_caps = {
1574 + .calc_startup_ticks = calc_startup_ticks_9260,
1575 + .num_channels = 4,
1576 +@@ -1154,11 +1156,27 @@ static const struct of_device_id at91_adc_dt_ids[] = {
1577 + {},
1578 + };
1579 + MODULE_DEVICE_TABLE(of, at91_adc_dt_ids);
1580 +-#endif
1581 ++
1582 ++static const struct platform_device_id at91_adc_ids[] = {
1583 ++ {
1584 ++ .name = "at91sam9260-adc",
1585 ++ .driver_data = (unsigned long)&at91sam9260_caps,
1586 ++ }, {
1587 ++ .name = "at91sam9g45-adc",
1588 ++ .driver_data = (unsigned long)&at91sam9g45_caps,
1589 ++ }, {
1590 ++ .name = "at91sam9x5-adc",
1591 ++ .driver_data = (unsigned long)&at91sam9x5_caps,
1592 ++ }, {
1593 ++ /* terminator */
1594 ++ }
1595 ++};
1596 ++MODULE_DEVICE_TABLE(platform, at91_adc_ids);
1597 +
1598 + static struct platform_driver at91_adc_driver = {
1599 + .probe = at91_adc_probe,
1600 + .remove = at91_adc_remove,
1601 ++ .id_table = at91_adc_ids,
1602 + .driver = {
1603 + .name = DRIVER_NAME,
1604 + .of_match_table = of_match_ptr(at91_adc_dt_ids),
1605 +diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
1606 +index c67d83bdc8f0..fe25042f056a 100644
1607 +--- a/drivers/iio/industrialio-buffer.c
1608 ++++ b/drivers/iio/industrialio-buffer.c
1609 +@@ -165,7 +165,8 @@ static ssize_t iio_scan_el_show(struct device *dev,
1610 + int ret;
1611 + struct iio_dev *indio_dev = dev_to_iio_dev(dev);
1612 +
1613 +- ret = test_bit(to_iio_dev_attr(attr)->address,
1614 ++ /* Ensure ret is 0 or 1. */
1615 ++ ret = !!test_bit(to_iio_dev_attr(attr)->address,
1616 + indio_dev->buffer->scan_mask);
1617 +
1618 + return sprintf(buf, "%d\n", ret);
1619 +@@ -866,7 +867,8 @@ int iio_scan_mask_query(struct iio_dev *indio_dev,
1620 + if (!buffer->scan_mask)
1621 + return 0;
1622 +
1623 +- return test_bit(bit, buffer->scan_mask);
1624 ++ /* Ensure return value is 0 or 1. */
1625 ++ return !!test_bit(bit, buffer->scan_mask);
1626 + };
1627 + EXPORT_SYMBOL_GPL(iio_scan_mask_query);
1628 +
1629 +diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
1630 +index 47a6dbac2d0c..d976e6ce60db 100644
1631 +--- a/drivers/iio/light/cm32181.c
1632 ++++ b/drivers/iio/light/cm32181.c
1633 +@@ -221,6 +221,7 @@ static int cm32181_read_raw(struct iio_dev *indio_dev,
1634 + *val = cm32181->calibscale;
1635 + return IIO_VAL_INT;
1636 + case IIO_CHAN_INFO_INT_TIME:
1637 ++ *val = 0;
1638 + ret = cm32181_read_als_it(cm32181, val2);
1639 + return ret;
1640 + }
1641 +diff --git a/drivers/iio/light/cm36651.c b/drivers/iio/light/cm36651.c
1642 +index a45e07492db3..39fc67e82138 100644
1643 +--- a/drivers/iio/light/cm36651.c
1644 ++++ b/drivers/iio/light/cm36651.c
1645 +@@ -652,7 +652,19 @@ static int cm36651_probe(struct i2c_client *client,
1646 + cm36651->client = client;
1647 + cm36651->ps_client = i2c_new_dummy(client->adapter,
1648 + CM36651_I2C_ADDR_PS);
1649 ++ if (!cm36651->ps_client) {
1650 ++ dev_err(&client->dev, "%s: new i2c device failed\n", __func__);
1651 ++ ret = -ENODEV;
1652 ++ goto error_disable_reg;
1653 ++ }
1654 ++
1655 + cm36651->ara_client = i2c_new_dummy(client->adapter, CM36651_ARA);
1656 ++ if (!cm36651->ara_client) {
1657 ++ dev_err(&client->dev, "%s: new i2c device failed\n", __func__);
1658 ++ ret = -ENODEV;
1659 ++ goto error_i2c_unregister_ps;
1660 ++ }
1661 ++
1662 + mutex_init(&cm36651->lock);
1663 + indio_dev->dev.parent = &client->dev;
1664 + indio_dev->channels = cm36651_channels;
1665 +@@ -664,7 +676,7 @@ static int cm36651_probe(struct i2c_client *client,
1666 + ret = cm36651_setup_reg(cm36651);
1667 + if (ret) {
1668 + dev_err(&client->dev, "%s: register setup failed\n", __func__);
1669 +- goto error_disable_reg;
1670 ++ goto error_i2c_unregister_ara;
1671 + }
1672 +
1673 + ret = request_threaded_irq(client->irq, NULL, cm36651_irq_handler,
1674 +@@ -672,7 +684,7 @@ static int cm36651_probe(struct i2c_client *client,
1675 + "cm36651", indio_dev);
1676 + if (ret) {
1677 + dev_err(&client->dev, "%s: request irq failed\n", __func__);
1678 +- goto error_disable_reg;
1679 ++ goto error_i2c_unregister_ara;
1680 + }
1681 +
1682 + ret = iio_device_register(indio_dev);
1683 +@@ -685,6 +697,10 @@ static int cm36651_probe(struct i2c_client *client,
1684 +
1685 + error_free_irq:
1686 + free_irq(client->irq, indio_dev);
1687 ++error_i2c_unregister_ara:
1688 ++ i2c_unregister_device(cm36651->ara_client);
1689 ++error_i2c_unregister_ps:
1690 ++ i2c_unregister_device(cm36651->ps_client);
1691 + error_disable_reg:
1692 + regulator_disable(cm36651->vled_reg);
1693 + return ret;
1694 +@@ -698,6 +714,8 @@ static int cm36651_remove(struct i2c_client *client)
1695 + iio_device_unregister(indio_dev);
1696 + regulator_disable(cm36651->vled_reg);
1697 + free_irq(client->irq, indio_dev);
1698 ++ i2c_unregister_device(cm36651->ps_client);
1699 ++ i2c_unregister_device(cm36651->ara_client);
1700 +
1701 + return 0;
1702 + }
1703 +diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
1704 +index 0601b9daf840..c3239170d8b7 100644
1705 +--- a/drivers/infiniband/core/cm.c
1706 ++++ b/drivers/infiniband/core/cm.c
1707 +@@ -349,23 +349,6 @@ static void cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc,
1708 + grh, &av->ah_attr);
1709 + }
1710 +
1711 +-int ib_update_cm_av(struct ib_cm_id *id, const u8 *smac, const u8 *alt_smac)
1712 +-{
1713 +- struct cm_id_private *cm_id_priv;
1714 +-
1715 +- cm_id_priv = container_of(id, struct cm_id_private, id);
1716 +-
1717 +- if (smac != NULL)
1718 +- memcpy(cm_id_priv->av.smac, smac, sizeof(cm_id_priv->av.smac));
1719 +-
1720 +- if (alt_smac != NULL)
1721 +- memcpy(cm_id_priv->alt_av.smac, alt_smac,
1722 +- sizeof(cm_id_priv->alt_av.smac));
1723 +-
1724 +- return 0;
1725 +-}
1726 +-EXPORT_SYMBOL(ib_update_cm_av);
1727 +-
1728 + static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
1729 + {
1730 + struct cm_device *cm_dev;
1731 +diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
1732 +index 199958d9ddc8..42c3058e6e9c 100644
1733 +--- a/drivers/infiniband/core/cma.c
1734 ++++ b/drivers/infiniband/core/cma.c
1735 +@@ -1284,15 +1284,6 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1736 + struct rdma_id_private *listen_id, *conn_id;
1737 + struct rdma_cm_event event;
1738 + int offset, ret;
1739 +- u8 smac[ETH_ALEN];
1740 +- u8 alt_smac[ETH_ALEN];
1741 +- u8 *psmac = smac;
1742 +- u8 *palt_smac = alt_smac;
1743 +- int is_iboe = ((rdma_node_get_transport(cm_id->device->node_type) ==
1744 +- RDMA_TRANSPORT_IB) &&
1745 +- (rdma_port_get_link_layer(cm_id->device,
1746 +- ib_event->param.req_rcvd.port) ==
1747 +- IB_LINK_LAYER_ETHERNET));
1748 +
1749 + listen_id = cm_id->context;
1750 + if (!cma_check_req_qp_type(&listen_id->id, ib_event))
1751 +@@ -1336,28 +1327,11 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1752 + ret = conn_id->id.event_handler(&conn_id->id, &event);
1753 + if (ret)
1754 + goto err3;
1755 +-
1756 +- if (is_iboe) {
1757 +- if (ib_event->param.req_rcvd.primary_path != NULL)
1758 +- rdma_addr_find_smac_by_sgid(
1759 +- &ib_event->param.req_rcvd.primary_path->sgid,
1760 +- psmac, NULL);
1761 +- else
1762 +- psmac = NULL;
1763 +- if (ib_event->param.req_rcvd.alternate_path != NULL)
1764 +- rdma_addr_find_smac_by_sgid(
1765 +- &ib_event->param.req_rcvd.alternate_path->sgid,
1766 +- palt_smac, NULL);
1767 +- else
1768 +- palt_smac = NULL;
1769 +- }
1770 + /*
1771 + * Acquire mutex to prevent user executing rdma_destroy_id()
1772 + * while we're accessing the cm_id.
1773 + */
1774 + mutex_lock(&lock);
1775 +- if (is_iboe)
1776 +- ib_update_cm_av(cm_id, psmac, palt_smac);
1777 + if (cma_comp(conn_id, RDMA_CM_CONNECT) &&
1778 + (conn_id->id.qp_type != IB_QPT_UD))
1779 + ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
1780 +diff --git a/drivers/infiniband/hw/ehca/ehca_cq.c b/drivers/infiniband/hw/ehca/ehca_cq.c
1781 +index 212150c25ea0..8cc837537768 100644
1782 +--- a/drivers/infiniband/hw/ehca/ehca_cq.c
1783 ++++ b/drivers/infiniband/hw/ehca/ehca_cq.c
1784 +@@ -283,6 +283,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
1785 + (my_cq->galpas.user.fw_handle & (PAGE_SIZE - 1));
1786 + if (ib_copy_to_udata(udata, &resp, sizeof(resp))) {
1787 + ehca_err(device, "Copy to udata failed.");
1788 ++ cq = ERR_PTR(-EFAULT);
1789 + goto create_cq_exit4;
1790 + }
1791 + }
1792 +diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c
1793 +index 714293b78518..e2f9a51f4a38 100644
1794 +--- a/drivers/infiniband/hw/ipath/ipath_diag.c
1795 ++++ b/drivers/infiniband/hw/ipath/ipath_diag.c
1796 +@@ -326,7 +326,7 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
1797 + size_t count, loff_t *off)
1798 + {
1799 + u32 __iomem *piobuf;
1800 +- u32 plen, clen, pbufn;
1801 ++ u32 plen, pbufn, maxlen_reserve;
1802 + struct ipath_diag_pkt odp;
1803 + struct ipath_diag_xpkt dp;
1804 + u32 *tmpbuf = NULL;
1805 +@@ -335,51 +335,29 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
1806 + u64 val;
1807 + u32 l_state, lt_state; /* LinkState, LinkTrainingState */
1808 +
1809 +- if (count < sizeof(odp)) {
1810 +- ret = -EINVAL;
1811 +- goto bail;
1812 +- }
1813 +
1814 + if (count == sizeof(dp)) {
1815 + if (copy_from_user(&dp, data, sizeof(dp))) {
1816 + ret = -EFAULT;
1817 + goto bail;
1818 + }
1819 +- } else if (copy_from_user(&odp, data, sizeof(odp))) {
1820 +- ret = -EFAULT;
1821 ++ } else if (count == sizeof(odp)) {
1822 ++ if (copy_from_user(&odp, data, sizeof(odp))) {
1823 ++ ret = -EFAULT;
1824 ++ goto bail;
1825 ++ }
1826 ++ } else {
1827 ++ ret = -EINVAL;
1828 + goto bail;
1829 + }
1830 +
1831 +- /*
1832 +- * Due to padding/alignment issues (lessened with new struct)
1833 +- * the old and new structs are the same length. We need to
1834 +- * disambiguate them, which we can do because odp.len has never
1835 +- * been less than the total of LRH+BTH+DETH so far, while
1836 +- * dp.unit (same offset) unit is unlikely to get that high.
1837 +- * Similarly, dp.data, the pointer to user at the same offset
1838 +- * as odp.unit, is almost certainly at least one (512byte)page
1839 +- * "above" NULL. The if-block below can be omitted if compatibility
1840 +- * between a new driver and older diagnostic code is unimportant.
1841 +- * compatibility the other direction (new diags, old driver) is
1842 +- * handled in the diagnostic code, with a warning.
1843 +- */
1844 +- if (dp.unit >= 20 && dp.data < 512) {
1845 +- /* very probable version mismatch. Fix it up */
1846 +- memcpy(&odp, &dp, sizeof(odp));
1847 +- /* We got a legacy dp, copy elements to dp */
1848 +- dp.unit = odp.unit;
1849 +- dp.data = odp.data;
1850 +- dp.len = odp.len;
1851 +- dp.pbc_wd = 0; /* Indicate we need to compute PBC wd */
1852 +- }
1853 +-
1854 + /* send count must be an exact number of dwords */
1855 + if (dp.len & 3) {
1856 + ret = -EINVAL;
1857 + goto bail;
1858 + }
1859 +
1860 +- clen = dp.len >> 2;
1861 ++ plen = dp.len >> 2;
1862 +
1863 + dd = ipath_lookup(dp.unit);
1864 + if (!dd || !(dd->ipath_flags & IPATH_PRESENT) ||
1865 +@@ -422,16 +400,22 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
1866 + goto bail;
1867 + }
1868 +
1869 +- /* need total length before first word written */
1870 +- /* +1 word is for the qword padding */
1871 +- plen = sizeof(u32) + dp.len;
1872 +-
1873 +- if ((plen + 4) > dd->ipath_ibmaxlen) {
1874 ++ /*
1875 ++ * need total length before first word written, plus 2 Dwords. One Dword
1876 ++ * is for padding so we get the full user data when not aligned on
1877 ++ * a word boundary. The other Dword is to make sure we have room for the
1878 ++ * ICRC which gets tacked on later.
1879 ++ */
1880 ++ maxlen_reserve = 2 * sizeof(u32);
1881 ++ if (dp.len > dd->ipath_ibmaxlen - maxlen_reserve) {
1882 + ipath_dbg("Pkt len 0x%x > ibmaxlen %x\n",
1883 +- plen - 4, dd->ipath_ibmaxlen);
1884 ++ dp.len, dd->ipath_ibmaxlen);
1885 + ret = -EINVAL;
1886 +- goto bail; /* before writing pbc */
1887 ++ goto bail;
1888 + }
1889 ++
1890 ++ plen = sizeof(u32) + dp.len;
1891 ++
1892 + tmpbuf = vmalloc(plen);
1893 + if (!tmpbuf) {
1894 + dev_info(&dd->pcidev->dev, "Unable to allocate tmp buffer, "
1895 +@@ -473,11 +457,11 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
1896 + */
1897 + if (dd->ipath_flags & IPATH_PIO_FLUSH_WC) {
1898 + ipath_flush_wc();
1899 +- __iowrite32_copy(piobuf + 2, tmpbuf, clen - 1);
1900 ++ __iowrite32_copy(piobuf + 2, tmpbuf, plen - 1);
1901 + ipath_flush_wc();
1902 +- __raw_writel(tmpbuf[clen - 1], piobuf + clen + 1);
1903 ++ __raw_writel(tmpbuf[plen - 1], piobuf + plen + 1);
1904 + } else
1905 +- __iowrite32_copy(piobuf + 2, tmpbuf, clen);
1906 ++ __iowrite32_copy(piobuf + 2, tmpbuf, plen);
1907 +
1908 + ipath_flush_wc();
1909 +
1910 +diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
1911 +index 5b71d43bd89c..42dde06fdb91 100644
1912 +--- a/drivers/infiniband/hw/mthca/mthca_provider.c
1913 ++++ b/drivers/infiniband/hw/mthca/mthca_provider.c
1914 +@@ -695,6 +695,7 @@ static struct ib_cq *mthca_create_cq(struct ib_device *ibdev, int entries,
1915 +
1916 + if (context && ib_copy_to_udata(udata, &cq->cqn, sizeof (__u32))) {
1917 + mthca_free_cq(to_mdev(ibdev), cq);
1918 ++ err = -EFAULT;
1919 + goto err_free;
1920 + }
1921 +
1922 +diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
1923 +index 8308e3634767..eb624611f94b 100644
1924 +--- a/drivers/infiniband/hw/nes/nes_verbs.c
1925 ++++ b/drivers/infiniband/hw/nes/nes_verbs.c
1926 +@@ -1186,7 +1186,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
1927 + nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num);
1928 + kfree(nesqp->allocated_buffer);
1929 + nes_debug(NES_DBG_QP, "ib_copy_from_udata() Failed \n");
1930 +- return NULL;
1931 ++ return ERR_PTR(-EFAULT);
1932 + }
1933 + if (req.user_wqe_buffers) {
1934 + virt_wqs = 1;
1935 +diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c
1936 +index 275f247f9fca..2023cd61b897 100644
1937 +--- a/drivers/infiniband/hw/qib/qib_file_ops.c
1938 ++++ b/drivers/infiniband/hw/qib/qib_file_ops.c
1939 +@@ -1578,7 +1578,7 @@ static int do_qib_user_sdma_queue_create(struct file *fp)
1940 + struct qib_ctxtdata *rcd = fd->rcd;
1941 + struct qib_devdata *dd = rcd->dd;
1942 +
1943 +- if (dd->flags & QIB_HAS_SEND_DMA)
1944 ++ if (dd->flags & QIB_HAS_SEND_DMA) {
1945 +
1946 + fd->pq = qib_user_sdma_queue_create(&dd->pcidev->dev,
1947 + dd->unit,
1948 +@@ -1586,6 +1586,7 @@ static int do_qib_user_sdma_queue_create(struct file *fp)
1949 + fd->subctxt);
1950 + if (!fd->pq)
1951 + return -ENOMEM;
1952 ++ }
1953 +
1954 + return 0;
1955 + }
1956 +diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c
1957 +index 24e802f4ea2f..76c3e177164d 100644
1958 +--- a/drivers/infiniband/hw/qib/qib_init.c
1959 ++++ b/drivers/infiniband/hw/qib/qib_init.c
1960 +@@ -1097,14 +1097,10 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
1961 + int ret;
1962 +
1963 + dd = (struct qib_devdata *) ib_alloc_device(sizeof(*dd) + extra);
1964 +- if (!dd) {
1965 +- dd = ERR_PTR(-ENOMEM);
1966 +- goto bail;
1967 +- }
1968 ++ if (!dd)
1969 ++ return ERR_PTR(-ENOMEM);
1970 +
1971 +-#ifdef CONFIG_DEBUG_FS
1972 +- qib_dbg_ibdev_init(&dd->verbs_dev);
1973 +-#endif
1974 ++ INIT_LIST_HEAD(&dd->list);
1975 +
1976 + idr_preload(GFP_KERNEL);
1977 + spin_lock_irqsave(&qib_devs_lock, flags);
1978 +@@ -1121,11 +1117,6 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
1979 + if (ret < 0) {
1980 + qib_early_err(&pdev->dev,
1981 + "Could not allocate unit ID: error %d\n", -ret);
1982 +-#ifdef CONFIG_DEBUG_FS
1983 +- qib_dbg_ibdev_exit(&dd->verbs_dev);
1984 +-#endif
1985 +- ib_dealloc_device(&dd->verbs_dev.ibdev);
1986 +- dd = ERR_PTR(ret);
1987 + goto bail;
1988 + }
1989 +
1990 +@@ -1139,9 +1130,15 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
1991 + qib_early_err(&pdev->dev,
1992 + "Could not alloc cpulist info, cpu affinity might be wrong\n");
1993 + }
1994 +-
1995 +-bail:
1996 ++#ifdef CONFIG_DEBUG_FS
1997 ++ qib_dbg_ibdev_init(&dd->verbs_dev);
1998 ++#endif
1999 + return dd;
2000 ++bail:
2001 ++ if (!list_empty(&dd->list))
2002 ++ list_del_init(&dd->list);
2003 ++ ib_dealloc_device(&dd->verbs_dev.ibdev);
2004 ++ return ERR_PTR(ret);;
2005 + }
2006 +
2007 + /*
2008 +diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
2009 +index 8ee228e9ab5a..f596b413a35b 100644
2010 +--- a/drivers/infiniband/ulp/isert/ib_isert.c
2011 ++++ b/drivers/infiniband/ulp/isert/ib_isert.c
2012 +@@ -436,11 +436,18 @@ isert_conn_create_fastreg_pool(struct isert_conn *isert_conn)
2013 + {
2014 + struct fast_reg_descriptor *fr_desc;
2015 + struct isert_device *device = isert_conn->conn_device;
2016 +- int i, ret;
2017 ++ struct se_session *se_sess = isert_conn->conn->sess->se_sess;
2018 ++ struct se_node_acl *se_nacl = se_sess->se_node_acl;
2019 ++ int i, ret, tag_num;
2020 ++ /*
2021 ++ * Setup the number of FRMRs based upon the number of tags
2022 ++ * available to session in iscsi_target_locate_portal().
2023 ++ */
2024 ++ tag_num = max_t(u32, ISCSIT_MIN_TAGS, se_nacl->queue_depth);
2025 ++ tag_num = (tag_num * 2) + ISCSIT_EXTRA_TAGS;
2026 +
2027 +- INIT_LIST_HEAD(&isert_conn->conn_fr_pool);
2028 + isert_conn->conn_fr_pool_size = 0;
2029 +- for (i = 0; i < ISCSI_DEF_XMIT_CMDS_MAX; i++) {
2030 ++ for (i = 0; i < tag_num; i++) {
2031 + fr_desc = kzalloc(sizeof(*fr_desc), GFP_KERNEL);
2032 + if (!fr_desc) {
2033 + pr_err("Failed to allocate fast_reg descriptor\n");
2034 +@@ -498,6 +505,7 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
2035 + kref_get(&isert_conn->conn_kref);
2036 + mutex_init(&isert_conn->conn_mutex);
2037 + spin_lock_init(&isert_conn->conn_lock);
2038 ++ INIT_LIST_HEAD(&isert_conn->conn_fr_pool);
2039 +
2040 + cma_id->context = isert_conn;
2041 + isert_conn->conn_cm_id = cma_id;
2042 +@@ -569,15 +577,6 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
2043 + goto out_mr;
2044 + }
2045 +
2046 +- if (device->use_fastreg) {
2047 +- ret = isert_conn_create_fastreg_pool(isert_conn);
2048 +- if (ret) {
2049 +- pr_err("Conn: %p failed to create fastreg pool\n",
2050 +- isert_conn);
2051 +- goto out_fastreg;
2052 +- }
2053 +- }
2054 +-
2055 + ret = isert_conn_setup_qp(isert_conn, cma_id);
2056 + if (ret)
2057 + goto out_conn_dev;
2058 +@@ -591,9 +590,6 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
2059 + return 0;
2060 +
2061 + out_conn_dev:
2062 +- if (device->use_fastreg)
2063 +- isert_conn_free_fastreg_pool(isert_conn);
2064 +-out_fastreg:
2065 + ib_dereg_mr(isert_conn->conn_mr);
2066 + out_mr:
2067 + ib_dealloc_pd(isert_conn->conn_pd);
2068 +@@ -967,6 +963,15 @@ isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,
2069 + }
2070 + if (!login->login_failed) {
2071 + if (login->login_complete) {
2072 ++ if (isert_conn->conn_device->use_fastreg) {
2073 ++ ret = isert_conn_create_fastreg_pool(isert_conn);
2074 ++ if (ret) {
2075 ++ pr_err("Conn: %p failed to create"
2076 ++ " fastreg pool\n", isert_conn);
2077 ++ return ret;
2078 ++ }
2079 ++ }
2080 ++
2081 + ret = isert_alloc_rx_descriptors(isert_conn);
2082 + if (ret)
2083 + return ret;
2084 +@@ -1451,7 +1456,7 @@ isert_unreg_rdma(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn)
2085 + }
2086 +
2087 + static void
2088 +-isert_put_cmd(struct isert_cmd *isert_cmd)
2089 ++isert_put_cmd(struct isert_cmd *isert_cmd, bool comp_err)
2090 + {
2091 + struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
2092 + struct isert_conn *isert_conn = isert_cmd->conn;
2093 +@@ -1467,8 +1472,21 @@ isert_put_cmd(struct isert_cmd *isert_cmd)
2094 + list_del_init(&cmd->i_conn_node);
2095 + spin_unlock_bh(&conn->cmd_lock);
2096 +
2097 +- if (cmd->data_direction == DMA_TO_DEVICE)
2098 ++ if (cmd->data_direction == DMA_TO_DEVICE) {
2099 + iscsit_stop_dataout_timer(cmd);
2100 ++ /*
2101 ++ * Check for special case during comp_err where
2102 ++ * WRITE_PENDING has been handed off from core,
2103 ++ * but requires an extra target_put_sess_cmd()
2104 ++ * before transport_generic_free_cmd() below.
2105 ++ */
2106 ++ if (comp_err &&
2107 ++ cmd->se_cmd.t_state == TRANSPORT_WRITE_PENDING) {
2108 ++ struct se_cmd *se_cmd = &cmd->se_cmd;
2109 ++
2110 ++ target_put_sess_cmd(se_cmd->se_sess, se_cmd);
2111 ++ }
2112 ++ }
2113 +
2114 + device->unreg_rdma_mem(isert_cmd, isert_conn);
2115 + transport_generic_free_cmd(&cmd->se_cmd, 0);
2116 +@@ -1523,7 +1541,7 @@ isert_unmap_tx_desc(struct iser_tx_desc *tx_desc, struct ib_device *ib_dev)
2117 +
2118 + static void
2119 + isert_completion_put(struct iser_tx_desc *tx_desc, struct isert_cmd *isert_cmd,
2120 +- struct ib_device *ib_dev)
2121 ++ struct ib_device *ib_dev, bool comp_err)
2122 + {
2123 + if (isert_cmd->pdu_buf_dma != 0) {
2124 + pr_debug("Calling ib_dma_unmap_single for isert_cmd->pdu_buf_dma\n");
2125 +@@ -1533,7 +1551,7 @@ isert_completion_put(struct iser_tx_desc *tx_desc, struct isert_cmd *isert_cmd,
2126 + }
2127 +
2128 + isert_unmap_tx_desc(tx_desc, ib_dev);
2129 +- isert_put_cmd(isert_cmd);
2130 ++ isert_put_cmd(isert_cmd, comp_err);
2131 + }
2132 +
2133 + static void
2134 +@@ -1577,14 +1595,14 @@ isert_do_control_comp(struct work_struct *work)
2135 + iscsit_tmr_post_handler(cmd, cmd->conn);
2136 +
2137 + cmd->i_state = ISTATE_SENT_STATUS;
2138 +- isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev);
2139 ++ isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev, false);
2140 + break;
2141 + case ISTATE_SEND_REJECT:
2142 + pr_debug("Got isert_do_control_comp ISTATE_SEND_REJECT: >>>\n");
2143 + atomic_dec(&isert_conn->post_send_buf_count);
2144 +
2145 + cmd->i_state = ISTATE_SENT_STATUS;
2146 +- isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev);
2147 ++ isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev, false);
2148 + break;
2149 + case ISTATE_SEND_LOGOUTRSP:
2150 + pr_debug("Calling iscsit_logout_post_handler >>>>>>>>>>>>>>\n");
2151 +@@ -1598,7 +1616,7 @@ isert_do_control_comp(struct work_struct *work)
2152 + case ISTATE_SEND_TEXTRSP:
2153 + atomic_dec(&isert_conn->post_send_buf_count);
2154 + cmd->i_state = ISTATE_SENT_STATUS;
2155 +- isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev);
2156 ++ isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev, false);
2157 + break;
2158 + default:
2159 + pr_err("Unknown do_control_comp i_state %d\n", cmd->i_state);
2160 +@@ -1629,7 +1647,7 @@ isert_response_completion(struct iser_tx_desc *tx_desc,
2161 + atomic_sub(wr->send_wr_num + 1, &isert_conn->post_send_buf_count);
2162 +
2163 + cmd->i_state = ISTATE_SENT_STATUS;
2164 +- isert_completion_put(tx_desc, isert_cmd, ib_dev);
2165 ++ isert_completion_put(tx_desc, isert_cmd, ib_dev, false);
2166 + }
2167 +
2168 + static void
2169 +@@ -1710,7 +1728,7 @@ isert_cq_drain_comp_llist(struct isert_conn *isert_conn, struct ib_device *ib_de
2170 + wr = &t->isert_cmd->rdma_wr;
2171 +
2172 + atomic_sub(wr->send_wr_num + 1, &isert_conn->post_send_buf_count);
2173 +- isert_completion_put(t, t->isert_cmd, ib_dev);
2174 ++ isert_completion_put(t, t->isert_cmd, ib_dev, true);
2175 + }
2176 + }
2177 +
2178 +@@ -1729,14 +1747,14 @@ isert_cq_tx_comp_err(struct iser_tx_desc *tx_desc, struct isert_conn *isert_conn
2179 + wr = &t->isert_cmd->rdma_wr;
2180 +
2181 + atomic_sub(wr->send_wr_num + 1, &isert_conn->post_send_buf_count);
2182 +- isert_completion_put(t, t->isert_cmd, ib_dev);
2183 ++ isert_completion_put(t, t->isert_cmd, ib_dev, true);
2184 + }
2185 + tx_desc->comp_llnode_batch = NULL;
2186 +
2187 + if (!isert_cmd)
2188 + isert_unmap_tx_desc(tx_desc, ib_dev);
2189 + else
2190 +- isert_completion_put(tx_desc, isert_cmd, ib_dev);
2191 ++ isert_completion_put(tx_desc, isert_cmd, ib_dev, true);
2192 + }
2193 +
2194 + static void
2195 +diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
2196 +index 0e537d8d0e47..d1078ce73095 100644
2197 +--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
2198 ++++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
2199 +@@ -1078,6 +1078,7 @@ static void srpt_unmap_sg_to_ib_sge(struct srpt_rdma_ch *ch,
2200 + static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
2201 + struct srpt_send_ioctx *ioctx)
2202 + {
2203 ++ struct ib_device *dev = ch->sport->sdev->device;
2204 + struct se_cmd *cmd;
2205 + struct scatterlist *sg, *sg_orig;
2206 + int sg_cnt;
2207 +@@ -1124,7 +1125,7 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
2208 +
2209 + db = ioctx->rbufs;
2210 + tsize = cmd->data_length;
2211 +- dma_len = sg_dma_len(&sg[0]);
2212 ++ dma_len = ib_sg_dma_len(dev, &sg[0]);
2213 + riu = ioctx->rdma_ius;
2214 +
2215 + /*
2216 +@@ -1155,7 +1156,8 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
2217 + ++j;
2218 + if (j < count) {
2219 + sg = sg_next(sg);
2220 +- dma_len = sg_dma_len(sg);
2221 ++ dma_len = ib_sg_dma_len(
2222 ++ dev, sg);
2223 + }
2224 + }
2225 + } else {
2226 +@@ -1192,8 +1194,8 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
2227 + tsize = cmd->data_length;
2228 + riu = ioctx->rdma_ius;
2229 + sg = sg_orig;
2230 +- dma_len = sg_dma_len(&sg[0]);
2231 +- dma_addr = sg_dma_address(&sg[0]);
2232 ++ dma_len = ib_sg_dma_len(dev, &sg[0]);
2233 ++ dma_addr = ib_sg_dma_address(dev, &sg[0]);
2234 +
2235 + /* this second loop is really mapped sg_addres to rdma_iu->ib_sge */
2236 + for (i = 0, j = 0;
2237 +@@ -1216,8 +1218,10 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
2238 + ++j;
2239 + if (j < count) {
2240 + sg = sg_next(sg);
2241 +- dma_len = sg_dma_len(sg);
2242 +- dma_addr = sg_dma_address(sg);
2243 ++ dma_len = ib_sg_dma_len(
2244 ++ dev, sg);
2245 ++ dma_addr = ib_sg_dma_address(
2246 ++ dev, sg);
2247 + }
2248 + }
2249 + } else {
2250 +diff --git a/drivers/media/dvb-frontends/m88rs2000.c b/drivers/media/dvb-frontends/m88rs2000.c
2251 +index b2351466b0da..32cffca14d0b 100644
2252 +--- a/drivers/media/dvb-frontends/m88rs2000.c
2253 ++++ b/drivers/media/dvb-frontends/m88rs2000.c
2254 +@@ -715,6 +715,22 @@ static int m88rs2000_get_frontend(struct dvb_frontend *fe)
2255 + return 0;
2256 + }
2257 +
2258 ++static int m88rs2000_get_tune_settings(struct dvb_frontend *fe,
2259 ++ struct dvb_frontend_tune_settings *tune)
2260 ++{
2261 ++ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
2262 ++
2263 ++ if (c->symbol_rate > 3000000)
2264 ++ tune->min_delay_ms = 2000;
2265 ++ else
2266 ++ tune->min_delay_ms = 3000;
2267 ++
2268 ++ tune->step_size = c->symbol_rate / 16000;
2269 ++ tune->max_drift = c->symbol_rate / 2000;
2270 ++
2271 ++ return 0;
2272 ++}
2273 ++
2274 + static int m88rs2000_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
2275 + {
2276 + struct m88rs2000_state *state = fe->demodulator_priv;
2277 +@@ -746,7 +762,7 @@ static struct dvb_frontend_ops m88rs2000_ops = {
2278 + .symbol_rate_tolerance = 500, /* ppm */
2279 + .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
2280 + FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
2281 +- FE_CAN_QPSK |
2282 ++ FE_CAN_QPSK | FE_CAN_INVERSION_AUTO |
2283 + FE_CAN_FEC_AUTO
2284 + },
2285 +
2286 +@@ -766,6 +782,7 @@ static struct dvb_frontend_ops m88rs2000_ops = {
2287 +
2288 + .set_frontend = m88rs2000_set_frontend,
2289 + .get_frontend = m88rs2000_get_frontend,
2290 ++ .get_tune_settings = m88rs2000_get_tune_settings,
2291 + };
2292 +
2293 + struct dvb_frontend *m88rs2000_attach(const struct m88rs2000_config *config,
2294 +diff --git a/drivers/media/pci/saa7134/saa7134-cards.c b/drivers/media/pci/saa7134/saa7134-cards.c
2295 +index c9b2350e92c8..6e4bdb90aa92 100644
2296 +--- a/drivers/media/pci/saa7134/saa7134-cards.c
2297 ++++ b/drivers/media/pci/saa7134/saa7134-cards.c
2298 +@@ -8045,8 +8045,8 @@ int saa7134_board_init2(struct saa7134_dev *dev)
2299 + break;
2300 + } /* switch() */
2301 +
2302 +- /* initialize tuner */
2303 +- if (TUNER_ABSENT != dev->tuner_type) {
2304 ++ /* initialize tuner (don't do this when resuming) */
2305 ++ if (!dev->insuspend && TUNER_ABSENT != dev->tuner_type) {
2306 + int has_demod = (dev->tda9887_conf & TDA9887_PRESENT);
2307 +
2308 + /* Note: radio tuner address is always filled in,
2309 +diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c
2310 +index 1c776c1186f1..1dbff1472809 100644
2311 +--- a/drivers/media/platform/omap3isp/isppreview.c
2312 ++++ b/drivers/media/platform/omap3isp/isppreview.c
2313 +@@ -1079,6 +1079,7 @@ static void preview_config_input_format(struct isp_prev_device *prev,
2314 + */
2315 + static void preview_config_input_size(struct isp_prev_device *prev, u32 active)
2316 + {
2317 ++ const struct v4l2_mbus_framefmt *format = &prev->formats[PREV_PAD_SINK];
2318 + struct isp_device *isp = to_isp_device(prev);
2319 + unsigned int sph = prev->crop.left;
2320 + unsigned int eph = prev->crop.left + prev->crop.width - 1;
2321 +@@ -1086,6 +1087,14 @@ static void preview_config_input_size(struct isp_prev_device *prev, u32 active)
2322 + unsigned int elv = prev->crop.top + prev->crop.height - 1;
2323 + u32 features;
2324 +
2325 ++ if (format->code != V4L2_MBUS_FMT_Y8_1X8 &&
2326 ++ format->code != V4L2_MBUS_FMT_Y10_1X10) {
2327 ++ sph -= 2;
2328 ++ eph += 2;
2329 ++ slv -= 2;
2330 ++ elv += 2;
2331 ++ }
2332 ++
2333 + features = (prev->params.params[0].features & active)
2334 + | (prev->params.params[1].features & ~active);
2335 +
2336 +diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
2337 +index 05e9bd11a3ff..dfdfa772eb1e 100644
2338 +--- a/drivers/media/usb/em28xx/em28xx-audio.c
2339 ++++ b/drivers/media/usb/em28xx/em28xx-audio.c
2340 +@@ -252,7 +252,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
2341 + {
2342 + struct em28xx *dev = snd_pcm_substream_chip(substream);
2343 + struct snd_pcm_runtime *runtime = substream->runtime;
2344 +- int ret = 0;
2345 ++ int nonblock, ret = 0;
2346 +
2347 + if (!dev) {
2348 + em28xx_err("BUG: em28xx can't find device struct."
2349 +@@ -265,15 +265,15 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
2350 +
2351 + dprintk("opening device and trying to acquire exclusive lock\n");
2352 +
2353 ++ nonblock = !!(substream->f_flags & O_NONBLOCK);
2354 ++ if (nonblock) {
2355 ++ if (!mutex_trylock(&dev->lock))
2356 ++ return -EAGAIN;
2357 ++ } else
2358 ++ mutex_lock(&dev->lock);
2359 ++
2360 + runtime->hw = snd_em28xx_hw_capture;
2361 + if ((dev->alt == 0 || dev->is_audio_only) && dev->adev.users == 0) {
2362 +- int nonblock = !!(substream->f_flags & O_NONBLOCK);
2363 +-
2364 +- if (nonblock) {
2365 +- if (!mutex_trylock(&dev->lock))
2366 +- return -EAGAIN;
2367 +- } else
2368 +- mutex_lock(&dev->lock);
2369 + if (dev->is_audio_only)
2370 + /* vendor audio is on a separate interface */
2371 + dev->alt = 1;
2372 +@@ -299,11 +299,11 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
2373 + ret = em28xx_audio_analog_set(dev);
2374 + if (ret < 0)
2375 + goto err;
2376 +-
2377 +- dev->adev.users++;
2378 +- mutex_unlock(&dev->lock);
2379 + }
2380 +
2381 ++ dev->adev.users++;
2382 ++ mutex_unlock(&dev->lock);
2383 ++
2384 + /* Dynamically adjust the period size */
2385 + snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
2386 + snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
2387 +diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
2388 +index a0a669e81362..1373cfa4e974 100644
2389 +--- a/drivers/media/usb/em28xx/em28xx-dvb.c
2390 ++++ b/drivers/media/usb/em28xx/em28xx-dvb.c
2391 +@@ -693,7 +693,8 @@ static void pctv_520e_init(struct em28xx *dev)
2392 + static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe)
2393 + {
2394 + struct dtv_frontend_properties *c = &fe->dtv_property_cache;
2395 +- struct em28xx *dev = fe->dvb->priv;
2396 ++ struct em28xx_i2c_bus *i2c_bus = fe->dvb->priv;
2397 ++ struct em28xx *dev = i2c_bus->dev;
2398 + #ifdef CONFIG_GPIOLIB
2399 + struct em28xx_dvb *dvb = dev->dvb;
2400 + int ret;
2401 +diff --git a/drivers/media/usb/gspca/sn9c20x.c b/drivers/media/usb/gspca/sn9c20x.c
2402 +index 2a38621cf718..41a9a892f79c 100644
2403 +--- a/drivers/media/usb/gspca/sn9c20x.c
2404 ++++ b/drivers/media/usb/gspca/sn9c20x.c
2405 +@@ -2359,6 +2359,7 @@ static const struct usb_device_id device_table[] = {
2406 + {USB_DEVICE(0x045e, 0x00f4), SN9C20X(OV9650, 0x30, 0)},
2407 + {USB_DEVICE(0x145f, 0x013d), SN9C20X(OV7660, 0x21, 0)},
2408 + {USB_DEVICE(0x0458, 0x7029), SN9C20X(HV7131R, 0x11, 0)},
2409 ++ {USB_DEVICE(0x0458, 0x7045), SN9C20X(MT9M112, 0x5d, LED_REVERSE)},
2410 + {USB_DEVICE(0x0458, 0x704a), SN9C20X(MT9M112, 0x5d, 0)},
2411 + {USB_DEVICE(0x0458, 0x704c), SN9C20X(MT9M112, 0x5d, 0)},
2412 + {USB_DEVICE(0xa168, 0x0610), SN9C20X(HV7131R, 0x11, 0)},
2413 +diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
2414 +index 898c208889cd..e32d6a59eaca 100644
2415 +--- a/drivers/media/usb/uvc/uvc_video.c
2416 ++++ b/drivers/media/usb/uvc/uvc_video.c
2417 +@@ -1847,7 +1847,25 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable)
2418 +
2419 + if (!enable) {
2420 + uvc_uninit_video(stream, 1);
2421 +- usb_set_interface(stream->dev->udev, stream->intfnum, 0);
2422 ++ if (stream->intf->num_altsetting > 1) {
2423 ++ usb_set_interface(stream->dev->udev,
2424 ++ stream->intfnum, 0);
2425 ++ } else {
2426 ++ /* UVC doesn't specify how to inform a bulk-based device
2427 ++ * when the video stream is stopped. Windows sends a
2428 ++ * CLEAR_FEATURE(HALT) request to the video streaming
2429 ++ * bulk endpoint, mimic the same behaviour.
2430 ++ */
2431 ++ unsigned int epnum = stream->header.bEndpointAddress
2432 ++ & USB_ENDPOINT_NUMBER_MASK;
2433 ++ unsigned int dir = stream->header.bEndpointAddress
2434 ++ & USB_ENDPOINT_DIR_MASK;
2435 ++ unsigned int pipe;
2436 ++
2437 ++ pipe = usb_sndbulkpipe(stream->dev->udev, epnum) | dir;
2438 ++ usb_clear_halt(stream->dev->udev, pipe);
2439 ++ }
2440 ++
2441 + uvc_queue_enable(&stream->queue, 0);
2442 + uvc_video_clock_cleanup(stream);
2443 + return 0;
2444 +diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
2445 +index 8f7a6a454a4c..b63a5e584aa0 100644
2446 +--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
2447 ++++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
2448 +@@ -787,8 +787,8 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
2449 + #define VIDIOC_DQBUF32 _IOWR('V', 17, struct v4l2_buffer32)
2450 + #define VIDIOC_ENUMSTD32 _IOWR('V', 25, struct v4l2_standard32)
2451 + #define VIDIOC_ENUMINPUT32 _IOWR('V', 26, struct v4l2_input32)
2452 +-#define VIDIOC_SUBDEV_G_EDID32 _IOWR('V', 63, struct v4l2_subdev_edid32)
2453 +-#define VIDIOC_SUBDEV_S_EDID32 _IOWR('V', 64, struct v4l2_subdev_edid32)
2454 ++#define VIDIOC_SUBDEV_G_EDID32 _IOWR('V', 40, struct v4l2_subdev_edid32)
2455 ++#define VIDIOC_SUBDEV_S_EDID32 _IOWR('V', 41, struct v4l2_subdev_edid32)
2456 + #define VIDIOC_TRY_FMT32 _IOWR('V', 64, struct v4l2_format32)
2457 + #define VIDIOC_G_EXT_CTRLS32 _IOWR('V', 71, struct v4l2_ext_controls32)
2458 + #define VIDIOC_S_EXT_CTRLS32 _IOWR('V', 72, struct v4l2_ext_controls32)
2459 +diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
2460 +index f7902fe8a526..a2e257970fec 100644
2461 +--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
2462 ++++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
2463 +@@ -26,6 +26,10 @@
2464 + #include <linux/v4l2-dv-timings.h>
2465 + #include <media/v4l2-dv-timings.h>
2466 +
2467 ++MODULE_AUTHOR("Hans Verkuil");
2468 ++MODULE_DESCRIPTION("V4L2 DV Timings Helper Functions");
2469 ++MODULE_LICENSE("GPL");
2470 ++
2471 + const struct v4l2_dv_timings v4l2_dv_timings_presets[] = {
2472 + V4L2_DV_BT_CEA_640X480P59_94,
2473 + V4L2_DV_BT_CEA_720X480I59_94,
2474 +diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c
2475 +index 7dca1e640970..841717a2842c 100644
2476 +--- a/drivers/mfd/88pm800.c
2477 ++++ b/drivers/mfd/88pm800.c
2478 +@@ -571,7 +571,7 @@ static int pm800_probe(struct i2c_client *client,
2479 + ret = pm800_pages_init(chip);
2480 + if (ret) {
2481 + dev_err(&client->dev, "pm800_pages_init failed!\n");
2482 +- goto err_page_init;
2483 ++ goto err_device_init;
2484 + }
2485 +
2486 + ret = device_800_init(chip, pdata);
2487 +@@ -587,7 +587,6 @@ static int pm800_probe(struct i2c_client *client,
2488 +
2489 + err_device_init:
2490 + pm800_pages_exit(chip);
2491 +-err_page_init:
2492 + err_subchip_alloc:
2493 + pm80x_deinit();
2494 + out_init:
2495 +diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
2496 +index c9b1f6422941..bcfc9e85b4a0 100644
2497 +--- a/drivers/mfd/88pm860x-core.c
2498 ++++ b/drivers/mfd/88pm860x-core.c
2499 +@@ -1179,12 +1179,18 @@ static int pm860x_probe(struct i2c_client *client,
2500 + chip->companion_addr = pdata->companion_addr;
2501 + chip->companion = i2c_new_dummy(chip->client->adapter,
2502 + chip->companion_addr);
2503 ++ if (!chip->companion) {
2504 ++ dev_err(&client->dev,
2505 ++ "Failed to allocate I2C companion device\n");
2506 ++ return -ENODEV;
2507 ++ }
2508 + chip->regmap_companion = regmap_init_i2c(chip->companion,
2509 + &pm860x_regmap_config);
2510 + if (IS_ERR(chip->regmap_companion)) {
2511 + ret = PTR_ERR(chip->regmap_companion);
2512 + dev_err(&chip->companion->dev,
2513 + "Failed to allocate register map: %d\n", ret);
2514 ++ i2c_unregister_device(chip->companion);
2515 + return ret;
2516 + }
2517 + i2c_set_clientdata(chip->companion, chip);
2518 +diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
2519 +index d3e23278d299..38917a822335 100644
2520 +--- a/drivers/mfd/kempld-core.c
2521 ++++ b/drivers/mfd/kempld-core.c
2522 +@@ -322,9 +322,12 @@ static int kempld_detect_device(struct kempld_device_data *pld)
2523 + return -ENODEV;
2524 + }
2525 +
2526 +- /* Release hardware mutex if aquired */
2527 +- if (!(index_reg & KEMPLD_MUTEX_KEY))
2528 ++ /* Release hardware mutex if acquired */
2529 ++ if (!(index_reg & KEMPLD_MUTEX_KEY)) {
2530 + iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
2531 ++ /* PXT and COMe-cPC2 boards may require a second release */
2532 ++ iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
2533 ++ }
2534 +
2535 + mutex_unlock(&pld->lock);
2536 +
2537 +diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
2538 +index f53d5823a3f7..e5fce765accb 100644
2539 +--- a/drivers/mfd/max77686.c
2540 ++++ b/drivers/mfd/max77686.c
2541 +@@ -121,6 +121,10 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
2542 + dev_info(max77686->dev, "device found\n");
2543 +
2544 + max77686->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC);
2545 ++ if (!max77686->rtc) {
2546 ++ dev_err(max77686->dev, "Failed to allocate I2C device for RTC\n");
2547 ++ return -ENODEV;
2548 ++ }
2549 + i2c_set_clientdata(max77686->rtc, max77686);
2550 +
2551 + max77686_irq_init(max77686);
2552 +diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
2553 +index e0859987ab6b..c5535f018466 100644
2554 +--- a/drivers/mfd/max77693.c
2555 ++++ b/drivers/mfd/max77693.c
2556 +@@ -148,9 +148,18 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
2557 + dev_info(max77693->dev, "device ID: 0x%x\n", reg_data);
2558 +
2559 + max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
2560 ++ if (!max77693->muic) {
2561 ++ dev_err(max77693->dev, "Failed to allocate I2C device for MUIC\n");
2562 ++ return -ENODEV;
2563 ++ }
2564 + i2c_set_clientdata(max77693->muic, max77693);
2565 +
2566 + max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
2567 ++ if (!max77693->haptic) {
2568 ++ dev_err(max77693->dev, "Failed to allocate I2C device for Haptic\n");
2569 ++ ret = -ENODEV;
2570 ++ goto err_i2c_haptic;
2571 ++ }
2572 + i2c_set_clientdata(max77693->haptic, max77693);
2573 +
2574 + /*
2575 +@@ -184,8 +193,9 @@ err_mfd:
2576 + max77693_irq_exit(max77693);
2577 + err_irq:
2578 + err_regmap_muic:
2579 +- i2c_unregister_device(max77693->muic);
2580 + i2c_unregister_device(max77693->haptic);
2581 ++err_i2c_haptic:
2582 ++ i2c_unregister_device(max77693->muic);
2583 + return ret;
2584 + }
2585 +
2586 +diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
2587 +index 176aa26fc787..a83eed5c15ca 100644
2588 +--- a/drivers/mfd/max8925-i2c.c
2589 ++++ b/drivers/mfd/max8925-i2c.c
2590 +@@ -181,9 +181,18 @@ static int max8925_probe(struct i2c_client *client,
2591 + mutex_init(&chip->io_lock);
2592 +
2593 + chip->rtc = i2c_new_dummy(chip->i2c->adapter, RTC_I2C_ADDR);
2594 ++ if (!chip->rtc) {
2595 ++ dev_err(chip->dev, "Failed to allocate I2C device for RTC\n");
2596 ++ return -ENODEV;
2597 ++ }
2598 + i2c_set_clientdata(chip->rtc, chip);
2599 +
2600 + chip->adc = i2c_new_dummy(chip->i2c->adapter, ADC_I2C_ADDR);
2601 ++ if (!chip->adc) {
2602 ++ dev_err(chip->dev, "Failed to allocate I2C device for ADC\n");
2603 ++ i2c_unregister_device(chip->rtc);
2604 ++ return -ENODEV;
2605 ++ }
2606 + i2c_set_clientdata(chip->adc, chip);
2607 +
2608 + device_init_wakeup(&client->dev, 1);
2609 +diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
2610 +index 5adede0fb04c..8cf7a015cfe5 100644
2611 +--- a/drivers/mfd/max8997.c
2612 ++++ b/drivers/mfd/max8997.c
2613 +@@ -208,10 +208,26 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
2614 + mutex_init(&max8997->iolock);
2615 +
2616 + max8997->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC);
2617 ++ if (!max8997->rtc) {
2618 ++ dev_err(max8997->dev, "Failed to allocate I2C device for RTC\n");
2619 ++ return -ENODEV;
2620 ++ }
2621 + i2c_set_clientdata(max8997->rtc, max8997);
2622 ++
2623 + max8997->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
2624 ++ if (!max8997->haptic) {
2625 ++ dev_err(max8997->dev, "Failed to allocate I2C device for Haptic\n");
2626 ++ ret = -ENODEV;
2627 ++ goto err_i2c_haptic;
2628 ++ }
2629 + i2c_set_clientdata(max8997->haptic, max8997);
2630 ++
2631 + max8997->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
2632 ++ if (!max8997->muic) {
2633 ++ dev_err(max8997->dev, "Failed to allocate I2C device for MUIC\n");
2634 ++ ret = -ENODEV;
2635 ++ goto err_i2c_muic;
2636 ++ }
2637 + i2c_set_clientdata(max8997->muic, max8997);
2638 +
2639 + pm_runtime_set_active(max8997->dev);
2640 +@@ -239,7 +255,9 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
2641 + err_mfd:
2642 + mfd_remove_devices(max8997->dev);
2643 + i2c_unregister_device(max8997->muic);
2644 ++err_i2c_muic:
2645 + i2c_unregister_device(max8997->haptic);
2646 ++err_i2c_haptic:
2647 + i2c_unregister_device(max8997->rtc);
2648 + return ret;
2649 + }
2650 +diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
2651 +index 5d5e186b5d8b..592db06098e6 100644
2652 +--- a/drivers/mfd/max8998.c
2653 ++++ b/drivers/mfd/max8998.c
2654 +@@ -215,6 +215,10 @@ static int max8998_i2c_probe(struct i2c_client *i2c,
2655 + mutex_init(&max8998->iolock);
2656 +
2657 + max8998->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
2658 ++ if (!max8998->rtc) {
2659 ++ dev_err(&i2c->dev, "Failed to allocate I2C device for RTC\n");
2660 ++ return -ENODEV;
2661 ++ }
2662 + i2c_set_clientdata(max8998->rtc, max8998);
2663 +
2664 + max8998_irq_init(max8998);
2665 +diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
2666 +index 714e2135210e..a76cd85a2868 100644
2667 +--- a/drivers/mfd/sec-core.c
2668 ++++ b/drivers/mfd/sec-core.c
2669 +@@ -252,6 +252,10 @@ static int sec_pmic_probe(struct i2c_client *i2c,
2670 + }
2671 +
2672 + sec_pmic->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
2673 ++ if (!sec_pmic->rtc) {
2674 ++ dev_err(&i2c->dev, "Failed to allocate I2C for RTC\n");
2675 ++ return -ENODEV;
2676 ++ }
2677 + i2c_set_clientdata(sec_pmic->rtc, sec_pmic);
2678 +
2679 + sec_pmic->regmap_rtc = devm_regmap_init_i2c(sec_pmic->rtc,
2680 +diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
2681 +index 1f142d76cbbc..d6573318977f 100644
2682 +--- a/drivers/mfd/tps65910.c
2683 ++++ b/drivers/mfd/tps65910.c
2684 +@@ -255,8 +255,10 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
2685 + ret = regmap_add_irq_chip(tps65910->regmap, tps65910->chip_irq,
2686 + IRQF_ONESHOT, pdata->irq_base,
2687 + tps6591x_irqs_chip, &tps65910->irq_data);
2688 +- if (ret < 0)
2689 ++ if (ret < 0) {
2690 + dev_warn(tps65910->dev, "Failed to add irq_chip %d\n", ret);
2691 ++ tps65910->chip_irq = 0;
2692 ++ }
2693 + return ret;
2694 + }
2695 +
2696 +diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
2697 +index ed718328eff1..e87140bef667 100644
2698 +--- a/drivers/mfd/twl-core.c
2699 ++++ b/drivers/mfd/twl-core.c
2700 +@@ -282,11 +282,11 @@ static struct reg_default twl4030_49_defaults[] = {
2701 + static bool twl4030_49_nop_reg(struct device *dev, unsigned int reg)
2702 + {
2703 + switch (reg) {
2704 +- case 0:
2705 +- case 3:
2706 +- case 40:
2707 +- case 41:
2708 +- case 42:
2709 ++ case 0x00:
2710 ++ case 0x03:
2711 ++ case 0x40:
2712 ++ case 0x41:
2713 ++ case 0x42:
2714 + return false;
2715 + default:
2716 + return true;
2717 +diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
2718 +index 89a557972d1b..5a9bfa71df86 100644
2719 +--- a/drivers/misc/mei/client.c
2720 ++++ b/drivers/misc/mei/client.c
2721 +@@ -74,23 +74,69 @@ int mei_me_cl_by_id(struct mei_device *dev, u8 client_id)
2722 +
2723 +
2724 + /**
2725 +- * mei_io_list_flush - removes list entry belonging to cl.
2726 ++ * mei_cl_cmp_id - tells if the clients are the same
2727 + *
2728 +- * @list: An instance of our list structure
2729 +- * @cl: host client
2730 ++ * @cl1: host client 1
2731 ++ * @cl2: host client 2
2732 ++ *
2733 ++ * returns true - if the clients has same host and me ids
2734 ++ * false - otherwise
2735 ++ */
2736 ++static inline bool mei_cl_cmp_id(const struct mei_cl *cl1,
2737 ++ const struct mei_cl *cl2)
2738 ++{
2739 ++ return cl1 && cl2 &&
2740 ++ (cl1->host_client_id == cl2->host_client_id) &&
2741 ++ (cl1->me_client_id == cl2->me_client_id);
2742 ++}
2743 ++
2744 ++/**
2745 ++ * mei_io_list_flush - removes cbs belonging to cl.
2746 ++ *
2747 ++ * @list: an instance of our list structure
2748 ++ * @cl: host client, can be NULL for flushing the whole list
2749 ++ * @free: whether to free the cbs
2750 + */
2751 +-void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl)
2752 ++static void __mei_io_list_flush(struct mei_cl_cb *list,
2753 ++ struct mei_cl *cl, bool free)
2754 + {
2755 + struct mei_cl_cb *cb;
2756 + struct mei_cl_cb *next;
2757 +
2758 ++ /* enable removing everything if no cl is specified */
2759 + list_for_each_entry_safe(cb, next, &list->list, list) {
2760 +- if (cb->cl && mei_cl_cmp_id(cl, cb->cl))
2761 ++ if (!cl || (cb->cl && mei_cl_cmp_id(cl, cb->cl))) {
2762 + list_del(&cb->list);
2763 ++ if (free)
2764 ++ mei_io_cb_free(cb);
2765 ++ }
2766 + }
2767 + }
2768 +
2769 + /**
2770 ++ * mei_io_list_flush - removes list entry belonging to cl.
2771 ++ *
2772 ++ * @list: An instance of our list structure
2773 ++ * @cl: host client
2774 ++ */
2775 ++static inline void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl)
2776 ++{
2777 ++ __mei_io_list_flush(list, cl, false);
2778 ++}
2779 ++
2780 ++
2781 ++/**
2782 ++ * mei_io_list_free - removes cb belonging to cl and free them
2783 ++ *
2784 ++ * @list: An instance of our list structure
2785 ++ * @cl: host client
2786 ++ */
2787 ++static inline void mei_io_list_free(struct mei_cl_cb *list, struct mei_cl *cl)
2788 ++{
2789 ++ __mei_io_list_flush(list, cl, true);
2790 ++}
2791 ++
2792 ++/**
2793 + * mei_io_cb_free - free mei_cb_private related memory
2794 + *
2795 + * @cb: mei callback struct
2796 +@@ -196,8 +242,8 @@ int mei_cl_flush_queues(struct mei_cl *cl)
2797 +
2798 + cl_dbg(dev, cl, "remove list entry belonging to cl\n");
2799 + mei_io_list_flush(&cl->dev->read_list, cl);
2800 +- mei_io_list_flush(&cl->dev->write_list, cl);
2801 +- mei_io_list_flush(&cl->dev->write_waiting_list, cl);
2802 ++ mei_io_list_free(&cl->dev->write_list, cl);
2803 ++ mei_io_list_free(&cl->dev->write_waiting_list, cl);
2804 + mei_io_list_flush(&cl->dev->ctrl_wr_list, cl);
2805 + mei_io_list_flush(&cl->dev->ctrl_rd_list, cl);
2806 + mei_io_list_flush(&cl->dev->amthif_cmd_list, cl);
2807 +@@ -942,20 +988,8 @@ void mei_cl_all_wakeup(struct mei_device *dev)
2808 + */
2809 + void mei_cl_all_write_clear(struct mei_device *dev)
2810 + {
2811 +- struct mei_cl_cb *cb, *next;
2812 +- struct list_head *list;
2813 +-
2814 +- list = &dev->write_list.list;
2815 +- list_for_each_entry_safe(cb, next, list, list) {
2816 +- list_del(&cb->list);
2817 +- mei_io_cb_free(cb);
2818 +- }
2819 +-
2820 +- list = &dev->write_waiting_list.list;
2821 +- list_for_each_entry_safe(cb, next, list, list) {
2822 +- list_del(&cb->list);
2823 +- mei_io_cb_free(cb);
2824 +- }
2825 ++ mei_io_list_free(&dev->write_list, NULL);
2826 ++ mei_io_list_free(&dev->write_waiting_list, NULL);
2827 + }
2828 +
2829 +
2830 +diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
2831 +index c8396e582f1c..0820e121d137 100644
2832 +--- a/drivers/misc/mei/client.h
2833 ++++ b/drivers/misc/mei/client.h
2834 +@@ -45,8 +45,6 @@ static inline void mei_io_list_init(struct mei_cl_cb *list)
2835 + {
2836 + INIT_LIST_HEAD(&list->list);
2837 + }
2838 +-void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl);
2839 +-
2840 + /*
2841 + * MEI Host Client Functions
2842 + */
2843 +@@ -61,22 +59,6 @@ int mei_cl_unlink(struct mei_cl *cl);
2844 + int mei_cl_flush_queues(struct mei_cl *cl);
2845 + struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl *cl);
2846 +
2847 +-/**
2848 +- * mei_cl_cmp_id - tells if file private data have same id
2849 +- *
2850 +- * @fe1: private data of 1. file object
2851 +- * @fe2: private data of 2. file object
2852 +- *
2853 +- * returns true - if ids are the same and not NULL
2854 +- */
2855 +-static inline bool mei_cl_cmp_id(const struct mei_cl *cl1,
2856 +- const struct mei_cl *cl2)
2857 +-{
2858 +- return cl1 && cl2 &&
2859 +- (cl1->host_client_id == cl2->host_client_id) &&
2860 +- (cl1->me_client_id == cl2->me_client_id);
2861 +-}
2862 +-
2863 +
2864 + int mei_cl_flow_ctrl_creds(struct mei_cl *cl);
2865 +
2866 +diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h
2867 +index 66f411a6e8ea..cabc04383685 100644
2868 +--- a/drivers/misc/mei/hw-me-regs.h
2869 ++++ b/drivers/misc/mei/hw-me-regs.h
2870 +@@ -115,6 +115,11 @@
2871 + #define MEI_DEV_ID_LPT_HR 0x8CBA /* Lynx Point H Refresh */
2872 +
2873 + #define MEI_DEV_ID_WPT_LP 0x9CBA /* Wildcat Point LP */
2874 ++
2875 ++/* Host Firmware Status Registers in PCI Config Space */
2876 ++#define PCI_CFG_HFS_1 0x40
2877 ++#define PCI_CFG_HFS_2 0x48
2878 ++
2879 + /*
2880 + * MEI HW Section
2881 + */
2882 +diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
2883 +index f0fbb5179f80..d36286874946 100644
2884 +--- a/drivers/misc/mei/interrupt.c
2885 ++++ b/drivers/misc/mei/interrupt.c
2886 +@@ -428,8 +428,7 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
2887 +
2888 + cl->status = 0;
2889 + list_del(&cb->list);
2890 +- if (MEI_WRITING == cl->writing_state &&
2891 +- cb->fop_type == MEI_FOP_WRITE &&
2892 ++ if (cb->fop_type == MEI_FOP_WRITE &&
2893 + cl != &dev->iamthif_cl) {
2894 + cl_dbg(dev, cl, "MEI WRITE COMPLETE\n");
2895 + cl->writing_state = MEI_WRITE_COMPLETE;
2896 +diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
2897 +index 5424f8ff3f7f..cfe1789923a3 100644
2898 +--- a/drivers/misc/mei/main.c
2899 ++++ b/drivers/misc/mei/main.c
2900 +@@ -653,8 +653,7 @@ static unsigned int mei_poll(struct file *file, poll_table *wait)
2901 + goto out;
2902 + }
2903 +
2904 +- if (MEI_WRITE_COMPLETE == cl->writing_state)
2905 +- mask |= (POLLIN | POLLRDNORM);
2906 ++ mask |= (POLLIN | POLLRDNORM);
2907 +
2908 + out:
2909 + mutex_unlock(&dev->device_lock);
2910 +diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
2911 +index ddadd08956f4..bf4bb74c39ff 100644
2912 +--- a/drivers/misc/mei/pci-me.c
2913 ++++ b/drivers/misc/mei/pci-me.c
2914 +@@ -100,15 +100,31 @@ static bool mei_me_quirk_probe(struct pci_dev *pdev,
2915 + const struct pci_device_id *ent)
2916 + {
2917 + u32 reg;
2918 +- if (ent->device == MEI_DEV_ID_PBG_1) {
2919 +- pci_read_config_dword(pdev, 0x48, &reg);
2920 +- /* make sure that bit 9 is up and bit 10 is down */
2921 +- if ((reg & 0x600) == 0x200) {
2922 +- dev_info(&pdev->dev, "Device doesn't have valid ME Interface\n");
2923 +- return false;
2924 +- }
2925 ++ /* Cougar Point || Patsburg */
2926 ++ if (ent->device == MEI_DEV_ID_CPT_1 ||
2927 ++ ent->device == MEI_DEV_ID_PBG_1) {
2928 ++ pci_read_config_dword(pdev, PCI_CFG_HFS_2, &reg);
2929 ++ /* make sure that bit 9 (NM) is up and bit 10 (DM) is down */
2930 ++ if ((reg & 0x600) == 0x200)
2931 ++ goto no_mei;
2932 + }
2933 ++
2934 ++ /* Lynx Point */
2935 ++ if (ent->device == MEI_DEV_ID_LPT_H ||
2936 ++ ent->device == MEI_DEV_ID_LPT_W ||
2937 ++ ent->device == MEI_DEV_ID_LPT_HR) {
2938 ++ /* Read ME FW Status check for SPS Firmware */
2939 ++ pci_read_config_dword(pdev, PCI_CFG_HFS_1, &reg);
2940 ++ /* if bits [19:16] = 15, running SPS Firmware */
2941 ++ if ((reg & 0xf0000) == 0xf0000)
2942 ++ goto no_mei;
2943 ++ }
2944 ++
2945 + return true;
2946 ++
2947 ++no_mei:
2948 ++ dev_info(&pdev->dev, "Device doesn't have valid ME Interface\n");
2949 ++ return false;
2950 + }
2951 + /**
2952 + * mei_probe - Device Initialization Routine
2953 +diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
2954 +index e8663a8c3406..ee082509b0ba 100644
2955 +--- a/drivers/pci/host/pci-imx6.c
2956 ++++ b/drivers/pci/host/pci-imx6.c
2957 +@@ -424,20 +424,40 @@ static void imx6_pcie_reset_phy(struct pcie_port *pp)
2958 +
2959 + static int imx6_pcie_link_up(struct pcie_port *pp)
2960 + {
2961 +- u32 rc, ltssm, rx_valid;
2962 ++ u32 rc, debug_r0, rx_valid;
2963 ++ int count = 5;
2964 +
2965 + /*
2966 +- * Test if the PHY reports that the link is up and also that
2967 +- * the link training finished. It might happen that the PHY
2968 +- * reports the link is already up, but the link training bit
2969 +- * is still set, so make sure to check the training is done
2970 +- * as well here.
2971 ++ * Test if the PHY reports that the link is up and also that the LTSSM
2972 ++ * training finished. There are three possible states of the link when
2973 ++ * this code is called:
2974 ++ * 1) The link is DOWN (unlikely)
2975 ++ * The link didn't come up yet for some reason. This usually means
2976 ++ * we have a real problem somewhere. Reset the PHY and exit. This
2977 ++ * state calls for inspection of the DEBUG registers.
2978 ++ * 2) The link is UP, but still in LTSSM training
2979 ++ * Wait for the training to finish, which should take a very short
2980 ++ * time. If the training does not finish, we have a problem and we
2981 ++ * need to inspect the DEBUG registers. If the training does finish,
2982 ++ * the link is up and operating correctly.
2983 ++ * 3) The link is UP and no longer in LTSSM training
2984 ++ * The link is up and operating correctly.
2985 + */
2986 +- rc = readl(pp->dbi_base + PCIE_PHY_DEBUG_R1);
2987 +- if ((rc & PCIE_PHY_DEBUG_R1_XMLH_LINK_UP) &&
2988 +- !(rc & PCIE_PHY_DEBUG_R1_XMLH_LINK_IN_TRAINING))
2989 +- return 1;
2990 +-
2991 ++ while (1) {
2992 ++ rc = readl(pp->dbi_base + PCIE_PHY_DEBUG_R1);
2993 ++ if (!(rc & PCIE_PHY_DEBUG_R1_XMLH_LINK_UP))
2994 ++ break;
2995 ++ if (!(rc & PCIE_PHY_DEBUG_R1_XMLH_LINK_IN_TRAINING))
2996 ++ return 1;
2997 ++ if (!count--)
2998 ++ break;
2999 ++ dev_dbg(pp->dev, "Link is up, but still in training\n");
3000 ++ /*
3001 ++ * Wait a little bit, then re-check if the link finished
3002 ++ * the training.
3003 ++ */
3004 ++ usleep_range(1000, 2000);
3005 ++ }
3006 + /*
3007 + * From L0, initiate MAC entry to gen2 if EP/RC supports gen2.
3008 + * Wait 2ms (LTSSM timeout is 24ms, PHY lock is ~5us in gen2).
3009 +@@ -446,15 +466,16 @@ static int imx6_pcie_link_up(struct pcie_port *pp)
3010 + * to gen2 is stuck
3011 + */
3012 + pcie_phy_read(pp->dbi_base, PCIE_PHY_RX_ASIC_OUT, &rx_valid);
3013 +- ltssm = readl(pp->dbi_base + PCIE_PHY_DEBUG_R0) & 0x3F;
3014 ++ debug_r0 = readl(pp->dbi_base + PCIE_PHY_DEBUG_R0);
3015 +
3016 + if (rx_valid & 0x01)
3017 + return 0;
3018 +
3019 +- if (ltssm != 0x0d)
3020 ++ if ((debug_r0 & 0x3f) != 0x0d)
3021 + return 0;
3022 +
3023 + dev_err(pp->dev, "transition to gen2 is stuck, reset PHY!\n");
3024 ++ dev_dbg(pp->dev, "debug_r0=%08x debug_r1=%08x\n", debug_r0, rc);
3025 +
3026 + imx6_pcie_reset_phy(pp);
3027 +
3028 +diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
3029 +index 0e79665afd44..05e352889868 100644
3030 +--- a/drivers/pci/host/pci-mvebu.c
3031 ++++ b/drivers/pci/host/pci-mvebu.c
3032 +@@ -797,7 +797,7 @@ static int mvebu_get_tgt_attr(struct device_node *np, int devfn,
3033 +
3034 + for (i = 0; i < nranges; i++) {
3035 + u32 flags = of_read_number(range, 1);
3036 +- u32 slot = of_read_number(range, 2);
3037 ++ u32 slot = of_read_number(range + 1, 1);
3038 + u64 cpuaddr = of_read_number(range + na, pna);
3039 + unsigned long rtype;
3040 +
3041 +diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
3042 +index 4f6c2055f6b2..f0ea4fdfde87 100644
3043 +--- a/drivers/regulator/arizona-ldo1.c
3044 ++++ b/drivers/regulator/arizona-ldo1.c
3045 +@@ -153,11 +153,9 @@ static const struct regulator_desc arizona_ldo1 = {
3046 +
3047 + .vsel_reg = ARIZONA_LDO1_CONTROL_1,
3048 + .vsel_mask = ARIZONA_LDO1_VSEL_MASK,
3049 +- .bypass_reg = ARIZONA_LDO1_CONTROL_1,
3050 +- .bypass_mask = ARIZONA_LDO1_BYPASS,
3051 + .min_uV = 900000,
3052 +- .uV_step = 50000,
3053 +- .n_voltages = 7,
3054 ++ .uV_step = 25000,
3055 ++ .n_voltages = 13,
3056 + .enable_time = 500,
3057 +
3058 + .owner = THIS_MODULE,
3059 +@@ -203,6 +201,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
3060 + */
3061 + switch (arizona->type) {
3062 + case WM5102:
3063 ++ case WM8997:
3064 + desc = &arizona_ldo1_hc;
3065 + ldo1->init_data = arizona_ldo1_dvfs;
3066 + break;
3067 +diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
3068 +index eb5d22795c47..bb86494e2b7b 100644
3069 +--- a/drivers/s390/char/con3215.c
3070 ++++ b/drivers/s390/char/con3215.c
3071 +@@ -922,7 +922,7 @@ static int __init con3215_init(void)
3072 + raw3215_freelist = req;
3073 + }
3074 +
3075 +- cdev = ccw_device_probe_console();
3076 ++ cdev = ccw_device_probe_console(&raw3215_ccw_driver);
3077 + if (IS_ERR(cdev))
3078 + return -ENODEV;
3079 +
3080 +diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
3081 +index 699fd3e363df..bb6b0df50b33 100644
3082 +--- a/drivers/s390/char/con3270.c
3083 ++++ b/drivers/s390/char/con3270.c
3084 +@@ -576,7 +576,6 @@ static struct console con3270 = {
3085 + static int __init
3086 + con3270_init(void)
3087 + {
3088 +- struct ccw_device *cdev;
3089 + struct raw3270 *rp;
3090 + void *cbuf;
3091 + int i;
3092 +@@ -591,10 +590,7 @@ con3270_init(void)
3093 + cpcmd("TERM AUTOCR OFF", NULL, 0, NULL);
3094 + }
3095 +
3096 +- cdev = ccw_device_probe_console();
3097 +- if (IS_ERR(cdev))
3098 +- return -ENODEV;
3099 +- rp = raw3270_setup_console(cdev);
3100 ++ rp = raw3270_setup_console();
3101 + if (IS_ERR(rp))
3102 + return PTR_ERR(rp);
3103 +
3104 +diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
3105 +index 2cdec21e8924..de2c0483949f 100644
3106 +--- a/drivers/s390/char/raw3270.c
3107 ++++ b/drivers/s390/char/raw3270.c
3108 +@@ -776,16 +776,24 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc)
3109 + }
3110 +
3111 + #ifdef CONFIG_TN3270_CONSOLE
3112 ++/* Tentative definition - see below for actual definition. */
3113 ++static struct ccw_driver raw3270_ccw_driver;
3114 ++
3115 + /*
3116 + * Setup 3270 device configured as console.
3117 + */
3118 +-struct raw3270 __init *raw3270_setup_console(struct ccw_device *cdev)
3119 ++struct raw3270 __init *raw3270_setup_console(void)
3120 + {
3121 ++ struct ccw_device *cdev;
3122 + unsigned long flags;
3123 + struct raw3270 *rp;
3124 + char *ascebc;
3125 + int rc;
3126 +
3127 ++ cdev = ccw_device_probe_console(&raw3270_ccw_driver);
3128 ++ if (IS_ERR(cdev))
3129 ++ return ERR_CAST(cdev);
3130 ++
3131 + rp = kzalloc(sizeof(struct raw3270), GFP_KERNEL | GFP_DMA);
3132 + ascebc = kzalloc(256, GFP_KERNEL);
3133 + rc = raw3270_setup_device(cdev, rp, ascebc);
3134 +diff --git a/drivers/s390/char/raw3270.h b/drivers/s390/char/raw3270.h
3135 +index 7b73ff8c1bd7..359276a88396 100644
3136 +--- a/drivers/s390/char/raw3270.h
3137 ++++ b/drivers/s390/char/raw3270.h
3138 +@@ -190,7 +190,7 @@ raw3270_put_view(struct raw3270_view *view)
3139 + wake_up(&raw3270_wait_queue);
3140 + }
3141 +
3142 +-struct raw3270 *raw3270_setup_console(struct ccw_device *cdev);
3143 ++struct raw3270 *raw3270_setup_console(void);
3144 + void raw3270_wait_cons_dev(struct raw3270 *);
3145 +
3146 + /* Notifier for device addition/removal */
3147 +diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
3148 +index e9d783563cbb..4283dd3cdd49 100644
3149 +--- a/drivers/s390/cio/device.c
3150 ++++ b/drivers/s390/cio/device.c
3151 +@@ -1609,7 +1609,7 @@ out_unlock:
3152 + return rc;
3153 + }
3154 +
3155 +-struct ccw_device *ccw_device_probe_console(void)
3156 ++struct ccw_device *ccw_device_probe_console(struct ccw_driver *drv)
3157 + {
3158 + struct io_subchannel_private *io_priv;
3159 + struct ccw_device *cdev;
3160 +@@ -1631,6 +1631,7 @@ struct ccw_device *ccw_device_probe_console(void)
3161 + kfree(io_priv);
3162 + return cdev;
3163 + }
3164 ++ cdev->drv = drv;
3165 + set_io_private(sch, io_priv);
3166 + ret = ccw_device_console_enable(cdev, sch);
3167 + if (ret) {
3168 +diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
3169 +index 4f6a30b8e5f9..652b41b4ddbd 100644
3170 +--- a/drivers/scsi/arcmsr/arcmsr_hba.c
3171 ++++ b/drivers/scsi/arcmsr/arcmsr_hba.c
3172 +@@ -2500,16 +2500,15 @@ static int arcmsr_polling_ccbdone(struct AdapterControlBlock *acb,
3173 + static int arcmsr_iop_confirm(struct AdapterControlBlock *acb)
3174 + {
3175 + uint32_t cdb_phyaddr, cdb_phyaddr_hi32;
3176 +- dma_addr_t dma_coherent_handle;
3177 ++
3178 + /*
3179 + ********************************************************************
3180 + ** here we need to tell iop 331 our freeccb.HighPart
3181 + ** if freeccb.HighPart is not zero
3182 + ********************************************************************
3183 + */
3184 +- dma_coherent_handle = acb->dma_coherent_handle;
3185 +- cdb_phyaddr = (uint32_t)(dma_coherent_handle);
3186 +- cdb_phyaddr_hi32 = (uint32_t)((cdb_phyaddr >> 16) >> 16);
3187 ++ cdb_phyaddr = lower_32_bits(acb->dma_coherent_handle);
3188 ++ cdb_phyaddr_hi32 = upper_32_bits(acb->dma_coherent_handle);
3189 + acb->cdb_phyaddr_hi32 = cdb_phyaddr_hi32;
3190 + /*
3191 + ***********************************************************************
3192 +diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
3193 +index 89a53002b585..83cb61266979 100644
3194 +--- a/drivers/scsi/qla2xxx/qla_os.c
3195 ++++ b/drivers/scsi/qla2xxx/qla_os.c
3196 +@@ -2536,7 +2536,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
3197 + ha->flags.enable_64bit_addressing ? "enable" :
3198 + "disable");
3199 + ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp);
3200 +- if (!ret) {
3201 ++ if (ret) {
3202 + ql_log_pci(ql_log_fatal, pdev, 0x0031,
3203 + "Failed to allocate memory for adapter, aborting.\n");
3204 +
3205 +@@ -3478,10 +3478,10 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
3206 + else {
3207 + qla2x00_set_reserved_loop_ids(ha);
3208 + ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123,
3209 +- "loop_id_map=%p. \n", ha->loop_id_map);
3210 ++ "loop_id_map=%p.\n", ha->loop_id_map);
3211 + }
3212 +
3213 +- return 1;
3214 ++ return 0;
3215 +
3216 + fail_async_pd:
3217 + dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma);
3218 +diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
3219 +index bf98d63d92b3..e63d27013142 100644
3220 +--- a/drivers/spi/spi-dw.c
3221 ++++ b/drivers/spi/spi-dw.c
3222 +@@ -671,12 +671,6 @@ static int dw_spi_setup(struct spi_device *spi)
3223 + return 0;
3224 + }
3225 +
3226 +-static void dw_spi_cleanup(struct spi_device *spi)
3227 +-{
3228 +- struct chip_data *chip = spi_get_ctldata(spi);
3229 +- kfree(chip);
3230 +-}
3231 +-
3232 + static int init_queue(struct dw_spi *dws)
3233 + {
3234 + INIT_LIST_HEAD(&dws->queue);
3235 +@@ -806,7 +800,6 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
3236 + master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
3237 + master->bus_num = dws->bus_num;
3238 + master->num_chipselect = dws->num_cs;
3239 +- master->cleanup = dw_spi_cleanup;
3240 + master->setup = dw_spi_setup;
3241 + master->transfer = dw_spi_transfer;
3242 +
3243 +diff --git a/drivers/spi/spi-efm32.c b/drivers/spi/spi-efm32.c
3244 +index d4d3cc534792..8933eb7ab79b 100644
3245 +--- a/drivers/spi/spi-efm32.c
3246 ++++ b/drivers/spi/spi-efm32.c
3247 +@@ -487,6 +487,9 @@ static int efm32_spi_remove(struct platform_device *pdev)
3248 +
3249 + static const struct of_device_id efm32_spi_dt_ids[] = {
3250 + {
3251 ++ .compatible = "energymicro,efm32-spi",
3252 ++ }, {
3253 ++ /* doesn't follow the "vendor,device" scheme, don't use */
3254 + .compatible = "efm32,spi",
3255 + }, {
3256 + /* sentinel */
3257 +diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
3258 +index 71db683098d6..b59af0303581 100644
3259 +--- a/drivers/staging/comedi/drivers/usbdux.c
3260 ++++ b/drivers/staging/comedi/drivers/usbdux.c
3261 +@@ -493,7 +493,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
3262 + /* pointer to the DA */
3263 + *datap++ = val & 0xff;
3264 + *datap++ = (val >> 8) & 0xff;
3265 +- *datap++ = chan;
3266 ++ *datap++ = chan << 6;
3267 + devpriv->ao_readback[chan] = val;
3268 +
3269 + s->async->events |= COMEDI_CB_BLOCK;
3270 +@@ -1040,11 +1040,8 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
3271 + /* set current channel of the running acquisition to zero */
3272 + s->async->cur_chan = 0;
3273 +
3274 +- for (i = 0; i < cmd->chanlist_len; ++i) {
3275 +- unsigned int chan = CR_CHAN(cmd->chanlist[i]);
3276 +-
3277 +- devpriv->ao_chanlist[i] = chan << 6;
3278 +- }
3279 ++ for (i = 0; i < cmd->chanlist_len; ++i)
3280 ++ devpriv->ao_chanlist[i] = CR_CHAN(cmd->chanlist[i]);
3281 +
3282 + /* we count in steps of 1ms (125us) */
3283 + /* 125us mode not used yet */
3284 +diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c
3285 +index c9c180649c12..cec3f1628cd8 100644
3286 +--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
3287 ++++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
3288 +@@ -542,7 +542,7 @@ _func_exit_;
3289 + /* set the security information in the recv_frame */
3290 + static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame)
3291 + {
3292 +- u8 *psta_addr = NULL, *ptr;
3293 ++ u8 *psta_addr, *ptr;
3294 + uint auth_alg;
3295 + struct recv_frame_hdr *pfhdr;
3296 + struct sta_info *psta;
3297 +@@ -556,7 +556,6 @@ static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *pre
3298 + _func_enter_;
3299 +
3300 + pstapriv = &adapter->stapriv;
3301 +- psta = rtw_get_stainfo(pstapriv, psta_addr);
3302 +
3303 + auth_alg = adapter->securitypriv.dot11AuthAlgrthm;
3304 +
3305 +@@ -564,6 +563,7 @@ _func_enter_;
3306 + pfhdr = &precv_frame->u.hdr;
3307 + pattrib = &pfhdr->attrib;
3308 + psta_addr = pattrib->ta;
3309 ++ psta = rtw_get_stainfo(pstapriv, psta_addr);
3310 +
3311 + prtnframe = NULL;
3312 +
3313 +diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c
3314 +index 23ec684b60e1..274c359279ef 100644
3315 +--- a/drivers/staging/rtl8712/rtl871x_recv.c
3316 ++++ b/drivers/staging/rtl8712/rtl871x_recv.c
3317 +@@ -254,7 +254,7 @@ union recv_frame *r8712_portctrl(struct _adapter *adapter,
3318 + struct sta_info *psta;
3319 + struct sta_priv *pstapriv;
3320 + union recv_frame *prtnframe;
3321 +- u16 ether_type = 0;
3322 ++ u16 ether_type;
3323 +
3324 + pstapriv = &adapter->stapriv;
3325 + ptr = get_recvframe_data(precv_frame);
3326 +@@ -263,15 +263,14 @@ union recv_frame *r8712_portctrl(struct _adapter *adapter,
3327 + psta = r8712_get_stainfo(pstapriv, psta_addr);
3328 + auth_alg = adapter->securitypriv.AuthAlgrthm;
3329 + if (auth_alg == 2) {
3330 ++ /* get ether_type */
3331 ++ ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE;
3332 ++ memcpy(&ether_type, ptr, 2);
3333 ++ ether_type = ntohs((unsigned short)ether_type);
3334 ++
3335 + if ((psta != NULL) && (psta->ieee8021x_blocked)) {
3336 + /* blocked
3337 + * only accept EAPOL frame */
3338 +- prtnframe = precv_frame;
3339 +- /*get ether_type */
3340 +- ptr = ptr + pfhdr->attrib.hdrlen +
3341 +- pfhdr->attrib.iv_len + LLC_HEADER_SIZE;
3342 +- memcpy(&ether_type, ptr, 2);
3343 +- ether_type = ntohs((unsigned short)ether_type);
3344 + if (ether_type == 0x888e)
3345 + prtnframe = precv_frame;
3346 + else {
3347 +diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
3348 +index f0fcbf7c7d7f..868226953d5c 100644
3349 +--- a/drivers/staging/serqt_usb2/serqt_usb2.c
3350 ++++ b/drivers/staging/serqt_usb2/serqt_usb2.c
3351 +@@ -724,7 +724,7 @@ static int qt_startup(struct usb_serial *serial)
3352 + goto startup_error;
3353 + }
3354 +
3355 +- switch (serial->dev->descriptor.idProduct) {
3356 ++ switch (le16_to_cpu(serial->dev->descriptor.idProduct)) {
3357 + case QUATECH_DSU100:
3358 + case QUATECH_QSU100:
3359 + case QUATECH_ESU100A:
3360 +diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
3361 +index b83ec378d04f..7e5469a80fe3 100644
3362 +--- a/drivers/target/iscsi/iscsi_target.c
3363 ++++ b/drivers/target/iscsi/iscsi_target.c
3364 +@@ -2468,6 +2468,7 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn)
3365 + {
3366 + struct iscsi_cmd *cmd;
3367 + struct iscsi_conn *conn_p;
3368 ++ bool found = false;
3369 +
3370 + /*
3371 + * Only send a Asynchronous Message on connections whos network
3372 +@@ -2476,11 +2477,12 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn)
3373 + list_for_each_entry(conn_p, &conn->sess->sess_conn_list, conn_list) {
3374 + if (conn_p->conn_state == TARG_CONN_STATE_LOGGED_IN) {
3375 + iscsit_inc_conn_usage_count(conn_p);
3376 ++ found = true;
3377 + break;
3378 + }
3379 + }
3380 +
3381 +- if (!conn_p)
3382 ++ if (!found)
3383 + return;
3384 +
3385 + cmd = iscsit_allocate_cmd(conn_p, TASK_RUNNING);
3386 +diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
3387 +index 554d4f75a75a..9e0232cca92e 100644
3388 +--- a/drivers/target/target_core_iblock.c
3389 ++++ b/drivers/target/target_core_iblock.c
3390 +@@ -203,10 +203,9 @@ static void iblock_free_device(struct se_device *dev)
3391 +
3392 + if (ib_dev->ibd_bd != NULL)
3393 + blkdev_put(ib_dev->ibd_bd, FMODE_WRITE|FMODE_READ|FMODE_EXCL);
3394 +- if (ib_dev->ibd_bio_set != NULL) {
3395 +- bioset_integrity_free(ib_dev->ibd_bio_set);
3396 ++ if (ib_dev->ibd_bio_set != NULL)
3397 + bioset_free(ib_dev->ibd_bio_set);
3398 +- }
3399 ++
3400 + kfree(ib_dev);
3401 + }
3402 +
3403 +diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
3404 +index 66a5aba5a0d9..b920db3388cd 100644
3405 +--- a/drivers/target/target_core_rd.c
3406 ++++ b/drivers/target/target_core_rd.c
3407 +@@ -242,7 +242,7 @@ static void rd_release_prot_space(struct rd_dev *rd_dev)
3408 + rd_dev->sg_prot_count = 0;
3409 + }
3410 +
3411 +-static int rd_build_prot_space(struct rd_dev *rd_dev, int prot_length)
3412 ++static int rd_build_prot_space(struct rd_dev *rd_dev, int prot_length, int block_size)
3413 + {
3414 + struct rd_dev_sg_table *sg_table;
3415 + u32 total_sg_needed, sg_tables;
3416 +@@ -252,8 +252,13 @@ static int rd_build_prot_space(struct rd_dev *rd_dev, int prot_length)
3417 +
3418 + if (rd_dev->rd_flags & RDF_NULLIO)
3419 + return 0;
3420 +-
3421 +- total_sg_needed = rd_dev->rd_page_count / prot_length;
3422 ++ /*
3423 ++ * prot_length=8byte dif data
3424 ++ * tot sg needed = rd_page_count * (PGSZ/block_size) *
3425 ++ * (prot_length/block_size) + pad
3426 ++ * PGSZ canceled each other.
3427 ++ */
3428 ++ total_sg_needed = (rd_dev->rd_page_count * prot_length / block_size) + 1;
3429 +
3430 + sg_tables = (total_sg_needed / max_sg_per_table) + 1;
3431 +
3432 +@@ -606,7 +611,8 @@ static int rd_init_prot(struct se_device *dev)
3433 + if (!dev->dev_attrib.pi_prot_type)
3434 + return 0;
3435 +
3436 +- return rd_build_prot_space(rd_dev, dev->prot_length);
3437 ++ return rd_build_prot_space(rd_dev, dev->prot_length,
3438 ++ dev->dev_attrib.block_size);
3439 + }
3440 +
3441 + static void rd_free_prot(struct se_device *dev)
3442 +diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
3443 +index 77e6531fb0a1..aa064a7bb446 100644
3444 +--- a/drivers/target/target_core_sbc.c
3445 ++++ b/drivers/target/target_core_sbc.c
3446 +@@ -425,13 +425,14 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd)
3447 + goto out;
3448 + }
3449 +
3450 +- write_sg = kzalloc(sizeof(struct scatterlist) * cmd->t_data_nents,
3451 ++ write_sg = kmalloc(sizeof(struct scatterlist) * cmd->t_data_nents,
3452 + GFP_KERNEL);
3453 + if (!write_sg) {
3454 + pr_err("Unable to allocate compare_and_write sg\n");
3455 + ret = TCM_OUT_OF_RESOURCES;
3456 + goto out;
3457 + }
3458 ++ sg_init_table(write_sg, cmd->t_data_nents);
3459 + /*
3460 + * Setup verify and write data payloads from total NumberLBAs.
3461 + */
3462 +diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
3463 +index ae52c08dad09..e9fe60fa7df1 100644
3464 +--- a/drivers/target/tcm_fc/tfc_sess.c
3465 ++++ b/drivers/target/tcm_fc/tfc_sess.c
3466 +@@ -68,6 +68,7 @@ static struct ft_tport *ft_tport_create(struct fc_lport *lport)
3467 +
3468 + if (tport) {
3469 + tport->tpg = tpg;
3470 ++ tpg->tport = tport;
3471 + return tport;
3472 + }
3473 +
3474 +diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
3475 +index 50b46881b6ca..94f9e3a38412 100644
3476 +--- a/drivers/tty/hvc/hvc_console.c
3477 ++++ b/drivers/tty/hvc/hvc_console.c
3478 +@@ -31,6 +31,7 @@
3479 + #include <linux/list.h>
3480 + #include <linux/module.h>
3481 + #include <linux/major.h>
3482 ++#include <linux/atomic.h>
3483 + #include <linux/sysrq.h>
3484 + #include <linux/tty.h>
3485 + #include <linux/tty_flip.h>
3486 +@@ -70,6 +71,9 @@ static struct task_struct *hvc_task;
3487 + /* Picks up late kicks after list walk but before schedule() */
3488 + static int hvc_kicked;
3489 +
3490 ++/* hvc_init is triggered from hvc_alloc, i.e. only when actually used */
3491 ++static atomic_t hvc_needs_init __read_mostly = ATOMIC_INIT(-1);
3492 ++
3493 + static int hvc_init(void);
3494 +
3495 + #ifdef CONFIG_MAGIC_SYSRQ
3496 +@@ -851,7 +855,7 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
3497 + int i;
3498 +
3499 + /* We wait until a driver actually comes along */
3500 +- if (!hvc_driver) {
3501 ++ if (atomic_inc_not_zero(&hvc_needs_init)) {
3502 + int err = hvc_init();
3503 + if (err)
3504 + return ERR_PTR(err);
3505 +diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
3506 +index ab90a0156828..4ebf1b2034e8 100644
3507 +--- a/drivers/usb/core/driver.c
3508 ++++ b/drivers/usb/core/driver.c
3509 +@@ -990,8 +990,7 @@ EXPORT_SYMBOL_GPL(usb_deregister);
3510 + * it doesn't support pre_reset/post_reset/reset_resume or
3511 + * because it doesn't support suspend/resume.
3512 + *
3513 +- * The caller must hold @intf's device's lock, but not its pm_mutex
3514 +- * and not @intf->dev.sem.
3515 ++ * The caller must hold @intf's device's lock, but not @intf's lock.
3516 + */
3517 + void usb_forced_unbind_intf(struct usb_interface *intf)
3518 + {
3519 +@@ -1004,16 +1003,37 @@ void usb_forced_unbind_intf(struct usb_interface *intf)
3520 + intf->needs_binding = 1;
3521 + }
3522 +
3523 ++/*
3524 ++ * Unbind drivers for @udev's marked interfaces. These interfaces have
3525 ++ * the needs_binding flag set, for example by usb_resume_interface().
3526 ++ *
3527 ++ * The caller must hold @udev's device lock.
3528 ++ */
3529 ++static void unbind_marked_interfaces(struct usb_device *udev)
3530 ++{
3531 ++ struct usb_host_config *config;
3532 ++ int i;
3533 ++ struct usb_interface *intf;
3534 ++
3535 ++ config = udev->actconfig;
3536 ++ if (config) {
3537 ++ for (i = 0; i < config->desc.bNumInterfaces; ++i) {
3538 ++ intf = config->interface[i];
3539 ++ if (intf->dev.driver && intf->needs_binding)
3540 ++ usb_forced_unbind_intf(intf);
3541 ++ }
3542 ++ }
3543 ++}
3544 ++
3545 + /* Delayed forced unbinding of a USB interface driver and scan
3546 + * for rebinding.
3547 + *
3548 +- * The caller must hold @intf's device's lock, but not its pm_mutex
3549 +- * and not @intf->dev.sem.
3550 ++ * The caller must hold @intf's device's lock, but not @intf's lock.
3551 + *
3552 + * Note: Rebinds will be skipped if a system sleep transition is in
3553 + * progress and the PM "complete" callback hasn't occurred yet.
3554 + */
3555 +-void usb_rebind_intf(struct usb_interface *intf)
3556 ++static void usb_rebind_intf(struct usb_interface *intf)
3557 + {
3558 + int rc;
3559 +
3560 +@@ -1030,68 +1050,66 @@ void usb_rebind_intf(struct usb_interface *intf)
3561 + }
3562 + }
3563 +
3564 +-#ifdef CONFIG_PM
3565 +-
3566 +-/* Unbind drivers for @udev's interfaces that don't support suspend/resume
3567 +- * There is no check for reset_resume here because it can be determined
3568 +- * only during resume whether reset_resume is needed.
3569 ++/*
3570 ++ * Rebind drivers to @udev's marked interfaces. These interfaces have
3571 ++ * the needs_binding flag set.
3572 + *
3573 + * The caller must hold @udev's device lock.
3574 + */
3575 +-static void unbind_no_pm_drivers_interfaces(struct usb_device *udev)
3576 ++static void rebind_marked_interfaces(struct usb_device *udev)
3577 + {
3578 + struct usb_host_config *config;
3579 + int i;
3580 + struct usb_interface *intf;
3581 +- struct usb_driver *drv;
3582 +
3583 + config = udev->actconfig;
3584 + if (config) {
3585 + for (i = 0; i < config->desc.bNumInterfaces; ++i) {
3586 + intf = config->interface[i];
3587 +-
3588 +- if (intf->dev.driver) {
3589 +- drv = to_usb_driver(intf->dev.driver);
3590 +- if (!drv->suspend || !drv->resume)
3591 +- usb_forced_unbind_intf(intf);
3592 +- }
3593 ++ if (intf->needs_binding)
3594 ++ usb_rebind_intf(intf);
3595 + }
3596 + }
3597 + }
3598 +
3599 +-/* Unbind drivers for @udev's interfaces that failed to support reset-resume.
3600 +- * These interfaces have the needs_binding flag set by usb_resume_interface().
3601 ++/*
3602 ++ * Unbind all of @udev's marked interfaces and then rebind all of them.
3603 ++ * This ordering is necessary because some drivers claim several interfaces
3604 ++ * when they are first probed.
3605 + *
3606 + * The caller must hold @udev's device lock.
3607 + */
3608 +-static void unbind_no_reset_resume_drivers_interfaces(struct usb_device *udev)
3609 ++void usb_unbind_and_rebind_marked_interfaces(struct usb_device *udev)
3610 + {
3611 +- struct usb_host_config *config;
3612 +- int i;
3613 +- struct usb_interface *intf;
3614 +-
3615 +- config = udev->actconfig;
3616 +- if (config) {
3617 +- for (i = 0; i < config->desc.bNumInterfaces; ++i) {
3618 +- intf = config->interface[i];
3619 +- if (intf->dev.driver && intf->needs_binding)
3620 +- usb_forced_unbind_intf(intf);
3621 +- }
3622 +- }
3623 ++ unbind_marked_interfaces(udev);
3624 ++ rebind_marked_interfaces(udev);
3625 + }
3626 +
3627 +-static void do_rebind_interfaces(struct usb_device *udev)
3628 ++#ifdef CONFIG_PM
3629 ++
3630 ++/* Unbind drivers for @udev's interfaces that don't support suspend/resume
3631 ++ * There is no check for reset_resume here because it can be determined
3632 ++ * only during resume whether reset_resume is needed.
3633 ++ *
3634 ++ * The caller must hold @udev's device lock.
3635 ++ */
3636 ++static void unbind_no_pm_drivers_interfaces(struct usb_device *udev)
3637 + {
3638 + struct usb_host_config *config;
3639 + int i;
3640 + struct usb_interface *intf;
3641 ++ struct usb_driver *drv;
3642 +
3643 + config = udev->actconfig;
3644 + if (config) {
3645 + for (i = 0; i < config->desc.bNumInterfaces; ++i) {
3646 + intf = config->interface[i];
3647 +- if (intf->needs_binding)
3648 +- usb_rebind_intf(intf);
3649 ++
3650 ++ if (intf->dev.driver) {
3651 ++ drv = to_usb_driver(intf->dev.driver);
3652 ++ if (!drv->suspend || !drv->resume)
3653 ++ usb_forced_unbind_intf(intf);
3654 ++ }
3655 + }
3656 + }
3657 + }
3658 +@@ -1420,7 +1438,7 @@ int usb_resume_complete(struct device *dev)
3659 + * whose needs_binding flag is set
3660 + */
3661 + if (udev->state != USB_STATE_NOTATTACHED)
3662 +- do_rebind_interfaces(udev);
3663 ++ rebind_marked_interfaces(udev);
3664 + return 0;
3665 + }
3666 +
3667 +@@ -1442,7 +1460,7 @@ int usb_resume(struct device *dev, pm_message_t msg)
3668 + pm_runtime_disable(dev);
3669 + pm_runtime_set_active(dev);
3670 + pm_runtime_enable(dev);
3671 +- unbind_no_reset_resume_drivers_interfaces(udev);
3672 ++ unbind_marked_interfaces(udev);
3673 + }
3674 +
3675 + /* Avoid PM error messages for devices disconnected while suspended
3676 +diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
3677 +index d59d99347d54..1f02e65fe305 100644
3678 +--- a/drivers/usb/core/hcd-pci.c
3679 ++++ b/drivers/usb/core/hcd-pci.c
3680 +@@ -75,7 +75,7 @@ static void for_each_companion(struct pci_dev *pdev, struct usb_hcd *hcd,
3681 + PCI_SLOT(companion->devfn) != slot)
3682 + continue;
3683 + companion_hcd = pci_get_drvdata(companion);
3684 +- if (!companion_hcd)
3685 ++ if (!companion_hcd || !companion_hcd->self.root_hub)
3686 + continue;
3687 + fn(pdev, hcd, companion, companion_hcd);
3688 + }
3689 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
3690 +index 64ea21971be2..d498d03afdbd 100644
3691 +--- a/drivers/usb/core/hub.c
3692 ++++ b/drivers/usb/core/hub.c
3693 +@@ -5340,10 +5340,11 @@ int usb_reset_device(struct usb_device *udev)
3694 + else if (cintf->condition ==
3695 + USB_INTERFACE_BOUND)
3696 + rebind = 1;
3697 ++ if (rebind)
3698 ++ cintf->needs_binding = 1;
3699 + }
3700 +- if (ret == 0 && rebind)
3701 +- usb_rebind_intf(cintf);
3702 + }
3703 ++ usb_unbind_and_rebind_marked_interfaces(udev);
3704 + }
3705 +
3706 + usb_autosuspend_device(udev);
3707 +diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
3708 +index 823857767a16..0923add72b59 100644
3709 +--- a/drivers/usb/core/usb.h
3710 ++++ b/drivers/usb/core/usb.h
3711 +@@ -55,7 +55,7 @@ extern int usb_match_one_id_intf(struct usb_device *dev,
3712 + extern int usb_match_device(struct usb_device *dev,
3713 + const struct usb_device_id *id);
3714 + extern void usb_forced_unbind_intf(struct usb_interface *intf);
3715 +-extern void usb_rebind_intf(struct usb_interface *intf);
3716 ++extern void usb_unbind_and_rebind_marked_interfaces(struct usb_device *udev);
3717 +
3718 + extern int usb_hub_claim_port(struct usb_device *hdev, unsigned port,
3719 + struct dev_state *owner);
3720 +diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
3721 +index f8af8d44af85..546e67a2e4cd 100644
3722 +--- a/drivers/usb/dwc3/core.h
3723 ++++ b/drivers/usb/dwc3/core.h
3724 +@@ -815,15 +815,15 @@ struct dwc3_event_depevt {
3725 + * 12 - VndrDevTstRcved
3726 + * @reserved15_12: Reserved, not used
3727 + * @event_info: Information about this event
3728 +- * @reserved31_24: Reserved, not used
3729 ++ * @reserved31_25: Reserved, not used
3730 + */
3731 + struct dwc3_event_devt {
3732 + u32 one_bit:1;
3733 + u32 device_event:7;
3734 + u32 type:4;
3735 + u32 reserved15_12:4;
3736 +- u32 event_info:8;
3737 +- u32 reserved31_24:8;
3738 ++ u32 event_info:9;
3739 ++ u32 reserved31_25:7;
3740 + } __packed;
3741 +
3742 + /**
3743 +@@ -856,6 +856,19 @@ union dwc3_event {
3744 + struct dwc3_event_gevt gevt;
3745 + };
3746 +
3747 ++/**
3748 ++ * struct dwc3_gadget_ep_cmd_params - representation of endpoint command
3749 ++ * parameters
3750 ++ * @param2: third parameter
3751 ++ * @param1: second parameter
3752 ++ * @param0: first parameter
3753 ++ */
3754 ++struct dwc3_gadget_ep_cmd_params {
3755 ++ u32 param2;
3756 ++ u32 param1;
3757 ++ u32 param0;
3758 ++};
3759 ++
3760 + /*
3761 + * DWC3 Features to be used as Driver Data
3762 + */
3763 +@@ -881,11 +894,31 @@ static inline void dwc3_host_exit(struct dwc3 *dwc)
3764 + #if IS_ENABLED(CONFIG_USB_DWC3_GADGET) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
3765 + int dwc3_gadget_init(struct dwc3 *dwc);
3766 + void dwc3_gadget_exit(struct dwc3 *dwc);
3767 ++int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode);
3768 ++int dwc3_gadget_get_link_state(struct dwc3 *dwc);
3769 ++int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state);
3770 ++int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
3771 ++ unsigned cmd, struct dwc3_gadget_ep_cmd_params *params);
3772 ++int dwc3_send_gadget_generic_command(struct dwc3 *dwc, int cmd, u32 param);
3773 + #else
3774 + static inline int dwc3_gadget_init(struct dwc3 *dwc)
3775 + { return 0; }
3776 + static inline void dwc3_gadget_exit(struct dwc3 *dwc)
3777 + { }
3778 ++static inline int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode)
3779 ++{ return 0; }
3780 ++static inline int dwc3_gadget_get_link_state(struct dwc3 *dwc)
3781 ++{ return 0; }
3782 ++static inline int dwc3_gadget_set_link_state(struct dwc3 *dwc,
3783 ++ enum dwc3_link_state state)
3784 ++{ return 0; }
3785 ++
3786 ++static inline int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
3787 ++ unsigned cmd, struct dwc3_gadget_ep_cmd_params *params)
3788 ++{ return 0; }
3789 ++static inline int dwc3_send_gadget_generic_command(struct dwc3 *dwc,
3790 ++ int cmd, u32 param)
3791 ++{ return 0; }
3792 + #endif
3793 +
3794 + /* power management interface */
3795 +diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
3796 +index febe1aa7b714..a0ee75b68a80 100644
3797 +--- a/drivers/usb/dwc3/gadget.h
3798 ++++ b/drivers/usb/dwc3/gadget.h
3799 +@@ -56,12 +56,6 @@ struct dwc3;
3800 + /* DEPXFERCFG parameter 0 */
3801 + #define DWC3_DEPXFERCFG_NUM_XFER_RES(n) ((n) & 0xffff)
3802 +
3803 +-struct dwc3_gadget_ep_cmd_params {
3804 +- u32 param2;
3805 +- u32 param1;
3806 +- u32 param0;
3807 +-};
3808 +-
3809 + /* -------------------------------------------------------------------------- */
3810 +
3811 + #define to_dwc3_request(r) (container_of(r, struct dwc3_request, request))
3812 +@@ -85,9 +79,6 @@ static inline void dwc3_gadget_move_request_queued(struct dwc3_request *req)
3813 + void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
3814 + int status);
3815 +
3816 +-int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode);
3817 +-int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state);
3818 +-
3819 + void dwc3_ep0_interrupt(struct dwc3 *dwc,
3820 + const struct dwc3_event_depevt *event);
3821 + void dwc3_ep0_out_start(struct dwc3 *dwc);
3822 +@@ -95,9 +86,6 @@ int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value);
3823 + int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
3824 + gfp_t gfp_flags);
3825 + int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value);
3826 +-int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
3827 +- unsigned cmd, struct dwc3_gadget_ep_cmd_params *params);
3828 +-int dwc3_send_gadget_generic_command(struct dwc3 *dwc, int cmd, u32 param);
3829 +
3830 + /**
3831 + * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW
3832 +diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
3833 +index 52771d4c44bc..167843de2d8a 100644
3834 +--- a/drivers/usb/gadget/atmel_usba_udc.c
3835 ++++ b/drivers/usb/gadget/atmel_usba_udc.c
3836 +@@ -1827,12 +1827,12 @@ static int atmel_usba_stop(struct usb_gadget *gadget,
3837 + toggle_bias(0);
3838 + usba_writel(udc, CTRL, USBA_DISABLE_MASK);
3839 +
3840 +- udc->driver = NULL;
3841 +-
3842 + clk_disable_unprepare(udc->hclk);
3843 + clk_disable_unprepare(udc->pclk);
3844 +
3845 +- DBG(DBG_GADGET, "unregistered driver `%s'\n", driver->driver.name);
3846 ++ DBG(DBG_GADGET, "unregistered driver `%s'\n", udc->driver->driver.name);
3847 ++
3848 ++ udc->driver = NULL;
3849 +
3850 + return 0;
3851 + }
3852 +diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c
3853 +index 0f8aad78b54f..460c266b8e24 100644
3854 +--- a/drivers/usb/gadget/tcm_usb_gadget.c
3855 ++++ b/drivers/usb/gadget/tcm_usb_gadget.c
3856 +@@ -1613,7 +1613,7 @@ static struct se_wwn *usbg_make_tport(
3857 + return ERR_PTR(-ENOMEM);
3858 + }
3859 + tport->tport_wwpn = wwpn;
3860 +- snprintf(tport->tport_name, sizeof(tport->tport_name), wnn_name);
3861 ++ snprintf(tport->tport_name, sizeof(tport->tport_name), "%s", wnn_name);
3862 + return &tport->tport_wwn;
3863 + }
3864 +
3865 +diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
3866 +index 9f170c53e3d9..134f354ede62 100644
3867 +--- a/drivers/usb/gadget/zero.c
3868 ++++ b/drivers/usb/gadget/zero.c
3869 +@@ -300,7 +300,7 @@ static int __init zero_bind(struct usb_composite_dev *cdev)
3870 + ss_opts->isoc_interval = gzero_options.isoc_interval;
3871 + ss_opts->isoc_maxpacket = gzero_options.isoc_maxpacket;
3872 + ss_opts->isoc_mult = gzero_options.isoc_mult;
3873 +- ss_opts->isoc_maxburst = gzero_options.isoc_maxpacket;
3874 ++ ss_opts->isoc_maxburst = gzero_options.isoc_maxburst;
3875 + ss_opts->bulk_buflen = gzero_options.bulk_buflen;
3876 +
3877 + func_ss = usb_get_function(func_inst_ss);
3878 +diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
3879 +index af28b748e87a..633dbea28f30 100644
3880 +--- a/drivers/usb/host/ehci-tegra.c
3881 ++++ b/drivers/usb/host/ehci-tegra.c
3882 +@@ -513,8 +513,31 @@ static struct platform_driver tegra_ehci_driver = {
3883 + }
3884 + };
3885 +
3886 ++static int tegra_ehci_reset(struct usb_hcd *hcd)
3887 ++{
3888 ++ struct ehci_hcd *ehci = hcd_to_ehci(hcd);
3889 ++ int retval;
3890 ++ int txfifothresh;
3891 ++
3892 ++ retval = ehci_setup(hcd);
3893 ++ if (retval)
3894 ++ return retval;
3895 ++
3896 ++ /*
3897 ++ * We should really pull this value out of tegra_ehci_soc_config, but
3898 ++ * to avoid needing access to it, make use of the fact that Tegra20 is
3899 ++ * the only one so far that needs a value of 10, and Tegra20 is the
3900 ++ * only one which doesn't set has_hostpc.
3901 ++ */
3902 ++ txfifothresh = ehci->has_hostpc ? 0x10 : 10;
3903 ++ ehci_writel(ehci, txfifothresh << 16, &ehci->regs->txfill_tuning);
3904 ++
3905 ++ return 0;
3906 ++}
3907 ++
3908 + static const struct ehci_driver_overrides tegra_overrides __initconst = {
3909 + .extra_priv_size = sizeof(struct tegra_ehci_hcd),
3910 ++ .reset = tegra_ehci_reset,
3911 + };
3912 +
3913 + static int __init ehci_tegra_init(void)
3914 +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
3915 +index 04f986d9234f..08a5f92d6c54 100644
3916 +--- a/drivers/usb/host/xhci-pci.c
3917 ++++ b/drivers/usb/host/xhci-pci.c
3918 +@@ -134,6 +134,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
3919 + */
3920 + if (pdev->subsystem_vendor == PCI_VENDOR_ID_HP)
3921 + xhci->quirks |= XHCI_SPURIOUS_WAKEUP;
3922 ++
3923 ++ xhci->quirks |= XHCI_SPURIOUS_REBOOT;
3924 + }
3925 + if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
3926 + pdev->device == PCI_DEVICE_ID_ASROCK_P67) {
3927 +@@ -143,9 +145,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
3928 + xhci->quirks |= XHCI_TRUST_TX_LENGTH;
3929 + }
3930 + if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
3931 +- pdev->device == 0x0015 &&
3932 +- pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG &&
3933 +- pdev->subsystem_device == 0xc0cd)
3934 ++ pdev->device == 0x0015)
3935 + xhci->quirks |= XHCI_RESET_ON_RESUME;
3936 + if (pdev->vendor == PCI_VENDOR_ID_VIA)
3937 + xhci->quirks |= XHCI_RESET_ON_RESUME;
3938 +@@ -190,6 +190,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
3939 + struct usb_hcd *hcd;
3940 +
3941 + driver = (struct hc_driver *)id->driver_data;
3942 ++
3943 ++ /* Prevent runtime suspending between USB-2 and USB-3 initialization */
3944 ++ pm_runtime_get_noresume(&dev->dev);
3945 ++
3946 + /* Register the USB 2.0 roothub.
3947 + * FIXME: USB core must know to register the USB 2.0 roothub first.
3948 + * This is sort of silly, because we could just set the HCD driver flags
3949 +@@ -199,7 +203,7 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
3950 + retval = usb_hcd_pci_probe(dev, id);
3951 +
3952 + if (retval)
3953 +- return retval;
3954 ++ goto put_runtime_pm;
3955 +
3956 + /* USB 2.0 roothub is stored in the PCI device now. */
3957 + hcd = dev_get_drvdata(&dev->dev);
3958 +@@ -228,12 +232,17 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
3959 + if (xhci->quirks & XHCI_LPM_SUPPORT)
3960 + hcd_to_bus(xhci->shared_hcd)->root_hub->lpm_capable = 1;
3961 +
3962 ++ /* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
3963 ++ pm_runtime_put_noidle(&dev->dev);
3964 ++
3965 + return 0;
3966 +
3967 + put_usb3_hcd:
3968 + usb_put_hcd(xhci->shared_hcd);
3969 + dealloc_usb2_hcd:
3970 + usb_hcd_pci_remove(dev);
3971 ++put_runtime_pm:
3972 ++ pm_runtime_put_noidle(&dev->dev);
3973 + return retval;
3974 + }
3975 +
3976 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
3977 +index 0ed64eb68e48..dff9b5ead3b3 100644
3978 +--- a/drivers/usb/host/xhci-ring.c
3979 ++++ b/drivers/usb/host/xhci-ring.c
3980 +@@ -550,6 +550,7 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
3981 + struct xhci_generic_trb *trb;
3982 + struct xhci_ep_ctx *ep_ctx;
3983 + dma_addr_t addr;
3984 ++ u64 hw_dequeue;
3985 +
3986 + ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id,
3987 + ep_index, stream_id);
3988 +@@ -559,56 +560,57 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
3989 + stream_id);
3990 + return;
3991 + }
3992 +- state->new_cycle_state = 0;
3993 +- xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
3994 +- "Finding segment containing stopped TRB.");
3995 +- state->new_deq_seg = find_trb_seg(cur_td->start_seg,
3996 +- dev->eps[ep_index].stopped_trb,
3997 +- &state->new_cycle_state);
3998 +- if (!state->new_deq_seg) {
3999 +- WARN_ON(1);
4000 +- return;
4001 +- }
4002 +
4003 + /* Dig out the cycle state saved by the xHC during the stop ep cmd */
4004 + xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
4005 + "Finding endpoint context");
4006 + ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index);
4007 +- state->new_cycle_state = 0x1 & le64_to_cpu(ep_ctx->deq);
4008 ++ hw_dequeue = le64_to_cpu(ep_ctx->deq);
4009 ++
4010 ++ /* Find virtual address and segment of hardware dequeue pointer */
4011 ++ state->new_deq_seg = ep_ring->deq_seg;
4012 ++ state->new_deq_ptr = ep_ring->dequeue;
4013 ++ while (xhci_trb_virt_to_dma(state->new_deq_seg, state->new_deq_ptr)
4014 ++ != (dma_addr_t)(hw_dequeue & ~0xf)) {
4015 ++ next_trb(xhci, ep_ring, &state->new_deq_seg,
4016 ++ &state->new_deq_ptr);
4017 ++ if (state->new_deq_ptr == ep_ring->dequeue) {
4018 ++ WARN_ON(1);
4019 ++ return;
4020 ++ }
4021 ++ }
4022 ++ /*
4023 ++ * Find cycle state for last_trb, starting at old cycle state of
4024 ++ * hw_dequeue. If there is only one segment ring, find_trb_seg() will
4025 ++ * return immediately and cannot toggle the cycle state if this search
4026 ++ * wraps around, so add one more toggle manually in that case.
4027 ++ */
4028 ++ state->new_cycle_state = hw_dequeue & 0x1;
4029 ++ if (ep_ring->first_seg == ep_ring->first_seg->next &&
4030 ++ cur_td->last_trb < state->new_deq_ptr)
4031 ++ state->new_cycle_state ^= 0x1;
4032 +
4033 + state->new_deq_ptr = cur_td->last_trb;
4034 + xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
4035 + "Finding segment containing last TRB in TD.");
4036 + state->new_deq_seg = find_trb_seg(state->new_deq_seg,
4037 +- state->new_deq_ptr,
4038 +- &state->new_cycle_state);
4039 ++ state->new_deq_ptr, &state->new_cycle_state);
4040 + if (!state->new_deq_seg) {
4041 + WARN_ON(1);
4042 + return;
4043 + }
4044 +
4045 ++ /* Increment to find next TRB after last_trb. Cycle if appropriate. */
4046 + trb = &state->new_deq_ptr->generic;
4047 + if (TRB_TYPE_LINK_LE32(trb->field[3]) &&
4048 + (trb->field[3] & cpu_to_le32(LINK_TOGGLE)))
4049 + state->new_cycle_state ^= 0x1;
4050 + next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr);
4051 +
4052 +- /*
4053 +- * If there is only one segment in a ring, find_trb_seg()'s while loop
4054 +- * will not run, and it will return before it has a chance to see if it
4055 +- * needs to toggle the cycle bit. It can't tell if the stalled transfer
4056 +- * ended just before the link TRB on a one-segment ring, or if the TD
4057 +- * wrapped around the top of the ring, because it doesn't have the TD in
4058 +- * question. Look for the one-segment case where stalled TRB's address
4059 +- * is greater than the new dequeue pointer address.
4060 +- */
4061 +- if (ep_ring->first_seg == ep_ring->first_seg->next &&
4062 +- state->new_deq_ptr < dev->eps[ep_index].stopped_trb)
4063 +- state->new_cycle_state ^= 0x1;
4064 ++ /* Don't update the ring cycle state for the producer (us). */
4065 + xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
4066 + "Cycle state = 0x%x", state->new_cycle_state);
4067 +
4068 +- /* Don't update the ring cycle state for the producer (us). */
4069 + xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
4070 + "New dequeue segment = %p (virtual)",
4071 + state->new_deq_seg);
4072 +@@ -791,7 +793,6 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id,
4073 + if (list_empty(&ep->cancelled_td_list)) {
4074 + xhci_stop_watchdog_timer_in_irq(xhci, ep);
4075 + ep->stopped_td = NULL;
4076 +- ep->stopped_trb = NULL;
4077 + ring_doorbell_for_active_rings(xhci, slot_id, ep_index);
4078 + return;
4079 + }
4080 +@@ -859,11 +860,9 @@ remove_finished_td:
4081 + ring_doorbell_for_active_rings(xhci, slot_id, ep_index);
4082 + }
4083 +
4084 +- /* Clear stopped_td and stopped_trb if endpoint is not halted */
4085 +- if (!(ep->ep_state & EP_HALTED)) {
4086 ++ /* Clear stopped_td if endpoint is not halted */
4087 ++ if (!(ep->ep_state & EP_HALTED))
4088 + ep->stopped_td = NULL;
4089 +- ep->stopped_trb = NULL;
4090 +- }
4091 +
4092 + /*
4093 + * Drop the lock and complete the URBs in the cancelled TD list.
4094 +@@ -1908,14 +1907,12 @@ static void xhci_cleanup_halted_endpoint(struct xhci_hcd *xhci,
4095 + struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index];
4096 + ep->ep_state |= EP_HALTED;
4097 + ep->stopped_td = td;
4098 +- ep->stopped_trb = event_trb;
4099 + ep->stopped_stream = stream_id;
4100 +
4101 + xhci_queue_reset_ep(xhci, slot_id, ep_index);
4102 + xhci_cleanup_stalled_ring(xhci, td->urb->dev, ep_index);
4103 +
4104 + ep->stopped_td = NULL;
4105 +- ep->stopped_trb = NULL;
4106 + ep->stopped_stream = 0;
4107 +
4108 + xhci_ring_cmd_db(xhci);
4109 +@@ -1997,7 +1994,6 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td,
4110 + * the ring dequeue pointer or take this TD off any lists yet.
4111 + */
4112 + ep->stopped_td = td;
4113 +- ep->stopped_trb = event_trb;
4114 + return 0;
4115 + } else {
4116 + if (trb_comp_code == COMP_STALL) {
4117 +@@ -2009,7 +2005,6 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td,
4118 + * USB class driver clear the stall later.
4119 + */
4120 + ep->stopped_td = td;
4121 +- ep->stopped_trb = event_trb;
4122 + ep->stopped_stream = ep_ring->stream_id;
4123 + } else if (xhci_requires_manual_halt_cleanup(xhci,
4124 + ep_ctx, trb_comp_code)) {
4125 +@@ -2626,7 +2621,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
4126 + * successful event after a short transfer.
4127 + * Ignore it.
4128 + */
4129 +- if ((xhci->quirks & XHCI_SPURIOUS_SUCCESS) &&
4130 ++ if ((xhci->quirks & XHCI_SPURIOUS_SUCCESS) &&
4131 + ep_ring->last_td_was_short) {
4132 + ep_ring->last_td_was_short = false;
4133 + ret = 0;
4134 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
4135 +index 924a6ccdb622..cca289667cf6 100644
4136 +--- a/drivers/usb/host/xhci.c
4137 ++++ b/drivers/usb/host/xhci.c
4138 +@@ -404,16 +404,16 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd)
4139 +
4140 + #else
4141 +
4142 +-static int xhci_try_enable_msi(struct usb_hcd *hcd)
4143 ++static inline int xhci_try_enable_msi(struct usb_hcd *hcd)
4144 + {
4145 + return 0;
4146 + }
4147 +
4148 +-static void xhci_cleanup_msix(struct xhci_hcd *xhci)
4149 ++static inline void xhci_cleanup_msix(struct xhci_hcd *xhci)
4150 + {
4151 + }
4152 +
4153 +-static void xhci_msix_sync_irqs(struct xhci_hcd *xhci)
4154 ++static inline void xhci_msix_sync_irqs(struct xhci_hcd *xhci)
4155 + {
4156 + }
4157 +
4158 +@@ -2933,7 +2933,6 @@ void xhci_endpoint_reset(struct usb_hcd *hcd,
4159 + xhci_ring_cmd_db(xhci);
4160 + }
4161 + virt_ep->stopped_td = NULL;
4162 +- virt_ep->stopped_trb = NULL;
4163 + virt_ep->stopped_stream = 0;
4164 + spin_unlock_irqrestore(&xhci->lock, flags);
4165 +
4166 +diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
4167 +index 58ed9d088e63..8faef64371c6 100644
4168 +--- a/drivers/usb/host/xhci.h
4169 ++++ b/drivers/usb/host/xhci.h
4170 +@@ -864,8 +864,6 @@ struct xhci_virt_ep {
4171 + #define EP_GETTING_NO_STREAMS (1 << 5)
4172 + /* ---- Related to URB cancellation ---- */
4173 + struct list_head cancelled_td_list;
4174 +- /* The TRB that was last reported in a stopped endpoint ring */
4175 +- union xhci_trb *stopped_trb;
4176 + struct xhci_td *stopped_td;
4177 + unsigned int stopped_stream;
4178 + /* Watchdog timer for stop endpoint command to cancel URBs */
4179 +diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
4180 +index 239ad0b1ceb6..07576907e2c6 100644
4181 +--- a/drivers/usb/musb/musb_core.c
4182 ++++ b/drivers/usb/musb/musb_core.c
4183 +@@ -438,7 +438,6 @@ void musb_hnp_stop(struct musb *musb)
4184 + static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
4185 + u8 devctl)
4186 + {
4187 +- struct usb_otg *otg = musb->xceiv->otg;
4188 + irqreturn_t handled = IRQ_NONE;
4189 +
4190 + dev_dbg(musb->controller, "<== DevCtl=%02x, int_usb=0x%x\n", devctl,
4191 +@@ -656,7 +655,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
4192 + break;
4193 + case OTG_STATE_B_PERIPHERAL:
4194 + musb_g_suspend(musb);
4195 +- musb->is_active = otg->gadget->b_hnp_enable;
4196 ++ musb->is_active = musb->g.b_hnp_enable;
4197 + if (musb->is_active) {
4198 + musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
4199 + dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n");
4200 +@@ -672,7 +671,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
4201 + break;
4202 + case OTG_STATE_A_HOST:
4203 + musb->xceiv->state = OTG_STATE_A_SUSPEND;
4204 +- musb->is_active = otg->host->b_hnp_enable;
4205 ++ musb->is_active = musb->hcd->self.b_hnp_enable;
4206 + break;
4207 + case OTG_STATE_B_HOST:
4208 + /* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */
4209 +diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
4210 +index 8aa59a2c5eb2..8e90d327e52b 100644
4211 +--- a/drivers/usb/musb/omap2430.c
4212 ++++ b/drivers/usb/musb/omap2430.c
4213 +@@ -416,6 +416,7 @@ static int omap2430_musb_init(struct musb *musb)
4214 + omap_musb_set_mailbox(glue);
4215 +
4216 + phy_init(musb->phy);
4217 ++ phy_power_on(musb->phy);
4218 +
4219 + pm_runtime_put_noidle(musb->controller);
4220 + return 0;
4221 +@@ -478,6 +479,7 @@ static int omap2430_musb_exit(struct musb *musb)
4222 + del_timer_sync(&musb_idle_timer);
4223 +
4224 + omap2430_low_level_exit(musb);
4225 ++ phy_power_off(musb->phy);
4226 + phy_exit(musb->phy);
4227 +
4228 + return 0;
4229 +diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c
4230 +index d75196ad5f2f..35b6083b7999 100644
4231 +--- a/drivers/usb/phy/phy-am335x-control.c
4232 ++++ b/drivers/usb/phy/phy-am335x-control.c
4233 +@@ -3,6 +3,7 @@
4234 + #include <linux/err.h>
4235 + #include <linux/of.h>
4236 + #include <linux/io.h>
4237 ++#include <linux/delay.h>
4238 + #include "am35x-phy-control.h"
4239 +
4240 + struct am335x_control_usb {
4241 +@@ -86,6 +87,14 @@ static void am335x_phy_power(struct phy_control *phy_ctrl, u32 id, bool on)
4242 + }
4243 +
4244 + writel(val, usb_ctrl->phy_reg + reg);
4245 ++
4246 ++ /*
4247 ++ * Give the PHY ~1ms to complete the power up operation.
4248 ++ * Tests have shown unstable behaviour if other USB PHY related
4249 ++ * registers are written too shortly after such a transition.
4250 ++ */
4251 ++ if (on)
4252 ++ mdelay(1);
4253 + }
4254 +
4255 + static const struct phy_control ctrl_am335x = {
4256 +diff --git a/drivers/usb/phy/phy-ulpi.c b/drivers/usb/phy/phy-ulpi.c
4257 +index 217339dd7a90..17ea3f271bd8 100644
4258 +--- a/drivers/usb/phy/phy-ulpi.c
4259 ++++ b/drivers/usb/phy/phy-ulpi.c
4260 +@@ -47,6 +47,8 @@ struct ulpi_info {
4261 + static struct ulpi_info ulpi_ids[] = {
4262 + ULPI_INFO(ULPI_ID(0x04cc, 0x1504), "NXP ISP1504"),
4263 + ULPI_INFO(ULPI_ID(0x0424, 0x0006), "SMSC USB331x"),
4264 ++ ULPI_INFO(ULPI_ID(0x0424, 0x0007), "SMSC USB3320"),
4265 ++ ULPI_INFO(ULPI_ID(0x0451, 0x1507), "TI TUSB1210"),
4266 + };
4267 +
4268 + static int ulpi_set_otg_flags(struct usb_phy *phy)
4269 +diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
4270 +index 2e22fc22c382..b3d5a35c0d4b 100644
4271 +--- a/drivers/usb/serial/pl2303.c
4272 ++++ b/drivers/usb/serial/pl2303.c
4273 +@@ -83,6 +83,9 @@ static const struct usb_device_id id_table[] = {
4274 + { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) },
4275 + { USB_DEVICE(SUPERIAL_VENDOR_ID, SUPERIAL_PRODUCT_ID) },
4276 + { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) },
4277 ++ { USB_DEVICE(HP_VENDOR_ID, HP_LD960_PRODUCT_ID) },
4278 ++ { USB_DEVICE(HP_VENDOR_ID, HP_LCM220_PRODUCT_ID) },
4279 ++ { USB_DEVICE(HP_VENDOR_ID, HP_LCM960_PRODUCT_ID) },
4280 + { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) },
4281 + { USB_DEVICE(ZEAGLE_VENDOR_ID, ZEAGLE_N2ITION3_PRODUCT_ID) },
4282 + { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) },
4283 +diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
4284 +index c38b8c00c06f..42bc082896ac 100644
4285 +--- a/drivers/usb/serial/pl2303.h
4286 ++++ b/drivers/usb/serial/pl2303.h
4287 +@@ -121,8 +121,11 @@
4288 + #define SUPERIAL_VENDOR_ID 0x5372
4289 + #define SUPERIAL_PRODUCT_ID 0x2303
4290 +
4291 +-/* Hewlett-Packard LD220-HP POS Pole Display */
4292 ++/* Hewlett-Packard POS Pole Displays */
4293 + #define HP_VENDOR_ID 0x03f0
4294 ++#define HP_LD960_PRODUCT_ID 0x0b39
4295 ++#define HP_LCM220_PRODUCT_ID 0x3139
4296 ++#define HP_LCM960_PRODUCT_ID 0x3239
4297 + #define HP_LD220_PRODUCT_ID 0x3524
4298 +
4299 + /* Cressi Edy (diving computer) PC interface */
4300 +diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
4301 +index cd961622f9c1..b74e5f5ddac8 100644
4302 +--- a/drivers/video/atmel_lcdfb.c
4303 ++++ b/drivers/video/atmel_lcdfb.c
4304 +@@ -1298,6 +1298,12 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
4305 + goto unregister_irqs;
4306 + }
4307 +
4308 ++ ret = atmel_lcdfb_set_par(info);
4309 ++ if (ret < 0) {
4310 ++ dev_err(dev, "set par failed: %d\n", ret);
4311 ++ goto unregister_irqs;
4312 ++ }
4313 ++
4314 + dev_set_drvdata(dev, info);
4315 +
4316 + /*
4317 +diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
4318 +index 40788c925d1c..73705aff53cb 100644
4319 +--- a/drivers/w1/w1_netlink.c
4320 ++++ b/drivers/w1/w1_netlink.c
4321 +@@ -54,28 +54,29 @@ static void w1_send_slave(struct w1_master *dev, u64 rn)
4322 + struct w1_netlink_msg *hdr = (struct w1_netlink_msg *)(msg + 1);
4323 + struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)(hdr + 1);
4324 + int avail;
4325 ++ u64 *data;
4326 +
4327 + /* update kernel slave list */
4328 + w1_slave_found(dev, rn);
4329 +
4330 + avail = dev->priv_size - cmd->len;
4331 +
4332 +- if (avail > 8) {
4333 +- u64 *data = (void *)(cmd + 1) + cmd->len;
4334 ++ if (avail < 8) {
4335 ++ msg->ack++;
4336 ++ cn_netlink_send(msg, 0, GFP_KERNEL);
4337 +
4338 +- *data = rn;
4339 +- cmd->len += 8;
4340 +- hdr->len += 8;
4341 +- msg->len += 8;
4342 +- return;
4343 ++ msg->len = sizeof(struct w1_netlink_msg) +
4344 ++ sizeof(struct w1_netlink_cmd);
4345 ++ hdr->len = sizeof(struct w1_netlink_cmd);
4346 ++ cmd->len = 0;
4347 + }
4348 +
4349 +- msg->ack++;
4350 +- cn_netlink_send(msg, 0, GFP_KERNEL);
4351 ++ data = (void *)(cmd + 1) + cmd->len;
4352 +
4353 +- msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd);
4354 +- hdr->len = sizeof(struct w1_netlink_cmd);
4355 +- cmd->len = 0;
4356 ++ *data = rn;
4357 ++ cmd->len += 8;
4358 ++ hdr->len += 8;
4359 ++ msg->len += 8;
4360 + }
4361 +
4362 + static int w1_process_search_command(struct w1_master *dev, struct cn_msg *msg,
4363 +diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
4364 +index d3a534fdc5ff..3a603a8d9f96 100644
4365 +--- a/fs/ext4/ext4.h
4366 ++++ b/fs/ext4/ext4.h
4367 +@@ -2462,23 +2462,6 @@ static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
4368 + up_write(&EXT4_I(inode)->i_data_sem);
4369 + }
4370 +
4371 +-/*
4372 +- * Update i_disksize after writeback has been started. Races with truncate
4373 +- * are avoided by checking i_size under i_data_sem.
4374 +- */
4375 +-static inline void ext4_wb_update_i_disksize(struct inode *inode, loff_t newsize)
4376 +-{
4377 +- loff_t i_size;
4378 +-
4379 +- down_write(&EXT4_I(inode)->i_data_sem);
4380 +- i_size = i_size_read(inode);
4381 +- if (newsize > i_size)
4382 +- newsize = i_size;
4383 +- if (newsize > EXT4_I(inode)->i_disksize)
4384 +- EXT4_I(inode)->i_disksize = newsize;
4385 +- up_write(&EXT4_I(inode)->i_data_sem);
4386 +-}
4387 +-
4388 + struct ext4_group_info {
4389 + unsigned long bb_state;
4390 + struct rb_root bb_free_root;
4391 +diff --git a/fs/ext4/file.c b/fs/ext4/file.c
4392 +index 1a5073959f32..2a8b2e15dcc4 100644
4393 +--- a/fs/ext4/file.c
4394 ++++ b/fs/ext4/file.c
4395 +@@ -82,7 +82,7 @@ ext4_unaligned_aio(struct inode *inode, const struct iovec *iov,
4396 + size_t count = iov_length(iov, nr_segs);
4397 + loff_t final_size = pos + count;
4398 +
4399 +- if (pos >= inode->i_size)
4400 ++ if (pos >= i_size_read(inode))
4401 + return 0;
4402 +
4403 + if ((pos & blockmask) || (final_size & blockmask))
4404 +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
4405 +index 24bfd7ff3049..4e8903d0432e 100644
4406 +--- a/fs/ext4/inode.c
4407 ++++ b/fs/ext4/inode.c
4408 +@@ -515,6 +515,10 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
4409 + "logical block %lu\n", inode->i_ino, flags, map->m_len,
4410 + (unsigned long) map->m_lblk);
4411 +
4412 ++ /* We can handle the block number less than EXT_MAX_BLOCKS */
4413 ++ if (unlikely(map->m_lblk >= EXT_MAX_BLOCKS))
4414 ++ return -EIO;
4415 ++
4416 + /* Lookup extent status tree firstly */
4417 + if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) {
4418 + ext4_es_lru_add(inode);
4419 +@@ -2232,13 +2236,23 @@ static int mpage_map_and_submit_extent(handle_t *handle,
4420 + return err;
4421 + } while (map->m_len);
4422 +
4423 +- /* Update on-disk size after IO is submitted */
4424 ++ /*
4425 ++ * Update on-disk size after IO is submitted. Races with
4426 ++ * truncate are avoided by checking i_size under i_data_sem.
4427 ++ */
4428 + disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT;
4429 + if (disksize > EXT4_I(inode)->i_disksize) {
4430 + int err2;
4431 +-
4432 +- ext4_wb_update_i_disksize(inode, disksize);
4433 ++ loff_t i_size;
4434 ++
4435 ++ down_write(&EXT4_I(inode)->i_data_sem);
4436 ++ i_size = i_size_read(inode);
4437 ++ if (disksize > i_size)
4438 ++ disksize = i_size;
4439 ++ if (disksize > EXT4_I(inode)->i_disksize)
4440 ++ EXT4_I(inode)->i_disksize = disksize;
4441 + err2 = ext4_mark_inode_dirty(handle, inode);
4442 ++ up_write(&EXT4_I(inode)->i_data_sem);
4443 + if (err2)
4444 + ext4_error(inode->i_sb,
4445 + "Failed to mark inode %lu dirty",
4446 +diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
4447 +index ab95508e3d40..c18d95b50540 100644
4448 +--- a/fs/ext4/page-io.c
4449 ++++ b/fs/ext4/page-io.c
4450 +@@ -308,13 +308,14 @@ static void ext4_end_bio(struct bio *bio, int error)
4451 + if (error) {
4452 + struct inode *inode = io_end->inode;
4453 +
4454 +- ext4_warning(inode->i_sb, "I/O error writing to inode %lu "
4455 ++ ext4_warning(inode->i_sb, "I/O error %d writing to inode %lu "
4456 + "(offset %llu size %ld starting block %llu)",
4457 +- inode->i_ino,
4458 ++ error, inode->i_ino,
4459 + (unsigned long long) io_end->offset,
4460 + (long) io_end->size,
4461 + (unsigned long long)
4462 + bi_sector >> (inode->i_blkbits - 9));
4463 ++ mapping_set_error(inode->i_mapping, error);
4464 + }
4465 +
4466 + if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
4467 +diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
4468 +index e175e94116ac..55e611c1513c 100644
4469 +--- a/fs/ext4/xattr.c
4470 ++++ b/fs/ext4/xattr.c
4471 +@@ -517,8 +517,8 @@ static void ext4_xattr_update_super_block(handle_t *handle,
4472 + }
4473 +
4474 + /*
4475 +- * Release the xattr block BH: If the reference count is > 1, decrement
4476 +- * it; otherwise free the block.
4477 ++ * Release the xattr block BH: If the reference count is > 1, decrement it;
4478 ++ * otherwise free the block.
4479 + */
4480 + static void
4481 + ext4_xattr_release_block(handle_t *handle, struct inode *inode,
4482 +@@ -538,16 +538,31 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
4483 + if (ce)
4484 + mb_cache_entry_free(ce);
4485 + get_bh(bh);
4486 ++ unlock_buffer(bh);
4487 + ext4_free_blocks(handle, inode, bh, 0, 1,
4488 + EXT4_FREE_BLOCKS_METADATA |
4489 + EXT4_FREE_BLOCKS_FORGET);
4490 +- unlock_buffer(bh);
4491 + } else {
4492 + le32_add_cpu(&BHDR(bh)->h_refcount, -1);
4493 + if (ce)
4494 + mb_cache_entry_release(ce);
4495 ++ /*
4496 ++ * Beware of this ugliness: Releasing of xattr block references
4497 ++ * from different inodes can race and so we have to protect
4498 ++ * from a race where someone else frees the block (and releases
4499 ++ * its journal_head) before we are done dirtying the buffer. In
4500 ++ * nojournal mode this race is harmless and we actually cannot
4501 ++ * call ext4_handle_dirty_xattr_block() with locked buffer as
4502 ++ * that function can call sync_dirty_buffer() so for that case
4503 ++ * we handle the dirtying after unlocking the buffer.
4504 ++ */
4505 ++ if (ext4_handle_valid(handle))
4506 ++ error = ext4_handle_dirty_xattr_block(handle, inode,
4507 ++ bh);
4508 + unlock_buffer(bh);
4509 +- error = ext4_handle_dirty_xattr_block(handle, inode, bh);
4510 ++ if (!ext4_handle_valid(handle))
4511 ++ error = ext4_handle_dirty_xattr_block(handle, inode,
4512 ++ bh);
4513 + if (IS_SYNC(inode))
4514 + ext4_handle_sync(handle);
4515 + dquot_free_block(inode, EXT4_C2B(EXT4_SB(inode->i_sb), 1));
4516 +diff --git a/fs/namespace.c b/fs/namespace.c
4517 +index 2ffc5a2905d4..65233a5f390a 100644
4518 +--- a/fs/namespace.c
4519 ++++ b/fs/namespace.c
4520 +@@ -885,7 +885,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
4521 + goto out_free;
4522 + }
4523 +
4524 +- mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~MNT_WRITE_HOLD;
4525 ++ mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~(MNT_WRITE_HOLD|MNT_MARKED);
4526 + /* Don't allow unprivileged users to change mount flags */
4527 + if ((flag & CL_UNPRIVILEGED) && (mnt->mnt.mnt_flags & MNT_READONLY))
4528 + mnt->mnt.mnt_flags |= MNT_LOCK_READONLY;
4529 +@@ -1661,9 +1661,9 @@ static int attach_recursive_mnt(struct mount *source_mnt,
4530 + if (err)
4531 + goto out;
4532 + err = propagate_mnt(dest_mnt, dest_mp, source_mnt, &tree_list);
4533 ++ lock_mount_hash();
4534 + if (err)
4535 + goto out_cleanup_ids;
4536 +- lock_mount_hash();
4537 + for (p = source_mnt; p; p = next_mnt(p, source_mnt))
4538 + set_mnt_shared(p);
4539 + } else {
4540 +@@ -1690,6 +1690,11 @@ static int attach_recursive_mnt(struct mount *source_mnt,
4541 + return 0;
4542 +
4543 + out_cleanup_ids:
4544 ++ while (!hlist_empty(&tree_list)) {
4545 ++ child = hlist_entry(tree_list.first, struct mount, mnt_hash);
4546 ++ umount_tree(child, 0);
4547 ++ }
4548 ++ unlock_mount_hash();
4549 + cleanup_group_ids(source_mnt, NULL);
4550 + out:
4551 + return err;
4552 +@@ -2044,7 +2049,7 @@ static int do_add_mount(struct mount *newmnt, struct path *path, int mnt_flags)
4553 + struct mount *parent;
4554 + int err;
4555 +
4556 +- mnt_flags &= ~(MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | MNT_DOOMED | MNT_SYNC_UMOUNT);
4557 ++ mnt_flags &= ~MNT_INTERNAL_FLAGS;
4558 +
4559 + mp = lock_mount(path);
4560 + if (IS_ERR(mp))
4561 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
4562 +index 450bfedbe2f4..d5d06e868841 100644
4563 +--- a/fs/nfs/nfs4proc.c
4564 ++++ b/fs/nfs/nfs4proc.c
4565 +@@ -1068,6 +1068,7 @@ static void nfs4_opendata_free(struct kref *kref)
4566 + dput(p->dentry);
4567 + nfs_sb_deactive(sb);
4568 + nfs_fattr_free_names(&p->f_attr);
4569 ++ kfree(p->f_attr.mdsthreshold);
4570 + kfree(p);
4571 + }
4572 +
4573 +@@ -2244,10 +2245,12 @@ static int _nfs4_do_open(struct inode *dir,
4574 + }
4575 + }
4576 +
4577 +- if (ctx_th && server->attr_bitmask[2] & FATTR4_WORD2_MDSTHRESHOLD) {
4578 +- opendata->f_attr.mdsthreshold = pnfs_mdsthreshold_alloc();
4579 +- if (!opendata->f_attr.mdsthreshold)
4580 +- goto err_free_label;
4581 ++ if (server->attr_bitmask[2] & FATTR4_WORD2_MDSTHRESHOLD) {
4582 ++ if (!opendata->f_attr.mdsthreshold) {
4583 ++ opendata->f_attr.mdsthreshold = pnfs_mdsthreshold_alloc();
4584 ++ if (!opendata->f_attr.mdsthreshold)
4585 ++ goto err_free_label;
4586 ++ }
4587 + opendata->o_arg.open_bitmap = &nfs4_pnfs_open_bitmap[0];
4588 + }
4589 + if (dentry->d_inode != NULL)
4590 +@@ -2275,11 +2278,10 @@ static int _nfs4_do_open(struct inode *dir,
4591 + if (opendata->file_created)
4592 + *opened |= FILE_CREATED;
4593 +
4594 +- if (pnfs_use_threshold(ctx_th, opendata->f_attr.mdsthreshold, server))
4595 ++ if (pnfs_use_threshold(ctx_th, opendata->f_attr.mdsthreshold, server)) {
4596 + *ctx_th = opendata->f_attr.mdsthreshold;
4597 +- else
4598 +- kfree(opendata->f_attr.mdsthreshold);
4599 +- opendata->f_attr.mdsthreshold = NULL;
4600 ++ opendata->f_attr.mdsthreshold = NULL;
4601 ++ }
4602 +
4603 + nfs4_label_free(olabel);
4604 +
4605 +@@ -2289,7 +2291,6 @@ static int _nfs4_do_open(struct inode *dir,
4606 + err_free_label:
4607 + nfs4_label_free(olabel);
4608 + err_opendata_put:
4609 +- kfree(opendata->f_attr.mdsthreshold);
4610 + nfs4_opendata_put(opendata);
4611 + err_put_state_owner:
4612 + nfs4_put_state_owner(sp);
4613 +diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
4614 +index 7f05cd140de3..3eaa6e30a2dc 100644
4615 +--- a/fs/nfsd/nfs4callback.c
4616 ++++ b/fs/nfsd/nfs4callback.c
4617 +@@ -637,9 +637,11 @@ static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc
4618 +
4619 + static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses)
4620 + {
4621 ++ int maxtime = max_cb_time(clp->net);
4622 + struct rpc_timeout timeparms = {
4623 +- .to_initval = max_cb_time(clp->net),
4624 ++ .to_initval = maxtime,
4625 + .to_retries = 0,
4626 ++ .to_maxval = maxtime,
4627 + };
4628 + struct rpc_create_args args = {
4629 + .net = clp->net,
4630 +diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
4631 +index 82189b208af3..9a914e892bb1 100644
4632 +--- a/fs/nfsd/nfs4proc.c
4633 ++++ b/fs/nfsd/nfs4proc.c
4634 +@@ -1359,6 +1359,12 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
4635 + /* If op is non-idempotent */
4636 + if (opdesc->op_flags & OP_MODIFIES_SOMETHING) {
4637 + plen = opdesc->op_rsize_bop(rqstp, op);
4638 ++ /*
4639 ++ * If there's still another operation, make sure
4640 ++ * we'll have space to at least encode an error:
4641 ++ */
4642 ++ if (resp->opcnt < args->opcnt)
4643 ++ plen += COMPOUND_ERR_SLACK_SPACE;
4644 + op->status = nfsd4_check_resp_size(resp, plen);
4645 + }
4646 +
4647 +@@ -1523,7 +1529,8 @@ static inline u32 nfsd4_setattr_rsize(struct svc_rqst *rqstp, struct nfsd4_op *o
4648 +
4649 + static inline u32 nfsd4_setclientid_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
4650 + {
4651 +- return (op_encode_hdr_size + 2 + 1024) * sizeof(__be32);
4652 ++ return (op_encode_hdr_size + 2 + XDR_QUADLEN(NFS4_VERIFIER_SIZE)) *
4653 ++ sizeof(__be32);
4654 + }
4655 +
4656 + static inline u32 nfsd4_write_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
4657 +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
4658 +index d5d070fbeb35..7415eac36501 100644
4659 +--- a/fs/nfsd/nfs4state.c
4660 ++++ b/fs/nfsd/nfs4state.c
4661 +@@ -5062,7 +5062,6 @@ nfs4_state_destroy_net(struct net *net)
4662 + int i;
4663 + struct nfs4_client *clp = NULL;
4664 + struct nfsd_net *nn = net_generic(net, nfsd_net_id);
4665 +- struct rb_node *node, *tmp;
4666 +
4667 + for (i = 0; i < CLIENT_HASH_SIZE; i++) {
4668 + while (!list_empty(&nn->conf_id_hashtbl[i])) {
4669 +@@ -5071,13 +5070,11 @@ nfs4_state_destroy_net(struct net *net)
4670 + }
4671 + }
4672 +
4673 +- node = rb_first(&nn->unconf_name_tree);
4674 +- while (node != NULL) {
4675 +- tmp = node;
4676 +- node = rb_next(tmp);
4677 +- clp = rb_entry(tmp, struct nfs4_client, cl_namenode);
4678 +- rb_erase(tmp, &nn->unconf_name_tree);
4679 +- destroy_client(clp);
4680 ++ for (i = 0; i < CLIENT_HASH_SIZE; i++) {
4681 ++ while (!list_empty(&nn->unconf_id_hashtbl[i])) {
4682 ++ clp = list_entry(nn->unconf_id_hashtbl[i].next, struct nfs4_client, cl_idhash);
4683 ++ destroy_client(clp);
4684 ++ }
4685 + }
4686 +
4687 + kfree(nn->sessionid_hashtbl);
4688 +diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
4689 +index 63f2395c57ed..16e8fa71eb84 100644
4690 +--- a/fs/nfsd/nfs4xdr.c
4691 ++++ b/fs/nfsd/nfs4xdr.c
4692 +@@ -2483,6 +2483,8 @@ out_acl:
4693 + goto out;
4694 + }
4695 + if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) {
4696 ++ if ((buflen -= 16) < 0)
4697 ++ goto out_resource;
4698 + WRITE32(3);
4699 + WRITE32(NFSD_SUPPATTR_EXCLCREAT_WORD0);
4700 + WRITE32(NFSD_SUPPATTR_EXCLCREAT_WORD1);
4701 +@@ -2499,8 +2501,10 @@ out:
4702 + security_release_secctx(context, contextlen);
4703 + #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */
4704 + kfree(acl);
4705 +- if (tempfh)
4706 ++ if (tempfh) {
4707 + fh_put(tempfh);
4708 ++ kfree(tempfh);
4709 ++ }
4710 + return status;
4711 + out_nfserr:
4712 + status = nfserrno(err);
4713 +@@ -3471,6 +3475,9 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, __be32 nfserr,
4714 + struct nfsd4_test_stateid_id *stateid, *next;
4715 + __be32 *p;
4716 +
4717 ++ if (nfserr)
4718 ++ return nfserr;
4719 ++
4720 + RESERVE_SPACE(4 + (4 * test_stateid->ts_num_ids));
4721 + *p++ = htonl(test_stateid->ts_num_ids);
4722 +
4723 +diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
4724 +index 7f555179bf81..f34d9de802ab 100644
4725 +--- a/fs/nfsd/nfsctl.c
4726 ++++ b/fs/nfsd/nfsctl.c
4727 +@@ -699,6 +699,11 @@ static ssize_t __write_ports_addfd(char *buf, struct net *net)
4728 + if (err != 0 || fd < 0)
4729 + return -EINVAL;
4730 +
4731 ++ if (svc_alien_sock(net, fd)) {
4732 ++ printk(KERN_ERR "%s: socket net is different to NFSd's one\n", __func__);
4733 ++ return -EINVAL;
4734 ++ }
4735 ++
4736 + err = nfsd_create_serv(net);
4737 + if (err != 0)
4738 + return err;
4739 +diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
4740 +index 30f34ab02137..479eb681c27c 100644
4741 +--- a/fs/nfsd/nfsd.h
4742 ++++ b/fs/nfsd/nfsd.h
4743 +@@ -282,7 +282,7 @@ void nfsd_lockd_shutdown(void);
4744 + * reason.
4745 + */
4746 + #define COMPOUND_SLACK_SPACE 140 /* OP_GETFH */
4747 +-#define COMPOUND_ERR_SLACK_SPACE 12 /* OP_SETATTR */
4748 ++#define COMPOUND_ERR_SLACK_SPACE 16 /* OP_SETATTR */
4749 +
4750 + #define NFSD_LAUNDROMAT_MINTIMEOUT 1 /* seconds */
4751 +
4752 +diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
4753 +index b17d93214d01..9c769a47ac5a 100644
4754 +--- a/fs/nfsd/nfsxdr.c
4755 ++++ b/fs/nfsd/nfsxdr.c
4756 +@@ -152,7 +152,7 @@ encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
4757 + type = (stat->mode & S_IFMT);
4758 +
4759 + *p++ = htonl(nfs_ftypes[type >> 12]);
4760 +- *p++ = htonl((u32) (stat->mode & S_IALLUGO));
4761 ++ *p++ = htonl((u32) stat->mode);
4762 + *p++ = htonl((u32) stat->nlink);
4763 + *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
4764 + *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
4765 +diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
4766 +index 6d7be3f80356..eea5ad188984 100644
4767 +--- a/fs/nfsd/vfs.c
4768 ++++ b/fs/nfsd/vfs.c
4769 +@@ -404,6 +404,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
4770 + umode_t ftype = 0;
4771 + __be32 err;
4772 + int host_err;
4773 ++ bool get_write_count;
4774 + int size_change = 0;
4775 +
4776 + if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
4777 +@@ -411,10 +412,18 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
4778 + if (iap->ia_valid & ATTR_SIZE)
4779 + ftype = S_IFREG;
4780 +
4781 ++ /* Callers that do fh_verify should do the fh_want_write: */
4782 ++ get_write_count = !fhp->fh_dentry;
4783 ++
4784 + /* Get inode */
4785 + err = fh_verify(rqstp, fhp, ftype, accmode);
4786 + if (err)
4787 + goto out;
4788 ++ if (get_write_count) {
4789 ++ host_err = fh_want_write(fhp);
4790 ++ if (host_err)
4791 ++ return nfserrno(host_err);
4792 ++ }
4793 +
4794 + dentry = fhp->fh_dentry;
4795 + inode = dentry->d_inode;
4796 +diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
4797 +index 5b704c63a103..1edcb141f639 100644
4798 +--- a/fs/ocfs2/buffer_head_io.c
4799 ++++ b/fs/ocfs2/buffer_head_io.c
4800 +@@ -90,7 +90,6 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh,
4801 + * information for this bh as it's not marked locally
4802 + * uptodate. */
4803 + ret = -EIO;
4804 +- put_bh(bh);
4805 + mlog_errno(ret);
4806 + }
4807 +
4808 +@@ -420,7 +419,6 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
4809 +
4810 + if (!buffer_uptodate(bh)) {
4811 + ret = -EIO;
4812 +- put_bh(bh);
4813 + mlog_errno(ret);
4814 + }
4815 +
4816 +diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
4817 +index 7035af09cc03..fe29f7978f81 100644
4818 +--- a/fs/ocfs2/dlm/dlmrecovery.c
4819 ++++ b/fs/ocfs2/dlm/dlmrecovery.c
4820 +@@ -537,7 +537,10 @@ master_here:
4821 + /* success! see if any other nodes need recovery */
4822 + mlog(0, "DONE mastering recovery of %s:%u here(this=%u)!\n",
4823 + dlm->name, dlm->reco.dead_node, dlm->node_num);
4824 +- dlm_reset_recovery(dlm);
4825 ++ spin_lock(&dlm->spinlock);
4826 ++ __dlm_reset_recovery(dlm);
4827 ++ dlm->reco.state &= ~DLM_RECO_STATE_FINALIZE;
4828 ++ spin_unlock(&dlm->spinlock);
4829 + }
4830 + dlm_end_recovery(dlm);
4831 +
4832 +@@ -695,6 +698,14 @@ static int dlm_remaster_locks(struct dlm_ctxt *dlm, u8 dead_node)
4833 + if (all_nodes_done) {
4834 + int ret;
4835 +
4836 ++ /* Set this flag on recovery master to avoid
4837 ++ * a new recovery for another dead node start
4838 ++ * before the recovery is not done. That may
4839 ++ * cause recovery hung.*/
4840 ++ spin_lock(&dlm->spinlock);
4841 ++ dlm->reco.state |= DLM_RECO_STATE_FINALIZE;
4842 ++ spin_unlock(&dlm->spinlock);
4843 ++
4844 + /* all nodes are now in DLM_RECO_NODE_DATA_DONE state
4845 + * just send a finalize message to everyone and
4846 + * clean up */
4847 +@@ -1750,13 +1761,13 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
4848 + struct dlm_migratable_lockres *mres)
4849 + {
4850 + struct dlm_migratable_lock *ml;
4851 +- struct list_head *queue;
4852 ++ struct list_head *queue, *iter;
4853 + struct list_head *tmpq = NULL;
4854 + struct dlm_lock *newlock = NULL;
4855 + struct dlm_lockstatus *lksb = NULL;
4856 + int ret = 0;
4857 + int i, j, bad;
4858 +- struct dlm_lock *lock = NULL;
4859 ++ struct dlm_lock *lock;
4860 + u8 from = O2NM_MAX_NODES;
4861 + unsigned int added = 0;
4862 + __be64 c;
4863 +@@ -1791,14 +1802,16 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
4864 + /* MIGRATION ONLY! */
4865 + BUG_ON(!(mres->flags & DLM_MRES_MIGRATION));
4866 +
4867 ++ lock = NULL;
4868 + spin_lock(&res->spinlock);
4869 + for (j = DLM_GRANTED_LIST; j <= DLM_BLOCKED_LIST; j++) {
4870 + tmpq = dlm_list_idx_to_ptr(res, j);
4871 +- list_for_each_entry(lock, tmpq, list) {
4872 +- if (lock->ml.cookie != ml->cookie)
4873 +- lock = NULL;
4874 +- else
4875 ++ list_for_each(iter, tmpq) {
4876 ++ lock = list_entry(iter,
4877 ++ struct dlm_lock, list);
4878 ++ if (lock->ml.cookie == ml->cookie)
4879 + break;
4880 ++ lock = NULL;
4881 + }
4882 + if (lock)
4883 + break;
4884 +@@ -2882,8 +2895,8 @@ int dlm_finalize_reco_handler(struct o2net_msg *msg, u32 len, void *data,
4885 + BUG();
4886 + }
4887 + dlm->reco.state &= ~DLM_RECO_STATE_FINALIZE;
4888 ++ __dlm_reset_recovery(dlm);
4889 + spin_unlock(&dlm->spinlock);
4890 +- dlm_reset_recovery(dlm);
4891 + dlm_kick_recovery_thread(dlm);
4892 + break;
4893 + default:
4894 +diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
4895 +index 3683643f3f0e..feed025fe064 100644
4896 +--- a/fs/ocfs2/namei.c
4897 ++++ b/fs/ocfs2/namei.c
4898 +@@ -450,7 +450,6 @@ leave:
4899 +
4900 + brelse(new_fe_bh);
4901 + brelse(parent_fe_bh);
4902 +- kfree(si.name);
4903 + kfree(si.value);
4904 +
4905 + ocfs2_free_dir_lookup_result(&lookup);
4906 +@@ -1855,7 +1854,6 @@ bail:
4907 +
4908 + brelse(new_fe_bh);
4909 + brelse(parent_fe_bh);
4910 +- kfree(si.name);
4911 + kfree(si.value);
4912 + ocfs2_free_dir_lookup_result(&lookup);
4913 + if (inode_ac)
4914 +diff --git a/fs/pnode.c b/fs/pnode.c
4915 +index 88396df725b4..a364a704333b 100644
4916 +--- a/fs/pnode.c
4917 ++++ b/fs/pnode.c
4918 +@@ -164,46 +164,94 @@ static struct mount *propagation_next(struct mount *m,
4919 + }
4920 + }
4921 +
4922 +-/*
4923 +- * return the source mount to be used for cloning
4924 +- *
4925 +- * @dest the current destination mount
4926 +- * @last_dest the last seen destination mount
4927 +- * @last_src the last seen source mount
4928 +- * @type return CL_SLAVE if the new mount has to be
4929 +- * cloned as a slave.
4930 +- */
4931 +-static struct mount *get_source(struct mount *dest,
4932 +- struct mount *last_dest,
4933 +- struct mount *last_src,
4934 +- int *type)
4935 ++static struct mount *next_group(struct mount *m, struct mount *origin)
4936 + {
4937 +- struct mount *p_last_src = NULL;
4938 +- struct mount *p_last_dest = NULL;
4939 +-
4940 +- while (last_dest != dest->mnt_master) {
4941 +- p_last_dest = last_dest;
4942 +- p_last_src = last_src;
4943 +- last_dest = last_dest->mnt_master;
4944 +- last_src = last_src->mnt_master;
4945 ++ while (1) {
4946 ++ while (1) {
4947 ++ struct mount *next;
4948 ++ if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list))
4949 ++ return first_slave(m);
4950 ++ next = next_peer(m);
4951 ++ if (m->mnt_group_id == origin->mnt_group_id) {
4952 ++ if (next == origin)
4953 ++ return NULL;
4954 ++ } else if (m->mnt_slave.next != &next->mnt_slave)
4955 ++ break;
4956 ++ m = next;
4957 ++ }
4958 ++ /* m is the last peer */
4959 ++ while (1) {
4960 ++ struct mount *master = m->mnt_master;
4961 ++ if (m->mnt_slave.next != &master->mnt_slave_list)
4962 ++ return next_slave(m);
4963 ++ m = next_peer(master);
4964 ++ if (master->mnt_group_id == origin->mnt_group_id)
4965 ++ break;
4966 ++ if (master->mnt_slave.next == &m->mnt_slave)
4967 ++ break;
4968 ++ m = master;
4969 ++ }
4970 ++ if (m == origin)
4971 ++ return NULL;
4972 + }
4973 ++}
4974 +
4975 +- if (p_last_dest) {
4976 +- do {
4977 +- p_last_dest = next_peer(p_last_dest);
4978 +- } while (IS_MNT_NEW(p_last_dest));
4979 +- /* is that a peer of the earlier? */
4980 +- if (dest == p_last_dest) {
4981 +- *type = CL_MAKE_SHARED;
4982 +- return p_last_src;
4983 ++/* all accesses are serialized by namespace_sem */
4984 ++static struct user_namespace *user_ns;
4985 ++static struct mount *last_dest, *last_source, *dest_master;
4986 ++static struct mountpoint *mp;
4987 ++static struct hlist_head *list;
4988 ++
4989 ++static int propagate_one(struct mount *m)
4990 ++{
4991 ++ struct mount *child;
4992 ++ int type;
4993 ++ /* skip ones added by this propagate_mnt() */
4994 ++ if (IS_MNT_NEW(m))
4995 ++ return 0;
4996 ++ /* skip if mountpoint isn't covered by it */
4997 ++ if (!is_subdir(mp->m_dentry, m->mnt.mnt_root))
4998 ++ return 0;
4999 ++ if (m->mnt_group_id == last_dest->mnt_group_id) {
5000 ++ type = CL_MAKE_SHARED;
5001 ++ } else {
5002 ++ struct mount *n, *p;
5003 ++ for (n = m; ; n = p) {
5004 ++ p = n->mnt_master;
5005 ++ if (p == dest_master || IS_MNT_MARKED(p)) {
5006 ++ while (last_dest->mnt_master != p) {
5007 ++ last_source = last_source->mnt_master;
5008 ++ last_dest = last_source->mnt_parent;
5009 ++ }
5010 ++ if (n->mnt_group_id != last_dest->mnt_group_id) {
5011 ++ last_source = last_source->mnt_master;
5012 ++ last_dest = last_source->mnt_parent;
5013 ++ }
5014 ++ break;
5015 ++ }
5016 + }
5017 ++ type = CL_SLAVE;
5018 ++ /* beginning of peer group among the slaves? */
5019 ++ if (IS_MNT_SHARED(m))
5020 ++ type |= CL_MAKE_SHARED;
5021 + }
5022 +- /* slave of the earlier, then */
5023 +- *type = CL_SLAVE;
5024 +- /* beginning of peer group among the slaves? */
5025 +- if (IS_MNT_SHARED(dest))
5026 +- *type |= CL_MAKE_SHARED;
5027 +- return last_src;
5028 ++
5029 ++ /* Notice when we are propagating across user namespaces */
5030 ++ if (m->mnt_ns->user_ns != user_ns)
5031 ++ type |= CL_UNPRIVILEGED;
5032 ++ child = copy_tree(last_source, last_source->mnt.mnt_root, type);
5033 ++ if (IS_ERR(child))
5034 ++ return PTR_ERR(child);
5035 ++ mnt_set_mountpoint(m, mp, child);
5036 ++ last_dest = m;
5037 ++ last_source = child;
5038 ++ if (m->mnt_master != dest_master) {
5039 ++ read_seqlock_excl(&mount_lock);
5040 ++ SET_MNT_MARK(m->mnt_master);
5041 ++ read_sequnlock_excl(&mount_lock);
5042 ++ }
5043 ++ hlist_add_head(&child->mnt_hash, list);
5044 ++ return 0;
5045 + }
5046 +
5047 + /*
5048 +@@ -222,56 +270,48 @@ static struct mount *get_source(struct mount *dest,
5049 + int propagate_mnt(struct mount *dest_mnt, struct mountpoint *dest_mp,
5050 + struct mount *source_mnt, struct hlist_head *tree_list)
5051 + {
5052 +- struct user_namespace *user_ns = current->nsproxy->mnt_ns->user_ns;
5053 +- struct mount *m, *child;
5054 ++ struct mount *m, *n;
5055 + int ret = 0;
5056 +- struct mount *prev_dest_mnt = dest_mnt;
5057 +- struct mount *prev_src_mnt = source_mnt;
5058 +- HLIST_HEAD(tmp_list);
5059 +-
5060 +- for (m = propagation_next(dest_mnt, dest_mnt); m;
5061 +- m = propagation_next(m, dest_mnt)) {
5062 +- int type;
5063 +- struct mount *source;
5064 +-
5065 +- if (IS_MNT_NEW(m))
5066 +- continue;
5067 +-
5068 +- source = get_source(m, prev_dest_mnt, prev_src_mnt, &type);
5069 +-
5070 +- /* Notice when we are propagating across user namespaces */
5071 +- if (m->mnt_ns->user_ns != user_ns)
5072 +- type |= CL_UNPRIVILEGED;
5073 +-
5074 +- child = copy_tree(source, source->mnt.mnt_root, type);
5075 +- if (IS_ERR(child)) {
5076 +- ret = PTR_ERR(child);
5077 +- tmp_list = *tree_list;
5078 +- tmp_list.first->pprev = &tmp_list.first;
5079 +- INIT_HLIST_HEAD(tree_list);
5080 ++
5081 ++ /*
5082 ++ * we don't want to bother passing tons of arguments to
5083 ++ * propagate_one(); everything is serialized by namespace_sem,
5084 ++ * so globals will do just fine.
5085 ++ */
5086 ++ user_ns = current->nsproxy->mnt_ns->user_ns;
5087 ++ last_dest = dest_mnt;
5088 ++ last_source = source_mnt;
5089 ++ mp = dest_mp;
5090 ++ list = tree_list;
5091 ++ dest_master = dest_mnt->mnt_master;
5092 ++
5093 ++ /* all peers of dest_mnt, except dest_mnt itself */
5094 ++ for (n = next_peer(dest_mnt); n != dest_mnt; n = next_peer(n)) {
5095 ++ ret = propagate_one(n);
5096 ++ if (ret)
5097 + goto out;
5098 +- }
5099 ++ }
5100 +
5101 +- if (is_subdir(dest_mp->m_dentry, m->mnt.mnt_root)) {
5102 +- mnt_set_mountpoint(m, dest_mp, child);
5103 +- hlist_add_head(&child->mnt_hash, tree_list);
5104 +- } else {
5105 +- /*
5106 +- * This can happen if the parent mount was bind mounted
5107 +- * on some subdirectory of a shared/slave mount.
5108 +- */
5109 +- hlist_add_head(&child->mnt_hash, &tmp_list);
5110 +- }
5111 +- prev_dest_mnt = m;
5112 +- prev_src_mnt = child;
5113 ++ /* all slave groups */
5114 ++ for (m = next_group(dest_mnt, dest_mnt); m;
5115 ++ m = next_group(m, dest_mnt)) {
5116 ++ /* everything in that slave group */
5117 ++ n = m;
5118 ++ do {
5119 ++ ret = propagate_one(n);
5120 ++ if (ret)
5121 ++ goto out;
5122 ++ n = next_peer(n);
5123 ++ } while (n != m);
5124 + }
5125 + out:
5126 +- lock_mount_hash();
5127 +- while (!hlist_empty(&tmp_list)) {
5128 +- child = hlist_entry(tmp_list.first, struct mount, mnt_hash);
5129 +- umount_tree(child, 0);
5130 ++ read_seqlock_excl(&mount_lock);
5131 ++ hlist_for_each_entry(n, tree_list, mnt_hash) {
5132 ++ m = n->mnt_parent;
5133 ++ if (m->mnt_master != dest_mnt->mnt_master)
5134 ++ CLEAR_MNT_MARK(m->mnt_master);
5135 + }
5136 +- unlock_mount_hash();
5137 ++ read_sequnlock_excl(&mount_lock);
5138 + return ret;
5139 + }
5140 +
5141 +diff --git a/fs/pnode.h b/fs/pnode.h
5142 +index fc28a27fa892..4a246358b031 100644
5143 +--- a/fs/pnode.h
5144 ++++ b/fs/pnode.h
5145 +@@ -16,6 +16,9 @@
5146 + #define IS_MNT_NEW(m) (!(m)->mnt_ns)
5147 + #define CLEAR_MNT_SHARED(m) ((m)->mnt.mnt_flags &= ~MNT_SHARED)
5148 + #define IS_MNT_UNBINDABLE(m) ((m)->mnt.mnt_flags & MNT_UNBINDABLE)
5149 ++#define IS_MNT_MARKED(m) ((m)->mnt.mnt_flags & MNT_MARKED)
5150 ++#define SET_MNT_MARK(m) ((m)->mnt.mnt_flags |= MNT_MARKED)
5151 ++#define CLEAR_MNT_MARK(m) ((m)->mnt.mnt_flags &= ~MNT_MARKED)
5152 +
5153 + #define CL_EXPIRE 0x01
5154 + #define CL_SLAVE 0x02
5155 +diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
5156 +index 1fd2051109a3..af677353a3f5 100644
5157 +--- a/fs/reiserfs/dir.c
5158 ++++ b/fs/reiserfs/dir.c
5159 +@@ -125,6 +125,7 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
5160 + int d_reclen;
5161 + char *d_name;
5162 + ino_t d_ino;
5163 ++ loff_t cur_pos = deh_offset(deh);
5164 +
5165 + if (!de_visible(deh))
5166 + /* it is hidden entry */
5167 +@@ -196,8 +197,9 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
5168 + if (local_buf != small_buf) {
5169 + kfree(local_buf);
5170 + }
5171 +- // next entry should be looked for with such offset
5172 +- next_pos = deh_offset(deh) + 1;
5173 ++
5174 ++ /* deh_offset(deh) may be invalid now. */
5175 ++ next_pos = cur_pos + 1;
5176 +
5177 + if (item_moved(&tmp_ih, &path_to_entry)) {
5178 + set_cpu_key_k_offset(&pos_key,
5179 +diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/word-at-a-time.h
5180 +index d3909effd725..d96deb443f18 100644
5181 +--- a/include/asm-generic/word-at-a-time.h
5182 ++++ b/include/asm-generic/word-at-a-time.h
5183 +@@ -50,11 +50,7 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct
5184 + }
5185 +
5186 + #ifndef zero_bytemask
5187 +-#ifdef CONFIG_64BIT
5188 +-#define zero_bytemask(mask) (~0ul << fls64(mask))
5189 +-#else
5190 +-#define zero_bytemask(mask) (~0ul << fls(mask))
5191 +-#endif /* CONFIG_64BIT */
5192 +-#endif /* zero_bytemask */
5193 ++#define zero_bytemask(mask) (~0ul << __fls(mask) << 1)
5194 ++#endif
5195 +
5196 + #endif /* _ASM_WORD_AT_A_TIME_H */
5197 +diff --git a/include/dt-bindings/clock/tegra124-car.h b/include/dt-bindings/clock/tegra124-car.h
5198 +index 8c1603b10665..433528ab5161 100644
5199 +--- a/include/dt-bindings/clock/tegra124-car.h
5200 ++++ b/include/dt-bindings/clock/tegra124-car.h
5201 +@@ -29,7 +29,7 @@
5202 + /* 10 (register bit affects spdif_in and spdif_out) */
5203 + #define TEGRA124_CLK_I2S1 11
5204 + #define TEGRA124_CLK_I2C1 12
5205 +-#define TEGRA124_CLK_NDFLASH 13
5206 ++/* 13 */
5207 + #define TEGRA124_CLK_SDMMC1 14
5208 + #define TEGRA124_CLK_SDMMC4 15
5209 + /* 16 */
5210 +@@ -83,7 +83,7 @@
5211 +
5212 + /* 64 */
5213 + #define TEGRA124_CLK_UARTD 65
5214 +-#define TEGRA124_CLK_UARTE 66
5215 ++/* 66 */
5216 + #define TEGRA124_CLK_I2C3 67
5217 + #define TEGRA124_CLK_SBC4 68
5218 + #define TEGRA124_CLK_SDMMC3 69
5219 +@@ -97,7 +97,7 @@
5220 + #define TEGRA124_CLK_TRACE 77
5221 + #define TEGRA124_CLK_SOC_THERM 78
5222 + #define TEGRA124_CLK_DTV 79
5223 +-#define TEGRA124_CLK_NDSPEED 80
5224 ++/* 80 */
5225 + #define TEGRA124_CLK_I2CSLOW 81
5226 + #define TEGRA124_CLK_DSIB 82
5227 + #define TEGRA124_CLK_TSEC 83
5228 +diff --git a/include/linux/bio.h b/include/linux/bio.h
5229 +index 5a4d39b4686b..5aa372a7380c 100644
5230 +--- a/include/linux/bio.h
5231 ++++ b/include/linux/bio.h
5232 +@@ -216,9 +216,9 @@ static inline void bvec_iter_advance(struct bio_vec *bv, struct bvec_iter *iter,
5233 + }
5234 +
5235 + #define for_each_bvec(bvl, bio_vec, iter, start) \
5236 +- for ((iter) = start; \
5237 +- (bvl) = bvec_iter_bvec((bio_vec), (iter)), \
5238 +- (iter).bi_size; \
5239 ++ for (iter = (start); \
5240 ++ (iter).bi_size && \
5241 ++ ((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \
5242 + bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
5243 +
5244 +
5245 +diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
5246 +index 344883dce584..6088058a3e00 100644
5247 +--- a/include/linux/hyperv.h
5248 ++++ b/include/linux/hyperv.h
5249 +@@ -464,15 +464,17 @@ hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
5250 + * 0 . 13 (Windows Server 2008)
5251 + * 1 . 1 (Windows 7)
5252 + * 2 . 4 (Windows 8)
5253 ++ * 3 . 0 (Windows 8 R2)
5254 + */
5255 +
5256 + #define VERSION_WS2008 ((0 << 16) | (13))
5257 + #define VERSION_WIN7 ((1 << 16) | (1))
5258 + #define VERSION_WIN8 ((2 << 16) | (4))
5259 ++#define VERSION_WIN8_1 ((3 << 16) | (0))
5260 +
5261 + #define VERSION_INVAL -1
5262 +
5263 +-#define VERSION_CURRENT VERSION_WIN8
5264 ++#define VERSION_CURRENT VERSION_WIN8_1
5265 +
5266 + /* Make maximum size of pipe payload of 16K */
5267 + #define MAX_PIPE_DATA_PAYLOAD (sizeof(u8) * 16384)
5268 +diff --git a/include/linux/mount.h b/include/linux/mount.h
5269 +index 371d346fa270..839bac270904 100644
5270 +--- a/include/linux/mount.h
5271 ++++ b/include/linux/mount.h
5272 +@@ -44,6 +44,8 @@ struct mnt_namespace;
5273 + #define MNT_SHARED_MASK (MNT_UNBINDABLE)
5274 + #define MNT_PROPAGATION_MASK (MNT_SHARED | MNT_UNBINDABLE)
5275 +
5276 ++#define MNT_INTERNAL_FLAGS (MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | \
5277 ++ MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED)
5278 +
5279 + #define MNT_INTERNAL 0x4000
5280 +
5281 +@@ -51,6 +53,7 @@ struct mnt_namespace;
5282 + #define MNT_LOCKED 0x800000
5283 + #define MNT_DOOMED 0x1000000
5284 + #define MNT_SYNC_UMOUNT 0x2000000
5285 ++#define MNT_MARKED 0x4000000
5286 +
5287 + struct vfsmount {
5288 + struct dentry *mnt_root; /* root of the mounted tree */
5289 +diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
5290 +index 62fd1b756e99..947009ed5996 100644
5291 +--- a/include/linux/sunrpc/svcsock.h
5292 ++++ b/include/linux/sunrpc/svcsock.h
5293 +@@ -56,6 +56,7 @@ int svc_recv(struct svc_rqst *, long);
5294 + int svc_send(struct svc_rqst *);
5295 + void svc_drop(struct svc_rqst *);
5296 + void svc_sock_update_bufs(struct svc_serv *serv);
5297 ++bool svc_alien_sock(struct net *net, int fd);
5298 + int svc_addsock(struct svc_serv *serv, const int fd,
5299 + char *name_return, const size_t len);
5300 + void svc_init_xprt_sock(void);
5301 +diff --git a/include/rdma/ib_cm.h b/include/rdma/ib_cm.h
5302 +index f29e3a27c2cc..0e3ff30647d5 100644
5303 +--- a/include/rdma/ib_cm.h
5304 ++++ b/include/rdma/ib_cm.h
5305 +@@ -601,5 +601,4 @@ struct ib_cm_sidr_rep_param {
5306 + int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
5307 + struct ib_cm_sidr_rep_param *param);
5308 +
5309 +-int ib_update_cm_av(struct ib_cm_id *id, const u8 *smac, const u8 *alt_smac);
5310 + #endif /* IB_CM_H */
5311 +diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
5312 +index 335e8a7cad39..c140620dad92 100644
5313 +--- a/include/uapi/linux/libc-compat.h
5314 ++++ b/include/uapi/linux/libc-compat.h
5315 +@@ -85,6 +85,12 @@
5316 +
5317 + #endif /* _NETINET_IN_H */
5318 +
5319 ++/* Definitions for xattr.h */
5320 ++#if defined(_SYS_XATTR_H)
5321 ++#define __UAPI_DEF_XATTR 0
5322 ++#else
5323 ++#define __UAPI_DEF_XATTR 1
5324 ++#endif
5325 +
5326 + /* If we did not see any headers from any supported C libraries,
5327 + * or we are being included in the kernel, then define everything
5328 +@@ -98,6 +104,9 @@
5329 + #define __UAPI_DEF_IPV6_MREQ 1
5330 + #define __UAPI_DEF_IPPROTO_V6 1
5331 +
5332 ++/* Definitions for xattr.h */
5333 ++#define __UAPI_DEF_XATTR 1
5334 ++
5335 + #endif /* __GLIBC__ */
5336 +
5337 + #endif /* _UAPI_LIBC_COMPAT_H */
5338 +diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
5339 +index 6ae7bbe988cc..fe94bb90582e 100644
5340 +--- a/include/uapi/linux/videodev2.h
5341 ++++ b/include/uapi/linux/videodev2.h
5342 +@@ -1059,14 +1059,14 @@ struct v4l2_bt_timings {
5343 +
5344 + /* A few useful defines to calculate the total blanking and frame sizes */
5345 + #define V4L2_DV_BT_BLANKING_WIDTH(bt) \
5346 +- (bt->hfrontporch + bt->hsync + bt->hbackporch)
5347 ++ ((bt)->hfrontporch + (bt)->hsync + (bt)->hbackporch)
5348 + #define V4L2_DV_BT_FRAME_WIDTH(bt) \
5349 +- (bt->width + V4L2_DV_BT_BLANKING_WIDTH(bt))
5350 ++ ((bt)->width + V4L2_DV_BT_BLANKING_WIDTH(bt))
5351 + #define V4L2_DV_BT_BLANKING_HEIGHT(bt) \
5352 +- (bt->vfrontporch + bt->vsync + bt->vbackporch + \
5353 +- bt->il_vfrontporch + bt->il_vsync + bt->il_vbackporch)
5354 ++ ((bt)->vfrontporch + (bt)->vsync + (bt)->vbackporch + \
5355 ++ (bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch)
5356 + #define V4L2_DV_BT_FRAME_HEIGHT(bt) \
5357 +- (bt->height + V4L2_DV_BT_BLANKING_HEIGHT(bt))
5358 ++ ((bt)->height + V4L2_DV_BT_BLANKING_HEIGHT(bt))
5359 +
5360 + /** struct v4l2_dv_timings - DV timings
5361 + * @type: the type of the timings
5362 +diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
5363 +index 40bbc04b6f81..c38355c1f3c9 100644
5364 +--- a/include/uapi/linux/xattr.h
5365 ++++ b/include/uapi/linux/xattr.h
5366 +@@ -7,11 +7,18 @@
5367 + Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved.
5368 + Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@××××××.com>
5369 + */
5370 ++
5371 ++#include <linux/libc-compat.h>
5372 ++
5373 + #ifndef _UAPI_LINUX_XATTR_H
5374 + #define _UAPI_LINUX_XATTR_H
5375 +
5376 ++#ifdef __UAPI_DEF_XATTR
5377 ++#define __USE_KERNEL_XATTR_DEFS
5378 ++
5379 + #define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
5380 + #define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
5381 ++#endif
5382 +
5383 + /* Namespaces */
5384 + #define XATTR_OS2_PREFIX "os2."
5385 +diff --git a/kernel/sysctl.c b/kernel/sysctl.c
5386 +index 49e13e1f8fe6..aae21e842918 100644
5387 +--- a/kernel/sysctl.c
5388 ++++ b/kernel/sysctl.c
5389 +@@ -144,6 +144,11 @@ static int min_percpu_pagelist_fract = 8;
5390 + static int ngroups_max = NGROUPS_MAX;
5391 + static const int cap_last_cap = CAP_LAST_CAP;
5392 +
5393 ++/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
5394 ++#ifdef CONFIG_DETECT_HUNG_TASK
5395 ++static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
5396 ++#endif
5397 ++
5398 + #ifdef CONFIG_INOTIFY_USER
5399 + #include <linux/inotify.h>
5400 + #endif
5401 +@@ -995,6 +1000,7 @@ static struct ctl_table kern_table[] = {
5402 + .maxlen = sizeof(unsigned long),
5403 + .mode = 0644,
5404 + .proc_handler = proc_dohung_task_timeout_secs,
5405 ++ .extra2 = &hung_task_timeout_max,
5406 + },
5407 + {
5408 + .procname = "hung_task_warnings",
5409 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
5410 +index c01cb9fedb18..2de3c845f03a 100644
5411 +--- a/mm/hugetlb.c
5412 ++++ b/mm/hugetlb.c
5413 +@@ -1509,6 +1509,7 @@ static unsigned long set_max_huge_pages(struct hstate *h, unsigned long count,
5414 + while (min_count < persistent_huge_pages(h)) {
5415 + if (!free_pool_huge_page(h, nodes_allowed, 0))
5416 + break;
5417 ++ cond_resched_lock(&hugetlb_lock);
5418 + }
5419 + while (count < persistent_huge_pages(h)) {
5420 + if (!adjust_pool_surplus(h, nodes_allowed, 1))
5421 +diff --git a/mm/internal.h b/mm/internal.h
5422 +index 29e1e761f9eb..3e910000fda4 100644
5423 +--- a/mm/internal.h
5424 ++++ b/mm/internal.h
5425 +@@ -370,5 +370,6 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone,
5426 + #define ALLOC_HIGH 0x20 /* __GFP_HIGH set */
5427 + #define ALLOC_CPUSET 0x40 /* check for correct cpuset */
5428 + #define ALLOC_CMA 0x80 /* allow allocations from CMA areas */
5429 ++#define ALLOC_FAIR 0x100 /* fair zone allocation */
5430 +
5431 + #endif /* __MM_INTERNAL_H */
5432 +diff --git a/mm/mlock.c b/mm/mlock.c
5433 +index 4e1a68162285..b1eb53634005 100644
5434 +--- a/mm/mlock.c
5435 ++++ b/mm/mlock.c
5436 +@@ -79,6 +79,7 @@ void clear_page_mlock(struct page *page)
5437 + */
5438 + void mlock_vma_page(struct page *page)
5439 + {
5440 ++ /* Serialize with page migration */
5441 + BUG_ON(!PageLocked(page));
5442 +
5443 + if (!TestSetPageMlocked(page)) {
5444 +@@ -174,6 +175,7 @@ unsigned int munlock_vma_page(struct page *page)
5445 + unsigned int nr_pages;
5446 + struct zone *zone = page_zone(page);
5447 +
5448 ++ /* For try_to_munlock() and to serialize with page migration */
5449 + BUG_ON(!PageLocked(page));
5450 +
5451 + /*
5452 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
5453 +index 3bac76ae4b30..7387a671234e 100644
5454 +--- a/mm/page_alloc.c
5455 ++++ b/mm/page_alloc.c
5456 +@@ -1238,15 +1238,6 @@ void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp)
5457 + }
5458 + local_irq_restore(flags);
5459 + }
5460 +-static bool gfp_thisnode_allocation(gfp_t gfp_mask)
5461 +-{
5462 +- return (gfp_mask & GFP_THISNODE) == GFP_THISNODE;
5463 +-}
5464 +-#else
5465 +-static bool gfp_thisnode_allocation(gfp_t gfp_mask)
5466 +-{
5467 +- return false;
5468 +-}
5469 + #endif
5470 +
5471 + /*
5472 +@@ -1583,12 +1574,7 @@ again:
5473 + get_pageblock_migratetype(page));
5474 + }
5475 +
5476 +- /*
5477 +- * NOTE: GFP_THISNODE allocations do not partake in the kswapd
5478 +- * aging protocol, so they can't be fair.
5479 +- */
5480 +- if (!gfp_thisnode_allocation(gfp_flags))
5481 +- __mod_zone_page_state(zone, NR_ALLOC_BATCH, -(1 << order));
5482 ++ __mod_zone_page_state(zone, NR_ALLOC_BATCH, -(1 << order));
5483 +
5484 + __count_zone_vm_events(PGALLOC, zone, 1 << order);
5485 + zone_statistics(preferred_zone, zone, gfp_flags);
5486 +@@ -1954,23 +1940,12 @@ zonelist_scan:
5487 + * zone size to ensure fair page aging. The zone a
5488 + * page was allocated in should have no effect on the
5489 + * time the page has in memory before being reclaimed.
5490 +- *
5491 +- * Try to stay in local zones in the fastpath. If
5492 +- * that fails, the slowpath is entered, which will do
5493 +- * another pass starting with the local zones, but
5494 +- * ultimately fall back to remote zones that do not
5495 +- * partake in the fairness round-robin cycle of this
5496 +- * zonelist.
5497 +- *
5498 +- * NOTE: GFP_THISNODE allocations do not partake in
5499 +- * the kswapd aging protocol, so they can't be fair.
5500 + */
5501 +- if ((alloc_flags & ALLOC_WMARK_LOW) &&
5502 +- !gfp_thisnode_allocation(gfp_mask)) {
5503 +- if (zone_page_state(zone, NR_ALLOC_BATCH) <= 0)
5504 +- continue;
5505 ++ if (alloc_flags & ALLOC_FAIR) {
5506 + if (!zone_local(preferred_zone, zone))
5507 + continue;
5508 ++ if (zone_page_state(zone, NR_ALLOC_BATCH) <= 0)
5509 ++ continue;
5510 + }
5511 + /*
5512 + * When allocating a page cache page for writing, we
5513 +@@ -2408,32 +2383,40 @@ __alloc_pages_high_priority(gfp_t gfp_mask, unsigned int order,
5514 + return page;
5515 + }
5516 +
5517 +-static void prepare_slowpath(gfp_t gfp_mask, unsigned int order,
5518 +- struct zonelist *zonelist,
5519 +- enum zone_type high_zoneidx,
5520 +- struct zone *preferred_zone)
5521 ++static void reset_alloc_batches(struct zonelist *zonelist,
5522 ++ enum zone_type high_zoneidx,
5523 ++ struct zone *preferred_zone)
5524 + {
5525 + struct zoneref *z;
5526 + struct zone *zone;
5527 +
5528 + for_each_zone_zonelist(zone, z, zonelist, high_zoneidx) {
5529 +- if (!(gfp_mask & __GFP_NO_KSWAPD))
5530 +- wakeup_kswapd(zone, order, zone_idx(preferred_zone));
5531 + /*
5532 + * Only reset the batches of zones that were actually
5533 +- * considered in the fast path, we don't want to
5534 +- * thrash fairness information for zones that are not
5535 ++ * considered in the fairness pass, we don't want to
5536 ++ * trash fairness information for zones that are not
5537 + * actually part of this zonelist's round-robin cycle.
5538 + */
5539 + if (!zone_local(preferred_zone, zone))
5540 + continue;
5541 + mod_zone_page_state(zone, NR_ALLOC_BATCH,
5542 +- high_wmark_pages(zone) -
5543 +- low_wmark_pages(zone) -
5544 +- zone_page_state(zone, NR_ALLOC_BATCH));
5545 ++ high_wmark_pages(zone) - low_wmark_pages(zone) -
5546 ++ atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]));
5547 + }
5548 + }
5549 +
5550 ++static void wake_all_kswapds(unsigned int order,
5551 ++ struct zonelist *zonelist,
5552 ++ enum zone_type high_zoneidx,
5553 ++ struct zone *preferred_zone)
5554 ++{
5555 ++ struct zoneref *z;
5556 ++ struct zone *zone;
5557 ++
5558 ++ for_each_zone_zonelist(zone, z, zonelist, high_zoneidx)
5559 ++ wakeup_kswapd(zone, order, zone_idx(preferred_zone));
5560 ++}
5561 ++
5562 + static inline int
5563 + gfp_to_alloc_flags(gfp_t gfp_mask)
5564 + {
5565 +@@ -2522,12 +2505,13 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
5566 + * allowed per node queues are empty and that nodes are
5567 + * over allocated.
5568 + */
5569 +- if (gfp_thisnode_allocation(gfp_mask))
5570 ++ if (IS_ENABLED(CONFIG_NUMA) &&
5571 ++ (gfp_mask & GFP_THISNODE) == GFP_THISNODE)
5572 + goto nopage;
5573 +
5574 + restart:
5575 +- prepare_slowpath(gfp_mask, order, zonelist,
5576 +- high_zoneidx, preferred_zone);
5577 ++ if (!(gfp_mask & __GFP_NO_KSWAPD))
5578 ++ wake_all_kswapds(order, zonelist, high_zoneidx, preferred_zone);
5579 +
5580 + /*
5581 + * OK, we're below the kswapd watermark and have kicked background
5582 +@@ -2711,7 +2695,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
5583 + struct page *page = NULL;
5584 + int migratetype = allocflags_to_migratetype(gfp_mask);
5585 + unsigned int cpuset_mems_cookie;
5586 +- int alloc_flags = ALLOC_WMARK_LOW|ALLOC_CPUSET;
5587 ++ int alloc_flags = ALLOC_WMARK_LOW|ALLOC_CPUSET|ALLOC_FAIR;
5588 + struct mem_cgroup *memcg = NULL;
5589 +
5590 + gfp_mask &= gfp_allowed_mask;
5591 +@@ -2752,12 +2736,29 @@ retry_cpuset:
5592 + if (allocflags_to_migratetype(gfp_mask) == MIGRATE_MOVABLE)
5593 + alloc_flags |= ALLOC_CMA;
5594 + #endif
5595 ++retry:
5596 + /* First allocation attempt */
5597 + page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, nodemask, order,
5598 + zonelist, high_zoneidx, alloc_flags,
5599 + preferred_zone, migratetype);
5600 + if (unlikely(!page)) {
5601 + /*
5602 ++ * The first pass makes sure allocations are spread
5603 ++ * fairly within the local node. However, the local
5604 ++ * node might have free pages left after the fairness
5605 ++ * batches are exhausted, and remote zones haven't
5606 ++ * even been considered yet. Try once more without
5607 ++ * fairness, and include remote zones now, before
5608 ++ * entering the slowpath and waking kswapd: prefer
5609 ++ * spilling to a remote zone over swapping locally.
5610 ++ */
5611 ++ if (alloc_flags & ALLOC_FAIR) {
5612 ++ reset_alloc_batches(zonelist, high_zoneidx,
5613 ++ preferred_zone);
5614 ++ alloc_flags &= ~ALLOC_FAIR;
5615 ++ goto retry;
5616 ++ }
5617 ++ /*
5618 + * Runtime PM, block IO and its error handling path
5619 + * can deadlock because I/O on the device might not
5620 + * complete.
5621 +diff --git a/mm/rmap.c b/mm/rmap.c
5622 +index 8fc049f9a5a6..d3cbac508c2f 100644
5623 +--- a/mm/rmap.c
5624 ++++ b/mm/rmap.c
5625 +@@ -1322,9 +1322,19 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
5626 + BUG_ON(!page || PageAnon(page));
5627 +
5628 + if (locked_vma) {
5629 +- mlock_vma_page(page); /* no-op if already mlocked */
5630 +- if (page == check_page)
5631 ++ if (page == check_page) {
5632 ++ /* we know we have check_page locked */
5633 ++ mlock_vma_page(page);
5634 + ret = SWAP_MLOCK;
5635 ++ } else if (trylock_page(page)) {
5636 ++ /*
5637 ++ * If we can lock the page, perform mlock.
5638 ++ * Otherwise leave the page alone, it will be
5639 ++ * eventually encountered again later.
5640 ++ */
5641 ++ mlock_vma_page(page);
5642 ++ unlock_page(page);
5643 ++ }
5644 + continue; /* don't unmap */
5645 + }
5646 +
5647 +diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
5648 +index b6e59f0a9475..d06cb8752dcd 100644
5649 +--- a/net/sunrpc/svcsock.c
5650 ++++ b/net/sunrpc/svcsock.c
5651 +@@ -1397,6 +1397,22 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
5652 + return svsk;
5653 + }
5654 +
5655 ++bool svc_alien_sock(struct net *net, int fd)
5656 ++{
5657 ++ int err;
5658 ++ struct socket *sock = sockfd_lookup(fd, &err);
5659 ++ bool ret = false;
5660 ++
5661 ++ if (!sock)
5662 ++ goto out;
5663 ++ if (sock_net(sock->sk) != net)
5664 ++ ret = true;
5665 ++ sockfd_put(sock);
5666 ++out:
5667 ++ return ret;
5668 ++}
5669 ++EXPORT_SYMBOL_GPL(svc_alien_sock);
5670 ++
5671 + /**
5672 + * svc_addsock - add a listener socket to an RPC service
5673 + * @serv: pointer to RPC service to which to add a new listener
5674 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
5675 +index 8d0a84436674..41106813a9aa 100644
5676 +--- a/sound/pci/hda/patch_realtek.c
5677 ++++ b/sound/pci/hda/patch_realtek.c
5678 +@@ -993,6 +993,7 @@ static int alc_codec_rename_from_preset(struct hda_codec *codec)
5679 +
5680 + static const struct snd_pci_quirk beep_white_list[] = {
5681 + SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
5682 ++ SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
5683 + SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
5684 + SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
5685 + SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
5686 +@@ -2786,6 +2787,89 @@ static void alc269_shutup(struct hda_codec *codec)
5687 + snd_hda_shutup_pins(codec);
5688 + }
5689 +
5690 ++static void alc283_restore_default_value(struct hda_codec *codec)
5691 ++{
5692 ++ int val;
5693 ++
5694 ++ /* Power Down Control */
5695 ++ alc_write_coef_idx(codec, 0x03, 0x0002);
5696 ++ /* FIFO and filter clock */
5697 ++ alc_write_coef_idx(codec, 0x05, 0x0700);
5698 ++ /* DMIC control */
5699 ++ alc_write_coef_idx(codec, 0x07, 0x0200);
5700 ++ /* Analog clock */
5701 ++ val = alc_read_coef_idx(codec, 0x06);
5702 ++ alc_write_coef_idx(codec, 0x06, (val & ~0x00f0) | 0x0);
5703 ++ /* JD */
5704 ++ val = alc_read_coef_idx(codec, 0x08);
5705 ++ alc_write_coef_idx(codec, 0x08, (val & ~0xfffc) | 0x0c2c);
5706 ++ /* JD offset1 */
5707 ++ alc_write_coef_idx(codec, 0x0a, 0xcccc);
5708 ++ /* JD offset2 */
5709 ++ alc_write_coef_idx(codec, 0x0b, 0xcccc);
5710 ++ /* LDO1/2/3, DAC/ADC */
5711 ++ alc_write_coef_idx(codec, 0x0e, 0x6fc0);
5712 ++ /* JD */
5713 ++ val = alc_read_coef_idx(codec, 0x0f);
5714 ++ alc_write_coef_idx(codec, 0x0f, (val & ~0xf800) | 0x1000);
5715 ++ /* Capless */
5716 ++ val = alc_read_coef_idx(codec, 0x10);
5717 ++ alc_write_coef_idx(codec, 0x10, (val & ~0xfc00) | 0x0c00);
5718 ++ /* Class D test 4 */
5719 ++ alc_write_coef_idx(codec, 0x3a, 0x0);
5720 ++ /* IO power down directly */
5721 ++ val = alc_read_coef_idx(codec, 0x0c);
5722 ++ alc_write_coef_idx(codec, 0x0c, (val & ~0xfe00) | 0x0);
5723 ++ /* ANC */
5724 ++ alc_write_coef_idx(codec, 0x22, 0xa0c0);
5725 ++ /* AGC MUX */
5726 ++ val = alc_read_coefex_idx(codec, 0x53, 0x01);
5727 ++ alc_write_coefex_idx(codec, 0x53, 0x01, (val & ~0x000f) | 0x0008);
5728 ++ /* DAC simple content protection */
5729 ++ val = alc_read_coef_idx(codec, 0x1d);
5730 ++ alc_write_coef_idx(codec, 0x1d, (val & ~0x00e0) | 0x0);
5731 ++ /* ADC simple content protection */
5732 ++ val = alc_read_coef_idx(codec, 0x1f);
5733 ++ alc_write_coef_idx(codec, 0x1f, (val & ~0x00e0) | 0x0);
5734 ++ /* DAC ADC Zero Detection */
5735 ++ alc_write_coef_idx(codec, 0x21, 0x8804);
5736 ++ /* PLL */
5737 ++ alc_write_coef_idx(codec, 0x2e, 0x2902);
5738 ++ /* capless control 2 */
5739 ++ alc_write_coef_idx(codec, 0x33, 0xa080);
5740 ++ /* capless control 3 */
5741 ++ alc_write_coef_idx(codec, 0x34, 0x3400);
5742 ++ /* capless control 4 */
5743 ++ alc_write_coef_idx(codec, 0x35, 0x2f3e);
5744 ++ /* capless control 5 */
5745 ++ alc_write_coef_idx(codec, 0x36, 0x0);
5746 ++ /* class D test 2 */
5747 ++ val = alc_read_coef_idx(codec, 0x38);
5748 ++ alc_write_coef_idx(codec, 0x38, (val & ~0x0fff) | 0x0900);
5749 ++ /* class D test 3 */
5750 ++ alc_write_coef_idx(codec, 0x39, 0x110a);
5751 ++ /* class D test 5 */
5752 ++ val = alc_read_coef_idx(codec, 0x3b);
5753 ++ alc_write_coef_idx(codec, 0x3b, (val & ~0x00f8) | 0x00d8);
5754 ++ /* class D test 6 */
5755 ++ alc_write_coef_idx(codec, 0x3c, 0x0014);
5756 ++ /* classD OCP */
5757 ++ alc_write_coef_idx(codec, 0x3d, 0xc2ba);
5758 ++ /* classD pure DC test */
5759 ++ val = alc_read_coef_idx(codec, 0x42);
5760 ++ alc_write_coef_idx(codec, 0x42, (val & ~0x0f80) | 0x0);
5761 ++ /* test mode */
5762 ++ alc_write_coef_idx(codec, 0x49, 0x0);
5763 ++ /* Class D DC enable */
5764 ++ val = alc_read_coef_idx(codec, 0x40);
5765 ++ alc_write_coef_idx(codec, 0x40, (val & ~0xf800) | 0x9800);
5766 ++ /* DC offset */
5767 ++ val = alc_read_coef_idx(codec, 0x42);
5768 ++ alc_write_coef_idx(codec, 0x42, (val & ~0xf000) | 0x2000);
5769 ++ /* Class D amp control */
5770 ++ alc_write_coef_idx(codec, 0x37, 0xfc06);
5771 ++}
5772 ++
5773 + static void alc283_init(struct hda_codec *codec)
5774 + {
5775 + struct alc_spec *spec = codec->spec;
5776 +@@ -2793,6 +2877,8 @@ static void alc283_init(struct hda_codec *codec)
5777 + bool hp_pin_sense;
5778 + int val;
5779 +
5780 ++ alc283_restore_default_value(codec);
5781 ++
5782 + if (!hp_pin)
5783 + return;
5784 + hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
5785 +@@ -3126,8 +3212,9 @@ static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
5786 +
5787 + if (spec->mute_led_polarity)
5788 + enabled = !enabled;
5789 +- pinval = AC_PINCTL_IN_EN |
5790 +- (enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80);
5791 ++ pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
5792 ++ pinval &= ~AC_PINCTL_VREFEN;
5793 ++ pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
5794 + if (spec->mute_led_nid)
5795 + snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
5796 + }
5797 +@@ -4319,6 +4406,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5798 + SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
5799 + SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
5800 + SND_PCI_QUIRK(0x1028, 0x0629, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
5801 ++ SND_PCI_QUIRK(0x1028, 0x062c, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
5802 ++ SND_PCI_QUIRK(0x1028, 0x062e, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
5803 ++ SND_PCI_QUIRK(0x1028, 0x0632, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
5804 + SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
5805 + SND_PCI_QUIRK(0x1028, 0x063e, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
5806 + SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
5807 +@@ -4618,6 +4708,7 @@ static int patch_alc269(struct hda_codec *codec)
5808 + spec->codec_variant = ALC269_TYPE_ALC285;
5809 + break;
5810 + case 0x10ec0286:
5811 ++ case 0x10ec0288:
5812 + spec->codec_variant = ALC269_TYPE_ALC286;
5813 + break;
5814 + case 0x10ec0255:
5815 +@@ -5184,6 +5275,8 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
5816 + SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5817 + SND_PCI_QUIRK(0x1028, 0x0628, "Dell", ALC668_FIXUP_AUTO_MUTE),
5818 + SND_PCI_QUIRK(0x1028, 0x064e, "Dell", ALC668_FIXUP_AUTO_MUTE),
5819 ++ SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5820 ++ SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5821 + SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
5822 + SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A_CHMAP),
5823 + SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_CHMAP),
5824 +@@ -5424,6 +5517,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
5825 + { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
5826 + { .id = 0x10ec0285, .name = "ALC285", .patch = patch_alc269 },
5827 + { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 },
5828 ++ { .id = 0x10ec0288, .name = "ALC288", .patch = patch_alc269 },
5829 + { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
5830 + { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
5831 + { .id = 0x10ec0293, .name = "ALC293", .patch = patch_alc269 },
5832 +diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
5833 +index 28ec872e54c0..b6e278fe8f67 100644
5834 +--- a/sound/pci/ice1712/ice1712.c
5835 ++++ b/sound/pci/ice1712/ice1712.c
5836 +@@ -685,9 +685,10 @@ static snd_pcm_uframes_t snd_ice1712_playback_pointer(struct snd_pcm_substream *
5837 + if (!(snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL) & 1))
5838 + return 0;
5839 + ptr = runtime->buffer_size - inw(ice->ddma_port + 4);
5840 ++ ptr = bytes_to_frames(substream->runtime, ptr);
5841 + if (ptr == runtime->buffer_size)
5842 + ptr = 0;
5843 +- return bytes_to_frames(substream->runtime, ptr);
5844 ++ return ptr;
5845 + }
5846 +
5847 + static snd_pcm_uframes_t snd_ice1712_playback_ds_pointer(struct snd_pcm_substream *substream)
5848 +@@ -704,9 +705,10 @@ static snd_pcm_uframes_t snd_ice1712_playback_ds_pointer(struct snd_pcm_substrea
5849 + addr = ICE1712_DSC_ADDR0;
5850 + ptr = snd_ice1712_ds_read(ice, substream->number * 2, addr) -
5851 + ice->playback_con_virt_addr[substream->number];
5852 ++ ptr = bytes_to_frames(substream->runtime, ptr);
5853 + if (ptr == substream->runtime->buffer_size)
5854 + ptr = 0;
5855 +- return bytes_to_frames(substream->runtime, ptr);
5856 ++ return ptr;
5857 + }
5858 +
5859 + static snd_pcm_uframes_t snd_ice1712_capture_pointer(struct snd_pcm_substream *substream)
5860 +@@ -717,9 +719,10 @@ static snd_pcm_uframes_t snd_ice1712_capture_pointer(struct snd_pcm_substream *s
5861 + if (!(snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL) & 1))
5862 + return 0;
5863 + ptr = inl(ICEREG(ice, CONCAP_ADDR)) - ice->capture_con_virt_addr;
5864 ++ ptr = bytes_to_frames(substream->runtime, ptr);
5865 + if (ptr == substream->runtime->buffer_size)
5866 + ptr = 0;
5867 +- return bytes_to_frames(substream->runtime, ptr);
5868 ++ return ptr;
5869 + }
5870 +
5871 + static const struct snd_pcm_hardware snd_ice1712_playback = {
5872 +@@ -1113,9 +1116,10 @@ static snd_pcm_uframes_t snd_ice1712_playback_pro_pointer(struct snd_pcm_substre
5873 + if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_PLAYBACK_START))
5874 + return 0;
5875 + ptr = ice->playback_pro_size - (inw(ICEMT(ice, PLAYBACK_SIZE)) << 2);
5876 ++ ptr = bytes_to_frames(substream->runtime, ptr);
5877 + if (ptr == substream->runtime->buffer_size)
5878 + ptr = 0;
5879 +- return bytes_to_frames(substream->runtime, ptr);
5880 ++ return ptr;
5881 + }
5882 +
5883 + static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(struct snd_pcm_substream *substream)
5884 +@@ -1126,9 +1130,10 @@ static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(struct snd_pcm_substrea
5885 + if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_CAPTURE_START_SHADOW))
5886 + return 0;
5887 + ptr = ice->capture_pro_size - (inw(ICEMT(ice, CAPTURE_SIZE)) << 2);
5888 ++ ptr = bytes_to_frames(substream->runtime, ptr);
5889 + if (ptr == substream->runtime->buffer_size)
5890 + ptr = 0;
5891 +- return bytes_to_frames(substream->runtime, ptr);
5892 ++ return ptr;
5893 + }
5894 +
5895 + static const struct snd_pcm_hardware snd_ice1712_playback_pro = {
5896 +diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c
5897 +index 6e9ea8379a91..7a272fa90b39 100644
5898 +--- a/sound/soc/codecs/cs42l51.c
5899 ++++ b/sound/soc/codecs/cs42l51.c
5900 +@@ -124,9 +124,8 @@ static int cs42l51_set_chan_mix(struct snd_kcontrol *kcontrol,
5901 +
5902 + static const DECLARE_TLV_DB_SCALE(adc_pcm_tlv, -5150, 50, 0);
5903 + static const DECLARE_TLV_DB_SCALE(tone_tlv, -1050, 150, 0);
5904 +-/* This is a lie. after -102 db, it stays at -102 */
5905 +-/* maybe a range would be better */
5906 +-static const DECLARE_TLV_DB_SCALE(aout_tlv, -11550, 50, 0);
5907 ++
5908 ++static const DECLARE_TLV_DB_SCALE(aout_tlv, -10200, 50, 0);
5909 +
5910 + static const DECLARE_TLV_DB_SCALE(boost_tlv, 1600, 1600, 0);
5911 + static const char *chan_mix[] = {
5912 +@@ -141,7 +140,7 @@ static const struct soc_enum cs42l51_chan_mix =
5913 + static const struct snd_kcontrol_new cs42l51_snd_controls[] = {
5914 + SOC_DOUBLE_R_SX_TLV("PCM Playback Volume",
5915 + CS42L51_PCMA_VOL, CS42L51_PCMB_VOL,
5916 +- 6, 0x19, 0x7F, adc_pcm_tlv),
5917 ++ 0, 0x19, 0x7F, adc_pcm_tlv),
5918 + SOC_DOUBLE_R("PCM Playback Switch",
5919 + CS42L51_PCMA_VOL, CS42L51_PCMB_VOL, 7, 1, 1),
5920 + SOC_DOUBLE_R_SX_TLV("Analog Playback Volume",
5921 +@@ -149,7 +148,7 @@ static const struct snd_kcontrol_new cs42l51_snd_controls[] = {
5922 + 0, 0x34, 0xE4, aout_tlv),
5923 + SOC_DOUBLE_R_SX_TLV("ADC Mixer Volume",
5924 + CS42L51_ADCA_VOL, CS42L51_ADCB_VOL,
5925 +- 6, 0x19, 0x7F, adc_pcm_tlv),
5926 ++ 0, 0x19, 0x7F, adc_pcm_tlv),
5927 + SOC_DOUBLE_R("ADC Mixer Switch",
5928 + CS42L51_ADCA_VOL, CS42L51_ADCB_VOL, 7, 1, 1),
5929 + SOC_SINGLE("Playback Deemphasis Switch", CS42L51_DAC_CTL, 3, 1, 0),
5930 +diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
5931 +index 0bac6d5a4ac8..1102ced9b20e 100644
5932 +--- a/sound/soc/codecs/cs42l52.c
5933 ++++ b/sound/soc/codecs/cs42l52.c
5934 +@@ -347,7 +347,7 @@ static const char * const right_swap_text[] = {
5935 + static const unsigned int swap_values[] = { 0, 1, 3 };
5936 +
5937 + static const struct soc_enum adca_swap_enum =
5938 +- SOC_VALUE_ENUM_SINGLE(CS42L52_ADC_PCM_MIXER, 2, 1,
5939 ++ SOC_VALUE_ENUM_SINGLE(CS42L52_ADC_PCM_MIXER, 2, 3,
5940 + ARRAY_SIZE(left_swap_text),
5941 + left_swap_text,
5942 + swap_values);
5943 +@@ -356,7 +356,7 @@ static const struct snd_kcontrol_new adca_mixer =
5944 + SOC_DAPM_ENUM("Route", adca_swap_enum);
5945 +
5946 + static const struct soc_enum pcma_swap_enum =
5947 +- SOC_VALUE_ENUM_SINGLE(CS42L52_ADC_PCM_MIXER, 6, 1,
5948 ++ SOC_VALUE_ENUM_SINGLE(CS42L52_ADC_PCM_MIXER, 6, 3,
5949 + ARRAY_SIZE(left_swap_text),
5950 + left_swap_text,
5951 + swap_values);
5952 +@@ -365,7 +365,7 @@ static const struct snd_kcontrol_new pcma_mixer =
5953 + SOC_DAPM_ENUM("Route", pcma_swap_enum);
5954 +
5955 + static const struct soc_enum adcb_swap_enum =
5956 +- SOC_VALUE_ENUM_SINGLE(CS42L52_ADC_PCM_MIXER, 0, 1,
5957 ++ SOC_VALUE_ENUM_SINGLE(CS42L52_ADC_PCM_MIXER, 0, 3,
5958 + ARRAY_SIZE(right_swap_text),
5959 + right_swap_text,
5960 + swap_values);
5961 +@@ -374,7 +374,7 @@ static const struct snd_kcontrol_new adcb_mixer =
5962 + SOC_DAPM_ENUM("Route", adcb_swap_enum);
5963 +
5964 + static const struct soc_enum pcmb_swap_enum =
5965 +- SOC_VALUE_ENUM_SINGLE(CS42L52_ADC_PCM_MIXER, 4, 1,
5966 ++ SOC_VALUE_ENUM_SINGLE(CS42L52_ADC_PCM_MIXER, 4, 3,
5967 + ARRAY_SIZE(right_swap_text),
5968 + right_swap_text,
5969 + swap_values);
5970 +diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c
5971 +index 549d5d6a3fef..7b95f7cbc515 100644
5972 +--- a/sound/soc/codecs/cs42l73.c
5973 ++++ b/sound/soc/codecs/cs42l73.c
5974 +@@ -319,7 +319,7 @@ static const char * const cs42l73_mono_mix_texts[] = {
5975 + static const unsigned int cs42l73_mono_mix_values[] = { 0, 1, 2 };
5976 +
5977 + static const struct soc_enum spk_asp_enum =
5978 +- SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 6, 1,
5979 ++ SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 6, 3,
5980 + ARRAY_SIZE(cs42l73_mono_mix_texts),
5981 + cs42l73_mono_mix_texts,
5982 + cs42l73_mono_mix_values);
5983 +@@ -337,7 +337,7 @@ static const struct snd_kcontrol_new spk_xsp_mixer =
5984 + SOC_DAPM_ENUM("Route", spk_xsp_enum);
5985 +
5986 + static const struct soc_enum esl_asp_enum =
5987 +- SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 2, 5,
5988 ++ SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 2, 3,
5989 + ARRAY_SIZE(cs42l73_mono_mix_texts),
5990 + cs42l73_mono_mix_texts,
5991 + cs42l73_mono_mix_values);
5992 +@@ -346,7 +346,7 @@ static const struct snd_kcontrol_new esl_asp_mixer =
5993 + SOC_DAPM_ENUM("Route", esl_asp_enum);
5994 +
5995 + static const struct soc_enum esl_xsp_enum =
5996 +- SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 0, 7,
5997 ++ SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 0, 3,
5998 + ARRAY_SIZE(cs42l73_mono_mix_texts),
5999 + cs42l73_mono_mix_texts,
6000 + cs42l73_mono_mix_values);
6001 +diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
6002 +index 28522bd03b8e..47e1ce771e65 100644
6003 +--- a/sound/soc/soc-pcm.c
6004 ++++ b/sound/soc/soc-pcm.c
6005 +@@ -1989,7 +1989,6 @@ int soc_dpcm_runtime_update(struct snd_soc_card *card)
6006 +
6007 + paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_PLAYBACK, &list);
6008 + if (paths < 0) {
6009 +- dpcm_path_put(&list);
6010 + dev_warn(fe->dev, "ASoC: %s no valid %s path\n",
6011 + fe->dai_link->name, "playback");
6012 + mutex_unlock(&card->mutex);
6013 +@@ -2019,7 +2018,6 @@ capture:
6014 +
6015 + paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_CAPTURE, &list);
6016 + if (paths < 0) {
6017 +- dpcm_path_put(&list);
6018 + dev_warn(fe->dev, "ASoC: %s no valid %s path\n",
6019 + fe->dai_link->name, "capture");
6020 + mutex_unlock(&card->mutex);
6021 +@@ -2084,7 +2082,6 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
6022 + fe->dpcm[stream].runtime = fe_substream->runtime;
6023 +
6024 + if (dpcm_path_get(fe, stream, &list) <= 0) {
6025 +- dpcm_path_put(&list);
6026 + dev_dbg(fe->dev, "ASoC: %s no valid %s route\n",
6027 + fe->dai_link->name, stream ? "capture" : "playback");
6028 + }