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: Wed, 14 Nov 2018 14:01:02
Message-Id: 1542204041.dea4c6d136519c0de870d6bfb4a4aa676a034597.mpagano@gentoo
1 commit: dea4c6d136519c0de870d6bfb4a4aa676a034597
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Aug 24 11:43:57 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 14 14:00:41 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=dea4c6d1
7
8 Linux patch 4.14.67
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1066_linux-4.14.67.patch | 6716 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 6720 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 352e3ec..de230d4 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -307,6 +307,10 @@ Patch: 1065_linux-4.14.66.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.14.66
23
24 +Patch: 1066_linux-4.14.67.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.14.67
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1066_linux-4.14.67.patch b/1066_linux-4.14.67.patch
33 new file mode 100644
34 index 0000000..caaaf72
35 --- /dev/null
36 +++ b/1066_linux-4.14.67.patch
37 @@ -0,0 +1,6716 @@
38 +diff --git a/Makefile b/Makefile
39 +index e69d0d091742..4dad2d1c24ba 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 4
45 + PATCHLEVEL = 14
46 +-SUBLEVEL = 66
47 ++SUBLEVEL = 67
48 + EXTRAVERSION =
49 + NAME = Petit Gorille
50 +
51 +@@ -357,9 +357,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
52 + else if [ -x /bin/bash ]; then echo /bin/bash; \
53 + else echo sh; fi ; fi)
54 +
55 +-HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS)
56 +-HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS)
57 +-HOST_LFS_LIBS := $(shell getconf LFS_LIBS)
58 ++HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
59 ++HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
60 ++HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
61 +
62 + HOSTCC = gcc
63 + HOSTCXX = g++
64 +diff --git a/arch/arc/Makefile b/arch/arc/Makefile
65 +index d37f49d6a27f..6c1b20dd76ad 100644
66 +--- a/arch/arc/Makefile
67 ++++ b/arch/arc/Makefile
68 +@@ -16,7 +16,7 @@ endif
69 +
70 + KBUILD_DEFCONFIG := nsim_700_defconfig
71 +
72 +-cflags-y += -fno-common -pipe -fno-builtin -D__linux__
73 ++cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
74 + cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7
75 + cflags-$(CONFIG_ISA_ARCV2) += -mcpu=archs
76 +
77 +@@ -140,16 +140,3 @@ dtbs: scripts
78 +
79 + archclean:
80 + $(Q)$(MAKE) $(clean)=$(boot)
81 +-
82 +-# Hacks to enable final link due to absence of link-time branch relexation
83 +-# and gcc choosing optimal(shorter) branches at -O3
84 +-#
85 +-# vineetg Feb 2010: -mlong-calls switched off for overall kernel build
86 +-# However lib/decompress_inflate.o (.init.text) calls
87 +-# zlib_inflate_workspacesize (.text) causing relocation errors.
88 +-# Thus forcing all exten calls in this file to be long calls
89 +-export CFLAGS_decompress_inflate.o = -mmedium-calls
90 +-export CFLAGS_initramfs.o = -mmedium-calls
91 +-ifdef CONFIG_SMP
92 +-export CFLAGS_core.o = -mmedium-calls
93 +-endif
94 +diff --git a/arch/arc/include/asm/mach_desc.h b/arch/arc/include/asm/mach_desc.h
95 +index c28e6c347b49..871f3cb16af9 100644
96 +--- a/arch/arc/include/asm/mach_desc.h
97 ++++ b/arch/arc/include/asm/mach_desc.h
98 +@@ -34,9 +34,7 @@ struct machine_desc {
99 + const char *name;
100 + const char **dt_compat;
101 + void (*init_early)(void);
102 +-#ifdef CONFIG_SMP
103 + void (*init_per_cpu)(unsigned int);
104 +-#endif
105 + void (*init_machine)(void);
106 + void (*init_late)(void);
107 +
108 +diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c
109 +index 538b36afe89e..62b185057c04 100644
110 +--- a/arch/arc/kernel/irq.c
111 ++++ b/arch/arc/kernel/irq.c
112 +@@ -31,10 +31,10 @@ void __init init_IRQ(void)
113 + /* a SMP H/w block could do IPI IRQ request here */
114 + if (plat_smp_ops.init_per_cpu)
115 + plat_smp_ops.init_per_cpu(smp_processor_id());
116 ++#endif
117 +
118 + if (machine_desc->init_per_cpu)
119 + machine_desc->init_per_cpu(smp_processor_id());
120 +-#endif
121 + }
122 +
123 + /*
124 +diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
125 +index 5ac3b547453f..4674541eba3f 100644
126 +--- a/arch/arc/kernel/process.c
127 ++++ b/arch/arc/kernel/process.c
128 +@@ -47,7 +47,8 @@ SYSCALL_DEFINE0(arc_gettls)
129 + SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
130 + {
131 + struct pt_regs *regs = current_pt_regs();
132 +- int uval = -EFAULT;
133 ++ u32 uval;
134 ++ int ret;
135 +
136 + /*
137 + * This is only for old cores lacking LLOCK/SCOND, which by defintion
138 +@@ -60,23 +61,47 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
139 + /* Z indicates to userspace if operation succeded */
140 + regs->status32 &= ~STATUS_Z_MASK;
141 +
142 +- if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
143 +- return -EFAULT;
144 ++ ret = access_ok(VERIFY_WRITE, uaddr, sizeof(*uaddr));
145 ++ if (!ret)
146 ++ goto fail;
147 +
148 ++again:
149 + preempt_disable();
150 +
151 +- if (__get_user(uval, uaddr))
152 +- goto done;
153 ++ ret = __get_user(uval, uaddr);
154 ++ if (ret)
155 ++ goto fault;
156 +
157 +- if (uval == expected) {
158 +- if (!__put_user(new, uaddr))
159 +- regs->status32 |= STATUS_Z_MASK;
160 +- }
161 ++ if (uval != expected)
162 ++ goto out;
163 +
164 +-done:
165 +- preempt_enable();
166 ++ ret = __put_user(new, uaddr);
167 ++ if (ret)
168 ++ goto fault;
169 ++
170 ++ regs->status32 |= STATUS_Z_MASK;
171 +
172 ++out:
173 ++ preempt_enable();
174 + return uval;
175 ++
176 ++fault:
177 ++ preempt_enable();
178 ++
179 ++ if (unlikely(ret != -EFAULT))
180 ++ goto fail;
181 ++
182 ++ down_read(&current->mm->mmap_sem);
183 ++ ret = fixup_user_fault(current, current->mm, (unsigned long) uaddr,
184 ++ FAULT_FLAG_WRITE, NULL);
185 ++ up_read(&current->mm->mmap_sem);
186 ++
187 ++ if (likely(!ret))
188 ++ goto again;
189 ++
190 ++fail:
191 ++ force_sig(SIGSEGV, current);
192 ++ return ret;
193 + }
194 +
195 + #ifdef CONFIG_ISA_ARCV2
196 +diff --git a/arch/arm/boot/dts/am3517.dtsi b/arch/arm/boot/dts/am3517.dtsi
197 +index 00da3f2c4072..4b57094a0356 100644
198 +--- a/arch/arm/boot/dts/am3517.dtsi
199 ++++ b/arch/arm/boot/dts/am3517.dtsi
200 +@@ -87,6 +87,11 @@
201 + };
202 + };
203 +
204 ++/* Table Table 5-79 of the TRM shows 480ab000 is reserved */
205 ++&usb_otg_hs {
206 ++ status = "disabled";
207 ++};
208 ++
209 + &iva {
210 + status = "disabled";
211 + };
212 +diff --git a/arch/arm/boot/dts/am437x-sk-evm.dts b/arch/arm/boot/dts/am437x-sk-evm.dts
213 +index 2c6bf0684f50..094fd0ea91a0 100644
214 +--- a/arch/arm/boot/dts/am437x-sk-evm.dts
215 ++++ b/arch/arm/boot/dts/am437x-sk-evm.dts
216 +@@ -535,6 +535,8 @@
217 +
218 + touchscreen-size-x = <480>;
219 + touchscreen-size-y = <272>;
220 ++
221 ++ wakeup-source;
222 + };
223 +
224 + tlv320aic3106: tlv320aic3106@1b {
225 +diff --git a/arch/arm/boot/dts/armada-385-synology-ds116.dts b/arch/arm/boot/dts/armada-385-synology-ds116.dts
226 +index 31510eb56f10..874189b4d218 100644
227 +--- a/arch/arm/boot/dts/armada-385-synology-ds116.dts
228 ++++ b/arch/arm/boot/dts/armada-385-synology-ds116.dts
229 +@@ -170,7 +170,7 @@
230 + 3700 5
231 + 3900 6
232 + 4000 7>;
233 +- cooling-cells = <2>;
234 ++ #cooling-cells = <2>;
235 + };
236 +
237 + gpio-leds {
238 +diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi b/arch/arm/boot/dts/bcm-cygnus.dtsi
239 +index 9a9902974b1b..8b2c65cd61a2 100644
240 +--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
241 ++++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
242 +@@ -216,7 +216,7 @@
243 + reg = <0x18008000 0x100>;
244 + #address-cells = <1>;
245 + #size-cells = <0>;
246 +- interrupts = <GIC_SPI 85 IRQ_TYPE_NONE>;
247 ++ interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
248 + clock-frequency = <100000>;
249 + status = "disabled";
250 + };
251 +@@ -245,7 +245,7 @@
252 + reg = <0x1800b000 0x100>;
253 + #address-cells = <1>;
254 + #size-cells = <0>;
255 +- interrupts = <GIC_SPI 86 IRQ_TYPE_NONE>;
256 ++ interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
257 + clock-frequency = <100000>;
258 + status = "disabled";
259 + };
260 +@@ -256,7 +256,7 @@
261 +
262 + #interrupt-cells = <1>;
263 + interrupt-map-mask = <0 0 0 0>;
264 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_NONE>;
265 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>;
266 +
267 + linux,pci-domain = <0>;
268 +
269 +@@ -278,10 +278,10 @@
270 + compatible = "brcm,iproc-msi";
271 + msi-controller;
272 + interrupt-parent = <&gic>;
273 +- interrupts = <GIC_SPI 96 IRQ_TYPE_NONE>,
274 +- <GIC_SPI 97 IRQ_TYPE_NONE>,
275 +- <GIC_SPI 98 IRQ_TYPE_NONE>,
276 +- <GIC_SPI 99 IRQ_TYPE_NONE>;
277 ++ interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>,
278 ++ <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>,
279 ++ <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>,
280 ++ <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>;
281 + };
282 + };
283 +
284 +@@ -291,7 +291,7 @@
285 +
286 + #interrupt-cells = <1>;
287 + interrupt-map-mask = <0 0 0 0>;
288 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_NONE>;
289 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
290 +
291 + linux,pci-domain = <1>;
292 +
293 +@@ -313,10 +313,10 @@
294 + compatible = "brcm,iproc-msi";
295 + msi-controller;
296 + interrupt-parent = <&gic>;
297 +- interrupts = <GIC_SPI 102 IRQ_TYPE_NONE>,
298 +- <GIC_SPI 103 IRQ_TYPE_NONE>,
299 +- <GIC_SPI 104 IRQ_TYPE_NONE>,
300 +- <GIC_SPI 105 IRQ_TYPE_NONE>;
301 ++ interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>,
302 ++ <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
303 ++ <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>,
304 ++ <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>;
305 + };
306 + };
307 +
308 +diff --git a/arch/arm/boot/dts/bcm-nsp.dtsi b/arch/arm/boot/dts/bcm-nsp.dtsi
309 +index d5f5e92e7488..1792192001a2 100644
310 +--- a/arch/arm/boot/dts/bcm-nsp.dtsi
311 ++++ b/arch/arm/boot/dts/bcm-nsp.dtsi
312 +@@ -391,7 +391,7 @@
313 + reg = <0x38000 0x50>;
314 + #address-cells = <1>;
315 + #size-cells = <0>;
316 +- interrupts = <GIC_SPI 89 IRQ_TYPE_NONE>;
317 ++ interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
318 + clock-frequency = <100000>;
319 + dma-coherent;
320 + status = "disabled";
321 +@@ -496,7 +496,7 @@
322 +
323 + #interrupt-cells = <1>;
324 + interrupt-map-mask = <0 0 0 0>;
325 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 131 IRQ_TYPE_NONE>;
326 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
327 +
328 + linux,pci-domain = <0>;
329 +
330 +@@ -519,10 +519,10 @@
331 + compatible = "brcm,iproc-msi";
332 + msi-controller;
333 + interrupt-parent = <&gic>;
334 +- interrupts = <GIC_SPI 127 IRQ_TYPE_NONE>,
335 +- <GIC_SPI 128 IRQ_TYPE_NONE>,
336 +- <GIC_SPI 129 IRQ_TYPE_NONE>,
337 +- <GIC_SPI 130 IRQ_TYPE_NONE>;
338 ++ interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>,
339 ++ <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>,
340 ++ <GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH>,
341 ++ <GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>;
342 + brcm,pcie-msi-inten;
343 + };
344 + };
345 +@@ -533,7 +533,7 @@
346 +
347 + #interrupt-cells = <1>;
348 + interrupt-map-mask = <0 0 0 0>;
349 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 137 IRQ_TYPE_NONE>;
350 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>;
351 +
352 + linux,pci-domain = <1>;
353 +
354 +@@ -556,10 +556,10 @@
355 + compatible = "brcm,iproc-msi";
356 + msi-controller;
357 + interrupt-parent = <&gic>;
358 +- interrupts = <GIC_SPI 133 IRQ_TYPE_NONE>,
359 +- <GIC_SPI 134 IRQ_TYPE_NONE>,
360 +- <GIC_SPI 135 IRQ_TYPE_NONE>,
361 +- <GIC_SPI 136 IRQ_TYPE_NONE>;
362 ++ interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>,
363 ++ <GIC_SPI 134 IRQ_TYPE_LEVEL_HIGH>,
364 ++ <GIC_SPI 135 IRQ_TYPE_LEVEL_HIGH>,
365 ++ <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
366 + brcm,pcie-msi-inten;
367 + };
368 + };
369 +@@ -570,7 +570,7 @@
370 +
371 + #interrupt-cells = <1>;
372 + interrupt-map-mask = <0 0 0 0>;
373 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 143 IRQ_TYPE_NONE>;
374 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
375 +
376 + linux,pci-domain = <2>;
377 +
378 +@@ -593,10 +593,10 @@
379 + compatible = "brcm,iproc-msi";
380 + msi-controller;
381 + interrupt-parent = <&gic>;
382 +- interrupts = <GIC_SPI 139 IRQ_TYPE_NONE>,
383 +- <GIC_SPI 140 IRQ_TYPE_NONE>,
384 +- <GIC_SPI 141 IRQ_TYPE_NONE>,
385 +- <GIC_SPI 142 IRQ_TYPE_NONE>;
386 ++ interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>,
387 ++ <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>,
388 ++ <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>,
389 ++ <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>;
390 + brcm,pcie-msi-inten;
391 + };
392 + };
393 +diff --git a/arch/arm/boot/dts/bcm5301x.dtsi b/arch/arm/boot/dts/bcm5301x.dtsi
394 +index 045b9bb857f9..501877e87a5b 100644
395 +--- a/arch/arm/boot/dts/bcm5301x.dtsi
396 ++++ b/arch/arm/boot/dts/bcm5301x.dtsi
397 +@@ -365,7 +365,7 @@
398 + i2c0: i2c@18009000 {
399 + compatible = "brcm,iproc-i2c";
400 + reg = <0x18009000 0x50>;
401 +- interrupts = <GIC_SPI 121 IRQ_TYPE_NONE>;
402 ++ interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
403 + #address-cells = <1>;
404 + #size-cells = <0>;
405 + clock-frequency = <100000>;
406 +diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
407 +index 8a15f7193c82..77dd62e260db 100644
408 +--- a/arch/arm/boot/dts/da850.dtsi
409 ++++ b/arch/arm/boot/dts/da850.dtsi
410 +@@ -518,11 +518,7 @@
411 + gpio-controller;
412 + #gpio-cells = <2>;
413 + reg = <0x226000 0x1000>;
414 +- interrupts = <42 IRQ_TYPE_EDGE_BOTH
415 +- 43 IRQ_TYPE_EDGE_BOTH 44 IRQ_TYPE_EDGE_BOTH
416 +- 45 IRQ_TYPE_EDGE_BOTH 46 IRQ_TYPE_EDGE_BOTH
417 +- 47 IRQ_TYPE_EDGE_BOTH 48 IRQ_TYPE_EDGE_BOTH
418 +- 49 IRQ_TYPE_EDGE_BOTH 50 IRQ_TYPE_EDGE_BOTH>;
419 ++ interrupts = <42 43 44 45 46 47 48 49 50>;
420 + ti,ngpio = <144>;
421 + ti,davinci-gpio-unbanked = <0>;
422 + status = "disabled";
423 +diff --git a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
424 +index eeb7679fd348..849eb3443cde 100644
425 +--- a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
426 ++++ b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
427 +@@ -644,7 +644,7 @@
428 + dsa,member = <0 0>;
429 + eeprom-length = <512>;
430 + interrupt-parent = <&gpio6>;
431 +- interrupts = <3 IRQ_TYPE_EDGE_FALLING>;
432 ++ interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
433 + interrupt-controller;
434 + #interrupt-cells = <2>;
435 +
436 +diff --git a/arch/arm/configs/imx_v4_v5_defconfig b/arch/arm/configs/imx_v4_v5_defconfig
437 +index ca0f13cafe38..6e5a3d9c23e1 100644
438 +--- a/arch/arm/configs/imx_v4_v5_defconfig
439 ++++ b/arch/arm/configs/imx_v4_v5_defconfig
440 +@@ -144,9 +144,11 @@ CONFIG_USB_STORAGE=y
441 + CONFIG_USB_CHIPIDEA=y
442 + CONFIG_USB_CHIPIDEA_UDC=y
443 + CONFIG_USB_CHIPIDEA_HOST=y
444 ++CONFIG_USB_CHIPIDEA_ULPI=y
445 + CONFIG_NOP_USB_XCEIV=y
446 + CONFIG_USB_GADGET=y
447 + CONFIG_USB_ETH=m
448 ++CONFIG_USB_ULPI_BUS=y
449 + CONFIG_MMC=y
450 + CONFIG_MMC_SDHCI=y
451 + CONFIG_MMC_SDHCI_PLTFM=y
452 +diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
453 +index 32acac9ab81a..21ac9f02407e 100644
454 +--- a/arch/arm/configs/imx_v6_v7_defconfig
455 ++++ b/arch/arm/configs/imx_v6_v7_defconfig
456 +@@ -289,6 +289,7 @@ CONFIG_USB_STORAGE=y
457 + CONFIG_USB_CHIPIDEA=y
458 + CONFIG_USB_CHIPIDEA_UDC=y
459 + CONFIG_USB_CHIPIDEA_HOST=y
460 ++CONFIG_USB_CHIPIDEA_ULPI=y
461 + CONFIG_USB_SERIAL=m
462 + CONFIG_USB_SERIAL_GENERIC=y
463 + CONFIG_USB_SERIAL_FTDI_SIO=m
464 +@@ -325,6 +326,7 @@ CONFIG_USB_GADGETFS=m
465 + CONFIG_USB_FUNCTIONFS=m
466 + CONFIG_USB_MASS_STORAGE=m
467 + CONFIG_USB_G_SERIAL=m
468 ++CONFIG_USB_ULPI_BUS=y
469 + CONFIG_MMC=y
470 + CONFIG_MMC_SDHCI=y
471 + CONFIG_MMC_SDHCI_PLTFM=y
472 +diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
473 +index 25f12118c364..2f6ac1afa804 100644
474 +--- a/arch/arm/mach-davinci/board-da850-evm.c
475 ++++ b/arch/arm/mach-davinci/board-da850-evm.c
476 +@@ -773,7 +773,7 @@ static struct gpiod_lookup_table mmc_gpios_table = {
477 + GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_CD_PIN, "cd",
478 + GPIO_ACTIVE_LOW),
479 + GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_WP_PIN, "wp",
480 +- GPIO_ACTIVE_LOW),
481 ++ GPIO_ACTIVE_HIGH),
482 + },
483 + };
484 +
485 +diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
486 +index 69df3620eca5..1c73694c871a 100644
487 +--- a/arch/arm/mach-omap2/omap-smp.c
488 ++++ b/arch/arm/mach-omap2/omap-smp.c
489 +@@ -109,6 +109,45 @@ void omap5_erratum_workaround_801819(void)
490 + static inline void omap5_erratum_workaround_801819(void) { }
491 + #endif
492 +
493 ++#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
494 ++/*
495 ++ * Configure ACR and enable ACTLR[0] (Enable invalidates of BTB with
496 ++ * ICIALLU) to activate the workaround for secondary Core.
497 ++ * NOTE: it is assumed that the primary core's configuration is done
498 ++ * by the boot loader (kernel will detect a misconfiguration and complain
499 ++ * if this is not done).
500 ++ *
501 ++ * In General Purpose(GP) devices, ACR bit settings can only be done
502 ++ * by ROM code in "secure world" using the smc call and there is no
503 ++ * option to update the "firmware" on such devices. This also works for
504 ++ * High security(HS) devices, as a backup option in case the
505 ++ * "update" is not done in the "security firmware".
506 ++ */
507 ++static void omap5_secondary_harden_predictor(void)
508 ++{
509 ++ u32 acr, acr_mask;
510 ++
511 ++ asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
512 ++
513 ++ /*
514 ++ * ACTLR[0] (Enable invalidates of BTB with ICIALLU)
515 ++ */
516 ++ acr_mask = BIT(0);
517 ++
518 ++ /* Do we already have it done.. if yes, skip expensive smc */
519 ++ if ((acr & acr_mask) == acr_mask)
520 ++ return;
521 ++
522 ++ acr |= acr_mask;
523 ++ omap_smc1(OMAP5_DRA7_MON_SET_ACR_INDEX, acr);
524 ++
525 ++ pr_debug("%s: ARM ACR setup for CVE_2017_5715 applied on CPU%d\n",
526 ++ __func__, smp_processor_id());
527 ++}
528 ++#else
529 ++static inline void omap5_secondary_harden_predictor(void) { }
530 ++#endif
531 ++
532 + static void omap4_secondary_init(unsigned int cpu)
533 + {
534 + /*
535 +@@ -131,6 +170,8 @@ static void omap4_secondary_init(unsigned int cpu)
536 + set_cntfreq();
537 + /* Configure ACR to disable streaming WA for 801819 */
538 + omap5_erratum_workaround_801819();
539 ++ /* Enable ACR to allow for ICUALLU workaround */
540 ++ omap5_secondary_harden_predictor();
541 + }
542 +
543 + /*
544 +diff --git a/arch/arm/mach-pxa/irq.c b/arch/arm/mach-pxa/irq.c
545 +index 9c10248fadcc..4e8c2116808e 100644
546 +--- a/arch/arm/mach-pxa/irq.c
547 ++++ b/arch/arm/mach-pxa/irq.c
548 +@@ -185,7 +185,7 @@ static int pxa_irq_suspend(void)
549 + {
550 + int i;
551 +
552 +- for (i = 0; i < pxa_internal_irq_nr / 32; i++) {
553 ++ for (i = 0; i < DIV_ROUND_UP(pxa_internal_irq_nr, 32); i++) {
554 + void __iomem *base = irq_base(i);
555 +
556 + saved_icmr[i] = __raw_readl(base + ICMR);
557 +@@ -204,7 +204,7 @@ static void pxa_irq_resume(void)
558 + {
559 + int i;
560 +
561 +- for (i = 0; i < pxa_internal_irq_nr / 32; i++) {
562 ++ for (i = 0; i < DIV_ROUND_UP(pxa_internal_irq_nr, 32); i++) {
563 + void __iomem *base = irq_base(i);
564 +
565 + __raw_writel(saved_icmr[i], base + ICMR);
566 +diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
567 +index 0f6d1537f330..defb7fc26428 100644
568 +--- a/arch/arm/mm/init.c
569 ++++ b/arch/arm/mm/init.c
570 +@@ -745,19 +745,28 @@ static int __mark_rodata_ro(void *unused)
571 + return 0;
572 + }
573 +
574 ++static int kernel_set_to_readonly __read_mostly;
575 ++
576 + void mark_rodata_ro(void)
577 + {
578 ++ kernel_set_to_readonly = 1;
579 + stop_machine(__mark_rodata_ro, NULL, NULL);
580 + }
581 +
582 + void set_kernel_text_rw(void)
583 + {
584 ++ if (!kernel_set_to_readonly)
585 ++ return;
586 ++
587 + set_section_perms(ro_perms, ARRAY_SIZE(ro_perms), false,
588 + current->active_mm);
589 + }
590 +
591 + void set_kernel_text_ro(void)
592 + {
593 ++ if (!kernel_set_to_readonly)
594 ++ return;
595 ++
596 + set_section_perms(ro_perms, ARRAY_SIZE(ro_perms), true,
597 + current->active_mm);
598 + }
599 +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
600 +index f06cc234693b..379abc3d82fe 100644
601 +--- a/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
602 ++++ b/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
603 +@@ -7,7 +7,7 @@
604 +
605 + &apb {
606 + mali: gpu@c0000 {
607 +- compatible = "amlogic,meson-gxbb-mali", "arm,mali-450";
608 ++ compatible = "amlogic,meson-gxl-mali", "arm,mali-450";
609 + reg = <0x0 0xc0000 0x0 0x40000>;
610 + interrupts = <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
611 + <GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>,
612 +diff --git a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
613 +index 35c8457e3d1f..0b72094bcf5a 100644
614 +--- a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
615 ++++ b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
616 +@@ -118,7 +118,7 @@
617 +
618 + #interrupt-cells = <1>;
619 + interrupt-map-mask = <0 0 0 0>;
620 +- interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 281 IRQ_TYPE_NONE>;
621 ++ interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 281 IRQ_TYPE_LEVEL_HIGH>;
622 +
623 + linux,pci-domain = <0>;
624 +
625 +@@ -149,7 +149,7 @@
626 +
627 + #interrupt-cells = <1>;
628 + interrupt-map-mask = <0 0 0 0>;
629 +- interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 305 IRQ_TYPE_NONE>;
630 ++ interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 305 IRQ_TYPE_LEVEL_HIGH>;
631 +
632 + linux,pci-domain = <4>;
633 +
634 +@@ -566,7 +566,7 @@
635 + reg = <0x66080000 0x100>;
636 + #address-cells = <1>;
637 + #size-cells = <0>;
638 +- interrupts = <GIC_SPI 394 IRQ_TYPE_NONE>;
639 ++ interrupts = <GIC_SPI 394 IRQ_TYPE_LEVEL_HIGH>;
640 + clock-frequency = <100000>;
641 + status = "disabled";
642 + };
643 +@@ -594,7 +594,7 @@
644 + reg = <0x660b0000 0x100>;
645 + #address-cells = <1>;
646 + #size-cells = <0>;
647 +- interrupts = <GIC_SPI 395 IRQ_TYPE_NONE>;
648 ++ interrupts = <GIC_SPI 395 IRQ_TYPE_LEVEL_HIGH>;
649 + clock-frequency = <100000>;
650 + status = "disabled";
651 + };
652 +diff --git a/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts b/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
653 +index eb6f08cdbd79..77efa28c4dd5 100644
654 +--- a/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
655 ++++ b/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
656 +@@ -43,6 +43,10 @@
657 + enet-phy-lane-swap;
658 + };
659 +
660 ++&sdio0 {
661 ++ mmc-ddr-1_8v;
662 ++};
663 ++
664 + &uart2 {
665 + status = "okay";
666 + };
667 +diff --git a/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts b/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
668 +index 5084b037320f..55ba495ef56e 100644
669 +--- a/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
670 ++++ b/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
671 +@@ -42,3 +42,7 @@
672 + &gphy0 {
673 + enet-phy-lane-swap;
674 + };
675 ++
676 ++&sdio0 {
677 ++ mmc-ddr-1_8v;
678 ++};
679 +diff --git a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
680 +index e6f75c633623..2b76293b51c8 100644
681 +--- a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
682 ++++ b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
683 +@@ -409,7 +409,7 @@
684 + reg = <0x000b0000 0x100>;
685 + #address-cells = <1>;
686 + #size-cells = <0>;
687 +- interrupts = <GIC_SPI 177 IRQ_TYPE_NONE>;
688 ++ interrupts = <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>;
689 + clock-frequency = <100000>;
690 + status = "disabled";
691 + };
692 +@@ -453,7 +453,7 @@
693 + reg = <0x000e0000 0x100>;
694 + #address-cells = <1>;
695 + #size-cells = <0>;
696 +- interrupts = <GIC_SPI 178 IRQ_TYPE_NONE>;
697 ++ interrupts = <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>;
698 + clock-frequency = <100000>;
699 + status = "disabled";
700 + };
701 +diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
702 +index 61da6e65900b..3cc449425a03 100644
703 +--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
704 ++++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
705 +@@ -1132,14 +1132,14 @@
706 +
707 + port@0 {
708 + reg = <0>;
709 +- etf_out: endpoint {
710 ++ etf_in: endpoint {
711 + slave-mode;
712 + remote-endpoint = <&funnel0_out>;
713 + };
714 + };
715 + port@1 {
716 + reg = <0>;
717 +- etf_in: endpoint {
718 ++ etf_out: endpoint {
719 + remote-endpoint = <&replicator_in>;
720 + };
721 + };
722 +diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
723 +index 9f7195a5773e..b7ad41d7b6ee 100644
724 +--- a/arch/arm64/kernel/smp.c
725 ++++ b/arch/arm64/kernel/smp.c
726 +@@ -214,7 +214,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
727 + * This is the secondary CPU boot entry. We're using this CPUs
728 + * idle thread stack, but a set of temporary page tables.
729 + */
730 +-asmlinkage void secondary_start_kernel(void)
731 ++asmlinkage notrace void secondary_start_kernel(void)
732 + {
733 + struct mm_struct *mm = &init_mm;
734 + unsigned int cpu;
735 +diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
736 +index 614af886b7ef..58470b151bc3 100644
737 +--- a/arch/arm64/mm/dma-mapping.c
738 ++++ b/arch/arm64/mm/dma-mapping.c
739 +@@ -629,13 +629,14 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size,
740 + size >> PAGE_SHIFT);
741 + return NULL;
742 + }
743 +- if (!coherent)
744 +- __dma_flush_area(page_to_virt(page), iosize);
745 +-
746 + addr = dma_common_contiguous_remap(page, size, VM_USERMAP,
747 + prot,
748 + __builtin_return_address(0));
749 +- if (!addr) {
750 ++ if (addr) {
751 ++ memset(addr, 0, size);
752 ++ if (!coherent)
753 ++ __dma_flush_area(page_to_virt(page), iosize);
754 ++ } else {
755 + iommu_dma_unmap_page(dev, *handle, iosize, 0, attrs);
756 + dma_release_from_contiguous(dev, page,
757 + size >> PAGE_SHIFT);
758 +diff --git a/arch/m68k/include/asm/mcf_pgalloc.h b/arch/m68k/include/asm/mcf_pgalloc.h
759 +index 8b707c249026..12fe700632f4 100644
760 +--- a/arch/m68k/include/asm/mcf_pgalloc.h
761 ++++ b/arch/m68k/include/asm/mcf_pgalloc.h
762 +@@ -44,6 +44,7 @@ extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address)
763 + static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page,
764 + unsigned long address)
765 + {
766 ++ pgtable_page_dtor(page);
767 + __free_page(page);
768 + }
769 +
770 +@@ -74,8 +75,9 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm,
771 + return page;
772 + }
773 +
774 +-extern inline void pte_free(struct mm_struct *mm, struct page *page)
775 ++static inline void pte_free(struct mm_struct *mm, struct page *page)
776 + {
777 ++ pgtable_page_dtor(page);
778 + __free_page(page);
779 + }
780 +
781 +diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
782 +index 1b7160c79646..b16e95a4e875 100644
783 +--- a/arch/openrisc/kernel/entry.S
784 ++++ b/arch/openrisc/kernel/entry.S
785 +@@ -221,12 +221,6 @@ EXCEPTION_ENTRY(_data_page_fault_handler)
786 + l.addi r3,r1,0 // pt_regs
787 + /* r4 set be EXCEPTION_HANDLE */ // effective address of fault
788 +
789 +- /*
790 +- * __PHX__: TODO
791 +- *
792 +- * all this can be written much simpler. look at
793 +- * DTLB miss handler in the CONFIG_GUARD_PROTECTED_CORE part
794 +- */
795 + #ifdef CONFIG_OPENRISC_NO_SPR_SR_DSX
796 + l.lwz r6,PT_PC(r3) // address of an offending insn
797 + l.lwz r6,0(r6) // instruction that caused pf
798 +@@ -258,7 +252,7 @@ EXCEPTION_ENTRY(_data_page_fault_handler)
799 +
800 + #else
801 +
802 +- l.lwz r6,PT_SR(r3) // SR
803 ++ l.mfspr r6,r0,SPR_SR // SR
804 + l.andi r6,r6,SPR_SR_DSX // check for delay slot exception
805 + l.sfne r6,r0 // exception happened in delay slot
806 + l.bnf 7f
807 +diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S
808 +index 1e87913576e3..90979acdf165 100644
809 +--- a/arch/openrisc/kernel/head.S
810 ++++ b/arch/openrisc/kernel/head.S
811 +@@ -141,8 +141,7 @@
812 + * r4 - EEAR exception EA
813 + * r10 - current pointing to current_thread_info struct
814 + * r12 - syscall 0, since we didn't come from syscall
815 +- * r13 - temp it actually contains new SR, not needed anymore
816 +- * r31 - handler address of the handler we'll jump to
817 ++ * r30 - handler address of the handler we'll jump to
818 + *
819 + * handler has to save remaining registers to the exception
820 + * ksp frame *before* tainting them!
821 +@@ -178,6 +177,7 @@
822 + /* r1 is KSP, r30 is __pa(KSP) */ ;\
823 + tophys (r30,r1) ;\
824 + l.sw PT_GPR12(r30),r12 ;\
825 ++ /* r4 use for tmp before EA */ ;\
826 + l.mfspr r12,r0,SPR_EPCR_BASE ;\
827 + l.sw PT_PC(r30),r12 ;\
828 + l.mfspr r12,r0,SPR_ESR_BASE ;\
829 +@@ -197,7 +197,10 @@
830 + /* r12 == 1 if we come from syscall */ ;\
831 + CLEAR_GPR(r12) ;\
832 + /* ----- turn on MMU ----- */ ;\
833 +- l.ori r30,r0,(EXCEPTION_SR) ;\
834 ++ /* Carry DSX into exception SR */ ;\
835 ++ l.mfspr r30,r0,SPR_SR ;\
836 ++ l.andi r30,r30,SPR_SR_DSX ;\
837 ++ l.ori r30,r30,(EXCEPTION_SR) ;\
838 + l.mtspr r0,r30,SPR_ESR_BASE ;\
839 + /* r30: EA address of handler */ ;\
840 + LOAD_SYMBOL_2_GPR(r30,handler) ;\
841 +diff --git a/arch/openrisc/kernel/traps.c b/arch/openrisc/kernel/traps.c
842 +index 8d8437169b5e..0d44e8007ad6 100644
843 +--- a/arch/openrisc/kernel/traps.c
844 ++++ b/arch/openrisc/kernel/traps.c
845 +@@ -358,7 +358,7 @@ static inline int in_delay_slot(struct pt_regs *regs)
846 + return 0;
847 + }
848 + #else
849 +- return regs->sr & SPR_SR_DSX;
850 ++ return mfspr(SPR_SR) & SPR_SR_DSX;
851 + #endif
852 + }
853 +
854 +diff --git a/arch/parisc/include/asm/spinlock.h b/arch/parisc/include/asm/spinlock.h
855 +index af03359e6ac5..a82776592c8e 100644
856 +--- a/arch/parisc/include/asm/spinlock.h
857 ++++ b/arch/parisc/include/asm/spinlock.h
858 +@@ -20,7 +20,6 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *x,
859 + {
860 + volatile unsigned int *a;
861 +
862 +- mb();
863 + a = __ldcw_align(x);
864 + while (__ldcw(a) == 0)
865 + while (*a == 0)
866 +@@ -30,16 +29,15 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *x,
867 + local_irq_disable();
868 + } else
869 + cpu_relax();
870 +- mb();
871 + }
872 +
873 + static inline void arch_spin_unlock(arch_spinlock_t *x)
874 + {
875 + volatile unsigned int *a;
876 +- mb();
877 ++
878 + a = __ldcw_align(x);
879 +- *a = 1;
880 + mb();
881 ++ *a = 1;
882 + }
883 +
884 + static inline int arch_spin_trylock(arch_spinlock_t *x)
885 +@@ -47,10 +45,8 @@ static inline int arch_spin_trylock(arch_spinlock_t *x)
886 + volatile unsigned int *a;
887 + int ret;
888 +
889 +- mb();
890 + a = __ldcw_align(x);
891 + ret = __ldcw(a) != 0;
892 +- mb();
893 +
894 + return ret;
895 + }
896 +diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
897 +index 4886a6db42e9..5f7e57fcaeef 100644
898 +--- a/arch/parisc/kernel/syscall.S
899 ++++ b/arch/parisc/kernel/syscall.S
900 +@@ -629,12 +629,12 @@ cas_action:
901 + stw %r1, 4(%sr2,%r20)
902 + #endif
903 + /* The load and store could fail */
904 +-1: ldw,ma 0(%r26), %r28
905 ++1: ldw 0(%r26), %r28
906 + sub,<> %r28, %r25, %r0
907 +-2: stw,ma %r24, 0(%r26)
908 ++2: stw %r24, 0(%r26)
909 + /* Free lock */
910 + sync
911 +- stw,ma %r20, 0(%sr2,%r20)
912 ++ stw %r20, 0(%sr2,%r20)
913 + #if ENABLE_LWS_DEBUG
914 + /* Clear thread register indicator */
915 + stw %r0, 4(%sr2,%r20)
916 +@@ -798,30 +798,30 @@ cas2_action:
917 + ldo 1(%r0),%r28
918 +
919 + /* 8bit CAS */
920 +-13: ldb,ma 0(%r26), %r29
921 ++13: ldb 0(%r26), %r29
922 + sub,= %r29, %r25, %r0
923 + b,n cas2_end
924 +-14: stb,ma %r24, 0(%r26)
925 ++14: stb %r24, 0(%r26)
926 + b cas2_end
927 + copy %r0, %r28
928 + nop
929 + nop
930 +
931 + /* 16bit CAS */
932 +-15: ldh,ma 0(%r26), %r29
933 ++15: ldh 0(%r26), %r29
934 + sub,= %r29, %r25, %r0
935 + b,n cas2_end
936 +-16: sth,ma %r24, 0(%r26)
937 ++16: sth %r24, 0(%r26)
938 + b cas2_end
939 + copy %r0, %r28
940 + nop
941 + nop
942 +
943 + /* 32bit CAS */
944 +-17: ldw,ma 0(%r26), %r29
945 ++17: ldw 0(%r26), %r29
946 + sub,= %r29, %r25, %r0
947 + b,n cas2_end
948 +-18: stw,ma %r24, 0(%r26)
949 ++18: stw %r24, 0(%r26)
950 + b cas2_end
951 + copy %r0, %r28
952 + nop
953 +@@ -829,10 +829,10 @@ cas2_action:
954 +
955 + /* 64bit CAS */
956 + #ifdef CONFIG_64BIT
957 +-19: ldd,ma 0(%r26), %r29
958 ++19: ldd 0(%r26), %r29
959 + sub,*= %r29, %r25, %r0
960 + b,n cas2_end
961 +-20: std,ma %r24, 0(%r26)
962 ++20: std %r24, 0(%r26)
963 + copy %r0, %r28
964 + #else
965 + /* Compare first word */
966 +@@ -851,7 +851,7 @@ cas2_action:
967 + cas2_end:
968 + /* Free lock */
969 + sync
970 +- stw,ma %r20, 0(%sr2,%r20)
971 ++ stw %r20, 0(%sr2,%r20)
972 + /* Enable interrupts */
973 + ssm PSW_SM_I, %r0
974 + /* Return to userspace, set no error */
975 +diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
976 +index 11cd151733d4..45f1ea117128 100644
977 +--- a/arch/s390/net/bpf_jit_comp.c
978 ++++ b/arch/s390/net/bpf_jit_comp.c
979 +@@ -1403,6 +1403,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
980 + goto free_addrs;
981 + }
982 + if (bpf_jit_prog(&jit, fp)) {
983 ++ bpf_jit_binary_free(header);
984 + fp = orig_fp;
985 + goto free_addrs;
986 + }
987 +diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
988 +index 1c2cfa0644aa..97ccf4c3b45b 100644
989 +--- a/arch/x86/kernel/cpu/microcode/intel.c
990 ++++ b/arch/x86/kernel/cpu/microcode/intel.c
991 +@@ -190,8 +190,11 @@ static void save_microcode_patch(void *data, unsigned int size)
992 + p = memdup_patch(data, size);
993 + if (!p)
994 + pr_err("Error allocating buffer %p\n", data);
995 +- else
996 ++ else {
997 + list_replace(&iter->plist, &p->plist);
998 ++ kfree(iter->data);
999 ++ kfree(iter);
1000 ++ }
1001 + }
1002 + }
1003 +
1004 +diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
1005 +index 5b609e28ce3f..48703d430a2f 100644
1006 +--- a/arch/x86/kernel/kvmclock.c
1007 ++++ b/arch/x86/kernel/kvmclock.c
1008 +@@ -143,6 +143,7 @@ static unsigned long kvm_get_tsc_khz(void)
1009 + src = &hv_clock[cpu].pvti;
1010 + tsc_khz = pvclock_tsc_khz(src);
1011 + put_cpu();
1012 ++ setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
1013 + return tsc_khz;
1014 + }
1015 +
1016 +diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
1017 +index 5ebb0dbcf4f7..30447d210f37 100644
1018 +--- a/arch/x86/kernel/smpboot.c
1019 ++++ b/arch/x86/kernel/smpboot.c
1020 +@@ -223,6 +223,11 @@ static void notrace start_secondary(void *unused)
1021 + #ifdef CONFIG_X86_32
1022 + /* switch away from the initial page table */
1023 + load_cr3(swapper_pg_dir);
1024 ++ /*
1025 ++ * Initialize the CR4 shadow before doing anything that could
1026 ++ * try to read it.
1027 ++ */
1028 ++ cr4_init_shadow();
1029 + __flush_tlb_all();
1030 + #endif
1031 + load_current_idt();
1032 +diff --git a/block/sed-opal.c b/block/sed-opal.c
1033 +index 9ed51d0c6b1d..4f5e70d4abc3 100644
1034 +--- a/block/sed-opal.c
1035 ++++ b/block/sed-opal.c
1036 +@@ -877,7 +877,7 @@ static size_t response_get_string(const struct parsed_resp *resp, int n,
1037 + return 0;
1038 + }
1039 +
1040 +- if (n > resp->num) {
1041 ++ if (n >= resp->num) {
1042 + pr_debug("Response has %d tokens. Can't access %d\n",
1043 + resp->num, n);
1044 + return 0;
1045 +@@ -899,7 +899,7 @@ static u64 response_get_u64(const struct parsed_resp *resp, int n)
1046 + return 0;
1047 + }
1048 +
1049 +- if (n > resp->num) {
1050 ++ if (n >= resp->num) {
1051 + pr_debug("Response has %d tokens. Can't access %d\n",
1052 + resp->num, n);
1053 + return 0;
1054 +diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
1055 +index 58bc28aff3aa..3d624c72c6c2 100644
1056 +--- a/drivers/acpi/ec.c
1057 ++++ b/drivers/acpi/ec.c
1058 +@@ -2029,6 +2029,17 @@ static inline void acpi_ec_query_exit(void)
1059 + }
1060 + }
1061 +
1062 ++static const struct dmi_system_id acpi_ec_no_wakeup[] = {
1063 ++ {
1064 ++ .ident = "Thinkpad X1 Carbon 6th",
1065 ++ .matches = {
1066 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1067 ++ DMI_MATCH(DMI_PRODUCT_FAMILY, "Thinkpad X1 Carbon 6th"),
1068 ++ },
1069 ++ },
1070 ++ { },
1071 ++};
1072 ++
1073 + int __init acpi_ec_init(void)
1074 + {
1075 + int result;
1076 +@@ -2039,6 +2050,15 @@ int __init acpi_ec_init(void)
1077 + if (result)
1078 + return result;
1079 +
1080 ++ /*
1081 ++ * Disable EC wakeup on following systems to prevent periodic
1082 ++ * wakeup from EC GPE.
1083 ++ */
1084 ++ if (dmi_check_system(acpi_ec_no_wakeup)) {
1085 ++ ec_no_wakeup = true;
1086 ++ pr_debug("Disabling EC wakeup on suspend-to-idle\n");
1087 ++ }
1088 ++
1089 + /* Drivers must be started after acpi_ec_query_init() */
1090 + dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver);
1091 + /*
1092 +diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
1093 +index d56822f58ab1..8260b90eb64b 100644
1094 +--- a/drivers/acpi/nfit/core.c
1095 ++++ b/drivers/acpi/nfit/core.c
1096 +@@ -224,6 +224,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
1097 + const guid_t *guid;
1098 + int rc, i;
1099 +
1100 ++ if (cmd_rc)
1101 ++ *cmd_rc = -EINVAL;
1102 + func = cmd;
1103 + if (cmd == ND_CMD_CALL) {
1104 + call_pkg = buf;
1105 +@@ -314,6 +316,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
1106 + * If we return an error (like elsewhere) then caller wouldn't
1107 + * be able to rely upon data returned to make calculation.
1108 + */
1109 ++ if (cmd_rc)
1110 ++ *cmd_rc = 0;
1111 + return 0;
1112 + }
1113 +
1114 +diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
1115 +index 5ae268b8514e..bc562fd2b0a0 100644
1116 +--- a/drivers/ata/libahci.c
1117 ++++ b/drivers/ata/libahci.c
1118 +@@ -35,6 +35,7 @@
1119 + #include <linux/kernel.h>
1120 + #include <linux/gfp.h>
1121 + #include <linux/module.h>
1122 ++#include <linux/nospec.h>
1123 + #include <linux/blkdev.h>
1124 + #include <linux/delay.h>
1125 + #include <linux/interrupt.h>
1126 +@@ -1135,10 +1136,12 @@ static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
1127 +
1128 + /* get the slot number from the message */
1129 + pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
1130 +- if (pmp < EM_MAX_SLOTS)
1131 ++ if (pmp < EM_MAX_SLOTS) {
1132 ++ pmp = array_index_nospec(pmp, EM_MAX_SLOTS);
1133 + emp = &pp->em_priv[pmp];
1134 +- else
1135 ++ } else {
1136 + return -EINVAL;
1137 ++ }
1138 +
1139 + /* mask off the activity bits if we are in sw_activity
1140 + * mode, user should turn off sw_activity before setting
1141 +diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
1142 +index de8566e55334..c72071c300bb 100644
1143 +--- a/drivers/block/drbd/drbd_req.c
1144 ++++ b/drivers/block/drbd/drbd_req.c
1145 +@@ -1244,8 +1244,8 @@ drbd_request_prepare(struct drbd_device *device, struct bio *bio, unsigned long
1146 + _drbd_start_io_acct(device, req);
1147 +
1148 + /* process discards always from our submitter thread */
1149 +- if ((bio_op(bio) & REQ_OP_WRITE_ZEROES) ||
1150 +- (bio_op(bio) & REQ_OP_DISCARD))
1151 ++ if (bio_op(bio) == REQ_OP_WRITE_ZEROES ||
1152 ++ bio_op(bio) == REQ_OP_DISCARD)
1153 + goto queue_for_submitter_thread;
1154 +
1155 + if (rw == WRITE && req->private_bio && req->i.size
1156 +diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
1157 +index 6fb64e73bc96..5feba04ab940 100644
1158 +--- a/drivers/block/nbd.c
1159 ++++ b/drivers/block/nbd.c
1160 +@@ -76,6 +76,7 @@ struct link_dead_args {
1161 + #define NBD_HAS_CONFIG_REF 4
1162 + #define NBD_BOUND 5
1163 + #define NBD_DESTROY_ON_DISCONNECT 6
1164 ++#define NBD_DISCONNECT_ON_CLOSE 7
1165 +
1166 + struct nbd_config {
1167 + u32 flags;
1168 +@@ -138,6 +139,7 @@ static void nbd_config_put(struct nbd_device *nbd);
1169 + static void nbd_connect_reply(struct genl_info *info, int index);
1170 + static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info);
1171 + static void nbd_dead_link_work(struct work_struct *work);
1172 ++static void nbd_disconnect_and_put(struct nbd_device *nbd);
1173 +
1174 + static inline struct device *nbd_to_dev(struct nbd_device *nbd)
1175 + {
1176 +@@ -1291,6 +1293,12 @@ out:
1177 + static void nbd_release(struct gendisk *disk, fmode_t mode)
1178 + {
1179 + struct nbd_device *nbd = disk->private_data;
1180 ++ struct block_device *bdev = bdget_disk(disk, 0);
1181 ++
1182 ++ if (test_bit(NBD_DISCONNECT_ON_CLOSE, &nbd->config->runtime_flags) &&
1183 ++ bdev->bd_openers == 0)
1184 ++ nbd_disconnect_and_put(nbd);
1185 ++
1186 + nbd_config_put(nbd);
1187 + nbd_put(nbd);
1188 + }
1189 +@@ -1690,6 +1698,10 @@ again:
1190 + &config->runtime_flags);
1191 + put_dev = true;
1192 + }
1193 ++ if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) {
1194 ++ set_bit(NBD_DISCONNECT_ON_CLOSE,
1195 ++ &config->runtime_flags);
1196 ++ }
1197 + }
1198 +
1199 + if (info->attrs[NBD_ATTR_SOCKETS]) {
1200 +@@ -1734,6 +1746,16 @@ out:
1201 + return ret;
1202 + }
1203 +
1204 ++static void nbd_disconnect_and_put(struct nbd_device *nbd)
1205 ++{
1206 ++ mutex_lock(&nbd->config_lock);
1207 ++ nbd_disconnect(nbd);
1208 ++ mutex_unlock(&nbd->config_lock);
1209 ++ if (test_and_clear_bit(NBD_HAS_CONFIG_REF,
1210 ++ &nbd->config->runtime_flags))
1211 ++ nbd_config_put(nbd);
1212 ++}
1213 ++
1214 + static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
1215 + {
1216 + struct nbd_device *nbd;
1217 +@@ -1766,12 +1788,7 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
1218 + nbd_put(nbd);
1219 + return 0;
1220 + }
1221 +- mutex_lock(&nbd->config_lock);
1222 +- nbd_disconnect(nbd);
1223 +- mutex_unlock(&nbd->config_lock);
1224 +- if (test_and_clear_bit(NBD_HAS_CONFIG_REF,
1225 +- &nbd->config->runtime_flags))
1226 +- nbd_config_put(nbd);
1227 ++ nbd_disconnect_and_put(nbd);
1228 + nbd_config_put(nbd);
1229 + nbd_put(nbd);
1230 + return 0;
1231 +@@ -1782,7 +1799,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1232 + struct nbd_device *nbd = NULL;
1233 + struct nbd_config *config;
1234 + int index;
1235 +- int ret = -EINVAL;
1236 ++ int ret = 0;
1237 + bool put_dev = false;
1238 +
1239 + if (!netlink_capable(skb, CAP_SYS_ADMIN))
1240 +@@ -1822,6 +1839,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1241 + !nbd->task_recv) {
1242 + dev_err(nbd_to_dev(nbd),
1243 + "not configured, cannot reconfigure\n");
1244 ++ ret = -EINVAL;
1245 + goto out;
1246 + }
1247 +
1248 +@@ -1846,6 +1864,14 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1249 + &config->runtime_flags))
1250 + refcount_inc(&nbd->refs);
1251 + }
1252 ++
1253 ++ if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) {
1254 ++ set_bit(NBD_DISCONNECT_ON_CLOSE,
1255 ++ &config->runtime_flags);
1256 ++ } else {
1257 ++ clear_bit(NBD_DISCONNECT_ON_CLOSE,
1258 ++ &config->runtime_flags);
1259 ++ }
1260 + }
1261 +
1262 + if (info->attrs[NBD_ATTR_SOCKETS]) {
1263 +diff --git a/drivers/dax/device.c b/drivers/dax/device.c
1264 +index 7b0bf825c4e7..050e299129ac 100644
1265 +--- a/drivers/dax/device.c
1266 ++++ b/drivers/dax/device.c
1267 +@@ -188,14 +188,16 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma,
1268 +
1269 + /* prevent private mappings from being established */
1270 + if ((vma->vm_flags & VM_MAYSHARE) != VM_MAYSHARE) {
1271 +- dev_info(dev, "%s: %s: fail, attempted private mapping\n",
1272 ++ dev_info_ratelimited(dev,
1273 ++ "%s: %s: fail, attempted private mapping\n",
1274 + current->comm, func);
1275 + return -EINVAL;
1276 + }
1277 +
1278 + mask = dax_region->align - 1;
1279 + if (vma->vm_start & mask || vma->vm_end & mask) {
1280 +- dev_info(dev, "%s: %s: fail, unaligned vma (%#lx - %#lx, %#lx)\n",
1281 ++ dev_info_ratelimited(dev,
1282 ++ "%s: %s: fail, unaligned vma (%#lx - %#lx, %#lx)\n",
1283 + current->comm, func, vma->vm_start, vma->vm_end,
1284 + mask);
1285 + return -EINVAL;
1286 +@@ -203,13 +205,15 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma,
1287 +
1288 + if ((dax_region->pfn_flags & (PFN_DEV|PFN_MAP)) == PFN_DEV
1289 + && (vma->vm_flags & VM_DONTCOPY) == 0) {
1290 +- dev_info(dev, "%s: %s: fail, dax range requires MADV_DONTFORK\n",
1291 ++ dev_info_ratelimited(dev,
1292 ++ "%s: %s: fail, dax range requires MADV_DONTFORK\n",
1293 + current->comm, func);
1294 + return -EINVAL;
1295 + }
1296 +
1297 + if (!vma_is_dax(vma)) {
1298 +- dev_info(dev, "%s: %s: fail, vma is not DAX capable\n",
1299 ++ dev_info_ratelimited(dev,
1300 ++ "%s: %s: fail, vma is not DAX capable\n",
1301 + current->comm, func);
1302 + return -EINVAL;
1303 + }
1304 +diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
1305 +index 01d2a750a621..219ae3b545db 100644
1306 +--- a/drivers/dma/k3dma.c
1307 ++++ b/drivers/dma/k3dma.c
1308 +@@ -787,7 +787,7 @@ static struct dma_chan *k3_of_dma_simple_xlate(struct of_phandle_args *dma_spec,
1309 + struct k3_dma_dev *d = ofdma->of_dma_data;
1310 + unsigned int request = dma_spec->args[0];
1311 +
1312 +- if (request > d->dma_requests)
1313 ++ if (request >= d->dma_requests)
1314 + return NULL;
1315 +
1316 + return dma_get_slave_channel(&(d->chans[request].vc.chan));
1317 +diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
1318 +index 7432c8894e32..d19862f4dc9a 100644
1319 +--- a/drivers/dma/pl330.c
1320 ++++ b/drivers/dma/pl330.c
1321 +@@ -2923,7 +2923,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
1322 + pd->src_addr_widths = PL330_DMA_BUSWIDTHS;
1323 + pd->dst_addr_widths = PL330_DMA_BUSWIDTHS;
1324 + pd->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
1325 +- pd->residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
1326 ++ pd->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
1327 + pd->max_burst = ((pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) ?
1328 + 1 : PL330_MAX_BURST);
1329 +
1330 +diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
1331 +index 480072139b7a..80801c616395 100644
1332 +--- a/drivers/edac/edac_mc.c
1333 ++++ b/drivers/edac/edac_mc.c
1334 +@@ -215,6 +215,7 @@ const char * const edac_mem_types[] = {
1335 + [MEM_LRDDR3] = "Load-Reduced DDR3 RAM",
1336 + [MEM_DDR4] = "Unbuffered DDR4 RAM",
1337 + [MEM_RDDR4] = "Registered DDR4 RAM",
1338 ++ [MEM_LRDDR4] = "Load-Reduced-DDR4-RAM",
1339 + };
1340 + EXPORT_SYMBOL_GPL(edac_mem_types);
1341 +
1342 +diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
1343 +index 5183b46563f6..242dfb1433d2 100644
1344 +--- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
1345 ++++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
1346 +@@ -899,7 +899,7 @@ static const struct amdgpu_ring_funcs vce_v3_0_ring_phys_funcs = {
1347 + .emit_frame_size =
1348 + 4 + /* vce_v3_0_emit_pipeline_sync */
1349 + 6, /* amdgpu_vce_ring_emit_fence x1 no user fence */
1350 +- .emit_ib_size = 5, /* vce_v3_0_ring_emit_ib */
1351 ++ .emit_ib_size = 4, /* amdgpu_vce_ring_emit_ib */
1352 + .emit_ib = amdgpu_vce_ring_emit_ib,
1353 + .emit_fence = amdgpu_vce_ring_emit_fence,
1354 + .test_ring = amdgpu_vce_ring_test_ring,
1355 +@@ -923,7 +923,7 @@ static const struct amdgpu_ring_funcs vce_v3_0_ring_vm_funcs = {
1356 + 6 + /* vce_v3_0_emit_vm_flush */
1357 + 4 + /* vce_v3_0_emit_pipeline_sync */
1358 + 6 + 6, /* amdgpu_vce_ring_emit_fence x2 vm fence */
1359 +- .emit_ib_size = 4, /* amdgpu_vce_ring_emit_ib */
1360 ++ .emit_ib_size = 5, /* vce_v3_0_ring_emit_ib */
1361 + .emit_ib = vce_v3_0_ring_emit_ib,
1362 + .emit_vm_flush = vce_v3_0_emit_vm_flush,
1363 + .emit_pipeline_sync = vce_v3_0_emit_pipeline_sync,
1364 +diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c
1365 +index 17bca99e8ac8..7e2c341dfe5f 100644
1366 +--- a/drivers/gpu/drm/arm/malidp_hw.c
1367 ++++ b/drivers/gpu/drm/arm/malidp_hw.c
1368 +@@ -634,7 +634,8 @@ const struct malidp_hw_device malidp_device[MALIDP_MAX_DEVICES] = {
1369 + .vsync_irq = MALIDP500_DE_IRQ_VSYNC,
1370 + },
1371 + .se_irq_map = {
1372 +- .irq_mask = MALIDP500_SE_IRQ_CONF_MODE,
1373 ++ .irq_mask = MALIDP500_SE_IRQ_CONF_MODE |
1374 ++ MALIDP500_SE_IRQ_GLOBAL,
1375 + .vsync_irq = 0,
1376 + },
1377 + .dc_irq_map = {
1378 +diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
1379 +index 94e7e3fa3408..16b8b310ae5c 100644
1380 +--- a/drivers/gpu/drm/arm/malidp_planes.c
1381 ++++ b/drivers/gpu/drm/arm/malidp_planes.c
1382 +@@ -23,6 +23,7 @@
1383 +
1384 + /* Layer specific register offsets */
1385 + #define MALIDP_LAYER_FORMAT 0x000
1386 ++#define LAYER_FORMAT_MASK 0x3f
1387 + #define MALIDP_LAYER_CONTROL 0x004
1388 + #define LAYER_ENABLE (1 << 0)
1389 + #define LAYER_FLOWCFG_MASK 7
1390 +@@ -278,7 +279,9 @@ static void malidp_de_plane_update(struct drm_plane *plane,
1391 + dest_w = plane->state->crtc_w;
1392 + dest_h = plane->state->crtc_h;
1393 +
1394 +- malidp_hw_write(mp->hwdev, ms->format, mp->layer->base);
1395 ++ val = malidp_hw_read(mp->hwdev, mp->layer->base);
1396 ++ val = (val & ~LAYER_FORMAT_MASK) | ms->format;
1397 ++ malidp_hw_write(mp->hwdev, val, mp->layer->base);
1398 +
1399 + for (i = 0; i < ms->n_planes; i++) {
1400 + /* calculate the offset for the layer's plane registers */
1401 +diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
1402 +index 79ce877bf45f..3039936f8f3f 100644
1403 +--- a/drivers/gpu/drm/armada/armada_crtc.c
1404 ++++ b/drivers/gpu/drm/armada/armada_crtc.c
1405 +@@ -483,8 +483,9 @@ static irqreturn_t armada_drm_irq(int irq, void *arg)
1406 + u32 v, stat = readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
1407 +
1408 + /*
1409 +- * This is rediculous - rather than writing bits to clear, we
1410 +- * have to set the actual status register value. This is racy.
1411 ++ * Reading the ISR appears to clear bits provided CLEAN_SPU_IRQ_ISR
1412 ++ * is set. Writing has some other effect to acknowledge the IRQ -
1413 ++ * without this, we only get a single IRQ.
1414 + */
1415 + writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
1416 +
1417 +@@ -1104,16 +1105,22 @@ armada_drm_crtc_set_property(struct drm_crtc *crtc,
1418 + static int armada_drm_crtc_enable_vblank(struct drm_crtc *crtc)
1419 + {
1420 + struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
1421 ++ unsigned long flags;
1422 +
1423 ++ spin_lock_irqsave(&dcrtc->irq_lock, flags);
1424 + armada_drm_crtc_enable_irq(dcrtc, VSYNC_IRQ_ENA);
1425 ++ spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
1426 + return 0;
1427 + }
1428 +
1429 + static void armada_drm_crtc_disable_vblank(struct drm_crtc *crtc)
1430 + {
1431 + struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
1432 ++ unsigned long flags;
1433 +
1434 ++ spin_lock_irqsave(&dcrtc->irq_lock, flags);
1435 + armada_drm_crtc_disable_irq(dcrtc, VSYNC_IRQ_ENA);
1436 ++ spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
1437 + }
1438 +
1439 + static const struct drm_crtc_funcs armada_crtc_funcs = {
1440 +@@ -1221,6 +1228,7 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
1441 + CFG_PDWN64x66, dcrtc->base + LCD_SPU_SRAM_PARA1);
1442 + writel_relaxed(0x2032ff81, dcrtc->base + LCD_SPU_DMA_CTRL1);
1443 + writel_relaxed(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
1444 ++ readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
1445 + writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
1446 +
1447 + ret = devm_request_irq(dev, irq, armada_drm_irq, 0, "armada_drm_crtc",
1448 +diff --git a/drivers/gpu/drm/armada/armada_hw.h b/drivers/gpu/drm/armada/armada_hw.h
1449 +index 27319a8335e2..345dc4d0851e 100644
1450 +--- a/drivers/gpu/drm/armada/armada_hw.h
1451 ++++ b/drivers/gpu/drm/armada/armada_hw.h
1452 +@@ -160,6 +160,7 @@ enum {
1453 + CFG_ALPHAM_GRA = 0x1 << 16,
1454 + CFG_ALPHAM_CFG = 0x2 << 16,
1455 + CFG_ALPHA_MASK = 0xff << 8,
1456 ++#define CFG_ALPHA(x) ((x) << 8)
1457 + CFG_PIXCMD_MASK = 0xff,
1458 + };
1459 +
1460 +diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
1461 +index edc44910d79f..2076346b09ee 100644
1462 +--- a/drivers/gpu/drm/armada/armada_overlay.c
1463 ++++ b/drivers/gpu/drm/armada/armada_overlay.c
1464 +@@ -28,6 +28,7 @@ struct armada_ovl_plane_properties {
1465 + uint16_t contrast;
1466 + uint16_t saturation;
1467 + uint32_t colorkey_mode;
1468 ++ uint32_t colorkey_enable;
1469 + };
1470 +
1471 + struct armada_ovl_plane {
1472 +@@ -59,11 +60,13 @@ armada_ovl_update_attr(struct armada_ovl_plane_properties *prop,
1473 + writel_relaxed(0x00002000, dcrtc->base + LCD_SPU_CBSH_HUE);
1474 +
1475 + spin_lock_irq(&dcrtc->irq_lock);
1476 +- armada_updatel(prop->colorkey_mode | CFG_ALPHAM_GRA,
1477 +- CFG_CKMODE_MASK | CFG_ALPHAM_MASK | CFG_ALPHA_MASK,
1478 +- dcrtc->base + LCD_SPU_DMA_CTRL1);
1479 +-
1480 +- armada_updatel(ADV_GRACOLORKEY, 0, dcrtc->base + LCD_SPU_ADV_REG);
1481 ++ armada_updatel(prop->colorkey_mode,
1482 ++ CFG_CKMODE_MASK | CFG_ALPHAM_MASK | CFG_ALPHA_MASK,
1483 ++ dcrtc->base + LCD_SPU_DMA_CTRL1);
1484 ++ if (dcrtc->variant->has_spu_adv_reg)
1485 ++ armada_updatel(prop->colorkey_enable,
1486 ++ ADV_GRACOLORKEY | ADV_VIDCOLORKEY,
1487 ++ dcrtc->base + LCD_SPU_ADV_REG);
1488 + spin_unlock_irq(&dcrtc->irq_lock);
1489 + }
1490 +
1491 +@@ -339,8 +342,17 @@ static int armada_ovl_plane_set_property(struct drm_plane *plane,
1492 + dplane->prop.colorkey_vb |= K2B(val);
1493 + update_attr = true;
1494 + } else if (property == priv->colorkey_mode_prop) {
1495 +- dplane->prop.colorkey_mode &= ~CFG_CKMODE_MASK;
1496 +- dplane->prop.colorkey_mode |= CFG_CKMODE(val);
1497 ++ if (val == CKMODE_DISABLE) {
1498 ++ dplane->prop.colorkey_mode =
1499 ++ CFG_CKMODE(CKMODE_DISABLE) |
1500 ++ CFG_ALPHAM_CFG | CFG_ALPHA(255);
1501 ++ dplane->prop.colorkey_enable = 0;
1502 ++ } else {
1503 ++ dplane->prop.colorkey_mode =
1504 ++ CFG_CKMODE(val) |
1505 ++ CFG_ALPHAM_GRA | CFG_ALPHA(0);
1506 ++ dplane->prop.colorkey_enable = ADV_GRACOLORKEY;
1507 ++ }
1508 + update_attr = true;
1509 + } else if (property == priv->brightness_prop) {
1510 + dplane->prop.brightness = val - 256;
1511 +@@ -470,7 +482,9 @@ int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs)
1512 + dplane->prop.colorkey_yr = 0xfefefe00;
1513 + dplane->prop.colorkey_ug = 0x01010100;
1514 + dplane->prop.colorkey_vb = 0x01010100;
1515 +- dplane->prop.colorkey_mode = CFG_CKMODE(CKMODE_RGB);
1516 ++ dplane->prop.colorkey_mode = CFG_CKMODE(CKMODE_RGB) |
1517 ++ CFG_ALPHAM_GRA | CFG_ALPHA(0);
1518 ++ dplane->prop.colorkey_enable = ADV_GRACOLORKEY;
1519 + dplane->prop.brightness = 0;
1520 + dplane->prop.contrast = 0x4000;
1521 + dplane->prop.saturation = 0x4000;
1522 +diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
1523 +index 5131bfb94f06..0cb69ee94ac1 100644
1524 +--- a/drivers/gpu/drm/bridge/sil-sii8620.c
1525 ++++ b/drivers/gpu/drm/bridge/sil-sii8620.c
1526 +@@ -788,6 +788,7 @@ static void sii8620_burst_rx_all(struct sii8620 *ctx)
1527 + static void sii8620_fetch_edid(struct sii8620 *ctx)
1528 + {
1529 + u8 lm_ddc, ddc_cmd, int3, cbus;
1530 ++ unsigned long timeout;
1531 + int fetched, i;
1532 + int edid_len = EDID_LENGTH;
1533 + u8 *edid;
1534 +@@ -837,23 +838,31 @@ static void sii8620_fetch_edid(struct sii8620 *ctx)
1535 + REG_DDC_CMD, ddc_cmd | VAL_DDC_CMD_ENH_DDC_READ_NO_ACK
1536 + );
1537 +
1538 +- do {
1539 +- int3 = sii8620_readb(ctx, REG_INTR3);
1540 ++ int3 = 0;
1541 ++ timeout = jiffies + msecs_to_jiffies(200);
1542 ++ for (;;) {
1543 + cbus = sii8620_readb(ctx, REG_CBUS_STATUS);
1544 +-
1545 +- if (int3 & BIT_DDC_CMD_DONE)
1546 +- break;
1547 +-
1548 +- if (!(cbus & BIT_CBUS_STATUS_CBUS_CONNECTED)) {
1549 ++ if (~cbus & BIT_CBUS_STATUS_CBUS_CONNECTED) {
1550 ++ kfree(edid);
1551 ++ edid = NULL;
1552 ++ goto end;
1553 ++ }
1554 ++ if (int3 & BIT_DDC_CMD_DONE) {
1555 ++ if (sii8620_readb(ctx, REG_DDC_DOUT_CNT)
1556 ++ >= FETCH_SIZE)
1557 ++ break;
1558 ++ } else {
1559 ++ int3 = sii8620_readb(ctx, REG_INTR3);
1560 ++ }
1561 ++ if (time_is_before_jiffies(timeout)) {
1562 ++ ctx->error = -ETIMEDOUT;
1563 ++ dev_err(ctx->dev, "timeout during EDID read\n");
1564 + kfree(edid);
1565 + edid = NULL;
1566 + goto end;
1567 + }
1568 +- } while (1);
1569 +-
1570 +- sii8620_readb(ctx, REG_DDC_STATUS);
1571 +- while (sii8620_readb(ctx, REG_DDC_DOUT_CNT) < FETCH_SIZE)
1572 + usleep_range(10, 20);
1573 ++ }
1574 +
1575 + sii8620_read_buf(ctx, REG_DDC_DATA, edid + fetched, FETCH_SIZE);
1576 + if (fetched + FETCH_SIZE == EDID_LENGTH) {
1577 +@@ -1036,23 +1045,23 @@ static void sii8620_set_format(struct sii8620 *ctx)
1578 + BIT_M3_P0CTRL_MHL3_P0_PIXEL_MODE_PACKED,
1579 + ctx->use_packed_pixel ? ~0 : 0);
1580 + } else {
1581 +- if (ctx->use_packed_pixel)
1582 ++ if (ctx->use_packed_pixel) {
1583 + sii8620_write_seq_static(ctx,
1584 + REG_VID_MODE, BIT_VID_MODE_M1080P,
1585 + REG_MHL_TOP_CTL, BIT_MHL_TOP_CTL_MHL_PP_SEL | 1,
1586 + REG_MHLTX_CTL6, 0x60
1587 + );
1588 +- else
1589 ++ } else {
1590 + sii8620_write_seq_static(ctx,
1591 + REG_VID_MODE, 0,
1592 + REG_MHL_TOP_CTL, 1,
1593 + REG_MHLTX_CTL6, 0xa0
1594 + );
1595 ++ }
1596 + }
1597 +
1598 + if (ctx->use_packed_pixel)
1599 +- out_fmt = VAL_TPI_FORMAT(YCBCR422, FULL) |
1600 +- BIT_TPI_OUTPUT_CSCMODE709;
1601 ++ out_fmt = VAL_TPI_FORMAT(YCBCR422, FULL);
1602 + else
1603 + out_fmt = VAL_TPI_FORMAT(RGB, FULL);
1604 +
1605 +@@ -1187,7 +1196,7 @@ static void sii8620_start_hdmi(struct sii8620 *ctx)
1606 + int clk = ctx->pixel_clock * (ctx->use_packed_pixel ? 2 : 3);
1607 + int i;
1608 +
1609 +- for (i = 0; i < ARRAY_SIZE(clk_spec); ++i)
1610 ++ for (i = 0; i < ARRAY_SIZE(clk_spec) - 1; ++i)
1611 + if (clk < clk_spec[i].max_clk)
1612 + break;
1613 +
1614 +diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
1615 +index 6be5b53c3b27..f905c214fdd0 100644
1616 +--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
1617 ++++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
1618 +@@ -261,7 +261,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
1619 + unsigned long val;
1620 +
1621 + val = readl(ctx->addr + DECON_WINCONx(win));
1622 +- val &= ~WINCONx_BPPMODE_MASK;
1623 ++ val &= WINCONx_ENWIN_F;
1624 +
1625 + switch (fb->format->format) {
1626 + case DRM_FORMAT_XRGB1555:
1627 +@@ -352,8 +352,8 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
1628 + writel(val, ctx->addr + DECON_VIDOSDxB(win));
1629 + }
1630 +
1631 +- val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
1632 +- VIDOSD_Wx_ALPHA_B_F(0x0);
1633 ++ val = VIDOSD_Wx_ALPHA_R_F(0xff) | VIDOSD_Wx_ALPHA_G_F(0xff) |
1634 ++ VIDOSD_Wx_ALPHA_B_F(0xff);
1635 + writel(val, ctx->addr + DECON_VIDOSDxC(win));
1636 +
1637 + val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
1638 +diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
1639 +index 0506b2b17ac1..48f913d8208c 100644
1640 +--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
1641 ++++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
1642 +@@ -532,21 +532,25 @@ static int gsc_src_set_fmt(struct device *dev, u32 fmt)
1643 + GSC_IN_CHROMA_ORDER_CRCB);
1644 + break;
1645 + case DRM_FORMAT_NV21:
1646 ++ cfg |= (GSC_IN_CHROMA_ORDER_CRCB | GSC_IN_YUV420_2P);
1647 ++ break;
1648 + case DRM_FORMAT_NV61:
1649 +- cfg |= (GSC_IN_CHROMA_ORDER_CRCB |
1650 +- GSC_IN_YUV420_2P);
1651 ++ cfg |= (GSC_IN_CHROMA_ORDER_CRCB | GSC_IN_YUV422_2P);
1652 + break;
1653 + case DRM_FORMAT_YUV422:
1654 + cfg |= GSC_IN_YUV422_3P;
1655 + break;
1656 + case DRM_FORMAT_YUV420:
1657 ++ cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV420_3P);
1658 ++ break;
1659 + case DRM_FORMAT_YVU420:
1660 +- cfg |= GSC_IN_YUV420_3P;
1661 ++ cfg |= (GSC_IN_CHROMA_ORDER_CRCB | GSC_IN_YUV420_3P);
1662 + break;
1663 + case DRM_FORMAT_NV12:
1664 ++ cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV420_2P);
1665 ++ break;
1666 + case DRM_FORMAT_NV16:
1667 +- cfg |= (GSC_IN_CHROMA_ORDER_CBCR |
1668 +- GSC_IN_YUV420_2P);
1669 ++ cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV422_2P);
1670 + break;
1671 + default:
1672 + dev_err(ippdrv->dev, "invalid target yuv order 0x%x.\n", fmt);
1673 +@@ -806,18 +810,25 @@ static int gsc_dst_set_fmt(struct device *dev, u32 fmt)
1674 + GSC_OUT_CHROMA_ORDER_CRCB);
1675 + break;
1676 + case DRM_FORMAT_NV21:
1677 +- case DRM_FORMAT_NV61:
1678 + cfg |= (GSC_OUT_CHROMA_ORDER_CRCB | GSC_OUT_YUV420_2P);
1679 + break;
1680 ++ case DRM_FORMAT_NV61:
1681 ++ cfg |= (GSC_OUT_CHROMA_ORDER_CRCB | GSC_OUT_YUV422_2P);
1682 ++ break;
1683 + case DRM_FORMAT_YUV422:
1684 ++ cfg |= GSC_OUT_YUV422_3P;
1685 ++ break;
1686 + case DRM_FORMAT_YUV420:
1687 ++ cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV420_3P);
1688 ++ break;
1689 + case DRM_FORMAT_YVU420:
1690 +- cfg |= GSC_OUT_YUV420_3P;
1691 ++ cfg |= (GSC_OUT_CHROMA_ORDER_CRCB | GSC_OUT_YUV420_3P);
1692 + break;
1693 + case DRM_FORMAT_NV12:
1694 ++ cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV420_2P);
1695 ++ break;
1696 + case DRM_FORMAT_NV16:
1697 +- cfg |= (GSC_OUT_CHROMA_ORDER_CBCR |
1698 +- GSC_OUT_YUV420_2P);
1699 ++ cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV422_2P);
1700 + break;
1701 + default:
1702 + dev_err(ippdrv->dev, "invalid target yuv order 0x%x.\n", fmt);
1703 +diff --git a/drivers/gpu/drm/exynos/regs-gsc.h b/drivers/gpu/drm/exynos/regs-gsc.h
1704 +index 4704a993cbb7..16b39734115c 100644
1705 +--- a/drivers/gpu/drm/exynos/regs-gsc.h
1706 ++++ b/drivers/gpu/drm/exynos/regs-gsc.h
1707 +@@ -138,6 +138,7 @@
1708 + #define GSC_OUT_YUV420_3P (3 << 4)
1709 + #define GSC_OUT_YUV422_1P (4 << 4)
1710 + #define GSC_OUT_YUV422_2P (5 << 4)
1711 ++#define GSC_OUT_YUV422_3P (6 << 4)
1712 + #define GSC_OUT_YUV444 (7 << 4)
1713 + #define GSC_OUT_TILE_TYPE_MASK (1 << 2)
1714 + #define GSC_OUT_TILE_C_16x8 (0 << 2)
1715 +diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
1716 +index 9bf4045cd679..73c672fc17c4 100644
1717 +--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
1718 ++++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
1719 +@@ -42,6 +42,8 @@
1720 + #include <linux/vfio.h>
1721 + #include <linux/mdev.h>
1722 +
1723 ++#include <linux/nospec.h>
1724 ++
1725 + #include "i915_drv.h"
1726 + #include "gvt.h"
1727 +
1728 +@@ -953,7 +955,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
1729 + } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) {
1730 + struct vfio_region_info info;
1731 + struct vfio_info_cap caps = { .buf = NULL, .size = 0 };
1732 +- int i, ret;
1733 ++ unsigned int i;
1734 ++ int ret;
1735 + struct vfio_region_info_cap_sparse_mmap *sparse = NULL;
1736 + size_t size;
1737 + int nr_areas = 1;
1738 +@@ -1030,6 +1033,10 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
1739 + if (info.index >= VFIO_PCI_NUM_REGIONS +
1740 + vgpu->vdev.num_regions)
1741 + return -EINVAL;
1742 ++ info.index =
1743 ++ array_index_nospec(info.index,
1744 ++ VFIO_PCI_NUM_REGIONS +
1745 ++ vgpu->vdev.num_regions);
1746 +
1747 + i = info.index - VFIO_PCI_NUM_REGIONS;
1748 +
1749 +diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
1750 +index 2170534101ca..60ffb70bb908 100644
1751 +--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
1752 ++++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
1753 +@@ -599,7 +599,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
1754 + struct nouveau_bo *nvbo;
1755 + uint32_t data;
1756 +
1757 +- if (unlikely(r->bo_index > req->nr_buffers)) {
1758 ++ if (unlikely(r->bo_index >= req->nr_buffers)) {
1759 + NV_PRINTK(err, cli, "reloc bo index invalid\n");
1760 + ret = -EINVAL;
1761 + break;
1762 +@@ -609,7 +609,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
1763 + if (b->presumed.valid)
1764 + continue;
1765 +
1766 +- if (unlikely(r->reloc_bo_index > req->nr_buffers)) {
1767 ++ if (unlikely(r->reloc_bo_index >= req->nr_buffers)) {
1768 + NV_PRINTK(err, cli, "reloc container bo index invalid\n");
1769 + ret = -EINVAL;
1770 + break;
1771 +diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
1772 +index 0598b4c18c25..75b1c8c03ce9 100644
1773 +--- a/drivers/gpu/drm/tegra/drm.c
1774 ++++ b/drivers/gpu/drm/tegra/drm.c
1775 +@@ -470,7 +470,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
1776 + * unaligned offset is malformed and cause commands stream
1777 + * corruption on the buffer address relocation.
1778 + */
1779 +- if (offset & 3 || offset >= obj->gem.size) {
1780 ++ if (offset & 3 || offset > obj->gem.size) {
1781 + err = -EINVAL;
1782 + goto fail;
1783 + }
1784 +diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c
1785 +index db509ab8874e..acd99783bbca 100644
1786 +--- a/drivers/gpu/host1x/job.c
1787 ++++ b/drivers/gpu/host1x/job.c
1788 +@@ -686,7 +686,8 @@ void host1x_job_unpin(struct host1x_job *job)
1789 + for (i = 0; i < job->num_unpins; i++) {
1790 + struct host1x_job_unpin_data *unpin = &job->unpins[i];
1791 +
1792 +- if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) && host->domain) {
1793 ++ if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) &&
1794 ++ unpin->size && host->domain) {
1795 + iommu_unmap(host->domain, job->addr_phys[i],
1796 + unpin->size);
1797 + free_iova(&host->iova,
1798 +diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
1799 +index c401b5b63f4c..4c72e68637c2 100644
1800 +--- a/drivers/hid/wacom_wac.c
1801 ++++ b/drivers/hid/wacom_wac.c
1802 +@@ -3212,8 +3212,14 @@ void wacom_setup_device_quirks(struct wacom *wacom)
1803 + if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
1804 + features->device_type |= WACOM_DEVICETYPE_PAD;
1805 +
1806 +- features->x_max = 4096;
1807 +- features->y_max = 4096;
1808 ++ if (features->type == INTUOSHT2) {
1809 ++ features->x_max = features->x_max / 10;
1810 ++ features->y_max = features->y_max / 10;
1811 ++ }
1812 ++ else {
1813 ++ features->x_max = 4096;
1814 ++ features->y_max = 4096;
1815 ++ }
1816 + }
1817 + else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
1818 + features->device_type |= WACOM_DEVICETYPE_PAD;
1819 +diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
1820 +index f5f3f8cf57ea..5f87764d7015 100644
1821 +--- a/drivers/hwmon/nct6775.c
1822 ++++ b/drivers/hwmon/nct6775.c
1823 +@@ -4107,7 +4107,7 @@ static int nct6775_probe(struct platform_device *pdev)
1824 + * The temperature is already monitored if the respective bit in <mask>
1825 + * is set.
1826 + */
1827 +- for (i = 0; i < 32; i++) {
1828 ++ for (i = 0; i < 31; i++) {
1829 + if (!(data->temp_mask & BIT(i + 1)))
1830 + continue;
1831 + if (!reg_temp_alternate[i])
1832 +diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
1833 +index 75c6b98585ba..b73dd837fb53 100644
1834 +--- a/drivers/i2c/busses/i2c-imx.c
1835 ++++ b/drivers/i2c/busses/i2c-imx.c
1836 +@@ -665,9 +665,6 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx,
1837 + struct imx_i2c_dma *dma = i2c_imx->dma;
1838 + struct device *dev = &i2c_imx->adapter.dev;
1839 +
1840 +- temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
1841 +- temp |= I2CR_DMAEN;
1842 +- imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
1843 +
1844 + dma->chan_using = dma->chan_rx;
1845 + dma->dma_transfer_dir = DMA_DEV_TO_MEM;
1846 +@@ -780,6 +777,7 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, bo
1847 + int i, result;
1848 + unsigned int temp;
1849 + int block_data = msgs->flags & I2C_M_RECV_LEN;
1850 ++ int use_dma = i2c_imx->dma && msgs->len >= DMA_THRESHOLD && !block_data;
1851 +
1852 + dev_dbg(&i2c_imx->adapter.dev,
1853 + "<%s> write slave address: addr=0x%x\n",
1854 +@@ -806,12 +804,14 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, bo
1855 + */
1856 + if ((msgs->len - 1) || block_data)
1857 + temp &= ~I2CR_TXAK;
1858 ++ if (use_dma)
1859 ++ temp |= I2CR_DMAEN;
1860 + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
1861 + imx_i2c_read_reg(i2c_imx, IMX_I2C_I2DR); /* dummy read */
1862 +
1863 + dev_dbg(&i2c_imx->adapter.dev, "<%s> read data\n", __func__);
1864 +
1865 +- if (i2c_imx->dma && msgs->len >= DMA_THRESHOLD && !block_data)
1866 ++ if (use_dma)
1867 + return i2c_imx_dma_read(i2c_imx, msgs, is_lastmsg);
1868 +
1869 + /* read data */
1870 +diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
1871 +index a9126b3cda61..847d9bf6744c 100644
1872 +--- a/drivers/i2c/i2c-core-acpi.c
1873 ++++ b/drivers/i2c/i2c-core-acpi.c
1874 +@@ -475,11 +475,16 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
1875 + msgs[0].buf = buffer;
1876 +
1877 + ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
1878 +- if (ret < 0)
1879 +- dev_err(&client->adapter->dev, "i2c write failed\n");
1880 +
1881 + kfree(buffer);
1882 +- return ret;
1883 ++
1884 ++ if (ret < 0) {
1885 ++ dev_err(&client->adapter->dev, "i2c write failed: %d\n", ret);
1886 ++ return ret;
1887 ++ }
1888 ++
1889 ++ /* 1 transfer must have completed successfully */
1890 ++ return (ret == 1) ? 0 : -EIO;
1891 + }
1892 +
1893 + static acpi_status
1894 +diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
1895 +index 8f26428804a2..5f625ffa2a88 100644
1896 +--- a/drivers/iio/pressure/bmp280-core.c
1897 ++++ b/drivers/iio/pressure/bmp280-core.c
1898 +@@ -362,10 +362,9 @@ static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2)
1899 + }
1900 + comp_humidity = bmp280_compensate_humidity(data, adc_humidity);
1901 +
1902 +- *val = comp_humidity;
1903 +- *val2 = 1024;
1904 ++ *val = comp_humidity * 1000 / 1024;
1905 +
1906 +- return IIO_VAL_FRACTIONAL;
1907 ++ return IIO_VAL_INT;
1908 + }
1909 +
1910 + static int bmp280_read_raw(struct iio_dev *indio_dev,
1911 +diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
1912 +index 1587cedee13e..761d3ce6a63a 100644
1913 +--- a/drivers/infiniband/hw/mlx4/mr.c
1914 ++++ b/drivers/infiniband/hw/mlx4/mr.c
1915 +@@ -247,8 +247,11 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
1916 + }
1917 +
1918 + if (flags & IB_MR_REREG_ACCESS) {
1919 +- if (ib_access_writable(mr_access_flags) && !mmr->umem->writable)
1920 +- return -EPERM;
1921 ++ if (ib_access_writable(mr_access_flags) &&
1922 ++ !mmr->umem->writable) {
1923 ++ err = -EPERM;
1924 ++ goto release_mpt_entry;
1925 ++ }
1926 +
1927 + err = mlx4_mr_hw_change_access(dev->dev, *pmpt_entry,
1928 + convert_access(mr_access_flags));
1929 +diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
1930 +index 3c7522d025f2..93d67d97c279 100644
1931 +--- a/drivers/infiniband/hw/mlx5/srq.c
1932 ++++ b/drivers/infiniband/hw/mlx5/srq.c
1933 +@@ -266,18 +266,24 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
1934 +
1935 + desc_size = sizeof(struct mlx5_wqe_srq_next_seg) +
1936 + srq->msrq.max_gs * sizeof(struct mlx5_wqe_data_seg);
1937 +- if (desc_size == 0 || srq->msrq.max_gs > desc_size)
1938 +- return ERR_PTR(-EINVAL);
1939 ++ if (desc_size == 0 || srq->msrq.max_gs > desc_size) {
1940 ++ err = -EINVAL;
1941 ++ goto err_srq;
1942 ++ }
1943 + desc_size = roundup_pow_of_two(desc_size);
1944 + desc_size = max_t(size_t, 32, desc_size);
1945 +- if (desc_size < sizeof(struct mlx5_wqe_srq_next_seg))
1946 +- return ERR_PTR(-EINVAL);
1947 ++ if (desc_size < sizeof(struct mlx5_wqe_srq_next_seg)) {
1948 ++ err = -EINVAL;
1949 ++ goto err_srq;
1950 ++ }
1951 + srq->msrq.max_avail_gather = (desc_size - sizeof(struct mlx5_wqe_srq_next_seg)) /
1952 + sizeof(struct mlx5_wqe_data_seg);
1953 + srq->msrq.wqe_shift = ilog2(desc_size);
1954 + buf_size = srq->msrq.max * desc_size;
1955 +- if (buf_size < desc_size)
1956 +- return ERR_PTR(-EINVAL);
1957 ++ if (buf_size < desc_size) {
1958 ++ err = -EINVAL;
1959 ++ goto err_srq;
1960 ++ }
1961 + in.type = init_attr->srq_type;
1962 +
1963 + if (pd->uobject)
1964 +diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c
1965 +index 54cc9cb1e3b7..de853bcc2384 100644
1966 +--- a/drivers/infiniband/sw/rxe/rxe_req.c
1967 ++++ b/drivers/infiniband/sw/rxe/rxe_req.c
1968 +@@ -645,6 +645,9 @@ next_wqe:
1969 + } else {
1970 + goto exit;
1971 + }
1972 ++ if ((wqe->wr.send_flags & IB_SEND_SIGNALED) ||
1973 ++ qp->sq_sig_type == IB_SIGNAL_ALL_WR)
1974 ++ rxe_run_task(&qp->comp.task, 1);
1975 + qp->req.wqe_index = next_index(qp->sq.queue,
1976 + qp->req.wqe_index);
1977 + goto next_wqe;
1978 +diff --git a/drivers/input/rmi4/rmi_2d_sensor.c b/drivers/input/rmi4/rmi_2d_sensor.c
1979 +index 8bb866c7b985..8eeffa066022 100644
1980 +--- a/drivers/input/rmi4/rmi_2d_sensor.c
1981 ++++ b/drivers/input/rmi4/rmi_2d_sensor.c
1982 +@@ -32,15 +32,15 @@ void rmi_2d_sensor_abs_process(struct rmi_2d_sensor *sensor,
1983 + if (obj->type == RMI_2D_OBJECT_NONE)
1984 + return;
1985 +
1986 +- if (axis_align->swap_axes)
1987 +- swap(obj->x, obj->y);
1988 +-
1989 + if (axis_align->flip_x)
1990 + obj->x = sensor->max_x - obj->x;
1991 +
1992 + if (axis_align->flip_y)
1993 + obj->y = sensor->max_y - obj->y;
1994 +
1995 ++ if (axis_align->swap_axes)
1996 ++ swap(obj->x, obj->y);
1997 ++
1998 + /*
1999 + * Here checking if X offset or y offset are specified is
2000 + * redundant. We just add the offsets or clip the values.
2001 +@@ -120,15 +120,15 @@ void rmi_2d_sensor_rel_report(struct rmi_2d_sensor *sensor, int x, int y)
2002 + x = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)x));
2003 + y = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)y));
2004 +
2005 +- if (axis_align->swap_axes)
2006 +- swap(x, y);
2007 +-
2008 + if (axis_align->flip_x)
2009 + x = min(RMI_2D_REL_POS_MAX, -x);
2010 +
2011 + if (axis_align->flip_y)
2012 + y = min(RMI_2D_REL_POS_MAX, -y);
2013 +
2014 ++ if (axis_align->swap_axes)
2015 ++ swap(x, y);
2016 ++
2017 + if (x || y) {
2018 + input_report_rel(sensor->input, REL_X, x);
2019 + input_report_rel(sensor->input, REL_Y, y);
2020 +@@ -141,17 +141,10 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
2021 + struct input_dev *input = sensor->input;
2022 + int res_x;
2023 + int res_y;
2024 ++ int max_x, max_y;
2025 + int input_flags = 0;
2026 +
2027 + if (sensor->report_abs) {
2028 +- if (sensor->axis_align.swap_axes) {
2029 +- swap(sensor->max_x, sensor->max_y);
2030 +- swap(sensor->axis_align.clip_x_low,
2031 +- sensor->axis_align.clip_y_low);
2032 +- swap(sensor->axis_align.clip_x_high,
2033 +- sensor->axis_align.clip_y_high);
2034 +- }
2035 +-
2036 + sensor->min_x = sensor->axis_align.clip_x_low;
2037 + if (sensor->axis_align.clip_x_high)
2038 + sensor->max_x = min(sensor->max_x,
2039 +@@ -163,14 +156,19 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
2040 + sensor->axis_align.clip_y_high);
2041 +
2042 + set_bit(EV_ABS, input->evbit);
2043 +- input_set_abs_params(input, ABS_MT_POSITION_X, 0, sensor->max_x,
2044 +- 0, 0);
2045 +- input_set_abs_params(input, ABS_MT_POSITION_Y, 0, sensor->max_y,
2046 +- 0, 0);
2047 ++
2048 ++ max_x = sensor->max_x;
2049 ++ max_y = sensor->max_y;
2050 ++ if (sensor->axis_align.swap_axes)
2051 ++ swap(max_x, max_y);
2052 ++ input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_x, 0, 0);
2053 ++ input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
2054 +
2055 + if (sensor->x_mm && sensor->y_mm) {
2056 + res_x = (sensor->max_x - sensor->min_x) / sensor->x_mm;
2057 + res_y = (sensor->max_y - sensor->min_y) / sensor->y_mm;
2058 ++ if (sensor->axis_align.swap_axes)
2059 ++ swap(res_x, res_y);
2060 +
2061 + input_abs_set_res(input, ABS_X, res_x);
2062 + input_abs_set_res(input, ABS_Y, res_y);
2063 +diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
2064 +index b20c23f970f4..262a0f0f8fd5 100644
2065 +--- a/drivers/md/raid10.c
2066 ++++ b/drivers/md/raid10.c
2067 +@@ -3754,6 +3754,13 @@ static int raid10_run(struct mddev *mddev)
2068 + disk->rdev->saved_raid_disk < 0)
2069 + conf->fullsync = 1;
2070 + }
2071 ++
2072 ++ if (disk->replacement &&
2073 ++ !test_bit(In_sync, &disk->replacement->flags) &&
2074 ++ disk->replacement->saved_raid_disk < 0) {
2075 ++ conf->fullsync = 1;
2076 ++ }
2077 ++
2078 + disk->recovery_disabled = mddev->recovery_disabled - 1;
2079 + }
2080 +
2081 +diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
2082 +index 5dc8bd042cc5..504e34f29518 100644
2083 +--- a/drivers/mtd/devices/mtd_dataflash.c
2084 ++++ b/drivers/mtd/devices/mtd_dataflash.c
2085 +@@ -737,8 +737,8 @@ static struct flash_info dataflash_data[] = {
2086 + { "AT45DB642x", 0x1f2800, 8192, 1056, 11, SUP_POW2PS},
2087 + { "at45db642d", 0x1f2800, 8192, 1024, 10, SUP_POW2PS | IS_POW2PS},
2088 +
2089 +- { "AT45DB641E", 0x1f28000100, 32768, 264, 9, SUP_EXTID | SUP_POW2PS},
2090 +- { "at45db641e", 0x1f28000100, 32768, 256, 8, SUP_EXTID | SUP_POW2PS | IS_POW2PS},
2091 ++ { "AT45DB641E", 0x1f28000100ULL, 32768, 264, 9, SUP_EXTID | SUP_POW2PS},
2092 ++ { "at45db641e", 0x1f28000100ULL, 32768, 256, 8, SUP_EXTID | SUP_POW2PS | IS_POW2PS},
2093 + };
2094 +
2095 + static struct flash_info *jedec_lookup(struct spi_device *spi,
2096 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
2097 +index 352beff796ae..828e2e56b75e 100644
2098 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
2099 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
2100 +@@ -1529,6 +1529,7 @@ struct bnx2x {
2101 + struct link_vars link_vars;
2102 + u32 link_cnt;
2103 + struct bnx2x_link_report_data last_reported_link;
2104 ++ bool force_link_down;
2105 +
2106 + struct mdio_if_info mdio;
2107 +
2108 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
2109 +index 6465414dad74..8498a357d389 100644
2110 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
2111 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
2112 +@@ -1260,6 +1260,11 @@ void __bnx2x_link_report(struct bnx2x *bp)
2113 + {
2114 + struct bnx2x_link_report_data cur_data;
2115 +
2116 ++ if (bp->force_link_down) {
2117 ++ bp->link_vars.link_up = 0;
2118 ++ return;
2119 ++ }
2120 ++
2121 + /* reread mf_cfg */
2122 + if (IS_PF(bp) && !CHIP_IS_E1(bp))
2123 + bnx2x_read_mf_cfg(bp);
2124 +@@ -2817,6 +2822,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
2125 + bp->pending_max = 0;
2126 + }
2127 +
2128 ++ bp->force_link_down = false;
2129 + if (bp->port.pmf) {
2130 + rc = bnx2x_initial_phy_init(bp, load_mode);
2131 + if (rc)
2132 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
2133 +index e855a271db48..bd3e3f080ebf 100644
2134 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
2135 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
2136 +@@ -10279,6 +10279,12 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work)
2137 + bp->sp_rtnl_state = 0;
2138 + smp_mb();
2139 +
2140 ++ /* Immediately indicate link as down */
2141 ++ bp->link_vars.link_up = 0;
2142 ++ bp->force_link_down = true;
2143 ++ netif_carrier_off(bp->dev);
2144 ++ BNX2X_ERR("Indicating link is down due to Tx-timeout\n");
2145 ++
2146 + bnx2x_nic_unload(bp, UNLOAD_NORMAL, true);
2147 + bnx2x_nic_load(bp, LOAD_NORMAL);
2148 +
2149 +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2150 +index 94931318587c..937db8019289 100644
2151 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2152 ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2153 +@@ -6348,7 +6348,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
2154 + rc = bnxt_request_irq(bp);
2155 + if (rc) {
2156 + netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc);
2157 +- goto open_err;
2158 ++ goto open_err_irq;
2159 + }
2160 + }
2161 +
2162 +@@ -6386,6 +6386,8 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
2163 +
2164 + open_err:
2165 + bnxt_disable_napi(bp);
2166 ++
2167 ++open_err_irq:
2168 + bnxt_del_napi(bp);
2169 +
2170 + open_err_free_mem:
2171 +@@ -7866,11 +7868,11 @@ int bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx, bool shared)
2172 + int rx, tx, cp;
2173 +
2174 + _bnxt_get_max_rings(bp, &rx, &tx, &cp);
2175 ++ *max_rx = rx;
2176 ++ *max_tx = tx;
2177 + if (!rx || !tx || !cp)
2178 + return -ENOMEM;
2179 +
2180 +- *max_rx = rx;
2181 +- *max_tx = tx;
2182 + return bnxt_trim_rings(bp, max_rx, max_tx, cp, shared);
2183 + }
2184 +
2185 +@@ -7884,8 +7886,11 @@ static int bnxt_get_dflt_rings(struct bnxt *bp, int *max_rx, int *max_tx,
2186 + /* Not enough rings, try disabling agg rings. */
2187 + bp->flags &= ~BNXT_FLAG_AGG_RINGS;
2188 + rc = bnxt_get_max_rings(bp, max_rx, max_tx, shared);
2189 +- if (rc)
2190 ++ if (rc) {
2191 ++ /* set BNXT_FLAG_AGG_RINGS back for consistency */
2192 ++ bp->flags |= BNXT_FLAG_AGG_RINGS;
2193 + return rc;
2194 ++ }
2195 + bp->flags |= BNXT_FLAG_NO_AGG_RINGS;
2196 + bp->dev->hw_features &= ~NETIF_F_LRO;
2197 + bp->dev->features &= ~NETIF_F_LRO;
2198 +diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
2199 +index 2887bcaf6af5..45c51277e0cf 100644
2200 +--- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
2201 ++++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
2202 +@@ -643,13 +643,21 @@ static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr)
2203 + static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
2204 + {
2205 + struct octeon_mgmt *p = netdev_priv(netdev);
2206 +- int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM;
2207 ++ int max_packet = new_mtu + ETH_HLEN + ETH_FCS_LEN;
2208 +
2209 + netdev->mtu = new_mtu;
2210 +
2211 +- cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, size_without_fcs);
2212 ++ /* HW lifts the limit if the frame is VLAN tagged
2213 ++ * (+4 bytes per each tag, up to two tags)
2214 ++ */
2215 ++ cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, max_packet);
2216 ++ /* Set the hardware to truncate packets larger than the MTU. The jabber
2217 ++ * register must be set to a multiple of 8 bytes, so round up. JABBER is
2218 ++ * an unconditional limit, so we need to account for two possible VLAN
2219 ++ * tags.
2220 ++ */
2221 + cvmx_write_csr(p->agl + AGL_GMX_RX_JABBER,
2222 +- (size_without_fcs + 7) & 0xfff8);
2223 ++ (max_packet + 7 + VLAN_HLEN * 2) & 0xfff8);
2224 +
2225 + return 0;
2226 + }
2227 +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2228 +index 44a0d04dd8a0..74a42f12064b 100644
2229 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2230 ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2231 +@@ -253,7 +253,7 @@ static void dcb_tx_queue_prio_enable(struct net_device *dev, int enable)
2232 + "Can't %s DCB Priority on port %d, TX Queue %d: err=%d\n",
2233 + enable ? "set" : "unset", pi->port_id, i, -err);
2234 + else
2235 +- txq->dcb_prio = value;
2236 ++ txq->dcb_prio = enable ? value : 0;
2237 + }
2238 + }
2239 +
2240 +diff --git a/drivers/net/ethernet/cisco/enic/enic_clsf.c b/drivers/net/ethernet/cisco/enic/enic_clsf.c
2241 +index 8dc21c9f9716..df613a87ccff 100644
2242 +--- a/drivers/net/ethernet/cisco/enic/enic_clsf.c
2243 ++++ b/drivers/net/ethernet/cisco/enic/enic_clsf.c
2244 +@@ -79,7 +79,6 @@ void enic_rfs_flw_tbl_init(struct enic *enic)
2245 + enic->rfs_h.max = enic->config.num_arfs;
2246 + enic->rfs_h.free = enic->rfs_h.max;
2247 + enic->rfs_h.toclean = 0;
2248 +- enic_rfs_timer_start(enic);
2249 + }
2250 +
2251 + void enic_rfs_flw_tbl_free(struct enic *enic)
2252 +@@ -88,7 +87,6 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
2253 +
2254 + enic_rfs_timer_stop(enic);
2255 + spin_lock_bh(&enic->rfs_h.lock);
2256 +- enic->rfs_h.free = 0;
2257 + for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) {
2258 + struct hlist_head *hhead;
2259 + struct hlist_node *tmp;
2260 +@@ -99,6 +97,7 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
2261 + enic_delfltr(enic, n->fltr_id);
2262 + hlist_del(&n->node);
2263 + kfree(n);
2264 ++ enic->rfs_h.free++;
2265 + }
2266 + }
2267 + spin_unlock_bh(&enic->rfs_h.lock);
2268 +diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
2269 +index a03a32a4ffca..800edfbd36c1 100644
2270 +--- a/drivers/net/ethernet/cisco/enic/enic_main.c
2271 ++++ b/drivers/net/ethernet/cisco/enic/enic_main.c
2272 +@@ -1930,7 +1930,7 @@ static int enic_open(struct net_device *netdev)
2273 + vnic_intr_unmask(&enic->intr[i]);
2274 +
2275 + enic_notify_timer_start(enic);
2276 +- enic_rfs_flw_tbl_init(enic);
2277 ++ enic_rfs_timer_start(enic);
2278 +
2279 + return 0;
2280 +
2281 +@@ -2854,6 +2854,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2282 + enic->notify_timer.function = enic_notify_timer;
2283 + enic->notify_timer.data = (unsigned long)enic;
2284 +
2285 ++ enic_rfs_flw_tbl_init(enic);
2286 + enic_set_rx_coal_setting(enic);
2287 + INIT_WORK(&enic->reset, enic_reset);
2288 + INIT_WORK(&enic->tx_hang_reset, enic_tx_hang_reset);
2289 +diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
2290 +index 519a021c0a25..a202c50d6fc7 100644
2291 +--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
2292 ++++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
2293 +@@ -125,6 +125,9 @@ MODULE_PARM_DESC(tx_timeout, "The Tx timeout in ms");
2294 + /* Default alignment for start of data in an Rx FD */
2295 + #define DPAA_FD_DATA_ALIGNMENT 16
2296 +
2297 ++/* The DPAA requires 256 bytes reserved and mapped for the SGT */
2298 ++#define DPAA_SGT_SIZE 256
2299 ++
2300 + /* Values for the L3R field of the FM Parse Results
2301 + */
2302 + /* L3 Type field: First IP Present IPv4 */
2303 +@@ -1622,8 +1625,8 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct dpaa_priv *priv,
2304 +
2305 + if (unlikely(qm_fd_get_format(fd) == qm_fd_sg)) {
2306 + nr_frags = skb_shinfo(skb)->nr_frags;
2307 +- dma_unmap_single(dev, addr, qm_fd_get_offset(fd) +
2308 +- sizeof(struct qm_sg_entry) * (1 + nr_frags),
2309 ++ dma_unmap_single(dev, addr,
2310 ++ qm_fd_get_offset(fd) + DPAA_SGT_SIZE,
2311 + dma_dir);
2312 +
2313 + /* The sgt buffer has been allocated with netdev_alloc_frag(),
2314 +@@ -1907,8 +1910,7 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
2315 + void *sgt_buf;
2316 +
2317 + /* get a page frag to store the SGTable */
2318 +- sz = SKB_DATA_ALIGN(priv->tx_headroom +
2319 +- sizeof(struct qm_sg_entry) * (1 + nr_frags));
2320 ++ sz = SKB_DATA_ALIGN(priv->tx_headroom + DPAA_SGT_SIZE);
2321 + sgt_buf = netdev_alloc_frag(sz);
2322 + if (unlikely(!sgt_buf)) {
2323 + netdev_err(net_dev, "netdev_alloc_frag() failed for size %d\n",
2324 +@@ -1976,9 +1978,8 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
2325 + skbh = (struct sk_buff **)buffer_start;
2326 + *skbh = skb;
2327 +
2328 +- addr = dma_map_single(dev, buffer_start, priv->tx_headroom +
2329 +- sizeof(struct qm_sg_entry) * (1 + nr_frags),
2330 +- dma_dir);
2331 ++ addr = dma_map_single(dev, buffer_start,
2332 ++ priv->tx_headroom + DPAA_SGT_SIZE, dma_dir);
2333 + if (unlikely(dma_mapping_error(dev, addr))) {
2334 + dev_err(dev, "DMA mapping failed");
2335 + err = -EINVAL;
2336 +diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c b/drivers/net/ethernet/freescale/fman/fman_port.c
2337 +index 1789b206be58..495190764155 100644
2338 +--- a/drivers/net/ethernet/freescale/fman/fman_port.c
2339 ++++ b/drivers/net/ethernet/freescale/fman/fman_port.c
2340 +@@ -324,6 +324,10 @@ struct fman_port_qmi_regs {
2341 + #define HWP_HXS_PHE_REPORT 0x00000800
2342 + #define HWP_HXS_PCAC_PSTAT 0x00000100
2343 + #define HWP_HXS_PCAC_PSTOP 0x00000001
2344 ++#define HWP_HXS_TCP_OFFSET 0xA
2345 ++#define HWP_HXS_UDP_OFFSET 0xB
2346 ++#define HWP_HXS_SH_PAD_REM 0x80000000
2347 ++
2348 + struct fman_port_hwp_regs {
2349 + struct {
2350 + u32 ssa; /* Soft Sequence Attachment */
2351 +@@ -728,6 +732,10 @@ static void init_hwp(struct fman_port *port)
2352 + iowrite32be(0xffffffff, &regs->pmda[i].lcv);
2353 + }
2354 +
2355 ++ /* Short packet padding removal from checksum calculation */
2356 ++ iowrite32be(HWP_HXS_SH_PAD_REM, &regs->pmda[HWP_HXS_TCP_OFFSET].ssa);
2357 ++ iowrite32be(HWP_HXS_SH_PAD_REM, &regs->pmda[HWP_HXS_UDP_OFFSET].ssa);
2358 ++
2359 + start_port_hwp(port);
2360 + }
2361 +
2362 +diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
2363 +index 98493be7b4af..046af22a37cb 100644
2364 +--- a/drivers/net/ethernet/ibm/ibmvnic.c
2365 ++++ b/drivers/net/ethernet/ibm/ibmvnic.c
2366 +@@ -1463,8 +1463,8 @@ static int do_reset(struct ibmvnic_adapter *adapter,
2367 +
2368 + rc = ibmvnic_login(netdev);
2369 + if (rc) {
2370 +- adapter->state = VNIC_PROBED;
2371 +- return 0;
2372 ++ adapter->state = reset_state;
2373 ++ return rc;
2374 + }
2375 +
2376 + rc = reset_tx_pools(adapter);
2377 +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
2378 +index 64429a14c630..815284fe9324 100644
2379 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
2380 ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
2381 +@@ -1895,7 +1895,12 @@ s32 ixgbe_set_rar_generic(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
2382 + if (enable_addr != 0)
2383 + rar_high |= IXGBE_RAH_AV;
2384 +
2385 ++ /* Record lower 32 bits of MAC address and then make
2386 ++ * sure that write is flushed to hardware before writing
2387 ++ * the upper 16 bits and setting the valid bit.
2388 ++ */
2389 + IXGBE_WRITE_REG(hw, IXGBE_RAL(index), rar_low);
2390 ++ IXGBE_WRITE_FLUSH(hw);
2391 + IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
2392 +
2393 + return 0;
2394 +@@ -1927,8 +1932,13 @@ s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index)
2395 + rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));
2396 + rar_high &= ~(0x0000FFFF | IXGBE_RAH_AV);
2397 +
2398 +- IXGBE_WRITE_REG(hw, IXGBE_RAL(index), 0);
2399 ++ /* Clear the address valid bit and upper 16 bits of the address
2400 ++ * before clearing the lower bits. This way we aren't updating
2401 ++ * a live filter.
2402 ++ */
2403 + IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
2404 ++ IXGBE_WRITE_FLUSH(hw);
2405 ++ IXGBE_WRITE_REG(hw, IXGBE_RAL(index), 0);
2406 +
2407 + /* clear VMDq pool/queue selection for this RAR */
2408 + hw->mac.ops.clear_vmdq(hw, index, IXGBE_CLEAR_VMDQ_ALL);
2409 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
2410 +index f697084937c3..de72b66df3e5 100644
2411 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
2412 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
2413 +@@ -1525,17 +1525,15 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, int vport_num)
2414 + }
2415 +
2416 + /* Public E-Switch API */
2417 +-#define ESW_ALLOWED(esw) ((esw) && MLX5_VPORT_MANAGER((esw)->dev))
2418 ++#define ESW_ALLOWED(esw) ((esw) && MLX5_ESWITCH_MANAGER((esw)->dev))
2419 ++
2420 +
2421 + int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
2422 + {
2423 + int err;
2424 + int i, enabled_events;
2425 +
2426 +- if (!ESW_ALLOWED(esw))
2427 +- return 0;
2428 +-
2429 +- if (!MLX5_ESWITCH_MANAGER(esw->dev) ||
2430 ++ if (!ESW_ALLOWED(esw) ||
2431 + !MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ft_support)) {
2432 + esw_warn(esw->dev, "E-Switch FDB is not supported, aborting ...\n");
2433 + return -EOPNOTSUPP;
2434 +@@ -1728,7 +1726,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
2435 + u64 node_guid;
2436 + int err = 0;
2437 +
2438 +- if (!ESW_ALLOWED(esw))
2439 ++ if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
2440 + return -EPERM;
2441 + if (!LEGAL_VPORT(esw, vport) || is_multicast_ether_addr(mac))
2442 + return -EINVAL;
2443 +@@ -1805,7 +1803,7 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
2444 + {
2445 + struct mlx5_vport *evport;
2446 +
2447 +- if (!ESW_ALLOWED(esw))
2448 ++ if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
2449 + return -EPERM;
2450 + if (!LEGAL_VPORT(esw, vport))
2451 + return -EINVAL;
2452 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
2453 +index 71153c0f1605..aa9a88e84e3b 100644
2454 +--- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c
2455 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
2456 +@@ -549,8 +549,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
2457 + return -EINVAL;
2458 + if (!MLX5_CAP_GEN(mdev, vport_group_manager))
2459 + return -EACCES;
2460 +- if (!MLX5_CAP_ESW(mdev, nic_vport_node_guid_modify))
2461 +- return -EOPNOTSUPP;
2462 +
2463 + in = kvzalloc(inlen, GFP_KERNEL);
2464 + if (!in)
2465 +diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c
2466 +index cd34097b79f1..37a6d7822a38 100644
2467 +--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c
2468 ++++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c
2469 +@@ -232,7 +232,7 @@ struct nfp_nffw_info *nfp_nffw_info_open(struct nfp_cpp *cpp)
2470 + err = nfp_cpp_read(cpp, nfp_resource_cpp_id(state->res),
2471 + nfp_resource_address(state->res),
2472 + fwinf, sizeof(*fwinf));
2473 +- if (err < sizeof(*fwinf))
2474 ++ if (err < (int)sizeof(*fwinf))
2475 + goto err_release;
2476 +
2477 + if (!nffw_res_flg_init_get(fwinf))
2478 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
2479 +index b306961b02fd..d62dccb85539 100644
2480 +--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
2481 ++++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
2482 +@@ -255,9 +255,8 @@ qed_dcbx_get_app_protocol_type(struct qed_hwfn *p_hwfn,
2483 + *type = DCBX_PROTOCOL_ROCE_V2;
2484 + } else {
2485 + *type = DCBX_MAX_PROTOCOL_TYPE;
2486 +- DP_ERR(p_hwfn,
2487 +- "No action required, App TLV id = 0x%x app_prio_bitmap = 0x%x\n",
2488 +- id, app_prio_bitmap);
2489 ++ DP_ERR(p_hwfn, "No action required, App TLV entry = 0x%x\n",
2490 ++ app_prio_bitmap);
2491 + return false;
2492 + }
2493 +
2494 +@@ -1472,8 +1471,8 @@ static u8 qed_dcbnl_getcap(struct qed_dev *cdev, int capid, u8 *cap)
2495 + *cap = 0x80;
2496 + break;
2497 + case DCB_CAP_ATTR_DCBX:
2498 +- *cap = (DCB_CAP_DCBX_LLD_MANAGED | DCB_CAP_DCBX_VER_CEE |
2499 +- DCB_CAP_DCBX_VER_IEEE | DCB_CAP_DCBX_STATIC);
2500 ++ *cap = (DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_VER_IEEE |
2501 ++ DCB_CAP_DCBX_STATIC);
2502 + break;
2503 + default:
2504 + *cap = false;
2505 +@@ -1541,8 +1540,6 @@ static u8 qed_dcbnl_getdcbx(struct qed_dev *cdev)
2506 + if (!dcbx_info)
2507 + return 0;
2508 +
2509 +- if (dcbx_info->operational.enabled)
2510 +- mode |= DCB_CAP_DCBX_LLD_MANAGED;
2511 + if (dcbx_info->operational.ieee)
2512 + mode |= DCB_CAP_DCBX_VER_IEEE;
2513 + if (dcbx_info->operational.cee)
2514 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
2515 +index c06ad4f0758e..5f52f14761a3 100644
2516 +--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
2517 ++++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
2518 +@@ -201,8 +201,9 @@ void qed_ll2b_complete_rx_packet(void *cxt, struct qed_ll2_comp_rx_data *data)
2519 +
2520 + skb = build_skb(buffer->data, 0);
2521 + if (!skb) {
2522 +- rc = -ENOMEM;
2523 +- goto out_post;
2524 ++ DP_INFO(cdev, "Failed to build SKB\n");
2525 ++ kfree(buffer->data);
2526 ++ goto out_post1;
2527 + }
2528 +
2529 + data->u.placement_offset += NET_SKB_PAD;
2530 +@@ -224,8 +225,14 @@ void qed_ll2b_complete_rx_packet(void *cxt, struct qed_ll2_comp_rx_data *data)
2531 + cdev->ll2->cbs->rx_cb(cdev->ll2->cb_cookie, skb,
2532 + data->opaque_data_0,
2533 + data->opaque_data_1);
2534 ++ } else {
2535 ++ DP_VERBOSE(p_hwfn, (NETIF_MSG_RX_STATUS | NETIF_MSG_PKTDATA |
2536 ++ QED_MSG_LL2 | QED_MSG_STORAGE),
2537 ++ "Dropping the packet\n");
2538 ++ kfree(buffer->data);
2539 + }
2540 +
2541 ++out_post1:
2542 + /* Update Buffer information and update FW producer */
2543 + buffer->data = new_data;
2544 + buffer->phys_addr = new_phys_addr;
2545 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
2546 +index 2c958921dfb3..954f7ce4cf28 100644
2547 +--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
2548 ++++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
2549 +@@ -565,8 +565,16 @@ static irqreturn_t qed_single_int(int irq, void *dev_instance)
2550 + /* Fastpath interrupts */
2551 + for (j = 0; j < 64; j++) {
2552 + if ((0x2ULL << j) & status) {
2553 +- hwfn->simd_proto_handler[j].func(
2554 +- hwfn->simd_proto_handler[j].token);
2555 ++ struct qed_simd_fp_handler *p_handler =
2556 ++ &hwfn->simd_proto_handler[j];
2557 ++
2558 ++ if (p_handler->func)
2559 ++ p_handler->func(p_handler->token);
2560 ++ else
2561 ++ DP_NOTICE(hwfn,
2562 ++ "Not calling fastpath handler as it is NULL [handler #%d, status 0x%llx]\n",
2563 ++ j, status);
2564 ++
2565 + status &= ~(0x2ULL << j);
2566 + rc = IRQ_HANDLED;
2567 + }
2568 +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
2569 +index 287d89dd086f..9c94240bb05a 100644
2570 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
2571 ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
2572 +@@ -1128,6 +1128,8 @@ static ssize_t qlcnic_83xx_sysfs_flash_write_handler(struct file *filp,
2573 + struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
2574 +
2575 + ret = kstrtoul(buf, 16, &data);
2576 ++ if (ret)
2577 ++ return ret;
2578 +
2579 + switch (data) {
2580 + case QLC_83XX_FLASH_SECTOR_ERASE_CMD:
2581 +diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
2582 +index 9c236298fe21..b1f5f0b8e546 100644
2583 +--- a/drivers/net/ethernet/qualcomm/qca_spi.c
2584 ++++ b/drivers/net/ethernet/qualcomm/qca_spi.c
2585 +@@ -658,7 +658,7 @@ qcaspi_netdev_open(struct net_device *dev)
2586 + return ret;
2587 + }
2588 +
2589 +- netif_start_queue(qca->net_dev);
2590 ++ /* SPI thread takes care of TX queue */
2591 +
2592 + return 0;
2593 + }
2594 +@@ -761,6 +761,9 @@ qcaspi_netdev_tx_timeout(struct net_device *dev)
2595 + qca->net_dev->stats.tx_errors++;
2596 + /* Trigger tx queue flush and QCA7000 reset */
2597 + qca->sync = QCASPI_SYNC_UNKNOWN;
2598 ++
2599 ++ if (qca->spi_thread)
2600 ++ wake_up_process(qca->spi_thread);
2601 + }
2602 +
2603 + static int
2604 +@@ -879,22 +882,22 @@ qca_spi_probe(struct spi_device *spi)
2605 +
2606 + if ((qcaspi_clkspeed < QCASPI_CLK_SPEED_MIN) ||
2607 + (qcaspi_clkspeed > QCASPI_CLK_SPEED_MAX)) {
2608 +- dev_info(&spi->dev, "Invalid clkspeed: %d\n",
2609 +- qcaspi_clkspeed);
2610 ++ dev_err(&spi->dev, "Invalid clkspeed: %d\n",
2611 ++ qcaspi_clkspeed);
2612 + return -EINVAL;
2613 + }
2614 +
2615 + if ((qcaspi_burst_len < QCASPI_BURST_LEN_MIN) ||
2616 + (qcaspi_burst_len > QCASPI_BURST_LEN_MAX)) {
2617 +- dev_info(&spi->dev, "Invalid burst len: %d\n",
2618 +- qcaspi_burst_len);
2619 ++ dev_err(&spi->dev, "Invalid burst len: %d\n",
2620 ++ qcaspi_burst_len);
2621 + return -EINVAL;
2622 + }
2623 +
2624 + if ((qcaspi_pluggable < QCASPI_PLUGGABLE_MIN) ||
2625 + (qcaspi_pluggable > QCASPI_PLUGGABLE_MAX)) {
2626 +- dev_info(&spi->dev, "Invalid pluggable: %d\n",
2627 +- qcaspi_pluggable);
2628 ++ dev_err(&spi->dev, "Invalid pluggable: %d\n",
2629 ++ qcaspi_pluggable);
2630 + return -EINVAL;
2631 + }
2632 +
2633 +@@ -956,8 +959,8 @@ qca_spi_probe(struct spi_device *spi)
2634 + }
2635 +
2636 + if (register_netdev(qcaspi_devs)) {
2637 +- dev_info(&spi->dev, "Unable to register net device %s\n",
2638 +- qcaspi_devs->name);
2639 ++ dev_err(&spi->dev, "Unable to register net device %s\n",
2640 ++ qcaspi_devs->name);
2641 + free_netdev(qcaspi_devs);
2642 + return -EFAULT;
2643 + }
2644 +diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
2645 +index fdf30bfa403b..e87a779bfcfe 100644
2646 +--- a/drivers/net/ethernet/renesas/ravb_main.c
2647 ++++ b/drivers/net/ethernet/renesas/ravb_main.c
2648 +@@ -959,6 +959,13 @@ static void ravb_adjust_link(struct net_device *ndev)
2649 + struct ravb_private *priv = netdev_priv(ndev);
2650 + struct phy_device *phydev = ndev->phydev;
2651 + bool new_state = false;
2652 ++ unsigned long flags;
2653 ++
2654 ++ spin_lock_irqsave(&priv->lock, flags);
2655 ++
2656 ++ /* Disable TX and RX right over here, if E-MAC change is ignored */
2657 ++ if (priv->no_avb_link)
2658 ++ ravb_rcv_snd_disable(ndev);
2659 +
2660 + if (phydev->link) {
2661 + if (phydev->duplex != priv->duplex) {
2662 +@@ -976,18 +983,21 @@ static void ravb_adjust_link(struct net_device *ndev)
2663 + ravb_modify(ndev, ECMR, ECMR_TXF, 0);
2664 + new_state = true;
2665 + priv->link = phydev->link;
2666 +- if (priv->no_avb_link)
2667 +- ravb_rcv_snd_enable(ndev);
2668 + }
2669 + } else if (priv->link) {
2670 + new_state = true;
2671 + priv->link = 0;
2672 + priv->speed = 0;
2673 + priv->duplex = -1;
2674 +- if (priv->no_avb_link)
2675 +- ravb_rcv_snd_disable(ndev);
2676 + }
2677 +
2678 ++ /* Enable TX and RX right over here, if E-MAC change is ignored */
2679 ++ if (priv->no_avb_link && phydev->link)
2680 ++ ravb_rcv_snd_enable(ndev);
2681 ++
2682 ++ mmiowb();
2683 ++ spin_unlock_irqrestore(&priv->lock, flags);
2684 ++
2685 + if (new_state && netif_msg_link(priv))
2686 + phy_print_status(phydev);
2687 + }
2688 +@@ -1094,52 +1104,18 @@ static int ravb_get_link_ksettings(struct net_device *ndev,
2689 + static int ravb_set_link_ksettings(struct net_device *ndev,
2690 + const struct ethtool_link_ksettings *cmd)
2691 + {
2692 +- struct ravb_private *priv = netdev_priv(ndev);
2693 +- unsigned long flags;
2694 +- int error;
2695 +-
2696 + if (!ndev->phydev)
2697 + return -ENODEV;
2698 +
2699 +- spin_lock_irqsave(&priv->lock, flags);
2700 +-
2701 +- /* Disable TX and RX */
2702 +- ravb_rcv_snd_disable(ndev);
2703 +-
2704 +- error = phy_ethtool_ksettings_set(ndev->phydev, cmd);
2705 +- if (error)
2706 +- goto error_exit;
2707 +-
2708 +- if (cmd->base.duplex == DUPLEX_FULL)
2709 +- priv->duplex = 1;
2710 +- else
2711 +- priv->duplex = 0;
2712 +-
2713 +- ravb_set_duplex(ndev);
2714 +-
2715 +-error_exit:
2716 +- mdelay(1);
2717 +-
2718 +- /* Enable TX and RX */
2719 +- ravb_rcv_snd_enable(ndev);
2720 +-
2721 +- mmiowb();
2722 +- spin_unlock_irqrestore(&priv->lock, flags);
2723 +-
2724 +- return error;
2725 ++ return phy_ethtool_ksettings_set(ndev->phydev, cmd);
2726 + }
2727 +
2728 + static int ravb_nway_reset(struct net_device *ndev)
2729 + {
2730 +- struct ravb_private *priv = netdev_priv(ndev);
2731 + int error = -ENODEV;
2732 +- unsigned long flags;
2733 +
2734 +- if (ndev->phydev) {
2735 +- spin_lock_irqsave(&priv->lock, flags);
2736 ++ if (ndev->phydev)
2737 + error = phy_start_aneg(ndev->phydev);
2738 +- spin_unlock_irqrestore(&priv->lock, flags);
2739 +- }
2740 +
2741 + return error;
2742 + }
2743 +diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
2744 +index 38080e95a82d..abfb9faadbc4 100644
2745 +--- a/drivers/net/ethernet/renesas/sh_eth.c
2746 ++++ b/drivers/net/ethernet/renesas/sh_eth.c
2747 +@@ -1821,8 +1821,15 @@ static void sh_eth_adjust_link(struct net_device *ndev)
2748 + {
2749 + struct sh_eth_private *mdp = netdev_priv(ndev);
2750 + struct phy_device *phydev = ndev->phydev;
2751 ++ unsigned long flags;
2752 + int new_state = 0;
2753 +
2754 ++ spin_lock_irqsave(&mdp->lock, flags);
2755 ++
2756 ++ /* Disable TX and RX right over here, if E-MAC change is ignored */
2757 ++ if (mdp->cd->no_psr || mdp->no_ether_link)
2758 ++ sh_eth_rcv_snd_disable(ndev);
2759 ++
2760 + if (phydev->link) {
2761 + if (phydev->duplex != mdp->duplex) {
2762 + new_state = 1;
2763 +@@ -1841,18 +1848,21 @@ static void sh_eth_adjust_link(struct net_device *ndev)
2764 + sh_eth_modify(ndev, ECMR, ECMR_TXF, 0);
2765 + new_state = 1;
2766 + mdp->link = phydev->link;
2767 +- if (mdp->cd->no_psr || mdp->no_ether_link)
2768 +- sh_eth_rcv_snd_enable(ndev);
2769 + }
2770 + } else if (mdp->link) {
2771 + new_state = 1;
2772 + mdp->link = 0;
2773 + mdp->speed = 0;
2774 + mdp->duplex = -1;
2775 +- if (mdp->cd->no_psr || mdp->no_ether_link)
2776 +- sh_eth_rcv_snd_disable(ndev);
2777 + }
2778 +
2779 ++ /* Enable TX and RX right over here, if E-MAC change is ignored */
2780 ++ if ((mdp->cd->no_psr || mdp->no_ether_link) && phydev->link)
2781 ++ sh_eth_rcv_snd_enable(ndev);
2782 ++
2783 ++ mmiowb();
2784 ++ spin_unlock_irqrestore(&mdp->lock, flags);
2785 ++
2786 + if (new_state && netif_msg_link(mdp))
2787 + phy_print_status(phydev);
2788 + }
2789 +@@ -1933,39 +1943,10 @@ static int sh_eth_get_link_ksettings(struct net_device *ndev,
2790 + static int sh_eth_set_link_ksettings(struct net_device *ndev,
2791 + const struct ethtool_link_ksettings *cmd)
2792 + {
2793 +- struct sh_eth_private *mdp = netdev_priv(ndev);
2794 +- unsigned long flags;
2795 +- int ret;
2796 +-
2797 + if (!ndev->phydev)
2798 + return -ENODEV;
2799 +
2800 +- spin_lock_irqsave(&mdp->lock, flags);
2801 +-
2802 +- /* disable tx and rx */
2803 +- sh_eth_rcv_snd_disable(ndev);
2804 +-
2805 +- ret = phy_ethtool_ksettings_set(ndev->phydev, cmd);
2806 +- if (ret)
2807 +- goto error_exit;
2808 +-
2809 +- if (cmd->base.duplex == DUPLEX_FULL)
2810 +- mdp->duplex = 1;
2811 +- else
2812 +- mdp->duplex = 0;
2813 +-
2814 +- if (mdp->cd->set_duplex)
2815 +- mdp->cd->set_duplex(ndev);
2816 +-
2817 +-error_exit:
2818 +- mdelay(1);
2819 +-
2820 +- /* enable tx and rx */
2821 +- sh_eth_rcv_snd_enable(ndev);
2822 +-
2823 +- spin_unlock_irqrestore(&mdp->lock, flags);
2824 +-
2825 +- return ret;
2826 ++ return phy_ethtool_ksettings_set(ndev->phydev, cmd);
2827 + }
2828 +
2829 + /* If it is ever necessary to increase SH_ETH_REG_DUMP_MAX_REGS, the
2830 +@@ -2156,18 +2137,10 @@ static void sh_eth_get_regs(struct net_device *ndev, struct ethtool_regs *regs,
2831 +
2832 + static int sh_eth_nway_reset(struct net_device *ndev)
2833 + {
2834 +- struct sh_eth_private *mdp = netdev_priv(ndev);
2835 +- unsigned long flags;
2836 +- int ret;
2837 +-
2838 + if (!ndev->phydev)
2839 + return -ENODEV;
2840 +
2841 +- spin_lock_irqsave(&mdp->lock, flags);
2842 +- ret = phy_start_aneg(ndev->phydev);
2843 +- spin_unlock_irqrestore(&mdp->lock, flags);
2844 +-
2845 +- return ret;
2846 ++ return phy_start_aneg(ndev->phydev);
2847 + }
2848 +
2849 + static u32 sh_eth_get_msglevel(struct net_device *ndev)
2850 +diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
2851 +index 97035766c291..5790cd61436d 100644
2852 +--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
2853 ++++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
2854 +@@ -111,7 +111,7 @@ config DWMAC_ROCKCHIP
2855 + config DWMAC_SOCFPGA
2856 + tristate "SOCFPGA dwmac support"
2857 + default ARCH_SOCFPGA
2858 +- depends on OF && (ARCH_SOCFPGA || COMPILE_TEST)
2859 ++ depends on OF && (ARCH_SOCFPGA || ARCH_STRATIX10 || COMPILE_TEST)
2860 + select MFD_SYSCON
2861 + help
2862 + Support for ethernet controller on Altera SOCFPGA
2863 +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
2864 +index 6e359572b9f0..5b3b06a0a3bf 100644
2865 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
2866 ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
2867 +@@ -55,6 +55,7 @@ struct socfpga_dwmac {
2868 + struct device *dev;
2869 + struct regmap *sys_mgr_base_addr;
2870 + struct reset_control *stmmac_rst;
2871 ++ struct reset_control *stmmac_ocp_rst;
2872 + void __iomem *splitter_base;
2873 + bool f2h_ptp_ref_clk;
2874 + struct tse_pcs pcs;
2875 +@@ -262,8 +263,8 @@ static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
2876 + val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
2877 +
2878 + /* Assert reset to the enet controller before changing the phy mode */
2879 +- if (dwmac->stmmac_rst)
2880 +- reset_control_assert(dwmac->stmmac_rst);
2881 ++ reset_control_assert(dwmac->stmmac_ocp_rst);
2882 ++ reset_control_assert(dwmac->stmmac_rst);
2883 +
2884 + regmap_read(sys_mgr_base_addr, reg_offset, &ctrl);
2885 + ctrl &= ~(SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << reg_shift);
2886 +@@ -288,8 +289,8 @@ static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
2887 + /* Deassert reset for the phy configuration to be sampled by
2888 + * the enet controller, and operation to start in requested mode
2889 + */
2890 +- if (dwmac->stmmac_rst)
2891 +- reset_control_deassert(dwmac->stmmac_rst);
2892 ++ reset_control_deassert(dwmac->stmmac_ocp_rst);
2893 ++ reset_control_deassert(dwmac->stmmac_rst);
2894 + if (phymode == PHY_INTERFACE_MODE_SGMII) {
2895 + if (tse_pcs_init(dwmac->pcs.tse_pcs_base, &dwmac->pcs) != 0) {
2896 + dev_err(dwmac->dev, "Unable to initialize TSE PCS");
2897 +@@ -324,6 +325,15 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
2898 + goto err_remove_config_dt;
2899 + }
2900 +
2901 ++ dwmac->stmmac_ocp_rst = devm_reset_control_get_optional(dev, "stmmaceth-ocp");
2902 ++ if (IS_ERR(dwmac->stmmac_ocp_rst)) {
2903 ++ ret = PTR_ERR(dwmac->stmmac_ocp_rst);
2904 ++ dev_err(dev, "error getting reset control of ocp %d\n", ret);
2905 ++ goto err_remove_config_dt;
2906 ++ }
2907 ++
2908 ++ reset_control_deassert(dwmac->stmmac_ocp_rst);
2909 ++
2910 + ret = socfpga_dwmac_parse_data(dwmac, dev);
2911 + if (ret) {
2912 + dev_err(dev, "Unable to parse OF data\n");
2913 +diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
2914 +index 4bb561856af5..47a096134043 100644
2915 +--- a/drivers/net/ethernet/ti/davinci_emac.c
2916 ++++ b/drivers/net/ethernet/ti/davinci_emac.c
2917 +@@ -1387,6 +1387,10 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
2918 +
2919 + static int match_first_device(struct device *dev, void *data)
2920 + {
2921 ++ if (dev->parent && dev->parent->of_node)
2922 ++ return of_device_is_compatible(dev->parent->of_node,
2923 ++ "ti,davinci_mdio");
2924 ++
2925 + return !strncmp(dev_name(dev), "davinci_mdio", 12);
2926 + }
2927 +
2928 +diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
2929 +index 78a6414c5fd9..7d94a7842557 100644
2930 +--- a/drivers/net/hamradio/bpqether.c
2931 ++++ b/drivers/net/hamradio/bpqether.c
2932 +@@ -89,10 +89,6 @@
2933 + static const char banner[] __initconst = KERN_INFO \
2934 + "AX.25: bpqether driver version 004\n";
2935 +
2936 +-static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2937 +-
2938 +-static char bpq_eth_addr[6];
2939 +-
2940 + static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);
2941 + static int bpq_device_event(struct notifier_block *, unsigned long, void *);
2942 +
2943 +@@ -515,8 +511,8 @@ static int bpq_new_device(struct net_device *edev)
2944 + bpq->ethdev = edev;
2945 + bpq->axdev = ndev;
2946 +
2947 +- memcpy(bpq->dest_addr, bcast_addr, sizeof(bpq_eth_addr));
2948 +- memcpy(bpq->acpt_addr, bcast_addr, sizeof(bpq_eth_addr));
2949 ++ eth_broadcast_addr(bpq->dest_addr);
2950 ++ eth_broadcast_addr(bpq->acpt_addr);
2951 +
2952 + err = register_netdevice(ndev);
2953 + if (err)
2954 +diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
2955 +index cb03a6ea076a..328c37e9096d 100644
2956 +--- a/drivers/net/hyperv/rndis_filter.c
2957 ++++ b/drivers/net/hyperv/rndis_filter.c
2958 +@@ -1299,6 +1299,7 @@ out:
2959 + /* setting up multiple channels failed */
2960 + net_device->max_chn = 1;
2961 + net_device->num_chn = 1;
2962 ++ return 0;
2963 +
2964 + err_dev_remv:
2965 + rndis_filter_device_remove(dev, net_device);
2966 +diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
2967 +index 548d9d026a85..5c48bdb6f678 100644
2968 +--- a/drivers/net/ieee802154/at86rf230.c
2969 ++++ b/drivers/net/ieee802154/at86rf230.c
2970 +@@ -940,7 +940,7 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
2971 + static int
2972 + at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
2973 + {
2974 +- BUG_ON(!level);
2975 ++ WARN_ON(!level);
2976 + *level = 0xbe;
2977 + return 0;
2978 + }
2979 +@@ -1121,8 +1121,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
2980 + if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
2981 + u16 addr = le16_to_cpu(filt->short_addr);
2982 +
2983 +- dev_vdbg(&lp->spi->dev,
2984 +- "at86rf230_set_hw_addr_filt called for saddr\n");
2985 ++ dev_vdbg(&lp->spi->dev, "%s called for saddr\n", __func__);
2986 + __at86rf230_write(lp, RG_SHORT_ADDR_0, addr);
2987 + __at86rf230_write(lp, RG_SHORT_ADDR_1, addr >> 8);
2988 + }
2989 +@@ -1130,8 +1129,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
2990 + if (changed & IEEE802154_AFILT_PANID_CHANGED) {
2991 + u16 pan = le16_to_cpu(filt->pan_id);
2992 +
2993 +- dev_vdbg(&lp->spi->dev,
2994 +- "at86rf230_set_hw_addr_filt called for pan id\n");
2995 ++ dev_vdbg(&lp->spi->dev, "%s called for pan id\n", __func__);
2996 + __at86rf230_write(lp, RG_PAN_ID_0, pan);
2997 + __at86rf230_write(lp, RG_PAN_ID_1, pan >> 8);
2998 + }
2999 +@@ -1140,15 +1138,13 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
3000 + u8 i, addr[8];
3001 +
3002 + memcpy(addr, &filt->ieee_addr, 8);
3003 +- dev_vdbg(&lp->spi->dev,
3004 +- "at86rf230_set_hw_addr_filt called for IEEE addr\n");
3005 ++ dev_vdbg(&lp->spi->dev, "%s called for IEEE addr\n", __func__);
3006 + for (i = 0; i < 8; i++)
3007 + __at86rf230_write(lp, RG_IEEE_ADDR_0 + i, addr[i]);
3008 + }
3009 +
3010 + if (changed & IEEE802154_AFILT_PANC_CHANGED) {
3011 +- dev_vdbg(&lp->spi->dev,
3012 +- "at86rf230_set_hw_addr_filt called for panc change\n");
3013 ++ dev_vdbg(&lp->spi->dev, "%s called for panc change\n", __func__);
3014 + if (filt->pan_coord)
3015 + at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1);
3016 + else
3017 +@@ -1252,7 +1248,6 @@ at86rf230_set_cca_mode(struct ieee802154_hw *hw,
3018 + return at86rf230_write_subreg(lp, SR_CCA_MODE, val);
3019 + }
3020 +
3021 +-
3022 + static int
3023 + at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
3024 + {
3025 +diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c
3026 +index 0d673f7682ee..176395e4b7bb 100644
3027 +--- a/drivers/net/ieee802154/fakelb.c
3028 ++++ b/drivers/net/ieee802154/fakelb.c
3029 +@@ -49,7 +49,7 @@ struct fakelb_phy {
3030 +
3031 + static int fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level)
3032 + {
3033 +- BUG_ON(!level);
3034 ++ WARN_ON(!level);
3035 + *level = 0xbe;
3036 +
3037 + return 0;
3038 +diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
3039 +index e7f7a1a002ee..58133c9f701b 100644
3040 +--- a/drivers/net/ipvlan/ipvlan_main.c
3041 ++++ b/drivers/net/ipvlan/ipvlan_main.c
3042 +@@ -73,10 +73,23 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval)
3043 + {
3044 + struct ipvl_dev *ipvlan;
3045 + struct net_device *mdev = port->dev;
3046 +- int err = 0;
3047 ++ unsigned int flags;
3048 ++ int err;
3049 +
3050 + ASSERT_RTNL();
3051 + if (port->mode != nval) {
3052 ++ list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
3053 ++ flags = ipvlan->dev->flags;
3054 ++ if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S) {
3055 ++ err = dev_change_flags(ipvlan->dev,
3056 ++ flags | IFF_NOARP);
3057 ++ } else {
3058 ++ err = dev_change_flags(ipvlan->dev,
3059 ++ flags & ~IFF_NOARP);
3060 ++ }
3061 ++ if (unlikely(err))
3062 ++ goto fail;
3063 ++ }
3064 + if (nval == IPVLAN_MODE_L3S) {
3065 + /* New mode is L3S */
3066 + err = ipvlan_register_nf_hook(read_pnet(&port->pnet));
3067 +@@ -84,21 +97,28 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval)
3068 + mdev->l3mdev_ops = &ipvl_l3mdev_ops;
3069 + mdev->priv_flags |= IFF_L3MDEV_MASTER;
3070 + } else
3071 +- return err;
3072 ++ goto fail;
3073 + } else if (port->mode == IPVLAN_MODE_L3S) {
3074 + /* Old mode was L3S */
3075 + mdev->priv_flags &= ~IFF_L3MDEV_MASTER;
3076 + ipvlan_unregister_nf_hook(read_pnet(&port->pnet));
3077 + mdev->l3mdev_ops = NULL;
3078 + }
3079 +- list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
3080 +- if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S)
3081 +- ipvlan->dev->flags |= IFF_NOARP;
3082 +- else
3083 +- ipvlan->dev->flags &= ~IFF_NOARP;
3084 +- }
3085 + port->mode = nval;
3086 + }
3087 ++ return 0;
3088 ++
3089 ++fail:
3090 ++ /* Undo the flags changes that have been done so far. */
3091 ++ list_for_each_entry_continue_reverse(ipvlan, &port->ipvlans, pnode) {
3092 ++ flags = ipvlan->dev->flags;
3093 ++ if (port->mode == IPVLAN_MODE_L3 ||
3094 ++ port->mode == IPVLAN_MODE_L3S)
3095 ++ dev_change_flags(ipvlan->dev, flags | IFF_NOARP);
3096 ++ else
3097 ++ dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP);
3098 ++ }
3099 ++
3100 + return err;
3101 + }
3102 +
3103 +diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
3104 +index 5f565bd574da..48ba80a8ca5c 100644
3105 +--- a/drivers/net/usb/rtl8150.c
3106 ++++ b/drivers/net/usb/rtl8150.c
3107 +@@ -681,7 +681,7 @@ static void rtl8150_set_multicast(struct net_device *netdev)
3108 + (netdev->flags & IFF_ALLMULTI)) {
3109 + rx_creg &= 0xfffe;
3110 + rx_creg |= 0x0002;
3111 +- dev_info(&netdev->dev, "%s: allmulti set\n", netdev->name);
3112 ++ dev_dbg(&netdev->dev, "%s: allmulti set\n", netdev->name);
3113 + } else {
3114 + /* ~RX_MULTICAST, ~RX_PROMISCUOUS */
3115 + rx_creg &= 0x00fc;
3116 +diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
3117 +index 7a6a1fe79309..05553d252446 100644
3118 +--- a/drivers/net/usb/smsc75xx.c
3119 ++++ b/drivers/net/usb/smsc75xx.c
3120 +@@ -82,6 +82,9 @@ static bool turbo_mode = true;
3121 + module_param(turbo_mode, bool, 0644);
3122 + MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
3123 +
3124 ++static int smsc75xx_link_ok_nopm(struct usbnet *dev);
3125 ++static int smsc75xx_phy_gig_workaround(struct usbnet *dev);
3126 ++
3127 + static int __must_check __smsc75xx_read_reg(struct usbnet *dev, u32 index,
3128 + u32 *data, int in_pm)
3129 + {
3130 +@@ -852,6 +855,9 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
3131 + return -EIO;
3132 + }
3133 +
3134 ++ /* phy workaround for gig link */
3135 ++ smsc75xx_phy_gig_workaround(dev);
3136 ++
3137 + smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
3138 + ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP |
3139 + ADVERTISE_PAUSE_ASYM);
3140 +@@ -987,6 +993,62 @@ static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm)
3141 + return -EIO;
3142 + }
3143 +
3144 ++static int smsc75xx_phy_gig_workaround(struct usbnet *dev)
3145 ++{
3146 ++ struct mii_if_info *mii = &dev->mii;
3147 ++ int ret = 0, timeout = 0;
3148 ++ u32 buf, link_up = 0;
3149 ++
3150 ++ /* Set the phy in Gig loopback */
3151 ++ smsc75xx_mdio_write(dev->net, mii->phy_id, MII_BMCR, 0x4040);
3152 ++
3153 ++ /* Wait for the link up */
3154 ++ do {
3155 ++ link_up = smsc75xx_link_ok_nopm(dev);
3156 ++ usleep_range(10000, 20000);
3157 ++ timeout++;
3158 ++ } while ((!link_up) && (timeout < 1000));
3159 ++
3160 ++ if (timeout >= 1000) {
3161 ++ netdev_warn(dev->net, "Timeout waiting for PHY link up\n");
3162 ++ return -EIO;
3163 ++ }
3164 ++
3165 ++ /* phy reset */
3166 ++ ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
3167 ++ if (ret < 0) {
3168 ++ netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret);
3169 ++ return ret;
3170 ++ }
3171 ++
3172 ++ buf |= PMT_CTL_PHY_RST;
3173 ++
3174 ++ ret = smsc75xx_write_reg(dev, PMT_CTL, buf);
3175 ++ if (ret < 0) {
3176 ++ netdev_warn(dev->net, "Failed to write PMT_CTL: %d\n", ret);
3177 ++ return ret;
3178 ++ }
3179 ++
3180 ++ timeout = 0;
3181 ++ do {
3182 ++ usleep_range(10000, 20000);
3183 ++ ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
3184 ++ if (ret < 0) {
3185 ++ netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n",
3186 ++ ret);
3187 ++ return ret;
3188 ++ }
3189 ++ timeout++;
3190 ++ } while ((buf & PMT_CTL_PHY_RST) && (timeout < 100));
3191 ++
3192 ++ if (timeout >= 100) {
3193 ++ netdev_warn(dev->net, "timeout waiting for PHY Reset\n");
3194 ++ return -EIO;
3195 ++ }
3196 ++
3197 ++ return 0;
3198 ++}
3199 ++
3200 + static int smsc75xx_reset(struct usbnet *dev)
3201 + {
3202 + struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
3203 +diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
3204 +index df11bb449988..52ebed1f55a1 100644
3205 +--- a/drivers/net/wireless/ath/ath10k/mac.c
3206 ++++ b/drivers/net/wireless/ath/ath10k/mac.c
3207 +@@ -5923,8 +5923,19 @@ static void ath10k_sta_rc_update_wk(struct work_struct *wk)
3208 + ath10k_mac_max_vht_nss(vht_mcs_mask)));
3209 +
3210 + if (changed & IEEE80211_RC_BW_CHANGED) {
3211 +- ath10k_dbg(ar, ATH10K_DBG_MAC, "mac update sta %pM peer bw %d\n",
3212 +- sta->addr, bw);
3213 ++ enum wmi_phy_mode mode;
3214 ++
3215 ++ mode = chan_to_phymode(&def);
3216 ++ ath10k_dbg(ar, ATH10K_DBG_MAC, "mac update sta %pM peer bw %d phymode %d\n",
3217 ++ sta->addr, bw, mode);
3218 ++
3219 ++ err = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr,
3220 ++ WMI_PEER_PHYMODE, mode);
3221 ++ if (err) {
3222 ++ ath10k_warn(ar, "failed to update STA %pM peer phymode %d: %d\n",
3223 ++ sta->addr, mode, err);
3224 ++ goto exit;
3225 ++ }
3226 +
3227 + err = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr,
3228 + WMI_PEER_CHAN_WIDTH, bw);
3229 +@@ -5965,6 +5976,7 @@ static void ath10k_sta_rc_update_wk(struct work_struct *wk)
3230 + sta->addr);
3231 + }
3232 +
3233 ++exit:
3234 + mutex_unlock(&ar->conf_mutex);
3235 + }
3236 +
3237 +diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
3238 +index bab876cf25fe..d0e05aa437e3 100644
3239 +--- a/drivers/net/wireless/ath/ath10k/wmi.h
3240 ++++ b/drivers/net/wireless/ath/ath10k/wmi.h
3241 +@@ -6002,6 +6002,7 @@ enum wmi_peer_param {
3242 + WMI_PEER_NSS = 0x5,
3243 + WMI_PEER_USE_4ADDR = 0x6,
3244 + WMI_PEER_DEBUG = 0xa,
3245 ++ WMI_PEER_PHYMODE = 0xd,
3246 + WMI_PEER_DUMMY_VAR = 0xff, /* dummy parameter for STA PS workaround */
3247 + };
3248 +
3249 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
3250 +index eccd25febfe6..4c28b04ea605 100644
3251 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
3252 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
3253 +@@ -4245,6 +4245,13 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)
3254 + brcmf_dbg(TRACE, "Enter\n");
3255 +
3256 + if (bus) {
3257 ++ /* Stop watchdog task */
3258 ++ if (bus->watchdog_tsk) {
3259 ++ send_sig(SIGTERM, bus->watchdog_tsk, 1);
3260 ++ kthread_stop(bus->watchdog_tsk);
3261 ++ bus->watchdog_tsk = NULL;
3262 ++ }
3263 ++
3264 + /* De-register interrupt handler */
3265 + brcmf_sdiod_intr_unregister(bus->sdiodev);
3266 +
3267 +diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
3268 +index d5553c47014f..5d823e965883 100644
3269 +--- a/drivers/nfc/pn533/usb.c
3270 ++++ b/drivers/nfc/pn533/usb.c
3271 +@@ -74,7 +74,7 @@ static void pn533_recv_response(struct urb *urb)
3272 + struct sk_buff *skb = NULL;
3273 +
3274 + if (!urb->status) {
3275 +- skb = alloc_skb(urb->actual_length, GFP_KERNEL);
3276 ++ skb = alloc_skb(urb->actual_length, GFP_ATOMIC);
3277 + if (!skb) {
3278 + nfc_err(&phy->udev->dev, "failed to alloc memory\n");
3279 + } else {
3280 +@@ -186,7 +186,7 @@ static int pn533_usb_send_frame(struct pn533 *dev,
3281 +
3282 + if (dev->protocol_type == PN533_PROTO_REQ_RESP) {
3283 + /* request for response for sent packet directly */
3284 +- rc = pn533_submit_urb_for_response(phy, GFP_ATOMIC);
3285 ++ rc = pn533_submit_urb_for_response(phy, GFP_KERNEL);
3286 + if (rc)
3287 + goto error;
3288 + } else if (dev->protocol_type == PN533_PROTO_REQ_ACK_RESP) {
3289 +diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
3290 +index 38c128f230e7..3a63d58d2ca9 100644
3291 +--- a/drivers/nvme/host/core.c
3292 ++++ b/drivers/nvme/host/core.c
3293 +@@ -1016,7 +1016,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
3294 +
3295 + status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c,
3296 + (void __user *)(uintptr_t)cmd.addr, cmd.data_len,
3297 +- (void __user *)(uintptr_t)cmd.metadata, cmd.metadata,
3298 ++ (void __user *)(uintptr_t)cmd.metadata, cmd.metadata_len,
3299 + 0, &cmd.result, timeout);
3300 + if (status >= 0) {
3301 + if (put_user(cmd.result, &ucmd->result))
3302 +diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
3303 +index 240b0d628222..5fa7856f6b34 100644
3304 +--- a/drivers/nvme/target/core.c
3305 ++++ b/drivers/nvme/target/core.c
3306 +@@ -598,6 +598,14 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)
3307 + }
3308 +
3309 + ctrl->csts = NVME_CSTS_RDY;
3310 ++
3311 ++ /*
3312 ++ * Controllers that are not yet enabled should not really enforce the
3313 ++ * keep alive timeout, but we still want to track a timeout and cleanup
3314 ++ * in case a host died before it enabled the controller. Hence, simply
3315 ++ * reset the keep alive timer when the controller is enabled.
3316 ++ */
3317 ++ mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
3318 + }
3319 +
3320 + static void nvmet_clear_ctrl(struct nvmet_ctrl *ctrl)
3321 +diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
3322 +index 2afafd5d8915..635886e4835c 100644
3323 +--- a/drivers/nvmem/core.c
3324 ++++ b/drivers/nvmem/core.c
3325 +@@ -865,6 +865,10 @@ struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *cell_id)
3326 + return cell;
3327 + }
3328 +
3329 ++ /* NULL cell_id only allowed for device tree; invalid otherwise */
3330 ++ if (!cell_id)
3331 ++ return ERR_PTR(-EINVAL);
3332 ++
3333 + return nvmem_cell_get_from_list(cell_id);
3334 + }
3335 + EXPORT_SYMBOL_GPL(nvmem_cell_get);
3336 +diff --git a/drivers/pci/host/pci-ftpci100.c b/drivers/pci/host/pci-ftpci100.c
3337 +index 4ea7d2ebcc5c..4e6b21931514 100644
3338 +--- a/drivers/pci/host/pci-ftpci100.c
3339 ++++ b/drivers/pci/host/pci-ftpci100.c
3340 +@@ -353,11 +353,13 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p)
3341 + irq = of_irq_get(intc, 0);
3342 + if (irq <= 0) {
3343 + dev_err(p->dev, "failed to get parent IRQ\n");
3344 ++ of_node_put(intc);
3345 + return irq ?: -EINVAL;
3346 + }
3347 +
3348 + p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX,
3349 + &faraday_pci_irqdomain_ops, p);
3350 ++ of_node_put(intc);
3351 + if (!p->irqdomain) {
3352 + dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n");
3353 + return -EINVAL;
3354 +diff --git a/drivers/pci/host/pci-host-common.c b/drivers/pci/host/pci-host-common.c
3355 +index 44a47d4f0b8f..148896f73c06 100644
3356 +--- a/drivers/pci/host/pci-host-common.c
3357 ++++ b/drivers/pci/host/pci-host-common.c
3358 +@@ -45,7 +45,7 @@ static int gen_pci_parse_request_of_pci_ranges(struct device *dev,
3359 +
3360 + switch (resource_type(res)) {
3361 + case IORESOURCE_IO:
3362 +- err = pci_remap_iospace(res, iobase);
3363 ++ err = devm_pci_remap_iospace(dev, res, iobase);
3364 + if (err) {
3365 + dev_warn(dev, "error %d: failed to map resource %pR\n",
3366 + err, res);
3367 +diff --git a/drivers/pci/host/pci-versatile.c b/drivers/pci/host/pci-versatile.c
3368 +index d417acab0ecf..aff4cfb555fb 100644
3369 +--- a/drivers/pci/host/pci-versatile.c
3370 ++++ b/drivers/pci/host/pci-versatile.c
3371 +@@ -89,7 +89,7 @@ static int versatile_pci_parse_request_of_pci_ranges(struct device *dev,
3372 +
3373 + switch (resource_type(res)) {
3374 + case IORESOURCE_IO:
3375 +- err = pci_remap_iospace(res, iobase);
3376 ++ err = devm_pci_remap_iospace(dev, res, iobase);
3377 + if (err) {
3378 + dev_warn(dev, "error %d: failed to map resource %pR\n",
3379 + err, res);
3380 +diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
3381 +index 8f44a7d14bff..41edce16a07c 100644
3382 +--- a/drivers/pci/host/pcie-rcar.c
3383 ++++ b/drivers/pci/host/pcie-rcar.c
3384 +@@ -1105,7 +1105,7 @@ static int rcar_pcie_parse_request_of_pci_ranges(struct rcar_pcie *pci)
3385 + struct resource *res = win->res;
3386 +
3387 + if (resource_type(res) == IORESOURCE_IO) {
3388 +- err = pci_remap_iospace(res, iobase);
3389 ++ err = devm_pci_remap_iospace(dev, res, iobase);
3390 + if (err) {
3391 + dev_warn(dev, "error %d: failed to map resource %pR\n",
3392 + err, res);
3393 +diff --git a/drivers/pci/host/pcie-xilinx-nwl.c b/drivers/pci/host/pcie-xilinx-nwl.c
3394 +index 65dea98b2643..dd527ea558d7 100644
3395 +--- a/drivers/pci/host/pcie-xilinx-nwl.c
3396 ++++ b/drivers/pci/host/pcie-xilinx-nwl.c
3397 +@@ -561,7 +561,7 @@ static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie)
3398 + PCI_NUM_INTX,
3399 + &legacy_domain_ops,
3400 + pcie);
3401 +-
3402 ++ of_node_put(legacy_intc_node);
3403 + if (!pcie->legacy_irq_domain) {
3404 + dev_err(dev, "failed to create IRQ domain\n");
3405 + return -ENOMEM;
3406 +diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c
3407 +index 94e13cb8608f..29f024f0ed7f 100644
3408 +--- a/drivers/pci/host/pcie-xilinx.c
3409 ++++ b/drivers/pci/host/pcie-xilinx.c
3410 +@@ -511,6 +511,7 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port)
3411 + port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
3412 + &intx_domain_ops,
3413 + port);
3414 ++ of_node_put(pcie_intc_node);
3415 + if (!port->leg_domain) {
3416 + dev_err(dev, "Failed to get a INTx IRQ domain\n");
3417 + return -ENODEV;
3418 +diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
3419 +index 7b0e97be9063..591f2e05ab1c 100644
3420 +--- a/drivers/pci/hotplug/pci_hotplug_core.c
3421 ++++ b/drivers/pci/hotplug/pci_hotplug_core.c
3422 +@@ -452,8 +452,17 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
3423 + list_add(&slot->slot_list, &pci_hotplug_slot_list);
3424 +
3425 + result = fs_add_slot(pci_slot);
3426 ++ if (result)
3427 ++ goto err_list_del;
3428 ++
3429 + kobject_uevent(&pci_slot->kobj, KOBJ_ADD);
3430 + dbg("Added slot %s to the list\n", name);
3431 ++ goto out;
3432 ++
3433 ++err_list_del:
3434 ++ list_del(&slot->slot_list);
3435 ++ pci_slot->hotplug = NULL;
3436 ++ pci_destroy_slot(pci_slot);
3437 + out:
3438 + mutex_unlock(&pci_hp_mutex);
3439 + return result;
3440 +diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
3441 +index e7d6cfaf3865..9fc4357c3db9 100644
3442 +--- a/drivers/pci/hotplug/pciehp.h
3443 ++++ b/drivers/pci/hotplug/pciehp.h
3444 +@@ -132,6 +132,7 @@ int pciehp_unconfigure_device(struct slot *p_slot);
3445 + void pciehp_queue_pushbutton_work(struct work_struct *work);
3446 + struct controller *pcie_init(struct pcie_device *dev);
3447 + int pcie_init_notification(struct controller *ctrl);
3448 ++void pcie_shutdown_notification(struct controller *ctrl);
3449 + int pciehp_enable_slot(struct slot *p_slot);
3450 + int pciehp_disable_slot(struct slot *p_slot);
3451 + void pcie_reenable_notification(struct controller *ctrl);
3452 +diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
3453 +index 1288289cc85d..c38e392d63e4 100644
3454 +--- a/drivers/pci/hotplug/pciehp_core.c
3455 ++++ b/drivers/pci/hotplug/pciehp_core.c
3456 +@@ -76,6 +76,12 @@ static int reset_slot(struct hotplug_slot *slot, int probe);
3457 + */
3458 + static void release_slot(struct hotplug_slot *hotplug_slot)
3459 + {
3460 ++ struct slot *slot = hotplug_slot->private;
3461 ++
3462 ++ /* queued work needs hotplug_slot name */
3463 ++ cancel_delayed_work(&slot->work);
3464 ++ drain_workqueue(slot->wq);
3465 ++
3466 + kfree(hotplug_slot->ops);
3467 + kfree(hotplug_slot->info);
3468 + kfree(hotplug_slot);
3469 +@@ -278,6 +284,7 @@ static void pciehp_remove(struct pcie_device *dev)
3470 + {
3471 + struct controller *ctrl = get_service_data(dev);
3472 +
3473 ++ pcie_shutdown_notification(ctrl);
3474 + cleanup_slot(ctrl);
3475 + pciehp_release_ctrl(ctrl);
3476 + }
3477 +diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
3478 +index 46c2ee2caf28..2fa830727362 100644
3479 +--- a/drivers/pci/hotplug/pciehp_hpc.c
3480 ++++ b/drivers/pci/hotplug/pciehp_hpc.c
3481 +@@ -562,8 +562,6 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id)
3482 + {
3483 + struct controller *ctrl = (struct controller *)dev_id;
3484 + struct pci_dev *pdev = ctrl_dev(ctrl);
3485 +- struct pci_bus *subordinate = pdev->subordinate;
3486 +- struct pci_dev *dev;
3487 + struct slot *slot = ctrl->slot;
3488 + u16 status, events;
3489 + u8 present;
3490 +@@ -611,14 +609,9 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id)
3491 + wake_up(&ctrl->queue);
3492 + }
3493 +
3494 +- if (subordinate) {
3495 +- list_for_each_entry(dev, &subordinate->devices, bus_list) {
3496 +- if (dev->ignore_hotplug) {
3497 +- ctrl_dbg(ctrl, "ignoring hotplug event %#06x (%s requested no hotplug)\n",
3498 +- events, pci_name(dev));
3499 +- return IRQ_HANDLED;
3500 +- }
3501 +- }
3502 ++ if (pdev->ignore_hotplug) {
3503 ++ ctrl_dbg(ctrl, "ignoring hotplug event %#06x\n", events);
3504 ++ return IRQ_HANDLED;
3505 + }
3506 +
3507 + /* Check Attention Button Pressed */
3508 +@@ -789,7 +782,7 @@ int pcie_init_notification(struct controller *ctrl)
3509 + return 0;
3510 + }
3511 +
3512 +-static void pcie_shutdown_notification(struct controller *ctrl)
3513 ++void pcie_shutdown_notification(struct controller *ctrl)
3514 + {
3515 + if (ctrl->notification_enabled) {
3516 + pcie_disable_notification(ctrl);
3517 +@@ -824,7 +817,7 @@ abort:
3518 + static void pcie_cleanup_slot(struct controller *ctrl)
3519 + {
3520 + struct slot *slot = ctrl->slot;
3521 +- cancel_delayed_work(&slot->work);
3522 ++
3523 + destroy_workqueue(slot->wq);
3524 + kfree(slot);
3525 + }
3526 +@@ -912,7 +905,6 @@ abort:
3527 +
3528 + void pciehp_release_ctrl(struct controller *ctrl)
3529 + {
3530 +- pcie_shutdown_notification(ctrl);
3531 + pcie_cleanup_slot(ctrl);
3532 + kfree(ctrl);
3533 + }
3534 +diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
3535 +index 62a0677b32f1..22924629e64a 100644
3536 +--- a/drivers/pci/pci.c
3537 ++++ b/drivers/pci/pci.c
3538 +@@ -3446,6 +3446,44 @@ void pci_unmap_iospace(struct resource *res)
3539 + }
3540 + EXPORT_SYMBOL(pci_unmap_iospace);
3541 +
3542 ++static void devm_pci_unmap_iospace(struct device *dev, void *ptr)
3543 ++{
3544 ++ struct resource **res = ptr;
3545 ++
3546 ++ pci_unmap_iospace(*res);
3547 ++}
3548 ++
3549 ++/**
3550 ++ * devm_pci_remap_iospace - Managed pci_remap_iospace()
3551 ++ * @dev: Generic device to remap IO address for
3552 ++ * @res: Resource describing the I/O space
3553 ++ * @phys_addr: physical address of range to be mapped
3554 ++ *
3555 ++ * Managed pci_remap_iospace(). Map is automatically unmapped on driver
3556 ++ * detach.
3557 ++ */
3558 ++int devm_pci_remap_iospace(struct device *dev, const struct resource *res,
3559 ++ phys_addr_t phys_addr)
3560 ++{
3561 ++ const struct resource **ptr;
3562 ++ int error;
3563 ++
3564 ++ ptr = devres_alloc(devm_pci_unmap_iospace, sizeof(*ptr), GFP_KERNEL);
3565 ++ if (!ptr)
3566 ++ return -ENOMEM;
3567 ++
3568 ++ error = pci_remap_iospace(res, phys_addr);
3569 ++ if (error) {
3570 ++ devres_free(ptr);
3571 ++ } else {
3572 ++ *ptr = res;
3573 ++ devres_add(dev, ptr);
3574 ++ }
3575 ++
3576 ++ return error;
3577 ++}
3578 ++EXPORT_SYMBOL(devm_pci_remap_iospace);
3579 ++
3580 + /**
3581 + * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace()
3582 + * @dev: Generic device to remap IO address for
3583 +diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
3584 +index 4bccaf688aad..e23bfd9845b1 100644
3585 +--- a/drivers/pci/probe.c
3586 ++++ b/drivers/pci/probe.c
3587 +@@ -1560,6 +1560,10 @@ static void pci_configure_mps(struct pci_dev *dev)
3588 + if (!pci_is_pcie(dev) || !bridge || !pci_is_pcie(bridge))
3589 + return;
3590 +
3591 ++ /* MPS and MRRS fields are of type 'RsvdP' for VFs, short-circuit out */
3592 ++ if (dev->is_virtfn)
3593 ++ return;
3594 ++
3595 + mps = pcie_get_mps(dev);
3596 + p_mps = pcie_get_mps(bridge);
3597 +
3598 +diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c
3599 +index eb23311bc70c..8b79c2f7931f 100644
3600 +--- a/drivers/perf/xgene_pmu.c
3601 ++++ b/drivers/perf/xgene_pmu.c
3602 +@@ -1463,7 +1463,7 @@ static char *xgene_pmu_dev_name(struct device *dev, u32 type, int id)
3603 + case PMU_TYPE_IOB:
3604 + return devm_kasprintf(dev, GFP_KERNEL, "iob%d", id);
3605 + case PMU_TYPE_IOB_SLOW:
3606 +- return devm_kasprintf(dev, GFP_KERNEL, "iob-slow%d", id);
3607 ++ return devm_kasprintf(dev, GFP_KERNEL, "iob_slow%d", id);
3608 + case PMU_TYPE_MCB:
3609 + return devm_kasprintf(dev, GFP_KERNEL, "mcb%d", id);
3610 + case PMU_TYPE_MC:
3611 +diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
3612 +index 35c17653c694..87618a4e90e4 100644
3613 +--- a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
3614 ++++ b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
3615 +@@ -460,8 +460,8 @@ static int nsp_pinmux_enable(struct pinctrl_dev *pctrl_dev,
3616 + const struct nsp_pin_function *func;
3617 + const struct nsp_pin_group *grp;
3618 +
3619 +- if (grp_select > pinctrl->num_groups ||
3620 +- func_select > pinctrl->num_functions)
3621 ++ if (grp_select >= pinctrl->num_groups ||
3622 ++ func_select >= pinctrl->num_functions)
3623 + return -EINVAL;
3624 +
3625 + func = &pinctrl->functions[func_select];
3626 +@@ -577,6 +577,8 @@ static int nsp_pinmux_probe(struct platform_device *pdev)
3627 + return PTR_ERR(pinctrl->base0);
3628 +
3629 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
3630 ++ if (!res)
3631 ++ return -EINVAL;
3632 + pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start,
3633 + resource_size(res));
3634 + if (!pinctrl->base1) {
3635 +diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
3636 +index d84761822243..103aaab41357 100644
3637 +--- a/drivers/pinctrl/pinctrl-ingenic.c
3638 ++++ b/drivers/pinctrl/pinctrl-ingenic.c
3639 +@@ -536,7 +536,7 @@ static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
3640 + ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, input);
3641 + } else {
3642 + ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false);
3643 +- ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, input);
3644 ++ ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input);
3645 + ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false);
3646 + }
3647 +
3648 +diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
3649 +index 82f05c4b8c52..ae7a49ade414 100644
3650 +--- a/drivers/s390/cio/vfio_ccw_drv.c
3651 ++++ b/drivers/s390/cio/vfio_ccw_drv.c
3652 +@@ -176,6 +176,7 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
3653 + {
3654 + struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev);
3655 + unsigned long flags;
3656 ++ int rc = -EAGAIN;
3657 +
3658 + spin_lock_irqsave(sch->lock, flags);
3659 + if (!device_is_registered(&sch->dev))
3660 +@@ -186,6 +187,7 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
3661 +
3662 + if (cio_update_schib(sch)) {
3663 + vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_NOT_OPER);
3664 ++ rc = 0;
3665 + goto out_unlock;
3666 + }
3667 +
3668 +@@ -194,11 +196,12 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
3669 + private->state = private->mdev ? VFIO_CCW_STATE_IDLE :
3670 + VFIO_CCW_STATE_STANDBY;
3671 + }
3672 ++ rc = 0;
3673 +
3674 + out_unlock:
3675 + spin_unlock_irqrestore(sch->lock, flags);
3676 +
3677 +- return 0;
3678 ++ return rc;
3679 + }
3680 +
3681 + static struct css_device_id vfio_ccw_sch_ids[] = {
3682 +diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
3683 +index 382edb79a0de..56bcdd412d26 100644
3684 +--- a/drivers/scsi/qedf/qedf_main.c
3685 ++++ b/drivers/scsi/qedf/qedf_main.c
3686 +@@ -3240,6 +3240,11 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
3687 +
3688 + init_completion(&qedf->flogi_compl);
3689 +
3690 ++ status = qed_ops->common->update_drv_state(qedf->cdev, true);
3691 ++ if (status)
3692 ++ QEDF_ERR(&(qedf->dbg_ctx),
3693 ++ "Failed to send drv state to MFW.\n");
3694 ++
3695 + memset(&link_params, 0, sizeof(struct qed_link_params));
3696 + link_params.link_up = true;
3697 + status = qed_ops->common->set_link(qedf->cdev, &link_params);
3698 +@@ -3288,6 +3293,7 @@ static int qedf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
3699 + static void __qedf_remove(struct pci_dev *pdev, int mode)
3700 + {
3701 + struct qedf_ctx *qedf;
3702 ++ int rc;
3703 +
3704 + if (!pdev) {
3705 + QEDF_ERR(NULL, "pdev is NULL.\n");
3706 +@@ -3382,6 +3388,12 @@ static void __qedf_remove(struct pci_dev *pdev, int mode)
3707 + qed_ops->common->set_power_state(qedf->cdev, PCI_D0);
3708 + pci_set_drvdata(pdev, NULL);
3709 + }
3710 ++
3711 ++ rc = qed_ops->common->update_drv_state(qedf->cdev, false);
3712 ++ if (rc)
3713 ++ QEDF_ERR(&(qedf->dbg_ctx),
3714 ++ "Failed to send drv state to MFW.\n");
3715 ++
3716 + qed_ops->common->slowpath_stop(qedf->cdev);
3717 + qed_ops->common->remove(qedf->cdev);
3718 +
3719 +diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
3720 +index 1573749fe615..e7daadc089fc 100644
3721 +--- a/drivers/scsi/qedi/qedi_main.c
3722 ++++ b/drivers/scsi/qedi/qedi_main.c
3723 +@@ -2087,6 +2087,7 @@ kset_free:
3724 + static void __qedi_remove(struct pci_dev *pdev, int mode)
3725 + {
3726 + struct qedi_ctx *qedi = pci_get_drvdata(pdev);
3727 ++ int rval;
3728 +
3729 + if (qedi->tmf_thread) {
3730 + flush_workqueue(qedi->tmf_thread);
3731 +@@ -2116,6 +2117,10 @@ static void __qedi_remove(struct pci_dev *pdev, int mode)
3732 + if (mode == QEDI_MODE_NORMAL)
3733 + qedi_free_iscsi_pf_param(qedi);
3734 +
3735 ++ rval = qedi_ops->common->update_drv_state(qedi->cdev, false);
3736 ++ if (rval)
3737 ++ QEDI_ERR(&qedi->dbg_ctx, "Failed to send drv state to MFW\n");
3738 ++
3739 + if (!test_bit(QEDI_IN_OFFLINE, &qedi->flags)) {
3740 + qedi_ops->common->slowpath_stop(qedi->cdev);
3741 + qedi_ops->common->remove(qedi->cdev);
3742 +@@ -2390,6 +2395,12 @@ static int __qedi_probe(struct pci_dev *pdev, int mode)
3743 + if (qedi_setup_boot_info(qedi))
3744 + QEDI_ERR(&qedi->dbg_ctx,
3745 + "No iSCSI boot target configured\n");
3746 ++
3747 ++ rc = qedi_ops->common->update_drv_state(qedi->cdev, true);
3748 ++ if (rc)
3749 ++ QEDI_ERR(&qedi->dbg_ctx,
3750 ++ "Failed to send drv state to MFW\n");
3751 ++
3752 + }
3753 +
3754 + return 0;
3755 +diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
3756 +index 36f59a1be7e9..61389bdc7926 100644
3757 +--- a/drivers/scsi/xen-scsifront.c
3758 ++++ b/drivers/scsi/xen-scsifront.c
3759 +@@ -654,10 +654,17 @@ static int scsifront_dev_reset_handler(struct scsi_cmnd *sc)
3760 + static int scsifront_sdev_configure(struct scsi_device *sdev)
3761 + {
3762 + struct vscsifrnt_info *info = shost_priv(sdev->host);
3763 ++ int err;
3764 +
3765 +- if (info && current == info->curr)
3766 +- xenbus_printf(XBT_NIL, info->dev->nodename,
3767 ++ if (info && current == info->curr) {
3768 ++ err = xenbus_printf(XBT_NIL, info->dev->nodename,
3769 + info->dev_state_path, "%d", XenbusStateConnected);
3770 ++ if (err) {
3771 ++ xenbus_dev_error(info->dev, err,
3772 ++ "%s: writing dev_state_path", __func__);
3773 ++ return err;
3774 ++ }
3775 ++ }
3776 +
3777 + return 0;
3778 + }
3779 +@@ -665,10 +672,15 @@ static int scsifront_sdev_configure(struct scsi_device *sdev)
3780 + static void scsifront_sdev_destroy(struct scsi_device *sdev)
3781 + {
3782 + struct vscsifrnt_info *info = shost_priv(sdev->host);
3783 ++ int err;
3784 +
3785 +- if (info && current == info->curr)
3786 +- xenbus_printf(XBT_NIL, info->dev->nodename,
3787 ++ if (info && current == info->curr) {
3788 ++ err = xenbus_printf(XBT_NIL, info->dev->nodename,
3789 + info->dev_state_path, "%d", XenbusStateClosed);
3790 ++ if (err)
3791 ++ xenbus_dev_error(info->dev, err,
3792 ++ "%s: writing dev_state_path", __func__);
3793 ++ }
3794 + }
3795 +
3796 + static struct scsi_host_template scsifront_sht = {
3797 +@@ -1003,9 +1015,12 @@ static void scsifront_do_lun_hotplug(struct vscsifrnt_info *info, int op)
3798 +
3799 + if (scsi_add_device(info->host, chn, tgt, lun)) {
3800 + dev_err(&dev->dev, "scsi_add_device\n");
3801 +- xenbus_printf(XBT_NIL, dev->nodename,
3802 ++ err = xenbus_printf(XBT_NIL, dev->nodename,
3803 + info->dev_state_path,
3804 + "%d", XenbusStateClosed);
3805 ++ if (err)
3806 ++ xenbus_dev_error(dev, err,
3807 ++ "%s: writing dev_state_path", __func__);
3808 + }
3809 + break;
3810 + case VSCSIFRONT_OP_DEL_LUN:
3811 +@@ -1019,10 +1034,14 @@ static void scsifront_do_lun_hotplug(struct vscsifrnt_info *info, int op)
3812 + }
3813 + break;
3814 + case VSCSIFRONT_OP_READD_LUN:
3815 +- if (device_state == XenbusStateConnected)
3816 +- xenbus_printf(XBT_NIL, dev->nodename,
3817 ++ if (device_state == XenbusStateConnected) {
3818 ++ err = xenbus_printf(XBT_NIL, dev->nodename,
3819 + info->dev_state_path,
3820 + "%d", XenbusStateConnected);
3821 ++ if (err)
3822 ++ xenbus_dev_error(dev, err,
3823 ++ "%s: writing dev_state_path", __func__);
3824 ++ }
3825 + break;
3826 + default:
3827 + break;
3828 +diff --git a/drivers/soc/imx/gpc.c b/drivers/soc/imx/gpc.c
3829 +index 1613ccf0c059..c54d229f8da4 100644
3830 +--- a/drivers/soc/imx/gpc.c
3831 ++++ b/drivers/soc/imx/gpc.c
3832 +@@ -27,9 +27,16 @@
3833 + #define GPC_PGC_SW2ISO_SHIFT 0x8
3834 + #define GPC_PGC_SW_SHIFT 0x0
3835 +
3836 ++#define GPC_PGC_PCI_PDN 0x200
3837 ++#define GPC_PGC_PCI_SR 0x20c
3838 ++
3839 + #define GPC_PGC_GPU_PDN 0x260
3840 + #define GPC_PGC_GPU_PUPSCR 0x264
3841 + #define GPC_PGC_GPU_PDNSCR 0x268
3842 ++#define GPC_PGC_GPU_SR 0x26c
3843 ++
3844 ++#define GPC_PGC_DISP_PDN 0x240
3845 ++#define GPC_PGC_DISP_SR 0x24c
3846 +
3847 + #define GPU_VPU_PUP_REQ BIT(1)
3848 + #define GPU_VPU_PDN_REQ BIT(0)
3849 +@@ -303,10 +310,24 @@ static const struct of_device_id imx_gpc_dt_ids[] = {
3850 + { }
3851 + };
3852 +
3853 ++static const struct regmap_range yes_ranges[] = {
3854 ++ regmap_reg_range(GPC_CNTR, GPC_CNTR),
3855 ++ regmap_reg_range(GPC_PGC_PCI_PDN, GPC_PGC_PCI_SR),
3856 ++ regmap_reg_range(GPC_PGC_GPU_PDN, GPC_PGC_GPU_SR),
3857 ++ regmap_reg_range(GPC_PGC_DISP_PDN, GPC_PGC_DISP_SR),
3858 ++};
3859 ++
3860 ++static const struct regmap_access_table access_table = {
3861 ++ .yes_ranges = yes_ranges,
3862 ++ .n_yes_ranges = ARRAY_SIZE(yes_ranges),
3863 ++};
3864 ++
3865 + static const struct regmap_config imx_gpc_regmap_config = {
3866 + .reg_bits = 32,
3867 + .val_bits = 32,
3868 + .reg_stride = 4,
3869 ++ .rd_table = &access_table,
3870 ++ .wr_table = &access_table,
3871 + .max_register = 0x2ac,
3872 + };
3873 +
3874 +diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
3875 +index f4e3bd40c72e..6ef18cf8f243 100644
3876 +--- a/drivers/soc/imx/gpcv2.c
3877 ++++ b/drivers/soc/imx/gpcv2.c
3878 +@@ -39,10 +39,15 @@
3879 +
3880 + #define GPC_M4_PU_PDN_FLG 0x1bc
3881 +
3882 +-
3883 +-#define PGC_MIPI 4
3884 +-#define PGC_PCIE 5
3885 +-#define PGC_USB_HSIC 8
3886 ++/*
3887 ++ * The PGC offset values in Reference Manual
3888 ++ * (Rev. 1, 01/2018 and the older ones) GPC chapter's
3889 ++ * GPC_PGC memory map are incorrect, below offset
3890 ++ * values are from design RTL.
3891 ++ */
3892 ++#define PGC_MIPI 16
3893 ++#define PGC_PCIE 17
3894 ++#define PGC_USB_HSIC 20
3895 + #define GPC_PGC_CTRL(n) (0x800 + (n) * 0x40)
3896 + #define GPC_PGC_SR(n) (GPC_PGC_CTRL(n) + 0xc)
3897 +
3898 +diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
3899 +index 8af62e74d54c..f237e31926f4 100644
3900 +--- a/drivers/staging/typec/tcpm.c
3901 ++++ b/drivers/staging/typec/tcpm.c
3902 +@@ -2479,7 +2479,8 @@ static void run_state_machine(struct tcpm_port *port)
3903 + tcpm_port_is_sink(port) &&
3904 + time_is_after_jiffies(port->delayed_runtime)) {
3905 + tcpm_set_state(port, SNK_DISCOVERY,
3906 +- port->delayed_runtime - jiffies);
3907 ++ jiffies_to_msecs(port->delayed_runtime -
3908 ++ jiffies));
3909 + break;
3910 + }
3911 + tcpm_set_state(port, unattached_state(port), 0);
3912 +diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
3913 +index 899e8fe5e00f..9e26c530d2dd 100644
3914 +--- a/drivers/tty/pty.c
3915 ++++ b/drivers/tty/pty.c
3916 +@@ -625,7 +625,7 @@ int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags)
3917 + if (tty->driver != ptm_driver)
3918 + return -EIO;
3919 +
3920 +- fd = get_unused_fd_flags(0);
3921 ++ fd = get_unused_fd_flags(flags);
3922 + if (fd < 0) {
3923 + retval = fd;
3924 + goto err;
3925 +diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
3926 +index ec965ac5f1f5..3c0d386dc62f 100644
3927 +--- a/drivers/usb/dwc2/core.h
3928 ++++ b/drivers/usb/dwc2/core.h
3929 +@@ -872,6 +872,7 @@ struct dwc2_hregs_backup {
3930 + * @frame_list_sz: Frame list size
3931 + * @desc_gen_cache: Kmem cache for generic descriptors
3932 + * @desc_hsisoc_cache: Kmem cache for hs isochronous descriptors
3933 ++ * @unaligned_cache: Kmem cache for DMA mode to handle non-aligned buf
3934 + *
3935 + * These are for peripheral mode:
3936 + *
3937 +@@ -1004,6 +1005,8 @@ struct dwc2_hsotg {
3938 + u32 frame_list_sz;
3939 + struct kmem_cache *desc_gen_cache;
3940 + struct kmem_cache *desc_hsisoc_cache;
3941 ++ struct kmem_cache *unaligned_cache;
3942 ++#define DWC2_KMEM_UNALIGNED_BUF_SIZE 1024
3943 +
3944 + #ifdef DEBUG
3945 + u32 frrem_samples;
3946 +diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
3947 +index 6ef001a83fe2..e164439b2154 100644
3948 +--- a/drivers/usb/dwc2/gadget.c
3949 ++++ b/drivers/usb/dwc2/gadget.c
3950 +@@ -848,6 +848,7 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep,
3951 + u32 index;
3952 + u32 maxsize = 0;
3953 + u32 mask = 0;
3954 ++ u8 pid = 0;
3955 +
3956 + maxsize = dwc2_gadget_get_desc_params(hs_ep, &mask);
3957 + if (len > maxsize) {
3958 +@@ -893,7 +894,11 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep,
3959 + ((len << DEV_DMA_NBYTES_SHIFT) & mask));
3960 +
3961 + if (hs_ep->dir_in) {
3962 +- desc->status |= ((hs_ep->mc << DEV_DMA_ISOC_PID_SHIFT) &
3963 ++ if (len)
3964 ++ pid = DIV_ROUND_UP(len, hs_ep->ep.maxpacket);
3965 ++ else
3966 ++ pid = 1;
3967 ++ desc->status |= ((pid << DEV_DMA_ISOC_PID_SHIFT) &
3968 + DEV_DMA_ISOC_PID_MASK) |
3969 + ((len % hs_ep->ep.maxpacket) ?
3970 + DEV_DMA_SHORT : 0) |
3971 +@@ -932,6 +937,7 @@ static void dwc2_gadget_start_isoc_ddma(struct dwc2_hsotg_ep *hs_ep)
3972 + u32 ctrl;
3973 +
3974 + if (list_empty(&hs_ep->queue)) {
3975 ++ hs_ep->target_frame = TARGET_FRAME_INITIAL;
3976 + dev_dbg(hsotg->dev, "%s: No requests in queue\n", __func__);
3977 + return;
3978 + }
3979 +@@ -4716,9 +4722,11 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
3980 + }
3981 +
3982 + ret = usb_add_gadget_udc(dev, &hsotg->gadget);
3983 +- if (ret)
3984 ++ if (ret) {
3985 ++ dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep,
3986 ++ hsotg->ctrl_req);
3987 + return ret;
3988 +-
3989 ++ }
3990 + dwc2_hsotg_dump(hsotg);
3991 +
3992 + return 0;
3993 +@@ -4731,6 +4739,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
3994 + int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg)
3995 + {
3996 + usb_del_gadget_udc(&hsotg->gadget);
3997 ++ dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep, hsotg->ctrl_req);
3998 +
3999 + return 0;
4000 + }
4001 +diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
4002 +index 46d3b0fc00c5..fa20ec43a187 100644
4003 +--- a/drivers/usb/dwc2/hcd.c
4004 ++++ b/drivers/usb/dwc2/hcd.c
4005 +@@ -1544,11 +1544,20 @@ static void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
4006 + }
4007 +
4008 + if (hsotg->params.host_dma) {
4009 +- dwc2_writel((u32)chan->xfer_dma,
4010 +- hsotg->regs + HCDMA(chan->hc_num));
4011 ++ dma_addr_t dma_addr;
4012 ++
4013 ++ if (chan->align_buf) {
4014 ++ if (dbg_hc(chan))
4015 ++ dev_vdbg(hsotg->dev, "align_buf\n");
4016 ++ dma_addr = chan->align_buf;
4017 ++ } else {
4018 ++ dma_addr = chan->xfer_dma;
4019 ++ }
4020 ++ dwc2_writel((u32)dma_addr, hsotg->regs + HCDMA(chan->hc_num));
4021 ++
4022 + if (dbg_hc(chan))
4023 + dev_vdbg(hsotg->dev, "Wrote %08lx to HCDMA(%d)\n",
4024 +- (unsigned long)chan->xfer_dma, chan->hc_num);
4025 ++ (unsigned long)dma_addr, chan->hc_num);
4026 + }
4027 +
4028 + /* Start the split */
4029 +@@ -2604,6 +2613,35 @@ static void dwc2_hc_init_xfer(struct dwc2_hsotg *hsotg,
4030 + }
4031 + }
4032 +
4033 ++static int dwc2_alloc_split_dma_aligned_buf(struct dwc2_hsotg *hsotg,
4034 ++ struct dwc2_qh *qh,
4035 ++ struct dwc2_host_chan *chan)
4036 ++{
4037 ++ if (!hsotg->unaligned_cache ||
4038 ++ chan->max_packet > DWC2_KMEM_UNALIGNED_BUF_SIZE)
4039 ++ return -ENOMEM;
4040 ++
4041 ++ if (!qh->dw_align_buf) {
4042 ++ qh->dw_align_buf = kmem_cache_alloc(hsotg->unaligned_cache,
4043 ++ GFP_ATOMIC | GFP_DMA);
4044 ++ if (!qh->dw_align_buf)
4045 ++ return -ENOMEM;
4046 ++ }
4047 ++
4048 ++ qh->dw_align_buf_dma = dma_map_single(hsotg->dev, qh->dw_align_buf,
4049 ++ DWC2_KMEM_UNALIGNED_BUF_SIZE,
4050 ++ DMA_FROM_DEVICE);
4051 ++
4052 ++ if (dma_mapping_error(hsotg->dev, qh->dw_align_buf_dma)) {
4053 ++ dev_err(hsotg->dev, "can't map align_buf\n");
4054 ++ chan->align_buf = 0;
4055 ++ return -EINVAL;
4056 ++ }
4057 ++
4058 ++ chan->align_buf = qh->dw_align_buf_dma;
4059 ++ return 0;
4060 ++}
4061 ++
4062 + #define DWC2_USB_DMA_ALIGN 4
4063 +
4064 + static void dwc2_free_dma_aligned_buffer(struct urb *urb)
4065 +@@ -2783,6 +2821,32 @@ static int dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
4066 + /* Set the transfer attributes */
4067 + dwc2_hc_init_xfer(hsotg, chan, qtd);
4068 +
4069 ++ /* For non-dword aligned buffers */
4070 ++ if (hsotg->params.host_dma && qh->do_split &&
4071 ++ chan->ep_is_in && (chan->xfer_dma & 0x3)) {
4072 ++ dev_vdbg(hsotg->dev, "Non-aligned buffer\n");
4073 ++ if (dwc2_alloc_split_dma_aligned_buf(hsotg, qh, chan)) {
4074 ++ dev_err(hsotg->dev,
4075 ++ "Failed to allocate memory to handle non-aligned buffer\n");
4076 ++ /* Add channel back to free list */
4077 ++ chan->align_buf = 0;
4078 ++ chan->multi_count = 0;
4079 ++ list_add_tail(&chan->hc_list_entry,
4080 ++ &hsotg->free_hc_list);
4081 ++ qtd->in_process = 0;
4082 ++ qh->channel = NULL;
4083 ++ return -ENOMEM;
4084 ++ }
4085 ++ } else {
4086 ++ /*
4087 ++ * We assume that DMA is always aligned in non-split
4088 ++ * case or split out case. Warn if not.
4089 ++ */
4090 ++ WARN_ON_ONCE(hsotg->params.host_dma &&
4091 ++ (chan->xfer_dma & 0x3));
4092 ++ chan->align_buf = 0;
4093 ++ }
4094 ++
4095 + if (chan->ep_type == USB_ENDPOINT_XFER_INT ||
4096 + chan->ep_type == USB_ENDPOINT_XFER_ISOC)
4097 + /*
4098 +@@ -5277,6 +5341,19 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
4099 + }
4100 + }
4101 +
4102 ++ if (hsotg->params.host_dma) {
4103 ++ /*
4104 ++ * Create kmem caches to handle non-aligned buffer
4105 ++ * in Buffer DMA mode.
4106 ++ */
4107 ++ hsotg->unaligned_cache = kmem_cache_create("dwc2-unaligned-dma",
4108 ++ DWC2_KMEM_UNALIGNED_BUF_SIZE, 4,
4109 ++ SLAB_CACHE_DMA, NULL);
4110 ++ if (!hsotg->unaligned_cache)
4111 ++ dev_err(hsotg->dev,
4112 ++ "unable to create dwc2 unaligned cache\n");
4113 ++ }
4114 ++
4115 + hsotg->otg_port = 1;
4116 + hsotg->frame_list = NULL;
4117 + hsotg->frame_list_dma = 0;
4118 +@@ -5311,8 +5388,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
4119 + return 0;
4120 +
4121 + error4:
4122 +- kmem_cache_destroy(hsotg->desc_gen_cache);
4123 ++ kmem_cache_destroy(hsotg->unaligned_cache);
4124 + kmem_cache_destroy(hsotg->desc_hsisoc_cache);
4125 ++ kmem_cache_destroy(hsotg->desc_gen_cache);
4126 + error3:
4127 + dwc2_hcd_release(hsotg);
4128 + error2:
4129 +@@ -5353,8 +5431,9 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
4130 + usb_remove_hcd(hcd);
4131 + hsotg->priv = NULL;
4132 +
4133 +- kmem_cache_destroy(hsotg->desc_gen_cache);
4134 ++ kmem_cache_destroy(hsotg->unaligned_cache);
4135 + kmem_cache_destroy(hsotg->desc_hsisoc_cache);
4136 ++ kmem_cache_destroy(hsotg->desc_gen_cache);
4137 +
4138 + dwc2_hcd_release(hsotg);
4139 + usb_put_hcd(hcd);
4140 +diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
4141 +index 11c3c145b793..461bdc67df6f 100644
4142 +--- a/drivers/usb/dwc2/hcd.h
4143 ++++ b/drivers/usb/dwc2/hcd.h
4144 +@@ -75,6 +75,8 @@ struct dwc2_qh;
4145 + * (micro)frame
4146 + * @xfer_buf: Pointer to current transfer buffer position
4147 + * @xfer_dma: DMA address of xfer_buf
4148 ++ * @align_buf: In Buffer DMA mode this will be used if xfer_buf is not
4149 ++ * DWORD aligned
4150 + * @xfer_len: Total number of bytes to transfer
4151 + * @xfer_count: Number of bytes transferred so far
4152 + * @start_pkt_count: Packet count at start of transfer
4153 +@@ -132,6 +134,7 @@ struct dwc2_host_chan {
4154 +
4155 + u8 *xfer_buf;
4156 + dma_addr_t xfer_dma;
4157 ++ dma_addr_t align_buf;
4158 + u32 xfer_len;
4159 + u32 xfer_count;
4160 + u16 start_pkt_count;
4161 +@@ -302,6 +305,9 @@ struct dwc2_hs_transfer_time {
4162 + * is tightly packed.
4163 + * @ls_duration_us: Duration on the low speed bus schedule.
4164 + * @ntd: Actual number of transfer descriptors in a list
4165 ++ * @dw_align_buf: Used instead of original buffer if its physical address
4166 ++ * is not dword-aligned
4167 ++ * @dw_align_buf_dma: DMA address for dw_align_buf
4168 + * @qtd_list: List of QTDs for this QH
4169 + * @channel: Host channel currently processing transfers for this QH
4170 + * @qh_list_entry: Entry for QH in either the periodic or non-periodic
4171 +@@ -345,6 +351,8 @@ struct dwc2_qh {
4172 + struct dwc2_hs_transfer_time hs_transfers[DWC2_HS_SCHEDULE_UFRAMES];
4173 + u32 ls_start_schedule_slice;
4174 + u16 ntd;
4175 ++ u8 *dw_align_buf;
4176 ++ dma_addr_t dw_align_buf_dma;
4177 + struct list_head qtd_list;
4178 + struct dwc2_host_chan *channel;
4179 + struct list_head qh_list_entry;
4180 +diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
4181 +index 28a8210710b1..17905ba1139c 100644
4182 +--- a/drivers/usb/dwc2/hcd_intr.c
4183 ++++ b/drivers/usb/dwc2/hcd_intr.c
4184 +@@ -923,14 +923,21 @@ static int dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg *hsotg,
4185 + frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index];
4186 + len = dwc2_get_actual_xfer_length(hsotg, chan, chnum, qtd,
4187 + DWC2_HC_XFER_COMPLETE, NULL);
4188 +- if (!len) {
4189 ++ if (!len && !qtd->isoc_split_offset) {
4190 + qtd->complete_split = 0;
4191 +- qtd->isoc_split_offset = 0;
4192 + return 0;
4193 + }
4194 +
4195 + frame_desc->actual_length += len;
4196 +
4197 ++ if (chan->align_buf) {
4198 ++ dev_vdbg(hsotg->dev, "non-aligned buffer\n");
4199 ++ dma_unmap_single(hsotg->dev, chan->qh->dw_align_buf_dma,
4200 ++ DWC2_KMEM_UNALIGNED_BUF_SIZE, DMA_FROM_DEVICE);
4201 ++ memcpy(qtd->urb->buf + (chan->xfer_dma - qtd->urb->dma),
4202 ++ chan->qh->dw_align_buf, len);
4203 ++ }
4204 ++
4205 + qtd->isoc_split_offset += len;
4206 +
4207 + hctsiz = dwc2_readl(hsotg->regs + HCTSIZ(chnum));
4208 +diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
4209 +index 7f51a77bc5cc..56e61220efc6 100644
4210 +--- a/drivers/usb/dwc2/hcd_queue.c
4211 ++++ b/drivers/usb/dwc2/hcd_queue.c
4212 +@@ -1632,6 +1632,9 @@ void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
4213 +
4214 + if (qh->desc_list)
4215 + dwc2_hcd_qh_free_ddma(hsotg, qh);
4216 ++ else if (hsotg->unaligned_cache && qh->dw_align_buf)
4217 ++ kmem_cache_free(hsotg->unaligned_cache, qh->dw_align_buf);
4218 ++
4219 + kfree(qh);
4220 + }
4221 +
4222 +diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
4223 +index fbfc09ebd2ec..acf41ba3638d 100644
4224 +--- a/drivers/usb/dwc3/dwc3-of-simple.c
4225 ++++ b/drivers/usb/dwc3/dwc3-of-simple.c
4226 +@@ -132,8 +132,9 @@ static int dwc3_of_simple_remove(struct platform_device *pdev)
4227 +
4228 + of_platform_depopulate(dev);
4229 +
4230 +- pm_runtime_put_sync(dev);
4231 + pm_runtime_disable(dev);
4232 ++ pm_runtime_put_noidle(dev);
4233 ++ pm_runtime_set_suspended(dev);
4234 +
4235 + return 0;
4236 + }
4237 +diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
4238 +index bc5e91d4fac8..09c0454833ad 100644
4239 +--- a/drivers/usb/dwc3/dwc3-pci.c
4240 ++++ b/drivers/usb/dwc3/dwc3-pci.c
4241 +@@ -41,6 +41,7 @@
4242 + #define PCI_DEVICE_ID_INTEL_GLK 0x31aa
4243 + #define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee
4244 + #define PCI_DEVICE_ID_INTEL_CNPH 0xa36e
4245 ++#define PCI_DEVICE_ID_INTEL_ICLLP 0x34ee
4246 +
4247 + #define PCI_INTEL_BXT_DSM_GUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
4248 + #define PCI_INTEL_BXT_FUNC_PMU_PWR 4
4249 +@@ -273,6 +274,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
4250 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), },
4251 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPLP), },
4252 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPH), },
4253 ++ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICLLP), },
4254 + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
4255 + { } /* Terminating Entry */
4256 + };
4257 +diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
4258 +index 940de04ed72a..b805962f5154 100644
4259 +--- a/drivers/usb/gadget/composite.c
4260 ++++ b/drivers/usb/gadget/composite.c
4261 +@@ -1720,6 +1720,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
4262 + */
4263 + if (w_value && !f->get_alt)
4264 + break;
4265 ++
4266 ++ spin_lock(&cdev->lock);
4267 + value = f->set_alt(f, w_index, w_value);
4268 + if (value == USB_GADGET_DELAYED_STATUS) {
4269 + DBG(cdev,
4270 +@@ -1729,6 +1731,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
4271 + DBG(cdev, "delayed_status count %d\n",
4272 + cdev->delayed_status);
4273 + }
4274 ++ spin_unlock(&cdev->lock);
4275 + break;
4276 + case USB_REQ_GET_INTERFACE:
4277 + if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE))
4278 +diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
4279 +index 52e6897fa35a..17467545391b 100644
4280 +--- a/drivers/usb/gadget/function/f_fs.c
4281 ++++ b/drivers/usb/gadget/function/f_fs.c
4282 +@@ -219,6 +219,7 @@ struct ffs_io_data {
4283 +
4284 + struct mm_struct *mm;
4285 + struct work_struct work;
4286 ++ struct work_struct cancellation_work;
4287 +
4288 + struct usb_ep *ep;
4289 + struct usb_request *req;
4290 +@@ -1073,22 +1074,31 @@ ffs_epfile_open(struct inode *inode, struct file *file)
4291 + return 0;
4292 + }
4293 +
4294 ++static void ffs_aio_cancel_worker(struct work_struct *work)
4295 ++{
4296 ++ struct ffs_io_data *io_data = container_of(work, struct ffs_io_data,
4297 ++ cancellation_work);
4298 ++
4299 ++ ENTER();
4300 ++
4301 ++ usb_ep_dequeue(io_data->ep, io_data->req);
4302 ++}
4303 ++
4304 + static int ffs_aio_cancel(struct kiocb *kiocb)
4305 + {
4306 + struct ffs_io_data *io_data = kiocb->private;
4307 +- struct ffs_epfile *epfile = kiocb->ki_filp->private_data;
4308 ++ struct ffs_data *ffs = io_data->ffs;
4309 + int value;
4310 +
4311 + ENTER();
4312 +
4313 +- spin_lock_irq(&epfile->ffs->eps_lock);
4314 +-
4315 +- if (likely(io_data && io_data->ep && io_data->req))
4316 +- value = usb_ep_dequeue(io_data->ep, io_data->req);
4317 +- else
4318 ++ if (likely(io_data && io_data->ep && io_data->req)) {
4319 ++ INIT_WORK(&io_data->cancellation_work, ffs_aio_cancel_worker);
4320 ++ queue_work(ffs->io_completion_wq, &io_data->cancellation_work);
4321 ++ value = -EINPROGRESS;
4322 ++ } else {
4323 + value = -EINVAL;
4324 +-
4325 +- spin_unlock_irq(&epfile->ffs->eps_lock);
4326 ++ }
4327 +
4328 + return value;
4329 + }
4330 +diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
4331 +index 74436f8ca538..32ddafe7af87 100644
4332 +--- a/drivers/usb/host/xhci-tegra.c
4333 ++++ b/drivers/usb/host/xhci-tegra.c
4334 +@@ -482,7 +482,7 @@ static void tegra_xusb_mbox_handle(struct tegra_xusb *tegra,
4335 + unsigned long mask;
4336 + unsigned int port;
4337 + bool idle, enable;
4338 +- int err;
4339 ++ int err = 0;
4340 +
4341 + memset(&rsp, 0, sizeof(rsp));
4342 +
4343 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
4344 +index fe84b36627ec..6b11fd9d8efe 100644
4345 +--- a/drivers/usb/host/xhci.c
4346 ++++ b/drivers/usb/host/xhci.c
4347 +@@ -1024,8 +1024,13 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
4348 + command = readl(&xhci->op_regs->command);
4349 + command |= CMD_CRS;
4350 + writel(command, &xhci->op_regs->command);
4351 ++ /*
4352 ++ * Some controllers take up to 55+ ms to complete the controller
4353 ++ * restore so setting the timeout to 100ms. Xhci specification
4354 ++ * doesn't mention any timeout value.
4355 ++ */
4356 + if (xhci_handshake(&xhci->op_regs->status,
4357 +- STS_RESTORE, 0, 10 * 1000)) {
4358 ++ STS_RESTORE, 0, 100 * 1000)) {
4359 + xhci_warn(xhci, "WARN: xHC restore state timeout\n");
4360 + spin_unlock_irq(&xhci->lock);
4361 + return -ETIMEDOUT;
4362 +diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
4363 +index c425d03d37d2..587d12829925 100644
4364 +--- a/drivers/xen/manage.c
4365 ++++ b/drivers/xen/manage.c
4366 +@@ -292,8 +292,15 @@ static void sysrq_handler(struct xenbus_watch *watch, const char *path,
4367 + return;
4368 + }
4369 +
4370 +- if (sysrq_key != '\0')
4371 +- xenbus_printf(xbt, "control", "sysrq", "%c", '\0');
4372 ++ if (sysrq_key != '\0') {
4373 ++ err = xenbus_printf(xbt, "control", "sysrq", "%c", '\0');
4374 ++ if (err) {
4375 ++ pr_err("%s: Error %d writing sysrq in control/sysrq\n",
4376 ++ __func__, err);
4377 ++ xenbus_transaction_end(xbt, 1);
4378 ++ return;
4379 ++ }
4380 ++ }
4381 +
4382 + err = xenbus_transaction_end(xbt, 0);
4383 + if (err == -EAGAIN)
4384 +@@ -345,7 +352,12 @@ static int setup_shutdown_watcher(void)
4385 + continue;
4386 + snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
4387 + shutdown_handlers[idx].command);
4388 +- xenbus_printf(XBT_NIL, "control", node, "%u", 1);
4389 ++ err = xenbus_printf(XBT_NIL, "control", node, "%u", 1);
4390 ++ if (err) {
4391 ++ pr_err("%s: Error %d writing %s\n", __func__,
4392 ++ err, node);
4393 ++ return err;
4394 ++ }
4395 + }
4396 +
4397 + return 0;
4398 +diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
4399 +index 7bc88fd43cfc..e2f3e8b0fba9 100644
4400 +--- a/drivers/xen/xen-scsiback.c
4401 ++++ b/drivers/xen/xen-scsiback.c
4402 +@@ -1012,6 +1012,7 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
4403 + {
4404 + struct v2p_entry *entry;
4405 + unsigned long flags;
4406 ++ int err;
4407 +
4408 + if (try) {
4409 + spin_lock_irqsave(&info->v2p_lock, flags);
4410 +@@ -1027,8 +1028,11 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
4411 + scsiback_del_translation_entry(info, vir);
4412 + }
4413 + } else if (!try) {
4414 +- xenbus_printf(XBT_NIL, info->dev->nodename, state,
4415 ++ err = xenbus_printf(XBT_NIL, info->dev->nodename, state,
4416 + "%d", XenbusStateClosed);
4417 ++ if (err)
4418 ++ xenbus_dev_error(info->dev, err,
4419 ++ "%s: writing %s", __func__, state);
4420 + }
4421 + }
4422 +
4423 +@@ -1067,8 +1071,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
4424 + snprintf(str, sizeof(str), "vscsi-devs/%s/p-dev", ent);
4425 + val = xenbus_read(XBT_NIL, dev->nodename, str, NULL);
4426 + if (IS_ERR(val)) {
4427 +- xenbus_printf(XBT_NIL, dev->nodename, state,
4428 ++ err = xenbus_printf(XBT_NIL, dev->nodename, state,
4429 + "%d", XenbusStateClosed);
4430 ++ if (err)
4431 ++ xenbus_dev_error(info->dev, err,
4432 ++ "%s: writing %s", __func__, state);
4433 + return;
4434 + }
4435 + strlcpy(phy, val, VSCSI_NAMELEN);
4436 +@@ -1079,8 +1086,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
4437 + err = xenbus_scanf(XBT_NIL, dev->nodename, str, "%u:%u:%u:%u",
4438 + &vir.hst, &vir.chn, &vir.tgt, &vir.lun);
4439 + if (XENBUS_EXIST_ERR(err)) {
4440 +- xenbus_printf(XBT_NIL, dev->nodename, state,
4441 ++ err = xenbus_printf(XBT_NIL, dev->nodename, state,
4442 + "%d", XenbusStateClosed);
4443 ++ if (err)
4444 ++ xenbus_dev_error(info->dev, err,
4445 ++ "%s: writing %s", __func__, state);
4446 + return;
4447 + }
4448 +
4449 +diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
4450 +index 936d58ca2b49..61192c536e6c 100644
4451 +--- a/fs/btrfs/scrub.c
4452 ++++ b/fs/btrfs/scrub.c
4453 +@@ -1166,11 +1166,6 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
4454 + return ret;
4455 + }
4456 +
4457 +- if (sctx->is_dev_replace && !is_metadata && !have_csum) {
4458 +- sblocks_for_recheck = NULL;
4459 +- goto nodatasum_case;
4460 +- }
4461 +-
4462 + /*
4463 + * read all mirrors one after the other. This includes to
4464 + * re-read the extent or metadata block that failed (that was
4465 +@@ -1283,13 +1278,19 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
4466 + goto out;
4467 + }
4468 +
4469 +- if (!is_metadata && !have_csum) {
4470 ++ /*
4471 ++ * NOTE: Even for nodatasum case, it's still possible that it's a
4472 ++ * compressed data extent, thus scrub_fixup_nodatasum(), which write
4473 ++ * inode page cache onto disk, could cause serious data corruption.
4474 ++ *
4475 ++ * So here we could only read from disk, and hope our recovery could
4476 ++ * reach disk before the newer write.
4477 ++ */
4478 ++ if (0 && !is_metadata && !have_csum) {
4479 + struct scrub_fixup_nodatasum *fixup_nodatasum;
4480 +
4481 + WARN_ON(sctx->is_dev_replace);
4482 +
4483 +-nodatasum_case:
4484 +-
4485 + /*
4486 + * !is_metadata and !have_csum, this means that the data
4487 + * might not be COWed, that it might be modified
4488 +diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
4489 +index f2550a076edc..d5124ed35154 100644
4490 +--- a/fs/ceph/inode.c
4491 ++++ b/fs/ceph/inode.c
4492 +@@ -1087,6 +1087,7 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in)
4493 + if (IS_ERR(realdn)) {
4494 + pr_err("splice_dentry error %ld %p inode %p ino %llx.%llx\n",
4495 + PTR_ERR(realdn), dn, in, ceph_vinop(in));
4496 ++ dput(dn);
4497 + dn = realdn; /* note realdn contains the error */
4498 + goto out;
4499 + } else if (realdn) {
4500 +diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
4501 +index 048c586d9a8b..1792999eec91 100644
4502 +--- a/fs/ext4/mballoc.c
4503 ++++ b/fs/ext4/mballoc.c
4504 +@@ -26,6 +26,7 @@
4505 + #include <linux/log2.h>
4506 + #include <linux/module.h>
4507 + #include <linux/slab.h>
4508 ++#include <linux/nospec.h>
4509 + #include <linux/backing-dev.h>
4510 + #include <trace/events/ext4.h>
4511 +
4512 +@@ -2152,7 +2153,8 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
4513 + * This should tell if fe_len is exactly power of 2
4514 + */
4515 + if ((ac->ac_g_ex.fe_len & (~(1 << (i - 1)))) == 0)
4516 +- ac->ac_2order = i - 1;
4517 ++ ac->ac_2order = array_index_nospec(i - 1,
4518 ++ sb->s_blocksize_bits + 2);
4519 + }
4520 +
4521 + /* if stream allocation is enabled, use global goal */
4522 +diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
4523 +index 7c05bd4222b2..3c7bbbae0afa 100644
4524 +--- a/fs/f2fs/segment.c
4525 ++++ b/fs/f2fs/segment.c
4526 +@@ -3240,7 +3240,7 @@ static int build_curseg(struct f2fs_sb_info *sbi)
4527 + return restore_curseg_summaries(sbi);
4528 + }
4529 +
4530 +-static void build_sit_entries(struct f2fs_sb_info *sbi)
4531 ++static int build_sit_entries(struct f2fs_sb_info *sbi)
4532 + {
4533 + struct sit_info *sit_i = SIT_I(sbi);
4534 + struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
4535 +@@ -3250,6 +3250,8 @@ static void build_sit_entries(struct f2fs_sb_info *sbi)
4536 + int sit_blk_cnt = SIT_BLK_CNT(sbi);
4537 + unsigned int i, start, end;
4538 + unsigned int readed, start_blk = 0;
4539 ++ int err = 0;
4540 ++ block_t total_node_blocks = 0;
4541 +
4542 + do {
4543 + readed = ra_meta_pages(sbi, start_blk, BIO_MAX_PAGES,
4544 +@@ -3268,8 +3270,12 @@ static void build_sit_entries(struct f2fs_sb_info *sbi)
4545 + sit = sit_blk->entries[SIT_ENTRY_OFFSET(sit_i, start)];
4546 + f2fs_put_page(page, 1);
4547 +
4548 +- check_block_count(sbi, start, &sit);
4549 ++ err = check_block_count(sbi, start, &sit);
4550 ++ if (err)
4551 ++ return err;
4552 + seg_info_from_raw_sit(se, &sit);
4553 ++ if (IS_NODESEG(se->type))
4554 ++ total_node_blocks += se->valid_blocks;
4555 +
4556 + /* build discard map only one time */
4557 + if (f2fs_discard_en(sbi)) {
4558 +@@ -3302,9 +3308,15 @@ static void build_sit_entries(struct f2fs_sb_info *sbi)
4559 + sit = sit_in_journal(journal, i);
4560 +
4561 + old_valid_blocks = se->valid_blocks;
4562 ++ if (IS_NODESEG(se->type))
4563 ++ total_node_blocks -= old_valid_blocks;
4564 +
4565 +- check_block_count(sbi, start, &sit);
4566 ++ err = check_block_count(sbi, start, &sit);
4567 ++ if (err)
4568 ++ break;
4569 + seg_info_from_raw_sit(se, &sit);
4570 ++ if (IS_NODESEG(se->type))
4571 ++ total_node_blocks += se->valid_blocks;
4572 +
4573 + if (f2fs_discard_en(sbi)) {
4574 + if (is_set_ckpt_flags(sbi, CP_TRIMMED_FLAG)) {
4575 +@@ -3323,6 +3335,16 @@ static void build_sit_entries(struct f2fs_sb_info *sbi)
4576 + se->valid_blocks - old_valid_blocks;
4577 + }
4578 + up_read(&curseg->journal_rwsem);
4579 ++
4580 ++ if (!err && total_node_blocks != valid_node_count(sbi)) {
4581 ++ f2fs_msg(sbi->sb, KERN_ERR,
4582 ++ "SIT is corrupted node# %u vs %u",
4583 ++ total_node_blocks, valid_node_count(sbi));
4584 ++ set_sbi_flag(sbi, SBI_NEED_FSCK);
4585 ++ err = -EINVAL;
4586 ++ }
4587 ++
4588 ++ return err;
4589 + }
4590 +
4591 + static void init_free_segmap(struct f2fs_sb_info *sbi)
4592 +@@ -3492,7 +3514,9 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
4593 + return err;
4594 +
4595 + /* reinit free segmap based on SIT */
4596 +- build_sit_entries(sbi);
4597 ++ err = build_sit_entries(sbi);
4598 ++ if (err)
4599 ++ return err;
4600 +
4601 + init_free_segmap(sbi);
4602 + err = build_dirty_segmap(sbi);
4603 +diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
4604 +index e0a6cc23ace3..39ada30889b6 100644
4605 +--- a/fs/f2fs/segment.h
4606 ++++ b/fs/f2fs/segment.h
4607 +@@ -625,7 +625,7 @@ static inline void verify_block_addr(struct f2fs_sb_info *sbi, block_t blk_addr)
4608 + /*
4609 + * Summary block is always treated as an invalid block
4610 + */
4611 +-static inline void check_block_count(struct f2fs_sb_info *sbi,
4612 ++static inline int check_block_count(struct f2fs_sb_info *sbi,
4613 + int segno, struct f2fs_sit_entry *raw_sit)
4614 + {
4615 + #ifdef CONFIG_F2FS_CHECK_FS
4616 +@@ -647,11 +647,25 @@ static inline void check_block_count(struct f2fs_sb_info *sbi,
4617 + cur_pos = next_pos;
4618 + is_valid = !is_valid;
4619 + } while (cur_pos < sbi->blocks_per_seg);
4620 +- BUG_ON(GET_SIT_VBLOCKS(raw_sit) != valid_blocks);
4621 ++
4622 ++ if (unlikely(GET_SIT_VBLOCKS(raw_sit) != valid_blocks)) {
4623 ++ f2fs_msg(sbi->sb, KERN_ERR,
4624 ++ "Mismatch valid blocks %d vs. %d",
4625 ++ GET_SIT_VBLOCKS(raw_sit), valid_blocks);
4626 ++ set_sbi_flag(sbi, SBI_NEED_FSCK);
4627 ++ return -EINVAL;
4628 ++ }
4629 + #endif
4630 + /* check segment usage, and check boundary of a given segment number */
4631 +- f2fs_bug_on(sbi, GET_SIT_VBLOCKS(raw_sit) > sbi->blocks_per_seg
4632 +- || segno > TOTAL_SEGS(sbi) - 1);
4633 ++ if (unlikely(GET_SIT_VBLOCKS(raw_sit) > sbi->blocks_per_seg
4634 ++ || segno > TOTAL_SEGS(sbi) - 1)) {
4635 ++ f2fs_msg(sbi->sb, KERN_ERR,
4636 ++ "Wrong valid blocks %d or segno %u",
4637 ++ GET_SIT_VBLOCKS(raw_sit), segno);
4638 ++ set_sbi_flag(sbi, SBI_NEED_FSCK);
4639 ++ return -EINVAL;
4640 ++ }
4641 ++ return 0;
4642 + }
4643 +
4644 + static inline pgoff_t current_sit_addr(struct f2fs_sb_info *sbi,
4645 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
4646 +index 43fbf4495090..51deff8e1f86 100644
4647 +--- a/fs/nfs/nfs4proc.c
4648 ++++ b/fs/nfs/nfs4proc.c
4649 +@@ -8429,6 +8429,8 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
4650 +
4651 + dprintk("--> %s tk_status => %d\n", __func__, -task->tk_status);
4652 +
4653 ++ nfs4_sequence_free_slot(&lgp->res.seq_res);
4654 ++
4655 + switch (nfs4err) {
4656 + case 0:
4657 + goto out;
4658 +@@ -8493,7 +8495,6 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
4659 + goto out;
4660 + }
4661 +
4662 +- nfs4_sequence_free_slot(&lgp->res.seq_res);
4663 + err = nfs4_handle_exception(server, nfs4err, exception);
4664 + if (!status) {
4665 + if (exception->retry)
4666 +@@ -8619,20 +8620,22 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout, gfp_t gfp_flags)
4667 + if (IS_ERR(task))
4668 + return ERR_CAST(task);
4669 + status = rpc_wait_for_completion_task(task);
4670 +- if (status == 0) {
4671 ++ if (status != 0)
4672 ++ goto out;
4673 ++
4674 ++ /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */
4675 ++ if (task->tk_status < 0 || lgp->res.layoutp->len == 0) {
4676 + status = nfs4_layoutget_handle_exception(task, lgp, &exception);
4677 + *timeout = exception.timeout;
4678 +- }
4679 +-
4680 ++ } else
4681 ++ lseg = pnfs_layout_process(lgp);
4682 ++out:
4683 + trace_nfs4_layoutget(lgp->args.ctx,
4684 + &lgp->args.range,
4685 + &lgp->res.range,
4686 + &lgp->res.stateid,
4687 + status);
4688 +
4689 +- /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */
4690 +- if (status == 0 && lgp->res.layoutp->len)
4691 +- lseg = pnfs_layout_process(lgp);
4692 + rpc_put_task(task);
4693 + dprintk("<-- %s status=%d\n", __func__, status);
4694 + if (status)
4695 +diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
4696 +index 46492fb37a4c..505f87a8c724 100644
4697 +--- a/fs/reiserfs/xattr.c
4698 ++++ b/fs/reiserfs/xattr.c
4699 +@@ -792,8 +792,10 @@ static int listxattr_filler(struct dir_context *ctx, const char *name,
4700 + return 0;
4701 + size = namelen + 1;
4702 + if (b->buf) {
4703 +- if (size > b->size)
4704 ++ if (b->pos + size > b->size) {
4705 ++ b->pos = -ERANGE;
4706 + return -ERANGE;
4707 ++ }
4708 + memcpy(b->buf + b->pos, name, namelen);
4709 + b->buf[b->pos + namelen] = 0;
4710 + }
4711 +diff --git a/include/linux/fsl/guts.h b/include/linux/fsl/guts.h
4712 +index 3efa3b861d44..941b11811f85 100644
4713 +--- a/include/linux/fsl/guts.h
4714 ++++ b/include/linux/fsl/guts.h
4715 +@@ -16,6 +16,7 @@
4716 + #define __FSL_GUTS_H__
4717 +
4718 + #include <linux/types.h>
4719 ++#include <linux/io.h>
4720 +
4721 + /**
4722 + * Global Utility Registers.
4723 +diff --git a/include/linux/pci.h b/include/linux/pci.h
4724 +index 727e309baa5e..9d6fae809c09 100644
4725 +--- a/include/linux/pci.h
4726 ++++ b/include/linux/pci.h
4727 +@@ -1235,6 +1235,8 @@ int pci_register_io_range(phys_addr_t addr, resource_size_t size);
4728 + unsigned long pci_address_to_pio(phys_addr_t addr);
4729 + phys_addr_t pci_pio_to_address(unsigned long pio);
4730 + int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr);
4731 ++int devm_pci_remap_iospace(struct device *dev, const struct resource *res,
4732 ++ phys_addr_t phys_addr);
4733 + void pci_unmap_iospace(struct resource *res);
4734 + void __iomem *devm_pci_remap_cfgspace(struct device *dev,
4735 + resource_size_t offset,
4736 +diff --git a/include/net/ipv6.h b/include/net/ipv6.h
4737 +index e59f385da38e..f280c61e019a 100644
4738 +--- a/include/net/ipv6.h
4739 ++++ b/include/net/ipv6.h
4740 +@@ -313,14 +313,7 @@ struct ipv6_txoptions *ipv6_dup_options(struct sock *sk,
4741 + struct ipv6_txoptions *ipv6_renew_options(struct sock *sk,
4742 + struct ipv6_txoptions *opt,
4743 + int newtype,
4744 +- struct ipv6_opt_hdr __user *newopt,
4745 +- int newoptlen);
4746 +-struct ipv6_txoptions *
4747 +-ipv6_renew_options_kern(struct sock *sk,
4748 +- struct ipv6_txoptions *opt,
4749 +- int newtype,
4750 +- struct ipv6_opt_hdr *newopt,
4751 +- int newoptlen);
4752 ++ struct ipv6_opt_hdr *newopt);
4753 + struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
4754 + struct ipv6_txoptions *opt);
4755 +
4756 +diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
4757 +index 049008493faf..f4bf75fac349 100644
4758 +--- a/include/net/net_namespace.h
4759 ++++ b/include/net/net_namespace.h
4760 +@@ -120,6 +120,7 @@ struct net {
4761 + #endif
4762 + #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
4763 + struct netns_nf_frag nf_frag;
4764 ++ struct ctl_table_header *nf_frag_frags_hdr;
4765 + #endif
4766 + struct sock *nfnl;
4767 + struct sock *nfnl_stash;
4768 +diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
4769 +index dc825a5ddd7f..c004d051c2d3 100644
4770 +--- a/include/net/netns/ipv6.h
4771 ++++ b/include/net/netns/ipv6.h
4772 +@@ -94,7 +94,6 @@ struct netns_ipv6 {
4773 +
4774 + #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
4775 + struct netns_nf_frag {
4776 +- struct netns_sysctl_ipv6 sysctl;
4777 + struct netns_frags frags;
4778 + };
4779 + #endif
4780 +diff --git a/include/net/tc_act/tc_tunnel_key.h b/include/net/tc_act/tc_tunnel_key.h
4781 +index efef0b4b1b2b..46b8c7f1c8d5 100644
4782 +--- a/include/net/tc_act/tc_tunnel_key.h
4783 ++++ b/include/net/tc_act/tc_tunnel_key.h
4784 +@@ -18,7 +18,6 @@
4785 + struct tcf_tunnel_key_params {
4786 + struct rcu_head rcu;
4787 + int tcft_action;
4788 +- int action;
4789 + struct metadata_dst *tcft_enc_metadata;
4790 + };
4791 +
4792 +diff --git a/include/net/tcp.h b/include/net/tcp.h
4793 +index 686e33ea76e7..eca8d65cad1e 100644
4794 +--- a/include/net/tcp.h
4795 ++++ b/include/net/tcp.h
4796 +@@ -938,8 +938,6 @@ enum tcp_ca_event {
4797 + CA_EVENT_LOSS, /* loss timeout */
4798 + CA_EVENT_ECN_NO_CE, /* ECT set, but not CE marked */
4799 + CA_EVENT_ECN_IS_CE, /* received CE marked IP packet */
4800 +- CA_EVENT_DELAYED_ACK, /* Delayed ack is sent */
4801 +- CA_EVENT_NON_DELAYED_ACK,
4802 + };
4803 +
4804 + /* Information about inbound ACK, passed to cong_ops->in_ack_event() */
4805 +diff --git a/include/uapi/linux/nbd.h b/include/uapi/linux/nbd.h
4806 +index 85a3fb65e40a..20d6cc91435d 100644
4807 +--- a/include/uapi/linux/nbd.h
4808 ++++ b/include/uapi/linux/nbd.h
4809 +@@ -53,6 +53,9 @@ enum {
4810 + /* These are client behavior specific flags. */
4811 + #define NBD_CFLAG_DESTROY_ON_DISCONNECT (1 << 0) /* delete the nbd device on
4812 + disconnect. */
4813 ++#define NBD_CFLAG_DISCONNECT_ON_CLOSE (1 << 1) /* disconnect the nbd device on
4814 ++ * close by last opener.
4815 ++ */
4816 +
4817 + /* userspace doesn't need the nbd_device structure */
4818 +
4819 +diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
4820 +index 6533f08d1238..3d0ecc273cc6 100644
4821 +--- a/kernel/bpf/hashtab.c
4822 ++++ b/kernel/bpf/hashtab.c
4823 +@@ -730,13 +730,15 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
4824 + * old element will be freed immediately.
4825 + * Otherwise return an error
4826 + */
4827 +- atomic_dec(&htab->count);
4828 +- return ERR_PTR(-E2BIG);
4829 ++ l_new = ERR_PTR(-E2BIG);
4830 ++ goto dec_count;
4831 + }
4832 + l_new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN,
4833 + htab->map.numa_node);
4834 +- if (!l_new)
4835 +- return ERR_PTR(-ENOMEM);
4836 ++ if (!l_new) {
4837 ++ l_new = ERR_PTR(-ENOMEM);
4838 ++ goto dec_count;
4839 ++ }
4840 + }
4841 +
4842 + memcpy(l_new->key, key, key_size);
4843 +@@ -749,7 +751,8 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
4844 + GFP_ATOMIC | __GFP_NOWARN);
4845 + if (!pptr) {
4846 + kfree(l_new);
4847 +- return ERR_PTR(-ENOMEM);
4848 ++ l_new = ERR_PTR(-ENOMEM);
4849 ++ goto dec_count;
4850 + }
4851 + }
4852 +
4853 +@@ -763,6 +766,9 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
4854 +
4855 + l_new->hash = hash;
4856 + return l_new;
4857 ++dec_count:
4858 ++ atomic_dec(&htab->count);
4859 ++ return l_new;
4860 + }
4861 +
4862 + static int check_flags(struct bpf_htab *htab, struct htab_elem *l_old,
4863 +diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
4864 +index 2f0f5720b123..d7c155048ea9 100644
4865 +--- a/kernel/locking/lockdep.c
4866 ++++ b/kernel/locking/lockdep.c
4867 +@@ -1296,11 +1296,11 @@ unsigned long lockdep_count_forward_deps(struct lock_class *class)
4868 + this.parent = NULL;
4869 + this.class = class;
4870 +
4871 +- local_irq_save(flags);
4872 ++ raw_local_irq_save(flags);
4873 + arch_spin_lock(&lockdep_lock);
4874 + ret = __lockdep_count_forward_deps(&this);
4875 + arch_spin_unlock(&lockdep_lock);
4876 +- local_irq_restore(flags);
4877 ++ raw_local_irq_restore(flags);
4878 +
4879 + return ret;
4880 + }
4881 +@@ -1323,11 +1323,11 @@ unsigned long lockdep_count_backward_deps(struct lock_class *class)
4882 + this.parent = NULL;
4883 + this.class = class;
4884 +
4885 +- local_irq_save(flags);
4886 ++ raw_local_irq_save(flags);
4887 + arch_spin_lock(&lockdep_lock);
4888 + ret = __lockdep_count_backward_deps(&this);
4889 + arch_spin_unlock(&lockdep_lock);
4890 +- local_irq_restore(flags);
4891 ++ raw_local_irq_restore(flags);
4892 +
4893 + return ret;
4894 + }
4895 +@@ -4478,7 +4478,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
4896 + if (unlikely(!debug_locks))
4897 + return;
4898 +
4899 +- local_irq_save(flags);
4900 ++ raw_local_irq_save(flags);
4901 + for (i = 0; i < curr->lockdep_depth; i++) {
4902 + hlock = curr->held_locks + i;
4903 +
4904 +@@ -4489,7 +4489,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
4905 + print_freed_lock_bug(curr, mem_from, mem_from + mem_len, hlock);
4906 + break;
4907 + }
4908 +- local_irq_restore(flags);
4909 ++ raw_local_irq_restore(flags);
4910 + }
4911 + EXPORT_SYMBOL_GPL(debug_check_no_locks_freed);
4912 +
4913 +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
4914 +index 20919489883f..fbc75c84076e 100644
4915 +--- a/kernel/trace/trace.c
4916 ++++ b/kernel/trace/trace.c
4917 +@@ -2958,6 +2958,7 @@ out_nobuffer:
4918 + }
4919 + EXPORT_SYMBOL_GPL(trace_vbprintk);
4920 +
4921 ++__printf(3, 0)
4922 + static int
4923 + __trace_array_vprintk(struct ring_buffer *buffer,
4924 + unsigned long ip, const char *fmt, va_list args)
4925 +@@ -3012,12 +3013,14 @@ out_nobuffer:
4926 + return len;
4927 + }
4928 +
4929 ++__printf(3, 0)
4930 + int trace_array_vprintk(struct trace_array *tr,
4931 + unsigned long ip, const char *fmt, va_list args)
4932 + {
4933 + return __trace_array_vprintk(tr->trace_buffer.buffer, ip, fmt, args);
4934 + }
4935 +
4936 ++__printf(3, 0)
4937 + int trace_array_printk(struct trace_array *tr,
4938 + unsigned long ip, const char *fmt, ...)
4939 + {
4940 +@@ -3033,6 +3036,7 @@ int trace_array_printk(struct trace_array *tr,
4941 + return ret;
4942 + }
4943 +
4944 ++__printf(3, 4)
4945 + int trace_array_printk_buf(struct ring_buffer *buffer,
4946 + unsigned long ip, const char *fmt, ...)
4947 + {
4948 +@@ -3048,6 +3052,7 @@ int trace_array_printk_buf(struct ring_buffer *buffer,
4949 + return ret;
4950 + }
4951 +
4952 ++__printf(2, 0)
4953 + int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
4954 + {
4955 + return trace_array_vprintk(&global_trace, ip, fmt, args);
4956 +diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
4957 +index d90f29a166d8..71a4319256b6 100644
4958 +--- a/mm/kasan/kasan.c
4959 ++++ b/mm/kasan/kasan.c
4960 +@@ -613,12 +613,13 @@ void kasan_kfree_large(const void *ptr)
4961 + int kasan_module_alloc(void *addr, size_t size)
4962 + {
4963 + void *ret;
4964 ++ size_t scaled_size;
4965 + size_t shadow_size;
4966 + unsigned long shadow_start;
4967 +
4968 + shadow_start = (unsigned long)kasan_mem_to_shadow(addr);
4969 +- shadow_size = round_up(size >> KASAN_SHADOW_SCALE_SHIFT,
4970 +- PAGE_SIZE);
4971 ++ scaled_size = (size + KASAN_SHADOW_MASK) >> KASAN_SHADOW_SCALE_SHIFT;
4972 ++ shadow_size = round_up(scaled_size, PAGE_SIZE);
4973 +
4974 + if (WARN_ON(!PAGE_ALIGNED(shadow_start)))
4975 + return -EINVAL;
4976 +diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
4977 +index 71d8809fbe94..5bd9b389f8c9 100644
4978 +--- a/net/batman-adv/bat_iv_ogm.c
4979 ++++ b/net/batman-adv/bat_iv_ogm.c
4980 +@@ -2718,7 +2718,7 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
4981 + {
4982 + struct batadv_neigh_ifinfo *router_ifinfo = NULL;
4983 + struct batadv_neigh_node *router;
4984 +- struct batadv_gw_node *curr_gw;
4985 ++ struct batadv_gw_node *curr_gw = NULL;
4986 + int ret = 0;
4987 + void *hdr;
4988 +
4989 +@@ -2766,6 +2766,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
4990 + ret = 0;
4991 +
4992 + out:
4993 ++ if (curr_gw)
4994 ++ batadv_gw_node_put(curr_gw);
4995 + if (router_ifinfo)
4996 + batadv_neigh_ifinfo_put(router_ifinfo);
4997 + if (router)
4998 +diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
4999 +index a8f4c3902cf5..371a1f1651b4 100644
5000 +--- a/net/batman-adv/bat_v.c
5001 ++++ b/net/batman-adv/bat_v.c
5002 +@@ -929,7 +929,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
5003 + {
5004 + struct batadv_neigh_ifinfo *router_ifinfo = NULL;
5005 + struct batadv_neigh_node *router;
5006 +- struct batadv_gw_node *curr_gw;
5007 ++ struct batadv_gw_node *curr_gw = NULL;
5008 + int ret = 0;
5009 + void *hdr;
5010 +
5011 +@@ -997,6 +997,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
5012 + ret = 0;
5013 +
5014 + out:
5015 ++ if (curr_gw)
5016 ++ batadv_gw_node_put(curr_gw);
5017 + if (router_ifinfo)
5018 + batadv_neigh_ifinfo_put(router_ifinfo);
5019 + if (router)
5020 +diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
5021 +index 8a3ce79b1307..0f4d4eece3e4 100644
5022 +--- a/net/batman-adv/translation-table.c
5023 ++++ b/net/batman-adv/translation-table.c
5024 +@@ -1679,7 +1679,9 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
5025 + ether_addr_copy(common->addr, tt_addr);
5026 + common->vid = vid;
5027 +
5028 +- common->flags = flags;
5029 ++ if (!is_multicast_ether_addr(common->addr))
5030 ++ common->flags = flags & (~BATADV_TT_SYNC_MASK);
5031 ++
5032 + tt_global_entry->roam_at = 0;
5033 + /* node must store current time in case of roaming. This is
5034 + * needed to purge this entry out on timeout (if nobody claims
5035 +@@ -1742,7 +1744,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
5036 + * TT_CLIENT_TEMP, therefore they have to be copied in the
5037 + * client entry
5038 + */
5039 +- common->flags |= flags & (~BATADV_TT_SYNC_MASK);
5040 ++ if (!is_multicast_ether_addr(common->addr))
5041 ++ common->flags |= flags & (~BATADV_TT_SYNC_MASK);
5042 +
5043 + /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
5044 + * one originator left in the list and we previously received a
5045 +diff --git a/net/core/dev.c b/net/core/dev.c
5046 +index 6ca771f2f25b..85f4a1047707 100644
5047 +--- a/net/core/dev.c
5048 ++++ b/net/core/dev.c
5049 +@@ -8297,7 +8297,8 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
5050 + /* We get here if we can't use the current device name */
5051 + if (!pat)
5052 + goto out;
5053 +- if (dev_get_valid_name(net, dev, pat) < 0)
5054 ++ err = dev_get_valid_name(net, dev, pat);
5055 ++ if (err < 0)
5056 + goto out;
5057 + }
5058 +
5059 +@@ -8309,7 +8310,6 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
5060 + dev_close(dev);
5061 +
5062 + /* And unlink it from device chain */
5063 +- err = -ENODEV;
5064 + unlist_netdevice(dev);
5065 +
5066 + synchronize_net();
5067 +diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
5068 +index e9f0489e4229..22db273f15ea 100644
5069 +--- a/net/ieee802154/6lowpan/core.c
5070 ++++ b/net/ieee802154/6lowpan/core.c
5071 +@@ -90,12 +90,18 @@ static int lowpan_neigh_construct(struct net_device *dev, struct neighbour *n)
5072 + return 0;
5073 + }
5074 +
5075 ++static int lowpan_get_iflink(const struct net_device *dev)
5076 ++{
5077 ++ return lowpan_802154_dev(dev)->wdev->ifindex;
5078 ++}
5079 ++
5080 + static const struct net_device_ops lowpan_netdev_ops = {
5081 + .ndo_init = lowpan_dev_init,
5082 + .ndo_start_xmit = lowpan_xmit,
5083 + .ndo_open = lowpan_open,
5084 + .ndo_stop = lowpan_stop,
5085 + .ndo_neigh_construct = lowpan_neigh_construct,
5086 ++ .ndo_get_iflink = lowpan_get_iflink,
5087 + };
5088 +
5089 + static void lowpan_setup(struct net_device *ldev)
5090 +diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
5091 +index 114d4bef1bec..0d1a2cda1bfb 100644
5092 +--- a/net/ipv4/netfilter/ip_tables.c
5093 ++++ b/net/ipv4/netfilter/ip_tables.c
5094 +@@ -1894,6 +1894,7 @@ static struct xt_match ipt_builtin_mt[] __read_mostly = {
5095 + .checkentry = icmp_checkentry,
5096 + .proto = IPPROTO_ICMP,
5097 + .family = NFPROTO_IPV4,
5098 ++ .me = THIS_MODULE,
5099 + },
5100 + };
5101 +
5102 +diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
5103 +index e81ff9d545a4..7462ec7587ce 100644
5104 +--- a/net/ipv4/tcp.c
5105 ++++ b/net/ipv4/tcp.c
5106 +@@ -1837,7 +1837,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
5107 + * shouldn't happen.
5108 + */
5109 + if (WARN(before(*seq, TCP_SKB_CB(skb)->seq),
5110 +- "recvmsg bug: copied %X seq %X rcvnxt %X fl %X\n",
5111 ++ "TCP recvmsg seq # bug: copied %X, seq %X, rcvnxt %X, fl %X\n",
5112 + *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt,
5113 + flags))
5114 + break;
5115 +@@ -1852,7 +1852,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
5116 + if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
5117 + goto found_fin_ok;
5118 + WARN(!(flags & MSG_PEEK),
5119 +- "recvmsg bug 2: copied %X seq %X rcvnxt %X fl %X\n",
5120 ++ "TCP recvmsg seq # bug 2: copied %X, seq %X, rcvnxt %X, fl %X\n",
5121 + *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt, flags);
5122 + }
5123 +
5124 +diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
5125 +index 1a9b88c8cf72..8b637f9f23a2 100644
5126 +--- a/net/ipv4/tcp_dctcp.c
5127 ++++ b/net/ipv4/tcp_dctcp.c
5128 +@@ -55,7 +55,6 @@ struct dctcp {
5129 + u32 dctcp_alpha;
5130 + u32 next_seq;
5131 + u32 ce_state;
5132 +- u32 delayed_ack_reserved;
5133 + u32 loss_cwnd;
5134 + };
5135 +
5136 +@@ -96,7 +95,6 @@ static void dctcp_init(struct sock *sk)
5137 +
5138 + ca->dctcp_alpha = min(dctcp_alpha_on_init, DCTCP_MAX_ALPHA);
5139 +
5140 +- ca->delayed_ack_reserved = 0;
5141 + ca->loss_cwnd = 0;
5142 + ca->ce_state = 0;
5143 +
5144 +@@ -230,25 +228,6 @@ static void dctcp_state(struct sock *sk, u8 new_state)
5145 + }
5146 + }
5147 +
5148 +-static void dctcp_update_ack_reserved(struct sock *sk, enum tcp_ca_event ev)
5149 +-{
5150 +- struct dctcp *ca = inet_csk_ca(sk);
5151 +-
5152 +- switch (ev) {
5153 +- case CA_EVENT_DELAYED_ACK:
5154 +- if (!ca->delayed_ack_reserved)
5155 +- ca->delayed_ack_reserved = 1;
5156 +- break;
5157 +- case CA_EVENT_NON_DELAYED_ACK:
5158 +- if (ca->delayed_ack_reserved)
5159 +- ca->delayed_ack_reserved = 0;
5160 +- break;
5161 +- default:
5162 +- /* Don't care for the rest. */
5163 +- break;
5164 +- }
5165 +-}
5166 +-
5167 + static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
5168 + {
5169 + switch (ev) {
5170 +@@ -258,10 +237,6 @@ static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
5171 + case CA_EVENT_ECN_NO_CE:
5172 + dctcp_ce_state_1_to_0(sk);
5173 + break;
5174 +- case CA_EVENT_DELAYED_ACK:
5175 +- case CA_EVENT_NON_DELAYED_ACK:
5176 +- dctcp_update_ack_reserved(sk, ev);
5177 +- break;
5178 + default:
5179 + /* Don't care for the rest. */
5180 + break;
5181 +diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
5182 +index 3d8f6f342cb1..b2ead31afcba 100644
5183 +--- a/net/ipv4/tcp_output.c
5184 ++++ b/net/ipv4/tcp_output.c
5185 +@@ -3513,8 +3513,6 @@ void tcp_send_delayed_ack(struct sock *sk)
5186 + int ato = icsk->icsk_ack.ato;
5187 + unsigned long timeout;
5188 +
5189 +- tcp_ca_event(sk, CA_EVENT_DELAYED_ACK);
5190 +-
5191 + if (ato > TCP_DELACK_MIN) {
5192 + const struct tcp_sock *tp = tcp_sk(sk);
5193 + int max_ato = HZ / 2;
5194 +@@ -3571,8 +3569,6 @@ void __tcp_send_ack(struct sock *sk, u32 rcv_nxt)
5195 + if (sk->sk_state == TCP_CLOSE)
5196 + return;
5197 +
5198 +- tcp_ca_event(sk, CA_EVENT_NON_DELAYED_ACK);
5199 +-
5200 + /* We are not putting this on the write queue, so
5201 + * tcp_transmit_skb() will set the ownership to this
5202 + * sock.
5203 +diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
5204 +index 1323b9679cf7..1c0bb9fb76e6 100644
5205 +--- a/net/ipv6/calipso.c
5206 ++++ b/net/ipv6/calipso.c
5207 +@@ -799,8 +799,7 @@ static int calipso_opt_update(struct sock *sk, struct ipv6_opt_hdr *hop)
5208 + {
5209 + struct ipv6_txoptions *old = txopt_get(inet6_sk(sk)), *txopts;
5210 +
5211 +- txopts = ipv6_renew_options_kern(sk, old, IPV6_HOPOPTS,
5212 +- hop, hop ? ipv6_optlen(hop) : 0);
5213 ++ txopts = ipv6_renew_options(sk, old, IPV6_HOPOPTS, hop);
5214 + txopt_put(old);
5215 + if (IS_ERR(txopts))
5216 + return PTR_ERR(txopts);
5217 +@@ -1222,8 +1221,7 @@ static int calipso_req_setattr(struct request_sock *req,
5218 + if (IS_ERR(new))
5219 + return PTR_ERR(new);
5220 +
5221 +- txopts = ipv6_renew_options_kern(sk, req_inet->ipv6_opt, IPV6_HOPOPTS,
5222 +- new, new ? ipv6_optlen(new) : 0);
5223 ++ txopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);
5224 +
5225 + kfree(new);
5226 +
5227 +@@ -1260,8 +1258,7 @@ static void calipso_req_delattr(struct request_sock *req)
5228 + if (calipso_opt_del(req_inet->ipv6_opt->hopopt, &new))
5229 + return; /* Nothing to do */
5230 +
5231 +- txopts = ipv6_renew_options_kern(sk, req_inet->ipv6_opt, IPV6_HOPOPTS,
5232 +- new, new ? ipv6_optlen(new) : 0);
5233 ++ txopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);
5234 +
5235 + if (!IS_ERR(txopts)) {
5236 + txopts = xchg(&req_inet->ipv6_opt, txopts);
5237 +diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
5238 +index d6189c2a35e4..47a5f8f88c70 100644
5239 +--- a/net/ipv6/exthdrs.c
5240 ++++ b/net/ipv6/exthdrs.c
5241 +@@ -987,29 +987,21 @@ ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt)
5242 + }
5243 + EXPORT_SYMBOL_GPL(ipv6_dup_options);
5244 +
5245 +-static int ipv6_renew_option(void *ohdr,
5246 +- struct ipv6_opt_hdr __user *newopt, int newoptlen,
5247 +- int inherit,
5248 +- struct ipv6_opt_hdr **hdr,
5249 +- char **p)
5250 ++static void ipv6_renew_option(int renewtype,
5251 ++ struct ipv6_opt_hdr **dest,
5252 ++ struct ipv6_opt_hdr *old,
5253 ++ struct ipv6_opt_hdr *new,
5254 ++ int newtype, char **p)
5255 + {
5256 +- if (inherit) {
5257 +- if (ohdr) {
5258 +- memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr));
5259 +- *hdr = (struct ipv6_opt_hdr *)*p;
5260 +- *p += CMSG_ALIGN(ipv6_optlen(*hdr));
5261 +- }
5262 +- } else {
5263 +- if (newopt) {
5264 +- if (copy_from_user(*p, newopt, newoptlen))
5265 +- return -EFAULT;
5266 +- *hdr = (struct ipv6_opt_hdr *)*p;
5267 +- if (ipv6_optlen(*hdr) > newoptlen)
5268 +- return -EINVAL;
5269 +- *p += CMSG_ALIGN(newoptlen);
5270 +- }
5271 +- }
5272 +- return 0;
5273 ++ struct ipv6_opt_hdr *src;
5274 ++
5275 ++ src = (renewtype == newtype ? new : old);
5276 ++ if (!src)
5277 ++ return;
5278 ++
5279 ++ memcpy(*p, src, ipv6_optlen(src));
5280 ++ *dest = (struct ipv6_opt_hdr *)*p;
5281 ++ *p += CMSG_ALIGN(ipv6_optlen(*dest));
5282 + }
5283 +
5284 + /**
5285 +@@ -1035,13 +1027,11 @@ static int ipv6_renew_option(void *ohdr,
5286 + */
5287 + struct ipv6_txoptions *
5288 + ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
5289 +- int newtype,
5290 +- struct ipv6_opt_hdr __user *newopt, int newoptlen)
5291 ++ int newtype, struct ipv6_opt_hdr *newopt)
5292 + {
5293 + int tot_len = 0;
5294 + char *p;
5295 + struct ipv6_txoptions *opt2;
5296 +- int err;
5297 +
5298 + if (opt) {
5299 + if (newtype != IPV6_HOPOPTS && opt->hopopt)
5300 +@@ -1054,8 +1044,8 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
5301 + tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt));
5302 + }
5303 +
5304 +- if (newopt && newoptlen)
5305 +- tot_len += CMSG_ALIGN(newoptlen);
5306 ++ if (newopt)
5307 ++ tot_len += CMSG_ALIGN(ipv6_optlen(newopt));
5308 +
5309 + if (!tot_len)
5310 + return NULL;
5311 +@@ -1070,29 +1060,19 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
5312 + opt2->tot_len = tot_len;
5313 + p = (char *)(opt2 + 1);
5314 +
5315 +- err = ipv6_renew_option(opt ? opt->hopopt : NULL, newopt, newoptlen,
5316 +- newtype != IPV6_HOPOPTS,
5317 +- &opt2->hopopt, &p);
5318 +- if (err)
5319 +- goto out;
5320 +-
5321 +- err = ipv6_renew_option(opt ? opt->dst0opt : NULL, newopt, newoptlen,
5322 +- newtype != IPV6_RTHDRDSTOPTS,
5323 +- &opt2->dst0opt, &p);
5324 +- if (err)
5325 +- goto out;
5326 +-
5327 +- err = ipv6_renew_option(opt ? opt->srcrt : NULL, newopt, newoptlen,
5328 +- newtype != IPV6_RTHDR,
5329 +- (struct ipv6_opt_hdr **)&opt2->srcrt, &p);
5330 +- if (err)
5331 +- goto out;
5332 +-
5333 +- err = ipv6_renew_option(opt ? opt->dst1opt : NULL, newopt, newoptlen,
5334 +- newtype != IPV6_DSTOPTS,
5335 +- &opt2->dst1opt, &p);
5336 +- if (err)
5337 +- goto out;
5338 ++ ipv6_renew_option(IPV6_HOPOPTS, &opt2->hopopt,
5339 ++ (opt ? opt->hopopt : NULL),
5340 ++ newopt, newtype, &p);
5341 ++ ipv6_renew_option(IPV6_RTHDRDSTOPTS, &opt2->dst0opt,
5342 ++ (opt ? opt->dst0opt : NULL),
5343 ++ newopt, newtype, &p);
5344 ++ ipv6_renew_option(IPV6_RTHDR,
5345 ++ (struct ipv6_opt_hdr **)&opt2->srcrt,
5346 ++ (opt ? (struct ipv6_opt_hdr *)opt->srcrt : NULL),
5347 ++ newopt, newtype, &p);
5348 ++ ipv6_renew_option(IPV6_DSTOPTS, &opt2->dst1opt,
5349 ++ (opt ? opt->dst1opt : NULL),
5350 ++ newopt, newtype, &p);
5351 +
5352 + opt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) +
5353 + (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) +
5354 +@@ -1100,37 +1080,6 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
5355 + opt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0);
5356 +
5357 + return opt2;
5358 +-out:
5359 +- sock_kfree_s(sk, opt2, opt2->tot_len);
5360 +- return ERR_PTR(err);
5361 +-}
5362 +-
5363 +-/**
5364 +- * ipv6_renew_options_kern - replace a specific ext hdr with a new one.
5365 +- *
5366 +- * @sk: sock from which to allocate memory
5367 +- * @opt: original options
5368 +- * @newtype: option type to replace in @opt
5369 +- * @newopt: new option of type @newtype to replace (kernel-mem)
5370 +- * @newoptlen: length of @newopt
5371 +- *
5372 +- * See ipv6_renew_options(). The difference is that @newopt is
5373 +- * kernel memory, rather than user memory.
5374 +- */
5375 +-struct ipv6_txoptions *
5376 +-ipv6_renew_options_kern(struct sock *sk, struct ipv6_txoptions *opt,
5377 +- int newtype, struct ipv6_opt_hdr *newopt,
5378 +- int newoptlen)
5379 +-{
5380 +- struct ipv6_txoptions *ret_val;
5381 +- const mm_segment_t old_fs = get_fs();
5382 +-
5383 +- set_fs(KERNEL_DS);
5384 +- ret_val = ipv6_renew_options(sk, opt, newtype,
5385 +- (struct ipv6_opt_hdr __user *)newopt,
5386 +- newoptlen);
5387 +- set_fs(old_fs);
5388 +- return ret_val;
5389 + }
5390 +
5391 + struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
5392 +diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
5393 +index 1276d5bd5675..5c91b05c8d8f 100644
5394 +--- a/net/ipv6/ipv6_sockglue.c
5395 ++++ b/net/ipv6/ipv6_sockglue.c
5396 +@@ -390,6 +390,12 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
5397 + case IPV6_DSTOPTS:
5398 + {
5399 + struct ipv6_txoptions *opt;
5400 ++ struct ipv6_opt_hdr *new = NULL;
5401 ++
5402 ++ /* hop-by-hop / destination options are privileged option */
5403 ++ retv = -EPERM;
5404 ++ if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW))
5405 ++ break;
5406 +
5407 + /* remove any sticky options header with a zero option
5408 + * length, per RFC3542.
5409 +@@ -401,17 +407,22 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
5410 + else if (optlen < sizeof(struct ipv6_opt_hdr) ||
5411 + optlen & 0x7 || optlen > 8 * 255)
5412 + goto e_inval;
5413 +-
5414 +- /* hop-by-hop / destination options are privileged option */
5415 +- retv = -EPERM;
5416 +- if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW))
5417 +- break;
5418 ++ else {
5419 ++ new = memdup_user(optval, optlen);
5420 ++ if (IS_ERR(new)) {
5421 ++ retv = PTR_ERR(new);
5422 ++ break;
5423 ++ }
5424 ++ if (unlikely(ipv6_optlen(new) > optlen)) {
5425 ++ kfree(new);
5426 ++ goto e_inval;
5427 ++ }
5428 ++ }
5429 +
5430 + opt = rcu_dereference_protected(np->opt,
5431 + lockdep_sock_is_held(sk));
5432 +- opt = ipv6_renew_options(sk, opt, optname,
5433 +- (struct ipv6_opt_hdr __user *)optval,
5434 +- optlen);
5435 ++ opt = ipv6_renew_options(sk, opt, optname, new);
5436 ++ kfree(new);
5437 + if (IS_ERR(opt)) {
5438 + retv = PTR_ERR(opt);
5439 + break;
5440 +diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
5441 +index 6fd913d63835..d112762b4cb8 100644
5442 +--- a/net/ipv6/mcast.c
5443 ++++ b/net/ipv6/mcast.c
5444 +@@ -2083,7 +2083,8 @@ void ipv6_mc_dad_complete(struct inet6_dev *idev)
5445 + mld_send_initial_cr(idev);
5446 + idev->mc_dad_count--;
5447 + if (idev->mc_dad_count)
5448 +- mld_dad_start_timer(idev, idev->mc_maxdelay);
5449 ++ mld_dad_start_timer(idev,
5450 ++ unsolicited_report_interval(idev));
5451 + }
5452 + }
5453 +
5454 +@@ -2095,7 +2096,8 @@ static void mld_dad_timer_expire(unsigned long data)
5455 + if (idev->mc_dad_count) {
5456 + idev->mc_dad_count--;
5457 + if (idev->mc_dad_count)
5458 +- mld_dad_start_timer(idev, idev->mc_maxdelay);
5459 ++ mld_dad_start_timer(idev,
5460 ++ unsolicited_report_interval(idev));
5461 + }
5462 + in6_dev_put(idev);
5463 + }
5464 +@@ -2453,7 +2455,8 @@ static void mld_ifc_timer_expire(unsigned long data)
5465 + if (idev->mc_ifc_count) {
5466 + idev->mc_ifc_count--;
5467 + if (idev->mc_ifc_count)
5468 +- mld_ifc_start_timer(idev, idev->mc_maxdelay);
5469 ++ mld_ifc_start_timer(idev,
5470 ++ unsolicited_report_interval(idev));
5471 + }
5472 + in6_dev_put(idev);
5473 + }
5474 +diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
5475 +index 2e51e0156903..90f5bf2502a7 100644
5476 +--- a/net/ipv6/netfilter/ip6_tables.c
5477 ++++ b/net/ipv6/netfilter/ip6_tables.c
5478 +@@ -1907,6 +1907,7 @@ static struct xt_match ip6t_builtin_mt[] __read_mostly = {
5479 + .checkentry = icmp6_checkentry,
5480 + .proto = IPPROTO_ICMPV6,
5481 + .family = NFPROTO_IPV6,
5482 ++ .me = THIS_MODULE,
5483 + },
5484 + };
5485 +
5486 +diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
5487 +index 722a9db8c6a7..ee33a6743f3b 100644
5488 +--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
5489 ++++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
5490 +@@ -117,7 +117,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
5491 + if (hdr == NULL)
5492 + goto err_reg;
5493 +
5494 +- net->nf_frag.sysctl.frags_hdr = hdr;
5495 ++ net->nf_frag_frags_hdr = hdr;
5496 + return 0;
5497 +
5498 + err_reg:
5499 +@@ -131,8 +131,8 @@ static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)
5500 + {
5501 + struct ctl_table *table;
5502 +
5503 +- table = net->nf_frag.sysctl.frags_hdr->ctl_table_arg;
5504 +- unregister_net_sysctl_table(net->nf_frag.sysctl.frags_hdr);
5505 ++ table = net->nf_frag_frags_hdr->ctl_table_arg;
5506 ++ unregister_net_sysctl_table(net->nf_frag_frags_hdr);
5507 + if (!net_eq(net, &init_net))
5508 + kfree(table);
5509 + }
5510 +diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
5511 +index 01130392b7c0..a268acc48af0 100644
5512 +--- a/net/netfilter/nf_conntrack_core.c
5513 ++++ b/net/netfilter/nf_conntrack_core.c
5514 +@@ -1949,7 +1949,7 @@ int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp)
5515 + return -EOPNOTSUPP;
5516 +
5517 + /* On boot, we can set this without any fancy locking. */
5518 +- if (!nf_conntrack_htable_size)
5519 ++ if (!nf_conntrack_hash)
5520 + return param_set_uint(val, kp);
5521 +
5522 + rc = kstrtouint(val, 0, &hashsize);
5523 +diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
5524 +index 551a1eddf0fa..a75b11c39312 100644
5525 +--- a/net/netfilter/nf_conntrack_helper.c
5526 ++++ b/net/netfilter/nf_conntrack_helper.c
5527 +@@ -465,6 +465,11 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)
5528 +
5529 + nf_ct_expect_iterate_destroy(expect_iter_me, NULL);
5530 + nf_ct_iterate_destroy(unhelp, me);
5531 ++
5532 ++ /* Maybe someone has gotten the helper already when unhelp above.
5533 ++ * So need to wait it.
5534 ++ */
5535 ++ synchronize_rcu();
5536 + }
5537 + EXPORT_SYMBOL_GPL(nf_conntrack_helper_unregister);
5538 +
5539 +diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
5540 +index 0f5a4d79f6b8..812de5496b37 100644
5541 +--- a/net/netfilter/nf_conntrack_proto_dccp.c
5542 ++++ b/net/netfilter/nf_conntrack_proto_dccp.c
5543 +@@ -243,14 +243,14 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][DCCP_PKT_SYNCACK + 1][CT_DCCP_MAX + 1] =
5544 + * We currently ignore Sync packets
5545 + *
5546 + * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
5547 +- sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5548 ++ sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5549 + },
5550 + [DCCP_PKT_SYNCACK] = {
5551 + /*
5552 + * We currently ignore SyncAck packets
5553 + *
5554 + * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
5555 +- sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5556 ++ sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5557 + },
5558 + },
5559 + [CT_DCCP_ROLE_SERVER] = {
5560 +@@ -371,14 +371,14 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][DCCP_PKT_SYNCACK + 1][CT_DCCP_MAX + 1] =
5561 + * We currently ignore Sync packets
5562 + *
5563 + * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
5564 +- sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5565 ++ sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5566 + },
5567 + [DCCP_PKT_SYNCACK] = {
5568 + /*
5569 + * We currently ignore SyncAck packets
5570 + *
5571 + * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
5572 +- sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5573 ++ sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5574 + },
5575 + },
5576 + };
5577 +diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
5578 +index 276324abfa60..cdc744aa5889 100644
5579 +--- a/net/netfilter/nf_log.c
5580 ++++ b/net/netfilter/nf_log.c
5581 +@@ -440,6 +440,10 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
5582 + if (write) {
5583 + struct ctl_table tmp = *table;
5584 +
5585 ++ /* proc_dostring() can append to existing strings, so we need to
5586 ++ * initialize it as an empty string.
5587 ++ */
5588 ++ buf[0] = '\0';
5589 + tmp.data = buf;
5590 + r = proc_dostring(&tmp, write, buffer, lenp, ppos);
5591 + if (r)
5592 +diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
5593 +index 3bd637eadc42..6da1cec1494a 100644
5594 +--- a/net/netfilter/nft_compat.c
5595 ++++ b/net/netfilter/nft_compat.c
5596 +@@ -825,10 +825,18 @@ nft_target_select_ops(const struct nft_ctx *ctx,
5597 + rev = ntohl(nla_get_be32(tb[NFTA_TARGET_REV]));
5598 + family = ctx->afi->family;
5599 +
5600 ++ if (strcmp(tg_name, XT_ERROR_TARGET) == 0 ||
5601 ++ strcmp(tg_name, XT_STANDARD_TARGET) == 0 ||
5602 ++ strcmp(tg_name, "standard") == 0)
5603 ++ return ERR_PTR(-EINVAL);
5604 ++
5605 + /* Re-use the existing target if it's already loaded. */
5606 + list_for_each_entry(nft_target, &nft_target_list, head) {
5607 + struct xt_target *target = nft_target->ops.data;
5608 +
5609 ++ if (!target->target)
5610 ++ continue;
5611 ++
5612 + if (nft_target_cmp(target, tg_name, rev, family))
5613 + return &nft_target->ops;
5614 + }
5615 +@@ -837,6 +845,11 @@ nft_target_select_ops(const struct nft_ctx *ctx,
5616 + if (IS_ERR(target))
5617 + return ERR_PTR(-ENOENT);
5618 +
5619 ++ if (!target->target) {
5620 ++ err = -EINVAL;
5621 ++ goto err;
5622 ++ }
5623 ++
5624 + if (target->targetsize > nla_len(tb[NFTA_TARGET_INFO])) {
5625 + err = -EINVAL;
5626 + goto err;
5627 +diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
5628 +index 27dafe36f29c..8833a58ca3ee 100644
5629 +--- a/net/packet/af_packet.c
5630 ++++ b/net/packet/af_packet.c
5631 +@@ -2919,6 +2919,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
5632 + goto out_free;
5633 + } else if (reserve) {
5634 + skb_reserve(skb, -reserve);
5635 ++ if (len < reserve)
5636 ++ skb_reset_network_header(skb);
5637 + }
5638 +
5639 + /* Returns -EFAULT on error */
5640 +@@ -4267,6 +4269,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
5641 + }
5642 +
5643 + if (req->tp_block_nr) {
5644 ++ unsigned int min_frame_size;
5645 ++
5646 + /* Sanity tests and some calculations */
5647 + err = -EBUSY;
5648 + if (unlikely(rb->pg_vec))
5649 +@@ -4289,12 +4293,12 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
5650 + goto out;
5651 + if (unlikely(!PAGE_ALIGNED(req->tp_block_size)))
5652 + goto out;
5653 ++ min_frame_size = po->tp_hdrlen + po->tp_reserve;
5654 + if (po->tp_version >= TPACKET_V3 &&
5655 +- req->tp_block_size <=
5656 +- BLK_PLUS_PRIV((u64)req_u->req3.tp_sizeof_priv) + sizeof(struct tpacket3_hdr))
5657 ++ req->tp_block_size <
5658 ++ BLK_PLUS_PRIV((u64)req_u->req3.tp_sizeof_priv) + min_frame_size)
5659 + goto out;
5660 +- if (unlikely(req->tp_frame_size < po->tp_hdrlen +
5661 +- po->tp_reserve))
5662 ++ if (unlikely(req->tp_frame_size < min_frame_size))
5663 + goto out;
5664 + if (unlikely(req->tp_frame_size & (TPACKET_ALIGNMENT - 1)))
5665 + goto out;
5666 +diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
5667 +index 78418f38464a..084adea6a818 100644
5668 +--- a/net/qrtr/qrtr.c
5669 ++++ b/net/qrtr/qrtr.c
5670 +@@ -710,6 +710,10 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
5671 + node = NULL;
5672 + if (addr->sq_node == QRTR_NODE_BCAST) {
5673 + enqueue_fn = qrtr_bcast_enqueue;
5674 ++ if (addr->sq_port != QRTR_PORT_CTRL) {
5675 ++ release_sock(sk);
5676 ++ return -ENOTCONN;
5677 ++ }
5678 + } else if (addr->sq_node == ipc->us.sq_node) {
5679 + enqueue_fn = qrtr_local_enqueue;
5680 + } else {
5681 +diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
5682 +index 7cb63616805d..cd51f2ed55fa 100644
5683 +--- a/net/sched/act_tunnel_key.c
5684 ++++ b/net/sched/act_tunnel_key.c
5685 +@@ -36,7 +36,7 @@ static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
5686 +
5687 + tcf_lastuse_update(&t->tcf_tm);
5688 + bstats_cpu_update(this_cpu_ptr(t->common.cpu_bstats), skb);
5689 +- action = params->action;
5690 ++ action = READ_ONCE(t->tcf_action);
5691 +
5692 + switch (params->tcft_action) {
5693 + case TCA_TUNNEL_KEY_ACT_RELEASE:
5694 +@@ -182,7 +182,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
5695 +
5696 + params_old = rtnl_dereference(t->params);
5697 +
5698 +- params_new->action = parm->action;
5699 ++ t->tcf_action = parm->action;
5700 + params_new->tcft_action = parm->t_action;
5701 + params_new->tcft_enc_metadata = metadata;
5702 +
5703 +@@ -254,13 +254,13 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
5704 + .index = t->tcf_index,
5705 + .refcnt = t->tcf_refcnt - ref,
5706 + .bindcnt = t->tcf_bindcnt - bind,
5707 ++ .action = t->tcf_action,
5708 + };
5709 + struct tcf_t tm;
5710 +
5711 + params = rtnl_dereference(t->params);
5712 +
5713 + opt.t_action = params->tcft_action;
5714 +- opt.action = params->action;
5715 +
5716 + if (nla_put(skb, TCA_TUNNEL_KEY_PARMS, sizeof(opt), &opt))
5717 + goto nla_put_failure;
5718 +diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
5719 +index 3afac275ee82..acd9380a56fb 100644
5720 +--- a/net/sctp/chunk.c
5721 ++++ b/net/sctp/chunk.c
5722 +@@ -230,7 +230,9 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
5723 + /* Account for a different sized first fragment */
5724 + if (msg_len >= first_len) {
5725 + msg->can_delay = 0;
5726 +- SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_FRAGUSRMSGS);
5727 ++ if (msg_len > first_len)
5728 ++ SCTP_INC_STATS(sock_net(asoc->base.sk),
5729 ++ SCTP_MIB_FRAGUSRMSGS);
5730 + } else {
5731 + /* Which may be the only one... */
5732 + first_len = msg_len;
5733 +diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
5734 +index 654a81238406..43ef7be69428 100644
5735 +--- a/net/smc/af_smc.c
5736 ++++ b/net/smc/af_smc.c
5737 +@@ -1180,8 +1180,7 @@ static int smc_shutdown(struct socket *sock, int how)
5738 + lock_sock(sk);
5739 +
5740 + rc = -ENOTCONN;
5741 +- if ((sk->sk_state != SMC_LISTEN) &&
5742 +- (sk->sk_state != SMC_ACTIVE) &&
5743 ++ if ((sk->sk_state != SMC_ACTIVE) &&
5744 + (sk->sk_state != SMC_PEERCLOSEWAIT1) &&
5745 + (sk->sk_state != SMC_PEERCLOSEWAIT2) &&
5746 + (sk->sk_state != SMC_APPCLOSEWAIT1) &&
5747 +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
5748 +index ea28aa505302..4cd351b74e48 100644
5749 +--- a/net/wireless/nl80211.c
5750 ++++ b/net/wireless/nl80211.c
5751 +@@ -5990,7 +5990,7 @@ do { \
5752 + nl80211_check_s32);
5753 + /*
5754 + * Check HT operation mode based on
5755 +- * IEEE 802.11 2012 8.4.2.59 HT Operation element.
5756 ++ * IEEE 802.11-2016 9.4.2.57 HT Operation element.
5757 + */
5758 + if (tb[NL80211_MESHCONF_HT_OPMODE]) {
5759 + ht_opmode = nla_get_u16(tb[NL80211_MESHCONF_HT_OPMODE]);
5760 +@@ -6000,22 +6000,9 @@ do { \
5761 + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
5762 + return -EINVAL;
5763 +
5764 +- if ((ht_opmode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) &&
5765 +- (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
5766 +- return -EINVAL;
5767 ++ /* NON_HT_STA bit is reserved, but some programs set it */
5768 ++ ht_opmode &= ~IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
5769 +
5770 +- switch (ht_opmode & IEEE80211_HT_OP_MODE_PROTECTION) {
5771 +- case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
5772 +- case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
5773 +- if (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)
5774 +- return -EINVAL;
5775 +- break;
5776 +- case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
5777 +- case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
5778 +- if (!(ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
5779 +- return -EINVAL;
5780 +- break;
5781 +- }
5782 + cfg->ht_opmode = ht_opmode;
5783 + mask |= (1 << (NL80211_MESHCONF_HT_OPMODE - 1));
5784 + }
5785 +@@ -10542,9 +10529,12 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
5786 + rem) {
5787 + u8 *mask_pat;
5788 +
5789 +- nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
5790 +- nl80211_packet_pattern_policy,
5791 +- info->extack);
5792 ++ err = nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
5793 ++ nl80211_packet_pattern_policy,
5794 ++ info->extack);
5795 ++ if (err)
5796 ++ goto error;
5797 ++
5798 + err = -EINVAL;
5799 + if (!pat_tb[NL80211_PKTPAT_MASK] ||
5800 + !pat_tb[NL80211_PKTPAT_PATTERN])
5801 +@@ -10793,8 +10783,11 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
5802 + rem) {
5803 + u8 *mask_pat;
5804 +
5805 +- nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
5806 +- nl80211_packet_pattern_policy, NULL);
5807 ++ err = nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
5808 ++ nl80211_packet_pattern_policy, NULL);
5809 ++ if (err)
5810 ++ return err;
5811 ++
5812 + if (!pat_tb[NL80211_PKTPAT_MASK] ||
5813 + !pat_tb[NL80211_PKTPAT_PATTERN])
5814 + return -EINVAL;
5815 +diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
5816 +index dbfcfefd6d69..dde40f995ac0 100644
5817 +--- a/net/xfrm/xfrm_user.c
5818 ++++ b/net/xfrm/xfrm_user.c
5819 +@@ -1665,9 +1665,11 @@ static inline size_t userpolicy_type_attrsize(void)
5820 + #ifdef CONFIG_XFRM_SUB_POLICY
5821 + static int copy_to_user_policy_type(u8 type, struct sk_buff *skb)
5822 + {
5823 +- struct xfrm_userpolicy_type upt = {
5824 +- .type = type,
5825 +- };
5826 ++ struct xfrm_userpolicy_type upt;
5827 ++
5828 ++ /* Sadly there are two holes in struct xfrm_userpolicy_type */
5829 ++ memset(&upt, 0, sizeof(upt));
5830 ++ upt.type = type;
5831 +
5832 + return nla_put(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt);
5833 + }
5834 +diff --git a/samples/bpf/parse_varlen.c b/samples/bpf/parse_varlen.c
5835 +index 95c16324760c..0b6f22feb2c9 100644
5836 +--- a/samples/bpf/parse_varlen.c
5837 ++++ b/samples/bpf/parse_varlen.c
5838 +@@ -6,6 +6,7 @@
5839 + */
5840 + #define KBUILD_MODNAME "foo"
5841 + #include <linux/if_ether.h>
5842 ++#include <linux/if_vlan.h>
5843 + #include <linux/ip.h>
5844 + #include <linux/ipv6.h>
5845 + #include <linux/in.h>
5846 +@@ -108,11 +109,6 @@ static int parse_ipv6(void *data, uint64_t nh_off, void *data_end)
5847 + return 0;
5848 + }
5849 +
5850 +-struct vlan_hdr {
5851 +- uint16_t h_vlan_TCI;
5852 +- uint16_t h_vlan_encapsulated_proto;
5853 +-};
5854 +-
5855 + SEC("varlen")
5856 + int handle_ingress(struct __sk_buff *skb)
5857 + {
5858 +diff --git a/samples/bpf/test_overhead_user.c b/samples/bpf/test_overhead_user.c
5859 +index d291167fd3c7..7dad9a3168e1 100644
5860 +--- a/samples/bpf/test_overhead_user.c
5861 ++++ b/samples/bpf/test_overhead_user.c
5862 +@@ -6,6 +6,7 @@
5863 + */
5864 + #define _GNU_SOURCE
5865 + #include <sched.h>
5866 ++#include <errno.h>
5867 + #include <stdio.h>
5868 + #include <sys/types.h>
5869 + #include <asm/unistd.h>
5870 +@@ -44,8 +45,13 @@ static void test_task_rename(int cpu)
5871 + exit(1);
5872 + }
5873 + start_time = time_get_ns();
5874 +- for (i = 0; i < MAX_CNT; i++)
5875 +- write(fd, buf, sizeof(buf));
5876 ++ for (i = 0; i < MAX_CNT; i++) {
5877 ++ if (write(fd, buf, sizeof(buf)) < 0) {
5878 ++ printf("task rename failed: %s\n", strerror(errno));
5879 ++ close(fd);
5880 ++ return;
5881 ++ }
5882 ++ }
5883 + printf("task_rename:%d: %lld events per sec\n",
5884 + cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time));
5885 + close(fd);
5886 +@@ -63,8 +69,13 @@ static void test_urandom_read(int cpu)
5887 + exit(1);
5888 + }
5889 + start_time = time_get_ns();
5890 +- for (i = 0; i < MAX_CNT; i++)
5891 +- read(fd, buf, sizeof(buf));
5892 ++ for (i = 0; i < MAX_CNT; i++) {
5893 ++ if (read(fd, buf, sizeof(buf)) < 0) {
5894 ++ printf("failed to read from /dev/urandom: %s\n", strerror(errno));
5895 ++ close(fd);
5896 ++ return;
5897 ++ }
5898 ++ }
5899 + printf("urandom_read:%d: %lld events per sec\n",
5900 + cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time));
5901 + close(fd);
5902 +diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
5903 +index 7bd827b84a67..c7d525e5696e 100644
5904 +--- a/samples/bpf/trace_event_user.c
5905 ++++ b/samples/bpf/trace_event_user.c
5906 +@@ -121,6 +121,16 @@ static void print_stacks(void)
5907 + }
5908 + }
5909 +
5910 ++static inline int generate_load(void)
5911 ++{
5912 ++ if (system("dd if=/dev/zero of=/dev/null count=5000k status=none") < 0) {
5913 ++ printf("failed to generate some load with dd: %s\n", strerror(errno));
5914 ++ return -1;
5915 ++ }
5916 ++
5917 ++ return 0;
5918 ++}
5919 ++
5920 + static void test_perf_event_all_cpu(struct perf_event_attr *attr)
5921 + {
5922 + int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
5923 +@@ -138,7 +148,11 @@ static void test_perf_event_all_cpu(struct perf_event_attr *attr)
5924 + assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
5925 + assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE) == 0);
5926 + }
5927 +- system("dd if=/dev/zero of=/dev/null count=5000k status=none");
5928 ++
5929 ++ if (generate_load() < 0) {
5930 ++ error = 1;
5931 ++ goto all_cpu_err;
5932 ++ }
5933 + print_stacks();
5934 + all_cpu_err:
5935 + for (i--; i >= 0; i--) {
5936 +@@ -152,7 +166,7 @@ all_cpu_err:
5937 +
5938 + static void test_perf_event_task(struct perf_event_attr *attr)
5939 + {
5940 +- int pmu_fd;
5941 ++ int pmu_fd, error = 0;
5942 +
5943 + /* open task bound event */
5944 + pmu_fd = sys_perf_event_open(attr, 0, -1, -1, 0);
5945 +@@ -162,10 +176,17 @@ static void test_perf_event_task(struct perf_event_attr *attr)
5946 + }
5947 + assert(ioctl(pmu_fd, PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
5948 + assert(ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE) == 0);
5949 +- system("dd if=/dev/zero of=/dev/null count=5000k status=none");
5950 ++
5951 ++ if (generate_load() < 0) {
5952 ++ error = 1;
5953 ++ goto err;
5954 ++ }
5955 + print_stacks();
5956 ++err:
5957 + ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE);
5958 + close(pmu_fd);
5959 ++ if (error)
5960 ++ int_exit(0);
5961 + }
5962 +
5963 + static void test_bpf_perf_event(void)
5964 +diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
5965 +index 20d9caa4be99..126e3f2e1ed7 100644
5966 +--- a/scripts/kconfig/zconf.y
5967 ++++ b/scripts/kconfig/zconf.y
5968 +@@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE];
5969 + static struct menu *current_menu, *current_entry;
5970 +
5971 + %}
5972 +-%expect 32
5973 ++%expect 31
5974 +
5975 + %union
5976 + {
5977 +@@ -345,7 +345,7 @@ choice_block:
5978 +
5979 + /* if entry */
5980 +
5981 +-if_entry: T_IF expr nl
5982 ++if_entry: T_IF expr T_EOL
5983 + {
5984 + printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
5985 + menu_add_entry(NULL);
5986 +diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
5987 +index 286171a16ed2..fdf01bfd1b07 100644
5988 +--- a/security/smack/smack_lsm.c
5989 ++++ b/security/smack/smack_lsm.c
5990 +@@ -2281,6 +2281,7 @@ static void smack_task_to_inode(struct task_struct *p, struct inode *inode)
5991 + struct smack_known *skp = smk_of_task_struct(p);
5992 +
5993 + isp->smk_inode = skp;
5994 ++ isp->smk_flags |= SMK_INODE_INSTANT;
5995 + }
5996 +
5997 + /*
5998 +diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
5999 +index a4c571cb3b87..350c33ec82b3 100644
6000 +--- a/sound/core/seq/seq_clientmgr.c
6001 ++++ b/sound/core/seq/seq_clientmgr.c
6002 +@@ -2001,7 +2001,8 @@ static int snd_seq_ioctl_query_next_client(struct snd_seq_client *client,
6003 + struct snd_seq_client *cptr = NULL;
6004 +
6005 + /* search for next client */
6006 +- info->client++;
6007 ++ if (info->client < INT_MAX)
6008 ++ info->client++;
6009 + if (info->client < 0)
6010 + info->client = 0;
6011 + for (; info->client < SNDRV_SEQ_MAX_CLIENTS; info->client++) {
6012 +diff --git a/tools/build/Makefile b/tools/build/Makefile
6013 +index 5eb4b5ad79cb..5edf65e684ab 100644
6014 +--- a/tools/build/Makefile
6015 ++++ b/tools/build/Makefile
6016 +@@ -43,7 +43,7 @@ $(OUTPUT)fixdep-in.o: FORCE
6017 + $(Q)$(MAKE) $(build)=fixdep
6018 +
6019 + $(OUTPUT)fixdep: $(OUTPUT)fixdep-in.o
6020 +- $(QUIET_LINK)$(HOSTCC) $(LDFLAGS) -o $@ $<
6021 ++ $(QUIET_LINK)$(HOSTCC) $(HOSTLDFLAGS) -o $@ $<
6022 +
6023 + FORCE:
6024 +
6025 +diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
6026 +index 4e60e105583e..0d1acb704f64 100644
6027 +--- a/tools/objtool/elf.c
6028 ++++ b/tools/objtool/elf.c
6029 +@@ -302,19 +302,34 @@ static int read_symbols(struct elf *elf)
6030 + continue;
6031 + sym->pfunc = sym->cfunc = sym;
6032 + coldstr = strstr(sym->name, ".cold.");
6033 +- if (coldstr) {
6034 +- coldstr[0] = '\0';
6035 +- pfunc = find_symbol_by_name(elf, sym->name);
6036 +- coldstr[0] = '.';
6037 +-
6038 +- if (!pfunc) {
6039 +- WARN("%s(): can't find parent function",
6040 +- sym->name);
6041 +- goto err;
6042 +- }
6043 +-
6044 +- sym->pfunc = pfunc;
6045 +- pfunc->cfunc = sym;
6046 ++ if (!coldstr)
6047 ++ continue;
6048 ++
6049 ++ coldstr[0] = '\0';
6050 ++ pfunc = find_symbol_by_name(elf, sym->name);
6051 ++ coldstr[0] = '.';
6052 ++
6053 ++ if (!pfunc) {
6054 ++ WARN("%s(): can't find parent function",
6055 ++ sym->name);
6056 ++ goto err;
6057 ++ }
6058 ++
6059 ++ sym->pfunc = pfunc;
6060 ++ pfunc->cfunc = sym;
6061 ++
6062 ++ /*
6063 ++ * Unfortunately, -fnoreorder-functions puts the child
6064 ++ * inside the parent. Remove the overlap so we can
6065 ++ * have sane assumptions.
6066 ++ *
6067 ++ * Note that pfunc->len now no longer matches
6068 ++ * pfunc->sym.st_size.
6069 ++ */
6070 ++ if (sym->sec == pfunc->sec &&
6071 ++ sym->offset >= pfunc->offset &&
6072 ++ sym->offset + sym->len == pfunc->offset + pfunc->len) {
6073 ++ pfunc->len -= sym->len;
6074 + }
6075 + }
6076 + }
6077 +diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
6078 +index 0c370f81e002..bd630c222e65 100644
6079 +--- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
6080 ++++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
6081 +@@ -243,7 +243,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
6082 + u64 ip;
6083 + u64 skip_slot = -1;
6084 +
6085 +- if (chain->nr < 3)
6086 ++ if (!chain || chain->nr < 3)
6087 + return skip_slot;
6088 +
6089 + ip = chain->ips[2];
6090 +diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c
6091 +index 4b2caf6d48e7..fead6b3b4206 100644
6092 +--- a/tools/perf/arch/x86/util/perf_regs.c
6093 ++++ b/tools/perf/arch/x86/util/perf_regs.c
6094 +@@ -226,7 +226,7 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)
6095 + else if (rm[2].rm_so != rm[2].rm_eo)
6096 + prefix[0] = '+';
6097 + else
6098 +- strncpy(prefix, "+0", 2);
6099 ++ scnprintf(prefix, sizeof(prefix), "+0");
6100 + }
6101 +
6102 + /* Rename register */
6103 +diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
6104 +index 944070e98a2c..0afcc7eccc61 100644
6105 +--- a/tools/perf/bench/numa.c
6106 ++++ b/tools/perf/bench/numa.c
6107 +@@ -1098,7 +1098,7 @@ static void *worker_thread(void *__tdata)
6108 + u8 *global_data;
6109 + u8 *process_data;
6110 + u8 *thread_data;
6111 +- u64 bytes_done;
6112 ++ u64 bytes_done, secs;
6113 + long work_done;
6114 + u32 l;
6115 + struct rusage rusage;
6116 +@@ -1254,7 +1254,8 @@ static void *worker_thread(void *__tdata)
6117 + timersub(&stop, &start0, &diff);
6118 + td->runtime_ns = diff.tv_sec * NSEC_PER_SEC;
6119 + td->runtime_ns += diff.tv_usec * NSEC_PER_USEC;
6120 +- td->speed_gbs = bytes_done / (td->runtime_ns / NSEC_PER_SEC) / 1e9;
6121 ++ secs = td->runtime_ns / NSEC_PER_SEC;
6122 ++ td->speed_gbs = secs ? bytes_done / secs / 1e9 : 0;
6123 +
6124 + getrusage(RUSAGE_THREAD, &rusage);
6125 + td->system_time_ns = rusage.ru_stime.tv_sec * NSEC_PER_SEC;
6126 +diff --git a/tools/perf/jvmti/jvmti_agent.c b/tools/perf/jvmti/jvmti_agent.c
6127 +index cf36de7ea255..c1d20d951434 100644
6128 +--- a/tools/perf/jvmti/jvmti_agent.c
6129 ++++ b/tools/perf/jvmti/jvmti_agent.c
6130 +@@ -35,6 +35,7 @@
6131 + #include <sys/mman.h>
6132 + #include <syscall.h> /* for gettid() */
6133 + #include <err.h>
6134 ++#include <linux/kernel.h>
6135 +
6136 + #include "jvmti_agent.h"
6137 + #include "../util/jitdump.h"
6138 +@@ -249,7 +250,7 @@ void *jvmti_open(void)
6139 + /*
6140 + * jitdump file name
6141 + */
6142 +- snprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid());
6143 ++ scnprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid());
6144 +
6145 + fd = open(dump_path, O_CREAT|O_TRUNC|O_RDWR, 0666);
6146 + if (fd == -1)
6147 +diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
6148 +index 81ede20f49d7..4e9dad8c9763 100644
6149 +--- a/tools/perf/tests/topology.c
6150 ++++ b/tools/perf/tests/topology.c
6151 +@@ -43,6 +43,7 @@ static int session_write_header(char *path)
6152 +
6153 + perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
6154 + perf_header__set_feat(&session->header, HEADER_NRCPUS);
6155 ++ perf_header__set_feat(&session->header, HEADER_ARCH);
6156 +
6157 + session->header.data_size += DATA_SIZE;
6158 +
6159 +diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cpp
6160 +index bf31ceab33bd..89512504551b 100644
6161 +--- a/tools/perf/util/c++/clang.cpp
6162 ++++ b/tools/perf/util/c++/clang.cpp
6163 +@@ -146,8 +146,15 @@ getBPFObjectFromModule(llvm::Module *Module)
6164 + raw_svector_ostream ostream(*Buffer);
6165 +
6166 + legacy::PassManager PM;
6167 +- if (TargetMachine->addPassesToEmitFile(PM, ostream,
6168 +- TargetMachine::CGFT_ObjectFile)) {
6169 ++ bool NotAdded;
6170 ++#if CLANG_VERSION_MAJOR < 7
6171 ++ NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
6172 ++ TargetMachine::CGFT_ObjectFile);
6173 ++#else
6174 ++ NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
6175 ++ TargetMachine::CGFT_ObjectFile);
6176 ++#endif
6177 ++ if (NotAdded) {
6178 + llvm::errs() << "TargetMachine can't emit a file of this type\n";
6179 + return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr);;
6180 + }
6181 +diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
6182 +index ba0cea8fef72..8a678a3d5a2a 100644
6183 +--- a/tools/perf/util/header.c
6184 ++++ b/tools/perf/util/header.c
6185 +@@ -1824,6 +1824,7 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
6186 + int cpu_nr = ff->ph->env.nr_cpus_avail;
6187 + u64 size = 0;
6188 + struct perf_header *ph = ff->ph;
6189 ++ bool do_core_id_test = true;
6190 +
6191 + ph->env.cpu = calloc(cpu_nr, sizeof(*ph->env.cpu));
6192 + if (!ph->env.cpu)
6193 +@@ -1878,6 +1879,13 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
6194 + return 0;
6195 + }
6196 +
6197 ++ /* On s390 the socket_id number is not related to the numbers of cpus.
6198 ++ * The socket_id number might be higher than the numbers of cpus.
6199 ++ * This depends on the configuration.
6200 ++ */
6201 ++ if (ph->env.arch && !strncmp(ph->env.arch, "s390", 4))
6202 ++ do_core_id_test = false;
6203 ++
6204 + for (i = 0; i < (u32)cpu_nr; i++) {
6205 + if (do_read_u32(ff, &nr))
6206 + goto free_cpu;
6207 +@@ -1887,7 +1895,7 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
6208 + if (do_read_u32(ff, &nr))
6209 + goto free_cpu;
6210 +
6211 +- if (nr != (u32)-1 && nr > (u32)cpu_nr) {
6212 ++ if (do_core_id_test && nr != (u32)-1 && nr > (u32)cpu_nr) {
6213 + pr_debug("socket_id number is too big."
6214 + "You may need to upgrade the perf tool.\n");
6215 + goto free_cpu;
6216 +diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
6217 +index 4952b429caa7..2bdaac048a0a 100644
6218 +--- a/tools/perf/util/llvm-utils.c
6219 ++++ b/tools/perf/util/llvm-utils.c
6220 +@@ -265,16 +265,16 @@ static const char *kinc_fetch_script =
6221 + "#!/usr/bin/env sh\n"
6222 + "if ! test -d \"$KBUILD_DIR\"\n"
6223 + "then\n"
6224 +-" exit -1\n"
6225 ++" exit 1\n"
6226 + "fi\n"
6227 + "if ! test -f \"$KBUILD_DIR/include/generated/autoconf.h\"\n"
6228 + "then\n"
6229 +-" exit -1\n"
6230 ++" exit 1\n"
6231 + "fi\n"
6232 + "TMPDIR=`mktemp -d`\n"
6233 + "if test -z \"$TMPDIR\"\n"
6234 + "then\n"
6235 +-" exit -1\n"
6236 ++" exit 1\n"
6237 + "fi\n"
6238 + "cat << EOF > $TMPDIR/Makefile\n"
6239 + "obj-y := dummy.o\n"
6240 +diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
6241 +index 988310cd3049..b6115cbdf842 100644
6242 +--- a/tools/perf/util/parse-events.y
6243 ++++ b/tools/perf/util/parse-events.y
6244 +@@ -226,11 +226,16 @@ event_def: event_pmu |
6245 + event_pmu:
6246 + PE_NAME opt_pmu_config
6247 + {
6248 ++ struct parse_events_state *parse_state = _parse_state;
6249 ++ struct parse_events_error *error = parse_state->error;
6250 + struct list_head *list, *orig_terms, *terms;
6251 +
6252 + if (parse_events_copy_term_list($2, &orig_terms))
6253 + YYABORT;
6254 +
6255 ++ if (error)
6256 ++ error->idx = @1.first_column;
6257 ++
6258 + ALLOC_LIST(list);
6259 + if (parse_events_add_pmu(_parse_state, list, $1, $2)) {
6260 + struct perf_pmu *pmu = NULL;
6261 +diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
6262 +index c7187f067d31..f03fa7a835a1 100644
6263 +--- a/tools/perf/util/scripting-engines/trace-event-python.c
6264 ++++ b/tools/perf/util/scripting-engines/trace-event-python.c
6265 +@@ -643,14 +643,11 @@ static void python_process_tracepoint(struct perf_sample *sample,
6266 + if (_PyTuple_Resize(&t, n) == -1)
6267 + Py_FatalError("error resizing Python tuple");
6268 +
6269 +- if (!dict) {
6270 ++ if (!dict)
6271 + call_object(handler, t, handler_name);
6272 +- } else {
6273 ++ else
6274 + call_object(handler, t, default_handler_name);
6275 +- Py_DECREF(dict);
6276 +- }
6277 +
6278 +- Py_XDECREF(all_entries_dict);
6279 + Py_DECREF(t);
6280 + }
6281 +
6282 +@@ -970,7 +967,6 @@ static void python_process_general_event(struct perf_sample *sample,
6283 +
6284 + call_object(handler, t, handler_name);
6285 +
6286 +- Py_DECREF(dict);
6287 + Py_DECREF(t);
6288 + }
6289 +
6290 +diff --git a/tools/testing/selftests/bpf/test_kmod.sh b/tools/testing/selftests/bpf/test_kmod.sh
6291 +index ed4774d8d6ed..0f7b9aa9c6a5 100755
6292 +--- a/tools/testing/selftests/bpf/test_kmod.sh
6293 ++++ b/tools/testing/selftests/bpf/test_kmod.sh
6294 +@@ -1,6 +1,15 @@
6295 + #!/bin/sh
6296 + # SPDX-License-Identifier: GPL-2.0
6297 +
6298 ++# Kselftest framework requirement - SKIP code is 4.
6299 ++ksft_skip=4
6300 ++
6301 ++msg="skip all tests:"
6302 ++if [ "$(id -u)" != "0" ]; then
6303 ++ echo $msg please run this as root >&2
6304 ++ exit $ksft_skip
6305 ++fi
6306 ++
6307 + SRC_TREE=../../../../
6308 +
6309 + test_run()
6310 +diff --git a/tools/testing/selftests/pstore/pstore_post_reboot_tests b/tools/testing/selftests/pstore/pstore_post_reboot_tests
6311 +index 6ccb154cb4aa..22f8df1ad7d4 100755
6312 +--- a/tools/testing/selftests/pstore/pstore_post_reboot_tests
6313 ++++ b/tools/testing/selftests/pstore/pstore_post_reboot_tests
6314 +@@ -7,13 +7,16 @@
6315 + #
6316 + # Released under the terms of the GPL v2.
6317 +
6318 ++# Kselftest framework requirement - SKIP code is 4.
6319 ++ksft_skip=4
6320 ++
6321 + . ./common_tests
6322 +
6323 + if [ -e $REBOOT_FLAG ]; then
6324 + rm $REBOOT_FLAG
6325 + else
6326 + prlog "pstore_crash_test has not been executed yet. we skip further tests."
6327 +- exit 0
6328 ++ exit $ksft_skip
6329 + fi
6330 +
6331 + prlog -n "Mounting pstore filesystem ... "
6332 +diff --git a/tools/testing/selftests/static_keys/test_static_keys.sh b/tools/testing/selftests/static_keys/test_static_keys.sh
6333 +index 24cff498b31a..fc9f8cde7d42 100755
6334 +--- a/tools/testing/selftests/static_keys/test_static_keys.sh
6335 ++++ b/tools/testing/selftests/static_keys/test_static_keys.sh
6336 +@@ -2,6 +2,19 @@
6337 + # SPDX-License-Identifier: GPL-2.0
6338 + # Runs static keys kernel module tests
6339 +
6340 ++# Kselftest framework requirement - SKIP code is 4.
6341 ++ksft_skip=4
6342 ++
6343 ++if ! /sbin/modprobe -q -n test_static_key_base; then
6344 ++ echo "static_key: module test_static_key_base is not found [SKIP]"
6345 ++ exit $ksft_skip
6346 ++fi
6347 ++
6348 ++if ! /sbin/modprobe -q -n test_static_keys; then
6349 ++ echo "static_key: module test_static_keys is not found [SKIP]"
6350 ++ exit $ksft_skip
6351 ++fi
6352 ++
6353 + if /sbin/modprobe -q test_static_key_base; then
6354 + if /sbin/modprobe -q test_static_keys; then
6355 + echo "static_key: ok"
6356 +diff --git a/tools/testing/selftests/sync/config b/tools/testing/selftests/sync/config
6357 +new file mode 100644
6358 +index 000000000000..1ab7e8130db2
6359 +--- /dev/null
6360 ++++ b/tools/testing/selftests/sync/config
6361 +@@ -0,0 +1,4 @@
6362 ++CONFIG_STAGING=y
6363 ++CONFIG_ANDROID=y
6364 ++CONFIG_SYNC=y
6365 ++CONFIG_SW_SYNC=y
6366 +diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
6367 +index ec232c3cfcaa..584eb8ea780a 100755
6368 +--- a/tools/testing/selftests/sysctl/sysctl.sh
6369 ++++ b/tools/testing/selftests/sysctl/sysctl.sh
6370 +@@ -14,6 +14,9 @@
6371 +
6372 + # This performs a series tests against the proc sysctl interface.
6373 +
6374 ++# Kselftest framework requirement - SKIP code is 4.
6375 ++ksft_skip=4
6376 ++
6377 + TEST_NAME="sysctl"
6378 + TEST_DRIVER="test_${TEST_NAME}"
6379 + TEST_DIR=$(dirname $0)
6380 +@@ -41,7 +44,7 @@ test_modprobe()
6381 + echo "$0: $DIR not present" >&2
6382 + echo "You must have the following enabled in your kernel:" >&2
6383 + cat $TEST_DIR/config >&2
6384 +- exit 1
6385 ++ exit $ksft_skip
6386 + fi
6387 + }
6388 +
6389 +@@ -98,28 +101,30 @@ test_reqs()
6390 + uid=$(id -u)
6391 + if [ $uid -ne 0 ]; then
6392 + echo $msg must be run as root >&2
6393 +- exit 0
6394 ++ exit $ksft_skip
6395 + fi
6396 +
6397 + if ! which perl 2> /dev/null > /dev/null; then
6398 + echo "$0: You need perl installed"
6399 +- exit 1
6400 ++ exit $ksft_skip
6401 + fi
6402 + if ! which getconf 2> /dev/null > /dev/null; then
6403 + echo "$0: You need getconf installed"
6404 +- exit 1
6405 ++ exit $ksft_skip
6406 + fi
6407 + if ! which diff 2> /dev/null > /dev/null; then
6408 + echo "$0: You need diff installed"
6409 +- exit 1
6410 ++ exit $ksft_skip
6411 + fi
6412 + }
6413 +
6414 + function load_req_mod()
6415 + {
6416 +- trap "test_modprobe" EXIT
6417 +-
6418 + if [ ! -d $DIR ]; then
6419 ++ if ! modprobe -q -n $TEST_DRIVER; then
6420 ++ echo "$0: module $TEST_DRIVER not found [SKIP]"
6421 ++ exit $ksft_skip
6422 ++ fi
6423 + modprobe $TEST_DRIVER
6424 + if [ $? -ne 0 ]; then
6425 + exit
6426 +@@ -765,6 +770,7 @@ function parse_args()
6427 + test_reqs
6428 + allow_user_defaults
6429 + check_production_sysctl_writes_strict
6430 ++test_modprobe
6431 + load_req_mod
6432 +
6433 + trap "test_finish" EXIT
6434 +diff --git a/tools/testing/selftests/user/test_user_copy.sh b/tools/testing/selftests/user/test_user_copy.sh
6435 +index d60506fc77f8..f9b31a57439b 100755
6436 +--- a/tools/testing/selftests/user/test_user_copy.sh
6437 ++++ b/tools/testing/selftests/user/test_user_copy.sh
6438 +@@ -2,6 +2,13 @@
6439 + # SPDX-License-Identifier: GPL-2.0
6440 + # Runs copy_to/from_user infrastructure using test_user_copy kernel module
6441 +
6442 ++# Kselftest framework requirement - SKIP code is 4.
6443 ++ksft_skip=4
6444 ++
6445 ++if ! /sbin/modprobe -q -n test_user_copy; then
6446 ++ echo "user: module test_user_copy is not found [SKIP]"
6447 ++ exit $ksft_skip
6448 ++fi
6449 + if /sbin/modprobe -q test_user_copy; then
6450 + /sbin/modprobe -q -r test_user_copy
6451 + echo "user_copy: ok"
6452 +diff --git a/tools/testing/selftests/vm/compaction_test.c b/tools/testing/selftests/vm/compaction_test.c
6453 +index 1097f04e4d80..bcec71250873 100644
6454 +--- a/tools/testing/selftests/vm/compaction_test.c
6455 ++++ b/tools/testing/selftests/vm/compaction_test.c
6456 +@@ -16,6 +16,8 @@
6457 + #include <unistd.h>
6458 + #include <string.h>
6459 +
6460 ++#include "../kselftest.h"
6461 ++
6462 + #define MAP_SIZE 1048576
6463 +
6464 + struct map_list {
6465 +@@ -169,7 +171,7 @@ int main(int argc, char **argv)
6466 + printf("Either the sysctl compact_unevictable_allowed is not\n"
6467 + "set to 1 or couldn't read the proc file.\n"
6468 + "Skipping the test\n");
6469 +- return 0;
6470 ++ return KSFT_SKIP;
6471 + }
6472 +
6473 + lim.rlim_cur = RLIM_INFINITY;
6474 +diff --git a/tools/testing/selftests/vm/mlock2-tests.c b/tools/testing/selftests/vm/mlock2-tests.c
6475 +index 4997b9222cfa..637b6d0ac0d0 100644
6476 +--- a/tools/testing/selftests/vm/mlock2-tests.c
6477 ++++ b/tools/testing/selftests/vm/mlock2-tests.c
6478 +@@ -9,6 +9,8 @@
6479 + #include <stdbool.h>
6480 + #include "mlock2.h"
6481 +
6482 ++#include "../kselftest.h"
6483 ++
6484 + struct vm_boundaries {
6485 + unsigned long start;
6486 + unsigned long end;
6487 +@@ -303,7 +305,7 @@ static int test_mlock_lock()
6488 + if (mlock2_(map, 2 * page_size, 0)) {
6489 + if (errno == ENOSYS) {
6490 + printf("Cannot call new mlock family, skipping test\n");
6491 +- _exit(0);
6492 ++ _exit(KSFT_SKIP);
6493 + }
6494 + perror("mlock2(0)");
6495 + goto unmap;
6496 +@@ -412,7 +414,7 @@ static int test_mlock_onfault()
6497 + if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) {
6498 + if (errno == ENOSYS) {
6499 + printf("Cannot call new mlock family, skipping test\n");
6500 +- _exit(0);
6501 ++ _exit(KSFT_SKIP);
6502 + }
6503 + perror("mlock2(MLOCK_ONFAULT)");
6504 + goto unmap;
6505 +@@ -425,7 +427,7 @@ static int test_mlock_onfault()
6506 + if (munlock(map, 2 * page_size)) {
6507 + if (errno == ENOSYS) {
6508 + printf("Cannot call new mlock family, skipping test\n");
6509 +- _exit(0);
6510 ++ _exit(KSFT_SKIP);
6511 + }
6512 + perror("munlock()");
6513 + goto unmap;
6514 +@@ -457,7 +459,7 @@ static int test_lock_onfault_of_present()
6515 + if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) {
6516 + if (errno == ENOSYS) {
6517 + printf("Cannot call new mlock family, skipping test\n");
6518 +- _exit(0);
6519 ++ _exit(KSFT_SKIP);
6520 + }
6521 + perror("mlock2(MLOCK_ONFAULT)");
6522 + goto unmap;
6523 +@@ -583,7 +585,7 @@ static int test_vma_management(bool call_mlock)
6524 + if (call_mlock && mlock2_(map, 3 * page_size, MLOCK_ONFAULT)) {
6525 + if (errno == ENOSYS) {
6526 + printf("Cannot call new mlock family, skipping test\n");
6527 +- _exit(0);
6528 ++ _exit(KSFT_SKIP);
6529 + }
6530 + perror("mlock(ONFAULT)\n");
6531 + goto out;
6532 +diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
6533 +index 45708aa3ce47..57ab6ac0d4a4 100755
6534 +--- a/tools/testing/selftests/vm/run_vmtests
6535 ++++ b/tools/testing/selftests/vm/run_vmtests
6536 +@@ -2,6 +2,9 @@
6537 + # SPDX-License-Identifier: GPL-2.0
6538 + #please run as root
6539 +
6540 ++# Kselftest framework requirement - SKIP code is 4.
6541 ++ksft_skip=4
6542 ++
6543 + mnt=./huge
6544 + exitcode=0
6545 +
6546 +@@ -36,7 +39,7 @@ if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
6547 + echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
6548 + if [ $? -ne 0 ]; then
6549 + echo "Please run this test as root"
6550 +- exit 1
6551 ++ exit $ksft_skip
6552 + fi
6553 + while read name size unit; do
6554 + if [ "$name" = "HugePages_Free:" ]; then
6555 +diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
6556 +index de2f9ec8a87f..7b8171e3128a 100644
6557 +--- a/tools/testing/selftests/vm/userfaultfd.c
6558 ++++ b/tools/testing/selftests/vm/userfaultfd.c
6559 +@@ -69,6 +69,8 @@
6560 + #include <setjmp.h>
6561 + #include <stdbool.h>
6562 +
6563 ++#include "../kselftest.h"
6564 ++
6565 + #ifdef __NR_userfaultfd
6566 +
6567 + static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
6568 +@@ -1322,7 +1324,7 @@ int main(int argc, char **argv)
6569 + int main(void)
6570 + {
6571 + printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n");
6572 +- return 0;
6573 ++ return KSFT_SKIP;
6574 + }
6575 +
6576 + #endif /* __NR_userfaultfd */
6577 +diff --git a/tools/testing/selftests/x86/sigreturn.c b/tools/testing/selftests/x86/sigreturn.c
6578 +index 246145b84a12..4d9dc3f2fd70 100644
6579 +--- a/tools/testing/selftests/x86/sigreturn.c
6580 ++++ b/tools/testing/selftests/x86/sigreturn.c
6581 +@@ -610,21 +610,41 @@ static int test_valid_sigreturn(int cs_bits, bool use_16bit_ss, int force_ss)
6582 + */
6583 + for (int i = 0; i < NGREG; i++) {
6584 + greg_t req = requested_regs[i], res = resulting_regs[i];
6585 ++
6586 + if (i == REG_TRAPNO || i == REG_IP)
6587 + continue; /* don't care */
6588 +- if (i == REG_SP) {
6589 +- printf("\tSP: %llx -> %llx\n", (unsigned long long)req,
6590 +- (unsigned long long)res);
6591 +
6592 ++ if (i == REG_SP) {
6593 + /*
6594 +- * In many circumstances, the high 32 bits of rsp
6595 +- * are zeroed. For example, we could be a real
6596 +- * 32-bit program, or we could hit any of a number
6597 +- * of poorly-documented IRET or segmented ESP
6598 +- * oddities. If this happens, it's okay.
6599 ++ * If we were using a 16-bit stack segment, then
6600 ++ * the kernel is a bit stuck: IRET only restores
6601 ++ * the low 16 bits of ESP/RSP if SS is 16-bit.
6602 ++ * The kernel uses a hack to restore bits 31:16,
6603 ++ * but that hack doesn't help with bits 63:32.
6604 ++ * On Intel CPUs, bits 63:32 end up zeroed, and, on
6605 ++ * AMD CPUs, they leak the high bits of the kernel
6606 ++ * espfix64 stack pointer. There's very little that
6607 ++ * the kernel can do about it.
6608 ++ *
6609 ++ * Similarly, if we are returning to a 32-bit context,
6610 ++ * the CPU will often lose the high 32 bits of RSP.
6611 + */
6612 +- if (res == (req & 0xFFFFFFFF))
6613 +- continue; /* OK; not expected to work */
6614 ++
6615 ++ if (res == req)
6616 ++ continue;
6617 ++
6618 ++ if (cs_bits != 64 && ((res ^ req) & 0xFFFFFFFF) == 0) {
6619 ++ printf("[NOTE]\tSP: %llx -> %llx\n",
6620 ++ (unsigned long long)req,
6621 ++ (unsigned long long)res);
6622 ++ continue;
6623 ++ }
6624 ++
6625 ++ printf("[FAIL]\tSP mismatch: requested 0x%llx; got 0x%llx\n",
6626 ++ (unsigned long long)requested_regs[i],
6627 ++ (unsigned long long)resulting_regs[i]);
6628 ++ nerrs++;
6629 ++ continue;
6630 + }
6631 +
6632 + bool ignore_reg = false;
6633 +@@ -654,25 +674,18 @@ static int test_valid_sigreturn(int cs_bits, bool use_16bit_ss, int force_ss)
6634 + #endif
6635 +
6636 + /* Sanity check on the kernel */
6637 +- if (i == REG_CX && requested_regs[i] != resulting_regs[i]) {
6638 ++ if (i == REG_CX && req != res) {
6639 + printf("[FAIL]\tCX (saved SP) mismatch: requested 0x%llx; got 0x%llx\n",
6640 +- (unsigned long long)requested_regs[i],
6641 +- (unsigned long long)resulting_regs[i]);
6642 ++ (unsigned long long)req,
6643 ++ (unsigned long long)res);
6644 + nerrs++;
6645 + continue;
6646 + }
6647 +
6648 +- if (requested_regs[i] != resulting_regs[i] && !ignore_reg) {
6649 +- /*
6650 +- * SP is particularly interesting here. The
6651 +- * usual cause of failures is that we hit the
6652 +- * nasty IRET case of returning to a 16-bit SS,
6653 +- * in which case bits 16:31 of the *kernel*
6654 +- * stack pointer persist in ESP.
6655 +- */
6656 ++ if (req != res && !ignore_reg) {
6657 + printf("[FAIL]\tReg %d mismatch: requested 0x%llx; got 0x%llx\n",
6658 +- i, (unsigned long long)requested_regs[i],
6659 +- (unsigned long long)resulting_regs[i]);
6660 ++ i, (unsigned long long)req,
6661 ++ (unsigned long long)res);
6662 + nerrs++;
6663 + }
6664 + }
6665 +diff --git a/tools/testing/selftests/zram/zram.sh b/tools/testing/selftests/zram/zram.sh
6666 +index 754de7da426a..232e958ec454 100755
6667 +--- a/tools/testing/selftests/zram/zram.sh
6668 ++++ b/tools/testing/selftests/zram/zram.sh
6669 +@@ -2,6 +2,9 @@
6670 + # SPDX-License-Identifier: GPL-2.0
6671 + TCID="zram.sh"
6672 +
6673 ++# Kselftest framework requirement - SKIP code is 4.
6674 ++ksft_skip=4
6675 ++
6676 + . ./zram_lib.sh
6677 +
6678 + run_zram () {
6679 +@@ -24,5 +27,5 @@ elif [ -b /dev/zram0 ]; then
6680 + else
6681 + echo "$TCID : No zram.ko module or /dev/zram0 device file not found"
6682 + echo "$TCID : CONFIG_ZRAM is not set"
6683 +- exit 1
6684 ++ exit $ksft_skip
6685 + fi
6686 +diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh
6687 +index f6a9c73e7a44..9e73a4fb9b0a 100755
6688 +--- a/tools/testing/selftests/zram/zram_lib.sh
6689 ++++ b/tools/testing/selftests/zram/zram_lib.sh
6690 +@@ -18,6 +18,9 @@ MODULE=0
6691 + dev_makeswap=-1
6692 + dev_mounted=-1
6693 +
6694 ++# Kselftest framework requirement - SKIP code is 4.
6695 ++ksft_skip=4
6696 ++
6697 + trap INT
6698 +
6699 + check_prereqs()
6700 +@@ -27,7 +30,7 @@ check_prereqs()
6701 +
6702 + if [ $uid -ne 0 ]; then
6703 + echo $msg must be run as root >&2
6704 +- exit 0
6705 ++ exit $ksft_skip
6706 + fi
6707 + }
6708 +
6709 +diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
6710 +index 6b4fcd52f14c..a37b03c25457 100644
6711 +--- a/virt/kvm/arm/vgic/vgic-v3.c
6712 ++++ b/virt/kvm/arm/vgic/vgic-v3.c
6713 +@@ -492,11 +492,6 @@ int vgic_v3_probe(const struct gic_kvm_info *info)
6714 + pr_warn("GICV physical address 0x%llx not page aligned\n",
6715 + (unsigned long long)info->vcpu.start);
6716 + kvm_vgic_global_state.vcpu_base = 0;
6717 +- } else if (!PAGE_ALIGNED(resource_size(&info->vcpu))) {
6718 +- pr_warn("GICV size 0x%llx not a multiple of page size 0x%lx\n",
6719 +- (unsigned long long)resource_size(&info->vcpu),
6720 +- PAGE_SIZE);
6721 +- kvm_vgic_global_state.vcpu_base = 0;
6722 + } else {
6723 + kvm_vgic_global_state.vcpu_base = info->vcpu.start;
6724 + kvm_vgic_global_state.can_emulate_gicv2 = true;
6725 +diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
6726 +index 58a9b31b0dd5..088734a700e9 100644
6727 +--- a/virt/kvm/eventfd.c
6728 ++++ b/virt/kvm/eventfd.c
6729 +@@ -405,11 +405,6 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
6730 + if (events & POLLIN)
6731 + schedule_work(&irqfd->inject);
6732 +
6733 +- /*
6734 +- * do not drop the file until the irqfd is fully initialized, otherwise
6735 +- * we might race against the POLLHUP
6736 +- */
6737 +- fdput(f);
6738 + #ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
6739 + if (kvm_arch_has_irq_bypass()) {
6740 + irqfd->consumer.token = (void *)irqfd->eventfd;
6741 +@@ -425,6 +420,12 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
6742 + #endif
6743 +
6744 + srcu_read_unlock(&kvm->irq_srcu, idx);
6745 ++
6746 ++ /*
6747 ++ * do not drop the file until the irqfd is fully initialized, otherwise
6748 ++ * we might race against the POLLHUP
6749 ++ */
6750 ++ fdput(f);
6751 + return 0;
6752 +
6753 + fail: