Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0233-5.4.134-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3637 - (show annotations) (download)
Mon Oct 24 12:40:44 2022 UTC (18 months ago) by niro
File size: 151231 byte(s)
-add missing
1 diff --git a/Makefile b/Makefile
2 index c0a064eea2b77..02ea9378161eb 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,7 +1,7 @@
6 # SPDX-License-Identifier: GPL-2.0
7 VERSION = 5
8 PATCHLEVEL = 4
9 -SUBLEVEL = 133
10 +SUBLEVEL = 134
11 EXTRAVERSION =
12 NAME = Kleptomaniac Octopus
13
14 diff --git a/arch/arm/boot/dts/am335x-cm-t335.dts b/arch/arm/boot/dts/am335x-cm-t335.dts
15 index 1fe3b566ba3df..09b36df140e5a 100644
16 --- a/arch/arm/boot/dts/am335x-cm-t335.dts
17 +++ b/arch/arm/boot/dts/am335x-cm-t335.dts
18 @@ -516,7 +516,7 @@ status = "okay";
19 status = "okay";
20 pinctrl-names = "default";
21 pinctrl-0 = <&spi0_pins>;
22 - ti,pindir-d0-out-d1-in = <1>;
23 + ti,pindir-d0-out-d1-in;
24 /* WLS1271 WiFi */
25 wlcore: wlcore@1 {
26 compatible = "ti,wl1271";
27 diff --git a/arch/arm/boot/dts/am43x-epos-evm.dts b/arch/arm/boot/dts/am43x-epos-evm.dts
28 index a6fbc088daa86..a9f191d78b544 100644
29 --- a/arch/arm/boot/dts/am43x-epos-evm.dts
30 +++ b/arch/arm/boot/dts/am43x-epos-evm.dts
31 @@ -848,7 +848,7 @@
32 pinctrl-names = "default", "sleep";
33 pinctrl-0 = <&spi0_pins_default>;
34 pinctrl-1 = <&spi0_pins_sleep>;
35 - ti,pindir-d0-out-d1-in = <1>;
36 + ti,pindir-d0-out-d1-in;
37 };
38
39 &spi1 {
40 @@ -856,7 +856,7 @@
41 pinctrl-names = "default", "sleep";
42 pinctrl-0 = <&spi1_pins_default>;
43 pinctrl-1 = <&spi1_pins_sleep>;
44 - ti,pindir-d0-out-d1-in = <1>;
45 + ti,pindir-d0-out-d1-in;
46 };
47
48 &usb2_phy1 {
49 diff --git a/arch/arm/boot/dts/bcm5301x.dtsi b/arch/arm/boot/dts/bcm5301x.dtsi
50 index 0016720ce5300..9711170649b69 100644
51 --- a/arch/arm/boot/dts/bcm5301x.dtsi
52 +++ b/arch/arm/boot/dts/bcm5301x.dtsi
53 @@ -494,27 +494,27 @@
54 <0x1811b408 0x004>,
55 <0x180293a0 0x01c>;
56 reg-names = "mspi", "bspi", "intr_regs", "intr_status_reg";
57 - interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
58 + interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>,
59 + <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>,
60 + <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
61 <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>,
62 <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>,
63 <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>,
64 - <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>,
65 - <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>,
66 - <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>;
67 - interrupt-names = "spi_lr_fullness_reached",
68 + <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
69 + interrupt-names = "mspi_done",
70 + "mspi_halted",
71 + "spi_lr_fullness_reached",
72 "spi_lr_session_aborted",
73 "spi_lr_impatient",
74 "spi_lr_session_done",
75 - "spi_lr_overhead",
76 - "mspi_done",
77 - "mspi_halted";
78 + "spi_lr_overread";
79 clocks = <&iprocmed>;
80 clock-names = "iprocmed";
81 num-cs = <2>;
82 #address-cells = <1>;
83 #size-cells = <0>;
84
85 - spi_nor: spi-nor@0 {
86 + spi_nor: flash@0 {
87 compatible = "jedec,spi-nor";
88 reg = <0>;
89 spi-max-frequency = <20000000>;
90 diff --git a/arch/arm/boot/dts/exynos5422-odroidhc1.dts b/arch/arm/boot/dts/exynos5422-odroidhc1.dts
91 index d271e75488262..fce5a4579693e 100644
92 --- a/arch/arm/boot/dts/exynos5422-odroidhc1.dts
93 +++ b/arch/arm/boot/dts/exynos5422-odroidhc1.dts
94 @@ -22,7 +22,7 @@
95 label = "blue:heartbeat";
96 pwms = <&pwm 2 2000000 0>;
97 pwm-names = "pwm2";
98 - max_brightness = <255>;
99 + max-brightness = <255>;
100 linux,default-trigger = "heartbeat";
101 };
102 };
103 diff --git a/arch/arm/boot/dts/exynos5422-odroidxu4.dts b/arch/arm/boot/dts/exynos5422-odroidxu4.dts
104 index 892d389d6d091..1fc3544854030 100644
105 --- a/arch/arm/boot/dts/exynos5422-odroidxu4.dts
106 +++ b/arch/arm/boot/dts/exynos5422-odroidxu4.dts
107 @@ -24,7 +24,7 @@
108 label = "blue:heartbeat";
109 pwms = <&pwm 2 2000000 0>;
110 pwm-names = "pwm2";
111 - max_brightness = <255>;
112 + max-brightness = <255>;
113 linux,default-trigger = "heartbeat";
114 };
115 };
116 diff --git a/arch/arm/boot/dts/exynos54xx-odroidxu-leds.dtsi b/arch/arm/boot/dts/exynos54xx-odroidxu-leds.dtsi
117 index 56acd832f0b3c..16e1087ec7172 100644
118 --- a/arch/arm/boot/dts/exynos54xx-odroidxu-leds.dtsi
119 +++ b/arch/arm/boot/dts/exynos54xx-odroidxu-leds.dtsi
120 @@ -22,7 +22,7 @@
121 * Green LED is much brighter than the others
122 * so limit its max brightness
123 */
124 - max_brightness = <127>;
125 + max-brightness = <127>;
126 linux,default-trigger = "mmc0";
127 };
128
129 @@ -30,7 +30,7 @@
130 label = "blue:heartbeat";
131 pwms = <&pwm 2 2000000 0>;
132 pwm-names = "pwm2";
133 - max_brightness = <255>;
134 + max-brightness = <255>;
135 linux,default-trigger = "heartbeat";
136 };
137 };
138 diff --git a/arch/arm/boot/dts/gemini-rut1xx.dts b/arch/arm/boot/dts/gemini-rut1xx.dts
139 index 9611ddf067927..08091d2a64e15 100644
140 --- a/arch/arm/boot/dts/gemini-rut1xx.dts
141 +++ b/arch/arm/boot/dts/gemini-rut1xx.dts
142 @@ -125,18 +125,6 @@
143 };
144 };
145
146 - ethernet@60000000 {
147 - status = "okay";
148 -
149 - ethernet-port@0 {
150 - phy-mode = "rgmii";
151 - phy-handle = <&phy0>;
152 - };
153 - ethernet-port@1 {
154 - /* Not used in this platform */
155 - };
156 - };
157 -
158 usb@68000000 {
159 status = "okay";
160 };
161 diff --git a/arch/arm/boot/dts/imx6q-dhcom-som.dtsi b/arch/arm/boot/dts/imx6q-dhcom-som.dtsi
162 index 621894d13dcbc..3233927d33b4c 100644
163 --- a/arch/arm/boot/dts/imx6q-dhcom-som.dtsi
164 +++ b/arch/arm/boot/dts/imx6q-dhcom-som.dtsi
165 @@ -98,30 +98,40 @@
166 reg = <0>;
167 max-speed = <100>;
168 reset-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
169 - reset-delay-us = <1000>;
170 - reset-post-delay-us = <1000>;
171 + reset-assert-us = <1000>;
172 + reset-deassert-us = <1000>;
173 + smsc,disable-energy-detect; /* Make plugin detection reliable */
174 };
175 };
176 };
177
178 &i2c1 {
179 clock-frequency = <100000>;
180 - pinctrl-names = "default";
181 + pinctrl-names = "default", "gpio";
182 pinctrl-0 = <&pinctrl_i2c1>;
183 + pinctrl-1 = <&pinctrl_i2c1_gpio>;
184 + scl-gpios = <&gpio3 21 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
185 + sda-gpios = <&gpio3 28 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
186 status = "okay";
187 };
188
189 &i2c2 {
190 clock-frequency = <100000>;
191 - pinctrl-names = "default";
192 + pinctrl-names = "default", "gpio";
193 pinctrl-0 = <&pinctrl_i2c2>;
194 + pinctrl-1 = <&pinctrl_i2c2_gpio>;
195 + scl-gpios = <&gpio4 12 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
196 + sda-gpios = <&gpio4 13 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
197 status = "okay";
198 };
199
200 &i2c3 {
201 clock-frequency = <100000>;
202 - pinctrl-names = "default";
203 + pinctrl-names = "default", "gpio";
204 pinctrl-0 = <&pinctrl_i2c3>;
205 + pinctrl-1 = <&pinctrl_i2c3_gpio>;
206 + scl-gpios = <&gpio1 3 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
207 + sda-gpios = <&gpio1 6 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
208 status = "okay";
209
210 ltc3676: pmic@3c {
211 @@ -287,6 +297,13 @@
212 >;
213 };
214
215 + pinctrl_i2c1_gpio: i2c1-gpio-grp {
216 + fsl,pins = <
217 + MX6QDL_PAD_EIM_D21__GPIO3_IO21 0x4001b8b1
218 + MX6QDL_PAD_EIM_D28__GPIO3_IO28 0x4001b8b1
219 + >;
220 + };
221 +
222 pinctrl_i2c2: i2c2-grp {
223 fsl,pins = <
224 MX6QDL_PAD_KEY_COL3__I2C2_SCL 0x4001b8b1
225 @@ -294,6 +311,13 @@
226 >;
227 };
228
229 + pinctrl_i2c2_gpio: i2c2-gpio-grp {
230 + fsl,pins = <
231 + MX6QDL_PAD_KEY_COL3__GPIO4_IO12 0x4001b8b1
232 + MX6QDL_PAD_KEY_ROW3__GPIO4_IO13 0x4001b8b1
233 + >;
234 + };
235 +
236 pinctrl_i2c3: i2c3-grp {
237 fsl,pins = <
238 MX6QDL_PAD_GPIO_3__I2C3_SCL 0x4001b8b1
239 @@ -301,6 +325,13 @@
240 >;
241 };
242
243 + pinctrl_i2c3_gpio: i2c3-gpio-grp {
244 + fsl,pins = <
245 + MX6QDL_PAD_GPIO_3__GPIO1_IO03 0x4001b8b1
246 + MX6QDL_PAD_GPIO_6__GPIO1_IO06 0x4001b8b1
247 + >;
248 + };
249 +
250 pinctrl_pmic_hw300: pmic-hw300-grp {
251 fsl,pins = <
252 MX6QDL_PAD_EIM_A25__GPIO5_IO02 0x1B0B0
253 diff --git a/arch/arm/boot/dts/r8a7779-marzen.dts b/arch/arm/boot/dts/r8a7779-marzen.dts
254 index c755f0b8fd0d7..29599adea2aba 100644
255 --- a/arch/arm/boot/dts/r8a7779-marzen.dts
256 +++ b/arch/arm/boot/dts/r8a7779-marzen.dts
257 @@ -146,7 +146,7 @@
258 status = "okay";
259
260 clocks = <&mstp1_clks R8A7779_CLK_DU>, <&x3_clk>;
261 - clock-names = "du", "dclkin.0";
262 + clock-names = "du.0", "dclkin.0";
263
264 ports {
265 port@0 {
266 diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
267 index 63341635bddf8..b3cb6492fc27e 100644
268 --- a/arch/arm/boot/dts/r8a7779.dtsi
269 +++ b/arch/arm/boot/dts/r8a7779.dtsi
270 @@ -463,6 +463,7 @@
271 reg = <0xfff80000 0x40000>;
272 interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
273 clocks = <&mstp1_clks R8A7779_CLK_DU>;
274 + clock-names = "du.0";
275 power-domains = <&sysc R8A7779_PD_ALWAYS_ON>;
276 status = "disabled";
277
278 diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
279 index 9aa483366ebcb..f226d4f57bf41 100644
280 --- a/arch/arm/mach-exynos/exynos.c
281 +++ b/arch/arm/mach-exynos/exynos.c
282 @@ -46,6 +46,7 @@ void __init exynos_sysram_init(void)
283 sysram_base_addr = of_iomap(node, 0);
284 sysram_base_phys = of_translate_address(node,
285 of_get_address(node, 0, NULL, NULL));
286 + of_node_put(node);
287 break;
288 }
289
290 @@ -53,6 +54,7 @@ void __init exynos_sysram_init(void)
291 if (!of_device_is_available(node))
292 continue;
293 sysram_ns_base_addr = of_iomap(node, 0);
294 + of_node_put(node);
295 break;
296 }
297 }
298 diff --git a/arch/arm/probes/kprobes/test-thumb.c b/arch/arm/probes/kprobes/test-thumb.c
299 index 456c181a7bfe8..4e11f0b760f89 100644
300 --- a/arch/arm/probes/kprobes/test-thumb.c
301 +++ b/arch/arm/probes/kprobes/test-thumb.c
302 @@ -441,21 +441,21 @@ void kprobe_thumb32_test_cases(void)
303 "3: mvn r0, r0 \n\t"
304 "2: nop \n\t")
305
306 - TEST_RX("tbh [pc, r",7, (9f-(1f+4))>>1,"]",
307 + TEST_RX("tbh [pc, r",7, (9f-(1f+4))>>1,", lsl #1]",
308 "9: \n\t"
309 ".short (2f-1b-4)>>1 \n\t"
310 ".short (3f-1b-4)>>1 \n\t"
311 "3: mvn r0, r0 \n\t"
312 "2: nop \n\t")
313
314 - TEST_RX("tbh [pc, r",12, ((9f-(1f+4))>>1)+1,"]",
315 + TEST_RX("tbh [pc, r",12, ((9f-(1f+4))>>1)+1,", lsl #1]",
316 "9: \n\t"
317 ".short (2f-1b-4)>>1 \n\t"
318 ".short (3f-1b-4)>>1 \n\t"
319 "3: mvn r0, r0 \n\t"
320 "2: nop \n\t")
321
322 - TEST_RRX("tbh [r",1,9f, ", r",14,1,"]",
323 + TEST_RRX("tbh [r",1,9f, ", r",14,1,", lsl #1]",
324 "9: \n\t"
325 ".short (2f-1b-4)>>1 \n\t"
326 ".short (3f-1b-4)>>1 \n\t"
327 @@ -468,10 +468,10 @@ void kprobe_thumb32_test_cases(void)
328
329 TEST_UNSUPPORTED("strexb r0, r1, [r2]")
330 TEST_UNSUPPORTED("strexh r0, r1, [r2]")
331 - TEST_UNSUPPORTED("strexd r0, r1, [r2]")
332 + TEST_UNSUPPORTED("strexd r0, r1, r2, [r2]")
333 TEST_UNSUPPORTED("ldrexb r0, [r1]")
334 TEST_UNSUPPORTED("ldrexh r0, [r1]")
335 - TEST_UNSUPPORTED("ldrexd r0, [r1]")
336 + TEST_UNSUPPORTED("ldrexd r0, r1, [r1]")
337
338 TEST_GROUP("Data-processing (shifted register) and (modified immediate)")
339
340 diff --git a/arch/arm64/boot/dts/renesas/r8a77970-v3msk.dts b/arch/arm64/boot/dts/renesas/r8a77970-v3msk.dts
341 index d7c7b9156e082..5c391248ddb31 100644
342 --- a/arch/arm64/boot/dts/renesas/r8a77970-v3msk.dts
343 +++ b/arch/arm64/boot/dts/renesas/r8a77970-v3msk.dts
344 @@ -59,7 +59,7 @@
345 memory@48000000 {
346 device_type = "memory";
347 /* first 128MB is reserved for secure area. */
348 - reg = <0x0 0x48000000 0x0 0x38000000>;
349 + reg = <0x0 0x48000000 0x0 0x78000000>;
350 };
351
352 osc5_clk: osc5-clock {
353 diff --git a/arch/hexagon/kernel/vmlinux.lds.S b/arch/hexagon/kernel/vmlinux.lds.S
354 index 78f2418e97c84..3c6b7abf0080e 100644
355 --- a/arch/hexagon/kernel/vmlinux.lds.S
356 +++ b/arch/hexagon/kernel/vmlinux.lds.S
357 @@ -60,13 +60,8 @@ SECTIONS
358
359 _end = .;
360
361 - /DISCARD/ : {
362 - EXIT_TEXT
363 - EXIT_DATA
364 - EXIT_CALL
365 - }
366 -
367 STABS_DEBUG
368 DWARF_DEBUG
369
370 + DISCARDS
371 }
372 diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
373 index 378cbfb31ee70..1d6ebbc2a5d02 100644
374 --- a/arch/mips/boot/compressed/Makefile
375 +++ b/arch/mips/boot/compressed/Makefile
376 @@ -33,7 +33,7 @@ KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
377 KCOV_INSTRUMENT := n
378
379 # decompressor objects (linked with vmlinuz)
380 -vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
381 +vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/bswapsi.o
382
383 ifdef CONFIG_DEBUG_ZBOOT
384 vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o
385 @@ -47,7 +47,7 @@ extra-y += uart-ath79.c
386 $(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c
387 $(call cmd,shipped)
388
389 -vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o
390 +vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o
391
392 extra-y += ashldi3.c
393 $(obj)/ashldi3.c: $(obj)/%.c: $(srctree)/lib/%.c FORCE
394 diff --git a/arch/mips/boot/compressed/decompress.c b/arch/mips/boot/compressed/decompress.c
395 index a52e929381ea4..281e922e5c652 100644
396 --- a/arch/mips/boot/compressed/decompress.c
397 +++ b/arch/mips/boot/compressed/decompress.c
398 @@ -7,6 +7,8 @@
399 * Author: Wu Zhangjin <wuzhangjin@gmail.com>
400 */
401
402 +#define DISABLE_BRANCH_PROFILING
403 +
404 #include <linux/types.h>
405 #include <linux/kernel.h>
406 #include <linux/string.h>
407 diff --git a/arch/mips/include/asm/vdso/vdso.h b/arch/mips/include/asm/vdso/vdso.h
408 index 737ddfc3411cb..a327ca21270ec 100644
409 --- a/arch/mips/include/asm/vdso/vdso.h
410 +++ b/arch/mips/include/asm/vdso/vdso.h
411 @@ -67,7 +67,7 @@ static inline const struct vdso_data *get_vdso_data(void)
412
413 static inline void __iomem *get_gic(const struct vdso_data *data)
414 {
415 - return (void __iomem *)data - PAGE_SIZE;
416 + return (void __iomem *)((unsigned long)data & PAGE_MASK) - PAGE_SIZE;
417 }
418
419 #endif /* CONFIG_CLKSRC_MIPS_GIC */
420 diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
421 index 5d91036ad626d..58fbcfcc98c9e 100644
422 --- a/arch/powerpc/boot/devtree.c
423 +++ b/arch/powerpc/boot/devtree.c
424 @@ -13,6 +13,7 @@
425 #include "string.h"
426 #include "stdio.h"
427 #include "ops.h"
428 +#include "of.h"
429
430 void dt_fixup_memory(u64 start, u64 size)
431 {
432 @@ -23,21 +24,25 @@ void dt_fixup_memory(u64 start, u64 size)
433 root = finddevice("/");
434 if (getprop(root, "#address-cells", &naddr, sizeof(naddr)) < 0)
435 naddr = 2;
436 + else
437 + naddr = be32_to_cpu(naddr);
438 if (naddr < 1 || naddr > 2)
439 fatal("Can't cope with #address-cells == %d in /\n\r", naddr);
440
441 if (getprop(root, "#size-cells", &nsize, sizeof(nsize)) < 0)
442 nsize = 1;
443 + else
444 + nsize = be32_to_cpu(nsize);
445 if (nsize < 1 || nsize > 2)
446 fatal("Can't cope with #size-cells == %d in /\n\r", nsize);
447
448 i = 0;
449 if (naddr == 2)
450 - memreg[i++] = start >> 32;
451 - memreg[i++] = start & 0xffffffff;
452 + memreg[i++] = cpu_to_be32(start >> 32);
453 + memreg[i++] = cpu_to_be32(start & 0xffffffff);
454 if (nsize == 2)
455 - memreg[i++] = size >> 32;
456 - memreg[i++] = size & 0xffffffff;
457 + memreg[i++] = cpu_to_be32(size >> 32);
458 + memreg[i++] = cpu_to_be32(size & 0xffffffff);
459
460 memory = finddevice("/memory");
461 if (! memory) {
462 @@ -45,9 +50,9 @@ void dt_fixup_memory(u64 start, u64 size)
463 setprop_str(memory, "device_type", "memory");
464 }
465
466 - printf("Memory <- <0x%x", memreg[0]);
467 + printf("Memory <- <0x%x", be32_to_cpu(memreg[0]));
468 for (i = 1; i < (naddr + nsize); i++)
469 - printf(" 0x%x", memreg[i]);
470 + printf(" 0x%x", be32_to_cpu(memreg[i]));
471 printf("> (%ldMB)\n\r", (unsigned long)(size >> 20));
472
473 setprop(memory, "reg", memreg, (naddr + nsize)*sizeof(u32));
474 @@ -65,10 +70,10 @@ void dt_fixup_cpu_clocks(u32 cpu, u32 tb, u32 bus)
475 printf("CPU bus-frequency <- 0x%x (%dMHz)\n\r", bus, MHZ(bus));
476
477 while ((devp = find_node_by_devtype(devp, "cpu"))) {
478 - setprop_val(devp, "clock-frequency", cpu);
479 - setprop_val(devp, "timebase-frequency", tb);
480 + setprop_val(devp, "clock-frequency", cpu_to_be32(cpu));
481 + setprop_val(devp, "timebase-frequency", cpu_to_be32(tb));
482 if (bus > 0)
483 - setprop_val(devp, "bus-frequency", bus);
484 + setprop_val(devp, "bus-frequency", cpu_to_be32(bus));
485 }
486
487 timebase_period_ns = 1000000000 / tb;
488 @@ -80,7 +85,7 @@ void dt_fixup_clock(const char *path, u32 freq)
489
490 if (devp) {
491 printf("%s: clock-frequency <- %x (%dMHz)\n\r", path, freq, MHZ(freq));
492 - setprop_val(devp, "clock-frequency", freq);
493 + setprop_val(devp, "clock-frequency", cpu_to_be32(freq));
494 }
495 }
496
497 @@ -133,8 +138,12 @@ void dt_get_reg_format(void *node, u32 *naddr, u32 *nsize)
498 {
499 if (getprop(node, "#address-cells", naddr, 4) != 4)
500 *naddr = 2;
501 + else
502 + *naddr = be32_to_cpu(*naddr);
503 if (getprop(node, "#size-cells", nsize, 4) != 4)
504 *nsize = 1;
505 + else
506 + *nsize = be32_to_cpu(*nsize);
507 }
508
509 static void copy_val(u32 *dest, u32 *src, int naddr)
510 @@ -163,9 +172,9 @@ static int add_reg(u32 *reg, u32 *add, int naddr)
511 int i, carry = 0;
512
513 for (i = MAX_ADDR_CELLS - 1; i >= MAX_ADDR_CELLS - naddr; i--) {
514 - u64 tmp = (u64)reg[i] + add[i] + carry;
515 + u64 tmp = (u64)be32_to_cpu(reg[i]) + be32_to_cpu(add[i]) + carry;
516 carry = tmp >> 32;
517 - reg[i] = (u32)tmp;
518 + reg[i] = cpu_to_be32((u32)tmp);
519 }
520
521 return !carry;
522 @@ -180,18 +189,18 @@ static int compare_reg(u32 *reg, u32 *range, u32 *rangesize)
523 u32 end;
524
525 for (i = 0; i < MAX_ADDR_CELLS; i++) {
526 - if (reg[i] < range[i])
527 + if (be32_to_cpu(reg[i]) < be32_to_cpu(range[i]))
528 return 0;
529 - if (reg[i] > range[i])
530 + if (be32_to_cpu(reg[i]) > be32_to_cpu(range[i]))
531 break;
532 }
533
534 for (i = 0; i < MAX_ADDR_CELLS; i++) {
535 - end = range[i] + rangesize[i];
536 + end = be32_to_cpu(range[i]) + be32_to_cpu(rangesize[i]);
537
538 - if (reg[i] < end)
539 + if (be32_to_cpu(reg[i]) < end)
540 break;
541 - if (reg[i] > end)
542 + if (be32_to_cpu(reg[i]) > end)
543 return 0;
544 }
545
546 @@ -240,7 +249,6 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
547 return 0;
548
549 dt_get_reg_format(parent, &naddr, &nsize);
550 -
551 if (nsize > 2)
552 return 0;
553
554 @@ -252,10 +260,10 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
555
556 copy_val(last_addr, prop_buf + offset, naddr);
557
558 - ret_size = prop_buf[offset + naddr];
559 + ret_size = be32_to_cpu(prop_buf[offset + naddr]);
560 if (nsize == 2) {
561 ret_size <<= 32;
562 - ret_size |= prop_buf[offset + naddr + 1];
563 + ret_size |= be32_to_cpu(prop_buf[offset + naddr + 1]);
564 }
565
566 for (;;) {
567 @@ -278,7 +286,6 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
568
569 offset = find_range(last_addr, prop_buf, prev_naddr,
570 naddr, prev_nsize, buflen / 4);
571 -
572 if (offset < 0)
573 return 0;
574
575 @@ -296,8 +303,7 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
576 if (naddr > 2)
577 return 0;
578
579 - ret_addr = ((u64)last_addr[2] << 32) | last_addr[3];
580 -
581 + ret_addr = ((u64)be32_to_cpu(last_addr[2]) << 32) | be32_to_cpu(last_addr[3]);
582 if (sizeof(void *) == 4 &&
583 (ret_addr >= 0x100000000ULL || ret_size > 0x100000000ULL ||
584 ret_addr + ret_size > 0x100000000ULL))
585 @@ -350,11 +356,14 @@ int dt_is_compatible(void *node, const char *compat)
586 int dt_get_virtual_reg(void *node, void **addr, int nres)
587 {
588 unsigned long xaddr;
589 - int n;
590 + int n, i;
591
592 n = getprop(node, "virtual-reg", addr, nres * 4);
593 - if (n > 0)
594 + if (n > 0) {
595 + for (i = 0; i < n/4; i ++)
596 + ((u32 *)addr)[i] = be32_to_cpu(((u32 *)addr)[i]);
597 return n / 4;
598 + }
599
600 for (n = 0; n < nres; n++) {
601 if (!dt_xlate_reg(node, n, &xaddr, NULL))
602 diff --git a/arch/powerpc/boot/ns16550.c b/arch/powerpc/boot/ns16550.c
603 index b0da4466d4198..f16d2be1d0f31 100644
604 --- a/arch/powerpc/boot/ns16550.c
605 +++ b/arch/powerpc/boot/ns16550.c
606 @@ -15,6 +15,7 @@
607 #include "stdio.h"
608 #include "io.h"
609 #include "ops.h"
610 +#include "of.h"
611
612 #define UART_DLL 0 /* Out: Divisor Latch Low */
613 #define UART_DLM 1 /* Out: Divisor Latch High */
614 @@ -58,16 +59,20 @@ int ns16550_console_init(void *devp, struct serial_console_data *scdp)
615 int n;
616 u32 reg_offset;
617
618 - if (dt_get_virtual_reg(devp, (void **)&reg_base, 1) < 1)
619 + if (dt_get_virtual_reg(devp, (void **)&reg_base, 1) < 1) {
620 + printf("virt reg parse fail...\r\n");
621 return -1;
622 + }
623
624 n = getprop(devp, "reg-offset", &reg_offset, sizeof(reg_offset));
625 if (n == sizeof(reg_offset))
626 - reg_base += reg_offset;
627 + reg_base += be32_to_cpu(reg_offset);
628
629 n = getprop(devp, "reg-shift", &reg_shift, sizeof(reg_shift));
630 if (n != sizeof(reg_shift))
631 reg_shift = 0;
632 + else
633 + reg_shift = be32_to_cpu(reg_shift);
634
635 scdp->open = ns16550_open;
636 scdp->putc = ns16550_putc;
637 diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h
638 index cb89e4bf55cef..964063765662b 100644
639 --- a/arch/powerpc/include/asm/ps3.h
640 +++ b/arch/powerpc/include/asm/ps3.h
641 @@ -71,6 +71,7 @@ struct ps3_dma_region_ops;
642 * @bus_addr: The 'translated' bus address of the region.
643 * @len: The length in bytes of the region.
644 * @offset: The offset from the start of memory of the region.
645 + * @dma_mask: Device dma_mask.
646 * @ioid: The IOID of the device who owns this region
647 * @chunk_list: Opaque variable used by the ioc page manager.
648 * @region_ops: struct ps3_dma_region_ops - dma region operations
649 @@ -85,6 +86,7 @@ struct ps3_dma_region {
650 enum ps3_dma_region_type region_type;
651 unsigned long len;
652 unsigned long offset;
653 + u64 dma_mask;
654
655 /* driver variables (set by ps3_dma_region_create) */
656 unsigned long bus_addr;
657 diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
658 index f42fe4e86ce52..c3e3746694003 100644
659 --- a/arch/powerpc/platforms/ps3/mm.c
660 +++ b/arch/powerpc/platforms/ps3/mm.c
661 @@ -6,6 +6,7 @@
662 * Copyright 2006 Sony Corp.
663 */
664
665 +#include <linux/dma-mapping.h>
666 #include <linux/kernel.h>
667 #include <linux/export.h>
668 #include <linux/memblock.h>
669 @@ -1118,6 +1119,7 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
670 enum ps3_dma_region_type region_type, void *addr, unsigned long len)
671 {
672 unsigned long lpar_addr;
673 + int result;
674
675 lpar_addr = addr ? ps3_mm_phys_to_lpar(__pa(addr)) : 0;
676
677 @@ -1129,6 +1131,16 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
678 r->offset -= map.r1.offset;
679 r->len = len ? len : _ALIGN_UP(map.total, 1 << r->page_size);
680
681 + dev->core.dma_mask = &r->dma_mask;
682 +
683 + result = dma_set_mask_and_coherent(&dev->core, DMA_BIT_MASK(32));
684 +
685 + if (result < 0) {
686 + dev_err(&dev->core, "%s:%d: dma_set_mask_and_coherent failed: %d\n",
687 + __func__, __LINE__, result);
688 + return result;
689 + }
690 +
691 switch (dev->dev_type) {
692 case PS3_DEVICE_TYPE_SB:
693 r->region_ops = (USE_DYNAMIC_DMA)
694 diff --git a/arch/s390/boot/ipl_parm.c b/arch/s390/boot/ipl_parm.c
695 index 24ef67eb1ceff..75905b548f69d 100644
696 --- a/arch/s390/boot/ipl_parm.c
697 +++ b/arch/s390/boot/ipl_parm.c
698 @@ -27,22 +27,25 @@ static inline int __diag308(unsigned long subcode, void *addr)
699 register unsigned long _addr asm("0") = (unsigned long)addr;
700 register unsigned long _rc asm("1") = 0;
701 unsigned long reg1, reg2;
702 - psw_t old = S390_lowcore.program_new_psw;
703 + psw_t old;
704
705 asm volatile(
706 + " mvc 0(16,%[psw_old]),0(%[psw_pgm])\n"
707 " epsw %0,%1\n"
708 - " st %0,%[psw_pgm]\n"
709 - " st %1,%[psw_pgm]+4\n"
710 + " st %0,0(%[psw_pgm])\n"
711 + " st %1,4(%[psw_pgm])\n"
712 " larl %0,1f\n"
713 - " stg %0,%[psw_pgm]+8\n"
714 + " stg %0,8(%[psw_pgm])\n"
715 " diag %[addr],%[subcode],0x308\n"
716 - "1: nopr %%r7\n"
717 + "1: mvc 0(16,%[psw_pgm]),0(%[psw_old])\n"
718 : "=&d" (reg1), "=&a" (reg2),
719 - [psw_pgm] "=Q" (S390_lowcore.program_new_psw),
720 + "+Q" (S390_lowcore.program_new_psw),
721 + "=Q" (old),
722 [addr] "+d" (_addr), "+d" (_rc)
723 - : [subcode] "d" (subcode)
724 + : [subcode] "d" (subcode),
725 + [psw_old] "a" (&old),
726 + [psw_pgm] "a" (&S390_lowcore.program_new_psw)
727 : "cc", "memory");
728 - S390_lowcore.program_new_psw = old;
729 return _rc;
730 }
731
732 diff --git a/arch/s390/boot/mem_detect.c b/arch/s390/boot/mem_detect.c
733 index 62e7c13ce85c7..85049541c191e 100644
734 --- a/arch/s390/boot/mem_detect.c
735 +++ b/arch/s390/boot/mem_detect.c
736 @@ -70,24 +70,27 @@ static int __diag260(unsigned long rx1, unsigned long rx2)
737 register unsigned long _ry asm("4") = 0x10; /* storage configuration */
738 int rc = -1; /* fail */
739 unsigned long reg1, reg2;
740 - psw_t old = S390_lowcore.program_new_psw;
741 + psw_t old;
742
743 asm volatile(
744 + " mvc 0(16,%[psw_old]),0(%[psw_pgm])\n"
745 " epsw %0,%1\n"
746 - " st %0,%[psw_pgm]\n"
747 - " st %1,%[psw_pgm]+4\n"
748 + " st %0,0(%[psw_pgm])\n"
749 + " st %1,4(%[psw_pgm])\n"
750 " larl %0,1f\n"
751 - " stg %0,%[psw_pgm]+8\n"
752 + " stg %0,8(%[psw_pgm])\n"
753 " diag %[rx],%[ry],0x260\n"
754 " ipm %[rc]\n"
755 " srl %[rc],28\n"
756 - "1:\n"
757 + "1: mvc 0(16,%[psw_pgm]),0(%[psw_old])\n"
758 : "=&d" (reg1), "=&a" (reg2),
759 - [psw_pgm] "=Q" (S390_lowcore.program_new_psw),
760 + "+Q" (S390_lowcore.program_new_psw),
761 + "=Q" (old),
762 [rc] "+&d" (rc), [ry] "+d" (_ry)
763 - : [rx] "d" (_rx1), "d" (_rx2)
764 + : [rx] "d" (_rx1), "d" (_rx2),
765 + [psw_old] "a" (&old),
766 + [psw_pgm] "a" (&S390_lowcore.program_new_psw)
767 : "cc", "memory");
768 - S390_lowcore.program_new_psw = old;
769 return rc == 0 ? _ry : -1;
770 }
771
772 @@ -112,24 +115,30 @@ static int diag260(void)
773
774 static int tprot(unsigned long addr)
775 {
776 - unsigned long pgm_addr;
777 + unsigned long reg1, reg2;
778 int rc = -EFAULT;
779 - psw_t old = S390_lowcore.program_new_psw;
780 + psw_t old;
781
782 - S390_lowcore.program_new_psw.mask = __extract_psw();
783 asm volatile(
784 - " larl %[pgm_addr],1f\n"
785 - " stg %[pgm_addr],%[psw_pgm_addr]\n"
786 + " mvc 0(16,%[psw_old]),0(%[psw_pgm])\n"
787 + " epsw %[reg1],%[reg2]\n"
788 + " st %[reg1],0(%[psw_pgm])\n"
789 + " st %[reg2],4(%[psw_pgm])\n"
790 + " larl %[reg1],1f\n"
791 + " stg %[reg1],8(%[psw_pgm])\n"
792 " tprot 0(%[addr]),0\n"
793 " ipm %[rc]\n"
794 " srl %[rc],28\n"
795 - "1:\n"
796 - : [pgm_addr] "=&d"(pgm_addr),
797 - [psw_pgm_addr] "=Q"(S390_lowcore.program_new_psw.addr),
798 - [rc] "+&d"(rc)
799 - : [addr] "a"(addr)
800 + "1: mvc 0(16,%[psw_pgm]),0(%[psw_old])\n"
801 + : [reg1] "=&d" (reg1),
802 + [reg2] "=&a" (reg2),
803 + [rc] "+&d" (rc),
804 + "=Q" (S390_lowcore.program_new_psw.addr),
805 + "=Q" (old)
806 + : [psw_old] "a" (&old),
807 + [psw_pgm] "a" (&S390_lowcore.program_new_psw),
808 + [addr] "a" (addr)
809 : "cc", "memory");
810 - S390_lowcore.program_new_psw = old;
811 return rc;
812 }
813
814 diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
815 index 560d8b77b1d17..48d6ccdef5f77 100644
816 --- a/arch/s390/include/asm/processor.h
817 +++ b/arch/s390/include/asm/processor.h
818 @@ -215,7 +215,7 @@ static inline unsigned long current_stack_pointer(void)
819 return sp;
820 }
821
822 -static __no_kasan_or_inline unsigned short stap(void)
823 +static __always_inline unsigned short stap(void)
824 {
825 unsigned short cpu_address;
826
827 @@ -254,7 +254,7 @@ static inline void __load_psw(psw_t psw)
828 * Set PSW mask to specified value, while leaving the
829 * PSW addr pointing to the next instruction.
830 */
831 -static __no_kasan_or_inline void __load_psw_mask(unsigned long mask)
832 +static __always_inline void __load_psw_mask(unsigned long mask)
833 {
834 unsigned long addr;
835 psw_t psw;
836 diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
837 index 3588f4c65a4d4..f661f176966f5 100644
838 --- a/arch/s390/kernel/setup.c
839 +++ b/arch/s390/kernel/setup.c
840 @@ -162,7 +162,7 @@ static void __init set_preferred_console(void)
841 else if (CONSOLE_IS_3270)
842 add_preferred_console("tty3270", 0, NULL);
843 else if (CONSOLE_IS_VT220)
844 - add_preferred_console("ttyS", 1, NULL);
845 + add_preferred_console("ttysclp", 0, NULL);
846 else if (CONSOLE_IS_HVC)
847 add_preferred_console("hvc", 0, NULL);
848 }
849 diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c
850 index d8845d4aac6a7..6040817c036f3 100644
851 --- a/arch/um/drivers/chan_user.c
852 +++ b/arch/um/drivers/chan_user.c
853 @@ -256,7 +256,8 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
854 goto out_close;
855 }
856
857 - if (os_set_fd_block(*fd_out, 0)) {
858 + err = os_set_fd_block(*fd_out, 0);
859 + if (err) {
860 printk(UM_KERN_ERR "winch_tramp: failed to set thread_fd "
861 "non-blocking.\n");
862 goto out_close;
863 diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c
864 index 8016d32b68092..8d736eb629614 100644
865 --- a/arch/um/drivers/slip_user.c
866 +++ b/arch/um/drivers/slip_user.c
867 @@ -145,7 +145,8 @@ static int slip_open(void *data)
868 }
869 sfd = err;
870
871 - if (set_up_tty(sfd))
872 + err = set_up_tty(sfd);
873 + if (err)
874 goto out_close2;
875
876 pri->slave = sfd;
877 diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
878 index 9f135e5b9cf51..a9d1dd82d8208 100644
879 --- a/arch/x86/include/asm/fpu/internal.h
880 +++ b/arch/x86/include/asm/fpu/internal.h
881 @@ -102,6 +102,7 @@ static inline void fpstate_init_fxstate(struct fxregs_state *fx)
882 }
883 extern void fpstate_sanitize_xstate(struct fpu *fpu);
884
885 +/* Returns 0 or the negated trap number, which results in -EFAULT for #PF */
886 #define user_insn(insn, output, input...) \
887 ({ \
888 int err; \
889 @@ -109,14 +110,14 @@ extern void fpstate_sanitize_xstate(struct fpu *fpu);
890 might_fault(); \
891 \
892 asm volatile(ASM_STAC "\n" \
893 - "1:" #insn "\n\t" \
894 + "1: " #insn "\n" \
895 "2: " ASM_CLAC "\n" \
896 ".section .fixup,\"ax\"\n" \
897 - "3: movl $-1,%[err]\n" \
898 + "3: negl %%eax\n" \
899 " jmp 2b\n" \
900 ".previous\n" \
901 - _ASM_EXTABLE(1b, 3b) \
902 - : [err] "=r" (err), output \
903 + _ASM_EXTABLE_FAULT(1b, 3b) \
904 + : [err] "=a" (err), output \
905 : "0"(0), input); \
906 err; \
907 })
908 @@ -210,16 +211,20 @@ static inline void copy_fxregs_to_kernel(struct fpu *fpu)
909 #define XRSTOR ".byte " REX_PREFIX "0x0f,0xae,0x2f"
910 #define XRSTORS ".byte " REX_PREFIX "0x0f,0xc7,0x1f"
911
912 +/*
913 + * After this @err contains 0 on success or the negated trap number when
914 + * the operation raises an exception. For faults this results in -EFAULT.
915 + */
916 #define XSTATE_OP(op, st, lmask, hmask, err) \
917 asm volatile("1:" op "\n\t" \
918 "xor %[err], %[err]\n" \
919 "2:\n\t" \
920 ".pushsection .fixup,\"ax\"\n\t" \
921 - "3: movl $-2,%[err]\n\t" \
922 + "3: negl %%eax\n\t" \
923 "jmp 2b\n\t" \
924 ".popsection\n\t" \
925 - _ASM_EXTABLE(1b, 3b) \
926 - : [err] "=r" (err) \
927 + _ASM_EXTABLE_FAULT(1b, 3b) \
928 + : [err] "=a" (err) \
929 : "D" (st), "m" (*st), "a" (lmask), "d" (hmask) \
930 : "memory")
931
932 diff --git a/arch/x86/kernel/fpu/regset.c b/arch/x86/kernel/fpu/regset.c
933 index d652b939ccfb5..68e1fb66e701b 100644
934 --- a/arch/x86/kernel/fpu/regset.c
935 +++ b/arch/x86/kernel/fpu/regset.c
936 @@ -124,7 +124,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
937 /*
938 * A whole standard-format XSAVE buffer is needed:
939 */
940 - if ((pos != 0) || (count < fpu_user_xstate_size))
941 + if (pos != 0 || count != fpu_user_xstate_size)
942 return -EFAULT;
943
944 xsave = &fpu->state.xsave;
945 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
946 index 2fdbf5ef8c39c..026ce06a24c03 100644
947 --- a/arch/x86/kernel/signal.c
948 +++ b/arch/x86/kernel/signal.c
949 @@ -241,10 +241,11 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
950 void __user **fpstate)
951 {
952 /* Default to using normal stack */
953 + bool nested_altstack = on_sig_stack(regs->sp);
954 + bool entering_altstack = false;
955 unsigned long math_size = 0;
956 unsigned long sp = regs->sp;
957 unsigned long buf_fx = 0;
958 - int onsigstack = on_sig_stack(sp);
959 int ret;
960
961 /* redzone */
962 @@ -253,15 +254,23 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
963
964 /* This is the X/Open sanctioned signal stack switching. */
965 if (ka->sa.sa_flags & SA_ONSTACK) {
966 - if (sas_ss_flags(sp) == 0)
967 + /*
968 + * This checks nested_altstack via sas_ss_flags(). Sensible
969 + * programs use SS_AUTODISARM, which disables that check, and
970 + * programs that don't use SS_AUTODISARM get compatible.
971 + */
972 + if (sas_ss_flags(sp) == 0) {
973 sp = current->sas_ss_sp + current->sas_ss_size;
974 + entering_altstack = true;
975 + }
976 } else if (IS_ENABLED(CONFIG_X86_32) &&
977 - !onsigstack &&
978 + !nested_altstack &&
979 regs->ss != __USER_DS &&
980 !(ka->sa.sa_flags & SA_RESTORER) &&
981 ka->sa.sa_restorer) {
982 /* This is the legacy signal stack switching. */
983 sp = (unsigned long) ka->sa.sa_restorer;
984 + entering_altstack = true;
985 }
986
987 sp = fpu__alloc_mathframe(sp, IS_ENABLED(CONFIG_X86_32),
988 @@ -274,8 +283,15 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
989 * If we are on the alternate signal stack and would overflow it, don't.
990 * Return an always-bogus address instead so we will die with SIGSEGV.
991 */
992 - if (onsigstack && !likely(on_sig_stack(sp)))
993 + if (unlikely((nested_altstack || entering_altstack) &&
994 + !__on_sig_stack(sp))) {
995 +
996 + if (show_unhandled_signals && printk_ratelimit())
997 + pr_info("%s[%d] overflowed sigaltstack\n",
998 + current->comm, task_pid_nr(current));
999 +
1000 return (void __user *)-1L;
1001 + }
1002
1003 /* save i387 and extended state */
1004 ret = copy_fpstate_to_sigframe(*fpstate, (void __user *)buf_fx, math_size);
1005 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
1006 index 6fa946f983c92..6a8db8eb0e943 100644
1007 --- a/arch/x86/kvm/cpuid.c
1008 +++ b/arch/x86/kvm/cpuid.c
1009 @@ -745,8 +745,14 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function,
1010 unsigned virt_as = max((entry->eax >> 8) & 0xff, 48U);
1011 unsigned phys_as = entry->eax & 0xff;
1012
1013 - if (!g_phys_as)
1014 + /*
1015 + * Use bare metal's MAXPHADDR if the CPU doesn't report guest
1016 + * MAXPHYADDR separately, or if TDP (NPT) is disabled, as the
1017 + * guest version "applies only to guests using nested paging".
1018 + */
1019 + if (!g_phys_as || !tdp_enabled)
1020 g_phys_as = phys_as;
1021 +
1022 entry->eax = g_phys_as | (virt_as << 8);
1023 entry->edx = 0;
1024 entry->ebx &= kvm_cpuid_8000_0008_ebx_x86_features;
1025 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
1026 index 4cc052108f156..377157656a8b6 100644
1027 --- a/arch/x86/kvm/x86.c
1028 +++ b/arch/x86/kvm/x86.c
1029 @@ -8271,6 +8271,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
1030 set_debugreg(vcpu->arch.eff_db[3], 3);
1031 set_debugreg(vcpu->arch.dr6, 6);
1032 vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_RELOAD;
1033 + } else if (unlikely(hw_breakpoint_active())) {
1034 + set_debugreg(0, 7);
1035 }
1036
1037 kvm_x86_ops->run(vcpu);
1038 diff --git a/drivers/acpi/acpi_amba.c b/drivers/acpi/acpi_amba.c
1039 index 49b781a9cd979..ab8a4e0191b19 100644
1040 --- a/drivers/acpi/acpi_amba.c
1041 +++ b/drivers/acpi/acpi_amba.c
1042 @@ -76,6 +76,7 @@ static int amba_handler_attach(struct acpi_device *adev,
1043 case IORESOURCE_MEM:
1044 if (!address_found) {
1045 dev->res = *rentry->res;
1046 + dev->res.name = dev_name(&dev->dev);
1047 address_found = true;
1048 }
1049 break;
1050 diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
1051 index 4f325e47519f5..81cd47d299320 100644
1052 --- a/drivers/acpi/acpi_video.c
1053 +++ b/drivers/acpi/acpi_video.c
1054 @@ -543,6 +543,15 @@ static const struct dmi_system_id video_dmi_table[] = {
1055 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"),
1056 },
1057 },
1058 + {
1059 + .callback = video_set_report_key_events,
1060 + .driver_data = (void *)((uintptr_t)REPORT_BRIGHTNESS_KEY_EVENTS),
1061 + .ident = "Dell Vostro 3350",
1062 + .matches = {
1063 + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
1064 + DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3350"),
1065 + },
1066 + },
1067 /*
1068 * Some machines change the brightness themselves when a brightness
1069 * hotkey gets pressed, despite us telling them not to. In this case
1070 diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
1071 index 2eeb2bcb488d4..816eb2db73080 100644
1072 --- a/drivers/block/virtio_blk.c
1073 +++ b/drivers/block/virtio_blk.c
1074 @@ -1057,6 +1057,8 @@ static int virtblk_freeze(struct virtio_device *vdev)
1075 blk_mq_quiesce_queue(vblk->disk->queue);
1076
1077 vdev->config->del_vqs(vdev);
1078 + kfree(vblk->vqs);
1079 +
1080 return 0;
1081 }
1082
1083 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
1084 index 5eabbf73fdef7..b453029487a12 100644
1085 --- a/drivers/char/virtio_console.c
1086 +++ b/drivers/char/virtio_console.c
1087 @@ -475,7 +475,7 @@ static struct port_buffer *get_inbuf(struct port *port)
1088
1089 buf = virtqueue_get_buf(port->in_vq, &len);
1090 if (buf) {
1091 - buf->len = len;
1092 + buf->len = min_t(size_t, len, buf->size);
1093 buf->offset = 0;
1094 port->stats.bytes_received += len;
1095 }
1096 @@ -1714,7 +1714,7 @@ static void control_work_handler(struct work_struct *work)
1097 while ((buf = virtqueue_get_buf(vq, &len))) {
1098 spin_unlock(&portdev->c_ivq_lock);
1099
1100 - buf->len = len;
1101 + buf->len = min_t(size_t, len, buf->size);
1102 buf->offset = 0;
1103
1104 handle_control_message(vq->vdev, portdev, buf);
1105 diff --git a/drivers/dma/fsl-qdma.c b/drivers/dma/fsl-qdma.c
1106 index 95cc0256b3878..f5a1ae164193f 100644
1107 --- a/drivers/dma/fsl-qdma.c
1108 +++ b/drivers/dma/fsl-qdma.c
1109 @@ -1184,7 +1184,11 @@ static int fsl_qdma_probe(struct platform_device *pdev)
1110 fsl_qdma->dma_dev.device_synchronize = fsl_qdma_synchronize;
1111 fsl_qdma->dma_dev.device_terminate_all = fsl_qdma_terminate_all;
1112
1113 - dma_set_mask(&pdev->dev, DMA_BIT_MASK(40));
1114 + ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(40));
1115 + if (ret) {
1116 + dev_err(&pdev->dev, "dma_set_mask failure.\n");
1117 + return ret;
1118 + }
1119
1120 platform_set_drvdata(pdev, fsl_qdma);
1121
1122 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
1123 index 11078199abed3..7b6903bad4085 100644
1124 --- a/drivers/firmware/arm_scmi/driver.c
1125 +++ b/drivers/firmware/arm_scmi/driver.c
1126 @@ -370,6 +370,10 @@ static void scmi_rx_callback(struct mbox_client *cl, void *m)
1127
1128 xfer = &minfo->xfer_block[xfer_id];
1129
1130 + /* rx.len could be shrunk in the sync do_xfer, so reset to maxsz */
1131 + if (msg_type == MSG_TYPE_DELAYED_RESP)
1132 + xfer->rx.len = info->desc->max_msg_size;
1133 +
1134 scmi_dump_header_dbg(dev, &xfer->hdr);
1135
1136 scmi_fetch_response(xfer, mem);
1137 diff --git a/drivers/firmware/tegra/bpmp-tegra210.c b/drivers/firmware/tegra/bpmp-tegra210.c
1138 index ae15940a078e3..c32754055c60b 100644
1139 --- a/drivers/firmware/tegra/bpmp-tegra210.c
1140 +++ b/drivers/firmware/tegra/bpmp-tegra210.c
1141 @@ -210,7 +210,7 @@ static int tegra210_bpmp_init(struct tegra_bpmp *bpmp)
1142 priv->tx_irq_data = irq_get_irq_data(err);
1143 if (!priv->tx_irq_data) {
1144 dev_err(&pdev->dev, "failed to get IRQ data for TX IRQ\n");
1145 - return err;
1146 + return -ENOENT;
1147 }
1148
1149 err = platform_get_irq_byname(pdev, "rx");
1150 diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
1151 index 72be58960e540..9a6cf5af27a3d 100644
1152 --- a/drivers/firmware/turris-mox-rwtm.c
1153 +++ b/drivers/firmware/turris-mox-rwtm.c
1154 @@ -134,11 +134,14 @@ MOX_ATTR_RO(pubkey, "%s\n", pubkey);
1155
1156 static int mox_get_status(enum mbox_cmd cmd, u32 retval)
1157 {
1158 - if (MBOX_STS_CMD(retval) != cmd ||
1159 - MBOX_STS_ERROR(retval) != MBOX_STS_SUCCESS)
1160 + if (MBOX_STS_CMD(retval) != cmd)
1161 return -EIO;
1162 else if (MBOX_STS_ERROR(retval) == MBOX_STS_FAIL)
1163 return -(int)MBOX_STS_VALUE(retval);
1164 + else if (MBOX_STS_ERROR(retval) == MBOX_STS_BADCMD)
1165 + return -ENOSYS;
1166 + else if (MBOX_STS_ERROR(retval) != MBOX_STS_SUCCESS)
1167 + return -EIO;
1168 else
1169 return MBOX_STS_VALUE(retval);
1170 }
1171 @@ -188,11 +191,14 @@ static int mox_get_board_info(struct mox_rwtm *rwtm)
1172 return ret;
1173
1174 ret = mox_get_status(MBOX_CMD_BOARD_INFO, reply->retval);
1175 - if (ret < 0 && ret != -ENODATA) {
1176 - return ret;
1177 - } else if (ret == -ENODATA) {
1178 + if (ret == -ENODATA) {
1179 dev_warn(rwtm->dev,
1180 "Board does not have manufacturing information burned!\n");
1181 + } else if (ret == -ENOSYS) {
1182 + dev_notice(rwtm->dev,
1183 + "Firmware does not support the BOARD_INFO command\n");
1184 + } else if (ret < 0) {
1185 + return ret;
1186 } else {
1187 rwtm->serial_number = reply->status[1];
1188 rwtm->serial_number <<= 32;
1189 @@ -221,10 +227,13 @@ static int mox_get_board_info(struct mox_rwtm *rwtm)
1190 return ret;
1191
1192 ret = mox_get_status(MBOX_CMD_ECDSA_PUB_KEY, reply->retval);
1193 - if (ret < 0 && ret != -ENODATA) {
1194 - return ret;
1195 - } else if (ret == -ENODATA) {
1196 + if (ret == -ENODATA) {
1197 dev_warn(rwtm->dev, "Board has no public key burned!\n");
1198 + } else if (ret == -ENOSYS) {
1199 + dev_notice(rwtm->dev,
1200 + "Firmware does not support the ECDSA_PUB_KEY command\n");
1201 + } else if (ret < 0) {
1202 + return ret;
1203 } else {
1204 u32 *s = reply->status;
1205
1206 @@ -238,6 +247,27 @@ static int mox_get_board_info(struct mox_rwtm *rwtm)
1207 return 0;
1208 }
1209
1210 +static int check_get_random_support(struct mox_rwtm *rwtm)
1211 +{
1212 + struct armada_37xx_rwtm_tx_msg msg;
1213 + int ret;
1214 +
1215 + msg.command = MBOX_CMD_GET_RANDOM;
1216 + msg.args[0] = 1;
1217 + msg.args[1] = rwtm->buf_phys;
1218 + msg.args[2] = 4;
1219 +
1220 + ret = mbox_send_message(rwtm->mbox, &msg);
1221 + if (ret < 0)
1222 + return ret;
1223 +
1224 + ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2);
1225 + if (ret < 0)
1226 + return ret;
1227 +
1228 + return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval);
1229 +}
1230 +
1231 static int mox_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait)
1232 {
1233 struct mox_rwtm *rwtm = (struct mox_rwtm *) rng->priv;
1234 @@ -329,6 +359,13 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev)
1235 if (ret < 0)
1236 dev_warn(dev, "Cannot read board information: %i\n", ret);
1237
1238 + ret = check_get_random_support(rwtm);
1239 + if (ret < 0) {
1240 + dev_notice(dev,
1241 + "Firmware does not support the GET_RANDOM command\n");
1242 + goto free_channel;
1243 + }
1244 +
1245 rwtm->hwrng.name = DRIVER_NAME "_hwrng";
1246 rwtm->hwrng.read = mox_hwrng_read;
1247 rwtm->hwrng.priv = (unsigned long) rwtm;
1248 diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
1249 index 9a24dce3c2628..d9193ffa17a1e 100644
1250 --- a/drivers/gpio/gpio-pca953x.c
1251 +++ b/drivers/gpio/gpio-pca953x.c
1252 @@ -1272,6 +1272,7 @@ static const struct of_device_id pca953x_dt_ids[] = {
1253
1254 { .compatible = "onnn,cat9554", .data = OF_953X( 8, PCA_INT), },
1255 { .compatible = "onnn,pca9654", .data = OF_953X( 8, PCA_INT), },
1256 + { .compatible = "onnn,pca9655", .data = OF_953X(16, PCA_INT), },
1257
1258 { .compatible = "exar,xra1202", .data = OF_953X( 8, 0), },
1259 { }
1260 diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
1261 index 88b04d8a7fa7d..25a42605aa811 100644
1262 --- a/drivers/gpio/gpio-zynq.c
1263 +++ b/drivers/gpio/gpio-zynq.c
1264 @@ -938,8 +938,11 @@ err_pm_dis:
1265 static int zynq_gpio_remove(struct platform_device *pdev)
1266 {
1267 struct zynq_gpio *gpio = platform_get_drvdata(pdev);
1268 + int ret;
1269
1270 - pm_runtime_get_sync(&pdev->dev);
1271 + ret = pm_runtime_get_sync(&pdev->dev);
1272 + if (ret < 0)
1273 + dev_warn(&pdev->dev, "pm_runtime_get_sync() Failed\n");
1274 gpiochip_remove(&gpio->chip);
1275 clk_disable_unprepare(gpio->clk);
1276 device_set_wakeup_capable(&pdev->dev, 0);
1277 diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
1278 index c9ac3dc651135..9cb8c7d13d46b 100644
1279 --- a/drivers/hwtracing/intel_th/core.c
1280 +++ b/drivers/hwtracing/intel_th/core.c
1281 @@ -215,6 +215,22 @@ static ssize_t port_show(struct device *dev, struct device_attribute *attr,
1282
1283 static DEVICE_ATTR_RO(port);
1284
1285 +static void intel_th_trace_prepare(struct intel_th_device *thdev)
1286 +{
1287 + struct intel_th_device *hub = to_intel_th_hub(thdev);
1288 + struct intel_th_driver *hubdrv = to_intel_th_driver(hub->dev.driver);
1289 +
1290 + if (hub->type != INTEL_TH_SWITCH)
1291 + return;
1292 +
1293 + if (thdev->type != INTEL_TH_OUTPUT)
1294 + return;
1295 +
1296 + pm_runtime_get_sync(&thdev->dev);
1297 + hubdrv->prepare(hub, &thdev->output);
1298 + pm_runtime_put(&thdev->dev);
1299 +}
1300 +
1301 static int intel_th_output_activate(struct intel_th_device *thdev)
1302 {
1303 struct intel_th_driver *thdrv =
1304 @@ -235,6 +251,7 @@ static int intel_th_output_activate(struct intel_th_device *thdev)
1305 if (ret)
1306 goto fail_put;
1307
1308 + intel_th_trace_prepare(thdev);
1309 if (thdrv->activate)
1310 ret = thdrv->activate(thdev);
1311 else
1312 diff --git a/drivers/hwtracing/intel_th/gth.c b/drivers/hwtracing/intel_th/gth.c
1313 index 28509b02a0b56..b3308934a687d 100644
1314 --- a/drivers/hwtracing/intel_th/gth.c
1315 +++ b/drivers/hwtracing/intel_th/gth.c
1316 @@ -564,6 +564,21 @@ static void gth_tscu_resync(struct gth_device *gth)
1317 iowrite32(reg, gth->base + REG_TSCU_TSUCTRL);
1318 }
1319
1320 +static void intel_th_gth_prepare(struct intel_th_device *thdev,
1321 + struct intel_th_output *output)
1322 +{
1323 + struct gth_device *gth = dev_get_drvdata(&thdev->dev);
1324 + int count;
1325 +
1326 + /*
1327 + * Wait until the output port is in reset before we start
1328 + * programming it.
1329 + */
1330 + for (count = GTH_PLE_WAITLOOP_DEPTH;
1331 + count && !(gth_output_get(gth, output->port) & BIT(5)); count--)
1332 + cpu_relax();
1333 +}
1334 +
1335 /**
1336 * intel_th_gth_enable() - enable tracing to an output device
1337 * @thdev: GTH device
1338 @@ -815,6 +830,7 @@ static struct intel_th_driver intel_th_gth_driver = {
1339 .assign = intel_th_gth_assign,
1340 .unassign = intel_th_gth_unassign,
1341 .set_output = intel_th_gth_set_output,
1342 + .prepare = intel_th_gth_prepare,
1343 .enable = intel_th_gth_enable,
1344 .trig_switch = intel_th_gth_switch,
1345 .disable = intel_th_gth_disable,
1346 diff --git a/drivers/hwtracing/intel_th/intel_th.h b/drivers/hwtracing/intel_th/intel_th.h
1347 index 5fe694708b7a3..595615b791086 100644
1348 --- a/drivers/hwtracing/intel_th/intel_th.h
1349 +++ b/drivers/hwtracing/intel_th/intel_th.h
1350 @@ -143,6 +143,7 @@ intel_th_output_assigned(struct intel_th_device *thdev)
1351 * @remove: remove method
1352 * @assign: match a given output type device against available outputs
1353 * @unassign: deassociate an output type device from an output port
1354 + * @prepare: prepare output port for tracing
1355 * @enable: enable tracing for a given output device
1356 * @disable: disable tracing for a given output device
1357 * @irq: interrupt callback
1358 @@ -164,6 +165,8 @@ struct intel_th_driver {
1359 struct intel_th_device *othdev);
1360 void (*unassign)(struct intel_th_device *thdev,
1361 struct intel_th_device *othdev);
1362 + void (*prepare)(struct intel_th_device *thdev,
1363 + struct intel_th_output *output);
1364 void (*enable)(struct intel_th_device *thdev,
1365 struct intel_th_output *output);
1366 void (*trig_switch)(struct intel_th_device *thdev,
1367 diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
1368 index 840f59650c7c4..1b93fae58ec75 100644
1369 --- a/drivers/i2c/i2c-core-base.c
1370 +++ b/drivers/i2c/i2c-core-base.c
1371 @@ -24,6 +24,7 @@
1372 #include <linux/i2c-smbus.h>
1373 #include <linux/idr.h>
1374 #include <linux/init.h>
1375 +#include <linux/interrupt.h>
1376 #include <linux/irqflags.h>
1377 #include <linux/jump_label.h>
1378 #include <linux/kernel.h>
1379 @@ -459,6 +460,8 @@ static void i2c_device_shutdown(struct device *dev)
1380 driver = to_i2c_driver(dev->driver);
1381 if (driver->shutdown)
1382 driver->shutdown(client);
1383 + else if (client->irq > 0)
1384 + disable_irq(client->irq);
1385 }
1386
1387 static void i2c_client_dev_release(struct device *dev)
1388 diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c
1389 index 958cf8b6002ca..45e2b5b330726 100644
1390 --- a/drivers/iio/gyro/fxas21002c_core.c
1391 +++ b/drivers/iio/gyro/fxas21002c_core.c
1392 @@ -300,14 +300,7 @@ out_unlock:
1393
1394 static int fxas21002c_pm_get(struct fxas21002c_data *data)
1395 {
1396 - struct device *dev = regmap_get_device(data->regmap);
1397 - int ret;
1398 -
1399 - ret = pm_runtime_get_sync(dev);
1400 - if (ret < 0)
1401 - pm_runtime_put_noidle(dev);
1402 -
1403 - return ret;
1404 + return pm_runtime_resume_and_get(regmap_get_device(data->regmap));
1405 }
1406
1407 static int fxas21002c_pm_put(struct fxas21002c_data *data)
1408 @@ -940,7 +933,6 @@ int fxas21002c_core_probe(struct device *dev, struct regmap *regmap, int irq,
1409 pm_disable:
1410 pm_runtime_disable(dev);
1411 pm_runtime_set_suspended(dev);
1412 - pm_runtime_put_noidle(dev);
1413
1414 return ret;
1415 }
1416 @@ -954,7 +946,6 @@ void fxas21002c_core_remove(struct device *dev)
1417
1418 pm_runtime_disable(dev);
1419 pm_runtime_set_suspended(dev);
1420 - pm_runtime_put_noidle(dev);
1421 }
1422 EXPORT_SYMBOL_GPL(fxas21002c_core_remove);
1423
1424 diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c
1425 index 48685d785c1b6..087dc16c2185c 100644
1426 --- a/drivers/iio/magnetometer/bmc150_magn.c
1427 +++ b/drivers/iio/magnetometer/bmc150_magn.c
1428 @@ -263,7 +263,7 @@ static int bmc150_magn_set_power_state(struct bmc150_magn_data *data, bool on)
1429 int ret;
1430
1431 if (on) {
1432 - ret = pm_runtime_get_sync(data->dev);
1433 + ret = pm_runtime_resume_and_get(data->dev);
1434 } else {
1435 pm_runtime_mark_last_busy(data->dev);
1436 ret = pm_runtime_put_autosuspend(data->dev);
1437 @@ -272,9 +272,6 @@ static int bmc150_magn_set_power_state(struct bmc150_magn_data *data, bool on)
1438 if (ret < 0) {
1439 dev_err(data->dev,
1440 "failed to change power state to %d\n", on);
1441 - if (on)
1442 - pm_runtime_put_noidle(data->dev);
1443 -
1444 return ret;
1445 }
1446 #endif
1447 @@ -947,12 +944,14 @@ int bmc150_magn_probe(struct device *dev, struct regmap *regmap,
1448 ret = iio_device_register(indio_dev);
1449 if (ret < 0) {
1450 dev_err(dev, "unable to register iio device\n");
1451 - goto err_buffer_cleanup;
1452 + goto err_disable_runtime_pm;
1453 }
1454
1455 dev_dbg(dev, "Registered device %s\n", name);
1456 return 0;
1457
1458 +err_disable_runtime_pm:
1459 + pm_runtime_disable(dev);
1460 err_buffer_cleanup:
1461 iio_triggered_buffer_cleanup(indio_dev);
1462 err_free_irq:
1463 @@ -976,7 +975,6 @@ int bmc150_magn_remove(struct device *dev)
1464
1465 pm_runtime_disable(dev);
1466 pm_runtime_set_suspended(dev);
1467 - pm_runtime_put_noidle(dev);
1468
1469 iio_triggered_buffer_cleanup(indio_dev);
1470
1471 diff --git a/drivers/input/touchscreen/hideep.c b/drivers/input/touchscreen/hideep.c
1472 index ddad4a82a5e55..e9547ee297564 100644
1473 --- a/drivers/input/touchscreen/hideep.c
1474 +++ b/drivers/input/touchscreen/hideep.c
1475 @@ -361,13 +361,16 @@ static int hideep_enter_pgm(struct hideep_ts *ts)
1476 return -EIO;
1477 }
1478
1479 -static void hideep_nvm_unlock(struct hideep_ts *ts)
1480 +static int hideep_nvm_unlock(struct hideep_ts *ts)
1481 {
1482 u32 unmask_code;
1483 + int error;
1484
1485 hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_SFR_RPAGE);
1486 - hideep_pgm_r_reg(ts, 0x0000000C, &unmask_code);
1487 + error = hideep_pgm_r_reg(ts, 0x0000000C, &unmask_code);
1488 hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE);
1489 + if (error)
1490 + return error;
1491
1492 /* make it unprotected code */
1493 unmask_code &= ~HIDEEP_PROT_MODE;
1494 @@ -384,6 +387,8 @@ static void hideep_nvm_unlock(struct hideep_ts *ts)
1495 NVM_W_SFR(HIDEEP_NVM_MASK_OFS, ts->nvm_mask);
1496 SET_FLASH_HWCONTROL();
1497 hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE);
1498 +
1499 + return 0;
1500 }
1501
1502 static int hideep_check_status(struct hideep_ts *ts)
1503 @@ -462,7 +467,9 @@ static int hideep_program_nvm(struct hideep_ts *ts,
1504 u32 addr = 0;
1505 int error;
1506
1507 - hideep_nvm_unlock(ts);
1508 + error = hideep_nvm_unlock(ts);
1509 + if (error)
1510 + return error;
1511
1512 while (ucode_len > 0) {
1513 xfer_len = min_t(size_t, ucode_len, HIDEEP_NVM_PAGE_SIZE);
1514 diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
1515 index 7c503a6bc5854..2185ea5191c15 100644
1516 --- a/drivers/iommu/arm-smmu.c
1517 +++ b/drivers/iommu/arm-smmu.c
1518 @@ -114,7 +114,7 @@ static bool using_legacy_binding, using_generic_binding;
1519 static inline int arm_smmu_rpm_get(struct arm_smmu_device *smmu)
1520 {
1521 if (pm_runtime_enabled(smmu->dev))
1522 - return pm_runtime_get_sync(smmu->dev);
1523 + return pm_runtime_resume_and_get(smmu->dev);
1524
1525 return 0;
1526 }
1527 @@ -1231,6 +1231,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
1528 u64 phys;
1529 unsigned long va, flags;
1530 int ret, idx = cfg->cbndx;
1531 + phys_addr_t addr = 0;
1532
1533 ret = arm_smmu_rpm_get(smmu);
1534 if (ret < 0)
1535 @@ -1249,6 +1250,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
1536 dev_err(dev,
1537 "iova to phys timed out on %pad. Falling back to software table walk.\n",
1538 &iova);
1539 + arm_smmu_rpm_put(smmu);
1540 return ops->iova_to_phys(ops, iova);
1541 }
1542
1543 @@ -1257,12 +1259,14 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
1544 if (phys & CB_PAR_F) {
1545 dev_err(dev, "translation fault!\n");
1546 dev_err(dev, "PAR = 0x%llx\n", phys);
1547 - return 0;
1548 + goto out;
1549 }
1550
1551 + addr = (phys & GENMASK_ULL(39, 12)) | (iova & 0xfff);
1552 +out:
1553 arm_smmu_rpm_put(smmu);
1554
1555 - return (phys & GENMASK_ULL(39, 12)) | (iova & 0xfff);
1556 + return addr;
1557 }
1558
1559 static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
1560 diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
1561 index 0322df9dc2497..89646896a1833 100644
1562 --- a/drivers/memory/atmel-ebi.c
1563 +++ b/drivers/memory/atmel-ebi.c
1564 @@ -601,8 +601,10 @@ static int atmel_ebi_probe(struct platform_device *pdev)
1565 child);
1566
1567 ret = atmel_ebi_dev_disable(ebi, child);
1568 - if (ret)
1569 + if (ret) {
1570 + of_node_put(child);
1571 return ret;
1572 + }
1573 }
1574 }
1575
1576 diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
1577 index a2c971743ffe6..2790258346070 100644
1578 --- a/drivers/memory/fsl_ifc.c
1579 +++ b/drivers/memory/fsl_ifc.c
1580 @@ -96,7 +96,6 @@ static int fsl_ifc_ctrl_remove(struct platform_device *dev)
1581 iounmap(ctrl->gregs);
1582
1583 dev_set_drvdata(&dev->dev, NULL);
1584 - kfree(ctrl);
1585
1586 return 0;
1587 }
1588 @@ -208,7 +207,8 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
1589
1590 dev_info(&dev->dev, "Freescale Integrated Flash Controller\n");
1591
1592 - fsl_ifc_ctrl_dev = kzalloc(sizeof(*fsl_ifc_ctrl_dev), GFP_KERNEL);
1593 + fsl_ifc_ctrl_dev = devm_kzalloc(&dev->dev, sizeof(*fsl_ifc_ctrl_dev),
1594 + GFP_KERNEL);
1595 if (!fsl_ifc_ctrl_dev)
1596 return -ENOMEM;
1597
1598 @@ -218,8 +218,7 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
1599 fsl_ifc_ctrl_dev->gregs = of_iomap(dev->dev.of_node, 0);
1600 if (!fsl_ifc_ctrl_dev->gregs) {
1601 dev_err(&dev->dev, "failed to get memory region\n");
1602 - ret = -ENODEV;
1603 - goto err;
1604 + return -ENODEV;
1605 }
1606
1607 if (of_property_read_bool(dev->dev.of_node, "little-endian")) {
1608 @@ -295,6 +294,7 @@ err_irq:
1609 free_irq(fsl_ifc_ctrl_dev->irq, fsl_ifc_ctrl_dev);
1610 irq_dispose_mapping(fsl_ifc_ctrl_dev->irq);
1611 err:
1612 + iounmap(fsl_ifc_ctrl_dev->gregs);
1613 return ret;
1614 }
1615
1616 diff --git a/drivers/memory/pl353-smc.c b/drivers/memory/pl353-smc.c
1617 index b42804b1801e6..cc01979780d87 100644
1618 --- a/drivers/memory/pl353-smc.c
1619 +++ b/drivers/memory/pl353-smc.c
1620 @@ -407,6 +407,7 @@ static int pl353_smc_probe(struct amba_device *adev, const struct amba_id *id)
1621 break;
1622 }
1623 if (!match) {
1624 + err = -ENODEV;
1625 dev_err(&adev->dev, "no matching children\n");
1626 goto out_clk_disable;
1627 }
1628 diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c
1629 index 47556d2d9abe2..8ebfc7bbe4e01 100644
1630 --- a/drivers/mfd/da9052-i2c.c
1631 +++ b/drivers/mfd/da9052-i2c.c
1632 @@ -113,6 +113,7 @@ static const struct i2c_device_id da9052_i2c_id[] = {
1633 {"da9053-bc", DA9053_BC},
1634 {}
1635 };
1636 +MODULE_DEVICE_TABLE(i2c, da9052_i2c_id);
1637
1638 #ifdef CONFIG_OF
1639 static const struct of_device_id dialog_dt_ids[] = {
1640 diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
1641 index 52f38e57cdc19..1ae58c977e1b5 100644
1642 --- a/drivers/mfd/motorola-cpcap.c
1643 +++ b/drivers/mfd/motorola-cpcap.c
1644 @@ -305,6 +305,10 @@ static int cpcap_probe(struct spi_device *spi)
1645 if (ret)
1646 return ret;
1647
1648 + /* Parent SPI controller uses DMA, CPCAP and child devices do not */
1649 + spi->dev.coherent_dma_mask = 0;
1650 + spi->dev.dma_mask = &spi->dev.coherent_dma_mask;
1651 +
1652 return devm_mfd_add_devices(&spi->dev, 0, cpcap_mfd_devices,
1653 ARRAY_SIZE(cpcap_mfd_devices), NULL, 0, NULL);
1654 }
1655 diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
1656 index 61aa020199f57..cd2f45257dc16 100644
1657 --- a/drivers/mfd/stmpe-i2c.c
1658 +++ b/drivers/mfd/stmpe-i2c.c
1659 @@ -109,7 +109,7 @@ static const struct i2c_device_id stmpe_i2c_id[] = {
1660 { "stmpe2403", STMPE2403 },
1661 { }
1662 };
1663 -MODULE_DEVICE_TABLE(i2c, stmpe_id);
1664 +MODULE_DEVICE_TABLE(i2c, stmpe_i2c_id);
1665
1666 static struct i2c_driver stmpe_i2c_driver = {
1667 .driver = {
1668 diff --git a/drivers/misc/cardreader/alcor_pci.c b/drivers/misc/cardreader/alcor_pci.c
1669 index 259fe1dfec039..1fadb95b85b09 100644
1670 --- a/drivers/misc/cardreader/alcor_pci.c
1671 +++ b/drivers/misc/cardreader/alcor_pci.c
1672 @@ -133,7 +133,13 @@ static void alcor_pci_init_check_aspm(struct alcor_pci_priv *priv)
1673 u32 val32;
1674
1675 priv->pdev_cap_off = alcor_pci_find_cap_offset(priv, priv->pdev);
1676 - priv->parent_cap_off = alcor_pci_find_cap_offset(priv,
1677 + /*
1678 + * A device might be attached to root complex directly and
1679 + * priv->parent_pdev will be NULL. In this case we don't check its
1680 + * capability and disable ASPM completely.
1681 + */
1682 + if (priv->parent_pdev)
1683 + priv->parent_cap_off = alcor_pci_find_cap_offset(priv,
1684 priv->parent_pdev);
1685
1686 if ((priv->pdev_cap_off == 0) || (priv->parent_cap_off == 0)) {
1687 diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
1688 index 4edad6c445d37..dc8a06c06c637 100644
1689 --- a/drivers/misc/ibmasm/module.c
1690 +++ b/drivers/misc/ibmasm/module.c
1691 @@ -111,7 +111,7 @@ static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1692 result = ibmasm_init_remote_input_dev(sp);
1693 if (result) {
1694 dev_err(sp->dev, "Failed to initialize remote queue\n");
1695 - goto error_send_message;
1696 + goto error_init_remote;
1697 }
1698
1699 result = ibmasm_send_driver_vpd(sp);
1700 @@ -131,8 +131,9 @@ static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1701 return 0;
1702
1703 error_send_message:
1704 - disable_sp_interrupts(sp->base_address);
1705 ibmasm_free_remote_input_dev(sp);
1706 +error_init_remote:
1707 + disable_sp_interrupts(sp->base_address);
1708 free_irq(sp->irq, (void *)sp);
1709 error_request_irq:
1710 iounmap(sp->base_address);
1711 diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
1712 index f70bb81e1ed65..caf7051302725 100644
1713 --- a/drivers/net/ethernet/moxa/moxart_ether.c
1714 +++ b/drivers/net/ethernet/moxa/moxart_ether.c
1715 @@ -481,6 +481,10 @@ static int moxart_mac_probe(struct platform_device *pdev)
1716 priv->pdev = pdev;
1717
1718 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1719 + if (!res) {
1720 + ret = -EINVAL;
1721 + goto init_fail;
1722 + }
1723 ndev->base_addr = res->start;
1724 priv->base = devm_ioremap_resource(p_dev, res);
1725 if (IS_ERR(priv->base)) {
1726 diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
1727 index 5cd55f950032a..15453d6fcc232 100644
1728 --- a/drivers/net/virtio_net.c
1729 +++ b/drivers/net/virtio_net.c
1730 @@ -1504,6 +1504,8 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget)
1731 struct virtnet_info *vi = sq->vq->vdev->priv;
1732 unsigned int index = vq2txq(sq->vq);
1733 struct netdev_queue *txq;
1734 + int opaque;
1735 + bool done;
1736
1737 if (unlikely(is_xdp_raw_buffer_queue(vi, index))) {
1738 /* We don't need to enable cb for XDP */
1739 @@ -1513,10 +1515,28 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget)
1740
1741 txq = netdev_get_tx_queue(vi->dev, index);
1742 __netif_tx_lock(txq, raw_smp_processor_id());
1743 + virtqueue_disable_cb(sq->vq);
1744 free_old_xmit_skbs(sq, true);
1745 +
1746 + opaque = virtqueue_enable_cb_prepare(sq->vq);
1747 +
1748 + done = napi_complete_done(napi, 0);
1749 +
1750 + if (!done)
1751 + virtqueue_disable_cb(sq->vq);
1752 +
1753 __netif_tx_unlock(txq);
1754
1755 - virtqueue_napi_complete(napi, sq->vq, 0);
1756 + if (done) {
1757 + if (unlikely(virtqueue_poll(sq->vq, opaque))) {
1758 + if (napi_schedule_prep(napi)) {
1759 + __netif_tx_lock(txq, raw_smp_processor_id());
1760 + virtqueue_disable_cb(sq->vq);
1761 + __netif_tx_unlock(txq);
1762 + __napi_schedule(napi);
1763 + }
1764 + }
1765 + }
1766
1767 if (sq->vq->num_free >= 2 + MAX_SKB_FRAGS)
1768 netif_tx_wake_queue(txq);
1769 @@ -3282,8 +3302,11 @@ static __maybe_unused int virtnet_restore(struct virtio_device *vdev)
1770 virtnet_set_queues(vi, vi->curr_queue_pairs);
1771
1772 err = virtnet_cpu_notif_add(vi);
1773 - if (err)
1774 + if (err) {
1775 + virtnet_freeze_down(vdev);
1776 + remove_vq_common(vi);
1777 return err;
1778 + }
1779
1780 return 0;
1781 }
1782 diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
1783 index 9bfd92b6677b0..2ae846297d7ca 100644
1784 --- a/drivers/nvme/target/tcp.c
1785 +++ b/drivers/nvme/target/tcp.c
1786 @@ -1412,7 +1412,6 @@ static void nvmet_tcp_state_change(struct sock *sk)
1787 case TCP_CLOSE_WAIT:
1788 case TCP_CLOSE:
1789 /* FALLTHRU */
1790 - sk->sk_user_data = NULL;
1791 nvmet_tcp_schedule_release_queue(queue);
1792 break;
1793 default:
1794 diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
1795 index cfa3c83d6cc74..99d505a85067b 100644
1796 --- a/drivers/pci/controller/pci-tegra.c
1797 +++ b/drivers/pci/controller/pci-tegra.c
1798 @@ -2613,6 +2613,7 @@ static const struct of_device_id tegra_pcie_of_match[] = {
1799 { .compatible = "nvidia,tegra20-pcie", .data = &tegra20_pcie },
1800 { },
1801 };
1802 +MODULE_DEVICE_TABLE(of, tegra_pcie_of_match);
1803
1804 static void *tegra_pcie_ports_seq_start(struct seq_file *s, loff_t *pos)
1805 {
1806 diff --git a/drivers/pci/controller/pcie-iproc-msi.c b/drivers/pci/controller/pcie-iproc-msi.c
1807 index f40d17b285c5e..0cb2fa1e0af4f 100644
1808 --- a/drivers/pci/controller/pcie-iproc-msi.c
1809 +++ b/drivers/pci/controller/pcie-iproc-msi.c
1810 @@ -171,7 +171,7 @@ static struct irq_chip iproc_msi_irq_chip = {
1811
1812 static struct msi_domain_info iproc_msi_domain_info = {
1813 .flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
1814 - MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX,
1815 + MSI_FLAG_PCI_MSIX,
1816 .chip = &iproc_msi_irq_chip,
1817 };
1818
1819 @@ -250,20 +250,23 @@ static int iproc_msi_irq_domain_alloc(struct irq_domain *domain,
1820 struct iproc_msi *msi = domain->host_data;
1821 int hwirq, i;
1822
1823 + if (msi->nr_cpus > 1 && nr_irqs > 1)
1824 + return -EINVAL;
1825 +
1826 mutex_lock(&msi->bitmap_lock);
1827
1828 - /* Allocate 'nr_cpus' number of MSI vectors each time */
1829 - hwirq = bitmap_find_next_zero_area(msi->bitmap, msi->nr_msi_vecs, 0,
1830 - msi->nr_cpus, 0);
1831 - if (hwirq < msi->nr_msi_vecs) {
1832 - bitmap_set(msi->bitmap, hwirq, msi->nr_cpus);
1833 - } else {
1834 - mutex_unlock(&msi->bitmap_lock);
1835 - return -ENOSPC;
1836 - }
1837 + /*
1838 + * Allocate 'nr_irqs' multiplied by 'nr_cpus' number of MSI vectors
1839 + * each time
1840 + */
1841 + hwirq = bitmap_find_free_region(msi->bitmap, msi->nr_msi_vecs,
1842 + order_base_2(msi->nr_cpus * nr_irqs));
1843
1844 mutex_unlock(&msi->bitmap_lock);
1845
1846 + if (hwirq < 0)
1847 + return -ENOSPC;
1848 +
1849 for (i = 0; i < nr_irqs; i++) {
1850 irq_domain_set_info(domain, virq + i, hwirq + i,
1851 &iproc_msi_bottom_irq_chip,
1852 @@ -284,7 +287,8 @@ static void iproc_msi_irq_domain_free(struct irq_domain *domain,
1853 mutex_lock(&msi->bitmap_lock);
1854
1855 hwirq = hwirq_to_canonical_hwirq(msi, data->hwirq);
1856 - bitmap_clear(msi->bitmap, hwirq, msi->nr_cpus);
1857 + bitmap_release_region(msi->bitmap, hwirq,
1858 + order_base_2(msi->nr_cpus * nr_irqs));
1859
1860 mutex_unlock(&msi->bitmap_lock);
1861
1862 @@ -538,6 +542,9 @@ int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node)
1863 mutex_init(&msi->bitmap_lock);
1864 msi->nr_cpus = num_possible_cpus();
1865
1866 + if (msi->nr_cpus == 1)
1867 + iproc_msi_domain_info.flags |= MSI_FLAG_MULTI_PCI_MSI;
1868 +
1869 msi->nr_irqs = of_irq_count(node);
1870 if (!msi->nr_irqs) {
1871 dev_err(pcie->dev, "found no MSI GIC interrupt\n");
1872 diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
1873 index 0608aae72cccc..0153abdbbc8dd 100644
1874 --- a/drivers/pci/p2pdma.c
1875 +++ b/drivers/pci/p2pdma.c
1876 @@ -292,10 +292,41 @@ static const struct pci_p2pdma_whitelist_entry {
1877 {}
1878 };
1879
1880 +/*
1881 + * This lookup function tries to find the PCI device corresponding to a given
1882 + * host bridge.
1883 + *
1884 + * It assumes the host bridge device is the first PCI device in the
1885 + * bus->devices list and that the devfn is 00.0. These assumptions should hold
1886 + * for all the devices in the whitelist above.
1887 + *
1888 + * This function is equivalent to pci_get_slot(host->bus, 0), however it does
1889 + * not take the pci_bus_sem lock seeing __host_bridge_whitelist() must not
1890 + * sleep.
1891 + *
1892 + * For this to be safe, the caller should hold a reference to a device on the
1893 + * bridge, which should ensure the host_bridge device will not be freed
1894 + * or removed from the head of the devices list.
1895 + */
1896 +static struct pci_dev *pci_host_bridge_dev(struct pci_host_bridge *host)
1897 +{
1898 + struct pci_dev *root;
1899 +
1900 + root = list_first_entry_or_null(&host->bus->devices,
1901 + struct pci_dev, bus_list);
1902 +
1903 + if (!root)
1904 + return NULL;
1905 + if (root->devfn != PCI_DEVFN(0, 0))
1906 + return NULL;
1907 +
1908 + return root;
1909 +}
1910 +
1911 static bool __host_bridge_whitelist(struct pci_host_bridge *host,
1912 bool same_host_bridge)
1913 {
1914 - struct pci_dev *root = pci_get_slot(host->bus, PCI_DEVFN(0, 0));
1915 + struct pci_dev *root = pci_host_bridge_dev(host);
1916 const struct pci_p2pdma_whitelist_entry *entry;
1917 unsigned short vendor, device;
1918
1919 @@ -304,7 +335,6 @@ static bool __host_bridge_whitelist(struct pci_host_bridge *host,
1920
1921 vendor = root->vendor;
1922 device = root->device;
1923 - pci_dev_put(root);
1924
1925 for (entry = pci_p2pdma_whitelist; entry->vendor; entry++) {
1926 if (vendor != entry->vendor || device != entry->device)
1927 diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
1928 index a5910f9428576..9fb4ef568f405 100644
1929 --- a/drivers/pci/pci-label.c
1930 +++ b/drivers/pci/pci-label.c
1931 @@ -162,7 +162,7 @@ static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
1932 len = utf16s_to_utf8s((const wchar_t *)obj->buffer.pointer,
1933 obj->buffer.length,
1934 UTF16_LITTLE_ENDIAN,
1935 - buf, PAGE_SIZE);
1936 + buf, PAGE_SIZE - 1);
1937 buf[len] = '\n';
1938 }
1939
1940 diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c
1941 index 6a4bbb5065510..97d1f58efef40 100644
1942 --- a/drivers/power/reset/gpio-poweroff.c
1943 +++ b/drivers/power/reset/gpio-poweroff.c
1944 @@ -90,6 +90,7 @@ static const struct of_device_id of_gpio_poweroff_match[] = {
1945 { .compatible = "gpio-poweroff", },
1946 {},
1947 };
1948 +MODULE_DEVICE_TABLE(of, of_gpio_poweroff_match);
1949
1950 static struct platform_driver gpio_poweroff_driver = {
1951 .probe = gpio_poweroff_probe,
1952 diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
1953 index d6fdc10c29f0b..ffdb15278c109 100644
1954 --- a/drivers/power/supply/Kconfig
1955 +++ b/drivers/power/supply/Kconfig
1956 @@ -643,7 +643,8 @@ config BATTERY_GOLDFISH
1957
1958 config BATTERY_RT5033
1959 tristate "RT5033 fuel gauge support"
1960 - depends on MFD_RT5033
1961 + depends on I2C
1962 + select REGMAP_I2C
1963 help
1964 This adds support for battery fuel gauge in Richtek RT5033 PMIC.
1965 The fuelgauge calculates and determines the battery state of charge
1966 diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c
1967 index 8fe81259bfd96..c8a22df650364 100644
1968 --- a/drivers/power/supply/ab8500_btemp.c
1969 +++ b/drivers/power/supply/ab8500_btemp.c
1970 @@ -1120,6 +1120,7 @@ static const struct of_device_id ab8500_btemp_match[] = {
1971 { .compatible = "stericsson,ab8500-btemp", },
1972 { },
1973 };
1974 +MODULE_DEVICE_TABLE(of, ab8500_btemp_match);
1975
1976 static struct platform_driver ab8500_btemp_driver = {
1977 .probe = ab8500_btemp_probe,
1978 diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c
1979 index e51d0e72beead..28e9d4f9ab8c4 100644
1980 --- a/drivers/power/supply/ab8500_charger.c
1981 +++ b/drivers/power/supply/ab8500_charger.c
1982 @@ -407,6 +407,14 @@ disable_otp:
1983 static void ab8500_power_supply_changed(struct ab8500_charger *di,
1984 struct power_supply *psy)
1985 {
1986 + /*
1987 + * This happens if we get notifications or interrupts and
1988 + * the platform has been configured not to support one or
1989 + * other type of charging.
1990 + */
1991 + if (!psy)
1992 + return;
1993 +
1994 if (di->autopower_cfg) {
1995 if (!di->usb.charger_connected &&
1996 !di->ac.charger_connected &&
1997 @@ -433,7 +441,15 @@ static void ab8500_charger_set_usb_connected(struct ab8500_charger *di,
1998 if (!connected)
1999 di->flags.vbus_drop_end = false;
2000
2001 - sysfs_notify(&di->usb_chg.psy->dev.kobj, NULL, "present");
2002 + /*
2003 + * Sometimes the platform is configured not to support
2004 + * USB charging and no psy has been created, but we still
2005 + * will get these notifications.
2006 + */
2007 + if (di->usb_chg.psy) {
2008 + sysfs_notify(&di->usb_chg.psy->dev.kobj, NULL,
2009 + "present");
2010 + }
2011
2012 if (connected) {
2013 mutex_lock(&di->charger_attached_mutex);
2014 @@ -3617,6 +3633,7 @@ static const struct of_device_id ab8500_charger_match[] = {
2015 { .compatible = "stericsson,ab8500-charger", },
2016 { },
2017 };
2018 +MODULE_DEVICE_TABLE(of, ab8500_charger_match);
2019
2020 static struct platform_driver ab8500_charger_driver = {
2021 .probe = ab8500_charger_probe,
2022 diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c
2023 index 6fc4bc30644cd..69452fc085b99 100644
2024 --- a/drivers/power/supply/ab8500_fg.c
2025 +++ b/drivers/power/supply/ab8500_fg.c
2026 @@ -3230,6 +3230,7 @@ static const struct of_device_id ab8500_fg_match[] = {
2027 { .compatible = "stericsson,ab8500-fg", },
2028 { },
2029 };
2030 +MODULE_DEVICE_TABLE(of, ab8500_fg_match);
2031
2032 static struct platform_driver ab8500_fg_driver = {
2033 .probe = ab8500_fg_probe,
2034 diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
2035 index a21e1a2673f80..1a215b6d94471 100644
2036 --- a/drivers/power/supply/charger-manager.c
2037 +++ b/drivers/power/supply/charger-manager.c
2038 @@ -1470,6 +1470,7 @@ static const struct of_device_id charger_manager_match[] = {
2039 },
2040 {},
2041 };
2042 +MODULE_DEVICE_TABLE(of, charger_manager_match);
2043
2044 static struct charger_desc *of_cm_parse_desc(struct device *dev)
2045 {
2046 diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
2047 index 0dfad2cf13fe0..fa862f0380c41 100644
2048 --- a/drivers/power/supply/max17042_battery.c
2049 +++ b/drivers/power/supply/max17042_battery.c
2050 @@ -1076,7 +1076,7 @@ static int max17042_probe(struct i2c_client *client,
2051 }
2052
2053 if (client->irq) {
2054 - unsigned int flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
2055 + unsigned int flags = IRQF_ONESHOT;
2056
2057 /*
2058 * On ACPI systems the IRQ may be handled by ACPI-event code,
2059 diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c
2060 index d8667a9fc49b1..6609f8cb8ca01 100644
2061 --- a/drivers/power/supply/rt5033_battery.c
2062 +++ b/drivers/power/supply/rt5033_battery.c
2063 @@ -164,9 +164,16 @@ static const struct i2c_device_id rt5033_battery_id[] = {
2064 };
2065 MODULE_DEVICE_TABLE(i2c, rt5033_battery_id);
2066
2067 +static const struct of_device_id rt5033_battery_of_match[] = {
2068 + { .compatible = "richtek,rt5033-battery", },
2069 + { }
2070 +};
2071 +MODULE_DEVICE_TABLE(of, rt5033_battery_of_match);
2072 +
2073 static struct i2c_driver rt5033_battery_driver = {
2074 .driver = {
2075 .name = "rt5033-battery",
2076 + .of_match_table = rt5033_battery_of_match,
2077 },
2078 .probe = rt5033_battery_probe,
2079 .remove = rt5033_battery_remove,
2080 diff --git a/drivers/power/supply/sc2731_charger.c b/drivers/power/supply/sc2731_charger.c
2081 index 335cb857ef307..288b79836c139 100644
2082 --- a/drivers/power/supply/sc2731_charger.c
2083 +++ b/drivers/power/supply/sc2731_charger.c
2084 @@ -524,6 +524,7 @@ static const struct of_device_id sc2731_charger_of_match[] = {
2085 { .compatible = "sprd,sc2731-charger", },
2086 { }
2087 };
2088 +MODULE_DEVICE_TABLE(of, sc2731_charger_of_match);
2089
2090 static struct platform_driver sc2731_charger_driver = {
2091 .driver = {
2092 diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c
2093 index bc8f5bda5762f..5e5bcdbf2e695 100644
2094 --- a/drivers/power/supply/sc27xx_fuel_gauge.c
2095 +++ b/drivers/power/supply/sc27xx_fuel_gauge.c
2096 @@ -1215,6 +1215,7 @@ static const struct of_device_id sc27xx_fgu_of_match[] = {
2097 { .compatible = "sprd,sc2731-fgu", },
2098 { }
2099 };
2100 +MODULE_DEVICE_TABLE(of, sc27xx_fgu_of_match);
2101
2102 static struct platform_driver sc27xx_fgu_driver = {
2103 .probe = sc27xx_fgu_probe,
2104 diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
2105 index a34d95ed70b20..22c002e685b34 100644
2106 --- a/drivers/pwm/pwm-img.c
2107 +++ b/drivers/pwm/pwm-img.c
2108 @@ -156,7 +156,7 @@ static int img_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
2109 struct img_pwm_chip *pwm_chip = to_img_pwm_chip(chip);
2110 int ret;
2111
2112 - ret = pm_runtime_get_sync(chip->dev);
2113 + ret = pm_runtime_resume_and_get(chip->dev);
2114 if (ret < 0)
2115 return ret;
2116
2117 diff --git a/drivers/pwm/pwm-imx1.c b/drivers/pwm/pwm-imx1.c
2118 index f8b2c2e001a7a..c17652c40e142 100644
2119 --- a/drivers/pwm/pwm-imx1.c
2120 +++ b/drivers/pwm/pwm-imx1.c
2121 @@ -180,8 +180,6 @@ static int pwm_imx1_remove(struct platform_device *pdev)
2122 {
2123 struct pwm_imx1_chip *imx = platform_get_drvdata(pdev);
2124
2125 - pwm_imx1_clk_disable_unprepare(&imx->chip);
2126 -
2127 return pwmchip_remove(&imx->chip);
2128 }
2129
2130 diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c
2131 index 6c6b44fd3f438..2d11ac277de8d 100644
2132 --- a/drivers/pwm/pwm-spear.c
2133 +++ b/drivers/pwm/pwm-spear.c
2134 @@ -231,10 +231,6 @@ static int spear_pwm_probe(struct platform_device *pdev)
2135 static int spear_pwm_remove(struct platform_device *pdev)
2136 {
2137 struct spear_pwm_chip *pc = platform_get_drvdata(pdev);
2138 - int i;
2139 -
2140 - for (i = 0; i < NUM_PWM; i++)
2141 - pwm_disable(&pc->chip.pwms[i]);
2142
2143 /* clk was prepared in probe, hence unprepare it here */
2144 clk_unprepare(pc->clk);
2145 diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
2146 index aa12fb3ed92e3..3d55e30a68662 100644
2147 --- a/drivers/pwm/pwm-tegra.c
2148 +++ b/drivers/pwm/pwm-tegra.c
2149 @@ -232,7 +232,6 @@ static int tegra_pwm_probe(struct platform_device *pdev)
2150 static int tegra_pwm_remove(struct platform_device *pdev)
2151 {
2152 struct tegra_pwm_chip *pc = platform_get_drvdata(pdev);
2153 - unsigned int i;
2154 int err;
2155
2156 if (WARN_ON(!pc))
2157 @@ -242,18 +241,6 @@ static int tegra_pwm_remove(struct platform_device *pdev)
2158 if (err < 0)
2159 return err;
2160
2161 - for (i = 0; i < pc->chip.npwm; i++) {
2162 - struct pwm_device *pwm = &pc->chip.pwms[i];
2163 -
2164 - if (!pwm_is_enabled(pwm))
2165 - if (clk_prepare_enable(pc->clk) < 0)
2166 - continue;
2167 -
2168 - pwm_writel(pc, i, 0);
2169 -
2170 - clk_disable_unprepare(pc->clk);
2171 - }
2172 -
2173 reset_control_assert(pc->rst);
2174 clk_disable_unprepare(pc->clk);
2175
2176 diff --git a/drivers/reset/core.c b/drivers/reset/core.c
2177 index 76c0dc7f165df..688b4f6227fcb 100644
2178 --- a/drivers/reset/core.c
2179 +++ b/drivers/reset/core.c
2180 @@ -565,7 +565,10 @@ static struct reset_control *__reset_control_get_internal(
2181 if (!rstc)
2182 return ERR_PTR(-ENOMEM);
2183
2184 - try_module_get(rcdev->owner);
2185 + if (!try_module_get(rcdev->owner)) {
2186 + kfree(rstc);
2187 + return ERR_PTR(-ENODEV);
2188 + }
2189
2190 rstc->rcdev = rcdev;
2191 list_add(&rstc->list, &rcdev->reset_control_head);
2192 diff --git a/drivers/reset/reset-a10sr.c b/drivers/reset/reset-a10sr.c
2193 index 7eacc89382f8a..99b3bc8382f35 100644
2194 --- a/drivers/reset/reset-a10sr.c
2195 +++ b/drivers/reset/reset-a10sr.c
2196 @@ -118,6 +118,7 @@ static struct platform_driver a10sr_reset_driver = {
2197 .probe = a10sr_reset_probe,
2198 .driver = {
2199 .name = "altr_a10sr_reset",
2200 + .of_match_table = a10sr_reset_of_match,
2201 },
2202 };
2203 module_platform_driver(a10sr_reset_driver);
2204 diff --git a/drivers/reset/reset-brcmstb.c b/drivers/reset/reset-brcmstb.c
2205 index f213264c8567b..42c9d5241c530 100644
2206 --- a/drivers/reset/reset-brcmstb.c
2207 +++ b/drivers/reset/reset-brcmstb.c
2208 @@ -111,6 +111,7 @@ static const struct of_device_id brcmstb_reset_of_match[] = {
2209 { .compatible = "brcm,brcmstb-reset" },
2210 { /* sentinel */ }
2211 };
2212 +MODULE_DEVICE_TABLE(of, brcmstb_reset_of_match);
2213
2214 static struct platform_driver brcmstb_reset_driver = {
2215 .probe = brcmstb_reset_probe,
2216 diff --git a/drivers/rtc/proc.c b/drivers/rtc/proc.c
2217 index 73344598fc1be..cbcdbb19d848e 100644
2218 --- a/drivers/rtc/proc.c
2219 +++ b/drivers/rtc/proc.c
2220 @@ -23,8 +23,8 @@ static bool is_rtc_hctosys(struct rtc_device *rtc)
2221 int size;
2222 char name[NAME_SIZE];
2223
2224 - size = scnprintf(name, NAME_SIZE, "rtc%d", rtc->id);
2225 - if (size > NAME_SIZE)
2226 + size = snprintf(name, NAME_SIZE, "rtc%d", rtc->id);
2227 + if (size >= NAME_SIZE)
2228 return false;
2229
2230 return !strncmp(name, CONFIG_RTC_HCTOSYS_DEVICE, NAME_SIZE);
2231 diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
2232 index 3f9a6ef650fac..3c2ed6d013873 100644
2233 --- a/drivers/s390/char/sclp_vt220.c
2234 +++ b/drivers/s390/char/sclp_vt220.c
2235 @@ -35,8 +35,8 @@
2236 #define SCLP_VT220_MINOR 65
2237 #define SCLP_VT220_DRIVER_NAME "sclp_vt220"
2238 #define SCLP_VT220_DEVICE_NAME "ttysclp"
2239 -#define SCLP_VT220_CONSOLE_NAME "ttyS"
2240 -#define SCLP_VT220_CONSOLE_INDEX 1 /* console=ttyS1 */
2241 +#define SCLP_VT220_CONSOLE_NAME "ttysclp"
2242 +#define SCLP_VT220_CONSOLE_INDEX 0 /* console=ttysclp0 */
2243
2244 /* Representation of a single write request */
2245 struct sclp_vt220_request {
2246 diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
2247 index 0760d0bd8a10b..53b33f146f825 100644
2248 --- a/drivers/scsi/be2iscsi/be_main.c
2249 +++ b/drivers/scsi/be2iscsi/be_main.c
2250 @@ -416,7 +416,7 @@ static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev)
2251 "beiscsi_hba_alloc - iscsi_host_alloc failed\n");
2252 return NULL;
2253 }
2254 - shost->max_id = BE2_MAX_SESSIONS;
2255 + shost->max_id = BE2_MAX_SESSIONS - 1;
2256 shost->max_channel = 0;
2257 shost->max_cmd_len = BEISCSI_MAX_CMD_LEN;
2258 shost->max_lun = BEISCSI_NUM_MAX_LUN;
2259 @@ -5318,7 +5318,7 @@ static int beiscsi_enable_port(struct beiscsi_hba *phba)
2260 /* Re-enable UER. If different TPE occurs then it is recoverable. */
2261 beiscsi_set_uer_feature(phba);
2262
2263 - phba->shost->max_id = phba->params.cxns_per_ctrl;
2264 + phba->shost->max_id = phba->params.cxns_per_ctrl - 1;
2265 phba->shost->can_queue = phba->params.ios_per_ctrl;
2266 ret = beiscsi_init_port(phba);
2267 if (ret < 0) {
2268 @@ -5745,6 +5745,7 @@ free_hba:
2269 pci_disable_msix(phba->pcidev);
2270 pci_dev_put(phba->pcidev);
2271 iscsi_host_free(phba->shost);
2272 + pci_disable_pcie_error_reporting(pcidev);
2273 pci_set_drvdata(pcidev, NULL);
2274 disable_pci:
2275 pci_release_regions(pcidev);
2276 diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
2277 index 0b28d44d35738..949d20b72ec44 100644
2278 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
2279 +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
2280 @@ -793,7 +793,7 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
2281 return NULL;
2282 shost->dma_boundary = cnic->pcidev->dma_mask;
2283 shost->transportt = bnx2i_scsi_xport_template;
2284 - shost->max_id = ISCSI_MAX_CONNS_PER_HBA;
2285 + shost->max_id = ISCSI_MAX_CONNS_PER_HBA - 1;
2286 shost->max_channel = 0;
2287 shost->max_lun = 512;
2288 shost->max_cmd_len = 16;
2289 diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
2290 index 2cd2761bd2492..40d93fadd206c 100644
2291 --- a/drivers/scsi/cxgbi/libcxgbi.c
2292 +++ b/drivers/scsi/cxgbi/libcxgbi.c
2293 @@ -337,7 +337,7 @@ void cxgbi_hbas_remove(struct cxgbi_device *cdev)
2294 EXPORT_SYMBOL_GPL(cxgbi_hbas_remove);
2295
2296 int cxgbi_hbas_add(struct cxgbi_device *cdev, u64 max_lun,
2297 - unsigned int max_id, struct scsi_host_template *sht,
2298 + unsigned int max_conns, struct scsi_host_template *sht,
2299 struct scsi_transport_template *stt)
2300 {
2301 struct cxgbi_hba *chba;
2302 @@ -357,7 +357,7 @@ int cxgbi_hbas_add(struct cxgbi_device *cdev, u64 max_lun,
2303
2304 shost->transportt = stt;
2305 shost->max_lun = max_lun;
2306 - shost->max_id = max_id;
2307 + shost->max_id = max_conns - 1;
2308 shost->max_channel = 0;
2309 shost->max_cmd_len = 16;
2310
2311 diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
2312 index df5a3bbeba5eb..fe8a5e5c0df84 100644
2313 --- a/drivers/scsi/device_handler/scsi_dh_alua.c
2314 +++ b/drivers/scsi/device_handler/scsi_dh_alua.c
2315 @@ -508,7 +508,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
2316 struct alua_port_group *tmp_pg;
2317 int len, k, off, bufflen = ALUA_RTPG_SIZE;
2318 unsigned char *desc, *buff;
2319 - unsigned err, retval;
2320 + unsigned err;
2321 + int retval;
2322 unsigned int tpg_desc_tbl_off;
2323 unsigned char orig_transition_tmo;
2324 unsigned long flags;
2325 @@ -548,12 +549,12 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
2326 kfree(buff);
2327 return SCSI_DH_OK;
2328 }
2329 - if (!scsi_sense_valid(&sense_hdr)) {
2330 + if (retval < 0 || !scsi_sense_valid(&sense_hdr)) {
2331 sdev_printk(KERN_INFO, sdev,
2332 "%s: rtpg failed, result %d\n",
2333 ALUA_DH_NAME, retval);
2334 kfree(buff);
2335 - if (driver_byte(retval) == DRIVER_ERROR)
2336 + if (retval < 0)
2337 return SCSI_DH_DEV_TEMP_BUSY;
2338 return SCSI_DH_IO;
2339 }
2340 @@ -775,11 +776,11 @@ static unsigned alua_stpg(struct scsi_device *sdev, struct alua_port_group *pg)
2341 retval = submit_stpg(sdev, pg->group_id, &sense_hdr);
2342
2343 if (retval) {
2344 - if (!scsi_sense_valid(&sense_hdr)) {
2345 + if (retval < 0 || !scsi_sense_valid(&sense_hdr)) {
2346 sdev_printk(KERN_INFO, sdev,
2347 "%s: stpg failed, result %d",
2348 ALUA_DH_NAME, retval);
2349 - if (driver_byte(retval) == DRIVER_ERROR)
2350 + if (retval < 0)
2351 return SCSI_DH_DEV_TEMP_BUSY;
2352 } else {
2353 sdev_printk(KERN_INFO, sdev, "%s: stpg failed\n",
2354 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
2355 index 3364ae0b9bfe6..9f6534bd354bc 100644
2356 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
2357 +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
2358 @@ -1648,7 +1648,7 @@ static int interrupt_init_v1_hw(struct hisi_hba *hisi_hba)
2359 if (irq < 0) {
2360 dev_err(dev, "irq init: fail map phy interrupt %d\n",
2361 idx);
2362 - return -ENOENT;
2363 + return irq;
2364 }
2365
2366 rc = devm_request_irq(dev, irq, phy_interrupts[j], 0,
2367 @@ -1656,7 +1656,7 @@ static int interrupt_init_v1_hw(struct hisi_hba *hisi_hba)
2368 if (rc) {
2369 dev_err(dev, "irq init: could not request phy interrupt %d, rc=%d\n",
2370 irq, rc);
2371 - return -ENOENT;
2372 + return rc;
2373 }
2374 }
2375 }
2376 @@ -1667,7 +1667,7 @@ static int interrupt_init_v1_hw(struct hisi_hba *hisi_hba)
2377 if (irq < 0) {
2378 dev_err(dev, "irq init: could not map cq interrupt %d\n",
2379 idx);
2380 - return -ENOENT;
2381 + return irq;
2382 }
2383
2384 rc = devm_request_irq(dev, irq, cq_interrupt_v1_hw, 0,
2385 @@ -1675,7 +1675,7 @@ static int interrupt_init_v1_hw(struct hisi_hba *hisi_hba)
2386 if (rc) {
2387 dev_err(dev, "irq init: could not request cq interrupt %d, rc=%d\n",
2388 irq, rc);
2389 - return -ENOENT;
2390 + return rc;
2391 }
2392 }
2393
2394 @@ -1685,7 +1685,7 @@ static int interrupt_init_v1_hw(struct hisi_hba *hisi_hba)
2395 if (irq < 0) {
2396 dev_err(dev, "irq init: could not map fatal interrupt %d\n",
2397 idx);
2398 - return -ENOENT;
2399 + return irq;
2400 }
2401
2402 rc = devm_request_irq(dev, irq, fatal_interrupts[i], 0,
2403 @@ -1693,7 +1693,7 @@ static int interrupt_init_v1_hw(struct hisi_hba *hisi_hba)
2404 if (rc) {
2405 dev_err(dev, "irq init: could not request fatal interrupt %d, rc=%d\n",
2406 irq, rc);
2407 - return -ENOENT;
2408 + return rc;
2409 }
2410 }
2411
2412 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
2413 index ff36432c8fbc2..7c736e4ddafe7 100644
2414 --- a/drivers/scsi/hosts.c
2415 +++ b/drivers/scsi/hosts.c
2416 @@ -219,6 +219,9 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
2417 goto fail;
2418 }
2419
2420 + shost->cmd_per_lun = min_t(short, shost->cmd_per_lun,
2421 + shost->can_queue);
2422 +
2423 error = scsi_init_sense_cache(shost);
2424 if (error)
2425 goto fail;
2426 @@ -486,6 +489,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
2427 shost_printk(KERN_WARNING, shost,
2428 "error handler thread failed to spawn, error = %ld\n",
2429 PTR_ERR(shost->ehandler));
2430 + shost->ehandler = NULL;
2431 goto fail;
2432 }
2433
2434 diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
2435 index c5b7d18513b66..eeba6180711cd 100644
2436 --- a/drivers/scsi/libiscsi.c
2437 +++ b/drivers/scsi/libiscsi.c
2438 @@ -230,11 +230,11 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_task *task)
2439 */
2440 static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
2441 {
2442 - struct iscsi_conn *conn = task->conn;
2443 - struct iscsi_tm *tmf = &conn->tmhdr;
2444 + struct iscsi_session *session = task->conn->session;
2445 + struct iscsi_tm *tmf = &session->tmhdr;
2446 u64 hdr_lun;
2447
2448 - if (conn->tmf_state == TMF_INITIAL)
2449 + if (session->tmf_state == TMF_INITIAL)
2450 return 0;
2451
2452 if ((tmf->opcode & ISCSI_OPCODE_MASK) != ISCSI_OP_SCSI_TMFUNC)
2453 @@ -254,24 +254,19 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
2454 * Fail all SCSI cmd PDUs
2455 */
2456 if (opcode != ISCSI_OP_SCSI_DATA_OUT) {
2457 - iscsi_conn_printk(KERN_INFO, conn,
2458 - "task [op %x itt "
2459 - "0x%x/0x%x] "
2460 - "rejected.\n",
2461 - opcode, task->itt,
2462 - task->hdr_itt);
2463 + iscsi_session_printk(KERN_INFO, session,
2464 + "task [op %x itt 0x%x/0x%x] rejected.\n",
2465 + opcode, task->itt, task->hdr_itt);
2466 return -EACCES;
2467 }
2468 /*
2469 * And also all data-out PDUs in response to R2T
2470 * if fast_abort is set.
2471 */
2472 - if (conn->session->fast_abort) {
2473 - iscsi_conn_printk(KERN_INFO, conn,
2474 - "task [op %x itt "
2475 - "0x%x/0x%x] fast abort.\n",
2476 - opcode, task->itt,
2477 - task->hdr_itt);
2478 + if (session->fast_abort) {
2479 + iscsi_session_printk(KERN_INFO, session,
2480 + "task [op %x itt 0x%x/0x%x] fast abort.\n",
2481 + opcode, task->itt, task->hdr_itt);
2482 return -EACCES;
2483 }
2484 break;
2485 @@ -284,7 +279,7 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
2486 */
2487 if (opcode == ISCSI_OP_SCSI_DATA_OUT &&
2488 task->hdr_itt == tmf->rtt) {
2489 - ISCSI_DBG_SESSION(conn->session,
2490 + ISCSI_DBG_SESSION(session,
2491 "Preventing task %x/%x from sending "
2492 "data-out due to abort task in "
2493 "progress\n", task->itt,
2494 @@ -923,20 +918,21 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
2495 static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
2496 {
2497 struct iscsi_tm_rsp *tmf = (struct iscsi_tm_rsp *)hdr;
2498 + struct iscsi_session *session = conn->session;
2499
2500 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
2501 conn->tmfrsp_pdus_cnt++;
2502
2503 - if (conn->tmf_state != TMF_QUEUED)
2504 + if (session->tmf_state != TMF_QUEUED)
2505 return;
2506
2507 if (tmf->response == ISCSI_TMF_RSP_COMPLETE)
2508 - conn->tmf_state = TMF_SUCCESS;
2509 + session->tmf_state = TMF_SUCCESS;
2510 else if (tmf->response == ISCSI_TMF_RSP_NO_TASK)
2511 - conn->tmf_state = TMF_NOT_FOUND;
2512 + session->tmf_state = TMF_NOT_FOUND;
2513 else
2514 - conn->tmf_state = TMF_FAILED;
2515 - wake_up(&conn->ehwait);
2516 + session->tmf_state = TMF_FAILED;
2517 + wake_up(&session->ehwait);
2518 }
2519
2520 static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
2521 @@ -1348,7 +1344,6 @@ void iscsi_session_failure(struct iscsi_session *session,
2522 enum iscsi_err err)
2523 {
2524 struct iscsi_conn *conn;
2525 - struct device *dev;
2526
2527 spin_lock_bh(&session->frwd_lock);
2528 conn = session->leadconn;
2529 @@ -1357,10 +1352,8 @@ void iscsi_session_failure(struct iscsi_session *session,
2530 return;
2531 }
2532
2533 - dev = get_device(&conn->cls_conn->dev);
2534 + iscsi_get_conn(conn->cls_conn);
2535 spin_unlock_bh(&session->frwd_lock);
2536 - if (!dev)
2537 - return;
2538 /*
2539 * if the host is being removed bypass the connection
2540 * recovery initialization because we are going to kill
2541 @@ -1370,7 +1363,7 @@ void iscsi_session_failure(struct iscsi_session *session,
2542 iscsi_conn_error_event(conn->cls_conn, err);
2543 else
2544 iscsi_conn_failure(conn, err);
2545 - put_device(dev);
2546 + iscsi_put_conn(conn->cls_conn);
2547 }
2548 EXPORT_SYMBOL_GPL(iscsi_session_failure);
2549
2550 @@ -1787,15 +1780,14 @@ EXPORT_SYMBOL_GPL(iscsi_target_alloc);
2551
2552 static void iscsi_tmf_timedout(struct timer_list *t)
2553 {
2554 - struct iscsi_conn *conn = from_timer(conn, t, tmf_timer);
2555 - struct iscsi_session *session = conn->session;
2556 + struct iscsi_session *session = from_timer(session, t, tmf_timer);
2557
2558 spin_lock(&session->frwd_lock);
2559 - if (conn->tmf_state == TMF_QUEUED) {
2560 - conn->tmf_state = TMF_TIMEDOUT;
2561 + if (session->tmf_state == TMF_QUEUED) {
2562 + session->tmf_state = TMF_TIMEDOUT;
2563 ISCSI_DBG_EH(session, "tmf timedout\n");
2564 /* unblock eh_abort() */
2565 - wake_up(&conn->ehwait);
2566 + wake_up(&session->ehwait);
2567 }
2568 spin_unlock(&session->frwd_lock);
2569 }
2570 @@ -1818,8 +1810,8 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
2571 return -EPERM;
2572 }
2573 conn->tmfcmd_pdus_cnt++;
2574 - conn->tmf_timer.expires = timeout * HZ + jiffies;
2575 - add_timer(&conn->tmf_timer);
2576 + session->tmf_timer.expires = timeout * HZ + jiffies;
2577 + add_timer(&session->tmf_timer);
2578 ISCSI_DBG_EH(session, "tmf set timeout\n");
2579
2580 spin_unlock_bh(&session->frwd_lock);
2581 @@ -1833,12 +1825,12 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
2582 * 3) session is terminated or restarted or userspace has
2583 * given up on recovery
2584 */
2585 - wait_event_interruptible(conn->ehwait, age != session->age ||
2586 + wait_event_interruptible(session->ehwait, age != session->age ||
2587 session->state != ISCSI_STATE_LOGGED_IN ||
2588 - conn->tmf_state != TMF_QUEUED);
2589 + session->tmf_state != TMF_QUEUED);
2590 if (signal_pending(current))
2591 flush_signals(current);
2592 - del_timer_sync(&conn->tmf_timer);
2593 + del_timer_sync(&session->tmf_timer);
2594
2595 mutex_lock(&session->eh_mutex);
2596 spin_lock_bh(&session->frwd_lock);
2597 @@ -2198,17 +2190,17 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
2598 }
2599
2600 /* only have one tmf outstanding at a time */
2601 - if (conn->tmf_state != TMF_INITIAL)
2602 + if (session->tmf_state != TMF_INITIAL)
2603 goto failed;
2604 - conn->tmf_state = TMF_QUEUED;
2605 + session->tmf_state = TMF_QUEUED;
2606
2607 - hdr = &conn->tmhdr;
2608 + hdr = &session->tmhdr;
2609 iscsi_prep_abort_task_pdu(task, hdr);
2610
2611 if (iscsi_exec_task_mgmt_fn(conn, hdr, age, session->abort_timeout))
2612 goto failed;
2613
2614 - switch (conn->tmf_state) {
2615 + switch (session->tmf_state) {
2616 case TMF_SUCCESS:
2617 spin_unlock_bh(&session->frwd_lock);
2618 /*
2619 @@ -2223,7 +2215,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
2620 */
2621 spin_lock_bh(&session->frwd_lock);
2622 fail_scsi_task(task, DID_ABORT);
2623 - conn->tmf_state = TMF_INITIAL;
2624 + session->tmf_state = TMF_INITIAL;
2625 memset(hdr, 0, sizeof(*hdr));
2626 spin_unlock_bh(&session->frwd_lock);
2627 iscsi_start_tx(conn);
2628 @@ -2234,7 +2226,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
2629 goto failed_unlocked;
2630 case TMF_NOT_FOUND:
2631 if (!sc->SCp.ptr) {
2632 - conn->tmf_state = TMF_INITIAL;
2633 + session->tmf_state = TMF_INITIAL;
2634 memset(hdr, 0, sizeof(*hdr));
2635 /* task completed before tmf abort response */
2636 ISCSI_DBG_EH(session, "sc completed while abort in "
2637 @@ -2243,7 +2235,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
2638 }
2639 /* fall through */
2640 default:
2641 - conn->tmf_state = TMF_INITIAL;
2642 + session->tmf_state = TMF_INITIAL;
2643 goto failed;
2644 }
2645
2646 @@ -2300,11 +2292,11 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
2647 conn = session->leadconn;
2648
2649 /* only have one tmf outstanding at a time */
2650 - if (conn->tmf_state != TMF_INITIAL)
2651 + if (session->tmf_state != TMF_INITIAL)
2652 goto unlock;
2653 - conn->tmf_state = TMF_QUEUED;
2654 + session->tmf_state = TMF_QUEUED;
2655
2656 - hdr = &conn->tmhdr;
2657 + hdr = &session->tmhdr;
2658 iscsi_prep_lun_reset_pdu(sc, hdr);
2659
2660 if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age,
2661 @@ -2313,7 +2305,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
2662 goto unlock;
2663 }
2664
2665 - switch (conn->tmf_state) {
2666 + switch (session->tmf_state) {
2667 case TMF_SUCCESS:
2668 break;
2669 case TMF_TIMEDOUT:
2670 @@ -2321,7 +2313,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
2671 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2672 goto done;
2673 default:
2674 - conn->tmf_state = TMF_INITIAL;
2675 + session->tmf_state = TMF_INITIAL;
2676 goto unlock;
2677 }
2678
2679 @@ -2333,7 +2325,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
2680 spin_lock_bh(&session->frwd_lock);
2681 memset(hdr, 0, sizeof(*hdr));
2682 fail_scsi_tasks(conn, sc->device->lun, DID_ERROR);
2683 - conn->tmf_state = TMF_INITIAL;
2684 + session->tmf_state = TMF_INITIAL;
2685 spin_unlock_bh(&session->frwd_lock);
2686
2687 iscsi_start_tx(conn);
2688 @@ -2356,8 +2348,7 @@ void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session)
2689 spin_lock_bh(&session->frwd_lock);
2690 if (session->state != ISCSI_STATE_LOGGED_IN) {
2691 session->state = ISCSI_STATE_RECOVERY_FAILED;
2692 - if (session->leadconn)
2693 - wake_up(&session->leadconn->ehwait);
2694 + wake_up(&session->ehwait);
2695 }
2696 spin_unlock_bh(&session->frwd_lock);
2697 }
2698 @@ -2402,7 +2393,7 @@ failed:
2699 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2700
2701 ISCSI_DBG_EH(session, "wait for relogin\n");
2702 - wait_event_interruptible(conn->ehwait,
2703 + wait_event_interruptible(session->ehwait,
2704 session->state == ISCSI_STATE_TERMINATE ||
2705 session->state == ISCSI_STATE_LOGGED_IN ||
2706 session->state == ISCSI_STATE_RECOVERY_FAILED);
2707 @@ -2463,11 +2454,11 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc)
2708 conn = session->leadconn;
2709
2710 /* only have one tmf outstanding at a time */
2711 - if (conn->tmf_state != TMF_INITIAL)
2712 + if (session->tmf_state != TMF_INITIAL)
2713 goto unlock;
2714 - conn->tmf_state = TMF_QUEUED;
2715 + session->tmf_state = TMF_QUEUED;
2716
2717 - hdr = &conn->tmhdr;
2718 + hdr = &session->tmhdr;
2719 iscsi_prep_tgt_reset_pdu(sc, hdr);
2720
2721 if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age,
2722 @@ -2476,7 +2467,7 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc)
2723 goto unlock;
2724 }
2725
2726 - switch (conn->tmf_state) {
2727 + switch (session->tmf_state) {
2728 case TMF_SUCCESS:
2729 break;
2730 case TMF_TIMEDOUT:
2731 @@ -2484,7 +2475,7 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc)
2732 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2733 goto done;
2734 default:
2735 - conn->tmf_state = TMF_INITIAL;
2736 + session->tmf_state = TMF_INITIAL;
2737 goto unlock;
2738 }
2739
2740 @@ -2496,7 +2487,7 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc)
2741 spin_lock_bh(&session->frwd_lock);
2742 memset(hdr, 0, sizeof(*hdr));
2743 fail_scsi_tasks(conn, -1, DID_ERROR);
2744 - conn->tmf_state = TMF_INITIAL;
2745 + session->tmf_state = TMF_INITIAL;
2746 spin_unlock_bh(&session->frwd_lock);
2747
2748 iscsi_start_tx(conn);
2749 @@ -2801,7 +2792,10 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,
2750 session->tt = iscsit;
2751 session->dd_data = cls_session->dd_data + sizeof(*session);
2752
2753 + session->tmf_state = TMF_INITIAL;
2754 + timer_setup(&session->tmf_timer, iscsi_tmf_timedout, 0);
2755 mutex_init(&session->eh_mutex);
2756 +
2757 spin_lock_init(&session->frwd_lock);
2758 spin_lock_init(&session->back_lock);
2759
2760 @@ -2905,7 +2899,6 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
2761 conn->c_stage = ISCSI_CONN_INITIAL_STAGE;
2762 conn->id = conn_idx;
2763 conn->exp_statsn = 0;
2764 - conn->tmf_state = TMF_INITIAL;
2765
2766 timer_setup(&conn->transport_timer, iscsi_check_transport_timeouts, 0);
2767
2768 @@ -2931,8 +2924,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
2769 goto login_task_data_alloc_fail;
2770 conn->login_task->data = conn->data = data;
2771
2772 - timer_setup(&conn->tmf_timer, iscsi_tmf_timedout, 0);
2773 - init_waitqueue_head(&conn->ehwait);
2774 + init_waitqueue_head(&session->ehwait);
2775
2776 return cls_conn;
2777
2778 @@ -2967,7 +2959,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
2779 * leading connection? then give up on recovery.
2780 */
2781 session->state = ISCSI_STATE_TERMINATE;
2782 - wake_up(&conn->ehwait);
2783 + wake_up(&session->ehwait);
2784 }
2785 spin_unlock_bh(&session->frwd_lock);
2786
2787 @@ -3042,7 +3034,7 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
2788 * commands after successful recovery
2789 */
2790 conn->stop_stage = 0;
2791 - conn->tmf_state = TMF_INITIAL;
2792 + session->tmf_state = TMF_INITIAL;
2793 session->age++;
2794 if (session->age == 16)
2795 session->age = 0;
2796 @@ -3056,7 +3048,7 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
2797 spin_unlock_bh(&session->frwd_lock);
2798
2799 iscsi_unblock_session(session->cls_session);
2800 - wake_up(&conn->ehwait);
2801 + wake_up(&session->ehwait);
2802 return 0;
2803 }
2804 EXPORT_SYMBOL_GPL(iscsi_conn_start);
2805 @@ -3143,7 +3135,7 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
2806 spin_lock_bh(&session->frwd_lock);
2807 fail_scsi_tasks(conn, -1, DID_TRANSPORT_DISRUPTED);
2808 fail_mgmt_tasks(session, conn);
2809 - memset(&conn->tmhdr, 0, sizeof(conn->tmhdr));
2810 + memset(&session->tmhdr, 0, sizeof(session->tmhdr));
2811 spin_unlock_bh(&session->frwd_lock);
2812 mutex_unlock(&session->eh_mutex);
2813 }
2814 diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
2815 index 4e994a693e3f5..2040affa08874 100644
2816 --- a/drivers/scsi/lpfc/lpfc_els.c
2817 +++ b/drivers/scsi/lpfc/lpfc_els.c
2818 @@ -1179,6 +1179,15 @@ stop_rr_fcf_flogi:
2819 phba->fcf.fcf_redisc_attempted = 0; /* reset */
2820 goto out;
2821 }
2822 + } else if (vport->port_state > LPFC_FLOGI &&
2823 + vport->fc_flag & FC_PT2PT) {
2824 + /*
2825 + * In a p2p topology, it is possible that discovery has
2826 + * already progressed, and this completion can be ignored.
2827 + * Recheck the indicated topology.
2828 + */
2829 + if (!sp->cmn.fPort)
2830 + goto out;
2831 }
2832
2833 flogifail:
2834 diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
2835 index 795460eda6a59..4a7ceaa34341c 100644
2836 --- a/drivers/scsi/lpfc/lpfc_sli.c
2837 +++ b/drivers/scsi/lpfc/lpfc_sli.c
2838 @@ -7602,7 +7602,7 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
2839 "0393 Error %d during rpi post operation\n",
2840 rc);
2841 rc = -ENODEV;
2842 - goto out_destroy_queue;
2843 + goto out_free_iocblist;
2844 }
2845 lpfc_sli4_node_prep(phba);
2846
2847 @@ -7765,8 +7765,9 @@ out_io_buff_free:
2848 out_unset_queue:
2849 /* Unset all the queues set up in this routine when error out */
2850 lpfc_sli4_queue_unset(phba);
2851 -out_destroy_queue:
2852 +out_free_iocblist:
2853 lpfc_free_iocb_list(phba);
2854 +out_destroy_queue:
2855 lpfc_sli4_queue_destroy(phba);
2856 out_stop_timers:
2857 lpfc_stop_hba_timers(phba);
2858 diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
2859 index a6e788c02ff4f..3d43ac9772f7e 100644
2860 --- a/drivers/scsi/megaraid/megaraid_sas.h
2861 +++ b/drivers/scsi/megaraid/megaraid_sas.h
2862 @@ -2256,6 +2256,15 @@ enum MR_PERF_MODE {
2863 (mode) == MR_LATENCY_PERF_MODE ? "Latency" : \
2864 "Unknown")
2865
2866 +enum MEGASAS_LD_TARGET_ID_STATUS {
2867 + LD_TARGET_ID_INITIAL,
2868 + LD_TARGET_ID_ACTIVE,
2869 + LD_TARGET_ID_DELETED,
2870 +};
2871 +
2872 +#define MEGASAS_TARGET_ID(sdev) \
2873 + (((sdev->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + sdev->id)
2874 +
2875 struct megasas_instance {
2876
2877 unsigned int *reply_map;
2878 @@ -2320,6 +2329,9 @@ struct megasas_instance {
2879 struct megasas_pd_list pd_list[MEGASAS_MAX_PD];
2880 struct megasas_pd_list local_pd_list[MEGASAS_MAX_PD];
2881 u8 ld_ids[MEGASAS_MAX_LD_IDS];
2882 + u8 ld_tgtid_status[MEGASAS_MAX_LD_IDS];
2883 + u8 ld_ids_prev[MEGASAS_MAX_LD_IDS];
2884 + u8 ld_ids_from_raidmap[MEGASAS_MAX_LD_IDS];
2885 s8 init_id;
2886
2887 u16 max_num_sge;
2888 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
2889 index b9c1f722f1ded..6700d43b12ff5 100644
2890 --- a/drivers/scsi/megaraid/megaraid_sas_base.c
2891 +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
2892 @@ -127,6 +127,8 @@ static int megasas_register_aen(struct megasas_instance *instance,
2893 u32 seq_num, u32 class_locale_word);
2894 static void megasas_get_pd_info(struct megasas_instance *instance,
2895 struct scsi_device *sdev);
2896 +static void
2897 +megasas_set_ld_removed_by_fw(struct megasas_instance *instance);
2898
2899 /*
2900 * PCI ID table for all supported controllers
2901 @@ -425,6 +427,12 @@ megasas_decode_evt(struct megasas_instance *instance)
2902 (class_locale.members.locale),
2903 format_class(class_locale.members.class),
2904 evt_detail->description);
2905 +
2906 + if (megasas_dbg_lvl & LD_PD_DEBUG)
2907 + dev_info(&instance->pdev->dev,
2908 + "evt_detail.args.ld.target_id/index %d/%d\n",
2909 + evt_detail->args.ld.target_id, evt_detail->args.ld.ld_index);
2910 +
2911 }
2912
2913 /**
2914 @@ -1759,6 +1767,7 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
2915 {
2916 struct megasas_instance *instance;
2917 struct MR_PRIV_DEVICE *mr_device_priv_data;
2918 + u32 ld_tgt_id;
2919
2920 instance = (struct megasas_instance *)
2921 scmd->device->host->hostdata;
2922 @@ -1785,17 +1794,21 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
2923 }
2924 }
2925
2926 - if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
2927 + mr_device_priv_data = scmd->device->hostdata;
2928 + if (!mr_device_priv_data ||
2929 + (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR)) {
2930 scmd->result = DID_NO_CONNECT << 16;
2931 scmd->scsi_done(scmd);
2932 return 0;
2933 }
2934
2935 - mr_device_priv_data = scmd->device->hostdata;
2936 - if (!mr_device_priv_data) {
2937 - scmd->result = DID_NO_CONNECT << 16;
2938 - scmd->scsi_done(scmd);
2939 - return 0;
2940 + if (MEGASAS_IS_LOGICAL(scmd->device)) {
2941 + ld_tgt_id = MEGASAS_TARGET_ID(scmd->device);
2942 + if (instance->ld_tgtid_status[ld_tgt_id] == LD_TARGET_ID_DELETED) {
2943 + scmd->result = DID_NO_CONNECT << 16;
2944 + scmd->scsi_done(scmd);
2945 + return 0;
2946 + }
2947 }
2948
2949 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL)
2950 @@ -2071,7 +2084,7 @@ static int megasas_slave_configure(struct scsi_device *sdev)
2951
2952 static int megasas_slave_alloc(struct scsi_device *sdev)
2953 {
2954 - u16 pd_index = 0;
2955 + u16 pd_index = 0, ld_tgt_id;
2956 struct megasas_instance *instance ;
2957 struct MR_PRIV_DEVICE *mr_device_priv_data;
2958
2959 @@ -2096,6 +2109,14 @@ scan_target:
2960 GFP_KERNEL);
2961 if (!mr_device_priv_data)
2962 return -ENOMEM;
2963 +
2964 + if (MEGASAS_IS_LOGICAL(sdev)) {
2965 + ld_tgt_id = MEGASAS_TARGET_ID(sdev);
2966 + instance->ld_tgtid_status[ld_tgt_id] = LD_TARGET_ID_ACTIVE;
2967 + if (megasas_dbg_lvl & LD_PD_DEBUG)
2968 + sdev_printk(KERN_INFO, sdev, "LD target ID %d created.\n", ld_tgt_id);
2969 + }
2970 +
2971 sdev->hostdata = mr_device_priv_data;
2972
2973 atomic_set(&mr_device_priv_data->r1_ldio_hint,
2974 @@ -2105,6 +2126,19 @@ scan_target:
2975
2976 static void megasas_slave_destroy(struct scsi_device *sdev)
2977 {
2978 + u16 ld_tgt_id;
2979 + struct megasas_instance *instance;
2980 +
2981 + instance = megasas_lookup_instance(sdev->host->host_no);
2982 +
2983 + if (MEGASAS_IS_LOGICAL(sdev)) {
2984 + ld_tgt_id = MEGASAS_TARGET_ID(sdev);
2985 + instance->ld_tgtid_status[ld_tgt_id] = LD_TARGET_ID_DELETED;
2986 + if (megasas_dbg_lvl & LD_PD_DEBUG)
2987 + sdev_printk(KERN_INFO, sdev,
2988 + "LD target ID %d removed from OS stack\n", ld_tgt_id);
2989 + }
2990 +
2991 kfree(sdev->hostdata);
2992 sdev->hostdata = NULL;
2993 }
2994 @@ -3456,6 +3490,22 @@ megasas_complete_abort(struct megasas_instance *instance,
2995 }
2996 }
2997
2998 +static void
2999 +megasas_set_ld_removed_by_fw(struct megasas_instance *instance)
3000 +{
3001 + uint i;
3002 +
3003 + for (i = 0; (i < MEGASAS_MAX_LD_IDS); i++) {
3004 + if (instance->ld_ids_prev[i] != 0xff &&
3005 + instance->ld_ids_from_raidmap[i] == 0xff) {
3006 + if (megasas_dbg_lvl & LD_PD_DEBUG)
3007 + dev_info(&instance->pdev->dev,
3008 + "LD target ID %d removed from RAID map\n", i);
3009 + instance->ld_tgtid_status[i] = LD_TARGET_ID_DELETED;
3010 + }
3011 + }
3012 +}
3013 +
3014 /**
3015 * megasas_complete_cmd - Completes a command
3016 * @instance: Adapter soft state
3017 @@ -3618,9 +3668,13 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
3018 fusion->fast_path_io = 0;
3019 }
3020
3021 + if (instance->adapter_type >= INVADER_SERIES)
3022 + megasas_set_ld_removed_by_fw(instance);
3023 +
3024 megasas_sync_map_info(instance);
3025 spin_unlock_irqrestore(instance->host->host_lock,
3026 flags);
3027 +
3028 break;
3029 }
3030 if (opcode == MR_DCMD_CTRL_EVENT_GET_INFO ||
3031 @@ -7415,11 +7469,16 @@ static int megasas_probe_one(struct pci_dev *pdev,
3032 return 0;
3033
3034 fail_start_aen:
3035 + instance->unload = 1;
3036 + scsi_remove_host(instance->host);
3037 fail_io_attach:
3038 megasas_mgmt_info.count--;
3039 megasas_mgmt_info.max_index--;
3040 megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL;
3041
3042 + if (instance->requestorId && !instance->skip_heartbeat_timer_del)
3043 + del_timer_sync(&instance->sriov_heartbeat_timer);
3044 +
3045 instance->instancet->disable_intr(instance);
3046 megasas_destroy_irqs(instance);
3047
3048 @@ -7427,8 +7486,16 @@ fail_io_attach:
3049 megasas_release_fusion(instance);
3050 else
3051 megasas_release_mfi(instance);
3052 +
3053 if (instance->msix_vectors)
3054 pci_free_irq_vectors(instance->pdev);
3055 + instance->msix_vectors = 0;
3056 +
3057 + if (instance->fw_crash_state != UNAVAILABLE)
3058 + megasas_free_host_crash_buffer(instance);
3059 +
3060 + if (instance->adapter_type != MFI_SERIES)
3061 + megasas_fusion_stop_watchdog(instance);
3062 fail_init_mfi:
3063 scsi_host_put(host);
3064 fail_alloc_instance:
3065 @@ -8698,8 +8765,10 @@ megasas_aen_polling(struct work_struct *work)
3066 union megasas_evt_class_locale class_locale;
3067 int event_type = 0;
3068 u32 seq_num;
3069 + u16 ld_target_id;
3070 int error;
3071 u8 dcmd_ret = DCMD_SUCCESS;
3072 + struct scsi_device *sdev1;
3073
3074 if (!instance) {
3075 printk(KERN_ERR "invalid instance!\n");
3076 @@ -8722,12 +8791,23 @@ megasas_aen_polling(struct work_struct *work)
3077 break;
3078
3079 case MR_EVT_LD_OFFLINE:
3080 - case MR_EVT_CFG_CLEARED:
3081 case MR_EVT_LD_DELETED:
3082 + ld_target_id = instance->evt_detail->args.ld.target_id;
3083 + sdev1 = scsi_device_lookup(instance->host,
3084 + MEGASAS_MAX_PD_CHANNELS +
3085 + (ld_target_id / MEGASAS_MAX_DEV_PER_CHANNEL),
3086 + (ld_target_id - MEGASAS_MAX_DEV_PER_CHANNEL),
3087 + 0);
3088 + if (sdev1)
3089 + megasas_remove_scsi_device(sdev1);
3090 +
3091 + event_type = SCAN_VD_CHANNEL;
3092 + break;
3093 case MR_EVT_LD_CREATED:
3094 event_type = SCAN_VD_CHANNEL;
3095 break;
3096
3097 + case MR_EVT_CFG_CLEARED:
3098 case MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED:
3099 case MR_EVT_FOREIGN_CFG_IMPORTED:
3100 case MR_EVT_LD_STATE_CHANGE:
3101 diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
3102 index 50b8c1b127671..8bfb46dbbed3a 100644
3103 --- a/drivers/scsi/megaraid/megaraid_sas_fp.c
3104 +++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
3105 @@ -350,6 +350,10 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance, u64 map_id)
3106
3107 num_lds = le16_to_cpu(drv_map->raidMap.ldCount);
3108
3109 + memcpy(instance->ld_ids_prev,
3110 + instance->ld_ids_from_raidmap,
3111 + sizeof(instance->ld_ids_from_raidmap));
3112 + memset(instance->ld_ids_from_raidmap, 0xff, MEGASAS_MAX_LD_IDS);
3113 /*Convert Raid capability values to CPU arch */
3114 for (i = 0; (num_lds > 0) && (i < MAX_LOGICAL_DRIVES_EXT); i++) {
3115 ld = MR_TargetIdToLdGet(i, drv_map);
3116 @@ -360,7 +364,7 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance, u64 map_id)
3117
3118 raid = MR_LdRaidGet(ld, drv_map);
3119 le32_to_cpus((u32 *)&raid->capability);
3120 -
3121 + instance->ld_ids_from_raidmap[i] = i;
3122 num_lds--;
3123 }
3124
3125 diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
3126 index 5dcd7b9b72ced..a78a702511faa 100644
3127 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
3128 +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
3129 @@ -3716,6 +3716,7 @@ static void megasas_sync_irqs(unsigned long instance_addr)
3130 if (irq_ctx->irq_poll_scheduled) {
3131 irq_ctx->irq_poll_scheduled = false;
3132 enable_irq(irq_ctx->os_irq);
3133 + complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx);
3134 }
3135 }
3136 }
3137 @@ -3747,6 +3748,7 @@ int megasas_irqpoll(struct irq_poll *irqpoll, int budget)
3138 irq_poll_complete(irqpoll);
3139 irq_ctx->irq_poll_scheduled = false;
3140 enable_irq(irq_ctx->os_irq);
3141 + complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx);
3142 }
3143
3144 return num_entries;
3145 @@ -3763,6 +3765,7 @@ megasas_complete_cmd_dpc_fusion(unsigned long instance_addr)
3146 {
3147 struct megasas_instance *instance =
3148 (struct megasas_instance *)instance_addr;
3149 + struct megasas_irq_context *irq_ctx = NULL;
3150 u32 count, MSIxIndex;
3151
3152 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1;
3153 @@ -3771,8 +3774,10 @@ megasas_complete_cmd_dpc_fusion(unsigned long instance_addr)
3154 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR)
3155 return;
3156
3157 - for (MSIxIndex = 0 ; MSIxIndex < count; MSIxIndex++)
3158 - complete_cmd_fusion(instance, MSIxIndex, NULL);
3159 + for (MSIxIndex = 0 ; MSIxIndex < count; MSIxIndex++) {
3160 + irq_ctx = &instance->irq_context[MSIxIndex];
3161 + complete_cmd_fusion(instance, MSIxIndex, irq_ctx);
3162 + }
3163 }
3164
3165 /**
3166 @@ -5177,6 +5182,7 @@ megasas_alloc_fusion_context(struct megasas_instance *instance)
3167 if (!fusion->log_to_span) {
3168 dev_err(&instance->pdev->dev, "Failed from %s %d\n",
3169 __func__, __LINE__);
3170 + kfree(instance->ctrl_context);
3171 return -ENOMEM;
3172 }
3173 }
3174 diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c
3175 index 90aa64604ad78..37b8f08d5020f 100644
3176 --- a/drivers/scsi/qedi/qedi_fw.c
3177 +++ b/drivers/scsi/qedi/qedi_fw.c
3178 @@ -1451,7 +1451,7 @@ abort_ret:
3179
3180 ldel_exit:
3181 spin_lock_bh(&qedi_conn->tmf_work_lock);
3182 - if (!qedi_cmd->list_tmf_work) {
3183 + if (qedi_cmd->list_tmf_work) {
3184 list_del_init(&list_work->list);
3185 qedi_cmd->list_tmf_work = NULL;
3186 kfree(list_work);
3187 diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
3188 index 4498add3d4d66..1ec42c5f0b2a0 100644
3189 --- a/drivers/scsi/qedi/qedi_main.c
3190 +++ b/drivers/scsi/qedi/qedi_main.c
3191 @@ -631,7 +631,7 @@ static struct qedi_ctx *qedi_host_alloc(struct pci_dev *pdev)
3192 goto exit_setup_shost;
3193 }
3194
3195 - shost->max_id = QEDI_MAX_ISCSI_CONNS_PER_HBA;
3196 + shost->max_id = QEDI_MAX_ISCSI_CONNS_PER_HBA - 1;
3197 shost->max_channel = 0;
3198 shost->max_lun = ~0;
3199 shost->max_cmd_len = 16;
3200 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
3201 index a26df7d6d5d18..2f1553d0a10ed 100644
3202 --- a/drivers/scsi/scsi_transport_iscsi.c
3203 +++ b/drivers/scsi/scsi_transport_iscsi.c
3204 @@ -2308,6 +2308,18 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn)
3205 }
3206 EXPORT_SYMBOL_GPL(iscsi_destroy_conn);
3207
3208 +void iscsi_put_conn(struct iscsi_cls_conn *conn)
3209 +{
3210 + put_device(&conn->dev);
3211 +}
3212 +EXPORT_SYMBOL_GPL(iscsi_put_conn);
3213 +
3214 +void iscsi_get_conn(struct iscsi_cls_conn *conn)
3215 +{
3216 + get_device(&conn->dev);
3217 +}
3218 +EXPORT_SYMBOL_GPL(iscsi_get_conn);
3219 +
3220 /*
3221 * iscsi interface functions
3222 */
3223 diff --git a/drivers/staging/rtl8723bs/hal/odm.h b/drivers/staging/rtl8723bs/hal/odm.h
3224 index fba3b9e1491b4..ee867621aed9f 100644
3225 --- a/drivers/staging/rtl8723bs/hal/odm.h
3226 +++ b/drivers/staging/rtl8723bs/hal/odm.h
3227 @@ -197,10 +197,7 @@ typedef struct _ODM_RATE_ADAPTIVE {
3228
3229 #define AVG_THERMAL_NUM 8
3230 #define IQK_Matrix_REG_NUM 8
3231 -#define IQK_Matrix_Settings_NUM (14 + 24 + 21) /* Channels_2_4G_NUM
3232 - * + Channels_5G_20M_NUM
3233 - * + Channels_5G
3234 - */
3235 +#define IQK_Matrix_Settings_NUM 14 /* Channels_2_4G_NUM */
3236
3237 #define DM_Type_ByFW 0
3238 #define DM_Type_ByDriver 1
3239 diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
3240 index 1ab2ffff4e7c7..a0673059bd4ae 100644
3241 --- a/drivers/thermal/rcar_gen3_thermal.c
3242 +++ b/drivers/thermal/rcar_gen3_thermal.c
3243 @@ -143,7 +143,7 @@ static void rcar_gen3_thermal_calc_coefs(struct rcar_gen3_thermal_tsc *tsc,
3244 * Division is not scaled in BSP and if scaled it might overflow
3245 * the dividend (4095 * 4095 << 14 > INT_MAX) so keep it unscaled
3246 */
3247 - tsc->tj_t = (FIXPT_INT((ptat[1] - ptat[2]) * 157)
3248 + tsc->tj_t = (FIXPT_INT((ptat[1] - ptat[2]) * (ths_tj_1 - TJ_3))
3249 / (ptat[0] - ptat[2])) + FIXPT_INT(TJ_3);
3250
3251 tsc->coef.a1 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[2]),
3252 diff --git a/drivers/tty/serial/8250/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c
3253 index ccd1a615305b5..a05c2b652040c 100644
3254 --- a/drivers/tty/serial/8250/serial_cs.c
3255 +++ b/drivers/tty/serial/8250/serial_cs.c
3256 @@ -306,6 +306,7 @@ static int serial_resume(struct pcmcia_device *link)
3257 static int serial_probe(struct pcmcia_device *link)
3258 {
3259 struct serial_info *info;
3260 + int ret;
3261
3262 dev_dbg(&link->dev, "serial_attach()\n");
3263
3264 @@ -320,7 +321,15 @@ static int serial_probe(struct pcmcia_device *link)
3265 if (do_sound)
3266 link->config_flags |= CONF_ENABLE_SPKR;
3267
3268 - return serial_config(link);
3269 + ret = serial_config(link);
3270 + if (ret)
3271 + goto free_info;
3272 +
3273 + return 0;
3274 +
3275 +free_info:
3276 + kfree(info);
3277 + return ret;
3278 }
3279
3280 static void serial_detach(struct pcmcia_device *link)
3281 diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
3282 index 6ad985e8dc653..b053345dfd1ae 100644
3283 --- a/drivers/tty/serial/fsl_lpuart.c
3284 +++ b/drivers/tty/serial/fsl_lpuart.c
3285 @@ -2253,6 +2253,9 @@ lpuart32_console_get_options(struct lpuart_port *sport, int *baud,
3286
3287 bd = lpuart32_read(&sport->port, UARTBAUD);
3288 bd &= UARTBAUD_SBR_MASK;
3289 + if (!bd)
3290 + return;
3291 +
3292 sbr = bd;
3293 uartclk = lpuart_get_baud_clk_rate(sport);
3294 /*
3295 diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
3296 index 06e79c11141d4..56066d93a65b8 100644
3297 --- a/drivers/tty/serial/uartlite.c
3298 +++ b/drivers/tty/serial/uartlite.c
3299 @@ -508,21 +508,23 @@ static void ulite_console_write(struct console *co, const char *s,
3300
3301 static int ulite_console_setup(struct console *co, char *options)
3302 {
3303 - struct uart_port *port;
3304 + struct uart_port *port = NULL;
3305 int baud = 9600;
3306 int bits = 8;
3307 int parity = 'n';
3308 int flow = 'n';
3309
3310 -
3311 - port = console_port;
3312 + if (co->index >= 0 && co->index < ULITE_NR_UARTS)
3313 + port = ulite_ports + co->index;
3314
3315 /* Has the device been initialized yet? */
3316 - if (!port->mapbase) {
3317 + if (!port || !port->mapbase) {
3318 pr_debug("console on ttyUL%i not present\n", co->index);
3319 return -ENODEV;
3320 }
3321
3322 + console_port = port;
3323 +
3324 /* not initialized yet? */
3325 if (!port->membase) {
3326 if (ulite_request_port(port))
3327 @@ -658,17 +660,6 @@ static int ulite_assign(struct device *dev, int id, u32 base, int irq,
3328
3329 dev_set_drvdata(dev, port);
3330
3331 -#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
3332 - /*
3333 - * If console hasn't been found yet try to assign this port
3334 - * because it is required to be assigned for console setup function.
3335 - * If register_console() don't assign value, then console_port pointer
3336 - * is cleanup.
3337 - */
3338 - if (ulite_uart_driver.cons->index == -1)
3339 - console_port = port;
3340 -#endif
3341 -
3342 /* Register the port */
3343 rc = uart_add_one_port(&ulite_uart_driver, port);
3344 if (rc) {
3345 @@ -678,12 +669,6 @@ static int ulite_assign(struct device *dev, int id, u32 base, int irq,
3346 return rc;
3347 }
3348
3349 -#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
3350 - /* This is not port which is used for console that's why clean it up */
3351 - if (ulite_uart_driver.cons->index == -1)
3352 - console_port = NULL;
3353 -#endif
3354 -
3355 return 0;
3356 }
3357
3358 diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
3359 index 0586229ac83de..3d540b0d93687 100644
3360 --- a/drivers/usb/gadget/function/f_hid.c
3361 +++ b/drivers/usb/gadget/function/f_hid.c
3362 @@ -88,7 +88,7 @@ static struct usb_interface_descriptor hidg_interface_desc = {
3363 static struct hid_descriptor hidg_desc = {
3364 .bLength = sizeof hidg_desc,
3365 .bDescriptorType = HID_DT_HID,
3366 - .bcdHID = 0x0101,
3367 + .bcdHID = cpu_to_le16(0x0101),
3368 .bCountryCode = 0x00,
3369 .bNumDescriptors = 0x1,
3370 /*.desc[0].bDescriptorType = DYNAMIC */
3371 diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
3372 index c4eda7fe7ab45..5b27d289443fe 100644
3373 --- a/drivers/usb/gadget/legacy/hid.c
3374 +++ b/drivers/usb/gadget/legacy/hid.c
3375 @@ -171,8 +171,10 @@ static int hid_bind(struct usb_composite_dev *cdev)
3376 struct usb_descriptor_header *usb_desc;
3377
3378 usb_desc = usb_otg_descriptor_alloc(gadget);
3379 - if (!usb_desc)
3380 + if (!usb_desc) {
3381 + status = -ENOMEM;
3382 goto put;
3383 + }
3384 usb_otg_descriptor_init(gadget, usb_desc);
3385 otg_desc[0] = usb_desc;
3386 otg_desc[1] = NULL;
3387 diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c
3388 index f03ffe2bb2376..8096202fbe5d5 100644
3389 --- a/drivers/video/backlight/lm3630a_bl.c
3390 +++ b/drivers/video/backlight/lm3630a_bl.c
3391 @@ -188,7 +188,7 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
3392 if ((pwm_ctrl & LM3630A_PWM_BANK_A) != 0) {
3393 lm3630a_pwm_ctrl(pchip, bl->props.brightness,
3394 bl->props.max_brightness);
3395 - return bl->props.brightness;
3396 + return 0;
3397 }
3398
3399 /* disable sleep */
3400 @@ -208,8 +208,8 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
3401 return 0;
3402
3403 out_i2c_err:
3404 - dev_err(pchip->dev, "i2c failed to access\n");
3405 - return bl->props.brightness;
3406 + dev_err(pchip->dev, "i2c failed to access (%pe)\n", ERR_PTR(ret));
3407 + return ret;
3408 }
3409
3410 static int lm3630a_bank_a_get_brightness(struct backlight_device *bl)
3411 @@ -265,7 +265,7 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl)
3412 if ((pwm_ctrl & LM3630A_PWM_BANK_B) != 0) {
3413 lm3630a_pwm_ctrl(pchip, bl->props.brightness,
3414 bl->props.max_brightness);
3415 - return bl->props.brightness;
3416 + return 0;
3417 }
3418
3419 /* disable sleep */
3420 @@ -285,8 +285,8 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl)
3421 return 0;
3422
3423 out_i2c_err:
3424 - dev_err(pchip->dev, "i2c failed to access REG_CTRL\n");
3425 - return bl->props.brightness;
3426 + dev_err(pchip->dev, "i2c failed to access (%pe)\n", ERR_PTR(ret));
3427 + return ret;
3428 }
3429
3430 static int lm3630a_bank_b_get_brightness(struct backlight_device *bl)
3431 diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
3432 index bf76dadbed87f..d87de5d467189 100644
3433 --- a/drivers/video/fbdev/core/fbmem.c
3434 +++ b/drivers/video/fbdev/core/fbmem.c
3435 @@ -965,13 +965,11 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
3436 fb_var_to_videomode(&mode2, &info->var);
3437 /* make sure we don't delete the videomode of current var */
3438 ret = fb_mode_is_equal(&mode1, &mode2);
3439 -
3440 - if (!ret)
3441 - fbcon_mode_deleted(info, &mode1);
3442 -
3443 - if (!ret)
3444 - fb_delete_videomode(&mode1, &info->modelist);
3445 -
3446 + if (!ret) {
3447 + ret = fbcon_mode_deleted(info, &mode1);
3448 + if (!ret)
3449 + fb_delete_videomode(&mode1, &info->modelist);
3450 + }
3451
3452 return ret ? -EINVAL : 0;
3453 }
3454 diff --git a/drivers/w1/slaves/w1_ds2438.c b/drivers/w1/slaves/w1_ds2438.c
3455 index d199e5a25cc00..404dacb150046 100644
3456 --- a/drivers/w1/slaves/w1_ds2438.c
3457 +++ b/drivers/w1/slaves/w1_ds2438.c
3458 @@ -62,13 +62,13 @@ static int w1_ds2438_get_page(struct w1_slave *sl, int pageno, u8 *buf)
3459 if (w1_reset_select_slave(sl))
3460 continue;
3461 w1_buf[0] = W1_DS2438_RECALL_MEMORY;
3462 - w1_buf[1] = 0x00;
3463 + w1_buf[1] = (u8)pageno;
3464 w1_write_block(sl->master, w1_buf, 2);
3465
3466 if (w1_reset_select_slave(sl))
3467 continue;
3468 w1_buf[0] = W1_DS2438_READ_SCRATCH;
3469 - w1_buf[1] = 0x00;
3470 + w1_buf[1] = (u8)pageno;
3471 w1_write_block(sl->master, w1_buf, 2);
3472
3473 count = w1_read_block(sl->master, buf, DS2438_PAGE_SIZE + 1);
3474 diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
3475 index 7e00960651fa2..507fd815d7679 100644
3476 --- a/drivers/watchdog/aspeed_wdt.c
3477 +++ b/drivers/watchdog/aspeed_wdt.c
3478 @@ -147,7 +147,7 @@ static int aspeed_wdt_set_timeout(struct watchdog_device *wdd,
3479
3480 wdd->timeout = timeout;
3481
3482 - actual = min(timeout, wdd->max_hw_heartbeat_ms * 1000);
3483 + actual = min(timeout, wdd->max_hw_heartbeat_ms / 1000);
3484
3485 writel(actual * WDT_RATE_1MHZ, wdt->base + WDT_RELOAD_VALUE);
3486 writel(WDT_RESTART_MAGIC, wdt->base + WDT_RESTART);
3487 diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
3488 index e707c4797f76e..08e534fba1bf0 100644
3489 --- a/drivers/watchdog/iTCO_wdt.c
3490 +++ b/drivers/watchdog/iTCO_wdt.c
3491 @@ -72,6 +72,8 @@
3492 #define TCOBASE(p) ((p)->tco_res->start)
3493 /* SMI Control and Enable Register */
3494 #define SMI_EN(p) ((p)->smi_res->start)
3495 +#define TCO_EN (1 << 13)
3496 +#define GBL_SMI_EN (1 << 0)
3497
3498 #define TCO_RLD(p) (TCOBASE(p) + 0x00) /* TCO Timer Reload/Curr. Value */
3499 #define TCOv1_TMR(p) (TCOBASE(p) + 0x01) /* TCOv1 Timer Initial Value*/
3500 @@ -344,8 +346,12 @@ static int iTCO_wdt_set_timeout(struct watchdog_device *wd_dev, unsigned int t)
3501
3502 tmrval = seconds_to_ticks(p, t);
3503
3504 - /* For TCO v1 the timer counts down twice before rebooting */
3505 - if (p->iTCO_version == 1)
3506 + /*
3507 + * If TCO SMIs are off, the timer counts down twice before rebooting.
3508 + * Otherwise, the BIOS generally reboots when the SMI triggers.
3509 + */
3510 + if (p->smi_res &&
3511 + (SMI_EN(p) & (TCO_EN | GBL_SMI_EN)) != (TCO_EN | GBL_SMI_EN))
3512 tmrval /= 2;
3513
3514 /* from the specs: */
3515 @@ -510,7 +516,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
3516 * Disables TCO logic generating an SMI#
3517 */
3518 val32 = inl(SMI_EN(p));
3519 - val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
3520 + val32 &= ~TCO_EN; /* Turn off SMI clearing watchdog */
3521 outl(val32, SMI_EN(p));
3522 }
3523
3524 diff --git a/drivers/watchdog/imx_sc_wdt.c b/drivers/watchdog/imx_sc_wdt.c
3525 index e0e62149a6f48..8c9936e78bee0 100644
3526 --- a/drivers/watchdog/imx_sc_wdt.c
3527 +++ b/drivers/watchdog/imx_sc_wdt.c
3528 @@ -185,16 +185,12 @@ static int imx_sc_wdt_probe(struct platform_device *pdev)
3529 watchdog_stop_on_reboot(wdog);
3530 watchdog_stop_on_unregister(wdog);
3531
3532 - ret = devm_watchdog_register_device(dev, wdog);
3533 - if (ret)
3534 - return ret;
3535 -
3536 ret = imx_scu_irq_group_enable(SC_IRQ_GROUP_WDOG,
3537 SC_IRQ_WDOG,
3538 true);
3539 if (ret) {
3540 dev_warn(dev, "Enable irq failed, pretimeout NOT supported\n");
3541 - return 0;
3542 + goto register_device;
3543 }
3544
3545 imx_sc_wdd->wdt_notifier.notifier_call = imx_sc_wdt_notify;
3546 @@ -205,7 +201,7 @@ static int imx_sc_wdt_probe(struct platform_device *pdev)
3547 false);
3548 dev_warn(dev,
3549 "Register irq notifier failed, pretimeout NOT supported\n");
3550 - return 0;
3551 + goto register_device;
3552 }
3553
3554 ret = devm_add_action_or_reset(dev, imx_sc_wdt_action,
3555 @@ -215,7 +211,8 @@ static int imx_sc_wdt_probe(struct platform_device *pdev)
3556 else
3557 dev_warn(dev, "Add action failed, pretimeout NOT supported\n");
3558
3559 - return 0;
3560 +register_device:
3561 + return devm_watchdog_register_device(dev, wdog);
3562 }
3563
3564 static int __maybe_unused imx_sc_wdt_suspend(struct device *dev)
3565 diff --git a/drivers/watchdog/lpc18xx_wdt.c b/drivers/watchdog/lpc18xx_wdt.c
3566 index 78cf11c949416..60b6d74f267dd 100644
3567 --- a/drivers/watchdog/lpc18xx_wdt.c
3568 +++ b/drivers/watchdog/lpc18xx_wdt.c
3569 @@ -292,7 +292,7 @@ static int lpc18xx_wdt_remove(struct platform_device *pdev)
3570 struct lpc18xx_wdt_dev *lpc18xx_wdt = platform_get_drvdata(pdev);
3571
3572 dev_warn(&pdev->dev, "I quit now, hardware will probably reboot!\n");
3573 - del_timer(&lpc18xx_wdt->timer);
3574 + del_timer_sync(&lpc18xx_wdt->timer);
3575
3576 return 0;
3577 }
3578 diff --git a/drivers/watchdog/sbc60xxwdt.c b/drivers/watchdog/sbc60xxwdt.c
3579 index c3151642694c9..de1f7add05c3d 100644
3580 --- a/drivers/watchdog/sbc60xxwdt.c
3581 +++ b/drivers/watchdog/sbc60xxwdt.c
3582 @@ -146,7 +146,7 @@ static void wdt_startup(void)
3583 static void wdt_turnoff(void)
3584 {
3585 /* Stop the timer */
3586 - del_timer(&timer);
3587 + del_timer_sync(&timer);
3588 inb_p(wdt_stop);
3589 pr_info("Watchdog timer is now disabled...\n");
3590 }
3591 diff --git a/drivers/watchdog/sc520_wdt.c b/drivers/watchdog/sc520_wdt.c
3592 index a612128c5f808..57969564c7f9d 100644
3593 --- a/drivers/watchdog/sc520_wdt.c
3594 +++ b/drivers/watchdog/sc520_wdt.c
3595 @@ -186,7 +186,7 @@ static int wdt_startup(void)
3596 static int wdt_turnoff(void)
3597 {
3598 /* Stop the timer */
3599 - del_timer(&timer);
3600 + del_timer_sync(&timer);
3601
3602 /* Stop the watchdog */
3603 wdt_config(0);
3604 diff --git a/drivers/watchdog/w83877f_wdt.c b/drivers/watchdog/w83877f_wdt.c
3605 index 6eb5185d6ea68..d9addf06b44d6 100644
3606 --- a/drivers/watchdog/w83877f_wdt.c
3607 +++ b/drivers/watchdog/w83877f_wdt.c
3608 @@ -166,7 +166,7 @@ static void wdt_startup(void)
3609 static void wdt_turnoff(void)
3610 {
3611 /* Stop the timer */
3612 - del_timer(&timer);
3613 + del_timer_sync(&timer);
3614
3615 wdt_change(WDT_DISABLE);
3616
3617 diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
3618 index a02e845eb0fbf..34ab7b892b700 100644
3619 --- a/fs/ceph/addr.c
3620 +++ b/fs/ceph/addr.c
3621 @@ -76,10 +76,6 @@ static int ceph_set_page_dirty(struct page *page)
3622 struct inode *inode;
3623 struct ceph_inode_info *ci;
3624 struct ceph_snap_context *snapc;
3625 - int ret;
3626 -
3627 - if (unlikely(!mapping))
3628 - return !TestSetPageDirty(page);
3629
3630 if (PageDirty(page)) {
3631 dout("%p set_page_dirty %p idx %lu -- already dirty\n",
3632 @@ -125,11 +121,7 @@ static int ceph_set_page_dirty(struct page *page)
3633 page->private = (unsigned long)snapc;
3634 SetPagePrivate(page);
3635
3636 - ret = __set_page_dirty_nobuffers(page);
3637 - WARN_ON(!PageLocked(page));
3638 - WARN_ON(!page->mapping);
3639 -
3640 - return ret;
3641 + return __set_page_dirty_nobuffers(page);
3642 }
3643
3644 /*
3645 diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
3646 index a9a083232bcfc..6d904dc9bd199 100644
3647 --- a/fs/f2fs/super.c
3648 +++ b/fs/f2fs/super.c
3649 @@ -3804,4 +3804,5 @@ module_exit(exit_f2fs_fs)
3650 MODULE_AUTHOR("Samsung Electronics's Praesto Team");
3651 MODULE_DESCRIPTION("Flash Friendly File System");
3652 MODULE_LICENSE("GPL");
3653 +MODULE_SOFTDEP("pre: crc32");
3654
3655 diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
3656 index 9330eff210e0c..78fd136ac13b9 100644
3657 --- a/fs/jfs/jfs_logmgr.c
3658 +++ b/fs/jfs/jfs_logmgr.c
3659 @@ -1324,6 +1324,7 @@ int lmLogInit(struct jfs_log * log)
3660 } else {
3661 if (!uuid_equal(&logsuper->uuid, &log->uuid)) {
3662 jfs_warn("wrong uuid on JFS log device");
3663 + rc = -EINVAL;
3664 goto errout20;
3665 }
3666 log->size = le32_to_cpu(logsuper->size);
3667 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
3668 index 8c0f916380c4e..209263c0c5377 100644
3669 --- a/fs/nfs/inode.c
3670 +++ b/fs/nfs/inode.c
3671 @@ -1048,6 +1048,7 @@ EXPORT_SYMBOL_GPL(nfs_inode_attach_open_context);
3672 void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx)
3673 {
3674 filp->private_data = get_nfs_open_context(ctx);
3675 + set_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags);
3676 if (list_empty(&ctx->list))
3677 nfs_inode_attach_open_context(ctx);
3678 }
3679 @@ -1067,6 +1068,8 @@ struct nfs_open_context *nfs_find_open_context(struct inode *inode, const struct
3680 continue;
3681 if ((pos->mode & (FMODE_READ|FMODE_WRITE)) != mode)
3682 continue;
3683 + if (!test_bit(NFS_CONTEXT_FILE_OPEN, &pos->flags))
3684 + continue;
3685 ctx = get_nfs_open_context(pos);
3686 if (ctx)
3687 break;
3688 @@ -1082,6 +1085,7 @@ void nfs_file_clear_open_context(struct file *filp)
3689 if (ctx) {
3690 struct inode *inode = d_inode(ctx->dentry);
3691
3692 + clear_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags);
3693 /*
3694 * We fatal error on write before. Try to writeback
3695 * every page again.
3696 diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
3697 index 9eb2f1a503ab0..01a03ca36659e 100644
3698 --- a/fs/nfs/nfs3proc.c
3699 +++ b/fs/nfs/nfs3proc.c
3700 @@ -350,7 +350,7 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
3701 break;
3702
3703 case NFS3_CREATE_UNCHECKED:
3704 - goto out;
3705 + goto out_release_acls;
3706 }
3707 nfs_fattr_init(data->res.dir_attr);
3708 nfs_fattr_init(data->res.fattr);
3709 @@ -717,7 +717,7 @@ nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
3710 break;
3711 default:
3712 status = -EINVAL;
3713 - goto out;
3714 + goto out_release_acls;
3715 }
3716
3717 d_alias = nfs3_do_create(dir, dentry, data);
3718 diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
3719 index 5a69dbd01a6cf..8cace8350fa3d 100644
3720 --- a/fs/nfs/nfs4client.c
3721 +++ b/fs/nfs/nfs4client.c
3722 @@ -197,8 +197,11 @@ void nfs40_shutdown_client(struct nfs_client *clp)
3723
3724 struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
3725 {
3726 - int err;
3727 + char buf[INET6_ADDRSTRLEN + 1];
3728 + const char *ip_addr = cl_init->ip_addr;
3729 struct nfs_client *clp = nfs_alloc_client(cl_init);
3730 + int err;
3731 +
3732 if (IS_ERR(clp))
3733 return clp;
3734
3735 @@ -222,6 +225,44 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
3736 init_waitqueue_head(&clp->cl_lock_waitq);
3737 #endif
3738 INIT_LIST_HEAD(&clp->pending_cb_stateids);
3739 +
3740 + if (cl_init->minorversion != 0)
3741 + __set_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags);
3742 + __set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
3743 + __set_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags);
3744 +
3745 + /*
3746 + * Set up the connection to the server before we add add to the
3747 + * global list.
3748 + */
3749 + err = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_GSS_KRB5I);
3750 + if (err == -EINVAL)
3751 + err = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX);
3752 + if (err < 0)
3753 + goto error;
3754 +
3755 + /* If no clientaddr= option was specified, find a usable cb address */
3756 + if (ip_addr == NULL) {
3757 + struct sockaddr_storage cb_addr;
3758 + struct sockaddr *sap = (struct sockaddr *)&cb_addr;
3759 +
3760 + err = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr));
3761 + if (err < 0)
3762 + goto error;
3763 + err = rpc_ntop(sap, buf, sizeof(buf));
3764 + if (err < 0)
3765 + goto error;
3766 + ip_addr = (const char *)buf;
3767 + }
3768 + strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
3769 +
3770 + err = nfs_idmap_new(clp);
3771 + if (err < 0) {
3772 + dprintk("%s: failed to create idmapper. Error = %d\n",
3773 + __func__, err);
3774 + goto error;
3775 + }
3776 + __set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
3777 return clp;
3778
3779 error:
3780 @@ -372,8 +413,6 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp)
3781 struct nfs_client *nfs4_init_client(struct nfs_client *clp,
3782 const struct nfs_client_initdata *cl_init)
3783 {
3784 - char buf[INET6_ADDRSTRLEN + 1];
3785 - const char *ip_addr = cl_init->ip_addr;
3786 struct nfs_client *old;
3787 int error;
3788
3789 @@ -381,43 +420,6 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp,
3790 /* the client is initialised already */
3791 return clp;
3792
3793 - /* Check NFS protocol revision and initialize RPC op vector */
3794 - clp->rpc_ops = &nfs_v4_clientops;
3795 -
3796 - if (clp->cl_minorversion != 0)
3797 - __set_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags);
3798 - __set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
3799 - __set_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags);
3800 -
3801 - error = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_GSS_KRB5I);
3802 - if (error == -EINVAL)
3803 - error = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX);
3804 - if (error < 0)
3805 - goto error;
3806 -
3807 - /* If no clientaddr= option was specified, find a usable cb address */
3808 - if (ip_addr == NULL) {
3809 - struct sockaddr_storage cb_addr;
3810 - struct sockaddr *sap = (struct sockaddr *)&cb_addr;
3811 -
3812 - error = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr));
3813 - if (error < 0)
3814 - goto error;
3815 - error = rpc_ntop(sap, buf, sizeof(buf));
3816 - if (error < 0)
3817 - goto error;
3818 - ip_addr = (const char *)buf;
3819 - }
3820 - strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
3821 -
3822 - error = nfs_idmap_new(clp);
3823 - if (error < 0) {
3824 - dprintk("%s: failed to create idmapper. Error = %d\n",
3825 - __func__, error);
3826 - goto error;
3827 - }
3828 - __set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
3829 -
3830 error = nfs4_init_client_minor_version(clp);
3831 if (error < 0)
3832 goto error;
3833 diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
3834 index 8b37e7f8e789f..249cf9037dbd7 100644
3835 --- a/fs/nfs/pnfs_nfs.c
3836 +++ b/fs/nfs/pnfs_nfs.c
3837 @@ -556,19 +556,16 @@ out:
3838 }
3839 EXPORT_SYMBOL_GPL(nfs4_pnfs_ds_add);
3840
3841 -static void nfs4_wait_ds_connect(struct nfs4_pnfs_ds *ds)
3842 +static int nfs4_wait_ds_connect(struct nfs4_pnfs_ds *ds)
3843 {
3844 might_sleep();
3845 - wait_on_bit(&ds->ds_state, NFS4DS_CONNECTING,
3846 - TASK_KILLABLE);
3847 + return wait_on_bit(&ds->ds_state, NFS4DS_CONNECTING, TASK_KILLABLE);
3848 }
3849
3850 static void nfs4_clear_ds_conn_bit(struct nfs4_pnfs_ds *ds)
3851 {
3852 smp_mb__before_atomic();
3853 - clear_bit(NFS4DS_CONNECTING, &ds->ds_state);
3854 - smp_mb__after_atomic();
3855 - wake_up_bit(&ds->ds_state, NFS4DS_CONNECTING);
3856 + clear_and_wake_up_bit(NFS4DS_CONNECTING, &ds->ds_state);
3857 }
3858
3859 static struct nfs_client *(*get_v3_ds_connect)(
3860 @@ -734,30 +731,33 @@ int nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds,
3861 {
3862 int err;
3863
3864 -again:
3865 - err = 0;
3866 - if (test_and_set_bit(NFS4DS_CONNECTING, &ds->ds_state) == 0) {
3867 - if (version == 3) {
3868 - err = _nfs4_pnfs_v3_ds_connect(mds_srv, ds, timeo,
3869 - retrans);
3870 - } else if (version == 4) {
3871 - err = _nfs4_pnfs_v4_ds_connect(mds_srv, ds, timeo,
3872 - retrans, minor_version);
3873 - } else {
3874 - dprintk("%s: unsupported DS version %d\n", __func__,
3875 - version);
3876 - err = -EPROTONOSUPPORT;
3877 - }
3878 + do {
3879 + err = nfs4_wait_ds_connect(ds);
3880 + if (err || ds->ds_clp)
3881 + goto out;
3882 + if (nfs4_test_deviceid_unavailable(devid))
3883 + return -ENODEV;
3884 + } while (test_and_set_bit(NFS4DS_CONNECTING, &ds->ds_state) != 0);
3885
3886 - nfs4_clear_ds_conn_bit(ds);
3887 - } else {
3888 - nfs4_wait_ds_connect(ds);
3889 + if (ds->ds_clp)
3890 + goto connect_done;
3891
3892 - /* what was waited on didn't connect AND didn't mark unavail */
3893 - if (!ds->ds_clp && !nfs4_test_deviceid_unavailable(devid))
3894 - goto again;
3895 + switch (version) {
3896 + case 3:
3897 + err = _nfs4_pnfs_v3_ds_connect(mds_srv, ds, timeo, retrans);
3898 + break;
3899 + case 4:
3900 + err = _nfs4_pnfs_v4_ds_connect(mds_srv, ds, timeo, retrans,
3901 + minor_version);
3902 + break;
3903 + default:
3904 + dprintk("%s: unsupported DS version %d\n", __func__, version);
3905 + err = -EPROTONOSUPPORT;
3906 }
3907
3908 +connect_done:
3909 + nfs4_clear_ds_conn_bit(ds);
3910 +out:
3911 /*
3912 * At this point the ds->ds_clp should be ready, but it might have
3913 * hit an error.
3914 diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
3915 index ee5efdc35cc1e..2f2e430461b21 100644
3916 --- a/fs/orangefs/super.c
3917 +++ b/fs/orangefs/super.c
3918 @@ -209,7 +209,7 @@ static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf)
3919 buf->f_bavail = (sector_t) new_op->downcall.resp.statfs.blocks_avail;
3920 buf->f_files = (sector_t) new_op->downcall.resp.statfs.files_total;
3921 buf->f_ffree = (sector_t) new_op->downcall.resp.statfs.files_avail;
3922 - buf->f_frsize = sb->s_blocksize;
3923 + buf->f_frsize = 0;
3924
3925 out_op_release:
3926 op_release(new_op);
3927 diff --git a/fs/seq_file.c b/fs/seq_file.c
3928 index 1600034a929bb..c19ecc1f2d502 100644
3929 --- a/fs/seq_file.c
3930 +++ b/fs/seq_file.c
3931 @@ -29,6 +29,9 @@ static void seq_set_overflow(struct seq_file *m)
3932
3933 static void *seq_buf_alloc(unsigned long size)
3934 {
3935 + if (unlikely(size > MAX_RW_COUNT))
3936 + return NULL;
3937 +
3938 return kvmalloc(size, GFP_KERNEL_ACCOUNT);
3939 }
3940
3941 diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
3942 index a5e5e9b9d4e31..eeb93f009b282 100644
3943 --- a/fs/ubifs/dir.c
3944 +++ b/fs/ubifs/dir.c
3945 @@ -1343,7 +1343,10 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
3946 goto out_release;
3947 }
3948
3949 + spin_lock(&whiteout->i_lock);
3950 whiteout->i_state |= I_LINKABLE;
3951 + spin_unlock(&whiteout->i_lock);
3952 +
3953 whiteout_ui = ubifs_inode(whiteout);
3954 whiteout_ui->data = dev;
3955 whiteout_ui->data_len = ubifs_encode_dev(dev, MKDEV(0, 0));
3956 @@ -1436,7 +1439,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
3957
3958 inc_nlink(whiteout);
3959 mark_inode_dirty(whiteout);
3960 +
3961 + spin_lock(&whiteout->i_lock);
3962 whiteout->i_state &= ~I_LINKABLE;
3963 + spin_unlock(&whiteout->i_lock);
3964 +
3965 iput(whiteout);
3966 }
3967
3968 diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
3969 index ad09c0cc54645..978ef674f0388 100644
3970 --- a/include/linux/nfs_fs.h
3971 +++ b/include/linux/nfs_fs.h
3972 @@ -79,6 +79,7 @@ struct nfs_open_context {
3973 #define NFS_CONTEXT_RESEND_WRITES (1)
3974 #define NFS_CONTEXT_BAD (2)
3975 #define NFS_CONTEXT_UNLOCK (3)
3976 +#define NFS_CONTEXT_FILE_OPEN (4)
3977 int error;
3978
3979 struct list_head list;
3980 diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
3981 index baf58f4cb0578..b3f88470cbb58 100644
3982 --- a/include/linux/sched/signal.h
3983 +++ b/include/linux/sched/signal.h
3984 @@ -509,6 +509,17 @@ static inline int kill_cad_pid(int sig, int priv)
3985 #define SEND_SIG_NOINFO ((struct kernel_siginfo *) 0)
3986 #define SEND_SIG_PRIV ((struct kernel_siginfo *) 1)
3987
3988 +static inline int __on_sig_stack(unsigned long sp)
3989 +{
3990 +#ifdef CONFIG_STACK_GROWSUP
3991 + return sp >= current->sas_ss_sp &&
3992 + sp - current->sas_ss_sp < current->sas_ss_size;
3993 +#else
3994 + return sp > current->sas_ss_sp &&
3995 + sp - current->sas_ss_sp <= current->sas_ss_size;
3996 +#endif
3997 +}
3998 +
3999 /*
4000 * True if we are on the alternate signal stack.
4001 */
4002 @@ -526,13 +537,7 @@ static inline int on_sig_stack(unsigned long sp)
4003 if (current->sas_ss_flags & SS_AUTODISARM)
4004 return 0;
4005
4006 -#ifdef CONFIG_STACK_GROWSUP
4007 - return sp >= current->sas_ss_sp &&
4008 - sp - current->sas_ss_sp < current->sas_ss_size;
4009 -#else
4010 - return sp > current->sas_ss_sp &&
4011 - sp - current->sas_ss_sp <= current->sas_ss_size;
4012 -#endif
4013 + return __on_sig_stack(sp);
4014 }
4015
4016 static inline int sas_ss_flags(unsigned long sp)
4017 diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
4018 index b3bbd10eb3f07..2b5f97224f693 100644
4019 --- a/include/scsi/libiscsi.h
4020 +++ b/include/scsi/libiscsi.h
4021 @@ -195,12 +195,6 @@ struct iscsi_conn {
4022 unsigned long suspend_tx; /* suspend Tx */
4023 unsigned long suspend_rx; /* suspend Rx */
4024
4025 - /* abort */
4026 - wait_queue_head_t ehwait; /* used in eh_abort() */
4027 - struct iscsi_tm tmhdr;
4028 - struct timer_list tmf_timer;
4029 - int tmf_state; /* see TMF_INITIAL, etc.*/
4030 -
4031 /* negotiated params */
4032 unsigned max_recv_dlength; /* initiator_max_recv_dsl*/
4033 unsigned max_xmit_dlength; /* target_max_recv_dsl */
4034 @@ -270,6 +264,11 @@ struct iscsi_session {
4035 * and recv lock.
4036 */
4037 struct mutex eh_mutex;
4038 + /* abort */
4039 + wait_queue_head_t ehwait; /* used in eh_abort() */
4040 + struct iscsi_tm tmhdr;
4041 + struct timer_list tmf_timer;
4042 + int tmf_state; /* see TMF_INITIAL, etc.*/
4043
4044 /* iSCSI session-wide sequencing */
4045 uint32_t cmdsn;
4046 diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
4047 index 325ae731d9ad8..71c78410e6ab3 100644
4048 --- a/include/scsi/scsi_transport_iscsi.h
4049 +++ b/include/scsi/scsi_transport_iscsi.h
4050 @@ -423,6 +423,8 @@ extern void iscsi_remove_session(struct iscsi_cls_session *session);
4051 extern void iscsi_free_session(struct iscsi_cls_session *session);
4052 extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess,
4053 int dd_size, uint32_t cid);
4054 +extern void iscsi_put_conn(struct iscsi_cls_conn *conn);
4055 +extern void iscsi_get_conn(struct iscsi_cls_conn *conn);
4056 extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn);
4057 extern void iscsi_unblock_session(struct iscsi_cls_session *session);
4058 extern void iscsi_block_session(struct iscsi_cls_session *session);
4059 diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
4060 index ae31b158baf73..9329f725d22b6 100644
4061 --- a/kernel/cgroup/cgroup-v1.c
4062 +++ b/kernel/cgroup/cgroup-v1.c
4063 @@ -918,6 +918,8 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)
4064 opt = fs_parse(fc, &cgroup1_fs_parameters, param, &result);
4065 if (opt == -ENOPARAM) {
4066 if (strcmp(param->key, "source") == 0) {
4067 + if (param->type != fs_value_is_string)
4068 + return invalf(fc, "Non-string source");
4069 if (fc->source)
4070 return invalf(fc, "Multiple sources not supported");
4071 fc->source = param->string;
4072 diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
4073 index 8fd4f82c9b3d7..7fd1c18b7cf15 100644
4074 --- a/kernel/rcu/rcu.h
4075 +++ b/kernel/rcu/rcu.h
4076 @@ -316,6 +316,8 @@ static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt)
4077 }
4078 }
4079
4080 +extern void rcu_init_geometry(void);
4081 +
4082 /* Returns a pointer to the first leaf rcu_node structure. */
4083 #define rcu_first_leaf_node() (rcu_state.level[rcu_num_lvls - 1])
4084
4085 diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
4086 index 21acdff3bd278..21115ffb6c446 100644
4087 --- a/kernel/rcu/srcutree.c
4088 +++ b/kernel/rcu/srcutree.c
4089 @@ -90,6 +90,9 @@ static void init_srcu_struct_nodes(struct srcu_struct *ssp, bool is_static)
4090 struct srcu_node *snp;
4091 struct srcu_node *snp_first;
4092
4093 + /* Initialize geometry if it has not already been initialized. */
4094 + rcu_init_geometry();
4095 +
4096 /* Work out the overall tree geometry. */
4097 ssp->level[0] = &ssp->node[0];
4098 for (i = 1; i < rcu_num_lvls; i++)
4099 diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
4100 index fd37827eca5b0..11ae2747701b5 100644
4101 --- a/kernel/rcu/tree.c
4102 +++ b/kernel/rcu/tree.c
4103 @@ -3425,11 +3425,25 @@ static void __init rcu_init_one(void)
4104 * replace the definitions in tree.h because those are needed to size
4105 * the ->node array in the rcu_state structure.
4106 */
4107 -static void __init rcu_init_geometry(void)
4108 +void rcu_init_geometry(void)
4109 {
4110 ulong d;
4111 int i;
4112 + static unsigned long old_nr_cpu_ids;
4113 int rcu_capacity[RCU_NUM_LVLS];
4114 + static bool initialized;
4115 +
4116 + if (initialized) {
4117 + /*
4118 + * Warn if setup_nr_cpu_ids() had not yet been invoked,
4119 + * unless nr_cpus_ids == NR_CPUS, in which case who cares?
4120 + */
4121 + WARN_ON_ONCE(old_nr_cpu_ids != nr_cpu_ids);
4122 + return;
4123 + }
4124 +
4125 + old_nr_cpu_ids = nr_cpu_ids;
4126 + initialized = true;
4127
4128 /*
4129 * Initialize any unspecified boot parameters.
4130 diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
4131 index b05376a01091d..f136449821bfe 100644
4132 --- a/kernel/trace/trace_events_hist.c
4133 +++ b/kernel/trace/trace_events_hist.c
4134 @@ -2571,7 +2571,9 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data,
4135 if (WARN_ON_ONCE(!field))
4136 goto out;
4137
4138 - if (is_string_field(field)) {
4139 + /* Pointers to strings are just pointers and dangerous to dereference */
4140 + if (is_string_field(field) &&
4141 + (field->filter_type != FILTER_PTR_STRING)) {
4142 flags |= HIST_FIELD_FL_STRING;
4143
4144 hist_field->size = MAX_FILTER_STR_VAL;
4145 @@ -5326,8 +5328,6 @@ static inline void add_to_key(char *compound_key, void *key,
4146 field = key_field->field;
4147 if (field->filter_type == FILTER_DYN_STRING)
4148 size = *(u32 *)(rec + field->offset) >> 16;
4149 - else if (field->filter_type == FILTER_PTR_STRING)
4150 - size = strlen(key);
4151 else if (field->filter_type == FILTER_STATIC_STRING)
4152 size = field->size;
4153
4154 diff --git a/lib/decompress_unlz4.c b/lib/decompress_unlz4.c
4155 index c0cfcfd486be0..e6327391b6b66 100644
4156 --- a/lib/decompress_unlz4.c
4157 +++ b/lib/decompress_unlz4.c
4158 @@ -112,6 +112,9 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,
4159 error("data corrupted");
4160 goto exit_2;
4161 }
4162 + } else if (size < 4) {
4163 + /* empty or end-of-file */
4164 + goto exit_3;
4165 }
4166
4167 chunksize = get_unaligned_le32(inp);
4168 @@ -125,6 +128,10 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,
4169 continue;
4170 }
4171
4172 + if (!fill && chunksize == 0) {
4173 + /* empty or end-of-file */
4174 + goto exit_3;
4175 + }
4176
4177 if (posp)
4178 *posp += 4;
4179 @@ -184,6 +191,7 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,
4180 }
4181 }
4182
4183 +exit_3:
4184 ret = 0;
4185 exit_2:
4186 if (!input)
4187 diff --git a/sound/ac97/bus.c b/sound/ac97/bus.c
4188 index 7985dd8198b6c..99e1728b52ae4 100644
4189 --- a/sound/ac97/bus.c
4190 +++ b/sound/ac97/bus.c
4191 @@ -520,7 +520,7 @@ static int ac97_bus_remove(struct device *dev)
4192 struct ac97_codec_driver *adrv = to_ac97_driver(dev->driver);
4193 int ret;
4194
4195 - ret = pm_runtime_get_sync(dev);
4196 + ret = pm_runtime_resume_and_get(dev);
4197 if (ret < 0)
4198 return ret;
4199
4200 diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig
4201 index e6b4ca469b2aa..e469375e2f2af 100644
4202 --- a/sound/firewire/Kconfig
4203 +++ b/sound/firewire/Kconfig
4204 @@ -38,7 +38,7 @@ config SND_OXFW
4205 * Mackie(Loud) Onyx 1640i (former model)
4206 * Mackie(Loud) Onyx Satellite
4207 * Mackie(Loud) Tapco Link.Firewire
4208 - * Mackie(Loud) d.4 pro
4209 + * Mackie(Loud) d.2 pro/d.4 pro (built-in FireWire card with OXFW971 ASIC)
4210 * Mackie(Loud) U.420/U.420d
4211 * TASCAM FireOne
4212 * Stanton Controllers & Systems 1 Deck/Mixer
4213 @@ -84,7 +84,7 @@ config SND_BEBOB
4214 * PreSonus FIREBOX/FIREPOD/FP10/Inspire1394
4215 * BridgeCo RDAudio1/Audio5
4216 * Mackie Onyx 1220/1620/1640 (FireWire I/O Card)
4217 - * Mackie d.2 (FireWire Option) and d.2 Pro
4218 + * Mackie d.2 (optional FireWire card with DM1000 ASIC)
4219 * Stanton FinalScratch 2 (ScratchAmp)
4220 * Tascam IF-FW/DM
4221 * Behringer XENIX UFX 1204/1604
4222 @@ -110,6 +110,7 @@ config SND_BEBOB
4223 * M-Audio Ozonic/NRV10/ProfireLightBridge
4224 * M-Audio FireWire 1814/ProjectMix IO
4225 * Digidesign Mbox 2 Pro
4226 + * ToneWeal FW66
4227
4228 To compile this driver as a module, choose M here: the module
4229 will be called snd-bebob.
4230 diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c
4231 index 441c58283b47e..d58f4fe2be8c1 100644
4232 --- a/sound/firewire/bebob/bebob.c
4233 +++ b/sound/firewire/bebob/bebob.c
4234 @@ -59,6 +59,7 @@ static DECLARE_BITMAP(devices_used, SNDRV_CARDS);
4235 #define VEN_MAUDIO1 0x00000d6c
4236 #define VEN_MAUDIO2 0x000007f5
4237 #define VEN_DIGIDESIGN 0x00a07e
4238 +#define OUI_SHOUYO 0x002327
4239
4240 #define MODEL_FOCUSRITE_SAFFIRE_BOTH 0x00000000
4241 #define MODEL_MAUDIO_AUDIOPHILE_BOTH 0x00010060
4242 @@ -387,7 +388,7 @@ static const struct ieee1394_device_id bebob_id_table[] = {
4243 SND_BEBOB_DEV_ENTRY(VEN_BRIDGECO, 0x00010049, &spec_normal),
4244 /* Mackie, Onyx 1220/1620/1640 (Firewire I/O Card) */
4245 SND_BEBOB_DEV_ENTRY(VEN_MACKIE2, 0x00010065, &spec_normal),
4246 - // Mackie, d.2 (Firewire option card) and d.2 Pro (the card is built-in).
4247 + // Mackie, d.2 (optional Firewire card with DM1000).
4248 SND_BEBOB_DEV_ENTRY(VEN_MACKIE1, 0x00010067, &spec_normal),
4249 /* Stanton, ScratchAmp */
4250 SND_BEBOB_DEV_ENTRY(VEN_STANTON, 0x00000001, &spec_normal),
4251 @@ -486,6 +487,8 @@ static const struct ieee1394_device_id bebob_id_table[] = {
4252 &maudio_special_spec),
4253 /* Digidesign Mbox 2 Pro */
4254 SND_BEBOB_DEV_ENTRY(VEN_DIGIDESIGN, 0x0000a9, &spec_normal),
4255 + // Toneweal FW66.
4256 + SND_BEBOB_DEV_ENTRY(OUI_SHOUYO, 0x020002, &spec_normal),
4257 /* IDs are unknown but able to be supported */
4258 /* Apogee, Mini-ME Firewire */
4259 /* Apogee, Mini-DAC Firewire */
4260 diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c
4261 index 6184a7c8f2b34..bebb2b8296cb2 100644
4262 --- a/sound/firewire/oxfw/oxfw.c
4263 +++ b/sound/firewire/oxfw/oxfw.c
4264 @@ -350,7 +350,7 @@ static const struct ieee1394_device_id oxfw_id_table[] = {
4265 * Onyx-i series (former models): 0x081216
4266 * Mackie Onyx Satellite: 0x00200f
4267 * Tapco LINK.firewire 4x6: 0x000460
4268 - * d.4 pro: Unknown
4269 + * d.2 pro/d.4 pro (built-in card): Unknown
4270 * U.420: Unknown
4271 * U.420d: Unknown
4272 */
4273 diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
4274 index bb7d4940ac25f..281ecd0eea48d 100644
4275 --- a/sound/isa/cmi8330.c
4276 +++ b/sound/isa/cmi8330.c
4277 @@ -549,7 +549,7 @@ static int snd_cmi8330_probe(struct snd_card *card, int dev)
4278 }
4279 if (acard->sb->hardware != SB_HW_16) {
4280 snd_printk(KERN_ERR PFX "SB16 not found during probe\n");
4281 - return err;
4282 + return -ENODEV;
4283 }
4284
4285 snd_wss_out(acard->wss, CS4231_MISC_INFO, 0x40); /* switch on MODE2 */
4286 diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c
4287 index 69960cf1bb51d..ef1289cc78a48 100644
4288 --- a/sound/isa/sb/sb16_csp.c
4289 +++ b/sound/isa/sb/sb16_csp.c
4290 @@ -1072,10 +1072,14 @@ static void snd_sb_qsound_destroy(struct snd_sb_csp * p)
4291 card = p->chip->card;
4292
4293 down_write(&card->controls_rwsem);
4294 - if (p->qsound_switch)
4295 + if (p->qsound_switch) {
4296 snd_ctl_remove(card, p->qsound_switch);
4297 - if (p->qsound_space)
4298 + p->qsound_switch = NULL;
4299 + }
4300 + if (p->qsound_space) {
4301 snd_ctl_remove(card, p->qsound_space);
4302 + p->qsound_space = NULL;
4303 + }
4304 up_write(&card->controls_rwsem);
4305
4306 /* cancel pending transfer of QSound parameters */
4307 diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
4308 index e378cb33c69df..2971b34c87c1a 100644
4309 --- a/sound/pci/hda/hda_tegra.c
4310 +++ b/sound/pci/hda/hda_tegra.c
4311 @@ -292,6 +292,9 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev)
4312 const char *sname, *drv_name = "tegra-hda";
4313 struct device_node *np = pdev->dev.of_node;
4314
4315 + if (irq_id < 0)
4316 + return irq_id;
4317 +
4318 err = hda_tegra_init_chip(chip, pdev);
4319 if (err)
4320 return err;
4321 diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c
4322 index 96ef55082bf9a..b135d114ce893 100644
4323 --- a/sound/ppc/powermac.c
4324 +++ b/sound/ppc/powermac.c
4325 @@ -77,7 +77,11 @@ static int snd_pmac_probe(struct platform_device *devptr)
4326 sprintf(card->shortname, "PowerMac %s", name_ext);
4327 sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
4328 card->shortname, chip->device_id, chip->subframe);
4329 - if ( snd_pmac_tumbler_init(chip) < 0 || snd_pmac_tumbler_post_init() < 0)
4330 + err = snd_pmac_tumbler_init(chip);
4331 + if (err < 0)
4332 + goto __error;
4333 + err = snd_pmac_tumbler_post_init();
4334 + if (err < 0)
4335 goto __error;
4336 break;
4337 case PMAC_AWACS:
4338 diff --git a/sound/soc/img/img-i2s-in.c b/sound/soc/img/img-i2s-in.c
4339 index bb668551dd4b2..243f916355eeb 100644
4340 --- a/sound/soc/img/img-i2s-in.c
4341 +++ b/sound/soc/img/img-i2s-in.c
4342 @@ -464,7 +464,7 @@ static int img_i2s_in_probe(struct platform_device *pdev)
4343 if (ret)
4344 goto err_pm_disable;
4345 }
4346 - ret = pm_runtime_get_sync(&pdev->dev);
4347 + ret = pm_runtime_resume_and_get(&pdev->dev);
4348 if (ret < 0)
4349 goto err_suspend;
4350
4351 diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c
4352 index 537a88932bb69..69362eae65be5 100644
4353 --- a/sound/soc/intel/boards/kbl_da7219_max98357a.c
4354 +++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c
4355 @@ -607,7 +607,7 @@ static int kabylake_audio_probe(struct platform_device *pdev)
4356
4357 static const struct platform_device_id kbl_board_ids[] = {
4358 {
4359 - .name = "kbl_da7219_max98357a",
4360 + .name = "kbl_da7219_mx98357a",
4361 .driver_data =
4362 (kernel_ulong_t)&kabylake_audio_card_da7219_m98357a,
4363 },
4364 @@ -629,4 +629,4 @@ module_platform_driver(kabylake_audio)
4365 MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode");
4366 MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>");
4367 MODULE_LICENSE("GPL v2");
4368 -MODULE_ALIAS("platform:kbl_da7219_max98357a");
4369 +MODULE_ALIAS("platform:kbl_da7219_mx98357a");
4370 diff --git a/sound/soc/intel/common/soc-acpi-intel-kbl-match.c b/sound/soc/intel/common/soc-acpi-intel-kbl-match.c
4371 index e200baa110118..df7f82e55a5a7 100644
4372 --- a/sound/soc/intel/common/soc-acpi-intel-kbl-match.c
4373 +++ b/sound/soc/intel/common/soc-acpi-intel-kbl-match.c
4374 @@ -113,7 +113,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_kbl_machines[] = {
4375 },
4376 {
4377 .id = "DLGS7219",
4378 - .drv_name = "kbl_da7219_max98373",
4379 + .drv_name = "kbl_da7219_mx98373",
4380 .fw_filename = "intel/dsp_fw_kbl.bin",
4381 .machine_quirk = snd_soc_acpi_codec_list,
4382 .quirk_data = &kbl_7219_98373_codecs,
4383 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
4384 index 9df20768a8f29..c0e03cc8ea822 100644
4385 --- a/sound/soc/soc-core.c
4386 +++ b/sound/soc/soc-core.c
4387 @@ -3178,7 +3178,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
4388 if (!routes) {
4389 dev_err(card->dev,
4390 "ASoC: Could not allocate DAPM route table\n");
4391 - return -EINVAL;
4392 + return -ENOMEM;
4393 }
4394
4395 for (i = 0; i < num_routes; i++) {
4396 diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c
4397 index 54bcf1c14bc24..ab7abe360fcfe 100644
4398 --- a/sound/usb/mixer_scarlett_gen2.c
4399 +++ b/sound/usb/mixer_scarlett_gen2.c
4400 @@ -254,10 +254,10 @@ static const struct scarlett2_device_info s6i6_gen2_info = {
4401 .pad_input_count = 2,
4402
4403 .line_out_descrs = {
4404 - "Monitor L",
4405 - "Monitor R",
4406 - "Headphones L",
4407 - "Headphones R",
4408 + "Headphones 1 L",
4409 + "Headphones 1 R",
4410 + "Headphones 2 L",
4411 + "Headphones 2 R",
4412 },
4413
4414 .ports = {
4415 @@ -356,7 +356,7 @@ static const struct scarlett2_device_info s18i8_gen2_info = {
4416 },
4417 [SCARLETT2_PORT_TYPE_PCM] = {
4418 .id = 0x600,
4419 - .num = { 20, 18, 18, 14, 10 },
4420 + .num = { 8, 18, 18, 14, 10 },
4421 .src_descr = "PCM %d",
4422 .src_num_offset = 1,
4423 .dst_descr = "PCM %02d Capture"
4424 @@ -1033,11 +1033,10 @@ static int scarlett2_master_volume_ctl_get(struct snd_kcontrol *kctl,
4425 struct usb_mixer_interface *mixer = elem->head.mixer;
4426 struct scarlett2_mixer_data *private = mixer->private_data;
4427
4428 - if (private->vol_updated) {
4429 - mutex_lock(&private->data_mutex);
4430 + mutex_lock(&private->data_mutex);
4431 + if (private->vol_updated)
4432 scarlett2_update_volumes(mixer);
4433 - mutex_unlock(&private->data_mutex);
4434 - }
4435 + mutex_unlock(&private->data_mutex);
4436
4437 ucontrol->value.integer.value[0] = private->master_vol;
4438 return 0;
4439 @@ -1051,11 +1050,10 @@ static int scarlett2_volume_ctl_get(struct snd_kcontrol *kctl,
4440 struct scarlett2_mixer_data *private = mixer->private_data;
4441 int index = elem->control;
4442
4443 - if (private->vol_updated) {
4444 - mutex_lock(&private->data_mutex);
4445 + mutex_lock(&private->data_mutex);
4446 + if (private->vol_updated)
4447 scarlett2_update_volumes(mixer);
4448 - mutex_unlock(&private->data_mutex);
4449 - }
4450 + mutex_unlock(&private->data_mutex);
4451
4452 ucontrol->value.integer.value[0] = private->vol[index];
4453 return 0;
4454 @@ -1186,6 +1184,8 @@ static int scarlett2_sw_hw_enum_ctl_put(struct snd_kcontrol *kctl,
4455 /* Send SW/HW switch change to the device */
4456 err = scarlett2_usb_set_config(mixer, SCARLETT2_CONFIG_SW_HW_SWITCH,
4457 index, val);
4458 + if (err == 0)
4459 + err = 1;
4460
4461 unlock:
4462 mutex_unlock(&private->data_mutex);
4463 @@ -1246,6 +1246,8 @@ static int scarlett2_level_enum_ctl_put(struct snd_kcontrol *kctl,
4464 /* Send switch change to the device */
4465 err = scarlett2_usb_set_config(mixer, SCARLETT2_CONFIG_LEVEL_SWITCH,
4466 index, val);
4467 + if (err == 0)
4468 + err = 1;
4469
4470 unlock:
4471 mutex_unlock(&private->data_mutex);
4472 @@ -1296,6 +1298,8 @@ static int scarlett2_pad_ctl_put(struct snd_kcontrol *kctl,
4473 /* Send switch change to the device */
4474 err = scarlett2_usb_set_config(mixer, SCARLETT2_CONFIG_PAD_SWITCH,
4475 index, val);
4476 + if (err == 0)
4477 + err = 1;
4478
4479 unlock:
4480 mutex_unlock(&private->data_mutex);
4481 @@ -1319,11 +1323,10 @@ static int scarlett2_button_ctl_get(struct snd_kcontrol *kctl,
4482 struct usb_mixer_interface *mixer = elem->head.mixer;
4483 struct scarlett2_mixer_data *private = mixer->private_data;
4484
4485 - if (private->vol_updated) {
4486 - mutex_lock(&private->data_mutex);
4487 + mutex_lock(&private->data_mutex);
4488 + if (private->vol_updated)
4489 scarlett2_update_volumes(mixer);
4490 - mutex_unlock(&private->data_mutex);
4491 - }
4492 + mutex_unlock(&private->data_mutex);
4493
4494 ucontrol->value.enumerated.item[0] = private->buttons[elem->control];
4495 return 0;
4496 @@ -1352,6 +1355,8 @@ static int scarlett2_button_ctl_put(struct snd_kcontrol *kctl,
4497 /* Send switch change to the device */
4498 err = scarlett2_usb_set_config(mixer, SCARLETT2_CONFIG_BUTTONS,
4499 index, val);
4500 + if (err == 0)
4501 + err = 1;
4502
4503 unlock:
4504 mutex_unlock(&private->data_mutex);
4505 diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
4506 index 091c071b270af..cff684942c4f0 100644
4507 --- a/sound/usb/usx2y/usb_stream.c
4508 +++ b/sound/usb/usx2y/usb_stream.c
4509 @@ -142,8 +142,11 @@ void usb_stream_free(struct usb_stream_kernel *sk)
4510 if (!s)
4511 return;
4512
4513 - free_pages_exact(sk->write_page, s->write_size);
4514 - sk->write_page = NULL;
4515 + if (sk->write_page) {
4516 + free_pages_exact(sk->write_page, s->write_size);
4517 + sk->write_page = NULL;
4518 + }
4519 +
4520 free_pages_exact(s, s->read_size);
4521 sk->s = NULL;
4522 }
4523 diff --git a/tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c b/tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c
4524 index fc5bf4870d8e6..01e827c31169d 100644
4525 --- a/tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c
4526 +++ b/tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c
4527 @@ -50,8 +50,6 @@ static int no_handler_test(void)
4528
4529 event_close(&event);
4530
4531 - dump_ebb_state();
4532 -
4533 /* The real test is that we never took an EBB at 0x0 */
4534
4535 return 0;
4536 diff --git a/tools/testing/selftests/timers/rtcpie.c b/tools/testing/selftests/timers/rtcpie.c
4537 index 47b5bad1b3933..4ef2184f15588 100644
4538 --- a/tools/testing/selftests/timers/rtcpie.c
4539 +++ b/tools/testing/selftests/timers/rtcpie.c
4540 @@ -18,6 +18,8 @@
4541 #include <stdlib.h>
4542 #include <errno.h>
4543
4544 +#include "../kselftest.h"
4545 +
4546 /*
4547 * This expects the new RTC class driver framework, working with
4548 * clocks that will often not be clones of what the PC-AT had.
4549 @@ -35,8 +37,14 @@ int main(int argc, char **argv)
4550 switch (argc) {
4551 case 2:
4552 rtc = argv[1];
4553 - /* FALLTHROUGH */
4554 + break;
4555 case 1:
4556 + fd = open(default_rtc, O_RDONLY);
4557 + if (fd == -1) {
4558 + printf("Default RTC %s does not exist. Test Skipped!\n", default_rtc);
4559 + exit(KSFT_SKIP);
4560 + }
4561 + close(fd);
4562 break;
4563 default:
4564 fprintf(stderr, "usage: rtctest [rtcdev] [d]\n");
4565 diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c
4566 index 6b870e4b9b972..8d606997c2993 100644
4567 --- a/virt/kvm/coalesced_mmio.c
4568 +++ b/virt/kvm/coalesced_mmio.c
4569 @@ -190,7 +190,6 @@ int kvm_vm_ioctl_unregister_coalesced_mmio(struct kvm *kvm,
4570 coalesced_mmio_in_range(dev, zone->addr, zone->size)) {
4571 r = kvm_io_bus_unregister_dev(kvm,
4572 zone->pio ? KVM_PIO_BUS : KVM_MMIO_BUS, &dev->dev);
4573 - kvm_iodevice_destructor(&dev->dev);
4574
4575 /*
4576 * On failure, unregister destroys all devices on the
4577 @@ -200,6 +199,7 @@ int kvm_vm_ioctl_unregister_coalesced_mmio(struct kvm *kvm,
4578 */
4579 if (r)
4580 break;
4581 + kvm_iodevice_destructor(&dev->dev);
4582 }
4583 }
4584