Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.4 commit in: /
Date: Thu, 29 Oct 2020 11:19:43
Message-Id: 1603970362.041d5eccd7e071fa162d963f85c8ef7cbe2dd595.mpagano@gentoo
1 commit: 041d5eccd7e071fa162d963f85c8ef7cbe2dd595
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Thu Oct 29 11:19:22 2020 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 29 11:19:22 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=041d5ecc
7
8 Linux patch 5.4.73
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1072_linux-5.4.73.patch | 13402 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 13406 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 2cb2603..6920241 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -331,6 +331,10 @@ Patch: 1071_linux-5.4.72.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.4.72
23
24 +Patch: 1072_linux-5.4.73.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.4.73
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1072_linux-5.4.73.patch b/1072_linux-5.4.73.patch
33 new file mode 100644
34 index 0000000..4ca07f2
35 --- /dev/null
36 +++ b/1072_linux-5.4.73.patch
37 @@ -0,0 +1,13402 @@
38 +diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
39 +index 13984b6cc3225..988a0d2535b25 100644
40 +--- a/Documentation/admin-guide/kernel-parameters.txt
41 ++++ b/Documentation/admin-guide/kernel-parameters.txt
42 +@@ -567,7 +567,7 @@
43 + loops can be debugged more effectively on production
44 + systems.
45 +
46 +- clearcpuid=BITNUM [X86]
47 ++ clearcpuid=BITNUM[,BITNUM...] [X86]
48 + Disable CPUID feature X for the kernel. See
49 + arch/x86/include/asm/cpufeatures.h for the valid bit
50 + numbers. Note the Linux specific bits are not necessarily
51 +diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
52 +index 8d4ad1d1ae26f..8af3771a3ebf2 100644
53 +--- a/Documentation/networking/ip-sysctl.txt
54 ++++ b/Documentation/networking/ip-sysctl.txt
55 +@@ -1000,12 +1000,14 @@ icmp_ratelimit - INTEGER
56 + icmp_msgs_per_sec - INTEGER
57 + Limit maximal number of ICMP packets sent per second from this host.
58 + Only messages whose type matches icmp_ratemask (see below) are
59 +- controlled by this limit.
60 ++ controlled by this limit. For security reasons, the precise count
61 ++ of messages per second is randomized.
62 + Default: 1000
63 +
64 + icmp_msgs_burst - INTEGER
65 + icmp_msgs_per_sec controls number of ICMP packets sent per second,
66 + while icmp_msgs_burst controls the burst size of these packets.
67 ++ For security reasons, the precise burst size is randomized.
68 + Default: 50
69 +
70 + icmp_ratemask - INTEGER
71 +diff --git a/Makefile b/Makefile
72 +index 8db75cc76ed16..f9a8d76a693eb 100644
73 +--- a/Makefile
74 ++++ b/Makefile
75 +@@ -1,7 +1,7 @@
76 + # SPDX-License-Identifier: GPL-2.0
77 + VERSION = 5
78 + PATCHLEVEL = 4
79 +-SUBLEVEL = 72
80 ++SUBLEVEL = 73
81 + EXTRAVERSION =
82 + NAME = Kleptomaniac Octopus
83 +
84 +diff --git a/arch/arc/plat-hsdk/Kconfig b/arch/arc/plat-hsdk/Kconfig
85 +index ce81018345184..6b5c54576f54d 100644
86 +--- a/arch/arc/plat-hsdk/Kconfig
87 ++++ b/arch/arc/plat-hsdk/Kconfig
88 +@@ -8,5 +8,6 @@ menuconfig ARC_SOC_HSDK
89 + select ARC_HAS_ACCL_REGS
90 + select ARC_IRQ_NO_AUTOSAVE
91 + select CLK_HSDK
92 ++ select RESET_CONTROLLER
93 + select RESET_HSDK
94 + select HAVE_PCI
95 +diff --git a/arch/arm/boot/dts/imx6sl.dtsi b/arch/arm/boot/dts/imx6sl.dtsi
96 +index 3a96b5538a2a1..540880f0413fd 100644
97 +--- a/arch/arm/boot/dts/imx6sl.dtsi
98 ++++ b/arch/arm/boot/dts/imx6sl.dtsi
99 +@@ -936,8 +936,10 @@
100 + };
101 +
102 + rngb: rngb@21b4000 {
103 ++ compatible = "fsl,imx6sl-rngb", "fsl,imx25-rngb";
104 + reg = <0x021b4000 0x4000>;
105 + interrupts = <0 5 IRQ_TYPE_LEVEL_HIGH>;
106 ++ clocks = <&clks IMX6SL_CLK_DUMMY>;
107 + };
108 +
109 + weim: weim@21b8000 {
110 +diff --git a/arch/arm/boot/dts/meson8.dtsi b/arch/arm/boot/dts/meson8.dtsi
111 +index db2033f674c67..3efe9d41c2bb6 100644
112 +--- a/arch/arm/boot/dts/meson8.dtsi
113 ++++ b/arch/arm/boot/dts/meson8.dtsi
114 +@@ -230,8 +230,6 @@
115 + <GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>,
116 + <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>,
117 + <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>,
118 +- <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>,
119 +- <GIC_SPI 171 IRQ_TYPE_LEVEL_HIGH>,
120 + <GIC_SPI 172 IRQ_TYPE_LEVEL_HIGH>,
121 + <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>,
122 + <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>,
123 +diff --git a/arch/arm/boot/dts/owl-s500.dtsi b/arch/arm/boot/dts/owl-s500.dtsi
124 +index 5ceb6cc4451d2..1dbe4e8b38ac7 100644
125 +--- a/arch/arm/boot/dts/owl-s500.dtsi
126 ++++ b/arch/arm/boot/dts/owl-s500.dtsi
127 +@@ -84,21 +84,21 @@
128 + global_timer: timer@b0020200 {
129 + compatible = "arm,cortex-a9-global-timer";
130 + reg = <0xb0020200 0x100>;
131 +- interrupts = <GIC_PPI 0 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>;
132 ++ interrupts = <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>;
133 + status = "disabled";
134 + };
135 +
136 + twd_timer: timer@b0020600 {
137 + compatible = "arm,cortex-a9-twd-timer";
138 + reg = <0xb0020600 0x20>;
139 +- interrupts = <GIC_PPI 2 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>;
140 ++ interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>;
141 + status = "disabled";
142 + };
143 +
144 + twd_wdt: wdt@b0020620 {
145 + compatible = "arm,cortex-a9-twd-wdt";
146 + reg = <0xb0020620 0xe0>;
147 +- interrupts = <GIC_PPI 3 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>;
148 ++ interrupts = <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>;
149 + status = "disabled";
150 + };
151 +
152 +diff --git a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
153 +index 42d62d1ba1dc7..ea15073f0c79c 100644
154 +--- a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
155 ++++ b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
156 +@@ -223,16 +223,16 @@
157 + };
158 +
159 + &reg_dc1sw {
160 +- regulator-min-microvolt = <3000000>;
161 +- regulator-max-microvolt = <3000000>;
162 ++ regulator-min-microvolt = <3300000>;
163 ++ regulator-max-microvolt = <3300000>;
164 + regulator-name = "vcc-gmac-phy";
165 + };
166 +
167 + &reg_dcdc1 {
168 + regulator-always-on;
169 +- regulator-min-microvolt = <3000000>;
170 +- regulator-max-microvolt = <3000000>;
171 +- regulator-name = "vcc-3v0";
172 ++ regulator-min-microvolt = <3300000>;
173 ++ regulator-max-microvolt = <3300000>;
174 ++ regulator-name = "vcc-3v3";
175 + };
176 +
177 + &reg_dcdc2 {
178 +diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
179 +index 6bc3000deb86e..676cc2a318f41 100644
180 +--- a/arch/arm/mach-at91/pm.c
181 ++++ b/arch/arm/mach-at91/pm.c
182 +@@ -777,6 +777,7 @@ static void __init at91_pm_init(void (*pm_idle)(void))
183 +
184 + pmc_np = of_find_matching_node_and_match(NULL, atmel_pmc_ids, &of_id);
185 + soc_pm.data.pmc = of_iomap(pmc_np, 0);
186 ++ of_node_put(pmc_np);
187 + if (!soc_pm.data.pmc) {
188 + pr_err("AT91: PM not supported, PMC not found\n");
189 + return;
190 +diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c
191 +index 6f5f89711f256..a92d277f81a08 100644
192 +--- a/arch/arm/mach-omap2/cpuidle44xx.c
193 ++++ b/arch/arm/mach-omap2/cpuidle44xx.c
194 +@@ -174,8 +174,10 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
195 + */
196 + if (mpuss_can_lose_context) {
197 + error = cpu_cluster_pm_enter();
198 +- if (error)
199 ++ if (error) {
200 ++ omap_set_pwrdm_state(mpu_pd, PWRDM_POWER_ON);
201 + goto cpu_cluster_pm_out;
202 ++ }
203 + }
204 + }
205 +
206 +diff --git a/arch/arm/mach-s3c24xx/mach-at2440evb.c b/arch/arm/mach-s3c24xx/mach-at2440evb.c
207 +index 58c5ef3cf1d7e..2d370f7f75fa2 100644
208 +--- a/arch/arm/mach-s3c24xx/mach-at2440evb.c
209 ++++ b/arch/arm/mach-s3c24xx/mach-at2440evb.c
210 +@@ -143,7 +143,7 @@ static struct gpiod_lookup_table at2440evb_mci_gpio_table = {
211 + .dev_id = "s3c2410-sdi",
212 + .table = {
213 + /* Card detect S3C2410_GPG(10) */
214 +- GPIO_LOOKUP("GPG", 10, "cd", GPIO_ACTIVE_LOW),
215 ++ GPIO_LOOKUP("GPIOG", 10, "cd", GPIO_ACTIVE_LOW),
216 + { },
217 + },
218 + };
219 +diff --git a/arch/arm/mach-s3c24xx/mach-h1940.c b/arch/arm/mach-s3c24xx/mach-h1940.c
220 +index 74d6b68e91c74..8d9d8e7c71d4c 100644
221 +--- a/arch/arm/mach-s3c24xx/mach-h1940.c
222 ++++ b/arch/arm/mach-s3c24xx/mach-h1940.c
223 +@@ -468,9 +468,9 @@ static struct gpiod_lookup_table h1940_mmc_gpio_table = {
224 + .dev_id = "s3c2410-sdi",
225 + .table = {
226 + /* Card detect S3C2410_GPF(5) */
227 +- GPIO_LOOKUP("GPF", 5, "cd", GPIO_ACTIVE_LOW),
228 ++ GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW),
229 + /* Write protect S3C2410_GPH(8) */
230 +- GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_LOW),
231 ++ GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW),
232 + { },
233 + },
234 + };
235 +diff --git a/arch/arm/mach-s3c24xx/mach-mini2440.c b/arch/arm/mach-s3c24xx/mach-mini2440.c
236 +index 9035f868fb34e..3a5b1124037b2 100644
237 +--- a/arch/arm/mach-s3c24xx/mach-mini2440.c
238 ++++ b/arch/arm/mach-s3c24xx/mach-mini2440.c
239 +@@ -244,9 +244,9 @@ static struct gpiod_lookup_table mini2440_mmc_gpio_table = {
240 + .dev_id = "s3c2410-sdi",
241 + .table = {
242 + /* Card detect S3C2410_GPG(8) */
243 +- GPIO_LOOKUP("GPG", 8, "cd", GPIO_ACTIVE_LOW),
244 ++ GPIO_LOOKUP("GPIOG", 8, "cd", GPIO_ACTIVE_LOW),
245 + /* Write protect S3C2410_GPH(8) */
246 +- GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_HIGH),
247 ++ GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_HIGH),
248 + { },
249 + },
250 + };
251 +diff --git a/arch/arm/mach-s3c24xx/mach-n30.c b/arch/arm/mach-s3c24xx/mach-n30.c
252 +index d856f23939aff..ffa20f52aa832 100644
253 +--- a/arch/arm/mach-s3c24xx/mach-n30.c
254 ++++ b/arch/arm/mach-s3c24xx/mach-n30.c
255 +@@ -359,9 +359,9 @@ static struct gpiod_lookup_table n30_mci_gpio_table = {
256 + .dev_id = "s3c2410-sdi",
257 + .table = {
258 + /* Card detect S3C2410_GPF(1) */
259 +- GPIO_LOOKUP("GPF", 1, "cd", GPIO_ACTIVE_LOW),
260 ++ GPIO_LOOKUP("GPIOF", 1, "cd", GPIO_ACTIVE_LOW),
261 + /* Write protect S3C2410_GPG(10) */
262 +- GPIO_LOOKUP("GPG", 10, "wp", GPIO_ACTIVE_LOW),
263 ++ GPIO_LOOKUP("GPIOG", 10, "wp", GPIO_ACTIVE_LOW),
264 + { },
265 + },
266 + };
267 +diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c
268 +index 29f9b345a5311..534e9c1d8161f 100644
269 +--- a/arch/arm/mach-s3c24xx/mach-rx1950.c
270 ++++ b/arch/arm/mach-s3c24xx/mach-rx1950.c
271 +@@ -567,9 +567,9 @@ static struct gpiod_lookup_table rx1950_mmc_gpio_table = {
272 + .dev_id = "s3c2410-sdi",
273 + .table = {
274 + /* Card detect S3C2410_GPF(5) */
275 +- GPIO_LOOKUP("GPF", 5, "cd", GPIO_ACTIVE_LOW),
276 ++ GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW),
277 + /* Write protect S3C2410_GPH(8) */
278 +- GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_LOW),
279 ++ GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW),
280 + { },
281 + },
282 + };
283 +diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
284 +index 12c26eb88afbc..43d91bfd23600 100644
285 +--- a/arch/arm/mm/cache-l2x0.c
286 ++++ b/arch/arm/mm/cache-l2x0.c
287 +@@ -1249,20 +1249,28 @@ static void __init l2c310_of_parse(const struct device_node *np,
288 +
289 + ret = of_property_read_u32(np, "prefetch-data", &val);
290 + if (ret == 0) {
291 +- if (val)
292 ++ if (val) {
293 + prefetch |= L310_PREFETCH_CTRL_DATA_PREFETCH;
294 +- else
295 ++ *aux_val |= L310_PREFETCH_CTRL_DATA_PREFETCH;
296 ++ } else {
297 + prefetch &= ~L310_PREFETCH_CTRL_DATA_PREFETCH;
298 ++ *aux_val &= ~L310_PREFETCH_CTRL_DATA_PREFETCH;
299 ++ }
300 ++ *aux_mask &= ~L310_PREFETCH_CTRL_DATA_PREFETCH;
301 + } else if (ret != -EINVAL) {
302 + pr_err("L2C-310 OF prefetch-data property value is missing\n");
303 + }
304 +
305 + ret = of_property_read_u32(np, "prefetch-instr", &val);
306 + if (ret == 0) {
307 +- if (val)
308 ++ if (val) {
309 + prefetch |= L310_PREFETCH_CTRL_INSTR_PREFETCH;
310 +- else
311 ++ *aux_val |= L310_PREFETCH_CTRL_INSTR_PREFETCH;
312 ++ } else {
313 + prefetch &= ~L310_PREFETCH_CTRL_INSTR_PREFETCH;
314 ++ *aux_val &= ~L310_PREFETCH_CTRL_INSTR_PREFETCH;
315 ++ }
316 ++ *aux_mask &= ~L310_PREFETCH_CTRL_INSTR_PREFETCH;
317 + } else if (ret != -EINVAL) {
318 + pr_err("L2C-310 OF prefetch-instr property value is missing\n");
319 + }
320 +diff --git a/arch/arm64/boot/dts/actions/s700.dtsi b/arch/arm64/boot/dts/actions/s700.dtsi
321 +index 2006ad5424fa6..f8eb72bb41254 100644
322 +--- a/arch/arm64/boot/dts/actions/s700.dtsi
323 ++++ b/arch/arm64/boot/dts/actions/s700.dtsi
324 +@@ -231,7 +231,7 @@
325 +
326 + pinctrl: pinctrl@e01b0000 {
327 + compatible = "actions,s700-pinctrl";
328 +- reg = <0x0 0xe01b0000 0x0 0x1000>;
329 ++ reg = <0x0 0xe01b0000 0x0 0x100>;
330 + clocks = <&cmu CLK_GPIO>;
331 + gpio-controller;
332 + gpio-ranges = <&pinctrl 0 0 136>;
333 +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
334 +index eaf8f83794fd9..8466d44ee0b15 100644
335 +--- a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
336 ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
337 +@@ -155,8 +155,7 @@
338 + <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>,
339 + <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>,
340 + <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>,
341 +- <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>,
342 +- <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
343 ++ <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
344 + interrupt-names = "gp",
345 + "gpmmu",
346 + "pp",
347 +@@ -167,8 +166,7 @@
348 + "pp2",
349 + "ppmmu2",
350 + "pp3",
351 +- "ppmmu3",
352 +- "pmu";
353 ++ "ppmmu3";
354 + clocks = <&ccu CLK_BUS_GPU>, <&ccu CLK_GPU>;
355 + clock-names = "bus", "core";
356 + resets = <&ccu RST_BUS_GPU>;
357 +diff --git a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
358 +index 8647da7d6609b..f6694aad84db3 100644
359 +--- a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
360 ++++ b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
361 +@@ -43,13 +43,13 @@
362 +
363 + white {
364 + label = "vim3:white:sys";
365 +- gpios = <&gpio_ao GPIOAO_4 GPIO_ACTIVE_LOW>;
366 ++ gpios = <&gpio_ao GPIOAO_4 GPIO_ACTIVE_HIGH>;
367 + linux,default-trigger = "heartbeat";
368 + };
369 +
370 + red {
371 + label = "vim3:red";
372 +- gpios = <&gpio_expander 5 GPIO_ACTIVE_LOW>;
373 ++ gpios = <&gpio_expander 5 GPIO_ACTIVE_HIGH>;
374 + };
375 + };
376 +
377 +diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
378 +index bc8540f879654..f1011bcd5ed5a 100644
379 +--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
380 ++++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
381 +@@ -516,6 +516,7 @@
382 + gpc: gpc@303a0000 {
383 + compatible = "fsl,imx8mq-gpc";
384 + reg = <0x303a0000 0x10000>;
385 ++ interrupts = <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>;
386 + interrupt-parent = <&gic>;
387 + interrupt-controller;
388 + #interrupt-cells = <3>;
389 +diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
390 +index 340da154d4e37..d95273af9f1e4 100644
391 +--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
392 ++++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
393 +@@ -175,14 +175,14 @@
394 + };
395 +
396 + thermal-zones {
397 +- cpu0_1-thermal {
398 ++ cpu0-1-thermal {
399 + polling-delay-passive = <250>;
400 + polling-delay = <1000>;
401 +
402 + thermal-sensors = <&tsens 4>;
403 +
404 + trips {
405 +- cpu0_1_alert0: trip-point@0 {
406 ++ cpu0_1_alert0: trip-point0 {
407 + temperature = <75000>;
408 + hysteresis = <2000>;
409 + type = "passive";
410 +@@ -205,7 +205,7 @@
411 + };
412 + };
413 +
414 +- cpu2_3-thermal {
415 ++ cpu2-3-thermal {
416 + polling-delay-passive = <250>;
417 + polling-delay = <1000>;
418 +
419 +@@ -934,7 +934,7 @@
420 + reg-names = "mdp_phys";
421 +
422 + interrupt-parent = <&mdss>;
423 +- interrupts = <0 0>;
424 ++ interrupts = <0>;
425 +
426 + clocks = <&gcc GCC_MDSS_AHB_CLK>,
427 + <&gcc GCC_MDSS_AXI_CLK>,
428 +@@ -966,7 +966,7 @@
429 + reg-names = "dsi_ctrl";
430 +
431 + interrupt-parent = <&mdss>;
432 +- interrupts = <4 0>;
433 ++ interrupts = <4>;
434 +
435 + assigned-clocks = <&gcc BYTE0_CLK_SRC>,
436 + <&gcc PCLK0_CLK_SRC>;
437 +diff --git a/arch/arm64/boot/dts/qcom/pm8916.dtsi b/arch/arm64/boot/dts/qcom/pm8916.dtsi
438 +index 9dd2df1cbf47d..40df4d95a47ac 100644
439 +--- a/arch/arm64/boot/dts/qcom/pm8916.dtsi
440 ++++ b/arch/arm64/boot/dts/qcom/pm8916.dtsi
441 +@@ -113,7 +113,7 @@
442 +
443 + wcd_codec: codec@f000 {
444 + compatible = "qcom,pm8916-wcd-analog-codec";
445 +- reg = <0xf000 0x200>;
446 ++ reg = <0xf000>;
447 + reg-names = "pmic-codec-core";
448 + clocks = <&gcc GCC_CODEC_DIGCODEC_CLK>;
449 + clock-names = "mclk";
450 +diff --git a/arch/arm64/boot/dts/renesas/r8a774c0.dtsi b/arch/arm64/boot/dts/renesas/r8a774c0.dtsi
451 +index a1c2de90e4706..73ded80a79ba0 100644
452 +--- a/arch/arm64/boot/dts/renesas/r8a774c0.dtsi
453 ++++ b/arch/arm64/boot/dts/renesas/r8a774c0.dtsi
454 +@@ -1212,9 +1212,8 @@
455 + reg = <0 0xe6ea0000 0 0x0064>;
456 + interrupts = <GIC_SPI 157 IRQ_TYPE_LEVEL_HIGH>;
457 + clocks = <&cpg CPG_MOD 210>;
458 +- dmas = <&dmac1 0x43>, <&dmac1 0x42>,
459 +- <&dmac2 0x43>, <&dmac2 0x42>;
460 +- dma-names = "tx", "rx", "tx", "rx";
461 ++ dmas = <&dmac0 0x43>, <&dmac0 0x42>;
462 ++ dma-names = "tx", "rx";
463 + power-domains = <&sysc R8A774C0_PD_ALWAYS_ON>;
464 + resets = <&cpg 210>;
465 + #address-cells = <1>;
466 +diff --git a/arch/arm64/boot/dts/renesas/r8a77990.dtsi b/arch/arm64/boot/dts/renesas/r8a77990.dtsi
467 +index 455954c3d98ea..dabee157119f9 100644
468 +--- a/arch/arm64/boot/dts/renesas/r8a77990.dtsi
469 ++++ b/arch/arm64/boot/dts/renesas/r8a77990.dtsi
470 +@@ -1168,9 +1168,8 @@
471 + reg = <0 0xe6ea0000 0 0x0064>;
472 + interrupts = <GIC_SPI 157 IRQ_TYPE_LEVEL_HIGH>;
473 + clocks = <&cpg CPG_MOD 210>;
474 +- dmas = <&dmac1 0x43>, <&dmac1 0x42>,
475 +- <&dmac2 0x43>, <&dmac2 0x42>;
476 +- dma-names = "tx", "rx", "tx", "rx";
477 ++ dmas = <&dmac0 0x43>, <&dmac0 0x42>;
478 ++ dma-names = "tx", "rx";
479 + power-domains = <&sysc R8A77990_PD_ALWAYS_ON>;
480 + resets = <&cpg 210>;
481 + #address-cells = <1>;
482 +diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
483 +index 9aa67340a4d8c..a2645262f8623 100644
484 +--- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
485 ++++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
486 +@@ -419,7 +419,7 @@
487 + };
488 +
489 + i2c0: i2c@ff020000 {
490 +- compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
491 ++ compatible = "cdns,i2c-r1p14";
492 + status = "disabled";
493 + interrupt-parent = <&gic>;
494 + interrupts = <0 17 4>;
495 +@@ -429,7 +429,7 @@
496 + };
497 +
498 + i2c1: i2c@ff030000 {
499 +- compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
500 ++ compatible = "cdns,i2c-r1p14";
501 + status = "disabled";
502 + interrupt-parent = <&gic>;
503 + interrupts = <0 18 4>;
504 +diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/include/asm/book3s/64/hash-4k.h
505 +index 3f9ae3585ab98..80c9534148821 100644
506 +--- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
507 ++++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
508 +@@ -13,20 +13,19 @@
509 + */
510 + #define MAX_EA_BITS_PER_CONTEXT 46
511 +
512 +-#define REGION_SHIFT (MAX_EA_BITS_PER_CONTEXT - 2)
513 +
514 + /*
515 +- * Our page table limit us to 64TB. Hence for the kernel mapping,
516 +- * each MAP area is limited to 16 TB.
517 +- * The four map areas are: linear mapping, vmap, IO and vmemmap
518 ++ * Our page table limit us to 64TB. For 64TB physical memory, we only need 64GB
519 ++ * of vmemmap space. To better support sparse memory layout, we use 61TB
520 ++ * linear map range, 1TB of vmalloc, 1TB of I/O and 1TB of vmememmap.
521 + */
522 ++#define REGION_SHIFT (40)
523 + #define H_KERN_MAP_SIZE (ASM_CONST(1) << REGION_SHIFT)
524 +
525 + /*
526 +- * Define the address range of the kernel non-linear virtual area
527 +- * 16TB
528 ++ * Define the address range of the kernel non-linear virtual area (61TB)
529 + */
530 +-#define H_KERN_VIRT_START ASM_CONST(0xc000100000000000)
531 ++#define H_KERN_VIRT_START ASM_CONST(0xc0003d0000000000)
532 +
533 + #ifndef __ASSEMBLY__
534 + #define H_PTE_TABLE_SIZE (sizeof(pte_t) << H_PTE_INDEX_SIZE)
535 +diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h
536 +index 28c3d936fdf32..bea7a2405ba5d 100644
537 +--- a/arch/powerpc/include/asm/drmem.h
538 ++++ b/arch/powerpc/include/asm/drmem.h
539 +@@ -8,14 +8,13 @@
540 + #ifndef _ASM_POWERPC_LMB_H
541 + #define _ASM_POWERPC_LMB_H
542 +
543 ++#include <linux/sched.h>
544 ++
545 + struct drmem_lmb {
546 + u64 base_addr;
547 + u32 drc_index;
548 + u32 aa_index;
549 + u32 flags;
550 +-#ifdef CONFIG_MEMORY_HOTPLUG
551 +- int nid;
552 +-#endif
553 + };
554 +
555 + struct drmem_lmb_info {
556 +@@ -26,8 +25,22 @@ struct drmem_lmb_info {
557 +
558 + extern struct drmem_lmb_info *drmem_info;
559 +
560 ++static inline struct drmem_lmb *drmem_lmb_next(struct drmem_lmb *lmb,
561 ++ const struct drmem_lmb *start)
562 ++{
563 ++ /*
564 ++ * DLPAR code paths can take several milliseconds per element
565 ++ * when interacting with firmware. Ensure that we don't
566 ++ * unfairly monopolize the CPU.
567 ++ */
568 ++ if (((++lmb - start) % 16) == 0)
569 ++ cond_resched();
570 ++
571 ++ return lmb;
572 ++}
573 ++
574 + #define for_each_drmem_lmb_in_range(lmb, start, end) \
575 +- for ((lmb) = (start); (lmb) < (end); (lmb)++)
576 ++ for ((lmb) = (start); (lmb) < (end); lmb = drmem_lmb_next(lmb, start))
577 +
578 + #define for_each_drmem_lmb(lmb) \
579 + for_each_drmem_lmb_in_range((lmb), \
580 +@@ -103,22 +116,4 @@ static inline void invalidate_lmb_associativity_index(struct drmem_lmb *lmb)
581 + lmb->aa_index = 0xffffffff;
582 + }
583 +
584 +-#ifdef CONFIG_MEMORY_HOTPLUG
585 +-static inline void lmb_set_nid(struct drmem_lmb *lmb)
586 +-{
587 +- lmb->nid = memory_add_physaddr_to_nid(lmb->base_addr);
588 +-}
589 +-static inline void lmb_clear_nid(struct drmem_lmb *lmb)
590 +-{
591 +- lmb->nid = -1;
592 +-}
593 +-#else
594 +-static inline void lmb_set_nid(struct drmem_lmb *lmb)
595 +-{
596 +-}
597 +-static inline void lmb_clear_nid(struct drmem_lmb *lmb)
598 +-{
599 +-}
600 +-#endif
601 +-
602 + #endif /* _ASM_POWERPC_LMB_H */
603 +diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
604 +index b3cbb1136bce0..34d08ff21b988 100644
605 +--- a/arch/powerpc/include/asm/reg.h
606 ++++ b/arch/powerpc/include/asm/reg.h
607 +@@ -796,7 +796,7 @@
608 + #define THRM1_TIN (1 << 31)
609 + #define THRM1_TIV (1 << 30)
610 + #define THRM1_THRES(x) ((x&0x7f)<<23)
611 +-#define THRM3_SITV(x) ((x&0x3fff)<<1)
612 ++#define THRM3_SITV(x) ((x & 0x1fff) << 1)
613 + #define THRM1_TID (1<<2)
614 + #define THRM1_TIE (1<<1)
615 + #define THRM1_V (1<<0)
616 +diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tlb.h
617 +index 7f3a8b9023254..02a1c18cdba3d 100644
618 +--- a/arch/powerpc/include/asm/tlb.h
619 ++++ b/arch/powerpc/include/asm/tlb.h
620 +@@ -67,19 +67,6 @@ static inline int mm_is_thread_local(struct mm_struct *mm)
621 + return false;
622 + return cpumask_test_cpu(smp_processor_id(), mm_cpumask(mm));
623 + }
624 +-static inline void mm_reset_thread_local(struct mm_struct *mm)
625 +-{
626 +- WARN_ON(atomic_read(&mm->context.copros) > 0);
627 +- /*
628 +- * It's possible for mm_access to take a reference on mm_users to
629 +- * access the remote mm from another thread, but it's not allowed
630 +- * to set mm_cpumask, so mm_users may be > 1 here.
631 +- */
632 +- WARN_ON(current->mm != mm);
633 +- atomic_set(&mm->context.active_cpus, 1);
634 +- cpumask_clear(mm_cpumask(mm));
635 +- cpumask_set_cpu(smp_processor_id(), mm_cpumask(mm));
636 +-}
637 + #else /* CONFIG_PPC_BOOK3S_64 */
638 + static inline int mm_is_thread_local(struct mm_struct *mm)
639 + {
640 +diff --git a/arch/powerpc/kernel/tau_6xx.c b/arch/powerpc/kernel/tau_6xx.c
641 +index e2ab8a111b693..0b4694b8d2482 100644
642 +--- a/arch/powerpc/kernel/tau_6xx.c
643 ++++ b/arch/powerpc/kernel/tau_6xx.c
644 +@@ -13,13 +13,14 @@
645 + */
646 +
647 + #include <linux/errno.h>
648 +-#include <linux/jiffies.h>
649 + #include <linux/kernel.h>
650 + #include <linux/param.h>
651 + #include <linux/string.h>
652 + #include <linux/mm.h>
653 + #include <linux/interrupt.h>
654 + #include <linux/init.h>
655 ++#include <linux/delay.h>
656 ++#include <linux/workqueue.h>
657 +
658 + #include <asm/io.h>
659 + #include <asm/reg.h>
660 +@@ -39,9 +40,7 @@ static struct tau_temp
661 + unsigned char grew;
662 + } tau[NR_CPUS];
663 +
664 +-struct timer_list tau_timer;
665 +-
666 +-#undef DEBUG
667 ++static bool tau_int_enable;
668 +
669 + /* TODO: put these in a /proc interface, with some sanity checks, and maybe
670 + * dynamic adjustment to minimize # of interrupts */
671 +@@ -50,72 +49,49 @@ struct timer_list tau_timer;
672 + #define step_size 2 /* step size when temp goes out of range */
673 + #define window_expand 1 /* expand the window by this much */
674 + /* configurable values for shrinking the window */
675 +-#define shrink_timer 2*HZ /* period between shrinking the window */
676 ++#define shrink_timer 2000 /* period between shrinking the window */
677 + #define min_window 2 /* minimum window size, degrees C */
678 +
679 + static void set_thresholds(unsigned long cpu)
680 + {
681 +-#ifdef CONFIG_TAU_INT
682 +- /*
683 +- * setup THRM1,
684 +- * threshold, valid bit, enable interrupts, interrupt when below threshold
685 +- */
686 +- mtspr(SPRN_THRM1, THRM1_THRES(tau[cpu].low) | THRM1_V | THRM1_TIE | THRM1_TID);
687 ++ u32 maybe_tie = tau_int_enable ? THRM1_TIE : 0;
688 +
689 +- /* setup THRM2,
690 +- * threshold, valid bit, enable interrupts, interrupt when above threshold
691 +- */
692 +- mtspr (SPRN_THRM2, THRM1_THRES(tau[cpu].high) | THRM1_V | THRM1_TIE);
693 +-#else
694 +- /* same thing but don't enable interrupts */
695 +- mtspr(SPRN_THRM1, THRM1_THRES(tau[cpu].low) | THRM1_V | THRM1_TID);
696 +- mtspr(SPRN_THRM2, THRM1_THRES(tau[cpu].high) | THRM1_V);
697 +-#endif
698 ++ /* setup THRM1, threshold, valid bit, interrupt when below threshold */
699 ++ mtspr(SPRN_THRM1, THRM1_THRES(tau[cpu].low) | THRM1_V | maybe_tie | THRM1_TID);
700 ++
701 ++ /* setup THRM2, threshold, valid bit, interrupt when above threshold */
702 ++ mtspr(SPRN_THRM2, THRM1_THRES(tau[cpu].high) | THRM1_V | maybe_tie);
703 + }
704 +
705 + static void TAUupdate(int cpu)
706 + {
707 +- unsigned thrm;
708 +-
709 +-#ifdef DEBUG
710 +- printk("TAUupdate ");
711 +-#endif
712 ++ u32 thrm;
713 ++ u32 bits = THRM1_TIV | THRM1_TIN | THRM1_V;
714 +
715 + /* if both thresholds are crossed, the step_sizes cancel out
716 + * and the window winds up getting expanded twice. */
717 +- if((thrm = mfspr(SPRN_THRM1)) & THRM1_TIV){ /* is valid? */
718 +- if(thrm & THRM1_TIN){ /* crossed low threshold */
719 +- if (tau[cpu].low >= step_size){
720 +- tau[cpu].low -= step_size;
721 +- tau[cpu].high -= (step_size - window_expand);
722 +- }
723 +- tau[cpu].grew = 1;
724 +-#ifdef DEBUG
725 +- printk("low threshold crossed ");
726 +-#endif
727 ++ thrm = mfspr(SPRN_THRM1);
728 ++ if ((thrm & bits) == bits) {
729 ++ mtspr(SPRN_THRM1, 0);
730 ++
731 ++ if (tau[cpu].low >= step_size) {
732 ++ tau[cpu].low -= step_size;
733 ++ tau[cpu].high -= (step_size - window_expand);
734 + }
735 ++ tau[cpu].grew = 1;
736 ++ pr_debug("%s: low threshold crossed\n", __func__);
737 + }
738 +- if((thrm = mfspr(SPRN_THRM2)) & THRM1_TIV){ /* is valid? */
739 +- if(thrm & THRM1_TIN){ /* crossed high threshold */
740 +- if (tau[cpu].high <= 127-step_size){
741 +- tau[cpu].low += (step_size - window_expand);
742 +- tau[cpu].high += step_size;
743 +- }
744 +- tau[cpu].grew = 1;
745 +-#ifdef DEBUG
746 +- printk("high threshold crossed ");
747 +-#endif
748 ++ thrm = mfspr(SPRN_THRM2);
749 ++ if ((thrm & bits) == bits) {
750 ++ mtspr(SPRN_THRM2, 0);
751 ++
752 ++ if (tau[cpu].high <= 127 - step_size) {
753 ++ tau[cpu].low += (step_size - window_expand);
754 ++ tau[cpu].high += step_size;
755 + }
756 ++ tau[cpu].grew = 1;
757 ++ pr_debug("%s: high threshold crossed\n", __func__);
758 + }
759 +-
760 +-#ifdef DEBUG
761 +- printk("grew = %d\n", tau[cpu].grew);
762 +-#endif
763 +-
764 +-#ifndef CONFIG_TAU_INT /* tau_timeout will do this if not using interrupts */
765 +- set_thresholds(cpu);
766 +-#endif
767 +-
768 + }
769 +
770 + #ifdef CONFIG_TAU_INT
771 +@@ -140,17 +116,16 @@ void TAUException(struct pt_regs * regs)
772 + static void tau_timeout(void * info)
773 + {
774 + int cpu;
775 +- unsigned long flags;
776 + int size;
777 + int shrink;
778 +
779 +- /* disabling interrupts *should* be okay */
780 +- local_irq_save(flags);
781 + cpu = smp_processor_id();
782 +
783 +-#ifndef CONFIG_TAU_INT
784 +- TAUupdate(cpu);
785 +-#endif
786 ++ if (!tau_int_enable)
787 ++ TAUupdate(cpu);
788 ++
789 ++ /* Stop thermal sensor comparisons and interrupts */
790 ++ mtspr(SPRN_THRM3, 0);
791 +
792 + size = tau[cpu].high - tau[cpu].low;
793 + if (size > min_window && ! tau[cpu].grew) {
794 +@@ -173,32 +148,26 @@ static void tau_timeout(void * info)
795 +
796 + set_thresholds(cpu);
797 +
798 +- /*
799 +- * Do the enable every time, since otherwise a bunch of (relatively)
800 +- * complex sleep code needs to be added. One mtspr every time
801 +- * tau_timeout is called is probably not a big deal.
802 +- *
803 +- * Enable thermal sensor and set up sample interval timer
804 +- * need 20 us to do the compare.. until a nice 'cpu_speed' function
805 +- * call is implemented, just assume a 500 mhz clock. It doesn't really
806 +- * matter if we take too long for a compare since it's all interrupt
807 +- * driven anyway.
808 +- *
809 +- * use a extra long time.. (60 us @ 500 mhz)
810 ++ /* Restart thermal sensor comparisons and interrupts.
811 ++ * The "PowerPC 740 and PowerPC 750 Microprocessor Datasheet"
812 ++ * recommends that "the maximum value be set in THRM3 under all
813 ++ * conditions."
814 + */
815 +- mtspr(SPRN_THRM3, THRM3_SITV(500*60) | THRM3_E);
816 +-
817 +- local_irq_restore(flags);
818 ++ mtspr(SPRN_THRM3, THRM3_SITV(0x1fff) | THRM3_E);
819 + }
820 +
821 +-static void tau_timeout_smp(struct timer_list *unused)
822 +-{
823 ++static struct workqueue_struct *tau_workq;
824 +
825 +- /* schedule ourselves to be run again */
826 +- mod_timer(&tau_timer, jiffies + shrink_timer) ;
827 ++static void tau_work_func(struct work_struct *work)
828 ++{
829 ++ msleep(shrink_timer);
830 + on_each_cpu(tau_timeout, NULL, 0);
831 ++ /* schedule ourselves to be run again */
832 ++ queue_work(tau_workq, work);
833 + }
834 +
835 ++DECLARE_WORK(tau_work, tau_work_func);
836 ++
837 + /*
838 + * setup the TAU
839 + *
840 +@@ -231,21 +200,19 @@ static int __init TAU_init(void)
841 + return 1;
842 + }
843 +
844 ++ tau_int_enable = IS_ENABLED(CONFIG_TAU_INT) &&
845 ++ !strcmp(cur_cpu_spec->platform, "ppc750");
846 +
847 +- /* first, set up the window shrinking timer */
848 +- timer_setup(&tau_timer, tau_timeout_smp, 0);
849 +- tau_timer.expires = jiffies + shrink_timer;
850 +- add_timer(&tau_timer);
851 ++ tau_workq = alloc_workqueue("tau", WQ_UNBOUND, 1, 0);
852 ++ if (!tau_workq)
853 ++ return -ENOMEM;
854 +
855 + on_each_cpu(TAU_init_smp, NULL, 0);
856 +
857 +- printk("Thermal assist unit ");
858 +-#ifdef CONFIG_TAU_INT
859 +- printk("using interrupts, ");
860 +-#else
861 +- printk("using timers, ");
862 +-#endif
863 +- printk("shrink_timer: %d jiffies\n", shrink_timer);
864 ++ queue_work(tau_workq, &tau_work);
865 ++
866 ++ pr_info("Thermal assist unit using %s, shrink_timer: %d ms\n",
867 ++ tau_int_enable ? "interrupts" : "workqueue", shrink_timer);
868 + tau_initialized = 1;
869 +
870 + return 0;
871 +diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book3s64/radix_tlb.c
872 +index 67af871190c6d..b0f240afffa22 100644
873 +--- a/arch/powerpc/mm/book3s64/radix_tlb.c
874 ++++ b/arch/powerpc/mm/book3s64/radix_tlb.c
875 +@@ -639,19 +639,29 @@ static void do_exit_flush_lazy_tlb(void *arg)
876 + struct mm_struct *mm = arg;
877 + unsigned long pid = mm->context.id;
878 +
879 ++ /*
880 ++ * A kthread could have done a mmget_not_zero() after the flushing CPU
881 ++ * checked mm_is_singlethreaded, and be in the process of
882 ++ * kthread_use_mm when interrupted here. In that case, current->mm will
883 ++ * be set to mm, because kthread_use_mm() setting ->mm and switching to
884 ++ * the mm is done with interrupts off.
885 ++ */
886 + if (current->mm == mm)
887 +- return; /* Local CPU */
888 ++ goto out_flush;
889 +
890 + if (current->active_mm == mm) {
891 +- /*
892 +- * Must be a kernel thread because sender is single-threaded.
893 +- */
894 +- BUG_ON(current->mm);
895 ++ WARN_ON_ONCE(current->mm != NULL);
896 ++ /* Is a kernel thread and is using mm as the lazy tlb */
897 + mmgrab(&init_mm);
898 +- switch_mm(mm, &init_mm, current);
899 + current->active_mm = &init_mm;
900 ++ switch_mm_irqs_off(mm, &init_mm, current);
901 + mmdrop(mm);
902 + }
903 ++
904 ++ atomic_dec(&mm->context.active_cpus);
905 ++ cpumask_clear_cpu(smp_processor_id(), mm_cpumask(mm));
906 ++
907 ++out_flush:
908 + _tlbiel_pid(pid, RIC_FLUSH_ALL);
909 + }
910 +
911 +@@ -666,7 +676,6 @@ static void exit_flush_lazy_tlbs(struct mm_struct *mm)
912 + */
913 + smp_call_function_many(mm_cpumask(mm), do_exit_flush_lazy_tlb,
914 + (void *)mm, 1);
915 +- mm_reset_thread_local(mm);
916 + }
917 +
918 + void radix__flush_tlb_mm(struct mm_struct *mm)
919 +diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c
920 +index 59327cefbc6a6..873fcfc7b8756 100644
921 +--- a/arch/powerpc/mm/drmem.c
922 ++++ b/arch/powerpc/mm/drmem.c
923 +@@ -362,10 +362,8 @@ static void __init init_drmem_v1_lmbs(const __be32 *prop)
924 + if (!drmem_info->lmbs)
925 + return;
926 +
927 +- for_each_drmem_lmb(lmb) {
928 ++ for_each_drmem_lmb(lmb)
929 + read_drconf_v1_cell(lmb, &prop);
930 +- lmb_set_nid(lmb);
931 +- }
932 + }
933 +
934 + static void __init init_drmem_v2_lmbs(const __be32 *prop)
935 +@@ -410,8 +408,6 @@ static void __init init_drmem_v2_lmbs(const __be32 *prop)
936 +
937 + lmb->aa_index = dr_cell.aa_index;
938 + lmb->flags = dr_cell.flags;
939 +-
940 +- lmb_set_nid(lmb);
941 + }
942 + }
943 + }
944 +diff --git a/arch/powerpc/perf/hv-gpci-requests.h b/arch/powerpc/perf/hv-gpci-requests.h
945 +index e608f9db12ddc..8965b4463d433 100644
946 +--- a/arch/powerpc/perf/hv-gpci-requests.h
947 ++++ b/arch/powerpc/perf/hv-gpci-requests.h
948 +@@ -95,7 +95,7 @@ REQUEST(__field(0, 8, partition_id)
949 +
950 + #define REQUEST_NAME system_performance_capabilities
951 + #define REQUEST_NUM 0x40
952 +-#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff"
953 ++#define REQUEST_IDX_KIND "starting_index=0xffffffff"
954 + #include I(REQUEST_BEGIN)
955 + REQUEST(__field(0, 1, perf_collect_privileged)
956 + __field(0x1, 1, capability_mask)
957 +@@ -223,7 +223,7 @@ REQUEST(__field(0, 2, partition_id)
958 +
959 + #define REQUEST_NAME system_hypervisor_times
960 + #define REQUEST_NUM 0xF0
961 +-#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff"
962 ++#define REQUEST_IDX_KIND "starting_index=0xffffffff"
963 + #include I(REQUEST_BEGIN)
964 + REQUEST(__count(0, 8, time_spent_to_dispatch_virtual_processors)
965 + __count(0x8, 8, time_spent_processing_virtual_processor_timers)
966 +@@ -234,7 +234,7 @@ REQUEST(__count(0, 8, time_spent_to_dispatch_virtual_processors)
967 +
968 + #define REQUEST_NAME system_tlbie_count_and_time
969 + #define REQUEST_NUM 0xF4
970 +-#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff"
971 ++#define REQUEST_IDX_KIND "starting_index=0xffffffff"
972 + #include I(REQUEST_BEGIN)
973 + REQUEST(__count(0, 8, tlbie_instructions_issued)
974 + /*
975 +diff --git a/arch/powerpc/perf/isa207-common.c b/arch/powerpc/perf/isa207-common.c
976 +index 4c86da5eb28ab..0b5c8f4fbdbfd 100644
977 +--- a/arch/powerpc/perf/isa207-common.c
978 ++++ b/arch/powerpc/perf/isa207-common.c
979 +@@ -269,6 +269,15 @@ int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp)
980 +
981 + mask |= CNST_PMC_MASK(pmc);
982 + value |= CNST_PMC_VAL(pmc);
983 ++
984 ++ /*
985 ++ * PMC5 and PMC6 are used to count cycles and instructions and
986 ++ * they do not support most of the constraint bits. Add a check
987 ++ * to exclude PMC5/6 from most of the constraints except for
988 ++ * EBB/BHRB.
989 ++ */
990 ++ if (pmc >= 5)
991 ++ goto ebb_bhrb;
992 + }
993 +
994 + if (pmc <= 4) {
995 +@@ -335,6 +344,7 @@ int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp)
996 + }
997 + }
998 +
999 ++ebb_bhrb:
1000 + if (!pmc && ebb)
1001 + /* EBB events must specify the PMC */
1002 + return -1;
1003 +diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
1004 +index d82e3664ffdf8..18792a5b003a0 100644
1005 +--- a/arch/powerpc/platforms/Kconfig
1006 ++++ b/arch/powerpc/platforms/Kconfig
1007 +@@ -219,12 +219,11 @@ config TAU
1008 + temperature within 2-4 degrees Celsius. This option shows the current
1009 + on-die temperature in /proc/cpuinfo if the cpu supports it.
1010 +
1011 +- Unfortunately, on some chip revisions, this sensor is very inaccurate
1012 +- and in many cases, does not work at all, so don't assume the cpu
1013 +- temp is actually what /proc/cpuinfo says it is.
1014 ++ Unfortunately, this sensor is very inaccurate when uncalibrated, so
1015 ++ don't assume the cpu temp is actually what /proc/cpuinfo says it is.
1016 +
1017 + config TAU_INT
1018 +- bool "Interrupt driven TAU driver (DANGEROUS)"
1019 ++ bool "Interrupt driven TAU driver (EXPERIMENTAL)"
1020 + depends on TAU
1021 + ---help---
1022 + The TAU supports an interrupt driven mode which causes an interrupt
1023 +@@ -232,12 +231,7 @@ config TAU_INT
1024 + to get notified the temp has exceeded a range. With this option off,
1025 + a timer is used to re-check the temperature periodically.
1026 +
1027 +- However, on some cpus it appears that the TAU interrupt hardware
1028 +- is buggy and can cause a situation which would lead unexplained hard
1029 +- lockups.
1030 +-
1031 +- Unless you are extending the TAU driver, or enjoy kernel/hardware
1032 +- debugging, leave this option off.
1033 ++ If in doubt, say N here.
1034 +
1035 + config TAU_AVERAGE
1036 + bool "Average high and low temp"
1037 +diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c
1038 +index 543c816fa99ef..0e6693bacb7e7 100644
1039 +--- a/arch/powerpc/platforms/powernv/opal-dump.c
1040 ++++ b/arch/powerpc/platforms/powernv/opal-dump.c
1041 +@@ -318,15 +318,14 @@ static ssize_t dump_attr_read(struct file *filep, struct kobject *kobj,
1042 + return count;
1043 + }
1044 +
1045 +-static struct dump_obj *create_dump_obj(uint32_t id, size_t size,
1046 +- uint32_t type)
1047 ++static void create_dump_obj(uint32_t id, size_t size, uint32_t type)
1048 + {
1049 + struct dump_obj *dump;
1050 + int rc;
1051 +
1052 + dump = kzalloc(sizeof(*dump), GFP_KERNEL);
1053 + if (!dump)
1054 +- return NULL;
1055 ++ return;
1056 +
1057 + dump->kobj.kset = dump_kset;
1058 +
1059 +@@ -346,21 +345,39 @@ static struct dump_obj *create_dump_obj(uint32_t id, size_t size,
1060 + rc = kobject_add(&dump->kobj, NULL, "0x%x-0x%x", type, id);
1061 + if (rc) {
1062 + kobject_put(&dump->kobj);
1063 +- return NULL;
1064 ++ return;
1065 + }
1066 +
1067 ++ /*
1068 ++ * As soon as the sysfs file for this dump is created/activated there is
1069 ++ * a chance the opal_errd daemon (or any userspace) might read and
1070 ++ * acknowledge the dump before kobject_uevent() is called. If that
1071 ++ * happens then there is a potential race between
1072 ++ * dump_ack_store->kobject_put() and kobject_uevent() which leads to a
1073 ++ * use-after-free of a kernfs object resulting in a kernel crash.
1074 ++ *
1075 ++ * To avoid that, we need to take a reference on behalf of the bin file,
1076 ++ * so that our reference remains valid while we call kobject_uevent().
1077 ++ * We then drop our reference before exiting the function, leaving the
1078 ++ * bin file to drop the last reference (if it hasn't already).
1079 ++ */
1080 ++
1081 ++ /* Take a reference for the bin file */
1082 ++ kobject_get(&dump->kobj);
1083 + rc = sysfs_create_bin_file(&dump->kobj, &dump->dump_attr);
1084 +- if (rc) {
1085 ++ if (rc == 0) {
1086 ++ kobject_uevent(&dump->kobj, KOBJ_ADD);
1087 ++
1088 ++ pr_info("%s: New platform dump. ID = 0x%x Size %u\n",
1089 ++ __func__, dump->id, dump->size);
1090 ++ } else {
1091 ++ /* Drop reference count taken for bin file */
1092 + kobject_put(&dump->kobj);
1093 +- return NULL;
1094 + }
1095 +
1096 +- pr_info("%s: New platform dump. ID = 0x%x Size %u\n",
1097 +- __func__, dump->id, dump->size);
1098 +-
1099 +- kobject_uevent(&dump->kobj, KOBJ_ADD);
1100 +-
1101 +- return dump;
1102 ++ /* Drop our reference */
1103 ++ kobject_put(&dump->kobj);
1104 ++ return;
1105 + }
1106 +
1107 + static irqreturn_t process_dump(int irq, void *data)
1108 +diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
1109 +index e7d23a933a0d3..66b32f46702de 100644
1110 +--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
1111 ++++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
1112 +@@ -376,25 +376,32 @@ static int dlpar_add_lmb(struct drmem_lmb *);
1113 +
1114 + static int dlpar_remove_lmb(struct drmem_lmb *lmb)
1115 + {
1116 ++ struct memory_block *mem_block;
1117 + unsigned long block_sz;
1118 + int rc;
1119 +
1120 + if (!lmb_is_removable(lmb))
1121 + return -EINVAL;
1122 +
1123 ++ mem_block = lmb_to_memblock(lmb);
1124 ++ if (mem_block == NULL)
1125 ++ return -EINVAL;
1126 ++
1127 + rc = dlpar_offline_lmb(lmb);
1128 +- if (rc)
1129 ++ if (rc) {
1130 ++ put_device(&mem_block->dev);
1131 + return rc;
1132 ++ }
1133 +
1134 + block_sz = pseries_memory_block_size();
1135 +
1136 +- __remove_memory(lmb->nid, lmb->base_addr, block_sz);
1137 ++ __remove_memory(mem_block->nid, lmb->base_addr, block_sz);
1138 ++ put_device(&mem_block->dev);
1139 +
1140 + /* Update memory regions for memory remove */
1141 + memblock_remove(lmb->base_addr, block_sz);
1142 +
1143 + invalidate_lmb_associativity_index(lmb);
1144 +- lmb_clear_nid(lmb);
1145 + lmb->flags &= ~DRCONF_MEM_ASSIGNED;
1146 +
1147 + return 0;
1148 +@@ -651,7 +658,7 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index)
1149 + static int dlpar_add_lmb(struct drmem_lmb *lmb)
1150 + {
1151 + unsigned long block_sz;
1152 +- int rc;
1153 ++ int nid, rc;
1154 +
1155 + if (lmb->flags & DRCONF_MEM_ASSIGNED)
1156 + return -EINVAL;
1157 +@@ -662,11 +669,13 @@ static int dlpar_add_lmb(struct drmem_lmb *lmb)
1158 + return rc;
1159 + }
1160 +
1161 +- lmb_set_nid(lmb);
1162 + block_sz = memory_block_size_bytes();
1163 +
1164 ++ /* Find the node id for this address. */
1165 ++ nid = memory_add_physaddr_to_nid(lmb->base_addr);
1166 ++
1167 + /* Add the memory */
1168 +- rc = __add_memory(lmb->nid, lmb->base_addr, block_sz);
1169 ++ rc = __add_memory(nid, lmb->base_addr, block_sz);
1170 + if (rc) {
1171 + invalidate_lmb_associativity_index(lmb);
1172 + return rc;
1173 +@@ -674,9 +683,8 @@ static int dlpar_add_lmb(struct drmem_lmb *lmb)
1174 +
1175 + rc = dlpar_online_lmb(lmb);
1176 + if (rc) {
1177 +- __remove_memory(lmb->nid, lmb->base_addr, block_sz);
1178 ++ __remove_memory(nid, lmb->base_addr, block_sz);
1179 + invalidate_lmb_associativity_index(lmb);
1180 +- lmb_clear_nid(lmb);
1181 + } else {
1182 + lmb->flags |= DRCONF_MEM_ASSIGNED;
1183 + }
1184 +diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
1185 +index b3c4848869e52..b658fa627a34b 100644
1186 +--- a/arch/powerpc/platforms/pseries/ras.c
1187 ++++ b/arch/powerpc/platforms/pseries/ras.c
1188 +@@ -494,18 +494,55 @@ int pSeries_system_reset_exception(struct pt_regs *regs)
1189 + return 0; /* need to perform reset */
1190 + }
1191 +
1192 ++static int mce_handle_err_realmode(int disposition, u8 error_type)
1193 ++{
1194 ++#ifdef CONFIG_PPC_BOOK3S_64
1195 ++ if (disposition == RTAS_DISP_NOT_RECOVERED) {
1196 ++ switch (error_type) {
1197 ++ case MC_ERROR_TYPE_SLB:
1198 ++ case MC_ERROR_TYPE_ERAT:
1199 ++ /*
1200 ++ * Store the old slb content in paca before flushing.
1201 ++ * Print this when we go to virtual mode.
1202 ++ * There are chances that we may hit MCE again if there
1203 ++ * is a parity error on the SLB entry we trying to read
1204 ++ * for saving. Hence limit the slb saving to single
1205 ++ * level of recursion.
1206 ++ */
1207 ++ if (local_paca->in_mce == 1)
1208 ++ slb_save_contents(local_paca->mce_faulty_slbs);
1209 ++ flush_and_reload_slb();
1210 ++ disposition = RTAS_DISP_FULLY_RECOVERED;
1211 ++ break;
1212 ++ default:
1213 ++ break;
1214 ++ }
1215 ++ } else if (disposition == RTAS_DISP_LIMITED_RECOVERY) {
1216 ++ /* Platform corrected itself but could be degraded */
1217 ++ pr_err("MCE: limited recovery, system may be degraded\n");
1218 ++ disposition = RTAS_DISP_FULLY_RECOVERED;
1219 ++ }
1220 ++#endif
1221 ++ return disposition;
1222 ++}
1223 +
1224 +-static int mce_handle_error(struct pt_regs *regs, struct rtas_error_log *errp)
1225 ++static int mce_handle_err_virtmode(struct pt_regs *regs,
1226 ++ struct rtas_error_log *errp,
1227 ++ struct pseries_mc_errorlog *mce_log,
1228 ++ int disposition)
1229 + {
1230 + struct mce_error_info mce_err = { 0 };
1231 +- unsigned long eaddr = 0, paddr = 0;
1232 +- struct pseries_errorlog *pseries_log;
1233 +- struct pseries_mc_errorlog *mce_log;
1234 +- int disposition = rtas_error_disposition(errp);
1235 + int initiator = rtas_error_initiator(errp);
1236 + int severity = rtas_error_severity(errp);
1237 ++ unsigned long eaddr = 0, paddr = 0;
1238 + u8 error_type, err_sub_type;
1239 +
1240 ++ if (!mce_log)
1241 ++ goto out;
1242 ++
1243 ++ error_type = mce_log->error_type;
1244 ++ err_sub_type = rtas_mc_error_sub_type(mce_log);
1245 ++
1246 + if (initiator == RTAS_INITIATOR_UNKNOWN)
1247 + mce_err.initiator = MCE_INITIATOR_UNKNOWN;
1248 + else if (initiator == RTAS_INITIATOR_CPU)
1249 +@@ -544,18 +581,7 @@ static int mce_handle_error(struct pt_regs *regs, struct rtas_error_log *errp)
1250 + mce_err.error_type = MCE_ERROR_TYPE_UNKNOWN;
1251 + mce_err.error_class = MCE_ECLASS_UNKNOWN;
1252 +
1253 +- if (!rtas_error_extended(errp))
1254 +- goto out;
1255 +-
1256 +- pseries_log = get_pseries_errorlog(errp, PSERIES_ELOG_SECT_ID_MCE);
1257 +- if (pseries_log == NULL)
1258 +- goto out;
1259 +-
1260 +- mce_log = (struct pseries_mc_errorlog *)pseries_log->data;
1261 +- error_type = mce_log->error_type;
1262 +- err_sub_type = rtas_mc_error_sub_type(mce_log);
1263 +-
1264 +- switch (mce_log->error_type) {
1265 ++ switch (error_type) {
1266 + case MC_ERROR_TYPE_UE:
1267 + mce_err.error_type = MCE_ERROR_TYPE_UE;
1268 + switch (err_sub_type) {
1269 +@@ -652,37 +678,31 @@ static int mce_handle_error(struct pt_regs *regs, struct rtas_error_log *errp)
1270 + mce_err.error_type = MCE_ERROR_TYPE_UNKNOWN;
1271 + break;
1272 + }
1273 ++out:
1274 ++ save_mce_event(regs, disposition == RTAS_DISP_FULLY_RECOVERED,
1275 ++ &mce_err, regs->nip, eaddr, paddr);
1276 ++ return disposition;
1277 ++}
1278 +
1279 +-#ifdef CONFIG_PPC_BOOK3S_64
1280 +- if (disposition == RTAS_DISP_NOT_RECOVERED) {
1281 +- switch (error_type) {
1282 +- case MC_ERROR_TYPE_SLB:
1283 +- case MC_ERROR_TYPE_ERAT:
1284 +- /*
1285 +- * Store the old slb content in paca before flushing.
1286 +- * Print this when we go to virtual mode.
1287 +- * There are chances that we may hit MCE again if there
1288 +- * is a parity error on the SLB entry we trying to read
1289 +- * for saving. Hence limit the slb saving to single
1290 +- * level of recursion.
1291 +- */
1292 +- if (local_paca->in_mce == 1)
1293 +- slb_save_contents(local_paca->mce_faulty_slbs);
1294 +- flush_and_reload_slb();
1295 +- disposition = RTAS_DISP_FULLY_RECOVERED;
1296 +- break;
1297 +- default:
1298 +- break;
1299 +- }
1300 +- } else if (disposition == RTAS_DISP_LIMITED_RECOVERY) {
1301 +- /* Platform corrected itself but could be degraded */
1302 +- printk(KERN_ERR "MCE: limited recovery, system may "
1303 +- "be degraded\n");
1304 +- disposition = RTAS_DISP_FULLY_RECOVERED;
1305 +- }
1306 +-#endif
1307 ++static int mce_handle_error(struct pt_regs *regs, struct rtas_error_log *errp)
1308 ++{
1309 ++ struct pseries_errorlog *pseries_log;
1310 ++ struct pseries_mc_errorlog *mce_log = NULL;
1311 ++ int disposition = rtas_error_disposition(errp);
1312 ++ u8 error_type;
1313 ++
1314 ++ if (!rtas_error_extended(errp))
1315 ++ goto out;
1316 ++
1317 ++ pseries_log = get_pseries_errorlog(errp, PSERIES_ELOG_SECT_ID_MCE);
1318 ++ if (!pseries_log)
1319 ++ goto out;
1320 ++
1321 ++ mce_log = (struct pseries_mc_errorlog *)pseries_log->data;
1322 ++ error_type = mce_log->error_type;
1323 ++
1324 ++ disposition = mce_handle_err_realmode(disposition, error_type);
1325 +
1326 +-out:
1327 + /*
1328 + * Enable translation as we will be accessing per-cpu variables
1329 + * in save_mce_event() which may fall outside RMO region, also
1330 +@@ -693,10 +713,10 @@ out:
1331 + * Note: All the realmode handling like flushing SLB entries for
1332 + * SLB multihit is done by now.
1333 + */
1334 ++out:
1335 + mtmsr(mfmsr() | MSR_IR | MSR_DR);
1336 +- save_mce_event(regs, disposition == RTAS_DISP_FULLY_RECOVERED,
1337 +- &mce_err, regs->nip, eaddr, paddr);
1338 +-
1339 ++ disposition = mce_handle_err_virtmode(regs, errp, mce_log,
1340 ++ disposition);
1341 + return disposition;
1342 + }
1343 +
1344 +diff --git a/arch/powerpc/platforms/pseries/rng.c b/arch/powerpc/platforms/pseries/rng.c
1345 +index bbb97169bf63e..6268545947b83 100644
1346 +--- a/arch/powerpc/platforms/pseries/rng.c
1347 ++++ b/arch/powerpc/platforms/pseries/rng.c
1348 +@@ -36,6 +36,7 @@ static __init int rng_init(void)
1349 +
1350 + ppc_md.get_random_seed = pseries_get_random_long;
1351 +
1352 ++ of_node_put(dn);
1353 + return 0;
1354 + }
1355 + machine_subsys_initcall(pseries, rng_init);
1356 +diff --git a/arch/powerpc/sysdev/xics/icp-hv.c b/arch/powerpc/sysdev/xics/icp-hv.c
1357 +index ad8117148ea3b..21b9d1bf39ff6 100644
1358 +--- a/arch/powerpc/sysdev/xics/icp-hv.c
1359 ++++ b/arch/powerpc/sysdev/xics/icp-hv.c
1360 +@@ -174,6 +174,7 @@ int icp_hv_init(void)
1361 +
1362 + icp_ops = &icp_hv_ops;
1363 +
1364 ++ of_node_put(np);
1365 + return 0;
1366 + }
1367 +
1368 +diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c
1369 +index c8862696a47b9..7d0394f4ebf97 100644
1370 +--- a/arch/x86/boot/compressed/pgtable_64.c
1371 ++++ b/arch/x86/boot/compressed/pgtable_64.c
1372 +@@ -5,15 +5,6 @@
1373 + #include "pgtable.h"
1374 + #include "../string.h"
1375 +
1376 +-/*
1377 +- * __force_order is used by special_insns.h asm code to force instruction
1378 +- * serialization.
1379 +- *
1380 +- * It is not referenced from the code, but GCC < 5 with -fPIE would fail
1381 +- * due to an undefined symbol. Define it to make these ancient GCCs work.
1382 +- */
1383 +-unsigned long __force_order;
1384 +-
1385 + #define BIOS_START_MIN 0x20000U /* 128K, less than this is insane */
1386 + #define BIOS_START_MAX 0x9f000U /* 640K, absolute maximum */
1387 +
1388 +diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c
1389 +index fb616203ce427..be50ef8572cce 100644
1390 +--- a/arch/x86/events/amd/iommu.c
1391 ++++ b/arch/x86/events/amd/iommu.c
1392 +@@ -379,7 +379,7 @@ static __init int _init_events_attrs(void)
1393 + while (amd_iommu_v2_event_descs[i].attr.attr.name)
1394 + i++;
1395 +
1396 +- attrs = kcalloc(i + 1, sizeof(struct attribute **), GFP_KERNEL);
1397 ++ attrs = kcalloc(i + 1, sizeof(*attrs), GFP_KERNEL);
1398 + if (!attrs)
1399 + return -ENOMEM;
1400 +
1401 +diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
1402 +index e5ad97a823426..1aaba2c8a9ba6 100644
1403 +--- a/arch/x86/events/intel/ds.c
1404 ++++ b/arch/x86/events/intel/ds.c
1405 +@@ -669,9 +669,7 @@ unlock:
1406 +
1407 + static inline void intel_pmu_drain_pebs_buffer(void)
1408 + {
1409 +- struct pt_regs regs;
1410 +-
1411 +- x86_pmu.drain_pebs(&regs);
1412 ++ x86_pmu.drain_pebs(NULL);
1413 + }
1414 +
1415 + /*
1416 +@@ -1736,6 +1734,7 @@ static void __intel_pmu_pebs_event(struct perf_event *event,
1417 + struct x86_perf_regs perf_regs;
1418 + struct pt_regs *regs = &perf_regs.regs;
1419 + void *at = get_next_pebs_record_by_bit(base, top, bit);
1420 ++ struct pt_regs dummy_iregs;
1421 +
1422 + if (hwc->flags & PERF_X86_EVENT_AUTO_RELOAD) {
1423 + /*
1424 +@@ -1748,6 +1747,9 @@ static void __intel_pmu_pebs_event(struct perf_event *event,
1425 + } else if (!intel_pmu_save_and_restart(event))
1426 + return;
1427 +
1428 ++ if (!iregs)
1429 ++ iregs = &dummy_iregs;
1430 ++
1431 + while (count > 1) {
1432 + setup_sample(event, iregs, at, &data, regs);
1433 + perf_event_output(event, &data, regs);
1434 +@@ -1757,16 +1759,22 @@ static void __intel_pmu_pebs_event(struct perf_event *event,
1435 + }
1436 +
1437 + setup_sample(event, iregs, at, &data, regs);
1438 +-
1439 +- /*
1440 +- * All but the last records are processed.
1441 +- * The last one is left to be able to call the overflow handler.
1442 +- */
1443 +- if (perf_event_overflow(event, &data, regs)) {
1444 +- x86_pmu_stop(event, 0);
1445 +- return;
1446 ++ if (iregs == &dummy_iregs) {
1447 ++ /*
1448 ++ * The PEBS records may be drained in the non-overflow context,
1449 ++ * e.g., large PEBS + context switch. Perf should treat the
1450 ++ * last record the same as other PEBS records, and doesn't
1451 ++ * invoke the generic overflow handler.
1452 ++ */
1453 ++ perf_event_output(event, &data, regs);
1454 ++ } else {
1455 ++ /*
1456 ++ * All but the last records are processed.
1457 ++ * The last one is left to be able to call the overflow handler.
1458 ++ */
1459 ++ if (perf_event_overflow(event, &data, regs))
1460 ++ x86_pmu_stop(event, 0);
1461 + }
1462 +-
1463 + }
1464 +
1465 + static void intel_pmu_drain_pebs_core(struct pt_regs *iregs)
1466 +diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c
1467 +index c37cb12d0ef68..aec6e63c6a04a 100644
1468 +--- a/arch/x86/events/intel/uncore_snb.c
1469 ++++ b/arch/x86/events/intel/uncore_snb.c
1470 +@@ -110,6 +110,10 @@
1471 + #define ICL_UNC_CBO_0_PER_CTR0 0x702
1472 + #define ICL_UNC_CBO_MSR_OFFSET 0x8
1473 +
1474 ++/* ICL ARB register */
1475 ++#define ICL_UNC_ARB_PER_CTR 0x3b1
1476 ++#define ICL_UNC_ARB_PERFEVTSEL 0x3b3
1477 ++
1478 + DEFINE_UNCORE_FORMAT_ATTR(event, event, "config:0-7");
1479 + DEFINE_UNCORE_FORMAT_ATTR(umask, umask, "config:8-15");
1480 + DEFINE_UNCORE_FORMAT_ATTR(edge, edge, "config:18");
1481 +@@ -297,15 +301,21 @@ void skl_uncore_cpu_init(void)
1482 + snb_uncore_arb.ops = &skl_uncore_msr_ops;
1483 + }
1484 +
1485 ++static struct intel_uncore_ops icl_uncore_msr_ops = {
1486 ++ .disable_event = snb_uncore_msr_disable_event,
1487 ++ .enable_event = snb_uncore_msr_enable_event,
1488 ++ .read_counter = uncore_msr_read_counter,
1489 ++};
1490 ++
1491 + static struct intel_uncore_type icl_uncore_cbox = {
1492 + .name = "cbox",
1493 +- .num_counters = 4,
1494 ++ .num_counters = 2,
1495 + .perf_ctr_bits = 44,
1496 + .perf_ctr = ICL_UNC_CBO_0_PER_CTR0,
1497 + .event_ctl = SNB_UNC_CBO_0_PERFEVTSEL0,
1498 + .event_mask = SNB_UNC_RAW_EVENT_MASK,
1499 + .msr_offset = ICL_UNC_CBO_MSR_OFFSET,
1500 +- .ops = &skl_uncore_msr_ops,
1501 ++ .ops = &icl_uncore_msr_ops,
1502 + .format_group = &snb_uncore_format_group,
1503 + };
1504 +
1505 +@@ -334,13 +344,25 @@ static struct intel_uncore_type icl_uncore_clockbox = {
1506 + .single_fixed = 1,
1507 + .event_mask = SNB_UNC_CTL_EV_SEL_MASK,
1508 + .format_group = &icl_uncore_clock_format_group,
1509 +- .ops = &skl_uncore_msr_ops,
1510 ++ .ops = &icl_uncore_msr_ops,
1511 + .event_descs = icl_uncore_events,
1512 + };
1513 +
1514 ++static struct intel_uncore_type icl_uncore_arb = {
1515 ++ .name = "arb",
1516 ++ .num_counters = 1,
1517 ++ .num_boxes = 1,
1518 ++ .perf_ctr_bits = 44,
1519 ++ .perf_ctr = ICL_UNC_ARB_PER_CTR,
1520 ++ .event_ctl = ICL_UNC_ARB_PERFEVTSEL,
1521 ++ .event_mask = SNB_UNC_RAW_EVENT_MASK,
1522 ++ .ops = &icl_uncore_msr_ops,
1523 ++ .format_group = &snb_uncore_format_group,
1524 ++};
1525 ++
1526 + static struct intel_uncore_type *icl_msr_uncores[] = {
1527 + &icl_uncore_cbox,
1528 +- &snb_uncore_arb,
1529 ++ &icl_uncore_arb,
1530 + &icl_uncore_clockbox,
1531 + NULL,
1532 + };
1533 +@@ -358,7 +380,6 @@ void icl_uncore_cpu_init(void)
1534 + {
1535 + uncore_msr_uncores = icl_msr_uncores;
1536 + icl_uncore_cbox.num_boxes = icl_get_cbox_num();
1537 +- snb_uncore_arb.ops = &skl_uncore_msr_ops;
1538 + }
1539 +
1540 + enum {
1541 +diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
1542 +index 6d37b8fcfc778..2e0cdc64cb50d 100644
1543 +--- a/arch/x86/include/asm/special_insns.h
1544 ++++ b/arch/x86/include/asm/special_insns.h
1545 +@@ -10,45 +10,47 @@
1546 + #include <linux/jump_label.h>
1547 +
1548 + /*
1549 +- * Volatile isn't enough to prevent the compiler from reordering the
1550 +- * read/write functions for the control registers and messing everything up.
1551 +- * A memory clobber would solve the problem, but would prevent reordering of
1552 +- * all loads stores around it, which can hurt performance. Solution is to
1553 +- * use a variable and mimic reads and writes to it to enforce serialization
1554 ++ * The compiler should not reorder volatile asm statements with respect to each
1555 ++ * other: they should execute in program order. However GCC 4.9.x and 5.x have
1556 ++ * a bug (which was fixed in 8.1, 7.3 and 6.5) where they might reorder
1557 ++ * volatile asm. The write functions are not affected since they have memory
1558 ++ * clobbers preventing reordering. To prevent reads from being reordered with
1559 ++ * respect to writes, use a dummy memory operand.
1560 + */
1561 +-extern unsigned long __force_order;
1562 ++
1563 ++#define __FORCE_ORDER "m"(*(unsigned int *)0x1000UL)
1564 +
1565 + void native_write_cr0(unsigned long val);
1566 +
1567 + static inline unsigned long native_read_cr0(void)
1568 + {
1569 + unsigned long val;
1570 +- asm volatile("mov %%cr0,%0\n\t" : "=r" (val), "=m" (__force_order));
1571 ++ asm volatile("mov %%cr0,%0\n\t" : "=r" (val) : __FORCE_ORDER);
1572 + return val;
1573 + }
1574 +
1575 + static inline unsigned long native_read_cr2(void)
1576 + {
1577 + unsigned long val;
1578 +- asm volatile("mov %%cr2,%0\n\t" : "=r" (val), "=m" (__force_order));
1579 ++ asm volatile("mov %%cr2,%0\n\t" : "=r" (val) : __FORCE_ORDER);
1580 + return val;
1581 + }
1582 +
1583 + static inline void native_write_cr2(unsigned long val)
1584 + {
1585 +- asm volatile("mov %0,%%cr2": : "r" (val), "m" (__force_order));
1586 ++ asm volatile("mov %0,%%cr2": : "r" (val) : "memory");
1587 + }
1588 +
1589 + static inline unsigned long __native_read_cr3(void)
1590 + {
1591 + unsigned long val;
1592 +- asm volatile("mov %%cr3,%0\n\t" : "=r" (val), "=m" (__force_order));
1593 ++ asm volatile("mov %%cr3,%0\n\t" : "=r" (val) : __FORCE_ORDER);
1594 + return val;
1595 + }
1596 +
1597 + static inline void native_write_cr3(unsigned long val)
1598 + {
1599 +- asm volatile("mov %0,%%cr3": : "r" (val), "m" (__force_order));
1600 ++ asm volatile("mov %0,%%cr3": : "r" (val) : "memory");
1601 + }
1602 +
1603 + static inline unsigned long native_read_cr4(void)
1604 +@@ -63,10 +65,10 @@ static inline unsigned long native_read_cr4(void)
1605 + asm volatile("1: mov %%cr4, %0\n"
1606 + "2:\n"
1607 + _ASM_EXTABLE(1b, 2b)
1608 +- : "=r" (val), "=m" (__force_order) : "0" (0));
1609 ++ : "=r" (val) : "0" (0), __FORCE_ORDER);
1610 + #else
1611 + /* CR4 always exists on x86_64. */
1612 +- asm volatile("mov %%cr4,%0\n\t" : "=r" (val), "=m" (__force_order));
1613 ++ asm volatile("mov %%cr4,%0\n\t" : "=r" (val) : __FORCE_ORDER);
1614 + #endif
1615 + return val;
1616 + }
1617 +diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
1618 +index 9b3f25e146087..8a85c2e144a6f 100644
1619 +--- a/arch/x86/kernel/cpu/common.c
1620 ++++ b/arch/x86/kernel/cpu/common.c
1621 +@@ -377,7 +377,7 @@ void native_write_cr0(unsigned long val)
1622 + unsigned long bits_missing = 0;
1623 +
1624 + set_register:
1625 +- asm volatile("mov %0,%%cr0": "+r" (val), "+m" (__force_order));
1626 ++ asm volatile("mov %0,%%cr0": "+r" (val) : : "memory");
1627 +
1628 + if (static_branch_likely(&cr_pinning)) {
1629 + if (unlikely((val & X86_CR0_WP) != X86_CR0_WP)) {
1630 +@@ -396,7 +396,7 @@ void native_write_cr4(unsigned long val)
1631 + unsigned long bits_changed = 0;
1632 +
1633 + set_register:
1634 +- asm volatile("mov %0,%%cr4": "+r" (val), "+m" (cr4_pinned_bits));
1635 ++ asm volatile("mov %0,%%cr4": "+r" (val) : : "memory");
1636 +
1637 + if (static_branch_likely(&cr_pinning)) {
1638 + if (unlikely((val & cr4_pinned_mask) != cr4_pinned_bits)) {
1639 +diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
1640 +index fd76e3733dd3d..92331de16d70e 100644
1641 +--- a/arch/x86/kernel/cpu/mce/core.c
1642 ++++ b/arch/x86/kernel/cpu/mce/core.c
1643 +@@ -388,10 +388,28 @@ static int msr_to_offset(u32 msr)
1644 + return -1;
1645 + }
1646 +
1647 ++__visible bool ex_handler_rdmsr_fault(const struct exception_table_entry *fixup,
1648 ++ struct pt_regs *regs, int trapnr,
1649 ++ unsigned long error_code,
1650 ++ unsigned long fault_addr)
1651 ++{
1652 ++ pr_emerg("MSR access error: RDMSR from 0x%x at rIP: 0x%lx (%pS)\n",
1653 ++ (unsigned int)regs->cx, regs->ip, (void *)regs->ip);
1654 ++
1655 ++ show_stack_regs(regs);
1656 ++
1657 ++ panic("MCA architectural violation!\n");
1658 ++
1659 ++ while (true)
1660 ++ cpu_relax();
1661 ++
1662 ++ return true;
1663 ++}
1664 ++
1665 + /* MSR access wrappers used for error injection */
1666 + static u64 mce_rdmsrl(u32 msr)
1667 + {
1668 +- u64 v;
1669 ++ DECLARE_ARGS(val, low, high);
1670 +
1671 + if (__this_cpu_read(injectm.finished)) {
1672 + int offset = msr_to_offset(msr);
1673 +@@ -401,21 +419,43 @@ static u64 mce_rdmsrl(u32 msr)
1674 + return *(u64 *)((char *)this_cpu_ptr(&injectm) + offset);
1675 + }
1676 +
1677 +- if (rdmsrl_safe(msr, &v)) {
1678 +- WARN_ONCE(1, "mce: Unable to read MSR 0x%x!\n", msr);
1679 +- /*
1680 +- * Return zero in case the access faulted. This should
1681 +- * not happen normally but can happen if the CPU does
1682 +- * something weird, or if the code is buggy.
1683 +- */
1684 +- v = 0;
1685 +- }
1686 ++ /*
1687 ++ * RDMSR on MCA MSRs should not fault. If they do, this is very much an
1688 ++ * architectural violation and needs to be reported to hw vendor. Panic
1689 ++ * the box to not allow any further progress.
1690 ++ */
1691 ++ asm volatile("1: rdmsr\n"
1692 ++ "2:\n"
1693 ++ _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_fault)
1694 ++ : EAX_EDX_RET(val, low, high) : "c" (msr));
1695 +
1696 +- return v;
1697 ++
1698 ++ return EAX_EDX_VAL(val, low, high);
1699 ++}
1700 ++
1701 ++__visible bool ex_handler_wrmsr_fault(const struct exception_table_entry *fixup,
1702 ++ struct pt_regs *regs, int trapnr,
1703 ++ unsigned long error_code,
1704 ++ unsigned long fault_addr)
1705 ++{
1706 ++ pr_emerg("MSR access error: WRMSR to 0x%x (tried to write 0x%08x%08x) at rIP: 0x%lx (%pS)\n",
1707 ++ (unsigned int)regs->cx, (unsigned int)regs->dx, (unsigned int)regs->ax,
1708 ++ regs->ip, (void *)regs->ip);
1709 ++
1710 ++ show_stack_regs(regs);
1711 ++
1712 ++ panic("MCA architectural violation!\n");
1713 ++
1714 ++ while (true)
1715 ++ cpu_relax();
1716 ++
1717 ++ return true;
1718 + }
1719 +
1720 + static void mce_wrmsrl(u32 msr, u64 v)
1721 + {
1722 ++ u32 low, high;
1723 ++
1724 + if (__this_cpu_read(injectm.finished)) {
1725 + int offset = msr_to_offset(msr);
1726 +
1727 +@@ -423,7 +463,15 @@ static void mce_wrmsrl(u32 msr, u64 v)
1728 + *(u64 *)((char *)this_cpu_ptr(&injectm) + offset) = v;
1729 + return;
1730 + }
1731 +- wrmsrl(msr, v);
1732 ++
1733 ++ low = (u32)v;
1734 ++ high = (u32)(v >> 32);
1735 ++
1736 ++ /* See comment in mce_rdmsrl() */
1737 ++ asm volatile("1: wrmsr\n"
1738 ++ "2:\n"
1739 ++ _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_wrmsr_fault)
1740 ++ : : "c" (msr), "a"(low), "d" (high) : "memory");
1741 + }
1742 +
1743 + /*
1744 +diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h
1745 +index 43031db429d24..231954fe5b4e6 100644
1746 +--- a/arch/x86/kernel/cpu/mce/internal.h
1747 ++++ b/arch/x86/kernel/cpu/mce/internal.h
1748 +@@ -172,4 +172,14 @@ extern bool amd_filter_mce(struct mce *m);
1749 + static inline bool amd_filter_mce(struct mce *m) { return false; };
1750 + #endif
1751 +
1752 ++__visible bool ex_handler_rdmsr_fault(const struct exception_table_entry *fixup,
1753 ++ struct pt_regs *regs, int trapnr,
1754 ++ unsigned long error_code,
1755 ++ unsigned long fault_addr);
1756 ++
1757 ++__visible bool ex_handler_wrmsr_fault(const struct exception_table_entry *fixup,
1758 ++ struct pt_regs *regs, int trapnr,
1759 ++ unsigned long error_code,
1760 ++ unsigned long fault_addr);
1761 ++
1762 + #endif /* __X86_MCE_INTERNAL_H__ */
1763 +diff --git a/arch/x86/kernel/cpu/mce/severity.c b/arch/x86/kernel/cpu/mce/severity.c
1764 +index 87bcdc6dc2f0c..0d09eb13743b4 100644
1765 +--- a/arch/x86/kernel/cpu/mce/severity.c
1766 ++++ b/arch/x86/kernel/cpu/mce/severity.c
1767 +@@ -9,9 +9,11 @@
1768 + #include <linux/seq_file.h>
1769 + #include <linux/init.h>
1770 + #include <linux/debugfs.h>
1771 +-#include <asm/mce.h>
1772 + #include <linux/uaccess.h>
1773 +
1774 ++#include <asm/mce.h>
1775 ++#include <asm/intel-family.h>
1776 ++
1777 + #include "internal.h"
1778 +
1779 + /*
1780 +@@ -40,9 +42,14 @@ static struct severity {
1781 + unsigned char context;
1782 + unsigned char excp;
1783 + unsigned char covered;
1784 ++ unsigned char cpu_model;
1785 ++ unsigned char cpu_minstepping;
1786 ++ unsigned char bank_lo, bank_hi;
1787 + char *msg;
1788 + } severities[] = {
1789 + #define MCESEV(s, m, c...) { .sev = MCE_ ## s ## _SEVERITY, .msg = m, ## c }
1790 ++#define BANK_RANGE(l, h) .bank_lo = l, .bank_hi = h
1791 ++#define MODEL_STEPPING(m, s) .cpu_model = m, .cpu_minstepping = s
1792 + #define KERNEL .context = IN_KERNEL
1793 + #define USER .context = IN_USER
1794 + #define KERNEL_RECOV .context = IN_KERNEL_RECOV
1795 +@@ -97,7 +104,6 @@ static struct severity {
1796 + KEEP, "Corrected error",
1797 + NOSER, BITCLR(MCI_STATUS_UC)
1798 + ),
1799 +-
1800 + /*
1801 + * known AO MCACODs reported via MCE or CMC:
1802 + *
1803 +@@ -113,6 +119,18 @@ static struct severity {
1804 + AO, "Action optional: last level cache writeback error",
1805 + SER, MASK(MCI_UC_AR|MCACOD, MCI_STATUS_UC|MCACOD_L3WB)
1806 + ),
1807 ++ /*
1808 ++ * Quirk for Skylake/Cascade Lake. Patrol scrubber may be configured
1809 ++ * to report uncorrected errors using CMCI with a special signature.
1810 ++ * UC=0, MSCOD=0x0010, MCACOD=binary(000X 0000 1100 XXXX) reported
1811 ++ * in one of the memory controller banks.
1812 ++ * Set severity to "AO" for same action as normal patrol scrub error.
1813 ++ */
1814 ++ MCESEV(
1815 ++ AO, "Uncorrected Patrol Scrub Error",
1816 ++ SER, MASK(MCI_STATUS_UC|MCI_ADDR|0xffffeff0, MCI_ADDR|0x001000c0),
1817 ++ MODEL_STEPPING(INTEL_FAM6_SKYLAKE_X, 4), BANK_RANGE(13, 18)
1818 ++ ),
1819 +
1820 + /* ignore OVER for UCNA */
1821 + MCESEV(
1822 +@@ -320,6 +338,12 @@ static int mce_severity_intel(struct mce *m, int tolerant, char **msg, bool is_e
1823 + continue;
1824 + if (s->excp && excp != s->excp)
1825 + continue;
1826 ++ if (s->cpu_model && boot_cpu_data.x86_model != s->cpu_model)
1827 ++ continue;
1828 ++ if (s->cpu_minstepping && boot_cpu_data.x86_stepping < s->cpu_minstepping)
1829 ++ continue;
1830 ++ if (s->bank_lo && (m->bank < s->bank_lo || m->bank > s->bank_hi))
1831 ++ continue;
1832 + if (msg)
1833 + *msg = s->msg;
1834 + s->covered = 1;
1835 +diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
1836 +index 6ce7e0a23268f..b271da0fa2193 100644
1837 +--- a/arch/x86/kernel/fpu/init.c
1838 ++++ b/arch/x86/kernel/fpu/init.c
1839 +@@ -242,9 +242,9 @@ static void __init fpu__init_system_ctx_switch(void)
1840 + */
1841 + static void __init fpu__init_parse_early_param(void)
1842 + {
1843 +- char arg[32];
1844 ++ char arg[128];
1845 + char *argptr = arg;
1846 +- int bit;
1847 ++ int arglen, res, bit;
1848 +
1849 + #ifdef CONFIG_X86_32
1850 + if (cmdline_find_option_bool(boot_command_line, "no387"))
1851 +@@ -267,12 +267,26 @@ static void __init fpu__init_parse_early_param(void)
1852 + if (cmdline_find_option_bool(boot_command_line, "noxsaves"))
1853 + setup_clear_cpu_cap(X86_FEATURE_XSAVES);
1854 +
1855 +- if (cmdline_find_option(boot_command_line, "clearcpuid", arg,
1856 +- sizeof(arg)) &&
1857 +- get_option(&argptr, &bit) &&
1858 +- bit >= 0 &&
1859 +- bit < NCAPINTS * 32)
1860 +- setup_clear_cpu_cap(bit);
1861 ++ arglen = cmdline_find_option(boot_command_line, "clearcpuid", arg, sizeof(arg));
1862 ++ if (arglen <= 0)
1863 ++ return;
1864 ++
1865 ++ pr_info("Clearing CPUID bits:");
1866 ++ do {
1867 ++ res = get_option(&argptr, &bit);
1868 ++ if (res == 0 || res == 3)
1869 ++ break;
1870 ++
1871 ++ /* If the argument was too long, the last bit may be cut off */
1872 ++ if (res == 1 && arglen >= sizeof(arg))
1873 ++ break;
1874 ++
1875 ++ if (bit >= 0 && bit < NCAPINTS * 32) {
1876 ++ pr_cont(" " X86_CAP_FMT, x86_cap_flag(bit));
1877 ++ setup_clear_cpu_cap(bit);
1878 ++ }
1879 ++ } while (res == 2);
1880 ++ pr_cont("\n");
1881 + }
1882 +
1883 + /*
1884 +diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
1885 +index 54c21d6abd5ac..5bb001c0c771a 100644
1886 +--- a/arch/x86/kernel/nmi.c
1887 ++++ b/arch/x86/kernel/nmi.c
1888 +@@ -106,7 +106,6 @@ fs_initcall(nmi_warning_debugfs);
1889 +
1890 + static void nmi_check_duration(struct nmiaction *action, u64 duration)
1891 + {
1892 +- u64 whole_msecs = READ_ONCE(action->max_duration);
1893 + int remainder_ns, decimal_msecs;
1894 +
1895 + if (duration < nmi_longest_ns || duration < action->max_duration)
1896 +@@ -114,12 +113,12 @@ static void nmi_check_duration(struct nmiaction *action, u64 duration)
1897 +
1898 + action->max_duration = duration;
1899 +
1900 +- remainder_ns = do_div(whole_msecs, (1000 * 1000));
1901 ++ remainder_ns = do_div(duration, (1000 * 1000));
1902 + decimal_msecs = remainder_ns / 1000;
1903 +
1904 + printk_ratelimited(KERN_INFO
1905 + "INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n",
1906 +- action->handler, whole_msecs, decimal_msecs);
1907 ++ action->handler, duration, decimal_msecs);
1908 + }
1909 +
1910 + static int nmi_handle(unsigned int type, struct pt_regs *regs)
1911 +diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
1912 +index cc7823e7ef96c..484c32b7f79ff 100644
1913 +--- a/arch/x86/kvm/emulate.c
1914 ++++ b/arch/x86/kvm/emulate.c
1915 +@@ -3617,7 +3617,7 @@ static int em_rdpid(struct x86_emulate_ctxt *ctxt)
1916 + u64 tsc_aux = 0;
1917 +
1918 + if (ctxt->ops->get_msr(ctxt, MSR_TSC_AUX, &tsc_aux))
1919 +- return emulate_gp(ctxt, 0);
1920 ++ return emulate_ud(ctxt);
1921 + ctxt->dst.val = tsc_aux;
1922 + return X86EMUL_CONTINUE;
1923 + }
1924 +diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
1925 +index bb743f956c232..b90e8fd2f6ced 100644
1926 +--- a/arch/x86/kvm/mmu.c
1927 ++++ b/arch/x86/kvm/mmu.c
1928 +@@ -6453,6 +6453,7 @@ static void kvm_recover_nx_lpages(struct kvm *kvm)
1929 + cond_resched_lock(&kvm->mmu_lock);
1930 + }
1931 + }
1932 ++ kvm_mmu_commit_zap_page(kvm, &invalid_list);
1933 +
1934 + spin_unlock(&kvm->mmu_lock);
1935 + srcu_read_unlock(&kvm->srcu, rcu_idx);
1936 +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
1937 +index b58495fde2e89..c79c1a07f44b9 100644
1938 +--- a/arch/x86/kvm/svm.c
1939 ++++ b/arch/x86/kvm/svm.c
1940 +@@ -5383,6 +5383,7 @@ static int svm_update_pi_irte(struct kvm *kvm, unsigned int host_irq,
1941 + * - Tell IOMMU to use legacy mode for this interrupt.
1942 + * - Retrieve ga_tag of prior interrupt remapping data.
1943 + */
1944 ++ pi.prev_ga_tag = 0;
1945 + pi.is_guest_mode = false;
1946 + ret = irq_set_vcpu_affinity(host_irq, &pi);
1947 +
1948 +diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
1949 +index a460ddf04d60c..08e1e7544f823 100644
1950 +--- a/arch/x86/kvm/vmx/nested.c
1951 ++++ b/arch/x86/kvm/vmx/nested.c
1952 +@@ -2231,6 +2231,8 @@ static void prepare_vmcs02_rare(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
1953 + vmcs_writel(GUEST_TR_BASE, vmcs12->guest_tr_base);
1954 + vmcs_writel(GUEST_GDTR_BASE, vmcs12->guest_gdtr_base);
1955 + vmcs_writel(GUEST_IDTR_BASE, vmcs12->guest_idtr_base);
1956 ++
1957 ++ vmx->segment_cache.bitmask = 0;
1958 + }
1959 +
1960 + if (!hv_evmcs || !(hv_evmcs->hv_clean_fields &
1961 +@@ -3094,8 +3096,10 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
1962 + prepare_vmcs02_early(vmx, vmcs12);
1963 +
1964 + if (from_vmentry) {
1965 +- if (unlikely(!nested_get_vmcs12_pages(vcpu)))
1966 ++ if (unlikely(!nested_get_vmcs12_pages(vcpu))) {
1967 ++ vmx_switch_vmcs(vcpu, &vmx->vmcs01);
1968 + return NVMX_VMENTRY_KVM_INTERNAL_ERROR;
1969 ++ }
1970 +
1971 + if (nested_vmx_check_vmentry_hw(vcpu)) {
1972 + vmx_switch_vmcs(vcpu, &vmx->vmcs01);
1973 +diff --git a/block/blk-core.c b/block/blk-core.c
1974 +index 81aafb601df06..d2213220099d3 100644
1975 +--- a/block/blk-core.c
1976 ++++ b/block/blk-core.c
1977 +@@ -743,11 +743,10 @@ static void handle_bad_sector(struct bio *bio, sector_t maxsector)
1978 + {
1979 + char b[BDEVNAME_SIZE];
1980 +
1981 +- printk(KERN_INFO "attempt to access beyond end of device\n");
1982 +- printk(KERN_INFO "%s: rw=%d, want=%Lu, limit=%Lu\n",
1983 +- bio_devname(bio, b), bio->bi_opf,
1984 +- (unsigned long long)bio_end_sector(bio),
1985 +- (long long)maxsector);
1986 ++ pr_info_ratelimited("attempt to access beyond end of device\n"
1987 ++ "%s: rw=%d, want=%llu, limit=%llu\n",
1988 ++ bio_devname(bio, b), bio->bi_opf,
1989 ++ bio_end_sector(bio), maxsector);
1990 + }
1991 +
1992 + #ifdef CONFIG_FAIL_MAKE_REQUEST
1993 +diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
1994 +index a09ab0c3d074d..5dafd7a8ec913 100644
1995 +--- a/block/blk-mq-sysfs.c
1996 ++++ b/block/blk-mq-sysfs.c
1997 +@@ -36,8 +36,6 @@ static void blk_mq_hw_sysfs_release(struct kobject *kobj)
1998 + struct blk_mq_hw_ctx *hctx = container_of(kobj, struct blk_mq_hw_ctx,
1999 + kobj);
2000 +
2001 +- cancel_delayed_work_sync(&hctx->run_work);
2002 +-
2003 + if (hctx->flags & BLK_MQ_F_BLOCKING)
2004 + cleanup_srcu_struct(hctx->srcu);
2005 + blk_free_flush_queue(hctx->fq);
2006 +diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
2007 +index 46f5198be0173..bf33570da5ac7 100644
2008 +--- a/block/blk-sysfs.c
2009 ++++ b/block/blk-sysfs.c
2010 +@@ -891,9 +891,16 @@ static void __blk_release_queue(struct work_struct *work)
2011 +
2012 + blk_free_queue_stats(q->stats);
2013 +
2014 +- if (queue_is_mq(q))
2015 ++ if (queue_is_mq(q)) {
2016 ++ struct blk_mq_hw_ctx *hctx;
2017 ++ int i;
2018 ++
2019 + cancel_delayed_work_sync(&q->requeue_work);
2020 +
2021 ++ queue_for_each_hw_ctx(q, hctx, i)
2022 ++ cancel_delayed_work_sync(&hctx->run_work);
2023 ++ }
2024 ++
2025 + blk_exit_queue(q);
2026 +
2027 + blk_queue_free_zone_bitmaps(q);
2028 +diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
2029 +index 43c6aa784858b..e62d735ed2660 100644
2030 +--- a/crypto/algif_aead.c
2031 ++++ b/crypto/algif_aead.c
2032 +@@ -78,7 +78,7 @@ static int crypto_aead_copy_sgl(struct crypto_sync_skcipher *null_tfm,
2033 + SYNC_SKCIPHER_REQUEST_ON_STACK(skreq, null_tfm);
2034 +
2035 + skcipher_request_set_sync_tfm(skreq, null_tfm);
2036 +- skcipher_request_set_callback(skreq, CRYPTO_TFM_REQ_MAY_BACKLOG,
2037 ++ skcipher_request_set_callback(skreq, CRYPTO_TFM_REQ_MAY_SLEEP,
2038 + NULL, NULL);
2039 + skcipher_request_set_crypt(skreq, src, dst, len, NULL);
2040 +
2041 +@@ -291,19 +291,20 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg,
2042 + areq->outlen = outlen;
2043 +
2044 + aead_request_set_callback(&areq->cra_u.aead_req,
2045 +- CRYPTO_TFM_REQ_MAY_BACKLOG,
2046 ++ CRYPTO_TFM_REQ_MAY_SLEEP,
2047 + af_alg_async_cb, areq);
2048 + err = ctx->enc ? crypto_aead_encrypt(&areq->cra_u.aead_req) :
2049 + crypto_aead_decrypt(&areq->cra_u.aead_req);
2050 +
2051 + /* AIO operation in progress */
2052 +- if (err == -EINPROGRESS || err == -EBUSY)
2053 ++ if (err == -EINPROGRESS)
2054 + return -EIOCBQUEUED;
2055 +
2056 + sock_put(sk);
2057 + } else {
2058 + /* Synchronous operation */
2059 + aead_request_set_callback(&areq->cra_u.aead_req,
2060 ++ CRYPTO_TFM_REQ_MAY_SLEEP |
2061 + CRYPTO_TFM_REQ_MAY_BACKLOG,
2062 + crypto_req_done, &ctx->wait);
2063 + err = crypto_wait_req(ctx->enc ?
2064 +diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
2065 +index 81c4022285a7c..30069a92a9b22 100644
2066 +--- a/crypto/algif_skcipher.c
2067 ++++ b/crypto/algif_skcipher.c
2068 +@@ -123,7 +123,7 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
2069 + crypto_skcipher_decrypt(&areq->cra_u.skcipher_req);
2070 +
2071 + /* AIO operation in progress */
2072 +- if (err == -EINPROGRESS || err == -EBUSY)
2073 ++ if (err == -EINPROGRESS)
2074 + return -EIOCBQUEUED;
2075 +
2076 + sock_put(sk);
2077 +diff --git a/drivers/android/binder.c b/drivers/android/binder.c
2078 +index 110dd4c2977f5..b62b1ab6bb699 100644
2079 +--- a/drivers/android/binder.c
2080 ++++ b/drivers/android/binder.c
2081 +@@ -227,7 +227,7 @@ static struct binder_transaction_log_entry *binder_transaction_log_add(
2082 + struct binder_work {
2083 + struct list_head entry;
2084 +
2085 +- enum {
2086 ++ enum binder_work_type {
2087 + BINDER_WORK_TRANSACTION = 1,
2088 + BINDER_WORK_TRANSACTION_COMPLETE,
2089 + BINDER_WORK_RETURN_ERROR,
2090 +@@ -889,27 +889,6 @@ static struct binder_work *binder_dequeue_work_head_ilocked(
2091 + return w;
2092 + }
2093 +
2094 +-/**
2095 +- * binder_dequeue_work_head() - Dequeues the item at head of list
2096 +- * @proc: binder_proc associated with list
2097 +- * @list: list to dequeue head
2098 +- *
2099 +- * Removes the head of the list if there are items on the list
2100 +- *
2101 +- * Return: pointer dequeued binder_work, NULL if list was empty
2102 +- */
2103 +-static struct binder_work *binder_dequeue_work_head(
2104 +- struct binder_proc *proc,
2105 +- struct list_head *list)
2106 +-{
2107 +- struct binder_work *w;
2108 +-
2109 +- binder_inner_proc_lock(proc);
2110 +- w = binder_dequeue_work_head_ilocked(list);
2111 +- binder_inner_proc_unlock(proc);
2112 +- return w;
2113 +-}
2114 +-
2115 + static void
2116 + binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer);
2117 + static void binder_free_thread(struct binder_thread *thread);
2118 +@@ -2347,8 +2326,6 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
2119 + * file is done when the transaction is torn
2120 + * down.
2121 + */
2122 +- WARN_ON(failed_at &&
2123 +- proc->tsk == current->group_leader);
2124 + } break;
2125 + case BINDER_TYPE_PTR:
2126 + /*
2127 +@@ -4591,13 +4568,17 @@ static void binder_release_work(struct binder_proc *proc,
2128 + struct list_head *list)
2129 + {
2130 + struct binder_work *w;
2131 ++ enum binder_work_type wtype;
2132 +
2133 + while (1) {
2134 +- w = binder_dequeue_work_head(proc, list);
2135 ++ binder_inner_proc_lock(proc);
2136 ++ w = binder_dequeue_work_head_ilocked(list);
2137 ++ wtype = w ? w->type : 0;
2138 ++ binder_inner_proc_unlock(proc);
2139 + if (!w)
2140 + return;
2141 +
2142 +- switch (w->type) {
2143 ++ switch (wtype) {
2144 + case BINDER_WORK_TRANSACTION: {
2145 + struct binder_transaction *t;
2146 +
2147 +@@ -4631,9 +4612,11 @@ static void binder_release_work(struct binder_proc *proc,
2148 + kfree(death);
2149 + binder_stats_deleted(BINDER_STAT_DEATH);
2150 + } break;
2151 ++ case BINDER_WORK_NODE:
2152 ++ break;
2153 + default:
2154 + pr_err("unexpected work type, %d, not freed\n",
2155 +- w->type);
2156 ++ wtype);
2157 + break;
2158 + }
2159 + }
2160 +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
2161 +index f3f0529564da0..b326eeddaadf0 100644
2162 +--- a/drivers/bluetooth/btusb.c
2163 ++++ b/drivers/bluetooth/btusb.c
2164 +@@ -2664,6 +2664,7 @@ static int btusb_mtk_submit_wmt_recv_urb(struct hci_dev *hdev)
2165 + buf = kmalloc(size, GFP_KERNEL);
2166 + if (!buf) {
2167 + kfree(dr);
2168 ++ usb_free_urb(urb);
2169 + return -ENOMEM;
2170 + }
2171 +
2172 +diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
2173 +index 85a30fb9177bb..f83d67eafc9f0 100644
2174 +--- a/drivers/bluetooth/hci_ldisc.c
2175 ++++ b/drivers/bluetooth/hci_ldisc.c
2176 +@@ -538,6 +538,7 @@ static void hci_uart_tty_close(struct tty_struct *tty)
2177 + clear_bit(HCI_UART_PROTO_READY, &hu->flags);
2178 + percpu_up_write(&hu->proto_lock);
2179 +
2180 ++ cancel_work_sync(&hu->init_ready);
2181 + cancel_work_sync(&hu->write_work);
2182 +
2183 + if (hdev) {
2184 +diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c
2185 +index ad2f26cb2622e..5b9aa73ff2b7f 100644
2186 +--- a/drivers/bluetooth/hci_serdev.c
2187 ++++ b/drivers/bluetooth/hci_serdev.c
2188 +@@ -357,6 +357,8 @@ void hci_uart_unregister_device(struct hci_uart *hu)
2189 + struct hci_dev *hdev = hu->hdev;
2190 +
2191 + clear_bit(HCI_UART_PROTO_READY, &hu->flags);
2192 ++
2193 ++ cancel_work_sync(&hu->init_ready);
2194 + if (test_bit(HCI_UART_REGISTERED, &hu->flags))
2195 + hci_unregister_dev(hdev);
2196 + hci_free_dev(hdev);
2197 +diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
2198 +index 6b9a0593d2eb7..b6e7df9e88503 100644
2199 +--- a/drivers/char/ipmi/ipmi_si_intf.c
2200 ++++ b/drivers/char/ipmi/ipmi_si_intf.c
2201 +@@ -1977,7 +1977,7 @@ static int try_smi_init(struct smi_info *new_smi)
2202 + /* Do this early so it's available for logs. */
2203 + if (!new_smi->io.dev) {
2204 + pr_err("IPMI interface added with no device\n");
2205 +- rv = EIO;
2206 ++ rv = -EIO;
2207 + goto out_err;
2208 + }
2209 +
2210 +diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
2211 +index 37c22667e8319..4313ecb2af5b2 100644
2212 +--- a/drivers/clk/at91/clk-main.c
2213 ++++ b/drivers/clk/at91/clk-main.c
2214 +@@ -437,12 +437,17 @@ static int clk_sam9x5_main_set_parent(struct clk_hw *hw, u8 index)
2215 + return -EINVAL;
2216 +
2217 + regmap_read(regmap, AT91_CKGR_MOR, &tmp);
2218 +- tmp &= ~MOR_KEY_MASK;
2219 +
2220 + if (index && !(tmp & AT91_PMC_MOSCSEL))
2221 +- regmap_write(regmap, AT91_CKGR_MOR, tmp | AT91_PMC_MOSCSEL);
2222 ++ tmp = AT91_PMC_MOSCSEL;
2223 + else if (!index && (tmp & AT91_PMC_MOSCSEL))
2224 +- regmap_write(regmap, AT91_CKGR_MOR, tmp & ~AT91_PMC_MOSCSEL);
2225 ++ tmp = 0;
2226 ++ else
2227 ++ return 0;
2228 ++
2229 ++ regmap_update_bits(regmap, AT91_CKGR_MOR,
2230 ++ AT91_PMC_MOSCSEL | MOR_KEY_MASK,
2231 ++ tmp | AT91_PMC_KEY);
2232 +
2233 + while (!clk_sam9x5_main_ready(regmap))
2234 + cpu_relax();
2235 +diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
2236 +index 45420b514149f..c5486537b9284 100644
2237 +--- a/drivers/clk/bcm/clk-bcm2835.c
2238 ++++ b/drivers/clk/bcm/clk-bcm2835.c
2239 +@@ -1336,8 +1336,10 @@ static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
2240 + pll->hw.init = &init;
2241 +
2242 + ret = devm_clk_hw_register(cprman->dev, &pll->hw);
2243 +- if (ret)
2244 ++ if (ret) {
2245 ++ kfree(pll);
2246 + return NULL;
2247 ++ }
2248 + return &pll->hw;
2249 + }
2250 +
2251 +diff --git a/drivers/clk/imx/clk-imx8mq.c b/drivers/clk/imx/clk-imx8mq.c
2252 +index 41fc9c63356ea..1846bd879dd71 100644
2253 +--- a/drivers/clk/imx/clk-imx8mq.c
2254 ++++ b/drivers/clk/imx/clk-imx8mq.c
2255 +@@ -157,10 +157,10 @@ static const char * const imx8mq_qspi_sels[] = {"osc_25m", "sys1_pll_400m", "sys
2256 + "audio_pll2_out", "sys1_pll_266m", "sys3_pll_out", "sys1_pll_100m", };
2257 +
2258 + static const char * const imx8mq_usdhc1_sels[] = {"osc_25m", "sys1_pll_400m", "sys1_pll_800m", "sys2_pll_500m",
2259 +- "audio_pll2_out", "sys1_pll_266m", "sys3_pll_out", "sys1_pll_100m", };
2260 ++ "sys3_pll_out", "sys1_pll_266m", "audio_pll2_out", "sys1_pll_100m", };
2261 +
2262 + static const char * const imx8mq_usdhc2_sels[] = {"osc_25m", "sys1_pll_400m", "sys1_pll_800m", "sys2_pll_500m",
2263 +- "audio_pll2_out", "sys1_pll_266m", "sys3_pll_out", "sys1_pll_100m", };
2264 ++ "sys3_pll_out", "sys1_pll_266m", "audio_pll2_out", "sys1_pll_100m", };
2265 +
2266 + static const char * const imx8mq_i2c1_sels[] = {"osc_25m", "sys1_pll_160m", "sys2_pll_50m", "sys3_pll_out", "audio_pll1_out",
2267 + "video_pll1_out", "audio_pll2_out", "sys1_pll_133m", };
2268 +diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c
2269 +index 7edf8c8432b67..64ea895f1a7df 100644
2270 +--- a/drivers/clk/keystone/sci-clk.c
2271 ++++ b/drivers/clk/keystone/sci-clk.c
2272 +@@ -522,7 +522,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider)
2273 + np = of_find_node_with_property(np, *clk_name);
2274 + if (!np) {
2275 + clk_name++;
2276 +- break;
2277 ++ continue;
2278 + }
2279 +
2280 + if (!of_device_is_available(np))
2281 +diff --git a/drivers/clk/mediatek/clk-mt6779.c b/drivers/clk/mediatek/clk-mt6779.c
2282 +index 608a9a6621a37..00920182bbe63 100644
2283 +--- a/drivers/clk/mediatek/clk-mt6779.c
2284 ++++ b/drivers/clk/mediatek/clk-mt6779.c
2285 +@@ -919,6 +919,8 @@ static const struct mtk_gate infra_clks[] = {
2286 + "pwm_sel", 19),
2287 + GATE_INFRA0(CLK_INFRA_PWM, "infra_pwm",
2288 + "pwm_sel", 21),
2289 ++ GATE_INFRA0(CLK_INFRA_UART0, "infra_uart0",
2290 ++ "uart_sel", 22),
2291 + GATE_INFRA0(CLK_INFRA_UART1, "infra_uart1",
2292 + "uart_sel", 23),
2293 + GATE_INFRA0(CLK_INFRA_UART2, "infra_uart2",
2294 +diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
2295 +index d2760a021301d..3143e16065de6 100644
2296 +--- a/drivers/clk/meson/g12a.c
2297 ++++ b/drivers/clk/meson/g12a.c
2298 +@@ -298,6 +298,17 @@ static struct clk_regmap g12a_fclk_div2 = {
2299 + &g12a_fclk_div2_div.hw
2300 + },
2301 + .num_parents = 1,
2302 ++ /*
2303 ++ * Similar to fclk_div3, it seems that this clock is used by
2304 ++ * the resident firmware and is required by the platform to
2305 ++ * operate correctly.
2306 ++ * Until the following condition are met, we need this clock to
2307 ++ * be marked as critical:
2308 ++ * a) Mark the clock used by a firmware resource, if possible
2309 ++ * b) CCF has a clock hand-off mechanism to make the sure the
2310 ++ * clock stays on until the proper driver comes along
2311 ++ */
2312 ++ .flags = CLK_IS_CRITICAL,
2313 + },
2314 + };
2315 +
2316 +diff --git a/drivers/clk/qcom/gcc-sdm660.c b/drivers/clk/qcom/gcc-sdm660.c
2317 +index c6fb57cd576f5..aa5c0c6ead017 100644
2318 +--- a/drivers/clk/qcom/gcc-sdm660.c
2319 ++++ b/drivers/clk/qcom/gcc-sdm660.c
2320 +@@ -666,7 +666,7 @@ static struct clk_rcg2 hmss_rbcpr_clk_src = {
2321 + .cmd_rcgr = 0x48044,
2322 + .mnd_width = 0,
2323 + .hid_width = 5,
2324 +- .parent_map = gcc_parent_map_xo_gpll0_gpll0_early_div,
2325 ++ .parent_map = gcc_parent_map_xo_gpll0,
2326 + .freq_tbl = ftbl_hmss_rbcpr_clk_src,
2327 + .clkr.hw.init = &(struct clk_init_data){
2328 + .name = "hmss_rbcpr_clk_src",
2329 +diff --git a/drivers/clk/rockchip/clk-half-divider.c b/drivers/clk/rockchip/clk-half-divider.c
2330 +index ba9f00dc9740c..7dd2e0b1a5866 100644
2331 +--- a/drivers/clk/rockchip/clk-half-divider.c
2332 ++++ b/drivers/clk/rockchip/clk-half-divider.c
2333 +@@ -167,7 +167,7 @@ struct clk *rockchip_clk_register_halfdiv(const char *name,
2334 + unsigned long flags,
2335 + spinlock_t *lock)
2336 + {
2337 +- struct clk *clk;
2338 ++ struct clk *clk = ERR_PTR(-ENOMEM);
2339 + struct clk_mux *mux = NULL;
2340 + struct clk_gate *gate = NULL;
2341 + struct clk_divider *div = NULL;
2342 +diff --git a/drivers/cpufreq/armada-37xx-cpufreq.c b/drivers/cpufreq/armada-37xx-cpufreq.c
2343 +index df1c941260d14..b4af4094309b0 100644
2344 +--- a/drivers/cpufreq/armada-37xx-cpufreq.c
2345 ++++ b/drivers/cpufreq/armada-37xx-cpufreq.c
2346 +@@ -484,6 +484,12 @@ remove_opp:
2347 + /* late_initcall, to guarantee the driver is loaded after A37xx clock driver */
2348 + late_initcall(armada37xx_cpufreq_driver_init);
2349 +
2350 ++static const struct of_device_id __maybe_unused armada37xx_cpufreq_of_match[] = {
2351 ++ { .compatible = "marvell,armada-3700-nb-pm" },
2352 ++ { },
2353 ++};
2354 ++MODULE_DEVICE_TABLE(of, armada37xx_cpufreq_of_match);
2355 ++
2356 + MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@××××××××××××××.com>");
2357 + MODULE_DESCRIPTION("Armada 37xx cpufreq driver");
2358 + MODULE_LICENSE("GPL");
2359 +diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
2360 +index 3a2f022f6bde2..bc6ccf2c7aae0 100644
2361 +--- a/drivers/cpufreq/powernv-cpufreq.c
2362 ++++ b/drivers/cpufreq/powernv-cpufreq.c
2363 +@@ -884,12 +884,15 @@ static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
2364 + unsigned long action, void *unused)
2365 + {
2366 + int cpu;
2367 +- struct cpufreq_policy cpu_policy;
2368 ++ struct cpufreq_policy *cpu_policy;
2369 +
2370 + rebooting = true;
2371 + for_each_online_cpu(cpu) {
2372 +- cpufreq_get_policy(&cpu_policy, cpu);
2373 +- powernv_cpufreq_target_index(&cpu_policy, get_nominal_index());
2374 ++ cpu_policy = cpufreq_cpu_get(cpu);
2375 ++ if (!cpu_policy)
2376 ++ continue;
2377 ++ powernv_cpufreq_target_index(cpu_policy, get_nominal_index());
2378 ++ cpufreq_cpu_put(cpu_policy);
2379 + }
2380 +
2381 + return NOTIFY_DONE;
2382 +diff --git a/drivers/crypto/caam/Kconfig b/drivers/crypto/caam/Kconfig
2383 +index 137ed3df0c74d..9612da122ceba 100644
2384 +--- a/drivers/crypto/caam/Kconfig
2385 ++++ b/drivers/crypto/caam/Kconfig
2386 +@@ -112,6 +112,7 @@ config CRYPTO_DEV_FSL_CAAM_CRYPTO_API_QI
2387 + select CRYPTO_AUTHENC
2388 + select CRYPTO_BLKCIPHER
2389 + select CRYPTO_DES
2390 ++ select CRYPTO_XTS
2391 + help
2392 + Selecting this will use CAAM Queue Interface (QI) for sending
2393 + & receiving crypto jobs to/from CAAM. This gives better performance
2394 +diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c
2395 +index 8e3449670d2f0..2a605a419df8b 100644
2396 +--- a/drivers/crypto/caam/caamalg_qi.c
2397 ++++ b/drivers/crypto/caam/caamalg_qi.c
2398 +@@ -18,6 +18,7 @@
2399 + #include "qi.h"
2400 + #include "jr.h"
2401 + #include "caamalg_desc.h"
2402 ++#include <asm/unaligned.h>
2403 +
2404 + /*
2405 + * crypto alg
2406 +@@ -67,6 +68,11 @@ struct caam_ctx {
2407 + struct device *qidev;
2408 + spinlock_t lock; /* Protects multiple init of driver context */
2409 + struct caam_drv_ctx *drv_ctx[NUM_OP];
2410 ++ struct crypto_skcipher *fallback;
2411 ++};
2412 ++
2413 ++struct caam_skcipher_req_ctx {
2414 ++ struct skcipher_request fallback_req;
2415 + };
2416 +
2417 + static int aead_set_sh_desc(struct crypto_aead *aead)
2418 +@@ -745,12 +751,17 @@ static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
2419 + struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher);
2420 + struct device *jrdev = ctx->jrdev;
2421 + int ret = 0;
2422 ++ int err;
2423 +
2424 + if (keylen != 2 * AES_MIN_KEY_SIZE && keylen != 2 * AES_MAX_KEY_SIZE) {
2425 + dev_err(jrdev, "key size mismatch\n");
2426 + goto badkey;
2427 + }
2428 +
2429 ++ err = crypto_skcipher_setkey(ctx->fallback, key, keylen);
2430 ++ if (err)
2431 ++ return err;
2432 ++
2433 + ctx->cdata.keylen = keylen;
2434 + ctx->cdata.key_virt = key;
2435 + ctx->cdata.key_inline = true;
2436 +@@ -1395,6 +1406,14 @@ static struct skcipher_edesc *skcipher_edesc_alloc(struct skcipher_request *req,
2437 + return edesc;
2438 + }
2439 +
2440 ++static inline bool xts_skcipher_ivsize(struct skcipher_request *req)
2441 ++{
2442 ++ struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
2443 ++ unsigned int ivsize = crypto_skcipher_ivsize(skcipher);
2444 ++
2445 ++ return !!get_unaligned((u64 *)(req->iv + (ivsize / 2)));
2446 ++}
2447 ++
2448 + static inline int skcipher_crypt(struct skcipher_request *req, bool encrypt)
2449 + {
2450 + struct skcipher_edesc *edesc;
2451 +@@ -1405,6 +1424,21 @@ static inline int skcipher_crypt(struct skcipher_request *req, bool encrypt)
2452 + if (!req->cryptlen)
2453 + return 0;
2454 +
2455 ++ if (ctx->fallback && xts_skcipher_ivsize(req)) {
2456 ++ struct caam_skcipher_req_ctx *rctx = skcipher_request_ctx(req);
2457 ++
2458 ++ skcipher_request_set_tfm(&rctx->fallback_req, ctx->fallback);
2459 ++ skcipher_request_set_callback(&rctx->fallback_req,
2460 ++ req->base.flags,
2461 ++ req->base.complete,
2462 ++ req->base.data);
2463 ++ skcipher_request_set_crypt(&rctx->fallback_req, req->src,
2464 ++ req->dst, req->cryptlen, req->iv);
2465 ++
2466 ++ return encrypt ? crypto_skcipher_encrypt(&rctx->fallback_req) :
2467 ++ crypto_skcipher_decrypt(&rctx->fallback_req);
2468 ++ }
2469 ++
2470 + if (unlikely(caam_congested))
2471 + return -EAGAIN;
2472 +
2473 +@@ -1529,6 +1563,7 @@ static struct caam_skcipher_alg driver_algs[] = {
2474 + .base = {
2475 + .cra_name = "xts(aes)",
2476 + .cra_driver_name = "xts-aes-caam-qi",
2477 ++ .cra_flags = CRYPTO_ALG_NEED_FALLBACK,
2478 + .cra_blocksize = AES_BLOCK_SIZE,
2479 + },
2480 + .setkey = xts_skcipher_setkey,
2481 +@@ -2462,9 +2497,32 @@ static int caam_cra_init(struct crypto_skcipher *tfm)
2482 + struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
2483 + struct caam_skcipher_alg *caam_alg =
2484 + container_of(alg, typeof(*caam_alg), skcipher);
2485 ++ struct caam_ctx *ctx = crypto_skcipher_ctx(tfm);
2486 ++ u32 alg_aai = caam_alg->caam.class1_alg_type & OP_ALG_AAI_MASK;
2487 ++ int ret = 0;
2488 ++
2489 ++ if (alg_aai == OP_ALG_AAI_XTS) {
2490 ++ const char *tfm_name = crypto_tfm_alg_name(&tfm->base);
2491 ++ struct crypto_skcipher *fallback;
2492 ++
2493 ++ fallback = crypto_alloc_skcipher(tfm_name, 0,
2494 ++ CRYPTO_ALG_NEED_FALLBACK);
2495 ++ if (IS_ERR(fallback)) {
2496 ++ dev_err(ctx->jrdev, "Failed to allocate %s fallback: %ld\n",
2497 ++ tfm_name, PTR_ERR(fallback));
2498 ++ return PTR_ERR(fallback);
2499 ++ }
2500 +
2501 +- return caam_init_common(crypto_skcipher_ctx(tfm), &caam_alg->caam,
2502 +- false);
2503 ++ ctx->fallback = fallback;
2504 ++ crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx) +
2505 ++ crypto_skcipher_reqsize(fallback));
2506 ++ }
2507 ++
2508 ++ ret = caam_init_common(ctx, &caam_alg->caam, false);
2509 ++ if (ret && ctx->fallback)
2510 ++ crypto_free_skcipher(ctx->fallback);
2511 ++
2512 ++ return ret;
2513 + }
2514 +
2515 + static int caam_aead_init(struct crypto_aead *tfm)
2516 +@@ -2490,7 +2548,11 @@ static void caam_exit_common(struct caam_ctx *ctx)
2517 +
2518 + static void caam_cra_exit(struct crypto_skcipher *tfm)
2519 + {
2520 +- caam_exit_common(crypto_skcipher_ctx(tfm));
2521 ++ struct caam_ctx *ctx = crypto_skcipher_ctx(tfm);
2522 ++
2523 ++ if (ctx->fallback)
2524 ++ crypto_free_skcipher(ctx->fallback);
2525 ++ caam_exit_common(ctx);
2526 + }
2527 +
2528 + static void caam_aead_exit(struct crypto_aead *tfm)
2529 +@@ -2524,7 +2586,7 @@ static void caam_skcipher_alg_init(struct caam_skcipher_alg *t_alg)
2530 + alg->base.cra_module = THIS_MODULE;
2531 + alg->base.cra_priority = CAAM_CRA_PRIORITY;
2532 + alg->base.cra_ctxsize = sizeof(struct caam_ctx);
2533 +- alg->base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY;
2534 ++ alg->base.cra_flags |= CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY;
2535 +
2536 + alg->init = caam_cra_init;
2537 + alg->exit = caam_cra_exit;
2538 +diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
2539 +index 64112c736810e..7234b95241e91 100644
2540 +--- a/drivers/crypto/ccp/ccp-ops.c
2541 ++++ b/drivers/crypto/ccp/ccp-ops.c
2542 +@@ -1746,7 +1746,7 @@ ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
2543 + break;
2544 + default:
2545 + ret = -EINVAL;
2546 +- goto e_ctx;
2547 ++ goto e_data;
2548 + }
2549 + } else {
2550 + /* Stash the context */
2551 +diff --git a/drivers/crypto/chelsio/chtls/chtls_cm.c b/drivers/crypto/chelsio/chtls/chtls_cm.c
2552 +index dffa2aa855fdd..9b410ffafc4dd 100644
2553 +--- a/drivers/crypto/chelsio/chtls/chtls_cm.c
2554 ++++ b/drivers/crypto/chelsio/chtls/chtls_cm.c
2555 +@@ -1053,6 +1053,9 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
2556 + ndev = n->dev;
2557 + if (!ndev)
2558 + goto free_dst;
2559 ++ if (is_vlan_dev(ndev))
2560 ++ ndev = vlan_dev_real_dev(ndev);
2561 ++
2562 + port_id = cxgb4_port_idx(ndev);
2563 +
2564 + csk = chtls_sock_create(cdev);
2565 +diff --git a/drivers/crypto/chelsio/chtls/chtls_io.c b/drivers/crypto/chelsio/chtls/chtls_io.c
2566 +index c403d6b64e087..a5903cfc83523 100644
2567 +--- a/drivers/crypto/chelsio/chtls/chtls_io.c
2568 ++++ b/drivers/crypto/chelsio/chtls/chtls_io.c
2569 +@@ -910,9 +910,9 @@ static int tls_header_read(struct tls_hdr *thdr, struct iov_iter *from)
2570 + return (__force int)cpu_to_be16(thdr->length);
2571 + }
2572 +
2573 +-static int csk_mem_free(struct chtls_dev *cdev, struct sock *sk)
2574 ++static bool csk_mem_free(struct chtls_dev *cdev, struct sock *sk)
2575 + {
2576 +- return (cdev->max_host_sndbuf - sk->sk_wmem_queued);
2577 ++ return (cdev->max_host_sndbuf - sk->sk_wmem_queued > 0);
2578 + }
2579 +
2580 + static int csk_wait_memory(struct chtls_dev *cdev,
2581 +@@ -1210,6 +1210,7 @@ int chtls_sendpage(struct sock *sk, struct page *page,
2582 + copied = 0;
2583 + csk = rcu_dereference_sk_user_data(sk);
2584 + cdev = csk->cdev;
2585 ++ lock_sock(sk);
2586 + timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
2587 +
2588 + err = sk_stream_wait_connect(sk, &timeo);
2589 +diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
2590 +index 9181523ba7607..acaa504d5a798 100644
2591 +--- a/drivers/crypto/ixp4xx_crypto.c
2592 ++++ b/drivers/crypto/ixp4xx_crypto.c
2593 +@@ -527,7 +527,7 @@ static void release_ixp_crypto(struct device *dev)
2594 +
2595 + if (crypt_virt) {
2596 + dma_free_coherent(dev,
2597 +- NPE_QLEN_TOTAL * sizeof( struct crypt_ctl),
2598 ++ NPE_QLEN * sizeof(struct crypt_ctl),
2599 + crypt_virt, crypt_phys);
2600 + }
2601 + }
2602 +diff --git a/drivers/crypto/mediatek/mtk-platform.c b/drivers/crypto/mediatek/mtk-platform.c
2603 +index 7e3ad085b5bdd..efce3a83b35a8 100644
2604 +--- a/drivers/crypto/mediatek/mtk-platform.c
2605 ++++ b/drivers/crypto/mediatek/mtk-platform.c
2606 +@@ -442,7 +442,7 @@ static void mtk_desc_dma_free(struct mtk_cryp *cryp)
2607 + static int mtk_desc_ring_alloc(struct mtk_cryp *cryp)
2608 + {
2609 + struct mtk_ring **ring = cryp->ring;
2610 +- int i, err = ENOMEM;
2611 ++ int i;
2612 +
2613 + for (i = 0; i < MTK_RING_MAX; i++) {
2614 + ring[i] = kzalloc(sizeof(**ring), GFP_KERNEL);
2615 +@@ -469,14 +469,14 @@ static int mtk_desc_ring_alloc(struct mtk_cryp *cryp)
2616 + return 0;
2617 +
2618 + err_cleanup:
2619 +- for (; i--; ) {
2620 ++ do {
2621 + dma_free_coherent(cryp->dev, MTK_DESC_RING_SZ,
2622 + ring[i]->res_base, ring[i]->res_dma);
2623 + dma_free_coherent(cryp->dev, MTK_DESC_RING_SZ,
2624 + ring[i]->cmd_base, ring[i]->cmd_dma);
2625 + kfree(ring[i]);
2626 +- }
2627 +- return err;
2628 ++ } while (i--);
2629 ++ return -ENOMEM;
2630 + }
2631 +
2632 + static int mtk_crypto_probe(struct platform_device *pdev)
2633 +diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
2634 +index aba5db3c0588f..d7c0c982ba433 100644
2635 +--- a/drivers/crypto/omap-sham.c
2636 ++++ b/drivers/crypto/omap-sham.c
2637 +@@ -453,6 +453,9 @@ static void omap_sham_write_ctrl_omap4(struct omap_sham_dev *dd, size_t length,
2638 + struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req);
2639 + u32 val, mask;
2640 +
2641 ++ if (likely(ctx->digcnt))
2642 ++ omap_sham_write(dd, SHA_REG_DIGCNT(dd), ctx->digcnt);
2643 ++
2644 + /*
2645 + * Setting ALGO_CONST only for the first iteration and
2646 + * CLOSE_HASH only for the last one. Note that flags mode bits
2647 +diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c
2648 +index 2680e1525db58..13ecbb0e58528 100644
2649 +--- a/drivers/crypto/picoxcell_crypto.c
2650 ++++ b/drivers/crypto/picoxcell_crypto.c
2651 +@@ -1697,11 +1697,6 @@ static int spacc_probe(struct platform_device *pdev)
2652 + goto err_clk_put;
2653 + }
2654 +
2655 +- ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh);
2656 +- if (ret)
2657 +- goto err_clk_disable;
2658 +-
2659 +-
2660 + /*
2661 + * Use an IRQ threshold of 50% as a default. This seems to be a
2662 + * reasonable trade off of latency against throughput but can be
2663 +@@ -1709,6 +1704,10 @@ static int spacc_probe(struct platform_device *pdev)
2664 + */
2665 + engine->stat_irq_thresh = (engine->fifo_sz / 2);
2666 +
2667 ++ ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh);
2668 ++ if (ret)
2669 ++ goto err_clk_disable;
2670 ++
2671 + /*
2672 + * Configure the interrupts. We only use the STAT_CNT interrupt as we
2673 + * only submit a new packet for processing when we complete another in
2674 +diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
2675 +index 62d9825a49e9d..238936e2dfe2d 100644
2676 +--- a/drivers/dma/dmatest.c
2677 ++++ b/drivers/dma/dmatest.c
2678 +@@ -1218,15 +1218,14 @@ static int dmatest_chan_set(const char *val, const struct kernel_param *kp)
2679 + add_threaded_test(info);
2680 +
2681 + /* Check if channel was added successfully */
2682 +- dtc = list_last_entry(&info->channels, struct dmatest_chan, node);
2683 +-
2684 +- if (dtc->chan) {
2685 ++ if (!list_empty(&info->channels)) {
2686 + /*
2687 + * if new channel was not successfully added, revert the
2688 + * "test_channel" string to the name of the last successfully
2689 + * added channel. exception for when users issues empty string
2690 + * to channel parameter.
2691 + */
2692 ++ dtc = list_last_entry(&info->channels, struct dmatest_chan, node);
2693 + if ((strcmp(dma_chan_name(dtc->chan), strim(test_channel)) != 0)
2694 + && (strcmp("", strim(test_channel)) != 0)) {
2695 + ret = -EINVAL;
2696 +diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
2697 +index a1b56f52db2f2..5e7fdc0b6e3db 100644
2698 +--- a/drivers/dma/dw/core.c
2699 ++++ b/drivers/dma/dw/core.c
2700 +@@ -772,6 +772,10 @@ bool dw_dma_filter(struct dma_chan *chan, void *param)
2701 + if (dws->dma_dev != chan->device->dev)
2702 + return false;
2703 +
2704 ++ /* permit channels in accordance with the channels mask */
2705 ++ if (dws->channels && !(dws->channels & dwc->mask))
2706 ++ return false;
2707 ++
2708 + /* We have to copy data since dws can be temporary storage */
2709 + memcpy(&dwc->dws, dws, sizeof(struct dw_dma_slave));
2710 +
2711 +diff --git a/drivers/dma/dw/dw.c b/drivers/dma/dw/dw.c
2712 +index 7a085b3c1854c..d9810980920a1 100644
2713 +--- a/drivers/dma/dw/dw.c
2714 ++++ b/drivers/dma/dw/dw.c
2715 +@@ -14,7 +14,7 @@
2716 + static void dw_dma_initialize_chan(struct dw_dma_chan *dwc)
2717 + {
2718 + struct dw_dma *dw = to_dw_dma(dwc->chan.device);
2719 +- u32 cfghi = DWC_CFGH_FIFO_MODE;
2720 ++ u32 cfghi = is_slave_direction(dwc->direction) ? 0 : DWC_CFGH_FIFO_MODE;
2721 + u32 cfglo = DWC_CFGL_CH_PRIOR(dwc->priority);
2722 + bool hs_polarity = dwc->dws.hs_polarity;
2723 +
2724 +diff --git a/drivers/dma/dw/of.c b/drivers/dma/dw/of.c
2725 +index 9e27831dee324..43e975fb67142 100644
2726 +--- a/drivers/dma/dw/of.c
2727 ++++ b/drivers/dma/dw/of.c
2728 +@@ -22,18 +22,21 @@ static struct dma_chan *dw_dma_of_xlate(struct of_phandle_args *dma_spec,
2729 + };
2730 + dma_cap_mask_t cap;
2731 +
2732 +- if (dma_spec->args_count != 3)
2733 ++ if (dma_spec->args_count < 3 || dma_spec->args_count > 4)
2734 + return NULL;
2735 +
2736 + slave.src_id = dma_spec->args[0];
2737 + slave.dst_id = dma_spec->args[0];
2738 + slave.m_master = dma_spec->args[1];
2739 + slave.p_master = dma_spec->args[2];
2740 ++ if (dma_spec->args_count >= 4)
2741 ++ slave.channels = dma_spec->args[3];
2742 +
2743 + if (WARN_ON(slave.src_id >= DW_DMA_MAX_NR_REQUESTS ||
2744 + slave.dst_id >= DW_DMA_MAX_NR_REQUESTS ||
2745 + slave.m_master >= dw->pdata->nr_masters ||
2746 +- slave.p_master >= dw->pdata->nr_masters))
2747 ++ slave.p_master >= dw->pdata->nr_masters ||
2748 ++ slave.channels >= BIT(dw->pdata->nr_channels)))
2749 + return NULL;
2750 +
2751 + dma_cap_zero(cap);
2752 +diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
2753 +index 5634437bb39d2..66669f9d690be 100644
2754 +--- a/drivers/edac/aspeed_edac.c
2755 ++++ b/drivers/edac/aspeed_edac.c
2756 +@@ -209,8 +209,8 @@ static int config_irq(void *ctx, struct platform_device *pdev)
2757 + /* register interrupt handler */
2758 + irq = platform_get_irq(pdev, 0);
2759 + dev_dbg(&pdev->dev, "got irq %d\n", irq);
2760 +- if (!irq)
2761 +- return -ENODEV;
2762 ++ if (irq < 0)
2763 ++ return irq;
2764 +
2765 + rc = devm_request_irq(&pdev->dev, irq, mcr_isr, IRQF_TRIGGER_HIGH,
2766 + DRV_NAME, ctx);
2767 +diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
2768 +index 251f2b692785d..0c72daa519ffa 100644
2769 +--- a/drivers/edac/i5100_edac.c
2770 ++++ b/drivers/edac/i5100_edac.c
2771 +@@ -1074,16 +1074,15 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
2772 + PCI_DEVICE_ID_INTEL_5100_19, 0);
2773 + if (!einj) {
2774 + ret = -ENODEV;
2775 +- goto bail_einj;
2776 ++ goto bail_mc_free;
2777 + }
2778 +
2779 + rc = pci_enable_device(einj);
2780 + if (rc < 0) {
2781 + ret = rc;
2782 +- goto bail_disable_einj;
2783 ++ goto bail_einj;
2784 + }
2785 +
2786 +-
2787 + mci->pdev = &pdev->dev;
2788 +
2789 + priv = mci->pvt_info;
2790 +@@ -1149,14 +1148,14 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
2791 + bail_scrub:
2792 + priv->scrub_enable = 0;
2793 + cancel_delayed_work_sync(&(priv->i5100_scrubbing));
2794 +- edac_mc_free(mci);
2795 +-
2796 +-bail_disable_einj:
2797 + pci_disable_device(einj);
2798 +
2799 + bail_einj:
2800 + pci_dev_put(einj);
2801 +
2802 ++bail_mc_free:
2803 ++ edac_mc_free(mci);
2804 ++
2805 + bail_disable_ch1:
2806 + pci_disable_device(ch1mm);
2807 +
2808 +diff --git a/drivers/edac/ti_edac.c b/drivers/edac/ti_edac.c
2809 +index 6ac26d1b929f0..3247689467435 100644
2810 +--- a/drivers/edac/ti_edac.c
2811 ++++ b/drivers/edac/ti_edac.c
2812 +@@ -278,7 +278,8 @@ static int ti_edac_probe(struct platform_device *pdev)
2813 +
2814 + /* add EMIF ECC error handler */
2815 + error_irq = platform_get_irq(pdev, 0);
2816 +- if (!error_irq) {
2817 ++ if (error_irq < 0) {
2818 ++ ret = error_irq;
2819 + edac_printk(KERN_ERR, EDAC_MOD_NAME,
2820 + "EMIF irq number not defined.\n");
2821 + goto err;
2822 +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
2823 +index 2384aa018993d..7c58085031732 100644
2824 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
2825 ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
2826 +@@ -6984,8 +6984,7 @@ static int dm_update_plane_state(struct dc *dc,
2827 + dm_old_plane_state->dc_state,
2828 + dm_state->context)) {
2829 +
2830 +- ret = EINVAL;
2831 +- return ret;
2832 ++ return -EINVAL;
2833 + }
2834 +
2835 +
2836 +diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c
2837 +index 6a626c82e264b..f6598c5a9a879 100644
2838 +--- a/drivers/gpu/drm/drm_debugfs_crc.c
2839 ++++ b/drivers/gpu/drm/drm_debugfs_crc.c
2840 +@@ -144,8 +144,10 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf,
2841 + source[len - 1] = '\0';
2842 +
2843 + ret = crtc->funcs->verify_crc_source(crtc, source, &values_cnt);
2844 +- if (ret)
2845 ++ if (ret) {
2846 ++ kfree(source);
2847 + return ret;
2848 ++ }
2849 +
2850 + spin_lock_irq(&crc->lock);
2851 +
2852 +diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c b/drivers/gpu/drm/gma500/cdv_intel_dp.c
2853 +index 570b59520fd13..2ff4b35151bf8 100644
2854 +--- a/drivers/gpu/drm/gma500/cdv_intel_dp.c
2855 ++++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c
2856 +@@ -2120,7 +2120,7 @@ cdv_intel_dp_init(struct drm_device *dev, struct psb_intel_mode_device *mode_dev
2857 + intel_dp->dpcd,
2858 + sizeof(intel_dp->dpcd));
2859 + cdv_intel_edp_panel_vdd_off(gma_encoder);
2860 +- if (ret == 0) {
2861 ++ if (ret <= 0) {
2862 + /* if this fails, presume the device is a ghost */
2863 + DRM_INFO("failed to retrieve link info, disabling eDP\n");
2864 + cdv_intel_dp_encoder_destroy(encoder);
2865 +diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
2866 +index 691c1a277d91b..dfcbb2b7cdda3 100644
2867 +--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
2868 ++++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
2869 +@@ -834,7 +834,7 @@ static void a6xx_get_indexed_registers(struct msm_gpu *gpu,
2870 + int i;
2871 +
2872 + a6xx_state->indexed_regs = state_kcalloc(a6xx_state, count,
2873 +- sizeof(a6xx_state->indexed_regs));
2874 ++ sizeof(*a6xx_state->indexed_regs));
2875 + if (!a6xx_state->indexed_regs)
2876 + return;
2877 +
2878 +diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
2879 +index 36c85c05b7cf7..4aed5e9a84a45 100644
2880 +--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
2881 ++++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
2882 +@@ -819,7 +819,7 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
2883 + struct drm_plane *plane;
2884 + struct drm_display_mode *mode;
2885 +
2886 +- int cnt = 0, rc = 0, mixer_width, i, z_pos;
2887 ++ int cnt = 0, rc = 0, mixer_width = 0, i, z_pos;
2888 +
2889 + struct dpu_multirect_plane_states multirect_plane[DPU_STAGE_MAX * 2];
2890 + int multirect_count = 0;
2891 +@@ -852,9 +852,11 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
2892 +
2893 + memset(pipe_staged, 0, sizeof(pipe_staged));
2894 +
2895 +- mixer_width = mode->hdisplay / cstate->num_mixers;
2896 ++ if (cstate->num_mixers) {
2897 ++ mixer_width = mode->hdisplay / cstate->num_mixers;
2898 +
2899 +- _dpu_crtc_setup_lm_bounds(crtc, state);
2900 ++ _dpu_crtc_setup_lm_bounds(crtc, state);
2901 ++ }
2902 +
2903 + crtc_rect.x2 = mode->hdisplay;
2904 + crtc_rect.y2 = mode->vdisplay;
2905 +diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
2906 +index e8506335cd155..1694a7deb9133 100644
2907 +--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
2908 ++++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
2909 +@@ -26,6 +26,7 @@
2910 + #include <drm/drm_drv.h>
2911 + #include <drm/drm_fb_cma_helper.h>
2912 + #include <drm/drm_fb_helper.h>
2913 ++#include <drm/drm_fourcc.h>
2914 + #include <drm/drm_gem_cma_helper.h>
2915 + #include <drm/drm_gem_framebuffer_helper.h>
2916 + #include <drm/drm_irq.h>
2917 +@@ -87,8 +88,26 @@ void mxsfb_disable_axi_clk(struct mxsfb_drm_private *mxsfb)
2918 + clk_disable_unprepare(mxsfb->clk_axi);
2919 + }
2920 +
2921 ++static struct drm_framebuffer *
2922 ++mxsfb_fb_create(struct drm_device *dev, struct drm_file *file_priv,
2923 ++ const struct drm_mode_fb_cmd2 *mode_cmd)
2924 ++{
2925 ++ const struct drm_format_info *info;
2926 ++
2927 ++ info = drm_get_format_info(dev, mode_cmd);
2928 ++ if (!info)
2929 ++ return ERR_PTR(-EINVAL);
2930 ++
2931 ++ if (mode_cmd->width * info->cpp[0] != mode_cmd->pitches[0]) {
2932 ++ dev_dbg(dev->dev, "Invalid pitch: fb width must match pitch\n");
2933 ++ return ERR_PTR(-EINVAL);
2934 ++ }
2935 ++
2936 ++ return drm_gem_fb_create(dev, file_priv, mode_cmd);
2937 ++}
2938 ++
2939 + static const struct drm_mode_config_funcs mxsfb_mode_config_funcs = {
2940 +- .fb_create = drm_gem_fb_create,
2941 ++ .fb_create = mxsfb_fb_create,
2942 + .atomic_check = drm_atomic_helper_check,
2943 + .atomic_commit = drm_atomic_helper_commit,
2944 + };
2945 +diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
2946 +index 6d9656323a3f4..f0ea782df836d 100644
2947 +--- a/drivers/gpu/drm/panel/panel-simple.c
2948 ++++ b/drivers/gpu/drm/panel/panel-simple.c
2949 +@@ -2382,12 +2382,12 @@ static const struct drm_display_mode ortustech_com43h4m85ulc_mode = {
2950 + static const struct panel_desc ortustech_com43h4m85ulc = {
2951 + .modes = &ortustech_com43h4m85ulc_mode,
2952 + .num_modes = 1,
2953 +- .bpc = 8,
2954 ++ .bpc = 6,
2955 + .size = {
2956 + .width = 56,
2957 + .height = 93,
2958 + },
2959 +- .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
2960 ++ .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
2961 + .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE,
2962 + };
2963 +
2964 +diff --git a/drivers/gpu/drm/panfrost/panfrost_gpu.c b/drivers/gpu/drm/panfrost/panfrost_gpu.c
2965 +index 8822ec13a0d61..0d39a201c7591 100644
2966 +--- a/drivers/gpu/drm/panfrost/panfrost_gpu.c
2967 ++++ b/drivers/gpu/drm/panfrost/panfrost_gpu.c
2968 +@@ -75,6 +75,17 @@ int panfrost_gpu_soft_reset(struct panfrost_device *pfdev)
2969 + return 0;
2970 + }
2971 +
2972 ++void panfrost_gpu_amlogic_quirk(struct panfrost_device *pfdev)
2973 ++{
2974 ++ /*
2975 ++ * The Amlogic integrated Mali-T820, Mali-G31 & Mali-G52 needs
2976 ++ * these undocumented bits in GPU_PWR_OVERRIDE1 to be set in order
2977 ++ * to operate correctly.
2978 ++ */
2979 ++ gpu_write(pfdev, GPU_PWR_KEY, GPU_PWR_KEY_UNLOCK);
2980 ++ gpu_write(pfdev, GPU_PWR_OVERRIDE1, 0xfff | (0x20 << 16));
2981 ++}
2982 ++
2983 + static void panfrost_gpu_init_quirks(struct panfrost_device *pfdev)
2984 + {
2985 + u32 quirks = 0;
2986 +@@ -304,6 +315,8 @@ void panfrost_gpu_power_on(struct panfrost_device *pfdev)
2987 + int ret;
2988 + u32 val;
2989 +
2990 ++ panfrost_gpu_init_quirks(pfdev);
2991 ++
2992 + /* Just turn on everything for now */
2993 + gpu_write(pfdev, L2_PWRON_LO, pfdev->features.l2_present);
2994 + ret = readl_relaxed_poll_timeout(pfdev->iomem + L2_READY_LO,
2995 +@@ -357,7 +370,6 @@ int panfrost_gpu_init(struct panfrost_device *pfdev)
2996 + return err;
2997 + }
2998 +
2999 +- panfrost_gpu_init_quirks(pfdev);
3000 + panfrost_gpu_power_on(pfdev);
3001 +
3002 + return 0;
3003 +diff --git a/drivers/gpu/drm/panfrost/panfrost_gpu.h b/drivers/gpu/drm/panfrost/panfrost_gpu.h
3004 +index 4112412087b27..468c51e7e46db 100644
3005 +--- a/drivers/gpu/drm/panfrost/panfrost_gpu.h
3006 ++++ b/drivers/gpu/drm/panfrost/panfrost_gpu.h
3007 +@@ -16,4 +16,6 @@ int panfrost_gpu_soft_reset(struct panfrost_device *pfdev);
3008 + void panfrost_gpu_power_on(struct panfrost_device *pfdev);
3009 + void panfrost_gpu_power_off(struct panfrost_device *pfdev);
3010 +
3011 ++void panfrost_gpu_amlogic_quirk(struct panfrost_device *pfdev);
3012 ++
3013 + #endif
3014 +diff --git a/drivers/gpu/drm/panfrost/panfrost_regs.h b/drivers/gpu/drm/panfrost/panfrost_regs.h
3015 +index ea38ac60581c6..eddaa62ad8b0e 100644
3016 +--- a/drivers/gpu/drm/panfrost/panfrost_regs.h
3017 ++++ b/drivers/gpu/drm/panfrost/panfrost_regs.h
3018 +@@ -51,6 +51,10 @@
3019 + #define GPU_STATUS 0x34
3020 + #define GPU_STATUS_PRFCNT_ACTIVE BIT(2)
3021 + #define GPU_LATEST_FLUSH_ID 0x38
3022 ++#define GPU_PWR_KEY 0x50 /* (WO) Power manager key register */
3023 ++#define GPU_PWR_KEY_UNLOCK 0x2968A819
3024 ++#define GPU_PWR_OVERRIDE0 0x54 /* (RW) Power manager override settings */
3025 ++#define GPU_PWR_OVERRIDE1 0x58 /* (RW) Power manager override settings */
3026 + #define GPU_FAULT_STATUS 0x3C
3027 + #define GPU_FAULT_ADDRESS_LO 0x40
3028 + #define GPU_FAULT_ADDRESS_HI 0x44
3029 +diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
3030 +index c190702fab726..6dcc05ab31eba 100644
3031 +--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
3032 ++++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
3033 +@@ -96,8 +96,10 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev,
3034 + vgdev->capsets[i].id > 0, 5 * HZ);
3035 + if (ret == 0) {
3036 + DRM_ERROR("timed out waiting for cap set %d\n", i);
3037 ++ spin_lock(&vgdev->display_info_lock);
3038 + kfree(vgdev->capsets);
3039 + vgdev->capsets = NULL;
3040 ++ spin_unlock(&vgdev->display_info_lock);
3041 + return;
3042 + }
3043 + DRM_INFO("cap set %d: id %d, max-version %d, max-size %d\n",
3044 +diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
3045 +index 7ac20490e1b4c..92022a83bbd5e 100644
3046 +--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
3047 ++++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
3048 +@@ -572,9 +572,13 @@ static void virtio_gpu_cmd_get_capset_info_cb(struct virtio_gpu_device *vgdev,
3049 + int i = le32_to_cpu(cmd->capset_index);
3050 +
3051 + spin_lock(&vgdev->display_info_lock);
3052 +- vgdev->capsets[i].id = le32_to_cpu(resp->capset_id);
3053 +- vgdev->capsets[i].max_version = le32_to_cpu(resp->capset_max_version);
3054 +- vgdev->capsets[i].max_size = le32_to_cpu(resp->capset_max_size);
3055 ++ if (vgdev->capsets) {
3056 ++ vgdev->capsets[i].id = le32_to_cpu(resp->capset_id);
3057 ++ vgdev->capsets[i].max_version = le32_to_cpu(resp->capset_max_version);
3058 ++ vgdev->capsets[i].max_size = le32_to_cpu(resp->capset_max_size);
3059 ++ } else {
3060 ++ DRM_ERROR("invalid capset memory.");
3061 ++ }
3062 + spin_unlock(&vgdev->display_info_lock);
3063 + wake_up(&vgdev->resp_wq);
3064 + }
3065 +diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
3066 +index d5585695c64d1..45d6ebbdbdb22 100644
3067 +--- a/drivers/gpu/drm/vkms/vkms_composer.c
3068 ++++ b/drivers/gpu/drm/vkms/vkms_composer.c
3069 +@@ -33,7 +33,7 @@ static uint32_t compute_crc(void *vaddr_out, struct vkms_composer *composer)
3070 + + (i * composer->pitch)
3071 + + (j * composer->cpp);
3072 + /* XRGB format ignores Alpha channel */
3073 +- memset(vaddr_out + src_offset + 24, 0, 8);
3074 ++ bitmap_clear(vaddr_out + src_offset, 24, 8);
3075 + crc = crc32_le(crc, vaddr_out + src_offset,
3076 + sizeof(u32));
3077 + }
3078 +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
3079 +index e03a4d794240c..7363d0b488bd8 100644
3080 +--- a/drivers/hid/hid-ids.h
3081 ++++ b/drivers/hid/hid-ids.h
3082 +@@ -1119,6 +1119,7 @@
3083 + #define USB_DEVICE_ID_SYNAPTICS_DELL_K12A 0x2819
3084 + #define USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012 0x2968
3085 + #define USB_DEVICE_ID_SYNAPTICS_TP_V103 0x5710
3086 ++#define USB_DEVICE_ID_SYNAPTICS_ACER_ONE_S1003 0x73f5
3087 + #define USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5 0x81a7
3088 +
3089 + #define USB_VENDOR_ID_TEXAS_INSTRUMENTS 0x2047
3090 +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
3091 +index e3d475f4baf66..b2bff932c524f 100644
3092 +--- a/drivers/hid/hid-input.c
3093 ++++ b/drivers/hid/hid-input.c
3094 +@@ -797,7 +797,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
3095 + case 0x3b: /* Battery Strength */
3096 + hidinput_setup_battery(device, HID_INPUT_REPORT, field);
3097 + usage->type = EV_PWR;
3098 +- goto ignore;
3099 ++ return;
3100 +
3101 + case 0x3c: /* Invert */
3102 + map_key_clear(BTN_TOOL_RUBBER);
3103 +@@ -1059,7 +1059,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
3104 + case HID_DC_BATTERYSTRENGTH:
3105 + hidinput_setup_battery(device, HID_INPUT_REPORT, field);
3106 + usage->type = EV_PWR;
3107 +- goto ignore;
3108 ++ return;
3109 + }
3110 + goto unknown;
3111 +
3112 +diff --git a/drivers/hid/hid-ite.c b/drivers/hid/hid-ite.c
3113 +index 6c55682c59740..044a93f3c1178 100644
3114 +--- a/drivers/hid/hid-ite.c
3115 ++++ b/drivers/hid/hid-ite.c
3116 +@@ -44,6 +44,10 @@ static const struct hid_device_id ite_devices[] = {
3117 + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
3118 + USB_VENDOR_ID_SYNAPTICS,
3119 + USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012) },
3120 ++ /* ITE8910 USB kbd ctlr, with Synaptics touchpad connected to it. */
3121 ++ { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
3122 ++ USB_VENDOR_ID_SYNAPTICS,
3123 ++ USB_DEVICE_ID_SYNAPTICS_ACER_ONE_S1003) },
3124 + { }
3125 + };
3126 + MODULE_DEVICE_TABLE(hid, ite_devices);
3127 +diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
3128 +index 1a6e600197d0b..509b9bb1362cb 100644
3129 +--- a/drivers/hid/hid-roccat-kone.c
3130 ++++ b/drivers/hid/hid-roccat-kone.c
3131 +@@ -294,31 +294,40 @@ static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj,
3132 + struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev));
3133 + struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
3134 + int retval = 0, difference, old_profile;
3135 ++ struct kone_settings *settings = (struct kone_settings *)buf;
3136 +
3137 + /* I need to get my data in one piece */
3138 + if (off != 0 || count != sizeof(struct kone_settings))
3139 + return -EINVAL;
3140 +
3141 + mutex_lock(&kone->kone_lock);
3142 +- difference = memcmp(buf, &kone->settings, sizeof(struct kone_settings));
3143 ++ difference = memcmp(settings, &kone->settings,
3144 ++ sizeof(struct kone_settings));
3145 + if (difference) {
3146 +- retval = kone_set_settings(usb_dev,
3147 +- (struct kone_settings const *)buf);
3148 +- if (retval) {
3149 +- mutex_unlock(&kone->kone_lock);
3150 +- return retval;
3151 ++ if (settings->startup_profile < 1 ||
3152 ++ settings->startup_profile > 5) {
3153 ++ retval = -EINVAL;
3154 ++ goto unlock;
3155 + }
3156 +
3157 ++ retval = kone_set_settings(usb_dev, settings);
3158 ++ if (retval)
3159 ++ goto unlock;
3160 ++
3161 + old_profile = kone->settings.startup_profile;
3162 +- memcpy(&kone->settings, buf, sizeof(struct kone_settings));
3163 ++ memcpy(&kone->settings, settings, sizeof(struct kone_settings));
3164 +
3165 + kone_profile_activated(kone, kone->settings.startup_profile);
3166 +
3167 + if (kone->settings.startup_profile != old_profile)
3168 + kone_profile_report(kone, kone->settings.startup_profile);
3169 + }
3170 ++unlock:
3171 + mutex_unlock(&kone->kone_lock);
3172 +
3173 ++ if (retval)
3174 ++ return retval;
3175 ++
3176 + return sizeof(struct kone_settings);
3177 + }
3178 + static BIN_ATTR(settings, 0660, kone_sysfs_read_settings,
3179 +diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c
3180 +index 5c63a66007293..e22617def70bf 100644
3181 +--- a/drivers/hwmon/pmbus/max34440.c
3182 ++++ b/drivers/hwmon/pmbus/max34440.c
3183 +@@ -387,7 +387,6 @@ static struct pmbus_driver_info max34440_info[] = {
3184 + .func[18] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
3185 + .func[19] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
3186 + .func[20] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
3187 +- .read_byte_data = max34440_read_byte_data,
3188 + .read_word_data = max34440_read_word_data,
3189 + .write_word_data = max34440_write_word_data,
3190 + },
3191 +@@ -418,7 +417,6 @@ static struct pmbus_driver_info max34440_info[] = {
3192 + .func[15] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
3193 + .func[16] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
3194 + .func[17] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
3195 +- .read_byte_data = max34440_read_byte_data,
3196 + .read_word_data = max34440_read_word_data,
3197 + .write_word_data = max34440_write_word_data,
3198 + },
3199 +@@ -454,7 +452,6 @@ static struct pmbus_driver_info max34440_info[] = {
3200 + .func[19] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
3201 + .func[20] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
3202 + .func[21] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
3203 +- .read_byte_data = max34440_read_byte_data,
3204 + .read_word_data = max34440_read_word_data,
3205 + .write_word_data = max34440_write_word_data,
3206 + },
3207 +diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
3208 +index 84f1dcb698272..9b0c5d719232f 100644
3209 +--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
3210 ++++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
3211 +@@ -126,10 +126,10 @@ static void free_sink_buffer(struct etm_event_data *event_data)
3212 + cpumask_t *mask = &event_data->mask;
3213 + struct coresight_device *sink;
3214 +
3215 +- if (WARN_ON(cpumask_empty(mask)))
3216 ++ if (!event_data->snk_config)
3217 + return;
3218 +
3219 +- if (!event_data->snk_config)
3220 ++ if (WARN_ON(cpumask_empty(mask)))
3221 + return;
3222 +
3223 + cpu = cpumask_first(mask);
3224 +@@ -310,6 +310,16 @@ static void etm_event_start(struct perf_event *event, int flags)
3225 + if (!event_data)
3226 + goto fail;
3227 +
3228 ++ /*
3229 ++ * Check if this ETM is allowed to trace, as decided
3230 ++ * at etm_setup_aux(). This could be due to an unreachable
3231 ++ * sink from this ETM. We can't do much in this case if
3232 ++ * the sink was specified or hinted to the driver. For
3233 ++ * now, simply don't record anything on this ETM.
3234 ++ */
3235 ++ if (!cpumask_test_cpu(cpu, &event_data->mask))
3236 ++ goto fail_end_stop;
3237 ++
3238 + path = etm_event_cpu_path(event_data, cpu);
3239 + /* We need a sink, no need to continue without one */
3240 + sink = coresight_get_sink(path);
3241 +diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
3242 +index 146ce40d8e0aa..2d08a8719506c 100644
3243 +--- a/drivers/i2c/busses/Kconfig
3244 ++++ b/drivers/i2c/busses/Kconfig
3245 +@@ -1162,6 +1162,7 @@ config I2C_RCAR
3246 + tristate "Renesas R-Car I2C Controller"
3247 + depends on ARCH_RENESAS || COMPILE_TEST
3248 + select I2C_SLAVE
3249 ++ select RESET_CONTROLLER if ARCH_RCAR_GEN3
3250 + help
3251 + If you say yes to this option, support will be included for the
3252 + R-Car I2C controller.
3253 +diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
3254 +index ce70b5288472c..c70983780ae79 100644
3255 +--- a/drivers/i2c/i2c-core-acpi.c
3256 ++++ b/drivers/i2c/i2c-core-acpi.c
3257 +@@ -264,6 +264,7 @@ static acpi_status i2c_acpi_add_device(acpi_handle handle, u32 level,
3258 + void i2c_acpi_register_devices(struct i2c_adapter *adap)
3259 + {
3260 + acpi_status status;
3261 ++ acpi_handle handle;
3262 +
3263 + if (!has_acpi_companion(&adap->dev))
3264 + return;
3265 +@@ -274,6 +275,15 @@ void i2c_acpi_register_devices(struct i2c_adapter *adap)
3266 + adap, NULL);
3267 + if (ACPI_FAILURE(status))
3268 + dev_warn(&adap->dev, "failed to enumerate I2C slaves\n");
3269 ++
3270 ++ if (!adap->dev.parent)
3271 ++ return;
3272 ++
3273 ++ handle = ACPI_HANDLE(adap->dev.parent);
3274 ++ if (!handle)
3275 ++ return;
3276 ++
3277 ++ acpi_walk_dep_device_list(handle);
3278 + }
3279 +
3280 + const struct acpi_device_id *
3281 +@@ -737,7 +747,6 @@ int i2c_acpi_install_space_handler(struct i2c_adapter *adapter)
3282 + return -ENOMEM;
3283 + }
3284 +
3285 +- acpi_walk_dep_device_list(handle);
3286 + return 0;
3287 + }
3288 +
3289 +diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
3290 +index 5c051dba32a51..6cc71c90f85ea 100644
3291 +--- a/drivers/i3c/master.c
3292 ++++ b/drivers/i3c/master.c
3293 +@@ -1760,6 +1760,21 @@ static void i3c_master_bus_cleanup(struct i3c_master_controller *master)
3294 + i3c_master_detach_free_devs(master);
3295 + }
3296 +
3297 ++static void i3c_master_attach_boardinfo(struct i3c_dev_desc *i3cdev)
3298 ++{
3299 ++ struct i3c_master_controller *master = i3cdev->common.master;
3300 ++ struct i3c_dev_boardinfo *i3cboardinfo;
3301 ++
3302 ++ list_for_each_entry(i3cboardinfo, &master->boardinfo.i3c, node) {
3303 ++ if (i3cdev->info.pid != i3cboardinfo->pid)
3304 ++ continue;
3305 ++
3306 ++ i3cdev->boardinfo = i3cboardinfo;
3307 ++ i3cdev->info.static_addr = i3cboardinfo->static_addr;
3308 ++ return;
3309 ++ }
3310 ++}
3311 ++
3312 + static struct i3c_dev_desc *
3313 + i3c_master_search_i3c_dev_duplicate(struct i3c_dev_desc *refdev)
3314 + {
3315 +@@ -1815,10 +1830,10 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master,
3316 + if (ret)
3317 + goto err_detach_dev;
3318 +
3319 ++ i3c_master_attach_boardinfo(newdev);
3320 ++
3321 + olddev = i3c_master_search_i3c_dev_duplicate(newdev);
3322 + if (olddev) {
3323 +- newdev->boardinfo = olddev->boardinfo;
3324 +- newdev->info.static_addr = olddev->info.static_addr;
3325 + newdev->dev = olddev->dev;
3326 + if (newdev->dev)
3327 + newdev->dev->desc = newdev;
3328 +diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-master-cdns.c
3329 +index 10db0bf0655a9..6d5719cea9f53 100644
3330 +--- a/drivers/i3c/master/i3c-master-cdns.c
3331 ++++ b/drivers/i3c/master/i3c-master-cdns.c
3332 +@@ -1593,8 +1593,10 @@ static int cdns_i3c_master_probe(struct platform_device *pdev)
3333 + master->ibi.slots = devm_kcalloc(&pdev->dev, master->ibi.num_slots,
3334 + sizeof(*master->ibi.slots),
3335 + GFP_KERNEL);
3336 +- if (!master->ibi.slots)
3337 ++ if (!master->ibi.slots) {
3338 ++ ret = -ENOMEM;
3339 + goto err_disable_sysclk;
3340 ++ }
3341 +
3342 + writel(IBIR_THR(1), master->regs + CMD_IBI_THR_CTRL);
3343 + writel(MST_INT_IBIR_THR, master->regs + MST_IER);
3344 +diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
3345 +index 74f3a2be17a64..14d6a537289cb 100644
3346 +--- a/drivers/iio/adc/stm32-adc-core.c
3347 ++++ b/drivers/iio/adc/stm32-adc-core.c
3348 +@@ -780,6 +780,13 @@ static int stm32_adc_core_runtime_resume(struct device *dev)
3349 + {
3350 + return stm32_adc_core_hw_start(dev);
3351 + }
3352 ++
3353 ++static int stm32_adc_core_runtime_idle(struct device *dev)
3354 ++{
3355 ++ pm_runtime_mark_last_busy(dev);
3356 ++
3357 ++ return 0;
3358 ++}
3359 + #endif
3360 +
3361 + static const struct dev_pm_ops stm32_adc_core_pm_ops = {
3362 +@@ -787,7 +794,7 @@ static const struct dev_pm_ops stm32_adc_core_pm_ops = {
3363 + pm_runtime_force_resume)
3364 + SET_RUNTIME_PM_OPS(stm32_adc_core_runtime_suspend,
3365 + stm32_adc_core_runtime_resume,
3366 +- NULL)
3367 ++ stm32_adc_core_runtime_idle)
3368 + };
3369 +
3370 + static const struct stm32_adc_priv_cfg stm32f4_adc_priv_cfg = {
3371 +diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
3372 +index e3cd9d2b0dd2b..98d2d74b96f78 100644
3373 +--- a/drivers/infiniband/core/cma.c
3374 ++++ b/drivers/infiniband/core/cma.c
3375 +@@ -1803,19 +1803,30 @@ static void cma_release_port(struct rdma_id_private *id_priv)
3376 + mutex_unlock(&lock);
3377 + }
3378 +
3379 +-static void cma_leave_roce_mc_group(struct rdma_id_private *id_priv,
3380 +- struct cma_multicast *mc)
3381 ++static void destroy_mc(struct rdma_id_private *id_priv,
3382 ++ struct cma_multicast *mc)
3383 + {
3384 +- struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
3385 +- struct net_device *ndev = NULL;
3386 ++ if (rdma_cap_ib_mcast(id_priv->id.device, id_priv->id.port_num)) {
3387 ++ ib_sa_free_multicast(mc->multicast.ib);
3388 ++ kfree(mc);
3389 ++ return;
3390 ++ }
3391 +
3392 +- if (dev_addr->bound_dev_if)
3393 +- ndev = dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if);
3394 +- if (ndev) {
3395 +- cma_igmp_send(ndev, &mc->multicast.ib->rec.mgid, false);
3396 +- dev_put(ndev);
3397 ++ if (rdma_protocol_roce(id_priv->id.device,
3398 ++ id_priv->id.port_num)) {
3399 ++ struct rdma_dev_addr *dev_addr =
3400 ++ &id_priv->id.route.addr.dev_addr;
3401 ++ struct net_device *ndev = NULL;
3402 ++
3403 ++ if (dev_addr->bound_dev_if)
3404 ++ ndev = dev_get_by_index(dev_addr->net,
3405 ++ dev_addr->bound_dev_if);
3406 ++ if (ndev) {
3407 ++ cma_igmp_send(ndev, &mc->multicast.ib->rec.mgid, false);
3408 ++ dev_put(ndev);
3409 ++ }
3410 ++ kref_put(&mc->mcref, release_mc);
3411 + }
3412 +- kref_put(&mc->mcref, release_mc);
3413 + }
3414 +
3415 + static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
3416 +@@ -1823,16 +1834,10 @@ static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
3417 + struct cma_multicast *mc;
3418 +
3419 + while (!list_empty(&id_priv->mc_list)) {
3420 +- mc = container_of(id_priv->mc_list.next,
3421 +- struct cma_multicast, list);
3422 ++ mc = list_first_entry(&id_priv->mc_list, struct cma_multicast,
3423 ++ list);
3424 + list_del(&mc->list);
3425 +- if (rdma_cap_ib_mcast(id_priv->cma_dev->device,
3426 +- id_priv->id.port_num)) {
3427 +- ib_sa_free_multicast(mc->multicast.ib);
3428 +- kfree(mc);
3429 +- } else {
3430 +- cma_leave_roce_mc_group(id_priv, mc);
3431 +- }
3432 ++ destroy_mc(id_priv, mc);
3433 + }
3434 + }
3435 +
3436 +@@ -4182,16 +4187,6 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
3437 + else
3438 + pr_debug_ratelimited("RDMA CM: MULTICAST_ERROR: failed to join multicast. status %d\n",
3439 + status);
3440 +- mutex_lock(&id_priv->qp_mutex);
3441 +- if (!status && id_priv->id.qp) {
3442 +- status = ib_attach_mcast(id_priv->id.qp, &multicast->rec.mgid,
3443 +- be16_to_cpu(multicast->rec.mlid));
3444 +- if (status)
3445 +- pr_debug_ratelimited("RDMA CM: MULTICAST_ERROR: failed to attach QP. status %d\n",
3446 +- status);
3447 +- }
3448 +- mutex_unlock(&id_priv->qp_mutex);
3449 +-
3450 + event.status = status;
3451 + event.param.ud.private_data = mc->context;
3452 + if (!status) {
3453 +@@ -4446,6 +4441,10 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
3454 + struct cma_multicast *mc;
3455 + int ret;
3456 +
3457 ++ /* Not supported for kernel QPs */
3458 ++ if (WARN_ON(id->qp))
3459 ++ return -EINVAL;
3460 ++
3461 + if (!id->device)
3462 + return -EINVAL;
3463 +
3464 +@@ -4496,25 +4495,14 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)
3465 + id_priv = container_of(id, struct rdma_id_private, id);
3466 + spin_lock_irq(&id_priv->lock);
3467 + list_for_each_entry(mc, &id_priv->mc_list, list) {
3468 +- if (!memcmp(&mc->addr, addr, rdma_addr_size(addr))) {
3469 +- list_del(&mc->list);
3470 +- spin_unlock_irq(&id_priv->lock);
3471 +-
3472 +- if (id->qp)
3473 +- ib_detach_mcast(id->qp,
3474 +- &mc->multicast.ib->rec.mgid,
3475 +- be16_to_cpu(mc->multicast.ib->rec.mlid));
3476 +-
3477 +- BUG_ON(id_priv->cma_dev->device != id->device);
3478 +-
3479 +- if (rdma_cap_ib_mcast(id->device, id->port_num)) {
3480 +- ib_sa_free_multicast(mc->multicast.ib);
3481 +- kfree(mc);
3482 +- } else if (rdma_protocol_roce(id->device, id->port_num)) {
3483 +- cma_leave_roce_mc_group(id_priv, mc);
3484 +- }
3485 +- return;
3486 +- }
3487 ++ if (memcmp(&mc->addr, addr, rdma_addr_size(addr)) != 0)
3488 ++ continue;
3489 ++ list_del(&mc->list);
3490 ++ spin_unlock_irq(&id_priv->lock);
3491 ++
3492 ++ WARN_ON(id_priv->cma_dev->device != id->device);
3493 ++ destroy_mc(id_priv, mc);
3494 ++ return;
3495 + }
3496 + spin_unlock_irq(&id_priv->lock);
3497 + }
3498 +diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
3499 +index f4f79f1292b91..ef4be14af3bb9 100644
3500 +--- a/drivers/infiniband/core/ucma.c
3501 ++++ b/drivers/infiniband/core/ucma.c
3502 +@@ -581,6 +581,7 @@ static int ucma_free_ctx(struct ucma_context *ctx)
3503 + list_move_tail(&uevent->list, &list);
3504 + }
3505 + list_del(&ctx->list);
3506 ++ events_reported = ctx->events_reported;
3507 + mutex_unlock(&ctx->file->mut);
3508 +
3509 + list_for_each_entry_safe(uevent, tmp, &list, list) {
3510 +@@ -590,7 +591,6 @@ static int ucma_free_ctx(struct ucma_context *ctx)
3511 + kfree(uevent);
3512 + }
3513 +
3514 +- events_reported = ctx->events_reported;
3515 + mutex_destroy(&ctx->mutex);
3516 + kfree(ctx);
3517 + return events_reported;
3518 +@@ -1473,7 +1473,9 @@ static ssize_t ucma_process_join(struct ucma_file *file,
3519 + return 0;
3520 +
3521 + err3:
3522 ++ mutex_lock(&ctx->mutex);
3523 + rdma_leave_multicast(ctx->cm_id, (struct sockaddr *) &mc->addr);
3524 ++ mutex_unlock(&ctx->mutex);
3525 + ucma_cleanup_mc_events(mc);
3526 + err2:
3527 + xa_erase(&multicast_table, mc->id);
3528 +@@ -1639,7 +1641,9 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
3529 +
3530 + cur_file = ctx->file;
3531 + if (cur_file == new_file) {
3532 ++ mutex_lock(&cur_file->mut);
3533 + resp.events_reported = ctx->events_reported;
3534 ++ mutex_unlock(&cur_file->mut);
3535 + goto response;
3536 + }
3537 +
3538 +diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
3539 +index 0d42ba8c0b696..650f71dd4ab93 100644
3540 +--- a/drivers/infiniband/core/umem.c
3541 ++++ b/drivers/infiniband/core/umem.c
3542 +@@ -151,13 +151,24 @@ unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
3543 + dma_addr_t mask;
3544 + int i;
3545 +
3546 ++ /* rdma_for_each_block() has a bug if the page size is smaller than the
3547 ++ * page size used to build the umem. For now prevent smaller page sizes
3548 ++ * from being returned.
3549 ++ */
3550 ++ pgsz_bitmap &= GENMASK(BITS_PER_LONG - 1, PAGE_SHIFT);
3551 ++
3552 + /* At minimum, drivers must support PAGE_SIZE or smaller */
3553 + if (WARN_ON(!(pgsz_bitmap & GENMASK(PAGE_SHIFT, 0))))
3554 + return 0;
3555 +
3556 + va = virt;
3557 +- /* max page size not to exceed MR length */
3558 +- mask = roundup_pow_of_two(umem->length);
3559 ++ /* The best result is the smallest page size that results in the minimum
3560 ++ * number of required pages. Compute the largest page size that could
3561 ++ * work based on VA address bits that don't change.
3562 ++ */
3563 ++ mask = pgsz_bitmap &
3564 ++ GENMASK(BITS_PER_LONG - 1,
3565 ++ bits_per((umem->length - 1 + virt) ^ virt));
3566 + /* offset into first SGL */
3567 + pgoff = umem->address & ~PAGE_MASK;
3568 +
3569 +diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
3570 +index a79fa67df8715..a405c64d2a82b 100644
3571 +--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
3572 ++++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
3573 +@@ -271,7 +271,6 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
3574 + ps_opcode = HNS_ROCE_WQE_OPCODE_SEND;
3575 + break;
3576 + case IB_WR_LOCAL_INV:
3577 +- break;
3578 + case IB_WR_ATOMIC_CMP_AND_SWP:
3579 + case IB_WR_ATOMIC_FETCH_AND_ADD:
3580 + case IB_WR_LSO:
3581 +diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
3582 +index 0502c90c83edd..bb75328193957 100644
3583 +--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
3584 ++++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
3585 +@@ -4616,7 +4616,9 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
3586 + qp_attr->retry_cnt = roce_get_field(context.byte_212_lsn,
3587 + V2_QPC_BYTE_212_RETRY_CNT_M,
3588 + V2_QPC_BYTE_212_RETRY_CNT_S);
3589 +- qp_attr->rnr_retry = le32_to_cpu(context.rq_rnr_timer);
3590 ++ qp_attr->rnr_retry = roce_get_field(context.byte_244_rnr_rxack,
3591 ++ V2_QPC_BYTE_244_RNR_CNT_M,
3592 ++ V2_QPC_BYTE_244_RNR_CNT_S);
3593 +
3594 + done:
3595 + qp_attr->cur_qp_state = qp_attr->qp_state;
3596 +@@ -4632,6 +4634,7 @@ done:
3597 + }
3598 +
3599 + qp_init_attr->cap = qp_attr->cap;
3600 ++ qp_init_attr->sq_sig_type = hr_qp->sq_signal_bits;
3601 +
3602 + out:
3603 + mutex_unlock(&hr_qp->mutex);
3604 +diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
3605 +index 8dd2d666f6875..730e50c87a760 100644
3606 +--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
3607 ++++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
3608 +@@ -1181,8 +1181,10 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
3609 +
3610 + mutex_lock(&hr_qp->mutex);
3611 +
3612 +- cur_state = attr_mask & IB_QP_CUR_STATE ?
3613 +- attr->cur_qp_state : (enum ib_qp_state)hr_qp->state;
3614 ++ if (attr_mask & IB_QP_CUR_STATE && attr->cur_qp_state != hr_qp->state)
3615 ++ goto out;
3616 ++
3617 ++ cur_state = hr_qp->state;
3618 + new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
3619 +
3620 + if (ibqp->uobject &&
3621 +diff --git a/drivers/infiniband/hw/i40iw/i40iw.h b/drivers/infiniband/hw/i40iw/i40iw.h
3622 +index 8feec35f95a7c..6d6719fa7e46a 100644
3623 +--- a/drivers/infiniband/hw/i40iw/i40iw.h
3624 ++++ b/drivers/infiniband/hw/i40iw/i40iw.h
3625 +@@ -398,8 +398,8 @@ static inline struct i40iw_qp *to_iwqp(struct ib_qp *ibqp)
3626 + }
3627 +
3628 + /* i40iw.c */
3629 +-void i40iw_add_ref(struct ib_qp *);
3630 +-void i40iw_rem_ref(struct ib_qp *);
3631 ++void i40iw_qp_add_ref(struct ib_qp *ibqp);
3632 ++void i40iw_qp_rem_ref(struct ib_qp *ibqp);
3633 + struct ib_qp *i40iw_get_qp(struct ib_device *, int);
3634 +
3635 + void i40iw_flush_wqes(struct i40iw_device *iwdev,
3636 +@@ -543,9 +543,8 @@ enum i40iw_status_code i40iw_manage_qhash(struct i40iw_device *iwdev,
3637 + bool wait);
3638 + void i40iw_receive_ilq(struct i40iw_sc_vsi *vsi, struct i40iw_puda_buf *rbuf);
3639 + void i40iw_free_sqbuf(struct i40iw_sc_vsi *vsi, void *bufp);
3640 +-void i40iw_free_qp_resources(struct i40iw_device *iwdev,
3641 +- struct i40iw_qp *iwqp,
3642 +- u32 qp_num);
3643 ++void i40iw_free_qp_resources(struct i40iw_qp *iwqp);
3644 ++
3645 + enum i40iw_status_code i40iw_obj_aligned_mem(struct i40iw_device *iwdev,
3646 + struct i40iw_dma_mem *memptr,
3647 + u32 size, u32 mask);
3648 +diff --git a/drivers/infiniband/hw/i40iw/i40iw_cm.c b/drivers/infiniband/hw/i40iw/i40iw_cm.c
3649 +index fa7a5ff498c73..56c1e9abc52dc 100644
3650 +--- a/drivers/infiniband/hw/i40iw/i40iw_cm.c
3651 ++++ b/drivers/infiniband/hw/i40iw/i40iw_cm.c
3652 +@@ -2322,7 +2322,7 @@ static void i40iw_rem_ref_cm_node(struct i40iw_cm_node *cm_node)
3653 + iwqp = cm_node->iwqp;
3654 + if (iwqp) {
3655 + iwqp->cm_node = NULL;
3656 +- i40iw_rem_ref(&iwqp->ibqp);
3657 ++ i40iw_qp_rem_ref(&iwqp->ibqp);
3658 + cm_node->iwqp = NULL;
3659 + } else if (cm_node->qhash_set) {
3660 + i40iw_get_addr_info(cm_node, &nfo);
3661 +@@ -3452,7 +3452,7 @@ void i40iw_cm_disconn(struct i40iw_qp *iwqp)
3662 + kfree(work);
3663 + return;
3664 + }
3665 +- i40iw_add_ref(&iwqp->ibqp);
3666 ++ i40iw_qp_add_ref(&iwqp->ibqp);
3667 + spin_unlock_irqrestore(&iwdev->qptable_lock, flags);
3668 +
3669 + work->iwqp = iwqp;
3670 +@@ -3623,7 +3623,7 @@ static void i40iw_disconnect_worker(struct work_struct *work)
3671 +
3672 + kfree(dwork);
3673 + i40iw_cm_disconn_true(iwqp);
3674 +- i40iw_rem_ref(&iwqp->ibqp);
3675 ++ i40iw_qp_rem_ref(&iwqp->ibqp);
3676 + }
3677 +
3678 + /**
3679 +@@ -3745,7 +3745,7 @@ int i40iw_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
3680 + cm_node->lsmm_size = accept.size + conn_param->private_data_len;
3681 + i40iw_cm_init_tsa_conn(iwqp, cm_node);
3682 + cm_id->add_ref(cm_id);
3683 +- i40iw_add_ref(&iwqp->ibqp);
3684 ++ i40iw_qp_add_ref(&iwqp->ibqp);
3685 +
3686 + attr.qp_state = IB_QPS_RTS;
3687 + cm_node->qhash_set = false;
3688 +@@ -3908,7 +3908,7 @@ int i40iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
3689 + iwqp->cm_node = cm_node;
3690 + cm_node->iwqp = iwqp;
3691 + iwqp->cm_id = cm_id;
3692 +- i40iw_add_ref(&iwqp->ibqp);
3693 ++ i40iw_qp_add_ref(&iwqp->ibqp);
3694 +
3695 + if (cm_node->state != I40IW_CM_STATE_OFFLOADED) {
3696 + cm_node->state = I40IW_CM_STATE_SYN_SENT;
3697 +diff --git a/drivers/infiniband/hw/i40iw/i40iw_hw.c b/drivers/infiniband/hw/i40iw/i40iw_hw.c
3698 +index ae8b97c306657..a7512508f7e60 100644
3699 +--- a/drivers/infiniband/hw/i40iw/i40iw_hw.c
3700 ++++ b/drivers/infiniband/hw/i40iw/i40iw_hw.c
3701 +@@ -313,7 +313,7 @@ void i40iw_process_aeq(struct i40iw_device *iwdev)
3702 + __func__, info->qp_cq_id);
3703 + continue;
3704 + }
3705 +- i40iw_add_ref(&iwqp->ibqp);
3706 ++ i40iw_qp_add_ref(&iwqp->ibqp);
3707 + spin_unlock_irqrestore(&iwdev->qptable_lock, flags);
3708 + qp = &iwqp->sc_qp;
3709 + spin_lock_irqsave(&iwqp->lock, flags);
3710 +@@ -427,7 +427,7 @@ void i40iw_process_aeq(struct i40iw_device *iwdev)
3711 + break;
3712 + }
3713 + if (info->qp)
3714 +- i40iw_rem_ref(&iwqp->ibqp);
3715 ++ i40iw_qp_rem_ref(&iwqp->ibqp);
3716 + } while (1);
3717 +
3718 + if (aeqcnt)
3719 +diff --git a/drivers/infiniband/hw/i40iw/i40iw_utils.c b/drivers/infiniband/hw/i40iw/i40iw_utils.c
3720 +index 016524683e17e..72db7c1dc2998 100644
3721 +--- a/drivers/infiniband/hw/i40iw/i40iw_utils.c
3722 ++++ b/drivers/infiniband/hw/i40iw/i40iw_utils.c
3723 +@@ -479,25 +479,6 @@ void i40iw_cleanup_pending_cqp_op(struct i40iw_device *iwdev)
3724 + }
3725 + }
3726 +
3727 +-/**
3728 +- * i40iw_free_qp - callback after destroy cqp completes
3729 +- * @cqp_request: cqp request for destroy qp
3730 +- * @num: not used
3731 +- */
3732 +-static void i40iw_free_qp(struct i40iw_cqp_request *cqp_request, u32 num)
3733 +-{
3734 +- struct i40iw_sc_qp *qp = (struct i40iw_sc_qp *)cqp_request->param;
3735 +- struct i40iw_qp *iwqp = (struct i40iw_qp *)qp->back_qp;
3736 +- struct i40iw_device *iwdev;
3737 +- u32 qp_num = iwqp->ibqp.qp_num;
3738 +-
3739 +- iwdev = iwqp->iwdev;
3740 +-
3741 +- i40iw_rem_pdusecount(iwqp->iwpd, iwdev);
3742 +- i40iw_free_qp_resources(iwdev, iwqp, qp_num);
3743 +- i40iw_rem_devusecount(iwdev);
3744 +-}
3745 +-
3746 + /**
3747 + * i40iw_wait_event - wait for completion
3748 + * @iwdev: iwarp device
3749 +@@ -618,26 +599,23 @@ void i40iw_rem_pdusecount(struct i40iw_pd *iwpd, struct i40iw_device *iwdev)
3750 + }
3751 +
3752 + /**
3753 +- * i40iw_add_ref - add refcount for qp
3754 ++ * i40iw_qp_add_ref - add refcount for qp
3755 + * @ibqp: iqarp qp
3756 + */
3757 +-void i40iw_add_ref(struct ib_qp *ibqp)
3758 ++void i40iw_qp_add_ref(struct ib_qp *ibqp)
3759 + {
3760 + struct i40iw_qp *iwqp = (struct i40iw_qp *)ibqp;
3761 +
3762 +- atomic_inc(&iwqp->refcount);
3763 ++ refcount_inc(&iwqp->refcount);
3764 + }
3765 +
3766 + /**
3767 +- * i40iw_rem_ref - rem refcount for qp and free if 0
3768 ++ * i40iw_qp_rem_ref - rem refcount for qp and free if 0
3769 + * @ibqp: iqarp qp
3770 + */
3771 +-void i40iw_rem_ref(struct ib_qp *ibqp)
3772 ++void i40iw_qp_rem_ref(struct ib_qp *ibqp)
3773 + {
3774 + struct i40iw_qp *iwqp;
3775 +- enum i40iw_status_code status;
3776 +- struct i40iw_cqp_request *cqp_request;
3777 +- struct cqp_commands_info *cqp_info;
3778 + struct i40iw_device *iwdev;
3779 + u32 qp_num;
3780 + unsigned long flags;
3781 +@@ -645,7 +623,7 @@ void i40iw_rem_ref(struct ib_qp *ibqp)
3782 + iwqp = to_iwqp(ibqp);
3783 + iwdev = iwqp->iwdev;
3784 + spin_lock_irqsave(&iwdev->qptable_lock, flags);
3785 +- if (!atomic_dec_and_test(&iwqp->refcount)) {
3786 ++ if (!refcount_dec_and_test(&iwqp->refcount)) {
3787 + spin_unlock_irqrestore(&iwdev->qptable_lock, flags);
3788 + return;
3789 + }
3790 +@@ -653,25 +631,8 @@ void i40iw_rem_ref(struct ib_qp *ibqp)
3791 + qp_num = iwqp->ibqp.qp_num;
3792 + iwdev->qp_table[qp_num] = NULL;
3793 + spin_unlock_irqrestore(&iwdev->qptable_lock, flags);
3794 +- cqp_request = i40iw_get_cqp_request(&iwdev->cqp, false);
3795 +- if (!cqp_request)
3796 +- return;
3797 +-
3798 +- cqp_request->callback_fcn = i40iw_free_qp;
3799 +- cqp_request->param = (void *)&iwqp->sc_qp;
3800 +- cqp_info = &cqp_request->info;
3801 +- cqp_info->cqp_cmd = OP_QP_DESTROY;
3802 +- cqp_info->post_sq = 1;
3803 +- cqp_info->in.u.qp_destroy.qp = &iwqp->sc_qp;
3804 +- cqp_info->in.u.qp_destroy.scratch = (uintptr_t)cqp_request;
3805 +- cqp_info->in.u.qp_destroy.remove_hash_idx = true;
3806 +- status = i40iw_handle_cqp_op(iwdev, cqp_request);
3807 +- if (!status)
3808 +- return;
3809 ++ complete(&iwqp->free_qp);
3810 +
3811 +- i40iw_rem_pdusecount(iwqp->iwpd, iwdev);
3812 +- i40iw_free_qp_resources(iwdev, iwqp, qp_num);
3813 +- i40iw_rem_devusecount(iwdev);
3814 + }
3815 +
3816 + /**
3817 +@@ -938,7 +899,7 @@ static void i40iw_terminate_timeout(struct timer_list *t)
3818 + struct i40iw_sc_qp *qp = (struct i40iw_sc_qp *)&iwqp->sc_qp;
3819 +
3820 + i40iw_terminate_done(qp, 1);
3821 +- i40iw_rem_ref(&iwqp->ibqp);
3822 ++ i40iw_qp_rem_ref(&iwqp->ibqp);
3823 + }
3824 +
3825 + /**
3826 +@@ -950,7 +911,7 @@ void i40iw_terminate_start_timer(struct i40iw_sc_qp *qp)
3827 + struct i40iw_qp *iwqp;
3828 +
3829 + iwqp = (struct i40iw_qp *)qp->back_qp;
3830 +- i40iw_add_ref(&iwqp->ibqp);
3831 ++ i40iw_qp_add_ref(&iwqp->ibqp);
3832 + timer_setup(&iwqp->terminate_timer, i40iw_terminate_timeout, 0);
3833 + iwqp->terminate_timer.expires = jiffies + HZ;
3834 + add_timer(&iwqp->terminate_timer);
3835 +@@ -966,7 +927,7 @@ void i40iw_terminate_del_timer(struct i40iw_sc_qp *qp)
3836 +
3837 + iwqp = (struct i40iw_qp *)qp->back_qp;
3838 + if (del_timer(&iwqp->terminate_timer))
3839 +- i40iw_rem_ref(&iwqp->ibqp);
3840 ++ i40iw_qp_rem_ref(&iwqp->ibqp);
3841 + }
3842 +
3843 + /**
3844 +diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
3845 +index cd9ee1664a69e..22bf4f09c0647 100644
3846 +--- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c
3847 ++++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
3848 +@@ -366,11 +366,11 @@ static struct i40iw_pbl *i40iw_get_pbl(unsigned long va,
3849 + * @iwqp: qp ptr (user or kernel)
3850 + * @qp_num: qp number assigned
3851 + */
3852 +-void i40iw_free_qp_resources(struct i40iw_device *iwdev,
3853 +- struct i40iw_qp *iwqp,
3854 +- u32 qp_num)
3855 ++void i40iw_free_qp_resources(struct i40iw_qp *iwqp)
3856 + {
3857 + struct i40iw_pbl *iwpbl = &iwqp->iwpbl;
3858 ++ struct i40iw_device *iwdev = iwqp->iwdev;
3859 ++ u32 qp_num = iwqp->ibqp.qp_num;
3860 +
3861 + i40iw_ieq_cleanup_qp(iwdev->vsi.ieq, &iwqp->sc_qp);
3862 + i40iw_dealloc_push_page(iwdev, &iwqp->sc_qp);
3863 +@@ -404,6 +404,10 @@ static void i40iw_clean_cqes(struct i40iw_qp *iwqp, struct i40iw_cq *iwcq)
3864 + static int i40iw_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
3865 + {
3866 + struct i40iw_qp *iwqp = to_iwqp(ibqp);
3867 ++ struct ib_qp_attr attr;
3868 ++ struct i40iw_device *iwdev = iwqp->iwdev;
3869 ++
3870 ++ memset(&attr, 0, sizeof(attr));
3871 +
3872 + iwqp->destroyed = 1;
3873 +
3874 +@@ -418,7 +422,15 @@ static int i40iw_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
3875 + }
3876 + }
3877 +
3878 +- i40iw_rem_ref(&iwqp->ibqp);
3879 ++ attr.qp_state = IB_QPS_ERR;
3880 ++ i40iw_modify_qp(&iwqp->ibqp, &attr, IB_QP_STATE, NULL);
3881 ++ i40iw_qp_rem_ref(&iwqp->ibqp);
3882 ++ wait_for_completion(&iwqp->free_qp);
3883 ++ i40iw_cqp_qp_destroy_cmd(&iwdev->sc_dev, &iwqp->sc_qp);
3884 ++ i40iw_rem_pdusecount(iwqp->iwpd, iwdev);
3885 ++ i40iw_free_qp_resources(iwqp);
3886 ++ i40iw_rem_devusecount(iwdev);
3887 ++
3888 + return 0;
3889 + }
3890 +
3891 +@@ -579,6 +591,7 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
3892 + qp->back_qp = (void *)iwqp;
3893 + qp->push_idx = I40IW_INVALID_PUSH_PAGE_INDEX;
3894 +
3895 ++ iwqp->iwdev = iwdev;
3896 + iwqp->ctx_info.iwarp_info = &iwqp->iwarp_info;
3897 +
3898 + if (i40iw_allocate_dma_mem(dev->hw,
3899 +@@ -603,7 +616,6 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
3900 + goto error;
3901 + }
3902 +
3903 +- iwqp->iwdev = iwdev;
3904 + iwqp->iwpd = iwpd;
3905 + iwqp->ibqp.qp_num = qp_num;
3906 + qp = &iwqp->sc_qp;
3907 +@@ -717,7 +729,7 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
3908 + goto error;
3909 + }
3910 +
3911 +- i40iw_add_ref(&iwqp->ibqp);
3912 ++ refcount_set(&iwqp->refcount, 1);
3913 + spin_lock_init(&iwqp->lock);
3914 + iwqp->sig_all = (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR) ? 1 : 0;
3915 + iwdev->qp_table[qp_num] = iwqp;
3916 +@@ -739,10 +751,11 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
3917 + }
3918 + init_completion(&iwqp->sq_drained);
3919 + init_completion(&iwqp->rq_drained);
3920 ++ init_completion(&iwqp->free_qp);
3921 +
3922 + return &iwqp->ibqp;
3923 + error:
3924 +- i40iw_free_qp_resources(iwdev, iwqp, qp_num);
3925 ++ i40iw_free_qp_resources(iwqp);
3926 + return ERR_PTR(err_code);
3927 + }
3928 +
3929 +@@ -2654,13 +2667,13 @@ static const struct ib_device_ops i40iw_dev_ops = {
3930 + .get_hw_stats = i40iw_get_hw_stats,
3931 + .get_port_immutable = i40iw_port_immutable,
3932 + .iw_accept = i40iw_accept,
3933 +- .iw_add_ref = i40iw_add_ref,
3934 ++ .iw_add_ref = i40iw_qp_add_ref,
3935 + .iw_connect = i40iw_connect,
3936 + .iw_create_listen = i40iw_create_listen,
3937 + .iw_destroy_listen = i40iw_destroy_listen,
3938 + .iw_get_qp = i40iw_get_qp,
3939 + .iw_reject = i40iw_reject,
3940 +- .iw_rem_ref = i40iw_rem_ref,
3941 ++ .iw_rem_ref = i40iw_qp_rem_ref,
3942 + .map_mr_sg = i40iw_map_mr_sg,
3943 + .mmap = i40iw_mmap,
3944 + .modify_qp = i40iw_modify_qp,
3945 +diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.h b/drivers/infiniband/hw/i40iw/i40iw_verbs.h
3946 +index 3a413752ccc38..ad7d81041bc9a 100644
3947 +--- a/drivers/infiniband/hw/i40iw/i40iw_verbs.h
3948 ++++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.h
3949 +@@ -140,7 +140,7 @@ struct i40iw_qp {
3950 + struct i40iw_qp_host_ctx_info ctx_info;
3951 + struct i40iwarp_offload_info iwarp_info;
3952 + void *allocated_buffer;
3953 +- atomic_t refcount;
3954 ++ refcount_t refcount;
3955 + struct iw_cm_id *cm_id;
3956 + void *cm_node;
3957 + struct ib_mr *lsmm_mr;
3958 +@@ -175,5 +175,6 @@ struct i40iw_qp {
3959 + struct i40iw_dma_mem ietf_mem;
3960 + struct completion sq_drained;
3961 + struct completion rq_drained;
3962 ++ struct completion free_qp;
3963 + };
3964 + #endif
3965 +diff --git a/drivers/infiniband/hw/mlx4/cm.c b/drivers/infiniband/hw/mlx4/cm.c
3966 +index b591861934b3c..81d6a3460b55d 100644
3967 +--- a/drivers/infiniband/hw/mlx4/cm.c
3968 ++++ b/drivers/infiniband/hw/mlx4/cm.c
3969 +@@ -280,6 +280,9 @@ static void schedule_delayed(struct ib_device *ibdev, struct id_map_entry *id)
3970 + if (!sriov->is_going_down && !id->scheduled_delete) {
3971 + id->scheduled_delete = 1;
3972 + schedule_delayed_work(&id->timeout, CM_CLEANUP_CACHE_TIMEOUT);
3973 ++ } else if (id->scheduled_delete) {
3974 ++ /* Adjust timeout if already scheduled */
3975 ++ mod_delayed_work(system_wq, &id->timeout, CM_CLEANUP_CACHE_TIMEOUT);
3976 + }
3977 + spin_unlock_irqrestore(&sriov->going_down_lock, flags);
3978 + spin_unlock(&sriov->id_map_lock);
3979 +diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
3980 +index 57079110af9b5..08eccf2b6967d 100644
3981 +--- a/drivers/infiniband/hw/mlx4/mad.c
3982 ++++ b/drivers/infiniband/hw/mlx4/mad.c
3983 +@@ -1307,6 +1307,18 @@ static void mlx4_ib_tunnel_comp_handler(struct ib_cq *cq, void *arg)
3984 + spin_unlock_irqrestore(&dev->sriov.going_down_lock, flags);
3985 + }
3986 +
3987 ++static void mlx4_ib_wire_comp_handler(struct ib_cq *cq, void *arg)
3988 ++{
3989 ++ unsigned long flags;
3990 ++ struct mlx4_ib_demux_pv_ctx *ctx = cq->cq_context;
3991 ++ struct mlx4_ib_dev *dev = to_mdev(ctx->ib_dev);
3992 ++
3993 ++ spin_lock_irqsave(&dev->sriov.going_down_lock, flags);
3994 ++ if (!dev->sriov.is_going_down && ctx->state == DEMUX_PV_STATE_ACTIVE)
3995 ++ queue_work(ctx->wi_wq, &ctx->work);
3996 ++ spin_unlock_irqrestore(&dev->sriov.going_down_lock, flags);
3997 ++}
3998 ++
3999 + static int mlx4_ib_post_pv_qp_buf(struct mlx4_ib_demux_pv_ctx *ctx,
4000 + struct mlx4_ib_demux_pv_qp *tun_qp,
4001 + int index)
4002 +@@ -2009,7 +2021,8 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
4003 + cq_size *= 2;
4004 +
4005 + cq_attr.cqe = cq_size;
4006 +- ctx->cq = ib_create_cq(ctx->ib_dev, mlx4_ib_tunnel_comp_handler,
4007 ++ ctx->cq = ib_create_cq(ctx->ib_dev,
4008 ++ create_tun ? mlx4_ib_tunnel_comp_handler : mlx4_ib_wire_comp_handler,
4009 + NULL, ctx, &cq_attr);
4010 + if (IS_ERR(ctx->cq)) {
4011 + ret = PTR_ERR(ctx->cq);
4012 +@@ -2046,6 +2059,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
4013 + INIT_WORK(&ctx->work, mlx4_ib_sqp_comp_worker);
4014 +
4015 + ctx->wq = to_mdev(ibdev)->sriov.demux[port - 1].wq;
4016 ++ ctx->wi_wq = to_mdev(ibdev)->sriov.demux[port - 1].wi_wq;
4017 +
4018 + ret = ib_req_notify_cq(ctx->cq, IB_CQ_NEXT_COMP);
4019 + if (ret) {
4020 +@@ -2189,7 +2203,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
4021 + goto err_mcg;
4022 + }
4023 +
4024 +- snprintf(name, sizeof name, "mlx4_ibt%d", port);
4025 ++ snprintf(name, sizeof(name), "mlx4_ibt%d", port);
4026 + ctx->wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
4027 + if (!ctx->wq) {
4028 + pr_err("Failed to create tunnelling WQ for port %d\n", port);
4029 +@@ -2197,7 +2211,15 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
4030 + goto err_wq;
4031 + }
4032 +
4033 +- snprintf(name, sizeof name, "mlx4_ibud%d", port);
4034 ++ snprintf(name, sizeof(name), "mlx4_ibwi%d", port);
4035 ++ ctx->wi_wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
4036 ++ if (!ctx->wi_wq) {
4037 ++ pr_err("Failed to create wire WQ for port %d\n", port);
4038 ++ ret = -ENOMEM;
4039 ++ goto err_wiwq;
4040 ++ }
4041 ++
4042 ++ snprintf(name, sizeof(name), "mlx4_ibud%d", port);
4043 + ctx->ud_wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
4044 + if (!ctx->ud_wq) {
4045 + pr_err("Failed to create up/down WQ for port %d\n", port);
4046 +@@ -2208,6 +2230,10 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
4047 + return 0;
4048 +
4049 + err_udwq:
4050 ++ destroy_workqueue(ctx->wi_wq);
4051 ++ ctx->wi_wq = NULL;
4052 ++
4053 ++err_wiwq:
4054 + destroy_workqueue(ctx->wq);
4055 + ctx->wq = NULL;
4056 +
4057 +@@ -2255,12 +2281,14 @@ static void mlx4_ib_free_demux_ctx(struct mlx4_ib_demux_ctx *ctx)
4058 + ctx->tun[i]->state = DEMUX_PV_STATE_DOWNING;
4059 + }
4060 + flush_workqueue(ctx->wq);
4061 ++ flush_workqueue(ctx->wi_wq);
4062 + for (i = 0; i < dev->dev->caps.sqp_demux; i++) {
4063 + destroy_pv_resources(dev, i, ctx->port, ctx->tun[i], 0);
4064 + free_pv_object(dev, i, ctx->port);
4065 + }
4066 + kfree(ctx->tun);
4067 + destroy_workqueue(ctx->ud_wq);
4068 ++ destroy_workqueue(ctx->wi_wq);
4069 + destroy_workqueue(ctx->wq);
4070 + }
4071 + }
4072 +diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
4073 +index eb53bb4c0c91c..0173e3931cc7f 100644
4074 +--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
4075 ++++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
4076 +@@ -459,6 +459,7 @@ struct mlx4_ib_demux_pv_ctx {
4077 + struct ib_pd *pd;
4078 + struct work_struct work;
4079 + struct workqueue_struct *wq;
4080 ++ struct workqueue_struct *wi_wq;
4081 + struct mlx4_ib_demux_pv_qp qp[2];
4082 + };
4083 +
4084 +@@ -466,6 +467,7 @@ struct mlx4_ib_demux_ctx {
4085 + struct ib_device *ib_dev;
4086 + int port;
4087 + struct workqueue_struct *wq;
4088 ++ struct workqueue_struct *wi_wq;
4089 + struct workqueue_struct *ud_wq;
4090 + spinlock_t ud_lock;
4091 + atomic64_t subnet_prefix;
4092 +diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c
4093 +index ff664355de550..73d5b8dc74d86 100644
4094 +--- a/drivers/infiniband/hw/mlx5/cq.c
4095 ++++ b/drivers/infiniband/hw/mlx5/cq.c
4096 +@@ -167,7 +167,7 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
4097 + {
4098 + enum rdma_link_layer ll = rdma_port_get_link_layer(qp->ibqp.device, 1);
4099 + struct mlx5_ib_dev *dev = to_mdev(qp->ibqp.device);
4100 +- struct mlx5_ib_srq *srq;
4101 ++ struct mlx5_ib_srq *srq = NULL;
4102 + struct mlx5_ib_wq *wq;
4103 + u16 wqe_ctr;
4104 + u8 roce_packet_type;
4105 +@@ -179,7 +179,8 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
4106 +
4107 + if (qp->ibqp.xrcd) {
4108 + msrq = mlx5_cmd_get_srq(dev, be32_to_cpu(cqe->srqn));
4109 +- srq = to_mibsrq(msrq);
4110 ++ if (msrq)
4111 ++ srq = to_mibsrq(msrq);
4112 + } else {
4113 + srq = to_msrq(qp->ibqp.srq);
4114 + }
4115 +diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
4116 +index b781ad74e6de4..40c1a05c2445d 100644
4117 +--- a/drivers/infiniband/hw/mlx5/main.c
4118 ++++ b/drivers/infiniband/hw/mlx5/main.c
4119 +@@ -888,7 +888,9 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
4120 + /* We support 'Gappy' memory registration too */
4121 + props->device_cap_flags |= IB_DEVICE_SG_GAPS_REG;
4122 + }
4123 +- props->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS;
4124 ++ /* IB_WR_REG_MR always requires changing the entity size with UMR */
4125 ++ if (!MLX5_CAP_GEN(dev->mdev, umr_modify_entity_size_disabled))
4126 ++ props->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS;
4127 + if (MLX5_CAP_GEN(mdev, sho)) {
4128 + props->device_cap_flags |= IB_DEVICE_INTEGRITY_HANDOVER;
4129 + /* At this stage no support for signature handover */
4130 +diff --git a/drivers/infiniband/hw/qedr/main.c b/drivers/infiniband/hw/qedr/main.c
4131 +index 4494dab8c3d83..93040c994e2e3 100644
4132 +--- a/drivers/infiniband/hw/qedr/main.c
4133 ++++ b/drivers/infiniband/hw/qedr/main.c
4134 +@@ -601,7 +601,7 @@ static int qedr_set_device_attr(struct qedr_dev *dev)
4135 + qed_attr = dev->ops->rdma_query_device(dev->rdma_ctx);
4136 +
4137 + /* Part 2 - check capabilities */
4138 +- page_size = ~dev->attr.page_size_caps + 1;
4139 ++ page_size = ~qed_attr->page_size_caps + 1;
4140 + if (page_size > PAGE_SIZE) {
4141 + DP_ERR(dev,
4142 + "Kernel PAGE_SIZE is %ld which is smaller than minimum page size (%d) required by qedr\n",
4143 +diff --git a/drivers/infiniband/hw/qedr/qedr_iw_cm.c b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
4144 +index 6dea49e11f5f0..e521f3c3dbbf1 100644
4145 +--- a/drivers/infiniband/hw/qedr/qedr_iw_cm.c
4146 ++++ b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
4147 +@@ -736,7 +736,7 @@ int qedr_iw_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
4148 + struct qedr_dev *dev = ep->dev;
4149 + struct qedr_qp *qp;
4150 + struct qed_iwarp_accept_in params;
4151 +- int rc = 0;
4152 ++ int rc;
4153 +
4154 + DP_DEBUG(dev, QEDR_MSG_IWARP, "Accept on qpid=%d\n", conn_param->qpn);
4155 +
4156 +@@ -759,8 +759,10 @@ int qedr_iw_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
4157 + params.ord = conn_param->ord;
4158 +
4159 + if (test_and_set_bit(QEDR_IWARP_CM_WAIT_FOR_CONNECT,
4160 +- &qp->iwarp_cm_flags))
4161 ++ &qp->iwarp_cm_flags)) {
4162 ++ rc = -EINVAL;
4163 + goto err; /* QP already destroyed */
4164 ++ }
4165 +
4166 + rc = dev->ops->iwarp_accept(dev->rdma_ctx, &params);
4167 + if (rc) {
4168 +diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
4169 +index 16a994fd7d0a7..4408d33646647 100644
4170 +--- a/drivers/infiniband/hw/qedr/verbs.c
4171 ++++ b/drivers/infiniband/hw/qedr/verbs.c
4172 +@@ -2405,7 +2405,7 @@ int qedr_query_qp(struct ib_qp *ibqp,
4173 + qp_attr->cap.max_recv_wr = qp->rq.max_wr;
4174 + qp_attr->cap.max_send_sge = qp->sq.max_sges;
4175 + qp_attr->cap.max_recv_sge = qp->rq.max_sges;
4176 +- qp_attr->cap.max_inline_data = ROCE_REQ_MAX_INLINE_DATA_SIZE;
4177 ++ qp_attr->cap.max_inline_data = dev->attr.max_inline;
4178 + qp_init_attr->cap = qp_attr->cap;
4179 +
4180 + qp_attr->ah_attr.type = RDMA_AH_ATTR_TYPE_ROCE;
4181 +@@ -2518,6 +2518,8 @@ int qedr_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
4182 +
4183 + if (rdma_protocol_iwarp(&dev->ibdev, 1))
4184 + qedr_iw_qp_rem_ref(&qp->ibqp);
4185 ++ else
4186 ++ kfree(qp);
4187 +
4188 + return 0;
4189 + }
4190 +diff --git a/drivers/infiniband/sw/rdmavt/vt.c b/drivers/infiniband/sw/rdmavt/vt.c
4191 +index 18da1e1ea9797..833f3f1b87f5e 100644
4192 +--- a/drivers/infiniband/sw/rdmavt/vt.c
4193 ++++ b/drivers/infiniband/sw/rdmavt/vt.c
4194 +@@ -95,9 +95,7 @@ struct rvt_dev_info *rvt_alloc_device(size_t size, int nports)
4195 + if (!rdi)
4196 + return rdi;
4197 +
4198 +- rdi->ports = kcalloc(nports,
4199 +- sizeof(struct rvt_ibport **),
4200 +- GFP_KERNEL);
4201 ++ rdi->ports = kcalloc(nports, sizeof(*rdi->ports), GFP_KERNEL);
4202 + if (!rdi->ports)
4203 + ib_dealloc_device(&rdi->ibdev);
4204 +
4205 +diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c
4206 +index 46e111c218fd4..9bfb98056fc2a 100644
4207 +--- a/drivers/infiniband/sw/rxe/rxe_recv.c
4208 ++++ b/drivers/infiniband/sw/rxe/rxe_recv.c
4209 +@@ -281,6 +281,8 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)
4210 + struct rxe_mc_elem *mce;
4211 + struct rxe_qp *qp;
4212 + union ib_gid dgid;
4213 ++ struct sk_buff *per_qp_skb;
4214 ++ struct rxe_pkt_info *per_qp_pkt;
4215 + int err;
4216 +
4217 + if (skb->protocol == htons(ETH_P_IP))
4218 +@@ -309,21 +311,29 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)
4219 + if (err)
4220 + continue;
4221 +
4222 +- /* if *not* the last qp in the list
4223 +- * increase the users of the skb then post to the next qp
4224 ++ /* for all but the last qp create a new clone of the
4225 ++ * skb and pass to the qp.
4226 + */
4227 + if (mce->qp_list.next != &mcg->qp_list)
4228 +- skb_get(skb);
4229 ++ per_qp_skb = skb_clone(skb, GFP_ATOMIC);
4230 ++ else
4231 ++ per_qp_skb = skb;
4232 ++
4233 ++ if (unlikely(!per_qp_skb))
4234 ++ continue;
4235 +
4236 +- pkt->qp = qp;
4237 ++ per_qp_pkt = SKB_TO_PKT(per_qp_skb);
4238 ++ per_qp_pkt->qp = qp;
4239 + rxe_add_ref(qp);
4240 +- rxe_rcv_pkt(pkt, skb);
4241 ++ rxe_rcv_pkt(per_qp_pkt, per_qp_skb);
4242 + }
4243 +
4244 + spin_unlock_bh(&mcg->mcg_lock);
4245 +
4246 + rxe_drop_ref(mcg); /* drop ref from rxe_pool_get_key. */
4247 +
4248 ++ return;
4249 ++
4250 + err1:
4251 + kfree_skb(skb);
4252 + }
4253 +diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
4254 +index 044bcacad6e48..69ecf37053a81 100644
4255 +--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
4256 ++++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
4257 +@@ -2463,6 +2463,8 @@ static struct net_device *ipoib_add_port(const char *format,
4258 + /* call event handler to ensure pkey in sync */
4259 + queue_work(ipoib_workqueue, &priv->flush_heavy);
4260 +
4261 ++ ndev->rtnl_link_ops = ipoib_get_link_ops();
4262 ++
4263 + result = register_netdev(ndev);
4264 + if (result) {
4265 + pr_warn("%s: couldn't register ipoib port %d; error %d\n",
4266 +diff --git a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
4267 +index 38c984d16996d..d5a90a66b45cf 100644
4268 +--- a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
4269 ++++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
4270 +@@ -144,6 +144,16 @@ static int ipoib_new_child_link(struct net *src_net, struct net_device *dev,
4271 + return 0;
4272 + }
4273 +
4274 ++static void ipoib_del_child_link(struct net_device *dev, struct list_head *head)
4275 ++{
4276 ++ struct ipoib_dev_priv *priv = ipoib_priv(dev);
4277 ++
4278 ++ if (!priv->parent)
4279 ++ return;
4280 ++
4281 ++ unregister_netdevice_queue(dev, head);
4282 ++}
4283 ++
4284 + static size_t ipoib_get_size(const struct net_device *dev)
4285 + {
4286 + return nla_total_size(2) + /* IFLA_IPOIB_PKEY */
4287 +@@ -158,6 +168,7 @@ static struct rtnl_link_ops ipoib_link_ops __read_mostly = {
4288 + .priv_size = sizeof(struct ipoib_dev_priv),
4289 + .setup = ipoib_setup_common,
4290 + .newlink = ipoib_new_child_link,
4291 ++ .dellink = ipoib_del_child_link,
4292 + .changelink = ipoib_changelink,
4293 + .get_size = ipoib_get_size,
4294 + .fill_info = ipoib_fill_info,
4295 +diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
4296 +index 8ac8e18fbe0c3..58ca5e9c6079c 100644
4297 +--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
4298 ++++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
4299 +@@ -192,6 +192,8 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
4300 + }
4301 + priv = ipoib_priv(ndev);
4302 +
4303 ++ ndev->rtnl_link_ops = ipoib_get_link_ops();
4304 ++
4305 + result = __ipoib_vlan_add(ppriv, priv, pkey, IPOIB_LEGACY_CHILD);
4306 +
4307 + if (result && ndev->reg_state == NETREG_UNINITIALIZED)
4308 +diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
4309 +index 7c70492d9d6b5..f831f01501d58 100644
4310 +--- a/drivers/input/keyboard/ep93xx_keypad.c
4311 ++++ b/drivers/input/keyboard/ep93xx_keypad.c
4312 +@@ -250,8 +250,8 @@ static int ep93xx_keypad_probe(struct platform_device *pdev)
4313 + }
4314 +
4315 + keypad->irq = platform_get_irq(pdev, 0);
4316 +- if (!keypad->irq) {
4317 +- err = -ENXIO;
4318 ++ if (keypad->irq < 0) {
4319 ++ err = keypad->irq;
4320 + goto failed_free;
4321 + }
4322 +
4323 +diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
4324 +index 94c94d7f5155f..d6c924032aaa8 100644
4325 +--- a/drivers/input/keyboard/omap4-keypad.c
4326 ++++ b/drivers/input/keyboard/omap4-keypad.c
4327 +@@ -240,10 +240,8 @@ static int omap4_keypad_probe(struct platform_device *pdev)
4328 + }
4329 +
4330 + irq = platform_get_irq(pdev, 0);
4331 +- if (!irq) {
4332 +- dev_err(&pdev->dev, "no keyboard irq assigned\n");
4333 +- return -EINVAL;
4334 +- }
4335 ++ if (irq < 0)
4336 ++ return irq;
4337 +
4338 + keypad_data = kzalloc(sizeof(struct omap4_keypad), GFP_KERNEL);
4339 + if (!keypad_data) {
4340 +diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
4341 +index af3a6824f1a4d..77e0743a3cf85 100644
4342 +--- a/drivers/input/keyboard/twl4030_keypad.c
4343 ++++ b/drivers/input/keyboard/twl4030_keypad.c
4344 +@@ -50,7 +50,7 @@ struct twl4030_keypad {
4345 + bool autorepeat;
4346 + unsigned int n_rows;
4347 + unsigned int n_cols;
4348 +- unsigned int irq;
4349 ++ int irq;
4350 +
4351 + struct device *dbg_dev;
4352 + struct input_dev *input;
4353 +@@ -376,10 +376,8 @@ static int twl4030_kp_probe(struct platform_device *pdev)
4354 + }
4355 +
4356 + kp->irq = platform_get_irq(pdev, 0);
4357 +- if (!kp->irq) {
4358 +- dev_err(&pdev->dev, "no keyboard irq assigned\n");
4359 +- return -EINVAL;
4360 +- }
4361 ++ if (kp->irq < 0)
4362 ++ return kp->irq;
4363 +
4364 + error = matrix_keypad_build_keymap(keymap_data, NULL,
4365 + TWL4030_MAX_ROWS,
4366 +diff --git a/drivers/input/serio/sun4i-ps2.c b/drivers/input/serio/sun4i-ps2.c
4367 +index a681a2c04e399..f15ed3dcdb9b2 100644
4368 +--- a/drivers/input/serio/sun4i-ps2.c
4369 ++++ b/drivers/input/serio/sun4i-ps2.c
4370 +@@ -211,7 +211,6 @@ static int sun4i_ps2_probe(struct platform_device *pdev)
4371 + struct sun4i_ps2data *drvdata;
4372 + struct serio *serio;
4373 + struct device *dev = &pdev->dev;
4374 +- unsigned int irq;
4375 + int error;
4376 +
4377 + drvdata = kzalloc(sizeof(struct sun4i_ps2data), GFP_KERNEL);
4378 +@@ -264,14 +263,12 @@ static int sun4i_ps2_probe(struct platform_device *pdev)
4379 + writel(0, drvdata->reg_base + PS2_REG_GCTL);
4380 +
4381 + /* Get IRQ for the device */
4382 +- irq = platform_get_irq(pdev, 0);
4383 +- if (!irq) {
4384 +- dev_err(dev, "no IRQ found\n");
4385 +- error = -ENXIO;
4386 ++ drvdata->irq = platform_get_irq(pdev, 0);
4387 ++ if (drvdata->irq < 0) {
4388 ++ error = drvdata->irq;
4389 + goto err_disable_clk;
4390 + }
4391 +
4392 +- drvdata->irq = irq;
4393 + drvdata->serio = serio;
4394 + drvdata->dev = dev;
4395 +
4396 +diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c
4397 +index 9ed258854349b..5e6ba5c4eca2a 100644
4398 +--- a/drivers/input/touchscreen/imx6ul_tsc.c
4399 ++++ b/drivers/input/touchscreen/imx6ul_tsc.c
4400 +@@ -530,20 +530,25 @@ static int __maybe_unused imx6ul_tsc_resume(struct device *dev)
4401 +
4402 + mutex_lock(&input_dev->mutex);
4403 +
4404 +- if (input_dev->users) {
4405 +- retval = clk_prepare_enable(tsc->adc_clk);
4406 +- if (retval)
4407 +- goto out;
4408 +-
4409 +- retval = clk_prepare_enable(tsc->tsc_clk);
4410 +- if (retval) {
4411 +- clk_disable_unprepare(tsc->adc_clk);
4412 +- goto out;
4413 +- }
4414 ++ if (!input_dev->users)
4415 ++ goto out;
4416 +
4417 +- retval = imx6ul_tsc_init(tsc);
4418 ++ retval = clk_prepare_enable(tsc->adc_clk);
4419 ++ if (retval)
4420 ++ goto out;
4421 ++
4422 ++ retval = clk_prepare_enable(tsc->tsc_clk);
4423 ++ if (retval) {
4424 ++ clk_disable_unprepare(tsc->adc_clk);
4425 ++ goto out;
4426 + }
4427 +
4428 ++ retval = imx6ul_tsc_init(tsc);
4429 ++ if (retval) {
4430 ++ clk_disable_unprepare(tsc->tsc_clk);
4431 ++ clk_disable_unprepare(tsc->adc_clk);
4432 ++ goto out;
4433 ++ }
4434 + out:
4435 + mutex_unlock(&input_dev->mutex);
4436 + return retval;
4437 +diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
4438 +index b6f95f20f9244..cd8805d71d977 100644
4439 +--- a/drivers/input/touchscreen/stmfts.c
4440 ++++ b/drivers/input/touchscreen/stmfts.c
4441 +@@ -479,7 +479,7 @@ static ssize_t stmfts_sysfs_hover_enable_write(struct device *dev,
4442 +
4443 + mutex_lock(&sdata->mutex);
4444 +
4445 +- if (value & sdata->hover_enabled)
4446 ++ if (value && sdata->hover_enabled)
4447 + goto out;
4448 +
4449 + if (sdata->running)
4450 +diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
4451 +index 7543e395a2c64..a2ebc75af8c79 100644
4452 +--- a/drivers/lightnvm/core.c
4453 ++++ b/drivers/lightnvm/core.c
4454 +@@ -1316,8 +1316,9 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg)
4455 + strlcpy(info->bmname, "gennvm", sizeof(info->bmname));
4456 + i++;
4457 +
4458 +- if (i > 31) {
4459 +- pr_err("max 31 devices can be reported.\n");
4460 ++ if (i >= ARRAY_SIZE(devices->info)) {
4461 ++ pr_err("max %zd devices can be reported.\n",
4462 ++ ARRAY_SIZE(devices->info));
4463 + break;
4464 + }
4465 + }
4466 +diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
4467 +index 0b821a5b2db84..3e7d4b20ab34f 100644
4468 +--- a/drivers/mailbox/mailbox.c
4469 ++++ b/drivers/mailbox/mailbox.c
4470 +@@ -82,9 +82,12 @@ static void msg_submit(struct mbox_chan *chan)
4471 + exit:
4472 + spin_unlock_irqrestore(&chan->lock, flags);
4473 +
4474 +- if (!err && (chan->txdone_method & TXDONE_BY_POLL))
4475 +- /* kick start the timer immediately to avoid delays */
4476 +- hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL);
4477 ++ /* kick start the timer immediately to avoid delays */
4478 ++ if (!err && (chan->txdone_method & TXDONE_BY_POLL)) {
4479 ++ /* but only if not already active */
4480 ++ if (!hrtimer_active(&chan->mbox->poll_hrt))
4481 ++ hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL);
4482 ++ }
4483 + }
4484 +
4485 + static void tx_tick(struct mbox_chan *chan, int r)
4486 +@@ -122,11 +125,10 @@ static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer)
4487 + struct mbox_chan *chan = &mbox->chans[i];
4488 +
4489 + if (chan->active_req && chan->cl) {
4490 ++ resched = true;
4491 + txdone = chan->mbox->ops->last_tx_done(chan);
4492 + if (txdone)
4493 + tx_tick(chan, 0);
4494 +- else
4495 +- resched = true;
4496 + }
4497 + }
4498 +
4499 +diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
4500 +index 9a6ce9f5a7db5..3c8b365ce635a 100644
4501 +--- a/drivers/mailbox/mtk-cmdq-mailbox.c
4502 ++++ b/drivers/mailbox/mtk-cmdq-mailbox.c
4503 +@@ -70,7 +70,7 @@ struct cmdq_task {
4504 + struct cmdq {
4505 + struct mbox_controller mbox;
4506 + void __iomem *base;
4507 +- u32 irq;
4508 ++ int irq;
4509 + u32 thread_nr;
4510 + u32 irq_mask;
4511 + struct cmdq_thread *thread;
4512 +@@ -474,10 +474,8 @@ static int cmdq_probe(struct platform_device *pdev)
4513 + }
4514 +
4515 + cmdq->irq = platform_get_irq(pdev, 0);
4516 +- if (!cmdq->irq) {
4517 +- dev_err(dev, "failed to get irq\n");
4518 +- return -EINVAL;
4519 +- }
4520 ++ if (cmdq->irq < 0)
4521 ++ return cmdq->irq;
4522 +
4523 + cmdq->thread_nr = (u32)(unsigned long)of_device_get_match_data(dev);
4524 + cmdq->irq_mask = GENMASK(cmdq->thread_nr - 1, 0);
4525 +diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
4526 +index 3ad18246fcb3c..7227d03dbbea7 100644
4527 +--- a/drivers/md/md-bitmap.c
4528 ++++ b/drivers/md/md-bitmap.c
4529 +@@ -1954,6 +1954,7 @@ out:
4530 + }
4531 + EXPORT_SYMBOL_GPL(md_bitmap_load);
4532 +
4533 ++/* caller need to free returned bitmap with md_bitmap_free() */
4534 + struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot)
4535 + {
4536 + int rv = 0;
4537 +@@ -2017,6 +2018,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
4538 + md_bitmap_unplug(mddev->bitmap);
4539 + *low = lo;
4540 + *high = hi;
4541 ++ md_bitmap_free(bitmap);
4542 +
4543 + return rv;
4544 + }
4545 +@@ -2620,4 +2622,3 @@ struct attribute_group md_bitmap_group = {
4546 + .name = "bitmap",
4547 + .attrs = md_bitmap_attrs,
4548 + };
4549 +-
4550 +diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
4551 +index d50737ec40394..afbbc552c3275 100644
4552 +--- a/drivers/md/md-cluster.c
4553 ++++ b/drivers/md/md-cluster.c
4554 +@@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
4555 + * can't resize bitmap
4556 + */
4557 + goto out;
4558 ++ md_bitmap_free(bitmap);
4559 + }
4560 +
4561 + return 0;
4562 +diff --git a/drivers/media/firewire/firedtv-fw.c b/drivers/media/firewire/firedtv-fw.c
4563 +index 3f1ca40b9b987..8a8585261bb80 100644
4564 +--- a/drivers/media/firewire/firedtv-fw.c
4565 ++++ b/drivers/media/firewire/firedtv-fw.c
4566 +@@ -272,8 +272,10 @@ static int node_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
4567 +
4568 + name_len = fw_csr_string(unit->directory, CSR_MODEL,
4569 + name, sizeof(name));
4570 +- if (name_len < 0)
4571 +- return name_len;
4572 ++ if (name_len < 0) {
4573 ++ err = name_len;
4574 ++ goto fail_free;
4575 ++ }
4576 + for (i = ARRAY_SIZE(model_names); --i; )
4577 + if (strlen(model_names[i]) <= name_len &&
4578 + strncmp(name, model_names[i], name_len) == 0)
4579 +diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
4580 +index de295114ca482..21666d705e372 100644
4581 +--- a/drivers/media/i2c/m5mols/m5mols_core.c
4582 ++++ b/drivers/media/i2c/m5mols/m5mols_core.c
4583 +@@ -764,7 +764,8 @@ static int m5mols_sensor_power(struct m5mols_info *info, bool enable)
4584 +
4585 + ret = regulator_bulk_enable(ARRAY_SIZE(supplies), supplies);
4586 + if (ret) {
4587 +- info->set_power(&client->dev, 0);
4588 ++ if (info->set_power)
4589 ++ info->set_power(&client->dev, 0);
4590 + return ret;
4591 + }
4592 +
4593 +diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
4594 +index 266e947572c1e..be6c882dd1d54 100644
4595 +--- a/drivers/media/i2c/ov5640.c
4596 ++++ b/drivers/media/i2c/ov5640.c
4597 +@@ -34,6 +34,8 @@
4598 + #define OV5640_REG_SYS_RESET02 0x3002
4599 + #define OV5640_REG_SYS_CLOCK_ENABLE02 0x3006
4600 + #define OV5640_REG_SYS_CTRL0 0x3008
4601 ++#define OV5640_REG_SYS_CTRL0_SW_PWDN 0x42
4602 ++#define OV5640_REG_SYS_CTRL0_SW_PWUP 0x02
4603 + #define OV5640_REG_CHIP_ID 0x300a
4604 + #define OV5640_REG_IO_MIPI_CTRL00 0x300e
4605 + #define OV5640_REG_PAD_OUTPUT_ENABLE01 0x3017
4606 +@@ -272,8 +274,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
4607 + /* YUV422 UYVY VGA@30fps */
4608 + static const struct reg_value ov5640_init_setting_30fps_VGA[] = {
4609 + {0x3103, 0x11, 0, 0}, {0x3008, 0x82, 0, 5}, {0x3008, 0x42, 0, 0},
4610 +- {0x3103, 0x03, 0, 0}, {0x3017, 0x00, 0, 0}, {0x3018, 0x00, 0, 0},
4611 +- {0x3630, 0x36, 0, 0},
4612 ++ {0x3103, 0x03, 0, 0}, {0x3630, 0x36, 0, 0},
4613 + {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0},
4614 + {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0},
4615 + {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x370b, 0x60, 0, 0},
4616 +@@ -740,7 +741,7 @@ static int ov5640_mod_reg(struct ov5640_dev *sensor, u16 reg,
4617 + * +->| PLL Root Div | - reg 0x3037, bit 4
4618 + * +-+------------+
4619 + * | +---------+
4620 +- * +->| Bit Div | - reg 0x3035, bits 0-3
4621 ++ * +->| Bit Div | - reg 0x3034, bits 0-3
4622 + * +-+-------+
4623 + * | +-------------+
4624 + * +->| SCLK Div | - reg 0x3108, bits 0-1
4625 +@@ -1109,6 +1110,12 @@ static int ov5640_load_regs(struct ov5640_dev *sensor,
4626 + val = regs->val;
4627 + mask = regs->mask;
4628 +
4629 ++ /* remain in power down mode for DVP */
4630 ++ if (regs->reg_addr == OV5640_REG_SYS_CTRL0 &&
4631 ++ val == OV5640_REG_SYS_CTRL0_SW_PWUP &&
4632 ++ sensor->ep.bus_type != V4L2_MBUS_CSI2_DPHY)
4633 ++ continue;
4634 ++
4635 + if (mask)
4636 + ret = ov5640_mod_reg(sensor, reg_addr, mask, val);
4637 + else
4638 +@@ -1264,31 +1271,9 @@ static int ov5640_set_stream_dvp(struct ov5640_dev *sensor, bool on)
4639 + if (ret)
4640 + return ret;
4641 +
4642 +- /*
4643 +- * enable VSYNC/HREF/PCLK DVP control lines
4644 +- * & D[9:6] DVP data lines
4645 +- *
4646 +- * PAD OUTPUT ENABLE 01
4647 +- * - 6: VSYNC output enable
4648 +- * - 5: HREF output enable
4649 +- * - 4: PCLK output enable
4650 +- * - [3:0]: D[9:6] output enable
4651 +- */
4652 +- ret = ov5640_write_reg(sensor,
4653 +- OV5640_REG_PAD_OUTPUT_ENABLE01,
4654 +- on ? 0x7f : 0);
4655 +- if (ret)
4656 +- return ret;
4657 +-
4658 +- /*
4659 +- * enable D[5:0] DVP data lines
4660 +- *
4661 +- * PAD OUTPUT ENABLE 02
4662 +- * - [7:2]: D[5:0] output enable
4663 +- */
4664 +- return ov5640_write_reg(sensor,
4665 +- OV5640_REG_PAD_OUTPUT_ENABLE02,
4666 +- on ? 0xfc : 0);
4667 ++ return ov5640_write_reg(sensor, OV5640_REG_SYS_CTRL0, on ?
4668 ++ OV5640_REG_SYS_CTRL0_SW_PWUP :
4669 ++ OV5640_REG_SYS_CTRL0_SW_PWDN);
4670 + }
4671 +
4672 + static int ov5640_set_stream_mipi(struct ov5640_dev *sensor, bool on)
4673 +@@ -1987,6 +1972,95 @@ static void ov5640_set_power_off(struct ov5640_dev *sensor)
4674 + clk_disable_unprepare(sensor->xclk);
4675 + }
4676 +
4677 ++static int ov5640_set_power_mipi(struct ov5640_dev *sensor, bool on)
4678 ++{
4679 ++ int ret;
4680 ++
4681 ++ if (!on) {
4682 ++ /* Reset MIPI bus settings to their default values. */
4683 ++ ov5640_write_reg(sensor, OV5640_REG_IO_MIPI_CTRL00, 0x58);
4684 ++ ov5640_write_reg(sensor, OV5640_REG_MIPI_CTRL00, 0x04);
4685 ++ ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT00, 0x00);
4686 ++ return 0;
4687 ++ }
4688 ++
4689 ++ /*
4690 ++ * Power up MIPI HS Tx and LS Rx; 2 data lanes mode
4691 ++ *
4692 ++ * 0x300e = 0x40
4693 ++ * [7:5] = 010 : 2 data lanes mode (see FIXME note in
4694 ++ * "ov5640_set_stream_mipi()")
4695 ++ * [4] = 0 : Power up MIPI HS Tx
4696 ++ * [3] = 0 : Power up MIPI LS Rx
4697 ++ * [2] = 0 : MIPI interface disabled
4698 ++ */
4699 ++ ret = ov5640_write_reg(sensor, OV5640_REG_IO_MIPI_CTRL00, 0x40);
4700 ++ if (ret)
4701 ++ return ret;
4702 ++
4703 ++ /*
4704 ++ * Gate clock and set LP11 in 'no packets mode' (idle)
4705 ++ *
4706 ++ * 0x4800 = 0x24
4707 ++ * [5] = 1 : Gate clock when 'no packets'
4708 ++ * [2] = 1 : MIPI bus in LP11 when 'no packets'
4709 ++ */
4710 ++ ret = ov5640_write_reg(sensor, OV5640_REG_MIPI_CTRL00, 0x24);
4711 ++ if (ret)
4712 ++ return ret;
4713 ++
4714 ++ /*
4715 ++ * Set data lanes and clock in LP11 when 'sleeping'
4716 ++ *
4717 ++ * 0x3019 = 0x70
4718 ++ * [6] = 1 : MIPI data lane 2 in LP11 when 'sleeping'
4719 ++ * [5] = 1 : MIPI data lane 1 in LP11 when 'sleeping'
4720 ++ * [4] = 1 : MIPI clock lane in LP11 when 'sleeping'
4721 ++ */
4722 ++ ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT00, 0x70);
4723 ++ if (ret)
4724 ++ return ret;
4725 ++
4726 ++ /* Give lanes some time to coax into LP11 state. */
4727 ++ usleep_range(500, 1000);
4728 ++
4729 ++ return 0;
4730 ++}
4731 ++
4732 ++static int ov5640_set_power_dvp(struct ov5640_dev *sensor, bool on)
4733 ++{
4734 ++ int ret;
4735 ++
4736 ++ if (!on) {
4737 ++ /* Reset settings to their default values. */
4738 ++ ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE01, 0x00);
4739 ++ ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE02, 0x00);
4740 ++ return 0;
4741 ++ }
4742 ++
4743 ++ /*
4744 ++ * enable VSYNC/HREF/PCLK DVP control lines
4745 ++ * & D[9:6] DVP data lines
4746 ++ *
4747 ++ * PAD OUTPUT ENABLE 01
4748 ++ * - 6: VSYNC output enable
4749 ++ * - 5: HREF output enable
4750 ++ * - 4: PCLK output enable
4751 ++ * - [3:0]: D[9:6] output enable
4752 ++ */
4753 ++ ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE01, 0x7f);
4754 ++ if (ret)
4755 ++ return ret;
4756 ++
4757 ++ /*
4758 ++ * enable D[5:0] DVP data lines
4759 ++ *
4760 ++ * PAD OUTPUT ENABLE 02
4761 ++ * - [7:2]: D[5:0] output enable
4762 ++ */
4763 ++ return ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE02, 0xfc);
4764 ++}
4765 ++
4766 + static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
4767 + {
4768 + int ret = 0;
4769 +@@ -1999,67 +2073,17 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
4770 + ret = ov5640_restore_mode(sensor);
4771 + if (ret)
4772 + goto power_off;
4773 ++ }
4774 +
4775 +- /* We're done here for DVP bus, while CSI-2 needs setup. */
4776 +- if (sensor->ep.bus_type != V4L2_MBUS_CSI2_DPHY)
4777 +- return 0;
4778 +-
4779 +- /*
4780 +- * Power up MIPI HS Tx and LS Rx; 2 data lanes mode
4781 +- *
4782 +- * 0x300e = 0x40
4783 +- * [7:5] = 010 : 2 data lanes mode (see FIXME note in
4784 +- * "ov5640_set_stream_mipi()")
4785 +- * [4] = 0 : Power up MIPI HS Tx
4786 +- * [3] = 0 : Power up MIPI LS Rx
4787 +- * [2] = 0 : MIPI interface disabled
4788 +- */
4789 +- ret = ov5640_write_reg(sensor,
4790 +- OV5640_REG_IO_MIPI_CTRL00, 0x40);
4791 +- if (ret)
4792 +- goto power_off;
4793 +-
4794 +- /*
4795 +- * Gate clock and set LP11 in 'no packets mode' (idle)
4796 +- *
4797 +- * 0x4800 = 0x24
4798 +- * [5] = 1 : Gate clock when 'no packets'
4799 +- * [2] = 1 : MIPI bus in LP11 when 'no packets'
4800 +- */
4801 +- ret = ov5640_write_reg(sensor,
4802 +- OV5640_REG_MIPI_CTRL00, 0x24);
4803 +- if (ret)
4804 +- goto power_off;
4805 +-
4806 +- /*
4807 +- * Set data lanes and clock in LP11 when 'sleeping'
4808 +- *
4809 +- * 0x3019 = 0x70
4810 +- * [6] = 1 : MIPI data lane 2 in LP11 when 'sleeping'
4811 +- * [5] = 1 : MIPI data lane 1 in LP11 when 'sleeping'
4812 +- * [4] = 1 : MIPI clock lane in LP11 when 'sleeping'
4813 +- */
4814 +- ret = ov5640_write_reg(sensor,
4815 +- OV5640_REG_PAD_OUTPUT00, 0x70);
4816 +- if (ret)
4817 +- goto power_off;
4818 +-
4819 +- /* Give lanes some time to coax into LP11 state. */
4820 +- usleep_range(500, 1000);
4821 +-
4822 +- } else {
4823 +- if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY) {
4824 +- /* Reset MIPI bus settings to their default values. */
4825 +- ov5640_write_reg(sensor,
4826 +- OV5640_REG_IO_MIPI_CTRL00, 0x58);
4827 +- ov5640_write_reg(sensor,
4828 +- OV5640_REG_MIPI_CTRL00, 0x04);
4829 +- ov5640_write_reg(sensor,
4830 +- OV5640_REG_PAD_OUTPUT00, 0x00);
4831 +- }
4832 ++ if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY)
4833 ++ ret = ov5640_set_power_mipi(sensor, on);
4834 ++ else
4835 ++ ret = ov5640_set_power_dvp(sensor, on);
4836 ++ if (ret)
4837 ++ goto power_off;
4838 +
4839 ++ if (!on)
4840 + ov5640_set_power_off(sensor);
4841 +- }
4842 +
4843 + return 0;
4844 +
4845 +diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
4846 +index dbbab75f135ec..cff99cf61ed4d 100644
4847 +--- a/drivers/media/i2c/tc358743.c
4848 ++++ b/drivers/media/i2c/tc358743.c
4849 +@@ -919,8 +919,8 @@ static const struct cec_adap_ops tc358743_cec_adap_ops = {
4850 + .adap_monitor_all_enable = tc358743_cec_adap_monitor_all_enable,
4851 + };
4852 +
4853 +-static void tc358743_cec_isr(struct v4l2_subdev *sd, u16 intstatus,
4854 +- bool *handled)
4855 ++static void tc358743_cec_handler(struct v4l2_subdev *sd, u16 intstatus,
4856 ++ bool *handled)
4857 + {
4858 + struct tc358743_state *state = to_state(sd);
4859 + unsigned int cec_rxint, cec_txint;
4860 +@@ -953,7 +953,8 @@ static void tc358743_cec_isr(struct v4l2_subdev *sd, u16 intstatus,
4861 + cec_transmit_attempt_done(state->cec_adap,
4862 + CEC_TX_STATUS_ERROR);
4863 + }
4864 +- *handled = true;
4865 ++ if (handled)
4866 ++ *handled = true;
4867 + }
4868 + if ((intstatus & MASK_CEC_RINT) &&
4869 + (cec_rxint & MASK_CECRIEND)) {
4870 +@@ -968,7 +969,8 @@ static void tc358743_cec_isr(struct v4l2_subdev *sd, u16 intstatus,
4871 + msg.msg[i] = v & 0xff;
4872 + }
4873 + cec_received_msg(state->cec_adap, &msg);
4874 +- *handled = true;
4875 ++ if (handled)
4876 ++ *handled = true;
4877 + }
4878 + i2c_wr16(sd, INTSTATUS,
4879 + intstatus & (MASK_CEC_RINT | MASK_CEC_TINT));
4880 +@@ -1432,7 +1434,7 @@ static int tc358743_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
4881 +
4882 + #ifdef CONFIG_VIDEO_TC358743_CEC
4883 + if (intstatus & (MASK_CEC_RINT | MASK_CEC_TINT)) {
4884 +- tc358743_cec_isr(sd, intstatus, handled);
4885 ++ tc358743_cec_handler(sd, intstatus, handled);
4886 + i2c_wr16(sd, INTSTATUS,
4887 + intstatus & (MASK_CEC_RINT | MASK_CEC_TINT));
4888 + intstatus &= ~(MASK_CEC_RINT | MASK_CEC_TINT);
4889 +@@ -1461,7 +1463,7 @@ static int tc358743_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
4890 + static irqreturn_t tc358743_irq_handler(int irq, void *dev_id)
4891 + {
4892 + struct tc358743_state *state = dev_id;
4893 +- bool handled;
4894 ++ bool handled = false;
4895 +
4896 + tc358743_isr(&state->sd, 0, &handled);
4897 +
4898 +diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
4899 +index a359da7773a90..ff2962cea6164 100644
4900 +--- a/drivers/media/pci/bt8xx/bttv-driver.c
4901 ++++ b/drivers/media/pci/bt8xx/bttv-driver.c
4902 +@@ -4013,11 +4013,13 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4903 + btv->id = dev->device;
4904 + if (pci_enable_device(dev)) {
4905 + pr_warn("%d: Can't enable device\n", btv->c.nr);
4906 +- return -EIO;
4907 ++ result = -EIO;
4908 ++ goto free_mem;
4909 + }
4910 + if (pci_set_dma_mask(dev, DMA_BIT_MASK(32))) {
4911 + pr_warn("%d: No suitable DMA available\n", btv->c.nr);
4912 +- return -EIO;
4913 ++ result = -EIO;
4914 ++ goto free_mem;
4915 + }
4916 + if (!request_mem_region(pci_resource_start(dev,0),
4917 + pci_resource_len(dev,0),
4918 +@@ -4025,7 +4027,8 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4919 + pr_warn("%d: can't request iomem (0x%llx)\n",
4920 + btv->c.nr,
4921 + (unsigned long long)pci_resource_start(dev, 0));
4922 +- return -EBUSY;
4923 ++ result = -EBUSY;
4924 ++ goto free_mem;
4925 + }
4926 + pci_set_master(dev);
4927 + pci_set_command(dev);
4928 +@@ -4211,6 +4214,10 @@ fail0:
4929 + release_mem_region(pci_resource_start(btv->c.pci,0),
4930 + pci_resource_len(btv->c.pci,0));
4931 + pci_disable_device(btv->c.pci);
4932 ++
4933 ++free_mem:
4934 ++ bttvs[btv->c.nr] = NULL;
4935 ++ kfree(btv);
4936 + return result;
4937 + }
4938 +
4939 +diff --git a/drivers/media/pci/saa7134/saa7134-tvaudio.c b/drivers/media/pci/saa7134/saa7134-tvaudio.c
4940 +index 79e1afb710758..5cc4ef21f9d37 100644
4941 +--- a/drivers/media/pci/saa7134/saa7134-tvaudio.c
4942 ++++ b/drivers/media/pci/saa7134/saa7134-tvaudio.c
4943 +@@ -683,7 +683,8 @@ int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value)
4944 + {
4945 + int err;
4946 +
4947 +- audio_dbg(2, "dsp write reg 0x%x = 0x%06x\n", reg << 2, value);
4948 ++ audio_dbg(2, "dsp write reg 0x%x = 0x%06x\n",
4949 ++ (reg << 2) & 0xffffffff, value);
4950 + err = saa_dsp_wait_bit(dev,SAA7135_DSP_RWSTATE_WRR);
4951 + if (err < 0)
4952 + return err;
4953 +diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c
4954 +index cde0d254ec1c4..a77c49b185115 100644
4955 +--- a/drivers/media/platform/exynos4-is/fimc-isp.c
4956 ++++ b/drivers/media/platform/exynos4-is/fimc-isp.c
4957 +@@ -305,8 +305,10 @@ static int fimc_isp_subdev_s_power(struct v4l2_subdev *sd, int on)
4958 +
4959 + if (on) {
4960 + ret = pm_runtime_get_sync(&is->pdev->dev);
4961 +- if (ret < 0)
4962 ++ if (ret < 0) {
4963 ++ pm_runtime_put(&is->pdev->dev);
4964 + return ret;
4965 ++ }
4966 + set_bit(IS_ST_PWR_ON, &is->state);
4967 +
4968 + ret = fimc_is_start_firmware(is);
4969 +diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
4970 +index e87c6a09205bd..efd06621951c7 100644
4971 +--- a/drivers/media/platform/exynos4-is/fimc-lite.c
4972 ++++ b/drivers/media/platform/exynos4-is/fimc-lite.c
4973 +@@ -470,7 +470,7 @@ static int fimc_lite_open(struct file *file)
4974 + set_bit(ST_FLITE_IN_USE, &fimc->state);
4975 + ret = pm_runtime_get_sync(&fimc->pdev->dev);
4976 + if (ret < 0)
4977 +- goto unlock;
4978 ++ goto err_pm;
4979 +
4980 + ret = v4l2_fh_open(file);
4981 + if (ret < 0)
4982 +diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
4983 +index 9c31d950cddf7..a07d796f63df0 100644
4984 +--- a/drivers/media/platform/exynos4-is/media-dev.c
4985 ++++ b/drivers/media/platform/exynos4-is/media-dev.c
4986 +@@ -484,8 +484,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
4987 + return -ENXIO;
4988 +
4989 + ret = pm_runtime_get_sync(fmd->pmf);
4990 +- if (ret < 0)
4991 ++ if (ret < 0) {
4992 ++ pm_runtime_put(fmd->pmf);
4993 + return ret;
4994 ++ }
4995 +
4996 + fmd->num_sensors = 0;
4997 +
4998 +@@ -1268,11 +1270,9 @@ static int fimc_md_get_pinctrl(struct fimc_md *fmd)
4999 + if (IS_ERR(pctl->state_default))
5000 + return PTR_ERR(pctl->state_default);
5001 +
5002 ++ /* PINCTRL_STATE_IDLE is optional */
5003 + pctl->state_idle = pinctrl_lookup_state(pctl->pinctrl,
5004 + PINCTRL_STATE_IDLE);
5005 +- if (IS_ERR(pctl->state_idle))
5006 +- return PTR_ERR(pctl->state_idle);
5007 +-
5008 + return 0;
5009 + }
5010 +
5011 +diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
5012 +index 540151bbf58f2..1aac167abb175 100644
5013 +--- a/drivers/media/platform/exynos4-is/mipi-csis.c
5014 ++++ b/drivers/media/platform/exynos4-is/mipi-csis.c
5015 +@@ -510,8 +510,10 @@ static int s5pcsis_s_stream(struct v4l2_subdev *sd, int enable)
5016 + if (enable) {
5017 + s5pcsis_clear_counters(state);
5018 + ret = pm_runtime_get_sync(&state->pdev->dev);
5019 +- if (ret && ret != 1)
5020 ++ if (ret && ret != 1) {
5021 ++ pm_runtime_put_noidle(&state->pdev->dev);
5022 + return ret;
5023 ++ }
5024 + }
5025 +
5026 + mutex_lock(&state->lock);
5027 +diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
5028 +index 27779b75df543..ac112cf06ab31 100644
5029 +--- a/drivers/media/platform/mx2_emmaprp.c
5030 ++++ b/drivers/media/platform/mx2_emmaprp.c
5031 +@@ -852,8 +852,11 @@ static int emmaprp_probe(struct platform_device *pdev)
5032 + platform_set_drvdata(pdev, pcdev);
5033 +
5034 + irq = platform_get_irq(pdev, 0);
5035 +- if (irq < 0)
5036 +- return irq;
5037 ++ if (irq < 0) {
5038 ++ ret = irq;
5039 ++ goto rel_vdev;
5040 ++ }
5041 ++
5042 + ret = devm_request_irq(&pdev->dev, irq, emmaprp_irq, 0,
5043 + dev_name(&pdev->dev), pcdev);
5044 + if (ret)
5045 +diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
5046 +index 327c5716922ac..dce6b3685e135 100644
5047 +--- a/drivers/media/platform/omap3isp/isp.c
5048 ++++ b/drivers/media/platform/omap3isp/isp.c
5049 +@@ -2330,8 +2330,10 @@ static int isp_probe(struct platform_device *pdev)
5050 + mem = platform_get_resource(pdev, IORESOURCE_MEM, i);
5051 + isp->mmio_base[map_idx] =
5052 + devm_ioremap_resource(isp->dev, mem);
5053 +- if (IS_ERR(isp->mmio_base[map_idx]))
5054 +- return PTR_ERR(isp->mmio_base[map_idx]);
5055 ++ if (IS_ERR(isp->mmio_base[map_idx])) {
5056 ++ ret = PTR_ERR(isp->mmio_base[map_idx]);
5057 ++ goto error;
5058 ++ }
5059 + }
5060 +
5061 + ret = isp_get_clocks(isp);
5062 +diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
5063 +index 008afb85023be..3c5b9082ad723 100644
5064 +--- a/drivers/media/platform/qcom/camss/camss-csiphy.c
5065 ++++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
5066 +@@ -176,8 +176,10 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int on)
5067 + int ret;
5068 +
5069 + ret = pm_runtime_get_sync(dev);
5070 +- if (ret < 0)
5071 ++ if (ret < 0) {
5072 ++ pm_runtime_put_sync(dev);
5073 + return ret;
5074 ++ }
5075 +
5076 + ret = csiphy_set_clock_rates(csiphy);
5077 + if (ret < 0) {
5078 +diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
5079 +index 84e982f259a06..bbc430a003443 100644
5080 +--- a/drivers/media/platform/qcom/venus/core.c
5081 ++++ b/drivers/media/platform/qcom/venus/core.c
5082 +@@ -316,8 +316,10 @@ static int venus_probe(struct platform_device *pdev)
5083 + goto err_core_deinit;
5084 +
5085 + ret = pm_runtime_put_sync(dev);
5086 +- if (ret)
5087 ++ if (ret) {
5088 ++ pm_runtime_get_noresume(dev);
5089 + goto err_dev_unregister;
5090 ++ }
5091 +
5092 + return 0;
5093 +
5094 +@@ -328,6 +330,7 @@ err_core_deinit:
5095 + err_venus_shutdown:
5096 + venus_shutdown(core);
5097 + err_runtime_disable:
5098 ++ pm_runtime_put_noidle(dev);
5099 + pm_runtime_set_suspended(dev);
5100 + pm_runtime_disable(dev);
5101 + hfi_destroy(core);
5102 +diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
5103 +index 05b80a66e80ed..658825b4c4e8d 100644
5104 +--- a/drivers/media/platform/qcom/venus/vdec.c
5105 ++++ b/drivers/media/platform/qcom/venus/vdec.c
5106 +@@ -993,8 +993,6 @@ static int vdec_stop_capture(struct venus_inst *inst)
5107 + break;
5108 + }
5109 +
5110 +- INIT_LIST_HEAD(&inst->registeredbufs);
5111 +-
5112 + return ret;
5113 + }
5114 +
5115 +@@ -1091,6 +1089,14 @@ static int vdec_buf_init(struct vb2_buffer *vb)
5116 + static void vdec_buf_cleanup(struct vb2_buffer *vb)
5117 + {
5118 + struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue);
5119 ++ struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
5120 ++ struct venus_buffer *buf = to_venus_buffer(vbuf);
5121 ++
5122 ++ mutex_lock(&inst->lock);
5123 ++ if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
5124 ++ if (!list_empty(&inst->registeredbufs))
5125 ++ list_del_init(&buf->reg_list);
5126 ++ mutex_unlock(&inst->lock);
5127 +
5128 + inst->buf_count--;
5129 + if (!inst->buf_count)
5130 +diff --git a/drivers/media/platform/rcar-fcp.c b/drivers/media/platform/rcar-fcp.c
5131 +index 5c6b00737fe75..05c712e00a2a7 100644
5132 +--- a/drivers/media/platform/rcar-fcp.c
5133 ++++ b/drivers/media/platform/rcar-fcp.c
5134 +@@ -103,8 +103,10 @@ int rcar_fcp_enable(struct rcar_fcp_device *fcp)
5135 + return 0;
5136 +
5137 + ret = pm_runtime_get_sync(fcp->dev);
5138 +- if (ret < 0)
5139 ++ if (ret < 0) {
5140 ++ pm_runtime_put_noidle(fcp->dev);
5141 + return ret;
5142 ++ }
5143 +
5144 + return 0;
5145 + }
5146 +diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
5147 +index c14af1b929dff..d27eccfa57cae 100644
5148 +--- a/drivers/media/platform/rcar-vin/rcar-csi2.c
5149 ++++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
5150 +@@ -361,7 +361,6 @@ struct rcar_csi2 {
5151 + struct media_pad pads[NR_OF_RCAR_CSI2_PAD];
5152 +
5153 + struct v4l2_async_notifier notifier;
5154 +- struct v4l2_async_subdev asd;
5155 + struct v4l2_subdev *remote;
5156 +
5157 + struct v4l2_mbus_framefmt mf;
5158 +@@ -810,6 +809,8 @@ static int rcsi2_parse_v4l2(struct rcar_csi2 *priv,
5159 +
5160 + static int rcsi2_parse_dt(struct rcar_csi2 *priv)
5161 + {
5162 ++ struct v4l2_async_subdev *asd;
5163 ++ struct fwnode_handle *fwnode;
5164 + struct device_node *ep;
5165 + struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
5166 + int ret;
5167 +@@ -833,24 +834,19 @@ static int rcsi2_parse_dt(struct rcar_csi2 *priv)
5168 + return ret;
5169 + }
5170 +
5171 +- priv->asd.match.fwnode =
5172 +- fwnode_graph_get_remote_endpoint(of_fwnode_handle(ep));
5173 +- priv->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
5174 +-
5175 ++ fwnode = fwnode_graph_get_remote_endpoint(of_fwnode_handle(ep));
5176 + of_node_put(ep);
5177 +
5178 +- v4l2_async_notifier_init(&priv->notifier);
5179 +-
5180 +- ret = v4l2_async_notifier_add_subdev(&priv->notifier, &priv->asd);
5181 +- if (ret) {
5182 +- fwnode_handle_put(priv->asd.match.fwnode);
5183 +- return ret;
5184 +- }
5185 ++ dev_dbg(priv->dev, "Found '%pOF'\n", to_of_node(fwnode));
5186 +
5187 ++ v4l2_async_notifier_init(&priv->notifier);
5188 + priv->notifier.ops = &rcar_csi2_notify_ops;
5189 +
5190 +- dev_dbg(priv->dev, "Found '%pOF'\n",
5191 +- to_of_node(priv->asd.match.fwnode));
5192 ++ asd = v4l2_async_notifier_add_fwnode_subdev(&priv->notifier, fwnode,
5193 ++ sizeof(*asd));
5194 ++ fwnode_handle_put(fwnode);
5195 ++ if (IS_ERR(asd))
5196 ++ return PTR_ERR(asd);
5197 +
5198 + ret = v4l2_async_subdev_notifier_register(&priv->subdev,
5199 + &priv->notifier);
5200 +diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
5201 +index 3cb29b2e0b2b1..e5f6360801082 100644
5202 +--- a/drivers/media/platform/rcar-vin/rcar-dma.c
5203 ++++ b/drivers/media/platform/rcar-vin/rcar-dma.c
5204 +@@ -1334,8 +1334,10 @@ int rvin_set_channel_routing(struct rvin_dev *vin, u8 chsel)
5205 + int ret;
5206 +
5207 + ret = pm_runtime_get_sync(vin->dev);
5208 +- if (ret < 0)
5209 ++ if (ret < 0) {
5210 ++ pm_runtime_put_noidle(vin->dev);
5211 + return ret;
5212 ++ }
5213 +
5214 + /* Make register writes take effect immediately. */
5215 + vnmc = rvin_read(vin, VNMC_REG);
5216 +diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
5217 +index 0f267a237b424..af3c8d405509e 100644
5218 +--- a/drivers/media/platform/rcar_drif.c
5219 ++++ b/drivers/media/platform/rcar_drif.c
5220 +@@ -185,7 +185,6 @@ struct rcar_drif_frame_buf {
5221 + /* OF graph endpoint's V4L2 async data */
5222 + struct rcar_drif_graph_ep {
5223 + struct v4l2_subdev *subdev; /* Async matched subdev */
5224 +- struct v4l2_async_subdev asd; /* Async sub-device descriptor */
5225 + };
5226 +
5227 + /* DMA buffer */
5228 +@@ -1105,12 +1104,6 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,
5229 + struct rcar_drif_sdr *sdr =
5230 + container_of(notifier, struct rcar_drif_sdr, notifier);
5231 +
5232 +- if (sdr->ep.asd.match.fwnode !=
5233 +- of_fwnode_handle(subdev->dev->of_node)) {
5234 +- rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
5235 +- return -EINVAL;
5236 +- }
5237 +-
5238 + v4l2_set_subdev_hostdata(subdev, sdr);
5239 + sdr->ep.subdev = subdev;
5240 + rdrif_dbg(sdr, "bound asd %s\n", subdev->name);
5241 +@@ -1214,7 +1207,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)
5242 + {
5243 + struct v4l2_async_notifier *notifier = &sdr->notifier;
5244 + struct fwnode_handle *fwnode, *ep;
5245 +- int ret;
5246 ++ struct v4l2_async_subdev *asd;
5247 +
5248 + v4l2_async_notifier_init(notifier);
5249 +
5250 +@@ -1223,26 +1216,21 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)
5251 + if (!ep)
5252 + return 0;
5253 +
5254 ++ /* Get the endpoint properties */
5255 ++ rcar_drif_get_ep_properties(sdr, ep);
5256 ++
5257 + fwnode = fwnode_graph_get_remote_port_parent(ep);
5258 ++ fwnode_handle_put(ep);
5259 + if (!fwnode) {
5260 + dev_warn(sdr->dev, "bad remote port parent\n");
5261 +- fwnode_handle_put(ep);
5262 + return -EINVAL;
5263 + }
5264 +
5265 +- sdr->ep.asd.match.fwnode = fwnode;
5266 +- sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
5267 +- ret = v4l2_async_notifier_add_subdev(notifier, &sdr->ep.asd);
5268 +- if (ret) {
5269 +- fwnode_handle_put(fwnode);
5270 +- return ret;
5271 +- }
5272 +-
5273 +- /* Get the endpoint properties */
5274 +- rcar_drif_get_ep_properties(sdr, ep);
5275 +-
5276 ++ asd = v4l2_async_notifier_add_fwnode_subdev(notifier, fwnode,
5277 ++ sizeof(*asd));
5278 + fwnode_handle_put(fwnode);
5279 +- fwnode_handle_put(ep);
5280 ++ if (IS_ERR(asd))
5281 ++ return PTR_ERR(asd);
5282 +
5283 + return 0;
5284 + }
5285 +diff --git a/drivers/media/platform/rockchip/rga/rga-buf.c b/drivers/media/platform/rockchip/rga/rga-buf.c
5286 +index 36b821ccc1dba..bf9a75b75083b 100644
5287 +--- a/drivers/media/platform/rockchip/rga/rga-buf.c
5288 ++++ b/drivers/media/platform/rockchip/rga/rga-buf.c
5289 +@@ -81,6 +81,7 @@ static int rga_buf_start_streaming(struct vb2_queue *q, unsigned int count)
5290 +
5291 + ret = pm_runtime_get_sync(rga->dev);
5292 + if (ret < 0) {
5293 ++ pm_runtime_put_noidle(rga->dev);
5294 + rga_buf_return_buffers(q, VB2_BUF_STATE_QUEUED);
5295 + return ret;
5296 + }
5297 +diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c
5298 +index c6fbcd7036d6d..ee624804862e2 100644
5299 +--- a/drivers/media/platform/s3c-camif/camif-core.c
5300 ++++ b/drivers/media/platform/s3c-camif/camif-core.c
5301 +@@ -464,7 +464,7 @@ static int s3c_camif_probe(struct platform_device *pdev)
5302 +
5303 + ret = camif_media_dev_init(camif);
5304 + if (ret < 0)
5305 +- goto err_alloc;
5306 ++ goto err_pm;
5307 +
5308 + ret = camif_register_sensor(camif);
5309 + if (ret < 0)
5310 +@@ -498,10 +498,9 @@ err_sens:
5311 + media_device_unregister(&camif->media_dev);
5312 + media_device_cleanup(&camif->media_dev);
5313 + camif_unregister_media_entities(camif);
5314 +-err_alloc:
5315 ++err_pm:
5316 + pm_runtime_put(dev);
5317 + pm_runtime_disable(dev);
5318 +-err_pm:
5319 + camif_clk_put(camif);
5320 + err_clk:
5321 + s3c_camif_unregister_subdev(camif);
5322 +diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
5323 +index 7d52431c2c837..62d2320a72186 100644
5324 +--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
5325 ++++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
5326 +@@ -79,8 +79,10 @@ int s5p_mfc_power_on(void)
5327 + int i, ret = 0;
5328 +
5329 + ret = pm_runtime_get_sync(pm->device);
5330 +- if (ret < 0)
5331 ++ if (ret < 0) {
5332 ++ pm_runtime_put_noidle(pm->device);
5333 + return ret;
5334 ++ }
5335 +
5336 + /* clock control */
5337 + for (i = 0; i < pm->num_clocks; i++) {
5338 +diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
5339 +index 675b5f2b4c2ee..a55ddf8d185d5 100644
5340 +--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
5341 ++++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
5342 +@@ -1367,7 +1367,7 @@ static int bdisp_probe(struct platform_device *pdev)
5343 + ret = pm_runtime_get_sync(dev);
5344 + if (ret < 0) {
5345 + dev_err(dev, "failed to set PM\n");
5346 +- goto err_dbg;
5347 ++ goto err_pm;
5348 + }
5349 +
5350 + /* Filters */
5351 +@@ -1395,7 +1395,6 @@ err_filter:
5352 + bdisp_hw_free_filters(bdisp->dev);
5353 + err_pm:
5354 + pm_runtime_put(dev);
5355 +-err_dbg:
5356 + bdisp_debugfs_remove(bdisp);
5357 + err_v4l2:
5358 + v4l2_device_unregister(&bdisp->v4l2_dev);
5359 +diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c b/drivers/media/platform/sti/delta/delta-v4l2.c
5360 +index 91369fb3ffaa4..2791107e641bc 100644
5361 +--- a/drivers/media/platform/sti/delta/delta-v4l2.c
5362 ++++ b/drivers/media/platform/sti/delta/delta-v4l2.c
5363 +@@ -954,8 +954,10 @@ static void delta_run_work(struct work_struct *work)
5364 + /* enable the hardware */
5365 + if (!dec->pm) {
5366 + ret = delta_get_sync(ctx);
5367 +- if (ret)
5368 ++ if (ret) {
5369 ++ delta_put_autosuspend(ctx);
5370 + goto err;
5371 ++ }
5372 + }
5373 +
5374 + /* decode this access unit */
5375 +diff --git a/drivers/media/platform/sti/hva/hva-hw.c b/drivers/media/platform/sti/hva/hva-hw.c
5376 +index 401aaafa17109..43f279e2a6a38 100644
5377 +--- a/drivers/media/platform/sti/hva/hva-hw.c
5378 ++++ b/drivers/media/platform/sti/hva/hva-hw.c
5379 +@@ -272,6 +272,7 @@ static unsigned long int hva_hw_get_ip_version(struct hva_dev *hva)
5380 +
5381 + if (pm_runtime_get_sync(dev) < 0) {
5382 + dev_err(dev, "%s failed to get pm_runtime\n", HVA_PREFIX);
5383 ++ pm_runtime_put_noidle(dev);
5384 + mutex_unlock(&hva->protect_mutex);
5385 + return -EFAULT;
5386 + }
5387 +@@ -388,7 +389,7 @@ int hva_hw_probe(struct platform_device *pdev, struct hva_dev *hva)
5388 + ret = pm_runtime_get_sync(dev);
5389 + if (ret < 0) {
5390 + dev_err(dev, "%s failed to set PM\n", HVA_PREFIX);
5391 +- goto err_clk;
5392 ++ goto err_pm;
5393 + }
5394 +
5395 + /* check IP hardware version */
5396 +@@ -553,6 +554,7 @@ void hva_hw_dump_regs(struct hva_dev *hva, struct seq_file *s)
5397 +
5398 + if (pm_runtime_get_sync(dev) < 0) {
5399 + seq_puts(s, "Cannot wake up IP\n");
5400 ++ pm_runtime_put_noidle(dev);
5401 + mutex_unlock(&hva->protect_mutex);
5402 + return;
5403 + }
5404 +diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
5405 +index 9392e3409fba0..d41475f56ab54 100644
5406 +--- a/drivers/media/platform/stm32/stm32-dcmi.c
5407 ++++ b/drivers/media/platform/stm32/stm32-dcmi.c
5408 +@@ -733,7 +733,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
5409 + if (ret < 0) {
5410 + dev_err(dcmi->dev, "%s: Failed to start streaming, cannot get sync (%d)\n",
5411 + __func__, ret);
5412 +- goto err_release_buffers;
5413 ++ goto err_pm_put;
5414 + }
5415 +
5416 + ret = media_pipeline_start(&dcmi->vdev->entity, &dcmi->pipeline);
5417 +@@ -837,8 +837,6 @@ err_media_pipeline_stop:
5418 +
5419 + err_pm_put:
5420 + pm_runtime_put(dcmi->dev);
5421 +-
5422 +-err_release_buffers:
5423 + spin_lock_irq(&dcmi->irqlock);
5424 + /*
5425 + * Return all buffers to vb2 in QUEUED state.
5426 +diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
5427 +index 8b14ba4a3d9ea..817bd13370eff 100644
5428 +--- a/drivers/media/platform/ti-vpe/vpe.c
5429 ++++ b/drivers/media/platform/ti-vpe/vpe.c
5430 +@@ -2435,6 +2435,8 @@ static int vpe_runtime_get(struct platform_device *pdev)
5431 +
5432 + r = pm_runtime_get_sync(&pdev->dev);
5433 + WARN_ON(r < 0);
5434 ++ if (r)
5435 ++ pm_runtime_put_noidle(&pdev->dev);
5436 + return r < 0 ? r : 0;
5437 + }
5438 +
5439 +diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
5440 +index c650e45bb0ad1..dc62533cf32ce 100644
5441 +--- a/drivers/media/platform/vsp1/vsp1_drv.c
5442 ++++ b/drivers/media/platform/vsp1/vsp1_drv.c
5443 +@@ -562,7 +562,12 @@ int vsp1_device_get(struct vsp1_device *vsp1)
5444 + int ret;
5445 +
5446 + ret = pm_runtime_get_sync(vsp1->dev);
5447 +- return ret < 0 ? ret : 0;
5448 ++ if (ret < 0) {
5449 ++ pm_runtime_put_noidle(vsp1->dev);
5450 ++ return ret;
5451 ++ }
5452 ++
5453 ++ return 0;
5454 + }
5455 +
5456 + /*
5457 +@@ -845,12 +850,12 @@ static int vsp1_probe(struct platform_device *pdev)
5458 + /* Configure device parameters based on the version register. */
5459 + pm_runtime_enable(&pdev->dev);
5460 +
5461 +- ret = pm_runtime_get_sync(&pdev->dev);
5462 ++ ret = vsp1_device_get(vsp1);
5463 + if (ret < 0)
5464 + goto done;
5465 +
5466 + vsp1->version = vsp1_read(vsp1, VI6_IP_VERSION);
5467 +- pm_runtime_put_sync(&pdev->dev);
5468 ++ vsp1_device_put(vsp1);
5469 +
5470 + for (i = 0; i < ARRAY_SIZE(vsp1_device_infos); ++i) {
5471 + if ((vsp1->version & VI6_IP_VERSION_MODEL_MASK) ==
5472 +diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
5473 +index 9cdef17b4793f..c12dda73cdd53 100644
5474 +--- a/drivers/media/rc/ati_remote.c
5475 ++++ b/drivers/media/rc/ati_remote.c
5476 +@@ -835,6 +835,10 @@ static int ati_remote_probe(struct usb_interface *interface,
5477 + err("%s: endpoint_in message size==0? \n", __func__);
5478 + return -ENODEV;
5479 + }
5480 ++ if (!usb_endpoint_is_int_out(endpoint_out)) {
5481 ++ err("%s: Unexpected endpoint_out\n", __func__);
5482 ++ return -ENODEV;
5483 ++ }
5484 +
5485 + ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL);
5486 + rc_dev = rc_allocate_device(RC_DRIVER_SCANCODE);
5487 +diff --git a/drivers/media/tuners/tuner-simple.c b/drivers/media/tuners/tuner-simple.c
5488 +index b6e70fada3fb2..8fb186b25d6af 100644
5489 +--- a/drivers/media/tuners/tuner-simple.c
5490 ++++ b/drivers/media/tuners/tuner-simple.c
5491 +@@ -500,7 +500,7 @@ static int simple_radio_bandswitch(struct dvb_frontend *fe, u8 *buffer)
5492 + case TUNER_TENA_9533_DI:
5493 + case TUNER_YMEC_TVF_5533MF:
5494 + tuner_dbg("This tuner doesn't have FM. Most cards have a TEA5767 for FM\n");
5495 +- return 0;
5496 ++ return -EINVAL;
5497 + case TUNER_PHILIPS_FM1216ME_MK3:
5498 + case TUNER_PHILIPS_FM1236_MK3:
5499 + case TUNER_PHILIPS_FMD1216ME_MK3:
5500 +@@ -702,7 +702,8 @@ static int simple_set_radio_freq(struct dvb_frontend *fe,
5501 + TUNER_RATIO_SELECT_50; /* 50 kHz step */
5502 +
5503 + /* Bandswitch byte */
5504 +- simple_radio_bandswitch(fe, &buffer[0]);
5505 ++ if (simple_radio_bandswitch(fe, &buffer[0]))
5506 ++ return 0;
5507 +
5508 + /* Convert from 1/16 kHz V4L steps to 1/20 MHz (=50 kHz) PLL steps
5509 + freq * (1 Mhz / 16000 V4L steps) * (20 PLL steps / 1 MHz) =
5510 +diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
5511 +index e399b9fad7574..a30a8a731eda8 100644
5512 +--- a/drivers/media/usb/uvc/uvc_ctrl.c
5513 ++++ b/drivers/media/usb/uvc/uvc_ctrl.c
5514 +@@ -773,12 +773,16 @@ static s32 uvc_get_le_value(struct uvc_control_mapping *mapping,
5515 + offset &= 7;
5516 + mask = ((1LL << bits) - 1) << offset;
5517 +
5518 +- for (; bits > 0; data++) {
5519 ++ while (1) {
5520 + u8 byte = *data & mask;
5521 + value |= offset > 0 ? (byte >> offset) : (byte << (-offset));
5522 + bits -= 8 - (offset > 0 ? offset : 0);
5523 ++ if (bits <= 0)
5524 ++ break;
5525 ++
5526 + offset -= 8;
5527 + mask = (1 << bits) - 1;
5528 ++ data++;
5529 + }
5530 +
5531 + /* Sign-extend the value if needed. */
5532 +diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c
5533 +index b4499cddeffe5..ca3a9c2eec271 100644
5534 +--- a/drivers/media/usb/uvc/uvc_entity.c
5535 ++++ b/drivers/media/usb/uvc/uvc_entity.c
5536 +@@ -73,10 +73,45 @@ static int uvc_mc_init_entity(struct uvc_video_chain *chain,
5537 + int ret;
5538 +
5539 + if (UVC_ENTITY_TYPE(entity) != UVC_TT_STREAMING) {
5540 ++ u32 function;
5541 ++
5542 + v4l2_subdev_init(&entity->subdev, &uvc_subdev_ops);
5543 + strscpy(entity->subdev.name, entity->name,
5544 + sizeof(entity->subdev.name));
5545 +
5546 ++ switch (UVC_ENTITY_TYPE(entity)) {
5547 ++ case UVC_VC_SELECTOR_UNIT:
5548 ++ function = MEDIA_ENT_F_VID_MUX;
5549 ++ break;
5550 ++ case UVC_VC_PROCESSING_UNIT:
5551 ++ case UVC_VC_EXTENSION_UNIT:
5552 ++ /* For lack of a better option. */
5553 ++ function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER;
5554 ++ break;
5555 ++ case UVC_COMPOSITE_CONNECTOR:
5556 ++ case UVC_COMPONENT_CONNECTOR:
5557 ++ function = MEDIA_ENT_F_CONN_COMPOSITE;
5558 ++ break;
5559 ++ case UVC_SVIDEO_CONNECTOR:
5560 ++ function = MEDIA_ENT_F_CONN_SVIDEO;
5561 ++ break;
5562 ++ case UVC_ITT_CAMERA:
5563 ++ function = MEDIA_ENT_F_CAM_SENSOR;
5564 ++ break;
5565 ++ case UVC_TT_VENDOR_SPECIFIC:
5566 ++ case UVC_ITT_VENDOR_SPECIFIC:
5567 ++ case UVC_ITT_MEDIA_TRANSPORT_INPUT:
5568 ++ case UVC_OTT_VENDOR_SPECIFIC:
5569 ++ case UVC_OTT_DISPLAY:
5570 ++ case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
5571 ++ case UVC_EXTERNAL_VENDOR_SPECIFIC:
5572 ++ default:
5573 ++ function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
5574 ++ break;
5575 ++ }
5576 ++
5577 ++ entity->subdev.entity.function = function;
5578 ++
5579 + ret = media_entity_pads_init(&entity->subdev.entity,
5580 + entity->num_pads, entity->pads);
5581 +
5582 +diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
5583 +index 0335e69b70abe..5e6f3153b5ff8 100644
5584 +--- a/drivers/media/usb/uvc/uvc_v4l2.c
5585 ++++ b/drivers/media/usb/uvc/uvc_v4l2.c
5586 +@@ -247,11 +247,41 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
5587 + if (ret < 0)
5588 + goto done;
5589 +
5590 ++ /* After the probe, update fmt with the values returned from
5591 ++ * negotiation with the device.
5592 ++ */
5593 ++ for (i = 0; i < stream->nformats; ++i) {
5594 ++ if (probe->bFormatIndex == stream->format[i].index) {
5595 ++ format = &stream->format[i];
5596 ++ break;
5597 ++ }
5598 ++ }
5599 ++
5600 ++ if (i == stream->nformats) {
5601 ++ uvc_trace(UVC_TRACE_FORMAT, "Unknown bFormatIndex %u\n",
5602 ++ probe->bFormatIndex);
5603 ++ return -EINVAL;
5604 ++ }
5605 ++
5606 ++ for (i = 0; i < format->nframes; ++i) {
5607 ++ if (probe->bFrameIndex == format->frame[i].bFrameIndex) {
5608 ++ frame = &format->frame[i];
5609 ++ break;
5610 ++ }
5611 ++ }
5612 ++
5613 ++ if (i == format->nframes) {
5614 ++ uvc_trace(UVC_TRACE_FORMAT, "Unknown bFrameIndex %u\n",
5615 ++ probe->bFrameIndex);
5616 ++ return -EINVAL;
5617 ++ }
5618 ++
5619 + fmt->fmt.pix.width = frame->wWidth;
5620 + fmt->fmt.pix.height = frame->wHeight;
5621 + fmt->fmt.pix.field = V4L2_FIELD_NONE;
5622 + fmt->fmt.pix.bytesperline = uvc_v4l2_get_bytesperline(format, frame);
5623 + fmt->fmt.pix.sizeimage = probe->dwMaxVideoFrameSize;
5624 ++ fmt->fmt.pix.pixelformat = format->fcc;
5625 + fmt->fmt.pix.colorspace = format->colorspace;
5626 +
5627 + if (uvc_format != NULL)
5628 +diff --git a/drivers/memory/fsl-corenet-cf.c b/drivers/memory/fsl-corenet-cf.c
5629 +index 0b0ed72016da8..0309bd5a18008 100644
5630 +--- a/drivers/memory/fsl-corenet-cf.c
5631 ++++ b/drivers/memory/fsl-corenet-cf.c
5632 +@@ -211,10 +211,8 @@ static int ccf_probe(struct platform_device *pdev)
5633 + dev_set_drvdata(&pdev->dev, ccf);
5634 +
5635 + irq = platform_get_irq(pdev, 0);
5636 +- if (!irq) {
5637 +- dev_err(&pdev->dev, "%s: no irq\n", __func__);
5638 +- return -ENXIO;
5639 +- }
5640 ++ if (irq < 0)
5641 ++ return irq;
5642 +
5643 + ret = devm_request_irq(&pdev->dev, irq, ccf_irq, 0, pdev->name, ccf);
5644 + if (ret) {
5645 +diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
5646 +index eff26c1b13940..27bc417029e11 100644
5647 +--- a/drivers/memory/omap-gpmc.c
5648 ++++ b/drivers/memory/omap-gpmc.c
5649 +@@ -949,7 +949,7 @@ static int gpmc_cs_remap(int cs, u32 base)
5650 + int ret;
5651 + u32 old_base, size;
5652 +
5653 +- if (cs > gpmc_cs_num) {
5654 ++ if (cs >= gpmc_cs_num) {
5655 + pr_err("%s: requested chip-select is disabled\n", __func__);
5656 + return -ENODEV;
5657 + }
5658 +@@ -984,7 +984,7 @@ int gpmc_cs_request(int cs, unsigned long size, unsigned long *base)
5659 + struct resource *res = &gpmc->mem;
5660 + int r = -1;
5661 +
5662 +- if (cs > gpmc_cs_num) {
5663 ++ if (cs >= gpmc_cs_num) {
5664 + pr_err("%s: requested chip-select is disabled\n", __func__);
5665 + return -ENODEV;
5666 + }
5667 +@@ -2274,6 +2274,10 @@ static void gpmc_probe_dt_children(struct platform_device *pdev)
5668 + }
5669 + }
5670 + #else
5671 ++void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p)
5672 ++{
5673 ++ memset(p, 0, sizeof(*p));
5674 ++}
5675 + static int gpmc_probe_dt(struct platform_device *pdev)
5676 + {
5677 + return 0;
5678 +diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
5679 +index 154270f8d8d78..bbcde58e2a11e 100644
5680 +--- a/drivers/mfd/sm501.c
5681 ++++ b/drivers/mfd/sm501.c
5682 +@@ -1424,8 +1424,14 @@ static int sm501_plat_probe(struct platform_device *dev)
5683 + goto err_claim;
5684 + }
5685 +
5686 +- return sm501_init_dev(sm);
5687 ++ ret = sm501_init_dev(sm);
5688 ++ if (ret)
5689 ++ goto err_unmap;
5690 ++
5691 ++ return 0;
5692 +
5693 ++ err_unmap:
5694 ++ iounmap(sm->regs);
5695 + err_claim:
5696 + release_resource(sm->regs_claim);
5697 + kfree(sm->regs_claim);
5698 +diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c
5699 +index 1958833b3b74e..4fd57052ddd3d 100644
5700 +--- a/drivers/misc/cardreader/rtsx_pcr.c
5701 ++++ b/drivers/misc/cardreader/rtsx_pcr.c
5702 +@@ -1534,12 +1534,14 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
5703 + ret = mfd_add_devices(&pcidev->dev, pcr->id, rtsx_pcr_cells,
5704 + ARRAY_SIZE(rtsx_pcr_cells), NULL, 0, NULL);
5705 + if (ret < 0)
5706 +- goto disable_irq;
5707 ++ goto free_slots;
5708 +
5709 + schedule_delayed_work(&pcr->idle_work, msecs_to_jiffies(200));
5710 +
5711 + return 0;
5712 +
5713 ++free_slots:
5714 ++ kfree(pcr->slots);
5715 + disable_irq:
5716 + free_irq(pcr->irq, (void *)pcr);
5717 + disable_msi:
5718 +diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
5719 +index cde9a2fc13250..490ff49d11ede 100644
5720 +--- a/drivers/misc/eeprom/at25.c
5721 ++++ b/drivers/misc/eeprom/at25.c
5722 +@@ -358,7 +358,7 @@ static int at25_probe(struct spi_device *spi)
5723 + at25->nvmem_config.reg_read = at25_ee_read;
5724 + at25->nvmem_config.reg_write = at25_ee_write;
5725 + at25->nvmem_config.priv = at25;
5726 +- at25->nvmem_config.stride = 4;
5727 ++ at25->nvmem_config.stride = 1;
5728 + at25->nvmem_config.word_size = 1;
5729 + at25->nvmem_config.size = chip.byte_len;
5730 +
5731 +diff --git a/drivers/misc/mic/scif/scif_rma.c b/drivers/misc/mic/scif/scif_rma.c
5732 +index 01e27682ea303..a486c6c7f4077 100644
5733 +--- a/drivers/misc/mic/scif/scif_rma.c
5734 ++++ b/drivers/misc/mic/scif/scif_rma.c
5735 +@@ -1381,6 +1381,8 @@ retry:
5736 + (prot & SCIF_PROT_WRITE) ? FOLL_WRITE : 0,
5737 + pinned_pages->pages);
5738 + if (nr_pages != pinned_pages->nr_pages) {
5739 ++ if (pinned_pages->nr_pages < 0)
5740 ++ pinned_pages->nr_pages = 0;
5741 + if (try_upgrade) {
5742 + if (ulimit)
5743 + __scif_dec_pinned_vm_lock(mm, nr_pages);
5744 +@@ -1400,7 +1402,6 @@ retry:
5745 +
5746 + if (pinned_pages->nr_pages < nr_pages) {
5747 + err = -EFAULT;
5748 +- pinned_pages->nr_pages = nr_pages;
5749 + goto dec_pinned;
5750 + }
5751 +
5752 +@@ -1413,7 +1414,6 @@ dec_pinned:
5753 + __scif_dec_pinned_vm_lock(mm, nr_pages);
5754 + /* Something went wrong! Rollback */
5755 + error_unmap:
5756 +- pinned_pages->nr_pages = nr_pages;
5757 + scif_destroy_pinned_pages(pinned_pages);
5758 + *pages = NULL;
5759 + dev_dbg(scif_info.mdev.this_device,
5760 +diff --git a/drivers/misc/mic/vop/vop_main.c b/drivers/misc/mic/vop/vop_main.c
5761 +index 85942f6717c57..8aadc6055df17 100644
5762 +--- a/drivers/misc/mic/vop/vop_main.c
5763 ++++ b/drivers/misc/mic/vop/vop_main.c
5764 +@@ -320,7 +320,7 @@ static struct virtqueue *vop_find_vq(struct virtio_device *dev,
5765 + /* First assign the vring's allocated in host memory */
5766 + vqconfig = _vop_vq_config(vdev->desc) + index;
5767 + memcpy_fromio(&config, vqconfig, sizeof(config));
5768 +- _vr_size = vring_size(le16_to_cpu(config.num), MIC_VIRTIO_RING_ALIGN);
5769 ++ _vr_size = round_up(vring_size(le16_to_cpu(config.num), MIC_VIRTIO_RING_ALIGN), 4);
5770 + vr_size = PAGE_ALIGN(_vr_size + sizeof(struct _mic_vring_info));
5771 + va = vpdev->hw_ops->remap(vpdev, le64_to_cpu(config.address), vr_size);
5772 + if (!va)
5773 +diff --git a/drivers/misc/mic/vop/vop_vringh.c b/drivers/misc/mic/vop/vop_vringh.c
5774 +index 30eac172f0170..7014ffe88632e 100644
5775 +--- a/drivers/misc/mic/vop/vop_vringh.c
5776 ++++ b/drivers/misc/mic/vop/vop_vringh.c
5777 +@@ -296,7 +296,7 @@ static int vop_virtio_add_device(struct vop_vdev *vdev,
5778 +
5779 + num = le16_to_cpu(vqconfig[i].num);
5780 + mutex_init(&vvr->vr_mutex);
5781 +- vr_size = PAGE_ALIGN(vring_size(num, MIC_VIRTIO_RING_ALIGN) +
5782 ++ vr_size = PAGE_ALIGN(round_up(vring_size(num, MIC_VIRTIO_RING_ALIGN), 4) +
5783 + sizeof(struct _mic_vring_info));
5784 + vr->va = (void *)
5785 + __get_free_pages(GFP_KERNEL | __GFP_ZERO,
5786 +@@ -308,7 +308,7 @@ static int vop_virtio_add_device(struct vop_vdev *vdev,
5787 + goto err;
5788 + }
5789 + vr->len = vr_size;
5790 +- vr->info = vr->va + vring_size(num, MIC_VIRTIO_RING_ALIGN);
5791 ++ vr->info = vr->va + round_up(vring_size(num, MIC_VIRTIO_RING_ALIGN), 4);
5792 + vr->info->magic = cpu_to_le32(MIC_MAGIC + vdev->virtio_id + i);
5793 + vr_addr = dma_map_single(&vpdev->dev, vr->va, vr_size,
5794 + DMA_BIDIRECTIONAL);
5795 +@@ -602,6 +602,7 @@ static int vop_virtio_copy_from_user(struct vop_vdev *vdev, void __user *ubuf,
5796 + size_t partlen;
5797 + bool dma = VOP_USE_DMA && vi->dma_ch;
5798 + int err = 0;
5799 ++ size_t offset = 0;
5800 +
5801 + if (dma) {
5802 + dma_alignment = 1 << vi->dma_ch->device->copy_align;
5803 +@@ -655,13 +656,20 @@ memcpy:
5804 + * We are copying to IO below and should ideally use something
5805 + * like copy_from_user_toio(..) if it existed.
5806 + */
5807 +- if (copy_from_user((void __force *)dbuf, ubuf, len)) {
5808 +- err = -EFAULT;
5809 +- dev_err(vop_dev(vdev), "%s %d err %d\n",
5810 +- __func__, __LINE__, err);
5811 +- goto err;
5812 ++ while (len) {
5813 ++ partlen = min_t(size_t, len, VOP_INT_DMA_BUF_SIZE);
5814 ++
5815 ++ if (copy_from_user(vvr->buf, ubuf + offset, partlen)) {
5816 ++ err = -EFAULT;
5817 ++ dev_err(vop_dev(vdev), "%s %d err %d\n",
5818 ++ __func__, __LINE__, err);
5819 ++ goto err;
5820 ++ }
5821 ++ memcpy_toio(dbuf + offset, vvr->buf, partlen);
5822 ++ offset += partlen;
5823 ++ vdev->out_bytes += partlen;
5824 ++ len -= partlen;
5825 + }
5826 +- vdev->out_bytes += len;
5827 + err = 0;
5828 + err:
5829 + vpdev->hw_ops->unmap(vpdev, dbuf);
5830 +diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
5831 +index 8531ae7811956..c49065887e8f5 100644
5832 +--- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
5833 ++++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
5834 +@@ -657,8 +657,9 @@ static int qp_host_get_user_memory(u64 produce_uva,
5835 + if (retval < (int)produce_q->kernel_if->num_pages) {
5836 + pr_debug("get_user_pages_fast(produce) failed (retval=%d)",
5837 + retval);
5838 +- qp_release_pages(produce_q->kernel_if->u.h.header_page,
5839 +- retval, false);
5840 ++ if (retval > 0)
5841 ++ qp_release_pages(produce_q->kernel_if->u.h.header_page,
5842 ++ retval, false);
5843 + err = VMCI_ERROR_NO_MEM;
5844 + goto out;
5845 + }
5846 +@@ -670,8 +671,9 @@ static int qp_host_get_user_memory(u64 produce_uva,
5847 + if (retval < (int)consume_q->kernel_if->num_pages) {
5848 + pr_debug("get_user_pages_fast(consume) failed (retval=%d)",
5849 + retval);
5850 +- qp_release_pages(consume_q->kernel_if->u.h.header_page,
5851 +- retval, false);
5852 ++ if (retval > 0)
5853 ++ qp_release_pages(consume_q->kernel_if->u.h.header_page,
5854 ++ retval, false);
5855 + qp_release_pages(produce_q->kernel_if->u.h.header_page,
5856 + produce_q->kernel_if->num_pages, false);
5857 + err = VMCI_ERROR_NO_MEM;
5858 +diff --git a/drivers/mmc/core/sdio_cis.c b/drivers/mmc/core/sdio_cis.c
5859 +index e0655278c5c32..3efaa9534a777 100644
5860 +--- a/drivers/mmc/core/sdio_cis.c
5861 ++++ b/drivers/mmc/core/sdio_cis.c
5862 +@@ -26,6 +26,9 @@ static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func,
5863 + unsigned i, nr_strings;
5864 + char **buffer, *string;
5865 +
5866 ++ if (size < 2)
5867 ++ return 0;
5868 ++
5869 + /* Find all null-terminated (including zero length) strings in
5870 + the TPLLV1_INFO field. Trailing garbage is ignored. */
5871 + buf += 2;
5872 +diff --git a/drivers/mtd/lpddr/lpddr2_nvm.c b/drivers/mtd/lpddr/lpddr2_nvm.c
5873 +index 0f1547f09d08b..72f5c7b300790 100644
5874 +--- a/drivers/mtd/lpddr/lpddr2_nvm.c
5875 ++++ b/drivers/mtd/lpddr/lpddr2_nvm.c
5876 +@@ -393,6 +393,17 @@ static int lpddr2_nvm_lock(struct mtd_info *mtd, loff_t start_add,
5877 + return lpddr2_nvm_do_block_op(mtd, start_add, len, LPDDR2_NVM_LOCK);
5878 + }
5879 +
5880 ++static const struct mtd_info lpddr2_nvm_mtd_info = {
5881 ++ .type = MTD_RAM,
5882 ++ .writesize = 1,
5883 ++ .flags = (MTD_CAP_NVRAM | MTD_POWERUP_LOCK),
5884 ++ ._read = lpddr2_nvm_read,
5885 ++ ._write = lpddr2_nvm_write,
5886 ++ ._erase = lpddr2_nvm_erase,
5887 ++ ._unlock = lpddr2_nvm_unlock,
5888 ++ ._lock = lpddr2_nvm_lock,
5889 ++};
5890 ++
5891 + /*
5892 + * lpddr2_nvm driver probe method
5893 + */
5894 +@@ -433,6 +444,7 @@ static int lpddr2_nvm_probe(struct platform_device *pdev)
5895 + .pfow_base = OW_BASE_ADDRESS,
5896 + .fldrv_priv = pcm_data,
5897 + };
5898 ++
5899 + if (IS_ERR(map->virt))
5900 + return PTR_ERR(map->virt);
5901 +
5902 +@@ -444,22 +456,13 @@ static int lpddr2_nvm_probe(struct platform_device *pdev)
5903 + return PTR_ERR(pcm_data->ctl_regs);
5904 +
5905 + /* Populate mtd_info data structure */
5906 +- *mtd = (struct mtd_info) {
5907 +- .dev = { .parent = &pdev->dev },
5908 +- .name = pdev->dev.init_name,
5909 +- .type = MTD_RAM,
5910 +- .priv = map,
5911 +- .size = resource_size(add_range),
5912 +- .erasesize = ERASE_BLOCKSIZE * pcm_data->bus_width,
5913 +- .writesize = 1,
5914 +- .writebufsize = WRITE_BUFFSIZE * pcm_data->bus_width,
5915 +- .flags = (MTD_CAP_NVRAM | MTD_POWERUP_LOCK),
5916 +- ._read = lpddr2_nvm_read,
5917 +- ._write = lpddr2_nvm_write,
5918 +- ._erase = lpddr2_nvm_erase,
5919 +- ._unlock = lpddr2_nvm_unlock,
5920 +- ._lock = lpddr2_nvm_lock,
5921 +- };
5922 ++ *mtd = lpddr2_nvm_mtd_info;
5923 ++ mtd->dev.parent = &pdev->dev;
5924 ++ mtd->name = pdev->dev.init_name;
5925 ++ mtd->priv = map;
5926 ++ mtd->size = resource_size(add_range);
5927 ++ mtd->erasesize = ERASE_BLOCKSIZE * pcm_data->bus_width;
5928 ++ mtd->writebufsize = WRITE_BUFFSIZE * pcm_data->bus_width;
5929 +
5930 + /* Verify the presence of the device looking for PFOW string */
5931 + if (!lpddr2_nvm_pfow_present(map)) {
5932 +diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
5933 +index 4ced68be7ed7e..774970bfcf859 100644
5934 +--- a/drivers/mtd/mtdoops.c
5935 ++++ b/drivers/mtd/mtdoops.c
5936 +@@ -279,12 +279,13 @@ static void mtdoops_do_dump(struct kmsg_dumper *dumper,
5937 + kmsg_dump_get_buffer(dumper, true, cxt->oops_buf + MTDOOPS_HEADER_SIZE,
5938 + record_size - MTDOOPS_HEADER_SIZE, NULL);
5939 +
5940 +- /* Panics must be written immediately */
5941 +- if (reason != KMSG_DUMP_OOPS)
5942 ++ if (reason != KMSG_DUMP_OOPS) {
5943 ++ /* Panics must be written immediately */
5944 + mtdoops_write(cxt, 1);
5945 +-
5946 +- /* For other cases, schedule work to write it "nicely" */
5947 +- schedule_work(&cxt->work_write);
5948 ++ } else {
5949 ++ /* For other cases, schedule work to write it "nicely" */
5950 ++ schedule_work(&cxt->work_write);
5951 ++ }
5952 + }
5953 +
5954 + static void mtdoops_notify_add(struct mtd_info *mtd)
5955 +diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c
5956 +index 6b399a75f9aec..b6f114da57143 100644
5957 +--- a/drivers/mtd/nand/raw/vf610_nfc.c
5958 ++++ b/drivers/mtd/nand/raw/vf610_nfc.c
5959 +@@ -850,8 +850,10 @@ static int vf610_nfc_probe(struct platform_device *pdev)
5960 + }
5961 +
5962 + of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev);
5963 +- if (!of_id)
5964 +- return -ENODEV;
5965 ++ if (!of_id) {
5966 ++ err = -ENODEV;
5967 ++ goto err_disable_clk;
5968 ++ }
5969 +
5970 + nfc->variant = (enum vf610_nfc_variant)of_id->data;
5971 +
5972 +diff --git a/drivers/mtd/nand/spi/gigadevice.c b/drivers/mtd/nand/spi/gigadevice.c
5973 +index e99d425aa93f5..b13b39763a405 100644
5974 +--- a/drivers/mtd/nand/spi/gigadevice.c
5975 ++++ b/drivers/mtd/nand/spi/gigadevice.c
5976 +@@ -21,7 +21,7 @@
5977 + #define GD5FXGQ4UXFXXG_STATUS_ECC_UNCOR_ERROR (7 << 4)
5978 +
5979 + static SPINAND_OP_VARIANTS(read_cache_variants,
5980 +- SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
5981 ++ SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 1, NULL, 0),
5982 + SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
5983 + SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
5984 + SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
5985 +@@ -29,7 +29,7 @@ static SPINAND_OP_VARIANTS(read_cache_variants,
5986 + SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
5987 +
5988 + static SPINAND_OP_VARIANTS(read_cache_variants_f,
5989 +- SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
5990 ++ SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 1, NULL, 0),
5991 + SPINAND_PAGE_READ_FROM_CACHE_X4_OP_3A(0, 1, NULL, 0),
5992 + SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
5993 + SPINAND_PAGE_READ_FROM_CACHE_X2_OP_3A(0, 1, NULL, 0),
5994 +@@ -201,7 +201,7 @@ static const struct spinand_info gigadevice_spinand_table[] = {
5995 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
5996 + &write_cache_variants,
5997 + &update_cache_variants),
5998 +- 0,
5999 ++ SPINAND_HAS_QE_BIT,
6000 + SPINAND_ECCINFO(&gd5fxgq4xa_ooblayout,
6001 + gd5fxgq4xa_ecc_get_status)),
6002 + SPINAND_INFO("GD5F2GQ4xA", 0xF2,
6003 +@@ -210,7 +210,7 @@ static const struct spinand_info gigadevice_spinand_table[] = {
6004 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
6005 + &write_cache_variants,
6006 + &update_cache_variants),
6007 +- 0,
6008 ++ SPINAND_HAS_QE_BIT,
6009 + SPINAND_ECCINFO(&gd5fxgq4xa_ooblayout,
6010 + gd5fxgq4xa_ecc_get_status)),
6011 + SPINAND_INFO("GD5F4GQ4xA", 0xF4,
6012 +@@ -219,7 +219,7 @@ static const struct spinand_info gigadevice_spinand_table[] = {
6013 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
6014 + &write_cache_variants,
6015 + &update_cache_variants),
6016 +- 0,
6017 ++ SPINAND_HAS_QE_BIT,
6018 + SPINAND_ECCINFO(&gd5fxgq4xa_ooblayout,
6019 + gd5fxgq4xa_ecc_get_status)),
6020 + SPINAND_INFO("GD5F1GQ4UExxG", 0xd1,
6021 +@@ -228,7 +228,7 @@ static const struct spinand_info gigadevice_spinand_table[] = {
6022 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
6023 + &write_cache_variants,
6024 + &update_cache_variants),
6025 +- 0,
6026 ++ SPINAND_HAS_QE_BIT,
6027 + SPINAND_ECCINFO(&gd5fxgq4_variant2_ooblayout,
6028 + gd5fxgq4uexxg_ecc_get_status)),
6029 + SPINAND_INFO("GD5F1GQ4UFxxG", 0xb148,
6030 +@@ -237,7 +237,7 @@ static const struct spinand_info gigadevice_spinand_table[] = {
6031 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants_f,
6032 + &write_cache_variants,
6033 + &update_cache_variants),
6034 +- 0,
6035 ++ SPINAND_HAS_QE_BIT,
6036 + SPINAND_ECCINFO(&gd5fxgq4_variant2_ooblayout,
6037 + gd5fxgq4ufxxg_ecc_get_status)),
6038 + };
6039 +diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
6040 +index e5c207ad3c77d..aaa7ed1dc97ee 100644
6041 +--- a/drivers/net/can/flexcan.c
6042 ++++ b/drivers/net/can/flexcan.c
6043 +@@ -1232,18 +1232,23 @@ static int flexcan_chip_start(struct net_device *dev)
6044 + return err;
6045 + }
6046 +
6047 +-/* flexcan_chip_stop
6048 ++/* __flexcan_chip_stop
6049 + *
6050 +- * this functions is entered with clocks enabled
6051 ++ * this function is entered with clocks enabled
6052 + */
6053 +-static void flexcan_chip_stop(struct net_device *dev)
6054 ++static int __flexcan_chip_stop(struct net_device *dev, bool disable_on_error)
6055 + {
6056 + struct flexcan_priv *priv = netdev_priv(dev);
6057 + struct flexcan_regs __iomem *regs = priv->regs;
6058 ++ int err;
6059 +
6060 + /* freeze + disable module */
6061 +- flexcan_chip_freeze(priv);
6062 +- flexcan_chip_disable(priv);
6063 ++ err = flexcan_chip_freeze(priv);
6064 ++ if (err && !disable_on_error)
6065 ++ return err;
6066 ++ err = flexcan_chip_disable(priv);
6067 ++ if (err && !disable_on_error)
6068 ++ goto out_chip_unfreeze;
6069 +
6070 + /* Disable all interrupts */
6071 + priv->write(0, &regs->imask2);
6072 +@@ -1253,6 +1258,23 @@ static void flexcan_chip_stop(struct net_device *dev)
6073 +
6074 + flexcan_transceiver_disable(priv);
6075 + priv->can.state = CAN_STATE_STOPPED;
6076 ++
6077 ++ return 0;
6078 ++
6079 ++ out_chip_unfreeze:
6080 ++ flexcan_chip_unfreeze(priv);
6081 ++
6082 ++ return err;
6083 ++}
6084 ++
6085 ++static inline int flexcan_chip_stop_disable_on_error(struct net_device *dev)
6086 ++{
6087 ++ return __flexcan_chip_stop(dev, true);
6088 ++}
6089 ++
6090 ++static inline int flexcan_chip_stop(struct net_device *dev)
6091 ++{
6092 ++ return __flexcan_chip_stop(dev, false);
6093 + }
6094 +
6095 + static int flexcan_open(struct net_device *dev)
6096 +@@ -1341,7 +1363,7 @@ static int flexcan_close(struct net_device *dev)
6097 +
6098 + netif_stop_queue(dev);
6099 + can_rx_offload_disable(&priv->offload);
6100 +- flexcan_chip_stop(dev);
6101 ++ flexcan_chip_stop_disable_on_error(dev);
6102 +
6103 + can_rx_offload_del(&priv->offload);
6104 + free_irq(dev->irq, dev);
6105 +diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
6106 +index 38ea5e600fb84..e6d0cb9ee02f0 100644
6107 +--- a/drivers/net/can/m_can/m_can_platform.c
6108 ++++ b/drivers/net/can/m_can/m_can_platform.c
6109 +@@ -144,8 +144,6 @@ static int __maybe_unused m_can_runtime_suspend(struct device *dev)
6110 + struct net_device *ndev = dev_get_drvdata(dev);
6111 + struct m_can_classdev *mcan_class = netdev_priv(ndev);
6112 +
6113 +- m_can_class_suspend(dev);
6114 +-
6115 + clk_disable_unprepare(mcan_class->cclk);
6116 + clk_disable_unprepare(mcan_class->hclk);
6117 +
6118 +diff --git a/drivers/net/dsa/realtek-smi-core.h b/drivers/net/dsa/realtek-smi-core.h
6119 +index 9a63b51e1d82f..6f2dab7e33d65 100644
6120 +--- a/drivers/net/dsa/realtek-smi-core.h
6121 ++++ b/drivers/net/dsa/realtek-smi-core.h
6122 +@@ -25,6 +25,9 @@ struct rtl8366_mib_counter {
6123 + const char *name;
6124 + };
6125 +
6126 ++/**
6127 ++ * struct rtl8366_vlan_mc - Virtual LAN member configuration
6128 ++ */
6129 + struct rtl8366_vlan_mc {
6130 + u16 vid;
6131 + u16 untag;
6132 +@@ -119,7 +122,6 @@ int realtek_smi_setup_mdio(struct realtek_smi *smi);
6133 + int rtl8366_mc_is_used(struct realtek_smi *smi, int mc_index, int *used);
6134 + int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member,
6135 + u32 untag, u32 fid);
6136 +-int rtl8366_get_pvid(struct realtek_smi *smi, int port, int *val);
6137 + int rtl8366_set_pvid(struct realtek_smi *smi, unsigned int port,
6138 + unsigned int vid);
6139 + int rtl8366_enable_vlan4k(struct realtek_smi *smi, bool enable);
6140 +diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c
6141 +index 99cdb2f18fa2f..49c626a336803 100644
6142 +--- a/drivers/net/dsa/rtl8366.c
6143 ++++ b/drivers/net/dsa/rtl8366.c
6144 +@@ -36,12 +36,113 @@ int rtl8366_mc_is_used(struct realtek_smi *smi, int mc_index, int *used)
6145 + }
6146 + EXPORT_SYMBOL_GPL(rtl8366_mc_is_used);
6147 +
6148 ++/**
6149 ++ * rtl8366_obtain_mc() - retrieve or allocate a VLAN member configuration
6150 ++ * @smi: the Realtek SMI device instance
6151 ++ * @vid: the VLAN ID to look up or allocate
6152 ++ * @vlanmc: the pointer will be assigned to a pointer to a valid member config
6153 ++ * if successful
6154 ++ * @return: index of a new member config or negative error number
6155 ++ */
6156 ++static int rtl8366_obtain_mc(struct realtek_smi *smi, int vid,
6157 ++ struct rtl8366_vlan_mc *vlanmc)
6158 ++{
6159 ++ struct rtl8366_vlan_4k vlan4k;
6160 ++ int ret;
6161 ++ int i;
6162 ++
6163 ++ /* Try to find an existing member config entry for this VID */
6164 ++ for (i = 0; i < smi->num_vlan_mc; i++) {
6165 ++ ret = smi->ops->get_vlan_mc(smi, i, vlanmc);
6166 ++ if (ret) {
6167 ++ dev_err(smi->dev, "error searching for VLAN MC %d for VID %d\n",
6168 ++ i, vid);
6169 ++ return ret;
6170 ++ }
6171 ++
6172 ++ if (vid == vlanmc->vid)
6173 ++ return i;
6174 ++ }
6175 ++
6176 ++ /* We have no MC entry for this VID, try to find an empty one */
6177 ++ for (i = 0; i < smi->num_vlan_mc; i++) {
6178 ++ ret = smi->ops->get_vlan_mc(smi, i, vlanmc);
6179 ++ if (ret) {
6180 ++ dev_err(smi->dev, "error searching for VLAN MC %d for VID %d\n",
6181 ++ i, vid);
6182 ++ return ret;
6183 ++ }
6184 ++
6185 ++ if (vlanmc->vid == 0 && vlanmc->member == 0) {
6186 ++ /* Update the entry from the 4K table */
6187 ++ ret = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
6188 ++ if (ret) {
6189 ++ dev_err(smi->dev, "error looking for 4K VLAN MC %d for VID %d\n",
6190 ++ i, vid);
6191 ++ return ret;
6192 ++ }
6193 ++
6194 ++ vlanmc->vid = vid;
6195 ++ vlanmc->member = vlan4k.member;
6196 ++ vlanmc->untag = vlan4k.untag;
6197 ++ vlanmc->fid = vlan4k.fid;
6198 ++ ret = smi->ops->set_vlan_mc(smi, i, vlanmc);
6199 ++ if (ret) {
6200 ++ dev_err(smi->dev, "unable to set/update VLAN MC %d for VID %d\n",
6201 ++ i, vid);
6202 ++ return ret;
6203 ++ }
6204 ++
6205 ++ dev_dbg(smi->dev, "created new MC at index %d for VID %d\n",
6206 ++ i, vid);
6207 ++ return i;
6208 ++ }
6209 ++ }
6210 ++
6211 ++ /* MC table is full, try to find an unused entry and replace it */
6212 ++ for (i = 0; i < smi->num_vlan_mc; i++) {
6213 ++ int used;
6214 ++
6215 ++ ret = rtl8366_mc_is_used(smi, i, &used);
6216 ++ if (ret)
6217 ++ return ret;
6218 ++
6219 ++ if (!used) {
6220 ++ /* Update the entry from the 4K table */
6221 ++ ret = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
6222 ++ if (ret)
6223 ++ return ret;
6224 ++
6225 ++ vlanmc->vid = vid;
6226 ++ vlanmc->member = vlan4k.member;
6227 ++ vlanmc->untag = vlan4k.untag;
6228 ++ vlanmc->fid = vlan4k.fid;
6229 ++ ret = smi->ops->set_vlan_mc(smi, i, vlanmc);
6230 ++ if (ret) {
6231 ++ dev_err(smi->dev, "unable to set/update VLAN MC %d for VID %d\n",
6232 ++ i, vid);
6233 ++ return ret;
6234 ++ }
6235 ++ dev_dbg(smi->dev, "recycled MC at index %i for VID %d\n",
6236 ++ i, vid);
6237 ++ return i;
6238 ++ }
6239 ++ }
6240 ++
6241 ++ dev_err(smi->dev, "all VLAN member configurations are in use\n");
6242 ++ return -ENOSPC;
6243 ++}
6244 ++
6245 + int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member,
6246 + u32 untag, u32 fid)
6247 + {
6248 ++ struct rtl8366_vlan_mc vlanmc;
6249 + struct rtl8366_vlan_4k vlan4k;
6250 ++ int mc;
6251 + int ret;
6252 +- int i;
6253 ++
6254 ++ if (!smi->ops->is_vlan_valid(smi, vid))
6255 ++ return -EINVAL;
6256 +
6257 + dev_dbg(smi->dev,
6258 + "setting VLAN%d 4k members: 0x%02x, untagged: 0x%02x\n",
6259 +@@ -63,133 +164,58 @@ int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member,
6260 + "resulting VLAN%d 4k members: 0x%02x, untagged: 0x%02x\n",
6261 + vid, vlan4k.member, vlan4k.untag);
6262 +
6263 +- /* Try to find an existing MC entry for this VID */
6264 +- for (i = 0; i < smi->num_vlan_mc; i++) {
6265 +- struct rtl8366_vlan_mc vlanmc;
6266 +-
6267 +- ret = smi->ops->get_vlan_mc(smi, i, &vlanmc);
6268 +- if (ret)
6269 +- return ret;
6270 +-
6271 +- if (vid == vlanmc.vid) {
6272 +- /* update the MC entry */
6273 +- vlanmc.member |= member;
6274 +- vlanmc.untag |= untag;
6275 +- vlanmc.fid = fid;
6276 +-
6277 +- ret = smi->ops->set_vlan_mc(smi, i, &vlanmc);
6278 ++ /* Find or allocate a member config for this VID */
6279 ++ ret = rtl8366_obtain_mc(smi, vid, &vlanmc);
6280 ++ if (ret < 0)
6281 ++ return ret;
6282 ++ mc = ret;
6283 +
6284 +- dev_dbg(smi->dev,
6285 +- "resulting VLAN%d MC members: 0x%02x, untagged: 0x%02x\n",
6286 +- vid, vlanmc.member, vlanmc.untag);
6287 ++ /* Update the MC entry */
6288 ++ vlanmc.member |= member;
6289 ++ vlanmc.untag |= untag;
6290 ++ vlanmc.fid = fid;
6291 +
6292 +- break;
6293 +- }
6294 +- }
6295 ++ /* Commit updates to the MC entry */
6296 ++ ret = smi->ops->set_vlan_mc(smi, mc, &vlanmc);
6297 ++ if (ret)
6298 ++ dev_err(smi->dev, "failed to commit changes to VLAN MC index %d for VID %d\n",
6299 ++ mc, vid);
6300 ++ else
6301 ++ dev_dbg(smi->dev,
6302 ++ "resulting VLAN%d MC members: 0x%02x, untagged: 0x%02x\n",
6303 ++ vid, vlanmc.member, vlanmc.untag);
6304 +
6305 + return ret;
6306 + }
6307 + EXPORT_SYMBOL_GPL(rtl8366_set_vlan);
6308 +
6309 +-int rtl8366_get_pvid(struct realtek_smi *smi, int port, int *val)
6310 +-{
6311 +- struct rtl8366_vlan_mc vlanmc;
6312 +- int ret;
6313 +- int index;
6314 +-
6315 +- ret = smi->ops->get_mc_index(smi, port, &index);
6316 +- if (ret)
6317 +- return ret;
6318 +-
6319 +- ret = smi->ops->get_vlan_mc(smi, index, &vlanmc);
6320 +- if (ret)
6321 +- return ret;
6322 +-
6323 +- *val = vlanmc.vid;
6324 +- return 0;
6325 +-}
6326 +-EXPORT_SYMBOL_GPL(rtl8366_get_pvid);
6327 +-
6328 + int rtl8366_set_pvid(struct realtek_smi *smi, unsigned int port,
6329 + unsigned int vid)
6330 + {
6331 + struct rtl8366_vlan_mc vlanmc;
6332 +- struct rtl8366_vlan_4k vlan4k;
6333 ++ int mc;
6334 + int ret;
6335 +- int i;
6336 +-
6337 +- /* Try to find an existing MC entry for this VID */
6338 +- for (i = 0; i < smi->num_vlan_mc; i++) {
6339 +- ret = smi->ops->get_vlan_mc(smi, i, &vlanmc);
6340 +- if (ret)
6341 +- return ret;
6342 +-
6343 +- if (vid == vlanmc.vid) {
6344 +- ret = smi->ops->set_vlan_mc(smi, i, &vlanmc);
6345 +- if (ret)
6346 +- return ret;
6347 +-
6348 +- ret = smi->ops->set_mc_index(smi, port, i);
6349 +- return ret;
6350 +- }
6351 +- }
6352 +-
6353 +- /* We have no MC entry for this VID, try to find an empty one */
6354 +- for (i = 0; i < smi->num_vlan_mc; i++) {
6355 +- ret = smi->ops->get_vlan_mc(smi, i, &vlanmc);
6356 +- if (ret)
6357 +- return ret;
6358 +-
6359 +- if (vlanmc.vid == 0 && vlanmc.member == 0) {
6360 +- /* Update the entry from the 4K table */
6361 +- ret = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
6362 +- if (ret)
6363 +- return ret;
6364 +
6365 +- vlanmc.vid = vid;
6366 +- vlanmc.member = vlan4k.member;
6367 +- vlanmc.untag = vlan4k.untag;
6368 +- vlanmc.fid = vlan4k.fid;
6369 +- ret = smi->ops->set_vlan_mc(smi, i, &vlanmc);
6370 +- if (ret)
6371 +- return ret;
6372 +-
6373 +- ret = smi->ops->set_mc_index(smi, port, i);
6374 +- return ret;
6375 +- }
6376 +- }
6377 +-
6378 +- /* MC table is full, try to find an unused entry and replace it */
6379 +- for (i = 0; i < smi->num_vlan_mc; i++) {
6380 +- int used;
6381 +-
6382 +- ret = rtl8366_mc_is_used(smi, i, &used);
6383 +- if (ret)
6384 +- return ret;
6385 +-
6386 +- if (!used) {
6387 +- /* Update the entry from the 4K table */
6388 +- ret = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
6389 +- if (ret)
6390 +- return ret;
6391 ++ if (!smi->ops->is_vlan_valid(smi, vid))
6392 ++ return -EINVAL;
6393 +
6394 +- vlanmc.vid = vid;
6395 +- vlanmc.member = vlan4k.member;
6396 +- vlanmc.untag = vlan4k.untag;
6397 +- vlanmc.fid = vlan4k.fid;
6398 +- ret = smi->ops->set_vlan_mc(smi, i, &vlanmc);
6399 +- if (ret)
6400 +- return ret;
6401 ++ /* Find or allocate a member config for this VID */
6402 ++ ret = rtl8366_obtain_mc(smi, vid, &vlanmc);
6403 ++ if (ret < 0)
6404 ++ return ret;
6405 ++ mc = ret;
6406 +
6407 +- ret = smi->ops->set_mc_index(smi, port, i);
6408 +- return ret;
6409 +- }
6410 ++ ret = smi->ops->set_mc_index(smi, port, mc);
6411 ++ if (ret) {
6412 ++ dev_err(smi->dev, "set PVID: failed to set MC index %d for port %d\n",
6413 ++ mc, port);
6414 ++ return ret;
6415 + }
6416 +
6417 +- dev_err(smi->dev,
6418 +- "all VLAN member configurations are in use\n");
6419 ++ dev_dbg(smi->dev, "set PVID: the PVID for port %d set to %d using existing MC index %d\n",
6420 ++ port, vid, mc);
6421 +
6422 +- return -ENOSPC;
6423 ++ return 0;
6424 + }
6425 + EXPORT_SYMBOL_GPL(rtl8366_set_pvid);
6426 +
6427 +@@ -389,7 +415,8 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port,
6428 + if (!smi->ops->is_vlan_valid(smi, vid))
6429 + return;
6430 +
6431 +- dev_info(smi->dev, "add VLAN on port %d, %s, %s\n",
6432 ++ dev_info(smi->dev, "add VLAN %d on port %d, %s, %s\n",
6433 ++ vlan->vid_begin,
6434 + port,
6435 + untagged ? "untagged" : "tagged",
6436 + pvid ? " PVID" : "no PVID");
6437 +@@ -398,34 +425,29 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port,
6438 + dev_err(smi->dev, "port is DSA or CPU port\n");
6439 +
6440 + for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
6441 +- int pvid_val = 0;
6442 +-
6443 +- dev_info(smi->dev, "add VLAN %04x\n", vid);
6444 + member |= BIT(port);
6445 +
6446 + if (untagged)
6447 + untag |= BIT(port);
6448 +
6449 +- /* To ensure that we have a valid MC entry for this VLAN,
6450 +- * initialize the port VLAN ID here.
6451 +- */
6452 +- ret = rtl8366_get_pvid(smi, port, &pvid_val);
6453 +- if (ret < 0) {
6454 +- dev_err(smi->dev, "could not lookup PVID for port %d\n",
6455 +- port);
6456 +- return;
6457 +- }
6458 +- if (pvid_val == 0) {
6459 +- ret = rtl8366_set_pvid(smi, port, vid);
6460 +- if (ret < 0)
6461 +- return;
6462 +- }
6463 +-
6464 + ret = rtl8366_set_vlan(smi, vid, member, untag, 0);
6465 + if (ret)
6466 + dev_err(smi->dev,
6467 + "failed to set up VLAN %04x",
6468 + vid);
6469 ++
6470 ++ if (!pvid)
6471 ++ continue;
6472 ++
6473 ++ ret = rtl8366_set_pvid(smi, port, vid);
6474 ++ if (ret)
6475 ++ dev_err(smi->dev,
6476 ++ "failed to set PVID on port %d to VLAN %04x",
6477 ++ port, vid);
6478 ++
6479 ++ if (!ret)
6480 ++ dev_dbg(smi->dev, "VLAN add: added VLAN %d with PVID on port %d\n",
6481 ++ vid, port);
6482 + }
6483 + }
6484 + EXPORT_SYMBOL_GPL(rtl8366_vlan_add);
6485 +diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c
6486 +index f5cc8b0a7c74c..7f731bf369980 100644
6487 +--- a/drivers/net/dsa/rtl8366rb.c
6488 ++++ b/drivers/net/dsa/rtl8366rb.c
6489 +@@ -1269,7 +1269,7 @@ static bool rtl8366rb_is_vlan_valid(struct realtek_smi *smi, unsigned int vlan)
6490 + if (smi->vlan4k_enabled)
6491 + max = RTL8366RB_NUM_VIDS - 1;
6492 +
6493 +- if (vlan == 0 || vlan >= max)
6494 ++ if (vlan == 0 || vlan > max)
6495 + return false;
6496 +
6497 + return true;
6498 +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
6499 +index 16a939f9b04d5..22d634111b818 100644
6500 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
6501 ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
6502 +@@ -60,6 +60,89 @@ static struct ch_tc_pedit_fields pedits[] = {
6503 + PEDIT_FIELDS(IP6_, DST_127_96, 4, nat_lip, 12),
6504 + };
6505 +
6506 ++static const struct cxgb4_natmode_config cxgb4_natmode_config_array[] = {
6507 ++ /* Default supported NAT modes */
6508 ++ {
6509 ++ .chip = CHELSIO_T5,
6510 ++ .flags = CXGB4_ACTION_NATMODE_NONE,
6511 ++ .natmode = NAT_MODE_NONE,
6512 ++ },
6513 ++ {
6514 ++ .chip = CHELSIO_T5,
6515 ++ .flags = CXGB4_ACTION_NATMODE_DIP,
6516 ++ .natmode = NAT_MODE_DIP,
6517 ++ },
6518 ++ {
6519 ++ .chip = CHELSIO_T5,
6520 ++ .flags = CXGB4_ACTION_NATMODE_DIP | CXGB4_ACTION_NATMODE_DPORT,
6521 ++ .natmode = NAT_MODE_DIP_DP,
6522 ++ },
6523 ++ {
6524 ++ .chip = CHELSIO_T5,
6525 ++ .flags = CXGB4_ACTION_NATMODE_DIP | CXGB4_ACTION_NATMODE_DPORT |
6526 ++ CXGB4_ACTION_NATMODE_SIP,
6527 ++ .natmode = NAT_MODE_DIP_DP_SIP,
6528 ++ },
6529 ++ {
6530 ++ .chip = CHELSIO_T5,
6531 ++ .flags = CXGB4_ACTION_NATMODE_DIP | CXGB4_ACTION_NATMODE_DPORT |
6532 ++ CXGB4_ACTION_NATMODE_SPORT,
6533 ++ .natmode = NAT_MODE_DIP_DP_SP,
6534 ++ },
6535 ++ {
6536 ++ .chip = CHELSIO_T5,
6537 ++ .flags = CXGB4_ACTION_NATMODE_SIP | CXGB4_ACTION_NATMODE_SPORT,
6538 ++ .natmode = NAT_MODE_SIP_SP,
6539 ++ },
6540 ++ {
6541 ++ .chip = CHELSIO_T5,
6542 ++ .flags = CXGB4_ACTION_NATMODE_DIP | CXGB4_ACTION_NATMODE_SIP |
6543 ++ CXGB4_ACTION_NATMODE_SPORT,
6544 ++ .natmode = NAT_MODE_DIP_SIP_SP,
6545 ++ },
6546 ++ {
6547 ++ .chip = CHELSIO_T5,
6548 ++ .flags = CXGB4_ACTION_NATMODE_DIP | CXGB4_ACTION_NATMODE_SIP |
6549 ++ CXGB4_ACTION_NATMODE_DPORT |
6550 ++ CXGB4_ACTION_NATMODE_SPORT,
6551 ++ .natmode = NAT_MODE_ALL,
6552 ++ },
6553 ++ /* T6+ can ignore L4 ports when they're disabled. */
6554 ++ {
6555 ++ .chip = CHELSIO_T6,
6556 ++ .flags = CXGB4_ACTION_NATMODE_SIP,
6557 ++ .natmode = NAT_MODE_SIP_SP,
6558 ++ },
6559 ++ {
6560 ++ .chip = CHELSIO_T6,
6561 ++ .flags = CXGB4_ACTION_NATMODE_DIP | CXGB4_ACTION_NATMODE_SPORT,
6562 ++ .natmode = NAT_MODE_DIP_DP_SP,
6563 ++ },
6564 ++ {
6565 ++ .chip = CHELSIO_T6,
6566 ++ .flags = CXGB4_ACTION_NATMODE_DIP | CXGB4_ACTION_NATMODE_SIP,
6567 ++ .natmode = NAT_MODE_ALL,
6568 ++ },
6569 ++};
6570 ++
6571 ++static void cxgb4_action_natmode_tweak(struct ch_filter_specification *fs,
6572 ++ u8 natmode_flags)
6573 ++{
6574 ++ u8 i = 0;
6575 ++
6576 ++ /* Translate the enabled NAT 4-tuple fields to one of the
6577 ++ * hardware supported NAT mode configurations. This ensures
6578 ++ * that we pick a valid combination, where the disabled fields
6579 ++ * do not get overwritten to 0.
6580 ++ */
6581 ++ for (i = 0; i < ARRAY_SIZE(cxgb4_natmode_config_array); i++) {
6582 ++ if (cxgb4_natmode_config_array[i].flags == natmode_flags) {
6583 ++ fs->nat_mode = cxgb4_natmode_config_array[i].natmode;
6584 ++ return;
6585 ++ }
6586 ++ }
6587 ++}
6588 ++
6589 + static struct ch_tc_flower_entry *allocate_flower_entry(void)
6590 + {
6591 + struct ch_tc_flower_entry *new = kzalloc(sizeof(*new), GFP_KERNEL);
6592 +@@ -287,7 +370,8 @@ static void offload_pedit(struct ch_filter_specification *fs, u32 val, u32 mask,
6593 + }
6594 +
6595 + static void process_pedit_field(struct ch_filter_specification *fs, u32 val,
6596 +- u32 mask, u32 offset, u8 htype)
6597 ++ u32 mask, u32 offset, u8 htype,
6598 ++ u8 *natmode_flags)
6599 + {
6600 + switch (htype) {
6601 + case FLOW_ACT_MANGLE_HDR_TYPE_ETH:
6602 +@@ -312,60 +396,95 @@ static void process_pedit_field(struct ch_filter_specification *fs, u32 val,
6603 + switch (offset) {
6604 + case PEDIT_IP4_SRC:
6605 + offload_pedit(fs, val, mask, IP4_SRC);
6606 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_SIP;
6607 + break;
6608 + case PEDIT_IP4_DST:
6609 + offload_pedit(fs, val, mask, IP4_DST);
6610 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_DIP;
6611 + }
6612 +- fs->nat_mode = NAT_MODE_ALL;
6613 + break;
6614 + case FLOW_ACT_MANGLE_HDR_TYPE_IP6:
6615 + switch (offset) {
6616 + case PEDIT_IP6_SRC_31_0:
6617 + offload_pedit(fs, val, mask, IP6_SRC_31_0);
6618 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_SIP;
6619 + break;
6620 + case PEDIT_IP6_SRC_63_32:
6621 + offload_pedit(fs, val, mask, IP6_SRC_63_32);
6622 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_SIP;
6623 + break;
6624 + case PEDIT_IP6_SRC_95_64:
6625 + offload_pedit(fs, val, mask, IP6_SRC_95_64);
6626 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_SIP;
6627 + break;
6628 + case PEDIT_IP6_SRC_127_96:
6629 + offload_pedit(fs, val, mask, IP6_SRC_127_96);
6630 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_SIP;
6631 + break;
6632 + case PEDIT_IP6_DST_31_0:
6633 + offload_pedit(fs, val, mask, IP6_DST_31_0);
6634 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_DIP;
6635 + break;
6636 + case PEDIT_IP6_DST_63_32:
6637 + offload_pedit(fs, val, mask, IP6_DST_63_32);
6638 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_DIP;
6639 + break;
6640 + case PEDIT_IP6_DST_95_64:
6641 + offload_pedit(fs, val, mask, IP6_DST_95_64);
6642 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_DIP;
6643 + break;
6644 + case PEDIT_IP6_DST_127_96:
6645 + offload_pedit(fs, val, mask, IP6_DST_127_96);
6646 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_DIP;
6647 + }
6648 +- fs->nat_mode = NAT_MODE_ALL;
6649 + break;
6650 + case FLOW_ACT_MANGLE_HDR_TYPE_TCP:
6651 + switch (offset) {
6652 + case PEDIT_TCP_SPORT_DPORT:
6653 +- if (~mask & PEDIT_TCP_UDP_SPORT_MASK)
6654 ++ if (~mask & PEDIT_TCP_UDP_SPORT_MASK) {
6655 + fs->nat_fport = val;
6656 +- else
6657 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_SPORT;
6658 ++ } else {
6659 + fs->nat_lport = val >> 16;
6660 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_DPORT;
6661 ++ }
6662 + }
6663 +- fs->nat_mode = NAT_MODE_ALL;
6664 + break;
6665 + case FLOW_ACT_MANGLE_HDR_TYPE_UDP:
6666 + switch (offset) {
6667 + case PEDIT_UDP_SPORT_DPORT:
6668 +- if (~mask & PEDIT_TCP_UDP_SPORT_MASK)
6669 ++ if (~mask & PEDIT_TCP_UDP_SPORT_MASK) {
6670 + fs->nat_fport = val;
6671 +- else
6672 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_SPORT;
6673 ++ } else {
6674 + fs->nat_lport = val >> 16;
6675 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_DPORT;
6676 ++ }
6677 + }
6678 +- fs->nat_mode = NAT_MODE_ALL;
6679 ++ break;
6680 ++ }
6681 ++}
6682 ++
6683 ++static int cxgb4_action_natmode_validate(struct net_device *dev,
6684 ++ struct adapter *adap, u8 natmode_flags)
6685 ++{
6686 ++ u8 i = 0;
6687 ++
6688 ++ /* Extract the NAT mode to enable based on what 4-tuple fields
6689 ++ * are enabled to be overwritten. This ensures that the
6690 ++ * disabled fields don't get overwritten to 0.
6691 ++ */
6692 ++ for (i = 0; i < ARRAY_SIZE(cxgb4_natmode_config_array); i++) {
6693 ++ const struct cxgb4_natmode_config *c;
6694 ++
6695 ++ c = &cxgb4_natmode_config_array[i];
6696 ++ if (CHELSIO_CHIP_VERSION(adap->params.chip) >= c->chip &&
6697 ++ natmode_flags == c->flags)
6698 ++ return 0;
6699 + }
6700 ++ netdev_err(dev, "%s: Unsupported NAT mode 4-tuple combination\n",
6701 ++ __func__);
6702 ++ return -EOPNOTSUPP;
6703 + }
6704 +
6705 + static void cxgb4_process_flow_actions(struct net_device *in,
6706 +@@ -374,6 +493,7 @@ static void cxgb4_process_flow_actions(struct net_device *in,
6707 + {
6708 + struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
6709 + struct flow_action_entry *act;
6710 ++ u8 natmode_flags = 0;
6711 + int i;
6712 +
6713 + flow_action_for_each(i, act, &rule->action) {
6714 +@@ -424,13 +544,17 @@ static void cxgb4_process_flow_actions(struct net_device *in,
6715 + val = act->mangle.val;
6716 + offset = act->mangle.offset;
6717 +
6718 +- process_pedit_field(fs, val, mask, offset, htype);
6719 ++ process_pedit_field(fs, val, mask, offset, htype,
6720 ++ &natmode_flags);
6721 + }
6722 + break;
6723 + default:
6724 + break;
6725 + }
6726 + }
6727 ++ if (natmode_flags)
6728 ++ cxgb4_action_natmode_tweak(fs, natmode_flags);
6729 ++
6730 + }
6731 +
6732 + static bool valid_l4_mask(u32 mask)
6733 +@@ -447,7 +571,8 @@ static bool valid_l4_mask(u32 mask)
6734 + }
6735 +
6736 + static bool valid_pedit_action(struct net_device *dev,
6737 +- const struct flow_action_entry *act)
6738 ++ const struct flow_action_entry *act,
6739 ++ u8 *natmode_flags)
6740 + {
6741 + u32 mask, offset;
6742 + u8 htype;
6743 +@@ -472,7 +597,10 @@ static bool valid_pedit_action(struct net_device *dev,
6744 + case FLOW_ACT_MANGLE_HDR_TYPE_IP4:
6745 + switch (offset) {
6746 + case PEDIT_IP4_SRC:
6747 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_SIP;
6748 ++ break;
6749 + case PEDIT_IP4_DST:
6750 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_DIP;
6751 + break;
6752 + default:
6753 + netdev_err(dev, "%s: Unsupported pedit field\n",
6754 +@@ -486,10 +614,13 @@ static bool valid_pedit_action(struct net_device *dev,
6755 + case PEDIT_IP6_SRC_63_32:
6756 + case PEDIT_IP6_SRC_95_64:
6757 + case PEDIT_IP6_SRC_127_96:
6758 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_SIP;
6759 ++ break;
6760 + case PEDIT_IP6_DST_31_0:
6761 + case PEDIT_IP6_DST_63_32:
6762 + case PEDIT_IP6_DST_95_64:
6763 + case PEDIT_IP6_DST_127_96:
6764 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_DIP;
6765 + break;
6766 + default:
6767 + netdev_err(dev, "%s: Unsupported pedit field\n",
6768 +@@ -505,6 +636,10 @@ static bool valid_pedit_action(struct net_device *dev,
6769 + __func__);
6770 + return false;
6771 + }
6772 ++ if (~mask & PEDIT_TCP_UDP_SPORT_MASK)
6773 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_SPORT;
6774 ++ else
6775 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_DPORT;
6776 + break;
6777 + default:
6778 + netdev_err(dev, "%s: Unsupported pedit field\n",
6779 +@@ -520,6 +655,10 @@ static bool valid_pedit_action(struct net_device *dev,
6780 + __func__);
6781 + return false;
6782 + }
6783 ++ if (~mask & PEDIT_TCP_UDP_SPORT_MASK)
6784 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_SPORT;
6785 ++ else
6786 ++ *natmode_flags |= CXGB4_ACTION_NATMODE_DPORT;
6787 + break;
6788 + default:
6789 + netdev_err(dev, "%s: Unsupported pedit field\n",
6790 +@@ -538,10 +677,12 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,
6791 + struct flow_cls_offload *cls)
6792 + {
6793 + struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
6794 ++ struct adapter *adap = netdev2adap(dev);
6795 + struct flow_action_entry *act;
6796 + bool act_redir = false;
6797 + bool act_pedit = false;
6798 + bool act_vlan = false;
6799 ++ u8 natmode_flags = 0;
6800 + int i;
6801 +
6802 + flow_action_for_each(i, act, &rule->action) {
6803 +@@ -551,7 +692,6 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,
6804 + /* Do nothing */
6805 + break;
6806 + case FLOW_ACTION_REDIRECT: {
6807 +- struct adapter *adap = netdev2adap(dev);
6808 + struct net_device *n_dev, *target_dev;
6809 + unsigned int i;
6810 + bool found = false;
6811 +@@ -601,7 +741,8 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,
6812 + }
6813 + break;
6814 + case FLOW_ACTION_MANGLE: {
6815 +- bool pedit_valid = valid_pedit_action(dev, act);
6816 ++ bool pedit_valid = valid_pedit_action(dev, act,
6817 ++ &natmode_flags);
6818 +
6819 + if (!pedit_valid)
6820 + return -EOPNOTSUPP;
6821 +@@ -620,6 +761,14 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,
6822 + return -EINVAL;
6823 + }
6824 +
6825 ++ if (act_pedit) {
6826 ++ int ret;
6827 ++
6828 ++ ret = cxgb4_action_natmode_validate(dev, adap, natmode_flags);
6829 ++ if (ret)
6830 ++ return ret;
6831 ++ }
6832 ++
6833 + return 0;
6834 + }
6835 +
6836 +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h
6837 +index eb4c95248baf6..c905debe6f7ac 100644
6838 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h
6839 ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h
6840 +@@ -108,6 +108,21 @@ struct ch_tc_pedit_fields {
6841 + #define PEDIT_TCP_SPORT_DPORT 0x0
6842 + #define PEDIT_UDP_SPORT_DPORT 0x0
6843 +
6844 ++enum cxgb4_action_natmode_flags {
6845 ++ CXGB4_ACTION_NATMODE_NONE = 0,
6846 ++ CXGB4_ACTION_NATMODE_DIP = (1 << 0),
6847 ++ CXGB4_ACTION_NATMODE_SIP = (1 << 1),
6848 ++ CXGB4_ACTION_NATMODE_DPORT = (1 << 2),
6849 ++ CXGB4_ACTION_NATMODE_SPORT = (1 << 3),
6850 ++};
6851 ++
6852 ++/* TC PEDIT action to NATMODE translation entry */
6853 ++struct cxgb4_natmode_config {
6854 ++ enum chip_type chip;
6855 ++ u8 flags;
6856 ++ u8 natmode;
6857 ++};
6858 ++
6859 + int cxgb4_tc_flower_replace(struct net_device *dev,
6860 + struct flow_cls_offload *cls);
6861 + int cxgb4_tc_flower_destroy(struct net_device *dev,
6862 +diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h
6863 +index 0dd64acd2a3fb..08cac1bfacafb 100644
6864 +--- a/drivers/net/ethernet/cisco/enic/enic.h
6865 ++++ b/drivers/net/ethernet/cisco/enic/enic.h
6866 +@@ -171,6 +171,7 @@ struct enic {
6867 + u16 num_vfs;
6868 + #endif
6869 + spinlock_t enic_api_lock;
6870 ++ bool enic_api_busy;
6871 + struct enic_port_profile *pp;
6872 +
6873 + /* work queue cache line section */
6874 +diff --git a/drivers/net/ethernet/cisco/enic/enic_api.c b/drivers/net/ethernet/cisco/enic/enic_api.c
6875 +index b161f24522b87..b028ea2dec2b9 100644
6876 +--- a/drivers/net/ethernet/cisco/enic/enic_api.c
6877 ++++ b/drivers/net/ethernet/cisco/enic/enic_api.c
6878 +@@ -34,6 +34,12 @@ int enic_api_devcmd_proxy_by_index(struct net_device *netdev, int vf,
6879 + struct vnic_dev *vdev = enic->vdev;
6880 +
6881 + spin_lock(&enic->enic_api_lock);
6882 ++ while (enic->enic_api_busy) {
6883 ++ spin_unlock(&enic->enic_api_lock);
6884 ++ cpu_relax();
6885 ++ spin_lock(&enic->enic_api_lock);
6886 ++ }
6887 ++
6888 + spin_lock_bh(&enic->devcmd_lock);
6889 +
6890 + vnic_dev_cmd_proxy_by_index_start(vdev, vf);
6891 +diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
6892 +index 6e2ab10ad2e6f..8314102002b0f 100644
6893 +--- a/drivers/net/ethernet/cisco/enic/enic_main.c
6894 ++++ b/drivers/net/ethernet/cisco/enic/enic_main.c
6895 +@@ -2142,8 +2142,6 @@ static int enic_dev_wait(struct vnic_dev *vdev,
6896 + int done;
6897 + int err;
6898 +
6899 +- BUG_ON(in_interrupt());
6900 +-
6901 + err = start(vdev, arg);
6902 + if (err)
6903 + return err;
6904 +@@ -2331,6 +2329,13 @@ static int enic_set_rss_nic_cfg(struct enic *enic)
6905 + rss_hash_bits, rss_base_cpu, rss_enable);
6906 + }
6907 +
6908 ++static void enic_set_api_busy(struct enic *enic, bool busy)
6909 ++{
6910 ++ spin_lock(&enic->enic_api_lock);
6911 ++ enic->enic_api_busy = busy;
6912 ++ spin_unlock(&enic->enic_api_lock);
6913 ++}
6914 ++
6915 + static void enic_reset(struct work_struct *work)
6916 + {
6917 + struct enic *enic = container_of(work, struct enic, reset);
6918 +@@ -2340,7 +2345,9 @@ static void enic_reset(struct work_struct *work)
6919 +
6920 + rtnl_lock();
6921 +
6922 +- spin_lock(&enic->enic_api_lock);
6923 ++ /* Stop any activity from infiniband */
6924 ++ enic_set_api_busy(enic, true);
6925 ++
6926 + enic_stop(enic->netdev);
6927 + enic_dev_soft_reset(enic);
6928 + enic_reset_addr_lists(enic);
6929 +@@ -2348,7 +2355,10 @@ static void enic_reset(struct work_struct *work)
6930 + enic_set_rss_nic_cfg(enic);
6931 + enic_dev_set_ig_vlan_rewrite_mode(enic);
6932 + enic_open(enic->netdev);
6933 +- spin_unlock(&enic->enic_api_lock);
6934 ++
6935 ++ /* Allow infiniband to fiddle with the device again */
6936 ++ enic_set_api_busy(enic, false);
6937 ++
6938 + call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev);
6939 +
6940 + rtnl_unlock();
6941 +@@ -2360,7 +2370,9 @@ static void enic_tx_hang_reset(struct work_struct *work)
6942 +
6943 + rtnl_lock();
6944 +
6945 +- spin_lock(&enic->enic_api_lock);
6946 ++ /* Stop any activity from infiniband */
6947 ++ enic_set_api_busy(enic, true);
6948 ++
6949 + enic_dev_hang_notify(enic);
6950 + enic_stop(enic->netdev);
6951 + enic_dev_hang_reset(enic);
6952 +@@ -2369,7 +2381,10 @@ static void enic_tx_hang_reset(struct work_struct *work)
6953 + enic_set_rss_nic_cfg(enic);
6954 + enic_dev_set_ig_vlan_rewrite_mode(enic);
6955 + enic_open(enic->netdev);
6956 +- spin_unlock(&enic->enic_api_lock);
6957 ++
6958 ++ /* Allow infiniband to fiddle with the device again */
6959 ++ enic_set_api_busy(enic, false);
6960 ++
6961 + call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev);
6962 +
6963 + rtnl_unlock();
6964 +diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
6965 +index 96e9565f1e08a..1fbc243fc3f4c 100644
6966 +--- a/drivers/net/ethernet/faraday/ftgmac100.c
6967 ++++ b/drivers/net/ethernet/faraday/ftgmac100.c
6968 +@@ -1807,6 +1807,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
6969 + priv->rxdes0_edorr_mask = BIT(30);
6970 + priv->txdes0_edotr_mask = BIT(30);
6971 + priv->is_aspeed = true;
6972 ++ /* Disable ast2600 problematic HW arbitration */
6973 ++ if (of_device_is_compatible(np, "aspeed,ast2600-mac")) {
6974 ++ iowrite32(FTGMAC100_TM_DEFAULT,
6975 ++ priv->base + FTGMAC100_OFFSET_TM);
6976 ++ }
6977 + } else {
6978 + priv->rxdes0_edorr_mask = BIT(15);
6979 + priv->txdes0_edotr_mask = BIT(15);
6980 +diff --git a/drivers/net/ethernet/faraday/ftgmac100.h b/drivers/net/ethernet/faraday/ftgmac100.h
6981 +index e5876a3fda91d..63b3e02fab162 100644
6982 +--- a/drivers/net/ethernet/faraday/ftgmac100.h
6983 ++++ b/drivers/net/ethernet/faraday/ftgmac100.h
6984 +@@ -169,6 +169,14 @@
6985 + #define FTGMAC100_MACCR_FAST_MODE (1 << 19)
6986 + #define FTGMAC100_MACCR_SW_RST (1 << 31)
6987 +
6988 ++/*
6989 ++ * test mode control register
6990 ++ */
6991 ++#define FTGMAC100_TM_RQ_TX_VALID_DIS (1 << 28)
6992 ++#define FTGMAC100_TM_RQ_RR_IDLE_PREV (1 << 27)
6993 ++#define FTGMAC100_TM_DEFAULT \
6994 ++ (FTGMAC100_TM_RQ_TX_VALID_DIS | FTGMAC100_TM_RQ_RR_IDLE_PREV)
6995 ++
6996 + /*
6997 + * PHY control register
6998 + */
6999 +diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
7000 +index a0e4b12ac4ea2..fd7fc6f20c9da 100644
7001 +--- a/drivers/net/ethernet/freescale/fec_main.c
7002 ++++ b/drivers/net/ethernet/freescale/fec_main.c
7003 +@@ -1945,6 +1945,27 @@ out:
7004 + return ret;
7005 + }
7006 +
7007 ++static void fec_enet_phy_reset_after_clk_enable(struct net_device *ndev)
7008 ++{
7009 ++ struct fec_enet_private *fep = netdev_priv(ndev);
7010 ++ struct phy_device *phy_dev = ndev->phydev;
7011 ++
7012 ++ if (phy_dev) {
7013 ++ phy_reset_after_clk_enable(phy_dev);
7014 ++ } else if (fep->phy_node) {
7015 ++ /*
7016 ++ * If the PHY still is not bound to the MAC, but there is
7017 ++ * OF PHY node and a matching PHY device instance already,
7018 ++ * use the OF PHY node to obtain the PHY device instance,
7019 ++ * and then use that PHY device instance when triggering
7020 ++ * the PHY reset.
7021 ++ */
7022 ++ phy_dev = of_phy_find_device(fep->phy_node);
7023 ++ phy_reset_after_clk_enable(phy_dev);
7024 ++ put_device(&phy_dev->mdio.dev);
7025 ++ }
7026 ++}
7027 ++
7028 + static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
7029 + {
7030 + struct fec_enet_private *fep = netdev_priv(ndev);
7031 +@@ -1971,7 +1992,7 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
7032 + if (ret)
7033 + goto failed_clk_ref;
7034 +
7035 +- phy_reset_after_clk_enable(ndev->phydev);
7036 ++ fec_enet_phy_reset_after_clk_enable(ndev);
7037 + } else {
7038 + clk_disable_unprepare(fep->clk_enet_out);
7039 + if (fep->clk_ptp) {
7040 +@@ -2982,16 +3003,16 @@ fec_enet_open(struct net_device *ndev)
7041 + /* Init MAC prior to mii bus probe */
7042 + fec_restart(ndev);
7043 +
7044 +- /* Probe and connect to PHY when open the interface */
7045 +- ret = fec_enet_mii_probe(ndev);
7046 +- if (ret)
7047 +- goto err_enet_mii_probe;
7048 +-
7049 + /* Call phy_reset_after_clk_enable() again if it failed during
7050 + * phy_reset_after_clk_enable() before because the PHY wasn't probed.
7051 + */
7052 + if (reset_again)
7053 +- phy_reset_after_clk_enable(ndev->phydev);
7054 ++ fec_enet_phy_reset_after_clk_enable(ndev);
7055 ++
7056 ++ /* Probe and connect to PHY when open the interface */
7057 ++ ret = fec_enet_mii_probe(ndev);
7058 ++ if (ret)
7059 ++ goto err_enet_mii_probe;
7060 +
7061 + if (fep->quirks & FEC_QUIRK_ERR006687)
7062 + imx6q_cpuidle_fec_irqs_used();
7063 +diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
7064 +index aa32a5b041129..a20d9147d5f22 100644
7065 +--- a/drivers/net/ethernet/ibm/ibmveth.c
7066 ++++ b/drivers/net/ethernet/ibm/ibmveth.c
7067 +@@ -1317,6 +1317,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
7068 + int offset = ibmveth_rxq_frame_offset(adapter);
7069 + int csum_good = ibmveth_rxq_csum_good(adapter);
7070 + int lrg_pkt = ibmveth_rxq_large_packet(adapter);
7071 ++ __sum16 iph_check = 0;
7072 +
7073 + skb = ibmveth_rxq_get_buffer(adapter);
7074 +
7075 +@@ -1353,16 +1354,26 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
7076 + skb_put(skb, length);
7077 + skb->protocol = eth_type_trans(skb, netdev);
7078 +
7079 +- if (csum_good) {
7080 +- skb->ip_summed = CHECKSUM_UNNECESSARY;
7081 +- ibmveth_rx_csum_helper(skb, adapter);
7082 ++ /* PHYP without PLSO support places a -1 in the ip
7083 ++ * checksum for large send frames.
7084 ++ */
7085 ++ if (skb->protocol == cpu_to_be16(ETH_P_IP)) {
7086 ++ struct iphdr *iph = (struct iphdr *)skb->data;
7087 ++
7088 ++ iph_check = iph->check;
7089 + }
7090 +
7091 +- if (length > netdev->mtu + ETH_HLEN) {
7092 ++ if ((length > netdev->mtu + ETH_HLEN) ||
7093 ++ lrg_pkt || iph_check == 0xffff) {
7094 + ibmveth_rx_mss_helper(skb, mss, lrg_pkt);
7095 + adapter->rx_large_packets++;
7096 + }
7097 +
7098 ++ if (csum_good) {
7099 ++ skb->ip_summed = CHECKSUM_UNNECESSARY;
7100 ++ ibmveth_rx_csum_helper(skb, adapter);
7101 ++ }
7102 ++
7103 + napi_gro_receive(napi, skb); /* send it up */
7104 +
7105 + netdev->stats.rx_packets++;
7106 +diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
7107 +index 5329af2337a91..48105a2eebe4d 100644
7108 +--- a/drivers/net/ethernet/ibm/ibmvnic.c
7109 ++++ b/drivers/net/ethernet/ibm/ibmvnic.c
7110 +@@ -4074,8 +4074,13 @@ static int handle_change_mac_rsp(union ibmvnic_crq *crq,
7111 + dev_err(dev, "Error %ld in CHANGE_MAC_ADDR_RSP\n", rc);
7112 + goto out;
7113 + }
7114 ++ /* crq->change_mac_addr.mac_addr is the requested one
7115 ++ * crq->change_mac_addr_rsp.mac_addr is the returned valid one.
7116 ++ */
7117 + ether_addr_copy(netdev->dev_addr,
7118 + &crq->change_mac_addr_rsp.mac_addr[0]);
7119 ++ ether_addr_copy(adapter->mac_addr,
7120 ++ &crq->change_mac_addr_rsp.mac_addr[0]);
7121 + out:
7122 + complete(&adapter->fw_done);
7123 + return rc;
7124 +@@ -4472,7 +4477,7 @@ static int handle_query_phys_parms_rsp(union ibmvnic_crq *crq,
7125 + case IBMVNIC_1GBPS:
7126 + adapter->speed = SPEED_1000;
7127 + break;
7128 +- case IBMVNIC_10GBP:
7129 ++ case IBMVNIC_10GBPS:
7130 + adapter->speed = SPEED_10000;
7131 + break;
7132 + case IBMVNIC_25GBPS:
7133 +@@ -4487,6 +4492,9 @@ static int handle_query_phys_parms_rsp(union ibmvnic_crq *crq,
7134 + case IBMVNIC_100GBPS:
7135 + adapter->speed = SPEED_100000;
7136 + break;
7137 ++ case IBMVNIC_200GBPS:
7138 ++ adapter->speed = SPEED_200000;
7139 ++ break;
7140 + default:
7141 + if (netif_carrier_ok(netdev))
7142 + netdev_warn(netdev, "Unknown speed 0x%08x\n", rspeed);
7143 +diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
7144 +index ebc39248b334a..0da20f19bb17c 100644
7145 +--- a/drivers/net/ethernet/ibm/ibmvnic.h
7146 ++++ b/drivers/net/ethernet/ibm/ibmvnic.h
7147 +@@ -373,7 +373,7 @@ struct ibmvnic_phys_parms {
7148 + #define IBMVNIC_10MBPS 0x40000000
7149 + #define IBMVNIC_100MBPS 0x20000000
7150 + #define IBMVNIC_1GBPS 0x10000000
7151 +-#define IBMVNIC_10GBP 0x08000000
7152 ++#define IBMVNIC_10GBPS 0x08000000
7153 + #define IBMVNIC_40GBPS 0x04000000
7154 + #define IBMVNIC_100GBPS 0x02000000
7155 + #define IBMVNIC_25GBPS 0x01000000
7156 +diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
7157 +index ae195f8adff58..993f495e2bf7b 100644
7158 +--- a/drivers/net/ethernet/korina.c
7159 ++++ b/drivers/net/ethernet/korina.c
7160 +@@ -1113,7 +1113,7 @@ out:
7161 + return rc;
7162 +
7163 + probe_err_register:
7164 +- kfree(lp->td_ring);
7165 ++ kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring));
7166 + probe_err_td_ring:
7167 + iounmap(lp->tx_dma_regs);
7168 + probe_err_dma_tx:
7169 +@@ -1133,6 +1133,7 @@ static int korina_remove(struct platform_device *pdev)
7170 + iounmap(lp->eth_regs);
7171 + iounmap(lp->rx_dma_regs);
7172 + iounmap(lp->tx_dma_regs);
7173 ++ kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring));
7174 +
7175 + unregister_netdev(bif->dev);
7176 + free_netdev(bif->dev);
7177 +diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
7178 +index db3552f2d0877..f9797e5038841 100644
7179 +--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
7180 ++++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
7181 +@@ -942,6 +942,9 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)
7182 + bool clean_complete = true;
7183 + int done;
7184 +
7185 ++ if (!budget)
7186 ++ return 0;
7187 ++
7188 + if (priv->tx_ring_num[TX_XDP]) {
7189 + xdp_tx_cq = priv->tx_cq[TX_XDP][cq->ring];
7190 + if (xdp_tx_cq->xdp_busy) {
7191 +diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
7192 +index a30edb436f4af..191ead7a7fa59 100644
7193 +--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
7194 ++++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
7195 +@@ -350,7 +350,7 @@ u32 mlx4_en_recycle_tx_desc(struct mlx4_en_priv *priv,
7196 + .dma = tx_info->map0_dma,
7197 + };
7198 +
7199 +- if (!mlx4_en_rx_recycle(ring->recycle_ring, &frame)) {
7200 ++ if (!napi_mode || !mlx4_en_rx_recycle(ring->recycle_ring, &frame)) {
7201 + dma_unmap_page(priv->ddev, tx_info->map0_dma,
7202 + PAGE_SIZE, priv->dma_dir);
7203 + put_page(tx_info->page);
7204 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
7205 +index 75fc283cacc36..492ff2ef9a404 100644
7206 +--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
7207 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
7208 +@@ -498,8 +498,9 @@ static int mlx5_pps_event(struct notifier_block *nb,
7209 + switch (clock->ptp_info.pin_config[pin].func) {
7210 + case PTP_PF_EXTTS:
7211 + ptp_event.index = pin;
7212 +- ptp_event.timestamp = timecounter_cyc2time(&clock->tc,
7213 +- be64_to_cpu(eqe->data.pps.time_stamp));
7214 ++ ptp_event.timestamp =
7215 ++ mlx5_timecounter_cyc2time(clock,
7216 ++ be64_to_cpu(eqe->data.pps.time_stamp));
7217 + if (clock->pps_info.enabled) {
7218 + ptp_event.type = PTP_CLOCK_PPSUSR;
7219 + ptp_event.pps_times.ts_real =
7220 +diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
7221 +index 66c97049f52b7..f838abdb35e1d 100644
7222 +--- a/drivers/net/ethernet/realtek/r8169_main.c
7223 ++++ b/drivers/net/ethernet/realtek/r8169_main.c
7224 +@@ -5514,6 +5514,10 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
7225 + dev->mtu = new_mtu;
7226 + netdev_update_features(dev);
7227 +
7228 ++ /* Reportedly at least Asus X453MA truncates packets otherwise */
7229 ++ if (tp->mac_version == RTL_GIGA_MAC_VER_37)
7230 ++ rtl_init_rxcfg(tp);
7231 ++
7232 + return 0;
7233 + }
7234 +
7235 +@@ -6414,7 +6418,7 @@ static int rtl8169_close(struct net_device *dev)
7236 +
7237 + phy_disconnect(tp->phydev);
7238 +
7239 +- pci_free_irq(pdev, 0, tp);
7240 ++ free_irq(pci_irq_vector(pdev, 0), tp);
7241 +
7242 + dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray,
7243 + tp->RxPhyAddr);
7244 +@@ -6465,8 +6469,8 @@ static int rtl_open(struct net_device *dev)
7245 +
7246 + rtl_request_firmware(tp);
7247 +
7248 +- retval = pci_request_irq(pdev, 0, rtl8169_interrupt, NULL, tp,
7249 +- dev->name);
7250 ++ retval = request_irq(pci_irq_vector(pdev, 0), rtl8169_interrupt,
7251 ++ IRQF_NO_THREAD | IRQF_SHARED, dev->name, tp);
7252 + if (retval < 0)
7253 + goto err_release_fw_2;
7254 +
7255 +@@ -6499,7 +6503,7 @@ out:
7256 + return retval;
7257 +
7258 + err_free_irq:
7259 +- pci_free_irq(pdev, 0, tp);
7260 ++ free_irq(pci_irq_vector(pdev, 0), tp);
7261 + err_release_fw_2:
7262 + rtl_release_firmware(tp);
7263 + rtl8169_rx_clear(tp);
7264 +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
7265 +index 982be75fde833..189cdb7633671 100644
7266 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
7267 ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
7268 +@@ -175,32 +175,6 @@ static void stmmac_enable_all_queues(struct stmmac_priv *priv)
7269 + }
7270 + }
7271 +
7272 +-/**
7273 +- * stmmac_stop_all_queues - Stop all queues
7274 +- * @priv: driver private structure
7275 +- */
7276 +-static void stmmac_stop_all_queues(struct stmmac_priv *priv)
7277 +-{
7278 +- u32 tx_queues_cnt = priv->plat->tx_queues_to_use;
7279 +- u32 queue;
7280 +-
7281 +- for (queue = 0; queue < tx_queues_cnt; queue++)
7282 +- netif_tx_stop_queue(netdev_get_tx_queue(priv->dev, queue));
7283 +-}
7284 +-
7285 +-/**
7286 +- * stmmac_start_all_queues - Start all queues
7287 +- * @priv: driver private structure
7288 +- */
7289 +-static void stmmac_start_all_queues(struct stmmac_priv *priv)
7290 +-{
7291 +- u32 tx_queues_cnt = priv->plat->tx_queues_to_use;
7292 +- u32 queue;
7293 +-
7294 +- for (queue = 0; queue < tx_queues_cnt; queue++)
7295 +- netif_tx_start_queue(netdev_get_tx_queue(priv->dev, queue));
7296 +-}
7297 +-
7298 + static void stmmac_service_event_schedule(struct stmmac_priv *priv)
7299 + {
7300 + if (!test_bit(STMMAC_DOWN, &priv->state) &&
7301 +@@ -2737,7 +2711,7 @@ static int stmmac_open(struct net_device *dev)
7302 + }
7303 +
7304 + stmmac_enable_all_queues(priv);
7305 +- stmmac_start_all_queues(priv);
7306 ++ netif_tx_start_all_queues(priv->dev);
7307 +
7308 + return 0;
7309 +
7310 +@@ -2778,8 +2752,6 @@ static int stmmac_release(struct net_device *dev)
7311 + phylink_stop(priv->phylink);
7312 + phylink_disconnect_phy(priv->phylink);
7313 +
7314 +- stmmac_stop_all_queues(priv);
7315 +-
7316 + stmmac_disable_all_queues(priv);
7317 +
7318 + for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
7319 +@@ -4770,7 +4742,6 @@ int stmmac_suspend(struct device *dev)
7320 + mutex_lock(&priv->lock);
7321 +
7322 + netif_device_detach(ndev);
7323 +- stmmac_stop_all_queues(priv);
7324 +
7325 + stmmac_disable_all_queues(priv);
7326 +
7327 +@@ -4883,8 +4854,6 @@ int stmmac_resume(struct device *dev)
7328 +
7329 + stmmac_enable_all_queues(priv);
7330 +
7331 +- stmmac_start_all_queues(priv);
7332 +-
7333 + mutex_unlock(&priv->lock);
7334 +
7335 + if (!device_may_wakeup(priv->device)) {
7336 +diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
7337 +index e57d59b0a7ae9..21d905d90650b 100644
7338 +--- a/drivers/net/usb/qmi_wwan.c
7339 ++++ b/drivers/net/usb/qmi_wwan.c
7340 +@@ -1375,6 +1375,7 @@ static const struct usb_device_id products[] = {
7341 + {QMI_QUIRK_SET_DTR(0x2cb7, 0x0104, 4)}, /* Fibocom NL678 series */
7342 + {QMI_FIXED_INTF(0x0489, 0xe0b4, 0)}, /* Foxconn T77W968 LTE */
7343 + {QMI_FIXED_INTF(0x0489, 0xe0b5, 0)}, /* Foxconn T77W968 LTE with eSIM support*/
7344 ++ {QMI_FIXED_INTF(0x2692, 0x9025, 4)}, /* Cellient MPL200 (rebranded Qualcomm 05c6:9025) */
7345 +
7346 + /* 4. Gobi 1000 devices */
7347 + {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
7348 +diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c
7349 +index dfc16770458d8..8b6598a3713d1 100644
7350 +--- a/drivers/net/wan/hdlc.c
7351 ++++ b/drivers/net/wan/hdlc.c
7352 +@@ -46,7 +46,15 @@ static struct hdlc_proto *first_proto;
7353 + static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,
7354 + struct packet_type *p, struct net_device *orig_dev)
7355 + {
7356 +- struct hdlc_device *hdlc = dev_to_hdlc(dev);
7357 ++ struct hdlc_device *hdlc;
7358 ++
7359 ++ /* First make sure "dev" is an HDLC device */
7360 ++ if (!(dev->priv_flags & IFF_WAN_HDLC)) {
7361 ++ kfree_skb(skb);
7362 ++ return NET_RX_SUCCESS;
7363 ++ }
7364 ++
7365 ++ hdlc = dev_to_hdlc(dev);
7366 +
7367 + if (!net_eq(dev_net(dev), &init_net)) {
7368 + kfree_skb(skb);
7369 +diff --git a/drivers/net/wan/hdlc_raw_eth.c b/drivers/net/wan/hdlc_raw_eth.c
7370 +index 08e0a46501dec..c70a518b8b478 100644
7371 +--- a/drivers/net/wan/hdlc_raw_eth.c
7372 ++++ b/drivers/net/wan/hdlc_raw_eth.c
7373 +@@ -99,6 +99,7 @@ static int raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr)
7374 + old_qlen = dev->tx_queue_len;
7375 + ether_setup(dev);
7376 + dev->tx_queue_len = old_qlen;
7377 ++ dev->priv_flags &= ~IFF_TX_SKB_SHARING;
7378 + eth_hw_addr_random(dev);
7379 + call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
7380 + netif_dormant_off(dev);
7381 +diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
7382 +index eca87f7c5b6c1..01e05af5ae085 100644
7383 +--- a/drivers/net/wireless/ath/ath10k/ce.c
7384 ++++ b/drivers/net/wireless/ath/ath10k/ce.c
7385 +@@ -1555,7 +1555,7 @@ ath10k_ce_alloc_src_ring(struct ath10k *ar, unsigned int ce_id,
7386 + ret = ath10k_ce_alloc_shadow_base(ar, src_ring, nentries);
7387 + if (ret) {
7388 + dma_free_coherent(ar->dev,
7389 +- (nentries * sizeof(struct ce_desc_64) +
7390 ++ (nentries * sizeof(struct ce_desc) +
7391 + CE_DESC_RING_ALIGN),
7392 + src_ring->base_addr_owner_space_unaligned,
7393 + base_addr);
7394 +diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
7395 +index 9f0e7b4943ec6..8ca0a808a644d 100644
7396 +--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
7397 ++++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
7398 +@@ -142,6 +142,14 @@ static int __ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num)
7399 + BUILD_BUG_ON(HTT_RX_RING_FILL_LEVEL >= HTT_RX_RING_SIZE / 2);
7400 +
7401 + idx = __le32_to_cpu(*htt->rx_ring.alloc_idx.vaddr);
7402 ++
7403 ++ if (idx < 0 || idx >= htt->rx_ring.size) {
7404 ++ ath10k_err(htt->ar, "rx ring index is not valid, firmware malfunctioning?\n");
7405 ++ idx &= htt->rx_ring.size_mask;
7406 ++ ret = -ENOMEM;
7407 ++ goto fail;
7408 ++ }
7409 ++
7410 + while (num > 0) {
7411 + skb = dev_alloc_skb(HTT_RX_BUF_SIZE + HTT_RX_DESC_ALIGN);
7412 + if (!skb) {
7413 +diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
7414 +index d373602a80145..915ba2a7f7448 100644
7415 +--- a/drivers/net/wireless/ath/ath10k/mac.c
7416 ++++ b/drivers/net/wireless/ath/ath10k/mac.c
7417 +@@ -7131,7 +7131,7 @@ ath10k_mac_update_bss_chan_survey(struct ath10k *ar,
7418 + struct ieee80211_channel *channel)
7419 + {
7420 + int ret;
7421 +- enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ_CLEAR;
7422 ++ enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ;
7423 +
7424 + lockdep_assert_held(&ar->conf_mutex);
7425 +
7426 +diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c
7427 +index 5e7ea838a9218..814131a0680a4 100644
7428 +--- a/drivers/net/wireless/ath/ath6kl/main.c
7429 ++++ b/drivers/net/wireless/ath/ath6kl/main.c
7430 +@@ -430,6 +430,9 @@ void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr,
7431 +
7432 + ath6kl_dbg(ATH6KL_DBG_TRC, "new station %pM aid=%d\n", mac_addr, aid);
7433 +
7434 ++ if (aid < 1 || aid > AP_MAX_NUM_STA)
7435 ++ return;
7436 ++
7437 + if (assoc_req_len > sizeof(struct ieee80211_hdr_3addr)) {
7438 + struct ieee80211_mgmt *mgmt =
7439 + (struct ieee80211_mgmt *) assoc_info;
7440 +diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c
7441 +index 2382c6c46851e..c610fe21c85c0 100644
7442 +--- a/drivers/net/wireless/ath/ath6kl/wmi.c
7443 ++++ b/drivers/net/wireless/ath/ath6kl/wmi.c
7444 +@@ -2645,6 +2645,11 @@ int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class,
7445 + return -EINVAL;
7446 + }
7447 +
7448 ++ if (tsid >= 16) {
7449 ++ ath6kl_err("invalid tsid: %d\n", tsid);
7450 ++ return -EINVAL;
7451 ++ }
7452 ++
7453 + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
7454 + if (!skb)
7455 + return -ENOMEM;
7456 +diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
7457 +index 3f563e02d17da..2ed98aaed6fb5 100644
7458 +--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
7459 ++++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
7460 +@@ -449,10 +449,19 @@ static void hif_usb_stop(void *hif_handle)
7461 + spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
7462 +
7463 + /* The pending URBs have to be canceled. */
7464 ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
7465 + list_for_each_entry_safe(tx_buf, tx_buf_tmp,
7466 + &hif_dev->tx.tx_pending, list) {
7467 ++ usb_get_urb(tx_buf->urb);
7468 ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
7469 + usb_kill_urb(tx_buf->urb);
7470 ++ list_del(&tx_buf->list);
7471 ++ usb_free_urb(tx_buf->urb);
7472 ++ kfree(tx_buf->buf);
7473 ++ kfree(tx_buf);
7474 ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
7475 + }
7476 ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
7477 +
7478 + usb_kill_anchored_urbs(&hif_dev->mgmt_submitted);
7479 + }
7480 +@@ -762,27 +771,37 @@ static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
7481 + struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL;
7482 + unsigned long flags;
7483 +
7484 ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
7485 + list_for_each_entry_safe(tx_buf, tx_buf_tmp,
7486 + &hif_dev->tx.tx_buf, list) {
7487 ++ usb_get_urb(tx_buf->urb);
7488 ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
7489 + usb_kill_urb(tx_buf->urb);
7490 + list_del(&tx_buf->list);
7491 + usb_free_urb(tx_buf->urb);
7492 + kfree(tx_buf->buf);
7493 + kfree(tx_buf);
7494 ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
7495 + }
7496 ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
7497 +
7498 + spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
7499 + hif_dev->tx.flags |= HIF_USB_TX_FLUSH;
7500 + spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
7501 +
7502 ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
7503 + list_for_each_entry_safe(tx_buf, tx_buf_tmp,
7504 + &hif_dev->tx.tx_pending, list) {
7505 ++ usb_get_urb(tx_buf->urb);
7506 ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
7507 + usb_kill_urb(tx_buf->urb);
7508 + list_del(&tx_buf->list);
7509 + usb_free_urb(tx_buf->urb);
7510 + kfree(tx_buf->buf);
7511 + kfree(tx_buf);
7512 ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
7513 + }
7514 ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
7515 +
7516 + usb_kill_anchored_urbs(&hif_dev->mgmt_submitted);
7517 + }
7518 +diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
7519 +index d2e062eaf5614..510e61e97dbcb 100644
7520 +--- a/drivers/net/wireless/ath/ath9k/htc_hst.c
7521 ++++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
7522 +@@ -339,6 +339,8 @@ void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
7523 +
7524 + if (skb) {
7525 + htc_hdr = (struct htc_frame_hdr *) skb->data;
7526 ++ if (htc_hdr->endpoint_id >= ARRAY_SIZE(htc_handle->endpoint))
7527 ++ goto ret;
7528 + endpoint = &htc_handle->endpoint[htc_hdr->endpoint_id];
7529 + skb_pull(skb, sizeof(struct htc_frame_hdr));
7530 +
7531 +diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
7532 +index ad051f34e65b2..46ae4ec4ad47d 100644
7533 +--- a/drivers/net/wireless/ath/wcn36xx/main.c
7534 ++++ b/drivers/net/wireless/ath/wcn36xx/main.c
7535 +@@ -163,7 +163,7 @@ static struct ieee80211_supported_band wcn_band_5ghz = {
7536 + .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
7537 + .mcs = {
7538 + .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
7539 +- .rx_highest = cpu_to_le16(72),
7540 ++ .rx_highest = cpu_to_le16(150),
7541 + .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
7542 + }
7543 + }
7544 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
7545 +index 85cf96461ddeb..e9bb8dbdc9aa8 100644
7546 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
7547 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
7548 +@@ -483,7 +483,7 @@ static int brcmf_rx_hdrpull(struct brcmf_pub *drvr, struct sk_buff *skb,
7549 + ret = brcmf_proto_hdrpull(drvr, true, skb, ifp);
7550 +
7551 + if (ret || !(*ifp) || !(*ifp)->ndev) {
7552 +- if (ret != -ENODATA && *ifp)
7553 ++ if (ret != -ENODATA && *ifp && (*ifp)->ndev)
7554 + (*ifp)->ndev->stats.rx_errors++;
7555 + brcmu_pkt_buf_free_skb(skb);
7556 + return -ENODATA;
7557 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
7558 +index e3dd8623be4ec..c2705d7a4247e 100644
7559 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
7560 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
7561 +@@ -1619,6 +1619,8 @@ fail:
7562 + BRCMF_TX_IOCTL_MAX_MSG_SIZE,
7563 + msgbuf->ioctbuf,
7564 + msgbuf->ioctbuf_handle);
7565 ++ if (msgbuf->txflow_wq)
7566 ++ destroy_workqueue(msgbuf->txflow_wq);
7567 + kfree(msgbuf);
7568 + }
7569 + return -ENOMEM;
7570 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
7571 +index 7ef36234a25dc..66797dc5e90d5 100644
7572 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
7573 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
7574 +@@ -5065,8 +5065,10 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi)
7575 + pi->pi_fptr.radioloftget = wlc_lcnphy_get_radio_loft;
7576 + pi->pi_fptr.detach = wlc_phy_detach_lcnphy;
7577 +
7578 +- if (!wlc_phy_txpwr_srom_read_lcnphy(pi))
7579 ++ if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) {
7580 ++ kfree(pi->u.pi_lcnphy);
7581 + return false;
7582 ++ }
7583 +
7584 + if (LCNREV_IS(pi->pubpi.phy_rev, 1)) {
7585 + if (pi_lcn->lcnphy_tempsense_option == 3) {
7586 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
7587 +index ed92a8e8cd519..01b26b3327b01 100644
7588 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
7589 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
7590 +@@ -3650,9 +3650,12 @@ static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm,
7591 + tail->apply_time_max_delay = cpu_to_le32(delay);
7592 +
7593 + IWL_DEBUG_TE(mvm,
7594 +- "ROC: Requesting to remain on channel %u for %ums (requested = %ums, max_delay = %ums, dtim_interval = %ums)\n",
7595 +- channel->hw_value, req_dur, duration, delay,
7596 +- dtim_interval);
7597 ++ "ROC: Requesting to remain on channel %u for %ums\n",
7598 ++ channel->hw_value, req_dur);
7599 ++ IWL_DEBUG_TE(mvm,
7600 ++ "\t(requested = %ums, max_delay = %ums, dtim_interval = %ums)\n",
7601 ++ duration, delay, dtim_interval);
7602 ++
7603 + /* Set the node address */
7604 + memcpy(tail->node_addr, vif->addr, ETH_ALEN);
7605 +
7606 +diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
7607 +index 59f0651d148bb..629af26675cf1 100644
7608 +--- a/drivers/net/wireless/marvell/mwifiex/scan.c
7609 ++++ b/drivers/net/wireless/marvell/mwifiex/scan.c
7610 +@@ -1891,7 +1891,7 @@ mwifiex_parse_single_response_buf(struct mwifiex_private *priv, u8 **bss_info,
7611 + chan, CFG80211_BSS_FTYPE_UNKNOWN,
7612 + bssid, timestamp,
7613 + cap_info_bitmap, beacon_period,
7614 +- ie_buf, ie_len, rssi, GFP_KERNEL);
7615 ++ ie_buf, ie_len, rssi, GFP_ATOMIC);
7616 + if (bss) {
7617 + bss_priv = (struct mwifiex_bss_priv *)bss->priv;
7618 + bss_priv->band = band;
7619 +diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
7620 +index fec38b6e86ffd..b322c2755e9a4 100644
7621 +--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
7622 ++++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
7623 +@@ -1996,6 +1996,8 @@ error:
7624 + kfree(card->mpa_rx.buf);
7625 + card->mpa_tx.buf_size = 0;
7626 + card->mpa_rx.buf_size = 0;
7627 ++ card->mpa_tx.buf = NULL;
7628 ++ card->mpa_rx.buf = NULL;
7629 + }
7630 +
7631 + return ret;
7632 +diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
7633 +index c2365eeb70168..528107d70c1cb 100644
7634 +--- a/drivers/net/wireless/marvell/mwifiex/usb.c
7635 ++++ b/drivers/net/wireless/marvell/mwifiex/usb.c
7636 +@@ -1353,7 +1353,8 @@ static void mwifiex_usb_cleanup_tx_aggr(struct mwifiex_adapter *adapter)
7637 + skb_dequeue(&port->tx_aggr.aggr_list)))
7638 + mwifiex_write_data_complete(adapter, skb_tmp,
7639 + 0, -1);
7640 +- del_timer_sync(&port->tx_aggr.timer_cnxt.hold_timer);
7641 ++ if (port->tx_aggr.timer_cnxt.hold_timer.function)
7642 ++ del_timer_sync(&port->tx_aggr.timer_cnxt.hold_timer);
7643 + port->tx_aggr.timer_cnxt.is_hold_timer_set = false;
7644 + port->tx_aggr.timer_cnxt.hold_tmo_msecs = 0;
7645 + }
7646 +diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c
7647 +index c0c32805fb8de..106f1a846f499 100644
7648 +--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
7649 ++++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
7650 +@@ -834,6 +834,7 @@ int qtnf_cmd_send_del_intf(struct qtnf_vif *vif)
7651 + default:
7652 + pr_warn("VIF%u.%u: unsupported iftype %d\n", vif->mac->macid,
7653 + vif->vifid, vif->wdev.iftype);
7654 ++ dev_kfree_skb(cmd_skb);
7655 + ret = -EINVAL;
7656 + goto out;
7657 + }
7658 +@@ -1996,6 +1997,7 @@ int qtnf_cmd_send_change_sta(struct qtnf_vif *vif, const u8 *mac,
7659 + break;
7660 + default:
7661 + pr_err("unsupported iftype %d\n", vif->wdev.iftype);
7662 ++ dev_kfree_skb(cmd_skb);
7663 + ret = -EINVAL;
7664 + goto out;
7665 + }
7666 +diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
7667 +index 3499b211dad51..048984ca81fdb 100644
7668 +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
7669 ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
7670 +@@ -5447,7 +5447,6 @@ static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw)
7671 + ret = usb_submit_urb(urb, GFP_KERNEL);
7672 + if (ret) {
7673 + usb_unanchor_urb(urb);
7674 +- usb_free_urb(urb);
7675 + goto error;
7676 + }
7677 +
7678 +@@ -5456,6 +5455,7 @@ static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw)
7679 + rtl8xxxu_write32(priv, REG_USB_HIMR, val32);
7680 +
7681 + error:
7682 ++ usb_free_urb(urb);
7683 + return ret;
7684 + }
7685 +
7686 +@@ -5781,6 +5781,7 @@ static int rtl8xxxu_start(struct ieee80211_hw *hw)
7687 + struct rtl8xxxu_priv *priv = hw->priv;
7688 + struct rtl8xxxu_rx_urb *rx_urb;
7689 + struct rtl8xxxu_tx_urb *tx_urb;
7690 ++ struct sk_buff *skb;
7691 + unsigned long flags;
7692 + int ret, i;
7693 +
7694 +@@ -5831,6 +5832,13 @@ static int rtl8xxxu_start(struct ieee80211_hw *hw)
7695 + rx_urb->hw = hw;
7696 +
7697 + ret = rtl8xxxu_submit_rx_urb(priv, rx_urb);
7698 ++ if (ret) {
7699 ++ if (ret != -ENOMEM) {
7700 ++ skb = (struct sk_buff *)rx_urb->urb.context;
7701 ++ dev_kfree_skb(skb);
7702 ++ }
7703 ++ rtl8xxxu_queue_rx_urb(priv, rx_urb);
7704 ++ }
7705 + }
7706 + exit:
7707 + /*
7708 +diff --git a/drivers/net/wireless/realtek/rtw88/pci.h b/drivers/net/wireless/realtek/rtw88/pci.h
7709 +index 87824a4caba98..a47d871ae506a 100644
7710 +--- a/drivers/net/wireless/realtek/rtw88/pci.h
7711 ++++ b/drivers/net/wireless/realtek/rtw88/pci.h
7712 +@@ -13,8 +13,8 @@
7713 + #define RTK_BEQ_TX_DESC_NUM 256
7714 +
7715 + #define RTK_MAX_RX_DESC_NUM 512
7716 +-/* 8K + rx desc size */
7717 +-#define RTK_PCI_RX_BUF_SIZE (8192 + 24)
7718 ++/* 11K + rx desc size */
7719 ++#define RTK_PCI_RX_BUF_SIZE (11454 + 24)
7720 +
7721 + #define RTK_PCI_CTRL 0x300
7722 + #define BIT_RST_TRXDMA_INTF BIT(20)
7723 +diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
7724 +index 156c2a18a2394..abb37659de343 100644
7725 +--- a/drivers/ntb/hw/amd/ntb_hw_amd.c
7726 ++++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
7727 +@@ -1036,6 +1036,7 @@ static int amd_ntb_init_pci(struct amd_ntb_dev *ndev,
7728 +
7729 + err_dma_mask:
7730 + pci_clear_master(pdev);
7731 ++ pci_release_regions(pdev);
7732 + err_pci_regions:
7733 + pci_disable_device(pdev);
7734 + err_pci_enable:
7735 +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
7736 +index af0b51d1d43e8..f5d12bf109c78 100644
7737 +--- a/drivers/nvme/host/pci.c
7738 ++++ b/drivers/nvme/host/pci.c
7739 +@@ -3110,7 +3110,8 @@ static const struct pci_device_id nvme_id_table[] = {
7740 + NVME_QUIRK_DEALLOCATE_ZEROES, },
7741 + { PCI_VDEVICE(INTEL, 0xf1a5), /* Intel 600P/P3100 */
7742 + .driver_data = NVME_QUIRK_NO_DEEPEST_PS |
7743 +- NVME_QUIRK_MEDIUM_PRIO_SQ },
7744 ++ NVME_QUIRK_MEDIUM_PRIO_SQ |
7745 ++ NVME_QUIRK_DISABLE_WRITE_ZEROES, },
7746 + { PCI_VDEVICE(INTEL, 0xf1a6), /* Intel 760p/Pro 7600p */
7747 + .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, },
7748 + { PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */
7749 +diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
7750 +index 7d7176369edf7..6b2f1e290fa73 100644
7751 +--- a/drivers/nvme/target/core.c
7752 ++++ b/drivers/nvme/target/core.c
7753 +@@ -1048,7 +1048,8 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)
7754 + * in case a host died before it enabled the controller. Hence, simply
7755 + * reset the keep alive timer when the controller is enabled.
7756 + */
7757 +- mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
7758 ++ if (ctrl->kato)
7759 ++ mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
7760 + }
7761 +
7762 + static void nvmet_clear_ctrl(struct nvmet_ctrl *ctrl)
7763 +diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
7764 +index 960542dea5adb..84f4078216a36 100644
7765 +--- a/drivers/nvmem/core.c
7766 ++++ b/drivers/nvmem/core.c
7767 +@@ -130,16 +130,14 @@ static void nvmem_cell_add(struct nvmem_cell *cell)
7768 + blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_ADD, cell);
7769 + }
7770 +
7771 +-static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem,
7772 +- const struct nvmem_cell_info *info,
7773 +- struct nvmem_cell *cell)
7774 ++static int nvmem_cell_info_to_nvmem_cell_nodup(struct nvmem_device *nvmem,
7775 ++ const struct nvmem_cell_info *info,
7776 ++ struct nvmem_cell *cell)
7777 + {
7778 + cell->nvmem = nvmem;
7779 + cell->offset = info->offset;
7780 + cell->bytes = info->bytes;
7781 +- cell->name = kstrdup_const(info->name, GFP_KERNEL);
7782 +- if (!cell->name)
7783 +- return -ENOMEM;
7784 ++ cell->name = info->name;
7785 +
7786 + cell->bit_offset = info->bit_offset;
7787 + cell->nbits = info->nbits;
7788 +@@ -151,13 +149,30 @@ static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem,
7789 + if (!IS_ALIGNED(cell->offset, nvmem->stride)) {
7790 + dev_err(&nvmem->dev,
7791 + "cell %s unaligned to nvmem stride %d\n",
7792 +- cell->name, nvmem->stride);
7793 ++ cell->name ?: "<unknown>", nvmem->stride);
7794 + return -EINVAL;
7795 + }
7796 +
7797 + return 0;
7798 + }
7799 +
7800 ++static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem,
7801 ++ const struct nvmem_cell_info *info,
7802 ++ struct nvmem_cell *cell)
7803 ++{
7804 ++ int err;
7805 ++
7806 ++ err = nvmem_cell_info_to_nvmem_cell_nodup(nvmem, info, cell);
7807 ++ if (err)
7808 ++ return err;
7809 ++
7810 ++ cell->name = kstrdup_const(info->name, GFP_KERNEL);
7811 ++ if (!cell->name)
7812 ++ return -ENOMEM;
7813 ++
7814 ++ return 0;
7815 ++}
7816 ++
7817 + /**
7818 + * nvmem_add_cells() - Add cell information to an nvmem device
7819 + *
7820 +@@ -1174,7 +1189,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
7821 + if (!nvmem)
7822 + return -EINVAL;
7823 +
7824 +- rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
7825 ++ rc = nvmem_cell_info_to_nvmem_cell_nodup(nvmem, info, &cell);
7826 + if (rc)
7827 + return rc;
7828 +
7829 +@@ -1204,7 +1219,7 @@ int nvmem_device_cell_write(struct nvmem_device *nvmem,
7830 + if (!nvmem)
7831 + return -EINVAL;
7832 +
7833 +- rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
7834 ++ rc = nvmem_cell_info_to_nvmem_cell_nodup(nvmem, info, &cell);
7835 + if (rc)
7836 + return rc;
7837 +
7838 +diff --git a/drivers/opp/core.c b/drivers/opp/core.c
7839 +index 29dfaa591f8b0..8867bab72e171 100644
7840 +--- a/drivers/opp/core.c
7841 ++++ b/drivers/opp/core.c
7842 +@@ -1796,6 +1796,9 @@ static void _opp_detach_genpd(struct opp_table *opp_table)
7843 + {
7844 + int index;
7845 +
7846 ++ if (!opp_table->genpd_virt_devs)
7847 ++ return;
7848 ++
7849 + for (index = 0; index < opp_table->required_opp_count; index++) {
7850 + if (!opp_table->genpd_virt_devs[index])
7851 + continue;
7852 +@@ -1842,6 +1845,9 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev,
7853 + if (!opp_table)
7854 + return ERR_PTR(-ENOMEM);
7855 +
7856 ++ if (opp_table->genpd_virt_devs)
7857 ++ return opp_table;
7858 ++
7859 + /*
7860 + * If the genpd's OPP table isn't already initialized, parsing of the
7861 + * required-opps fail for dev. We should retry this after genpd's OPP
7862 +diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
7863 +index f2481e80e2723..d0e60441dc8f2 100644
7864 +--- a/drivers/pci/controller/pci-aardvark.c
7865 ++++ b/drivers/pci/controller/pci-aardvark.c
7866 +@@ -503,7 +503,7 @@ static struct pci_bridge_emul_ops advk_pci_bridge_emul_ops = {
7867 + * Initialize the configuration space of the PCI-to-PCI bridge
7868 + * associated with the given PCIe interface.
7869 + */
7870 +-static void advk_sw_pci_bridge_init(struct advk_pcie *pcie)
7871 ++static int advk_sw_pci_bridge_init(struct advk_pcie *pcie)
7872 + {
7873 + struct pci_bridge_emul *bridge = &pcie->bridge;
7874 +
7875 +@@ -527,8 +527,7 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie)
7876 + bridge->data = pcie;
7877 + bridge->ops = &advk_pci_bridge_emul_ops;
7878 +
7879 +- pci_bridge_emul_init(bridge, 0);
7880 +-
7881 ++ return pci_bridge_emul_init(bridge, 0);
7882 + }
7883 +
7884 + static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus,
7885 +@@ -1027,7 +1026,11 @@ static int advk_pcie_probe(struct platform_device *pdev)
7886 +
7887 + advk_pcie_setup_hw(pcie);
7888 +
7889 +- advk_sw_pci_bridge_init(pcie);
7890 ++ ret = advk_sw_pci_bridge_init(pcie);
7891 ++ if (ret) {
7892 ++ dev_err(dev, "Failed to register emulated root PCI bridge\n");
7893 ++ return ret;
7894 ++ }
7895 +
7896 + ret = advk_pcie_init_irq_domain(pcie);
7897 + if (ret) {
7898 +diff --git a/drivers/pci/controller/pcie-iproc-msi.c b/drivers/pci/controller/pcie-iproc-msi.c
7899 +index 0a3f61be5625b..a1298f6784ac9 100644
7900 +--- a/drivers/pci/controller/pcie-iproc-msi.c
7901 ++++ b/drivers/pci/controller/pcie-iproc-msi.c
7902 +@@ -209,15 +209,20 @@ static int iproc_msi_irq_set_affinity(struct irq_data *data,
7903 + struct iproc_msi *msi = irq_data_get_irq_chip_data(data);
7904 + int target_cpu = cpumask_first(mask);
7905 + int curr_cpu;
7906 ++ int ret;
7907 +
7908 + curr_cpu = hwirq_to_cpu(msi, data->hwirq);
7909 + if (curr_cpu == target_cpu)
7910 +- return IRQ_SET_MASK_OK_DONE;
7911 ++ ret = IRQ_SET_MASK_OK_DONE;
7912 ++ else {
7913 ++ /* steer MSI to the target CPU */
7914 ++ data->hwirq = hwirq_to_canonical_hwirq(msi, data->hwirq) + target_cpu;
7915 ++ ret = IRQ_SET_MASK_OK;
7916 ++ }
7917 +
7918 +- /* steer MSI to the target CPU */
7919 +- data->hwirq = hwirq_to_canonical_hwirq(msi, data->hwirq) + target_cpu;
7920 ++ irq_data_update_effective_affinity(data, cpumask_of(target_cpu));
7921 +
7922 +- return IRQ_SET_MASK_OK;
7923 ++ return ret;
7924 + }
7925 +
7926 + static void iproc_msi_irq_compose_msi_msg(struct irq_data *data,
7927 +diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
7928 +index 9c116cbaa95d8..e15220385666f 100644
7929 +--- a/drivers/pci/iov.c
7930 ++++ b/drivers/pci/iov.c
7931 +@@ -158,6 +158,7 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id)
7932 + virtfn->device = iov->vf_device;
7933 + virtfn->is_virtfn = 1;
7934 + virtfn->physfn = pci_dev_get(dev);
7935 ++ virtfn->no_command_memory = 1;
7936 +
7937 + if (id == 0)
7938 + pci_read_vf_config_common(virtfn);
7939 +diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c
7940 +index 9e1c3c7eeba9b..170ccb164c604 100644
7941 +--- a/drivers/perf/thunderx2_pmu.c
7942 ++++ b/drivers/perf/thunderx2_pmu.c
7943 +@@ -627,14 +627,17 @@ static struct tx2_uncore_pmu *tx2_uncore_pmu_init_dev(struct device *dev,
7944 + list_for_each_entry(rentry, &list, node) {
7945 + if (resource_type(rentry->res) == IORESOURCE_MEM) {
7946 + res = *rentry->res;
7947 ++ rentry = NULL;
7948 + break;
7949 + }
7950 + }
7951 ++ acpi_dev_free_resource_list(&list);
7952 +
7953 +- if (!rentry->res)
7954 ++ if (rentry) {
7955 ++ dev_err(dev, "PMU type %d: Fail to find resource\n", type);
7956 + return NULL;
7957 ++ }
7958 +
7959 +- acpi_dev_free_resource_list(&list);
7960 + base = devm_ioremap_resource(dev, &res);
7961 + if (IS_ERR(base)) {
7962 + dev_err(dev, "PMU type %d: Fail to map resource\n", type);
7963 +diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c
7964 +index 328aea9f6be32..50b37f8f5c7ff 100644
7965 +--- a/drivers/perf/xgene_pmu.c
7966 ++++ b/drivers/perf/xgene_pmu.c
7967 +@@ -1459,17 +1459,6 @@ static char *xgene_pmu_dev_name(struct device *dev, u32 type, int id)
7968 + }
7969 +
7970 + #if defined(CONFIG_ACPI)
7971 +-static int acpi_pmu_dev_add_resource(struct acpi_resource *ares, void *data)
7972 +-{
7973 +- struct resource *res = data;
7974 +-
7975 +- if (ares->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32)
7976 +- acpi_dev_resource_memory(ares, res);
7977 +-
7978 +- /* Always tell the ACPI core to skip this resource */
7979 +- return 1;
7980 +-}
7981 +-
7982 + static struct
7983 + xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu,
7984 + struct acpi_device *adev, u32 type)
7985 +@@ -1481,6 +1470,7 @@ xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu,
7986 + struct hw_pmu_info *inf;
7987 + void __iomem *dev_csr;
7988 + struct resource res;
7989 ++ struct resource_entry *rentry;
7990 + int enable_bit;
7991 + int rc;
7992 +
7993 +@@ -1489,11 +1479,23 @@ xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu,
7994 + return NULL;
7995 +
7996 + INIT_LIST_HEAD(&resource_list);
7997 +- rc = acpi_dev_get_resources(adev, &resource_list,
7998 +- acpi_pmu_dev_add_resource, &res);
7999 ++ rc = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
8000 ++ if (rc <= 0) {
8001 ++ dev_err(dev, "PMU type %d: No resources found\n", type);
8002 ++ return NULL;
8003 ++ }
8004 ++
8005 ++ list_for_each_entry(rentry, &resource_list, node) {
8006 ++ if (resource_type(rentry->res) == IORESOURCE_MEM) {
8007 ++ res = *rentry->res;
8008 ++ rentry = NULL;
8009 ++ break;
8010 ++ }
8011 ++ }
8012 + acpi_dev_free_resource_list(&resource_list);
8013 +- if (rc < 0) {
8014 +- dev_err(dev, "PMU type %d: No resource address found\n", type);
8015 ++
8016 ++ if (rentry) {
8017 ++ dev_err(dev, "PMU type %d: No memory resource found\n", type);
8018 + return NULL;
8019 + }
8020 +
8021 +diff --git a/drivers/pinctrl/bcm/Kconfig b/drivers/pinctrl/bcm/Kconfig
8022 +index dcf7df797af75..0ed14de0134cf 100644
8023 +--- a/drivers/pinctrl/bcm/Kconfig
8024 ++++ b/drivers/pinctrl/bcm/Kconfig
8025 +@@ -23,6 +23,7 @@ config PINCTRL_BCM2835
8026 + select PINMUX
8027 + select PINCONF
8028 + select GENERIC_PINCONF
8029 ++ select GPIOLIB
8030 + select GPIOLIB_IRQCHIP
8031 + default ARCH_BCM2835 || ARCH_BRCMSTB
8032 + help
8033 +diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
8034 +index 3a235487e38d7..d8bcbefcba890 100644
8035 +--- a/drivers/pinctrl/pinctrl-mcp23s08.c
8036 ++++ b/drivers/pinctrl/pinctrl-mcp23s08.c
8037 +@@ -122,7 +122,7 @@ static const struct regmap_config mcp23x08_regmap = {
8038 + .max_register = MCP_OLAT,
8039 + };
8040 +
8041 +-static const struct reg_default mcp23x16_defaults[] = {
8042 ++static const struct reg_default mcp23x17_defaults[] = {
8043 + {.reg = MCP_IODIR << 1, .def = 0xffff},
8044 + {.reg = MCP_IPOL << 1, .def = 0x0000},
8045 + {.reg = MCP_GPINTEN << 1, .def = 0x0000},
8046 +@@ -133,23 +133,23 @@ static const struct reg_default mcp23x16_defaults[] = {
8047 + {.reg = MCP_OLAT << 1, .def = 0x0000},
8048 + };
8049 +
8050 +-static const struct regmap_range mcp23x16_volatile_range = {
8051 ++static const struct regmap_range mcp23x17_volatile_range = {
8052 + .range_min = MCP_INTF << 1,
8053 + .range_max = MCP_GPIO << 1,
8054 + };
8055 +
8056 +-static const struct regmap_access_table mcp23x16_volatile_table = {
8057 +- .yes_ranges = &mcp23x16_volatile_range,
8058 ++static const struct regmap_access_table mcp23x17_volatile_table = {
8059 ++ .yes_ranges = &mcp23x17_volatile_range,
8060 + .n_yes_ranges = 1,
8061 + };
8062 +
8063 +-static const struct regmap_range mcp23x16_precious_range = {
8064 +- .range_min = MCP_GPIO << 1,
8065 ++static const struct regmap_range mcp23x17_precious_range = {
8066 ++ .range_min = MCP_INTCAP << 1,
8067 + .range_max = MCP_GPIO << 1,
8068 + };
8069 +
8070 +-static const struct regmap_access_table mcp23x16_precious_table = {
8071 +- .yes_ranges = &mcp23x16_precious_range,
8072 ++static const struct regmap_access_table mcp23x17_precious_table = {
8073 ++ .yes_ranges = &mcp23x17_precious_range,
8074 + .n_yes_ranges = 1,
8075 + };
8076 +
8077 +@@ -159,10 +159,10 @@ static const struct regmap_config mcp23x17_regmap = {
8078 +
8079 + .reg_stride = 2,
8080 + .max_register = MCP_OLAT << 1,
8081 +- .volatile_table = &mcp23x16_volatile_table,
8082 +- .precious_table = &mcp23x16_precious_table,
8083 +- .reg_defaults = mcp23x16_defaults,
8084 +- .num_reg_defaults = ARRAY_SIZE(mcp23x16_defaults),
8085 ++ .volatile_table = &mcp23x17_volatile_table,
8086 ++ .precious_table = &mcp23x17_precious_table,
8087 ++ .reg_defaults = mcp23x17_defaults,
8088 ++ .num_reg_defaults = ARRAY_SIZE(mcp23x17_defaults),
8089 + .cache_type = REGCACHE_FLAT,
8090 + .val_format_endian = REGMAP_ENDIAN_LITTLE,
8091 + };
8092 +diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c
8093 +index 8fe51e43f1bc1..59b5b7eebb05a 100644
8094 +--- a/drivers/platform/x86/mlx-platform.c
8095 ++++ b/drivers/platform/x86/mlx-platform.c
8096 +@@ -243,15 +243,6 @@ static struct i2c_board_info mlxplat_mlxcpld_psu[] = {
8097 + },
8098 + };
8099 +
8100 +-static struct i2c_board_info mlxplat_mlxcpld_ng_psu[] = {
8101 +- {
8102 +- I2C_BOARD_INFO("24c32", 0x51),
8103 +- },
8104 +- {
8105 +- I2C_BOARD_INFO("24c32", 0x50),
8106 +- },
8107 +-};
8108 +-
8109 + static struct i2c_board_info mlxplat_mlxcpld_pwr[] = {
8110 + {
8111 + I2C_BOARD_INFO("dps460", 0x59),
8112 +@@ -611,15 +602,13 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_psu_items_data[] = {
8113 + .label = "psu1",
8114 + .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
8115 + .mask = BIT(0),
8116 +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_psu[0],
8117 +- .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR,
8118 ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
8119 + },
8120 + {
8121 + .label = "psu2",
8122 + .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
8123 + .mask = BIT(1),
8124 +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_psu[1],
8125 +- .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR,
8126 ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
8127 + },
8128 + };
8129 +
8130 +diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
8131 +index 599a0f66a3845..a34d95ed70b20 100644
8132 +--- a/drivers/pwm/pwm-img.c
8133 ++++ b/drivers/pwm/pwm-img.c
8134 +@@ -277,6 +277,8 @@ static int img_pwm_probe(struct platform_device *pdev)
8135 + return PTR_ERR(pwm->pwm_clk);
8136 + }
8137 +
8138 ++ platform_set_drvdata(pdev, pwm);
8139 ++
8140 + pm_runtime_set_autosuspend_delay(&pdev->dev, IMG_PWM_PM_TIMEOUT);
8141 + pm_runtime_use_autosuspend(&pdev->dev);
8142 + pm_runtime_enable(&pdev->dev);
8143 +@@ -313,7 +315,6 @@ static int img_pwm_probe(struct platform_device *pdev)
8144 + goto err_suspend;
8145 + }
8146 +
8147 +- platform_set_drvdata(pdev, pwm);
8148 + return 0;
8149 +
8150 + err_suspend:
8151 +diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c
8152 +index 75bbfe5f3bc29..d77cec2769b76 100644
8153 +--- a/drivers/pwm/pwm-lpss.c
8154 ++++ b/drivers/pwm/pwm-lpss.c
8155 +@@ -93,10 +93,12 @@ static void pwm_lpss_prepare(struct pwm_lpss_chip *lpwm, struct pwm_device *pwm,
8156 + * The equation is:
8157 + * base_unit = round(base_unit_range * freq / c)
8158 + */
8159 +- base_unit_range = BIT(lpwm->info->base_unit_bits) - 1;
8160 ++ base_unit_range = BIT(lpwm->info->base_unit_bits);
8161 + freq *= base_unit_range;
8162 +
8163 + base_unit = DIV_ROUND_CLOSEST_ULL(freq, c);
8164 ++ /* base_unit must not be 0 and we also want to avoid overflowing it */
8165 ++ base_unit = clamp_val(base_unit, 1, base_unit_range - 1);
8166 +
8167 + on_time_div = 255ULL * duty_ns;
8168 + do_div(on_time_div, period_ns);
8169 +@@ -104,8 +106,7 @@ static void pwm_lpss_prepare(struct pwm_lpss_chip *lpwm, struct pwm_device *pwm,
8170 +
8171 + orig_ctrl = ctrl = pwm_lpss_read(pwm);
8172 + ctrl &= ~PWM_ON_TIME_DIV_MASK;
8173 +- ctrl &= ~(base_unit_range << PWM_BASE_UNIT_SHIFT);
8174 +- base_unit &= base_unit_range;
8175 ++ ctrl &= ~((base_unit_range - 1) << PWM_BASE_UNIT_SHIFT);
8176 + ctrl |= (u32) base_unit << PWM_BASE_UNIT_SHIFT;
8177 + ctrl |= on_time_div;
8178 +
8179 +diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
8180 +index 0b85a80ae7ef6..2b08fdeb87c18 100644
8181 +--- a/drivers/rapidio/devices/rio_mport_cdev.c
8182 ++++ b/drivers/rapidio/devices/rio_mport_cdev.c
8183 +@@ -873,15 +873,16 @@ rio_dma_transfer(struct file *filp, u32 transfer_mode,
8184 + rmcd_error("get_user_pages_unlocked err=%ld",
8185 + pinned);
8186 + nr_pages = 0;
8187 +- } else
8188 ++ } else {
8189 + rmcd_error("pinned %ld out of %ld pages",
8190 + pinned, nr_pages);
8191 ++ /*
8192 ++ * Set nr_pages up to mean "how many pages to unpin, in
8193 ++ * the error handler:
8194 ++ */
8195 ++ nr_pages = pinned;
8196 ++ }
8197 + ret = -EFAULT;
8198 +- /*
8199 +- * Set nr_pages up to mean "how many pages to unpin, in
8200 +- * the error handler:
8201 +- */
8202 +- nr_pages = pinned;
8203 + goto err_pg;
8204 + }
8205 +
8206 +@@ -1682,6 +1683,7 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,
8207 + struct rio_dev *rdev;
8208 + struct rio_switch *rswitch = NULL;
8209 + struct rio_mport *mport;
8210 ++ struct device *dev;
8211 + size_t size;
8212 + u32 rval;
8213 + u32 swpinfo = 0;
8214 +@@ -1696,8 +1698,10 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,
8215 + rmcd_debug(RDEV, "name:%s ct:0x%x did:0x%x hc:0x%x", dev_info.name,
8216 + dev_info.comptag, dev_info.destid, dev_info.hopcount);
8217 +
8218 +- if (bus_find_device_by_name(&rio_bus_type, NULL, dev_info.name)) {
8219 ++ dev = bus_find_device_by_name(&rio_bus_type, NULL, dev_info.name);
8220 ++ if (dev) {
8221 + rmcd_debug(RDEV, "device %s already exists", dev_info.name);
8222 ++ put_device(dev);
8223 + return -EEXIST;
8224 + }
8225 +
8226 +diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
8227 +index 55fc80de5ef16..ee850cffe1542 100644
8228 +--- a/drivers/regulator/core.c
8229 ++++ b/drivers/regulator/core.c
8230 +@@ -5158,15 +5158,20 @@ regulator_register(const struct regulator_desc *regulator_desc,
8231 + else if (regulator_desc->supply_name)
8232 + rdev->supply_name = regulator_desc->supply_name;
8233 +
8234 +- /*
8235 +- * Attempt to resolve the regulator supply, if specified,
8236 +- * but don't return an error if we fail because we will try
8237 +- * to resolve it again later as more regulators are added.
8238 +- */
8239 +- if (regulator_resolve_supply(rdev))
8240 +- rdev_dbg(rdev, "unable to resolve supply\n");
8241 +-
8242 + ret = set_machine_constraints(rdev, constraints);
8243 ++ if (ret == -EPROBE_DEFER) {
8244 ++ /* Regulator might be in bypass mode and so needs its supply
8245 ++ * to set the constraints */
8246 ++ /* FIXME: this currently triggers a chicken-and-egg problem
8247 ++ * when creating -SUPPLY symlink in sysfs to a regulator
8248 ++ * that is just being created */
8249 ++ ret = regulator_resolve_supply(rdev);
8250 ++ if (!ret)
8251 ++ ret = set_machine_constraints(rdev, constraints);
8252 ++ else
8253 ++ rdev_dbg(rdev, "unable to resolve supply early: %pe\n",
8254 ++ ERR_PTR(ret));
8255 ++ }
8256 + if (ret < 0)
8257 + goto wash;
8258 +
8259 +diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
8260 +index 4abbeea782fa4..19903de6268db 100644
8261 +--- a/drivers/rpmsg/qcom_smd.c
8262 ++++ b/drivers/rpmsg/qcom_smd.c
8263 +@@ -1338,7 +1338,7 @@ static int qcom_smd_parse_edge(struct device *dev,
8264 + ret = of_property_read_u32(node, key, &edge->edge_id);
8265 + if (ret) {
8266 + dev_err(dev, "edge missing %s property\n", key);
8267 +- return -EINVAL;
8268 ++ goto put_node;
8269 + }
8270 +
8271 + edge->remote_pid = QCOM_SMEM_HOST_ANY;
8272 +@@ -1349,32 +1349,37 @@ static int qcom_smd_parse_edge(struct device *dev,
8273 + edge->mbox_client.knows_txdone = true;
8274 + edge->mbox_chan = mbox_request_channel(&edge->mbox_client, 0);
8275 + if (IS_ERR(edge->mbox_chan)) {
8276 +- if (PTR_ERR(edge->mbox_chan) != -ENODEV)
8277 +- return PTR_ERR(edge->mbox_chan);
8278 ++ if (PTR_ERR(edge->mbox_chan) != -ENODEV) {
8279 ++ ret = PTR_ERR(edge->mbox_chan);
8280 ++ goto put_node;
8281 ++ }
8282 +
8283 + edge->mbox_chan = NULL;
8284 +
8285 + syscon_np = of_parse_phandle(node, "qcom,ipc", 0);
8286 + if (!syscon_np) {
8287 + dev_err(dev, "no qcom,ipc node\n");
8288 +- return -ENODEV;
8289 ++ ret = -ENODEV;
8290 ++ goto put_node;
8291 + }
8292 +
8293 + edge->ipc_regmap = syscon_node_to_regmap(syscon_np);
8294 +- if (IS_ERR(edge->ipc_regmap))
8295 +- return PTR_ERR(edge->ipc_regmap);
8296 ++ if (IS_ERR(edge->ipc_regmap)) {
8297 ++ ret = PTR_ERR(edge->ipc_regmap);
8298 ++ goto put_node;
8299 ++ }
8300 +
8301 + key = "qcom,ipc";
8302 + ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset);
8303 + if (ret < 0) {
8304 + dev_err(dev, "no offset in %s\n", key);
8305 +- return -EINVAL;
8306 ++ goto put_node;
8307 + }
8308 +
8309 + ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit);
8310 + if (ret < 0) {
8311 + dev_err(dev, "no bit in %s\n", key);
8312 +- return -EINVAL;
8313 ++ goto put_node;
8314 + }
8315 + }
8316 +
8317 +@@ -1385,7 +1390,8 @@ static int qcom_smd_parse_edge(struct device *dev,
8318 + irq = irq_of_parse_and_map(node, 0);
8319 + if (irq < 0) {
8320 + dev_err(dev, "required smd interrupt missing\n");
8321 +- return -EINVAL;
8322 ++ ret = irq;
8323 ++ goto put_node;
8324 + }
8325 +
8326 + ret = devm_request_irq(dev, irq,
8327 +@@ -1393,12 +1399,18 @@ static int qcom_smd_parse_edge(struct device *dev,
8328 + node->name, edge);
8329 + if (ret) {
8330 + dev_err(dev, "failed to request smd irq\n");
8331 +- return ret;
8332 ++ goto put_node;
8333 + }
8334 +
8335 + edge->irq = irq;
8336 +
8337 + return 0;
8338 ++
8339 ++put_node:
8340 ++ of_node_put(node);
8341 ++ edge->of_node = NULL;
8342 ++
8343 ++ return ret;
8344 + }
8345 +
8346 + /*
8347 +diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
8348 +index 4ce28aa490cdb..8c4613617ef11 100644
8349 +--- a/drivers/s390/net/qeth_l2_main.c
8350 ++++ b/drivers/s390/net/qeth_l2_main.c
8351 +@@ -1168,12 +1168,6 @@ static void qeth_bridge_state_change_worker(struct work_struct *work)
8352 + NULL
8353 + };
8354 +
8355 +- /* Role should not change by itself, but if it did, */
8356 +- /* information from the hardware is authoritative. */
8357 +- mutex_lock(&data->card->sbp_lock);
8358 +- data->card->options.sbp.role = entry->role;
8359 +- mutex_unlock(&data->card->sbp_lock);
8360 +-
8361 + snprintf(env_locrem, sizeof(env_locrem), "BRIDGEPORT=statechange");
8362 + snprintf(env_role, sizeof(env_role), "ROLE=%s",
8363 + (entry->role == QETH_SBP_ROLE_NONE) ? "none" :
8364 +diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
8365 +index 0760d0bd8a10b..0fa455357594e 100644
8366 +--- a/drivers/scsi/be2iscsi/be_main.c
8367 ++++ b/drivers/scsi/be2iscsi/be_main.c
8368 +@@ -3020,6 +3020,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
8369 + goto create_eq_error;
8370 + }
8371 +
8372 ++ mem->dma = paddr;
8373 + mem->va = eq_vaddress;
8374 + ret = be_fill_queue(eq, phba->params.num_eq_entries,
8375 + sizeof(struct be_eq_entry), eq_vaddress);
8376 +@@ -3029,7 +3030,6 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
8377 + goto create_eq_error;
8378 + }
8379 +
8380 +- mem->dma = paddr;
8381 + ret = beiscsi_cmd_eq_create(&phba->ctrl, eq,
8382 + BEISCSI_EQ_DELAY_DEF);
8383 + if (ret) {
8384 +@@ -3086,6 +3086,7 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
8385 + goto create_cq_error;
8386 + }
8387 +
8388 ++ mem->dma = paddr;
8389 + ret = be_fill_queue(cq, phba->params.num_cq_entries,
8390 + sizeof(struct sol_cqe), cq_vaddress);
8391 + if (ret) {
8392 +@@ -3095,7 +3096,6 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
8393 + goto create_cq_error;
8394 + }
8395 +
8396 +- mem->dma = paddr;
8397 + ret = beiscsi_cmd_cq_create(&phba->ctrl, cq, eq, false,
8398 + false, 0);
8399 + if (ret) {
8400 +diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
8401 +index 2f9213b257a4a..93e4011809919 100644
8402 +--- a/drivers/scsi/bfa/bfad.c
8403 ++++ b/drivers/scsi/bfa/bfad.c
8404 +@@ -749,6 +749,7 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
8405 +
8406 + if (bfad->pci_bar0_kva == NULL) {
8407 + printk(KERN_ERR "Fail to map bar0\n");
8408 ++ rc = -ENODEV;
8409 + goto out_release_region;
8410 + }
8411 +
8412 +diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c
8413 +index e519238864758..1b6f9351b43f9 100644
8414 +--- a/drivers/scsi/csiostor/csio_hw.c
8415 ++++ b/drivers/scsi/csiostor/csio_hw.c
8416 +@@ -2384,7 +2384,7 @@ static int csio_hw_prep_fw(struct csio_hw *hw, struct fw_info *fw_info,
8417 + FW_HDR_FW_VER_MICRO_G(c), FW_HDR_FW_VER_BUILD_G(c),
8418 + FW_HDR_FW_VER_MAJOR_G(k), FW_HDR_FW_VER_MINOR_G(k),
8419 + FW_HDR_FW_VER_MICRO_G(k), FW_HDR_FW_VER_BUILD_G(k));
8420 +- ret = EINVAL;
8421 ++ ret = -EINVAL;
8422 + goto bye;
8423 + }
8424 +
8425 +diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
8426 +index df897df5cafee..8a76284b59b08 100644
8427 +--- a/drivers/scsi/ibmvscsi/ibmvfc.c
8428 ++++ b/drivers/scsi/ibmvscsi/ibmvfc.c
8429 +@@ -4788,6 +4788,7 @@ static int ibmvfc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
8430 + if (IS_ERR(vhost->work_thread)) {
8431 + dev_err(dev, "Couldn't create kernel thread: %ld\n",
8432 + PTR_ERR(vhost->work_thread));
8433 ++ rc = PTR_ERR(vhost->work_thread);
8434 + goto free_host_mem;
8435 + }
8436 +
8437 +diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
8438 +index b7e44634d0dc2..3d58d24de6b61 100644
8439 +--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
8440 ++++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
8441 +@@ -1708,18 +1708,22 @@ mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc)
8442 + /* TMs are on msix_index == 0 */
8443 + if (reply_q->msix_index == 0)
8444 + continue;
8445 ++ synchronize_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index));
8446 + if (reply_q->irq_poll_scheduled) {
8447 + /* Calling irq_poll_disable will wait for any pending
8448 + * callbacks to have completed.
8449 + */
8450 + irq_poll_disable(&reply_q->irqpoll);
8451 + irq_poll_enable(&reply_q->irqpoll);
8452 +- reply_q->irq_poll_scheduled = false;
8453 +- reply_q->irq_line_enable = true;
8454 +- enable_irq(reply_q->os_irq);
8455 +- continue;
8456 ++ /* check how the scheduled poll has ended,
8457 ++ * clean up only if necessary
8458 ++ */
8459 ++ if (reply_q->irq_poll_scheduled) {
8460 ++ reply_q->irq_poll_scheduled = false;
8461 ++ reply_q->irq_line_enable = true;
8462 ++ enable_irq(reply_q->os_irq);
8463 ++ }
8464 + }
8465 +- synchronize_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index));
8466 + }
8467 + }
8468 +
8469 +diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
8470 +index 8906aceda4c43..0354898d7cac1 100644
8471 +--- a/drivers/scsi/mvumi.c
8472 ++++ b/drivers/scsi/mvumi.c
8473 +@@ -2425,6 +2425,7 @@ static int mvumi_io_attach(struct mvumi_hba *mhba)
8474 + if (IS_ERR(mhba->dm_thread)) {
8475 + dev_err(&mhba->pdev->dev,
8476 + "failed to create device scan thread\n");
8477 ++ ret = PTR_ERR(mhba->dm_thread);
8478 + mutex_unlock(&mhba->sas_discovery_mutex);
8479 + goto fail_create_thread;
8480 + }
8481 +diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
8482 +index 3d0e345947c1f..9c0955c334e3e 100644
8483 +--- a/drivers/scsi/qedf/qedf_main.c
8484 ++++ b/drivers/scsi/qedf/qedf_main.c
8485 +@@ -668,7 +668,7 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd)
8486 + rdata = fcport->rdata;
8487 + if (!rdata || !kref_get_unless_zero(&rdata->kref)) {
8488 + QEDF_ERR(&qedf->dbg_ctx, "stale rport, sc_cmd=%p\n", sc_cmd);
8489 +- rc = 1;
8490 ++ rc = SUCCESS;
8491 + goto out;
8492 + }
8493 +
8494 +diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c
8495 +index 946cebc4c9322..90aa64604ad78 100644
8496 +--- a/drivers/scsi/qedi/qedi_fw.c
8497 ++++ b/drivers/scsi/qedi/qedi_fw.c
8498 +@@ -59,6 +59,7 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi,
8499 + "Freeing tid=0x%x for cid=0x%x\n",
8500 + cmd->task_id, qedi_conn->iscsi_conn_id);
8501 +
8502 ++ spin_lock(&qedi_conn->list_lock);
8503 + if (likely(cmd->io_cmd_in_list)) {
8504 + cmd->io_cmd_in_list = false;
8505 + list_del_init(&cmd->io_cmd);
8506 +@@ -69,6 +70,7 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi,
8507 + cmd->task_id, qedi_conn->iscsi_conn_id,
8508 + &cmd->io_cmd);
8509 + }
8510 ++ spin_unlock(&qedi_conn->list_lock);
8511 +
8512 + cmd->state = RESPONSE_RECEIVED;
8513 + qedi_clear_task_idx(qedi, cmd->task_id);
8514 +@@ -122,6 +124,7 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi,
8515 + "Freeing tid=0x%x for cid=0x%x\n",
8516 + cmd->task_id, qedi_conn->iscsi_conn_id);
8517 +
8518 ++ spin_lock(&qedi_conn->list_lock);
8519 + if (likely(cmd->io_cmd_in_list)) {
8520 + cmd->io_cmd_in_list = false;
8521 + list_del_init(&cmd->io_cmd);
8522 +@@ -132,6 +135,7 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi,
8523 + cmd->task_id, qedi_conn->iscsi_conn_id,
8524 + &cmd->io_cmd);
8525 + }
8526 ++ spin_unlock(&qedi_conn->list_lock);
8527 +
8528 + cmd->state = RESPONSE_RECEIVED;
8529 + qedi_clear_task_idx(qedi, cmd->task_id);
8530 +@@ -222,11 +226,13 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi,
8531 +
8532 + tmf_hdr = (struct iscsi_tm *)qedi_cmd->task->hdr;
8533 +
8534 ++ spin_lock(&qedi_conn->list_lock);
8535 + if (likely(qedi_cmd->io_cmd_in_list)) {
8536 + qedi_cmd->io_cmd_in_list = false;
8537 + list_del_init(&qedi_cmd->io_cmd);
8538 + qedi_conn->active_cmd_count--;
8539 + }
8540 ++ spin_unlock(&qedi_conn->list_lock);
8541 +
8542 + if (((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) ==
8543 + ISCSI_TM_FUNC_LOGICAL_UNIT_RESET) ||
8544 +@@ -288,11 +294,13 @@ static void qedi_process_login_resp(struct qedi_ctx *qedi,
8545 + ISCSI_LOGIN_RESPONSE_HDR_DATA_SEG_LEN_MASK;
8546 + qedi_conn->gen_pdu.resp_wr_ptr = qedi_conn->gen_pdu.resp_buf + pld_len;
8547 +
8548 ++ spin_lock(&qedi_conn->list_lock);
8549 + if (likely(cmd->io_cmd_in_list)) {
8550 + cmd->io_cmd_in_list = false;
8551 + list_del_init(&cmd->io_cmd);
8552 + qedi_conn->active_cmd_count--;
8553 + }
8554 ++ spin_unlock(&qedi_conn->list_lock);
8555 +
8556 + memset(task_ctx, '\0', sizeof(*task_ctx));
8557 +
8558 +@@ -817,8 +825,11 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi,
8559 + qedi_clear_task_idx(qedi_conn->qedi, rtid);
8560 +
8561 + spin_lock(&qedi_conn->list_lock);
8562 +- list_del_init(&dbg_cmd->io_cmd);
8563 +- qedi_conn->active_cmd_count--;
8564 ++ if (likely(dbg_cmd->io_cmd_in_list)) {
8565 ++ dbg_cmd->io_cmd_in_list = false;
8566 ++ list_del_init(&dbg_cmd->io_cmd);
8567 ++ qedi_conn->active_cmd_count--;
8568 ++ }
8569 + spin_unlock(&qedi_conn->list_lock);
8570 + qedi_cmd->state = CLEANUP_RECV;
8571 + wake_up_interruptible(&qedi_conn->wait_queue);
8572 +@@ -1236,6 +1247,7 @@ int qedi_cleanup_all_io(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn,
8573 + qedi_conn->cmd_cleanup_req++;
8574 + qedi_iscsi_cleanup_task(ctask, true);
8575 +
8576 ++ cmd->io_cmd_in_list = false;
8577 + list_del_init(&cmd->io_cmd);
8578 + qedi_conn->active_cmd_count--;
8579 + QEDI_WARN(&qedi->dbg_ctx,
8580 +@@ -1447,8 +1459,11 @@ ldel_exit:
8581 + spin_unlock_bh(&qedi_conn->tmf_work_lock);
8582 +
8583 + spin_lock(&qedi_conn->list_lock);
8584 +- list_del_init(&cmd->io_cmd);
8585 +- qedi_conn->active_cmd_count--;
8586 ++ if (likely(cmd->io_cmd_in_list)) {
8587 ++ cmd->io_cmd_in_list = false;
8588 ++ list_del_init(&cmd->io_cmd);
8589 ++ qedi_conn->active_cmd_count--;
8590 ++ }
8591 + spin_unlock(&qedi_conn->list_lock);
8592 +
8593 + clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags);
8594 +diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c
8595 +index 0f2622a48311c..755f66b1ff9c7 100644
8596 +--- a/drivers/scsi/qedi/qedi_iscsi.c
8597 ++++ b/drivers/scsi/qedi/qedi_iscsi.c
8598 +@@ -972,11 +972,13 @@ static void qedi_cleanup_active_cmd_list(struct qedi_conn *qedi_conn)
8599 + {
8600 + struct qedi_cmd *cmd, *cmd_tmp;
8601 +
8602 ++ spin_lock(&qedi_conn->list_lock);
8603 + list_for_each_entry_safe(cmd, cmd_tmp, &qedi_conn->active_cmd_list,
8604 + io_cmd) {
8605 + list_del_init(&cmd->io_cmd);
8606 + qedi_conn->active_cmd_count--;
8607 + }
8608 ++ spin_unlock(&qedi_conn->list_lock);
8609 + }
8610 +
8611 + static void qedi_ep_disconnect(struct iscsi_endpoint *ep)
8612 +diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
8613 +index 62d2ee825c97a..b300e11095828 100644
8614 +--- a/drivers/scsi/qla2xxx/qla_init.c
8615 ++++ b/drivers/scsi/qla2xxx/qla_init.c
8616 +@@ -71,6 +71,16 @@ void qla2x00_sp_free(srb_t *sp)
8617 + qla2x00_rel_sp(sp);
8618 + }
8619 +
8620 ++void qla2xxx_rel_done_warning(srb_t *sp, int res)
8621 ++{
8622 ++ WARN_ONCE(1, "Calling done() of an already freed srb %p object\n", sp);
8623 ++}
8624 ++
8625 ++void qla2xxx_rel_free_warning(srb_t *sp)
8626 ++{
8627 ++ WARN_ONCE(1, "Calling free() of an already freed srb %p object\n", sp);
8628 ++}
8629 ++
8630 + /* Asynchronous Login/Logout Routines -------------------------------------- */
8631 +
8632 + unsigned long
8633 +diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
8634 +index 0c3d907af7692..6dfde42d799b5 100644
8635 +--- a/drivers/scsi/qla2xxx/qla_inline.h
8636 ++++ b/drivers/scsi/qla2xxx/qla_inline.h
8637 +@@ -183,10 +183,15 @@ qla2xxx_get_qpair_sp(scsi_qla_host_t *vha, struct qla_qpair *qpair,
8638 + return sp;
8639 + }
8640 +
8641 ++void qla2xxx_rel_done_warning(srb_t *sp, int res);
8642 ++void qla2xxx_rel_free_warning(srb_t *sp);
8643 ++
8644 + static inline void
8645 + qla2xxx_rel_qpair_sp(struct qla_qpair *qpair, srb_t *sp)
8646 + {
8647 + sp->qpair = NULL;
8648 ++ sp->done = qla2xxx_rel_done_warning;
8649 ++ sp->free = qla2xxx_rel_free_warning;
8650 + mempool_free(sp, qpair->srb_mempool);
8651 + QLA_QPAIR_MARK_NOT_BUSY(qpair);
8652 + }
8653 +diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
8654 +index f4815a4084d8c..11656e864fca9 100644
8655 +--- a/drivers/scsi/qla2xxx/qla_nvme.c
8656 ++++ b/drivers/scsi/qla2xxx/qla_nvme.c
8657 +@@ -682,7 +682,7 @@ int qla_nvme_register_hba(struct scsi_qla_host *vha)
8658 + struct nvme_fc_port_template *tmpl;
8659 + struct qla_hw_data *ha;
8660 + struct nvme_fc_port_info pinfo;
8661 +- int ret = EINVAL;
8662 ++ int ret = -EINVAL;
8663 +
8664 + if (!IS_ENABLED(CONFIG_NVME_FC))
8665 + return ret;
8666 +diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
8667 +index a7acc266cec06..d84d95cac2a13 100644
8668 +--- a/drivers/scsi/qla2xxx/qla_target.c
8669 ++++ b/drivers/scsi/qla2xxx/qla_target.c
8670 +@@ -5677,7 +5677,7 @@ static int qlt_chk_unresolv_exchg(struct scsi_qla_host *vha,
8671 + /* found existing exchange */
8672 + qpair->retry_term_cnt++;
8673 + if (qpair->retry_term_cnt >= 5) {
8674 +- rc = EIO;
8675 ++ rc = -EIO;
8676 + qpair->retry_term_cnt = 0;
8677 + ql_log(ql_log_warn, vha, 0xffff,
8678 + "Unable to send ABTS Respond. Dumping firmware.\n");
8679 +diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
8680 +index 5504ab11decc7..df43cf6405a8e 100644
8681 +--- a/drivers/scsi/qla4xxx/ql4_os.c
8682 ++++ b/drivers/scsi/qla4xxx/ql4_os.c
8683 +@@ -1220,7 +1220,7 @@ static int qla4xxx_get_host_stats(struct Scsi_Host *shost, char *buf, int len)
8684 + le64_to_cpu(ql_iscsi_stats->iscsi_sequence_error);
8685 + exit_host_stats:
8686 + if (ql_iscsi_stats)
8687 +- dma_free_coherent(&ha->pdev->dev, host_stats_size,
8688 ++ dma_free_coherent(&ha->pdev->dev, stats_size,
8689 + ql_iscsi_stats, iscsi_stats_dma);
8690 +
8691 + ql4_printk(KERN_INFO, ha, "%s: Get host stats done\n",
8692 +diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
8693 +index 7a3a942b40df0..dd2175e9bfa17 100644
8694 +--- a/drivers/scsi/smartpqi/smartpqi.h
8695 ++++ b/drivers/scsi/smartpqi/smartpqi.h
8696 +@@ -357,7 +357,7 @@ struct pqi_event_response {
8697 + struct pqi_iu_header header;
8698 + u8 event_type;
8699 + u8 reserved2 : 7;
8700 +- u8 request_acknowlege : 1;
8701 ++ u8 request_acknowledge : 1;
8702 + __le16 event_id;
8703 + __le32 additional_event_id;
8704 + union {
8705 +diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
8706 +index 5ae074505386a..093ed5d1eef20 100644
8707 +--- a/drivers/scsi/smartpqi/smartpqi_init.c
8708 ++++ b/drivers/scsi/smartpqi/smartpqi_init.c
8709 +@@ -527,8 +527,7 @@ static int pqi_build_raid_path_request(struct pqi_ctrl_info *ctrl_info,
8710 + put_unaligned_be16(cdb_length, &cdb[7]);
8711 + break;
8712 + default:
8713 +- dev_err(&ctrl_info->pci_dev->dev, "unknown command 0x%c\n",
8714 +- cmd);
8715 ++ dev_err(&ctrl_info->pci_dev->dev, "unknown command 0x%c\n", cmd);
8716 + break;
8717 + }
8718 +
8719 +@@ -2450,7 +2449,6 @@ static int pqi_raid_bypass_submit_scsi_cmd(struct pqi_ctrl_info *ctrl_info,
8720 + offload_to_mirror =
8721 + (offload_to_mirror >= layout_map_count - 1) ?
8722 + 0 : offload_to_mirror + 1;
8723 +- WARN_ON(offload_to_mirror >= layout_map_count);
8724 + device->offload_to_mirror = offload_to_mirror;
8725 + /*
8726 + * Avoid direct use of device->offload_to_mirror within this
8727 +@@ -2903,10 +2901,14 @@ static int pqi_interpret_task_management_response(
8728 + return rc;
8729 + }
8730 +
8731 +-static unsigned int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info,
8732 +- struct pqi_queue_group *queue_group)
8733 ++static inline void pqi_invalid_response(struct pqi_ctrl_info *ctrl_info)
8734 ++{
8735 ++ pqi_take_ctrl_offline(ctrl_info);
8736 ++}
8737 ++
8738 ++static int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info, struct pqi_queue_group *queue_group)
8739 + {
8740 +- unsigned int num_responses;
8741 ++ int num_responses;
8742 + pqi_index_t oq_pi;
8743 + pqi_index_t oq_ci;
8744 + struct pqi_io_request *io_request;
8745 +@@ -2918,6 +2920,13 @@ static unsigned int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info,
8746 +
8747 + while (1) {
8748 + oq_pi = readl(queue_group->oq_pi);
8749 ++ if (oq_pi >= ctrl_info->num_elements_per_oq) {
8750 ++ pqi_invalid_response(ctrl_info);
8751 ++ dev_err(&ctrl_info->pci_dev->dev,
8752 ++ "I/O interrupt: producer index (%u) out of range (0-%u): consumer index: %u\n",
8753 ++ oq_pi, ctrl_info->num_elements_per_oq - 1, oq_ci);
8754 ++ return -1;
8755 ++ }
8756 + if (oq_pi == oq_ci)
8757 + break;
8758 +
8759 +@@ -2926,10 +2935,22 @@ static unsigned int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info,
8760 + (oq_ci * PQI_OPERATIONAL_OQ_ELEMENT_LENGTH);
8761 +
8762 + request_id = get_unaligned_le16(&response->request_id);
8763 +- WARN_ON(request_id >= ctrl_info->max_io_slots);
8764 ++ if (request_id >= ctrl_info->max_io_slots) {
8765 ++ pqi_invalid_response(ctrl_info);
8766 ++ dev_err(&ctrl_info->pci_dev->dev,
8767 ++ "request ID in response (%u) out of range (0-%u): producer index: %u consumer index: %u\n",
8768 ++ request_id, ctrl_info->max_io_slots - 1, oq_pi, oq_ci);
8769 ++ return -1;
8770 ++ }
8771 +
8772 + io_request = &ctrl_info->io_request_pool[request_id];
8773 +- WARN_ON(atomic_read(&io_request->refcount) == 0);
8774 ++ if (atomic_read(&io_request->refcount) == 0) {
8775 ++ pqi_invalid_response(ctrl_info);
8776 ++ dev_err(&ctrl_info->pci_dev->dev,
8777 ++ "request ID in response (%u) does not match an outstanding I/O request: producer index: %u consumer index: %u\n",
8778 ++ request_id, oq_pi, oq_ci);
8779 ++ return -1;
8780 ++ }
8781 +
8782 + switch (response->header.iu_type) {
8783 + case PQI_RESPONSE_IU_RAID_PATH_IO_SUCCESS:
8784 +@@ -2959,24 +2980,22 @@ static unsigned int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info,
8785 + io_request->error_info = ctrl_info->error_buffer +
8786 + (get_unaligned_le16(&response->error_index) *
8787 + PQI_ERROR_BUFFER_ELEMENT_LENGTH);
8788 +- pqi_process_io_error(response->header.iu_type,
8789 +- io_request);
8790 ++ pqi_process_io_error(response->header.iu_type, io_request);
8791 + break;
8792 + default:
8793 ++ pqi_invalid_response(ctrl_info);
8794 + dev_err(&ctrl_info->pci_dev->dev,
8795 +- "unexpected IU type: 0x%x\n",
8796 +- response->header.iu_type);
8797 +- break;
8798 ++ "unexpected IU type: 0x%x: producer index: %u consumer index: %u\n",
8799 ++ response->header.iu_type, oq_pi, oq_ci);
8800 ++ return -1;
8801 + }
8802 +
8803 +- io_request->io_complete_callback(io_request,
8804 +- io_request->context);
8805 ++ io_request->io_complete_callback(io_request, io_request->context);
8806 +
8807 + /*
8808 + * Note that the I/O request structure CANNOT BE TOUCHED after
8809 + * returning from the I/O completion callback!
8810 + */
8811 +-
8812 + oq_ci = (oq_ci + 1) % ctrl_info->num_elements_per_oq;
8813 + }
8814 +
8815 +@@ -3289,9 +3308,9 @@ static void pqi_ofa_capture_event_payload(struct pqi_event *event,
8816 + }
8817 + }
8818 +
8819 +-static unsigned int pqi_process_event_intr(struct pqi_ctrl_info *ctrl_info)
8820 ++static int pqi_process_event_intr(struct pqi_ctrl_info *ctrl_info)
8821 + {
8822 +- unsigned int num_events;
8823 ++ int num_events;
8824 + pqi_index_t oq_pi;
8825 + pqi_index_t oq_ci;
8826 + struct pqi_event_queue *event_queue;
8827 +@@ -3305,26 +3324,31 @@ static unsigned int pqi_process_event_intr(struct pqi_ctrl_info *ctrl_info)
8828 +
8829 + while (1) {
8830 + oq_pi = readl(event_queue->oq_pi);
8831 ++ if (oq_pi >= PQI_NUM_EVENT_QUEUE_ELEMENTS) {
8832 ++ pqi_invalid_response(ctrl_info);
8833 ++ dev_err(&ctrl_info->pci_dev->dev,
8834 ++ "event interrupt: producer index (%u) out of range (0-%u): consumer index: %u\n",
8835 ++ oq_pi, PQI_NUM_EVENT_QUEUE_ELEMENTS - 1, oq_ci);
8836 ++ return -1;
8837 ++ }
8838 ++
8839 + if (oq_pi == oq_ci)
8840 + break;
8841 +
8842 + num_events++;
8843 +- response = event_queue->oq_element_array +
8844 +- (oq_ci * PQI_EVENT_OQ_ELEMENT_LENGTH);
8845 ++ response = event_queue->oq_element_array + (oq_ci * PQI_EVENT_OQ_ELEMENT_LENGTH);
8846 +
8847 + event_index =
8848 + pqi_event_type_to_event_index(response->event_type);
8849 +
8850 +- if (event_index >= 0) {
8851 +- if (response->request_acknowlege) {
8852 +- event = &ctrl_info->events[event_index];
8853 +- event->pending = true;
8854 +- event->event_type = response->event_type;
8855 +- event->event_id = response->event_id;
8856 +- event->additional_event_id =
8857 +- response->additional_event_id;
8858 ++ if (event_index >= 0 && response->request_acknowledge) {
8859 ++ event = &ctrl_info->events[event_index];
8860 ++ event->pending = true;
8861 ++ event->event_type = response->event_type;
8862 ++ event->event_id = response->event_id;
8863 ++ event->additional_event_id = response->additional_event_id;
8864 ++ if (event->event_type == PQI_EVENT_TYPE_OFA)
8865 + pqi_ofa_capture_event_payload(event, response);
8866 +- }
8867 + }
8868 +
8869 + oq_ci = (oq_ci + 1) % PQI_NUM_EVENT_QUEUE_ELEMENTS;
8870 +@@ -3439,7 +3463,8 @@ static irqreturn_t pqi_irq_handler(int irq, void *data)
8871 + {
8872 + struct pqi_ctrl_info *ctrl_info;
8873 + struct pqi_queue_group *queue_group;
8874 +- unsigned int num_responses_handled;
8875 ++ int num_io_responses_handled;
8876 ++ int num_events_handled;
8877 +
8878 + queue_group = data;
8879 + ctrl_info = queue_group->ctrl_info;
8880 +@@ -3447,17 +3472,25 @@ static irqreturn_t pqi_irq_handler(int irq, void *data)
8881 + if (!pqi_is_valid_irq(ctrl_info))
8882 + return IRQ_NONE;
8883 +
8884 +- num_responses_handled = pqi_process_io_intr(ctrl_info, queue_group);
8885 ++ num_io_responses_handled = pqi_process_io_intr(ctrl_info, queue_group);
8886 ++ if (num_io_responses_handled < 0)
8887 ++ goto out;
8888 +
8889 +- if (irq == ctrl_info->event_irq)
8890 +- num_responses_handled += pqi_process_event_intr(ctrl_info);
8891 ++ if (irq == ctrl_info->event_irq) {
8892 ++ num_events_handled = pqi_process_event_intr(ctrl_info);
8893 ++ if (num_events_handled < 0)
8894 ++ goto out;
8895 ++ } else {
8896 ++ num_events_handled = 0;
8897 ++ }
8898 +
8899 +- if (num_responses_handled)
8900 ++ if (num_io_responses_handled + num_events_handled > 0)
8901 + atomic_inc(&ctrl_info->num_interrupts);
8902 +
8903 + pqi_start_io(ctrl_info, queue_group, RAID_PATH, NULL);
8904 + pqi_start_io(ctrl_info, queue_group, AIO_PATH, NULL);
8905 +
8906 ++out:
8907 + return IRQ_HANDLED;
8908 + }
8909 +
8910 +diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
8911 +index c49e9f6c46f87..4f066e3b19af1 100644
8912 +--- a/drivers/scsi/ufs/ufs-qcom.c
8913 ++++ b/drivers/scsi/ufs/ufs-qcom.c
8914 +@@ -1492,9 +1492,6 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host)
8915 + */
8916 + }
8917 + mask <<= offset;
8918 +-
8919 +- pm_runtime_get_sync(host->hba->dev);
8920 +- ufshcd_hold(host->hba, false);
8921 + ufshcd_rmwl(host->hba, TEST_BUS_SEL,
8922 + (u32)host->testbus.select_major << 19,
8923 + REG_UFS_CFG1);
8924 +@@ -1507,8 +1504,6 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host)
8925 + * committed before returning.
8926 + */
8927 + mb();
8928 +- ufshcd_release(host->hba);
8929 +- pm_runtime_put_sync(host->hba->dev);
8930 +
8931 + return 0;
8932 + }
8933 +diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c
8934 +index 63ee96eb58c68..130c798921b5d 100644
8935 +--- a/drivers/slimbus/core.c
8936 ++++ b/drivers/slimbus/core.c
8937 +@@ -302,8 +302,6 @@ int slim_unregister_controller(struct slim_controller *ctrl)
8938 + {
8939 + /* Remove all clients */
8940 + device_for_each_child(ctrl->dev, NULL, slim_ctrl_remove_device);
8941 +- /* Enter Clock Pause */
8942 +- slim_ctrl_clk_pause(ctrl, false, 0);
8943 + ida_simple_remove(&ctrl_ida, ctrl->id);
8944 +
8945 + return 0;
8946 +@@ -327,8 +325,8 @@ void slim_report_absent(struct slim_device *sbdev)
8947 + mutex_lock(&ctrl->lock);
8948 + sbdev->is_laddr_valid = false;
8949 + mutex_unlock(&ctrl->lock);
8950 +-
8951 +- ida_simple_remove(&ctrl->laddr_ida, sbdev->laddr);
8952 ++ if (!ctrl->get_laddr)
8953 ++ ida_simple_remove(&ctrl->laddr_ida, sbdev->laddr);
8954 + slim_device_update_status(sbdev, SLIM_DEVICE_STATUS_DOWN);
8955 + }
8956 + EXPORT_SYMBOL_GPL(slim_report_absent);
8957 +diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
8958 +index 01a17d84b6064..ce265bf7de868 100644
8959 +--- a/drivers/slimbus/qcom-ngd-ctrl.c
8960 ++++ b/drivers/slimbus/qcom-ngd-ctrl.c
8961 +@@ -1273,9 +1273,13 @@ static void qcom_slim_ngd_qmi_del_server(struct qmi_handle *hdl,
8962 + {
8963 + struct qcom_slim_ngd_qmi *qmi =
8964 + container_of(hdl, struct qcom_slim_ngd_qmi, svc_event_hdl);
8965 ++ struct qcom_slim_ngd_ctrl *ctrl =
8966 ++ container_of(qmi, struct qcom_slim_ngd_ctrl, qmi);
8967 +
8968 + qmi->svc_info.sq_node = 0;
8969 + qmi->svc_info.sq_port = 0;
8970 ++
8971 ++ qcom_slim_ngd_enable(ctrl, false);
8972 + }
8973 +
8974 + static struct qmi_ops qcom_slim_ngd_qmi_svc_event_ops = {
8975 +diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c
8976 +index f4fb527d83018..c5dd026fe889f 100644
8977 +--- a/drivers/soc/fsl/qbman/bman.c
8978 ++++ b/drivers/soc/fsl/qbman/bman.c
8979 +@@ -660,7 +660,7 @@ int bm_shutdown_pool(u32 bpid)
8980 + }
8981 + done:
8982 + put_affine_portal();
8983 +- return 0;
8984 ++ return err;
8985 + }
8986 +
8987 + struct gen_pool *bm_bpalloc;
8988 +diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
8989 +index 4433cb4de564e..7646b4b56bed9 100644
8990 +--- a/drivers/spi/spi-omap2-mcspi.c
8991 ++++ b/drivers/spi/spi-omap2-mcspi.c
8992 +@@ -24,7 +24,6 @@
8993 + #include <linux/of.h>
8994 + #include <linux/of_device.h>
8995 + #include <linux/gcd.h>
8996 +-#include <linux/iopoll.h>
8997 +
8998 + #include <linux/spi/spi.h>
8999 + #include <linux/gpio.h>
9000 +@@ -348,9 +347,19 @@ disable_fifo:
9001 +
9002 + static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit)
9003 + {
9004 +- u32 val;
9005 +-
9006 +- return readl_poll_timeout(reg, val, val & bit, 1, MSEC_PER_SEC);
9007 ++ unsigned long timeout;
9008 ++
9009 ++ timeout = jiffies + msecs_to_jiffies(1000);
9010 ++ while (!(readl_relaxed(reg) & bit)) {
9011 ++ if (time_after(jiffies, timeout)) {
9012 ++ if (!(readl_relaxed(reg) & bit))
9013 ++ return -ETIMEDOUT;
9014 ++ else
9015 ++ return 0;
9016 ++ }
9017 ++ cpu_relax();
9018 ++ }
9019 ++ return 0;
9020 + }
9021 +
9022 + static int mcspi_wait_for_completion(struct omap2_mcspi *mcspi,
9023 +diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
9024 +index 7b7151ec14c8a..1d948fee1a039 100644
9025 +--- a/drivers/spi/spi-s3c64xx.c
9026 ++++ b/drivers/spi/spi-s3c64xx.c
9027 +@@ -122,6 +122,7 @@
9028 +
9029 + struct s3c64xx_spi_dma_data {
9030 + struct dma_chan *ch;
9031 ++ dma_cookie_t cookie;
9032 + enum dma_transfer_direction direction;
9033 + };
9034 +
9035 +@@ -264,12 +265,13 @@ static void s3c64xx_spi_dmacb(void *data)
9036 + spin_unlock_irqrestore(&sdd->lock, flags);
9037 + }
9038 +
9039 +-static void prepare_dma(struct s3c64xx_spi_dma_data *dma,
9040 ++static int prepare_dma(struct s3c64xx_spi_dma_data *dma,
9041 + struct sg_table *sgt)
9042 + {
9043 + struct s3c64xx_spi_driver_data *sdd;
9044 + struct dma_slave_config config;
9045 + struct dma_async_tx_descriptor *desc;
9046 ++ int ret;
9047 +
9048 + memset(&config, 0, sizeof(config));
9049 +
9050 +@@ -293,12 +295,24 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma,
9051 +
9052 + desc = dmaengine_prep_slave_sg(dma->ch, sgt->sgl, sgt->nents,
9053 + dma->direction, DMA_PREP_INTERRUPT);
9054 ++ if (!desc) {
9055 ++ dev_err(&sdd->pdev->dev, "unable to prepare %s scatterlist",
9056 ++ dma->direction == DMA_DEV_TO_MEM ? "rx" : "tx");
9057 ++ return -ENOMEM;
9058 ++ }
9059 +
9060 + desc->callback = s3c64xx_spi_dmacb;
9061 + desc->callback_param = dma;
9062 +
9063 +- dmaengine_submit(desc);
9064 ++ dma->cookie = dmaengine_submit(desc);
9065 ++ ret = dma_submit_error(dma->cookie);
9066 ++ if (ret) {
9067 ++ dev_err(&sdd->pdev->dev, "DMA submission failed");
9068 ++ return -EIO;
9069 ++ }
9070 ++
9071 + dma_async_issue_pending(dma->ch);
9072 ++ return 0;
9073 + }
9074 +
9075 + static void s3c64xx_spi_set_cs(struct spi_device *spi, bool enable)
9076 +@@ -348,11 +362,12 @@ static bool s3c64xx_spi_can_dma(struct spi_master *master,
9077 + return xfer->len > (FIFO_LVL_MASK(sdd) >> 1) + 1;
9078 + }
9079 +
9080 +-static void s3c64xx_enable_datapath(struct s3c64xx_spi_driver_data *sdd,
9081 ++static int s3c64xx_enable_datapath(struct s3c64xx_spi_driver_data *sdd,
9082 + struct spi_transfer *xfer, int dma_mode)
9083 + {
9084 + void __iomem *regs = sdd->regs;
9085 + u32 modecfg, chcfg;
9086 ++ int ret = 0;
9087 +
9088 + modecfg = readl(regs + S3C64XX_SPI_MODE_CFG);
9089 + modecfg &= ~(S3C64XX_SPI_MODE_TXDMA_ON | S3C64XX_SPI_MODE_RXDMA_ON);
9090 +@@ -378,7 +393,7 @@ static void s3c64xx_enable_datapath(struct s3c64xx_spi_driver_data *sdd,
9091 + chcfg |= S3C64XX_SPI_CH_TXCH_ON;
9092 + if (dma_mode) {
9093 + modecfg |= S3C64XX_SPI_MODE_TXDMA_ON;
9094 +- prepare_dma(&sdd->tx_dma, &xfer->tx_sg);
9095 ++ ret = prepare_dma(&sdd->tx_dma, &xfer->tx_sg);
9096 + } else {
9097 + switch (sdd->cur_bpw) {
9098 + case 32:
9099 +@@ -410,12 +425,17 @@ static void s3c64xx_enable_datapath(struct s3c64xx_spi_driver_data *sdd,
9100 + writel(((xfer->len * 8 / sdd->cur_bpw) & 0xffff)
9101 + | S3C64XX_SPI_PACKET_CNT_EN,
9102 + regs + S3C64XX_SPI_PACKET_CNT);
9103 +- prepare_dma(&sdd->rx_dma, &xfer->rx_sg);
9104 ++ ret = prepare_dma(&sdd->rx_dma, &xfer->rx_sg);
9105 + }
9106 + }
9107 +
9108 ++ if (ret)
9109 ++ return ret;
9110 ++
9111 + writel(modecfg, regs + S3C64XX_SPI_MODE_CFG);
9112 + writel(chcfg, regs + S3C64XX_SPI_CH_CFG);
9113 ++
9114 ++ return 0;
9115 + }
9116 +
9117 + static u32 s3c64xx_spi_wait_for_timeout(struct s3c64xx_spi_driver_data *sdd,
9118 +@@ -548,9 +568,10 @@ static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd,
9119 + return 0;
9120 + }
9121 +
9122 +-static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
9123 ++static int s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
9124 + {
9125 + void __iomem *regs = sdd->regs;
9126 ++ int ret;
9127 + u32 val;
9128 +
9129 + /* Disable Clock */
9130 +@@ -598,7 +619,9 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
9131 +
9132 + if (sdd->port_conf->clk_from_cmu) {
9133 + /* The src_clk clock is divided internally by 2 */
9134 +- clk_set_rate(sdd->src_clk, sdd->cur_speed * 2);
9135 ++ ret = clk_set_rate(sdd->src_clk, sdd->cur_speed * 2);
9136 ++ if (ret)
9137 ++ return ret;
9138 + } else {
9139 + /* Configure Clock */
9140 + val = readl(regs + S3C64XX_SPI_CLK_CFG);
9141 +@@ -612,6 +635,8 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
9142 + val |= S3C64XX_SPI_ENCLK_ENABLE;
9143 + writel(val, regs + S3C64XX_SPI_CLK_CFG);
9144 + }
9145 ++
9146 ++ return 0;
9147 + }
9148 +
9149 + #define XFER_DMAADDR_INVALID DMA_BIT_MASK(32)
9150 +@@ -654,7 +679,9 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master,
9151 + sdd->cur_bpw = bpw;
9152 + sdd->cur_speed = speed;
9153 + sdd->cur_mode = spi->mode;
9154 +- s3c64xx_spi_config(sdd);
9155 ++ status = s3c64xx_spi_config(sdd);
9156 ++ if (status)
9157 ++ return status;
9158 + }
9159 +
9160 + if (!is_polling(sdd) && (xfer->len > fifo_len) &&
9161 +@@ -678,13 +705,18 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master,
9162 + sdd->state &= ~RXBUSY;
9163 + sdd->state &= ~TXBUSY;
9164 +
9165 +- s3c64xx_enable_datapath(sdd, xfer, use_dma);
9166 +-
9167 + /* Start the signals */
9168 + s3c64xx_spi_set_cs(spi, true);
9169 +
9170 ++ status = s3c64xx_enable_datapath(sdd, xfer, use_dma);
9171 ++
9172 + spin_unlock_irqrestore(&sdd->lock, flags);
9173 +
9174 ++ if (status) {
9175 ++ dev_err(&spi->dev, "failed to enable data path for transfer: %d\n", status);
9176 ++ break;
9177 ++ }
9178 ++
9179 + if (use_dma)
9180 + status = s3c64xx_wait_for_dma(sdd, xfer);
9181 + else
9182 +diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
9183 +index 147481bf680c3..a6c893ddbf280 100644
9184 +--- a/drivers/staging/emxx_udc/emxx_udc.c
9185 ++++ b/drivers/staging/emxx_udc/emxx_udc.c
9186 +@@ -2594,7 +2594,7 @@ static int nbu2ss_ep_queue(struct usb_ep *_ep,
9187 +
9188 + if (req->unaligned) {
9189 + if (!ep->virt_buf)
9190 +- ep->virt_buf = dma_alloc_coherent(NULL, PAGE_SIZE,
9191 ++ ep->virt_buf = dma_alloc_coherent(udc->dev, PAGE_SIZE,
9192 + &ep->phys_buf,
9193 + GFP_ATOMIC | GFP_DMA);
9194 + if (ep->epnum > 0) {
9195 +@@ -3153,7 +3153,7 @@ static int nbu2ss_drv_remove(struct platform_device *pdev)
9196 + for (i = 0; i < NUM_ENDPOINTS; i++) {
9197 + ep = &udc->ep[i];
9198 + if (ep->virt_buf)
9199 +- dma_free_coherent(NULL, PAGE_SIZE, (void *)ep->virt_buf,
9200 ++ dma_free_coherent(udc->dev, PAGE_SIZE, (void *)ep->virt_buf,
9201 + ep->phys_buf);
9202 + }
9203 +
9204 +diff --git a/drivers/staging/media/ipu3/ipu3-css-params.c b/drivers/staging/media/ipu3/ipu3-css-params.c
9205 +index 4533dacad4beb..ef3b5d07137a1 100644
9206 +--- a/drivers/staging/media/ipu3/ipu3-css-params.c
9207 ++++ b/drivers/staging/media/ipu3/ipu3-css-params.c
9208 +@@ -161,7 +161,7 @@ imgu_css_scaler_calc(u32 input_width, u32 input_height, u32 target_width,
9209 +
9210 + memset(&cfg->scaler_coeffs_chroma, 0,
9211 + sizeof(cfg->scaler_coeffs_chroma));
9212 +- memset(&cfg->scaler_coeffs_luma, 0, sizeof(*cfg->scaler_coeffs_luma));
9213 ++ memset(&cfg->scaler_coeffs_luma, 0, sizeof(cfg->scaler_coeffs_luma));
9214 + do {
9215 + phase_step_correction++;
9216 +
9217 +diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
9218 +index 5c33bcb0db2ee..00e34c392a388 100644
9219 +--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
9220 ++++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
9221 +@@ -585,7 +585,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
9222 +
9223 + prxbIndicateArray = kmalloc_array(REORDER_WIN_SIZE,
9224 + sizeof(struct ieee80211_rxb *),
9225 +- GFP_KERNEL);
9226 ++ GFP_ATOMIC);
9227 + if (!prxbIndicateArray)
9228 + return;
9229 +
9230 +diff --git a/drivers/staging/wilc1000/wilc_mon.c b/drivers/staging/wilc1000/wilc_mon.c
9231 +index d6f14f69ad64e..017e8e91334f1 100644
9232 +--- a/drivers/staging/wilc1000/wilc_mon.c
9233 ++++ b/drivers/staging/wilc1000/wilc_mon.c
9234 +@@ -236,11 +236,10 @@ struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,
9235 +
9236 + if (register_netdevice(wl->monitor_dev)) {
9237 + netdev_err(real_dev, "register_netdevice failed\n");
9238 ++ free_netdev(wl->monitor_dev);
9239 + return NULL;
9240 + }
9241 + priv = netdev_priv(wl->monitor_dev);
9242 +- if (!priv)
9243 +- return NULL;
9244 +
9245 + priv->real_ndev = real_dev;
9246 +
9247 +diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
9248 +index ea925b102b322..d6634baebb474 100644
9249 +--- a/drivers/target/target_core_user.c
9250 ++++ b/drivers/target/target_core_user.c
9251 +@@ -669,7 +669,7 @@ static void scatter_data_area(struct tcmu_dev *udev,
9252 + void *from, *to = NULL;
9253 + size_t copy_bytes, to_offset, offset;
9254 + struct scatterlist *sg;
9255 +- struct page *page;
9256 ++ struct page *page = NULL;
9257 +
9258 + for_each_sg(data_sg, sg, data_nents, i) {
9259 + int sg_remaining = sg->length;
9260 +diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
9261 +index ee0604cd9c6b2..0c498b20d8cb5 100644
9262 +--- a/drivers/tty/hvc/hvcs.c
9263 ++++ b/drivers/tty/hvc/hvcs.c
9264 +@@ -1218,13 +1218,6 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
9265 +
9266 + tty_wait_until_sent(tty, HVCS_CLOSE_WAIT);
9267 +
9268 +- /*
9269 +- * This line is important because it tells hvcs_open that this
9270 +- * device needs to be re-configured the next time hvcs_open is
9271 +- * called.
9272 +- */
9273 +- tty->driver_data = NULL;
9274 +-
9275 + free_irq(irq, hvcsd);
9276 + return;
9277 + } else if (hvcsd->port.count < 0) {
9278 +@@ -1239,6 +1232,13 @@ static void hvcs_cleanup(struct tty_struct * tty)
9279 + {
9280 + struct hvcs_struct *hvcsd = tty->driver_data;
9281 +
9282 ++ /*
9283 ++ * This line is important because it tells hvcs_open that this
9284 ++ * device needs to be re-configured the next time hvcs_open is
9285 ++ * called.
9286 ++ */
9287 ++ tty->driver_data = NULL;
9288 ++
9289 + tty_port_put(&hvcsd->port);
9290 + }
9291 +
9292 +diff --git a/drivers/tty/ipwireless/network.c b/drivers/tty/ipwireless/network.c
9293 +index cf20616340a1a..fe569f6294a24 100644
9294 +--- a/drivers/tty/ipwireless/network.c
9295 ++++ b/drivers/tty/ipwireless/network.c
9296 +@@ -117,7 +117,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
9297 + skb->len,
9298 + notify_packet_sent,
9299 + network);
9300 +- if (ret == -1) {
9301 ++ if (ret < 0) {
9302 + skb_pull(skb, 2);
9303 + return 0;
9304 + }
9305 +@@ -134,7 +134,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
9306 + notify_packet_sent,
9307 + network);
9308 + kfree(buf);
9309 +- if (ret == -1)
9310 ++ if (ret < 0)
9311 + return 0;
9312 + }
9313 + kfree_skb(skb);
9314 +diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
9315 +index fad3401e604d9..23584769fc292 100644
9316 +--- a/drivers/tty/ipwireless/tty.c
9317 ++++ b/drivers/tty/ipwireless/tty.c
9318 +@@ -218,7 +218,7 @@ static int ipw_write(struct tty_struct *linux_tty,
9319 + ret = ipwireless_send_packet(tty->hardware, IPW_CHANNEL_RAS,
9320 + buf, count,
9321 + ipw_write_packet_sent_callback, tty);
9322 +- if (ret == -1) {
9323 ++ if (ret < 0) {
9324 + mutex_unlock(&tty->ipw_tty_mutex);
9325 + return 0;
9326 + }
9327 +diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
9328 +index 00099a8439d21..c6a1d8c4e6894 100644
9329 +--- a/drivers/tty/pty.c
9330 ++++ b/drivers/tty/pty.c
9331 +@@ -120,10 +120,10 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
9332 + spin_lock_irqsave(&to->port->lock, flags);
9333 + /* Stuff the data into the input queue of the other end */
9334 + c = tty_insert_flip_string(to->port, buf, c);
9335 ++ spin_unlock_irqrestore(&to->port->lock, flags);
9336 + /* And shovel */
9337 + if (c)
9338 + tty_flip_buffer_push(to->port);
9339 +- spin_unlock_irqrestore(&to->port->lock, flags);
9340 + }
9341 + return c;
9342 + }
9343 +diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
9344 +index 67a9eb3f94cec..a9751a83d5dbb 100644
9345 +--- a/drivers/tty/serial/Kconfig
9346 ++++ b/drivers/tty/serial/Kconfig
9347 +@@ -10,6 +10,7 @@ menu "Serial drivers"
9348 +
9349 + config SERIAL_EARLYCON
9350 + bool
9351 ++ depends on SERIAL_CORE
9352 + help
9353 + Support for early consoles with the earlycon parameter. This enables
9354 + the console before standard serial driver is probed. The console is
9355 +diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
9356 +index d2fc050a34454..ec8e608b46baa 100644
9357 +--- a/drivers/tty/serial/fsl_lpuart.c
9358 ++++ b/drivers/tty/serial/fsl_lpuart.c
9359 +@@ -635,26 +635,24 @@ static int lpuart32_poll_init(struct uart_port *port)
9360 + spin_lock_irqsave(&sport->port.lock, flags);
9361 +
9362 + /* Disable Rx & Tx */
9363 +- lpuart32_write(&sport->port, UARTCTRL, 0);
9364 ++ lpuart32_write(&sport->port, 0, UARTCTRL);
9365 +
9366 + temp = lpuart32_read(&sport->port, UARTFIFO);
9367 +
9368 + /* Enable Rx and Tx FIFO */
9369 +- lpuart32_write(&sport->port, UARTFIFO,
9370 +- temp | UARTFIFO_RXFE | UARTFIFO_TXFE);
9371 ++ lpuart32_write(&sport->port, temp | UARTFIFO_RXFE | UARTFIFO_TXFE, UARTFIFO);
9372 +
9373 + /* flush Tx and Rx FIFO */
9374 +- lpuart32_write(&sport->port, UARTFIFO,
9375 +- UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH);
9376 ++ lpuart32_write(&sport->port, UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH, UARTFIFO);
9377 +
9378 + /* explicitly clear RDRF */
9379 + if (lpuart32_read(&sport->port, UARTSTAT) & UARTSTAT_RDRF) {
9380 + lpuart32_read(&sport->port, UARTDATA);
9381 +- lpuart32_write(&sport->port, UARTFIFO, UARTFIFO_RXUF);
9382 ++ lpuart32_write(&sport->port, UARTFIFO_RXUF, UARTFIFO);
9383 + }
9384 +
9385 + /* Enable Rx and Tx */
9386 +- lpuart32_write(&sport->port, UARTCTRL, UARTCTRL_RE | UARTCTRL_TE);
9387 ++ lpuart32_write(&sport->port, UARTCTRL_RE | UARTCTRL_TE, UARTCTRL);
9388 + spin_unlock_irqrestore(&sport->port.lock, flags);
9389 +
9390 + return 0;
9391 +@@ -663,12 +661,12 @@ static int lpuart32_poll_init(struct uart_port *port)
9392 + static void lpuart32_poll_put_char(struct uart_port *port, unsigned char c)
9393 + {
9394 + lpuart32_wait_bit_set(port, UARTSTAT, UARTSTAT_TDRE);
9395 +- lpuart32_write(port, UARTDATA, c);
9396 ++ lpuart32_write(port, c, UARTDATA);
9397 + }
9398 +
9399 + static int lpuart32_poll_get_char(struct uart_port *port)
9400 + {
9401 +- if (!(lpuart32_read(port, UARTSTAT) & UARTSTAT_RDRF))
9402 ++ if (!(lpuart32_read(port, UARTWATER) >> UARTWATER_RXCNT_OFF))
9403 + return NO_POLL_CHAR;
9404 +
9405 + return lpuart32_read(port, UARTDATA);
9406 +diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
9407 +index 9900888afbcd8..c0c39cf303871 100644
9408 +--- a/drivers/usb/cdns3/gadget.c
9409 ++++ b/drivers/usb/cdns3/gadget.c
9410 +@@ -2545,12 +2545,12 @@ void cdns3_gadget_exit(struct cdns3 *cdns)
9411 +
9412 + priv_dev = cdns->gadget_dev;
9413 +
9414 +- devm_free_irq(cdns->dev, cdns->dev_irq, priv_dev);
9415 +
9416 + pm_runtime_mark_last_busy(cdns->dev);
9417 + pm_runtime_put_autosuspend(cdns->dev);
9418 +
9419 + usb_del_gadget_udc(&priv_dev->gadget);
9420 ++ devm_free_irq(cdns->dev, cdns->dev_irq, priv_dev);
9421 +
9422 + cdns3_free_all_eps(priv_dev);
9423 +
9424 +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
9425 +index 7499ba118665a..808722b8294a4 100644
9426 +--- a/drivers/usb/class/cdc-acm.c
9427 ++++ b/drivers/usb/class/cdc-acm.c
9428 +@@ -1243,9 +1243,21 @@ static int acm_probe(struct usb_interface *intf,
9429 + }
9430 + }
9431 + } else {
9432 ++ int class = -1;
9433 ++
9434 + data_intf_num = union_header->bSlaveInterface0;
9435 + control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0);
9436 + data_interface = usb_ifnum_to_if(usb_dev, data_intf_num);
9437 ++
9438 ++ if (control_interface)
9439 ++ class = control_interface->cur_altsetting->desc.bInterfaceClass;
9440 ++
9441 ++ if (class != USB_CLASS_COMM && class != USB_CLASS_CDC_DATA) {
9442 ++ dev_dbg(&intf->dev, "Broken union descriptor, assuming single interface\n");
9443 ++ combined_interfaces = 1;
9444 ++ control_interface = data_interface = intf;
9445 ++ goto look_for_collapsed_interface;
9446 ++ }
9447 + }
9448 +
9449 + if (!control_interface || !data_interface) {
9450 +@@ -1900,6 +1912,17 @@ static const struct usb_device_id acm_ids[] = {
9451 + .driver_info = IGNORE_DEVICE,
9452 + },
9453 +
9454 ++ /* Exclude ETAS ES58x */
9455 ++ { USB_DEVICE(0x108c, 0x0159), /* ES581.4 */
9456 ++ .driver_info = IGNORE_DEVICE,
9457 ++ },
9458 ++ { USB_DEVICE(0x108c, 0x0168), /* ES582.1 */
9459 ++ .driver_info = IGNORE_DEVICE,
9460 ++ },
9461 ++ { USB_DEVICE(0x108c, 0x0169), /* ES584.1 */
9462 ++ .driver_info = IGNORE_DEVICE,
9463 ++ },
9464 ++
9465 + { USB_DEVICE(0x1bc7, 0x0021), /* Telit 3G ACM only composition */
9466 + .driver_info = SEND_ZERO_PACKET,
9467 + },
9468 +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
9469 +index 70afb2ca1eabd..9875e2fe33db2 100644
9470 +--- a/drivers/usb/class/cdc-wdm.c
9471 ++++ b/drivers/usb/class/cdc-wdm.c
9472 +@@ -58,6 +58,9 @@ MODULE_DEVICE_TABLE (usb, wdm_ids);
9473 +
9474 + #define WDM_MAX 16
9475 +
9476 ++/* we cannot wait forever at flush() */
9477 ++#define WDM_FLUSH_TIMEOUT (30 * HZ)
9478 ++
9479 + /* CDC-WMC r1.1 requires wMaxCommand to be "at least 256 decimal (0x100)" */
9480 + #define WDM_DEFAULT_BUFSIZE 256
9481 +
9482 +@@ -151,7 +154,7 @@ static void wdm_out_callback(struct urb *urb)
9483 + kfree(desc->outbuf);
9484 + desc->outbuf = NULL;
9485 + clear_bit(WDM_IN_USE, &desc->flags);
9486 +- wake_up(&desc->wait);
9487 ++ wake_up_all(&desc->wait);
9488 + }
9489 +
9490 + static void wdm_in_callback(struct urb *urb)
9491 +@@ -393,6 +396,9 @@ static ssize_t wdm_write
9492 + if (test_bit(WDM_RESETTING, &desc->flags))
9493 + r = -EIO;
9494 +
9495 ++ if (test_bit(WDM_DISCONNECTING, &desc->flags))
9496 ++ r = -ENODEV;
9497 ++
9498 + if (r < 0) {
9499 + rv = r;
9500 + goto out_free_mem_pm;
9501 +@@ -424,6 +430,7 @@ static ssize_t wdm_write
9502 + if (rv < 0) {
9503 + desc->outbuf = NULL;
9504 + clear_bit(WDM_IN_USE, &desc->flags);
9505 ++ wake_up_all(&desc->wait); /* for wdm_wait_for_response() */
9506 + dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv);
9507 + rv = usb_translate_errors(rv);
9508 + goto out_free_mem_pm;
9509 +@@ -583,28 +590,58 @@ err:
9510 + return rv;
9511 + }
9512 +
9513 +-static int wdm_flush(struct file *file, fl_owner_t id)
9514 ++static int wdm_wait_for_response(struct file *file, long timeout)
9515 + {
9516 + struct wdm_device *desc = file->private_data;
9517 ++ long rv; /* Use long here because (int) MAX_SCHEDULE_TIMEOUT < 0. */
9518 ++
9519 ++ /*
9520 ++ * Needs both flags. We cannot do with one because resetting it would
9521 ++ * cause a race with write() yet we need to signal a disconnect.
9522 ++ */
9523 ++ rv = wait_event_interruptible_timeout(desc->wait,
9524 ++ !test_bit(WDM_IN_USE, &desc->flags) ||
9525 ++ test_bit(WDM_DISCONNECTING, &desc->flags),
9526 ++ timeout);
9527 +
9528 +- wait_event(desc->wait,
9529 +- /*
9530 +- * needs both flags. We cannot do with one
9531 +- * because resetting it would cause a race
9532 +- * with write() yet we need to signal
9533 +- * a disconnect
9534 +- */
9535 +- !test_bit(WDM_IN_USE, &desc->flags) ||
9536 +- test_bit(WDM_DISCONNECTING, &desc->flags));
9537 +-
9538 +- /* cannot dereference desc->intf if WDM_DISCONNECTING */
9539 ++ /*
9540 ++ * To report the correct error. This is best effort.
9541 ++ * We are inevitably racing with the hardware.
9542 ++ */
9543 + if (test_bit(WDM_DISCONNECTING, &desc->flags))
9544 + return -ENODEV;
9545 +- if (desc->werr < 0)
9546 +- dev_err(&desc->intf->dev, "Error in flush path: %d\n",
9547 +- desc->werr);
9548 ++ if (!rv)
9549 ++ return -EIO;
9550 ++ if (rv < 0)
9551 ++ return -EINTR;
9552 ++
9553 ++ spin_lock_irq(&desc->iuspin);
9554 ++ rv = desc->werr;
9555 ++ desc->werr = 0;
9556 ++ spin_unlock_irq(&desc->iuspin);
9557 ++
9558 ++ return usb_translate_errors(rv);
9559 ++
9560 ++}
9561 ++
9562 ++/*
9563 ++ * You need to send a signal when you react to malicious or defective hardware.
9564 ++ * Also, don't abort when fsync() returned -EINVAL, for older kernels which do
9565 ++ * not implement wdm_flush() will return -EINVAL.
9566 ++ */
9567 ++static int wdm_fsync(struct file *file, loff_t start, loff_t end, int datasync)
9568 ++{
9569 ++ return wdm_wait_for_response(file, MAX_SCHEDULE_TIMEOUT);
9570 ++}
9571 +
9572 +- return usb_translate_errors(desc->werr);
9573 ++/*
9574 ++ * Same with wdm_fsync(), except it uses finite timeout in order to react to
9575 ++ * malicious or defective hardware which ceased communication after close() was
9576 ++ * implicitly called due to process termination.
9577 ++ */
9578 ++static int wdm_flush(struct file *file, fl_owner_t id)
9579 ++{
9580 ++ return wdm_wait_for_response(file, WDM_FLUSH_TIMEOUT);
9581 + }
9582 +
9583 + static __poll_t wdm_poll(struct file *file, struct poll_table_struct *wait)
9584 +@@ -729,6 +766,7 @@ static const struct file_operations wdm_fops = {
9585 + .owner = THIS_MODULE,
9586 + .read = wdm_read,
9587 + .write = wdm_write,
9588 ++ .fsync = wdm_fsync,
9589 + .open = wdm_open,
9590 + .flush = wdm_flush,
9591 + .release = wdm_release,
9592 +diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
9593 +index da923ec176122..31ca5abb4c12a 100644
9594 +--- a/drivers/usb/core/urb.c
9595 ++++ b/drivers/usb/core/urb.c
9596 +@@ -772,11 +772,12 @@ void usb_block_urb(struct urb *urb)
9597 + EXPORT_SYMBOL_GPL(usb_block_urb);
9598 +
9599 + /**
9600 +- * usb_kill_anchored_urbs - cancel transfer requests en masse
9601 ++ * usb_kill_anchored_urbs - kill all URBs associated with an anchor
9602 + * @anchor: anchor the requests are bound to
9603 + *
9604 +- * this allows all outstanding URBs to be killed starting
9605 +- * from the back of the queue
9606 ++ * This kills all outstanding URBs starting from the back of the queue,
9607 ++ * with guarantee that no completer callbacks will take place from the
9608 ++ * anchor after this function returns.
9609 + *
9610 + * This routine should not be called by a driver after its disconnect
9611 + * method has returned.
9612 +@@ -784,20 +785,26 @@ EXPORT_SYMBOL_GPL(usb_block_urb);
9613 + void usb_kill_anchored_urbs(struct usb_anchor *anchor)
9614 + {
9615 + struct urb *victim;
9616 ++ int surely_empty;
9617 +
9618 +- spin_lock_irq(&anchor->lock);
9619 +- while (!list_empty(&anchor->urb_list)) {
9620 +- victim = list_entry(anchor->urb_list.prev, struct urb,
9621 +- anchor_list);
9622 +- /* we must make sure the URB isn't freed before we kill it*/
9623 +- usb_get_urb(victim);
9624 +- spin_unlock_irq(&anchor->lock);
9625 +- /* this will unanchor the URB */
9626 +- usb_kill_urb(victim);
9627 +- usb_put_urb(victim);
9628 ++ do {
9629 + spin_lock_irq(&anchor->lock);
9630 +- }
9631 +- spin_unlock_irq(&anchor->lock);
9632 ++ while (!list_empty(&anchor->urb_list)) {
9633 ++ victim = list_entry(anchor->urb_list.prev,
9634 ++ struct urb, anchor_list);
9635 ++ /* make sure the URB isn't freed before we kill it */
9636 ++ usb_get_urb(victim);
9637 ++ spin_unlock_irq(&anchor->lock);
9638 ++ /* this will unanchor the URB */
9639 ++ usb_kill_urb(victim);
9640 ++ usb_put_urb(victim);
9641 ++ spin_lock_irq(&anchor->lock);
9642 ++ }
9643 ++ surely_empty = usb_anchor_check_wakeup(anchor);
9644 ++
9645 ++ spin_unlock_irq(&anchor->lock);
9646 ++ cpu_relax();
9647 ++ } while (!surely_empty);
9648 + }
9649 + EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs);
9650 +
9651 +@@ -816,21 +823,27 @@ EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs);
9652 + void usb_poison_anchored_urbs(struct usb_anchor *anchor)
9653 + {
9654 + struct urb *victim;
9655 ++ int surely_empty;
9656 +
9657 +- spin_lock_irq(&anchor->lock);
9658 +- anchor->poisoned = 1;
9659 +- while (!list_empty(&anchor->urb_list)) {
9660 +- victim = list_entry(anchor->urb_list.prev, struct urb,
9661 +- anchor_list);
9662 +- /* we must make sure the URB isn't freed before we kill it*/
9663 +- usb_get_urb(victim);
9664 +- spin_unlock_irq(&anchor->lock);
9665 +- /* this will unanchor the URB */
9666 +- usb_poison_urb(victim);
9667 +- usb_put_urb(victim);
9668 ++ do {
9669 + spin_lock_irq(&anchor->lock);
9670 +- }
9671 +- spin_unlock_irq(&anchor->lock);
9672 ++ anchor->poisoned = 1;
9673 ++ while (!list_empty(&anchor->urb_list)) {
9674 ++ victim = list_entry(anchor->urb_list.prev,
9675 ++ struct urb, anchor_list);
9676 ++ /* make sure the URB isn't freed before we kill it */
9677 ++ usb_get_urb(victim);
9678 ++ spin_unlock_irq(&anchor->lock);
9679 ++ /* this will unanchor the URB */
9680 ++ usb_poison_urb(victim);
9681 ++ usb_put_urb(victim);
9682 ++ spin_lock_irq(&anchor->lock);
9683 ++ }
9684 ++ surely_empty = usb_anchor_check_wakeup(anchor);
9685 ++
9686 ++ spin_unlock_irq(&anchor->lock);
9687 ++ cpu_relax();
9688 ++ } while (!surely_empty);
9689 + }
9690 + EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs);
9691 +
9692 +@@ -970,14 +983,20 @@ void usb_scuttle_anchored_urbs(struct usb_anchor *anchor)
9693 + {
9694 + struct urb *victim;
9695 + unsigned long flags;
9696 ++ int surely_empty;
9697 ++
9698 ++ do {
9699 ++ spin_lock_irqsave(&anchor->lock, flags);
9700 ++ while (!list_empty(&anchor->urb_list)) {
9701 ++ victim = list_entry(anchor->urb_list.prev,
9702 ++ struct urb, anchor_list);
9703 ++ __usb_unanchor_urb(victim, anchor);
9704 ++ }
9705 ++ surely_empty = usb_anchor_check_wakeup(anchor);
9706 +
9707 +- spin_lock_irqsave(&anchor->lock, flags);
9708 +- while (!list_empty(&anchor->urb_list)) {
9709 +- victim = list_entry(anchor->urb_list.prev, struct urb,
9710 +- anchor_list);
9711 +- __usb_unanchor_urb(victim, anchor);
9712 +- }
9713 +- spin_unlock_irqrestore(&anchor->lock, flags);
9714 ++ spin_unlock_irqrestore(&anchor->lock, flags);
9715 ++ cpu_relax();
9716 ++ } while (!surely_empty);
9717 + }
9718 +
9719 + EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs);
9720 +diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
9721 +index f7528f732b2aa..70ac47a341ac2 100644
9722 +--- a/drivers/usb/dwc2/gadget.c
9723 ++++ b/drivers/usb/dwc2/gadget.c
9724 +@@ -712,8 +712,11 @@ static u32 dwc2_hsotg_read_frameno(struct dwc2_hsotg *hsotg)
9725 + */
9726 + static unsigned int dwc2_gadget_get_chain_limit(struct dwc2_hsotg_ep *hs_ep)
9727 + {
9728 ++ const struct usb_endpoint_descriptor *ep_desc = hs_ep->ep.desc;
9729 + int is_isoc = hs_ep->isochronous;
9730 + unsigned int maxsize;
9731 ++ u32 mps = hs_ep->ep.maxpacket;
9732 ++ int dir_in = hs_ep->dir_in;
9733 +
9734 + if (is_isoc)
9735 + maxsize = (hs_ep->dir_in ? DEV_DMA_ISOC_TX_NBYTES_LIMIT :
9736 +@@ -722,6 +725,11 @@ static unsigned int dwc2_gadget_get_chain_limit(struct dwc2_hsotg_ep *hs_ep)
9737 + else
9738 + maxsize = DEV_DMA_NBYTES_LIMIT * MAX_DMA_DESC_NUM_GENERIC;
9739 +
9740 ++ /* Interrupt OUT EP with mps not multiple of 4 */
9741 ++ if (hs_ep->index)
9742 ++ if (usb_endpoint_xfer_int(ep_desc) && !dir_in && (mps % 4))
9743 ++ maxsize = mps * MAX_DMA_DESC_NUM_GENERIC;
9744 ++
9745 + return maxsize;
9746 + }
9747 +
9748 +@@ -737,11 +745,14 @@ static unsigned int dwc2_gadget_get_chain_limit(struct dwc2_hsotg_ep *hs_ep)
9749 + * Isochronous - descriptor rx/tx bytes bitfield limit,
9750 + * Control In/Bulk/Interrupt - multiple of mps. This will allow to not
9751 + * have concatenations from various descriptors within one packet.
9752 ++ * Interrupt OUT - if mps not multiple of 4 then a single packet corresponds
9753 ++ * to a single descriptor.
9754 + *
9755 + * Selects corresponding mask for RX/TX bytes as well.
9756 + */
9757 + static u32 dwc2_gadget_get_desc_params(struct dwc2_hsotg_ep *hs_ep, u32 *mask)
9758 + {
9759 ++ const struct usb_endpoint_descriptor *ep_desc = hs_ep->ep.desc;
9760 + u32 mps = hs_ep->ep.maxpacket;
9761 + int dir_in = hs_ep->dir_in;
9762 + u32 desc_size = 0;
9763 +@@ -765,6 +776,13 @@ static u32 dwc2_gadget_get_desc_params(struct dwc2_hsotg_ep *hs_ep, u32 *mask)
9764 + desc_size -= desc_size % mps;
9765 + }
9766 +
9767 ++ /* Interrupt OUT EP with mps not multiple of 4 */
9768 ++ if (hs_ep->index)
9769 ++ if (usb_endpoint_xfer_int(ep_desc) && !dir_in && (mps % 4)) {
9770 ++ desc_size = mps;
9771 ++ *mask = DEV_DMA_NBYTES_MASK;
9772 ++ }
9773 ++
9774 + return desc_size;
9775 + }
9776 +
9777 +@@ -1123,13 +1141,7 @@ static void dwc2_hsotg_start_req(struct dwc2_hsotg *hsotg,
9778 + length += (mps - (length % mps));
9779 + }
9780 +
9781 +- /*
9782 +- * If more data to send, adjust DMA for EP0 out data stage.
9783 +- * ureq->dma stays unchanged, hence increment it by already
9784 +- * passed passed data count before starting new transaction.
9785 +- */
9786 +- if (!index && hsotg->ep0_state == DWC2_EP0_DATA_OUT &&
9787 +- continuing)
9788 ++ if (continuing)
9789 + offset = ureq->actual;
9790 +
9791 + /* Fill DDMA chain entries */
9792 +@@ -2319,22 +2331,36 @@ static void dwc2_hsotg_change_ep_iso_parity(struct dwc2_hsotg *hsotg,
9793 + */
9794 + static unsigned int dwc2_gadget_get_xfersize_ddma(struct dwc2_hsotg_ep *hs_ep)
9795 + {
9796 ++ const struct usb_endpoint_descriptor *ep_desc = hs_ep->ep.desc;
9797 + struct dwc2_hsotg *hsotg = hs_ep->parent;
9798 + unsigned int bytes_rem = 0;
9799 ++ unsigned int bytes_rem_correction = 0;
9800 + struct dwc2_dma_desc *desc = hs_ep->desc_list;
9801 + int i;
9802 + u32 status;
9803 ++ u32 mps = hs_ep->ep.maxpacket;
9804 ++ int dir_in = hs_ep->dir_in;
9805 +
9806 + if (!desc)
9807 + return -EINVAL;
9808 +
9809 ++ /* Interrupt OUT EP with mps not multiple of 4 */
9810 ++ if (hs_ep->index)
9811 ++ if (usb_endpoint_xfer_int(ep_desc) && !dir_in && (mps % 4))
9812 ++ bytes_rem_correction = 4 - (mps % 4);
9813 ++
9814 + for (i = 0; i < hs_ep->desc_count; ++i) {
9815 + status = desc->status;
9816 + bytes_rem += status & DEV_DMA_NBYTES_MASK;
9817 ++ bytes_rem -= bytes_rem_correction;
9818 +
9819 + if (status & DEV_DMA_STS_MASK)
9820 + dev_err(hsotg->dev, "descriptor %d closed with %x\n",
9821 + i, status & DEV_DMA_STS_MASK);
9822 ++
9823 ++ if (status & DEV_DMA_L)
9824 ++ break;
9825 ++
9826 + desc++;
9827 + }
9828 +
9829 +diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
9830 +index 31e090ac9f1ec..6d3812678b8c6 100644
9831 +--- a/drivers/usb/dwc2/params.c
9832 ++++ b/drivers/usb/dwc2/params.c
9833 +@@ -846,7 +846,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
9834 + int dwc2_init_params(struct dwc2_hsotg *hsotg)
9835 + {
9836 + const struct of_device_id *match;
9837 +- void (*set_params)(void *data);
9838 ++ void (*set_params)(struct dwc2_hsotg *data);
9839 +
9840 + dwc2_set_default_params(hsotg);
9841 + dwc2_get_device_properties(hsotg);
9842 +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
9843 +index 526c275ad0bc5..4cbf295390062 100644
9844 +--- a/drivers/usb/dwc3/core.c
9845 ++++ b/drivers/usb/dwc3/core.c
9846 +@@ -117,6 +117,7 @@ static void __dwc3_set_mode(struct work_struct *work)
9847 + struct dwc3 *dwc = work_to_dwc(work);
9848 + unsigned long flags;
9849 + int ret;
9850 ++ u32 reg;
9851 +
9852 + if (dwc->dr_mode != USB_DR_MODE_OTG)
9853 + return;
9854 +@@ -168,6 +169,11 @@ static void __dwc3_set_mode(struct work_struct *work)
9855 + otg_set_vbus(dwc->usb2_phy->otg, true);
9856 + phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST);
9857 + phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST);
9858 ++ if (dwc->dis_split_quirk) {
9859 ++ reg = dwc3_readl(dwc->regs, DWC3_GUCTL3);
9860 ++ reg |= DWC3_GUCTL3_SPLITDISABLE;
9861 ++ dwc3_writel(dwc->regs, DWC3_GUCTL3, reg);
9862 ++ }
9863 + }
9864 + break;
9865 + case DWC3_GCTL_PRTCAP_DEVICE:
9866 +@@ -1323,6 +1329,9 @@ static void dwc3_get_properties(struct dwc3 *dwc)
9867 + dwc->dis_metastability_quirk = device_property_read_bool(dev,
9868 + "snps,dis_metastability_quirk");
9869 +
9870 ++ dwc->dis_split_quirk = device_property_read_bool(dev,
9871 ++ "snps,dis-split-quirk");
9872 ++
9873 + dwc->lpm_nyet_threshold = lpm_nyet_threshold;
9874 + dwc->tx_de_emphasis = tx_de_emphasis;
9875 +
9876 +@@ -1835,10 +1844,26 @@ static int dwc3_resume(struct device *dev)
9877 +
9878 + return 0;
9879 + }
9880 ++
9881 ++static void dwc3_complete(struct device *dev)
9882 ++{
9883 ++ struct dwc3 *dwc = dev_get_drvdata(dev);
9884 ++ u32 reg;
9885 ++
9886 ++ if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST &&
9887 ++ dwc->dis_split_quirk) {
9888 ++ reg = dwc3_readl(dwc->regs, DWC3_GUCTL3);
9889 ++ reg |= DWC3_GUCTL3_SPLITDISABLE;
9890 ++ dwc3_writel(dwc->regs, DWC3_GUCTL3, reg);
9891 ++ }
9892 ++}
9893 ++#else
9894 ++#define dwc3_complete NULL
9895 + #endif /* CONFIG_PM_SLEEP */
9896 +
9897 + static const struct dev_pm_ops dwc3_dev_pm_ops = {
9898 + SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume)
9899 ++ .complete = dwc3_complete,
9900 + SET_RUNTIME_PM_OPS(dwc3_runtime_suspend, dwc3_runtime_resume,
9901 + dwc3_runtime_idle)
9902 + };
9903 +diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
9904 +index ce4acbf7fef90..4dfbffa944de1 100644
9905 +--- a/drivers/usb/dwc3/core.h
9906 ++++ b/drivers/usb/dwc3/core.h
9907 +@@ -136,6 +136,7 @@
9908 + #define DWC3_GEVNTCOUNT(n) (0xc40c + ((n) * 0x10))
9909 +
9910 + #define DWC3_GHWPARAMS8 0xc600
9911 ++#define DWC3_GUCTL3 0xc60c
9912 + #define DWC3_GFLADJ 0xc630
9913 +
9914 + /* Device Registers */
9915 +@@ -375,6 +376,9 @@
9916 + /* Global User Control Register 2 */
9917 + #define DWC3_GUCTL2_RST_ACTBITLATER BIT(14)
9918 +
9919 ++/* Global User Control Register 3 */
9920 ++#define DWC3_GUCTL3_SPLITDISABLE BIT(14)
9921 ++
9922 + /* Device Configuration Register */
9923 + #define DWC3_DCFG_DEVADDR(addr) ((addr) << 3)
9924 + #define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f)
9925 +@@ -1038,6 +1042,7 @@ struct dwc3_scratchpad_array {
9926 + * 2 - No de-emphasis
9927 + * 3 - Reserved
9928 + * @dis_metastability_quirk: set to disable metastability quirk.
9929 ++ * @dis_split_quirk: set to disable split boundary.
9930 + * @imod_interval: set the interrupt moderation interval in 250ns
9931 + * increments or 0 to disable.
9932 + */
9933 +@@ -1229,6 +1234,8 @@ struct dwc3 {
9934 +
9935 + unsigned dis_metastability_quirk:1;
9936 +
9937 ++ unsigned dis_split_quirk:1;
9938 ++
9939 + u16 imod_interval;
9940 + };
9941 +
9942 +diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
9943 +index bdac3e7d7b184..d055e00f81808 100644
9944 +--- a/drivers/usb/dwc3/dwc3-of-simple.c
9945 ++++ b/drivers/usb/dwc3/dwc3-of-simple.c
9946 +@@ -183,6 +183,7 @@ static const struct of_device_id of_dwc3_simple_match[] = {
9947 + { .compatible = "amlogic,meson-axg-dwc3" },
9948 + { .compatible = "amlogic,meson-gxl-dwc3" },
9949 + { .compatible = "allwinner,sun50i-h6-dwc3" },
9950 ++ { .compatible = "hisilicon,hi3670-dwc3" },
9951 + { /* Sentinel */ }
9952 + };
9953 + MODULE_DEVICE_TABLE(of, of_dwc3_simple_match);
9954 +diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
9955 +index 1f638759a9533..92a7c3a839454 100644
9956 +--- a/drivers/usb/gadget/function/f_ncm.c
9957 ++++ b/drivers/usb/gadget/function/f_ncm.c
9958 +@@ -85,8 +85,10 @@ static inline struct f_ncm *func_to_ncm(struct usb_function *f)
9959 + /* peak (theoretical) bulk transfer rate in bits-per-second */
9960 + static inline unsigned ncm_bitrate(struct usb_gadget *g)
9961 + {
9962 +- if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER)
9963 +- return 13 * 1024 * 8 * 1000 * 8;
9964 ++ if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS)
9965 ++ return 4250000000U;
9966 ++ else if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER)
9967 ++ return 3750000000U;
9968 + else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
9969 + return 13 * 512 * 8 * 1000 * 8;
9970 + else
9971 +@@ -1534,7 +1536,7 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f)
9972 + fs_ncm_notify_desc.bEndpointAddress;
9973 +
9974 + status = usb_assign_descriptors(f, ncm_fs_function, ncm_hs_function,
9975 +- ncm_ss_function, NULL);
9976 ++ ncm_ss_function, ncm_ss_function);
9977 + if (status)
9978 + goto fail;
9979 +
9980 +diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
9981 +index 9c7ed2539ff77..8ed1295d7e350 100644
9982 +--- a/drivers/usb/gadget/function/f_printer.c
9983 ++++ b/drivers/usb/gadget/function/f_printer.c
9984 +@@ -31,6 +31,7 @@
9985 + #include <linux/types.h>
9986 + #include <linux/ctype.h>
9987 + #include <linux/cdev.h>
9988 ++#include <linux/kref.h>
9989 +
9990 + #include <asm/byteorder.h>
9991 + #include <linux/io.h>
9992 +@@ -64,7 +65,7 @@ struct printer_dev {
9993 + struct usb_gadget *gadget;
9994 + s8 interface;
9995 + struct usb_ep *in_ep, *out_ep;
9996 +-
9997 ++ struct kref kref;
9998 + struct list_head rx_reqs; /* List of free RX structs */
9999 + struct list_head rx_reqs_active; /* List of Active RX xfers */
10000 + struct list_head rx_buffers; /* List of completed xfers */
10001 +@@ -218,6 +219,13 @@ static inline struct usb_endpoint_descriptor *ep_desc(struct usb_gadget *gadget,
10002 +
10003 + /*-------------------------------------------------------------------------*/
10004 +
10005 ++static void printer_dev_free(struct kref *kref)
10006 ++{
10007 ++ struct printer_dev *dev = container_of(kref, struct printer_dev, kref);
10008 ++
10009 ++ kfree(dev);
10010 ++}
10011 ++
10012 + static struct usb_request *
10013 + printer_req_alloc(struct usb_ep *ep, unsigned len, gfp_t gfp_flags)
10014 + {
10015 +@@ -348,6 +356,7 @@ printer_open(struct inode *inode, struct file *fd)
10016 +
10017 + spin_unlock_irqrestore(&dev->lock, flags);
10018 +
10019 ++ kref_get(&dev->kref);
10020 + DBG(dev, "printer_open returned %x\n", ret);
10021 + return ret;
10022 + }
10023 +@@ -365,6 +374,7 @@ printer_close(struct inode *inode, struct file *fd)
10024 + dev->printer_status &= ~PRINTER_SELECTED;
10025 + spin_unlock_irqrestore(&dev->lock, flags);
10026 +
10027 ++ kref_put(&dev->kref, printer_dev_free);
10028 + DBG(dev, "printer_close\n");
10029 +
10030 + return 0;
10031 +@@ -1350,7 +1360,8 @@ static void gprinter_free(struct usb_function *f)
10032 + struct f_printer_opts *opts;
10033 +
10034 + opts = container_of(f->fi, struct f_printer_opts, func_inst);
10035 +- kfree(dev);
10036 ++
10037 ++ kref_put(&dev->kref, printer_dev_free);
10038 + mutex_lock(&opts->lock);
10039 + --opts->refcnt;
10040 + mutex_unlock(&opts->lock);
10041 +@@ -1419,6 +1430,7 @@ static struct usb_function *gprinter_alloc(struct usb_function_instance *fi)
10042 + return ERR_PTR(-ENOMEM);
10043 + }
10044 +
10045 ++ kref_init(&dev->kref);
10046 + ++opts->refcnt;
10047 + dev->minor = opts->minor;
10048 + dev->pnp_string = opts->pnp_string;
10049 +diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
10050 +index fbe96ef1ac7a4..891e9f7f40d59 100644
10051 +--- a/drivers/usb/gadget/function/u_ether.c
10052 ++++ b/drivers/usb/gadget/function/u_ether.c
10053 +@@ -93,7 +93,7 @@ struct eth_dev {
10054 + static inline int qlen(struct usb_gadget *gadget, unsigned qmult)
10055 + {
10056 + if (gadget_is_dualspeed(gadget) && (gadget->speed == USB_SPEED_HIGH ||
10057 +- gadget->speed == USB_SPEED_SUPER))
10058 ++ gadget->speed >= USB_SPEED_SUPER))
10059 + return qmult * DEFAULT_QLEN;
10060 + else
10061 + return DEFAULT_QLEN;
10062 +diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
10063 +index 4de91653a2c7b..5eb62240c7f87 100644
10064 +--- a/drivers/usb/host/ohci-hcd.c
10065 ++++ b/drivers/usb/host/ohci-hcd.c
10066 +@@ -673,20 +673,24 @@ retry:
10067 +
10068 + /* handle root hub init quirks ... */
10069 + val = roothub_a (ohci);
10070 +- val &= ~(RH_A_PSM | RH_A_OCPM);
10071 ++ /* Configure for per-port over-current protection by default */
10072 ++ val &= ~RH_A_NOCP;
10073 ++ val |= RH_A_OCPM;
10074 + if (ohci->flags & OHCI_QUIRK_SUPERIO) {
10075 +- /* NSC 87560 and maybe others */
10076 ++ /* NSC 87560 and maybe others.
10077 ++ * Ganged power switching, no over-current protection.
10078 ++ */
10079 + val |= RH_A_NOCP;
10080 +- val &= ~(RH_A_POTPGT | RH_A_NPS);
10081 +- ohci_writel (ohci, val, &ohci->regs->roothub.a);
10082 ++ val &= ~(RH_A_POTPGT | RH_A_NPS | RH_A_PSM | RH_A_OCPM);
10083 + } else if ((ohci->flags & OHCI_QUIRK_AMD756) ||
10084 + (ohci->flags & OHCI_QUIRK_HUB_POWER)) {
10085 + /* hub power always on; required for AMD-756 and some
10086 +- * Mac platforms. ganged overcurrent reporting, if any.
10087 ++ * Mac platforms.
10088 + */
10089 + val |= RH_A_NPS;
10090 +- ohci_writel (ohci, val, &ohci->regs->roothub.a);
10091 + }
10092 ++ ohci_writel(ohci, val, &ohci->regs->roothub.a);
10093 ++
10094 + ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status);
10095 + ohci_writel (ohci, (val & RH_A_NPS) ? 0 : RH_B_PPCM,
10096 + &ohci->regs->roothub.b);
10097 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
10098 +index bad154f446f8d..0d10ede581cbd 100644
10099 +--- a/drivers/usb/host/xhci.c
10100 ++++ b/drivers/usb/host/xhci.c
10101 +@@ -1915,8 +1915,6 @@ static int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
10102 + ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
10103 + trace_xhci_add_endpoint(ep_ctx);
10104 +
10105 +- xhci_debugfs_create_endpoint(xhci, virt_dev, ep_index);
10106 +-
10107 + xhci_dbg(xhci, "add ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x\n",
10108 + (unsigned int) ep->desc.bEndpointAddress,
10109 + udev->slot_id,
10110 +@@ -2949,6 +2947,7 @@ static int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
10111 + xhci_check_bw_drop_ep_streams(xhci, virt_dev, i);
10112 + virt_dev->eps[i].ring = virt_dev->eps[i].new_ring;
10113 + virt_dev->eps[i].new_ring = NULL;
10114 ++ xhci_debugfs_create_endpoint(xhci, virt_dev, i);
10115 + }
10116 + command_cleanup:
10117 + kfree(command->completion);
10118 +diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
10119 +index 927b608461c82..bf32997c557ff 100644
10120 +--- a/drivers/vfio/pci/vfio_pci_config.c
10121 ++++ b/drivers/vfio/pci/vfio_pci_config.c
10122 +@@ -406,7 +406,7 @@ bool __vfio_pci_memory_enabled(struct vfio_pci_device *vdev)
10123 + * PF SR-IOV capability, there's therefore no need to trigger
10124 + * faults based on the virtual value.
10125 + */
10126 +- return pdev->is_virtfn || (cmd & PCI_COMMAND_MEMORY);
10127 ++ return pdev->no_command_memory || (cmd & PCI_COMMAND_MEMORY);
10128 + }
10129 +
10130 + /*
10131 +@@ -518,8 +518,8 @@ static int vfio_basic_config_read(struct vfio_pci_device *vdev, int pos,
10132 +
10133 + count = vfio_default_config_read(vdev, pos, count, perm, offset, val);
10134 +
10135 +- /* Mask in virtual memory enable for SR-IOV devices */
10136 +- if (offset == PCI_COMMAND && vdev->pdev->is_virtfn) {
10137 ++ /* Mask in virtual memory enable */
10138 ++ if (offset == PCI_COMMAND && vdev->pdev->no_command_memory) {
10139 + u16 cmd = le16_to_cpu(*(__le16 *)&vdev->vconfig[PCI_COMMAND]);
10140 + u32 tmp_val = le32_to_cpu(*val);
10141 +
10142 +@@ -587,9 +587,11 @@ static int vfio_basic_config_write(struct vfio_pci_device *vdev, int pos,
10143 + * shows it disabled (phys_mem/io, then the device has
10144 + * undergone some kind of backdoor reset and needs to be
10145 + * restored before we allow it to enable the bars.
10146 +- * SR-IOV devices will trigger this, but we catch them later
10147 ++ * SR-IOV devices will trigger this - for mem enable let's
10148 ++ * catch this now and for io enable it will be caught later
10149 + */
10150 +- if ((new_mem && virt_mem && !phys_mem) ||
10151 ++ if ((new_mem && virt_mem && !phys_mem &&
10152 ++ !pdev->no_command_memory) ||
10153 + (new_io && virt_io && !phys_io) ||
10154 + vfio_need_bar_restore(vdev))
10155 + vfio_bar_restore(vdev);
10156 +@@ -1732,12 +1734,14 @@ int vfio_config_init(struct vfio_pci_device *vdev)
10157 + vconfig[PCI_INTERRUPT_PIN]);
10158 +
10159 + vconfig[PCI_INTERRUPT_PIN] = 0; /* Gratuitous for good VFs */
10160 +-
10161 ++ }
10162 ++ if (pdev->no_command_memory) {
10163 + /*
10164 +- * VFs do no implement the memory enable bit of the COMMAND
10165 +- * register therefore we'll not have it set in our initial
10166 +- * copy of config space after pci_enable_device(). For
10167 +- * consistency with PFs, set the virtual enable bit here.
10168 ++ * VFs and devices that set pdev->no_command_memory do not
10169 ++ * implement the memory enable bit of the COMMAND register
10170 ++ * therefore we'll not have it set in our initial copy of
10171 ++ * config space after pci_enable_device(). For consistency
10172 ++ * with PFs, set the virtual enable bit here.
10173 + */
10174 + *(__le16 *)&vconfig[PCI_COMMAND] |=
10175 + cpu_to_le16(PCI_COMMAND_MEMORY);
10176 +diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
10177 +index 1d9fb25929459..869dce5f134dd 100644
10178 +--- a/drivers/vfio/pci/vfio_pci_intrs.c
10179 ++++ b/drivers/vfio/pci/vfio_pci_intrs.c
10180 +@@ -352,11 +352,13 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
10181 + vdev->ctx[vector].producer.token = trigger;
10182 + vdev->ctx[vector].producer.irq = irq;
10183 + ret = irq_bypass_register_producer(&vdev->ctx[vector].producer);
10184 +- if (unlikely(ret))
10185 ++ if (unlikely(ret)) {
10186 + dev_info(&pdev->dev,
10187 + "irq bypass producer (token %p) registration fails: %d\n",
10188 + vdev->ctx[vector].producer.token, ret);
10189 +
10190 ++ vdev->ctx[vector].producer.token = NULL;
10191 ++ }
10192 + vdev->ctx[vector].trigger = trigger;
10193 +
10194 + return 0;
10195 +diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
10196 +index c6220f57fdf3e..3b31e83a92155 100644
10197 +--- a/drivers/vfio/vfio_iommu_type1.c
10198 ++++ b/drivers/vfio/vfio_iommu_type1.c
10199 +@@ -631,7 +631,8 @@ static int vfio_iommu_type1_pin_pages(void *iommu_data,
10200 +
10201 + ret = vfio_add_to_pfn_list(dma, iova, phys_pfn[i]);
10202 + if (ret) {
10203 +- vfio_unpin_page_external(dma, iova, do_accounting);
10204 ++ if (put_pfn(phys_pfn[i], dma->prot) && do_accounting)
10205 ++ vfio_lock_acct(dma, -1, true);
10206 + goto pin_unwind;
10207 + }
10208 + }
10209 +diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
10210 +index 2355f00f57732..1f6301375fd33 100644
10211 +--- a/drivers/video/backlight/sky81452-backlight.c
10212 ++++ b/drivers/video/backlight/sky81452-backlight.c
10213 +@@ -196,6 +196,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
10214 + num_entry);
10215 + if (ret < 0) {
10216 + dev_err(dev, "led-sources node is invalid.\n");
10217 ++ of_node_put(np);
10218 + return ERR_PTR(-EINVAL);
10219 + }
10220 +
10221 +diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c
10222 +index 4ca07866f2f66..5dda824d0da3f 100644
10223 +--- a/drivers/video/fbdev/aty/radeon_base.c
10224 ++++ b/drivers/video/fbdev/aty/radeon_base.c
10225 +@@ -2323,7 +2323,7 @@ static int radeonfb_pci_register(struct pci_dev *pdev,
10226 +
10227 + ret = radeon_kick_out_firmware_fb(pdev);
10228 + if (ret)
10229 +- return ret;
10230 ++ goto err_release_fb;
10231 +
10232 + /* request the mem regions */
10233 + ret = pci_request_region(pdev, 0, "radeonfb framebuffer");
10234 +diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
10235 +index 97abcd497c7e0..bf76dadbed87f 100644
10236 +--- a/drivers/video/fbdev/core/fbmem.c
10237 ++++ b/drivers/video/fbdev/core/fbmem.c
10238 +@@ -1001,6 +1001,10 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
10239 + return 0;
10240 + }
10241 +
10242 ++ /* bitfill_aligned() assumes that it's at least 8x8 */
10243 ++ if (var->xres < 8 || var->yres < 8)
10244 ++ return -EINVAL;
10245 ++
10246 + ret = info->fbops->fb_check_var(var, info);
10247 +
10248 + if (ret)
10249 +diff --git a/drivers/video/fbdev/sis/init.c b/drivers/video/fbdev/sis/init.c
10250 +index dfe3eb769638b..fde27feae5d0c 100644
10251 +--- a/drivers/video/fbdev/sis/init.c
10252 ++++ b/drivers/video/fbdev/sis/init.c
10253 +@@ -2428,6 +2428,11 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
10254 +
10255 + i = 0;
10256 +
10257 ++ if (SiS_Pr->ChipType == SIS_730)
10258 ++ queuedata = &FQBQData730[0];
10259 ++ else
10260 ++ queuedata = &FQBQData[0];
10261 ++
10262 + if(ModeNo > 0x13) {
10263 +
10264 + /* Get VCLK */
10265 +@@ -2445,12 +2450,6 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
10266 + /* Get half colordepth */
10267 + colorth = colortharray[(SiS_Pr->SiS_ModeType - ModeEGA)];
10268 +
10269 +- if(SiS_Pr->ChipType == SIS_730) {
10270 +- queuedata = &FQBQData730[0];
10271 +- } else {
10272 +- queuedata = &FQBQData[0];
10273 +- }
10274 +-
10275 + do {
10276 + templ = SiS_CalcDelay2(SiS_Pr, queuedata[i]) * VCLK * colorth;
10277 +
10278 +diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c
10279 +index 4b83109202b1c..3c4d20618de4c 100644
10280 +--- a/drivers/video/fbdev/vga16fb.c
10281 ++++ b/drivers/video/fbdev/vga16fb.c
10282 +@@ -243,7 +243,7 @@ static void vga16fb_update_fix(struct fb_info *info)
10283 + }
10284 +
10285 + static void vga16fb_clock_chip(struct vga16fb_par *par,
10286 +- unsigned int pixclock,
10287 ++ unsigned int *pixclock,
10288 + const struct fb_info *info,
10289 + int mul, int div)
10290 + {
10291 +@@ -259,14 +259,14 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
10292 + { 0 /* bad */, 0x00, 0x00}};
10293 + int err;
10294 +
10295 +- pixclock = (pixclock * mul) / div;
10296 ++ *pixclock = (*pixclock * mul) / div;
10297 + best = vgaclocks;
10298 +- err = pixclock - best->pixclock;
10299 ++ err = *pixclock - best->pixclock;
10300 + if (err < 0) err = -err;
10301 + for (ptr = vgaclocks + 1; ptr->pixclock; ptr++) {
10302 + int tmp;
10303 +
10304 +- tmp = pixclock - ptr->pixclock;
10305 ++ tmp = *pixclock - ptr->pixclock;
10306 + if (tmp < 0) tmp = -tmp;
10307 + if (tmp < err) {
10308 + err = tmp;
10309 +@@ -275,7 +275,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
10310 + }
10311 + par->misc |= best->misc;
10312 + par->clkdiv = best->seq_clock_mode;
10313 +- pixclock = (best->pixclock * div) / mul;
10314 ++ *pixclock = (best->pixclock * div) / mul;
10315 + }
10316 +
10317 + #define FAIL(X) return -EINVAL
10318 +@@ -497,10 +497,10 @@ static int vga16fb_check_var(struct fb_var_screeninfo *var,
10319 +
10320 + if (mode & MODE_8BPP)
10321 + /* pixel clock == vga clock / 2 */
10322 +- vga16fb_clock_chip(par, var->pixclock, info, 1, 2);
10323 ++ vga16fb_clock_chip(par, &var->pixclock, info, 1, 2);
10324 + else
10325 + /* pixel clock == vga clock */
10326 +- vga16fb_clock_chip(par, var->pixclock, info, 1, 1);
10327 ++ vga16fb_clock_chip(par, &var->pixclock, info, 1, 1);
10328 +
10329 + var->red.offset = var->green.offset = var->blue.offset =
10330 + var->transp.offset = 0;
10331 +diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
10332 +index 93d5bebf9572a..fb292f9cf29df 100644
10333 +--- a/drivers/virt/fsl_hypervisor.c
10334 ++++ b/drivers/virt/fsl_hypervisor.c
10335 +@@ -157,7 +157,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
10336 +
10337 + unsigned int i;
10338 + long ret = 0;
10339 +- int num_pinned; /* return value from get_user_pages() */
10340 ++ int num_pinned = 0; /* return value from get_user_pages_fast() */
10341 + phys_addr_t remote_paddr; /* The next address in the remote buffer */
10342 + uint32_t count; /* The number of bytes left to copy */
10343 +
10344 +@@ -174,7 +174,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
10345 + return -EINVAL;
10346 +
10347 + /*
10348 +- * The array of pages returned by get_user_pages() covers only
10349 ++ * The array of pages returned by get_user_pages_fast() covers only
10350 + * page-aligned memory. Since the user buffer is probably not
10351 + * page-aligned, we need to handle the discrepancy.
10352 + *
10353 +@@ -224,7 +224,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
10354 +
10355 + /*
10356 + * 'pages' is an array of struct page pointers that's initialized by
10357 +- * get_user_pages().
10358 ++ * get_user_pages_fast().
10359 + */
10360 + pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
10361 + if (!pages) {
10362 +@@ -241,7 +241,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
10363 + if (!sg_list_unaligned) {
10364 + pr_debug("fsl-hv: could not allocate S/G list\n");
10365 + ret = -ENOMEM;
10366 +- goto exit;
10367 ++ goto free_pages;
10368 + }
10369 + sg_list = PTR_ALIGN(sg_list_unaligned, sizeof(struct fh_sg_list));
10370 +
10371 +@@ -250,7 +250,6 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
10372 + num_pages, param.source != -1 ? FOLL_WRITE : 0, pages);
10373 +
10374 + if (num_pinned != num_pages) {
10375 +- /* get_user_pages() failed */
10376 + pr_debug("fsl-hv: could not lock source buffer\n");
10377 + ret = (num_pinned < 0) ? num_pinned : -EFAULT;
10378 + goto exit;
10379 +@@ -292,13 +291,13 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
10380 + virt_to_phys(sg_list), num_pages);
10381 +
10382 + exit:
10383 +- if (pages) {
10384 +- for (i = 0; i < num_pages; i++)
10385 +- if (pages[i])
10386 +- put_page(pages[i]);
10387 ++ if (pages && (num_pinned > 0)) {
10388 ++ for (i = 0; i < num_pinned; i++)
10389 ++ put_page(pages[i]);
10390 + }
10391 +
10392 + kfree(sg_list_unaligned);
10393 ++free_pages:
10394 + kfree(pages);
10395 +
10396 + if (!ret)
10397 +diff --git a/drivers/watchdog/sp5100_tco.h b/drivers/watchdog/sp5100_tco.h
10398 +index 87eaf357ae01f..adf015aa4126f 100644
10399 +--- a/drivers/watchdog/sp5100_tco.h
10400 ++++ b/drivers/watchdog/sp5100_tco.h
10401 +@@ -70,7 +70,7 @@
10402 + #define EFCH_PM_DECODEEN_WDT_TMREN BIT(7)
10403 +
10404 +
10405 +-#define EFCH_PM_DECODEEN3 0x00
10406 ++#define EFCH_PM_DECODEEN3 0x03
10407 + #define EFCH_PM_DECODEEN_SECOND_RES GENMASK(1, 0)
10408 + #define EFCH_PM_WATCHDOG_DISABLE ((u8)GENMASK(3, 2))
10409 +
10410 +diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
10411 +index 3729f99fd8eca..8494846ccdc5f 100644
10412 +--- a/drivers/watchdog/watchdog_dev.c
10413 ++++ b/drivers/watchdog/watchdog_dev.c
10414 +@@ -971,8 +971,10 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
10415 + wd_data->wdd = wdd;
10416 + wdd->wd_data = wd_data;
10417 +
10418 +- if (IS_ERR_OR_NULL(watchdog_kworker))
10419 ++ if (IS_ERR_OR_NULL(watchdog_kworker)) {
10420 ++ kfree(wd_data);
10421 + return -ENODEV;
10422 ++ }
10423 +
10424 + device_initialize(&wd_data->dev);
10425 + wd_data->dev.devt = MKDEV(MAJOR(watchdog_devt), wdd->id);
10426 +@@ -998,7 +1000,7 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
10427 + pr_err("%s: a legacy watchdog module is probably present.\n",
10428 + wdd->info->identity);
10429 + old_wd_data = NULL;
10430 +- kfree(wd_data);
10431 ++ put_device(&wd_data->dev);
10432 + return err;
10433 + }
10434 + }
10435 +diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c
10436 +index 689162e2e1755..3150c19cdc2fb 100644
10437 +--- a/fs/cifs/asn1.c
10438 ++++ b/fs/cifs/asn1.c
10439 +@@ -530,8 +530,8 @@ decode_negTokenInit(unsigned char *security_blob, int length,
10440 + return 0;
10441 + } else if ((cls != ASN1_CTX) || (con != ASN1_CON)
10442 + || (tag != ASN1_EOC)) {
10443 +- cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 0\n",
10444 +- cls, con, tag, end, *end);
10445 ++ cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p exit 0\n",
10446 ++ cls, con, tag, end);
10447 + return 0;
10448 + }
10449 +
10450 +@@ -541,8 +541,8 @@ decode_negTokenInit(unsigned char *security_blob, int length,
10451 + return 0;
10452 + } else if ((cls != ASN1_UNI) || (con != ASN1_CON)
10453 + || (tag != ASN1_SEQ)) {
10454 +- cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 1\n",
10455 +- cls, con, tag, end, *end);
10456 ++ cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p exit 1\n",
10457 ++ cls, con, tag, end);
10458 + return 0;
10459 + }
10460 +
10461 +@@ -552,8 +552,8 @@ decode_negTokenInit(unsigned char *security_blob, int length,
10462 + return 0;
10463 + } else if ((cls != ASN1_CTX) || (con != ASN1_CON)
10464 + || (tag != ASN1_EOC)) {
10465 +- cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 0\n",
10466 +- cls, con, tag, end, *end);
10467 ++ cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p exit 0\n",
10468 ++ cls, con, tag, end);
10469 + return 0;
10470 + }
10471 +
10472 +@@ -564,8 +564,8 @@ decode_negTokenInit(unsigned char *security_blob, int length,
10473 + return 0;
10474 + } else if ((cls != ASN1_UNI) || (con != ASN1_CON)
10475 + || (tag != ASN1_SEQ)) {
10476 +- cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 1\n",
10477 +- cls, con, tag, end, *end);
10478 ++ cifs_dbg(FYI, "cls = %d con = %d tag = %d sequence_end = %p exit 1\n",
10479 ++ cls, con, tag, sequence_end);
10480 + return 0;
10481 + }
10482 +
10483 +diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
10484 +index 9a89e5f7c4da3..776029a57e717 100644
10485 +--- a/fs/cifs/smb2ops.c
10486 ++++ b/fs/cifs/smb2ops.c
10487 +@@ -3707,7 +3707,7 @@ crypt_message(struct TCP_Server_Info *server, int num_rqst,
10488 + if (rc) {
10489 + cifs_server_dbg(VFS, "%s: Could not get %scryption key\n", __func__,
10490 + enc ? "en" : "de");
10491 +- return 0;
10492 ++ return rc;
10493 + }
10494 +
10495 + rc = smb3_crypto_aead_allocate(server);
10496 +@@ -3886,7 +3886,8 @@ smb3_is_transform_hdr(void *buf)
10497 + static int
10498 + decrypt_raw_data(struct TCP_Server_Info *server, char *buf,
10499 + unsigned int buf_data_size, struct page **pages,
10500 +- unsigned int npages, unsigned int page_data_size)
10501 ++ unsigned int npages, unsigned int page_data_size,
10502 ++ bool is_offloaded)
10503 + {
10504 + struct kvec iov[2];
10505 + struct smb_rqst rqst = {NULL};
10506 +@@ -3912,7 +3913,8 @@ decrypt_raw_data(struct TCP_Server_Info *server, char *buf,
10507 +
10508 + memmove(buf, iov[1].iov_base, buf_data_size);
10509 +
10510 +- server->total_read = buf_data_size + page_data_size;
10511 ++ if (!is_offloaded)
10512 ++ server->total_read = buf_data_size + page_data_size;
10513 +
10514 + return rc;
10515 + }
10516 +@@ -4126,7 +4128,7 @@ static void smb2_decrypt_offload(struct work_struct *work)
10517 + struct mid_q_entry *mid;
10518 +
10519 + rc = decrypt_raw_data(dw->server, dw->buf, dw->server->vals->read_rsp_size,
10520 +- dw->ppages, dw->npages, dw->len);
10521 ++ dw->ppages, dw->npages, dw->len, true);
10522 + if (rc) {
10523 + cifs_dbg(VFS, "error decrypting rc=%d\n", rc);
10524 + goto free_pages;
10525 +@@ -4232,7 +4234,7 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid,
10526 +
10527 + non_offloaded_decrypt:
10528 + rc = decrypt_raw_data(server, buf, server->vals->read_rsp_size,
10529 +- pages, npages, len);
10530 ++ pages, npages, len, false);
10531 + if (rc)
10532 + goto free_pages;
10533 +
10534 +@@ -4288,7 +4290,7 @@ receive_encrypted_standard(struct TCP_Server_Info *server,
10535 + server->total_read += length;
10536 +
10537 + buf_size = pdu_length - sizeof(struct smb2_transform_hdr);
10538 +- length = decrypt_raw_data(server, buf, buf_size, NULL, 0, 0);
10539 ++ length = decrypt_raw_data(server, buf, buf_size, NULL, 0, 0, false);
10540 + if (length)
10541 + return length;
10542 +
10543 +diff --git a/fs/d_path.c b/fs/d_path.c
10544 +index 0f1fc1743302f..a69e2cd36e6e3 100644
10545 +--- a/fs/d_path.c
10546 ++++ b/fs/d_path.c
10547 +@@ -102,6 +102,8 @@ restart:
10548 +
10549 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
10550 + struct mount *parent = READ_ONCE(mnt->mnt_parent);
10551 ++ struct mnt_namespace *mnt_ns;
10552 ++
10553 + /* Escaped? */
10554 + if (dentry != vfsmnt->mnt_root) {
10555 + bptr = *buffer;
10556 +@@ -116,7 +118,9 @@ restart:
10557 + vfsmnt = &mnt->mnt;
10558 + continue;
10559 + }
10560 +- if (is_mounted(vfsmnt) && !is_anon_ns(mnt->mnt_ns))
10561 ++ mnt_ns = READ_ONCE(mnt->mnt_ns);
10562 ++ /* open-coded is_mounted() to use local mnt_ns */
10563 ++ if (!IS_ERR_OR_NULL(mnt_ns) && !is_anon_ns(mnt_ns))
10564 + error = 1; // absolute root
10565 + else
10566 + error = 2; // detached or not attached yet
10567 +diff --git a/fs/dlm/config.c b/fs/dlm/config.c
10568 +index 3b21082e1b550..3b1012a3c4396 100644
10569 +--- a/fs/dlm/config.c
10570 ++++ b/fs/dlm/config.c
10571 +@@ -216,6 +216,7 @@ struct dlm_space {
10572 + struct list_head members;
10573 + struct mutex members_lock;
10574 + int members_count;
10575 ++ struct dlm_nodes *nds;
10576 + };
10577 +
10578 + struct dlm_comms {
10579 +@@ -424,6 +425,7 @@ static struct config_group *make_space(struct config_group *g, const char *name)
10580 + INIT_LIST_HEAD(&sp->members);
10581 + mutex_init(&sp->members_lock);
10582 + sp->members_count = 0;
10583 ++ sp->nds = nds;
10584 + return &sp->group;
10585 +
10586 + fail:
10587 +@@ -445,6 +447,7 @@ static void drop_space(struct config_group *g, struct config_item *i)
10588 + static void release_space(struct config_item *i)
10589 + {
10590 + struct dlm_space *sp = config_item_to_space(i);
10591 ++ kfree(sp->nds);
10592 + kfree(sp);
10593 + }
10594 +
10595 +diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c
10596 +index dbccf46f17709..37347ba868b70 100644
10597 +--- a/fs/ext4/fsmap.c
10598 ++++ b/fs/ext4/fsmap.c
10599 +@@ -108,6 +108,9 @@ static int ext4_getfsmap_helper(struct super_block *sb,
10600 +
10601 + /* Are we just counting mappings? */
10602 + if (info->gfi_head->fmh_count == 0) {
10603 ++ if (info->gfi_head->fmh_entries == UINT_MAX)
10604 ++ return EXT4_QUERY_RANGE_ABORT;
10605 ++
10606 + if (rec_fsblk > info->gfi_next_fsblk)
10607 + info->gfi_head->fmh_entries++;
10608 +
10609 +diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
10610 +index 170934430d7d7..029e693e201cf 100644
10611 +--- a/fs/f2fs/sysfs.c
10612 ++++ b/fs/f2fs/sysfs.c
10613 +@@ -788,4 +788,5 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
10614 + }
10615 + kobject_del(&sbi->s_kobj);
10616 + kobject_put(&sbi->s_kobj);
10617 ++ wait_for_completion(&sbi->s_kobj_unregister);
10618 + }
10619 +diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
10620 +index a30ea7ecb790a..80867a1a94f26 100644
10621 +--- a/fs/iomap/buffered-io.c
10622 ++++ b/fs/iomap/buffered-io.c
10623 +@@ -559,6 +559,7 @@ __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len,
10624 +
10625 + if (PageUptodate(page))
10626 + return 0;
10627 ++ ClearPageError(page);
10628 +
10629 + do {
10630 + iomap_adjust_read_range(inode, iop, &block_start,
10631 +diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
10632 +index 7b5f76efef02d..8c98fd92bf665 100644
10633 +--- a/fs/iomap/direct-io.c
10634 ++++ b/fs/iomap/direct-io.c
10635 +@@ -377,6 +377,16 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
10636 + return iomap_dio_bio_actor(inode, pos, length, dio, iomap);
10637 + case IOMAP_INLINE:
10638 + return iomap_dio_inline_actor(inode, pos, length, dio, iomap);
10639 ++ case IOMAP_DELALLOC:
10640 ++ /*
10641 ++ * DIO is not serialised against mmap() access at all, and so
10642 ++ * if the page_mkwrite occurs between the writeback and the
10643 ++ * iomap_apply() call in the DIO path, then it will see the
10644 ++ * DELALLOC block that the page-mkwrite allocated.
10645 ++ */
10646 ++ pr_warn_ratelimited("Direct I/O collision with buffered writes! File: %pD4 Comm: %.20s\n",
10647 ++ dio->iocb->ki_filp, current->comm);
10648 ++ return -EIO;
10649 + default:
10650 + WARN_ON_ONCE(1);
10651 + return -EIO;
10652 +diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
10653 +index d4359a1df3d5e..84933a0af49b6 100644
10654 +--- a/fs/ntfs/inode.c
10655 ++++ b/fs/ntfs/inode.c
10656 +@@ -1809,6 +1809,12 @@ int ntfs_read_inode_mount(struct inode *vi)
10657 + brelse(bh);
10658 + }
10659 +
10660 ++ if (le32_to_cpu(m->bytes_allocated) != vol->mft_record_size) {
10661 ++ ntfs_error(sb, "Incorrect mft record size %u in superblock, should be %u.",
10662 ++ le32_to_cpu(m->bytes_allocated), vol->mft_record_size);
10663 ++ goto err_out;
10664 ++ }
10665 ++
10666 + /* Apply the mst fixups. */
10667 + if (post_read_mst_fixup((NTFS_RECORD*)m, vol->mft_record_size)) {
10668 + /* FIXME: Try to use the $MFTMirr now. */
10669 +diff --git a/fs/proc/base.c b/fs/proc/base.c
10670 +index 529d0c6ec6f9c..b690074e65ffa 100644
10671 +--- a/fs/proc/base.c
10672 ++++ b/fs/proc/base.c
10673 +@@ -1036,7 +1036,6 @@ static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
10674 +
10675 + static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
10676 + {
10677 +- static DEFINE_MUTEX(oom_adj_mutex);
10678 + struct mm_struct *mm = NULL;
10679 + struct task_struct *task;
10680 + int err = 0;
10681 +@@ -1076,7 +1075,7 @@ static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
10682 + struct task_struct *p = find_lock_task_mm(task);
10683 +
10684 + if (p) {
10685 +- if (atomic_read(&p->mm->mm_users) > 1) {
10686 ++ if (test_bit(MMF_MULTIPROCESS, &p->mm->flags)) {
10687 + mm = p->mm;
10688 + mmgrab(mm);
10689 + }
10690 +diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
10691 +index 53429c29c7842..276c27fb99280 100644
10692 +--- a/fs/quota/quota_v2.c
10693 ++++ b/fs/quota/quota_v2.c
10694 +@@ -284,6 +284,7 @@ static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot)
10695 + d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
10696 + d->dqb_btime = cpu_to_le64(m->dqb_btime);
10697 + d->dqb_id = cpu_to_le32(from_kqid(&init_user_ns, dquot->dq_id));
10698 ++ d->dqb_pad = 0;
10699 + if (qtree_entry_unused(info, dp))
10700 + d->dqb_itime = cpu_to_le64(1);
10701 + }
10702 +diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
10703 +index 4146954549560..355523f4a4bf3 100644
10704 +--- a/fs/ramfs/file-nommu.c
10705 ++++ b/fs/ramfs/file-nommu.c
10706 +@@ -224,7 +224,7 @@ static unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
10707 + if (!pages)
10708 + goto out_free;
10709 +
10710 +- nr = find_get_pages(inode->i_mapping, &pgoff, lpages, pages);
10711 ++ nr = find_get_pages_contig(inode->i_mapping, pgoff, lpages, pages);
10712 + if (nr != lpages)
10713 + goto out_free_pages; /* leave if some pages were missing */
10714 +
10715 +diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
10716 +index 70387650436cf..ac35ddf0dd603 100644
10717 +--- a/fs/reiserfs/inode.c
10718 ++++ b/fs/reiserfs/inode.c
10719 +@@ -2161,7 +2161,8 @@ out_end_trans:
10720 + out_inserted_sd:
10721 + clear_nlink(inode);
10722 + th->t_trans_id = 0; /* so the caller can't use this handle later */
10723 +- unlock_new_inode(inode); /* OK to do even if we hadn't locked it */
10724 ++ if (inode->i_state & I_NEW)
10725 ++ unlock_new_inode(inode);
10726 + iput(inode);
10727 + return err;
10728 + }
10729 +diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
10730 +index a6bce5b1fb1dc..1b9c7a387dc71 100644
10731 +--- a/fs/reiserfs/super.c
10732 ++++ b/fs/reiserfs/super.c
10733 +@@ -1258,6 +1258,10 @@ static int reiserfs_parse_options(struct super_block *s,
10734 + "turned on.");
10735 + return 0;
10736 + }
10737 ++ if (qf_names[qtype] !=
10738 ++ REISERFS_SB(s)->s_qf_names[qtype])
10739 ++ kfree(qf_names[qtype]);
10740 ++ qf_names[qtype] = NULL;
10741 + if (*arg) { /* Some filename specified? */
10742 + if (REISERFS_SB(s)->s_qf_names[qtype]
10743 + && strcmp(REISERFS_SB(s)->s_qf_names[qtype],
10744 +@@ -1287,10 +1291,6 @@ static int reiserfs_parse_options(struct super_block *s,
10745 + else
10746 + *mount_options |= 1 << REISERFS_GRPQUOTA;
10747 + } else {
10748 +- if (qf_names[qtype] !=
10749 +- REISERFS_SB(s)->s_qf_names[qtype])
10750 +- kfree(qf_names[qtype]);
10751 +- qf_names[qtype] = NULL;
10752 + if (qtype == USRQUOTA)
10753 + *mount_options &= ~(1 << REISERFS_USRQUOTA);
10754 + else
10755 +diff --git a/fs/udf/inode.c b/fs/udf/inode.c
10756 +index ea80036d7897b..97a192eb9949c 100644
10757 +--- a/fs/udf/inode.c
10758 ++++ b/fs/udf/inode.c
10759 +@@ -139,21 +139,24 @@ void udf_evict_inode(struct inode *inode)
10760 + struct udf_inode_info *iinfo = UDF_I(inode);
10761 + int want_delete = 0;
10762 +
10763 +- if (!inode->i_nlink && !is_bad_inode(inode)) {
10764 +- want_delete = 1;
10765 +- udf_setsize(inode, 0);
10766 +- udf_update_inode(inode, IS_SYNC(inode));
10767 ++ if (!is_bad_inode(inode)) {
10768 ++ if (!inode->i_nlink) {
10769 ++ want_delete = 1;
10770 ++ udf_setsize(inode, 0);
10771 ++ udf_update_inode(inode, IS_SYNC(inode));
10772 ++ }
10773 ++ if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB &&
10774 ++ inode->i_size != iinfo->i_lenExtents) {
10775 ++ udf_warn(inode->i_sb,
10776 ++ "Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\n",
10777 ++ inode->i_ino, inode->i_mode,
10778 ++ (unsigned long long)inode->i_size,
10779 ++ (unsigned long long)iinfo->i_lenExtents);
10780 ++ }
10781 + }
10782 + truncate_inode_pages_final(&inode->i_data);
10783 + invalidate_inode_buffers(inode);
10784 + clear_inode(inode);
10785 +- if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB &&
10786 +- inode->i_size != iinfo->i_lenExtents) {
10787 +- udf_warn(inode->i_sb, "Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\n",
10788 +- inode->i_ino, inode->i_mode,
10789 +- (unsigned long long)inode->i_size,
10790 +- (unsigned long long)iinfo->i_lenExtents);
10791 +- }
10792 + kfree(iinfo->i_ext.i_data);
10793 + iinfo->i_ext.i_data = NULL;
10794 + udf_clear_extent_cache(inode);
10795 +diff --git a/fs/udf/super.c b/fs/udf/super.c
10796 +index 4baa1ca91e9be..a0cd766b41cdb 100644
10797 +--- a/fs/udf/super.c
10798 ++++ b/fs/udf/super.c
10799 +@@ -1352,6 +1352,12 @@ static int udf_load_sparable_map(struct super_block *sb,
10800 + (int)spm->numSparingTables);
10801 + return -EIO;
10802 + }
10803 ++ if (le32_to_cpu(spm->sizeSparingTable) > sb->s_blocksize) {
10804 ++ udf_err(sb, "error loading logical volume descriptor: "
10805 ++ "Too big sparing table size (%u)\n",
10806 ++ le32_to_cpu(spm->sizeSparingTable));
10807 ++ return -EIO;
10808 ++ }
10809 +
10810 + for (i = 0; i < spm->numSparingTables; i++) {
10811 + loc = le32_to_cpu(spm->locSparingTable[i]);
10812 +diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
10813 +index 8ea1efc97b41d..42085e70c01ac 100644
10814 +--- a/fs/xfs/libxfs/xfs_rtbitmap.c
10815 ++++ b/fs/xfs/libxfs/xfs_rtbitmap.c
10816 +@@ -1018,7 +1018,6 @@ xfs_rtalloc_query_range(
10817 + struct xfs_mount *mp = tp->t_mountp;
10818 + xfs_rtblock_t rtstart;
10819 + xfs_rtblock_t rtend;
10820 +- xfs_rtblock_t rem;
10821 + int is_free;
10822 + int error = 0;
10823 +
10824 +@@ -1027,13 +1026,12 @@ xfs_rtalloc_query_range(
10825 + if (low_rec->ar_startext >= mp->m_sb.sb_rextents ||
10826 + low_rec->ar_startext == high_rec->ar_startext)
10827 + return 0;
10828 +- if (high_rec->ar_startext > mp->m_sb.sb_rextents)
10829 +- high_rec->ar_startext = mp->m_sb.sb_rextents;
10830 ++ high_rec->ar_startext = min(high_rec->ar_startext,
10831 ++ mp->m_sb.sb_rextents - 1);
10832 +
10833 + /* Iterate the bitmap, looking for discrepancies. */
10834 + rtstart = low_rec->ar_startext;
10835 +- rem = high_rec->ar_startext - rtstart;
10836 +- while (rem) {
10837 ++ while (rtstart <= high_rec->ar_startext) {
10838 + /* Is the first block free? */
10839 + error = xfs_rtcheck_range(mp, tp, rtstart, 1, 1, &rtend,
10840 + &is_free);
10841 +@@ -1042,7 +1040,7 @@ xfs_rtalloc_query_range(
10842 +
10843 + /* How long does the extent go for? */
10844 + error = xfs_rtfind_forw(mp, tp, rtstart,
10845 +- high_rec->ar_startext - 1, &rtend);
10846 ++ high_rec->ar_startext, &rtend);
10847 + if (error)
10848 + break;
10849 +
10850 +@@ -1055,7 +1053,6 @@ xfs_rtalloc_query_range(
10851 + break;
10852 + }
10853 +
10854 +- rem -= rtend - rtstart + 1;
10855 + rtstart = rtend + 1;
10856 + }
10857 +
10858 +diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
10859 +index c13754e119be1..01c0933a4d10d 100644
10860 +--- a/fs/xfs/xfs_fsmap.c
10861 ++++ b/fs/xfs/xfs_fsmap.c
10862 +@@ -26,7 +26,7 @@
10863 + #include "xfs_rtalloc.h"
10864 +
10865 + /* Convert an xfs_fsmap to an fsmap. */
10866 +-void
10867 ++static void
10868 + xfs_fsmap_from_internal(
10869 + struct fsmap *dest,
10870 + struct xfs_fsmap *src)
10871 +@@ -154,8 +154,7 @@ xfs_fsmap_owner_from_rmap(
10872 + /* getfsmap query state */
10873 + struct xfs_getfsmap_info {
10874 + struct xfs_fsmap_head *head;
10875 +- xfs_fsmap_format_t formatter; /* formatting fn */
10876 +- void *format_arg; /* format buffer */
10877 ++ struct fsmap *fsmap_recs; /* mapping records */
10878 + struct xfs_buf *agf_bp; /* AGF, for refcount queries */
10879 + xfs_daddr_t next_daddr; /* next daddr we expect */
10880 + u64 missing_owner; /* owner of holes */
10881 +@@ -223,6 +222,20 @@ xfs_getfsmap_is_shared(
10882 + return 0;
10883 + }
10884 +
10885 ++static inline void
10886 ++xfs_getfsmap_format(
10887 ++ struct xfs_mount *mp,
10888 ++ struct xfs_fsmap *xfm,
10889 ++ struct xfs_getfsmap_info *info)
10890 ++{
10891 ++ struct fsmap *rec;
10892 ++
10893 ++ trace_xfs_getfsmap_mapping(mp, xfm);
10894 ++
10895 ++ rec = &info->fsmap_recs[info->head->fmh_entries++];
10896 ++ xfs_fsmap_from_internal(rec, xfm);
10897 ++}
10898 ++
10899 + /*
10900 + * Format a reverse mapping for getfsmap, having translated rm_startblock
10901 + * into the appropriate daddr units.
10902 +@@ -255,6 +268,9 @@ xfs_getfsmap_helper(
10903 +
10904 + /* Are we just counting mappings? */
10905 + if (info->head->fmh_count == 0) {
10906 ++ if (info->head->fmh_entries == UINT_MAX)
10907 ++ return -ECANCELED;
10908 ++
10909 + if (rec_daddr > info->next_daddr)
10910 + info->head->fmh_entries++;
10911 +
10912 +@@ -284,10 +300,7 @@ xfs_getfsmap_helper(
10913 + fmr.fmr_offset = 0;
10914 + fmr.fmr_length = rec_daddr - info->next_daddr;
10915 + fmr.fmr_flags = FMR_OF_SPECIAL_OWNER;
10916 +- error = info->formatter(&fmr, info->format_arg);
10917 +- if (error)
10918 +- return error;
10919 +- info->head->fmh_entries++;
10920 ++ xfs_getfsmap_format(mp, &fmr, info);
10921 + }
10922 +
10923 + if (info->last)
10924 +@@ -319,11 +332,8 @@ xfs_getfsmap_helper(
10925 + if (shared)
10926 + fmr.fmr_flags |= FMR_OF_SHARED;
10927 + }
10928 +- error = info->formatter(&fmr, info->format_arg);
10929 +- if (error)
10930 +- return error;
10931 +- info->head->fmh_entries++;
10932 +
10933 ++ xfs_getfsmap_format(mp, &fmr, info);
10934 + out:
10935 + rec_daddr += XFS_FSB_TO_BB(mp, rec->rm_blockcount);
10936 + if (info->next_daddr < rec_daddr)
10937 +@@ -791,11 +801,11 @@ xfs_getfsmap_check_keys(
10938 + #endif /* CONFIG_XFS_RT */
10939 +
10940 + /*
10941 +- * Get filesystem's extents as described in head, and format for
10942 +- * output. Calls formatter to fill the user's buffer until all
10943 +- * extents are mapped, until the passed-in head->fmh_count slots have
10944 +- * been filled, or until the formatter short-circuits the loop, if it
10945 +- * is tracking filled-in extents on its own.
10946 ++ * Get filesystem's extents as described in head, and format for output. Fills
10947 ++ * in the supplied records array until there are no more reverse mappings to
10948 ++ * return or head.fmh_entries == head.fmh_count. In the second case, this
10949 ++ * function returns -ECANCELED to indicate that more records would have been
10950 ++ * returned.
10951 + *
10952 + * Key to Confusion
10953 + * ----------------
10954 +@@ -815,8 +825,7 @@ int
10955 + xfs_getfsmap(
10956 + struct xfs_mount *mp,
10957 + struct xfs_fsmap_head *head,
10958 +- xfs_fsmap_format_t formatter,
10959 +- void *arg)
10960 ++ struct fsmap *fsmap_recs)
10961 + {
10962 + struct xfs_trans *tp = NULL;
10963 + struct xfs_fsmap dkeys[2]; /* per-dev keys */
10964 +@@ -891,8 +900,7 @@ xfs_getfsmap(
10965 +
10966 + info.next_daddr = head->fmh_keys[0].fmr_physical +
10967 + head->fmh_keys[0].fmr_length;
10968 +- info.formatter = formatter;
10969 +- info.format_arg = arg;
10970 ++ info.fsmap_recs = fsmap_recs;
10971 + info.head = head;
10972 +
10973 + /*
10974 +diff --git a/fs/xfs/xfs_fsmap.h b/fs/xfs/xfs_fsmap.h
10975 +index c6c57739b8626..a0775788e7b13 100644
10976 +--- a/fs/xfs/xfs_fsmap.h
10977 ++++ b/fs/xfs/xfs_fsmap.h
10978 +@@ -27,13 +27,9 @@ struct xfs_fsmap_head {
10979 + struct xfs_fsmap fmh_keys[2]; /* low and high keys */
10980 + };
10981 +
10982 +-void xfs_fsmap_from_internal(struct fsmap *dest, struct xfs_fsmap *src);
10983 + void xfs_fsmap_to_internal(struct xfs_fsmap *dest, struct fsmap *src);
10984 +
10985 +-/* fsmap to userspace formatter - copy to user & advance pointer */
10986 +-typedef int (*xfs_fsmap_format_t)(struct xfs_fsmap *, void *);
10987 +-
10988 + int xfs_getfsmap(struct xfs_mount *mp, struct xfs_fsmap_head *head,
10989 +- xfs_fsmap_format_t formatter, void *arg);
10990 ++ struct fsmap *out_recs);
10991 +
10992 + #endif /* __XFS_FSMAP_H__ */
10993 +diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
10994 +index 60c4526312771..bf0435dbec436 100644
10995 +--- a/fs/xfs/xfs_ioctl.c
10996 ++++ b/fs/xfs/xfs_ioctl.c
10997 +@@ -1832,39 +1832,17 @@ out_free_buf:
10998 + return error;
10999 + }
11000 +
11001 +-struct getfsmap_info {
11002 +- struct xfs_mount *mp;
11003 +- struct fsmap_head __user *data;
11004 +- unsigned int idx;
11005 +- __u32 last_flags;
11006 +-};
11007 +-
11008 +-STATIC int
11009 +-xfs_getfsmap_format(struct xfs_fsmap *xfm, void *priv)
11010 +-{
11011 +- struct getfsmap_info *info = priv;
11012 +- struct fsmap fm;
11013 +-
11014 +- trace_xfs_getfsmap_mapping(info->mp, xfm);
11015 +-
11016 +- info->last_flags = xfm->fmr_flags;
11017 +- xfs_fsmap_from_internal(&fm, xfm);
11018 +- if (copy_to_user(&info->data->fmh_recs[info->idx++], &fm,
11019 +- sizeof(struct fsmap)))
11020 +- return -EFAULT;
11021 +-
11022 +- return 0;
11023 +-}
11024 +-
11025 + STATIC int
11026 + xfs_ioc_getfsmap(
11027 + struct xfs_inode *ip,
11028 + struct fsmap_head __user *arg)
11029 + {
11030 +- struct getfsmap_info info = { NULL };
11031 + struct xfs_fsmap_head xhead = {0};
11032 + struct fsmap_head head;
11033 +- bool aborted = false;
11034 ++ struct fsmap *recs;
11035 ++ unsigned int count;
11036 ++ __u32 last_flags = 0;
11037 ++ bool done = false;
11038 + int error;
11039 +
11040 + if (copy_from_user(&head, arg, sizeof(struct fsmap_head)))
11041 +@@ -1876,38 +1854,112 @@ xfs_ioc_getfsmap(
11042 + sizeof(head.fmh_keys[1].fmr_reserved)))
11043 + return -EINVAL;
11044 +
11045 ++ /*
11046 ++ * Use an internal memory buffer so that we don't have to copy fsmap
11047 ++ * data to userspace while holding locks. Start by trying to allocate
11048 ++ * up to 128k for the buffer, but fall back to a single page if needed.
11049 ++ */
11050 ++ count = min_t(unsigned int, head.fmh_count,
11051 ++ 131072 / sizeof(struct fsmap));
11052 ++ recs = kvzalloc(count * sizeof(struct fsmap), GFP_KERNEL);
11053 ++ if (!recs) {
11054 ++ count = min_t(unsigned int, head.fmh_count,
11055 ++ PAGE_SIZE / sizeof(struct fsmap));
11056 ++ recs = kvzalloc(count * sizeof(struct fsmap), GFP_KERNEL);
11057 ++ if (!recs)
11058 ++ return -ENOMEM;
11059 ++ }
11060 ++
11061 + xhead.fmh_iflags = head.fmh_iflags;
11062 +- xhead.fmh_count = head.fmh_count;
11063 + xfs_fsmap_to_internal(&xhead.fmh_keys[0], &head.fmh_keys[0]);
11064 + xfs_fsmap_to_internal(&xhead.fmh_keys[1], &head.fmh_keys[1]);
11065 +
11066 + trace_xfs_getfsmap_low_key(ip->i_mount, &xhead.fmh_keys[0]);
11067 + trace_xfs_getfsmap_high_key(ip->i_mount, &xhead.fmh_keys[1]);
11068 +
11069 +- info.mp = ip->i_mount;
11070 +- info.data = arg;
11071 +- error = xfs_getfsmap(ip->i_mount, &xhead, xfs_getfsmap_format, &info);
11072 +- if (error == -ECANCELED) {
11073 +- error = 0;
11074 +- aborted = true;
11075 +- } else if (error)
11076 +- return error;
11077 ++ head.fmh_entries = 0;
11078 ++ do {
11079 ++ struct fsmap __user *user_recs;
11080 ++ struct fsmap *last_rec;
11081 ++
11082 ++ user_recs = &arg->fmh_recs[head.fmh_entries];
11083 ++ xhead.fmh_entries = 0;
11084 ++ xhead.fmh_count = min_t(unsigned int, count,
11085 ++ head.fmh_count - head.fmh_entries);
11086 ++
11087 ++ /* Run query, record how many entries we got. */
11088 ++ error = xfs_getfsmap(ip->i_mount, &xhead, recs);
11089 ++ switch (error) {
11090 ++ case 0:
11091 ++ /*
11092 ++ * There are no more records in the result set. Copy
11093 ++ * whatever we got to userspace and break out.
11094 ++ */
11095 ++ done = true;
11096 ++ break;
11097 ++ case -ECANCELED:
11098 ++ /*
11099 ++ * The internal memory buffer is full. Copy whatever
11100 ++ * records we got to userspace and go again if we have
11101 ++ * not yet filled the userspace buffer.
11102 ++ */
11103 ++ error = 0;
11104 ++ break;
11105 ++ default:
11106 ++ goto out_free;
11107 ++ }
11108 ++ head.fmh_entries += xhead.fmh_entries;
11109 ++ head.fmh_oflags = xhead.fmh_oflags;
11110 +
11111 +- /* If we didn't abort, set the "last" flag in the last fmx */
11112 +- if (!aborted && info.idx) {
11113 +- info.last_flags |= FMR_OF_LAST;
11114 +- if (copy_to_user(&info.data->fmh_recs[info.idx - 1].fmr_flags,
11115 +- &info.last_flags, sizeof(info.last_flags)))
11116 +- return -EFAULT;
11117 ++ /*
11118 ++ * If the caller wanted a record count or there aren't any
11119 ++ * new records to return, we're done.
11120 ++ */
11121 ++ if (head.fmh_count == 0 || xhead.fmh_entries == 0)
11122 ++ break;
11123 ++
11124 ++ /* Copy all the records we got out to userspace. */
11125 ++ if (copy_to_user(user_recs, recs,
11126 ++ xhead.fmh_entries * sizeof(struct fsmap))) {
11127 ++ error = -EFAULT;
11128 ++ goto out_free;
11129 ++ }
11130 ++
11131 ++ /* Remember the last record flags we copied to userspace. */
11132 ++ last_rec = &recs[xhead.fmh_entries - 1];
11133 ++ last_flags = last_rec->fmr_flags;
11134 ++
11135 ++ /* Set up the low key for the next iteration. */
11136 ++ xfs_fsmap_to_internal(&xhead.fmh_keys[0], last_rec);
11137 ++ trace_xfs_getfsmap_low_key(ip->i_mount, &xhead.fmh_keys[0]);
11138 ++ } while (!done && head.fmh_entries < head.fmh_count);
11139 ++
11140 ++ /*
11141 ++ * If there are no more records in the query result set and we're not
11142 ++ * in counting mode, mark the last record returned with the LAST flag.
11143 ++ */
11144 ++ if (done && head.fmh_count > 0 && head.fmh_entries > 0) {
11145 ++ struct fsmap __user *user_rec;
11146 ++
11147 ++ last_flags |= FMR_OF_LAST;
11148 ++ user_rec = &arg->fmh_recs[head.fmh_entries - 1];
11149 ++
11150 ++ if (copy_to_user(&user_rec->fmr_flags, &last_flags,
11151 ++ sizeof(last_flags))) {
11152 ++ error = -EFAULT;
11153 ++ goto out_free;
11154 ++ }
11155 + }
11156 +
11157 + /* copy back header */
11158 +- head.fmh_entries = xhead.fmh_entries;
11159 +- head.fmh_oflags = xhead.fmh_oflags;
11160 +- if (copy_to_user(arg, &head, sizeof(struct fsmap_head)))
11161 +- return -EFAULT;
11162 ++ if (copy_to_user(arg, &head, sizeof(struct fsmap_head))) {
11163 ++ error = -EFAULT;
11164 ++ goto out_free;
11165 ++ }
11166 +
11167 +- return 0;
11168 ++out_free:
11169 ++ kmem_free(recs);
11170 ++ return error;
11171 + }
11172 +
11173 + STATIC int
11174 +diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
11175 +index 4a48a8c75b4f7..b583669370825 100644
11176 +--- a/fs/xfs/xfs_rtalloc.c
11177 ++++ b/fs/xfs/xfs_rtalloc.c
11178 +@@ -247,6 +247,9 @@ xfs_rtallocate_extent_block(
11179 + end = XFS_BLOCKTOBIT(mp, bbno + 1) - 1;
11180 + i <= end;
11181 + i++) {
11182 ++ /* Make sure we don't scan off the end of the rt volume. */
11183 ++ maxlen = min(mp->m_sb.sb_rextents, i + maxlen) - i;
11184 ++
11185 + /*
11186 + * See if there's a free extent of maxlen starting at i.
11187 + * If it's not so then next will contain the first non-free.
11188 +@@ -442,6 +445,14 @@ xfs_rtallocate_extent_near(
11189 + */
11190 + if (bno >= mp->m_sb.sb_rextents)
11191 + bno = mp->m_sb.sb_rextents - 1;
11192 ++
11193 ++ /* Make sure we don't run off the end of the rt volume. */
11194 ++ maxlen = min(mp->m_sb.sb_rextents, bno + maxlen) - bno;
11195 ++ if (maxlen < minlen) {
11196 ++ *rtblock = NULLRTBLOCK;
11197 ++ return 0;
11198 ++ }
11199 ++
11200 + /*
11201 + * Try the exact allocation first.
11202 + */
11203 +diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
11204 +index 26a6d58ca78cc..81c7ea83e8079 100644
11205 +--- a/include/linux/bpf_verifier.h
11206 ++++ b/include/linux/bpf_verifier.h
11207 +@@ -342,6 +342,7 @@ struct bpf_subprog_info {
11208 + u32 start; /* insn idx of function entry point */
11209 + u32 linfo_idx; /* The idx to the main_prog->aux->linfo */
11210 + u16 stack_depth; /* max. stack depth used by this function */
11211 ++ bool has_tail_call;
11212 + };
11213 +
11214 + /* single container for all structs
11215 +diff --git a/include/linux/oom.h b/include/linux/oom.h
11216 +index c696c265f0193..b9df34326772c 100644
11217 +--- a/include/linux/oom.h
11218 ++++ b/include/linux/oom.h
11219 +@@ -55,6 +55,7 @@ struct oom_control {
11220 + };
11221 +
11222 + extern struct mutex oom_lock;
11223 ++extern struct mutex oom_adj_mutex;
11224 +
11225 + static inline void set_current_oom_origin(void)
11226 + {
11227 +diff --git a/include/linux/overflow.h b/include/linux/overflow.h
11228 +index 659045046468f..50c93ca0c3d6f 100644
11229 +--- a/include/linux/overflow.h
11230 ++++ b/include/linux/overflow.h
11231 +@@ -3,6 +3,7 @@
11232 + #define __LINUX_OVERFLOW_H
11233 +
11234 + #include <linux/compiler.h>
11235 ++#include <linux/limits.h>
11236 +
11237 + /*
11238 + * In the fallback code below, we need to compute the minimum and
11239 +diff --git a/include/linux/page_owner.h b/include/linux/page_owner.h
11240 +index 8679ccd722e89..3468794f83d23 100644
11241 +--- a/include/linux/page_owner.h
11242 ++++ b/include/linux/page_owner.h
11243 +@@ -11,7 +11,7 @@ extern struct page_ext_operations page_owner_ops;
11244 + extern void __reset_page_owner(struct page *page, unsigned int order);
11245 + extern void __set_page_owner(struct page *page,
11246 + unsigned int order, gfp_t gfp_mask);
11247 +-extern void __split_page_owner(struct page *page, unsigned int order);
11248 ++extern void __split_page_owner(struct page *page, unsigned int nr);
11249 + extern void __copy_page_owner(struct page *oldpage, struct page *newpage);
11250 + extern void __set_page_owner_migrate_reason(struct page *page, int reason);
11251 + extern void __dump_page_owner(struct page *page);
11252 +@@ -31,10 +31,10 @@ static inline void set_page_owner(struct page *page,
11253 + __set_page_owner(page, order, gfp_mask);
11254 + }
11255 +
11256 +-static inline void split_page_owner(struct page *page, unsigned int order)
11257 ++static inline void split_page_owner(struct page *page, unsigned int nr)
11258 + {
11259 + if (static_branch_unlikely(&page_owner_inited))
11260 +- __split_page_owner(page, order);
11261 ++ __split_page_owner(page, nr);
11262 + }
11263 + static inline void copy_page_owner(struct page *oldpage, struct page *newpage)
11264 + {
11265 +diff --git a/include/linux/pci.h b/include/linux/pci.h
11266 +index e92bd9b32f369..6a6a819c5b49b 100644
11267 +--- a/include/linux/pci.h
11268 ++++ b/include/linux/pci.h
11269 +@@ -423,6 +423,7 @@ struct pci_dev {
11270 + unsigned int is_probed:1; /* Device probing in progress */
11271 + unsigned int link_active_reporting:1;/* Device capable of reporting link active */
11272 + unsigned int no_vf_scan:1; /* Don't scan for VFs after IOV enablement */
11273 ++ unsigned int no_command_memory:1; /* No PCI_COMMAND_MEMORY */
11274 + pci_dev_flags_t dev_flags;
11275 + atomic_t enable_cnt; /* pci_enable_device has been called */
11276 +
11277 +diff --git a/include/linux/platform_data/dma-dw.h b/include/linux/platform_data/dma-dw.h
11278 +index f3eaf9ec00a1b..70078be166e3c 100644
11279 +--- a/include/linux/platform_data/dma-dw.h
11280 ++++ b/include/linux/platform_data/dma-dw.h
11281 +@@ -21,6 +21,7 @@
11282 + * @dst_id: dst request line
11283 + * @m_master: memory master for transfers on allocated channel
11284 + * @p_master: peripheral master for transfers on allocated channel
11285 ++ * @channels: mask of the channels permitted for allocation (zero value means any)
11286 + * @hs_polarity:set active low polarity of handshake interface
11287 + */
11288 + struct dw_dma_slave {
11289 +@@ -29,6 +30,7 @@ struct dw_dma_slave {
11290 + u8 dst_id;
11291 + u8 m_master;
11292 + u8 p_master;
11293 ++ u8 channels;
11294 + bool hs_polarity;
11295 + };
11296 +
11297 +diff --git a/include/linux/sched/coredump.h b/include/linux/sched/coredump.h
11298 +index ecdc6542070f1..dfd82eab29025 100644
11299 +--- a/include/linux/sched/coredump.h
11300 ++++ b/include/linux/sched/coredump.h
11301 +@@ -72,6 +72,7 @@ static inline int get_dumpable(struct mm_struct *mm)
11302 + #define MMF_DISABLE_THP 24 /* disable THP for all VMAs */
11303 + #define MMF_OOM_VICTIM 25 /* mm is the oom victim */
11304 + #define MMF_OOM_REAP_QUEUED 26 /* mm was queued for oom_reaper */
11305 ++#define MMF_MULTIPROCESS 27 /* mm is shared between processes */
11306 + #define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP)
11307 +
11308 + #define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\
11309 +diff --git a/include/net/ip.h b/include/net/ip.h
11310 +index 4b15cc1c224c6..0278d63c15274 100644
11311 +--- a/include/net/ip.h
11312 ++++ b/include/net/ip.h
11313 +@@ -439,12 +439,18 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst,
11314 + bool forwarding)
11315 + {
11316 + struct net *net = dev_net(dst->dev);
11317 ++ unsigned int mtu;
11318 +
11319 + if (net->ipv4.sysctl_ip_fwd_use_pmtu ||
11320 + ip_mtu_locked(dst) ||
11321 + !forwarding)
11322 + return dst_mtu(dst);
11323 +
11324 ++ /* 'forwarding = true' case should always honour route mtu */
11325 ++ mtu = dst_metric_raw(dst, RTAX_MTU);
11326 ++ if (mtu)
11327 ++ return mtu;
11328 ++
11329 + return min(READ_ONCE(dst->dev->mtu), IP_MAX_MTU);
11330 + }
11331 +
11332 +diff --git a/include/net/netfilter/nf_log.h b/include/net/netfilter/nf_log.h
11333 +index 0d3920896d502..716db4a0fed89 100644
11334 +--- a/include/net/netfilter/nf_log.h
11335 ++++ b/include/net/netfilter/nf_log.h
11336 +@@ -108,6 +108,7 @@ int nf_log_dump_tcp_header(struct nf_log_buf *m, const struct sk_buff *skb,
11337 + unsigned int logflags);
11338 + void nf_log_dump_sk_uid_gid(struct net *net, struct nf_log_buf *m,
11339 + struct sock *sk);
11340 ++void nf_log_dump_vlan(struct nf_log_buf *m, const struct sk_buff *skb);
11341 + void nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf,
11342 + unsigned int hooknum, const struct sk_buff *skb,
11343 + const struct net_device *in,
11344 +diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h
11345 +index a91b2af64ec47..8e94279af47df 100644
11346 +--- a/include/rdma/ib_umem.h
11347 ++++ b/include/rdma/ib_umem.h
11348 +@@ -95,10 +95,11 @@ static inline int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offs
11349 + size_t length) {
11350 + return -EINVAL;
11351 + }
11352 +-static inline int ib_umem_find_best_pgsz(struct ib_umem *umem,
11353 +- unsigned long pgsz_bitmap,
11354 +- unsigned long virt) {
11355 +- return -EINVAL;
11356 ++static inline unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
11357 ++ unsigned long pgsz_bitmap,
11358 ++ unsigned long virt)
11359 ++{
11360 ++ return 0;
11361 + }
11362 +
11363 + #endif /* CONFIG_INFINIBAND_USER_MEM */
11364 +diff --git a/include/scsi/scsi_common.h b/include/scsi/scsi_common.h
11365 +index 731ac09ed2313..5b567b43e1b16 100644
11366 +--- a/include/scsi/scsi_common.h
11367 ++++ b/include/scsi/scsi_common.h
11368 +@@ -25,6 +25,13 @@ scsi_command_size(const unsigned char *cmnd)
11369 + scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]);
11370 + }
11371 +
11372 ++static inline unsigned char
11373 ++scsi_command_control(const unsigned char *cmnd)
11374 ++{
11375 ++ return (cmnd[0] == VARIABLE_LENGTH_CMD) ?
11376 ++ cmnd[1] : cmnd[COMMAND_SIZE(cmnd[0]) - 1];
11377 ++}
11378 ++
11379 + /* Returns a human-readable name for the device */
11380 + extern const char *scsi_device_type(unsigned type);
11381 +
11382 +diff --git a/include/sound/hda_codec.h b/include/sound/hda_codec.h
11383 +index 65c056ce91128..8341e2c489824 100644
11384 +--- a/include/sound/hda_codec.h
11385 ++++ b/include/sound/hda_codec.h
11386 +@@ -254,6 +254,7 @@ struct hda_codec {
11387 + unsigned int force_pin_prefix:1; /* Add location prefix */
11388 + unsigned int link_down_at_suspend:1; /* link down at runtime suspend */
11389 + unsigned int relaxed_resume:1; /* don't resume forcibly for jack */
11390 ++ unsigned int forced_resume:1; /* forced resume for jack */
11391 +
11392 + #ifdef CONFIG_PM
11393 + unsigned long power_on_acct;
11394 +diff --git a/include/trace/events/target.h b/include/trace/events/target.h
11395 +index 914a872dd3435..e87a3716b0ac9 100644
11396 +--- a/include/trace/events/target.h
11397 ++++ b/include/trace/events/target.h
11398 +@@ -140,6 +140,7 @@ TRACE_EVENT(target_sequencer_start,
11399 + __field( unsigned int, opcode )
11400 + __field( unsigned int, data_length )
11401 + __field( unsigned int, task_attribute )
11402 ++ __field( unsigned char, control )
11403 + __array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE )
11404 + __string( initiator, cmd->se_sess->se_node_acl->initiatorname )
11405 + ),
11406 +@@ -149,6 +150,7 @@ TRACE_EVENT(target_sequencer_start,
11407 + __entry->opcode = cmd->t_task_cdb[0];
11408 + __entry->data_length = cmd->data_length;
11409 + __entry->task_attribute = cmd->sam_task_attr;
11410 ++ __entry->control = scsi_command_control(cmd->t_task_cdb);
11411 + memcpy(__entry->cdb, cmd->t_task_cdb, TCM_MAX_COMMAND_SIZE);
11412 + __assign_str(initiator, cmd->se_sess->se_node_acl->initiatorname);
11413 + ),
11414 +@@ -158,9 +160,7 @@ TRACE_EVENT(target_sequencer_start,
11415 + show_opcode_name(__entry->opcode),
11416 + __entry->data_length, __print_hex(__entry->cdb, 16),
11417 + show_task_attribute_name(__entry->task_attribute),
11418 +- scsi_command_size(__entry->cdb) <= 16 ?
11419 +- __entry->cdb[scsi_command_size(__entry->cdb) - 1] :
11420 +- __entry->cdb[1]
11421 ++ __entry->control
11422 + )
11423 + );
11424 +
11425 +@@ -175,6 +175,7 @@ TRACE_EVENT(target_cmd_complete,
11426 + __field( unsigned int, opcode )
11427 + __field( unsigned int, data_length )
11428 + __field( unsigned int, task_attribute )
11429 ++ __field( unsigned char, control )
11430 + __field( unsigned char, scsi_status )
11431 + __field( unsigned char, sense_length )
11432 + __array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE )
11433 +@@ -187,6 +188,7 @@ TRACE_EVENT(target_cmd_complete,
11434 + __entry->opcode = cmd->t_task_cdb[0];
11435 + __entry->data_length = cmd->data_length;
11436 + __entry->task_attribute = cmd->sam_task_attr;
11437 ++ __entry->control = scsi_command_control(cmd->t_task_cdb);
11438 + __entry->scsi_status = cmd->scsi_status;
11439 + __entry->sense_length = cmd->scsi_status == SAM_STAT_CHECK_CONDITION ?
11440 + min(18, ((u8 *) cmd->sense_buffer)[SPC_ADD_SENSE_LEN_OFFSET] + 8) : 0;
11441 +@@ -203,9 +205,7 @@ TRACE_EVENT(target_cmd_complete,
11442 + show_opcode_name(__entry->opcode),
11443 + __entry->data_length, __print_hex(__entry->cdb, 16),
11444 + show_task_attribute_name(__entry->task_attribute),
11445 +- scsi_command_size(__entry->cdb) <= 16 ?
11446 +- __entry->cdb[scsi_command_size(__entry->cdb) - 1] :
11447 +- __entry->cdb[1]
11448 ++ __entry->control
11449 + )
11450 + );
11451 +
11452 +diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
11453 +index bb7b271397a66..ceccd980ffcfe 100644
11454 +--- a/include/uapi/linux/perf_event.h
11455 ++++ b/include/uapi/linux/perf_event.h
11456 +@@ -1131,7 +1131,7 @@ union perf_mem_data_src {
11457 +
11458 + #define PERF_MEM_SNOOPX_FWD 0x01 /* forward */
11459 + /* 1 free */
11460 +-#define PERF_MEM_SNOOPX_SHIFT 37
11461 ++#define PERF_MEM_SNOOPX_SHIFT 38
11462 +
11463 + /* locked instruction */
11464 + #define PERF_MEM_LOCK_NA 0x01 /* not available */
11465 +diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
11466 +index ae27dd77a73cb..507474f79195f 100644
11467 +--- a/kernel/bpf/verifier.c
11468 ++++ b/kernel/bpf/verifier.c
11469 +@@ -1160,6 +1160,10 @@ static int check_subprogs(struct bpf_verifier_env *env)
11470 + for (i = 0; i < insn_cnt; i++) {
11471 + u8 code = insn[i].code;
11472 +
11473 ++ if (code == (BPF_JMP | BPF_CALL) &&
11474 ++ insn[i].imm == BPF_FUNC_tail_call &&
11475 ++ insn[i].src_reg != BPF_PSEUDO_CALL)
11476 ++ subprog[cur_subprog].has_tail_call = true;
11477 + if (BPF_CLASS(code) != BPF_JMP && BPF_CLASS(code) != BPF_JMP32)
11478 + goto next;
11479 + if (BPF_OP(code) == BPF_EXIT || BPF_OP(code) == BPF_CALL)
11480 +@@ -2612,6 +2616,31 @@ static int check_max_stack_depth(struct bpf_verifier_env *env)
11481 + int ret_prog[MAX_CALL_FRAMES];
11482 +
11483 + process_func:
11484 ++ /* protect against potential stack overflow that might happen when
11485 ++ * bpf2bpf calls get combined with tailcalls. Limit the caller's stack
11486 ++ * depth for such case down to 256 so that the worst case scenario
11487 ++ * would result in 8k stack size (32 which is tailcall limit * 256 =
11488 ++ * 8k).
11489 ++ *
11490 ++ * To get the idea what might happen, see an example:
11491 ++ * func1 -> sub rsp, 128
11492 ++ * subfunc1 -> sub rsp, 256
11493 ++ * tailcall1 -> add rsp, 256
11494 ++ * func2 -> sub rsp, 192 (total stack size = 128 + 192 = 320)
11495 ++ * subfunc2 -> sub rsp, 64
11496 ++ * subfunc22 -> sub rsp, 128
11497 ++ * tailcall2 -> add rsp, 128
11498 ++ * func3 -> sub rsp, 32 (total stack size 128 + 192 + 64 + 32 = 416)
11499 ++ *
11500 ++ * tailcall will unwind the current stack frame but it will not get rid
11501 ++ * of caller's stack as shown on the example above.
11502 ++ */
11503 ++ if (idx && subprog[idx].has_tail_call && depth >= 256) {
11504 ++ verbose(env,
11505 ++ "tail_calls are not allowed when call stack of previous frames is %d bytes. Too large\n",
11506 ++ depth);
11507 ++ return -EACCES;
11508 ++ }
11509 + /* round up to 32-bytes, since this is granularity
11510 + * of interpreter stack size
11511 + */
11512 +diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
11513 +index 3a5184eb6977d..46821793637a1 100644
11514 +--- a/kernel/debug/kdb/kdb_io.c
11515 ++++ b/kernel/debug/kdb/kdb_io.c
11516 +@@ -679,12 +679,16 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
11517 + size_avail = sizeof(kdb_buffer) - len;
11518 + goto kdb_print_out;
11519 + }
11520 +- if (kdb_grepping_flag >= KDB_GREPPING_FLAG_SEARCH)
11521 ++ if (kdb_grepping_flag >= KDB_GREPPING_FLAG_SEARCH) {
11522 + /*
11523 + * This was a interactive search (using '/' at more
11524 +- * prompt) and it has completed. Clear the flag.
11525 ++ * prompt) and it has completed. Replace the \0 with
11526 ++ * its original value to ensure multi-line strings
11527 ++ * are handled properly, and return to normal mode.
11528 + */
11529 ++ *cphold = replaced_byte;
11530 + kdb_grepping_flag = 0;
11531 ++ }
11532 + /*
11533 + * at this point the string is a full line and
11534 + * should be printed, up to the null.
11535 +diff --git a/kernel/fork.c b/kernel/fork.c
11536 +index 594272569a80f..e3d5963d8c6f5 100644
11537 +--- a/kernel/fork.c
11538 ++++ b/kernel/fork.c
11539 +@@ -1750,6 +1750,25 @@ static __always_inline void delayed_free_task(struct task_struct *tsk)
11540 + free_task(tsk);
11541 + }
11542 +
11543 ++static void copy_oom_score_adj(u64 clone_flags, struct task_struct *tsk)
11544 ++{
11545 ++ /* Skip if kernel thread */
11546 ++ if (!tsk->mm)
11547 ++ return;
11548 ++
11549 ++ /* Skip if spawning a thread or using vfork */
11550 ++ if ((clone_flags & (CLONE_VM | CLONE_THREAD | CLONE_VFORK)) != CLONE_VM)
11551 ++ return;
11552 ++
11553 ++ /* We need to synchronize with __set_oom_adj */
11554 ++ mutex_lock(&oom_adj_mutex);
11555 ++ set_bit(MMF_MULTIPROCESS, &tsk->mm->flags);
11556 ++ /* Update the values in case they were changed after copy_signal */
11557 ++ tsk->signal->oom_score_adj = current->signal->oom_score_adj;
11558 ++ tsk->signal->oom_score_adj_min = current->signal->oom_score_adj_min;
11559 ++ mutex_unlock(&oom_adj_mutex);
11560 ++}
11561 ++
11562 + /*
11563 + * This creates a new process as a copy of the old one,
11564 + * but does not actually start it yet.
11565 +@@ -2222,6 +2241,8 @@ static __latent_entropy struct task_struct *copy_process(
11566 + trace_task_newtask(p, clone_flags);
11567 + uprobe_copy_process(p, clone_flags);
11568 +
11569 ++ copy_oom_score_adj(clone_flags, p);
11570 ++
11571 + return p;
11572 +
11573 + bad_fork_cancel_cgroup:
11574 +diff --git a/kernel/module.c b/kernel/module.c
11575 +index 819c5d3b4c295..45513909b01d5 100644
11576 +--- a/kernel/module.c
11577 ++++ b/kernel/module.c
11578 +@@ -88,8 +88,9 @@ EXPORT_SYMBOL_GPL(module_mutex);
11579 + static LIST_HEAD(modules);
11580 +
11581 + /* Work queue for freeing init sections in success case */
11582 +-static struct work_struct init_free_wq;
11583 +-static struct llist_head init_free_list;
11584 ++static void do_free_init(struct work_struct *w);
11585 ++static DECLARE_WORK(init_free_wq, do_free_init);
11586 ++static LLIST_HEAD(init_free_list);
11587 +
11588 + #ifdef CONFIG_MODULES_TREE_LOOKUP
11589 +
11590 +@@ -3563,14 +3564,6 @@ static void do_free_init(struct work_struct *w)
11591 + }
11592 + }
11593 +
11594 +-static int __init modules_wq_init(void)
11595 +-{
11596 +- INIT_WORK(&init_free_wq, do_free_init);
11597 +- init_llist_head(&init_free_list);
11598 +- return 0;
11599 +-}
11600 +-module_init(modules_wq_init);
11601 +-
11602 + /*
11603 + * This is where the real work happens.
11604 + *
11605 +diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
11606 +index b6c5895ced36b..69c4cd472def3 100644
11607 +--- a/kernel/power/hibernate.c
11608 ++++ b/kernel/power/hibernate.c
11609 +@@ -839,17 +839,6 @@ static int software_resume(void)
11610 +
11611 + /* Check if the device is there */
11612 + swsusp_resume_device = name_to_dev_t(resume_file);
11613 +-
11614 +- /*
11615 +- * name_to_dev_t is ineffective to verify parition if resume_file is in
11616 +- * integer format. (e.g. major:minor)
11617 +- */
11618 +- if (isdigit(resume_file[0]) && resume_wait) {
11619 +- int partno;
11620 +- while (!get_gendisk(swsusp_resume_device, &partno))
11621 +- msleep(10);
11622 +- }
11623 +-
11624 + if (!swsusp_resume_device) {
11625 + /*
11626 + * Some device discovery might still be in progress; we need
11627 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
11628 +index 79ce22de44095..4511532b08b84 100644
11629 +--- a/kernel/sched/core.c
11630 ++++ b/kernel/sched/core.c
11631 +@@ -36,7 +36,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_overutilized_tp);
11632 +
11633 + DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
11634 +
11635 +-#if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_JUMP_LABEL)
11636 ++#ifdef CONFIG_SCHED_DEBUG
11637 + /*
11638 + * Debugging: various feature bits
11639 + *
11640 +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
11641 +index b02a83ff40687..dddaf61378f62 100644
11642 +--- a/kernel/sched/fair.c
11643 ++++ b/kernel/sched/fair.c
11644 +@@ -5936,7 +5936,7 @@ static int select_idle_core(struct task_struct *p, struct sched_domain *sd, int
11645 + /*
11646 + * Scan the local SMT mask for idle CPUs.
11647 + */
11648 +-static int select_idle_smt(struct task_struct *p, int target)
11649 ++static int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int target)
11650 + {
11651 + int cpu, si_cpu = -1;
11652 +
11653 +@@ -5944,7 +5944,8 @@ static int select_idle_smt(struct task_struct *p, int target)
11654 + return -1;
11655 +
11656 + for_each_cpu(cpu, cpu_smt_mask(target)) {
11657 +- if (!cpumask_test_cpu(cpu, p->cpus_ptr))
11658 ++ if (!cpumask_test_cpu(cpu, p->cpus_ptr) ||
11659 ++ !cpumask_test_cpu(cpu, sched_domain_span(sd)))
11660 + continue;
11661 + if (available_idle_cpu(cpu))
11662 + return cpu;
11663 +@@ -5962,7 +5963,7 @@ static inline int select_idle_core(struct task_struct *p, struct sched_domain *s
11664 + return -1;
11665 + }
11666 +
11667 +-static inline int select_idle_smt(struct task_struct *p, int target)
11668 ++static inline int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int target)
11669 + {
11670 + return -1;
11671 + }
11672 +@@ -6072,7 +6073,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
11673 + if ((unsigned)i < nr_cpumask_bits)
11674 + return i;
11675 +
11676 +- i = select_idle_smt(p, target);
11677 ++ i = select_idle_smt(p, sd, target);
11678 + if ((unsigned)i < nr_cpumask_bits)
11679 + return i;
11680 +
11681 +diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
11682 +index 9f2a9e34a78d5..3e7590813844f 100644
11683 +--- a/kernel/sched/sched.h
11684 ++++ b/kernel/sched/sched.h
11685 +@@ -1568,7 +1568,7 @@ enum {
11686 +
11687 + #undef SCHED_FEAT
11688 +
11689 +-#if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_JUMP_LABEL)
11690 ++#ifdef CONFIG_SCHED_DEBUG
11691 +
11692 + /*
11693 + * To support run-time toggling of sched features, all the translation units
11694 +@@ -1576,6 +1576,7 @@ enum {
11695 + */
11696 + extern const_debug unsigned int sysctl_sched_features;
11697 +
11698 ++#ifdef CONFIG_JUMP_LABEL
11699 + #define SCHED_FEAT(name, enabled) \
11700 + static __always_inline bool static_branch_##name(struct static_key *key) \
11701 + { \
11702 +@@ -1588,7 +1589,13 @@ static __always_inline bool static_branch_##name(struct static_key *key) \
11703 + extern struct static_key sched_feat_keys[__SCHED_FEAT_NR];
11704 + #define sched_feat(x) (static_branch_##x(&sched_feat_keys[__SCHED_FEAT_##x]))
11705 +
11706 +-#else /* !(SCHED_DEBUG && CONFIG_JUMP_LABEL) */
11707 ++#else /* !CONFIG_JUMP_LABEL */
11708 ++
11709 ++#define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x))
11710 ++
11711 ++#endif /* CONFIG_JUMP_LABEL */
11712 ++
11713 ++#else /* !SCHED_DEBUG */
11714 +
11715 + /*
11716 + * Each translation unit has its own copy of sysctl_sched_features to allow
11717 +@@ -1604,7 +1611,7 @@ static const_debug __maybe_unused unsigned int sysctl_sched_features =
11718 +
11719 + #define sched_feat(x) !!(sysctl_sched_features & (1UL << __SCHED_FEAT_##x))
11720 +
11721 +-#endif /* SCHED_DEBUG && CONFIG_JUMP_LABEL */
11722 ++#endif /* SCHED_DEBUG */
11723 +
11724 + extern struct static_key_false sched_numa_balancing;
11725 + extern struct static_key_false sched_schedstats;
11726 +diff --git a/lib/crc32.c b/lib/crc32.c
11727 +index 4a20455d1f61e..bf60ef26a45c2 100644
11728 +--- a/lib/crc32.c
11729 ++++ b/lib/crc32.c
11730 +@@ -331,7 +331,7 @@ static inline u32 __pure crc32_be_generic(u32 crc, unsigned char const *p,
11731 + return crc;
11732 + }
11733 +
11734 +-#if CRC_LE_BITS == 1
11735 ++#if CRC_BE_BITS == 1
11736 + u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len)
11737 + {
11738 + return crc32_be_generic(crc, p, len, NULL, CRC32_POLY_BE);
11739 +diff --git a/lib/idr.c b/lib/idr.c
11740 +index c2cf2c52bbde5..4d2eef0259d2c 100644
11741 +--- a/lib/idr.c
11742 ++++ b/lib/idr.c
11743 +@@ -470,6 +470,7 @@ alloc:
11744 + goto retry;
11745 + nospc:
11746 + xas_unlock_irqrestore(&xas, flags);
11747 ++ kfree(alloc);
11748 + return -ENOSPC;
11749 + }
11750 + EXPORT_SYMBOL(ida_alloc_range);
11751 +diff --git a/mm/filemap.c b/mm/filemap.c
11752 +index 51b2cb5aa5030..db542b4948838 100644
11753 +--- a/mm/filemap.c
11754 ++++ b/mm/filemap.c
11755 +@@ -847,10 +847,10 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
11756 + }
11757 + EXPORT_SYMBOL_GPL(replace_page_cache_page);
11758 +
11759 +-static int __add_to_page_cache_locked(struct page *page,
11760 +- struct address_space *mapping,
11761 +- pgoff_t offset, gfp_t gfp_mask,
11762 +- void **shadowp)
11763 ++noinline int __add_to_page_cache_locked(struct page *page,
11764 ++ struct address_space *mapping,
11765 ++ pgoff_t offset, gfp_t gfp_mask,
11766 ++ void **shadowp)
11767 + {
11768 + XA_STATE(xas, &mapping->i_pages, offset);
11769 + int huge = PageHuge(page);
11770 +diff --git a/mm/huge_memory.c b/mm/huge_memory.c
11771 +index 873de55d93fb2..9295d9d70681e 100644
11772 +--- a/mm/huge_memory.c
11773 ++++ b/mm/huge_memory.c
11774 +@@ -2569,7 +2569,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,
11775 +
11776 + ClearPageCompound(head);
11777 +
11778 +- split_page_owner(head, HPAGE_PMD_ORDER);
11779 ++ split_page_owner(head, HPAGE_PMD_NR);
11780 +
11781 + /* See comment in __split_huge_page_tail() */
11782 + if (PageAnon(head)) {
11783 +diff --git a/mm/memcontrol.c b/mm/memcontrol.c
11784 +index ca1632850fb76..edf98f8588eeb 100644
11785 +--- a/mm/memcontrol.c
11786 ++++ b/mm/memcontrol.c
11787 +@@ -5398,7 +5398,7 @@ static struct page *mc_handle_swap_pte(struct vm_area_struct *vma,
11788 + struct page *page = NULL;
11789 + swp_entry_t ent = pte_to_swp_entry(ptent);
11790 +
11791 +- if (!(mc.flags & MOVE_ANON) || non_swap_entry(ent))
11792 ++ if (!(mc.flags & MOVE_ANON))
11793 + return NULL;
11794 +
11795 + /*
11796 +@@ -5417,6 +5417,9 @@ static struct page *mc_handle_swap_pte(struct vm_area_struct *vma,
11797 + return page;
11798 + }
11799 +
11800 ++ if (non_swap_entry(ent))
11801 ++ return NULL;
11802 ++
11803 + /*
11804 + * Because lookup_swap_cache() updates some statistics counter,
11805 + * we call find_get_page() with swapper_space directly.
11806 +diff --git a/mm/oom_kill.c b/mm/oom_kill.c
11807 +index d58c481b3df83..212e718743018 100644
11808 +--- a/mm/oom_kill.c
11809 ++++ b/mm/oom_kill.c
11810 +@@ -63,6 +63,8 @@ int sysctl_oom_dump_tasks = 1;
11811 + * and mark_oom_victim
11812 + */
11813 + DEFINE_MUTEX(oom_lock);
11814 ++/* Serializes oom_score_adj and oom_score_adj_min updates */
11815 ++DEFINE_MUTEX(oom_adj_mutex);
11816 +
11817 + static inline bool is_memcg_oom(struct oom_control *oc)
11818 + {
11819 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
11820 +index aff0bb4629bdf..c20e664866c33 100644
11821 +--- a/mm/page_alloc.c
11822 ++++ b/mm/page_alloc.c
11823 +@@ -3130,7 +3130,7 @@ void split_page(struct page *page, unsigned int order)
11824 +
11825 + for (i = 1; i < (1 << order); i++)
11826 + set_page_refcounted(page + i);
11827 +- split_page_owner(page, order);
11828 ++ split_page_owner(page, 1 << order);
11829 + }
11830 + EXPORT_SYMBOL_GPL(split_page);
11831 +
11832 +@@ -3385,7 +3385,7 @@ static inline bool __should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
11833 +
11834 + #endif /* CONFIG_FAIL_PAGE_ALLOC */
11835 +
11836 +-static noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
11837 ++noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
11838 + {
11839 + return __should_fail_alloc_page(gfp_mask, order);
11840 + }
11841 +diff --git a/mm/page_owner.c b/mm/page_owner.c
11842 +index 18ecde9f45b24..83d08943bcdee 100644
11843 +--- a/mm/page_owner.c
11844 ++++ b/mm/page_owner.c
11845 +@@ -204,7 +204,7 @@ void __set_page_owner_migrate_reason(struct page *page, int reason)
11846 + page_owner->last_migrate_reason = reason;
11847 + }
11848 +
11849 +-void __split_page_owner(struct page *page, unsigned int order)
11850 ++void __split_page_owner(struct page *page, unsigned int nr)
11851 + {
11852 + int i;
11853 + struct page_ext *page_ext = lookup_page_ext(page);
11854 +@@ -213,7 +213,7 @@ void __split_page_owner(struct page *page, unsigned int order)
11855 + if (unlikely(!page_ext))
11856 + return;
11857 +
11858 +- for (i = 0; i < (1 << order); i++) {
11859 ++ for (i = 0; i < nr; i++) {
11860 + page_owner = get_page_owner(page_ext);
11861 + page_owner->order = 0;
11862 + page_ext = page_ext_next(page_ext);
11863 +diff --git a/mm/swapfile.c b/mm/swapfile.c
11864 +index cf62bdb7b3045..ff83ffe7a9108 100644
11865 +--- a/mm/swapfile.c
11866 ++++ b/mm/swapfile.c
11867 +@@ -3284,7 +3284,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
11868 + error = inode_drain_writes(inode);
11869 + if (error) {
11870 + inode->i_flags &= ~S_SWAPFILE;
11871 +- goto bad_swap_unlock_inode;
11872 ++ goto free_swap_address_space;
11873 + }
11874 +
11875 + mutex_lock(&swapon_mutex);
11876 +@@ -3309,6 +3309,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
11877 +
11878 + error = 0;
11879 + goto out;
11880 ++free_swap_address_space:
11881 ++ exit_swap_address_space(p->type);
11882 + bad_swap_unlock_inode:
11883 + inode_unlock(inode);
11884 + bad_swap:
11885 +diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
11886 +index 40e96a610e2b4..8648c5211ebe6 100644
11887 +--- a/net/bluetooth/l2cap_sock.c
11888 ++++ b/net/bluetooth/l2cap_sock.c
11889 +@@ -1344,8 +1344,6 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err)
11890 +
11891 + parent = bt_sk(sk)->parent;
11892 +
11893 +- sock_set_flag(sk, SOCK_ZAPPED);
11894 +-
11895 + switch (chan->state) {
11896 + case BT_OPEN:
11897 + case BT_BOUND:
11898 +@@ -1372,8 +1370,11 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err)
11899 +
11900 + break;
11901 + }
11902 +-
11903 + release_sock(sk);
11904 ++
11905 ++ /* Only zap after cleanup to avoid use after free race */
11906 ++ sock_set_flag(sk, SOCK_ZAPPED);
11907 ++
11908 + }
11909 +
11910 + static void l2cap_sock_state_change_cb(struct l2cap_chan *chan, int state,
11911 +diff --git a/net/bridge/netfilter/ebt_dnat.c b/net/bridge/netfilter/ebt_dnat.c
11912 +index 12a4f4d936810..3fda71a8579d1 100644
11913 +--- a/net/bridge/netfilter/ebt_dnat.c
11914 ++++ b/net/bridge/netfilter/ebt_dnat.c
11915 +@@ -21,7 +21,7 @@ ebt_dnat_tg(struct sk_buff *skb, const struct xt_action_param *par)
11916 + {
11917 + const struct ebt_nat_info *info = par->targinfo;
11918 +
11919 +- if (skb_ensure_writable(skb, ETH_ALEN))
11920 ++ if (skb_ensure_writable(skb, 0))
11921 + return EBT_DROP;
11922 +
11923 + ether_addr_copy(eth_hdr(skb)->h_dest, info->mac);
11924 +diff --git a/net/bridge/netfilter/ebt_redirect.c b/net/bridge/netfilter/ebt_redirect.c
11925 +index 0cad62a4052b9..307790562b492 100644
11926 +--- a/net/bridge/netfilter/ebt_redirect.c
11927 ++++ b/net/bridge/netfilter/ebt_redirect.c
11928 +@@ -21,7 +21,7 @@ ebt_redirect_tg(struct sk_buff *skb, const struct xt_action_param *par)
11929 + {
11930 + const struct ebt_redirect_info *info = par->targinfo;
11931 +
11932 +- if (skb_ensure_writable(skb, ETH_ALEN))
11933 ++ if (skb_ensure_writable(skb, 0))
11934 + return EBT_DROP;
11935 +
11936 + if (xt_hooknum(par) != NF_BR_BROUTING)
11937 +diff --git a/net/bridge/netfilter/ebt_snat.c b/net/bridge/netfilter/ebt_snat.c
11938 +index 27443bf229a3b..7dfbcdfc30e5d 100644
11939 +--- a/net/bridge/netfilter/ebt_snat.c
11940 ++++ b/net/bridge/netfilter/ebt_snat.c
11941 +@@ -22,7 +22,7 @@ ebt_snat_tg(struct sk_buff *skb, const struct xt_action_param *par)
11942 + {
11943 + const struct ebt_nat_info *info = par->targinfo;
11944 +
11945 +- if (skb_ensure_writable(skb, ETH_ALEN * 2))
11946 ++ if (skb_ensure_writable(skb, 0))
11947 + return EBT_DROP;
11948 +
11949 + ether_addr_copy(eth_hdr(skb)->h_source, info->mac);
11950 +diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
11951 +index a8dd956b5e8e1..916fdf2464bc2 100644
11952 +--- a/net/can/j1939/transport.c
11953 ++++ b/net/can/j1939/transport.c
11954 +@@ -580,6 +580,7 @@ sk_buff *j1939_tp_tx_dat_new(struct j1939_priv *priv,
11955 + skb->dev = priv->ndev;
11956 + can_skb_reserve(skb);
11957 + can_skb_prv(skb)->ifindex = priv->ndev->ifindex;
11958 ++ can_skb_prv(skb)->skbcnt = 0;
11959 + /* reserve CAN header */
11960 + skb_reserve(skb, offsetof(struct can_frame, data));
11961 +
11962 +@@ -1487,6 +1488,7 @@ j1939_session *j1939_session_fresh_new(struct j1939_priv *priv,
11963 + skb->dev = priv->ndev;
11964 + can_skb_reserve(skb);
11965 + can_skb_prv(skb)->ifindex = priv->ndev->ifindex;
11966 ++ can_skb_prv(skb)->skbcnt = 0;
11967 + skcb = j1939_skb_to_cb(skb);
11968 + memcpy(skcb, rel_skcb, sizeof(*skcb));
11969 +
11970 +diff --git a/net/core/filter.c b/net/core/filter.c
11971 +index c441f9961e917..b040b7bf28582 100644
11972 +--- a/net/core/filter.c
11973 ++++ b/net/core/filter.c
11974 +@@ -4270,7 +4270,8 @@ BPF_CALL_5(bpf_setsockopt, struct bpf_sock_ops_kern *, bpf_sock,
11975 + cmpxchg(&sk->sk_pacing_status,
11976 + SK_PACING_NONE,
11977 + SK_PACING_NEEDED);
11978 +- sk->sk_max_pacing_rate = (val == ~0U) ? ~0UL : val;
11979 ++ sk->sk_max_pacing_rate = (val == ~0U) ?
11980 ++ ~0UL : (unsigned int)val;
11981 + sk->sk_pacing_rate = min(sk->sk_pacing_rate,
11982 + sk->sk_max_pacing_rate);
11983 + break;
11984 +diff --git a/net/core/sock.c b/net/core/sock.c
11985 +index 919f1a1739e90..1b765e62658f0 100644
11986 +--- a/net/core/sock.c
11987 ++++ b/net/core/sock.c
11988 +@@ -928,8 +928,6 @@ set_rcvbuf:
11989 + break;
11990 +
11991 + case SO_TIMESTAMPING_NEW:
11992 +- sock_set_flag(sk, SOCK_TSTAMP_NEW);
11993 +- /* fall through */
11994 + case SO_TIMESTAMPING_OLD:
11995 + if (val & ~SOF_TIMESTAMPING_MASK) {
11996 + ret = -EINVAL;
11997 +@@ -958,16 +956,14 @@ set_rcvbuf:
11998 + }
11999 +
12000 + sk->sk_tsflags = val;
12001 ++ sock_valbool_flag(sk, SOCK_TSTAMP_NEW, optname == SO_TIMESTAMPING_NEW);
12002 ++
12003 + if (val & SOF_TIMESTAMPING_RX_SOFTWARE)
12004 + sock_enable_timestamp(sk,
12005 + SOCK_TIMESTAMPING_RX_SOFTWARE);
12006 +- else {
12007 +- if (optname == SO_TIMESTAMPING_NEW)
12008 +- sock_reset_flag(sk, SOCK_TSTAMP_NEW);
12009 +-
12010 ++ else
12011 + sock_disable_timestamp(sk,
12012 + (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE));
12013 +- }
12014 + break;
12015 +
12016 + case SO_RCVLOWAT:
12017 +@@ -1110,7 +1106,7 @@ set_rcvbuf:
12018 +
12019 + case SO_MAX_PACING_RATE:
12020 + {
12021 +- unsigned long ulval = (val == ~0U) ? ~0UL : val;
12022 ++ unsigned long ulval = (val == ~0U) ? ~0UL : (unsigned int)val;
12023 +
12024 + if (sizeof(ulval) != sizeof(val) &&
12025 + optlen >= sizeof(ulval) &&
12026 +diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
12027 +index 73f46cb5e51da..d00533aea1f05 100644
12028 +--- a/net/ipv4/icmp.c
12029 ++++ b/net/ipv4/icmp.c
12030 +@@ -239,7 +239,7 @@ static struct {
12031 + /**
12032 + * icmp_global_allow - Are we allowed to send one more ICMP message ?
12033 + *
12034 +- * Uses a token bucket to limit our ICMP messages to sysctl_icmp_msgs_per_sec.
12035 ++ * Uses a token bucket to limit our ICMP messages to ~sysctl_icmp_msgs_per_sec.
12036 + * Returns false if we reached the limit and can not send another packet.
12037 + * Note: called with BH disabled
12038 + */
12039 +@@ -267,7 +267,10 @@ bool icmp_global_allow(void)
12040 + }
12041 + credit = min_t(u32, icmp_global.credit + incr, sysctl_icmp_msgs_burst);
12042 + if (credit) {
12043 +- credit--;
12044 ++ /* We want to use a credit of one in average, but need to randomize
12045 ++ * it for security reasons.
12046 ++ */
12047 ++ credit = max_t(int, credit - prandom_u32_max(3), 0);
12048 + rc = true;
12049 + }
12050 + WRITE_ONCE(icmp_global.credit, credit);
12051 +diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
12052 +index 85ba1453ba5ca..fedad3a3e61b8 100644
12053 +--- a/net/ipv4/ip_gre.c
12054 ++++ b/net/ipv4/ip_gre.c
12055 +@@ -603,9 +603,7 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
12056 + }
12057 +
12058 + if (dev->header_ops) {
12059 +- /* Need space for new headers */
12060 +- if (skb_cow_head(skb, dev->needed_headroom -
12061 +- (tunnel->hlen + sizeof(struct iphdr))))
12062 ++ if (skb_cow_head(skb, 0))
12063 + goto free_skb;
12064 +
12065 + tnl_params = (const struct iphdr *)skb->data;
12066 +@@ -723,7 +721,11 @@ static void ipgre_link_update(struct net_device *dev, bool set_mtu)
12067 + len = tunnel->tun_hlen - len;
12068 + tunnel->hlen = tunnel->hlen + len;
12069 +
12070 +- dev->needed_headroom = dev->needed_headroom + len;
12071 ++ if (dev->header_ops)
12072 ++ dev->hard_header_len += len;
12073 ++ else
12074 ++ dev->needed_headroom += len;
12075 ++
12076 + if (set_mtu)
12077 + dev->mtu = max_t(int, dev->mtu - len, 68);
12078 +
12079 +@@ -926,6 +928,7 @@ static void __gre_tunnel_init(struct net_device *dev)
12080 + tunnel->parms.iph.protocol = IPPROTO_GRE;
12081 +
12082 + tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen;
12083 ++ dev->needed_headroom = tunnel->hlen + sizeof(tunnel->parms.iph);
12084 +
12085 + dev->features |= GRE_FEATURES;
12086 + dev->hw_features |= GRE_FEATURES;
12087 +@@ -969,10 +972,14 @@ static int ipgre_tunnel_init(struct net_device *dev)
12088 + return -EINVAL;
12089 + dev->flags = IFF_BROADCAST;
12090 + dev->header_ops = &ipgre_header_ops;
12091 ++ dev->hard_header_len = tunnel->hlen + sizeof(*iph);
12092 ++ dev->needed_headroom = 0;
12093 + }
12094 + #endif
12095 + } else if (!tunnel->collect_md) {
12096 + dev->header_ops = &ipgre_header_ops;
12097 ++ dev->hard_header_len = tunnel->hlen + sizeof(*iph);
12098 ++ dev->needed_headroom = 0;
12099 + }
12100 +
12101 + return ip_tunnel_init(dev);
12102 +diff --git a/net/ipv4/netfilter/nf_log_arp.c b/net/ipv4/netfilter/nf_log_arp.c
12103 +index 7a83f881efa9e..136030ad2e546 100644
12104 +--- a/net/ipv4/netfilter/nf_log_arp.c
12105 ++++ b/net/ipv4/netfilter/nf_log_arp.c
12106 +@@ -43,16 +43,31 @@ static void dump_arp_packet(struct nf_log_buf *m,
12107 + const struct nf_loginfo *info,
12108 + const struct sk_buff *skb, unsigned int nhoff)
12109 + {
12110 +- const struct arphdr *ah;
12111 +- struct arphdr _arph;
12112 + const struct arppayload *ap;
12113 + struct arppayload _arpp;
12114 ++ const struct arphdr *ah;
12115 ++ unsigned int logflags;
12116 ++ struct arphdr _arph;
12117 +
12118 + ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
12119 + if (ah == NULL) {
12120 + nf_log_buf_add(m, "TRUNCATED");
12121 + return;
12122 + }
12123 ++
12124 ++ if (info->type == NF_LOG_TYPE_LOG)
12125 ++ logflags = info->u.log.logflags;
12126 ++ else
12127 ++ logflags = NF_LOG_DEFAULT_MASK;
12128 ++
12129 ++ if (logflags & NF_LOG_MACDECODE) {
12130 ++ nf_log_buf_add(m, "MACSRC=%pM MACDST=%pM ",
12131 ++ eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest);
12132 ++ nf_log_dump_vlan(m, skb);
12133 ++ nf_log_buf_add(m, "MACPROTO=%04x ",
12134 ++ ntohs(eth_hdr(skb)->h_proto));
12135 ++ }
12136 ++
12137 + nf_log_buf_add(m, "ARP HTYPE=%d PTYPE=0x%04x OPCODE=%d",
12138 + ntohs(ah->ar_hrd), ntohs(ah->ar_pro), ntohs(ah->ar_op));
12139 +
12140 +diff --git a/net/ipv4/netfilter/nf_log_ipv4.c b/net/ipv4/netfilter/nf_log_ipv4.c
12141 +index 4b2d49cc9f1a1..cb288ffbcfde2 100644
12142 +--- a/net/ipv4/netfilter/nf_log_ipv4.c
12143 ++++ b/net/ipv4/netfilter/nf_log_ipv4.c
12144 +@@ -284,8 +284,10 @@ static void dump_ipv4_mac_header(struct nf_log_buf *m,
12145 +
12146 + switch (dev->type) {
12147 + case ARPHRD_ETHER:
12148 +- nf_log_buf_add(m, "MACSRC=%pM MACDST=%pM MACPROTO=%04x ",
12149 +- eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
12150 ++ nf_log_buf_add(m, "MACSRC=%pM MACDST=%pM ",
12151 ++ eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest);
12152 ++ nf_log_dump_vlan(m, skb);
12153 ++ nf_log_buf_add(m, "MACPROTO=%04x ",
12154 + ntohs(eth_hdr(skb)->h_proto));
12155 + return;
12156 + default:
12157 +diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
12158 +index afa2c5049845f..ea32b113089d3 100644
12159 +--- a/net/ipv4/nexthop.c
12160 ++++ b/net/ipv4/nexthop.c
12161 +@@ -763,7 +763,7 @@ static void remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
12162 + remove_nh_grp_entry(net, nhge, nlinfo);
12163 +
12164 + /* make sure all see the newly published array before releasing rtnl */
12165 +- synchronize_rcu();
12166 ++ synchronize_net();
12167 + }
12168 +
12169 + static void remove_nexthop_group(struct nexthop *nh, struct nl_info *nlinfo)
12170 +diff --git a/net/ipv4/route.c b/net/ipv4/route.c
12171 +index 7a5f64cf1fdd2..a293d4968d1eb 100644
12172 +--- a/net/ipv4/route.c
12173 ++++ b/net/ipv4/route.c
12174 +@@ -2728,10 +2728,12 @@ struct rtable *ip_route_output_flow(struct net *net, struct flowi4 *flp4,
12175 + if (IS_ERR(rt))
12176 + return rt;
12177 +
12178 +- if (flp4->flowi4_proto)
12179 ++ if (flp4->flowi4_proto) {
12180 ++ flp4->flowi4_oif = rt->dst.dev->ifindex;
12181 + rt = (struct rtable *)xfrm_lookup_route(net, &rt->dst,
12182 + flowi4_to_flowi(flp4),
12183 + sk, 0);
12184 ++ }
12185 +
12186 + return rt;
12187 + }
12188 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
12189 +index ab5358281000e..62f8ba4048180 100644
12190 +--- a/net/ipv4/tcp_input.c
12191 ++++ b/net/ipv4/tcp_input.c
12192 +@@ -5696,6 +5696,8 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
12193 + tcp_data_snd_check(sk);
12194 + if (!inet_csk_ack_scheduled(sk))
12195 + goto no_ack;
12196 ++ } else {
12197 ++ tcp_update_wl(tp, TCP_SKB_CB(skb)->seq);
12198 + }
12199 +
12200 + __tcp_ack_snd_check(sk, 0);
12201 +diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
12202 +index 9ca6c32065ec6..0646fce31b67a 100644
12203 +--- a/net/ipv6/ip6_fib.c
12204 ++++ b/net/ipv6/ip6_fib.c
12205 +@@ -2519,8 +2519,10 @@ static void *ipv6_route_seq_start(struct seq_file *seq, loff_t *pos)
12206 + iter->skip = *pos;
12207 +
12208 + if (iter->tbl) {
12209 ++ loff_t p = 0;
12210 ++
12211 + ipv6_route_seq_setup_walk(iter, net);
12212 +- return ipv6_route_seq_next(seq, NULL, pos);
12213 ++ return ipv6_route_seq_next(seq, NULL, &p);
12214 + } else {
12215 + return NULL;
12216 + }
12217 +diff --git a/net/ipv6/netfilter/nf_log_ipv6.c b/net/ipv6/netfilter/nf_log_ipv6.c
12218 +index 22b80db6d8826..5b40258d3a5e9 100644
12219 +--- a/net/ipv6/netfilter/nf_log_ipv6.c
12220 ++++ b/net/ipv6/netfilter/nf_log_ipv6.c
12221 +@@ -297,9 +297,11 @@ static void dump_ipv6_mac_header(struct nf_log_buf *m,
12222 +
12223 + switch (dev->type) {
12224 + case ARPHRD_ETHER:
12225 +- nf_log_buf_add(m, "MACSRC=%pM MACDST=%pM MACPROTO=%04x ",
12226 +- eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
12227 +- ntohs(eth_hdr(skb)->h_proto));
12228 ++ nf_log_buf_add(m, "MACSRC=%pM MACDST=%pM ",
12229 ++ eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest);
12230 ++ nf_log_dump_vlan(m, skb);
12231 ++ nf_log_buf_add(m, "MACPROTO=%04x ",
12232 ++ ntohs(eth_hdr(skb)->h_proto));
12233 + return;
12234 + default:
12235 + break;
12236 +diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
12237 +index a9dda5c228f60..fa293feef935d 100644
12238 +--- a/net/mac80211/cfg.c
12239 ++++ b/net/mac80211/cfg.c
12240 +@@ -698,7 +698,8 @@ void sta_set_rate_info_tx(struct sta_info *sta,
12241 + u16 brate;
12242 +
12243 + sband = ieee80211_get_sband(sta->sdata);
12244 +- if (sband) {
12245 ++ WARN_ON_ONCE(sband && !sband->bitrates);
12246 ++ if (sband && sband->bitrates) {
12247 + brate = sband->bitrates[rate->idx].bitrate;
12248 + rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
12249 + }
12250 +diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
12251 +index f5d96107af6de..4f14d8a06915a 100644
12252 +--- a/net/mac80211/sta_info.c
12253 ++++ b/net/mac80211/sta_info.c
12254 +@@ -2083,6 +2083,10 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u32 rate,
12255 + int rate_idx = STA_STATS_GET(LEGACY_IDX, rate);
12256 +
12257 + sband = local->hw.wiphy->bands[band];
12258 ++
12259 ++ if (WARN_ON_ONCE(!sband->bitrates))
12260 ++ break;
12261 ++
12262 + brate = sband->bitrates[rate_idx].bitrate;
12263 + if (rinfo->bw == RATE_INFO_BW_5)
12264 + shift = 2;
12265 +diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
12266 +index 3cccc88ef817b..99168af0c28d9 100644
12267 +--- a/net/netfilter/ipvs/ip_vs_ctl.c
12268 ++++ b/net/netfilter/ipvs/ip_vs_ctl.c
12269 +@@ -2465,6 +2465,10 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
12270 + /* Set timeout values for (tcp tcpfin udp) */
12271 + ret = ip_vs_set_timeout(ipvs, (struct ip_vs_timeout_user *)arg);
12272 + goto out_unlock;
12273 ++ } else if (!len) {
12274 ++ /* No more commands with len == 0 below */
12275 ++ ret = -EINVAL;
12276 ++ goto out_unlock;
12277 + }
12278 +
12279 + usvc_compat = (struct ip_vs_service_user *)arg;
12280 +@@ -2541,9 +2545,6 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
12281 + break;
12282 + case IP_VS_SO_SET_DELDEST:
12283 + ret = ip_vs_del_dest(svc, &udest);
12284 +- break;
12285 +- default:
12286 +- ret = -EINVAL;
12287 + }
12288 +
12289 + out_unlock:
12290 +diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
12291 +index c62a131a60948..cefc39878b1a4 100644
12292 +--- a/net/netfilter/ipvs/ip_vs_xmit.c
12293 ++++ b/net/netfilter/ipvs/ip_vs_xmit.c
12294 +@@ -615,6 +615,8 @@ static inline int ip_vs_tunnel_xmit_prepare(struct sk_buff *skb,
12295 + if (ret == NF_ACCEPT) {
12296 + nf_reset_ct(skb);
12297 + skb_forward_csum(skb);
12298 ++ if (skb->dev)
12299 ++ skb->tstamp = 0;
12300 + }
12301 + return ret;
12302 + }
12303 +@@ -655,6 +657,8 @@ static inline int ip_vs_nat_send_or_cont(int pf, struct sk_buff *skb,
12304 +
12305 + if (!local) {
12306 + skb_forward_csum(skb);
12307 ++ if (skb->dev)
12308 ++ skb->tstamp = 0;
12309 + NF_HOOK(pf, NF_INET_LOCAL_OUT, cp->ipvs->net, NULL, skb,
12310 + NULL, skb_dst(skb)->dev, dst_output);
12311 + } else
12312 +@@ -675,6 +679,8 @@ static inline int ip_vs_send_or_cont(int pf, struct sk_buff *skb,
12313 + if (!local) {
12314 + ip_vs_drop_early_demux_sk(skb);
12315 + skb_forward_csum(skb);
12316 ++ if (skb->dev)
12317 ++ skb->tstamp = 0;
12318 + NF_HOOK(pf, NF_INET_LOCAL_OUT, cp->ipvs->net, NULL, skb,
12319 + NULL, skb_dst(skb)->dev, dst_output);
12320 + } else
12321 +diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
12322 +index 1926fd56df56a..848b137151c26 100644
12323 +--- a/net/netfilter/nf_conntrack_proto_tcp.c
12324 ++++ b/net/netfilter/nf_conntrack_proto_tcp.c
12325 +@@ -541,13 +541,20 @@ static bool tcp_in_window(const struct nf_conn *ct,
12326 + swin = win << sender->td_scale;
12327 + sender->td_maxwin = (swin == 0 ? 1 : swin);
12328 + sender->td_maxend = end + sender->td_maxwin;
12329 +- /*
12330 +- * We haven't seen traffic in the other direction yet
12331 +- * but we have to tweak window tracking to pass III
12332 +- * and IV until that happens.
12333 +- */
12334 +- if (receiver->td_maxwin == 0)
12335 ++ if (receiver->td_maxwin == 0) {
12336 ++ /* We haven't seen traffic in the other
12337 ++ * direction yet but we have to tweak window
12338 ++ * tracking to pass III and IV until that
12339 ++ * happens.
12340 ++ */
12341 + receiver->td_end = receiver->td_maxend = sack;
12342 ++ } else if (sack == receiver->td_end + 1) {
12343 ++ /* Likely a reply to a keepalive.
12344 ++ * Needed for III.
12345 ++ */
12346 ++ receiver->td_end++;
12347 ++ }
12348 ++
12349 + }
12350 + } else if (((state->state == TCP_CONNTRACK_SYN_SENT
12351 + && dir == IP_CT_DIR_ORIGINAL)
12352 +diff --git a/net/netfilter/nf_dup_netdev.c b/net/netfilter/nf_dup_netdev.c
12353 +index f108a76925dd8..ec6e7d6860163 100644
12354 +--- a/net/netfilter/nf_dup_netdev.c
12355 ++++ b/net/netfilter/nf_dup_netdev.c
12356 +@@ -19,6 +19,7 @@ static void nf_do_netdev_egress(struct sk_buff *skb, struct net_device *dev)
12357 + skb_push(skb, skb->mac_len);
12358 +
12359 + skb->dev = dev;
12360 ++ skb->tstamp = 0;
12361 + dev_queue_xmit(skb);
12362 + }
12363 +
12364 +diff --git a/net/netfilter/nf_log_common.c b/net/netfilter/nf_log_common.c
12365 +index ae5628ddbe6d7..fd7c5f0f5c25b 100644
12366 +--- a/net/netfilter/nf_log_common.c
12367 ++++ b/net/netfilter/nf_log_common.c
12368 +@@ -171,6 +171,18 @@ nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf,
12369 + }
12370 + EXPORT_SYMBOL_GPL(nf_log_dump_packet_common);
12371 +
12372 ++void nf_log_dump_vlan(struct nf_log_buf *m, const struct sk_buff *skb)
12373 ++{
12374 ++ u16 vid;
12375 ++
12376 ++ if (!skb_vlan_tag_present(skb))
12377 ++ return;
12378 ++
12379 ++ vid = skb_vlan_tag_get(skb);
12380 ++ nf_log_buf_add(m, "VPROTO=%04x VID=%u ", ntohs(skb->vlan_proto), vid);
12381 ++}
12382 ++EXPORT_SYMBOL_GPL(nf_log_dump_vlan);
12383 ++
12384 + /* bridge and netdev logging families share this code. */
12385 + void nf_log_l2packet(struct net *net, u_int8_t pf,
12386 + __be16 protocol,
12387 +diff --git a/net/netfilter/nft_fwd_netdev.c b/net/netfilter/nft_fwd_netdev.c
12388 +index 3087e23297dbf..b77985986b24e 100644
12389 +--- a/net/netfilter/nft_fwd_netdev.c
12390 ++++ b/net/netfilter/nft_fwd_netdev.c
12391 +@@ -138,6 +138,7 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr,
12392 + return;
12393 +
12394 + skb->dev = dev;
12395 ++ skb->tstamp = 0;
12396 + neigh_xmit(neigh_table, dev, addr, skb);
12397 + out:
12398 + regs->verdict.code = verdict;
12399 +diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
12400 +index 1b261375722e3..4170acc2dc282 100644
12401 +--- a/net/nfc/netlink.c
12402 ++++ b/net/nfc/netlink.c
12403 +@@ -1225,7 +1225,7 @@ static int nfc_genl_fw_download(struct sk_buff *skb, struct genl_info *info)
12404 + u32 idx;
12405 + char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
12406 +
12407 +- if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
12408 ++ if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || !info->attrs[NFC_ATTR_FIRMWARE_NAME])
12409 + return -EINVAL;
12410 +
12411 + idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
12412 +diff --git a/net/sched/act_api.c b/net/sched/act_api.c
12413 +index 4a5ef2adb2e57..1dc642b11443c 100644
12414 +--- a/net/sched/act_api.c
12415 ++++ b/net/sched/act_api.c
12416 +@@ -706,13 +706,6 @@ int tcf_action_destroy(struct tc_action *actions[], int bind)
12417 + return ret;
12418 + }
12419 +
12420 +-static int tcf_action_destroy_1(struct tc_action *a, int bind)
12421 +-{
12422 +- struct tc_action *actions[] = { a, NULL };
12423 +-
12424 +- return tcf_action_destroy(actions, bind);
12425 +-}
12426 +-
12427 + static int tcf_action_put(struct tc_action *p)
12428 + {
12429 + return __tcf_action_put(p, false);
12430 +@@ -932,13 +925,6 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
12431 + if (err < 0)
12432 + goto err_mod;
12433 +
12434 +- if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN) &&
12435 +- !rcu_access_pointer(a->goto_chain)) {
12436 +- tcf_action_destroy_1(a, bind);
12437 +- NL_SET_ERR_MSG(extack, "can't use goto chain with NULL chain");
12438 +- return ERR_PTR(-EINVAL);
12439 +- }
12440 +-
12441 + if (!name && tb[TCA_ACT_COOKIE])
12442 + tcf_set_action_cookie(&a->act_cookie, cookie);
12443 +
12444 +diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
12445 +index bdaa04a9a7fa4..a5a2bf01eb9bc 100644
12446 +--- a/net/sched/act_tunnel_key.c
12447 ++++ b/net/sched/act_tunnel_key.c
12448 +@@ -315,7 +315,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
12449 +
12450 + metadata = __ipv6_tun_set_dst(&saddr, &daddr, tos, ttl, dst_port,
12451 + 0, flags,
12452 +- key_id, 0);
12453 ++ key_id, opts_len);
12454 + } else {
12455 + NL_SET_ERR_MSG(extack, "Missing either ipv4 or ipv6 src and dst");
12456 + ret = -EINVAL;
12457 +diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
12458 +index 0c5fcb8ed404d..aeea67f908415 100644
12459 +--- a/net/smc/smc_core.c
12460 ++++ b/net/smc/smc_core.c
12461 +@@ -795,7 +795,7 @@ static struct smc_buf_desc *smcr_new_buf_create(struct smc_link_group *lgr,
12462 + return buf_desc;
12463 + }
12464 +
12465 +-#define SMCD_DMBE_SIZES 7 /* 0 -> 16KB, 1 -> 32KB, .. 6 -> 1MB */
12466 ++#define SMCD_DMBE_SIZES 6 /* 0 -> 16KB, 1 -> 32KB, .. 6 -> 1MB */
12467 +
12468 + static struct smc_buf_desc *smcd_new_buf_create(struct smc_link_group *lgr,
12469 + bool is_dmb, int bufsize)
12470 +diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
12471 +index 3645cd241d3ea..cf4d6d7e72822 100644
12472 +--- a/net/sunrpc/auth_gss/svcauth_gss.c
12473 ++++ b/net/sunrpc/auth_gss/svcauth_gss.c
12474 +@@ -1095,9 +1095,9 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
12475 + struct gssp_in_token *in_token)
12476 + {
12477 + struct kvec *argv = &rqstp->rq_arg.head[0];
12478 +- unsigned int page_base, length;
12479 +- int pages, i, res;
12480 +- size_t inlen;
12481 ++ unsigned int length, pgto_offs, pgfrom_offs;
12482 ++ int pages, i, res, pgto, pgfrom;
12483 ++ size_t inlen, to_offs, from_offs;
12484 +
12485 + res = gss_read_common_verf(gc, argv, authp, in_handle);
12486 + if (res)
12487 +@@ -1125,17 +1125,24 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
12488 + memcpy(page_address(in_token->pages[0]), argv->iov_base, length);
12489 + inlen -= length;
12490 +
12491 +- i = 1;
12492 +- page_base = rqstp->rq_arg.page_base;
12493 ++ to_offs = length;
12494 ++ from_offs = rqstp->rq_arg.page_base;
12495 + while (inlen) {
12496 +- length = min_t(unsigned int, inlen, PAGE_SIZE);
12497 +- memcpy(page_address(in_token->pages[i]),
12498 +- page_address(rqstp->rq_arg.pages[i]) + page_base,
12499 ++ pgto = to_offs >> PAGE_SHIFT;
12500 ++ pgfrom = from_offs >> PAGE_SHIFT;
12501 ++ pgto_offs = to_offs & ~PAGE_MASK;
12502 ++ pgfrom_offs = from_offs & ~PAGE_MASK;
12503 ++
12504 ++ length = min_t(unsigned int, inlen,
12505 ++ min_t(unsigned int, PAGE_SIZE - pgto_offs,
12506 ++ PAGE_SIZE - pgfrom_offs));
12507 ++ memcpy(page_address(in_token->pages[pgto]) + pgto_offs,
12508 ++ page_address(rqstp->rq_arg.pages[pgfrom]) + pgfrom_offs,
12509 + length);
12510 +
12511 ++ to_offs += length;
12512 ++ from_offs += length;
12513 + inlen -= length;
12514 +- page_base = 0;
12515 +- i++;
12516 + }
12517 + return 0;
12518 + }
12519 +diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
12520 +index 217106c66a13c..25e8922c10b28 100644
12521 +--- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
12522 ++++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
12523 +@@ -609,10 +609,11 @@ static int svc_rdma_pull_up_reply_msg(struct svcxprt_rdma *rdma,
12524 + while (remaining) {
12525 + len = min_t(u32, PAGE_SIZE - pageoff, remaining);
12526 +
12527 +- memcpy(dst, page_address(*ppages), len);
12528 ++ memcpy(dst, page_address(*ppages) + pageoff, len);
12529 + remaining -= len;
12530 + dst += len;
12531 + pageoff = 0;
12532 ++ ppages++;
12533 + }
12534 + }
12535 +
12536 +diff --git a/net/tipc/msg.c b/net/tipc/msg.c
12537 +index ee4b2261e7957..b0ed3c944b2d1 100644
12538 +--- a/net/tipc/msg.c
12539 ++++ b/net/tipc/msg.c
12540 +@@ -140,7 +140,8 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf)
12541 + if (fragid == FIRST_FRAGMENT) {
12542 + if (unlikely(head))
12543 + goto err;
12544 +- frag = skb_unshare(frag, GFP_ATOMIC);
12545 ++ if (skb_cloned(frag))
12546 ++ frag = skb_copy(frag, GFP_ATOMIC);
12547 + if (unlikely(!frag))
12548 + goto err;
12549 + head = *headbuf = frag;
12550 +diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
12551 +index 25fca390cdcf5..933a3187d3bf2 100644
12552 +--- a/net/tls/tls_device.c
12553 ++++ b/net/tls/tls_device.c
12554 +@@ -405,14 +405,14 @@ static int tls_push_data(struct sock *sk,
12555 + struct tls_context *tls_ctx = tls_get_ctx(sk);
12556 + struct tls_prot_info *prot = &tls_ctx->prot_info;
12557 + struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
12558 +- int more = flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE);
12559 + struct tls_record_info *record = ctx->open_record;
12560 + int tls_push_record_flags;
12561 + struct page_frag *pfrag;
12562 + size_t orig_size = size;
12563 + u32 max_open_record_len;
12564 +- int copy, rc = 0;
12565 ++ bool more = false;
12566 + bool done = false;
12567 ++ int copy, rc = 0;
12568 + long timeo;
12569 +
12570 + if (flags &
12571 +@@ -480,9 +480,8 @@ handle_error:
12572 + if (!size) {
12573 + last_record:
12574 + tls_push_record_flags = flags;
12575 +- if (more) {
12576 +- tls_ctx->pending_open_record_frags =
12577 +- !!record->num_frags;
12578 ++ if (flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE)) {
12579 ++ more = true;
12580 + break;
12581 + }
12582 +
12583 +@@ -514,6 +513,8 @@ last_record:
12584 + }
12585 + } while (!done);
12586 +
12587 ++ tls_ctx->pending_open_record_frags = more;
12588 ++
12589 + if (orig_size - size > 0)
12590 + rc = orig_size - size;
12591 +
12592 +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
12593 +index 7bc4f37655237..672b70730e898 100644
12594 +--- a/net/wireless/nl80211.c
12595 ++++ b/net/wireless/nl80211.c
12596 +@@ -2227,7 +2227,10 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
12597 + * case we'll continue with more data in the next round,
12598 + * but break unconditionally so unsplit data stops here.
12599 + */
12600 +- state->split_start++;
12601 ++ if (state->split)
12602 ++ state->split_start++;
12603 ++ else
12604 ++ state->split_start = 0;
12605 + break;
12606 + case 9:
12607 + if (rdev->wiphy.extended_capabilities &&
12608 +@@ -4496,16 +4499,14 @@ static int nl80211_parse_he_obss_pd(struct nlattr *attrs,
12609 + if (err)
12610 + return err;
12611 +
12612 +- if (!tb[NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET] ||
12613 +- !tb[NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET])
12614 +- return -EINVAL;
12615 +-
12616 +- he_obss_pd->min_offset =
12617 +- nla_get_u32(tb[NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET]);
12618 +- he_obss_pd->max_offset =
12619 +- nla_get_u32(tb[NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET]);
12620 ++ if (tb[NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET])
12621 ++ he_obss_pd->min_offset =
12622 ++ nla_get_u8(tb[NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET]);
12623 ++ if (tb[NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET])
12624 ++ he_obss_pd->max_offset =
12625 ++ nla_get_u8(tb[NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET]);
12626 +
12627 +- if (he_obss_pd->min_offset >= he_obss_pd->max_offset)
12628 ++ if (he_obss_pd->min_offset > he_obss_pd->max_offset)
12629 + return -EINVAL;
12630 +
12631 + he_obss_pd->enable = true;
12632 +diff --git a/samples/mic/mpssd/mpssd.c b/samples/mic/mpssd/mpssd.c
12633 +index a11bf6c5b53b4..cd3f16a6f5caf 100644
12634 +--- a/samples/mic/mpssd/mpssd.c
12635 ++++ b/samples/mic/mpssd/mpssd.c
12636 +@@ -403,9 +403,9 @@ mic_virtio_copy(struct mic_info *mic, int fd,
12637 +
12638 + static inline unsigned _vring_size(unsigned int num, unsigned long align)
12639 + {
12640 +- return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (3 + num)
12641 ++ return _ALIGN_UP(((sizeof(struct vring_desc) * num + sizeof(__u16) * (3 + num)
12642 + + align - 1) & ~(align - 1))
12643 +- + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num;
12644 ++ + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num, 4);
12645 + }
12646 +
12647 + /*
12648 +diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c
12649 +index d5ad7b2539c75..d86825261b515 100644
12650 +--- a/security/integrity/ima/ima_crypto.c
12651 ++++ b/security/integrity/ima/ima_crypto.c
12652 +@@ -688,6 +688,8 @@ static int ima_calc_boot_aggregate_tfm(char *digest, u16 alg_id,
12653 + /* now accumulate with current aggregate */
12654 + rc = crypto_shash_update(shash, d.digest,
12655 + crypto_shash_digestsize(tfm));
12656 ++ if (rc != 0)
12657 ++ return rc;
12658 + }
12659 + if (!rc)
12660 + crypto_shash_final(shash, digest);
12661 +diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
12662 +index c8b9c0b315d8f..250a92b187265 100644
12663 +--- a/sound/core/seq/oss/seq_oss.c
12664 ++++ b/sound/core/seq/oss/seq_oss.c
12665 +@@ -174,9 +174,12 @@ odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
12666 + if (snd_BUG_ON(!dp))
12667 + return -ENXIO;
12668 +
12669 +- mutex_lock(&register_mutex);
12670 ++ if (cmd != SNDCTL_SEQ_SYNC &&
12671 ++ mutex_lock_interruptible(&register_mutex))
12672 ++ return -ERESTARTSYS;
12673 + rc = snd_seq_oss_ioctl(dp, cmd, arg);
12674 +- mutex_unlock(&register_mutex);
12675 ++ if (cmd != SNDCTL_SEQ_SYNC)
12676 ++ mutex_unlock(&register_mutex);
12677 + return rc;
12678 + }
12679 +
12680 +diff --git a/sound/firewire/bebob/bebob_hwdep.c b/sound/firewire/bebob/bebob_hwdep.c
12681 +index 45b740f44c459..c362eb38ab906 100644
12682 +--- a/sound/firewire/bebob/bebob_hwdep.c
12683 ++++ b/sound/firewire/bebob/bebob_hwdep.c
12684 +@@ -36,12 +36,11 @@ hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count,
12685 + }
12686 +
12687 + memset(&event, 0, sizeof(event));
12688 ++ count = min_t(long, count, sizeof(event.lock_status));
12689 + if (bebob->dev_lock_changed) {
12690 + event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS;
12691 + event.lock_status.status = (bebob->dev_lock_count > 0);
12692 + bebob->dev_lock_changed = false;
12693 +-
12694 +- count = min_t(long, count, sizeof(event.lock_status));
12695 + }
12696 +
12697 + spin_unlock_irq(&bebob->lock);
12698 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
12699 +index 590ea262f2e20..9a1968932b783 100644
12700 +--- a/sound/pci/hda/hda_intel.c
12701 ++++ b/sound/pci/hda/hda_intel.c
12702 +@@ -1001,12 +1001,14 @@ static void __azx_runtime_resume(struct azx *chip, bool from_rt)
12703 + azx_init_pci(chip);
12704 + hda_intel_init_chip(chip, true);
12705 +
12706 +- if (status && from_rt) {
12707 +- list_for_each_codec(codec, &chip->bus)
12708 +- if (!codec->relaxed_resume &&
12709 +- (status & (1 << codec->addr)))
12710 +- schedule_delayed_work(&codec->jackpoll_work,
12711 +- codec->jackpoll_interval);
12712 ++ if (from_rt) {
12713 ++ list_for_each_codec(codec, &chip->bus) {
12714 ++ if (codec->relaxed_resume)
12715 ++ continue;
12716 ++
12717 ++ if (codec->forced_resume || (status & (1 << codec->addr)))
12718 ++ pm_request_resume(hda_codec_dev(codec));
12719 ++ }
12720 + }
12721 +
12722 + /* power down again for link-controlled chips */
12723 +diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
12724 +index 6aa39339db0ab..459aff6c10bc5 100644
12725 +--- a/sound/pci/hda/patch_ca0132.c
12726 ++++ b/sound/pci/hda/patch_ca0132.c
12727 +@@ -1065,6 +1065,7 @@ enum {
12728 + QUIRK_R3DI,
12729 + QUIRK_R3D,
12730 + QUIRK_AE5,
12731 ++ QUIRK_AE7,
12732 + };
12733 +
12734 + #ifdef CONFIG_PCI
12735 +@@ -1184,6 +1185,7 @@ static const struct snd_pci_quirk ca0132_quirks[] = {
12736 + SND_PCI_QUIRK(0x1102, 0x0013, "Recon3D", QUIRK_R3D),
12737 + SND_PCI_QUIRK(0x1102, 0x0018, "Recon3D", QUIRK_R3D),
12738 + SND_PCI_QUIRK(0x1102, 0x0051, "Sound Blaster AE-5", QUIRK_AE5),
12739 ++ SND_PCI_QUIRK(0x1102, 0x0081, "Sound Blaster AE-7", QUIRK_AE7),
12740 + {}
12741 + };
12742 +
12743 +@@ -4674,6 +4676,15 @@ static int ca0132_alt_select_in(struct hda_codec *codec)
12744 + ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00);
12745 + tmp = FLOAT_THREE;
12746 + break;
12747 ++ case QUIRK_AE7:
12748 ++ ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00);
12749 ++ tmp = FLOAT_THREE;
12750 ++ chipio_set_conn_rate(codec, MEM_CONNID_MICIN2,
12751 ++ SR_96_000);
12752 ++ chipio_set_conn_rate(codec, MEM_CONNID_MICOUT2,
12753 ++ SR_96_000);
12754 ++ dspio_set_uint_param(codec, 0x80, 0x01, FLOAT_ZERO);
12755 ++ break;
12756 + default:
12757 + tmp = FLOAT_ONE;
12758 + break;
12759 +@@ -4719,6 +4730,14 @@ static int ca0132_alt_select_in(struct hda_codec *codec)
12760 + case QUIRK_AE5:
12761 + ca0113_mmio_command_set(codec, 0x30, 0x28, 0x00);
12762 + break;
12763 ++ case QUIRK_AE7:
12764 ++ ca0113_mmio_command_set(codec, 0x30, 0x28, 0x3f);
12765 ++ chipio_set_conn_rate(codec, MEM_CONNID_MICIN2,
12766 ++ SR_96_000);
12767 ++ chipio_set_conn_rate(codec, MEM_CONNID_MICOUT2,
12768 ++ SR_96_000);
12769 ++ dspio_set_uint_param(codec, 0x80, 0x01, FLOAT_ZERO);
12770 ++ break;
12771 + default:
12772 + break;
12773 + }
12774 +@@ -4728,7 +4747,10 @@ static int ca0132_alt_select_in(struct hda_codec *codec)
12775 + if (ca0132_quirk(spec) == QUIRK_R3DI)
12776 + chipio_set_conn_rate(codec, 0x0F, SR_96_000);
12777 +
12778 +- tmp = FLOAT_ZERO;
12779 ++ if (ca0132_quirk(spec) == QUIRK_AE7)
12780 ++ tmp = FLOAT_THREE;
12781 ++ else
12782 ++ tmp = FLOAT_ZERO;
12783 + dspio_set_uint_param(codec, 0x80, 0x00, tmp);
12784 +
12785 + switch (ca0132_quirk(spec)) {
12786 +diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
12787 +index 51798632d334c..df4771b9eff24 100644
12788 +--- a/sound/pci/hda/patch_hdmi.c
12789 ++++ b/sound/pci/hda/patch_hdmi.c
12790 +@@ -2001,22 +2001,25 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
12791 + int pinctl;
12792 + int err = 0;
12793 +
12794 ++ mutex_lock(&spec->pcm_lock);
12795 + if (hinfo->nid) {
12796 + pcm_idx = hinfo_to_pcm_index(codec, hinfo);
12797 +- if (snd_BUG_ON(pcm_idx < 0))
12798 +- return -EINVAL;
12799 ++ if (snd_BUG_ON(pcm_idx < 0)) {
12800 ++ err = -EINVAL;
12801 ++ goto unlock;
12802 ++ }
12803 + cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid);
12804 +- if (snd_BUG_ON(cvt_idx < 0))
12805 +- return -EINVAL;
12806 ++ if (snd_BUG_ON(cvt_idx < 0)) {
12807 ++ err = -EINVAL;
12808 ++ goto unlock;
12809 ++ }
12810 + per_cvt = get_cvt(spec, cvt_idx);
12811 +-
12812 + snd_BUG_ON(!per_cvt->assigned);
12813 + per_cvt->assigned = 0;
12814 + hinfo->nid = 0;
12815 +
12816 + azx_stream(get_azx_dev(substream))->stripe = 0;
12817 +
12818 +- mutex_lock(&spec->pcm_lock);
12819 + snd_hda_spdif_ctls_unassign(codec, pcm_idx);
12820 + clear_bit(pcm_idx, &spec->pcm_in_use);
12821 + pin_idx = hinfo_to_pin_index(codec, hinfo);
12822 +@@ -2044,10 +2047,11 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
12823 + per_pin->setup = false;
12824 + per_pin->channels = 0;
12825 + mutex_unlock(&per_pin->lock);
12826 +- unlock:
12827 +- mutex_unlock(&spec->pcm_lock);
12828 + }
12829 +
12830 ++unlock:
12831 ++ mutex_unlock(&spec->pcm_lock);
12832 ++
12833 + return err;
12834 + }
12835 +
12836 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
12837 +index 4dfd714f718b8..7a24e9f0d2fe7 100644
12838 +--- a/sound/pci/hda/patch_realtek.c
12839 ++++ b/sound/pci/hda/patch_realtek.c
12840 +@@ -1141,6 +1141,7 @@ static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
12841 + codec->single_adc_amp = 1;
12842 + /* FIXME: do we need this for all Realtek codec models? */
12843 + codec->spdif_status_reset = 1;
12844 ++ codec->forced_resume = 1;
12845 + codec->patch_ops = alc_patch_ops;
12846 +
12847 + err = alc_codec_rename_from_preset(codec);
12848 +@@ -1920,6 +1921,8 @@ enum {
12849 + ALC1220_FIXUP_CLEVO_P950,
12850 + ALC1220_FIXUP_CLEVO_PB51ED,
12851 + ALC1220_FIXUP_CLEVO_PB51ED_PINS,
12852 ++ ALC887_FIXUP_ASUS_AUDIO,
12853 ++ ALC887_FIXUP_ASUS_HMIC,
12854 + };
12855 +
12856 + static void alc889_fixup_coef(struct hda_codec *codec,
12857 +@@ -2132,6 +2135,31 @@ static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
12858 + alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
12859 + }
12860 +
12861 ++static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
12862 ++ struct hda_jack_callback *jack)
12863 ++{
12864 ++ struct alc_spec *spec = codec->spec;
12865 ++ unsigned int vref;
12866 ++
12867 ++ snd_hda_gen_hp_automute(codec, jack);
12868 ++
12869 ++ if (spec->gen.hp_jack_present)
12870 ++ vref = AC_PINCTL_VREF_80;
12871 ++ else
12872 ++ vref = AC_PINCTL_VREF_HIZ;
12873 ++ snd_hda_set_pin_ctl(codec, 0x19, PIN_HP | vref);
12874 ++}
12875 ++
12876 ++static void alc887_fixup_asus_jack(struct hda_codec *codec,
12877 ++ const struct hda_fixup *fix, int action)
12878 ++{
12879 ++ struct alc_spec *spec = codec->spec;
12880 ++ if (action != HDA_FIXUP_ACT_PROBE)
12881 ++ return;
12882 ++ snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_HP);
12883 ++ spec->gen.hp_automute_hook = alc887_asus_hp_automute_hook;
12884 ++}
12885 ++
12886 + static const struct hda_fixup alc882_fixups[] = {
12887 + [ALC882_FIXUP_ABIT_AW9D_MAX] = {
12888 + .type = HDA_FIXUP_PINS,
12889 +@@ -2389,6 +2417,20 @@ static const struct hda_fixup alc882_fixups[] = {
12890 + .chained = true,
12891 + .chain_id = ALC1220_FIXUP_CLEVO_PB51ED,
12892 + },
12893 ++ [ALC887_FIXUP_ASUS_AUDIO] = {
12894 ++ .type = HDA_FIXUP_PINS,
12895 ++ .v.pins = (const struct hda_pintbl[]) {
12896 ++ { 0x15, 0x02a14150 }, /* use as headset mic, without its own jack detect */
12897 ++ { 0x19, 0x22219420 },
12898 ++ {}
12899 ++ },
12900 ++ },
12901 ++ [ALC887_FIXUP_ASUS_HMIC] = {
12902 ++ .type = HDA_FIXUP_FUNC,
12903 ++ .v.func = alc887_fixup_asus_jack,
12904 ++ .chained = true,
12905 ++ .chain_id = ALC887_FIXUP_ASUS_AUDIO,
12906 ++ },
12907 + };
12908 +
12909 + static const struct snd_pci_quirk alc882_fixup_tbl[] = {
12910 +@@ -2422,6 +2464,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
12911 + SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
12912 + SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
12913 + SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
12914 ++ SND_PCI_QUIRK(0x1043, 0x2390, "Asus D700SA", ALC887_FIXUP_ASUS_HMIC),
12915 + SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
12916 + SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
12917 + SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
12918 +@@ -6215,6 +6258,7 @@ enum {
12919 + ALC269_FIXUP_LEMOTE_A190X,
12920 + ALC256_FIXUP_INTEL_NUC8_RUGGED,
12921 + ALC255_FIXUP_XIAOMI_HEADSET_MIC,
12922 ++ ALC274_FIXUP_HP_MIC,
12923 + };
12924 +
12925 + static const struct hda_fixup alc269_fixups[] = {
12926 +@@ -7594,6 +7638,14 @@ static const struct hda_fixup alc269_fixups[] = {
12927 + .chained = true,
12928 + .chain_id = ALC289_FIXUP_ASUS_GA401
12929 + },
12930 ++ [ALC274_FIXUP_HP_MIC] = {
12931 ++ .type = HDA_FIXUP_VERBS,
12932 ++ .v.verbs = (const struct hda_verb[]) {
12933 ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
12934 ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
12935 ++ { }
12936 ++ },
12937 ++ },
12938 + };
12939 +
12940 + static const struct snd_pci_quirk alc269_fixup_tbl[] = {
12941 +@@ -7745,6 +7797,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
12942 + SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
12943 + SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED),
12944 + SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_AMP_INIT),
12945 ++ SND_PCI_QUIRK(0x103c, 0x874e, "HP", ALC274_FIXUP_HP_MIC),
12946 ++ SND_PCI_QUIRK(0x103c, 0x8760, "HP", ALC285_FIXUP_HP_MUTE_LED),
12947 + SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED),
12948 + SND_PCI_QUIRK(0x103c, 0x877d, "HP", ALC236_FIXUP_HP_MUTE_LED),
12949 + SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
12950 +@@ -8070,6 +8124,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
12951 + {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
12952 + {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"},
12953 + {.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"},
12954 ++ {.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"},
12955 + {}
12956 + };
12957 + #define ALC225_STANDARD_PINS \
12958 +@@ -9633,6 +9688,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
12959 + SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
12960 + SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
12961 + SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
12962 ++ SND_PCI_QUIRK(0x103c, 0x873e, "HP", ALC671_FIXUP_HP_HEADSET_MIC2),
12963 + SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
12964 + SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
12965 + SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
12966 +diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
12967 +index 68165de1c8dea..7a1ffbaf48be5 100644
12968 +--- a/sound/soc/codecs/tlv320aic32x4.c
12969 ++++ b/sound/soc/codecs/tlv320aic32x4.c
12970 +@@ -662,7 +662,7 @@ static int aic32x4_set_processing_blocks(struct snd_soc_component *component,
12971 + }
12972 +
12973 + static int aic32x4_setup_clocks(struct snd_soc_component *component,
12974 +- unsigned int sample_rate)
12975 ++ unsigned int sample_rate, unsigned int channels)
12976 + {
12977 + u8 aosr;
12978 + u16 dosr;
12979 +@@ -750,7 +750,9 @@ static int aic32x4_setup_clocks(struct snd_soc_component *component,
12980 + dosr);
12981 +
12982 + clk_set_rate(clocks[5].clk,
12983 +- sample_rate * 32);
12984 ++ sample_rate * 32 *
12985 ++ channels);
12986 ++
12987 + return 0;
12988 + }
12989 + }
12990 +@@ -772,7 +774,8 @@ static int aic32x4_hw_params(struct snd_pcm_substream *substream,
12991 + u8 iface1_reg = 0;
12992 + u8 dacsetup_reg = 0;
12993 +
12994 +- aic32x4_setup_clocks(component, params_rate(params));
12995 ++ aic32x4_setup_clocks(component, params_rate(params),
12996 ++ params_channels(params));
12997 +
12998 + switch (params_width(params)) {
12999 + case 16:
13000 +diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
13001 +index 914b75c23d1bf..027259695551c 100644
13002 +--- a/sound/soc/fsl/fsl_sai.c
13003 ++++ b/sound/soc/fsl/fsl_sai.c
13004 +@@ -694,7 +694,7 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai)
13005 + return 0;
13006 + }
13007 +
13008 +-static struct snd_soc_dai_driver fsl_sai_dai = {
13009 ++static struct snd_soc_dai_driver fsl_sai_dai_template = {
13010 + .probe = fsl_sai_dai_probe,
13011 + .playback = {
13012 + .stream_name = "CPU-Playback",
13013 +@@ -965,12 +965,15 @@ static int fsl_sai_probe(struct platform_device *pdev)
13014 + return ret;
13015 + }
13016 +
13017 ++ memcpy(&sai->cpu_dai_drv, &fsl_sai_dai_template,
13018 ++ sizeof(fsl_sai_dai_template));
13019 ++
13020 + /* Sync Tx with Rx as default by following old DT binding */
13021 + sai->synchronous[RX] = true;
13022 + sai->synchronous[TX] = false;
13023 +- fsl_sai_dai.symmetric_rates = 1;
13024 +- fsl_sai_dai.symmetric_channels = 1;
13025 +- fsl_sai_dai.symmetric_samplebits = 1;
13026 ++ sai->cpu_dai_drv.symmetric_rates = 1;
13027 ++ sai->cpu_dai_drv.symmetric_channels = 1;
13028 ++ sai->cpu_dai_drv.symmetric_samplebits = 1;
13029 +
13030 + if (of_find_property(np, "fsl,sai-synchronous-rx", NULL) &&
13031 + of_find_property(np, "fsl,sai-asynchronous", NULL)) {
13032 +@@ -987,9 +990,9 @@ static int fsl_sai_probe(struct platform_device *pdev)
13033 + /* Discard all settings for asynchronous mode */
13034 + sai->synchronous[RX] = false;
13035 + sai->synchronous[TX] = false;
13036 +- fsl_sai_dai.symmetric_rates = 0;
13037 +- fsl_sai_dai.symmetric_channels = 0;
13038 +- fsl_sai_dai.symmetric_samplebits = 0;
13039 ++ sai->cpu_dai_drv.symmetric_rates = 0;
13040 ++ sai->cpu_dai_drv.symmetric_channels = 0;
13041 ++ sai->cpu_dai_drv.symmetric_samplebits = 0;
13042 + }
13043 +
13044 + if (of_find_property(np, "fsl,sai-mclk-direction-output", NULL) &&
13045 +@@ -1018,7 +1021,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
13046 + pm_runtime_enable(&pdev->dev);
13047 +
13048 + ret = devm_snd_soc_register_component(&pdev->dev, &fsl_component,
13049 +- &fsl_sai_dai, 1);
13050 ++ &sai->cpu_dai_drv, 1);
13051 + if (ret)
13052 + goto err_pm_disable;
13053 +
13054 +diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
13055 +index 6aba7d28f5f34..677ecfc1ec68f 100644
13056 +--- a/sound/soc/fsl/fsl_sai.h
13057 ++++ b/sound/soc/fsl/fsl_sai.h
13058 +@@ -180,6 +180,7 @@ struct fsl_sai {
13059 + unsigned int bclk_ratio;
13060 +
13061 + const struct fsl_sai_soc_data *soc_data;
13062 ++ struct snd_soc_dai_driver cpu_dai_drv;
13063 + struct snd_dmaengine_dai_dma_data dma_params_rx;
13064 + struct snd_dmaengine_dai_dma_data dma_params_tx;
13065 + };
13066 +diff --git a/sound/soc/fsl/imx-es8328.c b/sound/soc/fsl/imx-es8328.c
13067 +index 15a27a2cd0cae..fad1eb6253d53 100644
13068 +--- a/sound/soc/fsl/imx-es8328.c
13069 ++++ b/sound/soc/fsl/imx-es8328.c
13070 +@@ -145,13 +145,13 @@ static int imx_es8328_probe(struct platform_device *pdev)
13071 + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
13072 + if (!data) {
13073 + ret = -ENOMEM;
13074 +- goto fail;
13075 ++ goto put_device;
13076 + }
13077 +
13078 + comp = devm_kzalloc(dev, 3 * sizeof(*comp), GFP_KERNEL);
13079 + if (!comp) {
13080 + ret = -ENOMEM;
13081 +- goto fail;
13082 ++ goto put_device;
13083 + }
13084 +
13085 + data->dev = dev;
13086 +@@ -182,12 +182,12 @@ static int imx_es8328_probe(struct platform_device *pdev)
13087 + ret = snd_soc_of_parse_card_name(&data->card, "model");
13088 + if (ret) {
13089 + dev_err(dev, "Unable to parse card name\n");
13090 +- goto fail;
13091 ++ goto put_device;
13092 + }
13093 + ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing");
13094 + if (ret) {
13095 + dev_err(dev, "Unable to parse routing: %d\n", ret);
13096 +- goto fail;
13097 ++ goto put_device;
13098 + }
13099 + data->card.num_links = 1;
13100 + data->card.owner = THIS_MODULE;
13101 +@@ -196,10 +196,12 @@ static int imx_es8328_probe(struct platform_device *pdev)
13102 + ret = snd_soc_register_card(&data->card);
13103 + if (ret) {
13104 + dev_err(dev, "Unable to register: %d\n", ret);
13105 +- goto fail;
13106 ++ goto put_device;
13107 + }
13108 +
13109 + platform_set_drvdata(pdev, data);
13110 ++put_device:
13111 ++ put_device(&ssi_pdev->dev);
13112 + fail:
13113 + of_node_put(ssi_np);
13114 + of_node_put(codec_np);
13115 +diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c
13116 +index dbce7e92baf3c..c5d6952a4a33f 100644
13117 +--- a/sound/soc/qcom/lpass-cpu.c
13118 ++++ b/sound/soc/qcom/lpass-cpu.c
13119 +@@ -174,21 +174,6 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
13120 + return 0;
13121 + }
13122 +
13123 +-static int lpass_cpu_daiops_hw_free(struct snd_pcm_substream *substream,
13124 +- struct snd_soc_dai *dai)
13125 +-{
13126 +- struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
13127 +- int ret;
13128 +-
13129 +- ret = regmap_write(drvdata->lpaif_map,
13130 +- LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
13131 +- 0);
13132 +- if (ret)
13133 +- dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);
13134 +-
13135 +- return ret;
13136 +-}
13137 +-
13138 + static int lpass_cpu_daiops_prepare(struct snd_pcm_substream *substream,
13139 + struct snd_soc_dai *dai)
13140 + {
13141 +@@ -269,7 +254,6 @@ const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops = {
13142 + .startup = lpass_cpu_daiops_startup,
13143 + .shutdown = lpass_cpu_daiops_shutdown,
13144 + .hw_params = lpass_cpu_daiops_hw_params,
13145 +- .hw_free = lpass_cpu_daiops_hw_free,
13146 + .prepare = lpass_cpu_daiops_prepare,
13147 + .trigger = lpass_cpu_daiops_trigger,
13148 + };
13149 +diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c
13150 +index 4c745baa39f73..9acaef81dd74c 100644
13151 +--- a/sound/soc/qcom/lpass-platform.c
13152 ++++ b/sound/soc/qcom/lpass-platform.c
13153 +@@ -61,7 +61,7 @@ static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream)
13154 + int ret, dma_ch, dir = substream->stream;
13155 + struct lpass_pcm_data *data;
13156 +
13157 +- data = devm_kzalloc(soc_runtime->dev, sizeof(*data), GFP_KERNEL);
13158 ++ data = kzalloc(sizeof(*data), GFP_KERNEL);
13159 + if (!data)
13160 + return -ENOMEM;
13161 +
13162 +@@ -119,6 +119,7 @@ static int lpass_platform_pcmops_close(struct snd_pcm_substream *substream)
13163 + if (v->free_dma_channel)
13164 + v->free_dma_channel(drvdata, data->dma_ch);
13165 +
13166 ++ kfree(data);
13167 + return 0;
13168 + }
13169 +
13170 +diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
13171 +index ac2feddc75fdd..ea183922c4ef1 100644
13172 +--- a/tools/perf/builtin-stat.c
13173 ++++ b/tools/perf/builtin-stat.c
13174 +@@ -1671,8 +1671,10 @@ static void setup_system_wide(int forks)
13175 + struct evsel *counter;
13176 +
13177 + evlist__for_each_entry(evsel_list, counter) {
13178 +- if (!counter->core.system_wide)
13179 ++ if (!counter->core.system_wide &&
13180 ++ strcmp(counter->name, "duration_time")) {
13181 + return;
13182 ++ }
13183 + }
13184 +
13185 + if (evsel_list->core.nr_entries)
13186 +diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
13187 +index c5cce3a60476b..8aeaeba48a41f 100644
13188 +--- a/tools/perf/util/intel-pt.c
13189 ++++ b/tools/perf/util/intel-pt.c
13190 +@@ -974,6 +974,8 @@ static void intel_pt_set_pid_tid_cpu(struct intel_pt *pt,
13191 +
13192 + if (queue->tid == -1 || pt->have_sched_switch) {
13193 + ptq->tid = machine__get_current_tid(pt->machine, ptq->cpu);
13194 ++ if (ptq->tid == -1)
13195 ++ ptq->pid = -1;
13196 + thread__zput(ptq->thread);
13197 + }
13198 +
13199 +@@ -2488,10 +2490,8 @@ static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event,
13200 + tid = sample->tid;
13201 + }
13202 +
13203 +- if (tid == -1) {
13204 +- pr_err("context_switch event has no tid\n");
13205 +- return -EINVAL;
13206 +- }
13207 ++ if (tid == -1)
13208 ++ intel_pt_log("context_switch event has no tid\n");
13209 +
13210 + intel_pt_log("context_switch: cpu %d pid %d tid %d time %"PRIu64" tsc %#"PRIx64"\n",
13211 + cpu, pid, tid, sample->time, perf_time_to_tsc(sample->time,
13212 +diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c
13213 +index 8995092d541ec..3b796dd5e5772 100644
13214 +--- a/tools/testing/radix-tree/idr-test.c
13215 ++++ b/tools/testing/radix-tree/idr-test.c
13216 +@@ -523,8 +523,27 @@ static void *ida_random_fn(void *arg)
13217 + return NULL;
13218 + }
13219 +
13220 ++static void *ida_leak_fn(void *arg)
13221 ++{
13222 ++ struct ida *ida = arg;
13223 ++ time_t s = time(NULL);
13224 ++ int i, ret;
13225 ++
13226 ++ rcu_register_thread();
13227 ++
13228 ++ do for (i = 0; i < 1000; i++) {
13229 ++ ret = ida_alloc_range(ida, 128, 128, GFP_KERNEL);
13230 ++ if (ret >= 0)
13231 ++ ida_free(ida, 128);
13232 ++ } while (time(NULL) < s + 2);
13233 ++
13234 ++ rcu_unregister_thread();
13235 ++ return NULL;
13236 ++}
13237 ++
13238 + void ida_thread_tests(void)
13239 + {
13240 ++ DEFINE_IDA(ida);
13241 + pthread_t threads[20];
13242 + int i;
13243 +
13244 +@@ -536,6 +555,16 @@ void ida_thread_tests(void)
13245 +
13246 + while (i--)
13247 + pthread_join(threads[i], NULL);
13248 ++
13249 ++ for (i = 0; i < ARRAY_SIZE(threads); i++)
13250 ++ if (pthread_create(&threads[i], NULL, ida_leak_fn, &ida)) {
13251 ++ perror("creating ida thread");
13252 ++ exit(1);
13253 ++ }
13254 ++
13255 ++ while (i--)
13256 ++ pthread_join(threads[i], NULL);
13257 ++ assert(ida_is_empty(&ida));
13258 + }
13259 +
13260 + void ida_tests(void)
13261 +diff --git a/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c b/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
13262 +index d22e438198cf7..9af8822ece477 100644
13263 +--- a/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
13264 ++++ b/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
13265 +@@ -18,11 +18,11 @@
13266 + #define MAX_ULONG_STR_LEN 7
13267 + #define MAX_VALUE_STR_LEN (TCP_MEM_LOOPS * MAX_ULONG_STR_LEN)
13268 +
13269 ++const char tcp_mem_name[] = "net/ipv4/tcp_mem/very_very_very_very_long_pointless_string";
13270 + static __always_inline int is_tcp_mem(struct bpf_sysctl *ctx)
13271 + {
13272 +- volatile char tcp_mem_name[] = "net/ipv4/tcp_mem/very_very_very_very_long_pointless_string";
13273 + unsigned char i;
13274 +- char name[64];
13275 ++ char name[sizeof(tcp_mem_name)];
13276 + int ret;
13277 +
13278 + memset(name, 0, sizeof(name));
13279 +diff --git a/tools/testing/selftests/bpf/progs/test_sysctl_loop2.c b/tools/testing/selftests/bpf/progs/test_sysctl_loop2.c
13280 +index cb201cbe11e77..55251046c9b73 100644
13281 +--- a/tools/testing/selftests/bpf/progs/test_sysctl_loop2.c
13282 ++++ b/tools/testing/selftests/bpf/progs/test_sysctl_loop2.c
13283 +@@ -18,11 +18,11 @@
13284 + #define MAX_ULONG_STR_LEN 7
13285 + #define MAX_VALUE_STR_LEN (TCP_MEM_LOOPS * MAX_ULONG_STR_LEN)
13286 +
13287 ++const char tcp_mem_name[] = "net/ipv4/tcp_mem/very_very_very_very_long_pointless_string_to_stress_byte_loop";
13288 + static __attribute__((noinline)) int is_tcp_mem(struct bpf_sysctl *ctx)
13289 + {
13290 +- volatile char tcp_mem_name[] = "net/ipv4/tcp_mem/very_very_very_very_long_pointless_string_to_stress_byte_loop";
13291 + unsigned char i;
13292 +- char name[64];
13293 ++ char name[sizeof(tcp_mem_name)];
13294 + int ret;
13295 +
13296 + memset(name, 0, sizeof(name));
13297 +diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc
13298 +index f3eb8aacec0e7..a2b0e4eb1fe4c 100644
13299 +--- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc
13300 ++++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc
13301 +@@ -34,12 +34,12 @@ echo 'wakeup_latency u64 lat pid_t pid' >> synthetic_events
13302 + echo 'hist:keys=pid:ts1=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_wakeup/trigger
13303 + echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts1:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid) if next_comm=="ping"' > events/sched/sched_switch/trigger
13304 +
13305 +-echo 'waking+wakeup_latency u64 lat; pid_t pid' >> synthetic_events
13306 +-echo 'hist:keys=pid,lat:sort=pid,lat:ww_lat=$waking_lat+$wakeup_lat:onmatch(synthetic.wakeup_latency).waking+wakeup_latency($ww_lat,pid)' >> events/synthetic/wakeup_latency/trigger
13307 +-echo 'hist:keys=pid,lat:sort=pid,lat' >> events/synthetic/waking+wakeup_latency/trigger
13308 ++echo 'waking_plus_wakeup_latency u64 lat; pid_t pid' >> synthetic_events
13309 ++echo 'hist:keys=pid,lat:sort=pid,lat:ww_lat=$waking_lat+$wakeup_lat:onmatch(synthetic.wakeup_latency).waking_plus_wakeup_latency($ww_lat,pid)' >> events/synthetic/wakeup_latency/trigger
13310 ++echo 'hist:keys=pid,lat:sort=pid,lat' >> events/synthetic/waking_plus_wakeup_latency/trigger
13311 +
13312 + ping $LOCALHOST -c 3
13313 +-if ! grep -q "pid:" events/synthetic/waking+wakeup_latency/hist; then
13314 ++if ! grep -q "pid:" events/synthetic/waking_plus_wakeup_latency/hist; then
13315 + fail "Failed to create combined histogram"
13316 + fi
13317 +
13318 +diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config
13319 +index b8503a8119b07..81fcc25a54db6 100644
13320 +--- a/tools/testing/selftests/net/config
13321 ++++ b/tools/testing/selftests/net/config
13322 +@@ -29,3 +29,4 @@ CONFIG_NET_SCH_FQ=m
13323 + CONFIG_NET_SCH_ETF=m
13324 + CONFIG_TEST_BLACKHOLE_DEV=m
13325 + CONFIG_KALLSYMS=y
13326 ++CONFIG_NET_FOU=m
13327 +diff --git a/tools/testing/selftests/net/forwarding/vxlan_asymmetric.sh b/tools/testing/selftests/net/forwarding/vxlan_asymmetric.sh
13328 +index a0b5f57d6bd31..0727e2012b685 100755
13329 +--- a/tools/testing/selftests/net/forwarding/vxlan_asymmetric.sh
13330 ++++ b/tools/testing/selftests/net/forwarding/vxlan_asymmetric.sh
13331 +@@ -215,10 +215,16 @@ switch_create()
13332 +
13333 + bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
13334 + bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20
13335 ++
13336 ++ sysctl_set net.ipv4.conf.all.rp_filter 0
13337 ++ sysctl_set net.ipv4.conf.vlan10-v.rp_filter 0
13338 ++ sysctl_set net.ipv4.conf.vlan20-v.rp_filter 0
13339 + }
13340 +
13341 + switch_destroy()
13342 + {
13343 ++ sysctl_restore net.ipv4.conf.all.rp_filter
13344 ++
13345 + bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 20
13346 + bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 10
13347 +
13348 +@@ -359,6 +365,10 @@ ns_switch_create()
13349 +
13350 + bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
13351 + bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20
13352 ++
13353 ++ sysctl_set net.ipv4.conf.all.rp_filter 0
13354 ++ sysctl_set net.ipv4.conf.vlan10-v.rp_filter 0
13355 ++ sysctl_set net.ipv4.conf.vlan20-v.rp_filter 0
13356 + }
13357 + export -f ns_switch_create
13358 +
13359 +diff --git a/tools/testing/selftests/net/forwarding/vxlan_symmetric.sh b/tools/testing/selftests/net/forwarding/vxlan_symmetric.sh
13360 +index 1209031bc794d..5d97fa347d75a 100755
13361 +--- a/tools/testing/selftests/net/forwarding/vxlan_symmetric.sh
13362 ++++ b/tools/testing/selftests/net/forwarding/vxlan_symmetric.sh
13363 +@@ -237,10 +237,16 @@ switch_create()
13364 +
13365 + bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
13366 + bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20
13367 ++
13368 ++ sysctl_set net.ipv4.conf.all.rp_filter 0
13369 ++ sysctl_set net.ipv4.conf.vlan10-v.rp_filter 0
13370 ++ sysctl_set net.ipv4.conf.vlan20-v.rp_filter 0
13371 + }
13372 +
13373 + switch_destroy()
13374 + {
13375 ++ sysctl_restore net.ipv4.conf.all.rp_filter
13376 ++
13377 + bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 20
13378 + bridge fdb del 00:00:5e:00:01:01 dev br1 self local vlan 10
13379 +
13380 +@@ -402,6 +408,10 @@ ns_switch_create()
13381 +
13382 + bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 10
13383 + bridge fdb add 00:00:5e:00:01:01 dev br1 self local vlan 20
13384 ++
13385 ++ sysctl_set net.ipv4.conf.all.rp_filter 0
13386 ++ sysctl_set net.ipv4.conf.vlan10-v.rp_filter 0
13387 ++ sysctl_set net.ipv4.conf.vlan20-v.rp_filter 0
13388 + }
13389 + export -f ns_switch_create
13390 +
13391 +diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
13392 +index bdbf4b3125b6a..28ea3753da207 100755
13393 +--- a/tools/testing/selftests/net/rtnetlink.sh
13394 ++++ b/tools/testing/selftests/net/rtnetlink.sh
13395 +@@ -521,6 +521,11 @@ kci_test_encap_fou()
13396 + return $ksft_skip
13397 + fi
13398 +
13399 ++ if ! /sbin/modprobe -q -n fou; then
13400 ++ echo "SKIP: module fou is not found"
13401 ++ return $ksft_skip
13402 ++ fi
13403 ++ /sbin/modprobe -q fou
13404 + ip -netns "$testns" fou add port 7777 ipproto 47 2>/dev/null
13405 + if [ $? -ne 0 ];then
13406 + echo "FAIL: can't add fou port 7777, skipping test"
13407 +diff --git a/tools/testing/selftests/powerpc/eeh/eeh-basic.sh b/tools/testing/selftests/powerpc/eeh/eeh-basic.sh
13408 +index f988d2f42e8f2..cf001a2c69420 100755
13409 +--- a/tools/testing/selftests/powerpc/eeh/eeh-basic.sh
13410 ++++ b/tools/testing/selftests/powerpc/eeh/eeh-basic.sh
13411 +@@ -1,17 +1,19 @@
13412 + #!/bin/sh
13413 + # SPDX-License-Identifier: GPL-2.0-only
13414 +
13415 ++KSELFTESTS_SKIP=4
13416 ++
13417 + . ./eeh-functions.sh
13418 +
13419 + if ! eeh_supported ; then
13420 + echo "EEH not supported on this system, skipping"
13421 +- exit 0;
13422 ++ exit $KSELFTESTS_SKIP;
13423 + fi
13424 +
13425 + if [ ! -e "/sys/kernel/debug/powerpc/eeh_dev_check" ] && \
13426 + [ ! -e "/sys/kernel/debug/powerpc/eeh_dev_break" ] ; then
13427 + echo "debugfs EEH testing files are missing. Is debugfs mounted?"
13428 +- exit 1;
13429 ++ exit $KSELFTESTS_SKIP;
13430 + fi
13431 +
13432 + pre_lspci=`mktemp`
13433 +@@ -79,4 +81,5 @@ echo "$failed devices failed to recover ($dev_count tested)"
13434 + lspci | diff -u $pre_lspci -
13435 + rm -f $pre_lspci
13436 +
13437 +-exit $failed
13438 ++test "$failed" == 0
13439 ++exit $?