Gentoo Archives: gentoo-commits

From: Alice Ferrazzi <alicef@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.19 commit in: /
Date: Wed, 19 Aug 2020 09:37:03
Message-Id: 1597829789.6d1a8845fcc13034b366f55c1caf5dff4fc57a9e.alicef@gentoo
1 commit: 6d1a8845fcc13034b366f55c1caf5dff4fc57a9e
2 Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
3 AuthorDate: Wed Aug 19 09:35:17 2020 +0000
4 Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
5 CommitDate: Wed Aug 19 09:36:29 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=6d1a8845
7
8 Linux patch 4.19.140
9
10 Signed-off-by: Alice Ferrazzi <alicef <AT> gentoo.org>
11
12 0000_README | 4 +
13 1139_linux-4.19.140.patch | 4937 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 4941 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index b90eb63..1b514b0 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -595,6 +595,10 @@ Patch: 1138_linux-4.19.139.patch
21 From: https://www.kernel.org
22 Desc: Linux 4.19.139
23
24 +Patch: 1139_linux-4.19.140.patch
25 +From: https://www.kernel.org
26 +Desc: Linux 4.19.140
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/1139_linux-4.19.140.patch b/1139_linux-4.19.140.patch
33 new file mode 100644
34 index 0000000..7af331f
35 --- /dev/null
36 +++ b/1139_linux-4.19.140.patch
37 @@ -0,0 +1,4937 @@
38 +diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
39 +index 8127a08e366d..d10bcca6c3fb 100644
40 +--- a/Documentation/ABI/testing/sysfs-bus-iio
41 ++++ b/Documentation/ABI/testing/sysfs-bus-iio
42 +@@ -1559,7 +1559,8 @@ What: /sys/bus/iio/devices/iio:deviceX/in_concentrationX_voc_raw
43 + KernelVersion: 4.3
44 + Contact: linux-iio@×××××××××××.org
45 + Description:
46 +- Raw (unscaled no offset etc.) percentage reading of a substance.
47 ++ Raw (unscaled no offset etc.) reading of a substance. Units
48 ++ after application of scale and offset are percents.
49 +
50 + What: /sys/bus/iio/devices/iio:deviceX/in_resistance_raw
51 + What: /sys/bus/iio/devices/iio:deviceX/in_resistanceX_raw
52 +diff --git a/Makefile b/Makefile
53 +index f6012170995e..c5ee1c10a39c 100644
54 +--- a/Makefile
55 ++++ b/Makefile
56 +@@ -1,7 +1,7 @@
57 + # SPDX-License-Identifier: GPL-2.0
58 + VERSION = 4
59 + PATCHLEVEL = 19
60 +-SUBLEVEL = 139
61 ++SUBLEVEL = 140
62 + EXTRAVERSION =
63 + NAME = "People's Front"
64 +
65 +diff --git a/arch/arm/boot/dts/r8a7793-gose.dts b/arch/arm/boot/dts/r8a7793-gose.dts
66 +index 6b2f3a4fd13d..7802ce842a73 100644
67 +--- a/arch/arm/boot/dts/r8a7793-gose.dts
68 ++++ b/arch/arm/boot/dts/r8a7793-gose.dts
69 +@@ -339,7 +339,7 @@
70 + reg = <0x20>;
71 + remote = <&vin1>;
72 +
73 +- port {
74 ++ ports {
75 + #address-cells = <1>;
76 + #size-cells = <0>;
77 +
78 +@@ -399,7 +399,7 @@
79 + interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
80 + default-input = <0>;
81 +
82 +- port {
83 ++ ports {
84 + #address-cells = <1>;
85 + #size-cells = <0>;
86 +
87 +diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
88 +index a56e7c856ab5..a4d4a28fe07d 100644
89 +--- a/arch/arm/kernel/stacktrace.c
90 ++++ b/arch/arm/kernel/stacktrace.c
91 +@@ -21,6 +21,19 @@
92 + * A simple function epilogue looks like this:
93 + * ldm sp, {fp, sp, pc}
94 + *
95 ++ * When compiled with clang, pc and sp are not pushed. A simple function
96 ++ * prologue looks like this when built with clang:
97 ++ *
98 ++ * stmdb {..., fp, lr}
99 ++ * add fp, sp, #x
100 ++ * sub sp, sp, #y
101 ++ *
102 ++ * A simple function epilogue looks like this when built with clang:
103 ++ *
104 ++ * sub sp, fp, #x
105 ++ * ldm {..., fp, pc}
106 ++ *
107 ++ *
108 + * Note that with framepointer enabled, even the leaf functions have the same
109 + * prologue and epilogue, therefore we can ignore the LR value in this case.
110 + */
111 +@@ -33,6 +46,16 @@ int notrace unwind_frame(struct stackframe *frame)
112 + low = frame->sp;
113 + high = ALIGN(low, THREAD_SIZE);
114 +
115 ++#ifdef CONFIG_CC_IS_CLANG
116 ++ /* check current frame pointer is within bounds */
117 ++ if (fp < low + 4 || fp > high - 4)
118 ++ return -EINVAL;
119 ++
120 ++ frame->sp = frame->fp;
121 ++ frame->fp = *(unsigned long *)(fp);
122 ++ frame->pc = frame->lr;
123 ++ frame->lr = *(unsigned long *)(fp + 4);
124 ++#else
125 + /* check current frame pointer is within bounds */
126 + if (fp < low + 12 || fp > high - 4)
127 + return -EINVAL;
128 +@@ -41,6 +64,7 @@ int notrace unwind_frame(struct stackframe *frame)
129 + frame->fp = *(unsigned long *)(fp - 12);
130 + frame->sp = *(unsigned long *)(fp - 8);
131 + frame->pc = *(unsigned long *)(fp - 4);
132 ++#endif
133 +
134 + return 0;
135 + }
136 +diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
137 +index e2e4df3d11e5..21bfe9b6e16a 100644
138 +--- a/arch/arm/mach-at91/pm.c
139 ++++ b/arch/arm/mach-at91/pm.c
140 +@@ -542,13 +542,13 @@ static void __init at91_pm_sram_init(void)
141 + sram_pool = gen_pool_get(&pdev->dev, NULL);
142 + if (!sram_pool) {
143 + pr_warn("%s: sram pool unavailable!\n", __func__);
144 +- return;
145 ++ goto out_put_device;
146 + }
147 +
148 + sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
149 + if (!sram_base) {
150 + pr_warn("%s: unable to alloc sram!\n", __func__);
151 +- return;
152 ++ goto out_put_device;
153 + }
154 +
155 + sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
156 +@@ -556,12 +556,17 @@ static void __init at91_pm_sram_init(void)
157 + at91_pm_suspend_in_sram_sz, false);
158 + if (!at91_suspend_sram_fn) {
159 + pr_warn("SRAM: Could not map\n");
160 +- return;
161 ++ goto out_put_device;
162 + }
163 +
164 + /* Copy the pm suspend handler to SRAM */
165 + at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
166 + &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
167 ++ return;
168 ++
169 ++out_put_device:
170 ++ put_device(&pdev->dev);
171 ++ return;
172 + }
173 +
174 + static bool __init at91_is_pm_mode_active(int pm_mode)
175 +diff --git a/arch/arm/mach-socfpga/pm.c b/arch/arm/mach-socfpga/pm.c
176 +index d4866788702c..b782294ee30b 100644
177 +--- a/arch/arm/mach-socfpga/pm.c
178 ++++ b/arch/arm/mach-socfpga/pm.c
179 +@@ -60,14 +60,14 @@ static int socfpga_setup_ocram_self_refresh(void)
180 + if (!ocram_pool) {
181 + pr_warn("%s: ocram pool unavailable!\n", __func__);
182 + ret = -ENODEV;
183 +- goto put_node;
184 ++ goto put_device;
185 + }
186 +
187 + ocram_base = gen_pool_alloc(ocram_pool, socfpga_sdram_self_refresh_sz);
188 + if (!ocram_base) {
189 + pr_warn("%s: unable to alloc ocram!\n", __func__);
190 + ret = -ENOMEM;
191 +- goto put_node;
192 ++ goto put_device;
193 + }
194 +
195 + ocram_pbase = gen_pool_virt_to_phys(ocram_pool, ocram_base);
196 +@@ -78,7 +78,7 @@ static int socfpga_setup_ocram_self_refresh(void)
197 + if (!suspend_ocram_base) {
198 + pr_warn("%s: __arm_ioremap_exec failed!\n", __func__);
199 + ret = -ENOMEM;
200 +- goto put_node;
201 ++ goto put_device;
202 + }
203 +
204 + /* Copy the code that puts DDR in self refresh to ocram */
205 +@@ -92,6 +92,8 @@ static int socfpga_setup_ocram_self_refresh(void)
206 + if (!socfpga_sdram_self_refresh_in_ocram)
207 + ret = -EFAULT;
208 +
209 ++put_device:
210 ++ put_device(&pdev->dev);
211 + put_node:
212 + of_node_put(np);
213 +
214 +diff --git a/arch/arm64/boot/dts/exynos/exynos7-espresso.dts b/arch/arm64/boot/dts/exynos/exynos7-espresso.dts
215 +index 00dd89b92b42..d991eae5202f 100644
216 +--- a/arch/arm64/boot/dts/exynos/exynos7-espresso.dts
217 ++++ b/arch/arm64/boot/dts/exynos/exynos7-espresso.dts
218 +@@ -152,6 +152,7 @@
219 + regulator-min-microvolt = <700000>;
220 + regulator-max-microvolt = <1150000>;
221 + regulator-enable-ramp-delay = <125>;
222 ++ regulator-always-on;
223 + };
224 +
225 + ldo8_reg: LDO8 {
226 +diff --git a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
227 +index c98bcbc8dfba..53848e0e5e0c 100644
228 +--- a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
229 ++++ b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
230 +@@ -530,6 +530,17 @@
231 + status = "ok";
232 + compatible = "adi,adv7533";
233 + reg = <0x39>;
234 ++ adi,dsi-lanes = <4>;
235 ++ ports {
236 ++ #address-cells = <1>;
237 ++ #size-cells = <0>;
238 ++ port@0 {
239 ++ reg = <0>;
240 ++ };
241 ++ port@1 {
242 ++ reg = <1>;
243 ++ };
244 ++ };
245 + };
246 + };
247 +
248 +diff --git a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
249 +index e80a792827ed..60568392d21e 100644
250 +--- a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
251 ++++ b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
252 +@@ -515,7 +515,7 @@
253 + reg = <0x39>;
254 + interrupt-parent = <&gpio1>;
255 + interrupts = <1 2>;
256 +- pd-gpio = <&gpio0 4 0>;
257 ++ pd-gpios = <&gpio0 4 0>;
258 + adi,dsi-lanes = <4>;
259 + #sound-dai-cells = <0>;
260 +
261 +diff --git a/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi b/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
262 +index 390a2fa28514..60d218c5275c 100644
263 +--- a/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
264 ++++ b/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
265 +@@ -516,7 +516,7 @@
266 + pins = "gpio63", "gpio64", "gpio65", "gpio66",
267 + "gpio67", "gpio68";
268 + drive-strength = <8>;
269 +- bias-pull-none;
270 ++ bias-disable;
271 + };
272 + };
273 + cdc_pdm_lines_sus: pdm_lines_off {
274 +@@ -545,7 +545,7 @@
275 + pins = "gpio113", "gpio114", "gpio115",
276 + "gpio116";
277 + drive-strength = <8>;
278 +- bias-pull-none;
279 ++ bias-disable;
280 + };
281 + };
282 +
283 +@@ -573,7 +573,7 @@
284 + pinconf {
285 + pins = "gpio110";
286 + drive-strength = <8>;
287 +- bias-pull-none;
288 ++ bias-disable;
289 + };
290 + };
291 +
292 +@@ -599,7 +599,7 @@
293 + pinconf {
294 + pins = "gpio116";
295 + drive-strength = <8>;
296 +- bias-pull-none;
297 ++ bias-disable;
298 + };
299 + };
300 + ext_mclk_tlmm_lines_sus: mclk_lines_off {
301 +@@ -627,7 +627,7 @@
302 + pins = "gpio112", "gpio117", "gpio118",
303 + "gpio119";
304 + drive-strength = <8>;
305 +- bias-pull-none;
306 ++ bias-disable;
307 + };
308 + };
309 + ext_sec_tlmm_lines_sus: tlmm_lines_off {
310 +diff --git a/arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi b/arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi
311 +index 1315972412df..23098c13ad83 100644
312 +--- a/arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi
313 ++++ b/arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi
314 +@@ -159,7 +159,7 @@
315 + pinctrl-0 = <&rgmii_pins>;
316 + snps,reset-active-low;
317 + snps,reset-delays-us = <0 10000 50000>;
318 +- snps,reset-gpio = <&gpio3 RK_PB3 GPIO_ACTIVE_HIGH>;
319 ++ snps,reset-gpio = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
320 + tx_delay = <0x10>;
321 + rx_delay = <0x10>;
322 + status = "okay";
323 +diff --git a/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi
324 +index 0130b9f98c9d..b155f657292b 100644
325 +--- a/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi
326 ++++ b/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi
327 +@@ -101,7 +101,7 @@
328 +
329 + vcc5v0_host: vcc5v0-host-regulator {
330 + compatible = "regulator-fixed";
331 +- gpio = <&gpio4 RK_PA3 GPIO_ACTIVE_HIGH>;
332 ++ gpio = <&gpio4 RK_PA3 GPIO_ACTIVE_LOW>;
333 + enable-active-low;
334 + pinctrl-names = "default";
335 + pinctrl-0 = <&vcc5v0_host_en>;
336 +@@ -156,7 +156,7 @@
337 + phy-mode = "rgmii";
338 + pinctrl-names = "default";
339 + pinctrl-0 = <&rgmii_pins>;
340 +- snps,reset-gpio = <&gpio3 RK_PC0 GPIO_ACTIVE_HIGH>;
341 ++ snps,reset-gpio = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
342 + snps,reset-active-low;
343 + snps,reset-delays-us = <0 10000 50000>;
344 + tx_delay = <0x10>;
345 +diff --git a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c
346 +index 9bfa17015768..c432bfafe63e 100644
347 +--- a/arch/m68k/mac/iop.c
348 ++++ b/arch/m68k/mac/iop.c
349 +@@ -183,7 +183,7 @@ static __inline__ void iop_writeb(volatile struct mac_iop *iop, __u16 addr, __u8
350 +
351 + static __inline__ void iop_stop(volatile struct mac_iop *iop)
352 + {
353 +- iop->status_ctrl &= ~IOP_RUN;
354 ++ iop->status_ctrl = IOP_AUTOINC;
355 + }
356 +
357 + static __inline__ void iop_start(volatile struct mac_iop *iop)
358 +@@ -191,14 +191,9 @@ static __inline__ void iop_start(volatile struct mac_iop *iop)
359 + iop->status_ctrl = IOP_RUN | IOP_AUTOINC;
360 + }
361 +
362 +-static __inline__ void iop_bypass(volatile struct mac_iop *iop)
363 +-{
364 +- iop->status_ctrl |= IOP_BYPASS;
365 +-}
366 +-
367 + static __inline__ void iop_interrupt(volatile struct mac_iop *iop)
368 + {
369 +- iop->status_ctrl |= IOP_IRQ;
370 ++ iop->status_ctrl = IOP_IRQ | IOP_RUN | IOP_AUTOINC;
371 + }
372 +
373 + static int iop_alive(volatile struct mac_iop *iop)
374 +@@ -244,7 +239,6 @@ void __init iop_preinit(void)
375 + } else {
376 + iop_base[IOP_NUM_SCC] = (struct mac_iop *) SCC_IOP_BASE_QUADRA;
377 + }
378 +- iop_base[IOP_NUM_SCC]->status_ctrl = 0x87;
379 + iop_scc_present = 1;
380 + } else {
381 + iop_base[IOP_NUM_SCC] = NULL;
382 +@@ -256,7 +250,7 @@ void __init iop_preinit(void)
383 + } else {
384 + iop_base[IOP_NUM_ISM] = (struct mac_iop *) ISM_IOP_BASE_QUADRA;
385 + }
386 +- iop_base[IOP_NUM_ISM]->status_ctrl = 0;
387 ++ iop_stop(iop_base[IOP_NUM_ISM]);
388 + iop_ism_present = 1;
389 + } else {
390 + iop_base[IOP_NUM_ISM] = NULL;
391 +@@ -416,7 +410,8 @@ static void iop_handle_send(uint iop_num, uint chan)
392 + msg->status = IOP_MSGSTATUS_UNUSED;
393 + msg = msg->next;
394 + iop_send_queue[iop_num][chan] = msg;
395 +- if (msg) iop_do_send(msg);
396 ++ if (msg && iop_readb(iop, IOP_ADDR_SEND_STATE + chan) == IOP_MSG_IDLE)
397 ++ iop_do_send(msg);
398 + }
399 +
400 + /*
401 +@@ -490,16 +485,12 @@ int iop_send_message(uint iop_num, uint chan, void *privdata,
402 +
403 + if (!(q = iop_send_queue[iop_num][chan])) {
404 + iop_send_queue[iop_num][chan] = msg;
405 ++ iop_do_send(msg);
406 + } else {
407 + while (q->next) q = q->next;
408 + q->next = msg;
409 + }
410 +
411 +- if (iop_readb(iop_base[iop_num],
412 +- IOP_ADDR_SEND_STATE + chan) == IOP_MSG_IDLE) {
413 +- iop_do_send(msg);
414 +- }
415 +-
416 + return 0;
417 + }
418 +
419 +diff --git a/arch/mips/cavium-octeon/octeon-usb.c b/arch/mips/cavium-octeon/octeon-usb.c
420 +index bfdfaf32d2c4..75189ff2f3c7 100644
421 +--- a/arch/mips/cavium-octeon/octeon-usb.c
422 ++++ b/arch/mips/cavium-octeon/octeon-usb.c
423 +@@ -517,6 +517,7 @@ static int __init dwc3_octeon_device_init(void)
424 +
425 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
426 + if (res == NULL) {
427 ++ put_device(&pdev->dev);
428 + dev_err(&pdev->dev, "No memory resources\n");
429 + return -ENXIO;
430 + }
431 +@@ -528,8 +529,10 @@ static int __init dwc3_octeon_device_init(void)
432 + * know the difference.
433 + */
434 + base = devm_ioremap_resource(&pdev->dev, res);
435 +- if (IS_ERR(base))
436 ++ if (IS_ERR(base)) {
437 ++ put_device(&pdev->dev);
438 + return PTR_ERR(base);
439 ++ }
440 +
441 + mutex_lock(&dwc3_octeon_clocks_mutex);
442 + dwc3_octeon_clocks_start(&pdev->dev, (u64)base);
443 +diff --git a/arch/parisc/include/asm/barrier.h b/arch/parisc/include/asm/barrier.h
444 +index dbaaca84f27f..640d46edf32e 100644
445 +--- a/arch/parisc/include/asm/barrier.h
446 ++++ b/arch/parisc/include/asm/barrier.h
447 +@@ -26,6 +26,67 @@
448 + #define __smp_rmb() mb()
449 + #define __smp_wmb() mb()
450 +
451 ++#define __smp_store_release(p, v) \
452 ++do { \
453 ++ typeof(p) __p = (p); \
454 ++ union { typeof(*p) __val; char __c[1]; } __u = \
455 ++ { .__val = (__force typeof(*p)) (v) }; \
456 ++ compiletime_assert_atomic_type(*p); \
457 ++ switch (sizeof(*p)) { \
458 ++ case 1: \
459 ++ asm volatile("stb,ma %0,0(%1)" \
460 ++ : : "r"(*(__u8 *)__u.__c), "r"(__p) \
461 ++ : "memory"); \
462 ++ break; \
463 ++ case 2: \
464 ++ asm volatile("sth,ma %0,0(%1)" \
465 ++ : : "r"(*(__u16 *)__u.__c), "r"(__p) \
466 ++ : "memory"); \
467 ++ break; \
468 ++ case 4: \
469 ++ asm volatile("stw,ma %0,0(%1)" \
470 ++ : : "r"(*(__u32 *)__u.__c), "r"(__p) \
471 ++ : "memory"); \
472 ++ break; \
473 ++ case 8: \
474 ++ if (IS_ENABLED(CONFIG_64BIT)) \
475 ++ asm volatile("std,ma %0,0(%1)" \
476 ++ : : "r"(*(__u64 *)__u.__c), "r"(__p) \
477 ++ : "memory"); \
478 ++ break; \
479 ++ } \
480 ++} while (0)
481 ++
482 ++#define __smp_load_acquire(p) \
483 ++({ \
484 ++ union { typeof(*p) __val; char __c[1]; } __u; \
485 ++ typeof(p) __p = (p); \
486 ++ compiletime_assert_atomic_type(*p); \
487 ++ switch (sizeof(*p)) { \
488 ++ case 1: \
489 ++ asm volatile("ldb,ma 0(%1),%0" \
490 ++ : "=r"(*(__u8 *)__u.__c) : "r"(__p) \
491 ++ : "memory"); \
492 ++ break; \
493 ++ case 2: \
494 ++ asm volatile("ldh,ma 0(%1),%0" \
495 ++ : "=r"(*(__u16 *)__u.__c) : "r"(__p) \
496 ++ : "memory"); \
497 ++ break; \
498 ++ case 4: \
499 ++ asm volatile("ldw,ma 0(%1),%0" \
500 ++ : "=r"(*(__u32 *)__u.__c) : "r"(__p) \
501 ++ : "memory"); \
502 ++ break; \
503 ++ case 8: \
504 ++ if (IS_ENABLED(CONFIG_64BIT)) \
505 ++ asm volatile("ldd,ma 0(%1),%0" \
506 ++ : "=r"(*(__u64 *)__u.__c) : "r"(__p) \
507 ++ : "memory"); \
508 ++ break; \
509 ++ } \
510 ++ __u.__val; \
511 ++})
512 + #include <asm-generic/barrier.h>
513 +
514 + #endif /* !__ASSEMBLY__ */
515 +diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
516 +index 7d5ddf53750c..7a83b5e136e0 100644
517 +--- a/arch/powerpc/boot/Makefile
518 ++++ b/arch/powerpc/boot/Makefile
519 +@@ -122,7 +122,7 @@ src-wlib-y := string.S crt0.S stdio.c decompress.c main.c \
520 + elf_util.c $(zlib-y) devtree.c stdlib.c \
521 + oflib.c ofconsole.c cuboot.c
522 +
523 +-src-wlib-$(CONFIG_PPC_MPC52XX) += mpc52xx-psc.c
524 ++src-wlib-$(CONFIG_PPC_MPC52xx) += mpc52xx-psc.c
525 + src-wlib-$(CONFIG_PPC64_BOOT_WRAPPER) += opal-calls.S opal.c
526 + ifndef CONFIG_PPC64_BOOT_WRAPPER
527 + src-wlib-y += crtsavres.S
528 +diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
529 +index 48e3743faedf..83c78427c20b 100644
530 +--- a/arch/powerpc/boot/serial.c
531 ++++ b/arch/powerpc/boot/serial.c
532 +@@ -127,7 +127,7 @@ int serial_console_init(void)
533 + dt_is_compatible(devp, "fsl,cpm2-smc-uart"))
534 + rc = cpm_console_init(devp, &serial_cd);
535 + #endif
536 +-#ifdef CONFIG_PPC_MPC52XX
537 ++#ifdef CONFIG_PPC_MPC52xx
538 + else if (dt_is_compatible(devp, "fsl,mpc5200-psc-uart"))
539 + rc = mpc5200_psc_console_init(devp, &serial_cd);
540 + #endif
541 +diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
542 +index 65b3bdb99f0b..31ab6eb61e26 100644
543 +--- a/arch/powerpc/kernel/vdso.c
544 ++++ b/arch/powerpc/kernel/vdso.c
545 +@@ -705,7 +705,7 @@ int vdso_getcpu_init(void)
546 + node = cpu_to_node(cpu);
547 + WARN_ON_ONCE(node > 0xffff);
548 +
549 +- val = (cpu & 0xfff) | ((node & 0xffff) << 16);
550 ++ val = (cpu & 0xffff) | ((node & 0xffff) << 16);
551 + mtspr(SPRN_SPRG_VDSO_WRITE, val);
552 + get_paca()->sprg_vdso = val;
553 +
554 +diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c
555 +index 7124af17da72..a587f9013988 100644
556 +--- a/arch/powerpc/mm/pkeys.c
557 ++++ b/arch/powerpc/mm/pkeys.c
558 +@@ -81,13 +81,17 @@ int pkey_initialize(void)
559 + scan_pkey_feature();
560 +
561 + /*
562 +- * Let's assume 32 pkeys on P8 bare metal, if its not defined by device
563 +- * tree. We make this exception since skiboot forgot to expose this
564 +- * property on power8.
565 ++ * Let's assume 32 pkeys on P8/P9 bare metal, if its not defined by device
566 ++ * tree. We make this exception since some version of skiboot forgot to
567 ++ * expose this property on power8/9.
568 + */
569 +- if (!pkeys_devtree_defined && !firmware_has_feature(FW_FEATURE_LPAR) &&
570 +- cpu_has_feature(CPU_FTRS_POWER8))
571 +- pkeys_total = 32;
572 ++ if (!pkeys_devtree_defined && !firmware_has_feature(FW_FEATURE_LPAR)) {
573 ++ unsigned long pvr = mfspr(SPRN_PVR);
574 ++
575 ++ if (PVR_VER(pvr) == PVR_POWER8 || PVR_VER(pvr) == PVR_POWER8E ||
576 ++ PVR_VER(pvr) == PVR_POWER8NVL || PVR_VER(pvr) == PVR_POWER9)
577 ++ pkeys_total = 32;
578 ++ }
579 +
580 + /*
581 + * Adjust the upper limit, based on the number of bits supported by
582 +diff --git a/arch/x86/crypto/aes_ctrby8_avx-x86_64.S b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
583 +index 5f6a5af9c489..77043a82da51 100644
584 +--- a/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
585 ++++ b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
586 +@@ -127,10 +127,6 @@ ddq_add_8:
587 +
588 + /* generate a unique variable for ddq_add_x */
589 +
590 +-.macro setddq n
591 +- var_ddq_add = ddq_add_\n
592 +-.endm
593 +-
594 + /* generate a unique variable for xmm register */
595 + .macro setxdata n
596 + var_xdata = %xmm\n
597 +@@ -140,9 +136,7 @@ ddq_add_8:
598 +
599 + .macro club name, id
600 + .altmacro
601 +- .if \name == DDQ_DATA
602 +- setddq %\id
603 +- .elseif \name == XDATA
604 ++ .if \name == XDATA
605 + setxdata %\id
606 + .endif
607 + .noaltmacro
608 +@@ -165,9 +159,8 @@ ddq_add_8:
609 +
610 + .set i, 1
611 + .rept (by - 1)
612 +- club DDQ_DATA, i
613 + club XDATA, i
614 +- vpaddq var_ddq_add(%rip), xcounter, var_xdata
615 ++ vpaddq (ddq_add_1 + 16 * (i - 1))(%rip), xcounter, var_xdata
616 + vptest ddq_low_msk(%rip), var_xdata
617 + jnz 1f
618 + vpaddq ddq_high_add_1(%rip), var_xdata, var_xdata
619 +@@ -180,8 +173,7 @@ ddq_add_8:
620 + vmovdqa 1*16(p_keys), xkeyA
621 +
622 + vpxor xkey0, xdata0, xdata0
623 +- club DDQ_DATA, by
624 +- vpaddq var_ddq_add(%rip), xcounter, xcounter
625 ++ vpaddq (ddq_add_1 + 16 * (by - 1))(%rip), xcounter, xcounter
626 + vptest ddq_low_msk(%rip), xcounter
627 + jnz 1f
628 + vpaddq ddq_high_add_1(%rip), xcounter, xcounter
629 +diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
630 +index cb2deb61c5d9..29b27f9a6e1e 100644
631 +--- a/arch/x86/crypto/aesni-intel_asm.S
632 ++++ b/arch/x86/crypto/aesni-intel_asm.S
633 +@@ -270,7 +270,7 @@ ALL_F: .octa 0xffffffffffffffffffffffffffffffff
634 + PSHUFB_XMM %xmm2, %xmm0
635 + movdqu %xmm0, CurCount(%arg2) # ctx_data.current_counter = iv
636 +
637 +- PRECOMPUTE \SUBKEY, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
638 ++ PRECOMPUTE \SUBKEY, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7
639 + movdqu HashKey(%arg2), %xmm13
640 +
641 + CALC_AAD_HASH %xmm13, \AAD, \AADLEN, %xmm0, %xmm1, %xmm2, %xmm3, \
642 +@@ -982,7 +982,7 @@ _initial_blocks_done\@:
643 + * arg1, %arg3, %arg4 are used as pointers only, not modified
644 + * %r11 is the data offset value
645 + */
646 +-.macro GHASH_4_ENCRYPT_4_PARALLEL_ENC TMP1 TMP2 TMP3 TMP4 TMP5 \
647 ++.macro GHASH_4_ENCRYPT_4_PARALLEL_enc TMP1 TMP2 TMP3 TMP4 TMP5 \
648 + TMP6 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 operation
649 +
650 + movdqa \XMM1, \XMM5
651 +@@ -1190,7 +1190,7 @@ aes_loop_par_enc_done\@:
652 + * arg1, %arg3, %arg4 are used as pointers only, not modified
653 + * %r11 is the data offset value
654 + */
655 +-.macro GHASH_4_ENCRYPT_4_PARALLEL_DEC TMP1 TMP2 TMP3 TMP4 TMP5 \
656 ++.macro GHASH_4_ENCRYPT_4_PARALLEL_dec TMP1 TMP2 TMP3 TMP4 TMP5 \
657 + TMP6 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 operation
658 +
659 + movdqa \XMM1, \XMM5
660 +diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
661 +index 08e2f3a5f124..95e21c438012 100644
662 +--- a/arch/x86/kernel/apic/io_apic.c
663 ++++ b/arch/x86/kernel/apic/io_apic.c
664 +@@ -2342,8 +2342,13 @@ static int mp_irqdomain_create(int ioapic)
665 +
666 + static void ioapic_destroy_irqdomain(int idx)
667 + {
668 ++ struct ioapic_domain_cfg *cfg = &ioapics[idx].irqdomain_cfg;
669 ++ struct fwnode_handle *fn = ioapics[idx].irqdomain->fwnode;
670 ++
671 + if (ioapics[idx].irqdomain) {
672 + irq_domain_remove(ioapics[idx].irqdomain);
673 ++ if (!cfg->dev)
674 ++ irq_domain_free_fwnode(fn);
675 + ioapics[idx].irqdomain = NULL;
676 + }
677 + }
678 +diff --git a/arch/x86/kernel/cpu/mcheck/mce-inject.c b/arch/x86/kernel/cpu/mcheck/mce-inject.c
679 +index 1ceccc4a5472..9cc524be3c94 100644
680 +--- a/arch/x86/kernel/cpu/mcheck/mce-inject.c
681 ++++ b/arch/x86/kernel/cpu/mcheck/mce-inject.c
682 +@@ -518,7 +518,7 @@ static void do_inject(void)
683 + */
684 + if (inj_type == DFR_INT_INJ) {
685 + i_mce.status |= MCI_STATUS_DEFERRED;
686 +- i_mce.status |= (i_mce.status & ~MCI_STATUS_UC);
687 ++ i_mce.status &= ~MCI_STATUS_UC;
688 + }
689 +
690 + /*
691 +diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
692 +index 8d4d50645310..1401f86e4007 100644
693 +--- a/arch/x86/kernel/ptrace.c
694 ++++ b/arch/x86/kernel/ptrace.c
695 +@@ -374,7 +374,7 @@ static unsigned long task_seg_base(struct task_struct *task,
696 + */
697 + mutex_lock(&task->mm->context.lock);
698 + ldt = task->mm->context.ldt;
699 +- if (unlikely(idx >= ldt->nr_entries))
700 ++ if (unlikely(!ldt || idx >= ldt->nr_entries))
701 + base = 0;
702 + else
703 + base = get_desc_base(ldt->entries + idx);
704 +diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
705 +index 738f3c732363..228feeea555f 100644
706 +--- a/drivers/acpi/acpica/exprep.c
707 ++++ b/drivers/acpi/acpica/exprep.c
708 +@@ -473,10 +473,6 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
709 + (u8)access_byte_width;
710 + }
711 + }
712 +- /* An additional reference for the container */
713 +-
714 +- acpi_ut_add_reference(obj_desc->field.region_obj);
715 +-
716 + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
717 + "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
718 + obj_desc->field.start_field_bit_offset,
719 +diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
720 +index 8cc4392c61f3..0dc8dea81582 100644
721 +--- a/drivers/acpi/acpica/utdelete.c
722 ++++ b/drivers/acpi/acpica/utdelete.c
723 +@@ -563,11 +563,6 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
724 + next_object = object->buffer_field.buffer_obj;
725 + break;
726 +
727 +- case ACPI_TYPE_LOCAL_REGION_FIELD:
728 +-
729 +- next_object = object->field.region_obj;
730 +- break;
731 +-
732 + case ACPI_TYPE_LOCAL_BANK_FIELD:
733 +
734 + next_object = object->bank_field.bank_obj;
735 +@@ -608,6 +603,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
736 + }
737 + break;
738 +
739 ++ case ACPI_TYPE_LOCAL_REGION_FIELD:
740 + case ACPI_TYPE_REGION:
741 + default:
742 +
743 +diff --git a/drivers/block/loop.c b/drivers/block/loop.c
744 +index 728681a20b7f..da68c42aed68 100644
745 +--- a/drivers/block/loop.c
746 ++++ b/drivers/block/loop.c
747 +@@ -2279,6 +2279,8 @@ static void __exit loop_exit(void)
748 +
749 + range = max_loop ? max_loop << part_shift : 1UL << MINORBITS;
750 +
751 ++ mutex_lock(&loop_ctl_mutex);
752 ++
753 + idr_for_each(&loop_index_idr, &loop_exit_cb, NULL);
754 + idr_destroy(&loop_index_idr);
755 +
756 +@@ -2286,6 +2288,8 @@ static void __exit loop_exit(void)
757 + unregister_blkdev(LOOP_MAJOR, "loop");
758 +
759 + misc_deregister(&loop_misc);
760 ++
761 ++ mutex_unlock(&loop_ctl_mutex);
762 + }
763 +
764 + module_init(loop_init);
765 +diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
766 +index 8eede1197cd2..5a68cd4dd71c 100644
767 +--- a/drivers/bluetooth/hci_h5.c
768 ++++ b/drivers/bluetooth/hci_h5.c
769 +@@ -803,7 +803,7 @@ static int h5_serdev_probe(struct serdev_device *serdev)
770 + if (!h5)
771 + return -ENOMEM;
772 +
773 +- set_bit(HCI_UART_RESET_ON_INIT, &h5->serdev_hu.flags);
774 ++ set_bit(HCI_UART_RESET_ON_INIT, &h5->serdev_hu.hdev_flags);
775 +
776 + h5->hu = &h5->serdev_hu;
777 + h5->serdev_hu.serdev = serdev;
778 +diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c
779 +index 46e20444ba19..d3fb0d657fa5 100644
780 +--- a/drivers/bluetooth/hci_serdev.c
781 ++++ b/drivers/bluetooth/hci_serdev.c
782 +@@ -369,7 +369,8 @@ void hci_uart_unregister_device(struct hci_uart *hu)
783 + struct hci_dev *hdev = hu->hdev;
784 +
785 + clear_bit(HCI_UART_PROTO_READY, &hu->flags);
786 +- hci_unregister_dev(hdev);
787 ++ if (test_bit(HCI_UART_REGISTERED, &hu->flags))
788 ++ hci_unregister_dev(hdev);
789 + hci_free_dev(hdev);
790 +
791 + cancel_work_sync(&hu->write_work);
792 +diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
793 +index b161bdf60000..0941d38b2d32 100644
794 +--- a/drivers/char/agp/intel-gtt.c
795 ++++ b/drivers/char/agp/intel-gtt.c
796 +@@ -304,8 +304,10 @@ static int intel_gtt_setup_scratch_page(void)
797 + if (intel_private.needs_dmar) {
798 + dma_addr = pci_map_page(intel_private.pcidev, page, 0,
799 + PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
800 +- if (pci_dma_mapping_error(intel_private.pcidev, dma_addr))
801 ++ if (pci_dma_mapping_error(intel_private.pcidev, dma_addr)) {
802 ++ __free_page(page);
803 + return -EINVAL;
804 ++ }
805 +
806 + intel_private.scratch_page_dma = dma_addr;
807 + } else
808 +diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c
809 +index a985bf5e1ac6..c65d30bba700 100644
810 +--- a/drivers/clk/clk-scmi.c
811 ++++ b/drivers/clk/clk-scmi.c
812 +@@ -103,6 +103,8 @@ static const struct clk_ops scmi_clk_ops = {
813 + static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk)
814 + {
815 + int ret;
816 ++ unsigned long min_rate, max_rate;
817 ++
818 + struct clk_init_data init = {
819 + .flags = CLK_GET_RATE_NOCACHE,
820 + .num_parents = 0,
821 +@@ -112,9 +114,23 @@ static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk)
822 +
823 + sclk->hw.init = &init;
824 + ret = devm_clk_hw_register(dev, &sclk->hw);
825 +- if (!ret)
826 +- clk_hw_set_rate_range(&sclk->hw, sclk->info->range.min_rate,
827 +- sclk->info->range.max_rate);
828 ++ if (ret)
829 ++ return ret;
830 ++
831 ++ if (sclk->info->rate_discrete) {
832 ++ int num_rates = sclk->info->list.num_rates;
833 ++
834 ++ if (num_rates <= 0)
835 ++ return -EINVAL;
836 ++
837 ++ min_rate = sclk->info->list.rates[0];
838 ++ max_rate = sclk->info->list.rates[num_rates - 1];
839 ++ } else {
840 ++ min_rate = sclk->info->range.min_rate;
841 ++ max_rate = sclk->info->range.max_rate;
842 ++ }
843 ++
844 ++ clk_hw_set_rate_range(&sclk->hw, min_rate, max_rate);
845 + return ret;
846 + }
847 +
848 +diff --git a/drivers/cpufreq/armada-37xx-cpufreq.c b/drivers/cpufreq/armada-37xx-cpufreq.c
849 +index 0df16eb1eb3c..c5f98cafc25c 100644
850 +--- a/drivers/cpufreq/armada-37xx-cpufreq.c
851 ++++ b/drivers/cpufreq/armada-37xx-cpufreq.c
852 +@@ -458,6 +458,7 @@ static int __init armada37xx_cpufreq_driver_init(void)
853 + /* Now that everything is setup, enable the DVFS at hardware level */
854 + armada37xx_cpufreq_enable_dvfs(nb_pm_base);
855 +
856 ++ memset(&pdata, 0, sizeof(pdata));
857 + pdata.suspend = armada37xx_cpufreq_suspend;
858 + pdata.resume = armada37xx_cpufreq_resume;
859 +
860 +diff --git a/drivers/crypto/cavium/cpt/cptvf_algs.c b/drivers/crypto/cavium/cpt/cptvf_algs.c
861 +index 600336d169a9..cd4d60d318ba 100644
862 +--- a/drivers/crypto/cavium/cpt/cptvf_algs.c
863 ++++ b/drivers/crypto/cavium/cpt/cptvf_algs.c
864 +@@ -205,6 +205,7 @@ static inline int cvm_enc_dec(struct ablkcipher_request *req, u32 enc)
865 + int status;
866 +
867 + memset(req_info, 0, sizeof(struct cpt_request_info));
868 ++ req_info->may_sleep = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) != 0;
869 + memset(fctx, 0, sizeof(struct fc_context));
870 + create_input_list(req, enc, enc_iv_len);
871 + create_output_list(req, enc_iv_len);
872 +diff --git a/drivers/crypto/cavium/cpt/cptvf_reqmanager.c b/drivers/crypto/cavium/cpt/cptvf_reqmanager.c
873 +index b0ba4331944b..43fe69d0981a 100644
874 +--- a/drivers/crypto/cavium/cpt/cptvf_reqmanager.c
875 ++++ b/drivers/crypto/cavium/cpt/cptvf_reqmanager.c
876 +@@ -136,7 +136,7 @@ static inline int setup_sgio_list(struct cpt_vf *cptvf,
877 +
878 + /* Setup gather (input) components */
879 + g_sz_bytes = ((req->incnt + 3) / 4) * sizeof(struct sglist_component);
880 +- info->gather_components = kzalloc(g_sz_bytes, GFP_KERNEL);
881 ++ info->gather_components = kzalloc(g_sz_bytes, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
882 + if (!info->gather_components) {
883 + ret = -ENOMEM;
884 + goto scatter_gather_clean;
885 +@@ -153,7 +153,7 @@ static inline int setup_sgio_list(struct cpt_vf *cptvf,
886 +
887 + /* Setup scatter (output) components */
888 + s_sz_bytes = ((req->outcnt + 3) / 4) * sizeof(struct sglist_component);
889 +- info->scatter_components = kzalloc(s_sz_bytes, GFP_KERNEL);
890 ++ info->scatter_components = kzalloc(s_sz_bytes, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
891 + if (!info->scatter_components) {
892 + ret = -ENOMEM;
893 + goto scatter_gather_clean;
894 +@@ -170,7 +170,7 @@ static inline int setup_sgio_list(struct cpt_vf *cptvf,
895 +
896 + /* Create and initialize DPTR */
897 + info->dlen = g_sz_bytes + s_sz_bytes + SG_LIST_HDR_SIZE;
898 +- info->in_buffer = kzalloc(info->dlen, GFP_KERNEL);
899 ++ info->in_buffer = kzalloc(info->dlen, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
900 + if (!info->in_buffer) {
901 + ret = -ENOMEM;
902 + goto scatter_gather_clean;
903 +@@ -198,7 +198,7 @@ static inline int setup_sgio_list(struct cpt_vf *cptvf,
904 + }
905 +
906 + /* Create and initialize RPTR */
907 +- info->out_buffer = kzalloc(COMPLETION_CODE_SIZE, GFP_KERNEL);
908 ++ info->out_buffer = kzalloc(COMPLETION_CODE_SIZE, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
909 + if (!info->out_buffer) {
910 + ret = -ENOMEM;
911 + goto scatter_gather_clean;
912 +@@ -434,7 +434,7 @@ int process_request(struct cpt_vf *cptvf, struct cpt_request_info *req)
913 + struct cpt_vq_command vq_cmd;
914 + union cpt_inst_s cptinst;
915 +
916 +- info = kzalloc(sizeof(*info), GFP_KERNEL);
917 ++ info = kzalloc(sizeof(*info), req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
918 + if (unlikely(!info)) {
919 + dev_err(&pdev->dev, "Unable to allocate memory for info_buffer\n");
920 + return -ENOMEM;
921 +@@ -456,7 +456,7 @@ int process_request(struct cpt_vf *cptvf, struct cpt_request_info *req)
922 + * Get buffer for union cpt_res_s response
923 + * structure and its physical address
924 + */
925 +- info->completion_addr = kzalloc(sizeof(union cpt_res_s), GFP_KERNEL);
926 ++ info->completion_addr = kzalloc(sizeof(union cpt_res_s), req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
927 + if (unlikely(!info->completion_addr)) {
928 + dev_err(&pdev->dev, "Unable to allocate memory for completion_addr\n");
929 + ret = -ENOMEM;
930 +diff --git a/drivers/crypto/cavium/cpt/request_manager.h b/drivers/crypto/cavium/cpt/request_manager.h
931 +index 80ee074c6e0c..09930d95ad24 100644
932 +--- a/drivers/crypto/cavium/cpt/request_manager.h
933 ++++ b/drivers/crypto/cavium/cpt/request_manager.h
934 +@@ -65,6 +65,8 @@ struct cpt_request_info {
935 + union ctrl_info ctrl; /* User control information */
936 + struct cptvf_request req; /* Request Information (Core specific) */
937 +
938 ++ bool may_sleep;
939 ++
940 + struct buf_ptr in[MAX_BUF_CNT];
941 + struct buf_ptr out[MAX_BUF_CNT];
942 +
943 +diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
944 +index 7442b0422f8a..bd43b5c1450c 100644
945 +--- a/drivers/crypto/ccp/ccp-dev.h
946 ++++ b/drivers/crypto/ccp/ccp-dev.h
947 +@@ -471,6 +471,7 @@ struct ccp_sg_workarea {
948 + unsigned int sg_used;
949 +
950 + struct scatterlist *dma_sg;
951 ++ struct scatterlist *dma_sg_head;
952 + struct device *dma_dev;
953 + unsigned int dma_count;
954 + enum dma_data_direction dma_dir;
955 +diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
956 +index 43b74cf0787e..626b643d610e 100644
957 +--- a/drivers/crypto/ccp/ccp-ops.c
958 ++++ b/drivers/crypto/ccp/ccp-ops.c
959 +@@ -67,7 +67,7 @@ static u32 ccp_gen_jobid(struct ccp_device *ccp)
960 + static void ccp_sg_free(struct ccp_sg_workarea *wa)
961 + {
962 + if (wa->dma_count)
963 +- dma_unmap_sg(wa->dma_dev, wa->dma_sg, wa->nents, wa->dma_dir);
964 ++ dma_unmap_sg(wa->dma_dev, wa->dma_sg_head, wa->nents, wa->dma_dir);
965 +
966 + wa->dma_count = 0;
967 + }
968 +@@ -96,6 +96,7 @@ static int ccp_init_sg_workarea(struct ccp_sg_workarea *wa, struct device *dev,
969 + return 0;
970 +
971 + wa->dma_sg = sg;
972 ++ wa->dma_sg_head = sg;
973 + wa->dma_dev = dev;
974 + wa->dma_dir = dma_dir;
975 + wa->dma_count = dma_map_sg(dev, sg, wa->nents, dma_dir);
976 +@@ -108,14 +109,28 @@ static int ccp_init_sg_workarea(struct ccp_sg_workarea *wa, struct device *dev,
977 + static void ccp_update_sg_workarea(struct ccp_sg_workarea *wa, unsigned int len)
978 + {
979 + unsigned int nbytes = min_t(u64, len, wa->bytes_left);
980 ++ unsigned int sg_combined_len = 0;
981 +
982 + if (!wa->sg)
983 + return;
984 +
985 + wa->sg_used += nbytes;
986 + wa->bytes_left -= nbytes;
987 +- if (wa->sg_used == wa->sg->length) {
988 +- wa->sg = sg_next(wa->sg);
989 ++ if (wa->sg_used == sg_dma_len(wa->dma_sg)) {
990 ++ /* Advance to the next DMA scatterlist entry */
991 ++ wa->dma_sg = sg_next(wa->dma_sg);
992 ++
993 ++ /* In the case that the DMA mapped scatterlist has entries
994 ++ * that have been merged, the non-DMA mapped scatterlist
995 ++ * must be advanced multiple times for each merged entry.
996 ++ * This ensures that the current non-DMA mapped entry
997 ++ * corresponds to the current DMA mapped entry.
998 ++ */
999 ++ do {
1000 ++ sg_combined_len += wa->sg->length;
1001 ++ wa->sg = sg_next(wa->sg);
1002 ++ } while (wa->sg_used > sg_combined_len);
1003 ++
1004 + wa->sg_used = 0;
1005 + }
1006 + }
1007 +@@ -304,7 +319,7 @@ static unsigned int ccp_queue_buf(struct ccp_data *data, unsigned int from)
1008 + /* Update the structures and generate the count */
1009 + buf_count = 0;
1010 + while (sg_wa->bytes_left && (buf_count < dm_wa->length)) {
1011 +- nbytes = min(sg_wa->sg->length - sg_wa->sg_used,
1012 ++ nbytes = min(sg_dma_len(sg_wa->dma_sg) - sg_wa->sg_used,
1013 + dm_wa->length - buf_count);
1014 + nbytes = min_t(u64, sg_wa->bytes_left, nbytes);
1015 +
1016 +@@ -336,11 +351,11 @@ static void ccp_prepare_data(struct ccp_data *src, struct ccp_data *dst,
1017 + * and destination. The resulting len values will always be <= UINT_MAX
1018 + * because the dma length is an unsigned int.
1019 + */
1020 +- sg_src_len = sg_dma_len(src->sg_wa.sg) - src->sg_wa.sg_used;
1021 ++ sg_src_len = sg_dma_len(src->sg_wa.dma_sg) - src->sg_wa.sg_used;
1022 + sg_src_len = min_t(u64, src->sg_wa.bytes_left, sg_src_len);
1023 +
1024 + if (dst) {
1025 +- sg_dst_len = sg_dma_len(dst->sg_wa.sg) - dst->sg_wa.sg_used;
1026 ++ sg_dst_len = sg_dma_len(dst->sg_wa.dma_sg) - dst->sg_wa.sg_used;
1027 + sg_dst_len = min_t(u64, src->sg_wa.bytes_left, sg_dst_len);
1028 + op_len = min(sg_src_len, sg_dst_len);
1029 + } else {
1030 +@@ -370,7 +385,7 @@ static void ccp_prepare_data(struct ccp_data *src, struct ccp_data *dst,
1031 + /* Enough data in the sg element, but we need to
1032 + * adjust for any previously copied data
1033 + */
1034 +- op->src.u.dma.address = sg_dma_address(src->sg_wa.sg);
1035 ++ op->src.u.dma.address = sg_dma_address(src->sg_wa.dma_sg);
1036 + op->src.u.dma.offset = src->sg_wa.sg_used;
1037 + op->src.u.dma.length = op_len & ~(block_size - 1);
1038 +
1039 +@@ -391,7 +406,7 @@ static void ccp_prepare_data(struct ccp_data *src, struct ccp_data *dst,
1040 + /* Enough room in the sg element, but we need to
1041 + * adjust for any previously used area
1042 + */
1043 +- op->dst.u.dma.address = sg_dma_address(dst->sg_wa.sg);
1044 ++ op->dst.u.dma.address = sg_dma_address(dst->sg_wa.dma_sg);
1045 + op->dst.u.dma.offset = dst->sg_wa.sg_used;
1046 + op->dst.u.dma.length = op->src.u.dma.length;
1047 + }
1048 +@@ -2034,7 +2049,7 @@ ccp_run_passthru_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
1049 + dst.sg_wa.sg_used = 0;
1050 + for (i = 1; i <= src.sg_wa.dma_count; i++) {
1051 + if (!dst.sg_wa.sg ||
1052 +- (dst.sg_wa.sg->length < src.sg_wa.sg->length)) {
1053 ++ (sg_dma_len(dst.sg_wa.sg) < sg_dma_len(src.sg_wa.sg))) {
1054 + ret = -EINVAL;
1055 + goto e_dst;
1056 + }
1057 +@@ -2060,8 +2075,8 @@ ccp_run_passthru_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
1058 + goto e_dst;
1059 + }
1060 +
1061 +- dst.sg_wa.sg_used += src.sg_wa.sg->length;
1062 +- if (dst.sg_wa.sg_used == dst.sg_wa.sg->length) {
1063 ++ dst.sg_wa.sg_used += sg_dma_len(src.sg_wa.sg);
1064 ++ if (dst.sg_wa.sg_used == sg_dma_len(dst.sg_wa.sg)) {
1065 + dst.sg_wa.sg = sg_next(dst.sg_wa.sg);
1066 + dst.sg_wa.sg_used = 0;
1067 + }
1068 +diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
1069 +index 28a5b8b38fa2..1bcb6f0157b0 100644
1070 +--- a/drivers/crypto/ccree/cc_cipher.c
1071 ++++ b/drivers/crypto/ccree/cc_cipher.c
1072 +@@ -137,7 +137,6 @@ static int cc_cipher_init(struct crypto_tfm *tfm)
1073 + skcipher_alg.base);
1074 + struct device *dev = drvdata_to_dev(cc_alg->drvdata);
1075 + unsigned int max_key_buf_size = cc_alg->skcipher_alg.max_keysize;
1076 +- int rc = 0;
1077 +
1078 + dev_dbg(dev, "Initializing context @%p for %s\n", ctx_p,
1079 + crypto_tfm_alg_name(tfm));
1080 +@@ -149,10 +148,19 @@ static int cc_cipher_init(struct crypto_tfm *tfm)
1081 + ctx_p->flow_mode = cc_alg->flow_mode;
1082 + ctx_p->drvdata = cc_alg->drvdata;
1083 +
1084 ++ if (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) {
1085 ++ /* Alloc hash tfm for essiv */
1086 ++ ctx_p->shash_tfm = crypto_alloc_shash("sha256-generic", 0, 0);
1087 ++ if (IS_ERR(ctx_p->shash_tfm)) {
1088 ++ dev_err(dev, "Error allocating hash tfm for ESSIV.\n");
1089 ++ return PTR_ERR(ctx_p->shash_tfm);
1090 ++ }
1091 ++ }
1092 ++
1093 + /* Allocate key buffer, cache line aligned */
1094 + ctx_p->user.key = kmalloc(max_key_buf_size, GFP_KERNEL);
1095 + if (!ctx_p->user.key)
1096 +- return -ENOMEM;
1097 ++ goto free_shash;
1098 +
1099 + dev_dbg(dev, "Allocated key buffer in context. key=@%p\n",
1100 + ctx_p->user.key);
1101 +@@ -164,21 +172,19 @@ static int cc_cipher_init(struct crypto_tfm *tfm)
1102 + if (dma_mapping_error(dev, ctx_p->user.key_dma_addr)) {
1103 + dev_err(dev, "Mapping Key %u B at va=%pK for DMA failed\n",
1104 + max_key_buf_size, ctx_p->user.key);
1105 +- return -ENOMEM;
1106 ++ goto free_key;
1107 + }
1108 + dev_dbg(dev, "Mapped key %u B at va=%pK to dma=%pad\n",
1109 + max_key_buf_size, ctx_p->user.key, &ctx_p->user.key_dma_addr);
1110 +
1111 +- if (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) {
1112 +- /* Alloc hash tfm for essiv */
1113 +- ctx_p->shash_tfm = crypto_alloc_shash("sha256-generic", 0, 0);
1114 +- if (IS_ERR(ctx_p->shash_tfm)) {
1115 +- dev_err(dev, "Error allocating hash tfm for ESSIV.\n");
1116 +- return PTR_ERR(ctx_p->shash_tfm);
1117 +- }
1118 +- }
1119 ++ return 0;
1120 +
1121 +- return rc;
1122 ++free_key:
1123 ++ kfree(ctx_p->user.key);
1124 ++free_shash:
1125 ++ crypto_free_shash(ctx_p->shash_tfm);
1126 ++
1127 ++ return -ENOMEM;
1128 + }
1129 +
1130 + static void cc_cipher_exit(struct crypto_tfm *tfm)
1131 +diff --git a/drivers/crypto/hisilicon/sec/sec_algs.c b/drivers/crypto/hisilicon/sec/sec_algs.c
1132 +index bf9658800bda..3e3cc28d5cfe 100644
1133 +--- a/drivers/crypto/hisilicon/sec/sec_algs.c
1134 ++++ b/drivers/crypto/hisilicon/sec/sec_algs.c
1135 +@@ -175,7 +175,8 @@ static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl,
1136 + dma_addr_t *psec_sgl,
1137 + struct scatterlist *sgl,
1138 + int count,
1139 +- struct sec_dev_info *info)
1140 ++ struct sec_dev_info *info,
1141 ++ gfp_t gfp)
1142 + {
1143 + struct sec_hw_sgl *sgl_current = NULL;
1144 + struct sec_hw_sgl *sgl_next;
1145 +@@ -190,7 +191,7 @@ static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl,
1146 + sge_index = i % SEC_MAX_SGE_NUM;
1147 + if (sge_index == 0) {
1148 + sgl_next = dma_pool_zalloc(info->hw_sgl_pool,
1149 +- GFP_KERNEL, &sgl_next_dma);
1150 ++ gfp, &sgl_next_dma);
1151 + if (!sgl_next) {
1152 + ret = -ENOMEM;
1153 + goto err_free_hw_sgls;
1154 +@@ -553,14 +554,14 @@ void sec_alg_callback(struct sec_bd_info *resp, void *shadow)
1155 + }
1156 +
1157 + static int sec_alg_alloc_and_calc_split_sizes(int length, size_t **split_sizes,
1158 +- int *steps)
1159 ++ int *steps, gfp_t gfp)
1160 + {
1161 + size_t *sizes;
1162 + int i;
1163 +
1164 + /* Split into suitable sized blocks */
1165 + *steps = roundup(length, SEC_REQ_LIMIT) / SEC_REQ_LIMIT;
1166 +- sizes = kcalloc(*steps, sizeof(*sizes), GFP_KERNEL);
1167 ++ sizes = kcalloc(*steps, sizeof(*sizes), gfp);
1168 + if (!sizes)
1169 + return -ENOMEM;
1170 +
1171 +@@ -576,7 +577,7 @@ static int sec_map_and_split_sg(struct scatterlist *sgl, size_t *split_sizes,
1172 + int steps, struct scatterlist ***splits,
1173 + int **splits_nents,
1174 + int sgl_len_in,
1175 +- struct device *dev)
1176 ++ struct device *dev, gfp_t gfp)
1177 + {
1178 + int ret, count;
1179 +
1180 +@@ -584,12 +585,12 @@ static int sec_map_and_split_sg(struct scatterlist *sgl, size_t *split_sizes,
1181 + if (!count)
1182 + return -EINVAL;
1183 +
1184 +- *splits = kcalloc(steps, sizeof(struct scatterlist *), GFP_KERNEL);
1185 ++ *splits = kcalloc(steps, sizeof(struct scatterlist *), gfp);
1186 + if (!*splits) {
1187 + ret = -ENOMEM;
1188 + goto err_unmap_sg;
1189 + }
1190 +- *splits_nents = kcalloc(steps, sizeof(int), GFP_KERNEL);
1191 ++ *splits_nents = kcalloc(steps, sizeof(int), gfp);
1192 + if (!*splits_nents) {
1193 + ret = -ENOMEM;
1194 + goto err_free_splits;
1195 +@@ -597,7 +598,7 @@ static int sec_map_and_split_sg(struct scatterlist *sgl, size_t *split_sizes,
1196 +
1197 + /* output the scatter list before and after this */
1198 + ret = sg_split(sgl, count, 0, steps, split_sizes,
1199 +- *splits, *splits_nents, GFP_KERNEL);
1200 ++ *splits, *splits_nents, gfp);
1201 + if (ret) {
1202 + ret = -ENOMEM;
1203 + goto err_free_splits_nents;
1204 +@@ -638,13 +639,13 @@ static struct sec_request_el
1205 + int el_size, bool different_dest,
1206 + struct scatterlist *sgl_in, int n_ents_in,
1207 + struct scatterlist *sgl_out, int n_ents_out,
1208 +- struct sec_dev_info *info)
1209 ++ struct sec_dev_info *info, gfp_t gfp)
1210 + {
1211 + struct sec_request_el *el;
1212 + struct sec_bd_info *req;
1213 + int ret;
1214 +
1215 +- el = kzalloc(sizeof(*el), GFP_KERNEL);
1216 ++ el = kzalloc(sizeof(*el), gfp);
1217 + if (!el)
1218 + return ERR_PTR(-ENOMEM);
1219 + el->el_length = el_size;
1220 +@@ -676,7 +677,7 @@ static struct sec_request_el
1221 + el->sgl_in = sgl_in;
1222 +
1223 + ret = sec_alloc_and_fill_hw_sgl(&el->in, &el->dma_in, el->sgl_in,
1224 +- n_ents_in, info);
1225 ++ n_ents_in, info, gfp);
1226 + if (ret)
1227 + goto err_free_el;
1228 +
1229 +@@ -687,7 +688,7 @@ static struct sec_request_el
1230 + el->sgl_out = sgl_out;
1231 + ret = sec_alloc_and_fill_hw_sgl(&el->out, &el->dma_out,
1232 + el->sgl_out,
1233 +- n_ents_out, info);
1234 ++ n_ents_out, info, gfp);
1235 + if (ret)
1236 + goto err_free_hw_sgl_in;
1237 +
1238 +@@ -728,6 +729,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
1239 + int *splits_out_nents = NULL;
1240 + struct sec_request_el *el, *temp;
1241 + bool split = skreq->src != skreq->dst;
1242 ++ gfp_t gfp = skreq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : GFP_ATOMIC;
1243 +
1244 + mutex_init(&sec_req->lock);
1245 + sec_req->req_base = &skreq->base;
1246 +@@ -736,13 +738,13 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
1247 + sec_req->len_in = sg_nents(skreq->src);
1248 +
1249 + ret = sec_alg_alloc_and_calc_split_sizes(skreq->cryptlen, &split_sizes,
1250 +- &steps);
1251 ++ &steps, gfp);
1252 + if (ret)
1253 + return ret;
1254 + sec_req->num_elements = steps;
1255 + ret = sec_map_and_split_sg(skreq->src, split_sizes, steps, &splits_in,
1256 + &splits_in_nents, sec_req->len_in,
1257 +- info->dev);
1258 ++ info->dev, gfp);
1259 + if (ret)
1260 + goto err_free_split_sizes;
1261 +
1262 +@@ -750,7 +752,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
1263 + sec_req->len_out = sg_nents(skreq->dst);
1264 + ret = sec_map_and_split_sg(skreq->dst, split_sizes, steps,
1265 + &splits_out, &splits_out_nents,
1266 +- sec_req->len_out, info->dev);
1267 ++ sec_req->len_out, info->dev, gfp);
1268 + if (ret)
1269 + goto err_unmap_in_sg;
1270 + }
1271 +@@ -783,7 +785,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
1272 + splits_in[i], splits_in_nents[i],
1273 + split ? splits_out[i] : NULL,
1274 + split ? splits_out_nents[i] : 0,
1275 +- info);
1276 ++ info, gfp);
1277 + if (IS_ERR(el)) {
1278 + ret = PTR_ERR(el);
1279 + goto err_free_elements;
1280 +diff --git a/drivers/crypto/qat/qat_common/qat_uclo.c b/drivers/crypto/qat/qat_common/qat_uclo.c
1281 +index 6bd8f6a2a24f..aeb03081415c 100644
1282 +--- a/drivers/crypto/qat/qat_common/qat_uclo.c
1283 ++++ b/drivers/crypto/qat/qat_common/qat_uclo.c
1284 +@@ -332,13 +332,18 @@ static int qat_uclo_create_batch_init_list(struct icp_qat_fw_loader_handle
1285 + }
1286 + return 0;
1287 + out_err:
1288 ++ /* Do not free the list head unless we allocated it. */
1289 ++ tail_old = tail_old->next;
1290 ++ if (flag) {
1291 ++ kfree(*init_tab_base);
1292 ++ *init_tab_base = NULL;
1293 ++ }
1294 ++
1295 + while (tail_old) {
1296 + mem_init = tail_old->next;
1297 + kfree(tail_old);
1298 + tail_old = mem_init;
1299 + }
1300 +- if (flag)
1301 +- kfree(*init_tab_base);
1302 + return -ENOMEM;
1303 + }
1304 +
1305 +diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
1306 +index 0e7ea3591b78..5e7593753799 100644
1307 +--- a/drivers/edac/edac_device_sysfs.c
1308 ++++ b/drivers/edac/edac_device_sysfs.c
1309 +@@ -275,6 +275,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
1310 +
1311 + /* Error exit stack */
1312 + err_kobj_reg:
1313 ++ kobject_put(&edac_dev->kobj);
1314 + module_put(edac_dev->owner);
1315 +
1316 + err_out:
1317 +diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
1318 +index 72c9eb9fdffb..53042af7262e 100644
1319 +--- a/drivers/edac/edac_pci_sysfs.c
1320 ++++ b/drivers/edac/edac_pci_sysfs.c
1321 +@@ -386,7 +386,7 @@ static int edac_pci_main_kobj_setup(void)
1322 +
1323 + /* Error unwind statck */
1324 + kobject_init_and_add_fail:
1325 +- kfree(edac_pci_top_main_kobj);
1326 ++ kobject_put(edac_pci_top_main_kobj);
1327 +
1328 + kzalloc_fail:
1329 + module_put(THIS_MODULE);
1330 +diff --git a/drivers/firmware/arm_scmi/scmi_pm_domain.c b/drivers/firmware/arm_scmi/scmi_pm_domain.c
1331 +index 87f737e01473..041f8152272b 100644
1332 +--- a/drivers/firmware/arm_scmi/scmi_pm_domain.c
1333 ++++ b/drivers/firmware/arm_scmi/scmi_pm_domain.c
1334 +@@ -85,7 +85,10 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
1335 + for (i = 0; i < num_domains; i++, scmi_pd++) {
1336 + u32 state;
1337 +
1338 +- domains[i] = &scmi_pd->genpd;
1339 ++ if (handle->power_ops->state_get(handle, i, &state)) {
1340 ++ dev_warn(dev, "failed to get state for domain %d\n", i);
1341 ++ continue;
1342 ++ }
1343 +
1344 + scmi_pd->domain = i;
1345 + scmi_pd->handle = handle;
1346 +@@ -94,13 +97,10 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
1347 + scmi_pd->genpd.power_off = scmi_pd_power_off;
1348 + scmi_pd->genpd.power_on = scmi_pd_power_on;
1349 +
1350 +- if (handle->power_ops->state_get(handle, i, &state)) {
1351 +- dev_warn(dev, "failed to get state for domain %d\n", i);
1352 +- continue;
1353 +- }
1354 +-
1355 + pm_genpd_init(&scmi_pd->genpd, NULL,
1356 + state == SCMI_POWER_STATE_GENERIC_OFF);
1357 ++
1358 ++ domains[i] = &scmi_pd->genpd;
1359 + }
1360 +
1361 + scmi_pd_data->domains = domains;
1362 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
1363 +index 869ff624b108..e5e51e4d4f3d 100644
1364 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
1365 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
1366 +@@ -396,7 +396,9 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
1367 + ring->fence_drv.gpu_addr = adev->uvd.inst[ring->me].gpu_addr + index;
1368 + }
1369 + amdgpu_fence_write(ring, atomic_read(&ring->fence_drv.last_seq));
1370 +- amdgpu_irq_get(adev, irq_src, irq_type);
1371 ++
1372 ++ if (irq_src)
1373 ++ amdgpu_irq_get(adev, irq_src, irq_type);
1374 +
1375 + ring->fence_drv.irq_src = irq_src;
1376 + ring->fence_drv.irq_type = irq_type;
1377 +@@ -508,8 +510,9 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev)
1378 + /* no need to trigger GPU reset as we are unloading */
1379 + amdgpu_fence_driver_force_completion(ring);
1380 + }
1381 +- amdgpu_irq_put(adev, ring->fence_drv.irq_src,
1382 +- ring->fence_drv.irq_type);
1383 ++ if (ring->fence_drv.irq_src)
1384 ++ amdgpu_irq_put(adev, ring->fence_drv.irq_src,
1385 ++ ring->fence_drv.irq_type);
1386 + drm_sched_fini(&ring->sched);
1387 + del_timer_sync(&ring->fence_drv.fallback_timer);
1388 + for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j)
1389 +@@ -545,8 +548,9 @@ void amdgpu_fence_driver_suspend(struct amdgpu_device *adev)
1390 + }
1391 +
1392 + /* disable the interrupt */
1393 +- amdgpu_irq_put(adev, ring->fence_drv.irq_src,
1394 +- ring->fence_drv.irq_type);
1395 ++ if (ring->fence_drv.irq_src)
1396 ++ amdgpu_irq_put(adev, ring->fence_drv.irq_src,
1397 ++ ring->fence_drv.irq_type);
1398 + }
1399 + }
1400 +
1401 +@@ -572,8 +576,9 @@ void amdgpu_fence_driver_resume(struct amdgpu_device *adev)
1402 + continue;
1403 +
1404 + /* enable the interrupt */
1405 +- amdgpu_irq_get(adev, ring->fence_drv.irq_src,
1406 +- ring->fence_drv.irq_type);
1407 ++ if (ring->fence_drv.irq_src)
1408 ++ amdgpu_irq_get(adev, ring->fence_drv.irq_src,
1409 ++ ring->fence_drv.irq_type);
1410 + }
1411 + }
1412 +
1413 +diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
1414 +index 29409a65d864..a347b27405d8 100644
1415 +--- a/drivers/gpu/drm/arm/malidp_planes.c
1416 ++++ b/drivers/gpu/drm/arm/malidp_planes.c
1417 +@@ -446,7 +446,7 @@ int malidp_de_planes_init(struct drm_device *drm)
1418 + const struct malidp_hw_regmap *map = &malidp->dev->hw->map;
1419 + struct malidp_plane *plane = NULL;
1420 + enum drm_plane_type plane_type;
1421 +- unsigned long crtcs = 1 << drm->mode_config.num_crtc;
1422 ++ unsigned long crtcs = BIT(drm->mode_config.num_crtc);
1423 + unsigned long flags = DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_180 |
1424 + DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;
1425 + u32 *formats;
1426 +diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
1427 +index a6e8f4591e63..1ea2a1b0fe37 100644
1428 +--- a/drivers/gpu/drm/bridge/sil-sii8620.c
1429 ++++ b/drivers/gpu/drm/bridge/sil-sii8620.c
1430 +@@ -180,7 +180,7 @@ static void sii8620_read_buf(struct sii8620 *ctx, u16 addr, u8 *buf, int len)
1431 +
1432 + static u8 sii8620_readb(struct sii8620 *ctx, u16 addr)
1433 + {
1434 +- u8 ret;
1435 ++ u8 ret = 0;
1436 +
1437 + sii8620_read_buf(ctx, addr, &ret, 1);
1438 + return ret;
1439 +diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
1440 +index 373bd4c2b698..84b7b22a9590 100644
1441 +--- a/drivers/gpu/drm/drm_debugfs.c
1442 ++++ b/drivers/gpu/drm/drm_debugfs.c
1443 +@@ -265,13 +265,13 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
1444 +
1445 + buf[len] = '\0';
1446 +
1447 +- if (!strcmp(buf, "on"))
1448 ++ if (sysfs_streq(buf, "on"))
1449 + connector->force = DRM_FORCE_ON;
1450 +- else if (!strcmp(buf, "digital"))
1451 ++ else if (sysfs_streq(buf, "digital"))
1452 + connector->force = DRM_FORCE_ON_DIGITAL;
1453 +- else if (!strcmp(buf, "off"))
1454 ++ else if (sysfs_streq(buf, "off"))
1455 + connector->force = DRM_FORCE_OFF;
1456 +- else if (!strcmp(buf, "unspecified"))
1457 ++ else if (sysfs_streq(buf, "unspecified"))
1458 + connector->force = DRM_FORCE_UNSPECIFIED;
1459 + else
1460 + return -EINVAL;
1461 +diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
1462 +index 80b75501f5c6..7ed8e510565e 100644
1463 +--- a/drivers/gpu/drm/drm_mipi_dsi.c
1464 ++++ b/drivers/gpu/drm/drm_mipi_dsi.c
1465 +@@ -1034,11 +1034,11 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);
1466 + */
1467 + int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline)
1468 + {
1469 +- u8 payload[3] = { MIPI_DCS_SET_TEAR_SCANLINE, scanline >> 8,
1470 +- scanline & 0xff };
1471 ++ u8 payload[2] = { scanline >> 8, scanline & 0xff };
1472 + ssize_t err;
1473 +
1474 +- err = mipi_dsi_generic_write(dsi, payload, sizeof(payload));
1475 ++ err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_SCANLINE, payload,
1476 ++ sizeof(payload));
1477 + if (err < 0)
1478 + return err;
1479 +
1480 +diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
1481 +index 6a859e077ea0..37ae15dc4fc6 100644
1482 +--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
1483 ++++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
1484 +@@ -694,7 +694,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
1485 + ret = pm_runtime_get_sync(gpu->dev);
1486 + if (ret < 0) {
1487 + dev_err(gpu->dev, "Failed to enable GPU power domain\n");
1488 +- return ret;
1489 ++ goto pm_put;
1490 + }
1491 +
1492 + etnaviv_hw_identify(gpu);
1493 +@@ -808,6 +808,7 @@ destroy_iommu:
1494 + gpu->mmu = NULL;
1495 + fail:
1496 + pm_runtime_mark_last_busy(gpu->dev);
1497 ++pm_put:
1498 + pm_runtime_put_autosuspend(gpu->dev);
1499 +
1500 + return ret;
1501 +@@ -848,7 +849,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
1502 +
1503 + ret = pm_runtime_get_sync(gpu->dev);
1504 + if (ret < 0)
1505 +- return ret;
1506 ++ goto pm_put;
1507 +
1508 + dma_lo = gpu_read(gpu, VIVS_FE_DMA_LOW);
1509 + dma_hi = gpu_read(gpu, VIVS_FE_DMA_HIGH);
1510 +@@ -971,6 +972,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
1511 + ret = 0;
1512 +
1513 + pm_runtime_mark_last_busy(gpu->dev);
1514 ++pm_put:
1515 + pm_runtime_put_autosuspend(gpu->dev);
1516 +
1517 + return ret;
1518 +@@ -985,7 +987,7 @@ void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
1519 + dev_err(gpu->dev, "recover hung GPU!\n");
1520 +
1521 + if (pm_runtime_get_sync(gpu->dev) < 0)
1522 +- return;
1523 ++ goto pm_put;
1524 +
1525 + mutex_lock(&gpu->lock);
1526 +
1527 +@@ -1005,6 +1007,7 @@ void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
1528 +
1529 + mutex_unlock(&gpu->lock);
1530 + pm_runtime_mark_last_busy(gpu->dev);
1531 ++pm_put:
1532 + pm_runtime_put_autosuspend(gpu->dev);
1533 + }
1534 +
1535 +@@ -1278,8 +1281,10 @@ struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit)
1536 +
1537 + if (!submit->runtime_resumed) {
1538 + ret = pm_runtime_get_sync(gpu->dev);
1539 +- if (ret < 0)
1540 ++ if (ret < 0) {
1541 ++ pm_runtime_put_noidle(gpu->dev);
1542 + return NULL;
1543 ++ }
1544 + submit->runtime_resumed = true;
1545 + }
1546 +
1547 +@@ -1296,6 +1301,7 @@ struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit)
1548 + ret = event_alloc(gpu, nr_events, event);
1549 + if (ret) {
1550 + DRM_ERROR("no free events\n");
1551 ++ pm_runtime_put_noidle(gpu->dev);
1552 + return NULL;
1553 + }
1554 +
1555 +@@ -1459,7 +1465,7 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu)
1556 + if (gpu->clk_bus) {
1557 + ret = clk_prepare_enable(gpu->clk_bus);
1558 + if (ret)
1559 +- return ret;
1560 ++ goto disable_clk_reg;
1561 + }
1562 +
1563 + if (gpu->clk_core) {
1564 +@@ -1482,6 +1488,9 @@ disable_clk_core:
1565 + disable_clk_bus:
1566 + if (gpu->clk_bus)
1567 + clk_disable_unprepare(gpu->clk_bus);
1568 ++disable_clk_reg:
1569 ++ if (gpu->clk_reg)
1570 ++ clk_disable_unprepare(gpu->clk_reg);
1571 +
1572 + return ret;
1573 + }
1574 +diff --git a/drivers/gpu/drm/imx/imx-tve.c b/drivers/gpu/drm/imx/imx-tve.c
1575 +index cffd3310240e..c19c1dfbfcdc 100644
1576 +--- a/drivers/gpu/drm/imx/imx-tve.c
1577 ++++ b/drivers/gpu/drm/imx/imx-tve.c
1578 +@@ -498,6 +498,13 @@ static int imx_tve_register(struct drm_device *drm, struct imx_tve *tve)
1579 + return 0;
1580 + }
1581 +
1582 ++static void imx_tve_disable_regulator(void *data)
1583 ++{
1584 ++ struct imx_tve *tve = data;
1585 ++
1586 ++ regulator_disable(tve->dac_reg);
1587 ++}
1588 ++
1589 + static bool imx_tve_readable_reg(struct device *dev, unsigned int reg)
1590 + {
1591 + return (reg % 4 == 0) && (reg <= 0xdc);
1592 +@@ -622,6 +629,9 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data)
1593 + ret = regulator_enable(tve->dac_reg);
1594 + if (ret)
1595 + return ret;
1596 ++ ret = devm_add_action_or_reset(dev, imx_tve_disable_regulator, tve);
1597 ++ if (ret)
1598 ++ return ret;
1599 + }
1600 +
1601 + tve->clk = devm_clk_get(dev, "tve");
1602 +@@ -668,18 +678,8 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data)
1603 + return 0;
1604 + }
1605 +
1606 +-static void imx_tve_unbind(struct device *dev, struct device *master,
1607 +- void *data)
1608 +-{
1609 +- struct imx_tve *tve = dev_get_drvdata(dev);
1610 +-
1611 +- if (!IS_ERR(tve->dac_reg))
1612 +- regulator_disable(tve->dac_reg);
1613 +-}
1614 +-
1615 + static const struct component_ops imx_tve_ops = {
1616 + .bind = imx_tve_bind,
1617 +- .unbind = imx_tve_unbind,
1618 + };
1619 +
1620 + static int imx_tve_probe(struct platform_device *pdev)
1621 +diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
1622 +index 4752f08f0884..3c3b7f7013e8 100644
1623 +--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
1624 ++++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
1625 +@@ -659,7 +659,7 @@ static void dpu_crtc_frame_event_cb(void *data, u32 event)
1626 + spin_unlock_irqrestore(&dpu_crtc->spin_lock, flags);
1627 +
1628 + if (!fevent) {
1629 +- DRM_ERROR("crtc%d event %d overflow\n", crtc->base.id, event);
1630 ++ DRM_ERROR_RATELIMITED("crtc%d event %d overflow\n", crtc->base.id, event);
1631 + return;
1632 + }
1633 +
1634 +diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
1635 +index 2b7a54cc3c9e..81999bed1e4a 100644
1636 +--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
1637 ++++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
1638 +@@ -899,8 +899,10 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
1639 +
1640 + /* need to bring up power immediately if opening device */
1641 + ret = pm_runtime_get_sync(dev->dev);
1642 +- if (ret < 0 && ret != -EACCES)
1643 ++ if (ret < 0 && ret != -EACCES) {
1644 ++ pm_runtime_put_autosuspend(dev->dev);
1645 + return ret;
1646 ++ }
1647 +
1648 + get_task_comm(tmpname, current);
1649 + snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid));
1650 +@@ -980,8 +982,10 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1651 + long ret;
1652 +
1653 + ret = pm_runtime_get_sync(dev->dev);
1654 +- if (ret < 0 && ret != -EACCES)
1655 ++ if (ret < 0 && ret != -EACCES) {
1656 ++ pm_runtime_put_autosuspend(dev->dev);
1657 + return ret;
1658 ++ }
1659 +
1660 + switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
1661 + case DRM_NOUVEAU_NVIF:
1662 +diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
1663 +index b56524d343c3..791f970714ed 100644
1664 +--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
1665 ++++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
1666 +@@ -46,8 +46,10 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
1667 + int ret;
1668 +
1669 + ret = pm_runtime_get_sync(dev);
1670 +- if (WARN_ON(ret < 0 && ret != -EACCES))
1671 ++ if (WARN_ON(ret < 0 && ret != -EACCES)) {
1672 ++ pm_runtime_put_autosuspend(dev);
1673 + return;
1674 ++ }
1675 +
1676 + if (gem->import_attach)
1677 + drm_prime_gem_destroy(gem, nvbo->bo.sg);
1678 +diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
1679 +index 8ebdc74cc0ad..326948b65542 100644
1680 +--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
1681 ++++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
1682 +@@ -96,12 +96,9 @@ nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags)
1683 + else
1684 + nvbe->ttm.ttm.func = &nv50_sgdma_backend;
1685 +
1686 +- if (ttm_dma_tt_init(&nvbe->ttm, bo, page_flags))
1687 +- /*
1688 +- * A failing ttm_dma_tt_init() will call ttm_tt_destroy()
1689 +- * and thus our nouveau_sgdma_destroy() hook, so we don't need
1690 +- * to free nvbe here.
1691 +- */
1692 ++ if (ttm_dma_tt_init(&nvbe->ttm, bo, page_flags)) {
1693 ++ kfree(nvbe);
1694 + return NULL;
1695 ++ }
1696 + return &nvbe->ttm.ttm;
1697 + }
1698 +diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
1699 +index 654fea2b4312..8814aa38c5e7 100644
1700 +--- a/drivers/gpu/drm/panel/panel-simple.c
1701 ++++ b/drivers/gpu/drm/panel/panel-simple.c
1702 +@@ -1503,7 +1503,7 @@ static const struct drm_display_mode lg_lb070wv8_mode = {
1703 + static const struct panel_desc lg_lb070wv8 = {
1704 + .modes = &lg_lb070wv8_mode,
1705 + .num_modes = 1,
1706 +- .bpc = 16,
1707 ++ .bpc = 8,
1708 + .size = {
1709 + .width = 151,
1710 + .height = 91,
1711 +diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
1712 +index 9e7d5e44a12f..90c1afe498be 100644
1713 +--- a/drivers/gpu/drm/radeon/ci_dpm.c
1714 ++++ b/drivers/gpu/drm/radeon/ci_dpm.c
1715 +@@ -4364,7 +4364,7 @@ static int ci_set_mc_special_registers(struct radeon_device *rdev,
1716 + table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
1717 + }
1718 + j++;
1719 +- if (j > SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
1720 ++ if (j >= SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
1721 + return -EINVAL;
1722 +
1723 + if (!pi->mem_gddr5) {
1724 +diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
1725 +index 7d1e14f0140a..3f0f3a578ddf 100644
1726 +--- a/drivers/gpu/drm/radeon/radeon_display.c
1727 ++++ b/drivers/gpu/drm/radeon/radeon_display.c
1728 +@@ -625,8 +625,10 @@ radeon_crtc_set_config(struct drm_mode_set *set,
1729 + dev = set->crtc->dev;
1730 +
1731 + ret = pm_runtime_get_sync(dev->dev);
1732 +- if (ret < 0)
1733 ++ if (ret < 0) {
1734 ++ pm_runtime_put_autosuspend(dev->dev);
1735 + return ret;
1736 ++ }
1737 +
1738 + ret = drm_crtc_helper_set_config(set, ctx);
1739 +
1740 +diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
1741 +index c26f09b47ecb..0cd33289c2b6 100644
1742 +--- a/drivers/gpu/drm/radeon/radeon_drv.c
1743 ++++ b/drivers/gpu/drm/radeon/radeon_drv.c
1744 +@@ -168,12 +168,7 @@ int radeon_no_wb;
1745 + int radeon_modeset = -1;
1746 + int radeon_dynclks = -1;
1747 + int radeon_r4xx_atom = 0;
1748 +-#ifdef __powerpc__
1749 +-/* Default to PCI on PowerPC (fdo #95017) */
1750 + int radeon_agpmode = -1;
1751 +-#else
1752 +-int radeon_agpmode = 0;
1753 +-#endif
1754 + int radeon_vram_limit = 0;
1755 + int radeon_gart_size = -1; /* auto */
1756 + int radeon_benchmarking = 0;
1757 +@@ -523,8 +518,10 @@ long radeon_drm_ioctl(struct file *filp,
1758 + long ret;
1759 + dev = file_priv->minor->dev;
1760 + ret = pm_runtime_get_sync(dev->dev);
1761 +- if (ret < 0)
1762 ++ if (ret < 0) {
1763 ++ pm_runtime_put_autosuspend(dev->dev);
1764 + return ret;
1765 ++ }
1766 +
1767 + ret = drm_ioctl(filp, cmd, arg);
1768 +
1769 +diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
1770 +index 3ff835767ac5..34b3cb6c146f 100644
1771 +--- a/drivers/gpu/drm/radeon/radeon_kms.c
1772 ++++ b/drivers/gpu/drm/radeon/radeon_kms.c
1773 +@@ -627,8 +627,10 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
1774 + file_priv->driver_priv = NULL;
1775 +
1776 + r = pm_runtime_get_sync(dev->dev);
1777 +- if (r < 0)
1778 ++ if (r < 0) {
1779 ++ pm_runtime_put_autosuspend(dev->dev);
1780 + return r;
1781 ++ }
1782 +
1783 + /* new gpu have virtual address space support */
1784 + if (rdev->family >= CHIP_CAYMAN) {
1785 +diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
1786 +index a1acab39d87f..096a33f12c61 100644
1787 +--- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
1788 ++++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
1789 +@@ -150,12 +150,16 @@ static int panel_connector_get_modes(struct drm_connector *connector)
1790 + int i;
1791 +
1792 + for (i = 0; i < timings->num_timings; i++) {
1793 +- struct drm_display_mode *mode = drm_mode_create(dev);
1794 ++ struct drm_display_mode *mode;
1795 + struct videomode vm;
1796 +
1797 + if (videomode_from_timings(timings, &vm, i))
1798 + break;
1799 +
1800 ++ mode = drm_mode_create(dev);
1801 ++ if (!mode)
1802 ++ break;
1803 ++
1804 + drm_display_mode_from_videomode(&vm, mode);
1805 +
1806 + mode->type = DRM_MODE_TYPE_DRIVER;
1807 +diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
1808 +index e3a0691582ff..68cfa25674e5 100644
1809 +--- a/drivers/gpu/drm/ttm/ttm_tt.c
1810 ++++ b/drivers/gpu/drm/ttm/ttm_tt.c
1811 +@@ -241,7 +241,6 @@ int ttm_tt_init(struct ttm_tt *ttm, struct ttm_buffer_object *bo,
1812 + ttm_tt_init_fields(ttm, bo, page_flags);
1813 +
1814 + if (ttm_tt_alloc_page_directory(ttm)) {
1815 +- ttm_tt_destroy(ttm);
1816 + pr_err("Failed allocating page table\n");
1817 + return -ENOMEM;
1818 + }
1819 +@@ -265,7 +264,6 @@ int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo,
1820 +
1821 + INIT_LIST_HEAD(&ttm_dma->pages_list);
1822 + if (ttm_dma_tt_alloc_page_directory(ttm_dma)) {
1823 +- ttm_tt_destroy(ttm);
1824 + pr_err("Failed allocating page table\n");
1825 + return -ENOMEM;
1826 + }
1827 +@@ -287,7 +285,6 @@ int ttm_sg_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo,
1828 + else
1829 + ret = ttm_dma_tt_alloc_page_directory(ttm_dma);
1830 + if (ret) {
1831 +- ttm_tt_destroy(ttm);
1832 + pr_err("Failed allocating page table\n");
1833 + return -ENOMEM;
1834 + }
1835 +diff --git a/drivers/gpu/host1x/debug.c b/drivers/gpu/host1x/debug.c
1836 +index 329e4a3d8ae7..6c9ad4533999 100644
1837 +--- a/drivers/gpu/host1x/debug.c
1838 ++++ b/drivers/gpu/host1x/debug.c
1839 +@@ -25,6 +25,8 @@
1840 + #include "debug.h"
1841 + #include "channel.h"
1842 +
1843 ++static DEFINE_MUTEX(debug_lock);
1844 ++
1845 + unsigned int host1x_debug_trace_cmdbuf;
1846 +
1847 + static pid_t host1x_debug_force_timeout_pid;
1848 +@@ -61,12 +63,14 @@ static int show_channel(struct host1x_channel *ch, void *data, bool show_fifo)
1849 + struct output *o = data;
1850 +
1851 + mutex_lock(&ch->cdma.lock);
1852 ++ mutex_lock(&debug_lock);
1853 +
1854 + if (show_fifo)
1855 + host1x_hw_show_channel_fifo(m, ch, o);
1856 +
1857 + host1x_hw_show_channel_cdma(m, ch, o);
1858 +
1859 ++ mutex_unlock(&debug_lock);
1860 + mutex_unlock(&ch->cdma.lock);
1861 +
1862 + return 0;
1863 +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
1864 +index dbb0cbe65fc9..51bfe23d00bc 100644
1865 +--- a/drivers/hid/hid-input.c
1866 ++++ b/drivers/hid/hid-input.c
1867 +@@ -362,13 +362,13 @@ static int hidinput_query_battery_capacity(struct hid_device *dev)
1868 + u8 *buf;
1869 + int ret;
1870 +
1871 +- buf = kmalloc(2, GFP_KERNEL);
1872 ++ buf = kmalloc(4, GFP_KERNEL);
1873 + if (!buf)
1874 + return -ENOMEM;
1875 +
1876 +- ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 2,
1877 ++ ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 4,
1878 + dev->battery_report_type, HID_REQ_GET_REPORT);
1879 +- if (ret != 2) {
1880 ++ if (ret < 2) {
1881 + kfree(buf);
1882 + return -ENODATA;
1883 + }
1884 +diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
1885 +index e90af39283b1..29dc2eac5b06 100644
1886 +--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
1887 ++++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
1888 +@@ -583,15 +583,14 @@ int tmc_read_unprepare_etb(struct tmc_drvdata *drvdata)
1889 +
1890 + spin_lock_irqsave(&drvdata->spinlock, flags);
1891 +
1892 +- /* There is no point in reading a TMC in HW FIFO mode */
1893 +- mode = readl_relaxed(drvdata->base + TMC_MODE);
1894 +- if (mode != TMC_MODE_CIRCULAR_BUFFER) {
1895 +- spin_unlock_irqrestore(&drvdata->spinlock, flags);
1896 +- return -EINVAL;
1897 +- }
1898 +-
1899 + /* Re-enable the TMC if need be */
1900 + if (drvdata->mode == CS_MODE_SYSFS) {
1901 ++ /* There is no point in reading a TMC in HW FIFO mode */
1902 ++ mode = readl_relaxed(drvdata->base + TMC_MODE);
1903 ++ if (mode != TMC_MODE_CIRCULAR_BUFFER) {
1904 ++ spin_unlock_irqrestore(&drvdata->spinlock, flags);
1905 ++ return -EINVAL;
1906 ++ }
1907 + /*
1908 + * The trace run will continue with the same allocated trace
1909 + * buffer. As such zero-out the buffer so that we don't end
1910 +diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
1911 +index 82f309fb3ce5..e8432876cc86 100644
1912 +--- a/drivers/infiniband/core/verbs.c
1913 ++++ b/drivers/infiniband/core/verbs.c
1914 +@@ -1617,7 +1617,7 @@ static int _ib_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr,
1915 + if (!(rdma_protocol_ib(qp->device,
1916 + attr->alt_ah_attr.port_num) &&
1917 + rdma_protocol_ib(qp->device, port))) {
1918 +- ret = EINVAL;
1919 ++ ret = -EINVAL;
1920 + goto out;
1921 + }
1922 + }
1923 +diff --git a/drivers/infiniband/hw/qedr/qedr.h b/drivers/infiniband/hw/qedr/qedr.h
1924 +index a2d708dceb8d..cca12100c583 100644
1925 +--- a/drivers/infiniband/hw/qedr/qedr.h
1926 ++++ b/drivers/infiniband/hw/qedr/qedr.h
1927 +@@ -351,10 +351,10 @@ struct qedr_srq_hwq_info {
1928 + u32 wqe_prod;
1929 + u32 sge_prod;
1930 + u32 wr_prod_cnt;
1931 +- u32 wr_cons_cnt;
1932 ++ atomic_t wr_cons_cnt;
1933 + u32 num_elems;
1934 +
1935 +- u32 *virt_prod_pair_addr;
1936 ++ struct rdma_srq_producers *virt_prod_pair_addr;
1937 + dma_addr_t phy_prod_pair_addr;
1938 + };
1939 +
1940 +diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
1941 +index 38fe2f741375..7b26afc7fef3 100644
1942 +--- a/drivers/infiniband/hw/qedr/verbs.c
1943 ++++ b/drivers/infiniband/hw/qedr/verbs.c
1944 +@@ -3577,7 +3577,7 @@ static u32 qedr_srq_elem_left(struct qedr_srq_hwq_info *hw_srq)
1945 + * count and consumer count and subtract it from max
1946 + * work request supported so that we get elements left.
1947 + */
1948 +- used = hw_srq->wr_prod_cnt - hw_srq->wr_cons_cnt;
1949 ++ used = hw_srq->wr_prod_cnt - (u32)atomic_read(&hw_srq->wr_cons_cnt);
1950 +
1951 + return hw_srq->max_wr - used;
1952 + }
1953 +@@ -3592,7 +3592,6 @@ int qedr_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
1954 + unsigned long flags;
1955 + int status = 0;
1956 + u32 num_sge;
1957 +- u32 offset;
1958 +
1959 + spin_lock_irqsave(&srq->lock, flags);
1960 +
1961 +@@ -3605,7 +3604,8 @@ int qedr_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
1962 + if (!qedr_srq_elem_left(hw_srq) ||
1963 + wr->num_sge > srq->hw_srq.max_sges) {
1964 + DP_ERR(dev, "Can't post WR (%d,%d) || (%d > %d)\n",
1965 +- hw_srq->wr_prod_cnt, hw_srq->wr_cons_cnt,
1966 ++ hw_srq->wr_prod_cnt,
1967 ++ atomic_read(&hw_srq->wr_cons_cnt),
1968 + wr->num_sge, srq->hw_srq.max_sges);
1969 + status = -ENOMEM;
1970 + *bad_wr = wr;
1971 +@@ -3639,22 +3639,20 @@ int qedr_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
1972 + hw_srq->sge_prod++;
1973 + }
1974 +
1975 +- /* Flush WQE and SGE information before
1976 ++ /* Update WQE and SGE information before
1977 + * updating producer.
1978 + */
1979 +- wmb();
1980 ++ dma_wmb();
1981 +
1982 + /* SRQ producer is 8 bytes. Need to update SGE producer index
1983 + * in first 4 bytes and need to update WQE producer in
1984 + * next 4 bytes.
1985 + */
1986 +- *srq->hw_srq.virt_prod_pair_addr = hw_srq->sge_prod;
1987 +- offset = offsetof(struct rdma_srq_producers, wqe_prod);
1988 +- *((u8 *)srq->hw_srq.virt_prod_pair_addr + offset) =
1989 +- hw_srq->wqe_prod;
1990 ++ srq->hw_srq.virt_prod_pair_addr->sge_prod = hw_srq->sge_prod;
1991 ++ /* Make sure sge producer is updated first */
1992 ++ dma_wmb();
1993 ++ srq->hw_srq.virt_prod_pair_addr->wqe_prod = hw_srq->wqe_prod;
1994 +
1995 +- /* Flush producer after updating it. */
1996 +- wmb();
1997 + wr = wr->next;
1998 + }
1999 +
2000 +@@ -4077,7 +4075,7 @@ static int process_resp_one_srq(struct qedr_dev *dev, struct qedr_qp *qp,
2001 + } else {
2002 + __process_resp_one(dev, qp, cq, wc, resp, wr_id);
2003 + }
2004 +- srq->hw_srq.wr_cons_cnt++;
2005 ++ atomic_inc(&srq->hw_srq.wr_cons_cnt);
2006 +
2007 + return 1;
2008 + }
2009 +diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c
2010 +index 695a607e2d14..b8f3e65402d1 100644
2011 +--- a/drivers/infiniband/sw/rxe/rxe_recv.c
2012 ++++ b/drivers/infiniband/sw/rxe/rxe_recv.c
2013 +@@ -332,10 +332,14 @@ err1:
2014 +
2015 + static int rxe_match_dgid(struct rxe_dev *rxe, struct sk_buff *skb)
2016 + {
2017 ++ struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
2018 + const struct ib_gid_attr *gid_attr;
2019 + union ib_gid dgid;
2020 + union ib_gid *pdgid;
2021 +
2022 ++ if (pkt->mask & RXE_LOOPBACK_MASK)
2023 ++ return 0;
2024 ++
2025 + if (skb->protocol == htons(ETH_P_IP)) {
2026 + ipv6_addr_set_v4mapped(ip_hdr(skb)->daddr,
2027 + (struct in6_addr *)&dgid);
2028 +@@ -368,7 +372,7 @@ void rxe_rcv(struct sk_buff *skb)
2029 + if (unlikely(skb->len < pkt->offset + RXE_BTH_BYTES))
2030 + goto drop;
2031 +
2032 +- if (unlikely(rxe_match_dgid(rxe, skb) < 0)) {
2033 ++ if (rxe_match_dgid(rxe, skb) < 0) {
2034 + pr_warn_ratelimited("failed matching dgid\n");
2035 + goto drop;
2036 + }
2037 +diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
2038 +index f5b1e0ad6142..3a94eb5edcf9 100644
2039 +--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
2040 ++++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
2041 +@@ -733,6 +733,7 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr,
2042 + unsigned int mask;
2043 + unsigned int length = 0;
2044 + int i;
2045 ++ struct ib_send_wr *next;
2046 +
2047 + while (wr) {
2048 + mask = wr_opcode_mask(wr->opcode, qp);
2049 +@@ -749,6 +750,8 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr,
2050 + break;
2051 + }
2052 +
2053 ++ next = wr->next;
2054 ++
2055 + length = 0;
2056 + for (i = 0; i < wr->num_sge; i++)
2057 + length += wr->sg_list[i].length;
2058 +@@ -759,7 +762,7 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr,
2059 + *bad_wr = wr;
2060 + break;
2061 + }
2062 +- wr = wr->next;
2063 ++ wr = next;
2064 + }
2065 +
2066 + rxe_run_task(&qp->req.task, 1);
2067 +diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
2068 +index 852e2841395b..15a4ad31c510 100644
2069 +--- a/drivers/iommu/intel_irq_remapping.c
2070 ++++ b/drivers/iommu/intel_irq_remapping.c
2071 +@@ -601,13 +601,21 @@ out_free_table:
2072 +
2073 + static void intel_teardown_irq_remapping(struct intel_iommu *iommu)
2074 + {
2075 ++ struct fwnode_handle *fn;
2076 ++
2077 + if (iommu && iommu->ir_table) {
2078 + if (iommu->ir_msi_domain) {
2079 ++ fn = iommu->ir_msi_domain->fwnode;
2080 ++
2081 + irq_domain_remove(iommu->ir_msi_domain);
2082 ++ irq_domain_free_fwnode(fn);
2083 + iommu->ir_msi_domain = NULL;
2084 + }
2085 + if (iommu->ir_domain) {
2086 ++ fn = iommu->ir_domain->fwnode;
2087 ++
2088 + irq_domain_remove(iommu->ir_domain);
2089 ++ irq_domain_free_fwnode(fn);
2090 + iommu->ir_domain = NULL;
2091 + }
2092 + free_pages((unsigned long)iommu->ir_table->base,
2093 +diff --git a/drivers/irqchip/irq-mtk-sysirq.c b/drivers/irqchip/irq-mtk-sysirq.c
2094 +index 90aaf190157f..42455f31b061 100644
2095 +--- a/drivers/irqchip/irq-mtk-sysirq.c
2096 ++++ b/drivers/irqchip/irq-mtk-sysirq.c
2097 +@@ -23,7 +23,7 @@
2098 + #include <linux/spinlock.h>
2099 +
2100 + struct mtk_sysirq_chip_data {
2101 +- spinlock_t lock;
2102 ++ raw_spinlock_t lock;
2103 + u32 nr_intpol_bases;
2104 + void __iomem **intpol_bases;
2105 + u32 *intpol_words;
2106 +@@ -45,7 +45,7 @@ static int mtk_sysirq_set_type(struct irq_data *data, unsigned int type)
2107 + reg_index = chip_data->which_word[hwirq];
2108 + offset = hwirq & 0x1f;
2109 +
2110 +- spin_lock_irqsave(&chip_data->lock, flags);
2111 ++ raw_spin_lock_irqsave(&chip_data->lock, flags);
2112 + value = readl_relaxed(base + reg_index * 4);
2113 + if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_EDGE_FALLING) {
2114 + if (type == IRQ_TYPE_LEVEL_LOW)
2115 +@@ -61,7 +61,7 @@ static int mtk_sysirq_set_type(struct irq_data *data, unsigned int type)
2116 +
2117 + data = data->parent_data;
2118 + ret = data->chip->irq_set_type(data, type);
2119 +- spin_unlock_irqrestore(&chip_data->lock, flags);
2120 ++ raw_spin_unlock_irqrestore(&chip_data->lock, flags);
2121 + return ret;
2122 + }
2123 +
2124 +@@ -220,7 +220,7 @@ static int __init mtk_sysirq_of_init(struct device_node *node,
2125 + ret = -ENOMEM;
2126 + goto out_free_which_word;
2127 + }
2128 +- spin_lock_init(&chip_data->lock);
2129 ++ raw_spin_lock_init(&chip_data->lock);
2130 +
2131 + return 0;
2132 +
2133 +diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
2134 +index 3c7e3487b373..4e63dd2bfcf8 100644
2135 +--- a/drivers/leds/led-class.c
2136 ++++ b/drivers/leds/led-class.c
2137 +@@ -173,6 +173,7 @@ void led_classdev_suspend(struct led_classdev *led_cdev)
2138 + {
2139 + led_cdev->flags |= LED_SUSPENDED;
2140 + led_set_brightness_nopm(led_cdev, 0);
2141 ++ flush_work(&led_cdev->set_brightness_work);
2142 + }
2143 + EXPORT_SYMBOL_GPL(led_classdev_suspend);
2144 +
2145 +diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c
2146 +index 6cb94f9a2f3f..b9c60dd2b132 100644
2147 +--- a/drivers/leds/leds-lm355x.c
2148 ++++ b/drivers/leds/leds-lm355x.c
2149 +@@ -168,18 +168,19 @@ static int lm355x_chip_init(struct lm355x_chip_data *chip)
2150 + /* input and output pins configuration */
2151 + switch (chip->type) {
2152 + case CHIP_LM3554:
2153 +- reg_val = pdata->pin_tx2 | pdata->ntc_pin;
2154 ++ reg_val = (u32)pdata->pin_tx2 | (u32)pdata->ntc_pin;
2155 + ret = regmap_update_bits(chip->regmap, 0xE0, 0x28, reg_val);
2156 + if (ret < 0)
2157 + goto out;
2158 +- reg_val = pdata->pass_mode;
2159 ++ reg_val = (u32)pdata->pass_mode;
2160 + ret = regmap_update_bits(chip->regmap, 0xA0, 0x04, reg_val);
2161 + if (ret < 0)
2162 + goto out;
2163 + break;
2164 +
2165 + case CHIP_LM3556:
2166 +- reg_val = pdata->pin_tx2 | pdata->ntc_pin | pdata->pass_mode;
2167 ++ reg_val = (u32)pdata->pin_tx2 | (u32)pdata->ntc_pin |
2168 ++ (u32)pdata->pass_mode;
2169 + ret = regmap_update_bits(chip->regmap, 0x0A, 0xC4, reg_val);
2170 + if (ret < 0)
2171 + goto out;
2172 +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
2173 +index 68ebc2759c2e..46ad0bf18e1f 100644
2174 +--- a/drivers/md/bcache/super.c
2175 ++++ b/drivers/md/bcache/super.c
2176 +@@ -2013,7 +2013,14 @@ found:
2177 + sysfs_create_link(&c->kobj, &ca->kobj, buf))
2178 + goto err;
2179 +
2180 +- if (ca->sb.seq > c->sb.seq) {
2181 ++ /*
2182 ++ * A special case is both ca->sb.seq and c->sb.seq are 0,
2183 ++ * such condition happens on a new created cache device whose
2184 ++ * super block is never flushed yet. In this case c->sb.version
2185 ++ * and other members should be updated too, otherwise we will
2186 ++ * have a mistaken super block version in cache set.
2187 ++ */
2188 ++ if (ca->sb.seq > c->sb.seq || c->sb.seq == 0) {
2189 + c->sb.version = ca->sb.version;
2190 + memcpy(c->sb.set_uuid, ca->sb.set_uuid, 16);
2191 + c->sb.flags = ca->sb.flags;
2192 +diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
2193 +index 0b2af6e74fc3..4522e87d9d68 100644
2194 +--- a/drivers/md/md-cluster.c
2195 ++++ b/drivers/md/md-cluster.c
2196 +@@ -1443,6 +1443,7 @@ static void unlock_all_bitmaps(struct mddev *mddev)
2197 + }
2198 + }
2199 + kfree(cinfo->other_bitmap_lockres);
2200 ++ cinfo->other_bitmap_lockres = NULL;
2201 + }
2202 + }
2203 +
2204 +diff --git a/drivers/media/firewire/firedtv-fw.c b/drivers/media/firewire/firedtv-fw.c
2205 +index 92f4112d2e37..eaf94b817dbc 100644
2206 +--- a/drivers/media/firewire/firedtv-fw.c
2207 ++++ b/drivers/media/firewire/firedtv-fw.c
2208 +@@ -271,6 +271,8 @@ static int node_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
2209 +
2210 + name_len = fw_csr_string(unit->directory, CSR_MODEL,
2211 + name, sizeof(name));
2212 ++ if (name_len < 0)
2213 ++ return name_len;
2214 + for (i = ARRAY_SIZE(model_names); --i; )
2215 + if (strlen(model_names[i]) <= name_len &&
2216 + strncmp(name, model_names[i], name_len) == 0)
2217 +diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
2218 +index b5993532831d..2d25a197dc65 100644
2219 +--- a/drivers/media/platform/exynos4-is/media-dev.c
2220 ++++ b/drivers/media/platform/exynos4-is/media-dev.c
2221 +@@ -1259,6 +1259,9 @@ static int fimc_md_get_pinctrl(struct fimc_md *fmd)
2222 +
2223 + pctl->state_idle = pinctrl_lookup_state(pctl->pinctrl,
2224 + PINCTRL_STATE_IDLE);
2225 ++ if (IS_ERR(pctl->state_idle))
2226 ++ return PTR_ERR(pctl->state_idle);
2227 ++
2228 + return 0;
2229 + }
2230 +
2231 +diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c
2232 +index 591c6de498f8..20857ae42a77 100644
2233 +--- a/drivers/media/platform/omap3isp/isppreview.c
2234 ++++ b/drivers/media/platform/omap3isp/isppreview.c
2235 +@@ -2290,7 +2290,7 @@ static int preview_init_entities(struct isp_prev_device *prev)
2236 + me->ops = &preview_media_ops;
2237 + ret = media_entity_pads_init(me, PREV_PADS_NUM, pads);
2238 + if (ret < 0)
2239 +- return ret;
2240 ++ goto error_handler_free;
2241 +
2242 + preview_init_formats(sd, NULL);
2243 +
2244 +@@ -2323,6 +2323,8 @@ error_video_out:
2245 + omap3isp_video_cleanup(&prev->video_in);
2246 + error_video_in:
2247 + media_entity_cleanup(&prev->subdev.entity);
2248 ++error_handler_free:
2249 ++ v4l2_ctrl_handler_free(&prev->ctrls);
2250 + return ret;
2251 + }
2252 +
2253 +diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c
2254 +index 629e2e156412..0baa229d2b7d 100644
2255 +--- a/drivers/misc/cxl/sysfs.c
2256 ++++ b/drivers/misc/cxl/sysfs.c
2257 +@@ -628,7 +628,7 @@ static struct afu_config_record *cxl_sysfs_afu_new_cr(struct cxl_afu *afu, int c
2258 + rc = kobject_init_and_add(&cr->kobj, &afu_config_record_type,
2259 + &afu->dev.kobj, "cr%i", cr->cr);
2260 + if (rc)
2261 +- goto err;
2262 ++ goto err1;
2263 +
2264 + rc = sysfs_create_bin_file(&cr->kobj, &cr->config_attr);
2265 + if (rc)
2266 +diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
2267 +index 1f9d64aeb863..9fcbcf4b217b 100644
2268 +--- a/drivers/mtd/nand/raw/qcom_nandc.c
2269 ++++ b/drivers/mtd/nand/raw/qcom_nandc.c
2270 +@@ -466,11 +466,13 @@ struct qcom_nand_host {
2271 + * among different NAND controllers.
2272 + * @ecc_modes - ecc mode for NAND
2273 + * @is_bam - whether NAND controller is using BAM
2274 ++ * @is_qpic - whether NAND CTRL is part of qpic IP
2275 + * @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset
2276 + */
2277 + struct qcom_nandc_props {
2278 + u32 ecc_modes;
2279 + bool is_bam;
2280 ++ bool is_qpic;
2281 + u32 dev_cmd_reg_start;
2282 + };
2283 +
2284 +@@ -2766,7 +2768,8 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)
2285 + u32 nand_ctrl;
2286 +
2287 + /* kill onenand */
2288 +- nandc_write(nandc, SFLASHC_BURST_CFG, 0);
2289 ++ if (!nandc->props->is_qpic)
2290 ++ nandc_write(nandc, SFLASHC_BURST_CFG, 0);
2291 + nandc_write(nandc, dev_cmd_reg_addr(nandc, NAND_DEV_CMD_VLD),
2292 + NAND_DEV_CMD_VLD_VAL);
2293 +
2294 +@@ -3022,12 +3025,14 @@ static const struct qcom_nandc_props ipq806x_nandc_props = {
2295 + static const struct qcom_nandc_props ipq4019_nandc_props = {
2296 + .ecc_modes = (ECC_BCH_4BIT | ECC_BCH_8BIT),
2297 + .is_bam = true,
2298 ++ .is_qpic = true,
2299 + .dev_cmd_reg_start = 0x0,
2300 + };
2301 +
2302 + static const struct qcom_nandc_props ipq8074_nandc_props = {
2303 + .ecc_modes = (ECC_BCH_4BIT | ECC_BCH_8BIT),
2304 + .is_bam = true,
2305 ++ .is_qpic = true,
2306 + .dev_cmd_reg_start = 0x7000,
2307 + };
2308 +
2309 +diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
2310 +index 43b00e8bcdcd..6fa8aa69b418 100644
2311 +--- a/drivers/net/dsa/mv88e6xxx/chip.c
2312 ++++ b/drivers/net/dsa/mv88e6xxx/chip.c
2313 +@@ -2930,7 +2930,6 @@ static const struct mv88e6xxx_ops mv88e6097_ops = {
2314 + .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2315 + .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2316 + .port_set_ether_type = mv88e6351_port_set_ether_type,
2317 +- .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
2318 + .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
2319 + .port_pause_limit = mv88e6097_port_pause_limit,
2320 + .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2321 +diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c
2322 +index c281c488a306..7e27c9aff9b7 100644
2323 +--- a/drivers/net/dsa/rtl8366.c
2324 ++++ b/drivers/net/dsa/rtl8366.c
2325 +@@ -43,18 +43,26 @@ int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member,
2326 + int ret;
2327 + int i;
2328 +
2329 ++ dev_dbg(smi->dev,
2330 ++ "setting VLAN%d 4k members: 0x%02x, untagged: 0x%02x\n",
2331 ++ vid, member, untag);
2332 ++
2333 + /* Update the 4K table */
2334 + ret = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
2335 + if (ret)
2336 + return ret;
2337 +
2338 +- vlan4k.member = member;
2339 +- vlan4k.untag = untag;
2340 ++ vlan4k.member |= member;
2341 ++ vlan4k.untag |= untag;
2342 + vlan4k.fid = fid;
2343 + ret = smi->ops->set_vlan_4k(smi, &vlan4k);
2344 + if (ret)
2345 + return ret;
2346 +
2347 ++ dev_dbg(smi->dev,
2348 ++ "resulting VLAN%d 4k members: 0x%02x, untagged: 0x%02x\n",
2349 ++ vid, vlan4k.member, vlan4k.untag);
2350 ++
2351 + /* Try to find an existing MC entry for this VID */
2352 + for (i = 0; i < smi->num_vlan_mc; i++) {
2353 + struct rtl8366_vlan_mc vlanmc;
2354 +@@ -65,11 +73,16 @@ int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member,
2355 +
2356 + if (vid == vlanmc.vid) {
2357 + /* update the MC entry */
2358 +- vlanmc.member = member;
2359 +- vlanmc.untag = untag;
2360 ++ vlanmc.member |= member;
2361 ++ vlanmc.untag |= untag;
2362 + vlanmc.fid = fid;
2363 +
2364 + ret = smi->ops->set_vlan_mc(smi, i, &vlanmc);
2365 ++
2366 ++ dev_dbg(smi->dev,
2367 ++ "resulting VLAN%d MC members: 0x%02x, untagged: 0x%02x\n",
2368 ++ vid, vlanmc.member, vlanmc.untag);
2369 ++
2370 + break;
2371 + }
2372 + }
2373 +@@ -384,7 +397,7 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port,
2374 + if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
2375 + dev_err(smi->dev, "port is DSA or CPU port\n");
2376 +
2377 +- for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
2378 ++ for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
2379 + int pvid_val = 0;
2380 +
2381 + dev_info(smi->dev, "add VLAN %04x\n", vid);
2382 +@@ -407,13 +420,13 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port,
2383 + if (ret < 0)
2384 + return;
2385 + }
2386 +- }
2387 +
2388 +- ret = rtl8366_set_vlan(smi, port, member, untag, 0);
2389 +- if (ret)
2390 +- dev_err(smi->dev,
2391 +- "failed to set up VLAN %04x",
2392 +- vid);
2393 ++ ret = rtl8366_set_vlan(smi, vid, member, untag, 0);
2394 ++ if (ret)
2395 ++ dev_err(smi->dev,
2396 ++ "failed to set up VLAN %04x",
2397 ++ vid);
2398 ++ }
2399 + }
2400 + EXPORT_SYMBOL_GPL(rtl8366_vlan_add);
2401 +
2402 +diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
2403 +index dab5891b9714..d48595470ec8 100644
2404 +--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
2405 ++++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
2406 +@@ -774,7 +774,7 @@ static int hw_atl_a0_hw_multicast_list_set(struct aq_hw_s *self,
2407 + int err = 0;
2408 +
2409 + if (count > (HW_ATL_A0_MAC_MAX - HW_ATL_A0_MAC_MIN)) {
2410 +- err = EBADRQC;
2411 ++ err = -EBADRQC;
2412 + goto err_exit;
2413 + }
2414 + for (self->aq_nic_cfg->mc_list_count = 0U;
2415 +diff --git a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c
2416 +index 9f4f3c1d5043..55fe80ca10d3 100644
2417 +--- a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c
2418 ++++ b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c
2419 +@@ -1167,7 +1167,7 @@ static int cn23xx_get_pf_num(struct octeon_device *oct)
2420 + oct->pf_num = ((fdl_bit >> CN23XX_PCIE_SRIOV_FDL_BIT_POS) &
2421 + CN23XX_PCIE_SRIOV_FDL_MASK);
2422 + } else {
2423 +- ret = EINVAL;
2424 ++ ret = -EINVAL;
2425 +
2426 + /* Under some virtual environments, extended PCI regs are
2427 + * inaccessible, in which case the above read will have failed.
2428 +diff --git a/drivers/net/ethernet/freescale/fman/fman.c b/drivers/net/ethernet/freescale/fman/fman.c
2429 +index 21d8023535ae..eba7e54ecf85 100644
2430 +--- a/drivers/net/ethernet/freescale/fman/fman.c
2431 ++++ b/drivers/net/ethernet/freescale/fman/fman.c
2432 +@@ -1396,8 +1396,7 @@ static void enable_time_stamp(struct fman *fman)
2433 + {
2434 + struct fman_fpm_regs __iomem *fpm_rg = fman->fpm_regs;
2435 + u16 fm_clk_freq = fman->state->fm_clk_freq;
2436 +- u32 tmp, intgr, ts_freq;
2437 +- u64 frac;
2438 ++ u32 tmp, intgr, ts_freq, frac;
2439 +
2440 + ts_freq = (u32)(1 << fman->state->count1_micro_bit);
2441 + /* configure timestamp so that bit 8 will count 1 microsecond
2442 +diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
2443 +index 1ca543ac8f2c..d2de9ea80c43 100644
2444 +--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
2445 ++++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
2446 +@@ -1205,7 +1205,7 @@ int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)
2447 + list_for_each(pos,
2448 + &dtsec->multicast_addr_hash->lsts[bucket]) {
2449 + hash_entry = ETH_HASH_ENTRY_OBJ(pos);
2450 +- if (hash_entry->addr == addr) {
2451 ++ if (hash_entry && hash_entry->addr == addr) {
2452 + list_del_init(&hash_entry->node);
2453 + kfree(hash_entry);
2454 + break;
2455 +@@ -1218,7 +1218,7 @@ int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)
2456 + list_for_each(pos,
2457 + &dtsec->unicast_addr_hash->lsts[bucket]) {
2458 + hash_entry = ETH_HASH_ENTRY_OBJ(pos);
2459 +- if (hash_entry->addr == addr) {
2460 ++ if (hash_entry && hash_entry->addr == addr) {
2461 + list_del_init(&hash_entry->node);
2462 + kfree(hash_entry);
2463 + break;
2464 +diff --git a/drivers/net/ethernet/freescale/fman/fman_mac.h b/drivers/net/ethernet/freescale/fman/fman_mac.h
2465 +index dd6d0526f6c1..19f327efdaff 100644
2466 +--- a/drivers/net/ethernet/freescale/fman/fman_mac.h
2467 ++++ b/drivers/net/ethernet/freescale/fman/fman_mac.h
2468 +@@ -252,7 +252,7 @@ static inline struct eth_hash_t *alloc_hash_table(u16 size)
2469 + struct eth_hash_t *hash;
2470 +
2471 + /* Allocate address hash table */
2472 +- hash = kmalloc_array(size, sizeof(struct eth_hash_t *), GFP_KERNEL);
2473 ++ hash = kmalloc(sizeof(*hash), GFP_KERNEL);
2474 + if (!hash)
2475 + return NULL;
2476 +
2477 +diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c
2478 +index e1901874c19f..9088b4f4b4b8 100644
2479 +--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
2480 ++++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
2481 +@@ -856,7 +856,6 @@ int memac_set_tx_pause_frames(struct fman_mac *memac, u8 priority,
2482 +
2483 + tmp = ioread32be(&regs->command_config);
2484 + tmp &= ~CMD_CFG_PFC_MODE;
2485 +- priority = 0;
2486 +
2487 + iowrite32be(tmp, &regs->command_config);
2488 +
2489 +@@ -986,7 +985,7 @@ int memac_del_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr)
2490 +
2491 + list_for_each(pos, &memac->multicast_addr_hash->lsts[hash]) {
2492 + hash_entry = ETH_HASH_ENTRY_OBJ(pos);
2493 +- if (hash_entry->addr == addr) {
2494 ++ if (hash_entry && hash_entry->addr == addr) {
2495 + list_del_init(&hash_entry->node);
2496 + kfree(hash_entry);
2497 + break;
2498 +diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c b/drivers/net/ethernet/freescale/fman/fman_port.c
2499 +index ee82ee1384eb..47f6fee1f396 100644
2500 +--- a/drivers/net/ethernet/freescale/fman/fman_port.c
2501 ++++ b/drivers/net/ethernet/freescale/fman/fman_port.c
2502 +@@ -1756,6 +1756,7 @@ static int fman_port_probe(struct platform_device *of_dev)
2503 + struct fman_port *port;
2504 + struct fman *fman;
2505 + struct device_node *fm_node, *port_node;
2506 ++ struct platform_device *fm_pdev;
2507 + struct resource res;
2508 + struct resource *dev_res;
2509 + u32 val;
2510 +@@ -1780,8 +1781,14 @@ static int fman_port_probe(struct platform_device *of_dev)
2511 + goto return_err;
2512 + }
2513 +
2514 +- fman = dev_get_drvdata(&of_find_device_by_node(fm_node)->dev);
2515 ++ fm_pdev = of_find_device_by_node(fm_node);
2516 + of_node_put(fm_node);
2517 ++ if (!fm_pdev) {
2518 ++ err = -EINVAL;
2519 ++ goto return_err;
2520 ++ }
2521 ++
2522 ++ fman = dev_get_drvdata(&fm_pdev->dev);
2523 + if (!fman) {
2524 + err = -EINVAL;
2525 + goto return_err;
2526 +diff --git a/drivers/net/ethernet/freescale/fman/fman_tgec.c b/drivers/net/ethernet/freescale/fman/fman_tgec.c
2527 +index f75b9c11b2d2..ac5a281e0ec3 100644
2528 +--- a/drivers/net/ethernet/freescale/fman/fman_tgec.c
2529 ++++ b/drivers/net/ethernet/freescale/fman/fman_tgec.c
2530 +@@ -630,7 +630,7 @@ int tgec_del_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr)
2531 +
2532 + list_for_each(pos, &tgec->multicast_addr_hash->lsts[hash]) {
2533 + hash_entry = ETH_HASH_ENTRY_OBJ(pos);
2534 +- if (hash_entry->addr == addr) {
2535 ++ if (hash_entry && hash_entry->addr == addr) {
2536 + list_del_init(&hash_entry->node);
2537 + kfree(hash_entry);
2538 + break;
2539 +diff --git a/drivers/net/ethernet/toshiba/spider_net.c b/drivers/net/ethernet/toshiba/spider_net.c
2540 +index 23417266b7ec..e66014e0427f 100644
2541 +--- a/drivers/net/ethernet/toshiba/spider_net.c
2542 ++++ b/drivers/net/ethernet/toshiba/spider_net.c
2543 +@@ -296,8 +296,8 @@ spider_net_free_chain(struct spider_net_card *card,
2544 + descr = descr->next;
2545 + } while (descr != chain->ring);
2546 +
2547 +- dma_free_coherent(&card->pdev->dev, chain->num_desc,
2548 +- chain->hwring, chain->dma_addr);
2549 ++ dma_free_coherent(&card->pdev->dev, chain->num_desc * sizeof(struct spider_net_hw_descr),
2550 ++ chain->hwring, chain->dma_addr);
2551 + }
2552 +
2553 + /**
2554 +diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
2555 +index ac34257e9f20..c94dfa70f2a3 100644
2556 +--- a/drivers/net/wan/lapbether.c
2557 ++++ b/drivers/net/wan/lapbether.c
2558 +@@ -160,6 +160,12 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff *skb,
2559 + if (!netif_running(dev))
2560 + goto drop;
2561 +
2562 ++ /* There should be a pseudo header of 1 byte added by upper layers.
2563 ++ * Check to make sure it is there before reading it.
2564 ++ */
2565 ++ if (skb->len < 1)
2566 ++ goto drop;
2567 ++
2568 + switch (skb->data[0]) {
2569 + case X25_IFACE_DATA:
2570 + break;
2571 +@@ -308,6 +314,7 @@ static void lapbeth_setup(struct net_device *dev)
2572 + dev->netdev_ops = &lapbeth_netdev_ops;
2573 + dev->needs_free_netdev = true;
2574 + dev->type = ARPHRD_X25;
2575 ++ dev->hard_header_len = 0;
2576 + dev->mtu = 1000;
2577 + dev->addr_len = 0;
2578 + }
2579 +@@ -334,7 +341,8 @@ static int lapbeth_new_device(struct net_device *dev)
2580 + * then this driver prepends a length field of 2 bytes,
2581 + * then the underlying Ethernet device prepends its own header.
2582 + */
2583 +- ndev->hard_header_len = -1 + 3 + 2 + dev->hard_header_len;
2584 ++ ndev->needed_headroom = -1 + 3 + 2 + dev->hard_header_len
2585 ++ + dev->needed_headroom;
2586 +
2587 + lapbeth = netdev_priv(ndev);
2588 + lapbeth->axdev = ndev;
2589 +diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c
2590 +index 7cff0d52338f..fd011bdabb96 100644
2591 +--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
2592 ++++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
2593 +@@ -1329,7 +1329,9 @@ static int ath10k_htt_tx_32(struct ath10k_htt *htt,
2594 + err_unmap_msdu:
2595 + dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
2596 + err_free_msdu_id:
2597 ++ spin_lock_bh(&htt->tx_lock);
2598 + ath10k_htt_tx_free_msdu_id(htt, msdu_id);
2599 ++ spin_unlock_bh(&htt->tx_lock);
2600 + err:
2601 + return res;
2602 + }
2603 +@@ -1536,7 +1538,9 @@ static int ath10k_htt_tx_64(struct ath10k_htt *htt,
2604 + err_unmap_msdu:
2605 + dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
2606 + err_free_msdu_id:
2607 ++ spin_lock_bh(&htt->tx_lock);
2608 + ath10k_htt_tx_free_msdu_id(htt, msdu_id);
2609 ++ spin_unlock_bh(&htt->tx_lock);
2610 + err:
2611 + return res;
2612 + }
2613 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
2614 +index d5bb81e88762..9d2367133c7c 100644
2615 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
2616 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
2617 +@@ -30,7 +30,7 @@
2618 + #define BRCMF_ARP_OL_PEER_AUTO_REPLY 0x00000008
2619 +
2620 + #define BRCMF_BSS_INFO_VERSION 109 /* curr ver of brcmf_bss_info_le struct */
2621 +-#define BRCMF_BSS_RSSI_ON_CHANNEL 0x0002
2622 ++#define BRCMF_BSS_RSSI_ON_CHANNEL 0x0004
2623 +
2624 + #define BRCMF_STA_BRCM 0x00000001 /* Running a Broadcom driver */
2625 + #define BRCMF_STA_WME 0x00000002 /* WMM association */
2626 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
2627 +index 1de8497d92b8..dc7c970257d2 100644
2628 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
2629 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
2630 +@@ -653,6 +653,7 @@ static inline int brcmf_fws_hanger_poppkt(struct brcmf_fws_hanger *h,
2631 + static void brcmf_fws_psq_flush(struct brcmf_fws_info *fws, struct pktq *q,
2632 + int ifidx)
2633 + {
2634 ++ struct brcmf_fws_hanger_item *hi;
2635 + bool (*matchfn)(struct sk_buff *, void *) = NULL;
2636 + struct sk_buff *skb;
2637 + int prec;
2638 +@@ -664,6 +665,9 @@ static void brcmf_fws_psq_flush(struct brcmf_fws_info *fws, struct pktq *q,
2639 + skb = brcmu_pktq_pdeq_match(q, prec, matchfn, &ifidx);
2640 + while (skb) {
2641 + hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT);
2642 ++ hi = &fws->hanger.items[hslot];
2643 ++ WARN_ON(skb != hi->pkt);
2644 ++ hi->state = BRCMF_FWS_HANGER_ITEM_STATE_FREE;
2645 + brcmf_fws_hanger_poppkt(&fws->hanger, hslot, &skb,
2646 + true);
2647 + brcmu_pkt_buf_free_skb(skb);
2648 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
2649 +index 96870d1b3b73..a5195bdb4d9b 100644
2650 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
2651 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
2652 +@@ -3633,7 +3633,11 @@ static void brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
2653 + if (bus->idlecount > bus->idletime) {
2654 + brcmf_dbg(SDIO, "idle\n");
2655 + sdio_claim_host(bus->sdiodev->func1);
2656 +- brcmf_sdio_wd_timer(bus, false);
2657 ++#ifdef DEBUG
2658 ++ if (!BRCMF_FWCON_ON() ||
2659 ++ bus->console_interval == 0)
2660 ++#endif
2661 ++ brcmf_sdio_wd_timer(bus, false);
2662 + bus->idlecount = 0;
2663 + brcmf_sdio_bus_sleep(bus, true, false);
2664 + sdio_release_host(bus->sdiodev->func1);
2665 +diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
2666 +index e16f2597c219..c1c1cf330de7 100644
2667 +--- a/drivers/net/wireless/intel/iwlegacy/common.c
2668 ++++ b/drivers/net/wireless/intel/iwlegacy/common.c
2669 +@@ -4302,8 +4302,8 @@ il_apm_init(struct il_priv *il)
2670 + * power savings, even without L1.
2671 + */
2672 + if (il->cfg->set_l0s) {
2673 +- pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl);
2674 +- if (lctl & PCI_EXP_LNKCTL_ASPM_L1) {
2675 ++ ret = pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl);
2676 ++ if (!ret && (lctl & PCI_EXP_LNKCTL_ASPM_L1)) {
2677 + /* L1-ASPM enabled; disable(!) L0S */
2678 + il_set_bit(il, CSR_GIO_REG,
2679 + CSR_GIO_REG_VAL_L0S_ENABLED);
2680 +diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
2681 +index 69e3b624adbb..797c2e978394 100644
2682 +--- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
2683 ++++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
2684 +@@ -581,6 +581,11 @@ static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv,
2685 + {
2686 + struct host_cmd_ds_802_11_key_material *key =
2687 + &resp->params.key_material;
2688 ++ int len;
2689 ++
2690 ++ len = le16_to_cpu(key->key_param_set.key_len);
2691 ++ if (len > sizeof(key->key_param_set.key))
2692 ++ return -EINVAL;
2693 +
2694 + if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) {
2695 + if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) {
2696 +@@ -594,9 +599,8 @@ static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv,
2697 +
2698 + memset(priv->aes_key.key_param_set.key, 0,
2699 + sizeof(key->key_param_set.key));
2700 +- priv->aes_key.key_param_set.key_len = key->key_param_set.key_len;
2701 +- memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key,
2702 +- le16_to_cpu(priv->aes_key.key_param_set.key_len));
2703 ++ priv->aes_key.key_param_set.key_len = cpu_to_le16(len);
2704 ++ memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key, len);
2705 +
2706 + return 0;
2707 + }
2708 +@@ -611,9 +615,14 @@ static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv,
2709 + struct host_cmd_ds_command *resp)
2710 + {
2711 + struct host_cmd_ds_802_11_key_material_v2 *key_v2;
2712 +- __le16 len;
2713 ++ int len;
2714 +
2715 + key_v2 = &resp->params.key_material_v2;
2716 ++
2717 ++ len = le16_to_cpu(key_v2->key_param_set.key_params.aes.key_len);
2718 ++ if (len > WLAN_KEY_LEN_CCMP)
2719 ++ return -EINVAL;
2720 ++
2721 + if (le16_to_cpu(key_v2->action) == HostCmd_ACT_GEN_SET) {
2722 + if ((le16_to_cpu(key_v2->key_param_set.key_info) & KEY_MCAST)) {
2723 + mwifiex_dbg(priv->adapter, INFO, "info: key: GTK is set\n");
2724 +@@ -629,10 +638,9 @@ static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv,
2725 + memset(priv->aes_key_v2.key_param_set.key_params.aes.key, 0,
2726 + WLAN_KEY_LEN_CCMP);
2727 + priv->aes_key_v2.key_param_set.key_params.aes.key_len =
2728 +- key_v2->key_param_set.key_params.aes.key_len;
2729 +- len = priv->aes_key_v2.key_param_set.key_params.aes.key_len;
2730 ++ cpu_to_le16(len);
2731 + memcpy(priv->aes_key_v2.key_param_set.key_params.aes.key,
2732 +- key_v2->key_param_set.key_params.aes.key, le16_to_cpu(len));
2733 ++ key_v2->key_param_set.key_params.aes.key, len);
2734 +
2735 + return 0;
2736 + }
2737 +diff --git a/drivers/net/wireless/ti/wl1251/event.c b/drivers/net/wireless/ti/wl1251/event.c
2738 +index f5acd24d0e2b..988abb49771f 100644
2739 +--- a/drivers/net/wireless/ti/wl1251/event.c
2740 ++++ b/drivers/net/wireless/ti/wl1251/event.c
2741 +@@ -84,7 +84,7 @@ static int wl1251_event_ps_report(struct wl1251 *wl,
2742 + break;
2743 + }
2744 +
2745 +- return 0;
2746 ++ return ret;
2747 + }
2748 +
2749 + static void wl1251_event_mbox_dump(struct event_mailbox *mbox)
2750 +diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
2751 +index 6dd1780a5885..0f19cc75cc0c 100644
2752 +--- a/drivers/parisc/sba_iommu.c
2753 ++++ b/drivers/parisc/sba_iommu.c
2754 +@@ -1291,7 +1291,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
2755 + ** (one that doesn't overlap memory or LMMIO space) in the
2756 + ** IBASE and IMASK registers.
2757 + */
2758 +- ioc->ibase = READ_REG(ioc->ioc_hpa + IOC_IBASE);
2759 ++ ioc->ibase = READ_REG(ioc->ioc_hpa + IOC_IBASE) & ~0x1fffffULL;
2760 + iova_space_size = ~(READ_REG(ioc->ioc_hpa + IOC_IMASK) & 0xFFFFFFFFUL) + 1;
2761 +
2762 + if ((ioc->ibase < 0xfed00000UL) && ((ioc->ibase + iova_space_size) > 0xfee00000UL)) {
2763 +diff --git a/drivers/pci/access.c b/drivers/pci/access.c
2764 +index a3ad2fe185b9..3c8ffd62dc00 100644
2765 +--- a/drivers/pci/access.c
2766 ++++ b/drivers/pci/access.c
2767 +@@ -204,17 +204,13 @@ EXPORT_SYMBOL(pci_bus_set_ops);
2768 + static DECLARE_WAIT_QUEUE_HEAD(pci_cfg_wait);
2769 +
2770 + static noinline void pci_wait_cfg(struct pci_dev *dev)
2771 ++ __must_hold(&pci_lock)
2772 + {
2773 +- DECLARE_WAITQUEUE(wait, current);
2774 +-
2775 +- __add_wait_queue(&pci_cfg_wait, &wait);
2776 + do {
2777 +- set_current_state(TASK_UNINTERRUPTIBLE);
2778 + raw_spin_unlock_irq(&pci_lock);
2779 +- schedule();
2780 ++ wait_event(pci_cfg_wait, !dev->block_cfg_access);
2781 + raw_spin_lock_irq(&pci_lock);
2782 + } while (dev->block_cfg_access);
2783 +- __remove_wait_queue(&pci_cfg_wait, &wait);
2784 + }
2785 +
2786 + /* Returns 0 on success, negative values indicate error. */
2787 +diff --git a/drivers/pci/controller/pcie-cadence-host.c b/drivers/pci/controller/pcie-cadence-host.c
2788 +index ec394f6a19c8..ae7affcb1a81 100644
2789 +--- a/drivers/pci/controller/pcie-cadence-host.c
2790 ++++ b/drivers/pci/controller/pcie-cadence-host.c
2791 +@@ -102,6 +102,7 @@ static int cdns_pcie_host_init_root_port(struct cdns_pcie_rc *rc)
2792 + {
2793 + struct cdns_pcie *pcie = &rc->pcie;
2794 + u32 value, ctrl;
2795 ++ u32 id;
2796 +
2797 + /*
2798 + * Set the root complex BAR configuration register:
2799 +@@ -121,8 +122,12 @@ static int cdns_pcie_host_init_root_port(struct cdns_pcie_rc *rc)
2800 + cdns_pcie_writel(pcie, CDNS_PCIE_LM_RC_BAR_CFG, value);
2801 +
2802 + /* Set root port configuration space */
2803 +- if (rc->vendor_id != 0xffff)
2804 +- cdns_pcie_rp_writew(pcie, PCI_VENDOR_ID, rc->vendor_id);
2805 ++ if (rc->vendor_id != 0xffff) {
2806 ++ id = CDNS_PCIE_LM_ID_VENDOR(rc->vendor_id) |
2807 ++ CDNS_PCIE_LM_ID_SUBSYS(rc->vendor_id);
2808 ++ cdns_pcie_writel(pcie, CDNS_PCIE_LM_ID, id);
2809 ++ }
2810 ++
2811 + if (rc->device_id != 0xffff)
2812 + cdns_pcie_rp_writew(pcie, PCI_DEVICE_ID, rc->device_id);
2813 +
2814 +diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
2815 +index ad39b404f10a..3d1b004a58f8 100644
2816 +--- a/drivers/pci/controller/vmd.c
2817 ++++ b/drivers/pci/controller/vmd.c
2818 +@@ -718,6 +718,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
2819 + if (!vmd->bus) {
2820 + pci_free_resource_list(&resources);
2821 + irq_domain_remove(vmd->irq_domain);
2822 ++ irq_domain_free_fwnode(fn);
2823 + return -ENODEV;
2824 + }
2825 +
2826 +@@ -820,6 +821,7 @@ static void vmd_cleanup_srcu(struct vmd_dev *vmd)
2827 + static void vmd_remove(struct pci_dev *dev)
2828 + {
2829 + struct vmd_dev *vmd = pci_get_drvdata(dev);
2830 ++ struct fwnode_handle *fn = vmd->irq_domain->fwnode;
2831 +
2832 + sysfs_remove_link(&vmd->dev->dev.kobj, "domain");
2833 + pci_stop_root_bus(vmd->bus);
2834 +@@ -828,6 +830,7 @@ static void vmd_remove(struct pci_dev *dev)
2835 + vmd_teardown_dma_ops(vmd);
2836 + vmd_detach_resources(vmd);
2837 + irq_domain_remove(vmd->irq_domain);
2838 ++ irq_domain_free_fwnode(fn);
2839 + }
2840 +
2841 + #ifdef CONFIG_PM_SLEEP
2842 +diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
2843 +index 6e50f84733b7..279f9f0197b0 100644
2844 +--- a/drivers/pci/pcie/aspm.c
2845 ++++ b/drivers/pci/pcie/aspm.c
2846 +@@ -1164,6 +1164,7 @@ static int pcie_aspm_get_policy(char *buffer, const struct kernel_param *kp)
2847 + cnt += sprintf(buffer + cnt, "[%s] ", policy_str[i]);
2848 + else
2849 + cnt += sprintf(buffer + cnt, "%s ", policy_str[i]);
2850 ++ cnt += sprintf(buffer + cnt, "\n");
2851 + return cnt;
2852 + }
2853 +
2854 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
2855 +index 8f856657dac2..9129ccd593d1 100644
2856 +--- a/drivers/pci/quirks.c
2857 ++++ b/drivers/pci/quirks.c
2858 +@@ -4334,6 +4334,8 @@ static int pci_quirk_amd_sb_acs(struct pci_dev *dev, u16 acs_flags)
2859 + if (ACPI_FAILURE(status))
2860 + return -ENODEV;
2861 +
2862 ++ acpi_put_table(header);
2863 ++
2864 + /* Filter out flags not applicable to multifunction */
2865 + acs_flags &= (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC | PCI_ACS_DT);
2866 +
2867 +diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
2868 +index b8b226a20014..1feb1e1bf85e 100644
2869 +--- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
2870 ++++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
2871 +@@ -717,7 +717,9 @@ static int exynos5_usbdrd_phy_calibrate(struct phy *phy)
2872 + struct phy_usb_instance *inst = phy_get_drvdata(phy);
2873 + struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst);
2874 +
2875 +- return exynos5420_usbdrd_phy_calibrate(phy_drd);
2876 ++ if (inst->phy_cfg->id == EXYNOS5_DRDPHY_UTMI)
2877 ++ return exynos5420_usbdrd_phy_calibrate(phy_drd);
2878 ++ return 0;
2879 + }
2880 +
2881 + static const struct phy_ops exynos5_usbdrd_phy_ops = {
2882 +diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
2883 +index 7ec72ff2419a..04a4e761e9a9 100644
2884 +--- a/drivers/pinctrl/pinctrl-single.c
2885 ++++ b/drivers/pinctrl/pinctrl-single.c
2886 +@@ -916,7 +916,7 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np,
2887 +
2888 + /* If pinconf isn't supported, don't parse properties in below. */
2889 + if (!PCS_HAS_PINCONF)
2890 +- return 0;
2891 ++ return -ENOTSUPP;
2892 +
2893 + /* cacluate how much properties are supported in current node */
2894 + for (i = 0; i < ARRAY_SIZE(prop2); i++) {
2895 +@@ -928,7 +928,7 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np,
2896 + nconfs++;
2897 + }
2898 + if (!nconfs)
2899 +- return 0;
2900 ++ return -ENOTSUPP;
2901 +
2902 + func->conf = devm_kcalloc(pcs->dev,
2903 + nconfs, sizeof(struct pcs_conf_vals),
2904 +@@ -1056,9 +1056,12 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
2905 +
2906 + if (PCS_HAS_PINCONF && function) {
2907 + res = pcs_parse_pinconf(pcs, np, function, map);
2908 +- if (res)
2909 ++ if (res == 0)
2910 ++ *num_maps = 2;
2911 ++ else if (res == -ENOTSUPP)
2912 ++ *num_maps = 1;
2913 ++ else
2914 + goto free_pingroups;
2915 +- *num_maps = 2;
2916 + } else {
2917 + *num_maps = 1;
2918 + }
2919 +diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c
2920 +index c514cb73bb50..d7d69eadb9bb 100644
2921 +--- a/drivers/platform/x86/intel-hid.c
2922 ++++ b/drivers/platform/x86/intel-hid.c
2923 +@@ -564,7 +564,7 @@ check_acpi_dev(acpi_handle handle, u32 lvl, void *context, void **rv)
2924 + return AE_OK;
2925 +
2926 + if (acpi_match_device_ids(dev, ids) == 0)
2927 +- if (acpi_create_platform_device(dev, NULL))
2928 ++ if (!IS_ERR_OR_NULL(acpi_create_platform_device(dev, NULL)))
2929 + dev_info(&dev->dev,
2930 + "intel-hid: created platform device\n");
2931 +
2932 +diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
2933 +index d122f33d43ac..c7c8b432c163 100644
2934 +--- a/drivers/platform/x86/intel-vbtn.c
2935 ++++ b/drivers/platform/x86/intel-vbtn.c
2936 +@@ -272,7 +272,7 @@ check_acpi_dev(acpi_handle handle, u32 lvl, void *context, void **rv)
2937 + return AE_OK;
2938 +
2939 + if (acpi_match_device_ids(dev, ids) == 0)
2940 +- if (acpi_create_platform_device(dev, NULL))
2941 ++ if (!IS_ERR_OR_NULL(acpi_create_platform_device(dev, NULL)))
2942 + dev_info(&dev->dev,
2943 + "intel-vbtn: created platform device\n");
2944 +
2945 +diff --git a/drivers/power/supply/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c
2946 +index 63c57dc82ac1..4eda5065b5bb 100644
2947 +--- a/drivers/power/supply/88pm860x_battery.c
2948 ++++ b/drivers/power/supply/88pm860x_battery.c
2949 +@@ -436,7 +436,7 @@ static void pm860x_init_battery(struct pm860x_battery_info *info)
2950 + int ret;
2951 + int data;
2952 + int bat_remove;
2953 +- int soc;
2954 ++ int soc = 0;
2955 +
2956 + /* measure enable on GPADC1 */
2957 + data = MEAS1_GP1;
2958 +@@ -499,7 +499,9 @@ static void pm860x_init_battery(struct pm860x_battery_info *info)
2959 + }
2960 + mutex_unlock(&info->lock);
2961 +
2962 +- calc_soc(info, OCV_MODE_ACTIVE, &soc);
2963 ++ ret = calc_soc(info, OCV_MODE_ACTIVE, &soc);
2964 ++ if (ret < 0)
2965 ++ goto out;
2966 +
2967 + data = pm860x_reg_read(info->i2c, PM8607_POWER_UP_LOG);
2968 + bat_remove = data & BAT_WU_LOG;
2969 +diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
2970 +index eb917e93fa72..8d30f9ac3e9d 100644
2971 +--- a/drivers/s390/net/qeth_l2_main.c
2972 ++++ b/drivers/s390/net/qeth_l2_main.c
2973 +@@ -1463,6 +1463,10 @@ static void qeth_bridge_state_change(struct qeth_card *card,
2974 + int extrasize;
2975 +
2976 + QETH_CARD_TEXT(card, 2, "brstchng");
2977 ++ if (qports->num_entries == 0) {
2978 ++ QETH_CARD_TEXT(card, 2, "BPempty");
2979 ++ return;
2980 ++ }
2981 + if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) {
2982 + QETH_CARD_TEXT_(card, 2, "BPsz%04x", qports->entry_length);
2983 + return;
2984 +diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c
2985 +index edce5f3cfdba..93ba83e3148e 100644
2986 +--- a/drivers/scsi/arm/cumana_2.c
2987 ++++ b/drivers/scsi/arm/cumana_2.c
2988 +@@ -454,7 +454,7 @@ static int cumanascsi2_probe(struct expansion_card *ec,
2989 +
2990 + if (info->info.scsi.dma != NO_DMA)
2991 + free_dma(info->info.scsi.dma);
2992 +- free_irq(ec->irq, host);
2993 ++ free_irq(ec->irq, info);
2994 +
2995 + out_release:
2996 + fas216_release(host);
2997 +diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c
2998 +index e93e047f4316..65bb34ce93b9 100644
2999 +--- a/drivers/scsi/arm/eesox.c
3000 ++++ b/drivers/scsi/arm/eesox.c
3001 +@@ -575,7 +575,7 @@ static int eesoxscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
3002 +
3003 + if (info->info.scsi.dma != NO_DMA)
3004 + free_dma(info->info.scsi.dma);
3005 +- free_irq(ec->irq, host);
3006 ++ free_irq(ec->irq, info);
3007 +
3008 + out_remove:
3009 + fas216_remove(host);
3010 +diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c
3011 +index 79aa88911b7f..b5e4a25ea1ef 100644
3012 +--- a/drivers/scsi/arm/powertec.c
3013 ++++ b/drivers/scsi/arm/powertec.c
3014 +@@ -382,7 +382,7 @@ static int powertecscsi_probe(struct expansion_card *ec,
3015 +
3016 + if (info->info.scsi.dma != NO_DMA)
3017 + free_dma(info->info.scsi.dma);
3018 +- free_irq(ec->irq, host);
3019 ++ free_irq(ec->irq, info);
3020 +
3021 + out_release:
3022 + fas216_release(host);
3023 +diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
3024 +index 82e01dbe90af..7c0eaa9ea1ed 100644
3025 +--- a/drivers/scsi/mesh.c
3026 ++++ b/drivers/scsi/mesh.c
3027 +@@ -1044,6 +1044,8 @@ static void handle_error(struct mesh_state *ms)
3028 + while ((in_8(&mr->bus_status1) & BS1_RST) != 0)
3029 + udelay(1);
3030 + printk("done\n");
3031 ++ if (ms->dma_started)
3032 ++ halt_dma(ms);
3033 + handle_reset(ms);
3034 + /* request_q is empty, no point in mesh_start() */
3035 + return;
3036 +@@ -1356,7 +1358,8 @@ static void halt_dma(struct mesh_state *ms)
3037 + ms->conn_tgt, ms->data_ptr, scsi_bufflen(cmd),
3038 + ms->tgts[ms->conn_tgt].data_goes_out);
3039 + }
3040 +- scsi_dma_unmap(cmd);
3041 ++ if (cmd)
3042 ++ scsi_dma_unmap(cmd);
3043 + ms->dma_started = 0;
3044 + }
3045 +
3046 +@@ -1711,6 +1714,9 @@ static int mesh_host_reset(struct scsi_cmnd *cmd)
3047 +
3048 + spin_lock_irqsave(ms->host->host_lock, flags);
3049 +
3050 ++ if (ms->dma_started)
3051 ++ halt_dma(ms);
3052 ++
3053 + /* Reset the controller & dbdma channel */
3054 + out_le32(&md->control, (RUN|PAUSE|FLUSH|WAKE) << 16); /* stop dma */
3055 + out_8(&mr->exception, 0xff); /* clear all exception bits */
3056 +diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
3057 +index a1dbae806fde..d2b045eb7274 100644
3058 +--- a/drivers/scsi/scsi_debug.c
3059 ++++ b/drivers/scsi/scsi_debug.c
3060 +@@ -5384,6 +5384,12 @@ static int __init scsi_debug_init(void)
3061 + pr_err("submit_queues must be 1 or more\n");
3062 + return -EINVAL;
3063 + }
3064 ++
3065 ++ if ((sdebug_max_queue > SDEBUG_CANQUEUE) || (sdebug_max_queue < 1)) {
3066 ++ pr_err("max_queue must be in range [1, %d]\n", SDEBUG_CANQUEUE);
3067 ++ return -EINVAL;
3068 ++ }
3069 ++
3070 + sdebug_q_arr = kcalloc(submit_queues, sizeof(struct sdebug_queue),
3071 + GFP_KERNEL);
3072 + if (sdebug_q_arr == NULL)
3073 +diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
3074 +index 3c6f920535ea..519d19f57eee 100644
3075 +--- a/drivers/soc/qcom/rpmh-rsc.c
3076 ++++ b/drivers/soc/qcom/rpmh-rsc.c
3077 +@@ -715,6 +715,7 @@ static struct platform_driver rpmh_driver = {
3078 + .driver = {
3079 + .name = "rpmh",
3080 + .of_match_table = rpmh_drv_match,
3081 ++ .suppress_bind_attrs = true,
3082 + },
3083 + };
3084 +
3085 +diff --git a/drivers/spi/spi-lantiq-ssc.c b/drivers/spi/spi-lantiq-ssc.c
3086 +index d5976615d924..dc740b5f720b 100644
3087 +--- a/drivers/spi/spi-lantiq-ssc.c
3088 ++++ b/drivers/spi/spi-lantiq-ssc.c
3089 +@@ -187,6 +187,7 @@ struct lantiq_ssc_spi {
3090 + unsigned int tx_fifo_size;
3091 + unsigned int rx_fifo_size;
3092 + unsigned int base_cs;
3093 ++ unsigned int fdx_tx_level;
3094 + };
3095 +
3096 + static u32 lantiq_ssc_readl(const struct lantiq_ssc_spi *spi, u32 reg)
3097 +@@ -484,6 +485,7 @@ static void tx_fifo_write(struct lantiq_ssc_spi *spi)
3098 + u32 data;
3099 + unsigned int tx_free = tx_fifo_free(spi);
3100 +
3101 ++ spi->fdx_tx_level = 0;
3102 + while (spi->tx_todo && tx_free) {
3103 + switch (spi->bits_per_word) {
3104 + case 2 ... 8:
3105 +@@ -512,6 +514,7 @@ static void tx_fifo_write(struct lantiq_ssc_spi *spi)
3106 +
3107 + lantiq_ssc_writel(spi, data, LTQ_SPI_TB);
3108 + tx_free--;
3109 ++ spi->fdx_tx_level++;
3110 + }
3111 + }
3112 +
3113 +@@ -523,6 +526,13 @@ static void rx_fifo_read_full_duplex(struct lantiq_ssc_spi *spi)
3114 + u32 data;
3115 + unsigned int rx_fill = rx_fifo_level(spi);
3116 +
3117 ++ /*
3118 ++ * Wait until all expected data to be shifted in.
3119 ++ * Otherwise, rx overrun may occur.
3120 ++ */
3121 ++ while (rx_fill != spi->fdx_tx_level)
3122 ++ rx_fill = rx_fifo_level(spi);
3123 ++
3124 + while (rx_fill) {
3125 + data = lantiq_ssc_readl(spi, LTQ_SPI_RB);
3126 +
3127 +diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
3128 +index 167047760d79..e444e7cc6968 100644
3129 +--- a/drivers/spi/spidev.c
3130 ++++ b/drivers/spi/spidev.c
3131 +@@ -232,6 +232,11 @@ static int spidev_message(struct spidev_data *spidev,
3132 + for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers;
3133 + n;
3134 + n--, k_tmp++, u_tmp++) {
3135 ++ /* Ensure that also following allocations from rx_buf/tx_buf will meet
3136 ++ * DMA alignment requirements.
3137 ++ */
3138 ++ unsigned int len_aligned = ALIGN(u_tmp->len, ARCH_KMALLOC_MINALIGN);
3139 ++
3140 + k_tmp->len = u_tmp->len;
3141 +
3142 + total += k_tmp->len;
3143 +@@ -247,17 +252,17 @@ static int spidev_message(struct spidev_data *spidev,
3144 +
3145 + if (u_tmp->rx_buf) {
3146 + /* this transfer needs space in RX bounce buffer */
3147 +- rx_total += k_tmp->len;
3148 ++ rx_total += len_aligned;
3149 + if (rx_total > bufsiz) {
3150 + status = -EMSGSIZE;
3151 + goto done;
3152 + }
3153 + k_tmp->rx_buf = rx_buf;
3154 +- rx_buf += k_tmp->len;
3155 ++ rx_buf += len_aligned;
3156 + }
3157 + if (u_tmp->tx_buf) {
3158 + /* this transfer needs space in TX bounce buffer */
3159 +- tx_total += k_tmp->len;
3160 ++ tx_total += len_aligned;
3161 + if (tx_total > bufsiz) {
3162 + status = -EMSGSIZE;
3163 + goto done;
3164 +@@ -267,7 +272,7 @@ static int spidev_message(struct spidev_data *spidev,
3165 + (uintptr_t) u_tmp->tx_buf,
3166 + u_tmp->len))
3167 + goto done;
3168 +- tx_buf += k_tmp->len;
3169 ++ tx_buf += len_aligned;
3170 + }
3171 +
3172 + k_tmp->cs_change = !!u_tmp->cs_change;
3173 +@@ -297,16 +302,16 @@ static int spidev_message(struct spidev_data *spidev,
3174 + goto done;
3175 +
3176 + /* copy any rx data out of bounce buffer */
3177 +- rx_buf = spidev->rx_buffer;
3178 +- for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) {
3179 ++ for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers;
3180 ++ n;
3181 ++ n--, k_tmp++, u_tmp++) {
3182 + if (u_tmp->rx_buf) {
3183 + if (copy_to_user((u8 __user *)
3184 +- (uintptr_t) u_tmp->rx_buf, rx_buf,
3185 ++ (uintptr_t) u_tmp->rx_buf, k_tmp->rx_buf,
3186 + u_tmp->len)) {
3187 + status = -EFAULT;
3188 + goto done;
3189 + }
3190 +- rx_buf += u_tmp->len;
3191 + }
3192 + }
3193 + status = total;
3194 +diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
3195 +index 2066a1d9bc84..87244a208976 100644
3196 +--- a/drivers/staging/rtl8192u/r8192U_core.c
3197 ++++ b/drivers/staging/rtl8192u/r8192U_core.c
3198 +@@ -2484,7 +2484,7 @@ static int rtl8192_read_eeprom_info(struct net_device *dev)
3199 + ret = eprom_read(dev, (EEPROM_TxPwIndex_CCK >> 1));
3200 + if (ret < 0)
3201 + return ret;
3202 +- priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff) >> 8;
3203 ++ priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff00) >> 8;
3204 + } else
3205 + priv->EEPROMTxPowerLevelCCK = 0x10;
3206 + RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK);
3207 +diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
3208 +index 452e034aedc1..343da0031299 100644
3209 +--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
3210 ++++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
3211 +@@ -183,7 +183,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
3212 +
3213 + data = ti_bandgap_get_sensor_data(bgp, id);
3214 +
3215 +- if (!IS_ERR_OR_NULL(data))
3216 ++ if (IS_ERR_OR_NULL(data))
3217 + data = ti_thermal_build_data(bgp, id);
3218 +
3219 + if (!data)
3220 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
3221 +index e0b77674869c..c96c50faccf7 100644
3222 +--- a/drivers/usb/core/quirks.c
3223 ++++ b/drivers/usb/core/quirks.c
3224 +@@ -25,17 +25,23 @@ static unsigned int quirk_count;
3225 +
3226 + static char quirks_param[128];
3227 +
3228 +-static int quirks_param_set(const char *val, const struct kernel_param *kp)
3229 ++static int quirks_param_set(const char *value, const struct kernel_param *kp)
3230 + {
3231 +- char *p, *field;
3232 ++ char *val, *p, *field;
3233 + u16 vid, pid;
3234 + u32 flags;
3235 + size_t i;
3236 + int err;
3237 +
3238 ++ val = kstrdup(value, GFP_KERNEL);
3239 ++ if (!val)
3240 ++ return -ENOMEM;
3241 ++
3242 + err = param_set_copystring(val, kp);
3243 +- if (err)
3244 ++ if (err) {
3245 ++ kfree(val);
3246 + return err;
3247 ++ }
3248 +
3249 + mutex_lock(&quirk_mutex);
3250 +
3251 +@@ -60,10 +66,11 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
3252 + if (!quirk_list) {
3253 + quirk_count = 0;
3254 + mutex_unlock(&quirk_mutex);
3255 ++ kfree(val);
3256 + return -ENOMEM;
3257 + }
3258 +
3259 +- for (i = 0, p = (char *)val; p && *p;) {
3260 ++ for (i = 0, p = val; p && *p;) {
3261 + /* Each entry consists of VID:PID:flags */
3262 + field = strsep(&p, ":");
3263 + if (!field)
3264 +@@ -144,6 +151,7 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
3265 +
3266 + unlock:
3267 + mutex_unlock(&quirk_mutex);
3268 ++ kfree(val);
3269 +
3270 + return 0;
3271 + }
3272 +diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
3273 +index c35c93f16a49..a9e86f5e6eaa 100644
3274 +--- a/drivers/usb/dwc2/platform.c
3275 ++++ b/drivers/usb/dwc2/platform.c
3276 +@@ -499,6 +499,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
3277 + if (hsotg->gadget_enabled) {
3278 + retval = usb_add_gadget_udc(hsotg->dev, &hsotg->gadget);
3279 + if (retval) {
3280 ++ hsotg->gadget.udc = NULL;
3281 + dwc2_hsotg_remove(hsotg);
3282 + goto error;
3283 + }
3284 +@@ -507,7 +508,8 @@ static int dwc2_driver_probe(struct platform_device *dev)
3285 + return 0;
3286 +
3287 + error:
3288 +- dwc2_lowlevel_hw_disable(hsotg);
3289 ++ if (hsotg->dr_mode != USB_DR_MODE_PERIPHERAL)
3290 ++ dwc2_lowlevel_hw_disable(hsotg);
3291 + return retval;
3292 + }
3293 +
3294 +diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
3295 +index 01b44e159623..e174b1b889da 100644
3296 +--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
3297 ++++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
3298 +@@ -283,6 +283,7 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit)
3299 + * in that case reinit is passed as 1
3300 + */
3301 + if (reinit) {
3302 ++ int i;
3303 + /* Enable interrupts */
3304 + temp = bdc_readl(bdc->regs, BDC_BDCSC);
3305 + temp |= BDC_GIE;
3306 +@@ -292,6 +293,9 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit)
3307 + /* Initialize SRR to 0 */
3308 + memset(bdc->srr.sr_bds, 0,
3309 + NUM_SR_ENTRIES * sizeof(struct bdc_bd));
3310 ++ /* clear ep flags to avoid post disconnect stops/deconfigs */
3311 ++ for (i = 1; i < bdc->num_eps; ++i)
3312 ++ bdc->bdc_ep_array[i]->flags = 0;
3313 + } else {
3314 + /* One time initiaization only */
3315 + /* Enable status report function pointers */
3316 +@@ -604,9 +608,14 @@ static int bdc_remove(struct platform_device *pdev)
3317 + static int bdc_suspend(struct device *dev)
3318 + {
3319 + struct bdc *bdc = dev_get_drvdata(dev);
3320 ++ int ret;
3321 +
3322 +- clk_disable_unprepare(bdc->clk);
3323 +- return 0;
3324 ++ /* Halt the controller */
3325 ++ ret = bdc_stop(bdc);
3326 ++ if (!ret)
3327 ++ clk_disable_unprepare(bdc->clk);
3328 ++
3329 ++ return ret;
3330 + }
3331 +
3332 + static int bdc_resume(struct device *dev)
3333 +diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c
3334 +index d49c6dc1082d..9ddc0b4e92c9 100644
3335 +--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
3336 ++++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
3337 +@@ -615,7 +615,6 @@ int bdc_ep_enable(struct bdc_ep *ep)
3338 + }
3339 + bdc_dbg_bd_list(bdc, ep);
3340 + /* only for ep0: config ep is called for ep0 from connect event */
3341 +- ep->flags |= BDC_EP_ENABLED;
3342 + if (ep->ep_num == 1)
3343 + return ret;
3344 +
3345 +@@ -759,10 +758,13 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req *req)
3346 + __func__, ep->name, start_bdi, end_bdi);
3347 + dev_dbg(bdc->dev, "ep_dequeue ep=%p ep->desc=%p\n",
3348 + ep, (void *)ep->usb_ep.desc);
3349 +- /* Stop the ep to see where the HW is ? */
3350 +- ret = bdc_stop_ep(bdc, ep->ep_num);
3351 +- /* if there is an issue with stopping ep, then no need to go further */
3352 +- if (ret)
3353 ++ /* if still connected, stop the ep to see where the HW is ? */
3354 ++ if (!(bdc_readl(bdc->regs, BDC_USPC) & BDC_PST_MASK)) {
3355 ++ ret = bdc_stop_ep(bdc, ep->ep_num);
3356 ++ /* if there is an issue, then no need to go further */
3357 ++ if (ret)
3358 ++ return 0;
3359 ++ } else
3360 + return 0;
3361 +
3362 + /*
3363 +@@ -1911,7 +1913,9 @@ static int bdc_gadget_ep_disable(struct usb_ep *_ep)
3364 + __func__, ep->name, ep->flags);
3365 +
3366 + if (!(ep->flags & BDC_EP_ENABLED)) {
3367 +- dev_warn(bdc->dev, "%s is already disabled\n", ep->name);
3368 ++ if (bdc->gadget.speed != USB_SPEED_UNKNOWN)
3369 ++ dev_warn(bdc->dev, "%s is already disabled\n",
3370 ++ ep->name);
3371 + return 0;
3372 + }
3373 + spin_lock_irqsave(&bdc->lock, flags);
3374 +diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
3375 +index ee872cad5270..a87caad8d1c7 100644
3376 +--- a/drivers/usb/gadget/udc/net2280.c
3377 ++++ b/drivers/usb/gadget/udc/net2280.c
3378 +@@ -3782,8 +3782,10 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
3379 + return 0;
3380 +
3381 + done:
3382 +- if (dev)
3383 ++ if (dev) {
3384 + net2280_remove(pdev);
3385 ++ kfree(dev);
3386 ++ }
3387 + return retval;
3388 + }
3389 +
3390 +diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
3391 +index 860693520132..408e964522ab 100644
3392 +--- a/drivers/usb/mtu3/mtu3_core.c
3393 ++++ b/drivers/usb/mtu3/mtu3_core.c
3394 +@@ -128,8 +128,12 @@ static void mtu3_device_disable(struct mtu3 *mtu)
3395 + mtu3_setbits(ibase, SSUSB_U2_CTRL(0),
3396 + SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN);
3397 +
3398 +- if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG)
3399 ++ if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG) {
3400 + mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
3401 ++ if (mtu->is_u3_ip)
3402 ++ mtu3_clrbits(ibase, SSUSB_U3_CTRL(0),
3403 ++ SSUSB_U3_PORT_DUAL_MODE);
3404 ++ }
3405 +
3406 + mtu3_setbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
3407 + }
3408 +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
3409 +index 7ae121567098..46ec30a2c516 100644
3410 +--- a/drivers/usb/serial/cp210x.c
3411 ++++ b/drivers/usb/serial/cp210x.c
3412 +@@ -271,6 +271,8 @@ static struct usb_serial_driver cp210x_device = {
3413 + .break_ctl = cp210x_break_ctl,
3414 + .set_termios = cp210x_set_termios,
3415 + .tx_empty = cp210x_tx_empty,
3416 ++ .throttle = usb_serial_generic_throttle,
3417 ++ .unthrottle = usb_serial_generic_unthrottle,
3418 + .tiocmget = cp210x_tiocmget,
3419 + .tiocmset = cp210x_tiocmset,
3420 + .attach = cp210x_attach,
3421 +@@ -893,6 +895,7 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
3422 + u32 baud;
3423 + u16 bits;
3424 + u32 ctl_hs;
3425 ++ u32 flow_repl;
3426 +
3427 + cp210x_read_u32_reg(port, CP210X_GET_BAUDRATE, &baud);
3428 +
3429 +@@ -993,6 +996,22 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
3430 + ctl_hs = le32_to_cpu(flow_ctl.ulControlHandshake);
3431 + if (ctl_hs & CP210X_SERIAL_CTS_HANDSHAKE) {
3432 + dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
3433 ++ /*
3434 ++ * When the port is closed, the CP210x hardware disables
3435 ++ * auto-RTS and RTS is deasserted but it leaves auto-CTS when
3436 ++ * in hardware flow control mode. When re-opening the port, if
3437 ++ * auto-CTS is enabled on the cp210x, then auto-RTS must be
3438 ++ * re-enabled in the driver.
3439 ++ */
3440 ++ flow_repl = le32_to_cpu(flow_ctl.ulFlowReplace);
3441 ++ flow_repl &= ~CP210X_SERIAL_RTS_MASK;
3442 ++ flow_repl |= CP210X_SERIAL_RTS_SHIFT(CP210X_SERIAL_RTS_FLOW_CTL);
3443 ++ flow_ctl.ulFlowReplace = cpu_to_le32(flow_repl);
3444 ++ cp210x_write_reg_block(port,
3445 ++ CP210X_SET_FLOW,
3446 ++ &flow_ctl,
3447 ++ sizeof(flow_ctl));
3448 ++
3449 + cflag |= CRTSCTS;
3450 + } else {
3451 + dev_dbg(dev, "%s - flow control = NONE\n", __func__);
3452 +diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
3453 +index e287fd52c575..734f18d0a7f7 100644
3454 +--- a/drivers/usb/serial/iuu_phoenix.c
3455 ++++ b/drivers/usb/serial/iuu_phoenix.c
3456 +@@ -353,10 +353,11 @@ static void iuu_led_activity_on(struct urb *urb)
3457 + struct usb_serial_port *port = urb->context;
3458 + int result;
3459 + char *buf_ptr = port->write_urb->transfer_buffer;
3460 +- *buf_ptr++ = IUU_SET_LED;
3461 ++
3462 + if (xmas) {
3463 +- get_random_bytes(buf_ptr, 6);
3464 +- *(buf_ptr+7) = 1;
3465 ++ buf_ptr[0] = IUU_SET_LED;
3466 ++ get_random_bytes(buf_ptr + 1, 6);
3467 ++ buf_ptr[7] = 1;
3468 + } else {
3469 + iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255);
3470 + }
3471 +@@ -374,13 +375,14 @@ static void iuu_led_activity_off(struct urb *urb)
3472 + struct usb_serial_port *port = urb->context;
3473 + int result;
3474 + char *buf_ptr = port->write_urb->transfer_buffer;
3475 ++
3476 + if (xmas) {
3477 + iuu_rxcmd(urb);
3478 + return;
3479 +- } else {
3480 +- *buf_ptr++ = IUU_SET_LED;
3481 +- iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255);
3482 + }
3483 ++
3484 ++ iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255);
3485 ++
3486 + usb_fill_bulk_urb(port->write_urb, port->serial->dev,
3487 + usb_sndbulkpipe(port->serial->dev,
3488 + port->bulk_out_endpointAddress),
3489 +diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
3490 +index 7f2526b43b33..cc2fb5043184 100644
3491 +--- a/drivers/video/console/newport_con.c
3492 ++++ b/drivers/video/console/newport_con.c
3493 +@@ -31,6 +31,8 @@
3494 + #include <linux/linux_logo.h>
3495 + #include <linux/font.h>
3496 +
3497 ++#define NEWPORT_LEN 0x10000
3498 ++
3499 + #define FONT_DATA ((unsigned char *)font_vga_8x16.data)
3500 +
3501 + /* borrowed from fbcon.c */
3502 +@@ -42,6 +44,7 @@
3503 + static unsigned char *font_data[MAX_NR_CONSOLES];
3504 +
3505 + static struct newport_regs *npregs;
3506 ++static unsigned long newport_addr;
3507 +
3508 + static int logo_active;
3509 + static int topscan;
3510 +@@ -701,7 +704,6 @@ const struct consw newport_con = {
3511 + static int newport_probe(struct gio_device *dev,
3512 + const struct gio_device_id *id)
3513 + {
3514 +- unsigned long newport_addr;
3515 + int err;
3516 +
3517 + if (!dev->resource.start)
3518 +@@ -711,7 +713,7 @@ static int newport_probe(struct gio_device *dev,
3519 + return -EBUSY; /* we only support one Newport as console */
3520 +
3521 + newport_addr = dev->resource.start + 0xF0000;
3522 +- if (!request_mem_region(newport_addr, 0x10000, "Newport"))
3523 ++ if (!request_mem_region(newport_addr, NEWPORT_LEN, "Newport"))
3524 + return -ENODEV;
3525 +
3526 + npregs = (struct newport_regs *)/* ioremap cannot fail */
3527 +@@ -719,6 +721,11 @@ static int newport_probe(struct gio_device *dev,
3528 + console_lock();
3529 + err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
3530 + console_unlock();
3531 ++
3532 ++ if (err) {
3533 ++ iounmap((void *)npregs);
3534 ++ release_mem_region(newport_addr, NEWPORT_LEN);
3535 ++ }
3536 + return err;
3537 + }
3538 +
3539 +@@ -726,6 +733,7 @@ static void newport_remove(struct gio_device *dev)
3540 + {
3541 + give_up_console(&newport_con);
3542 + iounmap((void *)npregs);
3543 ++ release_mem_region(newport_addr, NEWPORT_LEN);
3544 + }
3545 +
3546 + static struct gio_device_id newport_ids[] = {
3547 +diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c
3548 +index 5d3a444083f7..2018e1ca33eb 100644
3549 +--- a/drivers/video/fbdev/neofb.c
3550 ++++ b/drivers/video/fbdev/neofb.c
3551 +@@ -1820,6 +1820,7 @@ static int neo_scan_monitor(struct fb_info *info)
3552 + #else
3553 + printk(KERN_ERR
3554 + "neofb: Only 640x480, 800x600/480 and 1024x768 panels are currently supported\n");
3555 ++ kfree(info->monspecs.modedb);
3556 + return -1;
3557 + #endif
3558 + default:
3559 +diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
3560 +index d59c8a59f582..90dee3e6f8bc 100644
3561 +--- a/drivers/video/fbdev/pxafb.c
3562 ++++ b/drivers/video/fbdev/pxafb.c
3563 +@@ -2446,8 +2446,8 @@ static int pxafb_remove(struct platform_device *dev)
3564 +
3565 + free_pages_exact(fbi->video_mem, fbi->video_mem_size);
3566 +
3567 +- dma_free_wc(&dev->dev, fbi->dma_buff_size, fbi->dma_buff,
3568 +- fbi->dma_buff_phys);
3569 ++ dma_free_coherent(&dev->dev, fbi->dma_buff_size, fbi->dma_buff,
3570 ++ fbi->dma_buff_phys);
3571 +
3572 + return 0;
3573 + }
3574 +diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c
3575 +index f1dcc6766d1e..1781ca697f66 100644
3576 +--- a/drivers/video/fbdev/sm712fb.c
3577 ++++ b/drivers/video/fbdev/sm712fb.c
3578 +@@ -1429,6 +1429,8 @@ static int smtc_map_smem(struct smtcfb_info *sfb,
3579 + static void smtc_unmap_smem(struct smtcfb_info *sfb)
3580 + {
3581 + if (sfb && sfb->fb->screen_base) {
3582 ++ if (sfb->chip_id == 0x720)
3583 ++ sfb->fb->screen_base -= 0x00200000;
3584 + iounmap(sfb->fb->screen_base);
3585 + sfb->fb->screen_base = NULL;
3586 + }
3587 +diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
3588 +index 6fa7209f24f4..b23edf64c2b2 100644
3589 +--- a/drivers/xen/balloon.c
3590 ++++ b/drivers/xen/balloon.c
3591 +@@ -570,11 +570,13 @@ static int add_ballooned_pages(int nr_pages)
3592 + if (xen_hotplug_unpopulated) {
3593 + st = reserve_additional_memory();
3594 + if (st != BP_ECANCELED) {
3595 ++ int rc;
3596 ++
3597 + mutex_unlock(&balloon_mutex);
3598 +- wait_event(balloon_wq,
3599 ++ rc = wait_event_interruptible(balloon_wq,
3600 + !list_empty(&ballooned_pages));
3601 + mutex_lock(&balloon_mutex);
3602 +- return 0;
3603 ++ return rc ? -ENOMEM : 0;
3604 + }
3605 + }
3606 +
3607 +@@ -632,6 +634,12 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
3608 + out_undo:
3609 + mutex_unlock(&balloon_mutex);
3610 + free_xenballooned_pages(pgno, pages);
3611 ++ /*
3612 ++ * NB: free_xenballooned_pages will only subtract pgno pages, but since
3613 ++ * target_unpopulated is incremented with nr_pages at the start we need
3614 ++ * to remove the remaining ones also, or accounting will be screwed.
3615 ++ */
3616 ++ balloon_stats.target_unpopulated -= nr_pages - pgno;
3617 + return ret;
3618 + }
3619 + EXPORT_SYMBOL(alloc_xenballooned_pages);
3620 +diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c
3621 +index d97fcfc5e558..f6589563ff71 100644
3622 +--- a/drivers/xen/gntdev-dmabuf.c
3623 ++++ b/drivers/xen/gntdev-dmabuf.c
3624 +@@ -641,6 +641,14 @@ dmabuf_imp_to_refs(struct gntdev_dmabuf_priv *priv, struct device *dev,
3625 + goto fail_detach;
3626 + }
3627 +
3628 ++ /* Check that we have zero offset. */
3629 ++ if (sgt->sgl->offset) {
3630 ++ ret = ERR_PTR(-EINVAL);
3631 ++ pr_debug("DMA buffer has %d bytes offset, user-space expects 0\n",
3632 ++ sgt->sgl->offset);
3633 ++ goto fail_unmap;
3634 ++ }
3635 ++
3636 + /* Check number of pages that imported buffer has. */
3637 + if (attach->dmabuf->size != gntdev_dmabuf->nr_pages << PAGE_SHIFT) {
3638 + ret = ERR_PTR(-EINVAL);
3639 +diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
3640 +index 619128b55837..c579966a0e5c 100644
3641 +--- a/fs/9p/v9fs.c
3642 ++++ b/fs/9p/v9fs.c
3643 +@@ -515,10 +515,9 @@ void v9fs_session_close(struct v9fs_session_info *v9ses)
3644 + }
3645 +
3646 + #ifdef CONFIG_9P_FSCACHE
3647 +- if (v9ses->fscache) {
3648 ++ if (v9ses->fscache)
3649 + v9fs_cache_session_put_cookie(v9ses);
3650 +- kfree(v9ses->cachetag);
3651 +- }
3652 ++ kfree(v9ses->cachetag);
3653 + #endif
3654 + kfree(v9ses->uname);
3655 + kfree(v9ses->aname);
3656 +diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
3657 +index 520b70b54331..fbcd18d96c52 100644
3658 +--- a/fs/btrfs/extent_io.c
3659 ++++ b/fs/btrfs/extent_io.c
3660 +@@ -4270,6 +4270,8 @@ int try_release_extent_mapping(struct page *page, gfp_t mask)
3661 +
3662 + /* once for us */
3663 + free_extent_map(em);
3664 ++
3665 ++ cond_resched(); /* Allow large-extent preemption. */
3666 + }
3667 + }
3668 + return try_release_extent_state(tree, page, mask);
3669 +diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
3670 +index f1261fa0af8a..244b87e4dfe7 100644
3671 +--- a/fs/dlm/lockspace.c
3672 ++++ b/fs/dlm/lockspace.c
3673 +@@ -633,6 +633,9 @@ static int new_lockspace(const char *name, const char *cluster,
3674 + wait_event(ls->ls_recover_lock_wait,
3675 + test_bit(LSFL_RECOVER_LOCK, &ls->ls_flags));
3676 +
3677 ++ /* let kobject handle freeing of ls if there's an error */
3678 ++ do_unreg = 1;
3679 ++
3680 + ls->ls_kobj.kset = dlm_kset;
3681 + error = kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL,
3682 + "%s", ls->ls_name);
3683 +@@ -640,9 +643,6 @@ static int new_lockspace(const char *name, const char *cluster,
3684 + goto out_recoverd;
3685 + kobject_uevent(&ls->ls_kobj, KOBJ_ADD);
3686 +
3687 +- /* let kobject handle freeing of ls if there's an error */
3688 +- do_unreg = 1;
3689 +-
3690 + /* This uevent triggers dlm_controld in userspace to add us to the
3691 + group of nodes that are members of this lockspace (managed by the
3692 + cluster infrastructure.) Once it's done that, it tells us who the
3693 +diff --git a/fs/minix/inode.c b/fs/minix/inode.c
3694 +index 72e308c3e66b..4f994de46e6b 100644
3695 +--- a/fs/minix/inode.c
3696 ++++ b/fs/minix/inode.c
3697 +@@ -155,6 +155,23 @@ static int minix_remount (struct super_block * sb, int * flags, char * data)
3698 + return 0;
3699 + }
3700 +
3701 ++static bool minix_check_superblock(struct minix_sb_info *sbi)
3702 ++{
3703 ++ if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0)
3704 ++ return false;
3705 ++
3706 ++ /*
3707 ++ * s_max_size must not exceed the block mapping limitation. This check
3708 ++ * is only needed for V1 filesystems, since V2/V3 support an extra level
3709 ++ * of indirect blocks which places the limit well above U32_MAX.
3710 ++ */
3711 ++ if (sbi->s_version == MINIX_V1 &&
3712 ++ sbi->s_max_size > (7 + 512 + 512*512) * BLOCK_SIZE)
3713 ++ return false;
3714 ++
3715 ++ return true;
3716 ++}
3717 ++
3718 + static int minix_fill_super(struct super_block *s, void *data, int silent)
3719 + {
3720 + struct buffer_head *bh;
3721 +@@ -233,11 +250,12 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
3722 + } else
3723 + goto out_no_fs;
3724 +
3725 ++ if (!minix_check_superblock(sbi))
3726 ++ goto out_illegal_sb;
3727 ++
3728 + /*
3729 + * Allocate the buffer map to keep the superblock small.
3730 + */
3731 +- if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0)
3732 +- goto out_illegal_sb;
3733 + i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh);
3734 + map = kzalloc(i, GFP_KERNEL);
3735 + if (!map)
3736 +@@ -471,6 +489,13 @@ static struct inode *V1_minix_iget(struct inode *inode)
3737 + iget_failed(inode);
3738 + return ERR_PTR(-EIO);
3739 + }
3740 ++ if (raw_inode->i_nlinks == 0) {
3741 ++ printk("MINIX-fs: deleted inode referenced: %lu\n",
3742 ++ inode->i_ino);
3743 ++ brelse(bh);
3744 ++ iget_failed(inode);
3745 ++ return ERR_PTR(-ESTALE);
3746 ++ }
3747 + inode->i_mode = raw_inode->i_mode;
3748 + i_uid_write(inode, raw_inode->i_uid);
3749 + i_gid_write(inode, raw_inode->i_gid);
3750 +@@ -504,6 +529,13 @@ static struct inode *V2_minix_iget(struct inode *inode)
3751 + iget_failed(inode);
3752 + return ERR_PTR(-EIO);
3753 + }
3754 ++ if (raw_inode->i_nlinks == 0) {
3755 ++ printk("MINIX-fs: deleted inode referenced: %lu\n",
3756 ++ inode->i_ino);
3757 ++ brelse(bh);
3758 ++ iget_failed(inode);
3759 ++ return ERR_PTR(-ESTALE);
3760 ++ }
3761 + inode->i_mode = raw_inode->i_mode;
3762 + i_uid_write(inode, raw_inode->i_uid);
3763 + i_gid_write(inode, raw_inode->i_gid);
3764 +diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c
3765 +index 043c3fdbc8e7..446148792f41 100644
3766 +--- a/fs/minix/itree_common.c
3767 ++++ b/fs/minix/itree_common.c
3768 +@@ -75,6 +75,7 @@ static int alloc_branch(struct inode *inode,
3769 + int n = 0;
3770 + int i;
3771 + int parent = minix_new_block(inode);
3772 ++ int err = -ENOSPC;
3773 +
3774 + branch[0].key = cpu_to_block(parent);
3775 + if (parent) for (n = 1; n < num; n++) {
3776 +@@ -85,6 +86,11 @@ static int alloc_branch(struct inode *inode,
3777 + break;
3778 + branch[n].key = cpu_to_block(nr);
3779 + bh = sb_getblk(inode->i_sb, parent);
3780 ++ if (!bh) {
3781 ++ minix_free_block(inode, nr);
3782 ++ err = -ENOMEM;
3783 ++ break;
3784 ++ }
3785 + lock_buffer(bh);
3786 + memset(bh->b_data, 0, bh->b_size);
3787 + branch[n].bh = bh;
3788 +@@ -103,7 +109,7 @@ static int alloc_branch(struct inode *inode,
3789 + bforget(branch[i].bh);
3790 + for (i = 0; i < n; i++)
3791 + minix_free_block(inode, block_to_cpu(branch[i].key));
3792 +- return -ENOSPC;
3793 ++ return err;
3794 + }
3795 +
3796 + static inline int splice_branch(struct inode *inode,
3797 +diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
3798 +index 66f699e18755..2b9e139a2997 100644
3799 +--- a/fs/nfs/pnfs.c
3800 ++++ b/fs/nfs/pnfs.c
3801 +@@ -1181,31 +1181,27 @@ out:
3802 + return status;
3803 + }
3804 +
3805 ++static bool
3806 ++pnfs_layout_segments_returnable(struct pnfs_layout_hdr *lo,
3807 ++ enum pnfs_iomode iomode,
3808 ++ u32 seq)
3809 ++{
3810 ++ struct pnfs_layout_range recall_range = {
3811 ++ .length = NFS4_MAX_UINT64,
3812 ++ .iomode = iomode,
3813 ++ };
3814 ++ return pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs,
3815 ++ &recall_range, seq) != -EBUSY;
3816 ++}
3817 ++
3818 + /* Return true if layoutreturn is needed */
3819 + static bool
3820 + pnfs_layout_need_return(struct pnfs_layout_hdr *lo)
3821 + {
3822 +- struct pnfs_layout_segment *s;
3823 +- enum pnfs_iomode iomode;
3824 +- u32 seq;
3825 +-
3826 + if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags))
3827 + return false;
3828 +-
3829 +- seq = lo->plh_return_seq;
3830 +- iomode = lo->plh_return_iomode;
3831 +-
3832 +- /* Defer layoutreturn until all recalled lsegs are done */
3833 +- list_for_each_entry(s, &lo->plh_segs, pls_list) {
3834 +- if (seq && pnfs_seqid_is_newer(s->pls_seq, seq))
3835 +- continue;
3836 +- if (iomode != IOMODE_ANY && s->pls_range.iomode != iomode)
3837 +- continue;
3838 +- if (test_bit(NFS_LSEG_LAYOUTRETURN, &s->pls_flags))
3839 +- return false;
3840 +- }
3841 +-
3842 +- return true;
3843 ++ return pnfs_layout_segments_returnable(lo, lo->plh_return_iomode,
3844 ++ lo->plh_return_seq);
3845 + }
3846 +
3847 + static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo)
3848 +@@ -2291,16 +2287,6 @@ out_forget:
3849 + return ERR_PTR(-EAGAIN);
3850 + }
3851 +
3852 +-static int
3853 +-mark_lseg_invalid_or_return(struct pnfs_layout_segment *lseg,
3854 +- struct list_head *tmp_list)
3855 +-{
3856 +- if (!mark_lseg_invalid(lseg, tmp_list))
3857 +- return 0;
3858 +- pnfs_cache_lseg_for_layoutreturn(lseg->pls_layout, lseg);
3859 +- return 1;
3860 +-}
3861 +-
3862 + /**
3863 + * pnfs_mark_matching_lsegs_return - Free or return matching layout segments
3864 + * @lo: pointer to layout header
3865 +@@ -2337,7 +2323,7 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
3866 + lseg, lseg->pls_range.iomode,
3867 + lseg->pls_range.offset,
3868 + lseg->pls_range.length);
3869 +- if (mark_lseg_invalid_or_return(lseg, tmp_list))
3870 ++ if (mark_lseg_invalid(lseg, tmp_list))
3871 + continue;
3872 + remaining++;
3873 + set_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags);
3874 +diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
3875 +index c141b06811a6..8149fb6f1f0d 100644
3876 +--- a/fs/ocfs2/dlmglue.c
3877 ++++ b/fs/ocfs2/dlmglue.c
3878 +@@ -2867,9 +2867,15 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)
3879 +
3880 + status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE,
3881 + 0, 0);
3882 +- if (status < 0)
3883 ++ if (status < 0) {
3884 + mlog(ML_ERROR, "lock on nfs sync lock failed %d\n", status);
3885 +
3886 ++ if (ex)
3887 ++ up_write(&osb->nfs_sync_rwlock);
3888 ++ else
3889 ++ up_read(&osb->nfs_sync_rwlock);
3890 ++ }
3891 ++
3892 + return status;
3893 + }
3894 +
3895 +diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
3896 +index dcd9c3163587..2197bf68f278 100644
3897 +--- a/fs/pstore/platform.c
3898 ++++ b/fs/pstore/platform.c
3899 +@@ -250,6 +250,9 @@ static int pstore_compress(const void *in, void *out,
3900 + {
3901 + int ret;
3902 +
3903 ++ if (!IS_ENABLED(CONFIG_PSTORE_COMPRESSION))
3904 ++ return -EINVAL;
3905 ++
3906 + ret = crypto_comp_compress(tfm, in, inlen, out, &outlen);
3907 + if (ret) {
3908 + pr_err("crypto_comp_compress failed, ret = %d!\n", ret);
3909 +@@ -647,7 +650,7 @@ static void decompress_record(struct pstore_record *record)
3910 + int unzipped_len;
3911 + char *decompressed;
3912 +
3913 +- if (!record->compressed)
3914 ++ if (!IS_ENABLED(CONFIG_PSTORE_COMPRESSION) || !record->compressed)
3915 + return;
3916 +
3917 + /* Only PSTORE_TYPE_DMESG support compression. */
3918 +diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c
3919 +index e1d11f3223e3..f84a58e523bc 100644
3920 +--- a/fs/xfs/scrub/bmap.c
3921 ++++ b/fs/xfs/scrub/bmap.c
3922 +@@ -53,9 +53,27 @@ xchk_setup_inode_bmap(
3923 + */
3924 + if (S_ISREG(VFS_I(sc->ip)->i_mode) &&
3925 + sc->sm->sm_type == XFS_SCRUB_TYPE_BMBTD) {
3926 ++ struct address_space *mapping = VFS_I(sc->ip)->i_mapping;
3927 ++
3928 + inode_dio_wait(VFS_I(sc->ip));
3929 +- error = filemap_write_and_wait(VFS_I(sc->ip)->i_mapping);
3930 +- if (error)
3931 ++
3932 ++ /*
3933 ++ * Try to flush all incore state to disk before we examine the
3934 ++ * space mappings for the data fork. Leave accumulated errors
3935 ++ * in the mapping for the writer threads to consume.
3936 ++ *
3937 ++ * On ENOSPC or EIO writeback errors, we continue into the
3938 ++ * extent mapping checks because write failures do not
3939 ++ * necessarily imply anything about the correctness of the file
3940 ++ * metadata. The metadata and the file data could be on
3941 ++ * completely separate devices; a media failure might only
3942 ++ * affect a subset of the disk, etc. We can handle delalloc
3943 ++ * extents in the scrubber, so leaving them in memory is fine.
3944 ++ */
3945 ++ error = filemap_fdatawrite(mapping);
3946 ++ if (!error)
3947 ++ error = filemap_fdatawait_keep_errors(mapping);
3948 ++ if (error && (error != -ENOSPC && error != -EIO))
3949 + goto out;
3950 + }
3951 +
3952 +diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
3953 +index 6622652a85a8..0b159a79a17c 100644
3954 +--- a/fs/xfs/xfs_reflink.c
3955 ++++ b/fs/xfs/xfs_reflink.c
3956 +@@ -1010,6 +1010,7 @@ xfs_reflink_remap_extent(
3957 + xfs_filblks_t rlen;
3958 + xfs_filblks_t unmap_len;
3959 + xfs_off_t newlen;
3960 ++ int64_t qres;
3961 + int error;
3962 +
3963 + unmap_len = irec->br_startoff + irec->br_blockcount - destoff;
3964 +@@ -1032,13 +1033,19 @@ xfs_reflink_remap_extent(
3965 + xfs_ilock(ip, XFS_ILOCK_EXCL);
3966 + xfs_trans_ijoin(tp, ip, 0);
3967 +
3968 +- /* If we're not just clearing space, then do we have enough quota? */
3969 +- if (real_extent) {
3970 +- error = xfs_trans_reserve_quota_nblks(tp, ip,
3971 +- irec->br_blockcount, 0, XFS_QMOPT_RES_REGBLKS);
3972 +- if (error)
3973 +- goto out_cancel;
3974 +- }
3975 ++ /*
3976 ++ * Reserve quota for this operation. We don't know if the first unmap
3977 ++ * in the dest file will cause a bmap btree split, so we always reserve
3978 ++ * at least enough blocks for that split. If the extent being mapped
3979 ++ * in is written, we need to reserve quota for that too.
3980 ++ */
3981 ++ qres = XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK);
3982 ++ if (real_extent)
3983 ++ qres += irec->br_blockcount;
3984 ++ error = xfs_trans_reserve_quota_nblks(tp, ip, qres, 0,
3985 ++ XFS_QMOPT_RES_REGBLKS);
3986 ++ if (error)
3987 ++ goto out_cancel;
3988 +
3989 + trace_xfs_reflink_remap(ip, irec->br_startoff,
3990 + irec->br_blockcount, irec->br_startblock);
3991 +diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
3992 +index 95479f35e239..4976f4d30f55 100644
3993 +--- a/include/asm-generic/vmlinux.lds.h
3994 ++++ b/include/asm-generic/vmlinux.lds.h
3995 +@@ -307,6 +307,7 @@
3996 + */
3997 + #ifndef RO_AFTER_INIT_DATA
3998 + #define RO_AFTER_INIT_DATA \
3999 ++ . = ALIGN(8); \
4000 + __start_ro_after_init = .; \
4001 + *(.data..ro_after_init) \
4002 + __end_ro_after_init = .;
4003 +diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
4004 +index 3f1ef4450a7c..775cd10c04b0 100644
4005 +--- a/include/linux/bitfield.h
4006 ++++ b/include/linux/bitfield.h
4007 +@@ -72,7 +72,7 @@
4008 + */
4009 + #define FIELD_FIT(_mask, _val) \
4010 + ({ \
4011 +- __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_FIT: "); \
4012 ++ __BF_FIELD_CHECK(_mask, 0ULL, 0ULL, "FIELD_FIT: "); \
4013 + !((((typeof(_mask))_val) << __bf_shf(_mask)) & ~(_mask)); \
4014 + })
4015 +
4016 +diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
4017 +index e9de8ad0bad7..444aa73037f1 100644
4018 +--- a/include/linux/tracepoint.h
4019 ++++ b/include/linux/tracepoint.h
4020 +@@ -364,7 +364,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
4021 + static const char *___tp_str __tracepoint_string = str; \
4022 + ___tp_str; \
4023 + })
4024 +-#define __tracepoint_string __attribute__((section("__tracepoint_str")))
4025 ++#define __tracepoint_string __attribute__((section("__tracepoint_str"), used))
4026 + #else
4027 + /*
4028 + * tracepoint_string() is used to save the string address for userspace
4029 +diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
4030 +index 371b3b45fd5c..2d5220ab0600 100644
4031 +--- a/include/net/inet_connection_sock.h
4032 ++++ b/include/net/inet_connection_sock.h
4033 +@@ -313,5 +313,9 @@ int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname,
4034 + int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname,
4035 + char __user *optval, unsigned int optlen);
4036 +
4037 ++/* update the fast reuse flag when adding a socket */
4038 ++void inet_csk_update_fastreuse(struct inet_bind_bucket *tb,
4039 ++ struct sock *sk);
4040 ++
4041 + struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu);
4042 + #endif /* _INET_CONNECTION_SOCK_H */
4043 +diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
4044 +index af0ede9ad4d0..c31e54a41b5c 100644
4045 +--- a/include/net/ip_vs.h
4046 ++++ b/include/net/ip_vs.h
4047 +@@ -1614,18 +1614,16 @@ static inline void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp)
4048 + }
4049 + #endif /* CONFIG_IP_VS_NFCT */
4050 +
4051 +-/* Really using conntrack? */
4052 +-static inline bool ip_vs_conn_uses_conntrack(struct ip_vs_conn *cp,
4053 +- struct sk_buff *skb)
4054 ++/* Using old conntrack that can not be redirected to another real server? */
4055 ++static inline bool ip_vs_conn_uses_old_conntrack(struct ip_vs_conn *cp,
4056 ++ struct sk_buff *skb)
4057 + {
4058 + #ifdef CONFIG_IP_VS_NFCT
4059 + enum ip_conntrack_info ctinfo;
4060 + struct nf_conn *ct;
4061 +
4062 +- if (!(cp->flags & IP_VS_CONN_F_NFCT))
4063 +- return false;
4064 + ct = nf_ct_get(skb, &ctinfo);
4065 +- if (ct)
4066 ++ if (ct && nf_ct_is_confirmed(ct))
4067 + return true;
4068 + #endif
4069 + return false;
4070 +diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
4071 +index 6ae98c714edd..2a879d34bbe5 100644
4072 +--- a/kernel/cgroup/cgroup.c
4073 ++++ b/kernel/cgroup/cgroup.c
4074 +@@ -5957,6 +5957,8 @@ void cgroup_sk_clone(struct sock_cgroup_data *skcd)
4075 + {
4076 + /* Socket clone path */
4077 + if (skcd->val) {
4078 ++ if (skcd->no_refcnt)
4079 ++ return;
4080 + /*
4081 + * We might be cloning a socket which is left in an empty
4082 + * cgroup and the cgroup might have already been rmdir'd.
4083 +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
4084 +index d8c249e6dcb7..696d08a4593e 100644
4085 +--- a/kernel/sched/fair.c
4086 ++++ b/kernel/sched/fair.c
4087 +@@ -9208,7 +9208,12 @@ static void kick_ilb(unsigned int flags)
4088 + {
4089 + int ilb_cpu;
4090 +
4091 +- nohz.next_balance++;
4092 ++ /*
4093 ++ * Increase nohz.next_balance only when if full ilb is triggered but
4094 ++ * not if we only update stats.
4095 ++ */
4096 ++ if (flags & NOHZ_BALANCE_KICK)
4097 ++ nohz.next_balance = jiffies+1;
4098 +
4099 + ilb_cpu = find_new_ilb();
4100 +
4101 +@@ -9503,6 +9508,14 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags,
4102 + }
4103 + }
4104 +
4105 ++ /*
4106 ++ * next_balance will be updated only when there is a need.
4107 ++ * When the CPU is attached to null domain for ex, it will not be
4108 ++ * updated.
4109 ++ */
4110 ++ if (likely(update_next_balance))
4111 ++ nohz.next_balance = next_balance;
4112 ++
4113 + /* Newly idle CPU doesn't need an update */
4114 + if (idle != CPU_NEWLY_IDLE) {
4115 + update_blocked_averages(this_cpu);
4116 +@@ -9523,14 +9536,6 @@ abort:
4117 + if (has_blocked_load)
4118 + WRITE_ONCE(nohz.has_blocked, 1);
4119 +
4120 +- /*
4121 +- * next_balance will be updated only when there is a need.
4122 +- * When the CPU is attached to null domain for ex, it will not be
4123 +- * updated.
4124 +- */
4125 +- if (likely(update_next_balance))
4126 +- nohz.next_balance = next_balance;
4127 +-
4128 + return ret;
4129 + }
4130 +
4131 +diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
4132 +index 74b694392f2f..f58efa5cc647 100644
4133 +--- a/kernel/sched/topology.c
4134 ++++ b/kernel/sched/topology.c
4135 +@@ -1098,7 +1098,7 @@ sd_init(struct sched_domain_topology_level *tl,
4136 + sd_flags = (*tl->sd_flags)();
4137 + if (WARN_ONCE(sd_flags & ~TOPOLOGY_SD_FLAGS,
4138 + "wrong sd_flags in topology description\n"))
4139 +- sd_flags &= ~TOPOLOGY_SD_FLAGS;
4140 ++ sd_flags &= TOPOLOGY_SD_FLAGS;
4141 +
4142 + *sd = (struct sched_domain){
4143 + .min_interval = sd_weight,
4144 +diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
4145 +index dbf2b457e47e..9305ff43fc15 100644
4146 +--- a/lib/dynamic_debug.c
4147 ++++ b/lib/dynamic_debug.c
4148 +@@ -85,22 +85,22 @@ static struct { unsigned flag:8; char opt_char; } opt_array[] = {
4149 + { _DPRINTK_FLAGS_NONE, '_' },
4150 + };
4151 +
4152 ++struct flagsbuf { char buf[ARRAY_SIZE(opt_array)+1]; };
4153 ++
4154 + /* format a string into buf[] which describes the _ddebug's flags */
4155 +-static char *ddebug_describe_flags(struct _ddebug *dp, char *buf,
4156 +- size_t maxlen)
4157 ++static char *ddebug_describe_flags(unsigned int flags, struct flagsbuf *fb)
4158 + {
4159 +- char *p = buf;
4160 ++ char *p = fb->buf;
4161 + int i;
4162 +
4163 +- BUG_ON(maxlen < 6);
4164 + for (i = 0; i < ARRAY_SIZE(opt_array); ++i)
4165 +- if (dp->flags & opt_array[i].flag)
4166 ++ if (flags & opt_array[i].flag)
4167 + *p++ = opt_array[i].opt_char;
4168 +- if (p == buf)
4169 ++ if (p == fb->buf)
4170 + *p++ = '_';
4171 + *p = '\0';
4172 +
4173 +- return buf;
4174 ++ return fb->buf;
4175 + }
4176 +
4177 + #define vpr_info(fmt, ...) \
4178 +@@ -142,7 +142,7 @@ static int ddebug_change(const struct ddebug_query *query,
4179 + struct ddebug_table *dt;
4180 + unsigned int newflags;
4181 + unsigned int nfound = 0;
4182 +- char flagbuf[10];
4183 ++ struct flagsbuf fbuf;
4184 +
4185 + /* search for matching ddebugs */
4186 + mutex_lock(&ddebug_lock);
4187 +@@ -199,8 +199,7 @@ static int ddebug_change(const struct ddebug_query *query,
4188 + vpr_info("changed %s:%d [%s]%s =%s\n",
4189 + trim_prefix(dp->filename), dp->lineno,
4190 + dt->mod_name, dp->function,
4191 +- ddebug_describe_flags(dp, flagbuf,
4192 +- sizeof(flagbuf)));
4193 ++ ddebug_describe_flags(dp->flags, &fbuf));
4194 + }
4195 + }
4196 + mutex_unlock(&ddebug_lock);
4197 +@@ -779,7 +778,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
4198 + {
4199 + struct ddebug_iter *iter = m->private;
4200 + struct _ddebug *dp = p;
4201 +- char flagsbuf[10];
4202 ++ struct flagsbuf flags;
4203 +
4204 + vpr_info("called m=%p p=%p\n", m, p);
4205 +
4206 +@@ -792,7 +791,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
4207 + seq_printf(m, "%s:%u [%s]%s =%s \"",
4208 + trim_prefix(dp->filename), dp->lineno,
4209 + iter->table->mod_name, dp->function,
4210 +- ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf)));
4211 ++ ddebug_describe_flags(dp->flags, &flags));
4212 + seq_escape(m, dp->format, "\t\r\n\"");
4213 + seq_puts(m, "\"\n");
4214 +
4215 +diff --git a/mm/mmap.c b/mm/mmap.c
4216 +index a98f09b83019..e84fd3347a51 100644
4217 +--- a/mm/mmap.c
4218 ++++ b/mm/mmap.c
4219 +@@ -3100,6 +3100,7 @@ void exit_mmap(struct mm_struct *mm)
4220 + if (vma->vm_flags & VM_ACCOUNT)
4221 + nr_accounted += vma_pages(vma);
4222 + vma = remove_vma(vma);
4223 ++ cond_resched();
4224 + }
4225 + vm_unacct_memory(nr_accounted);
4226 + }
4227 +diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
4228 +index 357475cceec6..9a75f9b00b51 100644
4229 +--- a/net/bluetooth/6lowpan.c
4230 ++++ b/net/bluetooth/6lowpan.c
4231 +@@ -57,6 +57,7 @@ static bool enable_6lowpan;
4232 + /* We are listening incoming connections via this channel
4233 + */
4234 + static struct l2cap_chan *listen_chan;
4235 ++static DEFINE_MUTEX(set_lock);
4236 +
4237 + struct lowpan_peer {
4238 + struct list_head list;
4239 +@@ -1082,12 +1083,14 @@ static void do_enable_set(struct work_struct *work)
4240 +
4241 + enable_6lowpan = set_enable->flag;
4242 +
4243 ++ mutex_lock(&set_lock);
4244 + if (listen_chan) {
4245 + l2cap_chan_close(listen_chan, 0);
4246 + l2cap_chan_put(listen_chan);
4247 + }
4248 +
4249 + listen_chan = bt_6lowpan_listen();
4250 ++ mutex_unlock(&set_lock);
4251 +
4252 + kfree(set_enable);
4253 + }
4254 +@@ -1139,11 +1142,13 @@ static ssize_t lowpan_control_write(struct file *fp,
4255 + if (ret == -EINVAL)
4256 + return ret;
4257 +
4258 ++ mutex_lock(&set_lock);
4259 + if (listen_chan) {
4260 + l2cap_chan_close(listen_chan, 0);
4261 + l2cap_chan_put(listen_chan);
4262 + listen_chan = NULL;
4263 + }
4264 ++ mutex_unlock(&set_lock);
4265 +
4266 + if (conn) {
4267 + struct lowpan_peer *peer;
4268 +diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
4269 +index ddbe58f0d597..534e2598981d 100644
4270 +--- a/net/ipv4/inet_connection_sock.c
4271 ++++ b/net/ipv4/inet_connection_sock.c
4272 +@@ -285,51 +285,12 @@ static inline int sk_reuseport_match(struct inet_bind_bucket *tb,
4273 + ipv6_only_sock(sk), true, false);
4274 + }
4275 +
4276 +-/* Obtain a reference to a local port for the given sock,
4277 +- * if snum is zero it means select any available local port.
4278 +- * We try to allocate an odd port (and leave even ports for connect())
4279 +- */
4280 +-int inet_csk_get_port(struct sock *sk, unsigned short snum)
4281 ++void inet_csk_update_fastreuse(struct inet_bind_bucket *tb,
4282 ++ struct sock *sk)
4283 + {
4284 +- bool reuse = sk->sk_reuse && sk->sk_state != TCP_LISTEN;
4285 +- struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo;
4286 +- int ret = 1, port = snum;
4287 +- struct inet_bind_hashbucket *head;
4288 +- struct net *net = sock_net(sk);
4289 +- struct inet_bind_bucket *tb = NULL;
4290 + kuid_t uid = sock_i_uid(sk);
4291 ++ bool reuse = sk->sk_reuse && sk->sk_state != TCP_LISTEN;
4292 +
4293 +- if (!port) {
4294 +- head = inet_csk_find_open_port(sk, &tb, &port);
4295 +- if (!head)
4296 +- return ret;
4297 +- if (!tb)
4298 +- goto tb_not_found;
4299 +- goto success;
4300 +- }
4301 +- head = &hinfo->bhash[inet_bhashfn(net, port,
4302 +- hinfo->bhash_size)];
4303 +- spin_lock_bh(&head->lock);
4304 +- inet_bind_bucket_for_each(tb, &head->chain)
4305 +- if (net_eq(ib_net(tb), net) && tb->port == port)
4306 +- goto tb_found;
4307 +-tb_not_found:
4308 +- tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep,
4309 +- net, head, port);
4310 +- if (!tb)
4311 +- goto fail_unlock;
4312 +-tb_found:
4313 +- if (!hlist_empty(&tb->owners)) {
4314 +- if (sk->sk_reuse == SK_FORCE_REUSE)
4315 +- goto success;
4316 +-
4317 +- if ((tb->fastreuse > 0 && reuse) ||
4318 +- sk_reuseport_match(tb, sk))
4319 +- goto success;
4320 +- if (inet_csk_bind_conflict(sk, tb, true, true))
4321 +- goto fail_unlock;
4322 +- }
4323 +-success:
4324 + if (hlist_empty(&tb->owners)) {
4325 + tb->fastreuse = reuse;
4326 + if (sk->sk_reuseport) {
4327 +@@ -373,6 +334,54 @@ success:
4328 + tb->fastreuseport = 0;
4329 + }
4330 + }
4331 ++}
4332 ++
4333 ++/* Obtain a reference to a local port for the given sock,
4334 ++ * if snum is zero it means select any available local port.
4335 ++ * We try to allocate an odd port (and leave even ports for connect())
4336 ++ */
4337 ++int inet_csk_get_port(struct sock *sk, unsigned short snum)
4338 ++{
4339 ++ bool reuse = sk->sk_reuse && sk->sk_state != TCP_LISTEN;
4340 ++ struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo;
4341 ++ int ret = 1, port = snum;
4342 ++ struct inet_bind_hashbucket *head;
4343 ++ struct net *net = sock_net(sk);
4344 ++ struct inet_bind_bucket *tb = NULL;
4345 ++
4346 ++ if (!port) {
4347 ++ head = inet_csk_find_open_port(sk, &tb, &port);
4348 ++ if (!head)
4349 ++ return ret;
4350 ++ if (!tb)
4351 ++ goto tb_not_found;
4352 ++ goto success;
4353 ++ }
4354 ++ head = &hinfo->bhash[inet_bhashfn(net, port,
4355 ++ hinfo->bhash_size)];
4356 ++ spin_lock_bh(&head->lock);
4357 ++ inet_bind_bucket_for_each(tb, &head->chain)
4358 ++ if (net_eq(ib_net(tb), net) && tb->port == port)
4359 ++ goto tb_found;
4360 ++tb_not_found:
4361 ++ tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep,
4362 ++ net, head, port);
4363 ++ if (!tb)
4364 ++ goto fail_unlock;
4365 ++tb_found:
4366 ++ if (!hlist_empty(&tb->owners)) {
4367 ++ if (sk->sk_reuse == SK_FORCE_REUSE)
4368 ++ goto success;
4369 ++
4370 ++ if ((tb->fastreuse > 0 && reuse) ||
4371 ++ sk_reuseport_match(tb, sk))
4372 ++ goto success;
4373 ++ if (inet_csk_bind_conflict(sk, tb, true, true))
4374 ++ goto fail_unlock;
4375 ++ }
4376 ++success:
4377 ++ inet_csk_update_fastreuse(tb, sk);
4378 ++
4379 + if (!inet_csk(sk)->icsk_bind_hash)
4380 + inet_bind_hash(sk, tb, port);
4381 + WARN_ON(inet_csk(sk)->icsk_bind_hash != tb);
4382 +diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
4383 +index b53da2691adb..3a5f12f011cb 100644
4384 +--- a/net/ipv4/inet_hashtables.c
4385 ++++ b/net/ipv4/inet_hashtables.c
4386 +@@ -161,6 +161,7 @@ int __inet_inherit_port(const struct sock *sk, struct sock *child)
4387 + return -ENOMEM;
4388 + }
4389 + }
4390 ++ inet_csk_update_fastreuse(tb, child);
4391 + }
4392 + inet_bind_hash(child, tb, port);
4393 + spin_unlock(&head->lock);
4394 +diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
4395 +index a71f777d1353..d5e4329579e2 100644
4396 +--- a/net/netfilter/ipvs/ip_vs_core.c
4397 ++++ b/net/netfilter/ipvs/ip_vs_core.c
4398 +@@ -1928,14 +1928,14 @@ ip_vs_in(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, int
4399 +
4400 + conn_reuse_mode = sysctl_conn_reuse_mode(ipvs);
4401 + if (conn_reuse_mode && !iph.fragoffs && is_new_conn(skb, &iph) && cp) {
4402 +- bool uses_ct = false, resched = false;
4403 ++ bool old_ct = false, resched = false;
4404 +
4405 + if (unlikely(sysctl_expire_nodest_conn(ipvs)) && cp->dest &&
4406 + unlikely(!atomic_read(&cp->dest->weight))) {
4407 + resched = true;
4408 +- uses_ct = ip_vs_conn_uses_conntrack(cp, skb);
4409 ++ old_ct = ip_vs_conn_uses_old_conntrack(cp, skb);
4410 + } else if (is_new_conn_expected(cp, conn_reuse_mode)) {
4411 +- uses_ct = ip_vs_conn_uses_conntrack(cp, skb);
4412 ++ old_ct = ip_vs_conn_uses_old_conntrack(cp, skb);
4413 + if (!atomic_read(&cp->n_control)) {
4414 + resched = true;
4415 + } else {
4416 +@@ -1943,15 +1943,17 @@ ip_vs_in(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, int
4417 + * that uses conntrack while it is still
4418 + * referenced by controlled connection(s).
4419 + */
4420 +- resched = !uses_ct;
4421 ++ resched = !old_ct;
4422 + }
4423 + }
4424 +
4425 + if (resched) {
4426 ++ if (!old_ct)
4427 ++ cp->flags &= ~IP_VS_CONN_F_NFCT;
4428 + if (!atomic_read(&cp->n_control))
4429 + ip_vs_conn_expire_now(cp);
4430 + __ip_vs_conn_put(cp);
4431 +- if (uses_ct)
4432 ++ if (old_ct)
4433 + return NF_DROP;
4434 + cp = NULL;
4435 + }
4436 +diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
4437 +index e2188deb08dc..b927730d9ab0 100644
4438 +--- a/net/nfc/rawsock.c
4439 ++++ b/net/nfc/rawsock.c
4440 +@@ -344,10 +344,13 @@ static int rawsock_create(struct net *net, struct socket *sock,
4441 + if ((sock->type != SOCK_SEQPACKET) && (sock->type != SOCK_RAW))
4442 + return -ESOCKTNOSUPPORT;
4443 +
4444 +- if (sock->type == SOCK_RAW)
4445 ++ if (sock->type == SOCK_RAW) {
4446 ++ if (!capable(CAP_NET_RAW))
4447 ++ return -EPERM;
4448 + sock->ops = &rawsock_raw_ops;
4449 +- else
4450 ++ } else {
4451 + sock->ops = &rawsock_ops;
4452 ++ }
4453 +
4454 + sk = sk_alloc(net, PF_NFC, GFP_ATOMIC, nfc_proto->proto, kern);
4455 + if (!sk)
4456 +diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
4457 +index 0e029aefa707..b3caf1eac6af 100644
4458 +--- a/net/packet/af_packet.c
4459 ++++ b/net/packet/af_packet.c
4460 +@@ -949,6 +949,7 @@ static int prb_queue_frozen(struct tpacket_kbdq_core *pkc)
4461 + }
4462 +
4463 + static void prb_clear_blk_fill_status(struct packet_ring_buffer *rb)
4464 ++ __releases(&pkc->blk_fill_in_prog_lock)
4465 + {
4466 + struct tpacket_kbdq_core *pkc = GET_PBDQC_FROM_RB(rb);
4467 + atomic_dec(&pkc->blk_fill_in_prog);
4468 +@@ -996,6 +997,7 @@ static void prb_fill_curr_block(char *curr,
4469 + struct tpacket_kbdq_core *pkc,
4470 + struct tpacket_block_desc *pbd,
4471 + unsigned int len)
4472 ++ __acquires(&pkc->blk_fill_in_prog_lock)
4473 + {
4474 + struct tpacket3_hdr *ppd;
4475 +
4476 +@@ -2272,8 +2274,11 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
4477 + if (do_vnet &&
4478 + virtio_net_hdr_from_skb(skb, h.raw + macoff -
4479 + sizeof(struct virtio_net_hdr),
4480 +- vio_le(), true, 0))
4481 ++ vio_le(), true, 0)) {
4482 ++ if (po->tp_version == TPACKET_V3)
4483 ++ prb_clear_blk_fill_status(&po->rx_ring);
4484 + goto drop_n_account;
4485 ++ }
4486 +
4487 + if (po->tp_version <= TPACKET_V2) {
4488 + packet_increment_rx_head(po, &po->rx_ring);
4489 +@@ -2379,7 +2384,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
4490 + __clear_bit(slot_id, po->rx_ring.rx_owner_map);
4491 + spin_unlock(&sk->sk_receive_queue.lock);
4492 + sk->sk_data_ready(sk);
4493 +- } else {
4494 ++ } else if (po->tp_version == TPACKET_V3) {
4495 + prb_clear_blk_fill_status(&po->rx_ring);
4496 + }
4497 +
4498 +diff --git a/net/socket.c b/net/socket.c
4499 +index 1030a612423b..29169045dcfe 100644
4500 +--- a/net/socket.c
4501 ++++ b/net/socket.c
4502 +@@ -474,7 +474,7 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed)
4503 + if (f.file) {
4504 + sock = sock_from_file(f.file, err);
4505 + if (likely(sock)) {
4506 +- *fput_needed = f.flags;
4507 ++ *fput_needed = f.flags & FDPUT_FPUT;
4508 + return sock;
4509 + }
4510 + fdput(f);
4511 +diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c
4512 +index 4fc0ce127089..22f135263815 100644
4513 +--- a/net/sunrpc/xprtrdma/svc_rdma_rw.c
4514 ++++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c
4515 +@@ -679,7 +679,6 @@ static int svc_rdma_build_read_chunk(struct svc_rqst *rqstp,
4516 + struct svc_rdma_read_info *info,
4517 + __be32 *p)
4518 + {
4519 +- unsigned int i;
4520 + int ret;
4521 +
4522 + ret = -EINVAL;
4523 +@@ -702,12 +701,6 @@ static int svc_rdma_build_read_chunk(struct svc_rqst *rqstp,
4524 + info->ri_chunklen += rs_length;
4525 + }
4526 +
4527 +- /* Pages under I/O have been copied to head->rc_pages.
4528 +- * Prevent their premature release by svc_xprt_release() .
4529 +- */
4530 +- for (i = 0; i < info->ri_readctxt->rc_page_count; i++)
4531 +- rqstp->rq_pages[i] = NULL;
4532 +-
4533 + return ret;
4534 + }
4535 +
4536 +@@ -802,6 +795,26 @@ out:
4537 + return ret;
4538 + }
4539 +
4540 ++/* Pages under I/O have been copied to head->rc_pages. Ensure they
4541 ++ * are not released by svc_xprt_release() until the I/O is complete.
4542 ++ *
4543 ++ * This has to be done after all Read WRs are constructed to properly
4544 ++ * handle a page that is part of I/O on behalf of two different RDMA
4545 ++ * segments.
4546 ++ *
4547 ++ * Do this only if I/O has been posted. Otherwise, we do indeed want
4548 ++ * svc_xprt_release() to clean things up properly.
4549 ++ */
4550 ++static void svc_rdma_save_io_pages(struct svc_rqst *rqstp,
4551 ++ const unsigned int start,
4552 ++ const unsigned int num_pages)
4553 ++{
4554 ++ unsigned int i;
4555 ++
4556 ++ for (i = start; i < num_pages + start; i++)
4557 ++ rqstp->rq_pages[i] = NULL;
4558 ++}
4559 ++
4560 + /**
4561 + * svc_rdma_recv_read_chunk - Pull a Read chunk from the client
4562 + * @rdma: controlling RDMA transport
4563 +@@ -855,6 +868,7 @@ int svc_rdma_recv_read_chunk(struct svcxprt_rdma *rdma, struct svc_rqst *rqstp,
4564 + ret = svc_rdma_post_chunk_ctxt(&info->ri_cc);
4565 + if (ret < 0)
4566 + goto out_err;
4567 ++ svc_rdma_save_io_pages(rqstp, 0, head->rc_page_count);
4568 + return 0;
4569 +
4570 + out_err:
4571 +diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
4572 +index 8f40bbfd60ea..575d62130578 100644
4573 +--- a/net/tls/tls_device.c
4574 ++++ b/net/tls/tls_device.c
4575 +@@ -476,7 +476,7 @@ int tls_device_sendpage(struct sock *sk, struct page *page,
4576 + int offset, size_t size, int flags)
4577 + {
4578 + struct iov_iter msg_iter;
4579 +- char *kaddr = kmap(page);
4580 ++ char *kaddr;
4581 + struct kvec iov;
4582 + int rc;
4583 +
4584 +@@ -490,6 +490,7 @@ int tls_device_sendpage(struct sock *sk, struct page *page,
4585 + goto out;
4586 + }
4587 +
4588 ++ kaddr = kmap(page);
4589 + iov.iov_base = kaddr + offset;
4590 + iov.iov_len = size;
4591 + iov_iter_kvec(&msg_iter, WRITE | ITER_KVEC, &iov, 1, size);
4592 +diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
4593 +index 10ee51d04492..accd3846f1e3 100644
4594 +--- a/security/smack/smackfs.c
4595 ++++ b/security/smack/smackfs.c
4596 +@@ -912,7 +912,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
4597 + }
4598 +
4599 + ret = sscanf(rule, "%d", &maplevel);
4600 +- if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL)
4601 ++ if (ret != 1 || maplevel < 0 || maplevel > SMACK_CIPSO_MAXLEVEL)
4602 + goto out;
4603 +
4604 + rule += SMK_DIGITLEN;
4605 +@@ -933,6 +933,10 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
4606 +
4607 + for (i = 0; i < catlen; i++) {
4608 + rule += SMK_DIGITLEN;
4609 ++ if (rule > data + count) {
4610 ++ rc = -EOVERFLOW;
4611 ++ goto out;
4612 ++ }
4613 + ret = sscanf(rule, "%u", &cat);
4614 + if (ret != 1 || cat > SMACK_CIPSO_MAXCATNUM)
4615 + goto out;
4616 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
4617 +index fed9df479ef8..9c5b3d19bfa7 100644
4618 +--- a/sound/pci/hda/patch_realtek.c
4619 ++++ b/sound/pci/hda/patch_realtek.c
4620 +@@ -4072,6 +4072,7 @@ static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
4621 + {
4622 + struct alc_spec *spec = codec->spec;
4623 +
4624 ++ spec->micmute_led_polarity = 1;
4625 + alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4626 + if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4627 + spec->init_amp = ALC_INIT_DEFAULT;
4628 +diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c
4629 +index 27308337ab12..ba76e37a4b09 100644
4630 +--- a/sound/soc/intel/boards/bxt_rt298.c
4631 ++++ b/sound/soc/intel/boards/bxt_rt298.c
4632 +@@ -544,6 +544,7 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
4633 + /* broxton audio machine driver for SPT + RT298S */
4634 + static struct snd_soc_card broxton_rt298 = {
4635 + .name = "broxton-rt298",
4636 ++ .owner = THIS_MODULE,
4637 + .dai_link = broxton_rt298_dais,
4638 + .num_links = ARRAY_SIZE(broxton_rt298_dais),
4639 + .controls = broxton_controls,
4640 +@@ -559,6 +560,7 @@ static struct snd_soc_card broxton_rt298 = {
4641 +
4642 + static struct snd_soc_card geminilake_rt298 = {
4643 + .name = "geminilake-rt298",
4644 ++ .owner = THIS_MODULE,
4645 + .dai_link = broxton_rt298_dais,
4646 + .num_links = ARRAY_SIZE(broxton_rt298_dais),
4647 + .controls = broxton_controls,
4648 +diff --git a/sound/soc/meson/axg-tdm-interface.c b/sound/soc/meson/axg-tdm-interface.c
4649 +index 7b8baf46d968..5c055d8de8c7 100644
4650 +--- a/sound/soc/meson/axg-tdm-interface.c
4651 ++++ b/sound/soc/meson/axg-tdm-interface.c
4652 +@@ -111,18 +111,25 @@ static int axg_tdm_iface_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
4653 + {
4654 + struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai);
4655 +
4656 +- /* These modes are not supported */
4657 +- if (fmt & (SND_SOC_DAIFMT_CBS_CFM | SND_SOC_DAIFMT_CBM_CFS)) {
4658 ++ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
4659 ++ case SND_SOC_DAIFMT_CBS_CFS:
4660 ++ if (!iface->mclk) {
4661 ++ dev_err(dai->dev, "cpu clock master: mclk missing\n");
4662 ++ return -ENODEV;
4663 ++ }
4664 ++ break;
4665 ++
4666 ++ case SND_SOC_DAIFMT_CBM_CFM:
4667 ++ break;
4668 ++
4669 ++ case SND_SOC_DAIFMT_CBS_CFM:
4670 ++ case SND_SOC_DAIFMT_CBM_CFS:
4671 + dev_err(dai->dev, "only CBS_CFS and CBM_CFM are supported\n");
4672 ++ /* Fall-through */
4673 ++ default:
4674 + return -EINVAL;
4675 + }
4676 +
4677 +- /* If the TDM interface is the clock master, it requires mclk */
4678 +- if (!iface->mclk && (fmt & SND_SOC_DAIFMT_CBS_CFS)) {
4679 +- dev_err(dai->dev, "cpu clock master: mclk missing\n");
4680 +- return -ENODEV;
4681 +- }
4682 +-
4683 + iface->fmt = fmt;
4684 + return 0;
4685 + }
4686 +@@ -311,7 +318,8 @@ static int axg_tdm_iface_hw_params(struct snd_pcm_substream *substream,
4687 + if (ret)
4688 + return ret;
4689 +
4690 +- if (iface->fmt & SND_SOC_DAIFMT_CBS_CFS) {
4691 ++ if ((iface->fmt & SND_SOC_DAIFMT_MASTER_MASK) ==
4692 ++ SND_SOC_DAIFMT_CBS_CFS) {
4693 + ret = axg_tdm_iface_set_sclk(dai, params);
4694 + if (ret)
4695 + return ret;
4696 +diff --git a/sound/usb/card.h b/sound/usb/card.h
4697 +index 7f11655bde50..f30fec68e2ca 100644
4698 +--- a/sound/usb/card.h
4699 ++++ b/sound/usb/card.h
4700 +@@ -129,6 +129,7 @@ struct snd_usb_substream {
4701 + unsigned int tx_length_quirk:1; /* add length specifier to transfers */
4702 + unsigned int fmt_type; /* USB audio format type (1-3) */
4703 + unsigned int pkt_offset_adj; /* Bytes to drop from beginning of packets (for non-compliant devices) */
4704 ++ unsigned int stream_offset_adj; /* Bytes to drop from beginning of stream (for non-compliant devices) */
4705 +
4706 + unsigned int running: 1; /* running status */
4707 +
4708 +diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
4709 +index 21c1135bb89b..d1328abd1bc4 100644
4710 +--- a/sound/usb/mixer_quirks.c
4711 ++++ b/sound/usb/mixer_quirks.c
4712 +@@ -195,6 +195,7 @@ static const struct rc_config {
4713 + { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */
4714 + { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
4715 + { USB_ID(0x041e, 0x3237), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
4716 ++ { USB_ID(0x041e, 0x3263), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
4717 + { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
4718 + };
4719 +
4720 +diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
4721 +index 8b91be394407..7743e7bc6bf2 100644
4722 +--- a/sound/usb/pcm.c
4723 ++++ b/sound/usb/pcm.c
4724 +@@ -1387,6 +1387,12 @@ static void retire_capture_urb(struct snd_usb_substream *subs,
4725 + // continue;
4726 + }
4727 + bytes = urb->iso_frame_desc[i].actual_length;
4728 ++ if (subs->stream_offset_adj > 0) {
4729 ++ unsigned int adj = min(subs->stream_offset_adj, bytes);
4730 ++ cp += adj;
4731 ++ bytes -= adj;
4732 ++ subs->stream_offset_adj -= adj;
4733 ++ }
4734 + frames = bytes / stride;
4735 + if (!subs->txfr_quirk)
4736 + bytes = frames * stride;
4737 +diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
4738 +index 41a5e38b7870..89b70308b551 100644
4739 +--- a/sound/usb/quirks-table.h
4740 ++++ b/sound/usb/quirks-table.h
4741 +@@ -3419,6 +3419,62 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
4742 + .type = QUIRK_SETUP_FMT_AFTER_RESUME
4743 + }
4744 + },
4745 ++{
4746 ++ /*
4747 ++ * PIONEER DJ DDJ-RB
4748 ++ * PCM is 4 channels out, 2 dummy channels in @ 44.1 fixed
4749 ++ * The feedback for the output is the dummy input.
4750 ++ */
4751 ++ USB_DEVICE_VENDOR_SPEC(0x2b73, 0x000e),
4752 ++ .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
4753 ++ .ifnum = QUIRK_ANY_INTERFACE,
4754 ++ .type = QUIRK_COMPOSITE,
4755 ++ .data = (const struct snd_usb_audio_quirk[]) {
4756 ++ {
4757 ++ .ifnum = 0,
4758 ++ .type = QUIRK_AUDIO_FIXED_ENDPOINT,
4759 ++ .data = &(const struct audioformat) {
4760 ++ .formats = SNDRV_PCM_FMTBIT_S24_3LE,
4761 ++ .channels = 4,
4762 ++ .iface = 0,
4763 ++ .altsetting = 1,
4764 ++ .altset_idx = 1,
4765 ++ .endpoint = 0x01,
4766 ++ .ep_attr = USB_ENDPOINT_XFER_ISOC|
4767 ++ USB_ENDPOINT_SYNC_ASYNC,
4768 ++ .rates = SNDRV_PCM_RATE_44100,
4769 ++ .rate_min = 44100,
4770 ++ .rate_max = 44100,
4771 ++ .nr_rates = 1,
4772 ++ .rate_table = (unsigned int[]) { 44100 }
4773 ++ }
4774 ++ },
4775 ++ {
4776 ++ .ifnum = 0,
4777 ++ .type = QUIRK_AUDIO_FIXED_ENDPOINT,
4778 ++ .data = &(const struct audioformat) {
4779 ++ .formats = SNDRV_PCM_FMTBIT_S24_3LE,
4780 ++ .channels = 2,
4781 ++ .iface = 0,
4782 ++ .altsetting = 1,
4783 ++ .altset_idx = 1,
4784 ++ .endpoint = 0x82,
4785 ++ .ep_attr = USB_ENDPOINT_XFER_ISOC|
4786 ++ USB_ENDPOINT_SYNC_ASYNC|
4787 ++ USB_ENDPOINT_USAGE_IMPLICIT_FB,
4788 ++ .rates = SNDRV_PCM_RATE_44100,
4789 ++ .rate_min = 44100,
4790 ++ .rate_max = 44100,
4791 ++ .nr_rates = 1,
4792 ++ .rate_table = (unsigned int[]) { 44100 }
4793 ++ }
4794 ++ },
4795 ++ {
4796 ++ .ifnum = -1
4797 ++ }
4798 ++ }
4799 ++ }
4800 ++},
4801 +
4802 + #define ALC1220_VB_DESKTOP(vend, prod) { \
4803 + USB_DEVICE(vend, prod), \
4804 +@@ -3472,7 +3528,13 @@ ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* Asrock TRX40 Creator */
4805 + * with.
4806 + */
4807 + {
4808 +- USB_DEVICE(0x534d, 0x2109),
4809 ++ .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
4810 ++ USB_DEVICE_ID_MATCH_INT_CLASS |
4811 ++ USB_DEVICE_ID_MATCH_INT_SUBCLASS,
4812 ++ .idVendor = 0x534d,
4813 ++ .idProduct = 0x2109,
4814 ++ .bInterfaceClass = USB_CLASS_AUDIO,
4815 ++ .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
4816 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
4817 + .vendor_name = "MacroSilicon",
4818 + .product_name = "MS2109",
4819 +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
4820 +index e9ec6166acc6..8d9117312e30 100644
4821 +--- a/sound/usb/quirks.c
4822 ++++ b/sound/usb/quirks.c
4823 +@@ -1166,6 +1166,9 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
4824 + case USB_ID(0x041e, 0x3f19): /* E-Mu 0204 USB */
4825 + set_format_emu_quirk(subs, fmt);
4826 + break;
4827 ++ case USB_ID(0x534d, 0x2109): /* MacroSilicon MS2109 */
4828 ++ subs->stream_offset_adj = 2;
4829 ++ break;
4830 + }
4831 + }
4832 +
4833 +diff --git a/sound/usb/stream.c b/sound/usb/stream.c
4834 +index 9d020bd0de17..ff5d803cfaf0 100644
4835 +--- a/sound/usb/stream.c
4836 ++++ b/sound/usb/stream.c
4837 +@@ -99,6 +99,7 @@ static void snd_usb_init_substream(struct snd_usb_stream *as,
4838 + subs->tx_length_quirk = as->chip->tx_length_quirk;
4839 + subs->speed = snd_usb_get_speed(subs->dev);
4840 + subs->pkt_offset_adj = 0;
4841 ++ subs->stream_offset_adj = 0;
4842 +
4843 + snd_usb_set_pcm_ops(as->pcm, stream);
4844 +
4845 +diff --git a/tools/build/Build.include b/tools/build/Build.include
4846 +index 9ec01f4454f9..585486e40995 100644
4847 +--- a/tools/build/Build.include
4848 ++++ b/tools/build/Build.include
4849 +@@ -74,7 +74,8 @@ dep-cmd = $(if $(wildcard $(fixdep)),
4850 + # dependencies in the cmd file
4851 + if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)), \
4852 + @set -e; \
4853 +- $(echo-cmd) $(cmd_$(1)) && $(dep-cmd))
4854 ++ $(echo-cmd) $(cmd_$(1)); \
4855 ++ $(dep-cmd))
4856 +
4857 + # if_changed - execute command if any prerequisite is newer than
4858 + # target, or command line has changed
4859 +diff --git a/tools/testing/selftests/powerpc/benchmarks/context_switch.c b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
4860 +index 87f1f0252299..9ec7674697b1 100644
4861 +--- a/tools/testing/selftests/powerpc/benchmarks/context_switch.c
4862 ++++ b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
4863 +@@ -23,6 +23,7 @@
4864 + #include <limits.h>
4865 + #include <sys/time.h>
4866 + #include <sys/syscall.h>
4867 ++#include <sys/sysinfo.h>
4868 + #include <sys/types.h>
4869 + #include <sys/shm.h>
4870 + #include <linux/futex.h>
4871 +@@ -108,8 +109,9 @@ static void start_thread_on(void *(*fn)(void *), void *arg, unsigned long cpu)
4872 +
4873 + static void start_process_on(void *(*fn)(void *), void *arg, unsigned long cpu)
4874 + {
4875 +- int pid;
4876 +- cpu_set_t cpuset;
4877 ++ int pid, ncpus;
4878 ++ cpu_set_t *cpuset;
4879 ++ size_t size;
4880 +
4881 + pid = fork();
4882 + if (pid == -1) {
4883 +@@ -120,14 +122,23 @@ static void start_process_on(void *(*fn)(void *), void *arg, unsigned long cpu)
4884 + if (pid)
4885 + return;
4886 +
4887 +- CPU_ZERO(&cpuset);
4888 +- CPU_SET(cpu, &cpuset);
4889 ++ ncpus = get_nprocs();
4890 ++ size = CPU_ALLOC_SIZE(ncpus);
4891 ++ cpuset = CPU_ALLOC(ncpus);
4892 ++ if (!cpuset) {
4893 ++ perror("malloc");
4894 ++ exit(1);
4895 ++ }
4896 ++ CPU_ZERO_S(size, cpuset);
4897 ++ CPU_SET_S(cpu, size, cpuset);
4898 +
4899 +- if (sched_setaffinity(0, sizeof(cpuset), &cpuset)) {
4900 ++ if (sched_setaffinity(0, size, cpuset)) {
4901 + perror("sched_setaffinity");
4902 ++ CPU_FREE(cpuset);
4903 + exit(1);
4904 + }
4905 +
4906 ++ CPU_FREE(cpuset);
4907 + fn(arg);
4908 +
4909 + exit(0);
4910 +diff --git a/tools/testing/selftests/powerpc/utils.c b/tools/testing/selftests/powerpc/utils.c
4911 +index aa8fc1e6365b..ba0959d454b3 100644
4912 +--- a/tools/testing/selftests/powerpc/utils.c
4913 ++++ b/tools/testing/selftests/powerpc/utils.c
4914 +@@ -13,6 +13,7 @@
4915 + #include <stdio.h>
4916 + #include <string.h>
4917 + #include <sys/stat.h>
4918 ++#include <sys/sysinfo.h>
4919 + #include <sys/types.h>
4920 + #include <sys/utsname.h>
4921 + #include <unistd.h>
4922 +@@ -83,28 +84,40 @@ void *get_auxv_entry(int type)
4923 +
4924 + int pick_online_cpu(void)
4925 + {
4926 +- cpu_set_t mask;
4927 +- int cpu;
4928 ++ int ncpus, cpu = -1;
4929 ++ cpu_set_t *mask;
4930 ++ size_t size;
4931 ++
4932 ++ ncpus = get_nprocs_conf();
4933 ++ size = CPU_ALLOC_SIZE(ncpus);
4934 ++ mask = CPU_ALLOC(ncpus);
4935 ++ if (!mask) {
4936 ++ perror("malloc");
4937 ++ return -1;
4938 ++ }
4939 +
4940 +- CPU_ZERO(&mask);
4941 ++ CPU_ZERO_S(size, mask);
4942 +
4943 +- if (sched_getaffinity(0, sizeof(mask), &mask)) {
4944 ++ if (sched_getaffinity(0, size, mask)) {
4945 + perror("sched_getaffinity");
4946 +- return -1;
4947 ++ goto done;
4948 + }
4949 +
4950 + /* We prefer a primary thread, but skip 0 */
4951 +- for (cpu = 8; cpu < CPU_SETSIZE; cpu += 8)
4952 +- if (CPU_ISSET(cpu, &mask))
4953 +- return cpu;
4954 ++ for (cpu = 8; cpu < ncpus; cpu += 8)
4955 ++ if (CPU_ISSET_S(cpu, size, mask))
4956 ++ goto done;
4957 +
4958 + /* Search for anything, but in reverse */
4959 +- for (cpu = CPU_SETSIZE - 1; cpu >= 0; cpu--)
4960 +- if (CPU_ISSET(cpu, &mask))
4961 +- return cpu;
4962 ++ for (cpu = ncpus - 1; cpu >= 0; cpu--)
4963 ++ if (CPU_ISSET_S(cpu, size, mask))
4964 ++ goto done;
4965 +
4966 + printf("No cpus in affinity mask?!\n");
4967 +- return -1;
4968 ++
4969 ++done:
4970 ++ CPU_FREE(mask);
4971 ++ return cpu;
4972 + }
4973 +
4974 + bool is_ppc64le(void)