Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Fri, 03 Aug 2018 12:27:27
Message-Id: 1533299232.a713a7021ac1cda1fd26928470410551e3ec1636.mpagano@gentoo
1 commit: a713a7021ac1cda1fd26928470410551e3ec1636
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Aug 3 12:27:12 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri Aug 3 12:27:12 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=a713a702
7
8 Linux patch 4.14.60
9
10 0000_README | 4 +
11 1059_linux-4.14.60.patch | 7461 ++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 7465 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index 7ca7e18..685cb5d 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -279,6 +279,10 @@ Patch: 1058_linux-4.14.59.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.14.59
21
22 +Patch: 1059_linux-4.14.60.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.14.60
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1059_linux-4.14.60.patch b/1059_linux-4.14.60.patch
31 new file mode 100644
32 index 0000000..03968cc
33 --- /dev/null
34 +++ b/1059_linux-4.14.60.patch
35 @@ -0,0 +1,7461 @@
36 +diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.txt b/Documentation/devicetree/bindings/net/dsa/qca8k.txt
37 +index 9c67ee4890d7..bbcb255c3150 100644
38 +--- a/Documentation/devicetree/bindings/net/dsa/qca8k.txt
39 ++++ b/Documentation/devicetree/bindings/net/dsa/qca8k.txt
40 +@@ -2,7 +2,10 @@
41 +
42 + Required properties:
43 +
44 +-- compatible: should be "qca,qca8337"
45 ++- compatible: should be one of:
46 ++ "qca,qca8334"
47 ++ "qca,qca8337"
48 ++
49 + - #size-cells: must be 0
50 + - #address-cells: must be 1
51 +
52 +@@ -14,6 +17,20 @@ port and PHY id, each subnode describing a port needs to have a valid phandle
53 + referencing the internal PHY connected to it. The CPU port of this switch is
54 + always port 0.
55 +
56 ++A CPU port node has the following optional node:
57 ++
58 ++- fixed-link : Fixed-link subnode describing a link to a non-MDIO
59 ++ managed entity. See
60 ++ Documentation/devicetree/bindings/net/fixed-link.txt
61 ++ for details.
62 ++
63 ++For QCA8K the 'fixed-link' sub-node supports only the following properties:
64 ++
65 ++- 'speed' (integer, mandatory), to indicate the link speed. Accepted
66 ++ values are 10, 100 and 1000
67 ++- 'full-duplex' (boolean, optional), to indicate that full duplex is
68 ++ used. When absent, half duplex is assumed.
69 ++
70 + Example:
71 +
72 +
73 +@@ -53,6 +70,10 @@ Example:
74 + label = "cpu";
75 + ethernet = <&gmac1>;
76 + phy-mode = "rgmii";
77 ++ fixed-link {
78 ++ speed = 1000;
79 ++ full-duplex;
80 ++ };
81 + };
82 +
83 + port@1 {
84 +diff --git a/Documentation/devicetree/bindings/net/meson-dwmac.txt b/Documentation/devicetree/bindings/net/meson-dwmac.txt
85 +index 354dd9896bb5..910187ebf1ce 100644
86 +--- a/Documentation/devicetree/bindings/net/meson-dwmac.txt
87 ++++ b/Documentation/devicetree/bindings/net/meson-dwmac.txt
88 +@@ -10,6 +10,7 @@ Required properties on all platforms:
89 + - "amlogic,meson6-dwmac"
90 + - "amlogic,meson8b-dwmac"
91 + - "amlogic,meson-gxbb-dwmac"
92 ++ - "amlogic,meson-axg-dwmac"
93 + Additionally "snps,dwmac" and any applicable more
94 + detailed version number described in net/stmmac.txt
95 + should be used.
96 +diff --git a/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
97 +index 2392557ede27..df77d394edc0 100644
98 +--- a/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
99 ++++ b/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
100 +@@ -3,8 +3,10 @@
101 + Required properties for the root node:
102 + - compatible: one of "amlogic,meson8-cbus-pinctrl"
103 + "amlogic,meson8b-cbus-pinctrl"
104 ++ "amlogic,meson8m2-cbus-pinctrl"
105 + "amlogic,meson8-aobus-pinctrl"
106 + "amlogic,meson8b-aobus-pinctrl"
107 ++ "amlogic,meson8m2-aobus-pinctrl"
108 + "amlogic,meson-gxbb-periphs-pinctrl"
109 + "amlogic,meson-gxbb-aobus-pinctrl"
110 + "amlogic,meson-gxl-periphs-pinctrl"
111 +diff --git a/Documentation/vfio-mediated-device.txt b/Documentation/vfio-mediated-device.txt
112 +index 1b3950346532..c3f69bcaf96e 100644
113 +--- a/Documentation/vfio-mediated-device.txt
114 ++++ b/Documentation/vfio-mediated-device.txt
115 +@@ -145,6 +145,11 @@ The functions in the mdev_parent_ops structure are as follows:
116 + * create: allocate basic resources in a driver for a mediated device
117 + * remove: free resources in a driver when a mediated device is destroyed
118 +
119 ++(Note that mdev-core provides no implicit serialization of create/remove
120 ++callbacks per mdev parent device, per mdev type, or any other categorization.
121 ++Vendor drivers are expected to be fully asynchronous in this respect or
122 ++provide their own internal resource protection.)
123 ++
124 + The callbacks in the mdev_parent_ops structure are as follows:
125 +
126 + * open: open callback of mediated device
127 +diff --git a/Makefile b/Makefile
128 +index 81b0e99dce80..5b48ec630990 100644
129 +--- a/Makefile
130 ++++ b/Makefile
131 +@@ -1,7 +1,7 @@
132 + # SPDX-License-Identifier: GPL-2.0
133 + VERSION = 4
134 + PATCHLEVEL = 14
135 +-SUBLEVEL = 59
136 ++SUBLEVEL = 60
137 + EXTRAVERSION =
138 + NAME = Petit Gorille
139 +
140 +diff --git a/arch/arm/boot/dts/emev2.dtsi b/arch/arm/boot/dts/emev2.dtsi
141 +index 42ea246e71cb..fec1241b858f 100644
142 +--- a/arch/arm/boot/dts/emev2.dtsi
143 ++++ b/arch/arm/boot/dts/emev2.dtsi
144 +@@ -31,13 +31,13 @@
145 + #address-cells = <1>;
146 + #size-cells = <0>;
147 +
148 +- cpu@0 {
149 ++ cpu0: cpu@0 {
150 + device_type = "cpu";
151 + compatible = "arm,cortex-a9";
152 + reg = <0>;
153 + clock-frequency = <533000000>;
154 + };
155 +- cpu@1 {
156 ++ cpu1: cpu@1 {
157 + device_type = "cpu";
158 + compatible = "arm,cortex-a9";
159 + reg = <1>;
160 +@@ -57,6 +57,7 @@
161 + compatible = "arm,cortex-a9-pmu";
162 + interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>,
163 + <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
164 ++ interrupt-affinity = <&cpu0>, <&cpu1>;
165 + };
166 +
167 + clocks@e0110000 {
168 +diff --git a/arch/arm/boot/dts/sh73a0.dtsi b/arch/arm/boot/dts/sh73a0.dtsi
169 +index 4ea5c5a16c57..5fc24d4c2d5d 100644
170 +--- a/arch/arm/boot/dts/sh73a0.dtsi
171 ++++ b/arch/arm/boot/dts/sh73a0.dtsi
172 +@@ -22,7 +22,7 @@
173 + #address-cells = <1>;
174 + #size-cells = <0>;
175 +
176 +- cpu@0 {
177 ++ cpu0: cpu@0 {
178 + device_type = "cpu";
179 + compatible = "arm,cortex-a9";
180 + reg = <0>;
181 +@@ -30,7 +30,7 @@
182 + power-domains = <&pd_a2sl>;
183 + next-level-cache = <&L2>;
184 + };
185 +- cpu@1 {
186 ++ cpu1: cpu@1 {
187 + device_type = "cpu";
188 + compatible = "arm,cortex-a9";
189 + reg = <1>;
190 +@@ -89,6 +89,7 @@
191 + compatible = "arm,cortex-a9-pmu";
192 + interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
193 + <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>;
194 ++ interrupt-affinity = <&cpu0>, <&cpu1>;
195 + };
196 +
197 + cmt1: timer@e6138000 {
198 +diff --git a/arch/arm/boot/dts/stih407-pinctrl.dtsi b/arch/arm/boot/dts/stih407-pinctrl.dtsi
199 +index bd1a82e8fffe..fe501d32d059 100644
200 +--- a/arch/arm/boot/dts/stih407-pinctrl.dtsi
201 ++++ b/arch/arm/boot/dts/stih407-pinctrl.dtsi
202 +@@ -52,7 +52,7 @@
203 + st,syscfg = <&syscfg_sbc>;
204 + reg = <0x0961f080 0x4>;
205 + reg-names = "irqmux";
206 +- interrupts = <GIC_SPI 188 IRQ_TYPE_NONE>;
207 ++ interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
208 + interrupt-names = "irqmux";
209 + ranges = <0 0x09610000 0x6000>;
210 +
211 +@@ -376,7 +376,7 @@
212 + st,syscfg = <&syscfg_front>;
213 + reg = <0x0920f080 0x4>;
214 + reg-names = "irqmux";
215 +- interrupts = <GIC_SPI 189 IRQ_TYPE_NONE>;
216 ++ interrupts = <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>;
217 + interrupt-names = "irqmux";
218 + ranges = <0 0x09200000 0x10000>;
219 +
220 +@@ -936,7 +936,7 @@
221 + st,syscfg = <&syscfg_front>;
222 + reg = <0x0921f080 0x4>;
223 + reg-names = "irqmux";
224 +- interrupts = <GIC_SPI 190 IRQ_TYPE_NONE>;
225 ++ interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>;
226 + interrupt-names = "irqmux";
227 + ranges = <0 0x09210000 0x10000>;
228 +
229 +@@ -969,7 +969,7 @@
230 + st,syscfg = <&syscfg_rear>;
231 + reg = <0x0922f080 0x4>;
232 + reg-names = "irqmux";
233 +- interrupts = <GIC_SPI 191 IRQ_TYPE_NONE>;
234 ++ interrupts = <GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>;
235 + interrupt-names = "irqmux";
236 + ranges = <0 0x09220000 0x6000>;
237 +
238 +@@ -1164,7 +1164,7 @@
239 + st,syscfg = <&syscfg_flash>;
240 + reg = <0x0923f080 0x4>;
241 + reg-names = "irqmux";
242 +- interrupts = <GIC_SPI 192 IRQ_TYPE_NONE>;
243 ++ interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
244 + interrupt-names = "irqmux";
245 + ranges = <0 0x09230000 0x3000>;
246 +
247 +diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
248 +index 323a4df59a6c..ece2d1d43724 100644
249 +--- a/arch/arm/net/bpf_jit_32.c
250 ++++ b/arch/arm/net/bpf_jit_32.c
251 +@@ -718,7 +718,7 @@ static inline void emit_a32_arsh_r64(const u8 dst[], const u8 src[], bool dstk,
252 + }
253 +
254 + /* dst = dst >> src */
255 +-static inline void emit_a32_lsr_r64(const u8 dst[], const u8 src[], bool dstk,
256 ++static inline void emit_a32_rsh_r64(const u8 dst[], const u8 src[], bool dstk,
257 + bool sstk, struct jit_ctx *ctx) {
258 + const u8 *tmp = bpf2a32[TMP_REG_1];
259 + const u8 *tmp2 = bpf2a32[TMP_REG_2];
260 +@@ -734,7 +734,7 @@ static inline void emit_a32_lsr_r64(const u8 dst[], const u8 src[], bool dstk,
261 + emit(ARM_LDR_I(rm, ARM_SP, STACK_VAR(dst_hi)), ctx);
262 + }
263 +
264 +- /* Do LSH operation */
265 ++ /* Do RSH operation */
266 + emit(ARM_RSB_I(ARM_IP, rt, 32), ctx);
267 + emit(ARM_SUBS_I(tmp2[0], rt, 32), ctx);
268 + emit(ARM_MOV_SR(ARM_LR, rd, SRTYPE_LSR, rt), ctx);
269 +@@ -784,7 +784,7 @@ static inline void emit_a32_lsh_i64(const u8 dst[], bool dstk,
270 + }
271 +
272 + /* dst = dst >> val */
273 +-static inline void emit_a32_lsr_i64(const u8 dst[], bool dstk,
274 ++static inline void emit_a32_rsh_i64(const u8 dst[], bool dstk,
275 + const u32 val, struct jit_ctx *ctx) {
276 + const u8 *tmp = bpf2a32[TMP_REG_1];
277 + const u8 *tmp2 = bpf2a32[TMP_REG_2];
278 +@@ -1340,7 +1340,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
279 + case BPF_ALU64 | BPF_RSH | BPF_K:
280 + if (unlikely(imm > 63))
281 + return -EINVAL;
282 +- emit_a32_lsr_i64(dst, dstk, imm, ctx);
283 ++ emit_a32_rsh_i64(dst, dstk, imm, ctx);
284 + break;
285 + /* dst = dst << src */
286 + case BPF_ALU64 | BPF_LSH | BPF_X:
287 +@@ -1348,7 +1348,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
288 + break;
289 + /* dst = dst >> src */
290 + case BPF_ALU64 | BPF_RSH | BPF_X:
291 +- emit_a32_lsr_r64(dst, src, dstk, sstk, ctx);
292 ++ emit_a32_rsh_r64(dst, src, dstk, sstk, ctx);
293 + break;
294 + /* dst = dst >> src (signed) */
295 + case BPF_ALU64 | BPF_ARSH | BPF_X:
296 +diff --git a/arch/arm64/boot/dts/renesas/salvator-common.dtsi b/arch/arm64/boot/dts/renesas/salvator-common.dtsi
297 +index 9eb11a8d9eda..26a978616071 100644
298 +--- a/arch/arm64/boot/dts/renesas/salvator-common.dtsi
299 ++++ b/arch/arm64/boot/dts/renesas/salvator-common.dtsi
300 +@@ -93,20 +93,12 @@
301 + regulator-always-on;
302 + };
303 +
304 +- rsnd_ak4613: sound {
305 +- compatible = "simple-audio-card";
306 ++ sound_card: sound {
307 ++ compatible = "audio-graph-card";
308 +
309 +- simple-audio-card,format = "left_j";
310 +- simple-audio-card,bitclock-master = <&sndcpu>;
311 +- simple-audio-card,frame-master = <&sndcpu>;
312 ++ label = "rcar-sound";
313 +
314 +- sndcpu: simple-audio-card,cpu {
315 +- sound-dai = <&rcar_sound>;
316 +- };
317 +-
318 +- sndcodec: simple-audio-card,codec {
319 +- sound-dai = <&ak4613>;
320 +- };
321 ++ dais = <&rsnd_port0>;
322 + };
323 +
324 + vbus0_usb2: regulator-vbus0-usb2 {
325 +@@ -320,6 +312,12 @@
326 + asahi-kasei,out4-single-end;
327 + asahi-kasei,out5-single-end;
328 + asahi-kasei,out6-single-end;
329 ++
330 ++ port {
331 ++ ak4613_endpoint: endpoint {
332 ++ remote-endpoint = <&rsnd_endpoint0>;
333 ++ };
334 ++ };
335 + };
336 +
337 + cs2000: clk_multiplier@4f {
338 +@@ -538,10 +536,18 @@
339 + <&audio_clk_c>,
340 + <&cpg CPG_CORE CPG_AUDIO_CLK_I>;
341 +
342 +- rcar_sound,dai {
343 +- dai0 {
344 +- playback = <&ssi0 &src0 &dvc0>;
345 +- capture = <&ssi1 &src1 &dvc1>;
346 ++ ports {
347 ++ rsnd_port0: port@0 {
348 ++ rsnd_endpoint0: endpoint {
349 ++ remote-endpoint = <&ak4613_endpoint>;
350 ++
351 ++ dai-format = "left_j";
352 ++ bitclock-master = <&rsnd_endpoint0>;
353 ++ frame-master = <&rsnd_endpoint0>;
354 ++
355 ++ playback = <&ssi0 &src0 &dvc0>;
356 ++ capture = <&ssi1 &src1 &dvc1>;
357 ++ };
358 + };
359 + };
360 + };
361 +diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
362 +index 34480e9af2e7..b05796578e7a 100644
363 +--- a/arch/arm64/configs/defconfig
364 ++++ b/arch/arm64/configs/defconfig
365 +@@ -302,6 +302,8 @@ CONFIG_GPIO_XGENE_SB=y
366 + CONFIG_GPIO_PCA953X=y
367 + CONFIG_GPIO_PCA953X_IRQ=y
368 + CONFIG_GPIO_MAX77620=y
369 ++CONFIG_POWER_AVS=y
370 ++CONFIG_ROCKCHIP_IODOMAIN=y
371 + CONFIG_POWER_RESET_MSM=y
372 + CONFIG_POWER_RESET_XGENE=y
373 + CONFIG_POWER_RESET_SYSCON=y
374 +diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h
375 +index ae852add053d..0f2e1ab5e166 100644
376 +--- a/arch/arm64/include/asm/cmpxchg.h
377 ++++ b/arch/arm64/include/asm/cmpxchg.h
378 +@@ -229,7 +229,9 @@ static inline void __cmpwait_case_##name(volatile void *ptr, \
379 + unsigned long tmp; \
380 + \
381 + asm volatile( \
382 +- " ldxr" #sz "\t%" #w "[tmp], %[v]\n" \
383 ++ " sevl\n" \
384 ++ " wfe\n" \
385 ++ " ldxr" #sz "\t%" #w "[tmp], %[v]\n" \
386 + " eor %" #w "[tmp], %" #w "[tmp], %" #w "[val]\n" \
387 + " cbnz %" #w "[tmp], 1f\n" \
388 + " wfe\n" \
389 +diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
390 +index 00e7b900ca41..1190d90e01e6 100644
391 +--- a/arch/arm64/mm/init.c
392 ++++ b/arch/arm64/mm/init.c
393 +@@ -651,11 +651,13 @@ void __init mem_init(void)
394 + BUILD_BUG_ON(TASK_SIZE_32 > TASK_SIZE_64);
395 + #endif
396 +
397 ++#ifdef CONFIG_SPARSEMEM_VMEMMAP
398 + /*
399 + * Make sure we chose the upper bound of sizeof(struct page)
400 +- * correctly.
401 ++ * correctly when sizing the VMEMMAP array.
402 + */
403 + BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT));
404 ++#endif
405 +
406 + if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
407 + extern int sysctl_overcommit_memory;
408 +diff --git a/arch/microblaze/boot/Makefile b/arch/microblaze/boot/Makefile
409 +index 47f94cc383b6..7c2f52d4a0e4 100644
410 +--- a/arch/microblaze/boot/Makefile
411 ++++ b/arch/microblaze/boot/Makefile
412 +@@ -22,17 +22,19 @@ $(obj)/linux.bin.gz: $(obj)/linux.bin FORCE
413 + quiet_cmd_cp = CP $< $@$2
414 + cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false)
415 +
416 +-quiet_cmd_strip = STRIP $@
417 ++quiet_cmd_strip = STRIP $< $@$2
418 + cmd_strip = $(STRIP) -K microblaze_start -K _end -K __log_buf \
419 +- -K _fdt_start vmlinux -o $@
420 ++ -K _fdt_start $< -o $@$2
421 +
422 + UIMAGE_LOADADDR = $(CONFIG_KERNEL_BASE_ADDR)
423 ++UIMAGE_IN = $@
424 ++UIMAGE_OUT = $@.ub
425 +
426 + $(obj)/simpleImage.%: vmlinux FORCE
427 + $(call if_changed,cp,.unstrip)
428 + $(call if_changed,objcopy)
429 + $(call if_changed,uimage)
430 +- $(call if_changed,strip)
431 +- @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
432 ++ $(call if_changed,strip,.strip)
433 ++ @echo 'Kernel: $(UIMAGE_OUT) is ready' ' (#'`cat .version`')'
434 +
435 + clean-files += simpleImage.*.unstrip linux.bin.ub dts/*.dtb
436 +diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h
437 +index c7c63959ba91..e582d2c88092 100644
438 +--- a/arch/powerpc/include/asm/barrier.h
439 ++++ b/arch/powerpc/include/asm/barrier.h
440 +@@ -76,6 +76,21 @@ do { \
441 + ___p1; \
442 + })
443 +
444 ++#ifdef CONFIG_PPC_BOOK3S_64
445 ++/*
446 ++ * Prevent execution of subsequent instructions until preceding branches have
447 ++ * been fully resolved and are no longer executing speculatively.
448 ++ */
449 ++#define barrier_nospec_asm ori 31,31,0
450 ++
451 ++// This also acts as a compiler barrier due to the memory clobber.
452 ++#define barrier_nospec() asm (stringify_in_c(barrier_nospec_asm) ::: "memory")
453 ++
454 ++#else /* !CONFIG_PPC_BOOK3S_64 */
455 ++#define barrier_nospec_asm
456 ++#define barrier_nospec()
457 ++#endif
458 ++
459 + #include <asm-generic/barrier.h>
460 +
461 + #endif /* _ASM_POWERPC_BARRIER_H */
462 +diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
463 +index c1d257aa4c2d..66298461b640 100644
464 +--- a/arch/powerpc/include/asm/cache.h
465 ++++ b/arch/powerpc/include/asm/cache.h
466 +@@ -9,11 +9,14 @@
467 + #if defined(CONFIG_PPC_8xx) || defined(CONFIG_403GCX)
468 + #define L1_CACHE_SHIFT 4
469 + #define MAX_COPY_PREFETCH 1
470 ++#define IFETCH_ALIGN_SHIFT 2
471 + #elif defined(CONFIG_PPC_E500MC)
472 + #define L1_CACHE_SHIFT 6
473 + #define MAX_COPY_PREFETCH 4
474 ++#define IFETCH_ALIGN_SHIFT 3
475 + #elif defined(CONFIG_PPC32)
476 + #define MAX_COPY_PREFETCH 4
477 ++#define IFETCH_ALIGN_SHIFT 3 /* 603 fetches 2 insn at a time */
478 + #if defined(CONFIG_PPC_47x)
479 + #define L1_CACHE_SHIFT 7
480 + #else
481 +diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
482 +index ca2243df9cb2..470284f9e4f6 100644
483 +--- a/arch/powerpc/kernel/eeh_driver.c
484 ++++ b/arch/powerpc/kernel/eeh_driver.c
485 +@@ -450,9 +450,11 @@ static void *eeh_add_virt_device(void *data, void *userdata)
486 +
487 + driver = eeh_pcid_get(dev);
488 + if (driver) {
489 +- eeh_pcid_put(dev);
490 +- if (driver->err_handler)
491 ++ if (driver->err_handler) {
492 ++ eeh_pcid_put(dev);
493 + return NULL;
494 ++ }
495 ++ eeh_pcid_put(dev);
496 + }
497 +
498 + #ifdef CONFIG_PPC_POWERNV
499 +@@ -489,17 +491,19 @@ static void *eeh_rmv_device(void *data, void *userdata)
500 + if (eeh_dev_removed(edev))
501 + return NULL;
502 +
503 +- driver = eeh_pcid_get(dev);
504 +- if (driver) {
505 +- eeh_pcid_put(dev);
506 +- if (removed &&
507 +- eeh_pe_passed(edev->pe))
508 +- return NULL;
509 +- if (removed &&
510 +- driver->err_handler &&
511 +- driver->err_handler->error_detected &&
512 +- driver->err_handler->slot_reset)
513 ++ if (removed) {
514 ++ if (eeh_pe_passed(edev->pe))
515 + return NULL;
516 ++ driver = eeh_pcid_get(dev);
517 ++ if (driver) {
518 ++ if (driver->err_handler &&
519 ++ driver->err_handler->error_detected &&
520 ++ driver->err_handler->slot_reset) {
521 ++ eeh_pcid_put(dev);
522 ++ return NULL;
523 ++ }
524 ++ eeh_pcid_put(dev);
525 ++ }
526 + }
527 +
528 + /* Remove it from PCI subsystem */
529 +diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
530 +index 4fee00d414e8..2d0d89e2cb9a 100644
531 +--- a/arch/powerpc/kernel/head_8xx.S
532 ++++ b/arch/powerpc/kernel/head_8xx.S
533 +@@ -958,7 +958,7 @@ start_here:
534 + tovirt(r6,r6)
535 + lis r5, abatron_pteptrs@h
536 + ori r5, r5, abatron_pteptrs@l
537 +- stw r5, 0xf0(r0) /* Must match your Abatron config file */
538 ++ stw r5, 0xf0(0) /* Must match your Abatron config file */
539 + tophys(r5,r5)
540 + stw r6, 0(r5)
541 +
542 +diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
543 +index 1d817f4d97d9..2094f2b249fd 100644
544 +--- a/arch/powerpc/kernel/pci_32.c
545 ++++ b/arch/powerpc/kernel/pci_32.c
546 +@@ -11,6 +11,7 @@
547 + #include <linux/sched.h>
548 + #include <linux/errno.h>
549 + #include <linux/bootmem.h>
550 ++#include <linux/syscalls.h>
551 + #include <linux/irq.h>
552 + #include <linux/list.h>
553 + #include <linux/of.h>
554 +diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
555 +index 02190e90c7ae..f8782c7ef50f 100644
556 +--- a/arch/powerpc/kernel/prom_init.c
557 ++++ b/arch/powerpc/kernel/prom_init.c
558 +@@ -334,6 +334,7 @@ static void __init prom_print_dec(unsigned long val)
559 + call_prom("write", 3, 1, prom.stdout, buf+i, size);
560 + }
561 +
562 ++__printf(1, 2)
563 + static void __init prom_printf(const char *format, ...)
564 + {
565 + const char *p, *q, *s;
566 +@@ -1148,7 +1149,7 @@ static void __init prom_send_capabilities(void)
567 + */
568 +
569 + cores = DIV_ROUND_UP(NR_CPUS, prom_count_smt_threads());
570 +- prom_printf("Max number of cores passed to firmware: %lu (NR_CPUS = %lu)\n",
571 ++ prom_printf("Max number of cores passed to firmware: %u (NR_CPUS = %d)\n",
572 + cores, NR_CPUS);
573 +
574 + ibm_architecture_vec.vec5.max_cpus = cpu_to_be32(cores);
575 +@@ -1230,7 +1231,7 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align)
576 +
577 + if (align)
578 + base = _ALIGN_UP(base, align);
579 +- prom_debug("alloc_up(%x, %x)\n", size, align);
580 ++ prom_debug("%s(%lx, %lx)\n", __func__, size, align);
581 + if (ram_top == 0)
582 + prom_panic("alloc_up() called with mem not initialized\n");
583 +
584 +@@ -1241,7 +1242,7 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align)
585 +
586 + for(; (base + size) <= alloc_top;
587 + base = _ALIGN_UP(base + 0x100000, align)) {
588 +- prom_debug(" trying: 0x%x\n\r", base);
589 ++ prom_debug(" trying: 0x%lx\n\r", base);
590 + addr = (unsigned long)prom_claim(base, size, 0);
591 + if (addr != PROM_ERROR && addr != 0)
592 + break;
593 +@@ -1253,12 +1254,12 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align)
594 + return 0;
595 + alloc_bottom = addr + size;
596 +
597 +- prom_debug(" -> %x\n", addr);
598 +- prom_debug(" alloc_bottom : %x\n", alloc_bottom);
599 +- prom_debug(" alloc_top : %x\n", alloc_top);
600 +- prom_debug(" alloc_top_hi : %x\n", alloc_top_high);
601 +- prom_debug(" rmo_top : %x\n", rmo_top);
602 +- prom_debug(" ram_top : %x\n", ram_top);
603 ++ prom_debug(" -> %lx\n", addr);
604 ++ prom_debug(" alloc_bottom : %lx\n", alloc_bottom);
605 ++ prom_debug(" alloc_top : %lx\n", alloc_top);
606 ++ prom_debug(" alloc_top_hi : %lx\n", alloc_top_high);
607 ++ prom_debug(" rmo_top : %lx\n", rmo_top);
608 ++ prom_debug(" ram_top : %lx\n", ram_top);
609 +
610 + return addr;
611 + }
612 +@@ -1273,7 +1274,7 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
613 + {
614 + unsigned long base, addr = 0;
615 +
616 +- prom_debug("alloc_down(%x, %x, %s)\n", size, align,
617 ++ prom_debug("%s(%lx, %lx, %s)\n", __func__, size, align,
618 + highmem ? "(high)" : "(low)");
619 + if (ram_top == 0)
620 + prom_panic("alloc_down() called with mem not initialized\n");
621 +@@ -1301,7 +1302,7 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
622 + base = _ALIGN_DOWN(alloc_top - size, align);
623 + for (; base > alloc_bottom;
624 + base = _ALIGN_DOWN(base - 0x100000, align)) {
625 +- prom_debug(" trying: 0x%x\n\r", base);
626 ++ prom_debug(" trying: 0x%lx\n\r", base);
627 + addr = (unsigned long)prom_claim(base, size, 0);
628 + if (addr != PROM_ERROR && addr != 0)
629 + break;
630 +@@ -1312,12 +1313,12 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
631 + alloc_top = addr;
632 +
633 + bail:
634 +- prom_debug(" -> %x\n", addr);
635 +- prom_debug(" alloc_bottom : %x\n", alloc_bottom);
636 +- prom_debug(" alloc_top : %x\n", alloc_top);
637 +- prom_debug(" alloc_top_hi : %x\n", alloc_top_high);
638 +- prom_debug(" rmo_top : %x\n", rmo_top);
639 +- prom_debug(" ram_top : %x\n", ram_top);
640 ++ prom_debug(" -> %lx\n", addr);
641 ++ prom_debug(" alloc_bottom : %lx\n", alloc_bottom);
642 ++ prom_debug(" alloc_top : %lx\n", alloc_top);
643 ++ prom_debug(" alloc_top_hi : %lx\n", alloc_top_high);
644 ++ prom_debug(" rmo_top : %lx\n", rmo_top);
645 ++ prom_debug(" ram_top : %lx\n", ram_top);
646 +
647 + return addr;
648 + }
649 +@@ -1443,7 +1444,7 @@ static void __init prom_init_mem(void)
650 +
651 + if (size == 0)
652 + continue;
653 +- prom_debug(" %x %x\n", base, size);
654 ++ prom_debug(" %lx %lx\n", base, size);
655 + if (base == 0 && (of_platform & PLATFORM_LPAR))
656 + rmo_top = size;
657 + if ((base + size) > ram_top)
658 +@@ -1463,12 +1464,12 @@ static void __init prom_init_mem(void)
659 +
660 + if (prom_memory_limit) {
661 + if (prom_memory_limit <= alloc_bottom) {
662 +- prom_printf("Ignoring mem=%x <= alloc_bottom.\n",
663 +- prom_memory_limit);
664 ++ prom_printf("Ignoring mem=%lx <= alloc_bottom.\n",
665 ++ prom_memory_limit);
666 + prom_memory_limit = 0;
667 + } else if (prom_memory_limit >= ram_top) {
668 +- prom_printf("Ignoring mem=%x >= ram_top.\n",
669 +- prom_memory_limit);
670 ++ prom_printf("Ignoring mem=%lx >= ram_top.\n",
671 ++ prom_memory_limit);
672 + prom_memory_limit = 0;
673 + } else {
674 + ram_top = prom_memory_limit;
675 +@@ -1500,12 +1501,13 @@ static void __init prom_init_mem(void)
676 + alloc_bottom = PAGE_ALIGN(prom_initrd_end);
677 +
678 + prom_printf("memory layout at init:\n");
679 +- prom_printf(" memory_limit : %x (16 MB aligned)\n", prom_memory_limit);
680 +- prom_printf(" alloc_bottom : %x\n", alloc_bottom);
681 +- prom_printf(" alloc_top : %x\n", alloc_top);
682 +- prom_printf(" alloc_top_hi : %x\n", alloc_top_high);
683 +- prom_printf(" rmo_top : %x\n", rmo_top);
684 +- prom_printf(" ram_top : %x\n", ram_top);
685 ++ prom_printf(" memory_limit : %lx (16 MB aligned)\n",
686 ++ prom_memory_limit);
687 ++ prom_printf(" alloc_bottom : %lx\n", alloc_bottom);
688 ++ prom_printf(" alloc_top : %lx\n", alloc_top);
689 ++ prom_printf(" alloc_top_hi : %lx\n", alloc_top_high);
690 ++ prom_printf(" rmo_top : %lx\n", rmo_top);
691 ++ prom_printf(" ram_top : %lx\n", ram_top);
692 + }
693 +
694 + static void __init prom_close_stdin(void)
695 +@@ -1566,7 +1568,7 @@ static void __init prom_instantiate_opal(void)
696 + return;
697 + }
698 +
699 +- prom_printf("instantiating opal at 0x%x...", base);
700 ++ prom_printf("instantiating opal at 0x%llx...", base);
701 +
702 + if (call_prom_ret("call-method", 4, 3, rets,
703 + ADDR("load-opal-runtime"),
704 +@@ -1582,10 +1584,10 @@ static void __init prom_instantiate_opal(void)
705 +
706 + reserve_mem(base, size);
707 +
708 +- prom_debug("opal base = 0x%x\n", base);
709 +- prom_debug("opal align = 0x%x\n", align);
710 +- prom_debug("opal entry = 0x%x\n", entry);
711 +- prom_debug("opal size = 0x%x\n", (long)size);
712 ++ prom_debug("opal base = 0x%llx\n", base);
713 ++ prom_debug("opal align = 0x%llx\n", align);
714 ++ prom_debug("opal entry = 0x%llx\n", entry);
715 ++ prom_debug("opal size = 0x%llx\n", size);
716 +
717 + prom_setprop(opal_node, "/ibm,opal", "opal-base-address",
718 + &base, sizeof(base));
719 +@@ -1662,7 +1664,7 @@ static void __init prom_instantiate_rtas(void)
720 +
721 + prom_debug("rtas base = 0x%x\n", base);
722 + prom_debug("rtas entry = 0x%x\n", entry);
723 +- prom_debug("rtas size = 0x%x\n", (long)size);
724 ++ prom_debug("rtas size = 0x%x\n", size);
725 +
726 + prom_debug("prom_instantiate_rtas: end...\n");
727 + }
728 +@@ -1720,7 +1722,7 @@ static void __init prom_instantiate_sml(void)
729 + if (base == 0)
730 + prom_panic("Could not allocate memory for sml\n");
731 +
732 +- prom_printf("instantiating sml at 0x%x...", base);
733 ++ prom_printf("instantiating sml at 0x%llx...", base);
734 +
735 + memset((void *)base, 0, size);
736 +
737 +@@ -1739,8 +1741,8 @@ static void __init prom_instantiate_sml(void)
738 + prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-size",
739 + &size, sizeof(size));
740 +
741 +- prom_debug("sml base = 0x%x\n", base);
742 +- prom_debug("sml size = 0x%x\n", (long)size);
743 ++ prom_debug("sml base = 0x%llx\n", base);
744 ++ prom_debug("sml size = 0x%x\n", size);
745 +
746 + prom_debug("prom_instantiate_sml: end...\n");
747 + }
748 +@@ -1841,7 +1843,7 @@ static void __init prom_initialize_tce_table(void)
749 +
750 + prom_debug("TCE table: %s\n", path);
751 + prom_debug("\tnode = 0x%x\n", node);
752 +- prom_debug("\tbase = 0x%x\n", base);
753 ++ prom_debug("\tbase = 0x%llx\n", base);
754 + prom_debug("\tsize = 0x%x\n", minsize);
755 +
756 + /* Initialize the table to have a one-to-one mapping
757 +@@ -1928,12 +1930,12 @@ static void __init prom_hold_cpus(void)
758 + }
759 +
760 + prom_debug("prom_hold_cpus: start...\n");
761 +- prom_debug(" 1) spinloop = 0x%x\n", (unsigned long)spinloop);
762 +- prom_debug(" 1) *spinloop = 0x%x\n", *spinloop);
763 +- prom_debug(" 1) acknowledge = 0x%x\n",
764 ++ prom_debug(" 1) spinloop = 0x%lx\n", (unsigned long)spinloop);
765 ++ prom_debug(" 1) *spinloop = 0x%lx\n", *spinloop);
766 ++ prom_debug(" 1) acknowledge = 0x%lx\n",
767 + (unsigned long)acknowledge);
768 +- prom_debug(" 1) *acknowledge = 0x%x\n", *acknowledge);
769 +- prom_debug(" 1) secondary_hold = 0x%x\n", secondary_hold);
770 ++ prom_debug(" 1) *acknowledge = 0x%lx\n", *acknowledge);
771 ++ prom_debug(" 1) secondary_hold = 0x%lx\n", secondary_hold);
772 +
773 + /* Set the common spinloop variable, so all of the secondary cpus
774 + * will block when they are awakened from their OF spinloop.
775 +@@ -1961,7 +1963,7 @@ static void __init prom_hold_cpus(void)
776 + prom_getprop(node, "reg", &reg, sizeof(reg));
777 + cpu_no = be32_to_cpu(reg);
778 +
779 +- prom_debug("cpu hw idx = %lu\n", cpu_no);
780 ++ prom_debug("cpu hw idx = %u\n", cpu_no);
781 +
782 + /* Init the acknowledge var which will be reset by
783 + * the secondary cpu when it awakens from its OF
784 +@@ -1971,7 +1973,7 @@ static void __init prom_hold_cpus(void)
785 +
786 + if (cpu_no != prom.cpu) {
787 + /* Primary Thread of non-boot cpu or any thread */
788 +- prom_printf("starting cpu hw idx %lu... ", cpu_no);
789 ++ prom_printf("starting cpu hw idx %u... ", cpu_no);
790 + call_prom("start-cpu", 3, 0, node,
791 + secondary_hold, cpu_no);
792 +
793 +@@ -1982,11 +1984,11 @@ static void __init prom_hold_cpus(void)
794 + if (*acknowledge == cpu_no)
795 + prom_printf("done\n");
796 + else
797 +- prom_printf("failed: %x\n", *acknowledge);
798 ++ prom_printf("failed: %lx\n", *acknowledge);
799 + }
800 + #ifdef CONFIG_SMP
801 + else
802 +- prom_printf("boot cpu hw idx %lu\n", cpu_no);
803 ++ prom_printf("boot cpu hw idx %u\n", cpu_no);
804 + #endif /* CONFIG_SMP */
805 + }
806 +
807 +@@ -2264,7 +2266,7 @@ static void __init *make_room(unsigned long *mem_start, unsigned long *mem_end,
808 + while ((*mem_start + needed) > *mem_end) {
809 + unsigned long room, chunk;
810 +
811 +- prom_debug("Chunk exhausted, claiming more at %x...\n",
812 ++ prom_debug("Chunk exhausted, claiming more at %lx...\n",
813 + alloc_bottom);
814 + room = alloc_top - alloc_bottom;
815 + if (room > DEVTREE_CHUNK_SIZE)
816 +@@ -2490,7 +2492,7 @@ static void __init flatten_device_tree(void)
817 + room = alloc_top - alloc_bottom - 0x4000;
818 + if (room > DEVTREE_CHUNK_SIZE)
819 + room = DEVTREE_CHUNK_SIZE;
820 +- prom_debug("starting device tree allocs at %x\n", alloc_bottom);
821 ++ prom_debug("starting device tree allocs at %lx\n", alloc_bottom);
822 +
823 + /* Now try to claim that */
824 + mem_start = (unsigned long)alloc_up(room, PAGE_SIZE);
825 +@@ -2553,7 +2555,7 @@ static void __init flatten_device_tree(void)
826 + int i;
827 + prom_printf("reserved memory map:\n");
828 + for (i = 0; i < mem_reserve_cnt; i++)
829 +- prom_printf(" %x - %x\n",
830 ++ prom_printf(" %llx - %llx\n",
831 + be64_to_cpu(mem_reserve_map[i].base),
832 + be64_to_cpu(mem_reserve_map[i].size));
833 + }
834 +@@ -2563,9 +2565,9 @@ static void __init flatten_device_tree(void)
835 + */
836 + mem_reserve_cnt = MEM_RESERVE_MAP_SIZE;
837 +
838 +- prom_printf("Device tree strings 0x%x -> 0x%x\n",
839 ++ prom_printf("Device tree strings 0x%lx -> 0x%lx\n",
840 + dt_string_start, dt_string_end);
841 +- prom_printf("Device tree struct 0x%x -> 0x%x\n",
842 ++ prom_printf("Device tree struct 0x%lx -> 0x%lx\n",
843 + dt_struct_start, dt_struct_end);
844 + }
845 +
846 +@@ -2997,7 +2999,7 @@ static void __init prom_find_boot_cpu(void)
847 + prom_getprop(cpu_pkg, "reg", &rval, sizeof(rval));
848 + prom.cpu = be32_to_cpu(rval);
849 +
850 +- prom_debug("Booting CPU hw index = %lu\n", prom.cpu);
851 ++ prom_debug("Booting CPU hw index = %d\n", prom.cpu);
852 + }
853 +
854 + static void __init prom_check_initrd(unsigned long r3, unsigned long r4)
855 +@@ -3019,8 +3021,8 @@ static void __init prom_check_initrd(unsigned long r3, unsigned long r4)
856 + reserve_mem(prom_initrd_start,
857 + prom_initrd_end - prom_initrd_start);
858 +
859 +- prom_debug("initrd_start=0x%x\n", prom_initrd_start);
860 +- prom_debug("initrd_end=0x%x\n", prom_initrd_end);
861 ++ prom_debug("initrd_start=0x%lx\n", prom_initrd_start);
862 ++ prom_debug("initrd_end=0x%lx\n", prom_initrd_end);
863 + }
864 + #endif /* CONFIG_BLK_DEV_INITRD */
865 + }
866 +@@ -3273,7 +3275,7 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
867 + /* Don't print anything after quiesce under OPAL, it crashes OFW */
868 + if (of_platform != PLATFORM_OPAL) {
869 + prom_printf("Booting Linux via __start() @ 0x%lx ...\n", kbase);
870 +- prom_debug("->dt_header_start=0x%x\n", hdr);
871 ++ prom_debug("->dt_header_start=0x%lx\n", hdr);
872 + }
873 +
874 + #ifdef CONFIG_PPC32
875 +diff --git a/arch/powerpc/lib/string.S b/arch/powerpc/lib/string.S
876 +index a787776822d8..0378def28d41 100644
877 +--- a/arch/powerpc/lib/string.S
878 ++++ b/arch/powerpc/lib/string.S
879 +@@ -12,6 +12,7 @@
880 + #include <asm/errno.h>
881 + #include <asm/ppc_asm.h>
882 + #include <asm/export.h>
883 ++#include <asm/cache.h>
884 +
885 + .text
886 +
887 +@@ -23,7 +24,7 @@ _GLOBAL(strncpy)
888 + mtctr r5
889 + addi r6,r3,-1
890 + addi r4,r4,-1
891 +- .balign 16
892 ++ .balign IFETCH_ALIGN_BYTES
893 + 1: lbzu r0,1(r4)
894 + cmpwi 0,r0,0
895 + stbu r0,1(r6)
896 +@@ -43,7 +44,7 @@ _GLOBAL(strncmp)
897 + mtctr r5
898 + addi r5,r3,-1
899 + addi r4,r4,-1
900 +- .balign 16
901 ++ .balign IFETCH_ALIGN_BYTES
902 + 1: lbzu r3,1(r5)
903 + cmpwi 1,r3,0
904 + lbzu r0,1(r4)
905 +@@ -77,7 +78,7 @@ _GLOBAL(memchr)
906 + beq- 2f
907 + mtctr r5
908 + addi r3,r3,-1
909 +- .balign 16
910 ++ .balign IFETCH_ALIGN_BYTES
911 + 1: lbzu r0,1(r3)
912 + cmpw 0,r0,r4
913 + bdnzf 2,1b
914 +diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
915 +index 13cfe413b40d..6d9bf014b3e7 100644
916 +--- a/arch/powerpc/mm/slb.c
917 ++++ b/arch/powerpc/mm/slb.c
918 +@@ -62,14 +62,14 @@ static inline void slb_shadow_update(unsigned long ea, int ssize,
919 + * updating it. No write barriers are needed here, provided
920 + * we only update the current CPU's SLB shadow buffer.
921 + */
922 +- p->save_area[index].esid = 0;
923 +- p->save_area[index].vsid = cpu_to_be64(mk_vsid_data(ea, ssize, flags));
924 +- p->save_area[index].esid = cpu_to_be64(mk_esid_data(ea, ssize, index));
925 ++ WRITE_ONCE(p->save_area[index].esid, 0);
926 ++ WRITE_ONCE(p->save_area[index].vsid, cpu_to_be64(mk_vsid_data(ea, ssize, flags)));
927 ++ WRITE_ONCE(p->save_area[index].esid, cpu_to_be64(mk_esid_data(ea, ssize, index)));
928 + }
929 +
930 + static inline void slb_shadow_clear(enum slb_index index)
931 + {
932 +- get_slb_shadow()->save_area[index].esid = 0;
933 ++ WRITE_ONCE(get_slb_shadow()->save_area[index].esid, 0);
934 + }
935 +
936 + static inline void create_shadowed_slbe(unsigned long ea, int ssize,
937 +diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
938 +index bd0786c23109..254634fb3fc7 100644
939 +--- a/arch/powerpc/net/bpf_jit_comp64.c
940 ++++ b/arch/powerpc/net/bpf_jit_comp64.c
941 +@@ -203,25 +203,37 @@ static void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx)
942 +
943 + static void bpf_jit_emit_func_call(u32 *image, struct codegen_context *ctx, u64 func)
944 + {
945 ++ unsigned int i, ctx_idx = ctx->idx;
946 ++
947 ++ /* Load function address into r12 */
948 ++ PPC_LI64(12, func);
949 ++
950 ++ /* For bpf-to-bpf function calls, the callee's address is unknown
951 ++ * until the last extra pass. As seen above, we use PPC_LI64() to
952 ++ * load the callee's address, but this may optimize the number of
953 ++ * instructions required based on the nature of the address.
954 ++ *
955 ++ * Since we don't want the number of instructions emitted to change,
956 ++ * we pad the optimized PPC_LI64() call with NOPs to guarantee that
957 ++ * we always have a five-instruction sequence, which is the maximum
958 ++ * that PPC_LI64() can emit.
959 ++ */
960 ++ for (i = ctx->idx - ctx_idx; i < 5; i++)
961 ++ PPC_NOP();
962 ++
963 + #ifdef PPC64_ELF_ABI_v1
964 +- /* func points to the function descriptor */
965 +- PPC_LI64(b2p[TMP_REG_2], func);
966 +- /* Load actual entry point from function descriptor */
967 +- PPC_BPF_LL(b2p[TMP_REG_1], b2p[TMP_REG_2], 0);
968 +- /* ... and move it to LR */
969 +- PPC_MTLR(b2p[TMP_REG_1]);
970 + /*
971 + * Load TOC from function descriptor at offset 8.
972 + * We can clobber r2 since we get called through a
973 + * function pointer (so caller will save/restore r2)
974 + * and since we don't use a TOC ourself.
975 + */
976 +- PPC_BPF_LL(2, b2p[TMP_REG_2], 8);
977 +-#else
978 +- /* We can clobber r12 */
979 +- PPC_FUNC_ADDR(12, func);
980 +- PPC_MTLR(12);
981 ++ PPC_BPF_LL(2, 12, 8);
982 ++ /* Load actual entry point from function descriptor */
983 ++ PPC_BPF_LL(12, 12, 0);
984 + #endif
985 ++
986 ++ PPC_MTLR(12);
987 + PPC_BLRL();
988 + }
989 +
990 +diff --git a/arch/powerpc/platforms/chrp/time.c b/arch/powerpc/platforms/chrp/time.c
991 +index 03d115aaa191..acde7bbe0716 100644
992 +--- a/arch/powerpc/platforms/chrp/time.c
993 ++++ b/arch/powerpc/platforms/chrp/time.c
994 +@@ -28,6 +28,8 @@
995 + #include <asm/sections.h>
996 + #include <asm/time.h>
997 +
998 ++#include <platforms/chrp/chrp.h>
999 ++
1000 + extern spinlock_t rtc_lock;
1001 +
1002 + #define NVRAM_AS0 0x74
1003 +@@ -63,7 +65,7 @@ long __init chrp_time_init(void)
1004 + return 0;
1005 + }
1006 +
1007 +-int chrp_cmos_clock_read(int addr)
1008 ++static int chrp_cmos_clock_read(int addr)
1009 + {
1010 + if (nvram_as1 != 0)
1011 + outb(addr>>8, nvram_as1);
1012 +@@ -71,7 +73,7 @@ int chrp_cmos_clock_read(int addr)
1013 + return (inb(nvram_data));
1014 + }
1015 +
1016 +-void chrp_cmos_clock_write(unsigned long val, int addr)
1017 ++static void chrp_cmos_clock_write(unsigned long val, int addr)
1018 + {
1019 + if (nvram_as1 != 0)
1020 + outb(addr>>8, nvram_as1);
1021 +diff --git a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
1022 +index 89c54de88b7a..bf4a125faec6 100644
1023 +--- a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
1024 ++++ b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
1025 +@@ -35,6 +35,8 @@
1026 + */
1027 + #define HW_BROADWAY_ICR 0x00
1028 + #define HW_BROADWAY_IMR 0x04
1029 ++#define HW_STARLET_ICR 0x08
1030 ++#define HW_STARLET_IMR 0x0c
1031 +
1032 +
1033 + /*
1034 +@@ -74,6 +76,9 @@ static void hlwd_pic_unmask(struct irq_data *d)
1035 + void __iomem *io_base = irq_data_get_irq_chip_data(d);
1036 +
1037 + setbits32(io_base + HW_BROADWAY_IMR, 1 << irq);
1038 ++
1039 ++ /* Make sure the ARM (aka. Starlet) doesn't handle this interrupt. */
1040 ++ clrbits32(io_base + HW_STARLET_IMR, 1 << irq);
1041 + }
1042 +
1043 +
1044 +diff --git a/arch/powerpc/platforms/powermac/bootx_init.c b/arch/powerpc/platforms/powermac/bootx_init.c
1045 +index c3c9bbb3573a..ba0964c17620 100644
1046 +--- a/arch/powerpc/platforms/powermac/bootx_init.c
1047 ++++ b/arch/powerpc/platforms/powermac/bootx_init.c
1048 +@@ -468,7 +468,7 @@ void __init bootx_init(unsigned long r3, unsigned long r4)
1049 + boot_infos_t *bi = (boot_infos_t *) r4;
1050 + unsigned long hdr;
1051 + unsigned long space;
1052 +- unsigned long ptr, x;
1053 ++ unsigned long ptr;
1054 + char *model;
1055 + unsigned long offset = reloc_offset();
1056 +
1057 +@@ -562,6 +562,8 @@ void __init bootx_init(unsigned long r3, unsigned long r4)
1058 + * MMU switched OFF, so this should not be useful anymore.
1059 + */
1060 + if (bi->version < 4) {
1061 ++ unsigned long x __maybe_unused;
1062 ++
1063 + bootx_printf("Touching pages...\n");
1064 +
1065 + /*
1066 +diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
1067 +index ab668cb72263..8b2eab1340f4 100644
1068 +--- a/arch/powerpc/platforms/powermac/setup.c
1069 ++++ b/arch/powerpc/platforms/powermac/setup.c
1070 +@@ -352,6 +352,7 @@ static int pmac_late_init(void)
1071 + }
1072 + machine_late_initcall(powermac, pmac_late_init);
1073 +
1074 ++void note_bootable_part(dev_t dev, int part, int goodness);
1075 + /*
1076 + * This is __ref because we check for "initializing" before
1077 + * touching any of the __init sensitive things and "initializing"
1078 +diff --git a/arch/s390/include/asm/cpu_mf.h b/arch/s390/include/asm/cpu_mf.h
1079 +index 05480e4cc5ca..bc764a674594 100644
1080 +--- a/arch/s390/include/asm/cpu_mf.h
1081 ++++ b/arch/s390/include/asm/cpu_mf.h
1082 +@@ -116,7 +116,7 @@ struct hws_basic_entry {
1083 +
1084 + struct hws_diag_entry {
1085 + unsigned int def:16; /* 0-15 Data Entry Format */
1086 +- unsigned int R:14; /* 16-19 and 20-30 reserved */
1087 ++ unsigned int R:15; /* 16-19 and 20-30 reserved */
1088 + unsigned int I:1; /* 31 entry valid or invalid */
1089 + u8 data[]; /* Machine-dependent sample data */
1090 + } __packed;
1091 +@@ -132,7 +132,9 @@ struct hws_trailer_entry {
1092 + unsigned int f:1; /* 0 - Block Full Indicator */
1093 + unsigned int a:1; /* 1 - Alert request control */
1094 + unsigned int t:1; /* 2 - Timestamp format */
1095 +- unsigned long long:61; /* 3 - 63: Reserved */
1096 ++ unsigned int :29; /* 3 - 31: Reserved */
1097 ++ unsigned int bsdes:16; /* 32-47: size of basic SDE */
1098 ++ unsigned int dsdes:16; /* 48-63: size of diagnostic SDE */
1099 + };
1100 + unsigned long long flags; /* 0 - 63: All indicators */
1101 + };
1102 +diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
1103 +index d45e06346f14..c56cb37b88e3 100644
1104 +--- a/arch/x86/events/intel/uncore.c
1105 ++++ b/arch/x86/events/intel/uncore.c
1106 +@@ -218,7 +218,7 @@ void uncore_perf_event_update(struct intel_uncore_box *box, struct perf_event *e
1107 + u64 prev_count, new_count, delta;
1108 + int shift;
1109 +
1110 +- if (event->hw.idx >= UNCORE_PMC_IDX_FIXED)
1111 ++ if (event->hw.idx == UNCORE_PMC_IDX_FIXED)
1112 + shift = 64 - uncore_fixed_ctr_bits(box);
1113 + else
1114 + shift = 64 - uncore_perf_ctr_bits(box);
1115 +diff --git a/arch/x86/events/intel/uncore_nhmex.c b/arch/x86/events/intel/uncore_nhmex.c
1116 +index 93e7a8397cde..173e2674be6e 100644
1117 +--- a/arch/x86/events/intel/uncore_nhmex.c
1118 ++++ b/arch/x86/events/intel/uncore_nhmex.c
1119 +@@ -246,7 +246,7 @@ static void nhmex_uncore_msr_enable_event(struct intel_uncore_box *box, struct p
1120 + {
1121 + struct hw_perf_event *hwc = &event->hw;
1122 +
1123 +- if (hwc->idx >= UNCORE_PMC_IDX_FIXED)
1124 ++ if (hwc->idx == UNCORE_PMC_IDX_FIXED)
1125 + wrmsrl(hwc->config_base, NHMEX_PMON_CTL_EN_BIT0);
1126 + else if (box->pmu->type->event_mask & NHMEX_PMON_CTL_EN_BIT0)
1127 + wrmsrl(hwc->config_base, hwc->config | NHMEX_PMON_CTL_EN_BIT22);
1128 +diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
1129 +index c8e0cda0f272..4fc0e08a30b9 100644
1130 +--- a/arch/x86/kernel/cpu/microcode/core.c
1131 ++++ b/arch/x86/kernel/cpu/microcode/core.c
1132 +@@ -70,7 +70,7 @@ static DEFINE_MUTEX(microcode_mutex);
1133 + /*
1134 + * Serialize late loading so that CPUs get updated one-by-one.
1135 + */
1136 +-static DEFINE_SPINLOCK(update_lock);
1137 ++static DEFINE_RAW_SPINLOCK(update_lock);
1138 +
1139 + struct ucode_cpu_info ucode_cpu_info[NR_CPUS];
1140 +
1141 +@@ -560,9 +560,9 @@ static int __reload_late(void *info)
1142 + if (__wait_for_cpus(&late_cpus_in, NSEC_PER_SEC))
1143 + return -1;
1144 +
1145 +- spin_lock(&update_lock);
1146 ++ raw_spin_lock(&update_lock);
1147 + apply_microcode_local(&err);
1148 +- spin_unlock(&update_lock);
1149 ++ raw_spin_unlock(&update_lock);
1150 +
1151 + /* siblings return UCODE_OK because their engine got updated already */
1152 + if (err > UCODE_NFOUND) {
1153 +diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
1154 +index 43bbece92632..2ef2f1fe875b 100644
1155 +--- a/arch/x86/kvm/mmu.c
1156 ++++ b/arch/x86/kvm/mmu.c
1157 +@@ -890,7 +890,7 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
1158 + if (cache->nobjs >= min)
1159 + return 0;
1160 + while (cache->nobjs < ARRAY_SIZE(cache->objects)) {
1161 +- page = (void *)__get_free_page(GFP_KERNEL);
1162 ++ page = (void *)__get_free_page(GFP_KERNEL_ACCOUNT);
1163 + if (!page)
1164 + return -ENOMEM;
1165 + cache->objects[cache->nobjs++] = page;
1166 +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
1167 +index 56c9cd01fd1d..4a4b7d3c909a 100644
1168 +--- a/block/bfq-iosched.c
1169 ++++ b/block/bfq-iosched.c
1170 +@@ -1678,7 +1678,6 @@ static void bfq_requests_merged(struct request_queue *q, struct request *rq,
1171 +
1172 + if (!RB_EMPTY_NODE(&rq->rb_node))
1173 + goto end;
1174 +- spin_lock_irq(&bfqq->bfqd->lock);
1175 +
1176 + /*
1177 + * If next and rq belong to the same bfq_queue and next is older
1178 +@@ -1702,7 +1701,6 @@ static void bfq_requests_merged(struct request_queue *q, struct request *rq,
1179 +
1180 + bfq_remove_request(q, next);
1181 +
1182 +- spin_unlock_irq(&bfqq->bfqd->lock);
1183 + end:
1184 + bfqg_stats_update_io_merged(bfqq_group(bfqq), next->cmd_flags);
1185 + }
1186 +diff --git a/block/bio.c b/block/bio.c
1187 +index 90f19d7df66c..194d28cdc642 100644
1188 +--- a/block/bio.c
1189 ++++ b/block/bio.c
1190 +@@ -881,16 +881,16 @@ EXPORT_SYMBOL(bio_add_page);
1191 + */
1192 + int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
1193 + {
1194 +- unsigned short nr_pages = bio->bi_max_vecs - bio->bi_vcnt;
1195 ++ unsigned short nr_pages = bio->bi_max_vecs - bio->bi_vcnt, idx;
1196 + struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt;
1197 + struct page **pages = (struct page **)bv;
1198 +- size_t offset, diff;
1199 ++ size_t offset;
1200 + ssize_t size;
1201 +
1202 + size = iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset);
1203 + if (unlikely(size <= 0))
1204 + return size ? size : -EFAULT;
1205 +- nr_pages = (size + offset + PAGE_SIZE - 1) / PAGE_SIZE;
1206 ++ idx = nr_pages = (size + offset + PAGE_SIZE - 1) / PAGE_SIZE;
1207 +
1208 + /*
1209 + * Deep magic below: We need to walk the pinned pages backwards
1210 +@@ -903,17 +903,15 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
1211 + bio->bi_iter.bi_size += size;
1212 + bio->bi_vcnt += nr_pages;
1213 +
1214 +- diff = (nr_pages * PAGE_SIZE - offset) - size;
1215 +- while (nr_pages--) {
1216 +- bv[nr_pages].bv_page = pages[nr_pages];
1217 +- bv[nr_pages].bv_len = PAGE_SIZE;
1218 +- bv[nr_pages].bv_offset = 0;
1219 ++ while (idx--) {
1220 ++ bv[idx].bv_page = pages[idx];
1221 ++ bv[idx].bv_len = PAGE_SIZE;
1222 ++ bv[idx].bv_offset = 0;
1223 + }
1224 +
1225 + bv[0].bv_offset += offset;
1226 + bv[0].bv_len -= offset;
1227 +- if (diff)
1228 +- bv[bio->bi_vcnt - 1].bv_len -= diff;
1229 ++ bv[nr_pages - 1].bv_len -= nr_pages * PAGE_SIZE - offset - size;
1230 +
1231 + iov_iter_advance(iter, size);
1232 + return 0;
1233 +@@ -1891,6 +1889,7 @@ struct bio *bio_split(struct bio *bio, int sectors,
1234 + bio_integrity_trim(split);
1235 +
1236 + bio_advance(bio, split->bi_iter.bi_size);
1237 ++ bio->bi_iter.bi_done = 0;
1238 +
1239 + if (bio_flagged(bio, BIO_TRACE_COMPLETION))
1240 + bio_set_flag(split, BIO_TRACE_COMPLETION);
1241 +diff --git a/crypto/authenc.c b/crypto/authenc.c
1242 +index 875470b0e026..0db344d5a01a 100644
1243 +--- a/crypto/authenc.c
1244 ++++ b/crypto/authenc.c
1245 +@@ -108,6 +108,7 @@ static int crypto_authenc_setkey(struct crypto_aead *authenc, const u8 *key,
1246 + CRYPTO_TFM_RES_MASK);
1247 +
1248 + out:
1249 ++ memzero_explicit(&keys, sizeof(keys));
1250 + return err;
1251 +
1252 + badkey:
1253 +diff --git a/crypto/authencesn.c b/crypto/authencesn.c
1254 +index 0cf5fefdb859..6de852ce4cf8 100644
1255 +--- a/crypto/authencesn.c
1256 ++++ b/crypto/authencesn.c
1257 +@@ -90,6 +90,7 @@ static int crypto_authenc_esn_setkey(struct crypto_aead *authenc_esn, const u8 *
1258 + CRYPTO_TFM_RES_MASK);
1259 +
1260 + out:
1261 ++ memzero_explicit(&keys, sizeof(keys));
1262 + return err;
1263 +
1264 + badkey:
1265 +diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
1266 +index 602ae58ee2d8..75c3cb377b98 100644
1267 +--- a/drivers/acpi/acpi_lpss.c
1268 ++++ b/drivers/acpi/acpi_lpss.c
1269 +@@ -69,6 +69,10 @@ ACPI_MODULE_NAME("acpi_lpss");
1270 + #define LPSS_SAVE_CTX BIT(4)
1271 + #define LPSS_NO_D3_DELAY BIT(5)
1272 +
1273 ++/* Crystal Cove PMIC shares same ACPI ID between different platforms */
1274 ++#define BYT_CRC_HRV 2
1275 ++#define CHT_CRC_HRV 3
1276 ++
1277 + struct lpss_private_data;
1278 +
1279 + struct lpss_device_desc {
1280 +@@ -162,7 +166,7 @@ static void byt_pwm_setup(struct lpss_private_data *pdata)
1281 + if (!adev->pnp.unique_id || strcmp(adev->pnp.unique_id, "1"))
1282 + return;
1283 +
1284 +- if (!acpi_dev_present("INT33FD", NULL, -1))
1285 ++ if (!acpi_dev_present("INT33FD", NULL, BYT_CRC_HRV))
1286 + pwm_add_table(byt_pwm_lookup, ARRAY_SIZE(byt_pwm_lookup));
1287 + }
1288 +
1289 +diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
1290 +index 6fc204a52493..eb857d6ea1fe 100644
1291 +--- a/drivers/acpi/pci_root.c
1292 ++++ b/drivers/acpi/pci_root.c
1293 +@@ -472,9 +472,11 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm)
1294 + }
1295 +
1296 + control = OSC_PCI_EXPRESS_CAPABILITY_CONTROL
1297 +- | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
1298 + | OSC_PCI_EXPRESS_PME_CONTROL;
1299 +
1300 ++ if (IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))
1301 ++ control |= OSC_PCI_EXPRESS_NATIVE_HP_CONTROL;
1302 ++
1303 + if (pci_aer_available()) {
1304 + if (aer_acpi_firmware_first())
1305 + dev_info(&device->dev,
1306 +diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
1307 +index 711dd91b5e2c..2651c81d1edf 100644
1308 +--- a/drivers/ata/libata-eh.c
1309 ++++ b/drivers/ata/libata-eh.c
1310 +@@ -2217,12 +2217,16 @@ static void ata_eh_link_autopsy(struct ata_link *link)
1311 + if (qc->err_mask & ~AC_ERR_OTHER)
1312 + qc->err_mask &= ~AC_ERR_OTHER;
1313 +
1314 +- /* SENSE_VALID trumps dev/unknown error and revalidation */
1315 ++ /*
1316 ++ * SENSE_VALID trumps dev/unknown error and revalidation. Upper
1317 ++ * layers will determine whether the command is worth retrying
1318 ++ * based on the sense data and device class/type. Otherwise,
1319 ++ * determine directly if the command is worth retrying using its
1320 ++ * error mask and flags.
1321 ++ */
1322 + if (qc->flags & ATA_QCFLAG_SENSE_VALID)
1323 + qc->err_mask &= ~(AC_ERR_DEV | AC_ERR_OTHER);
1324 +-
1325 +- /* determine whether the command is worth retrying */
1326 +- if (ata_eh_worth_retry(qc))
1327 ++ else if (ata_eh_worth_retry(qc))
1328 + qc->flags |= ATA_QCFLAG_RETRY;
1329 +
1330 + /* accumulate error info */
1331 +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
1332 +index 86d7975afaeb..819521d5895e 100644
1333 +--- a/drivers/bluetooth/btusb.c
1334 ++++ b/drivers/bluetooth/btusb.c
1335 +@@ -279,6 +279,7 @@ static const struct usb_device_id blacklist_table[] = {
1336 + { USB_DEVICE(0x04ca, 0x3011), .driver_info = BTUSB_QCA_ROME },
1337 + { USB_DEVICE(0x04ca, 0x3015), .driver_info = BTUSB_QCA_ROME },
1338 + { USB_DEVICE(0x04ca, 0x3016), .driver_info = BTUSB_QCA_ROME },
1339 ++ { USB_DEVICE(0x04ca, 0x301a), .driver_info = BTUSB_QCA_ROME },
1340 +
1341 + /* Broadcom BCM2035 */
1342 + { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 },
1343 +@@ -373,6 +374,9 @@ static const struct usb_device_id blacklist_table[] = {
1344 + /* Additional Realtek 8723BU Bluetooth devices */
1345 + { USB_DEVICE(0x7392, 0xa611), .driver_info = BTUSB_REALTEK },
1346 +
1347 ++ /* Additional Realtek 8723DE Bluetooth devices */
1348 ++ { USB_DEVICE(0x2ff8, 0xb011), .driver_info = BTUSB_REALTEK },
1349 ++
1350 + /* Additional Realtek 8821AE Bluetooth devices */
1351 + { USB_DEVICE(0x0b05, 0x17dc), .driver_info = BTUSB_REALTEK },
1352 + { USB_DEVICE(0x13d3, 0x3414), .driver_info = BTUSB_REALTEK },
1353 +diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
1354 +index 6f4ebd5e54c8..a6173ddfb5a7 100644
1355 +--- a/drivers/bluetooth/hci_qca.c
1356 ++++ b/drivers/bluetooth/hci_qca.c
1357 +@@ -881,7 +881,7 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
1358 + */
1359 + set_current_state(TASK_UNINTERRUPTIBLE);
1360 + schedule_timeout(msecs_to_jiffies(BAUDRATE_SETTLE_TIMEOUT_MS));
1361 +- set_current_state(TASK_INTERRUPTIBLE);
1362 ++ set_current_state(TASK_RUNNING);
1363 +
1364 + return 0;
1365 + }
1366 +diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c
1367 +index 72fd1750134d..942d076cbb0a 100644
1368 +--- a/drivers/bus/arm-ccn.c
1369 ++++ b/drivers/bus/arm-ccn.c
1370 +@@ -736,7 +736,7 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
1371 + ccn = pmu_to_arm_ccn(event->pmu);
1372 +
1373 + if (hw->sample_period) {
1374 +- dev_warn(ccn->dev, "Sampling not supported!\n");
1375 ++ dev_dbg(ccn->dev, "Sampling not supported!\n");
1376 + return -EOPNOTSUPP;
1377 + }
1378 +
1379 +@@ -744,12 +744,12 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
1380 + event->attr.exclude_kernel || event->attr.exclude_hv ||
1381 + event->attr.exclude_idle || event->attr.exclude_host ||
1382 + event->attr.exclude_guest) {
1383 +- dev_warn(ccn->dev, "Can't exclude execution levels!\n");
1384 ++ dev_dbg(ccn->dev, "Can't exclude execution levels!\n");
1385 + return -EINVAL;
1386 + }
1387 +
1388 + if (event->cpu < 0) {
1389 +- dev_warn(ccn->dev, "Can't provide per-task data!\n");
1390 ++ dev_dbg(ccn->dev, "Can't provide per-task data!\n");
1391 + return -EOPNOTSUPP;
1392 + }
1393 + /*
1394 +@@ -771,13 +771,13 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
1395 + switch (type) {
1396 + case CCN_TYPE_MN:
1397 + if (node_xp != ccn->mn_id) {
1398 +- dev_warn(ccn->dev, "Invalid MN ID %d!\n", node_xp);
1399 ++ dev_dbg(ccn->dev, "Invalid MN ID %d!\n", node_xp);
1400 + return -EINVAL;
1401 + }
1402 + break;
1403 + case CCN_TYPE_XP:
1404 + if (node_xp >= ccn->num_xps) {
1405 +- dev_warn(ccn->dev, "Invalid XP ID %d!\n", node_xp);
1406 ++ dev_dbg(ccn->dev, "Invalid XP ID %d!\n", node_xp);
1407 + return -EINVAL;
1408 + }
1409 + break;
1410 +@@ -785,11 +785,11 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
1411 + break;
1412 + default:
1413 + if (node_xp >= ccn->num_nodes) {
1414 +- dev_warn(ccn->dev, "Invalid node ID %d!\n", node_xp);
1415 ++ dev_dbg(ccn->dev, "Invalid node ID %d!\n", node_xp);
1416 + return -EINVAL;
1417 + }
1418 + if (!arm_ccn_pmu_type_eq(type, ccn->node[node_xp].type)) {
1419 +- dev_warn(ccn->dev, "Invalid type 0x%x for node %d!\n",
1420 ++ dev_dbg(ccn->dev, "Invalid type 0x%x for node %d!\n",
1421 + type, node_xp);
1422 + return -EINVAL;
1423 + }
1424 +@@ -808,19 +808,19 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
1425 + if (event_id != e->event)
1426 + continue;
1427 + if (e->num_ports && port >= e->num_ports) {
1428 +- dev_warn(ccn->dev, "Invalid port %d for node/XP %d!\n",
1429 ++ dev_dbg(ccn->dev, "Invalid port %d for node/XP %d!\n",
1430 + port, node_xp);
1431 + return -EINVAL;
1432 + }
1433 + if (e->num_vcs && vc >= e->num_vcs) {
1434 +- dev_warn(ccn->dev, "Invalid vc %d for node/XP %d!\n",
1435 ++ dev_dbg(ccn->dev, "Invalid vc %d for node/XP %d!\n",
1436 + vc, node_xp);
1437 + return -EINVAL;
1438 + }
1439 + valid = 1;
1440 + }
1441 + if (!valid) {
1442 +- dev_warn(ccn->dev, "Invalid event 0x%x for node/XP %d!\n",
1443 ++ dev_dbg(ccn->dev, "Invalid event 0x%x for node/XP %d!\n",
1444 + event_id, node_xp);
1445 + return -EINVAL;
1446 + }
1447 +diff --git a/drivers/char/random.c b/drivers/char/random.c
1448 +index ddc493d976fd..ea4dbfa30657 100644
1449 +--- a/drivers/char/random.c
1450 ++++ b/drivers/char/random.c
1451 +@@ -1897,14 +1897,22 @@ static int
1452 + write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
1453 + {
1454 + size_t bytes;
1455 +- __u32 buf[16];
1456 ++ __u32 t, buf[16];
1457 + const char __user *p = buffer;
1458 +
1459 + while (count > 0) {
1460 ++ int b, i = 0;
1461 ++
1462 + bytes = min(count, sizeof(buf));
1463 + if (copy_from_user(&buf, p, bytes))
1464 + return -EFAULT;
1465 +
1466 ++ for (b = bytes ; b > 0 ; b -= sizeof(__u32), i++) {
1467 ++ if (!arch_get_random_int(&t))
1468 ++ break;
1469 ++ buf[i] ^= t;
1470 ++ }
1471 ++
1472 + count -= bytes;
1473 + p += bytes;
1474 +
1475 +diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
1476 +index 346c4987b284..38983f56ad0d 100644
1477 +--- a/drivers/edac/altera_edac.c
1478 ++++ b/drivers/edac/altera_edac.c
1479 +@@ -1106,7 +1106,7 @@ static void *ocram_alloc_mem(size_t size, void **other)
1480 +
1481 + static void ocram_free_mem(void *p, size_t size, void *other)
1482 + {
1483 +- gen_pool_free((struct gen_pool *)other, (u32)p, size);
1484 ++ gen_pool_free((struct gen_pool *)other, (unsigned long)p, size);
1485 + }
1486 +
1487 + static const struct edac_device_prv_data ocramecc_data = {
1488 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
1489 +index 1360a24d2ede..f08624f2f209 100644
1490 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
1491 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
1492 +@@ -683,8 +683,12 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
1493 + return -EINVAL;
1494 +
1495 + /* A shared bo cannot be migrated to VRAM */
1496 +- if (bo->prime_shared_count && (domain == AMDGPU_GEM_DOMAIN_VRAM))
1497 +- return -EINVAL;
1498 ++ if (bo->prime_shared_count) {
1499 ++ if (domain & AMDGPU_GEM_DOMAIN_GTT)
1500 ++ domain = AMDGPU_GEM_DOMAIN_GTT;
1501 ++ else
1502 ++ return -EINVAL;
1503 ++ }
1504 +
1505 + if (bo->pin_count) {
1506 + uint32_t mem_type = bo->tbo.mem.mem_type;
1507 +diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
1508 +index 0d8a417e2cd6..bb5cc15fa0b9 100644
1509 +--- a/drivers/gpu/drm/drm_atomic.c
1510 ++++ b/drivers/gpu/drm/drm_atomic.c
1511 +@@ -1355,7 +1355,9 @@ drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
1512 + {
1513 + struct drm_plane *plane = plane_state->plane;
1514 + struct drm_crtc_state *crtc_state;
1515 +-
1516 ++ /* Nothing to do for same crtc*/
1517 ++ if (plane_state->crtc == crtc)
1518 ++ return 0;
1519 + if (plane_state->crtc) {
1520 + crtc_state = drm_atomic_get_crtc_state(plane_state->state,
1521 + plane_state->crtc);
1522 +diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
1523 +index 0028591f3f95..1f08d597b87a 100644
1524 +--- a/drivers/gpu/drm/drm_atomic_helper.c
1525 ++++ b/drivers/gpu/drm/drm_atomic_helper.c
1526 +@@ -2683,31 +2683,9 @@ commit:
1527 + return 0;
1528 + }
1529 +
1530 +-/**
1531 +- * drm_atomic_helper_disable_all - disable all currently active outputs
1532 +- * @dev: DRM device
1533 +- * @ctx: lock acquisition context
1534 +- *
1535 +- * Loops through all connectors, finding those that aren't turned off and then
1536 +- * turns them off by setting their DPMS mode to OFF and deactivating the CRTC
1537 +- * that they are connected to.
1538 +- *
1539 +- * This is used for example in suspend/resume to disable all currently active
1540 +- * functions when suspending. If you just want to shut down everything at e.g.
1541 +- * driver unload, look at drm_atomic_helper_shutdown().
1542 +- *
1543 +- * Note that if callers haven't already acquired all modeset locks this might
1544 +- * return -EDEADLK, which must be handled by calling drm_modeset_backoff().
1545 +- *
1546 +- * Returns:
1547 +- * 0 on success or a negative error code on failure.
1548 +- *
1549 +- * See also:
1550 +- * drm_atomic_helper_suspend(), drm_atomic_helper_resume() and
1551 +- * drm_atomic_helper_shutdown().
1552 +- */
1553 +-int drm_atomic_helper_disable_all(struct drm_device *dev,
1554 +- struct drm_modeset_acquire_ctx *ctx)
1555 ++static int __drm_atomic_helper_disable_all(struct drm_device *dev,
1556 ++ struct drm_modeset_acquire_ctx *ctx,
1557 ++ bool clean_old_fbs)
1558 + {
1559 + struct drm_atomic_state *state;
1560 + struct drm_connector_state *conn_state;
1561 +@@ -2759,8 +2737,11 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
1562 + goto free;
1563 +
1564 + drm_atomic_set_fb_for_plane(plane_state, NULL);
1565 +- plane_mask |= BIT(drm_plane_index(plane));
1566 +- plane->old_fb = plane->fb;
1567 ++
1568 ++ if (clean_old_fbs) {
1569 ++ plane->old_fb = plane->fb;
1570 ++ plane_mask |= BIT(drm_plane_index(plane));
1571 ++ }
1572 + }
1573 +
1574 + ret = drm_atomic_commit(state);
1575 +@@ -2771,6 +2752,34 @@ free:
1576 + return ret;
1577 + }
1578 +
1579 ++/**
1580 ++ * drm_atomic_helper_disable_all - disable all currently active outputs
1581 ++ * @dev: DRM device
1582 ++ * @ctx: lock acquisition context
1583 ++ *
1584 ++ * Loops through all connectors, finding those that aren't turned off and then
1585 ++ * turns them off by setting their DPMS mode to OFF and deactivating the CRTC
1586 ++ * that they are connected to.
1587 ++ *
1588 ++ * This is used for example in suspend/resume to disable all currently active
1589 ++ * functions when suspending. If you just want to shut down everything at e.g.
1590 ++ * driver unload, look at drm_atomic_helper_shutdown().
1591 ++ *
1592 ++ * Note that if callers haven't already acquired all modeset locks this might
1593 ++ * return -EDEADLK, which must be handled by calling drm_modeset_backoff().
1594 ++ *
1595 ++ * Returns:
1596 ++ * 0 on success or a negative error code on failure.
1597 ++ *
1598 ++ * See also:
1599 ++ * drm_atomic_helper_suspend(), drm_atomic_helper_resume() and
1600 ++ * drm_atomic_helper_shutdown().
1601 ++ */
1602 ++int drm_atomic_helper_disable_all(struct drm_device *dev,
1603 ++ struct drm_modeset_acquire_ctx *ctx)
1604 ++{
1605 ++ return __drm_atomic_helper_disable_all(dev, ctx, false);
1606 ++}
1607 + EXPORT_SYMBOL(drm_atomic_helper_disable_all);
1608 +
1609 + /**
1610 +@@ -2793,7 +2802,7 @@ void drm_atomic_helper_shutdown(struct drm_device *dev)
1611 + while (1) {
1612 + ret = drm_modeset_lock_all_ctx(dev, &ctx);
1613 + if (!ret)
1614 +- ret = drm_atomic_helper_disable_all(dev, &ctx);
1615 ++ ret = __drm_atomic_helper_disable_all(dev, &ctx, true);
1616 +
1617 + if (ret != -EDEADLK)
1618 + break;
1619 +@@ -2897,16 +2906,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
1620 + struct drm_connector_state *new_conn_state;
1621 + struct drm_crtc *crtc;
1622 + struct drm_crtc_state *new_crtc_state;
1623 +- unsigned plane_mask = 0;
1624 +- struct drm_device *dev = state->dev;
1625 +- int ret;
1626 +
1627 + state->acquire_ctx = ctx;
1628 +
1629 +- for_each_new_plane_in_state(state, plane, new_plane_state, i) {
1630 +- plane_mask |= BIT(drm_plane_index(plane));
1631 ++ for_each_new_plane_in_state(state, plane, new_plane_state, i)
1632 + state->planes[i].old_state = plane->state;
1633 +- }
1634 +
1635 + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
1636 + state->crtcs[i].old_state = crtc->state;
1637 +@@ -2914,11 +2918,7 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
1638 + for_each_new_connector_in_state(state, connector, new_conn_state, i)
1639 + state->connectors[i].old_state = connector->state;
1640 +
1641 +- ret = drm_atomic_commit(state);
1642 +- if (plane_mask)
1643 +- drm_atomic_clean_old_fb(dev, plane_mask, ret);
1644 +-
1645 +- return ret;
1646 ++ return drm_atomic_commit(state);
1647 + }
1648 + EXPORT_SYMBOL(drm_atomic_helper_commit_duplicated_state);
1649 +
1650 +diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
1651 +index 41b492f99955..c022ab6e84bd 100644
1652 +--- a/drivers/gpu/drm/drm_dp_mst_topology.c
1653 ++++ b/drivers/gpu/drm/drm_dp_mst_topology.c
1654 +@@ -2862,12 +2862,14 @@ static void drm_dp_mst_dump_mstb(struct seq_file *m,
1655 + }
1656 + }
1657 +
1658 ++#define DP_PAYLOAD_TABLE_SIZE 64
1659 ++
1660 + static bool dump_dp_payload_table(struct drm_dp_mst_topology_mgr *mgr,
1661 + char *buf)
1662 + {
1663 + int i;
1664 +
1665 +- for (i = 0; i < 64; i += 16) {
1666 ++ for (i = 0; i < DP_PAYLOAD_TABLE_SIZE; i += 16) {
1667 + if (drm_dp_dpcd_read(mgr->aux,
1668 + DP_PAYLOAD_TABLE_UPDATE_STATUS + i,
1669 + &buf[i], 16) != 16)
1670 +@@ -2936,7 +2938,7 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
1671 +
1672 + mutex_lock(&mgr->lock);
1673 + if (mgr->mst_primary) {
1674 +- u8 buf[64];
1675 ++ u8 buf[DP_PAYLOAD_TABLE_SIZE];
1676 + int ret;
1677 +
1678 + ret = drm_dp_dpcd_read(mgr->aux, DP_DPCD_REV, buf, DP_RECEIVER_CAP_SIZE);
1679 +@@ -2954,8 +2956,7 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
1680 + seq_printf(m, " revision: hw: %x.%x sw: %x.%x\n",
1681 + buf[0x9] >> 4, buf[0x9] & 0xf, buf[0xa], buf[0xb]);
1682 + if (dump_dp_payload_table(mgr, buf))
1683 +- seq_printf(m, "payload table: %*ph\n", 63, buf);
1684 +-
1685 ++ seq_printf(m, "payload table: %*ph\n", DP_PAYLOAD_TABLE_SIZE, buf);
1686 + }
1687 +
1688 + mutex_unlock(&mgr->lock);
1689 +diff --git a/drivers/gpu/drm/gma500/psb_intel_drv.h b/drivers/gpu/drm/gma500/psb_intel_drv.h
1690 +index e8e4ea14b12b..e05e5399af2d 100644
1691 +--- a/drivers/gpu/drm/gma500/psb_intel_drv.h
1692 ++++ b/drivers/gpu/drm/gma500/psb_intel_drv.h
1693 +@@ -255,7 +255,7 @@ extern int intelfb_remove(struct drm_device *dev,
1694 + extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
1695 + const struct drm_display_mode *mode,
1696 + struct drm_display_mode *adjusted_mode);
1697 +-extern int psb_intel_lvds_mode_valid(struct drm_connector *connector,
1698 ++extern enum drm_mode_status psb_intel_lvds_mode_valid(struct drm_connector *connector,
1699 + struct drm_display_mode *mode);
1700 + extern int psb_intel_lvds_set_property(struct drm_connector *connector,
1701 + struct drm_property *property,
1702 +diff --git a/drivers/gpu/drm/gma500/psb_intel_lvds.c b/drivers/gpu/drm/gma500/psb_intel_lvds.c
1703 +index be3eefec5152..8baf6325c6e4 100644
1704 +--- a/drivers/gpu/drm/gma500/psb_intel_lvds.c
1705 ++++ b/drivers/gpu/drm/gma500/psb_intel_lvds.c
1706 +@@ -343,7 +343,7 @@ static void psb_intel_lvds_restore(struct drm_connector *connector)
1707 + }
1708 + }
1709 +
1710 +-int psb_intel_lvds_mode_valid(struct drm_connector *connector,
1711 ++enum drm_mode_status psb_intel_lvds_mode_valid(struct drm_connector *connector,
1712 + struct drm_display_mode *mode)
1713 + {
1714 + struct drm_psb_private *dev_priv = connector->dev->dev_private;
1715 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
1716 +index a7e55c422501..0b632dc0cf7d 100644
1717 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
1718 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
1719 +@@ -155,10 +155,10 @@ gk104_fifo_runlist_commit(struct gk104_fifo *fifo, int runl)
1720 + (target << 28));
1721 + nvkm_wr32(device, 0x002274, (runl << 20) | nr);
1722 +
1723 +- if (wait_event_timeout(fifo->runlist[runl].wait,
1724 +- !(nvkm_rd32(device, 0x002284 + (runl * 0x08))
1725 +- & 0x00100000),
1726 +- msecs_to_jiffies(2000)) == 0)
1727 ++ if (nvkm_msec(device, 2000,
1728 ++ if (!(nvkm_rd32(device, 0x002284 + (runl * 0x08)) & 0x00100000))
1729 ++ break;
1730 ++ ) < 0)
1731 + nvkm_error(subdev, "runlist %d update timeout\n", runl);
1732 + unlock:
1733 + mutex_unlock(&subdev->mutex);
1734 +diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
1735 +index 424cd1b66575..337d3a1c2a40 100644
1736 +--- a/drivers/gpu/drm/radeon/radeon_connectors.c
1737 ++++ b/drivers/gpu/drm/radeon/radeon_connectors.c
1738 +@@ -853,7 +853,7 @@ static int radeon_lvds_get_modes(struct drm_connector *connector)
1739 + return ret;
1740 + }
1741 +
1742 +-static int radeon_lvds_mode_valid(struct drm_connector *connector,
1743 ++static enum drm_mode_status radeon_lvds_mode_valid(struct drm_connector *connector,
1744 + struct drm_display_mode *mode)
1745 + {
1746 + struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1747 +@@ -1013,7 +1013,7 @@ static int radeon_vga_get_modes(struct drm_connector *connector)
1748 + return ret;
1749 + }
1750 +
1751 +-static int radeon_vga_mode_valid(struct drm_connector *connector,
1752 ++static enum drm_mode_status radeon_vga_mode_valid(struct drm_connector *connector,
1753 + struct drm_display_mode *mode)
1754 + {
1755 + struct drm_device *dev = connector->dev;
1756 +@@ -1157,7 +1157,7 @@ static int radeon_tv_get_modes(struct drm_connector *connector)
1757 + return 1;
1758 + }
1759 +
1760 +-static int radeon_tv_mode_valid(struct drm_connector *connector,
1761 ++static enum drm_mode_status radeon_tv_mode_valid(struct drm_connector *connector,
1762 + struct drm_display_mode *mode)
1763 + {
1764 + if ((mode->hdisplay > 1024) || (mode->vdisplay > 768))
1765 +@@ -1499,7 +1499,7 @@ static void radeon_dvi_force(struct drm_connector *connector)
1766 + radeon_connector->use_digital = true;
1767 + }
1768 +
1769 +-static int radeon_dvi_mode_valid(struct drm_connector *connector,
1770 ++static enum drm_mode_status radeon_dvi_mode_valid(struct drm_connector *connector,
1771 + struct drm_display_mode *mode)
1772 + {
1773 + struct drm_device *dev = connector->dev;
1774 +@@ -1801,7 +1801,7 @@ out:
1775 + return ret;
1776 + }
1777 +
1778 +-static int radeon_dp_mode_valid(struct drm_connector *connector,
1779 ++static enum drm_mode_status radeon_dp_mode_valid(struct drm_connector *connector,
1780 + struct drm_display_mode *mode)
1781 + {
1782 + struct drm_device *dev = connector->dev;
1783 +diff --git a/drivers/hid/hid-plantronics.c b/drivers/hid/hid-plantronics.c
1784 +index febb21ee190e..584b10d3fc3d 100644
1785 +--- a/drivers/hid/hid-plantronics.c
1786 ++++ b/drivers/hid/hid-plantronics.c
1787 +@@ -2,7 +2,7 @@
1788 + * Plantronics USB HID Driver
1789 + *
1790 + * Copyright (c) 2014 JD Cole <jd.cole@×××××××××××.com>
1791 +- * Copyright (c) 2015 Terry Junge <terry.junge@×××××××××××.com>
1792 ++ * Copyright (c) 2015-2018 Terry Junge <terry.junge@×××××××××××.com>
1793 + */
1794 +
1795 + /*
1796 +@@ -48,6 +48,10 @@ static int plantronics_input_mapping(struct hid_device *hdev,
1797 + unsigned short mapped_key;
1798 + unsigned long plt_type = (unsigned long)hid_get_drvdata(hdev);
1799 +
1800 ++ /* special case for PTT products */
1801 ++ if (field->application == HID_GD_JOYSTICK)
1802 ++ goto defaulted;
1803 ++
1804 + /* handle volume up/down mapping */
1805 + /* non-standard types or multi-HID interfaces - plt_type is PID */
1806 + if (!(plt_type & HID_USAGE_PAGE)) {
1807 +diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
1808 +index d92827556389..136a34dc31b8 100644
1809 +--- a/drivers/hid/i2c-hid/i2c-hid.c
1810 ++++ b/drivers/hid/i2c-hid/i2c-hid.c
1811 +@@ -1036,6 +1036,14 @@ static int i2c_hid_probe(struct i2c_client *client,
1812 + pm_runtime_enable(&client->dev);
1813 + device_enable_async_suspend(&client->dev);
1814 +
1815 ++ /* Make sure there is something at this address */
1816 ++ ret = i2c_smbus_read_byte(client);
1817 ++ if (ret < 0) {
1818 ++ dev_dbg(&client->dev, "nothing at this address: %d\n", ret);
1819 ++ ret = -ENXIO;
1820 ++ goto err_pm;
1821 ++ }
1822 ++
1823 + ret = i2c_hid_fetch_hid_descriptor(ihid);
1824 + if (ret < 0)
1825 + goto err_pm;
1826 +diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
1827 +index 56e46581b84b..6f2fe63e8f5a 100644
1828 +--- a/drivers/i2c/i2c-core-base.c
1829 ++++ b/drivers/i2c/i2c-core-base.c
1830 +@@ -808,8 +808,11 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
1831 + */
1832 + void i2c_unregister_device(struct i2c_client *client)
1833 + {
1834 +- if (client->dev.of_node)
1835 ++ if (client->dev.of_node) {
1836 + of_node_clear_flag(client->dev.of_node, OF_POPULATED);
1837 ++ of_node_put(client->dev.of_node);
1838 ++ }
1839 ++
1840 + if (ACPI_COMPANION(&client->dev))
1841 + acpi_device_clear_enumerated(ACPI_COMPANION(&client->dev));
1842 + device_unregister(&client->dev);
1843 +diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
1844 +index d8efdc191c27..55252079faf6 100644
1845 +--- a/drivers/infiniband/core/mad.c
1846 ++++ b/drivers/infiniband/core/mad.c
1847 +@@ -1558,7 +1558,8 @@ static int add_oui_reg_req(struct ib_mad_reg_req *mad_reg_req,
1848 + mad_reg_req->oui, 3)) {
1849 + method = &(*vendor_table)->vendor_class[
1850 + vclass]->method_table[i];
1851 +- BUG_ON(!*method);
1852 ++ if (!*method)
1853 ++ goto error3;
1854 + goto check_in_use;
1855 + }
1856 + }
1857 +@@ -1568,10 +1569,12 @@ static int add_oui_reg_req(struct ib_mad_reg_req *mad_reg_req,
1858 + vclass]->oui[i])) {
1859 + method = &(*vendor_table)->vendor_class[
1860 + vclass]->method_table[i];
1861 +- BUG_ON(*method);
1862 + /* Allocate method table for this OUI */
1863 +- if ((ret = allocate_method_table(method)))
1864 +- goto error3;
1865 ++ if (!*method) {
1866 ++ ret = allocate_method_table(method);
1867 ++ if (ret)
1868 ++ goto error3;
1869 ++ }
1870 + memcpy((*vendor_table)->vendor_class[vclass]->oui[i],
1871 + mad_reg_req->oui, 3);
1872 + goto check_in_use;
1873 +diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
1874 +index e47baf0950e3..a22b992cde38 100644
1875 +--- a/drivers/infiniband/core/ucma.c
1876 ++++ b/drivers/infiniband/core/ucma.c
1877 +@@ -218,7 +218,7 @@ static struct ucma_multicast* ucma_alloc_multicast(struct ucma_context *ctx)
1878 + return NULL;
1879 +
1880 + mutex_lock(&mut);
1881 +- mc->id = idr_alloc(&multicast_idr, mc, 0, 0, GFP_KERNEL);
1882 ++ mc->id = idr_alloc(&multicast_idr, NULL, 0, 0, GFP_KERNEL);
1883 + mutex_unlock(&mut);
1884 + if (mc->id < 0)
1885 + goto error;
1886 +@@ -1404,6 +1404,10 @@ static ssize_t ucma_process_join(struct ucma_file *file,
1887 + goto err3;
1888 + }
1889 +
1890 ++ mutex_lock(&mut);
1891 ++ idr_replace(&multicast_idr, mc, mc->id);
1892 ++ mutex_unlock(&mut);
1893 ++
1894 + mutex_unlock(&file->mut);
1895 + ucma_put_ctx(ctx);
1896 + return 0;
1897 +diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
1898 +index 186dce6bba8f..b8229d7b0ff5 100644
1899 +--- a/drivers/infiniband/core/uverbs_cmd.c
1900 ++++ b/drivers/infiniband/core/uverbs_cmd.c
1901 +@@ -3376,6 +3376,11 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
1902 + goto err_uobj;
1903 + }
1904 +
1905 ++ if (qp->qp_type != IB_QPT_UD && qp->qp_type != IB_QPT_RAW_PACKET) {
1906 ++ err = -EINVAL;
1907 ++ goto err_put;
1908 ++ }
1909 ++
1910 + flow_attr = kzalloc(sizeof(*flow_attr) + cmd.flow_attr.num_of_specs *
1911 + sizeof(union ib_flow_spec), GFP_KERNEL);
1912 + if (!flow_attr) {
1913 +diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
1914 +index 9032f77cc38d..feb80dbb5948 100644
1915 +--- a/drivers/infiniband/core/verbs.c
1916 ++++ b/drivers/infiniband/core/verbs.c
1917 +@@ -2115,10 +2115,16 @@ static void __ib_drain_sq(struct ib_qp *qp)
1918 + struct ib_cq *cq = qp->send_cq;
1919 + struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
1920 + struct ib_drain_cqe sdrain;
1921 +- struct ib_send_wr swr = {}, *bad_swr;
1922 ++ struct ib_send_wr *bad_swr;
1923 ++ struct ib_rdma_wr swr = {
1924 ++ .wr = {
1925 ++ .next = NULL,
1926 ++ { .wr_cqe = &sdrain.cqe, },
1927 ++ .opcode = IB_WR_RDMA_WRITE,
1928 ++ },
1929 ++ };
1930 + int ret;
1931 +
1932 +- swr.wr_cqe = &sdrain.cqe;
1933 + sdrain.cqe.done = ib_drain_qp_done;
1934 + init_completion(&sdrain.done);
1935 +
1936 +@@ -2128,7 +2134,7 @@ static void __ib_drain_sq(struct ib_qp *qp)
1937 + return;
1938 + }
1939 +
1940 +- ret = ib_post_send(qp, &swr, &bad_swr);
1941 ++ ret = ib_post_send(qp, &swr.wr, &bad_swr);
1942 + if (ret) {
1943 + WARN_ONCE(ret, "failed to drain send queue: %d\n", ret);
1944 + return;
1945 +diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
1946 +index ee578fa713c2..97c2225829ea 100644
1947 +--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
1948 ++++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
1949 +@@ -787,13 +787,17 @@ static int srpt_post_recv(struct srpt_device *sdev,
1950 + */
1951 + static int srpt_zerolength_write(struct srpt_rdma_ch *ch)
1952 + {
1953 +- struct ib_send_wr wr, *bad_wr;
1954 ++ struct ib_send_wr *bad_wr;
1955 ++ struct ib_rdma_wr wr = {
1956 ++ .wr = {
1957 ++ .next = NULL,
1958 ++ { .wr_cqe = &ch->zw_cqe, },
1959 ++ .opcode = IB_WR_RDMA_WRITE,
1960 ++ .send_flags = IB_SEND_SIGNALED,
1961 ++ }
1962 ++ };
1963 +
1964 +- memset(&wr, 0, sizeof(wr));
1965 +- wr.opcode = IB_WR_RDMA_WRITE;
1966 +- wr.wr_cqe = &ch->zw_cqe;
1967 +- wr.send_flags = IB_SEND_SIGNALED;
1968 +- return ib_post_send(ch->qp, &wr, &bad_wr);
1969 ++ return ib_post_send(ch->qp, &wr.wr, &bad_wr);
1970 + }
1971 +
1972 + static void srpt_zerolength_write_done(struct ib_cq *cq, struct ib_wc *wc)
1973 +diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
1974 +index 7b5fa501bbcf..696e540304fd 100644
1975 +--- a/drivers/input/mouse/elan_i2c_core.c
1976 ++++ b/drivers/input/mouse/elan_i2c_core.c
1977 +@@ -1262,6 +1262,8 @@ static const struct acpi_device_id elan_acpi_id[] = {
1978 + { "ELAN0611", 0 },
1979 + { "ELAN0612", 0 },
1980 + { "ELAN0618", 0 },
1981 ++ { "ELAN061D", 0 },
1982 ++ { "ELAN0622", 0 },
1983 + { "ELAN1000", 0 },
1984 + { }
1985 + };
1986 +diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
1987 +index b353d494ad40..136f6e7bf797 100644
1988 +--- a/drivers/input/serio/i8042-x86ia64io.h
1989 ++++ b/drivers/input/serio/i8042-x86ia64io.h
1990 +@@ -527,6 +527,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
1991 + DMI_MATCH(DMI_PRODUCT_NAME, "N24_25BU"),
1992 + },
1993 + },
1994 ++ {
1995 ++ /* Lenovo LaVie Z */
1996 ++ .matches = {
1997 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1998 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo LaVie Z"),
1999 ++ },
2000 ++ },
2001 + { }
2002 + };
2003 +
2004 +diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c
2005 +index 119f4ef0d421..b7f943f96068 100644
2006 +--- a/drivers/irqchip/irq-ls-scfg-msi.c
2007 ++++ b/drivers/irqchip/irq-ls-scfg-msi.c
2008 +@@ -21,6 +21,7 @@
2009 + #include <linux/of_pci.h>
2010 + #include <linux/of_platform.h>
2011 + #include <linux/spinlock.h>
2012 ++#include <linux/dma-iommu.h>
2013 +
2014 + #define MSI_IRQS_PER_MSIR 32
2015 + #define MSI_MSIR_OFFSET 4
2016 +@@ -94,6 +95,8 @@ static void ls_scfg_msi_compose_msg(struct irq_data *data, struct msi_msg *msg)
2017 +
2018 + if (msi_affinity_flag)
2019 + msg->data |= cpumask_first(data->common->affinity);
2020 ++
2021 ++ iommu_dma_map_msi_msg(data->irq, msg);
2022 + }
2023 +
2024 + static int ls_scfg_msi_set_affinity(struct irq_data *irq_data,
2025 +diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c
2026 +index 9bc32578a766..c0dd17a82170 100644
2027 +--- a/drivers/lightnvm/pblk-rb.c
2028 ++++ b/drivers/lightnvm/pblk-rb.c
2029 +@@ -142,10 +142,9 @@ static void clean_wctx(struct pblk_w_ctx *w_ctx)
2030 + {
2031 + int flags;
2032 +
2033 +-try:
2034 + flags = READ_ONCE(w_ctx->flags);
2035 +- if (!(flags & PBLK_SUBMITTED_ENTRY))
2036 +- goto try;
2037 ++ WARN_ONCE(!(flags & PBLK_SUBMITTED_ENTRY),
2038 ++ "pblk: overwriting unsubmitted data\n");
2039 +
2040 + /* Release flags on context. Protect from writes and reads */
2041 + smp_store_release(&w_ctx->flags, PBLK_WRITABLE_ENTRY);
2042 +diff --git a/drivers/md/md.c b/drivers/md/md.c
2043 +index 11a67eac55b1..5599712d478e 100644
2044 +--- a/drivers/md/md.c
2045 ++++ b/drivers/md/md.c
2046 +@@ -6498,6 +6498,9 @@ static int hot_remove_disk(struct mddev *mddev, dev_t dev)
2047 + char b[BDEVNAME_SIZE];
2048 + struct md_rdev *rdev;
2049 +
2050 ++ if (!mddev->pers)
2051 ++ return -ENODEV;
2052 ++
2053 + rdev = find_rdev(mddev, dev);
2054 + if (!rdev)
2055 + return -ENXIO;
2056 +diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
2057 +index 029ecba60727..78d830763704 100644
2058 +--- a/drivers/md/raid1.c
2059 ++++ b/drivers/md/raid1.c
2060 +@@ -2462,6 +2462,8 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
2061 + fix_read_error(conf, r1_bio->read_disk,
2062 + r1_bio->sector, r1_bio->sectors);
2063 + unfreeze_array(conf);
2064 ++ } else if (mddev->ro == 0 && test_bit(FailFast, &rdev->flags)) {
2065 ++ md_error(mddev, rdev);
2066 + } else {
2067 + r1_bio->bios[r1_bio->read_disk] = IO_BLOCKED;
2068 + }
2069 +diff --git a/drivers/media/common/siano/smsendian.c b/drivers/media/common/siano/smsendian.c
2070 +index bfe831c10b1c..b95a631f23f9 100644
2071 +--- a/drivers/media/common/siano/smsendian.c
2072 ++++ b/drivers/media/common/siano/smsendian.c
2073 +@@ -35,7 +35,7 @@ void smsendian_handle_tx_message(void *buffer)
2074 + switch (msg->x_msg_header.msg_type) {
2075 + case MSG_SMS_DATA_DOWNLOAD_REQ:
2076 + {
2077 +- msg->msg_data[0] = le32_to_cpu(msg->msg_data[0]);
2078 ++ msg->msg_data[0] = le32_to_cpu((__force __le32)(msg->msg_data[0]));
2079 + break;
2080 + }
2081 +
2082 +@@ -44,7 +44,7 @@ void smsendian_handle_tx_message(void *buffer)
2083 + sizeof(struct sms_msg_hdr))/4;
2084 +
2085 + for (i = 0; i < msg_words; i++)
2086 +- msg->msg_data[i] = le32_to_cpu(msg->msg_data[i]);
2087 ++ msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
2088 +
2089 + break;
2090 + }
2091 +@@ -64,7 +64,7 @@ void smsendian_handle_rx_message(void *buffer)
2092 + {
2093 + struct sms_version_res *ver =
2094 + (struct sms_version_res *) msg;
2095 +- ver->chip_model = le16_to_cpu(ver->chip_model);
2096 ++ ver->chip_model = le16_to_cpu((__force __le16)ver->chip_model);
2097 + break;
2098 + }
2099 +
2100 +@@ -81,7 +81,7 @@ void smsendian_handle_rx_message(void *buffer)
2101 + sizeof(struct sms_msg_hdr))/4;
2102 +
2103 + for (i = 0; i < msg_words; i++)
2104 +- msg->msg_data[i] = le32_to_cpu(msg->msg_data[i]);
2105 ++ msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
2106 +
2107 + break;
2108 + }
2109 +@@ -95,9 +95,9 @@ void smsendian_handle_message_header(void *msg)
2110 + #ifdef __BIG_ENDIAN
2111 + struct sms_msg_hdr *phdr = (struct sms_msg_hdr *)msg;
2112 +
2113 +- phdr->msg_type = le16_to_cpu(phdr->msg_type);
2114 +- phdr->msg_length = le16_to_cpu(phdr->msg_length);
2115 +- phdr->msg_flags = le16_to_cpu(phdr->msg_flags);
2116 ++ phdr->msg_type = le16_to_cpu((__force __le16)phdr->msg_type);
2117 ++ phdr->msg_length = le16_to_cpu((__force __le16)phdr->msg_length);
2118 ++ phdr->msg_flags = le16_to_cpu((__force __le16)phdr->msg_flags);
2119 + #endif /* __BIG_ENDIAN */
2120 + }
2121 + EXPORT_SYMBOL_GPL(smsendian_handle_message_header);
2122 +diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
2123 +index 700f433261d0..e4d7f2febf00 100644
2124 +--- a/drivers/media/i2c/smiapp/smiapp-core.c
2125 ++++ b/drivers/media/i2c/smiapp/smiapp-core.c
2126 +@@ -1001,7 +1001,7 @@ static int smiapp_read_nvm(struct smiapp_sensor *sensor,
2127 + if (rval)
2128 + goto out;
2129 +
2130 +- for (i = 0; i < 1000; i++) {
2131 ++ for (i = 1000; i > 0; i--) {
2132 + rval = smiapp_read(
2133 + sensor,
2134 + SMIAPP_REG_U8_DATA_TRANSFER_IF_1_STATUS, &s);
2135 +@@ -1012,11 +1012,10 @@ static int smiapp_read_nvm(struct smiapp_sensor *sensor,
2136 + if (s & SMIAPP_DATA_TRANSFER_IF_1_STATUS_RD_READY)
2137 + break;
2138 +
2139 +- if (--i == 0) {
2140 +- rval = -ETIMEDOUT;
2141 +- goto out;
2142 +- }
2143 +-
2144 ++ }
2145 ++ if (!i) {
2146 ++ rval = -ETIMEDOUT;
2147 ++ goto out;
2148 + }
2149 +
2150 + for (i = 0; i < SMIAPP_NVM_PAGE_SIZE; i++) {
2151 +diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
2152 +index e79f72b8b858..62b2c5d9bdfb 100644
2153 +--- a/drivers/media/media-device.c
2154 ++++ b/drivers/media/media-device.c
2155 +@@ -54,9 +54,10 @@ static int media_device_close(struct file *filp)
2156 + return 0;
2157 + }
2158 +
2159 +-static int media_device_get_info(struct media_device *dev,
2160 +- struct media_device_info *info)
2161 ++static long media_device_get_info(struct media_device *dev, void *arg)
2162 + {
2163 ++ struct media_device_info *info = arg;
2164 ++
2165 + memset(info, 0, sizeof(*info));
2166 +
2167 + if (dev->driver_name[0])
2168 +@@ -93,9 +94,9 @@ static struct media_entity *find_entity(struct media_device *mdev, u32 id)
2169 + return NULL;
2170 + }
2171 +
2172 +-static long media_device_enum_entities(struct media_device *mdev,
2173 +- struct media_entity_desc *entd)
2174 ++static long media_device_enum_entities(struct media_device *mdev, void *arg)
2175 + {
2176 ++ struct media_entity_desc *entd = arg;
2177 + struct media_entity *ent;
2178 +
2179 + ent = find_entity(mdev, entd->id);
2180 +@@ -146,9 +147,9 @@ static void media_device_kpad_to_upad(const struct media_pad *kpad,
2181 + upad->flags = kpad->flags;
2182 + }
2183 +
2184 +-static long media_device_enum_links(struct media_device *mdev,
2185 +- struct media_links_enum *links)
2186 ++static long media_device_enum_links(struct media_device *mdev, void *arg)
2187 + {
2188 ++ struct media_links_enum *links = arg;
2189 + struct media_entity *entity;
2190 +
2191 + entity = find_entity(mdev, links->entity);
2192 +@@ -194,9 +195,9 @@ static long media_device_enum_links(struct media_device *mdev,
2193 + return 0;
2194 + }
2195 +
2196 +-static long media_device_setup_link(struct media_device *mdev,
2197 +- struct media_link_desc *linkd)
2198 ++static long media_device_setup_link(struct media_device *mdev, void *arg)
2199 + {
2200 ++ struct media_link_desc *linkd = arg;
2201 + struct media_link *link = NULL;
2202 + struct media_entity *source;
2203 + struct media_entity *sink;
2204 +@@ -222,9 +223,9 @@ static long media_device_setup_link(struct media_device *mdev,
2205 + return __media_entity_setup_link(link, linkd->flags);
2206 + }
2207 +
2208 +-static long media_device_get_topology(struct media_device *mdev,
2209 +- struct media_v2_topology *topo)
2210 ++static long media_device_get_topology(struct media_device *mdev, void *arg)
2211 + {
2212 ++ struct media_v2_topology *topo = arg;
2213 + struct media_entity *entity;
2214 + struct media_interface *intf;
2215 + struct media_pad *pad;
2216 +diff --git a/drivers/media/pci/saa7164/saa7164-fw.c b/drivers/media/pci/saa7164/saa7164-fw.c
2217 +index ef4906406ebf..a50461861133 100644
2218 +--- a/drivers/media/pci/saa7164/saa7164-fw.c
2219 ++++ b/drivers/media/pci/saa7164/saa7164-fw.c
2220 +@@ -426,7 +426,8 @@ int saa7164_downloadfirmware(struct saa7164_dev *dev)
2221 + __func__, fw->size);
2222 +
2223 + if (fw->size != fwlength) {
2224 +- printk(KERN_ERR "xc5000: firmware incorrect size\n");
2225 ++ printk(KERN_ERR "saa7164: firmware incorrect size %zu != %u\n",
2226 ++ fw->size, fwlength);
2227 + ret = -ENOMEM;
2228 + goto out;
2229 + }
2230 +diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c
2231 +index c3fafa97b2d0..0ea8dd44026c 100644
2232 +--- a/drivers/media/pci/tw686x/tw686x-video.c
2233 ++++ b/drivers/media/pci/tw686x/tw686x-video.c
2234 +@@ -1228,7 +1228,8 @@ int tw686x_video_init(struct tw686x_dev *dev)
2235 + vc->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
2236 + vc->vidq.min_buffers_needed = 2;
2237 + vc->vidq.lock = &vc->vb_mutex;
2238 +- vc->vidq.gfp_flags = GFP_DMA32;
2239 ++ vc->vidq.gfp_flags = dev->dma_mode != TW686X_DMA_MODE_MEMCPY ?
2240 ++ GFP_DMA32 : 0;
2241 + vc->vidq.dev = &dev->pci_dev->dev;
2242 +
2243 + err = vb2_queue_init(&vc->vidq);
2244 +diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
2245 +index 1a428fe9f070..9f023bc6e1b7 100644
2246 +--- a/drivers/media/platform/omap3isp/isp.c
2247 ++++ b/drivers/media/platform/omap3isp/isp.c
2248 +@@ -1945,6 +1945,7 @@ error_csi2:
2249 +
2250 + static void isp_detach_iommu(struct isp_device *isp)
2251 + {
2252 ++ arm_iommu_detach_device(isp->dev);
2253 + arm_iommu_release_mapping(isp->mapping);
2254 + isp->mapping = NULL;
2255 + }
2256 +@@ -1961,8 +1962,7 @@ static int isp_attach_iommu(struct isp_device *isp)
2257 + mapping = arm_iommu_create_mapping(&platform_bus_type, SZ_1G, SZ_2G);
2258 + if (IS_ERR(mapping)) {
2259 + dev_err(isp->dev, "failed to create ARM IOMMU mapping\n");
2260 +- ret = PTR_ERR(mapping);
2261 +- goto error;
2262 ++ return PTR_ERR(mapping);
2263 + }
2264 +
2265 + isp->mapping = mapping;
2266 +@@ -1977,7 +1977,8 @@ static int isp_attach_iommu(struct isp_device *isp)
2267 + return 0;
2268 +
2269 + error:
2270 +- isp_detach_iommu(isp);
2271 ++ arm_iommu_release_mapping(isp->mapping);
2272 ++ isp->mapping = NULL;
2273 + return ret;
2274 + }
2275 +
2276 +diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c
2277 +index 070bac36d766..2e2b8c409150 100644
2278 +--- a/drivers/media/platform/rcar_jpu.c
2279 ++++ b/drivers/media/platform/rcar_jpu.c
2280 +@@ -1280,7 +1280,7 @@ static int jpu_open(struct file *file)
2281 + /* ...issue software reset */
2282 + ret = jpu_reset(jpu);
2283 + if (ret)
2284 +- goto device_prepare_rollback;
2285 ++ goto jpu_reset_rollback;
2286 + }
2287 +
2288 + jpu->ref_count++;
2289 +@@ -1288,6 +1288,8 @@ static int jpu_open(struct file *file)
2290 + mutex_unlock(&jpu->mutex);
2291 + return 0;
2292 +
2293 ++jpu_reset_rollback:
2294 ++ clk_disable_unprepare(jpu->clk);
2295 + device_prepare_rollback:
2296 + mutex_unlock(&jpu->mutex);
2297 + v4l_prepare_rollback:
2298 +diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
2299 +index b3034f80163f..8ce6f9cff746 100644
2300 +--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
2301 ++++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
2302 +@@ -92,7 +92,7 @@ MODULE_PARM_DESC(max_rds_errors, "RDS maximum block errors: *1*");
2303 + */
2304 + int si470x_get_register(struct si470x_device *radio, int regnr)
2305 + {
2306 +- u16 buf[READ_REG_NUM];
2307 ++ __be16 buf[READ_REG_NUM];
2308 + struct i2c_msg msgs[1] = {
2309 + {
2310 + .addr = radio->client->addr,
2311 +@@ -117,7 +117,7 @@ int si470x_get_register(struct si470x_device *radio, int regnr)
2312 + int si470x_set_register(struct si470x_device *radio, int regnr)
2313 + {
2314 + int i;
2315 +- u16 buf[WRITE_REG_NUM];
2316 ++ __be16 buf[WRITE_REG_NUM];
2317 + struct i2c_msg msgs[1] = {
2318 + {
2319 + .addr = radio->client->addr,
2320 +@@ -147,7 +147,7 @@ int si470x_set_register(struct si470x_device *radio, int regnr)
2321 + static int si470x_get_all_registers(struct si470x_device *radio)
2322 + {
2323 + int i;
2324 +- u16 buf[READ_REG_NUM];
2325 ++ __be16 buf[READ_REG_NUM];
2326 + struct i2c_msg msgs[1] = {
2327 + {
2328 + .addr = radio->client->addr,
2329 +diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
2330 +index ffbb178c6918..2dbf632c10de 100644
2331 +--- a/drivers/media/v4l2-core/videobuf2-core.c
2332 ++++ b/drivers/media/v4l2-core/videobuf2-core.c
2333 +@@ -912,9 +912,12 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
2334 + dprintk(4, "done processing on buffer %d, state: %d\n",
2335 + vb->index, state);
2336 +
2337 +- /* sync buffers */
2338 +- for (plane = 0; plane < vb->num_planes; ++plane)
2339 +- call_void_memop(vb, finish, vb->planes[plane].mem_priv);
2340 ++ if (state != VB2_BUF_STATE_QUEUED &&
2341 ++ state != VB2_BUF_STATE_REQUEUEING) {
2342 ++ /* sync buffers */
2343 ++ for (plane = 0; plane < vb->num_planes; ++plane)
2344 ++ call_void_memop(vb, finish, vb->planes[plane].mem_priv);
2345 ++ }
2346 +
2347 + spin_lock_irqsave(&q->done_lock, flags);
2348 + if (state == VB2_BUF_STATE_QUEUED ||
2349 +diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
2350 +index a4803ac192bb..1d49a8dd4a37 100644
2351 +--- a/drivers/memory/tegra/mc.c
2352 ++++ b/drivers/memory/tegra/mc.c
2353 +@@ -20,14 +20,6 @@
2354 + #include "mc.h"
2355 +
2356 + #define MC_INTSTATUS 0x000
2357 +-#define MC_INT_DECERR_MTS (1 << 16)
2358 +-#define MC_INT_SECERR_SEC (1 << 13)
2359 +-#define MC_INT_DECERR_VPR (1 << 12)
2360 +-#define MC_INT_INVALID_APB_ASID_UPDATE (1 << 11)
2361 +-#define MC_INT_INVALID_SMMU_PAGE (1 << 10)
2362 +-#define MC_INT_ARBITRATION_EMEM (1 << 9)
2363 +-#define MC_INT_SECURITY_VIOLATION (1 << 8)
2364 +-#define MC_INT_DECERR_EMEM (1 << 6)
2365 +
2366 + #define MC_INTMASK 0x004
2367 +
2368 +@@ -248,12 +240,13 @@ static const char *const error_names[8] = {
2369 + static irqreturn_t tegra_mc_irq(int irq, void *data)
2370 + {
2371 + struct tegra_mc *mc = data;
2372 +- unsigned long status, mask;
2373 ++ unsigned long status;
2374 + unsigned int bit;
2375 +
2376 + /* mask all interrupts to avoid flooding */
2377 +- status = mc_readl(mc, MC_INTSTATUS);
2378 +- mask = mc_readl(mc, MC_INTMASK);
2379 ++ status = mc_readl(mc, MC_INTSTATUS) & mc->soc->intmask;
2380 ++ if (!status)
2381 ++ return IRQ_NONE;
2382 +
2383 + for_each_set_bit(bit, &status, 32) {
2384 + const char *error = status_names[bit] ?: "unknown";
2385 +@@ -346,7 +339,6 @@ static int tegra_mc_probe(struct platform_device *pdev)
2386 + const struct of_device_id *match;
2387 + struct resource *res;
2388 + struct tegra_mc *mc;
2389 +- u32 value;
2390 + int err;
2391 +
2392 + match = of_match_node(tegra_mc_of_match, pdev->dev.of_node);
2393 +@@ -414,11 +406,7 @@ static int tegra_mc_probe(struct platform_device *pdev)
2394 +
2395 + WARN(!mc->soc->client_id_mask, "Missing client ID mask for this SoC\n");
2396 +
2397 +- value = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
2398 +- MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
2399 +- MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM;
2400 +-
2401 +- mc_writel(mc, value, MC_INTMASK);
2402 ++ mc_writel(mc, mc->soc->intmask, MC_INTMASK);
2403 +
2404 + return 0;
2405 + }
2406 +diff --git a/drivers/memory/tegra/mc.h b/drivers/memory/tegra/mc.h
2407 +index ddb16676c3af..24e020b4609b 100644
2408 +--- a/drivers/memory/tegra/mc.h
2409 ++++ b/drivers/memory/tegra/mc.h
2410 +@@ -14,6 +14,15 @@
2411 +
2412 + #include <soc/tegra/mc.h>
2413 +
2414 ++#define MC_INT_DECERR_MTS (1 << 16)
2415 ++#define MC_INT_SECERR_SEC (1 << 13)
2416 ++#define MC_INT_DECERR_VPR (1 << 12)
2417 ++#define MC_INT_INVALID_APB_ASID_UPDATE (1 << 11)
2418 ++#define MC_INT_INVALID_SMMU_PAGE (1 << 10)
2419 ++#define MC_INT_ARBITRATION_EMEM (1 << 9)
2420 ++#define MC_INT_SECURITY_VIOLATION (1 << 8)
2421 ++#define MC_INT_DECERR_EMEM (1 << 6)
2422 ++
2423 + static inline u32 mc_readl(struct tegra_mc *mc, unsigned long offset)
2424 + {
2425 + return readl(mc->regs + offset);
2426 +diff --git a/drivers/memory/tegra/tegra114.c b/drivers/memory/tegra/tegra114.c
2427 +index ba8fff3d66a6..6d2a5a849d92 100644
2428 +--- a/drivers/memory/tegra/tegra114.c
2429 ++++ b/drivers/memory/tegra/tegra114.c
2430 +@@ -930,4 +930,6 @@ const struct tegra_mc_soc tegra114_mc_soc = {
2431 + .atom_size = 32,
2432 + .client_id_mask = 0x7f,
2433 + .smmu = &tegra114_smmu_soc,
2434 ++ .intmask = MC_INT_INVALID_SMMU_PAGE | MC_INT_SECURITY_VIOLATION |
2435 ++ MC_INT_DECERR_EMEM,
2436 + };
2437 +diff --git a/drivers/memory/tegra/tegra124.c b/drivers/memory/tegra/tegra124.c
2438 +index 5a58e440f4a7..9f68a56f2727 100644
2439 +--- a/drivers/memory/tegra/tegra124.c
2440 ++++ b/drivers/memory/tegra/tegra124.c
2441 +@@ -1020,6 +1020,9 @@ const struct tegra_mc_soc tegra124_mc_soc = {
2442 + .smmu = &tegra124_smmu_soc,
2443 + .emem_regs = tegra124_mc_emem_regs,
2444 + .num_emem_regs = ARRAY_SIZE(tegra124_mc_emem_regs),
2445 ++ .intmask = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
2446 ++ MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
2447 ++ MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM,
2448 + };
2449 + #endif /* CONFIG_ARCH_TEGRA_124_SOC */
2450 +
2451 +@@ -1042,5 +1045,8 @@ const struct tegra_mc_soc tegra132_mc_soc = {
2452 + .atom_size = 32,
2453 + .client_id_mask = 0x7f,
2454 + .smmu = &tegra132_smmu_soc,
2455 ++ .intmask = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
2456 ++ MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
2457 ++ MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM,
2458 + };
2459 + #endif /* CONFIG_ARCH_TEGRA_132_SOC */
2460 +diff --git a/drivers/memory/tegra/tegra210.c b/drivers/memory/tegra/tegra210.c
2461 +index 5e144abe4c18..47c78a6d8f00 100644
2462 +--- a/drivers/memory/tegra/tegra210.c
2463 ++++ b/drivers/memory/tegra/tegra210.c
2464 +@@ -1077,4 +1077,7 @@ const struct tegra_mc_soc tegra210_mc_soc = {
2465 + .atom_size = 64,
2466 + .client_id_mask = 0xff,
2467 + .smmu = &tegra210_smmu_soc,
2468 ++ .intmask = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
2469 ++ MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
2470 ++ MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM,
2471 + };
2472 +diff --git a/drivers/memory/tegra/tegra30.c b/drivers/memory/tegra/tegra30.c
2473 +index b44737840e70..d0689428ea1a 100644
2474 +--- a/drivers/memory/tegra/tegra30.c
2475 ++++ b/drivers/memory/tegra/tegra30.c
2476 +@@ -952,4 +952,6 @@ const struct tegra_mc_soc tegra30_mc_soc = {
2477 + .atom_size = 16,
2478 + .client_id_mask = 0x7f,
2479 + .smmu = &tegra30_smmu_soc,
2480 ++ .intmask = MC_INT_INVALID_SMMU_PAGE | MC_INT_SECURITY_VIOLATION |
2481 ++ MC_INT_DECERR_EMEM,
2482 + };
2483 +diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
2484 +index b0ca5a4c841e..c5528ae982f2 100644
2485 +--- a/drivers/mfd/cros_ec.c
2486 ++++ b/drivers/mfd/cros_ec.c
2487 +@@ -112,7 +112,11 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
2488 +
2489 + mutex_init(&ec_dev->lock);
2490 +
2491 +- cros_ec_query_all(ec_dev);
2492 ++ err = cros_ec_query_all(ec_dev);
2493 ++ if (err) {
2494 ++ dev_err(dev, "Cannot identify the EC: error %d\n", err);
2495 ++ return err;
2496 ++ }
2497 +
2498 + if (ec_dev->irq) {
2499 + err = request_threaded_irq(ec_dev->irq, NULL, ec_irq_thread,
2500 +diff --git a/drivers/mmc/core/pwrseq_simple.c b/drivers/mmc/core/pwrseq_simple.c
2501 +index 13ef162cf066..a8b9fee4d62a 100644
2502 +--- a/drivers/mmc/core/pwrseq_simple.c
2503 ++++ b/drivers/mmc/core/pwrseq_simple.c
2504 +@@ -40,14 +40,18 @@ static void mmc_pwrseq_simple_set_gpios_value(struct mmc_pwrseq_simple *pwrseq,
2505 + struct gpio_descs *reset_gpios = pwrseq->reset_gpios;
2506 +
2507 + if (!IS_ERR(reset_gpios)) {
2508 +- int i;
2509 +- int values[reset_gpios->ndescs];
2510 ++ int i, *values;
2511 ++ int nvalues = reset_gpios->ndescs;
2512 +
2513 +- for (i = 0; i < reset_gpios->ndescs; i++)
2514 ++ values = kmalloc_array(nvalues, sizeof(int), GFP_KERNEL);
2515 ++ if (!values)
2516 ++ return;
2517 ++
2518 ++ for (i = 0; i < nvalues; i++)
2519 + values[i] = value;
2520 +
2521 +- gpiod_set_array_value_cansleep(
2522 +- reset_gpios->ndescs, reset_gpios->desc, values);
2523 ++ gpiod_set_array_value_cansleep(nvalues, reset_gpios->desc, values);
2524 ++ kfree(values);
2525 + }
2526 + }
2527 +
2528 +diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
2529 +index 6a2cbbba29aa..5252885e5cda 100644
2530 +--- a/drivers/mmc/host/dw_mmc.c
2531 ++++ b/drivers/mmc/host/dw_mmc.c
2532 +@@ -1255,6 +1255,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
2533 + if (host->state == STATE_WAITING_CMD11_DONE)
2534 + sdmmc_cmd_bits |= SDMMC_CMD_VOLT_SWITCH;
2535 +
2536 ++ slot->mmc->actual_clock = 0;
2537 ++
2538 + if (!clock) {
2539 + mci_writel(host, CLKENA, 0);
2540 + mci_send_cmd(slot, sdmmc_cmd_bits, 0);
2541 +@@ -1313,6 +1315,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
2542 +
2543 + /* keep the last clock value that was requested from core */
2544 + slot->__clk_old = clock;
2545 ++ slot->mmc->actual_clock = div ? ((host->bus_hz / div) >> 1) :
2546 ++ host->bus_hz;
2547 + }
2548 +
2549 + host->current_speed = clock;
2550 +diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
2551 +index 4005b427023c..16deba1a2385 100644
2552 +--- a/drivers/mtd/nand/fsl_ifc_nand.c
2553 ++++ b/drivers/mtd/nand/fsl_ifc_nand.c
2554 +@@ -342,9 +342,16 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command,
2555 +
2556 + case NAND_CMD_READID:
2557 + case NAND_CMD_PARAM: {
2558 ++ /*
2559 ++ * For READID, read 8 bytes that are currently used.
2560 ++ * For PARAM, read all 3 copies of 256-bytes pages.
2561 ++ */
2562 ++ int len = 8;
2563 + int timing = IFC_FIR_OP_RB;
2564 +- if (command == NAND_CMD_PARAM)
2565 ++ if (command == NAND_CMD_PARAM) {
2566 + timing = IFC_FIR_OP_RBCD;
2567 ++ len = 256 * 3;
2568 ++ }
2569 +
2570 + ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
2571 + (IFC_FIR_OP_UA << IFC_NAND_FIR0_OP1_SHIFT) |
2572 +@@ -354,12 +361,8 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command,
2573 + &ifc->ifc_nand.nand_fcr0);
2574 + ifc_out32(column, &ifc->ifc_nand.row3);
2575 +
2576 +- /*
2577 +- * although currently it's 8 bytes for READID, we always read
2578 +- * the maximum 256 bytes(for PARAM)
2579 +- */
2580 +- ifc_out32(256, &ifc->ifc_nand.nand_fbcr);
2581 +- ifc_nand_ctrl->read_bytes = 256;
2582 ++ ifc_out32(len, &ifc->ifc_nand.nand_fbcr);
2583 ++ ifc_nand_ctrl->read_bytes = len;
2584 +
2585 + set_addr(mtd, 0, 0, 0);
2586 + fsl_ifc_run_command(mtd);
2587 +diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
2588 +index 5ada7a41449c..9645c8f05c7f 100644
2589 +--- a/drivers/net/dsa/qca8k.c
2590 ++++ b/drivers/net/dsa/qca8k.c
2591 +@@ -473,7 +473,7 @@ qca8k_set_pad_ctrl(struct qca8k_priv *priv, int port, int mode)
2592 + static void
2593 + qca8k_port_set_status(struct qca8k_priv *priv, int port, int enable)
2594 + {
2595 +- u32 mask = QCA8K_PORT_STATUS_TXMAC;
2596 ++ u32 mask = QCA8K_PORT_STATUS_TXMAC | QCA8K_PORT_STATUS_RXMAC;
2597 +
2598 + /* Port 0 and 6 have no internal PHY */
2599 + if ((port > 0) && (port < 6))
2600 +@@ -490,6 +490,7 @@ qca8k_setup(struct dsa_switch *ds)
2601 + {
2602 + struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
2603 + int ret, i, phy_mode = -1;
2604 ++ u32 mask;
2605 +
2606 + /* Make sure that port 0 is the cpu port */
2607 + if (!dsa_is_cpu_port(ds, 0)) {
2608 +@@ -515,7 +516,10 @@ qca8k_setup(struct dsa_switch *ds)
2609 + if (ret < 0)
2610 + return ret;
2611 +
2612 +- /* Enable CPU Port */
2613 ++ /* Enable CPU Port, force it to maximum bandwidth and full-duplex */
2614 ++ mask = QCA8K_PORT_STATUS_SPEED_1000 | QCA8K_PORT_STATUS_TXFLOW |
2615 ++ QCA8K_PORT_STATUS_RXFLOW | QCA8K_PORT_STATUS_DUPLEX;
2616 ++ qca8k_write(priv, QCA8K_REG_PORT_STATUS(QCA8K_CPU_PORT), mask);
2617 + qca8k_reg_set(priv, QCA8K_REG_GLOBAL_FW_CTRL0,
2618 + QCA8K_GLOBAL_FW_CTRL0_CPU_PORT_EN);
2619 + qca8k_port_set_status(priv, QCA8K_CPU_PORT, 1);
2620 +@@ -584,6 +588,47 @@ qca8k_setup(struct dsa_switch *ds)
2621 + return 0;
2622 + }
2623 +
2624 ++static void
2625 ++qca8k_adjust_link(struct dsa_switch *ds, int port, struct phy_device *phy)
2626 ++{
2627 ++ struct qca8k_priv *priv = ds->priv;
2628 ++ u32 reg;
2629 ++
2630 ++ /* Force fixed-link setting for CPU port, skip others. */
2631 ++ if (!phy_is_pseudo_fixed_link(phy))
2632 ++ return;
2633 ++
2634 ++ /* Set port speed */
2635 ++ switch (phy->speed) {
2636 ++ case 10:
2637 ++ reg = QCA8K_PORT_STATUS_SPEED_10;
2638 ++ break;
2639 ++ case 100:
2640 ++ reg = QCA8K_PORT_STATUS_SPEED_100;
2641 ++ break;
2642 ++ case 1000:
2643 ++ reg = QCA8K_PORT_STATUS_SPEED_1000;
2644 ++ break;
2645 ++ default:
2646 ++ dev_dbg(priv->dev, "port%d link speed %dMbps not supported.\n",
2647 ++ port, phy->speed);
2648 ++ return;
2649 ++ }
2650 ++
2651 ++ /* Set duplex mode */
2652 ++ if (phy->duplex == DUPLEX_FULL)
2653 ++ reg |= QCA8K_PORT_STATUS_DUPLEX;
2654 ++
2655 ++ /* Force flow control */
2656 ++ if (dsa_is_cpu_port(ds, port))
2657 ++ reg |= QCA8K_PORT_STATUS_RXFLOW | QCA8K_PORT_STATUS_TXFLOW;
2658 ++
2659 ++ /* Force link down before changing MAC options */
2660 ++ qca8k_port_set_status(priv, port, 0);
2661 ++ qca8k_write(priv, QCA8K_REG_PORT_STATUS(port), reg);
2662 ++ qca8k_port_set_status(priv, port, 1);
2663 ++}
2664 ++
2665 + static int
2666 + qca8k_phy_read(struct dsa_switch *ds, int phy, int regnum)
2667 + {
2668 +@@ -832,6 +877,7 @@ qca8k_get_tag_protocol(struct dsa_switch *ds)
2669 + static const struct dsa_switch_ops qca8k_switch_ops = {
2670 + .get_tag_protocol = qca8k_get_tag_protocol,
2671 + .setup = qca8k_setup,
2672 ++ .adjust_link = qca8k_adjust_link,
2673 + .get_strings = qca8k_get_strings,
2674 + .phy_read = qca8k_phy_read,
2675 + .phy_write = qca8k_phy_write,
2676 +@@ -863,6 +909,7 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
2677 + return -ENOMEM;
2678 +
2679 + priv->bus = mdiodev->bus;
2680 ++ priv->dev = &mdiodev->dev;
2681 +
2682 + /* read the switches ID register */
2683 + id = qca8k_read(priv, QCA8K_REG_MASK_CTRL);
2684 +@@ -934,6 +981,7 @@ static SIMPLE_DEV_PM_OPS(qca8k_pm_ops,
2685 + qca8k_suspend, qca8k_resume);
2686 +
2687 + static const struct of_device_id qca8k_of_match[] = {
2688 ++ { .compatible = "qca,qca8334" },
2689 + { .compatible = "qca,qca8337" },
2690 + { /* sentinel */ },
2691 + };
2692 +diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h
2693 +index 1cf8a920d4ff..613fe5c50236 100644
2694 +--- a/drivers/net/dsa/qca8k.h
2695 ++++ b/drivers/net/dsa/qca8k.h
2696 +@@ -51,8 +51,10 @@
2697 + #define QCA8K_GOL_MAC_ADDR0 0x60
2698 + #define QCA8K_GOL_MAC_ADDR1 0x64
2699 + #define QCA8K_REG_PORT_STATUS(_i) (0x07c + (_i) * 4)
2700 +-#define QCA8K_PORT_STATUS_SPEED GENMASK(2, 0)
2701 +-#define QCA8K_PORT_STATUS_SPEED_S 0
2702 ++#define QCA8K_PORT_STATUS_SPEED GENMASK(1, 0)
2703 ++#define QCA8K_PORT_STATUS_SPEED_10 0
2704 ++#define QCA8K_PORT_STATUS_SPEED_100 0x1
2705 ++#define QCA8K_PORT_STATUS_SPEED_1000 0x2
2706 + #define QCA8K_PORT_STATUS_TXMAC BIT(2)
2707 + #define QCA8K_PORT_STATUS_RXMAC BIT(3)
2708 + #define QCA8K_PORT_STATUS_TXFLOW BIT(4)
2709 +@@ -165,6 +167,7 @@ struct qca8k_priv {
2710 + struct ar8xxx_port_status port_sts[QCA8K_NUM_PORTS];
2711 + struct dsa_switch *ds;
2712 + struct mutex reg_mutex;
2713 ++ struct device *dev;
2714 + };
2715 +
2716 + struct qca8k_mib_desc {
2717 +diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c
2718 +index 52beba8c7a39..e3b7a71fcad9 100644
2719 +--- a/drivers/net/ethernet/amazon/ena/ena_com.c
2720 ++++ b/drivers/net/ethernet/amazon/ena/ena_com.c
2721 +@@ -331,6 +331,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
2722 +
2723 + memset(&io_sq->desc_addr, 0x0, sizeof(io_sq->desc_addr));
2724 +
2725 ++ io_sq->dma_addr_bits = ena_dev->dma_addr_bits;
2726 + io_sq->desc_entry_size =
2727 + (io_sq->direction == ENA_COM_IO_QUEUE_DIRECTION_TX) ?
2728 + sizeof(struct ena_eth_io_tx_desc) :
2729 +diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
2730 +index 1b45cd73a258..119777986ea4 100644
2731 +--- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
2732 ++++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
2733 +@@ -1128,14 +1128,14 @@ static void xgbe_phy_adjust_link(struct xgbe_prv_data *pdata)
2734 +
2735 + if (pdata->tx_pause != pdata->phy.tx_pause) {
2736 + new_state = 1;
2737 +- pdata->hw_if.config_tx_flow_control(pdata);
2738 + pdata->tx_pause = pdata->phy.tx_pause;
2739 ++ pdata->hw_if.config_tx_flow_control(pdata);
2740 + }
2741 +
2742 + if (pdata->rx_pause != pdata->phy.rx_pause) {
2743 + new_state = 1;
2744 +- pdata->hw_if.config_rx_flow_control(pdata);
2745 + pdata->rx_pause = pdata->phy.rx_pause;
2746 ++ pdata->hw_if.config_rx_flow_control(pdata);
2747 + }
2748 +
2749 + /* Speed support */
2750 +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2751 +index bfd2d0382f4c..94931318587c 100644
2752 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2753 ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2754 +@@ -5927,6 +5927,9 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state)
2755 + }
2756 + mutex_unlock(&bp->hwrm_cmd_lock);
2757 +
2758 ++ if (!BNXT_SINGLE_PF(bp))
2759 ++ return 0;
2760 ++
2761 + diff = link_info->support_auto_speeds ^ link_info->advertising;
2762 + if ((link_info->support_auto_speeds | diff) !=
2763 + link_info->support_auto_speeds) {
2764 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
2765 +index ff7a70ffafc6..c133491ad9fa 100644
2766 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
2767 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
2768 +@@ -1272,8 +1272,11 @@ static int hclge_alloc_vport(struct hclge_dev *hdev)
2769 + /* We need to alloc a vport for main NIC of PF */
2770 + num_vport = hdev->num_vmdq_vport + hdev->num_req_vfs + 1;
2771 +
2772 +- if (hdev->num_tqps < num_vport)
2773 +- num_vport = hdev->num_tqps;
2774 ++ if (hdev->num_tqps < num_vport) {
2775 ++ dev_err(&hdev->pdev->dev, "tqps(%d) is less than vports(%d)",
2776 ++ hdev->num_tqps, num_vport);
2777 ++ return -EINVAL;
2778 ++ }
2779 +
2780 + /* Alloc the same number of TQPs for every vport */
2781 + tqp_per_vport = hdev->num_tqps / num_vport;
2782 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
2783 +index d1e4dcec5db2..69726908e72c 100644
2784 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
2785 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
2786 +@@ -1598,6 +1598,7 @@ static void hns3_replace_buffer(struct hns3_enet_ring *ring, int i,
2787 + hns3_unmap_buffer(ring, &ring->desc_cb[i]);
2788 + ring->desc_cb[i] = *res_cb;
2789 + ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma);
2790 ++ ring->desc[i].rx.bd_base_info = 0;
2791 + }
2792 +
2793 + static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i)
2794 +@@ -1605,6 +1606,7 @@ static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i)
2795 + ring->desc_cb[i].reuse_flag = 0;
2796 + ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma
2797 + + ring->desc_cb[i].page_offset);
2798 ++ ring->desc[i].rx.bd_base_info = 0;
2799 + }
2800 +
2801 + static void hns3_nic_reclaim_one_desc(struct hns3_enet_ring *ring, int *bytes,
2802 +@@ -2881,6 +2883,8 @@ static int __init hns3_init_module(void)
2803 +
2804 + client.ops = &client_ops;
2805 +
2806 ++ INIT_LIST_HEAD(&client.node);
2807 ++
2808 + ret = hnae3_register_client(&client);
2809 + if (ret)
2810 + return ret;
2811 +diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
2812 +index 7a226537877b..6265ce8915b6 100644
2813 +--- a/drivers/net/ethernet/intel/e1000e/netdev.c
2814 ++++ b/drivers/net/ethernet/intel/e1000e/netdev.c
2815 +@@ -3558,15 +3558,12 @@ s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca)
2816 + }
2817 + break;
2818 + case e1000_pch_spt:
2819 +- if (er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_SYSCFI) {
2820 +- /* Stable 24MHz frequency */
2821 +- incperiod = INCPERIOD_24MHZ;
2822 +- incvalue = INCVALUE_24MHZ;
2823 +- shift = INCVALUE_SHIFT_24MHZ;
2824 +- adapter->cc.shift = shift;
2825 +- break;
2826 +- }
2827 +- return -EINVAL;
2828 ++ /* Stable 24MHz frequency */
2829 ++ incperiod = INCPERIOD_24MHZ;
2830 ++ incvalue = INCVALUE_24MHZ;
2831 ++ shift = INCVALUE_SHIFT_24MHZ;
2832 ++ adapter->cc.shift = shift;
2833 ++ break;
2834 + case e1000_pch_cnp:
2835 + if (er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_SYSCFI) {
2836 + /* Stable 24MHz frequency */
2837 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
2838 +index d8456c381c99..ef242dbae116 100644
2839 +--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
2840 ++++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
2841 +@@ -337,6 +337,8 @@ void i40e_ptp_rx_hang(struct i40e_pf *pf)
2842 + **/
2843 + void i40e_ptp_tx_hang(struct i40e_pf *pf)
2844 + {
2845 ++ struct sk_buff *skb;
2846 ++
2847 + if (!(pf->flags & I40E_FLAG_PTP) || !pf->ptp_tx)
2848 + return;
2849 +
2850 +@@ -349,9 +351,12 @@ void i40e_ptp_tx_hang(struct i40e_pf *pf)
2851 + * within a second it is reasonable to assume that we never will.
2852 + */
2853 + if (time_is_before_jiffies(pf->ptp_tx_start + HZ)) {
2854 +- dev_kfree_skb_any(pf->ptp_tx_skb);
2855 ++ skb = pf->ptp_tx_skb;
2856 + pf->ptp_tx_skb = NULL;
2857 + clear_bit_unlock(__I40E_PTP_TX_IN_PROGRESS, pf->state);
2858 ++
2859 ++ /* Free the skb after we clear the bitlock */
2860 ++ dev_kfree_skb_any(skb);
2861 + pf->tx_hwtstamp_timeouts++;
2862 + }
2863 + }
2864 +diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
2865 +index 6ca580cdfd84..1c027f9d9af5 100644
2866 +--- a/drivers/net/ethernet/intel/igb/igb_main.c
2867 ++++ b/drivers/net/ethernet/intel/igb/igb_main.c
2868 +@@ -8376,12 +8376,17 @@ static void igb_rar_set_index(struct igb_adapter *adapter, u32 index)
2869 + if (is_valid_ether_addr(addr))
2870 + rar_high |= E1000_RAH_AV;
2871 +
2872 +- if (hw->mac.type == e1000_82575)
2873 ++ switch (hw->mac.type) {
2874 ++ case e1000_82575:
2875 ++ case e1000_i210:
2876 + rar_high |= E1000_RAH_POOL_1 *
2877 + adapter->mac_table[index].queue;
2878 +- else
2879 ++ break;
2880 ++ default:
2881 + rar_high |= E1000_RAH_POOL_1 <<
2882 + adapter->mac_table[index].queue;
2883 ++ break;
2884 ++ }
2885 + }
2886 +
2887 + wr32(E1000_RAL(index), rar_low);
2888 +diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
2889 +index 90ecc4b06462..90be4385bf36 100644
2890 +--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
2891 ++++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
2892 +@@ -3737,6 +3737,7 @@ static int ixgbevf_set_mac(struct net_device *netdev, void *p)
2893 + return -EPERM;
2894 +
2895 + ether_addr_copy(hw->mac.addr, addr->sa_data);
2896 ++ ether_addr_copy(hw->mac.perm_addr, addr->sa_data);
2897 + ether_addr_copy(netdev->dev_addr, addr->sa_data);
2898 +
2899 + return 0;
2900 +diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
2901 +index 42a6afcaae03..7924f241e3ad 100644
2902 +--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
2903 ++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
2904 +@@ -912,8 +912,10 @@ mlxsw_sp_port_vlan_bridge_join(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan,
2905 + int err;
2906 +
2907 + /* No need to continue if only VLAN flags were changed */
2908 +- if (mlxsw_sp_port_vlan->bridge_port)
2909 ++ if (mlxsw_sp_port_vlan->bridge_port) {
2910 ++ mlxsw_sp_port_vlan_put(mlxsw_sp_port_vlan);
2911 + return 0;
2912 ++ }
2913 +
2914 + err = mlxsw_sp_port_vlan_fid_join(mlxsw_sp_port_vlan, bridge_port);
2915 + if (err)
2916 +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
2917 +index 27f2e650e27b..1a9a382bf1c4 100644
2918 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
2919 ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
2920 +@@ -51,7 +51,7 @@
2921 + #include <linux/of_mdio.h>
2922 + #include "dwmac1000.h"
2923 +
2924 +-#define STMMAC_ALIGN(x) L1_CACHE_ALIGN(x)
2925 ++#define STMMAC_ALIGN(x) __ALIGN_KERNEL(x, SMP_CACHE_BYTES)
2926 + #define TSO_MAX_BUFF_SIZE (SZ_16K - 1)
2927 +
2928 + /* Module parameters */
2929 +diff --git a/drivers/net/ethernet/ti/cpsw-phy-sel.c b/drivers/net/ethernet/ti/cpsw-phy-sel.c
2930 +index 18013645e76c..0c1adad7415d 100644
2931 +--- a/drivers/net/ethernet/ti/cpsw-phy-sel.c
2932 ++++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c
2933 +@@ -177,12 +177,18 @@ void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave)
2934 + }
2935 +
2936 + dev = bus_find_device(&platform_bus_type, NULL, node, match);
2937 +- of_node_put(node);
2938 ++ if (!dev) {
2939 ++ dev_err(dev, "unable to find platform device for %pOF\n", node);
2940 ++ goto out;
2941 ++ }
2942 ++
2943 + priv = dev_get_drvdata(dev);
2944 +
2945 + priv->cpsw_phy_sel(priv, phy_mode, slave);
2946 +
2947 + put_device(dev);
2948 ++out:
2949 ++ of_node_put(node);
2950 + }
2951 + EXPORT_SYMBOL_GPL(cpsw_phy_sel);
2952 +
2953 +diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
2954 +index cb250cacf721..e33a6c672a0a 100644
2955 +--- a/drivers/net/hyperv/hyperv_net.h
2956 ++++ b/drivers/net/hyperv/hyperv_net.h
2957 +@@ -724,6 +724,8 @@ struct net_device_context {
2958 + struct hv_device *device_ctx;
2959 + /* netvsc_device */
2960 + struct netvsc_device __rcu *nvdev;
2961 ++ /* list of netvsc net_devices */
2962 ++ struct list_head list;
2963 + /* reconfigure work */
2964 + struct delayed_work dwork;
2965 + /* last reconfig time */
2966 +diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
2967 +index aeabeb107fed..6a77ef38c549 100644
2968 +--- a/drivers/net/hyperv/netvsc_drv.c
2969 ++++ b/drivers/net/hyperv/netvsc_drv.c
2970 +@@ -66,6 +66,8 @@ static int debug = -1;
2971 + module_param(debug, int, S_IRUGO);
2972 + MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
2973 +
2974 ++static LIST_HEAD(netvsc_dev_list);
2975 ++
2976 + static void netvsc_change_rx_flags(struct net_device *net, int change)
2977 + {
2978 + struct net_device_context *ndev_ctx = netdev_priv(net);
2979 +@@ -1749,13 +1751,10 @@ out_unlock:
2980 +
2981 + static struct net_device *get_netvsc_bymac(const u8 *mac)
2982 + {
2983 +- struct net_device *dev;
2984 +-
2985 +- ASSERT_RTNL();
2986 ++ struct net_device_context *ndev_ctx;
2987 +
2988 +- for_each_netdev(&init_net, dev) {
2989 +- if (dev->netdev_ops != &device_ops)
2990 +- continue; /* not a netvsc device */
2991 ++ list_for_each_entry(ndev_ctx, &netvsc_dev_list, list) {
2992 ++ struct net_device *dev = hv_get_drvdata(ndev_ctx->device_ctx);
2993 +
2994 + if (ether_addr_equal(mac, dev->perm_addr))
2995 + return dev;
2996 +@@ -1766,25 +1765,18 @@ static struct net_device *get_netvsc_bymac(const u8 *mac)
2997 +
2998 + static struct net_device *get_netvsc_byref(struct net_device *vf_netdev)
2999 + {
3000 ++ struct net_device_context *net_device_ctx;
3001 + struct net_device *dev;
3002 +
3003 +- ASSERT_RTNL();
3004 +-
3005 +- for_each_netdev(&init_net, dev) {
3006 +- struct net_device_context *net_device_ctx;
3007 ++ dev = netdev_master_upper_dev_get(vf_netdev);
3008 ++ if (!dev || dev->netdev_ops != &device_ops)
3009 ++ return NULL; /* not a netvsc device */
3010 +
3011 +- if (dev->netdev_ops != &device_ops)
3012 +- continue; /* not a netvsc device */
3013 ++ net_device_ctx = netdev_priv(dev);
3014 ++ if (!rtnl_dereference(net_device_ctx->nvdev))
3015 ++ return NULL; /* device is removed */
3016 +
3017 +- net_device_ctx = netdev_priv(dev);
3018 +- if (!rtnl_dereference(net_device_ctx->nvdev))
3019 +- continue; /* device is removed */
3020 +-
3021 +- if (rtnl_dereference(net_device_ctx->vf_netdev) == vf_netdev)
3022 +- return dev; /* a match */
3023 +- }
3024 +-
3025 +- return NULL;
3026 ++ return dev;
3027 + }
3028 +
3029 + /* Called when VF is injecting data into network stack.
3030 +@@ -2065,15 +2057,19 @@ static int netvsc_probe(struct hv_device *dev,
3031 + else
3032 + net->max_mtu = ETH_DATA_LEN;
3033 +
3034 +- ret = register_netdev(net);
3035 ++ rtnl_lock();
3036 ++ ret = register_netdevice(net);
3037 + if (ret != 0) {
3038 + pr_err("Unable to register netdev.\n");
3039 + goto register_failed;
3040 + }
3041 +
3042 +- return ret;
3043 ++ list_add(&net_device_ctx->list, &netvsc_dev_list);
3044 ++ rtnl_unlock();
3045 ++ return 0;
3046 +
3047 + register_failed:
3048 ++ rtnl_unlock();
3049 + rndis_filter_device_remove(dev, nvdev);
3050 + rndis_failed:
3051 + free_percpu(net_device_ctx->vf_stats);
3052 +@@ -2119,6 +2115,7 @@ static int netvsc_remove(struct hv_device *dev)
3053 + rndis_filter_device_remove(dev, nvdev);
3054 +
3055 + unregister_netdevice(net);
3056 ++ list_del(&ndev_ctx->list);
3057 +
3058 + rtnl_unlock();
3059 + rcu_read_unlock();
3060 +diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
3061 +index 0831b7142df7..0c5b68e7da51 100644
3062 +--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
3063 ++++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
3064 +@@ -218,7 +218,7 @@ out:
3065 +
3066 + static int mdio_mux_iproc_remove(struct platform_device *pdev)
3067 + {
3068 +- struct iproc_mdiomux_desc *md = dev_get_platdata(&pdev->dev);
3069 ++ struct iproc_mdiomux_desc *md = platform_get_drvdata(pdev);
3070 +
3071 + mdio_mux_uninit(md->mux_handle);
3072 + mdiobus_unregister(md->mii_bus);
3073 +diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
3074 +index 1b2fe74a44ea..e4a6ed88b9cf 100644
3075 +--- a/drivers/net/phy/phylink.c
3076 ++++ b/drivers/net/phy/phylink.c
3077 +@@ -561,6 +561,8 @@ void phylink_destroy(struct phylink *pl)
3078 + {
3079 + if (pl->sfp_bus)
3080 + sfp_unregister_upstream(pl->sfp_bus);
3081 ++ if (!IS_ERR(pl->link_gpio))
3082 ++ gpiod_put(pl->link_gpio);
3083 +
3084 + cancel_work_sync(&pl->resolve);
3085 + kfree(pl);
3086 +diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
3087 +index 0aa91ab9a0fb..9e3f632e22f1 100644
3088 +--- a/drivers/net/usb/lan78xx.c
3089 ++++ b/drivers/net/usb/lan78xx.c
3090 +@@ -1216,6 +1216,8 @@ static int lan78xx_link_reset(struct lan78xx_net *dev)
3091 + mod_timer(&dev->stat_monitor,
3092 + jiffies + STAT_UPDATE_TIMER);
3093 + }
3094 ++
3095 ++ tasklet_schedule(&dev->bh);
3096 + }
3097 +
3098 + return ret;
3099 +diff --git a/drivers/net/wireless/ath/regd.h b/drivers/net/wireless/ath/regd.h
3100 +index 5d80be213fac..869f276cc1d8 100644
3101 +--- a/drivers/net/wireless/ath/regd.h
3102 ++++ b/drivers/net/wireless/ath/regd.h
3103 +@@ -68,12 +68,14 @@ enum CountryCode {
3104 + CTRY_AUSTRALIA = 36,
3105 + CTRY_AUSTRIA = 40,
3106 + CTRY_AZERBAIJAN = 31,
3107 ++ CTRY_BAHAMAS = 44,
3108 + CTRY_BAHRAIN = 48,
3109 + CTRY_BANGLADESH = 50,
3110 + CTRY_BARBADOS = 52,
3111 + CTRY_BELARUS = 112,
3112 + CTRY_BELGIUM = 56,
3113 + CTRY_BELIZE = 84,
3114 ++ CTRY_BERMUDA = 60,
3115 + CTRY_BOLIVIA = 68,
3116 + CTRY_BOSNIA_HERZ = 70,
3117 + CTRY_BRAZIL = 76,
3118 +@@ -159,6 +161,7 @@ enum CountryCode {
3119 + CTRY_ROMANIA = 642,
3120 + CTRY_RUSSIA = 643,
3121 + CTRY_SAUDI_ARABIA = 682,
3122 ++ CTRY_SERBIA = 688,
3123 + CTRY_SERBIA_MONTENEGRO = 891,
3124 + CTRY_SINGAPORE = 702,
3125 + CTRY_SLOVAKIA = 703,
3126 +@@ -170,11 +173,13 @@ enum CountryCode {
3127 + CTRY_SWITZERLAND = 756,
3128 + CTRY_SYRIA = 760,
3129 + CTRY_TAIWAN = 158,
3130 ++ CTRY_TANZANIA = 834,
3131 + CTRY_THAILAND = 764,
3132 + CTRY_TRINIDAD_Y_TOBAGO = 780,
3133 + CTRY_TUNISIA = 788,
3134 + CTRY_TURKEY = 792,
3135 + CTRY_UAE = 784,
3136 ++ CTRY_UGANDA = 800,
3137 + CTRY_UKRAINE = 804,
3138 + CTRY_UNITED_KINGDOM = 826,
3139 + CTRY_UNITED_STATES = 840,
3140 +diff --git a/drivers/net/wireless/ath/regd_common.h b/drivers/net/wireless/ath/regd_common.h
3141 +index bdd2b4d61f2f..15bbd1e0d912 100644
3142 +--- a/drivers/net/wireless/ath/regd_common.h
3143 ++++ b/drivers/net/wireless/ath/regd_common.h
3144 +@@ -35,6 +35,7 @@ enum EnumRd {
3145 + FRANCE_RES = 0x31,
3146 + FCC3_FCCA = 0x3A,
3147 + FCC3_WORLD = 0x3B,
3148 ++ FCC3_ETSIC = 0x3F,
3149 +
3150 + ETSI1_WORLD = 0x37,
3151 + ETSI3_ETSIA = 0x32,
3152 +@@ -44,6 +45,7 @@ enum EnumRd {
3153 + ETSI4_ETSIC = 0x38,
3154 + ETSI5_WORLD = 0x39,
3155 + ETSI6_WORLD = 0x34,
3156 ++ ETSI8_WORLD = 0x3D,
3157 + ETSI_RESERVED = 0x33,
3158 +
3159 + MKK1_MKKA = 0x40,
3160 +@@ -59,6 +61,7 @@ enum EnumRd {
3161 + MKK1_MKKA1 = 0x4A,
3162 + MKK1_MKKA2 = 0x4B,
3163 + MKK1_MKKC = 0x4C,
3164 ++ APL2_FCCA = 0x4D,
3165 +
3166 + APL3_FCCA = 0x50,
3167 + APL1_WORLD = 0x52,
3168 +@@ -67,6 +70,7 @@ enum EnumRd {
3169 + APL1_ETSIC = 0x55,
3170 + APL2_ETSIC = 0x56,
3171 + APL5_WORLD = 0x58,
3172 ++ APL13_WORLD = 0x5A,
3173 + APL6_WORLD = 0x5B,
3174 + APL7_FCCA = 0x5C,
3175 + APL8_WORLD = 0x5D,
3176 +@@ -168,6 +172,7 @@ static struct reg_dmn_pair_mapping regDomainPairs[] = {
3177 + {FCC2_ETSIC, CTL_FCC, CTL_ETSI},
3178 + {FCC3_FCCA, CTL_FCC, CTL_FCC},
3179 + {FCC3_WORLD, CTL_FCC, CTL_ETSI},
3180 ++ {FCC3_ETSIC, CTL_FCC, CTL_ETSI},
3181 + {FCC4_FCCA, CTL_FCC, CTL_FCC},
3182 + {FCC5_FCCA, CTL_FCC, CTL_FCC},
3183 + {FCC6_FCCA, CTL_FCC, CTL_FCC},
3184 +@@ -179,6 +184,7 @@ static struct reg_dmn_pair_mapping regDomainPairs[] = {
3185 + {ETSI4_WORLD, CTL_ETSI, CTL_ETSI},
3186 + {ETSI5_WORLD, CTL_ETSI, CTL_ETSI},
3187 + {ETSI6_WORLD, CTL_ETSI, CTL_ETSI},
3188 ++ {ETSI8_WORLD, CTL_ETSI, CTL_ETSI},
3189 +
3190 + /* XXX: For ETSI3_ETSIA, Was NO_CTL meant for the 2 GHz band ? */
3191 + {ETSI3_ETSIA, CTL_ETSI, CTL_ETSI},
3192 +@@ -188,9 +194,11 @@ static struct reg_dmn_pair_mapping regDomainPairs[] = {
3193 + {FCC1_FCCA, CTL_FCC, CTL_FCC},
3194 + {APL1_WORLD, CTL_FCC, CTL_ETSI},
3195 + {APL2_WORLD, CTL_FCC, CTL_ETSI},
3196 ++ {APL2_FCCA, CTL_FCC, CTL_FCC},
3197 + {APL3_WORLD, CTL_FCC, CTL_ETSI},
3198 + {APL4_WORLD, CTL_FCC, CTL_ETSI},
3199 + {APL5_WORLD, CTL_FCC, CTL_ETSI},
3200 ++ {APL13_WORLD, CTL_ETSI, CTL_ETSI},
3201 + {APL6_WORLD, CTL_ETSI, CTL_ETSI},
3202 + {APL8_WORLD, CTL_ETSI, CTL_ETSI},
3203 + {APL9_WORLD, CTL_ETSI, CTL_ETSI},
3204 +@@ -298,6 +306,7 @@ static struct country_code_to_enum_rd allCountries[] = {
3205 + {CTRY_AUSTRALIA2, FCC6_WORLD, "AU"},
3206 + {CTRY_AUSTRIA, ETSI1_WORLD, "AT"},
3207 + {CTRY_AZERBAIJAN, ETSI4_WORLD, "AZ"},
3208 ++ {CTRY_BAHAMAS, FCC3_WORLD, "BS"},
3209 + {CTRY_BAHRAIN, APL6_WORLD, "BH"},
3210 + {CTRY_BANGLADESH, NULL1_WORLD, "BD"},
3211 + {CTRY_BARBADOS, FCC2_WORLD, "BB"},
3212 +@@ -305,6 +314,7 @@ static struct country_code_to_enum_rd allCountries[] = {
3213 + {CTRY_BELGIUM, ETSI1_WORLD, "BE"},
3214 + {CTRY_BELGIUM2, ETSI4_WORLD, "BL"},
3215 + {CTRY_BELIZE, APL1_ETSIC, "BZ"},
3216 ++ {CTRY_BERMUDA, FCC3_FCCA, "BM"},
3217 + {CTRY_BOLIVIA, APL1_ETSIC, "BO"},
3218 + {CTRY_BOSNIA_HERZ, ETSI1_WORLD, "BA"},
3219 + {CTRY_BRAZIL, FCC3_WORLD, "BR"},
3220 +@@ -444,6 +454,7 @@ static struct country_code_to_enum_rd allCountries[] = {
3221 + {CTRY_ROMANIA, NULL1_WORLD, "RO"},
3222 + {CTRY_RUSSIA, NULL1_WORLD, "RU"},
3223 + {CTRY_SAUDI_ARABIA, NULL1_WORLD, "SA"},
3224 ++ {CTRY_SERBIA, ETSI1_WORLD, "RS"},
3225 + {CTRY_SERBIA_MONTENEGRO, ETSI1_WORLD, "CS"},
3226 + {CTRY_SINGAPORE, APL6_WORLD, "SG"},
3227 + {CTRY_SLOVAKIA, ETSI1_WORLD, "SK"},
3228 +@@ -455,10 +466,12 @@ static struct country_code_to_enum_rd allCountries[] = {
3229 + {CTRY_SWITZERLAND, ETSI1_WORLD, "CH"},
3230 + {CTRY_SYRIA, NULL1_WORLD, "SY"},
3231 + {CTRY_TAIWAN, APL3_FCCA, "TW"},
3232 ++ {CTRY_TANZANIA, APL1_WORLD, "TZ"},
3233 + {CTRY_THAILAND, FCC3_WORLD, "TH"},
3234 + {CTRY_TRINIDAD_Y_TOBAGO, FCC3_WORLD, "TT"},
3235 + {CTRY_TUNISIA, ETSI3_WORLD, "TN"},
3236 + {CTRY_TURKEY, ETSI3_WORLD, "TR"},
3237 ++ {CTRY_UGANDA, FCC3_WORLD, "UG"},
3238 + {CTRY_UKRAINE, NULL1_WORLD, "UA"},
3239 + {CTRY_UAE, NULL1_WORLD, "AE"},
3240 + {CTRY_UNITED_KINGDOM, ETSI1_WORLD, "GB"},
3241 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
3242 +index cd587325e286..dd6e27513cc1 100644
3243 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
3244 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
3245 +@@ -1098,6 +1098,7 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = {
3246 + BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_43340),
3247 + BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_43341),
3248 + BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_43362),
3249 ++ BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_43364),
3250 + BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_4335_4339),
3251 + BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_4339),
3252 + BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_43430),
3253 +diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
3254 +index a06b6612b658..ca99c3cf41c2 100644
3255 +--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
3256 ++++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
3257 +@@ -901,6 +901,8 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans)
3258 + }
3259 + def_rxq = trans_pcie->rxq;
3260 +
3261 ++ cancel_work_sync(&rba->rx_alloc);
3262 ++
3263 + spin_lock(&rba->lock);
3264 + atomic_set(&rba->req_pending, 0);
3265 + atomic_set(&rba->req_ready, 0);
3266 +diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
3267 +index f4f2b9b27e32..50890cab8807 100644
3268 +--- a/drivers/net/wireless/marvell/mwifiex/usb.c
3269 ++++ b/drivers/net/wireless/marvell/mwifiex/usb.c
3270 +@@ -644,6 +644,9 @@ static void mwifiex_usb_disconnect(struct usb_interface *intf)
3271 + MWIFIEX_FUNC_SHUTDOWN);
3272 + }
3273 +
3274 ++ if (adapter->workqueue)
3275 ++ flush_workqueue(adapter->workqueue);
3276 ++
3277 + mwifiex_usb_free(card);
3278 +
3279 + mwifiex_dbg(adapter, FATAL,
3280 +diff --git a/drivers/net/wireless/marvell/mwifiex/util.c b/drivers/net/wireless/marvell/mwifiex/util.c
3281 +index 0cd68ffc2c74..51ccf10f4413 100644
3282 +--- a/drivers/net/wireless/marvell/mwifiex/util.c
3283 ++++ b/drivers/net/wireless/marvell/mwifiex/util.c
3284 +@@ -708,12 +708,14 @@ void mwifiex_hist_data_set(struct mwifiex_private *priv, u8 rx_rate, s8 snr,
3285 + s8 nflr)
3286 + {
3287 + struct mwifiex_histogram_data *phist_data = priv->hist_data;
3288 ++ s8 nf = -nflr;
3289 ++ s8 rssi = snr - nflr;
3290 +
3291 + atomic_inc(&phist_data->num_samples);
3292 + atomic_inc(&phist_data->rx_rate[rx_rate]);
3293 +- atomic_inc(&phist_data->snr[snr]);
3294 +- atomic_inc(&phist_data->noise_flr[128 + nflr]);
3295 +- atomic_inc(&phist_data->sig_str[nflr - snr]);
3296 ++ atomic_inc(&phist_data->snr[snr + 128]);
3297 ++ atomic_inc(&phist_data->noise_flr[nf + 128]);
3298 ++ atomic_inc(&phist_data->sig_str[rssi + 128]);
3299 + }
3300 +
3301 + /* function to reset histogram data during init/reset */
3302 +diff --git a/drivers/net/wireless/rsi/rsi_91x_hal.c b/drivers/net/wireless/rsi/rsi_91x_hal.c
3303 +index 070dfd68bb83..120b0ff545c1 100644
3304 +--- a/drivers/net/wireless/rsi/rsi_91x_hal.c
3305 ++++ b/drivers/net/wireless/rsi/rsi_91x_hal.c
3306 +@@ -557,28 +557,32 @@ static int bl_write_header(struct rsi_hw *adapter, u8 *flash_content,
3307 + u32 content_size)
3308 + {
3309 + struct rsi_host_intf_ops *hif_ops = adapter->host_intf_ops;
3310 +- struct bl_header bl_hdr;
3311 ++ struct bl_header *bl_hdr;
3312 + u32 write_addr, write_len;
3313 + int status;
3314 +
3315 +- bl_hdr.flags = 0;
3316 +- bl_hdr.image_no = cpu_to_le32(adapter->priv->coex_mode);
3317 +- bl_hdr.check_sum = cpu_to_le32(
3318 +- *(u32 *)&flash_content[CHECK_SUM_OFFSET]);
3319 +- bl_hdr.flash_start_address = cpu_to_le32(
3320 +- *(u32 *)&flash_content[ADDR_OFFSET]);
3321 +- bl_hdr.flash_len = cpu_to_le32(*(u32 *)&flash_content[LEN_OFFSET]);
3322 ++ bl_hdr = kzalloc(sizeof(*bl_hdr), GFP_KERNEL);
3323 ++ if (!bl_hdr)
3324 ++ return -ENOMEM;
3325 ++
3326 ++ bl_hdr->flags = 0;
3327 ++ bl_hdr->image_no = cpu_to_le32(adapter->priv->coex_mode);
3328 ++ bl_hdr->check_sum =
3329 ++ cpu_to_le32(*(u32 *)&flash_content[CHECK_SUM_OFFSET]);
3330 ++ bl_hdr->flash_start_address =
3331 ++ cpu_to_le32(*(u32 *)&flash_content[ADDR_OFFSET]);
3332 ++ bl_hdr->flash_len = cpu_to_le32(*(u32 *)&flash_content[LEN_OFFSET]);
3333 + write_len = sizeof(struct bl_header);
3334 +
3335 + if (adapter->rsi_host_intf == RSI_HOST_INTF_USB) {
3336 + write_addr = PING_BUFFER_ADDRESS;
3337 + status = hif_ops->write_reg_multiple(adapter, write_addr,
3338 +- (u8 *)&bl_hdr, write_len);
3339 ++ (u8 *)bl_hdr, write_len);
3340 + if (status < 0) {
3341 + rsi_dbg(ERR_ZONE,
3342 + "%s: Failed to load Version/CRC structure\n",
3343 + __func__);
3344 +- return status;
3345 ++ goto fail;
3346 + }
3347 + } else {
3348 + write_addr = PING_BUFFER_ADDRESS >> 16;
3349 +@@ -587,20 +591,23 @@ static int bl_write_header(struct rsi_hw *adapter, u8 *flash_content,
3350 + rsi_dbg(ERR_ZONE,
3351 + "%s: Unable to set ms word to common reg\n",
3352 + __func__);
3353 +- return status;
3354 ++ goto fail;
3355 + }
3356 + write_addr = RSI_SD_REQUEST_MASTER |
3357 + (PING_BUFFER_ADDRESS & 0xFFFF);
3358 + status = hif_ops->write_reg_multiple(adapter, write_addr,
3359 +- (u8 *)&bl_hdr, write_len);
3360 ++ (u8 *)bl_hdr, write_len);
3361 + if (status < 0) {
3362 + rsi_dbg(ERR_ZONE,
3363 + "%s: Failed to load Version/CRC structure\n",
3364 + __func__);
3365 +- return status;
3366 ++ goto fail;
3367 + }
3368 + }
3369 +- return 0;
3370 ++ status = 0;
3371 ++fail:
3372 ++ kfree(bl_hdr);
3373 ++ return status;
3374 + }
3375 +
3376 + static u32 read_flash_capacity(struct rsi_hw *adapter)
3377 +diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c
3378 +index 370161ca2a1c..0362967874aa 100644
3379 +--- a/drivers/net/wireless/rsi/rsi_91x_sdio.c
3380 ++++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c
3381 +@@ -161,7 +161,6 @@ static void rsi_reset_card(struct sdio_func *pfunction)
3382 + int err;
3383 + struct mmc_card *card = pfunction->card;
3384 + struct mmc_host *host = card->host;
3385 +- s32 bit = (fls(host->ocr_avail) - 1);
3386 + u8 cmd52_resp;
3387 + u32 clock, resp, i;
3388 + u16 rca;
3389 +@@ -181,7 +180,6 @@ static void rsi_reset_card(struct sdio_func *pfunction)
3390 + msleep(20);
3391 +
3392 + /* Initialize the SDIO card */
3393 +- host->ios.vdd = bit;
3394 + host->ios.chip_select = MMC_CS_DONTCARE;
3395 + host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
3396 + host->ios.power_mode = MMC_POWER_UP;
3397 +@@ -970,17 +968,21 @@ static void ulp_read_write(struct rsi_hw *adapter, u16 addr, u32 data,
3398 + /*This function resets and re-initializes the chip.*/
3399 + static void rsi_reset_chip(struct rsi_hw *adapter)
3400 + {
3401 +- __le32 data;
3402 ++ u8 *data;
3403 + u8 sdio_interrupt_status = 0;
3404 + u8 request = 1;
3405 + int ret;
3406 +
3407 ++ data = kzalloc(sizeof(u32), GFP_KERNEL);
3408 ++ if (!data)
3409 ++ return;
3410 ++
3411 + rsi_dbg(INFO_ZONE, "Writing disable to wakeup register\n");
3412 + ret = rsi_sdio_write_register(adapter, 0, SDIO_WAKEUP_REG, &request);
3413 + if (ret < 0) {
3414 + rsi_dbg(ERR_ZONE,
3415 + "%s: Failed to write SDIO wakeup register\n", __func__);
3416 +- return;
3417 ++ goto err;
3418 + }
3419 + msleep(20);
3420 + ret = rsi_sdio_read_register(adapter, RSI_FN1_INT_REGISTER,
3421 +@@ -988,7 +990,7 @@ static void rsi_reset_chip(struct rsi_hw *adapter)
3422 + if (ret < 0) {
3423 + rsi_dbg(ERR_ZONE, "%s: Failed to Read Intr Status Register\n",
3424 + __func__);
3425 +- return;
3426 ++ goto err;
3427 + }
3428 + rsi_dbg(INFO_ZONE, "%s: Intr Status Register value = %d\n",
3429 + __func__, sdio_interrupt_status);
3430 +@@ -998,17 +1000,17 @@ static void rsi_reset_chip(struct rsi_hw *adapter)
3431 + rsi_dbg(ERR_ZONE,
3432 + "%s: Unable to set ms word to common reg\n",
3433 + __func__);
3434 +- return;
3435 ++ goto err;
3436 + }
3437 +
3438 +- data = TA_HOLD_THREAD_VALUE;
3439 ++ put_unaligned_le32(TA_HOLD_THREAD_VALUE, data);
3440 + if (rsi_sdio_write_register_multiple(adapter, TA_HOLD_THREAD_REG |
3441 + RSI_SD_REQUEST_MASTER,
3442 +- (u8 *)&data, 4)) {
3443 ++ data, 4)) {
3444 + rsi_dbg(ERR_ZONE,
3445 + "%s: Unable to hold Thread-Arch processor threads\n",
3446 + __func__);
3447 +- return;
3448 ++ goto err;
3449 + }
3450 +
3451 + /* This msleep will ensure Thread-Arch processor to go to hold
3452 +@@ -1029,6 +1031,9 @@ static void rsi_reset_chip(struct rsi_hw *adapter)
3453 + * read write operations to complete for chip reset.
3454 + */
3455 + msleep(500);
3456 ++err:
3457 ++ kfree(data);
3458 ++ return;
3459 + }
3460 +
3461 + /**
3462 +diff --git a/drivers/net/wireless/rsi/rsi_sdio.h b/drivers/net/wireless/rsi/rsi_sdio.h
3463 +index 903392039200..6788fbbdd166 100644
3464 +--- a/drivers/net/wireless/rsi/rsi_sdio.h
3465 ++++ b/drivers/net/wireless/rsi/rsi_sdio.h
3466 +@@ -85,7 +85,7 @@ enum sdio_interrupt_type {
3467 + #define TA_SOFT_RST_CLR 0
3468 + #define TA_SOFT_RST_SET BIT(0)
3469 + #define TA_PC_ZERO 0
3470 +-#define TA_HOLD_THREAD_VALUE cpu_to_le32(0xF)
3471 ++#define TA_HOLD_THREAD_VALUE 0xF
3472 + #define TA_RELEASE_THREAD_VALUE cpu_to_le32(0xF)
3473 + #define TA_BASE_ADDR 0x2200
3474 + #define MISC_CFG_BASE_ADDR 0x4105
3475 +diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c
3476 +index f8a1fea64e25..219d1a86b92e 100644
3477 +--- a/drivers/net/wireless/ti/wlcore/sdio.c
3478 ++++ b/drivers/net/wireless/ti/wlcore/sdio.c
3479 +@@ -406,6 +406,11 @@ static int wl1271_suspend(struct device *dev)
3480 + mmc_pm_flag_t sdio_flags;
3481 + int ret = 0;
3482 +
3483 ++ if (!wl) {
3484 ++ dev_err(dev, "no wilink module was probed\n");
3485 ++ goto out;
3486 ++ }
3487 ++
3488 + dev_dbg(dev, "wl1271 suspend. wow_enabled: %d\n",
3489 + wl->wow_enabled);
3490 +
3491 +diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
3492 +index f07b9c9bb5ba..dfc076f9ee4b 100644
3493 +--- a/drivers/net/xen-netfront.c
3494 ++++ b/drivers/net/xen-netfront.c
3495 +@@ -87,6 +87,7 @@ struct netfront_cb {
3496 + /* IRQ name is queue name with "-tx" or "-rx" appended */
3497 + #define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3)
3498 +
3499 ++static DECLARE_WAIT_QUEUE_HEAD(module_load_q);
3500 + static DECLARE_WAIT_QUEUE_HEAD(module_unload_q);
3501 +
3502 + struct netfront_stats {
3503 +@@ -239,7 +240,7 @@ static void rx_refill_timeout(unsigned long data)
3504 + static int netfront_tx_slot_available(struct netfront_queue *queue)
3505 + {
3506 + return (queue->tx.req_prod_pvt - queue->tx.rsp_cons) <
3507 +- (NET_TX_RING_SIZE - MAX_SKB_FRAGS - 2);
3508 ++ (NET_TX_RING_SIZE - XEN_NETIF_NR_SLOTS_MIN - 1);
3509 + }
3510 +
3511 + static void xennet_maybe_wake_tx(struct netfront_queue *queue)
3512 +@@ -790,7 +791,7 @@ static int xennet_get_responses(struct netfront_queue *queue,
3513 + RING_IDX cons = queue->rx.rsp_cons;
3514 + struct sk_buff *skb = xennet_get_rx_skb(queue, cons);
3515 + grant_ref_t ref = xennet_get_rx_ref(queue, cons);
3516 +- int max = MAX_SKB_FRAGS + (rx->status <= RX_COPY_THRESHOLD);
3517 ++ int max = XEN_NETIF_NR_SLOTS_MIN + (rx->status <= RX_COPY_THRESHOLD);
3518 + int slots = 1;
3519 + int err = 0;
3520 + unsigned long ret;
3521 +@@ -1330,6 +1331,11 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
3522 + netif_carrier_off(netdev);
3523 +
3524 + xenbus_switch_state(dev, XenbusStateInitialising);
3525 ++ wait_event(module_load_q,
3526 ++ xenbus_read_driver_state(dev->otherend) !=
3527 ++ XenbusStateClosed &&
3528 ++ xenbus_read_driver_state(dev->otherend) !=
3529 ++ XenbusStateUnknown);
3530 + return netdev;
3531 +
3532 + exit:
3533 +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
3534 +index 4cac4755abef..f5643d107cc6 100644
3535 +--- a/drivers/nvme/host/pci.c
3536 ++++ b/drivers/nvme/host/pci.c
3537 +@@ -2519,6 +2519,9 @@ static pci_ers_result_t nvme_slot_reset(struct pci_dev *pdev)
3538 +
3539 + static void nvme_error_resume(struct pci_dev *pdev)
3540 + {
3541 ++ struct nvme_dev *dev = pci_get_drvdata(pdev);
3542 ++
3543 ++ flush_work(&dev->ctrl.reset_work);
3544 + pci_cleanup_aer_uncorrect_error_status(pdev);
3545 + }
3546 +
3547 +@@ -2562,6 +2565,8 @@ static const struct pci_device_id nvme_id_table[] = {
3548 + .driver_data = NVME_QUIRK_LIGHTNVM, },
3549 + { PCI_DEVICE(0x1d1d, 0x2807), /* CNEX WL */
3550 + .driver_data = NVME_QUIRK_LIGHTNVM, },
3551 ++ { PCI_DEVICE(0x1d1d, 0x2601), /* CNEX Granby */
3552 ++ .driver_data = NVME_QUIRK_LIGHTNVM, },
3553 + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) },
3554 + { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001) },
3555 + { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2003) },
3556 +diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
3557 +index 93a082e0bdd4..48a831d58e7a 100644
3558 +--- a/drivers/nvme/host/rdma.c
3559 ++++ b/drivers/nvme/host/rdma.c
3560 +@@ -796,7 +796,7 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,
3561 + if (error) {
3562 + dev_err(ctrl->ctrl.device,
3563 + "prop_get NVME_REG_CAP failed\n");
3564 +- goto out_cleanup_queue;
3565 ++ goto out_stop_queue;
3566 + }
3567 +
3568 + ctrl->ctrl.sqsize =
3569 +@@ -804,23 +804,25 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,
3570 +
3571 + error = nvme_enable_ctrl(&ctrl->ctrl, ctrl->ctrl.cap);
3572 + if (error)
3573 +- goto out_cleanup_queue;
3574 ++ goto out_stop_queue;
3575 +
3576 + ctrl->ctrl.max_hw_sectors =
3577 + (ctrl->max_fr_pages - 1) << (ilog2(SZ_4K) - 9);
3578 +
3579 + error = nvme_init_identify(&ctrl->ctrl);
3580 + if (error)
3581 +- goto out_cleanup_queue;
3582 ++ goto out_stop_queue;
3583 +
3584 + error = nvme_rdma_alloc_qe(ctrl->queues[0].device->dev,
3585 + &ctrl->async_event_sqe, sizeof(struct nvme_command),
3586 + DMA_TO_DEVICE);
3587 + if (error)
3588 +- goto out_cleanup_queue;
3589 ++ goto out_stop_queue;
3590 +
3591 + return 0;
3592 +
3593 ++out_stop_queue:
3594 ++ nvme_rdma_stop_queue(&ctrl->queues[0]);
3595 + out_cleanup_queue:
3596 + if (new)
3597 + blk_cleanup_queue(ctrl->ctrl.admin_q);
3598 +diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
3599 +index d12e5de78e70..2afafd5d8915 100644
3600 +--- a/drivers/nvmem/core.c
3601 ++++ b/drivers/nvmem/core.c
3602 +@@ -1049,6 +1049,8 @@ static inline void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
3603 +
3604 + /* setup the first byte with lsb bits from nvmem */
3605 + rc = nvmem_reg_read(nvmem, cell->offset, &v, 1);
3606 ++ if (rc)
3607 ++ goto err;
3608 + *b++ |= GENMASK(bit_offset - 1, 0) & v;
3609 +
3610 + /* setup rest of the byte if any */
3611 +@@ -1067,11 +1069,16 @@ static inline void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
3612 + /* setup the last byte with msb bits from nvmem */
3613 + rc = nvmem_reg_read(nvmem,
3614 + cell->offset + cell->bytes - 1, &v, 1);
3615 ++ if (rc)
3616 ++ goto err;
3617 + *p |= GENMASK(7, (nbits + bit_offset) % BITS_PER_BYTE) & v;
3618 +
3619 + }
3620 +
3621 + return buf;
3622 ++err:
3623 ++ kfree(buf);
3624 ++ return ERR_PTR(rc);
3625 + }
3626 +
3627 + /**
3628 +diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
3629 +index 087645116ecb..c78fd9c2cf8c 100644
3630 +--- a/drivers/pci/host/pci-xgene.c
3631 ++++ b/drivers/pci/host/pci-xgene.c
3632 +@@ -686,7 +686,6 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
3633 +
3634 + bus = bridge->bus;
3635 +
3636 +- pci_scan_child_bus(bus);
3637 + pci_assign_unassigned_bus_resources(bus);
3638 + list_for_each_entry(child, &bus->children, node)
3639 + pcie_bus_configure_settings(child);
3640 +diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
3641 +index 05832b597e53..46c2ee2caf28 100644
3642 +--- a/drivers/pci/hotplug/pciehp_hpc.c
3643 ++++ b/drivers/pci/hotplug/pciehp_hpc.c
3644 +@@ -863,6 +863,13 @@ struct controller *pcie_init(struct pcie_device *dev)
3645 + if (pdev->hotplug_user_indicators)
3646 + slot_cap &= ~(PCI_EXP_SLTCAP_AIP | PCI_EXP_SLTCAP_PIP);
3647 +
3648 ++ /*
3649 ++ * We assume no Thunderbolt controllers support Command Complete events,
3650 ++ * but some controllers falsely claim they do.
3651 ++ */
3652 ++ if (pdev->is_thunderbolt)
3653 ++ slot_cap |= PCI_EXP_SLTCAP_NCCS;
3654 ++
3655 + ctrl->slot_cap = slot_cap;
3656 + mutex_init(&ctrl->ctrl_lock);
3657 + init_waitqueue_head(&ctrl->queue);
3658 +diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
3659 +index 00fa4278c1f4..c3f0473d1afa 100644
3660 +--- a/drivers/pci/pci-sysfs.c
3661 ++++ b/drivers/pci/pci-sysfs.c
3662 +@@ -305,13 +305,16 @@ static ssize_t enable_store(struct device *dev, struct device_attribute *attr,
3663 + if (!capable(CAP_SYS_ADMIN))
3664 + return -EPERM;
3665 +
3666 +- if (!val) {
3667 +- if (pci_is_enabled(pdev))
3668 +- pci_disable_device(pdev);
3669 +- else
3670 +- result = -EIO;
3671 +- } else
3672 ++ device_lock(dev);
3673 ++ if (dev->driver)
3674 ++ result = -EBUSY;
3675 ++ else if (val)
3676 + result = pci_enable_device(pdev);
3677 ++ else if (pci_is_enabled(pdev))
3678 ++ pci_disable_device(pdev);
3679 ++ else
3680 ++ result = -EIO;
3681 ++ device_unlock(dev);
3682 +
3683 + return result < 0 ? result : count;
3684 + }
3685 +diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
3686 +index f285cd74088e..4bccaf688aad 100644
3687 +--- a/drivers/pci/probe.c
3688 ++++ b/drivers/pci/probe.c
3689 +@@ -516,12 +516,14 @@ static void devm_pci_release_host_bridge_dev(struct device *dev)
3690 +
3691 + if (bridge->release_fn)
3692 + bridge->release_fn(bridge);
3693 ++
3694 ++ pci_free_resource_list(&bridge->windows);
3695 + }
3696 +
3697 + static void pci_release_host_bridge_dev(struct device *dev)
3698 + {
3699 + devm_pci_release_host_bridge_dev(dev);
3700 +- pci_free_host_bridge(to_pci_host_bridge(dev));
3701 ++ kfree(to_pci_host_bridge(dev));
3702 + }
3703 +
3704 + struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
3705 +diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
3706 +index b1ca838dd80a..e61e2f8c91ce 100644
3707 +--- a/drivers/pinctrl/pinctrl-at91-pio4.c
3708 ++++ b/drivers/pinctrl/pinctrl-at91-pio4.c
3709 +@@ -576,8 +576,10 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
3710 + for_each_child_of_node(np_config, np) {
3711 + ret = atmel_pctl_dt_subnode_to_map(pctldev, np, map,
3712 + &reserved_maps, num_maps);
3713 +- if (ret < 0)
3714 ++ if (ret < 0) {
3715 ++ of_node_put(np);
3716 + break;
3717 ++ }
3718 + }
3719 + }
3720 +
3721 +diff --git a/drivers/regulator/cpcap-regulator.c b/drivers/regulator/cpcap-regulator.c
3722 +index f541b80f1b54..bd910fe123d9 100644
3723 +--- a/drivers/regulator/cpcap-regulator.c
3724 ++++ b/drivers/regulator/cpcap-regulator.c
3725 +@@ -222,7 +222,7 @@ static unsigned int cpcap_map_mode(unsigned int mode)
3726 + case CPCAP_BIT_AUDIO_LOW_PWR:
3727 + return REGULATOR_MODE_STANDBY;
3728 + default:
3729 +- return -EINVAL;
3730 ++ return REGULATOR_MODE_INVALID;
3731 + }
3732 + }
3733 +
3734 +diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
3735 +index c9875355905d..a3bf7c993723 100644
3736 +--- a/drivers/regulator/of_regulator.c
3737 ++++ b/drivers/regulator/of_regulator.c
3738 +@@ -31,6 +31,7 @@ static void of_get_regulation_constraints(struct device_node *np,
3739 + struct regulation_constraints *constraints = &(*init_data)->constraints;
3740 + struct regulator_state *suspend_state;
3741 + struct device_node *suspend_np;
3742 ++ unsigned int mode;
3743 + int ret, i;
3744 + u32 pval;
3745 +
3746 +@@ -124,11 +125,11 @@ static void of_get_regulation_constraints(struct device_node *np,
3747 +
3748 + if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) {
3749 + if (desc && desc->of_map_mode) {
3750 +- ret = desc->of_map_mode(pval);
3751 +- if (ret == -EINVAL)
3752 ++ mode = desc->of_map_mode(pval);
3753 ++ if (mode == REGULATOR_MODE_INVALID)
3754 + pr_err("%s: invalid mode %u\n", np->name, pval);
3755 + else
3756 +- constraints->initial_mode = ret;
3757 ++ constraints->initial_mode = mode;
3758 + } else {
3759 + pr_warn("%s: mapping for mode %d not defined\n",
3760 + np->name, pval);
3761 +@@ -163,12 +164,12 @@ static void of_get_regulation_constraints(struct device_node *np,
3762 + if (!of_property_read_u32(suspend_np, "regulator-mode",
3763 + &pval)) {
3764 + if (desc && desc->of_map_mode) {
3765 +- ret = desc->of_map_mode(pval);
3766 +- if (ret == -EINVAL)
3767 ++ mode = desc->of_map_mode(pval);
3768 ++ if (mode == REGULATOR_MODE_INVALID)
3769 + pr_err("%s: invalid mode %u\n",
3770 + np->name, pval);
3771 + else
3772 +- suspend_state->mode = ret;
3773 ++ suspend_state->mode = mode;
3774 + } else {
3775 + pr_warn("%s: mapping for mode %d not defined\n",
3776 + np->name, pval);
3777 +diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
3778 +index 63922a2167e5..659e516455be 100644
3779 +--- a/drivers/regulator/pfuze100-regulator.c
3780 ++++ b/drivers/regulator/pfuze100-regulator.c
3781 +@@ -158,6 +158,7 @@ static const struct regulator_ops pfuze100_sw_regulator_ops = {
3782 + static const struct regulator_ops pfuze100_swb_regulator_ops = {
3783 + .enable = regulator_enable_regmap,
3784 + .disable = regulator_disable_regmap,
3785 ++ .is_enabled = regulator_is_enabled_regmap,
3786 + .list_voltage = regulator_list_voltage_table,
3787 + .map_voltage = regulator_map_voltage_ascend,
3788 + .set_voltage_sel = regulator_set_voltage_sel_regmap,
3789 +diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
3790 +index a4456db5849d..884c7505ed91 100644
3791 +--- a/drivers/regulator/twl-regulator.c
3792 ++++ b/drivers/regulator/twl-regulator.c
3793 +@@ -274,7 +274,7 @@ static inline unsigned int twl4030reg_map_mode(unsigned int mode)
3794 + case RES_STATE_SLEEP:
3795 + return REGULATOR_MODE_STANDBY;
3796 + default:
3797 +- return -EINVAL;
3798 ++ return REGULATOR_MODE_INVALID;
3799 + }
3800 + }
3801 +
3802 +diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
3803 +index 9eb32ead63db..e4f951e968a4 100644
3804 +--- a/drivers/rtc/interface.c
3805 ++++ b/drivers/rtc/interface.c
3806 +@@ -359,6 +359,11 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
3807 + {
3808 + int err;
3809 +
3810 ++ if (!rtc->ops)
3811 ++ return -ENODEV;
3812 ++ else if (!rtc->ops->set_alarm)
3813 ++ return -EINVAL;
3814 ++
3815 + err = rtc_valid_tm(&alarm->time);
3816 + if (err != 0)
3817 + return err;
3818 +diff --git a/drivers/rtc/rtc-tps6586x.c b/drivers/rtc/rtc-tps6586x.c
3819 +index a3418a8a3796..97fdc99bfeef 100644
3820 +--- a/drivers/rtc/rtc-tps6586x.c
3821 ++++ b/drivers/rtc/rtc-tps6586x.c
3822 +@@ -276,14 +276,15 @@ static int tps6586x_rtc_probe(struct platform_device *pdev)
3823 + device_init_wakeup(&pdev->dev, 1);
3824 +
3825 + platform_set_drvdata(pdev, rtc);
3826 +- rtc->rtc = devm_rtc_device_register(&pdev->dev, dev_name(&pdev->dev),
3827 +- &tps6586x_rtc_ops, THIS_MODULE);
3828 ++ rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
3829 + if (IS_ERR(rtc->rtc)) {
3830 + ret = PTR_ERR(rtc->rtc);
3831 +- dev_err(&pdev->dev, "RTC device register: ret %d\n", ret);
3832 ++ dev_err(&pdev->dev, "RTC allocate device: ret %d\n", ret);
3833 + goto fail_rtc_register;
3834 + }
3835 +
3836 ++ rtc->rtc->ops = &tps6586x_rtc_ops;
3837 ++
3838 + ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
3839 + tps6586x_rtc_irq,
3840 + IRQF_ONESHOT,
3841 +@@ -294,6 +295,13 @@ static int tps6586x_rtc_probe(struct platform_device *pdev)
3842 + goto fail_rtc_register;
3843 + }
3844 + disable_irq(rtc->irq);
3845 ++
3846 ++ ret = rtc_register_device(rtc->rtc);
3847 ++ if (ret) {
3848 ++ dev_err(&pdev->dev, "RTC device register: ret %d\n", ret);
3849 ++ goto fail_rtc_register;
3850 ++ }
3851 ++
3852 + return 0;
3853 +
3854 + fail_rtc_register:
3855 +diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c
3856 +index d0244d7979fc..a56b526db89a 100644
3857 +--- a/drivers/rtc/rtc-tps65910.c
3858 ++++ b/drivers/rtc/rtc-tps65910.c
3859 +@@ -380,6 +380,10 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
3860 + if (!tps_rtc)
3861 + return -ENOMEM;
3862 +
3863 ++ tps_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
3864 ++ if (IS_ERR(tps_rtc->rtc))
3865 ++ return PTR_ERR(tps_rtc->rtc);
3866 ++
3867 + /* Clear pending interrupts */
3868 + ret = regmap_read(tps65910->regmap, TPS65910_RTC_STATUS, &rtc_reg);
3869 + if (ret < 0)
3870 +@@ -421,10 +425,10 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
3871 + tps_rtc->irq = irq;
3872 + device_set_wakeup_capable(&pdev->dev, 1);
3873 +
3874 +- tps_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
3875 +- &tps65910_rtc_ops, THIS_MODULE);
3876 +- if (IS_ERR(tps_rtc->rtc)) {
3877 +- ret = PTR_ERR(tps_rtc->rtc);
3878 ++ tps_rtc->rtc->ops = &tps65910_rtc_ops;
3879 ++
3880 ++ ret = rtc_register_device(tps_rtc->rtc);
3881 ++ if (ret) {
3882 + dev_err(&pdev->dev, "RTC device register: err %d\n", ret);
3883 + return ret;
3884 + }
3885 +diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
3886 +index 7ce22967fd16..7ed010714f29 100644
3887 +--- a/drivers/rtc/rtc-vr41xx.c
3888 ++++ b/drivers/rtc/rtc-vr41xx.c
3889 +@@ -292,13 +292,14 @@ static int rtc_probe(struct platform_device *pdev)
3890 + goto err_rtc1_iounmap;
3891 + }
3892 +
3893 +- rtc = devm_rtc_device_register(&pdev->dev, rtc_name, &vr41xx_rtc_ops,
3894 +- THIS_MODULE);
3895 ++ rtc = devm_rtc_allocate_device(&pdev->dev);
3896 + if (IS_ERR(rtc)) {
3897 + retval = PTR_ERR(rtc);
3898 + goto err_iounmap_all;
3899 + }
3900 +
3901 ++ rtc->ops = &vr41xx_rtc_ops;
3902 ++
3903 + rtc->max_user_freq = MAX_PERIODIC_RATE;
3904 +
3905 + spin_lock_irq(&rtc_lock);
3906 +@@ -340,6 +341,10 @@ static int rtc_probe(struct platform_device *pdev)
3907 +
3908 + dev_info(&pdev->dev, "Real Time Clock of NEC VR4100 series\n");
3909 +
3910 ++ retval = rtc_register_device(rtc);
3911 ++ if (retval)
3912 ++ goto err_iounmap_all;
3913 ++
3914 + return 0;
3915 +
3916 + err_iounmap_all:
3917 +diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
3918 +index b415ba42ca73..599447032e50 100644
3919 +--- a/drivers/s390/scsi/zfcp_dbf.c
3920 ++++ b/drivers/s390/scsi/zfcp_dbf.c
3921 +@@ -285,6 +285,8 @@ void zfcp_dbf_rec_trig(char *tag, struct zfcp_adapter *adapter,
3922 + struct list_head *entry;
3923 + unsigned long flags;
3924 +
3925 ++ lockdep_assert_held(&adapter->erp_lock);
3926 ++
3927 + if (unlikely(!debug_level_enabled(dbf->rec, level)))
3928 + return;
3929 +
3930 +diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
3931 +index 00e7968a1d70..a1388842e17e 100644
3932 +--- a/drivers/scsi/3w-9xxx.c
3933 ++++ b/drivers/scsi/3w-9xxx.c
3934 +@@ -886,6 +886,11 @@ static int twa_chrdev_open(struct inode *inode, struct file *file)
3935 + unsigned int minor_number;
3936 + int retval = TW_IOCTL_ERROR_OS_ENODEV;
3937 +
3938 ++ if (!capable(CAP_SYS_ADMIN)) {
3939 ++ retval = -EACCES;
3940 ++ goto out;
3941 ++ }
3942 ++
3943 + minor_number = iminor(inode);
3944 + if (minor_number >= twa_device_extension_count)
3945 + goto out;
3946 +diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
3947 +index 33261b690774..f6179e3d6953 100644
3948 +--- a/drivers/scsi/3w-xxxx.c
3949 ++++ b/drivers/scsi/3w-xxxx.c
3950 +@@ -1033,6 +1033,9 @@ static int tw_chrdev_open(struct inode *inode, struct file *file)
3951 +
3952 + dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n");
3953 +
3954 ++ if (!capable(CAP_SYS_ADMIN))
3955 ++ return -EACCES;
3956 ++
3957 + minor_number = iminor(inode);
3958 + if (minor_number >= tw_device_extension_count)
3959 + return -ENODEV;
3960 +diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
3961 +index 0b6467206f8e..737314cac8d8 100644
3962 +--- a/drivers/scsi/cxlflash/main.c
3963 ++++ b/drivers/scsi/cxlflash/main.c
3964 +@@ -946,9 +946,9 @@ static void cxlflash_remove(struct pci_dev *pdev)
3965 + return;
3966 + }
3967 +
3968 +- /* If a Task Management Function is active, wait for it to complete
3969 +- * before continuing with remove.
3970 +- */
3971 ++ /* Yield to running recovery threads before continuing with remove */
3972 ++ wait_event(cfg->reset_waitq, cfg->state != STATE_RESET &&
3973 ++ cfg->state != STATE_PROBING);
3974 + spin_lock_irqsave(&cfg->tmf_slock, lock_flags);
3975 + if (cfg->tmf_active)
3976 + wait_event_interruptible_lock_irq(cfg->tmf_waitq,
3977 +@@ -1303,7 +1303,10 @@ static void afu_err_intr_init(struct afu *afu)
3978 + for (i = 0; i < afu->num_hwqs; i++) {
3979 + hwq = get_hwq(afu, i);
3980 +
3981 +- writeq_be(SISL_MSI_SYNC_ERROR, &hwq->host_map->ctx_ctrl);
3982 ++ reg = readq_be(&hwq->host_map->ctx_ctrl);
3983 ++ WARN_ON((reg & SISL_CTX_CTRL_LISN_MASK) != 0);
3984 ++ reg |= SISL_MSI_SYNC_ERROR;
3985 ++ writeq_be(reg, &hwq->host_map->ctx_ctrl);
3986 + writeq_be(SISL_ISTATUS_MASK, &hwq->host_map->intr_mask);
3987 + }
3988 + }
3989 +diff --git a/drivers/scsi/cxlflash/sislite.h b/drivers/scsi/cxlflash/sislite.h
3990 +index 09daa86670fc..0892fb1f0a1e 100644
3991 +--- a/drivers/scsi/cxlflash/sislite.h
3992 ++++ b/drivers/scsi/cxlflash/sislite.h
3993 +@@ -284,6 +284,7 @@ struct sisl_host_map {
3994 + __be64 cmd_room;
3995 + __be64 ctx_ctrl; /* least significant byte or b56:63 is LISN# */
3996 + #define SISL_CTX_CTRL_UNMAP_SECTOR 0x8000000000000000ULL /* b0 */
3997 ++#define SISL_CTX_CTRL_LISN_MASK (0xFFULL)
3998 + __be64 mbox_w; /* restricted use */
3999 + __be64 sq_start; /* Submission Queue (R/W): write sequence and */
4000 + __be64 sq_end; /* inclusion semantics are the same as RRQ */
4001 +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
4002 +index 2e5fa9717be8..871962b2e2f6 100644
4003 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
4004 ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
4005 +@@ -328,10 +328,11 @@ enum {
4006 + #define DIR_TO_DEVICE 2
4007 + #define DIR_RESERVED 3
4008 +
4009 +-#define CMD_IS_UNCONSTRAINT(cmd) \
4010 +- ((cmd == ATA_CMD_READ_LOG_EXT) || \
4011 +- (cmd == ATA_CMD_READ_LOG_DMA_EXT) || \
4012 +- (cmd == ATA_CMD_DEV_RESET))
4013 ++#define FIS_CMD_IS_UNCONSTRAINED(fis) \
4014 ++ ((fis.command == ATA_CMD_READ_LOG_EXT) || \
4015 ++ (fis.command == ATA_CMD_READ_LOG_DMA_EXT) || \
4016 ++ ((fis.command == ATA_CMD_DEV_RESET) && \
4017 ++ ((fis.control & ATA_SRST) != 0)))
4018 +
4019 + static u32 hisi_sas_read32(struct hisi_hba *hisi_hba, u32 off)
4020 + {
4021 +@@ -1044,7 +1045,7 @@ static int prep_ata_v3_hw(struct hisi_hba *hisi_hba,
4022 + << CMD_HDR_FRAME_TYPE_OFF;
4023 + dw1 |= sas_dev->device_id << CMD_HDR_DEV_ID_OFF;
4024 +
4025 +- if (CMD_IS_UNCONSTRAINT(task->ata_task.fis.command))
4026 ++ if (FIS_CMD_IS_UNCONSTRAINED(task->ata_task.fis))
4027 + dw1 |= 1 << CMD_HDR_UNCON_CMD_OFF;
4028 +
4029 + hdr->dw1 = cpu_to_le32(dw1);
4030 +diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
4031 +index 7195cff51d4c..9b6f5d024dba 100644
4032 +--- a/drivers/scsi/megaraid.c
4033 ++++ b/drivers/scsi/megaraid.c
4034 +@@ -4199,6 +4199,9 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
4035 + int irq, i, j;
4036 + int error = -ENODEV;
4037 +
4038 ++ if (hba_count >= MAX_CONTROLLERS)
4039 ++ goto out;
4040 ++
4041 + if (pci_enable_device(pdev))
4042 + goto out;
4043 + pci_set_master(pdev);
4044 +diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
4045 +index d8f626567f59..06a2e3d9fc5b 100644
4046 +--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
4047 ++++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
4048 +@@ -2677,6 +2677,9 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
4049 + pRAID_Context->timeout_value = cpu_to_le16(os_timeout_value);
4050 + pRAID_Context->virtual_disk_tgt_id = cpu_to_le16(device_id);
4051 + } else {
4052 ++ if (os_timeout_value)
4053 ++ os_timeout_value++;
4054 ++
4055 + /* system pd Fast Path */
4056 + io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
4057 + timeout_limit = (scmd->device->type == TYPE_DISK) ?
4058 +diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
4059 +index 7c0064500cc5..382edb79a0de 100644
4060 +--- a/drivers/scsi/qedf/qedf_main.c
4061 ++++ b/drivers/scsi/qedf/qedf_main.c
4062 +@@ -1649,6 +1649,15 @@ static int qedf_vport_destroy(struct fc_vport *vport)
4063 + struct Scsi_Host *shost = vport_to_shost(vport);
4064 + struct fc_lport *n_port = shost_priv(shost);
4065 + struct fc_lport *vn_port = vport->dd_data;
4066 ++ struct qedf_ctx *qedf = lport_priv(vn_port);
4067 ++
4068 ++ if (!qedf) {
4069 ++ QEDF_ERR(NULL, "qedf is NULL.\n");
4070 ++ goto out;
4071 ++ }
4072 ++
4073 ++ /* Set unloading bit on vport qedf_ctx to prevent more I/O */
4074 ++ set_bit(QEDF_UNLOADING, &qedf->flags);
4075 +
4076 + mutex_lock(&n_port->lp_mutex);
4077 + list_del(&vn_port->list);
4078 +@@ -1675,6 +1684,7 @@ static int qedf_vport_destroy(struct fc_vport *vport)
4079 + if (vn_port->host)
4080 + scsi_host_put(vn_port->host);
4081 +
4082 ++out:
4083 + return 0;
4084 + }
4085 +
4086 +diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
4087 +index a5e30e9449ef..375cede0c534 100644
4088 +--- a/drivers/scsi/scsi_dh.c
4089 ++++ b/drivers/scsi/scsi_dh.c
4090 +@@ -58,7 +58,10 @@ static const struct scsi_dh_blist scsi_dh_blist[] = {
4091 + {"IBM", "3526", "rdac", },
4092 + {"IBM", "3542", "rdac", },
4093 + {"IBM", "3552", "rdac", },
4094 +- {"SGI", "TP9", "rdac", },
4095 ++ {"SGI", "TP9300", "rdac", },
4096 ++ {"SGI", "TP9400", "rdac", },
4097 ++ {"SGI", "TP9500", "rdac", },
4098 ++ {"SGI", "TP9700", "rdac", },
4099 + {"SGI", "IS", "rdac", },
4100 + {"STK", "OPENstorage", "rdac", },
4101 + {"STK", "FLEXLINE 380", "rdac", },
4102 +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
4103 +index 3bb1f6cc297a..21c81c1feac5 100644
4104 +--- a/drivers/scsi/ufs/ufshcd.c
4105 ++++ b/drivers/scsi/ufs/ufshcd.c
4106 +@@ -4947,6 +4947,7 @@ static void ufshcd_exception_event_handler(struct work_struct *work)
4107 + hba = container_of(work, struct ufs_hba, eeh_work);
4108 +
4109 + pm_runtime_get_sync(hba->dev);
4110 ++ scsi_block_requests(hba->host);
4111 + err = ufshcd_get_ee_status(hba, &status);
4112 + if (err) {
4113 + dev_err(hba->dev, "%s: failed to get exception status %d\n",
4114 +@@ -4960,6 +4961,7 @@ static void ufshcd_exception_event_handler(struct work_struct *work)
4115 + ufshcd_bkops_exception_event_handler(hba);
4116 +
4117 + out:
4118 ++ scsi_unblock_requests(hba->host);
4119 + pm_runtime_put_sync(hba->dev);
4120 + return;
4121 + }
4122 +@@ -6761,9 +6763,16 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
4123 + if (list_empty(head))
4124 + goto out;
4125 +
4126 +- ret = ufshcd_vops_setup_clocks(hba, on, PRE_CHANGE);
4127 +- if (ret)
4128 +- return ret;
4129 ++ /*
4130 ++ * vendor specific setup_clocks ops may depend on clocks managed by
4131 ++ * this standard driver hence call the vendor specific setup_clocks
4132 ++ * before disabling the clocks managed here.
4133 ++ */
4134 ++ if (!on) {
4135 ++ ret = ufshcd_vops_setup_clocks(hba, on, PRE_CHANGE);
4136 ++ if (ret)
4137 ++ return ret;
4138 ++ }
4139 +
4140 + list_for_each_entry(clki, head, list) {
4141 + if (!IS_ERR_OR_NULL(clki->clk)) {
4142 +@@ -6787,9 +6796,16 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
4143 + }
4144 + }
4145 +
4146 +- ret = ufshcd_vops_setup_clocks(hba, on, POST_CHANGE);
4147 +- if (ret)
4148 +- return ret;
4149 ++ /*
4150 ++ * vendor specific setup_clocks ops may depend on clocks managed by
4151 ++ * this standard driver hence call the vendor specific setup_clocks
4152 ++ * after enabling the clocks managed here.
4153 ++ */
4154 ++ if (on) {
4155 ++ ret = ufshcd_vops_setup_clocks(hba, on, POST_CHANGE);
4156 ++ if (ret)
4157 ++ return ret;
4158 ++ }
4159 +
4160 + out:
4161 + if (ret) {
4162 +diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
4163 +index afc7ecc3c187..f4e3bd40c72e 100644
4164 +--- a/drivers/soc/imx/gpcv2.c
4165 ++++ b/drivers/soc/imx/gpcv2.c
4166 +@@ -155,7 +155,7 @@ static int imx7_gpc_pu_pgc_sw_pdn_req(struct generic_pm_domain *genpd)
4167 + return imx7_gpc_pu_pgc_sw_pxx_req(genpd, false);
4168 + }
4169 +
4170 +-static struct imx7_pgc_domain imx7_pgc_domains[] = {
4171 ++static const struct imx7_pgc_domain imx7_pgc_domains[] = {
4172 + [IMX7_POWER_DOMAIN_MIPI_PHY] = {
4173 + .genpd = {
4174 + .name = "mipi-phy",
4175 +@@ -321,11 +321,6 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
4176 + continue;
4177 + }
4178 +
4179 +- domain = &imx7_pgc_domains[domain_index];
4180 +- domain->regmap = regmap;
4181 +- domain->genpd.power_on = imx7_gpc_pu_pgc_sw_pup_req;
4182 +- domain->genpd.power_off = imx7_gpc_pu_pgc_sw_pdn_req;
4183 +-
4184 + pd_pdev = platform_device_alloc("imx7-pgc-domain",
4185 + domain_index);
4186 + if (!pd_pdev) {
4187 +@@ -334,7 +329,20 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
4188 + return -ENOMEM;
4189 + }
4190 +
4191 +- pd_pdev->dev.platform_data = domain;
4192 ++ ret = platform_device_add_data(pd_pdev,
4193 ++ &imx7_pgc_domains[domain_index],
4194 ++ sizeof(imx7_pgc_domains[domain_index]));
4195 ++ if (ret) {
4196 ++ platform_device_put(pd_pdev);
4197 ++ of_node_put(np);
4198 ++ return ret;
4199 ++ }
4200 ++
4201 ++ domain = pd_pdev->dev.platform_data;
4202 ++ domain->regmap = regmap;
4203 ++ domain->genpd.power_on = imx7_gpc_pu_pgc_sw_pup_req;
4204 ++ domain->genpd.power_off = imx7_gpc_pu_pgc_sw_pdn_req;
4205 ++
4206 + pd_pdev->dev.parent = dev;
4207 + pd_pdev->dev.of_node = np;
4208 +
4209 +diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c
4210 +index 7f8429635502..a5b0df7e6131 100644
4211 +--- a/drivers/spi/spi-meson-spicc.c
4212 ++++ b/drivers/spi/spi-meson-spicc.c
4213 +@@ -574,10 +574,15 @@ static int meson_spicc_probe(struct platform_device *pdev)
4214 + master->max_speed_hz = rate >> 2;
4215 +
4216 + ret = devm_spi_register_master(&pdev->dev, master);
4217 +- if (!ret)
4218 +- return 0;
4219 ++ if (ret) {
4220 ++ dev_err(&pdev->dev, "spi master registration failed\n");
4221 ++ goto out_clk;
4222 ++ }
4223 +
4224 +- dev_err(&pdev->dev, "spi master registration failed\n");
4225 ++ return 0;
4226 ++
4227 ++out_clk:
4228 ++ clk_disable_unprepare(spicc->core);
4229 +
4230 + out_master:
4231 + spi_master_put(master);
4232 +diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
4233 +index b392cca8fa4f..1a6ec226d6e4 100644
4234 +--- a/drivers/spi/spi-s3c64xx.c
4235 ++++ b/drivers/spi/spi-s3c64xx.c
4236 +@@ -1273,8 +1273,6 @@ static int s3c64xx_spi_resume(struct device *dev)
4237 + if (ret < 0)
4238 + return ret;
4239 +
4240 +- s3c64xx_spi_hwinit(sdd, sdd->port_id);
4241 +-
4242 + return spi_master_resume(master);
4243 + }
4244 + #endif /* CONFIG_PM_SLEEP */
4245 +@@ -1312,6 +1310,8 @@ static int s3c64xx_spi_runtime_resume(struct device *dev)
4246 + if (ret != 0)
4247 + goto err_disable_src_clk;
4248 +
4249 ++ s3c64xx_spi_hwinit(sdd, sdd->port_id);
4250 ++
4251 + return 0;
4252 +
4253 + err_disable_src_clk:
4254 +diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
4255 +index 52056535f54e..0fea18ab970e 100644
4256 +--- a/drivers/spi/spi-sh-msiof.c
4257 ++++ b/drivers/spi/spi-sh-msiof.c
4258 +@@ -555,14 +555,16 @@ static int sh_msiof_spi_setup(struct spi_device *spi)
4259 +
4260 + /* Configure native chip select mode/polarity early */
4261 + clr = MDR1_SYNCMD_MASK;
4262 +- set = MDR1_TRMD | TMDR1_PCON | MDR1_SYNCMD_SPI;
4263 ++ set = MDR1_SYNCMD_SPI;
4264 + if (spi->mode & SPI_CS_HIGH)
4265 + clr |= BIT(MDR1_SYNCAC_SHIFT);
4266 + else
4267 + set |= BIT(MDR1_SYNCAC_SHIFT);
4268 + pm_runtime_get_sync(&p->pdev->dev);
4269 + tmp = sh_msiof_read(p, TMDR1) & ~clr;
4270 +- sh_msiof_write(p, TMDR1, tmp | set);
4271 ++ sh_msiof_write(p, TMDR1, tmp | set | MDR1_TRMD | TMDR1_PCON);
4272 ++ tmp = sh_msiof_read(p, RMDR1) & ~clr;
4273 ++ sh_msiof_write(p, RMDR1, tmp | set);
4274 + pm_runtime_put(&p->pdev->dev);
4275 + p->native_cs_high = spi->mode & SPI_CS_HIGH;
4276 + p->native_cs_inited = true;
4277 +diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
4278 +index 84dfef4bd6ae..f85d30dc9187 100644
4279 +--- a/drivers/spi/spi.c
4280 ++++ b/drivers/spi/spi.c
4281 +@@ -1222,6 +1222,7 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
4282 + if (!was_busy && ctlr->auto_runtime_pm) {
4283 + ret = pm_runtime_get_sync(ctlr->dev.parent);
4284 + if (ret < 0) {
4285 ++ pm_runtime_put_noidle(ctlr->dev.parent);
4286 + dev_err(&ctlr->dev, "Failed to power device: %d\n",
4287 + ret);
4288 + mutex_unlock(&ctlr->io_mutex);
4289 +diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
4290 +index 284cdd44a2ee..8b92cf06d063 100644
4291 +--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
4292 ++++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
4293 +@@ -1710,7 +1710,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
4294 + return 0;
4295 + }
4296 + spin_unlock(&fps->fps_lock);
4297 +- rc = -EBUSY;
4298 ++ rc = -EAGAIN;
4299 + }
4300 +
4301 + spin_lock(&fps->fps_lock);
4302 +diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
4303 +index 29e10021b906..4b4a20149894 100644
4304 +--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
4305 ++++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
4306 +@@ -47,7 +47,7 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type,
4307 + __u64 dstcookie);
4308 + static void kiblnd_queue_tx_locked(struct kib_tx *tx, struct kib_conn *conn);
4309 + static void kiblnd_queue_tx(struct kib_tx *tx, struct kib_conn *conn);
4310 +-static void kiblnd_unmap_tx(struct lnet_ni *ni, struct kib_tx *tx);
4311 ++static void kiblnd_unmap_tx(struct kib_tx *tx);
4312 + static void kiblnd_check_sends_locked(struct kib_conn *conn);
4313 +
4314 + static void
4315 +@@ -65,7 +65,7 @@ kiblnd_tx_done(struct lnet_ni *ni, struct kib_tx *tx)
4316 + LASSERT(!tx->tx_waiting); /* mustn't be awaiting peer response */
4317 + LASSERT(tx->tx_pool);
4318 +
4319 +- kiblnd_unmap_tx(ni, tx);
4320 ++ kiblnd_unmap_tx(tx);
4321 +
4322 + /* tx may have up to 2 lnet msgs to finalise */
4323 + lntmsg[0] = tx->tx_lntmsg[0]; tx->tx_lntmsg[0] = NULL;
4324 +@@ -590,13 +590,9 @@ kiblnd_fmr_map_tx(struct kib_net *net, struct kib_tx *tx, struct kib_rdma_desc *
4325 + return 0;
4326 + }
4327 +
4328 +-static void kiblnd_unmap_tx(struct lnet_ni *ni, struct kib_tx *tx)
4329 ++static void kiblnd_unmap_tx(struct kib_tx *tx)
4330 + {
4331 +- struct kib_net *net = ni->ni_data;
4332 +-
4333 +- LASSERT(net);
4334 +-
4335 +- if (net->ibn_fmr_ps)
4336 ++ if (tx->fmr.fmr_pfmr || tx->fmr.fmr_frd)
4337 + kiblnd_fmr_pool_unmap(&tx->fmr, tx->tx_status);
4338 +
4339 + if (tx->tx_nfrags) {
4340 +@@ -1289,11 +1285,6 @@ kiblnd_connect_peer(struct kib_peer *peer)
4341 + goto failed2;
4342 + }
4343 +
4344 +- LASSERT(cmid->device);
4345 +- CDEBUG(D_NET, "%s: connection bound to %s:%pI4h:%s\n",
4346 +- libcfs_nid2str(peer->ibp_nid), dev->ibd_ifname,
4347 +- &dev->ibd_ifip, cmid->device->name);
4348 +-
4349 + return;
4350 +
4351 + failed2:
4352 +@@ -2995,8 +2986,19 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
4353 + } else {
4354 + rc = rdma_resolve_route(
4355 + cmid, *kiblnd_tunables.kib_timeout * 1000);
4356 +- if (!rc)
4357 ++ if (!rc) {
4358 ++ struct kib_net *net = peer->ibp_ni->ni_data;
4359 ++ struct kib_dev *dev = net->ibn_dev;
4360 ++
4361 ++ CDEBUG(D_NET, "%s: connection bound to "\
4362 ++ "%s:%pI4h:%s\n",
4363 ++ libcfs_nid2str(peer->ibp_nid),
4364 ++ dev->ibd_ifname,
4365 ++ &dev->ibd_ifip, cmid->device->name);
4366 ++
4367 + return 0;
4368 ++ }
4369 ++
4370 + /* Can't initiate route resolution */
4371 + CERROR("Can't resolve route for %s: %d\n",
4372 + libcfs_nid2str(peer->ibp_nid), rc);
4373 +diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
4374 +index b5d84f3f6071..11e01c48f51a 100644
4375 +--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
4376 ++++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
4377 +@@ -1571,8 +1571,10 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
4378 + return ERR_CAST(res);
4379 +
4380 + lock = ldlm_lock_new(res);
4381 +- if (!lock)
4382 ++ if (!lock) {
4383 ++ ldlm_resource_putref(res);
4384 + return ERR_PTR(-ENOMEM);
4385 ++ }
4386 +
4387 + lock->l_req_mode = mode;
4388 + lock->l_ast_data = data;
4389 +@@ -1615,6 +1617,8 @@ out:
4390 + return ERR_PTR(rc);
4391 + }
4392 +
4393 ++
4394 ++
4395 + /**
4396 + * Enqueue (request) a lock.
4397 + * On the client this is called from ldlm_cli_enqueue_fini
4398 +diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
4399 +index 0be55623bac4..364d697b2690 100644
4400 +--- a/drivers/staging/lustre/lustre/llite/xattr.c
4401 ++++ b/drivers/staging/lustre/lustre/llite/xattr.c
4402 +@@ -93,7 +93,11 @@ ll_xattr_set_common(const struct xattr_handler *handler,
4403 + __u64 valid;
4404 + int rc;
4405 +
4406 +- if (flags == XATTR_REPLACE) {
4407 ++ /* When setxattr() is called with a size of 0 the value is
4408 ++ * unconditionally replaced by "". When removexattr() is
4409 ++ * called we get a NULL value and XATTR_REPLACE for flags.
4410 ++ */
4411 ++ if (!value && flags == XATTR_REPLACE) {
4412 + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_REMOVEXATTR, 1);
4413 + valid = OBD_MD_FLXATTRRM;
4414 + } else {
4415 +diff --git a/drivers/staging/media/atomisp/i2c/ov2680.c b/drivers/staging/media/atomisp/i2c/ov2680.c
4416 +index 51b7d61df0f5..179576224319 100644
4417 +--- a/drivers/staging/media/atomisp/i2c/ov2680.c
4418 ++++ b/drivers/staging/media/atomisp/i2c/ov2680.c
4419 +@@ -396,12 +396,11 @@ static long __ov2680_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
4420 + {
4421 + struct i2c_client *client = v4l2_get_subdevdata(sd);
4422 + struct ov2680_device *dev = to_ov2680_sensor(sd);
4423 +- u16 vts,hts;
4424 ++ u16 vts;
4425 + int ret,exp_val;
4426 +
4427 + dev_dbg(&client->dev, "+++++++__ov2680_set_exposure coarse_itg %d, gain %d, digitgain %d++\n",coarse_itg, gain, digitgain);
4428 +
4429 +- hts = ov2680_res[dev->fmt_idx].pixels_per_line;
4430 + vts = ov2680_res[dev->fmt_idx].lines_per_frame;
4431 +
4432 + /* group hold */
4433 +@@ -1190,7 +1189,8 @@ static int ov2680_detect(struct i2c_client *client)
4434 + OV2680_SC_CMMN_SUB_ID, &high);
4435 + revision = (u8) high & 0x0f;
4436 +
4437 +- dev_info(&client->dev, "sensor_revision id = 0x%x\n", id);
4438 ++ dev_info(&client->dev, "sensor_revision id = 0x%x, rev= %d\n",
4439 ++ id, revision);
4440 +
4441 + return 0;
4442 + }
4443 +diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_ioctl32.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_ioctl32.c
4444 +index 0592ac1f2832..cfe6bb610014 100644
4445 +--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_ioctl32.c
4446 ++++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_ioctl32.c
4447 +@@ -81,7 +81,7 @@ static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp,
4448 + get_user(kp->flags, &up->flags))
4449 + return -EFAULT;
4450 +
4451 +- kp->base = compat_ptr(tmp);
4452 ++ kp->base = (void __force *)compat_ptr(tmp);
4453 + get_v4l2_pix_format((struct v4l2_pix_format *)&kp->fmt, &up->fmt);
4454 + return 0;
4455 + }
4456 +@@ -232,10 +232,10 @@ static int get_atomisp_dvs_6axis_config32(struct atomisp_dvs_6axis_config *kp,
4457 + get_user(ycoords_uv, &up->ycoords_uv))
4458 + return -EFAULT;
4459 +
4460 +- kp->xcoords_y = compat_ptr(xcoords_y);
4461 +- kp->ycoords_y = compat_ptr(ycoords_y);
4462 +- kp->xcoords_uv = compat_ptr(xcoords_uv);
4463 +- kp->ycoords_uv = compat_ptr(ycoords_uv);
4464 ++ kp->xcoords_y = (void __force *)compat_ptr(xcoords_y);
4465 ++ kp->ycoords_y = (void __force *)compat_ptr(ycoords_y);
4466 ++ kp->xcoords_uv = (void __force *)compat_ptr(xcoords_uv);
4467 ++ kp->ycoords_uv = (void __force *)compat_ptr(ycoords_uv);
4468 + return 0;
4469 + }
4470 +
4471 +@@ -296,7 +296,7 @@ static int get_atomisp_metadata_stat32(struct atomisp_metadata *kp,
4472 + return -EFAULT;
4473 +
4474 + kp->data = compat_ptr(data);
4475 +- kp->effective_width = compat_ptr(effective_width);
4476 ++ kp->effective_width = (void __force *)compat_ptr(effective_width);
4477 + return 0;
4478 + }
4479 +
4480 +@@ -360,7 +360,7 @@ static int get_atomisp_metadata_by_type_stat32(
4481 + return -EFAULT;
4482 +
4483 + kp->data = compat_ptr(data);
4484 +- kp->effective_width = compat_ptr(effective_width);
4485 ++ kp->effective_width = (void __force *)compat_ptr(effective_width);
4486 + return 0;
4487 + }
4488 +
4489 +@@ -437,7 +437,7 @@ static int get_atomisp_overlay32(struct atomisp_overlay *kp,
4490 + get_user(kp->overlay_start_x, &up->overlay_start_y))
4491 + return -EFAULT;
4492 +
4493 +- kp->frame = compat_ptr(frame);
4494 ++ kp->frame = (void __force *)compat_ptr(frame);
4495 + return 0;
4496 + }
4497 +
4498 +@@ -481,7 +481,7 @@ static int get_atomisp_calibration_group32(
4499 + get_user(calb_grp_values, &up->calb_grp_values))
4500 + return -EFAULT;
4501 +
4502 +- kp->calb_grp_values = compat_ptr(calb_grp_values);
4503 ++ kp->calb_grp_values = (void __force *)compat_ptr(calb_grp_values);
4504 + return 0;
4505 + }
4506 +
4507 +@@ -703,8 +703,8 @@ static int get_atomisp_parameters32(struct atomisp_parameters *kp,
4508 + return -EFAULT;
4509 +
4510 + while (n >= 0) {
4511 +- compat_uptr_t *src = (compat_uptr_t *)up + n;
4512 +- uintptr_t *dst = (uintptr_t *)kp + n;
4513 ++ compat_uptr_t __user *src = ((compat_uptr_t __user *)up) + n;
4514 ++ uintptr_t *dst = ((uintptr_t *)kp) + n;
4515 +
4516 + if (get_user((*dst), src))
4517 + return -EFAULT;
4518 +@@ -751,12 +751,12 @@ static int get_atomisp_parameters32(struct atomisp_parameters *kp,
4519 + #endif
4520 + return -EFAULT;
4521 +
4522 +- kp->shading_table = user_ptr + offset;
4523 ++ kp->shading_table = (void __force *)user_ptr + offset;
4524 + offset = sizeof(struct atomisp_shading_table);
4525 + if (!kp->shading_table)
4526 + return -EFAULT;
4527 +
4528 +- if (copy_to_user(kp->shading_table,
4529 ++ if (copy_to_user((void __user *)kp->shading_table,
4530 + &karg.shading_table,
4531 + sizeof(struct atomisp_shading_table)))
4532 + return -EFAULT;
4533 +@@ -777,13 +777,14 @@ static int get_atomisp_parameters32(struct atomisp_parameters *kp,
4534 + #endif
4535 + return -EFAULT;
4536 +
4537 +- kp->morph_table = user_ptr + offset;
4538 ++ kp->morph_table = (void __force *)user_ptr + offset;
4539 + offset += sizeof(struct atomisp_morph_table);
4540 + if (!kp->morph_table)
4541 + return -EFAULT;
4542 +
4543 +- if (copy_to_user(kp->morph_table, &karg.morph_table,
4544 +- sizeof(struct atomisp_morph_table)))
4545 ++ if (copy_to_user((void __user *)kp->morph_table,
4546 ++ &karg.morph_table,
4547 ++ sizeof(struct atomisp_morph_table)))
4548 + return -EFAULT;
4549 + }
4550 +
4551 +@@ -802,13 +803,14 @@ static int get_atomisp_parameters32(struct atomisp_parameters *kp,
4552 + #endif
4553 + return -EFAULT;
4554 +
4555 +- kp->dvs2_coefs = user_ptr + offset;
4556 ++ kp->dvs2_coefs = (void __force *)user_ptr + offset;
4557 + offset += sizeof(struct atomisp_dis_coefficients);
4558 + if (!kp->dvs2_coefs)
4559 + return -EFAULT;
4560 +
4561 +- if (copy_to_user(kp->dvs2_coefs, &karg.dvs2_coefs,
4562 +- sizeof(struct atomisp_dis_coefficients)))
4563 ++ if (copy_to_user((void __user *)kp->dvs2_coefs,
4564 ++ &karg.dvs2_coefs,
4565 ++ sizeof(struct atomisp_dis_coefficients)))
4566 + return -EFAULT;
4567 + }
4568 + /* handle dvs 6axis configuration */
4569 +@@ -826,13 +828,14 @@ static int get_atomisp_parameters32(struct atomisp_parameters *kp,
4570 + #endif
4571 + return -EFAULT;
4572 +
4573 +- kp->dvs_6axis_config = user_ptr + offset;
4574 ++ kp->dvs_6axis_config = (void __force *)user_ptr + offset;
4575 + offset += sizeof(struct atomisp_dvs_6axis_config);
4576 + if (!kp->dvs_6axis_config)
4577 + return -EFAULT;
4578 +
4579 +- if (copy_to_user(kp->dvs_6axis_config, &karg.dvs_6axis_config,
4580 +- sizeof(struct atomisp_dvs_6axis_config)))
4581 ++ if (copy_to_user((void __user *)kp->dvs_6axis_config,
4582 ++ &karg.dvs_6axis_config,
4583 ++ sizeof(struct atomisp_dvs_6axis_config)))
4584 + return -EFAULT;
4585 + }
4586 + }
4587 +@@ -891,7 +894,7 @@ static int get_atomisp_sensor_ae_bracketing_lut(
4588 + get_user(lut, &up->lut))
4589 + return -EFAULT;
4590 +
4591 +- kp->lut = compat_ptr(lut);
4592 ++ kp->lut = (void __force *)compat_ptr(lut);
4593 + return 0;
4594 + }
4595 +
4596 +diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
4597 +index 486be990d7fc..a457034818c3 100644
4598 +--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
4599 ++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
4600 +@@ -601,6 +601,7 @@ reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking)
4601 + }
4602 +
4603 + if (tx_pos == (state->slot_queue_available * VCHIQ_SLOT_SIZE)) {
4604 ++ up(&state->slot_available_event);
4605 + pr_warn("%s: invalid tx_pos: %d\n", __func__, tx_pos);
4606 + return NULL;
4607 + }
4608 +diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
4609 +index ac83f721db24..d60069b5dc98 100644
4610 +--- a/drivers/thermal/samsung/exynos_tmu.c
4611 ++++ b/drivers/thermal/samsung/exynos_tmu.c
4612 +@@ -598,6 +598,7 @@ static int exynos5433_tmu_initialize(struct platform_device *pdev)
4613 + threshold_code = temp_to_code(data, temp);
4614 +
4615 + rising_threshold = readl(data->base + rising_reg_offset);
4616 ++ rising_threshold &= ~(0xff << j * 8);
4617 + rising_threshold |= (threshold_code << j * 8);
4618 + writel(rising_threshold, data->base + rising_reg_offset);
4619 +
4620 +diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
4621 +index 16331a90c1e8..9da8474fe50a 100644
4622 +--- a/drivers/tty/hvc/hvc_opal.c
4623 ++++ b/drivers/tty/hvc/hvc_opal.c
4624 +@@ -332,7 +332,6 @@ static void udbg_init_opal_common(void)
4625 + udbg_putc = udbg_opal_putc;
4626 + udbg_getc = udbg_opal_getc;
4627 + udbg_getc_poll = udbg_opal_getc_poll;
4628 +- tb_ticks_per_usec = 0x200; /* Make udelay not suck */
4629 + }
4630 +
4631 + void __init hvc_opal_init_early(void)
4632 +diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
4633 +index 64338442050e..899e8fe5e00f 100644
4634 +--- a/drivers/tty/pty.c
4635 ++++ b/drivers/tty/pty.c
4636 +@@ -110,16 +110,19 @@ static void pty_unthrottle(struct tty_struct *tty)
4637 + static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
4638 + {
4639 + struct tty_struct *to = tty->link;
4640 ++ unsigned long flags;
4641 +
4642 + if (tty->stopped)
4643 + return 0;
4644 +
4645 + if (c > 0) {
4646 ++ spin_lock_irqsave(&to->port->lock, flags);
4647 + /* Stuff the data into the input queue of the other end */
4648 + c = tty_insert_flip_string(to->port, buf, c);
4649 + /* And shovel */
4650 + if (c)
4651 + tty_flip_buffer_push(to->port);
4652 ++ spin_unlock_irqrestore(&to->port->lock, flags);
4653 + }
4654 + return c;
4655 + }
4656 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
4657 +index a8bc48b26c23..a9db0887edca 100644
4658 +--- a/drivers/usb/core/hub.c
4659 ++++ b/drivers/usb/core/hub.c
4660 +@@ -3361,6 +3361,10 @@ static int wait_for_connected(struct usb_device *udev,
4661 + while (delay_ms < 2000) {
4662 + if (status || *portstatus & USB_PORT_STAT_CONNECTION)
4663 + break;
4664 ++ if (!port_is_power_on(hub, *portstatus)) {
4665 ++ status = -ENODEV;
4666 ++ break;
4667 ++ }
4668 + msleep(20);
4669 + delay_ms += 20;
4670 + status = hub_port_status(hub, *port1, portstatus, portchange);
4671 +diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
4672 +index 4cfa72cb0a91..c12a1a6554ba 100644
4673 +--- a/drivers/usb/gadget/udc/renesas_usb3.c
4674 ++++ b/drivers/usb/gadget/udc/renesas_usb3.c
4675 +@@ -334,6 +334,7 @@ struct renesas_usb3 {
4676 + struct usb_gadget_driver *driver;
4677 + struct extcon_dev *extcon;
4678 + struct work_struct extcon_work;
4679 ++ struct dentry *dentry;
4680 +
4681 + struct renesas_usb3_ep *usb3_ep;
4682 + int num_usb3_eps;
4683 +@@ -2397,8 +2398,12 @@ static void renesas_usb3_debugfs_init(struct renesas_usb3 *usb3,
4684 +
4685 + file = debugfs_create_file("b_device", 0644, root, usb3,
4686 + &renesas_usb3_b_device_fops);
4687 +- if (!file)
4688 ++ if (!file) {
4689 + dev_info(dev, "%s: Can't create debugfs mode\n", __func__);
4690 ++ debugfs_remove_recursive(root);
4691 ++ } else {
4692 ++ usb3->dentry = root;
4693 ++ }
4694 + }
4695 +
4696 + /*------- platform_driver ------------------------------------------------*/
4697 +@@ -2406,6 +2411,7 @@ static int renesas_usb3_remove(struct platform_device *pdev)
4698 + {
4699 + struct renesas_usb3 *usb3 = platform_get_drvdata(pdev);
4700 +
4701 ++ debugfs_remove_recursive(usb3->dentry);
4702 + device_remove_file(&pdev->dev, &dev_attr_role);
4703 +
4704 + usb_del_gadget_udc(&usb3->gadget);
4705 +diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
4706 +index 126991046eb7..0212f0ee8aea 100644
4707 +--- a/drivers/vfio/mdev/mdev_core.c
4708 ++++ b/drivers/vfio/mdev/mdev_core.c
4709 +@@ -66,34 +66,6 @@ uuid_le mdev_uuid(struct mdev_device *mdev)
4710 + }
4711 + EXPORT_SYMBOL(mdev_uuid);
4712 +
4713 +-static int _find_mdev_device(struct device *dev, void *data)
4714 +-{
4715 +- struct mdev_device *mdev;
4716 +-
4717 +- if (!dev_is_mdev(dev))
4718 +- return 0;
4719 +-
4720 +- mdev = to_mdev_device(dev);
4721 +-
4722 +- if (uuid_le_cmp(mdev->uuid, *(uuid_le *)data) == 0)
4723 +- return 1;
4724 +-
4725 +- return 0;
4726 +-}
4727 +-
4728 +-static bool mdev_device_exist(struct mdev_parent *parent, uuid_le uuid)
4729 +-{
4730 +- struct device *dev;
4731 +-
4732 +- dev = device_find_child(parent->dev, &uuid, _find_mdev_device);
4733 +- if (dev) {
4734 +- put_device(dev);
4735 +- return true;
4736 +- }
4737 +-
4738 +- return false;
4739 +-}
4740 +-
4741 + /* Should be called holding parent_list_lock */
4742 + static struct mdev_parent *__find_parent_device(struct device *dev)
4743 + {
4744 +@@ -221,7 +193,6 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
4745 + }
4746 +
4747 + kref_init(&parent->ref);
4748 +- mutex_init(&parent->lock);
4749 +
4750 + parent->dev = dev;
4751 + parent->ops = ops;
4752 +@@ -297,6 +268,10 @@ static void mdev_device_release(struct device *dev)
4753 + {
4754 + struct mdev_device *mdev = to_mdev_device(dev);
4755 +
4756 ++ mutex_lock(&mdev_list_lock);
4757 ++ list_del(&mdev->next);
4758 ++ mutex_unlock(&mdev_list_lock);
4759 ++
4760 + dev_dbg(&mdev->dev, "MDEV: destroying\n");
4761 + kfree(mdev);
4762 + }
4763 +@@ -304,7 +279,7 @@ static void mdev_device_release(struct device *dev)
4764 + int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
4765 + {
4766 + int ret;
4767 +- struct mdev_device *mdev;
4768 ++ struct mdev_device *mdev, *tmp;
4769 + struct mdev_parent *parent;
4770 + struct mdev_type *type = to_mdev_type(kobj);
4771 +
4772 +@@ -312,21 +287,28 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
4773 + if (!parent)
4774 + return -EINVAL;
4775 +
4776 +- mutex_lock(&parent->lock);
4777 ++ mutex_lock(&mdev_list_lock);
4778 +
4779 + /* Check for duplicate */
4780 +- if (mdev_device_exist(parent, uuid)) {
4781 +- ret = -EEXIST;
4782 +- goto create_err;
4783 ++ list_for_each_entry(tmp, &mdev_list, next) {
4784 ++ if (!uuid_le_cmp(tmp->uuid, uuid)) {
4785 ++ mutex_unlock(&mdev_list_lock);
4786 ++ ret = -EEXIST;
4787 ++ goto mdev_fail;
4788 ++ }
4789 + }
4790 +
4791 + mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
4792 + if (!mdev) {
4793 ++ mutex_unlock(&mdev_list_lock);
4794 + ret = -ENOMEM;
4795 +- goto create_err;
4796 ++ goto mdev_fail;
4797 + }
4798 +
4799 + memcpy(&mdev->uuid, &uuid, sizeof(uuid_le));
4800 ++ list_add(&mdev->next, &mdev_list);
4801 ++ mutex_unlock(&mdev_list_lock);
4802 ++
4803 + mdev->parent = parent;
4804 + kref_init(&mdev->ref);
4805 +
4806 +@@ -338,35 +320,28 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
4807 + ret = device_register(&mdev->dev);
4808 + if (ret) {
4809 + put_device(&mdev->dev);
4810 +- goto create_err;
4811 ++ goto mdev_fail;
4812 + }
4813 +
4814 + ret = mdev_device_create_ops(kobj, mdev);
4815 + if (ret)
4816 +- goto create_failed;
4817 ++ goto create_fail;
4818 +
4819 + ret = mdev_create_sysfs_files(&mdev->dev, type);
4820 + if (ret) {
4821 + mdev_device_remove_ops(mdev, true);
4822 +- goto create_failed;
4823 ++ goto create_fail;
4824 + }
4825 +
4826 + mdev->type_kobj = kobj;
4827 ++ mdev->active = true;
4828 + dev_dbg(&mdev->dev, "MDEV: created\n");
4829 +
4830 +- mutex_unlock(&parent->lock);
4831 +-
4832 +- mutex_lock(&mdev_list_lock);
4833 +- list_add(&mdev->next, &mdev_list);
4834 +- mutex_unlock(&mdev_list_lock);
4835 +-
4836 +- return ret;
4837 ++ return 0;
4838 +
4839 +-create_failed:
4840 ++create_fail:
4841 + device_unregister(&mdev->dev);
4842 +-
4843 +-create_err:
4844 +- mutex_unlock(&parent->lock);
4845 ++mdev_fail:
4846 + mdev_put_parent(parent);
4847 + return ret;
4848 + }
4849 +@@ -377,44 +352,39 @@ int mdev_device_remove(struct device *dev, bool force_remove)
4850 + struct mdev_parent *parent;
4851 + struct mdev_type *type;
4852 + int ret;
4853 +- bool found = false;
4854 +
4855 + mdev = to_mdev_device(dev);
4856 +
4857 + mutex_lock(&mdev_list_lock);
4858 + list_for_each_entry(tmp, &mdev_list, next) {
4859 +- if (tmp == mdev) {
4860 +- found = true;
4861 ++ if (tmp == mdev)
4862 + break;
4863 +- }
4864 + }
4865 +
4866 +- if (found)
4867 +- list_del(&mdev->next);
4868 ++ if (tmp != mdev) {
4869 ++ mutex_unlock(&mdev_list_lock);
4870 ++ return -ENODEV;
4871 ++ }
4872 +
4873 +- mutex_unlock(&mdev_list_lock);
4874 ++ if (!mdev->active) {
4875 ++ mutex_unlock(&mdev_list_lock);
4876 ++ return -EAGAIN;
4877 ++ }
4878 +
4879 +- if (!found)
4880 +- return -ENODEV;
4881 ++ mdev->active = false;
4882 ++ mutex_unlock(&mdev_list_lock);
4883 +
4884 + type = to_mdev_type(mdev->type_kobj);
4885 + parent = mdev->parent;
4886 +- mutex_lock(&parent->lock);
4887 +
4888 + ret = mdev_device_remove_ops(mdev, force_remove);
4889 + if (ret) {
4890 +- mutex_unlock(&parent->lock);
4891 +-
4892 +- mutex_lock(&mdev_list_lock);
4893 +- list_add(&mdev->next, &mdev_list);
4894 +- mutex_unlock(&mdev_list_lock);
4895 +-
4896 ++ mdev->active = true;
4897 + return ret;
4898 + }
4899 +
4900 + mdev_remove_sysfs_files(dev, type);
4901 + device_unregister(dev);
4902 +- mutex_unlock(&parent->lock);
4903 + mdev_put_parent(parent);
4904 +
4905 + return 0;
4906 +diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h
4907 +index a9cefd70a705..b5819b7d7ef7 100644
4908 +--- a/drivers/vfio/mdev/mdev_private.h
4909 ++++ b/drivers/vfio/mdev/mdev_private.h
4910 +@@ -20,7 +20,6 @@ struct mdev_parent {
4911 + struct device *dev;
4912 + const struct mdev_parent_ops *ops;
4913 + struct kref ref;
4914 +- struct mutex lock;
4915 + struct list_head next;
4916 + struct kset *mdev_types_kset;
4917 + struct list_head type_list;
4918 +@@ -34,6 +33,7 @@ struct mdev_device {
4919 + struct kref ref;
4920 + struct list_head next;
4921 + struct kobject *type_kobj;
4922 ++ bool active;
4923 + };
4924 +
4925 + #define to_mdev_device(dev) container_of(dev, struct mdev_device, dev)
4926 +diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
4927 +index 4c27f4be3c3d..aa9e792110e3 100644
4928 +--- a/drivers/vfio/platform/vfio_platform_common.c
4929 ++++ b/drivers/vfio/platform/vfio_platform_common.c
4930 +@@ -681,18 +681,23 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
4931 + group = vfio_iommu_group_get(dev);
4932 + if (!group) {
4933 + pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
4934 +- return -EINVAL;
4935 ++ ret = -EINVAL;
4936 ++ goto put_reset;
4937 + }
4938 +
4939 + ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
4940 +- if (ret) {
4941 +- vfio_iommu_group_put(group, dev);
4942 +- return ret;
4943 +- }
4944 ++ if (ret)
4945 ++ goto put_iommu;
4946 +
4947 + mutex_init(&vdev->igate);
4948 +
4949 + return 0;
4950 ++
4951 ++put_iommu:
4952 ++ vfio_iommu_group_put(group, dev);
4953 ++put_reset:
4954 ++ vfio_platform_put_reset(vdev);
4955 ++ return ret;
4956 + }
4957 + EXPORT_SYMBOL_GPL(vfio_platform_probe_common);
4958 +
4959 +diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
4960 +index d639378e36ac..50eeb74ddc0a 100644
4961 +--- a/drivers/vfio/vfio_iommu_type1.c
4962 ++++ b/drivers/vfio/vfio_iommu_type1.c
4963 +@@ -83,6 +83,7 @@ struct vfio_dma {
4964 + size_t size; /* Map size (bytes) */
4965 + int prot; /* IOMMU_READ/WRITE */
4966 + bool iommu_mapped;
4967 ++ bool lock_cap; /* capable(CAP_IPC_LOCK) */
4968 + struct task_struct *task;
4969 + struct rb_root pfn_list; /* Ex-user pinned pfn list */
4970 + };
4971 +@@ -246,29 +247,25 @@ static int vfio_iova_put_vfio_pfn(struct vfio_dma *dma, struct vfio_pfn *vpfn)
4972 + return ret;
4973 + }
4974 +
4975 +-static int vfio_lock_acct(struct task_struct *task, long npage, bool *lock_cap)
4976 ++static int vfio_lock_acct(struct vfio_dma *dma, long npage, bool async)
4977 + {
4978 + struct mm_struct *mm;
4979 +- bool is_current;
4980 + int ret;
4981 +
4982 + if (!npage)
4983 + return 0;
4984 +
4985 +- is_current = (task->mm == current->mm);
4986 +-
4987 +- mm = is_current ? task->mm : get_task_mm(task);
4988 ++ mm = async ? get_task_mm(dma->task) : dma->task->mm;
4989 + if (!mm)
4990 + return -ESRCH; /* process exited */
4991 +
4992 + ret = down_write_killable(&mm->mmap_sem);
4993 + if (!ret) {
4994 + if (npage > 0) {
4995 +- if (lock_cap ? !*lock_cap :
4996 +- !has_capability(task, CAP_IPC_LOCK)) {
4997 ++ if (!dma->lock_cap) {
4998 + unsigned long limit;
4999 +
5000 +- limit = task_rlimit(task,
5001 ++ limit = task_rlimit(dma->task,
5002 + RLIMIT_MEMLOCK) >> PAGE_SHIFT;
5003 +
5004 + if (mm->locked_vm + npage > limit)
5005 +@@ -282,7 +279,7 @@ static int vfio_lock_acct(struct task_struct *task, long npage, bool *lock_cap)
5006 + up_write(&mm->mmap_sem);
5007 + }
5008 +
5009 +- if (!is_current)
5010 ++ if (async)
5011 + mmput(mm);
5012 +
5013 + return ret;
5014 +@@ -391,7 +388,7 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,
5015 + */
5016 + static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
5017 + long npage, unsigned long *pfn_base,
5018 +- bool lock_cap, unsigned long limit)
5019 ++ unsigned long limit)
5020 + {
5021 + unsigned long pfn = 0;
5022 + long ret, pinned = 0, lock_acct = 0;
5023 +@@ -414,7 +411,7 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
5024 + * pages are already counted against the user.
5025 + */
5026 + if (!rsvd && !vfio_find_vpfn(dma, iova)) {
5027 +- if (!lock_cap && current->mm->locked_vm + 1 > limit) {
5028 ++ if (!dma->lock_cap && current->mm->locked_vm + 1 > limit) {
5029 + put_pfn(*pfn_base, dma->prot);
5030 + pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n", __func__,
5031 + limit << PAGE_SHIFT);
5032 +@@ -440,7 +437,7 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
5033 + }
5034 +
5035 + if (!rsvd && !vfio_find_vpfn(dma, iova)) {
5036 +- if (!lock_cap &&
5037 ++ if (!dma->lock_cap &&
5038 + current->mm->locked_vm + lock_acct + 1 > limit) {
5039 + put_pfn(pfn, dma->prot);
5040 + pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n",
5041 +@@ -453,7 +450,7 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
5042 + }
5043 +
5044 + out:
5045 +- ret = vfio_lock_acct(current, lock_acct, &lock_cap);
5046 ++ ret = vfio_lock_acct(dma, lock_acct, false);
5047 +
5048 + unpin_out:
5049 + if (ret) {
5050 +@@ -484,7 +481,7 @@ static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova,
5051 + }
5052 +
5053 + if (do_accounting)
5054 +- vfio_lock_acct(dma->task, locked - unlocked, NULL);
5055 ++ vfio_lock_acct(dma, locked - unlocked, true);
5056 +
5057 + return unlocked;
5058 + }
5059 +@@ -501,7 +498,7 @@ static int vfio_pin_page_external(struct vfio_dma *dma, unsigned long vaddr,
5060 +
5061 + ret = vaddr_get_pfn(mm, vaddr, dma->prot, pfn_base);
5062 + if (!ret && do_accounting && !is_invalid_reserved_pfn(*pfn_base)) {
5063 +- ret = vfio_lock_acct(dma->task, 1, NULL);
5064 ++ ret = vfio_lock_acct(dma, 1, true);
5065 + if (ret) {
5066 + put_pfn(*pfn_base, dma->prot);
5067 + if (ret == -ENOMEM)
5068 +@@ -528,7 +525,7 @@ static int vfio_unpin_page_external(struct vfio_dma *dma, dma_addr_t iova,
5069 + unlocked = vfio_iova_put_vfio_pfn(dma, vpfn);
5070 +
5071 + if (do_accounting)
5072 +- vfio_lock_acct(dma->task, -unlocked, NULL);
5073 ++ vfio_lock_acct(dma, -unlocked, true);
5074 +
5075 + return unlocked;
5076 + }
5077 +@@ -723,7 +720,7 @@ static long vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma,
5078 +
5079 + dma->iommu_mapped = false;
5080 + if (do_accounting) {
5081 +- vfio_lock_acct(dma->task, -unlocked, NULL);
5082 ++ vfio_lock_acct(dma, -unlocked, true);
5083 + return 0;
5084 + }
5085 + return unlocked;
5086 +@@ -935,14 +932,12 @@ static int vfio_pin_map_dma(struct vfio_iommu *iommu, struct vfio_dma *dma,
5087 + size_t size = map_size;
5088 + long npage;
5089 + unsigned long pfn, limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
5090 +- bool lock_cap = capable(CAP_IPC_LOCK);
5091 + int ret = 0;
5092 +
5093 + while (size) {
5094 + /* Pin a contiguous chunk of memory */
5095 + npage = vfio_pin_pages_remote(dma, vaddr + dma->size,
5096 +- size >> PAGE_SHIFT, &pfn,
5097 +- lock_cap, limit);
5098 ++ size >> PAGE_SHIFT, &pfn, limit);
5099 + if (npage <= 0) {
5100 + WARN_ON(!npage);
5101 + ret = (int)npage;
5102 +@@ -1017,8 +1012,36 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
5103 + dma->iova = iova;
5104 + dma->vaddr = vaddr;
5105 + dma->prot = prot;
5106 +- get_task_struct(current);
5107 +- dma->task = current;
5108 ++
5109 ++ /*
5110 ++ * We need to be able to both add to a task's locked memory and test
5111 ++ * against the locked memory limit and we need to be able to do both
5112 ++ * outside of this call path as pinning can be asynchronous via the
5113 ++ * external interfaces for mdev devices. RLIMIT_MEMLOCK requires a
5114 ++ * task_struct and VM locked pages requires an mm_struct, however
5115 ++ * holding an indefinite mm reference is not recommended, therefore we
5116 ++ * only hold a reference to a task. We could hold a reference to
5117 ++ * current, however QEMU uses this call path through vCPU threads,
5118 ++ * which can be killed resulting in a NULL mm and failure in the unmap
5119 ++ * path when called via a different thread. Avoid this problem by
5120 ++ * using the group_leader as threads within the same group require
5121 ++ * both CLONE_THREAD and CLONE_VM and will therefore use the same
5122 ++ * mm_struct.
5123 ++ *
5124 ++ * Previously we also used the task for testing CAP_IPC_LOCK at the
5125 ++ * time of pinning and accounting, however has_capability() makes use
5126 ++ * of real_cred, a copy-on-write field, so we can't guarantee that it
5127 ++ * matches group_leader, or in fact that it might not change by the
5128 ++ * time it's evaluated. If a process were to call MAP_DMA with
5129 ++ * CAP_IPC_LOCK but later drop it, it doesn't make sense that they
5130 ++ * possibly see different results for an iommu_mapped vfio_dma vs
5131 ++ * externally mapped. Therefore track CAP_IPC_LOCK in vfio_dma at the
5132 ++ * time of calling MAP_DMA.
5133 ++ */
5134 ++ get_task_struct(current->group_leader);
5135 ++ dma->task = current->group_leader;
5136 ++ dma->lock_cap = capable(CAP_IPC_LOCK);
5137 ++
5138 + dma->pfn_list = RB_ROOT;
5139 +
5140 + /* Insert zero-sized and grow as we map chunks of it */
5141 +@@ -1053,7 +1076,6 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu,
5142 + struct vfio_domain *d;
5143 + struct rb_node *n;
5144 + unsigned long limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
5145 +- bool lock_cap = capable(CAP_IPC_LOCK);
5146 + int ret;
5147 +
5148 + /* Arbitrarily pick the first domain in the list for lookups */
5149 +@@ -1100,8 +1122,7 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu,
5150 +
5151 + npage = vfio_pin_pages_remote(dma, vaddr,
5152 + n >> PAGE_SHIFT,
5153 +- &pfn, lock_cap,
5154 +- limit);
5155 ++ &pfn, limit);
5156 + if (npage <= 0) {
5157 + WARN_ON(!npage);
5158 + ret = (int)npage;
5159 +@@ -1378,7 +1399,7 @@ static void vfio_iommu_unmap_unpin_reaccount(struct vfio_iommu *iommu)
5160 + if (!is_invalid_reserved_pfn(vpfn->pfn))
5161 + locked++;
5162 + }
5163 +- vfio_lock_acct(dma->task, locked - unlocked, NULL);
5164 ++ vfio_lock_acct(dma, locked - unlocked, true);
5165 + }
5166 + }
5167 +
5168 +diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
5169 +index 1c2289ddd555..0fa7d2bd0e48 100644
5170 +--- a/drivers/video/backlight/pwm_bl.c
5171 ++++ b/drivers/video/backlight/pwm_bl.c
5172 +@@ -301,14 +301,14 @@ static int pwm_backlight_probe(struct platform_device *pdev)
5173 +
5174 + /*
5175 + * If the GPIO is not known to be already configured as output, that
5176 +- * is, if gpiod_get_direction returns either GPIOF_DIR_IN or -EINVAL,
5177 +- * change the direction to output and set the GPIO as active.
5178 ++ * is, if gpiod_get_direction returns either 1 or -EINVAL, change the
5179 ++ * direction to output and set the GPIO as active.
5180 + * Do not force the GPIO to active when it was already output as it
5181 + * could cause backlight flickering or we would enable the backlight too
5182 + * early. Leave the decision of the initial backlight state for later.
5183 + */
5184 + if (pb->enable_gpio &&
5185 +- gpiod_get_direction(pb->enable_gpio) != GPIOF_DIR_OUT)
5186 ++ gpiod_get_direction(pb->enable_gpio) != 0)
5187 + gpiod_direction_output(pb->enable_gpio, 1);
5188 +
5189 + pb->power_supply = devm_regulator_get(&pdev->dev, "power");
5190 +diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
5191 +index 2a20fc163ed0..4c62ad74aec0 100644
5192 +--- a/drivers/watchdog/da9063_wdt.c
5193 ++++ b/drivers/watchdog/da9063_wdt.c
5194 +@@ -102,10 +102,23 @@ static int da9063_wdt_set_timeout(struct watchdog_device *wdd,
5195 + {
5196 + struct da9063 *da9063 = watchdog_get_drvdata(wdd);
5197 + unsigned int selector;
5198 +- int ret;
5199 ++ int ret = 0;
5200 +
5201 + selector = da9063_wdt_timeout_to_sel(timeout);
5202 +- ret = _da9063_wdt_set_timeout(da9063, selector);
5203 ++
5204 ++ /*
5205 ++ * There are two cases when a set_timeout() will be called:
5206 ++ * 1. The watchdog is off and someone wants to set the timeout for the
5207 ++ * further use.
5208 ++ * 2. The watchdog is already running and a new timeout value should be
5209 ++ * set.
5210 ++ *
5211 ++ * The watchdog can't store a timeout value not equal zero without
5212 ++ * enabling the watchdog, so the timeout must be buffered by the driver.
5213 ++ */
5214 ++ if (watchdog_active(wdd))
5215 ++ ret = _da9063_wdt_set_timeout(da9063, selector);
5216 ++
5217 + if (ret)
5218 + dev_err(da9063->dev, "Failed to set watchdog timeout (err = %d)\n",
5219 + ret);
5220 +diff --git a/fs/block_dev.c b/fs/block_dev.c
5221 +index 789f55e851ae..3323eec5c164 100644
5222 +--- a/fs/block_dev.c
5223 ++++ b/fs/block_dev.c
5224 +@@ -231,7 +231,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
5225 +
5226 + ret = bio_iov_iter_get_pages(&bio, iter);
5227 + if (unlikely(ret))
5228 +- return ret;
5229 ++ goto out;
5230 + ret = bio.bi_iter.bi_size;
5231 +
5232 + if (iov_iter_rw(iter) == READ) {
5233 +@@ -260,12 +260,13 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
5234 + put_page(bvec->bv_page);
5235 + }
5236 +
5237 +- if (vecs != inline_vecs)
5238 +- kfree(vecs);
5239 +-
5240 + if (unlikely(bio.bi_status))
5241 + ret = blk_status_to_errno(bio.bi_status);
5242 +
5243 ++out:
5244 ++ if (vecs != inline_vecs)
5245 ++ kfree(vecs);
5246 ++
5247 + bio_uninit(&bio);
5248 +
5249 + return ret;
5250 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
5251 +index f5b90dc137ec..28a58f40f3a4 100644
5252 +--- a/fs/btrfs/inode.c
5253 ++++ b/fs/btrfs/inode.c
5254 +@@ -3162,6 +3162,9 @@ out:
5255 + /* once for the tree */
5256 + btrfs_put_ordered_extent(ordered_extent);
5257 +
5258 ++ /* Try to release some metadata so we don't get an OOM but don't wait */
5259 ++ btrfs_btree_balance_dirty_nodelay(fs_info);
5260 ++
5261 + return ret;
5262 + }
5263 +
5264 +@@ -4737,7 +4740,10 @@ delete:
5265 + extent_num_bytes, 0,
5266 + btrfs_header_owner(leaf),
5267 + ino, extent_offset);
5268 +- BUG_ON(ret);
5269 ++ if (ret) {
5270 ++ btrfs_abort_transaction(trans, ret);
5271 ++ break;
5272 ++ }
5273 + if (btrfs_should_throttle_delayed_refs(trans, fs_info))
5274 + btrfs_async_run_delayed_refs(fs_info,
5275 + trans->delayed_ref_updates * 2,
5276 +@@ -5496,13 +5502,18 @@ void btrfs_evict_inode(struct inode *inode)
5277 + trans->block_rsv = rsv;
5278 +
5279 + ret = btrfs_truncate_inode_items(trans, root, inode, 0, 0);
5280 +- if (ret != -ENOSPC && ret != -EAGAIN)
5281 ++ if (ret) {
5282 ++ trans->block_rsv = &fs_info->trans_block_rsv;
5283 ++ btrfs_end_transaction(trans);
5284 ++ btrfs_btree_balance_dirty(fs_info);
5285 ++ if (ret != -ENOSPC && ret != -EAGAIN) {
5286 ++ btrfs_orphan_del(NULL, BTRFS_I(inode));
5287 ++ btrfs_free_block_rsv(fs_info, rsv);
5288 ++ goto no_delete;
5289 ++ }
5290 ++ } else {
5291 + break;
5292 +-
5293 +- trans->block_rsv = &fs_info->trans_block_rsv;
5294 +- btrfs_end_transaction(trans);
5295 +- trans = NULL;
5296 +- btrfs_btree_balance_dirty(fs_info);
5297 ++ }
5298 + }
5299 +
5300 + btrfs_free_block_rsv(fs_info, rsv);
5301 +@@ -5511,12 +5522,8 @@ void btrfs_evict_inode(struct inode *inode)
5302 + * Errors here aren't a big deal, it just means we leave orphan items
5303 + * in the tree. They will be cleaned up on the next mount.
5304 + */
5305 +- if (ret == 0) {
5306 +- trans->block_rsv = root->orphan_block_rsv;
5307 +- btrfs_orphan_del(trans, BTRFS_I(inode));
5308 +- } else {
5309 +- btrfs_orphan_del(NULL, BTRFS_I(inode));
5310 +- }
5311 ++ trans->block_rsv = root->orphan_block_rsv;
5312 ++ btrfs_orphan_del(trans, BTRFS_I(inode));
5313 +
5314 + trans->block_rsv = &fs_info->trans_block_rsv;
5315 + if (!(root == fs_info->tree_root ||
5316 +diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
5317 +index e172d4843eae..473ad5985aa3 100644
5318 +--- a/fs/btrfs/qgroup.c
5319 ++++ b/fs/btrfs/qgroup.c
5320 +@@ -2499,6 +2499,21 @@ out:
5321 + spin_unlock(&fs_info->qgroup_lock);
5322 + }
5323 +
5324 ++/*
5325 ++ * Check if the leaf is the last leaf. Which means all node pointers
5326 ++ * are at their last position.
5327 ++ */
5328 ++static bool is_last_leaf(struct btrfs_path *path)
5329 ++{
5330 ++ int i;
5331 ++
5332 ++ for (i = 1; i < BTRFS_MAX_LEVEL && path->nodes[i]; i++) {
5333 ++ if (path->slots[i] != btrfs_header_nritems(path->nodes[i]) - 1)
5334 ++ return false;
5335 ++ }
5336 ++ return true;
5337 ++}
5338 ++
5339 + /*
5340 + * returns < 0 on error, 0 when more leafs are to be scanned.
5341 + * returns 1 when done.
5342 +@@ -2512,6 +2527,7 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
5343 + struct ulist *roots = NULL;
5344 + struct seq_list tree_mod_seq_elem = SEQ_LIST_INIT(tree_mod_seq_elem);
5345 + u64 num_bytes;
5346 ++ bool done;
5347 + int slot;
5348 + int ret;
5349 +
5350 +@@ -2540,6 +2556,7 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
5351 + mutex_unlock(&fs_info->qgroup_rescan_lock);
5352 + return ret;
5353 + }
5354 ++ done = is_last_leaf(path);
5355 +
5356 + btrfs_item_key_to_cpu(path->nodes[0], &found,
5357 + btrfs_header_nritems(path->nodes[0]) - 1);
5358 +@@ -2586,6 +2603,8 @@ out:
5359 + }
5360 + btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem);
5361 +
5362 ++ if (done && !ret)
5363 ++ ret = 1;
5364 + return ret;
5365 + }
5366 +
5367 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
5368 +index bf4e22df7c97..e1b4a59485df 100644
5369 +--- a/fs/btrfs/tree-log.c
5370 ++++ b/fs/btrfs/tree-log.c
5371 +@@ -3041,8 +3041,11 @@ out_wake_log_root:
5372 + mutex_unlock(&log_root_tree->log_mutex);
5373 +
5374 + /*
5375 +- * The barrier before waitqueue_active is implied by mutex_unlock
5376 ++ * The barrier before waitqueue_active is needed so all the updates
5377 ++ * above are seen by the woken threads. It might not be necessary, but
5378 ++ * proving that seems to be hard.
5379 + */
5380 ++ smp_mb();
5381 + if (waitqueue_active(&log_root_tree->log_commit_wait[index2]))
5382 + wake_up(&log_root_tree->log_commit_wait[index2]);
5383 + out:
5384 +@@ -3053,8 +3056,11 @@ out:
5385 + mutex_unlock(&root->log_mutex);
5386 +
5387 + /*
5388 +- * The barrier before waitqueue_active is implied by mutex_unlock
5389 ++ * The barrier before waitqueue_active is needed so all the updates
5390 ++ * above are seen by the woken threads. It might not be necessary, but
5391 ++ * proving that seems to be hard.
5392 + */
5393 ++ smp_mb();
5394 + if (waitqueue_active(&root->log_commit_wait[index1]))
5395 + wake_up(&root->log_commit_wait[index1]);
5396 + return ret;
5397 +diff --git a/fs/ceph/super.c b/fs/ceph/super.c
5398 +index 48ffe720bf09..b79b1211a2b5 100644
5399 +--- a/fs/ceph/super.c
5400 ++++ b/fs/ceph/super.c
5401 +@@ -254,7 +254,7 @@ static int parse_fsopt_token(char *c, void *private)
5402 + case Opt_rasize:
5403 + if (intval < 0)
5404 + return -EINVAL;
5405 +- fsopt->rasize = ALIGN(intval + PAGE_SIZE - 1, PAGE_SIZE);
5406 ++ fsopt->rasize = ALIGN(intval, PAGE_SIZE);
5407 + break;
5408 + case Opt_caps_wanted_delay_min:
5409 + if (intval < 1)
5410 +diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
5411 +index d262a93d9b31..daf2683f0655 100644
5412 +--- a/fs/crypto/crypto.c
5413 ++++ b/fs/crypto/crypto.c
5414 +@@ -446,8 +446,17 @@ fail:
5415 + */
5416 + static int __init fscrypt_init(void)
5417 + {
5418 ++ /*
5419 ++ * Use an unbound workqueue to allow bios to be decrypted in parallel
5420 ++ * even when they happen to complete on the same CPU. This sacrifices
5421 ++ * locality, but it's worthwhile since decryption is CPU-intensive.
5422 ++ *
5423 ++ * Also use a high-priority workqueue to prioritize decryption work,
5424 ++ * which blocks reads from completing, over regular application tasks.
5425 ++ */
5426 + fscrypt_read_workqueue = alloc_workqueue("fscrypt_read_queue",
5427 +- WQ_HIGHPRI, 0);
5428 ++ WQ_UNBOUND | WQ_HIGHPRI,
5429 ++ num_online_cpus());
5430 + if (!fscrypt_read_workqueue)
5431 + goto fail;
5432 +
5433 +diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
5434 +index 9c9eafd6bd76..70266a3355dc 100644
5435 +--- a/fs/ext4/balloc.c
5436 ++++ b/fs/ext4/balloc.c
5437 +@@ -379,6 +379,8 @@ static int ext4_validate_block_bitmap(struct super_block *sb,
5438 + return -EFSCORRUPTED;
5439 +
5440 + ext4_lock_group(sb, block_group);
5441 ++ if (buffer_verified(bh))
5442 ++ goto verified;
5443 + if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group,
5444 + desc, bh))) {
5445 + ext4_unlock_group(sb, block_group);
5446 +@@ -401,6 +403,7 @@ static int ext4_validate_block_bitmap(struct super_block *sb,
5447 + return -EFSCORRUPTED;
5448 + }
5449 + set_buffer_verified(bh);
5450 ++verified:
5451 + ext4_unlock_group(sb, block_group);
5452 + return 0;
5453 + }
5454 +diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
5455 +index 95341bc2b3b7..2f46564d3fca 100644
5456 +--- a/fs/ext4/ialloc.c
5457 ++++ b/fs/ext4/ialloc.c
5458 +@@ -91,6 +91,8 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
5459 + return -EFSCORRUPTED;
5460 +
5461 + ext4_lock_group(sb, block_group);
5462 ++ if (buffer_verified(bh))
5463 ++ goto verified;
5464 + blk = ext4_inode_bitmap(sb, desc);
5465 + if (!ext4_inode_bitmap_csum_verify(sb, block_group, desc, bh,
5466 + EXT4_INODES_PER_GROUP(sb) / 8)) {
5467 +@@ -108,6 +110,7 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
5468 + return -EFSBADCRC;
5469 + }
5470 + set_buffer_verified(bh);
5471 ++verified:
5472 + ext4_unlock_group(sb, block_group);
5473 + return 0;
5474 + }
5475 +@@ -1394,7 +1397,10 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group,
5476 + ext4_itable_unused_count(sb, gdp)),
5477 + sbi->s_inodes_per_block);
5478 +
5479 +- if ((used_blks < 0) || (used_blks > sbi->s_itb_per_group)) {
5480 ++ if ((used_blks < 0) || (used_blks > sbi->s_itb_per_group) ||
5481 ++ ((group == 0) && ((EXT4_INODES_PER_GROUP(sb) -
5482 ++ ext4_itable_unused_count(sb, gdp)) <
5483 ++ EXT4_FIRST_INO(sb)))) {
5484 + ext4_error(sb, "Something is wrong with group %u: "
5485 + "used itable blocks: %d; "
5486 + "itable unused count: %u",
5487 +diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
5488 +index 7d498f4a3f90..b549cfd2d7d3 100644
5489 +--- a/fs/ext4/inline.c
5490 ++++ b/fs/ext4/inline.c
5491 +@@ -688,6 +688,10 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
5492 + goto convert;
5493 + }
5494 +
5495 ++ ret = ext4_journal_get_write_access(handle, iloc.bh);
5496 ++ if (ret)
5497 ++ goto out;
5498 ++
5499 + flags |= AOP_FLAG_NOFS;
5500 +
5501 + page = grab_cache_page_write_begin(mapping, 0, flags);
5502 +@@ -716,7 +720,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
5503 + out_up_read:
5504 + up_read(&EXT4_I(inode)->xattr_sem);
5505 + out:
5506 +- if (handle)
5507 ++ if (handle && (ret != 1))
5508 + ext4_journal_stop(handle);
5509 + brelse(iloc.bh);
5510 + return ret;
5511 +@@ -758,6 +762,7 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
5512 +
5513 + ext4_write_unlock_xattr(inode, &no_expand);
5514 + brelse(iloc.bh);
5515 ++ mark_inode_dirty(inode);
5516 + out:
5517 + return copied;
5518 + }
5519 +@@ -904,7 +909,6 @@ retry_journal:
5520 + goto out;
5521 + }
5522 +
5523 +-
5524 + page = grab_cache_page_write_begin(mapping, 0, flags);
5525 + if (!page) {
5526 + ret = -ENOMEM;
5527 +@@ -922,6 +926,9 @@ retry_journal:
5528 + if (ret < 0)
5529 + goto out_release_page;
5530 + }
5531 ++ ret = ext4_journal_get_write_access(handle, iloc.bh);
5532 ++ if (ret)
5533 ++ goto out_release_page;
5534 +
5535 + up_read(&EXT4_I(inode)->xattr_sem);
5536 + *pagep = page;
5537 +@@ -942,7 +949,6 @@ int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
5538 + unsigned len, unsigned copied,
5539 + struct page *page)
5540 + {
5541 +- int i_size_changed = 0;
5542 + int ret;
5543 +
5544 + ret = ext4_write_inline_data_end(inode, pos, len, copied, page);
5545 +@@ -960,10 +966,8 @@ int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
5546 + * But it's important to update i_size while still holding page lock:
5547 + * page writeout could otherwise come in and zero beyond i_size.
5548 + */
5549 +- if (pos+copied > inode->i_size) {
5550 ++ if (pos+copied > inode->i_size)
5551 + i_size_write(inode, pos+copied);
5552 +- i_size_changed = 1;
5553 +- }
5554 + unlock_page(page);
5555 + put_page(page);
5556 +
5557 +@@ -973,8 +977,7 @@ int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
5558 + * ordering of page lock and transaction start for journaling
5559 + * filesystems.
5560 + */
5561 +- if (i_size_changed)
5562 +- mark_inode_dirty(inode);
5563 ++ mark_inode_dirty(inode);
5564 +
5565 + return copied;
5566 + }
5567 +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
5568 +index c2efe4d2ad87..f9baa59de0e2 100644
5569 +--- a/fs/ext4/inode.c
5570 ++++ b/fs/ext4/inode.c
5571 +@@ -1388,9 +1388,10 @@ static int ext4_write_end(struct file *file,
5572 + loff_t old_size = inode->i_size;
5573 + int ret = 0, ret2;
5574 + int i_size_changed = 0;
5575 ++ int inline_data = ext4_has_inline_data(inode);
5576 +
5577 + trace_ext4_write_end(inode, pos, len, copied);
5578 +- if (ext4_has_inline_data(inode)) {
5579 ++ if (inline_data) {
5580 + ret = ext4_write_inline_data_end(inode, pos, len,
5581 + copied, page);
5582 + if (ret < 0) {
5583 +@@ -1418,7 +1419,7 @@ static int ext4_write_end(struct file *file,
5584 + * ordering of page lock and transaction start for journaling
5585 + * filesystems.
5586 + */
5587 +- if (i_size_changed)
5588 ++ if (i_size_changed || inline_data)
5589 + ext4_mark_inode_dirty(handle, inode);
5590 +
5591 + if (pos + len > inode->i_size && ext4_can_truncate(inode))
5592 +@@ -1492,6 +1493,7 @@ static int ext4_journalled_write_end(struct file *file,
5593 + int partial = 0;
5594 + unsigned from, to;
5595 + int size_changed = 0;
5596 ++ int inline_data = ext4_has_inline_data(inode);
5597 +
5598 + trace_ext4_journalled_write_end(inode, pos, len, copied);
5599 + from = pos & (PAGE_SIZE - 1);
5600 +@@ -1499,7 +1501,7 @@ static int ext4_journalled_write_end(struct file *file,
5601 +
5602 + BUG_ON(!ext4_handle_valid(handle));
5603 +
5604 +- if (ext4_has_inline_data(inode)) {
5605 ++ if (inline_data) {
5606 + ret = ext4_write_inline_data_end(inode, pos, len,
5607 + copied, page);
5608 + if (ret < 0) {
5609 +@@ -1530,7 +1532,7 @@ static int ext4_journalled_write_end(struct file *file,
5610 + if (old_size < pos)
5611 + pagecache_isize_extended(inode, old_size, pos);
5612 +
5613 +- if (size_changed) {
5614 ++ if (size_changed || inline_data) {
5615 + ret2 = ext4_mark_inode_dirty(handle, inode);
5616 + if (!ret)
5617 + ret = ret2;
5618 +@@ -2027,11 +2029,7 @@ static int __ext4_journalled_writepage(struct page *page,
5619 + }
5620 +
5621 + if (inline_data) {
5622 +- BUFFER_TRACE(inode_bh, "get write access");
5623 +- ret = ext4_journal_get_write_access(handle, inode_bh);
5624 +-
5625 +- err = ext4_handle_dirty_metadata(handle, inode, inode_bh);
5626 +-
5627 ++ ret = ext4_mark_inode_dirty(handle, inode);
5628 + } else {
5629 + ret = ext4_walk_page_buffers(handle, page_bufs, 0, len, NULL,
5630 + do_journal_get_write_access);
5631 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
5632 +index fc32a67a7a19..6b0c1ea95196 100644
5633 +--- a/fs/ext4/super.c
5634 ++++ b/fs/ext4/super.c
5635 +@@ -3103,14 +3103,8 @@ static ext4_group_t ext4_has_uninit_itable(struct super_block *sb)
5636 + if (!gdp)
5637 + continue;
5638 +
5639 +- if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED))
5640 +- continue;
5641 +- if (group != 0)
5642 ++ if (!(gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED)))
5643 + break;
5644 +- ext4_error(sb, "Inode table for bg 0 marked as "
5645 +- "needing zeroing");
5646 +- if (sb_rdonly(sb))
5647 +- return ngroups;
5648 + }
5649 +
5650 + return group;
5651 +diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
5652 +index 36b535207c88..85142e5df88b 100644
5653 +--- a/fs/f2fs/data.c
5654 ++++ b/fs/f2fs/data.c
5655 +@@ -1601,7 +1601,13 @@ out:
5656 +
5657 + redirty_out:
5658 + redirty_page_for_writepage(wbc, page);
5659 +- if (!err)
5660 ++ /*
5661 ++ * pageout() in MM traslates EAGAIN, so calls handle_write_error()
5662 ++ * -> mapping_set_error() -> set_bit(AS_EIO, ...).
5663 ++ * file_write_and_wait_range() will see EIO error, which is critical
5664 ++ * to return value of fsync() followed by atomic_write failure to user.
5665 ++ */
5666 ++ if (!err || wbc->for_reclaim)
5667 + return AOP_WRITEPAGE_ACTIVATE;
5668 + unlock_page(page);
5669 + return err;
5670 +diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
5671 +index 72c6a9e9a9b4..87e654c53c31 100644
5672 +--- a/fs/f2fs/file.c
5673 ++++ b/fs/f2fs/file.c
5674 +@@ -1630,6 +1630,8 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
5675 +
5676 + inode_lock(inode);
5677 +
5678 ++ down_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
5679 ++
5680 + if (f2fs_is_atomic_file(inode))
5681 + goto out;
5682 +
5683 +@@ -1659,6 +1661,7 @@ inc_stat:
5684 + stat_inc_atomic_write(inode);
5685 + stat_update_max_atomic_write(inode);
5686 + out:
5687 ++ up_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
5688 + inode_unlock(inode);
5689 + mnt_drop_write_file(filp);
5690 + return ret;
5691 +@@ -1808,9 +1811,11 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
5692 + if (get_user(in, (__u32 __user *)arg))
5693 + return -EFAULT;
5694 +
5695 +- ret = mnt_want_write_file(filp);
5696 +- if (ret)
5697 +- return ret;
5698 ++ if (in != F2FS_GOING_DOWN_FULLSYNC) {
5699 ++ ret = mnt_want_write_file(filp);
5700 ++ if (ret)
5701 ++ return ret;
5702 ++ }
5703 +
5704 + switch (in) {
5705 + case F2FS_GOING_DOWN_FULLSYNC:
5706 +@@ -1838,7 +1843,8 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
5707 + }
5708 + f2fs_update_time(sbi, REQ_TIME);
5709 + out:
5710 +- mnt_drop_write_file(filp);
5711 ++ if (in != F2FS_GOING_DOWN_FULLSYNC)
5712 ++ mnt_drop_write_file(filp);
5713 + return ret;
5714 + }
5715 +
5716 +@@ -2490,7 +2496,9 @@ static int f2fs_ioc_setproject(struct file *filp, __u32 projid)
5717 + }
5718 + f2fs_put_page(ipage, 1);
5719 +
5720 +- dquot_initialize(inode);
5721 ++ err = dquot_initialize(inode);
5722 ++ if (err)
5723 ++ goto out_unlock;
5724 +
5725 + transfer_to[PRJQUOTA] = dqget(sb, make_kqid_projid(kprojid));
5726 + if (!IS_ERR(transfer_to[PRJQUOTA])) {
5727 +diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
5728 +index e5673a9b2619..f2f897cd23c9 100644
5729 +--- a/fs/f2fs/gc.c
5730 ++++ b/fs/f2fs/gc.c
5731 +@@ -768,9 +768,14 @@ retry:
5732 + set_cold_data(page);
5733 +
5734 + err = do_write_data_page(&fio);
5735 +- if (err == -ENOMEM && is_dirty) {
5736 +- congestion_wait(BLK_RW_ASYNC, HZ/50);
5737 +- goto retry;
5738 ++ if (err) {
5739 ++ clear_cold_data(page);
5740 ++ if (err == -ENOMEM) {
5741 ++ congestion_wait(BLK_RW_ASYNC, HZ/50);
5742 ++ goto retry;
5743 ++ }
5744 ++ if (is_dirty)
5745 ++ set_page_dirty(page);
5746 + }
5747 + }
5748 + out:
5749 +diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
5750 +index 271516db8939..7c05bd4222b2 100644
5751 +--- a/fs/f2fs/segment.c
5752 ++++ b/fs/f2fs/segment.c
5753 +@@ -225,6 +225,8 @@ static int __revoke_inmem_pages(struct inode *inode,
5754 +
5755 + lock_page(page);
5756 +
5757 ++ f2fs_wait_on_page_writeback(page, DATA, true);
5758 ++
5759 + if (recover) {
5760 + struct dnode_of_data dn;
5761 + struct node_info ni;
5762 +@@ -435,6 +437,9 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
5763 +
5764 + void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
5765 + {
5766 ++ if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
5767 ++ return;
5768 ++
5769 + /* try to shrink extent cache when there is no enough memory */
5770 + if (!available_free_memory(sbi, EXTENT_CACHE))
5771 + f2fs_shrink_extent_tree(sbi, EXTENT_CACHE_SHRINK_NUMBER);
5772 +diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
5773 +index 933c3d529e65..400c00058bad 100644
5774 +--- a/fs/f2fs/super.c
5775 ++++ b/fs/f2fs/super.c
5776 +@@ -2663,6 +2663,12 @@ static int __init init_f2fs_fs(void)
5777 + {
5778 + int err;
5779 +
5780 ++ if (PAGE_SIZE != F2FS_BLKSIZE) {
5781 ++ printk("F2FS not supported on PAGE_SIZE(%lu) != %d\n",
5782 ++ PAGE_SIZE, F2FS_BLKSIZE);
5783 ++ return -EINVAL;
5784 ++ }
5785 ++
5786 + f2fs_build_trace_ios();
5787 +
5788 + err = init_inodecache();
5789 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
5790 +index 928bbc397818..43fbf4495090 100644
5791 +--- a/fs/nfs/nfs4proc.c
5792 ++++ b/fs/nfs/nfs4proc.c
5793 +@@ -745,6 +745,13 @@ static int nfs41_sequence_process(struct rpc_task *task,
5794 + slot->slot_nr,
5795 + slot->seq_nr);
5796 + goto out_retry;
5797 ++ case -NFS4ERR_RETRY_UNCACHED_REP:
5798 ++ case -NFS4ERR_SEQ_FALSE_RETRY:
5799 ++ /*
5800 ++ * The server thinks we tried to replay a request.
5801 ++ * Retry the call after bumping the sequence ID.
5802 ++ */
5803 ++ goto retry_new_seq;
5804 + case -NFS4ERR_BADSLOT:
5805 + /*
5806 + * The slot id we used was probably retired. Try again
5807 +@@ -769,10 +776,6 @@ static int nfs41_sequence_process(struct rpc_task *task,
5808 + goto retry_nowait;
5809 + }
5810 + goto session_recover;
5811 +- case -NFS4ERR_SEQ_FALSE_RETRY:
5812 +- if (interrupted)
5813 +- goto retry_new_seq;
5814 +- goto session_recover;
5815 + default:
5816 + /* Just update the slot sequence no. */
5817 + slot->seq_done = 1;
5818 +@@ -2692,7 +2695,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
5819 + if (ret != 0)
5820 + goto out;
5821 +
5822 +- state = nfs4_opendata_to_nfs4_state(opendata);
5823 ++ state = _nfs4_opendata_to_nfs4_state(opendata);
5824 + ret = PTR_ERR(state);
5825 + if (IS_ERR(state))
5826 + goto out;
5827 +@@ -2728,6 +2731,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
5828 + nfs4_schedule_stateid_recovery(server, state);
5829 + }
5830 + out:
5831 ++ nfs4_sequence_free_slot(&opendata->o_res.seq_res);
5832 + return ret;
5833 + }
5834 +
5835 +diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
5836 +index 7b34534210ce..96867fb159bf 100644
5837 +--- a/fs/nfs/pnfs.c
5838 ++++ b/fs/nfs/pnfs.c
5839 +@@ -1126,7 +1126,7 @@ _pnfs_return_layout(struct inode *ino)
5840 + LIST_HEAD(tmp_list);
5841 + nfs4_stateid stateid;
5842 + int status = 0;
5843 +- bool send;
5844 ++ bool send, valid_layout;
5845 +
5846 + dprintk("NFS: %s for inode %lu\n", __func__, ino->i_ino);
5847 +
5848 +@@ -1147,6 +1147,7 @@ _pnfs_return_layout(struct inode *ino)
5849 + goto out_put_layout_hdr;
5850 + spin_lock(&ino->i_lock);
5851 + }
5852 ++ valid_layout = pnfs_layout_is_valid(lo);
5853 + pnfs_clear_layoutcommit(ino, &tmp_list);
5854 + pnfs_mark_matching_lsegs_invalid(lo, &tmp_list, NULL, 0);
5855 +
5856 +@@ -1160,7 +1161,8 @@ _pnfs_return_layout(struct inode *ino)
5857 + }
5858 +
5859 + /* Don't send a LAYOUTRETURN if list was initially empty */
5860 +- if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags)) {
5861 ++ if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags) ||
5862 ++ !valid_layout) {
5863 + spin_unlock(&ino->i_lock);
5864 + dprintk("NFS: %s no layout segments to return\n", __func__);
5865 + goto out_put_layout_hdr;
5866 +diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
5867 +index f6588cc6816c..c1e923334012 100644
5868 +--- a/fs/nfsd/nfs4xdr.c
5869 ++++ b/fs/nfsd/nfs4xdr.c
5870 +@@ -1586,6 +1586,8 @@ nfsd4_decode_getdeviceinfo(struct nfsd4_compoundargs *argp,
5871 + gdev->gd_maxcount = be32_to_cpup(p++);
5872 + num = be32_to_cpup(p++);
5873 + if (num) {
5874 ++ if (num > 1000)
5875 ++ goto xdr_error;
5876 + READ_BUF(4 * num);
5877 + gdev->gd_notify_types = be32_to_cpup(p++);
5878 + for (i = 1; i < num; i++) {
5879 +diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
5880 +index b8f8d666e8d4..ba20393d60ef 100644
5881 +--- a/fs/overlayfs/super.c
5882 ++++ b/fs/overlayfs/super.c
5883 +@@ -232,6 +232,7 @@ static void ovl_put_super(struct super_block *sb)
5884 + kfree(ufs);
5885 + }
5886 +
5887 ++/* Sync real dirty inodes in upper filesystem (if it exists) */
5888 + static int ovl_sync_fs(struct super_block *sb, int wait)
5889 + {
5890 + struct ovl_fs *ufs = sb->s_fs_info;
5891 +@@ -240,14 +241,24 @@ static int ovl_sync_fs(struct super_block *sb, int wait)
5892 +
5893 + if (!ufs->upper_mnt)
5894 + return 0;
5895 +- upper_sb = ufs->upper_mnt->mnt_sb;
5896 +- if (!upper_sb->s_op->sync_fs)
5897 ++
5898 ++ /*
5899 ++ * If this is a sync(2) call or an emergency sync, all the super blocks
5900 ++ * will be iterated, including upper_sb, so no need to do anything.
5901 ++ *
5902 ++ * If this is a syncfs(2) call, then we do need to call
5903 ++ * sync_filesystem() on upper_sb, but enough if we do it when being
5904 ++ * called with wait == 1.
5905 ++ */
5906 ++ if (!wait)
5907 + return 0;
5908 +
5909 +- /* real inodes have already been synced by sync_filesystem(ovl_sb) */
5910 ++ upper_sb = ufs->upper_mnt->mnt_sb;
5911 ++
5912 + down_read(&upper_sb->s_umount);
5913 +- ret = upper_sb->s_op->sync_fs(upper_sb, wait);
5914 ++ ret = sync_filesystem(upper_sb);
5915 + up_read(&upper_sb->s_umount);
5916 ++
5917 + return ret;
5918 + }
5919 +
5920 +diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
5921 +index 6f337fff38c4..519522d39bde 100644
5922 +--- a/fs/proc/task_mmu.c
5923 ++++ b/fs/proc/task_mmu.c
5924 +@@ -1275,8 +1275,9 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm,
5925 + if (pte_swp_soft_dirty(pte))
5926 + flags |= PM_SOFT_DIRTY;
5927 + entry = pte_to_swp_entry(pte);
5928 +- frame = swp_type(entry) |
5929 +- (swp_offset(entry) << MAX_SWAPFILES_SHIFT);
5930 ++ if (pm->show_pfn)
5931 ++ frame = swp_type(entry) |
5932 ++ (swp_offset(entry) << MAX_SWAPFILES_SHIFT);
5933 + flags |= PM_SWAP;
5934 + if (is_migration_entry(entry))
5935 + page = migration_entry_to_page(entry);
5936 +@@ -1327,11 +1328,14 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
5937 + #ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
5938 + else if (is_swap_pmd(pmd)) {
5939 + swp_entry_t entry = pmd_to_swp_entry(pmd);
5940 +- unsigned long offset = swp_offset(entry);
5941 ++ unsigned long offset;
5942 +
5943 +- offset += (addr & ~PMD_MASK) >> PAGE_SHIFT;
5944 +- frame = swp_type(entry) |
5945 +- (offset << MAX_SWAPFILES_SHIFT);
5946 ++ if (pm->show_pfn) {
5947 ++ offset = swp_offset(entry) +
5948 ++ ((addr & ~PMD_MASK) >> PAGE_SHIFT);
5949 ++ frame = swp_type(entry) |
5950 ++ (offset << MAX_SWAPFILES_SHIFT);
5951 ++ }
5952 + flags |= PM_SWAP;
5953 + if (pmd_swp_soft_dirty(pmd))
5954 + flags |= PM_SOFT_DIRTY;
5955 +@@ -1349,10 +1353,12 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
5956 + err = add_to_pagemap(addr, &pme, pm);
5957 + if (err)
5958 + break;
5959 +- if (pm->show_pfn && (flags & PM_PRESENT))
5960 +- frame++;
5961 +- else if (flags & PM_SWAP)
5962 +- frame += (1 << MAX_SWAPFILES_SHIFT);
5963 ++ if (pm->show_pfn) {
5964 ++ if (flags & PM_PRESENT)
5965 ++ frame++;
5966 ++ else if (flags & PM_SWAP)
5967 ++ frame += (1 << MAX_SWAPFILES_SHIFT);
5968 ++ }
5969 + }
5970 + spin_unlock(ptl);
5971 + return err;
5972 +diff --git a/fs/squashfs/cache.c b/fs/squashfs/cache.c
5973 +index 23813c078cc9..0839efa720b3 100644
5974 +--- a/fs/squashfs/cache.c
5975 ++++ b/fs/squashfs/cache.c
5976 +@@ -350,6 +350,9 @@ int squashfs_read_metadata(struct super_block *sb, void *buffer,
5977 +
5978 + TRACE("Entered squashfs_read_metadata [%llx:%x]\n", *block, *offset);
5979 +
5980 ++ if (unlikely(length < 0))
5981 ++ return -EIO;
5982 ++
5983 + while (length) {
5984 + entry = squashfs_cache_get(sb, msblk->block_cache, *block, 0);
5985 + if (entry->error) {
5986 +diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
5987 +index 13d80947bf9e..fcff2e0487fe 100644
5988 +--- a/fs/squashfs/file.c
5989 ++++ b/fs/squashfs/file.c
5990 +@@ -194,7 +194,11 @@ static long long read_indexes(struct super_block *sb, int n,
5991 + }
5992 +
5993 + for (i = 0; i < blocks; i++) {
5994 +- int size = le32_to_cpu(blist[i]);
5995 ++ int size = squashfs_block_size(blist[i]);
5996 ++ if (size < 0) {
5997 ++ err = size;
5998 ++ goto failure;
5999 ++ }
6000 + block += SQUASHFS_COMPRESSED_SIZE_BLOCK(size);
6001 + }
6002 + n -= blocks;
6003 +@@ -367,7 +371,7 @@ static int read_blocklist(struct inode *inode, int index, u64 *block)
6004 + sizeof(size));
6005 + if (res < 0)
6006 + return res;
6007 +- return le32_to_cpu(size);
6008 ++ return squashfs_block_size(size);
6009 + }
6010 +
6011 + /* Copy data into page cache */
6012 +diff --git a/fs/squashfs/fragment.c b/fs/squashfs/fragment.c
6013 +index 0ed6edbc5c71..86ad9a4b8c36 100644
6014 +--- a/fs/squashfs/fragment.c
6015 ++++ b/fs/squashfs/fragment.c
6016 +@@ -61,9 +61,7 @@ int squashfs_frag_lookup(struct super_block *sb, unsigned int fragment,
6017 + return size;
6018 +
6019 + *fragment_block = le64_to_cpu(fragment_entry.start_block);
6020 +- size = le32_to_cpu(fragment_entry.size);
6021 +-
6022 +- return size;
6023 ++ return squashfs_block_size(fragment_entry.size);
6024 + }
6025 +
6026 +
6027 +diff --git a/fs/squashfs/squashfs_fs.h b/fs/squashfs/squashfs_fs.h
6028 +index 24d12fd14177..4e6853f084d0 100644
6029 +--- a/fs/squashfs/squashfs_fs.h
6030 ++++ b/fs/squashfs/squashfs_fs.h
6031 +@@ -129,6 +129,12 @@
6032 +
6033 + #define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
6034 +
6035 ++static inline int squashfs_block_size(__le32 raw)
6036 ++{
6037 ++ u32 size = le32_to_cpu(raw);
6038 ++ return (size >> 25) ? -EIO : size;
6039 ++}
6040 ++
6041 + /*
6042 + * Inode number ops. Inodes consist of a compressed block number, and an
6043 + * uncompressed offset within that block
6044 +diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
6045 +index b17476a6909c..8fd7cb5297ab 100644
6046 +--- a/include/drm/drm_dp_helper.h
6047 ++++ b/include/drm/drm_dp_helper.h
6048 +@@ -453,6 +453,7 @@
6049 + # define DP_PSR_FRAME_CAPTURE (1 << 3)
6050 + # define DP_PSR_SELECTIVE_UPDATE (1 << 4)
6051 + # define DP_PSR_IRQ_HPD_WITH_CRC_ERRORS (1 << 5)
6052 ++# define DP_PSR_ENABLE_PSR2 (1 << 6) /* eDP 1.4a */
6053 +
6054 + #define DP_ADAPTER_CTRL 0x1a0
6055 + # define DP_ADAPTER_CTRL_FORCE_LOAD_SENSE (1 << 0)
6056 +diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
6057 +index 5e335b6203f4..31c865d1842e 100644
6058 +--- a/include/linux/delayacct.h
6059 ++++ b/include/linux/delayacct.h
6060 +@@ -29,7 +29,7 @@
6061 +
6062 + #ifdef CONFIG_TASK_DELAY_ACCT
6063 + struct task_delay_info {
6064 +- spinlock_t lock;
6065 ++ raw_spinlock_t lock;
6066 + unsigned int flags; /* Private per-task flags */
6067 +
6068 + /* For each stat XXX, add following, aligned appropriately
6069 +@@ -124,7 +124,7 @@ static inline void delayacct_blkio_start(void)
6070 +
6071 + static inline void delayacct_blkio_end(struct task_struct *p)
6072 + {
6073 +- if (current->delays)
6074 ++ if (p->delays)
6075 + __delayacct_blkio_end(p);
6076 + delayacct_clear_flag(DELAYACCT_PF_BLKIO);
6077 + }
6078 +diff --git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h
6079 +index 92f20832fd28..e8ca5e654277 100644
6080 +--- a/include/linux/dma-iommu.h
6081 ++++ b/include/linux/dma-iommu.h
6082 +@@ -17,6 +17,7 @@
6083 + #define __DMA_IOMMU_H
6084 +
6085 + #ifdef __KERNEL__
6086 ++#include <linux/types.h>
6087 + #include <asm/errno.h>
6088 +
6089 + #ifdef CONFIG_IOMMU_DMA
6090 +diff --git a/include/linux/mmc/sdio_ids.h b/include/linux/mmc/sdio_ids.h
6091 +index cdd66a5fbd5e..0a7abe8a407f 100644
6092 +--- a/include/linux/mmc/sdio_ids.h
6093 ++++ b/include/linux/mmc/sdio_ids.h
6094 +@@ -35,6 +35,7 @@
6095 + #define SDIO_DEVICE_ID_BROADCOM_4335_4339 0x4335
6096 + #define SDIO_DEVICE_ID_BROADCOM_4339 0x4339
6097 + #define SDIO_DEVICE_ID_BROADCOM_43362 0xa962
6098 ++#define SDIO_DEVICE_ID_BROADCOM_43364 0xa9a4
6099 + #define SDIO_DEVICE_ID_BROADCOM_43430 0xa9a6
6100 + #define SDIO_DEVICE_ID_BROADCOM_4345 0x4345
6101 + #define SDIO_DEVICE_ID_BROADCOM_43455 0xa9bf
6102 +diff --git a/include/linux/netfilter/ipset/ip_set_timeout.h b/include/linux/netfilter/ipset/ip_set_timeout.h
6103 +index bfb3531fd88a..7ad8ddf9ca8a 100644
6104 +--- a/include/linux/netfilter/ipset/ip_set_timeout.h
6105 ++++ b/include/linux/netfilter/ipset/ip_set_timeout.h
6106 +@@ -65,8 +65,14 @@ ip_set_timeout_set(unsigned long *timeout, u32 value)
6107 + static inline u32
6108 + ip_set_timeout_get(const unsigned long *timeout)
6109 + {
6110 +- return *timeout == IPSET_ELEM_PERMANENT ? 0 :
6111 +- jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
6112 ++ u32 t;
6113 ++
6114 ++ if (*timeout == IPSET_ELEM_PERMANENT)
6115 ++ return 0;
6116 ++
6117 ++ t = jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
6118 ++ /* Zero value in userspace means no timeout */
6119 ++ return t == 0 ? 1 : t;
6120 + }
6121 +
6122 + #endif /* __KERNEL__ */
6123 +diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
6124 +index df176d7c2b87..25602afd4844 100644
6125 +--- a/include/linux/regulator/consumer.h
6126 ++++ b/include/linux/regulator/consumer.h
6127 +@@ -80,6 +80,7 @@ struct regmap;
6128 + * These modes can be OR'ed together to make up a mask of valid register modes.
6129 + */
6130 +
6131 ++#define REGULATOR_MODE_INVALID 0x0
6132 + #define REGULATOR_MODE_FAST 0x1
6133 + #define REGULATOR_MODE_NORMAL 0x2
6134 + #define REGULATOR_MODE_IDLE 0x4
6135 +diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
6136 +index 74fc82d22310..868b60a79c0b 100644
6137 +--- a/include/linux/serial_core.h
6138 ++++ b/include/linux/serial_core.h
6139 +@@ -348,7 +348,8 @@ struct earlycon_device {
6140 + };
6141 +
6142 + struct earlycon_id {
6143 +- char name[16];
6144 ++ char name[15];
6145 ++ char name_term; /* In case compiler didn't '\0' term name */
6146 + char compatible[128];
6147 + int (*setup)(struct earlycon_device *, const char *options);
6148 + };
6149 +diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
6150 +index 34f053a150a9..cf2862bd134a 100644
6151 +--- a/include/linux/thread_info.h
6152 ++++ b/include/linux/thread_info.h
6153 +@@ -43,11 +43,7 @@ enum {
6154 + #define THREAD_ALIGN THREAD_SIZE
6155 + #endif
6156 +
6157 +-#if IS_ENABLED(CONFIG_DEBUG_STACK_USAGE) || IS_ENABLED(CONFIG_DEBUG_KMEMLEAK)
6158 +-# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_ZERO)
6159 +-#else
6160 +-# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT)
6161 +-#endif
6162 ++#define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_ZERO)
6163 +
6164 + /*
6165 + * flag set/clear/test wrappers
6166 +diff --git a/include/net/tcp.h b/include/net/tcp.h
6167 +index 3173dd12b8cc..686e33ea76e7 100644
6168 +--- a/include/net/tcp.h
6169 ++++ b/include/net/tcp.h
6170 +@@ -372,7 +372,7 @@ ssize_t tcp_splice_read(struct socket *sk, loff_t *ppos,
6171 + struct pipe_inode_info *pipe, size_t len,
6172 + unsigned int flags);
6173 +
6174 +-void tcp_enter_quickack_mode(struct sock *sk);
6175 ++void tcp_enter_quickack_mode(struct sock *sk, unsigned int max_quickacks);
6176 + static inline void tcp_dec_quickack_mode(struct sock *sk,
6177 + const unsigned int pkts)
6178 + {
6179 +diff --git a/include/soc/tegra/mc.h b/include/soc/tegra/mc.h
6180 +index 44202ff897fd..f759e0918037 100644
6181 +--- a/include/soc/tegra/mc.h
6182 ++++ b/include/soc/tegra/mc.h
6183 +@@ -99,6 +99,8 @@ struct tegra_mc_soc {
6184 + u8 client_id_mask;
6185 +
6186 + const struct tegra_smmu_soc *smmu;
6187 ++
6188 ++ u32 intmask;
6189 + };
6190 +
6191 + struct tegra_mc {
6192 +diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
6193 +index 69c37ecbff7e..f3c4b46e39d8 100644
6194 +--- a/include/uapi/sound/asoc.h
6195 ++++ b/include/uapi/sound/asoc.h
6196 +@@ -139,6 +139,11 @@
6197 + #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS (1 << 1)
6198 + #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2)
6199 +
6200 ++/* DAI clock gating */
6201 ++#define SND_SOC_TPLG_DAI_CLK_GATE_UNDEFINED 0
6202 ++#define SND_SOC_TPLG_DAI_CLK_GATE_GATED 1
6203 ++#define SND_SOC_TPLG_DAI_CLK_GATE_CONT 2
6204 ++
6205 + /* DAI physical PCM data formats.
6206 + * Add new formats to the end of the list.
6207 + */
6208 +@@ -160,6 +165,18 @@
6209 + #define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2)
6210 + #define SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP (1 << 3)
6211 +
6212 ++/* DAI topology BCLK parameter
6213 ++ * For the backwards capability, by default codec is bclk master
6214 ++ */
6215 ++#define SND_SOC_TPLG_BCLK_CM 0 /* codec is bclk master */
6216 ++#define SND_SOC_TPLG_BCLK_CS 1 /* codec is bclk slave */
6217 ++
6218 ++/* DAI topology FSYNC parameter
6219 ++ * For the backwards capability, by default codec is fsync master
6220 ++ */
6221 ++#define SND_SOC_TPLG_FSYNC_CM 0 /* codec is fsync master */
6222 ++#define SND_SOC_TPLG_FSYNC_CS 1 /* codec is fsync slave */
6223 ++
6224 + /*
6225 + * Block Header.
6226 + * This header precedes all object and object arrays below.
6227 +@@ -312,11 +329,11 @@ struct snd_soc_tplg_hw_config {
6228 + __le32 size; /* in bytes of this structure */
6229 + __le32 id; /* unique ID - - used to match */
6230 + __le32 fmt; /* SND_SOC_DAI_FORMAT_ format value */
6231 +- __u8 clock_gated; /* 1 if clock can be gated to save power */
6232 ++ __u8 clock_gated; /* SND_SOC_TPLG_DAI_CLK_GATE_ value */
6233 + __u8 invert_bclk; /* 1 for inverted BCLK, 0 for normal */
6234 + __u8 invert_fsync; /* 1 for inverted frame clock, 0 for normal */
6235 +- __u8 bclk_master; /* 1 for master of BCLK, 0 for slave */
6236 +- __u8 fsync_master; /* 1 for master of FSYNC, 0 for slave */
6237 ++ __u8 bclk_master; /* SND_SOC_TPLG_BCLK_ value */
6238 ++ __u8 fsync_master; /* SND_SOC_TPLG_FSYNC_ value */
6239 + __u8 mclk_direction; /* 0 for input, 1 for output */
6240 + __le16 reserved; /* for 32bit alignment */
6241 + __le32 mclk_rate; /* MCLK or SYSCLK freqency in Hz */
6242 +diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
6243 +index 0b0aa5854dac..8dd4063647c2 100644
6244 +--- a/kernel/auditfilter.c
6245 ++++ b/kernel/auditfilter.c
6246 +@@ -407,7 +407,7 @@ static int audit_field_valid(struct audit_entry *entry, struct audit_field *f)
6247 + return -EINVAL;
6248 + break;
6249 + case AUDIT_EXE:
6250 +- if (f->op != Audit_equal)
6251 ++ if (f->op != Audit_not_equal && f->op != Audit_equal)
6252 + return -EINVAL;
6253 + if (entry->rule.listnr != AUDIT_FILTER_EXIT)
6254 + return -EINVAL;
6255 +diff --git a/kernel/auditsc.c b/kernel/auditsc.c
6256 +index ecc23e25c9eb..677053a2fb57 100644
6257 +--- a/kernel/auditsc.c
6258 ++++ b/kernel/auditsc.c
6259 +@@ -471,6 +471,8 @@ static int audit_filter_rules(struct task_struct *tsk,
6260 + break;
6261 + case AUDIT_EXE:
6262 + result = audit_exe_compare(tsk, rule->exe);
6263 ++ if (f->op == Audit_not_equal)
6264 ++ result = !result;
6265 + break;
6266 + case AUDIT_UID:
6267 + result = audit_uid_comparator(cred->uid, f->op, f->uid);
6268 +diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
6269 +index 3ceb269c0ebd..450e2cd31ed6 100644
6270 +--- a/kernel/bpf/verifier.c
6271 ++++ b/kernel/bpf/verifier.c
6272 +@@ -4110,7 +4110,7 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
6273 + /* hold the map. If the program is rejected by verifier,
6274 + * the map will be released by release_maps() or it
6275 + * will be used by the valid program until it's unloaded
6276 +- * and all maps are released in free_bpf_prog_info()
6277 ++ * and all maps are released in free_used_maps()
6278 + */
6279 + map = bpf_map_inc(map, false);
6280 + if (IS_ERR(map)) {
6281 +@@ -4623,7 +4623,7 @@ free_log_buf:
6282 + vfree(log_buf);
6283 + if (!env->prog->aux->used_maps)
6284 + /* if we didn't copy map pointers into bpf_prog_info, release
6285 +- * them now. Otherwise free_bpf_prog_info() will release them.
6286 ++ * them now. Otherwise free_used_maps() will release them.
6287 + */
6288 + release_maps(env);
6289 + *prog = env->prog;
6290 +diff --git a/kernel/delayacct.c b/kernel/delayacct.c
6291 +index e2764d767f18..ca8ac2824f0b 100644
6292 +--- a/kernel/delayacct.c
6293 ++++ b/kernel/delayacct.c
6294 +@@ -44,23 +44,24 @@ void __delayacct_tsk_init(struct task_struct *tsk)
6295 + {
6296 + tsk->delays = kmem_cache_zalloc(delayacct_cache, GFP_KERNEL);
6297 + if (tsk->delays)
6298 +- spin_lock_init(&tsk->delays->lock);
6299 ++ raw_spin_lock_init(&tsk->delays->lock);
6300 + }
6301 +
6302 + /*
6303 + * Finish delay accounting for a statistic using its timestamps (@start),
6304 + * accumalator (@total) and @count
6305 + */
6306 +-static void delayacct_end(spinlock_t *lock, u64 *start, u64 *total, u32 *count)
6307 ++static void delayacct_end(raw_spinlock_t *lock, u64 *start, u64 *total,
6308 ++ u32 *count)
6309 + {
6310 + s64 ns = ktime_get_ns() - *start;
6311 + unsigned long flags;
6312 +
6313 + if (ns > 0) {
6314 +- spin_lock_irqsave(lock, flags);
6315 ++ raw_spin_lock_irqsave(lock, flags);
6316 + *total += ns;
6317 + (*count)++;
6318 +- spin_unlock_irqrestore(lock, flags);
6319 ++ raw_spin_unlock_irqrestore(lock, flags);
6320 + }
6321 + }
6322 +
6323 +@@ -127,7 +128,7 @@ int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
6324 +
6325 + /* zero XXX_total, non-zero XXX_count implies XXX stat overflowed */
6326 +
6327 +- spin_lock_irqsave(&tsk->delays->lock, flags);
6328 ++ raw_spin_lock_irqsave(&tsk->delays->lock, flags);
6329 + tmp = d->blkio_delay_total + tsk->delays->blkio_delay;
6330 + d->blkio_delay_total = (tmp < d->blkio_delay_total) ? 0 : tmp;
6331 + tmp = d->swapin_delay_total + tsk->delays->swapin_delay;
6332 +@@ -137,7 +138,7 @@ int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
6333 + d->blkio_count += tsk->delays->blkio_count;
6334 + d->swapin_count += tsk->delays->swapin_count;
6335 + d->freepages_count += tsk->delays->freepages_count;
6336 +- spin_unlock_irqrestore(&tsk->delays->lock, flags);
6337 ++ raw_spin_unlock_irqrestore(&tsk->delays->lock, flags);
6338 +
6339 + return 0;
6340 + }
6341 +@@ -147,10 +148,10 @@ __u64 __delayacct_blkio_ticks(struct task_struct *tsk)
6342 + __u64 ret;
6343 + unsigned long flags;
6344 +
6345 +- spin_lock_irqsave(&tsk->delays->lock, flags);
6346 ++ raw_spin_lock_irqsave(&tsk->delays->lock, flags);
6347 + ret = nsec_to_clock_t(tsk->delays->blkio_delay +
6348 + tsk->delays->swapin_delay);
6349 +- spin_unlock_irqrestore(&tsk->delays->lock, flags);
6350 ++ raw_spin_unlock_irqrestore(&tsk->delays->lock, flags);
6351 + return ret;
6352 + }
6353 +
6354 +diff --git a/kernel/fork.c b/kernel/fork.c
6355 +index 98c91bd341b4..91907a3701ce 100644
6356 +--- a/kernel/fork.c
6357 ++++ b/kernel/fork.c
6358 +@@ -215,10 +215,9 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
6359 + if (!s)
6360 + continue;
6361 +
6362 +-#ifdef CONFIG_DEBUG_KMEMLEAK
6363 + /* Clear stale pointers from reused stack. */
6364 + memset(s->addr, 0, THREAD_SIZE);
6365 +-#endif
6366 ++
6367 + tsk->stack_vm_area = s;
6368 + return s->addr;
6369 + }
6370 +diff --git a/kernel/hung_task.c b/kernel/hung_task.c
6371 +index 751593ed7c0b..32b479468e4d 100644
6372 +--- a/kernel/hung_task.c
6373 ++++ b/kernel/hung_task.c
6374 +@@ -44,6 +44,7 @@ int __read_mostly sysctl_hung_task_warnings = 10;
6375 +
6376 + static int __read_mostly did_panic;
6377 + static bool hung_task_show_lock;
6378 ++static bool hung_task_call_panic;
6379 +
6380 + static struct task_struct *watchdog_task;
6381 +
6382 +@@ -127,10 +128,8 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
6383 + touch_nmi_watchdog();
6384 +
6385 + if (sysctl_hung_task_panic) {
6386 +- if (hung_task_show_lock)
6387 +- debug_show_all_locks();
6388 +- trigger_all_cpu_backtrace();
6389 +- panic("hung_task: blocked tasks");
6390 ++ hung_task_show_lock = true;
6391 ++ hung_task_call_panic = true;
6392 + }
6393 + }
6394 +
6395 +@@ -193,6 +192,10 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
6396 + rcu_read_unlock();
6397 + if (hung_task_show_lock)
6398 + debug_show_all_locks();
6399 ++ if (hung_task_call_panic) {
6400 ++ trigger_all_cpu_backtrace();
6401 ++ panic("hung_task: blocked tasks");
6402 ++ }
6403 + }
6404 +
6405 + static long hung_timeout_jiffies(unsigned long last_checked,
6406 +diff --git a/kernel/kcov.c b/kernel/kcov.c
6407 +index b11ef6e51f7e..f1e060b04ef6 100644
6408 +--- a/kernel/kcov.c
6409 ++++ b/kernel/kcov.c
6410 +@@ -108,7 +108,8 @@ static void kcov_put(struct kcov *kcov)
6411 +
6412 + void kcov_task_init(struct task_struct *t)
6413 + {
6414 +- t->kcov_mode = KCOV_MODE_DISABLED;
6415 ++ WRITE_ONCE(t->kcov_mode, KCOV_MODE_DISABLED);
6416 ++ barrier();
6417 + t->kcov_size = 0;
6418 + t->kcov_area = NULL;
6419 + t->kcov = NULL;
6420 +diff --git a/kernel/kthread.c b/kernel/kthread.c
6421 +index 1ef8f3a5b072..4e6d85b63201 100644
6422 +--- a/kernel/kthread.c
6423 ++++ b/kernel/kthread.c
6424 +@@ -311,8 +311,14 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
6425 + task = create->result;
6426 + if (!IS_ERR(task)) {
6427 + static const struct sched_param param = { .sched_priority = 0 };
6428 ++ char name[TASK_COMM_LEN];
6429 +
6430 +- vsnprintf(task->comm, sizeof(task->comm), namefmt, args);
6431 ++ /*
6432 ++ * task is already visible to other tasks, so updating
6433 ++ * COMM must be protected.
6434 ++ */
6435 ++ vsnprintf(name, sizeof(name), namefmt, args);
6436 ++ set_task_comm(task, name);
6437 + /*
6438 + * root may have changed our (kthreadd's) priority or CPU mask.
6439 + * The kernel thread should not inherit these properties.
6440 +diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
6441 +index 0685c4499431..c0bc2c89697a 100644
6442 +--- a/kernel/power/suspend.c
6443 ++++ b/kernel/power/suspend.c
6444 +@@ -60,7 +60,7 @@ static const struct platform_s2idle_ops *s2idle_ops;
6445 + static DECLARE_WAIT_QUEUE_HEAD(s2idle_wait_head);
6446 +
6447 + enum s2idle_states __read_mostly s2idle_state;
6448 +-static DEFINE_SPINLOCK(s2idle_lock);
6449 ++static DEFINE_RAW_SPINLOCK(s2idle_lock);
6450 +
6451 + void s2idle_set_ops(const struct platform_s2idle_ops *ops)
6452 + {
6453 +@@ -78,12 +78,12 @@ static void s2idle_enter(void)
6454 + {
6455 + trace_suspend_resume(TPS("machine_suspend"), PM_SUSPEND_TO_IDLE, true);
6456 +
6457 +- spin_lock_irq(&s2idle_lock);
6458 ++ raw_spin_lock_irq(&s2idle_lock);
6459 + if (pm_wakeup_pending())
6460 + goto out;
6461 +
6462 + s2idle_state = S2IDLE_STATE_ENTER;
6463 +- spin_unlock_irq(&s2idle_lock);
6464 ++ raw_spin_unlock_irq(&s2idle_lock);
6465 +
6466 + get_online_cpus();
6467 + cpuidle_resume();
6468 +@@ -97,11 +97,11 @@ static void s2idle_enter(void)
6469 + cpuidle_pause();
6470 + put_online_cpus();
6471 +
6472 +- spin_lock_irq(&s2idle_lock);
6473 ++ raw_spin_lock_irq(&s2idle_lock);
6474 +
6475 + out:
6476 + s2idle_state = S2IDLE_STATE_NONE;
6477 +- spin_unlock_irq(&s2idle_lock);
6478 ++ raw_spin_unlock_irq(&s2idle_lock);
6479 +
6480 + trace_suspend_resume(TPS("machine_suspend"), PM_SUSPEND_TO_IDLE, false);
6481 + }
6482 +@@ -156,12 +156,12 @@ void s2idle_wake(void)
6483 + {
6484 + unsigned long flags;
6485 +
6486 +- spin_lock_irqsave(&s2idle_lock, flags);
6487 ++ raw_spin_lock_irqsave(&s2idle_lock, flags);
6488 + if (s2idle_state > S2IDLE_STATE_NONE) {
6489 + s2idle_state = S2IDLE_STATE_WAKE;
6490 + wake_up(&s2idle_wait_head);
6491 + }
6492 +- spin_unlock_irqrestore(&s2idle_lock, flags);
6493 ++ raw_spin_unlock_irqrestore(&s2idle_lock, flags);
6494 + }
6495 + EXPORT_SYMBOL_GPL(s2idle_wake);
6496 +
6497 +diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
6498 +index d989cc238198..64825b2df3a5 100644
6499 +--- a/kernel/printk/printk_safe.c
6500 ++++ b/kernel/printk/printk_safe.c
6501 +@@ -284,7 +284,7 @@ void printk_safe_flush_on_panic(void)
6502 + * Make sure that we could access the main ring buffer.
6503 + * Do not risk a double release when more CPUs are up.
6504 + */
6505 +- if (in_nmi() && raw_spin_is_locked(&logbuf_lock)) {
6506 ++ if (raw_spin_is_locked(&logbuf_lock)) {
6507 + if (num_online_cpus() > 1)
6508 + return;
6509 +
6510 +diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
6511 +index 2f6fa95de2d8..1ff523dae6e2 100644
6512 +--- a/kernel/stop_machine.c
6513 ++++ b/kernel/stop_machine.c
6514 +@@ -37,7 +37,7 @@ struct cpu_stop_done {
6515 + struct cpu_stopper {
6516 + struct task_struct *thread;
6517 +
6518 +- spinlock_t lock;
6519 ++ raw_spinlock_t lock;
6520 + bool enabled; /* is this stopper enabled? */
6521 + struct list_head works; /* list of pending works */
6522 +
6523 +@@ -81,13 +81,13 @@ static bool cpu_stop_queue_work(unsigned int cpu, struct cpu_stop_work *work)
6524 + unsigned long flags;
6525 + bool enabled;
6526 +
6527 +- spin_lock_irqsave(&stopper->lock, flags);
6528 ++ raw_spin_lock_irqsave(&stopper->lock, flags);
6529 + enabled = stopper->enabled;
6530 + if (enabled)
6531 + __cpu_stop_queue_work(stopper, work, &wakeq);
6532 + else if (work->done)
6533 + cpu_stop_signal_done(work->done);
6534 +- spin_unlock_irqrestore(&stopper->lock, flags);
6535 ++ raw_spin_unlock_irqrestore(&stopper->lock, flags);
6536 +
6537 + wake_up_q(&wakeq);
6538 +
6539 +@@ -237,8 +237,8 @@ static int cpu_stop_queue_two_works(int cpu1, struct cpu_stop_work *work1,
6540 + DEFINE_WAKE_Q(wakeq);
6541 + int err;
6542 + retry:
6543 +- spin_lock_irq(&stopper1->lock);
6544 +- spin_lock_nested(&stopper2->lock, SINGLE_DEPTH_NESTING);
6545 ++ raw_spin_lock_irq(&stopper1->lock);
6546 ++ raw_spin_lock_nested(&stopper2->lock, SINGLE_DEPTH_NESTING);
6547 +
6548 + err = -ENOENT;
6549 + if (!stopper1->enabled || !stopper2->enabled)
6550 +@@ -261,8 +261,8 @@ retry:
6551 + __cpu_stop_queue_work(stopper1, work1, &wakeq);
6552 + __cpu_stop_queue_work(stopper2, work2, &wakeq);
6553 + unlock:
6554 +- spin_unlock(&stopper2->lock);
6555 +- spin_unlock_irq(&stopper1->lock);
6556 ++ raw_spin_unlock(&stopper2->lock);
6557 ++ raw_spin_unlock_irq(&stopper1->lock);
6558 +
6559 + if (unlikely(err == -EDEADLK)) {
6560 + while (stop_cpus_in_progress)
6561 +@@ -461,9 +461,9 @@ static int cpu_stop_should_run(unsigned int cpu)
6562 + unsigned long flags;
6563 + int run;
6564 +
6565 +- spin_lock_irqsave(&stopper->lock, flags);
6566 ++ raw_spin_lock_irqsave(&stopper->lock, flags);
6567 + run = !list_empty(&stopper->works);
6568 +- spin_unlock_irqrestore(&stopper->lock, flags);
6569 ++ raw_spin_unlock_irqrestore(&stopper->lock, flags);
6570 + return run;
6571 + }
6572 +
6573 +@@ -474,13 +474,13 @@ static void cpu_stopper_thread(unsigned int cpu)
6574 +
6575 + repeat:
6576 + work = NULL;
6577 +- spin_lock_irq(&stopper->lock);
6578 ++ raw_spin_lock_irq(&stopper->lock);
6579 + if (!list_empty(&stopper->works)) {
6580 + work = list_first_entry(&stopper->works,
6581 + struct cpu_stop_work, list);
6582 + list_del_init(&work->list);
6583 + }
6584 +- spin_unlock_irq(&stopper->lock);
6585 ++ raw_spin_unlock_irq(&stopper->lock);
6586 +
6587 + if (work) {
6588 + cpu_stop_fn_t fn = work->fn;
6589 +@@ -554,7 +554,7 @@ static int __init cpu_stop_init(void)
6590 + for_each_possible_cpu(cpu) {
6591 + struct cpu_stopper *stopper = &per_cpu(cpu_stopper, cpu);
6592 +
6593 +- spin_lock_init(&stopper->lock);
6594 ++ raw_spin_lock_init(&stopper->lock);
6595 + INIT_LIST_HEAD(&stopper->works);
6596 + }
6597 +
6598 +diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
6599 +index b413fab7d75b..43254c5e7e16 100644
6600 +--- a/kernel/trace/trace_events_trigger.c
6601 ++++ b/kernel/trace/trace_events_trigger.c
6602 +@@ -680,6 +680,8 @@ event_trigger_callback(struct event_command *cmd_ops,
6603 + goto out_free;
6604 +
6605 + out_reg:
6606 ++ /* Up the trigger_data count to make sure reg doesn't free it on failure */
6607 ++ event_trigger_init(trigger_ops, trigger_data);
6608 + ret = cmd_ops->reg(glob, trigger_ops, trigger_data, file);
6609 + /*
6610 + * The above returns on success the # of functions enabled,
6611 +@@ -687,11 +689,13 @@ event_trigger_callback(struct event_command *cmd_ops,
6612 + * Consider no functions a failure too.
6613 + */
6614 + if (!ret) {
6615 ++ cmd_ops->unreg(glob, trigger_ops, trigger_data, file);
6616 + ret = -ENOENT;
6617 +- goto out_free;
6618 +- } else if (ret < 0)
6619 +- goto out_free;
6620 +- ret = 0;
6621 ++ } else if (ret > 0)
6622 ++ ret = 0;
6623 ++
6624 ++ /* Down the counter of trigger_data or free it if not used anymore */
6625 ++ event_trigger_free(trigger_ops, trigger_data);
6626 + out:
6627 + return ret;
6628 +
6629 +@@ -1392,6 +1396,9 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
6630 + goto out;
6631 + }
6632 +
6633 ++ /* Up the trigger_data count to make sure nothing frees it on failure */
6634 ++ event_trigger_init(trigger_ops, trigger_data);
6635 ++
6636 + if (trigger) {
6637 + number = strsep(&trigger, ":");
6638 +
6639 +@@ -1442,6 +1449,7 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
6640 + goto out_disable;
6641 + /* Just return zero, not the number of enabled functions */
6642 + ret = 0;
6643 ++ event_trigger_free(trigger_ops, trigger_data);
6644 + out:
6645 + return ret;
6646 +
6647 +@@ -1452,7 +1460,7 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
6648 + out_free:
6649 + if (cmd_ops->set_filter)
6650 + cmd_ops->set_filter(NULL, trigger_data, NULL);
6651 +- kfree(trigger_data);
6652 ++ event_trigger_free(trigger_ops, trigger_data);
6653 + kfree(enable_data);
6654 + goto out;
6655 + }
6656 +diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
6657 +index f8d3bd974bcc..ea20274a105a 100644
6658 +--- a/kernel/trace/trace_kprobe.c
6659 ++++ b/kernel/trace/trace_kprobe.c
6660 +@@ -376,11 +376,10 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
6661 + static int
6662 + enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
6663 + {
6664 ++ struct event_file_link *link = NULL;
6665 + int ret = 0;
6666 +
6667 + if (file) {
6668 +- struct event_file_link *link;
6669 +-
6670 + link = kmalloc(sizeof(*link), GFP_KERNEL);
6671 + if (!link) {
6672 + ret = -ENOMEM;
6673 +@@ -400,6 +399,18 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
6674 + else
6675 + ret = enable_kprobe(&tk->rp.kp);
6676 + }
6677 ++
6678 ++ if (ret) {
6679 ++ if (file) {
6680 ++ /* Notice the if is true on not WARN() */
6681 ++ if (!WARN_ON_ONCE(!link))
6682 ++ list_del_rcu(&link->list);
6683 ++ kfree(link);
6684 ++ tk->tp.flags &= ~TP_FLAG_TRACE;
6685 ++ } else {
6686 ++ tk->tp.flags &= ~TP_FLAG_PROFILE;
6687 ++ }
6688 ++ }
6689 + out:
6690 + return ret;
6691 + }
6692 +diff --git a/mm/slub.c b/mm/slub.c
6693 +index c38e71cea6d3..10e54c4acd19 100644
6694 +--- a/mm/slub.c
6695 ++++ b/mm/slub.c
6696 +@@ -708,7 +708,7 @@ void object_err(struct kmem_cache *s, struct page *page,
6697 + print_trailer(s, page, object);
6698 + }
6699 +
6700 +-static void slab_err(struct kmem_cache *s, struct page *page,
6701 ++static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page,
6702 + const char *fmt, ...)
6703 + {
6704 + va_list args;
6705 +diff --git a/mm/vmalloc.c b/mm/vmalloc.c
6706 +index ebff729cc956..9ff21a12ea00 100644
6707 +--- a/mm/vmalloc.c
6708 ++++ b/mm/vmalloc.c
6709 +@@ -1519,7 +1519,7 @@ static void __vunmap(const void *addr, int deallocate_pages)
6710 + addr))
6711 + return;
6712 +
6713 +- area = remove_vm_area(addr);
6714 ++ area = find_vmap_area((unsigned long)addr)->vm;
6715 + if (unlikely(!area)) {
6716 + WARN(1, KERN_ERR "Trying to vfree() nonexistent vm area (%p)\n",
6717 + addr);
6718 +@@ -1529,6 +1529,7 @@ static void __vunmap(const void *addr, int deallocate_pages)
6719 + debug_check_no_locks_freed(addr, get_vm_area_size(area));
6720 + debug_check_no_obj_freed(addr, get_vm_area_size(area));
6721 +
6722 ++ remove_vm_area(addr);
6723 + if (deallocate_pages) {
6724 + int i;
6725 +
6726 +diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
6727 +index 67eebcb113f3..5bbdd05d0cd3 100644
6728 +--- a/net/ipv4/fib_frontend.c
6729 ++++ b/net/ipv4/fib_frontend.c
6730 +@@ -282,19 +282,19 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
6731 + return ip_hdr(skb)->daddr;
6732 +
6733 + in_dev = __in_dev_get_rcu(dev);
6734 +- BUG_ON(!in_dev);
6735 +
6736 + net = dev_net(dev);
6737 +
6738 + scope = RT_SCOPE_UNIVERSE;
6739 + if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) {
6740 ++ bool vmark = in_dev && IN_DEV_SRC_VMARK(in_dev);
6741 + struct flowi4 fl4 = {
6742 + .flowi4_iif = LOOPBACK_IFINDEX,
6743 + .flowi4_oif = l3mdev_master_ifindex_rcu(dev),
6744 + .daddr = ip_hdr(skb)->saddr,
6745 + .flowi4_tos = RT_TOS(ip_hdr(skb)->tos),
6746 + .flowi4_scope = scope,
6747 +- .flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0,
6748 ++ .flowi4_mark = vmark ? skb->mark : 0,
6749 + };
6750 + if (!fib_lookup(net, &fl4, &res, 0))
6751 + return FIB_RES_PREFSRC(net, res);
6752 +diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
6753 +index abdebca848c9..f0782c91514c 100644
6754 +--- a/net/ipv4/ipconfig.c
6755 ++++ b/net/ipv4/ipconfig.c
6756 +@@ -781,6 +781,11 @@ static void __init ic_bootp_init_ext(u8 *e)
6757 + */
6758 + static inline void __init ic_bootp_init(void)
6759 + {
6760 ++ /* Re-initialise all name servers to NONE, in case any were set via the
6761 ++ * "ip=" or "nfsaddrs=" kernel command line parameters: any IP addresses
6762 ++ * specified there will already have been decoded but are no longer
6763 ++ * needed
6764 ++ */
6765 + ic_nameservers_predef();
6766 +
6767 + dev_add_pack(&bootp_packet_type);
6768 +@@ -1402,6 +1407,13 @@ static int __init ip_auto_config(void)
6769 + int err;
6770 + unsigned int i;
6771 +
6772 ++ /* Initialise all name servers to NONE (but only if the "ip=" or
6773 ++ * "nfsaddrs=" kernel command line parameters weren't decoded, otherwise
6774 ++ * we'll overwrite the IP addresses specified there)
6775 ++ */
6776 ++ if (ic_set_manually == 0)
6777 ++ ic_nameservers_predef();
6778 ++
6779 + #ifdef CONFIG_PROC_FS
6780 + proc_create("pnp", S_IRUGO, init_net.proc_net, &pnp_seq_fops);
6781 + #endif /* CONFIG_PROC_FS */
6782 +@@ -1622,6 +1634,7 @@ static int __init ip_auto_config_setup(char *addrs)
6783 + return 1;
6784 + }
6785 +
6786 ++ /* Initialise all name servers to NONE */
6787 + ic_nameservers_predef();
6788 +
6789 + /* Parse string for static IP assignment. */
6790 +diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c
6791 +index 9a0b952dd09b..06f247ca9197 100644
6792 +--- a/net/ipv4/tcp_bbr.c
6793 ++++ b/net/ipv4/tcp_bbr.c
6794 +@@ -353,6 +353,10 @@ static u32 bbr_target_cwnd(struct sock *sk, u32 bw, int gain)
6795 + /* Reduce delayed ACKs by rounding up cwnd to the next even number. */
6796 + cwnd = (cwnd + 1) & ~1U;
6797 +
6798 ++ /* Ensure gain cycling gets inflight above BDP even for small BDPs. */
6799 ++ if (bbr->mode == BBR_PROBE_BW && gain > BBR_UNIT)
6800 ++ cwnd += 2;
6801 ++
6802 + return cwnd;
6803 + }
6804 +
6805 +diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
6806 +index c78fb53988a1..1a9b88c8cf72 100644
6807 +--- a/net/ipv4/tcp_dctcp.c
6808 ++++ b/net/ipv4/tcp_dctcp.c
6809 +@@ -138,7 +138,7 @@ static void dctcp_ce_state_0_to_1(struct sock *sk)
6810 + */
6811 + if (inet_csk(sk)->icsk_ack.pending & ICSK_ACK_TIMER)
6812 + __tcp_send_ack(sk, ca->prior_rcv_nxt);
6813 +- tcp_enter_quickack_mode(sk);
6814 ++ tcp_enter_quickack_mode(sk, 1);
6815 + }
6816 +
6817 + ca->prior_rcv_nxt = tp->rcv_nxt;
6818 +@@ -159,7 +159,7 @@ static void dctcp_ce_state_1_to_0(struct sock *sk)
6819 + */
6820 + if (inet_csk(sk)->icsk_ack.pending & ICSK_ACK_TIMER)
6821 + __tcp_send_ack(sk, ca->prior_rcv_nxt);
6822 +- tcp_enter_quickack_mode(sk);
6823 ++ tcp_enter_quickack_mode(sk, 1);
6824 + }
6825 +
6826 + ca->prior_rcv_nxt = tp->rcv_nxt;
6827 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
6828 +index b86e7b8beb1d..bdabd748f4bc 100644
6829 +--- a/net/ipv4/tcp_input.c
6830 ++++ b/net/ipv4/tcp_input.c
6831 +@@ -198,21 +198,23 @@ static void tcp_measure_rcv_mss(struct sock *sk, const struct sk_buff *skb)
6832 + }
6833 + }
6834 +
6835 +-static void tcp_incr_quickack(struct sock *sk)
6836 ++static void tcp_incr_quickack(struct sock *sk, unsigned int max_quickacks)
6837 + {
6838 + struct inet_connection_sock *icsk = inet_csk(sk);
6839 + unsigned int quickacks = tcp_sk(sk)->rcv_wnd / (2 * icsk->icsk_ack.rcv_mss);
6840 +
6841 + if (quickacks == 0)
6842 + quickacks = 2;
6843 ++ quickacks = min(quickacks, max_quickacks);
6844 + if (quickacks > icsk->icsk_ack.quick)
6845 +- icsk->icsk_ack.quick = min(quickacks, TCP_MAX_QUICKACKS);
6846 ++ icsk->icsk_ack.quick = quickacks;
6847 + }
6848 +
6849 +-void tcp_enter_quickack_mode(struct sock *sk)
6850 ++void tcp_enter_quickack_mode(struct sock *sk, unsigned int max_quickacks)
6851 + {
6852 + struct inet_connection_sock *icsk = inet_csk(sk);
6853 +- tcp_incr_quickack(sk);
6854 ++
6855 ++ tcp_incr_quickack(sk, max_quickacks);
6856 + icsk->icsk_ack.pingpong = 0;
6857 + icsk->icsk_ack.ato = TCP_ATO_MIN;
6858 + }
6859 +@@ -248,8 +250,10 @@ static void tcp_ecn_withdraw_cwr(struct tcp_sock *tp)
6860 + tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
6861 + }
6862 +
6863 +-static void __tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb)
6864 ++static void __tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
6865 + {
6866 ++ struct tcp_sock *tp = tcp_sk(sk);
6867 ++
6868 + switch (TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK) {
6869 + case INET_ECN_NOT_ECT:
6870 + /* Funny extension: if ECT is not set on a segment,
6871 +@@ -257,31 +261,31 @@ static void __tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb)
6872 + * it is probably a retransmit.
6873 + */
6874 + if (tp->ecn_flags & TCP_ECN_SEEN)
6875 +- tcp_enter_quickack_mode((struct sock *)tp);
6876 ++ tcp_enter_quickack_mode(sk, 2);
6877 + break;
6878 + case INET_ECN_CE:
6879 +- if (tcp_ca_needs_ecn((struct sock *)tp))
6880 +- tcp_ca_event((struct sock *)tp, CA_EVENT_ECN_IS_CE);
6881 ++ if (tcp_ca_needs_ecn(sk))
6882 ++ tcp_ca_event(sk, CA_EVENT_ECN_IS_CE);
6883 +
6884 + if (!(tp->ecn_flags & TCP_ECN_DEMAND_CWR)) {
6885 + /* Better not delay acks, sender can have a very low cwnd */
6886 +- tcp_enter_quickack_mode((struct sock *)tp);
6887 ++ tcp_enter_quickack_mode(sk, 2);
6888 + tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
6889 + }
6890 + tp->ecn_flags |= TCP_ECN_SEEN;
6891 + break;
6892 + default:
6893 +- if (tcp_ca_needs_ecn((struct sock *)tp))
6894 +- tcp_ca_event((struct sock *)tp, CA_EVENT_ECN_NO_CE);
6895 ++ if (tcp_ca_needs_ecn(sk))
6896 ++ tcp_ca_event(sk, CA_EVENT_ECN_NO_CE);
6897 + tp->ecn_flags |= TCP_ECN_SEEN;
6898 + break;
6899 + }
6900 + }
6901 +
6902 +-static void tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb)
6903 ++static void tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
6904 + {
6905 +- if (tp->ecn_flags & TCP_ECN_OK)
6906 +- __tcp_ecn_check_ce(tp, skb);
6907 ++ if (tcp_sk(sk)->ecn_flags & TCP_ECN_OK)
6908 ++ __tcp_ecn_check_ce(sk, skb);
6909 + }
6910 +
6911 + static void tcp_ecn_rcv_synack(struct tcp_sock *tp, const struct tcphdr *th)
6912 +@@ -686,7 +690,7 @@ static void tcp_event_data_recv(struct sock *sk, struct sk_buff *skb)
6913 + /* The _first_ data packet received, initialize
6914 + * delayed ACK engine.
6915 + */
6916 +- tcp_incr_quickack(sk);
6917 ++ tcp_incr_quickack(sk, TCP_MAX_QUICKACKS);
6918 + icsk->icsk_ack.ato = TCP_ATO_MIN;
6919 + } else {
6920 + int m = now - icsk->icsk_ack.lrcvtime;
6921 +@@ -702,13 +706,13 @@ static void tcp_event_data_recv(struct sock *sk, struct sk_buff *skb)
6922 + /* Too long gap. Apparently sender failed to
6923 + * restart window, so that we send ACKs quickly.
6924 + */
6925 +- tcp_incr_quickack(sk);
6926 ++ tcp_incr_quickack(sk, TCP_MAX_QUICKACKS);
6927 + sk_mem_reclaim(sk);
6928 + }
6929 + }
6930 + icsk->icsk_ack.lrcvtime = now;
6931 +
6932 +- tcp_ecn_check_ce(tp, skb);
6933 ++ tcp_ecn_check_ce(sk, skb);
6934 +
6935 + if (skb->len >= 128)
6936 + tcp_grow_window(sk, skb);
6937 +@@ -4160,7 +4164,7 @@ static void tcp_send_dupack(struct sock *sk, const struct sk_buff *skb)
6938 + if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
6939 + before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
6940 + NET_INC_STATS(sock_net(sk), LINUX_MIB_DELAYEDACKLOST);
6941 +- tcp_enter_quickack_mode(sk);
6942 ++ tcp_enter_quickack_mode(sk, TCP_MAX_QUICKACKS);
6943 +
6944 + if (tcp_is_sack(tp) && sysctl_tcp_dsack) {
6945 + u32 end_seq = TCP_SKB_CB(skb)->end_seq;
6946 +@@ -4441,7 +4445,7 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb)
6947 + u32 seq, end_seq;
6948 + bool fragstolen;
6949 +
6950 +- tcp_ecn_check_ce(tp, skb);
6951 ++ tcp_ecn_check_ce(sk, skb);
6952 +
6953 + if (unlikely(tcp_try_rmem_schedule(sk, skb, skb->truesize))) {
6954 + NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFODROP);
6955 +@@ -4710,7 +4714,7 @@ queue_and_out:
6956 + tcp_dsack_set(sk, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq);
6957 +
6958 + out_of_window:
6959 +- tcp_enter_quickack_mode(sk);
6960 ++ tcp_enter_quickack_mode(sk, TCP_MAX_QUICKACKS);
6961 + inet_csk_schedule_ack(sk);
6962 + drop:
6963 + tcp_drop(sk, skb);
6964 +@@ -4721,8 +4725,6 @@ drop:
6965 + if (!before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt + tcp_receive_window(tp)))
6966 + goto out_of_window;
6967 +
6968 +- tcp_enter_quickack_mode(sk);
6969 +-
6970 + if (before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
6971 + /* Partial packet, seq < rcv_next < end_seq */
6972 + SOCK_DEBUG(sk, "partial packet: rcv_next %X seq %X - %X\n",
6973 +@@ -5793,7 +5795,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
6974 + * to stand against the temptation 8) --ANK
6975 + */
6976 + inet_csk_schedule_ack(sk);
6977 +- tcp_enter_quickack_mode(sk);
6978 ++ tcp_enter_quickack_mode(sk, TCP_MAX_QUICKACKS);
6979 + inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
6980 + TCP_DELACK_MAX, TCP_RTO_MAX);
6981 +
6982 +diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
6983 +index 51063d9ed0f7..dfd268166e42 100644
6984 +--- a/net/netfilter/ipset/ip_set_hash_gen.h
6985 ++++ b/net/netfilter/ipset/ip_set_hash_gen.h
6986 +@@ -1241,7 +1241,10 @@ IPSET_TOKEN(HTYPE, _create)(struct net *net, struct ip_set *set,
6987 + pr_debug("Create set %s with family %s\n",
6988 + set->name, set->family == NFPROTO_IPV4 ? "inet" : "inet6");
6989 +
6990 +-#ifndef IP_SET_PROTO_UNDEF
6991 ++#ifdef IP_SET_PROTO_UNDEF
6992 ++ if (set->family != NFPROTO_UNSPEC)
6993 ++ return -IPSET_ERR_INVALID_FAMILY;
6994 ++#else
6995 + if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6))
6996 + return -IPSET_ERR_INVALID_FAMILY;
6997 + #endif
6998 +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
6999 +index 85b549e84104..9a945024a0b6 100644
7000 +--- a/net/netfilter/nf_tables_api.c
7001 ++++ b/net/netfilter/nf_tables_api.c
7002 +@@ -2710,12 +2710,13 @@ static struct nft_set *nf_tables_set_lookup_byid(const struct net *net,
7003 + u32 id = ntohl(nla_get_be32(nla));
7004 +
7005 + list_for_each_entry(trans, &net->nft.commit_list, list) {
7006 +- struct nft_set *set = nft_trans_set(trans);
7007 ++ if (trans->msg_type == NFT_MSG_NEWSET) {
7008 ++ struct nft_set *set = nft_trans_set(trans);
7009 +
7010 +- if (trans->msg_type == NFT_MSG_NEWSET &&
7011 +- id == nft_trans_set_id(trans) &&
7012 +- nft_active_genmask(set, genmask))
7013 +- return set;
7014 ++ if (id == nft_trans_set_id(trans) &&
7015 ++ nft_active_genmask(set, genmask))
7016 ++ return set;
7017 ++ }
7018 + }
7019 + return ERR_PTR(-ENOENT);
7020 + }
7021 +diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
7022 +index b3932846f6c4..b2fcbf012056 100644
7023 +--- a/net/netlink/af_netlink.c
7024 ++++ b/net/netlink/af_netlink.c
7025 +@@ -977,6 +977,11 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
7026 + return err;
7027 + }
7028 +
7029 ++ if (nlk->ngroups == 0)
7030 ++ groups = 0;
7031 ++ else
7032 ++ groups &= (1ULL << nlk->ngroups) - 1;
7033 ++
7034 + bound = nlk->bound;
7035 + if (bound) {
7036 + /* Ensure nlk->portid is up-to-date. */
7037 +diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
7038 +index 7e334fd31c15..f8553179bdd7 100644
7039 +--- a/security/integrity/ima/ima_main.c
7040 ++++ b/security/integrity/ima/ima_main.c
7041 +@@ -379,6 +379,7 @@ int ima_read_file(struct file *file, enum kernel_read_file_id read_id)
7042 +
7043 + static int read_idmap[READING_MAX_ID] = {
7044 + [READING_FIRMWARE] = FIRMWARE_CHECK,
7045 ++ [READING_FIRMWARE_PREALLOC_BUFFER] = FIRMWARE_CHECK,
7046 + [READING_MODULE] = MODULE_CHECK,
7047 + [READING_KEXEC_IMAGE] = KEXEC_KERNEL_CHECK,
7048 + [READING_KEXEC_INITRAMFS] = KEXEC_INITRAMFS_CHECK,
7049 +diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
7050 +index 2683b9717215..56be1630bd3e 100644
7051 +--- a/sound/pci/emu10k1/emupcm.c
7052 ++++ b/sound/pci/emu10k1/emupcm.c
7053 +@@ -1850,7 +1850,9 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device)
7054 + if (!kctl)
7055 + return -ENOMEM;
7056 + kctl->id.device = device;
7057 +- snd_ctl_add(emu->card, kctl);
7058 ++ err = snd_ctl_add(emu->card, kctl);
7059 ++ if (err < 0)
7060 ++ return err;
7061 +
7062 + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024);
7063 +
7064 +diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c
7065 +index 4f1f69be1865..8c778fa33031 100644
7066 +--- a/sound/pci/emu10k1/memory.c
7067 ++++ b/sound/pci/emu10k1/memory.c
7068 +@@ -237,13 +237,13 @@ __found_pages:
7069 + static int is_valid_page(struct snd_emu10k1 *emu, dma_addr_t addr)
7070 + {
7071 + if (addr & ~emu->dma_mask) {
7072 +- dev_err(emu->card->dev,
7073 ++ dev_err_ratelimited(emu->card->dev,
7074 + "max memory size is 0x%lx (addr = 0x%lx)!!\n",
7075 + emu->dma_mask, (unsigned long)addr);
7076 + return 0;
7077 + }
7078 + if (addr & (EMUPAGESIZE-1)) {
7079 +- dev_err(emu->card->dev, "page is not aligned\n");
7080 ++ dev_err_ratelimited(emu->card->dev, "page is not aligned\n");
7081 + return 0;
7082 + }
7083 + return 1;
7084 +@@ -334,7 +334,7 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst
7085 + else
7086 + addr = snd_pcm_sgbuf_get_addr(substream, ofs);
7087 + if (! is_valid_page(emu, addr)) {
7088 +- dev_err(emu->card->dev,
7089 ++ dev_err_ratelimited(emu->card->dev,
7090 + "emu: failure page = %d\n", idx);
7091 + mutex_unlock(&hdr->block_mutex);
7092 + return NULL;
7093 +diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
7094 +index 73a67bc3586b..e3fb9c61017c 100644
7095 +--- a/sound/pci/fm801.c
7096 ++++ b/sound/pci/fm801.c
7097 +@@ -1068,11 +1068,19 @@ static int snd_fm801_mixer(struct fm801 *chip)
7098 + if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97_sec)) < 0)
7099 + return err;
7100 + }
7101 +- for (i = 0; i < FM801_CONTROLS; i++)
7102 +- snd_ctl_add(chip->card, snd_ctl_new1(&snd_fm801_controls[i], chip));
7103 ++ for (i = 0; i < FM801_CONTROLS; i++) {
7104 ++ err = snd_ctl_add(chip->card,
7105 ++ snd_ctl_new1(&snd_fm801_controls[i], chip));
7106 ++ if (err < 0)
7107 ++ return err;
7108 ++ }
7109 + if (chip->multichannel) {
7110 +- for (i = 0; i < FM801_CONTROLS_MULTI; i++)
7111 +- snd_ctl_add(chip->card, snd_ctl_new1(&snd_fm801_controls_multi[i], chip));
7112 ++ for (i = 0; i < FM801_CONTROLS_MULTI; i++) {
7113 ++ err = snd_ctl_add(chip->card,
7114 ++ snd_ctl_new1(&snd_fm801_controls_multi[i], chip));
7115 ++ if (err < 0)
7116 ++ return err;
7117 ++ }
7118 + }
7119 + return 0;
7120 + }
7121 +diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
7122 +index 3e73d5c6ccfc..119f3b504765 100644
7123 +--- a/sound/pci/hda/patch_ca0132.c
7124 ++++ b/sound/pci/hda/patch_ca0132.c
7125 +@@ -38,6 +38,10 @@
7126 + /* Enable this to see controls for tuning purpose. */
7127 + /*#define ENABLE_TUNING_CONTROLS*/
7128 +
7129 ++#ifdef ENABLE_TUNING_CONTROLS
7130 ++#include <sound/tlv.h>
7131 ++#endif
7132 ++
7133 + #define FLOAT_ZERO 0x00000000
7134 + #define FLOAT_ONE 0x3f800000
7135 + #define FLOAT_TWO 0x40000000
7136 +@@ -3067,8 +3071,8 @@ static int equalizer_ctl_put(struct snd_kcontrol *kcontrol,
7137 + return 1;
7138 + }
7139 +
7140 +-static const DECLARE_TLV_DB_SCALE(voice_focus_db_scale, 2000, 100, 0);
7141 +-static const DECLARE_TLV_DB_SCALE(eq_db_scale, -2400, 100, 0);
7142 ++static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(voice_focus_db_scale, 2000, 100, 0);
7143 ++static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(eq_db_scale, -2400, 100, 0);
7144 +
7145 + static int add_tuning_control(struct hda_codec *codec,
7146 + hda_nid_t pnid, hda_nid_t nid,
7147 +diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
7148 +index 94b88b897c3b..3d0dab8282ad 100644
7149 +--- a/sound/soc/soc-pcm.c
7150 ++++ b/sound/soc/soc-pcm.c
7151 +@@ -1779,8 +1779,10 @@ int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream)
7152 + continue;
7153 +
7154 + if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) &&
7155 +- (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN))
7156 +- continue;
7157 ++ (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN)) {
7158 ++ soc_pcm_hw_free(be_substream);
7159 ++ be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE;
7160 ++ }
7161 +
7162 + dev_dbg(be->dev, "ASoC: close BE %s\n",
7163 + be->dai_link->name);
7164 +diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
7165 +index 30cdad2eab7f..c1619860a5de 100644
7166 +--- a/sound/soc/soc-topology.c
7167 ++++ b/sound/soc/soc-topology.c
7168 +@@ -1997,6 +1997,13 @@ static void set_link_hw_format(struct snd_soc_dai_link *link,
7169 +
7170 + link->dai_fmt = hw_config->fmt & SND_SOC_DAIFMT_FORMAT_MASK;
7171 +
7172 ++ /* clock gating */
7173 ++ if (hw_config->clock_gated == SND_SOC_TPLG_DAI_CLK_GATE_GATED)
7174 ++ link->dai_fmt |= SND_SOC_DAIFMT_GATED;
7175 ++ else if (hw_config->clock_gated ==
7176 ++ SND_SOC_TPLG_DAI_CLK_GATE_CONT)
7177 ++ link->dai_fmt |= SND_SOC_DAIFMT_CONT;
7178 ++
7179 + /* clock signal polarity */
7180 + invert_bclk = hw_config->invert_bclk;
7181 + invert_fsync = hw_config->invert_fsync;
7182 +@@ -2010,13 +2017,15 @@ static void set_link_hw_format(struct snd_soc_dai_link *link,
7183 + link->dai_fmt |= SND_SOC_DAIFMT_IB_IF;
7184 +
7185 + /* clock masters */
7186 +- bclk_master = hw_config->bclk_master;
7187 +- fsync_master = hw_config->fsync_master;
7188 +- if (!bclk_master && !fsync_master)
7189 ++ bclk_master = (hw_config->bclk_master ==
7190 ++ SND_SOC_TPLG_BCLK_CM);
7191 ++ fsync_master = (hw_config->fsync_master ==
7192 ++ SND_SOC_TPLG_FSYNC_CM);
7193 ++ if (bclk_master && fsync_master)
7194 + link->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
7195 +- else if (bclk_master && !fsync_master)
7196 +- link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
7197 + else if (!bclk_master && fsync_master)
7198 ++ link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
7199 ++ else if (bclk_master && !fsync_master)
7200 + link->dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
7201 + else
7202 + link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
7203 +diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
7204 +index 3cbfae6604f9..d8a46d46bcd2 100644
7205 +--- a/sound/usb/pcm.c
7206 ++++ b/sound/usb/pcm.c
7207 +@@ -1311,7 +1311,7 @@ static void retire_capture_urb(struct snd_usb_substream *subs,
7208 + if (bytes % (runtime->sample_bits >> 3) != 0) {
7209 + int oldbytes = bytes;
7210 + bytes = frames * stride;
7211 +- dev_warn(&subs->dev->dev,
7212 ++ dev_warn_ratelimited(&subs->dev->dev,
7213 + "Corrected urb data len. %d->%d\n",
7214 + oldbytes, bytes);
7215 + }
7216 +diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
7217 +index e81a20ea8d7d..988310cd3049 100644
7218 +--- a/tools/perf/util/parse-events.y
7219 ++++ b/tools/perf/util/parse-events.y
7220 +@@ -72,6 +72,7 @@ static void inc_group_count(struct list_head *list,
7221 + %type <num> value_sym
7222 + %type <head> event_config
7223 + %type <head> opt_event_config
7224 ++%type <head> opt_pmu_config
7225 + %type <term> event_term
7226 + %type <head> event_pmu
7227 + %type <head> event_legacy_symbol
7228 +@@ -223,7 +224,7 @@ event_def: event_pmu |
7229 + event_bpf_file
7230 +
7231 + event_pmu:
7232 +-PE_NAME opt_event_config
7233 ++PE_NAME opt_pmu_config
7234 + {
7235 + struct list_head *list, *orig_terms, *terms;
7236 +
7237 +@@ -486,6 +487,17 @@ opt_event_config:
7238 + $$ = NULL;
7239 + }
7240 +
7241 ++opt_pmu_config:
7242 ++'/' event_config '/'
7243 ++{
7244 ++ $$ = $2;
7245 ++}
7246 ++|
7247 ++'/' '/'
7248 ++{
7249 ++ $$ = NULL;
7250 ++}
7251 ++
7252 + start_terms: event_config
7253 + {
7254 + struct parse_events_state *parse_state = _parse_state;
7255 +diff --git a/tools/testing/selftests/intel_pstate/run.sh b/tools/testing/selftests/intel_pstate/run.sh
7256 +index c670359becc6..928978804342 100755
7257 +--- a/tools/testing/selftests/intel_pstate/run.sh
7258 ++++ b/tools/testing/selftests/intel_pstate/run.sh
7259 +@@ -30,9 +30,12 @@
7260 +
7261 + EVALUATE_ONLY=0
7262 +
7263 ++# Kselftest framework requirement - SKIP code is 4.
7264 ++ksft_skip=4
7265 ++
7266 + if ! uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ | grep -q x86; then
7267 + echo "$0 # Skipped: Test can only run on x86 architectures."
7268 +- exit 0
7269 ++ exit $ksft_skip
7270 + fi
7271 +
7272 + max_cpus=$(($(nproc)-1))
7273 +@@ -48,11 +51,12 @@ function run_test () {
7274 +
7275 + echo "sleeping for 5 seconds"
7276 + sleep 5
7277 +- num_freqs=$(cat /proc/cpuinfo | grep MHz | sort -u | wc -l)
7278 +- if [ $num_freqs -le 2 ]; then
7279 +- cat /proc/cpuinfo | grep MHz | sort -u | tail -1 > /tmp/result.$1
7280 ++ grep MHz /proc/cpuinfo | sort -u > /tmp/result.freqs
7281 ++ num_freqs=$(wc -l /tmp/result.freqs | awk ' { print $1 } ')
7282 ++ if [ $num_freqs -ge 2 ]; then
7283 ++ tail -n 1 /tmp/result.freqs > /tmp/result.$1
7284 + else
7285 +- cat /proc/cpuinfo | grep MHz | sort -u > /tmp/result.$1
7286 ++ cp /tmp/result.freqs /tmp/result.$1
7287 + fi
7288 + ./msr 0 >> /tmp/result.$1
7289 +
7290 +@@ -82,21 +86,20 @@ _max_freq=$(cpupower frequency-info -l | tail -1 | awk ' { print $2 } ')
7291 + max_freq=$(($_max_freq / 1000))
7292 +
7293 +
7294 +-for freq in `seq $max_freq -100 $min_freq`
7295 ++[ $EVALUATE_ONLY -eq 0 ] && for freq in `seq $max_freq -100 $min_freq`
7296 + do
7297 + echo "Setting maximum frequency to $freq"
7298 + cpupower frequency-set -g powersave --max=${freq}MHz >& /dev/null
7299 +- [ $EVALUATE_ONLY -eq 0 ] && run_test $freq
7300 ++ run_test $freq
7301 + done
7302 +
7303 +-echo "=============================================================================="
7304 ++[ $EVALUATE_ONLY -eq 0 ] && cpupower frequency-set -g powersave --max=${max_freq}MHz >& /dev/null
7305 +
7306 ++echo "=============================================================================="
7307 + echo "The marketing frequency of the cpu is $mkt_freq MHz"
7308 + echo "The maximum frequency of the cpu is $max_freq MHz"
7309 + echo "The minimum frequency of the cpu is $min_freq MHz"
7310 +
7311 +-cpupower frequency-set -g powersave --max=${max_freq}MHz >& /dev/null
7312 +-
7313 + # make a pretty table
7314 + echo "Target Actual Difference MSR(0x199) max_perf_pct"
7315 + for freq in `seq $max_freq -100 $min_freq`
7316 +@@ -104,10 +107,6 @@ do
7317 + result_freq=$(cat /tmp/result.${freq} | grep "cpu MHz" | awk ' { print $4 } ' | awk -F "." ' { print $1 } ')
7318 + msr=$(cat /tmp/result.${freq} | grep "msr" | awk ' { print $3 } ')
7319 + max_perf_pct=$(cat /tmp/result.${freq} | grep "max_perf_pct" | awk ' { print $2 } ' )
7320 +- if [ $result_freq -eq $freq ]; then
7321 +- echo " $freq $result_freq 0 $msr $(($max_perf_pct*3300))"
7322 +- else
7323 +- echo " $freq $result_freq $(($result_freq-$freq)) $msr $(($max_perf_pct*$max_freq))"
7324 +- fi
7325 ++ echo " $freq $result_freq $(($result_freq-$freq)) $msr $(($max_perf_pct*$max_freq))"
7326 + done
7327 + exit 0
7328 +diff --git a/tools/testing/selftests/memfd/run_tests.sh b/tools/testing/selftests/memfd/run_tests.sh
7329 +index daabb350697c..bf83db61013a 100755
7330 +--- a/tools/testing/selftests/memfd/run_tests.sh
7331 ++++ b/tools/testing/selftests/memfd/run_tests.sh
7332 +@@ -1,6 +1,9 @@
7333 + #!/bin/bash
7334 + # please run as root
7335 +
7336 ++# Kselftest framework requirement - SKIP code is 4.
7337 ++ksft_skip=4
7338 ++
7339 + #
7340 + # Normal tests requiring no special resources
7341 + #
7342 +@@ -29,12 +32,13 @@ if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then
7343 + nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
7344 + hpages_needed=`expr $hpages_test - $freepgs`
7345 +
7346 ++ if [ $UID != 0 ]; then
7347 ++ echo "Please run memfd with hugetlbfs test as root"
7348 ++ exit $ksft_skip
7349 ++ fi
7350 ++
7351 + echo 3 > /proc/sys/vm/drop_caches
7352 + echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
7353 +- if [ $? -ne 0 ]; then
7354 +- echo "Please run this test as root"
7355 +- exit 1
7356 +- fi
7357 + while read name size unit; do
7358 + if [ "$name" = "HugePages_Free:" ]; then
7359 + freepgs=$size
7360 +@@ -53,7 +57,7 @@ if [ $freepgs -lt $hpages_test ]; then
7361 + fi
7362 + printf "Not enough huge pages available (%d < %d)\n" \
7363 + $freepgs $needpgs
7364 +- exit 1
7365 ++ exit $ksft_skip
7366 + fi
7367 +
7368 + #
7369 +diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c
7370 +index d1fc0f9f00fb..ed8c9d360c0f 100644
7371 +--- a/tools/usb/usbip/libsrc/vhci_driver.c
7372 ++++ b/tools/usb/usbip/libsrc/vhci_driver.c
7373 +@@ -135,11 +135,11 @@ static int refresh_imported_device_list(void)
7374 + return 0;
7375 + }
7376 +
7377 +-static int get_nports(void)
7378 ++static int get_nports(struct udev_device *hc_device)
7379 + {
7380 + const char *attr_nports;
7381 +
7382 +- attr_nports = udev_device_get_sysattr_value(vhci_driver->hc_device, "nports");
7383 ++ attr_nports = udev_device_get_sysattr_value(hc_device, "nports");
7384 + if (!attr_nports) {
7385 + err("udev_device_get_sysattr_value nports failed");
7386 + return -1;
7387 +@@ -242,35 +242,41 @@ static int read_record(int rhport, char *host, unsigned long host_len,
7388 +
7389 + int usbip_vhci_driver_open(void)
7390 + {
7391 ++ int nports;
7392 ++ struct udev_device *hc_device;
7393 ++
7394 + udev_context = udev_new();
7395 + if (!udev_context) {
7396 + err("udev_new failed");
7397 + return -1;
7398 + }
7399 +
7400 +- vhci_driver = calloc(1, sizeof(struct usbip_vhci_driver));
7401 +-
7402 + /* will be freed in usbip_driver_close() */
7403 +- vhci_driver->hc_device =
7404 ++ hc_device =
7405 + udev_device_new_from_subsystem_sysname(udev_context,
7406 + USBIP_VHCI_BUS_TYPE,
7407 + USBIP_VHCI_DEVICE_NAME);
7408 +- if (!vhci_driver->hc_device) {
7409 ++ if (!hc_device) {
7410 + err("udev_device_new_from_subsystem_sysname failed");
7411 + goto err;
7412 + }
7413 +
7414 +- vhci_driver->nports = get_nports();
7415 +- dbg("available ports: %d", vhci_driver->nports);
7416 +-
7417 +- if (vhci_driver->nports <= 0) {
7418 ++ nports = get_nports(hc_device);
7419 ++ if (nports <= 0) {
7420 + err("no available ports");
7421 + goto err;
7422 +- } else if (vhci_driver->nports > MAXNPORT) {
7423 +- err("port number exceeds %d", MAXNPORT);
7424 ++ }
7425 ++ dbg("available ports: %d", nports);
7426 ++
7427 ++ vhci_driver = calloc(1, sizeof(struct usbip_vhci_driver) +
7428 ++ nports * sizeof(struct usbip_imported_device));
7429 ++ if (!vhci_driver) {
7430 ++ err("vhci_driver allocation failed");
7431 + goto err;
7432 + }
7433 +
7434 ++ vhci_driver->nports = nports;
7435 ++ vhci_driver->hc_device = hc_device;
7436 + vhci_driver->ncontrollers = get_ncontrollers();
7437 + dbg("available controllers: %d", vhci_driver->ncontrollers);
7438 +
7439 +@@ -285,7 +291,7 @@ int usbip_vhci_driver_open(void)
7440 + return 0;
7441 +
7442 + err:
7443 +- udev_device_unref(vhci_driver->hc_device);
7444 ++ udev_device_unref(hc_device);
7445 +
7446 + if (vhci_driver)
7447 + free(vhci_driver);
7448 +diff --git a/tools/usb/usbip/libsrc/vhci_driver.h b/tools/usb/usbip/libsrc/vhci_driver.h
7449 +index 418b404d5121..6c9aca216705 100644
7450 +--- a/tools/usb/usbip/libsrc/vhci_driver.h
7451 ++++ b/tools/usb/usbip/libsrc/vhci_driver.h
7452 +@@ -13,7 +13,6 @@
7453 +
7454 + #define USBIP_VHCI_BUS_TYPE "platform"
7455 + #define USBIP_VHCI_DEVICE_NAME "vhci_hcd.0"
7456 +-#define MAXNPORT 128
7457 +
7458 + enum hub_speed {
7459 + HUB_SPEED_HIGH = 0,
7460 +@@ -41,7 +40,7 @@ struct usbip_vhci_driver {
7461 +
7462 + int ncontrollers;
7463 + int nports;
7464 +- struct usbip_imported_device idev[MAXNPORT];
7465 ++ struct usbip_imported_device idev[];
7466 + };
7467 +
7468 +
7469 +diff --git a/tools/usb/usbip/src/usbip_detach.c b/tools/usb/usbip/src/usbip_detach.c
7470 +index 9db9d21bb2ec..6a8db858caa5 100644
7471 +--- a/tools/usb/usbip/src/usbip_detach.c
7472 ++++ b/tools/usb/usbip/src/usbip_detach.c
7473 +@@ -43,7 +43,7 @@ void usbip_detach_usage(void)
7474 +
7475 + static int detach_port(char *port)
7476 + {
7477 +- int ret;
7478 ++ int ret = 0;
7479 + uint8_t portnum;
7480 + char path[PATH_MAX+1];
7481 +
7482 +@@ -73,9 +73,12 @@ static int detach_port(char *port)
7483 + }
7484 +
7485 + ret = usbip_vhci_detach_device(portnum);
7486 +- if (ret < 0)
7487 +- return -1;
7488 ++ if (ret < 0) {
7489 ++ ret = -1;
7490 ++ goto call_driver_close;
7491 ++ }
7492 +
7493 ++call_driver_close:
7494 + usbip_vhci_driver_close();
7495 +
7496 + return ret;