Gentoo Archives: gentoo-commits

From: Alice Ferrazzi <alicef@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.4 commit in: /
Date: Wed, 19 Aug 2020 09:28:41
Message-Id: 1597829283.9059eacca2ff0577649ea045d1f50f8c63c4b7cb.alicef@gentoo
1 commit: 9059eacca2ff0577649ea045d1f50f8c63c4b7cb
2 Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
3 AuthorDate: Wed Aug 19 09:18:57 2020 +0000
4 Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
5 CommitDate: Wed Aug 19 09:28:03 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=9059eacc
7
8 Linux patch 5.4.59
9
10 Signed-off-by: Alice Ferrazzi <alicef <AT> gentoo.org>
11
12 0000_README | 4 +
13 1058_linux-5.4.59.patch | 9156 +++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 9160 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 6dd92dc..78d0290 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -275,6 +275,10 @@ Patch: 1057_linux-5.4.58.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.4.58
23
24 +Patch: 1058_linux-5.4.59.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.4.59
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/1058_linux-5.4.59.patch b/1058_linux-5.4.59.patch
33 new file mode 100644
34 index 0000000..8a3a375
35 --- /dev/null
36 +++ b/1058_linux-5.4.59.patch
37 @@ -0,0 +1,9156 @@
38 +diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
39 +index 680451695422..c3767d4d01a6 100644
40 +--- a/Documentation/ABI/testing/sysfs-bus-iio
41 ++++ b/Documentation/ABI/testing/sysfs-bus-iio
42 +@@ -1566,7 +1566,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 29948bc4a0d2..cc72b8472f24 100644
54 +--- a/Makefile
55 ++++ b/Makefile
56 +@@ -1,7 +1,7 @@
57 + # SPDX-License-Identifier: GPL-2.0
58 + VERSION = 5
59 + PATCHLEVEL = 4
60 +-SUBLEVEL = 58
61 ++SUBLEVEL = 59
62 + EXTRAVERSION =
63 + NAME = Kleptomaniac Octopus
64 +
65 +diff --git a/arch/arm/boot/dts/r8a7793-gose.dts b/arch/arm/boot/dts/r8a7793-gose.dts
66 +index 42f3313e6988..9f507393c375 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/boot/dts/sunxi-bananapi-m2-plus-v1.2.dtsi b/arch/arm/boot/dts/sunxi-bananapi-m2-plus-v1.2.dtsi
88 +index 22466afd38a3..235994a4a2eb 100644
89 +--- a/arch/arm/boot/dts/sunxi-bananapi-m2-plus-v1.2.dtsi
90 ++++ b/arch/arm/boot/dts/sunxi-bananapi-m2-plus-v1.2.dtsi
91 +@@ -16,15 +16,27 @@
92 + regulator-type = "voltage";
93 + regulator-boot-on;
94 + regulator-always-on;
95 +- regulator-min-microvolt = <1100000>;
96 +- regulator-max-microvolt = <1300000>;
97 ++ regulator-min-microvolt = <1108475>;
98 ++ regulator-max-microvolt = <1308475>;
99 + regulator-ramp-delay = <50>; /* 4ms */
100 + gpios = <&r_pio 0 1 GPIO_ACTIVE_HIGH>; /* PL1 */
101 + gpios-states = <0x1>;
102 +- states = <1100000 0>, <1300000 1>;
103 ++ states = <1108475 0>, <1308475 1>;
104 + };
105 + };
106 +
107 + &cpu0 {
108 + cpu-supply = <&reg_vdd_cpux>;
109 + };
110 ++
111 ++&cpu1 {
112 ++ cpu-supply = <&reg_vdd_cpux>;
113 ++};
114 ++
115 ++&cpu2 {
116 ++ cpu-supply = <&reg_vdd_cpux>;
117 ++};
118 ++
119 ++&cpu3 {
120 ++ cpu-supply = <&reg_vdd_cpux>;
121 ++};
122 +diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
123 +index 71778bb0475b..a082f6e4f0f4 100644
124 +--- a/arch/arm/kernel/stacktrace.c
125 ++++ b/arch/arm/kernel/stacktrace.c
126 +@@ -22,6 +22,19 @@
127 + * A simple function epilogue looks like this:
128 + * ldm sp, {fp, sp, pc}
129 + *
130 ++ * When compiled with clang, pc and sp are not pushed. A simple function
131 ++ * prologue looks like this when built with clang:
132 ++ *
133 ++ * stmdb {..., fp, lr}
134 ++ * add fp, sp, #x
135 ++ * sub sp, sp, #y
136 ++ *
137 ++ * A simple function epilogue looks like this when built with clang:
138 ++ *
139 ++ * sub sp, fp, #x
140 ++ * ldm {..., fp, pc}
141 ++ *
142 ++ *
143 + * Note that with framepointer enabled, even the leaf functions have the same
144 + * prologue and epilogue, therefore we can ignore the LR value in this case.
145 + */
146 +@@ -34,6 +47,16 @@ int notrace unwind_frame(struct stackframe *frame)
147 + low = frame->sp;
148 + high = ALIGN(low, THREAD_SIZE);
149 +
150 ++#ifdef CONFIG_CC_IS_CLANG
151 ++ /* check current frame pointer is within bounds */
152 ++ if (fp < low + 4 || fp > high - 4)
153 ++ return -EINVAL;
154 ++
155 ++ frame->sp = frame->fp;
156 ++ frame->fp = *(unsigned long *)(fp);
157 ++ frame->pc = frame->lr;
158 ++ frame->lr = *(unsigned long *)(fp + 4);
159 ++#else
160 + /* check current frame pointer is within bounds */
161 + if (fp < low + 12 || fp > high - 4)
162 + return -EINVAL;
163 +@@ -42,6 +65,7 @@ int notrace unwind_frame(struct stackframe *frame)
164 + frame->fp = *(unsigned long *)(fp - 12);
165 + frame->sp = *(unsigned long *)(fp - 8);
166 + frame->pc = *(unsigned long *)(fp - 4);
167 ++#endif
168 +
169 + return 0;
170 + }
171 +diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
172 +index 52665f30d236..6bc3000deb86 100644
173 +--- a/arch/arm/mach-at91/pm.c
174 ++++ b/arch/arm/mach-at91/pm.c
175 +@@ -592,13 +592,13 @@ static void __init at91_pm_sram_init(void)
176 + sram_pool = gen_pool_get(&pdev->dev, NULL);
177 + if (!sram_pool) {
178 + pr_warn("%s: sram pool unavailable!\n", __func__);
179 +- return;
180 ++ goto out_put_device;
181 + }
182 +
183 + sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
184 + if (!sram_base) {
185 + pr_warn("%s: unable to alloc sram!\n", __func__);
186 +- return;
187 ++ goto out_put_device;
188 + }
189 +
190 + sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
191 +@@ -606,12 +606,17 @@ static void __init at91_pm_sram_init(void)
192 + at91_pm_suspend_in_sram_sz, false);
193 + if (!at91_suspend_sram_fn) {
194 + pr_warn("SRAM: Could not map\n");
195 +- return;
196 ++ goto out_put_device;
197 + }
198 +
199 + /* Copy the pm suspend handler to SRAM */
200 + at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
201 + &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
202 ++ return;
203 ++
204 ++out_put_device:
205 ++ put_device(&pdev->dev);
206 ++ return;
207 + }
208 +
209 + static bool __init at91_is_pm_mode_active(int pm_mode)
210 +diff --git a/arch/arm/mach-exynos/mcpm-exynos.c b/arch/arm/mach-exynos/mcpm-exynos.c
211 +index 9a681b421ae1..cd861c57d5ad 100644
212 +--- a/arch/arm/mach-exynos/mcpm-exynos.c
213 ++++ b/arch/arm/mach-exynos/mcpm-exynos.c
214 +@@ -26,6 +26,7 @@
215 + #define EXYNOS5420_USE_L2_COMMON_UP_STATE BIT(30)
216 +
217 + static void __iomem *ns_sram_base_addr __ro_after_init;
218 ++static bool secure_firmware __ro_after_init;
219 +
220 + /*
221 + * The common v7_exit_coherency_flush API could not be used because of the
222 +@@ -58,15 +59,16 @@ static void __iomem *ns_sram_base_addr __ro_after_init;
223 + static int exynos_cpu_powerup(unsigned int cpu, unsigned int cluster)
224 + {
225 + unsigned int cpunr = cpu + (cluster * EXYNOS5420_CPUS_PER_CLUSTER);
226 ++ bool state;
227 +
228 + pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
229 + if (cpu >= EXYNOS5420_CPUS_PER_CLUSTER ||
230 + cluster >= EXYNOS5420_NR_CLUSTERS)
231 + return -EINVAL;
232 +
233 +- if (!exynos_cpu_power_state(cpunr)) {
234 +- exynos_cpu_power_up(cpunr);
235 +-
236 ++ state = exynos_cpu_power_state(cpunr);
237 ++ exynos_cpu_power_up(cpunr);
238 ++ if (!state && secure_firmware) {
239 + /*
240 + * This assumes the cluster number of the big cores(Cortex A15)
241 + * is 0 and the Little cores(Cortex A7) is 1.
242 +@@ -258,6 +260,8 @@ static int __init exynos_mcpm_init(void)
243 + return -ENOMEM;
244 + }
245 +
246 ++ secure_firmware = exynos_secure_firmware_available();
247 ++
248 + /*
249 + * To increase the stability of KFC reset we need to program
250 + * the PMU SPARE3 register
251 +diff --git a/arch/arm/mach-socfpga/pm.c b/arch/arm/mach-socfpga/pm.c
252 +index 6ed887cf8dc9..365c0428b21b 100644
253 +--- a/arch/arm/mach-socfpga/pm.c
254 ++++ b/arch/arm/mach-socfpga/pm.c
255 +@@ -49,14 +49,14 @@ static int socfpga_setup_ocram_self_refresh(void)
256 + if (!ocram_pool) {
257 + pr_warn("%s: ocram pool unavailable!\n", __func__);
258 + ret = -ENODEV;
259 +- goto put_node;
260 ++ goto put_device;
261 + }
262 +
263 + ocram_base = gen_pool_alloc(ocram_pool, socfpga_sdram_self_refresh_sz);
264 + if (!ocram_base) {
265 + pr_warn("%s: unable to alloc ocram!\n", __func__);
266 + ret = -ENOMEM;
267 +- goto put_node;
268 ++ goto put_device;
269 + }
270 +
271 + ocram_pbase = gen_pool_virt_to_phys(ocram_pool, ocram_base);
272 +@@ -67,7 +67,7 @@ static int socfpga_setup_ocram_self_refresh(void)
273 + if (!suspend_ocram_base) {
274 + pr_warn("%s: __arm_ioremap_exec failed!\n", __func__);
275 + ret = -ENOMEM;
276 +- goto put_node;
277 ++ goto put_device;
278 + }
279 +
280 + /* Copy the code that puts DDR in self refresh to ocram */
281 +@@ -81,6 +81,8 @@ static int socfpga_setup_ocram_self_refresh(void)
282 + if (!socfpga_sdram_self_refresh_in_ocram)
283 + ret = -EFAULT;
284 +
285 ++put_device:
286 ++ put_device(&pdev->dev);
287 + put_node:
288 + of_node_put(np);
289 +
290 +diff --git a/arch/arm64/boot/dts/exynos/exynos7-espresso.dts b/arch/arm64/boot/dts/exynos/exynos7-espresso.dts
291 +index 080e0f56e108..61ee7b6a3159 100644
292 +--- a/arch/arm64/boot/dts/exynos/exynos7-espresso.dts
293 ++++ b/arch/arm64/boot/dts/exynos/exynos7-espresso.dts
294 +@@ -157,6 +157,7 @@
295 + regulator-min-microvolt = <700000>;
296 + regulator-max-microvolt = <1150000>;
297 + regulator-enable-ramp-delay = <125>;
298 ++ regulator-always-on;
299 + };
300 +
301 + ldo8_reg: LDO8 {
302 +diff --git a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
303 +index e035cf195b19..8c4bfbaf3a80 100644
304 +--- a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
305 ++++ b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
306 +@@ -530,6 +530,17 @@
307 + status = "ok";
308 + compatible = "adi,adv7533";
309 + reg = <0x39>;
310 ++ adi,dsi-lanes = <4>;
311 ++ ports {
312 ++ #address-cells = <1>;
313 ++ #size-cells = <0>;
314 ++ port@0 {
315 ++ reg = <0>;
316 ++ };
317 ++ port@1 {
318 ++ reg = <1>;
319 ++ };
320 ++ };
321 + };
322 + };
323 +
324 +diff --git a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
325 +index c14205cd6bf5..3e47150c05ec 100644
326 +--- a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
327 ++++ b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
328 +@@ -516,7 +516,7 @@
329 + reg = <0x39>;
330 + interrupt-parent = <&gpio1>;
331 + interrupts = <1 2>;
332 +- pd-gpio = <&gpio0 4 0>;
333 ++ pd-gpios = <&gpio0 4 0>;
334 + adi,dsi-lanes = <4>;
335 + #sound-dai-cells = <0>;
336 +
337 +diff --git a/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi b/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
338 +index 242aaea68804..1235830ffd0b 100644
339 +--- a/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
340 ++++ b/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
341 +@@ -508,7 +508,7 @@
342 + pins = "gpio63", "gpio64", "gpio65", "gpio66",
343 + "gpio67", "gpio68";
344 + drive-strength = <8>;
345 +- bias-pull-none;
346 ++ bias-disable;
347 + };
348 + };
349 + cdc_pdm_lines_sus: pdm_lines_off {
350 +@@ -537,7 +537,7 @@
351 + pins = "gpio113", "gpio114", "gpio115",
352 + "gpio116";
353 + drive-strength = <8>;
354 +- bias-pull-none;
355 ++ bias-disable;
356 + };
357 + };
358 +
359 +@@ -565,7 +565,7 @@
360 + pinconf {
361 + pins = "gpio110";
362 + drive-strength = <8>;
363 +- bias-pull-none;
364 ++ bias-disable;
365 + };
366 + };
367 +
368 +@@ -591,7 +591,7 @@
369 + pinconf {
370 + pins = "gpio116";
371 + drive-strength = <8>;
372 +- bias-pull-none;
373 ++ bias-disable;
374 + };
375 + };
376 + ext_mclk_tlmm_lines_sus: mclk_lines_off {
377 +@@ -619,7 +619,7 @@
378 + pins = "gpio112", "gpio117", "gpio118",
379 + "gpio119";
380 + drive-strength = <8>;
381 +- bias-pull-none;
382 ++ bias-disable;
383 + };
384 + };
385 + ext_sec_tlmm_lines_sus: tlmm_lines_off {
386 +diff --git a/arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi b/arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi
387 +index e17311e09082..216aafd90e7f 100644
388 +--- a/arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi
389 ++++ b/arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi
390 +@@ -156,7 +156,7 @@
391 + pinctrl-0 = <&rgmii_pins>;
392 + snps,reset-active-low;
393 + snps,reset-delays-us = <0 10000 50000>;
394 +- snps,reset-gpio = <&gpio3 RK_PB3 GPIO_ACTIVE_HIGH>;
395 ++ snps,reset-gpio = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
396 + tx_delay = <0x10>;
397 + rx_delay = <0x10>;
398 + status = "okay";
399 +diff --git a/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi
400 +index 62ea288a1a70..45b86933c6ea 100644
401 +--- a/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi
402 ++++ b/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi
403 +@@ -101,7 +101,7 @@
404 +
405 + vcc5v0_host: vcc5v0-host-regulator {
406 + compatible = "regulator-fixed";
407 +- gpio = <&gpio4 RK_PA3 GPIO_ACTIVE_HIGH>;
408 ++ gpio = <&gpio4 RK_PA3 GPIO_ACTIVE_LOW>;
409 + enable-active-low;
410 + pinctrl-names = "default";
411 + pinctrl-0 = <&vcc5v0_host_en>;
412 +@@ -157,7 +157,7 @@
413 + phy-mode = "rgmii";
414 + pinctrl-names = "default";
415 + pinctrl-0 = <&rgmii_pins>;
416 +- snps,reset-gpio = <&gpio3 RK_PC0 GPIO_ACTIVE_HIGH>;
417 ++ snps,reset-gpio = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
418 + snps,reset-active-low;
419 + snps,reset-delays-us = <0 10000 50000>;
420 + tx_delay = <0x10>;
421 +diff --git a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c
422 +index 9bfa17015768..c432bfafe63e 100644
423 +--- a/arch/m68k/mac/iop.c
424 ++++ b/arch/m68k/mac/iop.c
425 +@@ -183,7 +183,7 @@ static __inline__ void iop_writeb(volatile struct mac_iop *iop, __u16 addr, __u8
426 +
427 + static __inline__ void iop_stop(volatile struct mac_iop *iop)
428 + {
429 +- iop->status_ctrl &= ~IOP_RUN;
430 ++ iop->status_ctrl = IOP_AUTOINC;
431 + }
432 +
433 + static __inline__ void iop_start(volatile struct mac_iop *iop)
434 +@@ -191,14 +191,9 @@ static __inline__ void iop_start(volatile struct mac_iop *iop)
435 + iop->status_ctrl = IOP_RUN | IOP_AUTOINC;
436 + }
437 +
438 +-static __inline__ void iop_bypass(volatile struct mac_iop *iop)
439 +-{
440 +- iop->status_ctrl |= IOP_BYPASS;
441 +-}
442 +-
443 + static __inline__ void iop_interrupt(volatile struct mac_iop *iop)
444 + {
445 +- iop->status_ctrl |= IOP_IRQ;
446 ++ iop->status_ctrl = IOP_IRQ | IOP_RUN | IOP_AUTOINC;
447 + }
448 +
449 + static int iop_alive(volatile struct mac_iop *iop)
450 +@@ -244,7 +239,6 @@ void __init iop_preinit(void)
451 + } else {
452 + iop_base[IOP_NUM_SCC] = (struct mac_iop *) SCC_IOP_BASE_QUADRA;
453 + }
454 +- iop_base[IOP_NUM_SCC]->status_ctrl = 0x87;
455 + iop_scc_present = 1;
456 + } else {
457 + iop_base[IOP_NUM_SCC] = NULL;
458 +@@ -256,7 +250,7 @@ void __init iop_preinit(void)
459 + } else {
460 + iop_base[IOP_NUM_ISM] = (struct mac_iop *) ISM_IOP_BASE_QUADRA;
461 + }
462 +- iop_base[IOP_NUM_ISM]->status_ctrl = 0;
463 ++ iop_stop(iop_base[IOP_NUM_ISM]);
464 + iop_ism_present = 1;
465 + } else {
466 + iop_base[IOP_NUM_ISM] = NULL;
467 +@@ -416,7 +410,8 @@ static void iop_handle_send(uint iop_num, uint chan)
468 + msg->status = IOP_MSGSTATUS_UNUSED;
469 + msg = msg->next;
470 + iop_send_queue[iop_num][chan] = msg;
471 +- if (msg) iop_do_send(msg);
472 ++ if (msg && iop_readb(iop, IOP_ADDR_SEND_STATE + chan) == IOP_MSG_IDLE)
473 ++ iop_do_send(msg);
474 + }
475 +
476 + /*
477 +@@ -490,16 +485,12 @@ int iop_send_message(uint iop_num, uint chan, void *privdata,
478 +
479 + if (!(q = iop_send_queue[iop_num][chan])) {
480 + iop_send_queue[iop_num][chan] = msg;
481 ++ iop_do_send(msg);
482 + } else {
483 + while (q->next) q = q->next;
484 + q->next = msg;
485 + }
486 +
487 +- if (iop_readb(iop_base[iop_num],
488 +- IOP_ADDR_SEND_STATE + chan) == IOP_MSG_IDLE) {
489 +- iop_do_send(msg);
490 +- }
491 +-
492 + return 0;
493 + }
494 +
495 +diff --git a/arch/mips/cavium-octeon/octeon-usb.c b/arch/mips/cavium-octeon/octeon-usb.c
496 +index cc88a08bc1f7..4017398519cf 100644
497 +--- a/arch/mips/cavium-octeon/octeon-usb.c
498 ++++ b/arch/mips/cavium-octeon/octeon-usb.c
499 +@@ -518,6 +518,7 @@ static int __init dwc3_octeon_device_init(void)
500 +
501 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
502 + if (res == NULL) {
503 ++ put_device(&pdev->dev);
504 + dev_err(&pdev->dev, "No memory resources\n");
505 + return -ENXIO;
506 + }
507 +@@ -529,8 +530,10 @@ static int __init dwc3_octeon_device_init(void)
508 + * know the difference.
509 + */
510 + base = devm_ioremap_resource(&pdev->dev, res);
511 +- if (IS_ERR(base))
512 ++ if (IS_ERR(base)) {
513 ++ put_device(&pdev->dev);
514 + return PTR_ERR(base);
515 ++ }
516 +
517 + mutex_lock(&dwc3_octeon_clocks_mutex);
518 + dwc3_octeon_clocks_start(&pdev->dev, (u64)base);
519 +diff --git a/arch/mips/pci/pci-xtalk-bridge.c b/arch/mips/pci/pci-xtalk-bridge.c
520 +index 6ce76b18186e..c4b1c6cf2660 100644
521 +--- a/arch/mips/pci/pci-xtalk-bridge.c
522 ++++ b/arch/mips/pci/pci-xtalk-bridge.c
523 +@@ -539,6 +539,7 @@ err_free_resource:
524 + pci_free_resource_list(&host->windows);
525 + err_remove_domain:
526 + irq_domain_remove(domain);
527 ++ irq_domain_free_fwnode(fn);
528 + return err;
529 + }
530 +
531 +@@ -546,8 +547,10 @@ static int bridge_remove(struct platform_device *pdev)
532 + {
533 + struct pci_bus *bus = platform_get_drvdata(pdev);
534 + struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
535 ++ struct fwnode_handle *fn = bc->domain->fwnode;
536 +
537 + irq_domain_remove(bc->domain);
538 ++ irq_domain_free_fwnode(fn);
539 + pci_lock_rescan_remove();
540 + pci_stop_root_bus(bus);
541 + pci_remove_root_bus(bus);
542 +diff --git a/arch/parisc/include/asm/barrier.h b/arch/parisc/include/asm/barrier.h
543 +index dbaaca84f27f..640d46edf32e 100644
544 +--- a/arch/parisc/include/asm/barrier.h
545 ++++ b/arch/parisc/include/asm/barrier.h
546 +@@ -26,6 +26,67 @@
547 + #define __smp_rmb() mb()
548 + #define __smp_wmb() mb()
549 +
550 ++#define __smp_store_release(p, v) \
551 ++do { \
552 ++ typeof(p) __p = (p); \
553 ++ union { typeof(*p) __val; char __c[1]; } __u = \
554 ++ { .__val = (__force typeof(*p)) (v) }; \
555 ++ compiletime_assert_atomic_type(*p); \
556 ++ switch (sizeof(*p)) { \
557 ++ case 1: \
558 ++ asm volatile("stb,ma %0,0(%1)" \
559 ++ : : "r"(*(__u8 *)__u.__c), "r"(__p) \
560 ++ : "memory"); \
561 ++ break; \
562 ++ case 2: \
563 ++ asm volatile("sth,ma %0,0(%1)" \
564 ++ : : "r"(*(__u16 *)__u.__c), "r"(__p) \
565 ++ : "memory"); \
566 ++ break; \
567 ++ case 4: \
568 ++ asm volatile("stw,ma %0,0(%1)" \
569 ++ : : "r"(*(__u32 *)__u.__c), "r"(__p) \
570 ++ : "memory"); \
571 ++ break; \
572 ++ case 8: \
573 ++ if (IS_ENABLED(CONFIG_64BIT)) \
574 ++ asm volatile("std,ma %0,0(%1)" \
575 ++ : : "r"(*(__u64 *)__u.__c), "r"(__p) \
576 ++ : "memory"); \
577 ++ break; \
578 ++ } \
579 ++} while (0)
580 ++
581 ++#define __smp_load_acquire(p) \
582 ++({ \
583 ++ union { typeof(*p) __val; char __c[1]; } __u; \
584 ++ typeof(p) __p = (p); \
585 ++ compiletime_assert_atomic_type(*p); \
586 ++ switch (sizeof(*p)) { \
587 ++ case 1: \
588 ++ asm volatile("ldb,ma 0(%1),%0" \
589 ++ : "=r"(*(__u8 *)__u.__c) : "r"(__p) \
590 ++ : "memory"); \
591 ++ break; \
592 ++ case 2: \
593 ++ asm volatile("ldh,ma 0(%1),%0" \
594 ++ : "=r"(*(__u16 *)__u.__c) : "r"(__p) \
595 ++ : "memory"); \
596 ++ break; \
597 ++ case 4: \
598 ++ asm volatile("ldw,ma 0(%1),%0" \
599 ++ : "=r"(*(__u32 *)__u.__c) : "r"(__p) \
600 ++ : "memory"); \
601 ++ break; \
602 ++ case 8: \
603 ++ if (IS_ENABLED(CONFIG_64BIT)) \
604 ++ asm volatile("ldd,ma 0(%1),%0" \
605 ++ : "=r"(*(__u64 *)__u.__c) : "r"(__p) \
606 ++ : "memory"); \
607 ++ break; \
608 ++ } \
609 ++ __u.__val; \
610 ++})
611 + #include <asm-generic/barrier.h>
612 +
613 + #endif /* !__ASSEMBLY__ */
614 +diff --git a/arch/parisc/include/asm/spinlock.h b/arch/parisc/include/asm/spinlock.h
615 +index 197d2247e4db..16aec9ba2580 100644
616 +--- a/arch/parisc/include/asm/spinlock.h
617 ++++ b/arch/parisc/include/asm/spinlock.h
618 +@@ -37,12 +37,8 @@ static inline void arch_spin_unlock(arch_spinlock_t *x)
619 + volatile unsigned int *a;
620 +
621 + a = __ldcw_align(x);
622 +-#ifdef CONFIG_SMP
623 +- (void) __ldcw(a);
624 +-#else
625 +- mb();
626 +-#endif
627 +- *a = 1;
628 ++ /* Release with ordered store. */
629 ++ __asm__ __volatile__("stw,ma %0,0(%1)" : : "r"(1), "r"(a) : "memory");
630 + }
631 +
632 + static inline int arch_spin_trylock(arch_spinlock_t *x)
633 +diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
634 +index b96d74496977..873bf3434da9 100644
635 +--- a/arch/parisc/kernel/entry.S
636 ++++ b/arch/parisc/kernel/entry.S
637 +@@ -454,7 +454,6 @@
638 + nop
639 + LDREG 0(\ptp),\pte
640 + bb,<,n \pte,_PAGE_PRESENT_BIT,3f
641 +- LDCW 0(\tmp),\tmp1
642 + b \fault
643 + stw \spc,0(\tmp)
644 + 99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
645 +@@ -464,23 +463,26 @@
646 + 3:
647 + .endm
648 +
649 +- /* Release pa_tlb_lock lock without reloading lock address. */
650 +- .macro tlb_unlock0 spc,tmp,tmp1
651 ++ /* Release pa_tlb_lock lock without reloading lock address.
652 ++ Note that the values in the register spc are limited to
653 ++ NR_SPACE_IDS (262144). Thus, the stw instruction always
654 ++ stores a nonzero value even when register spc is 64 bits.
655 ++ We use an ordered store to ensure all prior accesses are
656 ++ performed prior to releasing the lock. */
657 ++ .macro tlb_unlock0 spc,tmp
658 + #ifdef CONFIG_SMP
659 + 98: or,COND(=) %r0,\spc,%r0
660 +- LDCW 0(\tmp),\tmp1
661 +- or,COND(=) %r0,\spc,%r0
662 +- stw \spc,0(\tmp)
663 ++ stw,ma \spc,0(\tmp)
664 + 99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
665 + #endif
666 + .endm
667 +
668 + /* Release pa_tlb_lock lock. */
669 +- .macro tlb_unlock1 spc,tmp,tmp1
670 ++ .macro tlb_unlock1 spc,tmp
671 + #ifdef CONFIG_SMP
672 + 98: load_pa_tlb_lock \tmp
673 + 99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
674 +- tlb_unlock0 \spc,\tmp,\tmp1
675 ++ tlb_unlock0 \spc,\tmp
676 + #endif
677 + .endm
678 +
679 +@@ -1163,7 +1165,7 @@ dtlb_miss_20w:
680 +
681 + idtlbt pte,prot
682 +
683 +- tlb_unlock1 spc,t0,t1
684 ++ tlb_unlock1 spc,t0
685 + rfir
686 + nop
687 +
688 +@@ -1189,7 +1191,7 @@ nadtlb_miss_20w:
689 +
690 + idtlbt pte,prot
691 +
692 +- tlb_unlock1 spc,t0,t1
693 ++ tlb_unlock1 spc,t0
694 + rfir
695 + nop
696 +
697 +@@ -1223,7 +1225,7 @@ dtlb_miss_11:
698 +
699 + mtsp t1, %sr1 /* Restore sr1 */
700 +
701 +- tlb_unlock1 spc,t0,t1
702 ++ tlb_unlock1 spc,t0
703 + rfir
704 + nop
705 +
706 +@@ -1256,7 +1258,7 @@ nadtlb_miss_11:
707 +
708 + mtsp t1, %sr1 /* Restore sr1 */
709 +
710 +- tlb_unlock1 spc,t0,t1
711 ++ tlb_unlock1 spc,t0
712 + rfir
713 + nop
714 +
715 +@@ -1285,7 +1287,7 @@ dtlb_miss_20:
716 +
717 + idtlbt pte,prot
718 +
719 +- tlb_unlock1 spc,t0,t1
720 ++ tlb_unlock1 spc,t0
721 + rfir
722 + nop
723 +
724 +@@ -1313,7 +1315,7 @@ nadtlb_miss_20:
725 +
726 + idtlbt pte,prot
727 +
728 +- tlb_unlock1 spc,t0,t1
729 ++ tlb_unlock1 spc,t0
730 + rfir
731 + nop
732 +
733 +@@ -1420,7 +1422,7 @@ itlb_miss_20w:
734 +
735 + iitlbt pte,prot
736 +
737 +- tlb_unlock1 spc,t0,t1
738 ++ tlb_unlock1 spc,t0
739 + rfir
740 + nop
741 +
742 +@@ -1444,7 +1446,7 @@ naitlb_miss_20w:
743 +
744 + iitlbt pte,prot
745 +
746 +- tlb_unlock1 spc,t0,t1
747 ++ tlb_unlock1 spc,t0
748 + rfir
749 + nop
750 +
751 +@@ -1478,7 +1480,7 @@ itlb_miss_11:
752 +
753 + mtsp t1, %sr1 /* Restore sr1 */
754 +
755 +- tlb_unlock1 spc,t0,t1
756 ++ tlb_unlock1 spc,t0
757 + rfir
758 + nop
759 +
760 +@@ -1502,7 +1504,7 @@ naitlb_miss_11:
761 +
762 + mtsp t1, %sr1 /* Restore sr1 */
763 +
764 +- tlb_unlock1 spc,t0,t1
765 ++ tlb_unlock1 spc,t0
766 + rfir
767 + nop
768 +
769 +@@ -1532,7 +1534,7 @@ itlb_miss_20:
770 +
771 + iitlbt pte,prot
772 +
773 +- tlb_unlock1 spc,t0,t1
774 ++ tlb_unlock1 spc,t0
775 + rfir
776 + nop
777 +
778 +@@ -1552,7 +1554,7 @@ naitlb_miss_20:
779 +
780 + iitlbt pte,prot
781 +
782 +- tlb_unlock1 spc,t0,t1
783 ++ tlb_unlock1 spc,t0
784 + rfir
785 + nop
786 +
787 +@@ -1582,7 +1584,7 @@ dbit_trap_20w:
788 +
789 + idtlbt pte,prot
790 +
791 +- tlb_unlock0 spc,t0,t1
792 ++ tlb_unlock0 spc,t0
793 + rfir
794 + nop
795 + #else
796 +@@ -1608,7 +1610,7 @@ dbit_trap_11:
797 +
798 + mtsp t1, %sr1 /* Restore sr1 */
799 +
800 +- tlb_unlock0 spc,t0,t1
801 ++ tlb_unlock0 spc,t0
802 + rfir
803 + nop
804 +
805 +@@ -1628,7 +1630,7 @@ dbit_trap_20:
806 +
807 + idtlbt pte,prot
808 +
809 +- tlb_unlock0 spc,t0,t1
810 ++ tlb_unlock0 spc,t0
811 + rfir
812 + nop
813 + #endif
814 +diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
815 +index 97ac707c6bff..a37814cb66c7 100644
816 +--- a/arch/parisc/kernel/syscall.S
817 ++++ b/arch/parisc/kernel/syscall.S
818 +@@ -640,11 +640,7 @@ cas_action:
819 + sub,<> %r28, %r25, %r0
820 + 2: stw %r24, 0(%r26)
821 + /* Free lock */
822 +-#ifdef CONFIG_SMP
823 +-98: LDCW 0(%sr2,%r20), %r1 /* Barrier */
824 +-99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
825 +-#endif
826 +- stw %r20, 0(%sr2,%r20)
827 ++ stw,ma %r20, 0(%sr2,%r20)
828 + #if ENABLE_LWS_DEBUG
829 + /* Clear thread register indicator */
830 + stw %r0, 4(%sr2,%r20)
831 +@@ -658,11 +654,7 @@ cas_action:
832 + 3:
833 + /* Error occurred on load or store */
834 + /* Free lock */
835 +-#ifdef CONFIG_SMP
836 +-98: LDCW 0(%sr2,%r20), %r1 /* Barrier */
837 +-99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
838 +-#endif
839 +- stw %r20, 0(%sr2,%r20)
840 ++ stw,ma %r20, 0(%sr2,%r20)
841 + #if ENABLE_LWS_DEBUG
842 + stw %r0, 4(%sr2,%r20)
843 + #endif
844 +@@ -863,11 +855,7 @@ cas2_action:
845 +
846 + cas2_end:
847 + /* Free lock */
848 +-#ifdef CONFIG_SMP
849 +-98: LDCW 0(%sr2,%r20), %r1 /* Barrier */
850 +-99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
851 +-#endif
852 +- stw %r20, 0(%sr2,%r20)
853 ++ stw,ma %r20, 0(%sr2,%r20)
854 + /* Enable interrupts */
855 + ssm PSW_SM_I, %r0
856 + /* Return to userspace, set no error */
857 +@@ -877,11 +865,7 @@ cas2_end:
858 + 22:
859 + /* Error occurred on load or store */
860 + /* Free lock */
861 +-#ifdef CONFIG_SMP
862 +-98: LDCW 0(%sr2,%r20), %r1 /* Barrier */
863 +-99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
864 +-#endif
865 +- stw %r20, 0(%sr2,%r20)
866 ++ stw,ma %r20, 0(%sr2,%r20)
867 + ssm PSW_SM_I, %r0
868 + ldo 1(%r0),%r28
869 + b lws_exit
870 +diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
871 +index dfbd7f22eef5..8c69bd07ada6 100644
872 +--- a/arch/powerpc/boot/Makefile
873 ++++ b/arch/powerpc/boot/Makefile
874 +@@ -119,7 +119,7 @@ src-wlib-y := string.S crt0.S stdio.c decompress.c main.c \
875 + elf_util.c $(zlib-y) devtree.c stdlib.c \
876 + oflib.c ofconsole.c cuboot.c
877 +
878 +-src-wlib-$(CONFIG_PPC_MPC52XX) += mpc52xx-psc.c
879 ++src-wlib-$(CONFIG_PPC_MPC52xx) += mpc52xx-psc.c
880 + src-wlib-$(CONFIG_PPC64_BOOT_WRAPPER) += opal-calls.S opal.c
881 + ifndef CONFIG_PPC64_BOOT_WRAPPER
882 + src-wlib-y += crtsavres.S
883 +diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
884 +index 9457863147f9..00179cd6bdd0 100644
885 +--- a/arch/powerpc/boot/serial.c
886 ++++ b/arch/powerpc/boot/serial.c
887 +@@ -128,7 +128,7 @@ int serial_console_init(void)
888 + dt_is_compatible(devp, "fsl,cpm2-smc-uart"))
889 + rc = cpm_console_init(devp, &serial_cd);
890 + #endif
891 +-#ifdef CONFIG_PPC_MPC52XX
892 ++#ifdef CONFIG_PPC_MPC52xx
893 + else if (dt_is_compatible(devp, "fsl,mpc5200-psc-uart"))
894 + rc = mpc5200_psc_console_init(devp, &serial_cd);
895 + #endif
896 +diff --git a/arch/powerpc/include/asm/perf_event.h b/arch/powerpc/include/asm/perf_event.h
897 +index 7426d7a90e1e..7aba3c7ea25c 100644
898 +--- a/arch/powerpc/include/asm/perf_event.h
899 ++++ b/arch/powerpc/include/asm/perf_event.h
900 +@@ -12,6 +12,8 @@
901 +
902 + #ifdef CONFIG_PPC_PERF_CTRS
903 + #include <asm/perf_event_server.h>
904 ++#else
905 ++static inline bool is_sier_available(void) { return false; }
906 + #endif
907 +
908 + #ifdef CONFIG_FSL_EMB_PERF_EVENT
909 +diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
910 +index ee3ada66deb5..c41220f4aad9 100644
911 +--- a/arch/powerpc/include/asm/ptrace.h
912 ++++ b/arch/powerpc/include/asm/ptrace.h
913 +@@ -203,7 +203,7 @@ do { \
914 + #endif /* __powerpc64__ */
915 +
916 + #define arch_has_single_step() (1)
917 +-#ifndef CONFIG_BOOK3S_601
918 ++#ifndef CONFIG_PPC_BOOK3S_601
919 + #define arch_has_block_step() (true)
920 + #else
921 + #define arch_has_block_step() (false)
922 +diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
923 +index 3c1887351c71..bd227e0eab07 100644
924 +--- a/arch/powerpc/include/asm/rtas.h
925 ++++ b/arch/powerpc/include/asm/rtas.h
926 +@@ -368,8 +368,6 @@ extern int rtas_set_indicator_fast(int indicator, int index, int new_value);
927 + extern void rtas_progress(char *s, unsigned short hex);
928 + extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data);
929 + extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data);
930 +-extern int rtas_online_cpus_mask(cpumask_var_t cpus);
931 +-extern int rtas_offline_cpus_mask(cpumask_var_t cpus);
932 + extern int rtas_ibm_suspend_me(u64 handle);
933 +
934 + struct rtc_time;
935 +diff --git a/arch/powerpc/include/asm/timex.h b/arch/powerpc/include/asm/timex.h
936 +index d2d2c4bd8435..6047402b0a4d 100644
937 +--- a/arch/powerpc/include/asm/timex.h
938 ++++ b/arch/powerpc/include/asm/timex.h
939 +@@ -17,7 +17,7 @@ typedef unsigned long cycles_t;
940 +
941 + static inline cycles_t get_cycles(void)
942 + {
943 +- if (IS_ENABLED(CONFIG_BOOK3S_601))
944 ++ if (IS_ENABLED(CONFIG_PPC_BOOK3S_601))
945 + return 0;
946 +
947 + return mftb();
948 +diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
949 +index c5fa251b8950..01210593d60c 100644
950 +--- a/arch/powerpc/kernel/rtas.c
951 ++++ b/arch/powerpc/kernel/rtas.c
952 +@@ -842,96 +842,6 @@ static void rtas_percpu_suspend_me(void *info)
953 + __rtas_suspend_cpu((struct rtas_suspend_me_data *)info, 1);
954 + }
955 +
956 +-enum rtas_cpu_state {
957 +- DOWN,
958 +- UP,
959 +-};
960 +-
961 +-#ifndef CONFIG_SMP
962 +-static int rtas_cpu_state_change_mask(enum rtas_cpu_state state,
963 +- cpumask_var_t cpus)
964 +-{
965 +- if (!cpumask_empty(cpus)) {
966 +- cpumask_clear(cpus);
967 +- return -EINVAL;
968 +- } else
969 +- return 0;
970 +-}
971 +-#else
972 +-/* On return cpumask will be altered to indicate CPUs changed.
973 +- * CPUs with states changed will be set in the mask,
974 +- * CPUs with status unchanged will be unset in the mask. */
975 +-static int rtas_cpu_state_change_mask(enum rtas_cpu_state state,
976 +- cpumask_var_t cpus)
977 +-{
978 +- int cpu;
979 +- int cpuret = 0;
980 +- int ret = 0;
981 +-
982 +- if (cpumask_empty(cpus))
983 +- return 0;
984 +-
985 +- for_each_cpu(cpu, cpus) {
986 +- struct device *dev = get_cpu_device(cpu);
987 +-
988 +- switch (state) {
989 +- case DOWN:
990 +- cpuret = device_offline(dev);
991 +- break;
992 +- case UP:
993 +- cpuret = device_online(dev);
994 +- break;
995 +- }
996 +- if (cpuret < 0) {
997 +- pr_debug("%s: cpu_%s for cpu#%d returned %d.\n",
998 +- __func__,
999 +- ((state == UP) ? "up" : "down"),
1000 +- cpu, cpuret);
1001 +- if (!ret)
1002 +- ret = cpuret;
1003 +- if (state == UP) {
1004 +- /* clear bits for unchanged cpus, return */
1005 +- cpumask_shift_right(cpus, cpus, cpu);
1006 +- cpumask_shift_left(cpus, cpus, cpu);
1007 +- break;
1008 +- } else {
1009 +- /* clear bit for unchanged cpu, continue */
1010 +- cpumask_clear_cpu(cpu, cpus);
1011 +- }
1012 +- }
1013 +- cond_resched();
1014 +- }
1015 +-
1016 +- return ret;
1017 +-}
1018 +-#endif
1019 +-
1020 +-int rtas_online_cpus_mask(cpumask_var_t cpus)
1021 +-{
1022 +- int ret;
1023 +-
1024 +- ret = rtas_cpu_state_change_mask(UP, cpus);
1025 +-
1026 +- if (ret) {
1027 +- cpumask_var_t tmp_mask;
1028 +-
1029 +- if (!alloc_cpumask_var(&tmp_mask, GFP_KERNEL))
1030 +- return ret;
1031 +-
1032 +- /* Use tmp_mask to preserve cpus mask from first failure */
1033 +- cpumask_copy(tmp_mask, cpus);
1034 +- rtas_offline_cpus_mask(tmp_mask);
1035 +- free_cpumask_var(tmp_mask);
1036 +- }
1037 +-
1038 +- return ret;
1039 +-}
1040 +-
1041 +-int rtas_offline_cpus_mask(cpumask_var_t cpus)
1042 +-{
1043 +- return rtas_cpu_state_change_mask(DOWN, cpus);
1044 +-}
1045 +-
1046 + int rtas_ibm_suspend_me(u64 handle)
1047 + {
1048 + long state;
1049 +@@ -939,8 +849,6 @@ int rtas_ibm_suspend_me(u64 handle)
1050 + unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
1051 + struct rtas_suspend_me_data data;
1052 + DECLARE_COMPLETION_ONSTACK(done);
1053 +- cpumask_var_t offline_mask;
1054 +- int cpuret;
1055 +
1056 + if (!rtas_service_present("ibm,suspend-me"))
1057 + return -ENOSYS;
1058 +@@ -961,9 +869,6 @@ int rtas_ibm_suspend_me(u64 handle)
1059 + return -EIO;
1060 + }
1061 +
1062 +- if (!alloc_cpumask_var(&offline_mask, GFP_KERNEL))
1063 +- return -ENOMEM;
1064 +-
1065 + atomic_set(&data.working, 0);
1066 + atomic_set(&data.done, 0);
1067 + atomic_set(&data.error, 0);
1068 +@@ -972,24 +877,8 @@ int rtas_ibm_suspend_me(u64 handle)
1069 +
1070 + lock_device_hotplug();
1071 +
1072 +- /* All present CPUs must be online */
1073 +- cpumask_andnot(offline_mask, cpu_present_mask, cpu_online_mask);
1074 +- cpuret = rtas_online_cpus_mask(offline_mask);
1075 +- if (cpuret) {
1076 +- pr_err("%s: Could not bring present CPUs online.\n", __func__);
1077 +- atomic_set(&data.error, cpuret);
1078 +- goto out;
1079 +- }
1080 +-
1081 + cpu_hotplug_disable();
1082 +
1083 +- /* Check if we raced with a CPU-Offline Operation */
1084 +- if (!cpumask_equal(cpu_present_mask, cpu_online_mask)) {
1085 +- pr_info("%s: Raced against a concurrent CPU-Offline\n", __func__);
1086 +- atomic_set(&data.error, -EAGAIN);
1087 +- goto out_hotplug_enable;
1088 +- }
1089 +-
1090 + /* Call function on all CPUs. One of us will make the
1091 + * rtas call
1092 + */
1093 +@@ -1000,18 +889,11 @@ int rtas_ibm_suspend_me(u64 handle)
1094 + if (atomic_read(&data.error) != 0)
1095 + printk(KERN_ERR "Error doing global join\n");
1096 +
1097 +-out_hotplug_enable:
1098 +- cpu_hotplug_enable();
1099 +
1100 +- /* Take down CPUs not online prior to suspend */
1101 +- cpuret = rtas_offline_cpus_mask(offline_mask);
1102 +- if (cpuret)
1103 +- pr_warn("%s: Could not restore CPUs to offline state.\n",
1104 +- __func__);
1105 ++ cpu_hotplug_enable();
1106 +
1107 +-out:
1108 + unlock_device_hotplug();
1109 +- free_cpumask_var(offline_mask);
1110 ++
1111 + return atomic_read(&data.error);
1112 + }
1113 + #else /* CONFIG_PPC_PSERIES */
1114 +diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
1115 +index eae9ddaecbcf..efb1ba40274a 100644
1116 +--- a/arch/powerpc/kernel/vdso.c
1117 ++++ b/arch/powerpc/kernel/vdso.c
1118 +@@ -682,7 +682,7 @@ int vdso_getcpu_init(void)
1119 + node = cpu_to_node(cpu);
1120 + WARN_ON_ONCE(node > 0xffff);
1121 +
1122 +- val = (cpu & 0xfff) | ((node & 0xffff) << 16);
1123 ++ val = (cpu & 0xffff) | ((node & 0xffff) << 16);
1124 + mtspr(SPRN_SPRG_VDSO_WRITE, val);
1125 + get_paca()->sprg_vdso = val;
1126 +
1127 +diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
1128 +index 66f307e873dc..432fd9fa8c3f 100644
1129 +--- a/arch/powerpc/mm/book3s64/pkeys.c
1130 ++++ b/arch/powerpc/mm/book3s64/pkeys.c
1131 +@@ -83,13 +83,17 @@ static int pkey_initialize(void)
1132 + scan_pkey_feature();
1133 +
1134 + /*
1135 +- * Let's assume 32 pkeys on P8 bare metal, if its not defined by device
1136 +- * tree. We make this exception since skiboot forgot to expose this
1137 +- * property on power8.
1138 ++ * Let's assume 32 pkeys on P8/P9 bare metal, if its not defined by device
1139 ++ * tree. We make this exception since some version of skiboot forgot to
1140 ++ * expose this property on power8/9.
1141 + */
1142 +- if (!pkeys_devtree_defined && !firmware_has_feature(FW_FEATURE_LPAR) &&
1143 +- cpu_has_feature(CPU_FTRS_POWER8))
1144 +- pkeys_total = 32;
1145 ++ if (!pkeys_devtree_defined && !firmware_has_feature(FW_FEATURE_LPAR)) {
1146 ++ unsigned long pvr = mfspr(SPRN_PVR);
1147 ++
1148 ++ if (PVR_VER(pvr) == PVR_POWER8 || PVR_VER(pvr) == PVR_POWER8E ||
1149 ++ PVR_VER(pvr) == PVR_POWER8NVL || PVR_VER(pvr) == PVR_POWER9)
1150 ++ pkeys_total = 32;
1151 ++ }
1152 +
1153 + /*
1154 + * Adjust the upper limit, based on the number of bits supported by
1155 +diff --git a/arch/powerpc/platforms/pseries/suspend.c b/arch/powerpc/platforms/pseries/suspend.c
1156 +index 0a24a5a185f0..f789693f61f4 100644
1157 +--- a/arch/powerpc/platforms/pseries/suspend.c
1158 ++++ b/arch/powerpc/platforms/pseries/suspend.c
1159 +@@ -132,15 +132,11 @@ static ssize_t store_hibernate(struct device *dev,
1160 + struct device_attribute *attr,
1161 + const char *buf, size_t count)
1162 + {
1163 +- cpumask_var_t offline_mask;
1164 + int rc;
1165 +
1166 + if (!capable(CAP_SYS_ADMIN))
1167 + return -EPERM;
1168 +
1169 +- if (!alloc_cpumask_var(&offline_mask, GFP_KERNEL))
1170 +- return -ENOMEM;
1171 +-
1172 + stream_id = simple_strtoul(buf, NULL, 16);
1173 +
1174 + do {
1175 +@@ -150,32 +146,16 @@ static ssize_t store_hibernate(struct device *dev,
1176 + } while (rc == -EAGAIN);
1177 +
1178 + if (!rc) {
1179 +- /* All present CPUs must be online */
1180 +- cpumask_andnot(offline_mask, cpu_present_mask,
1181 +- cpu_online_mask);
1182 +- rc = rtas_online_cpus_mask(offline_mask);
1183 +- if (rc) {
1184 +- pr_err("%s: Could not bring present CPUs online.\n",
1185 +- __func__);
1186 +- goto out;
1187 +- }
1188 +-
1189 + stop_topology_update();
1190 + rc = pm_suspend(PM_SUSPEND_MEM);
1191 + start_topology_update();
1192 +-
1193 +- /* Take down CPUs not online prior to suspend */
1194 +- if (!rtas_offline_cpus_mask(offline_mask))
1195 +- pr_warn("%s: Could not restore CPUs to offline "
1196 +- "state.\n", __func__);
1197 + }
1198 +
1199 + stream_id = 0;
1200 +
1201 + if (!rc)
1202 + rc = count;
1203 +-out:
1204 +- free_cpumask_var(offline_mask);
1205 ++
1206 + return rc;
1207 + }
1208 +
1209 +diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
1210 +index 364e3a89c096..4fa7a562c6fc 100644
1211 +--- a/arch/s390/mm/gmap.c
1212 ++++ b/arch/s390/mm/gmap.c
1213 +@@ -2485,23 +2485,36 @@ void gmap_sync_dirty_log_pmd(struct gmap *gmap, unsigned long bitmap[4],
1214 + }
1215 + EXPORT_SYMBOL_GPL(gmap_sync_dirty_log_pmd);
1216 +
1217 ++#ifdef CONFIG_TRANSPARENT_HUGEPAGE
1218 ++static int thp_split_walk_pmd_entry(pmd_t *pmd, unsigned long addr,
1219 ++ unsigned long end, struct mm_walk *walk)
1220 ++{
1221 ++ struct vm_area_struct *vma = walk->vma;
1222 ++
1223 ++ split_huge_pmd(vma, pmd, addr);
1224 ++ return 0;
1225 ++}
1226 ++
1227 ++static const struct mm_walk_ops thp_split_walk_ops = {
1228 ++ .pmd_entry = thp_split_walk_pmd_entry,
1229 ++};
1230 ++
1231 + static inline void thp_split_mm(struct mm_struct *mm)
1232 + {
1233 +-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
1234 + struct vm_area_struct *vma;
1235 +- unsigned long addr;
1236 +
1237 + for (vma = mm->mmap; vma != NULL; vma = vma->vm_next) {
1238 +- for (addr = vma->vm_start;
1239 +- addr < vma->vm_end;
1240 +- addr += PAGE_SIZE)
1241 +- follow_page(vma, addr, FOLL_SPLIT);
1242 + vma->vm_flags &= ~VM_HUGEPAGE;
1243 + vma->vm_flags |= VM_NOHUGEPAGE;
1244 ++ walk_page_vma(vma, &thp_split_walk_ops, NULL);
1245 + }
1246 + mm->def_flags |= VM_NOHUGEPAGE;
1247 +-#endif
1248 + }
1249 ++#else
1250 ++static inline void thp_split_mm(struct mm_struct *mm)
1251 ++{
1252 ++}
1253 ++#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
1254 +
1255 + /*
1256 + * Remove all empty zero pages from the mapping for lazy refaulting
1257 +diff --git a/arch/x86/crypto/aes_ctrby8_avx-x86_64.S b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
1258 +index 5f6a5af9c489..77043a82da51 100644
1259 +--- a/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
1260 ++++ b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
1261 +@@ -127,10 +127,6 @@ ddq_add_8:
1262 +
1263 + /* generate a unique variable for ddq_add_x */
1264 +
1265 +-.macro setddq n
1266 +- var_ddq_add = ddq_add_\n
1267 +-.endm
1268 +-
1269 + /* generate a unique variable for xmm register */
1270 + .macro setxdata n
1271 + var_xdata = %xmm\n
1272 +@@ -140,9 +136,7 @@ ddq_add_8:
1273 +
1274 + .macro club name, id
1275 + .altmacro
1276 +- .if \name == DDQ_DATA
1277 +- setddq %\id
1278 +- .elseif \name == XDATA
1279 ++ .if \name == XDATA
1280 + setxdata %\id
1281 + .endif
1282 + .noaltmacro
1283 +@@ -165,9 +159,8 @@ ddq_add_8:
1284 +
1285 + .set i, 1
1286 + .rept (by - 1)
1287 +- club DDQ_DATA, i
1288 + club XDATA, i
1289 +- vpaddq var_ddq_add(%rip), xcounter, var_xdata
1290 ++ vpaddq (ddq_add_1 + 16 * (i - 1))(%rip), xcounter, var_xdata
1291 + vptest ddq_low_msk(%rip), var_xdata
1292 + jnz 1f
1293 + vpaddq ddq_high_add_1(%rip), var_xdata, var_xdata
1294 +@@ -180,8 +173,7 @@ ddq_add_8:
1295 + vmovdqa 1*16(p_keys), xkeyA
1296 +
1297 + vpxor xkey0, xdata0, xdata0
1298 +- club DDQ_DATA, by
1299 +- vpaddq var_ddq_add(%rip), xcounter, xcounter
1300 ++ vpaddq (ddq_add_1 + 16 * (by - 1))(%rip), xcounter, xcounter
1301 + vptest ddq_low_msk(%rip), xcounter
1302 + jnz 1f
1303 + vpaddq ddq_high_add_1(%rip), xcounter, xcounter
1304 +diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
1305 +index e40bdf024ba7..9afeb58c910e 100644
1306 +--- a/arch/x86/crypto/aesni-intel_asm.S
1307 ++++ b/arch/x86/crypto/aesni-intel_asm.S
1308 +@@ -266,7 +266,7 @@ ALL_F: .octa 0xffffffffffffffffffffffffffffffff
1309 + PSHUFB_XMM %xmm2, %xmm0
1310 + movdqu %xmm0, CurCount(%arg2) # ctx_data.current_counter = iv
1311 +
1312 +- PRECOMPUTE \SUBKEY, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
1313 ++ PRECOMPUTE \SUBKEY, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7
1314 + movdqu HashKey(%arg2), %xmm13
1315 +
1316 + CALC_AAD_HASH %xmm13, \AAD, \AADLEN, %xmm0, %xmm1, %xmm2, %xmm3, \
1317 +@@ -978,7 +978,7 @@ _initial_blocks_done\@:
1318 + * arg1, %arg3, %arg4 are used as pointers only, not modified
1319 + * %r11 is the data offset value
1320 + */
1321 +-.macro GHASH_4_ENCRYPT_4_PARALLEL_ENC TMP1 TMP2 TMP3 TMP4 TMP5 \
1322 ++.macro GHASH_4_ENCRYPT_4_PARALLEL_enc TMP1 TMP2 TMP3 TMP4 TMP5 \
1323 + TMP6 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 operation
1324 +
1325 + movdqa \XMM1, \XMM5
1326 +@@ -1186,7 +1186,7 @@ aes_loop_par_enc_done\@:
1327 + * arg1, %arg3, %arg4 are used as pointers only, not modified
1328 + * %r11 is the data offset value
1329 + */
1330 +-.macro GHASH_4_ENCRYPT_4_PARALLEL_DEC TMP1 TMP2 TMP3 TMP4 TMP5 \
1331 ++.macro GHASH_4_ENCRYPT_4_PARALLEL_dec TMP1 TMP2 TMP3 TMP4 TMP5 \
1332 + TMP6 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 operation
1333 +
1334 + movdqa \XMM1, \XMM5
1335 +diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
1336 +index 16699101fd2f..ea6d9da9b094 100644
1337 +--- a/arch/x86/kernel/apic/io_apic.c
1338 ++++ b/arch/x86/kernel/apic/io_apic.c
1339 +@@ -2348,8 +2348,13 @@ static int mp_irqdomain_create(int ioapic)
1340 +
1341 + static void ioapic_destroy_irqdomain(int idx)
1342 + {
1343 ++ struct ioapic_domain_cfg *cfg = &ioapics[idx].irqdomain_cfg;
1344 ++ struct fwnode_handle *fn = ioapics[idx].irqdomain->fwnode;
1345 ++
1346 + if (ioapics[idx].irqdomain) {
1347 + irq_domain_remove(ioapics[idx].irqdomain);
1348 ++ if (!cfg->dev)
1349 ++ irq_domain_free_fwnode(fn);
1350 + ioapics[idx].irqdomain = NULL;
1351 + }
1352 + }
1353 +diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
1354 +index 1f30117b24ba..eb2d41c1816d 100644
1355 +--- a/arch/x86/kernel/cpu/mce/inject.c
1356 ++++ b/arch/x86/kernel/cpu/mce/inject.c
1357 +@@ -511,7 +511,7 @@ static void do_inject(void)
1358 + */
1359 + if (inj_type == DFR_INT_INJ) {
1360 + i_mce.status |= MCI_STATUS_DEFERRED;
1361 +- i_mce.status |= (i_mce.status & ~MCI_STATUS_UC);
1362 ++ i_mce.status &= ~MCI_STATUS_UC;
1363 + }
1364 +
1365 + /*
1366 +diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
1367 +index af64519b2695..da3cc3a10d63 100644
1368 +--- a/arch/x86/kernel/process_64.c
1369 ++++ b/arch/x86/kernel/process_64.c
1370 +@@ -316,7 +316,7 @@ static unsigned long x86_fsgsbase_read_task(struct task_struct *task,
1371 + */
1372 + mutex_lock(&task->mm->context.lock);
1373 + ldt = task->mm->context.ldt;
1374 +- if (unlikely(idx >= ldt->nr_entries))
1375 ++ if (unlikely(!ldt || idx >= ldt->nr_entries))
1376 + base = 0;
1377 + else
1378 + base = get_desc_base(ldt->entries + idx);
1379 +diff --git a/block/blk-iocost.c b/block/blk-iocost.c
1380 +index 4d2bda812d9b..dcc6685d5bec 100644
1381 +--- a/block/blk-iocost.c
1382 ++++ b/block/blk-iocost.c
1383 +@@ -1377,7 +1377,7 @@ static void ioc_timer_fn(struct timer_list *timer)
1384 + * should have woken up in the last period and expire idle iocgs.
1385 + */
1386 + list_for_each_entry_safe(iocg, tiocg, &ioc->active_iocgs, active_list) {
1387 +- if (!waitqueue_active(&iocg->waitq) && iocg->abs_vdebt &&
1388 ++ if (!waitqueue_active(&iocg->waitq) && !iocg->abs_vdebt &&
1389 + !iocg_is_idle(iocg))
1390 + continue;
1391 +
1392 +diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
1393 +index 728d752f7adc..85f799c9c25c 100644
1394 +--- a/drivers/acpi/acpica/exprep.c
1395 ++++ b/drivers/acpi/acpica/exprep.c
1396 +@@ -473,10 +473,6 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
1397 + (u8)access_byte_width;
1398 + }
1399 + }
1400 +- /* An additional reference for the container */
1401 +-
1402 +- acpi_ut_add_reference(obj_desc->field.region_obj);
1403 +-
1404 + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
1405 + "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
1406 + obj_desc->field.start_field_bit_offset,
1407 +diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
1408 +index c365faf4e6cd..4c0d4e434196 100644
1409 +--- a/drivers/acpi/acpica/utdelete.c
1410 ++++ b/drivers/acpi/acpica/utdelete.c
1411 +@@ -568,11 +568,6 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
1412 + next_object = object->buffer_field.buffer_obj;
1413 + break;
1414 +
1415 +- case ACPI_TYPE_LOCAL_REGION_FIELD:
1416 +-
1417 +- next_object = object->field.region_obj;
1418 +- break;
1419 +-
1420 + case ACPI_TYPE_LOCAL_BANK_FIELD:
1421 +
1422 + next_object = object->bank_field.bank_obj;
1423 +@@ -613,6 +608,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
1424 + }
1425 + break;
1426 +
1427 ++ case ACPI_TYPE_LOCAL_REGION_FIELD:
1428 + case ACPI_TYPE_REGION:
1429 + default:
1430 +
1431 +diff --git a/drivers/block/loop.c b/drivers/block/loop.c
1432 +index 565e35e69f24..bddbbf5b3dda 100644
1433 +--- a/drivers/block/loop.c
1434 ++++ b/drivers/block/loop.c
1435 +@@ -2325,6 +2325,8 @@ static void __exit loop_exit(void)
1436 +
1437 + range = max_loop ? max_loop << part_shift : 1UL << MINORBITS;
1438 +
1439 ++ mutex_lock(&loop_ctl_mutex);
1440 ++
1441 + idr_for_each(&loop_index_idr, &loop_exit_cb, NULL);
1442 + idr_destroy(&loop_index_idr);
1443 +
1444 +@@ -2332,6 +2334,8 @@ static void __exit loop_exit(void)
1445 + unregister_blkdev(LOOP_MAJOR, "loop");
1446 +
1447 + misc_deregister(&loop_misc);
1448 ++
1449 ++ mutex_unlock(&loop_ctl_mutex);
1450 + }
1451 +
1452 + module_init(loop_init);
1453 +diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
1454 +index 0f3a020703ab..4c7978cb1786 100644
1455 +--- a/drivers/bluetooth/btmrvl_sdio.c
1456 ++++ b/drivers/bluetooth/btmrvl_sdio.c
1457 +@@ -328,7 +328,7 @@ static const struct btmrvl_sdio_device btmrvl_sdio_sd8897 = {
1458 +
1459 + static const struct btmrvl_sdio_device btmrvl_sdio_sd8977 = {
1460 + .helper = NULL,
1461 +- .firmware = "mrvl/sd8977_uapsta.bin",
1462 ++ .firmware = "mrvl/sdsd8977_combo_v2.bin",
1463 + .reg = &btmrvl_reg_8977,
1464 + .support_pscan_win_report = true,
1465 + .sd_blksz_fw_dl = 256,
1466 +@@ -346,7 +346,7 @@ static const struct btmrvl_sdio_device btmrvl_sdio_sd8987 = {
1467 +
1468 + static const struct btmrvl_sdio_device btmrvl_sdio_sd8997 = {
1469 + .helper = NULL,
1470 +- .firmware = "mrvl/sd8997_uapsta.bin",
1471 ++ .firmware = "mrvl/sdsd8997_combo_v4.bin",
1472 + .reg = &btmrvl_reg_8997,
1473 + .support_pscan_win_report = true,
1474 + .sd_blksz_fw_dl = 256,
1475 +@@ -1831,6 +1831,6 @@ MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin");
1476 + MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin");
1477 + MODULE_FIRMWARE("mrvl/sd8887_uapsta.bin");
1478 + MODULE_FIRMWARE("mrvl/sd8897_uapsta.bin");
1479 +-MODULE_FIRMWARE("mrvl/sd8977_uapsta.bin");
1480 ++MODULE_FIRMWARE("mrvl/sdsd8977_combo_v2.bin");
1481 + MODULE_FIRMWARE("mrvl/sd8987_uapsta.bin");
1482 +-MODULE_FIRMWARE("mrvl/sd8997_uapsta.bin");
1483 ++MODULE_FIRMWARE("mrvl/sdsd8997_combo_v4.bin");
1484 +diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
1485 +index 813338288453..b7de7cb8cca9 100644
1486 +--- a/drivers/bluetooth/btmtksdio.c
1487 ++++ b/drivers/bluetooth/btmtksdio.c
1488 +@@ -684,7 +684,7 @@ static int mtk_setup_firmware(struct hci_dev *hdev, const char *fwname)
1489 + const u8 *fw_ptr;
1490 + size_t fw_size;
1491 + int err, dlen;
1492 +- u8 flag;
1493 ++ u8 flag, param;
1494 +
1495 + err = request_firmware(&fw, fwname, &hdev->dev);
1496 + if (err < 0) {
1497 +@@ -692,6 +692,20 @@ static int mtk_setup_firmware(struct hci_dev *hdev, const char *fwname)
1498 + return err;
1499 + }
1500 +
1501 ++ /* Power on data RAM the firmware relies on. */
1502 ++ param = 1;
1503 ++ wmt_params.op = MTK_WMT_FUNC_CTRL;
1504 ++ wmt_params.flag = 3;
1505 ++ wmt_params.dlen = sizeof(param);
1506 ++ wmt_params.data = &param;
1507 ++ wmt_params.status = NULL;
1508 ++
1509 ++ err = mtk_hci_wmt_sync(hdev, &wmt_params);
1510 ++ if (err < 0) {
1511 ++ bt_dev_err(hdev, "Failed to power on data RAM (%d)", err);
1512 ++ return err;
1513 ++ }
1514 ++
1515 + fw_ptr = fw->data;
1516 + fw_size = fw->size;
1517 +
1518 +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
1519 +index 9c3b063e1a1f..f3f0529564da 100644
1520 +--- a/drivers/bluetooth/btusb.c
1521 ++++ b/drivers/bluetooth/btusb.c
1522 +@@ -2792,7 +2792,7 @@ static int btusb_mtk_setup_firmware(struct hci_dev *hdev, const char *fwname)
1523 + const u8 *fw_ptr;
1524 + size_t fw_size;
1525 + int err, dlen;
1526 +- u8 flag;
1527 ++ u8 flag, param;
1528 +
1529 + err = request_firmware(&fw, fwname, &hdev->dev);
1530 + if (err < 0) {
1531 +@@ -2800,6 +2800,20 @@ static int btusb_mtk_setup_firmware(struct hci_dev *hdev, const char *fwname)
1532 + return err;
1533 + }
1534 +
1535 ++ /* Power on data RAM the firmware relies on. */
1536 ++ param = 1;
1537 ++ wmt_params.op = BTMTK_WMT_FUNC_CTRL;
1538 ++ wmt_params.flag = 3;
1539 ++ wmt_params.dlen = sizeof(param);
1540 ++ wmt_params.data = &param;
1541 ++ wmt_params.status = NULL;
1542 ++
1543 ++ err = btusb_mtk_hci_wmt_sync(hdev, &wmt_params);
1544 ++ if (err < 0) {
1545 ++ bt_dev_err(hdev, "Failed to power on data RAM (%d)", err);
1546 ++ return err;
1547 ++ }
1548 ++
1549 + fw_ptr = fw->data;
1550 + fw_size = fw->size;
1551 +
1552 +diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
1553 +index dacf297baf59..5df0651b6cd5 100644
1554 +--- a/drivers/bluetooth/hci_h5.c
1555 ++++ b/drivers/bluetooth/hci_h5.c
1556 +@@ -790,7 +790,7 @@ static int h5_serdev_probe(struct serdev_device *serdev)
1557 + if (!h5)
1558 + return -ENOMEM;
1559 +
1560 +- set_bit(HCI_UART_RESET_ON_INIT, &h5->serdev_hu.flags);
1561 ++ set_bit(HCI_UART_RESET_ON_INIT, &h5->serdev_hu.hdev_flags);
1562 +
1563 + h5->hu = &h5->serdev_hu;
1564 + h5->serdev_hu.serdev = serdev;
1565 +diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c
1566 +index 4652896d4990..ad2f26cb2622 100644
1567 +--- a/drivers/bluetooth/hci_serdev.c
1568 ++++ b/drivers/bluetooth/hci_serdev.c
1569 +@@ -357,7 +357,8 @@ void hci_uart_unregister_device(struct hci_uart *hu)
1570 + struct hci_dev *hdev = hu->hdev;
1571 +
1572 + clear_bit(HCI_UART_PROTO_READY, &hu->flags);
1573 +- hci_unregister_dev(hdev);
1574 ++ if (test_bit(HCI_UART_REGISTERED, &hu->flags))
1575 ++ hci_unregister_dev(hdev);
1576 + hci_free_dev(hdev);
1577 +
1578 + cancel_work_sync(&hu->write_work);
1579 +diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
1580 +index f8bc052cd853..770a780dfa54 100644
1581 +--- a/drivers/bus/ti-sysc.c
1582 ++++ b/drivers/bus/ti-sysc.c
1583 +@@ -1371,6 +1371,10 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
1584 + SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY),
1585 + SYSC_QUIRK("tptc", 0, 0, -ENODEV, -ENODEV, 0x40007c00, 0xffffffff,
1586 + SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY),
1587 ++ SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, 0x14, 0x50700100, 0xffffffff,
1588 ++ SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY),
1589 ++ SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, -ENODEV, 0x50700101, 0xffffffff,
1590 ++ SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY),
1591 + SYSC_QUIRK("usb_otg_hs", 0, 0x400, 0x404, 0x408, 0x00000050,
1592 + 0xffffffff, SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY),
1593 + SYSC_QUIRK("usb_otg_hs", 0, 0, 0x10, -ENODEV, 0x4ea2080d, 0xffffffff,
1594 +@@ -1440,8 +1444,6 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
1595 + SYSC_QUIRK("tpcc", 0, 0, -ENODEV, -ENODEV, 0x40014c00, 0xffffffff, 0),
1596 + SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000004, 0xffffffff, 0),
1597 + SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000008, 0xffffffff, 0),
1598 +- SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, 0x14, 0x50700100, 0xffffffff, 0),
1599 +- SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, -ENODEV, 0x50700101, 0xffffffff, 0),
1600 + SYSC_QUIRK("venc", 0x58003000, 0, -ENODEV, -ENODEV, 0x00000002, 0xffffffff, 0),
1601 + SYSC_QUIRK("vfpe", 0, 0, 0x104, -ENODEV, 0x4d001200, 0xffffffff, 0),
1602 + #endif
1603 +diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
1604 +index b161bdf60000..0941d38b2d32 100644
1605 +--- a/drivers/char/agp/intel-gtt.c
1606 ++++ b/drivers/char/agp/intel-gtt.c
1607 +@@ -304,8 +304,10 @@ static int intel_gtt_setup_scratch_page(void)
1608 + if (intel_private.needs_dmar) {
1609 + dma_addr = pci_map_page(intel_private.pcidev, page, 0,
1610 + PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
1611 +- if (pci_dma_mapping_error(intel_private.pcidev, dma_addr))
1612 ++ if (pci_dma_mapping_error(intel_private.pcidev, dma_addr)) {
1613 ++ __free_page(page);
1614 + return -EINVAL;
1615 ++ }
1616 +
1617 + intel_private.scratch_page_dma = dma_addr;
1618 + } else
1619 +diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
1620 +index 58073836b555..1838039b0333 100644
1621 +--- a/drivers/char/tpm/tpm-chip.c
1622 ++++ b/drivers/char/tpm/tpm-chip.c
1623 +@@ -386,13 +386,8 @@ struct tpm_chip *tpm_chip_alloc(struct device *pdev,
1624 + chip->cdev.owner = THIS_MODULE;
1625 + chip->cdevs.owner = THIS_MODULE;
1626 +
1627 +- chip->work_space.context_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
1628 +- if (!chip->work_space.context_buf) {
1629 +- rc = -ENOMEM;
1630 +- goto out;
1631 +- }
1632 +- chip->work_space.session_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
1633 +- if (!chip->work_space.session_buf) {
1634 ++ rc = tpm2_init_space(&chip->work_space, TPM2_SPACE_BUFFER_SIZE);
1635 ++ if (rc) {
1636 + rc = -ENOMEM;
1637 + goto out;
1638 + }
1639 +diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
1640 +index 218cb496222a..37f010421a36 100644
1641 +--- a/drivers/char/tpm/tpm.h
1642 ++++ b/drivers/char/tpm/tpm.h
1643 +@@ -177,6 +177,9 @@ struct tpm_header {
1644 +
1645 + #define TPM_TAG_RQU_COMMAND 193
1646 +
1647 ++/* TPM2 specific constants. */
1648 ++#define TPM2_SPACE_BUFFER_SIZE 16384 /* 16 kB */
1649 ++
1650 + struct stclear_flags_t {
1651 + __be16 tag;
1652 + u8 deactivated;
1653 +@@ -456,7 +459,7 @@ void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
1654 + unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
1655 + int tpm2_probe(struct tpm_chip *chip);
1656 + int tpm2_find_cc(struct tpm_chip *chip, u32 cc);
1657 +-int tpm2_init_space(struct tpm_space *space);
1658 ++int tpm2_init_space(struct tpm_space *space, unsigned int buf_size);
1659 + void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space);
1660 + void tpm2_flush_space(struct tpm_chip *chip);
1661 + int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u8 *cmd,
1662 +diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
1663 +index 982d341d8837..784b8b3cb903 100644
1664 +--- a/drivers/char/tpm/tpm2-space.c
1665 ++++ b/drivers/char/tpm/tpm2-space.c
1666 +@@ -38,18 +38,21 @@ static void tpm2_flush_sessions(struct tpm_chip *chip, struct tpm_space *space)
1667 + }
1668 + }
1669 +
1670 +-int tpm2_init_space(struct tpm_space *space)
1671 ++int tpm2_init_space(struct tpm_space *space, unsigned int buf_size)
1672 + {
1673 +- space->context_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
1674 ++ space->context_buf = kzalloc(buf_size, GFP_KERNEL);
1675 + if (!space->context_buf)
1676 + return -ENOMEM;
1677 +
1678 +- space->session_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
1679 ++ space->session_buf = kzalloc(buf_size, GFP_KERNEL);
1680 + if (space->session_buf == NULL) {
1681 + kfree(space->context_buf);
1682 ++ /* Prevent caller getting a dangling pointer. */
1683 ++ space->context_buf = NULL;
1684 + return -ENOMEM;
1685 + }
1686 +
1687 ++ space->buf_size = buf_size;
1688 + return 0;
1689 + }
1690 +
1691 +@@ -311,8 +314,10 @@ int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u8 *cmd,
1692 + sizeof(space->context_tbl));
1693 + memcpy(&chip->work_space.session_tbl, &space->session_tbl,
1694 + sizeof(space->session_tbl));
1695 +- memcpy(chip->work_space.context_buf, space->context_buf, PAGE_SIZE);
1696 +- memcpy(chip->work_space.session_buf, space->session_buf, PAGE_SIZE);
1697 ++ memcpy(chip->work_space.context_buf, space->context_buf,
1698 ++ space->buf_size);
1699 ++ memcpy(chip->work_space.session_buf, space->session_buf,
1700 ++ space->buf_size);
1701 +
1702 + rc = tpm2_load_space(chip);
1703 + if (rc) {
1704 +@@ -492,7 +497,7 @@ static int tpm2_save_space(struct tpm_chip *chip)
1705 + continue;
1706 +
1707 + rc = tpm2_save_context(chip, space->context_tbl[i],
1708 +- space->context_buf, PAGE_SIZE,
1709 ++ space->context_buf, space->buf_size,
1710 + &offset);
1711 + if (rc == -ENOENT) {
1712 + space->context_tbl[i] = 0;
1713 +@@ -509,9 +514,8 @@ static int tpm2_save_space(struct tpm_chip *chip)
1714 + continue;
1715 +
1716 + rc = tpm2_save_context(chip, space->session_tbl[i],
1717 +- space->session_buf, PAGE_SIZE,
1718 ++ space->session_buf, space->buf_size,
1719 + &offset);
1720 +-
1721 + if (rc == -ENOENT) {
1722 + /* handle error saving session, just forget it */
1723 + space->session_tbl[i] = 0;
1724 +@@ -557,8 +561,10 @@ int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space,
1725 + sizeof(space->context_tbl));
1726 + memcpy(&space->session_tbl, &chip->work_space.session_tbl,
1727 + sizeof(space->session_tbl));
1728 +- memcpy(space->context_buf, chip->work_space.context_buf, PAGE_SIZE);
1729 +- memcpy(space->session_buf, chip->work_space.session_buf, PAGE_SIZE);
1730 ++ memcpy(space->context_buf, chip->work_space.context_buf,
1731 ++ space->buf_size);
1732 ++ memcpy(space->session_buf, chip->work_space.session_buf,
1733 ++ space->buf_size);
1734 +
1735 + return 0;
1736 + out:
1737 +diff --git a/drivers/char/tpm/tpmrm-dev.c b/drivers/char/tpm/tpmrm-dev.c
1738 +index 7a0a7051a06f..eef0fb06ea83 100644
1739 +--- a/drivers/char/tpm/tpmrm-dev.c
1740 ++++ b/drivers/char/tpm/tpmrm-dev.c
1741 +@@ -21,7 +21,7 @@ static int tpmrm_open(struct inode *inode, struct file *file)
1742 + if (priv == NULL)
1743 + return -ENOMEM;
1744 +
1745 +- rc = tpm2_init_space(&priv->space);
1746 ++ rc = tpm2_init_space(&priv->space, TPM2_SPACE_BUFFER_SIZE);
1747 + if (rc) {
1748 + kfree(priv);
1749 + return -ENOMEM;
1750 +diff --git a/drivers/clk/bcm/clk-bcm63xx-gate.c b/drivers/clk/bcm/clk-bcm63xx-gate.c
1751 +index 98e884957db8..911a29bd744e 100644
1752 +--- a/drivers/clk/bcm/clk-bcm63xx-gate.c
1753 ++++ b/drivers/clk/bcm/clk-bcm63xx-gate.c
1754 +@@ -155,6 +155,7 @@ static int clk_bcm63xx_probe(struct platform_device *pdev)
1755 +
1756 + for (entry = table; entry->name; entry++)
1757 + maxbit = max_t(u8, maxbit, entry->bit);
1758 ++ maxbit++;
1759 +
1760 + hw = devm_kzalloc(&pdev->dev, struct_size(hw, data.hws, maxbit),
1761 + GFP_KERNEL);
1762 +diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c
1763 +index 886f7c5df51a..e3cdb4a282fe 100644
1764 +--- a/drivers/clk/clk-scmi.c
1765 ++++ b/drivers/clk/clk-scmi.c
1766 +@@ -103,6 +103,8 @@ static const struct clk_ops scmi_clk_ops = {
1767 + static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk)
1768 + {
1769 + int ret;
1770 ++ unsigned long min_rate, max_rate;
1771 ++
1772 + struct clk_init_data init = {
1773 + .flags = CLK_GET_RATE_NOCACHE,
1774 + .num_parents = 0,
1775 +@@ -112,9 +114,23 @@ static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk)
1776 +
1777 + sclk->hw.init = &init;
1778 + ret = devm_clk_hw_register(dev, &sclk->hw);
1779 +- if (!ret)
1780 +- clk_hw_set_rate_range(&sclk->hw, sclk->info->range.min_rate,
1781 +- sclk->info->range.max_rate);
1782 ++ if (ret)
1783 ++ return ret;
1784 ++
1785 ++ if (sclk->info->rate_discrete) {
1786 ++ int num_rates = sclk->info->list.num_rates;
1787 ++
1788 ++ if (num_rates <= 0)
1789 ++ return -EINVAL;
1790 ++
1791 ++ min_rate = sclk->info->list.rates[0];
1792 ++ max_rate = sclk->info->list.rates[num_rates - 1];
1793 ++ } else {
1794 ++ min_rate = sclk->info->range.min_rate;
1795 ++ max_rate = sclk->info->range.max_rate;
1796 ++ }
1797 ++
1798 ++ clk_hw_set_rate_range(&sclk->hw, min_rate, max_rate);
1799 + return ret;
1800 + }
1801 +
1802 +diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
1803 +index 96a36f6ff667..d7586e26acd8 100644
1804 +--- a/drivers/clk/qcom/clk-rpmh.c
1805 ++++ b/drivers/clk/qcom/clk-rpmh.c
1806 +@@ -143,12 +143,22 @@ static inline bool has_state_changed(struct clk_rpmh *c, u32 state)
1807 + != (c->aggr_state & BIT(state));
1808 + }
1809 +
1810 ++static int clk_rpmh_send(struct clk_rpmh *c, enum rpmh_state state,
1811 ++ struct tcs_cmd *cmd, bool wait)
1812 ++{
1813 ++ if (wait)
1814 ++ return rpmh_write(c->dev, state, cmd, 1);
1815 ++
1816 ++ return rpmh_write_async(c->dev, state, cmd, 1);
1817 ++}
1818 ++
1819 + static int clk_rpmh_send_aggregate_command(struct clk_rpmh *c)
1820 + {
1821 + struct tcs_cmd cmd = { 0 };
1822 + u32 cmd_state, on_val;
1823 + enum rpmh_state state = RPMH_SLEEP_STATE;
1824 + int ret;
1825 ++ bool wait;
1826 +
1827 + cmd.addr = c->res_addr;
1828 + cmd_state = c->aggr_state;
1829 +@@ -159,7 +169,8 @@ static int clk_rpmh_send_aggregate_command(struct clk_rpmh *c)
1830 + if (cmd_state & BIT(state))
1831 + cmd.data = on_val;
1832 +
1833 +- ret = rpmh_write_async(c->dev, state, &cmd, 1);
1834 ++ wait = cmd_state && state == RPMH_ACTIVE_ONLY_STATE;
1835 ++ ret = clk_rpmh_send(c, state, &cmd, wait);
1836 + if (ret) {
1837 + dev_err(c->dev, "set %s state of %s failed: (%d)\n",
1838 + !state ? "sleep" :
1839 +@@ -267,7 +278,7 @@ static int clk_rpmh_bcm_send_cmd(struct clk_rpmh *c, bool enable)
1840 + cmd.addr = c->res_addr;
1841 + cmd.data = BCM_TCS_CMD(1, enable, 0, cmd_state);
1842 +
1843 +- ret = rpmh_write_async(c->dev, RPMH_ACTIVE_ONLY_STATE, &cmd, 1);
1844 ++ ret = clk_rpmh_send(c, RPMH_ACTIVE_ONLY_STATE, &cmd, enable);
1845 + if (ret) {
1846 + dev_err(c->dev, "set active state of %s failed: (%d)\n",
1847 + c->res_name, ret);
1848 +diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
1849 +index a905796f7f85..25f11e9ec358 100644
1850 +--- a/drivers/cpufreq/Kconfig.arm
1851 ++++ b/drivers/cpufreq/Kconfig.arm
1852 +@@ -41,6 +41,7 @@ config ARM_ARMADA_37XX_CPUFREQ
1853 + config ARM_ARMADA_8K_CPUFREQ
1854 + tristate "Armada 8K CPUFreq driver"
1855 + depends on ARCH_MVEBU && CPUFREQ_DT
1856 ++ select ARMADA_AP_CPU_CLK
1857 + help
1858 + This enables the CPUFreq driver support for Marvell
1859 + Armada8k SOCs.
1860 +diff --git a/drivers/cpufreq/armada-37xx-cpufreq.c b/drivers/cpufreq/armada-37xx-cpufreq.c
1861 +index aa0f06dec959..df1c941260d1 100644
1862 +--- a/drivers/cpufreq/armada-37xx-cpufreq.c
1863 ++++ b/drivers/cpufreq/armada-37xx-cpufreq.c
1864 +@@ -456,6 +456,7 @@ static int __init armada37xx_cpufreq_driver_init(void)
1865 + /* Now that everything is setup, enable the DVFS at hardware level */
1866 + armada37xx_cpufreq_enable_dvfs(nb_pm_base);
1867 +
1868 ++ memset(&pdata, 0, sizeof(pdata));
1869 + pdata.suspend = armada37xx_cpufreq_suspend;
1870 + pdata.resume = armada37xx_cpufreq_resume;
1871 +
1872 +diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
1873 +index fa988bd1e606..194a6587a1de 100644
1874 +--- a/drivers/cpufreq/cpufreq.c
1875 ++++ b/drivers/cpufreq/cpufreq.c
1876 +@@ -616,6 +616,24 @@ static struct cpufreq_governor *find_governor(const char *str_governor)
1877 + return NULL;
1878 + }
1879 +
1880 ++static struct cpufreq_governor *get_governor(const char *str_governor)
1881 ++{
1882 ++ struct cpufreq_governor *t;
1883 ++
1884 ++ mutex_lock(&cpufreq_governor_mutex);
1885 ++ t = find_governor(str_governor);
1886 ++ if (!t)
1887 ++ goto unlock;
1888 ++
1889 ++ if (!try_module_get(t->owner))
1890 ++ t = NULL;
1891 ++
1892 ++unlock:
1893 ++ mutex_unlock(&cpufreq_governor_mutex);
1894 ++
1895 ++ return t;
1896 ++}
1897 ++
1898 + static unsigned int cpufreq_parse_policy(char *str_governor)
1899 + {
1900 + if (!strncasecmp(str_governor, "performance", CPUFREQ_NAME_LEN))
1901 +@@ -635,28 +653,14 @@ static struct cpufreq_governor *cpufreq_parse_governor(char *str_governor)
1902 + {
1903 + struct cpufreq_governor *t;
1904 +
1905 +- mutex_lock(&cpufreq_governor_mutex);
1906 ++ t = get_governor(str_governor);
1907 ++ if (t)
1908 ++ return t;
1909 +
1910 +- t = find_governor(str_governor);
1911 +- if (!t) {
1912 +- int ret;
1913 +-
1914 +- mutex_unlock(&cpufreq_governor_mutex);
1915 +-
1916 +- ret = request_module("cpufreq_%s", str_governor);
1917 +- if (ret)
1918 +- return NULL;
1919 +-
1920 +- mutex_lock(&cpufreq_governor_mutex);
1921 +-
1922 +- t = find_governor(str_governor);
1923 +- }
1924 +- if (t && !try_module_get(t->owner))
1925 +- t = NULL;
1926 +-
1927 +- mutex_unlock(&cpufreq_governor_mutex);
1928 ++ if (request_module("cpufreq_%s", str_governor))
1929 ++ return NULL;
1930 +
1931 +- return t;
1932 ++ return get_governor(str_governor);
1933 + }
1934 +
1935 + /**
1936 +@@ -810,12 +814,14 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy,
1937 + goto out;
1938 + }
1939 +
1940 ++ mutex_lock(&cpufreq_governor_mutex);
1941 + for_each_governor(t) {
1942 + if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char))
1943 + - (CPUFREQ_NAME_LEN + 2)))
1944 +- goto out;
1945 ++ break;
1946 + i += scnprintf(&buf[i], CPUFREQ_NAME_PLEN, "%s ", t->name);
1947 + }
1948 ++ mutex_unlock(&cpufreq_governor_mutex);
1949 + out:
1950 + i += sprintf(&buf[i], "\n");
1951 + return i;
1952 +@@ -1053,15 +1059,17 @@ static int cpufreq_init_policy(struct cpufreq_policy *policy)
1953 + struct cpufreq_governor *def_gov = cpufreq_default_governor();
1954 + struct cpufreq_governor *gov = NULL;
1955 + unsigned int pol = CPUFREQ_POLICY_UNKNOWN;
1956 ++ int ret;
1957 +
1958 + if (has_target()) {
1959 + /* Update policy governor to the one used before hotplug. */
1960 +- gov = find_governor(policy->last_governor);
1961 ++ gov = get_governor(policy->last_governor);
1962 + if (gov) {
1963 + pr_debug("Restoring governor %s for cpu %d\n",
1964 + policy->governor->name, policy->cpu);
1965 + } else if (def_gov) {
1966 + gov = def_gov;
1967 ++ __module_get(gov->owner);
1968 + } else {
1969 + return -ENODATA;
1970 + }
1971 +@@ -1084,7 +1092,11 @@ static int cpufreq_init_policy(struct cpufreq_policy *policy)
1972 + return -ENODATA;
1973 + }
1974 +
1975 +- return cpufreq_set_policy(policy, gov, pol);
1976 ++ ret = cpufreq_set_policy(policy, gov, pol);
1977 ++ if (gov)
1978 ++ module_put(gov->owner);
1979 ++
1980 ++ return ret;
1981 + }
1982 +
1983 + static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu)
1984 +diff --git a/drivers/crypto/cavium/cpt/cptvf_algs.c b/drivers/crypto/cavium/cpt/cptvf_algs.c
1985 +index 596ce28b957d..2410b23aa609 100644
1986 +--- a/drivers/crypto/cavium/cpt/cptvf_algs.c
1987 ++++ b/drivers/crypto/cavium/cpt/cptvf_algs.c
1988 +@@ -200,6 +200,7 @@ static inline int cvm_enc_dec(struct ablkcipher_request *req, u32 enc)
1989 + int status;
1990 +
1991 + memset(req_info, 0, sizeof(struct cpt_request_info));
1992 ++ req_info->may_sleep = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) != 0;
1993 + memset(fctx, 0, sizeof(struct fc_context));
1994 + create_input_list(req, enc, enc_iv_len);
1995 + create_output_list(req, enc_iv_len);
1996 +diff --git a/drivers/crypto/cavium/cpt/cptvf_reqmanager.c b/drivers/crypto/cavium/cpt/cptvf_reqmanager.c
1997 +index 7a24019356b5..e343249c8d05 100644
1998 +--- a/drivers/crypto/cavium/cpt/cptvf_reqmanager.c
1999 ++++ b/drivers/crypto/cavium/cpt/cptvf_reqmanager.c
2000 +@@ -133,7 +133,7 @@ static inline int setup_sgio_list(struct cpt_vf *cptvf,
2001 +
2002 + /* Setup gather (input) components */
2003 + g_sz_bytes = ((req->incnt + 3) / 4) * sizeof(struct sglist_component);
2004 +- info->gather_components = kzalloc(g_sz_bytes, GFP_KERNEL);
2005 ++ info->gather_components = kzalloc(g_sz_bytes, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
2006 + if (!info->gather_components) {
2007 + ret = -ENOMEM;
2008 + goto scatter_gather_clean;
2009 +@@ -150,7 +150,7 @@ static inline int setup_sgio_list(struct cpt_vf *cptvf,
2010 +
2011 + /* Setup scatter (output) components */
2012 + s_sz_bytes = ((req->outcnt + 3) / 4) * sizeof(struct sglist_component);
2013 +- info->scatter_components = kzalloc(s_sz_bytes, GFP_KERNEL);
2014 ++ info->scatter_components = kzalloc(s_sz_bytes, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
2015 + if (!info->scatter_components) {
2016 + ret = -ENOMEM;
2017 + goto scatter_gather_clean;
2018 +@@ -167,7 +167,7 @@ static inline int setup_sgio_list(struct cpt_vf *cptvf,
2019 +
2020 + /* Create and initialize DPTR */
2021 + info->dlen = g_sz_bytes + s_sz_bytes + SG_LIST_HDR_SIZE;
2022 +- info->in_buffer = kzalloc(info->dlen, GFP_KERNEL);
2023 ++ info->in_buffer = kzalloc(info->dlen, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
2024 + if (!info->in_buffer) {
2025 + ret = -ENOMEM;
2026 + goto scatter_gather_clean;
2027 +@@ -195,7 +195,7 @@ static inline int setup_sgio_list(struct cpt_vf *cptvf,
2028 + }
2029 +
2030 + /* Create and initialize RPTR */
2031 +- info->out_buffer = kzalloc(COMPLETION_CODE_SIZE, GFP_KERNEL);
2032 ++ info->out_buffer = kzalloc(COMPLETION_CODE_SIZE, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
2033 + if (!info->out_buffer) {
2034 + ret = -ENOMEM;
2035 + goto scatter_gather_clean;
2036 +@@ -421,7 +421,7 @@ int process_request(struct cpt_vf *cptvf, struct cpt_request_info *req)
2037 + struct cpt_vq_command vq_cmd;
2038 + union cpt_inst_s cptinst;
2039 +
2040 +- info = kzalloc(sizeof(*info), GFP_KERNEL);
2041 ++ info = kzalloc(sizeof(*info), req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
2042 + if (unlikely(!info)) {
2043 + dev_err(&pdev->dev, "Unable to allocate memory for info_buffer\n");
2044 + return -ENOMEM;
2045 +@@ -443,7 +443,7 @@ int process_request(struct cpt_vf *cptvf, struct cpt_request_info *req)
2046 + * Get buffer for union cpt_res_s response
2047 + * structure and its physical address
2048 + */
2049 +- info->completion_addr = kzalloc(sizeof(union cpt_res_s), GFP_KERNEL);
2050 ++ info->completion_addr = kzalloc(sizeof(union cpt_res_s), req->may_sleep ? GFP_KERNEL : GFP_ATOMIC);
2051 + if (unlikely(!info->completion_addr)) {
2052 + dev_err(&pdev->dev, "Unable to allocate memory for completion_addr\n");
2053 + ret = -ENOMEM;
2054 +diff --git a/drivers/crypto/cavium/cpt/request_manager.h b/drivers/crypto/cavium/cpt/request_manager.h
2055 +index 3514b082eca7..1e8dd9ebcc17 100644
2056 +--- a/drivers/crypto/cavium/cpt/request_manager.h
2057 ++++ b/drivers/crypto/cavium/cpt/request_manager.h
2058 +@@ -62,6 +62,8 @@ struct cpt_request_info {
2059 + union ctrl_info ctrl; /* User control information */
2060 + struct cptvf_request req; /* Request Information (Core specific) */
2061 +
2062 ++ bool may_sleep;
2063 ++
2064 + struct buf_ptr in[MAX_BUF_CNT];
2065 + struct buf_ptr out[MAX_BUF_CNT];
2066 +
2067 +diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
2068 +index 3f68262d9ab4..87a34d91fdf7 100644
2069 +--- a/drivers/crypto/ccp/ccp-dev.h
2070 ++++ b/drivers/crypto/ccp/ccp-dev.h
2071 +@@ -469,6 +469,7 @@ struct ccp_sg_workarea {
2072 + unsigned int sg_used;
2073 +
2074 + struct scatterlist *dma_sg;
2075 ++ struct scatterlist *dma_sg_head;
2076 + struct device *dma_dev;
2077 + unsigned int dma_count;
2078 + enum dma_data_direction dma_dir;
2079 +diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
2080 +index 422193690fd4..64112c736810 100644
2081 +--- a/drivers/crypto/ccp/ccp-ops.c
2082 ++++ b/drivers/crypto/ccp/ccp-ops.c
2083 +@@ -63,7 +63,7 @@ static u32 ccp_gen_jobid(struct ccp_device *ccp)
2084 + static void ccp_sg_free(struct ccp_sg_workarea *wa)
2085 + {
2086 + if (wa->dma_count)
2087 +- dma_unmap_sg(wa->dma_dev, wa->dma_sg, wa->nents, wa->dma_dir);
2088 ++ dma_unmap_sg(wa->dma_dev, wa->dma_sg_head, wa->nents, wa->dma_dir);
2089 +
2090 + wa->dma_count = 0;
2091 + }
2092 +@@ -92,6 +92,7 @@ static int ccp_init_sg_workarea(struct ccp_sg_workarea *wa, struct device *dev,
2093 + return 0;
2094 +
2095 + wa->dma_sg = sg;
2096 ++ wa->dma_sg_head = sg;
2097 + wa->dma_dev = dev;
2098 + wa->dma_dir = dma_dir;
2099 + wa->dma_count = dma_map_sg(dev, sg, wa->nents, dma_dir);
2100 +@@ -104,14 +105,28 @@ static int ccp_init_sg_workarea(struct ccp_sg_workarea *wa, struct device *dev,
2101 + static void ccp_update_sg_workarea(struct ccp_sg_workarea *wa, unsigned int len)
2102 + {
2103 + unsigned int nbytes = min_t(u64, len, wa->bytes_left);
2104 ++ unsigned int sg_combined_len = 0;
2105 +
2106 + if (!wa->sg)
2107 + return;
2108 +
2109 + wa->sg_used += nbytes;
2110 + wa->bytes_left -= nbytes;
2111 +- if (wa->sg_used == wa->sg->length) {
2112 +- wa->sg = sg_next(wa->sg);
2113 ++ if (wa->sg_used == sg_dma_len(wa->dma_sg)) {
2114 ++ /* Advance to the next DMA scatterlist entry */
2115 ++ wa->dma_sg = sg_next(wa->dma_sg);
2116 ++
2117 ++ /* In the case that the DMA mapped scatterlist has entries
2118 ++ * that have been merged, the non-DMA mapped scatterlist
2119 ++ * must be advanced multiple times for each merged entry.
2120 ++ * This ensures that the current non-DMA mapped entry
2121 ++ * corresponds to the current DMA mapped entry.
2122 ++ */
2123 ++ do {
2124 ++ sg_combined_len += wa->sg->length;
2125 ++ wa->sg = sg_next(wa->sg);
2126 ++ } while (wa->sg_used > sg_combined_len);
2127 ++
2128 + wa->sg_used = 0;
2129 + }
2130 + }
2131 +@@ -299,7 +314,7 @@ static unsigned int ccp_queue_buf(struct ccp_data *data, unsigned int from)
2132 + /* Update the structures and generate the count */
2133 + buf_count = 0;
2134 + while (sg_wa->bytes_left && (buf_count < dm_wa->length)) {
2135 +- nbytes = min(sg_wa->sg->length - sg_wa->sg_used,
2136 ++ nbytes = min(sg_dma_len(sg_wa->dma_sg) - sg_wa->sg_used,
2137 + dm_wa->length - buf_count);
2138 + nbytes = min_t(u64, sg_wa->bytes_left, nbytes);
2139 +
2140 +@@ -331,11 +346,11 @@ static void ccp_prepare_data(struct ccp_data *src, struct ccp_data *dst,
2141 + * and destination. The resulting len values will always be <= UINT_MAX
2142 + * because the dma length is an unsigned int.
2143 + */
2144 +- sg_src_len = sg_dma_len(src->sg_wa.sg) - src->sg_wa.sg_used;
2145 ++ sg_src_len = sg_dma_len(src->sg_wa.dma_sg) - src->sg_wa.sg_used;
2146 + sg_src_len = min_t(u64, src->sg_wa.bytes_left, sg_src_len);
2147 +
2148 + if (dst) {
2149 +- sg_dst_len = sg_dma_len(dst->sg_wa.sg) - dst->sg_wa.sg_used;
2150 ++ sg_dst_len = sg_dma_len(dst->sg_wa.dma_sg) - dst->sg_wa.sg_used;
2151 + sg_dst_len = min_t(u64, src->sg_wa.bytes_left, sg_dst_len);
2152 + op_len = min(sg_src_len, sg_dst_len);
2153 + } else {
2154 +@@ -365,7 +380,7 @@ static void ccp_prepare_data(struct ccp_data *src, struct ccp_data *dst,
2155 + /* Enough data in the sg element, but we need to
2156 + * adjust for any previously copied data
2157 + */
2158 +- op->src.u.dma.address = sg_dma_address(src->sg_wa.sg);
2159 ++ op->src.u.dma.address = sg_dma_address(src->sg_wa.dma_sg);
2160 + op->src.u.dma.offset = src->sg_wa.sg_used;
2161 + op->src.u.dma.length = op_len & ~(block_size - 1);
2162 +
2163 +@@ -386,7 +401,7 @@ static void ccp_prepare_data(struct ccp_data *src, struct ccp_data *dst,
2164 + /* Enough room in the sg element, but we need to
2165 + * adjust for any previously used area
2166 + */
2167 +- op->dst.u.dma.address = sg_dma_address(dst->sg_wa.sg);
2168 ++ op->dst.u.dma.address = sg_dma_address(dst->sg_wa.dma_sg);
2169 + op->dst.u.dma.offset = dst->sg_wa.sg_used;
2170 + op->dst.u.dma.length = op->src.u.dma.length;
2171 + }
2172 +@@ -2028,7 +2043,7 @@ ccp_run_passthru_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
2173 + dst.sg_wa.sg_used = 0;
2174 + for (i = 1; i <= src.sg_wa.dma_count; i++) {
2175 + if (!dst.sg_wa.sg ||
2176 +- (dst.sg_wa.sg->length < src.sg_wa.sg->length)) {
2177 ++ (sg_dma_len(dst.sg_wa.sg) < sg_dma_len(src.sg_wa.sg))) {
2178 + ret = -EINVAL;
2179 + goto e_dst;
2180 + }
2181 +@@ -2054,8 +2069,8 @@ ccp_run_passthru_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
2182 + goto e_dst;
2183 + }
2184 +
2185 +- dst.sg_wa.sg_used += src.sg_wa.sg->length;
2186 +- if (dst.sg_wa.sg_used == dst.sg_wa.sg->length) {
2187 ++ dst.sg_wa.sg_used += sg_dma_len(src.sg_wa.sg);
2188 ++ if (dst.sg_wa.sg_used == sg_dma_len(dst.sg_wa.sg)) {
2189 + dst.sg_wa.sg = sg_next(dst.sg_wa.sg);
2190 + dst.sg_wa.sg_used = 0;
2191 + }
2192 +diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
2193 +index cd9c60268bf8..9bf0cce578f0 100644
2194 +--- a/drivers/crypto/ccree/cc_cipher.c
2195 ++++ b/drivers/crypto/ccree/cc_cipher.c
2196 +@@ -163,7 +163,6 @@ static int cc_cipher_init(struct crypto_tfm *tfm)
2197 + skcipher_alg.base);
2198 + struct device *dev = drvdata_to_dev(cc_alg->drvdata);
2199 + unsigned int max_key_buf_size = cc_alg->skcipher_alg.max_keysize;
2200 +- int rc = 0;
2201 +
2202 + dev_dbg(dev, "Initializing context @%p for %s\n", ctx_p,
2203 + crypto_tfm_alg_name(tfm));
2204 +@@ -175,10 +174,19 @@ static int cc_cipher_init(struct crypto_tfm *tfm)
2205 + ctx_p->flow_mode = cc_alg->flow_mode;
2206 + ctx_p->drvdata = cc_alg->drvdata;
2207 +
2208 ++ if (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) {
2209 ++ /* Alloc hash tfm for essiv */
2210 ++ ctx_p->shash_tfm = crypto_alloc_shash("sha256-generic", 0, 0);
2211 ++ if (IS_ERR(ctx_p->shash_tfm)) {
2212 ++ dev_err(dev, "Error allocating hash tfm for ESSIV.\n");
2213 ++ return PTR_ERR(ctx_p->shash_tfm);
2214 ++ }
2215 ++ }
2216 ++
2217 + /* Allocate key buffer, cache line aligned */
2218 + ctx_p->user.key = kmalloc(max_key_buf_size, GFP_KERNEL);
2219 + if (!ctx_p->user.key)
2220 +- return -ENOMEM;
2221 ++ goto free_shash;
2222 +
2223 + dev_dbg(dev, "Allocated key buffer in context. key=@%p\n",
2224 + ctx_p->user.key);
2225 +@@ -190,21 +198,19 @@ static int cc_cipher_init(struct crypto_tfm *tfm)
2226 + if (dma_mapping_error(dev, ctx_p->user.key_dma_addr)) {
2227 + dev_err(dev, "Mapping Key %u B at va=%pK for DMA failed\n",
2228 + max_key_buf_size, ctx_p->user.key);
2229 +- return -ENOMEM;
2230 ++ goto free_key;
2231 + }
2232 + dev_dbg(dev, "Mapped key %u B at va=%pK to dma=%pad\n",
2233 + max_key_buf_size, ctx_p->user.key, &ctx_p->user.key_dma_addr);
2234 +
2235 +- if (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) {
2236 +- /* Alloc hash tfm for essiv */
2237 +- ctx_p->shash_tfm = crypto_alloc_shash("sha256-generic", 0, 0);
2238 +- if (IS_ERR(ctx_p->shash_tfm)) {
2239 +- dev_err(dev, "Error allocating hash tfm for ESSIV.\n");
2240 +- return PTR_ERR(ctx_p->shash_tfm);
2241 +- }
2242 +- }
2243 ++ return 0;
2244 +
2245 +- return rc;
2246 ++free_key:
2247 ++ kfree(ctx_p->user.key);
2248 ++free_shash:
2249 ++ crypto_free_shash(ctx_p->shash_tfm);
2250 ++
2251 ++ return -ENOMEM;
2252 + }
2253 +
2254 + static void cc_cipher_exit(struct crypto_tfm *tfm)
2255 +diff --git a/drivers/crypto/hisilicon/sec/sec_algs.c b/drivers/crypto/hisilicon/sec/sec_algs.c
2256 +index c27e7160d2df..4ad4ffd90cee 100644
2257 +--- a/drivers/crypto/hisilicon/sec/sec_algs.c
2258 ++++ b/drivers/crypto/hisilicon/sec/sec_algs.c
2259 +@@ -175,7 +175,8 @@ static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl,
2260 + dma_addr_t *psec_sgl,
2261 + struct scatterlist *sgl,
2262 + int count,
2263 +- struct sec_dev_info *info)
2264 ++ struct sec_dev_info *info,
2265 ++ gfp_t gfp)
2266 + {
2267 + struct sec_hw_sgl *sgl_current = NULL;
2268 + struct sec_hw_sgl *sgl_next;
2269 +@@ -190,7 +191,7 @@ static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl,
2270 + sge_index = i % SEC_MAX_SGE_NUM;
2271 + if (sge_index == 0) {
2272 + sgl_next = dma_pool_zalloc(info->hw_sgl_pool,
2273 +- GFP_KERNEL, &sgl_next_dma);
2274 ++ gfp, &sgl_next_dma);
2275 + if (!sgl_next) {
2276 + ret = -ENOMEM;
2277 + goto err_free_hw_sgls;
2278 +@@ -545,14 +546,14 @@ void sec_alg_callback(struct sec_bd_info *resp, void *shadow)
2279 + }
2280 +
2281 + static int sec_alg_alloc_and_calc_split_sizes(int length, size_t **split_sizes,
2282 +- int *steps)
2283 ++ int *steps, gfp_t gfp)
2284 + {
2285 + size_t *sizes;
2286 + int i;
2287 +
2288 + /* Split into suitable sized blocks */
2289 + *steps = roundup(length, SEC_REQ_LIMIT) / SEC_REQ_LIMIT;
2290 +- sizes = kcalloc(*steps, sizeof(*sizes), GFP_KERNEL);
2291 ++ sizes = kcalloc(*steps, sizeof(*sizes), gfp);
2292 + if (!sizes)
2293 + return -ENOMEM;
2294 +
2295 +@@ -568,7 +569,7 @@ static int sec_map_and_split_sg(struct scatterlist *sgl, size_t *split_sizes,
2296 + int steps, struct scatterlist ***splits,
2297 + int **splits_nents,
2298 + int sgl_len_in,
2299 +- struct device *dev)
2300 ++ struct device *dev, gfp_t gfp)
2301 + {
2302 + int ret, count;
2303 +
2304 +@@ -576,12 +577,12 @@ static int sec_map_and_split_sg(struct scatterlist *sgl, size_t *split_sizes,
2305 + if (!count)
2306 + return -EINVAL;
2307 +
2308 +- *splits = kcalloc(steps, sizeof(struct scatterlist *), GFP_KERNEL);
2309 ++ *splits = kcalloc(steps, sizeof(struct scatterlist *), gfp);
2310 + if (!*splits) {
2311 + ret = -ENOMEM;
2312 + goto err_unmap_sg;
2313 + }
2314 +- *splits_nents = kcalloc(steps, sizeof(int), GFP_KERNEL);
2315 ++ *splits_nents = kcalloc(steps, sizeof(int), gfp);
2316 + if (!*splits_nents) {
2317 + ret = -ENOMEM;
2318 + goto err_free_splits;
2319 +@@ -589,7 +590,7 @@ static int sec_map_and_split_sg(struct scatterlist *sgl, size_t *split_sizes,
2320 +
2321 + /* output the scatter list before and after this */
2322 + ret = sg_split(sgl, count, 0, steps, split_sizes,
2323 +- *splits, *splits_nents, GFP_KERNEL);
2324 ++ *splits, *splits_nents, gfp);
2325 + if (ret) {
2326 + ret = -ENOMEM;
2327 + goto err_free_splits_nents;
2328 +@@ -630,13 +631,13 @@ static struct sec_request_el
2329 + int el_size, bool different_dest,
2330 + struct scatterlist *sgl_in, int n_ents_in,
2331 + struct scatterlist *sgl_out, int n_ents_out,
2332 +- struct sec_dev_info *info)
2333 ++ struct sec_dev_info *info, gfp_t gfp)
2334 + {
2335 + struct sec_request_el *el;
2336 + struct sec_bd_info *req;
2337 + int ret;
2338 +
2339 +- el = kzalloc(sizeof(*el), GFP_KERNEL);
2340 ++ el = kzalloc(sizeof(*el), gfp);
2341 + if (!el)
2342 + return ERR_PTR(-ENOMEM);
2343 + el->el_length = el_size;
2344 +@@ -668,7 +669,7 @@ static struct sec_request_el
2345 + el->sgl_in = sgl_in;
2346 +
2347 + ret = sec_alloc_and_fill_hw_sgl(&el->in, &el->dma_in, el->sgl_in,
2348 +- n_ents_in, info);
2349 ++ n_ents_in, info, gfp);
2350 + if (ret)
2351 + goto err_free_el;
2352 +
2353 +@@ -679,7 +680,7 @@ static struct sec_request_el
2354 + el->sgl_out = sgl_out;
2355 + ret = sec_alloc_and_fill_hw_sgl(&el->out, &el->dma_out,
2356 + el->sgl_out,
2357 +- n_ents_out, info);
2358 ++ n_ents_out, info, gfp);
2359 + if (ret)
2360 + goto err_free_hw_sgl_in;
2361 +
2362 +@@ -720,6 +721,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
2363 + int *splits_out_nents = NULL;
2364 + struct sec_request_el *el, *temp;
2365 + bool split = skreq->src != skreq->dst;
2366 ++ gfp_t gfp = skreq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : GFP_ATOMIC;
2367 +
2368 + mutex_init(&sec_req->lock);
2369 + sec_req->req_base = &skreq->base;
2370 +@@ -728,13 +730,13 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
2371 + sec_req->len_in = sg_nents(skreq->src);
2372 +
2373 + ret = sec_alg_alloc_and_calc_split_sizes(skreq->cryptlen, &split_sizes,
2374 +- &steps);
2375 ++ &steps, gfp);
2376 + if (ret)
2377 + return ret;
2378 + sec_req->num_elements = steps;
2379 + ret = sec_map_and_split_sg(skreq->src, split_sizes, steps, &splits_in,
2380 + &splits_in_nents, sec_req->len_in,
2381 +- info->dev);
2382 ++ info->dev, gfp);
2383 + if (ret)
2384 + goto err_free_split_sizes;
2385 +
2386 +@@ -742,7 +744,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
2387 + sec_req->len_out = sg_nents(skreq->dst);
2388 + ret = sec_map_and_split_sg(skreq->dst, split_sizes, steps,
2389 + &splits_out, &splits_out_nents,
2390 +- sec_req->len_out, info->dev);
2391 ++ sec_req->len_out, info->dev, gfp);
2392 + if (ret)
2393 + goto err_unmap_in_sg;
2394 + }
2395 +@@ -775,7 +777,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
2396 + splits_in[i], splits_in_nents[i],
2397 + split ? splits_out[i] : NULL,
2398 + split ? splits_out_nents[i] : 0,
2399 +- info);
2400 ++ info, gfp);
2401 + if (IS_ERR(el)) {
2402 + ret = PTR_ERR(el);
2403 + goto err_free_elements;
2404 +diff --git a/drivers/crypto/qat/qat_common/qat_uclo.c b/drivers/crypto/qat/qat_common/qat_uclo.c
2405 +index 6bd8f6a2a24f..aeb03081415c 100644
2406 +--- a/drivers/crypto/qat/qat_common/qat_uclo.c
2407 ++++ b/drivers/crypto/qat/qat_common/qat_uclo.c
2408 +@@ -332,13 +332,18 @@ static int qat_uclo_create_batch_init_list(struct icp_qat_fw_loader_handle
2409 + }
2410 + return 0;
2411 + out_err:
2412 ++ /* Do not free the list head unless we allocated it. */
2413 ++ tail_old = tail_old->next;
2414 ++ if (flag) {
2415 ++ kfree(*init_tab_base);
2416 ++ *init_tab_base = NULL;
2417 ++ }
2418 ++
2419 + while (tail_old) {
2420 + mem_init = tail_old->next;
2421 + kfree(tail_old);
2422 + tail_old = mem_init;
2423 + }
2424 +- if (flag)
2425 +- kfree(*init_tab_base);
2426 + return -ENOMEM;
2427 + }
2428 +
2429 +diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
2430 +index 0e7ea3591b78..5e7593753799 100644
2431 +--- a/drivers/edac/edac_device_sysfs.c
2432 ++++ b/drivers/edac/edac_device_sysfs.c
2433 +@@ -275,6 +275,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
2434 +
2435 + /* Error exit stack */
2436 + err_kobj_reg:
2437 ++ kobject_put(&edac_dev->kobj);
2438 + module_put(edac_dev->owner);
2439 +
2440 + err_out:
2441 +diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
2442 +index 72c9eb9fdffb..53042af7262e 100644
2443 +--- a/drivers/edac/edac_pci_sysfs.c
2444 ++++ b/drivers/edac/edac_pci_sysfs.c
2445 +@@ -386,7 +386,7 @@ static int edac_pci_main_kobj_setup(void)
2446 +
2447 + /* Error unwind statck */
2448 + kobject_init_and_add_fail:
2449 +- kfree(edac_pci_top_main_kobj);
2450 ++ kobject_put(edac_pci_top_main_kobj);
2451 +
2452 + kzalloc_fail:
2453 + module_put(THIS_MODULE);
2454 +diff --git a/drivers/firmware/arm_scmi/scmi_pm_domain.c b/drivers/firmware/arm_scmi/scmi_pm_domain.c
2455 +index 87f737e01473..041f8152272b 100644
2456 +--- a/drivers/firmware/arm_scmi/scmi_pm_domain.c
2457 ++++ b/drivers/firmware/arm_scmi/scmi_pm_domain.c
2458 +@@ -85,7 +85,10 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
2459 + for (i = 0; i < num_domains; i++, scmi_pd++) {
2460 + u32 state;
2461 +
2462 +- domains[i] = &scmi_pd->genpd;
2463 ++ if (handle->power_ops->state_get(handle, i, &state)) {
2464 ++ dev_warn(dev, "failed to get state for domain %d\n", i);
2465 ++ continue;
2466 ++ }
2467 +
2468 + scmi_pd->domain = i;
2469 + scmi_pd->handle = handle;
2470 +@@ -94,13 +97,10 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
2471 + scmi_pd->genpd.power_off = scmi_pd_power_off;
2472 + scmi_pd->genpd.power_on = scmi_pd_power_on;
2473 +
2474 +- if (handle->power_ops->state_get(handle, i, &state)) {
2475 +- dev_warn(dev, "failed to get state for domain %d\n", i);
2476 +- continue;
2477 +- }
2478 +-
2479 + pm_genpd_init(&scmi_pd->genpd, NULL,
2480 + state == SCMI_POWER_STATE_GENERIC_OFF);
2481 ++
2482 ++ domains[i] = &scmi_pd->genpd;
2483 + }
2484 +
2485 + scmi_pd_data->domains = domains;
2486 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
2487 +index 23085b352cf2..c212d5fc665c 100644
2488 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
2489 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
2490 +@@ -404,7 +404,9 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
2491 + ring->fence_drv.gpu_addr = adev->uvd.inst[ring->me].gpu_addr + index;
2492 + }
2493 + amdgpu_fence_write(ring, atomic_read(&ring->fence_drv.last_seq));
2494 +- amdgpu_irq_get(adev, irq_src, irq_type);
2495 ++
2496 ++ if (irq_src)
2497 ++ amdgpu_irq_get(adev, irq_src, irq_type);
2498 +
2499 + ring->fence_drv.irq_src = irq_src;
2500 + ring->fence_drv.irq_type = irq_type;
2501 +@@ -539,8 +541,9 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev)
2502 + /* no need to trigger GPU reset as we are unloading */
2503 + amdgpu_fence_driver_force_completion(ring);
2504 + }
2505 +- amdgpu_irq_put(adev, ring->fence_drv.irq_src,
2506 +- ring->fence_drv.irq_type);
2507 ++ if (ring->fence_drv.irq_src)
2508 ++ amdgpu_irq_put(adev, ring->fence_drv.irq_src,
2509 ++ ring->fence_drv.irq_type);
2510 + drm_sched_fini(&ring->sched);
2511 + del_timer_sync(&ring->fence_drv.fallback_timer);
2512 + for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j)
2513 +@@ -576,8 +579,9 @@ void amdgpu_fence_driver_suspend(struct amdgpu_device *adev)
2514 + }
2515 +
2516 + /* disable the interrupt */
2517 +- amdgpu_irq_put(adev, ring->fence_drv.irq_src,
2518 +- ring->fence_drv.irq_type);
2519 ++ if (ring->fence_drv.irq_src)
2520 ++ amdgpu_irq_put(adev, ring->fence_drv.irq_src,
2521 ++ ring->fence_drv.irq_type);
2522 + }
2523 + }
2524 +
2525 +@@ -603,8 +607,9 @@ void amdgpu_fence_driver_resume(struct amdgpu_device *adev)
2526 + continue;
2527 +
2528 + /* enable the interrupt */
2529 +- amdgpu_irq_get(adev, ring->fence_drv.irq_src,
2530 +- ring->fence_drv.irq_type);
2531 ++ if (ring->fence_drv.irq_src)
2532 ++ amdgpu_irq_get(adev, ring->fence_drv.irq_src,
2533 ++ ring->fence_drv.irq_type);
2534 + }
2535 + }
2536 +
2537 +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
2538 +index 785322cd4c6c..7241d4c20778 100644
2539 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
2540 ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
2541 +@@ -530,6 +530,8 @@ bool dm_pp_get_static_clocks(
2542 + &pp_clk_info);
2543 + else if (adev->smu.funcs)
2544 + ret = smu_get_current_clocks(&adev->smu, &pp_clk_info);
2545 ++ else
2546 ++ return false;
2547 + if (ret)
2548 + return false;
2549 +
2550 +diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
2551 +index 0922d9cd858a..c4d8c52c6b9c 100644
2552 +--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
2553 ++++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
2554 +@@ -171,7 +171,8 @@ static int smu_v11_0_init_microcode(struct smu_context *smu)
2555 + chip_name = "navi12";
2556 + break;
2557 + default:
2558 +- BUG();
2559 ++ dev_err(adev->dev, "Unsupported ASIC type %d\n", adev->asic_type);
2560 ++ return -EINVAL;
2561 + }
2562 +
2563 + snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_smc.bin", chip_name);
2564 +diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
2565 +index 3c70a53813bf..0b2bb485d9be 100644
2566 +--- a/drivers/gpu/drm/arm/malidp_planes.c
2567 ++++ b/drivers/gpu/drm/arm/malidp_planes.c
2568 +@@ -928,7 +928,7 @@ int malidp_de_planes_init(struct drm_device *drm)
2569 + const struct malidp_hw_regmap *map = &malidp->dev->hw->map;
2570 + struct malidp_plane *plane = NULL;
2571 + enum drm_plane_type plane_type;
2572 +- unsigned long crtcs = 1 << drm->mode_config.num_crtc;
2573 ++ unsigned long crtcs = BIT(drm->mode_config.num_crtc);
2574 + unsigned long flags = DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_180 |
2575 + DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;
2576 + unsigned int blend_caps = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
2577 +diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
2578 +index bd3165ee5354..04431dbac4a4 100644
2579 +--- a/drivers/gpu/drm/bridge/sil-sii8620.c
2580 ++++ b/drivers/gpu/drm/bridge/sil-sii8620.c
2581 +@@ -177,7 +177,7 @@ static void sii8620_read_buf(struct sii8620 *ctx, u16 addr, u8 *buf, int len)
2582 +
2583 + static u8 sii8620_readb(struct sii8620 *ctx, u16 addr)
2584 + {
2585 +- u8 ret;
2586 ++ u8 ret = 0;
2587 +
2588 + sii8620_read_buf(ctx, addr, &ret, 1);
2589 + return ret;
2590 +diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
2591 +index 0a580957c8cf..f1de4bb6558c 100644
2592 +--- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
2593 ++++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
2594 +@@ -647,6 +647,12 @@ static ssize_t ti_sn_aux_transfer(struct drm_dp_aux *aux,
2595 + buf[i]);
2596 + }
2597 +
2598 ++ /* Clear old status bits before start so we don't get confused */
2599 ++ regmap_write(pdata->regmap, SN_AUX_CMD_STATUS_REG,
2600 ++ AUX_IRQ_STATUS_NAT_I2C_FAIL |
2601 ++ AUX_IRQ_STATUS_AUX_RPLY_TOUT |
2602 ++ AUX_IRQ_STATUS_AUX_SHORT);
2603 ++
2604 + regmap_write(pdata->regmap, SN_AUX_CMD_REG, request_val | AUX_CMD_SEND);
2605 +
2606 + ret = regmap_read_poll_timeout(pdata->regmap, SN_AUX_CMD_REG, val,
2607 +diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
2608 +index eab0f2687cd6..00debd02c322 100644
2609 +--- a/drivers/gpu/drm/drm_debugfs.c
2610 ++++ b/drivers/gpu/drm/drm_debugfs.c
2611 +@@ -337,13 +337,13 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
2612 +
2613 + buf[len] = '\0';
2614 +
2615 +- if (!strcmp(buf, "on"))
2616 ++ if (sysfs_streq(buf, "on"))
2617 + connector->force = DRM_FORCE_ON;
2618 +- else if (!strcmp(buf, "digital"))
2619 ++ else if (sysfs_streq(buf, "digital"))
2620 + connector->force = DRM_FORCE_ON_DIGITAL;
2621 +- else if (!strcmp(buf, "off"))
2622 ++ else if (sysfs_streq(buf, "off"))
2623 + connector->force = DRM_FORCE_OFF;
2624 +- else if (!strcmp(buf, "unspecified"))
2625 ++ else if (sysfs_streq(buf, "unspecified"))
2626 + connector->force = DRM_FORCE_UNSPECIFIED;
2627 + else
2628 + return -EINVAL;
2629 +diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
2630 +index 46ad14470d06..1fdc85a71cec 100644
2631 +--- a/drivers/gpu/drm/drm_gem.c
2632 ++++ b/drivers/gpu/drm/drm_gem.c
2633 +@@ -710,6 +710,8 @@ int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles,
2634 + if (!objs)
2635 + return -ENOMEM;
2636 +
2637 ++ *objs_out = objs;
2638 ++
2639 + handles = kvmalloc_array(count, sizeof(u32), GFP_KERNEL);
2640 + if (!handles) {
2641 + ret = -ENOMEM;
2642 +@@ -723,8 +725,6 @@ int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles,
2643 + }
2644 +
2645 + ret = objects_lookup(filp, handles, count, objs);
2646 +- *objs_out = objs;
2647 +-
2648 + out:
2649 + kvfree(handles);
2650 + return ret;
2651 +diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
2652 +index bd2498bbd74a..b99f96dcc6f1 100644
2653 +--- a/drivers/gpu/drm/drm_mipi_dsi.c
2654 ++++ b/drivers/gpu/drm/drm_mipi_dsi.c
2655 +@@ -1029,11 +1029,11 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);
2656 + */
2657 + int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline)
2658 + {
2659 +- u8 payload[3] = { MIPI_DCS_SET_TEAR_SCANLINE, scanline >> 8,
2660 +- scanline & 0xff };
2661 ++ u8 payload[2] = { scanline >> 8, scanline & 0xff };
2662 + ssize_t err;
2663 +
2664 +- err = mipi_dsi_generic_write(dsi, payload, sizeof(payload));
2665 ++ err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_SCANLINE, payload,
2666 ++ sizeof(payload));
2667 + if (err < 0)
2668 + return err;
2669 +
2670 +diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
2671 +index d47d1a8e0219..85de8551ce86 100644
2672 +--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
2673 ++++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
2674 +@@ -713,7 +713,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
2675 + ret = pm_runtime_get_sync(gpu->dev);
2676 + if (ret < 0) {
2677 + dev_err(gpu->dev, "Failed to enable GPU power domain\n");
2678 +- return ret;
2679 ++ goto pm_put;
2680 + }
2681 +
2682 + etnaviv_hw_identify(gpu);
2683 +@@ -802,6 +802,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
2684 +
2685 + fail:
2686 + pm_runtime_mark_last_busy(gpu->dev);
2687 ++pm_put:
2688 + pm_runtime_put_autosuspend(gpu->dev);
2689 +
2690 + return ret;
2691 +@@ -842,7 +843,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
2692 +
2693 + ret = pm_runtime_get_sync(gpu->dev);
2694 + if (ret < 0)
2695 +- return ret;
2696 ++ goto pm_put;
2697 +
2698 + dma_lo = gpu_read(gpu, VIVS_FE_DMA_LOW);
2699 + dma_hi = gpu_read(gpu, VIVS_FE_DMA_HIGH);
2700 +@@ -965,6 +966,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
2701 + ret = 0;
2702 +
2703 + pm_runtime_mark_last_busy(gpu->dev);
2704 ++pm_put:
2705 + pm_runtime_put_autosuspend(gpu->dev);
2706 +
2707 + return ret;
2708 +@@ -978,7 +980,7 @@ void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
2709 + dev_err(gpu->dev, "recover hung GPU!\n");
2710 +
2711 + if (pm_runtime_get_sync(gpu->dev) < 0)
2712 +- return;
2713 ++ goto pm_put;
2714 +
2715 + mutex_lock(&gpu->lock);
2716 +
2717 +@@ -997,6 +999,7 @@ void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
2718 +
2719 + mutex_unlock(&gpu->lock);
2720 + pm_runtime_mark_last_busy(gpu->dev);
2721 ++pm_put:
2722 + pm_runtime_put_autosuspend(gpu->dev);
2723 + }
2724 +
2725 +@@ -1269,8 +1272,10 @@ struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit)
2726 +
2727 + if (!submit->runtime_resumed) {
2728 + ret = pm_runtime_get_sync(gpu->dev);
2729 +- if (ret < 0)
2730 ++ if (ret < 0) {
2731 ++ pm_runtime_put_noidle(gpu->dev);
2732 + return NULL;
2733 ++ }
2734 + submit->runtime_resumed = true;
2735 + }
2736 +
2737 +@@ -1287,6 +1292,7 @@ struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit)
2738 + ret = event_alloc(gpu, nr_events, event);
2739 + if (ret) {
2740 + DRM_ERROR("no free events\n");
2741 ++ pm_runtime_put_noidle(gpu->dev);
2742 + return NULL;
2743 + }
2744 +
2745 +@@ -1457,7 +1463,7 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu)
2746 + if (gpu->clk_bus) {
2747 + ret = clk_prepare_enable(gpu->clk_bus);
2748 + if (ret)
2749 +- return ret;
2750 ++ goto disable_clk_reg;
2751 + }
2752 +
2753 + if (gpu->clk_core) {
2754 +@@ -1480,6 +1486,9 @@ disable_clk_core:
2755 + disable_clk_bus:
2756 + if (gpu->clk_bus)
2757 + clk_disable_unprepare(gpu->clk_bus);
2758 ++disable_clk_reg:
2759 ++ if (gpu->clk_reg)
2760 ++ clk_disable_unprepare(gpu->clk_reg);
2761 +
2762 + return ret;
2763 + }
2764 +diff --git a/drivers/gpu/drm/imx/dw_hdmi-imx.c b/drivers/gpu/drm/imx/dw_hdmi-imx.c
2765 +index f22cfbf9353e..2e12a4a3bfa1 100644
2766 +--- a/drivers/gpu/drm/imx/dw_hdmi-imx.c
2767 ++++ b/drivers/gpu/drm/imx/dw_hdmi-imx.c
2768 +@@ -212,9 +212,8 @@ static int dw_hdmi_imx_bind(struct device *dev, struct device *master,
2769 + if (!pdev->dev.of_node)
2770 + return -ENODEV;
2771 +
2772 +- hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
2773 +- if (!hdmi)
2774 +- return -ENOMEM;
2775 ++ hdmi = dev_get_drvdata(dev);
2776 ++ memset(hdmi, 0, sizeof(*hdmi));
2777 +
2778 + match = of_match_node(dw_hdmi_imx_dt_ids, pdev->dev.of_node);
2779 + plat_data = match->data;
2780 +@@ -239,8 +238,6 @@ static int dw_hdmi_imx_bind(struct device *dev, struct device *master,
2781 + drm_encoder_init(drm, encoder, &dw_hdmi_imx_encoder_funcs,
2782 + DRM_MODE_ENCODER_TMDS, NULL);
2783 +
2784 +- platform_set_drvdata(pdev, hdmi);
2785 +-
2786 + hdmi->hdmi = dw_hdmi_bind(pdev, encoder, plat_data);
2787 +
2788 + /*
2789 +@@ -270,6 +267,14 @@ static const struct component_ops dw_hdmi_imx_ops = {
2790 +
2791 + static int dw_hdmi_imx_probe(struct platform_device *pdev)
2792 + {
2793 ++ struct imx_hdmi *hdmi;
2794 ++
2795 ++ hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
2796 ++ if (!hdmi)
2797 ++ return -ENOMEM;
2798 ++
2799 ++ platform_set_drvdata(pdev, hdmi);
2800 ++
2801 + return component_add(&pdev->dev, &dw_hdmi_imx_ops);
2802 + }
2803 +
2804 +diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
2805 +index da87c70e413b..881c36d0f16b 100644
2806 +--- a/drivers/gpu/drm/imx/imx-drm-core.c
2807 ++++ b/drivers/gpu/drm/imx/imx-drm-core.c
2808 +@@ -281,9 +281,10 @@ static void imx_drm_unbind(struct device *dev)
2809 +
2810 + drm_kms_helper_poll_fini(drm);
2811 +
2812 ++ component_unbind_all(drm->dev, drm);
2813 ++
2814 + drm_mode_config_cleanup(drm);
2815 +
2816 +- component_unbind_all(drm->dev, drm);
2817 + dev_set_drvdata(dev, NULL);
2818 +
2819 + drm_dev_put(drm);
2820 +diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
2821 +index 695f307f36b2..9af5a08d5490 100644
2822 +--- a/drivers/gpu/drm/imx/imx-ldb.c
2823 ++++ b/drivers/gpu/drm/imx/imx-ldb.c
2824 +@@ -593,9 +593,8 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
2825 + int ret;
2826 + int i;
2827 +
2828 +- imx_ldb = devm_kzalloc(dev, sizeof(*imx_ldb), GFP_KERNEL);
2829 +- if (!imx_ldb)
2830 +- return -ENOMEM;
2831 ++ imx_ldb = dev_get_drvdata(dev);
2832 ++ memset(imx_ldb, 0, sizeof(*imx_ldb));
2833 +
2834 + imx_ldb->regmap = syscon_regmap_lookup_by_phandle(np, "gpr");
2835 + if (IS_ERR(imx_ldb->regmap)) {
2836 +@@ -703,8 +702,6 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
2837 + }
2838 + }
2839 +
2840 +- dev_set_drvdata(dev, imx_ldb);
2841 +-
2842 + return 0;
2843 +
2844 + free_child:
2845 +@@ -736,6 +733,14 @@ static const struct component_ops imx_ldb_ops = {
2846 +
2847 + static int imx_ldb_probe(struct platform_device *pdev)
2848 + {
2849 ++ struct imx_ldb *imx_ldb;
2850 ++
2851 ++ imx_ldb = devm_kzalloc(&pdev->dev, sizeof(*imx_ldb), GFP_KERNEL);
2852 ++ if (!imx_ldb)
2853 ++ return -ENOMEM;
2854 ++
2855 ++ platform_set_drvdata(pdev, imx_ldb);
2856 ++
2857 + return component_add(&pdev->dev, &imx_ldb_ops);
2858 + }
2859 +
2860 +diff --git a/drivers/gpu/drm/imx/imx-tve.c b/drivers/gpu/drm/imx/imx-tve.c
2861 +index 5bbfaa2cd0f4..f91c3eb7697b 100644
2862 +--- a/drivers/gpu/drm/imx/imx-tve.c
2863 ++++ b/drivers/gpu/drm/imx/imx-tve.c
2864 +@@ -494,6 +494,13 @@ static int imx_tve_register(struct drm_device *drm, struct imx_tve *tve)
2865 + return 0;
2866 + }
2867 +
2868 ++static void imx_tve_disable_regulator(void *data)
2869 ++{
2870 ++ struct imx_tve *tve = data;
2871 ++
2872 ++ regulator_disable(tve->dac_reg);
2873 ++}
2874 ++
2875 + static bool imx_tve_readable_reg(struct device *dev, unsigned int reg)
2876 + {
2877 + return (reg % 4 == 0) && (reg <= 0xdc);
2878 +@@ -546,9 +553,8 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data)
2879 + int irq;
2880 + int ret;
2881 +
2882 +- tve = devm_kzalloc(dev, sizeof(*tve), GFP_KERNEL);
2883 +- if (!tve)
2884 +- return -ENOMEM;
2885 ++ tve = dev_get_drvdata(dev);
2886 ++ memset(tve, 0, sizeof(*tve));
2887 +
2888 + tve->dev = dev;
2889 + spin_lock_init(&tve->lock);
2890 +@@ -618,6 +624,9 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data)
2891 + ret = regulator_enable(tve->dac_reg);
2892 + if (ret)
2893 + return ret;
2894 ++ ret = devm_add_action_or_reset(dev, imx_tve_disable_regulator, tve);
2895 ++ if (ret)
2896 ++ return ret;
2897 + }
2898 +
2899 + tve->clk = devm_clk_get(dev, "tve");
2900 +@@ -659,27 +668,23 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data)
2901 + if (ret)
2902 + return ret;
2903 +
2904 +- dev_set_drvdata(dev, tve);
2905 +-
2906 + return 0;
2907 + }
2908 +
2909 +-static void imx_tve_unbind(struct device *dev, struct device *master,
2910 +- void *data)
2911 +-{
2912 +- struct imx_tve *tve = dev_get_drvdata(dev);
2913 +-
2914 +- if (!IS_ERR(tve->dac_reg))
2915 +- regulator_disable(tve->dac_reg);
2916 +-}
2917 +-
2918 + static const struct component_ops imx_tve_ops = {
2919 + .bind = imx_tve_bind,
2920 +- .unbind = imx_tve_unbind,
2921 + };
2922 +
2923 + static int imx_tve_probe(struct platform_device *pdev)
2924 + {
2925 ++ struct imx_tve *tve;
2926 ++
2927 ++ tve = devm_kzalloc(&pdev->dev, sizeof(*tve), GFP_KERNEL);
2928 ++ if (!tve)
2929 ++ return -ENOMEM;
2930 ++
2931 ++ platform_set_drvdata(pdev, tve);
2932 ++
2933 + return component_add(&pdev->dev, &imx_tve_ops);
2934 + }
2935 +
2936 +diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
2937 +index 63c0284f8b3c..2256c9789fc2 100644
2938 +--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
2939 ++++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
2940 +@@ -438,21 +438,13 @@ static int ipu_drm_bind(struct device *dev, struct device *master, void *data)
2941 + struct ipu_client_platformdata *pdata = dev->platform_data;
2942 + struct drm_device *drm = data;
2943 + struct ipu_crtc *ipu_crtc;
2944 +- int ret;
2945 +
2946 +- ipu_crtc = devm_kzalloc(dev, sizeof(*ipu_crtc), GFP_KERNEL);
2947 +- if (!ipu_crtc)
2948 +- return -ENOMEM;
2949 ++ ipu_crtc = dev_get_drvdata(dev);
2950 ++ memset(ipu_crtc, 0, sizeof(*ipu_crtc));
2951 +
2952 + ipu_crtc->dev = dev;
2953 +
2954 +- ret = ipu_crtc_init(ipu_crtc, pdata, drm);
2955 +- if (ret)
2956 +- return ret;
2957 +-
2958 +- dev_set_drvdata(dev, ipu_crtc);
2959 +-
2960 +- return 0;
2961 ++ return ipu_crtc_init(ipu_crtc, pdata, drm);
2962 + }
2963 +
2964 + static void ipu_drm_unbind(struct device *dev, struct device *master,
2965 +@@ -474,6 +466,7 @@ static const struct component_ops ipu_crtc_ops = {
2966 + static int ipu_drm_probe(struct platform_device *pdev)
2967 + {
2968 + struct device *dev = &pdev->dev;
2969 ++ struct ipu_crtc *ipu_crtc;
2970 + int ret;
2971 +
2972 + if (!dev->platform_data)
2973 +@@ -483,6 +476,12 @@ static int ipu_drm_probe(struct platform_device *pdev)
2974 + if (ret)
2975 + return ret;
2976 +
2977 ++ ipu_crtc = devm_kzalloc(dev, sizeof(*ipu_crtc), GFP_KERNEL);
2978 ++ if (!ipu_crtc)
2979 ++ return -ENOMEM;
2980 ++
2981 ++ dev_set_drvdata(dev, ipu_crtc);
2982 ++
2983 + return component_add(dev, &ipu_crtc_ops);
2984 + }
2985 +
2986 +diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c
2987 +index e7ce17503ae1..be55548f352a 100644
2988 +--- a/drivers/gpu/drm/imx/parallel-display.c
2989 ++++ b/drivers/gpu/drm/imx/parallel-display.c
2990 +@@ -204,9 +204,8 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
2991 + u32 bus_format = 0;
2992 + const char *fmt;
2993 +
2994 +- imxpd = devm_kzalloc(dev, sizeof(*imxpd), GFP_KERNEL);
2995 +- if (!imxpd)
2996 +- return -ENOMEM;
2997 ++ imxpd = dev_get_drvdata(dev);
2998 ++ memset(imxpd, 0, sizeof(*imxpd));
2999 +
3000 + edidp = of_get_property(np, "edid", &imxpd->edid_len);
3001 + if (edidp)
3002 +@@ -236,8 +235,6 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
3003 + if (ret)
3004 + return ret;
3005 +
3006 +- dev_set_drvdata(dev, imxpd);
3007 +-
3008 + return 0;
3009 + }
3010 +
3011 +@@ -259,6 +256,14 @@ static const struct component_ops imx_pd_ops = {
3012 +
3013 + static int imx_pd_probe(struct platform_device *pdev)
3014 + {
3015 ++ struct imx_parallel_display *imxpd;
3016 ++
3017 ++ imxpd = devm_kzalloc(&pdev->dev, sizeof(*imxpd), GFP_KERNEL);
3018 ++ if (!imxpd)
3019 ++ return -ENOMEM;
3020 ++
3021 ++ platform_set_drvdata(pdev, imxpd);
3022 ++
3023 + return component_add(&pdev->dev, &imx_pd_ops);
3024 + }
3025 +
3026 +diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
3027 +index e62b286947a7..9ea748667fab 100644
3028 +--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
3029 ++++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
3030 +@@ -713,10 +713,19 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
3031 + /* Turn on the resources */
3032 + pm_runtime_get_sync(gmu->dev);
3033 +
3034 ++ /*
3035 ++ * "enable" the GX power domain which won't actually do anything but it
3036 ++ * will make sure that the refcounting is correct in case we need to
3037 ++ * bring down the GX after a GMU failure
3038 ++ */
3039 ++ if (!IS_ERR_OR_NULL(gmu->gxpd))
3040 ++ pm_runtime_get_sync(gmu->gxpd);
3041 ++
3042 + /* Use a known rate to bring up the GMU */
3043 + clk_set_rate(gmu->core_clk, 200000000);
3044 + ret = clk_bulk_prepare_enable(gmu->nr_clocks, gmu->clocks);
3045 + if (ret) {
3046 ++ pm_runtime_put(gmu->gxpd);
3047 + pm_runtime_put(gmu->dev);
3048 + return ret;
3049 + }
3050 +@@ -752,19 +761,12 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
3051 + /* Set the GPU to the highest power frequency */
3052 + __a6xx_gmu_set_freq(gmu, gmu->nr_gpu_freqs - 1);
3053 +
3054 +- /*
3055 +- * "enable" the GX power domain which won't actually do anything but it
3056 +- * will make sure that the refcounting is correct in case we need to
3057 +- * bring down the GX after a GMU failure
3058 +- */
3059 +- if (!IS_ERR_OR_NULL(gmu->gxpd))
3060 +- pm_runtime_get(gmu->gxpd);
3061 +-
3062 + out:
3063 + /* On failure, shut down the GMU to leave it in a good state */
3064 + if (ret) {
3065 + disable_irq(gmu->gmu_irq);
3066 + a6xx_rpmh_stop(gmu);
3067 ++ pm_runtime_put(gmu->gxpd);
3068 + pm_runtime_put(gmu->dev);
3069 + }
3070 +
3071 +diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
3072 +index ce59adff06aa..36c85c05b7cf 100644
3073 +--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
3074 ++++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
3075 +@@ -381,7 +381,7 @@ static void dpu_crtc_frame_event_cb(void *data, u32 event)
3076 + spin_unlock_irqrestore(&dpu_crtc->spin_lock, flags);
3077 +
3078 + if (!fevent) {
3079 +- DRM_ERROR("crtc%d event %d overflow\n", crtc->base.id, event);
3080 ++ DRM_ERROR_RATELIMITED("crtc%d event %d overflow\n", crtc->base.id, event);
3081 + return;
3082 + }
3083 +
3084 +diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
3085 +index 5a6a79fbc9d6..d92a0ffe2a76 100644
3086 +--- a/drivers/gpu/drm/msm/msm_gem.c
3087 ++++ b/drivers/gpu/drm/msm/msm_gem.c
3088 +@@ -977,10 +977,8 @@ int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
3089 +
3090 + static int msm_gem_new_impl(struct drm_device *dev,
3091 + uint32_t size, uint32_t flags,
3092 +- struct drm_gem_object **obj,
3093 +- bool struct_mutex_locked)
3094 ++ struct drm_gem_object **obj)
3095 + {
3096 +- struct msm_drm_private *priv = dev->dev_private;
3097 + struct msm_gem_object *msm_obj;
3098 +
3099 + switch (flags & MSM_BO_CACHE_MASK) {
3100 +@@ -1006,15 +1004,6 @@ static int msm_gem_new_impl(struct drm_device *dev,
3101 + INIT_LIST_HEAD(&msm_obj->submit_entry);
3102 + INIT_LIST_HEAD(&msm_obj->vmas);
3103 +
3104 +- if (struct_mutex_locked) {
3105 +- WARN_ON(!mutex_is_locked(&dev->struct_mutex));
3106 +- list_add_tail(&msm_obj->mm_list, &priv->inactive_list);
3107 +- } else {
3108 +- mutex_lock(&dev->struct_mutex);
3109 +- list_add_tail(&msm_obj->mm_list, &priv->inactive_list);
3110 +- mutex_unlock(&dev->struct_mutex);
3111 +- }
3112 +-
3113 + *obj = &msm_obj->base;
3114 +
3115 + return 0;
3116 +@@ -1024,6 +1013,7 @@ static struct drm_gem_object *_msm_gem_new(struct drm_device *dev,
3117 + uint32_t size, uint32_t flags, bool struct_mutex_locked)
3118 + {
3119 + struct msm_drm_private *priv = dev->dev_private;
3120 ++ struct msm_gem_object *msm_obj;
3121 + struct drm_gem_object *obj = NULL;
3122 + bool use_vram = false;
3123 + int ret;
3124 +@@ -1044,14 +1034,15 @@ static struct drm_gem_object *_msm_gem_new(struct drm_device *dev,
3125 + if (size == 0)
3126 + return ERR_PTR(-EINVAL);
3127 +
3128 +- ret = msm_gem_new_impl(dev, size, flags, &obj, struct_mutex_locked);
3129 ++ ret = msm_gem_new_impl(dev, size, flags, &obj);
3130 + if (ret)
3131 + goto fail;
3132 +
3133 ++ msm_obj = to_msm_bo(obj);
3134 ++
3135 + if (use_vram) {
3136 + struct msm_gem_vma *vma;
3137 + struct page **pages;
3138 +- struct msm_gem_object *msm_obj = to_msm_bo(obj);
3139 +
3140 + mutex_lock(&msm_obj->lock);
3141 +
3142 +@@ -1086,6 +1077,15 @@ static struct drm_gem_object *_msm_gem_new(struct drm_device *dev,
3143 + mapping_set_gfp_mask(obj->filp->f_mapping, GFP_HIGHUSER);
3144 + }
3145 +
3146 ++ if (struct_mutex_locked) {
3147 ++ WARN_ON(!mutex_is_locked(&dev->struct_mutex));
3148 ++ list_add_tail(&msm_obj->mm_list, &priv->inactive_list);
3149 ++ } else {
3150 ++ mutex_lock(&dev->struct_mutex);
3151 ++ list_add_tail(&msm_obj->mm_list, &priv->inactive_list);
3152 ++ mutex_unlock(&dev->struct_mutex);
3153 ++ }
3154 ++
3155 + return obj;
3156 +
3157 + fail:
3158 +@@ -1108,6 +1108,7 @@ struct drm_gem_object *msm_gem_new(struct drm_device *dev,
3159 + struct drm_gem_object *msm_gem_import(struct drm_device *dev,
3160 + struct dma_buf *dmabuf, struct sg_table *sgt)
3161 + {
3162 ++ struct msm_drm_private *priv = dev->dev_private;
3163 + struct msm_gem_object *msm_obj;
3164 + struct drm_gem_object *obj;
3165 + uint32_t size;
3166 +@@ -1121,7 +1122,7 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,
3167 +
3168 + size = PAGE_ALIGN(dmabuf->size);
3169 +
3170 +- ret = msm_gem_new_impl(dev, size, MSM_BO_WC, &obj, false);
3171 ++ ret = msm_gem_new_impl(dev, size, MSM_BO_WC, &obj);
3172 + if (ret)
3173 + goto fail;
3174 +
3175 +@@ -1146,6 +1147,11 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,
3176 + }
3177 +
3178 + mutex_unlock(&msm_obj->lock);
3179 ++
3180 ++ mutex_lock(&dev->struct_mutex);
3181 ++ list_add_tail(&msm_obj->mm_list, &priv->inactive_list);
3182 ++ mutex_unlock(&dev->struct_mutex);
3183 ++
3184 + return obj;
3185 +
3186 + fail:
3187 +diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c b/drivers/gpu/drm/nouveau/dispnv50/head.c
3188 +index c9692df2b76c..46578108a430 100644
3189 +--- a/drivers/gpu/drm/nouveau/dispnv50/head.c
3190 ++++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
3191 +@@ -83,18 +83,20 @@ nv50_head_atomic_check_dither(struct nv50_head_atom *armh,
3192 + {
3193 + u32 mode = 0x00;
3194 +
3195 +- if (asyc->dither.mode == DITHERING_MODE_AUTO) {
3196 +- if (asyh->base.depth > asyh->or.bpc * 3)
3197 +- mode = DITHERING_MODE_DYNAMIC2X2;
3198 +- } else {
3199 +- mode = asyc->dither.mode;
3200 +- }
3201 ++ if (asyc->dither.mode) {
3202 ++ if (asyc->dither.mode == DITHERING_MODE_AUTO) {
3203 ++ if (asyh->base.depth > asyh->or.bpc * 3)
3204 ++ mode = DITHERING_MODE_DYNAMIC2X2;
3205 ++ } else {
3206 ++ mode = asyc->dither.mode;
3207 ++ }
3208 +
3209 +- if (asyc->dither.depth == DITHERING_DEPTH_AUTO) {
3210 +- if (asyh->or.bpc >= 8)
3211 +- mode |= DITHERING_DEPTH_8BPC;
3212 +- } else {
3213 +- mode |= asyc->dither.depth;
3214 ++ if (asyc->dither.depth == DITHERING_DEPTH_AUTO) {
3215 ++ if (asyh->or.bpc >= 8)
3216 ++ mode |= DITHERING_DEPTH_8BPC;
3217 ++ } else {
3218 ++ mode |= asyc->dither.depth;
3219 ++ }
3220 + }
3221 +
3222 + asyh->dither.enable = mode;
3223 +diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
3224 +index 7dfbbbc1beea..5c314f135dd1 100644
3225 +--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
3226 ++++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
3227 +@@ -54,8 +54,10 @@ nouveau_debugfs_strap_peek(struct seq_file *m, void *data)
3228 + int ret;
3229 +
3230 + ret = pm_runtime_get_sync(drm->dev->dev);
3231 +- if (ret < 0 && ret != -EACCES)
3232 ++ if (ret < 0 && ret != -EACCES) {
3233 ++ pm_runtime_put_autosuspend(drm->dev->dev);
3234 + return ret;
3235 ++ }
3236 +
3237 + seq_printf(m, "0x%08x\n",
3238 + nvif_rd32(&drm->client.device.object, 0x101000));
3239 +diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
3240 +index b1beed40e746..5347e5bdee8c 100644
3241 +--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
3242 ++++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
3243 +@@ -1052,8 +1052,10 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
3244 +
3245 + /* need to bring up power immediately if opening device */
3246 + ret = pm_runtime_get_sync(dev->dev);
3247 +- if (ret < 0 && ret != -EACCES)
3248 ++ if (ret < 0 && ret != -EACCES) {
3249 ++ pm_runtime_put_autosuspend(dev->dev);
3250 + return ret;
3251 ++ }
3252 +
3253 + get_task_comm(tmpname, current);
3254 + snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid));
3255 +@@ -1135,8 +1137,10 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
3256 + long ret;
3257 +
3258 + ret = pm_runtime_get_sync(dev->dev);
3259 +- if (ret < 0 && ret != -EACCES)
3260 ++ if (ret < 0 && ret != -EACCES) {
3261 ++ pm_runtime_put_autosuspend(dev->dev);
3262 + return ret;
3263 ++ }
3264 +
3265 + switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
3266 + case DRM_NOUVEAU_NVIF:
3267 +diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
3268 +index 1324c19f4e5c..fbfe25422774 100644
3269 +--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
3270 ++++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
3271 +@@ -45,8 +45,10 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
3272 + int ret;
3273 +
3274 + ret = pm_runtime_get_sync(dev);
3275 +- if (WARN_ON(ret < 0 && ret != -EACCES))
3276 ++ if (WARN_ON(ret < 0 && ret != -EACCES)) {
3277 ++ pm_runtime_put_autosuspend(dev);
3278 + return;
3279 ++ }
3280 +
3281 + if (gem->import_attach)
3282 + drm_prime_gem_destroy(gem, nvbo->bo.sg);
3283 +diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
3284 +index feaac908efed..34403b810dba 100644
3285 +--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
3286 ++++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
3287 +@@ -96,12 +96,9 @@ nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags)
3288 + else
3289 + nvbe->ttm.ttm.func = &nv50_sgdma_backend;
3290 +
3291 +- if (ttm_dma_tt_init(&nvbe->ttm, bo, page_flags))
3292 +- /*
3293 +- * A failing ttm_dma_tt_init() will call ttm_tt_destroy()
3294 +- * and thus our nouveau_sgdma_destroy() hook, so we don't need
3295 +- * to free nvbe here.
3296 +- */
3297 ++ if (ttm_dma_tt_init(&nvbe->ttm, bo, page_flags)) {
3298 ++ kfree(nvbe);
3299 + return NULL;
3300 ++ }
3301 + return &nvbe->ttm.ttm;
3302 + }
3303 +diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
3304 +index 8abb31f83ffc..6d9656323a3f 100644
3305 +--- a/drivers/gpu/drm/panel/panel-simple.c
3306 ++++ b/drivers/gpu/drm/panel/panel-simple.c
3307 +@@ -1935,7 +1935,7 @@ static const struct drm_display_mode lg_lb070wv8_mode = {
3308 + static const struct panel_desc lg_lb070wv8 = {
3309 + .modes = &lg_lb070wv8_mode,
3310 + .num_modes = 1,
3311 +- .bpc = 16,
3312 ++ .bpc = 8,
3313 + .size = {
3314 + .width = 151,
3315 + .height = 91,
3316 +diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
3317 +index f9685cce1652..1e62e7bbf1b1 100644
3318 +--- a/drivers/gpu/drm/radeon/ci_dpm.c
3319 ++++ b/drivers/gpu/drm/radeon/ci_dpm.c
3320 +@@ -4366,7 +4366,7 @@ static int ci_set_mc_special_registers(struct radeon_device *rdev,
3321 + table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
3322 + }
3323 + j++;
3324 +- if (j > SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
3325 ++ if (j >= SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
3326 + return -EINVAL;
3327 +
3328 + if (!pi->mem_gddr5) {
3329 +diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
3330 +index 0826efd9b5f5..f9f74150d0d7 100644
3331 +--- a/drivers/gpu/drm/radeon/radeon_display.c
3332 ++++ b/drivers/gpu/drm/radeon/radeon_display.c
3333 +@@ -631,8 +631,10 @@ radeon_crtc_set_config(struct drm_mode_set *set,
3334 + dev = set->crtc->dev;
3335 +
3336 + ret = pm_runtime_get_sync(dev->dev);
3337 +- if (ret < 0)
3338 ++ if (ret < 0) {
3339 ++ pm_runtime_put_autosuspend(dev->dev);
3340 + return ret;
3341 ++ }
3342 +
3343 + ret = drm_crtc_helper_set_config(set, ctx);
3344 +
3345 +diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
3346 +index 6128792ab883..c2573096d43c 100644
3347 +--- a/drivers/gpu/drm/radeon/radeon_drv.c
3348 ++++ b/drivers/gpu/drm/radeon/radeon_drv.c
3349 +@@ -174,12 +174,7 @@ int radeon_no_wb;
3350 + int radeon_modeset = -1;
3351 + int radeon_dynclks = -1;
3352 + int radeon_r4xx_atom = 0;
3353 +-#ifdef __powerpc__
3354 +-/* Default to PCI on PowerPC (fdo #95017) */
3355 + int radeon_agpmode = -1;
3356 +-#else
3357 +-int radeon_agpmode = 0;
3358 +-#endif
3359 + int radeon_vram_limit = 0;
3360 + int radeon_gart_size = -1; /* auto */
3361 + int radeon_benchmarking = 0;
3362 +@@ -555,8 +550,10 @@ long radeon_drm_ioctl(struct file *filp,
3363 + long ret;
3364 + dev = file_priv->minor->dev;
3365 + ret = pm_runtime_get_sync(dev->dev);
3366 +- if (ret < 0)
3367 ++ if (ret < 0) {
3368 ++ pm_runtime_put_autosuspend(dev->dev);
3369 + return ret;
3370 ++ }
3371 +
3372 + ret = drm_ioctl(filp, cmd, arg);
3373 +
3374 +diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
3375 +index 2bb0187c5bc7..709c4ef5e7d5 100644
3376 +--- a/drivers/gpu/drm/radeon/radeon_kms.c
3377 ++++ b/drivers/gpu/drm/radeon/radeon_kms.c
3378 +@@ -638,8 +638,10 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
3379 + file_priv->driver_priv = NULL;
3380 +
3381 + r = pm_runtime_get_sync(dev->dev);
3382 +- if (r < 0)
3383 ++ if (r < 0) {
3384 ++ pm_runtime_put_autosuspend(dev->dev);
3385 + return r;
3386 ++ }
3387 +
3388 + /* new gpu have virtual address space support */
3389 + if (rdev->family >= CHIP_CAYMAN) {
3390 +diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
3391 +index 3ab4fbf8eb0d..51571f7246ab 100644
3392 +--- a/drivers/gpu/drm/stm/ltdc.c
3393 ++++ b/drivers/gpu/drm/stm/ltdc.c
3394 +@@ -424,9 +424,12 @@ static void ltdc_crtc_atomic_enable(struct drm_crtc *crtc,
3395 + struct drm_crtc_state *old_state)
3396 + {
3397 + struct ltdc_device *ldev = crtc_to_ltdc(crtc);
3398 ++ struct drm_device *ddev = crtc->dev;
3399 +
3400 + DRM_DEBUG_DRIVER("\n");
3401 +
3402 ++ pm_runtime_get_sync(ddev->dev);
3403 ++
3404 + /* Sets the background color value */
3405 + reg_write(ldev->regs, LTDC_BCCR, BCCR_BCBLACK);
3406 +
3407 +diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
3408 +index 5584e656b857..8c4fd1aa4c2d 100644
3409 +--- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
3410 ++++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
3411 +@@ -143,12 +143,16 @@ static int panel_connector_get_modes(struct drm_connector *connector)
3412 + int i;
3413 +
3414 + for (i = 0; i < timings->num_timings; i++) {
3415 +- struct drm_display_mode *mode = drm_mode_create(dev);
3416 ++ struct drm_display_mode *mode;
3417 + struct videomode vm;
3418 +
3419 + if (videomode_from_timings(timings, &vm, i))
3420 + break;
3421 +
3422 ++ mode = drm_mode_create(dev);
3423 ++ if (!mode)
3424 ++ break;
3425 ++
3426 + drm_display_mode_from_videomode(&vm, mode);
3427 +
3428 + mode->type = DRM_MODE_TYPE_DRIVER;
3429 +diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
3430 +index e0e9b4f69db6..c770ec7e9e8b 100644
3431 +--- a/drivers/gpu/drm/ttm/ttm_tt.c
3432 ++++ b/drivers/gpu/drm/ttm/ttm_tt.c
3433 +@@ -241,7 +241,6 @@ int ttm_tt_init(struct ttm_tt *ttm, struct ttm_buffer_object *bo,
3434 + ttm_tt_init_fields(ttm, bo, page_flags);
3435 +
3436 + if (ttm_tt_alloc_page_directory(ttm)) {
3437 +- ttm_tt_destroy(ttm);
3438 + pr_err("Failed allocating page table\n");
3439 + return -ENOMEM;
3440 + }
3441 +@@ -265,7 +264,6 @@ int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo,
3442 +
3443 + INIT_LIST_HEAD(&ttm_dma->pages_list);
3444 + if (ttm_dma_tt_alloc_page_directory(ttm_dma)) {
3445 +- ttm_tt_destroy(ttm);
3446 + pr_err("Failed allocating page table\n");
3447 + return -ENOMEM;
3448 + }
3449 +@@ -287,7 +285,6 @@ int ttm_sg_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo,
3450 + else
3451 + ret = ttm_dma_tt_alloc_page_directory(ttm_dma);
3452 + if (ret) {
3453 +- ttm_tt_destroy(ttm);
3454 + pr_err("Failed allocating page table\n");
3455 + return -ENOMEM;
3456 + }
3457 +diff --git a/drivers/gpu/host1x/debug.c b/drivers/gpu/host1x/debug.c
3458 +index c0392672a842..1b4997bda1c7 100644
3459 +--- a/drivers/gpu/host1x/debug.c
3460 ++++ b/drivers/gpu/host1x/debug.c
3461 +@@ -16,6 +16,8 @@
3462 + #include "debug.h"
3463 + #include "channel.h"
3464 +
3465 ++static DEFINE_MUTEX(debug_lock);
3466 ++
3467 + unsigned int host1x_debug_trace_cmdbuf;
3468 +
3469 + static pid_t host1x_debug_force_timeout_pid;
3470 +@@ -52,12 +54,14 @@ static int show_channel(struct host1x_channel *ch, void *data, bool show_fifo)
3471 + struct output *o = data;
3472 +
3473 + mutex_lock(&ch->cdma.lock);
3474 ++ mutex_lock(&debug_lock);
3475 +
3476 + if (show_fifo)
3477 + host1x_hw_show_channel_fifo(m, ch, o);
3478 +
3479 + host1x_hw_show_channel_cdma(m, ch, o);
3480 +
3481 ++ mutex_unlock(&debug_lock);
3482 + mutex_unlock(&ch->cdma.lock);
3483 +
3484 + return 0;
3485 +diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
3486 +index ee2a025e54cf..b3dae9ec1a38 100644
3487 +--- a/drivers/gpu/ipu-v3/ipu-common.c
3488 ++++ b/drivers/gpu/ipu-v3/ipu-common.c
3489 +@@ -124,6 +124,8 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat)
3490 + case V4L2_PIX_FMT_RGBX32:
3491 + case V4L2_PIX_FMT_ARGB32:
3492 + case V4L2_PIX_FMT_XRGB32:
3493 ++ case V4L2_PIX_FMT_RGB32:
3494 ++ case V4L2_PIX_FMT_BGR32:
3495 + return IPUV3_COLORSPACE_RGB;
3496 + default:
3497 + return IPUV3_COLORSPACE_UNKNOWN;
3498 +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
3499 +index dea9cc65bf80..e8641ce677e4 100644
3500 +--- a/drivers/hid/hid-input.c
3501 ++++ b/drivers/hid/hid-input.c
3502 +@@ -350,13 +350,13 @@ static int hidinput_query_battery_capacity(struct hid_device *dev)
3503 + u8 *buf;
3504 + int ret;
3505 +
3506 +- buf = kmalloc(2, GFP_KERNEL);
3507 ++ buf = kmalloc(4, GFP_KERNEL);
3508 + if (!buf)
3509 + return -ENOMEM;
3510 +
3511 +- ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 2,
3512 ++ ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 4,
3513 + dev->battery_report_type, HID_REQ_GET_REPORT);
3514 +- if (ret != 2) {
3515 ++ if (ret < 2) {
3516 + kfree(buf);
3517 + return -ENODATA;
3518 + }
3519 +diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
3520 +index 36cce2bfb744..6375504ba8b0 100644
3521 +--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
3522 ++++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
3523 +@@ -639,15 +639,14 @@ int tmc_read_unprepare_etb(struct tmc_drvdata *drvdata)
3524 +
3525 + spin_lock_irqsave(&drvdata->spinlock, flags);
3526 +
3527 +- /* There is no point in reading a TMC in HW FIFO mode */
3528 +- mode = readl_relaxed(drvdata->base + TMC_MODE);
3529 +- if (mode != TMC_MODE_CIRCULAR_BUFFER) {
3530 +- spin_unlock_irqrestore(&drvdata->spinlock, flags);
3531 +- return -EINVAL;
3532 +- }
3533 +-
3534 + /* Re-enable the TMC if need be */
3535 + if (drvdata->mode == CS_MODE_SYSFS) {
3536 ++ /* There is no point in reading a TMC in HW FIFO mode */
3537 ++ mode = readl_relaxed(drvdata->base + TMC_MODE);
3538 ++ if (mode != TMC_MODE_CIRCULAR_BUFFER) {
3539 ++ spin_unlock_irqrestore(&drvdata->spinlock, flags);
3540 ++ return -EINVAL;
3541 ++ }
3542 + /*
3543 + * The trace run will continue with the same allocated trace
3544 + * buffer. As such zero-out the buffer so that we don't end
3545 +diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
3546 +index 10ae6c6eab0a..59dc9f3cfb37 100644
3547 +--- a/drivers/infiniband/core/device.c
3548 ++++ b/drivers/infiniband/core/device.c
3549 +@@ -1330,6 +1330,10 @@ out:
3550 + return ret;
3551 + }
3552 +
3553 ++static void prevent_dealloc_device(struct ib_device *ib_dev)
3554 ++{
3555 ++}
3556 ++
3557 + /**
3558 + * ib_register_device - Register an IB device with IB core
3559 + * @device:Device to register
3560 +@@ -1397,11 +1401,11 @@ int ib_register_device(struct ib_device *device, const char *name)
3561 + * possibility for a parallel unregistration along with this
3562 + * error flow. Since we have a refcount here we know any
3563 + * parallel flow is stopped in disable_device and will see the
3564 +- * NULL pointers, causing the responsibility to
3565 ++ * special dealloc_driver pointer, causing the responsibility to
3566 + * ib_dealloc_device() to revert back to this thread.
3567 + */
3568 + dealloc_fn = device->ops.dealloc_driver;
3569 +- device->ops.dealloc_driver = NULL;
3570 ++ device->ops.dealloc_driver = prevent_dealloc_device;
3571 + ib_device_put(device);
3572 + __ib_unregister_device(device);
3573 + device->ops.dealloc_driver = dealloc_fn;
3574 +@@ -1449,7 +1453,8 @@ static void __ib_unregister_device(struct ib_device *ib_dev)
3575 + * Drivers using the new flow may not call ib_dealloc_device except
3576 + * in error unwind prior to registration success.
3577 + */
3578 +- if (ib_dev->ops.dealloc_driver) {
3579 ++ if (ib_dev->ops.dealloc_driver &&
3580 ++ ib_dev->ops.dealloc_driver != prevent_dealloc_device) {
3581 + WARN_ON(kref_read(&ib_dev->dev.kobj.kref) <= 1);
3582 + ib_dealloc_device(ib_dev);
3583 + }
3584 +diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
3585 +index 244ebf285fc3..e4905d9fecb0 100644
3586 +--- a/drivers/infiniband/core/nldev.c
3587 ++++ b/drivers/infiniband/core/nldev.c
3588 +@@ -702,9 +702,6 @@ static int fill_stat_counter_qps(struct sk_buff *msg,
3589 + continue;
3590 +
3591 + qp = container_of(res, struct ib_qp, res);
3592 +- if (qp->qp_type == IB_QPT_RAW_PACKET && !capable(CAP_NET_RAW))
3593 +- continue;
3594 +-
3595 + if (!qp->counter || (qp->counter->id != counter->id))
3596 + continue;
3597 +
3598 +diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
3599 +index 6c4093d0a91d..d4815f29cfd2 100644
3600 +--- a/drivers/infiniband/core/verbs.c
3601 ++++ b/drivers/infiniband/core/verbs.c
3602 +@@ -1648,7 +1648,7 @@ static int _ib_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr,
3603 + if (!(rdma_protocol_ib(qp->device,
3604 + attr->alt_ah_attr.port_num) &&
3605 + rdma_protocol_ib(qp->device, port))) {
3606 +- ret = EINVAL;
3607 ++ ret = -EINVAL;
3608 + goto out;
3609 + }
3610 + }
3611 +diff --git a/drivers/infiniband/hw/qedr/qedr.h b/drivers/infiniband/hw/qedr/qedr.h
3612 +index 8e927f6c1520..ed56df319d2d 100644
3613 +--- a/drivers/infiniband/hw/qedr/qedr.h
3614 ++++ b/drivers/infiniband/hw/qedr/qedr.h
3615 +@@ -349,10 +349,10 @@ struct qedr_srq_hwq_info {
3616 + u32 wqe_prod;
3617 + u32 sge_prod;
3618 + u32 wr_prod_cnt;
3619 +- u32 wr_cons_cnt;
3620 ++ atomic_t wr_cons_cnt;
3621 + u32 num_elems;
3622 +
3623 +- u32 *virt_prod_pair_addr;
3624 ++ struct rdma_srq_producers *virt_prod_pair_addr;
3625 + dma_addr_t phy_prod_pair_addr;
3626 + };
3627 +
3628 +diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
3629 +index 8b4240c1cc76..16a994fd7d0a 100644
3630 +--- a/drivers/infiniband/hw/qedr/verbs.c
3631 ++++ b/drivers/infiniband/hw/qedr/verbs.c
3632 +@@ -3460,7 +3460,7 @@ static u32 qedr_srq_elem_left(struct qedr_srq_hwq_info *hw_srq)
3633 + * count and consumer count and subtract it from max
3634 + * work request supported so that we get elements left.
3635 + */
3636 +- used = hw_srq->wr_prod_cnt - hw_srq->wr_cons_cnt;
3637 ++ used = hw_srq->wr_prod_cnt - (u32)atomic_read(&hw_srq->wr_cons_cnt);
3638 +
3639 + return hw_srq->max_wr - used;
3640 + }
3641 +@@ -3475,7 +3475,6 @@ int qedr_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
3642 + unsigned long flags;
3643 + int status = 0;
3644 + u32 num_sge;
3645 +- u32 offset;
3646 +
3647 + spin_lock_irqsave(&srq->lock, flags);
3648 +
3649 +@@ -3488,7 +3487,8 @@ int qedr_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
3650 + if (!qedr_srq_elem_left(hw_srq) ||
3651 + wr->num_sge > srq->hw_srq.max_sges) {
3652 + DP_ERR(dev, "Can't post WR (%d,%d) || (%d > %d)\n",
3653 +- hw_srq->wr_prod_cnt, hw_srq->wr_cons_cnt,
3654 ++ hw_srq->wr_prod_cnt,
3655 ++ atomic_read(&hw_srq->wr_cons_cnt),
3656 + wr->num_sge, srq->hw_srq.max_sges);
3657 + status = -ENOMEM;
3658 + *bad_wr = wr;
3659 +@@ -3522,22 +3522,20 @@ int qedr_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
3660 + hw_srq->sge_prod++;
3661 + }
3662 +
3663 +- /* Flush WQE and SGE information before
3664 ++ /* Update WQE and SGE information before
3665 + * updating producer.
3666 + */
3667 +- wmb();
3668 ++ dma_wmb();
3669 +
3670 + /* SRQ producer is 8 bytes. Need to update SGE producer index
3671 + * in first 4 bytes and need to update WQE producer in
3672 + * next 4 bytes.
3673 + */
3674 +- *srq->hw_srq.virt_prod_pair_addr = hw_srq->sge_prod;
3675 +- offset = offsetof(struct rdma_srq_producers, wqe_prod);
3676 +- *((u8 *)srq->hw_srq.virt_prod_pair_addr + offset) =
3677 +- hw_srq->wqe_prod;
3678 ++ srq->hw_srq.virt_prod_pair_addr->sge_prod = hw_srq->sge_prod;
3679 ++ /* Make sure sge producer is updated first */
3680 ++ dma_wmb();
3681 ++ srq->hw_srq.virt_prod_pair_addr->wqe_prod = hw_srq->wqe_prod;
3682 +
3683 +- /* Flush producer after updating it. */
3684 +- wmb();
3685 + wr = wr->next;
3686 + }
3687 +
3688 +@@ -3956,7 +3954,7 @@ static int process_resp_one_srq(struct qedr_dev *dev, struct qedr_qp *qp,
3689 + } else {
3690 + __process_resp_one(dev, qp, cq, wc, resp, wr_id);
3691 + }
3692 +- srq->hw_srq.wr_cons_cnt++;
3693 ++ atomic_inc(&srq->hw_srq.wr_cons_cnt);
3694 +
3695 + return 1;
3696 + }
3697 +diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c
3698 +index 831ad578a7b2..46e111c218fd 100644
3699 +--- a/drivers/infiniband/sw/rxe/rxe_recv.c
3700 ++++ b/drivers/infiniband/sw/rxe/rxe_recv.c
3701 +@@ -330,10 +330,14 @@ err1:
3702 +
3703 + static int rxe_match_dgid(struct rxe_dev *rxe, struct sk_buff *skb)
3704 + {
3705 ++ struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
3706 + const struct ib_gid_attr *gid_attr;
3707 + union ib_gid dgid;
3708 + union ib_gid *pdgid;
3709 +
3710 ++ if (pkt->mask & RXE_LOOPBACK_MASK)
3711 ++ return 0;
3712 ++
3713 + if (skb->protocol == htons(ETH_P_IP)) {
3714 + ipv6_addr_set_v4mapped(ip_hdr(skb)->daddr,
3715 + (struct in6_addr *)&dgid);
3716 +@@ -366,7 +370,7 @@ void rxe_rcv(struct sk_buff *skb)
3717 + if (unlikely(skb->len < pkt->offset + RXE_BTH_BYTES))
3718 + goto drop;
3719 +
3720 +- if (unlikely(rxe_match_dgid(rxe, skb) < 0)) {
3721 ++ if (rxe_match_dgid(rxe, skb) < 0) {
3722 + pr_warn_ratelimited("failed matching dgid\n");
3723 + goto drop;
3724 + }
3725 +diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
3726 +index 623129f27f5a..71358b0b8910 100644
3727 +--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
3728 ++++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
3729 +@@ -679,6 +679,7 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr,
3730 + unsigned int mask;
3731 + unsigned int length = 0;
3732 + int i;
3733 ++ struct ib_send_wr *next;
3734 +
3735 + while (wr) {
3736 + mask = wr_opcode_mask(wr->opcode, qp);
3737 +@@ -695,6 +696,8 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr,
3738 + break;
3739 + }
3740 +
3741 ++ next = wr->next;
3742 ++
3743 + length = 0;
3744 + for (i = 0; i < wr->num_sge; i++)
3745 + length += wr->sg_list[i].length;
3746 +@@ -705,7 +708,7 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr,
3747 + *bad_wr = wr;
3748 + break;
3749 + }
3750 +- wr = wr->next;
3751 ++ wr = next;
3752 + }
3753 +
3754 + rxe_run_task(&qp->req.task, 1);
3755 +diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
3756 +index 982d796b686b..6bfb283e6f28 100644
3757 +--- a/drivers/iommu/intel_irq_remapping.c
3758 ++++ b/drivers/iommu/intel_irq_remapping.c
3759 +@@ -628,13 +628,21 @@ out_free_table:
3760 +
3761 + static void intel_teardown_irq_remapping(struct intel_iommu *iommu)
3762 + {
3763 ++ struct fwnode_handle *fn;
3764 ++
3765 + if (iommu && iommu->ir_table) {
3766 + if (iommu->ir_msi_domain) {
3767 ++ fn = iommu->ir_msi_domain->fwnode;
3768 ++
3769 + irq_domain_remove(iommu->ir_msi_domain);
3770 ++ irq_domain_free_fwnode(fn);
3771 + iommu->ir_msi_domain = NULL;
3772 + }
3773 + if (iommu->ir_domain) {
3774 ++ fn = iommu->ir_domain->fwnode;
3775 ++
3776 + irq_domain_remove(iommu->ir_domain);
3777 ++ irq_domain_free_fwnode(fn);
3778 + iommu->ir_domain = NULL;
3779 + }
3780 + free_pages((unsigned long)iommu->ir_table->base,
3781 +diff --git a/drivers/irqchip/irq-mtk-sysirq.c b/drivers/irqchip/irq-mtk-sysirq.c
3782 +index 73eae5966a40..6ff98b87e5c0 100644
3783 +--- a/drivers/irqchip/irq-mtk-sysirq.c
3784 ++++ b/drivers/irqchip/irq-mtk-sysirq.c
3785 +@@ -15,7 +15,7 @@
3786 + #include <linux/spinlock.h>
3787 +
3788 + struct mtk_sysirq_chip_data {
3789 +- spinlock_t lock;
3790 ++ raw_spinlock_t lock;
3791 + u32 nr_intpol_bases;
3792 + void __iomem **intpol_bases;
3793 + u32 *intpol_words;
3794 +@@ -37,7 +37,7 @@ static int mtk_sysirq_set_type(struct irq_data *data, unsigned int type)
3795 + reg_index = chip_data->which_word[hwirq];
3796 + offset = hwirq & 0x1f;
3797 +
3798 +- spin_lock_irqsave(&chip_data->lock, flags);
3799 ++ raw_spin_lock_irqsave(&chip_data->lock, flags);
3800 + value = readl_relaxed(base + reg_index * 4);
3801 + if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_EDGE_FALLING) {
3802 + if (type == IRQ_TYPE_LEVEL_LOW)
3803 +@@ -53,7 +53,7 @@ static int mtk_sysirq_set_type(struct irq_data *data, unsigned int type)
3804 +
3805 + data = data->parent_data;
3806 + ret = data->chip->irq_set_type(data, type);
3807 +- spin_unlock_irqrestore(&chip_data->lock, flags);
3808 ++ raw_spin_unlock_irqrestore(&chip_data->lock, flags);
3809 + return ret;
3810 + }
3811 +
3812 +@@ -212,7 +212,7 @@ static int __init mtk_sysirq_of_init(struct device_node *node,
3813 + ret = -ENOMEM;
3814 + goto out_free_which_word;
3815 + }
3816 +- spin_lock_init(&chip_data->lock);
3817 ++ raw_spin_lock_init(&chip_data->lock);
3818 +
3819 + return 0;
3820 +
3821 +diff --git a/drivers/irqchip/irq-ti-sci-inta.c b/drivers/irqchip/irq-ti-sci-inta.c
3822 +index fa7488863bd0..0a35499c4672 100644
3823 +--- a/drivers/irqchip/irq-ti-sci-inta.c
3824 ++++ b/drivers/irqchip/irq-ti-sci-inta.c
3825 +@@ -571,7 +571,7 @@ static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev)
3826 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
3827 + inta->base = devm_ioremap_resource(dev, res);
3828 + if (IS_ERR(inta->base))
3829 +- return -ENODEV;
3830 ++ return PTR_ERR(inta->base);
3831 +
3832 + domain = irq_domain_add_linear(dev_of_node(dev),
3833 + ti_sci_get_num_resources(inta->vint),
3834 +diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
3835 +index d3e83c33783e..0a4823d9797a 100644
3836 +--- a/drivers/leds/led-class.c
3837 ++++ b/drivers/leds/led-class.c
3838 +@@ -172,6 +172,7 @@ void led_classdev_suspend(struct led_classdev *led_cdev)
3839 + {
3840 + led_cdev->flags |= LED_SUSPENDED;
3841 + led_set_brightness_nopm(led_cdev, 0);
3842 ++ flush_work(&led_cdev->set_brightness_work);
3843 + }
3844 + EXPORT_SYMBOL_GPL(led_classdev_suspend);
3845 +
3846 +diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c
3847 +index a5abb499574b..129f475aebf2 100644
3848 +--- a/drivers/leds/leds-lm355x.c
3849 ++++ b/drivers/leds/leds-lm355x.c
3850 +@@ -165,18 +165,19 @@ static int lm355x_chip_init(struct lm355x_chip_data *chip)
3851 + /* input and output pins configuration */
3852 + switch (chip->type) {
3853 + case CHIP_LM3554:
3854 +- reg_val = pdata->pin_tx2 | pdata->ntc_pin;
3855 ++ reg_val = (u32)pdata->pin_tx2 | (u32)pdata->ntc_pin;
3856 + ret = regmap_update_bits(chip->regmap, 0xE0, 0x28, reg_val);
3857 + if (ret < 0)
3858 + goto out;
3859 +- reg_val = pdata->pass_mode;
3860 ++ reg_val = (u32)pdata->pass_mode;
3861 + ret = regmap_update_bits(chip->regmap, 0xA0, 0x04, reg_val);
3862 + if (ret < 0)
3863 + goto out;
3864 + break;
3865 +
3866 + case CHIP_LM3556:
3867 +- reg_val = pdata->pin_tx2 | pdata->ntc_pin | pdata->pass_mode;
3868 ++ reg_val = (u32)pdata->pin_tx2 | (u32)pdata->ntc_pin |
3869 ++ (u32)pdata->pass_mode;
3870 + ret = regmap_update_bits(chip->regmap, 0x0A, 0xC4, reg_val);
3871 + if (ret < 0)
3872 + goto out;
3873 +diff --git a/drivers/macintosh/via-macii.c b/drivers/macintosh/via-macii.c
3874 +index ac824d7b2dcf..6aa903529570 100644
3875 +--- a/drivers/macintosh/via-macii.c
3876 ++++ b/drivers/macintosh/via-macii.c
3877 +@@ -270,15 +270,12 @@ static int macii_autopoll(int devs)
3878 + unsigned long flags;
3879 + int err = 0;
3880 +
3881 ++ local_irq_save(flags);
3882 ++
3883 + /* bit 1 == device 1, and so on. */
3884 + autopoll_devs = devs & 0xFFFE;
3885 +
3886 +- if (!autopoll_devs)
3887 +- return 0;
3888 +-
3889 +- local_irq_save(flags);
3890 +-
3891 +- if (current_req == NULL) {
3892 ++ if (autopoll_devs && !current_req) {
3893 + /* Send a Talk Reg 0. The controller will repeatedly transmit
3894 + * this as long as it is idle.
3895 + */
3896 +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
3897 +index 68901745eb20..168d64707859 100644
3898 +--- a/drivers/md/bcache/super.c
3899 ++++ b/drivers/md/bcache/super.c
3900 +@@ -2091,7 +2091,14 @@ found:
3901 + sysfs_create_link(&c->kobj, &ca->kobj, buf))
3902 + goto err;
3903 +
3904 +- if (ca->sb.seq > c->sb.seq) {
3905 ++ /*
3906 ++ * A special case is both ca->sb.seq and c->sb.seq are 0,
3907 ++ * such condition happens on a new created cache device whose
3908 ++ * super block is never flushed yet. In this case c->sb.version
3909 ++ * and other members should be updated too, otherwise we will
3910 ++ * have a mistaken super block version in cache set.
3911 ++ */
3912 ++ if (ca->sb.seq > c->sb.seq || c->sb.seq == 0) {
3913 + c->sb.version = ca->sb.version;
3914 + memcpy(c->sb.set_uuid, ca->sb.set_uuid, 16);
3915 + c->sb.flags = ca->sb.flags;
3916 +diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
3917 +index 813a99ffa86f..73fd50e77975 100644
3918 +--- a/drivers/md/md-cluster.c
3919 ++++ b/drivers/md/md-cluster.c
3920 +@@ -1518,6 +1518,7 @@ static void unlock_all_bitmaps(struct mddev *mddev)
3921 + }
3922 + }
3923 + kfree(cinfo->other_bitmap_lockres);
3924 ++ cinfo->other_bitmap_lockres = NULL;
3925 + }
3926 + }
3927 +
3928 +diff --git a/drivers/md/md.c b/drivers/md/md.c
3929 +index 5a378a453a2d..acef01e519d0 100644
3930 +--- a/drivers/md/md.c
3931 ++++ b/drivers/md/md.c
3932 +@@ -376,17 +376,18 @@ static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio)
3933 + struct mddev *mddev = q->queuedata;
3934 + unsigned int sectors;
3935 +
3936 +- if (unlikely(test_bit(MD_BROKEN, &mddev->flags)) && (rw == WRITE)) {
3937 ++ if (mddev == NULL || mddev->pers == NULL) {
3938 + bio_io_error(bio);
3939 + return BLK_QC_T_NONE;
3940 + }
3941 +
3942 +- blk_queue_split(q, &bio);
3943 +-
3944 +- if (mddev == NULL || mddev->pers == NULL) {
3945 ++ if (unlikely(test_bit(MD_BROKEN, &mddev->flags)) && (rw == WRITE)) {
3946 + bio_io_error(bio);
3947 + return BLK_QC_T_NONE;
3948 + }
3949 ++
3950 ++ blk_queue_split(q, &bio);
3951 ++
3952 + if (mddev->ro == 1 && unlikely(rw == WRITE)) {
3953 + if (bio_sectors(bio) != 0)
3954 + bio->bi_status = BLK_STS_IOERR;
3955 +diff --git a/drivers/media/firewire/firedtv-fw.c b/drivers/media/firewire/firedtv-fw.c
3956 +index 97144734eb05..3f1ca40b9b98 100644
3957 +--- a/drivers/media/firewire/firedtv-fw.c
3958 ++++ b/drivers/media/firewire/firedtv-fw.c
3959 +@@ -272,6 +272,8 @@ static int node_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
3960 +
3961 + name_len = fw_csr_string(unit->directory, CSR_MODEL,
3962 + name, sizeof(name));
3963 ++ if (name_len < 0)
3964 ++ return name_len;
3965 + for (i = ARRAY_SIZE(model_names); --i; )
3966 + if (strlen(model_names[i]) <= name_len &&
3967 + strncmp(name, model_names[i], name_len) == 0)
3968 +diff --git a/drivers/media/mc/mc-request.c b/drivers/media/mc/mc-request.c
3969 +index e3fca436c75b..c0782fd96c59 100644
3970 +--- a/drivers/media/mc/mc-request.c
3971 ++++ b/drivers/media/mc/mc-request.c
3972 +@@ -296,9 +296,18 @@ int media_request_alloc(struct media_device *mdev, int *alloc_fd)
3973 + if (WARN_ON(!mdev->ops->req_alloc ^ !mdev->ops->req_free))
3974 + return -ENOMEM;
3975 +
3976 ++ if (mdev->ops->req_alloc)
3977 ++ req = mdev->ops->req_alloc(mdev);
3978 ++ else
3979 ++ req = kzalloc(sizeof(*req), GFP_KERNEL);
3980 ++ if (!req)
3981 ++ return -ENOMEM;
3982 ++
3983 + fd = get_unused_fd_flags(O_CLOEXEC);
3984 +- if (fd < 0)
3985 +- return fd;
3986 ++ if (fd < 0) {
3987 ++ ret = fd;
3988 ++ goto err_free_req;
3989 ++ }
3990 +
3991 + filp = anon_inode_getfile("request", &request_fops, NULL, O_CLOEXEC);
3992 + if (IS_ERR(filp)) {
3993 +@@ -306,15 +315,6 @@ int media_request_alloc(struct media_device *mdev, int *alloc_fd)
3994 + goto err_put_fd;
3995 + }
3996 +
3997 +- if (mdev->ops->req_alloc)
3998 +- req = mdev->ops->req_alloc(mdev);
3999 +- else
4000 +- req = kzalloc(sizeof(*req), GFP_KERNEL);
4001 +- if (!req) {
4002 +- ret = -ENOMEM;
4003 +- goto err_fput;
4004 +- }
4005 +-
4006 + filp->private_data = req;
4007 + req->mdev = mdev;
4008 + req->state = MEDIA_REQUEST_STATE_IDLE;
4009 +@@ -336,12 +336,15 @@ int media_request_alloc(struct media_device *mdev, int *alloc_fd)
4010 +
4011 + return 0;
4012 +
4013 +-err_fput:
4014 +- fput(filp);
4015 +-
4016 + err_put_fd:
4017 + put_unused_fd(fd);
4018 +
4019 ++err_free_req:
4020 ++ if (mdev->ops->req_free)
4021 ++ mdev->ops->req_free(req);
4022 ++ else
4023 ++ kfree(req);
4024 ++
4025 + return ret;
4026 + }
4027 +
4028 +diff --git a/drivers/media/platform/cros-ec-cec/cros-ec-cec.c b/drivers/media/platform/cros-ec-cec/cros-ec-cec.c
4029 +index 4a3b3810fd89..31390ce2dbf2 100644
4030 +--- a/drivers/media/platform/cros-ec-cec/cros-ec-cec.c
4031 ++++ b/drivers/media/platform/cros-ec-cec/cros-ec-cec.c
4032 +@@ -278,11 +278,7 @@ static int cros_ec_cec_probe(struct platform_device *pdev)
4033 + platform_set_drvdata(pdev, cros_ec_cec);
4034 + cros_ec_cec->cros_ec = cros_ec;
4035 +
4036 +- ret = device_init_wakeup(&pdev->dev, 1);
4037 +- if (ret) {
4038 +- dev_err(&pdev->dev, "failed to initialize wakeup\n");
4039 +- return ret;
4040 +- }
4041 ++ device_init_wakeup(&pdev->dev, 1);
4042 +
4043 + cros_ec_cec->adap = cec_allocate_adapter(&cros_ec_cec_ops, cros_ec_cec,
4044 + DRV_NAME,
4045 +diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
4046 +index 9aaf3b8060d5..9c31d950cddf 100644
4047 +--- a/drivers/media/platform/exynos4-is/media-dev.c
4048 ++++ b/drivers/media/platform/exynos4-is/media-dev.c
4049 +@@ -1270,6 +1270,9 @@ static int fimc_md_get_pinctrl(struct fimc_md *fmd)
4050 +
4051 + pctl->state_idle = pinctrl_lookup_state(pctl->pinctrl,
4052 + PINCTRL_STATE_IDLE);
4053 ++ if (IS_ERR(pctl->state_idle))
4054 ++ return PTR_ERR(pctl->state_idle);
4055 ++
4056 + return 0;
4057 + }
4058 +
4059 +diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
4060 +index 803baf97f06e..6de8b3d99fb9 100644
4061 +--- a/drivers/media/platform/marvell-ccic/mcam-core.c
4062 ++++ b/drivers/media/platform/marvell-ccic/mcam-core.c
4063 +@@ -1940,6 +1940,7 @@ int mccic_register(struct mcam_camera *cam)
4064 + out:
4065 + v4l2_async_notifier_unregister(&cam->notifier);
4066 + v4l2_device_unregister(&cam->v4l2_dev);
4067 ++ v4l2_async_notifier_cleanup(&cam->notifier);
4068 + return ret;
4069 + }
4070 + EXPORT_SYMBOL_GPL(mccic_register);
4071 +@@ -1961,6 +1962,7 @@ void mccic_shutdown(struct mcam_camera *cam)
4072 + v4l2_ctrl_handler_free(&cam->ctrl_handler);
4073 + v4l2_async_notifier_unregister(&cam->notifier);
4074 + v4l2_device_unregister(&cam->v4l2_dev);
4075 ++ v4l2_async_notifier_cleanup(&cam->notifier);
4076 + }
4077 + EXPORT_SYMBOL_GPL(mccic_shutdown);
4078 +
4079 +diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c
4080 +index 97d660606d98..b8c2b8bba826 100644
4081 +--- a/drivers/media/platform/omap3isp/isppreview.c
4082 ++++ b/drivers/media/platform/omap3isp/isppreview.c
4083 +@@ -2287,7 +2287,7 @@ static int preview_init_entities(struct isp_prev_device *prev)
4084 + me->ops = &preview_media_ops;
4085 + ret = media_entity_pads_init(me, PREV_PADS_NUM, pads);
4086 + if (ret < 0)
4087 +- return ret;
4088 ++ goto error_handler_free;
4089 +
4090 + preview_init_formats(sd, NULL);
4091 +
4092 +@@ -2320,6 +2320,8 @@ error_video_out:
4093 + omap3isp_video_cleanup(&prev->video_in);
4094 + error_video_in:
4095 + media_entity_cleanup(&prev->subdev.entity);
4096 ++error_handler_free:
4097 ++ v4l2_ctrl_handler_free(&prev->ctrls);
4098 + return ret;
4099 + }
4100 +
4101 +diff --git a/drivers/media/usb/dvb-usb/Kconfig b/drivers/media/usb/dvb-usb/Kconfig
4102 +index 1a3e5f965ae4..2d7a5c1c84af 100644
4103 +--- a/drivers/media/usb/dvb-usb/Kconfig
4104 ++++ b/drivers/media/usb/dvb-usb/Kconfig
4105 +@@ -150,6 +150,7 @@ config DVB_USB_CXUSB
4106 + config DVB_USB_CXUSB_ANALOG
4107 + bool "Analog support for the Conexant USB2.0 hybrid reference design"
4108 + depends on DVB_USB_CXUSB && VIDEO_V4L2
4109 ++ depends on VIDEO_V4L2=y || VIDEO_V4L2=DVB_USB_CXUSB
4110 + select VIDEO_CX25840
4111 + select VIDEOBUF2_VMALLOC
4112 + help
4113 +diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c
4114 +index f0263d1a1fdf..d97a243ad30c 100644
4115 +--- a/drivers/misc/cxl/sysfs.c
4116 ++++ b/drivers/misc/cxl/sysfs.c
4117 +@@ -624,7 +624,7 @@ static struct afu_config_record *cxl_sysfs_afu_new_cr(struct cxl_afu *afu, int c
4118 + rc = kobject_init_and_add(&cr->kobj, &afu_config_record_type,
4119 + &afu->dev.kobj, "cr%i", cr->cr);
4120 + if (rc)
4121 +- goto err;
4122 ++ goto err1;
4123 +
4124 + rc = sysfs_create_bin_file(&cr->kobj, &cr->config_attr);
4125 + if (rc)
4126 +diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c
4127 +index 5f2e9696ee4d..0c2489446bd7 100644
4128 +--- a/drivers/mmc/host/sdhci-cadence.c
4129 ++++ b/drivers/mmc/host/sdhci-cadence.c
4130 +@@ -194,57 +194,6 @@ static u32 sdhci_cdns_get_emmc_mode(struct sdhci_cdns_priv *priv)
4131 + return FIELD_GET(SDHCI_CDNS_HRS06_MODE, tmp);
4132 + }
4133 +
4134 +-static void sdhci_cdns_set_uhs_signaling(struct sdhci_host *host,
4135 +- unsigned int timing)
4136 +-{
4137 +- struct sdhci_cdns_priv *priv = sdhci_cdns_priv(host);
4138 +- u32 mode;
4139 +-
4140 +- switch (timing) {
4141 +- case MMC_TIMING_MMC_HS:
4142 +- mode = SDHCI_CDNS_HRS06_MODE_MMC_SDR;
4143 +- break;
4144 +- case MMC_TIMING_MMC_DDR52:
4145 +- mode = SDHCI_CDNS_HRS06_MODE_MMC_DDR;
4146 +- break;
4147 +- case MMC_TIMING_MMC_HS200:
4148 +- mode = SDHCI_CDNS_HRS06_MODE_MMC_HS200;
4149 +- break;
4150 +- case MMC_TIMING_MMC_HS400:
4151 +- if (priv->enhanced_strobe)
4152 +- mode = SDHCI_CDNS_HRS06_MODE_MMC_HS400ES;
4153 +- else
4154 +- mode = SDHCI_CDNS_HRS06_MODE_MMC_HS400;
4155 +- break;
4156 +- default:
4157 +- mode = SDHCI_CDNS_HRS06_MODE_SD;
4158 +- break;
4159 +- }
4160 +-
4161 +- sdhci_cdns_set_emmc_mode(priv, mode);
4162 +-
4163 +- /* For SD, fall back to the default handler */
4164 +- if (mode == SDHCI_CDNS_HRS06_MODE_SD)
4165 +- sdhci_set_uhs_signaling(host, timing);
4166 +-}
4167 +-
4168 +-static const struct sdhci_ops sdhci_cdns_ops = {
4169 +- .set_clock = sdhci_set_clock,
4170 +- .get_timeout_clock = sdhci_cdns_get_timeout_clock,
4171 +- .set_bus_width = sdhci_set_bus_width,
4172 +- .reset = sdhci_reset,
4173 +- .set_uhs_signaling = sdhci_cdns_set_uhs_signaling,
4174 +-};
4175 +-
4176 +-static const struct sdhci_pltfm_data sdhci_cdns_uniphier_pltfm_data = {
4177 +- .ops = &sdhci_cdns_ops,
4178 +- .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
4179 +-};
4180 +-
4181 +-static const struct sdhci_pltfm_data sdhci_cdns_pltfm_data = {
4182 +- .ops = &sdhci_cdns_ops,
4183 +-};
4184 +-
4185 + static int sdhci_cdns_set_tune_val(struct sdhci_host *host, unsigned int val)
4186 + {
4187 + struct sdhci_cdns_priv *priv = sdhci_cdns_priv(host);
4188 +@@ -278,23 +227,24 @@ static int sdhci_cdns_set_tune_val(struct sdhci_host *host, unsigned int val)
4189 + return 0;
4190 + }
4191 +
4192 +-static int sdhci_cdns_execute_tuning(struct mmc_host *mmc, u32 opcode)
4193 ++/*
4194 ++ * In SD mode, software must not use the hardware tuning and instead perform
4195 ++ * an almost identical procedure to eMMC.
4196 ++ */
4197 ++static int sdhci_cdns_execute_tuning(struct sdhci_host *host, u32 opcode)
4198 + {
4199 +- struct sdhci_host *host = mmc_priv(mmc);
4200 + int cur_streak = 0;
4201 + int max_streak = 0;
4202 + int end_of_streak = 0;
4203 + int i;
4204 +
4205 + /*
4206 +- * This handler only implements the eMMC tuning that is specific to
4207 +- * this controller. Fall back to the standard method for SD timing.
4208 ++ * Do not execute tuning for UHS_SDR50 or UHS_DDR50.
4209 ++ * The delay is set by probe, based on the DT properties.
4210 + */
4211 +- if (host->timing != MMC_TIMING_MMC_HS200)
4212 +- return sdhci_execute_tuning(mmc, opcode);
4213 +-
4214 +- if (WARN_ON(opcode != MMC_SEND_TUNING_BLOCK_HS200))
4215 +- return -EINVAL;
4216 ++ if (host->timing != MMC_TIMING_MMC_HS200 &&
4217 ++ host->timing != MMC_TIMING_UHS_SDR104)
4218 ++ return 0;
4219 +
4220 + for (i = 0; i < SDHCI_CDNS_MAX_TUNING_LOOP; i++) {
4221 + if (sdhci_cdns_set_tune_val(host, i) ||
4222 +@@ -317,6 +267,58 @@ static int sdhci_cdns_execute_tuning(struct mmc_host *mmc, u32 opcode)
4223 + return sdhci_cdns_set_tune_val(host, end_of_streak - max_streak / 2);
4224 + }
4225 +
4226 ++static void sdhci_cdns_set_uhs_signaling(struct sdhci_host *host,
4227 ++ unsigned int timing)
4228 ++{
4229 ++ struct sdhci_cdns_priv *priv = sdhci_cdns_priv(host);
4230 ++ u32 mode;
4231 ++
4232 ++ switch (timing) {
4233 ++ case MMC_TIMING_MMC_HS:
4234 ++ mode = SDHCI_CDNS_HRS06_MODE_MMC_SDR;
4235 ++ break;
4236 ++ case MMC_TIMING_MMC_DDR52:
4237 ++ mode = SDHCI_CDNS_HRS06_MODE_MMC_DDR;
4238 ++ break;
4239 ++ case MMC_TIMING_MMC_HS200:
4240 ++ mode = SDHCI_CDNS_HRS06_MODE_MMC_HS200;
4241 ++ break;
4242 ++ case MMC_TIMING_MMC_HS400:
4243 ++ if (priv->enhanced_strobe)
4244 ++ mode = SDHCI_CDNS_HRS06_MODE_MMC_HS400ES;
4245 ++ else
4246 ++ mode = SDHCI_CDNS_HRS06_MODE_MMC_HS400;
4247 ++ break;
4248 ++ default:
4249 ++ mode = SDHCI_CDNS_HRS06_MODE_SD;
4250 ++ break;
4251 ++ }
4252 ++
4253 ++ sdhci_cdns_set_emmc_mode(priv, mode);
4254 ++
4255 ++ /* For SD, fall back to the default handler */
4256 ++ if (mode == SDHCI_CDNS_HRS06_MODE_SD)
4257 ++ sdhci_set_uhs_signaling(host, timing);
4258 ++}
4259 ++
4260 ++static const struct sdhci_ops sdhci_cdns_ops = {
4261 ++ .set_clock = sdhci_set_clock,
4262 ++ .get_timeout_clock = sdhci_cdns_get_timeout_clock,
4263 ++ .set_bus_width = sdhci_set_bus_width,
4264 ++ .reset = sdhci_reset,
4265 ++ .platform_execute_tuning = sdhci_cdns_execute_tuning,
4266 ++ .set_uhs_signaling = sdhci_cdns_set_uhs_signaling,
4267 ++};
4268 ++
4269 ++static const struct sdhci_pltfm_data sdhci_cdns_uniphier_pltfm_data = {
4270 ++ .ops = &sdhci_cdns_ops,
4271 ++ .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
4272 ++};
4273 ++
4274 ++static const struct sdhci_pltfm_data sdhci_cdns_pltfm_data = {
4275 ++ .ops = &sdhci_cdns_ops,
4276 ++};
4277 ++
4278 + static void sdhci_cdns_hs400_enhanced_strobe(struct mmc_host *mmc,
4279 + struct mmc_ios *ios)
4280 + {
4281 +@@ -377,7 +379,6 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
4282 + priv->hrs_addr = host->ioaddr;
4283 + priv->enhanced_strobe = false;
4284 + host->ioaddr += SDHCI_CDNS_SRS_BASE;
4285 +- host->mmc_host_ops.execute_tuning = sdhci_cdns_execute_tuning;
4286 + host->mmc_host_ops.hs400_enhanced_strobe =
4287 + sdhci_cdns_hs400_enhanced_strobe;
4288 + sdhci_enable_v4_mode(host);
4289 +diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
4290 +index fa8105087d68..41a2394313dd 100644
4291 +--- a/drivers/mmc/host/sdhci-pci-o2micro.c
4292 ++++ b/drivers/mmc/host/sdhci-pci-o2micro.c
4293 +@@ -561,6 +561,12 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
4294 + slot->host->mmc_host_ops.get_cd = sdhci_o2_get_cd;
4295 + }
4296 +
4297 ++ if (chip->pdev->device == PCI_DEVICE_ID_O2_SEABIRD1) {
4298 ++ slot->host->mmc_host_ops.get_cd = sdhci_o2_get_cd;
4299 ++ host->mmc->caps2 |= MMC_CAP2_NO_SDIO;
4300 ++ host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN;
4301 ++ }
4302 ++
4303 + host->mmc_host_ops.execute_tuning = sdhci_o2_execute_tuning;
4304 +
4305 + if (chip->pdev->device != PCI_DEVICE_ID_O2_FUJIN2)
4306 +diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
4307 +index 7bb9a7e8e1e7..c1c53b02b35f 100644
4308 +--- a/drivers/mtd/nand/raw/qcom_nandc.c
4309 ++++ b/drivers/mtd/nand/raw/qcom_nandc.c
4310 +@@ -459,11 +459,13 @@ struct qcom_nand_host {
4311 + * among different NAND controllers.
4312 + * @ecc_modes - ecc mode for NAND
4313 + * @is_bam - whether NAND controller is using BAM
4314 ++ * @is_qpic - whether NAND CTRL is part of qpic IP
4315 + * @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset
4316 + */
4317 + struct qcom_nandc_props {
4318 + u32 ecc_modes;
4319 + bool is_bam;
4320 ++ bool is_qpic;
4321 + u32 dev_cmd_reg_start;
4322 + };
4323 +
4324 +@@ -2751,7 +2753,8 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)
4325 + u32 nand_ctrl;
4326 +
4327 + /* kill onenand */
4328 +- nandc_write(nandc, SFLASHC_BURST_CFG, 0);
4329 ++ if (!nandc->props->is_qpic)
4330 ++ nandc_write(nandc, SFLASHC_BURST_CFG, 0);
4331 + nandc_write(nandc, dev_cmd_reg_addr(nandc, NAND_DEV_CMD_VLD),
4332 + NAND_DEV_CMD_VLD_VAL);
4333 +
4334 +@@ -3007,12 +3010,14 @@ static const struct qcom_nandc_props ipq806x_nandc_props = {
4335 + static const struct qcom_nandc_props ipq4019_nandc_props = {
4336 + .ecc_modes = (ECC_BCH_4BIT | ECC_BCH_8BIT),
4337 + .is_bam = true,
4338 ++ .is_qpic = true,
4339 + .dev_cmd_reg_start = 0x0,
4340 + };
4341 +
4342 + static const struct qcom_nandc_props ipq8074_nandc_props = {
4343 + .ecc_modes = (ECC_BCH_4BIT | ECC_BCH_8BIT),
4344 + .is_bam = true,
4345 ++ .is_qpic = true,
4346 + .dev_cmd_reg_start = 0x7000,
4347 + };
4348 +
4349 +diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
4350 +index 6787d560e9e3..92e4d140df6f 100644
4351 +--- a/drivers/net/dsa/mv88e6xxx/chip.c
4352 ++++ b/drivers/net/dsa/mv88e6xxx/chip.c
4353 +@@ -3063,7 +3063,6 @@ static const struct mv88e6xxx_ops mv88e6097_ops = {
4354 + .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4355 + .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4356 + .port_set_ether_type = mv88e6351_port_set_ether_type,
4357 +- .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4358 + .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
4359 + .port_pause_limit = mv88e6097_port_pause_limit,
4360 + .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4361 +diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c
4362 +index ac88caca5ad4..1368816abaed 100644
4363 +--- a/drivers/net/dsa/rtl8366.c
4364 ++++ b/drivers/net/dsa/rtl8366.c
4365 +@@ -43,18 +43,26 @@ int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member,
4366 + int ret;
4367 + int i;
4368 +
4369 ++ dev_dbg(smi->dev,
4370 ++ "setting VLAN%d 4k members: 0x%02x, untagged: 0x%02x\n",
4371 ++ vid, member, untag);
4372 ++
4373 + /* Update the 4K table */
4374 + ret = smi->ops->get_vlan_4k(smi, vid, &vlan4k);
4375 + if (ret)
4376 + return ret;
4377 +
4378 +- vlan4k.member = member;
4379 +- vlan4k.untag = untag;
4380 ++ vlan4k.member |= member;
4381 ++ vlan4k.untag |= untag;
4382 + vlan4k.fid = fid;
4383 + ret = smi->ops->set_vlan_4k(smi, &vlan4k);
4384 + if (ret)
4385 + return ret;
4386 +
4387 ++ dev_dbg(smi->dev,
4388 ++ "resulting VLAN%d 4k members: 0x%02x, untagged: 0x%02x\n",
4389 ++ vid, vlan4k.member, vlan4k.untag);
4390 ++
4391 + /* Try to find an existing MC entry for this VID */
4392 + for (i = 0; i < smi->num_vlan_mc; i++) {
4393 + struct rtl8366_vlan_mc vlanmc;
4394 +@@ -65,11 +73,16 @@ int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member,
4395 +
4396 + if (vid == vlanmc.vid) {
4397 + /* update the MC entry */
4398 +- vlanmc.member = member;
4399 +- vlanmc.untag = untag;
4400 ++ vlanmc.member |= member;
4401 ++ vlanmc.untag |= untag;
4402 + vlanmc.fid = fid;
4403 +
4404 + ret = smi->ops->set_vlan_mc(smi, i, &vlanmc);
4405 ++
4406 ++ dev_dbg(smi->dev,
4407 ++ "resulting VLAN%d MC members: 0x%02x, untagged: 0x%02x\n",
4408 ++ vid, vlanmc.member, vlanmc.untag);
4409 ++
4410 + break;
4411 + }
4412 + }
4413 +@@ -384,7 +397,7 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port,
4414 + if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
4415 + dev_err(smi->dev, "port is DSA or CPU port\n");
4416 +
4417 +- for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
4418 ++ for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
4419 + int pvid_val = 0;
4420 +
4421 + dev_info(smi->dev, "add VLAN %04x\n", vid);
4422 +@@ -407,13 +420,13 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port,
4423 + if (ret < 0)
4424 + return;
4425 + }
4426 +- }
4427 +
4428 +- ret = rtl8366_set_vlan(smi, port, member, untag, 0);
4429 +- if (ret)
4430 +- dev_err(smi->dev,
4431 +- "failed to set up VLAN %04x",
4432 +- vid);
4433 ++ ret = rtl8366_set_vlan(smi, vid, member, untag, 0);
4434 ++ if (ret)
4435 ++ dev_err(smi->dev,
4436 ++ "failed to set up VLAN %04x",
4437 ++ vid);
4438 ++ }
4439 + }
4440 + EXPORT_SYMBOL_GPL(rtl8366_vlan_add);
4441 +
4442 +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
4443 +index 359a4d387185..9a0db70c1143 100644
4444 +--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
4445 ++++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
4446 +@@ -776,7 +776,7 @@ static int hw_atl_a0_hw_multicast_list_set(struct aq_hw_s *self,
4447 + int err = 0;
4448 +
4449 + if (count > (HW_ATL_A0_MAC_MAX - HW_ATL_A0_MAC_MIN)) {
4450 +- err = EBADRQC;
4451 ++ err = -EBADRQC;
4452 + goto err_exit;
4453 + }
4454 + for (self->aq_nic_cfg->mc_list_count = 0U;
4455 +diff --git a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c
4456 +index 43d11c38b38a..4cddd628d41b 100644
4457 +--- a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c
4458 ++++ b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c
4459 +@@ -1167,7 +1167,7 @@ static int cn23xx_get_pf_num(struct octeon_device *oct)
4460 + oct->pf_num = ((fdl_bit >> CN23XX_PCIE_SRIOV_FDL_BIT_POS) &
4461 + CN23XX_PCIE_SRIOV_FDL_MASK);
4462 + } else {
4463 +- ret = EINVAL;
4464 ++ ret = -EINVAL;
4465 +
4466 + /* Under some virtual environments, extended PCI regs are
4467 + * inaccessible, in which case the above read will have failed.
4468 +diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
4469 +index f414f5651dbd..5c45c0c6dd23 100644
4470 +--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
4471 ++++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
4472 +@@ -2185,6 +2185,9 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
4473 + nic->max_queues *= 2;
4474 + nic->ptp_clock = ptp_clock;
4475 +
4476 ++ /* Initialize mutex that serializes usage of VF's mailbox */
4477 ++ mutex_init(&nic->rx_mode_mtx);
4478 ++
4479 + /* MAP VF's configuration registers */
4480 + nic->reg_base = pcim_iomap(pdev, PCI_CFG_REG_BAR_NUM, 0);
4481 + if (!nic->reg_base) {
4482 +@@ -2261,7 +2264,6 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
4483 +
4484 + INIT_WORK(&nic->rx_mode_work.work, nicvf_set_rx_mode_task);
4485 + spin_lock_init(&nic->rx_mode_wq_lock);
4486 +- mutex_init(&nic->rx_mode_mtx);
4487 +
4488 + err = register_netdev(netdev);
4489 + if (err) {
4490 +diff --git a/drivers/net/ethernet/freescale/fman/fman.c b/drivers/net/ethernet/freescale/fman/fman.c
4491 +index 4c2fa13a7dd7..c8e434c8ab98 100644
4492 +--- a/drivers/net/ethernet/freescale/fman/fman.c
4493 ++++ b/drivers/net/ethernet/freescale/fman/fman.c
4494 +@@ -1396,8 +1396,7 @@ static void enable_time_stamp(struct fman *fman)
4495 + {
4496 + struct fman_fpm_regs __iomem *fpm_rg = fman->fpm_regs;
4497 + u16 fm_clk_freq = fman->state->fm_clk_freq;
4498 +- u32 tmp, intgr, ts_freq;
4499 +- u64 frac;
4500 ++ u32 tmp, intgr, ts_freq, frac;
4501 +
4502 + ts_freq = (u32)(1 << fman->state->count1_micro_bit);
4503 + /* configure timestamp so that bit 8 will count 1 microsecond
4504 +diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
4505 +index 1ca543ac8f2c..d2de9ea80c43 100644
4506 +--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
4507 ++++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
4508 +@@ -1205,7 +1205,7 @@ int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)
4509 + list_for_each(pos,
4510 + &dtsec->multicast_addr_hash->lsts[bucket]) {
4511 + hash_entry = ETH_HASH_ENTRY_OBJ(pos);
4512 +- if (hash_entry->addr == addr) {
4513 ++ if (hash_entry && hash_entry->addr == addr) {
4514 + list_del_init(&hash_entry->node);
4515 + kfree(hash_entry);
4516 + break;
4517 +@@ -1218,7 +1218,7 @@ int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)
4518 + list_for_each(pos,
4519 + &dtsec->unicast_addr_hash->lsts[bucket]) {
4520 + hash_entry = ETH_HASH_ENTRY_OBJ(pos);
4521 +- if (hash_entry->addr == addr) {
4522 ++ if (hash_entry && hash_entry->addr == addr) {
4523 + list_del_init(&hash_entry->node);
4524 + kfree(hash_entry);
4525 + break;
4526 +diff --git a/drivers/net/ethernet/freescale/fman/fman_mac.h b/drivers/net/ethernet/freescale/fman/fman_mac.h
4527 +index dd6d0526f6c1..19f327efdaff 100644
4528 +--- a/drivers/net/ethernet/freescale/fman/fman_mac.h
4529 ++++ b/drivers/net/ethernet/freescale/fman/fman_mac.h
4530 +@@ -252,7 +252,7 @@ static inline struct eth_hash_t *alloc_hash_table(u16 size)
4531 + struct eth_hash_t *hash;
4532 +
4533 + /* Allocate address hash table */
4534 +- hash = kmalloc_array(size, sizeof(struct eth_hash_t *), GFP_KERNEL);
4535 ++ hash = kmalloc(sizeof(*hash), GFP_KERNEL);
4536 + if (!hash)
4537 + return NULL;
4538 +
4539 +diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c
4540 +index e1901874c19f..9088b4f4b4b8 100644
4541 +--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
4542 ++++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
4543 +@@ -856,7 +856,6 @@ int memac_set_tx_pause_frames(struct fman_mac *memac, u8 priority,
4544 +
4545 + tmp = ioread32be(&regs->command_config);
4546 + tmp &= ~CMD_CFG_PFC_MODE;
4547 +- priority = 0;
4548 +
4549 + iowrite32be(tmp, &regs->command_config);
4550 +
4551 +@@ -986,7 +985,7 @@ int memac_del_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr)
4552 +
4553 + list_for_each(pos, &memac->multicast_addr_hash->lsts[hash]) {
4554 + hash_entry = ETH_HASH_ENTRY_OBJ(pos);
4555 +- if (hash_entry->addr == addr) {
4556 ++ if (hash_entry && hash_entry->addr == addr) {
4557 + list_del_init(&hash_entry->node);
4558 + kfree(hash_entry);
4559 + break;
4560 +diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c b/drivers/net/ethernet/freescale/fman/fman_port.c
4561 +index ee82ee1384eb..47f6fee1f396 100644
4562 +--- a/drivers/net/ethernet/freescale/fman/fman_port.c
4563 ++++ b/drivers/net/ethernet/freescale/fman/fman_port.c
4564 +@@ -1756,6 +1756,7 @@ static int fman_port_probe(struct platform_device *of_dev)
4565 + struct fman_port *port;
4566 + struct fman *fman;
4567 + struct device_node *fm_node, *port_node;
4568 ++ struct platform_device *fm_pdev;
4569 + struct resource res;
4570 + struct resource *dev_res;
4571 + u32 val;
4572 +@@ -1780,8 +1781,14 @@ static int fman_port_probe(struct platform_device *of_dev)
4573 + goto return_err;
4574 + }
4575 +
4576 +- fman = dev_get_drvdata(&of_find_device_by_node(fm_node)->dev);
4577 ++ fm_pdev = of_find_device_by_node(fm_node);
4578 + of_node_put(fm_node);
4579 ++ if (!fm_pdev) {
4580 ++ err = -EINVAL;
4581 ++ goto return_err;
4582 ++ }
4583 ++
4584 ++ fman = dev_get_drvdata(&fm_pdev->dev);
4585 + if (!fman) {
4586 + err = -EINVAL;
4587 + goto return_err;
4588 +diff --git a/drivers/net/ethernet/freescale/fman/fman_tgec.c b/drivers/net/ethernet/freescale/fman/fman_tgec.c
4589 +index f75b9c11b2d2..ac5a281e0ec3 100644
4590 +--- a/drivers/net/ethernet/freescale/fman/fman_tgec.c
4591 ++++ b/drivers/net/ethernet/freescale/fman/fman_tgec.c
4592 +@@ -630,7 +630,7 @@ int tgec_del_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr)
4593 +
4594 + list_for_each(pos, &tgec->multicast_addr_hash->lsts[hash]) {
4595 + hash_entry = ETH_HASH_ENTRY_OBJ(pos);
4596 +- if (hash_entry->addr == addr) {
4597 ++ if (hash_entry && hash_entry->addr == addr) {
4598 + list_del_init(&hash_entry->node);
4599 + kfree(hash_entry);
4600 + break;
4601 +diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
4602 +index bacc5fb7eba2..34124c213d27 100644
4603 +--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
4604 ++++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
4605 +@@ -1863,8 +1863,10 @@ static int iavf_init_get_resources(struct iavf_adapter *adapter)
4606 +
4607 + adapter->rss_key = kzalloc(adapter->rss_key_size, GFP_KERNEL);
4608 + adapter->rss_lut = kzalloc(adapter->rss_lut_size, GFP_KERNEL);
4609 +- if (!adapter->rss_key || !adapter->rss_lut)
4610 ++ if (!adapter->rss_key || !adapter->rss_lut) {
4611 ++ err = -ENOMEM;
4612 + goto err_mem;
4613 ++ }
4614 + if (RSS_AQ(adapter))
4615 + adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_RSS;
4616 + else
4617 +@@ -1946,7 +1948,10 @@ static void iavf_watchdog_task(struct work_struct *work)
4618 + iavf_send_api_ver(adapter);
4619 + }
4620 + } else {
4621 +- if (!iavf_process_aq_command(adapter) &&
4622 ++ /* An error will be returned if no commands were
4623 ++ * processed; use this opportunity to update stats
4624 ++ */
4625 ++ if (iavf_process_aq_command(adapter) &&
4626 + adapter->state == __IAVF_RUNNING)
4627 + iavf_request_stats(adapter);
4628 + }
4629 +diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
4630 +index cbd53b586c36..6cfe8eb7f47d 100644
4631 +--- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
4632 ++++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
4633 +@@ -1535,10 +1535,12 @@ enum ice_status ice_init_hw_tbls(struct ice_hw *hw)
4634 + es->ref_count = devm_kcalloc(ice_hw_to_dev(hw), es->count,
4635 + sizeof(*es->ref_count),
4636 + GFP_KERNEL);
4637 ++ if (!es->ref_count)
4638 ++ goto err;
4639 +
4640 + es->written = devm_kcalloc(ice_hw_to_dev(hw), es->count,
4641 + sizeof(*es->written), GFP_KERNEL);
4642 +- if (!es->ref_count)
4643 ++ if (!es->written)
4644 + goto err;
4645 + }
4646 + return 0;
4647 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
4648 +index 86e6bbb57482..b66e5b6eecd9 100644
4649 +--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
4650 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
4651 +@@ -809,18 +809,15 @@ static int connect_fts_in_prio(struct mlx5_core_dev *dev,
4652 + {
4653 + struct mlx5_flow_root_namespace *root = find_root(&prio->node);
4654 + struct mlx5_flow_table *iter;
4655 +- int i = 0;
4656 + int err;
4657 +
4658 + fs_for_each_ft(iter, prio) {
4659 +- i++;
4660 + err = root->cmds->modify_flow_table(root, iter, ft);
4661 + if (err) {
4662 +- mlx5_core_warn(dev, "Failed to modify flow table %d\n",
4663 +- iter->id);
4664 ++ mlx5_core_err(dev,
4665 ++ "Failed to modify flow table id %d, type %d, err %d\n",
4666 ++ iter->id, iter->type, err);
4667 + /* The driver is out of sync with the FW */
4668 +- if (i > 1)
4669 +- WARN_ON(true);
4670 + return err;
4671 + }
4672 + }
4673 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c
4674 +index 1e32e2443f73..348f02e336f6 100644
4675 +--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c
4676 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c
4677 +@@ -247,29 +247,9 @@ static int mlx5_cmd_dr_create_fte(struct mlx5_flow_root_namespace *ns,
4678 +
4679 + /* The order of the actions are must to be keep, only the following
4680 + * order is supported by SW steering:
4681 +- * TX: push vlan -> modify header -> encap
4682 ++ * TX: modify header -> push vlan -> encap
4683 + * RX: decap -> pop vlan -> modify header
4684 + */
4685 +- if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH) {
4686 +- tmp_action = create_action_push_vlan(domain, &fte->action.vlan[0]);
4687 +- if (!tmp_action) {
4688 +- err = -ENOMEM;
4689 +- goto free_actions;
4690 +- }
4691 +- fs_dr_actions[fs_dr_num_actions++] = tmp_action;
4692 +- actions[num_actions++] = tmp_action;
4693 +- }
4694 +-
4695 +- if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH_2) {
4696 +- tmp_action = create_action_push_vlan(domain, &fte->action.vlan[1]);
4697 +- if (!tmp_action) {
4698 +- err = -ENOMEM;
4699 +- goto free_actions;
4700 +- }
4701 +- fs_dr_actions[fs_dr_num_actions++] = tmp_action;
4702 +- actions[num_actions++] = tmp_action;
4703 +- }
4704 +-
4705 + if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_DECAP) {
4706 + enum mlx5dr_action_reformat_type decap_type =
4707 + DR_ACTION_REFORMAT_TYP_TNL_L2_TO_L2;
4708 +@@ -322,6 +302,26 @@ static int mlx5_cmd_dr_create_fte(struct mlx5_flow_root_namespace *ns,
4709 + actions[num_actions++] =
4710 + fte->action.modify_hdr->action.dr_action;
4711 +
4712 ++ if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH) {
4713 ++ tmp_action = create_action_push_vlan(domain, &fte->action.vlan[0]);
4714 ++ if (!tmp_action) {
4715 ++ err = -ENOMEM;
4716 ++ goto free_actions;
4717 ++ }
4718 ++ fs_dr_actions[fs_dr_num_actions++] = tmp_action;
4719 ++ actions[num_actions++] = tmp_action;
4720 ++ }
4721 ++
4722 ++ if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH_2) {
4723 ++ tmp_action = create_action_push_vlan(domain, &fte->action.vlan[1]);
4724 ++ if (!tmp_action) {
4725 ++ err = -ENOMEM;
4726 ++ goto free_actions;
4727 ++ }
4728 ++ fs_dr_actions[fs_dr_num_actions++] = tmp_action;
4729 ++ actions[num_actions++] = tmp_action;
4730 ++ }
4731 ++
4732 + if (delay_encap_set)
4733 + actions[num_actions++] =
4734 + fte->action.pkt_reformat->action.dr_action;
4735 +diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
4736 +index c00ec9a02097..e66002251596 100644
4737 +--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
4738 ++++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
4739 +@@ -666,7 +666,7 @@ static bool ionic_notifyq_service(struct ionic_cq *cq,
4740 + eid = le64_to_cpu(comp->event.eid);
4741 +
4742 + /* Have we run out of new completions to process? */
4743 +- if (eid <= lif->last_eid)
4744 ++ if ((s64)(eid - lif->last_eid) <= 0)
4745 + return false;
4746 +
4747 + lif->last_eid = eid;
4748 +diff --git a/drivers/net/ethernet/toshiba/spider_net.c b/drivers/net/ethernet/toshiba/spider_net.c
4749 +index 538e70810d3d..a99c7c95de5c 100644
4750 +--- a/drivers/net/ethernet/toshiba/spider_net.c
4751 ++++ b/drivers/net/ethernet/toshiba/spider_net.c
4752 +@@ -283,8 +283,8 @@ spider_net_free_chain(struct spider_net_card *card,
4753 + descr = descr->next;
4754 + } while (descr != chain->ring);
4755 +
4756 +- dma_free_coherent(&card->pdev->dev, chain->num_desc,
4757 +- chain->hwring, chain->dma_addr);
4758 ++ dma_free_coherent(&card->pdev->dev, chain->num_desc * sizeof(struct spider_net_hw_descr),
4759 ++ chain->hwring, chain->dma_addr);
4760 + }
4761 +
4762 + /**
4763 +diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
4764 +index dba52a5c378a..110924d62744 100644
4765 +--- a/drivers/net/phy/phy_device.c
4766 ++++ b/drivers/net/phy/phy_device.c
4767 +@@ -615,7 +615,9 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
4768 + if (c45_ids)
4769 + dev->c45_ids = *c45_ids;
4770 + dev->irq = bus->irq[addr];
4771 ++
4772 + dev_set_name(&mdiodev->dev, PHY_ID_FMT, bus->id, addr);
4773 ++ device_initialize(&mdiodev->dev);
4774 +
4775 + dev->state = PHY_DOWN;
4776 +
4777 +@@ -649,10 +651,8 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
4778 + ret = phy_request_driver_module(dev, phy_id);
4779 + }
4780 +
4781 +- if (!ret) {
4782 +- device_initialize(&mdiodev->dev);
4783 +- } else {
4784 +- kfree(dev);
4785 ++ if (ret) {
4786 ++ put_device(&mdiodev->dev);
4787 + dev = ERR_PTR(ret);
4788 + }
4789 +
4790 +diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
4791 +index 216acf37ca7c..a06e6ab453f5 100644
4792 +--- a/drivers/net/vmxnet3/vmxnet3_drv.c
4793 ++++ b/drivers/net/vmxnet3/vmxnet3_drv.c
4794 +@@ -861,7 +861,8 @@ vmxnet3_parse_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
4795 +
4796 + switch (protocol) {
4797 + case IPPROTO_TCP:
4798 +- ctx->l4_hdr_size = tcp_hdrlen(skb);
4799 ++ ctx->l4_hdr_size = skb->encapsulation ? inner_tcp_hdrlen(skb) :
4800 ++ tcp_hdrlen(skb);
4801 + break;
4802 + case IPPROTO_UDP:
4803 + ctx->l4_hdr_size = sizeof(struct udphdr);
4804 +diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
4805 +index 134e4dd916c1..996eb9c55b39 100644
4806 +--- a/drivers/net/wan/lapbether.c
4807 ++++ b/drivers/net/wan/lapbether.c
4808 +@@ -157,6 +157,12 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff *skb,
4809 + if (!netif_running(dev))
4810 + goto drop;
4811 +
4812 ++ /* There should be a pseudo header of 1 byte added by upper layers.
4813 ++ * Check to make sure it is there before reading it.
4814 ++ */
4815 ++ if (skb->len < 1)
4816 ++ goto drop;
4817 ++
4818 + switch (skb->data[0]) {
4819 + case X25_IFACE_DATA:
4820 + break;
4821 +@@ -305,6 +311,7 @@ static void lapbeth_setup(struct net_device *dev)
4822 + dev->netdev_ops = &lapbeth_netdev_ops;
4823 + dev->needs_free_netdev = true;
4824 + dev->type = ARPHRD_X25;
4825 ++ dev->hard_header_len = 0;
4826 + dev->mtu = 1000;
4827 + dev->addr_len = 0;
4828 + }
4829 +@@ -331,7 +338,8 @@ static int lapbeth_new_device(struct net_device *dev)
4830 + * then this driver prepends a length field of 2 bytes,
4831 + * then the underlying Ethernet device prepends its own header.
4832 + */
4833 +- ndev->hard_header_len = -1 + 3 + 2 + dev->hard_header_len;
4834 ++ ndev->needed_headroom = -1 + 3 + 2 + dev->hard_header_len
4835 ++ + dev->needed_headroom;
4836 +
4837 + lapbeth = netdev_priv(ndev);
4838 + lapbeth->axdev = ndev;
4839 +diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c
4840 +index 735482877a1f..c38e1963ebc0 100644
4841 +--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
4842 ++++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
4843 +@@ -1540,7 +1540,9 @@ static int ath10k_htt_tx_32(struct ath10k_htt *htt,
4844 + err_unmap_msdu:
4845 + dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
4846 + err_free_msdu_id:
4847 ++ spin_lock_bh(&htt->tx_lock);
4848 + ath10k_htt_tx_free_msdu_id(htt, msdu_id);
4849 ++ spin_unlock_bh(&htt->tx_lock);
4850 + err:
4851 + return res;
4852 + }
4853 +@@ -1747,7 +1749,9 @@ static int ath10k_htt_tx_64(struct ath10k_htt *htt,
4854 + err_unmap_msdu:
4855 + dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
4856 + err_free_msdu_id:
4857 ++ spin_lock_bh(&htt->tx_lock);
4858 + ath10k_htt_tx_free_msdu_id(htt, msdu_id);
4859 ++ spin_unlock_bh(&htt->tx_lock);
4860 + err:
4861 + return res;
4862 + }
4863 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
4864 +index 37c512036e0e..ce18433aaefb 100644
4865 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
4866 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
4867 +@@ -19,7 +19,7 @@
4868 + #define BRCMF_ARP_OL_PEER_AUTO_REPLY 0x00000008
4869 +
4870 + #define BRCMF_BSS_INFO_VERSION 109 /* curr ver of brcmf_bss_info_le struct */
4871 +-#define BRCMF_BSS_RSSI_ON_CHANNEL 0x0002
4872 ++#define BRCMF_BSS_RSSI_ON_CHANNEL 0x0004
4873 +
4874 + #define BRCMF_STA_BRCM 0x00000001 /* Running a Broadcom driver */
4875 + #define BRCMF_STA_WME 0x00000002 /* WMM association */
4876 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
4877 +index 2bd892df83cc..eadc64454839 100644
4878 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
4879 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
4880 +@@ -643,6 +643,7 @@ static inline int brcmf_fws_hanger_poppkt(struct brcmf_fws_hanger *h,
4881 + static void brcmf_fws_psq_flush(struct brcmf_fws_info *fws, struct pktq *q,
4882 + int ifidx)
4883 + {
4884 ++ struct brcmf_fws_hanger_item *hi;
4885 + bool (*matchfn)(struct sk_buff *, void *) = NULL;
4886 + struct sk_buff *skb;
4887 + int prec;
4888 +@@ -654,6 +655,9 @@ static void brcmf_fws_psq_flush(struct brcmf_fws_info *fws, struct pktq *q,
4889 + skb = brcmu_pktq_pdeq_match(q, prec, matchfn, &ifidx);
4890 + while (skb) {
4891 + hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT);
4892 ++ hi = &fws->hanger.items[hslot];
4893 ++ WARN_ON(skb != hi->pkt);
4894 ++ hi->state = BRCMF_FWS_HANGER_ITEM_STATE_FREE;
4895 + brcmf_fws_hanger_poppkt(&fws->hanger, hslot, &skb,
4896 + true);
4897 + brcmu_pkt_buf_free_skb(skb);
4898 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
4899 +index d43247a95ce5..38e6809f16c7 100644
4900 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
4901 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
4902 +@@ -3685,7 +3685,11 @@ static void brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
4903 + if (bus->idlecount > bus->idletime) {
4904 + brcmf_dbg(SDIO, "idle\n");
4905 + sdio_claim_host(bus->sdiodev->func1);
4906 +- brcmf_sdio_wd_timer(bus, false);
4907 ++#ifdef DEBUG
4908 ++ if (!BRCMF_FWCON_ON() ||
4909 ++ bus->console_interval == 0)
4910 ++#endif
4911 ++ brcmf_sdio_wd_timer(bus, false);
4912 + bus->idlecount = 0;
4913 + brcmf_sdio_bus_sleep(bus, true, false);
4914 + sdio_release_host(bus->sdiodev->func1);
4915 +diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
4916 +index 746749f37996..1107b96a8a88 100644
4917 +--- a/drivers/net/wireless/intel/iwlegacy/common.c
4918 ++++ b/drivers/net/wireless/intel/iwlegacy/common.c
4919 +@@ -4286,8 +4286,8 @@ il_apm_init(struct il_priv *il)
4920 + * power savings, even without L1.
4921 + */
4922 + if (il->cfg->set_l0s) {
4923 +- pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl);
4924 +- if (lctl & PCI_EXP_LNKCTL_ASPM_L1) {
4925 ++ ret = pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl);
4926 ++ if (!ret && (lctl & PCI_EXP_LNKCTL_ASPM_L1)) {
4927 + /* L1-ASPM enabled; disable(!) L0S */
4928 + il_set_bit(il, CSR_GIO_REG,
4929 + CSR_GIO_REG_VAL_L0S_ENABLED);
4930 +diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.h b/drivers/net/wireless/marvell/mwifiex/sdio.h
4931 +index f672bdf52cc1..2d9ec225aead 100644
4932 +--- a/drivers/net/wireless/marvell/mwifiex/sdio.h
4933 ++++ b/drivers/net/wireless/marvell/mwifiex/sdio.h
4934 +@@ -36,9 +36,9 @@
4935 + #define SD8897_DEFAULT_FW_NAME "mrvl/sd8897_uapsta.bin"
4936 + #define SD8887_DEFAULT_FW_NAME "mrvl/sd8887_uapsta.bin"
4937 + #define SD8801_DEFAULT_FW_NAME "mrvl/sd8801_uapsta.bin"
4938 +-#define SD8977_DEFAULT_FW_NAME "mrvl/sd8977_uapsta.bin"
4939 ++#define SD8977_DEFAULT_FW_NAME "mrvl/sdsd8977_combo_v2.bin"
4940 + #define SD8987_DEFAULT_FW_NAME "mrvl/sd8987_uapsta.bin"
4941 +-#define SD8997_DEFAULT_FW_NAME "mrvl/sd8997_uapsta.bin"
4942 ++#define SD8997_DEFAULT_FW_NAME "mrvl/sdsd8997_combo_v4.bin"
4943 +
4944 + #define BLOCK_MODE 1
4945 + #define BYTE_MODE 0
4946 +diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
4947 +index 20c206da0631..7ae2c34f65db 100644
4948 +--- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
4949 ++++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
4950 +@@ -580,6 +580,11 @@ static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv,
4951 + {
4952 + struct host_cmd_ds_802_11_key_material *key =
4953 + &resp->params.key_material;
4954 ++ int len;
4955 ++
4956 ++ len = le16_to_cpu(key->key_param_set.key_len);
4957 ++ if (len > sizeof(key->key_param_set.key))
4958 ++ return -EINVAL;
4959 +
4960 + if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) {
4961 + if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) {
4962 +@@ -593,9 +598,8 @@ static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv,
4963 +
4964 + memset(priv->aes_key.key_param_set.key, 0,
4965 + sizeof(key->key_param_set.key));
4966 +- priv->aes_key.key_param_set.key_len = key->key_param_set.key_len;
4967 +- memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key,
4968 +- le16_to_cpu(priv->aes_key.key_param_set.key_len));
4969 ++ priv->aes_key.key_param_set.key_len = cpu_to_le16(len);
4970 ++ memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key, len);
4971 +
4972 + return 0;
4973 + }
4974 +@@ -610,9 +614,14 @@ static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv,
4975 + struct host_cmd_ds_command *resp)
4976 + {
4977 + struct host_cmd_ds_802_11_key_material_v2 *key_v2;
4978 +- __le16 len;
4979 ++ int len;
4980 +
4981 + key_v2 = &resp->params.key_material_v2;
4982 ++
4983 ++ len = le16_to_cpu(key_v2->key_param_set.key_params.aes.key_len);
4984 ++ if (len > WLAN_KEY_LEN_CCMP)
4985 ++ return -EINVAL;
4986 ++
4987 + if (le16_to_cpu(key_v2->action) == HostCmd_ACT_GEN_SET) {
4988 + if ((le16_to_cpu(key_v2->key_param_set.key_info) & KEY_MCAST)) {
4989 + mwifiex_dbg(priv->adapter, INFO, "info: key: GTK is set\n");
4990 +@@ -628,10 +637,9 @@ static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv,
4991 + memset(priv->aes_key_v2.key_param_set.key_params.aes.key, 0,
4992 + WLAN_KEY_LEN_CCMP);
4993 + priv->aes_key_v2.key_param_set.key_params.aes.key_len =
4994 +- key_v2->key_param_set.key_params.aes.key_len;
4995 +- len = priv->aes_key_v2.key_param_set.key_params.aes.key_len;
4996 ++ cpu_to_le16(len);
4997 + memcpy(priv->aes_key_v2.key_param_set.key_params.aes.key,
4998 +- key_v2->key_param_set.key_params.aes.key, le16_to_cpu(len));
4999 ++ key_v2->key_param_set.key_params.aes.key, len);
5000 +
5001 + return 0;
5002 + }
5003 +diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
5004 +index 842cd81704db..b6867d93c0e3 100644
5005 +--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
5006 ++++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
5007 +@@ -119,8 +119,10 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd,
5008 + struct mt7615_mcu_rxd *rxd = (struct mt7615_mcu_rxd *)skb->data;
5009 + int ret = 0;
5010 +
5011 +- if (seq != rxd->seq)
5012 +- return -EAGAIN;
5013 ++ if (seq != rxd->seq) {
5014 ++ ret = -EAGAIN;
5015 ++ goto out;
5016 ++ }
5017 +
5018 + switch (cmd) {
5019 + case -MCU_CMD_PATCH_SEM_CONTROL:
5020 +@@ -134,6 +136,7 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd,
5021 + default:
5022 + break;
5023 + }
5024 ++out:
5025 + dev_kfree_skb(skb);
5026 +
5027 + return ret;
5028 +diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c
5029 +index 3e95ad198912..853ac1c2ed73 100644
5030 +--- a/drivers/net/wireless/realtek/rtw88/coex.c
5031 ++++ b/drivers/net/wireless/realtek/rtw88/coex.c
5032 +@@ -1923,7 +1923,8 @@ static void rtw_coex_run_coex(struct rtw_dev *rtwdev, u8 reason)
5033 + if (coex_stat->wl_under_ips)
5034 + return;
5035 +
5036 +- if (coex->freeze && !coex_stat->bt_setup_link)
5037 ++ if (coex->freeze && coex_dm->reason == COEX_RSN_BTINFO &&
5038 ++ !coex_stat->bt_setup_link)
5039 + return;
5040 +
5041 + coex_stat->cnt_wl[COEX_CNT_WL_COEXRUN]++;
5042 +diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
5043 +index 35dbdb3c4f1e..8efaee7571f3 100644
5044 +--- a/drivers/net/wireless/realtek/rtw88/fw.c
5045 ++++ b/drivers/net/wireless/realtek/rtw88/fw.c
5046 +@@ -340,7 +340,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si)
5047 + SET_RA_INFO_INIT_RA_LVL(h2c_pkt, si->init_ra_lv);
5048 + SET_RA_INFO_SGI_EN(h2c_pkt, si->sgi_enable);
5049 + SET_RA_INFO_BW_MODE(h2c_pkt, si->bw_mode);
5050 +- SET_RA_INFO_LDPC(h2c_pkt, si->ldpc_en);
5051 ++ SET_RA_INFO_LDPC(h2c_pkt, !!si->ldpc_en);
5052 + SET_RA_INFO_NO_UPDATE(h2c_pkt, no_update);
5053 + SET_RA_INFO_VHT_EN(h2c_pkt, si->vht_enable);
5054 + SET_RA_INFO_DIS_PT(h2c_pkt, disable_pt);
5055 +diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
5056 +index 88e2252bf8a2..15c7a6fc37b9 100644
5057 +--- a/drivers/net/wireless/realtek/rtw88/main.c
5058 ++++ b/drivers/net/wireless/realtek/rtw88/main.c
5059 +@@ -553,8 +553,6 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si)
5060 + stbc_en = VHT_STBC_EN;
5061 + if (sta->vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC)
5062 + ldpc_en = VHT_LDPC_EN;
5063 +- if (sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80)
5064 +- is_support_sgi = true;
5065 + } else if (sta->ht_cap.ht_supported) {
5066 + ra_mask |= (sta->ht_cap.mcs.rx_mask[1] << 20) |
5067 + (sta->ht_cap.mcs.rx_mask[0] << 12);
5068 +@@ -562,9 +560,6 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si)
5069 + stbc_en = HT_STBC_EN;
5070 + if (sta->ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING)
5071 + ldpc_en = HT_LDPC_EN;
5072 +- if (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20 ||
5073 +- sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40)
5074 +- is_support_sgi = true;
5075 + }
5076 +
5077 + if (efuse->hw_cap.nss == 1)
5078 +@@ -606,12 +601,18 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si)
5079 + switch (sta->bandwidth) {
5080 + case IEEE80211_STA_RX_BW_80:
5081 + bw_mode = RTW_CHANNEL_WIDTH_80;
5082 ++ is_support_sgi = sta->vht_cap.vht_supported &&
5083 ++ (sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80);
5084 + break;
5085 + case IEEE80211_STA_RX_BW_40:
5086 + bw_mode = RTW_CHANNEL_WIDTH_40;
5087 ++ is_support_sgi = sta->ht_cap.ht_supported &&
5088 ++ (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40);
5089 + break;
5090 + default:
5091 + bw_mode = RTW_CHANNEL_WIDTH_20;
5092 ++ is_support_sgi = sta->ht_cap.ht_supported &&
5093 ++ (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20);
5094 + break;
5095 + }
5096 +
5097 +diff --git a/drivers/net/wireless/ti/wl1251/event.c b/drivers/net/wireless/ti/wl1251/event.c
5098 +index 850864dbafa1..e6d426edab56 100644
5099 +--- a/drivers/net/wireless/ti/wl1251/event.c
5100 ++++ b/drivers/net/wireless/ti/wl1251/event.c
5101 +@@ -70,7 +70,7 @@ static int wl1251_event_ps_report(struct wl1251 *wl,
5102 + break;
5103 + }
5104 +
5105 +- return 0;
5106 ++ return ret;
5107 + }
5108 +
5109 + static void wl1251_event_mbox_dump(struct event_mailbox *mbox)
5110 +diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
5111 +index 071b63146d4b..ff5681da8780 100644
5112 +--- a/drivers/nvme/host/core.c
5113 ++++ b/drivers/nvme/host/core.c
5114 +@@ -1074,6 +1074,9 @@ static int nvme_identify_ns_descs(struct nvme_ctrl *ctrl, unsigned nsid,
5115 + int pos;
5116 + int len;
5117 +
5118 ++ if (ctrl->quirks & NVME_QUIRK_NO_NS_DESC_LIST)
5119 ++ return 0;
5120 ++
5121 + c.identify.opcode = nvme_admin_identify;
5122 + c.identify.nsid = cpu_to_le32(nsid);
5123 + c.identify.cns = NVME_ID_CNS_NS_DESC_LIST;
5124 +@@ -1087,18 +1090,6 @@ static int nvme_identify_ns_descs(struct nvme_ctrl *ctrl, unsigned nsid,
5125 + if (status) {
5126 + dev_warn(ctrl->device,
5127 + "Identify Descriptors failed (%d)\n", status);
5128 +- /*
5129 +- * Don't treat non-retryable errors as fatal, as we potentially
5130 +- * already have a NGUID or EUI-64. If we failed with DNR set,
5131 +- * we want to silently ignore the error as we can still
5132 +- * identify the device, but if the status has DNR set, we want
5133 +- * to propagate the error back specifically for the disk
5134 +- * revalidation flow to make sure we don't abandon the
5135 +- * device just because of a temporal retry-able error (such
5136 +- * as path of transport errors).
5137 +- */
5138 +- if (status > 0 && (status & NVME_SC_DNR))
5139 +- status = 0;
5140 + goto free_data;
5141 + }
5142 +
5143 +diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
5144 +index 5433aa2f7601..484aad0d0c9c 100644
5145 +--- a/drivers/nvme/host/multipath.c
5146 ++++ b/drivers/nvme/host/multipath.c
5147 +@@ -249,6 +249,12 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
5148 + fallback = ns;
5149 + }
5150 +
5151 ++ /* No optimized path found, re-check the current path */
5152 ++ if (!nvme_path_is_disabled(old) &&
5153 ++ old->ana_state == NVME_ANA_OPTIMIZED) {
5154 ++ found = old;
5155 ++ goto out;
5156 ++ }
5157 + if (!fallback)
5158 + return NULL;
5159 + found = fallback;
5160 +@@ -269,10 +275,13 @@ inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head)
5161 + struct nvme_ns *ns;
5162 +
5163 + ns = srcu_dereference(head->current_path[node], &head->srcu);
5164 +- if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_RR && ns)
5165 +- ns = nvme_round_robin_path(head, node, ns);
5166 +- if (unlikely(!ns || !nvme_path_is_optimized(ns)))
5167 +- ns = __nvme_find_path(head, node);
5168 ++ if (unlikely(!ns))
5169 ++ return __nvme_find_path(head, node);
5170 ++
5171 ++ if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_RR)
5172 ++ return nvme_round_robin_path(head, node, ns);
5173 ++ if (unlikely(!nvme_path_is_optimized(ns)))
5174 ++ return __nvme_find_path(head, node);
5175 + return ns;
5176 + }
5177 +
5178 +diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
5179 +index ed02260862cb..056953bd8bd8 100644
5180 +--- a/drivers/nvme/host/nvme.h
5181 ++++ b/drivers/nvme/host/nvme.h
5182 +@@ -115,6 +115,13 @@ enum nvme_quirks {
5183 + * Prevent tag overlap between queues
5184 + */
5185 + NVME_QUIRK_SHARED_TAGS = (1 << 13),
5186 ++
5187 ++ /*
5188 ++ * The controller doesn't handle the Identify Namespace
5189 ++ * Identification Descriptor list subcommand despite claiming
5190 ++ * NVMe 1.3 compliance.
5191 ++ */
5192 ++ NVME_QUIRK_NO_NS_DESC_LIST = (1 << 15),
5193 + };
5194 +
5195 + /*
5196 +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
5197 +index ee7669f23cff..100da11ce98c 100644
5198 +--- a/drivers/nvme/host/pci.c
5199 ++++ b/drivers/nvme/host/pci.c
5200 +@@ -3117,6 +3117,8 @@ static const struct pci_device_id nvme_id_table[] = {
5201 + { PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */
5202 + .driver_data = NVME_QUIRK_IDENTIFY_CNS |
5203 + NVME_QUIRK_DISABLE_WRITE_ZEROES, },
5204 ++ { PCI_DEVICE(0x126f, 0x2263), /* Silicon Motion unidentified */
5205 ++ .driver_data = NVME_QUIRK_NO_NS_DESC_LIST, },
5206 + { PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */
5207 + .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
5208 + { PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */
5209 +diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
5210 +index cd0d49978190..d0336545e1fe 100644
5211 +--- a/drivers/nvme/host/rdma.c
5212 ++++ b/drivers/nvme/host/rdma.c
5213 +@@ -890,15 +890,20 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
5214 + ret = PTR_ERR(ctrl->ctrl.connect_q);
5215 + goto out_free_tag_set;
5216 + }
5217 +- } else {
5218 +- blk_mq_update_nr_hw_queues(&ctrl->tag_set,
5219 +- ctrl->ctrl.queue_count - 1);
5220 + }
5221 +
5222 + ret = nvme_rdma_start_io_queues(ctrl);
5223 + if (ret)
5224 + goto out_cleanup_connect_q;
5225 +
5226 ++ if (!new) {
5227 ++ nvme_start_queues(&ctrl->ctrl);
5228 ++ nvme_wait_freeze(&ctrl->ctrl);
5229 ++ blk_mq_update_nr_hw_queues(ctrl->ctrl.tagset,
5230 ++ ctrl->ctrl.queue_count - 1);
5231 ++ nvme_unfreeze(&ctrl->ctrl);
5232 ++ }
5233 ++
5234 + return 0;
5235 +
5236 + out_cleanup_connect_q:
5237 +@@ -931,6 +936,7 @@ static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl,
5238 + bool remove)
5239 + {
5240 + if (ctrl->ctrl.queue_count > 1) {
5241 ++ nvme_start_freeze(&ctrl->ctrl);
5242 + nvme_stop_queues(&ctrl->ctrl);
5243 + nvme_rdma_stop_io_queues(ctrl);
5244 + if (ctrl->ctrl.tagset) {
5245 +diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
5246 +index 53e113a18a54..0166ff0e4738 100644
5247 +--- a/drivers/nvme/host/tcp.c
5248 ++++ b/drivers/nvme/host/tcp.c
5249 +@@ -1684,15 +1684,20 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)
5250 + ret = PTR_ERR(ctrl->connect_q);
5251 + goto out_free_tag_set;
5252 + }
5253 +- } else {
5254 +- blk_mq_update_nr_hw_queues(ctrl->tagset,
5255 +- ctrl->queue_count - 1);
5256 + }
5257 +
5258 + ret = nvme_tcp_start_io_queues(ctrl);
5259 + if (ret)
5260 + goto out_cleanup_connect_q;
5261 +
5262 ++ if (!new) {
5263 ++ nvme_start_queues(ctrl);
5264 ++ nvme_wait_freeze(ctrl);
5265 ++ blk_mq_update_nr_hw_queues(ctrl->tagset,
5266 ++ ctrl->queue_count - 1);
5267 ++ nvme_unfreeze(ctrl);
5268 ++ }
5269 ++
5270 + return 0;
5271 +
5272 + out_cleanup_connect_q:
5273 +@@ -1797,6 +1802,7 @@ static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl,
5274 + {
5275 + if (ctrl->queue_count <= 1)
5276 + return;
5277 ++ nvme_start_freeze(ctrl);
5278 + nvme_stop_queues(ctrl);
5279 + nvme_tcp_stop_io_queues(ctrl);
5280 + if (ctrl->tagset) {
5281 +diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
5282 +index de8e4e347249..e410033b6df0 100644
5283 +--- a/drivers/parisc/sba_iommu.c
5284 ++++ b/drivers/parisc/sba_iommu.c
5285 +@@ -1270,7 +1270,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
5286 + ** (one that doesn't overlap memory or LMMIO space) in the
5287 + ** IBASE and IMASK registers.
5288 + */
5289 +- ioc->ibase = READ_REG(ioc->ioc_hpa + IOC_IBASE);
5290 ++ ioc->ibase = READ_REG(ioc->ioc_hpa + IOC_IBASE) & ~0x1fffffULL;
5291 + iova_space_size = ~(READ_REG(ioc->ioc_hpa + IOC_IMASK) & 0xFFFFFFFFUL) + 1;
5292 +
5293 + if ((ioc->ibase < 0xfed00000UL) && ((ioc->ibase + iova_space_size) > 0xfee00000UL)) {
5294 +diff --git a/drivers/pci/access.c b/drivers/pci/access.c
5295 +index 2fccb5762c76..0914ddeae17f 100644
5296 +--- a/drivers/pci/access.c
5297 ++++ b/drivers/pci/access.c
5298 +@@ -204,17 +204,13 @@ EXPORT_SYMBOL(pci_bus_set_ops);
5299 + static DECLARE_WAIT_QUEUE_HEAD(pci_cfg_wait);
5300 +
5301 + static noinline void pci_wait_cfg(struct pci_dev *dev)
5302 ++ __must_hold(&pci_lock)
5303 + {
5304 +- DECLARE_WAITQUEUE(wait, current);
5305 +-
5306 +- __add_wait_queue(&pci_cfg_wait, &wait);
5307 + do {
5308 +- set_current_state(TASK_UNINTERRUPTIBLE);
5309 + raw_spin_unlock_irq(&pci_lock);
5310 +- schedule();
5311 ++ wait_event(pci_cfg_wait, !dev->block_cfg_access);
5312 + raw_spin_lock_irq(&pci_lock);
5313 + } while (dev->block_cfg_access);
5314 +- __remove_wait_queue(&pci_cfg_wait, &wait);
5315 + }
5316 +
5317 + /* Returns 0 on success, negative values indicate error. */
5318 +diff --git a/drivers/pci/controller/pcie-cadence-host.c b/drivers/pci/controller/pcie-cadence-host.c
5319 +index 97e251090b4f..0dfc778f40a7 100644
5320 +--- a/drivers/pci/controller/pcie-cadence-host.c
5321 ++++ b/drivers/pci/controller/pcie-cadence-host.c
5322 +@@ -102,6 +102,7 @@ static int cdns_pcie_host_init_root_port(struct cdns_pcie_rc *rc)
5323 + {
5324 + struct cdns_pcie *pcie = &rc->pcie;
5325 + u32 value, ctrl;
5326 ++ u32 id;
5327 +
5328 + /*
5329 + * Set the root complex BAR configuration register:
5330 +@@ -121,8 +122,12 @@ static int cdns_pcie_host_init_root_port(struct cdns_pcie_rc *rc)
5331 + cdns_pcie_writel(pcie, CDNS_PCIE_LM_RC_BAR_CFG, value);
5332 +
5333 + /* Set root port configuration space */
5334 +- if (rc->vendor_id != 0xffff)
5335 +- cdns_pcie_rp_writew(pcie, PCI_VENDOR_ID, rc->vendor_id);
5336 ++ if (rc->vendor_id != 0xffff) {
5337 ++ id = CDNS_PCIE_LM_ID_VENDOR(rc->vendor_id) |
5338 ++ CDNS_PCIE_LM_ID_SUBSYS(rc->vendor_id);
5339 ++ cdns_pcie_writel(pcie, CDNS_PCIE_LM_ID, id);
5340 ++ }
5341 ++
5342 + if (rc->device_id != 0xffff)
5343 + cdns_pcie_rp_writew(pcie, PCI_DEVICE_ID, rc->device_id);
5344 +
5345 +diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
5346 +index 7c24c0aedad4..9966dcf1d112 100644
5347 +--- a/drivers/pci/controller/vmd.c
5348 ++++ b/drivers/pci/controller/vmd.c
5349 +@@ -694,6 +694,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
5350 + if (!vmd->bus) {
5351 + pci_free_resource_list(&resources);
5352 + irq_domain_remove(vmd->irq_domain);
5353 ++ irq_domain_free_fwnode(fn);
5354 + return -ENODEV;
5355 + }
5356 +
5357 +@@ -808,6 +809,7 @@ static void vmd_cleanup_srcu(struct vmd_dev *vmd)
5358 + static void vmd_remove(struct pci_dev *dev)
5359 + {
5360 + struct vmd_dev *vmd = pci_get_drvdata(dev);
5361 ++ struct fwnode_handle *fn = vmd->irq_domain->fwnode;
5362 +
5363 + sysfs_remove_link(&vmd->dev->dev.kobj, "domain");
5364 + pci_stop_root_bus(vmd->bus);
5365 +@@ -816,6 +818,7 @@ static void vmd_remove(struct pci_dev *dev)
5366 + vmd_teardown_dma_ops(vmd);
5367 + vmd_detach_resources(vmd);
5368 + irq_domain_remove(vmd->irq_domain);
5369 ++ irq_domain_free_fwnode(fn);
5370 + }
5371 +
5372 + #ifdef CONFIG_PM_SLEEP
5373 +diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
5374 +index 4a0ec34062d6..7624c71011c6 100644
5375 +--- a/drivers/pci/pcie/aspm.c
5376 ++++ b/drivers/pci/pcie/aspm.c
5377 +@@ -1157,6 +1157,7 @@ static int pcie_aspm_get_policy(char *buffer, const struct kernel_param *kp)
5378 + cnt += sprintf(buffer + cnt, "[%s] ", policy_str[i]);
5379 + else
5380 + cnt += sprintf(buffer + cnt, "%s ", policy_str[i]);
5381 ++ cnt += sprintf(buffer + cnt, "\n");
5382 + return cnt;
5383 + }
5384 +
5385 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
5386 +index 4ac4b28e0ebb..9bc0f321aaf0 100644
5387 +--- a/drivers/pci/quirks.c
5388 ++++ b/drivers/pci/quirks.c
5389 +@@ -4446,6 +4446,8 @@ static int pci_quirk_amd_sb_acs(struct pci_dev *dev, u16 acs_flags)
5390 + if (ACPI_FAILURE(status))
5391 + return -ENODEV;
5392 +
5393 ++ acpi_put_table(header);
5394 ++
5395 + /* Filter out flags not applicable to multifunction */
5396 + acs_flags &= (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC | PCI_ACS_DT);
5397 +
5398 +diff --git a/drivers/phy/marvell/phy-armada38x-comphy.c b/drivers/phy/marvell/phy-armada38x-comphy.c
5399 +index 6960dfd8ad8c..0fe408964334 100644
5400 +--- a/drivers/phy/marvell/phy-armada38x-comphy.c
5401 ++++ b/drivers/phy/marvell/phy-armada38x-comphy.c
5402 +@@ -41,6 +41,7 @@ struct a38x_comphy_lane {
5403 +
5404 + struct a38x_comphy {
5405 + void __iomem *base;
5406 ++ void __iomem *conf;
5407 + struct device *dev;
5408 + struct a38x_comphy_lane lane[MAX_A38X_COMPHY];
5409 + };
5410 +@@ -54,6 +55,21 @@ static const u8 gbe_mux[MAX_A38X_COMPHY][MAX_A38X_PORTS] = {
5411 + { 0, 0, 3 },
5412 + };
5413 +
5414 ++static void a38x_set_conf(struct a38x_comphy_lane *lane, bool enable)
5415 ++{
5416 ++ struct a38x_comphy *priv = lane->priv;
5417 ++ u32 conf;
5418 ++
5419 ++ if (priv->conf) {
5420 ++ conf = readl_relaxed(priv->conf);
5421 ++ if (enable)
5422 ++ conf |= BIT(lane->port);
5423 ++ else
5424 ++ conf &= ~BIT(lane->port);
5425 ++ writel(conf, priv->conf);
5426 ++ }
5427 ++}
5428 ++
5429 + static void a38x_comphy_set_reg(struct a38x_comphy_lane *lane,
5430 + unsigned int offset, u32 mask, u32 value)
5431 + {
5432 +@@ -97,6 +113,7 @@ static int a38x_comphy_set_mode(struct phy *phy, enum phy_mode mode, int sub)
5433 + {
5434 + struct a38x_comphy_lane *lane = phy_get_drvdata(phy);
5435 + unsigned int gen;
5436 ++ int ret;
5437 +
5438 + if (mode != PHY_MODE_ETHERNET)
5439 + return -EINVAL;
5440 +@@ -115,13 +132,20 @@ static int a38x_comphy_set_mode(struct phy *phy, enum phy_mode mode, int sub)
5441 + return -EINVAL;
5442 + }
5443 +
5444 ++ a38x_set_conf(lane, false);
5445 ++
5446 + a38x_comphy_set_speed(lane, gen, gen);
5447 +
5448 +- return a38x_comphy_poll(lane, COMPHY_STAT1,
5449 +- COMPHY_STAT1_PLL_RDY_TX |
5450 +- COMPHY_STAT1_PLL_RDY_RX,
5451 +- COMPHY_STAT1_PLL_RDY_TX |
5452 +- COMPHY_STAT1_PLL_RDY_RX);
5453 ++ ret = a38x_comphy_poll(lane, COMPHY_STAT1,
5454 ++ COMPHY_STAT1_PLL_RDY_TX |
5455 ++ COMPHY_STAT1_PLL_RDY_RX,
5456 ++ COMPHY_STAT1_PLL_RDY_TX |
5457 ++ COMPHY_STAT1_PLL_RDY_RX);
5458 ++
5459 ++ if (ret == 0)
5460 ++ a38x_set_conf(lane, true);
5461 ++
5462 ++ return ret;
5463 + }
5464 +
5465 + static const struct phy_ops a38x_comphy_ops = {
5466 +@@ -174,14 +198,21 @@ static int a38x_comphy_probe(struct platform_device *pdev)
5467 + if (!priv)
5468 + return -ENOMEM;
5469 +
5470 +- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
5471 +- base = devm_ioremap_resource(&pdev->dev, res);
5472 ++ base = devm_platform_ioremap_resource(pdev, 0);
5473 + if (IS_ERR(base))
5474 + return PTR_ERR(base);
5475 +
5476 + priv->dev = &pdev->dev;
5477 + priv->base = base;
5478 +
5479 ++ /* Optional */
5480 ++ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "conf");
5481 ++ if (res) {
5482 ++ priv->conf = devm_ioremap_resource(&pdev->dev, res);
5483 ++ if (IS_ERR(priv->conf))
5484 ++ return PTR_ERR(priv->conf);
5485 ++ }
5486 ++
5487 + for_each_available_child_of_node(pdev->dev.of_node, child) {
5488 + struct phy *phy;
5489 + int ret;
5490 +diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
5491 +index bfb22f868857..5087b7c44d55 100644
5492 +--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
5493 ++++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
5494 +@@ -111,6 +111,7 @@ struct rcar_gen3_chan {
5495 + struct work_struct work;
5496 + struct mutex lock; /* protects rphys[...].powered */
5497 + enum usb_dr_mode dr_mode;
5498 ++ int irq;
5499 + bool extcon_host;
5500 + bool is_otg_channel;
5501 + bool uses_otg_pins;
5502 +@@ -389,12 +390,38 @@ static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch)
5503 + rcar_gen3_device_recognition(ch);
5504 + }
5505 +
5506 ++static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
5507 ++{
5508 ++ struct rcar_gen3_chan *ch = _ch;
5509 ++ void __iomem *usb2_base = ch->base;
5510 ++ u32 status = readl(usb2_base + USB2_OBINTSTA);
5511 ++ irqreturn_t ret = IRQ_NONE;
5512 ++
5513 ++ if (status & USB2_OBINT_BITS) {
5514 ++ dev_vdbg(ch->dev, "%s: %08x\n", __func__, status);
5515 ++ writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTSTA);
5516 ++ rcar_gen3_device_recognition(ch);
5517 ++ ret = IRQ_HANDLED;
5518 ++ }
5519 ++
5520 ++ return ret;
5521 ++}
5522 ++
5523 + static int rcar_gen3_phy_usb2_init(struct phy *p)
5524 + {
5525 + struct rcar_gen3_phy *rphy = phy_get_drvdata(p);
5526 + struct rcar_gen3_chan *channel = rphy->ch;
5527 + void __iomem *usb2_base = channel->base;
5528 + u32 val;
5529 ++ int ret;
5530 ++
5531 ++ if (!rcar_gen3_is_any_rphy_initialized(channel) && channel->irq >= 0) {
5532 ++ INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work);
5533 ++ ret = request_irq(channel->irq, rcar_gen3_phy_usb2_irq,
5534 ++ IRQF_SHARED, dev_name(channel->dev), channel);
5535 ++ if (ret < 0)
5536 ++ dev_err(channel->dev, "No irq handler (%d)\n", channel->irq);
5537 ++ }
5538 +
5539 + /* Initialize USB2 part */
5540 + val = readl(usb2_base + USB2_INT_ENABLE);
5541 +@@ -433,6 +460,9 @@ static int rcar_gen3_phy_usb2_exit(struct phy *p)
5542 + val &= ~USB2_INT_ENABLE_UCOM_INTEN;
5543 + writel(val, usb2_base + USB2_INT_ENABLE);
5544 +
5545 ++ if (channel->irq >= 0 && !rcar_gen3_is_any_rphy_initialized(channel))
5546 ++ free_irq(channel->irq, channel);
5547 ++
5548 + return 0;
5549 + }
5550 +
5551 +@@ -503,23 +533,6 @@ static const struct phy_ops rz_g1c_phy_usb2_ops = {
5552 + .owner = THIS_MODULE,
5553 + };
5554 +
5555 +-static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
5556 +-{
5557 +- struct rcar_gen3_chan *ch = _ch;
5558 +- void __iomem *usb2_base = ch->base;
5559 +- u32 status = readl(usb2_base + USB2_OBINTSTA);
5560 +- irqreturn_t ret = IRQ_NONE;
5561 +-
5562 +- if (status & USB2_OBINT_BITS) {
5563 +- dev_vdbg(ch->dev, "%s: %08x\n", __func__, status);
5564 +- writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTSTA);
5565 +- rcar_gen3_device_recognition(ch);
5566 +- ret = IRQ_HANDLED;
5567 +- }
5568 +-
5569 +- return ret;
5570 +-}
5571 +-
5572 + static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = {
5573 + {
5574 + .compatible = "renesas,usb2-phy-r8a77470",
5575 +@@ -598,7 +611,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
5576 + struct phy_provider *provider;
5577 + struct resource *res;
5578 + const struct phy_ops *phy_usb2_ops;
5579 +- int irq, ret = 0, i;
5580 ++ int ret = 0, i;
5581 +
5582 + if (!dev->of_node) {
5583 + dev_err(dev, "This driver needs device tree\n");
5584 +@@ -614,16 +627,8 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
5585 + if (IS_ERR(channel->base))
5586 + return PTR_ERR(channel->base);
5587 +
5588 +- /* call request_irq for OTG */
5589 +- irq = platform_get_irq_optional(pdev, 0);
5590 +- if (irq >= 0) {
5591 +- INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work);
5592 +- irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq,
5593 +- IRQF_SHARED, dev_name(dev), channel);
5594 +- if (irq < 0)
5595 +- dev_err(dev, "No irq handler (%d)\n", irq);
5596 +- }
5597 +-
5598 ++ /* get irq number here and request_irq for OTG in phy_init */
5599 ++ channel->irq = platform_get_irq_optional(pdev, 0);
5600 + channel->dr_mode = rcar_gen3_get_dr_mode(dev->of_node);
5601 + if (channel->dr_mode != USB_DR_MODE_UNKNOWN) {
5602 + int ret;
5603 +diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
5604 +index e510732afb8b..7f6279fb4f8f 100644
5605 +--- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
5606 ++++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
5607 +@@ -714,7 +714,9 @@ static int exynos5_usbdrd_phy_calibrate(struct phy *phy)
5608 + struct phy_usb_instance *inst = phy_get_drvdata(phy);
5609 + struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst);
5610 +
5611 +- return exynos5420_usbdrd_phy_calibrate(phy_drd);
5612 ++ if (inst->phy_cfg->id == EXYNOS5_DRDPHY_UTMI)
5613 ++ return exynos5420_usbdrd_phy_calibrate(phy_drd);
5614 ++ return 0;
5615 + }
5616 +
5617 + static const struct phy_ops exynos5_usbdrd_phy_ops = {
5618 +diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
5619 +index 1e0614daee9b..a9d511982780 100644
5620 +--- a/drivers/pinctrl/pinctrl-single.c
5621 ++++ b/drivers/pinctrl/pinctrl-single.c
5622 +@@ -916,7 +916,7 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np,
5623 +
5624 + /* If pinconf isn't supported, don't parse properties in below. */
5625 + if (!PCS_HAS_PINCONF)
5626 +- return 0;
5627 ++ return -ENOTSUPP;
5628 +
5629 + /* cacluate how much properties are supported in current node */
5630 + for (i = 0; i < ARRAY_SIZE(prop2); i++) {
5631 +@@ -928,7 +928,7 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np,
5632 + nconfs++;
5633 + }
5634 + if (!nconfs)
5635 +- return 0;
5636 ++ return -ENOTSUPP;
5637 +
5638 + func->conf = devm_kcalloc(pcs->dev,
5639 + nconfs, sizeof(struct pcs_conf_vals),
5640 +@@ -1056,9 +1056,12 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
5641 +
5642 + if (PCS_HAS_PINCONF && function) {
5643 + res = pcs_parse_pinconf(pcs, np, function, map);
5644 +- if (res)
5645 ++ if (res == 0)
5646 ++ *num_maps = 2;
5647 ++ else if (res == -ENOTSUPP)
5648 ++ *num_maps = 1;
5649 ++ else
5650 + goto free_pingroups;
5651 +- *num_maps = 2;
5652 + } else {
5653 + *num_maps = 1;
5654 + }
5655 +diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
5656 +index 0d42477946f3..59b78a181723 100644
5657 +--- a/drivers/platform/x86/asus-nb-wmi.c
5658 ++++ b/drivers/platform/x86/asus-nb-wmi.c
5659 +@@ -110,6 +110,16 @@ static struct quirk_entry quirk_asus_forceals = {
5660 + .wmi_force_als_set = true,
5661 + };
5662 +
5663 ++static struct quirk_entry quirk_asus_ga401i = {
5664 ++ .wmi_backlight_power = true,
5665 ++ .wmi_backlight_set_devstate = true,
5666 ++};
5667 ++
5668 ++static struct quirk_entry quirk_asus_ga502i = {
5669 ++ .wmi_backlight_power = true,
5670 ++ .wmi_backlight_set_devstate = true,
5671 ++};
5672 ++
5673 + static int dmi_matched(const struct dmi_system_id *dmi)
5674 + {
5675 + pr_info("Identified laptop model '%s'\n", dmi->ident);
5676 +@@ -411,6 +421,78 @@ static const struct dmi_system_id asus_quirks[] = {
5677 + },
5678 + .driver_data = &quirk_asus_forceals,
5679 + },
5680 ++ {
5681 ++ .callback = dmi_matched,
5682 ++ .ident = "ASUSTeK COMPUTER INC. GA401IH",
5683 ++ .matches = {
5684 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
5685 ++ DMI_MATCH(DMI_PRODUCT_NAME, "GA401IH"),
5686 ++ },
5687 ++ .driver_data = &quirk_asus_ga401i,
5688 ++ },
5689 ++ {
5690 ++ .callback = dmi_matched,
5691 ++ .ident = "ASUSTeK COMPUTER INC. GA401II",
5692 ++ .matches = {
5693 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
5694 ++ DMI_MATCH(DMI_PRODUCT_NAME, "GA401II"),
5695 ++ },
5696 ++ .driver_data = &quirk_asus_ga401i,
5697 ++ },
5698 ++ {
5699 ++ .callback = dmi_matched,
5700 ++ .ident = "ASUSTeK COMPUTER INC. GA401IU",
5701 ++ .matches = {
5702 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
5703 ++ DMI_MATCH(DMI_PRODUCT_NAME, "GA401IU"),
5704 ++ },
5705 ++ .driver_data = &quirk_asus_ga401i,
5706 ++ },
5707 ++ {
5708 ++ .callback = dmi_matched,
5709 ++ .ident = "ASUSTeK COMPUTER INC. GA401IV",
5710 ++ .matches = {
5711 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
5712 ++ DMI_MATCH(DMI_PRODUCT_NAME, "GA401IV"),
5713 ++ },
5714 ++ .driver_data = &quirk_asus_ga401i,
5715 ++ },
5716 ++ {
5717 ++ .callback = dmi_matched,
5718 ++ .ident = "ASUSTeK COMPUTER INC. GA401IVC",
5719 ++ .matches = {
5720 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
5721 ++ DMI_MATCH(DMI_PRODUCT_NAME, "GA401IVC"),
5722 ++ },
5723 ++ .driver_data = &quirk_asus_ga401i,
5724 ++ },
5725 ++ {
5726 ++ .callback = dmi_matched,
5727 ++ .ident = "ASUSTeK COMPUTER INC. GA502II",
5728 ++ .matches = {
5729 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
5730 ++ DMI_MATCH(DMI_PRODUCT_NAME, "GA502II"),
5731 ++ },
5732 ++ .driver_data = &quirk_asus_ga502i,
5733 ++ },
5734 ++ {
5735 ++ .callback = dmi_matched,
5736 ++ .ident = "ASUSTeK COMPUTER INC. GA502IU",
5737 ++ .matches = {
5738 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
5739 ++ DMI_MATCH(DMI_PRODUCT_NAME, "GA502IU"),
5740 ++ },
5741 ++ .driver_data = &quirk_asus_ga502i,
5742 ++ },
5743 ++ {
5744 ++ .callback = dmi_matched,
5745 ++ .ident = "ASUSTeK COMPUTER INC. GA502IV",
5746 ++ .matches = {
5747 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
5748 ++ DMI_MATCH(DMI_PRODUCT_NAME, "GA502IV"),
5749 ++ },
5750 ++ .driver_data = &quirk_asus_ga502i,
5751 ++ },
5752 + {},
5753 + };
5754 +
5755 +diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c
5756 +index 7a506c1d0113..ad1399dcb21f 100644
5757 +--- a/drivers/platform/x86/intel-hid.c
5758 ++++ b/drivers/platform/x86/intel-hid.c
5759 +@@ -570,7 +570,7 @@ check_acpi_dev(acpi_handle handle, u32 lvl, void *context, void **rv)
5760 + return AE_OK;
5761 +
5762 + if (acpi_match_device_ids(dev, ids) == 0)
5763 +- if (acpi_create_platform_device(dev, NULL))
5764 ++ if (!IS_ERR_OR_NULL(acpi_create_platform_device(dev, NULL)))
5765 + dev_info(&dev->dev,
5766 + "intel-hid: created platform device\n");
5767 +
5768 +diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
5769 +index cb2a80fdd8f4..3393ee95077f 100644
5770 +--- a/drivers/platform/x86/intel-vbtn.c
5771 ++++ b/drivers/platform/x86/intel-vbtn.c
5772 +@@ -286,7 +286,7 @@ check_acpi_dev(acpi_handle handle, u32 lvl, void *context, void **rv)
5773 + return AE_OK;
5774 +
5775 + if (acpi_match_device_ids(dev, ids) == 0)
5776 +- if (acpi_create_platform_device(dev, NULL))
5777 ++ if (!IS_ERR_OR_NULL(acpi_create_platform_device(dev, NULL)))
5778 + dev_info(&dev->dev,
5779 + "intel-vbtn: created platform device\n");
5780 +
5781 +diff --git a/drivers/power/supply/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c
5782 +index 5ca047b3f58f..23e7d6447ae9 100644
5783 +--- a/drivers/power/supply/88pm860x_battery.c
5784 ++++ b/drivers/power/supply/88pm860x_battery.c
5785 +@@ -433,7 +433,7 @@ static void pm860x_init_battery(struct pm860x_battery_info *info)
5786 + int ret;
5787 + int data;
5788 + int bat_remove;
5789 +- int soc;
5790 ++ int soc = 0;
5791 +
5792 + /* measure enable on GPADC1 */
5793 + data = MEAS1_GP1;
5794 +@@ -496,7 +496,9 @@ static void pm860x_init_battery(struct pm860x_battery_info *info)
5795 + }
5796 + mutex_unlock(&info->lock);
5797 +
5798 +- calc_soc(info, OCV_MODE_ACTIVE, &soc);
5799 ++ ret = calc_soc(info, OCV_MODE_ACTIVE, &soc);
5800 ++ if (ret < 0)
5801 ++ goto out;
5802 +
5803 + data = pm860x_reg_read(info->i2c, PM8607_POWER_UP_LOG);
5804 + bat_remove = data & BAT_WU_LOG;
5805 +diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
5806 +index 0011bdc15afb..a17aebe0aa7a 100644
5807 +--- a/drivers/regulator/core.c
5808 ++++ b/drivers/regulator/core.c
5809 +@@ -4994,7 +4994,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
5810 + struct regulator_dev *rdev;
5811 + bool dangling_cfg_gpiod = false;
5812 + bool dangling_of_gpiod = false;
5813 +- bool reg_device_fail = false;
5814 + struct device *dev;
5815 + int ret, i;
5816 +
5817 +@@ -5123,10 +5122,12 @@ regulator_register(const struct regulator_desc *regulator_desc,
5818 + }
5819 +
5820 + /* register with sysfs */
5821 ++ device_initialize(&rdev->dev);
5822 + rdev->dev.class = &regulator_class;
5823 + rdev->dev.parent = dev;
5824 + dev_set_name(&rdev->dev, "regulator.%lu",
5825 + (unsigned long) atomic_inc_return(&regulator_no));
5826 ++ dev_set_drvdata(&rdev->dev, rdev);
5827 +
5828 + /* set regulator constraints */
5829 + if (init_data)
5830 +@@ -5177,12 +5178,9 @@ regulator_register(const struct regulator_desc *regulator_desc,
5831 + !rdev->desc->fixed_uV)
5832 + rdev->is_switch = true;
5833 +
5834 +- dev_set_drvdata(&rdev->dev, rdev);
5835 +- ret = device_register(&rdev->dev);
5836 +- if (ret != 0) {
5837 +- reg_device_fail = true;
5838 ++ ret = device_add(&rdev->dev);
5839 ++ if (ret != 0)
5840 + goto unset_supplies;
5841 +- }
5842 +
5843 + rdev_init_debugfs(rdev);
5844 +
5845 +@@ -5204,17 +5202,15 @@ unset_supplies:
5846 + mutex_unlock(&regulator_list_mutex);
5847 + wash:
5848 + kfree(rdev->coupling_desc.coupled_rdevs);
5849 +- kfree(rdev->constraints);
5850 + mutex_lock(&regulator_list_mutex);
5851 + regulator_ena_gpio_free(rdev);
5852 + mutex_unlock(&regulator_list_mutex);
5853 ++ put_device(&rdev->dev);
5854 ++ rdev = NULL;
5855 + clean:
5856 + if (dangling_of_gpiod)
5857 + gpiod_put(config->ena_gpiod);
5858 +- if (reg_device_fail)
5859 +- put_device(&rdev->dev);
5860 +- else
5861 +- kfree(rdev);
5862 ++ kfree(rdev);
5863 + kfree(config);
5864 + rinse:
5865 + if (dangling_cfg_gpiod)
5866 +diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
5867 +index 8d4971645cf1..f7ae03fd36cb 100644
5868 +--- a/drivers/s390/block/dasd_diag.c
5869 ++++ b/drivers/s390/block/dasd_diag.c
5870 +@@ -319,7 +319,7 @@ dasd_diag_check_device(struct dasd_device *device)
5871 + struct dasd_diag_characteristics *rdc_data;
5872 + struct vtoc_cms_label *label;
5873 + struct dasd_block *block;
5874 +- struct dasd_diag_bio bio;
5875 ++ struct dasd_diag_bio *bio;
5876 + unsigned int sb, bsize;
5877 + blocknum_t end_block;
5878 + int rc;
5879 +@@ -395,29 +395,36 @@ dasd_diag_check_device(struct dasd_device *device)
5880 + rc = -ENOMEM;
5881 + goto out;
5882 + }
5883 ++ bio = kzalloc(sizeof(*bio), GFP_KERNEL);
5884 ++ if (bio == NULL) {
5885 ++ DBF_DEV_EVENT(DBF_WARNING, device, "%s",
5886 ++ "No memory to allocate initialization bio");
5887 ++ rc = -ENOMEM;
5888 ++ goto out_label;
5889 ++ }
5890 + rc = 0;
5891 + end_block = 0;
5892 + /* try all sizes - needed for ECKD devices */
5893 + for (bsize = 512; bsize <= PAGE_SIZE; bsize <<= 1) {
5894 + mdsk_init_io(device, bsize, 0, &end_block);
5895 +- memset(&bio, 0, sizeof (struct dasd_diag_bio));
5896 +- bio.type = MDSK_READ_REQ;
5897 +- bio.block_number = private->pt_block + 1;
5898 +- bio.buffer = label;
5899 ++ memset(bio, 0, sizeof(*bio));
5900 ++ bio->type = MDSK_READ_REQ;
5901 ++ bio->block_number = private->pt_block + 1;
5902 ++ bio->buffer = label;
5903 + memset(&private->iob, 0, sizeof (struct dasd_diag_rw_io));
5904 + private->iob.dev_nr = rdc_data->dev_nr;
5905 + private->iob.key = 0;
5906 + private->iob.flags = 0; /* do synchronous io */
5907 + private->iob.block_count = 1;
5908 + private->iob.interrupt_params = 0;
5909 +- private->iob.bio_list = &bio;
5910 ++ private->iob.bio_list = bio;
5911 + private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT;
5912 + rc = dia250(&private->iob, RW_BIO);
5913 + if (rc == 3) {
5914 + pr_warn("%s: A 64-bit DIAG call failed\n",
5915 + dev_name(&device->cdev->dev));
5916 + rc = -EOPNOTSUPP;
5917 +- goto out_label;
5918 ++ goto out_bio;
5919 + }
5920 + mdsk_term_io(device);
5921 + if (rc == 0)
5922 +@@ -427,7 +434,7 @@ dasd_diag_check_device(struct dasd_device *device)
5923 + pr_warn("%s: Accessing the DASD failed because of an incorrect format (rc=%d)\n",
5924 + dev_name(&device->cdev->dev), rc);
5925 + rc = -EIO;
5926 +- goto out_label;
5927 ++ goto out_bio;
5928 + }
5929 + /* check for label block */
5930 + if (memcmp(label->label_id, DASD_DIAG_CMS1,
5931 +@@ -457,6 +464,8 @@ dasd_diag_check_device(struct dasd_device *device)
5932 + (rc == 4) ? ", read-only device" : "");
5933 + rc = 0;
5934 + }
5935 ++out_bio:
5936 ++ kfree(bio);
5937 + out_label:
5938 + free_page((long) label);
5939 + out:
5940 +diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
5941 +index 92bace3b28fd..4ce28aa490cd 100644
5942 +--- a/drivers/s390/net/qeth_l2_main.c
5943 ++++ b/drivers/s390/net/qeth_l2_main.c
5944 +@@ -1199,6 +1199,10 @@ static void qeth_bridge_state_change(struct qeth_card *card,
5945 + int extrasize;
5946 +
5947 + QETH_CARD_TEXT(card, 2, "brstchng");
5948 ++ if (qports->num_entries == 0) {
5949 ++ QETH_CARD_TEXT(card, 2, "BPempty");
5950 ++ return;
5951 ++ }
5952 + if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) {
5953 + QETH_CARD_TEXT_(card, 2, "BPsz%04x", qports->entry_length);
5954 + return;
5955 +diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c
5956 +index a1f3e9ee4e63..14e1d001253c 100644
5957 +--- a/drivers/scsi/arm/cumana_2.c
5958 ++++ b/drivers/scsi/arm/cumana_2.c
5959 +@@ -450,7 +450,7 @@ static int cumanascsi2_probe(struct expansion_card *ec,
5960 +
5961 + if (info->info.scsi.dma != NO_DMA)
5962 + free_dma(info->info.scsi.dma);
5963 +- free_irq(ec->irq, host);
5964 ++ free_irq(ec->irq, info);
5965 +
5966 + out_release:
5967 + fas216_release(host);
5968 +diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c
5969 +index 134f040d58e2..f441ec8eb93d 100644
5970 +--- a/drivers/scsi/arm/eesox.c
5971 ++++ b/drivers/scsi/arm/eesox.c
5972 +@@ -571,7 +571,7 @@ static int eesoxscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
5973 +
5974 + if (info->info.scsi.dma != NO_DMA)
5975 + free_dma(info->info.scsi.dma);
5976 +- free_irq(ec->irq, host);
5977 ++ free_irq(ec->irq, info);
5978 +
5979 + out_remove:
5980 + fas216_remove(host);
5981 +diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c
5982 +index c795537a671c..2dc0df005cb3 100644
5983 +--- a/drivers/scsi/arm/powertec.c
5984 ++++ b/drivers/scsi/arm/powertec.c
5985 +@@ -378,7 +378,7 @@ static int powertecscsi_probe(struct expansion_card *ec,
5986 +
5987 + if (info->info.scsi.dma != NO_DMA)
5988 + free_dma(info->info.scsi.dma);
5989 +- free_irq(ec->irq, host);
5990 ++ free_irq(ec->irq, info);
5991 +
5992 + out_release:
5993 + fas216_release(host);
5994 +diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
5995 +index 0cbe6740e0c9..2c2966a297c7 100644
5996 +--- a/drivers/scsi/megaraid/megaraid_sas_base.c
5997 ++++ b/drivers/scsi/megaraid/megaraid_sas_base.c
5998 +@@ -5586,9 +5586,13 @@ megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe)
5999 + &instance->irq_context[i])) {
6000 + dev_err(&instance->pdev->dev,
6001 + "Failed to register IRQ for vector %d.\n", i);
6002 +- for (j = 0; j < i; j++)
6003 ++ for (j = 0; j < i; j++) {
6004 ++ if (j < instance->low_latency_index_start)
6005 ++ irq_set_affinity_hint(
6006 ++ pci_irq_vector(pdev, j), NULL);
6007 + free_irq(pci_irq_vector(pdev, j),
6008 + &instance->irq_context[j]);
6009 ++ }
6010 + /* Retry irq register for IO_APIC*/
6011 + instance->msix_vectors = 0;
6012 + instance->msix_load_balance = false;
6013 +@@ -5626,6 +5630,9 @@ megasas_destroy_irqs(struct megasas_instance *instance) {
6014 +
6015 + if (instance->msix_vectors)
6016 + for (i = 0; i < instance->msix_vectors; i++) {
6017 ++ if (i < instance->low_latency_index_start)
6018 ++ irq_set_affinity_hint(
6019 ++ pci_irq_vector(instance->pdev, i), NULL);
6020 + free_irq(pci_irq_vector(instance->pdev, i),
6021 + &instance->irq_context[i]);
6022 + }
6023 +diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
6024 +index 74fb50644678..4dd50db90677 100644
6025 +--- a/drivers/scsi/mesh.c
6026 ++++ b/drivers/scsi/mesh.c
6027 +@@ -1045,6 +1045,8 @@ static void handle_error(struct mesh_state *ms)
6028 + while ((in_8(&mr->bus_status1) & BS1_RST) != 0)
6029 + udelay(1);
6030 + printk("done\n");
6031 ++ if (ms->dma_started)
6032 ++ halt_dma(ms);
6033 + handle_reset(ms);
6034 + /* request_q is empty, no point in mesh_start() */
6035 + return;
6036 +@@ -1357,7 +1359,8 @@ static void halt_dma(struct mesh_state *ms)
6037 + ms->conn_tgt, ms->data_ptr, scsi_bufflen(cmd),
6038 + ms->tgts[ms->conn_tgt].data_goes_out);
6039 + }
6040 +- scsi_dma_unmap(cmd);
6041 ++ if (cmd)
6042 ++ scsi_dma_unmap(cmd);
6043 + ms->dma_started = 0;
6044 + }
6045 +
6046 +@@ -1712,6 +1715,9 @@ static int mesh_host_reset(struct scsi_cmnd *cmd)
6047 +
6048 + spin_lock_irqsave(ms->host->host_lock, flags);
6049 +
6050 ++ if (ms->dma_started)
6051 ++ halt_dma(ms);
6052 ++
6053 + /* Reset the controller & dbdma channel */
6054 + out_le32(&md->control, (RUN|PAUSE|FLUSH|WAKE) << 16); /* stop dma */
6055 + out_8(&mr->exception, 0xff); /* clear all exception bits */
6056 +diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
6057 +index 32965ec76965..44181a2cbf18 100644
6058 +--- a/drivers/scsi/scsi_debug.c
6059 ++++ b/drivers/scsi/scsi_debug.c
6060 +@@ -5296,6 +5296,12 @@ static int __init scsi_debug_init(void)
6061 + pr_err("submit_queues must be 1 or more\n");
6062 + return -EINVAL;
6063 + }
6064 ++
6065 ++ if ((sdebug_max_queue > SDEBUG_CANQUEUE) || (sdebug_max_queue < 1)) {
6066 ++ pr_err("max_queue must be in range [1, %d]\n", SDEBUG_CANQUEUE);
6067 ++ return -EINVAL;
6068 ++ }
6069 ++
6070 + sdebug_q_arr = kcalloc(submit_queues, sizeof(struct sdebug_queue),
6071 + GFP_KERNEL);
6072 + if (sdebug_q_arr == NULL)
6073 +diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
6074 +index 0ba1f465db12..8924fcd9f5f5 100644
6075 +--- a/drivers/soc/qcom/rpmh-rsc.c
6076 ++++ b/drivers/soc/qcom/rpmh-rsc.c
6077 +@@ -715,6 +715,7 @@ static struct platform_driver rpmh_driver = {
6078 + .driver = {
6079 + .name = "rpmh",
6080 + .of_match_table = rpmh_drv_match,
6081 ++ .suppress_bind_attrs = true,
6082 + },
6083 + };
6084 +
6085 +diff --git a/drivers/spi/spi-lantiq-ssc.c b/drivers/spi/spi-lantiq-ssc.c
6086 +index 9dfe8b04e688..f9bc1705c0d4 100644
6087 +--- a/drivers/spi/spi-lantiq-ssc.c
6088 ++++ b/drivers/spi/spi-lantiq-ssc.c
6089 +@@ -184,6 +184,7 @@ struct lantiq_ssc_spi {
6090 + unsigned int tx_fifo_size;
6091 + unsigned int rx_fifo_size;
6092 + unsigned int base_cs;
6093 ++ unsigned int fdx_tx_level;
6094 + };
6095 +
6096 + static u32 lantiq_ssc_readl(const struct lantiq_ssc_spi *spi, u32 reg)
6097 +@@ -481,6 +482,7 @@ static void tx_fifo_write(struct lantiq_ssc_spi *spi)
6098 + u32 data;
6099 + unsigned int tx_free = tx_fifo_free(spi);
6100 +
6101 ++ spi->fdx_tx_level = 0;
6102 + while (spi->tx_todo && tx_free) {
6103 + switch (spi->bits_per_word) {
6104 + case 2 ... 8:
6105 +@@ -509,6 +511,7 @@ static void tx_fifo_write(struct lantiq_ssc_spi *spi)
6106 +
6107 + lantiq_ssc_writel(spi, data, LTQ_SPI_TB);
6108 + tx_free--;
6109 ++ spi->fdx_tx_level++;
6110 + }
6111 + }
6112 +
6113 +@@ -520,6 +523,13 @@ static void rx_fifo_read_full_duplex(struct lantiq_ssc_spi *spi)
6114 + u32 data;
6115 + unsigned int rx_fill = rx_fifo_level(spi);
6116 +
6117 ++ /*
6118 ++ * Wait until all expected data to be shifted in.
6119 ++ * Otherwise, rx overrun may occur.
6120 ++ */
6121 ++ while (rx_fill != spi->fdx_tx_level)
6122 ++ rx_fill = rx_fifo_level(spi);
6123 ++
6124 + while (rx_fill) {
6125 + data = lantiq_ssc_readl(spi, LTQ_SPI_RB);
6126 +
6127 +@@ -907,7 +917,7 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
6128 + master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 8) |
6129 + SPI_BPW_MASK(16) | SPI_BPW_MASK(32);
6130 +
6131 +- spi->wq = alloc_ordered_workqueue(dev_name(dev), 0);
6132 ++ spi->wq = alloc_ordered_workqueue(dev_name(dev), WQ_MEM_RECLAIM);
6133 + if (!spi->wq) {
6134 + err = -ENOMEM;
6135 + goto err_clk_put;
6136 +diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
6137 +index 2cc6d9951b52..008b64f4e031 100644
6138 +--- a/drivers/spi/spi-rockchip.c
6139 ++++ b/drivers/spi/spi-rockchip.c
6140 +@@ -286,7 +286,7 @@ static void rockchip_spi_pio_writer(struct rockchip_spi *rs)
6141 + static void rockchip_spi_pio_reader(struct rockchip_spi *rs)
6142 + {
6143 + u32 words = readl_relaxed(rs->regs + ROCKCHIP_SPI_RXFLR);
6144 +- u32 rx_left = rs->rx_left - words;
6145 ++ u32 rx_left = (rs->rx_left > words) ? rs->rx_left - words : 0;
6146 +
6147 + /* the hardware doesn't allow us to change fifo threshold
6148 + * level while spi is enabled, so instead make sure to leave
6149 +diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
6150 +index ac6bf1fbbfe6..be503a0e6ef7 100644
6151 +--- a/drivers/spi/spidev.c
6152 ++++ b/drivers/spi/spidev.c
6153 +@@ -223,6 +223,11 @@ static int spidev_message(struct spidev_data *spidev,
6154 + for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers;
6155 + n;
6156 + n--, k_tmp++, u_tmp++) {
6157 ++ /* Ensure that also following allocations from rx_buf/tx_buf will meet
6158 ++ * DMA alignment requirements.
6159 ++ */
6160 ++ unsigned int len_aligned = ALIGN(u_tmp->len, ARCH_KMALLOC_MINALIGN);
6161 ++
6162 + k_tmp->len = u_tmp->len;
6163 +
6164 + total += k_tmp->len;
6165 +@@ -238,17 +243,17 @@ static int spidev_message(struct spidev_data *spidev,
6166 +
6167 + if (u_tmp->rx_buf) {
6168 + /* this transfer needs space in RX bounce buffer */
6169 +- rx_total += k_tmp->len;
6170 ++ rx_total += len_aligned;
6171 + if (rx_total > bufsiz) {
6172 + status = -EMSGSIZE;
6173 + goto done;
6174 + }
6175 + k_tmp->rx_buf = rx_buf;
6176 +- rx_buf += k_tmp->len;
6177 ++ rx_buf += len_aligned;
6178 + }
6179 + if (u_tmp->tx_buf) {
6180 + /* this transfer needs space in TX bounce buffer */
6181 +- tx_total += k_tmp->len;
6182 ++ tx_total += len_aligned;
6183 + if (tx_total > bufsiz) {
6184 + status = -EMSGSIZE;
6185 + goto done;
6186 +@@ -258,7 +263,7 @@ static int spidev_message(struct spidev_data *spidev,
6187 + (uintptr_t) u_tmp->tx_buf,
6188 + u_tmp->len))
6189 + goto done;
6190 +- tx_buf += k_tmp->len;
6191 ++ tx_buf += len_aligned;
6192 + }
6193 +
6194 + k_tmp->cs_change = !!u_tmp->cs_change;
6195 +@@ -290,16 +295,16 @@ static int spidev_message(struct spidev_data *spidev,
6196 + goto done;
6197 +
6198 + /* copy any rx data out of bounce buffer */
6199 +- rx_buf = spidev->rx_buffer;
6200 +- for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) {
6201 ++ for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers;
6202 ++ n;
6203 ++ n--, k_tmp++, u_tmp++) {
6204 + if (u_tmp->rx_buf) {
6205 + if (copy_to_user((u8 __user *)
6206 +- (uintptr_t) u_tmp->rx_buf, rx_buf,
6207 ++ (uintptr_t) u_tmp->rx_buf, k_tmp->rx_buf,
6208 + u_tmp->len)) {
6209 + status = -EFAULT;
6210 + goto done;
6211 + }
6212 +- rx_buf += u_tmp->len;
6213 + }
6214 + }
6215 + status = total;
6216 +diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
6217 +index 511136dce3a4..ddc09616248a 100644
6218 +--- a/drivers/staging/rtl8192u/r8192U_core.c
6219 ++++ b/drivers/staging/rtl8192u/r8192U_core.c
6220 +@@ -2401,7 +2401,7 @@ static int rtl8192_read_eeprom_info(struct net_device *dev)
6221 + ret = eprom_read(dev, (EEPROM_TX_PW_INDEX_CCK >> 1));
6222 + if (ret < 0)
6223 + return ret;
6224 +- priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff) >> 8;
6225 ++ priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff00) >> 8;
6226 + } else
6227 + priv->EEPROMTxPowerLevelCCK = 0x10;
6228 + RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK);
6229 +diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
6230 +index af6bf0736b52..eb76cc2cbfd8 100644
6231 +--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
6232 ++++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
6233 +@@ -3257,6 +3257,7 @@ failed_platform_init:
6234 +
6235 + static int vchiq_remove(struct platform_device *pdev)
6236 + {
6237 ++ platform_device_unregister(bcm2835_audio);
6238 + platform_device_unregister(bcm2835_camera);
6239 + vchiq_debugfs_deinit();
6240 + device_destroy(vchiq_class, vchiq_devid);
6241 +diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
6242 +index 85776db4bf34..2ce4b19f312a 100644
6243 +--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
6244 ++++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
6245 +@@ -169,7 +169,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
6246 +
6247 + data = ti_bandgap_get_sensor_data(bgp, id);
6248 +
6249 +- if (!IS_ERR_OR_NULL(data))
6250 ++ if (IS_ERR_OR_NULL(data))
6251 + data = ti_thermal_build_data(bgp, id);
6252 +
6253 + if (!data)
6254 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
6255 +index e0b77674869c..c96c50faccf7 100644
6256 +--- a/drivers/usb/core/quirks.c
6257 ++++ b/drivers/usb/core/quirks.c
6258 +@@ -25,17 +25,23 @@ static unsigned int quirk_count;
6259 +
6260 + static char quirks_param[128];
6261 +
6262 +-static int quirks_param_set(const char *val, const struct kernel_param *kp)
6263 ++static int quirks_param_set(const char *value, const struct kernel_param *kp)
6264 + {
6265 +- char *p, *field;
6266 ++ char *val, *p, *field;
6267 + u16 vid, pid;
6268 + u32 flags;
6269 + size_t i;
6270 + int err;
6271 +
6272 ++ val = kstrdup(value, GFP_KERNEL);
6273 ++ if (!val)
6274 ++ return -ENOMEM;
6275 ++
6276 + err = param_set_copystring(val, kp);
6277 +- if (err)
6278 ++ if (err) {
6279 ++ kfree(val);
6280 + return err;
6281 ++ }
6282 +
6283 + mutex_lock(&quirk_mutex);
6284 +
6285 +@@ -60,10 +66,11 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
6286 + if (!quirk_list) {
6287 + quirk_count = 0;
6288 + mutex_unlock(&quirk_mutex);
6289 ++ kfree(val);
6290 + return -ENOMEM;
6291 + }
6292 +
6293 +- for (i = 0, p = (char *)val; p && *p;) {
6294 ++ for (i = 0, p = val; p && *p;) {
6295 + /* Each entry consists of VID:PID:flags */
6296 + field = strsep(&p, ":");
6297 + if (!field)
6298 +@@ -144,6 +151,7 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
6299 +
6300 + unlock:
6301 + mutex_unlock(&quirk_mutex);
6302 ++ kfree(val);
6303 +
6304 + return 0;
6305 + }
6306 +diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
6307 +index 4e14c4f7fed7..34bb6124f1e2 100644
6308 +--- a/drivers/usb/dwc2/platform.c
6309 ++++ b/drivers/usb/dwc2/platform.c
6310 +@@ -514,6 +514,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
6311 + if (hsotg->gadget_enabled) {
6312 + retval = usb_add_gadget_udc(hsotg->dev, &hsotg->gadget);
6313 + if (retval) {
6314 ++ hsotg->gadget.udc = NULL;
6315 + dwc2_hsotg_remove(hsotg);
6316 + goto error;
6317 + }
6318 +@@ -522,7 +523,8 @@ static int dwc2_driver_probe(struct platform_device *dev)
6319 + return 0;
6320 +
6321 + error:
6322 +- dwc2_lowlevel_hw_disable(hsotg);
6323 ++ if (hsotg->dr_mode != USB_DR_MODE_PERIPHERAL)
6324 ++ dwc2_lowlevel_hw_disable(hsotg);
6325 + return retval;
6326 + }
6327 +
6328 +diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
6329 +index db2d4980cb35..3633df6d7610 100644
6330 +--- a/drivers/usb/gadget/function/f_uac2.c
6331 ++++ b/drivers/usb/gadget/function/f_uac2.c
6332 +@@ -215,10 +215,7 @@ static struct uac2_ac_header_descriptor ac_hdr_desc = {
6333 + .bDescriptorSubtype = UAC_MS_HEADER,
6334 + .bcdADC = cpu_to_le16(0x200),
6335 + .bCategory = UAC2_FUNCTION_IO_BOX,
6336 +- .wTotalLength = cpu_to_le16(sizeof in_clk_src_desc
6337 +- + sizeof out_clk_src_desc + sizeof usb_out_it_desc
6338 +- + sizeof io_in_it_desc + sizeof usb_in_ot_desc
6339 +- + sizeof io_out_ot_desc),
6340 ++ /* .wTotalLength = DYNAMIC */
6341 + .bmControls = 0,
6342 + };
6343 +
6344 +@@ -501,7 +498,7 @@ static void setup_descriptor(struct f_uac2_opts *opts)
6345 + as_in_hdr_desc.bTerminalLink = usb_in_ot_desc.bTerminalID;
6346 +
6347 + iad_desc.bInterfaceCount = 1;
6348 +- ac_hdr_desc.wTotalLength = 0;
6349 ++ ac_hdr_desc.wTotalLength = cpu_to_le16(sizeof(ac_hdr_desc));
6350 +
6351 + if (EPIN_EN(opts)) {
6352 + u16 len = le16_to_cpu(ac_hdr_desc.wTotalLength);
6353 +diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
6354 +index cc4a16e253ac..3d33499db50b 100644
6355 +--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
6356 ++++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
6357 +@@ -282,6 +282,7 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit)
6358 + * in that case reinit is passed as 1
6359 + */
6360 + if (reinit) {
6361 ++ int i;
6362 + /* Enable interrupts */
6363 + temp = bdc_readl(bdc->regs, BDC_BDCSC);
6364 + temp |= BDC_GIE;
6365 +@@ -291,6 +292,9 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit)
6366 + /* Initialize SRR to 0 */
6367 + memset(bdc->srr.sr_bds, 0,
6368 + NUM_SR_ENTRIES * sizeof(struct bdc_bd));
6369 ++ /* clear ep flags to avoid post disconnect stops/deconfigs */
6370 ++ for (i = 1; i < bdc->num_eps; ++i)
6371 ++ bdc->bdc_ep_array[i]->flags = 0;
6372 + } else {
6373 + /* One time initiaization only */
6374 + /* Enable status report function pointers */
6375 +@@ -601,9 +605,14 @@ static int bdc_remove(struct platform_device *pdev)
6376 + static int bdc_suspend(struct device *dev)
6377 + {
6378 + struct bdc *bdc = dev_get_drvdata(dev);
6379 ++ int ret;
6380 +
6381 +- clk_disable_unprepare(bdc->clk);
6382 +- return 0;
6383 ++ /* Halt the controller */
6384 ++ ret = bdc_stop(bdc);
6385 ++ if (!ret)
6386 ++ clk_disable_unprepare(bdc->clk);
6387 ++
6388 ++ return ret;
6389 + }
6390 +
6391 + static int bdc_resume(struct device *dev)
6392 +diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c
6393 +index d49c6dc1082d..9ddc0b4e92c9 100644
6394 +--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
6395 ++++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
6396 +@@ -615,7 +615,6 @@ int bdc_ep_enable(struct bdc_ep *ep)
6397 + }
6398 + bdc_dbg_bd_list(bdc, ep);
6399 + /* only for ep0: config ep is called for ep0 from connect event */
6400 +- ep->flags |= BDC_EP_ENABLED;
6401 + if (ep->ep_num == 1)
6402 + return ret;
6403 +
6404 +@@ -759,10 +758,13 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req *req)
6405 + __func__, ep->name, start_bdi, end_bdi);
6406 + dev_dbg(bdc->dev, "ep_dequeue ep=%p ep->desc=%p\n",
6407 + ep, (void *)ep->usb_ep.desc);
6408 +- /* Stop the ep to see where the HW is ? */
6409 +- ret = bdc_stop_ep(bdc, ep->ep_num);
6410 +- /* if there is an issue with stopping ep, then no need to go further */
6411 +- if (ret)
6412 ++ /* if still connected, stop the ep to see where the HW is ? */
6413 ++ if (!(bdc_readl(bdc->regs, BDC_USPC) & BDC_PST_MASK)) {
6414 ++ ret = bdc_stop_ep(bdc, ep->ep_num);
6415 ++ /* if there is an issue, then no need to go further */
6416 ++ if (ret)
6417 ++ return 0;
6418 ++ } else
6419 + return 0;
6420 +
6421 + /*
6422 +@@ -1911,7 +1913,9 @@ static int bdc_gadget_ep_disable(struct usb_ep *_ep)
6423 + __func__, ep->name, ep->flags);
6424 +
6425 + if (!(ep->flags & BDC_EP_ENABLED)) {
6426 +- dev_warn(bdc->dev, "%s is already disabled\n", ep->name);
6427 ++ if (bdc->gadget.speed != USB_SPEED_UNKNOWN)
6428 ++ dev_warn(bdc->dev, "%s is already disabled\n",
6429 ++ ep->name);
6430 + return 0;
6431 + }
6432 + spin_lock_irqsave(&bdc->lock, flags);
6433 +diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
6434 +index 51efee21915f..7c616d7641c6 100644
6435 +--- a/drivers/usb/gadget/udc/net2280.c
6436 ++++ b/drivers/usb/gadget/udc/net2280.c
6437 +@@ -3782,8 +3782,10 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
6438 + return 0;
6439 +
6440 + done:
6441 +- if (dev)
6442 ++ if (dev) {
6443 + net2280_remove(pdev);
6444 ++ kfree(dev);
6445 ++ }
6446 + return retval;
6447 + }
6448 +
6449 +diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
6450 +index 9dd02160cca9..e3780d4d6514 100644
6451 +--- a/drivers/usb/mtu3/mtu3_core.c
6452 ++++ b/drivers/usb/mtu3/mtu3_core.c
6453 +@@ -131,8 +131,12 @@ static void mtu3_device_disable(struct mtu3 *mtu)
6454 + mtu3_setbits(ibase, SSUSB_U2_CTRL(0),
6455 + SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN);
6456 +
6457 +- if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG)
6458 ++ if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG) {
6459 + mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
6460 ++ if (mtu->is_u3_ip)
6461 ++ mtu3_clrbits(ibase, SSUSB_U3_CTRL(0),
6462 ++ SSUSB_U3_PORT_DUAL_MODE);
6463 ++ }
6464 +
6465 + mtu3_setbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
6466 + }
6467 +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
6468 +index f5143eedbc48..a90801ef0055 100644
6469 +--- a/drivers/usb/serial/cp210x.c
6470 ++++ b/drivers/usb/serial/cp210x.c
6471 +@@ -272,6 +272,8 @@ static struct usb_serial_driver cp210x_device = {
6472 + .break_ctl = cp210x_break_ctl,
6473 + .set_termios = cp210x_set_termios,
6474 + .tx_empty = cp210x_tx_empty,
6475 ++ .throttle = usb_serial_generic_throttle,
6476 ++ .unthrottle = usb_serial_generic_unthrottle,
6477 + .tiocmget = cp210x_tiocmget,
6478 + .tiocmset = cp210x_tiocmset,
6479 + .attach = cp210x_attach,
6480 +@@ -915,6 +917,7 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
6481 + u32 baud;
6482 + u16 bits;
6483 + u32 ctl_hs;
6484 ++ u32 flow_repl;
6485 +
6486 + cp210x_read_u32_reg(port, CP210X_GET_BAUDRATE, &baud);
6487 +
6488 +@@ -1015,6 +1018,22 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
6489 + ctl_hs = le32_to_cpu(flow_ctl.ulControlHandshake);
6490 + if (ctl_hs & CP210X_SERIAL_CTS_HANDSHAKE) {
6491 + dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
6492 ++ /*
6493 ++ * When the port is closed, the CP210x hardware disables
6494 ++ * auto-RTS and RTS is deasserted but it leaves auto-CTS when
6495 ++ * in hardware flow control mode. When re-opening the port, if
6496 ++ * auto-CTS is enabled on the cp210x, then auto-RTS must be
6497 ++ * re-enabled in the driver.
6498 ++ */
6499 ++ flow_repl = le32_to_cpu(flow_ctl.ulFlowReplace);
6500 ++ flow_repl &= ~CP210X_SERIAL_RTS_MASK;
6501 ++ flow_repl |= CP210X_SERIAL_RTS_SHIFT(CP210X_SERIAL_RTS_FLOW_CTL);
6502 ++ flow_ctl.ulFlowReplace = cpu_to_le32(flow_repl);
6503 ++ cp210x_write_reg_block(port,
6504 ++ CP210X_SET_FLOW,
6505 ++ &flow_ctl,
6506 ++ sizeof(flow_ctl));
6507 ++
6508 + cflag |= CRTSCTS;
6509 + } else {
6510 + dev_dbg(dev, "%s - flow control = NONE\n", __func__);
6511 +diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
6512 +index b8dfeb4fb2ed..ffbb2a8901b2 100644
6513 +--- a/drivers/usb/serial/iuu_phoenix.c
6514 ++++ b/drivers/usb/serial/iuu_phoenix.c
6515 +@@ -353,10 +353,11 @@ static void iuu_led_activity_on(struct urb *urb)
6516 + struct usb_serial_port *port = urb->context;
6517 + int result;
6518 + char *buf_ptr = port->write_urb->transfer_buffer;
6519 +- *buf_ptr++ = IUU_SET_LED;
6520 ++
6521 + if (xmas) {
6522 +- get_random_bytes(buf_ptr, 6);
6523 +- *(buf_ptr+7) = 1;
6524 ++ buf_ptr[0] = IUU_SET_LED;
6525 ++ get_random_bytes(buf_ptr + 1, 6);
6526 ++ buf_ptr[7] = 1;
6527 + } else {
6528 + iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255);
6529 + }
6530 +@@ -374,13 +375,14 @@ static void iuu_led_activity_off(struct urb *urb)
6531 + struct usb_serial_port *port = urb->context;
6532 + int result;
6533 + char *buf_ptr = port->write_urb->transfer_buffer;
6534 ++
6535 + if (xmas) {
6536 + iuu_rxcmd(urb);
6537 + return;
6538 +- } else {
6539 +- *buf_ptr++ = IUU_SET_LED;
6540 +- iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255);
6541 + }
6542 ++
6543 ++ iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255);
6544 ++
6545 + usb_fill_bulk_urb(port->write_urb, port->serial->dev,
6546 + usb_sndbulkpipe(port->serial->dev,
6547 + port->bulk_out_endpointAddress),
6548 +diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
6549 +index 00dddf6e08b0..2d2ee17052e8 100644
6550 +--- a/drivers/video/console/newport_con.c
6551 ++++ b/drivers/video/console/newport_con.c
6552 +@@ -32,6 +32,8 @@
6553 + #include <linux/linux_logo.h>
6554 + #include <linux/font.h>
6555 +
6556 ++#define NEWPORT_LEN 0x10000
6557 ++
6558 + #define FONT_DATA ((unsigned char *)font_vga_8x16.data)
6559 +
6560 + /* borrowed from fbcon.c */
6561 +@@ -43,6 +45,7 @@
6562 + static unsigned char *font_data[MAX_NR_CONSOLES];
6563 +
6564 + static struct newport_regs *npregs;
6565 ++static unsigned long newport_addr;
6566 +
6567 + static int logo_active;
6568 + static int topscan;
6569 +@@ -702,7 +705,6 @@ const struct consw newport_con = {
6570 + static int newport_probe(struct gio_device *dev,
6571 + const struct gio_device_id *id)
6572 + {
6573 +- unsigned long newport_addr;
6574 + int err;
6575 +
6576 + if (!dev->resource.start)
6577 +@@ -712,7 +714,7 @@ static int newport_probe(struct gio_device *dev,
6578 + return -EBUSY; /* we only support one Newport as console */
6579 +
6580 + newport_addr = dev->resource.start + 0xF0000;
6581 +- if (!request_mem_region(newport_addr, 0x10000, "Newport"))
6582 ++ if (!request_mem_region(newport_addr, NEWPORT_LEN, "Newport"))
6583 + return -ENODEV;
6584 +
6585 + npregs = (struct newport_regs *)/* ioremap cannot fail */
6586 +@@ -720,6 +722,11 @@ static int newport_probe(struct gio_device *dev,
6587 + console_lock();
6588 + err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
6589 + console_unlock();
6590 ++
6591 ++ if (err) {
6592 ++ iounmap((void *)npregs);
6593 ++ release_mem_region(newport_addr, NEWPORT_LEN);
6594 ++ }
6595 + return err;
6596 + }
6597 +
6598 +@@ -727,6 +734,7 @@ static void newport_remove(struct gio_device *dev)
6599 + {
6600 + give_up_console(&newport_con);
6601 + iounmap((void *)npregs);
6602 ++ release_mem_region(newport_addr, NEWPORT_LEN);
6603 + }
6604 +
6605 + static struct gio_device_id newport_ids[] = {
6606 +diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c
6607 +index b770946a0920..76464000933d 100644
6608 +--- a/drivers/video/fbdev/neofb.c
6609 ++++ b/drivers/video/fbdev/neofb.c
6610 +@@ -1820,6 +1820,7 @@ static int neo_scan_monitor(struct fb_info *info)
6611 + #else
6612 + printk(KERN_ERR
6613 + "neofb: Only 640x480, 800x600/480 and 1024x768 panels are currently supported\n");
6614 ++ kfree(info->monspecs.modedb);
6615 + return -1;
6616 + #endif
6617 + default:
6618 +diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
6619 +index f70c9f79622e..27635926cea3 100644
6620 +--- a/drivers/video/fbdev/pxafb.c
6621 ++++ b/drivers/video/fbdev/pxafb.c
6622 +@@ -2425,8 +2425,8 @@ static int pxafb_remove(struct platform_device *dev)
6623 +
6624 + free_pages_exact(fbi->video_mem, fbi->video_mem_size);
6625 +
6626 +- dma_free_wc(&dev->dev, fbi->dma_buff_size, fbi->dma_buff,
6627 +- fbi->dma_buff_phys);
6628 ++ dma_free_coherent(&dev->dev, fbi->dma_buff_size, fbi->dma_buff,
6629 ++ fbi->dma_buff_phys);
6630 +
6631 + return 0;
6632 + }
6633 +diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c
6634 +index 512789f5f884..d5d22d9c0f56 100644
6635 +--- a/drivers/video/fbdev/savage/savagefb_driver.c
6636 ++++ b/drivers/video/fbdev/savage/savagefb_driver.c
6637 +@@ -2158,6 +2158,8 @@ static int savage_init_fb_info(struct fb_info *info, struct pci_dev *dev,
6638 + info->flags |= FBINFO_HWACCEL_COPYAREA |
6639 + FBINFO_HWACCEL_FILLRECT |
6640 + FBINFO_HWACCEL_IMAGEBLIT;
6641 ++ else
6642 ++ kfree(info->pixmap.addr);
6643 + }
6644 + #endif
6645 + return err;
6646 +diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c
6647 +index 207d0add684b..246681414577 100644
6648 +--- a/drivers/video/fbdev/sm712fb.c
6649 ++++ b/drivers/video/fbdev/sm712fb.c
6650 +@@ -1429,6 +1429,8 @@ static int smtc_map_smem(struct smtcfb_info *sfb,
6651 + static void smtc_unmap_smem(struct smtcfb_info *sfb)
6652 + {
6653 + if (sfb && sfb->fb->screen_base) {
6654 ++ if (sfb->chip_id == 0x720)
6655 ++ sfb->fb->screen_base -= 0x00200000;
6656 + iounmap(sfb->fb->screen_base);
6657 + sfb->fb->screen_base = NULL;
6658 + }
6659 +diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
6660 +index bed90d612e48..ebb05517b6aa 100644
6661 +--- a/drivers/xen/balloon.c
6662 ++++ b/drivers/xen/balloon.c
6663 +@@ -570,11 +570,13 @@ static int add_ballooned_pages(int nr_pages)
6664 + if (xen_hotplug_unpopulated) {
6665 + st = reserve_additional_memory();
6666 + if (st != BP_ECANCELED) {
6667 ++ int rc;
6668 ++
6669 + mutex_unlock(&balloon_mutex);
6670 +- wait_event(balloon_wq,
6671 ++ rc = wait_event_interruptible(balloon_wq,
6672 + !list_empty(&ballooned_pages));
6673 + mutex_lock(&balloon_mutex);
6674 +- return 0;
6675 ++ return rc ? -ENOMEM : 0;
6676 + }
6677 + }
6678 +
6679 +@@ -632,6 +634,12 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
6680 + out_undo:
6681 + mutex_unlock(&balloon_mutex);
6682 + free_xenballooned_pages(pgno, pages);
6683 ++ /*
6684 ++ * NB: free_xenballooned_pages will only subtract pgno pages, but since
6685 ++ * target_unpopulated is incremented with nr_pages at the start we need
6686 ++ * to remove the remaining ones also, or accounting will be screwed.
6687 ++ */
6688 ++ balloon_stats.target_unpopulated -= nr_pages - pgno;
6689 + return ret;
6690 + }
6691 + EXPORT_SYMBOL(alloc_xenballooned_pages);
6692 +diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c
6693 +index 2c4f324f8626..da799929087d 100644
6694 +--- a/drivers/xen/gntdev-dmabuf.c
6695 ++++ b/drivers/xen/gntdev-dmabuf.c
6696 +@@ -641,6 +641,14 @@ dmabuf_imp_to_refs(struct gntdev_dmabuf_priv *priv, struct device *dev,
6697 + goto fail_detach;
6698 + }
6699 +
6700 ++ /* Check that we have zero offset. */
6701 ++ if (sgt->sgl->offset) {
6702 ++ ret = ERR_PTR(-EINVAL);
6703 ++ pr_debug("DMA buffer has %d bytes offset, user-space expects 0\n",
6704 ++ sgt->sgl->offset);
6705 ++ goto fail_unmap;
6706 ++ }
6707 ++
6708 + /* Check number of pages that imported buffer has. */
6709 + if (attach->dmabuf->size != gntdev_dmabuf->nr_pages << PAGE_SHIFT) {
6710 + ret = ERR_PTR(-EINVAL);
6711 +diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
6712 +index 15a99f9c7253..39def020a074 100644
6713 +--- a/fs/9p/v9fs.c
6714 ++++ b/fs/9p/v9fs.c
6715 +@@ -500,10 +500,9 @@ void v9fs_session_close(struct v9fs_session_info *v9ses)
6716 + }
6717 +
6718 + #ifdef CONFIG_9P_FSCACHE
6719 +- if (v9ses->fscache) {
6720 ++ if (v9ses->fscache)
6721 + v9fs_cache_session_put_cookie(v9ses);
6722 +- kfree(v9ses->cachetag);
6723 +- }
6724 ++ kfree(v9ses->cachetag);
6725 + #endif
6726 + kfree(v9ses->uname);
6727 + kfree(v9ses->aname);
6728 +diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
6729 +index 1a089a642422..99dcb3897659 100644
6730 +--- a/fs/btrfs/extent_io.c
6731 ++++ b/fs/btrfs/extent_io.c
6732 +@@ -4481,6 +4481,8 @@ int try_release_extent_mapping(struct page *page, gfp_t mask)
6733 +
6734 + /* once for us */
6735 + free_extent_map(em);
6736 ++
6737 ++ cond_resched(); /* Allow large-extent preemption. */
6738 + }
6739 + }
6740 + return try_release_extent_state(tree, page, mask);
6741 +diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
6742 +index 7889a59a57fa..6f484f0d347e 100644
6743 +--- a/fs/btrfs/space-info.c
6744 ++++ b/fs/btrfs/space-info.c
6745 +@@ -304,8 +304,8 @@ again:
6746 + cache->key.objectid, cache->key.offset,
6747 + btrfs_block_group_used(&cache->item), cache->pinned,
6748 + cache->reserved, cache->ro ? "[readonly]" : "");
6749 +- btrfs_dump_free_space(cache, bytes);
6750 + spin_unlock(&cache->lock);
6751 ++ btrfs_dump_free_space(cache, bytes);
6752 + }
6753 + if (++index < BTRFS_NR_RAID_TYPES)
6754 + goto again;
6755 +diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
6756 +index afb8340918b8..c689359ca532 100644
6757 +--- a/fs/dlm/lockspace.c
6758 ++++ b/fs/dlm/lockspace.c
6759 +@@ -632,6 +632,9 @@ static int new_lockspace(const char *name, const char *cluster,
6760 + wait_event(ls->ls_recover_lock_wait,
6761 + test_bit(LSFL_RECOVER_LOCK, &ls->ls_flags));
6762 +
6763 ++ /* let kobject handle freeing of ls if there's an error */
6764 ++ do_unreg = 1;
6765 ++
6766 + ls->ls_kobj.kset = dlm_kset;
6767 + error = kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL,
6768 + "%s", ls->ls_name);
6769 +@@ -639,9 +642,6 @@ static int new_lockspace(const char *name, const char *cluster,
6770 + goto out_recoverd;
6771 + kobject_uevent(&ls->ls_kobj, KOBJ_ADD);
6772 +
6773 +- /* let kobject handle freeing of ls if there's an error */
6774 +- do_unreg = 1;
6775 +-
6776 + /* This uevent triggers dlm_controld in userspace to add us to the
6777 + group of nodes that are members of this lockspace (managed by the
6778 + cluster infrastructure.) Once it's done that, it tells us who the
6779 +diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
6780 +index 3350ab65d892..b36b414cd7a7 100644
6781 +--- a/fs/erofs/inode.c
6782 ++++ b/fs/erofs/inode.c
6783 +@@ -8,31 +8,80 @@
6784 +
6785 + #include <trace/events/erofs.h>
6786 +
6787 +-/* no locking */
6788 +-static int erofs_read_inode(struct inode *inode, void *data)
6789 ++/*
6790 ++ * if inode is successfully read, return its inode page (or sometimes
6791 ++ * the inode payload page if it's an extended inode) in order to fill
6792 ++ * inline data if possible.
6793 ++ */
6794 ++static struct page *erofs_read_inode(struct inode *inode,
6795 ++ unsigned int *ofs)
6796 + {
6797 ++ struct super_block *sb = inode->i_sb;
6798 ++ struct erofs_sb_info *sbi = EROFS_SB(sb);
6799 + struct erofs_inode *vi = EROFS_I(inode);
6800 +- struct erofs_inode_compact *dic = data;
6801 +- struct erofs_inode_extended *die;
6802 ++ const erofs_off_t inode_loc = iloc(sbi, vi->nid);
6803 ++
6804 ++ erofs_blk_t blkaddr, nblks = 0;
6805 ++ struct page *page;
6806 ++ struct erofs_inode_compact *dic;
6807 ++ struct erofs_inode_extended *die, *copied = NULL;
6808 ++ unsigned int ifmt;
6809 ++ int err;
6810 +
6811 +- const unsigned int ifmt = le16_to_cpu(dic->i_format);
6812 +- struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb);
6813 +- erofs_blk_t nblks = 0;
6814 ++ blkaddr = erofs_blknr(inode_loc);
6815 ++ *ofs = erofs_blkoff(inode_loc);
6816 +
6817 +- vi->datalayout = erofs_inode_datalayout(ifmt);
6818 ++ erofs_dbg("%s, reading inode nid %llu at %u of blkaddr %u",
6819 ++ __func__, vi->nid, *ofs, blkaddr);
6820 ++
6821 ++ page = erofs_get_meta_page(sb, blkaddr);
6822 ++ if (IS_ERR(page)) {
6823 ++ erofs_err(sb, "failed to get inode (nid: %llu) page, err %ld",
6824 ++ vi->nid, PTR_ERR(page));
6825 ++ return page;
6826 ++ }
6827 +
6828 ++ dic = page_address(page) + *ofs;
6829 ++ ifmt = le16_to_cpu(dic->i_format);
6830 ++
6831 ++ vi->datalayout = erofs_inode_datalayout(ifmt);
6832 + if (vi->datalayout >= EROFS_INODE_DATALAYOUT_MAX) {
6833 + erofs_err(inode->i_sb, "unsupported datalayout %u of nid %llu",
6834 + vi->datalayout, vi->nid);
6835 +- DBG_BUGON(1);
6836 +- return -EOPNOTSUPP;
6837 ++ err = -EOPNOTSUPP;
6838 ++ goto err_out;
6839 + }
6840 +
6841 + switch (erofs_inode_version(ifmt)) {
6842 + case EROFS_INODE_LAYOUT_EXTENDED:
6843 +- die = data;
6844 +-
6845 + vi->inode_isize = sizeof(struct erofs_inode_extended);
6846 ++ /* check if the inode acrosses page boundary */
6847 ++ if (*ofs + vi->inode_isize <= PAGE_SIZE) {
6848 ++ *ofs += vi->inode_isize;
6849 ++ die = (struct erofs_inode_extended *)dic;
6850 ++ } else {
6851 ++ const unsigned int gotten = PAGE_SIZE - *ofs;
6852 ++
6853 ++ copied = kmalloc(vi->inode_isize, GFP_NOFS);
6854 ++ if (!copied) {
6855 ++ err = -ENOMEM;
6856 ++ goto err_out;
6857 ++ }
6858 ++ memcpy(copied, dic, gotten);
6859 ++ unlock_page(page);
6860 ++ put_page(page);
6861 ++
6862 ++ page = erofs_get_meta_page(sb, blkaddr + 1);
6863 ++ if (IS_ERR(page)) {
6864 ++ erofs_err(sb, "failed to get inode payload page (nid: %llu), err %ld",
6865 ++ vi->nid, PTR_ERR(page));
6866 ++ kfree(copied);
6867 ++ return page;
6868 ++ }
6869 ++ *ofs = vi->inode_isize - gotten;
6870 ++ memcpy((u8 *)copied + gotten, page_address(page), *ofs);
6871 ++ die = copied;
6872 ++ }
6873 + vi->xattr_isize = erofs_xattr_ibody_size(die->i_xattr_icount);
6874 +
6875 + inode->i_mode = le16_to_cpu(die->i_mode);
6876 +@@ -69,9 +118,12 @@ static int erofs_read_inode(struct inode *inode, void *data)
6877 + /* total blocks for compressed files */
6878 + if (erofs_inode_is_data_compressed(vi->datalayout))
6879 + nblks = le32_to_cpu(die->i_u.compressed_blocks);
6880 ++
6881 ++ kfree(copied);
6882 + break;
6883 + case EROFS_INODE_LAYOUT_COMPACT:
6884 + vi->inode_isize = sizeof(struct erofs_inode_compact);
6885 ++ *ofs += vi->inode_isize;
6886 + vi->xattr_isize = erofs_xattr_ibody_size(dic->i_xattr_icount);
6887 +
6888 + inode->i_mode = le16_to_cpu(dic->i_mode);
6889 +@@ -111,8 +163,8 @@ static int erofs_read_inode(struct inode *inode, void *data)
6890 + erofs_err(inode->i_sb,
6891 + "unsupported on-disk inode version %u of nid %llu",
6892 + erofs_inode_version(ifmt), vi->nid);
6893 +- DBG_BUGON(1);
6894 +- return -EOPNOTSUPP;
6895 ++ err = -EOPNOTSUPP;
6896 ++ goto err_out;
6897 + }
6898 +
6899 + if (!nblks)
6900 +@@ -120,13 +172,18 @@ static int erofs_read_inode(struct inode *inode, void *data)
6901 + inode->i_blocks = roundup(inode->i_size, EROFS_BLKSIZ) >> 9;
6902 + else
6903 + inode->i_blocks = nblks << LOG_SECTORS_PER_BLOCK;
6904 +- return 0;
6905 ++ return page;
6906 +
6907 + bogusimode:
6908 + erofs_err(inode->i_sb, "bogus i_mode (%o) @ nid %llu",
6909 + inode->i_mode, vi->nid);
6910 ++ err = -EFSCORRUPTED;
6911 ++err_out:
6912 + DBG_BUGON(1);
6913 +- return -EFSCORRUPTED;
6914 ++ kfree(copied);
6915 ++ unlock_page(page);
6916 ++ put_page(page);
6917 ++ return ERR_PTR(err);
6918 + }
6919 +
6920 + static int erofs_fill_symlink(struct inode *inode, void *data,
6921 +@@ -146,7 +203,7 @@ static int erofs_fill_symlink(struct inode *inode, void *data,
6922 + if (!lnk)
6923 + return -ENOMEM;
6924 +
6925 +- m_pofs += vi->inode_isize + vi->xattr_isize;
6926 ++ m_pofs += vi->xattr_isize;
6927 + /* inline symlink data shouldn't cross page boundary as well */
6928 + if (m_pofs + inode->i_size > PAGE_SIZE) {
6929 + kfree(lnk);
6930 +@@ -167,37 +224,17 @@ static int erofs_fill_symlink(struct inode *inode, void *data,
6931 +
6932 + static int erofs_fill_inode(struct inode *inode, int isdir)
6933 + {
6934 +- struct super_block *sb = inode->i_sb;
6935 + struct erofs_inode *vi = EROFS_I(inode);
6936 + struct page *page;
6937 +- void *data;
6938 +- int err;
6939 +- erofs_blk_t blkaddr;
6940 + unsigned int ofs;
6941 +- erofs_off_t inode_loc;
6942 ++ int err = 0;
6943 +
6944 + trace_erofs_fill_inode(inode, isdir);
6945 +- inode_loc = iloc(EROFS_SB(sb), vi->nid);
6946 +- blkaddr = erofs_blknr(inode_loc);
6947 +- ofs = erofs_blkoff(inode_loc);
6948 +-
6949 +- erofs_dbg("%s, reading inode nid %llu at %u of blkaddr %u",
6950 +- __func__, vi->nid, ofs, blkaddr);
6951 +
6952 +- page = erofs_get_meta_page(sb, blkaddr);
6953 +-
6954 +- if (IS_ERR(page)) {
6955 +- erofs_err(sb, "failed to get inode (nid: %llu) page, err %ld",
6956 +- vi->nid, PTR_ERR(page));
6957 ++ /* read inode base data from disk */
6958 ++ page = erofs_read_inode(inode, &ofs);
6959 ++ if (IS_ERR(page))
6960 + return PTR_ERR(page);
6961 +- }
6962 +-
6963 +- DBG_BUGON(!PageUptodate(page));
6964 +- data = page_address(page);
6965 +-
6966 +- err = erofs_read_inode(inode, data + ofs);
6967 +- if (err)
6968 +- goto out_unlock;
6969 +
6970 + /* setup the new inode */
6971 + switch (inode->i_mode & S_IFMT) {
6972 +@@ -210,7 +247,7 @@ static int erofs_fill_inode(struct inode *inode, int isdir)
6973 + inode->i_fop = &erofs_dir_fops;
6974 + break;
6975 + case S_IFLNK:
6976 +- err = erofs_fill_symlink(inode, data, ofs);
6977 ++ err = erofs_fill_symlink(inode, page_address(page), ofs);
6978 + if (err)
6979 + goto out_unlock;
6980 + inode_nohighmem(inode);
6981 +diff --git a/fs/io_uring.c b/fs/io_uring.c
6982 +index be3d595a607f..fada14ee1cdc 100644
6983 +--- a/fs/io_uring.c
6984 ++++ b/fs/io_uring.c
6985 +@@ -1433,8 +1433,10 @@ static int io_read(struct io_kiocb *req, const struct sqe_submit *s,
6986 +
6987 + if (file->f_op->read_iter)
6988 + ret2 = call_read_iter(file, kiocb, &iter);
6989 +- else
6990 ++ else if (req->file->f_op->read)
6991 + ret2 = loop_rw_iter(READ, file, kiocb, &iter);
6992 ++ else
6993 ++ ret2 = -EINVAL;
6994 +
6995 + /*
6996 + * In case of a short read, punt to async. This can happen
6997 +@@ -1524,8 +1526,10 @@ static int io_write(struct io_kiocb *req, const struct sqe_submit *s,
6998 +
6999 + if (file->f_op->write_iter)
7000 + ret2 = call_write_iter(file, kiocb, &iter);
7001 +- else
7002 ++ else if (req->file->f_op->write)
7003 + ret2 = loop_rw_iter(WRITE, file, kiocb, &iter);
7004 ++ else
7005 ++ ret2 = -EINVAL;
7006 +
7007 + if (!force_nonblock)
7008 + current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
7009 +@@ -2559,6 +2563,7 @@ static void io_submit_sqe(struct io_ring_ctx *ctx, struct sqe_submit *s,
7010 + goto err;
7011 + }
7012 +
7013 ++ memcpy(&req->submit, s, sizeof(*s));
7014 + ret = io_req_set_file(ctx, s, state, req);
7015 + if (unlikely(ret)) {
7016 + err_req:
7017 +@@ -3390,6 +3395,9 @@ static unsigned long rings_size(unsigned sq_entries, unsigned cq_entries,
7018 + return SIZE_MAX;
7019 + #endif
7020 +
7021 ++ if (sq_offset)
7022 ++ *sq_offset = off;
7023 ++
7024 + sq_array_size = array_size(sizeof(u32), sq_entries);
7025 + if (sq_array_size == SIZE_MAX)
7026 + return SIZE_MAX;
7027 +@@ -3397,9 +3405,6 @@ static unsigned long rings_size(unsigned sq_entries, unsigned cq_entries,
7028 + if (check_add_overflow(off, sq_array_size, &off))
7029 + return SIZE_MAX;
7030 +
7031 +- if (sq_offset)
7032 +- *sq_offset = off;
7033 +-
7034 + return off;
7035 + }
7036 +
7037 +@@ -3856,6 +3861,10 @@ static int io_allocate_scq_urings(struct io_ring_ctx *ctx,
7038 + struct io_rings *rings;
7039 + size_t size, sq_array_offset;
7040 +
7041 ++ /* make sure these are sane, as we already accounted them */
7042 ++ ctx->sq_entries = p->sq_entries;
7043 ++ ctx->cq_entries = p->cq_entries;
7044 ++
7045 + size = rings_size(p->sq_entries, p->cq_entries, &sq_array_offset);
7046 + if (size == SIZE_MAX)
7047 + return -EOVERFLOW;
7048 +@@ -3872,8 +3881,6 @@ static int io_allocate_scq_urings(struct io_ring_ctx *ctx,
7049 + rings->cq_ring_entries = p->cq_entries;
7050 + ctx->sq_mask = rings->sq_ring_mask;
7051 + ctx->cq_mask = rings->cq_ring_mask;
7052 +- ctx->sq_entries = rings->sq_ring_entries;
7053 +- ctx->cq_entries = rings->cq_ring_entries;
7054 +
7055 + size = array_size(sizeof(struct io_uring_sqe), p->sq_entries);
7056 + if (size == SIZE_MAX) {
7057 +diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
7058 +index e8c792b49616..c35bbaa19486 100644
7059 +--- a/fs/kernfs/file.c
7060 ++++ b/fs/kernfs/file.c
7061 +@@ -912,7 +912,7 @@ repeat:
7062 + }
7063 +
7064 + fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE,
7065 +- &name, 0);
7066 ++ NULL, 0);
7067 + iput(inode);
7068 + }
7069 +
7070 +diff --git a/fs/minix/inode.c b/fs/minix/inode.c
7071 +index 7cb5fd38eb14..0dd929346f3f 100644
7072 +--- a/fs/minix/inode.c
7073 ++++ b/fs/minix/inode.c
7074 +@@ -150,6 +150,23 @@ static int minix_remount (struct super_block * sb, int * flags, char * data)
7075 + return 0;
7076 + }
7077 +
7078 ++static bool minix_check_superblock(struct minix_sb_info *sbi)
7079 ++{
7080 ++ if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0)
7081 ++ return false;
7082 ++
7083 ++ /*
7084 ++ * s_max_size must not exceed the block mapping limitation. This check
7085 ++ * is only needed for V1 filesystems, since V2/V3 support an extra level
7086 ++ * of indirect blocks which places the limit well above U32_MAX.
7087 ++ */
7088 ++ if (sbi->s_version == MINIX_V1 &&
7089 ++ sbi->s_max_size > (7 + 512 + 512*512) * BLOCK_SIZE)
7090 ++ return false;
7091 ++
7092 ++ return true;
7093 ++}
7094 ++
7095 + static int minix_fill_super(struct super_block *s, void *data, int silent)
7096 + {
7097 + struct buffer_head *bh;
7098 +@@ -228,11 +245,12 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
7099 + } else
7100 + goto out_no_fs;
7101 +
7102 ++ if (!minix_check_superblock(sbi))
7103 ++ goto out_illegal_sb;
7104 ++
7105 + /*
7106 + * Allocate the buffer map to keep the superblock small.
7107 + */
7108 +- if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0)
7109 +- goto out_illegal_sb;
7110 + i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh);
7111 + map = kzalloc(i, GFP_KERNEL);
7112 + if (!map)
7113 +@@ -468,6 +486,13 @@ static struct inode *V1_minix_iget(struct inode *inode)
7114 + iget_failed(inode);
7115 + return ERR_PTR(-EIO);
7116 + }
7117 ++ if (raw_inode->i_nlinks == 0) {
7118 ++ printk("MINIX-fs: deleted inode referenced: %lu\n",
7119 ++ inode->i_ino);
7120 ++ brelse(bh);
7121 ++ iget_failed(inode);
7122 ++ return ERR_PTR(-ESTALE);
7123 ++ }
7124 + inode->i_mode = raw_inode->i_mode;
7125 + i_uid_write(inode, raw_inode->i_uid);
7126 + i_gid_write(inode, raw_inode->i_gid);
7127 +@@ -501,6 +526,13 @@ static struct inode *V2_minix_iget(struct inode *inode)
7128 + iget_failed(inode);
7129 + return ERR_PTR(-EIO);
7130 + }
7131 ++ if (raw_inode->i_nlinks == 0) {
7132 ++ printk("MINIX-fs: deleted inode referenced: %lu\n",
7133 ++ inode->i_ino);
7134 ++ brelse(bh);
7135 ++ iget_failed(inode);
7136 ++ return ERR_PTR(-ESTALE);
7137 ++ }
7138 + inode->i_mode = raw_inode->i_mode;
7139 + i_uid_write(inode, raw_inode->i_uid);
7140 + i_gid_write(inode, raw_inode->i_gid);
7141 +diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c
7142 +index 043c3fdbc8e7..446148792f41 100644
7143 +--- a/fs/minix/itree_common.c
7144 ++++ b/fs/minix/itree_common.c
7145 +@@ -75,6 +75,7 @@ static int alloc_branch(struct inode *inode,
7146 + int n = 0;
7147 + int i;
7148 + int parent = minix_new_block(inode);
7149 ++ int err = -ENOSPC;
7150 +
7151 + branch[0].key = cpu_to_block(parent);
7152 + if (parent) for (n = 1; n < num; n++) {
7153 +@@ -85,6 +86,11 @@ static int alloc_branch(struct inode *inode,
7154 + break;
7155 + branch[n].key = cpu_to_block(nr);
7156 + bh = sb_getblk(inode->i_sb, parent);
7157 ++ if (!bh) {
7158 ++ minix_free_block(inode, nr);
7159 ++ err = -ENOMEM;
7160 ++ break;
7161 ++ }
7162 + lock_buffer(bh);
7163 + memset(bh->b_data, 0, bh->b_size);
7164 + branch[n].bh = bh;
7165 +@@ -103,7 +109,7 @@ static int alloc_branch(struct inode *inode,
7166 + bforget(branch[i].bh);
7167 + for (i = 0; i < n; i++)
7168 + minix_free_block(inode, block_to_cpu(branch[i].key));
7169 +- return -ENOSPC;
7170 ++ return err;
7171 + }
7172 +
7173 + static inline int splice_branch(struct inode *inode,
7174 +diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
7175 +index 443639cbb0cf..9c2b07ce57b2 100644
7176 +--- a/fs/nfs/pnfs.c
7177 ++++ b/fs/nfs/pnfs.c
7178 +@@ -1198,31 +1198,27 @@ out:
7179 + return status;
7180 + }
7181 +
7182 ++static bool
7183 ++pnfs_layout_segments_returnable(struct pnfs_layout_hdr *lo,
7184 ++ enum pnfs_iomode iomode,
7185 ++ u32 seq)
7186 ++{
7187 ++ struct pnfs_layout_range recall_range = {
7188 ++ .length = NFS4_MAX_UINT64,
7189 ++ .iomode = iomode,
7190 ++ };
7191 ++ return pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs,
7192 ++ &recall_range, seq) != -EBUSY;
7193 ++}
7194 ++
7195 + /* Return true if layoutreturn is needed */
7196 + static bool
7197 + pnfs_layout_need_return(struct pnfs_layout_hdr *lo)
7198 + {
7199 +- struct pnfs_layout_segment *s;
7200 +- enum pnfs_iomode iomode;
7201 +- u32 seq;
7202 +-
7203 + if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags))
7204 + return false;
7205 +-
7206 +- seq = lo->plh_return_seq;
7207 +- iomode = lo->plh_return_iomode;
7208 +-
7209 +- /* Defer layoutreturn until all recalled lsegs are done */
7210 +- list_for_each_entry(s, &lo->plh_segs, pls_list) {
7211 +- if (seq && pnfs_seqid_is_newer(s->pls_seq, seq))
7212 +- continue;
7213 +- if (iomode != IOMODE_ANY && s->pls_range.iomode != iomode)
7214 +- continue;
7215 +- if (test_bit(NFS_LSEG_LAYOUTRETURN, &s->pls_flags))
7216 +- return false;
7217 +- }
7218 +-
7219 +- return true;
7220 ++ return pnfs_layout_segments_returnable(lo, lo->plh_return_iomode,
7221 ++ lo->plh_return_seq);
7222 + }
7223 +
7224 + static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo)
7225 +@@ -2362,16 +2358,6 @@ out_forget:
7226 + return ERR_PTR(-EAGAIN);
7227 + }
7228 +
7229 +-static int
7230 +-mark_lseg_invalid_or_return(struct pnfs_layout_segment *lseg,
7231 +- struct list_head *tmp_list)
7232 +-{
7233 +- if (!mark_lseg_invalid(lseg, tmp_list))
7234 +- return 0;
7235 +- pnfs_cache_lseg_for_layoutreturn(lseg->pls_layout, lseg);
7236 +- return 1;
7237 +-}
7238 +-
7239 + /**
7240 + * pnfs_mark_matching_lsegs_return - Free or return matching layout segments
7241 + * @lo: pointer to layout header
7242 +@@ -2408,7 +2394,7 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
7243 + lseg, lseg->pls_range.iomode,
7244 + lseg->pls_range.offset,
7245 + lseg->pls_range.length);
7246 +- if (mark_lseg_invalid_or_return(lseg, tmp_list))
7247 ++ if (mark_lseg_invalid(lseg, tmp_list))
7248 + continue;
7249 + remaining++;
7250 + set_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags);
7251 +diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
7252 +index e2c34c704185..50a863fc1779 100644
7253 +--- a/fs/ocfs2/dlmglue.c
7254 ++++ b/fs/ocfs2/dlmglue.c
7255 +@@ -2871,9 +2871,15 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)
7256 +
7257 + status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE,
7258 + 0, 0);
7259 +- if (status < 0)
7260 ++ if (status < 0) {
7261 + mlog(ML_ERROR, "lock on nfs sync lock failed %d\n", status);
7262 +
7263 ++ if (ex)
7264 ++ up_write(&osb->nfs_sync_rwlock);
7265 ++ else
7266 ++ up_read(&osb->nfs_sync_rwlock);
7267 ++ }
7268 ++
7269 + return status;
7270 + }
7271 +
7272 +diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
7273 +index cdf5b8ae2583..74a60bae2b23 100644
7274 +--- a/fs/pstore/platform.c
7275 ++++ b/fs/pstore/platform.c
7276 +@@ -275,6 +275,9 @@ static int pstore_compress(const void *in, void *out,
7277 + {
7278 + int ret;
7279 +
7280 ++ if (!IS_ENABLED(CONFIG_PSTORE_COMPRESSION))
7281 ++ return -EINVAL;
7282 ++
7283 + ret = crypto_comp_compress(tfm, in, inlen, out, &outlen);
7284 + if (ret) {
7285 + pr_err("crypto_comp_compress failed, ret = %d!\n", ret);
7286 +@@ -661,7 +664,7 @@ static void decompress_record(struct pstore_record *record)
7287 + int unzipped_len;
7288 + char *unzipped, *workspace;
7289 +
7290 +- if (!record->compressed)
7291 ++ if (!IS_ENABLED(CONFIG_PSTORE_COMPRESSION) || !record->compressed)
7292 + return;
7293 +
7294 + /* Only PSTORE_TYPE_DMESG support compression. */
7295 +diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h
7296 +index 88221c7a04cc..c6df01a2a158 100644
7297 +--- a/fs/xfs/libxfs/xfs_trans_space.h
7298 ++++ b/fs/xfs/libxfs/xfs_trans_space.h
7299 +@@ -57,7 +57,7 @@
7300 + XFS_DAREMOVE_SPACE_RES(mp, XFS_DATA_FORK)
7301 + #define XFS_IALLOC_SPACE_RES(mp) \
7302 + (M_IGEO(mp)->ialloc_blks + \
7303 +- (xfs_sb_version_hasfinobt(&mp->m_sb) ? 2 : 1 * \
7304 ++ ((xfs_sb_version_hasfinobt(&mp->m_sb) ? 2 : 1) * \
7305 + (M_IGEO(mp)->inobt_maxlevels - 1)))
7306 +
7307 + /*
7308 +diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c
7309 +index fa6ea6407992..392fb4df5c12 100644
7310 +--- a/fs/xfs/scrub/bmap.c
7311 ++++ b/fs/xfs/scrub/bmap.c
7312 +@@ -45,9 +45,27 @@ xchk_setup_inode_bmap(
7313 + */
7314 + if (S_ISREG(VFS_I(sc->ip)->i_mode) &&
7315 + sc->sm->sm_type == XFS_SCRUB_TYPE_BMBTD) {
7316 ++ struct address_space *mapping = VFS_I(sc->ip)->i_mapping;
7317 ++
7318 + inode_dio_wait(VFS_I(sc->ip));
7319 +- error = filemap_write_and_wait(VFS_I(sc->ip)->i_mapping);
7320 +- if (error)
7321 ++
7322 ++ /*
7323 ++ * Try to flush all incore state to disk before we examine the
7324 ++ * space mappings for the data fork. Leave accumulated errors
7325 ++ * in the mapping for the writer threads to consume.
7326 ++ *
7327 ++ * On ENOSPC or EIO writeback errors, we continue into the
7328 ++ * extent mapping checks because write failures do not
7329 ++ * necessarily imply anything about the correctness of the file
7330 ++ * metadata. The metadata and the file data could be on
7331 ++ * completely separate devices; a media failure might only
7332 ++ * affect a subset of the disk, etc. We can handle delalloc
7333 ++ * extents in the scrubber, so leaving them in memory is fine.
7334 ++ */
7335 ++ error = filemap_fdatawrite(mapping);
7336 ++ if (!error)
7337 ++ error = filemap_fdatawait_keep_errors(mapping);
7338 ++ if (error && (error != -ENOSPC && error != -EIO))
7339 + goto out;
7340 + }
7341 +
7342 +diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
7343 +index 6a4fd1738b08..904d8285c226 100644
7344 +--- a/fs/xfs/xfs_reflink.c
7345 ++++ b/fs/xfs/xfs_reflink.c
7346 +@@ -1005,6 +1005,7 @@ xfs_reflink_remap_extent(
7347 + xfs_filblks_t rlen;
7348 + xfs_filblks_t unmap_len;
7349 + xfs_off_t newlen;
7350 ++ int64_t qres;
7351 + int error;
7352 +
7353 + unmap_len = irec->br_startoff + irec->br_blockcount - destoff;
7354 +@@ -1027,13 +1028,19 @@ xfs_reflink_remap_extent(
7355 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7356 + xfs_trans_ijoin(tp, ip, 0);
7357 +
7358 +- /* If we're not just clearing space, then do we have enough quota? */
7359 +- if (real_extent) {
7360 +- error = xfs_trans_reserve_quota_nblks(tp, ip,
7361 +- irec->br_blockcount, 0, XFS_QMOPT_RES_REGBLKS);
7362 +- if (error)
7363 +- goto out_cancel;
7364 +- }
7365 ++ /*
7366 ++ * Reserve quota for this operation. We don't know if the first unmap
7367 ++ * in the dest file will cause a bmap btree split, so we always reserve
7368 ++ * at least enough blocks for that split. If the extent being mapped
7369 ++ * in is written, we need to reserve quota for that too.
7370 ++ */
7371 ++ qres = XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK);
7372 ++ if (real_extent)
7373 ++ qres += irec->br_blockcount;
7374 ++ error = xfs_trans_reserve_quota_nblks(tp, ip, qres, 0,
7375 ++ XFS_QMOPT_RES_REGBLKS);
7376 ++ if (error)
7377 ++ goto out_cancel;
7378 +
7379 + trace_xfs_reflink_remap(ip, irec->br_startoff,
7380 + irec->br_blockcount, irec->br_startblock);
7381 +diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
7382 +index d7616d08e863..f050039ca2c0 100644
7383 +--- a/include/asm-generic/vmlinux.lds.h
7384 ++++ b/include/asm-generic/vmlinux.lds.h
7385 +@@ -340,6 +340,7 @@
7386 + */
7387 + #ifndef RO_AFTER_INIT_DATA
7388 + #define RO_AFTER_INIT_DATA \
7389 ++ . = ALIGN(8); \
7390 + __start_ro_after_init = .; \
7391 + *(.data..ro_after_init) \
7392 + JUMP_TABLE_DATA \
7393 +diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
7394 +index 4bbb5f1c8b5b..4c0224ff0a14 100644
7395 +--- a/include/linux/bitfield.h
7396 ++++ b/include/linux/bitfield.h
7397 +@@ -64,7 +64,7 @@
7398 + */
7399 + #define FIELD_FIT(_mask, _val) \
7400 + ({ \
7401 +- __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_FIT: "); \
7402 ++ __BF_FIELD_CHECK(_mask, 0ULL, 0ULL, "FIELD_FIT: "); \
7403 + !((((typeof(_mask))_val) << __bf_shf(_mask)) & ~(_mask)); \
7404 + })
7405 +
7406 +diff --git a/include/linux/tpm.h b/include/linux/tpm.h
7407 +index 53c0ea9ec9df..77fdc988c610 100644
7408 +--- a/include/linux/tpm.h
7409 ++++ b/include/linux/tpm.h
7410 +@@ -93,6 +93,7 @@ struct tpm_space {
7411 + u8 *context_buf;
7412 + u32 session_tbl[3];
7413 + u8 *session_buf;
7414 ++ u32 buf_size;
7415 + };
7416 +
7417 + struct tpm_bios_log {
7418 +diff --git a/include/linux/tpm_eventlog.h b/include/linux/tpm_eventlog.h
7419 +index eccfd3a4e4c8..f3caeeb7a0d0 100644
7420 +--- a/include/linux/tpm_eventlog.h
7421 ++++ b/include/linux/tpm_eventlog.h
7422 +@@ -211,9 +211,16 @@ static inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *event,
7423 +
7424 + efispecid = (struct tcg_efi_specid_event_head *)event_header->event;
7425 +
7426 +- /* Check if event is malformed. */
7427 ++ /*
7428 ++ * Perform validation of the event in order to identify malformed
7429 ++ * events. This function may be asked to parse arbitrary byte sequences
7430 ++ * immediately following a valid event log. The caller expects this
7431 ++ * function to recognize that the byte sequence is not a valid event
7432 ++ * and to return an event size of 0.
7433 ++ */
7434 + if (memcmp(efispecid->signature, TCG_SPECID_SIG,
7435 +- sizeof(TCG_SPECID_SIG)) || count > efispecid->num_algs) {
7436 ++ sizeof(TCG_SPECID_SIG)) ||
7437 ++ !efispecid->num_algs || count != efispecid->num_algs) {
7438 + size = 0;
7439 + goto out;
7440 + }
7441 +diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
7442 +index 1fb11daa5c53..57ce5af258a3 100644
7443 +--- a/include/linux/tracepoint.h
7444 ++++ b/include/linux/tracepoint.h
7445 +@@ -362,7 +362,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
7446 + static const char *___tp_str __tracepoint_string = str; \
7447 + ___tp_str; \
7448 + })
7449 +-#define __tracepoint_string __attribute__((section("__tracepoint_str")))
7450 ++#define __tracepoint_string __attribute__((section("__tracepoint_str"), used))
7451 + #else
7452 + /*
7453 + * tracepoint_string() is used to save the string address for userspace
7454 +diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
7455 +index 895546058a20..c71eb294da95 100644
7456 +--- a/include/net/inet_connection_sock.h
7457 ++++ b/include/net/inet_connection_sock.h
7458 +@@ -309,6 +309,10 @@ int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname,
7459 + int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname,
7460 + char __user *optval, unsigned int optlen);
7461 +
7462 ++/* update the fast reuse flag when adding a socket */
7463 ++void inet_csk_update_fastreuse(struct inet_bind_bucket *tb,
7464 ++ struct sock *sk);
7465 ++
7466 + struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu);
7467 +
7468 + #define TCP_PINGPONG_THRESH 3
7469 +diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
7470 +index 078887c8c586..7c37e3c3b1c7 100644
7471 +--- a/include/net/ip_vs.h
7472 ++++ b/include/net/ip_vs.h
7473 +@@ -1624,18 +1624,16 @@ static inline void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp)
7474 + }
7475 + #endif /* CONFIG_IP_VS_NFCT */
7476 +
7477 +-/* Really using conntrack? */
7478 +-static inline bool ip_vs_conn_uses_conntrack(struct ip_vs_conn *cp,
7479 +- struct sk_buff *skb)
7480 ++/* Using old conntrack that can not be redirected to another real server? */
7481 ++static inline bool ip_vs_conn_uses_old_conntrack(struct ip_vs_conn *cp,
7482 ++ struct sk_buff *skb)
7483 + {
7484 + #ifdef CONFIG_IP_VS_NFCT
7485 + enum ip_conntrack_info ctinfo;
7486 + struct nf_conn *ct;
7487 +
7488 +- if (!(cp->flags & IP_VS_CONN_F_NFCT))
7489 +- return false;
7490 + ct = nf_ct_get(skb, &ctinfo);
7491 +- if (ct)
7492 ++ if (ct && nf_ct_is_confirmed(ct))
7493 + return true;
7494 + #endif
7495 + return false;
7496 +diff --git a/include/net/tcp.h b/include/net/tcp.h
7497 +index 7cf1b4972c66..377179283c46 100644
7498 +--- a/include/net/tcp.h
7499 ++++ b/include/net/tcp.h
7500 +@@ -1650,6 +1650,8 @@ void tcp_fastopen_destroy_cipher(struct sock *sk);
7501 + void tcp_fastopen_ctx_destroy(struct net *net);
7502 + int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk,
7503 + void *primary_key, void *backup_key);
7504 ++int tcp_fastopen_get_cipher(struct net *net, struct inet_connection_sock *icsk,
7505 ++ u64 *key);
7506 + void tcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb);
7507 + struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb,
7508 + struct request_sock *req,
7509 +diff --git a/include/uapi/linux/seccomp.h b/include/uapi/linux/seccomp.h
7510 +index 90734aa5aa36..b5f901af79f0 100644
7511 +--- a/include/uapi/linux/seccomp.h
7512 ++++ b/include/uapi/linux/seccomp.h
7513 +@@ -93,5 +93,6 @@ struct seccomp_notif_resp {
7514 + #define SECCOMP_IOCTL_NOTIF_RECV SECCOMP_IOWR(0, struct seccomp_notif)
7515 + #define SECCOMP_IOCTL_NOTIF_SEND SECCOMP_IOWR(1, \
7516 + struct seccomp_notif_resp)
7517 +-#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOR(2, __u64)
7518 ++#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOW(2, __u64)
7519 ++
7520 + #endif /* _UAPI_LINUX_SECCOMP_H */
7521 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
7522 +index 38ae3cf9d173..b34b5c6e2524 100644
7523 +--- a/kernel/sched/core.c
7524 ++++ b/kernel/sched/core.c
7525 +@@ -1238,6 +1238,20 @@ static void uclamp_fork(struct task_struct *p)
7526 + }
7527 + }
7528 +
7529 ++static void __init init_uclamp_rq(struct rq *rq)
7530 ++{
7531 ++ enum uclamp_id clamp_id;
7532 ++ struct uclamp_rq *uc_rq = rq->uclamp;
7533 ++
7534 ++ for_each_clamp_id(clamp_id) {
7535 ++ uc_rq[clamp_id] = (struct uclamp_rq) {
7536 ++ .value = uclamp_none(clamp_id)
7537 ++ };
7538 ++ }
7539 ++
7540 ++ rq->uclamp_flags = 0;
7541 ++}
7542 ++
7543 + static void __init init_uclamp(void)
7544 + {
7545 + struct uclamp_se uc_max = {};
7546 +@@ -1246,11 +1260,8 @@ static void __init init_uclamp(void)
7547 +
7548 + mutex_init(&uclamp_mutex);
7549 +
7550 +- for_each_possible_cpu(cpu) {
7551 +- memset(&cpu_rq(cpu)->uclamp, 0,
7552 +- sizeof(struct uclamp_rq)*UCLAMP_CNT);
7553 +- cpu_rq(cpu)->uclamp_flags = 0;
7554 +- }
7555 ++ for_each_possible_cpu(cpu)
7556 ++ init_uclamp_rq(cpu_rq(cpu));
7557 +
7558 + for_each_clamp_id(clamp_id) {
7559 + uclamp_se_set(&init_task.uclamp_req[clamp_id],
7560 +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
7561 +index 9b16080093be..20bf1f66733a 100644
7562 +--- a/kernel/sched/fair.c
7563 ++++ b/kernel/sched/fair.c
7564 +@@ -9385,7 +9385,12 @@ static void kick_ilb(unsigned int flags)
7565 + {
7566 + int ilb_cpu;
7567 +
7568 +- nohz.next_balance++;
7569 ++ /*
7570 ++ * Increase nohz.next_balance only when if full ilb is triggered but
7571 ++ * not if we only update stats.
7572 ++ */
7573 ++ if (flags & NOHZ_BALANCE_KICK)
7574 ++ nohz.next_balance = jiffies+1;
7575 +
7576 + ilb_cpu = find_new_ilb();
7577 +
7578 +@@ -9703,6 +9708,14 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags,
7579 + }
7580 + }
7581 +
7582 ++ /*
7583 ++ * next_balance will be updated only when there is a need.
7584 ++ * When the CPU is attached to null domain for ex, it will not be
7585 ++ * updated.
7586 ++ */
7587 ++ if (likely(update_next_balance))
7588 ++ nohz.next_balance = next_balance;
7589 ++
7590 + /* Newly idle CPU doesn't need an update */
7591 + if (idle != CPU_NEWLY_IDLE) {
7592 + update_blocked_averages(this_cpu);
7593 +@@ -9723,14 +9736,6 @@ abort:
7594 + if (has_blocked_load)
7595 + WRITE_ONCE(nohz.has_blocked, 1);
7596 +
7597 +- /*
7598 +- * next_balance will be updated only when there is a need.
7599 +- * When the CPU is attached to null domain for ex, it will not be
7600 +- * updated.
7601 +- */
7602 +- if (likely(update_next_balance))
7603 +- nohz.next_balance = next_balance;
7604 +-
7605 + return ret;
7606 + }
7607 +
7608 +diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
7609 +index 1fa1e13a5944..ffaa97a8d405 100644
7610 +--- a/kernel/sched/topology.c
7611 ++++ b/kernel/sched/topology.c
7612 +@@ -1333,7 +1333,7 @@ sd_init(struct sched_domain_topology_level *tl,
7613 + sd_flags = (*tl->sd_flags)();
7614 + if (WARN_ONCE(sd_flags & ~TOPOLOGY_SD_FLAGS,
7615 + "wrong sd_flags in topology description\n"))
7616 +- sd_flags &= ~TOPOLOGY_SD_FLAGS;
7617 ++ sd_flags &= TOPOLOGY_SD_FLAGS;
7618 +
7619 + /* Apply detected topology flags */
7620 + sd_flags |= dflags;
7621 +diff --git a/kernel/seccomp.c b/kernel/seccomp.c
7622 +index 2c697ce7be21..e0fd97235653 100644
7623 +--- a/kernel/seccomp.c
7624 ++++ b/kernel/seccomp.c
7625 +@@ -42,6 +42,14 @@
7626 + #include <linux/uaccess.h>
7627 + #include <linux/anon_inodes.h>
7628 +
7629 ++/*
7630 ++ * When SECCOMP_IOCTL_NOTIF_ID_VALID was first introduced, it had the
7631 ++ * wrong direction flag in the ioctl number. This is the broken one,
7632 ++ * which the kernel needs to keep supporting until all userspaces stop
7633 ++ * using the wrong command number.
7634 ++ */
7635 ++#define SECCOMP_IOCTL_NOTIF_ID_VALID_WRONG_DIR SECCOMP_IOR(2, __u64)
7636 ++
7637 + enum notify_state {
7638 + SECCOMP_NOTIFY_INIT,
7639 + SECCOMP_NOTIFY_SENT,
7640 +@@ -1168,6 +1176,7 @@ static long seccomp_notify_ioctl(struct file *file, unsigned int cmd,
7641 + return seccomp_notify_recv(filter, buf);
7642 + case SECCOMP_IOCTL_NOTIF_SEND:
7643 + return seccomp_notify_send(filter, buf);
7644 ++ case SECCOMP_IOCTL_NOTIF_ID_VALID_WRONG_DIR:
7645 + case SECCOMP_IOCTL_NOTIF_ID_VALID:
7646 + return seccomp_notify_id_valid(filter, buf);
7647 + default:
7648 +diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
7649 +index eaee960153e1..a4c8f9d9522e 100644
7650 +--- a/kernel/trace/blktrace.c
7651 ++++ b/kernel/trace/blktrace.c
7652 +@@ -521,10 +521,18 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
7653 + if (!bt->msg_data)
7654 + goto err;
7655 +
7656 +- ret = -ENOENT;
7657 +-
7658 +- dir = debugfs_lookup(buts->name, blk_debugfs_root);
7659 +- if (!dir)
7660 ++#ifdef CONFIG_BLK_DEBUG_FS
7661 ++ /*
7662 ++ * When tracing whole make_request drivers (multiqueue) block devices,
7663 ++ * reuse the existing debugfs directory created by the block layer on
7664 ++ * init. For request-based block devices, all partitions block devices,
7665 ++ * and scsi-generic block devices we create a temporary new debugfs
7666 ++ * directory that will be removed once the trace ends.
7667 ++ */
7668 ++ if (queue_is_mq(q) && bdev && bdev == bdev->bd_contains)
7669 ++ dir = q->debugfs_dir;
7670 ++ else
7671 ++#endif
7672 + bt->dir = dir = debugfs_create_dir(buts->name, blk_debugfs_root);
7673 +
7674 + bt->dev = dev;
7675 +@@ -565,8 +573,6 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
7676 +
7677 + ret = 0;
7678 + err:
7679 +- if (dir && !bt->dir)
7680 +- dput(dir);
7681 + if (ret)
7682 + blk_trace_free(bt);
7683 + return ret;
7684 +diff --git a/lib/crc-t10dif.c b/lib/crc-t10dif.c
7685 +index 8cc01a603416..c9acf1c12cfc 100644
7686 +--- a/lib/crc-t10dif.c
7687 ++++ b/lib/crc-t10dif.c
7688 +@@ -19,39 +19,46 @@
7689 + static struct crypto_shash __rcu *crct10dif_tfm;
7690 + static struct static_key crct10dif_fallback __read_mostly;
7691 + static DEFINE_MUTEX(crc_t10dif_mutex);
7692 ++static struct work_struct crct10dif_rehash_work;
7693 +
7694 +-static int crc_t10dif_rehash(struct notifier_block *self, unsigned long val, void *data)
7695 ++static int crc_t10dif_notify(struct notifier_block *self, unsigned long val, void *data)
7696 + {
7697 + struct crypto_alg *alg = data;
7698 +- struct crypto_shash *new, *old;
7699 +
7700 + if (val != CRYPTO_MSG_ALG_LOADED ||
7701 + static_key_false(&crct10dif_fallback) ||
7702 + strncmp(alg->cra_name, CRC_T10DIF_STRING, strlen(CRC_T10DIF_STRING)))
7703 + return 0;
7704 +
7705 ++ schedule_work(&crct10dif_rehash_work);
7706 ++ return 0;
7707 ++}
7708 ++
7709 ++static void crc_t10dif_rehash(struct work_struct *work)
7710 ++{
7711 ++ struct crypto_shash *new, *old;
7712 ++
7713 + mutex_lock(&crc_t10dif_mutex);
7714 + old = rcu_dereference_protected(crct10dif_tfm,
7715 + lockdep_is_held(&crc_t10dif_mutex));
7716 + if (!old) {
7717 + mutex_unlock(&crc_t10dif_mutex);
7718 +- return 0;
7719 ++ return;
7720 + }
7721 + new = crypto_alloc_shash("crct10dif", 0, 0);
7722 + if (IS_ERR(new)) {
7723 + mutex_unlock(&crc_t10dif_mutex);
7724 +- return 0;
7725 ++ return;
7726 + }
7727 + rcu_assign_pointer(crct10dif_tfm, new);
7728 + mutex_unlock(&crc_t10dif_mutex);
7729 +
7730 + synchronize_rcu();
7731 + crypto_free_shash(old);
7732 +- return 0;
7733 + }
7734 +
7735 + static struct notifier_block crc_t10dif_nb = {
7736 +- .notifier_call = crc_t10dif_rehash,
7737 ++ .notifier_call = crc_t10dif_notify,
7738 + };
7739 +
7740 + __u16 crc_t10dif_update(__u16 crc, const unsigned char *buffer, size_t len)
7741 +@@ -86,19 +93,26 @@ EXPORT_SYMBOL(crc_t10dif);
7742 +
7743 + static int __init crc_t10dif_mod_init(void)
7744 + {
7745 ++ struct crypto_shash *tfm;
7746 ++
7747 ++ INIT_WORK(&crct10dif_rehash_work, crc_t10dif_rehash);
7748 + crypto_register_notifier(&crc_t10dif_nb);
7749 +- crct10dif_tfm = crypto_alloc_shash("crct10dif", 0, 0);
7750 +- if (IS_ERR(crct10dif_tfm)) {
7751 ++ mutex_lock(&crc_t10dif_mutex);
7752 ++ tfm = crypto_alloc_shash("crct10dif", 0, 0);
7753 ++ if (IS_ERR(tfm)) {
7754 + static_key_slow_inc(&crct10dif_fallback);
7755 +- crct10dif_tfm = NULL;
7756 ++ tfm = NULL;
7757 + }
7758 ++ RCU_INIT_POINTER(crct10dif_tfm, tfm);
7759 ++ mutex_unlock(&crc_t10dif_mutex);
7760 + return 0;
7761 + }
7762 +
7763 + static void __exit crc_t10dif_mod_fini(void)
7764 + {
7765 + crypto_unregister_notifier(&crc_t10dif_nb);
7766 +- crypto_free_shash(crct10dif_tfm);
7767 ++ cancel_work_sync(&crct10dif_rehash_work);
7768 ++ crypto_free_shash(rcu_dereference_protected(crct10dif_tfm, 1));
7769 + }
7770 +
7771 + module_init(crc_t10dif_mod_init);
7772 +@@ -106,11 +120,27 @@ module_exit(crc_t10dif_mod_fini);
7773 +
7774 + static int crc_t10dif_transform_show(char *buffer, const struct kernel_param *kp)
7775 + {
7776 ++ struct crypto_shash *tfm;
7777 ++ const char *name;
7778 ++ int len;
7779 ++
7780 + if (static_key_false(&crct10dif_fallback))
7781 + return sprintf(buffer, "fallback\n");
7782 +
7783 +- return sprintf(buffer, "%s\n",
7784 +- crypto_tfm_alg_driver_name(crypto_shash_tfm(crct10dif_tfm)));
7785 ++ rcu_read_lock();
7786 ++ tfm = rcu_dereference(crct10dif_tfm);
7787 ++ if (!tfm) {
7788 ++ len = sprintf(buffer, "init\n");
7789 ++ goto unlock;
7790 ++ }
7791 ++
7792 ++ name = crypto_tfm_alg_driver_name(crypto_shash_tfm(tfm));
7793 ++ len = sprintf(buffer, "%s\n", name);
7794 ++
7795 ++unlock:
7796 ++ rcu_read_unlock();
7797 ++
7798 ++ return len;
7799 + }
7800 +
7801 + module_param_call(transform, NULL, crc_t10dif_transform_show, NULL, 0644);
7802 +diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
7803 +index c60409138e13..ccf05719b1ad 100644
7804 +--- a/lib/dynamic_debug.c
7805 ++++ b/lib/dynamic_debug.c
7806 +@@ -87,22 +87,22 @@ static struct { unsigned flag:8; char opt_char; } opt_array[] = {
7807 + { _DPRINTK_FLAGS_NONE, '_' },
7808 + };
7809 +
7810 ++struct flagsbuf { char buf[ARRAY_SIZE(opt_array)+1]; };
7811 ++
7812 + /* format a string into buf[] which describes the _ddebug's flags */
7813 +-static char *ddebug_describe_flags(struct _ddebug *dp, char *buf,
7814 +- size_t maxlen)
7815 ++static char *ddebug_describe_flags(unsigned int flags, struct flagsbuf *fb)
7816 + {
7817 +- char *p = buf;
7818 ++ char *p = fb->buf;
7819 + int i;
7820 +
7821 +- BUG_ON(maxlen < 6);
7822 + for (i = 0; i < ARRAY_SIZE(opt_array); ++i)
7823 +- if (dp->flags & opt_array[i].flag)
7824 ++ if (flags & opt_array[i].flag)
7825 + *p++ = opt_array[i].opt_char;
7826 +- if (p == buf)
7827 ++ if (p == fb->buf)
7828 + *p++ = '_';
7829 + *p = '\0';
7830 +
7831 +- return buf;
7832 ++ return fb->buf;
7833 + }
7834 +
7835 + #define vpr_info(fmt, ...) \
7836 +@@ -144,7 +144,7 @@ static int ddebug_change(const struct ddebug_query *query,
7837 + struct ddebug_table *dt;
7838 + unsigned int newflags;
7839 + unsigned int nfound = 0;
7840 +- char flagbuf[10];
7841 ++ struct flagsbuf fbuf;
7842 +
7843 + /* search for matching ddebugs */
7844 + mutex_lock(&ddebug_lock);
7845 +@@ -201,8 +201,7 @@ static int ddebug_change(const struct ddebug_query *query,
7846 + vpr_info("changed %s:%d [%s]%s =%s\n",
7847 + trim_prefix(dp->filename), dp->lineno,
7848 + dt->mod_name, dp->function,
7849 +- ddebug_describe_flags(dp, flagbuf,
7850 +- sizeof(flagbuf)));
7851 ++ ddebug_describe_flags(dp->flags, &fbuf));
7852 + }
7853 + }
7854 + mutex_unlock(&ddebug_lock);
7855 +@@ -816,7 +815,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
7856 + {
7857 + struct ddebug_iter *iter = m->private;
7858 + struct _ddebug *dp = p;
7859 +- char flagsbuf[10];
7860 ++ struct flagsbuf flags;
7861 +
7862 + vpr_info("called m=%p p=%p\n", m, p);
7863 +
7864 +@@ -829,7 +828,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
7865 + seq_printf(m, "%s:%u [%s]%s =%s \"",
7866 + trim_prefix(dp->filename), dp->lineno,
7867 + iter->table->mod_name, dp->function,
7868 +- ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf)));
7869 ++ ddebug_describe_flags(dp->flags, &flags));
7870 + seq_escape(m, dp->format, "\t\r\n\"");
7871 + seq_puts(m, "\"\n");
7872 +
7873 +diff --git a/lib/kobject.c b/lib/kobject.c
7874 +index 83198cb37d8d..386873bdd51c 100644
7875 +--- a/lib/kobject.c
7876 ++++ b/lib/kobject.c
7877 +@@ -599,14 +599,7 @@ out:
7878 + }
7879 + EXPORT_SYMBOL_GPL(kobject_move);
7880 +
7881 +-/**
7882 +- * kobject_del() - Unlink kobject from hierarchy.
7883 +- * @kobj: object.
7884 +- *
7885 +- * This is the function that should be called to delete an object
7886 +- * successfully added via kobject_add().
7887 +- */
7888 +-void kobject_del(struct kobject *kobj)
7889 ++static void __kobject_del(struct kobject *kobj)
7890 + {
7891 + struct kernfs_node *sd;
7892 + const struct kobj_type *ktype;
7893 +@@ -625,9 +618,23 @@ void kobject_del(struct kobject *kobj)
7894 +
7895 + kobj->state_in_sysfs = 0;
7896 + kobj_kset_leave(kobj);
7897 +- kobject_put(kobj->parent);
7898 + kobj->parent = NULL;
7899 + }
7900 ++
7901 ++/**
7902 ++ * kobject_del() - Unlink kobject from hierarchy.
7903 ++ * @kobj: object.
7904 ++ *
7905 ++ * This is the function that should be called to delete an object
7906 ++ * successfully added via kobject_add().
7907 ++ */
7908 ++void kobject_del(struct kobject *kobj)
7909 ++{
7910 ++ struct kobject *parent = kobj->parent;
7911 ++
7912 ++ __kobject_del(kobj);
7913 ++ kobject_put(parent);
7914 ++}
7915 + EXPORT_SYMBOL(kobject_del);
7916 +
7917 + /**
7918 +@@ -663,6 +670,7 @@ EXPORT_SYMBOL(kobject_get_unless_zero);
7919 + */
7920 + static void kobject_cleanup(struct kobject *kobj)
7921 + {
7922 ++ struct kobject *parent = kobj->parent;
7923 + struct kobj_type *t = get_ktype(kobj);
7924 + const char *name = kobj->name;
7925 +
7926 +@@ -684,7 +692,10 @@ static void kobject_cleanup(struct kobject *kobj)
7927 + if (kobj->state_in_sysfs) {
7928 + pr_debug("kobject: '%s' (%p): auto cleanup kobject_del\n",
7929 + kobject_name(kobj), kobj);
7930 +- kobject_del(kobj);
7931 ++ __kobject_del(kobj);
7932 ++ } else {
7933 ++ /* avoid dropping the parent reference unnecessarily */
7934 ++ parent = NULL;
7935 + }
7936 +
7937 + if (t && t->release) {
7938 +@@ -698,6 +709,8 @@ static void kobject_cleanup(struct kobject *kobj)
7939 + pr_debug("kobject: '%s': free name\n", name);
7940 + kfree_const(name);
7941 + }
7942 ++
7943 ++ kobject_put(parent);
7944 + }
7945 +
7946 + #ifdef CONFIG_DEBUG_KOBJECT_RELEASE
7947 +diff --git a/mm/mmap.c b/mm/mmap.c
7948 +index ea1ba2db4f4f..a3584a90c55c 100644
7949 +--- a/mm/mmap.c
7950 ++++ b/mm/mmap.c
7951 +@@ -3172,6 +3172,7 @@ void exit_mmap(struct mm_struct *mm)
7952 + if (vma->vm_flags & VM_ACCOUNT)
7953 + nr_accounted += vma_pages(vma);
7954 + vma = remove_vma(vma);
7955 ++ cond_resched();
7956 + }
7957 + vm_unacct_memory(nr_accounted);
7958 + }
7959 +diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
7960 +index 4febc82a7c76..52fb6d6d6d58 100644
7961 +--- a/net/bluetooth/6lowpan.c
7962 ++++ b/net/bluetooth/6lowpan.c
7963 +@@ -50,6 +50,7 @@ static bool enable_6lowpan;
7964 + /* We are listening incoming connections via this channel
7965 + */
7966 + static struct l2cap_chan *listen_chan;
7967 ++static DEFINE_MUTEX(set_lock);
7968 +
7969 + struct lowpan_peer {
7970 + struct list_head list;
7971 +@@ -1070,12 +1071,14 @@ static void do_enable_set(struct work_struct *work)
7972 +
7973 + enable_6lowpan = set_enable->flag;
7974 +
7975 ++ mutex_lock(&set_lock);
7976 + if (listen_chan) {
7977 + l2cap_chan_close(listen_chan, 0);
7978 + l2cap_chan_put(listen_chan);
7979 + }
7980 +
7981 + listen_chan = bt_6lowpan_listen();
7982 ++ mutex_unlock(&set_lock);
7983 +
7984 + kfree(set_enable);
7985 + }
7986 +@@ -1127,11 +1130,13 @@ static ssize_t lowpan_control_write(struct file *fp,
7987 + if (ret == -EINVAL)
7988 + return ret;
7989 +
7990 ++ mutex_lock(&set_lock);
7991 + if (listen_chan) {
7992 + l2cap_chan_close(listen_chan, 0);
7993 + l2cap_chan_put(listen_chan);
7994 + listen_chan = NULL;
7995 + }
7996 ++ mutex_unlock(&set_lock);
7997 +
7998 + if (conn) {
7999 + struct lowpan_peer *peer;
8000 +diff --git a/net/core/sock.c b/net/core/sock.c
8001 +index 33a232974374..991ab80234ce 100644
8002 +--- a/net/core/sock.c
8003 ++++ b/net/core/sock.c
8004 +@@ -3337,6 +3337,16 @@ static void sock_inuse_add(struct net *net, int val)
8005 + }
8006 + #endif
8007 +
8008 ++static void tw_prot_cleanup(struct timewait_sock_ops *twsk_prot)
8009 ++{
8010 ++ if (!twsk_prot)
8011 ++ return;
8012 ++ kfree(twsk_prot->twsk_slab_name);
8013 ++ twsk_prot->twsk_slab_name = NULL;
8014 ++ kmem_cache_destroy(twsk_prot->twsk_slab);
8015 ++ twsk_prot->twsk_slab = NULL;
8016 ++}
8017 ++
8018 + static void req_prot_cleanup(struct request_sock_ops *rsk_prot)
8019 + {
8020 + if (!rsk_prot)
8021 +@@ -3407,7 +3417,7 @@ int proto_register(struct proto *prot, int alloc_slab)
8022 + prot->slab_flags,
8023 + NULL);
8024 + if (prot->twsk_prot->twsk_slab == NULL)
8025 +- goto out_free_timewait_sock_slab_name;
8026 ++ goto out_free_timewait_sock_slab;
8027 + }
8028 + }
8029 +
8030 +@@ -3415,15 +3425,15 @@ int proto_register(struct proto *prot, int alloc_slab)
8031 + ret = assign_proto_idx(prot);
8032 + if (ret) {
8033 + mutex_unlock(&proto_list_mutex);
8034 +- goto out_free_timewait_sock_slab_name;
8035 ++ goto out_free_timewait_sock_slab;
8036 + }
8037 + list_add(&prot->node, &proto_list);
8038 + mutex_unlock(&proto_list_mutex);
8039 + return ret;
8040 +
8041 +-out_free_timewait_sock_slab_name:
8042 ++out_free_timewait_sock_slab:
8043 + if (alloc_slab && prot->twsk_prot)
8044 +- kfree(prot->twsk_prot->twsk_slab_name);
8045 ++ tw_prot_cleanup(prot->twsk_prot);
8046 + out_free_request_sock_slab:
8047 + if (alloc_slab) {
8048 + req_prot_cleanup(prot->rsk_prot);
8049 +@@ -3447,12 +3457,7 @@ void proto_unregister(struct proto *prot)
8050 + prot->slab = NULL;
8051 +
8052 + req_prot_cleanup(prot->rsk_prot);
8053 +-
8054 +- if (prot->twsk_prot != NULL && prot->twsk_prot->twsk_slab != NULL) {
8055 +- kmem_cache_destroy(prot->twsk_prot->twsk_slab);
8056 +- kfree(prot->twsk_prot->twsk_slab_name);
8057 +- prot->twsk_prot->twsk_slab = NULL;
8058 +- }
8059 ++ tw_prot_cleanup(prot->twsk_prot);
8060 + }
8061 + EXPORT_SYMBOL(proto_unregister);
8062 +
8063 +diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
8064 +index 5e486895d67c..9745c52f49ca 100644
8065 +--- a/net/ipv4/inet_connection_sock.c
8066 ++++ b/net/ipv4/inet_connection_sock.c
8067 +@@ -284,6 +284,57 @@ static inline int sk_reuseport_match(struct inet_bind_bucket *tb,
8068 + ipv6_only_sock(sk), true, false);
8069 + }
8070 +
8071 ++void inet_csk_update_fastreuse(struct inet_bind_bucket *tb,
8072 ++ struct sock *sk)
8073 ++{
8074 ++ kuid_t uid = sock_i_uid(sk);
8075 ++ bool reuse = sk->sk_reuse && sk->sk_state != TCP_LISTEN;
8076 ++
8077 ++ if (hlist_empty(&tb->owners)) {
8078 ++ tb->fastreuse = reuse;
8079 ++ if (sk->sk_reuseport) {
8080 ++ tb->fastreuseport = FASTREUSEPORT_ANY;
8081 ++ tb->fastuid = uid;
8082 ++ tb->fast_rcv_saddr = sk->sk_rcv_saddr;
8083 ++ tb->fast_ipv6_only = ipv6_only_sock(sk);
8084 ++ tb->fast_sk_family = sk->sk_family;
8085 ++#if IS_ENABLED(CONFIG_IPV6)
8086 ++ tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
8087 ++#endif
8088 ++ } else {
8089 ++ tb->fastreuseport = 0;
8090 ++ }
8091 ++ } else {
8092 ++ if (!reuse)
8093 ++ tb->fastreuse = 0;
8094 ++ if (sk->sk_reuseport) {
8095 ++ /* We didn't match or we don't have fastreuseport set on
8096 ++ * the tb, but we have sk_reuseport set on this socket
8097 ++ * and we know that there are no bind conflicts with
8098 ++ * this socket in this tb, so reset our tb's reuseport
8099 ++ * settings so that any subsequent sockets that match
8100 ++ * our current socket will be put on the fast path.
8101 ++ *
8102 ++ * If we reset we need to set FASTREUSEPORT_STRICT so we
8103 ++ * do extra checking for all subsequent sk_reuseport
8104 ++ * socks.
8105 ++ */
8106 ++ if (!sk_reuseport_match(tb, sk)) {
8107 ++ tb->fastreuseport = FASTREUSEPORT_STRICT;
8108 ++ tb->fastuid = uid;
8109 ++ tb->fast_rcv_saddr = sk->sk_rcv_saddr;
8110 ++ tb->fast_ipv6_only = ipv6_only_sock(sk);
8111 ++ tb->fast_sk_family = sk->sk_family;
8112 ++#if IS_ENABLED(CONFIG_IPV6)
8113 ++ tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
8114 ++#endif
8115 ++ }
8116 ++ } else {
8117 ++ tb->fastreuseport = 0;
8118 ++ }
8119 ++ }
8120 ++}
8121 ++
8122 + /* Obtain a reference to a local port for the given sock,
8123 + * if snum is zero it means select any available local port.
8124 + * We try to allocate an odd port (and leave even ports for connect())
8125 +@@ -296,7 +347,6 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
8126 + struct inet_bind_hashbucket *head;
8127 + struct net *net = sock_net(sk);
8128 + struct inet_bind_bucket *tb = NULL;
8129 +- kuid_t uid = sock_i_uid(sk);
8130 + int l3mdev;
8131 +
8132 + l3mdev = inet_sk_bound_l3mdev(sk);
8133 +@@ -333,49 +383,8 @@ tb_found:
8134 + goto fail_unlock;
8135 + }
8136 + success:
8137 +- if (hlist_empty(&tb->owners)) {
8138 +- tb->fastreuse = reuse;
8139 +- if (sk->sk_reuseport) {
8140 +- tb->fastreuseport = FASTREUSEPORT_ANY;
8141 +- tb->fastuid = uid;
8142 +- tb->fast_rcv_saddr = sk->sk_rcv_saddr;
8143 +- tb->fast_ipv6_only = ipv6_only_sock(sk);
8144 +- tb->fast_sk_family = sk->sk_family;
8145 +-#if IS_ENABLED(CONFIG_IPV6)
8146 +- tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
8147 +-#endif
8148 +- } else {
8149 +- tb->fastreuseport = 0;
8150 +- }
8151 +- } else {
8152 +- if (!reuse)
8153 +- tb->fastreuse = 0;
8154 +- if (sk->sk_reuseport) {
8155 +- /* We didn't match or we don't have fastreuseport set on
8156 +- * the tb, but we have sk_reuseport set on this socket
8157 +- * and we know that there are no bind conflicts with
8158 +- * this socket in this tb, so reset our tb's reuseport
8159 +- * settings so that any subsequent sockets that match
8160 +- * our current socket will be put on the fast path.
8161 +- *
8162 +- * If we reset we need to set FASTREUSEPORT_STRICT so we
8163 +- * do extra checking for all subsequent sk_reuseport
8164 +- * socks.
8165 +- */
8166 +- if (!sk_reuseport_match(tb, sk)) {
8167 +- tb->fastreuseport = FASTREUSEPORT_STRICT;
8168 +- tb->fastuid = uid;
8169 +- tb->fast_rcv_saddr = sk->sk_rcv_saddr;
8170 +- tb->fast_ipv6_only = ipv6_only_sock(sk);
8171 +- tb->fast_sk_family = sk->sk_family;
8172 +-#if IS_ENABLED(CONFIG_IPV6)
8173 +- tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
8174 +-#endif
8175 +- }
8176 +- } else {
8177 +- tb->fastreuseport = 0;
8178 +- }
8179 +- }
8180 ++ inet_csk_update_fastreuse(tb, sk);
8181 ++
8182 + if (!inet_csk(sk)->icsk_bind_hash)
8183 + inet_bind_hash(sk, tb, port);
8184 + WARN_ON(inet_csk(sk)->icsk_bind_hash != tb);
8185 +diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
8186 +index 2bbaaf0c7176..006a34b18537 100644
8187 +--- a/net/ipv4/inet_hashtables.c
8188 ++++ b/net/ipv4/inet_hashtables.c
8189 +@@ -163,6 +163,7 @@ int __inet_inherit_port(const struct sock *sk, struct sock *child)
8190 + return -ENOMEM;
8191 + }
8192 + }
8193 ++ inet_csk_update_fastreuse(tb, child);
8194 + }
8195 + inet_bind_hash(child, tb, port);
8196 + spin_unlock(&head->lock);
8197 +diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
8198 +index 0902cb32bbad..c83a5d05aeaa 100644
8199 +--- a/net/ipv4/sysctl_net_ipv4.c
8200 ++++ b/net/ipv4/sysctl_net_ipv4.c
8201 +@@ -307,24 +307,16 @@ static int proc_tcp_fastopen_key(struct ctl_table *table, int write,
8202 + struct ctl_table tbl = { .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
8203 + 2 * TCP_FASTOPEN_KEY_MAX) +
8204 + (TCP_FASTOPEN_KEY_MAX * 5)) };
8205 +- struct tcp_fastopen_context *ctx;
8206 +- u32 user_key[TCP_FASTOPEN_KEY_MAX * 4];
8207 +- __le32 key[TCP_FASTOPEN_KEY_MAX * 4];
8208 ++ u32 user_key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(u32)];
8209 ++ __le32 key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(__le32)];
8210 + char *backup_data;
8211 +- int ret, i = 0, off = 0, n_keys = 0;
8212 ++ int ret, i = 0, off = 0, n_keys;
8213 +
8214 + tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
8215 + if (!tbl.data)
8216 + return -ENOMEM;
8217 +
8218 +- rcu_read_lock();
8219 +- ctx = rcu_dereference(net->ipv4.tcp_fastopen_ctx);
8220 +- if (ctx) {
8221 +- n_keys = tcp_fastopen_context_len(ctx);
8222 +- memcpy(&key[0], &ctx->key[0], TCP_FASTOPEN_KEY_LENGTH * n_keys);
8223 +- }
8224 +- rcu_read_unlock();
8225 +-
8226 ++ n_keys = tcp_fastopen_get_cipher(net, NULL, (u64 *)key);
8227 + if (!n_keys) {
8228 + memset(&key[0], 0, TCP_FASTOPEN_KEY_LENGTH);
8229 + n_keys = 1;
8230 +diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
8231 +index 840901154210..01ddfb4156e4 100644
8232 +--- a/net/ipv4/tcp.c
8233 ++++ b/net/ipv4/tcp.c
8234 +@@ -3527,22 +3527,14 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
8235 + return 0;
8236 +
8237 + case TCP_FASTOPEN_KEY: {
8238 +- __u8 key[TCP_FASTOPEN_KEY_BUF_LENGTH];
8239 +- struct tcp_fastopen_context *ctx;
8240 +- unsigned int key_len = 0;
8241 ++ u64 key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(u64)];
8242 ++ unsigned int key_len;
8243 +
8244 + if (get_user(len, optlen))
8245 + return -EFAULT;
8246 +
8247 +- rcu_read_lock();
8248 +- ctx = rcu_dereference(icsk->icsk_accept_queue.fastopenq.ctx);
8249 +- if (ctx) {
8250 +- key_len = tcp_fastopen_context_len(ctx) *
8251 +- TCP_FASTOPEN_KEY_LENGTH;
8252 +- memcpy(&key[0], &ctx->key[0], key_len);
8253 +- }
8254 +- rcu_read_unlock();
8255 +-
8256 ++ key_len = tcp_fastopen_get_cipher(net, icsk, key) *
8257 ++ TCP_FASTOPEN_KEY_LENGTH;
8258 + len = min_t(unsigned int, len, key_len);
8259 + if (put_user(len, optlen))
8260 + return -EFAULT;
8261 +diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
8262 +index a915ade0c818..a9971e41f31b 100644
8263 +--- a/net/ipv4/tcp_fastopen.c
8264 ++++ b/net/ipv4/tcp_fastopen.c
8265 +@@ -108,6 +108,29 @@ out:
8266 + return err;
8267 + }
8268 +
8269 ++int tcp_fastopen_get_cipher(struct net *net, struct inet_connection_sock *icsk,
8270 ++ u64 *key)
8271 ++{
8272 ++ struct tcp_fastopen_context *ctx;
8273 ++ int n_keys = 0, i;
8274 ++
8275 ++ rcu_read_lock();
8276 ++ if (icsk)
8277 ++ ctx = rcu_dereference(icsk->icsk_accept_queue.fastopenq.ctx);
8278 ++ else
8279 ++ ctx = rcu_dereference(net->ipv4.tcp_fastopen_ctx);
8280 ++ if (ctx) {
8281 ++ n_keys = tcp_fastopen_context_len(ctx);
8282 ++ for (i = 0; i < n_keys; i++) {
8283 ++ put_unaligned_le64(ctx->key[i].key[0], key + (i * 2));
8284 ++ put_unaligned_le64(ctx->key[i].key[1], key + (i * 2) + 1);
8285 ++ }
8286 ++ }
8287 ++ rcu_read_unlock();
8288 ++
8289 ++ return n_keys;
8290 ++}
8291 ++
8292 + static bool __tcp_fastopen_cookie_gen_cipher(struct request_sock *req,
8293 + struct sk_buff *syn,
8294 + const siphash_key_t *key,
8295 +diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
8296 +index 8b80ab794a92..64a05906cc0e 100644
8297 +--- a/net/netfilter/ipvs/ip_vs_core.c
8298 ++++ b/net/netfilter/ipvs/ip_vs_core.c
8299 +@@ -2061,14 +2061,14 @@ ip_vs_in(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, int
8300 +
8301 + conn_reuse_mode = sysctl_conn_reuse_mode(ipvs);
8302 + if (conn_reuse_mode && !iph.fragoffs && is_new_conn(skb, &iph) && cp) {
8303 +- bool uses_ct = false, resched = false;
8304 ++ bool old_ct = false, resched = false;
8305 +
8306 + if (unlikely(sysctl_expire_nodest_conn(ipvs)) && cp->dest &&
8307 + unlikely(!atomic_read(&cp->dest->weight))) {
8308 + resched = true;
8309 +- uses_ct = ip_vs_conn_uses_conntrack(cp, skb);
8310 ++ old_ct = ip_vs_conn_uses_old_conntrack(cp, skb);
8311 + } else if (is_new_conn_expected(cp, conn_reuse_mode)) {
8312 +- uses_ct = ip_vs_conn_uses_conntrack(cp, skb);
8313 ++ old_ct = ip_vs_conn_uses_old_conntrack(cp, skb);
8314 + if (!atomic_read(&cp->n_control)) {
8315 + resched = true;
8316 + } else {
8317 +@@ -2076,15 +2076,17 @@ ip_vs_in(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, int
8318 + * that uses conntrack while it is still
8319 + * referenced by controlled connection(s).
8320 + */
8321 +- resched = !uses_ct;
8322 ++ resched = !old_ct;
8323 + }
8324 + }
8325 +
8326 + if (resched) {
8327 ++ if (!old_ct)
8328 ++ cp->flags &= ~IP_VS_CONN_F_NFCT;
8329 + if (!atomic_read(&cp->n_control))
8330 + ip_vs_conn_expire_now(cp);
8331 + __ip_vs_conn_put(cp);
8332 +- if (uses_ct)
8333 ++ if (old_ct)
8334 + return NF_DROP;
8335 + cp = NULL;
8336 + }
8337 +diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
8338 +index ba5ffd3badd3..b5c867fe3232 100644
8339 +--- a/net/nfc/rawsock.c
8340 ++++ b/net/nfc/rawsock.c
8341 +@@ -332,10 +332,13 @@ static int rawsock_create(struct net *net, struct socket *sock,
8342 + if ((sock->type != SOCK_SEQPACKET) && (sock->type != SOCK_RAW))
8343 + return -ESOCKTNOSUPPORT;
8344 +
8345 +- if (sock->type == SOCK_RAW)
8346 ++ if (sock->type == SOCK_RAW) {
8347 ++ if (!capable(CAP_NET_RAW))
8348 ++ return -EPERM;
8349 + sock->ops = &rawsock_raw_ops;
8350 +- else
8351 ++ } else {
8352 + sock->ops = &rawsock_ops;
8353 ++ }
8354 +
8355 + sk = sk_alloc(net, PF_NFC, GFP_ATOMIC, nfc_proto->proto, kern);
8356 + if (!sk)
8357 +diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
8358 +index 1d63ab3a878a..7735340c892e 100644
8359 +--- a/net/packet/af_packet.c
8360 ++++ b/net/packet/af_packet.c
8361 +@@ -941,6 +941,7 @@ static int prb_queue_frozen(struct tpacket_kbdq_core *pkc)
8362 + }
8363 +
8364 + static void prb_clear_blk_fill_status(struct packet_ring_buffer *rb)
8365 ++ __releases(&pkc->blk_fill_in_prog_lock)
8366 + {
8367 + struct tpacket_kbdq_core *pkc = GET_PBDQC_FROM_RB(rb);
8368 + atomic_dec(&pkc->blk_fill_in_prog);
8369 +@@ -988,6 +989,7 @@ static void prb_fill_curr_block(char *curr,
8370 + struct tpacket_kbdq_core *pkc,
8371 + struct tpacket_block_desc *pbd,
8372 + unsigned int len)
8373 ++ __acquires(&pkc->blk_fill_in_prog_lock)
8374 + {
8375 + struct tpacket3_hdr *ppd;
8376 +
8377 +@@ -2285,8 +2287,11 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
8378 + if (do_vnet &&
8379 + virtio_net_hdr_from_skb(skb, h.raw + macoff -
8380 + sizeof(struct virtio_net_hdr),
8381 +- vio_le(), true, 0))
8382 ++ vio_le(), true, 0)) {
8383 ++ if (po->tp_version == TPACKET_V3)
8384 ++ prb_clear_blk_fill_status(&po->rx_ring);
8385 + goto drop_n_account;
8386 ++ }
8387 +
8388 + if (po->tp_version <= TPACKET_V2) {
8389 + packet_increment_rx_head(po, &po->rx_ring);
8390 +@@ -2392,7 +2397,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
8391 + __clear_bit(slot_id, po->rx_ring.rx_owner_map);
8392 + spin_unlock(&sk->sk_receive_queue.lock);
8393 + sk->sk_data_ready(sk);
8394 +- } else {
8395 ++ } else if (po->tp_version == TPACKET_V3) {
8396 + prb_clear_blk_fill_status(&po->rx_ring);
8397 + }
8398 +
8399 +diff --git a/net/socket.c b/net/socket.c
8400 +index 432800b39ddb..d1a0264401b7 100644
8401 +--- a/net/socket.c
8402 ++++ b/net/socket.c
8403 +@@ -485,7 +485,7 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed)
8404 + if (f.file) {
8405 + sock = sock_from_file(f.file, err);
8406 + if (likely(sock)) {
8407 +- *fput_needed = f.flags;
8408 ++ *fput_needed = f.flags & FDPUT_FPUT;
8409 + return sock;
8410 + }
8411 + fdput(f);
8412 +diff --git a/net/sunrpc/auth_gss/gss_krb5_wrap.c b/net/sunrpc/auth_gss/gss_krb5_wrap.c
8413 +index 683755d95075..78ad41656996 100644
8414 +--- a/net/sunrpc/auth_gss/gss_krb5_wrap.c
8415 ++++ b/net/sunrpc/auth_gss/gss_krb5_wrap.c
8416 +@@ -584,7 +584,7 @@ gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, int len,
8417 + buf->head[0].iov_len);
8418 + memmove(ptr, ptr + GSS_KRB5_TOK_HDR_LEN + headskip, movelen);
8419 + buf->head[0].iov_len -= GSS_KRB5_TOK_HDR_LEN + headskip;
8420 +- buf->len = len - GSS_KRB5_TOK_HDR_LEN + headskip;
8421 ++ buf->len = len - (GSS_KRB5_TOK_HDR_LEN + headskip);
8422 +
8423 + /* Trim off the trailing "extra count" and checksum blob */
8424 + xdr_buf_trim(buf, ec + GSS_KRB5_TOK_HDR_LEN + tailskip);
8425 +diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
8426 +index fd91274e834d..3645cd241d3e 100644
8427 +--- a/net/sunrpc/auth_gss/svcauth_gss.c
8428 ++++ b/net/sunrpc/auth_gss/svcauth_gss.c
8429 +@@ -949,7 +949,6 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
8430 +
8431 + maj_stat = gss_unwrap(ctx, 0, priv_len, buf);
8432 + pad = priv_len - buf->len;
8433 +- buf->len -= pad;
8434 + /* The upper layers assume the buffer is aligned on 4-byte boundaries.
8435 + * In the krb5p case, at least, the data ends up offset, so we need to
8436 + * move it around. */
8437 +diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c
8438 +index 066af6b2eb01..0bb3f0dca80d 100644
8439 +--- a/net/sunrpc/xprtrdma/svc_rdma_rw.c
8440 ++++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c
8441 +@@ -677,7 +677,6 @@ static int svc_rdma_build_read_chunk(struct svc_rqst *rqstp,
8442 + struct svc_rdma_read_info *info,
8443 + __be32 *p)
8444 + {
8445 +- unsigned int i;
8446 + int ret;
8447 +
8448 + ret = -EINVAL;
8449 +@@ -700,12 +699,6 @@ static int svc_rdma_build_read_chunk(struct svc_rqst *rqstp,
8450 + info->ri_chunklen += rs_length;
8451 + }
8452 +
8453 +- /* Pages under I/O have been copied to head->rc_pages.
8454 +- * Prevent their premature release by svc_xprt_release() .
8455 +- */
8456 +- for (i = 0; i < info->ri_readctxt->rc_page_count; i++)
8457 +- rqstp->rq_pages[i] = NULL;
8458 +-
8459 + return ret;
8460 + }
8461 +
8462 +@@ -800,6 +793,26 @@ out:
8463 + return ret;
8464 + }
8465 +
8466 ++/* Pages under I/O have been copied to head->rc_pages. Ensure they
8467 ++ * are not released by svc_xprt_release() until the I/O is complete.
8468 ++ *
8469 ++ * This has to be done after all Read WRs are constructed to properly
8470 ++ * handle a page that is part of I/O on behalf of two different RDMA
8471 ++ * segments.
8472 ++ *
8473 ++ * Do this only if I/O has been posted. Otherwise, we do indeed want
8474 ++ * svc_xprt_release() to clean things up properly.
8475 ++ */
8476 ++static void svc_rdma_save_io_pages(struct svc_rqst *rqstp,
8477 ++ const unsigned int start,
8478 ++ const unsigned int num_pages)
8479 ++{
8480 ++ unsigned int i;
8481 ++
8482 ++ for (i = start; i < num_pages + start; i++)
8483 ++ rqstp->rq_pages[i] = NULL;
8484 ++}
8485 ++
8486 + /**
8487 + * svc_rdma_recv_read_chunk - Pull a Read chunk from the client
8488 + * @rdma: controlling RDMA transport
8489 +@@ -853,6 +866,7 @@ int svc_rdma_recv_read_chunk(struct svcxprt_rdma *rdma, struct svc_rqst *rqstp,
8490 + ret = svc_rdma_post_chunk_ctxt(&info->ri_cc);
8491 + if (ret < 0)
8492 + goto out_err;
8493 ++ svc_rdma_save_io_pages(rqstp, 0, head->rc_page_count);
8494 + return 0;
8495 +
8496 + out_err:
8497 +diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
8498 +index 1adeb1c0473b..25fca390cdcf 100644
8499 +--- a/net/tls/tls_device.c
8500 ++++ b/net/tls/tls_device.c
8501 +@@ -549,7 +549,7 @@ int tls_device_sendpage(struct sock *sk, struct page *page,
8502 + {
8503 + struct tls_context *tls_ctx = tls_get_ctx(sk);
8504 + struct iov_iter msg_iter;
8505 +- char *kaddr = kmap(page);
8506 ++ char *kaddr;
8507 + struct kvec iov;
8508 + int rc;
8509 +
8510 +@@ -564,6 +564,7 @@ int tls_device_sendpage(struct sock *sk, struct page *page,
8511 + goto out;
8512 + }
8513 +
8514 ++ kaddr = kmap(page);
8515 + iov.iov_base = kaddr + offset;
8516 + iov.iov_len = size;
8517 + iov_iter_kvec(&msg_iter, WRITE, &iov, 1, size);
8518 +diff --git a/samples/bpf/fds_example.c b/samples/bpf/fds_example.c
8519 +index 2d4b717726b6..34b3fca788e8 100644
8520 +--- a/samples/bpf/fds_example.c
8521 ++++ b/samples/bpf/fds_example.c
8522 +@@ -30,6 +30,8 @@
8523 + #define BPF_M_MAP 1
8524 + #define BPF_M_PROG 2
8525 +
8526 ++char bpf_log_buf[BPF_LOG_BUF_SIZE];
8527 ++
8528 + static void usage(void)
8529 + {
8530 + printf("Usage: fds_example [...]\n");
8531 +@@ -57,7 +59,6 @@ static int bpf_prog_create(const char *object)
8532 + BPF_EXIT_INSN(),
8533 + };
8534 + size_t insns_cnt = sizeof(insns) / sizeof(struct bpf_insn);
8535 +- char bpf_log_buf[BPF_LOG_BUF_SIZE];
8536 + struct bpf_object *obj;
8537 + int prog_fd;
8538 +
8539 +diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
8540 +index 7225107a9aaf..e59022b3f125 100644
8541 +--- a/scripts/recordmcount.c
8542 ++++ b/scripts/recordmcount.c
8543 +@@ -434,6 +434,11 @@ static int arm_is_fake_mcount(Elf32_Rel const *rp)
8544 + return 1;
8545 + }
8546 +
8547 ++static int arm64_is_fake_mcount(Elf64_Rel const *rp)
8548 ++{
8549 ++ return ELF64_R_TYPE(w(rp->r_info)) != R_AARCH64_CALL26;
8550 ++}
8551 ++
8552 + /* 64-bit EM_MIPS has weird ELF64_Rela.r_info.
8553 + * http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf
8554 + * We interpret Table 29 Relocation Operation (Elf64_Rel, Elf64_Rela) [p.40]
8555 +@@ -547,6 +552,7 @@ static int do_file(char const *const fname)
8556 + make_nop = make_nop_arm64;
8557 + rel_type_nop = R_AARCH64_NONE;
8558 + ideal_nop = ideal_nop4_arm64;
8559 ++ is_fake_mcount64 = arm64_is_fake_mcount;
8560 + break;
8561 + case EM_IA_64: reltype = R_IA64_IMM64; break;
8562 + case EM_MIPS: /* reltype: e_class */ break;
8563 +diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
8564 +index be469fce19e1..8173982e00ab 100644
8565 +--- a/security/integrity/ima/ima.h
8566 ++++ b/security/integrity/ima/ima.h
8567 +@@ -362,6 +362,7 @@ static inline void ima_free_modsig(struct modsig *modsig)
8568 + #ifdef CONFIG_IMA_LSM_RULES
8569 +
8570 + #define security_filter_rule_init security_audit_rule_init
8571 ++#define security_filter_rule_free security_audit_rule_free
8572 + #define security_filter_rule_match security_audit_rule_match
8573 +
8574 + #else
8575 +@@ -372,6 +373,10 @@ static inline int security_filter_rule_init(u32 field, u32 op, char *rulestr,
8576 + return -EINVAL;
8577 + }
8578 +
8579 ++static inline void security_filter_rule_free(void *lsmrule)
8580 ++{
8581 ++}
8582 ++
8583 + static inline int security_filter_rule_match(u32 secid, u32 field, u32 op,
8584 + void *lsmrule)
8585 + {
8586 +diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
8587 +index 558a7607bf93..e725d4187271 100644
8588 +--- a/security/integrity/ima/ima_policy.c
8589 ++++ b/security/integrity/ima/ima_policy.c
8590 +@@ -254,7 +254,7 @@ static void ima_lsm_free_rule(struct ima_rule_entry *entry)
8591 + int i;
8592 +
8593 + for (i = 0; i < MAX_LSM_RULES; i++) {
8594 +- kfree(entry->lsm[i].rule);
8595 ++ security_filter_rule_free(entry->lsm[i].rule);
8596 + kfree(entry->lsm[i].args_p);
8597 + }
8598 + kfree(entry);
8599 +diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
8600 +index 840a192e9337..9c4308077574 100644
8601 +--- a/security/smack/smackfs.c
8602 ++++ b/security/smack/smackfs.c
8603 +@@ -884,7 +884,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
8604 + }
8605 +
8606 + ret = sscanf(rule, "%d", &maplevel);
8607 +- if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL)
8608 ++ if (ret != 1 || maplevel < 0 || maplevel > SMACK_CIPSO_MAXLEVEL)
8609 + goto out;
8610 +
8611 + rule += SMK_DIGITLEN;
8612 +@@ -905,6 +905,10 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
8613 +
8614 + for (i = 0; i < catlen; i++) {
8615 + rule += SMK_DIGITLEN;
8616 ++ if (rule > data + count) {
8617 ++ rc = -EOVERFLOW;
8618 ++ goto out;
8619 ++ }
8620 + ret = sscanf(rule, "%u", &cat);
8621 + if (ret != 1 || cat > SMACK_CIPSO_MAXCATNUM)
8622 + goto out;
8623 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
8624 +index ea25b8d0350d..88629906f314 100644
8625 +--- a/sound/pci/hda/patch_realtek.c
8626 ++++ b/sound/pci/hda/patch_realtek.c
8627 +@@ -4391,6 +4391,7 @@ static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
8628 + {
8629 + struct alc_spec *spec = codec->spec;
8630 +
8631 ++ spec->micmute_led_polarity = 1;
8632 + alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
8633 + if (action == HDA_FIXUP_ACT_PRE_PROBE) {
8634 + spec->init_amp = ALC_INIT_DEFAULT;
8635 +diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
8636 +index 41b83ecaf008..914b75c23d1b 100644
8637 +--- a/sound/soc/fsl/fsl_sai.c
8638 ++++ b/sound/soc/fsl/fsl_sai.c
8639 +@@ -680,10 +680,11 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai)
8640 + regmap_write(sai->regmap, FSL_SAI_RCSR(ofs), 0);
8641 +
8642 + regmap_update_bits(sai->regmap, FSL_SAI_TCR1(ofs),
8643 +- FSL_SAI_CR1_RFW_MASK,
8644 ++ FSL_SAI_CR1_RFW_MASK(sai->soc_data->fifo_depth),
8645 + sai->soc_data->fifo_depth - FSL_SAI_MAXBURST_TX);
8646 + regmap_update_bits(sai->regmap, FSL_SAI_RCR1(ofs),
8647 +- FSL_SAI_CR1_RFW_MASK, FSL_SAI_MAXBURST_RX - 1);
8648 ++ FSL_SAI_CR1_RFW_MASK(sai->soc_data->fifo_depth),
8649 ++ FSL_SAI_MAXBURST_RX - 1);
8650 +
8651 + snd_soc_dai_init_dma_data(cpu_dai, &sai->dma_params_tx,
8652 + &sai->dma_params_rx);
8653 +diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
8654 +index 76b15deea80c..6aba7d28f5f3 100644
8655 +--- a/sound/soc/fsl/fsl_sai.h
8656 ++++ b/sound/soc/fsl/fsl_sai.h
8657 +@@ -94,7 +94,7 @@
8658 + #define FSL_SAI_CSR_FRDE BIT(0)
8659 +
8660 + /* SAI Transmit and Receive Configuration 1 Register */
8661 +-#define FSL_SAI_CR1_RFW_MASK 0x1f
8662 ++#define FSL_SAI_CR1_RFW_MASK(x) ((x) - 1)
8663 +
8664 + /* SAI Transmit and Receive Configuration 2 Register */
8665 + #define FSL_SAI_CR2_SYNC BIT(30)
8666 +diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c
8667 +index adf416a49b48..60fb87495050 100644
8668 +--- a/sound/soc/intel/boards/bxt_rt298.c
8669 ++++ b/sound/soc/intel/boards/bxt_rt298.c
8670 +@@ -556,6 +556,7 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
8671 + /* broxton audio machine driver for SPT + RT298S */
8672 + static struct snd_soc_card broxton_rt298 = {
8673 + .name = "broxton-rt298",
8674 ++ .owner = THIS_MODULE,
8675 + .dai_link = broxton_rt298_dais,
8676 + .num_links = ARRAY_SIZE(broxton_rt298_dais),
8677 + .controls = broxton_controls,
8678 +@@ -571,6 +572,7 @@ static struct snd_soc_card broxton_rt298 = {
8679 +
8680 + static struct snd_soc_card geminilake_rt298 = {
8681 + .name = "geminilake-rt298",
8682 ++ .owner = THIS_MODULE,
8683 + .dai_link = broxton_rt298_dais,
8684 + .num_links = ARRAY_SIZE(broxton_rt298_dais),
8685 + .controls = broxton_controls,
8686 +diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c
8687 +index 1f698adde506..7126344017fa 100644
8688 +--- a/sound/soc/meson/axg-card.c
8689 ++++ b/sound/soc/meson/axg-card.c
8690 +@@ -266,7 +266,7 @@ static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
8691 +
8692 + lb = &card->dai_link[*index + 1];
8693 +
8694 +- lb->name = kasprintf(GFP_KERNEL, "%s-lb", pad->name);
8695 ++ lb->name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-lb", pad->name);
8696 + if (!lb->name)
8697 + return -ENOMEM;
8698 +
8699 +diff --git a/sound/soc/meson/axg-tdm-formatter.c b/sound/soc/meson/axg-tdm-formatter.c
8700 +index 358c8c0d861c..f7e8e9da68a0 100644
8701 +--- a/sound/soc/meson/axg-tdm-formatter.c
8702 ++++ b/sound/soc/meson/axg-tdm-formatter.c
8703 +@@ -70,7 +70,7 @@ EXPORT_SYMBOL_GPL(axg_tdm_formatter_set_channel_masks);
8704 + static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter)
8705 + {
8706 + struct axg_tdm_stream *ts = formatter->stream;
8707 +- bool invert = formatter->drv->quirks->invert_sclk;
8708 ++ bool invert;
8709 + int ret;
8710 +
8711 + /* Do nothing if the formatter is already enabled */
8712 +@@ -96,11 +96,12 @@ static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter)
8713 + return ret;
8714 +
8715 + /*
8716 +- * If sclk is inverted, invert it back and provide the inversion
8717 +- * required by the formatter
8718 ++ * If sclk is inverted, it means the bit should latched on the
8719 ++ * rising edge which is what our HW expects. If not, we need to
8720 ++ * invert it before the formatter.
8721 + */
8722 +- invert ^= axg_tdm_sclk_invert(ts->iface->fmt);
8723 +- ret = clk_set_phase(formatter->sclk, invert ? 180 : 0);
8724 ++ invert = axg_tdm_sclk_invert(ts->iface->fmt);
8725 ++ ret = clk_set_phase(formatter->sclk, invert ? 0 : 180);
8726 + if (ret)
8727 + return ret;
8728 +
8729 +diff --git a/sound/soc/meson/axg-tdm-formatter.h b/sound/soc/meson/axg-tdm-formatter.h
8730 +index 9ef98e955cb2..a1f0dcc0ff13 100644
8731 +--- a/sound/soc/meson/axg-tdm-formatter.h
8732 ++++ b/sound/soc/meson/axg-tdm-formatter.h
8733 +@@ -16,7 +16,6 @@ struct snd_kcontrol;
8734 +
8735 + struct axg_tdm_formatter_hw {
8736 + unsigned int skew_offset;
8737 +- bool invert_sclk;
8738 + };
8739 +
8740 + struct axg_tdm_formatter_ops {
8741 +diff --git a/sound/soc/meson/axg-tdm-interface.c b/sound/soc/meson/axg-tdm-interface.c
8742 +index d51f3344be7c..e25336f73912 100644
8743 +--- a/sound/soc/meson/axg-tdm-interface.c
8744 ++++ b/sound/soc/meson/axg-tdm-interface.c
8745 +@@ -119,18 +119,25 @@ static int axg_tdm_iface_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
8746 + {
8747 + struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai);
8748 +
8749 +- /* These modes are not supported */
8750 +- if (fmt & (SND_SOC_DAIFMT_CBS_CFM | SND_SOC_DAIFMT_CBM_CFS)) {
8751 ++ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
8752 ++ case SND_SOC_DAIFMT_CBS_CFS:
8753 ++ if (!iface->mclk) {
8754 ++ dev_err(dai->dev, "cpu clock master: mclk missing\n");
8755 ++ return -ENODEV;
8756 ++ }
8757 ++ break;
8758 ++
8759 ++ case SND_SOC_DAIFMT_CBM_CFM:
8760 ++ break;
8761 ++
8762 ++ case SND_SOC_DAIFMT_CBS_CFM:
8763 ++ case SND_SOC_DAIFMT_CBM_CFS:
8764 + dev_err(dai->dev, "only CBS_CFS and CBM_CFM are supported\n");
8765 ++ /* Fall-through */
8766 ++ default:
8767 + return -EINVAL;
8768 + }
8769 +
8770 +- /* If the TDM interface is the clock master, it requires mclk */
8771 +- if (!iface->mclk && (fmt & SND_SOC_DAIFMT_CBS_CFS)) {
8772 +- dev_err(dai->dev, "cpu clock master: mclk missing\n");
8773 +- return -ENODEV;
8774 +- }
8775 +-
8776 + iface->fmt = fmt;
8777 + return 0;
8778 + }
8779 +@@ -319,7 +326,8 @@ static int axg_tdm_iface_hw_params(struct snd_pcm_substream *substream,
8780 + if (ret)
8781 + return ret;
8782 +
8783 +- if (iface->fmt & SND_SOC_DAIFMT_CBS_CFS) {
8784 ++ if ((iface->fmt & SND_SOC_DAIFMT_MASTER_MASK) ==
8785 ++ SND_SOC_DAIFMT_CBS_CFS) {
8786 + ret = axg_tdm_iface_set_sclk(dai, params);
8787 + if (ret)
8788 + return ret;
8789 +diff --git a/sound/soc/meson/axg-tdmin.c b/sound/soc/meson/axg-tdmin.c
8790 +index 973d4c02ef8d..88ed95ae886b 100644
8791 +--- a/sound/soc/meson/axg-tdmin.c
8792 ++++ b/sound/soc/meson/axg-tdmin.c
8793 +@@ -228,15 +228,29 @@ static const struct axg_tdm_formatter_driver axg_tdmin_drv = {
8794 + .regmap_cfg = &axg_tdmin_regmap_cfg,
8795 + .ops = &axg_tdmin_ops,
8796 + .quirks = &(const struct axg_tdm_formatter_hw) {
8797 +- .invert_sclk = false,
8798 + .skew_offset = 2,
8799 + },
8800 + };
8801 +
8802 ++static const struct axg_tdm_formatter_driver g12a_tdmin_drv = {
8803 ++ .component_drv = &axg_tdmin_component_drv,
8804 ++ .regmap_cfg = &axg_tdmin_regmap_cfg,
8805 ++ .ops = &axg_tdmin_ops,
8806 ++ .quirks = &(const struct axg_tdm_formatter_hw) {
8807 ++ .skew_offset = 3,
8808 ++ },
8809 ++};
8810 ++
8811 + static const struct of_device_id axg_tdmin_of_match[] = {
8812 + {
8813 + .compatible = "amlogic,axg-tdmin",
8814 + .data = &axg_tdmin_drv,
8815 ++ }, {
8816 ++ .compatible = "amlogic,g12a-tdmin",
8817 ++ .data = &g12a_tdmin_drv,
8818 ++ }, {
8819 ++ .compatible = "amlogic,sm1-tdmin",
8820 ++ .data = &g12a_tdmin_drv,
8821 + }, {}
8822 + };
8823 + MODULE_DEVICE_TABLE(of, axg_tdmin_of_match);
8824 +diff --git a/sound/soc/meson/axg-tdmout.c b/sound/soc/meson/axg-tdmout.c
8825 +index 418ec314b37d..3ceabddae629 100644
8826 +--- a/sound/soc/meson/axg-tdmout.c
8827 ++++ b/sound/soc/meson/axg-tdmout.c
8828 +@@ -238,7 +238,6 @@ static const struct axg_tdm_formatter_driver axg_tdmout_drv = {
8829 + .regmap_cfg = &axg_tdmout_regmap_cfg,
8830 + .ops = &axg_tdmout_ops,
8831 + .quirks = &(const struct axg_tdm_formatter_hw) {
8832 +- .invert_sclk = true,
8833 + .skew_offset = 1,
8834 + },
8835 + };
8836 +@@ -248,7 +247,6 @@ static const struct axg_tdm_formatter_driver g12a_tdmout_drv = {
8837 + .regmap_cfg = &axg_tdmout_regmap_cfg,
8838 + .ops = &axg_tdmout_ops,
8839 + .quirks = &(const struct axg_tdm_formatter_hw) {
8840 +- .invert_sclk = true,
8841 + .skew_offset = 2,
8842 + },
8843 + };
8844 +@@ -309,7 +307,6 @@ static const struct axg_tdm_formatter_driver sm1_tdmout_drv = {
8845 + .regmap_cfg = &axg_tdmout_regmap_cfg,
8846 + .ops = &axg_tdmout_ops,
8847 + .quirks = &(const struct axg_tdm_formatter_hw) {
8848 +- .invert_sclk = true,
8849 + .skew_offset = 2,
8850 + },
8851 + };
8852 +diff --git a/sound/soc/sof/nocodec.c b/sound/soc/sof/nocodec.c
8853 +index ea0fe9a09f3f..71410116add1 100644
8854 +--- a/sound/soc/sof/nocodec.c
8855 ++++ b/sound/soc/sof/nocodec.c
8856 +@@ -14,6 +14,7 @@
8857 +
8858 + static struct snd_soc_card sof_nocodec_card = {
8859 + .name = "nocodec", /* the sof- prefix is added by the core */
8860 ++ .owner = THIS_MODULE
8861 + };
8862 +
8863 + static int sof_nocodec_bes_setup(struct device *dev,
8864 +diff --git a/sound/usb/card.h b/sound/usb/card.h
8865 +index f39f23e3525d..d8ec5caf464d 100644
8866 +--- a/sound/usb/card.h
8867 ++++ b/sound/usb/card.h
8868 +@@ -133,6 +133,7 @@ struct snd_usb_substream {
8869 + unsigned int tx_length_quirk:1; /* add length specifier to transfers */
8870 + unsigned int fmt_type; /* USB audio format type (1-3) */
8871 + unsigned int pkt_offset_adj; /* Bytes to drop from beginning of packets (for non-compliant devices) */
8872 ++ unsigned int stream_offset_adj; /* Bytes to drop from beginning of stream (for non-compliant devices) */
8873 +
8874 + unsigned int running: 1; /* running status */
8875 +
8876 +diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
8877 +index d39bf5b648d1..49f0dc0e3e4d 100644
8878 +--- a/sound/usb/mixer_quirks.c
8879 ++++ b/sound/usb/mixer_quirks.c
8880 +@@ -184,6 +184,7 @@ static const struct rc_config {
8881 + { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */
8882 + { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
8883 + { USB_ID(0x041e, 0x3237), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
8884 ++ { USB_ID(0x041e, 0x3263), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
8885 + { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
8886 + };
8887 +
8888 +diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
8889 +index d11d00efc574..7b41f9748978 100644
8890 +--- a/sound/usb/pcm.c
8891 ++++ b/sound/usb/pcm.c
8892 +@@ -1417,6 +1417,12 @@ static void retire_capture_urb(struct snd_usb_substream *subs,
8893 + // continue;
8894 + }
8895 + bytes = urb->iso_frame_desc[i].actual_length;
8896 ++ if (subs->stream_offset_adj > 0) {
8897 ++ unsigned int adj = min(subs->stream_offset_adj, bytes);
8898 ++ cp += adj;
8899 ++ bytes -= adj;
8900 ++ subs->stream_offset_adj -= adj;
8901 ++ }
8902 + frames = bytes / stride;
8903 + if (!subs->txfr_quirk)
8904 + bytes = frames * stride;
8905 +diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
8906 +index 562179492a33..1573229d8cf4 100644
8907 +--- a/sound/usb/quirks-table.h
8908 ++++ b/sound/usb/quirks-table.h
8909 +@@ -3570,6 +3570,62 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
8910 + }
8911 + }
8912 + },
8913 ++{
8914 ++ /*
8915 ++ * PIONEER DJ DDJ-RB
8916 ++ * PCM is 4 channels out, 2 dummy channels in @ 44.1 fixed
8917 ++ * The feedback for the output is the dummy input.
8918 ++ */
8919 ++ USB_DEVICE_VENDOR_SPEC(0x2b73, 0x000e),
8920 ++ .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
8921 ++ .ifnum = QUIRK_ANY_INTERFACE,
8922 ++ .type = QUIRK_COMPOSITE,
8923 ++ .data = (const struct snd_usb_audio_quirk[]) {
8924 ++ {
8925 ++ .ifnum = 0,
8926 ++ .type = QUIRK_AUDIO_FIXED_ENDPOINT,
8927 ++ .data = &(const struct audioformat) {
8928 ++ .formats = SNDRV_PCM_FMTBIT_S24_3LE,
8929 ++ .channels = 4,
8930 ++ .iface = 0,
8931 ++ .altsetting = 1,
8932 ++ .altset_idx = 1,
8933 ++ .endpoint = 0x01,
8934 ++ .ep_attr = USB_ENDPOINT_XFER_ISOC|
8935 ++ USB_ENDPOINT_SYNC_ASYNC,
8936 ++ .rates = SNDRV_PCM_RATE_44100,
8937 ++ .rate_min = 44100,
8938 ++ .rate_max = 44100,
8939 ++ .nr_rates = 1,
8940 ++ .rate_table = (unsigned int[]) { 44100 }
8941 ++ }
8942 ++ },
8943 ++ {
8944 ++ .ifnum = 0,
8945 ++ .type = QUIRK_AUDIO_FIXED_ENDPOINT,
8946 ++ .data = &(const struct audioformat) {
8947 ++ .formats = SNDRV_PCM_FMTBIT_S24_3LE,
8948 ++ .channels = 2,
8949 ++ .iface = 0,
8950 ++ .altsetting = 1,
8951 ++ .altset_idx = 1,
8952 ++ .endpoint = 0x82,
8953 ++ .ep_attr = USB_ENDPOINT_XFER_ISOC|
8954 ++ USB_ENDPOINT_SYNC_ASYNC|
8955 ++ USB_ENDPOINT_USAGE_IMPLICIT_FB,
8956 ++ .rates = SNDRV_PCM_RATE_44100,
8957 ++ .rate_min = 44100,
8958 ++ .rate_max = 44100,
8959 ++ .nr_rates = 1,
8960 ++ .rate_table = (unsigned int[]) { 44100 }
8961 ++ }
8962 ++ },
8963 ++ {
8964 ++ .ifnum = -1
8965 ++ }
8966 ++ }
8967 ++ }
8968 ++},
8969 +
8970 + #define ALC1220_VB_DESKTOP(vend, prod) { \
8971 + USB_DEVICE(vend, prod), \
8972 +@@ -3623,7 +3679,13 @@ ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* Asrock TRX40 Creator */
8973 + * with.
8974 + */
8975 + {
8976 +- USB_DEVICE(0x534d, 0x2109),
8977 ++ .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
8978 ++ USB_DEVICE_ID_MATCH_INT_CLASS |
8979 ++ USB_DEVICE_ID_MATCH_INT_SUBCLASS,
8980 ++ .idVendor = 0x534d,
8981 ++ .idProduct = 0x2109,
8982 ++ .bInterfaceClass = USB_CLASS_AUDIO,
8983 ++ .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
8984 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
8985 + .vendor_name = "MacroSilicon",
8986 + .product_name = "MS2109",
8987 +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
8988 +index a8bb953cc468..a756f50d9f07 100644
8989 +--- a/sound/usb/quirks.c
8990 ++++ b/sound/usb/quirks.c
8991 +@@ -1432,6 +1432,9 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
8992 + case USB_ID(0x041e, 0x3f19): /* E-Mu 0204 USB */
8993 + set_format_emu_quirk(subs, fmt);
8994 + break;
8995 ++ case USB_ID(0x534d, 0x2109): /* MacroSilicon MS2109 */
8996 ++ subs->stream_offset_adj = 2;
8997 ++ break;
8998 + }
8999 + }
9000 +
9001 +diff --git a/sound/usb/stream.c b/sound/usb/stream.c
9002 +index 11785f9652ad..d01edd5da6cf 100644
9003 +--- a/sound/usb/stream.c
9004 ++++ b/sound/usb/stream.c
9005 +@@ -94,6 +94,7 @@ static void snd_usb_init_substream(struct snd_usb_stream *as,
9006 + subs->tx_length_quirk = as->chip->tx_length_quirk;
9007 + subs->speed = snd_usb_get_speed(subs->dev);
9008 + subs->pkt_offset_adj = 0;
9009 ++ subs->stream_offset_adj = 0;
9010 +
9011 + snd_usb_set_pcm_ops(as->pcm, stream);
9012 +
9013 +diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
9014 +index 9a9376d1d3df..66765f970bc5 100644
9015 +--- a/tools/bpf/bpftool/btf.c
9016 ++++ b/tools/bpf/bpftool/btf.c
9017 +@@ -510,7 +510,7 @@ static int do_dump(int argc, char **argv)
9018 + goto done;
9019 + }
9020 + if (!btf) {
9021 +- err = ENOENT;
9022 ++ err = -ENOENT;
9023 + p_err("can't find btf with ID (%u)", btf_id);
9024 + goto done;
9025 + }
9026 +diff --git a/tools/build/Build.include b/tools/build/Build.include
9027 +index 9ec01f4454f9..585486e40995 100644
9028 +--- a/tools/build/Build.include
9029 ++++ b/tools/build/Build.include
9030 +@@ -74,7 +74,8 @@ dep-cmd = $(if $(wildcard $(fixdep)),
9031 + # dependencies in the cmd file
9032 + if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)), \
9033 + @set -e; \
9034 +- $(echo-cmd) $(cmd_$(1)) && $(dep-cmd))
9035 ++ $(echo-cmd) $(cmd_$(1)); \
9036 ++ $(dep-cmd))
9037 +
9038 + # if_changed - execute command if any prerequisite is newer than
9039 + # target, or command line has changed
9040 +diff --git a/tools/testing/selftests/powerpc/benchmarks/context_switch.c b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
9041 +index a2e8c9da7fa5..d50cc05df495 100644
9042 +--- a/tools/testing/selftests/powerpc/benchmarks/context_switch.c
9043 ++++ b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
9044 +@@ -19,6 +19,7 @@
9045 + #include <limits.h>
9046 + #include <sys/time.h>
9047 + #include <sys/syscall.h>
9048 ++#include <sys/sysinfo.h>
9049 + #include <sys/types.h>
9050 + #include <sys/shm.h>
9051 + #include <linux/futex.h>
9052 +@@ -104,8 +105,9 @@ static void start_thread_on(void *(*fn)(void *), void *arg, unsigned long cpu)
9053 +
9054 + static void start_process_on(void *(*fn)(void *), void *arg, unsigned long cpu)
9055 + {
9056 +- int pid;
9057 +- cpu_set_t cpuset;
9058 ++ int pid, ncpus;
9059 ++ cpu_set_t *cpuset;
9060 ++ size_t size;
9061 +
9062 + pid = fork();
9063 + if (pid == -1) {
9064 +@@ -116,14 +118,23 @@ static void start_process_on(void *(*fn)(void *), void *arg, unsigned long cpu)
9065 + if (pid)
9066 + return;
9067 +
9068 +- CPU_ZERO(&cpuset);
9069 +- CPU_SET(cpu, &cpuset);
9070 ++ ncpus = get_nprocs();
9071 ++ size = CPU_ALLOC_SIZE(ncpus);
9072 ++ cpuset = CPU_ALLOC(ncpus);
9073 ++ if (!cpuset) {
9074 ++ perror("malloc");
9075 ++ exit(1);
9076 ++ }
9077 ++ CPU_ZERO_S(size, cpuset);
9078 ++ CPU_SET_S(cpu, size, cpuset);
9079 +
9080 +- if (sched_setaffinity(0, sizeof(cpuset), &cpuset)) {
9081 ++ if (sched_setaffinity(0, size, cpuset)) {
9082 + perror("sched_setaffinity");
9083 ++ CPU_FREE(cpuset);
9084 + exit(1);
9085 + }
9086 +
9087 ++ CPU_FREE(cpuset);
9088 + fn(arg);
9089 +
9090 + exit(0);
9091 +diff --git a/tools/testing/selftests/powerpc/eeh/eeh-functions.sh b/tools/testing/selftests/powerpc/eeh/eeh-functions.sh
9092 +index f52ed92b53e7..00dc32c0ed75 100755
9093 +--- a/tools/testing/selftests/powerpc/eeh/eeh-functions.sh
9094 ++++ b/tools/testing/selftests/powerpc/eeh/eeh-functions.sh
9095 +@@ -5,12 +5,17 @@ pe_ok() {
9096 + local dev="$1"
9097 + local path="/sys/bus/pci/devices/$dev/eeh_pe_state"
9098 +
9099 +- if ! [ -e "$path" ] ; then
9100 ++ # if a driver doesn't support the error handling callbacks then the
9101 ++ # device is recovered by removing and re-probing it. This causes the
9102 ++ # sysfs directory to disappear so read the PE state once and squash
9103 ++ # any potential error messages
9104 ++ local eeh_state="$(cat $path 2>/dev/null)"
9105 ++ if [ -z "$eeh_state" ]; then
9106 + return 1;
9107 + fi
9108 +
9109 +- local fw_state="$(cut -d' ' -f1 < $path)"
9110 +- local sw_state="$(cut -d' ' -f2 < $path)"
9111 ++ local fw_state="$(echo $eeh_state | cut -d' ' -f1)"
9112 ++ local sw_state="$(echo $eeh_state | cut -d' ' -f2)"
9113 +
9114 + # If EEH_PE_ISOLATED or EEH_PE_RECOVERING are set then the PE is in an
9115 + # error state or being recovered. Either way, not ok.
9116 +diff --git a/tools/testing/selftests/powerpc/utils.c b/tools/testing/selftests/powerpc/utils.c
9117 +index c02d24835db4..176102eca994 100644
9118 +--- a/tools/testing/selftests/powerpc/utils.c
9119 ++++ b/tools/testing/selftests/powerpc/utils.c
9120 +@@ -16,6 +16,7 @@
9121 + #include <string.h>
9122 + #include <sys/ioctl.h>
9123 + #include <sys/stat.h>
9124 ++#include <sys/sysinfo.h>
9125 + #include <sys/types.h>
9126 + #include <sys/utsname.h>
9127 + #include <unistd.h>
9128 +@@ -88,28 +89,40 @@ void *get_auxv_entry(int type)
9129 +
9130 + int pick_online_cpu(void)
9131 + {
9132 +- cpu_set_t mask;
9133 +- int cpu;
9134 ++ int ncpus, cpu = -1;
9135 ++ cpu_set_t *mask;
9136 ++ size_t size;
9137 ++
9138 ++ ncpus = get_nprocs_conf();
9139 ++ size = CPU_ALLOC_SIZE(ncpus);
9140 ++ mask = CPU_ALLOC(ncpus);
9141 ++ if (!mask) {
9142 ++ perror("malloc");
9143 ++ return -1;
9144 ++ }
9145 +
9146 +- CPU_ZERO(&mask);
9147 ++ CPU_ZERO_S(size, mask);
9148 +
9149 +- if (sched_getaffinity(0, sizeof(mask), &mask)) {
9150 ++ if (sched_getaffinity(0, size, mask)) {
9151 + perror("sched_getaffinity");
9152 +- return -1;
9153 ++ goto done;
9154 + }
9155 +
9156 + /* We prefer a primary thread, but skip 0 */
9157 +- for (cpu = 8; cpu < CPU_SETSIZE; cpu += 8)
9158 +- if (CPU_ISSET(cpu, &mask))
9159 +- return cpu;
9160 ++ for (cpu = 8; cpu < ncpus; cpu += 8)
9161 ++ if (CPU_ISSET_S(cpu, size, mask))
9162 ++ goto done;
9163 +
9164 + /* Search for anything, but in reverse */
9165 +- for (cpu = CPU_SETSIZE - 1; cpu >= 0; cpu--)
9166 +- if (CPU_ISSET(cpu, &mask))
9167 +- return cpu;
9168 ++ for (cpu = ncpus - 1; cpu >= 0; cpu--)
9169 ++ if (CPU_ISSET_S(cpu, size, mask))
9170 ++ goto done;
9171 +
9172 + printf("No cpus in affinity mask?!\n");
9173 +- return -1;
9174 ++
9175 ++done:
9176 ++ CPU_FREE(mask);
9177 ++ return cpu;
9178 + }
9179 +
9180 + bool is_ppc64le(void)
9181 +diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
9182 +index 96bbda4f10fc..19c7351eeb74 100644
9183 +--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
9184 ++++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
9185 +@@ -177,7 +177,7 @@ struct seccomp_metadata {
9186 + #define SECCOMP_IOCTL_NOTIF_RECV SECCOMP_IOWR(0, struct seccomp_notif)
9187 + #define SECCOMP_IOCTL_NOTIF_SEND SECCOMP_IOWR(1, \
9188 + struct seccomp_notif_resp)
9189 +-#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOR(2, __u64)
9190 ++#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOW(2, __u64)
9191 +
9192 + struct seccomp_notif {
9193 + __u64 id;