Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.17 commit in: /
Date: Fri, 24 Aug 2018 11:45:12
Message-Id: 1535111096.c75c995c2729fd757a3c04492a7adac5e31b18c0.mpagano@gentoo
1 commit: c75c995c2729fd757a3c04492a7adac5e31b18c0
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Aug 24 11:44:56 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri Aug 24 11:44:56 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=c75c995c
7
8 Linux patch 4.17.19
9
10 0000_README | 4 +
11 1018_linux-4.17.19.patch | 10954 +++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 10958 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index 1887187..b1dd52b 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -115,6 +115,10 @@ Patch: 1017_linux-4.17.18.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.17.18
21
22 +Patch: 1018_linux-4.17.19.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.17.19
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1018_linux-4.17.19.patch b/1018_linux-4.17.19.patch
31 new file mode 100644
32 index 0000000..aac0886
33 --- /dev/null
34 +++ b/1018_linux-4.17.19.patch
35 @@ -0,0 +1,10954 @@
36 +diff --git a/Makefile b/Makefile
37 +index 429a1fe0b40b..32c83a163544 100644
38 +--- a/Makefile
39 ++++ b/Makefile
40 +@@ -1,7 +1,7 @@
41 + # SPDX-License-Identifier: GPL-2.0
42 + VERSION = 4
43 + PATCHLEVEL = 17
44 +-SUBLEVEL = 18
45 ++SUBLEVEL = 19
46 + EXTRAVERSION =
47 + NAME = Merciless Moray
48 +
49 +@@ -356,9 +356,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
50 + else if [ -x /bin/bash ]; then echo /bin/bash; \
51 + else echo sh; fi ; fi)
52 +
53 +-HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS)
54 +-HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS)
55 +-HOST_LFS_LIBS := $(shell getconf LFS_LIBS)
56 ++HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
57 ++HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
58 ++HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
59 +
60 + HOSTCC = gcc
61 + HOSTCXX = g++
62 +diff --git a/arch/arc/Makefile b/arch/arc/Makefile
63 +index d37f49d6a27f..6c1b20dd76ad 100644
64 +--- a/arch/arc/Makefile
65 ++++ b/arch/arc/Makefile
66 +@@ -16,7 +16,7 @@ endif
67 +
68 + KBUILD_DEFCONFIG := nsim_700_defconfig
69 +
70 +-cflags-y += -fno-common -pipe -fno-builtin -D__linux__
71 ++cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
72 + cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7
73 + cflags-$(CONFIG_ISA_ARCV2) += -mcpu=archs
74 +
75 +@@ -140,16 +140,3 @@ dtbs: scripts
76 +
77 + archclean:
78 + $(Q)$(MAKE) $(clean)=$(boot)
79 +-
80 +-# Hacks to enable final link due to absence of link-time branch relexation
81 +-# and gcc choosing optimal(shorter) branches at -O3
82 +-#
83 +-# vineetg Feb 2010: -mlong-calls switched off for overall kernel build
84 +-# However lib/decompress_inflate.o (.init.text) calls
85 +-# zlib_inflate_workspacesize (.text) causing relocation errors.
86 +-# Thus forcing all exten calls in this file to be long calls
87 +-export CFLAGS_decompress_inflate.o = -mmedium-calls
88 +-export CFLAGS_initramfs.o = -mmedium-calls
89 +-ifdef CONFIG_SMP
90 +-export CFLAGS_core.o = -mmedium-calls
91 +-endif
92 +diff --git a/arch/arc/include/asm/mach_desc.h b/arch/arc/include/asm/mach_desc.h
93 +index c28e6c347b49..871f3cb16af9 100644
94 +--- a/arch/arc/include/asm/mach_desc.h
95 ++++ b/arch/arc/include/asm/mach_desc.h
96 +@@ -34,9 +34,7 @@ struct machine_desc {
97 + const char *name;
98 + const char **dt_compat;
99 + void (*init_early)(void);
100 +-#ifdef CONFIG_SMP
101 + void (*init_per_cpu)(unsigned int);
102 +-#endif
103 + void (*init_machine)(void);
104 + void (*init_late)(void);
105 +
106 +diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c
107 +index 538b36afe89e..62b185057c04 100644
108 +--- a/arch/arc/kernel/irq.c
109 ++++ b/arch/arc/kernel/irq.c
110 +@@ -31,10 +31,10 @@ void __init init_IRQ(void)
111 + /* a SMP H/w block could do IPI IRQ request here */
112 + if (plat_smp_ops.init_per_cpu)
113 + plat_smp_ops.init_per_cpu(smp_processor_id());
114 ++#endif
115 +
116 + if (machine_desc->init_per_cpu)
117 + machine_desc->init_per_cpu(smp_processor_id());
118 +-#endif
119 + }
120 +
121 + /*
122 +diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
123 +index 5ac3b547453f..4674541eba3f 100644
124 +--- a/arch/arc/kernel/process.c
125 ++++ b/arch/arc/kernel/process.c
126 +@@ -47,7 +47,8 @@ SYSCALL_DEFINE0(arc_gettls)
127 + SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
128 + {
129 + struct pt_regs *regs = current_pt_regs();
130 +- int uval = -EFAULT;
131 ++ u32 uval;
132 ++ int ret;
133 +
134 + /*
135 + * This is only for old cores lacking LLOCK/SCOND, which by defintion
136 +@@ -60,23 +61,47 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
137 + /* Z indicates to userspace if operation succeded */
138 + regs->status32 &= ~STATUS_Z_MASK;
139 +
140 +- if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
141 +- return -EFAULT;
142 ++ ret = access_ok(VERIFY_WRITE, uaddr, sizeof(*uaddr));
143 ++ if (!ret)
144 ++ goto fail;
145 +
146 ++again:
147 + preempt_disable();
148 +
149 +- if (__get_user(uval, uaddr))
150 +- goto done;
151 ++ ret = __get_user(uval, uaddr);
152 ++ if (ret)
153 ++ goto fault;
154 +
155 +- if (uval == expected) {
156 +- if (!__put_user(new, uaddr))
157 +- regs->status32 |= STATUS_Z_MASK;
158 +- }
159 ++ if (uval != expected)
160 ++ goto out;
161 +
162 +-done:
163 +- preempt_enable();
164 ++ ret = __put_user(new, uaddr);
165 ++ if (ret)
166 ++ goto fault;
167 ++
168 ++ regs->status32 |= STATUS_Z_MASK;
169 +
170 ++out:
171 ++ preempt_enable();
172 + return uval;
173 ++
174 ++fault:
175 ++ preempt_enable();
176 ++
177 ++ if (unlikely(ret != -EFAULT))
178 ++ goto fail;
179 ++
180 ++ down_read(&current->mm->mmap_sem);
181 ++ ret = fixup_user_fault(current, current->mm, (unsigned long) uaddr,
182 ++ FAULT_FLAG_WRITE, NULL);
183 ++ up_read(&current->mm->mmap_sem);
184 ++
185 ++ if (likely(!ret))
186 ++ goto again;
187 ++
188 ++fail:
189 ++ force_sig(SIGSEGV, current);
190 ++ return ret;
191 + }
192 +
193 + #ifdef CONFIG_ISA_ARCV2
194 +diff --git a/arch/arc/plat-hsdk/platform.c b/arch/arc/plat-hsdk/platform.c
195 +index 2958aedb649a..2588b842407c 100644
196 +--- a/arch/arc/plat-hsdk/platform.c
197 ++++ b/arch/arc/plat-hsdk/platform.c
198 +@@ -42,6 +42,66 @@ static void __init hsdk_init_per_cpu(unsigned int cpu)
199 + #define SDIO_UHS_REG_EXT (SDIO_BASE + 0x108)
200 + #define SDIO_UHS_REG_EXT_DIV_2 (2 << 30)
201 +
202 ++#define HSDK_GPIO_INTC (ARC_PERIPHERAL_BASE + 0x3000)
203 ++
204 ++static void __init hsdk_enable_gpio_intc_wire(void)
205 ++{
206 ++ /*
207 ++ * Peripherals on CPU Card are wired to cpu intc via intermediate
208 ++ * DW APB GPIO blocks (mainly for debouncing)
209 ++ *
210 ++ * ---------------------
211 ++ * | snps,archs-intc |
212 ++ * ---------------------
213 ++ * |
214 ++ * ----------------------
215 ++ * | snps,archs-idu-intc |
216 ++ * ----------------------
217 ++ * | | | | |
218 ++ * | [eth] [USB] [... other peripherals]
219 ++ * |
220 ++ * -------------------
221 ++ * | snps,dw-apb-intc |
222 ++ * -------------------
223 ++ * | | | |
224 ++ * [Bt] [HAPS] [... other peripherals]
225 ++ *
226 ++ * Current implementation of "irq-dw-apb-ictl" driver doesn't work well
227 ++ * with stacked INTCs. In particular problem happens if its master INTC
228 ++ * not yet instantiated. See discussion here -
229 ++ * https://lkml.org/lkml/2015/3/4/755
230 ++ *
231 ++ * So setup the first gpio block as a passive pass thru and hide it from
232 ++ * DT hardware topology - connect intc directly to cpu intc
233 ++ * The GPIO "wire" needs to be init nevertheless (here)
234 ++ *
235 ++ * One side adv is that peripheral interrupt handling avoids one nested
236 ++ * intc ISR hop
237 ++ *
238 ++ * According to HSDK User's Manual [1], "Table 2 Interrupt Mapping"
239 ++ * we have the following GPIO input lines used as sources of interrupt:
240 ++ * - GPIO[0] - Bluetooth interrupt of RS9113 module
241 ++ * - GPIO[2] - HAPS interrupt (on HapsTrak 3 connector)
242 ++ * - GPIO[3] - Audio codec (MAX9880A) interrupt
243 ++ * - GPIO[8-23] - Available on Arduino and PMOD_x headers
244 ++ * For now there's no use of Arduino and PMOD_x headers in Linux
245 ++ * use-case so we only enable lines 0, 2 and 3.
246 ++ *
247 ++ * [1] https://github.com/foss-for-synopsys-dwc-arc-processors/ARC-Development-Systems-Forum/wiki/docs/ARC_HSDK_User_Guide.pdf
248 ++ */
249 ++#define GPIO_INTEN (HSDK_GPIO_INTC + 0x30)
250 ++#define GPIO_INTMASK (HSDK_GPIO_INTC + 0x34)
251 ++#define GPIO_INTTYPE_LEVEL (HSDK_GPIO_INTC + 0x38)
252 ++#define GPIO_INT_POLARITY (HSDK_GPIO_INTC + 0x3c)
253 ++#define GPIO_INT_CONNECTED_MASK 0x0d
254 ++
255 ++ iowrite32(0xffffffff, (void __iomem *) GPIO_INTMASK);
256 ++ iowrite32(~GPIO_INT_CONNECTED_MASK, (void __iomem *) GPIO_INTMASK);
257 ++ iowrite32(0x00000000, (void __iomem *) GPIO_INTTYPE_LEVEL);
258 ++ iowrite32(0xffffffff, (void __iomem *) GPIO_INT_POLARITY);
259 ++ iowrite32(GPIO_INT_CONNECTED_MASK, (void __iomem *) GPIO_INTEN);
260 ++}
261 ++
262 + static void __init hsdk_init_early(void)
263 + {
264 + /*
265 +@@ -62,6 +122,8 @@ static void __init hsdk_init_early(void)
266 + * minimum possible div-by-2.
267 + */
268 + iowrite32(SDIO_UHS_REG_EXT_DIV_2, (void __iomem *) SDIO_UHS_REG_EXT);
269 ++
270 ++ hsdk_enable_gpio_intc_wire();
271 + }
272 +
273 + static const char *hsdk_compat[] __initconst = {
274 +diff --git a/arch/arm/boot/dts/am3517.dtsi b/arch/arm/boot/dts/am3517.dtsi
275 +index 4b6062b631b1..23ea381d363f 100644
276 +--- a/arch/arm/boot/dts/am3517.dtsi
277 ++++ b/arch/arm/boot/dts/am3517.dtsi
278 +@@ -91,6 +91,11 @@
279 + };
280 + };
281 +
282 ++/* Table Table 5-79 of the TRM shows 480ab000 is reserved */
283 ++&usb_otg_hs {
284 ++ status = "disabled";
285 ++};
286 ++
287 + &iva {
288 + status = "disabled";
289 + };
290 +diff --git a/arch/arm/boot/dts/am437x-sk-evm.dts b/arch/arm/boot/dts/am437x-sk-evm.dts
291 +index 4118802b7fea..f17ed89da06b 100644
292 +--- a/arch/arm/boot/dts/am437x-sk-evm.dts
293 ++++ b/arch/arm/boot/dts/am437x-sk-evm.dts
294 +@@ -537,6 +537,8 @@
295 +
296 + touchscreen-size-x = <480>;
297 + touchscreen-size-y = <272>;
298 ++
299 ++ wakeup-source;
300 + };
301 +
302 + tlv320aic3106: tlv320aic3106@1b {
303 +diff --git a/arch/arm/boot/dts/armada-385-synology-ds116.dts b/arch/arm/boot/dts/armada-385-synology-ds116.dts
304 +index 6782ce481ac9..d8769956cbfc 100644
305 +--- a/arch/arm/boot/dts/armada-385-synology-ds116.dts
306 ++++ b/arch/arm/boot/dts/armada-385-synology-ds116.dts
307 +@@ -139,7 +139,7 @@
308 + 3700 5
309 + 3900 6
310 + 4000 7>;
311 +- cooling-cells = <2>;
312 ++ #cooling-cells = <2>;
313 + };
314 +
315 + gpio-leds {
316 +diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi b/arch/arm/boot/dts/bcm-cygnus.dtsi
317 +index 9fe4f5a6379e..2c4df2d2d4a6 100644
318 +--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
319 ++++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
320 +@@ -216,7 +216,7 @@
321 + reg = <0x18008000 0x100>;
322 + #address-cells = <1>;
323 + #size-cells = <0>;
324 +- interrupts = <GIC_SPI 85 IRQ_TYPE_NONE>;
325 ++ interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
326 + clock-frequency = <100000>;
327 + status = "disabled";
328 + };
329 +@@ -245,7 +245,7 @@
330 + reg = <0x1800b000 0x100>;
331 + #address-cells = <1>;
332 + #size-cells = <0>;
333 +- interrupts = <GIC_SPI 86 IRQ_TYPE_NONE>;
334 ++ interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
335 + clock-frequency = <100000>;
336 + status = "disabled";
337 + };
338 +@@ -256,7 +256,7 @@
339 +
340 + #interrupt-cells = <1>;
341 + interrupt-map-mask = <0 0 0 0>;
342 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_NONE>;
343 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>;
344 +
345 + linux,pci-domain = <0>;
346 +
347 +@@ -278,10 +278,10 @@
348 + compatible = "brcm,iproc-msi";
349 + msi-controller;
350 + interrupt-parent = <&gic>;
351 +- interrupts = <GIC_SPI 96 IRQ_TYPE_NONE>,
352 +- <GIC_SPI 97 IRQ_TYPE_NONE>,
353 +- <GIC_SPI 98 IRQ_TYPE_NONE>,
354 +- <GIC_SPI 99 IRQ_TYPE_NONE>;
355 ++ interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>,
356 ++ <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>,
357 ++ <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>,
358 ++ <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>;
359 + };
360 + };
361 +
362 +@@ -291,7 +291,7 @@
363 +
364 + #interrupt-cells = <1>;
365 + interrupt-map-mask = <0 0 0 0>;
366 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_NONE>;
367 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
368 +
369 + linux,pci-domain = <1>;
370 +
371 +@@ -313,10 +313,10 @@
372 + compatible = "brcm,iproc-msi";
373 + msi-controller;
374 + interrupt-parent = <&gic>;
375 +- interrupts = <GIC_SPI 102 IRQ_TYPE_NONE>,
376 +- <GIC_SPI 103 IRQ_TYPE_NONE>,
377 +- <GIC_SPI 104 IRQ_TYPE_NONE>,
378 +- <GIC_SPI 105 IRQ_TYPE_NONE>;
379 ++ interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>,
380 ++ <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
381 ++ <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>,
382 ++ <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>;
383 + };
384 + };
385 +
386 +diff --git a/arch/arm/boot/dts/bcm-hr2.dtsi b/arch/arm/boot/dts/bcm-hr2.dtsi
387 +index 3f9cedd8011f..3084a7c95733 100644
388 +--- a/arch/arm/boot/dts/bcm-hr2.dtsi
389 ++++ b/arch/arm/boot/dts/bcm-hr2.dtsi
390 +@@ -264,7 +264,7 @@
391 + reg = <0x38000 0x50>;
392 + #address-cells = <1>;
393 + #size-cells = <0>;
394 +- interrupts = <GIC_SPI 95 IRQ_TYPE_NONE>;
395 ++ interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>;
396 + clock-frequency = <100000>;
397 + };
398 +
399 +@@ -279,7 +279,7 @@
400 + reg = <0x3b000 0x50>;
401 + #address-cells = <1>;
402 + #size-cells = <0>;
403 +- interrupts = <GIC_SPI 96 IRQ_TYPE_NONE>;
404 ++ interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
405 + clock-frequency = <100000>;
406 + };
407 + };
408 +@@ -300,7 +300,7 @@
409 +
410 + #interrupt-cells = <1>;
411 + interrupt-map-mask = <0 0 0 0>;
412 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 186 IRQ_TYPE_NONE>;
413 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 186 IRQ_TYPE_LEVEL_HIGH>;
414 +
415 + linux,pci-domain = <0>;
416 +
417 +@@ -322,10 +322,10 @@
418 + compatible = "brcm,iproc-msi";
419 + msi-controller;
420 + interrupt-parent = <&gic>;
421 +- interrupts = <GIC_SPI 182 IRQ_TYPE_NONE>,
422 +- <GIC_SPI 183 IRQ_TYPE_NONE>,
423 +- <GIC_SPI 184 IRQ_TYPE_NONE>,
424 +- <GIC_SPI 185 IRQ_TYPE_NONE>;
425 ++ interrupts = <GIC_SPI 182 IRQ_TYPE_LEVEL_HIGH>,
426 ++ <GIC_SPI 183 IRQ_TYPE_LEVEL_HIGH>,
427 ++ <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>,
428 ++ <GIC_SPI 185 IRQ_TYPE_LEVEL_HIGH>;
429 + brcm,pcie-msi-inten;
430 + };
431 + };
432 +@@ -336,7 +336,7 @@
433 +
434 + #interrupt-cells = <1>;
435 + interrupt-map-mask = <0 0 0 0>;
436 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 192 IRQ_TYPE_NONE>;
437 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
438 +
439 + linux,pci-domain = <1>;
440 +
441 +@@ -358,10 +358,10 @@
442 + compatible = "brcm,iproc-msi";
443 + msi-controller;
444 + interrupt-parent = <&gic>;
445 +- interrupts = <GIC_SPI 188 IRQ_TYPE_NONE>,
446 +- <GIC_SPI 189 IRQ_TYPE_NONE>,
447 +- <GIC_SPI 190 IRQ_TYPE_NONE>,
448 +- <GIC_SPI 191 IRQ_TYPE_NONE>;
449 ++ interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>,
450 ++ <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>,
451 ++ <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>,
452 ++ <GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>;
453 + brcm,pcie-msi-inten;
454 + };
455 + };
456 +diff --git a/arch/arm/boot/dts/bcm-nsp.dtsi b/arch/arm/boot/dts/bcm-nsp.dtsi
457 +index dcc55aa84583..09ba85046322 100644
458 +--- a/arch/arm/boot/dts/bcm-nsp.dtsi
459 ++++ b/arch/arm/boot/dts/bcm-nsp.dtsi
460 +@@ -391,7 +391,7 @@
461 + reg = <0x38000 0x50>;
462 + #address-cells = <1>;
463 + #size-cells = <0>;
464 +- interrupts = <GIC_SPI 89 IRQ_TYPE_NONE>;
465 ++ interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
466 + clock-frequency = <100000>;
467 + dma-coherent;
468 + status = "disabled";
469 +@@ -496,7 +496,7 @@
470 +
471 + #interrupt-cells = <1>;
472 + interrupt-map-mask = <0 0 0 0>;
473 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 131 IRQ_TYPE_NONE>;
474 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
475 +
476 + linux,pci-domain = <0>;
477 +
478 +@@ -519,10 +519,10 @@
479 + compatible = "brcm,iproc-msi";
480 + msi-controller;
481 + interrupt-parent = <&gic>;
482 +- interrupts = <GIC_SPI 127 IRQ_TYPE_NONE>,
483 +- <GIC_SPI 128 IRQ_TYPE_NONE>,
484 +- <GIC_SPI 129 IRQ_TYPE_NONE>,
485 +- <GIC_SPI 130 IRQ_TYPE_NONE>;
486 ++ interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>,
487 ++ <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>,
488 ++ <GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH>,
489 ++ <GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>;
490 + brcm,pcie-msi-inten;
491 + };
492 + };
493 +@@ -533,7 +533,7 @@
494 +
495 + #interrupt-cells = <1>;
496 + interrupt-map-mask = <0 0 0 0>;
497 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 137 IRQ_TYPE_NONE>;
498 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>;
499 +
500 + linux,pci-domain = <1>;
501 +
502 +@@ -556,10 +556,10 @@
503 + compatible = "brcm,iproc-msi";
504 + msi-controller;
505 + interrupt-parent = <&gic>;
506 +- interrupts = <GIC_SPI 133 IRQ_TYPE_NONE>,
507 +- <GIC_SPI 134 IRQ_TYPE_NONE>,
508 +- <GIC_SPI 135 IRQ_TYPE_NONE>,
509 +- <GIC_SPI 136 IRQ_TYPE_NONE>;
510 ++ interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>,
511 ++ <GIC_SPI 134 IRQ_TYPE_LEVEL_HIGH>,
512 ++ <GIC_SPI 135 IRQ_TYPE_LEVEL_HIGH>,
513 ++ <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
514 + brcm,pcie-msi-inten;
515 + };
516 + };
517 +@@ -570,7 +570,7 @@
518 +
519 + #interrupt-cells = <1>;
520 + interrupt-map-mask = <0 0 0 0>;
521 +- interrupt-map = <0 0 0 0 &gic GIC_SPI 143 IRQ_TYPE_NONE>;
522 ++ interrupt-map = <0 0 0 0 &gic GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
523 +
524 + linux,pci-domain = <2>;
525 +
526 +@@ -593,10 +593,10 @@
527 + compatible = "brcm,iproc-msi";
528 + msi-controller;
529 + interrupt-parent = <&gic>;
530 +- interrupts = <GIC_SPI 139 IRQ_TYPE_NONE>,
531 +- <GIC_SPI 140 IRQ_TYPE_NONE>,
532 +- <GIC_SPI 141 IRQ_TYPE_NONE>,
533 +- <GIC_SPI 142 IRQ_TYPE_NONE>;
534 ++ interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>,
535 ++ <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>,
536 ++ <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>,
537 ++ <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>;
538 + brcm,pcie-msi-inten;
539 + };
540 + };
541 +diff --git a/arch/arm/boot/dts/bcm5301x.dtsi b/arch/arm/boot/dts/bcm5301x.dtsi
542 +index 9a076c409f4e..ef995e50ee12 100644
543 +--- a/arch/arm/boot/dts/bcm5301x.dtsi
544 ++++ b/arch/arm/boot/dts/bcm5301x.dtsi
545 +@@ -365,7 +365,7 @@
546 + i2c0: i2c@18009000 {
547 + compatible = "brcm,iproc-i2c";
548 + reg = <0x18009000 0x50>;
549 +- interrupts = <GIC_SPI 121 IRQ_TYPE_NONE>;
550 ++ interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
551 + #address-cells = <1>;
552 + #size-cells = <0>;
553 + clock-frequency = <100000>;
554 +diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
555 +index 12010002dbdb..a8500f062706 100644
556 +--- a/arch/arm/boot/dts/da850.dtsi
557 ++++ b/arch/arm/boot/dts/da850.dtsi
558 +@@ -539,11 +539,7 @@
559 + gpio-controller;
560 + #gpio-cells = <2>;
561 + reg = <0x226000 0x1000>;
562 +- interrupts = <42 IRQ_TYPE_EDGE_BOTH
563 +- 43 IRQ_TYPE_EDGE_BOTH 44 IRQ_TYPE_EDGE_BOTH
564 +- 45 IRQ_TYPE_EDGE_BOTH 46 IRQ_TYPE_EDGE_BOTH
565 +- 47 IRQ_TYPE_EDGE_BOTH 48 IRQ_TYPE_EDGE_BOTH
566 +- 49 IRQ_TYPE_EDGE_BOTH 50 IRQ_TYPE_EDGE_BOTH>;
567 ++ interrupts = <42 43 44 45 46 47 48 49 50>;
568 + ti,ngpio = <144>;
569 + ti,davinci-gpio-unbanked = <0>;
570 + status = "disabled";
571 +diff --git a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
572 +index 911f7f0e3cea..e000e27f595b 100644
573 +--- a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
574 ++++ b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
575 +@@ -672,7 +672,7 @@
576 + dsa,member = <0 0>;
577 + eeprom-length = <512>;
578 + interrupt-parent = <&gpio6>;
579 +- interrupts = <3 IRQ_TYPE_EDGE_FALLING>;
580 ++ interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
581 + interrupt-controller;
582 + #interrupt-cells = <2>;
583 +
584 +diff --git a/arch/arm/boot/dts/omap4-droid4-xt894.dts b/arch/arm/boot/dts/omap4-droid4-xt894.dts
585 +index bdf73cbcec3a..e7c3c563ff8f 100644
586 +--- a/arch/arm/boot/dts/omap4-droid4-xt894.dts
587 ++++ b/arch/arm/boot/dts/omap4-droid4-xt894.dts
588 +@@ -159,13 +159,7 @@
589 +
590 + dais = <&mcbsp2_port>, <&mcbsp3_port>;
591 + };
592 +-};
593 +-
594 +-&dss {
595 +- status = "okay";
596 +-};
597 +
598 +-&gpio6 {
599 + pwm8: dmtimer-pwm-8 {
600 + pinctrl-names = "default";
601 + pinctrl-0 = <&vibrator_direction_pin>;
602 +@@ -192,7 +186,10 @@
603 + pwm-names = "enable", "direction";
604 + direction-duty-cycle-ns = <10000000>;
605 + };
606 ++};
607 +
608 ++&dss {
609 ++ status = "okay";
610 + };
611 +
612 + &dsi1 {
613 +diff --git a/arch/arm/configs/imx_v4_v5_defconfig b/arch/arm/configs/imx_v4_v5_defconfig
614 +index 054591dc9a00..4cd2f4a2bff4 100644
615 +--- a/arch/arm/configs/imx_v4_v5_defconfig
616 ++++ b/arch/arm/configs/imx_v4_v5_defconfig
617 +@@ -141,9 +141,11 @@ CONFIG_USB_STORAGE=y
618 + CONFIG_USB_CHIPIDEA=y
619 + CONFIG_USB_CHIPIDEA_UDC=y
620 + CONFIG_USB_CHIPIDEA_HOST=y
621 ++CONFIG_USB_CHIPIDEA_ULPI=y
622 + CONFIG_NOP_USB_XCEIV=y
623 + CONFIG_USB_GADGET=y
624 + CONFIG_USB_ETH=m
625 ++CONFIG_USB_ULPI_BUS=y
626 + CONFIG_MMC=y
627 + CONFIG_MMC_SDHCI=y
628 + CONFIG_MMC_SDHCI_PLTFM=y
629 +diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
630 +index 3a308437b088..19c924de353b 100644
631 +--- a/arch/arm/configs/imx_v6_v7_defconfig
632 ++++ b/arch/arm/configs/imx_v6_v7_defconfig
633 +@@ -294,6 +294,7 @@ CONFIG_USB_STORAGE=y
634 + CONFIG_USB_CHIPIDEA=y
635 + CONFIG_USB_CHIPIDEA_UDC=y
636 + CONFIG_USB_CHIPIDEA_HOST=y
637 ++CONFIG_USB_CHIPIDEA_ULPI=y
638 + CONFIG_USB_SERIAL=m
639 + CONFIG_USB_SERIAL_GENERIC=y
640 + CONFIG_USB_SERIAL_FTDI_SIO=m
641 +@@ -330,6 +331,7 @@ CONFIG_USB_GADGETFS=m
642 + CONFIG_USB_FUNCTIONFS=m
643 + CONFIG_USB_MASS_STORAGE=m
644 + CONFIG_USB_G_SERIAL=m
645 ++CONFIG_USB_ULPI_BUS=y
646 + CONFIG_MMC=y
647 + CONFIG_MMC_SDHCI=y
648 + CONFIG_MMC_SDHCI_PLTFM=y
649 +diff --git a/arch/arm/crypto/speck-neon-core.S b/arch/arm/crypto/speck-neon-core.S
650 +index 3c1e203e53b9..57caa742016e 100644
651 +--- a/arch/arm/crypto/speck-neon-core.S
652 ++++ b/arch/arm/crypto/speck-neon-core.S
653 +@@ -272,9 +272,11 @@
654 + * Allocate stack space to store 128 bytes worth of tweaks. For
655 + * performance, this space is aligned to a 16-byte boundary so that we
656 + * can use the load/store instructions that declare 16-byte alignment.
657 ++ * For Thumb2 compatibility, don't do the 'bic' directly on 'sp'.
658 + */
659 +- sub sp, #128
660 +- bic sp, #0xf
661 ++ sub r12, sp, #128
662 ++ bic r12, #0xf
663 ++ mov sp, r12
664 +
665 + .if \n == 64
666 + // Load first tweak
667 +diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
668 +index 158ed9a1483f..826bd634d098 100644
669 +--- a/arch/arm/mach-davinci/board-da850-evm.c
670 ++++ b/arch/arm/mach-davinci/board-da850-evm.c
671 +@@ -773,7 +773,7 @@ static struct gpiod_lookup_table mmc_gpios_table = {
672 + GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_CD_PIN, "cd",
673 + GPIO_ACTIVE_LOW),
674 + GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_WP_PIN, "wp",
675 +- GPIO_ACTIVE_LOW),
676 ++ GPIO_ACTIVE_HIGH),
677 + },
678 + };
679 +
680 +diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
681 +index 69df3620eca5..1c73694c871a 100644
682 +--- a/arch/arm/mach-omap2/omap-smp.c
683 ++++ b/arch/arm/mach-omap2/omap-smp.c
684 +@@ -109,6 +109,45 @@ void omap5_erratum_workaround_801819(void)
685 + static inline void omap5_erratum_workaround_801819(void) { }
686 + #endif
687 +
688 ++#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
689 ++/*
690 ++ * Configure ACR and enable ACTLR[0] (Enable invalidates of BTB with
691 ++ * ICIALLU) to activate the workaround for secondary Core.
692 ++ * NOTE: it is assumed that the primary core's configuration is done
693 ++ * by the boot loader (kernel will detect a misconfiguration and complain
694 ++ * if this is not done).
695 ++ *
696 ++ * In General Purpose(GP) devices, ACR bit settings can only be done
697 ++ * by ROM code in "secure world" using the smc call and there is no
698 ++ * option to update the "firmware" on such devices. This also works for
699 ++ * High security(HS) devices, as a backup option in case the
700 ++ * "update" is not done in the "security firmware".
701 ++ */
702 ++static void omap5_secondary_harden_predictor(void)
703 ++{
704 ++ u32 acr, acr_mask;
705 ++
706 ++ asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
707 ++
708 ++ /*
709 ++ * ACTLR[0] (Enable invalidates of BTB with ICIALLU)
710 ++ */
711 ++ acr_mask = BIT(0);
712 ++
713 ++ /* Do we already have it done.. if yes, skip expensive smc */
714 ++ if ((acr & acr_mask) == acr_mask)
715 ++ return;
716 ++
717 ++ acr |= acr_mask;
718 ++ omap_smc1(OMAP5_DRA7_MON_SET_ACR_INDEX, acr);
719 ++
720 ++ pr_debug("%s: ARM ACR setup for CVE_2017_5715 applied on CPU%d\n",
721 ++ __func__, smp_processor_id());
722 ++}
723 ++#else
724 ++static inline void omap5_secondary_harden_predictor(void) { }
725 ++#endif
726 ++
727 + static void omap4_secondary_init(unsigned int cpu)
728 + {
729 + /*
730 +@@ -131,6 +170,8 @@ static void omap4_secondary_init(unsigned int cpu)
731 + set_cntfreq();
732 + /* Configure ACR to disable streaming WA for 801819 */
733 + omap5_erratum_workaround_801819();
734 ++ /* Enable ACR to allow for ICUALLU workaround */
735 ++ omap5_secondary_harden_predictor();
736 + }
737 +
738 + /*
739 +diff --git a/arch/arm/mach-pxa/irq.c b/arch/arm/mach-pxa/irq.c
740 +index 9c10248fadcc..4e8c2116808e 100644
741 +--- a/arch/arm/mach-pxa/irq.c
742 ++++ b/arch/arm/mach-pxa/irq.c
743 +@@ -185,7 +185,7 @@ static int pxa_irq_suspend(void)
744 + {
745 + int i;
746 +
747 +- for (i = 0; i < pxa_internal_irq_nr / 32; i++) {
748 ++ for (i = 0; i < DIV_ROUND_UP(pxa_internal_irq_nr, 32); i++) {
749 + void __iomem *base = irq_base(i);
750 +
751 + saved_icmr[i] = __raw_readl(base + ICMR);
752 +@@ -204,7 +204,7 @@ static void pxa_irq_resume(void)
753 + {
754 + int i;
755 +
756 +- for (i = 0; i < pxa_internal_irq_nr / 32; i++) {
757 ++ for (i = 0; i < DIV_ROUND_UP(pxa_internal_irq_nr, 32); i++) {
758 + void __iomem *base = irq_base(i);
759 +
760 + __raw_writel(saved_icmr[i], base + ICMR);
761 +diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
762 +index c186474422f3..0cc8e04295a4 100644
763 +--- a/arch/arm/mm/init.c
764 ++++ b/arch/arm/mm/init.c
765 +@@ -736,20 +736,29 @@ static int __mark_rodata_ro(void *unused)
766 + return 0;
767 + }
768 +
769 ++static int kernel_set_to_readonly __read_mostly;
770 ++
771 + void mark_rodata_ro(void)
772 + {
773 ++ kernel_set_to_readonly = 1;
774 + stop_machine(__mark_rodata_ro, NULL, NULL);
775 + debug_checkwx();
776 + }
777 +
778 + void set_kernel_text_rw(void)
779 + {
780 ++ if (!kernel_set_to_readonly)
781 ++ return;
782 ++
783 + set_section_perms(ro_perms, ARRAY_SIZE(ro_perms), false,
784 + current->active_mm);
785 + }
786 +
787 + void set_kernel_text_ro(void)
788 + {
789 ++ if (!kernel_set_to_readonly)
790 ++ return;
791 ++
792 + set_section_perms(ro_perms, ARRAY_SIZE(ro_perms), true,
793 + current->active_mm);
794 + }
795 +diff --git a/arch/arm64/boot/dts/amlogic/meson-axg-s400.dts b/arch/arm64/boot/dts/amlogic/meson-axg-s400.dts
796 +index 57eedced5a51..f7300cb6970f 100644
797 +--- a/arch/arm64/boot/dts/amlogic/meson-axg-s400.dts
798 ++++ b/arch/arm64/boot/dts/amlogic/meson-axg-s400.dts
799 +@@ -19,9 +19,22 @@
800 +
801 + &ethmac {
802 + status = "okay";
803 +- phy-mode = "rgmii";
804 + pinctrl-0 = <&eth_rgmii_y_pins>;
805 + pinctrl-names = "default";
806 ++ phy-handle = <&eth_phy0>;
807 ++ phy-mode = "rgmii";
808 ++
809 ++ mdio {
810 ++ compatible = "snps,dwmac-mdio";
811 ++ #address-cells = <1>;
812 ++ #size-cells = <0>;
813 ++
814 ++ eth_phy0: ethernet-phy@0 {
815 ++ /* Realtek RTL8211F (0x001cc916) */
816 ++ reg = <0>;
817 ++ eee-broken-1000t;
818 ++ };
819 ++ };
820 + };
821 +
822 + &uart_A {
823 +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
824 +index eb327664a4d8..6aaafff674f9 100644
825 +--- a/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
826 ++++ b/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
827 +@@ -6,7 +6,7 @@
828 +
829 + &apb {
830 + mali: gpu@c0000 {
831 +- compatible = "amlogic,meson-gxbb-mali", "arm,mali-450";
832 ++ compatible = "amlogic,meson-gxl-mali", "arm,mali-450";
833 + reg = <0x0 0xc0000 0x0 0x40000>;
834 + interrupts = <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
835 + <GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>,
836 +diff --git a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
837 +index 4a2a6af8e752..4057197048dc 100644
838 +--- a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
839 ++++ b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
840 +@@ -118,7 +118,7 @@
841 +
842 + #interrupt-cells = <1>;
843 + interrupt-map-mask = <0 0 0 0>;
844 +- interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 281 IRQ_TYPE_NONE>;
845 ++ interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 281 IRQ_TYPE_LEVEL_HIGH>;
846 +
847 + linux,pci-domain = <0>;
848 +
849 +@@ -149,7 +149,7 @@
850 +
851 + #interrupt-cells = <1>;
852 + interrupt-map-mask = <0 0 0 0>;
853 +- interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 305 IRQ_TYPE_NONE>;
854 ++ interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 305 IRQ_TYPE_LEVEL_HIGH>;
855 +
856 + linux,pci-domain = <4>;
857 +
858 +@@ -566,7 +566,7 @@
859 + reg = <0x66080000 0x100>;
860 + #address-cells = <1>;
861 + #size-cells = <0>;
862 +- interrupts = <GIC_SPI 394 IRQ_TYPE_NONE>;
863 ++ interrupts = <GIC_SPI 394 IRQ_TYPE_LEVEL_HIGH>;
864 + clock-frequency = <100000>;
865 + status = "disabled";
866 + };
867 +@@ -594,7 +594,7 @@
868 + reg = <0x660b0000 0x100>;
869 + #address-cells = <1>;
870 + #size-cells = <0>;
871 +- interrupts = <GIC_SPI 395 IRQ_TYPE_NONE>;
872 ++ interrupts = <GIC_SPI 395 IRQ_TYPE_LEVEL_HIGH>;
873 + clock-frequency = <100000>;
874 + status = "disabled";
875 + };
876 +diff --git a/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts b/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
877 +index eb6f08cdbd79..77efa28c4dd5 100644
878 +--- a/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
879 ++++ b/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
880 +@@ -43,6 +43,10 @@
881 + enet-phy-lane-swap;
882 + };
883 +
884 ++&sdio0 {
885 ++ mmc-ddr-1_8v;
886 ++};
887 ++
888 + &uart2 {
889 + status = "okay";
890 + };
891 +diff --git a/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts b/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
892 +index 5084b037320f..55ba495ef56e 100644
893 +--- a/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
894 ++++ b/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
895 +@@ -42,3 +42,7 @@
896 + &gphy0 {
897 + enet-phy-lane-swap;
898 + };
899 ++
900 ++&sdio0 {
901 ++ mmc-ddr-1_8v;
902 ++};
903 +diff --git a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
904 +index 99aaff0b6d72..b203152ad67c 100644
905 +--- a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
906 ++++ b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
907 +@@ -409,7 +409,7 @@
908 + reg = <0x000b0000 0x100>;
909 + #address-cells = <1>;
910 + #size-cells = <0>;
911 +- interrupts = <GIC_SPI 177 IRQ_TYPE_NONE>;
912 ++ interrupts = <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>;
913 + clock-frequency = <100000>;
914 + status = "disabled";
915 + };
916 +@@ -453,7 +453,7 @@
917 + reg = <0x000e0000 0x100>;
918 + #address-cells = <1>;
919 + #size-cells = <0>;
920 +- interrupts = <GIC_SPI 178 IRQ_TYPE_NONE>;
921 ++ interrupts = <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>;
922 + clock-frequency = <100000>;
923 + status = "disabled";
924 + };
925 +diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
926 +index 66b318e1de80..aef814b2dc9e 100644
927 +--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
928 ++++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
929 +@@ -1191,14 +1191,14 @@
930 +
931 + port@0 {
932 + reg = <0>;
933 +- etf_out: endpoint {
934 ++ etf_in: endpoint {
935 + slave-mode;
936 + remote-endpoint = <&funnel0_out>;
937 + };
938 + };
939 + port@1 {
940 + reg = <0>;
941 +- etf_in: endpoint {
942 ++ etf_out: endpoint {
943 + remote-endpoint = <&replicator_in>;
944 + };
945 + };
946 +diff --git a/arch/arm64/boot/dts/socionext/uniphier-ld11-global.dts b/arch/arm64/boot/dts/socionext/uniphier-ld11-global.dts
947 +index 9b4dc41703e3..ae3b5adf32df 100644
948 +--- a/arch/arm64/boot/dts/socionext/uniphier-ld11-global.dts
949 ++++ b/arch/arm64/boot/dts/socionext/uniphier-ld11-global.dts
950 +@@ -54,7 +54,7 @@
951 + sound {
952 + compatible = "audio-graph-card";
953 + label = "UniPhier LD11";
954 +- widgets = "Headphone", "Headphone Jack";
955 ++ widgets = "Headphone", "Headphones";
956 + dais = <&i2s_port2
957 + &i2s_port3
958 + &i2s_port4
959 +diff --git a/arch/arm64/boot/dts/socionext/uniphier-ld20-global.dts b/arch/arm64/boot/dts/socionext/uniphier-ld20-global.dts
960 +index fe6608ea3277..7919233c9ce2 100644
961 +--- a/arch/arm64/boot/dts/socionext/uniphier-ld20-global.dts
962 ++++ b/arch/arm64/boot/dts/socionext/uniphier-ld20-global.dts
963 +@@ -54,7 +54,7 @@
964 + sound {
965 + compatible = "audio-graph-card";
966 + label = "UniPhier LD20";
967 +- widgets = "Headphone", "Headphone Jack";
968 ++ widgets = "Headphone", "Headphones";
969 + dais = <&i2s_port2
970 + &i2s_port3
971 + &i2s_port4
972 +diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
973 +index a91933b1e2e6..4b650ec1d7dd 100644
974 +--- a/arch/arm64/include/asm/alternative.h
975 ++++ b/arch/arm64/include/asm/alternative.h
976 +@@ -28,7 +28,12 @@ typedef void (*alternative_cb_t)(struct alt_instr *alt,
977 + __le32 *origptr, __le32 *updptr, int nr_inst);
978 +
979 + void __init apply_alternatives_all(void);
980 +-void apply_alternatives(void *start, size_t length);
981 ++
982 ++#ifdef CONFIG_MODULES
983 ++void apply_alternatives_module(void *start, size_t length);
984 ++#else
985 ++static inline void apply_alternatives_module(void *start, size_t length) { }
986 ++#endif
987 +
988 + #define ALTINSTR_ENTRY(feature,cb) \
989 + " .word 661b - .\n" /* label */ \
990 +diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c
991 +index 5c4bce4ac381..36fb069fd049 100644
992 +--- a/arch/arm64/kernel/alternative.c
993 ++++ b/arch/arm64/kernel/alternative.c
994 +@@ -122,7 +122,30 @@ static void patch_alternative(struct alt_instr *alt,
995 + }
996 + }
997 +
998 +-static void __apply_alternatives(void *alt_region, bool use_linear_alias)
999 ++/*
1000 ++ * We provide our own, private D-cache cleaning function so that we don't
1001 ++ * accidentally call into the cache.S code, which is patched by us at
1002 ++ * runtime.
1003 ++ */
1004 ++static void clean_dcache_range_nopatch(u64 start, u64 end)
1005 ++{
1006 ++ u64 cur, d_size, ctr_el0;
1007 ++
1008 ++ ctr_el0 = read_sanitised_ftr_reg(SYS_CTR_EL0);
1009 ++ d_size = 4 << cpuid_feature_extract_unsigned_field(ctr_el0,
1010 ++ CTR_DMINLINE_SHIFT);
1011 ++ cur = start & ~(d_size - 1);
1012 ++ do {
1013 ++ /*
1014 ++ * We must clean+invalidate to the PoC in order to avoid
1015 ++ * Cortex-A53 errata 826319, 827319, 824069 and 819472
1016 ++ * (this corresponds to ARM64_WORKAROUND_CLEAN_CACHE)
1017 ++ */
1018 ++ asm volatile("dc civac, %0" : : "r" (cur) : "memory");
1019 ++ } while (cur += d_size, cur < end);
1020 ++}
1021 ++
1022 ++static void __apply_alternatives(void *alt_region, bool is_module)
1023 + {
1024 + struct alt_instr *alt;
1025 + struct alt_region *region = alt_region;
1026 +@@ -145,7 +168,7 @@ static void __apply_alternatives(void *alt_region, bool use_linear_alias)
1027 + pr_info_once("patching kernel code\n");
1028 +
1029 + origptr = ALT_ORIG_PTR(alt);
1030 +- updptr = use_linear_alias ? lm_alias(origptr) : origptr;
1031 ++ updptr = is_module ? origptr : lm_alias(origptr);
1032 + nr_inst = alt->orig_len / AARCH64_INSN_SIZE;
1033 +
1034 + if (alt->cpufeature < ARM64_CB_PATCH)
1035 +@@ -155,8 +178,20 @@ static void __apply_alternatives(void *alt_region, bool use_linear_alias)
1036 +
1037 + alt_cb(alt, origptr, updptr, nr_inst);
1038 +
1039 +- flush_icache_range((uintptr_t)origptr,
1040 +- (uintptr_t)(origptr + nr_inst));
1041 ++ if (!is_module) {
1042 ++ clean_dcache_range_nopatch((u64)origptr,
1043 ++ (u64)(origptr + nr_inst));
1044 ++ }
1045 ++ }
1046 ++
1047 ++ /*
1048 ++ * The core module code takes care of cache maintenance in
1049 ++ * flush_module_icache().
1050 ++ */
1051 ++ if (!is_module) {
1052 ++ dsb(ish);
1053 ++ __flush_icache_all();
1054 ++ isb();
1055 + }
1056 + }
1057 +
1058 +@@ -178,7 +213,7 @@ static int __apply_alternatives_multi_stop(void *unused)
1059 + isb();
1060 + } else {
1061 + BUG_ON(alternatives_applied);
1062 +- __apply_alternatives(&region, true);
1063 ++ __apply_alternatives(&region, false);
1064 + /* Barriers provided by the cache flushing */
1065 + WRITE_ONCE(alternatives_applied, 1);
1066 + }
1067 +@@ -192,12 +227,14 @@ void __init apply_alternatives_all(void)
1068 + stop_machine(__apply_alternatives_multi_stop, NULL, cpu_online_mask);
1069 + }
1070 +
1071 +-void apply_alternatives(void *start, size_t length)
1072 ++#ifdef CONFIG_MODULES
1073 ++void apply_alternatives_module(void *start, size_t length)
1074 + {
1075 + struct alt_region region = {
1076 + .begin = start,
1077 + .end = start + length,
1078 + };
1079 +
1080 +- __apply_alternatives(&region, false);
1081 ++ __apply_alternatives(&region, true);
1082 + }
1083 ++#endif
1084 +diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c
1085 +index 155fd91e78f4..f0f27aeefb73 100644
1086 +--- a/arch/arm64/kernel/module.c
1087 ++++ b/arch/arm64/kernel/module.c
1088 +@@ -448,9 +448,8 @@ int module_finalize(const Elf_Ehdr *hdr,
1089 + const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
1090 +
1091 + for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) {
1092 +- if (strcmp(".altinstructions", secstrs + s->sh_name) == 0) {
1093 +- apply_alternatives((void *)s->sh_addr, s->sh_size);
1094 +- }
1095 ++ if (strcmp(".altinstructions", secstrs + s->sh_name) == 0)
1096 ++ apply_alternatives_module((void *)s->sh_addr, s->sh_size);
1097 + #ifdef CONFIG_ARM64_MODULE_PLTS
1098 + if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE) &&
1099 + !strcmp(".text.ftrace_trampoline", secstrs + s->sh_name))
1100 +diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
1101 +index f3e2e3aec0b0..2faa9863d2e5 100644
1102 +--- a/arch/arm64/kernel/smp.c
1103 ++++ b/arch/arm64/kernel/smp.c
1104 +@@ -179,7 +179,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
1105 + * This is the secondary CPU boot entry. We're using this CPUs
1106 + * idle thread stack, but a set of temporary page tables.
1107 + */
1108 +-asmlinkage void secondary_start_kernel(void)
1109 ++asmlinkage notrace void secondary_start_kernel(void)
1110 + {
1111 + u64 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK;
1112 + struct mm_struct *mm = &init_mm;
1113 +diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
1114 +index a96ec0181818..4ed7ffa26d27 100644
1115 +--- a/arch/arm64/mm/dma-mapping.c
1116 ++++ b/arch/arm64/mm/dma-mapping.c
1117 +@@ -588,13 +588,14 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size,
1118 + size >> PAGE_SHIFT);
1119 + return NULL;
1120 + }
1121 +- if (!coherent)
1122 +- __dma_flush_area(page_to_virt(page), iosize);
1123 +-
1124 + addr = dma_common_contiguous_remap(page, size, VM_USERMAP,
1125 + prot,
1126 + __builtin_return_address(0));
1127 +- if (!addr) {
1128 ++ if (addr) {
1129 ++ memset(addr, 0, size);
1130 ++ if (!coherent)
1131 ++ __dma_flush_area(page_to_virt(page), iosize);
1132 ++ } else {
1133 + iommu_dma_unmap_page(dev, *handle, iosize, 0, attrs);
1134 + dma_release_from_contiguous(dev, page,
1135 + size >> PAGE_SHIFT);
1136 +diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
1137 +index 8fb280e33114..b483152875b5 100644
1138 +--- a/arch/ia64/kernel/perfmon.c
1139 ++++ b/arch/ia64/kernel/perfmon.c
1140 +@@ -2278,17 +2278,15 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
1141 + DPRINT(("smpl_buf @%p\n", smpl_buf));
1142 +
1143 + /* allocate vma */
1144 +- vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
1145 ++ vma = vm_area_alloc(mm);
1146 + if (!vma) {
1147 + DPRINT(("Cannot allocate vma\n"));
1148 + goto error_kmem;
1149 + }
1150 +- INIT_LIST_HEAD(&vma->anon_vma_chain);
1151 +
1152 + /*
1153 + * partially initialize the vma for the sampling buffer
1154 + */
1155 +- vma->vm_mm = mm;
1156 + vma->vm_file = get_file(filp);
1157 + vma->vm_flags = VM_READ|VM_MAYREAD|VM_DONTEXPAND|VM_DONTDUMP;
1158 + vma->vm_page_prot = PAGE_READONLY; /* XXX may need to change */
1159 +@@ -2346,7 +2344,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
1160 + return 0;
1161 +
1162 + error:
1163 +- kmem_cache_free(vm_area_cachep, vma);
1164 ++ vm_area_free(vma);
1165 + error_kmem:
1166 + pfm_rvfree(smpl_buf, size);
1167 +
1168 +diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
1169 +index 18278b448530..bdb14a369137 100644
1170 +--- a/arch/ia64/mm/init.c
1171 ++++ b/arch/ia64/mm/init.c
1172 +@@ -114,10 +114,8 @@ ia64_init_addr_space (void)
1173 + * the problem. When the process attempts to write to the register backing store
1174 + * for the first time, it will get a SEGFAULT in this case.
1175 + */
1176 +- vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
1177 ++ vma = vm_area_alloc(current->mm);
1178 + if (vma) {
1179 +- INIT_LIST_HEAD(&vma->anon_vma_chain);
1180 +- vma->vm_mm = current->mm;
1181 + vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
1182 + vma->vm_end = vma->vm_start + PAGE_SIZE;
1183 + vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
1184 +@@ -125,7 +123,7 @@ ia64_init_addr_space (void)
1185 + down_write(&current->mm->mmap_sem);
1186 + if (insert_vm_struct(current->mm, vma)) {
1187 + up_write(&current->mm->mmap_sem);
1188 +- kmem_cache_free(vm_area_cachep, vma);
1189 ++ vm_area_free(vma);
1190 + return;
1191 + }
1192 + up_write(&current->mm->mmap_sem);
1193 +@@ -133,10 +131,8 @@ ia64_init_addr_space (void)
1194 +
1195 + /* map NaT-page at address zero to speed up speculative dereferencing of NULL: */
1196 + if (!(current->personality & MMAP_PAGE_ZERO)) {
1197 +- vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
1198 ++ vma = vm_area_alloc(current->mm);
1199 + if (vma) {
1200 +- INIT_LIST_HEAD(&vma->anon_vma_chain);
1201 +- vma->vm_mm = current->mm;
1202 + vma->vm_end = PAGE_SIZE;
1203 + vma->vm_page_prot = __pgprot(pgprot_val(PAGE_READONLY) | _PAGE_MA_NAT);
1204 + vma->vm_flags = VM_READ | VM_MAYREAD | VM_IO |
1205 +@@ -144,7 +140,7 @@ ia64_init_addr_space (void)
1206 + down_write(&current->mm->mmap_sem);
1207 + if (insert_vm_struct(current->mm, vma)) {
1208 + up_write(&current->mm->mmap_sem);
1209 +- kmem_cache_free(vm_area_cachep, vma);
1210 ++ vm_area_free(vma);
1211 + return;
1212 + }
1213 + up_write(&current->mm->mmap_sem);
1214 +diff --git a/arch/m68k/include/asm/mcf_pgalloc.h b/arch/m68k/include/asm/mcf_pgalloc.h
1215 +index 8b707c249026..12fe700632f4 100644
1216 +--- a/arch/m68k/include/asm/mcf_pgalloc.h
1217 ++++ b/arch/m68k/include/asm/mcf_pgalloc.h
1218 +@@ -44,6 +44,7 @@ extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address)
1219 + static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page,
1220 + unsigned long address)
1221 + {
1222 ++ pgtable_page_dtor(page);
1223 + __free_page(page);
1224 + }
1225 +
1226 +@@ -74,8 +75,9 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm,
1227 + return page;
1228 + }
1229 +
1230 +-extern inline void pte_free(struct mm_struct *mm, struct page *page)
1231 ++static inline void pte_free(struct mm_struct *mm, struct page *page)
1232 + {
1233 ++ pgtable_page_dtor(page);
1234 + __free_page(page);
1235 + }
1236 +
1237 +diff --git a/arch/nds32/kernel/setup.c b/arch/nds32/kernel/setup.c
1238 +index 2f5b2ccebe47..63a1a5ef5219 100644
1239 +--- a/arch/nds32/kernel/setup.c
1240 ++++ b/arch/nds32/kernel/setup.c
1241 +@@ -278,7 +278,8 @@ static void __init setup_memory(void)
1242 +
1243 + void __init setup_arch(char **cmdline_p)
1244 + {
1245 +- early_init_devtree( __dtb_start);
1246 ++ early_init_devtree(__atags_pointer ? \
1247 ++ phys_to_virt(__atags_pointer) : __dtb_start);
1248 +
1249 + setup_cpuinfo();
1250 +
1251 +diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
1252 +index 690d55272ba6..0c826ad6e994 100644
1253 +--- a/arch/openrisc/kernel/entry.S
1254 ++++ b/arch/openrisc/kernel/entry.S
1255 +@@ -277,12 +277,6 @@ EXCEPTION_ENTRY(_data_page_fault_handler)
1256 + l.addi r3,r1,0 // pt_regs
1257 + /* r4 set be EXCEPTION_HANDLE */ // effective address of fault
1258 +
1259 +- /*
1260 +- * __PHX__: TODO
1261 +- *
1262 +- * all this can be written much simpler. look at
1263 +- * DTLB miss handler in the CONFIG_GUARD_PROTECTED_CORE part
1264 +- */
1265 + #ifdef CONFIG_OPENRISC_NO_SPR_SR_DSX
1266 + l.lwz r6,PT_PC(r3) // address of an offending insn
1267 + l.lwz r6,0(r6) // instruction that caused pf
1268 +@@ -314,7 +308,7 @@ EXCEPTION_ENTRY(_data_page_fault_handler)
1269 +
1270 + #else
1271 +
1272 +- l.lwz r6,PT_SR(r3) // SR
1273 ++ l.mfspr r6,r0,SPR_SR // SR
1274 + l.andi r6,r6,SPR_SR_DSX // check for delay slot exception
1275 + l.sfne r6,r0 // exception happened in delay slot
1276 + l.bnf 7f
1277 +diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S
1278 +index fb02b2a1d6f2..9fc6b60140f0 100644
1279 +--- a/arch/openrisc/kernel/head.S
1280 ++++ b/arch/openrisc/kernel/head.S
1281 +@@ -210,8 +210,7 @@
1282 + * r4 - EEAR exception EA
1283 + * r10 - current pointing to current_thread_info struct
1284 + * r12 - syscall 0, since we didn't come from syscall
1285 +- * r13 - temp it actually contains new SR, not needed anymore
1286 +- * r31 - handler address of the handler we'll jump to
1287 ++ * r30 - handler address of the handler we'll jump to
1288 + *
1289 + * handler has to save remaining registers to the exception
1290 + * ksp frame *before* tainting them!
1291 +@@ -244,6 +243,7 @@
1292 + /* r1 is KSP, r30 is __pa(KSP) */ ;\
1293 + tophys (r30,r1) ;\
1294 + l.sw PT_GPR12(r30),r12 ;\
1295 ++ /* r4 use for tmp before EA */ ;\
1296 + l.mfspr r12,r0,SPR_EPCR_BASE ;\
1297 + l.sw PT_PC(r30),r12 ;\
1298 + l.mfspr r12,r0,SPR_ESR_BASE ;\
1299 +@@ -263,7 +263,10 @@
1300 + /* r12 == 1 if we come from syscall */ ;\
1301 + CLEAR_GPR(r12) ;\
1302 + /* ----- turn on MMU ----- */ ;\
1303 +- l.ori r30,r0,(EXCEPTION_SR) ;\
1304 ++ /* Carry DSX into exception SR */ ;\
1305 ++ l.mfspr r30,r0,SPR_SR ;\
1306 ++ l.andi r30,r30,SPR_SR_DSX ;\
1307 ++ l.ori r30,r30,(EXCEPTION_SR) ;\
1308 + l.mtspr r0,r30,SPR_ESR_BASE ;\
1309 + /* r30: EA address of handler */ ;\
1310 + LOAD_SYMBOL_2_GPR(r30,handler) ;\
1311 +diff --git a/arch/openrisc/kernel/traps.c b/arch/openrisc/kernel/traps.c
1312 +index 113c175fe469..f35b485555db 100644
1313 +--- a/arch/openrisc/kernel/traps.c
1314 ++++ b/arch/openrisc/kernel/traps.c
1315 +@@ -317,7 +317,7 @@ static inline int in_delay_slot(struct pt_regs *regs)
1316 + return 0;
1317 + }
1318 + #else
1319 +- return regs->sr & SPR_SR_DSX;
1320 ++ return mfspr(SPR_SR) & SPR_SR_DSX;
1321 + #endif
1322 + }
1323 +
1324 +diff --git a/arch/parisc/include/asm/spinlock.h b/arch/parisc/include/asm/spinlock.h
1325 +index 6f84b6acc86e..8a63515f03bf 100644
1326 +--- a/arch/parisc/include/asm/spinlock.h
1327 ++++ b/arch/parisc/include/asm/spinlock.h
1328 +@@ -20,7 +20,6 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *x,
1329 + {
1330 + volatile unsigned int *a;
1331 +
1332 +- mb();
1333 + a = __ldcw_align(x);
1334 + while (__ldcw(a) == 0)
1335 + while (*a == 0)
1336 +@@ -30,17 +29,16 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *x,
1337 + local_irq_disable();
1338 + } else
1339 + cpu_relax();
1340 +- mb();
1341 + }
1342 + #define arch_spin_lock_flags arch_spin_lock_flags
1343 +
1344 + static inline void arch_spin_unlock(arch_spinlock_t *x)
1345 + {
1346 + volatile unsigned int *a;
1347 +- mb();
1348 ++
1349 + a = __ldcw_align(x);
1350 +- *a = 1;
1351 + mb();
1352 ++ *a = 1;
1353 + }
1354 +
1355 + static inline int arch_spin_trylock(arch_spinlock_t *x)
1356 +@@ -48,10 +46,8 @@ static inline int arch_spin_trylock(arch_spinlock_t *x)
1357 + volatile unsigned int *a;
1358 + int ret;
1359 +
1360 +- mb();
1361 + a = __ldcw_align(x);
1362 + ret = __ldcw(a) != 0;
1363 +- mb();
1364 +
1365 + return ret;
1366 + }
1367 +diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
1368 +index 4886a6db42e9..5f7e57fcaeef 100644
1369 +--- a/arch/parisc/kernel/syscall.S
1370 ++++ b/arch/parisc/kernel/syscall.S
1371 +@@ -629,12 +629,12 @@ cas_action:
1372 + stw %r1, 4(%sr2,%r20)
1373 + #endif
1374 + /* The load and store could fail */
1375 +-1: ldw,ma 0(%r26), %r28
1376 ++1: ldw 0(%r26), %r28
1377 + sub,<> %r28, %r25, %r0
1378 +-2: stw,ma %r24, 0(%r26)
1379 ++2: stw %r24, 0(%r26)
1380 + /* Free lock */
1381 + sync
1382 +- stw,ma %r20, 0(%sr2,%r20)
1383 ++ stw %r20, 0(%sr2,%r20)
1384 + #if ENABLE_LWS_DEBUG
1385 + /* Clear thread register indicator */
1386 + stw %r0, 4(%sr2,%r20)
1387 +@@ -798,30 +798,30 @@ cas2_action:
1388 + ldo 1(%r0),%r28
1389 +
1390 + /* 8bit CAS */
1391 +-13: ldb,ma 0(%r26), %r29
1392 ++13: ldb 0(%r26), %r29
1393 + sub,= %r29, %r25, %r0
1394 + b,n cas2_end
1395 +-14: stb,ma %r24, 0(%r26)
1396 ++14: stb %r24, 0(%r26)
1397 + b cas2_end
1398 + copy %r0, %r28
1399 + nop
1400 + nop
1401 +
1402 + /* 16bit CAS */
1403 +-15: ldh,ma 0(%r26), %r29
1404 ++15: ldh 0(%r26), %r29
1405 + sub,= %r29, %r25, %r0
1406 + b,n cas2_end
1407 +-16: sth,ma %r24, 0(%r26)
1408 ++16: sth %r24, 0(%r26)
1409 + b cas2_end
1410 + copy %r0, %r28
1411 + nop
1412 + nop
1413 +
1414 + /* 32bit CAS */
1415 +-17: ldw,ma 0(%r26), %r29
1416 ++17: ldw 0(%r26), %r29
1417 + sub,= %r29, %r25, %r0
1418 + b,n cas2_end
1419 +-18: stw,ma %r24, 0(%r26)
1420 ++18: stw %r24, 0(%r26)
1421 + b cas2_end
1422 + copy %r0, %r28
1423 + nop
1424 +@@ -829,10 +829,10 @@ cas2_action:
1425 +
1426 + /* 64bit CAS */
1427 + #ifdef CONFIG_64BIT
1428 +-19: ldd,ma 0(%r26), %r29
1429 ++19: ldd 0(%r26), %r29
1430 + sub,*= %r29, %r25, %r0
1431 + b,n cas2_end
1432 +-20: std,ma %r24, 0(%r26)
1433 ++20: std %r24, 0(%r26)
1434 + copy %r0, %r28
1435 + #else
1436 + /* Compare first word */
1437 +@@ -851,7 +851,7 @@ cas2_action:
1438 + cas2_end:
1439 + /* Free lock */
1440 + sync
1441 +- stw,ma %r20, 0(%sr2,%r20)
1442 ++ stw %r20, 0(%sr2,%r20)
1443 + /* Enable interrupts */
1444 + ssm PSW_SM_I, %r0
1445 + /* Return to userspace, set no error */
1446 +diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
1447 +index 9ca7148b5881..6d6cf14009cf 100644
1448 +--- a/arch/powerpc/kernel/smp.c
1449 ++++ b/arch/powerpc/kernel/smp.c
1450 +@@ -579,9 +579,6 @@ static void nmi_stop_this_cpu(struct pt_regs *regs)
1451 + nmi_ipi_busy_count--;
1452 + nmi_ipi_unlock();
1453 +
1454 +- /* Remove this CPU */
1455 +- set_cpu_online(smp_processor_id(), false);
1456 +-
1457 + spin_begin();
1458 + while (1)
1459 + spin_cpu_relax();
1460 +@@ -596,9 +593,6 @@ void smp_send_stop(void)
1461 +
1462 + static void stop_this_cpu(void *dummy)
1463 + {
1464 +- /* Remove this CPU */
1465 +- set_cpu_online(smp_processor_id(), false);
1466 +-
1467 + hard_irq_disable();
1468 + spin_begin();
1469 + while (1)
1470 +diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c
1471 +index b74cbfbce2d0..7bcdaed15703 100644
1472 +--- a/arch/riscv/kernel/irq.c
1473 ++++ b/arch/riscv/kernel/irq.c
1474 +@@ -16,10 +16,6 @@
1475 + #include <linux/irqchip.h>
1476 + #include <linux/irqdomain.h>
1477 +
1478 +-#ifdef CONFIG_RISCV_INTC
1479 +-#include <linux/irqchip/irq-riscv-intc.h>
1480 +-#endif
1481 +-
1482 + void __init init_IRQ(void)
1483 + {
1484 + irqchip_init();
1485 +diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
1486 +index 5dddba301d0a..ac7600b8709a 100644
1487 +--- a/arch/riscv/kernel/module.c
1488 ++++ b/arch/riscv/kernel/module.c
1489 +@@ -252,14 +252,14 @@ static int apply_r_riscv_align_rela(struct module *me, u32 *location,
1490 + static int apply_r_riscv_add32_rela(struct module *me, u32 *location,
1491 + Elf_Addr v)
1492 + {
1493 +- *(u32 *)location += (*(u32 *)v);
1494 ++ *(u32 *)location += (u32)v;
1495 + return 0;
1496 + }
1497 +
1498 + static int apply_r_riscv_sub32_rela(struct module *me, u32 *location,
1499 + Elf_Addr v)
1500 + {
1501 +- *(u32 *)location -= (*(u32 *)v);
1502 ++ *(u32 *)location -= (u32)v;
1503 + return 0;
1504 + }
1505 +
1506 +diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
1507 +index ba3e80712797..9f82a7e34c64 100644
1508 +--- a/arch/riscv/kernel/ptrace.c
1509 ++++ b/arch/riscv/kernel/ptrace.c
1510 +@@ -50,7 +50,7 @@ static int riscv_gpr_set(struct task_struct *target,
1511 + struct pt_regs *regs;
1512 +
1513 + regs = task_pt_regs(target);
1514 +- ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &regs, 0, -1);
1515 ++ ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, regs, 0, -1);
1516 + return ret;
1517 + }
1518 +
1519 +diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
1520 +index dd2bcf0e7d00..7b08b0ffa2c7 100644
1521 +--- a/arch/s390/net/bpf_jit_comp.c
1522 ++++ b/arch/s390/net/bpf_jit_comp.c
1523 +@@ -1391,6 +1391,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
1524 + goto free_addrs;
1525 + }
1526 + if (bpf_jit_prog(&jit, fp)) {
1527 ++ bpf_jit_binary_free(header);
1528 + fp = orig_fp;
1529 + goto free_addrs;
1530 + }
1531 +diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
1532 +index d7a9dea8563d..377d50509653 100644
1533 +--- a/arch/x86/include/asm/processor.h
1534 ++++ b/arch/x86/include/asm/processor.h
1535 +@@ -980,6 +980,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
1536 +
1537 + extern unsigned long arch_align_stack(unsigned long sp);
1538 + extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
1539 ++extern void free_kernel_image_pages(void *begin, void *end);
1540 +
1541 + void default_idle(void);
1542 + #ifdef CONFIG_XEN
1543 +diff --git a/arch/x86/include/asm/set_memory.h b/arch/x86/include/asm/set_memory.h
1544 +index bd090367236c..34cffcef7375 100644
1545 +--- a/arch/x86/include/asm/set_memory.h
1546 ++++ b/arch/x86/include/asm/set_memory.h
1547 +@@ -46,6 +46,7 @@ int set_memory_np(unsigned long addr, int numpages);
1548 + int set_memory_4k(unsigned long addr, int numpages);
1549 + int set_memory_encrypted(unsigned long addr, int numpages);
1550 + int set_memory_decrypted(unsigned long addr, int numpages);
1551 ++int set_memory_np_noalias(unsigned long addr, int numpages);
1552 +
1553 + int set_memory_array_uc(unsigned long *addr, int addrinarray);
1554 + int set_memory_array_wc(unsigned long *addr, int addrinarray);
1555 +diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
1556 +index 1c2cfa0644aa..97ccf4c3b45b 100644
1557 +--- a/arch/x86/kernel/cpu/microcode/intel.c
1558 ++++ b/arch/x86/kernel/cpu/microcode/intel.c
1559 +@@ -190,8 +190,11 @@ static void save_microcode_patch(void *data, unsigned int size)
1560 + p = memdup_patch(data, size);
1561 + if (!p)
1562 + pr_err("Error allocating buffer %p\n", data);
1563 +- else
1564 ++ else {
1565 + list_replace(&iter->plist, &p->plist);
1566 ++ kfree(iter->data);
1567 ++ kfree(iter);
1568 ++ }
1569 + }
1570 + }
1571 +
1572 +diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
1573 +index d79a18b4cf9d..4c53d12ca933 100644
1574 +--- a/arch/x86/kernel/kvmclock.c
1575 ++++ b/arch/x86/kernel/kvmclock.c
1576 +@@ -138,6 +138,7 @@ static unsigned long kvm_get_tsc_khz(void)
1577 + src = &hv_clock[cpu].pvti;
1578 + tsc_khz = pvclock_tsc_khz(src);
1579 + put_cpu();
1580 ++ setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
1581 + return tsc_khz;
1582 + }
1583 +
1584 +diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
1585 +index f5d30c68fd09..f02ecaf97904 100644
1586 +--- a/arch/x86/kernel/smpboot.c
1587 ++++ b/arch/x86/kernel/smpboot.c
1588 +@@ -222,6 +222,11 @@ static void notrace start_secondary(void *unused)
1589 + #ifdef CONFIG_X86_32
1590 + /* switch away from the initial page table */
1591 + load_cr3(swapper_pg_dir);
1592 ++ /*
1593 ++ * Initialize the CR4 shadow before doing anything that could
1594 ++ * try to read it.
1595 ++ */
1596 ++ cr4_init_shadow();
1597 + __flush_tlb_all();
1598 + #endif
1599 + load_current_idt();
1600 +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
1601 +index 12cad70acc3b..71dd00a140d2 100644
1602 +--- a/arch/x86/kvm/vmx.c
1603 ++++ b/arch/x86/kvm/vmx.c
1604 +@@ -11791,7 +11791,6 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry)
1605 + {
1606 + struct vcpu_vmx *vmx = to_vmx(vcpu);
1607 + struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
1608 +- u32 msr_entry_idx;
1609 + u32 exit_qual;
1610 + int r;
1611 +
1612 +@@ -11813,10 +11812,10 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry)
1613 + nested_get_vmcs12_pages(vcpu, vmcs12);
1614 +
1615 + r = EXIT_REASON_MSR_LOAD_FAIL;
1616 +- msr_entry_idx = nested_vmx_load_msr(vcpu,
1617 +- vmcs12->vm_entry_msr_load_addr,
1618 +- vmcs12->vm_entry_msr_load_count);
1619 +- if (msr_entry_idx)
1620 ++ exit_qual = nested_vmx_load_msr(vcpu,
1621 ++ vmcs12->vm_entry_msr_load_addr,
1622 ++ vmcs12->vm_entry_msr_load_count);
1623 ++ if (exit_qual)
1624 + goto fail;
1625 +
1626 + /*
1627 +diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
1628 +index 83241eb71cd4..acfab322fbe0 100644
1629 +--- a/arch/x86/mm/init.c
1630 ++++ b/arch/x86/mm/init.c
1631 +@@ -775,13 +775,44 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
1632 + }
1633 + }
1634 +
1635 ++/*
1636 ++ * begin/end can be in the direct map or the "high kernel mapping"
1637 ++ * used for the kernel image only. free_init_pages() will do the
1638 ++ * right thing for either kind of address.
1639 ++ */
1640 ++void free_kernel_image_pages(void *begin, void *end)
1641 ++{
1642 ++ unsigned long begin_ul = (unsigned long)begin;
1643 ++ unsigned long end_ul = (unsigned long)end;
1644 ++ unsigned long len_pages = (end_ul - begin_ul) >> PAGE_SHIFT;
1645 ++
1646 ++
1647 ++ free_init_pages("unused kernel image", begin_ul, end_ul);
1648 ++
1649 ++ /*
1650 ++ * PTI maps some of the kernel into userspace. For performance,
1651 ++ * this includes some kernel areas that do not contain secrets.
1652 ++ * Those areas might be adjacent to the parts of the kernel image
1653 ++ * being freed, which may contain secrets. Remove the "high kernel
1654 ++ * image mapping" for these freed areas, ensuring they are not even
1655 ++ * potentially vulnerable to Meltdown regardless of the specific
1656 ++ * optimizations PTI is currently using.
1657 ++ *
1658 ++ * The "noalias" prevents unmapping the direct map alias which is
1659 ++ * needed to access the freed pages.
1660 ++ *
1661 ++ * This is only valid for 64bit kernels. 32bit has only one mapping
1662 ++ * which can't be treated in this way for obvious reasons.
1663 ++ */
1664 ++ if (IS_ENABLED(CONFIG_X86_64) && cpu_feature_enabled(X86_FEATURE_PTI))
1665 ++ set_memory_np_noalias(begin_ul, len_pages);
1666 ++}
1667 ++
1668 + void __ref free_initmem(void)
1669 + {
1670 + e820__reallocate_tables();
1671 +
1672 +- free_init_pages("unused kernel",
1673 +- (unsigned long)(&__init_begin),
1674 +- (unsigned long)(&__init_end));
1675 ++ free_kernel_image_pages(&__init_begin, &__init_end);
1676 + }
1677 +
1678 + #ifdef CONFIG_BLK_DEV_INITRD
1679 +diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
1680 +index 20d8bf5fbceb..3060e1dda2ad 100644
1681 +--- a/arch/x86/mm/init_64.c
1682 ++++ b/arch/x86/mm/init_64.c
1683 +@@ -1283,12 +1283,8 @@ void mark_rodata_ro(void)
1684 + set_memory_ro(start, (end-start) >> PAGE_SHIFT);
1685 + #endif
1686 +
1687 +- free_init_pages("unused kernel",
1688 +- (unsigned long) __va(__pa_symbol(text_end)),
1689 +- (unsigned long) __va(__pa_symbol(rodata_start)));
1690 +- free_init_pages("unused kernel",
1691 +- (unsigned long) __va(__pa_symbol(rodata_end)),
1692 +- (unsigned long) __va(__pa_symbol(_sdata)));
1693 ++ free_kernel_image_pages((void *)text_end, (void *)rodata_start);
1694 ++ free_kernel_image_pages((void *)rodata_end, (void *)_sdata);
1695 +
1696 + debug_checkwx();
1697 +
1698 +diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
1699 +index 29505724202a..8d6c34fe49be 100644
1700 +--- a/arch/x86/mm/pageattr.c
1701 ++++ b/arch/x86/mm/pageattr.c
1702 +@@ -53,6 +53,7 @@ static DEFINE_SPINLOCK(cpa_lock);
1703 + #define CPA_FLUSHTLB 1
1704 + #define CPA_ARRAY 2
1705 + #define CPA_PAGES_ARRAY 4
1706 ++#define CPA_NO_CHECK_ALIAS 8 /* Do not search for aliases */
1707 +
1708 + #ifdef CONFIG_PROC_FS
1709 + static unsigned long direct_pages_count[PG_LEVEL_NUM];
1710 +@@ -1486,6 +1487,9 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
1711 +
1712 + /* No alias checking for _NX bit modifications */
1713 + checkalias = (pgprot_val(mask_set) | pgprot_val(mask_clr)) != _PAGE_NX;
1714 ++ /* Has caller explicitly disabled alias checking? */
1715 ++ if (in_flag & CPA_NO_CHECK_ALIAS)
1716 ++ checkalias = 0;
1717 +
1718 + ret = __change_page_attr_set_clr(&cpa, checkalias);
1719 +
1720 +@@ -1772,6 +1776,15 @@ int set_memory_np(unsigned long addr, int numpages)
1721 + return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_PRESENT), 0);
1722 + }
1723 +
1724 ++int set_memory_np_noalias(unsigned long addr, int numpages)
1725 ++{
1726 ++ int cpa_flags = CPA_NO_CHECK_ALIAS;
1727 ++
1728 ++ return change_page_attr_set_clr(&addr, numpages, __pgprot(0),
1729 ++ __pgprot(_PAGE_PRESENT), 0,
1730 ++ cpa_flags, NULL);
1731 ++}
1732 ++
1733 + int set_memory_4k(unsigned long addr, int numpages)
1734 + {
1735 + return change_page_attr_set_clr(&addr, numpages, __pgprot(0),
1736 +diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
1737 +index 3080e18cb859..62b5f3f21b4b 100644
1738 +--- a/block/blk-mq-debugfs.c
1739 ++++ b/block/blk-mq-debugfs.c
1740 +@@ -357,7 +357,7 @@ static const char *const blk_mq_rq_state_name_array[] = {
1741 +
1742 + static const char *blk_mq_rq_state_name(enum mq_rq_state rq_state)
1743 + {
1744 +- if (WARN_ON_ONCE((unsigned int)rq_state >
1745 ++ if (WARN_ON_ONCE((unsigned int)rq_state >=
1746 + ARRAY_SIZE(blk_mq_rq_state_name_array)))
1747 + return "(?)";
1748 + return blk_mq_rq_state_name_array[rq_state];
1749 +diff --git a/block/blk-mq.c b/block/blk-mq.c
1750 +index 90ffd8151c57..ed9b11e6b997 100644
1751 +--- a/block/blk-mq.c
1752 ++++ b/block/blk-mq.c
1753 +@@ -1174,6 +1174,9 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx,
1754 +
1755 + #define BLK_MQ_RESOURCE_DELAY 3 /* ms units */
1756 +
1757 ++/*
1758 ++ * Returns true if we did some work AND can potentially do more.
1759 ++ */
1760 + bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
1761 + bool got_budget)
1762 + {
1763 +@@ -1304,8 +1307,17 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
1764 + blk_mq_run_hw_queue(hctx, true);
1765 + else if (needs_restart && (ret == BLK_STS_RESOURCE))
1766 + blk_mq_delay_run_hw_queue(hctx, BLK_MQ_RESOURCE_DELAY);
1767 ++
1768 ++ return false;
1769 + }
1770 +
1771 ++ /*
1772 ++ * If the host/device is unable to accept more work, inform the
1773 ++ * caller of that.
1774 ++ */
1775 ++ if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE)
1776 ++ return false;
1777 ++
1778 + return (queued + errors) != 0;
1779 + }
1780 +
1781 +diff --git a/block/sed-opal.c b/block/sed-opal.c
1782 +index 945f4b8610e0..e0de4dd448b3 100644
1783 +--- a/block/sed-opal.c
1784 ++++ b/block/sed-opal.c
1785 +@@ -877,7 +877,7 @@ static size_t response_get_string(const struct parsed_resp *resp, int n,
1786 + return 0;
1787 + }
1788 +
1789 +- if (n > resp->num) {
1790 ++ if (n >= resp->num) {
1791 + pr_debug("Response has %d tokens. Can't access %d\n",
1792 + resp->num, n);
1793 + return 0;
1794 +@@ -916,7 +916,7 @@ static u64 response_get_u64(const struct parsed_resp *resp, int n)
1795 + return 0;
1796 + }
1797 +
1798 +- if (n > resp->num) {
1799 ++ if (n >= resp->num) {
1800 + pr_debug("Response has %d tokens. Can't access %d\n",
1801 + resp->num, n);
1802 + return 0;
1803 +diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
1804 +index 30a572956557..70a0f8b2f6c1 100644
1805 +--- a/drivers/acpi/ec.c
1806 ++++ b/drivers/acpi/ec.c
1807 +@@ -2031,6 +2031,17 @@ static inline void acpi_ec_query_exit(void)
1808 + }
1809 + }
1810 +
1811 ++static const struct dmi_system_id acpi_ec_no_wakeup[] = {
1812 ++ {
1813 ++ .ident = "Thinkpad X1 Carbon 6th",
1814 ++ .matches = {
1815 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1816 ++ DMI_MATCH(DMI_PRODUCT_FAMILY, "Thinkpad X1 Carbon 6th"),
1817 ++ },
1818 ++ },
1819 ++ { },
1820 ++};
1821 ++
1822 + int __init acpi_ec_init(void)
1823 + {
1824 + int result;
1825 +@@ -2041,6 +2052,15 @@ int __init acpi_ec_init(void)
1826 + if (result)
1827 + return result;
1828 +
1829 ++ /*
1830 ++ * Disable EC wakeup on following systems to prevent periodic
1831 ++ * wakeup from EC GPE.
1832 ++ */
1833 ++ if (dmi_check_system(acpi_ec_no_wakeup)) {
1834 ++ ec_no_wakeup = true;
1835 ++ pr_debug("Disabling EC wakeup on suspend-to-idle\n");
1836 ++ }
1837 ++
1838 + /* Drivers must be started after acpi_ec_query_init() */
1839 + dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver);
1840 + /*
1841 +diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
1842 +index 964106d173bd..3b1651426e12 100644
1843 +--- a/drivers/acpi/nfit/core.c
1844 ++++ b/drivers/acpi/nfit/core.c
1845 +@@ -408,6 +408,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
1846 + const guid_t *guid;
1847 + int rc, i;
1848 +
1849 ++ if (cmd_rc)
1850 ++ *cmd_rc = -EINVAL;
1851 + func = cmd;
1852 + if (cmd == ND_CMD_CALL) {
1853 + call_pkg = buf;
1854 +@@ -518,6 +520,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
1855 + * If we return an error (like elsewhere) then caller wouldn't
1856 + * be able to rely upon data returned to make calculation.
1857 + */
1858 ++ if (cmd_rc)
1859 ++ *cmd_rc = 0;
1860 + return 0;
1861 + }
1862 +
1863 +diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
1864 +index e5d90977caec..5e4befdd8562 100644
1865 +--- a/drivers/ata/libahci.c
1866 ++++ b/drivers/ata/libahci.c
1867 +@@ -35,6 +35,7 @@
1868 + #include <linux/kernel.h>
1869 + #include <linux/gfp.h>
1870 + #include <linux/module.h>
1871 ++#include <linux/nospec.h>
1872 + #include <linux/blkdev.h>
1873 + #include <linux/delay.h>
1874 + #include <linux/interrupt.h>
1875 +@@ -1146,10 +1147,12 @@ static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
1876 +
1877 + /* get the slot number from the message */
1878 + pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
1879 +- if (pmp < EM_MAX_SLOTS)
1880 ++ if (pmp < EM_MAX_SLOTS) {
1881 ++ pmp = array_index_nospec(pmp, EM_MAX_SLOTS);
1882 + emp = &pp->em_priv[pmp];
1883 +- else
1884 ++ } else {
1885 + return -EINVAL;
1886 ++ }
1887 +
1888 + /* mask off the activity bits if we are in sw_activity
1889 + * mode, user should turn off sw_activity before setting
1890 +diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
1891 +index a500e738d929..f0ccb0a2b3bf 100644
1892 +--- a/drivers/block/drbd/drbd_req.c
1893 ++++ b/drivers/block/drbd/drbd_req.c
1894 +@@ -1244,8 +1244,8 @@ drbd_request_prepare(struct drbd_device *device, struct bio *bio, unsigned long
1895 + _drbd_start_io_acct(device, req);
1896 +
1897 + /* process discards always from our submitter thread */
1898 +- if ((bio_op(bio) & REQ_OP_WRITE_ZEROES) ||
1899 +- (bio_op(bio) & REQ_OP_DISCARD))
1900 ++ if (bio_op(bio) == REQ_OP_WRITE_ZEROES ||
1901 ++ bio_op(bio) == REQ_OP_DISCARD)
1902 + goto queue_for_submitter_thread;
1903 +
1904 + if (rw == WRITE && req->private_bio && req->i.size
1905 +diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
1906 +index 64278f472efe..a1c0c1d1f264 100644
1907 +--- a/drivers/block/nbd.c
1908 ++++ b/drivers/block/nbd.c
1909 +@@ -76,6 +76,7 @@ struct link_dead_args {
1910 + #define NBD_HAS_CONFIG_REF 4
1911 + #define NBD_BOUND 5
1912 + #define NBD_DESTROY_ON_DISCONNECT 6
1913 ++#define NBD_DISCONNECT_ON_CLOSE 7
1914 +
1915 + struct nbd_config {
1916 + u32 flags;
1917 +@@ -138,6 +139,7 @@ static void nbd_config_put(struct nbd_device *nbd);
1918 + static void nbd_connect_reply(struct genl_info *info, int index);
1919 + static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info);
1920 + static void nbd_dead_link_work(struct work_struct *work);
1921 ++static void nbd_disconnect_and_put(struct nbd_device *nbd);
1922 +
1923 + static inline struct device *nbd_to_dev(struct nbd_device *nbd)
1924 + {
1925 +@@ -1291,6 +1293,12 @@ out:
1926 + static void nbd_release(struct gendisk *disk, fmode_t mode)
1927 + {
1928 + struct nbd_device *nbd = disk->private_data;
1929 ++ struct block_device *bdev = bdget_disk(disk, 0);
1930 ++
1931 ++ if (test_bit(NBD_DISCONNECT_ON_CLOSE, &nbd->config->runtime_flags) &&
1932 ++ bdev->bd_openers == 0)
1933 ++ nbd_disconnect_and_put(nbd);
1934 ++
1935 + nbd_config_put(nbd);
1936 + nbd_put(nbd);
1937 + }
1938 +@@ -1690,6 +1698,10 @@ again:
1939 + &config->runtime_flags);
1940 + put_dev = true;
1941 + }
1942 ++ if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) {
1943 ++ set_bit(NBD_DISCONNECT_ON_CLOSE,
1944 ++ &config->runtime_flags);
1945 ++ }
1946 + }
1947 +
1948 + if (info->attrs[NBD_ATTR_SOCKETS]) {
1949 +@@ -1734,6 +1746,16 @@ out:
1950 + return ret;
1951 + }
1952 +
1953 ++static void nbd_disconnect_and_put(struct nbd_device *nbd)
1954 ++{
1955 ++ mutex_lock(&nbd->config_lock);
1956 ++ nbd_disconnect(nbd);
1957 ++ mutex_unlock(&nbd->config_lock);
1958 ++ if (test_and_clear_bit(NBD_HAS_CONFIG_REF,
1959 ++ &nbd->config->runtime_flags))
1960 ++ nbd_config_put(nbd);
1961 ++}
1962 ++
1963 + static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
1964 + {
1965 + struct nbd_device *nbd;
1966 +@@ -1766,12 +1788,7 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
1967 + nbd_put(nbd);
1968 + return 0;
1969 + }
1970 +- mutex_lock(&nbd->config_lock);
1971 +- nbd_disconnect(nbd);
1972 +- mutex_unlock(&nbd->config_lock);
1973 +- if (test_and_clear_bit(NBD_HAS_CONFIG_REF,
1974 +- &nbd->config->runtime_flags))
1975 +- nbd_config_put(nbd);
1976 ++ nbd_disconnect_and_put(nbd);
1977 + nbd_config_put(nbd);
1978 + nbd_put(nbd);
1979 + return 0;
1980 +@@ -1782,7 +1799,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1981 + struct nbd_device *nbd = NULL;
1982 + struct nbd_config *config;
1983 + int index;
1984 +- int ret = -EINVAL;
1985 ++ int ret = 0;
1986 + bool put_dev = false;
1987 +
1988 + if (!netlink_capable(skb, CAP_SYS_ADMIN))
1989 +@@ -1822,6 +1839,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1990 + !nbd->task_recv) {
1991 + dev_err(nbd_to_dev(nbd),
1992 + "not configured, cannot reconfigure\n");
1993 ++ ret = -EINVAL;
1994 + goto out;
1995 + }
1996 +
1997 +@@ -1846,6 +1864,14 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1998 + &config->runtime_flags))
1999 + refcount_inc(&nbd->refs);
2000 + }
2001 ++
2002 ++ if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) {
2003 ++ set_bit(NBD_DISCONNECT_ON_CLOSE,
2004 ++ &config->runtime_flags);
2005 ++ } else {
2006 ++ clear_bit(NBD_DISCONNECT_ON_CLOSE,
2007 ++ &config->runtime_flags);
2008 ++ }
2009 + }
2010 +
2011 + if (info->attrs[NBD_ATTR_SOCKETS]) {
2012 +diff --git a/drivers/char/ipmi/kcs_bmc.c b/drivers/char/ipmi/kcs_bmc.c
2013 +index fbfc05e3f3d1..bb882ab161fe 100644
2014 +--- a/drivers/char/ipmi/kcs_bmc.c
2015 ++++ b/drivers/char/ipmi/kcs_bmc.c
2016 +@@ -210,34 +210,23 @@ static void kcs_bmc_handle_cmd(struct kcs_bmc *kcs_bmc)
2017 + int kcs_bmc_handle_event(struct kcs_bmc *kcs_bmc)
2018 + {
2019 + unsigned long flags;
2020 +- int ret = 0;
2021 ++ int ret = -ENODATA;
2022 + u8 status;
2023 +
2024 + spin_lock_irqsave(&kcs_bmc->lock, flags);
2025 +
2026 +- if (!kcs_bmc->running) {
2027 +- kcs_force_abort(kcs_bmc);
2028 +- ret = -ENODEV;
2029 +- goto out_unlock;
2030 +- }
2031 +-
2032 +- status = read_status(kcs_bmc) & (KCS_STATUS_IBF | KCS_STATUS_CMD_DAT);
2033 +-
2034 +- switch (status) {
2035 +- case KCS_STATUS_IBF | KCS_STATUS_CMD_DAT:
2036 +- kcs_bmc_handle_cmd(kcs_bmc);
2037 +- break;
2038 +-
2039 +- case KCS_STATUS_IBF:
2040 +- kcs_bmc_handle_data(kcs_bmc);
2041 +- break;
2042 ++ status = read_status(kcs_bmc);
2043 ++ if (status & KCS_STATUS_IBF) {
2044 ++ if (!kcs_bmc->running)
2045 ++ kcs_force_abort(kcs_bmc);
2046 ++ else if (status & KCS_STATUS_CMD_DAT)
2047 ++ kcs_bmc_handle_cmd(kcs_bmc);
2048 ++ else
2049 ++ kcs_bmc_handle_data(kcs_bmc);
2050 +
2051 +- default:
2052 +- ret = -ENODATA;
2053 +- break;
2054 ++ ret = 0;
2055 + }
2056 +
2057 +-out_unlock:
2058 + spin_unlock_irqrestore(&kcs_bmc->lock, flags);
2059 +
2060 + return ret;
2061 +diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
2062 +index de6d06ac790b..23a7fdcfc4e0 100644
2063 +--- a/drivers/clk/Makefile
2064 ++++ b/drivers/clk/Makefile
2065 +@@ -94,7 +94,7 @@ obj-$(CONFIG_ARCH_SPRD) += sprd/
2066 + obj-$(CONFIG_ARCH_STI) += st/
2067 + obj-$(CONFIG_ARCH_STRATIX10) += socfpga/
2068 + obj-$(CONFIG_ARCH_SUNXI) += sunxi/
2069 +-obj-$(CONFIG_ARCH_SUNXI) += sunxi-ng/
2070 ++obj-$(CONFIG_SUNXI_CCU) += sunxi-ng/
2071 + obj-$(CONFIG_ARCH_TEGRA) += tegra/
2072 + obj-y += ti/
2073 + obj-$(CONFIG_CLK_UNIPHIER) += uniphier/
2074 +diff --git a/drivers/clk/davinci/da8xx-cfgchip.c b/drivers/clk/davinci/da8xx-cfgchip.c
2075 +index c971111d2601..20a120aa147e 100644
2076 +--- a/drivers/clk/davinci/da8xx-cfgchip.c
2077 ++++ b/drivers/clk/davinci/da8xx-cfgchip.c
2078 +@@ -672,7 +672,7 @@ static int of_da8xx_usb_phy_clk_init(struct device *dev, struct regmap *regmap)
2079 +
2080 + usb1 = da8xx_cfgchip_register_usb1_clk48(dev, regmap);
2081 + if (IS_ERR(usb1)) {
2082 +- if (PTR_ERR(usb0) == -EPROBE_DEFER)
2083 ++ if (PTR_ERR(usb1) == -EPROBE_DEFER)
2084 + return -EPROBE_DEFER;
2085 +
2086 + dev_warn(dev, "Failed to register usb1_clk48 (%ld)\n",
2087 +diff --git a/drivers/clk/sunxi-ng/Makefile b/drivers/clk/sunxi-ng/Makefile
2088 +index 128a40ee5c5e..9ac0fb948101 100644
2089 +--- a/drivers/clk/sunxi-ng/Makefile
2090 ++++ b/drivers/clk/sunxi-ng/Makefile
2091 +@@ -1,24 +1,24 @@
2092 + # SPDX-License-Identifier: GPL-2.0
2093 + # Common objects
2094 +-lib-$(CONFIG_SUNXI_CCU) += ccu_common.o
2095 +-lib-$(CONFIG_SUNXI_CCU) += ccu_mmc_timing.o
2096 +-lib-$(CONFIG_SUNXI_CCU) += ccu_reset.o
2097 ++obj-y += ccu_common.o
2098 ++obj-y += ccu_mmc_timing.o
2099 ++obj-y += ccu_reset.o
2100 +
2101 + # Base clock types
2102 +-lib-$(CONFIG_SUNXI_CCU) += ccu_div.o
2103 +-lib-$(CONFIG_SUNXI_CCU) += ccu_frac.o
2104 +-lib-$(CONFIG_SUNXI_CCU) += ccu_gate.o
2105 +-lib-$(CONFIG_SUNXI_CCU) += ccu_mux.o
2106 +-lib-$(CONFIG_SUNXI_CCU) += ccu_mult.o
2107 +-lib-$(CONFIG_SUNXI_CCU) += ccu_phase.o
2108 +-lib-$(CONFIG_SUNXI_CCU) += ccu_sdm.o
2109 ++obj-y += ccu_div.o
2110 ++obj-y += ccu_frac.o
2111 ++obj-y += ccu_gate.o
2112 ++obj-y += ccu_mux.o
2113 ++obj-y += ccu_mult.o
2114 ++obj-y += ccu_phase.o
2115 ++obj-y += ccu_sdm.o
2116 +
2117 + # Multi-factor clocks
2118 +-lib-$(CONFIG_SUNXI_CCU) += ccu_nk.o
2119 +-lib-$(CONFIG_SUNXI_CCU) += ccu_nkm.o
2120 +-lib-$(CONFIG_SUNXI_CCU) += ccu_nkmp.o
2121 +-lib-$(CONFIG_SUNXI_CCU) += ccu_nm.o
2122 +-lib-$(CONFIG_SUNXI_CCU) += ccu_mp.o
2123 ++obj-y += ccu_nk.o
2124 ++obj-y += ccu_nkm.o
2125 ++obj-y += ccu_nkmp.o
2126 ++obj-y += ccu_nm.o
2127 ++obj-y += ccu_mp.o
2128 +
2129 + # SoC support
2130 + obj-$(CONFIG_SUN50I_A64_CCU) += ccu-sun50i-a64.o
2131 +@@ -37,12 +37,3 @@ obj-$(CONFIG_SUN8I_R40_CCU) += ccu-sun8i-r40.o
2132 + obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80.o
2133 + obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80-de.o
2134 + obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80-usb.o
2135 +-
2136 +-# The lib-y file goals is supposed to work only in arch/*/lib or lib/. In our
2137 +-# case, we want to use that goal, but even though lib.a will be properly
2138 +-# generated, it will not be linked in, eventually resulting in a linker error
2139 +-# for missing symbols.
2140 +-#
2141 +-# We can work around that by explicitly adding lib.a to the obj-y goal. This is
2142 +-# an undocumented behaviour, but works well for now.
2143 +-obj-$(CONFIG_SUNXI_CCU) += lib.a
2144 +diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c
2145 +index e5cdc3af684c..2717f88c7904 100644
2146 +--- a/drivers/clocksource/timer-stm32.c
2147 ++++ b/drivers/clocksource/timer-stm32.c
2148 +@@ -304,8 +304,10 @@ static int __init stm32_timer_init(struct device_node *node)
2149 +
2150 + to->private_data = kzalloc(sizeof(struct stm32_timer_private),
2151 + GFP_KERNEL);
2152 +- if (!to->private_data)
2153 ++ if (!to->private_data) {
2154 ++ ret = -ENOMEM;
2155 + goto deinit;
2156 ++ }
2157 +
2158 + rstc = of_reset_control_get(node, NULL);
2159 + if (!IS_ERR(rstc)) {
2160 +diff --git a/drivers/dax/device.c b/drivers/dax/device.c
2161 +index aff2c1594220..a26b7016367a 100644
2162 +--- a/drivers/dax/device.c
2163 ++++ b/drivers/dax/device.c
2164 +@@ -189,14 +189,16 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma,
2165 +
2166 + /* prevent private mappings from being established */
2167 + if ((vma->vm_flags & VM_MAYSHARE) != VM_MAYSHARE) {
2168 +- dev_info(dev, "%s: %s: fail, attempted private mapping\n",
2169 ++ dev_info_ratelimited(dev,
2170 ++ "%s: %s: fail, attempted private mapping\n",
2171 + current->comm, func);
2172 + return -EINVAL;
2173 + }
2174 +
2175 + mask = dax_region->align - 1;
2176 + if (vma->vm_start & mask || vma->vm_end & mask) {
2177 +- dev_info(dev, "%s: %s: fail, unaligned vma (%#lx - %#lx, %#lx)\n",
2178 ++ dev_info_ratelimited(dev,
2179 ++ "%s: %s: fail, unaligned vma (%#lx - %#lx, %#lx)\n",
2180 + current->comm, func, vma->vm_start, vma->vm_end,
2181 + mask);
2182 + return -EINVAL;
2183 +@@ -204,13 +206,15 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma,
2184 +
2185 + if ((dax_region->pfn_flags & (PFN_DEV|PFN_MAP)) == PFN_DEV
2186 + && (vma->vm_flags & VM_DONTCOPY) == 0) {
2187 +- dev_info(dev, "%s: %s: fail, dax range requires MADV_DONTFORK\n",
2188 ++ dev_info_ratelimited(dev,
2189 ++ "%s: %s: fail, dax range requires MADV_DONTFORK\n",
2190 + current->comm, func);
2191 + return -EINVAL;
2192 + }
2193 +
2194 + if (!vma_is_dax(vma)) {
2195 +- dev_info(dev, "%s: %s: fail, vma is not DAX capable\n",
2196 ++ dev_info_ratelimited(dev,
2197 ++ "%s: %s: fail, vma is not DAX capable\n",
2198 + current->comm, func);
2199 + return -EINVAL;
2200 + }
2201 +diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
2202 +index 26b67455208f..e27adc4ab59d 100644
2203 +--- a/drivers/dma/k3dma.c
2204 ++++ b/drivers/dma/k3dma.c
2205 +@@ -794,7 +794,7 @@ static struct dma_chan *k3_of_dma_simple_xlate(struct of_phandle_args *dma_spec,
2206 + struct k3_dma_dev *d = ofdma->of_dma_data;
2207 + unsigned int request = dma_spec->args[0];
2208 +
2209 +- if (request > d->dma_requests)
2210 ++ if (request >= d->dma_requests)
2211 + return NULL;
2212 +
2213 + return dma_get_slave_channel(&(d->chans[request].vc.chan));
2214 +diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
2215 +index d21c19822feb..56399bd45179 100644
2216 +--- a/drivers/dma/omap-dma.c
2217 ++++ b/drivers/dma/omap-dma.c
2218 +@@ -1485,7 +1485,11 @@ static int omap_dma_probe(struct platform_device *pdev)
2219 + od->ddev.src_addr_widths = OMAP_DMA_BUSWIDTHS;
2220 + od->ddev.dst_addr_widths = OMAP_DMA_BUSWIDTHS;
2221 + od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
2222 +- od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
2223 ++ if (__dma_omap15xx(od->plat->dma_attr))
2224 ++ od->ddev.residue_granularity =
2225 ++ DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
2226 ++ else
2227 ++ od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
2228 + od->ddev.max_burst = SZ_16M - 1; /* CCEN: 24bit unsigned */
2229 + od->ddev.dev = &pdev->dev;
2230 + INIT_LIST_HEAD(&od->ddev.channels);
2231 +diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
2232 +index de1fd59fe136..96a8ab3cec27 100644
2233 +--- a/drivers/dma/pl330.c
2234 ++++ b/drivers/dma/pl330.c
2235 +@@ -2924,7 +2924,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
2236 + pd->src_addr_widths = PL330_DMA_BUSWIDTHS;
2237 + pd->dst_addr_widths = PL330_DMA_BUSWIDTHS;
2238 + pd->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
2239 +- pd->residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
2240 ++ pd->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
2241 + pd->max_burst = ((pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) ?
2242 + 1 : PL330_MAX_BURST);
2243 +
2244 +diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
2245 +index 3bb82e511eca..7d3edd713932 100644
2246 +--- a/drivers/edac/edac_mc.c
2247 ++++ b/drivers/edac/edac_mc.c
2248 +@@ -215,6 +215,7 @@ const char * const edac_mem_types[] = {
2249 + [MEM_LRDDR3] = "Load-Reduced-DDR3-RAM",
2250 + [MEM_DDR4] = "Unbuffered-DDR4",
2251 + [MEM_RDDR4] = "Registered-DDR4",
2252 ++ [MEM_LRDDR4] = "Load-Reduced-DDR4-RAM",
2253 + [MEM_NVDIMM] = "Non-volatile-RAM",
2254 + };
2255 + EXPORT_SYMBOL_GPL(edac_mem_types);
2256 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
2257 +index 361975cf45a9..11e7eadf1166 100644
2258 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
2259 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
2260 +@@ -31,7 +31,7 @@
2261 + #include <linux/power_supply.h>
2262 + #include <linux/hwmon.h>
2263 + #include <linux/hwmon-sysfs.h>
2264 +-
2265 ++#include <linux/nospec.h>
2266 +
2267 + static int amdgpu_debugfs_pm_init(struct amdgpu_device *adev);
2268 +
2269 +@@ -309,6 +309,7 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev,
2270 + count = -EINVAL;
2271 + goto fail;
2272 + }
2273 ++ idx = array_index_nospec(idx, ARRAY_SIZE(data.states));
2274 +
2275 + amdgpu_dpm_get_pp_num_states(adev, &data);
2276 + state = data.states[idx];
2277 +diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
2278 +index ac9617269a2f..085f0ba564df 100644
2279 +--- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
2280 ++++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
2281 +@@ -899,7 +899,7 @@ static const struct amdgpu_ring_funcs vce_v3_0_ring_phys_funcs = {
2282 + .emit_frame_size =
2283 + 4 + /* vce_v3_0_emit_pipeline_sync */
2284 + 6, /* amdgpu_vce_ring_emit_fence x1 no user fence */
2285 +- .emit_ib_size = 5, /* vce_v3_0_ring_emit_ib */
2286 ++ .emit_ib_size = 4, /* amdgpu_vce_ring_emit_ib */
2287 + .emit_ib = amdgpu_vce_ring_emit_ib,
2288 + .emit_fence = amdgpu_vce_ring_emit_fence,
2289 + .test_ring = amdgpu_vce_ring_test_ring,
2290 +@@ -923,7 +923,7 @@ static const struct amdgpu_ring_funcs vce_v3_0_ring_vm_funcs = {
2291 + 6 + /* vce_v3_0_emit_vm_flush */
2292 + 4 + /* vce_v3_0_emit_pipeline_sync */
2293 + 6 + 6, /* amdgpu_vce_ring_emit_fence x2 vm fence */
2294 +- .emit_ib_size = 4, /* amdgpu_vce_ring_emit_ib */
2295 ++ .emit_ib_size = 5, /* vce_v3_0_ring_emit_ib */
2296 + .emit_ib = vce_v3_0_ring_emit_ib,
2297 + .emit_vm_flush = vce_v3_0_emit_vm_flush,
2298 + .emit_pipeline_sync = vce_v3_0_emit_pipeline_sync,
2299 +diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
2300 +index 3092f76bdb75..6531ee7f3af4 100644
2301 +--- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
2302 ++++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
2303 +@@ -678,9 +678,22 @@ bool dce100_validate_bandwidth(
2304 + struct dc *dc,
2305 + struct dc_state *context)
2306 + {
2307 +- /* TODO implement when needed but for now hardcode max value*/
2308 +- context->bw.dce.dispclk_khz = 681000;
2309 +- context->bw.dce.yclk_khz = 250000 * MEMORY_TYPE_MULTIPLIER;
2310 ++ int i;
2311 ++ bool at_least_one_pipe = false;
2312 ++
2313 ++ for (i = 0; i < dc->res_pool->pipe_count; i++) {
2314 ++ if (context->res_ctx.pipe_ctx[i].stream)
2315 ++ at_least_one_pipe = true;
2316 ++ }
2317 ++
2318 ++ if (at_least_one_pipe) {
2319 ++ /* TODO implement when needed but for now hardcode max value*/
2320 ++ context->bw.dce.dispclk_khz = 681000;
2321 ++ context->bw.dce.yclk_khz = 250000 * MEMORY_TYPE_MULTIPLIER;
2322 ++ } else {
2323 ++ context->bw.dce.dispclk_khz = 0;
2324 ++ context->bw.dce.yclk_khz = 0;
2325 ++ }
2326 +
2327 + return true;
2328 + }
2329 +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c
2330 +index 200de46bd06b..0d497d0f6056 100644
2331 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c
2332 ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c
2333 +@@ -82,6 +82,7 @@ static void vega12_set_default_registry_data(struct pp_hwmgr *hwmgr)
2334 +
2335 + data->registry_data.disallowed_features = 0x0;
2336 + data->registry_data.od_state_in_dc_support = 0;
2337 ++ data->registry_data.thermal_support = 1;
2338 + data->registry_data.skip_baco_hardware = 0;
2339 +
2340 + data->registry_data.log_avfs_param = 0;
2341 +diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
2342 +index 8d20faa198cf..0a788d76ed5f 100644
2343 +--- a/drivers/gpu/drm/arm/malidp_drv.c
2344 ++++ b/drivers/gpu/drm/arm/malidp_drv.c
2345 +@@ -278,7 +278,6 @@ static int malidp_init(struct drm_device *drm)
2346 +
2347 + static void malidp_fini(struct drm_device *drm)
2348 + {
2349 +- drm_atomic_helper_shutdown(drm);
2350 + drm_mode_config_cleanup(drm);
2351 + }
2352 +
2353 +@@ -646,6 +645,7 @@ vblank_fail:
2354 + malidp_de_irq_fini(drm);
2355 + drm->irq_enabled = false;
2356 + irq_init_fail:
2357 ++ drm_atomic_helper_shutdown(drm);
2358 + component_unbind_all(dev, drm);
2359 + bind_fail:
2360 + of_node_put(malidp->crtc.port);
2361 +@@ -681,6 +681,7 @@ static void malidp_unbind(struct device *dev)
2362 + malidp_se_irq_fini(drm);
2363 + malidp_de_irq_fini(drm);
2364 + drm->irq_enabled = false;
2365 ++ drm_atomic_helper_shutdown(drm);
2366 + component_unbind_all(dev, drm);
2367 + of_node_put(malidp->crtc.port);
2368 + malidp->crtc.port = NULL;
2369 +diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c
2370 +index d789b46dc817..069783e715f1 100644
2371 +--- a/drivers/gpu/drm/arm/malidp_hw.c
2372 ++++ b/drivers/gpu/drm/arm/malidp_hw.c
2373 +@@ -634,7 +634,8 @@ const struct malidp_hw malidp_device[MALIDP_MAX_DEVICES] = {
2374 + .vsync_irq = MALIDP500_DE_IRQ_VSYNC,
2375 + },
2376 + .se_irq_map = {
2377 +- .irq_mask = MALIDP500_SE_IRQ_CONF_MODE,
2378 ++ .irq_mask = MALIDP500_SE_IRQ_CONF_MODE |
2379 ++ MALIDP500_SE_IRQ_GLOBAL,
2380 + .vsync_irq = 0,
2381 + },
2382 + .dc_irq_map = {
2383 +diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
2384 +index 7a44897c50fe..29409a65d864 100644
2385 +--- a/drivers/gpu/drm/arm/malidp_planes.c
2386 ++++ b/drivers/gpu/drm/arm/malidp_planes.c
2387 +@@ -23,6 +23,7 @@
2388 +
2389 + /* Layer specific register offsets */
2390 + #define MALIDP_LAYER_FORMAT 0x000
2391 ++#define LAYER_FORMAT_MASK 0x3f
2392 + #define MALIDP_LAYER_CONTROL 0x004
2393 + #define LAYER_ENABLE (1 << 0)
2394 + #define LAYER_FLOWCFG_MASK 7
2395 +@@ -235,8 +236,8 @@ static int malidp_de_plane_check(struct drm_plane *plane,
2396 + if (state->rotation & MALIDP_ROTATED_MASK) {
2397 + int val;
2398 +
2399 +- val = mp->hwdev->hw->rotmem_required(mp->hwdev, state->crtc_h,
2400 +- state->crtc_w,
2401 ++ val = mp->hwdev->hw->rotmem_required(mp->hwdev, state->crtc_w,
2402 ++ state->crtc_h,
2403 + fb->format->format);
2404 + if (val < 0)
2405 + return val;
2406 +@@ -337,7 +338,9 @@ static void malidp_de_plane_update(struct drm_plane *plane,
2407 + dest_w = plane->state->crtc_w;
2408 + dest_h = plane->state->crtc_h;
2409 +
2410 +- malidp_hw_write(mp->hwdev, ms->format, mp->layer->base);
2411 ++ val = malidp_hw_read(mp->hwdev, mp->layer->base);
2412 ++ val = (val & ~LAYER_FORMAT_MASK) | ms->format;
2413 ++ malidp_hw_write(mp->hwdev, val, mp->layer->base);
2414 +
2415 + for (i = 0; i < ms->n_planes; i++) {
2416 + /* calculate the offset for the layer's plane registers */
2417 +diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
2418 +index 03eeee11dd5b..42a40daff132 100644
2419 +--- a/drivers/gpu/drm/armada/armada_crtc.c
2420 ++++ b/drivers/gpu/drm/armada/armada_crtc.c
2421 +@@ -519,8 +519,9 @@ static irqreturn_t armada_drm_irq(int irq, void *arg)
2422 + u32 v, stat = readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
2423 +
2424 + /*
2425 +- * This is rediculous - rather than writing bits to clear, we
2426 +- * have to set the actual status register value. This is racy.
2427 ++ * Reading the ISR appears to clear bits provided CLEAN_SPU_IRQ_ISR
2428 ++ * is set. Writing has some other effect to acknowledge the IRQ -
2429 ++ * without this, we only get a single IRQ.
2430 + */
2431 + writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
2432 +
2433 +@@ -1116,16 +1117,22 @@ armada_drm_crtc_set_property(struct drm_crtc *crtc,
2434 + static int armada_drm_crtc_enable_vblank(struct drm_crtc *crtc)
2435 + {
2436 + struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
2437 ++ unsigned long flags;
2438 +
2439 ++ spin_lock_irqsave(&dcrtc->irq_lock, flags);
2440 + armada_drm_crtc_enable_irq(dcrtc, VSYNC_IRQ_ENA);
2441 ++ spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
2442 + return 0;
2443 + }
2444 +
2445 + static void armada_drm_crtc_disable_vblank(struct drm_crtc *crtc)
2446 + {
2447 + struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
2448 ++ unsigned long flags;
2449 +
2450 ++ spin_lock_irqsave(&dcrtc->irq_lock, flags);
2451 + armada_drm_crtc_disable_irq(dcrtc, VSYNC_IRQ_ENA);
2452 ++ spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
2453 + }
2454 +
2455 + static const struct drm_crtc_funcs armada_crtc_funcs = {
2456 +@@ -1415,6 +1422,7 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
2457 + CFG_PDWN64x66, dcrtc->base + LCD_SPU_SRAM_PARA1);
2458 + writel_relaxed(0x2032ff81, dcrtc->base + LCD_SPU_DMA_CTRL1);
2459 + writel_relaxed(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
2460 ++ readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
2461 + writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
2462 +
2463 + ret = devm_request_irq(dev, irq, armada_drm_irq, 0, "armada_drm_crtc",
2464 +diff --git a/drivers/gpu/drm/armada/armada_hw.h b/drivers/gpu/drm/armada/armada_hw.h
2465 +index 27319a8335e2..345dc4d0851e 100644
2466 +--- a/drivers/gpu/drm/armada/armada_hw.h
2467 ++++ b/drivers/gpu/drm/armada/armada_hw.h
2468 +@@ -160,6 +160,7 @@ enum {
2469 + CFG_ALPHAM_GRA = 0x1 << 16,
2470 + CFG_ALPHAM_CFG = 0x2 << 16,
2471 + CFG_ALPHA_MASK = 0xff << 8,
2472 ++#define CFG_ALPHA(x) ((x) << 8)
2473 + CFG_PIXCMD_MASK = 0xff,
2474 + };
2475 +
2476 +diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
2477 +index c391955009d6..afa7ded3ae31 100644
2478 +--- a/drivers/gpu/drm/armada/armada_overlay.c
2479 ++++ b/drivers/gpu/drm/armada/armada_overlay.c
2480 +@@ -28,6 +28,7 @@ struct armada_ovl_plane_properties {
2481 + uint16_t contrast;
2482 + uint16_t saturation;
2483 + uint32_t colorkey_mode;
2484 ++ uint32_t colorkey_enable;
2485 + };
2486 +
2487 + struct armada_ovl_plane {
2488 +@@ -54,11 +55,13 @@ armada_ovl_update_attr(struct armada_ovl_plane_properties *prop,
2489 + writel_relaxed(0x00002000, dcrtc->base + LCD_SPU_CBSH_HUE);
2490 +
2491 + spin_lock_irq(&dcrtc->irq_lock);
2492 +- armada_updatel(prop->colorkey_mode | CFG_ALPHAM_GRA,
2493 +- CFG_CKMODE_MASK | CFG_ALPHAM_MASK | CFG_ALPHA_MASK,
2494 +- dcrtc->base + LCD_SPU_DMA_CTRL1);
2495 +-
2496 +- armada_updatel(ADV_GRACOLORKEY, 0, dcrtc->base + LCD_SPU_ADV_REG);
2497 ++ armada_updatel(prop->colorkey_mode,
2498 ++ CFG_CKMODE_MASK | CFG_ALPHAM_MASK | CFG_ALPHA_MASK,
2499 ++ dcrtc->base + LCD_SPU_DMA_CTRL1);
2500 ++ if (dcrtc->variant->has_spu_adv_reg)
2501 ++ armada_updatel(prop->colorkey_enable,
2502 ++ ADV_GRACOLORKEY | ADV_VIDCOLORKEY,
2503 ++ dcrtc->base + LCD_SPU_ADV_REG);
2504 + spin_unlock_irq(&dcrtc->irq_lock);
2505 + }
2506 +
2507 +@@ -321,8 +324,17 @@ static int armada_ovl_plane_set_property(struct drm_plane *plane,
2508 + dplane->prop.colorkey_vb |= K2B(val);
2509 + update_attr = true;
2510 + } else if (property == priv->colorkey_mode_prop) {
2511 +- dplane->prop.colorkey_mode &= ~CFG_CKMODE_MASK;
2512 +- dplane->prop.colorkey_mode |= CFG_CKMODE(val);
2513 ++ if (val == CKMODE_DISABLE) {
2514 ++ dplane->prop.colorkey_mode =
2515 ++ CFG_CKMODE(CKMODE_DISABLE) |
2516 ++ CFG_ALPHAM_CFG | CFG_ALPHA(255);
2517 ++ dplane->prop.colorkey_enable = 0;
2518 ++ } else {
2519 ++ dplane->prop.colorkey_mode =
2520 ++ CFG_CKMODE(val) |
2521 ++ CFG_ALPHAM_GRA | CFG_ALPHA(0);
2522 ++ dplane->prop.colorkey_enable = ADV_GRACOLORKEY;
2523 ++ }
2524 + update_attr = true;
2525 + } else if (property == priv->brightness_prop) {
2526 + dplane->prop.brightness = val - 256;
2527 +@@ -453,7 +465,9 @@ int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs)
2528 + dplane->prop.colorkey_yr = 0xfefefe00;
2529 + dplane->prop.colorkey_ug = 0x01010100;
2530 + dplane->prop.colorkey_vb = 0x01010100;
2531 +- dplane->prop.colorkey_mode = CFG_CKMODE(CKMODE_RGB);
2532 ++ dplane->prop.colorkey_mode = CFG_CKMODE(CKMODE_RGB) |
2533 ++ CFG_ALPHAM_GRA | CFG_ALPHA(0);
2534 ++ dplane->prop.colorkey_enable = ADV_GRACOLORKEY;
2535 + dplane->prop.brightness = 0;
2536 + dplane->prop.contrast = 0x4000;
2537 + dplane->prop.saturation = 0x4000;
2538 +diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
2539 +index 7ab36042a822..f1b33fc79fbb 100644
2540 +--- a/drivers/gpu/drm/bridge/sil-sii8620.c
2541 ++++ b/drivers/gpu/drm/bridge/sil-sii8620.c
2542 +@@ -36,8 +36,11 @@
2543 +
2544 + #define SII8620_BURST_BUF_LEN 288
2545 + #define VAL_RX_HDMI_CTRL2_DEFVAL VAL_RX_HDMI_CTRL2_IDLE_CNT(3)
2546 +-#define MHL1_MAX_LCLK 225000
2547 +-#define MHL3_MAX_LCLK 600000
2548 ++
2549 ++#define MHL1_MAX_PCLK 75000
2550 ++#define MHL1_MAX_PCLK_PP_MODE 150000
2551 ++#define MHL3_MAX_PCLK 200000
2552 ++#define MHL3_MAX_PCLK_PP_MODE 300000
2553 +
2554 + enum sii8620_mode {
2555 + CM_DISCONNECTED,
2556 +@@ -807,6 +810,7 @@ static void sii8620_burst_rx_all(struct sii8620 *ctx)
2557 + static void sii8620_fetch_edid(struct sii8620 *ctx)
2558 + {
2559 + u8 lm_ddc, ddc_cmd, int3, cbus;
2560 ++ unsigned long timeout;
2561 + int fetched, i;
2562 + int edid_len = EDID_LENGTH;
2563 + u8 *edid;
2564 +@@ -856,23 +860,31 @@ static void sii8620_fetch_edid(struct sii8620 *ctx)
2565 + REG_DDC_CMD, ddc_cmd | VAL_DDC_CMD_ENH_DDC_READ_NO_ACK
2566 + );
2567 +
2568 +- do {
2569 +- int3 = sii8620_readb(ctx, REG_INTR3);
2570 ++ int3 = 0;
2571 ++ timeout = jiffies + msecs_to_jiffies(200);
2572 ++ for (;;) {
2573 + cbus = sii8620_readb(ctx, REG_CBUS_STATUS);
2574 +-
2575 +- if (int3 & BIT_DDC_CMD_DONE)
2576 +- break;
2577 +-
2578 +- if (!(cbus & BIT_CBUS_STATUS_CBUS_CONNECTED)) {
2579 ++ if (~cbus & BIT_CBUS_STATUS_CBUS_CONNECTED) {
2580 ++ kfree(edid);
2581 ++ edid = NULL;
2582 ++ goto end;
2583 ++ }
2584 ++ if (int3 & BIT_DDC_CMD_DONE) {
2585 ++ if (sii8620_readb(ctx, REG_DDC_DOUT_CNT)
2586 ++ >= FETCH_SIZE)
2587 ++ break;
2588 ++ } else {
2589 ++ int3 = sii8620_readb(ctx, REG_INTR3);
2590 ++ }
2591 ++ if (time_is_before_jiffies(timeout)) {
2592 ++ ctx->error = -ETIMEDOUT;
2593 ++ dev_err(ctx->dev, "timeout during EDID read\n");
2594 + kfree(edid);
2595 + edid = NULL;
2596 + goto end;
2597 + }
2598 +- } while (1);
2599 +-
2600 +- sii8620_readb(ctx, REG_DDC_STATUS);
2601 +- while (sii8620_readb(ctx, REG_DDC_DOUT_CNT) < FETCH_SIZE)
2602 + usleep_range(10, 20);
2603 ++ }
2604 +
2605 + sii8620_read_buf(ctx, REG_DDC_DATA, edid + fetched, FETCH_SIZE);
2606 + if (fetched + FETCH_SIZE == EDID_LENGTH) {
2607 +@@ -1055,23 +1067,23 @@ static void sii8620_set_format(struct sii8620 *ctx)
2608 + BIT_M3_P0CTRL_MHL3_P0_PIXEL_MODE_PACKED,
2609 + ctx->use_packed_pixel ? ~0 : 0);
2610 + } else {
2611 +- if (ctx->use_packed_pixel)
2612 ++ if (ctx->use_packed_pixel) {
2613 + sii8620_write_seq_static(ctx,
2614 + REG_VID_MODE, BIT_VID_MODE_M1080P,
2615 + REG_MHL_TOP_CTL, BIT_MHL_TOP_CTL_MHL_PP_SEL | 1,
2616 + REG_MHLTX_CTL6, 0x60
2617 + );
2618 +- else
2619 ++ } else {
2620 + sii8620_write_seq_static(ctx,
2621 + REG_VID_MODE, 0,
2622 + REG_MHL_TOP_CTL, 1,
2623 + REG_MHLTX_CTL6, 0xa0
2624 + );
2625 ++ }
2626 + }
2627 +
2628 + if (ctx->use_packed_pixel)
2629 +- out_fmt = VAL_TPI_FORMAT(YCBCR422, FULL) |
2630 +- BIT_TPI_OUTPUT_CSCMODE709;
2631 ++ out_fmt = VAL_TPI_FORMAT(YCBCR422, FULL);
2632 + else
2633 + out_fmt = VAL_TPI_FORMAT(RGB, FULL);
2634 +
2635 +@@ -1216,7 +1228,7 @@ static void sii8620_start_video(struct sii8620 *ctx)
2636 + int clk = ctx->pixel_clock * (ctx->use_packed_pixel ? 2 : 3);
2637 + int i;
2638 +
2639 +- for (i = 0; i < ARRAY_SIZE(clk_spec); ++i)
2640 ++ for (i = 0; i < ARRAY_SIZE(clk_spec) - 1; ++i)
2641 + if (clk < clk_spec[i].max_clk)
2642 + break;
2643 +
2644 +@@ -2268,17 +2280,43 @@ static void sii8620_detach(struct drm_bridge *bridge)
2645 + rc_unregister_device(ctx->rc_dev);
2646 + }
2647 +
2648 ++static int sii8620_is_packing_required(struct sii8620 *ctx,
2649 ++ const struct drm_display_mode *mode)
2650 ++{
2651 ++ int max_pclk, max_pclk_pp_mode;
2652 ++
2653 ++ if (sii8620_is_mhl3(ctx)) {
2654 ++ max_pclk = MHL3_MAX_PCLK;
2655 ++ max_pclk_pp_mode = MHL3_MAX_PCLK_PP_MODE;
2656 ++ } else {
2657 ++ max_pclk = MHL1_MAX_PCLK;
2658 ++ max_pclk_pp_mode = MHL1_MAX_PCLK_PP_MODE;
2659 ++ }
2660 ++
2661 ++ if (mode->clock < max_pclk)
2662 ++ return 0;
2663 ++ else if (mode->clock < max_pclk_pp_mode)
2664 ++ return 1;
2665 ++ else
2666 ++ return -1;
2667 ++}
2668 ++
2669 + static enum drm_mode_status sii8620_mode_valid(struct drm_bridge *bridge,
2670 + const struct drm_display_mode *mode)
2671 + {
2672 + struct sii8620 *ctx = bridge_to_sii8620(bridge);
2673 ++ int pack_required = sii8620_is_packing_required(ctx, mode);
2674 + bool can_pack = ctx->devcap[MHL_DCAP_VID_LINK_MODE] &
2675 + MHL_DCAP_VID_LINK_PPIXEL;
2676 +- unsigned int max_pclk = sii8620_is_mhl3(ctx) ? MHL3_MAX_LCLK :
2677 +- MHL1_MAX_LCLK;
2678 +- max_pclk /= can_pack ? 2 : 3;
2679 +
2680 +- return (mode->clock > max_pclk) ? MODE_CLOCK_HIGH : MODE_OK;
2681 ++ switch (pack_required) {
2682 ++ case 0:
2683 ++ return MODE_OK;
2684 ++ case 1:
2685 ++ return (can_pack) ? MODE_OK : MODE_CLOCK_HIGH;
2686 ++ default:
2687 ++ return MODE_CLOCK_HIGH;
2688 ++ }
2689 + }
2690 +
2691 + static bool sii8620_mode_fixup(struct drm_bridge *bridge,
2692 +@@ -2286,43 +2324,16 @@ static bool sii8620_mode_fixup(struct drm_bridge *bridge,
2693 + struct drm_display_mode *adjusted_mode)
2694 + {
2695 + struct sii8620 *ctx = bridge_to_sii8620(bridge);
2696 +- int max_lclk;
2697 +- bool ret = true;
2698 +
2699 + mutex_lock(&ctx->lock);
2700 +
2701 +- max_lclk = sii8620_is_mhl3(ctx) ? MHL3_MAX_LCLK : MHL1_MAX_LCLK;
2702 +- if (max_lclk > 3 * adjusted_mode->clock) {
2703 +- ctx->use_packed_pixel = 0;
2704 +- goto end;
2705 +- }
2706 +- if ((ctx->devcap[MHL_DCAP_VID_LINK_MODE] & MHL_DCAP_VID_LINK_PPIXEL) &&
2707 +- max_lclk > 2 * adjusted_mode->clock) {
2708 +- ctx->use_packed_pixel = 1;
2709 +- goto end;
2710 +- }
2711 +- ret = false;
2712 +-end:
2713 +- if (ret) {
2714 +- u8 vic = drm_match_cea_mode(adjusted_mode);
2715 +-
2716 +- if (!vic) {
2717 +- union hdmi_infoframe frm;
2718 +- u8 mhl_vic[] = { 0, 95, 94, 93, 98 };
2719 +-
2720 +- /* FIXME: We need the connector here */
2721 +- drm_hdmi_vendor_infoframe_from_display_mode(
2722 +- &frm.vendor.hdmi, NULL, adjusted_mode);
2723 +- vic = frm.vendor.hdmi.vic;
2724 +- if (vic >= ARRAY_SIZE(mhl_vic))
2725 +- vic = 0;
2726 +- vic = mhl_vic[vic];
2727 +- }
2728 +- ctx->video_code = vic;
2729 +- ctx->pixel_clock = adjusted_mode->clock;
2730 +- }
2731 ++ ctx->use_packed_pixel = sii8620_is_packing_required(ctx, adjusted_mode);
2732 ++ ctx->video_code = drm_match_cea_mode(adjusted_mode);
2733 ++ ctx->pixel_clock = adjusted_mode->clock;
2734 ++
2735 + mutex_unlock(&ctx->lock);
2736 +- return ret;
2737 ++
2738 ++ return true;
2739 + }
2740 +
2741 + static const struct drm_bridge_funcs sii8620_bridge_funcs = {
2742 +diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
2743 +index 1c330f2a7a5d..7acfd0ed79cb 100644
2744 +--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
2745 ++++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
2746 +@@ -260,7 +260,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
2747 + unsigned long val;
2748 +
2749 + val = readl(ctx->addr + DECON_WINCONx(win));
2750 +- val &= ~WINCONx_BPPMODE_MASK;
2751 ++ val &= WINCONx_ENWIN_F;
2752 +
2753 + switch (fb->format->format) {
2754 + case DRM_FORMAT_XRGB1555:
2755 +@@ -351,8 +351,8 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
2756 + writel(val, ctx->addr + DECON_VIDOSDxB(win));
2757 + }
2758 +
2759 +- val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
2760 +- VIDOSD_Wx_ALPHA_B_F(0x0);
2761 ++ val = VIDOSD_Wx_ALPHA_R_F(0xff) | VIDOSD_Wx_ALPHA_G_F(0xff) |
2762 ++ VIDOSD_Wx_ALPHA_B_F(0xff);
2763 + writel(val, ctx->addr + DECON_VIDOSDxC(win));
2764 +
2765 + val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
2766 +diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
2767 +index 0506b2b17ac1..48f913d8208c 100644
2768 +--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
2769 ++++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
2770 +@@ -532,21 +532,25 @@ static int gsc_src_set_fmt(struct device *dev, u32 fmt)
2771 + GSC_IN_CHROMA_ORDER_CRCB);
2772 + break;
2773 + case DRM_FORMAT_NV21:
2774 ++ cfg |= (GSC_IN_CHROMA_ORDER_CRCB | GSC_IN_YUV420_2P);
2775 ++ break;
2776 + case DRM_FORMAT_NV61:
2777 +- cfg |= (GSC_IN_CHROMA_ORDER_CRCB |
2778 +- GSC_IN_YUV420_2P);
2779 ++ cfg |= (GSC_IN_CHROMA_ORDER_CRCB | GSC_IN_YUV422_2P);
2780 + break;
2781 + case DRM_FORMAT_YUV422:
2782 + cfg |= GSC_IN_YUV422_3P;
2783 + break;
2784 + case DRM_FORMAT_YUV420:
2785 ++ cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV420_3P);
2786 ++ break;
2787 + case DRM_FORMAT_YVU420:
2788 +- cfg |= GSC_IN_YUV420_3P;
2789 ++ cfg |= (GSC_IN_CHROMA_ORDER_CRCB | GSC_IN_YUV420_3P);
2790 + break;
2791 + case DRM_FORMAT_NV12:
2792 ++ cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV420_2P);
2793 ++ break;
2794 + case DRM_FORMAT_NV16:
2795 +- cfg |= (GSC_IN_CHROMA_ORDER_CBCR |
2796 +- GSC_IN_YUV420_2P);
2797 ++ cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV422_2P);
2798 + break;
2799 + default:
2800 + dev_err(ippdrv->dev, "invalid target yuv order 0x%x.\n", fmt);
2801 +@@ -806,18 +810,25 @@ static int gsc_dst_set_fmt(struct device *dev, u32 fmt)
2802 + GSC_OUT_CHROMA_ORDER_CRCB);
2803 + break;
2804 + case DRM_FORMAT_NV21:
2805 +- case DRM_FORMAT_NV61:
2806 + cfg |= (GSC_OUT_CHROMA_ORDER_CRCB | GSC_OUT_YUV420_2P);
2807 + break;
2808 ++ case DRM_FORMAT_NV61:
2809 ++ cfg |= (GSC_OUT_CHROMA_ORDER_CRCB | GSC_OUT_YUV422_2P);
2810 ++ break;
2811 + case DRM_FORMAT_YUV422:
2812 ++ cfg |= GSC_OUT_YUV422_3P;
2813 ++ break;
2814 + case DRM_FORMAT_YUV420:
2815 ++ cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV420_3P);
2816 ++ break;
2817 + case DRM_FORMAT_YVU420:
2818 +- cfg |= GSC_OUT_YUV420_3P;
2819 ++ cfg |= (GSC_OUT_CHROMA_ORDER_CRCB | GSC_OUT_YUV420_3P);
2820 + break;
2821 + case DRM_FORMAT_NV12:
2822 ++ cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV420_2P);
2823 ++ break;
2824 + case DRM_FORMAT_NV16:
2825 +- cfg |= (GSC_OUT_CHROMA_ORDER_CBCR |
2826 +- GSC_OUT_YUV420_2P);
2827 ++ cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV422_2P);
2828 + break;
2829 + default:
2830 + dev_err(ippdrv->dev, "invalid target yuv order 0x%x.\n", fmt);
2831 +diff --git a/drivers/gpu/drm/exynos/regs-gsc.h b/drivers/gpu/drm/exynos/regs-gsc.h
2832 +index 4704a993cbb7..16b39734115c 100644
2833 +--- a/drivers/gpu/drm/exynos/regs-gsc.h
2834 ++++ b/drivers/gpu/drm/exynos/regs-gsc.h
2835 +@@ -138,6 +138,7 @@
2836 + #define GSC_OUT_YUV420_3P (3 << 4)
2837 + #define GSC_OUT_YUV422_1P (4 << 4)
2838 + #define GSC_OUT_YUV422_2P (5 << 4)
2839 ++#define GSC_OUT_YUV422_3P (6 << 4)
2840 + #define GSC_OUT_YUV444 (7 << 4)
2841 + #define GSC_OUT_TILE_TYPE_MASK (1 << 2)
2842 + #define GSC_OUT_TILE_C_16x8 (0 << 2)
2843 +diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
2844 +index 1466d8769ec9..857a647fabf2 100644
2845 +--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
2846 ++++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
2847 +@@ -43,6 +43,8 @@
2848 + #include <linux/mdev.h>
2849 + #include <linux/debugfs.h>
2850 +
2851 ++#include <linux/nospec.h>
2852 ++
2853 + #include "i915_drv.h"
2854 + #include "gvt.h"
2855 +
2856 +@@ -1064,7 +1066,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
2857 + } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) {
2858 + struct vfio_region_info info;
2859 + struct vfio_info_cap caps = { .buf = NULL, .size = 0 };
2860 +- int i, ret;
2861 ++ unsigned int i;
2862 ++ int ret;
2863 + struct vfio_region_info_cap_sparse_mmap *sparse = NULL;
2864 + size_t size;
2865 + int nr_areas = 1;
2866 +@@ -1149,6 +1152,10 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
2867 + if (info.index >= VFIO_PCI_NUM_REGIONS +
2868 + vgpu->vdev.num_regions)
2869 + return -EINVAL;
2870 ++ info.index =
2871 ++ array_index_nospec(info.index,
2872 ++ VFIO_PCI_NUM_REGIONS +
2873 ++ vgpu->vdev.num_regions);
2874 +
2875 + i = info.index - VFIO_PCI_NUM_REGIONS;
2876 +
2877 +diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
2878 +index 707e02c80f18..95dfd169ef57 100644
2879 +--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
2880 ++++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
2881 +@@ -617,7 +617,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
2882 + struct nouveau_bo *nvbo;
2883 + uint32_t data;
2884 +
2885 +- if (unlikely(r->bo_index > req->nr_buffers)) {
2886 ++ if (unlikely(r->bo_index >= req->nr_buffers)) {
2887 + NV_PRINTK(err, cli, "reloc bo index invalid\n");
2888 + ret = -EINVAL;
2889 + break;
2890 +@@ -627,7 +627,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
2891 + if (b->presumed.valid)
2892 + continue;
2893 +
2894 +- if (unlikely(r->reloc_bo_index > req->nr_buffers)) {
2895 ++ if (unlikely(r->reloc_bo_index >= req->nr_buffers)) {
2896 + NV_PRINTK(err, cli, "reloc container bo index invalid\n");
2897 + ret = -EINVAL;
2898 + break;
2899 +diff --git a/drivers/gpu/drm/sun4i/Makefile b/drivers/gpu/drm/sun4i/Makefile
2900 +index 330843ce4280..a27ade6cf2bf 100644
2901 +--- a/drivers/gpu/drm/sun4i/Makefile
2902 ++++ b/drivers/gpu/drm/sun4i/Makefile
2903 +@@ -29,7 +29,10 @@ obj-$(CONFIG_DRM_SUN4I) += sun4i-tcon.o
2904 + obj-$(CONFIG_DRM_SUN4I) += sun4i_tv.o
2905 + obj-$(CONFIG_DRM_SUN4I) += sun6i_drc.o
2906 +
2907 +-obj-$(CONFIG_DRM_SUN4I_BACKEND) += sun4i-backend.o sun4i-frontend.o
2908 ++obj-$(CONFIG_DRM_SUN4I_BACKEND) += sun4i-backend.o
2909 ++ifdef CONFIG_DRM_SUN4I_BACKEND
2910 ++obj-$(CONFIG_DRM_SUN4I) += sun4i-frontend.o
2911 ++endif
2912 + obj-$(CONFIG_DRM_SUN4I_HDMI) += sun4i-drm-hdmi.o
2913 + obj-$(CONFIG_DRM_SUN8I_DW_HDMI) += sun8i-drm-hdmi.o
2914 + obj-$(CONFIG_DRM_SUN8I_MIXER) += sun8i-mixer.o
2915 +diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
2916 +index 7afe2f635f74..500b7c5b6672 100644
2917 +--- a/drivers/gpu/drm/tegra/drm.c
2918 ++++ b/drivers/gpu/drm/tegra/drm.c
2919 +@@ -436,7 +436,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
2920 + * unaligned offset is malformed and cause commands stream
2921 + * corruption on the buffer address relocation.
2922 + */
2923 +- if (offset & 3 || offset >= obj->gem.size) {
2924 ++ if (offset & 3 || offset > obj->gem.size) {
2925 + err = -EINVAL;
2926 + goto fail;
2927 + }
2928 +diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
2929 +index f1d5f76e9c33..d88073e7d22d 100644
2930 +--- a/drivers/gpu/host1x/dev.c
2931 ++++ b/drivers/gpu/host1x/dev.c
2932 +@@ -218,6 +218,9 @@ static int host1x_probe(struct platform_device *pdev)
2933 + return err;
2934 + }
2935 +
2936 ++ if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL))
2937 ++ goto skip_iommu;
2938 ++
2939 + host->group = iommu_group_get(&pdev->dev);
2940 + if (host->group) {
2941 + struct iommu_domain_geometry *geometry;
2942 +diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c
2943 +index db509ab8874e..acd99783bbca 100644
2944 +--- a/drivers/gpu/host1x/job.c
2945 ++++ b/drivers/gpu/host1x/job.c
2946 +@@ -686,7 +686,8 @@ void host1x_job_unpin(struct host1x_job *job)
2947 + for (i = 0; i < job->num_unpins; i++) {
2948 + struct host1x_job_unpin_data *unpin = &job->unpins[i];
2949 +
2950 +- if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) && host->domain) {
2951 ++ if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) &&
2952 ++ unpin->size && host->domain) {
2953 + iommu_unmap(host->domain, job->addr_phys[i],
2954 + unpin->size);
2955 + free_iova(&host->iova,
2956 +diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c
2957 +index 7b8e17b03cb8..6bf4da7ad63a 100644
2958 +--- a/drivers/hid/hid-google-hammer.c
2959 ++++ b/drivers/hid/hid-google-hammer.c
2960 +@@ -124,6 +124,8 @@ static const struct hid_device_id hammer_devices[] = {
2961 + USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_STAFF) },
2962 + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
2963 + USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_WAND) },
2964 ++ { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
2965 ++ USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_WHISKERS) },
2966 + { }
2967 + };
2968 + MODULE_DEVICE_TABLE(hid, hammer_devices);
2969 +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
2970 +index 46f5ecd11bf7..5a8b3362cf65 100644
2971 +--- a/drivers/hid/hid-ids.h
2972 ++++ b/drivers/hid/hid-ids.h
2973 +@@ -452,6 +452,7 @@
2974 + #define USB_DEVICE_ID_GOOGLE_TOUCH_ROSE 0x5028
2975 + #define USB_DEVICE_ID_GOOGLE_STAFF 0x502b
2976 + #define USB_DEVICE_ID_GOOGLE_WAND 0x502d
2977 ++#define USB_DEVICE_ID_GOOGLE_WHISKERS 0x5030
2978 +
2979 + #define USB_VENDOR_ID_GOTOP 0x08f2
2980 + #define USB_DEVICE_ID_SUPER_Q2 0x007f
2981 +diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
2982 +index 5f947ec20dcb..815a7b0b88cd 100644
2983 +--- a/drivers/hid/wacom_wac.c
2984 ++++ b/drivers/hid/wacom_wac.c
2985 +@@ -3361,8 +3361,14 @@ void wacom_setup_device_quirks(struct wacom *wacom)
2986 + if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
2987 + features->device_type |= WACOM_DEVICETYPE_PAD;
2988 +
2989 +- features->x_max = 4096;
2990 +- features->y_max = 4096;
2991 ++ if (features->type == INTUOSHT2) {
2992 ++ features->x_max = features->x_max / 10;
2993 ++ features->y_max = features->y_max / 10;
2994 ++ }
2995 ++ else {
2996 ++ features->x_max = 4096;
2997 ++ features->y_max = 4096;
2998 ++ }
2999 + }
3000 + else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3001 + features->device_type |= WACOM_DEVICETYPE_PAD;
3002 +diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
3003 +index bf3bb7e1adab..9d3ef879dc51 100644
3004 +--- a/drivers/hwmon/dell-smm-hwmon.c
3005 ++++ b/drivers/hwmon/dell-smm-hwmon.c
3006 +@@ -1074,6 +1074,13 @@ static struct dmi_system_id i8k_blacklist_fan_support_dmi_table[] __initdata = {
3007 + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Vostro 3360"),
3008 + },
3009 + },
3010 ++ {
3011 ++ .ident = "Dell XPS13 9333",
3012 ++ .matches = {
3013 ++ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
3014 ++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "XPS13 9333"),
3015 ++ },
3016 ++ },
3017 + { }
3018 + };
3019 +
3020 +diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
3021 +index aebce560bfaf..b14eb73bc3c9 100644
3022 +--- a/drivers/hwmon/nct6775.c
3023 ++++ b/drivers/hwmon/nct6775.c
3024 +@@ -4175,7 +4175,7 @@ static int nct6775_probe(struct platform_device *pdev)
3025 + * The temperature is already monitored if the respective bit in <mask>
3026 + * is set.
3027 + */
3028 +- for (i = 0; i < 32; i++) {
3029 ++ for (i = 0; i < 31; i++) {
3030 + if (!(data->temp_mask & BIT(i + 1)))
3031 + continue;
3032 + if (!reg_temp_alternate[i])
3033 +diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
3034 +index 6fca5e64cffb..f83405d3e8c2 100644
3035 +--- a/drivers/i2c/busses/i2c-imx.c
3036 ++++ b/drivers/i2c/busses/i2c-imx.c
3037 +@@ -677,9 +677,6 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx,
3038 + struct imx_i2c_dma *dma = i2c_imx->dma;
3039 + struct device *dev = &i2c_imx->adapter.dev;
3040 +
3041 +- temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
3042 +- temp |= I2CR_DMAEN;
3043 +- imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
3044 +
3045 + dma->chan_using = dma->chan_rx;
3046 + dma->dma_transfer_dir = DMA_DEV_TO_MEM;
3047 +@@ -792,6 +789,7 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, bo
3048 + int i, result;
3049 + unsigned int temp;
3050 + int block_data = msgs->flags & I2C_M_RECV_LEN;
3051 ++ int use_dma = i2c_imx->dma && msgs->len >= DMA_THRESHOLD && !block_data;
3052 +
3053 + dev_dbg(&i2c_imx->adapter.dev,
3054 + "<%s> write slave address: addr=0x%x\n",
3055 +@@ -818,12 +816,14 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, bo
3056 + */
3057 + if ((msgs->len - 1) || block_data)
3058 + temp &= ~I2CR_TXAK;
3059 ++ if (use_dma)
3060 ++ temp |= I2CR_DMAEN;
3061 + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
3062 + imx_i2c_read_reg(i2c_imx, IMX_I2C_I2DR); /* dummy read */
3063 +
3064 + dev_dbg(&i2c_imx->adapter.dev, "<%s> read data\n", __func__);
3065 +
3066 +- if (i2c_imx->dma && msgs->len >= DMA_THRESHOLD && !block_data)
3067 ++ if (use_dma)
3068 + return i2c_imx_dma_read(i2c_imx, msgs, is_lastmsg);
3069 +
3070 + /* read data */
3071 +diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
3072 +index 7c3b4740b94b..b8f303dea305 100644
3073 +--- a/drivers/i2c/i2c-core-acpi.c
3074 ++++ b/drivers/i2c/i2c-core-acpi.c
3075 +@@ -482,11 +482,16 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
3076 + msgs[0].buf = buffer;
3077 +
3078 + ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
3079 +- if (ret < 0)
3080 +- dev_err(&client->adapter->dev, "i2c write failed\n");
3081 +
3082 + kfree(buffer);
3083 +- return ret;
3084 ++
3085 ++ if (ret < 0) {
3086 ++ dev_err(&client->adapter->dev, "i2c write failed: %d\n", ret);
3087 ++ return ret;
3088 ++ }
3089 ++
3090 ++ /* 1 transfer must have completed successfully */
3091 ++ return (ret == 1) ? 0 : -EIO;
3092 + }
3093 +
3094 + static acpi_status
3095 +diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
3096 +index 5ec3e41b65f2..fe87d27779d9 100644
3097 +--- a/drivers/iio/pressure/bmp280-core.c
3098 ++++ b/drivers/iio/pressure/bmp280-core.c
3099 +@@ -415,10 +415,9 @@ static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2)
3100 + }
3101 + comp_humidity = bmp280_compensate_humidity(data, adc_humidity);
3102 +
3103 +- *val = comp_humidity;
3104 +- *val2 = 1024;
3105 ++ *val = comp_humidity * 1000 / 1024;
3106 +
3107 +- return IIO_VAL_FRACTIONAL;
3108 ++ return IIO_VAL_INT;
3109 + }
3110 +
3111 + static int bmp280_read_raw(struct iio_dev *indio_dev,
3112 +diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
3113 +index ed1f253faf97..c7c85c22e4e3 100644
3114 +--- a/drivers/infiniband/hw/mlx4/mr.c
3115 ++++ b/drivers/infiniband/hw/mlx4/mr.c
3116 +@@ -486,8 +486,11 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
3117 + }
3118 +
3119 + if (flags & IB_MR_REREG_ACCESS) {
3120 +- if (ib_access_writable(mr_access_flags) && !mmr->umem->writable)
3121 +- return -EPERM;
3122 ++ if (ib_access_writable(mr_access_flags) &&
3123 ++ !mmr->umem->writable) {
3124 ++ err = -EPERM;
3125 ++ goto release_mpt_entry;
3126 ++ }
3127 +
3128 + err = mlx4_mr_hw_change_access(dev->dev, *pmpt_entry,
3129 + convert_access(mr_access_flags));
3130 +diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
3131 +index 3c7522d025f2..93d67d97c279 100644
3132 +--- a/drivers/infiniband/hw/mlx5/srq.c
3133 ++++ b/drivers/infiniband/hw/mlx5/srq.c
3134 +@@ -266,18 +266,24 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
3135 +
3136 + desc_size = sizeof(struct mlx5_wqe_srq_next_seg) +
3137 + srq->msrq.max_gs * sizeof(struct mlx5_wqe_data_seg);
3138 +- if (desc_size == 0 || srq->msrq.max_gs > desc_size)
3139 +- return ERR_PTR(-EINVAL);
3140 ++ if (desc_size == 0 || srq->msrq.max_gs > desc_size) {
3141 ++ err = -EINVAL;
3142 ++ goto err_srq;
3143 ++ }
3144 + desc_size = roundup_pow_of_two(desc_size);
3145 + desc_size = max_t(size_t, 32, desc_size);
3146 +- if (desc_size < sizeof(struct mlx5_wqe_srq_next_seg))
3147 +- return ERR_PTR(-EINVAL);
3148 ++ if (desc_size < sizeof(struct mlx5_wqe_srq_next_seg)) {
3149 ++ err = -EINVAL;
3150 ++ goto err_srq;
3151 ++ }
3152 + srq->msrq.max_avail_gather = (desc_size - sizeof(struct mlx5_wqe_srq_next_seg)) /
3153 + sizeof(struct mlx5_wqe_data_seg);
3154 + srq->msrq.wqe_shift = ilog2(desc_size);
3155 + buf_size = srq->msrq.max * desc_size;
3156 +- if (buf_size < desc_size)
3157 +- return ERR_PTR(-EINVAL);
3158 ++ if (buf_size < desc_size) {
3159 ++ err = -EINVAL;
3160 ++ goto err_srq;
3161 ++ }
3162 + in.type = init_attr->srq_type;
3163 +
3164 + if (pd->uobject)
3165 +diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
3166 +index 3f9afc02d166..f86223aca7b8 100644
3167 +--- a/drivers/infiniband/hw/qedr/verbs.c
3168 ++++ b/drivers/infiniband/hw/qedr/verbs.c
3169 +@@ -1957,6 +1957,9 @@ int qedr_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
3170 + }
3171 +
3172 + if (attr_mask & (IB_QP_AV | IB_QP_PATH_MTU)) {
3173 ++ if (rdma_protocol_iwarp(&dev->ibdev, 1))
3174 ++ return -EINVAL;
3175 ++
3176 + if (attr_mask & IB_QP_PATH_MTU) {
3177 + if (attr->path_mtu < IB_MTU_256 ||
3178 + attr->path_mtu > IB_MTU_4096) {
3179 +diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c
3180 +index 785199990457..d048ac13e65b 100644
3181 +--- a/drivers/infiniband/sw/rxe/rxe_req.c
3182 ++++ b/drivers/infiniband/sw/rxe/rxe_req.c
3183 +@@ -645,6 +645,9 @@ next_wqe:
3184 + } else {
3185 + goto exit;
3186 + }
3187 ++ if ((wqe->wr.send_flags & IB_SEND_SIGNALED) ||
3188 ++ qp->sq_sig_type == IB_SIGNAL_ALL_WR)
3189 ++ rxe_run_task(&qp->comp.task, 1);
3190 + qp->req.wqe_index = next_index(qp->sq.queue,
3191 + qp->req.wqe_index);
3192 + goto next_wqe;
3193 +@@ -709,6 +712,7 @@ next_wqe:
3194 +
3195 + if (fill_packet(qp, wqe, &pkt, skb, payload)) {
3196 + pr_debug("qp#%d Error during fill packet\n", qp_num(qp));
3197 ++ kfree_skb(skb);
3198 + goto err;
3199 + }
3200 +
3201 +@@ -740,7 +744,6 @@ next_wqe:
3202 + goto next_wqe;
3203 +
3204 + err:
3205 +- kfree_skb(skb);
3206 + wqe->status = IB_WC_LOC_PROT_ERR;
3207 + wqe->state = wqe_state_error;
3208 + __rxe_do_task(&qp->comp.task);
3209 +diff --git a/drivers/input/rmi4/rmi_2d_sensor.c b/drivers/input/rmi4/rmi_2d_sensor.c
3210 +index 8bb866c7b985..8eeffa066022 100644
3211 +--- a/drivers/input/rmi4/rmi_2d_sensor.c
3212 ++++ b/drivers/input/rmi4/rmi_2d_sensor.c
3213 +@@ -32,15 +32,15 @@ void rmi_2d_sensor_abs_process(struct rmi_2d_sensor *sensor,
3214 + if (obj->type == RMI_2D_OBJECT_NONE)
3215 + return;
3216 +
3217 +- if (axis_align->swap_axes)
3218 +- swap(obj->x, obj->y);
3219 +-
3220 + if (axis_align->flip_x)
3221 + obj->x = sensor->max_x - obj->x;
3222 +
3223 + if (axis_align->flip_y)
3224 + obj->y = sensor->max_y - obj->y;
3225 +
3226 ++ if (axis_align->swap_axes)
3227 ++ swap(obj->x, obj->y);
3228 ++
3229 + /*
3230 + * Here checking if X offset or y offset are specified is
3231 + * redundant. We just add the offsets or clip the values.
3232 +@@ -120,15 +120,15 @@ void rmi_2d_sensor_rel_report(struct rmi_2d_sensor *sensor, int x, int y)
3233 + x = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)x));
3234 + y = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)y));
3235 +
3236 +- if (axis_align->swap_axes)
3237 +- swap(x, y);
3238 +-
3239 + if (axis_align->flip_x)
3240 + x = min(RMI_2D_REL_POS_MAX, -x);
3241 +
3242 + if (axis_align->flip_y)
3243 + y = min(RMI_2D_REL_POS_MAX, -y);
3244 +
3245 ++ if (axis_align->swap_axes)
3246 ++ swap(x, y);
3247 ++
3248 + if (x || y) {
3249 + input_report_rel(sensor->input, REL_X, x);
3250 + input_report_rel(sensor->input, REL_Y, y);
3251 +@@ -141,17 +141,10 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
3252 + struct input_dev *input = sensor->input;
3253 + int res_x;
3254 + int res_y;
3255 ++ int max_x, max_y;
3256 + int input_flags = 0;
3257 +
3258 + if (sensor->report_abs) {
3259 +- if (sensor->axis_align.swap_axes) {
3260 +- swap(sensor->max_x, sensor->max_y);
3261 +- swap(sensor->axis_align.clip_x_low,
3262 +- sensor->axis_align.clip_y_low);
3263 +- swap(sensor->axis_align.clip_x_high,
3264 +- sensor->axis_align.clip_y_high);
3265 +- }
3266 +-
3267 + sensor->min_x = sensor->axis_align.clip_x_low;
3268 + if (sensor->axis_align.clip_x_high)
3269 + sensor->max_x = min(sensor->max_x,
3270 +@@ -163,14 +156,19 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
3271 + sensor->axis_align.clip_y_high);
3272 +
3273 + set_bit(EV_ABS, input->evbit);
3274 +- input_set_abs_params(input, ABS_MT_POSITION_X, 0, sensor->max_x,
3275 +- 0, 0);
3276 +- input_set_abs_params(input, ABS_MT_POSITION_Y, 0, sensor->max_y,
3277 +- 0, 0);
3278 ++
3279 ++ max_x = sensor->max_x;
3280 ++ max_y = sensor->max_y;
3281 ++ if (sensor->axis_align.swap_axes)
3282 ++ swap(max_x, max_y);
3283 ++ input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_x, 0, 0);
3284 ++ input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
3285 +
3286 + if (sensor->x_mm && sensor->y_mm) {
3287 + res_x = (sensor->max_x - sensor->min_x) / sensor->x_mm;
3288 + res_y = (sensor->max_y - sensor->min_y) / sensor->y_mm;
3289 ++ if (sensor->axis_align.swap_axes)
3290 ++ swap(res_x, res_y);
3291 +
3292 + input_abs_set_res(input, ABS_X, res_x);
3293 + input_abs_set_res(input, ABS_Y, res_y);
3294 +diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
3295 +index 1ff38aff9f29..29dd8a9939b1 100644
3296 +--- a/drivers/irqchip/irq-gic-v2m.c
3297 ++++ b/drivers/irqchip/irq-gic-v2m.c
3298 +@@ -199,7 +199,7 @@ static int gicv2m_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
3299 +
3300 + fail:
3301 + irq_domain_free_irqs_parent(domain, virq, nr_irqs);
3302 +- gicv2m_unalloc_msi(v2m, hwirq, get_count_order(nr_irqs));
3303 ++ gicv2m_unalloc_msi(v2m, hwirq, nr_irqs);
3304 + return err;
3305 + }
3306 +
3307 +diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
3308 +index ab16968fced8..bb1580077054 100644
3309 +--- a/drivers/irqchip/irq-gic-v3-its.c
3310 ++++ b/drivers/irqchip/irq-gic-v3-its.c
3311 +@@ -3405,6 +3405,16 @@ static int redist_disable_lpis(void)
3312 + u64 timeout = USEC_PER_SEC;
3313 + u64 val;
3314 +
3315 ++ /*
3316 ++ * If coming via a CPU hotplug event, we don't need to disable
3317 ++ * LPIs before trying to re-enable them. They are already
3318 ++ * configured and all is well in the world. Detect this case
3319 ++ * by checking the allocation of the pending table for the
3320 ++ * current CPU.
3321 ++ */
3322 ++ if (gic_data_rdist()->pend_page)
3323 ++ return 0;
3324 ++
3325 + if (!gic_rdists_supports_plpis()) {
3326 + pr_info("CPU%d: LPIs not supported\n", smp_processor_id());
3327 + return -ENXIO;
3328 +diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
3329 +index 3c60774c8430..61dffc7bf6bf 100644
3330 +--- a/drivers/md/raid10.c
3331 ++++ b/drivers/md/raid10.c
3332 +@@ -3892,6 +3892,13 @@ static int raid10_run(struct mddev *mddev)
3333 + disk->rdev->saved_raid_disk < 0)
3334 + conf->fullsync = 1;
3335 + }
3336 ++
3337 ++ if (disk->replacement &&
3338 ++ !test_bit(In_sync, &disk->replacement->flags) &&
3339 ++ disk->replacement->saved_raid_disk < 0) {
3340 ++ conf->fullsync = 1;
3341 ++ }
3342 ++
3343 + disk->recovery_disabled = mddev->recovery_disabled - 1;
3344 + }
3345 +
3346 +diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
3347 +index aaaeaae01e1d..eeff2285fb8b 100644
3348 +--- a/drivers/mtd/devices/mtd_dataflash.c
3349 ++++ b/drivers/mtd/devices/mtd_dataflash.c
3350 +@@ -733,8 +733,8 @@ static struct flash_info dataflash_data[] = {
3351 + { "AT45DB642x", 0x1f2800, 8192, 1056, 11, SUP_POW2PS},
3352 + { "at45db642d", 0x1f2800, 8192, 1024, 10, SUP_POW2PS | IS_POW2PS},
3353 +
3354 +- { "AT45DB641E", 0x1f28000100, 32768, 264, 9, SUP_EXTID | SUP_POW2PS},
3355 +- { "at45db641e", 0x1f28000100, 32768, 256, 8, SUP_EXTID | SUP_POW2PS | IS_POW2PS},
3356 ++ { "AT45DB641E", 0x1f28000100ULL, 32768, 264, 9, SUP_EXTID | SUP_POW2PS},
3357 ++ { "at45db641e", 0x1f28000100ULL, 32768, 256, 8, SUP_EXTID | SUP_POW2PS | IS_POW2PS},
3358 + };
3359 +
3360 + static struct flash_info *jedec_lookup(struct spi_device *spi,
3361 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
3362 +index d847e1b9c37b..be1506169076 100644
3363 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
3364 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
3365 +@@ -1533,6 +1533,7 @@ struct bnx2x {
3366 + struct link_vars link_vars;
3367 + u32 link_cnt;
3368 + struct bnx2x_link_report_data last_reported_link;
3369 ++ bool force_link_down;
3370 +
3371 + struct mdio_if_info mdio;
3372 +
3373 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
3374 +index 95871576ab92..e7b305efa3fe 100644
3375 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
3376 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
3377 +@@ -1261,6 +1261,11 @@ void __bnx2x_link_report(struct bnx2x *bp)
3378 + {
3379 + struct bnx2x_link_report_data cur_data;
3380 +
3381 ++ if (bp->force_link_down) {
3382 ++ bp->link_vars.link_up = 0;
3383 ++ return;
3384 ++ }
3385 ++
3386 + /* reread mf_cfg */
3387 + if (IS_PF(bp) && !CHIP_IS_E1(bp))
3388 + bnx2x_read_mf_cfg(bp);
3389 +@@ -2817,6 +2822,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
3390 + bp->pending_max = 0;
3391 + }
3392 +
3393 ++ bp->force_link_down = false;
3394 + if (bp->port.pmf) {
3395 + rc = bnx2x_initial_phy_init(bp, load_mode);
3396 + if (rc)
3397 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
3398 +index c766ae23bc74..89484efbaba4 100644
3399 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
3400 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
3401 +@@ -10279,6 +10279,12 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work)
3402 + bp->sp_rtnl_state = 0;
3403 + smp_mb();
3404 +
3405 ++ /* Immediately indicate link as down */
3406 ++ bp->link_vars.link_up = 0;
3407 ++ bp->force_link_down = true;
3408 ++ netif_carrier_off(bp->dev);
3409 ++ BNX2X_ERR("Indicating link is down due to Tx-timeout\n");
3410 ++
3411 + bnx2x_nic_unload(bp, UNLOAD_NORMAL, true);
3412 + /* When ret value shows failure of allocation failure,
3413 + * the nic is rebooted again. If open still fails, a error
3414 +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
3415 +index 401e58939795..cb026e500127 100644
3416 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
3417 ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
3418 +@@ -5915,7 +5915,7 @@ unsigned int bnxt_get_max_func_irqs(struct bnxt *bp)
3419 + return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_cp_rings);
3420 + }
3421 +
3422 +-void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max_irqs)
3423 ++static void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max_irqs)
3424 + {
3425 + bp->hw_resc.max_irqs = max_irqs;
3426 + }
3427 +@@ -6875,7 +6875,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
3428 + rc = bnxt_request_irq(bp);
3429 + if (rc) {
3430 + netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc);
3431 +- goto open_err;
3432 ++ goto open_err_irq;
3433 + }
3434 + }
3435 +
3436 +@@ -6913,6 +6913,8 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
3437 +
3438 + open_err:
3439 + bnxt_disable_napi(bp);
3440 ++
3441 ++open_err_irq:
3442 + bnxt_del_napi(bp);
3443 +
3444 + open_err_free_mem:
3445 +@@ -8467,11 +8469,11 @@ int bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx, bool shared)
3446 + int rx, tx, cp;
3447 +
3448 + _bnxt_get_max_rings(bp, &rx, &tx, &cp);
3449 ++ *max_rx = rx;
3450 ++ *max_tx = tx;
3451 + if (!rx || !tx || !cp)
3452 + return -ENOMEM;
3453 +
3454 +- *max_rx = rx;
3455 +- *max_tx = tx;
3456 + return bnxt_trim_rings(bp, max_rx, max_tx, cp, shared);
3457 + }
3458 +
3459 +@@ -8485,8 +8487,11 @@ static int bnxt_get_dflt_rings(struct bnxt *bp, int *max_rx, int *max_tx,
3460 + /* Not enough rings, try disabling agg rings. */
3461 + bp->flags &= ~BNXT_FLAG_AGG_RINGS;
3462 + rc = bnxt_get_max_rings(bp, max_rx, max_tx, shared);
3463 +- if (rc)
3464 ++ if (rc) {
3465 ++ /* set BNXT_FLAG_AGG_RINGS back for consistency */
3466 ++ bp->flags |= BNXT_FLAG_AGG_RINGS;
3467 + return rc;
3468 ++ }
3469 + bp->flags |= BNXT_FLAG_NO_AGG_RINGS;
3470 + bp->dev->hw_features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW);
3471 + bp->dev->features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW);
3472 +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
3473 +index 3d55d3b56865..79bce5dcf7fe 100644
3474 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
3475 ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
3476 +@@ -1455,7 +1455,6 @@ void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max);
3477 + unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
3478 + void bnxt_set_max_func_cp_rings(struct bnxt *bp, unsigned int max);
3479 + unsigned int bnxt_get_max_func_irqs(struct bnxt *bp);
3480 +-void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max);
3481 + int bnxt_get_avail_msix(struct bnxt *bp, int num);
3482 + int bnxt_reserve_rings(struct bnxt *bp);
3483 + void bnxt_tx_disable(struct bnxt *bp);
3484 +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
3485 +index 795f45024c20..491bd40a254d 100644
3486 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
3487 ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
3488 +@@ -27,6 +27,15 @@
3489 + #define BNXT_FID_INVALID 0xffff
3490 + #define VLAN_TCI(vid, prio) ((vid) | ((prio) << VLAN_PRIO_SHIFT))
3491 +
3492 ++#define is_vlan_pcp_wildcarded(vlan_tci_mask) \
3493 ++ ((ntohs(vlan_tci_mask) & VLAN_PRIO_MASK) == 0x0000)
3494 ++#define is_vlan_pcp_exactmatch(vlan_tci_mask) \
3495 ++ ((ntohs(vlan_tci_mask) & VLAN_PRIO_MASK) == VLAN_PRIO_MASK)
3496 ++#define is_vlan_pcp_zero(vlan_tci) \
3497 ++ ((ntohs(vlan_tci) & VLAN_PRIO_MASK) == 0x0000)
3498 ++#define is_vid_exactmatch(vlan_tci_mask) \
3499 ++ ((ntohs(vlan_tci_mask) & VLAN_VID_MASK) == VLAN_VID_MASK)
3500 ++
3501 + /* Return the dst fid of the func for flow forwarding
3502 + * For PFs: src_fid is the fid of the PF
3503 + * For VF-reps: src_fid the fid of the VF
3504 +@@ -389,6 +398,21 @@ static bool is_exactmatch(void *mask, int len)
3505 + return true;
3506 + }
3507 +
3508 ++static bool is_vlan_tci_allowed(__be16 vlan_tci_mask,
3509 ++ __be16 vlan_tci)
3510 ++{
3511 ++ /* VLAN priority must be either exactly zero or fully wildcarded and
3512 ++ * VLAN id must be exact match.
3513 ++ */
3514 ++ if (is_vid_exactmatch(vlan_tci_mask) &&
3515 ++ ((is_vlan_pcp_exactmatch(vlan_tci_mask) &&
3516 ++ is_vlan_pcp_zero(vlan_tci)) ||
3517 ++ is_vlan_pcp_wildcarded(vlan_tci_mask)))
3518 ++ return true;
3519 ++
3520 ++ return false;
3521 ++}
3522 ++
3523 + static bool bits_set(void *key, int len)
3524 + {
3525 + const u8 *p = key;
3526 +@@ -803,9 +827,9 @@ static bool bnxt_tc_can_offload(struct bnxt *bp, struct bnxt_tc_flow *flow)
3527 + /* Currently VLAN fields cannot be partial wildcard */
3528 + if (bits_set(&flow->l2_key.inner_vlan_tci,
3529 + sizeof(flow->l2_key.inner_vlan_tci)) &&
3530 +- !is_exactmatch(&flow->l2_mask.inner_vlan_tci,
3531 +- sizeof(flow->l2_mask.inner_vlan_tci))) {
3532 +- netdev_info(bp->dev, "Wildcard match unsupported for VLAN TCI\n");
3533 ++ !is_vlan_tci_allowed(flow->l2_mask.inner_vlan_tci,
3534 ++ flow->l2_key.inner_vlan_tci)) {
3535 ++ netdev_info(bp->dev, "Unsupported VLAN TCI\n");
3536 + return false;
3537 + }
3538 + if (bits_set(&flow->l2_key.inner_vlan_tpid,
3539 +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
3540 +index 347e4f946eb2..840f6e505f73 100644
3541 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
3542 ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
3543 +@@ -169,7 +169,6 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,
3544 + edev->ulp_tbl[ulp_id].msix_requested = avail_msix;
3545 + }
3546 + bnxt_fill_msix_vecs(bp, ent);
3547 +- bnxt_set_max_func_irqs(bp, bnxt_get_max_func_irqs(bp) - avail_msix);
3548 + bnxt_set_max_func_cp_rings(bp, max_cp_rings - avail_msix);
3549 + edev->flags |= BNXT_EN_FLAG_MSIX_REQUESTED;
3550 + return avail_msix;
3551 +@@ -192,7 +191,6 @@ static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, int ulp_id)
3552 + msix_requested = edev->ulp_tbl[ulp_id].msix_requested;
3553 + bnxt_set_max_func_cp_rings(bp, max_cp_rings + msix_requested);
3554 + edev->ulp_tbl[ulp_id].msix_requested = 0;
3555 +- bnxt_set_max_func_irqs(bp, bnxt_get_max_func_irqs(bp) + msix_requested);
3556 + edev->flags &= ~BNXT_EN_FLAG_MSIX_REQUESTED;
3557 + if (netif_running(dev)) {
3558 + bnxt_close_nic(bp, true, false);
3559 +diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
3560 +index 068f991395dc..01032f37a308 100644
3561 +--- a/drivers/net/ethernet/cadence/macb_main.c
3562 ++++ b/drivers/net/ethernet/cadence/macb_main.c
3563 +@@ -1818,13 +1818,7 @@ static void macb_free_consistent(struct macb *bp)
3564 + struct macb_queue *queue;
3565 + unsigned int q;
3566 +
3567 +- queue = &bp->queues[0];
3568 + bp->macbgem_ops.mog_free_rx_buffers(bp);
3569 +- if (queue->rx_ring) {
3570 +- dma_free_coherent(&bp->pdev->dev, RX_RING_BYTES(bp),
3571 +- queue->rx_ring, queue->rx_ring_dma);
3572 +- queue->rx_ring = NULL;
3573 +- }
3574 +
3575 + for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
3576 + kfree(queue->tx_skb);
3577 +@@ -1834,6 +1828,11 @@ static void macb_free_consistent(struct macb *bp)
3578 + queue->tx_ring, queue->tx_ring_dma);
3579 + queue->tx_ring = NULL;
3580 + }
3581 ++ if (queue->rx_ring) {
3582 ++ dma_free_coherent(&bp->pdev->dev, RX_RING_BYTES(bp),
3583 ++ queue->rx_ring, queue->rx_ring_dma);
3584 ++ queue->rx_ring = NULL;
3585 ++ }
3586 + }
3587 + }
3588 +
3589 +diff --git a/drivers/net/ethernet/cavium/Kconfig b/drivers/net/ethernet/cavium/Kconfig
3590 +index 043e3c11c42b..92d88c5f76fb 100644
3591 +--- a/drivers/net/ethernet/cavium/Kconfig
3592 ++++ b/drivers/net/ethernet/cavium/Kconfig
3593 +@@ -15,7 +15,7 @@ if NET_VENDOR_CAVIUM
3594 +
3595 + config THUNDER_NIC_PF
3596 + tristate "Thunder Physical function driver"
3597 +- depends on 64BIT
3598 ++ depends on 64BIT && PCI
3599 + select THUNDER_NIC_BGX
3600 + ---help---
3601 + This driver supports Thunder's NIC physical function.
3602 +@@ -28,13 +28,13 @@ config THUNDER_NIC_PF
3603 + config THUNDER_NIC_VF
3604 + tristate "Thunder Virtual function driver"
3605 + imply CAVIUM_PTP
3606 +- depends on 64BIT
3607 ++ depends on 64BIT && PCI
3608 + ---help---
3609 + This driver supports Thunder's NIC virtual function
3610 +
3611 + config THUNDER_NIC_BGX
3612 + tristate "Thunder MAC interface driver (BGX)"
3613 +- depends on 64BIT
3614 ++ depends on 64BIT && PCI
3615 + select PHYLIB
3616 + select MDIO_THUNDER
3617 + select THUNDER_NIC_RGX
3618 +@@ -44,7 +44,7 @@ config THUNDER_NIC_BGX
3619 +
3620 + config THUNDER_NIC_RGX
3621 + tristate "Thunder MAC interface driver (RGX)"
3622 +- depends on 64BIT
3623 ++ depends on 64BIT && PCI
3624 + select PHYLIB
3625 + select MDIO_THUNDER
3626 + ---help---
3627 +@@ -53,7 +53,7 @@ config THUNDER_NIC_RGX
3628 +
3629 + config CAVIUM_PTP
3630 + tristate "Cavium PTP coprocessor as PTP clock"
3631 +- depends on 64BIT
3632 ++ depends on 64BIT && PCI
3633 + imply PTP_1588_CLOCK
3634 + default y
3635 + ---help---
3636 +@@ -65,7 +65,7 @@ config CAVIUM_PTP
3637 +
3638 + config LIQUIDIO
3639 + tristate "Cavium LiquidIO support"
3640 +- depends on 64BIT
3641 ++ depends on 64BIT && PCI
3642 + depends on MAY_USE_DEVLINK
3643 + imply PTP_1588_CLOCK
3644 + select FW_LOADER
3645 +diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
3646 +index 3f6afb54a5eb..bb43ddb7539e 100644
3647 +--- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
3648 ++++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
3649 +@@ -643,13 +643,21 @@ static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr)
3650 + static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
3651 + {
3652 + struct octeon_mgmt *p = netdev_priv(netdev);
3653 +- int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM;
3654 ++ int max_packet = new_mtu + ETH_HLEN + ETH_FCS_LEN;
3655 +
3656 + netdev->mtu = new_mtu;
3657 +
3658 +- cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, size_without_fcs);
3659 ++ /* HW lifts the limit if the frame is VLAN tagged
3660 ++ * (+4 bytes per each tag, up to two tags)
3661 ++ */
3662 ++ cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, max_packet);
3663 ++ /* Set the hardware to truncate packets larger than the MTU. The jabber
3664 ++ * register must be set to a multiple of 8 bytes, so round up. JABBER is
3665 ++ * an unconditional limit, so we need to account for two possible VLAN
3666 ++ * tags.
3667 ++ */
3668 + cvmx_write_csr(p->agl + AGL_GMX_RX_JABBER,
3669 +- (size_without_fcs + 7) & 0xfff8);
3670 ++ (max_packet + 7 + VLAN_HLEN * 2) & 0xfff8);
3671 +
3672 + return 0;
3673 + }
3674 +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
3675 +index 72c83496e01f..da73bf702e15 100644
3676 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
3677 ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
3678 +@@ -263,7 +263,7 @@ static void dcb_tx_queue_prio_enable(struct net_device *dev, int enable)
3679 + "Can't %s DCB Priority on port %d, TX Queue %d: err=%d\n",
3680 + enable ? "set" : "unset", pi->port_id, i, -err);
3681 + else
3682 +- txq->dcb_prio = value;
3683 ++ txq->dcb_prio = enable ? value : 0;
3684 + }
3685 + }
3686 +
3687 +diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
3688 +index 7cb3ef466cc7..c7a94aacc664 100644
3689 +--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
3690 ++++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
3691 +@@ -8526,7 +8526,7 @@ static int t4_get_flash_params(struct adapter *adap)
3692 + };
3693 +
3694 + unsigned int part, manufacturer;
3695 +- unsigned int density, size;
3696 ++ unsigned int density, size = 0;
3697 + u32 flashid = 0;
3698 + int ret;
3699 +
3700 +@@ -8596,11 +8596,6 @@ static int t4_get_flash_params(struct adapter *adap)
3701 + case 0x22: /* 256MB */
3702 + size = 1 << 28;
3703 + break;
3704 +-
3705 +- default:
3706 +- dev_err(adap->pdev_dev, "Micron Flash Part has bad size, ID = %#x, Density code = %#x\n",
3707 +- flashid, density);
3708 +- return -EINVAL;
3709 + }
3710 + break;
3711 + }
3712 +@@ -8616,10 +8611,6 @@ static int t4_get_flash_params(struct adapter *adap)
3713 + case 0x17: /* 64MB */
3714 + size = 1 << 26;
3715 + break;
3716 +- default:
3717 +- dev_err(adap->pdev_dev, "ISSI Flash Part has bad size, ID = %#x, Density code = %#x\n",
3718 +- flashid, density);
3719 +- return -EINVAL;
3720 + }
3721 + break;
3722 + }
3723 +@@ -8635,10 +8626,6 @@ static int t4_get_flash_params(struct adapter *adap)
3724 + case 0x18: /* 16MB */
3725 + size = 1 << 24;
3726 + break;
3727 +- default:
3728 +- dev_err(adap->pdev_dev, "Macronix Flash Part has bad size, ID = %#x, Density code = %#x\n",
3729 +- flashid, density);
3730 +- return -EINVAL;
3731 + }
3732 + break;
3733 + }
3734 +@@ -8654,17 +8641,21 @@ static int t4_get_flash_params(struct adapter *adap)
3735 + case 0x18: /* 16MB */
3736 + size = 1 << 24;
3737 + break;
3738 +- default:
3739 +- dev_err(adap->pdev_dev, "Winbond Flash Part has bad size, ID = %#x, Density code = %#x\n",
3740 +- flashid, density);
3741 +- return -EINVAL;
3742 + }
3743 + break;
3744 + }
3745 +- default:
3746 +- dev_err(adap->pdev_dev, "Unsupported Flash Part, ID = %#x\n",
3747 +- flashid);
3748 +- return -EINVAL;
3749 ++ }
3750 ++
3751 ++ /* If we didn't recognize the FLASH part, that's no real issue: the
3752 ++ * Hardware/Software contract says that Hardware will _*ALWAYS*_
3753 ++ * use a FLASH part which is at least 4MB in size and has 64KB
3754 ++ * sectors. The unrecognized FLASH part is likely to be much larger
3755 ++ * than 4MB, but that's all we really need.
3756 ++ */
3757 ++ if (size == 0) {
3758 ++ dev_warn(adap->pdev_dev, "Unknown Flash Part, ID = %#x, assuming 4MB\n",
3759 ++ flashid);
3760 ++ size = 1 << 22;
3761 + }
3762 +
3763 + /* Store decoded Flash size and fall through into vetting code. */
3764 +diff --git a/drivers/net/ethernet/cisco/enic/enic_clsf.c b/drivers/net/ethernet/cisco/enic/enic_clsf.c
3765 +index 973c1fb70d09..99038dfc7fbe 100644
3766 +--- a/drivers/net/ethernet/cisco/enic/enic_clsf.c
3767 ++++ b/drivers/net/ethernet/cisco/enic/enic_clsf.c
3768 +@@ -79,7 +79,6 @@ void enic_rfs_flw_tbl_init(struct enic *enic)
3769 + enic->rfs_h.max = enic->config.num_arfs;
3770 + enic->rfs_h.free = enic->rfs_h.max;
3771 + enic->rfs_h.toclean = 0;
3772 +- enic_rfs_timer_start(enic);
3773 + }
3774 +
3775 + void enic_rfs_flw_tbl_free(struct enic *enic)
3776 +@@ -88,7 +87,6 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
3777 +
3778 + enic_rfs_timer_stop(enic);
3779 + spin_lock_bh(&enic->rfs_h.lock);
3780 +- enic->rfs_h.free = 0;
3781 + for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) {
3782 + struct hlist_head *hhead;
3783 + struct hlist_node *tmp;
3784 +@@ -99,6 +97,7 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
3785 + enic_delfltr(enic, n->fltr_id);
3786 + hlist_del(&n->node);
3787 + kfree(n);
3788 ++ enic->rfs_h.free++;
3789 + }
3790 + }
3791 + spin_unlock_bh(&enic->rfs_h.lock);
3792 +diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
3793 +index 454e57ef047a..84eac2b0837d 100644
3794 +--- a/drivers/net/ethernet/cisco/enic/enic_main.c
3795 ++++ b/drivers/net/ethernet/cisco/enic/enic_main.c
3796 +@@ -1971,7 +1971,7 @@ static int enic_open(struct net_device *netdev)
3797 + vnic_intr_unmask(&enic->intr[i]);
3798 +
3799 + enic_notify_timer_start(enic);
3800 +- enic_rfs_flw_tbl_init(enic);
3801 ++ enic_rfs_timer_start(enic);
3802 +
3803 + return 0;
3804 +
3805 +@@ -2895,6 +2895,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3806 +
3807 + timer_setup(&enic->notify_timer, enic_notify_timer, 0);
3808 +
3809 ++ enic_rfs_flw_tbl_init(enic);
3810 + enic_set_rx_coal_setting(enic);
3811 + INIT_WORK(&enic->reset, enic_reset);
3812 + INIT_WORK(&enic->tx_hang_reset, enic_tx_hang_reset);
3813 +diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
3814 +index fd43f98ddbe7..38498cfa405e 100644
3815 +--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
3816 ++++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
3817 +@@ -125,6 +125,9 @@ MODULE_PARM_DESC(tx_timeout, "The Tx timeout in ms");
3818 + /* Default alignment for start of data in an Rx FD */
3819 + #define DPAA_FD_DATA_ALIGNMENT 16
3820 +
3821 ++/* The DPAA requires 256 bytes reserved and mapped for the SGT */
3822 ++#define DPAA_SGT_SIZE 256
3823 ++
3824 + /* Values for the L3R field of the FM Parse Results
3825 + */
3826 + /* L3 Type field: First IP Present IPv4 */
3827 +@@ -1617,8 +1620,8 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct dpaa_priv *priv,
3828 +
3829 + if (unlikely(qm_fd_get_format(fd) == qm_fd_sg)) {
3830 + nr_frags = skb_shinfo(skb)->nr_frags;
3831 +- dma_unmap_single(dev, addr, qm_fd_get_offset(fd) +
3832 +- sizeof(struct qm_sg_entry) * (1 + nr_frags),
3833 ++ dma_unmap_single(dev, addr,
3834 ++ qm_fd_get_offset(fd) + DPAA_SGT_SIZE,
3835 + dma_dir);
3836 +
3837 + /* The sgt buffer has been allocated with netdev_alloc_frag(),
3838 +@@ -1903,8 +1906,7 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
3839 + void *sgt_buf;
3840 +
3841 + /* get a page frag to store the SGTable */
3842 +- sz = SKB_DATA_ALIGN(priv->tx_headroom +
3843 +- sizeof(struct qm_sg_entry) * (1 + nr_frags));
3844 ++ sz = SKB_DATA_ALIGN(priv->tx_headroom + DPAA_SGT_SIZE);
3845 + sgt_buf = netdev_alloc_frag(sz);
3846 + if (unlikely(!sgt_buf)) {
3847 + netdev_err(net_dev, "netdev_alloc_frag() failed for size %d\n",
3848 +@@ -1972,9 +1974,8 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
3849 + skbh = (struct sk_buff **)buffer_start;
3850 + *skbh = skb;
3851 +
3852 +- addr = dma_map_single(dev, buffer_start, priv->tx_headroom +
3853 +- sizeof(struct qm_sg_entry) * (1 + nr_frags),
3854 +- dma_dir);
3855 ++ addr = dma_map_single(dev, buffer_start,
3856 ++ priv->tx_headroom + DPAA_SGT_SIZE, dma_dir);
3857 + if (unlikely(dma_mapping_error(dev, addr))) {
3858 + dev_err(dev, "DMA mapping failed");
3859 + err = -EINVAL;
3860 +diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c b/drivers/net/ethernet/freescale/fman/fman_port.c
3861 +index 6552d68ea6e1..4aa47bc8b02f 100644
3862 +--- a/drivers/net/ethernet/freescale/fman/fman_port.c
3863 ++++ b/drivers/net/ethernet/freescale/fman/fman_port.c
3864 +@@ -324,6 +324,10 @@ struct fman_port_qmi_regs {
3865 + #define HWP_HXS_PHE_REPORT 0x00000800
3866 + #define HWP_HXS_PCAC_PSTAT 0x00000100
3867 + #define HWP_HXS_PCAC_PSTOP 0x00000001
3868 ++#define HWP_HXS_TCP_OFFSET 0xA
3869 ++#define HWP_HXS_UDP_OFFSET 0xB
3870 ++#define HWP_HXS_SH_PAD_REM 0x80000000
3871 ++
3872 + struct fman_port_hwp_regs {
3873 + struct {
3874 + u32 ssa; /* Soft Sequence Attachment */
3875 +@@ -728,6 +732,10 @@ static void init_hwp(struct fman_port *port)
3876 + iowrite32be(0xffffffff, &regs->pmda[i].lcv);
3877 + }
3878 +
3879 ++ /* Short packet padding removal from checksum calculation */
3880 ++ iowrite32be(HWP_HXS_SH_PAD_REM, &regs->pmda[HWP_HXS_TCP_OFFSET].ssa);
3881 ++ iowrite32be(HWP_HXS_SH_PAD_REM, &regs->pmda[HWP_HXS_UDP_OFFSET].ssa);
3882 ++
3883 + start_port_hwp(port);
3884 + }
3885 +
3886 +diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
3887 +index 5ec1185808e5..65aa7a6e33a2 100644
3888 +--- a/drivers/net/ethernet/ibm/ibmvnic.c
3889 ++++ b/drivers/net/ethernet/ibm/ibmvnic.c
3890 +@@ -319,7 +319,8 @@ static void replenish_rx_pool(struct ibmvnic_adapter *adapter,
3891 + return;
3892 +
3893 + failure:
3894 +- dev_info(dev, "replenish pools failure\n");
3895 ++ if (lpar_rc != H_PARAMETER && lpar_rc != H_CLOSED)
3896 ++ dev_err_ratelimited(dev, "rx: replenish packet buffer failed\n");
3897 + pool->free_map[pool->next_free] = index;
3898 + pool->rx_buff[index].skb = NULL;
3899 +
3900 +@@ -1594,7 +1595,8 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
3901 + &tx_crq);
3902 + }
3903 + if (lpar_rc != H_SUCCESS) {
3904 +- dev_err(dev, "tx failed with code %ld\n", lpar_rc);
3905 ++ if (lpar_rc != H_CLOSED && lpar_rc != H_PARAMETER)
3906 ++ dev_err_ratelimited(dev, "tx: send failed\n");
3907 + dev_kfree_skb_any(skb);
3908 + tx_buff->skb = NULL;
3909 +
3910 +@@ -1799,8 +1801,8 @@ static int do_reset(struct ibmvnic_adapter *adapter,
3911 +
3912 + rc = ibmvnic_login(netdev);
3913 + if (rc) {
3914 +- adapter->state = VNIC_PROBED;
3915 +- return 0;
3916 ++ adapter->state = reset_state;
3917 ++ return rc;
3918 + }
3919 +
3920 + if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM ||
3921 +@@ -3085,6 +3087,25 @@ static union ibmvnic_crq *ibmvnic_next_crq(struct ibmvnic_adapter *adapter)
3922 + return crq;
3923 + }
3924 +
3925 ++static void print_subcrq_error(struct device *dev, int rc, const char *func)
3926 ++{
3927 ++ switch (rc) {
3928 ++ case H_PARAMETER:
3929 ++ dev_warn_ratelimited(dev,
3930 ++ "%s failed: Send request is malformed or adapter failover pending. (rc=%d)\n",
3931 ++ func, rc);
3932 ++ break;
3933 ++ case H_CLOSED:
3934 ++ dev_warn_ratelimited(dev,
3935 ++ "%s failed: Backing queue closed. Adapter is down or failover pending. (rc=%d)\n",
3936 ++ func, rc);
3937 ++ break;
3938 ++ default:
3939 ++ dev_err_ratelimited(dev, "%s failed: (rc=%d)\n", func, rc);
3940 ++ break;
3941 ++ }
3942 ++}
3943 ++
3944 + static int send_subcrq(struct ibmvnic_adapter *adapter, u64 remote_handle,
3945 + union sub_crq *sub_crq)
3946 + {
3947 +@@ -3111,11 +3132,8 @@ static int send_subcrq(struct ibmvnic_adapter *adapter, u64 remote_handle,
3948 + cpu_to_be64(u64_crq[2]),
3949 + cpu_to_be64(u64_crq[3]));
3950 +
3951 +- if (rc) {
3952 +- if (rc == H_CLOSED)
3953 +- dev_warn(dev, "CRQ Queue closed\n");
3954 +- dev_err(dev, "Send error (rc=%d)\n", rc);
3955 +- }
3956 ++ if (rc)
3957 ++ print_subcrq_error(dev, rc, __func__);
3958 +
3959 + return rc;
3960 + }
3961 +@@ -3133,11 +3151,8 @@ static int send_subcrq_indirect(struct ibmvnic_adapter *adapter,
3962 + cpu_to_be64(remote_handle),
3963 + ioba, num_entries);
3964 +
3965 +- if (rc) {
3966 +- if (rc == H_CLOSED)
3967 +- dev_warn(dev, "CRQ Queue closed\n");
3968 +- dev_err(dev, "Send (indirect) error (rc=%d)\n", rc);
3969 +- }
3970 ++ if (rc)
3971 ++ print_subcrq_error(dev, rc, __func__);
3972 +
3973 + return rc;
3974 + }
3975 +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
3976 +index 633be93f3dbb..b8f1f904e5c2 100644
3977 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
3978 ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
3979 +@@ -1897,7 +1897,12 @@ s32 ixgbe_set_rar_generic(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
3980 + if (enable_addr != 0)
3981 + rar_high |= IXGBE_RAH_AV;
3982 +
3983 ++ /* Record lower 32 bits of MAC address and then make
3984 ++ * sure that write is flushed to hardware before writing
3985 ++ * the upper 16 bits and setting the valid bit.
3986 ++ */
3987 + IXGBE_WRITE_REG(hw, IXGBE_RAL(index), rar_low);
3988 ++ IXGBE_WRITE_FLUSH(hw);
3989 + IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
3990 +
3991 + return 0;
3992 +@@ -1929,8 +1934,13 @@ s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index)
3993 + rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));
3994 + rar_high &= ~(0x0000FFFF | IXGBE_RAH_AV);
3995 +
3996 +- IXGBE_WRITE_REG(hw, IXGBE_RAL(index), 0);
3997 ++ /* Clear the address valid bit and upper 16 bits of the address
3998 ++ * before clearing the lower bits. This way we aren't updating
3999 ++ * a live filter.
4000 ++ */
4001 + IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
4002 ++ IXGBE_WRITE_FLUSH(hw);
4003 ++ IXGBE_WRITE_REG(hw, IXGBE_RAL(index), 0);
4004 +
4005 + /* clear VMDq pool/queue selection for this RAR */
4006 + hw->mac.ops.clear_vmdq(hw, index, IXGBE_CLEAR_VMDQ_ALL);
4007 +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
4008 +index cead23e3db0c..eea4b6f0efe5 100644
4009 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
4010 ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
4011 +@@ -759,7 +759,7 @@ int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring,
4012 + }
4013 +
4014 + itd->sa_idx = xs->xso.offload_handle - IXGBE_IPSEC_BASE_TX_INDEX;
4015 +- if (unlikely(itd->sa_idx > IXGBE_IPSEC_MAX_SA_COUNT)) {
4016 ++ if (unlikely(itd->sa_idx >= IXGBE_IPSEC_MAX_SA_COUNT)) {
4017 + netdev_err(tx_ring->netdev, "%s: bad sa_idx=%d handle=%lu\n",
4018 + __func__, itd->sa_idx, xs->xso.offload_handle);
4019 + return 0;
4020 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
4021 +index 4f52f87cf210..b6624e218962 100644
4022 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
4023 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
4024 +@@ -1594,17 +1594,15 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, int vport_num)
4025 + }
4026 +
4027 + /* Public E-Switch API */
4028 +-#define ESW_ALLOWED(esw) ((esw) && MLX5_VPORT_MANAGER((esw)->dev))
4029 ++#define ESW_ALLOWED(esw) ((esw) && MLX5_ESWITCH_MANAGER((esw)->dev))
4030 ++
4031 +
4032 + int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
4033 + {
4034 + int err;
4035 + int i, enabled_events;
4036 +
4037 +- if (!ESW_ALLOWED(esw))
4038 +- return 0;
4039 +-
4040 +- if (!MLX5_ESWITCH_MANAGER(esw->dev) ||
4041 ++ if (!ESW_ALLOWED(esw) ||
4042 + !MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ft_support)) {
4043 + esw_warn(esw->dev, "E-Switch FDB is not supported, aborting ...\n");
4044 + return -EOPNOTSUPP;
4045 +@@ -1806,7 +1804,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
4046 + u64 node_guid;
4047 + int err = 0;
4048 +
4049 +- if (!ESW_ALLOWED(esw))
4050 ++ if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
4051 + return -EPERM;
4052 + if (!LEGAL_VPORT(esw, vport) || is_multicast_ether_addr(mac))
4053 + return -EINVAL;
4054 +@@ -1883,7 +1881,7 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
4055 + {
4056 + struct mlx5_vport *evport;
4057 +
4058 +- if (!ESW_ALLOWED(esw))
4059 ++ if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
4060 + return -EPERM;
4061 + if (!LEGAL_VPORT(esw, vport))
4062 + return -EINVAL;
4063 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
4064 +index 177e076b8d17..1f3ccb435b06 100644
4065 +--- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c
4066 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
4067 +@@ -549,8 +549,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
4068 + return -EINVAL;
4069 + if (!MLX5_CAP_GEN(mdev, vport_group_manager))
4070 + return -EACCES;
4071 +- if (!MLX5_CAP_ESW(mdev, nic_vport_node_guid_modify))
4072 +- return -EOPNOTSUPP;
4073 +
4074 + in = kvzalloc(inlen, GFP_KERNEL);
4075 + if (!in)
4076 +diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.c b/drivers/net/ethernet/netronome/nfp/bpf/main.c
4077 +index 1a781281c57a..a86ae1318043 100644
4078 +--- a/drivers/net/ethernet/netronome/nfp/bpf/main.c
4079 ++++ b/drivers/net/ethernet/netronome/nfp/bpf/main.c
4080 +@@ -73,10 +73,10 @@ nfp_bpf_xdp_offload(struct nfp_app *app, struct nfp_net *nn,
4081 +
4082 + ret = nfp_net_bpf_offload(nn, prog, running, extack);
4083 + /* Stop offload if replace not possible */
4084 +- if (ret && prog)
4085 +- nfp_bpf_xdp_offload(app, nn, NULL, extack);
4086 ++ if (ret)
4087 ++ return ret;
4088 +
4089 +- nn->dp.bpf_offload_xdp = prog && !ret;
4090 ++ nn->dp.bpf_offload_xdp = !!prog;
4091 + return ret;
4092 + }
4093 +
4094 +diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c
4095 +index cd34097b79f1..37a6d7822a38 100644
4096 +--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c
4097 ++++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c
4098 +@@ -232,7 +232,7 @@ struct nfp_nffw_info *nfp_nffw_info_open(struct nfp_cpp *cpp)
4099 + err = nfp_cpp_read(cpp, nfp_resource_cpp_id(state->res),
4100 + nfp_resource_address(state->res),
4101 + fwinf, sizeof(*fwinf));
4102 +- if (err < sizeof(*fwinf))
4103 ++ if (err < (int)sizeof(*fwinf))
4104 + goto err_release;
4105 +
4106 + if (!nffw_res_flg_init_get(fwinf))
4107 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
4108 +index e82986df9b8e..6292c38ef597 100644
4109 +--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
4110 ++++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
4111 +@@ -255,9 +255,8 @@ qed_dcbx_get_app_protocol_type(struct qed_hwfn *p_hwfn,
4112 + *type = DCBX_PROTOCOL_ROCE_V2;
4113 + } else {
4114 + *type = DCBX_MAX_PROTOCOL_TYPE;
4115 +- DP_ERR(p_hwfn,
4116 +- "No action required, App TLV id = 0x%x app_prio_bitmap = 0x%x\n",
4117 +- id, app_prio_bitmap);
4118 ++ DP_ERR(p_hwfn, "No action required, App TLV entry = 0x%x\n",
4119 ++ app_prio_bitmap);
4120 + return false;
4121 + }
4122 +
4123 +@@ -1469,8 +1468,8 @@ static u8 qed_dcbnl_getcap(struct qed_dev *cdev, int capid, u8 *cap)
4124 + *cap = 0x80;
4125 + break;
4126 + case DCB_CAP_ATTR_DCBX:
4127 +- *cap = (DCB_CAP_DCBX_LLD_MANAGED | DCB_CAP_DCBX_VER_CEE |
4128 +- DCB_CAP_DCBX_VER_IEEE | DCB_CAP_DCBX_STATIC);
4129 ++ *cap = (DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_VER_IEEE |
4130 ++ DCB_CAP_DCBX_STATIC);
4131 + break;
4132 + default:
4133 + *cap = false;
4134 +@@ -1538,8 +1537,6 @@ static u8 qed_dcbnl_getdcbx(struct qed_dev *cdev)
4135 + if (!dcbx_info)
4136 + return 0;
4137 +
4138 +- if (dcbx_info->operational.enabled)
4139 +- mode |= DCB_CAP_DCBX_LLD_MANAGED;
4140 + if (dcbx_info->operational.ieee)
4141 + mode |= DCB_CAP_DCBX_VER_IEEE;
4142 + if (dcbx_info->operational.cee)
4143 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c b/drivers/net/ethernet/qlogic/qed/qed_debug.c
4144 +index 4926c5532fba..13641096a002 100644
4145 +--- a/drivers/net/ethernet/qlogic/qed/qed_debug.c
4146 ++++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c
4147 +@@ -6663,7 +6663,7 @@ static enum dbg_status qed_parse_mcp_trace_buf(u8 *trace_buf,
4148 + format_idx = header & MFW_TRACE_EVENTID_MASK;
4149 +
4150 + /* Skip message if its index doesn't exist in the meta data */
4151 +- if (format_idx > s_mcp_trace_meta.formats_num) {
4152 ++ if (format_idx >= s_mcp_trace_meta.formats_num) {
4153 + u8 format_size =
4154 + (u8)((header & MFW_TRACE_PRM_SIZE_MASK) >>
4155 + MFW_TRACE_PRM_SIZE_SHIFT);
4156 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
4157 +index 468c59d2e491..fa0598cf0ad6 100644
4158 +--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
4159 ++++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
4160 +@@ -201,8 +201,9 @@ void qed_ll2b_complete_rx_packet(void *cxt, struct qed_ll2_comp_rx_data *data)
4161 +
4162 + skb = build_skb(buffer->data, 0);
4163 + if (!skb) {
4164 +- rc = -ENOMEM;
4165 +- goto out_post;
4166 ++ DP_INFO(cdev, "Failed to build SKB\n");
4167 ++ kfree(buffer->data);
4168 ++ goto out_post1;
4169 + }
4170 +
4171 + data->u.placement_offset += NET_SKB_PAD;
4172 +@@ -224,8 +225,14 @@ void qed_ll2b_complete_rx_packet(void *cxt, struct qed_ll2_comp_rx_data *data)
4173 + cdev->ll2->cbs->rx_cb(cdev->ll2->cb_cookie, skb,
4174 + data->opaque_data_0,
4175 + data->opaque_data_1);
4176 ++ } else {
4177 ++ DP_VERBOSE(p_hwfn, (NETIF_MSG_RX_STATUS | NETIF_MSG_PKTDATA |
4178 ++ QED_MSG_LL2 | QED_MSG_STORAGE),
4179 ++ "Dropping the packet\n");
4180 ++ kfree(buffer->data);
4181 + }
4182 +
4183 ++out_post1:
4184 + /* Update Buffer information and update FW producer */
4185 + buffer->data = new_data;
4186 + buffer->phys_addr = new_phys_addr;
4187 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
4188 +index 261f21d6b0b0..30e9718fefbb 100644
4189 +--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
4190 ++++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
4191 +@@ -566,8 +566,16 @@ static irqreturn_t qed_single_int(int irq, void *dev_instance)
4192 + /* Fastpath interrupts */
4193 + for (j = 0; j < 64; j++) {
4194 + if ((0x2ULL << j) & status) {
4195 +- hwfn->simd_proto_handler[j].func(
4196 +- hwfn->simd_proto_handler[j].token);
4197 ++ struct qed_simd_fp_handler *p_handler =
4198 ++ &hwfn->simd_proto_handler[j];
4199 ++
4200 ++ if (p_handler->func)
4201 ++ p_handler->func(p_handler->token);
4202 ++ else
4203 ++ DP_NOTICE(hwfn,
4204 ++ "Not calling fastpath handler as it is NULL [handler #%d, status 0x%llx]\n",
4205 ++ j, status);
4206 ++
4207 + status &= ~(0x2ULL << j);
4208 + rc = IRQ_HANDLED;
4209 + }
4210 +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
4211 +index 891f03a7a33d..8d7b9bb910f2 100644
4212 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
4213 ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
4214 +@@ -1128,6 +1128,8 @@ static ssize_t qlcnic_83xx_sysfs_flash_write_handler(struct file *filp,
4215 + struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
4216 +
4217 + ret = kstrtoul(buf, 16, &data);
4218 ++ if (ret)
4219 ++ return ret;
4220 +
4221 + switch (data) {
4222 + case QLC_83XX_FLASH_SECTOR_ERASE_CMD:
4223 +diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
4224 +index 5803cd6db406..206f0266463e 100644
4225 +--- a/drivers/net/ethernet/qualcomm/qca_spi.c
4226 ++++ b/drivers/net/ethernet/qualcomm/qca_spi.c
4227 +@@ -658,7 +658,7 @@ qcaspi_netdev_open(struct net_device *dev)
4228 + return ret;
4229 + }
4230 +
4231 +- netif_start_queue(qca->net_dev);
4232 ++ /* SPI thread takes care of TX queue */
4233 +
4234 + return 0;
4235 + }
4236 +@@ -760,6 +760,9 @@ qcaspi_netdev_tx_timeout(struct net_device *dev)
4237 + qca->net_dev->stats.tx_errors++;
4238 + /* Trigger tx queue flush and QCA7000 reset */
4239 + qca->sync = QCASPI_SYNC_UNKNOWN;
4240 ++
4241 ++ if (qca->spi_thread)
4242 ++ wake_up_process(qca->spi_thread);
4243 + }
4244 +
4245 + static int
4246 +@@ -878,22 +881,22 @@ qca_spi_probe(struct spi_device *spi)
4247 +
4248 + if ((qcaspi_clkspeed < QCASPI_CLK_SPEED_MIN) ||
4249 + (qcaspi_clkspeed > QCASPI_CLK_SPEED_MAX)) {
4250 +- dev_info(&spi->dev, "Invalid clkspeed: %d\n",
4251 +- qcaspi_clkspeed);
4252 ++ dev_err(&spi->dev, "Invalid clkspeed: %d\n",
4253 ++ qcaspi_clkspeed);
4254 + return -EINVAL;
4255 + }
4256 +
4257 + if ((qcaspi_burst_len < QCASPI_BURST_LEN_MIN) ||
4258 + (qcaspi_burst_len > QCASPI_BURST_LEN_MAX)) {
4259 +- dev_info(&spi->dev, "Invalid burst len: %d\n",
4260 +- qcaspi_burst_len);
4261 ++ dev_err(&spi->dev, "Invalid burst len: %d\n",
4262 ++ qcaspi_burst_len);
4263 + return -EINVAL;
4264 + }
4265 +
4266 + if ((qcaspi_pluggable < QCASPI_PLUGGABLE_MIN) ||
4267 + (qcaspi_pluggable > QCASPI_PLUGGABLE_MAX)) {
4268 +- dev_info(&spi->dev, "Invalid pluggable: %d\n",
4269 +- qcaspi_pluggable);
4270 ++ dev_err(&spi->dev, "Invalid pluggable: %d\n",
4271 ++ qcaspi_pluggable);
4272 + return -EINVAL;
4273 + }
4274 +
4275 +@@ -955,8 +958,8 @@ qca_spi_probe(struct spi_device *spi)
4276 + }
4277 +
4278 + if (register_netdev(qcaspi_devs)) {
4279 +- dev_info(&spi->dev, "Unable to register net device %s\n",
4280 +- qcaspi_devs->name);
4281 ++ dev_err(&spi->dev, "Unable to register net device %s\n",
4282 ++ qcaspi_devs->name);
4283 + free_netdev(qcaspi_devs);
4284 + return -EFAULT;
4285 + }
4286 +diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
4287 +index d3c6ce074571..07cc71cc9b76 100644
4288 +--- a/drivers/net/ethernet/realtek/r8169.c
4289 ++++ b/drivers/net/ethernet/realtek/r8169.c
4290 +@@ -8345,6 +8345,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
4291 + NETIF_F_HW_VLAN_CTAG_RX;
4292 + dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
4293 + NETIF_F_HIGHDMA;
4294 ++ dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
4295 +
4296 + tp->cp_cmd |= RxChkSum | RxVlan;
4297 +
4298 +diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
4299 +index 68f122140966..40266fe01186 100644
4300 +--- a/drivers/net/ethernet/renesas/ravb_main.c
4301 ++++ b/drivers/net/ethernet/renesas/ravb_main.c
4302 +@@ -980,6 +980,13 @@ static void ravb_adjust_link(struct net_device *ndev)
4303 + struct ravb_private *priv = netdev_priv(ndev);
4304 + struct phy_device *phydev = ndev->phydev;
4305 + bool new_state = false;
4306 ++ unsigned long flags;
4307 ++
4308 ++ spin_lock_irqsave(&priv->lock, flags);
4309 ++
4310 ++ /* Disable TX and RX right over here, if E-MAC change is ignored */
4311 ++ if (priv->no_avb_link)
4312 ++ ravb_rcv_snd_disable(ndev);
4313 +
4314 + if (phydev->link) {
4315 + if (phydev->duplex != priv->duplex) {
4316 +@@ -997,18 +1004,21 @@ static void ravb_adjust_link(struct net_device *ndev)
4317 + ravb_modify(ndev, ECMR, ECMR_TXF, 0);
4318 + new_state = true;
4319 + priv->link = phydev->link;
4320 +- if (priv->no_avb_link)
4321 +- ravb_rcv_snd_enable(ndev);
4322 + }
4323 + } else if (priv->link) {
4324 + new_state = true;
4325 + priv->link = 0;
4326 + priv->speed = 0;
4327 + priv->duplex = -1;
4328 +- if (priv->no_avb_link)
4329 +- ravb_rcv_snd_disable(ndev);
4330 + }
4331 +
4332 ++ /* Enable TX and RX right over here, if E-MAC change is ignored */
4333 ++ if (priv->no_avb_link && phydev->link)
4334 ++ ravb_rcv_snd_enable(ndev);
4335 ++
4336 ++ mmiowb();
4337 ++ spin_unlock_irqrestore(&priv->lock, flags);
4338 ++
4339 + if (new_state && netif_msg_link(priv))
4340 + phy_print_status(phydev);
4341 + }
4342 +@@ -1115,52 +1125,18 @@ static int ravb_get_link_ksettings(struct net_device *ndev,
4343 + static int ravb_set_link_ksettings(struct net_device *ndev,
4344 + const struct ethtool_link_ksettings *cmd)
4345 + {
4346 +- struct ravb_private *priv = netdev_priv(ndev);
4347 +- unsigned long flags;
4348 +- int error;
4349 +-
4350 + if (!ndev->phydev)
4351 + return -ENODEV;
4352 +
4353 +- spin_lock_irqsave(&priv->lock, flags);
4354 +-
4355 +- /* Disable TX and RX */
4356 +- ravb_rcv_snd_disable(ndev);
4357 +-
4358 +- error = phy_ethtool_ksettings_set(ndev->phydev, cmd);
4359 +- if (error)
4360 +- goto error_exit;
4361 +-
4362 +- if (cmd->base.duplex == DUPLEX_FULL)
4363 +- priv->duplex = 1;
4364 +- else
4365 +- priv->duplex = 0;
4366 +-
4367 +- ravb_set_duplex(ndev);
4368 +-
4369 +-error_exit:
4370 +- mdelay(1);
4371 +-
4372 +- /* Enable TX and RX */
4373 +- ravb_rcv_snd_enable(ndev);
4374 +-
4375 +- mmiowb();
4376 +- spin_unlock_irqrestore(&priv->lock, flags);
4377 +-
4378 +- return error;
4379 ++ return phy_ethtool_ksettings_set(ndev->phydev, cmd);
4380 + }
4381 +
4382 + static int ravb_nway_reset(struct net_device *ndev)
4383 + {
4384 +- struct ravb_private *priv = netdev_priv(ndev);
4385 + int error = -ENODEV;
4386 +- unsigned long flags;
4387 +
4388 +- if (ndev->phydev) {
4389 +- spin_lock_irqsave(&priv->lock, flags);
4390 ++ if (ndev->phydev)
4391 + error = phy_start_aneg(ndev->phydev);
4392 +- spin_unlock_irqrestore(&priv->lock, flags);
4393 +- }
4394 +
4395 + return error;
4396 + }
4397 +diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
4398 +index b6b90a6314e3..d14914495a65 100644
4399 +--- a/drivers/net/ethernet/renesas/sh_eth.c
4400 ++++ b/drivers/net/ethernet/renesas/sh_eth.c
4401 +@@ -1855,8 +1855,15 @@ static void sh_eth_adjust_link(struct net_device *ndev)
4402 + {
4403 + struct sh_eth_private *mdp = netdev_priv(ndev);
4404 + struct phy_device *phydev = ndev->phydev;
4405 ++ unsigned long flags;
4406 + int new_state = 0;
4407 +
4408 ++ spin_lock_irqsave(&mdp->lock, flags);
4409 ++
4410 ++ /* Disable TX and RX right over here, if E-MAC change is ignored */
4411 ++ if (mdp->cd->no_psr || mdp->no_ether_link)
4412 ++ sh_eth_rcv_snd_disable(ndev);
4413 ++
4414 + if (phydev->link) {
4415 + if (phydev->duplex != mdp->duplex) {
4416 + new_state = 1;
4417 +@@ -1875,18 +1882,21 @@ static void sh_eth_adjust_link(struct net_device *ndev)
4418 + sh_eth_modify(ndev, ECMR, ECMR_TXF, 0);
4419 + new_state = 1;
4420 + mdp->link = phydev->link;
4421 +- if (mdp->cd->no_psr || mdp->no_ether_link)
4422 +- sh_eth_rcv_snd_enable(ndev);
4423 + }
4424 + } else if (mdp->link) {
4425 + new_state = 1;
4426 + mdp->link = 0;
4427 + mdp->speed = 0;
4428 + mdp->duplex = -1;
4429 +- if (mdp->cd->no_psr || mdp->no_ether_link)
4430 +- sh_eth_rcv_snd_disable(ndev);
4431 + }
4432 +
4433 ++ /* Enable TX and RX right over here, if E-MAC change is ignored */
4434 ++ if ((mdp->cd->no_psr || mdp->no_ether_link) && phydev->link)
4435 ++ sh_eth_rcv_snd_enable(ndev);
4436 ++
4437 ++ mmiowb();
4438 ++ spin_unlock_irqrestore(&mdp->lock, flags);
4439 ++
4440 + if (new_state && netif_msg_link(mdp))
4441 + phy_print_status(phydev);
4442 + }
4443 +@@ -1977,39 +1987,10 @@ static int sh_eth_get_link_ksettings(struct net_device *ndev,
4444 + static int sh_eth_set_link_ksettings(struct net_device *ndev,
4445 + const struct ethtool_link_ksettings *cmd)
4446 + {
4447 +- struct sh_eth_private *mdp = netdev_priv(ndev);
4448 +- unsigned long flags;
4449 +- int ret;
4450 +-
4451 + if (!ndev->phydev)
4452 + return -ENODEV;
4453 +
4454 +- spin_lock_irqsave(&mdp->lock, flags);
4455 +-
4456 +- /* disable tx and rx */
4457 +- sh_eth_rcv_snd_disable(ndev);
4458 +-
4459 +- ret = phy_ethtool_ksettings_set(ndev->phydev, cmd);
4460 +- if (ret)
4461 +- goto error_exit;
4462 +-
4463 +- if (cmd->base.duplex == DUPLEX_FULL)
4464 +- mdp->duplex = 1;
4465 +- else
4466 +- mdp->duplex = 0;
4467 +-
4468 +- if (mdp->cd->set_duplex)
4469 +- mdp->cd->set_duplex(ndev);
4470 +-
4471 +-error_exit:
4472 +- mdelay(1);
4473 +-
4474 +- /* enable tx and rx */
4475 +- sh_eth_rcv_snd_enable(ndev);
4476 +-
4477 +- spin_unlock_irqrestore(&mdp->lock, flags);
4478 +-
4479 +- return ret;
4480 ++ return phy_ethtool_ksettings_set(ndev->phydev, cmd);
4481 + }
4482 +
4483 + /* If it is ever necessary to increase SH_ETH_REG_DUMP_MAX_REGS, the
4484 +@@ -2193,18 +2174,10 @@ static void sh_eth_get_regs(struct net_device *ndev, struct ethtool_regs *regs,
4485 +
4486 + static int sh_eth_nway_reset(struct net_device *ndev)
4487 + {
4488 +- struct sh_eth_private *mdp = netdev_priv(ndev);
4489 +- unsigned long flags;
4490 +- int ret;
4491 +-
4492 + if (!ndev->phydev)
4493 + return -ENODEV;
4494 +
4495 +- spin_lock_irqsave(&mdp->lock, flags);
4496 +- ret = phy_start_aneg(ndev->phydev);
4497 +- spin_unlock_irqrestore(&mdp->lock, flags);
4498 +-
4499 +- return ret;
4500 ++ return phy_start_aneg(ndev->phydev);
4501 + }
4502 +
4503 + static u32 sh_eth_get_msglevel(struct net_device *ndev)
4504 +diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
4505 +index d90a7b1f4088..56ff390e6795 100644
4506 +--- a/drivers/net/ethernet/sfc/ef10.c
4507 ++++ b/drivers/net/ethernet/sfc/ef10.c
4508 +@@ -4288,9 +4288,9 @@ static int efx_ef10_filter_pri(struct efx_ef10_filter_table *table,
4509 + return -EPROTONOSUPPORT;
4510 + }
4511 +
4512 +-static s32 efx_ef10_filter_insert(struct efx_nic *efx,
4513 +- struct efx_filter_spec *spec,
4514 +- bool replace_equal)
4515 ++static s32 efx_ef10_filter_insert_locked(struct efx_nic *efx,
4516 ++ struct efx_filter_spec *spec,
4517 ++ bool replace_equal)
4518 + {
4519 + DECLARE_BITMAP(mc_rem_map, EFX_EF10_FILTER_SEARCH_LIMIT);
4520 + struct efx_ef10_nic_data *nic_data = efx->nic_data;
4521 +@@ -4307,7 +4307,7 @@ static s32 efx_ef10_filter_insert(struct efx_nic *efx,
4522 + bool is_mc_recip;
4523 + s32 rc;
4524 +
4525 +- down_read(&efx->filter_sem);
4526 ++ WARN_ON(!rwsem_is_locked(&efx->filter_sem));
4527 + table = efx->filter_state;
4528 + down_write(&table->lock);
4529 +
4530 +@@ -4498,10 +4498,22 @@ out_unlock:
4531 + if (rss_locked)
4532 + mutex_unlock(&efx->rss_lock);
4533 + up_write(&table->lock);
4534 +- up_read(&efx->filter_sem);
4535 + return rc;
4536 + }
4537 +
4538 ++static s32 efx_ef10_filter_insert(struct efx_nic *efx,
4539 ++ struct efx_filter_spec *spec,
4540 ++ bool replace_equal)
4541 ++{
4542 ++ s32 ret;
4543 ++
4544 ++ down_read(&efx->filter_sem);
4545 ++ ret = efx_ef10_filter_insert_locked(efx, spec, replace_equal);
4546 ++ up_read(&efx->filter_sem);
4547 ++
4548 ++ return ret;
4549 ++}
4550 ++
4551 + static void efx_ef10_filter_update_rx_scatter(struct efx_nic *efx)
4552 + {
4553 + /* no need to do anything here on EF10 */
4554 +@@ -5284,7 +5296,7 @@ static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx,
4555 + EFX_WARN_ON_PARANOID(ids[i] != EFX_EF10_FILTER_ID_INVALID);
4556 + efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0);
4557 + efx_filter_set_eth_local(&spec, vlan->vid, addr_list[i].addr);
4558 +- rc = efx_ef10_filter_insert(efx, &spec, true);
4559 ++ rc = efx_ef10_filter_insert_locked(efx, &spec, true);
4560 + if (rc < 0) {
4561 + if (rollback) {
4562 + netif_info(efx, drv, efx->net_dev,
4563 +@@ -5313,7 +5325,7 @@ static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx,
4564 + efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0);
4565 + eth_broadcast_addr(baddr);
4566 + efx_filter_set_eth_local(&spec, vlan->vid, baddr);
4567 +- rc = efx_ef10_filter_insert(efx, &spec, true);
4568 ++ rc = efx_ef10_filter_insert_locked(efx, &spec, true);
4569 + if (rc < 0) {
4570 + netif_warn(efx, drv, efx->net_dev,
4571 + "Broadcast filter insert failed rc=%d\n", rc);
4572 +@@ -5369,7 +5381,7 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx,
4573 + if (vlan->vid != EFX_FILTER_VID_UNSPEC)
4574 + efx_filter_set_eth_local(&spec, vlan->vid, NULL);
4575 +
4576 +- rc = efx_ef10_filter_insert(efx, &spec, true);
4577 ++ rc = efx_ef10_filter_insert_locked(efx, &spec, true);
4578 + if (rc < 0) {
4579 + const char *um = multicast ? "Multicast" : "Unicast";
4580 + const char *encap_name = "";
4581 +@@ -5429,7 +5441,7 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx,
4582 + filter_flags, 0);
4583 + eth_broadcast_addr(baddr);
4584 + efx_filter_set_eth_local(&spec, vlan->vid, baddr);
4585 +- rc = efx_ef10_filter_insert(efx, &spec, true);
4586 ++ rc = efx_ef10_filter_insert_locked(efx, &spec, true);
4587 + if (rc < 0) {
4588 + netif_warn(efx, drv, efx->net_dev,
4589 + "Broadcast filter insert failed rc=%d\n",
4590 +diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
4591 +index a4ebd8715494..bf41157cc712 100644
4592 +--- a/drivers/net/ethernet/sfc/efx.c
4593 ++++ b/drivers/net/ethernet/sfc/efx.c
4594 +@@ -1840,12 +1840,6 @@ static void efx_remove_filters(struct efx_nic *efx)
4595 + up_write(&efx->filter_sem);
4596 + }
4597 +
4598 +-static void efx_restore_filters(struct efx_nic *efx)
4599 +-{
4600 +- down_read(&efx->filter_sem);
4601 +- efx->type->filter_table_restore(efx);
4602 +- up_read(&efx->filter_sem);
4603 +-}
4604 +
4605 + /**************************************************************************
4606 + *
4607 +@@ -2657,6 +2651,7 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method)
4608 + efx_disable_interrupts(efx);
4609 +
4610 + mutex_lock(&efx->mac_lock);
4611 ++ down_write(&efx->filter_sem);
4612 + mutex_lock(&efx->rss_lock);
4613 + if (efx->port_initialized && method != RESET_TYPE_INVISIBLE &&
4614 + method != RESET_TYPE_DATAPATH)
4615 +@@ -2714,9 +2709,8 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok)
4616 + if (efx->type->rx_restore_rss_contexts)
4617 + efx->type->rx_restore_rss_contexts(efx);
4618 + mutex_unlock(&efx->rss_lock);
4619 +- down_read(&efx->filter_sem);
4620 +- efx_restore_filters(efx);
4621 +- up_read(&efx->filter_sem);
4622 ++ efx->type->filter_table_restore(efx);
4623 ++ up_write(&efx->filter_sem);
4624 + if (efx->type->sriov_reset)
4625 + efx->type->sriov_reset(efx);
4626 +
4627 +@@ -2733,6 +2727,7 @@ fail:
4628 + efx->port_initialized = false;
4629 +
4630 + mutex_unlock(&efx->rss_lock);
4631 ++ up_write(&efx->filter_sem);
4632 + mutex_unlock(&efx->mac_lock);
4633 +
4634 + return rc;
4635 +@@ -3440,7 +3435,9 @@ static int efx_pci_probe_main(struct efx_nic *efx)
4636 +
4637 + efx_init_napi(efx);
4638 +
4639 ++ down_write(&efx->filter_sem);
4640 + rc = efx->type->init(efx);
4641 ++ up_write(&efx->filter_sem);
4642 + if (rc) {
4643 + netif_err(efx, probe, efx->net_dev,
4644 + "failed to initialise NIC\n");
4645 +@@ -3729,7 +3726,9 @@ static int efx_pm_resume(struct device *dev)
4646 + rc = efx->type->reset(efx, RESET_TYPE_ALL);
4647 + if (rc)
4648 + return rc;
4649 ++ down_write(&efx->filter_sem);
4650 + rc = efx->type->init(efx);
4651 ++ up_write(&efx->filter_sem);
4652 + if (rc)
4653 + return rc;
4654 + rc = efx_pm_thaw(dev);
4655 +diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
4656 +index e28c0d2c58e9..bf4acebb6bcd 100644
4657 +--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
4658 ++++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
4659 +@@ -111,7 +111,7 @@ config DWMAC_ROCKCHIP
4660 + config DWMAC_SOCFPGA
4661 + tristate "SOCFPGA dwmac support"
4662 + default ARCH_SOCFPGA
4663 +- depends on OF && (ARCH_SOCFPGA || COMPILE_TEST)
4664 ++ depends on OF && (ARCH_SOCFPGA || ARCH_STRATIX10 || COMPILE_TEST)
4665 + select MFD_SYSCON
4666 + help
4667 + Support for ethernet controller on Altera SOCFPGA
4668 +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
4669 +index 6e359572b9f0..5b3b06a0a3bf 100644
4670 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
4671 ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
4672 +@@ -55,6 +55,7 @@ struct socfpga_dwmac {
4673 + struct device *dev;
4674 + struct regmap *sys_mgr_base_addr;
4675 + struct reset_control *stmmac_rst;
4676 ++ struct reset_control *stmmac_ocp_rst;
4677 + void __iomem *splitter_base;
4678 + bool f2h_ptp_ref_clk;
4679 + struct tse_pcs pcs;
4680 +@@ -262,8 +263,8 @@ static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
4681 + val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
4682 +
4683 + /* Assert reset to the enet controller before changing the phy mode */
4684 +- if (dwmac->stmmac_rst)
4685 +- reset_control_assert(dwmac->stmmac_rst);
4686 ++ reset_control_assert(dwmac->stmmac_ocp_rst);
4687 ++ reset_control_assert(dwmac->stmmac_rst);
4688 +
4689 + regmap_read(sys_mgr_base_addr, reg_offset, &ctrl);
4690 + ctrl &= ~(SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << reg_shift);
4691 +@@ -288,8 +289,8 @@ static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
4692 + /* Deassert reset for the phy configuration to be sampled by
4693 + * the enet controller, and operation to start in requested mode
4694 + */
4695 +- if (dwmac->stmmac_rst)
4696 +- reset_control_deassert(dwmac->stmmac_rst);
4697 ++ reset_control_deassert(dwmac->stmmac_ocp_rst);
4698 ++ reset_control_deassert(dwmac->stmmac_rst);
4699 + if (phymode == PHY_INTERFACE_MODE_SGMII) {
4700 + if (tse_pcs_init(dwmac->pcs.tse_pcs_base, &dwmac->pcs) != 0) {
4701 + dev_err(dwmac->dev, "Unable to initialize TSE PCS");
4702 +@@ -324,6 +325,15 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
4703 + goto err_remove_config_dt;
4704 + }
4705 +
4706 ++ dwmac->stmmac_ocp_rst = devm_reset_control_get_optional(dev, "stmmaceth-ocp");
4707 ++ if (IS_ERR(dwmac->stmmac_ocp_rst)) {
4708 ++ ret = PTR_ERR(dwmac->stmmac_ocp_rst);
4709 ++ dev_err(dev, "error getting reset control of ocp %d\n", ret);
4710 ++ goto err_remove_config_dt;
4711 ++ }
4712 ++
4713 ++ reset_control_deassert(dwmac->stmmac_ocp_rst);
4714 ++
4715 + ret = socfpga_dwmac_parse_data(dwmac, dev);
4716 + if (ret) {
4717 + dev_err(dev, "Unable to parse OF data\n");
4718 +diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
4719 +index 1480c094b57d..a817fad26a7b 100644
4720 +--- a/drivers/net/ethernet/ti/davinci_emac.c
4721 ++++ b/drivers/net/ethernet/ti/davinci_emac.c
4722 +@@ -1387,6 +1387,10 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
4723 +
4724 + static int match_first_device(struct device *dev, void *data)
4725 + {
4726 ++ if (dev->parent && dev->parent->of_node)
4727 ++ return of_device_is_compatible(dev->parent->of_node,
4728 ++ "ti,davinci_mdio");
4729 ++
4730 + return !strncmp(dev_name(dev), "davinci_mdio", 12);
4731 + }
4732 +
4733 +diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
4734 +index dfabbae72efd..4a22e169b5a5 100644
4735 +--- a/drivers/net/hamradio/bpqether.c
4736 ++++ b/drivers/net/hamradio/bpqether.c
4737 +@@ -89,10 +89,6 @@
4738 + static const char banner[] __initconst = KERN_INFO \
4739 + "AX.25: bpqether driver version 004\n";
4740 +
4741 +-static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4742 +-
4743 +-static char bpq_eth_addr[6];
4744 +-
4745 + static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);
4746 + static int bpq_device_event(struct notifier_block *, unsigned long, void *);
4747 +
4748 +@@ -515,8 +511,8 @@ static int bpq_new_device(struct net_device *edev)
4749 + bpq->ethdev = edev;
4750 + bpq->axdev = ndev;
4751 +
4752 +- memcpy(bpq->dest_addr, bcast_addr, sizeof(bpq_eth_addr));
4753 +- memcpy(bpq->acpt_addr, bcast_addr, sizeof(bpq_eth_addr));
4754 ++ eth_broadcast_addr(bpq->dest_addr);
4755 ++ eth_broadcast_addr(bpq->acpt_addr);
4756 +
4757 + err = register_netdevice(ndev);
4758 + if (err)
4759 +diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
4760 +index f362cda85425..fde0cddac71a 100644
4761 +--- a/drivers/net/hyperv/rndis_filter.c
4762 ++++ b/drivers/net/hyperv/rndis_filter.c
4763 +@@ -1307,6 +1307,7 @@ out:
4764 + /* setting up multiple channels failed */
4765 + net_device->max_chn = 1;
4766 + net_device->num_chn = 1;
4767 ++ return 0;
4768 +
4769 + err_dev_remv:
4770 + rndis_filter_device_remove(dev, net_device);
4771 +diff --git a/drivers/net/ieee802154/adf7242.c b/drivers/net/ieee802154/adf7242.c
4772 +index 64f1b1e77bc0..23a52b9293f3 100644
4773 +--- a/drivers/net/ieee802154/adf7242.c
4774 ++++ b/drivers/net/ieee802154/adf7242.c
4775 +@@ -275,6 +275,8 @@ struct adf7242_local {
4776 + struct spi_message stat_msg;
4777 + struct spi_transfer stat_xfer;
4778 + struct dentry *debugfs_root;
4779 ++ struct delayed_work work;
4780 ++ struct workqueue_struct *wqueue;
4781 + unsigned long flags;
4782 + int tx_stat;
4783 + bool promiscuous;
4784 +@@ -575,10 +577,26 @@ static int adf7242_cmd_rx(struct adf7242_local *lp)
4785 + /* Wait until the ACK is sent */
4786 + adf7242_wait_status(lp, RC_STATUS_PHY_RDY, RC_STATUS_MASK, __LINE__);
4787 + adf7242_clear_irqstat(lp);
4788 ++ mod_delayed_work(lp->wqueue, &lp->work, msecs_to_jiffies(400));
4789 +
4790 + return adf7242_cmd(lp, CMD_RC_RX);
4791 + }
4792 +
4793 ++static void adf7242_rx_cal_work(struct work_struct *work)
4794 ++{
4795 ++ struct adf7242_local *lp =
4796 ++ container_of(work, struct adf7242_local, work.work);
4797 ++
4798 ++ /* Reissuing RC_RX every 400ms - to adjust for offset
4799 ++ * drift in receiver (datasheet page 61, OCL section)
4800 ++ */
4801 ++
4802 ++ if (!test_bit(FLAG_XMIT, &lp->flags)) {
4803 ++ adf7242_cmd(lp, CMD_RC_PHY_RDY);
4804 ++ adf7242_cmd_rx(lp);
4805 ++ }
4806 ++}
4807 ++
4808 + static int adf7242_set_txpower(struct ieee802154_hw *hw, int mbm)
4809 + {
4810 + struct adf7242_local *lp = hw->priv;
4811 +@@ -686,7 +704,7 @@ static int adf7242_start(struct ieee802154_hw *hw)
4812 + enable_irq(lp->spi->irq);
4813 + set_bit(FLAG_START, &lp->flags);
4814 +
4815 +- return adf7242_cmd(lp, CMD_RC_RX);
4816 ++ return adf7242_cmd_rx(lp);
4817 + }
4818 +
4819 + static void adf7242_stop(struct ieee802154_hw *hw)
4820 +@@ -694,6 +712,7 @@ static void adf7242_stop(struct ieee802154_hw *hw)
4821 + struct adf7242_local *lp = hw->priv;
4822 +
4823 + disable_irq(lp->spi->irq);
4824 ++ cancel_delayed_work_sync(&lp->work);
4825 + adf7242_cmd(lp, CMD_RC_IDLE);
4826 + clear_bit(FLAG_START, &lp->flags);
4827 + adf7242_clear_irqstat(lp);
4828 +@@ -719,7 +738,10 @@ static int adf7242_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
4829 + adf7242_write_reg(lp, REG_CH_FREQ1, freq >> 8);
4830 + adf7242_write_reg(lp, REG_CH_FREQ2, freq >> 16);
4831 +
4832 +- return adf7242_cmd(lp, CMD_RC_RX);
4833 ++ if (test_bit(FLAG_START, &lp->flags))
4834 ++ return adf7242_cmd_rx(lp);
4835 ++ else
4836 ++ return adf7242_cmd(lp, CMD_RC_PHY_RDY);
4837 + }
4838 +
4839 + static int adf7242_set_hw_addr_filt(struct ieee802154_hw *hw,
4840 +@@ -814,6 +836,7 @@ static int adf7242_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
4841 + /* ensure existing instances of the IRQ handler have completed */
4842 + disable_irq(lp->spi->irq);
4843 + set_bit(FLAG_XMIT, &lp->flags);
4844 ++ cancel_delayed_work_sync(&lp->work);
4845 + reinit_completion(&lp->tx_complete);
4846 + adf7242_cmd(lp, CMD_RC_PHY_RDY);
4847 + adf7242_clear_irqstat(lp);
4848 +@@ -952,6 +975,7 @@ static irqreturn_t adf7242_isr(int irq, void *data)
4849 + unsigned int xmit;
4850 + u8 irq1;
4851 +
4852 ++ mod_delayed_work(lp->wqueue, &lp->work, msecs_to_jiffies(400));
4853 + adf7242_read_reg(lp, REG_IRQ1_SRC1, &irq1);
4854 +
4855 + if (!(irq1 & (IRQ_RX_PKT_RCVD | IRQ_CSMA_CA)))
4856 +@@ -1241,6 +1265,9 @@ static int adf7242_probe(struct spi_device *spi)
4857 + spi_message_add_tail(&lp->stat_xfer, &lp->stat_msg);
4858 +
4859 + spi_set_drvdata(spi, lp);
4860 ++ INIT_DELAYED_WORK(&lp->work, adf7242_rx_cal_work);
4861 ++ lp->wqueue = alloc_ordered_workqueue(dev_name(&spi->dev),
4862 ++ WQ_MEM_RECLAIM);
4863 +
4864 + ret = adf7242_hw_init(lp);
4865 + if (ret)
4866 +@@ -1284,6 +1311,9 @@ static int adf7242_remove(struct spi_device *spi)
4867 + if (!IS_ERR_OR_NULL(lp->debugfs_root))
4868 + debugfs_remove_recursive(lp->debugfs_root);
4869 +
4870 ++ cancel_delayed_work_sync(&lp->work);
4871 ++ destroy_workqueue(lp->wqueue);
4872 ++
4873 + ieee802154_unregister_hw(lp->hw);
4874 + mutex_destroy(&lp->bmux);
4875 + ieee802154_free_hw(lp->hw);
4876 +diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
4877 +index 77abedf0b524..3d9e91579866 100644
4878 +--- a/drivers/net/ieee802154/at86rf230.c
4879 ++++ b/drivers/net/ieee802154/at86rf230.c
4880 +@@ -940,7 +940,7 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
4881 + static int
4882 + at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
4883 + {
4884 +- BUG_ON(!level);
4885 ++ WARN_ON(!level);
4886 + *level = 0xbe;
4887 + return 0;
4888 + }
4889 +@@ -1121,8 +1121,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
4890 + if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
4891 + u16 addr = le16_to_cpu(filt->short_addr);
4892 +
4893 +- dev_vdbg(&lp->spi->dev,
4894 +- "at86rf230_set_hw_addr_filt called for saddr\n");
4895 ++ dev_vdbg(&lp->spi->dev, "%s called for saddr\n", __func__);
4896 + __at86rf230_write(lp, RG_SHORT_ADDR_0, addr);
4897 + __at86rf230_write(lp, RG_SHORT_ADDR_1, addr >> 8);
4898 + }
4899 +@@ -1130,8 +1129,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
4900 + if (changed & IEEE802154_AFILT_PANID_CHANGED) {
4901 + u16 pan = le16_to_cpu(filt->pan_id);
4902 +
4903 +- dev_vdbg(&lp->spi->dev,
4904 +- "at86rf230_set_hw_addr_filt called for pan id\n");
4905 ++ dev_vdbg(&lp->spi->dev, "%s called for pan id\n", __func__);
4906 + __at86rf230_write(lp, RG_PAN_ID_0, pan);
4907 + __at86rf230_write(lp, RG_PAN_ID_1, pan >> 8);
4908 + }
4909 +@@ -1140,15 +1138,13 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
4910 + u8 i, addr[8];
4911 +
4912 + memcpy(addr, &filt->ieee_addr, 8);
4913 +- dev_vdbg(&lp->spi->dev,
4914 +- "at86rf230_set_hw_addr_filt called for IEEE addr\n");
4915 ++ dev_vdbg(&lp->spi->dev, "%s called for IEEE addr\n", __func__);
4916 + for (i = 0; i < 8; i++)
4917 + __at86rf230_write(lp, RG_IEEE_ADDR_0 + i, addr[i]);
4918 + }
4919 +
4920 + if (changed & IEEE802154_AFILT_PANC_CHANGED) {
4921 +- dev_vdbg(&lp->spi->dev,
4922 +- "at86rf230_set_hw_addr_filt called for panc change\n");
4923 ++ dev_vdbg(&lp->spi->dev, "%s called for panc change\n", __func__);
4924 + if (filt->pan_coord)
4925 + at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1);
4926 + else
4927 +@@ -1252,7 +1248,6 @@ at86rf230_set_cca_mode(struct ieee802154_hw *hw,
4928 + return at86rf230_write_subreg(lp, SR_CCA_MODE, val);
4929 + }
4930 +
4931 +-
4932 + static int
4933 + at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
4934 + {
4935 +diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c
4936 +index 0d673f7682ee..176395e4b7bb 100644
4937 +--- a/drivers/net/ieee802154/fakelb.c
4938 ++++ b/drivers/net/ieee802154/fakelb.c
4939 +@@ -49,7 +49,7 @@ struct fakelb_phy {
4940 +
4941 + static int fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level)
4942 + {
4943 +- BUG_ON(!level);
4944 ++ WARN_ON(!level);
4945 + *level = 0xbe;
4946 +
4947 + return 0;
4948 +diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
4949 +index de0d7f28a181..e428277781ac 100644
4950 +--- a/drivers/net/ieee802154/mcr20a.c
4951 ++++ b/drivers/net/ieee802154/mcr20a.c
4952 +@@ -15,10 +15,11 @@
4953 + */
4954 + #include <linux/kernel.h>
4955 + #include <linux/module.h>
4956 +-#include <linux/gpio.h>
4957 ++#include <linux/gpio/consumer.h>
4958 + #include <linux/spi/spi.h>
4959 + #include <linux/workqueue.h>
4960 + #include <linux/interrupt.h>
4961 ++#include <linux/irq.h>
4962 + #include <linux/skbuff.h>
4963 + #include <linux/of_gpio.h>
4964 + #include <linux/regmap.h>
4965 +diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
4966 +index 6641fd5355e0..6511b1309940 100644
4967 +--- a/drivers/net/ipvlan/ipvlan_main.c
4968 ++++ b/drivers/net/ipvlan/ipvlan_main.c
4969 +@@ -75,10 +75,23 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval)
4970 + {
4971 + struct ipvl_dev *ipvlan;
4972 + struct net_device *mdev = port->dev;
4973 +- int err = 0;
4974 ++ unsigned int flags;
4975 ++ int err;
4976 +
4977 + ASSERT_RTNL();
4978 + if (port->mode != nval) {
4979 ++ list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
4980 ++ flags = ipvlan->dev->flags;
4981 ++ if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S) {
4982 ++ err = dev_change_flags(ipvlan->dev,
4983 ++ flags | IFF_NOARP);
4984 ++ } else {
4985 ++ err = dev_change_flags(ipvlan->dev,
4986 ++ flags & ~IFF_NOARP);
4987 ++ }
4988 ++ if (unlikely(err))
4989 ++ goto fail;
4990 ++ }
4991 + if (nval == IPVLAN_MODE_L3S) {
4992 + /* New mode is L3S */
4993 + err = ipvlan_register_nf_hook(read_pnet(&port->pnet));
4994 +@@ -86,21 +99,28 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval)
4995 + mdev->l3mdev_ops = &ipvl_l3mdev_ops;
4996 + mdev->priv_flags |= IFF_L3MDEV_MASTER;
4997 + } else
4998 +- return err;
4999 ++ goto fail;
5000 + } else if (port->mode == IPVLAN_MODE_L3S) {
5001 + /* Old mode was L3S */
5002 + mdev->priv_flags &= ~IFF_L3MDEV_MASTER;
5003 + ipvlan_unregister_nf_hook(read_pnet(&port->pnet));
5004 + mdev->l3mdev_ops = NULL;
5005 + }
5006 +- list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
5007 +- if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S)
5008 +- ipvlan->dev->flags |= IFF_NOARP;
5009 +- else
5010 +- ipvlan->dev->flags &= ~IFF_NOARP;
5011 +- }
5012 + port->mode = nval;
5013 + }
5014 ++ return 0;
5015 ++
5016 ++fail:
5017 ++ /* Undo the flags changes that have been done so far. */
5018 ++ list_for_each_entry_continue_reverse(ipvlan, &port->ipvlans, pnode) {
5019 ++ flags = ipvlan->dev->flags;
5020 ++ if (port->mode == IPVLAN_MODE_L3 ||
5021 ++ port->mode == IPVLAN_MODE_L3S)
5022 ++ dev_change_flags(ipvlan->dev, flags | IFF_NOARP);
5023 ++ else
5024 ++ dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP);
5025 ++ }
5026 ++
5027 + return err;
5028 + }
5029 +
5030 +diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
5031 +index 25e2a099b71c..adb2ec74ffc0 100644
5032 +--- a/drivers/net/phy/marvell.c
5033 ++++ b/drivers/net/phy/marvell.c
5034 +@@ -130,8 +130,9 @@
5035 + #define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12)
5036 + #define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14)
5037 +
5038 +-#define MII_88E1121_PHY_LED_CTRL 16
5039 ++#define MII_PHY_LED_CTRL 16
5040 + #define MII_88E1121_PHY_LED_DEF 0x0030
5041 ++#define MII_88E1510_PHY_LED_DEF 0x1177
5042 +
5043 + #define MII_M1011_PHY_STATUS 0x11
5044 + #define MII_M1011_PHY_STATUS_1000 0x8000
5045 +@@ -632,8 +633,40 @@ error:
5046 + return err;
5047 + }
5048 +
5049 ++static void marvell_config_led(struct phy_device *phydev)
5050 ++{
5051 ++ u16 def_config;
5052 ++ int err;
5053 ++
5054 ++ switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) {
5055 ++ /* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */
5056 ++ case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1121R):
5057 ++ case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1318S):
5058 ++ def_config = MII_88E1121_PHY_LED_DEF;
5059 ++ break;
5060 ++ /* Default PHY LED config:
5061 ++ * LED[0] .. 1000Mbps Link
5062 ++ * LED[1] .. 100Mbps Link
5063 ++ * LED[2] .. Blink, Activity
5064 ++ */
5065 ++ case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1510):
5066 ++ def_config = MII_88E1510_PHY_LED_DEF;
5067 ++ break;
5068 ++ default:
5069 ++ return;
5070 ++ }
5071 ++
5072 ++ err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL,
5073 ++ def_config);
5074 ++ if (err < 0)
5075 ++ pr_warn("Fail to config marvell phy LED.\n");
5076 ++}
5077 ++
5078 + static int marvell_config_init(struct phy_device *phydev)
5079 + {
5080 ++ /* Set defalut LED */
5081 ++ marvell_config_led(phydev);
5082 ++
5083 + /* Set registers from marvell,reg-init DT property */
5084 + return marvell_of_reg_init(phydev);
5085 + }
5086 +@@ -813,21 +846,6 @@ static int m88e1111_config_init(struct phy_device *phydev)
5087 + return genphy_soft_reset(phydev);
5088 + }
5089 +
5090 +-static int m88e1121_config_init(struct phy_device *phydev)
5091 +-{
5092 +- int err;
5093 +-
5094 +- /* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */
5095 +- err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE,
5096 +- MII_88E1121_PHY_LED_CTRL,
5097 +- MII_88E1121_PHY_LED_DEF);
5098 +- if (err < 0)
5099 +- return err;
5100 +-
5101 +- /* Set marvell,reg-init configuration from device tree */
5102 +- return marvell_config_init(phydev);
5103 +-}
5104 +-
5105 + static int m88e1318_config_init(struct phy_device *phydev)
5106 + {
5107 + if (phy_interrupt_is_valid(phydev)) {
5108 +@@ -841,7 +859,7 @@ static int m88e1318_config_init(struct phy_device *phydev)
5109 + return err;
5110 + }
5111 +
5112 +- return m88e1121_config_init(phydev);
5113 ++ return marvell_config_init(phydev);
5114 + }
5115 +
5116 + static int m88e1510_config_init(struct phy_device *phydev)
5117 +@@ -2090,7 +2108,7 @@ static struct phy_driver marvell_drivers[] = {
5118 + .features = PHY_GBIT_FEATURES,
5119 + .flags = PHY_HAS_INTERRUPT,
5120 + .probe = &m88e1121_probe,
5121 +- .config_init = &m88e1121_config_init,
5122 ++ .config_init = &marvell_config_init,
5123 + .config_aneg = &m88e1121_config_aneg,
5124 + .read_status = &marvell_read_status,
5125 + .ack_interrupt = &marvell_ack_interrupt,
5126 +diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
5127 +index d437f4f5ed52..740655261e5b 100644
5128 +--- a/drivers/net/phy/sfp-bus.c
5129 ++++ b/drivers/net/phy/sfp-bus.c
5130 +@@ -349,7 +349,6 @@ static int sfp_register_bus(struct sfp_bus *bus)
5131 + }
5132 + if (bus->started)
5133 + bus->socket_ops->start(bus->sfp);
5134 +- bus->netdev->sfp_bus = bus;
5135 + bus->registered = true;
5136 + return 0;
5137 + }
5138 +@@ -364,7 +363,6 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
5139 + if (bus->phydev && ops && ops->disconnect_phy)
5140 + ops->disconnect_phy(bus->upstream);
5141 + }
5142 +- bus->netdev->sfp_bus = NULL;
5143 + bus->registered = false;
5144 + }
5145 +
5146 +@@ -436,6 +434,14 @@ void sfp_upstream_stop(struct sfp_bus *bus)
5147 + }
5148 + EXPORT_SYMBOL_GPL(sfp_upstream_stop);
5149 +
5150 ++static void sfp_upstream_clear(struct sfp_bus *bus)
5151 ++{
5152 ++ bus->upstream_ops = NULL;
5153 ++ bus->upstream = NULL;
5154 ++ bus->netdev->sfp_bus = NULL;
5155 ++ bus->netdev = NULL;
5156 ++}
5157 ++
5158 + /**
5159 + * sfp_register_upstream() - Register the neighbouring device
5160 + * @fwnode: firmware node for the SFP bus
5161 +@@ -461,9 +467,13 @@ struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode,
5162 + bus->upstream_ops = ops;
5163 + bus->upstream = upstream;
5164 + bus->netdev = ndev;
5165 ++ ndev->sfp_bus = bus;
5166 +
5167 +- if (bus->sfp)
5168 ++ if (bus->sfp) {
5169 + ret = sfp_register_bus(bus);
5170 ++ if (ret)
5171 ++ sfp_upstream_clear(bus);
5172 ++ }
5173 + rtnl_unlock();
5174 + }
5175 +
5176 +@@ -488,8 +498,7 @@ void sfp_unregister_upstream(struct sfp_bus *bus)
5177 + rtnl_lock();
5178 + if (bus->sfp)
5179 + sfp_unregister_bus(bus);
5180 +- bus->upstream = NULL;
5181 +- bus->netdev = NULL;
5182 ++ sfp_upstream_clear(bus);
5183 + rtnl_unlock();
5184 +
5185 + sfp_bus_put(bus);
5186 +@@ -561,6 +570,13 @@ void sfp_module_remove(struct sfp_bus *bus)
5187 + }
5188 + EXPORT_SYMBOL_GPL(sfp_module_remove);
5189 +
5190 ++static void sfp_socket_clear(struct sfp_bus *bus)
5191 ++{
5192 ++ bus->sfp_dev = NULL;
5193 ++ bus->sfp = NULL;
5194 ++ bus->socket_ops = NULL;
5195 ++}
5196 ++
5197 + struct sfp_bus *sfp_register_socket(struct device *dev, struct sfp *sfp,
5198 + const struct sfp_socket_ops *ops)
5199 + {
5200 +@@ -573,8 +589,11 @@ struct sfp_bus *sfp_register_socket(struct device *dev, struct sfp *sfp,
5201 + bus->sfp = sfp;
5202 + bus->socket_ops = ops;
5203 +
5204 +- if (bus->netdev)
5205 ++ if (bus->netdev) {
5206 + ret = sfp_register_bus(bus);
5207 ++ if (ret)
5208 ++ sfp_socket_clear(bus);
5209 ++ }
5210 + rtnl_unlock();
5211 + }
5212 +
5213 +@@ -592,9 +611,7 @@ void sfp_unregister_socket(struct sfp_bus *bus)
5214 + rtnl_lock();
5215 + if (bus->netdev)
5216 + sfp_unregister_bus(bus);
5217 +- bus->sfp_dev = NULL;
5218 +- bus->sfp = NULL;
5219 +- bus->socket_ops = NULL;
5220 ++ sfp_socket_clear(bus);
5221 + rtnl_unlock();
5222 +
5223 + sfp_bus_put(bus);
5224 +diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
5225 +index 5f565bd574da..48ba80a8ca5c 100644
5226 +--- a/drivers/net/usb/rtl8150.c
5227 ++++ b/drivers/net/usb/rtl8150.c
5228 +@@ -681,7 +681,7 @@ static void rtl8150_set_multicast(struct net_device *netdev)
5229 + (netdev->flags & IFF_ALLMULTI)) {
5230 + rx_creg &= 0xfffe;
5231 + rx_creg |= 0x0002;
5232 +- dev_info(&netdev->dev, "%s: allmulti set\n", netdev->name);
5233 ++ dev_dbg(&netdev->dev, "%s: allmulti set\n", netdev->name);
5234 + } else {
5235 + /* ~RX_MULTICAST, ~RX_PROMISCUOUS */
5236 + rx_creg &= 0x00fc;
5237 +diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
5238 +index 7a6a1fe79309..05553d252446 100644
5239 +--- a/drivers/net/usb/smsc75xx.c
5240 ++++ b/drivers/net/usb/smsc75xx.c
5241 +@@ -82,6 +82,9 @@ static bool turbo_mode = true;
5242 + module_param(turbo_mode, bool, 0644);
5243 + MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
5244 +
5245 ++static int smsc75xx_link_ok_nopm(struct usbnet *dev);
5246 ++static int smsc75xx_phy_gig_workaround(struct usbnet *dev);
5247 ++
5248 + static int __must_check __smsc75xx_read_reg(struct usbnet *dev, u32 index,
5249 + u32 *data, int in_pm)
5250 + {
5251 +@@ -852,6 +855,9 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
5252 + return -EIO;
5253 + }
5254 +
5255 ++ /* phy workaround for gig link */
5256 ++ smsc75xx_phy_gig_workaround(dev);
5257 ++
5258 + smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
5259 + ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP |
5260 + ADVERTISE_PAUSE_ASYM);
5261 +@@ -987,6 +993,62 @@ static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm)
5262 + return -EIO;
5263 + }
5264 +
5265 ++static int smsc75xx_phy_gig_workaround(struct usbnet *dev)
5266 ++{
5267 ++ struct mii_if_info *mii = &dev->mii;
5268 ++ int ret = 0, timeout = 0;
5269 ++ u32 buf, link_up = 0;
5270 ++
5271 ++ /* Set the phy in Gig loopback */
5272 ++ smsc75xx_mdio_write(dev->net, mii->phy_id, MII_BMCR, 0x4040);
5273 ++
5274 ++ /* Wait for the link up */
5275 ++ do {
5276 ++ link_up = smsc75xx_link_ok_nopm(dev);
5277 ++ usleep_range(10000, 20000);
5278 ++ timeout++;
5279 ++ } while ((!link_up) && (timeout < 1000));
5280 ++
5281 ++ if (timeout >= 1000) {
5282 ++ netdev_warn(dev->net, "Timeout waiting for PHY link up\n");
5283 ++ return -EIO;
5284 ++ }
5285 ++
5286 ++ /* phy reset */
5287 ++ ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
5288 ++ if (ret < 0) {
5289 ++ netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret);
5290 ++ return ret;
5291 ++ }
5292 ++
5293 ++ buf |= PMT_CTL_PHY_RST;
5294 ++
5295 ++ ret = smsc75xx_write_reg(dev, PMT_CTL, buf);
5296 ++ if (ret < 0) {
5297 ++ netdev_warn(dev->net, "Failed to write PMT_CTL: %d\n", ret);
5298 ++ return ret;
5299 ++ }
5300 ++
5301 ++ timeout = 0;
5302 ++ do {
5303 ++ usleep_range(10000, 20000);
5304 ++ ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
5305 ++ if (ret < 0) {
5306 ++ netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n",
5307 ++ ret);
5308 ++ return ret;
5309 ++ }
5310 ++ timeout++;
5311 ++ } while ((buf & PMT_CTL_PHY_RST) && (timeout < 100));
5312 ++
5313 ++ if (timeout >= 100) {
5314 ++ netdev_warn(dev->net, "timeout waiting for PHY Reset\n");
5315 ++ return -EIO;
5316 ++ }
5317 ++
5318 ++ return 0;
5319 ++}
5320 ++
5321 + static int smsc75xx_reset(struct usbnet *dev)
5322 + {
5323 + struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
5324 +diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
5325 +index bf05a3689558..9fb89f3b8c59 100644
5326 +--- a/drivers/net/wireless/ath/ath10k/mac.c
5327 ++++ b/drivers/net/wireless/ath/ath10k/mac.c
5328 +@@ -6018,8 +6018,19 @@ static void ath10k_sta_rc_update_wk(struct work_struct *wk)
5329 + ath10k_mac_max_vht_nss(vht_mcs_mask)));
5330 +
5331 + if (changed & IEEE80211_RC_BW_CHANGED) {
5332 +- ath10k_dbg(ar, ATH10K_DBG_MAC, "mac update sta %pM peer bw %d\n",
5333 +- sta->addr, bw);
5334 ++ enum wmi_phy_mode mode;
5335 ++
5336 ++ mode = chan_to_phymode(&def);
5337 ++ ath10k_dbg(ar, ATH10K_DBG_MAC, "mac update sta %pM peer bw %d phymode %d\n",
5338 ++ sta->addr, bw, mode);
5339 ++
5340 ++ err = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr,
5341 ++ WMI_PEER_PHYMODE, mode);
5342 ++ if (err) {
5343 ++ ath10k_warn(ar, "failed to update STA %pM peer phymode %d: %d\n",
5344 ++ sta->addr, mode, err);
5345 ++ goto exit;
5346 ++ }
5347 +
5348 + err = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr,
5349 + WMI_PEER_CHAN_WIDTH, bw);
5350 +@@ -6060,6 +6071,7 @@ static void ath10k_sta_rc_update_wk(struct work_struct *wk)
5351 + sta->addr);
5352 + }
5353 +
5354 ++exit:
5355 + mutex_unlock(&ar->conf_mutex);
5356 + }
5357 +
5358 +diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
5359 +index 7fde22ea2ffa..d0a380d81d74 100644
5360 +--- a/drivers/net/wireless/ath/ath10k/wmi.h
5361 ++++ b/drivers/net/wireless/ath/ath10k/wmi.h
5362 +@@ -6098,6 +6098,7 @@ enum wmi_peer_param {
5363 + WMI_PEER_NSS = 0x5,
5364 + WMI_PEER_USE_4ADDR = 0x6,
5365 + WMI_PEER_DEBUG = 0xa,
5366 ++ WMI_PEER_PHYMODE = 0xd,
5367 + WMI_PEER_DUMMY_VAR = 0xff, /* dummy parameter for STA PS workaround */
5368 + };
5369 +
5370 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
5371 +index 1037df7297bb..32f2f8b63970 100644
5372 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
5373 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
5374 +@@ -4294,6 +4294,13 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)
5375 + brcmf_dbg(TRACE, "Enter\n");
5376 +
5377 + if (bus) {
5378 ++ /* Stop watchdog task */
5379 ++ if (bus->watchdog_tsk) {
5380 ++ send_sig(SIGTERM, bus->watchdog_tsk, 1);
5381 ++ kthread_stop(bus->watchdog_tsk);
5382 ++ bus->watchdog_tsk = NULL;
5383 ++ }
5384 ++
5385 + /* De-register interrupt handler */
5386 + brcmf_sdiod_intr_unregister(bus->sdiodev);
5387 +
5388 +diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
5389 +index d5553c47014f..5d823e965883 100644
5390 +--- a/drivers/nfc/pn533/usb.c
5391 ++++ b/drivers/nfc/pn533/usb.c
5392 +@@ -74,7 +74,7 @@ static void pn533_recv_response(struct urb *urb)
5393 + struct sk_buff *skb = NULL;
5394 +
5395 + if (!urb->status) {
5396 +- skb = alloc_skb(urb->actual_length, GFP_KERNEL);
5397 ++ skb = alloc_skb(urb->actual_length, GFP_ATOMIC);
5398 + if (!skb) {
5399 + nfc_err(&phy->udev->dev, "failed to alloc memory\n");
5400 + } else {
5401 +@@ -186,7 +186,7 @@ static int pn533_usb_send_frame(struct pn533 *dev,
5402 +
5403 + if (dev->protocol_type == PN533_PROTO_REQ_RESP) {
5404 + /* request for response for sent packet directly */
5405 +- rc = pn533_submit_urb_for_response(phy, GFP_ATOMIC);
5406 ++ rc = pn533_submit_urb_for_response(phy, GFP_KERNEL);
5407 + if (rc)
5408 + goto error;
5409 + } else if (dev->protocol_type == PN533_PROTO_REQ_ACK_RESP) {
5410 +diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
5411 +index b9ca782fe82d..620f837c1234 100644
5412 +--- a/drivers/nvme/host/core.c
5413 ++++ b/drivers/nvme/host/core.c
5414 +@@ -100,6 +100,22 @@ static struct class *nvme_subsys_class;
5415 + static void nvme_ns_remove(struct nvme_ns *ns);
5416 + static int nvme_revalidate_disk(struct gendisk *disk);
5417 + static void nvme_put_subsystem(struct nvme_subsystem *subsys);
5418 ++static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
5419 ++ unsigned nsid);
5420 ++
5421 ++static void nvme_set_queue_dying(struct nvme_ns *ns)
5422 ++{
5423 ++ /*
5424 ++ * Revalidating a dead namespace sets capacity to 0. This will end
5425 ++ * buffered writers dirtying pages that can't be synced.
5426 ++ */
5427 ++ if (!ns->disk || test_and_set_bit(NVME_NS_DEAD, &ns->flags))
5428 ++ return;
5429 ++ revalidate_disk(ns->disk);
5430 ++ blk_set_queue_dying(ns->queue);
5431 ++ /* Forcibly unquiesce queues to avoid blocking dispatch */
5432 ++ blk_mq_unquiesce_queue(ns->queue);
5433 ++}
5434 +
5435 + int nvme_reset_ctrl(struct nvme_ctrl *ctrl)
5436 + {
5437 +@@ -1130,19 +1146,15 @@ static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
5438 +
5439 + static void nvme_update_formats(struct nvme_ctrl *ctrl)
5440 + {
5441 +- struct nvme_ns *ns, *next;
5442 +- LIST_HEAD(rm_list);
5443 ++ struct nvme_ns *ns;
5444 +
5445 +- down_write(&ctrl->namespaces_rwsem);
5446 +- list_for_each_entry(ns, &ctrl->namespaces, list) {
5447 +- if (ns->disk && nvme_revalidate_disk(ns->disk)) {
5448 +- list_move_tail(&ns->list, &rm_list);
5449 +- }
5450 +- }
5451 +- up_write(&ctrl->namespaces_rwsem);
5452 ++ down_read(&ctrl->namespaces_rwsem);
5453 ++ list_for_each_entry(ns, &ctrl->namespaces, list)
5454 ++ if (ns->disk && nvme_revalidate_disk(ns->disk))
5455 ++ nvme_set_queue_dying(ns);
5456 ++ up_read(&ctrl->namespaces_rwsem);
5457 +
5458 +- list_for_each_entry_safe(ns, next, &rm_list, list)
5459 +- nvme_ns_remove(ns);
5460 ++ nvme_remove_invalid_namespaces(ctrl, NVME_NSID_ALL);
5461 + }
5462 +
5463 + static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects)
5464 +@@ -1197,7 +1209,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
5465 + effects = nvme_passthru_start(ctrl, ns, cmd.opcode);
5466 + status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c,
5467 + (void __user *)(uintptr_t)cmd.addr, cmd.data_len,
5468 +- (void __user *)(uintptr_t)cmd.metadata, cmd.metadata,
5469 ++ (void __user *)(uintptr_t)cmd.metadata, cmd.metadata_len,
5470 + 0, &cmd.result, timeout);
5471 + nvme_passthru_end(ctrl, effects);
5472 +
5473 +@@ -3110,7 +3122,7 @@ static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
5474 +
5475 + down_write(&ctrl->namespaces_rwsem);
5476 + list_for_each_entry_safe(ns, next, &ctrl->namespaces, list) {
5477 +- if (ns->head->ns_id > nsid)
5478 ++ if (ns->head->ns_id > nsid || test_bit(NVME_NS_DEAD, &ns->flags))
5479 + list_move_tail(&ns->list, &rm_list);
5480 + }
5481 + up_write(&ctrl->namespaces_rwsem);
5482 +@@ -3488,19 +3500,9 @@ void nvme_kill_queues(struct nvme_ctrl *ctrl)
5483 + if (ctrl->admin_q)
5484 + blk_mq_unquiesce_queue(ctrl->admin_q);
5485 +
5486 +- list_for_each_entry(ns, &ctrl->namespaces, list) {
5487 +- /*
5488 +- * Revalidating a dead namespace sets capacity to 0. This will
5489 +- * end buffered writers dirtying pages that can't be synced.
5490 +- */
5491 +- if (!ns->disk || test_and_set_bit(NVME_NS_DEAD, &ns->flags))
5492 +- continue;
5493 +- revalidate_disk(ns->disk);
5494 +- blk_set_queue_dying(ns->queue);
5495 ++ list_for_each_entry(ns, &ctrl->namespaces, list)
5496 ++ nvme_set_queue_dying(ns);
5497 +
5498 +- /* Forcibly unquiesce queues to avoid blocking dispatch */
5499 +- blk_mq_unquiesce_queue(ns->queue);
5500 +- }
5501 + up_read(&ctrl->namespaces_rwsem);
5502 + }
5503 + EXPORT_SYMBOL_GPL(nvme_kill_queues);
5504 +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
5505 +index 0483c33a3567..de9c3762a994 100644
5506 +--- a/drivers/nvme/host/pci.c
5507 ++++ b/drivers/nvme/host/pci.c
5508 +@@ -2291,6 +2291,7 @@ static void nvme_remove_dead_ctrl(struct nvme_dev *dev, int status)
5509 +
5510 + nvme_get_ctrl(&dev->ctrl);
5511 + nvme_dev_disable(dev, false);
5512 ++ nvme_kill_queues(&dev->ctrl);
5513 + if (!queue_work(nvme_wq, &dev->remove_work))
5514 + nvme_put_ctrl(&dev->ctrl);
5515 + }
5516 +@@ -2407,7 +2408,6 @@ static void nvme_remove_dead_ctrl_work(struct work_struct *work)
5517 + struct nvme_dev *dev = container_of(work, struct nvme_dev, remove_work);
5518 + struct pci_dev *pdev = to_pci_dev(dev->dev);
5519 +
5520 +- nvme_kill_queues(&dev->ctrl);
5521 + if (pci_get_drvdata(pdev))
5522 + device_release_driver(&pdev->dev);
5523 + nvme_put_ctrl(&dev->ctrl);
5524 +diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
5525 +index 2181299ce8f5..d1e8aa04d313 100644
5526 +--- a/drivers/nvme/host/rdma.c
5527 ++++ b/drivers/nvme/host/rdma.c
5528 +@@ -734,7 +734,6 @@ out:
5529 + static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl,
5530 + bool remove)
5531 + {
5532 +- nvme_rdma_stop_queue(&ctrl->queues[0]);
5533 + if (remove) {
5534 + blk_cleanup_queue(ctrl->ctrl.admin_q);
5535 + nvme_rdma_free_tagset(&ctrl->ctrl, ctrl->ctrl.admin_tagset);
5536 +@@ -819,7 +818,6 @@ out_free_queue:
5537 + static void nvme_rdma_destroy_io_queues(struct nvme_rdma_ctrl *ctrl,
5538 + bool remove)
5539 + {
5540 +- nvme_rdma_stop_io_queues(ctrl);
5541 + if (remove) {
5542 + blk_cleanup_queue(ctrl->ctrl.connect_q);
5543 + nvme_rdma_free_tagset(&ctrl->ctrl, ctrl->ctrl.tagset);
5544 +@@ -888,9 +886,9 @@ static void nvme_rdma_free_ctrl(struct nvme_ctrl *nctrl)
5545 + list_del(&ctrl->list);
5546 + mutex_unlock(&nvme_rdma_ctrl_mutex);
5547 +
5548 +- kfree(ctrl->queues);
5549 + nvmf_free_options(nctrl->opts);
5550 + free_ctrl:
5551 ++ kfree(ctrl->queues);
5552 + kfree(ctrl);
5553 + }
5554 +
5555 +@@ -949,6 +947,7 @@ static void nvme_rdma_reconnect_ctrl_work(struct work_struct *work)
5556 + return;
5557 +
5558 + destroy_admin:
5559 ++ nvme_rdma_stop_queue(&ctrl->queues[0]);
5560 + nvme_rdma_destroy_admin_queue(ctrl, false);
5561 + requeue:
5562 + dev_info(ctrl->ctrl.device, "Failed reconnect attempt %d\n",
5563 +@@ -965,12 +964,14 @@ static void nvme_rdma_error_recovery_work(struct work_struct *work)
5564 +
5565 + if (ctrl->ctrl.queue_count > 1) {
5566 + nvme_stop_queues(&ctrl->ctrl);
5567 ++ nvme_rdma_stop_io_queues(ctrl);
5568 + blk_mq_tagset_busy_iter(&ctrl->tag_set,
5569 + nvme_cancel_request, &ctrl->ctrl);
5570 + nvme_rdma_destroy_io_queues(ctrl, false);
5571 + }
5572 +
5573 + blk_mq_quiesce_queue(ctrl->ctrl.admin_q);
5574 ++ nvme_rdma_stop_queue(&ctrl->queues[0]);
5575 + blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
5576 + nvme_cancel_request, &ctrl->ctrl);
5577 + nvme_rdma_destroy_admin_queue(ctrl, false);
5578 +@@ -1720,6 +1721,7 @@ static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown)
5579 + {
5580 + if (ctrl->ctrl.queue_count > 1) {
5581 + nvme_stop_queues(&ctrl->ctrl);
5582 ++ nvme_rdma_stop_io_queues(ctrl);
5583 + blk_mq_tagset_busy_iter(&ctrl->tag_set,
5584 + nvme_cancel_request, &ctrl->ctrl);
5585 + nvme_rdma_destroy_io_queues(ctrl, shutdown);
5586 +@@ -1731,6 +1733,7 @@ static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown)
5587 + nvme_disable_ctrl(&ctrl->ctrl, ctrl->ctrl.cap);
5588 +
5589 + blk_mq_quiesce_queue(ctrl->ctrl.admin_q);
5590 ++ nvme_rdma_stop_queue(&ctrl->queues[0]);
5591 + blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
5592 + nvme_cancel_request, &ctrl->ctrl);
5593 + blk_mq_unquiesce_queue(ctrl->ctrl.admin_q);
5594 +@@ -1916,11 +1919,6 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
5595 + goto out_free_ctrl;
5596 + }
5597 +
5598 +- ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_rdma_ctrl_ops,
5599 +- 0 /* no quirks, we're perfect! */);
5600 +- if (ret)
5601 +- goto out_free_ctrl;
5602 +-
5603 + INIT_DELAYED_WORK(&ctrl->reconnect_work,
5604 + nvme_rdma_reconnect_ctrl_work);
5605 + INIT_WORK(&ctrl->err_work, nvme_rdma_error_recovery_work);
5606 +@@ -1934,14 +1932,19 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
5607 + ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues),
5608 + GFP_KERNEL);
5609 + if (!ctrl->queues)
5610 +- goto out_uninit_ctrl;
5611 ++ goto out_free_ctrl;
5612 ++
5613 ++ ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_rdma_ctrl_ops,
5614 ++ 0 /* no quirks, we're perfect! */);
5615 ++ if (ret)
5616 ++ goto out_kfree_queues;
5617 +
5618 + changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING);
5619 + WARN_ON_ONCE(!changed);
5620 +
5621 + ret = nvme_rdma_configure_admin_queue(ctrl, true);
5622 + if (ret)
5623 +- goto out_kfree_queues;
5624 ++ goto out_uninit_ctrl;
5625 +
5626 + /* sanity check icdoff */
5627 + if (ctrl->ctrl.icdoff) {
5628 +@@ -1996,15 +1999,16 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
5629 + return &ctrl->ctrl;
5630 +
5631 + out_remove_admin_queue:
5632 ++ nvme_rdma_stop_queue(&ctrl->queues[0]);
5633 + nvme_rdma_destroy_admin_queue(ctrl, true);
5634 +-out_kfree_queues:
5635 +- kfree(ctrl->queues);
5636 + out_uninit_ctrl:
5637 + nvme_uninit_ctrl(&ctrl->ctrl);
5638 + nvme_put_ctrl(&ctrl->ctrl);
5639 + if (ret > 0)
5640 + ret = -EIO;
5641 + return ERR_PTR(ret);
5642 ++out_kfree_queues:
5643 ++ kfree(ctrl->queues);
5644 + out_free_ctrl:
5645 + kfree(ctrl);
5646 + return ERR_PTR(ret);
5647 +diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
5648 +index e95424f172fd..0547d5f7d3ba 100644
5649 +--- a/drivers/nvme/target/core.c
5650 ++++ b/drivers/nvme/target/core.c
5651 +@@ -624,6 +624,14 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)
5652 + }
5653 +
5654 + ctrl->csts = NVME_CSTS_RDY;
5655 ++
5656 ++ /*
5657 ++ * Controllers that are not yet enabled should not really enforce the
5658 ++ * keep alive timeout, but we still want to track a timeout and cleanup
5659 ++ * in case a host died before it enabled the controller. Hence, simply
5660 ++ * reset the keep alive timer when the controller is enabled.
5661 ++ */
5662 ++ mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
5663 + }
5664 +
5665 + static void nvmet_clear_ctrl(struct nvmet_ctrl *ctrl)
5666 +diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
5667 +index 1e28597138c8..2d23479b9053 100644
5668 +--- a/drivers/nvmem/core.c
5669 ++++ b/drivers/nvmem/core.c
5670 +@@ -924,6 +924,10 @@ struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *cell_id)
5671 + return cell;
5672 + }
5673 +
5674 ++ /* NULL cell_id only allowed for device tree; invalid otherwise */
5675 ++ if (!cell_id)
5676 ++ return ERR_PTR(-EINVAL);
5677 ++
5678 + return nvmem_cell_get_from_list(cell_id);
5679 + }
5680 + EXPORT_SYMBOL_GPL(nvmem_cell_get);
5681 +diff --git a/drivers/of/base.c b/drivers/of/base.c
5682 +index 848f549164cd..466e3c8582f0 100644
5683 +--- a/drivers/of/base.c
5684 ++++ b/drivers/of/base.c
5685 +@@ -102,7 +102,7 @@ static u32 phandle_cache_mask;
5686 + * - the phandle lookup overhead reduction provided by the cache
5687 + * will likely be less
5688 + */
5689 +-static void of_populate_phandle_cache(void)
5690 ++void of_populate_phandle_cache(void)
5691 + {
5692 + unsigned long flags;
5693 + u32 cache_entries;
5694 +@@ -134,8 +134,7 @@ out:
5695 + raw_spin_unlock_irqrestore(&devtree_lock, flags);
5696 + }
5697 +
5698 +-#ifndef CONFIG_MODULES
5699 +-static int __init of_free_phandle_cache(void)
5700 ++int of_free_phandle_cache(void)
5701 + {
5702 + unsigned long flags;
5703 +
5704 +@@ -148,6 +147,7 @@ static int __init of_free_phandle_cache(void)
5705 +
5706 + return 0;
5707 + }
5708 ++#if !defined(CONFIG_MODULES)
5709 + late_initcall_sync(of_free_phandle_cache);
5710 + #endif
5711 +
5712 +diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
5713 +index 891d780c076a..216175d11d3d 100644
5714 +--- a/drivers/of/of_private.h
5715 ++++ b/drivers/of/of_private.h
5716 +@@ -79,6 +79,8 @@ int of_resolve_phandles(struct device_node *tree);
5717 + #if defined(CONFIG_OF_OVERLAY)
5718 + void of_overlay_mutex_lock(void);
5719 + void of_overlay_mutex_unlock(void);
5720 ++int of_free_phandle_cache(void);
5721 ++void of_populate_phandle_cache(void);
5722 + #else
5723 + static inline void of_overlay_mutex_lock(void) {};
5724 + static inline void of_overlay_mutex_unlock(void) {};
5725 +diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
5726 +index 7baa53e5b1d7..eda57ef12fd0 100644
5727 +--- a/drivers/of/overlay.c
5728 ++++ b/drivers/of/overlay.c
5729 +@@ -804,6 +804,8 @@ static int of_overlay_apply(const void *fdt, struct device_node *tree,
5730 + goto err_free_overlay_changeset;
5731 + }
5732 +
5733 ++ of_populate_phandle_cache();
5734 ++
5735 + ret = __of_changeset_apply_notify(&ovcs->cset);
5736 + if (ret)
5737 + pr_err("overlay changeset entry notify error %d\n", ret);
5738 +@@ -1046,8 +1048,17 @@ int of_overlay_remove(int *ovcs_id)
5739 +
5740 + list_del(&ovcs->ovcs_list);
5741 +
5742 ++ /*
5743 ++ * Disable phandle cache. Avoids race condition that would arise
5744 ++ * from removing cache entry when the associated node is deleted.
5745 ++ */
5746 ++ of_free_phandle_cache();
5747 ++
5748 + ret_apply = 0;
5749 + ret = __of_changeset_revert_entries(&ovcs->cset, &ret_apply);
5750 ++
5751 ++ of_populate_phandle_cache();
5752 ++
5753 + if (ret) {
5754 + if (ret_apply)
5755 + devicetree_state_flags |= DTSF_REVERT_FAIL;
5756 +diff --git a/drivers/pci/dwc/pcie-designware-host.c b/drivers/pci/dwc/pcie-designware-host.c
5757 +index 6c409079d514..35a2df4ddf20 100644
5758 +--- a/drivers/pci/dwc/pcie-designware-host.c
5759 ++++ b/drivers/pci/dwc/pcie-designware-host.c
5760 +@@ -355,7 +355,8 @@ int dw_pcie_host_init(struct pcie_port *pp)
5761 + resource_list_for_each_entry_safe(win, tmp, &bridge->windows) {
5762 + switch (resource_type(win->res)) {
5763 + case IORESOURCE_IO:
5764 +- ret = pci_remap_iospace(win->res, pp->io_base);
5765 ++ ret = devm_pci_remap_iospace(dev, win->res,
5766 ++ pp->io_base);
5767 + if (ret) {
5768 + dev_warn(dev, "error %d: failed to map resource %pR\n",
5769 + ret, win->res);
5770 +diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
5771 +index 9abf549631b4..d0867a311f42 100644
5772 +--- a/drivers/pci/host/pci-aardvark.c
5773 ++++ b/drivers/pci/host/pci-aardvark.c
5774 +@@ -848,7 +848,7 @@ static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie)
5775 + 0, 0xF8000000, 0,
5776 + lower_32_bits(res->start),
5777 + OB_PCIE_IO);
5778 +- err = pci_remap_iospace(res, iobase);
5779 ++ err = devm_pci_remap_iospace(dev, res, iobase);
5780 + if (err) {
5781 + dev_warn(dev, "error %d: failed to map resource %pR\n",
5782 + err, res);
5783 +diff --git a/drivers/pci/host/pci-ftpci100.c b/drivers/pci/host/pci-ftpci100.c
5784 +index 5008fd87956a..0e966219d66d 100644
5785 +--- a/drivers/pci/host/pci-ftpci100.c
5786 ++++ b/drivers/pci/host/pci-ftpci100.c
5787 +@@ -353,11 +353,13 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p)
5788 + irq = of_irq_get(intc, 0);
5789 + if (irq <= 0) {
5790 + dev_err(p->dev, "failed to get parent IRQ\n");
5791 ++ of_node_put(intc);
5792 + return irq ?: -EINVAL;
5793 + }
5794 +
5795 + p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX,
5796 + &faraday_pci_irqdomain_ops, p);
5797 ++ of_node_put(intc);
5798 + if (!p->irqdomain) {
5799 + dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n");
5800 + return -EINVAL;
5801 +@@ -499,7 +501,7 @@ static int faraday_pci_probe(struct platform_device *pdev)
5802 + dev_err(dev, "illegal IO mem size\n");
5803 + return -EINVAL;
5804 + }
5805 +- ret = pci_remap_iospace(io, io_base);
5806 ++ ret = devm_pci_remap_iospace(dev, io, io_base);
5807 + if (ret) {
5808 + dev_warn(dev, "error %d: failed to map resource %pR\n",
5809 + ret, io);
5810 +diff --git a/drivers/pci/host/pci-v3-semi.c b/drivers/pci/host/pci-v3-semi.c
5811 +index 0a4dea796663..3381bf29b59f 100644
5812 +--- a/drivers/pci/host/pci-v3-semi.c
5813 ++++ b/drivers/pci/host/pci-v3-semi.c
5814 +@@ -535,7 +535,7 @@ static int v3_pci_setup_resource(struct v3_pci *v3,
5815 + v3->io_bus_addr = io->start - win->offset;
5816 + dev_dbg(dev, "I/O window %pR, bus addr %pap\n",
5817 + io, &v3->io_bus_addr);
5818 +- ret = pci_remap_iospace(io, io_base);
5819 ++ ret = devm_pci_remap_iospace(dev, io, io_base);
5820 + if (ret) {
5821 + dev_warn(dev,
5822 + "error %d: failed to map resource %pR\n",
5823 +diff --git a/drivers/pci/host/pci-versatile.c b/drivers/pci/host/pci-versatile.c
5824 +index 5b3876f5312b..df9408c4873a 100644
5825 +--- a/drivers/pci/host/pci-versatile.c
5826 ++++ b/drivers/pci/host/pci-versatile.c
5827 +@@ -81,7 +81,7 @@ static int versatile_pci_parse_request_of_pci_ranges(struct device *dev,
5828 +
5829 + switch (resource_type(res)) {
5830 + case IORESOURCE_IO:
5831 +- err = pci_remap_iospace(res, iobase);
5832 ++ err = devm_pci_remap_iospace(dev, res, iobase);
5833 + if (err) {
5834 + dev_warn(dev, "error %d: failed to map resource %pR\n",
5835 + err, res);
5836 +diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
5837 +index 0a0d7ee6d3c9..e256d94cafb3 100644
5838 +--- a/drivers/pci/host/pci-xgene.c
5839 ++++ b/drivers/pci/host/pci-xgene.c
5840 +@@ -421,7 +421,7 @@ static int xgene_pcie_map_ranges(struct xgene_pcie_port *port,
5841 + case IORESOURCE_IO:
5842 + xgene_pcie_setup_ob_reg(port, res, OMR3BARL, io_base,
5843 + res->start - window->offset);
5844 +- ret = pci_remap_iospace(res, io_base);
5845 ++ ret = devm_pci_remap_iospace(dev, res, io_base);
5846 + if (ret < 0)
5847 + return ret;
5848 + break;
5849 +diff --git a/drivers/pci/host/pcie-mediatek.c b/drivers/pci/host/pcie-mediatek.c
5850 +index a8b20c5012a9..35e9fd028da4 100644
5851 +--- a/drivers/pci/host/pcie-mediatek.c
5852 ++++ b/drivers/pci/host/pcie-mediatek.c
5853 +@@ -1063,7 +1063,7 @@ static int mtk_pcie_request_resources(struct mtk_pcie *pcie)
5854 + if (err < 0)
5855 + return err;
5856 +
5857 +- pci_remap_iospace(&pcie->pio, pcie->io.start);
5858 ++ devm_pci_remap_iospace(dev, &pcie->pio, pcie->io.start);
5859 +
5860 + return 0;
5861 + }
5862 +diff --git a/drivers/pci/host/pcie-xilinx-nwl.c b/drivers/pci/host/pcie-xilinx-nwl.c
5863 +index 4839ae578711..62545e510389 100644
5864 +--- a/drivers/pci/host/pcie-xilinx-nwl.c
5865 ++++ b/drivers/pci/host/pcie-xilinx-nwl.c
5866 +@@ -557,7 +557,7 @@ static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie)
5867 + PCI_NUM_INTX,
5868 + &legacy_domain_ops,
5869 + pcie);
5870 +-
5871 ++ of_node_put(legacy_intc_node);
5872 + if (!pcie->legacy_irq_domain) {
5873 + dev_err(dev, "failed to create IRQ domain\n");
5874 + return -ENOMEM;
5875 +diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c
5876 +index 0ad188effc09..fd9c73dd347b 100644
5877 +--- a/drivers/pci/host/pcie-xilinx.c
5878 ++++ b/drivers/pci/host/pcie-xilinx.c
5879 +@@ -507,6 +507,7 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port)
5880 + port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
5881 + &intx_domain_ops,
5882 + port);
5883 ++ of_node_put(pcie_intc_node);
5884 + if (!port->leg_domain) {
5885 + dev_err(dev, "Failed to get a INTx IRQ domain\n");
5886 + return -ENODEV;
5887 +diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
5888 +index af92fed46ab7..fd93783a87b0 100644
5889 +--- a/drivers/pci/hotplug/pci_hotplug_core.c
5890 ++++ b/drivers/pci/hotplug/pci_hotplug_core.c
5891 +@@ -438,8 +438,17 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
5892 + list_add(&slot->slot_list, &pci_hotplug_slot_list);
5893 +
5894 + result = fs_add_slot(pci_slot);
5895 ++ if (result)
5896 ++ goto err_list_del;
5897 ++
5898 + kobject_uevent(&pci_slot->kobj, KOBJ_ADD);
5899 + dbg("Added slot %s to the list\n", name);
5900 ++ goto out;
5901 ++
5902 ++err_list_del:
5903 ++ list_del(&slot->slot_list);
5904 ++ pci_slot->hotplug = NULL;
5905 ++ pci_destroy_slot(pci_slot);
5906 + out:
5907 + mutex_unlock(&pci_hp_mutex);
5908 + return result;
5909 +diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
5910 +index 5f892065585e..fca87a1a2b22 100644
5911 +--- a/drivers/pci/hotplug/pciehp.h
5912 ++++ b/drivers/pci/hotplug/pciehp.h
5913 +@@ -119,6 +119,7 @@ int pciehp_unconfigure_device(struct slot *p_slot);
5914 + void pciehp_queue_pushbutton_work(struct work_struct *work);
5915 + struct controller *pcie_init(struct pcie_device *dev);
5916 + int pcie_init_notification(struct controller *ctrl);
5917 ++void pcie_shutdown_notification(struct controller *ctrl);
5918 + int pciehp_enable_slot(struct slot *p_slot);
5919 + int pciehp_disable_slot(struct slot *p_slot);
5920 + void pcie_reenable_notification(struct controller *ctrl);
5921 +diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
5922 +index 44a6a63802d5..2ba59fc94827 100644
5923 +--- a/drivers/pci/hotplug/pciehp_core.c
5924 ++++ b/drivers/pci/hotplug/pciehp_core.c
5925 +@@ -62,6 +62,12 @@ static int reset_slot(struct hotplug_slot *slot, int probe);
5926 + */
5927 + static void release_slot(struct hotplug_slot *hotplug_slot)
5928 + {
5929 ++ struct slot *slot = hotplug_slot->private;
5930 ++
5931 ++ /* queued work needs hotplug_slot name */
5932 ++ cancel_delayed_work(&slot->work);
5933 ++ drain_workqueue(slot->wq);
5934 ++
5935 + kfree(hotplug_slot->ops);
5936 + kfree(hotplug_slot->info);
5937 + kfree(hotplug_slot);
5938 +@@ -264,6 +270,7 @@ static void pciehp_remove(struct pcie_device *dev)
5939 + {
5940 + struct controller *ctrl = get_service_data(dev);
5941 +
5942 ++ pcie_shutdown_notification(ctrl);
5943 + cleanup_slot(ctrl);
5944 + pciehp_release_ctrl(ctrl);
5945 + }
5946 +diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
5947 +index 98ea75aa32c7..6635ae13962f 100644
5948 +--- a/drivers/pci/hotplug/pciehp_hpc.c
5949 ++++ b/drivers/pci/hotplug/pciehp_hpc.c
5950 +@@ -545,8 +545,6 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id)
5951 + {
5952 + struct controller *ctrl = (struct controller *)dev_id;
5953 + struct pci_dev *pdev = ctrl_dev(ctrl);
5954 +- struct pci_bus *subordinate = pdev->subordinate;
5955 +- struct pci_dev *dev;
5956 + struct slot *slot = ctrl->slot;
5957 + u16 status, events;
5958 + u8 present;
5959 +@@ -594,14 +592,9 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id)
5960 + wake_up(&ctrl->queue);
5961 + }
5962 +
5963 +- if (subordinate) {
5964 +- list_for_each_entry(dev, &subordinate->devices, bus_list) {
5965 +- if (dev->ignore_hotplug) {
5966 +- ctrl_dbg(ctrl, "ignoring hotplug event %#06x (%s requested no hotplug)\n",
5967 +- events, pci_name(dev));
5968 +- return IRQ_HANDLED;
5969 +- }
5970 +- }
5971 ++ if (pdev->ignore_hotplug) {
5972 ++ ctrl_dbg(ctrl, "ignoring hotplug event %#06x\n", events);
5973 ++ return IRQ_HANDLED;
5974 + }
5975 +
5976 + /* Check Attention Button Pressed */
5977 +@@ -771,7 +764,7 @@ int pcie_init_notification(struct controller *ctrl)
5978 + return 0;
5979 + }
5980 +
5981 +-static void pcie_shutdown_notification(struct controller *ctrl)
5982 ++void pcie_shutdown_notification(struct controller *ctrl)
5983 + {
5984 + if (ctrl->notification_enabled) {
5985 + pcie_disable_notification(ctrl);
5986 +@@ -806,7 +799,7 @@ abort:
5987 + static void pcie_cleanup_slot(struct controller *ctrl)
5988 + {
5989 + struct slot *slot = ctrl->slot;
5990 +- cancel_delayed_work(&slot->work);
5991 ++
5992 + destroy_workqueue(slot->wq);
5993 + kfree(slot);
5994 + }
5995 +@@ -898,7 +891,6 @@ abort:
5996 +
5997 + void pciehp_release_ctrl(struct controller *ctrl)
5998 + {
5999 +- pcie_shutdown_notification(ctrl);
6000 + pcie_cleanup_slot(ctrl);
6001 + kfree(ctrl);
6002 + }
6003 +diff --git a/drivers/pci/of.c b/drivers/pci/of.c
6004 +index a28355c273ae..f8bcfe209464 100644
6005 +--- a/drivers/pci/of.c
6006 ++++ b/drivers/pci/of.c
6007 +@@ -617,7 +617,7 @@ int pci_parse_request_of_pci_ranges(struct device *dev,
6008 +
6009 + switch (resource_type(res)) {
6010 + case IORESOURCE_IO:
6011 +- err = pci_remap_iospace(res, iobase);
6012 ++ err = devm_pci_remap_iospace(dev, res, iobase);
6013 + if (err) {
6014 + dev_warn(dev, "error %d: failed to map resource %pR\n",
6015 + err, res);
6016 +diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
6017 +index 054974055ea4..41d24b273d6f 100644
6018 +--- a/drivers/pci/pci-acpi.c
6019 ++++ b/drivers/pci/pci-acpi.c
6020 +@@ -601,13 +601,11 @@ static bool acpi_pci_need_resume(struct pci_dev *dev)
6021 + /*
6022 + * In some cases (eg. Samsung 305V4A) leaving a bridge in suspend over
6023 + * system-wide suspend/resume confuses the platform firmware, so avoid
6024 +- * doing that, unless the bridge has a driver that should take care of
6025 +- * the PM handling. According to Section 16.1.6 of ACPI 6.2, endpoint
6026 ++ * doing that. According to Section 16.1.6 of ACPI 6.2, endpoint
6027 + * devices are expected to be in D3 before invoking the S3 entry path
6028 + * from the firmware, so they should not be affected by this issue.
6029 + */
6030 +- if (pci_is_bridge(dev) && !dev->driver &&
6031 +- acpi_target_system_state() != ACPI_STATE_S0)
6032 ++ if (pci_is_bridge(dev) && acpi_target_system_state() != ACPI_STATE_S0)
6033 + return true;
6034 +
6035 + if (!adev || !acpi_device_power_manageable(adev))
6036 +diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
6037 +index dbfe7c4f3776..04ce05f9c2cb 100644
6038 +--- a/drivers/pci/pci.c
6039 ++++ b/drivers/pci/pci.c
6040 +@@ -1163,6 +1163,33 @@ static void pci_restore_config_space(struct pci_dev *pdev)
6041 + }
6042 + }
6043 +
6044 ++static void pci_restore_rebar_state(struct pci_dev *pdev)
6045 ++{
6046 ++ unsigned int pos, nbars, i;
6047 ++ u32 ctrl;
6048 ++
6049 ++ pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_REBAR);
6050 ++ if (!pos)
6051 ++ return;
6052 ++
6053 ++ pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
6054 ++ nbars = (ctrl & PCI_REBAR_CTRL_NBAR_MASK) >>
6055 ++ PCI_REBAR_CTRL_NBAR_SHIFT;
6056 ++
6057 ++ for (i = 0; i < nbars; i++, pos += 8) {
6058 ++ struct resource *res;
6059 ++ int bar_idx, size;
6060 ++
6061 ++ pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
6062 ++ bar_idx = ctrl & PCI_REBAR_CTRL_BAR_IDX;
6063 ++ res = pdev->resource + bar_idx;
6064 ++ size = order_base_2((resource_size(res) >> 20) | 1) - 1;
6065 ++ ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE;
6066 ++ ctrl |= size << 8;
6067 ++ pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl);
6068 ++ }
6069 ++}
6070 ++
6071 + /**
6072 + * pci_restore_state - Restore the saved state of a PCI device
6073 + * @dev: - PCI device that we're dealing with
6074 +@@ -1178,6 +1205,7 @@ void pci_restore_state(struct pci_dev *dev)
6075 + pci_restore_pri_state(dev);
6076 + pci_restore_ats_state(dev);
6077 + pci_restore_vc_state(dev);
6078 ++ pci_restore_rebar_state(dev);
6079 +
6080 + pci_cleanup_aer_error_status_regs(dev);
6081 +
6082 +@@ -3573,6 +3601,44 @@ void pci_unmap_iospace(struct resource *res)
6083 + }
6084 + EXPORT_SYMBOL(pci_unmap_iospace);
6085 +
6086 ++static void devm_pci_unmap_iospace(struct device *dev, void *ptr)
6087 ++{
6088 ++ struct resource **res = ptr;
6089 ++
6090 ++ pci_unmap_iospace(*res);
6091 ++}
6092 ++
6093 ++/**
6094 ++ * devm_pci_remap_iospace - Managed pci_remap_iospace()
6095 ++ * @dev: Generic device to remap IO address for
6096 ++ * @res: Resource describing the I/O space
6097 ++ * @phys_addr: physical address of range to be mapped
6098 ++ *
6099 ++ * Managed pci_remap_iospace(). Map is automatically unmapped on driver
6100 ++ * detach.
6101 ++ */
6102 ++int devm_pci_remap_iospace(struct device *dev, const struct resource *res,
6103 ++ phys_addr_t phys_addr)
6104 ++{
6105 ++ const struct resource **ptr;
6106 ++ int error;
6107 ++
6108 ++ ptr = devres_alloc(devm_pci_unmap_iospace, sizeof(*ptr), GFP_KERNEL);
6109 ++ if (!ptr)
6110 ++ return -ENOMEM;
6111 ++
6112 ++ error = pci_remap_iospace(res, phys_addr);
6113 ++ if (error) {
6114 ++ devres_free(ptr);
6115 ++ } else {
6116 ++ *ptr = res;
6117 ++ devres_add(dev, ptr);
6118 ++ }
6119 ++
6120 ++ return error;
6121 ++}
6122 ++EXPORT_SYMBOL(devm_pci_remap_iospace);
6123 ++
6124 + /**
6125 + * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace()
6126 + * @dev: Generic device to remap IO address for
6127 +diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
6128 +index d21686ad3ce5..979fd599fc66 100644
6129 +--- a/drivers/pci/probe.c
6130 ++++ b/drivers/pci/probe.c
6131 +@@ -1677,6 +1677,10 @@ static void pci_configure_mps(struct pci_dev *dev)
6132 + if (!pci_is_pcie(dev) || !bridge || !pci_is_pcie(bridge))
6133 + return;
6134 +
6135 ++ /* MPS and MRRS fields are of type 'RsvdP' for VFs, short-circuit out */
6136 ++ if (dev->is_virtfn)
6137 ++ return;
6138 ++
6139 + mps = pcie_get_mps(dev);
6140 + p_mps = pcie_get_mps(bridge);
6141 +
6142 +diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c
6143 +index 6bdb1dad805f..0e31f1392a53 100644
6144 +--- a/drivers/perf/xgene_pmu.c
6145 ++++ b/drivers/perf/xgene_pmu.c
6146 +@@ -1463,7 +1463,7 @@ static char *xgene_pmu_dev_name(struct device *dev, u32 type, int id)
6147 + case PMU_TYPE_IOB:
6148 + return devm_kasprintf(dev, GFP_KERNEL, "iob%d", id);
6149 + case PMU_TYPE_IOB_SLOW:
6150 +- return devm_kasprintf(dev, GFP_KERNEL, "iob-slow%d", id);
6151 ++ return devm_kasprintf(dev, GFP_KERNEL, "iob_slow%d", id);
6152 + case PMU_TYPE_MCB:
6153 + return devm_kasprintf(dev, GFP_KERNEL, "mcb%d", id);
6154 + case PMU_TYPE_MC:
6155 +diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
6156 +index 35c17653c694..87618a4e90e4 100644
6157 +--- a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
6158 ++++ b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
6159 +@@ -460,8 +460,8 @@ static int nsp_pinmux_enable(struct pinctrl_dev *pctrl_dev,
6160 + const struct nsp_pin_function *func;
6161 + const struct nsp_pin_group *grp;
6162 +
6163 +- if (grp_select > pinctrl->num_groups ||
6164 +- func_select > pinctrl->num_functions)
6165 ++ if (grp_select >= pinctrl->num_groups ||
6166 ++ func_select >= pinctrl->num_functions)
6167 + return -EINVAL;
6168 +
6169 + func = &pinctrl->functions[func_select];
6170 +@@ -577,6 +577,8 @@ static int nsp_pinmux_probe(struct platform_device *pdev)
6171 + return PTR_ERR(pinctrl->base0);
6172 +
6173 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
6174 ++ if (!res)
6175 ++ return -EINVAL;
6176 + pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start,
6177 + resource_size(res));
6178 + if (!pinctrl->base1) {
6179 +diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
6180 +index ac38a3f9f86b..4699b55a0990 100644
6181 +--- a/drivers/pinctrl/pinctrl-ingenic.c
6182 ++++ b/drivers/pinctrl/pinctrl-ingenic.c
6183 +@@ -536,7 +536,7 @@ static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
6184 + ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, input);
6185 + } else {
6186 + ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false);
6187 +- ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, input);
6188 ++ ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input);
6189 + ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false);
6190 + }
6191 +
6192 +diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
6193 +index c52c6723374b..d3f4b6e91f49 100644
6194 +--- a/drivers/platform/x86/dell-laptop.c
6195 ++++ b/drivers/platform/x86/dell-laptop.c
6196 +@@ -2170,7 +2170,7 @@ static int __init dell_init(void)
6197 + dell_fill_request(&buffer, token->location, 0, 0, 0);
6198 + ret = dell_send_request(&buffer,
6199 + CLASS_TOKEN_READ, SELECT_TOKEN_AC);
6200 +- if (ret)
6201 ++ if (ret == 0)
6202 + max_intensity = buffer.output[3];
6203 + }
6204 +
6205 +diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
6206 +index 6d4012dd6922..bac1eeb3d312 100644
6207 +--- a/drivers/rtc/interface.c
6208 ++++ b/drivers/rtc/interface.c
6209 +@@ -265,8 +265,10 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
6210 + return err;
6211 +
6212 + /* full-function RTCs won't have such missing fields */
6213 +- if (rtc_valid_tm(&alarm->time) == 0)
6214 ++ if (rtc_valid_tm(&alarm->time) == 0) {
6215 ++ rtc_add_offset(rtc, &alarm->time);
6216 + return 0;
6217 ++ }
6218 +
6219 + /* get the "after" timestamp, to detect wrapped fields */
6220 + err = rtc_read_time(rtc, &now);
6221 +@@ -409,7 +411,6 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
6222 + if (err)
6223 + return err;
6224 +
6225 +- rtc_subtract_offset(rtc, &alarm->time);
6226 + scheduled = rtc_tm_to_time64(&alarm->time);
6227 +
6228 + /* Make sure we're not setting alarms in the past */
6229 +@@ -426,6 +427,8 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
6230 + * over right here, before we set the alarm.
6231 + */
6232 +
6233 ++ rtc_subtract_offset(rtc, &alarm->time);
6234 ++
6235 + if (!rtc->ops)
6236 + err = -ENODEV;
6237 + else if (!rtc->ops->set_alarm)
6238 +@@ -467,7 +470,6 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
6239 +
6240 + mutex_unlock(&rtc->ops_lock);
6241 +
6242 +- rtc_add_offset(rtc, &alarm->time);
6243 + return err;
6244 + }
6245 + EXPORT_SYMBOL_GPL(rtc_set_alarm);
6246 +diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
6247 +index ea6a2d0b2894..770fa9cfc310 100644
6248 +--- a/drivers/s390/cio/vfio_ccw_drv.c
6249 ++++ b/drivers/s390/cio/vfio_ccw_drv.c
6250 +@@ -177,6 +177,7 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
6251 + {
6252 + struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev);
6253 + unsigned long flags;
6254 ++ int rc = -EAGAIN;
6255 +
6256 + spin_lock_irqsave(sch->lock, flags);
6257 + if (!device_is_registered(&sch->dev))
6258 +@@ -187,6 +188,7 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
6259 +
6260 + if (cio_update_schib(sch)) {
6261 + vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_NOT_OPER);
6262 ++ rc = 0;
6263 + goto out_unlock;
6264 + }
6265 +
6266 +@@ -195,11 +197,12 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
6267 + private->state = private->mdev ? VFIO_CCW_STATE_IDLE :
6268 + VFIO_CCW_STATE_STANDBY;
6269 + }
6270 ++ rc = 0;
6271 +
6272 + out_unlock:
6273 + spin_unlock_irqrestore(sch->lock, flags);
6274 +
6275 +- return 0;
6276 ++ return rc;
6277 + }
6278 +
6279 + static struct css_device_id vfio_ccw_sch_ids[] = {
6280 +diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h
6281 +index b7f75339683e..a05c53a44973 100644
6282 +--- a/drivers/s390/net/qeth_core.h
6283 ++++ b/drivers/s390/net/qeth_core.h
6284 +@@ -1003,7 +1003,7 @@ struct qeth_cmd_buffer *qeth_get_setassparms_cmd(struct qeth_card *,
6285 + __u16, __u16,
6286 + enum qeth_prot_versions);
6287 + int qeth_set_features(struct net_device *, netdev_features_t);
6288 +-void qeth_recover_features(struct net_device *dev);
6289 ++void qeth_enable_hw_features(struct net_device *dev);
6290 + netdev_features_t qeth_fix_features(struct net_device *, netdev_features_t);
6291 + netdev_features_t qeth_features_check(struct sk_buff *skb,
6292 + struct net_device *dev,
6293 +diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
6294 +index b2eebcffd502..32075de2f1e5 100644
6295 +--- a/drivers/s390/net/qeth_core_main.c
6296 ++++ b/drivers/s390/net/qeth_core_main.c
6297 +@@ -6432,28 +6432,27 @@ static int qeth_set_ipa_tso(struct qeth_card *card, int on)
6298 + #define QETH_HW_FEATURES (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_TSO)
6299 +
6300 + /**
6301 +- * qeth_recover_features() - Restore device features after recovery
6302 +- * @dev: the recovering net_device
6303 +- *
6304 +- * Caller must hold rtnl lock.
6305 ++ * qeth_enable_hw_features() - (Re-)Enable HW functions for device features
6306 ++ * @dev: a net_device
6307 + */
6308 +-void qeth_recover_features(struct net_device *dev)
6309 ++void qeth_enable_hw_features(struct net_device *dev)
6310 + {
6311 +- netdev_features_t features = dev->features;
6312 + struct qeth_card *card = dev->ml_priv;
6313 ++ netdev_features_t features;
6314 +
6315 ++ rtnl_lock();
6316 ++ features = dev->features;
6317 + /* force-off any feature that needs an IPA sequence.
6318 + * netdev_update_features() will restart them.
6319 + */
6320 + dev->features &= ~QETH_HW_FEATURES;
6321 + netdev_update_features(dev);
6322 +-
6323 +- if (features == dev->features)
6324 +- return;
6325 +- dev_warn(&card->gdev->dev,
6326 +- "Device recovery failed to restore all offload features\n");
6327 ++ if (features != dev->features)
6328 ++ dev_warn(&card->gdev->dev,
6329 ++ "Device recovery failed to restore all offload features\n");
6330 ++ rtnl_unlock();
6331 + }
6332 +-EXPORT_SYMBOL_GPL(qeth_recover_features);
6333 ++EXPORT_SYMBOL_GPL(qeth_enable_hw_features);
6334 +
6335 + int qeth_set_features(struct net_device *dev, netdev_features_t features)
6336 + {
6337 +diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
6338 +index 16dc8b83ca6f..525c82ba923c 100644
6339 +--- a/drivers/s390/net/qeth_l2_main.c
6340 ++++ b/drivers/s390/net/qeth_l2_main.c
6341 +@@ -1130,6 +1130,8 @@ static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode)
6342 + netif_carrier_off(card->dev);
6343 +
6344 + qeth_set_allowed_threads(card, 0xffffffff, 0);
6345 ++
6346 ++ qeth_enable_hw_features(card->dev);
6347 + if (recover_flag == CARD_STATE_RECOVER) {
6348 + if (recovery_mode &&
6349 + card->info.type != QETH_CARD_TYPE_OSN) {
6350 +@@ -1141,9 +1143,6 @@ static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode)
6351 + }
6352 + /* this also sets saved unicast addresses */
6353 + qeth_l2_set_rx_mode(card->dev);
6354 +- rtnl_lock();
6355 +- qeth_recover_features(card->dev);
6356 +- rtnl_unlock();
6357 + }
6358 + /* let user_space know that device is online */
6359 + kobject_uevent(&gdev->dev.kobj, KOBJ_CHANGE);
6360 +diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
6361 +index c1a16a74aa83..8de498befde2 100644
6362 +--- a/drivers/s390/net/qeth_l3_main.c
6363 ++++ b/drivers/s390/net/qeth_l3_main.c
6364 +@@ -2792,6 +2792,8 @@ static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode)
6365 + netif_carrier_on(card->dev);
6366 + else
6367 + netif_carrier_off(card->dev);
6368 ++
6369 ++ qeth_enable_hw_features(card->dev);
6370 + if (recover_flag == CARD_STATE_RECOVER) {
6371 + rtnl_lock();
6372 + if (recovery_mode)
6373 +@@ -2799,7 +2801,6 @@ static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode)
6374 + else
6375 + dev_open(card->dev);
6376 + qeth_l3_set_rx_mode(card->dev);
6377 +- qeth_recover_features(card->dev);
6378 + rtnl_unlock();
6379 + }
6380 + qeth_trace_features(card);
6381 +diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
6382 +index b92f86acb8bb..d37e8dd538f2 100644
6383 +--- a/drivers/scsi/hpsa.c
6384 ++++ b/drivers/scsi/hpsa.c
6385 +@@ -3438,11 +3438,11 @@ static void hpsa_get_enclosure_info(struct ctlr_info *h,
6386 + struct ext_report_lun_entry *rle = &rlep->LUN[rle_index];
6387 + u16 bmic_device_index = 0;
6388 +
6389 +- bmic_device_index = GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]);
6390 +-
6391 +- encl_dev->sas_address =
6392 ++ encl_dev->eli =
6393 + hpsa_get_enclosure_logical_identifier(h, scsi3addr);
6394 +
6395 ++ bmic_device_index = GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]);
6396 ++
6397 + if (encl_dev->target == -1 || encl_dev->lun == -1) {
6398 + rc = IO_OK;
6399 + goto out;
6400 +@@ -9695,7 +9695,24 @@ hpsa_sas_get_linkerrors(struct sas_phy *phy)
6401 + static int
6402 + hpsa_sas_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier)
6403 + {
6404 +- *identifier = rphy->identify.sas_address;
6405 ++ struct Scsi_Host *shost = phy_to_shost(rphy);
6406 ++ struct ctlr_info *h;
6407 ++ struct hpsa_scsi_dev_t *sd;
6408 ++
6409 ++ if (!shost)
6410 ++ return -ENXIO;
6411 ++
6412 ++ h = shost_to_hba(shost);
6413 ++
6414 ++ if (!h)
6415 ++ return -ENXIO;
6416 ++
6417 ++ sd = hpsa_find_device_by_sas_rphy(h, rphy);
6418 ++ if (!sd)
6419 ++ return -ENXIO;
6420 ++
6421 ++ *identifier = sd->eli;
6422 ++
6423 + return 0;
6424 + }
6425 +
6426 +diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
6427 +index fb9f5e7f8209..59e023696fff 100644
6428 +--- a/drivers/scsi/hpsa.h
6429 ++++ b/drivers/scsi/hpsa.h
6430 +@@ -68,6 +68,7 @@ struct hpsa_scsi_dev_t {
6431 + #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
6432 + unsigned char device_id[16]; /* from inquiry pg. 0x83 */
6433 + u64 sas_address;
6434 ++ u64 eli; /* from report diags. */
6435 + unsigned char vendor[8]; /* bytes 8-15 of inquiry data */
6436 + unsigned char model[16]; /* bytes 16-31 of inquiry data */
6437 + unsigned char rev; /* byte 2 of inquiry data */
6438 +diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
6439 +index 5015b8fbbfc5..b62239b548c4 100644
6440 +--- a/drivers/scsi/qedf/qedf_main.c
6441 ++++ b/drivers/scsi/qedf/qedf_main.c
6442 +@@ -3241,6 +3241,11 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
6443 +
6444 + init_completion(&qedf->flogi_compl);
6445 +
6446 ++ status = qed_ops->common->update_drv_state(qedf->cdev, true);
6447 ++ if (status)
6448 ++ QEDF_ERR(&(qedf->dbg_ctx),
6449 ++ "Failed to send drv state to MFW.\n");
6450 ++
6451 + memset(&link_params, 0, sizeof(struct qed_link_params));
6452 + link_params.link_up = true;
6453 + status = qed_ops->common->set_link(qedf->cdev, &link_params);
6454 +@@ -3289,6 +3294,7 @@ static int qedf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
6455 + static void __qedf_remove(struct pci_dev *pdev, int mode)
6456 + {
6457 + struct qedf_ctx *qedf;
6458 ++ int rc;
6459 +
6460 + if (!pdev) {
6461 + QEDF_ERR(NULL, "pdev is NULL.\n");
6462 +@@ -3383,6 +3389,12 @@ static void __qedf_remove(struct pci_dev *pdev, int mode)
6463 + qed_ops->common->set_power_state(qedf->cdev, PCI_D0);
6464 + pci_set_drvdata(pdev, NULL);
6465 + }
6466 ++
6467 ++ rc = qed_ops->common->update_drv_state(qedf->cdev, false);
6468 ++ if (rc)
6469 ++ QEDF_ERR(&(qedf->dbg_ctx),
6470 ++ "Failed to send drv state to MFW.\n");
6471 ++
6472 + qed_ops->common->slowpath_stop(qedf->cdev);
6473 + qed_ops->common->remove(qedf->cdev);
6474 +
6475 +diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
6476 +index 4da3592aec0f..1e674eb6dd17 100644
6477 +--- a/drivers/scsi/qedi/qedi_main.c
6478 ++++ b/drivers/scsi/qedi/qedi_main.c
6479 +@@ -2075,6 +2075,7 @@ kset_free:
6480 + static void __qedi_remove(struct pci_dev *pdev, int mode)
6481 + {
6482 + struct qedi_ctx *qedi = pci_get_drvdata(pdev);
6483 ++ int rval;
6484 +
6485 + if (qedi->tmf_thread) {
6486 + flush_workqueue(qedi->tmf_thread);
6487 +@@ -2104,6 +2105,10 @@ static void __qedi_remove(struct pci_dev *pdev, int mode)
6488 + if (mode == QEDI_MODE_NORMAL)
6489 + qedi_free_iscsi_pf_param(qedi);
6490 +
6491 ++ rval = qedi_ops->common->update_drv_state(qedi->cdev, false);
6492 ++ if (rval)
6493 ++ QEDI_ERR(&qedi->dbg_ctx, "Failed to send drv state to MFW\n");
6494 ++
6495 + if (!test_bit(QEDI_IN_OFFLINE, &qedi->flags)) {
6496 + qedi_ops->common->slowpath_stop(qedi->cdev);
6497 + qedi_ops->common->remove(qedi->cdev);
6498 +@@ -2378,6 +2383,12 @@ static int __qedi_probe(struct pci_dev *pdev, int mode)
6499 + if (qedi_setup_boot_info(qedi))
6500 + QEDI_ERR(&qedi->dbg_ctx,
6501 + "No iSCSI boot target configured\n");
6502 ++
6503 ++ rc = qedi_ops->common->update_drv_state(qedi->cdev, true);
6504 ++ if (rc)
6505 ++ QEDI_ERR(&qedi->dbg_ctx,
6506 ++ "Failed to send drv state to MFW\n");
6507 ++
6508 + }
6509 +
6510 + return 0;
6511 +diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
6512 +index 36f59a1be7e9..61389bdc7926 100644
6513 +--- a/drivers/scsi/xen-scsifront.c
6514 ++++ b/drivers/scsi/xen-scsifront.c
6515 +@@ -654,10 +654,17 @@ static int scsifront_dev_reset_handler(struct scsi_cmnd *sc)
6516 + static int scsifront_sdev_configure(struct scsi_device *sdev)
6517 + {
6518 + struct vscsifrnt_info *info = shost_priv(sdev->host);
6519 ++ int err;
6520 +
6521 +- if (info && current == info->curr)
6522 +- xenbus_printf(XBT_NIL, info->dev->nodename,
6523 ++ if (info && current == info->curr) {
6524 ++ err = xenbus_printf(XBT_NIL, info->dev->nodename,
6525 + info->dev_state_path, "%d", XenbusStateConnected);
6526 ++ if (err) {
6527 ++ xenbus_dev_error(info->dev, err,
6528 ++ "%s: writing dev_state_path", __func__);
6529 ++ return err;
6530 ++ }
6531 ++ }
6532 +
6533 + return 0;
6534 + }
6535 +@@ -665,10 +672,15 @@ static int scsifront_sdev_configure(struct scsi_device *sdev)
6536 + static void scsifront_sdev_destroy(struct scsi_device *sdev)
6537 + {
6538 + struct vscsifrnt_info *info = shost_priv(sdev->host);
6539 ++ int err;
6540 +
6541 +- if (info && current == info->curr)
6542 +- xenbus_printf(XBT_NIL, info->dev->nodename,
6543 ++ if (info && current == info->curr) {
6544 ++ err = xenbus_printf(XBT_NIL, info->dev->nodename,
6545 + info->dev_state_path, "%d", XenbusStateClosed);
6546 ++ if (err)
6547 ++ xenbus_dev_error(info->dev, err,
6548 ++ "%s: writing dev_state_path", __func__);
6549 ++ }
6550 + }
6551 +
6552 + static struct scsi_host_template scsifront_sht = {
6553 +@@ -1003,9 +1015,12 @@ static void scsifront_do_lun_hotplug(struct vscsifrnt_info *info, int op)
6554 +
6555 + if (scsi_add_device(info->host, chn, tgt, lun)) {
6556 + dev_err(&dev->dev, "scsi_add_device\n");
6557 +- xenbus_printf(XBT_NIL, dev->nodename,
6558 ++ err = xenbus_printf(XBT_NIL, dev->nodename,
6559 + info->dev_state_path,
6560 + "%d", XenbusStateClosed);
6561 ++ if (err)
6562 ++ xenbus_dev_error(dev, err,
6563 ++ "%s: writing dev_state_path", __func__);
6564 + }
6565 + break;
6566 + case VSCSIFRONT_OP_DEL_LUN:
6567 +@@ -1019,10 +1034,14 @@ static void scsifront_do_lun_hotplug(struct vscsifrnt_info *info, int op)
6568 + }
6569 + break;
6570 + case VSCSIFRONT_OP_READD_LUN:
6571 +- if (device_state == XenbusStateConnected)
6572 +- xenbus_printf(XBT_NIL, dev->nodename,
6573 ++ if (device_state == XenbusStateConnected) {
6574 ++ err = xenbus_printf(XBT_NIL, dev->nodename,
6575 + info->dev_state_path,
6576 + "%d", XenbusStateConnected);
6577 ++ if (err)
6578 ++ xenbus_dev_error(dev, err,
6579 ++ "%s: writing dev_state_path", __func__);
6580 ++ }
6581 + break;
6582 + default:
6583 + break;
6584 +diff --git a/drivers/soc/imx/gpc.c b/drivers/soc/imx/gpc.c
6585 +index c4d35f32af8d..f86f0ebab06a 100644
6586 +--- a/drivers/soc/imx/gpc.c
6587 ++++ b/drivers/soc/imx/gpc.c
6588 +@@ -27,9 +27,16 @@
6589 + #define GPC_PGC_SW2ISO_SHIFT 0x8
6590 + #define GPC_PGC_SW_SHIFT 0x0
6591 +
6592 ++#define GPC_PGC_PCI_PDN 0x200
6593 ++#define GPC_PGC_PCI_SR 0x20c
6594 ++
6595 + #define GPC_PGC_GPU_PDN 0x260
6596 + #define GPC_PGC_GPU_PUPSCR 0x264
6597 + #define GPC_PGC_GPU_PDNSCR 0x268
6598 ++#define GPC_PGC_GPU_SR 0x26c
6599 ++
6600 ++#define GPC_PGC_DISP_PDN 0x240
6601 ++#define GPC_PGC_DISP_SR 0x24c
6602 +
6603 + #define GPU_VPU_PUP_REQ BIT(1)
6604 + #define GPU_VPU_PDN_REQ BIT(0)
6605 +@@ -318,10 +325,24 @@ static const struct of_device_id imx_gpc_dt_ids[] = {
6606 + { }
6607 + };
6608 +
6609 ++static const struct regmap_range yes_ranges[] = {
6610 ++ regmap_reg_range(GPC_CNTR, GPC_CNTR),
6611 ++ regmap_reg_range(GPC_PGC_PCI_PDN, GPC_PGC_PCI_SR),
6612 ++ regmap_reg_range(GPC_PGC_GPU_PDN, GPC_PGC_GPU_SR),
6613 ++ regmap_reg_range(GPC_PGC_DISP_PDN, GPC_PGC_DISP_SR),
6614 ++};
6615 ++
6616 ++static const struct regmap_access_table access_table = {
6617 ++ .yes_ranges = yes_ranges,
6618 ++ .n_yes_ranges = ARRAY_SIZE(yes_ranges),
6619 ++};
6620 ++
6621 + static const struct regmap_config imx_gpc_regmap_config = {
6622 + .reg_bits = 32,
6623 + .val_bits = 32,
6624 + .reg_stride = 4,
6625 ++ .rd_table = &access_table,
6626 ++ .wr_table = &access_table,
6627 + .max_register = 0x2ac,
6628 + };
6629 +
6630 +diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
6631 +index f4e3bd40c72e..6ef18cf8f243 100644
6632 +--- a/drivers/soc/imx/gpcv2.c
6633 ++++ b/drivers/soc/imx/gpcv2.c
6634 +@@ -39,10 +39,15 @@
6635 +
6636 + #define GPC_M4_PU_PDN_FLG 0x1bc
6637 +
6638 +-
6639 +-#define PGC_MIPI 4
6640 +-#define PGC_PCIE 5
6641 +-#define PGC_USB_HSIC 8
6642 ++/*
6643 ++ * The PGC offset values in Reference Manual
6644 ++ * (Rev. 1, 01/2018 and the older ones) GPC chapter's
6645 ++ * GPC_PGC memory map are incorrect, below offset
6646 ++ * values are from design RTL.
6647 ++ */
6648 ++#define PGC_MIPI 16
6649 ++#define PGC_PCIE 17
6650 ++#define PGC_USB_HSIC 20
6651 + #define GPC_PGC_CTRL(n) (0x800 + (n) * 0x40)
6652 + #define GPC_PGC_SR(n) (GPC_PGC_CTRL(n) + 0xc)
6653 +
6654 +diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
6655 +index b0e2c4847a5d..678406e0948b 100644
6656 +--- a/drivers/tty/pty.c
6657 ++++ b/drivers/tty/pty.c
6658 +@@ -625,7 +625,7 @@ int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags)
6659 + if (tty->driver != ptm_driver)
6660 + return -EIO;
6661 +
6662 +- fd = get_unused_fd_flags(0);
6663 ++ fd = get_unused_fd_flags(flags);
6664 + if (fd < 0) {
6665 + retval = fd;
6666 + goto err;
6667 +diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
6668 +index af45aa3222b5..4638d9b066be 100644
6669 +--- a/drivers/usb/chipidea/host.c
6670 ++++ b/drivers/usb/chipidea/host.c
6671 +@@ -124,8 +124,11 @@ static int host_start(struct ci_hdrc *ci)
6672 +
6673 + hcd->power_budget = ci->platdata->power_budget;
6674 + hcd->tpl_support = ci->platdata->tpl_support;
6675 +- if (ci->phy || ci->usb_phy)
6676 ++ if (ci->phy || ci->usb_phy) {
6677 + hcd->skip_phy_initialization = 1;
6678 ++ if (ci->usb_phy)
6679 ++ hcd->usb_phy = ci->usb_phy;
6680 ++ }
6681 +
6682 + ehci = hcd_to_ehci(hcd);
6683 + ehci->caps = ci->hw_bank.cap;
6684 +diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
6685 +index a666e0758a99..143309341e11 100644
6686 +--- a/drivers/usb/dwc2/core.h
6687 ++++ b/drivers/usb/dwc2/core.h
6688 +@@ -915,6 +915,7 @@ struct dwc2_hregs_backup {
6689 + * @frame_list_sz: Frame list size
6690 + * @desc_gen_cache: Kmem cache for generic descriptors
6691 + * @desc_hsisoc_cache: Kmem cache for hs isochronous descriptors
6692 ++ * @unaligned_cache: Kmem cache for DMA mode to handle non-aligned buf
6693 + *
6694 + * These are for peripheral mode:
6695 + *
6696 +@@ -1061,6 +1062,8 @@ struct dwc2_hsotg {
6697 + u32 frame_list_sz;
6698 + struct kmem_cache *desc_gen_cache;
6699 + struct kmem_cache *desc_hsisoc_cache;
6700 ++ struct kmem_cache *unaligned_cache;
6701 ++#define DWC2_KMEM_UNALIGNED_BUF_SIZE 1024
6702 +
6703 + #endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */
6704 +
6705 +diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
6706 +index 83cb5577a52f..22240f8fe4ad 100644
6707 +--- a/drivers/usb/dwc2/gadget.c
6708 ++++ b/drivers/usb/dwc2/gadget.c
6709 +@@ -808,6 +808,7 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep,
6710 + u32 index;
6711 + u32 maxsize = 0;
6712 + u32 mask = 0;
6713 ++ u8 pid = 0;
6714 +
6715 + maxsize = dwc2_gadget_get_desc_params(hs_ep, &mask);
6716 + if (len > maxsize) {
6717 +@@ -853,7 +854,11 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep,
6718 + ((len << DEV_DMA_NBYTES_SHIFT) & mask));
6719 +
6720 + if (hs_ep->dir_in) {
6721 +- desc->status |= ((hs_ep->mc << DEV_DMA_ISOC_PID_SHIFT) &
6722 ++ if (len)
6723 ++ pid = DIV_ROUND_UP(len, hs_ep->ep.maxpacket);
6724 ++ else
6725 ++ pid = 1;
6726 ++ desc->status |= ((pid << DEV_DMA_ISOC_PID_SHIFT) &
6727 + DEV_DMA_ISOC_PID_MASK) |
6728 + ((len % hs_ep->ep.maxpacket) ?
6729 + DEV_DMA_SHORT : 0) |
6730 +@@ -892,6 +897,7 @@ static void dwc2_gadget_start_isoc_ddma(struct dwc2_hsotg_ep *hs_ep)
6731 + u32 ctrl;
6732 +
6733 + if (list_empty(&hs_ep->queue)) {
6734 ++ hs_ep->target_frame = TARGET_FRAME_INITIAL;
6735 + dev_dbg(hsotg->dev, "%s: No requests in queue\n", __func__);
6736 + return;
6737 + }
6738 +@@ -4720,9 +4726,11 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
6739 + }
6740 +
6741 + ret = usb_add_gadget_udc(dev, &hsotg->gadget);
6742 +- if (ret)
6743 ++ if (ret) {
6744 ++ dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep,
6745 ++ hsotg->ctrl_req);
6746 + return ret;
6747 +-
6748 ++ }
6749 + dwc2_hsotg_dump(hsotg);
6750 +
6751 + return 0;
6752 +@@ -4735,6 +4743,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
6753 + int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg)
6754 + {
6755 + usb_del_gadget_udc(&hsotg->gadget);
6756 ++ dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep, hsotg->ctrl_req);
6757 +
6758 + return 0;
6759 + }
6760 +diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
6761 +index 3a5f0005fae5..0d66ec3f59a2 100644
6762 +--- a/drivers/usb/dwc2/hcd.c
6763 ++++ b/drivers/usb/dwc2/hcd.c
6764 +@@ -1567,11 +1567,20 @@ static void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
6765 + }
6766 +
6767 + if (hsotg->params.host_dma) {
6768 +- dwc2_writel((u32)chan->xfer_dma,
6769 +- hsotg->regs + HCDMA(chan->hc_num));
6770 ++ dma_addr_t dma_addr;
6771 ++
6772 ++ if (chan->align_buf) {
6773 ++ if (dbg_hc(chan))
6774 ++ dev_vdbg(hsotg->dev, "align_buf\n");
6775 ++ dma_addr = chan->align_buf;
6776 ++ } else {
6777 ++ dma_addr = chan->xfer_dma;
6778 ++ }
6779 ++ dwc2_writel((u32)dma_addr, hsotg->regs + HCDMA(chan->hc_num));
6780 ++
6781 + if (dbg_hc(chan))
6782 + dev_vdbg(hsotg->dev, "Wrote %08lx to HCDMA(%d)\n",
6783 +- (unsigned long)chan->xfer_dma, chan->hc_num);
6784 ++ (unsigned long)dma_addr, chan->hc_num);
6785 + }
6786 +
6787 + /* Start the split */
6788 +@@ -2625,6 +2634,35 @@ static void dwc2_hc_init_xfer(struct dwc2_hsotg *hsotg,
6789 + }
6790 + }
6791 +
6792 ++static int dwc2_alloc_split_dma_aligned_buf(struct dwc2_hsotg *hsotg,
6793 ++ struct dwc2_qh *qh,
6794 ++ struct dwc2_host_chan *chan)
6795 ++{
6796 ++ if (!hsotg->unaligned_cache ||
6797 ++ chan->max_packet > DWC2_KMEM_UNALIGNED_BUF_SIZE)
6798 ++ return -ENOMEM;
6799 ++
6800 ++ if (!qh->dw_align_buf) {
6801 ++ qh->dw_align_buf = kmem_cache_alloc(hsotg->unaligned_cache,
6802 ++ GFP_ATOMIC | GFP_DMA);
6803 ++ if (!qh->dw_align_buf)
6804 ++ return -ENOMEM;
6805 ++ }
6806 ++
6807 ++ qh->dw_align_buf_dma = dma_map_single(hsotg->dev, qh->dw_align_buf,
6808 ++ DWC2_KMEM_UNALIGNED_BUF_SIZE,
6809 ++ DMA_FROM_DEVICE);
6810 ++
6811 ++ if (dma_mapping_error(hsotg->dev, qh->dw_align_buf_dma)) {
6812 ++ dev_err(hsotg->dev, "can't map align_buf\n");
6813 ++ chan->align_buf = 0;
6814 ++ return -EINVAL;
6815 ++ }
6816 ++
6817 ++ chan->align_buf = qh->dw_align_buf_dma;
6818 ++ return 0;
6819 ++}
6820 ++
6821 + #define DWC2_USB_DMA_ALIGN 4
6822 +
6823 + static void dwc2_free_dma_aligned_buffer(struct urb *urb)
6824 +@@ -2804,6 +2842,32 @@ static int dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
6825 + /* Set the transfer attributes */
6826 + dwc2_hc_init_xfer(hsotg, chan, qtd);
6827 +
6828 ++ /* For non-dword aligned buffers */
6829 ++ if (hsotg->params.host_dma && qh->do_split &&
6830 ++ chan->ep_is_in && (chan->xfer_dma & 0x3)) {
6831 ++ dev_vdbg(hsotg->dev, "Non-aligned buffer\n");
6832 ++ if (dwc2_alloc_split_dma_aligned_buf(hsotg, qh, chan)) {
6833 ++ dev_err(hsotg->dev,
6834 ++ "Failed to allocate memory to handle non-aligned buffer\n");
6835 ++ /* Add channel back to free list */
6836 ++ chan->align_buf = 0;
6837 ++ chan->multi_count = 0;
6838 ++ list_add_tail(&chan->hc_list_entry,
6839 ++ &hsotg->free_hc_list);
6840 ++ qtd->in_process = 0;
6841 ++ qh->channel = NULL;
6842 ++ return -ENOMEM;
6843 ++ }
6844 ++ } else {
6845 ++ /*
6846 ++ * We assume that DMA is always aligned in non-split
6847 ++ * case or split out case. Warn if not.
6848 ++ */
6849 ++ WARN_ON_ONCE(hsotg->params.host_dma &&
6850 ++ (chan->xfer_dma & 0x3));
6851 ++ chan->align_buf = 0;
6852 ++ }
6853 ++
6854 + if (chan->ep_type == USB_ENDPOINT_XFER_INT ||
6855 + chan->ep_type == USB_ENDPOINT_XFER_ISOC)
6856 + /*
6857 +@@ -5248,6 +5312,19 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
6858 + }
6859 + }
6860 +
6861 ++ if (hsotg->params.host_dma) {
6862 ++ /*
6863 ++ * Create kmem caches to handle non-aligned buffer
6864 ++ * in Buffer DMA mode.
6865 ++ */
6866 ++ hsotg->unaligned_cache = kmem_cache_create("dwc2-unaligned-dma",
6867 ++ DWC2_KMEM_UNALIGNED_BUF_SIZE, 4,
6868 ++ SLAB_CACHE_DMA, NULL);
6869 ++ if (!hsotg->unaligned_cache)
6870 ++ dev_err(hsotg->dev,
6871 ++ "unable to create dwc2 unaligned cache\n");
6872 ++ }
6873 ++
6874 + hsotg->otg_port = 1;
6875 + hsotg->frame_list = NULL;
6876 + hsotg->frame_list_dma = 0;
6877 +@@ -5282,8 +5359,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
6878 + return 0;
6879 +
6880 + error4:
6881 +- kmem_cache_destroy(hsotg->desc_gen_cache);
6882 ++ kmem_cache_destroy(hsotg->unaligned_cache);
6883 + kmem_cache_destroy(hsotg->desc_hsisoc_cache);
6884 ++ kmem_cache_destroy(hsotg->desc_gen_cache);
6885 + error3:
6886 + dwc2_hcd_release(hsotg);
6887 + error2:
6888 +@@ -5324,8 +5402,9 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
6889 + usb_remove_hcd(hcd);
6890 + hsotg->priv = NULL;
6891 +
6892 +- kmem_cache_destroy(hsotg->desc_gen_cache);
6893 ++ kmem_cache_destroy(hsotg->unaligned_cache);
6894 + kmem_cache_destroy(hsotg->desc_hsisoc_cache);
6895 ++ kmem_cache_destroy(hsotg->desc_gen_cache);
6896 +
6897 + dwc2_hcd_release(hsotg);
6898 + usb_put_hcd(hcd);
6899 +@@ -5437,7 +5516,7 @@ int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg)
6900 + dwc2_writel(hprt0, hsotg->regs + HPRT0);
6901 +
6902 + /* Wait for the HPRT0.PrtSusp register field to be set */
6903 +- if (dwc2_hsotg_wait_bit_set(hsotg, HPRT0, HPRT0_SUSP, 300))
6904 ++ if (dwc2_hsotg_wait_bit_set(hsotg, HPRT0, HPRT0_SUSP, 3000))
6905 + dev_warn(hsotg->dev, "Suspend wasn't generated\n");
6906 +
6907 + /*
6908 +@@ -5618,6 +5697,8 @@ int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg, int rem_wakeup,
6909 + return ret;
6910 + }
6911 +
6912 ++ dwc2_hcd_rem_wakeup(hsotg);
6913 ++
6914 + hsotg->hibernated = 0;
6915 + hsotg->bus_suspended = 0;
6916 + hsotg->lx_state = DWC2_L0;
6917 +diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
6918 +index 96a9da5fb202..5b5b9e6f2feb 100644
6919 +--- a/drivers/usb/dwc2/hcd.h
6920 ++++ b/drivers/usb/dwc2/hcd.h
6921 +@@ -76,6 +76,8 @@ struct dwc2_qh;
6922 + * (micro)frame
6923 + * @xfer_buf: Pointer to current transfer buffer position
6924 + * @xfer_dma: DMA address of xfer_buf
6925 ++ * @align_buf: In Buffer DMA mode this will be used if xfer_buf is not
6926 ++ * DWORD aligned
6927 + * @xfer_len: Total number of bytes to transfer
6928 + * @xfer_count: Number of bytes transferred so far
6929 + * @start_pkt_count: Packet count at start of transfer
6930 +@@ -133,6 +135,7 @@ struct dwc2_host_chan {
6931 +
6932 + u8 *xfer_buf;
6933 + dma_addr_t xfer_dma;
6934 ++ dma_addr_t align_buf;
6935 + u32 xfer_len;
6936 + u32 xfer_count;
6937 + u16 start_pkt_count;
6938 +@@ -303,6 +306,9 @@ struct dwc2_hs_transfer_time {
6939 + * is tightly packed.
6940 + * @ls_duration_us: Duration on the low speed bus schedule.
6941 + * @ntd: Actual number of transfer descriptors in a list
6942 ++ * @dw_align_buf: Used instead of original buffer if its physical address
6943 ++ * is not dword-aligned
6944 ++ * @dw_align_buf_dma: DMA address for dw_align_buf
6945 + * @qtd_list: List of QTDs for this QH
6946 + * @channel: Host channel currently processing transfers for this QH
6947 + * @qh_list_entry: Entry for QH in either the periodic or non-periodic
6948 +@@ -350,6 +356,8 @@ struct dwc2_qh {
6949 + struct dwc2_hs_transfer_time hs_transfers[DWC2_HS_SCHEDULE_UFRAMES];
6950 + u32 ls_start_schedule_slice;
6951 + u16 ntd;
6952 ++ u8 *dw_align_buf;
6953 ++ dma_addr_t dw_align_buf_dma;
6954 + struct list_head qtd_list;
6955 + struct dwc2_host_chan *channel;
6956 + struct list_head qh_list_entry;
6957 +diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
6958 +index a5dfd9d8bd9a..9751785ec561 100644
6959 +--- a/drivers/usb/dwc2/hcd_intr.c
6960 ++++ b/drivers/usb/dwc2/hcd_intr.c
6961 +@@ -930,14 +930,21 @@ static int dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg *hsotg,
6962 + frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index];
6963 + len = dwc2_get_actual_xfer_length(hsotg, chan, chnum, qtd,
6964 + DWC2_HC_XFER_COMPLETE, NULL);
6965 +- if (!len) {
6966 ++ if (!len && !qtd->isoc_split_offset) {
6967 + qtd->complete_split = 0;
6968 +- qtd->isoc_split_offset = 0;
6969 + return 0;
6970 + }
6971 +
6972 + frame_desc->actual_length += len;
6973 +
6974 ++ if (chan->align_buf) {
6975 ++ dev_vdbg(hsotg->dev, "non-aligned buffer\n");
6976 ++ dma_unmap_single(hsotg->dev, chan->qh->dw_align_buf_dma,
6977 ++ DWC2_KMEM_UNALIGNED_BUF_SIZE, DMA_FROM_DEVICE);
6978 ++ memcpy(qtd->urb->buf + (chan->xfer_dma - qtd->urb->dma),
6979 ++ chan->qh->dw_align_buf, len);
6980 ++ }
6981 ++
6982 + qtd->isoc_split_offset += len;
6983 +
6984 + hctsiz = dwc2_readl(hsotg->regs + HCTSIZ(chnum));
6985 +diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
6986 +index 6baa75da7907..7995106c98e8 100644
6987 +--- a/drivers/usb/dwc2/hcd_queue.c
6988 ++++ b/drivers/usb/dwc2/hcd_queue.c
6989 +@@ -1695,6 +1695,9 @@ void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
6990 +
6991 + if (qh->desc_list)
6992 + dwc2_hcd_qh_free_ddma(hsotg, qh);
6993 ++ else if (hsotg->unaligned_cache && qh->dw_align_buf)
6994 ++ kmem_cache_free(hsotg->unaligned_cache, qh->dw_align_buf);
6995 ++
6996 + kfree(qh);
6997 + }
6998 +
6999 +diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
7000 +index cb2ee96fd3e8..048922d549dd 100644
7001 +--- a/drivers/usb/dwc3/dwc3-of-simple.c
7002 ++++ b/drivers/usb/dwc3/dwc3-of-simple.c
7003 +@@ -165,8 +165,9 @@ static int dwc3_of_simple_remove(struct platform_device *pdev)
7004 +
7005 + reset_control_put(simple->resets);
7006 +
7007 +- pm_runtime_put_sync(dev);
7008 + pm_runtime_disable(dev);
7009 ++ pm_runtime_put_noidle(dev);
7010 ++ pm_runtime_set_suspended(dev);
7011 +
7012 + return 0;
7013 + }
7014 +diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
7015 +index c961a94d136b..f57e7c94b8e5 100644
7016 +--- a/drivers/usb/dwc3/dwc3-pci.c
7017 ++++ b/drivers/usb/dwc3/dwc3-pci.c
7018 +@@ -34,6 +34,7 @@
7019 + #define PCI_DEVICE_ID_INTEL_GLK 0x31aa
7020 + #define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee
7021 + #define PCI_DEVICE_ID_INTEL_CNPH 0xa36e
7022 ++#define PCI_DEVICE_ID_INTEL_ICLLP 0x34ee
7023 +
7024 + #define PCI_INTEL_BXT_DSM_GUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
7025 + #define PCI_INTEL_BXT_FUNC_PMU_PWR 4
7026 +@@ -289,6 +290,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
7027 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), },
7028 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPLP), },
7029 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPH), },
7030 ++ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICLLP), },
7031 + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
7032 + { } /* Terminating Entry */
7033 + };
7034 +diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
7035 +index 330c591fd7d6..afd6c977beec 100644
7036 +--- a/drivers/usb/gadget/composite.c
7037 ++++ b/drivers/usb/gadget/composite.c
7038 +@@ -1719,6 +1719,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
7039 + */
7040 + if (w_value && !f->get_alt)
7041 + break;
7042 ++
7043 ++ spin_lock(&cdev->lock);
7044 + value = f->set_alt(f, w_index, w_value);
7045 + if (value == USB_GADGET_DELAYED_STATUS) {
7046 + DBG(cdev,
7047 +@@ -1728,6 +1730,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
7048 + DBG(cdev, "delayed_status count %d\n",
7049 + cdev->delayed_status);
7050 + }
7051 ++ spin_unlock(&cdev->lock);
7052 + break;
7053 + case USB_REQ_GET_INTERFACE:
7054 + if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE))
7055 +diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
7056 +index 7e57439ac282..32fdc79cd73b 100644
7057 +--- a/drivers/usb/gadget/function/f_fs.c
7058 ++++ b/drivers/usb/gadget/function/f_fs.c
7059 +@@ -215,6 +215,7 @@ struct ffs_io_data {
7060 +
7061 + struct mm_struct *mm;
7062 + struct work_struct work;
7063 ++ struct work_struct cancellation_work;
7064 +
7065 + struct usb_ep *ep;
7066 + struct usb_request *req;
7067 +@@ -1072,22 +1073,31 @@ ffs_epfile_open(struct inode *inode, struct file *file)
7068 + return 0;
7069 + }
7070 +
7071 ++static void ffs_aio_cancel_worker(struct work_struct *work)
7072 ++{
7073 ++ struct ffs_io_data *io_data = container_of(work, struct ffs_io_data,
7074 ++ cancellation_work);
7075 ++
7076 ++ ENTER();
7077 ++
7078 ++ usb_ep_dequeue(io_data->ep, io_data->req);
7079 ++}
7080 ++
7081 + static int ffs_aio_cancel(struct kiocb *kiocb)
7082 + {
7083 + struct ffs_io_data *io_data = kiocb->private;
7084 +- struct ffs_epfile *epfile = kiocb->ki_filp->private_data;
7085 ++ struct ffs_data *ffs = io_data->ffs;
7086 + int value;
7087 +
7088 + ENTER();
7089 +
7090 +- spin_lock_irq(&epfile->ffs->eps_lock);
7091 +-
7092 +- if (likely(io_data && io_data->ep && io_data->req))
7093 +- value = usb_ep_dequeue(io_data->ep, io_data->req);
7094 +- else
7095 ++ if (likely(io_data && io_data->ep && io_data->req)) {
7096 ++ INIT_WORK(&io_data->cancellation_work, ffs_aio_cancel_worker);
7097 ++ queue_work(ffs->io_completion_wq, &io_data->cancellation_work);
7098 ++ value = -EINPROGRESS;
7099 ++ } else {
7100 + value = -EINVAL;
7101 +-
7102 +- spin_unlock_irq(&epfile->ffs->eps_lock);
7103 ++ }
7104 +
7105 + return value;
7106 + }
7107 +diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c
7108 +index c359bae7b754..18925c0dde59 100644
7109 +--- a/drivers/usb/host/xhci-dbgcap.c
7110 ++++ b/drivers/usb/host/xhci-dbgcap.c
7111 +@@ -507,16 +507,18 @@ static int xhci_do_dbc_start(struct xhci_hcd *xhci)
7112 + return 0;
7113 + }
7114 +
7115 +-static void xhci_do_dbc_stop(struct xhci_hcd *xhci)
7116 ++static int xhci_do_dbc_stop(struct xhci_hcd *xhci)
7117 + {
7118 + struct xhci_dbc *dbc = xhci->dbc;
7119 +
7120 + if (dbc->state == DS_DISABLED)
7121 +- return;
7122 ++ return -1;
7123 +
7124 + writel(0, &dbc->regs->control);
7125 + xhci_dbc_mem_cleanup(xhci);
7126 + dbc->state = DS_DISABLED;
7127 ++
7128 ++ return 0;
7129 + }
7130 +
7131 + static int xhci_dbc_start(struct xhci_hcd *xhci)
7132 +@@ -543,6 +545,7 @@ static int xhci_dbc_start(struct xhci_hcd *xhci)
7133 +
7134 + static void xhci_dbc_stop(struct xhci_hcd *xhci)
7135 + {
7136 ++ int ret;
7137 + unsigned long flags;
7138 + struct xhci_dbc *dbc = xhci->dbc;
7139 + struct dbc_port *port = &dbc->port;
7140 +@@ -555,10 +558,11 @@ static void xhci_dbc_stop(struct xhci_hcd *xhci)
7141 + xhci_dbc_tty_unregister_device(xhci);
7142 +
7143 + spin_lock_irqsave(&dbc->lock, flags);
7144 +- xhci_do_dbc_stop(xhci);
7145 ++ ret = xhci_do_dbc_stop(xhci);
7146 + spin_unlock_irqrestore(&dbc->lock, flags);
7147 +
7148 +- pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller);
7149 ++ if (!ret)
7150 ++ pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller);
7151 + }
7152 +
7153 + static void
7154 +diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
7155 +index 2c076ea80522..1ed87cee8d21 100644
7156 +--- a/drivers/usb/host/xhci-tegra.c
7157 ++++ b/drivers/usb/host/xhci-tegra.c
7158 +@@ -479,7 +479,7 @@ static void tegra_xusb_mbox_handle(struct tegra_xusb *tegra,
7159 + unsigned long mask;
7160 + unsigned int port;
7161 + bool idle, enable;
7162 +- int err;
7163 ++ int err = 0;
7164 +
7165 + memset(&rsp, 0, sizeof(rsp));
7166 +
7167 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
7168 +index 5fb4319d7fd1..ae56eac34fc7 100644
7169 +--- a/drivers/usb/host/xhci.c
7170 ++++ b/drivers/usb/host/xhci.c
7171 +@@ -1014,8 +1014,13 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
7172 + command = readl(&xhci->op_regs->command);
7173 + command |= CMD_CRS;
7174 + writel(command, &xhci->op_regs->command);
7175 ++ /*
7176 ++ * Some controllers take up to 55+ ms to complete the controller
7177 ++ * restore so setting the timeout to 100ms. Xhci specification
7178 ++ * doesn't mention any timeout value.
7179 ++ */
7180 + if (xhci_handshake(&xhci->op_regs->status,
7181 +- STS_RESTORE, 0, 10 * 1000)) {
7182 ++ STS_RESTORE, 0, 100 * 1000)) {
7183 + xhci_warn(xhci, "WARN: xHC restore state timeout\n");
7184 + spin_unlock_irq(&xhci->lock);
7185 + return -ETIMEDOUT;
7186 +diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
7187 +index 9b29b67191bc..58b6598f8e10 100644
7188 +--- a/drivers/usb/typec/tcpm.c
7189 ++++ b/drivers/usb/typec/tcpm.c
7190 +@@ -2543,7 +2543,8 @@ static void run_state_machine(struct tcpm_port *port)
7191 + tcpm_port_is_sink(port) &&
7192 + time_is_after_jiffies(port->delayed_runtime)) {
7193 + tcpm_set_state(port, SNK_DISCOVERY,
7194 +- port->delayed_runtime - jiffies);
7195 ++ jiffies_to_msecs(port->delayed_runtime -
7196 ++ jiffies));
7197 + break;
7198 + }
7199 + tcpm_set_state(port, unattached_state(port), 0);
7200 +diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
7201 +index 8835065029d3..c93d8ef8df34 100644
7202 +--- a/drivers/xen/manage.c
7203 ++++ b/drivers/xen/manage.c
7204 +@@ -289,8 +289,15 @@ static void sysrq_handler(struct xenbus_watch *watch, const char *path,
7205 + return;
7206 + }
7207 +
7208 +- if (sysrq_key != '\0')
7209 +- xenbus_printf(xbt, "control", "sysrq", "%c", '\0');
7210 ++ if (sysrq_key != '\0') {
7211 ++ err = xenbus_printf(xbt, "control", "sysrq", "%c", '\0');
7212 ++ if (err) {
7213 ++ pr_err("%s: Error %d writing sysrq in control/sysrq\n",
7214 ++ __func__, err);
7215 ++ xenbus_transaction_end(xbt, 1);
7216 ++ return;
7217 ++ }
7218 ++ }
7219 +
7220 + err = xenbus_transaction_end(xbt, 0);
7221 + if (err == -EAGAIN)
7222 +@@ -342,7 +349,12 @@ static int setup_shutdown_watcher(void)
7223 + continue;
7224 + snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
7225 + shutdown_handlers[idx].command);
7226 +- xenbus_printf(XBT_NIL, "control", node, "%u", 1);
7227 ++ err = xenbus_printf(XBT_NIL, "control", node, "%u", 1);
7228 ++ if (err) {
7229 ++ pr_err("%s: Error %d writing %s\n", __func__,
7230 ++ err, node);
7231 ++ return err;
7232 ++ }
7233 + }
7234 +
7235 + return 0;
7236 +diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
7237 +index 7bc88fd43cfc..e2f3e8b0fba9 100644
7238 +--- a/drivers/xen/xen-scsiback.c
7239 ++++ b/drivers/xen/xen-scsiback.c
7240 +@@ -1012,6 +1012,7 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
7241 + {
7242 + struct v2p_entry *entry;
7243 + unsigned long flags;
7244 ++ int err;
7245 +
7246 + if (try) {
7247 + spin_lock_irqsave(&info->v2p_lock, flags);
7248 +@@ -1027,8 +1028,11 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
7249 + scsiback_del_translation_entry(info, vir);
7250 + }
7251 + } else if (!try) {
7252 +- xenbus_printf(XBT_NIL, info->dev->nodename, state,
7253 ++ err = xenbus_printf(XBT_NIL, info->dev->nodename, state,
7254 + "%d", XenbusStateClosed);
7255 ++ if (err)
7256 ++ xenbus_dev_error(info->dev, err,
7257 ++ "%s: writing %s", __func__, state);
7258 + }
7259 + }
7260 +
7261 +@@ -1067,8 +1071,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
7262 + snprintf(str, sizeof(str), "vscsi-devs/%s/p-dev", ent);
7263 + val = xenbus_read(XBT_NIL, dev->nodename, str, NULL);
7264 + if (IS_ERR(val)) {
7265 +- xenbus_printf(XBT_NIL, dev->nodename, state,
7266 ++ err = xenbus_printf(XBT_NIL, dev->nodename, state,
7267 + "%d", XenbusStateClosed);
7268 ++ if (err)
7269 ++ xenbus_dev_error(info->dev, err,
7270 ++ "%s: writing %s", __func__, state);
7271 + return;
7272 + }
7273 + strlcpy(phy, val, VSCSI_NAMELEN);
7274 +@@ -1079,8 +1086,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
7275 + err = xenbus_scanf(XBT_NIL, dev->nodename, str, "%u:%u:%u:%u",
7276 + &vir.hst, &vir.chn, &vir.tgt, &vir.lun);
7277 + if (XENBUS_EXIST_ERR(err)) {
7278 +- xenbus_printf(XBT_NIL, dev->nodename, state,
7279 ++ err = xenbus_printf(XBT_NIL, dev->nodename, state,
7280 + "%d", XenbusStateClosed);
7281 ++ if (err)
7282 ++ xenbus_dev_error(info->dev, err,
7283 ++ "%s: writing %s", __func__, state);
7284 + return;
7285 + }
7286 +
7287 +diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
7288 +index ad8a69ba7f13..7391b123a17a 100644
7289 +--- a/fs/btrfs/scrub.c
7290 ++++ b/fs/btrfs/scrub.c
7291 +@@ -1151,11 +1151,6 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
7292 + return ret;
7293 + }
7294 +
7295 +- if (sctx->is_dev_replace && !is_metadata && !have_csum) {
7296 +- sblocks_for_recheck = NULL;
7297 +- goto nodatasum_case;
7298 +- }
7299 +-
7300 + /*
7301 + * read all mirrors one after the other. This includes to
7302 + * re-read the extent or metadata block that failed (that was
7303 +@@ -1268,13 +1263,19 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
7304 + goto out;
7305 + }
7306 +
7307 +- if (!is_metadata && !have_csum) {
7308 ++ /*
7309 ++ * NOTE: Even for nodatasum case, it's still possible that it's a
7310 ++ * compressed data extent, thus scrub_fixup_nodatasum(), which write
7311 ++ * inode page cache onto disk, could cause serious data corruption.
7312 ++ *
7313 ++ * So here we could only read from disk, and hope our recovery could
7314 ++ * reach disk before the newer write.
7315 ++ */
7316 ++ if (0 && !is_metadata && !have_csum) {
7317 + struct scrub_fixup_nodatasum *fixup_nodatasum;
7318 +
7319 + WARN_ON(sctx->is_dev_replace);
7320 +
7321 +-nodatasum_case:
7322 +-
7323 + /*
7324 + * !is_metadata and !have_csum, this means that the data
7325 + * might not be COWed, that it might be modified
7326 +diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
7327 +index ae056927080d..6b6868d0cdcc 100644
7328 +--- a/fs/ceph/inode.c
7329 ++++ b/fs/ceph/inode.c
7330 +@@ -1123,6 +1123,7 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in)
7331 + if (IS_ERR(realdn)) {
7332 + pr_err("splice_dentry error %ld %p inode %p ino %llx.%llx\n",
7333 + PTR_ERR(realdn), dn, in, ceph_vinop(in));
7334 ++ dput(dn);
7335 + dn = realdn; /* note realdn contains the error */
7336 + goto out;
7337 + } else if (realdn) {
7338 +diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
7339 +index 71013c5268b9..9c8d5f12546b 100644
7340 +--- a/fs/cifs/smb2pdu.c
7341 ++++ b/fs/cifs/smb2pdu.c
7342 +@@ -923,8 +923,9 @@ SMB2_sess_alloc_buffer(struct SMB2_sess_data *sess_data)
7343 + req->PreviousSessionId = sess_data->previous_session;
7344 +
7345 + req->Flags = 0; /* MBZ */
7346 +- /* to enable echos and oplocks */
7347 +- req->sync_hdr.CreditRequest = cpu_to_le16(3);
7348 ++
7349 ++ /* enough to enable echos and oplocks and one max size write */
7350 ++ req->sync_hdr.CreditRequest = cpu_to_le16(130);
7351 +
7352 + /* only one of SMB2 signing flags may be set in SMB2 request */
7353 + if (server->sign)
7354 +diff --git a/fs/exec.c b/fs/exec.c
7355 +index 183059c427b9..7d00f8ceba3f 100644
7356 +--- a/fs/exec.c
7357 ++++ b/fs/exec.c
7358 +@@ -290,7 +290,7 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
7359 + struct vm_area_struct *vma = NULL;
7360 + struct mm_struct *mm = bprm->mm;
7361 +
7362 +- bprm->vma = vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
7363 ++ bprm->vma = vma = vm_area_alloc(mm);
7364 + if (!vma)
7365 + return -ENOMEM;
7366 +
7367 +@@ -298,7 +298,6 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
7368 + err = -EINTR;
7369 + goto err_free;
7370 + }
7371 +- vma->vm_mm = mm;
7372 +
7373 + /*
7374 + * Place the stack at the largest stack address the architecture
7375 +@@ -311,7 +310,6 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
7376 + vma->vm_start = vma->vm_end - PAGE_SIZE;
7377 + vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
7378 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
7379 +- INIT_LIST_HEAD(&vma->anon_vma_chain);
7380 +
7381 + err = insert_vm_struct(mm, vma);
7382 + if (err)
7383 +@@ -326,7 +324,7 @@ err:
7384 + up_write(&mm->mmap_sem);
7385 + err_free:
7386 + bprm->vma = NULL;
7387 +- kmem_cache_free(vm_area_cachep, vma);
7388 ++ vm_area_free(vma);
7389 + return err;
7390 + }
7391 +
7392 +diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
7393 +index 39187e7b3748..050838f03328 100644
7394 +--- a/fs/ext4/mballoc.c
7395 ++++ b/fs/ext4/mballoc.c
7396 +@@ -14,6 +14,7 @@
7397 + #include <linux/log2.h>
7398 + #include <linux/module.h>
7399 + #include <linux/slab.h>
7400 ++#include <linux/nospec.h>
7401 + #include <linux/backing-dev.h>
7402 + #include <trace/events/ext4.h>
7403 +
7404 +@@ -2140,7 +2141,8 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
7405 + * This should tell if fe_len is exactly power of 2
7406 + */
7407 + if ((ac->ac_g_ex.fe_len & (~(1 << (i - 1)))) == 0)
7408 +- ac->ac_2order = i - 1;
7409 ++ ac->ac_2order = array_index_nospec(i - 1,
7410 ++ sb->s_blocksize_bits + 2);
7411 + }
7412 +
7413 + /* if stream allocation is enabled, use global goal */
7414 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
7415 +index 2d94eb9cd386..0f6291675123 100644
7416 +--- a/fs/nfs/nfs4proc.c
7417 ++++ b/fs/nfs/nfs4proc.c
7418 +@@ -8620,6 +8620,8 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
7419 +
7420 + dprintk("--> %s tk_status => %d\n", __func__, -task->tk_status);
7421 +
7422 ++ nfs4_sequence_free_slot(&lgp->res.seq_res);
7423 ++
7424 + switch (nfs4err) {
7425 + case 0:
7426 + goto out;
7427 +@@ -8684,7 +8686,6 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
7428 + goto out;
7429 + }
7430 +
7431 +- nfs4_sequence_free_slot(&lgp->res.seq_res);
7432 + err = nfs4_handle_exception(server, nfs4err, exception);
7433 + if (!status) {
7434 + if (exception->retry)
7435 +@@ -8810,20 +8811,22 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout, gfp_t gfp_flags)
7436 + if (IS_ERR(task))
7437 + return ERR_CAST(task);
7438 + status = rpc_wait_for_completion_task(task);
7439 +- if (status == 0) {
7440 ++ if (status != 0)
7441 ++ goto out;
7442 ++
7443 ++ /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */
7444 ++ if (task->tk_status < 0 || lgp->res.layoutp->len == 0) {
7445 + status = nfs4_layoutget_handle_exception(task, lgp, &exception);
7446 + *timeout = exception.timeout;
7447 +- }
7448 +-
7449 ++ } else
7450 ++ lseg = pnfs_layout_process(lgp);
7451 ++out:
7452 + trace_nfs4_layoutget(lgp->args.ctx,
7453 + &lgp->args.range,
7454 + &lgp->res.range,
7455 + &lgp->res.stateid,
7456 + status);
7457 +
7458 +- /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */
7459 +- if (status == 0 && lgp->res.layoutp->len)
7460 +- lseg = pnfs_layout_process(lgp);
7461 + rpc_put_task(task);
7462 + dprintk("<-- %s status=%d\n", __func__, status);
7463 + if (status)
7464 +diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
7465 +index 5dbf5324bdda..8fb367c5bdd7 100644
7466 +--- a/fs/reiserfs/xattr.c
7467 ++++ b/fs/reiserfs/xattr.c
7468 +@@ -792,8 +792,10 @@ static int listxattr_filler(struct dir_context *ctx, const char *name,
7469 + return 0;
7470 + size = namelen + 1;
7471 + if (b->buf) {
7472 +- if (size > b->size)
7473 ++ if (b->pos + size > b->size) {
7474 ++ b->pos = -ERANGE;
7475 + return -ERANGE;
7476 ++ }
7477 + memcpy(b->buf + b->pos, name, namelen);
7478 + b->buf[b->pos + namelen] = 0;
7479 + }
7480 +diff --git a/include/linux/fsl/guts.h b/include/linux/fsl/guts.h
7481 +index 3efa3b861d44..941b11811f85 100644
7482 +--- a/include/linux/fsl/guts.h
7483 ++++ b/include/linux/fsl/guts.h
7484 +@@ -16,6 +16,7 @@
7485 + #define __FSL_GUTS_H__
7486 +
7487 + #include <linux/types.h>
7488 ++#include <linux/io.h>
7489 +
7490 + /**
7491 + * Global Utility Registers.
7492 +diff --git a/include/linux/kthread.h b/include/linux/kthread.h
7493 +index 2803264c512f..c1961761311d 100644
7494 +--- a/include/linux/kthread.h
7495 ++++ b/include/linux/kthread.h
7496 +@@ -62,7 +62,6 @@ void *kthread_probe_data(struct task_struct *k);
7497 + int kthread_park(struct task_struct *k);
7498 + void kthread_unpark(struct task_struct *k);
7499 + void kthread_parkme(void);
7500 +-void kthread_park_complete(struct task_struct *k);
7501 +
7502 + int kthreadd(void *unused);
7503 + extern struct task_struct *kthreadd_task;
7504 +diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h
7505 +index 4f5f8c21e283..1eb6f244588d 100644
7506 +--- a/include/linux/marvell_phy.h
7507 ++++ b/include/linux/marvell_phy.h
7508 +@@ -27,6 +27,8 @@
7509 + */
7510 + #define MARVELL_PHY_ID_88E6390 0x01410f90
7511 +
7512 ++#define MARVELL_PHY_FAMILY_ID(id) ((id) >> 4)
7513 ++
7514 + /* struct phy_device dev_flags definitions */
7515 + #define MARVELL_PHY_M1145_FLAGS_RESISTANCE 0x00000001
7516 + #define MARVELL_PHY_M1118_DNS323_LEDS 0x00000002
7517 +diff --git a/include/linux/mm.h b/include/linux/mm.h
7518 +index edab43d2bec8..28477ff9cf04 100644
7519 +--- a/include/linux/mm.h
7520 ++++ b/include/linux/mm.h
7521 +@@ -154,7 +154,9 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *,
7522 + * mmap() functions).
7523 + */
7524 +
7525 +-extern struct kmem_cache *vm_area_cachep;
7526 ++struct vm_area_struct *vm_area_alloc(struct mm_struct *);
7527 ++struct vm_area_struct *vm_area_dup(struct vm_area_struct *);
7528 ++void vm_area_free(struct vm_area_struct *);
7529 +
7530 + #ifndef CONFIG_MMU
7531 + extern struct rb_root nommu_region_tree;
7532 +diff --git a/include/linux/pci.h b/include/linux/pci.h
7533 +index 73178a2fcee0..27f9bdd7e46d 100644
7534 +--- a/include/linux/pci.h
7535 ++++ b/include/linux/pci.h
7536 +@@ -1236,6 +1236,8 @@ int pci_register_io_range(struct fwnode_handle *fwnode, phys_addr_t addr,
7537 + unsigned long pci_address_to_pio(phys_addr_t addr);
7538 + phys_addr_t pci_pio_to_address(unsigned long pio);
7539 + int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr);
7540 ++int devm_pci_remap_iospace(struct device *dev, const struct resource *res,
7541 ++ phys_addr_t phys_addr);
7542 + void pci_unmap_iospace(struct resource *res);
7543 + void __iomem *devm_pci_remap_cfgspace(struct device *dev,
7544 + resource_size_t offset,
7545 +diff --git a/include/linux/sched.h b/include/linux/sched.h
7546 +index ca3f3eae8980..5c32faa4af99 100644
7547 +--- a/include/linux/sched.h
7548 ++++ b/include/linux/sched.h
7549 +@@ -117,7 +117,7 @@ struct task_group;
7550 + * the comment with set_special_state().
7551 + */
7552 + #define is_special_task_state(state) \
7553 +- ((state) & (__TASK_STOPPED | __TASK_TRACED | TASK_DEAD))
7554 ++ ((state) & (__TASK_STOPPED | __TASK_TRACED | TASK_PARKED | TASK_DEAD))
7555 +
7556 + #define __set_current_state(state_value) \
7557 + do { \
7558 +diff --git a/include/net/ipv6.h b/include/net/ipv6.h
7559 +index aeebbbb9e0bd..62b6bfcce152 100644
7560 +--- a/include/net/ipv6.h
7561 ++++ b/include/net/ipv6.h
7562 +@@ -354,14 +354,7 @@ struct ipv6_txoptions *ipv6_dup_options(struct sock *sk,
7563 + struct ipv6_txoptions *ipv6_renew_options(struct sock *sk,
7564 + struct ipv6_txoptions *opt,
7565 + int newtype,
7566 +- struct ipv6_opt_hdr __user *newopt,
7567 +- int newoptlen);
7568 +-struct ipv6_txoptions *
7569 +-ipv6_renew_options_kern(struct sock *sk,
7570 +- struct ipv6_txoptions *opt,
7571 +- int newtype,
7572 +- struct ipv6_opt_hdr *newopt,
7573 +- int newoptlen);
7574 ++ struct ipv6_opt_hdr *newopt);
7575 + struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
7576 + struct ipv6_txoptions *opt);
7577 +
7578 +diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
7579 +index 47e35cce3b64..a71264d75d7f 100644
7580 +--- a/include/net/net_namespace.h
7581 ++++ b/include/net/net_namespace.h
7582 +@@ -128,6 +128,7 @@ struct net {
7583 + #endif
7584 + #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
7585 + struct netns_nf_frag nf_frag;
7586 ++ struct ctl_table_header *nf_frag_frags_hdr;
7587 + #endif
7588 + struct sock *nfnl;
7589 + struct sock *nfnl_stash;
7590 +diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
7591 +index c29f09cfc9d7..5ce433f9e88a 100644
7592 +--- a/include/net/netns/ipv6.h
7593 ++++ b/include/net/netns/ipv6.h
7594 +@@ -107,7 +107,6 @@ struct netns_ipv6 {
7595 +
7596 + #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
7597 + struct netns_nf_frag {
7598 +- struct netns_sysctl_ipv6 sysctl;
7599 + struct netns_frags frags;
7600 + };
7601 + #endif
7602 +diff --git a/include/net/tc_act/tc_csum.h b/include/net/tc_act/tc_csum.h
7603 +index 9470fd7e4350..32d2454c0479 100644
7604 +--- a/include/net/tc_act/tc_csum.h
7605 ++++ b/include/net/tc_act/tc_csum.h
7606 +@@ -7,7 +7,6 @@
7607 + #include <linux/tc_act/tc_csum.h>
7608 +
7609 + struct tcf_csum_params {
7610 +- int action;
7611 + u32 update_flags;
7612 + struct rcu_head rcu;
7613 + };
7614 +diff --git a/include/net/tc_act/tc_tunnel_key.h b/include/net/tc_act/tc_tunnel_key.h
7615 +index efef0b4b1b2b..46b8c7f1c8d5 100644
7616 +--- a/include/net/tc_act/tc_tunnel_key.h
7617 ++++ b/include/net/tc_act/tc_tunnel_key.h
7618 +@@ -18,7 +18,6 @@
7619 + struct tcf_tunnel_key_params {
7620 + struct rcu_head rcu;
7621 + int tcft_action;
7622 +- int action;
7623 + struct metadata_dst *tcft_enc_metadata;
7624 + };
7625 +
7626 +diff --git a/include/net/tcp.h b/include/net/tcp.h
7627 +index 5ccc4ec646cb..b0639f336976 100644
7628 +--- a/include/net/tcp.h
7629 ++++ b/include/net/tcp.h
7630 +@@ -907,8 +907,6 @@ enum tcp_ca_event {
7631 + CA_EVENT_LOSS, /* loss timeout */
7632 + CA_EVENT_ECN_NO_CE, /* ECT set, but not CE marked */
7633 + CA_EVENT_ECN_IS_CE, /* received CE marked IP packet */
7634 +- CA_EVENT_DELAYED_ACK, /* Delayed ack is sent */
7635 +- CA_EVENT_NON_DELAYED_ACK,
7636 + };
7637 +
7638 + /* Information about inbound ACK, passed to cong_ops->in_ack_event() */
7639 +diff --git a/include/uapi/linux/nbd.h b/include/uapi/linux/nbd.h
7640 +index 85a3fb65e40a..20d6cc91435d 100644
7641 +--- a/include/uapi/linux/nbd.h
7642 ++++ b/include/uapi/linux/nbd.h
7643 +@@ -53,6 +53,9 @@ enum {
7644 + /* These are client behavior specific flags. */
7645 + #define NBD_CFLAG_DESTROY_ON_DISCONNECT (1 << 0) /* delete the nbd device on
7646 + disconnect. */
7647 ++#define NBD_CFLAG_DISCONNECT_ON_CLOSE (1 << 1) /* disconnect the nbd device on
7648 ++ * close by last opener.
7649 ++ */
7650 +
7651 + /* userspace doesn't need the nbd_device structure */
7652 +
7653 +diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
7654 +index b76828f23b49..3bd61b004418 100644
7655 +--- a/kernel/bpf/hashtab.c
7656 ++++ b/kernel/bpf/hashtab.c
7657 +@@ -743,13 +743,15 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
7658 + * old element will be freed immediately.
7659 + * Otherwise return an error
7660 + */
7661 +- atomic_dec(&htab->count);
7662 +- return ERR_PTR(-E2BIG);
7663 ++ l_new = ERR_PTR(-E2BIG);
7664 ++ goto dec_count;
7665 + }
7666 + l_new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN,
7667 + htab->map.numa_node);
7668 +- if (!l_new)
7669 +- return ERR_PTR(-ENOMEM);
7670 ++ if (!l_new) {
7671 ++ l_new = ERR_PTR(-ENOMEM);
7672 ++ goto dec_count;
7673 ++ }
7674 + }
7675 +
7676 + memcpy(l_new->key, key, key_size);
7677 +@@ -762,7 +764,8 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
7678 + GFP_ATOMIC | __GFP_NOWARN);
7679 + if (!pptr) {
7680 + kfree(l_new);
7681 +- return ERR_PTR(-ENOMEM);
7682 ++ l_new = ERR_PTR(-ENOMEM);
7683 ++ goto dec_count;
7684 + }
7685 + }
7686 +
7687 +@@ -776,6 +779,9 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
7688 +
7689 + l_new->hash = hash;
7690 + return l_new;
7691 ++dec_count:
7692 ++ atomic_dec(&htab->count);
7693 ++ return l_new;
7694 + }
7695 +
7696 + static int check_flags(struct bpf_htab *htab, struct htab_elem *l_old,
7697 +diff --git a/kernel/fork.c b/kernel/fork.c
7698 +index 5ad558e6f8fe..b9d9b39d4afc 100644
7699 +--- a/kernel/fork.c
7700 ++++ b/kernel/fork.c
7701 +@@ -303,11 +303,38 @@ struct kmem_cache *files_cachep;
7702 + struct kmem_cache *fs_cachep;
7703 +
7704 + /* SLAB cache for vm_area_struct structures */
7705 +-struct kmem_cache *vm_area_cachep;
7706 ++static struct kmem_cache *vm_area_cachep;
7707 +
7708 + /* SLAB cache for mm_struct structures (tsk->mm) */
7709 + static struct kmem_cache *mm_cachep;
7710 +
7711 ++struct vm_area_struct *vm_area_alloc(struct mm_struct *mm)
7712 ++{
7713 ++ struct vm_area_struct *vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
7714 ++
7715 ++ if (vma) {
7716 ++ vma->vm_mm = mm;
7717 ++ INIT_LIST_HEAD(&vma->anon_vma_chain);
7718 ++ }
7719 ++ return vma;
7720 ++}
7721 ++
7722 ++struct vm_area_struct *vm_area_dup(struct vm_area_struct *orig)
7723 ++{
7724 ++ struct vm_area_struct *new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
7725 ++
7726 ++ if (new) {
7727 ++ *new = *orig;
7728 ++ INIT_LIST_HEAD(&new->anon_vma_chain);
7729 ++ }
7730 ++ return new;
7731 ++}
7732 ++
7733 ++void vm_area_free(struct vm_area_struct *vma)
7734 ++{
7735 ++ kmem_cache_free(vm_area_cachep, vma);
7736 ++}
7737 ++
7738 + static void account_kernel_stack(struct task_struct *tsk, int account)
7739 + {
7740 + void *stack = task_stack_page(tsk);
7741 +@@ -455,11 +482,9 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
7742 + goto fail_nomem;
7743 + charge = len;
7744 + }
7745 +- tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
7746 ++ tmp = vm_area_dup(mpnt);
7747 + if (!tmp)
7748 + goto fail_nomem;
7749 +- *tmp = *mpnt;
7750 +- INIT_LIST_HEAD(&tmp->anon_vma_chain);
7751 + retval = vma_dup_policy(mpnt, tmp);
7752 + if (retval)
7753 + goto fail_nomem_policy;
7754 +@@ -539,7 +564,7 @@ fail_uprobe_end:
7755 + fail_nomem_anon_vma_fork:
7756 + mpol_put(vma_policy(tmp));
7757 + fail_nomem_policy:
7758 +- kmem_cache_free(vm_area_cachep, tmp);
7759 ++ vm_area_free(tmp);
7760 + fail_nomem:
7761 + retval = -ENOMEM;
7762 + vm_unacct_memory(charge);
7763 +diff --git a/kernel/kthread.c b/kernel/kthread.c
7764 +index 1a481ae12dec..486dedbd9af5 100644
7765 +--- a/kernel/kthread.c
7766 ++++ b/kernel/kthread.c
7767 +@@ -177,9 +177,20 @@ void *kthread_probe_data(struct task_struct *task)
7768 + static void __kthread_parkme(struct kthread *self)
7769 + {
7770 + for (;;) {
7771 +- set_current_state(TASK_PARKED);
7772 ++ /*
7773 ++ * TASK_PARKED is a special state; we must serialize against
7774 ++ * possible pending wakeups to avoid store-store collisions on
7775 ++ * task->state.
7776 ++ *
7777 ++ * Such a collision might possibly result in the task state
7778 ++ * changin from TASK_PARKED and us failing the
7779 ++ * wait_task_inactive() in kthread_park().
7780 ++ */
7781 ++ set_special_state(TASK_PARKED);
7782 + if (!test_bit(KTHREAD_SHOULD_PARK, &self->flags))
7783 + break;
7784 ++
7785 ++ complete_all(&self->parked);
7786 + schedule();
7787 + }
7788 + __set_current_state(TASK_RUNNING);
7789 +@@ -191,11 +202,6 @@ void kthread_parkme(void)
7790 + }
7791 + EXPORT_SYMBOL_GPL(kthread_parkme);
7792 +
7793 +-void kthread_park_complete(struct task_struct *k)
7794 +-{
7795 +- complete_all(&to_kthread(k)->parked);
7796 +-}
7797 +-
7798 + static int kthread(void *_create)
7799 + {
7800 + /* Copy data: it's on kthread's stack */
7801 +@@ -467,6 +473,9 @@ void kthread_unpark(struct task_struct *k)
7802 +
7803 + reinit_completion(&kthread->parked);
7804 + clear_bit(KTHREAD_SHOULD_PARK, &kthread->flags);
7805 ++ /*
7806 ++ * __kthread_parkme() will either see !SHOULD_PARK or get the wakeup.
7807 ++ */
7808 + wake_up_state(k, TASK_PARKED);
7809 + }
7810 + EXPORT_SYMBOL_GPL(kthread_unpark);
7811 +@@ -493,7 +502,16 @@ int kthread_park(struct task_struct *k)
7812 + set_bit(KTHREAD_SHOULD_PARK, &kthread->flags);
7813 + if (k != current) {
7814 + wake_up_process(k);
7815 ++ /*
7816 ++ * Wait for __kthread_parkme() to complete(), this means we
7817 ++ * _will_ have TASK_PARKED and are about to call schedule().
7818 ++ */
7819 + wait_for_completion(&kthread->parked);
7820 ++ /*
7821 ++ * Now wait for that schedule() to complete and the task to
7822 ++ * get scheduled out.
7823 ++ */
7824 ++ WARN_ON_ONCE(!wait_task_inactive(k, TASK_PARKED));
7825 + }
7826 +
7827 + return 0;
7828 +diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
7829 +index 023386338269..7184cea3ca10 100644
7830 +--- a/kernel/locking/lockdep.c
7831 ++++ b/kernel/locking/lockdep.c
7832 +@@ -1261,11 +1261,11 @@ unsigned long lockdep_count_forward_deps(struct lock_class *class)
7833 + this.parent = NULL;
7834 + this.class = class;
7835 +
7836 +- local_irq_save(flags);
7837 ++ raw_local_irq_save(flags);
7838 + arch_spin_lock(&lockdep_lock);
7839 + ret = __lockdep_count_forward_deps(&this);
7840 + arch_spin_unlock(&lockdep_lock);
7841 +- local_irq_restore(flags);
7842 ++ raw_local_irq_restore(flags);
7843 +
7844 + return ret;
7845 + }
7846 +@@ -1288,11 +1288,11 @@ unsigned long lockdep_count_backward_deps(struct lock_class *class)
7847 + this.parent = NULL;
7848 + this.class = class;
7849 +
7850 +- local_irq_save(flags);
7851 ++ raw_local_irq_save(flags);
7852 + arch_spin_lock(&lockdep_lock);
7853 + ret = __lockdep_count_backward_deps(&this);
7854 + arch_spin_unlock(&lockdep_lock);
7855 +- local_irq_restore(flags);
7856 ++ raw_local_irq_restore(flags);
7857 +
7858 + return ret;
7859 + }
7860 +@@ -4407,7 +4407,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
7861 + if (unlikely(!debug_locks))
7862 + return;
7863 +
7864 +- local_irq_save(flags);
7865 ++ raw_local_irq_save(flags);
7866 + for (i = 0; i < curr->lockdep_depth; i++) {
7867 + hlock = curr->held_locks + i;
7868 +
7869 +@@ -4418,7 +4418,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
7870 + print_freed_lock_bug(curr, mem_from, mem_from + mem_len, hlock);
7871 + break;
7872 + }
7873 +- local_irq_restore(flags);
7874 ++ raw_local_irq_restore(flags);
7875 + }
7876 + EXPORT_SYMBOL_GPL(debug_check_no_locks_freed);
7877 +
7878 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
7879 +index ec945451b9ef..0b817812f17f 100644
7880 +--- a/kernel/sched/core.c
7881 ++++ b/kernel/sched/core.c
7882 +@@ -7,7 +7,6 @@
7883 + */
7884 + #include "sched.h"
7885 +
7886 +-#include <linux/kthread.h>
7887 + #include <linux/nospec.h>
7888 +
7889 + #include <asm/switch_to.h>
7890 +@@ -2738,28 +2737,20 @@ static struct rq *finish_task_switch(struct task_struct *prev)
7891 + membarrier_mm_sync_core_before_usermode(mm);
7892 + mmdrop(mm);
7893 + }
7894 +- if (unlikely(prev_state & (TASK_DEAD|TASK_PARKED))) {
7895 +- switch (prev_state) {
7896 +- case TASK_DEAD:
7897 +- if (prev->sched_class->task_dead)
7898 +- prev->sched_class->task_dead(prev);
7899 ++ if (unlikely(prev_state == TASK_DEAD)) {
7900 ++ if (prev->sched_class->task_dead)
7901 ++ prev->sched_class->task_dead(prev);
7902 +
7903 +- /*
7904 +- * Remove function-return probe instances associated with this
7905 +- * task and put them back on the free list.
7906 +- */
7907 +- kprobe_flush_task(prev);
7908 +-
7909 +- /* Task is done with its stack. */
7910 +- put_task_stack(prev);
7911 ++ /*
7912 ++ * Remove function-return probe instances associated with this
7913 ++ * task and put them back on the free list.
7914 ++ */
7915 ++ kprobe_flush_task(prev);
7916 +
7917 +- put_task_struct(prev);
7918 +- break;
7919 ++ /* Task is done with its stack. */
7920 ++ put_task_stack(prev);
7921 +
7922 +- case TASK_PARKED:
7923 +- kthread_park_complete(prev);
7924 +- break;
7925 +- }
7926 ++ put_task_struct(prev);
7927 + }
7928 +
7929 + tick_nohz_task_switch();
7930 +@@ -3127,7 +3118,9 @@ static void sched_tick_remote(struct work_struct *work)
7931 + struct tick_work *twork = container_of(dwork, struct tick_work, work);
7932 + int cpu = twork->cpu;
7933 + struct rq *rq = cpu_rq(cpu);
7934 ++ struct task_struct *curr;
7935 + struct rq_flags rf;
7936 ++ u64 delta;
7937 +
7938 + /*
7939 + * Handle the tick only if it appears the remote CPU is running in full
7940 +@@ -3136,24 +3129,28 @@ static void sched_tick_remote(struct work_struct *work)
7941 + * statistics and checks timeslices in a time-independent way, regardless
7942 + * of when exactly it is running.
7943 + */
7944 +- if (!idle_cpu(cpu) && tick_nohz_tick_stopped_cpu(cpu)) {
7945 +- struct task_struct *curr;
7946 +- u64 delta;
7947 ++ if (idle_cpu(cpu) || !tick_nohz_tick_stopped_cpu(cpu))
7948 ++ goto out_requeue;
7949 +
7950 +- rq_lock_irq(rq, &rf);
7951 +- update_rq_clock(rq);
7952 +- curr = rq->curr;
7953 +- delta = rq_clock_task(rq) - curr->se.exec_start;
7954 ++ rq_lock_irq(rq, &rf);
7955 ++ curr = rq->curr;
7956 ++ if (is_idle_task(curr))
7957 ++ goto out_unlock;
7958 +
7959 +- /*
7960 +- * Make sure the next tick runs within a reasonable
7961 +- * amount of time.
7962 +- */
7963 +- WARN_ON_ONCE(delta > (u64)NSEC_PER_SEC * 3);
7964 +- curr->sched_class->task_tick(rq, curr, 0);
7965 +- rq_unlock_irq(rq, &rf);
7966 +- }
7967 ++ update_rq_clock(rq);
7968 ++ delta = rq_clock_task(rq) - curr->se.exec_start;
7969 ++
7970 ++ /*
7971 ++ * Make sure the next tick runs within a reasonable
7972 ++ * amount of time.
7973 ++ */
7974 ++ WARN_ON_ONCE(delta > (u64)NSEC_PER_SEC * 3);
7975 ++ curr->sched_class->task_tick(rq, curr, 0);
7976 ++
7977 ++out_unlock:
7978 ++ rq_unlock_irq(rq, &rf);
7979 +
7980 ++out_requeue:
7981 + /*
7982 + * Run the remote tick once per second (1Hz). This arbitrary
7983 + * frequency is large enough to avoid overload but short enough
7984 +diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
7985 +index 8b50eea4b607..b5fbdde6afa9 100644
7986 +--- a/kernel/sched/deadline.c
7987 ++++ b/kernel/sched/deadline.c
7988 +@@ -2296,8 +2296,17 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p)
7989 + if (task_on_rq_queued(p) && p->dl.dl_runtime)
7990 + task_non_contending(p);
7991 +
7992 +- if (!task_on_rq_queued(p))
7993 ++ if (!task_on_rq_queued(p)) {
7994 ++ /*
7995 ++ * Inactive timer is armed. However, p is leaving DEADLINE and
7996 ++ * might migrate away from this rq while continuing to run on
7997 ++ * some other class. We need to remove its contribution from
7998 ++ * this rq running_bw now, or sub_rq_bw (below) will complain.
7999 ++ */
8000 ++ if (p->dl.dl_non_contending)
8001 ++ sub_running_bw(&p->dl, &rq->dl);
8002 + sub_rq_bw(&p->dl, &rq->dl);
8003 ++ }
8004 +
8005 + /*
8006 + * We cannot use inactive_task_timer() to invoke sub_running_bw()
8007 +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
8008 +index 183068d22849..9b0c02ec7517 100644
8009 +--- a/kernel/sched/fair.c
8010 ++++ b/kernel/sched/fair.c
8011 +@@ -3941,18 +3941,10 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep)
8012 + if (!sched_feat(UTIL_EST))
8013 + return;
8014 +
8015 +- /*
8016 +- * Update root cfs_rq's estimated utilization
8017 +- *
8018 +- * If *p is the last task then the root cfs_rq's estimated utilization
8019 +- * of a CPU is 0 by definition.
8020 +- */
8021 +- ue.enqueued = 0;
8022 +- if (cfs_rq->nr_running) {
8023 +- ue.enqueued = cfs_rq->avg.util_est.enqueued;
8024 +- ue.enqueued -= min_t(unsigned int, ue.enqueued,
8025 +- (_task_util_est(p) | UTIL_AVG_UNCHANGED));
8026 +- }
8027 ++ /* Update root cfs_rq's estimated utilization */
8028 ++ ue.enqueued = cfs_rq->avg.util_est.enqueued;
8029 ++ ue.enqueued -= min_t(unsigned int, ue.enqueued,
8030 ++ (_task_util_est(p) | UTIL_AVG_UNCHANGED));
8031 + WRITE_ONCE(cfs_rq->avg.util_est.enqueued, ue.enqueued);
8032 +
8033 + /*
8034 +@@ -4549,6 +4541,7 @@ void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b)
8035 + now = sched_clock_cpu(smp_processor_id());
8036 + cfs_b->runtime = cfs_b->quota;
8037 + cfs_b->runtime_expires = now + ktime_to_ns(cfs_b->period);
8038 ++ cfs_b->expires_seq++;
8039 + }
8040 +
8041 + static inline struct cfs_bandwidth *tg_cfs_bandwidth(struct task_group *tg)
8042 +@@ -4571,6 +4564,7 @@ static int assign_cfs_rq_runtime(struct cfs_rq *cfs_rq)
8043 + struct task_group *tg = cfs_rq->tg;
8044 + struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(tg);
8045 + u64 amount = 0, min_amount, expires;
8046 ++ int expires_seq;
8047 +
8048 + /* note: this is a positive sum as runtime_remaining <= 0 */
8049 + min_amount = sched_cfs_bandwidth_slice() - cfs_rq->runtime_remaining;
8050 +@@ -4587,6 +4581,7 @@ static int assign_cfs_rq_runtime(struct cfs_rq *cfs_rq)
8051 + cfs_b->idle = 0;
8052 + }
8053 + }
8054 ++ expires_seq = cfs_b->expires_seq;
8055 + expires = cfs_b->runtime_expires;
8056 + raw_spin_unlock(&cfs_b->lock);
8057 +
8058 +@@ -4596,8 +4591,10 @@ static int assign_cfs_rq_runtime(struct cfs_rq *cfs_rq)
8059 + * spread between our sched_clock and the one on which runtime was
8060 + * issued.
8061 + */
8062 +- if ((s64)(expires - cfs_rq->runtime_expires) > 0)
8063 ++ if (cfs_rq->expires_seq != expires_seq) {
8064 ++ cfs_rq->expires_seq = expires_seq;
8065 + cfs_rq->runtime_expires = expires;
8066 ++ }
8067 +
8068 + return cfs_rq->runtime_remaining > 0;
8069 + }
8070 +@@ -4623,12 +4620,9 @@ static void expire_cfs_rq_runtime(struct cfs_rq *cfs_rq)
8071 + * has not truly expired.
8072 + *
8073 + * Fortunately we can check determine whether this the case by checking
8074 +- * whether the global deadline has advanced. It is valid to compare
8075 +- * cfs_b->runtime_expires without any locks since we only care about
8076 +- * exact equality, so a partial write will still work.
8077 ++ * whether the global deadline(cfs_b->expires_seq) has advanced.
8078 + */
8079 +-
8080 +- if (cfs_rq->runtime_expires != cfs_b->runtime_expires) {
8081 ++ if (cfs_rq->expires_seq == cfs_b->expires_seq) {
8082 + /* extend local deadline, drift is bounded above by 2 ticks */
8083 + cfs_rq->runtime_expires += TICK_NSEC;
8084 + } else {
8085 +diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
8086 +index cb467c221b15..7548b373d1c5 100644
8087 +--- a/kernel/sched/sched.h
8088 ++++ b/kernel/sched/sched.h
8089 +@@ -334,9 +334,10 @@ struct cfs_bandwidth {
8090 + u64 runtime;
8091 + s64 hierarchical_quota;
8092 + u64 runtime_expires;
8093 ++ int expires_seq;
8094 +
8095 +- int idle;
8096 +- int period_active;
8097 ++ short idle;
8098 ++ short period_active;
8099 + struct hrtimer period_timer;
8100 + struct hrtimer slack_timer;
8101 + struct list_head throttled_cfs_rq;
8102 +@@ -551,6 +552,7 @@ struct cfs_rq {
8103 +
8104 + #ifdef CONFIG_CFS_BANDWIDTH
8105 + int runtime_enabled;
8106 ++ int expires_seq;
8107 + u64 runtime_expires;
8108 + s64 runtime_remaining;
8109 +
8110 +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
8111 +index a583b6494b95..214820a14edf 100644
8112 +--- a/kernel/trace/trace.c
8113 ++++ b/kernel/trace/trace.c
8114 +@@ -2962,6 +2962,7 @@ out_nobuffer:
8115 + }
8116 + EXPORT_SYMBOL_GPL(trace_vbprintk);
8117 +
8118 ++__printf(3, 0)
8119 + static int
8120 + __trace_array_vprintk(struct ring_buffer *buffer,
8121 + unsigned long ip, const char *fmt, va_list args)
8122 +@@ -3016,12 +3017,14 @@ out_nobuffer:
8123 + return len;
8124 + }
8125 +
8126 ++__printf(3, 0)
8127 + int trace_array_vprintk(struct trace_array *tr,
8128 + unsigned long ip, const char *fmt, va_list args)
8129 + {
8130 + return __trace_array_vprintk(tr->trace_buffer.buffer, ip, fmt, args);
8131 + }
8132 +
8133 ++__printf(3, 0)
8134 + int trace_array_printk(struct trace_array *tr,
8135 + unsigned long ip, const char *fmt, ...)
8136 + {
8137 +@@ -3037,6 +3040,7 @@ int trace_array_printk(struct trace_array *tr,
8138 + return ret;
8139 + }
8140 +
8141 ++__printf(3, 4)
8142 + int trace_array_printk_buf(struct ring_buffer *buffer,
8143 + unsigned long ip, const char *fmt, ...)
8144 + {
8145 +@@ -3052,6 +3056,7 @@ int trace_array_printk_buf(struct ring_buffer *buffer,
8146 + return ret;
8147 + }
8148 +
8149 ++__printf(2, 0)
8150 + int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
8151 + {
8152 + return trace_array_vprintk(&global_trace, ip, fmt, args);
8153 +diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
8154 +index f185455b3406..c3bd5209da38 100644
8155 +--- a/mm/kasan/kasan.c
8156 ++++ b/mm/kasan/kasan.c
8157 +@@ -619,12 +619,13 @@ void kasan_kfree_large(void *ptr, unsigned long ip)
8158 + int kasan_module_alloc(void *addr, size_t size)
8159 + {
8160 + void *ret;
8161 ++ size_t scaled_size;
8162 + size_t shadow_size;
8163 + unsigned long shadow_start;
8164 +
8165 + shadow_start = (unsigned long)kasan_mem_to_shadow(addr);
8166 +- shadow_size = round_up(size >> KASAN_SHADOW_SCALE_SHIFT,
8167 +- PAGE_SIZE);
8168 ++ scaled_size = (size + KASAN_SHADOW_MASK) >> KASAN_SHADOW_SCALE_SHIFT;
8169 ++ shadow_size = round_up(scaled_size, PAGE_SIZE);
8170 +
8171 + if (WARN_ON(!PAGE_ALIGNED(shadow_start)))
8172 + return -EINVAL;
8173 +diff --git a/mm/mmap.c b/mm/mmap.c
8174 +index 540cfab8c2c4..55d68c24e742 100644
8175 +--- a/mm/mmap.c
8176 ++++ b/mm/mmap.c
8177 +@@ -182,7 +182,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
8178 + if (vma->vm_file)
8179 + fput(vma->vm_file);
8180 + mpol_put(vma_policy(vma));
8181 +- kmem_cache_free(vm_area_cachep, vma);
8182 ++ vm_area_free(vma);
8183 + return next;
8184 + }
8185 +
8186 +@@ -911,7 +911,7 @@ again:
8187 + anon_vma_merge(vma, next);
8188 + mm->map_count--;
8189 + mpol_put(vma_policy(next));
8190 +- kmem_cache_free(vm_area_cachep, next);
8191 ++ vm_area_free(next);
8192 + /*
8193 + * In mprotect's case 6 (see comments on vma_merge),
8194 + * we must remove another next too. It would clutter
8195 +@@ -1729,19 +1729,17 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
8196 + * specific mapper. the address has already been validated, but
8197 + * not unmapped, but the maps are removed from the list.
8198 + */
8199 +- vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
8200 ++ vma = vm_area_alloc(mm);
8201 + if (!vma) {
8202 + error = -ENOMEM;
8203 + goto unacct_error;
8204 + }
8205 +
8206 +- vma->vm_mm = mm;
8207 + vma->vm_start = addr;
8208 + vma->vm_end = addr + len;
8209 + vma->vm_flags = vm_flags;
8210 + vma->vm_page_prot = vm_get_page_prot(vm_flags);
8211 + vma->vm_pgoff = pgoff;
8212 +- INIT_LIST_HEAD(&vma->anon_vma_chain);
8213 +
8214 + if (file) {
8215 + if (vm_flags & VM_DENYWRITE) {
8216 +@@ -1832,7 +1830,7 @@ allow_write_and_free_vma:
8217 + if (vm_flags & VM_DENYWRITE)
8218 + allow_write_access(file);
8219 + free_vma:
8220 +- kmem_cache_free(vm_area_cachep, vma);
8221 ++ vm_area_free(vma);
8222 + unacct_error:
8223 + if (charged)
8224 + vm_unacct_memory(charged);
8225 +@@ -2620,15 +2618,10 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
8226 + return err;
8227 + }
8228 +
8229 +- new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
8230 ++ new = vm_area_dup(vma);
8231 + if (!new)
8232 + return -ENOMEM;
8233 +
8234 +- /* most fields are the same, copy all, and then fixup */
8235 +- *new = *vma;
8236 +-
8237 +- INIT_LIST_HEAD(&new->anon_vma_chain);
8238 +-
8239 + if (new_below)
8240 + new->vm_end = addr;
8241 + else {
8242 +@@ -2669,7 +2662,7 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
8243 + out_free_mpol:
8244 + mpol_put(vma_policy(new));
8245 + out_free_vma:
8246 +- kmem_cache_free(vm_area_cachep, new);
8247 ++ vm_area_free(new);
8248 + return err;
8249 + }
8250 +
8251 +@@ -2984,14 +2977,12 @@ static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long fla
8252 + /*
8253 + * create a vma struct for an anonymous mapping
8254 + */
8255 +- vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
8256 ++ vma = vm_area_alloc(mm);
8257 + if (!vma) {
8258 + vm_unacct_memory(len >> PAGE_SHIFT);
8259 + return -ENOMEM;
8260 + }
8261 +
8262 +- INIT_LIST_HEAD(&vma->anon_vma_chain);
8263 +- vma->vm_mm = mm;
8264 + vma->vm_start = addr;
8265 + vma->vm_end = addr + len;
8266 + vma->vm_pgoff = pgoff;
8267 +@@ -3202,16 +3193,14 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
8268 + }
8269 + *need_rmap_locks = (new_vma->vm_pgoff <= vma->vm_pgoff);
8270 + } else {
8271 +- new_vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
8272 ++ new_vma = vm_area_dup(vma);
8273 + if (!new_vma)
8274 + goto out;
8275 +- *new_vma = *vma;
8276 + new_vma->vm_start = addr;
8277 + new_vma->vm_end = addr + len;
8278 + new_vma->vm_pgoff = pgoff;
8279 + if (vma_dup_policy(vma, new_vma))
8280 + goto out_free_vma;
8281 +- INIT_LIST_HEAD(&new_vma->anon_vma_chain);
8282 + if (anon_vma_clone(new_vma, vma))
8283 + goto out_free_mempol;
8284 + if (new_vma->vm_file)
8285 +@@ -3226,7 +3215,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
8286 + out_free_mempol:
8287 + mpol_put(vma_policy(new_vma));
8288 + out_free_vma:
8289 +- kmem_cache_free(vm_area_cachep, new_vma);
8290 ++ vm_area_free(new_vma);
8291 + out:
8292 + return NULL;
8293 + }
8294 +@@ -3350,12 +3339,10 @@ static struct vm_area_struct *__install_special_mapping(
8295 + int ret;
8296 + struct vm_area_struct *vma;
8297 +
8298 +- vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
8299 ++ vma = vm_area_alloc(mm);
8300 + if (unlikely(vma == NULL))
8301 + return ERR_PTR(-ENOMEM);
8302 +
8303 +- INIT_LIST_HEAD(&vma->anon_vma_chain);
8304 +- vma->vm_mm = mm;
8305 + vma->vm_start = addr;
8306 + vma->vm_end = addr + len;
8307 +
8308 +@@ -3376,7 +3363,7 @@ static struct vm_area_struct *__install_special_mapping(
8309 + return vma;
8310 +
8311 + out:
8312 +- kmem_cache_free(vm_area_cachep, vma);
8313 ++ vm_area_free(vma);
8314 + return ERR_PTR(ret);
8315 + }
8316 +
8317 +diff --git a/mm/nommu.c b/mm/nommu.c
8318 +index 13723736d38f..b7a2aa7f7c0f 100644
8319 +--- a/mm/nommu.c
8320 ++++ b/mm/nommu.c
8321 +@@ -769,7 +769,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)
8322 + if (vma->vm_file)
8323 + fput(vma->vm_file);
8324 + put_nommu_region(vma->vm_region);
8325 +- kmem_cache_free(vm_area_cachep, vma);
8326 ++ vm_area_free(vma);
8327 + }
8328 +
8329 + /*
8330 +@@ -1204,7 +1204,7 @@ unsigned long do_mmap(struct file *file,
8331 + if (!region)
8332 + goto error_getting_region;
8333 +
8334 +- vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
8335 ++ vma = vm_area_alloc(current->mm);
8336 + if (!vma)
8337 + goto error_getting_vma;
8338 +
8339 +@@ -1212,7 +1212,6 @@ unsigned long do_mmap(struct file *file,
8340 + region->vm_flags = vm_flags;
8341 + region->vm_pgoff = pgoff;
8342 +
8343 +- INIT_LIST_HEAD(&vma->anon_vma_chain);
8344 + vma->vm_flags = vm_flags;
8345 + vma->vm_pgoff = pgoff;
8346 +
8347 +@@ -1368,7 +1367,7 @@ error:
8348 + kmem_cache_free(vm_region_jar, region);
8349 + if (vma->vm_file)
8350 + fput(vma->vm_file);
8351 +- kmem_cache_free(vm_area_cachep, vma);
8352 ++ vm_area_free(vma);
8353 + return ret;
8354 +
8355 + sharing_violation:
8356 +@@ -1469,14 +1468,13 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
8357 + if (!region)
8358 + return -ENOMEM;
8359 +
8360 +- new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
8361 ++ new = vm_area_dup(vma);
8362 + if (!new) {
8363 + kmem_cache_free(vm_region_jar, region);
8364 + return -ENOMEM;
8365 + }
8366 +
8367 + /* most fields are the same, copy all, and then fixup */
8368 +- *new = *vma;
8369 + *region = *vma->vm_region;
8370 + new->vm_region = region;
8371 +
8372 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
8373 +index 7b841a764dd0..e27bc10467c4 100644
8374 +--- a/mm/page_alloc.c
8375 ++++ b/mm/page_alloc.c
8376 +@@ -6933,9 +6933,21 @@ unsigned long free_reserved_area(void *start, void *end, int poison, char *s)
8377 + start = (void *)PAGE_ALIGN((unsigned long)start);
8378 + end = (void *)((unsigned long)end & PAGE_MASK);
8379 + for (pos = start; pos < end; pos += PAGE_SIZE, pages++) {
8380 ++ struct page *page = virt_to_page(pos);
8381 ++ void *direct_map_addr;
8382 ++
8383 ++ /*
8384 ++ * 'direct_map_addr' might be different from 'pos'
8385 ++ * because some architectures' virt_to_page()
8386 ++ * work with aliases. Getting the direct map
8387 ++ * address ensures that we get a _writeable_
8388 ++ * alias for the memset().
8389 ++ */
8390 ++ direct_map_addr = page_address(page);
8391 + if ((unsigned int)poison <= 0xFF)
8392 +- memset(pos, poison, PAGE_SIZE);
8393 +- free_reserved_page(virt_to_page(pos));
8394 ++ memset(direct_map_addr, poison, PAGE_SIZE);
8395 ++
8396 ++ free_reserved_page(page);
8397 + }
8398 +
8399 + if (pages && s)
8400 +diff --git a/net/9p/client.c b/net/9p/client.c
8401 +index 21e6df1cc70f..0ad6993aaa9b 100644
8402 +--- a/net/9p/client.c
8403 ++++ b/net/9p/client.c
8404 +@@ -228,7 +228,8 @@ static int parse_opts(char *opts, struct p9_client *clnt)
8405 + }
8406 +
8407 + free_and_return:
8408 +- v9fs_put_trans(clnt->trans_mod);
8409 ++ if (ret)
8410 ++ v9fs_put_trans(clnt->trans_mod);
8411 + kfree(tmp_options);
8412 + return ret;
8413 + }
8414 +diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
8415 +index be09a9883825..73bf6a93a3cf 100644
8416 +--- a/net/batman-adv/bat_iv_ogm.c
8417 ++++ b/net/batman-adv/bat_iv_ogm.c
8418 +@@ -2732,7 +2732,7 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
8419 + {
8420 + struct batadv_neigh_ifinfo *router_ifinfo = NULL;
8421 + struct batadv_neigh_node *router;
8422 +- struct batadv_gw_node *curr_gw;
8423 ++ struct batadv_gw_node *curr_gw = NULL;
8424 + int ret = 0;
8425 + void *hdr;
8426 +
8427 +@@ -2780,6 +2780,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
8428 + ret = 0;
8429 +
8430 + out:
8431 ++ if (curr_gw)
8432 ++ batadv_gw_node_put(curr_gw);
8433 + if (router_ifinfo)
8434 + batadv_neigh_ifinfo_put(router_ifinfo);
8435 + if (router)
8436 +diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
8437 +index ec93337ee259..6baec4e68898 100644
8438 +--- a/net/batman-adv/bat_v.c
8439 ++++ b/net/batman-adv/bat_v.c
8440 +@@ -927,7 +927,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
8441 + {
8442 + struct batadv_neigh_ifinfo *router_ifinfo = NULL;
8443 + struct batadv_neigh_node *router;
8444 +- struct batadv_gw_node *curr_gw;
8445 ++ struct batadv_gw_node *curr_gw = NULL;
8446 + int ret = 0;
8447 + void *hdr;
8448 +
8449 +@@ -995,6 +995,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
8450 + ret = 0;
8451 +
8452 + out:
8453 ++ if (curr_gw)
8454 ++ batadv_gw_node_put(curr_gw);
8455 + if (router_ifinfo)
8456 + batadv_neigh_ifinfo_put(router_ifinfo);
8457 + if (router)
8458 +diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c
8459 +index 4229b01ac7b5..87479c60670e 100644
8460 +--- a/net/batman-adv/debugfs.c
8461 ++++ b/net/batman-adv/debugfs.c
8462 +@@ -19,6 +19,7 @@
8463 + #include "debugfs.h"
8464 + #include "main.h"
8465 +
8466 ++#include <linux/dcache.h>
8467 + #include <linux/debugfs.h>
8468 + #include <linux/err.h>
8469 + #include <linux/errno.h>
8470 +@@ -343,6 +344,25 @@ out:
8471 + return -ENOMEM;
8472 + }
8473 +
8474 ++/**
8475 ++ * batadv_debugfs_rename_hardif() - Fix debugfs path for renamed hardif
8476 ++ * @hard_iface: hard interface which was renamed
8477 ++ */
8478 ++void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface)
8479 ++{
8480 ++ const char *name = hard_iface->net_dev->name;
8481 ++ struct dentry *dir;
8482 ++ struct dentry *d;
8483 ++
8484 ++ dir = hard_iface->debug_dir;
8485 ++ if (!dir)
8486 ++ return;
8487 ++
8488 ++ d = debugfs_rename(dir->d_parent, dir, dir->d_parent, name);
8489 ++ if (!d)
8490 ++ pr_err("Can't rename debugfs dir to %s\n", name);
8491 ++}
8492 ++
8493 + /**
8494 + * batadv_debugfs_del_hardif() - delete the base directory for a hard interface
8495 + * in debugfs.
8496 +@@ -413,6 +433,26 @@ out:
8497 + return -ENOMEM;
8498 + }
8499 +
8500 ++/**
8501 ++ * batadv_debugfs_rename_meshif() - Fix debugfs path for renamed softif
8502 ++ * @dev: net_device which was renamed
8503 ++ */
8504 ++void batadv_debugfs_rename_meshif(struct net_device *dev)
8505 ++{
8506 ++ struct batadv_priv *bat_priv = netdev_priv(dev);
8507 ++ const char *name = dev->name;
8508 ++ struct dentry *dir;
8509 ++ struct dentry *d;
8510 ++
8511 ++ dir = bat_priv->debug_dir;
8512 ++ if (!dir)
8513 ++ return;
8514 ++
8515 ++ d = debugfs_rename(dir->d_parent, dir, dir->d_parent, name);
8516 ++ if (!d)
8517 ++ pr_err("Can't rename debugfs dir to %s\n", name);
8518 ++}
8519 ++
8520 + /**
8521 + * batadv_debugfs_del_meshif() - Remove interface dependent debugfs entries
8522 + * @dev: netdev struct of the soft interface
8523 +diff --git a/net/batman-adv/debugfs.h b/net/batman-adv/debugfs.h
8524 +index 37b069698b04..08a592ffbee5 100644
8525 +--- a/net/batman-adv/debugfs.h
8526 ++++ b/net/batman-adv/debugfs.h
8527 +@@ -30,8 +30,10 @@ struct net_device;
8528 + void batadv_debugfs_init(void);
8529 + void batadv_debugfs_destroy(void);
8530 + int batadv_debugfs_add_meshif(struct net_device *dev);
8531 ++void batadv_debugfs_rename_meshif(struct net_device *dev);
8532 + void batadv_debugfs_del_meshif(struct net_device *dev);
8533 + int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface);
8534 ++void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface);
8535 + void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface);
8536 +
8537 + #else
8538 +@@ -49,6 +51,10 @@ static inline int batadv_debugfs_add_meshif(struct net_device *dev)
8539 + return 0;
8540 + }
8541 +
8542 ++static inline void batadv_debugfs_rename_meshif(struct net_device *dev)
8543 ++{
8544 ++}
8545 ++
8546 + static inline void batadv_debugfs_del_meshif(struct net_device *dev)
8547 + {
8548 + }
8549 +@@ -59,6 +65,11 @@ int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface)
8550 + return 0;
8551 + }
8552 +
8553 ++static inline
8554 ++void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface)
8555 ++{
8556 ++}
8557 ++
8558 + static inline
8559 + void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface)
8560 + {
8561 +diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
8562 +index c405d15befd6..2f0d42f2f913 100644
8563 +--- a/net/batman-adv/hard-interface.c
8564 ++++ b/net/batman-adv/hard-interface.c
8565 +@@ -989,6 +989,32 @@ void batadv_hardif_remove_interfaces(void)
8566 + rtnl_unlock();
8567 + }
8568 +
8569 ++/**
8570 ++ * batadv_hard_if_event_softif() - Handle events for soft interfaces
8571 ++ * @event: NETDEV_* event to handle
8572 ++ * @net_dev: net_device which generated an event
8573 ++ *
8574 ++ * Return: NOTIFY_* result
8575 ++ */
8576 ++static int batadv_hard_if_event_softif(unsigned long event,
8577 ++ struct net_device *net_dev)
8578 ++{
8579 ++ struct batadv_priv *bat_priv;
8580 ++
8581 ++ switch (event) {
8582 ++ case NETDEV_REGISTER:
8583 ++ batadv_sysfs_add_meshif(net_dev);
8584 ++ bat_priv = netdev_priv(net_dev);
8585 ++ batadv_softif_create_vlan(bat_priv, BATADV_NO_FLAGS);
8586 ++ break;
8587 ++ case NETDEV_CHANGENAME:
8588 ++ batadv_debugfs_rename_meshif(net_dev);
8589 ++ break;
8590 ++ }
8591 ++
8592 ++ return NOTIFY_DONE;
8593 ++}
8594 ++
8595 + static int batadv_hard_if_event(struct notifier_block *this,
8596 + unsigned long event, void *ptr)
8597 + {
8598 +@@ -997,12 +1023,8 @@ static int batadv_hard_if_event(struct notifier_block *this,
8599 + struct batadv_hard_iface *primary_if = NULL;
8600 + struct batadv_priv *bat_priv;
8601 +
8602 +- if (batadv_softif_is_valid(net_dev) && event == NETDEV_REGISTER) {
8603 +- batadv_sysfs_add_meshif(net_dev);
8604 +- bat_priv = netdev_priv(net_dev);
8605 +- batadv_softif_create_vlan(bat_priv, BATADV_NO_FLAGS);
8606 +- return NOTIFY_DONE;
8607 +- }
8608 ++ if (batadv_softif_is_valid(net_dev))
8609 ++ return batadv_hard_if_event_softif(event, net_dev);
8610 +
8611 + hard_iface = batadv_hardif_get_by_netdev(net_dev);
8612 + if (!hard_iface && (event == NETDEV_REGISTER ||
8613 +@@ -1051,6 +1073,9 @@ static int batadv_hard_if_event(struct notifier_block *this,
8614 + if (batadv_is_wifi_hardif(hard_iface))
8615 + hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS;
8616 + break;
8617 ++ case NETDEV_CHANGENAME:
8618 ++ batadv_debugfs_rename_hardif(hard_iface);
8619 ++ break;
8620 + default:
8621 + break;
8622 + }
8623 +diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
8624 +index 3986551397ca..12a2b7d21376 100644
8625 +--- a/net/batman-adv/translation-table.c
8626 ++++ b/net/batman-adv/translation-table.c
8627 +@@ -1705,7 +1705,9 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
8628 + ether_addr_copy(common->addr, tt_addr);
8629 + common->vid = vid;
8630 +
8631 +- common->flags = flags;
8632 ++ if (!is_multicast_ether_addr(common->addr))
8633 ++ common->flags = flags & (~BATADV_TT_SYNC_MASK);
8634 ++
8635 + tt_global_entry->roam_at = 0;
8636 + /* node must store current time in case of roaming. This is
8637 + * needed to purge this entry out on timeout (if nobody claims
8638 +@@ -1768,7 +1770,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
8639 + * TT_CLIENT_TEMP, therefore they have to be copied in the
8640 + * client entry
8641 + */
8642 +- common->flags |= flags & (~BATADV_TT_SYNC_MASK);
8643 ++ if (!is_multicast_ether_addr(common->addr))
8644 ++ common->flags |= flags & (~BATADV_TT_SYNC_MASK);
8645 +
8646 + /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
8647 + * one originator left in the list and we previously received a
8648 +diff --git a/net/core/dev.c b/net/core/dev.c
8649 +index 1ccc2a2ac2e9..2d6b23e39833 100644
8650 +--- a/net/core/dev.c
8651 ++++ b/net/core/dev.c
8652 +@@ -8608,7 +8608,8 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
8653 + /* We get here if we can't use the current device name */
8654 + if (!pat)
8655 + goto out;
8656 +- if (dev_get_valid_name(net, dev, pat) < 0)
8657 ++ err = dev_get_valid_name(net, dev, pat);
8658 ++ if (err < 0)
8659 + goto out;
8660 + }
8661 +
8662 +@@ -8620,7 +8621,6 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
8663 + dev_close(dev);
8664 +
8665 + /* And unlink it from device chain */
8666 +- err = -ENODEV;
8667 + unlist_netdevice(dev);
8668 +
8669 + synchronize_net();
8670 +diff --git a/net/core/filter.c b/net/core/filter.c
8671 +index 201ff36b17a8..a491dbb0a955 100644
8672 +--- a/net/core/filter.c
8673 ++++ b/net/core/filter.c
8674 +@@ -2516,7 +2516,8 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 len_diff)
8675 +
8676 + static u32 __bpf_skb_max_len(const struct sk_buff *skb)
8677 + {
8678 +- return skb->dev->mtu + skb->dev->hard_header_len;
8679 ++ return skb->dev ? skb->dev->mtu + skb->dev->hard_header_len :
8680 ++ SKB_MAX_ALLOC;
8681 + }
8682 +
8683 + static int bpf_skb_adjust_net(struct sk_buff *skb, s32 len_diff)
8684 +diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
8685 +index 275449b0d633..3297e7fa9945 100644
8686 +--- a/net/ieee802154/6lowpan/core.c
8687 ++++ b/net/ieee802154/6lowpan/core.c
8688 +@@ -90,12 +90,18 @@ static int lowpan_neigh_construct(struct net_device *dev, struct neighbour *n)
8689 + return 0;
8690 + }
8691 +
8692 ++static int lowpan_get_iflink(const struct net_device *dev)
8693 ++{
8694 ++ return lowpan_802154_dev(dev)->wdev->ifindex;
8695 ++}
8696 ++
8697 + static const struct net_device_ops lowpan_netdev_ops = {
8698 + .ndo_init = lowpan_dev_init,
8699 + .ndo_start_xmit = lowpan_xmit,
8700 + .ndo_open = lowpan_open,
8701 + .ndo_stop = lowpan_stop,
8702 + .ndo_neigh_construct = lowpan_neigh_construct,
8703 ++ .ndo_get_iflink = lowpan_get_iflink,
8704 + };
8705 +
8706 + static void lowpan_setup(struct net_device *ldev)
8707 +diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
8708 +index eeb6646aa892..0d70608cc2e1 100644
8709 +--- a/net/ipv4/inet_fragment.c
8710 ++++ b/net/ipv4/inet_fragment.c
8711 +@@ -90,7 +90,7 @@ static void inet_frags_free_cb(void *ptr, void *arg)
8712 +
8713 + void inet_frags_exit_net(struct netns_frags *nf)
8714 + {
8715 +- nf->low_thresh = 0; /* prevent creation of new frags */
8716 ++ nf->high_thresh = 0; /* prevent creation of new frags */
8717 +
8718 + rhashtable_free_and_destroy(&nf->rhashtable, inet_frags_free_cb, NULL);
8719 + }
8720 +diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
8721 +index f6130704f052..1bf71e36f545 100644
8722 +--- a/net/ipv4/netfilter/ip_tables.c
8723 ++++ b/net/ipv4/netfilter/ip_tables.c
8724 +@@ -1895,6 +1895,7 @@ static struct xt_match ipt_builtin_mt[] __read_mostly = {
8725 + .checkentry = icmp_checkentry,
8726 + .proto = IPPROTO_ICMP,
8727 + .family = NFPROTO_IPV4,
8728 ++ .me = THIS_MODULE,
8729 + },
8730 + };
8731 +
8732 +diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
8733 +index 58e316cf6607..14c26a747e50 100644
8734 +--- a/net/ipv4/tcp.c
8735 ++++ b/net/ipv4/tcp.c
8736 +@@ -1845,7 +1845,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
8737 + * shouldn't happen.
8738 + */
8739 + if (WARN(before(*seq, TCP_SKB_CB(skb)->seq),
8740 +- "recvmsg bug: copied %X seq %X rcvnxt %X fl %X\n",
8741 ++ "TCP recvmsg seq # bug: copied %X, seq %X, rcvnxt %X, fl %X\n",
8742 + *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt,
8743 + flags))
8744 + break;
8745 +@@ -1860,7 +1860,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
8746 + if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
8747 + goto found_fin_ok;
8748 + WARN(!(flags & MSG_PEEK),
8749 +- "recvmsg bug 2: copied %X seq %X rcvnxt %X fl %X\n",
8750 ++ "TCP recvmsg seq # bug 2: copied %X, seq %X, rcvnxt %X, fl %X\n",
8751 + *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt, flags);
8752 + }
8753 +
8754 +diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
8755 +index 1a9b88c8cf72..8b637f9f23a2 100644
8756 +--- a/net/ipv4/tcp_dctcp.c
8757 ++++ b/net/ipv4/tcp_dctcp.c
8758 +@@ -55,7 +55,6 @@ struct dctcp {
8759 + u32 dctcp_alpha;
8760 + u32 next_seq;
8761 + u32 ce_state;
8762 +- u32 delayed_ack_reserved;
8763 + u32 loss_cwnd;
8764 + };
8765 +
8766 +@@ -96,7 +95,6 @@ static void dctcp_init(struct sock *sk)
8767 +
8768 + ca->dctcp_alpha = min(dctcp_alpha_on_init, DCTCP_MAX_ALPHA);
8769 +
8770 +- ca->delayed_ack_reserved = 0;
8771 + ca->loss_cwnd = 0;
8772 + ca->ce_state = 0;
8773 +
8774 +@@ -230,25 +228,6 @@ static void dctcp_state(struct sock *sk, u8 new_state)
8775 + }
8776 + }
8777 +
8778 +-static void dctcp_update_ack_reserved(struct sock *sk, enum tcp_ca_event ev)
8779 +-{
8780 +- struct dctcp *ca = inet_csk_ca(sk);
8781 +-
8782 +- switch (ev) {
8783 +- case CA_EVENT_DELAYED_ACK:
8784 +- if (!ca->delayed_ack_reserved)
8785 +- ca->delayed_ack_reserved = 1;
8786 +- break;
8787 +- case CA_EVENT_NON_DELAYED_ACK:
8788 +- if (ca->delayed_ack_reserved)
8789 +- ca->delayed_ack_reserved = 0;
8790 +- break;
8791 +- default:
8792 +- /* Don't care for the rest. */
8793 +- break;
8794 +- }
8795 +-}
8796 +-
8797 + static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
8798 + {
8799 + switch (ev) {
8800 +@@ -258,10 +237,6 @@ static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
8801 + case CA_EVENT_ECN_NO_CE:
8802 + dctcp_ce_state_1_to_0(sk);
8803 + break;
8804 +- case CA_EVENT_DELAYED_ACK:
8805 +- case CA_EVENT_NON_DELAYED_ACK:
8806 +- dctcp_update_ack_reserved(sk, ev);
8807 +- break;
8808 + default:
8809 + /* Don't care for the rest. */
8810 + break;
8811 +diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
8812 +index 3049d10a1476..5a689b07bad7 100644
8813 +--- a/net/ipv4/tcp_output.c
8814 ++++ b/net/ipv4/tcp_output.c
8815 +@@ -3545,8 +3545,6 @@ void tcp_send_delayed_ack(struct sock *sk)
8816 + int ato = icsk->icsk_ack.ato;
8817 + unsigned long timeout;
8818 +
8819 +- tcp_ca_event(sk, CA_EVENT_DELAYED_ACK);
8820 +-
8821 + if (ato > TCP_DELACK_MIN) {
8822 + const struct tcp_sock *tp = tcp_sk(sk);
8823 + int max_ato = HZ / 2;
8824 +@@ -3603,8 +3601,6 @@ void __tcp_send_ack(struct sock *sk, u32 rcv_nxt)
8825 + if (sk->sk_state == TCP_CLOSE)
8826 + return;
8827 +
8828 +- tcp_ca_event(sk, CA_EVENT_NON_DELAYED_ACK);
8829 +-
8830 + /* We are not putting this on the write queue, so
8831 + * tcp_transmit_skb() will set the ownership to this
8832 + * sock.
8833 +diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
8834 +index 1323b9679cf7..1c0bb9fb76e6 100644
8835 +--- a/net/ipv6/calipso.c
8836 ++++ b/net/ipv6/calipso.c
8837 +@@ -799,8 +799,7 @@ static int calipso_opt_update(struct sock *sk, struct ipv6_opt_hdr *hop)
8838 + {
8839 + struct ipv6_txoptions *old = txopt_get(inet6_sk(sk)), *txopts;
8840 +
8841 +- txopts = ipv6_renew_options_kern(sk, old, IPV6_HOPOPTS,
8842 +- hop, hop ? ipv6_optlen(hop) : 0);
8843 ++ txopts = ipv6_renew_options(sk, old, IPV6_HOPOPTS, hop);
8844 + txopt_put(old);
8845 + if (IS_ERR(txopts))
8846 + return PTR_ERR(txopts);
8847 +@@ -1222,8 +1221,7 @@ static int calipso_req_setattr(struct request_sock *req,
8848 + if (IS_ERR(new))
8849 + return PTR_ERR(new);
8850 +
8851 +- txopts = ipv6_renew_options_kern(sk, req_inet->ipv6_opt, IPV6_HOPOPTS,
8852 +- new, new ? ipv6_optlen(new) : 0);
8853 ++ txopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);
8854 +
8855 + kfree(new);
8856 +
8857 +@@ -1260,8 +1258,7 @@ static void calipso_req_delattr(struct request_sock *req)
8858 + if (calipso_opt_del(req_inet->ipv6_opt->hopopt, &new))
8859 + return; /* Nothing to do */
8860 +
8861 +- txopts = ipv6_renew_options_kern(sk, req_inet->ipv6_opt, IPV6_HOPOPTS,
8862 +- new, new ? ipv6_optlen(new) : 0);
8863 ++ txopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);
8864 +
8865 + if (!IS_ERR(txopts)) {
8866 + txopts = xchg(&req_inet->ipv6_opt, txopts);
8867 +diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
8868 +index bc68eb661970..07a4d4232231 100644
8869 +--- a/net/ipv6/exthdrs.c
8870 ++++ b/net/ipv6/exthdrs.c
8871 +@@ -1028,29 +1028,21 @@ ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt)
8872 + }
8873 + EXPORT_SYMBOL_GPL(ipv6_dup_options);
8874 +
8875 +-static int ipv6_renew_option(void *ohdr,
8876 +- struct ipv6_opt_hdr __user *newopt, int newoptlen,
8877 +- int inherit,
8878 +- struct ipv6_opt_hdr **hdr,
8879 +- char **p)
8880 ++static void ipv6_renew_option(int renewtype,
8881 ++ struct ipv6_opt_hdr **dest,
8882 ++ struct ipv6_opt_hdr *old,
8883 ++ struct ipv6_opt_hdr *new,
8884 ++ int newtype, char **p)
8885 + {
8886 +- if (inherit) {
8887 +- if (ohdr) {
8888 +- memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr));
8889 +- *hdr = (struct ipv6_opt_hdr *)*p;
8890 +- *p += CMSG_ALIGN(ipv6_optlen(*hdr));
8891 +- }
8892 +- } else {
8893 +- if (newopt) {
8894 +- if (copy_from_user(*p, newopt, newoptlen))
8895 +- return -EFAULT;
8896 +- *hdr = (struct ipv6_opt_hdr *)*p;
8897 +- if (ipv6_optlen(*hdr) > newoptlen)
8898 +- return -EINVAL;
8899 +- *p += CMSG_ALIGN(newoptlen);
8900 +- }
8901 +- }
8902 +- return 0;
8903 ++ struct ipv6_opt_hdr *src;
8904 ++
8905 ++ src = (renewtype == newtype ? new : old);
8906 ++ if (!src)
8907 ++ return;
8908 ++
8909 ++ memcpy(*p, src, ipv6_optlen(src));
8910 ++ *dest = (struct ipv6_opt_hdr *)*p;
8911 ++ *p += CMSG_ALIGN(ipv6_optlen(*dest));
8912 + }
8913 +
8914 + /**
8915 +@@ -1076,13 +1068,11 @@ static int ipv6_renew_option(void *ohdr,
8916 + */
8917 + struct ipv6_txoptions *
8918 + ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
8919 +- int newtype,
8920 +- struct ipv6_opt_hdr __user *newopt, int newoptlen)
8921 ++ int newtype, struct ipv6_opt_hdr *newopt)
8922 + {
8923 + int tot_len = 0;
8924 + char *p;
8925 + struct ipv6_txoptions *opt2;
8926 +- int err;
8927 +
8928 + if (opt) {
8929 + if (newtype != IPV6_HOPOPTS && opt->hopopt)
8930 +@@ -1095,8 +1085,8 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
8931 + tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt));
8932 + }
8933 +
8934 +- if (newopt && newoptlen)
8935 +- tot_len += CMSG_ALIGN(newoptlen);
8936 ++ if (newopt)
8937 ++ tot_len += CMSG_ALIGN(ipv6_optlen(newopt));
8938 +
8939 + if (!tot_len)
8940 + return NULL;
8941 +@@ -1111,29 +1101,19 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
8942 + opt2->tot_len = tot_len;
8943 + p = (char *)(opt2 + 1);
8944 +
8945 +- err = ipv6_renew_option(opt ? opt->hopopt : NULL, newopt, newoptlen,
8946 +- newtype != IPV6_HOPOPTS,
8947 +- &opt2->hopopt, &p);
8948 +- if (err)
8949 +- goto out;
8950 +-
8951 +- err = ipv6_renew_option(opt ? opt->dst0opt : NULL, newopt, newoptlen,
8952 +- newtype != IPV6_RTHDRDSTOPTS,
8953 +- &opt2->dst0opt, &p);
8954 +- if (err)
8955 +- goto out;
8956 +-
8957 +- err = ipv6_renew_option(opt ? opt->srcrt : NULL, newopt, newoptlen,
8958 +- newtype != IPV6_RTHDR,
8959 +- (struct ipv6_opt_hdr **)&opt2->srcrt, &p);
8960 +- if (err)
8961 +- goto out;
8962 +-
8963 +- err = ipv6_renew_option(opt ? opt->dst1opt : NULL, newopt, newoptlen,
8964 +- newtype != IPV6_DSTOPTS,
8965 +- &opt2->dst1opt, &p);
8966 +- if (err)
8967 +- goto out;
8968 ++ ipv6_renew_option(IPV6_HOPOPTS, &opt2->hopopt,
8969 ++ (opt ? opt->hopopt : NULL),
8970 ++ newopt, newtype, &p);
8971 ++ ipv6_renew_option(IPV6_RTHDRDSTOPTS, &opt2->dst0opt,
8972 ++ (opt ? opt->dst0opt : NULL),
8973 ++ newopt, newtype, &p);
8974 ++ ipv6_renew_option(IPV6_RTHDR,
8975 ++ (struct ipv6_opt_hdr **)&opt2->srcrt,
8976 ++ (opt ? (struct ipv6_opt_hdr *)opt->srcrt : NULL),
8977 ++ newopt, newtype, &p);
8978 ++ ipv6_renew_option(IPV6_DSTOPTS, &opt2->dst1opt,
8979 ++ (opt ? opt->dst1opt : NULL),
8980 ++ newopt, newtype, &p);
8981 +
8982 + opt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) +
8983 + (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) +
8984 +@@ -1141,37 +1121,6 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
8985 + opt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0);
8986 +
8987 + return opt2;
8988 +-out:
8989 +- sock_kfree_s(sk, opt2, opt2->tot_len);
8990 +- return ERR_PTR(err);
8991 +-}
8992 +-
8993 +-/**
8994 +- * ipv6_renew_options_kern - replace a specific ext hdr with a new one.
8995 +- *
8996 +- * @sk: sock from which to allocate memory
8997 +- * @opt: original options
8998 +- * @newtype: option type to replace in @opt
8999 +- * @newopt: new option of type @newtype to replace (kernel-mem)
9000 +- * @newoptlen: length of @newopt
9001 +- *
9002 +- * See ipv6_renew_options(). The difference is that @newopt is
9003 +- * kernel memory, rather than user memory.
9004 +- */
9005 +-struct ipv6_txoptions *
9006 +-ipv6_renew_options_kern(struct sock *sk, struct ipv6_txoptions *opt,
9007 +- int newtype, struct ipv6_opt_hdr *newopt,
9008 +- int newoptlen)
9009 +-{
9010 +- struct ipv6_txoptions *ret_val;
9011 +- const mm_segment_t old_fs = get_fs();
9012 +-
9013 +- set_fs(KERNEL_DS);
9014 +- ret_val = ipv6_renew_options(sk, opt, newtype,
9015 +- (struct ipv6_opt_hdr __user *)newopt,
9016 +- newoptlen);
9017 +- set_fs(old_fs);
9018 +- return ret_val;
9019 + }
9020 +
9021 + struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
9022 +diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
9023 +index 4d780c7f0130..c95c3486d904 100644
9024 +--- a/net/ipv6/ipv6_sockglue.c
9025 ++++ b/net/ipv6/ipv6_sockglue.c
9026 +@@ -398,6 +398,12 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
9027 + case IPV6_DSTOPTS:
9028 + {
9029 + struct ipv6_txoptions *opt;
9030 ++ struct ipv6_opt_hdr *new = NULL;
9031 ++
9032 ++ /* hop-by-hop / destination options are privileged option */
9033 ++ retv = -EPERM;
9034 ++ if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW))
9035 ++ break;
9036 +
9037 + /* remove any sticky options header with a zero option
9038 + * length, per RFC3542.
9039 +@@ -409,17 +415,22 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
9040 + else if (optlen < sizeof(struct ipv6_opt_hdr) ||
9041 + optlen & 0x7 || optlen > 8 * 255)
9042 + goto e_inval;
9043 +-
9044 +- /* hop-by-hop / destination options are privileged option */
9045 +- retv = -EPERM;
9046 +- if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW))
9047 +- break;
9048 ++ else {
9049 ++ new = memdup_user(optval, optlen);
9050 ++ if (IS_ERR(new)) {
9051 ++ retv = PTR_ERR(new);
9052 ++ break;
9053 ++ }
9054 ++ if (unlikely(ipv6_optlen(new) > optlen)) {
9055 ++ kfree(new);
9056 ++ goto e_inval;
9057 ++ }
9058 ++ }
9059 +
9060 + opt = rcu_dereference_protected(np->opt,
9061 + lockdep_sock_is_held(sk));
9062 +- opt = ipv6_renew_options(sk, opt, optname,
9063 +- (struct ipv6_opt_hdr __user *)optval,
9064 +- optlen);
9065 ++ opt = ipv6_renew_options(sk, opt, optname, new);
9066 ++ kfree(new);
9067 + if (IS_ERR(opt)) {
9068 + retv = PTR_ERR(opt);
9069 + break;
9070 +diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
9071 +index 0604a737eecf..a23cfd922509 100644
9072 +--- a/net/ipv6/mcast.c
9073 ++++ b/net/ipv6/mcast.c
9074 +@@ -2081,7 +2081,8 @@ void ipv6_mc_dad_complete(struct inet6_dev *idev)
9075 + mld_send_initial_cr(idev);
9076 + idev->mc_dad_count--;
9077 + if (idev->mc_dad_count)
9078 +- mld_dad_start_timer(idev, idev->mc_maxdelay);
9079 ++ mld_dad_start_timer(idev,
9080 ++ unsolicited_report_interval(idev));
9081 + }
9082 + }
9083 +
9084 +@@ -2093,7 +2094,8 @@ static void mld_dad_timer_expire(struct timer_list *t)
9085 + if (idev->mc_dad_count) {
9086 + idev->mc_dad_count--;
9087 + if (idev->mc_dad_count)
9088 +- mld_dad_start_timer(idev, idev->mc_maxdelay);
9089 ++ mld_dad_start_timer(idev,
9090 ++ unsolicited_report_interval(idev));
9091 + }
9092 + in6_dev_put(idev);
9093 + }
9094 +@@ -2451,7 +2453,8 @@ static void mld_ifc_timer_expire(struct timer_list *t)
9095 + if (idev->mc_ifc_count) {
9096 + idev->mc_ifc_count--;
9097 + if (idev->mc_ifc_count)
9098 +- mld_ifc_start_timer(idev, idev->mc_maxdelay);
9099 ++ mld_ifc_start_timer(idev,
9100 ++ unsolicited_report_interval(idev));
9101 + }
9102 + in6_dev_put(idev);
9103 + }
9104 +diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
9105 +index 685c2168f524..1e518cedffea 100644
9106 +--- a/net/ipv6/netfilter/ip6_tables.c
9107 ++++ b/net/ipv6/netfilter/ip6_tables.c
9108 +@@ -1907,6 +1907,7 @@ static struct xt_match ip6t_builtin_mt[] __read_mostly = {
9109 + .checkentry = icmp6_checkentry,
9110 + .proto = IPPROTO_ICMPV6,
9111 + .family = NFPROTO_IPV6,
9112 ++ .me = THIS_MODULE,
9113 + },
9114 + };
9115 +
9116 +diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
9117 +index eeb4d3098ff4..e4d9e6976d3c 100644
9118 +--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
9119 ++++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
9120 +@@ -107,7 +107,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
9121 + if (hdr == NULL)
9122 + goto err_reg;
9123 +
9124 +- net->nf_frag.sysctl.frags_hdr = hdr;
9125 ++ net->nf_frag_frags_hdr = hdr;
9126 + return 0;
9127 +
9128 + err_reg:
9129 +@@ -121,8 +121,8 @@ static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)
9130 + {
9131 + struct ctl_table *table;
9132 +
9133 +- table = net->nf_frag.sysctl.frags_hdr->ctl_table_arg;
9134 +- unregister_net_sysctl_table(net->nf_frag.sysctl.frags_hdr);
9135 ++ table = net->nf_frag_frags_hdr->ctl_table_arg;
9136 ++ unregister_net_sysctl_table(net->nf_frag_frags_hdr);
9137 + if (!net_eq(net, &init_net))
9138 + kfree(table);
9139 + }
9140 +diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
9141 +index 05a265cd573d..7404a5114597 100644
9142 +--- a/net/mac80211/tx.c
9143 ++++ b/net/mac80211/tx.c
9144 +@@ -4800,7 +4800,9 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,
9145 + skb_reset_network_header(skb);
9146 + skb_reset_mac_header(skb);
9147 +
9148 ++ local_bh_disable();
9149 + __ieee80211_subif_start_xmit(skb, skb->dev, flags);
9150 ++ local_bh_enable();
9151 +
9152 + return 0;
9153 + }
9154 +diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
9155 +index 41ff04ee2554..6b2fa4870237 100644
9156 +--- a/net/netfilter/nf_conntrack_core.c
9157 ++++ b/net/netfilter/nf_conntrack_core.c
9158 +@@ -1972,7 +1972,7 @@ int nf_conntrack_set_hashsize(const char *val, const struct kernel_param *kp)
9159 + return -EOPNOTSUPP;
9160 +
9161 + /* On boot, we can set this without any fancy locking. */
9162 +- if (!nf_conntrack_htable_size)
9163 ++ if (!nf_conntrack_hash)
9164 + return param_set_uint(val, kp);
9165 +
9166 + rc = kstrtouint(val, 0, &hashsize);
9167 +diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
9168 +index 551a1eddf0fa..a75b11c39312 100644
9169 +--- a/net/netfilter/nf_conntrack_helper.c
9170 ++++ b/net/netfilter/nf_conntrack_helper.c
9171 +@@ -465,6 +465,11 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)
9172 +
9173 + nf_ct_expect_iterate_destroy(expect_iter_me, NULL);
9174 + nf_ct_iterate_destroy(unhelp, me);
9175 ++
9176 ++ /* Maybe someone has gotten the helper already when unhelp above.
9177 ++ * So need to wait it.
9178 ++ */
9179 ++ synchronize_rcu();
9180 + }
9181 + EXPORT_SYMBOL_GPL(nf_conntrack_helper_unregister);
9182 +
9183 +diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
9184 +index abe647d5b8c6..9ce6336d1e55 100644
9185 +--- a/net/netfilter/nf_conntrack_proto_dccp.c
9186 ++++ b/net/netfilter/nf_conntrack_proto_dccp.c
9187 +@@ -243,14 +243,14 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][DCCP_PKT_SYNCACK + 1][CT_DCCP_MAX + 1] =
9188 + * We currently ignore Sync packets
9189 + *
9190 + * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
9191 +- sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
9192 ++ sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
9193 + },
9194 + [DCCP_PKT_SYNCACK] = {
9195 + /*
9196 + * We currently ignore SyncAck packets
9197 + *
9198 + * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
9199 +- sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
9200 ++ sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
9201 + },
9202 + },
9203 + [CT_DCCP_ROLE_SERVER] = {
9204 +@@ -371,14 +371,14 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][DCCP_PKT_SYNCACK + 1][CT_DCCP_MAX + 1] =
9205 + * We currently ignore Sync packets
9206 + *
9207 + * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
9208 +- sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
9209 ++ sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
9210 + },
9211 + [DCCP_PKT_SYNCACK] = {
9212 + /*
9213 + * We currently ignore SyncAck packets
9214 + *
9215 + * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
9216 +- sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
9217 ++ sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
9218 + },
9219 + },
9220 + };
9221 +diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
9222 +index a82dfb8f8790..d60589747afb 100644
9223 +--- a/net/netfilter/nf_log.c
9224 ++++ b/net/netfilter/nf_log.c
9225 +@@ -439,6 +439,10 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
9226 + if (write) {
9227 + struct ctl_table tmp = *table;
9228 +
9229 ++ /* proc_dostring() can append to existing strings, so we need to
9230 ++ * initialize it as an empty string.
9231 ++ */
9232 ++ buf[0] = '\0';
9233 + tmp.data = buf;
9234 + r = proc_dostring(&tmp, write, buffer, lenp, ppos);
9235 + if (r)
9236 +diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
9237 +index 1d99a1efdafc..0210b40a529a 100644
9238 +--- a/net/netfilter/nft_compat.c
9239 ++++ b/net/netfilter/nft_compat.c
9240 +@@ -825,10 +825,18 @@ nft_target_select_ops(const struct nft_ctx *ctx,
9241 + rev = ntohl(nla_get_be32(tb[NFTA_TARGET_REV]));
9242 + family = ctx->family;
9243 +
9244 ++ if (strcmp(tg_name, XT_ERROR_TARGET) == 0 ||
9245 ++ strcmp(tg_name, XT_STANDARD_TARGET) == 0 ||
9246 ++ strcmp(tg_name, "standard") == 0)
9247 ++ return ERR_PTR(-EINVAL);
9248 ++
9249 + /* Re-use the existing target if it's already loaded. */
9250 + list_for_each_entry(nft_target, &nft_target_list, head) {
9251 + struct xt_target *target = nft_target->ops.data;
9252 +
9253 ++ if (!target->target)
9254 ++ continue;
9255 ++
9256 + if (nft_target_cmp(target, tg_name, rev, family))
9257 + return &nft_target->ops;
9258 + }
9259 +@@ -837,6 +845,11 @@ nft_target_select_ops(const struct nft_ctx *ctx,
9260 + if (IS_ERR(target))
9261 + return ERR_PTR(-ENOENT);
9262 +
9263 ++ if (!target->target) {
9264 ++ err = -EINVAL;
9265 ++ goto err;
9266 ++ }
9267 ++
9268 + if (target->targetsize > nla_len(tb[NFTA_TARGET_INFO])) {
9269 + err = -EINVAL;
9270 + goto err;
9271 +diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
9272 +index cb0f02785749..af663a27c191 100644
9273 +--- a/net/packet/af_packet.c
9274 ++++ b/net/packet/af_packet.c
9275 +@@ -2910,6 +2910,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
9276 + goto out_free;
9277 + } else if (reserve) {
9278 + skb_reserve(skb, -reserve);
9279 ++ if (len < reserve)
9280 ++ skb_reset_network_header(skb);
9281 + }
9282 +
9283 + /* Returns -EFAULT on error */
9284 +@@ -4256,6 +4258,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
9285 + }
9286 +
9287 + if (req->tp_block_nr) {
9288 ++ unsigned int min_frame_size;
9289 ++
9290 + /* Sanity tests and some calculations */
9291 + err = -EBUSY;
9292 + if (unlikely(rb->pg_vec))
9293 +@@ -4278,12 +4282,12 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
9294 + goto out;
9295 + if (unlikely(!PAGE_ALIGNED(req->tp_block_size)))
9296 + goto out;
9297 ++ min_frame_size = po->tp_hdrlen + po->tp_reserve;
9298 + if (po->tp_version >= TPACKET_V3 &&
9299 +- req->tp_block_size <=
9300 +- BLK_PLUS_PRIV((u64)req_u->req3.tp_sizeof_priv) + sizeof(struct tpacket3_hdr))
9301 ++ req->tp_block_size <
9302 ++ BLK_PLUS_PRIV((u64)req_u->req3.tp_sizeof_priv) + min_frame_size)
9303 + goto out;
9304 +- if (unlikely(req->tp_frame_size < po->tp_hdrlen +
9305 +- po->tp_reserve))
9306 ++ if (unlikely(req->tp_frame_size < min_frame_size))
9307 + goto out;
9308 + if (unlikely(req->tp_frame_size & (TPACKET_ALIGNMENT - 1)))
9309 + goto out;
9310 +diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
9311 +index 2aa07b547b16..86e1e37eb4e8 100644
9312 +--- a/net/qrtr/qrtr.c
9313 ++++ b/net/qrtr/qrtr.c
9314 +@@ -191,8 +191,13 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb,
9315 + hdr->type = cpu_to_le32(type);
9316 + hdr->src_node_id = cpu_to_le32(from->sq_node);
9317 + hdr->src_port_id = cpu_to_le32(from->sq_port);
9318 +- hdr->dst_node_id = cpu_to_le32(to->sq_node);
9319 +- hdr->dst_port_id = cpu_to_le32(to->sq_port);
9320 ++ if (to->sq_port == QRTR_PORT_CTRL) {
9321 ++ hdr->dst_node_id = cpu_to_le32(node->nid);
9322 ++ hdr->dst_port_id = cpu_to_le32(QRTR_NODE_BCAST);
9323 ++ } else {
9324 ++ hdr->dst_node_id = cpu_to_le32(to->sq_node);
9325 ++ hdr->dst_port_id = cpu_to_le32(to->sq_port);
9326 ++ }
9327 +
9328 + hdr->size = cpu_to_le32(len);
9329 + hdr->confirm_rx = 0;
9330 +@@ -764,6 +769,10 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
9331 + node = NULL;
9332 + if (addr->sq_node == QRTR_NODE_BCAST) {
9333 + enqueue_fn = qrtr_bcast_enqueue;
9334 ++ if (addr->sq_port != QRTR_PORT_CTRL) {
9335 ++ release_sock(sk);
9336 ++ return -ENOTCONN;
9337 ++ }
9338 + } else if (addr->sq_node == ipc->us.sq_node) {
9339 + enqueue_fn = qrtr_local_enqueue;
9340 + } else {
9341 +diff --git a/net/rds/connection.c b/net/rds/connection.c
9342 +index abef75da89a7..cfb05953b0e5 100644
9343 +--- a/net/rds/connection.c
9344 ++++ b/net/rds/connection.c
9345 +@@ -659,11 +659,19 @@ static void rds_conn_info(struct socket *sock, unsigned int len,
9346 +
9347 + int rds_conn_init(void)
9348 + {
9349 ++ int ret;
9350 ++
9351 ++ ret = rds_loop_net_init(); /* register pernet callback */
9352 ++ if (ret)
9353 ++ return ret;
9354 ++
9355 + rds_conn_slab = kmem_cache_create("rds_connection",
9356 + sizeof(struct rds_connection),
9357 + 0, 0, NULL);
9358 +- if (!rds_conn_slab)
9359 ++ if (!rds_conn_slab) {
9360 ++ rds_loop_net_exit();
9361 + return -ENOMEM;
9362 ++ }
9363 +
9364 + rds_info_register_func(RDS_INFO_CONNECTIONS, rds_conn_info);
9365 + rds_info_register_func(RDS_INFO_SEND_MESSAGES,
9366 +@@ -676,6 +684,7 @@ int rds_conn_init(void)
9367 +
9368 + void rds_conn_exit(void)
9369 + {
9370 ++ rds_loop_net_exit(); /* unregister pernet callback */
9371 + rds_loop_exit();
9372 +
9373 + WARN_ON(!hlist_empty(rds_conn_hash));
9374 +diff --git a/net/rds/loop.c b/net/rds/loop.c
9375 +index dac6218a460e..feea1f96ee2a 100644
9376 +--- a/net/rds/loop.c
9377 ++++ b/net/rds/loop.c
9378 +@@ -33,6 +33,8 @@
9379 + #include <linux/kernel.h>
9380 + #include <linux/slab.h>
9381 + #include <linux/in.h>
9382 ++#include <net/net_namespace.h>
9383 ++#include <net/netns/generic.h>
9384 +
9385 + #include "rds_single_path.h"
9386 + #include "rds.h"
9387 +@@ -40,6 +42,17 @@
9388 +
9389 + static DEFINE_SPINLOCK(loop_conns_lock);
9390 + static LIST_HEAD(loop_conns);
9391 ++static atomic_t rds_loop_unloading = ATOMIC_INIT(0);
9392 ++
9393 ++static void rds_loop_set_unloading(void)
9394 ++{
9395 ++ atomic_set(&rds_loop_unloading, 1);
9396 ++}
9397 ++
9398 ++static bool rds_loop_is_unloading(struct rds_connection *conn)
9399 ++{
9400 ++ return atomic_read(&rds_loop_unloading) != 0;
9401 ++}
9402 +
9403 + /*
9404 + * This 'loopback' transport is a special case for flows that originate
9405 +@@ -165,6 +178,8 @@ void rds_loop_exit(void)
9406 + struct rds_loop_connection *lc, *_lc;
9407 + LIST_HEAD(tmp_list);
9408 +
9409 ++ rds_loop_set_unloading();
9410 ++ synchronize_rcu();
9411 + /* avoid calling conn_destroy with irqs off */
9412 + spin_lock_irq(&loop_conns_lock);
9413 + list_splice(&loop_conns, &tmp_list);
9414 +@@ -177,6 +192,46 @@ void rds_loop_exit(void)
9415 + }
9416 + }
9417 +
9418 ++static void rds_loop_kill_conns(struct net *net)
9419 ++{
9420 ++ struct rds_loop_connection *lc, *_lc;
9421 ++ LIST_HEAD(tmp_list);
9422 ++
9423 ++ spin_lock_irq(&loop_conns_lock);
9424 ++ list_for_each_entry_safe(lc, _lc, &loop_conns, loop_node) {
9425 ++ struct net *c_net = read_pnet(&lc->conn->c_net);
9426 ++
9427 ++ if (net != c_net)
9428 ++ continue;
9429 ++ list_move_tail(&lc->loop_node, &tmp_list);
9430 ++ }
9431 ++ spin_unlock_irq(&loop_conns_lock);
9432 ++
9433 ++ list_for_each_entry_safe(lc, _lc, &tmp_list, loop_node) {
9434 ++ WARN_ON(lc->conn->c_passive);
9435 ++ rds_conn_destroy(lc->conn);
9436 ++ }
9437 ++}
9438 ++
9439 ++static void __net_exit rds_loop_exit_net(struct net *net)
9440 ++{
9441 ++ rds_loop_kill_conns(net);
9442 ++}
9443 ++
9444 ++static struct pernet_operations rds_loop_net_ops = {
9445 ++ .exit = rds_loop_exit_net,
9446 ++};
9447 ++
9448 ++int rds_loop_net_init(void)
9449 ++{
9450 ++ return register_pernet_device(&rds_loop_net_ops);
9451 ++}
9452 ++
9453 ++void rds_loop_net_exit(void)
9454 ++{
9455 ++ unregister_pernet_device(&rds_loop_net_ops);
9456 ++}
9457 ++
9458 + /*
9459 + * This is missing .xmit_* because loop doesn't go through generic
9460 + * rds_send_xmit() and doesn't call rds_recv_incoming(). .listen_stop and
9461 +@@ -194,4 +249,5 @@ struct rds_transport rds_loop_transport = {
9462 + .inc_free = rds_loop_inc_free,
9463 + .t_name = "loopback",
9464 + .t_type = RDS_TRANS_LOOP,
9465 ++ .t_unloading = rds_loop_is_unloading,
9466 + };
9467 +diff --git a/net/rds/loop.h b/net/rds/loop.h
9468 +index 469fa4b2da4f..bbc8cdd030df 100644
9469 +--- a/net/rds/loop.h
9470 ++++ b/net/rds/loop.h
9471 +@@ -5,6 +5,8 @@
9472 + /* loop.c */
9473 + extern struct rds_transport rds_loop_transport;
9474 +
9475 ++int rds_loop_net_init(void);
9476 ++void rds_loop_net_exit(void);
9477 + void rds_loop_exit(void);
9478 +
9479 + #endif
9480 +diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c
9481 +index 7e28b2ce1437..e65cc4d35cee 100644
9482 +--- a/net/sched/act_csum.c
9483 ++++ b/net/sched/act_csum.c
9484 +@@ -91,7 +91,7 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla,
9485 + }
9486 + params_old = rtnl_dereference(p->params);
9487 +
9488 +- params_new->action = parm->action;
9489 ++ p->tcf_action = parm->action;
9490 + params_new->update_flags = parm->update_flags;
9491 + rcu_assign_pointer(p->params, params_new);
9492 + if (params_old)
9493 +@@ -561,7 +561,7 @@ static int tcf_csum(struct sk_buff *skb, const struct tc_action *a,
9494 + tcf_lastuse_update(&p->tcf_tm);
9495 + bstats_cpu_update(this_cpu_ptr(p->common.cpu_bstats), skb);
9496 +
9497 +- action = params->action;
9498 ++ action = READ_ONCE(p->tcf_action);
9499 + if (unlikely(action == TC_ACT_SHOT))
9500 + goto drop_stats;
9501 +
9502 +@@ -599,11 +599,11 @@ static int tcf_csum_dump(struct sk_buff *skb, struct tc_action *a, int bind,
9503 + .index = p->tcf_index,
9504 + .refcnt = p->tcf_refcnt - ref,
9505 + .bindcnt = p->tcf_bindcnt - bind,
9506 ++ .action = p->tcf_action,
9507 + };
9508 + struct tcf_t t;
9509 +
9510 + params = rtnl_dereference(p->params);
9511 +- opt.action = params->action;
9512 + opt.update_flags = params->update_flags;
9513 +
9514 + if (nla_put(skb, TCA_CSUM_PARMS, sizeof(opt), &opt))
9515 +diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
9516 +index 626dac81a48a..9bc6c2ae98a5 100644
9517 +--- a/net/sched/act_tunnel_key.c
9518 ++++ b/net/sched/act_tunnel_key.c
9519 +@@ -36,7 +36,7 @@ static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
9520 +
9521 + tcf_lastuse_update(&t->tcf_tm);
9522 + bstats_cpu_update(this_cpu_ptr(t->common.cpu_bstats), skb);
9523 +- action = params->action;
9524 ++ action = READ_ONCE(t->tcf_action);
9525 +
9526 + switch (params->tcft_action) {
9527 + case TCA_TUNNEL_KEY_ACT_RELEASE:
9528 +@@ -182,7 +182,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
9529 +
9530 + params_old = rtnl_dereference(t->params);
9531 +
9532 +- params_new->action = parm->action;
9533 ++ t->tcf_action = parm->action;
9534 + params_new->tcft_action = parm->t_action;
9535 + params_new->tcft_enc_metadata = metadata;
9536 +
9537 +@@ -254,13 +254,13 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
9538 + .index = t->tcf_index,
9539 + .refcnt = t->tcf_refcnt - ref,
9540 + .bindcnt = t->tcf_bindcnt - bind,
9541 ++ .action = t->tcf_action,
9542 + };
9543 + struct tcf_t tm;
9544 +
9545 + params = rtnl_dereference(t->params);
9546 +
9547 + opt.t_action = params->tcft_action;
9548 +- opt.action = params->action;
9549 +
9550 + if (nla_put(skb, TCA_TUNNEL_KEY_PARMS, sizeof(opt), &opt))
9551 + goto nla_put_failure;
9552 +diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
9553 +index be296d633e95..ded86c449c49 100644
9554 +--- a/net/sctp/chunk.c
9555 ++++ b/net/sctp/chunk.c
9556 +@@ -247,7 +247,9 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
9557 + /* Account for a different sized first fragment */
9558 + if (msg_len >= first_len) {
9559 + msg->can_delay = 0;
9560 +- SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_FRAGUSRMSGS);
9561 ++ if (msg_len > first_len)
9562 ++ SCTP_INC_STATS(sock_net(asoc->base.sk),
9563 ++ SCTP_MIB_FRAGUSRMSGS);
9564 + } else {
9565 + /* Which may be the only one... */
9566 + first_len = msg_len;
9567 +diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
9568 +index 544bab42f925..9c5f447fa366 100644
9569 +--- a/net/smc/af_smc.c
9570 ++++ b/net/smc/af_smc.c
9571 +@@ -1231,8 +1231,7 @@ static int smc_shutdown(struct socket *sock, int how)
9572 + lock_sock(sk);
9573 +
9574 + rc = -ENOTCONN;
9575 +- if ((sk->sk_state != SMC_LISTEN) &&
9576 +- (sk->sk_state != SMC_ACTIVE) &&
9577 ++ if ((sk->sk_state != SMC_ACTIVE) &&
9578 + (sk->sk_state != SMC_PEERCLOSEWAIT1) &&
9579 + (sk->sk_state != SMC_PEERCLOSEWAIT2) &&
9580 + (sk->sk_state != SMC_APPCLOSEWAIT1) &&
9581 +diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
9582 +index 3a988c22f627..49062e752cbf 100644
9583 +--- a/net/smc/smc_clc.c
9584 ++++ b/net/smc/smc_clc.c
9585 +@@ -250,6 +250,7 @@ out:
9586 + int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
9587 + u8 expected_type)
9588 + {
9589 ++ long rcvtimeo = smc->clcsock->sk->sk_rcvtimeo;
9590 + struct sock *clc_sk = smc->clcsock->sk;
9591 + struct smc_clc_msg_hdr *clcm = buf;
9592 + struct msghdr msg = {NULL, 0};
9593 +@@ -306,7 +307,6 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
9594 + memset(&msg, 0, sizeof(struct msghdr));
9595 + iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1, datlen);
9596 + krflags = MSG_WAITALL;
9597 +- smc->clcsock->sk->sk_rcvtimeo = CLC_WAIT_TIME;
9598 + len = sock_recvmsg(smc->clcsock, &msg, krflags);
9599 + if (len < datlen || !smc_clc_msg_hdr_valid(clcm)) {
9600 + smc->sk.sk_err = EPROTO;
9601 +@@ -322,6 +322,7 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
9602 + }
9603 +
9604 + out:
9605 ++ smc->clcsock->sk->sk_rcvtimeo = rcvtimeo;
9606 + return reason_code;
9607 + }
9608 +
9609 +diff --git a/net/tipc/discover.c b/net/tipc/discover.c
9610 +index 9f666e0650e2..2830709957bd 100644
9611 +--- a/net/tipc/discover.c
9612 ++++ b/net/tipc/discover.c
9613 +@@ -133,6 +133,8 @@ static void disc_dupl_alert(struct tipc_bearer *b, u32 node_addr,
9614 + }
9615 +
9616 + /* tipc_disc_addr_trial(): - handle an address uniqueness trial from peer
9617 ++ * Returns true if message should be dropped by caller, i.e., if it is a
9618 ++ * trial message or we are inside trial period. Otherwise false.
9619 + */
9620 + static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d,
9621 + struct tipc_media_addr *maddr,
9622 +@@ -168,8 +170,9 @@ static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d,
9623 + msg_set_type(buf_msg(d->skb), DSC_REQ_MSG);
9624 + }
9625 +
9626 ++ /* Accept regular link requests/responses only after trial period */
9627 + if (mtyp != DSC_TRIAL_MSG)
9628 +- return false;
9629 ++ return trial;
9630 +
9631 + sugg_addr = tipc_node_try_addr(net, peer_id, src);
9632 + if (sugg_addr)
9633 +@@ -284,7 +287,6 @@ static void tipc_disc_timeout(struct timer_list *t)
9634 + {
9635 + struct tipc_discoverer *d = from_timer(d, t, timer);
9636 + struct tipc_net *tn = tipc_net(d->net);
9637 +- u32 self = tipc_own_addr(d->net);
9638 + struct tipc_media_addr maddr;
9639 + struct sk_buff *skb = NULL;
9640 + struct net *net = d->net;
9641 +@@ -298,12 +300,14 @@ static void tipc_disc_timeout(struct timer_list *t)
9642 + goto exit;
9643 + }
9644 +
9645 +- /* Did we just leave the address trial period ? */
9646 +- if (!self && !time_before(jiffies, tn->addr_trial_end)) {
9647 +- self = tn->trial_addr;
9648 +- tipc_net_finalize(net, self);
9649 +- msg_set_prevnode(buf_msg(d->skb), self);
9650 ++ /* Trial period over ? */
9651 ++ if (!time_before(jiffies, tn->addr_trial_end)) {
9652 ++ /* Did we just leave it ? */
9653 ++ if (!tipc_own_addr(net))
9654 ++ tipc_net_finalize(net, tn->trial_addr);
9655 ++
9656 + msg_set_type(buf_msg(d->skb), DSC_REQ_MSG);
9657 ++ msg_set_prevnode(buf_msg(d->skb), tipc_own_addr(net));
9658 + }
9659 +
9660 + /* Adjust timeout interval according to discovery phase */
9661 +diff --git a/net/tipc/net.c b/net/tipc/net.c
9662 +index 4fbaa0464405..a7f6964c3a4b 100644
9663 +--- a/net/tipc/net.c
9664 ++++ b/net/tipc/net.c
9665 +@@ -121,12 +121,17 @@ int tipc_net_init(struct net *net, u8 *node_id, u32 addr)
9666 +
9667 + void tipc_net_finalize(struct net *net, u32 addr)
9668 + {
9669 +- tipc_set_node_addr(net, addr);
9670 +- smp_mb();
9671 +- tipc_named_reinit(net);
9672 +- tipc_sk_reinit(net);
9673 +- tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
9674 +- TIPC_CLUSTER_SCOPE, 0, addr);
9675 ++ struct tipc_net *tn = tipc_net(net);
9676 ++
9677 ++ spin_lock_bh(&tn->node_list_lock);
9678 ++ if (!tipc_own_addr(net)) {
9679 ++ tipc_set_node_addr(net, addr);
9680 ++ tipc_named_reinit(net);
9681 ++ tipc_sk_reinit(net);
9682 ++ tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
9683 ++ TIPC_CLUSTER_SCOPE, 0, addr);
9684 ++ }
9685 ++ spin_unlock_bh(&tn->node_list_lock);
9686 + }
9687 +
9688 + void tipc_net_stop(struct net *net)
9689 +diff --git a/net/tipc/node.c b/net/tipc/node.c
9690 +index f29549de9245..aa09c515775f 100644
9691 +--- a/net/tipc/node.c
9692 ++++ b/net/tipc/node.c
9693 +@@ -776,6 +776,7 @@ static u32 tipc_node_suggest_addr(struct net *net, u32 addr)
9694 + }
9695 +
9696 + /* tipc_node_try_addr(): Check if addr can be used by peer, suggest other if not
9697 ++ * Returns suggested address if any, otherwise 0
9698 + */
9699 + u32 tipc_node_try_addr(struct net *net, u8 *id, u32 addr)
9700 + {
9701 +@@ -798,12 +799,14 @@ u32 tipc_node_try_addr(struct net *net, u8 *id, u32 addr)
9702 + if (n) {
9703 + addr = n->addr;
9704 + tipc_node_put(n);
9705 ++ return addr;
9706 + }
9707 +- /* Even this node may be in trial phase */
9708 ++
9709 ++ /* Even this node may be in conflict */
9710 + if (tn->trial_addr == addr)
9711 + return tipc_node_suggest_addr(net, addr);
9712 +
9713 +- return addr;
9714 ++ return 0;
9715 + }
9716 +
9717 + void tipc_node_check_dest(struct net *net, u32 addr,
9718 +diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
9719 +index 60708a4ebed4..237e227c9707 100644
9720 +--- a/net/tls/tls_sw.c
9721 ++++ b/net/tls/tls_sw.c
9722 +@@ -705,6 +705,10 @@ static int decrypt_skb(struct sock *sk, struct sk_buff *skb,
9723 + nsg = skb_to_sgvec(skb, &sgin[1],
9724 + rxm->offset + tls_ctx->rx.prepend_size,
9725 + rxm->full_len - tls_ctx->rx.prepend_size);
9726 ++ if (nsg < 0) {
9727 ++ ret = nsg;
9728 ++ goto out;
9729 ++ }
9730 +
9731 + tls_make_aad(ctx->rx_aad_ciphertext,
9732 + rxm->full_len - tls_ctx->rx.overhead_size,
9733 +@@ -716,6 +720,7 @@ static int decrypt_skb(struct sock *sk, struct sk_buff *skb,
9734 + rxm->full_len - tls_ctx->rx.overhead_size,
9735 + skb, sk->sk_allocation);
9736 +
9737 ++out:
9738 + if (sgin != &sgin_arr[0])
9739 + kfree(sgin);
9740 +
9741 +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
9742 +index 7c5135a92d76..f8e4371a1129 100644
9743 +--- a/net/wireless/nl80211.c
9744 ++++ b/net/wireless/nl80211.c
9745 +@@ -6061,7 +6061,7 @@ do { \
9746 + nl80211_check_s32);
9747 + /*
9748 + * Check HT operation mode based on
9749 +- * IEEE 802.11 2012 8.4.2.59 HT Operation element.
9750 ++ * IEEE 802.11-2016 9.4.2.57 HT Operation element.
9751 + */
9752 + if (tb[NL80211_MESHCONF_HT_OPMODE]) {
9753 + ht_opmode = nla_get_u16(tb[NL80211_MESHCONF_HT_OPMODE]);
9754 +@@ -6071,22 +6071,9 @@ do { \
9755 + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
9756 + return -EINVAL;
9757 +
9758 +- if ((ht_opmode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) &&
9759 +- (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
9760 +- return -EINVAL;
9761 ++ /* NON_HT_STA bit is reserved, but some programs set it */
9762 ++ ht_opmode &= ~IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
9763 +
9764 +- switch (ht_opmode & IEEE80211_HT_OP_MODE_PROTECTION) {
9765 +- case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
9766 +- case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
9767 +- if (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)
9768 +- return -EINVAL;
9769 +- break;
9770 +- case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
9771 +- case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
9772 +- if (!(ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
9773 +- return -EINVAL;
9774 +- break;
9775 +- }
9776 + cfg->ht_opmode = ht_opmode;
9777 + mask |= (1 << (NL80211_MESHCONF_HT_OPMODE - 1));
9778 + }
9779 +@@ -10716,9 +10703,12 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
9780 + rem) {
9781 + u8 *mask_pat;
9782 +
9783 +- nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
9784 +- nl80211_packet_pattern_policy,
9785 +- info->extack);
9786 ++ err = nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
9787 ++ nl80211_packet_pattern_policy,
9788 ++ info->extack);
9789 ++ if (err)
9790 ++ goto error;
9791 ++
9792 + err = -EINVAL;
9793 + if (!pat_tb[NL80211_PKTPAT_MASK] ||
9794 + !pat_tb[NL80211_PKTPAT_PATTERN])
9795 +@@ -10967,8 +10957,11 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
9796 + rem) {
9797 + u8 *mask_pat;
9798 +
9799 +- nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
9800 +- nl80211_packet_pattern_policy, NULL);
9801 ++ err = nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
9802 ++ nl80211_packet_pattern_policy, NULL);
9803 ++ if (err)
9804 ++ return err;
9805 ++
9806 + if (!pat_tb[NL80211_PKTPAT_MASK] ||
9807 + !pat_tb[NL80211_PKTPAT_PATTERN])
9808 + return -EINVAL;
9809 +diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
9810 +index 080035f056d9..1e50b70ad668 100644
9811 +--- a/net/xfrm/xfrm_user.c
9812 ++++ b/net/xfrm/xfrm_user.c
9813 +@@ -1671,9 +1671,11 @@ static inline unsigned int userpolicy_type_attrsize(void)
9814 + #ifdef CONFIG_XFRM_SUB_POLICY
9815 + static int copy_to_user_policy_type(u8 type, struct sk_buff *skb)
9816 + {
9817 +- struct xfrm_userpolicy_type upt = {
9818 +- .type = type,
9819 +- };
9820 ++ struct xfrm_userpolicy_type upt;
9821 ++
9822 ++ /* Sadly there are two holes in struct xfrm_userpolicy_type */
9823 ++ memset(&upt, 0, sizeof(upt));
9824 ++ upt.type = type;
9825 +
9826 + return nla_put(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt);
9827 + }
9828 +diff --git a/samples/bpf/parse_varlen.c b/samples/bpf/parse_varlen.c
9829 +index 95c16324760c..0b6f22feb2c9 100644
9830 +--- a/samples/bpf/parse_varlen.c
9831 ++++ b/samples/bpf/parse_varlen.c
9832 +@@ -6,6 +6,7 @@
9833 + */
9834 + #define KBUILD_MODNAME "foo"
9835 + #include <linux/if_ether.h>
9836 ++#include <linux/if_vlan.h>
9837 + #include <linux/ip.h>
9838 + #include <linux/ipv6.h>
9839 + #include <linux/in.h>
9840 +@@ -108,11 +109,6 @@ static int parse_ipv6(void *data, uint64_t nh_off, void *data_end)
9841 + return 0;
9842 + }
9843 +
9844 +-struct vlan_hdr {
9845 +- uint16_t h_vlan_TCI;
9846 +- uint16_t h_vlan_encapsulated_proto;
9847 +-};
9848 +-
9849 + SEC("varlen")
9850 + int handle_ingress(struct __sk_buff *skb)
9851 + {
9852 +diff --git a/samples/bpf/test_overhead_user.c b/samples/bpf/test_overhead_user.c
9853 +index e1d35e07a10e..da71dcc21634 100644
9854 +--- a/samples/bpf/test_overhead_user.c
9855 ++++ b/samples/bpf/test_overhead_user.c
9856 +@@ -6,6 +6,7 @@
9857 + */
9858 + #define _GNU_SOURCE
9859 + #include <sched.h>
9860 ++#include <errno.h>
9861 + #include <stdio.h>
9862 + #include <sys/types.h>
9863 + #include <asm/unistd.h>
9864 +@@ -44,8 +45,13 @@ static void test_task_rename(int cpu)
9865 + exit(1);
9866 + }
9867 + start_time = time_get_ns();
9868 +- for (i = 0; i < MAX_CNT; i++)
9869 +- write(fd, buf, sizeof(buf));
9870 ++ for (i = 0; i < MAX_CNT; i++) {
9871 ++ if (write(fd, buf, sizeof(buf)) < 0) {
9872 ++ printf("task rename failed: %s\n", strerror(errno));
9873 ++ close(fd);
9874 ++ return;
9875 ++ }
9876 ++ }
9877 + printf("task_rename:%d: %lld events per sec\n",
9878 + cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time));
9879 + close(fd);
9880 +@@ -63,8 +69,13 @@ static void test_urandom_read(int cpu)
9881 + exit(1);
9882 + }
9883 + start_time = time_get_ns();
9884 +- for (i = 0; i < MAX_CNT; i++)
9885 +- read(fd, buf, sizeof(buf));
9886 ++ for (i = 0; i < MAX_CNT; i++) {
9887 ++ if (read(fd, buf, sizeof(buf)) < 0) {
9888 ++ printf("failed to read from /dev/urandom: %s\n", strerror(errno));
9889 ++ close(fd);
9890 ++ return;
9891 ++ }
9892 ++ }
9893 + printf("urandom_read:%d: %lld events per sec\n",
9894 + cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time));
9895 + close(fd);
9896 +diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
9897 +index 56f7a259a7c9..ff2b8dae25ec 100644
9898 +--- a/samples/bpf/trace_event_user.c
9899 ++++ b/samples/bpf/trace_event_user.c
9900 +@@ -121,6 +121,16 @@ static void print_stacks(void)
9901 + }
9902 + }
9903 +
9904 ++static inline int generate_load(void)
9905 ++{
9906 ++ if (system("dd if=/dev/zero of=/dev/null count=5000k status=none") < 0) {
9907 ++ printf("failed to generate some load with dd: %s\n", strerror(errno));
9908 ++ return -1;
9909 ++ }
9910 ++
9911 ++ return 0;
9912 ++}
9913 ++
9914 + static void test_perf_event_all_cpu(struct perf_event_attr *attr)
9915 + {
9916 + int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
9917 +@@ -141,7 +151,11 @@ static void test_perf_event_all_cpu(struct perf_event_attr *attr)
9918 + assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
9919 + assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE) == 0);
9920 + }
9921 +- system("dd if=/dev/zero of=/dev/null count=5000k status=none");
9922 ++
9923 ++ if (generate_load() < 0) {
9924 ++ error = 1;
9925 ++ goto all_cpu_err;
9926 ++ }
9927 + print_stacks();
9928 + all_cpu_err:
9929 + for (i--; i >= 0; i--) {
9930 +@@ -155,7 +169,7 @@ all_cpu_err:
9931 +
9932 + static void test_perf_event_task(struct perf_event_attr *attr)
9933 + {
9934 +- int pmu_fd;
9935 ++ int pmu_fd, error = 0;
9936 +
9937 + /* per task perf event, enable inherit so the "dd ..." command can be traced properly.
9938 + * Enabling inherit will cause bpf_perf_prog_read_time helper failure.
9939 +@@ -170,10 +184,17 @@ static void test_perf_event_task(struct perf_event_attr *attr)
9940 + }
9941 + assert(ioctl(pmu_fd, PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
9942 + assert(ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE) == 0);
9943 +- system("dd if=/dev/zero of=/dev/null count=5000k status=none");
9944 ++
9945 ++ if (generate_load() < 0) {
9946 ++ error = 1;
9947 ++ goto err;
9948 ++ }
9949 + print_stacks();
9950 ++err:
9951 + ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE);
9952 + close(pmu_fd);
9953 ++ if (error)
9954 ++ int_exit(0);
9955 + }
9956 +
9957 + static void test_bpf_perf_event(void)
9958 +diff --git a/samples/bpf/xdp2skb_meta.sh b/samples/bpf/xdp2skb_meta.sh
9959 +index b9c9549c4c27..4bde9d066c46 100755
9960 +--- a/samples/bpf/xdp2skb_meta.sh
9961 ++++ b/samples/bpf/xdp2skb_meta.sh
9962 +@@ -16,8 +16,8 @@
9963 + BPF_FILE=xdp2skb_meta_kern.o
9964 + DIR=$(dirname $0)
9965 +
9966 +-export TC=/usr/sbin/tc
9967 +-export IP=/usr/sbin/ip
9968 ++[ -z "$TC" ] && TC=tc
9969 ++[ -z "$IP" ] && IP=ip
9970 +
9971 + function usage() {
9972 + echo ""
9973 +@@ -53,7 +53,7 @@ function _call_cmd() {
9974 + local allow_fail="$2"
9975 + shift 2
9976 + if [[ -n "$VERBOSE" ]]; then
9977 +- echo "$(basename $cmd) $@"
9978 ++ echo "$cmd $@"
9979 + fi
9980 + if [[ -n "$DRYRUN" ]]; then
9981 + return
9982 +diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
9983 +index ad6305b0f40c..f8f7cea86d7a 100644
9984 +--- a/scripts/kconfig/zconf.y
9985 ++++ b/scripts/kconfig/zconf.y
9986 +@@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE];
9987 + static struct menu *current_menu, *current_entry;
9988 +
9989 + %}
9990 +-%expect 32
9991 ++%expect 31
9992 +
9993 + %union
9994 + {
9995 +@@ -345,7 +345,7 @@ choice_block:
9996 +
9997 + /* if entry */
9998 +
9999 +-if_entry: T_IF expr nl
10000 ++if_entry: T_IF expr T_EOL
10001 + {
10002 + printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
10003 + menu_add_entry(NULL);
10004 +diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
10005 +index 0b414836bebd..60419cc2b7b8 100644
10006 +--- a/security/smack/smack_lsm.c
10007 ++++ b/security/smack/smack_lsm.c
10008 +@@ -2296,6 +2296,7 @@ static void smack_task_to_inode(struct task_struct *p, struct inode *inode)
10009 + struct smack_known *skp = smk_of_task_struct(p);
10010 +
10011 + isp->smk_inode = skp;
10012 ++ isp->smk_flags |= SMK_INODE_INSTANT;
10013 + }
10014 +
10015 + /*
10016 +diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
10017 +index ee8d0d86f0df..6fd4b074b206 100644
10018 +--- a/sound/core/seq/seq_clientmgr.c
10019 ++++ b/sound/core/seq/seq_clientmgr.c
10020 +@@ -2004,7 +2004,8 @@ static int snd_seq_ioctl_query_next_client(struct snd_seq_client *client,
10021 + struct snd_seq_client *cptr = NULL;
10022 +
10023 + /* search for next client */
10024 +- info->client++;
10025 ++ if (info->client < INT_MAX)
10026 ++ info->client++;
10027 + if (info->client < 0)
10028 + info->client = 0;
10029 + for (; info->client < SNDRV_SEQ_MAX_CLIENTS; info->client++) {
10030 +diff --git a/tools/build/Build.include b/tools/build/Build.include
10031 +index d9048f145f97..950c1504ca37 100644
10032 +--- a/tools/build/Build.include
10033 ++++ b/tools/build/Build.include
10034 +@@ -98,4 +98,4 @@ cxx_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXX
10035 + ###
10036 + ## HOSTCC C flags
10037 +
10038 +-host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CHOSTFLAGS) -D"BUILD_STR(s)=\#s" $(CHOSTFLAGS_$(basetarget).o) $(CHOSTFLAGS_$(obj))
10039 ++host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(HOSTCFLAGS) -D"BUILD_STR(s)=\#s" $(HOSTCFLAGS_$(basetarget).o) $(HOSTCFLAGS_$(obj))
10040 +diff --git a/tools/build/Makefile b/tools/build/Makefile
10041 +index 5eb4b5ad79cb..5edf65e684ab 100644
10042 +--- a/tools/build/Makefile
10043 ++++ b/tools/build/Makefile
10044 +@@ -43,7 +43,7 @@ $(OUTPUT)fixdep-in.o: FORCE
10045 + $(Q)$(MAKE) $(build)=fixdep
10046 +
10047 + $(OUTPUT)fixdep: $(OUTPUT)fixdep-in.o
10048 +- $(QUIET_LINK)$(HOSTCC) $(LDFLAGS) -o $@ $<
10049 ++ $(QUIET_LINK)$(HOSTCC) $(HOSTLDFLAGS) -o $@ $<
10050 +
10051 + FORCE:
10052 +
10053 +diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
10054 +index 4e60e105583e..0d1acb704f64 100644
10055 +--- a/tools/objtool/elf.c
10056 ++++ b/tools/objtool/elf.c
10057 +@@ -302,19 +302,34 @@ static int read_symbols(struct elf *elf)
10058 + continue;
10059 + sym->pfunc = sym->cfunc = sym;
10060 + coldstr = strstr(sym->name, ".cold.");
10061 +- if (coldstr) {
10062 +- coldstr[0] = '\0';
10063 +- pfunc = find_symbol_by_name(elf, sym->name);
10064 +- coldstr[0] = '.';
10065 +-
10066 +- if (!pfunc) {
10067 +- WARN("%s(): can't find parent function",
10068 +- sym->name);
10069 +- goto err;
10070 +- }
10071 +-
10072 +- sym->pfunc = pfunc;
10073 +- pfunc->cfunc = sym;
10074 ++ if (!coldstr)
10075 ++ continue;
10076 ++
10077 ++ coldstr[0] = '\0';
10078 ++ pfunc = find_symbol_by_name(elf, sym->name);
10079 ++ coldstr[0] = '.';
10080 ++
10081 ++ if (!pfunc) {
10082 ++ WARN("%s(): can't find parent function",
10083 ++ sym->name);
10084 ++ goto err;
10085 ++ }
10086 ++
10087 ++ sym->pfunc = pfunc;
10088 ++ pfunc->cfunc = sym;
10089 ++
10090 ++ /*
10091 ++ * Unfortunately, -fnoreorder-functions puts the child
10092 ++ * inside the parent. Remove the overlap so we can
10093 ++ * have sane assumptions.
10094 ++ *
10095 ++ * Note that pfunc->len now no longer matches
10096 ++ * pfunc->sym.st_size.
10097 ++ */
10098 ++ if (sym->sec == pfunc->sec &&
10099 ++ sym->offset >= pfunc->offset &&
10100 ++ sym->offset + sym->len == pfunc->offset + pfunc->len) {
10101 ++ pfunc->len -= sym->len;
10102 + }
10103 + }
10104 + }
10105 +diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
10106 +index ae7dc46e8f8a..46d69c5d2ec3 100644
10107 +--- a/tools/perf/Makefile.config
10108 ++++ b/tools/perf/Makefile.config
10109 +@@ -207,8 +207,7 @@ ifdef PYTHON_CONFIG
10110 + PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
10111 + PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
10112 + PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
10113 +- PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
10114 +- PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
10115 ++ PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
10116 + FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
10117 + endif
10118 +
10119 +diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
10120 +index 0c370f81e002..bd630c222e65 100644
10121 +--- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
10122 ++++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
10123 +@@ -243,7 +243,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
10124 + u64 ip;
10125 + u64 skip_slot = -1;
10126 +
10127 +- if (chain->nr < 3)
10128 ++ if (!chain || chain->nr < 3)
10129 + return skip_slot;
10130 +
10131 + ip = chain->ips[2];
10132 +diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c
10133 +index 4b2caf6d48e7..fead6b3b4206 100644
10134 +--- a/tools/perf/arch/x86/util/perf_regs.c
10135 ++++ b/tools/perf/arch/x86/util/perf_regs.c
10136 +@@ -226,7 +226,7 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)
10137 + else if (rm[2].rm_so != rm[2].rm_eo)
10138 + prefix[0] = '+';
10139 + else
10140 +- strncpy(prefix, "+0", 2);
10141 ++ scnprintf(prefix, sizeof(prefix), "+0");
10142 + }
10143 +
10144 + /* Rename register */
10145 +diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
10146 +index 63eb49082774..44195514b19e 100644
10147 +--- a/tools/perf/bench/numa.c
10148 ++++ b/tools/perf/bench/numa.c
10149 +@@ -1098,7 +1098,7 @@ static void *worker_thread(void *__tdata)
10150 + u8 *global_data;
10151 + u8 *process_data;
10152 + u8 *thread_data;
10153 +- u64 bytes_done;
10154 ++ u64 bytes_done, secs;
10155 + long work_done;
10156 + u32 l;
10157 + struct rusage rusage;
10158 +@@ -1254,7 +1254,8 @@ static void *worker_thread(void *__tdata)
10159 + timersub(&stop, &start0, &diff);
10160 + td->runtime_ns = diff.tv_sec * NSEC_PER_SEC;
10161 + td->runtime_ns += diff.tv_usec * NSEC_PER_USEC;
10162 +- td->speed_gbs = bytes_done / (td->runtime_ns / NSEC_PER_SEC) / 1e9;
10163 ++ secs = td->runtime_ns / NSEC_PER_SEC;
10164 ++ td->speed_gbs = secs ? bytes_done / secs / 1e9 : 0;
10165 +
10166 + getrusage(RUSAGE_THREAD, &rusage);
10167 + td->system_time_ns = rusage.ru_stime.tv_sec * NSEC_PER_SEC;
10168 +diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
10169 +index 51709a961496..3eeb6420ceea 100644
10170 +--- a/tools/perf/builtin-annotate.c
10171 ++++ b/tools/perf/builtin-annotate.c
10172 +@@ -283,6 +283,15 @@ out_put:
10173 + return ret;
10174 + }
10175 +
10176 ++static int process_feature_event(struct perf_tool *tool,
10177 ++ union perf_event *event,
10178 ++ struct perf_session *session)
10179 ++{
10180 ++ if (event->feat.feat_id < HEADER_LAST_FEATURE)
10181 ++ return perf_event__process_feature(tool, event, session);
10182 ++ return 0;
10183 ++}
10184 ++
10185 + static int hist_entry__tty_annotate(struct hist_entry *he,
10186 + struct perf_evsel *evsel,
10187 + struct perf_annotate *ann)
10188 +@@ -471,7 +480,7 @@ int cmd_annotate(int argc, const char **argv)
10189 + .attr = perf_event__process_attr,
10190 + .build_id = perf_event__process_build_id,
10191 + .tracing_data = perf_event__process_tracing_data,
10192 +- .feature = perf_event__process_feature,
10193 ++ .feature = process_feature_event,
10194 + .ordered_events = true,
10195 + .ordering_requires_timestamps = true,
10196 + },
10197 +diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
10198 +index 0f198f6d9b77..e5f0782b225d 100644
10199 +--- a/tools/perf/builtin-report.c
10200 ++++ b/tools/perf/builtin-report.c
10201 +@@ -226,7 +226,8 @@ static int process_feature_event(struct perf_tool *tool,
10202 + }
10203 +
10204 + /*
10205 +- * All features are received, we can force the
10206 ++ * (feat_id = HEADER_LAST_FEATURE) is the end marker which
10207 ++ * means all features are received, now we can force the
10208 + * group if needed.
10209 + */
10210 + setup_forced_leader(rep, session->evlist);
10211 +diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
10212 +index e0a9845b6cbc..553715ac8320 100644
10213 +--- a/tools/perf/builtin-script.c
10214 ++++ b/tools/perf/builtin-script.c
10215 +@@ -1832,6 +1832,7 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
10216 + struct perf_evlist *evlist;
10217 + struct perf_evsel *evsel, *pos;
10218 + int err;
10219 ++ static struct perf_evsel_script *es;
10220 +
10221 + err = perf_event__process_attr(tool, event, pevlist);
10222 + if (err)
10223 +@@ -1840,6 +1841,19 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
10224 + evlist = *pevlist;
10225 + evsel = perf_evlist__last(*pevlist);
10226 +
10227 ++ if (!evsel->priv) {
10228 ++ if (scr->per_event_dump) {
10229 ++ evsel->priv = perf_evsel_script__new(evsel,
10230 ++ scr->session->data);
10231 ++ } else {
10232 ++ es = zalloc(sizeof(*es));
10233 ++ if (!es)
10234 ++ return -ENOMEM;
10235 ++ es->fp = stdout;
10236 ++ evsel->priv = es;
10237 ++ }
10238 ++ }
10239 ++
10240 + if (evsel->attr.type >= PERF_TYPE_MAX &&
10241 + evsel->attr.type != PERF_TYPE_SYNTH)
10242 + return 0;
10243 +@@ -3028,6 +3042,15 @@ int process_cpu_map_event(struct perf_tool *tool __maybe_unused,
10244 + return set_maps(script);
10245 + }
10246 +
10247 ++static int process_feature_event(struct perf_tool *tool,
10248 ++ union perf_event *event,
10249 ++ struct perf_session *session)
10250 ++{
10251 ++ if (event->feat.feat_id < HEADER_LAST_FEATURE)
10252 ++ return perf_event__process_feature(tool, event, session);
10253 ++ return 0;
10254 ++}
10255 ++
10256 + #ifdef HAVE_AUXTRACE_SUPPORT
10257 + static int perf_script__process_auxtrace_info(struct perf_tool *tool,
10258 + union perf_event *event,
10259 +@@ -3072,7 +3095,7 @@ int cmd_script(int argc, const char **argv)
10260 + .attr = process_attr,
10261 + .event_update = perf_event__process_event_update,
10262 + .tracing_data = perf_event__process_tracing_data,
10263 +- .feature = perf_event__process_feature,
10264 ++ .feature = process_feature_event,
10265 + .build_id = perf_event__process_build_id,
10266 + .id_index = perf_event__process_id_index,
10267 + .auxtrace_info = perf_script__process_auxtrace_info,
10268 +diff --git a/tools/perf/jvmti/jvmti_agent.c b/tools/perf/jvmti/jvmti_agent.c
10269 +index 0c6d1002b524..ac1bcdc17dae 100644
10270 +--- a/tools/perf/jvmti/jvmti_agent.c
10271 ++++ b/tools/perf/jvmti/jvmti_agent.c
10272 +@@ -35,6 +35,7 @@
10273 + #include <sys/mman.h>
10274 + #include <syscall.h> /* for gettid() */
10275 + #include <err.h>
10276 ++#include <linux/kernel.h>
10277 +
10278 + #include "jvmti_agent.h"
10279 + #include "../util/jitdump.h"
10280 +@@ -249,7 +250,7 @@ void *jvmti_open(void)
10281 + /*
10282 + * jitdump file name
10283 + */
10284 +- snprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid());
10285 ++ scnprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid());
10286 +
10287 + fd = open(dump_path, O_CREAT|O_TRUNC|O_RDWR, 0666);
10288 + if (fd == -1)
10289 +diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
10290 +index 17783913d330..215ba30b8534 100644
10291 +--- a/tools/perf/pmu-events/Build
10292 ++++ b/tools/perf/pmu-events/Build
10293 +@@ -1,7 +1,7 @@
10294 + hostprogs := jevents
10295 +
10296 + jevents-y += json.o jsmn.o jevents.o
10297 +-CHOSTFLAGS_jevents.o = -I$(srctree)/tools/include
10298 ++HOSTCFLAGS_jevents.o = -I$(srctree)/tools/include
10299 + pmu-events-y += pmu-events.o
10300 + JDIR = pmu-events/arch/$(SRCARCH)
10301 + JSON = $(shell [ -d $(JDIR) ] && \
10302 +diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
10303 +index cac8f8889bc3..6a858355091d 100644
10304 +--- a/tools/perf/tests/builtin-test.c
10305 ++++ b/tools/perf/tests/builtin-test.c
10306 +@@ -422,7 +422,7 @@ static const char *shell_test__description(char *description, size_t size,
10307 +
10308 + #define for_each_shell_test(dir, base, ent) \
10309 + while ((ent = readdir(dir)) != NULL) \
10310 +- if (!is_directory(base, ent))
10311 ++ if (!is_directory(base, ent) && ent->d_name[0] != '.')
10312 +
10313 + static const char *shell_tests__dir(char *path, size_t size)
10314 + {
10315 +diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
10316 +index 18b06444f230..1509ef2c10c8 100644
10317 +--- a/tools/perf/tests/parse-events.c
10318 ++++ b/tools/perf/tests/parse-events.c
10319 +@@ -1672,6 +1672,7 @@ static struct terms_test test__terms[] = {
10320 +
10321 + static int test_event(struct evlist_test *e)
10322 + {
10323 ++ struct parse_events_error err = { .idx = 0, };
10324 + struct perf_evlist *evlist;
10325 + int ret;
10326 +
10327 +@@ -1679,10 +1680,11 @@ static int test_event(struct evlist_test *e)
10328 + if (evlist == NULL)
10329 + return -ENOMEM;
10330 +
10331 +- ret = parse_events(evlist, e->name, NULL);
10332 ++ ret = parse_events(evlist, e->name, &err);
10333 + if (ret) {
10334 +- pr_debug("failed to parse event '%s', err %d\n",
10335 +- e->name, ret);
10336 ++ pr_debug("failed to parse event '%s', err %d, str '%s'\n",
10337 ++ e->name, ret, err.str);
10338 ++ parse_events_print_error(&err, e->name);
10339 + } else {
10340 + ret = e->check(evlist);
10341 + }
10342 +diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
10343 +index 40e30a26b23c..9497d02f69e6 100644
10344 +--- a/tools/perf/tests/topology.c
10345 ++++ b/tools/perf/tests/topology.c
10346 +@@ -45,6 +45,7 @@ static int session_write_header(char *path)
10347 +
10348 + perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
10349 + perf_header__set_feat(&session->header, HEADER_NRCPUS);
10350 ++ perf_header__set_feat(&session->header, HEADER_ARCH);
10351 +
10352 + session->header.data_size += DATA_SIZE;
10353 +
10354 +diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cpp
10355 +index bf31ceab33bd..89512504551b 100644
10356 +--- a/tools/perf/util/c++/clang.cpp
10357 ++++ b/tools/perf/util/c++/clang.cpp
10358 +@@ -146,8 +146,15 @@ getBPFObjectFromModule(llvm::Module *Module)
10359 + raw_svector_ostream ostream(*Buffer);
10360 +
10361 + legacy::PassManager PM;
10362 +- if (TargetMachine->addPassesToEmitFile(PM, ostream,
10363 +- TargetMachine::CGFT_ObjectFile)) {
10364 ++ bool NotAdded;
10365 ++#if CLANG_VERSION_MAJOR < 7
10366 ++ NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
10367 ++ TargetMachine::CGFT_ObjectFile);
10368 ++#else
10369 ++ NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
10370 ++ TargetMachine::CGFT_ObjectFile);
10371 ++#endif
10372 ++ if (NotAdded) {
10373 + llvm::errs() << "TargetMachine can't emit a file of this type\n";
10374 + return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr);;
10375 + }
10376 +diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
10377 +index a8bff2178fbc..9d3907db0802 100644
10378 +--- a/tools/perf/util/header.c
10379 ++++ b/tools/perf/util/header.c
10380 +@@ -2113,6 +2113,7 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
10381 + int cpu_nr = ff->ph->env.nr_cpus_avail;
10382 + u64 size = 0;
10383 + struct perf_header *ph = ff->ph;
10384 ++ bool do_core_id_test = true;
10385 +
10386 + ph->env.cpu = calloc(cpu_nr, sizeof(*ph->env.cpu));
10387 + if (!ph->env.cpu)
10388 +@@ -2167,6 +2168,13 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
10389 + return 0;
10390 + }
10391 +
10392 ++ /* On s390 the socket_id number is not related to the numbers of cpus.
10393 ++ * The socket_id number might be higher than the numbers of cpus.
10394 ++ * This depends on the configuration.
10395 ++ */
10396 ++ if (ph->env.arch && !strncmp(ph->env.arch, "s390", 4))
10397 ++ do_core_id_test = false;
10398 ++
10399 + for (i = 0; i < (u32)cpu_nr; i++) {
10400 + if (do_read_u32(ff, &nr))
10401 + goto free_cpu;
10402 +@@ -2176,7 +2184,7 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
10403 + if (do_read_u32(ff, &nr))
10404 + goto free_cpu;
10405 +
10406 +- if (nr != (u32)-1 && nr > (u32)cpu_nr) {
10407 ++ if (do_core_id_test && nr != (u32)-1 && nr > (u32)cpu_nr) {
10408 + pr_debug("socket_id number is too big."
10409 + "You may need to upgrade the perf tool.\n");
10410 + goto free_cpu;
10411 +@@ -3442,7 +3450,7 @@ int perf_event__process_feature(struct perf_tool *tool,
10412 + pr_warning("invalid record type %d in pipe-mode\n", type);
10413 + return 0;
10414 + }
10415 +- if (feat == HEADER_RESERVED || feat > HEADER_LAST_FEATURE) {
10416 ++ if (feat == HEADER_RESERVED || feat >= HEADER_LAST_FEATURE) {
10417 + pr_warning("invalid record type %d in pipe-mode\n", type);
10418 + return -1;
10419 + }
10420 +diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
10421 +index 1cca0a2fa641..c3c0ce8cdc55 100644
10422 +--- a/tools/perf/util/llvm-utils.c
10423 ++++ b/tools/perf/util/llvm-utils.c
10424 +@@ -265,16 +265,16 @@ static const char *kinc_fetch_script =
10425 + "#!/usr/bin/env sh\n"
10426 + "if ! test -d \"$KBUILD_DIR\"\n"
10427 + "then\n"
10428 +-" exit -1\n"
10429 ++" exit 1\n"
10430 + "fi\n"
10431 + "if ! test -f \"$KBUILD_DIR/include/generated/autoconf.h\"\n"
10432 + "then\n"
10433 +-" exit -1\n"
10434 ++" exit 1\n"
10435 + "fi\n"
10436 + "TMPDIR=`mktemp -d`\n"
10437 + "if test -z \"$TMPDIR\"\n"
10438 + "then\n"
10439 +-" exit -1\n"
10440 ++" exit 1\n"
10441 + "fi\n"
10442 + "cat << EOF > $TMPDIR/Makefile\n"
10443 + "obj-y := dummy.o\n"
10444 +diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
10445 +index 155d2570274f..da8fe57691b8 100644
10446 +--- a/tools/perf/util/parse-events.y
10447 ++++ b/tools/perf/util/parse-events.y
10448 +@@ -227,11 +227,16 @@ event_def: event_pmu |
10449 + event_pmu:
10450 + PE_NAME opt_pmu_config
10451 + {
10452 ++ struct parse_events_state *parse_state = _parse_state;
10453 ++ struct parse_events_error *error = parse_state->error;
10454 + struct list_head *list, *orig_terms, *terms;
10455 +
10456 + if (parse_events_copy_term_list($2, &orig_terms))
10457 + YYABORT;
10458 +
10459 ++ if (error)
10460 ++ error->idx = @1.first_column;
10461 ++
10462 + ALLOC_LIST(list);
10463 + if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) {
10464 + struct perf_pmu *pmu = NULL;
10465 +diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
10466 +index 7f8afacd08ee..39894b96b5d6 100644
10467 +--- a/tools/perf/util/scripting-engines/trace-event-python.c
10468 ++++ b/tools/perf/util/scripting-engines/trace-event-python.c
10469 +@@ -676,14 +676,11 @@ static void python_process_tracepoint(struct perf_sample *sample,
10470 + if (_PyTuple_Resize(&t, n) == -1)
10471 + Py_FatalError("error resizing Python tuple");
10472 +
10473 +- if (!dict) {
10474 ++ if (!dict)
10475 + call_object(handler, t, handler_name);
10476 +- } else {
10477 ++ else
10478 + call_object(handler, t, default_handler_name);
10479 +- Py_DECREF(dict);
10480 +- }
10481 +
10482 +- Py_XDECREF(all_entries_dict);
10483 + Py_DECREF(t);
10484 + }
10485 +
10486 +@@ -1003,7 +1000,6 @@ static void python_process_general_event(struct perf_sample *sample,
10487 +
10488 + call_object(handler, t, handler_name);
10489 +
10490 +- Py_DECREF(dict);
10491 + Py_DECREF(t);
10492 + }
10493 +
10494 +diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
10495 +index 4ea385be528f..51b7ce7b9ad3 100644
10496 +--- a/tools/testing/nvdimm/test/nfit.c
10497 ++++ b/tools/testing/nvdimm/test/nfit.c
10498 +@@ -1989,8 +1989,7 @@ static void nfit_test0_setup(struct nfit_test *t)
10499 + pcap->header.type = ACPI_NFIT_TYPE_CAPABILITIES;
10500 + pcap->header.length = sizeof(*pcap);
10501 + pcap->highest_capability = 1;
10502 +- pcap->capabilities = ACPI_NFIT_CAPABILITY_CACHE_FLUSH |
10503 +- ACPI_NFIT_CAPABILITY_MEM_FLUSH;
10504 ++ pcap->capabilities = ACPI_NFIT_CAPABILITY_MEM_FLUSH;
10505 + offset += pcap->header.length;
10506 +
10507 + if (t->setup_hotplug) {
10508 +diff --git a/tools/testing/selftests/bpf/test_kmod.sh b/tools/testing/selftests/bpf/test_kmod.sh
10509 +index 35669ccd4d23..9df0d2ac45f8 100755
10510 +--- a/tools/testing/selftests/bpf/test_kmod.sh
10511 ++++ b/tools/testing/selftests/bpf/test_kmod.sh
10512 +@@ -1,6 +1,15 @@
10513 + #!/bin/sh
10514 + # SPDX-License-Identifier: GPL-2.0
10515 +
10516 ++# Kselftest framework requirement - SKIP code is 4.
10517 ++ksft_skip=4
10518 ++
10519 ++msg="skip all tests:"
10520 ++if [ "$(id -u)" != "0" ]; then
10521 ++ echo $msg please run this as root >&2
10522 ++ exit $ksft_skip
10523 ++fi
10524 ++
10525 + SRC_TREE=../../../../
10526 +
10527 + test_run()
10528 +diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py
10529 +index e78aad0a68bb..be800d0e7a84 100755
10530 +--- a/tools/testing/selftests/bpf/test_offload.py
10531 ++++ b/tools/testing/selftests/bpf/test_offload.py
10532 +@@ -163,6 +163,10 @@ def bpftool(args, JSON=True, ns="", fail=True):
10533 +
10534 + def bpftool_prog_list(expected=None, ns=""):
10535 + _, progs = bpftool("prog show", JSON=True, ns=ns, fail=True)
10536 ++ # Remove the base progs
10537 ++ for p in base_progs:
10538 ++ if p in progs:
10539 ++ progs.remove(p)
10540 + if expected is not None:
10541 + if len(progs) != expected:
10542 + fail(True, "%d BPF programs loaded, expected %d" %
10543 +@@ -171,6 +175,10 @@ def bpftool_prog_list(expected=None, ns=""):
10544 +
10545 + def bpftool_map_list(expected=None, ns=""):
10546 + _, maps = bpftool("map show", JSON=True, ns=ns, fail=True)
10547 ++ # Remove the base maps
10548 ++ for m in base_maps:
10549 ++ if m in maps:
10550 ++ maps.remove(m)
10551 + if expected is not None:
10552 + if len(maps) != expected:
10553 + fail(True, "%d BPF maps loaded, expected %d" %
10554 +@@ -585,8 +593,8 @@ skip(os.getuid() != 0, "test must be run as root")
10555 + # Check tools
10556 + ret, progs = bpftool("prog", fail=False)
10557 + skip(ret != 0, "bpftool not installed")
10558 +-# Check no BPF programs are loaded
10559 +-skip(len(progs) != 0, "BPF programs already loaded on the system")
10560 ++base_progs = progs
10561 ++_, base_maps = bpftool("map")
10562 +
10563 + # Check netdevsim
10564 + ret, out = cmd("modprobe netdevsim", fail=False)
10565 +diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config
10566 +index 7ba089b33e8b..cd3a2f1545b5 100644
10567 +--- a/tools/testing/selftests/net/config
10568 ++++ b/tools/testing/selftests/net/config
10569 +@@ -12,3 +12,5 @@ CONFIG_NET_IPVTI=y
10570 + CONFIG_INET6_XFRM_MODE_TUNNEL=y
10571 + CONFIG_IPV6_VTI=y
10572 + CONFIG_DUMMY=y
10573 ++CONFIG_BRIDGE=y
10574 ++CONFIG_VLAN_8021Q=y
10575 +diff --git a/tools/testing/selftests/pstore/pstore_post_reboot_tests b/tools/testing/selftests/pstore/pstore_post_reboot_tests
10576 +index 6ccb154cb4aa..22f8df1ad7d4 100755
10577 +--- a/tools/testing/selftests/pstore/pstore_post_reboot_tests
10578 ++++ b/tools/testing/selftests/pstore/pstore_post_reboot_tests
10579 +@@ -7,13 +7,16 @@
10580 + #
10581 + # Released under the terms of the GPL v2.
10582 +
10583 ++# Kselftest framework requirement - SKIP code is 4.
10584 ++ksft_skip=4
10585 ++
10586 + . ./common_tests
10587 +
10588 + if [ -e $REBOOT_FLAG ]; then
10589 + rm $REBOOT_FLAG
10590 + else
10591 + prlog "pstore_crash_test has not been executed yet. we skip further tests."
10592 +- exit 0
10593 ++ exit $ksft_skip
10594 + fi
10595 +
10596 + prlog -n "Mounting pstore filesystem ... "
10597 +diff --git a/tools/testing/selftests/static_keys/test_static_keys.sh b/tools/testing/selftests/static_keys/test_static_keys.sh
10598 +index 24cff498b31a..fc9f8cde7d42 100755
10599 +--- a/tools/testing/selftests/static_keys/test_static_keys.sh
10600 ++++ b/tools/testing/selftests/static_keys/test_static_keys.sh
10601 +@@ -2,6 +2,19 @@
10602 + # SPDX-License-Identifier: GPL-2.0
10603 + # Runs static keys kernel module tests
10604 +
10605 ++# Kselftest framework requirement - SKIP code is 4.
10606 ++ksft_skip=4
10607 ++
10608 ++if ! /sbin/modprobe -q -n test_static_key_base; then
10609 ++ echo "static_key: module test_static_key_base is not found [SKIP]"
10610 ++ exit $ksft_skip
10611 ++fi
10612 ++
10613 ++if ! /sbin/modprobe -q -n test_static_keys; then
10614 ++ echo "static_key: module test_static_keys is not found [SKIP]"
10615 ++ exit $ksft_skip
10616 ++fi
10617 ++
10618 + if /sbin/modprobe -q test_static_key_base; then
10619 + if /sbin/modprobe -q test_static_keys; then
10620 + echo "static_key: ok"
10621 +diff --git a/tools/testing/selftests/sync/config b/tools/testing/selftests/sync/config
10622 +new file mode 100644
10623 +index 000000000000..1ab7e8130db2
10624 +--- /dev/null
10625 ++++ b/tools/testing/selftests/sync/config
10626 +@@ -0,0 +1,4 @@
10627 ++CONFIG_STAGING=y
10628 ++CONFIG_ANDROID=y
10629 ++CONFIG_SYNC=y
10630 ++CONFIG_SW_SYNC=y
10631 +diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
10632 +index ec232c3cfcaa..584eb8ea780a 100755
10633 +--- a/tools/testing/selftests/sysctl/sysctl.sh
10634 ++++ b/tools/testing/selftests/sysctl/sysctl.sh
10635 +@@ -14,6 +14,9 @@
10636 +
10637 + # This performs a series tests against the proc sysctl interface.
10638 +
10639 ++# Kselftest framework requirement - SKIP code is 4.
10640 ++ksft_skip=4
10641 ++
10642 + TEST_NAME="sysctl"
10643 + TEST_DRIVER="test_${TEST_NAME}"
10644 + TEST_DIR=$(dirname $0)
10645 +@@ -41,7 +44,7 @@ test_modprobe()
10646 + echo "$0: $DIR not present" >&2
10647 + echo "You must have the following enabled in your kernel:" >&2
10648 + cat $TEST_DIR/config >&2
10649 +- exit 1
10650 ++ exit $ksft_skip
10651 + fi
10652 + }
10653 +
10654 +@@ -98,28 +101,30 @@ test_reqs()
10655 + uid=$(id -u)
10656 + if [ $uid -ne 0 ]; then
10657 + echo $msg must be run as root >&2
10658 +- exit 0
10659 ++ exit $ksft_skip
10660 + fi
10661 +
10662 + if ! which perl 2> /dev/null > /dev/null; then
10663 + echo "$0: You need perl installed"
10664 +- exit 1
10665 ++ exit $ksft_skip
10666 + fi
10667 + if ! which getconf 2> /dev/null > /dev/null; then
10668 + echo "$0: You need getconf installed"
10669 +- exit 1
10670 ++ exit $ksft_skip
10671 + fi
10672 + if ! which diff 2> /dev/null > /dev/null; then
10673 + echo "$0: You need diff installed"
10674 +- exit 1
10675 ++ exit $ksft_skip
10676 + fi
10677 + }
10678 +
10679 + function load_req_mod()
10680 + {
10681 +- trap "test_modprobe" EXIT
10682 +-
10683 + if [ ! -d $DIR ]; then
10684 ++ if ! modprobe -q -n $TEST_DRIVER; then
10685 ++ echo "$0: module $TEST_DRIVER not found [SKIP]"
10686 ++ exit $ksft_skip
10687 ++ fi
10688 + modprobe $TEST_DRIVER
10689 + if [ $? -ne 0 ]; then
10690 + exit
10691 +@@ -765,6 +770,7 @@ function parse_args()
10692 + test_reqs
10693 + allow_user_defaults
10694 + check_production_sysctl_writes_strict
10695 ++test_modprobe
10696 + load_req_mod
10697 +
10698 + trap "test_finish" EXIT
10699 +diff --git a/tools/testing/selftests/user/test_user_copy.sh b/tools/testing/selftests/user/test_user_copy.sh
10700 +index d60506fc77f8..f9b31a57439b 100755
10701 +--- a/tools/testing/selftests/user/test_user_copy.sh
10702 ++++ b/tools/testing/selftests/user/test_user_copy.sh
10703 +@@ -2,6 +2,13 @@
10704 + # SPDX-License-Identifier: GPL-2.0
10705 + # Runs copy_to/from_user infrastructure using test_user_copy kernel module
10706 +
10707 ++# Kselftest framework requirement - SKIP code is 4.
10708 ++ksft_skip=4
10709 ++
10710 ++if ! /sbin/modprobe -q -n test_user_copy; then
10711 ++ echo "user: module test_user_copy is not found [SKIP]"
10712 ++ exit $ksft_skip
10713 ++fi
10714 + if /sbin/modprobe -q test_user_copy; then
10715 + /sbin/modprobe -q -r test_user_copy
10716 + echo "user_copy: ok"
10717 +diff --git a/tools/testing/selftests/vm/compaction_test.c b/tools/testing/selftests/vm/compaction_test.c
10718 +index 1097f04e4d80..bcec71250873 100644
10719 +--- a/tools/testing/selftests/vm/compaction_test.c
10720 ++++ b/tools/testing/selftests/vm/compaction_test.c
10721 +@@ -16,6 +16,8 @@
10722 + #include <unistd.h>
10723 + #include <string.h>
10724 +
10725 ++#include "../kselftest.h"
10726 ++
10727 + #define MAP_SIZE 1048576
10728 +
10729 + struct map_list {
10730 +@@ -169,7 +171,7 @@ int main(int argc, char **argv)
10731 + printf("Either the sysctl compact_unevictable_allowed is not\n"
10732 + "set to 1 or couldn't read the proc file.\n"
10733 + "Skipping the test\n");
10734 +- return 0;
10735 ++ return KSFT_SKIP;
10736 + }
10737 +
10738 + lim.rlim_cur = RLIM_INFINITY;
10739 +diff --git a/tools/testing/selftests/vm/mlock2-tests.c b/tools/testing/selftests/vm/mlock2-tests.c
10740 +index 4997b9222cfa..637b6d0ac0d0 100644
10741 +--- a/tools/testing/selftests/vm/mlock2-tests.c
10742 ++++ b/tools/testing/selftests/vm/mlock2-tests.c
10743 +@@ -9,6 +9,8 @@
10744 + #include <stdbool.h>
10745 + #include "mlock2.h"
10746 +
10747 ++#include "../kselftest.h"
10748 ++
10749 + struct vm_boundaries {
10750 + unsigned long start;
10751 + unsigned long end;
10752 +@@ -303,7 +305,7 @@ static int test_mlock_lock()
10753 + if (mlock2_(map, 2 * page_size, 0)) {
10754 + if (errno == ENOSYS) {
10755 + printf("Cannot call new mlock family, skipping test\n");
10756 +- _exit(0);
10757 ++ _exit(KSFT_SKIP);
10758 + }
10759 + perror("mlock2(0)");
10760 + goto unmap;
10761 +@@ -412,7 +414,7 @@ static int test_mlock_onfault()
10762 + if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) {
10763 + if (errno == ENOSYS) {
10764 + printf("Cannot call new mlock family, skipping test\n");
10765 +- _exit(0);
10766 ++ _exit(KSFT_SKIP);
10767 + }
10768 + perror("mlock2(MLOCK_ONFAULT)");
10769 + goto unmap;
10770 +@@ -425,7 +427,7 @@ static int test_mlock_onfault()
10771 + if (munlock(map, 2 * page_size)) {
10772 + if (errno == ENOSYS) {
10773 + printf("Cannot call new mlock family, skipping test\n");
10774 +- _exit(0);
10775 ++ _exit(KSFT_SKIP);
10776 + }
10777 + perror("munlock()");
10778 + goto unmap;
10779 +@@ -457,7 +459,7 @@ static int test_lock_onfault_of_present()
10780 + if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) {
10781 + if (errno == ENOSYS) {
10782 + printf("Cannot call new mlock family, skipping test\n");
10783 +- _exit(0);
10784 ++ _exit(KSFT_SKIP);
10785 + }
10786 + perror("mlock2(MLOCK_ONFAULT)");
10787 + goto unmap;
10788 +@@ -583,7 +585,7 @@ static int test_vma_management(bool call_mlock)
10789 + if (call_mlock && mlock2_(map, 3 * page_size, MLOCK_ONFAULT)) {
10790 + if (errno == ENOSYS) {
10791 + printf("Cannot call new mlock family, skipping test\n");
10792 +- _exit(0);
10793 ++ _exit(KSFT_SKIP);
10794 + }
10795 + perror("mlock(ONFAULT)\n");
10796 + goto out;
10797 +diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
10798 +index 22d564673830..88cbe5575f0c 100755
10799 +--- a/tools/testing/selftests/vm/run_vmtests
10800 ++++ b/tools/testing/selftests/vm/run_vmtests
10801 +@@ -2,6 +2,9 @@
10802 + # SPDX-License-Identifier: GPL-2.0
10803 + #please run as root
10804 +
10805 ++# Kselftest framework requirement - SKIP code is 4.
10806 ++ksft_skip=4
10807 ++
10808 + mnt=./huge
10809 + exitcode=0
10810 +
10811 +@@ -36,7 +39,7 @@ if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
10812 + echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
10813 + if [ $? -ne 0 ]; then
10814 + echo "Please run this test as root"
10815 +- exit 1
10816 ++ exit $ksft_skip
10817 + fi
10818 + while read name size unit; do
10819 + if [ "$name" = "HugePages_Free:" ]; then
10820 +diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
10821 +index de2f9ec8a87f..7b8171e3128a 100644
10822 +--- a/tools/testing/selftests/vm/userfaultfd.c
10823 ++++ b/tools/testing/selftests/vm/userfaultfd.c
10824 +@@ -69,6 +69,8 @@
10825 + #include <setjmp.h>
10826 + #include <stdbool.h>
10827 +
10828 ++#include "../kselftest.h"
10829 ++
10830 + #ifdef __NR_userfaultfd
10831 +
10832 + static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
10833 +@@ -1322,7 +1324,7 @@ int main(int argc, char **argv)
10834 + int main(void)
10835 + {
10836 + printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n");
10837 +- return 0;
10838 ++ return KSFT_SKIP;
10839 + }
10840 +
10841 + #endif /* __NR_userfaultfd */
10842 +diff --git a/tools/testing/selftests/x86/sigreturn.c b/tools/testing/selftests/x86/sigreturn.c
10843 +index 246145b84a12..4d9dc3f2fd70 100644
10844 +--- a/tools/testing/selftests/x86/sigreturn.c
10845 ++++ b/tools/testing/selftests/x86/sigreturn.c
10846 +@@ -610,21 +610,41 @@ static int test_valid_sigreturn(int cs_bits, bool use_16bit_ss, int force_ss)
10847 + */
10848 + for (int i = 0; i < NGREG; i++) {
10849 + greg_t req = requested_regs[i], res = resulting_regs[i];
10850 ++
10851 + if (i == REG_TRAPNO || i == REG_IP)
10852 + continue; /* don't care */
10853 +- if (i == REG_SP) {
10854 +- printf("\tSP: %llx -> %llx\n", (unsigned long long)req,
10855 +- (unsigned long long)res);
10856 +
10857 ++ if (i == REG_SP) {
10858 + /*
10859 +- * In many circumstances, the high 32 bits of rsp
10860 +- * are zeroed. For example, we could be a real
10861 +- * 32-bit program, or we could hit any of a number
10862 +- * of poorly-documented IRET or segmented ESP
10863 +- * oddities. If this happens, it's okay.
10864 ++ * If we were using a 16-bit stack segment, then
10865 ++ * the kernel is a bit stuck: IRET only restores
10866 ++ * the low 16 bits of ESP/RSP if SS is 16-bit.
10867 ++ * The kernel uses a hack to restore bits 31:16,
10868 ++ * but that hack doesn't help with bits 63:32.
10869 ++ * On Intel CPUs, bits 63:32 end up zeroed, and, on
10870 ++ * AMD CPUs, they leak the high bits of the kernel
10871 ++ * espfix64 stack pointer. There's very little that
10872 ++ * the kernel can do about it.
10873 ++ *
10874 ++ * Similarly, if we are returning to a 32-bit context,
10875 ++ * the CPU will often lose the high 32 bits of RSP.
10876 + */
10877 +- if (res == (req & 0xFFFFFFFF))
10878 +- continue; /* OK; not expected to work */
10879 ++
10880 ++ if (res == req)
10881 ++ continue;
10882 ++
10883 ++ if (cs_bits != 64 && ((res ^ req) & 0xFFFFFFFF) == 0) {
10884 ++ printf("[NOTE]\tSP: %llx -> %llx\n",
10885 ++ (unsigned long long)req,
10886 ++ (unsigned long long)res);
10887 ++ continue;
10888 ++ }
10889 ++
10890 ++ printf("[FAIL]\tSP mismatch: requested 0x%llx; got 0x%llx\n",
10891 ++ (unsigned long long)requested_regs[i],
10892 ++ (unsigned long long)resulting_regs[i]);
10893 ++ nerrs++;
10894 ++ continue;
10895 + }
10896 +
10897 + bool ignore_reg = false;
10898 +@@ -654,25 +674,18 @@ static int test_valid_sigreturn(int cs_bits, bool use_16bit_ss, int force_ss)
10899 + #endif
10900 +
10901 + /* Sanity check on the kernel */
10902 +- if (i == REG_CX && requested_regs[i] != resulting_regs[i]) {
10903 ++ if (i == REG_CX && req != res) {
10904 + printf("[FAIL]\tCX (saved SP) mismatch: requested 0x%llx; got 0x%llx\n",
10905 +- (unsigned long long)requested_regs[i],
10906 +- (unsigned long long)resulting_regs[i]);
10907 ++ (unsigned long long)req,
10908 ++ (unsigned long long)res);
10909 + nerrs++;
10910 + continue;
10911 + }
10912 +
10913 +- if (requested_regs[i] != resulting_regs[i] && !ignore_reg) {
10914 +- /*
10915 +- * SP is particularly interesting here. The
10916 +- * usual cause of failures is that we hit the
10917 +- * nasty IRET case of returning to a 16-bit SS,
10918 +- * in which case bits 16:31 of the *kernel*
10919 +- * stack pointer persist in ESP.
10920 +- */
10921 ++ if (req != res && !ignore_reg) {
10922 + printf("[FAIL]\tReg %d mismatch: requested 0x%llx; got 0x%llx\n",
10923 +- i, (unsigned long long)requested_regs[i],
10924 +- (unsigned long long)resulting_regs[i]);
10925 ++ i, (unsigned long long)req,
10926 ++ (unsigned long long)res);
10927 + nerrs++;
10928 + }
10929 + }
10930 +diff --git a/tools/testing/selftests/zram/zram.sh b/tools/testing/selftests/zram/zram.sh
10931 +index 754de7da426a..232e958ec454 100755
10932 +--- a/tools/testing/selftests/zram/zram.sh
10933 ++++ b/tools/testing/selftests/zram/zram.sh
10934 +@@ -2,6 +2,9 @@
10935 + # SPDX-License-Identifier: GPL-2.0
10936 + TCID="zram.sh"
10937 +
10938 ++# Kselftest framework requirement - SKIP code is 4.
10939 ++ksft_skip=4
10940 ++
10941 + . ./zram_lib.sh
10942 +
10943 + run_zram () {
10944 +@@ -24,5 +27,5 @@ elif [ -b /dev/zram0 ]; then
10945 + else
10946 + echo "$TCID : No zram.ko module or /dev/zram0 device file not found"
10947 + echo "$TCID : CONFIG_ZRAM is not set"
10948 +- exit 1
10949 ++ exit $ksft_skip
10950 + fi
10951 +diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh
10952 +index f6a9c73e7a44..9e73a4fb9b0a 100755
10953 +--- a/tools/testing/selftests/zram/zram_lib.sh
10954 ++++ b/tools/testing/selftests/zram/zram_lib.sh
10955 +@@ -18,6 +18,9 @@ MODULE=0
10956 + dev_makeswap=-1
10957 + dev_mounted=-1
10958 +
10959 ++# Kselftest framework requirement - SKIP code is 4.
10960 ++ksft_skip=4
10961 ++
10962 + trap INT
10963 +
10964 + check_prereqs()
10965 +@@ -27,7 +30,7 @@ check_prereqs()
10966 +
10967 + if [ $uid -ne 0 ]; then
10968 + echo $msg must be run as root >&2
10969 +- exit 0
10970 ++ exit $ksft_skip
10971 + fi
10972 + }
10973 +
10974 +diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
10975 +index bdcf8e7a6161..72fc688c3e9d 100644
10976 +--- a/virt/kvm/arm/vgic/vgic-v3.c
10977 ++++ b/virt/kvm/arm/vgic/vgic-v3.c
10978 +@@ -552,11 +552,6 @@ int vgic_v3_probe(const struct gic_kvm_info *info)
10979 + pr_warn("GICV physical address 0x%llx not page aligned\n",
10980 + (unsigned long long)info->vcpu.start);
10981 + kvm_vgic_global_state.vcpu_base = 0;
10982 +- } else if (!PAGE_ALIGNED(resource_size(&info->vcpu))) {
10983 +- pr_warn("GICV size 0x%llx not a multiple of page size 0x%lx\n",
10984 +- (unsigned long long)resource_size(&info->vcpu),
10985 +- PAGE_SIZE);
10986 +- kvm_vgic_global_state.vcpu_base = 0;
10987 + } else {
10988 + kvm_vgic_global_state.vcpu_base = info->vcpu.start;
10989 + kvm_vgic_global_state.can_emulate_gicv2 = true;