Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.18 commit in: /
Date: Thu, 04 Oct 2018 10:44:48
Message-Id: 1538649847.2e88d7f9eaffea37f89cf24b95cf17b308c058e9.mpagano@gentoo
1 commit: 2e88d7f9eaffea37f89cf24b95cf17b308c058e9
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Thu Oct 4 10:44:07 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 4 10:44:07 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=2e88d7f9
7
8 Linux patch 4.18.12
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1011_linux-4.18.12.patch | 7724 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 7728 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index cccbd63..ff87445 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -87,6 +87,10 @@ Patch: 1010_linux-4.18.11.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.18.11
23
24 +Patch: 1011_linux-4.18.12.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.18.12
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/1011_linux-4.18.12.patch b/1011_linux-4.18.12.patch
33 new file mode 100644
34 index 0000000..0851ea8
35 --- /dev/null
36 +++ b/1011_linux-4.18.12.patch
37 @@ -0,0 +1,7724 @@
38 +diff --git a/Documentation/hwmon/ina2xx b/Documentation/hwmon/ina2xx
39 +index 72d16f08e431..b8df81f6d6bc 100644
40 +--- a/Documentation/hwmon/ina2xx
41 ++++ b/Documentation/hwmon/ina2xx
42 +@@ -32,7 +32,7 @@ Supported chips:
43 + Datasheet: Publicly available at the Texas Instruments website
44 + http://www.ti.com/
45 +
46 +-Author: Lothar Felten <l-felten@××.com>
47 ++Author: Lothar Felten <lothar.felten@×××××.com>
48 +
49 + Description
50 + -----------
51 +diff --git a/Documentation/process/2.Process.rst b/Documentation/process/2.Process.rst
52 +index a9c46dd0706b..51d0349c7809 100644
53 +--- a/Documentation/process/2.Process.rst
54 ++++ b/Documentation/process/2.Process.rst
55 +@@ -134,7 +134,7 @@ and their maintainers are:
56 + 4.4 Greg Kroah-Hartman (very long-term stable kernel)
57 + 4.9 Greg Kroah-Hartman
58 + 4.14 Greg Kroah-Hartman
59 +- ====== ====================== ===========================
60 ++ ====== ====================== ==============================
61 +
62 + The selection of a kernel for long-term support is purely a matter of a
63 + maintainer having the need and the time to maintain that release. There
64 +diff --git a/Makefile b/Makefile
65 +index de0ecace693a..466e07af8473 100644
66 +--- a/Makefile
67 ++++ b/Makefile
68 +@@ -1,7 +1,7 @@
69 + # SPDX-License-Identifier: GPL-2.0
70 + VERSION = 4
71 + PATCHLEVEL = 18
72 +-SUBLEVEL = 11
73 ++SUBLEVEL = 12
74 + EXTRAVERSION =
75 + NAME = Merciless Moray
76 +
77 +diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
78 +index e03495a799ce..a0ddf497e8cd 100644
79 +--- a/arch/arm/boot/dts/dra7.dtsi
80 ++++ b/arch/arm/boot/dts/dra7.dtsi
81 +@@ -1893,7 +1893,7 @@
82 + };
83 + };
84 +
85 +- dcan1: can@481cc000 {
86 ++ dcan1: can@4ae3c000 {
87 + compatible = "ti,dra7-d_can";
88 + ti,hwmods = "dcan1";
89 + reg = <0x4ae3c000 0x2000>;
90 +@@ -1903,7 +1903,7 @@
91 + status = "disabled";
92 + };
93 +
94 +- dcan2: can@481d0000 {
95 ++ dcan2: can@48480000 {
96 + compatible = "ti,dra7-d_can";
97 + ti,hwmods = "dcan2";
98 + reg = <0x48480000 0x2000>;
99 +diff --git a/arch/arm/boot/dts/imx7d.dtsi b/arch/arm/boot/dts/imx7d.dtsi
100 +index 8d3d123d0a5c..37f0a5afe348 100644
101 +--- a/arch/arm/boot/dts/imx7d.dtsi
102 ++++ b/arch/arm/boot/dts/imx7d.dtsi
103 +@@ -125,10 +125,14 @@
104 + interrupt-names = "msi";
105 + #interrupt-cells = <1>;
106 + interrupt-map-mask = <0 0 0 0x7>;
107 +- interrupt-map = <0 0 0 1 &intc GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
108 +- <0 0 0 2 &intc GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>,
109 +- <0 0 0 3 &intc GIC_SPI 124 IRQ_TYPE_LEVEL_HIGH>,
110 +- <0 0 0 4 &intc GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>;
111 ++ /*
112 ++ * Reference manual lists pci irqs incorrectly
113 ++ * Real hardware ordering is same as imx6: D+MSI, C, B, A
114 ++ */
115 ++ interrupt-map = <0 0 0 1 &intc GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>,
116 ++ <0 0 0 2 &intc GIC_SPI 124 IRQ_TYPE_LEVEL_HIGH>,
117 ++ <0 0 0 3 &intc GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>,
118 ++ <0 0 0 4 &intc GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>;
119 + clocks = <&clks IMX7D_PCIE_CTRL_ROOT_CLK>,
120 + <&clks IMX7D_PLL_ENET_MAIN_100M_CLK>,
121 + <&clks IMX7D_PCIE_PHY_ROOT_CLK>;
122 +diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
123 +index c55d479971cc..f18490548c78 100644
124 +--- a/arch/arm/boot/dts/ls1021a.dtsi
125 ++++ b/arch/arm/boot/dts/ls1021a.dtsi
126 +@@ -84,6 +84,7 @@
127 + device_type = "cpu";
128 + reg = <0xf01>;
129 + clocks = <&clockgen 1 0>;
130 ++ #cooling-cells = <2>;
131 + };
132 + };
133 +
134 +diff --git a/arch/arm/boot/dts/mt7623.dtsi b/arch/arm/boot/dts/mt7623.dtsi
135 +index d1eb123bc73b..1cdc346a05e8 100644
136 +--- a/arch/arm/boot/dts/mt7623.dtsi
137 ++++ b/arch/arm/boot/dts/mt7623.dtsi
138 +@@ -92,6 +92,7 @@
139 + <&apmixedsys CLK_APMIXED_MAINPLL>;
140 + clock-names = "cpu", "intermediate";
141 + operating-points-v2 = <&cpu_opp_table>;
142 ++ #cooling-cells = <2>;
143 + clock-frequency = <1300000000>;
144 + };
145 +
146 +@@ -103,6 +104,7 @@
147 + <&apmixedsys CLK_APMIXED_MAINPLL>;
148 + clock-names = "cpu", "intermediate";
149 + operating-points-v2 = <&cpu_opp_table>;
150 ++ #cooling-cells = <2>;
151 + clock-frequency = <1300000000>;
152 + };
153 +
154 +@@ -114,6 +116,7 @@
155 + <&apmixedsys CLK_APMIXED_MAINPLL>;
156 + clock-names = "cpu", "intermediate";
157 + operating-points-v2 = <&cpu_opp_table>;
158 ++ #cooling-cells = <2>;
159 + clock-frequency = <1300000000>;
160 + };
161 + };
162 +diff --git a/arch/arm/boot/dts/omap4-droid4-xt894.dts b/arch/arm/boot/dts/omap4-droid4-xt894.dts
163 +index e7c3c563ff8f..5f27518561c4 100644
164 +--- a/arch/arm/boot/dts/omap4-droid4-xt894.dts
165 ++++ b/arch/arm/boot/dts/omap4-droid4-xt894.dts
166 +@@ -351,7 +351,7 @@
167 + &mmc2 {
168 + vmmc-supply = <&vsdio>;
169 + bus-width = <8>;
170 +- non-removable;
171 ++ ti,non-removable;
172 + };
173 +
174 + &mmc3 {
175 +@@ -618,15 +618,6 @@
176 + OMAP4_IOPAD(0x10c, PIN_INPUT | MUX_MODE1) /* abe_mcbsp3_fsx */
177 + >;
178 + };
179 +-};
180 +-
181 +-&omap4_pmx_wkup {
182 +- usb_gpio_mux_sel2: pinmux_usb_gpio_mux_sel2_pins {
183 +- /* gpio_wk0 */
184 +- pinctrl-single,pins = <
185 +- OMAP4_IOPAD(0x040, PIN_OUTPUT_PULLDOWN | MUX_MODE3)
186 +- >;
187 +- };
188 +
189 + vibrator_direction_pin: pinmux_vibrator_direction_pin {
190 + pinctrl-single,pins = <
191 +@@ -641,6 +632,15 @@
192 + };
193 + };
194 +
195 ++&omap4_pmx_wkup {
196 ++ usb_gpio_mux_sel2: pinmux_usb_gpio_mux_sel2_pins {
197 ++ /* gpio_wk0 */
198 ++ pinctrl-single,pins = <
199 ++ OMAP4_IOPAD(0x040, PIN_OUTPUT_PULLDOWN | MUX_MODE3)
200 ++ >;
201 ++ };
202 ++};
203 ++
204 + /*
205 + * As uart1 is wired to mdm6600 with rts and cts, we can use the cts pin for
206 + * uart1 wakeirq.
207 +diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c
208 +index 27a78c80e5b1..73d5d72dfc3e 100644
209 +--- a/arch/arm/mach-mvebu/pmsu.c
210 ++++ b/arch/arm/mach-mvebu/pmsu.c
211 +@@ -116,8 +116,8 @@ void mvebu_pmsu_set_cpu_boot_addr(int hw_cpu, void *boot_addr)
212 + PMSU_BOOT_ADDR_REDIRECT_OFFSET(hw_cpu));
213 + }
214 +
215 +-extern unsigned char mvebu_boot_wa_start;
216 +-extern unsigned char mvebu_boot_wa_end;
217 ++extern unsigned char mvebu_boot_wa_start[];
218 ++extern unsigned char mvebu_boot_wa_end[];
219 +
220 + /*
221 + * This function sets up the boot address workaround needed for SMP
222 +@@ -130,7 +130,7 @@ int mvebu_setup_boot_addr_wa(unsigned int crypto_eng_target,
223 + phys_addr_t resume_addr_reg)
224 + {
225 + void __iomem *sram_virt_base;
226 +- u32 code_len = &mvebu_boot_wa_end - &mvebu_boot_wa_start;
227 ++ u32 code_len = mvebu_boot_wa_end - mvebu_boot_wa_start;
228 +
229 + mvebu_mbus_del_window(BOOTROM_BASE, BOOTROM_SIZE);
230 + mvebu_mbus_add_window_by_id(crypto_eng_target, crypto_eng_attribute,
231 +diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
232 +index 2ceffd85dd3d..cd65ea4e9c54 100644
233 +--- a/arch/arm/mach-omap2/omap_hwmod.c
234 ++++ b/arch/arm/mach-omap2/omap_hwmod.c
235 +@@ -2160,6 +2160,37 @@ static int of_dev_hwmod_lookup(struct device_node *np,
236 + return -ENODEV;
237 + }
238 +
239 ++/**
240 ++ * omap_hwmod_fix_mpu_rt_idx - fix up mpu_rt_idx register offsets
241 ++ *
242 ++ * @oh: struct omap_hwmod *
243 ++ * @np: struct device_node *
244 ++ *
245 ++ * Fix up module register offsets for modules with mpu_rt_idx.
246 ++ * Only needed for cpsw with interconnect target module defined
247 ++ * in device tree while still using legacy hwmod platform data
248 ++ * for rev, sysc and syss registers.
249 ++ *
250 ++ * Can be removed when all cpsw hwmod platform data has been
251 ++ * dropped.
252 ++ */
253 ++static void omap_hwmod_fix_mpu_rt_idx(struct omap_hwmod *oh,
254 ++ struct device_node *np,
255 ++ struct resource *res)
256 ++{
257 ++ struct device_node *child = NULL;
258 ++ int error;
259 ++
260 ++ child = of_get_next_child(np, child);
261 ++ if (!child)
262 ++ return;
263 ++
264 ++ error = of_address_to_resource(child, oh->mpu_rt_idx, res);
265 ++ if (error)
266 ++ pr_err("%s: error mapping mpu_rt_idx: %i\n",
267 ++ __func__, error);
268 ++}
269 ++
270 + /**
271 + * omap_hwmod_parse_module_range - map module IO range from device tree
272 + * @oh: struct omap_hwmod *
273 +@@ -2220,7 +2251,13 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh,
274 + size = be32_to_cpup(ranges);
275 +
276 + pr_debug("omap_hwmod: %s %s at 0x%llx size 0x%llx\n",
277 +- oh->name, np->name, base, size);
278 ++ oh ? oh->name : "", np->name, base, size);
279 ++
280 ++ if (oh && oh->mpu_rt_idx) {
281 ++ omap_hwmod_fix_mpu_rt_idx(oh, np, res);
282 ++
283 ++ return 0;
284 ++ }
285 +
286 + res->start = base;
287 + res->end = base + size - 1;
288 +diff --git a/arch/arm/mach-omap2/omap_hwmod_reset.c b/arch/arm/mach-omap2/omap_hwmod_reset.c
289 +index b68f9c0aff0b..d5ddba00bb73 100644
290 +--- a/arch/arm/mach-omap2/omap_hwmod_reset.c
291 ++++ b/arch/arm/mach-omap2/omap_hwmod_reset.c
292 +@@ -92,11 +92,13 @@ static void omap_rtc_wait_not_busy(struct omap_hwmod *oh)
293 + */
294 + void omap_hwmod_rtc_unlock(struct omap_hwmod *oh)
295 + {
296 +- local_irq_disable();
297 ++ unsigned long flags;
298 ++
299 ++ local_irq_save(flags);
300 + omap_rtc_wait_not_busy(oh);
301 + omap_hwmod_write(OMAP_RTC_KICK0_VALUE, oh, OMAP_RTC_KICK0_REG);
302 + omap_hwmod_write(OMAP_RTC_KICK1_VALUE, oh, OMAP_RTC_KICK1_REG);
303 +- local_irq_enable();
304 ++ local_irq_restore(flags);
305 + }
306 +
307 + /**
308 +@@ -110,9 +112,11 @@ void omap_hwmod_rtc_unlock(struct omap_hwmod *oh)
309 + */
310 + void omap_hwmod_rtc_lock(struct omap_hwmod *oh)
311 + {
312 +- local_irq_disable();
313 ++ unsigned long flags;
314 ++
315 ++ local_irq_save(flags);
316 + omap_rtc_wait_not_busy(oh);
317 + omap_hwmod_write(0x0, oh, OMAP_RTC_KICK0_REG);
318 + omap_hwmod_write(0x0, oh, OMAP_RTC_KICK1_REG);
319 +- local_irq_enable();
320 ++ local_irq_restore(flags);
321 + }
322 +diff --git a/arch/arm64/boot/dts/renesas/r8a7795-es1.dtsi b/arch/arm64/boot/dts/renesas/r8a7795-es1.dtsi
323 +index e19dcd6cb767..0a42b016f257 100644
324 +--- a/arch/arm64/boot/dts/renesas/r8a7795-es1.dtsi
325 ++++ b/arch/arm64/boot/dts/renesas/r8a7795-es1.dtsi
326 +@@ -80,7 +80,7 @@
327 +
328 + vspd3: vsp@fea38000 {
329 + compatible = "renesas,vsp2";
330 +- reg = <0 0xfea38000 0 0x8000>;
331 ++ reg = <0 0xfea38000 0 0x5000>;
332 + interrupts = <GIC_SPI 469 IRQ_TYPE_LEVEL_HIGH>;
333 + clocks = <&cpg CPG_MOD 620>;
334 + power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
335 +diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
336 +index d842940b2f43..91c392f879f9 100644
337 +--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
338 ++++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
339 +@@ -2530,7 +2530,7 @@
340 +
341 + vspd0: vsp@fea20000 {
342 + compatible = "renesas,vsp2";
343 +- reg = <0 0xfea20000 0 0x8000>;
344 ++ reg = <0 0xfea20000 0 0x5000>;
345 + interrupts = <GIC_SPI 466 IRQ_TYPE_LEVEL_HIGH>;
346 + clocks = <&cpg CPG_MOD 623>;
347 + power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
348 +@@ -2541,7 +2541,7 @@
349 +
350 + vspd1: vsp@fea28000 {
351 + compatible = "renesas,vsp2";
352 +- reg = <0 0xfea28000 0 0x8000>;
353 ++ reg = <0 0xfea28000 0 0x5000>;
354 + interrupts = <GIC_SPI 467 IRQ_TYPE_LEVEL_HIGH>;
355 + clocks = <&cpg CPG_MOD 622>;
356 + power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
357 +@@ -2552,7 +2552,7 @@
358 +
359 + vspd2: vsp@fea30000 {
360 + compatible = "renesas,vsp2";
361 +- reg = <0 0xfea30000 0 0x8000>;
362 ++ reg = <0 0xfea30000 0 0x5000>;
363 + interrupts = <GIC_SPI 468 IRQ_TYPE_LEVEL_HIGH>;
364 + clocks = <&cpg CPG_MOD 621>;
365 + power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
366 +diff --git a/arch/arm64/boot/dts/renesas/r8a7796.dtsi b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
367 +index 7c25be6b5af3..a3653f9f4627 100644
368 +--- a/arch/arm64/boot/dts/renesas/r8a7796.dtsi
369 ++++ b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
370 +@@ -2212,7 +2212,7 @@
371 +
372 + vspd0: vsp@fea20000 {
373 + compatible = "renesas,vsp2";
374 +- reg = <0 0xfea20000 0 0x8000>;
375 ++ reg = <0 0xfea20000 0 0x5000>;
376 + interrupts = <GIC_SPI 466 IRQ_TYPE_LEVEL_HIGH>;
377 + clocks = <&cpg CPG_MOD 623>;
378 + power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
379 +@@ -2223,7 +2223,7 @@
380 +
381 + vspd1: vsp@fea28000 {
382 + compatible = "renesas,vsp2";
383 +- reg = <0 0xfea28000 0 0x8000>;
384 ++ reg = <0 0xfea28000 0 0x5000>;
385 + interrupts = <GIC_SPI 467 IRQ_TYPE_LEVEL_HIGH>;
386 + clocks = <&cpg CPG_MOD 622>;
387 + power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
388 +@@ -2234,7 +2234,7 @@
389 +
390 + vspd2: vsp@fea30000 {
391 + compatible = "renesas,vsp2";
392 +- reg = <0 0xfea30000 0 0x8000>;
393 ++ reg = <0 0xfea30000 0 0x5000>;
394 + interrupts = <GIC_SPI 468 IRQ_TYPE_LEVEL_HIGH>;
395 + clocks = <&cpg CPG_MOD 621>;
396 + power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
397 +diff --git a/arch/arm64/boot/dts/renesas/r8a77965.dtsi b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
398 +index 486aecacb22a..ca618228fce1 100644
399 +--- a/arch/arm64/boot/dts/renesas/r8a77965.dtsi
400 ++++ b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
401 +@@ -1397,7 +1397,7 @@
402 +
403 + vspd0: vsp@fea20000 {
404 + compatible = "renesas,vsp2";
405 +- reg = <0 0xfea20000 0 0x8000>;
406 ++ reg = <0 0xfea20000 0 0x5000>;
407 + interrupts = <GIC_SPI 466 IRQ_TYPE_LEVEL_HIGH>;
408 + clocks = <&cpg CPG_MOD 623>;
409 + power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
410 +@@ -1416,7 +1416,7 @@
411 +
412 + vspd1: vsp@fea28000 {
413 + compatible = "renesas,vsp2";
414 +- reg = <0 0xfea28000 0 0x8000>;
415 ++ reg = <0 0xfea28000 0 0x5000>;
416 + interrupts = <GIC_SPI 467 IRQ_TYPE_LEVEL_HIGH>;
417 + clocks = <&cpg CPG_MOD 622>;
418 + power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
419 +diff --git a/arch/arm64/boot/dts/renesas/r8a77970.dtsi b/arch/arm64/boot/dts/renesas/r8a77970.dtsi
420 +index 98a2317a16c4..89dc4e343b7c 100644
421 +--- a/arch/arm64/boot/dts/renesas/r8a77970.dtsi
422 ++++ b/arch/arm64/boot/dts/renesas/r8a77970.dtsi
423 +@@ -776,7 +776,7 @@
424 +
425 + vspd0: vsp@fea20000 {
426 + compatible = "renesas,vsp2";
427 +- reg = <0 0xfea20000 0 0x8000>;
428 ++ reg = <0 0xfea20000 0 0x5000>;
429 + interrupts = <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>;
430 + clocks = <&cpg CPG_MOD 623>;
431 + power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
432 +diff --git a/arch/arm64/boot/dts/renesas/r8a77995.dtsi b/arch/arm64/boot/dts/renesas/r8a77995.dtsi
433 +index 2506f46293e8..ac9aadf2723c 100644
434 +--- a/arch/arm64/boot/dts/renesas/r8a77995.dtsi
435 ++++ b/arch/arm64/boot/dts/renesas/r8a77995.dtsi
436 +@@ -699,7 +699,7 @@
437 +
438 + vspd0: vsp@fea20000 {
439 + compatible = "renesas,vsp2";
440 +- reg = <0 0xfea20000 0 0x8000>;
441 ++ reg = <0 0xfea20000 0 0x5000>;
442 + interrupts = <GIC_SPI 466 IRQ_TYPE_LEVEL_HIGH>;
443 + clocks = <&cpg CPG_MOD 623>;
444 + power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
445 +@@ -709,7 +709,7 @@
446 +
447 + vspd1: vsp@fea28000 {
448 + compatible = "renesas,vsp2";
449 +- reg = <0 0xfea28000 0 0x8000>;
450 ++ reg = <0 0xfea28000 0 0x5000>;
451 + interrupts = <GIC_SPI 467 IRQ_TYPE_LEVEL_HIGH>;
452 + clocks = <&cpg CPG_MOD 622>;
453 + power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
454 +diff --git a/arch/arm64/boot/dts/renesas/salvator-common.dtsi b/arch/arm64/boot/dts/renesas/salvator-common.dtsi
455 +index 9256fbaaab7f..5853f5177b4b 100644
456 +--- a/arch/arm64/boot/dts/renesas/salvator-common.dtsi
457 ++++ b/arch/arm64/boot/dts/renesas/salvator-common.dtsi
458 +@@ -440,7 +440,7 @@
459 + };
460 + };
461 +
462 +- port@10 {
463 ++ port@a {
464 + reg = <10>;
465 +
466 + adv7482_txa: endpoint {
467 +@@ -450,7 +450,7 @@
468 + };
469 + };
470 +
471 +- port@11 {
472 ++ port@b {
473 + reg = <11>;
474 +
475 + adv7482_txb: endpoint {
476 +diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
477 +index 56a0260ceb11..d5c6bb1562d8 100644
478 +--- a/arch/arm64/kvm/guest.c
479 ++++ b/arch/arm64/kvm/guest.c
480 +@@ -57,6 +57,45 @@ static u64 core_reg_offset_from_id(u64 id)
481 + return id & ~(KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_CORE);
482 + }
483 +
484 ++static int validate_core_offset(const struct kvm_one_reg *reg)
485 ++{
486 ++ u64 off = core_reg_offset_from_id(reg->id);
487 ++ int size;
488 ++
489 ++ switch (off) {
490 ++ case KVM_REG_ARM_CORE_REG(regs.regs[0]) ...
491 ++ KVM_REG_ARM_CORE_REG(regs.regs[30]):
492 ++ case KVM_REG_ARM_CORE_REG(regs.sp):
493 ++ case KVM_REG_ARM_CORE_REG(regs.pc):
494 ++ case KVM_REG_ARM_CORE_REG(regs.pstate):
495 ++ case KVM_REG_ARM_CORE_REG(sp_el1):
496 ++ case KVM_REG_ARM_CORE_REG(elr_el1):
497 ++ case KVM_REG_ARM_CORE_REG(spsr[0]) ...
498 ++ KVM_REG_ARM_CORE_REG(spsr[KVM_NR_SPSR - 1]):
499 ++ size = sizeof(__u64);
500 ++ break;
501 ++
502 ++ case KVM_REG_ARM_CORE_REG(fp_regs.vregs[0]) ...
503 ++ KVM_REG_ARM_CORE_REG(fp_regs.vregs[31]):
504 ++ size = sizeof(__uint128_t);
505 ++ break;
506 ++
507 ++ case KVM_REG_ARM_CORE_REG(fp_regs.fpsr):
508 ++ case KVM_REG_ARM_CORE_REG(fp_regs.fpcr):
509 ++ size = sizeof(__u32);
510 ++ break;
511 ++
512 ++ default:
513 ++ return -EINVAL;
514 ++ }
515 ++
516 ++ if (KVM_REG_SIZE(reg->id) == size &&
517 ++ IS_ALIGNED(off, size / sizeof(__u32)))
518 ++ return 0;
519 ++
520 ++ return -EINVAL;
521 ++}
522 ++
523 + static int get_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
524 + {
525 + /*
526 +@@ -76,6 +115,9 @@ static int get_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
527 + (off + (KVM_REG_SIZE(reg->id) / sizeof(__u32))) >= nr_regs)
528 + return -ENOENT;
529 +
530 ++ if (validate_core_offset(reg))
531 ++ return -EINVAL;
532 ++
533 + if (copy_to_user(uaddr, ((u32 *)regs) + off, KVM_REG_SIZE(reg->id)))
534 + return -EFAULT;
535 +
536 +@@ -98,6 +140,9 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
537 + (off + (KVM_REG_SIZE(reg->id) / sizeof(__u32))) >= nr_regs)
538 + return -ENOENT;
539 +
540 ++ if (validate_core_offset(reg))
541 ++ return -EINVAL;
542 ++
543 + if (KVM_REG_SIZE(reg->id) > sizeof(tmp))
544 + return -EINVAL;
545 +
546 +@@ -107,17 +152,25 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
547 + }
548 +
549 + if (off == KVM_REG_ARM_CORE_REG(regs.pstate)) {
550 +- u32 mode = (*(u32 *)valp) & COMPAT_PSR_MODE_MASK;
551 ++ u64 mode = (*(u64 *)valp) & COMPAT_PSR_MODE_MASK;
552 + switch (mode) {
553 + case COMPAT_PSR_MODE_USR:
554 ++ if (!system_supports_32bit_el0())
555 ++ return -EINVAL;
556 ++ break;
557 + case COMPAT_PSR_MODE_FIQ:
558 + case COMPAT_PSR_MODE_IRQ:
559 + case COMPAT_PSR_MODE_SVC:
560 + case COMPAT_PSR_MODE_ABT:
561 + case COMPAT_PSR_MODE_UND:
562 ++ if (!vcpu_el1_is_32bit(vcpu))
563 ++ return -EINVAL;
564 ++ break;
565 + case PSR_MODE_EL0t:
566 + case PSR_MODE_EL1t:
567 + case PSR_MODE_EL1h:
568 ++ if (vcpu_el1_is_32bit(vcpu))
569 ++ return -EINVAL;
570 + break;
571 + default:
572 + err = -EINVAL;
573 +diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
574 +index c22da16d67b8..5c7bfa8478e7 100644
575 +--- a/arch/mips/boot/Makefile
576 ++++ b/arch/mips/boot/Makefile
577 +@@ -118,10 +118,12 @@ ifeq ($(ADDR_BITS),64)
578 + itb_addr_cells = 2
579 + endif
580 +
581 ++targets += vmlinux.its.S
582 ++
583 + quiet_cmd_its_cat = CAT $@
584 +- cmd_its_cat = cat $^ >$@
585 ++ cmd_its_cat = cat $(filter-out $(PHONY), $^) >$@
586 +
587 +-$(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS))
588 ++$(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE
589 + $(call if_changed,its_cat)
590 +
591 + quiet_cmd_cpp_its_S = ITS $@
592 +diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
593 +index f817342aab8f..53729220b48d 100644
594 +--- a/arch/powerpc/kernel/exceptions-64s.S
595 ++++ b/arch/powerpc/kernel/exceptions-64s.S
596 +@@ -1321,9 +1321,7 @@ EXC_REAL_BEGIN(denorm_exception_hv, 0x1500, 0x100)
597 +
598 + #ifdef CONFIG_PPC_DENORMALISATION
599 + mfspr r10,SPRN_HSRR1
600 +- mfspr r11,SPRN_HSRR0 /* save HSRR0 */
601 + andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */
602 +- addi r11,r11,-4 /* HSRR0 is next instruction */
603 + bne+ denorm_assist
604 + #endif
605 +
606 +@@ -1389,6 +1387,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
607 + */
608 + XVCPSGNDP32(32)
609 + denorm_done:
610 ++ mfspr r11,SPRN_HSRR0
611 ++ subi r11,r11,4
612 + mtspr SPRN_HSRR0,r11
613 + mtcrf 0x80,r9
614 + ld r9,PACA_EXGEN+EX_R9(r13)
615 +diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
616 +index 936c7e2d421e..b53401334e81 100644
617 +--- a/arch/powerpc/kernel/machine_kexec.c
618 ++++ b/arch/powerpc/kernel/machine_kexec.c
619 +@@ -188,7 +188,12 @@ void __init reserve_crashkernel(void)
620 + (unsigned long)(crashk_res.start >> 20),
621 + (unsigned long)(memblock_phys_mem_size() >> 20));
622 +
623 +- memblock_reserve(crashk_res.start, crash_size);
624 ++ if (!memblock_is_region_memory(crashk_res.start, crash_size) ||
625 ++ memblock_reserve(crashk_res.start, crash_size)) {
626 ++ pr_err("Failed to reserve memory for crashkernel!\n");
627 ++ crashk_res.start = crashk_res.end = 0;
628 ++ return;
629 ++ }
630 + }
631 +
632 + int overlaps_crashkernel(unsigned long start, unsigned long size)
633 +diff --git a/arch/powerpc/lib/checksum_64.S b/arch/powerpc/lib/checksum_64.S
634 +index 886ed94b9c13..d05c8af4ac51 100644
635 +--- a/arch/powerpc/lib/checksum_64.S
636 ++++ b/arch/powerpc/lib/checksum_64.S
637 +@@ -443,6 +443,9 @@ _GLOBAL(csum_ipv6_magic)
638 + addc r0, r8, r9
639 + ld r10, 0(r4)
640 + ld r11, 8(r4)
641 ++#ifdef CONFIG_CPU_LITTLE_ENDIAN
642 ++ rotldi r5, r5, 8
643 ++#endif
644 + adde r0, r0, r10
645 + add r5, r5, r7
646 + adde r0, r0, r11
647 +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
648 +index 35ac5422903a..b5a71baedbc2 100644
649 +--- a/arch/powerpc/mm/numa.c
650 ++++ b/arch/powerpc/mm/numa.c
651 +@@ -1452,7 +1452,8 @@ static struct timer_list topology_timer;
652 +
653 + static void reset_topology_timer(void)
654 + {
655 +- mod_timer(&topology_timer, jiffies + topology_timer_secs * HZ);
656 ++ if (vphn_enabled)
657 ++ mod_timer(&topology_timer, jiffies + topology_timer_secs * HZ);
658 + }
659 +
660 + #ifdef CONFIG_SMP
661 +diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c
662 +index 0e7810ccd1ae..c18d17d830a1 100644
663 +--- a/arch/powerpc/mm/pkeys.c
664 ++++ b/arch/powerpc/mm/pkeys.c
665 +@@ -44,7 +44,7 @@ static void scan_pkey_feature(void)
666 + * Since any pkey can be used for data or execute, we will just treat
667 + * all keys as equal and track them as one entity.
668 + */
669 +- pkeys_total = be32_to_cpu(vals[0]);
670 ++ pkeys_total = vals[0];
671 + pkeys_devtree_defined = true;
672 + }
673 +
674 +diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
675 +index a2cdf358a3ac..0976049d3365 100644
676 +--- a/arch/powerpc/platforms/powernv/pci-ioda.c
677 ++++ b/arch/powerpc/platforms/powernv/pci-ioda.c
678 +@@ -2841,7 +2841,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
679 + level_shift = entries_shift + 3;
680 + level_shift = max_t(unsigned, level_shift, PAGE_SHIFT);
681 +
682 +- if ((level_shift - 3) * levels + page_shift >= 60)
683 ++ if ((level_shift - 3) * levels + page_shift >= 55)
684 + return -EINVAL;
685 +
686 + /* Allocate TCE table */
687 +diff --git a/arch/s390/kernel/sysinfo.c b/arch/s390/kernel/sysinfo.c
688 +index 54f5496913fa..12f80d1f0415 100644
689 +--- a/arch/s390/kernel/sysinfo.c
690 ++++ b/arch/s390/kernel/sysinfo.c
691 +@@ -59,6 +59,8 @@ int stsi(void *sysinfo, int fc, int sel1, int sel2)
692 + }
693 + EXPORT_SYMBOL(stsi);
694 +
695 ++#ifdef CONFIG_PROC_FS
696 ++
697 + static bool convert_ext_name(unsigned char encoding, char *name, size_t len)
698 + {
699 + switch (encoding) {
700 +@@ -301,6 +303,8 @@ static int __init sysinfo_create_proc(void)
701 + }
702 + device_initcall(sysinfo_create_proc);
703 +
704 ++#endif /* CONFIG_PROC_FS */
705 ++
706 + /*
707 + * Service levels interface.
708 + */
709 +diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c
710 +index 6ad15d3fab81..84111a43ea29 100644
711 +--- a/arch/s390/mm/extmem.c
712 ++++ b/arch/s390/mm/extmem.c
713 +@@ -80,7 +80,7 @@ struct qin64 {
714 + struct dcss_segment {
715 + struct list_head list;
716 + char dcss_name[8];
717 +- char res_name[15];
718 ++ char res_name[16];
719 + unsigned long start_addr;
720 + unsigned long end;
721 + atomic_t ref_count;
722 +@@ -433,7 +433,7 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
723 + memcpy(&seg->res_name, seg->dcss_name, 8);
724 + EBCASC(seg->res_name, 8);
725 + seg->res_name[8] = '\0';
726 +- strncat(seg->res_name, " (DCSS)", 7);
727 ++ strlcat(seg->res_name, " (DCSS)", sizeof(seg->res_name));
728 + seg->res->name = seg->res_name;
729 + rc = seg->vm_segtype;
730 + if (rc == SEG_TYPE_SC ||
731 +diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c
732 +index e3bd5627afef..76d89ee8b428 100644
733 +--- a/arch/s390/mm/pgalloc.c
734 ++++ b/arch/s390/mm/pgalloc.c
735 +@@ -28,7 +28,7 @@ static struct ctl_table page_table_sysctl[] = {
736 + .data = &page_table_allocate_pgste,
737 + .maxlen = sizeof(int),
738 + .mode = S_IRUGO | S_IWUSR,
739 +- .proc_handler = proc_dointvec,
740 ++ .proc_handler = proc_dointvec_minmax,
741 + .extra1 = &page_table_allocate_pgste_min,
742 + .extra2 = &page_table_allocate_pgste_max,
743 + },
744 +diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
745 +index 8ae7ffda8f98..0ab33af41fbd 100644
746 +--- a/arch/x86/entry/entry_64.S
747 ++++ b/arch/x86/entry/entry_64.S
748 +@@ -92,7 +92,7 @@ END(native_usergs_sysret64)
749 + .endm
750 +
751 + .macro TRACE_IRQS_IRETQ_DEBUG
752 +- bt $9, EFLAGS(%rsp) /* interrupts off? */
753 ++ btl $9, EFLAGS(%rsp) /* interrupts off? */
754 + jnc 1f
755 + TRACE_IRQS_ON_DEBUG
756 + 1:
757 +@@ -701,7 +701,7 @@ retint_kernel:
758 + #ifdef CONFIG_PREEMPT
759 + /* Interrupts are off */
760 + /* Check if we need preemption */
761 +- bt $9, EFLAGS(%rsp) /* were interrupts off? */
762 ++ btl $9, EFLAGS(%rsp) /* were interrupts off? */
763 + jnc 1f
764 + 0: cmpl $0, PER_CPU_VAR(__preempt_count)
765 + jnz 1f
766 +diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c
767 +index cf372b90557e..a4170048a30b 100644
768 +--- a/arch/x86/events/intel/lbr.c
769 ++++ b/arch/x86/events/intel/lbr.c
770 +@@ -346,7 +346,7 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx)
771 +
772 + mask = x86_pmu.lbr_nr - 1;
773 + tos = task_ctx->tos;
774 +- for (i = 0; i < tos; i++) {
775 ++ for (i = 0; i < task_ctx->valid_lbrs; i++) {
776 + lbr_idx = (tos - i) & mask;
777 + wrlbr_from(lbr_idx, task_ctx->lbr_from[i]);
778 + wrlbr_to (lbr_idx, task_ctx->lbr_to[i]);
779 +@@ -354,6 +354,15 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx)
780 + if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
781 + wrmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr_info[i]);
782 + }
783 ++
784 ++ for (; i < x86_pmu.lbr_nr; i++) {
785 ++ lbr_idx = (tos - i) & mask;
786 ++ wrlbr_from(lbr_idx, 0);
787 ++ wrlbr_to(lbr_idx, 0);
788 ++ if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
789 ++ wrmsrl(MSR_LBR_INFO_0 + lbr_idx, 0);
790 ++ }
791 ++
792 + wrmsrl(x86_pmu.lbr_tos, tos);
793 + task_ctx->lbr_stack_state = LBR_NONE;
794 + }
795 +@@ -361,7 +370,7 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx)
796 + static void __intel_pmu_lbr_save(struct x86_perf_task_context *task_ctx)
797 + {
798 + unsigned lbr_idx, mask;
799 +- u64 tos;
800 ++ u64 tos, from;
801 + int i;
802 +
803 + if (task_ctx->lbr_callstack_users == 0) {
804 +@@ -371,13 +380,17 @@ static void __intel_pmu_lbr_save(struct x86_perf_task_context *task_ctx)
805 +
806 + mask = x86_pmu.lbr_nr - 1;
807 + tos = intel_pmu_lbr_tos();
808 +- for (i = 0; i < tos; i++) {
809 ++ for (i = 0; i < x86_pmu.lbr_nr; i++) {
810 + lbr_idx = (tos - i) & mask;
811 +- task_ctx->lbr_from[i] = rdlbr_from(lbr_idx);
812 ++ from = rdlbr_from(lbr_idx);
813 ++ if (!from)
814 ++ break;
815 ++ task_ctx->lbr_from[i] = from;
816 + task_ctx->lbr_to[i] = rdlbr_to(lbr_idx);
817 + if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
818 + rdmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr_info[i]);
819 + }
820 ++ task_ctx->valid_lbrs = i;
821 + task_ctx->tos = tos;
822 + task_ctx->lbr_stack_state = LBR_VALID;
823 + }
824 +@@ -531,7 +544,7 @@ static void intel_pmu_lbr_read_32(struct cpu_hw_events *cpuc)
825 + */
826 + static void intel_pmu_lbr_read_64(struct cpu_hw_events *cpuc)
827 + {
828 +- bool need_info = false;
829 ++ bool need_info = false, call_stack = false;
830 + unsigned long mask = x86_pmu.lbr_nr - 1;
831 + int lbr_format = x86_pmu.intel_cap.lbr_format;
832 + u64 tos = intel_pmu_lbr_tos();
833 +@@ -542,7 +555,7 @@ static void intel_pmu_lbr_read_64(struct cpu_hw_events *cpuc)
834 + if (cpuc->lbr_sel) {
835 + need_info = !(cpuc->lbr_sel->config & LBR_NO_INFO);
836 + if (cpuc->lbr_sel->config & LBR_CALL_STACK)
837 +- num = tos;
838 ++ call_stack = true;
839 + }
840 +
841 + for (i = 0; i < num; i++) {
842 +@@ -555,6 +568,13 @@ static void intel_pmu_lbr_read_64(struct cpu_hw_events *cpuc)
843 + from = rdlbr_from(lbr_idx);
844 + to = rdlbr_to(lbr_idx);
845 +
846 ++ /*
847 ++ * Read LBR call stack entries
848 ++ * until invalid entry (0s) is detected.
849 ++ */
850 ++ if (call_stack && !from)
851 ++ break;
852 ++
853 + if (lbr_format == LBR_FORMAT_INFO && need_info) {
854 + u64 info;
855 +
856 +diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
857 +index 9f3711470ec1..6b72a92069fd 100644
858 +--- a/arch/x86/events/perf_event.h
859 ++++ b/arch/x86/events/perf_event.h
860 +@@ -648,6 +648,7 @@ struct x86_perf_task_context {
861 + u64 lbr_to[MAX_LBR_ENTRIES];
862 + u64 lbr_info[MAX_LBR_ENTRIES];
863 + int tos;
864 ++ int valid_lbrs;
865 + int lbr_callstack_users;
866 + int lbr_stack_state;
867 + };
868 +diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
869 +index e203169931c7..6390bd8c141b 100644
870 +--- a/arch/x86/include/asm/fixmap.h
871 ++++ b/arch/x86/include/asm/fixmap.h
872 +@@ -14,6 +14,16 @@
873 + #ifndef _ASM_X86_FIXMAP_H
874 + #define _ASM_X86_FIXMAP_H
875 +
876 ++/*
877 ++ * Exposed to assembly code for setting up initial page tables. Cannot be
878 ++ * calculated in assembly code (fixmap entries are an enum), but is sanity
879 ++ * checked in the actual fixmap C code to make sure that the fixmap is
880 ++ * covered fully.
881 ++ */
882 ++#define FIXMAP_PMD_NUM 2
883 ++/* fixmap starts downwards from the 507th entry in level2_fixmap_pgt */
884 ++#define FIXMAP_PMD_TOP 507
885 ++
886 + #ifndef __ASSEMBLY__
887 + #include <linux/kernel.h>
888 + #include <asm/acpi.h>
889 +diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
890 +index 82ff20b0ae45..20127d551ab5 100644
891 +--- a/arch/x86/include/asm/pgtable_64.h
892 ++++ b/arch/x86/include/asm/pgtable_64.h
893 +@@ -14,6 +14,7 @@
894 + #include <asm/processor.h>
895 + #include <linux/bitops.h>
896 + #include <linux/threads.h>
897 ++#include <asm/fixmap.h>
898 +
899 + extern p4d_t level4_kernel_pgt[512];
900 + extern p4d_t level4_ident_pgt[512];
901 +@@ -22,7 +23,7 @@ extern pud_t level3_ident_pgt[512];
902 + extern pmd_t level2_kernel_pgt[512];
903 + extern pmd_t level2_fixmap_pgt[512];
904 + extern pmd_t level2_ident_pgt[512];
905 +-extern pte_t level1_fixmap_pgt[512];
906 ++extern pte_t level1_fixmap_pgt[512 * FIXMAP_PMD_NUM];
907 + extern pgd_t init_top_pgt[];
908 +
909 + #define swapper_pg_dir init_top_pgt
910 +diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
911 +index 8047379e575a..11455200ae66 100644
912 +--- a/arch/x86/kernel/head64.c
913 ++++ b/arch/x86/kernel/head64.c
914 +@@ -35,6 +35,7 @@
915 + #include <asm/bootparam_utils.h>
916 + #include <asm/microcode.h>
917 + #include <asm/kasan.h>
918 ++#include <asm/fixmap.h>
919 +
920 + /*
921 + * Manage page tables very early on.
922 +@@ -165,7 +166,8 @@ unsigned long __head __startup_64(unsigned long physaddr,
923 + pud[511] += load_delta;
924 +
925 + pmd = fixup_pointer(level2_fixmap_pgt, physaddr);
926 +- pmd[506] += load_delta;
927 ++ for (i = FIXMAP_PMD_TOP; i > FIXMAP_PMD_TOP - FIXMAP_PMD_NUM; i--)
928 ++ pmd[i] += load_delta;
929 +
930 + /*
931 + * Set up the identity mapping for the switchover. These
932 +diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
933 +index 8344dd2f310a..6bc215c15ce0 100644
934 +--- a/arch/x86/kernel/head_64.S
935 ++++ b/arch/x86/kernel/head_64.S
936 +@@ -24,6 +24,7 @@
937 + #include "../entry/calling.h"
938 + #include <asm/export.h>
939 + #include <asm/nospec-branch.h>
940 ++#include <asm/fixmap.h>
941 +
942 + #ifdef CONFIG_PARAVIRT
943 + #include <asm/asm-offsets.h>
944 +@@ -445,13 +446,20 @@ NEXT_PAGE(level2_kernel_pgt)
945 + KERNEL_IMAGE_SIZE/PMD_SIZE)
946 +
947 + NEXT_PAGE(level2_fixmap_pgt)
948 +- .fill 506,8,0
949 +- .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
950 +- /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
951 +- .fill 5,8,0
952 ++ .fill (512 - 4 - FIXMAP_PMD_NUM),8,0
953 ++ pgtno = 0
954 ++ .rept (FIXMAP_PMD_NUM)
955 ++ .quad level1_fixmap_pgt + (pgtno << PAGE_SHIFT) - __START_KERNEL_map \
956 ++ + _PAGE_TABLE_NOENC;
957 ++ pgtno = pgtno + 1
958 ++ .endr
959 ++ /* 6 MB reserved space + a 2MB hole */
960 ++ .fill 4,8,0
961 +
962 + NEXT_PAGE(level1_fixmap_pgt)
963 ++ .rept (FIXMAP_PMD_NUM)
964 + .fill 512,8,0
965 ++ .endr
966 +
967 + #undef PMDS
968 +
969 +diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c
970 +index 19afdbd7d0a7..5532d1be7687 100644
971 +--- a/arch/x86/kernel/tsc_msr.c
972 ++++ b/arch/x86/kernel/tsc_msr.c
973 +@@ -12,6 +12,7 @@
974 + #include <asm/setup.h>
975 + #include <asm/apic.h>
976 + #include <asm/param.h>
977 ++#include <asm/tsc.h>
978 +
979 + #define MAX_NUM_FREQS 9
980 +
981 +diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
982 +index 34a2a3bfde9c..22cbad56acab 100644
983 +--- a/arch/x86/mm/numa_emulation.c
984 ++++ b/arch/x86/mm/numa_emulation.c
985 +@@ -61,7 +61,7 @@ static int __init emu_setup_memblk(struct numa_meminfo *ei,
986 + eb->nid = nid;
987 +
988 + if (emu_nid_to_phys[nid] == NUMA_NO_NODE)
989 +- emu_nid_to_phys[nid] = nid;
990 ++ emu_nid_to_phys[nid] = pb->nid;
991 +
992 + pb->start += size;
993 + if (pb->start >= pb->end) {
994 +diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
995 +index e3deefb891da..a300ffeece9b 100644
996 +--- a/arch/x86/mm/pgtable.c
997 ++++ b/arch/x86/mm/pgtable.c
998 +@@ -577,6 +577,15 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
999 + {
1000 + unsigned long address = __fix_to_virt(idx);
1001 +
1002 ++#ifdef CONFIG_X86_64
1003 ++ /*
1004 ++ * Ensure that the static initial page tables are covering the
1005 ++ * fixmap completely.
1006 ++ */
1007 ++ BUILD_BUG_ON(__end_of_permanent_fixed_addresses >
1008 ++ (FIXMAP_PMD_NUM * PTRS_PER_PTE));
1009 ++#endif
1010 ++
1011 + if (idx >= __end_of_fixed_addresses) {
1012 + BUG();
1013 + return;
1014 +diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
1015 +index 1d2106d83b4e..019da252a04f 100644
1016 +--- a/arch/x86/mm/pti.c
1017 ++++ b/arch/x86/mm/pti.c
1018 +@@ -239,7 +239,7 @@ static pmd_t *pti_user_pagetable_walk_pmd(unsigned long address)
1019 + *
1020 + * Returns a pointer to a PTE on success, or NULL on failure.
1021 + */
1022 +-static __init pte_t *pti_user_pagetable_walk_pte(unsigned long address)
1023 ++static pte_t *pti_user_pagetable_walk_pte(unsigned long address)
1024 + {
1025 + gfp_t gfp = (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO);
1026 + pmd_t *pmd;
1027 +diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
1028 +index 071d82ec9abb..2473eaca3468 100644
1029 +--- a/arch/x86/xen/mmu_pv.c
1030 ++++ b/arch/x86/xen/mmu_pv.c
1031 +@@ -1908,7 +1908,7 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
1032 + /* L3_k[511] -> level2_fixmap_pgt */
1033 + convert_pfn_mfn(level3_kernel_pgt);
1034 +
1035 +- /* L3_k[511][506] -> level1_fixmap_pgt */
1036 ++ /* L3_k[511][508-FIXMAP_PMD_NUM ... 507] -> level1_fixmap_pgt */
1037 + convert_pfn_mfn(level2_fixmap_pgt);
1038 +
1039 + /* We get [511][511] and have Xen's version of level2_kernel_pgt */
1040 +@@ -1953,7 +1953,11 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
1041 + set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
1042 + set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
1043 + set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
1044 +- set_page_prot(level1_fixmap_pgt, PAGE_KERNEL_RO);
1045 ++
1046 ++ for (i = 0; i < FIXMAP_PMD_NUM; i++) {
1047 ++ set_page_prot(level1_fixmap_pgt + i * PTRS_PER_PTE,
1048 ++ PAGE_KERNEL_RO);
1049 ++ }
1050 +
1051 + /* Pin down new L4 */
1052 + pin_pagetable_pfn(MMUEXT_PIN_L4_TABLE,
1053 +diff --git a/block/elevator.c b/block/elevator.c
1054 +index fa828b5bfd4b..89a48a3a8c12 100644
1055 +--- a/block/elevator.c
1056 ++++ b/block/elevator.c
1057 +@@ -609,7 +609,7 @@ void elv_drain_elevator(struct request_queue *q)
1058 +
1059 + while (e->type->ops.sq.elevator_dispatch_fn(q, 1))
1060 + ;
1061 +- if (q->nr_sorted && printed++ < 10) {
1062 ++ if (q->nr_sorted && !blk_queue_is_zoned(q) && printed++ < 10 ) {
1063 + printk(KERN_ERR "%s: forced dispatching is broken "
1064 + "(nr_sorted=%u), please report this\n",
1065 + q->elevator->type->elevator_name, q->nr_sorted);
1066 +diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
1067 +index 4ee7c041bb82..8882e90e868e 100644
1068 +--- a/crypto/ablkcipher.c
1069 ++++ b/crypto/ablkcipher.c
1070 +@@ -368,6 +368,7 @@ static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
1071 + strncpy(rblkcipher.type, "ablkcipher", sizeof(rblkcipher.type));
1072 + strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<default>",
1073 + sizeof(rblkcipher.geniv));
1074 ++ rblkcipher.geniv[sizeof(rblkcipher.geniv) - 1] = '\0';
1075 +
1076 + rblkcipher.blocksize = alg->cra_blocksize;
1077 + rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize;
1078 +@@ -442,6 +443,7 @@ static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
1079 + strncpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type));
1080 + strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<built-in>",
1081 + sizeof(rblkcipher.geniv));
1082 ++ rblkcipher.geniv[sizeof(rblkcipher.geniv) - 1] = '\0';
1083 +
1084 + rblkcipher.blocksize = alg->cra_blocksize;
1085 + rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize;
1086 +diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
1087 +index 77b5fa293f66..f93abf13b5d4 100644
1088 +--- a/crypto/blkcipher.c
1089 ++++ b/crypto/blkcipher.c
1090 +@@ -510,6 +510,7 @@ static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
1091 + strncpy(rblkcipher.type, "blkcipher", sizeof(rblkcipher.type));
1092 + strncpy(rblkcipher.geniv, alg->cra_blkcipher.geniv ?: "<default>",
1093 + sizeof(rblkcipher.geniv));
1094 ++ rblkcipher.geniv[sizeof(rblkcipher.geniv) - 1] = '\0';
1095 +
1096 + rblkcipher.blocksize = alg->cra_blocksize;
1097 + rblkcipher.min_keysize = alg->cra_blkcipher.min_keysize;
1098 +diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
1099 +index 2345a5ee2dbb..40ed3ec9fc94 100644
1100 +--- a/drivers/acpi/button.c
1101 ++++ b/drivers/acpi/button.c
1102 +@@ -235,9 +235,6 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
1103 + button->last_time = ktime_get();
1104 + }
1105 +
1106 +- if (state)
1107 +- acpi_pm_wakeup_event(&device->dev);
1108 +-
1109 + ret = blocking_notifier_call_chain(&acpi_lid_notifier, state, device);
1110 + if (ret == NOTIFY_DONE)
1111 + ret = blocking_notifier_call_chain(&acpi_lid_notifier, state,
1112 +@@ -366,7 +363,8 @@ int acpi_lid_open(void)
1113 + }
1114 + EXPORT_SYMBOL(acpi_lid_open);
1115 +
1116 +-static int acpi_lid_update_state(struct acpi_device *device)
1117 ++static int acpi_lid_update_state(struct acpi_device *device,
1118 ++ bool signal_wakeup)
1119 + {
1120 + int state;
1121 +
1122 +@@ -374,6 +372,9 @@ static int acpi_lid_update_state(struct acpi_device *device)
1123 + if (state < 0)
1124 + return state;
1125 +
1126 ++ if (state && signal_wakeup)
1127 ++ acpi_pm_wakeup_event(&device->dev);
1128 ++
1129 + return acpi_lid_notify_state(device, state);
1130 + }
1131 +
1132 +@@ -384,7 +385,7 @@ static void acpi_lid_initialize_state(struct acpi_device *device)
1133 + (void)acpi_lid_notify_state(device, 1);
1134 + break;
1135 + case ACPI_BUTTON_LID_INIT_METHOD:
1136 +- (void)acpi_lid_update_state(device);
1137 ++ (void)acpi_lid_update_state(device, false);
1138 + break;
1139 + case ACPI_BUTTON_LID_INIT_IGNORE:
1140 + default:
1141 +@@ -409,7 +410,7 @@ static void acpi_button_notify(struct acpi_device *device, u32 event)
1142 + users = button->input->users;
1143 + mutex_unlock(&button->input->mutex);
1144 + if (users)
1145 +- acpi_lid_update_state(device);
1146 ++ acpi_lid_update_state(device, true);
1147 + } else {
1148 + int keycode;
1149 +
1150 +diff --git a/drivers/ata/pata_ftide010.c b/drivers/ata/pata_ftide010.c
1151 +index 5d4b72e21161..569a4a662dcd 100644
1152 +--- a/drivers/ata/pata_ftide010.c
1153 ++++ b/drivers/ata/pata_ftide010.c
1154 +@@ -256,14 +256,12 @@ static struct ata_port_operations pata_ftide010_port_ops = {
1155 + .qc_issue = ftide010_qc_issue,
1156 + };
1157 +
1158 +-static struct ata_port_info ftide010_port_info[] = {
1159 +- {
1160 +- .flags = ATA_FLAG_SLAVE_POSS,
1161 +- .mwdma_mask = ATA_MWDMA2,
1162 +- .udma_mask = ATA_UDMA6,
1163 +- .pio_mask = ATA_PIO4,
1164 +- .port_ops = &pata_ftide010_port_ops,
1165 +- },
1166 ++static struct ata_port_info ftide010_port_info = {
1167 ++ .flags = ATA_FLAG_SLAVE_POSS,
1168 ++ .mwdma_mask = ATA_MWDMA2,
1169 ++ .udma_mask = ATA_UDMA6,
1170 ++ .pio_mask = ATA_PIO4,
1171 ++ .port_ops = &pata_ftide010_port_ops,
1172 + };
1173 +
1174 + #if IS_ENABLED(CONFIG_SATA_GEMINI)
1175 +@@ -349,6 +347,7 @@ static int pata_ftide010_gemini_cable_detect(struct ata_port *ap)
1176 + }
1177 +
1178 + static int pata_ftide010_gemini_init(struct ftide010 *ftide,
1179 ++ struct ata_port_info *pi,
1180 + bool is_ata1)
1181 + {
1182 + struct device *dev = ftide->dev;
1183 +@@ -373,7 +372,13 @@ static int pata_ftide010_gemini_init(struct ftide010 *ftide,
1184 +
1185 + /* Flag port as SATA-capable */
1186 + if (gemini_sata_bridge_enabled(sg, is_ata1))
1187 +- ftide010_port_info[0].flags |= ATA_FLAG_SATA;
1188 ++ pi->flags |= ATA_FLAG_SATA;
1189 ++
1190 ++ /* This device has broken DMA, only PIO works */
1191 ++ if (of_machine_is_compatible("itian,sq201")) {
1192 ++ pi->mwdma_mask = 0;
1193 ++ pi->udma_mask = 0;
1194 ++ }
1195 +
1196 + /*
1197 + * We assume that a simple 40-wire cable is used in the PATA mode.
1198 +@@ -435,6 +440,7 @@ static int pata_ftide010_gemini_init(struct ftide010 *ftide,
1199 + }
1200 + #else
1201 + static int pata_ftide010_gemini_init(struct ftide010 *ftide,
1202 ++ struct ata_port_info *pi,
1203 + bool is_ata1)
1204 + {
1205 + return -ENOTSUPP;
1206 +@@ -446,7 +452,7 @@ static int pata_ftide010_probe(struct platform_device *pdev)
1207 + {
1208 + struct device *dev = &pdev->dev;
1209 + struct device_node *np = dev->of_node;
1210 +- const struct ata_port_info pi = ftide010_port_info[0];
1211 ++ struct ata_port_info pi = ftide010_port_info;
1212 + const struct ata_port_info *ppi[] = { &pi, NULL };
1213 + struct ftide010 *ftide;
1214 + struct resource *res;
1215 +@@ -490,6 +496,7 @@ static int pata_ftide010_probe(struct platform_device *pdev)
1216 + * are ATA0. This will also set up the cable types.
1217 + */
1218 + ret = pata_ftide010_gemini_init(ftide,
1219 ++ &pi,
1220 + (res->start == 0x63400000));
1221 + if (ret)
1222 + goto err_dis_clk;
1223 +diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
1224 +index 8871b5044d9e..7d7c698c0213 100644
1225 +--- a/drivers/block/floppy.c
1226 ++++ b/drivers/block/floppy.c
1227 +@@ -3470,6 +3470,9 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
1228 + (struct floppy_struct **)&outparam);
1229 + if (ret)
1230 + return ret;
1231 ++ memcpy(&inparam.g, outparam,
1232 ++ offsetof(struct floppy_struct, name));
1233 ++ outparam = &inparam.g;
1234 + break;
1235 + case FDMSGON:
1236 + UDP->flags |= FTD_MSG;
1237 +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
1238 +index f73a27ea28cc..75947f04fc75 100644
1239 +--- a/drivers/bluetooth/btusb.c
1240 ++++ b/drivers/bluetooth/btusb.c
1241 +@@ -374,6 +374,7 @@ static const struct usb_device_id blacklist_table[] = {
1242 + { USB_DEVICE(0x7392, 0xa611), .driver_info = BTUSB_REALTEK },
1243 +
1244 + /* Additional Realtek 8723DE Bluetooth devices */
1245 ++ { USB_DEVICE(0x0bda, 0xb009), .driver_info = BTUSB_REALTEK },
1246 + { USB_DEVICE(0x2ff8, 0xb011), .driver_info = BTUSB_REALTEK },
1247 +
1248 + /* Additional Realtek 8821AE Bluetooth devices */
1249 +diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
1250 +index 80d60f43db56..4576a1268e0e 100644
1251 +--- a/drivers/bus/ti-sysc.c
1252 ++++ b/drivers/bus/ti-sysc.c
1253 +@@ -490,32 +490,29 @@ static int sysc_check_registers(struct sysc *ddata)
1254 +
1255 + /**
1256 + * syc_ioremap - ioremap register space for the interconnect target module
1257 +- * @ddata: deviec driver data
1258 ++ * @ddata: device driver data
1259 + *
1260 + * Note that the interconnect target module registers can be anywhere
1261 +- * within the first child device address space. For example, SGX has
1262 +- * them at offset 0x1fc00 in the 32MB module address space. We just
1263 +- * what we need around the interconnect target module registers.
1264 ++ * within the interconnect target module range. For example, SGX has
1265 ++ * them at offset 0x1fc00 in the 32MB module address space. And cpsw
1266 ++ * has them at offset 0x1200 in the CPSW_WR child. Usually the
1267 ++ * the interconnect target module registers are at the beginning of
1268 ++ * the module range though.
1269 + */
1270 + static int sysc_ioremap(struct sysc *ddata)
1271 + {
1272 +- u32 size = 0;
1273 +-
1274 +- if (ddata->offsets[SYSC_SYSSTATUS] >= 0)
1275 +- size = ddata->offsets[SYSC_SYSSTATUS];
1276 +- else if (ddata->offsets[SYSC_SYSCONFIG] >= 0)
1277 +- size = ddata->offsets[SYSC_SYSCONFIG];
1278 +- else if (ddata->offsets[SYSC_REVISION] >= 0)
1279 +- size = ddata->offsets[SYSC_REVISION];
1280 +- else
1281 +- return -EINVAL;
1282 ++ int size;
1283 +
1284 +- size &= 0xfff00;
1285 +- size += SZ_256;
1286 ++ size = max3(ddata->offsets[SYSC_REVISION],
1287 ++ ddata->offsets[SYSC_SYSCONFIG],
1288 ++ ddata->offsets[SYSC_SYSSTATUS]);
1289 ++
1290 ++ if (size < 0 || (size + sizeof(u32)) > ddata->module_size)
1291 ++ return -EINVAL;
1292 +
1293 + ddata->module_va = devm_ioremap(ddata->dev,
1294 + ddata->module_pa,
1295 +- size);
1296 ++ size + sizeof(u32));
1297 + if (!ddata->module_va)
1298 + return -EIO;
1299 +
1300 +@@ -1178,10 +1175,10 @@ static int sysc_child_suspend_noirq(struct device *dev)
1301 + if (!pm_runtime_status_suspended(dev)) {
1302 + error = pm_generic_runtime_suspend(dev);
1303 + if (error) {
1304 +- dev_err(dev, "%s error at %i: %i\n",
1305 +- __func__, __LINE__, error);
1306 ++ dev_warn(dev, "%s busy at %i: %i\n",
1307 ++ __func__, __LINE__, error);
1308 +
1309 +- return error;
1310 ++ return 0;
1311 + }
1312 +
1313 + error = sysc_runtime_suspend(ddata->dev);
1314 +diff --git a/drivers/clk/x86/clk-st.c b/drivers/clk/x86/clk-st.c
1315 +index fb62f3938008..3a0996f2d556 100644
1316 +--- a/drivers/clk/x86/clk-st.c
1317 ++++ b/drivers/clk/x86/clk-st.c
1318 +@@ -46,7 +46,7 @@ static int st_clk_probe(struct platform_device *pdev)
1319 + clk_oscout1_parents, ARRAY_SIZE(clk_oscout1_parents),
1320 + 0, st_data->base + CLKDRVSTR2, OSCOUT1CLK25MHZ, 3, 0, NULL);
1321 +
1322 +- clk_set_parent(hws[ST_CLK_MUX]->clk, hws[ST_CLK_25M]->clk);
1323 ++ clk_set_parent(hws[ST_CLK_MUX]->clk, hws[ST_CLK_48M]->clk);
1324 +
1325 + hws[ST_CLK_GATE] = clk_hw_register_gate(NULL, "oscout1", "oscout1_mux",
1326 + 0, st_data->base + MISCCLKCNTL1, OSCCLKENB,
1327 +diff --git a/drivers/crypto/cavium/nitrox/nitrox_dev.h b/drivers/crypto/cavium/nitrox/nitrox_dev.h
1328 +index 9a476bb6d4c7..af596455b420 100644
1329 +--- a/drivers/crypto/cavium/nitrox/nitrox_dev.h
1330 ++++ b/drivers/crypto/cavium/nitrox/nitrox_dev.h
1331 +@@ -35,6 +35,7 @@ struct nitrox_cmdq {
1332 + /* requests in backlog queues */
1333 + atomic_t backlog_count;
1334 +
1335 ++ int write_idx;
1336 + /* command size 32B/64B */
1337 + u8 instr_size;
1338 + u8 qno;
1339 +@@ -87,7 +88,7 @@ struct nitrox_bh {
1340 + struct bh_data *slc;
1341 + };
1342 +
1343 +-/* NITROX-5 driver state */
1344 ++/* NITROX-V driver state */
1345 + #define NITROX_UCODE_LOADED 0
1346 + #define NITROX_READY 1
1347 +
1348 +diff --git a/drivers/crypto/cavium/nitrox/nitrox_lib.c b/drivers/crypto/cavium/nitrox/nitrox_lib.c
1349 +index 4fdc921ba611..9906c0086647 100644
1350 +--- a/drivers/crypto/cavium/nitrox/nitrox_lib.c
1351 ++++ b/drivers/crypto/cavium/nitrox/nitrox_lib.c
1352 +@@ -36,6 +36,7 @@ static int cmdq_common_init(struct nitrox_cmdq *cmdq)
1353 + cmdq->head = PTR_ALIGN(cmdq->head_unaligned, PKT_IN_ALIGN);
1354 + cmdq->dma = PTR_ALIGN(cmdq->dma_unaligned, PKT_IN_ALIGN);
1355 + cmdq->qsize = (qsize + PKT_IN_ALIGN);
1356 ++ cmdq->write_idx = 0;
1357 +
1358 + spin_lock_init(&cmdq->response_lock);
1359 + spin_lock_init(&cmdq->cmdq_lock);
1360 +diff --git a/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c b/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c
1361 +index deaefd532aaa..4a362fc22f62 100644
1362 +--- a/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c
1363 ++++ b/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c
1364 +@@ -42,6 +42,16 @@
1365 + * Invalid flag options in AES-CCM IV.
1366 + */
1367 +
1368 ++static inline int incr_index(int index, int count, int max)
1369 ++{
1370 ++ if ((index + count) >= max)
1371 ++ index = index + count - max;
1372 ++ else
1373 ++ index += count;
1374 ++
1375 ++ return index;
1376 ++}
1377 ++
1378 + /**
1379 + * dma_free_sglist - unmap and free the sg lists.
1380 + * @ndev: N5 device
1381 +@@ -426,30 +436,29 @@ static void post_se_instr(struct nitrox_softreq *sr,
1382 + struct nitrox_cmdq *cmdq)
1383 + {
1384 + struct nitrox_device *ndev = sr->ndev;
1385 +- union nps_pkt_in_instr_baoff_dbell pkt_in_baoff_dbell;
1386 +- u64 offset;
1387 ++ int idx;
1388 + u8 *ent;
1389 +
1390 + spin_lock_bh(&cmdq->cmdq_lock);
1391 +
1392 +- /* get the next write offset */
1393 +- offset = NPS_PKT_IN_INSTR_BAOFF_DBELLX(cmdq->qno);
1394 +- pkt_in_baoff_dbell.value = nitrox_read_csr(ndev, offset);
1395 ++ idx = cmdq->write_idx;
1396 + /* copy the instruction */
1397 +- ent = cmdq->head + pkt_in_baoff_dbell.s.aoff;
1398 ++ ent = cmdq->head + (idx * cmdq->instr_size);
1399 + memcpy(ent, &sr->instr, cmdq->instr_size);
1400 +- /* flush the command queue updates */
1401 +- dma_wmb();
1402 +
1403 +- sr->tstamp = jiffies;
1404 + atomic_set(&sr->status, REQ_POSTED);
1405 + response_list_add(sr, cmdq);
1406 ++ sr->tstamp = jiffies;
1407 ++ /* flush the command queue updates */
1408 ++ dma_wmb();
1409 +
1410 + /* Ring doorbell with count 1 */
1411 + writeq(1, cmdq->dbell_csr_addr);
1412 + /* orders the doorbell rings */
1413 + mmiowb();
1414 +
1415 ++ cmdq->write_idx = incr_index(idx, 1, ndev->qlen);
1416 ++
1417 + spin_unlock_bh(&cmdq->cmdq_lock);
1418 + }
1419 +
1420 +@@ -459,6 +468,9 @@ static int post_backlog_cmds(struct nitrox_cmdq *cmdq)
1421 + struct nitrox_softreq *sr, *tmp;
1422 + int ret = 0;
1423 +
1424 ++ if (!atomic_read(&cmdq->backlog_count))
1425 ++ return 0;
1426 ++
1427 + spin_lock_bh(&cmdq->backlog_lock);
1428 +
1429 + list_for_each_entry_safe(sr, tmp, &cmdq->backlog_head, backlog) {
1430 +@@ -466,7 +478,7 @@ static int post_backlog_cmds(struct nitrox_cmdq *cmdq)
1431 +
1432 + /* submit until space available */
1433 + if (unlikely(cmdq_full(cmdq, ndev->qlen))) {
1434 +- ret = -EBUSY;
1435 ++ ret = -ENOSPC;
1436 + break;
1437 + }
1438 + /* delete from backlog list */
1439 +@@ -491,23 +503,20 @@ static int nitrox_enqueue_request(struct nitrox_softreq *sr)
1440 + {
1441 + struct nitrox_cmdq *cmdq = sr->cmdq;
1442 + struct nitrox_device *ndev = sr->ndev;
1443 +- int ret = -EBUSY;
1444 ++
1445 ++ /* try to post backlog requests */
1446 ++ post_backlog_cmds(cmdq);
1447 +
1448 + if (unlikely(cmdq_full(cmdq, ndev->qlen))) {
1449 + if (!(sr->flags & CRYPTO_TFM_REQ_MAY_BACKLOG))
1450 +- return -EAGAIN;
1451 +-
1452 ++ return -ENOSPC;
1453 ++ /* add to backlog list */
1454 + backlog_list_add(sr, cmdq);
1455 +- } else {
1456 +- ret = post_backlog_cmds(cmdq);
1457 +- if (ret) {
1458 +- backlog_list_add(sr, cmdq);
1459 +- return ret;
1460 +- }
1461 +- post_se_instr(sr, cmdq);
1462 +- ret = -EINPROGRESS;
1463 ++ return -EBUSY;
1464 + }
1465 +- return ret;
1466 ++ post_se_instr(sr, cmdq);
1467 ++
1468 ++ return -EINPROGRESS;
1469 + }
1470 +
1471 + /**
1472 +@@ -624,11 +633,9 @@ int nitrox_process_se_request(struct nitrox_device *ndev,
1473 + */
1474 + sr->instr.fdata[0] = *((u64 *)&req->gph);
1475 + sr->instr.fdata[1] = 0;
1476 +- /* flush the soft_req changes before posting the cmd */
1477 +- wmb();
1478 +
1479 + ret = nitrox_enqueue_request(sr);
1480 +- if (ret == -EAGAIN)
1481 ++ if (ret == -ENOSPC)
1482 + goto send_fail;
1483 +
1484 + return ret;
1485 +diff --git a/drivers/crypto/chelsio/chtls/chtls.h b/drivers/crypto/chelsio/chtls/chtls.h
1486 +index a53a0e6ba024..7725b6ee14ef 100644
1487 +--- a/drivers/crypto/chelsio/chtls/chtls.h
1488 ++++ b/drivers/crypto/chelsio/chtls/chtls.h
1489 +@@ -96,6 +96,10 @@ enum csk_flags {
1490 + CSK_CONN_INLINE, /* Connection on HW */
1491 + };
1492 +
1493 ++enum chtls_cdev_state {
1494 ++ CHTLS_CDEV_STATE_UP = 1
1495 ++};
1496 ++
1497 + struct listen_ctx {
1498 + struct sock *lsk;
1499 + struct chtls_dev *cdev;
1500 +@@ -146,6 +150,7 @@ struct chtls_dev {
1501 + unsigned int send_page_order;
1502 + int max_host_sndbuf;
1503 + struct key_map kmap;
1504 ++ unsigned int cdev_state;
1505 + };
1506 +
1507 + struct chtls_hws {
1508 +diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c b/drivers/crypto/chelsio/chtls/chtls_main.c
1509 +index 9b07f9165658..f59b044ebd25 100644
1510 +--- a/drivers/crypto/chelsio/chtls/chtls_main.c
1511 ++++ b/drivers/crypto/chelsio/chtls/chtls_main.c
1512 +@@ -160,6 +160,7 @@ static void chtls_register_dev(struct chtls_dev *cdev)
1513 + tlsdev->hash = chtls_create_hash;
1514 + tlsdev->unhash = chtls_destroy_hash;
1515 + tls_register_device(&cdev->tlsdev);
1516 ++ cdev->cdev_state = CHTLS_CDEV_STATE_UP;
1517 + }
1518 +
1519 + static void chtls_unregister_dev(struct chtls_dev *cdev)
1520 +@@ -281,8 +282,10 @@ static void chtls_free_all_uld(void)
1521 + struct chtls_dev *cdev, *tmp;
1522 +
1523 + mutex_lock(&cdev_mutex);
1524 +- list_for_each_entry_safe(cdev, tmp, &cdev_list, list)
1525 +- chtls_free_uld(cdev);
1526 ++ list_for_each_entry_safe(cdev, tmp, &cdev_list, list) {
1527 ++ if (cdev->cdev_state == CHTLS_CDEV_STATE_UP)
1528 ++ chtls_free_uld(cdev);
1529 ++ }
1530 + mutex_unlock(&cdev_mutex);
1531 + }
1532 +
1533 +diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
1534 +index d0d5c4dbe097..5762c3c383f2 100644
1535 +--- a/drivers/edac/altera_edac.c
1536 ++++ b/drivers/edac/altera_edac.c
1537 +@@ -730,7 +730,8 @@ static int altr_s10_sdram_probe(struct platform_device *pdev)
1538 + S10_DDR0_IRQ_MASK)) {
1539 + edac_printk(KERN_ERR, EDAC_MC,
1540 + "Error clearing SDRAM ECC count\n");
1541 +- return -ENODEV;
1542 ++ ret = -ENODEV;
1543 ++ goto err2;
1544 + }
1545 +
1546 + if (regmap_update_bits(drvdata->mc_vbase, priv->ecc_irq_en_offset,
1547 +diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
1548 +index 7481955160a4..20374b8248f0 100644
1549 +--- a/drivers/edac/edac_mc_sysfs.c
1550 ++++ b/drivers/edac/edac_mc_sysfs.c
1551 +@@ -1075,14 +1075,14 @@ int __init edac_mc_sysfs_init(void)
1552 +
1553 + err = device_add(mci_pdev);
1554 + if (err < 0)
1555 +- goto out_dev_free;
1556 ++ goto out_put_device;
1557 +
1558 + edac_dbg(0, "device %s created\n", dev_name(mci_pdev));
1559 +
1560 + return 0;
1561 +
1562 +- out_dev_free:
1563 +- kfree(mci_pdev);
1564 ++ out_put_device:
1565 ++ put_device(mci_pdev);
1566 + out:
1567 + return err;
1568 + }
1569 +diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
1570 +index 8ed4dd9c571b..8e120bf60624 100644
1571 +--- a/drivers/edac/i7core_edac.c
1572 ++++ b/drivers/edac/i7core_edac.c
1573 +@@ -1177,15 +1177,14 @@ static int i7core_create_sysfs_devices(struct mem_ctl_info *mci)
1574 +
1575 + rc = device_add(pvt->addrmatch_dev);
1576 + if (rc < 0)
1577 +- return rc;
1578 ++ goto err_put_addrmatch;
1579 +
1580 + if (!pvt->is_registered) {
1581 + pvt->chancounts_dev = kzalloc(sizeof(*pvt->chancounts_dev),
1582 + GFP_KERNEL);
1583 + if (!pvt->chancounts_dev) {
1584 +- put_device(pvt->addrmatch_dev);
1585 +- device_del(pvt->addrmatch_dev);
1586 +- return -ENOMEM;
1587 ++ rc = -ENOMEM;
1588 ++ goto err_del_addrmatch;
1589 + }
1590 +
1591 + pvt->chancounts_dev->type = &all_channel_counts_type;
1592 +@@ -1199,9 +1198,18 @@ static int i7core_create_sysfs_devices(struct mem_ctl_info *mci)
1593 +
1594 + rc = device_add(pvt->chancounts_dev);
1595 + if (rc < 0)
1596 +- return rc;
1597 ++ goto err_put_chancounts;
1598 + }
1599 + return 0;
1600 ++
1601 ++err_put_chancounts:
1602 ++ put_device(pvt->chancounts_dev);
1603 ++err_del_addrmatch:
1604 ++ device_del(pvt->addrmatch_dev);
1605 ++err_put_addrmatch:
1606 ++ put_device(pvt->addrmatch_dev);
1607 ++
1608 ++ return rc;
1609 + }
1610 +
1611 + static void i7core_delete_sysfs_devices(struct mem_ctl_info *mci)
1612 +@@ -1211,11 +1219,11 @@ static void i7core_delete_sysfs_devices(struct mem_ctl_info *mci)
1613 + edac_dbg(1, "\n");
1614 +
1615 + if (!pvt->is_registered) {
1616 +- put_device(pvt->chancounts_dev);
1617 + device_del(pvt->chancounts_dev);
1618 ++ put_device(pvt->chancounts_dev);
1619 + }
1620 +- put_device(pvt->addrmatch_dev);
1621 + device_del(pvt->addrmatch_dev);
1622 ++ put_device(pvt->addrmatch_dev);
1623 + }
1624 +
1625 + /****************************************************************************
1626 +diff --git a/drivers/gpio/gpio-menz127.c b/drivers/gpio/gpio-menz127.c
1627 +index e1037582e34d..b2635326546e 100644
1628 +--- a/drivers/gpio/gpio-menz127.c
1629 ++++ b/drivers/gpio/gpio-menz127.c
1630 +@@ -56,9 +56,9 @@ static int men_z127_debounce(struct gpio_chip *gc, unsigned gpio,
1631 + rnd = fls(debounce) - 1;
1632 +
1633 + if (rnd && (debounce & BIT(rnd - 1)))
1634 +- debounce = round_up(debounce, MEN_Z127_DB_MIN_US);
1635 ++ debounce = roundup(debounce, MEN_Z127_DB_MIN_US);
1636 + else
1637 +- debounce = round_down(debounce, MEN_Z127_DB_MIN_US);
1638 ++ debounce = rounddown(debounce, MEN_Z127_DB_MIN_US);
1639 +
1640 + if (debounce > MEN_Z127_DB_MAX_US)
1641 + debounce = MEN_Z127_DB_MAX_US;
1642 +diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
1643 +index d5d79727c55d..d9e4da146227 100644
1644 +--- a/drivers/gpio/gpio-tegra.c
1645 ++++ b/drivers/gpio/gpio-tegra.c
1646 +@@ -323,13 +323,6 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type)
1647 + return -EINVAL;
1648 + }
1649 +
1650 +- ret = gpiochip_lock_as_irq(&tgi->gc, gpio);
1651 +- if (ret) {
1652 +- dev_err(tgi->dev,
1653 +- "unable to lock Tegra GPIO %u as IRQ\n", gpio);
1654 +- return ret;
1655 +- }
1656 +-
1657 + spin_lock_irqsave(&bank->lvl_lock[port], flags);
1658 +
1659 + val = tegra_gpio_readl(tgi, GPIO_INT_LVL(tgi, gpio));
1660 +@@ -342,6 +335,14 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type)
1661 + tegra_gpio_mask_write(tgi, GPIO_MSK_OE(tgi, gpio), gpio, 0);
1662 + tegra_gpio_enable(tgi, gpio);
1663 +
1664 ++ ret = gpiochip_lock_as_irq(&tgi->gc, gpio);
1665 ++ if (ret) {
1666 ++ dev_err(tgi->dev,
1667 ++ "unable to lock Tegra GPIO %u as IRQ\n", gpio);
1668 ++ tegra_gpio_disable(tgi, gpio);
1669 ++ return ret;
1670 ++ }
1671 ++
1672 + if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
1673 + irq_set_handler_locked(d, handle_level_irq);
1674 + else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
1675 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
1676 +index 5a196ec49be8..7200eea4f918 100644
1677 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
1678 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
1679 +@@ -975,13 +975,9 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
1680 + if (r)
1681 + return r;
1682 +
1683 +- if (chunk_ib->flags & AMDGPU_IB_FLAG_PREAMBLE) {
1684 +- parser->job->preamble_status |= AMDGPU_PREAMBLE_IB_PRESENT;
1685 +- if (!parser->ctx->preamble_presented) {
1686 +- parser->job->preamble_status |= AMDGPU_PREAMBLE_IB_PRESENT_FIRST;
1687 +- parser->ctx->preamble_presented = true;
1688 +- }
1689 +- }
1690 ++ if (chunk_ib->flags & AMDGPU_IB_FLAG_PREAMBLE)
1691 ++ parser->job->preamble_status |=
1692 ++ AMDGPU_PREAMBLE_IB_PRESENT;
1693 +
1694 + if (parser->job->ring && parser->job->ring != ring)
1695 + return -EINVAL;
1696 +@@ -1206,6 +1202,12 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
1697 +
1698 + amdgpu_cs_post_dependencies(p);
1699 +
1700 ++ if ((job->preamble_status & AMDGPU_PREAMBLE_IB_PRESENT) &&
1701 ++ !p->ctx->preamble_presented) {
1702 ++ job->preamble_status |= AMDGPU_PREAMBLE_IB_PRESENT_FIRST;
1703 ++ p->ctx->preamble_presented = true;
1704 ++ }
1705 ++
1706 + cs->out.handle = seq;
1707 + job->uf_sequence = seq;
1708 +
1709 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
1710 +index 7aaa263ad8c7..6b5d4a20860d 100644
1711 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
1712 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
1713 +@@ -164,8 +164,10 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
1714 + return r;
1715 + }
1716 +
1717 ++ need_ctx_switch = ring->current_ctx != fence_ctx;
1718 + if (ring->funcs->emit_pipeline_sync && job &&
1719 + ((tmp = amdgpu_sync_get_fence(&job->sched_sync, NULL)) ||
1720 ++ (amdgpu_sriov_vf(adev) && need_ctx_switch) ||
1721 + amdgpu_vm_need_pipeline_sync(ring, job))) {
1722 + need_pipe_sync = true;
1723 + dma_fence_put(tmp);
1724 +@@ -196,7 +198,6 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
1725 + }
1726 +
1727 + skip_preamble = ring->current_ctx == fence_ctx;
1728 +- need_ctx_switch = ring->current_ctx != fence_ctx;
1729 + if (job && ring->funcs->emit_cntxcntl) {
1730 + if (need_ctx_switch)
1731 + status |= AMDGPU_HAVE_CTX_SWITCH;
1732 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
1733 +index fdcb498f6d19..c31fff32a321 100644
1734 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
1735 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
1736 +@@ -123,6 +123,7 @@ static void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base,
1737 + * is validated on next vm use to avoid fault.
1738 + * */
1739 + list_move_tail(&base->vm_status, &vm->evicted);
1740 ++ base->moved = true;
1741 + }
1742 +
1743 + /**
1744 +@@ -303,7 +304,6 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
1745 + uint64_t addr;
1746 + int r;
1747 +
1748 +- addr = amdgpu_bo_gpu_offset(bo);
1749 + entries = amdgpu_bo_size(bo) / 8;
1750 +
1751 + if (pte_support_ats) {
1752 +@@ -335,6 +335,7 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
1753 + if (r)
1754 + goto error;
1755 +
1756 ++ addr = amdgpu_bo_gpu_offset(bo);
1757 + if (ats_entries) {
1758 + uint64_t ats_value;
1759 +
1760 +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
1761 +index 818874b13c99..9057a5adb31b 100644
1762 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
1763 ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
1764 +@@ -5614,6 +5614,11 @@ static int gfx_v8_0_set_powergating_state(void *handle,
1765 + if (amdgpu_sriov_vf(adev))
1766 + return 0;
1767 +
1768 ++ if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_SMG |
1769 ++ AMD_PG_SUPPORT_RLC_SMU_HS |
1770 ++ AMD_PG_SUPPORT_CP |
1771 ++ AMD_PG_SUPPORT_GFX_DMG))
1772 ++ adev->gfx.rlc.funcs->enter_safe_mode(adev);
1773 + switch (adev->asic_type) {
1774 + case CHIP_CARRIZO:
1775 + case CHIP_STONEY:
1776 +@@ -5663,7 +5668,11 @@ static int gfx_v8_0_set_powergating_state(void *handle,
1777 + default:
1778 + break;
1779 + }
1780 +-
1781 ++ if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_SMG |
1782 ++ AMD_PG_SUPPORT_RLC_SMU_HS |
1783 ++ AMD_PG_SUPPORT_CP |
1784 ++ AMD_PG_SUPPORT_GFX_DMG))
1785 ++ adev->gfx.rlc.funcs->exit_safe_mode(adev);
1786 + return 0;
1787 + }
1788 +
1789 +diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
1790 +index 7a1e77c93bf1..d8e469c594bb 100644
1791 +--- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
1792 ++++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
1793 +@@ -1354,8 +1354,6 @@ static int kv_dpm_enable(struct amdgpu_device *adev)
1794 + return ret;
1795 + }
1796 +
1797 +- kv_update_current_ps(adev, adev->pm.dpm.boot_ps);
1798 +-
1799 + if (adev->irq.installed &&
1800 + amdgpu_is_internal_thermal_sensor(adev->pm.int_thermal_type)) {
1801 + ret = kv_set_thermal_temperature_range(adev, KV_TEMP_RANGE_MIN, KV_TEMP_RANGE_MAX);
1802 +@@ -3061,7 +3059,7 @@ static int kv_dpm_hw_init(void *handle)
1803 + else
1804 + adev->pm.dpm_enabled = true;
1805 + mutex_unlock(&adev->pm.mutex);
1806 +-
1807 ++ amdgpu_pm_compute_clocks(adev);
1808 + return ret;
1809 + }
1810 +
1811 +diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
1812 +index 5c97a3671726..606f461dce49 100644
1813 +--- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c
1814 ++++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
1815 +@@ -6887,7 +6887,6 @@ static int si_dpm_enable(struct amdgpu_device *adev)
1816 +
1817 + si_enable_auto_throttle_source(adev, AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL, true);
1818 + si_thermal_start_thermal_controller(adev);
1819 +- ni_update_current_ps(adev, boot_ps);
1820 +
1821 + return 0;
1822 + }
1823 +@@ -7764,7 +7763,7 @@ static int si_dpm_hw_init(void *handle)
1824 + else
1825 + adev->pm.dpm_enabled = true;
1826 + mutex_unlock(&adev->pm.mutex);
1827 +-
1828 ++ amdgpu_pm_compute_clocks(adev);
1829 + return ret;
1830 + }
1831 +
1832 +diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
1833 +index 88b09dd758ba..ca137757a69e 100644
1834 +--- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
1835 ++++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
1836 +@@ -133,7 +133,7 @@ static bool calculate_fb_and_fractional_fb_divider(
1837 + uint64_t feedback_divider;
1838 +
1839 + feedback_divider =
1840 +- (uint64_t)(target_pix_clk_khz * ref_divider * post_divider);
1841 ++ (uint64_t)target_pix_clk_khz * ref_divider * post_divider;
1842 + feedback_divider *= 10;
1843 + /* additional factor, since we divide by 10 afterwards */
1844 + feedback_divider *= (uint64_t)(calc_pll_cs->fract_fb_divider_factor);
1845 +@@ -145,8 +145,8 @@ static bool calculate_fb_and_fractional_fb_divider(
1846 + * of fractional feedback decimal point and the fractional FB Divider precision
1847 + * is 2 then the equation becomes (ullfeedbackDivider + 5*100) / (10*100))*/
1848 +
1849 +- feedback_divider += (uint64_t)
1850 +- (5 * calc_pll_cs->fract_fb_divider_precision_factor);
1851 ++ feedback_divider += 5ULL *
1852 ++ calc_pll_cs->fract_fb_divider_precision_factor;
1853 + feedback_divider =
1854 + div_u64(feedback_divider,
1855 + calc_pll_cs->fract_fb_divider_precision_factor * 10);
1856 +@@ -203,8 +203,8 @@ static bool calc_fb_divider_checking_tolerance(
1857 + &fract_feedback_divider);
1858 +
1859 + /*Actual calculated value*/
1860 +- actual_calc_clk_khz = (uint64_t)(feedback_divider *
1861 +- calc_pll_cs->fract_fb_divider_factor) +
1862 ++ actual_calc_clk_khz = (uint64_t)feedback_divider *
1863 ++ calc_pll_cs->fract_fb_divider_factor +
1864 + fract_feedback_divider;
1865 + actual_calc_clk_khz *= calc_pll_cs->ref_freq_khz;
1866 + actual_calc_clk_khz =
1867 +diff --git a/drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c b/drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c
1868 +index c2037daa8e66..0efbf411667a 100644
1869 +--- a/drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c
1870 ++++ b/drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c
1871 +@@ -239,6 +239,8 @@ void dml1_extract_rq_regs(
1872 + extract_rq_sizing_regs(mode_lib, &(rq_regs->rq_regs_l), rq_param.sizing.rq_l);
1873 + if (rq_param.yuv420)
1874 + extract_rq_sizing_regs(mode_lib, &(rq_regs->rq_regs_c), rq_param.sizing.rq_c);
1875 ++ else
1876 ++ memset(&(rq_regs->rq_regs_c), 0, sizeof(rq_regs->rq_regs_c));
1877 +
1878 + rq_regs->rq_regs_l.swath_height = dml_log2(rq_param.dlg.rq_l.swath_height);
1879 + rq_regs->rq_regs_c.swath_height = dml_log2(rq_param.dlg.rq_c.swath_height);
1880 +diff --git a/drivers/gpu/drm/omapdrm/omap_debugfs.c b/drivers/gpu/drm/omapdrm/omap_debugfs.c
1881 +index b42e286616b0..84da7a5b84f3 100644
1882 +--- a/drivers/gpu/drm/omapdrm/omap_debugfs.c
1883 ++++ b/drivers/gpu/drm/omapdrm/omap_debugfs.c
1884 +@@ -37,7 +37,9 @@ static int gem_show(struct seq_file *m, void *arg)
1885 + return ret;
1886 +
1887 + seq_printf(m, "All Objects:\n");
1888 ++ mutex_lock(&priv->list_lock);
1889 + omap_gem_describe_objects(&priv->obj_list, m);
1890 ++ mutex_unlock(&priv->list_lock);
1891 +
1892 + mutex_unlock(&dev->struct_mutex);
1893 +
1894 +diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
1895 +index ef3b0e3571ec..5fcf9eaf3eaf 100644
1896 +--- a/drivers/gpu/drm/omapdrm/omap_drv.c
1897 ++++ b/drivers/gpu/drm/omapdrm/omap_drv.c
1898 +@@ -540,7 +540,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
1899 + priv->omaprev = soc ? (unsigned int)soc->data : 0;
1900 + priv->wq = alloc_ordered_workqueue("omapdrm", 0);
1901 +
1902 +- spin_lock_init(&priv->list_lock);
1903 ++ mutex_init(&priv->list_lock);
1904 + INIT_LIST_HEAD(&priv->obj_list);
1905 +
1906 + /* Allocate and initialize the DRM device. */
1907 +diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
1908 +index 6eaee4df4559..f27c8e216adf 100644
1909 +--- a/drivers/gpu/drm/omapdrm/omap_drv.h
1910 ++++ b/drivers/gpu/drm/omapdrm/omap_drv.h
1911 +@@ -71,7 +71,7 @@ struct omap_drm_private {
1912 + struct workqueue_struct *wq;
1913 +
1914 + /* lock for obj_list below */
1915 +- spinlock_t list_lock;
1916 ++ struct mutex list_lock;
1917 +
1918 + /* list of GEM objects: */
1919 + struct list_head obj_list;
1920 +diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
1921 +index 17a53d207978..7a029b892a37 100644
1922 +--- a/drivers/gpu/drm/omapdrm/omap_gem.c
1923 ++++ b/drivers/gpu/drm/omapdrm/omap_gem.c
1924 +@@ -1001,6 +1001,7 @@ int omap_gem_resume(struct drm_device *dev)
1925 + struct omap_gem_object *omap_obj;
1926 + int ret = 0;
1927 +
1928 ++ mutex_lock(&priv->list_lock);
1929 + list_for_each_entry(omap_obj, &priv->obj_list, mm_list) {
1930 + if (omap_obj->block) {
1931 + struct drm_gem_object *obj = &omap_obj->base;
1932 +@@ -1012,12 +1013,14 @@ int omap_gem_resume(struct drm_device *dev)
1933 + omap_obj->roll, true);
1934 + if (ret) {
1935 + dev_err(dev->dev, "could not repin: %d\n", ret);
1936 +- return ret;
1937 ++ goto done;
1938 + }
1939 + }
1940 + }
1941 +
1942 +- return 0;
1943 ++done:
1944 ++ mutex_unlock(&priv->list_lock);
1945 ++ return ret;
1946 + }
1947 + #endif
1948 +
1949 +@@ -1085,9 +1088,9 @@ void omap_gem_free_object(struct drm_gem_object *obj)
1950 +
1951 + WARN_ON(!mutex_is_locked(&dev->struct_mutex));
1952 +
1953 +- spin_lock(&priv->list_lock);
1954 ++ mutex_lock(&priv->list_lock);
1955 + list_del(&omap_obj->mm_list);
1956 +- spin_unlock(&priv->list_lock);
1957 ++ mutex_unlock(&priv->list_lock);
1958 +
1959 + /* this means the object is still pinned.. which really should
1960 + * not happen. I think..
1961 +@@ -1206,9 +1209,9 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev,
1962 + goto err_release;
1963 + }
1964 +
1965 +- spin_lock(&priv->list_lock);
1966 ++ mutex_lock(&priv->list_lock);
1967 + list_add(&omap_obj->mm_list, &priv->obj_list);
1968 +- spin_unlock(&priv->list_lock);
1969 ++ mutex_unlock(&priv->list_lock);
1970 +
1971 + return obj;
1972 +
1973 +diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
1974 +index 50d19605c38f..e15fa2389e3f 100644
1975 +--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
1976 ++++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
1977 +@@ -283,7 +283,6 @@ static int sun4i_drv_add_endpoints(struct device *dev,
1978 + remote = of_graph_get_remote_port_parent(ep);
1979 + if (!remote) {
1980 + DRM_DEBUG_DRIVER("Error retrieving the output node\n");
1981 +- of_node_put(remote);
1982 + continue;
1983 + }
1984 +
1985 +@@ -297,11 +296,13 @@ static int sun4i_drv_add_endpoints(struct device *dev,
1986 +
1987 + if (of_graph_parse_endpoint(ep, &endpoint)) {
1988 + DRM_DEBUG_DRIVER("Couldn't parse endpoint\n");
1989 ++ of_node_put(remote);
1990 + continue;
1991 + }
1992 +
1993 + if (!endpoint.id) {
1994 + DRM_DEBUG_DRIVER("Endpoint is our panel... skipping\n");
1995 ++ of_node_put(remote);
1996 + continue;
1997 + }
1998 + }
1999 +diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c
2000 +index 5a52fc489a9d..966688f04741 100644
2001 +--- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c
2002 ++++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c
2003 +@@ -477,13 +477,15 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node)
2004 + dev_err(dev, "Couldn't create the PHY clock\n");
2005 + goto err_put_clk_pll0;
2006 + }
2007 ++
2008 ++ clk_prepare_enable(phy->clk_phy);
2009 + }
2010 +
2011 + phy->rst_phy = of_reset_control_get_shared(node, "phy");
2012 + if (IS_ERR(phy->rst_phy)) {
2013 + dev_err(dev, "Could not get phy reset control\n");
2014 + ret = PTR_ERR(phy->rst_phy);
2015 +- goto err_put_clk_pll0;
2016 ++ goto err_disable_clk_phy;
2017 + }
2018 +
2019 + ret = reset_control_deassert(phy->rst_phy);
2020 +@@ -514,6 +516,8 @@ err_deassert_rst_phy:
2021 + reset_control_assert(phy->rst_phy);
2022 + err_put_rst_phy:
2023 + reset_control_put(phy->rst_phy);
2024 ++err_disable_clk_phy:
2025 ++ clk_disable_unprepare(phy->clk_phy);
2026 + err_put_clk_pll0:
2027 + if (phy->variant->has_phy_clk)
2028 + clk_put(phy->clk_pll0);
2029 +@@ -531,6 +535,7 @@ void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi)
2030 +
2031 + clk_disable_unprepare(phy->clk_mod);
2032 + clk_disable_unprepare(phy->clk_bus);
2033 ++ clk_disable_unprepare(phy->clk_phy);
2034 +
2035 + reset_control_assert(phy->rst_phy);
2036 +
2037 +diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
2038 +index a043ac3aae98..26005abd9c5d 100644
2039 +--- a/drivers/gpu/drm/v3d/v3d_drv.h
2040 ++++ b/drivers/gpu/drm/v3d/v3d_drv.h
2041 +@@ -85,6 +85,11 @@ struct v3d_dev {
2042 + */
2043 + struct mutex reset_lock;
2044 +
2045 ++ /* Lock taken when creating and pushing the GPU scheduler
2046 ++ * jobs, to keep the sched-fence seqnos in order.
2047 ++ */
2048 ++ struct mutex sched_lock;
2049 ++
2050 + struct {
2051 + u32 num_allocated;
2052 + u32 pages_allocated;
2053 +diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
2054 +index b513f9189caf..269fe16379c0 100644
2055 +--- a/drivers/gpu/drm/v3d/v3d_gem.c
2056 ++++ b/drivers/gpu/drm/v3d/v3d_gem.c
2057 +@@ -550,6 +550,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
2058 + if (ret)
2059 + goto fail;
2060 +
2061 ++ mutex_lock(&v3d->sched_lock);
2062 + if (exec->bin.start != exec->bin.end) {
2063 + ret = drm_sched_job_init(&exec->bin.base,
2064 + &v3d->queue[V3D_BIN].sched,
2065 +@@ -576,6 +577,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
2066 + kref_get(&exec->refcount); /* put by scheduler job completion */
2067 + drm_sched_entity_push_job(&exec->render.base,
2068 + &v3d_priv->sched_entity[V3D_RENDER]);
2069 ++ mutex_unlock(&v3d->sched_lock);
2070 +
2071 + v3d_attach_object_fences(exec);
2072 +
2073 +@@ -594,6 +596,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
2074 + return 0;
2075 +
2076 + fail_unreserve:
2077 ++ mutex_unlock(&v3d->sched_lock);
2078 + v3d_unlock_bo_reservations(dev, exec, &acquire_ctx);
2079 + fail:
2080 + v3d_exec_put(exec);
2081 +@@ -615,6 +618,7 @@ v3d_gem_init(struct drm_device *dev)
2082 + spin_lock_init(&v3d->job_lock);
2083 + mutex_init(&v3d->bo_lock);
2084 + mutex_init(&v3d->reset_lock);
2085 ++ mutex_init(&v3d->sched_lock);
2086 +
2087 + /* Note: We don't allocate address 0. Various bits of HW
2088 + * treat 0 as special, such as the occlusion query counters
2089 +diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
2090 +index cf5aea1d6488..203ddf5723e8 100644
2091 +--- a/drivers/gpu/drm/vc4/vc4_plane.c
2092 ++++ b/drivers/gpu/drm/vc4/vc4_plane.c
2093 +@@ -543,6 +543,7 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
2094 + /* Control word */
2095 + vc4_dlist_write(vc4_state,
2096 + SCALER_CTL0_VALID |
2097 ++ VC4_SET_FIELD(SCALER_CTL0_RGBA_EXPAND_ROUND, SCALER_CTL0_RGBA_EXPAND) |
2098 + (format->pixel_order << SCALER_CTL0_ORDER_SHIFT) |
2099 + (format->hvs << SCALER_CTL0_PIXEL_FORMAT_SHIFT) |
2100 + VC4_SET_FIELD(tiling, SCALER_CTL0_TILING) |
2101 +@@ -874,7 +875,9 @@ static bool vc4_format_mod_supported(struct drm_plane *plane,
2102 + case DRM_FORMAT_YUV420:
2103 + case DRM_FORMAT_YVU420:
2104 + case DRM_FORMAT_NV12:
2105 ++ case DRM_FORMAT_NV21:
2106 + case DRM_FORMAT_NV16:
2107 ++ case DRM_FORMAT_NV61:
2108 + default:
2109 + return (modifier == DRM_FORMAT_MOD_LINEAR);
2110 + }
2111 +diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
2112 +index 43b1c7234316..9bc6f4867cb3 100644
2113 +--- a/drivers/hid/hid-ntrig.c
2114 ++++ b/drivers/hid/hid-ntrig.c
2115 +@@ -955,6 +955,8 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
2116 +
2117 + ret = sysfs_create_group(&hdev->dev.kobj,
2118 + &ntrig_attribute_group);
2119 ++ if (ret)
2120 ++ hid_err(hdev, "cannot create sysfs group\n");
2121 +
2122 + return 0;
2123 + err_free:
2124 +diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
2125 +index 5fd1159fc095..64773433b947 100644
2126 +--- a/drivers/hid/i2c-hid/i2c-hid.c
2127 ++++ b/drivers/hid/i2c-hid/i2c-hid.c
2128 +@@ -1004,18 +1004,18 @@ static int i2c_hid_probe(struct i2c_client *client,
2129 + return client->irq;
2130 + }
2131 +
2132 +- ihid = kzalloc(sizeof(struct i2c_hid), GFP_KERNEL);
2133 ++ ihid = devm_kzalloc(&client->dev, sizeof(*ihid), GFP_KERNEL);
2134 + if (!ihid)
2135 + return -ENOMEM;
2136 +
2137 + if (client->dev.of_node) {
2138 + ret = i2c_hid_of_probe(client, &ihid->pdata);
2139 + if (ret)
2140 +- goto err;
2141 ++ return ret;
2142 + } else if (!platform_data) {
2143 + ret = i2c_hid_acpi_pdata(client, &ihid->pdata);
2144 + if (ret)
2145 +- goto err;
2146 ++ return ret;
2147 + } else {
2148 + ihid->pdata = *platform_data;
2149 + }
2150 +@@ -1128,7 +1128,6 @@ err_regulator:
2151 +
2152 + err:
2153 + i2c_hid_free_buffers(ihid);
2154 +- kfree(ihid);
2155 + return ret;
2156 + }
2157 +
2158 +@@ -1152,8 +1151,6 @@ static int i2c_hid_remove(struct i2c_client *client)
2159 +
2160 + regulator_disable(ihid->pdata.supply);
2161 +
2162 +- kfree(ihid);
2163 +-
2164 + return 0;
2165 + }
2166 +
2167 +diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
2168 +index 9ef84998c7f3..37db2eb66ed7 100644
2169 +--- a/drivers/hwmon/adt7475.c
2170 ++++ b/drivers/hwmon/adt7475.c
2171 +@@ -303,14 +303,18 @@ static inline u16 volt2reg(int channel, long volt, u8 bypass_attn)
2172 + return clamp_val(reg, 0, 1023) & (0xff << 2);
2173 + }
2174 +
2175 +-static u16 adt7475_read_word(struct i2c_client *client, int reg)
2176 ++static int adt7475_read_word(struct i2c_client *client, int reg)
2177 + {
2178 +- u16 val;
2179 ++ int val1, val2;
2180 +
2181 +- val = i2c_smbus_read_byte_data(client, reg);
2182 +- val |= (i2c_smbus_read_byte_data(client, reg + 1) << 8);
2183 ++ val1 = i2c_smbus_read_byte_data(client, reg);
2184 ++ if (val1 < 0)
2185 ++ return val1;
2186 ++ val2 = i2c_smbus_read_byte_data(client, reg + 1);
2187 ++ if (val2 < 0)
2188 ++ return val2;
2189 +
2190 +- return val;
2191 ++ return val1 | (val2 << 8);
2192 + }
2193 +
2194 + static void adt7475_write_word(struct i2c_client *client, int reg, u16 val)
2195 +diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
2196 +index e9e6aeabbf84..71d3445ba869 100644
2197 +--- a/drivers/hwmon/ina2xx.c
2198 ++++ b/drivers/hwmon/ina2xx.c
2199 +@@ -17,7 +17,7 @@
2200 + * Bi-directional Current/Power Monitor with I2C Interface
2201 + * Datasheet: http://www.ti.com/product/ina230
2202 + *
2203 +- * Copyright (C) 2012 Lothar Felten <l-felten@××.com>
2204 ++ * Copyright (C) 2012 Lothar Felten <lothar.felten@×××××.com>
2205 + * Thanks to Jan Volkering
2206 + *
2207 + * This program is free software; you can redistribute it and/or modify
2208 +@@ -329,6 +329,15 @@ static int ina2xx_set_shunt(struct ina2xx_data *data, long val)
2209 + return 0;
2210 + }
2211 +
2212 ++static ssize_t ina2xx_show_shunt(struct device *dev,
2213 ++ struct device_attribute *da,
2214 ++ char *buf)
2215 ++{
2216 ++ struct ina2xx_data *data = dev_get_drvdata(dev);
2217 ++
2218 ++ return snprintf(buf, PAGE_SIZE, "%li\n", data->rshunt);
2219 ++}
2220 ++
2221 + static ssize_t ina2xx_store_shunt(struct device *dev,
2222 + struct device_attribute *da,
2223 + const char *buf, size_t count)
2224 +@@ -403,7 +412,7 @@ static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, ina2xx_show_value, NULL,
2225 +
2226 + /* shunt resistance */
2227 + static SENSOR_DEVICE_ATTR(shunt_resistor, S_IRUGO | S_IWUSR,
2228 +- ina2xx_show_value, ina2xx_store_shunt,
2229 ++ ina2xx_show_shunt, ina2xx_store_shunt,
2230 + INA2XX_CALIBRATION);
2231 +
2232 + /* update interval (ina226 only) */
2233 +diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
2234 +index da962aa2cef5..fc6b7f8b62fb 100644
2235 +--- a/drivers/hwtracing/intel_th/core.c
2236 ++++ b/drivers/hwtracing/intel_th/core.c
2237 +@@ -139,7 +139,8 @@ static int intel_th_remove(struct device *dev)
2238 + th->thdev[i] = NULL;
2239 + }
2240 +
2241 +- th->num_thdevs = lowest;
2242 ++ if (lowest >= 0)
2243 ++ th->num_thdevs = lowest;
2244 + }
2245 +
2246 + if (thdrv->attr_group)
2247 +@@ -487,7 +488,7 @@ static const struct intel_th_subdevice {
2248 + .flags = IORESOURCE_MEM,
2249 + },
2250 + {
2251 +- .start = TH_MMIO_SW,
2252 ++ .start = 1, /* use resource[1] */
2253 + .end = 0,
2254 + .flags = IORESOURCE_MEM,
2255 + },
2256 +@@ -580,6 +581,7 @@ intel_th_subdevice_alloc(struct intel_th *th,
2257 + struct intel_th_device *thdev;
2258 + struct resource res[3];
2259 + unsigned int req = 0;
2260 ++ bool is64bit = false;
2261 + int r, err;
2262 +
2263 + thdev = intel_th_device_alloc(th, subdev->type, subdev->name,
2264 +@@ -589,12 +591,18 @@ intel_th_subdevice_alloc(struct intel_th *th,
2265 +
2266 + thdev->drvdata = th->drvdata;
2267 +
2268 ++ for (r = 0; r < th->num_resources; r++)
2269 ++ if (th->resource[r].flags & IORESOURCE_MEM_64) {
2270 ++ is64bit = true;
2271 ++ break;
2272 ++ }
2273 ++
2274 + memcpy(res, subdev->res,
2275 + sizeof(struct resource) * subdev->nres);
2276 +
2277 + for (r = 0; r < subdev->nres; r++) {
2278 + struct resource *devres = th->resource;
2279 +- int bar = TH_MMIO_CONFIG;
2280 ++ int bar = 0; /* cut subdevices' MMIO from resource[0] */
2281 +
2282 + /*
2283 + * Take .end == 0 to mean 'take the whole bar',
2284 +@@ -603,6 +611,8 @@ intel_th_subdevice_alloc(struct intel_th *th,
2285 + */
2286 + if (!res[r].end && res[r].flags == IORESOURCE_MEM) {
2287 + bar = res[r].start;
2288 ++ if (is64bit)
2289 ++ bar *= 2;
2290 + res[r].start = 0;
2291 + res[r].end = resource_size(&devres[bar]) - 1;
2292 + }
2293 +diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
2294 +index 45fcf0c37a9e..2806cdeda053 100644
2295 +--- a/drivers/i2c/busses/i2c-i801.c
2296 ++++ b/drivers/i2c/busses/i2c-i801.c
2297 +@@ -1417,6 +1417,13 @@ static void i801_add_tco(struct i801_priv *priv)
2298 + }
2299 +
2300 + #ifdef CONFIG_ACPI
2301 ++static bool i801_acpi_is_smbus_ioport(const struct i801_priv *priv,
2302 ++ acpi_physical_address address)
2303 ++{
2304 ++ return address >= priv->smba &&
2305 ++ address <= pci_resource_end(priv->pci_dev, SMBBAR);
2306 ++}
2307 ++
2308 + static acpi_status
2309 + i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits,
2310 + u64 *value, void *handler_context, void *region_context)
2311 +@@ -1432,7 +1439,7 @@ i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits,
2312 + */
2313 + mutex_lock(&priv->acpi_lock);
2314 +
2315 +- if (!priv->acpi_reserved) {
2316 ++ if (!priv->acpi_reserved && i801_acpi_is_smbus_ioport(priv, address)) {
2317 + priv->acpi_reserved = true;
2318 +
2319 + dev_warn(&pdev->dev, "BIOS is accessing SMBus registers\n");
2320 +diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
2321 +index 7251d0e63d74..98080e05ac6d 100644
2322 +--- a/drivers/iio/accel/adxl345_core.c
2323 ++++ b/drivers/iio/accel/adxl345_core.c
2324 +@@ -21,6 +21,8 @@
2325 + #define ADXL345_REG_DATAX0 0x32
2326 + #define ADXL345_REG_DATAY0 0x34
2327 + #define ADXL345_REG_DATAZ0 0x36
2328 ++#define ADXL345_REG_DATA_AXIS(index) \
2329 ++ (ADXL345_REG_DATAX0 + (index) * sizeof(__le16))
2330 +
2331 + #define ADXL345_POWER_CTL_MEASURE BIT(3)
2332 + #define ADXL345_POWER_CTL_STANDBY 0x00
2333 +@@ -47,19 +49,19 @@ struct adxl345_data {
2334 + u8 data_range;
2335 + };
2336 +
2337 +-#define ADXL345_CHANNEL(reg, axis) { \
2338 ++#define ADXL345_CHANNEL(index, axis) { \
2339 + .type = IIO_ACCEL, \
2340 + .modified = 1, \
2341 + .channel2 = IIO_MOD_##axis, \
2342 +- .address = reg, \
2343 ++ .address = index, \
2344 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
2345 + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
2346 + }
2347 +
2348 + static const struct iio_chan_spec adxl345_channels[] = {
2349 +- ADXL345_CHANNEL(ADXL345_REG_DATAX0, X),
2350 +- ADXL345_CHANNEL(ADXL345_REG_DATAY0, Y),
2351 +- ADXL345_CHANNEL(ADXL345_REG_DATAZ0, Z),
2352 ++ ADXL345_CHANNEL(0, X),
2353 ++ ADXL345_CHANNEL(1, Y),
2354 ++ ADXL345_CHANNEL(2, Z),
2355 + };
2356 +
2357 + static int adxl345_read_raw(struct iio_dev *indio_dev,
2358 +@@ -67,7 +69,7 @@ static int adxl345_read_raw(struct iio_dev *indio_dev,
2359 + int *val, int *val2, long mask)
2360 + {
2361 + struct adxl345_data *data = iio_priv(indio_dev);
2362 +- __le16 regval;
2363 ++ __le16 accel;
2364 + int ret;
2365 +
2366 + switch (mask) {
2367 +@@ -77,12 +79,13 @@ static int adxl345_read_raw(struct iio_dev *indio_dev,
2368 + * ADXL345_REG_DATA(X0/Y0/Z0) contain the least significant byte
2369 + * and ADXL345_REG_DATA(X0/Y0/Z0) + 1 the most significant byte
2370 + */
2371 +- ret = regmap_bulk_read(data->regmap, chan->address, &regval,
2372 +- sizeof(regval));
2373 ++ ret = regmap_bulk_read(data->regmap,
2374 ++ ADXL345_REG_DATA_AXIS(chan->address),
2375 ++ &accel, sizeof(accel));
2376 + if (ret < 0)
2377 + return ret;
2378 +
2379 +- *val = sign_extend32(le16_to_cpu(regval), 12);
2380 ++ *val = sign_extend32(le16_to_cpu(accel), 12);
2381 + return IIO_VAL_INT;
2382 + case IIO_CHAN_INFO_SCALE:
2383 + *val = 0;
2384 +diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
2385 +index 0635a79864bf..d1239624187d 100644
2386 +--- a/drivers/iio/adc/ina2xx-adc.c
2387 ++++ b/drivers/iio/adc/ina2xx-adc.c
2388 +@@ -30,6 +30,7 @@
2389 + #include <linux/module.h>
2390 + #include <linux/of_device.h>
2391 + #include <linux/regmap.h>
2392 ++#include <linux/sched/task.h>
2393 + #include <linux/util_macros.h>
2394 +
2395 + #include <linux/platform_data/ina2xx.h>
2396 +@@ -826,6 +827,7 @@ static int ina2xx_buffer_enable(struct iio_dev *indio_dev)
2397 + {
2398 + struct ina2xx_chip_info *chip = iio_priv(indio_dev);
2399 + unsigned int sampling_us = SAMPLING_PERIOD(chip);
2400 ++ struct task_struct *task;
2401 +
2402 + dev_dbg(&indio_dev->dev, "Enabling buffer w/ scan_mask %02x, freq = %d, avg =%u\n",
2403 + (unsigned int)(*indio_dev->active_scan_mask),
2404 +@@ -835,11 +837,17 @@ static int ina2xx_buffer_enable(struct iio_dev *indio_dev)
2405 + dev_dbg(&indio_dev->dev, "Async readout mode: %d\n",
2406 + chip->allow_async_readout);
2407 +
2408 +- chip->task = kthread_run(ina2xx_capture_thread, (void *)indio_dev,
2409 +- "%s:%d-%uus", indio_dev->name, indio_dev->id,
2410 +- sampling_us);
2411 ++ task = kthread_create(ina2xx_capture_thread, (void *)indio_dev,
2412 ++ "%s:%d-%uus", indio_dev->name, indio_dev->id,
2413 ++ sampling_us);
2414 ++ if (IS_ERR(task))
2415 ++ return PTR_ERR(task);
2416 ++
2417 ++ get_task_struct(task);
2418 ++ wake_up_process(task);
2419 ++ chip->task = task;
2420 +
2421 +- return PTR_ERR_OR_ZERO(chip->task);
2422 ++ return 0;
2423 + }
2424 +
2425 + static int ina2xx_buffer_disable(struct iio_dev *indio_dev)
2426 +@@ -848,6 +856,7 @@ static int ina2xx_buffer_disable(struct iio_dev *indio_dev)
2427 +
2428 + if (chip->task) {
2429 + kthread_stop(chip->task);
2430 ++ put_task_struct(chip->task);
2431 + chip->task = NULL;
2432 + }
2433 +
2434 +diff --git a/drivers/iio/counter/104-quad-8.c b/drivers/iio/counter/104-quad-8.c
2435 +index b56985078d8c..4be85ec54af4 100644
2436 +--- a/drivers/iio/counter/104-quad-8.c
2437 ++++ b/drivers/iio/counter/104-quad-8.c
2438 +@@ -138,7 +138,7 @@ static int quad8_write_raw(struct iio_dev *indio_dev,
2439 + outb(val >> (8 * i), base_offset);
2440 +
2441 + /* Reset Borrow, Carry, Compare, and Sign flags */
2442 +- outb(0x02, base_offset + 1);
2443 ++ outb(0x04, base_offset + 1);
2444 + /* Reset Error flag */
2445 + outb(0x06, base_offset + 1);
2446 +
2447 +diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c
2448 +index c8963e91f92a..3ee0adfb45e9 100644
2449 +--- a/drivers/infiniband/core/rw.c
2450 ++++ b/drivers/infiniband/core/rw.c
2451 +@@ -87,7 +87,7 @@ static int rdma_rw_init_one_mr(struct ib_qp *qp, u8 port_num,
2452 + }
2453 +
2454 + ret = ib_map_mr_sg(reg->mr, sg, nents, &offset, PAGE_SIZE);
2455 +- if (ret < nents) {
2456 ++ if (ret < 0 || ret < nents) {
2457 + ib_mr_pool_put(qp, &qp->rdma_mrs, reg->mr);
2458 + return -EINVAL;
2459 + }
2460 +diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
2461 +index 583d3a10b940..0e5eb0f547d3 100644
2462 +--- a/drivers/infiniband/core/uverbs_cmd.c
2463 ++++ b/drivers/infiniband/core/uverbs_cmd.c
2464 +@@ -2812,6 +2812,9 @@ static struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
2465 + if (!resources)
2466 + goto err_res;
2467 +
2468 ++ if (!num_specs)
2469 ++ goto out;
2470 ++
2471 + resources->counters =
2472 + kcalloc(num_specs, sizeof(*resources->counters), GFP_KERNEL);
2473 +
2474 +@@ -2824,8 +2827,8 @@ static struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
2475 + if (!resources->collection)
2476 + goto err_collection;
2477 +
2478 ++out:
2479 + resources->max = num_specs;
2480 +-
2481 + return resources;
2482 +
2483 + err_collection:
2484 +diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
2485 +index 2094d136513d..92d8469e28f3 100644
2486 +--- a/drivers/infiniband/core/uverbs_main.c
2487 ++++ b/drivers/infiniband/core/uverbs_main.c
2488 +@@ -429,6 +429,7 @@ static int ib_uverbs_comp_event_close(struct inode *inode, struct file *filp)
2489 + list_del(&entry->obj_list);
2490 + kfree(entry);
2491 + }
2492 ++ file->ev_queue.is_closed = 1;
2493 + spin_unlock_irq(&file->ev_queue.lock);
2494 +
2495 + uverbs_close_fd(filp);
2496 +diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
2497 +index 50d8f1fc98d5..e426b990c1dd 100644
2498 +--- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c
2499 ++++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
2500 +@@ -2354,7 +2354,7 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq,
2501 + srq = qp->srq;
2502 + if (!srq)
2503 + return -EINVAL;
2504 +- if (wr_id_idx > srq->hwq.max_elements) {
2505 ++ if (wr_id_idx >= srq->hwq.max_elements) {
2506 + dev_err(&cq->hwq.pdev->dev,
2507 + "QPLIB: FP: CQ Process RC ");
2508 + dev_err(&cq->hwq.pdev->dev,
2509 +@@ -2369,7 +2369,7 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq,
2510 + *pcqe = cqe;
2511 + } else {
2512 + rq = &qp->rq;
2513 +- if (wr_id_idx > rq->hwq.max_elements) {
2514 ++ if (wr_id_idx >= rq->hwq.max_elements) {
2515 + dev_err(&cq->hwq.pdev->dev,
2516 + "QPLIB: FP: CQ Process RC ");
2517 + dev_err(&cq->hwq.pdev->dev,
2518 +@@ -2437,7 +2437,7 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq,
2519 + if (!srq)
2520 + return -EINVAL;
2521 +
2522 +- if (wr_id_idx > srq->hwq.max_elements) {
2523 ++ if (wr_id_idx >= srq->hwq.max_elements) {
2524 + dev_err(&cq->hwq.pdev->dev,
2525 + "QPLIB: FP: CQ Process UD ");
2526 + dev_err(&cq->hwq.pdev->dev,
2527 +@@ -2452,7 +2452,7 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq,
2528 + *pcqe = cqe;
2529 + } else {
2530 + rq = &qp->rq;
2531 +- if (wr_id_idx > rq->hwq.max_elements) {
2532 ++ if (wr_id_idx >= rq->hwq.max_elements) {
2533 + dev_err(&cq->hwq.pdev->dev,
2534 + "QPLIB: FP: CQ Process UD ");
2535 + dev_err(&cq->hwq.pdev->dev,
2536 +@@ -2546,7 +2546,7 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq,
2537 + "QPLIB: FP: SRQ used but not defined??");
2538 + return -EINVAL;
2539 + }
2540 +- if (wr_id_idx > srq->hwq.max_elements) {
2541 ++ if (wr_id_idx >= srq->hwq.max_elements) {
2542 + dev_err(&cq->hwq.pdev->dev,
2543 + "QPLIB: FP: CQ Process Raw/QP1 ");
2544 + dev_err(&cq->hwq.pdev->dev,
2545 +@@ -2561,7 +2561,7 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq,
2546 + *pcqe = cqe;
2547 + } else {
2548 + rq = &qp->rq;
2549 +- if (wr_id_idx > rq->hwq.max_elements) {
2550 ++ if (wr_id_idx >= rq->hwq.max_elements) {
2551 + dev_err(&cq->hwq.pdev->dev,
2552 + "QPLIB: FP: CQ Process Raw/QP1 RQ wr_id ");
2553 + dev_err(&cq->hwq.pdev->dev,
2554 +diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.c b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
2555 +index 2f3f32eaa1d5..4097f3fa25c5 100644
2556 +--- a/drivers/infiniband/hw/bnxt_re/qplib_sp.c
2557 ++++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
2558 +@@ -197,7 +197,7 @@ int bnxt_qplib_get_sgid(struct bnxt_qplib_res *res,
2559 + struct bnxt_qplib_sgid_tbl *sgid_tbl, int index,
2560 + struct bnxt_qplib_gid *gid)
2561 + {
2562 +- if (index > sgid_tbl->max) {
2563 ++ if (index >= sgid_tbl->max) {
2564 + dev_err(&res->pdev->dev,
2565 + "QPLIB: Index %d exceeded SGID table max (%d)",
2566 + index, sgid_tbl->max);
2567 +@@ -402,7 +402,7 @@ int bnxt_qplib_get_pkey(struct bnxt_qplib_res *res,
2568 + *pkey = 0xFFFF;
2569 + return 0;
2570 + }
2571 +- if (index > pkey_tbl->max) {
2572 ++ if (index >= pkey_tbl->max) {
2573 + dev_err(&res->pdev->dev,
2574 + "QPLIB: Index %d exceeded PKEY table max (%d)",
2575 + index, pkey_tbl->max);
2576 +diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c
2577 +index 6deb101cdd43..b49351914feb 100644
2578 +--- a/drivers/infiniband/hw/hfi1/chip.c
2579 ++++ b/drivers/infiniband/hw/hfi1/chip.c
2580 +@@ -6733,6 +6733,7 @@ void start_freeze_handling(struct hfi1_pportdata *ppd, int flags)
2581 + struct hfi1_devdata *dd = ppd->dd;
2582 + struct send_context *sc;
2583 + int i;
2584 ++ int sc_flags;
2585 +
2586 + if (flags & FREEZE_SELF)
2587 + write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_FREEZE_SMASK);
2588 +@@ -6743,11 +6744,13 @@ void start_freeze_handling(struct hfi1_pportdata *ppd, int flags)
2589 + /* notify all SDMA engines that they are going into a freeze */
2590 + sdma_freeze_notify(dd, !!(flags & FREEZE_LINK_DOWN));
2591 +
2592 ++ sc_flags = SCF_FROZEN | SCF_HALTED | (flags & FREEZE_LINK_DOWN ?
2593 ++ SCF_LINK_DOWN : 0);
2594 + /* do halt pre-handling on all enabled send contexts */
2595 + for (i = 0; i < dd->num_send_contexts; i++) {
2596 + sc = dd->send_contexts[i].sc;
2597 + if (sc && (sc->flags & SCF_ENABLED))
2598 +- sc_stop(sc, SCF_FROZEN | SCF_HALTED);
2599 ++ sc_stop(sc, sc_flags);
2600 + }
2601 +
2602 + /* Send context are frozen. Notify user space */
2603 +@@ -10665,6 +10668,7 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state)
2604 + add_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
2605 +
2606 + handle_linkup_change(dd, 1);
2607 ++ pio_kernel_linkup(dd);
2608 +
2609 + /*
2610 + * After link up, a new link width will have been set.
2611 +diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c
2612 +index 9cac15d10c4f..81f7cd7abcc5 100644
2613 +--- a/drivers/infiniband/hw/hfi1/pio.c
2614 ++++ b/drivers/infiniband/hw/hfi1/pio.c
2615 +@@ -86,6 +86,7 @@ void pio_send_control(struct hfi1_devdata *dd, int op)
2616 + unsigned long flags;
2617 + int write = 1; /* write sendctrl back */
2618 + int flush = 0; /* re-read sendctrl to make sure it is flushed */
2619 ++ int i;
2620 +
2621 + spin_lock_irqsave(&dd->sendctrl_lock, flags);
2622 +
2623 +@@ -95,9 +96,13 @@ void pio_send_control(struct hfi1_devdata *dd, int op)
2624 + reg |= SEND_CTRL_SEND_ENABLE_SMASK;
2625 + /* Fall through */
2626 + case PSC_DATA_VL_ENABLE:
2627 ++ mask = 0;
2628 ++ for (i = 0; i < ARRAY_SIZE(dd->vld); i++)
2629 ++ if (!dd->vld[i].mtu)
2630 ++ mask |= BIT_ULL(i);
2631 + /* Disallow sending on VLs not enabled */
2632 +- mask = (((~0ull) << num_vls) & SEND_CTRL_UNSUPPORTED_VL_MASK) <<
2633 +- SEND_CTRL_UNSUPPORTED_VL_SHIFT;
2634 ++ mask = (mask & SEND_CTRL_UNSUPPORTED_VL_MASK) <<
2635 ++ SEND_CTRL_UNSUPPORTED_VL_SHIFT;
2636 + reg = (reg & ~SEND_CTRL_UNSUPPORTED_VL_SMASK) | mask;
2637 + break;
2638 + case PSC_GLOBAL_DISABLE:
2639 +@@ -921,20 +926,18 @@ void sc_free(struct send_context *sc)
2640 + void sc_disable(struct send_context *sc)
2641 + {
2642 + u64 reg;
2643 +- unsigned long flags;
2644 + struct pio_buf *pbuf;
2645 +
2646 + if (!sc)
2647 + return;
2648 +
2649 + /* do all steps, even if already disabled */
2650 +- spin_lock_irqsave(&sc->alloc_lock, flags);
2651 ++ spin_lock_irq(&sc->alloc_lock);
2652 + reg = read_kctxt_csr(sc->dd, sc->hw_context, SC(CTRL));
2653 + reg &= ~SC(CTRL_CTXT_ENABLE_SMASK);
2654 + sc->flags &= ~SCF_ENABLED;
2655 + sc_wait_for_packet_egress(sc, 1);
2656 + write_kctxt_csr(sc->dd, sc->hw_context, SC(CTRL), reg);
2657 +- spin_unlock_irqrestore(&sc->alloc_lock, flags);
2658 +
2659 + /*
2660 + * Flush any waiters. Once the context is disabled,
2661 +@@ -944,7 +947,7 @@ void sc_disable(struct send_context *sc)
2662 + * proceed with the flush.
2663 + */
2664 + udelay(1);
2665 +- spin_lock_irqsave(&sc->release_lock, flags);
2666 ++ spin_lock(&sc->release_lock);
2667 + if (sc->sr) { /* this context has a shadow ring */
2668 + while (sc->sr_tail != sc->sr_head) {
2669 + pbuf = &sc->sr[sc->sr_tail].pbuf;
2670 +@@ -955,7 +958,8 @@ void sc_disable(struct send_context *sc)
2671 + sc->sr_tail = 0;
2672 + }
2673 + }
2674 +- spin_unlock_irqrestore(&sc->release_lock, flags);
2675 ++ spin_unlock(&sc->release_lock);
2676 ++ spin_unlock_irq(&sc->alloc_lock);
2677 + }
2678 +
2679 + /* return SendEgressCtxtStatus.PacketOccupancy */
2680 +@@ -1178,11 +1182,39 @@ void pio_kernel_unfreeze(struct hfi1_devdata *dd)
2681 + sc = dd->send_contexts[i].sc;
2682 + if (!sc || !(sc->flags & SCF_FROZEN) || sc->type == SC_USER)
2683 + continue;
2684 ++ if (sc->flags & SCF_LINK_DOWN)
2685 ++ continue;
2686 +
2687 + sc_enable(sc); /* will clear the sc frozen flag */
2688 + }
2689 + }
2690 +
2691 ++/**
2692 ++ * pio_kernel_linkup() - Re-enable send contexts after linkup event
2693 ++ * @dd: valid devive data
2694 ++ *
2695 ++ * When the link goes down, the freeze path is taken. However, a link down
2696 ++ * event is different from a freeze because if the send context is re-enabled
2697 ++ * whowever is sending data will start sending data again, which will hang
2698 ++ * any QP that is sending data.
2699 ++ *
2700 ++ * The freeze path now looks at the type of event that occurs and takes this
2701 ++ * path for link down event.
2702 ++ */
2703 ++void pio_kernel_linkup(struct hfi1_devdata *dd)
2704 ++{
2705 ++ struct send_context *sc;
2706 ++ int i;
2707 ++
2708 ++ for (i = 0; i < dd->num_send_contexts; i++) {
2709 ++ sc = dd->send_contexts[i].sc;
2710 ++ if (!sc || !(sc->flags & SCF_LINK_DOWN) || sc->type == SC_USER)
2711 ++ continue;
2712 ++
2713 ++ sc_enable(sc); /* will clear the sc link down flag */
2714 ++ }
2715 ++}
2716 ++
2717 + /*
2718 + * Wait for the SendPioInitCtxt.PioInitInProgress bit to clear.
2719 + * Returns:
2720 +@@ -1382,11 +1414,10 @@ void sc_stop(struct send_context *sc, int flag)
2721 + {
2722 + unsigned long flags;
2723 +
2724 +- /* mark the context */
2725 +- sc->flags |= flag;
2726 +-
2727 + /* stop buffer allocations */
2728 + spin_lock_irqsave(&sc->alloc_lock, flags);
2729 ++ /* mark the context */
2730 ++ sc->flags |= flag;
2731 + sc->flags &= ~SCF_ENABLED;
2732 + spin_unlock_irqrestore(&sc->alloc_lock, flags);
2733 + wake_up(&sc->halt_wait);
2734 +diff --git a/drivers/infiniband/hw/hfi1/pio.h b/drivers/infiniband/hw/hfi1/pio.h
2735 +index 058b08f459ab..aaf372c3e5d6 100644
2736 +--- a/drivers/infiniband/hw/hfi1/pio.h
2737 ++++ b/drivers/infiniband/hw/hfi1/pio.h
2738 +@@ -139,6 +139,7 @@ struct send_context {
2739 + #define SCF_IN_FREE 0x02
2740 + #define SCF_HALTED 0x04
2741 + #define SCF_FROZEN 0x08
2742 ++#define SCF_LINK_DOWN 0x10
2743 +
2744 + struct send_context_info {
2745 + struct send_context *sc; /* allocated working context */
2746 +@@ -306,6 +307,7 @@ void set_pio_integrity(struct send_context *sc);
2747 + void pio_reset_all(struct hfi1_devdata *dd);
2748 + void pio_freeze(struct hfi1_devdata *dd);
2749 + void pio_kernel_unfreeze(struct hfi1_devdata *dd);
2750 ++void pio_kernel_linkup(struct hfi1_devdata *dd);
2751 +
2752 + /* global PIO send control operations */
2753 + #define PSC_GLOBAL_ENABLE 0
2754 +diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c
2755 +index a3a7b33196d6..5c88706121c1 100644
2756 +--- a/drivers/infiniband/hw/hfi1/user_sdma.c
2757 ++++ b/drivers/infiniband/hw/hfi1/user_sdma.c
2758 +@@ -828,7 +828,7 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
2759 + if (READ_ONCE(iovec->offset) == iovec->iov.iov_len) {
2760 + if (++req->iov_idx == req->data_iovs) {
2761 + ret = -EFAULT;
2762 +- goto free_txreq;
2763 ++ goto free_tx;
2764 + }
2765 + iovec = &req->iovs[req->iov_idx];
2766 + WARN_ON(iovec->offset);
2767 +diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
2768 +index 08991874c0e2..a1040a142aac 100644
2769 +--- a/drivers/infiniband/hw/hfi1/verbs.c
2770 ++++ b/drivers/infiniband/hw/hfi1/verbs.c
2771 +@@ -1590,6 +1590,7 @@ static int hfi1_check_ah(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr)
2772 + struct hfi1_pportdata *ppd;
2773 + struct hfi1_devdata *dd;
2774 + u8 sc5;
2775 ++ u8 sl;
2776 +
2777 + if (hfi1_check_mcast(rdma_ah_get_dlid(ah_attr)) &&
2778 + !(rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH))
2779 +@@ -1598,8 +1599,13 @@ static int hfi1_check_ah(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr)
2780 + /* test the mapping for validity */
2781 + ibp = to_iport(ibdev, rdma_ah_get_port_num(ah_attr));
2782 + ppd = ppd_from_ibp(ibp);
2783 +- sc5 = ibp->sl_to_sc[rdma_ah_get_sl(ah_attr)];
2784 + dd = dd_from_ppd(ppd);
2785 ++
2786 ++ sl = rdma_ah_get_sl(ah_attr);
2787 ++ if (sl >= ARRAY_SIZE(ibp->sl_to_sc))
2788 ++ return -EINVAL;
2789 ++
2790 ++ sc5 = ibp->sl_to_sc[sl];
2791 + if (sc_to_vlt(dd, sc5) > num_vls && sc_to_vlt(dd, sc5) != 0xf)
2792 + return -EINVAL;
2793 + return 0;
2794 +diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
2795 +index 68679ad4c6da..937899fea01d 100644
2796 +--- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c
2797 ++++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
2798 +@@ -1409,6 +1409,7 @@ static void i40iw_set_hugetlb_values(u64 addr, struct i40iw_mr *iwmr)
2799 + struct vm_area_struct *vma;
2800 + struct hstate *h;
2801 +
2802 ++ down_read(&current->mm->mmap_sem);
2803 + vma = find_vma(current->mm, addr);
2804 + if (vma && is_vm_hugetlb_page(vma)) {
2805 + h = hstate_vma(vma);
2806 +@@ -1417,6 +1418,7 @@ static void i40iw_set_hugetlb_values(u64 addr, struct i40iw_mr *iwmr)
2807 + iwmr->page_msk = huge_page_mask(h);
2808 + }
2809 + }
2810 ++ up_read(&current->mm->mmap_sem);
2811 + }
2812 +
2813 + /**
2814 +diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
2815 +index 3b8045fd23ed..b94e33a56e97 100644
2816 +--- a/drivers/infiniband/hw/mlx4/qp.c
2817 ++++ b/drivers/infiniband/hw/mlx4/qp.c
2818 +@@ -4047,9 +4047,9 @@ static void to_rdma_ah_attr(struct mlx4_ib_dev *ibdev,
2819 + u8 port_num = path->sched_queue & 0x40 ? 2 : 1;
2820 +
2821 + memset(ah_attr, 0, sizeof(*ah_attr));
2822 +- ah_attr->type = rdma_ah_find_type(&ibdev->ib_dev, port_num);
2823 + if (port_num == 0 || port_num > dev->caps.num_ports)
2824 + return;
2825 ++ ah_attr->type = rdma_ah_find_type(&ibdev->ib_dev, port_num);
2826 +
2827 + if (ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE)
2828 + rdma_ah_set_sl(ah_attr, ((path->sched_queue >> 3) & 0x7) |
2829 +diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
2830 +index cbeae4509359..85677afa6f77 100644
2831 +--- a/drivers/infiniband/hw/mlx5/main.c
2832 ++++ b/drivers/infiniband/hw/mlx5/main.c
2833 +@@ -2699,7 +2699,7 @@ static int parse_flow_attr(struct mlx5_core_dev *mdev, u32 *match_c,
2834 + IPPROTO_GRE);
2835 +
2836 + MLX5_SET(fte_match_set_misc, misc_params_c, gre_protocol,
2837 +- 0xffff);
2838 ++ ntohs(ib_spec->gre.mask.protocol));
2839 + MLX5_SET(fte_match_set_misc, misc_params_v, gre_protocol,
2840 + ntohs(ib_spec->gre.val.protocol));
2841 +
2842 +diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
2843 +index 9786b24b956f..2b8cc76bb77e 100644
2844 +--- a/drivers/infiniband/ulp/srp/ib_srp.c
2845 ++++ b/drivers/infiniband/ulp/srp/ib_srp.c
2846 +@@ -2954,7 +2954,7 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
2847 + {
2848 + struct srp_target_port *target = host_to_target(scmnd->device->host);
2849 + struct srp_rdma_ch *ch;
2850 +- int i;
2851 ++ int i, j;
2852 + u8 status;
2853 +
2854 + shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n");
2855 +@@ -2968,8 +2968,8 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
2856 +
2857 + for (i = 0; i < target->ch_count; i++) {
2858 + ch = &target->ch[i];
2859 +- for (i = 0; i < target->req_ring_size; ++i) {
2860 +- struct srp_request *req = &ch->req_ring[i];
2861 ++ for (j = 0; j < target->req_ring_size; ++j) {
2862 ++ struct srp_request *req = &ch->req_ring[j];
2863 +
2864 + srp_finish_req(ch, req, scmnd->device, DID_RESET << 16);
2865 + }
2866 +diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
2867 +index d91f3b1c5375..92d739649022 100644
2868 +--- a/drivers/input/misc/xen-kbdfront.c
2869 ++++ b/drivers/input/misc/xen-kbdfront.c
2870 +@@ -229,7 +229,7 @@ static int xenkbd_probe(struct xenbus_device *dev,
2871 + }
2872 + }
2873 +
2874 +- touch = xenbus_read_unsigned(dev->nodename,
2875 ++ touch = xenbus_read_unsigned(dev->otherend,
2876 + XENKBD_FIELD_FEAT_MTOUCH, 0);
2877 + if (touch) {
2878 + ret = xenbus_write(XBT_NIL, dev->nodename,
2879 +@@ -304,13 +304,13 @@ static int xenkbd_probe(struct xenbus_device *dev,
2880 + if (!mtouch)
2881 + goto error_nomem;
2882 +
2883 +- num_cont = xenbus_read_unsigned(info->xbdev->nodename,
2884 ++ num_cont = xenbus_read_unsigned(info->xbdev->otherend,
2885 + XENKBD_FIELD_MT_NUM_CONTACTS,
2886 + 1);
2887 +- width = xenbus_read_unsigned(info->xbdev->nodename,
2888 ++ width = xenbus_read_unsigned(info->xbdev->otherend,
2889 + XENKBD_FIELD_MT_WIDTH,
2890 + XENFB_WIDTH);
2891 +- height = xenbus_read_unsigned(info->xbdev->nodename,
2892 ++ height = xenbus_read_unsigned(info->xbdev->otherend,
2893 + XENKBD_FIELD_MT_HEIGHT,
2894 + XENFB_HEIGHT);
2895 +
2896 +diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
2897 +index dd85b16dc6f8..88564f729e93 100644
2898 +--- a/drivers/input/mouse/elantech.c
2899 ++++ b/drivers/input/mouse/elantech.c
2900 +@@ -1178,6 +1178,8 @@ static const struct dmi_system_id elantech_dmi_has_middle_button[] = {
2901 + static const char * const middle_button_pnp_ids[] = {
2902 + "LEN2131", /* ThinkPad P52 w/ NFC */
2903 + "LEN2132", /* ThinkPad P52 */
2904 ++ "LEN2133", /* ThinkPad P72 w/ NFC */
2905 ++ "LEN2134", /* ThinkPad P72 */
2906 + NULL
2907 + };
2908 +
2909 +diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
2910 +index 596b95c50051..d77c97fe4a23 100644
2911 +--- a/drivers/iommu/amd_iommu.c
2912 ++++ b/drivers/iommu/amd_iommu.c
2913 +@@ -2405,9 +2405,9 @@ static void __unmap_single(struct dma_ops_domain *dma_dom,
2914 + }
2915 +
2916 + if (amd_iommu_unmap_flush) {
2917 +- dma_ops_free_iova(dma_dom, dma_addr, pages);
2918 + domain_flush_tlb(&dma_dom->domain);
2919 + domain_flush_complete(&dma_dom->domain);
2920 ++ dma_ops_free_iova(dma_dom, dma_addr, pages);
2921 + } else {
2922 + pages = __roundup_pow_of_two(pages);
2923 + queue_iova(&dma_dom->iovad, dma_addr >> PAGE_SHIFT, pages, 0);
2924 +diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
2925 +index 0d3350463a3f..9a95c9b9d0d8 100644
2926 +--- a/drivers/iommu/msm_iommu.c
2927 ++++ b/drivers/iommu/msm_iommu.c
2928 +@@ -395,20 +395,15 @@ static int msm_iommu_add_device(struct device *dev)
2929 + struct msm_iommu_dev *iommu;
2930 + struct iommu_group *group;
2931 + unsigned long flags;
2932 +- int ret = 0;
2933 +
2934 + spin_lock_irqsave(&msm_iommu_lock, flags);
2935 +-
2936 + iommu = find_iommu_for_dev(dev);
2937 ++ spin_unlock_irqrestore(&msm_iommu_lock, flags);
2938 ++
2939 + if (iommu)
2940 + iommu_device_link(&iommu->iommu, dev);
2941 + else
2942 +- ret = -ENODEV;
2943 +-
2944 +- spin_unlock_irqrestore(&msm_iommu_lock, flags);
2945 +-
2946 +- if (ret)
2947 +- return ret;
2948 ++ return -ENODEV;
2949 +
2950 + group = iommu_group_get_for_dev(dev);
2951 + if (IS_ERR(group))
2952 +@@ -425,13 +420,12 @@ static void msm_iommu_remove_device(struct device *dev)
2953 + unsigned long flags;
2954 +
2955 + spin_lock_irqsave(&msm_iommu_lock, flags);
2956 +-
2957 + iommu = find_iommu_for_dev(dev);
2958 ++ spin_unlock_irqrestore(&msm_iommu_lock, flags);
2959 ++
2960 + if (iommu)
2961 + iommu_device_unlink(&iommu->iommu, dev);
2962 +
2963 +- spin_unlock_irqrestore(&msm_iommu_lock, flags);
2964 +-
2965 + iommu_group_remove_device(dev);
2966 + }
2967 +
2968 +diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
2969 +index 021cbf9ef1bf..1ac945f7a3c2 100644
2970 +--- a/drivers/md/md-cluster.c
2971 ++++ b/drivers/md/md-cluster.c
2972 +@@ -304,15 +304,6 @@ static void recover_bitmaps(struct md_thread *thread)
2973 + while (cinfo->recovery_map) {
2974 + slot = fls64((u64)cinfo->recovery_map) - 1;
2975 +
2976 +- /* Clear suspend_area associated with the bitmap */
2977 +- spin_lock_irq(&cinfo->suspend_lock);
2978 +- list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list)
2979 +- if (slot == s->slot) {
2980 +- list_del(&s->list);
2981 +- kfree(s);
2982 +- }
2983 +- spin_unlock_irq(&cinfo->suspend_lock);
2984 +-
2985 + snprintf(str, 64, "bitmap%04d", slot);
2986 + bm_lockres = lockres_init(mddev, str, NULL, 1);
2987 + if (!bm_lockres) {
2988 +@@ -331,6 +322,16 @@ static void recover_bitmaps(struct md_thread *thread)
2989 + pr_err("md-cluster: Could not copy data from bitmap %d\n", slot);
2990 + goto clear_bit;
2991 + }
2992 ++
2993 ++ /* Clear suspend_area associated with the bitmap */
2994 ++ spin_lock_irq(&cinfo->suspend_lock);
2995 ++ list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list)
2996 ++ if (slot == s->slot) {
2997 ++ list_del(&s->list);
2998 ++ kfree(s);
2999 ++ }
3000 ++ spin_unlock_irq(&cinfo->suspend_lock);
3001 ++
3002 + if (hi > 0) {
3003 + if (lo < mddev->recovery_cp)
3004 + mddev->recovery_cp = lo;
3005 +diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
3006 +index e2550708abc8..3fdbe644648a 100644
3007 +--- a/drivers/media/i2c/ov772x.c
3008 ++++ b/drivers/media/i2c/ov772x.c
3009 +@@ -542,9 +542,19 @@ static struct ov772x_priv *to_ov772x(struct v4l2_subdev *sd)
3010 + return container_of(sd, struct ov772x_priv, subdev);
3011 + }
3012 +
3013 +-static inline int ov772x_read(struct i2c_client *client, u8 addr)
3014 ++static int ov772x_read(struct i2c_client *client, u8 addr)
3015 + {
3016 +- return i2c_smbus_read_byte_data(client, addr);
3017 ++ int ret;
3018 ++ u8 val;
3019 ++
3020 ++ ret = i2c_master_send(client, &addr, 1);
3021 ++ if (ret < 0)
3022 ++ return ret;
3023 ++ ret = i2c_master_recv(client, &val, 1);
3024 ++ if (ret < 0)
3025 ++ return ret;
3026 ++
3027 ++ return val;
3028 + }
3029 +
3030 + static inline int ov772x_write(struct i2c_client *client, u8 addr, u8 value)
3031 +@@ -1136,7 +1146,7 @@ static int ov772x_set_fmt(struct v4l2_subdev *sd,
3032 + static int ov772x_video_probe(struct ov772x_priv *priv)
3033 + {
3034 + struct i2c_client *client = v4l2_get_subdevdata(&priv->subdev);
3035 +- u8 pid, ver;
3036 ++ int pid, ver, midh, midl;
3037 + const char *devname;
3038 + int ret;
3039 +
3040 +@@ -1146,7 +1156,11 @@ static int ov772x_video_probe(struct ov772x_priv *priv)
3041 +
3042 + /* Check and show product ID and manufacturer ID. */
3043 + pid = ov772x_read(client, PID);
3044 ++ if (pid < 0)
3045 ++ return pid;
3046 + ver = ov772x_read(client, VER);
3047 ++ if (ver < 0)
3048 ++ return ver;
3049 +
3050 + switch (VERSION(pid, ver)) {
3051 + case OV7720:
3052 +@@ -1162,13 +1176,17 @@ static int ov772x_video_probe(struct ov772x_priv *priv)
3053 + goto done;
3054 + }
3055 +
3056 ++ midh = ov772x_read(client, MIDH);
3057 ++ if (midh < 0)
3058 ++ return midh;
3059 ++ midl = ov772x_read(client, MIDL);
3060 ++ if (midl < 0)
3061 ++ return midl;
3062 ++
3063 + dev_info(&client->dev,
3064 + "%s Product ID %0x:%0x Manufacturer ID %x:%x\n",
3065 +- devname,
3066 +- pid,
3067 +- ver,
3068 +- ov772x_read(client, MIDH),
3069 +- ov772x_read(client, MIDL));
3070 ++ devname, pid, ver, midh, midl);
3071 ++
3072 + ret = v4l2_ctrl_handler_setup(&priv->hdl);
3073 +
3074 + done:
3075 +@@ -1255,13 +1273,11 @@ static int ov772x_probe(struct i2c_client *client,
3076 + return -EINVAL;
3077 + }
3078 +
3079 +- if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
3080 +- I2C_FUNC_PROTOCOL_MANGLING)) {
3081 ++ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
3082 + dev_err(&adapter->dev,
3083 +- "I2C-Adapter doesn't support SMBUS_BYTE_DATA or PROTOCOL_MANGLING\n");
3084 ++ "I2C-Adapter doesn't support SMBUS_BYTE_DATA\n");
3085 + return -EIO;
3086 + }
3087 +- client->flags |= I2C_CLIENT_SCCB;
3088 +
3089 + priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
3090 + if (!priv)
3091 +diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c
3092 +index 806383500313..14377af7c888 100644
3093 +--- a/drivers/media/i2c/soc_camera/ov772x.c
3094 ++++ b/drivers/media/i2c/soc_camera/ov772x.c
3095 +@@ -834,7 +834,7 @@ static int ov772x_set_params(struct ov772x_priv *priv,
3096 + * set COM8
3097 + */
3098 + if (priv->band_filter) {
3099 +- ret = ov772x_mask_set(client, COM8, BNDF_ON_OFF, 1);
3100 ++ ret = ov772x_mask_set(client, COM8, BNDF_ON_OFF, BNDF_ON_OFF);
3101 + if (!ret)
3102 + ret = ov772x_mask_set(client, BDBASE,
3103 + 0xff, 256 - priv->band_filter);
3104 +diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c
3105 +index 55ba696b8cf4..a920164f53f1 100644
3106 +--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
3107 ++++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
3108 +@@ -384,12 +384,17 @@ static void __isp_video_try_fmt(struct fimc_isp *isp,
3109 + struct v4l2_pix_format_mplane *pixm,
3110 + const struct fimc_fmt **fmt)
3111 + {
3112 +- *fmt = fimc_isp_find_format(&pixm->pixelformat, NULL, 2);
3113 ++ const struct fimc_fmt *__fmt;
3114 ++
3115 ++ __fmt = fimc_isp_find_format(&pixm->pixelformat, NULL, 2);
3116 ++
3117 ++ if (fmt)
3118 ++ *fmt = __fmt;
3119 +
3120 + pixm->colorspace = V4L2_COLORSPACE_SRGB;
3121 + pixm->field = V4L2_FIELD_NONE;
3122 +- pixm->num_planes = (*fmt)->memplanes;
3123 +- pixm->pixelformat = (*fmt)->fourcc;
3124 ++ pixm->num_planes = __fmt->memplanes;
3125 ++ pixm->pixelformat = __fmt->fourcc;
3126 + /*
3127 + * TODO: double check with the docmentation these width/height
3128 + * constraints are correct.
3129 +diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
3130 +index e41510ce69a4..0273302aa741 100644
3131 +--- a/drivers/media/platform/fsl-viu.c
3132 ++++ b/drivers/media/platform/fsl-viu.c
3133 +@@ -1414,7 +1414,7 @@ static int viu_of_probe(struct platform_device *op)
3134 + sizeof(struct viu_reg), DRV_NAME)) {
3135 + dev_err(&op->dev, "Error while requesting mem region\n");
3136 + ret = -EBUSY;
3137 +- goto err;
3138 ++ goto err_irq;
3139 + }
3140 +
3141 + /* remap registers */
3142 +@@ -1422,7 +1422,7 @@ static int viu_of_probe(struct platform_device *op)
3143 + if (!viu_regs) {
3144 + dev_err(&op->dev, "Can't map register set\n");
3145 + ret = -ENOMEM;
3146 +- goto err;
3147 ++ goto err_irq;
3148 + }
3149 +
3150 + /* Prepare our private structure */
3151 +@@ -1430,7 +1430,7 @@ static int viu_of_probe(struct platform_device *op)
3152 + if (!viu_dev) {
3153 + dev_err(&op->dev, "Can't allocate private structure\n");
3154 + ret = -ENOMEM;
3155 +- goto err;
3156 ++ goto err_irq;
3157 + }
3158 +
3159 + viu_dev->vr = viu_regs;
3160 +@@ -1446,16 +1446,21 @@ static int viu_of_probe(struct platform_device *op)
3161 + ret = v4l2_device_register(viu_dev->dev, &viu_dev->v4l2_dev);
3162 + if (ret < 0) {
3163 + dev_err(&op->dev, "v4l2_device_register() failed: %d\n", ret);
3164 +- goto err;
3165 ++ goto err_irq;
3166 + }
3167 +
3168 + ad = i2c_get_adapter(0);
3169 ++ if (!ad) {
3170 ++ ret = -EFAULT;
3171 ++ dev_err(&op->dev, "couldn't get i2c adapter\n");
3172 ++ goto err_v4l2;
3173 ++ }
3174 +
3175 + v4l2_ctrl_handler_init(&viu_dev->hdl, 5);
3176 + if (viu_dev->hdl.error) {
3177 + ret = viu_dev->hdl.error;
3178 + dev_err(&op->dev, "couldn't register control\n");
3179 +- goto err_vdev;
3180 ++ goto err_i2c;
3181 + }
3182 + /* This control handler will inherit the control(s) from the
3183 + sub-device(s). */
3184 +@@ -1471,7 +1476,7 @@ static int viu_of_probe(struct platform_device *op)
3185 + vdev = video_device_alloc();
3186 + if (vdev == NULL) {
3187 + ret = -ENOMEM;
3188 +- goto err_vdev;
3189 ++ goto err_hdl;
3190 + }
3191 +
3192 + *vdev = viu_template;
3193 +@@ -1492,7 +1497,7 @@ static int viu_of_probe(struct platform_device *op)
3194 + ret = video_register_device(viu_dev->vdev, VFL_TYPE_GRABBER, -1);
3195 + if (ret < 0) {
3196 + video_device_release(viu_dev->vdev);
3197 +- goto err_vdev;
3198 ++ goto err_unlock;
3199 + }
3200 +
3201 + /* enable VIU clock */
3202 +@@ -1500,12 +1505,12 @@ static int viu_of_probe(struct platform_device *op)
3203 + if (IS_ERR(clk)) {
3204 + dev_err(&op->dev, "failed to lookup the clock!\n");
3205 + ret = PTR_ERR(clk);
3206 +- goto err_clk;
3207 ++ goto err_vdev;
3208 + }
3209 + ret = clk_prepare_enable(clk);
3210 + if (ret) {
3211 + dev_err(&op->dev, "failed to enable the clock!\n");
3212 +- goto err_clk;
3213 ++ goto err_vdev;
3214 + }
3215 + viu_dev->clk = clk;
3216 +
3217 +@@ -1516,7 +1521,7 @@ static int viu_of_probe(struct platform_device *op)
3218 + if (request_irq(viu_dev->irq, viu_intr, 0, "viu", (void *)viu_dev)) {
3219 + dev_err(&op->dev, "Request VIU IRQ failed.\n");
3220 + ret = -ENODEV;
3221 +- goto err_irq;
3222 ++ goto err_clk;
3223 + }
3224 +
3225 + mutex_unlock(&viu_dev->lock);
3226 +@@ -1524,16 +1529,19 @@ static int viu_of_probe(struct platform_device *op)
3227 + dev_info(&op->dev, "Freescale VIU Video Capture Board\n");
3228 + return ret;
3229 +
3230 +-err_irq:
3231 +- clk_disable_unprepare(viu_dev->clk);
3232 + err_clk:
3233 +- video_unregister_device(viu_dev->vdev);
3234 ++ clk_disable_unprepare(viu_dev->clk);
3235 + err_vdev:
3236 +- v4l2_ctrl_handler_free(&viu_dev->hdl);
3237 ++ video_unregister_device(viu_dev->vdev);
3238 ++err_unlock:
3239 + mutex_unlock(&viu_dev->lock);
3240 ++err_hdl:
3241 ++ v4l2_ctrl_handler_free(&viu_dev->hdl);
3242 ++err_i2c:
3243 + i2c_put_adapter(ad);
3244 ++err_v4l2:
3245 + v4l2_device_unregister(&viu_dev->v4l2_dev);
3246 +-err:
3247 ++err_irq:
3248 + irq_dispose_mapping(viu_irq);
3249 + return ret;
3250 + }
3251 +diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
3252 +index f22cf351e3ee..ae0ef8b241a7 100644
3253 +--- a/drivers/media/platform/omap3isp/isp.c
3254 ++++ b/drivers/media/platform/omap3isp/isp.c
3255 +@@ -300,7 +300,7 @@ static struct clk *isp_xclk_src_get(struct of_phandle_args *clkspec, void *data)
3256 + static int isp_xclk_init(struct isp_device *isp)
3257 + {
3258 + struct device_node *np = isp->dev->of_node;
3259 +- struct clk_init_data init;
3260 ++ struct clk_init_data init = { 0 };
3261 + unsigned int i;
3262 +
3263 + for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i)
3264 +diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
3265 +index 9ab8e7ee2e1e..b1d9f3857d3d 100644
3266 +--- a/drivers/media/platform/s3c-camif/camif-capture.c
3267 ++++ b/drivers/media/platform/s3c-camif/camif-capture.c
3268 +@@ -117,6 +117,8 @@ static int sensor_set_power(struct camif_dev *camif, int on)
3269 +
3270 + if (camif->sensor.power_count == !on)
3271 + err = v4l2_subdev_call(sensor->sd, core, s_power, on);
3272 ++ if (err == -ENOIOCTLCMD)
3273 ++ err = 0;
3274 + if (!err)
3275 + sensor->power_count += on ? 1 : -1;
3276 +
3277 +diff --git a/drivers/media/usb/tm6000/tm6000-dvb.c b/drivers/media/usb/tm6000/tm6000-dvb.c
3278 +index c811fc6cf48a..3a4e545c6037 100644
3279 +--- a/drivers/media/usb/tm6000/tm6000-dvb.c
3280 ++++ b/drivers/media/usb/tm6000/tm6000-dvb.c
3281 +@@ -266,6 +266,11 @@ static int register_dvb(struct tm6000_core *dev)
3282 +
3283 + ret = dvb_register_adapter(&dvb->adapter, "Trident TVMaster 6000 DVB-T",
3284 + THIS_MODULE, &dev->udev->dev, adapter_nr);
3285 ++ if (ret < 0) {
3286 ++ pr_err("tm6000: couldn't register the adapter!\n");
3287 ++ goto err;
3288 ++ }
3289 ++
3290 + dvb->adapter.priv = dev;
3291 +
3292 + if (dvb->frontend) {
3293 +diff --git a/drivers/media/v4l2-core/v4l2-event.c b/drivers/media/v4l2-core/v4l2-event.c
3294 +index 127fe6eb91d9..a3ef1f50a4b3 100644
3295 +--- a/drivers/media/v4l2-core/v4l2-event.c
3296 ++++ b/drivers/media/v4l2-core/v4l2-event.c
3297 +@@ -115,14 +115,6 @@ static void __v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *e
3298 + if (sev == NULL)
3299 + return;
3300 +
3301 +- /*
3302 +- * If the event has been added to the fh->subscribed list, but its
3303 +- * add op has not completed yet elems will be 0, treat this as
3304 +- * not being subscribed.
3305 +- */
3306 +- if (!sev->elems)
3307 +- return;
3308 +-
3309 + /* Increase event sequence number on fh. */
3310 + fh->sequence++;
3311 +
3312 +@@ -208,6 +200,7 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
3313 + struct v4l2_subscribed_event *sev, *found_ev;
3314 + unsigned long flags;
3315 + unsigned i;
3316 ++ int ret = 0;
3317 +
3318 + if (sub->type == V4L2_EVENT_ALL)
3319 + return -EINVAL;
3320 +@@ -225,31 +218,36 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
3321 + sev->flags = sub->flags;
3322 + sev->fh = fh;
3323 + sev->ops = ops;
3324 ++ sev->elems = elems;
3325 ++
3326 ++ mutex_lock(&fh->subscribe_lock);
3327 +
3328 + spin_lock_irqsave(&fh->vdev->fh_lock, flags);
3329 + found_ev = v4l2_event_subscribed(fh, sub->type, sub->id);
3330 +- if (!found_ev)
3331 +- list_add(&sev->list, &fh->subscribed);
3332 + spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
3333 +
3334 + if (found_ev) {
3335 ++ /* Already listening */
3336 + kvfree(sev);
3337 +- return 0; /* Already listening */
3338 ++ goto out_unlock;
3339 + }
3340 +
3341 + if (sev->ops && sev->ops->add) {
3342 +- int ret = sev->ops->add(sev, elems);
3343 ++ ret = sev->ops->add(sev, elems);
3344 + if (ret) {
3345 +- sev->ops = NULL;
3346 +- v4l2_event_unsubscribe(fh, sub);
3347 +- return ret;
3348 ++ kvfree(sev);
3349 ++ goto out_unlock;
3350 + }
3351 + }
3352 +
3353 +- /* Mark as ready for use */
3354 +- sev->elems = elems;
3355 ++ spin_lock_irqsave(&fh->vdev->fh_lock, flags);
3356 ++ list_add(&sev->list, &fh->subscribed);
3357 ++ spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
3358 +
3359 +- return 0;
3360 ++out_unlock:
3361 ++ mutex_unlock(&fh->subscribe_lock);
3362 ++
3363 ++ return ret;
3364 + }
3365 + EXPORT_SYMBOL_GPL(v4l2_event_subscribe);
3366 +
3367 +@@ -288,6 +286,8 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
3368 + return 0;
3369 + }
3370 +
3371 ++ mutex_lock(&fh->subscribe_lock);
3372 ++
3373 + spin_lock_irqsave(&fh->vdev->fh_lock, flags);
3374 +
3375 + sev = v4l2_event_subscribed(fh, sub->type, sub->id);
3376 +@@ -305,6 +305,8 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
3377 + if (sev && sev->ops && sev->ops->del)
3378 + sev->ops->del(sev);
3379 +
3380 ++ mutex_unlock(&fh->subscribe_lock);
3381 ++
3382 + kvfree(sev);
3383 +
3384 + return 0;
3385 +diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
3386 +index 3895999bf880..c91a7bd3ecfc 100644
3387 +--- a/drivers/media/v4l2-core/v4l2-fh.c
3388 ++++ b/drivers/media/v4l2-core/v4l2-fh.c
3389 +@@ -45,6 +45,7 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
3390 + INIT_LIST_HEAD(&fh->available);
3391 + INIT_LIST_HEAD(&fh->subscribed);
3392 + fh->sequence = -1;
3393 ++ mutex_init(&fh->subscribe_lock);
3394 + }
3395 + EXPORT_SYMBOL_GPL(v4l2_fh_init);
3396 +
3397 +@@ -90,6 +91,7 @@ void v4l2_fh_exit(struct v4l2_fh *fh)
3398 + return;
3399 + v4l_disable_media_source(fh->vdev);
3400 + v4l2_event_unsubscribe_all(fh);
3401 ++ mutex_destroy(&fh->subscribe_lock);
3402 + fh->vdev = NULL;
3403 + }
3404 + EXPORT_SYMBOL_GPL(v4l2_fh_exit);
3405 +diff --git a/drivers/misc/ibmvmc.c b/drivers/misc/ibmvmc.c
3406 +index 50d82c3d032a..b8aaa684c397 100644
3407 +--- a/drivers/misc/ibmvmc.c
3408 ++++ b/drivers/misc/ibmvmc.c
3409 +@@ -273,7 +273,7 @@ static void *alloc_dma_buffer(struct vio_dev *vdev, size_t size,
3410 + dma_addr_t *dma_handle)
3411 + {
3412 + /* allocate memory */
3413 +- void *buffer = kzalloc(size, GFP_KERNEL);
3414 ++ void *buffer = kzalloc(size, GFP_ATOMIC);
3415 +
3416 + if (!buffer) {
3417 + *dma_handle = 0;
3418 +diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
3419 +index 679647713e36..74b183baf044 100644
3420 +--- a/drivers/misc/sram.c
3421 ++++ b/drivers/misc/sram.c
3422 +@@ -391,23 +391,23 @@ static int sram_probe(struct platform_device *pdev)
3423 + if (IS_ERR(sram->pool))
3424 + return PTR_ERR(sram->pool);
3425 +
3426 +- ret = sram_reserve_regions(sram, res);
3427 +- if (ret)
3428 +- return ret;
3429 +-
3430 + sram->clk = devm_clk_get(sram->dev, NULL);
3431 + if (IS_ERR(sram->clk))
3432 + sram->clk = NULL;
3433 + else
3434 + clk_prepare_enable(sram->clk);
3435 +
3436 ++ ret = sram_reserve_regions(sram, res);
3437 ++ if (ret)
3438 ++ goto err_disable_clk;
3439 ++
3440 + platform_set_drvdata(pdev, sram);
3441 +
3442 + init_func = of_device_get_match_data(&pdev->dev);
3443 + if (init_func) {
3444 + ret = init_func();
3445 + if (ret)
3446 +- goto err_disable_clk;
3447 ++ goto err_free_partitions;
3448 + }
3449 +
3450 + dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n",
3451 +@@ -415,10 +415,11 @@ static int sram_probe(struct platform_device *pdev)
3452 +
3453 + return 0;
3454 +
3455 ++err_free_partitions:
3456 ++ sram_free_partitions(sram);
3457 + err_disable_clk:
3458 + if (sram->clk)
3459 + clk_disable_unprepare(sram->clk);
3460 +- sram_free_partitions(sram);
3461 +
3462 + return ret;
3463 + }
3464 +diff --git a/drivers/misc/tsl2550.c b/drivers/misc/tsl2550.c
3465 +index adf46072cb37..3fce3b6a3624 100644
3466 +--- a/drivers/misc/tsl2550.c
3467 ++++ b/drivers/misc/tsl2550.c
3468 +@@ -177,7 +177,7 @@ static int tsl2550_calculate_lux(u8 ch0, u8 ch1)
3469 + } else
3470 + lux = 0;
3471 + else
3472 +- return -EAGAIN;
3473 ++ return 0;
3474 +
3475 + /* LUX range check */
3476 + return lux > TSL2550_MAX_LUX ? TSL2550_MAX_LUX : lux;
3477 +diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
3478 +index b4d7774cfe07..d95e8648e7b3 100644
3479 +--- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
3480 ++++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
3481 +@@ -668,7 +668,7 @@ static int qp_host_get_user_memory(u64 produce_uva,
3482 + retval = get_user_pages_fast((uintptr_t) produce_uva,
3483 + produce_q->kernel_if->num_pages, 1,
3484 + produce_q->kernel_if->u.h.header_page);
3485 +- if (retval < produce_q->kernel_if->num_pages) {
3486 ++ if (retval < (int)produce_q->kernel_if->num_pages) {
3487 + pr_debug("get_user_pages_fast(produce) failed (retval=%d)",
3488 + retval);
3489 + qp_release_pages(produce_q->kernel_if->u.h.header_page,
3490 +@@ -680,7 +680,7 @@ static int qp_host_get_user_memory(u64 produce_uva,
3491 + retval = get_user_pages_fast((uintptr_t) consume_uva,
3492 + consume_q->kernel_if->num_pages, 1,
3493 + consume_q->kernel_if->u.h.header_page);
3494 +- if (retval < consume_q->kernel_if->num_pages) {
3495 ++ if (retval < (int)consume_q->kernel_if->num_pages) {
3496 + pr_debug("get_user_pages_fast(consume) failed (retval=%d)",
3497 + retval);
3498 + qp_release_pages(consume_q->kernel_if->u.h.header_page,
3499 +diff --git a/drivers/mmc/host/android-goldfish.c b/drivers/mmc/host/android-goldfish.c
3500 +index 294de177632c..61e4e2a213c9 100644
3501 +--- a/drivers/mmc/host/android-goldfish.c
3502 ++++ b/drivers/mmc/host/android-goldfish.c
3503 +@@ -217,7 +217,7 @@ static void goldfish_mmc_xfer_done(struct goldfish_mmc_host *host,
3504 + * We don't really have DMA, so we need
3505 + * to copy from our platform driver buffer
3506 + */
3507 +- sg_copy_to_buffer(data->sg, 1, host->virt_base,
3508 ++ sg_copy_from_buffer(data->sg, 1, host->virt_base,
3509 + data->sg->length);
3510 + }
3511 + host->data->bytes_xfered += data->sg->length;
3512 +@@ -393,7 +393,7 @@ static void goldfish_mmc_prepare_data(struct goldfish_mmc_host *host,
3513 + * We don't really have DMA, so we need to copy to our
3514 + * platform driver buffer
3515 + */
3516 +- sg_copy_from_buffer(data->sg, 1, host->virt_base,
3517 ++ sg_copy_to_buffer(data->sg, 1, host->virt_base,
3518 + data->sg->length);
3519 + }
3520 + }
3521 +diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
3522 +index 5aa2c9404e92..be53044086c7 100644
3523 +--- a/drivers/mmc/host/atmel-mci.c
3524 ++++ b/drivers/mmc/host/atmel-mci.c
3525 +@@ -1976,7 +1976,7 @@ static void atmci_read_data_pio(struct atmel_mci *host)
3526 + do {
3527 + value = atmci_readl(host, ATMCI_RDR);
3528 + if (likely(offset + 4 <= sg->length)) {
3529 +- sg_pcopy_to_buffer(sg, 1, &value, sizeof(u32), offset);
3530 ++ sg_pcopy_from_buffer(sg, 1, &value, sizeof(u32), offset);
3531 +
3532 + offset += 4;
3533 + nbytes += 4;
3534 +@@ -1993,7 +1993,7 @@ static void atmci_read_data_pio(struct atmel_mci *host)
3535 + } else {
3536 + unsigned int remaining = sg->length - offset;
3537 +
3538 +- sg_pcopy_to_buffer(sg, 1, &value, remaining, offset);
3539 ++ sg_pcopy_from_buffer(sg, 1, &value, remaining, offset);
3540 + nbytes += remaining;
3541 +
3542 + flush_dcache_page(sg_page(sg));
3543 +@@ -2003,7 +2003,7 @@ static void atmci_read_data_pio(struct atmel_mci *host)
3544 + goto done;
3545 +
3546 + offset = 4 - remaining;
3547 +- sg_pcopy_to_buffer(sg, 1, (u8 *)&value + remaining,
3548 ++ sg_pcopy_from_buffer(sg, 1, (u8 *)&value + remaining,
3549 + offset, 0);
3550 + nbytes += offset;
3551 + }
3552 +@@ -2042,7 +2042,7 @@ static void atmci_write_data_pio(struct atmel_mci *host)
3553 +
3554 + do {
3555 + if (likely(offset + 4 <= sg->length)) {
3556 +- sg_pcopy_from_buffer(sg, 1, &value, sizeof(u32), offset);
3557 ++ sg_pcopy_to_buffer(sg, 1, &value, sizeof(u32), offset);
3558 + atmci_writel(host, ATMCI_TDR, value);
3559 +
3560 + offset += 4;
3561 +@@ -2059,7 +2059,7 @@ static void atmci_write_data_pio(struct atmel_mci *host)
3562 + unsigned int remaining = sg->length - offset;
3563 +
3564 + value = 0;
3565 +- sg_pcopy_from_buffer(sg, 1, &value, remaining, offset);
3566 ++ sg_pcopy_to_buffer(sg, 1, &value, remaining, offset);
3567 + nbytes += remaining;
3568 +
3569 + host->sg = sg = sg_next(sg);
3570 +@@ -2070,7 +2070,7 @@ static void atmci_write_data_pio(struct atmel_mci *host)
3571 + }
3572 +
3573 + offset = 4 - remaining;
3574 +- sg_pcopy_from_buffer(sg, 1, (u8 *)&value + remaining,
3575 ++ sg_pcopy_to_buffer(sg, 1, (u8 *)&value + remaining,
3576 + offset, 0);
3577 + atmci_writel(host, ATMCI_TDR, value);
3578 + nbytes += offset;
3579 +diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c
3580 +index 12f6753d47ae..e686fe73159e 100644
3581 +--- a/drivers/mtd/nand/raw/atmel/nand-controller.c
3582 ++++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
3583 +@@ -129,6 +129,11 @@
3584 + #define DEFAULT_TIMEOUT_MS 1000
3585 + #define MIN_DMA_LEN 128
3586 +
3587 ++static bool atmel_nand_avoid_dma __read_mostly;
3588 ++
3589 ++MODULE_PARM_DESC(avoiddma, "Avoid using DMA");
3590 ++module_param_named(avoiddma, atmel_nand_avoid_dma, bool, 0400);
3591 ++
3592 + enum atmel_nand_rb_type {
3593 + ATMEL_NAND_NO_RB,
3594 + ATMEL_NAND_NATIVE_RB,
3595 +@@ -1977,7 +1982,7 @@ static int atmel_nand_controller_init(struct atmel_nand_controller *nc,
3596 + return ret;
3597 + }
3598 +
3599 +- if (nc->caps->has_dma) {
3600 ++ if (nc->caps->has_dma && !atmel_nand_avoid_dma) {
3601 + dma_cap_mask_t mask;
3602 +
3603 + dma_cap_zero(mask);
3604 +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
3605 +index a8926e97935e..c5d387be6cfe 100644
3606 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
3607 ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
3608 +@@ -5705,7 +5705,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3609 + if (t4_read_reg(adapter, LE_DB_CONFIG_A) & HASHEN_F) {
3610 + u32 hash_base, hash_reg;
3611 +
3612 +- if (chip <= CHELSIO_T5) {
3613 ++ if (chip_ver <= CHELSIO_T5) {
3614 + hash_reg = LE_DB_TID_HASHBASE_A;
3615 + hash_base = t4_read_reg(adapter, hash_reg);
3616 + adapter->tids.hash_base = hash_base / 4;
3617 +diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
3618 +index fa5b30f547f6..cad52bd331f7 100644
3619 +--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
3620 ++++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
3621 +@@ -220,10 +220,10 @@ struct hnae_desc_cb {
3622 +
3623 + /* priv data for the desc, e.g. skb when use with ip stack*/
3624 + void *priv;
3625 +- u16 page_offset;
3626 +- u16 reuse_flag;
3627 ++ u32 page_offset;
3628 ++ u32 length; /* length of the buffer */
3629 +
3630 +- u16 length; /* length of the buffer */
3631 ++ u16 reuse_flag;
3632 +
3633 + /* desc type, used by the ring user to mark the type of the priv data */
3634 + u16 type;
3635 +diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
3636 +index ef9ef703d13a..ef994a715f93 100644
3637 +--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
3638 ++++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
3639 +@@ -530,7 +530,7 @@ static void hns_nic_reuse_page(struct sk_buff *skb, int i,
3640 + }
3641 +
3642 + skb_add_rx_frag(skb, i, desc_cb->priv, desc_cb->page_offset + pull_len,
3643 +- size - pull_len, truesize - pull_len);
3644 ++ size - pull_len, truesize);
3645 +
3646 + /* avoid re-using remote pages,flag default unreuse */
3647 + if (unlikely(page_to_nid(desc_cb->priv) != numa_node_id()))
3648 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
3649 +index 3b083d5ae9ce..c84c09053640 100644
3650 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
3651 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
3652 +@@ -290,11 +290,11 @@ struct hns3_desc_cb {
3653 +
3654 + /* priv data for the desc, e.g. skb when use with ip stack*/
3655 + void *priv;
3656 +- u16 page_offset;
3657 +- u16 reuse_flag;
3658 +-
3659 ++ u32 page_offset;
3660 + u32 length; /* length of the buffer */
3661 +
3662 ++ u16 reuse_flag;
3663 ++
3664 + /* desc type, used by the ring user to mark the type of the priv data */
3665 + u16 type;
3666 + };
3667 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
3668 +index 40c0425b4023..11620e003a8e 100644
3669 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
3670 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
3671 +@@ -201,7 +201,9 @@ static u32 hns3_lb_check_rx_ring(struct hns3_nic_priv *priv, u32 budget)
3672 + rx_group = &ring->tqp_vector->rx_group;
3673 + pre_rx_pkt = rx_group->total_packets;
3674 +
3675 ++ preempt_disable();
3676 + hns3_clean_rx_ring(ring, budget, hns3_lb_check_skb_data);
3677 ++ preempt_enable();
3678 +
3679 + rcv_good_pkt_total += (rx_group->total_packets - pre_rx_pkt);
3680 + rx_group->total_packets = pre_rx_pkt;
3681 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
3682 +index 262c125f8137..f027fceea548 100644
3683 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
3684 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
3685 +@@ -1223,6 +1223,10 @@ static int hclge_mac_pause_setup_hw(struct hclge_dev *hdev)
3686 + tx_en = true;
3687 + rx_en = true;
3688 + break;
3689 ++ case HCLGE_FC_PFC:
3690 ++ tx_en = false;
3691 ++ rx_en = false;
3692 ++ break;
3693 + default:
3694 + tx_en = true;
3695 + rx_en = true;
3696 +@@ -1240,8 +1244,9 @@ int hclge_pause_setup_hw(struct hclge_dev *hdev)
3697 + if (ret)
3698 + return ret;
3699 +
3700 +- if (hdev->tm_info.fc_mode != HCLGE_FC_PFC)
3701 +- return hclge_mac_pause_setup_hw(hdev);
3702 ++ ret = hclge_mac_pause_setup_hw(hdev);
3703 ++ if (ret)
3704 ++ return ret;
3705 +
3706 + /* Only DCB-supported dev supports qset back pressure and pfc cmd */
3707 + if (!hnae3_dev_dcb_supported(hdev))
3708 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
3709 +index a17872aab168..12aa1f1b99ef 100644
3710 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
3711 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
3712 +@@ -648,8 +648,17 @@ static int hclgevf_unmap_ring_from_vector(
3713 + static int hclgevf_put_vector(struct hnae3_handle *handle, int vector)
3714 + {
3715 + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
3716 ++ int vector_id;
3717 +
3718 +- hclgevf_free_vector(hdev, vector);
3719 ++ vector_id = hclgevf_get_vector_index(hdev, vector);
3720 ++ if (vector_id < 0) {
3721 ++ dev_err(&handle->pdev->dev,
3722 ++ "hclgevf_put_vector get vector index fail. ret =%d\n",
3723 ++ vector_id);
3724 ++ return vector_id;
3725 ++ }
3726 ++
3727 ++ hclgevf_free_vector(hdev, vector_id);
3728 +
3729 + return 0;
3730 + }
3731 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
3732 +index b598c06af8e0..cd246f906150 100644
3733 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
3734 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
3735 +@@ -208,7 +208,8 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev)
3736 +
3737 + /* tail the async message in arq */
3738 + msg_q = hdev->arq.msg_q[hdev->arq.tail];
3739 +- memcpy(&msg_q[0], req->msg, HCLGE_MBX_MAX_ARQ_MSG_SIZE);
3740 ++ memcpy(&msg_q[0], req->msg,
3741 ++ HCLGE_MBX_MAX_ARQ_MSG_SIZE * sizeof(u16));
3742 + hclge_mbx_tail_ptr_move_arq(hdev->arq);
3743 + hdev->arq.count++;
3744 +
3745 +diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
3746 +index bdb3f8e65ed4..2569a168334c 100644
3747 +--- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
3748 ++++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
3749 +@@ -624,14 +624,14 @@ static int e1000_set_ringparam(struct net_device *netdev,
3750 + adapter->tx_ring = tx_old;
3751 + e1000_free_all_rx_resources(adapter);
3752 + e1000_free_all_tx_resources(adapter);
3753 +- kfree(tx_old);
3754 +- kfree(rx_old);
3755 + adapter->rx_ring = rxdr;
3756 + adapter->tx_ring = txdr;
3757 + err = e1000_up(adapter);
3758 + if (err)
3759 + goto err_setup;
3760 + }
3761 ++ kfree(tx_old);
3762 ++ kfree(rx_old);
3763 +
3764 + clear_bit(__E1000_RESETTING, &adapter->flags);
3765 + return 0;
3766 +@@ -644,7 +644,8 @@ err_setup_rx:
3767 + err_alloc_rx:
3768 + kfree(txdr);
3769 + err_alloc_tx:
3770 +- e1000_up(adapter);
3771 ++ if (netif_running(adapter->netdev))
3772 ++ e1000_up(adapter);
3773 + err_setup:
3774 + clear_bit(__E1000_RESETTING, &adapter->flags);
3775 + return err;
3776 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
3777 +index 6947a2a571cb..5d670f4ce5ac 100644
3778 +--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
3779 ++++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
3780 +@@ -1903,7 +1903,7 @@ static void i40e_get_stat_strings(struct net_device *netdev, u8 *data)
3781 + data += ETH_GSTRING_LEN;
3782 + }
3783 +
3784 +- WARN_ONCE(p - data != i40e_get_stats_count(netdev) * ETH_GSTRING_LEN,
3785 ++ WARN_ONCE(data - p != i40e_get_stats_count(netdev) * ETH_GSTRING_LEN,
3786 + "stat strings count mismatch!");
3787 + }
3788 +
3789 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
3790 +index c944bd10b03d..5f105bc68c6a 100644
3791 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
3792 ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
3793 +@@ -5121,15 +5121,17 @@ static int i40e_vsi_configure_bw_alloc(struct i40e_vsi *vsi, u8 enabled_tc,
3794 + u8 *bw_share)
3795 + {
3796 + struct i40e_aqc_configure_vsi_tc_bw_data bw_data;
3797 ++ struct i40e_pf *pf = vsi->back;
3798 + i40e_status ret;
3799 + int i;
3800 +
3801 +- if (vsi->back->flags & I40E_FLAG_TC_MQPRIO)
3802 ++ /* There is no need to reset BW when mqprio mode is on. */
3803 ++ if (pf->flags & I40E_FLAG_TC_MQPRIO)
3804 + return 0;
3805 +- if (!vsi->mqprio_qopt.qopt.hw) {
3806 ++ if (!vsi->mqprio_qopt.qopt.hw && !(pf->flags & I40E_FLAG_DCB_ENABLED)) {
3807 + ret = i40e_set_bw_limit(vsi, vsi->seid, 0);
3808 + if (ret)
3809 +- dev_info(&vsi->back->pdev->dev,
3810 ++ dev_info(&pf->pdev->dev,
3811 + "Failed to reset tx rate for vsi->seid %u\n",
3812 + vsi->seid);
3813 + return ret;
3814 +@@ -5138,12 +5140,11 @@ static int i40e_vsi_configure_bw_alloc(struct i40e_vsi *vsi, u8 enabled_tc,
3815 + for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++)
3816 + bw_data.tc_bw_credits[i] = bw_share[i];
3817 +
3818 +- ret = i40e_aq_config_vsi_tc_bw(&vsi->back->hw, vsi->seid, &bw_data,
3819 +- NULL);
3820 ++ ret = i40e_aq_config_vsi_tc_bw(&pf->hw, vsi->seid, &bw_data, NULL);
3821 + if (ret) {
3822 +- dev_info(&vsi->back->pdev->dev,
3823 ++ dev_info(&pf->pdev->dev,
3824 + "AQ command Config VSI BW allocation per TC failed = %d\n",
3825 +- vsi->back->hw.aq.asq_last_status);
3826 ++ pf->hw.aq.asq_last_status);
3827 + return -EINVAL;
3828 + }
3829 +
3830 +diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
3831 +index d8b5fff581e7..ed071ea75f20 100644
3832 +--- a/drivers/net/ethernet/intel/ice/ice.h
3833 ++++ b/drivers/net/ethernet/intel/ice/ice.h
3834 +@@ -89,6 +89,13 @@ extern const char ice_drv_ver[];
3835 + #define ice_for_each_rxq(vsi, i) \
3836 + for ((i) = 0; (i) < (vsi)->num_rxq; (i)++)
3837 +
3838 ++/* Macros for each allocated tx/rx ring whether used or not in a VSI */
3839 ++#define ice_for_each_alloc_txq(vsi, i) \
3840 ++ for ((i) = 0; (i) < (vsi)->alloc_txq; (i)++)
3841 ++
3842 ++#define ice_for_each_alloc_rxq(vsi, i) \
3843 ++ for ((i) = 0; (i) < (vsi)->alloc_rxq; (i)++)
3844 ++
3845 + struct ice_tc_info {
3846 + u16 qoffset;
3847 + u16 qcount;
3848 +diff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
3849 +index 7541ec2270b3..a0614f472658 100644
3850 +--- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
3851 ++++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
3852 +@@ -329,19 +329,19 @@ struct ice_aqc_vsi_props {
3853 + /* VLAN section */
3854 + __le16 pvid; /* VLANS include priority bits */
3855 + u8 pvlan_reserved[2];
3856 +- u8 port_vlan_flags;
3857 +-#define ICE_AQ_VSI_PVLAN_MODE_S 0
3858 +-#define ICE_AQ_VSI_PVLAN_MODE_M (0x3 << ICE_AQ_VSI_PVLAN_MODE_S)
3859 +-#define ICE_AQ_VSI_PVLAN_MODE_UNTAGGED 0x1
3860 +-#define ICE_AQ_VSI_PVLAN_MODE_TAGGED 0x2
3861 +-#define ICE_AQ_VSI_PVLAN_MODE_ALL 0x3
3862 ++ u8 vlan_flags;
3863 ++#define ICE_AQ_VSI_VLAN_MODE_S 0
3864 ++#define ICE_AQ_VSI_VLAN_MODE_M (0x3 << ICE_AQ_VSI_VLAN_MODE_S)
3865 ++#define ICE_AQ_VSI_VLAN_MODE_UNTAGGED 0x1
3866 ++#define ICE_AQ_VSI_VLAN_MODE_TAGGED 0x2
3867 ++#define ICE_AQ_VSI_VLAN_MODE_ALL 0x3
3868 + #define ICE_AQ_VSI_PVLAN_INSERT_PVID BIT(2)
3869 +-#define ICE_AQ_VSI_PVLAN_EMOD_S 3
3870 +-#define ICE_AQ_VSI_PVLAN_EMOD_M (0x3 << ICE_AQ_VSI_PVLAN_EMOD_S)
3871 +-#define ICE_AQ_VSI_PVLAN_EMOD_STR_BOTH (0x0 << ICE_AQ_VSI_PVLAN_EMOD_S)
3872 +-#define ICE_AQ_VSI_PVLAN_EMOD_STR_UP (0x1 << ICE_AQ_VSI_PVLAN_EMOD_S)
3873 +-#define ICE_AQ_VSI_PVLAN_EMOD_STR (0x2 << ICE_AQ_VSI_PVLAN_EMOD_S)
3874 +-#define ICE_AQ_VSI_PVLAN_EMOD_NOTHING (0x3 << ICE_AQ_VSI_PVLAN_EMOD_S)
3875 ++#define ICE_AQ_VSI_VLAN_EMOD_S 3
3876 ++#define ICE_AQ_VSI_VLAN_EMOD_M (0x3 << ICE_AQ_VSI_VLAN_EMOD_S)
3877 ++#define ICE_AQ_VSI_VLAN_EMOD_STR_BOTH (0x0 << ICE_AQ_VSI_VLAN_EMOD_S)
3878 ++#define ICE_AQ_VSI_VLAN_EMOD_STR_UP (0x1 << ICE_AQ_VSI_VLAN_EMOD_S)
3879 ++#define ICE_AQ_VSI_VLAN_EMOD_STR (0x2 << ICE_AQ_VSI_VLAN_EMOD_S)
3880 ++#define ICE_AQ_VSI_VLAN_EMOD_NOTHING (0x3 << ICE_AQ_VSI_VLAN_EMOD_S)
3881 + u8 pvlan_reserved2[3];
3882 + /* ingress egress up sections */
3883 + __le32 ingress_table; /* bitmap, 3 bits per up */
3884 +@@ -594,6 +594,7 @@ struct ice_sw_rule_lg_act {
3885 + #define ICE_LG_ACT_GENERIC_OFFSET_M (0x7 << ICE_LG_ACT_GENERIC_OFFSET_S)
3886 + #define ICE_LG_ACT_GENERIC_PRIORITY_S 22
3887 + #define ICE_LG_ACT_GENERIC_PRIORITY_M (0x7 << ICE_LG_ACT_GENERIC_PRIORITY_S)
3888 ++#define ICE_LG_ACT_GENERIC_OFF_RX_DESC_PROF_IDX 7
3889 +
3890 + /* Action = 7 - Set Stat count */
3891 + #define ICE_LG_ACT_STAT_COUNT 0x7
3892 +diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
3893 +index 71d032cc5fa7..ebd701ac9428 100644
3894 +--- a/drivers/net/ethernet/intel/ice/ice_common.c
3895 ++++ b/drivers/net/ethernet/intel/ice/ice_common.c
3896 +@@ -1483,7 +1483,7 @@ enum ice_status ice_get_link_status(struct ice_port_info *pi, bool *link_up)
3897 + struct ice_phy_info *phy_info;
3898 + enum ice_status status = 0;
3899 +
3900 +- if (!pi)
3901 ++ if (!pi || !link_up)
3902 + return ICE_ERR_PARAM;
3903 +
3904 + phy_info = &pi->phy;
3905 +@@ -1619,20 +1619,23 @@ __ice_aq_get_set_rss_lut(struct ice_hw *hw, u16 vsi_id, u8 lut_type, u8 *lut,
3906 + }
3907 +
3908 + /* LUT size is only valid for Global and PF table types */
3909 +- if (lut_size == ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_128) {
3910 +- flags |= (ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_128_FLAG <<
3911 +- ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_S) &
3912 +- ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_M;
3913 +- } else if (lut_size == ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_512) {
3914 ++ switch (lut_size) {
3915 ++ case ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_128:
3916 ++ break;
3917 ++ case ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_512:
3918 + flags |= (ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_512_FLAG <<
3919 + ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_S) &
3920 + ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_M;
3921 +- } else if ((lut_size == ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K) &&
3922 +- (lut_type == ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF)) {
3923 +- flags |= (ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K_FLAG <<
3924 +- ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_S) &
3925 +- ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_M;
3926 +- } else {
3927 ++ break;
3928 ++ case ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K:
3929 ++ if (lut_type == ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF) {
3930 ++ flags |= (ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K_FLAG <<
3931 ++ ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_S) &
3932 ++ ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_M;
3933 ++ break;
3934 ++ }
3935 ++ /* fall-through */
3936 ++ default:
3937 + status = ICE_ERR_PARAM;
3938 + goto ice_aq_get_set_rss_lut_exit;
3939 + }
3940 +diff --git a/drivers/net/ethernet/intel/ice/ice_controlq.c b/drivers/net/ethernet/intel/ice/ice_controlq.c
3941 +index 7c511f144ed6..62be72fdc8f3 100644
3942 +--- a/drivers/net/ethernet/intel/ice/ice_controlq.c
3943 ++++ b/drivers/net/ethernet/intel/ice/ice_controlq.c
3944 +@@ -597,10 +597,14 @@ static enum ice_status ice_init_check_adminq(struct ice_hw *hw)
3945 + return 0;
3946 +
3947 + init_ctrlq_free_rq:
3948 +- ice_shutdown_rq(hw, cq);
3949 +- ice_shutdown_sq(hw, cq);
3950 +- mutex_destroy(&cq->sq_lock);
3951 +- mutex_destroy(&cq->rq_lock);
3952 ++ if (cq->rq.head) {
3953 ++ ice_shutdown_rq(hw, cq);
3954 ++ mutex_destroy(&cq->rq_lock);
3955 ++ }
3956 ++ if (cq->sq.head) {
3957 ++ ice_shutdown_sq(hw, cq);
3958 ++ mutex_destroy(&cq->sq_lock);
3959 ++ }
3960 + return status;
3961 + }
3962 +
3963 +@@ -706,10 +710,14 @@ static void ice_shutdown_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type)
3964 + return;
3965 + }
3966 +
3967 +- ice_shutdown_sq(hw, cq);
3968 +- ice_shutdown_rq(hw, cq);
3969 +- mutex_destroy(&cq->sq_lock);
3970 +- mutex_destroy(&cq->rq_lock);
3971 ++ if (cq->sq.head) {
3972 ++ ice_shutdown_sq(hw, cq);
3973 ++ mutex_destroy(&cq->sq_lock);
3974 ++ }
3975 ++ if (cq->rq.head) {
3976 ++ ice_shutdown_rq(hw, cq);
3977 ++ mutex_destroy(&cq->rq_lock);
3978 ++ }
3979 + }
3980 +
3981 + /**
3982 +@@ -1057,8 +1065,11 @@ ice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq,
3983 +
3984 + clean_rq_elem_out:
3985 + /* Set pending if needed, unlock and return */
3986 +- if (pending)
3987 ++ if (pending) {
3988 ++ /* re-read HW head to calculate actual pending messages */
3989 ++ ntu = (u16)(rd32(hw, cq->rq.head) & cq->rq.head_mask);
3990 + *pending = (u16)((ntc > ntu ? cq->rq.count : 0) + (ntu - ntc));
3991 ++ }
3992 + clean_rq_elem_err:
3993 + mutex_unlock(&cq->rq_lock);
3994 +
3995 +diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
3996 +index 1db304c01d10..c71a9b528d6d 100644
3997 +--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
3998 ++++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
3999 +@@ -26,7 +26,7 @@ static int ice_q_stats_len(struct net_device *netdev)
4000 + {
4001 + struct ice_netdev_priv *np = netdev_priv(netdev);
4002 +
4003 +- return ((np->vsi->num_txq + np->vsi->num_rxq) *
4004 ++ return ((np->vsi->alloc_txq + np->vsi->alloc_rxq) *
4005 + (sizeof(struct ice_q_stats) / sizeof(u64)));
4006 + }
4007 +
4008 +@@ -218,7 +218,7 @@ static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
4009 + p += ETH_GSTRING_LEN;
4010 + }
4011 +
4012 +- ice_for_each_txq(vsi, i) {
4013 ++ ice_for_each_alloc_txq(vsi, i) {
4014 + snprintf(p, ETH_GSTRING_LEN,
4015 + "tx-queue-%u.tx_packets", i);
4016 + p += ETH_GSTRING_LEN;
4017 +@@ -226,7 +226,7 @@ static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
4018 + p += ETH_GSTRING_LEN;
4019 + }
4020 +
4021 +- ice_for_each_rxq(vsi, i) {
4022 ++ ice_for_each_alloc_rxq(vsi, i) {
4023 + snprintf(p, ETH_GSTRING_LEN,
4024 + "rx-queue-%u.rx_packets", i);
4025 + p += ETH_GSTRING_LEN;
4026 +@@ -253,6 +253,24 @@ static int ice_get_sset_count(struct net_device *netdev, int sset)
4027 + {
4028 + switch (sset) {
4029 + case ETH_SS_STATS:
4030 ++ /* The number (and order) of strings reported *must* remain
4031 ++ * constant for a given netdevice. This function must not
4032 ++ * report a different number based on run time parameters
4033 ++ * (such as the number of queues in use, or the setting of
4034 ++ * a private ethtool flag). This is due to the nature of the
4035 ++ * ethtool stats API.
4036 ++ *
4037 ++ * User space programs such as ethtool must make 3 separate
4038 ++ * ioctl requests, one for size, one for the strings, and
4039 ++ * finally one for the stats. Since these cross into
4040 ++ * user space, changes to the number or size could result in
4041 ++ * undefined memory access or incorrect string<->value
4042 ++ * correlations for statistics.
4043 ++ *
4044 ++ * Even if it appears to be safe, changes to the size or
4045 ++ * order of strings will suffer from race conditions and are
4046 ++ * not safe.
4047 ++ */
4048 + return ICE_ALL_STATS_LEN(netdev);
4049 + default:
4050 + return -EOPNOTSUPP;
4051 +@@ -280,18 +298,26 @@ ice_get_ethtool_stats(struct net_device *netdev,
4052 + /* populate per queue stats */
4053 + rcu_read_lock();
4054 +
4055 +- ice_for_each_txq(vsi, j) {
4056 ++ ice_for_each_alloc_txq(vsi, j) {
4057 + ring = READ_ONCE(vsi->tx_rings[j]);
4058 +- if (!ring)
4059 +- continue;
4060 +- data[i++] = ring->stats.pkts;
4061 +- data[i++] = ring->stats.bytes;
4062 ++ if (ring) {
4063 ++ data[i++] = ring->stats.pkts;
4064 ++ data[i++] = ring->stats.bytes;
4065 ++ } else {
4066 ++ data[i++] = 0;
4067 ++ data[i++] = 0;
4068 ++ }
4069 + }
4070 +
4071 +- ice_for_each_rxq(vsi, j) {
4072 ++ ice_for_each_alloc_rxq(vsi, j) {
4073 + ring = READ_ONCE(vsi->rx_rings[j]);
4074 +- data[i++] = ring->stats.pkts;
4075 +- data[i++] = ring->stats.bytes;
4076 ++ if (ring) {
4077 ++ data[i++] = ring->stats.pkts;
4078 ++ data[i++] = ring->stats.bytes;
4079 ++ } else {
4080 ++ data[i++] = 0;
4081 ++ data[i++] = 0;
4082 ++ }
4083 + }
4084 +
4085 + rcu_read_unlock();
4086 +@@ -519,7 +545,7 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
4087 + goto done;
4088 + }
4089 +
4090 +- for (i = 0; i < vsi->num_txq; i++) {
4091 ++ for (i = 0; i < vsi->alloc_txq; i++) {
4092 + /* clone ring and setup updated count */
4093 + tx_rings[i] = *vsi->tx_rings[i];
4094 + tx_rings[i].count = new_tx_cnt;
4095 +@@ -551,7 +577,7 @@ process_rx:
4096 + goto done;
4097 + }
4098 +
4099 +- for (i = 0; i < vsi->num_rxq; i++) {
4100 ++ for (i = 0; i < vsi->alloc_rxq; i++) {
4101 + /* clone ring and setup updated count */
4102 + rx_rings[i] = *vsi->rx_rings[i];
4103 + rx_rings[i].count = new_rx_cnt;
4104 +diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
4105 +index 5299caf55a7f..27c9aa31b248 100644
4106 +--- a/drivers/net/ethernet/intel/ice/ice_main.c
4107 ++++ b/drivers/net/ethernet/intel/ice/ice_main.c
4108 +@@ -916,6 +916,21 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)
4109 + return pending && (i == ICE_DFLT_IRQ_WORK);
4110 + }
4111 +
4112 ++/**
4113 ++ * ice_ctrlq_pending - check if there is a difference between ntc and ntu
4114 ++ * @hw: pointer to hardware info
4115 ++ * @cq: control queue information
4116 ++ *
4117 ++ * returns true if there are pending messages in a queue, false if there aren't
4118 ++ */
4119 ++static bool ice_ctrlq_pending(struct ice_hw *hw, struct ice_ctl_q_info *cq)
4120 ++{
4121 ++ u16 ntu;
4122 ++
4123 ++ ntu = (u16)(rd32(hw, cq->rq.head) & cq->rq.head_mask);
4124 ++ return cq->rq.next_to_clean != ntu;
4125 ++}
4126 ++
4127 + /**
4128 + * ice_clean_adminq_subtask - clean the AdminQ rings
4129 + * @pf: board private structure
4130 +@@ -923,7 +938,6 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)
4131 + static void ice_clean_adminq_subtask(struct ice_pf *pf)
4132 + {
4133 + struct ice_hw *hw = &pf->hw;
4134 +- u32 val;
4135 +
4136 + if (!test_bit(__ICE_ADMINQ_EVENT_PENDING, pf->state))
4137 + return;
4138 +@@ -933,9 +947,13 @@ static void ice_clean_adminq_subtask(struct ice_pf *pf)
4139 +
4140 + clear_bit(__ICE_ADMINQ_EVENT_PENDING, pf->state);
4141 +
4142 +- /* re-enable Admin queue interrupt causes */
4143 +- val = rd32(hw, PFINT_FW_CTL);
4144 +- wr32(hw, PFINT_FW_CTL, (val | PFINT_FW_CTL_CAUSE_ENA_M));
4145 ++ /* There might be a situation where new messages arrive to a control
4146 ++ * queue between processing the last message and clearing the
4147 ++ * EVENT_PENDING bit. So before exiting, check queue head again (using
4148 ++ * ice_ctrlq_pending) and process new messages if any.
4149 ++ */
4150 ++ if (ice_ctrlq_pending(hw, &hw->adminq))
4151 ++ __ice_clean_ctrlq(pf, ICE_CTL_Q_ADMIN);
4152 +
4153 + ice_flush(hw);
4154 + }
4155 +@@ -1295,11 +1313,8 @@ static void ice_vsi_setup_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt)
4156 + qcount = numq_tc;
4157 + }
4158 +
4159 +- /* find higher power-of-2 of qcount */
4160 +- pow = ilog2(qcount);
4161 +-
4162 +- if (!is_power_of_2(qcount))
4163 +- pow++;
4164 ++ /* find the (rounded up) power-of-2 of qcount */
4165 ++ pow = order_base_2(qcount);
4166 +
4167 + for (i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
4168 + if (!(vsi->tc_cfg.ena_tc & BIT(i))) {
4169 +@@ -1352,14 +1367,15 @@ static void ice_set_dflt_vsi_ctx(struct ice_vsi_ctx *ctxt)
4170 + ctxt->info.sw_flags = ICE_AQ_VSI_SW_FLAG_SRC_PRUNE;
4171 + /* Traffic from VSI can be sent to LAN */
4172 + ctxt->info.sw_flags2 = ICE_AQ_VSI_SW_FLAG_LAN_ENA;
4173 +- /* Allow all packets untagged/tagged */
4174 +- ctxt->info.port_vlan_flags = ((ICE_AQ_VSI_PVLAN_MODE_ALL &
4175 +- ICE_AQ_VSI_PVLAN_MODE_M) >>
4176 +- ICE_AQ_VSI_PVLAN_MODE_S);
4177 +- /* Show VLAN/UP from packets in Rx descriptors */
4178 +- ctxt->info.port_vlan_flags |= ((ICE_AQ_VSI_PVLAN_EMOD_STR_BOTH &
4179 +- ICE_AQ_VSI_PVLAN_EMOD_M) >>
4180 +- ICE_AQ_VSI_PVLAN_EMOD_S);
4181 ++
4182 ++ /* By default bits 3 and 4 in vlan_flags are 0's which results in legacy
4183 ++ * behavior (show VLAN, DEI, and UP) in descriptor. Also, allow all
4184 ++ * packets untagged/tagged.
4185 ++ */
4186 ++ ctxt->info.vlan_flags = ((ICE_AQ_VSI_VLAN_MODE_ALL &
4187 ++ ICE_AQ_VSI_VLAN_MODE_M) >>
4188 ++ ICE_AQ_VSI_VLAN_MODE_S);
4189 ++
4190 + /* Have 1:1 UP mapping for both ingress/egress tables */
4191 + table |= ICE_UP_TABLE_TRANSLATE(0, 0);
4192 + table |= ICE_UP_TABLE_TRANSLATE(1, 1);
4193 +@@ -2058,15 +2074,13 @@ static int ice_req_irq_msix_misc(struct ice_pf *pf)
4194 + skip_req_irq:
4195 + ice_ena_misc_vector(pf);
4196 +
4197 +- val = (pf->oicr_idx & PFINT_OICR_CTL_MSIX_INDX_M) |
4198 +- (ICE_RX_ITR & PFINT_OICR_CTL_ITR_INDX_M) |
4199 +- PFINT_OICR_CTL_CAUSE_ENA_M;
4200 ++ val = ((pf->oicr_idx & PFINT_OICR_CTL_MSIX_INDX_M) |
4201 ++ PFINT_OICR_CTL_CAUSE_ENA_M);
4202 + wr32(hw, PFINT_OICR_CTL, val);
4203 +
4204 + /* This enables Admin queue Interrupt causes */
4205 +- val = (pf->oicr_idx & PFINT_FW_CTL_MSIX_INDX_M) |
4206 +- (ICE_RX_ITR & PFINT_FW_CTL_ITR_INDX_M) |
4207 +- PFINT_FW_CTL_CAUSE_ENA_M;
4208 ++ val = ((pf->oicr_idx & PFINT_FW_CTL_MSIX_INDX_M) |
4209 ++ PFINT_FW_CTL_CAUSE_ENA_M);
4210 + wr32(hw, PFINT_FW_CTL, val);
4211 +
4212 + itr_gran = hw->itr_gran_200;
4213 +@@ -3246,8 +3260,10 @@ static void ice_clear_interrupt_scheme(struct ice_pf *pf)
4214 + if (test_bit(ICE_FLAG_MSIX_ENA, pf->flags))
4215 + ice_dis_msix(pf);
4216 +
4217 +- devm_kfree(&pf->pdev->dev, pf->irq_tracker);
4218 +- pf->irq_tracker = NULL;
4219 ++ if (pf->irq_tracker) {
4220 ++ devm_kfree(&pf->pdev->dev, pf->irq_tracker);
4221 ++ pf->irq_tracker = NULL;
4222 ++ }
4223 + }
4224 +
4225 + /**
4226 +@@ -3720,10 +3736,10 @@ static int ice_vsi_manage_vlan_insertion(struct ice_vsi *vsi)
4227 + enum ice_status status;
4228 +
4229 + /* Here we are configuring the VSI to let the driver add VLAN tags by
4230 +- * setting port_vlan_flags to ICE_AQ_VSI_PVLAN_MODE_ALL. The actual VLAN
4231 +- * tag insertion happens in the Tx hot path, in ice_tx_map.
4232 ++ * setting vlan_flags to ICE_AQ_VSI_VLAN_MODE_ALL. The actual VLAN tag
4233 ++ * insertion happens in the Tx hot path, in ice_tx_map.
4234 + */
4235 +- ctxt.info.port_vlan_flags = ICE_AQ_VSI_PVLAN_MODE_ALL;
4236 ++ ctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_MODE_ALL;
4237 +
4238 + ctxt.info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_VLAN_VALID);
4239 + ctxt.vsi_num = vsi->vsi_num;
4240 +@@ -3735,7 +3751,7 @@ static int ice_vsi_manage_vlan_insertion(struct ice_vsi *vsi)
4241 + return -EIO;
4242 + }
4243 +
4244 +- vsi->info.port_vlan_flags = ctxt.info.port_vlan_flags;
4245 ++ vsi->info.vlan_flags = ctxt.info.vlan_flags;
4246 + return 0;
4247 + }
4248 +
4249 +@@ -3757,12 +3773,15 @@ static int ice_vsi_manage_vlan_stripping(struct ice_vsi *vsi, bool ena)
4250 + */
4251 + if (ena) {
4252 + /* Strip VLAN tag from Rx packet and put it in the desc */
4253 +- ctxt.info.port_vlan_flags = ICE_AQ_VSI_PVLAN_EMOD_STR_BOTH;
4254 ++ ctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_EMOD_STR_BOTH;
4255 + } else {
4256 + /* Disable stripping. Leave tag in packet */
4257 +- ctxt.info.port_vlan_flags = ICE_AQ_VSI_PVLAN_EMOD_NOTHING;
4258 ++ ctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_EMOD_NOTHING;
4259 + }
4260 +
4261 ++ /* Allow all packets untagged/tagged */
4262 ++ ctxt.info.vlan_flags |= ICE_AQ_VSI_VLAN_MODE_ALL;
4263 ++
4264 + ctxt.info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_VLAN_VALID);
4265 + ctxt.vsi_num = vsi->vsi_num;
4266 +
4267 +@@ -3773,7 +3792,7 @@ static int ice_vsi_manage_vlan_stripping(struct ice_vsi *vsi, bool ena)
4268 + return -EIO;
4269 + }
4270 +
4271 +- vsi->info.port_vlan_flags = ctxt.info.port_vlan_flags;
4272 ++ vsi->info.vlan_flags = ctxt.info.vlan_flags;
4273 + return 0;
4274 + }
4275 +
4276 +@@ -4098,11 +4117,12 @@ static int ice_vsi_cfg(struct ice_vsi *vsi)
4277 + {
4278 + int err;
4279 +
4280 +- ice_set_rx_mode(vsi->netdev);
4281 +-
4282 +- err = ice_restore_vlan(vsi);
4283 +- if (err)
4284 +- return err;
4285 ++ if (vsi->netdev) {
4286 ++ ice_set_rx_mode(vsi->netdev);
4287 ++ err = ice_restore_vlan(vsi);
4288 ++ if (err)
4289 ++ return err;
4290 ++ }
4291 +
4292 + err = ice_vsi_cfg_txqs(vsi);
4293 + if (!err)
4294 +@@ -4868,7 +4888,7 @@ int ice_down(struct ice_vsi *vsi)
4295 + */
4296 + static int ice_vsi_setup_tx_rings(struct ice_vsi *vsi)
4297 + {
4298 +- int i, err;
4299 ++ int i, err = 0;
4300 +
4301 + if (!vsi->num_txq) {
4302 + dev_err(&vsi->back->pdev->dev, "VSI %d has 0 Tx queues\n",
4303 +@@ -4893,7 +4913,7 @@ static int ice_vsi_setup_tx_rings(struct ice_vsi *vsi)
4304 + */
4305 + static int ice_vsi_setup_rx_rings(struct ice_vsi *vsi)
4306 + {
4307 +- int i, err;
4308 ++ int i, err = 0;
4309 +
4310 + if (!vsi->num_rxq) {
4311 + dev_err(&vsi->back->pdev->dev, "VSI %d has 0 Rx queues\n",
4312 +diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
4313 +index 723d15f1e90b..6b7ec2ae5ad6 100644
4314 +--- a/drivers/net/ethernet/intel/ice/ice_switch.c
4315 ++++ b/drivers/net/ethernet/intel/ice/ice_switch.c
4316 +@@ -645,14 +645,14 @@ ice_add_marker_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent,
4317 + act |= (1 << ICE_LG_ACT_GENERIC_VALUE_S) & ICE_LG_ACT_GENERIC_VALUE_M;
4318 + lg_act->pdata.lg_act.act[1] = cpu_to_le32(act);
4319 +
4320 +- act = (7 << ICE_LG_ACT_GENERIC_OFFSET_S) & ICE_LG_ACT_GENERIC_VALUE_M;
4321 ++ act = (ICE_LG_ACT_GENERIC_OFF_RX_DESC_PROF_IDX <<
4322 ++ ICE_LG_ACT_GENERIC_OFFSET_S) & ICE_LG_ACT_GENERIC_OFFSET_M;
4323 +
4324 + /* Third action Marker value */
4325 + act |= ICE_LG_ACT_GENERIC;
4326 + act |= (sw_marker << ICE_LG_ACT_GENERIC_VALUE_S) &
4327 + ICE_LG_ACT_GENERIC_VALUE_M;
4328 +
4329 +- act |= (0 << ICE_LG_ACT_GENERIC_OFFSET_S) & ICE_LG_ACT_GENERIC_VALUE_M;
4330 + lg_act->pdata.lg_act.act[2] = cpu_to_le32(act);
4331 +
4332 + /* call the fill switch rule to fill the lookup tx rx structure */
4333 +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
4334 +index 6f59933cdff7..2bc4fe475f28 100644
4335 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
4336 ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
4337 +@@ -688,8 +688,13 @@ static int ixgbe_set_vf_macvlan(struct ixgbe_adapter *adapter,
4338 + static inline void ixgbe_vf_reset_event(struct ixgbe_adapter *adapter, u32 vf)
4339 + {
4340 + struct ixgbe_hw *hw = &adapter->hw;
4341 ++ struct ixgbe_ring_feature *vmdq = &adapter->ring_feature[RING_F_VMDQ];
4342 + struct vf_data_storage *vfinfo = &adapter->vfinfo[vf];
4343 ++ u32 q_per_pool = __ALIGN_MASK(1, ~vmdq->mask);
4344 + u8 num_tcs = adapter->hw_tcs;
4345 ++ u32 reg_val;
4346 ++ u32 queue;
4347 ++ u32 word;
4348 +
4349 + /* remove VLAN filters beloning to this VF */
4350 + ixgbe_clear_vf_vlans(adapter, vf);
4351 +@@ -726,6 +731,27 @@ static inline void ixgbe_vf_reset_event(struct ixgbe_adapter *adapter, u32 vf)
4352 +
4353 + /* reset VF api back to unknown */
4354 + adapter->vfinfo[vf].vf_api = ixgbe_mbox_api_10;
4355 ++
4356 ++ /* Restart each queue for given VF */
4357 ++ for (queue = 0; queue < q_per_pool; queue++) {
4358 ++ unsigned int reg_idx = (vf * q_per_pool) + queue;
4359 ++
4360 ++ reg_val = IXGBE_READ_REG(hw, IXGBE_PVFTXDCTL(reg_idx));
4361 ++
4362 ++ /* Re-enabling only configured queues */
4363 ++ if (reg_val) {
4364 ++ reg_val |= IXGBE_TXDCTL_ENABLE;
4365 ++ IXGBE_WRITE_REG(hw, IXGBE_PVFTXDCTL(reg_idx), reg_val);
4366 ++ reg_val &= ~IXGBE_TXDCTL_ENABLE;
4367 ++ IXGBE_WRITE_REG(hw, IXGBE_PVFTXDCTL(reg_idx), reg_val);
4368 ++ }
4369 ++ }
4370 ++
4371 ++ /* Clear VF's mailbox memory */
4372 ++ for (word = 0; word < IXGBE_VFMAILBOX_SIZE; word++)
4373 ++ IXGBE_WRITE_REG_ARRAY(hw, IXGBE_PFMBMEM(vf), word, 0);
4374 ++
4375 ++ IXGBE_WRITE_FLUSH(hw);
4376 + }
4377 +
4378 + static int ixgbe_set_vf_mac(struct ixgbe_adapter *adapter,
4379 +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
4380 +index 44cfb2021145..41bcbb337e83 100644
4381 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
4382 ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
4383 +@@ -2518,6 +2518,7 @@ enum {
4384 + /* Translated register #defines */
4385 + #define IXGBE_PVFTDH(P) (0x06010 + (0x40 * (P)))
4386 + #define IXGBE_PVFTDT(P) (0x06018 + (0x40 * (P)))
4387 ++#define IXGBE_PVFTXDCTL(P) (0x06028 + (0x40 * (P)))
4388 + #define IXGBE_PVFTDWBAL(P) (0x06038 + (0x40 * (P)))
4389 + #define IXGBE_PVFTDWBAH(P) (0x0603C + (0x40 * (P)))
4390 +
4391 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
4392 +index cdd645024a32..ad6826b5f758 100644
4393 +--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
4394 ++++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
4395 +@@ -48,7 +48,7 @@
4396 + #include "qed_reg_addr.h"
4397 + #include "qed_sriov.h"
4398 +
4399 +-#define CHIP_MCP_RESP_ITER_US 10
4400 ++#define QED_MCP_RESP_ITER_US 10
4401 +
4402 + #define QED_DRV_MB_MAX_RETRIES (500 * 1000) /* Account for 5 sec */
4403 + #define QED_MCP_RESET_RETRIES (50 * 1000) /* Account for 500 msec */
4404 +@@ -183,18 +183,57 @@ int qed_mcp_free(struct qed_hwfn *p_hwfn)
4405 + return 0;
4406 + }
4407 +
4408 ++/* Maximum of 1 sec to wait for the SHMEM ready indication */
4409 ++#define QED_MCP_SHMEM_RDY_MAX_RETRIES 20
4410 ++#define QED_MCP_SHMEM_RDY_ITER_MS 50
4411 ++
4412 + static int qed_load_mcp_offsets(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
4413 + {
4414 + struct qed_mcp_info *p_info = p_hwfn->mcp_info;
4415 ++ u8 cnt = QED_MCP_SHMEM_RDY_MAX_RETRIES;
4416 ++ u8 msec = QED_MCP_SHMEM_RDY_ITER_MS;
4417 + u32 drv_mb_offsize, mfw_mb_offsize;
4418 + u32 mcp_pf_id = MCP_PF_ID(p_hwfn);
4419 +
4420 + p_info->public_base = qed_rd(p_hwfn, p_ptt, MISC_REG_SHARED_MEM_ADDR);
4421 +- if (!p_info->public_base)
4422 +- return 0;
4423 ++ if (!p_info->public_base) {
4424 ++ DP_NOTICE(p_hwfn,
4425 ++ "The address of the MCP scratch-pad is not configured\n");
4426 ++ return -EINVAL;
4427 ++ }
4428 +
4429 + p_info->public_base |= GRCBASE_MCP;
4430 +
4431 ++ /* Get the MFW MB address and number of supported messages */
4432 ++ mfw_mb_offsize = qed_rd(p_hwfn, p_ptt,
4433 ++ SECTION_OFFSIZE_ADDR(p_info->public_base,
4434 ++ PUBLIC_MFW_MB));
4435 ++ p_info->mfw_mb_addr = SECTION_ADDR(mfw_mb_offsize, mcp_pf_id);
4436 ++ p_info->mfw_mb_length = (u16)qed_rd(p_hwfn, p_ptt,
4437 ++ p_info->mfw_mb_addr +
4438 ++ offsetof(struct public_mfw_mb,
4439 ++ sup_msgs));
4440 ++
4441 ++ /* The driver can notify that there was an MCP reset, and might read the
4442 ++ * SHMEM values before the MFW has completed initializing them.
4443 ++ * To avoid this, the "sup_msgs" field in the MFW mailbox is used as a
4444 ++ * data ready indication.
4445 ++ */
4446 ++ while (!p_info->mfw_mb_length && --cnt) {
4447 ++ msleep(msec);
4448 ++ p_info->mfw_mb_length =
4449 ++ (u16)qed_rd(p_hwfn, p_ptt,
4450 ++ p_info->mfw_mb_addr +
4451 ++ offsetof(struct public_mfw_mb, sup_msgs));
4452 ++ }
4453 ++
4454 ++ if (!cnt) {
4455 ++ DP_NOTICE(p_hwfn,
4456 ++ "Failed to get the SHMEM ready notification after %d msec\n",
4457 ++ QED_MCP_SHMEM_RDY_MAX_RETRIES * msec);
4458 ++ return -EBUSY;
4459 ++ }
4460 ++
4461 + /* Calculate the driver and MFW mailbox address */
4462 + drv_mb_offsize = qed_rd(p_hwfn, p_ptt,
4463 + SECTION_OFFSIZE_ADDR(p_info->public_base,
4464 +@@ -204,13 +243,6 @@ static int qed_load_mcp_offsets(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
4465 + "drv_mb_offsiz = 0x%x, drv_mb_addr = 0x%x mcp_pf_id = 0x%x\n",
4466 + drv_mb_offsize, p_info->drv_mb_addr, mcp_pf_id);
4467 +
4468 +- /* Set the MFW MB address */
4469 +- mfw_mb_offsize = qed_rd(p_hwfn, p_ptt,
4470 +- SECTION_OFFSIZE_ADDR(p_info->public_base,
4471 +- PUBLIC_MFW_MB));
4472 +- p_info->mfw_mb_addr = SECTION_ADDR(mfw_mb_offsize, mcp_pf_id);
4473 +- p_info->mfw_mb_length = (u16)qed_rd(p_hwfn, p_ptt, p_info->mfw_mb_addr);
4474 +-
4475 + /* Get the current driver mailbox sequence before sending
4476 + * the first command
4477 + */
4478 +@@ -285,9 +317,15 @@ static void qed_mcp_reread_offsets(struct qed_hwfn *p_hwfn,
4479 +
4480 + int qed_mcp_reset(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
4481 + {
4482 +- u32 org_mcp_reset_seq, seq, delay = CHIP_MCP_RESP_ITER_US, cnt = 0;
4483 ++ u32 org_mcp_reset_seq, seq, delay = QED_MCP_RESP_ITER_US, cnt = 0;
4484 + int rc = 0;
4485 +
4486 ++ if (p_hwfn->mcp_info->b_block_cmd) {
4487 ++ DP_NOTICE(p_hwfn,
4488 ++ "The MFW is not responsive. Avoid sending MCP_RESET mailbox command.\n");
4489 ++ return -EBUSY;
4490 ++ }
4491 ++
4492 + /* Ensure that only a single thread is accessing the mailbox */
4493 + spin_lock_bh(&p_hwfn->mcp_info->cmd_lock);
4494 +
4495 +@@ -413,14 +451,41 @@ static void __qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
4496 + (p_mb_params->cmd | seq_num), p_mb_params->param);
4497 + }
4498 +
4499 ++static void qed_mcp_cmd_set_blocking(struct qed_hwfn *p_hwfn, bool block_cmd)
4500 ++{
4501 ++ p_hwfn->mcp_info->b_block_cmd = block_cmd;
4502 ++
4503 ++ DP_INFO(p_hwfn, "%s sending of mailbox commands to the MFW\n",
4504 ++ block_cmd ? "Block" : "Unblock");
4505 ++}
4506 ++
4507 ++static void qed_mcp_print_cpu_info(struct qed_hwfn *p_hwfn,
4508 ++ struct qed_ptt *p_ptt)
4509 ++{
4510 ++ u32 cpu_mode, cpu_state, cpu_pc_0, cpu_pc_1, cpu_pc_2;
4511 ++ u32 delay = QED_MCP_RESP_ITER_US;
4512 ++
4513 ++ cpu_mode = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_MODE);
4514 ++ cpu_state = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_STATE);
4515 ++ cpu_pc_0 = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_PROGRAM_COUNTER);
4516 ++ udelay(delay);
4517 ++ cpu_pc_1 = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_PROGRAM_COUNTER);
4518 ++ udelay(delay);
4519 ++ cpu_pc_2 = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_PROGRAM_COUNTER);
4520 ++
4521 ++ DP_NOTICE(p_hwfn,
4522 ++ "MCP CPU info: mode 0x%08x, state 0x%08x, pc {0x%08x, 0x%08x, 0x%08x}\n",
4523 ++ cpu_mode, cpu_state, cpu_pc_0, cpu_pc_1, cpu_pc_2);
4524 ++}
4525 ++
4526 + static int
4527 + _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
4528 + struct qed_ptt *p_ptt,
4529 + struct qed_mcp_mb_params *p_mb_params,
4530 +- u32 max_retries, u32 delay)
4531 ++ u32 max_retries, u32 usecs)
4532 + {
4533 ++ u32 cnt = 0, msecs = DIV_ROUND_UP(usecs, 1000);
4534 + struct qed_mcp_cmd_elem *p_cmd_elem;
4535 +- u32 cnt = 0;
4536 + u16 seq_num;
4537 + int rc = 0;
4538 +
4539 +@@ -443,7 +508,11 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
4540 + goto err;
4541 +
4542 + spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock);
4543 +- udelay(delay);
4544 ++
4545 ++ if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP))
4546 ++ msleep(msecs);
4547 ++ else
4548 ++ udelay(usecs);
4549 + } while (++cnt < max_retries);
4550 +
4551 + if (cnt >= max_retries) {
4552 +@@ -472,7 +541,11 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
4553 + * The spinlock stays locked until the list element is removed.
4554 + */
4555 +
4556 +- udelay(delay);
4557 ++ if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP))
4558 ++ msleep(msecs);
4559 ++ else
4560 ++ udelay(usecs);
4561 ++
4562 + spin_lock_bh(&p_hwfn->mcp_info->cmd_lock);
4563 +
4564 + if (p_cmd_elem->b_is_completed)
4565 +@@ -491,11 +564,15 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
4566 + DP_NOTICE(p_hwfn,
4567 + "The MFW failed to respond to command 0x%08x [param 0x%08x].\n",
4568 + p_mb_params->cmd, p_mb_params->param);
4569 ++ qed_mcp_print_cpu_info(p_hwfn, p_ptt);
4570 +
4571 + spin_lock_bh(&p_hwfn->mcp_info->cmd_lock);
4572 + qed_mcp_cmd_del_elem(p_hwfn, p_cmd_elem);
4573 + spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock);
4574 +
4575 ++ if (!QED_MB_FLAGS_IS_SET(p_mb_params, AVOID_BLOCK))
4576 ++ qed_mcp_cmd_set_blocking(p_hwfn, true);
4577 ++
4578 + return -EAGAIN;
4579 + }
4580 +
4581 +@@ -507,7 +584,7 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
4582 + "MFW mailbox: response 0x%08x param 0x%08x [after %d.%03d ms]\n",
4583 + p_mb_params->mcp_resp,
4584 + p_mb_params->mcp_param,
4585 +- (cnt * delay) / 1000, (cnt * delay) % 1000);
4586 ++ (cnt * usecs) / 1000, (cnt * usecs) % 1000);
4587 +
4588 + /* Clear the sequence number from the MFW response */
4589 + p_mb_params->mcp_resp &= FW_MSG_CODE_MASK;
4590 +@@ -525,7 +602,7 @@ static int qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
4591 + {
4592 + size_t union_data_size = sizeof(union drv_union_data);
4593 + u32 max_retries = QED_DRV_MB_MAX_RETRIES;
4594 +- u32 delay = CHIP_MCP_RESP_ITER_US;
4595 ++ u32 usecs = QED_MCP_RESP_ITER_US;
4596 +
4597 + /* MCP not initialized */
4598 + if (!qed_mcp_is_init(p_hwfn)) {
4599 +@@ -533,6 +610,13 @@ static int qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
4600 + return -EBUSY;
4601 + }
4602 +
4603 ++ if (p_hwfn->mcp_info->b_block_cmd) {
4604 ++ DP_NOTICE(p_hwfn,
4605 ++ "The MFW is not responsive. Avoid sending mailbox command 0x%08x [param 0x%08x].\n",
4606 ++ p_mb_params->cmd, p_mb_params->param);
4607 ++ return -EBUSY;
4608 ++ }
4609 ++
4610 + if (p_mb_params->data_src_size > union_data_size ||
4611 + p_mb_params->data_dst_size > union_data_size) {
4612 + DP_ERR(p_hwfn,
4613 +@@ -542,8 +626,13 @@ static int qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
4614 + return -EINVAL;
4615 + }
4616 +
4617 ++ if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP)) {
4618 ++ max_retries = DIV_ROUND_UP(max_retries, 1000);
4619 ++ usecs *= 1000;
4620 ++ }
4621 ++
4622 + return _qed_mcp_cmd_and_union(p_hwfn, p_ptt, p_mb_params, max_retries,
4623 +- delay);
4624 ++ usecs);
4625 + }
4626 +
4627 + int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
4628 +@@ -760,6 +849,7 @@ __qed_mcp_load_req(struct qed_hwfn *p_hwfn,
4629 + mb_params.data_src_size = sizeof(load_req);
4630 + mb_params.p_data_dst = &load_rsp;
4631 + mb_params.data_dst_size = sizeof(load_rsp);
4632 ++ mb_params.flags = QED_MB_FLAG_CAN_SLEEP | QED_MB_FLAG_AVOID_BLOCK;
4633 +
4634 + DP_VERBOSE(p_hwfn, QED_MSG_SP,
4635 + "Load Request: param 0x%08x [init_hw %d, drv_type %d, hsi_ver %d, pda 0x%04x]\n",
4636 +@@ -981,7 +1071,8 @@ int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
4637 +
4638 + int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
4639 + {
4640 +- u32 wol_param, mcp_resp, mcp_param;
4641 ++ struct qed_mcp_mb_params mb_params;
4642 ++ u32 wol_param;
4643 +
4644 + switch (p_hwfn->cdev->wol_config) {
4645 + case QED_OV_WOL_DISABLED:
4646 +@@ -999,8 +1090,12 @@ int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
4647 + wol_param = DRV_MB_PARAM_UNLOAD_WOL_MCP;
4648 + }
4649 +
4650 +- return qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_UNLOAD_REQ, wol_param,
4651 +- &mcp_resp, &mcp_param);
4652 ++ memset(&mb_params, 0, sizeof(mb_params));
4653 ++ mb_params.cmd = DRV_MSG_CODE_UNLOAD_REQ;
4654 ++ mb_params.param = wol_param;
4655 ++ mb_params.flags = QED_MB_FLAG_CAN_SLEEP | QED_MB_FLAG_AVOID_BLOCK;
4656 ++
4657 ++ return qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params);
4658 + }
4659 +
4660 + int qed_mcp_unload_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
4661 +@@ -2075,31 +2170,65 @@ qed_mcp_send_drv_version(struct qed_hwfn *p_hwfn,
4662 + return rc;
4663 + }
4664 +
4665 ++/* A maximal 100 msec waiting time for the MCP to halt */
4666 ++#define QED_MCP_HALT_SLEEP_MS 10
4667 ++#define QED_MCP_HALT_MAX_RETRIES 10
4668 ++
4669 + int qed_mcp_halt(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
4670 + {
4671 +- u32 resp = 0, param = 0;
4672 ++ u32 resp = 0, param = 0, cpu_state, cnt = 0;
4673 + int rc;
4674 +
4675 + rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_MCP_HALT, 0, &resp,
4676 + &param);
4677 +- if (rc)
4678 ++ if (rc) {
4679 + DP_ERR(p_hwfn, "MCP response failure, aborting\n");
4680 ++ return rc;
4681 ++ }
4682 +
4683 +- return rc;
4684 ++ do {
4685 ++ msleep(QED_MCP_HALT_SLEEP_MS);
4686 ++ cpu_state = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_STATE);
4687 ++ if (cpu_state & MCP_REG_CPU_STATE_SOFT_HALTED)
4688 ++ break;
4689 ++ } while (++cnt < QED_MCP_HALT_MAX_RETRIES);
4690 ++
4691 ++ if (cnt == QED_MCP_HALT_MAX_RETRIES) {
4692 ++ DP_NOTICE(p_hwfn,
4693 ++ "Failed to halt the MCP [CPU_MODE = 0x%08x, CPU_STATE = 0x%08x]\n",
4694 ++ qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_MODE), cpu_state);
4695 ++ return -EBUSY;
4696 ++ }
4697 ++
4698 ++ qed_mcp_cmd_set_blocking(p_hwfn, true);
4699 ++
4700 ++ return 0;
4701 + }
4702 +
4703 ++#define QED_MCP_RESUME_SLEEP_MS 10
4704 ++
4705 + int qed_mcp_resume(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
4706 + {
4707 +- u32 value, cpu_mode;
4708 ++ u32 cpu_mode, cpu_state;
4709 +
4710 + qed_wr(p_hwfn, p_ptt, MCP_REG_CPU_STATE, 0xffffffff);
4711 +
4712 +- value = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_MODE);
4713 +- value &= ~MCP_REG_CPU_MODE_SOFT_HALT;
4714 +- qed_wr(p_hwfn, p_ptt, MCP_REG_CPU_MODE, value);
4715 + cpu_mode = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_MODE);
4716 ++ cpu_mode &= ~MCP_REG_CPU_MODE_SOFT_HALT;
4717 ++ qed_wr(p_hwfn, p_ptt, MCP_REG_CPU_MODE, cpu_mode);
4718 ++ msleep(QED_MCP_RESUME_SLEEP_MS);
4719 ++ cpu_state = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_STATE);
4720 +
4721 +- return (cpu_mode & MCP_REG_CPU_MODE_SOFT_HALT) ? -EAGAIN : 0;
4722 ++ if (cpu_state & MCP_REG_CPU_STATE_SOFT_HALTED) {
4723 ++ DP_NOTICE(p_hwfn,
4724 ++ "Failed to resume the MCP [CPU_MODE = 0x%08x, CPU_STATE = 0x%08x]\n",
4725 ++ cpu_mode, cpu_state);
4726 ++ return -EBUSY;
4727 ++ }
4728 ++
4729 ++ qed_mcp_cmd_set_blocking(p_hwfn, false);
4730 ++
4731 ++ return 0;
4732 + }
4733 +
4734 + int qed_mcp_ov_update_current_config(struct qed_hwfn *p_hwfn,
4735 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.h b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
4736 +index 632a838f1fe3..ce2e617d2cab 100644
4737 +--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.h
4738 ++++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
4739 +@@ -635,11 +635,14 @@ struct qed_mcp_info {
4740 + */
4741 + spinlock_t cmd_lock;
4742 +
4743 ++ /* Flag to indicate whether sending a MFW mailbox command is blocked */
4744 ++ bool b_block_cmd;
4745 ++
4746 + /* Spinlock used for syncing SW link-changes and link-changes
4747 + * originating from attention context.
4748 + */
4749 + spinlock_t link_lock;
4750 +- bool block_mb_sending;
4751 ++
4752 + u32 public_base;
4753 + u32 drv_mb_addr;
4754 + u32 mfw_mb_addr;
4755 +@@ -660,14 +663,20 @@ struct qed_mcp_info {
4756 + };
4757 +
4758 + struct qed_mcp_mb_params {
4759 +- u32 cmd;
4760 +- u32 param;
4761 +- void *p_data_src;
4762 +- u8 data_src_size;
4763 +- void *p_data_dst;
4764 +- u8 data_dst_size;
4765 +- u32 mcp_resp;
4766 +- u32 mcp_param;
4767 ++ u32 cmd;
4768 ++ u32 param;
4769 ++ void *p_data_src;
4770 ++ void *p_data_dst;
4771 ++ u8 data_src_size;
4772 ++ u8 data_dst_size;
4773 ++ u32 mcp_resp;
4774 ++ u32 mcp_param;
4775 ++ u32 flags;
4776 ++#define QED_MB_FLAG_CAN_SLEEP (0x1 << 0)
4777 ++#define QED_MB_FLAG_AVOID_BLOCK (0x1 << 1)
4778 ++#define QED_MB_FLAGS_IS_SET(params, flag) \
4779 ++ ({ typeof(params) __params = (params); \
4780 ++ (__params && (__params->flags & QED_MB_FLAG_ ## flag)); })
4781 + };
4782 +
4783 + struct qed_drv_tlv_hdr {
4784 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_reg_addr.h b/drivers/net/ethernet/qlogic/qed/qed_reg_addr.h
4785 +index d8ad2dcad8d5..f736f70956fd 100644
4786 +--- a/drivers/net/ethernet/qlogic/qed/qed_reg_addr.h
4787 ++++ b/drivers/net/ethernet/qlogic/qed/qed_reg_addr.h
4788 +@@ -562,8 +562,10 @@
4789 + 0
4790 + #define MCP_REG_CPU_STATE \
4791 + 0xe05004UL
4792 ++#define MCP_REG_CPU_STATE_SOFT_HALTED (0x1UL << 10)
4793 + #define MCP_REG_CPU_EVENT_MASK \
4794 + 0xe05008UL
4795 ++#define MCP_REG_CPU_PROGRAM_COUNTER 0xe0501cUL
4796 + #define PGLUE_B_REG_PF_BAR0_SIZE \
4797 + 0x2aae60UL
4798 + #define PGLUE_B_REG_PF_BAR1_SIZE \
4799 +diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c
4800 +index 2e5150b0b8d5..7a14e8170e82 100644
4801 +--- a/drivers/net/phy/xilinx_gmii2rgmii.c
4802 ++++ b/drivers/net/phy/xilinx_gmii2rgmii.c
4803 +@@ -40,8 +40,11 @@ static int xgmiitorgmii_read_status(struct phy_device *phydev)
4804 + {
4805 + struct gmii2rgmii *priv = phydev->priv;
4806 + u16 val = 0;
4807 ++ int err;
4808 +
4809 +- priv->phy_drv->read_status(phydev);
4810 ++ err = priv->phy_drv->read_status(phydev);
4811 ++ if (err < 0)
4812 ++ return err;
4813 +
4814 + val = mdiobus_read(phydev->mdio.bus, priv->addr, XILINX_GMII2RGMII_REG);
4815 + val &= ~XILINX_GMII2RGMII_SPEED_MASK;
4816 +@@ -81,6 +84,11 @@ static int xgmiitorgmii_probe(struct mdio_device *mdiodev)
4817 + return -EPROBE_DEFER;
4818 + }
4819 +
4820 ++ if (!priv->phy_dev->drv) {
4821 ++ dev_info(dev, "Attached phy not ready\n");
4822 ++ return -EPROBE_DEFER;
4823 ++ }
4824 ++
4825 + priv->addr = mdiodev->addr;
4826 + priv->phy_drv = priv->phy_dev->drv;
4827 + memcpy(&priv->conv_phy_drv, priv->phy_dev->drv,
4828 +diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
4829 +index 3b96a43fbda4..18c709c484e7 100644
4830 +--- a/drivers/net/wireless/ath/ath10k/ce.c
4831 ++++ b/drivers/net/wireless/ath/ath10k/ce.c
4832 +@@ -1512,7 +1512,7 @@ ath10k_ce_alloc_src_ring_64(struct ath10k *ar, unsigned int ce_id,
4833 + ret = ath10k_ce_alloc_shadow_base(ar, src_ring, nentries);
4834 + if (ret) {
4835 + dma_free_coherent(ar->dev,
4836 +- (nentries * sizeof(struct ce_desc) +
4837 ++ (nentries * sizeof(struct ce_desc_64) +
4838 + CE_DESC_RING_ALIGN),
4839 + src_ring->base_addr_owner_space_unaligned,
4840 + base_addr);
4841 +diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
4842 +index c72d8af122a2..4d1cd90d6d27 100644
4843 +--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
4844 ++++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
4845 +@@ -268,11 +268,12 @@ int ath10k_htt_rx_ring_refill(struct ath10k *ar)
4846 + spin_lock_bh(&htt->rx_ring.lock);
4847 + ret = ath10k_htt_rx_ring_fill_n(htt, (htt->rx_ring.fill_level -
4848 + htt->rx_ring.fill_cnt));
4849 +- spin_unlock_bh(&htt->rx_ring.lock);
4850 +
4851 + if (ret)
4852 + ath10k_htt_rx_ring_free(htt);
4853 +
4854 ++ spin_unlock_bh(&htt->rx_ring.lock);
4855 ++
4856 + return ret;
4857 + }
4858 +
4859 +@@ -284,7 +285,9 @@ void ath10k_htt_rx_free(struct ath10k_htt *htt)
4860 + skb_queue_purge(&htt->rx_in_ord_compl_q);
4861 + skb_queue_purge(&htt->tx_fetch_ind_q);
4862 +
4863 ++ spin_lock_bh(&htt->rx_ring.lock);
4864 + ath10k_htt_rx_ring_free(htt);
4865 ++ spin_unlock_bh(&htt->rx_ring.lock);
4866 +
4867 + dma_free_coherent(htt->ar->dev,
4868 + ath10k_htt_get_rx_ring_size(htt),
4869 +@@ -1089,7 +1092,7 @@ static void ath10k_htt_rx_h_queue_msdu(struct ath10k *ar,
4870 + status = IEEE80211_SKB_RXCB(skb);
4871 + *status = *rx_status;
4872 +
4873 +- __skb_queue_tail(&ar->htt.rx_msdus_q, skb);
4874 ++ skb_queue_tail(&ar->htt.rx_msdus_q, skb);
4875 + }
4876 +
4877 + static void ath10k_process_rx(struct ath10k *ar, struct sk_buff *skb)
4878 +@@ -2810,7 +2813,7 @@ bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb)
4879 + break;
4880 + }
4881 + case HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND: {
4882 +- __skb_queue_tail(&htt->rx_in_ord_compl_q, skb);
4883 ++ skb_queue_tail(&htt->rx_in_ord_compl_q, skb);
4884 + return false;
4885 + }
4886 + case HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND:
4887 +@@ -2874,7 +2877,7 @@ static int ath10k_htt_rx_deliver_msdu(struct ath10k *ar, int quota, int budget)
4888 + if (skb_queue_empty(&ar->htt.rx_msdus_q))
4889 + break;
4890 +
4891 +- skb = __skb_dequeue(&ar->htt.rx_msdus_q);
4892 ++ skb = skb_dequeue(&ar->htt.rx_msdus_q);
4893 + if (!skb)
4894 + break;
4895 + ath10k_process_rx(ar, skb);
4896 +@@ -2905,7 +2908,7 @@ int ath10k_htt_txrx_compl_task(struct ath10k *ar, int budget)
4897 + goto exit;
4898 + }
4899 +
4900 +- while ((skb = __skb_dequeue(&htt->rx_in_ord_compl_q))) {
4901 ++ while ((skb = skb_dequeue(&htt->rx_in_ord_compl_q))) {
4902 + spin_lock_bh(&htt->rx_ring.lock);
4903 + ret = ath10k_htt_rx_in_ord_ind(ar, skb);
4904 + spin_unlock_bh(&htt->rx_ring.lock);
4905 +diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
4906 +index 747c6951b5c1..e0b9f7d0dfd3 100644
4907 +--- a/drivers/net/wireless/ath/ath10k/mac.c
4908 ++++ b/drivers/net/wireless/ath/ath10k/mac.c
4909 +@@ -4054,6 +4054,7 @@ void ath10k_mac_tx_push_pending(struct ath10k *ar)
4910 + rcu_read_unlock();
4911 + spin_unlock_bh(&ar->txqs_lock);
4912 + }
4913 ++EXPORT_SYMBOL(ath10k_mac_tx_push_pending);
4914 +
4915 + /************/
4916 + /* Scanning */
4917 +diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c
4918 +index d612ce8c9cff..299db8b1c9ba 100644
4919 +--- a/drivers/net/wireless/ath/ath10k/sdio.c
4920 ++++ b/drivers/net/wireless/ath/ath10k/sdio.c
4921 +@@ -30,6 +30,7 @@
4922 + #include "debug.h"
4923 + #include "hif.h"
4924 + #include "htc.h"
4925 ++#include "mac.h"
4926 + #include "targaddrs.h"
4927 + #include "trace.h"
4928 + #include "sdio.h"
4929 +@@ -396,6 +397,7 @@ static int ath10k_sdio_mbox_rx_process_packet(struct ath10k *ar,
4930 + int ret;
4931 +
4932 + payload_len = le16_to_cpu(htc_hdr->len);
4933 ++ skb->len = payload_len + sizeof(struct ath10k_htc_hdr);
4934 +
4935 + if (trailer_present) {
4936 + trailer = skb->data + sizeof(*htc_hdr) +
4937 +@@ -434,12 +436,14 @@ static int ath10k_sdio_mbox_rx_process_packets(struct ath10k *ar,
4938 + enum ath10k_htc_ep_id id;
4939 + int ret, i, *n_lookahead_local;
4940 + u32 *lookaheads_local;
4941 ++ int lookahead_idx = 0;
4942 +
4943 + for (i = 0; i < ar_sdio->n_rx_pkts; i++) {
4944 + lookaheads_local = lookaheads;
4945 + n_lookahead_local = n_lookahead;
4946 +
4947 +- id = ((struct ath10k_htc_hdr *)&lookaheads[i])->eid;
4948 ++ id = ((struct ath10k_htc_hdr *)
4949 ++ &lookaheads[lookahead_idx++])->eid;
4950 +
4951 + if (id >= ATH10K_HTC_EP_COUNT) {
4952 + ath10k_warn(ar, "invalid endpoint in look-ahead: %d\n",
4953 +@@ -462,6 +466,7 @@ static int ath10k_sdio_mbox_rx_process_packets(struct ath10k *ar,
4954 + /* Only read lookahead's from RX trailers
4955 + * for the last packet in a bundle.
4956 + */
4957 ++ lookahead_idx--;
4958 + lookaheads_local = NULL;
4959 + n_lookahead_local = NULL;
4960 + }
4961 +@@ -1342,6 +1347,8 @@ static void ath10k_sdio_irq_handler(struct sdio_func *func)
4962 + break;
4963 + } while (time_before(jiffies, timeout) && !done);
4964 +
4965 ++ ath10k_mac_tx_push_pending(ar);
4966 ++
4967 + sdio_claim_host(ar_sdio->func);
4968 +
4969 + if (ret && ret != -ECANCELED)
4970 +diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c
4971 +index a3a7042fe13a..aa621bf50a91 100644
4972 +--- a/drivers/net/wireless/ath/ath10k/snoc.c
4973 ++++ b/drivers/net/wireless/ath/ath10k/snoc.c
4974 +@@ -449,7 +449,7 @@ static void ath10k_snoc_htt_rx_cb(struct ath10k_ce_pipe *ce_state)
4975 +
4976 + static void ath10k_snoc_rx_replenish_retry(struct timer_list *t)
4977 + {
4978 +- struct ath10k_pci *ar_snoc = from_timer(ar_snoc, t, rx_post_retry);
4979 ++ struct ath10k_snoc *ar_snoc = from_timer(ar_snoc, t, rx_post_retry);
4980 + struct ath10k *ar = ar_snoc->ar;
4981 +
4982 + ath10k_snoc_rx_post(ar);
4983 +diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
4984 +index f97ab795cf2e..2319f79b34f0 100644
4985 +--- a/drivers/net/wireless/ath/ath10k/wmi.c
4986 ++++ b/drivers/net/wireless/ath/ath10k/wmi.c
4987 +@@ -4602,10 +4602,6 @@ void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, struct sk_buff *skb)
4988 +
4989 + ev = (struct wmi_pdev_tpc_config_event *)skb->data;
4990 +
4991 +- tpc_stats = kzalloc(sizeof(*tpc_stats), GFP_ATOMIC);
4992 +- if (!tpc_stats)
4993 +- return;
4994 +-
4995 + num_tx_chain = __le32_to_cpu(ev->num_tx_chain);
4996 +
4997 + if (num_tx_chain > WMI_TPC_TX_N_CHAIN) {
4998 +@@ -4614,6 +4610,10 @@ void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, struct sk_buff *skb)
4999 + return;
5000 + }
5001 +
5002 ++ tpc_stats = kzalloc(sizeof(*tpc_stats), GFP_ATOMIC);
5003 ++ if (!tpc_stats)
5004 ++ return;
5005 ++
5006 + ath10k_wmi_tpc_config_get_rate_code(rate_code, pream_table,
5007 + num_tx_chain);
5008 +
5009 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c
5010 +index b9672da24a9d..b24bc57ca91b 100644
5011 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c
5012 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_qmath.c
5013 +@@ -213,7 +213,7 @@ static const s16 log_table[] = {
5014 + 30498,
5015 + 31267,
5016 + 32024,
5017 +- 32768
5018 ++ 32767
5019 + };
5020 +
5021 + #define LOG_TABLE_SIZE 32 /* log_table size */
5022 +diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c
5023 +index b49aea4da2d6..8985446570bd 100644
5024 +--- a/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c
5025 ++++ b/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c
5026 +@@ -439,15 +439,13 @@ mt76x2_mac_fill_tx_status(struct mt76x2_dev *dev,
5027 + if (last_rate < IEEE80211_TX_MAX_RATES - 1)
5028 + rate[last_rate + 1].idx = -1;
5029 +
5030 +- cur_idx = rate[last_rate].idx + st->retry;
5031 ++ cur_idx = rate[last_rate].idx + last_rate;
5032 + for (i = 0; i <= last_rate; i++) {
5033 + rate[i].flags = rate[last_rate].flags;
5034 + rate[i].idx = max_t(int, 0, cur_idx - i);
5035 + rate[i].count = 1;
5036 + }
5037 +-
5038 +- if (last_rate > 0)
5039 +- rate[last_rate - 1].count = st->retry + 1 - last_rate;
5040 ++ rate[last_rate].count = st->retry + 1 - last_rate;
5041 +
5042 + info->status.ampdu_len = n_frames;
5043 + info->status.ampdu_ack_len = st->success ? n_frames : 0;
5044 +diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
5045 +index 9935bd09db1f..d4947e3a909e 100644
5046 +--- a/drivers/net/wireless/rndis_wlan.c
5047 ++++ b/drivers/net/wireless/rndis_wlan.c
5048 +@@ -2928,6 +2928,8 @@ static void rndis_wlan_auth_indication(struct usbnet *usbdev,
5049 +
5050 + while (buflen >= sizeof(*auth_req)) {
5051 + auth_req = (void *)buf;
5052 ++ if (buflen < le32_to_cpu(auth_req->length))
5053 ++ return;
5054 + type = "unknown";
5055 + flags = le32_to_cpu(auth_req->flags);
5056 + pairwise_error = false;
5057 +diff --git a/drivers/net/wireless/ti/wlcore/cmd.c b/drivers/net/wireless/ti/wlcore/cmd.c
5058 +index 761cf8573a80..f48c3f62966d 100644
5059 +--- a/drivers/net/wireless/ti/wlcore/cmd.c
5060 ++++ b/drivers/net/wireless/ti/wlcore/cmd.c
5061 +@@ -35,6 +35,7 @@
5062 + #include "wl12xx_80211.h"
5063 + #include "cmd.h"
5064 + #include "event.h"
5065 ++#include "ps.h"
5066 + #include "tx.h"
5067 + #include "hw_ops.h"
5068 +
5069 +@@ -191,6 +192,10 @@ int wlcore_cmd_wait_for_event_or_timeout(struct wl1271 *wl,
5070 +
5071 + timeout_time = jiffies + msecs_to_jiffies(WL1271_EVENT_TIMEOUT);
5072 +
5073 ++ ret = wl1271_ps_elp_wakeup(wl);
5074 ++ if (ret < 0)
5075 ++ return ret;
5076 ++
5077 + do {
5078 + if (time_after(jiffies, timeout_time)) {
5079 + wl1271_debug(DEBUG_CMD, "timeout waiting for event %d",
5080 +@@ -222,6 +227,7 @@ int wlcore_cmd_wait_for_event_or_timeout(struct wl1271 *wl,
5081 + } while (!event);
5082 +
5083 + out:
5084 ++ wl1271_ps_elp_sleep(wl);
5085 + kfree(events_vector);
5086 + return ret;
5087 + }
5088 +diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
5089 +index 34712def81b1..5251689a1d9a 100644
5090 +--- a/drivers/nvme/target/fcloop.c
5091 ++++ b/drivers/nvme/target/fcloop.c
5092 +@@ -311,7 +311,7 @@ fcloop_tgt_lsrqst_done_work(struct work_struct *work)
5093 + struct fcloop_tport *tport = tls_req->tport;
5094 + struct nvmefc_ls_req *lsreq = tls_req->lsreq;
5095 +
5096 +- if (tport->remoteport)
5097 ++ if (!tport || tport->remoteport)
5098 + lsreq->done(lsreq, tls_req->status);
5099 + }
5100 +
5101 +@@ -329,6 +329,7 @@ fcloop_ls_req(struct nvme_fc_local_port *localport,
5102 +
5103 + if (!rport->targetport) {
5104 + tls_req->status = -ECONNREFUSED;
5105 ++ tls_req->tport = NULL;
5106 + schedule_work(&tls_req->work);
5107 + return ret;
5108 + }
5109 +diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
5110 +index ef0b1b6ba86f..12afa7fdf77e 100644
5111 +--- a/drivers/pci/hotplug/acpiphp_glue.c
5112 ++++ b/drivers/pci/hotplug/acpiphp_glue.c
5113 +@@ -457,17 +457,18 @@ static void acpiphp_native_scan_bridge(struct pci_dev *bridge)
5114 + /**
5115 + * enable_slot - enable, configure a slot
5116 + * @slot: slot to be enabled
5117 ++ * @bridge: true if enable is for the whole bridge (not a single slot)
5118 + *
5119 + * This function should be called per *physical slot*,
5120 + * not per each slot object in ACPI namespace.
5121 + */
5122 +-static void enable_slot(struct acpiphp_slot *slot)
5123 ++static void enable_slot(struct acpiphp_slot *slot, bool bridge)
5124 + {
5125 + struct pci_dev *dev;
5126 + struct pci_bus *bus = slot->bus;
5127 + struct acpiphp_func *func;
5128 +
5129 +- if (bus->self && hotplug_is_native(bus->self)) {
5130 ++ if (bridge && bus->self && hotplug_is_native(bus->self)) {
5131 + /*
5132 + * If native hotplug is used, it will take care of hotplug
5133 + * slot management and resource allocation for hotplug
5134 +@@ -701,7 +702,7 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)
5135 + trim_stale_devices(dev);
5136 +
5137 + /* configure all functions */
5138 +- enable_slot(slot);
5139 ++ enable_slot(slot, true);
5140 + } else {
5141 + disable_slot(slot);
5142 + }
5143 +@@ -785,7 +786,7 @@ static void hotplug_event(u32 type, struct acpiphp_context *context)
5144 + if (bridge)
5145 + acpiphp_check_bridge(bridge);
5146 + else if (!(slot->flags & SLOT_IS_GOING_AWAY))
5147 +- enable_slot(slot);
5148 ++ enable_slot(slot, false);
5149 +
5150 + break;
5151 +
5152 +@@ -973,7 +974,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
5153 +
5154 + /* configure all functions */
5155 + if (!(slot->flags & SLOT_ENABLED))
5156 +- enable_slot(slot);
5157 ++ enable_slot(slot, false);
5158 +
5159 + pci_unlock_rescan_remove();
5160 + return 0;
5161 +diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c
5162 +index 6afd011de9e5..b8e35a8d65cf 100644
5163 +--- a/drivers/platform/x86/asus-wireless.c
5164 ++++ b/drivers/platform/x86/asus-wireless.c
5165 +@@ -52,13 +52,12 @@ static const struct acpi_device_id device_ids[] = {
5166 + };
5167 + MODULE_DEVICE_TABLE(acpi, device_ids);
5168 +
5169 +-static u64 asus_wireless_method(acpi_handle handle, const char *method,
5170 +- int param)
5171 ++static acpi_status asus_wireless_method(acpi_handle handle, const char *method,
5172 ++ int param, u64 *ret)
5173 + {
5174 + struct acpi_object_list p;
5175 + union acpi_object obj;
5176 + acpi_status s;
5177 +- u64 ret;
5178 +
5179 + acpi_handle_debug(handle, "Evaluating method %s, parameter %#x\n",
5180 + method, param);
5181 +@@ -67,24 +66,27 @@ static u64 asus_wireless_method(acpi_handle handle, const char *method,
5182 + p.count = 1;
5183 + p.pointer = &obj;
5184 +
5185 +- s = acpi_evaluate_integer(handle, (acpi_string) method, &p, &ret);
5186 ++ s = acpi_evaluate_integer(handle, (acpi_string) method, &p, ret);
5187 + if (ACPI_FAILURE(s))
5188 + acpi_handle_err(handle,
5189 + "Failed to eval method %s, param %#x (%d)\n",
5190 + method, param, s);
5191 +- acpi_handle_debug(handle, "%s returned %#llx\n", method, ret);
5192 +- return ret;
5193 ++ else
5194 ++ acpi_handle_debug(handle, "%s returned %#llx\n", method, *ret);
5195 ++
5196 ++ return s;
5197 + }
5198 +
5199 + static enum led_brightness led_state_get(struct led_classdev *led)
5200 + {
5201 + struct asus_wireless_data *data;
5202 +- int s;
5203 ++ acpi_status s;
5204 ++ u64 ret;
5205 +
5206 + data = container_of(led, struct asus_wireless_data, led);
5207 + s = asus_wireless_method(acpi_device_handle(data->adev), "HSWC",
5208 +- data->hswc_params->status);
5209 +- if (s == data->hswc_params->on)
5210 ++ data->hswc_params->status, &ret);
5211 ++ if (ACPI_SUCCESS(s) && ret == data->hswc_params->on)
5212 + return LED_FULL;
5213 + return LED_OFF;
5214 + }
5215 +@@ -92,10 +94,11 @@ static enum led_brightness led_state_get(struct led_classdev *led)
5216 + static void led_state_update(struct work_struct *work)
5217 + {
5218 + struct asus_wireless_data *data;
5219 ++ u64 ret;
5220 +
5221 + data = container_of(work, struct asus_wireless_data, led_work);
5222 + asus_wireless_method(acpi_device_handle(data->adev), "HSWC",
5223 +- data->led_state);
5224 ++ data->led_state, &ret);
5225 + }
5226 +
5227 + static void led_state_set(struct led_classdev *led, enum led_brightness value)
5228 +diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c
5229 +index 102f95a09460..e9e749f87517 100644
5230 +--- a/drivers/power/reset/vexpress-poweroff.c
5231 ++++ b/drivers/power/reset/vexpress-poweroff.c
5232 +@@ -35,6 +35,7 @@ static void vexpress_reset_do(struct device *dev, const char *what)
5233 + }
5234 +
5235 + static struct device *vexpress_power_off_device;
5236 ++static atomic_t vexpress_restart_nb_refcnt = ATOMIC_INIT(0);
5237 +
5238 + static void vexpress_power_off(void)
5239 + {
5240 +@@ -99,10 +100,13 @@ static int _vexpress_register_restart_handler(struct device *dev)
5241 + int err;
5242 +
5243 + vexpress_restart_device = dev;
5244 +- err = register_restart_handler(&vexpress_restart_nb);
5245 +- if (err) {
5246 +- dev_err(dev, "cannot register restart handler (err=%d)\n", err);
5247 +- return err;
5248 ++ if (atomic_inc_return(&vexpress_restart_nb_refcnt) == 1) {
5249 ++ err = register_restart_handler(&vexpress_restart_nb);
5250 ++ if (err) {
5251 ++ dev_err(dev, "cannot register restart handler (err=%d)\n", err);
5252 ++ atomic_dec(&vexpress_restart_nb_refcnt);
5253 ++ return err;
5254 ++ }
5255 + }
5256 + device_create_file(dev, &dev_attr_active);
5257 +
5258 +diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c
5259 +index 6e1bc14c3304..735658ee1c60 100644
5260 +--- a/drivers/power/supply/axp288_charger.c
5261 ++++ b/drivers/power/supply/axp288_charger.c
5262 +@@ -718,7 +718,7 @@ static int charger_init_hw_regs(struct axp288_chrg_info *info)
5263 + }
5264 +
5265 + /* Determine charge current limit */
5266 +- cc = (ret & CHRG_CCCV_CC_MASK) >> CHRG_CCCV_CC_BIT_POS;
5267 ++ cc = (val & CHRG_CCCV_CC_MASK) >> CHRG_CCCV_CC_BIT_POS;
5268 + cc = (cc * CHRG_CCCV_CC_LSB_RES) + CHRG_CCCV_CC_OFFSET;
5269 + info->cc = cc;
5270 +
5271 +diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
5272 +index d21f478741c1..e85361878450 100644
5273 +--- a/drivers/power/supply/power_supply_core.c
5274 ++++ b/drivers/power/supply/power_supply_core.c
5275 +@@ -14,6 +14,7 @@
5276 + #include <linux/types.h>
5277 + #include <linux/init.h>
5278 + #include <linux/slab.h>
5279 ++#include <linux/delay.h>
5280 + #include <linux/device.h>
5281 + #include <linux/notifier.h>
5282 + #include <linux/err.h>
5283 +@@ -140,8 +141,13 @@ static void power_supply_deferred_register_work(struct work_struct *work)
5284 + struct power_supply *psy = container_of(work, struct power_supply,
5285 + deferred_register_work.work);
5286 +
5287 +- if (psy->dev.parent)
5288 +- mutex_lock(&psy->dev.parent->mutex);
5289 ++ if (psy->dev.parent) {
5290 ++ while (!mutex_trylock(&psy->dev.parent->mutex)) {
5291 ++ if (psy->removing)
5292 ++ return;
5293 ++ msleep(10);
5294 ++ }
5295 ++ }
5296 +
5297 + power_supply_changed(psy);
5298 +
5299 +@@ -1082,6 +1088,7 @@ EXPORT_SYMBOL_GPL(devm_power_supply_register_no_ws);
5300 + void power_supply_unregister(struct power_supply *psy)
5301 + {
5302 + WARN_ON(atomic_dec_return(&psy->use_cnt));
5303 ++ psy->removing = true;
5304 + cancel_work_sync(&psy->changed_work);
5305 + cancel_delayed_work_sync(&psy->deferred_register_work);
5306 + sysfs_remove_link(&psy->dev.kobj, "powers");
5307 +diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
5308 +index 6ed568b96c0e..cc1450c53fb2 100644
5309 +--- a/drivers/regulator/core.c
5310 ++++ b/drivers/regulator/core.c
5311 +@@ -3147,7 +3147,7 @@ static inline int regulator_suspend_toggle(struct regulator_dev *rdev,
5312 + if (!rstate->changeable)
5313 + return -EPERM;
5314 +
5315 +- rstate->enabled = en;
5316 ++ rstate->enabled = (en) ? ENABLE_IN_SUSPEND : DISABLE_IN_SUSPEND;
5317 +
5318 + return 0;
5319 + }
5320 +@@ -4381,13 +4381,13 @@ regulator_register(const struct regulator_desc *regulator_desc,
5321 + !rdev->desc->fixed_uV)
5322 + rdev->is_switch = true;
5323 +
5324 ++ dev_set_drvdata(&rdev->dev, rdev);
5325 + ret = device_register(&rdev->dev);
5326 + if (ret != 0) {
5327 + put_device(&rdev->dev);
5328 + goto unset_supplies;
5329 + }
5330 +
5331 +- dev_set_drvdata(&rdev->dev, rdev);
5332 + rdev_init_debugfs(rdev);
5333 +
5334 + /* try to resolve regulators supply since a new one was registered */
5335 +diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
5336 +index 638f17d4c848..210fc20f7de7 100644
5337 +--- a/drivers/regulator/of_regulator.c
5338 ++++ b/drivers/regulator/of_regulator.c
5339 +@@ -213,8 +213,6 @@ static void of_get_regulation_constraints(struct device_node *np,
5340 + else if (of_property_read_bool(suspend_np,
5341 + "regulator-off-in-suspend"))
5342 + suspend_state->enabled = DISABLE_IN_SUSPEND;
5343 +- else
5344 +- suspend_state->enabled = DO_NOTHING_IN_SUSPEND;
5345 +
5346 + if (!of_property_read_u32(np, "regulator-suspend-min-microvolt",
5347 + &pval))
5348 +diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
5349 +index a9f60d0ee02e..7c732414367f 100644
5350 +--- a/drivers/s390/block/dasd.c
5351 ++++ b/drivers/s390/block/dasd.c
5352 +@@ -3127,6 +3127,7 @@ static int dasd_alloc_queue(struct dasd_block *block)
5353 + block->tag_set.nr_hw_queues = nr_hw_queues;
5354 + block->tag_set.queue_depth = queue_depth;
5355 + block->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
5356 ++ block->tag_set.numa_node = NUMA_NO_NODE;
5357 +
5358 + rc = blk_mq_alloc_tag_set(&block->tag_set);
5359 + if (rc)
5360 +diff --git a/drivers/s390/block/scm_blk.c b/drivers/s390/block/scm_blk.c
5361 +index b1fcb76dd272..98f66b7b6794 100644
5362 +--- a/drivers/s390/block/scm_blk.c
5363 ++++ b/drivers/s390/block/scm_blk.c
5364 +@@ -455,6 +455,7 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct scm_device *scmdev)
5365 + bdev->tag_set.nr_hw_queues = nr_requests;
5366 + bdev->tag_set.queue_depth = nr_requests_per_io * nr_requests;
5367 + bdev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
5368 ++ bdev->tag_set.numa_node = NUMA_NO_NODE;
5369 +
5370 + ret = blk_mq_alloc_tag_set(&bdev->tag_set);
5371 + if (ret)
5372 +diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
5373 +index 8f03a869ac98..e9e669a6c2bc 100644
5374 +--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
5375 ++++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
5376 +@@ -2727,6 +2727,8 @@ int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep)
5377 + BNX2X_DOORBELL_PCI_BAR);
5378 + reg_off = (1 << BNX2X_DB_SHIFT) * (cid_num & 0x1FFFF);
5379 + ep->qp.ctx_base = ioremap_nocache(reg_base + reg_off, 4);
5380 ++ if (!ep->qp.ctx_base)
5381 ++ return -ENOMEM;
5382 + goto arm_cq;
5383 + }
5384 +
5385 +diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
5386 +index 7052a5d45f7f..78e5a9254143 100644
5387 +--- a/drivers/scsi/hisi_sas/hisi_sas.h
5388 ++++ b/drivers/scsi/hisi_sas/hisi_sas.h
5389 +@@ -277,6 +277,7 @@ struct hisi_hba {
5390 +
5391 + int n_phy;
5392 + spinlock_t lock;
5393 ++ struct semaphore sem;
5394 +
5395 + struct timer_list timer;
5396 + struct workqueue_struct *wq;
5397 +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
5398 +index 6f562974f8f6..bfbd2fb7e69e 100644
5399 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
5400 ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
5401 +@@ -914,7 +914,9 @@ static void hisi_sas_dev_gone(struct domain_device *device)
5402 +
5403 + hisi_sas_dereg_device(hisi_hba, device);
5404 +
5405 ++ down(&hisi_hba->sem);
5406 + hisi_hba->hw->clear_itct(hisi_hba, sas_dev);
5407 ++ up(&hisi_hba->sem);
5408 + device->lldd_dev = NULL;
5409 + }
5410 +
5411 +@@ -1364,6 +1366,7 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba)
5412 + if (test_and_set_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags))
5413 + return -1;
5414 +
5415 ++ down(&hisi_hba->sem);
5416 + dev_info(dev, "controller resetting...\n");
5417 + old_state = hisi_hba->hw->get_phys_state(hisi_hba);
5418 +
5419 +@@ -1378,6 +1381,7 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba)
5420 + if (rc) {
5421 + dev_warn(dev, "controller reset failed (%d)\n", rc);
5422 + clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
5423 ++ up(&hisi_hba->sem);
5424 + scsi_unblock_requests(shost);
5425 + goto out;
5426 + }
5427 +@@ -1388,6 +1392,7 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba)
5428 + hisi_hba->hw->phys_init(hisi_hba);
5429 + msleep(1000);
5430 + hisi_sas_refresh_port_id(hisi_hba);
5431 ++ up(&hisi_hba->sem);
5432 +
5433 + if (hisi_hba->reject_stp_links_msk)
5434 + hisi_sas_terminate_stp_reject(hisi_hba);
5435 +@@ -2016,6 +2021,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
5436 + struct device *dev = hisi_hba->dev;
5437 + int i, s, max_command_entries = hisi_hba->hw->max_command_entries;
5438 +
5439 ++ sema_init(&hisi_hba->sem, 1);
5440 + spin_lock_init(&hisi_hba->lock);
5441 + for (i = 0; i < hisi_hba->n_phy; i++) {
5442 + hisi_sas_phy_init(hisi_hba, i);
5443 +diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
5444 +index 17df76f0be3c..67a2c844e30d 100644
5445 +--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
5446 ++++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
5447 +@@ -93,7 +93,7 @@ static int max_requests = IBMVSCSI_MAX_REQUESTS_DEFAULT;
5448 + static int max_events = IBMVSCSI_MAX_REQUESTS_DEFAULT + 2;
5449 + static int fast_fail = 1;
5450 + static int client_reserve = 1;
5451 +-static char partition_name[97] = "UNKNOWN";
5452 ++static char partition_name[96] = "UNKNOWN";
5453 + static unsigned int partition_number = -1;
5454 + static LIST_HEAD(ibmvscsi_head);
5455 +
5456 +@@ -262,7 +262,7 @@ static void gather_partition_info(void)
5457 +
5458 + ppartition_name = of_get_property(of_root, "ibm,partition-name", NULL);
5459 + if (ppartition_name)
5460 +- strncpy(partition_name, ppartition_name,
5461 ++ strlcpy(partition_name, ppartition_name,
5462 + sizeof(partition_name));
5463 + p_number_ptr = of_get_property(of_root, "ibm,partition-no", NULL);
5464 + if (p_number_ptr)
5465 +diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
5466 +index 71d97573a667..8e84e3fb648a 100644
5467 +--- a/drivers/scsi/megaraid/megaraid_sas_base.c
5468 ++++ b/drivers/scsi/megaraid/megaraid_sas_base.c
5469 +@@ -6789,6 +6789,9 @@ megasas_resume(struct pci_dev *pdev)
5470 + goto fail_init_mfi;
5471 + }
5472 +
5473 ++ if (megasas_get_ctrl_info(instance) != DCMD_SUCCESS)
5474 ++ goto fail_init_mfi;
5475 ++
5476 + tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet,
5477 + (unsigned long)instance);
5478 +
5479 +diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c
5480 +index 16590dfaafa4..cef307c0399c 100644
5481 +--- a/drivers/siox/siox-core.c
5482 ++++ b/drivers/siox/siox-core.c
5483 +@@ -715,17 +715,17 @@ int siox_master_register(struct siox_master *smaster)
5484 +
5485 + dev_set_name(&smaster->dev, "siox-%d", smaster->busno);
5486 +
5487 ++ mutex_init(&smaster->lock);
5488 ++ INIT_LIST_HEAD(&smaster->devices);
5489 ++
5490 + smaster->last_poll = jiffies;
5491 +- smaster->poll_thread = kthread_create(siox_poll_thread, smaster,
5492 +- "siox-%d", smaster->busno);
5493 ++ smaster->poll_thread = kthread_run(siox_poll_thread, smaster,
5494 ++ "siox-%d", smaster->busno);
5495 + if (IS_ERR(smaster->poll_thread)) {
5496 + smaster->active = 0;
5497 + return PTR_ERR(smaster->poll_thread);
5498 + }
5499 +
5500 +- mutex_init(&smaster->lock);
5501 +- INIT_LIST_HEAD(&smaster->devices);
5502 +-
5503 + ret = device_add(&smaster->dev);
5504 + if (ret)
5505 + kthread_stop(smaster->poll_thread);
5506 +diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
5507 +index d01a6adc726e..47ef6b1a2e76 100644
5508 +--- a/drivers/spi/spi-orion.c
5509 ++++ b/drivers/spi/spi-orion.c
5510 +@@ -20,6 +20,7 @@
5511 + #include <linux/of.h>
5512 + #include <linux/of_address.h>
5513 + #include <linux/of_device.h>
5514 ++#include <linux/of_gpio.h>
5515 + #include <linux/clk.h>
5516 + #include <linux/sizes.h>
5517 + #include <linux/gpio.h>
5518 +@@ -681,9 +682,9 @@ static int orion_spi_probe(struct platform_device *pdev)
5519 + goto out_rel_axi_clk;
5520 + }
5521 +
5522 +- /* Scan all SPI devices of this controller for direct mapped devices */
5523 + for_each_available_child_of_node(pdev->dev.of_node, np) {
5524 + u32 cs;
5525 ++ int cs_gpio;
5526 +
5527 + /* Get chip-select number from the "reg" property */
5528 + status = of_property_read_u32(np, "reg", &cs);
5529 +@@ -694,6 +695,44 @@ static int orion_spi_probe(struct platform_device *pdev)
5530 + continue;
5531 + }
5532 +
5533 ++ /*
5534 ++ * Initialize the CS GPIO:
5535 ++ * - properly request the actual GPIO signal
5536 ++ * - de-assert the logical signal so that all GPIO CS lines
5537 ++ * are inactive when probing for slaves
5538 ++ * - find an unused physical CS which will be driven for any
5539 ++ * slave which uses a CS GPIO
5540 ++ */
5541 ++ cs_gpio = of_get_named_gpio(pdev->dev.of_node, "cs-gpios", cs);
5542 ++ if (cs_gpio > 0) {
5543 ++ char *gpio_name;
5544 ++ int cs_flags;
5545 ++
5546 ++ if (spi->unused_hw_gpio == -1) {
5547 ++ dev_info(&pdev->dev,
5548 ++ "Selected unused HW CS#%d for any GPIO CSes\n",
5549 ++ cs);
5550 ++ spi->unused_hw_gpio = cs;
5551 ++ }
5552 ++
5553 ++ gpio_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
5554 ++ "%s-CS%d", dev_name(&pdev->dev), cs);
5555 ++ if (!gpio_name) {
5556 ++ status = -ENOMEM;
5557 ++ goto out_rel_axi_clk;
5558 ++ }
5559 ++
5560 ++ cs_flags = of_property_read_bool(np, "spi-cs-high") ?
5561 ++ GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH;
5562 ++ status = devm_gpio_request_one(&pdev->dev, cs_gpio,
5563 ++ cs_flags, gpio_name);
5564 ++ if (status) {
5565 ++ dev_err(&pdev->dev,
5566 ++ "Can't request GPIO for CS %d\n", cs);
5567 ++ goto out_rel_axi_clk;
5568 ++ }
5569 ++ }
5570 ++
5571 + /*
5572 + * Check if an address is configured for this SPI device. If
5573 + * not, the MBus mapping via the 'ranges' property in the 'soc'
5574 +@@ -740,44 +779,8 @@ static int orion_spi_probe(struct platform_device *pdev)
5575 + if (status < 0)
5576 + goto out_rel_pm;
5577 +
5578 +- if (master->cs_gpios) {
5579 +- int i;
5580 +- for (i = 0; i < master->num_chipselect; ++i) {
5581 +- char *gpio_name;
5582 +-
5583 +- if (!gpio_is_valid(master->cs_gpios[i])) {
5584 +- continue;
5585 +- }
5586 +-
5587 +- gpio_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
5588 +- "%s-CS%d", dev_name(&pdev->dev), i);
5589 +- if (!gpio_name) {
5590 +- status = -ENOMEM;
5591 +- goto out_rel_master;
5592 +- }
5593 +-
5594 +- status = devm_gpio_request(&pdev->dev,
5595 +- master->cs_gpios[i], gpio_name);
5596 +- if (status) {
5597 +- dev_err(&pdev->dev,
5598 +- "Can't request GPIO for CS %d\n",
5599 +- master->cs_gpios[i]);
5600 +- goto out_rel_master;
5601 +- }
5602 +- if (spi->unused_hw_gpio == -1) {
5603 +- dev_info(&pdev->dev,
5604 +- "Selected unused HW CS#%d for any GPIO CSes\n",
5605 +- i);
5606 +- spi->unused_hw_gpio = i;
5607 +- }
5608 +- }
5609 +- }
5610 +-
5611 +-
5612 + return status;
5613 +
5614 +-out_rel_master:
5615 +- spi_unregister_master(master);
5616 + out_rel_pm:
5617 + pm_runtime_disable(&pdev->dev);
5618 + out_rel_axi_clk:
5619 +diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
5620 +index 95dc4d78618d..b37de1d991d6 100644
5621 +--- a/drivers/spi/spi-rspi.c
5622 ++++ b/drivers/spi/spi-rspi.c
5623 +@@ -598,11 +598,13 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
5624 +
5625 + ret = wait_event_interruptible_timeout(rspi->wait,
5626 + rspi->dma_callbacked, HZ);
5627 +- if (ret > 0 && rspi->dma_callbacked)
5628 ++ if (ret > 0 && rspi->dma_callbacked) {
5629 + ret = 0;
5630 +- else if (!ret) {
5631 +- dev_err(&rspi->master->dev, "DMA timeout\n");
5632 +- ret = -ETIMEDOUT;
5633 ++ } else {
5634 ++ if (!ret) {
5635 ++ dev_err(&rspi->master->dev, "DMA timeout\n");
5636 ++ ret = -ETIMEDOUT;
5637 ++ }
5638 + if (tx)
5639 + dmaengine_terminate_all(rspi->master->dma_tx);
5640 + if (rx)
5641 +@@ -1350,12 +1352,36 @@ static const struct platform_device_id spi_driver_ids[] = {
5642 +
5643 + MODULE_DEVICE_TABLE(platform, spi_driver_ids);
5644 +
5645 ++#ifdef CONFIG_PM_SLEEP
5646 ++static int rspi_suspend(struct device *dev)
5647 ++{
5648 ++ struct platform_device *pdev = to_platform_device(dev);
5649 ++ struct rspi_data *rspi = platform_get_drvdata(pdev);
5650 ++
5651 ++ return spi_master_suspend(rspi->master);
5652 ++}
5653 ++
5654 ++static int rspi_resume(struct device *dev)
5655 ++{
5656 ++ struct platform_device *pdev = to_platform_device(dev);
5657 ++ struct rspi_data *rspi = platform_get_drvdata(pdev);
5658 ++
5659 ++ return spi_master_resume(rspi->master);
5660 ++}
5661 ++
5662 ++static SIMPLE_DEV_PM_OPS(rspi_pm_ops, rspi_suspend, rspi_resume);
5663 ++#define DEV_PM_OPS &rspi_pm_ops
5664 ++#else
5665 ++#define DEV_PM_OPS NULL
5666 ++#endif /* CONFIG_PM_SLEEP */
5667 ++
5668 + static struct platform_driver rspi_driver = {
5669 + .probe = rspi_probe,
5670 + .remove = rspi_remove,
5671 + .id_table = spi_driver_ids,
5672 + .driver = {
5673 + .name = "renesas_spi",
5674 ++ .pm = DEV_PM_OPS,
5675 + .of_match_table = of_match_ptr(rspi_of_match),
5676 + },
5677 + };
5678 +diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
5679 +index 0e74cbf9929d..37364c634fef 100644
5680 +--- a/drivers/spi/spi-sh-msiof.c
5681 ++++ b/drivers/spi/spi-sh-msiof.c
5682 +@@ -396,7 +396,8 @@ static void sh_msiof_spi_set_mode_regs(struct sh_msiof_spi_priv *p,
5683 +
5684 + static void sh_msiof_reset_str(struct sh_msiof_spi_priv *p)
5685 + {
5686 +- sh_msiof_write(p, STR, sh_msiof_read(p, STR));
5687 ++ sh_msiof_write(p, STR,
5688 ++ sh_msiof_read(p, STR) & ~(STR_TDREQ | STR_RDREQ));
5689 + }
5690 +
5691 + static void sh_msiof_spi_write_fifo_8(struct sh_msiof_spi_priv *p,
5692 +@@ -1421,12 +1422,37 @@ static const struct platform_device_id spi_driver_ids[] = {
5693 + };
5694 + MODULE_DEVICE_TABLE(platform, spi_driver_ids);
5695 +
5696 ++#ifdef CONFIG_PM_SLEEP
5697 ++static int sh_msiof_spi_suspend(struct device *dev)
5698 ++{
5699 ++ struct platform_device *pdev = to_platform_device(dev);
5700 ++ struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
5701 ++
5702 ++ return spi_master_suspend(p->master);
5703 ++}
5704 ++
5705 ++static int sh_msiof_spi_resume(struct device *dev)
5706 ++{
5707 ++ struct platform_device *pdev = to_platform_device(dev);
5708 ++ struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
5709 ++
5710 ++ return spi_master_resume(p->master);
5711 ++}
5712 ++
5713 ++static SIMPLE_DEV_PM_OPS(sh_msiof_spi_pm_ops, sh_msiof_spi_suspend,
5714 ++ sh_msiof_spi_resume);
5715 ++#define DEV_PM_OPS &sh_msiof_spi_pm_ops
5716 ++#else
5717 ++#define DEV_PM_OPS NULL
5718 ++#endif /* CONFIG_PM_SLEEP */
5719 ++
5720 + static struct platform_driver sh_msiof_spi_drv = {
5721 + .probe = sh_msiof_spi_probe,
5722 + .remove = sh_msiof_spi_remove,
5723 + .id_table = spi_driver_ids,
5724 + .driver = {
5725 + .name = "spi_sh_msiof",
5726 ++ .pm = DEV_PM_OPS,
5727 + .of_match_table = of_match_ptr(sh_msiof_match),
5728 + },
5729 + };
5730 +diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
5731 +index 6f7b946b5ced..1427f343b39a 100644
5732 +--- a/drivers/spi/spi-tegra20-slink.c
5733 ++++ b/drivers/spi/spi-tegra20-slink.c
5734 +@@ -1063,6 +1063,24 @@ static int tegra_slink_probe(struct platform_device *pdev)
5735 + goto exit_free_master;
5736 + }
5737 +
5738 ++ /* disabled clock may cause interrupt storm upon request */
5739 ++ tspi->clk = devm_clk_get(&pdev->dev, NULL);
5740 ++ if (IS_ERR(tspi->clk)) {
5741 ++ ret = PTR_ERR(tspi->clk);
5742 ++ dev_err(&pdev->dev, "Can not get clock %d\n", ret);
5743 ++ goto exit_free_master;
5744 ++ }
5745 ++ ret = clk_prepare(tspi->clk);
5746 ++ if (ret < 0) {
5747 ++ dev_err(&pdev->dev, "Clock prepare failed %d\n", ret);
5748 ++ goto exit_free_master;
5749 ++ }
5750 ++ ret = clk_enable(tspi->clk);
5751 ++ if (ret < 0) {
5752 ++ dev_err(&pdev->dev, "Clock enable failed %d\n", ret);
5753 ++ goto exit_free_master;
5754 ++ }
5755 ++
5756 + spi_irq = platform_get_irq(pdev, 0);
5757 + tspi->irq = spi_irq;
5758 + ret = request_threaded_irq(tspi->irq, tegra_slink_isr,
5759 +@@ -1071,14 +1089,7 @@ static int tegra_slink_probe(struct platform_device *pdev)
5760 + if (ret < 0) {
5761 + dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n",
5762 + tspi->irq);
5763 +- goto exit_free_master;
5764 +- }
5765 +-
5766 +- tspi->clk = devm_clk_get(&pdev->dev, NULL);
5767 +- if (IS_ERR(tspi->clk)) {
5768 +- dev_err(&pdev->dev, "can not get clock\n");
5769 +- ret = PTR_ERR(tspi->clk);
5770 +- goto exit_free_irq;
5771 ++ goto exit_clk_disable;
5772 + }
5773 +
5774 + tspi->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi");
5775 +@@ -1138,6 +1149,8 @@ exit_rx_dma_free:
5776 + tegra_slink_deinit_dma_param(tspi, true);
5777 + exit_free_irq:
5778 + free_irq(spi_irq, tspi);
5779 ++exit_clk_disable:
5780 ++ clk_disable(tspi->clk);
5781 + exit_free_master:
5782 + spi_master_put(master);
5783 + return ret;
5784 +@@ -1150,6 +1163,8 @@ static int tegra_slink_remove(struct platform_device *pdev)
5785 +
5786 + free_irq(tspi->irq, tspi);
5787 +
5788 ++ clk_disable(tspi->clk);
5789 ++
5790 + if (tspi->tx_dma_chan)
5791 + tegra_slink_deinit_dma_param(tspi, false);
5792 +
5793 +diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
5794 +index d5d33e12e952..716573c21579 100644
5795 +--- a/drivers/staging/android/ashmem.c
5796 ++++ b/drivers/staging/android/ashmem.c
5797 +@@ -366,6 +366,12 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
5798 + goto out;
5799 + }
5800 +
5801 ++ /* requested mapping size larger than object size */
5802 ++ if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) {
5803 ++ ret = -EINVAL;
5804 ++ goto out;
5805 ++ }
5806 ++
5807 + /* requested protection bits must match our allowed protection mask */
5808 + if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) &
5809 + calc_vm_prot_bits(PROT_MASK, 0))) {
5810 +diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c
5811 +index ae453fd422f0..ffeb017c73b2 100644
5812 +--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
5813 ++++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
5814 +@@ -210,6 +210,7 @@ static void prp_vb2_buf_done(struct prp_priv *priv, struct ipuv3_channel *ch)
5815 +
5816 + done = priv->active_vb2_buf[priv->ipu_buf_num];
5817 + if (done) {
5818 ++ done->vbuf.field = vdev->fmt.fmt.pix.field;
5819 + vb = &done->vbuf.vb2_buf;
5820 + vb->timestamp = ktime_get_ns();
5821 + vb2_buffer_done(vb, priv->nfb4eof ?
5822 +diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
5823 +index 95d7805f3485..0e963c24af37 100644
5824 +--- a/drivers/staging/media/imx/imx-media-csi.c
5825 ++++ b/drivers/staging/media/imx/imx-media-csi.c
5826 +@@ -236,6 +236,7 @@ static void csi_vb2_buf_done(struct csi_priv *priv)
5827 +
5828 + done = priv->active_vb2_buf[priv->ipu_buf_num];
5829 + if (done) {
5830 ++ done->vbuf.field = vdev->fmt.fmt.pix.field;
5831 + vb = &done->vbuf.vb2_buf;
5832 + vb->timestamp = ktime_get_ns();
5833 + vb2_buffer_done(vb, priv->nfb4eof ?
5834 +diff --git a/drivers/staging/mt7621-dts/gbpc1.dts b/drivers/staging/mt7621-dts/gbpc1.dts
5835 +index 6b13d85d9d34..87555600195f 100644
5836 +--- a/drivers/staging/mt7621-dts/gbpc1.dts
5837 ++++ b/drivers/staging/mt7621-dts/gbpc1.dts
5838 +@@ -113,6 +113,8 @@
5839 + };
5840 +
5841 + &pcie {
5842 ++ pinctrl-names = "default";
5843 ++ pinctrl-0 = <&pcie_pins>;
5844 + status = "okay";
5845 + };
5846 +
5847 +diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi
5848 +index eb3966b7f033..ce6b43639079 100644
5849 +--- a/drivers/staging/mt7621-dts/mt7621.dtsi
5850 ++++ b/drivers/staging/mt7621-dts/mt7621.dtsi
5851 +@@ -447,31 +447,28 @@
5852 + clocks = <&clkctrl 24 &clkctrl 25 &clkctrl 26>;
5853 + clock-names = "pcie0", "pcie1", "pcie2";
5854 +
5855 +- pcie0 {
5856 ++ pcie@0,0 {
5857 + reg = <0x0000 0 0 0 0>;
5858 +-
5859 + #address-cells = <3>;
5860 + #size-cells = <2>;
5861 +-
5862 +- device_type = "pci";
5863 ++ ranges;
5864 ++ bus-range = <0x00 0xff>;
5865 + };
5866 +
5867 +- pcie1 {
5868 ++ pcie@1,0 {
5869 + reg = <0x0800 0 0 0 0>;
5870 +-
5871 + #address-cells = <3>;
5872 + #size-cells = <2>;
5873 +-
5874 +- device_type = "pci";
5875 ++ ranges;
5876 ++ bus-range = <0x00 0xff>;
5877 + };
5878 +
5879 +- pcie2 {
5880 ++ pcie@2,0 {
5881 + reg = <0x1000 0 0 0 0>;
5882 +-
5883 + #address-cells = <3>;
5884 + #size-cells = <2>;
5885 +-
5886 +- device_type = "pci";
5887 ++ ranges;
5888 ++ bus-range = <0x00 0xff>;
5889 + };
5890 + };
5891 + };
5892 +diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.c b/drivers/staging/mt7621-eth/mtk_eth_soc.c
5893 +index 2c7a2e666bfb..381d9d270bf5 100644
5894 +--- a/drivers/staging/mt7621-eth/mtk_eth_soc.c
5895 ++++ b/drivers/staging/mt7621-eth/mtk_eth_soc.c
5896 +@@ -2012,8 +2012,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
5897 + mac->hw_stats = devm_kzalloc(eth->dev,
5898 + sizeof(*mac->hw_stats),
5899 + GFP_KERNEL);
5900 +- if (!mac->hw_stats)
5901 +- return -ENOMEM;
5902 ++ if (!mac->hw_stats) {
5903 ++ err = -ENOMEM;
5904 ++ goto free_netdev;
5905 ++ }
5906 + spin_lock_init(&mac->hw_stats->stats_lock);
5907 + mac->hw_stats->reg_offset = id * MTK_STAT_OFFSET;
5908 + }
5909 +@@ -2037,7 +2039,8 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
5910 + err = register_netdev(eth->netdev[id]);
5911 + if (err) {
5912 + dev_err(eth->dev, "error bringing up device\n");
5913 +- return err;
5914 ++ err = -ENOMEM;
5915 ++ goto free_netdev;
5916 + }
5917 + eth->netdev[id]->irq = eth->irq;
5918 + netif_info(eth, probe, eth->netdev[id],
5919 +@@ -2045,6 +2048,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
5920 + eth->netdev[id]->base_addr, eth->netdev[id]->irq);
5921 +
5922 + return 0;
5923 ++
5924 ++free_netdev:
5925 ++ free_netdev(eth->netdev[id]);
5926 ++ return err;
5927 + }
5928 +
5929 + static int mtk_probe(struct platform_device *pdev)
5930 +diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
5931 +index b061f77dda41..94e0bfcec991 100644
5932 +--- a/drivers/staging/pi433/pi433_if.c
5933 ++++ b/drivers/staging/pi433/pi433_if.c
5934 +@@ -880,6 +880,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5935 + int retval = 0;
5936 + struct pi433_instance *instance;
5937 + struct pi433_device *device;
5938 ++ struct pi433_tx_cfg tx_cfg;
5939 + void __user *argp = (void __user *)arg;
5940 +
5941 + /* Check type and command number */
5942 +@@ -902,9 +903,11 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5943 + return -EFAULT;
5944 + break;
5945 + case PI433_IOC_WR_TX_CFG:
5946 +- if (copy_from_user(&instance->tx_cfg, argp,
5947 +- sizeof(struct pi433_tx_cfg)))
5948 ++ if (copy_from_user(&tx_cfg, argp, sizeof(struct pi433_tx_cfg)))
5949 + return -EFAULT;
5950 ++ mutex_lock(&device->tx_fifo_lock);
5951 ++ memcpy(&instance->tx_cfg, &tx_cfg, sizeof(struct pi433_tx_cfg));
5952 ++ mutex_unlock(&device->tx_fifo_lock);
5953 + break;
5954 + case PI433_IOC_RD_RX_CFG:
5955 + if (copy_to_user(argp, &device->rx_cfg,
5956 +diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c
5957 +index d548bc695f9e..0421dd9277a8 100644
5958 +--- a/drivers/staging/rts5208/sd.c
5959 ++++ b/drivers/staging/rts5208/sd.c
5960 +@@ -4996,7 +4996,7 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
5961 + goto sd_execute_write_cmd_failed;
5962 + }
5963 +
5964 +- rtsx_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00);
5965 ++ retval = rtsx_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00);
5966 + if (retval != STATUS_SUCCESS) {
5967 + rtsx_trace(chip);
5968 + goto sd_execute_write_cmd_failed;
5969 +diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
5970 +index 4b34f71547c6..101d62105c93 100644
5971 +--- a/drivers/target/iscsi/iscsi_target_tpg.c
5972 ++++ b/drivers/target/iscsi/iscsi_target_tpg.c
5973 +@@ -636,8 +636,7 @@ int iscsit_ta_authentication(struct iscsi_portal_group *tpg, u32 authentication)
5974 + none = strstr(buf1, NONE);
5975 + if (none)
5976 + goto out;
5977 +- strncat(buf1, ",", strlen(","));
5978 +- strncat(buf1, NONE, strlen(NONE));
5979 ++ strlcat(buf1, "," NONE, sizeof(buf1));
5980 + if (iscsi_update_param_value(param, buf1) < 0)
5981 + return -EINVAL;
5982 + }
5983 +diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
5984 +index e27db4d45a9d..06c9886e556c 100644
5985 +--- a/drivers/target/target_core_device.c
5986 ++++ b/drivers/target/target_core_device.c
5987 +@@ -904,14 +904,20 @@ struct se_device *target_find_device(int id, bool do_depend)
5988 + EXPORT_SYMBOL(target_find_device);
5989 +
5990 + struct devices_idr_iter {
5991 ++ struct config_item *prev_item;
5992 + int (*fn)(struct se_device *dev, void *data);
5993 + void *data;
5994 + };
5995 +
5996 + static int target_devices_idr_iter(int id, void *p, void *data)
5997 ++ __must_hold(&device_mutex)
5998 + {
5999 + struct devices_idr_iter *iter = data;
6000 + struct se_device *dev = p;
6001 ++ int ret;
6002 ++
6003 ++ config_item_put(iter->prev_item);
6004 ++ iter->prev_item = NULL;
6005 +
6006 + /*
6007 + * We add the device early to the idr, so it can be used
6008 +@@ -922,7 +928,15 @@ static int target_devices_idr_iter(int id, void *p, void *data)
6009 + if (!(dev->dev_flags & DF_CONFIGURED))
6010 + return 0;
6011 +
6012 +- return iter->fn(dev, iter->data);
6013 ++ iter->prev_item = config_item_get_unless_zero(&dev->dev_group.cg_item);
6014 ++ if (!iter->prev_item)
6015 ++ return 0;
6016 ++ mutex_unlock(&device_mutex);
6017 ++
6018 ++ ret = iter->fn(dev, iter->data);
6019 ++
6020 ++ mutex_lock(&device_mutex);
6021 ++ return ret;
6022 + }
6023 +
6024 + /**
6025 +@@ -936,15 +950,13 @@ static int target_devices_idr_iter(int id, void *p, void *data)
6026 + int target_for_each_device(int (*fn)(struct se_device *dev, void *data),
6027 + void *data)
6028 + {
6029 +- struct devices_idr_iter iter;
6030 ++ struct devices_idr_iter iter = { .fn = fn, .data = data };
6031 + int ret;
6032 +
6033 +- iter.fn = fn;
6034 +- iter.data = data;
6035 +-
6036 + mutex_lock(&device_mutex);
6037 + ret = idr_for_each(&devices_idr, target_devices_idr_iter, &iter);
6038 + mutex_unlock(&device_mutex);
6039 ++ config_item_put(iter.prev_item);
6040 + return ret;
6041 + }
6042 +
6043 +diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
6044 +index 334d98be03b9..b1f82d64253e 100644
6045 +--- a/drivers/thermal/imx_thermal.c
6046 ++++ b/drivers/thermal/imx_thermal.c
6047 +@@ -604,7 +604,10 @@ static int imx_init_from_nvmem_cells(struct platform_device *pdev)
6048 + ret = nvmem_cell_read_u32(&pdev->dev, "calib", &val);
6049 + if (ret)
6050 + return ret;
6051 +- imx_init_calib(pdev, val);
6052 ++
6053 ++ ret = imx_init_calib(pdev, val);
6054 ++ if (ret)
6055 ++ return ret;
6056 +
6057 + ret = nvmem_cell_read_u32(&pdev->dev, "temp_grade", &val);
6058 + if (ret)
6059 +diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
6060 +index 977a8307fbb1..4f2816559205 100644
6061 +--- a/drivers/thermal/of-thermal.c
6062 ++++ b/drivers/thermal/of-thermal.c
6063 +@@ -260,10 +260,13 @@ static int of_thermal_set_mode(struct thermal_zone_device *tz,
6064 +
6065 + mutex_lock(&tz->lock);
6066 +
6067 +- if (mode == THERMAL_DEVICE_ENABLED)
6068 ++ if (mode == THERMAL_DEVICE_ENABLED) {
6069 + tz->polling_delay = data->polling_delay;
6070 +- else
6071 ++ tz->passive_delay = data->passive_delay;
6072 ++ } else {
6073 + tz->polling_delay = 0;
6074 ++ tz->passive_delay = 0;
6075 ++ }
6076 +
6077 + mutex_unlock(&tz->lock);
6078 +
6079 +diff --git a/drivers/tty/serial/8250/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c
6080 +index 9963a766dcfb..c8186a05a453 100644
6081 +--- a/drivers/tty/serial/8250/serial_cs.c
6082 ++++ b/drivers/tty/serial/8250/serial_cs.c
6083 +@@ -638,8 +638,10 @@ static int serial_config(struct pcmcia_device *link)
6084 + (link->has_func_id) &&
6085 + (link->socket->pcmcia_pfc == 0) &&
6086 + ((link->func_id == CISTPL_FUNCID_MULTI) ||
6087 +- (link->func_id == CISTPL_FUNCID_SERIAL)))
6088 +- pcmcia_loop_config(link, serial_check_for_multi, info);
6089 ++ (link->func_id == CISTPL_FUNCID_SERIAL))) {
6090 ++ if (pcmcia_loop_config(link, serial_check_for_multi, info))
6091 ++ goto failed;
6092 ++ }
6093 +
6094 + /*
6095 + * Apply any multi-port quirk.
6096 +diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
6097 +index 24a5f05e769b..e5389591bb4f 100644
6098 +--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
6099 ++++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
6100 +@@ -1054,8 +1054,8 @@ static int poll_wait_key(char *obuf, struct uart_cpm_port *pinfo)
6101 + /* Get the address of the host memory buffer.
6102 + */
6103 + bdp = pinfo->rx_cur;
6104 +- while (bdp->cbd_sc & BD_SC_EMPTY)
6105 +- ;
6106 ++ if (bdp->cbd_sc & BD_SC_EMPTY)
6107 ++ return NO_POLL_CHAR;
6108 +
6109 + /* If the buffer address is in the CPM DPRAM, don't
6110 + * convert it.
6111 +@@ -1090,7 +1090,11 @@ static int cpm_get_poll_char(struct uart_port *port)
6112 + poll_chars = 0;
6113 + }
6114 + if (poll_chars <= 0) {
6115 +- poll_chars = poll_wait_key(poll_buf, pinfo);
6116 ++ int ret = poll_wait_key(poll_buf, pinfo);
6117 ++
6118 ++ if (ret == NO_POLL_CHAR)
6119 ++ return ret;
6120 ++ poll_chars = ret;
6121 + pollp = poll_buf;
6122 + }
6123 + poll_chars--;
6124 +diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
6125 +index 51e47a63d61a..3f8d1274fc85 100644
6126 +--- a/drivers/tty/serial/fsl_lpuart.c
6127 ++++ b/drivers/tty/serial/fsl_lpuart.c
6128 +@@ -979,7 +979,8 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport)
6129 + struct circ_buf *ring = &sport->rx_ring;
6130 + int ret, nent;
6131 + int bits, baud;
6132 +- struct tty_struct *tty = tty_port_tty_get(&sport->port.state->port);
6133 ++ struct tty_port *port = &sport->port.state->port;
6134 ++ struct tty_struct *tty = port->tty;
6135 + struct ktermios *termios = &tty->termios;
6136 +
6137 + baud = tty_get_baud_rate(tty);
6138 +diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
6139 +index 4e853570ea80..554a69db1bca 100644
6140 +--- a/drivers/tty/serial/imx.c
6141 ++++ b/drivers/tty/serial/imx.c
6142 +@@ -2350,6 +2350,14 @@ static int imx_uart_probe(struct platform_device *pdev)
6143 + ret);
6144 + return ret;
6145 + }
6146 ++
6147 ++ ret = devm_request_irq(&pdev->dev, rtsirq, imx_uart_rtsint, 0,
6148 ++ dev_name(&pdev->dev), sport);
6149 ++ if (ret) {
6150 ++ dev_err(&pdev->dev, "failed to request rts irq: %d\n",
6151 ++ ret);
6152 ++ return ret;
6153 ++ }
6154 + } else {
6155 + ret = devm_request_irq(&pdev->dev, rxirq, imx_uart_int, 0,
6156 + dev_name(&pdev->dev), sport);
6157 +diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
6158 +index d04b5eeea3c6..170e446a2f62 100644
6159 +--- a/drivers/tty/serial/mvebu-uart.c
6160 ++++ b/drivers/tty/serial/mvebu-uart.c
6161 +@@ -511,6 +511,7 @@ static void mvebu_uart_set_termios(struct uart_port *port,
6162 + termios->c_iflag |= old->c_iflag & ~(INPCK | IGNPAR);
6163 + termios->c_cflag &= CREAD | CBAUD;
6164 + termios->c_cflag |= old->c_cflag & ~(CREAD | CBAUD);
6165 ++ termios->c_cflag |= CS8;
6166 + }
6167 +
6168 + spin_unlock_irqrestore(&port->lock, flags);
6169 +diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
6170 +index eda3c7710d6a..4932b674f7ef 100644
6171 +--- a/drivers/tty/serial/pxa.c
6172 ++++ b/drivers/tty/serial/pxa.c
6173 +@@ -887,7 +887,8 @@ static int serial_pxa_probe(struct platform_device *dev)
6174 + goto err_clk;
6175 + if (sport->port.line >= ARRAY_SIZE(serial_pxa_ports)) {
6176 + dev_err(&dev->dev, "serial%d out of range\n", sport->port.line);
6177 +- return -EINVAL;
6178 ++ ret = -EINVAL;
6179 ++ goto err_clk;
6180 + }
6181 + snprintf(sport->name, PXA_NAME_LEN - 1, "UART%d", sport->port.line + 1);
6182 +
6183 +diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
6184 +index c181eb37f985..3c55600a8236 100644
6185 +--- a/drivers/tty/serial/sh-sci.c
6186 ++++ b/drivers/tty/serial/sh-sci.c
6187 +@@ -2099,6 +2099,8 @@ static void sci_shutdown(struct uart_port *port)
6188 + }
6189 + #endif
6190 +
6191 ++ if (s->rx_trigger > 1 && s->rx_fifo_timeout > 0)
6192 ++ del_timer_sync(&s->rx_fifo_timer);
6193 + sci_free_irq(s);
6194 + sci_free_dma(port);
6195 + }
6196 +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
6197 +index 632a2bfabc08..a0d284ef3f40 100644
6198 +--- a/drivers/usb/class/cdc-wdm.c
6199 ++++ b/drivers/usb/class/cdc-wdm.c
6200 +@@ -458,7 +458,7 @@ static int service_outstanding_interrupt(struct wdm_device *desc)
6201 +
6202 + set_bit(WDM_RESPONDING, &desc->flags);
6203 + spin_unlock_irq(&desc->iuspin);
6204 +- rv = usb_submit_urb(desc->response, GFP_ATOMIC);
6205 ++ rv = usb_submit_urb(desc->response, GFP_KERNEL);
6206 + spin_lock_irq(&desc->iuspin);
6207 + if (rv) {
6208 + dev_err(&desc->intf->dev,
6209 +diff --git a/drivers/usb/common/roles.c b/drivers/usb/common/roles.c
6210 +index 15cc76e22123..99116af07f1d 100644
6211 +--- a/drivers/usb/common/roles.c
6212 ++++ b/drivers/usb/common/roles.c
6213 +@@ -109,8 +109,15 @@ static void *usb_role_switch_match(struct device_connection *con, int ep,
6214 + */
6215 + struct usb_role_switch *usb_role_switch_get(struct device *dev)
6216 + {
6217 +- return device_connection_find_match(dev, "usb-role-switch", NULL,
6218 +- usb_role_switch_match);
6219 ++ struct usb_role_switch *sw;
6220 ++
6221 ++ sw = device_connection_find_match(dev, "usb-role-switch", NULL,
6222 ++ usb_role_switch_match);
6223 ++
6224 ++ if (!IS_ERR_OR_NULL(sw))
6225 ++ WARN_ON(!try_module_get(sw->dev.parent->driver->owner));
6226 ++
6227 ++ return sw;
6228 + }
6229 + EXPORT_SYMBOL_GPL(usb_role_switch_get);
6230 +
6231 +@@ -122,8 +129,10 @@ EXPORT_SYMBOL_GPL(usb_role_switch_get);
6232 + */
6233 + void usb_role_switch_put(struct usb_role_switch *sw)
6234 + {
6235 +- if (!IS_ERR_OR_NULL(sw))
6236 ++ if (!IS_ERR_OR_NULL(sw)) {
6237 + put_device(&sw->dev);
6238 ++ module_put(sw->dev.parent->driver->owner);
6239 ++ }
6240 + }
6241 + EXPORT_SYMBOL_GPL(usb_role_switch_put);
6242 +
6243 +diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
6244 +index 476dcc5f2da3..e1e0c90ce569 100644
6245 +--- a/drivers/usb/core/devio.c
6246 ++++ b/drivers/usb/core/devio.c
6247 +@@ -1433,10 +1433,13 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
6248 + struct async *as = NULL;
6249 + struct usb_ctrlrequest *dr = NULL;
6250 + unsigned int u, totlen, isofrmlen;
6251 +- int i, ret, is_in, num_sgs = 0, ifnum = -1;
6252 ++ int i, ret, num_sgs = 0, ifnum = -1;
6253 + int number_of_packets = 0;
6254 + unsigned int stream_id = 0;
6255 + void *buf;
6256 ++ bool is_in;
6257 ++ bool allow_short = false;
6258 ++ bool allow_zero = false;
6259 + unsigned long mask = USBDEVFS_URB_SHORT_NOT_OK |
6260 + USBDEVFS_URB_BULK_CONTINUATION |
6261 + USBDEVFS_URB_NO_FSBR |
6262 +@@ -1470,6 +1473,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
6263 + u = 0;
6264 + switch (uurb->type) {
6265 + case USBDEVFS_URB_TYPE_CONTROL:
6266 ++ if (is_in)
6267 ++ allow_short = true;
6268 + if (!usb_endpoint_xfer_control(&ep->desc))
6269 + return -EINVAL;
6270 + /* min 8 byte setup packet */
6271 +@@ -1510,6 +1515,10 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
6272 + break;
6273 +
6274 + case USBDEVFS_URB_TYPE_BULK:
6275 ++ if (!is_in)
6276 ++ allow_zero = true;
6277 ++ else
6278 ++ allow_short = true;
6279 + switch (usb_endpoint_type(&ep->desc)) {
6280 + case USB_ENDPOINT_XFER_CONTROL:
6281 + case USB_ENDPOINT_XFER_ISOC:
6282 +@@ -1530,6 +1539,10 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
6283 + if (!usb_endpoint_xfer_int(&ep->desc))
6284 + return -EINVAL;
6285 + interrupt_urb:
6286 ++ if (!is_in)
6287 ++ allow_zero = true;
6288 ++ else
6289 ++ allow_short = true;
6290 + break;
6291 +
6292 + case USBDEVFS_URB_TYPE_ISO:
6293 +@@ -1675,14 +1688,19 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
6294 + u = (is_in ? URB_DIR_IN : URB_DIR_OUT);
6295 + if (uurb->flags & USBDEVFS_URB_ISO_ASAP)
6296 + u |= URB_ISO_ASAP;
6297 +- if (uurb->flags & USBDEVFS_URB_SHORT_NOT_OK && is_in)
6298 ++ if (allow_short && uurb->flags & USBDEVFS_URB_SHORT_NOT_OK)
6299 + u |= URB_SHORT_NOT_OK;
6300 +- if (uurb->flags & USBDEVFS_URB_ZERO_PACKET)
6301 ++ if (allow_zero && uurb->flags & USBDEVFS_URB_ZERO_PACKET)
6302 + u |= URB_ZERO_PACKET;
6303 + if (uurb->flags & USBDEVFS_URB_NO_INTERRUPT)
6304 + u |= URB_NO_INTERRUPT;
6305 + as->urb->transfer_flags = u;
6306 +
6307 ++ if (!allow_short && uurb->flags & USBDEVFS_URB_SHORT_NOT_OK)
6308 ++ dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_SHORT_NOT_OK.\n");
6309 ++ if (!allow_zero && uurb->flags & USBDEVFS_URB_ZERO_PACKET)
6310 ++ dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_ZERO_PACKET.\n");
6311 ++
6312 + as->urb->transfer_buffer_length = uurb->buffer_length;
6313 + as->urb->setup_packet = (unsigned char *)dr;
6314 + dr = NULL;
6315 +diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
6316 +index e76e95f62f76..a1f225f077cd 100644
6317 +--- a/drivers/usb/core/driver.c
6318 ++++ b/drivers/usb/core/driver.c
6319 +@@ -512,7 +512,6 @@ int usb_driver_claim_interface(struct usb_driver *driver,
6320 + struct device *dev;
6321 + struct usb_device *udev;
6322 + int retval = 0;
6323 +- int lpm_disable_error = -ENODEV;
6324 +
6325 + if (!iface)
6326 + return -ENODEV;
6327 +@@ -533,16 +532,6 @@ int usb_driver_claim_interface(struct usb_driver *driver,
6328 +
6329 + iface->condition = USB_INTERFACE_BOUND;
6330 +
6331 +- /* See the comment about disabling LPM in usb_probe_interface(). */
6332 +- if (driver->disable_hub_initiated_lpm) {
6333 +- lpm_disable_error = usb_unlocked_disable_lpm(udev);
6334 +- if (lpm_disable_error) {
6335 +- dev_err(&iface->dev, "%s Failed to disable LPM for driver %s\n",
6336 +- __func__, driver->name);
6337 +- return -ENOMEM;
6338 +- }
6339 +- }
6340 +-
6341 + /* Claimed interfaces are initially inactive (suspended) and
6342 + * runtime-PM-enabled, but only if the driver has autosuspend
6343 + * support. Otherwise they are marked active, to prevent the
6344 +@@ -561,9 +550,20 @@ int usb_driver_claim_interface(struct usb_driver *driver,
6345 + if (device_is_registered(dev))
6346 + retval = device_bind_driver(dev);
6347 +
6348 +- /* Attempt to re-enable USB3 LPM, if the disable was successful. */
6349 +- if (!lpm_disable_error)
6350 +- usb_unlocked_enable_lpm(udev);
6351 ++ if (retval) {
6352 ++ dev->driver = NULL;
6353 ++ usb_set_intfdata(iface, NULL);
6354 ++ iface->needs_remote_wakeup = 0;
6355 ++ iface->condition = USB_INTERFACE_UNBOUND;
6356 ++
6357 ++ /*
6358 ++ * Unbound interfaces are always runtime-PM-disabled
6359 ++ * and runtime-PM-suspended
6360 ++ */
6361 ++ if (driver->supports_autosuspend)
6362 ++ pm_runtime_disable(dev);
6363 ++ pm_runtime_set_suspended(dev);
6364 ++ }
6365 +
6366 + return retval;
6367 + }
6368 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
6369 +index e77dfe5ed5ec..178d6c6063c0 100644
6370 +--- a/drivers/usb/core/quirks.c
6371 ++++ b/drivers/usb/core/quirks.c
6372 +@@ -58,6 +58,7 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
6373 + quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
6374 + GFP_KERNEL);
6375 + if (!quirk_list) {
6376 ++ quirk_count = 0;
6377 + mutex_unlock(&quirk_mutex);
6378 + return -ENOMEM;
6379 + }
6380 +@@ -154,7 +155,7 @@ static struct kparam_string quirks_param_string = {
6381 + .string = quirks_param,
6382 + };
6383 +
6384 +-module_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644);
6385 ++device_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644);
6386 + MODULE_PARM_DESC(quirks, "Add/modify USB quirks by specifying quirks=vendorID:productID:quirks");
6387 +
6388 + /* Lists of quirky USB devices, split in device quirks and interface quirks.
6389 +diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
6390 +index 623be3174fb3..79d8bd7a612e 100644
6391 +--- a/drivers/usb/core/usb.c
6392 ++++ b/drivers/usb/core/usb.c
6393 +@@ -228,6 +228,8 @@ struct usb_host_interface *usb_find_alt_setting(
6394 + struct usb_interface_cache *intf_cache = NULL;
6395 + int i;
6396 +
6397 ++ if (!config)
6398 ++ return NULL;
6399 + for (i = 0; i < config->desc.bNumInterfaces; i++) {
6400 + if (config->intf_cache[i]->altsetting[0].desc.bInterfaceNumber
6401 + == iface_num) {
6402 +diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
6403 +index fb871eabcc10..a129d601a0c3 100644
6404 +--- a/drivers/usb/musb/musb_dsps.c
6405 ++++ b/drivers/usb/musb/musb_dsps.c
6406 +@@ -658,16 +658,6 @@ dsps_dma_controller_create(struct musb *musb, void __iomem *base)
6407 + return controller;
6408 + }
6409 +
6410 +-static void dsps_dma_controller_destroy(struct dma_controller *c)
6411 +-{
6412 +- struct musb *musb = c->musb;
6413 +- struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent);
6414 +- void __iomem *usbss_base = glue->usbss_base;
6415 +-
6416 +- musb_writel(usbss_base, USBSS_IRQ_CLEARR, USBSS_IRQ_PD_COMP);
6417 +- cppi41_dma_controller_destroy(c);
6418 +-}
6419 +-
6420 + #ifdef CONFIG_PM_SLEEP
6421 + static void dsps_dma_controller_suspend(struct dsps_glue *glue)
6422 + {
6423 +@@ -697,7 +687,7 @@ static struct musb_platform_ops dsps_ops = {
6424 +
6425 + #ifdef CONFIG_USB_TI_CPPI41_DMA
6426 + .dma_init = dsps_dma_controller_create,
6427 +- .dma_exit = dsps_dma_controller_destroy,
6428 ++ .dma_exit = cppi41_dma_controller_destroy,
6429 + #endif
6430 + .enable = dsps_musb_enable,
6431 + .disable = dsps_musb_disable,
6432 +diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
6433 +index a31ea7e194dd..a6ebed1e0f20 100644
6434 +--- a/drivers/usb/serial/kobil_sct.c
6435 ++++ b/drivers/usb/serial/kobil_sct.c
6436 +@@ -393,12 +393,20 @@ static int kobil_tiocmget(struct tty_struct *tty)
6437 + transfer_buffer_length,
6438 + KOBIL_TIMEOUT);
6439 +
6440 +- dev_dbg(&port->dev, "%s - Send get_status_line_state URB returns: %i. Statusline: %02x\n",
6441 +- __func__, result, transfer_buffer[0]);
6442 ++ dev_dbg(&port->dev, "Send get_status_line_state URB returns: %i\n",
6443 ++ result);
6444 ++ if (result < 1) {
6445 ++ if (result >= 0)
6446 ++ result = -EIO;
6447 ++ goto out_free;
6448 ++ }
6449 ++
6450 ++ dev_dbg(&port->dev, "Statusline: %02x\n", transfer_buffer[0]);
6451 +
6452 + result = 0;
6453 + if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0)
6454 + result = TIOCM_DSR;
6455 ++out_free:
6456 + kfree(transfer_buffer);
6457 + return result;
6458 + }
6459 +diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c
6460 +index 33d2f5d7f33b..14ac8c98ac9e 100644
6461 +--- a/drivers/usb/wusbcore/security.c
6462 ++++ b/drivers/usb/wusbcore/security.c
6463 +@@ -217,7 +217,7 @@ int wusb_dev_sec_add(struct wusbhc *wusbhc,
6464 +
6465 + result = usb_get_descriptor(usb_dev, USB_DT_SECURITY,
6466 + 0, secd, sizeof(*secd));
6467 +- if (result < sizeof(*secd)) {
6468 ++ if (result < (int)sizeof(*secd)) {
6469 + dev_err(dev, "Can't read security descriptor or "
6470 + "not enough data: %d\n", result);
6471 + goto out;
6472 +diff --git a/drivers/uwb/hwa-rc.c b/drivers/uwb/hwa-rc.c
6473 +index 9a53912bdfe9..5d3ba747ae17 100644
6474 +--- a/drivers/uwb/hwa-rc.c
6475 ++++ b/drivers/uwb/hwa-rc.c
6476 +@@ -873,6 +873,7 @@ error_get_version:
6477 + error_rc_add:
6478 + usb_put_intf(iface);
6479 + usb_put_dev(hwarc->usb_dev);
6480 ++ kfree(hwarc);
6481 + error_alloc:
6482 + uwb_rc_put(uwb_rc);
6483 + error_rc_alloc:
6484 +diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
6485 +index 29756d88799b..6b86ca8772fb 100644
6486 +--- a/drivers/vhost/net.c
6487 ++++ b/drivers/vhost/net.c
6488 +@@ -396,13 +396,10 @@ static inline unsigned long busy_clock(void)
6489 + return local_clock() >> 10;
6490 + }
6491 +
6492 +-static bool vhost_can_busy_poll(struct vhost_dev *dev,
6493 +- unsigned long endtime)
6494 ++static bool vhost_can_busy_poll(unsigned long endtime)
6495 + {
6496 +- return likely(!need_resched()) &&
6497 +- likely(!time_after(busy_clock(), endtime)) &&
6498 +- likely(!signal_pending(current)) &&
6499 +- !vhost_has_work(dev);
6500 ++ return likely(!need_resched() && !time_after(busy_clock(), endtime) &&
6501 ++ !signal_pending(current));
6502 + }
6503 +
6504 + static void vhost_net_disable_vq(struct vhost_net *n,
6505 +@@ -434,7 +431,8 @@ static int vhost_net_enable_vq(struct vhost_net *n,
6506 + static int vhost_net_tx_get_vq_desc(struct vhost_net *net,
6507 + struct vhost_virtqueue *vq,
6508 + struct iovec iov[], unsigned int iov_size,
6509 +- unsigned int *out_num, unsigned int *in_num)
6510 ++ unsigned int *out_num, unsigned int *in_num,
6511 ++ bool *busyloop_intr)
6512 + {
6513 + unsigned long uninitialized_var(endtime);
6514 + int r = vhost_get_vq_desc(vq, vq->iov, ARRAY_SIZE(vq->iov),
6515 +@@ -443,9 +441,15 @@ static int vhost_net_tx_get_vq_desc(struct vhost_net *net,
6516 + if (r == vq->num && vq->busyloop_timeout) {
6517 + preempt_disable();
6518 + endtime = busy_clock() + vq->busyloop_timeout;
6519 +- while (vhost_can_busy_poll(vq->dev, endtime) &&
6520 +- vhost_vq_avail_empty(vq->dev, vq))
6521 ++ while (vhost_can_busy_poll(endtime)) {
6522 ++ if (vhost_has_work(vq->dev)) {
6523 ++ *busyloop_intr = true;
6524 ++ break;
6525 ++ }
6526 ++ if (!vhost_vq_avail_empty(vq->dev, vq))
6527 ++ break;
6528 + cpu_relax();
6529 ++ }
6530 + preempt_enable();
6531 + r = vhost_get_vq_desc(vq, vq->iov, ARRAY_SIZE(vq->iov),
6532 + out_num, in_num, NULL, NULL);
6533 +@@ -501,20 +505,24 @@ static void handle_tx(struct vhost_net *net)
6534 + zcopy = nvq->ubufs;
6535 +
6536 + for (;;) {
6537 ++ bool busyloop_intr;
6538 ++
6539 + /* Release DMAs done buffers first */
6540 + if (zcopy)
6541 + vhost_zerocopy_signal_used(net, vq);
6542 +
6543 +-
6544 ++ busyloop_intr = false;
6545 + head = vhost_net_tx_get_vq_desc(net, vq, vq->iov,
6546 + ARRAY_SIZE(vq->iov),
6547 +- &out, &in);
6548 ++ &out, &in, &busyloop_intr);
6549 + /* On error, stop handling until the next kick. */
6550 + if (unlikely(head < 0))
6551 + break;
6552 + /* Nothing new? Wait for eventfd to tell us they refilled. */
6553 + if (head == vq->num) {
6554 +- if (unlikely(vhost_enable_notify(&net->dev, vq))) {
6555 ++ if (unlikely(busyloop_intr)) {
6556 ++ vhost_poll_queue(&vq->poll);
6557 ++ } else if (unlikely(vhost_enable_notify(&net->dev, vq))) {
6558 + vhost_disable_notify(&net->dev, vq);
6559 + continue;
6560 + }
6561 +@@ -663,7 +671,8 @@ static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk)
6562 + preempt_disable();
6563 + endtime = busy_clock() + vq->busyloop_timeout;
6564 +
6565 +- while (vhost_can_busy_poll(&net->dev, endtime) &&
6566 ++ while (vhost_can_busy_poll(endtime) &&
6567 ++ !vhost_has_work(&net->dev) &&
6568 + !sk_has_rx_data(sk) &&
6569 + vhost_vq_avail_empty(&net->dev, vq))
6570 + cpu_relax();
6571 +diff --git a/fs/dax.c b/fs/dax.c
6572 +index 641192808bb6..94f9fe002b12 100644
6573 +--- a/fs/dax.c
6574 ++++ b/fs/dax.c
6575 +@@ -1007,21 +1007,12 @@ static vm_fault_t dax_load_hole(struct address_space *mapping, void *entry,
6576 + {
6577 + struct inode *inode = mapping->host;
6578 + unsigned long vaddr = vmf->address;
6579 +- vm_fault_t ret = VM_FAULT_NOPAGE;
6580 +- struct page *zero_page;
6581 +- pfn_t pfn;
6582 +-
6583 +- zero_page = ZERO_PAGE(0);
6584 +- if (unlikely(!zero_page)) {
6585 +- ret = VM_FAULT_OOM;
6586 +- goto out;
6587 +- }
6588 ++ pfn_t pfn = pfn_to_pfn_t(my_zero_pfn(vaddr));
6589 ++ vm_fault_t ret;
6590 +
6591 +- pfn = page_to_pfn_t(zero_page);
6592 + dax_insert_mapping_entry(mapping, vmf, entry, pfn, RADIX_DAX_ZERO_PAGE,
6593 + false);
6594 + ret = vmf_insert_mixed(vmf->vma, vaddr, pfn);
6595 +-out:
6596 + trace_dax_load_hole(inode, vmf, ret);
6597 + return ret;
6598 + }
6599 +diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
6600 +index 71635909df3b..b4e0501bcba1 100644
6601 +--- a/fs/ext2/inode.c
6602 ++++ b/fs/ext2/inode.c
6603 +@@ -1448,6 +1448,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
6604 + }
6605 + inode->i_blocks = le32_to_cpu(raw_inode->i_blocks);
6606 + ei->i_flags = le32_to_cpu(raw_inode->i_flags);
6607 ++ ext2_set_inode_flags(inode);
6608 + ei->i_faddr = le32_to_cpu(raw_inode->i_faddr);
6609 + ei->i_frag_no = raw_inode->i_frag;
6610 + ei->i_frag_size = raw_inode->i_fsize;
6611 +@@ -1517,7 +1518,6 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
6612 + new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));
6613 + }
6614 + brelse (bh);
6615 +- ext2_set_inode_flags(inode);
6616 + unlock_new_inode(inode);
6617 + return inode;
6618 +
6619 +diff --git a/fs/iomap.c b/fs/iomap.c
6620 +index 0d0bd8845586..af6144fd4919 100644
6621 +--- a/fs/iomap.c
6622 ++++ b/fs/iomap.c
6623 +@@ -811,6 +811,7 @@ struct iomap_dio {
6624 + atomic_t ref;
6625 + unsigned flags;
6626 + int error;
6627 ++ bool wait_for_completion;
6628 +
6629 + union {
6630 + /* used during submission and for synchronous completion: */
6631 +@@ -914,9 +915,8 @@ static void iomap_dio_bio_end_io(struct bio *bio)
6632 + iomap_dio_set_error(dio, blk_status_to_errno(bio->bi_status));
6633 +
6634 + if (atomic_dec_and_test(&dio->ref)) {
6635 +- if (is_sync_kiocb(dio->iocb)) {
6636 ++ if (dio->wait_for_completion) {
6637 + struct task_struct *waiter = dio->submit.waiter;
6638 +-
6639 + WRITE_ONCE(dio->submit.waiter, NULL);
6640 + wake_up_process(waiter);
6641 + } else if (dio->flags & IOMAP_DIO_WRITE) {
6642 +@@ -1131,13 +1131,12 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
6643 + dio->end_io = end_io;
6644 + dio->error = 0;
6645 + dio->flags = 0;
6646 ++ dio->wait_for_completion = is_sync_kiocb(iocb);
6647 +
6648 + dio->submit.iter = iter;
6649 +- if (is_sync_kiocb(iocb)) {
6650 +- dio->submit.waiter = current;
6651 +- dio->submit.cookie = BLK_QC_T_NONE;
6652 +- dio->submit.last_queue = NULL;
6653 +- }
6654 ++ dio->submit.waiter = current;
6655 ++ dio->submit.cookie = BLK_QC_T_NONE;
6656 ++ dio->submit.last_queue = NULL;
6657 +
6658 + if (iov_iter_rw(iter) == READ) {
6659 + if (pos >= dio->i_size)
6660 +@@ -1187,7 +1186,7 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
6661 + dio_warn_stale_pagecache(iocb->ki_filp);
6662 + ret = 0;
6663 +
6664 +- if (iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) &&
6665 ++ if (iov_iter_rw(iter) == WRITE && !dio->wait_for_completion &&
6666 + !inode->i_sb->s_dio_done_wq) {
6667 + ret = sb_init_dio_done_wq(inode->i_sb);
6668 + if (ret < 0)
6669 +@@ -1202,8 +1201,10 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
6670 + iomap_dio_actor);
6671 + if (ret <= 0) {
6672 + /* magic error code to fall back to buffered I/O */
6673 +- if (ret == -ENOTBLK)
6674 ++ if (ret == -ENOTBLK) {
6675 ++ dio->wait_for_completion = true;
6676 + ret = 0;
6677 ++ }
6678 + break;
6679 + }
6680 + pos += ret;
6681 +@@ -1224,7 +1225,7 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
6682 + dio->flags &= ~IOMAP_DIO_NEED_SYNC;
6683 +
6684 + if (!atomic_dec_and_test(&dio->ref)) {
6685 +- if (!is_sync_kiocb(iocb))
6686 ++ if (!dio->wait_for_completion)
6687 + return -EIOCBQUEUED;
6688 +
6689 + for (;;) {
6690 +diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
6691 +index ec3fba7d492f..488a9e7f8f66 100644
6692 +--- a/fs/isofs/inode.c
6693 ++++ b/fs/isofs/inode.c
6694 +@@ -24,6 +24,7 @@
6695 + #include <linux/mpage.h>
6696 + #include <linux/user_namespace.h>
6697 + #include <linux/seq_file.h>
6698 ++#include <linux/blkdev.h>
6699 +
6700 + #include "isofs.h"
6701 + #include "zisofs.h"
6702 +@@ -653,6 +654,12 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
6703 + /*
6704 + * What if bugger tells us to go beyond page size?
6705 + */
6706 ++ if (bdev_logical_block_size(s->s_bdev) > 2048) {
6707 ++ printk(KERN_WARNING
6708 ++ "ISOFS: unsupported/invalid hardware sector size %d\n",
6709 ++ bdev_logical_block_size(s->s_bdev));
6710 ++ goto out_freesbi;
6711 ++ }
6712 + opt.blocksize = sb_min_blocksize(s, opt.blocksize);
6713 +
6714 + sbi->s_high_sierra = 0; /* default is iso9660 */
6715 +diff --git a/fs/locks.c b/fs/locks.c
6716 +index db7b6917d9c5..fafce5a8d74f 100644
6717 +--- a/fs/locks.c
6718 ++++ b/fs/locks.c
6719 +@@ -2072,6 +2072,13 @@ static pid_t locks_translate_pid(struct file_lock *fl, struct pid_namespace *ns)
6720 + return -1;
6721 + if (IS_REMOTELCK(fl))
6722 + return fl->fl_pid;
6723 ++ /*
6724 ++ * If the flock owner process is dead and its pid has been already
6725 ++ * freed, the translation below won't work, but we still want to show
6726 ++ * flock owner pid number in init pidns.
6727 ++ */
6728 ++ if (ns == &init_pid_ns)
6729 ++ return (pid_t)fl->fl_pid;
6730 +
6731 + rcu_read_lock();
6732 + pid = find_pid_ns(fl->fl_pid, &init_pid_ns);
6733 +diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
6734 +index 5d99e8810b85..0dded931f119 100644
6735 +--- a/fs/nfsd/nfs4proc.c
6736 ++++ b/fs/nfsd/nfs4proc.c
6737 +@@ -1726,6 +1726,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
6738 + if (status) {
6739 + op = &args->ops[0];
6740 + op->status = status;
6741 ++ resp->opcnt = 1;
6742 + goto encode_op;
6743 + }
6744 +
6745 +diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
6746 +index ca1d2cc2cdfa..18863d56273c 100644
6747 +--- a/include/linux/arm-smccc.h
6748 ++++ b/include/linux/arm-smccc.h
6749 +@@ -199,47 +199,57 @@ asmlinkage void __arm_smccc_hvc(unsigned long a0, unsigned long a1,
6750 +
6751 + #define __declare_arg_0(a0, res) \
6752 + struct arm_smccc_res *___res = res; \
6753 +- register u32 r0 asm("r0") = a0; \
6754 ++ register unsigned long r0 asm("r0") = (u32)a0; \
6755 + register unsigned long r1 asm("r1"); \
6756 + register unsigned long r2 asm("r2"); \
6757 + register unsigned long r3 asm("r3")
6758 +
6759 + #define __declare_arg_1(a0, a1, res) \
6760 ++ typeof(a1) __a1 = a1; \
6761 + struct arm_smccc_res *___res = res; \
6762 +- register u32 r0 asm("r0") = a0; \
6763 +- register typeof(a1) r1 asm("r1") = a1; \
6764 ++ register unsigned long r0 asm("r0") = (u32)a0; \
6765 ++ register unsigned long r1 asm("r1") = __a1; \
6766 + register unsigned long r2 asm("r2"); \
6767 + register unsigned long r3 asm("r3")
6768 +
6769 + #define __declare_arg_2(a0, a1, a2, res) \
6770 ++ typeof(a1) __a1 = a1; \
6771 ++ typeof(a2) __a2 = a2; \
6772 + struct arm_smccc_res *___res = res; \
6773 +- register u32 r0 asm("r0") = a0; \
6774 +- register typeof(a1) r1 asm("r1") = a1; \
6775 +- register typeof(a2) r2 asm("r2") = a2; \
6776 ++ register unsigned long r0 asm("r0") = (u32)a0; \
6777 ++ register unsigned long r1 asm("r1") = __a1; \
6778 ++ register unsigned long r2 asm("r2") = __a2; \
6779 + register unsigned long r3 asm("r3")
6780 +
6781 + #define __declare_arg_3(a0, a1, a2, a3, res) \
6782 ++ typeof(a1) __a1 = a1; \
6783 ++ typeof(a2) __a2 = a2; \
6784 ++ typeof(a3) __a3 = a3; \
6785 + struct arm_smccc_res *___res = res; \
6786 +- register u32 r0 asm("r0") = a0; \
6787 +- register typeof(a1) r1 asm("r1") = a1; \
6788 +- register typeof(a2) r2 asm("r2") = a2; \
6789 +- register typeof(a3) r3 asm("r3") = a3
6790 ++ register unsigned long r0 asm("r0") = (u32)a0; \
6791 ++ register unsigned long r1 asm("r1") = __a1; \
6792 ++ register unsigned long r2 asm("r2") = __a2; \
6793 ++ register unsigned long r3 asm("r3") = __a3
6794 +
6795 + #define __declare_arg_4(a0, a1, a2, a3, a4, res) \
6796 ++ typeof(a4) __a4 = a4; \
6797 + __declare_arg_3(a0, a1, a2, a3, res); \
6798 +- register typeof(a4) r4 asm("r4") = a4
6799 ++ register unsigned long r4 asm("r4") = __a4
6800 +
6801 + #define __declare_arg_5(a0, a1, a2, a3, a4, a5, res) \
6802 ++ typeof(a5) __a5 = a5; \
6803 + __declare_arg_4(a0, a1, a2, a3, a4, res); \
6804 +- register typeof(a5) r5 asm("r5") = a5
6805 ++ register unsigned long r5 asm("r5") = __a5
6806 +
6807 + #define __declare_arg_6(a0, a1, a2, a3, a4, a5, a6, res) \
6808 ++ typeof(a6) __a6 = a6; \
6809 + __declare_arg_5(a0, a1, a2, a3, a4, a5, res); \
6810 +- register typeof(a6) r6 asm("r6") = a6
6811 ++ register unsigned long r6 asm("r6") = __a6
6812 +
6813 + #define __declare_arg_7(a0, a1, a2, a3, a4, a5, a6, a7, res) \
6814 ++ typeof(a7) __a7 = a7; \
6815 + __declare_arg_6(a0, a1, a2, a3, a4, a5, a6, res); \
6816 +- register typeof(a7) r7 asm("r7") = a7
6817 ++ register unsigned long r7 asm("r7") = __a7
6818 +
6819 + #define ___declare_args(count, ...) __declare_arg_ ## count(__VA_ARGS__)
6820 + #define __declare_args(count, ...) ___declare_args(count, __VA_ARGS__)
6821 +diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
6822 +index cf2588d81148..147a7bb341dd 100644
6823 +--- a/include/linux/bitfield.h
6824 ++++ b/include/linux/bitfield.h
6825 +@@ -104,7 +104,7 @@
6826 + (typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \
6827 + })
6828 +
6829 +-extern void __compiletime_warning("value doesn't fit into mask")
6830 ++extern void __compiletime_error("value doesn't fit into mask")
6831 + __field_overflow(void);
6832 + extern void __compiletime_error("bad bitfield mask")
6833 + __bad_mask(void);
6834 +@@ -121,8 +121,8 @@ static __always_inline u64 field_mask(u64 field)
6835 + #define ____MAKE_OP(type,base,to,from) \
6836 + static __always_inline __##type type##_encode_bits(base v, base field) \
6837 + { \
6838 +- if (__builtin_constant_p(v) && (v & ~field_multiplier(field))) \
6839 +- __field_overflow(); \
6840 ++ if (__builtin_constant_p(v) && (v & ~field_mask(field))) \
6841 ++ __field_overflow(); \
6842 + return to((v & field_mask(field)) * field_multiplier(field)); \
6843 + } \
6844 + static __always_inline __##type type##_replace_bits(__##type old, \
6845 +diff --git a/include/linux/platform_data/ina2xx.h b/include/linux/platform_data/ina2xx.h
6846 +index 9abc0ca7259b..9f0aa1b48c78 100644
6847 +--- a/include/linux/platform_data/ina2xx.h
6848 ++++ b/include/linux/platform_data/ina2xx.h
6849 +@@ -1,7 +1,7 @@
6850 + /*
6851 + * Driver for Texas Instruments INA219, INA226 power monitor chips
6852 + *
6853 +- * Copyright (C) 2012 Lothar Felten <l-felten@××.com>
6854 ++ * Copyright (C) 2012 Lothar Felten <lothar.felten@×××××.com>
6855 + *
6856 + * This program is free software; you can redistribute it and/or modify
6857 + * it under the terms of the GNU General Public License version 2 as
6858 +diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
6859 +index c85704fcdbd2..ee7e987ea1b4 100644
6860 +--- a/include/linux/posix-timers.h
6861 ++++ b/include/linux/posix-timers.h
6862 +@@ -95,8 +95,8 @@ struct k_itimer {
6863 + clockid_t it_clock;
6864 + timer_t it_id;
6865 + int it_active;
6866 +- int it_overrun;
6867 +- int it_overrun_last;
6868 ++ s64 it_overrun;
6869 ++ s64 it_overrun_last;
6870 + int it_requeue_pending;
6871 + int it_sigev_notify;
6872 + ktime_t it_interval;
6873 +diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
6874 +index b21c4bd96b84..f80769175c56 100644
6875 +--- a/include/linux/power_supply.h
6876 ++++ b/include/linux/power_supply.h
6877 +@@ -269,6 +269,7 @@ struct power_supply {
6878 + spinlock_t changed_lock;
6879 + bool changed;
6880 + bool initialized;
6881 ++ bool removing;
6882 + atomic_t use_cnt;
6883 + #ifdef CONFIG_THERMAL
6884 + struct thermal_zone_device *tzd;
6885 +diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
6886 +index 3468703d663a..a459a5e973a7 100644
6887 +--- a/include/linux/regulator/machine.h
6888 ++++ b/include/linux/regulator/machine.h
6889 +@@ -48,9 +48,9 @@ struct regulator;
6890 + * DISABLE_IN_SUSPEND - turn off regulator in suspend states
6891 + * ENABLE_IN_SUSPEND - keep regulator on in suspend states
6892 + */
6893 +-#define DO_NOTHING_IN_SUSPEND (-1)
6894 +-#define DISABLE_IN_SUSPEND 0
6895 +-#define ENABLE_IN_SUSPEND 1
6896 ++#define DO_NOTHING_IN_SUSPEND 0
6897 ++#define DISABLE_IN_SUSPEND 1
6898 ++#define ENABLE_IN_SUSPEND 2
6899 +
6900 + /* Regulator active discharge flags */
6901 + enum regulator_active_discharge {
6902 +diff --git a/include/linux/uio.h b/include/linux/uio.h
6903 +index 409c845d4cd3..422b1c01ee0d 100644
6904 +--- a/include/linux/uio.h
6905 ++++ b/include/linux/uio.h
6906 +@@ -172,7 +172,7 @@ size_t copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i)
6907 + static __always_inline __must_check
6908 + size_t copy_to_iter_mcsafe(void *addr, size_t bytes, struct iov_iter *i)
6909 + {
6910 +- if (unlikely(!check_copy_size(addr, bytes, false)))
6911 ++ if (unlikely(!check_copy_size(addr, bytes, true)))
6912 + return 0;
6913 + else
6914 + return _copy_to_iter_mcsafe(addr, bytes, i);
6915 +diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
6916 +index ea73fef8bdc0..8586cfb49828 100644
6917 +--- a/include/media/v4l2-fh.h
6918 ++++ b/include/media/v4l2-fh.h
6919 +@@ -38,10 +38,13 @@ struct v4l2_ctrl_handler;
6920 + * @prio: priority of the file handler, as defined by &enum v4l2_priority
6921 + *
6922 + * @wait: event' s wait queue
6923 ++ * @subscribe_lock: serialise changes to the subscribed list; guarantee that
6924 ++ * the add and del event callbacks are orderly called
6925 + * @subscribed: list of subscribed events
6926 + * @available: list of events waiting to be dequeued
6927 + * @navailable: number of available events at @available list
6928 + * @sequence: event sequence number
6929 ++ *
6930 + * @m2m_ctx: pointer to &struct v4l2_m2m_ctx
6931 + */
6932 + struct v4l2_fh {
6933 +@@ -52,6 +55,7 @@ struct v4l2_fh {
6934 +
6935 + /* Events */
6936 + wait_queue_head_t wait;
6937 ++ struct mutex subscribe_lock;
6938 + struct list_head subscribed;
6939 + struct list_head available;
6940 + unsigned int navailable;
6941 +diff --git a/include/rdma/opa_addr.h b/include/rdma/opa_addr.h
6942 +index 2bbb7a67e643..66d4393d339c 100644
6943 +--- a/include/rdma/opa_addr.h
6944 ++++ b/include/rdma/opa_addr.h
6945 +@@ -120,7 +120,7 @@ static inline bool rdma_is_valid_unicast_lid(struct rdma_ah_attr *attr)
6946 + if (attr->type == RDMA_AH_ATTR_TYPE_IB) {
6947 + if (!rdma_ah_get_dlid(attr) ||
6948 + rdma_ah_get_dlid(attr) >=
6949 +- be32_to_cpu(IB_MULTICAST_LID_BASE))
6950 ++ be16_to_cpu(IB_MULTICAST_LID_BASE))
6951 + return false;
6952 + } else if (attr->type == RDMA_AH_ATTR_TYPE_OPA) {
6953 + if (!rdma_ah_get_dlid(attr) ||
6954 +diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
6955 +index 58899601fccf..ed707b21d152 100644
6956 +--- a/kernel/bpf/sockmap.c
6957 ++++ b/kernel/bpf/sockmap.c
6958 +@@ -1430,12 +1430,15 @@ out:
6959 + static void smap_write_space(struct sock *sk)
6960 + {
6961 + struct smap_psock *psock;
6962 ++ void (*write_space)(struct sock *sk);
6963 +
6964 + rcu_read_lock();
6965 + psock = smap_psock_sk(sk);
6966 + if (likely(psock && test_bit(SMAP_TX_RUNNING, &psock->state)))
6967 + schedule_work(&psock->tx_work);
6968 ++ write_space = psock->save_write_space;
6969 + rcu_read_unlock();
6970 ++ write_space(sk);
6971 + }
6972 +
6973 + static void smap_stop_sock(struct smap_psock *psock, struct sock *sk)
6974 +@@ -2143,7 +2146,9 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr)
6975 + return ERR_PTR(-EPERM);
6976 +
6977 + /* check sanity of attributes */
6978 +- if (attr->max_entries == 0 || attr->value_size != 4 ||
6979 ++ if (attr->max_entries == 0 ||
6980 ++ attr->key_size == 0 ||
6981 ++ attr->value_size != 4 ||
6982 + attr->map_flags & ~SOCK_CREATE_FLAG_MASK)
6983 + return ERR_PTR(-EINVAL);
6984 +
6985 +@@ -2270,8 +2275,10 @@ static struct htab_elem *alloc_sock_hash_elem(struct bpf_htab *htab,
6986 + }
6987 + l_new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN,
6988 + htab->map.numa_node);
6989 +- if (!l_new)
6990 ++ if (!l_new) {
6991 ++ atomic_dec(&htab->count);
6992 + return ERR_PTR(-ENOMEM);
6993 ++ }
6994 +
6995 + memcpy(l_new->key, key, key_size);
6996 + l_new->sk = sk;
6997 +diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
6998 +index 6e28d2866be5..314e2a9040c7 100644
6999 +--- a/kernel/events/hw_breakpoint.c
7000 ++++ b/kernel/events/hw_breakpoint.c
7001 +@@ -400,16 +400,35 @@ int dbg_release_bp_slot(struct perf_event *bp)
7002 + return 0;
7003 + }
7004 +
7005 +-static int validate_hw_breakpoint(struct perf_event *bp)
7006 ++#ifndef hw_breakpoint_arch_parse
7007 ++int hw_breakpoint_arch_parse(struct perf_event *bp,
7008 ++ const struct perf_event_attr *attr,
7009 ++ struct arch_hw_breakpoint *hw)
7010 + {
7011 +- int ret;
7012 ++ int err;
7013 +
7014 +- ret = arch_validate_hwbkpt_settings(bp);
7015 +- if (ret)
7016 +- return ret;
7017 ++ err = arch_validate_hwbkpt_settings(bp);
7018 ++ if (err)
7019 ++ return err;
7020 ++
7021 ++ *hw = bp->hw.info;
7022 ++
7023 ++ return 0;
7024 ++}
7025 ++#endif
7026 ++
7027 ++static int hw_breakpoint_parse(struct perf_event *bp,
7028 ++ const struct perf_event_attr *attr,
7029 ++ struct arch_hw_breakpoint *hw)
7030 ++{
7031 ++ int err;
7032 ++
7033 ++ err = hw_breakpoint_arch_parse(bp, attr, hw);
7034 ++ if (err)
7035 ++ return err;
7036 +
7037 + if (arch_check_bp_in_kernelspace(bp)) {
7038 +- if (bp->attr.exclude_kernel)
7039 ++ if (attr->exclude_kernel)
7040 + return -EINVAL;
7041 + /*
7042 + * Don't let unprivileged users set a breakpoint in the trap
7043 +@@ -424,19 +443,22 @@ static int validate_hw_breakpoint(struct perf_event *bp)
7044 +
7045 + int register_perf_hw_breakpoint(struct perf_event *bp)
7046 + {
7047 +- int ret;
7048 +-
7049 +- ret = reserve_bp_slot(bp);
7050 +- if (ret)
7051 +- return ret;
7052 ++ struct arch_hw_breakpoint hw;
7053 ++ int err;
7054 +
7055 +- ret = validate_hw_breakpoint(bp);
7056 ++ err = reserve_bp_slot(bp);
7057 ++ if (err)
7058 ++ return err;
7059 +
7060 +- /* if arch_validate_hwbkpt_settings() fails then release bp slot */
7061 +- if (ret)
7062 ++ err = hw_breakpoint_parse(bp, &bp->attr, &hw);
7063 ++ if (err) {
7064 + release_bp_slot(bp);
7065 ++ return err;
7066 ++ }
7067 +
7068 +- return ret;
7069 ++ bp->hw.info = hw;
7070 ++
7071 ++ return 0;
7072 + }
7073 +
7074 + /**
7075 +@@ -464,6 +486,7 @@ modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *a
7076 + u64 old_len = bp->attr.bp_len;
7077 + int old_type = bp->attr.bp_type;
7078 + bool modify = attr->bp_type != old_type;
7079 ++ struct arch_hw_breakpoint hw;
7080 + int err = 0;
7081 +
7082 + bp->attr.bp_addr = attr->bp_addr;
7083 +@@ -473,7 +496,7 @@ modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *a
7084 + if (check && memcmp(&bp->attr, attr, sizeof(*attr)))
7085 + return -EINVAL;
7086 +
7087 +- err = validate_hw_breakpoint(bp);
7088 ++ err = hw_breakpoint_parse(bp, attr, &hw);
7089 + if (!err && modify)
7090 + err = modify_bp_slot(bp, old_type);
7091 +
7092 +@@ -484,7 +507,9 @@ modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *a
7093 + return err;
7094 + }
7095 +
7096 ++ bp->hw.info = hw;
7097 + bp->attr.disabled = attr->disabled;
7098 ++
7099 + return 0;
7100 + }
7101 +
7102 +diff --git a/kernel/module.c b/kernel/module.c
7103 +index f475f30eed8c..4a6b9c6d5f2c 100644
7104 +--- a/kernel/module.c
7105 ++++ b/kernel/module.c
7106 +@@ -4067,7 +4067,7 @@ static unsigned long mod_find_symname(struct module *mod, const char *name)
7107 +
7108 + for (i = 0; i < kallsyms->num_symtab; i++)
7109 + if (strcmp(name, symname(kallsyms, i)) == 0 &&
7110 +- kallsyms->symtab[i].st_info != 'U')
7111 ++ kallsyms->symtab[i].st_shndx != SHN_UNDEF)
7112 + return kallsyms->symtab[i].st_value;
7113 + return 0;
7114 + }
7115 +@@ -4113,6 +4113,10 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
7116 + if (mod->state == MODULE_STATE_UNFORMED)
7117 + continue;
7118 + for (i = 0; i < kallsyms->num_symtab; i++) {
7119 ++
7120 ++ if (kallsyms->symtab[i].st_shndx == SHN_UNDEF)
7121 ++ continue;
7122 ++
7123 + ret = fn(data, symname(kallsyms, i),
7124 + mod, kallsyms->symtab[i].st_value);
7125 + if (ret != 0)
7126 +diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
7127 +index 639321bf2e39..fa5de5e8de61 100644
7128 +--- a/kernel/time/alarmtimer.c
7129 ++++ b/kernel/time/alarmtimer.c
7130 +@@ -581,11 +581,11 @@ static void alarm_timer_rearm(struct k_itimer *timr)
7131 + * @timr: Pointer to the posixtimer data struct
7132 + * @now: Current time to forward the timer against
7133 + */
7134 +-static int alarm_timer_forward(struct k_itimer *timr, ktime_t now)
7135 ++static s64 alarm_timer_forward(struct k_itimer *timr, ktime_t now)
7136 + {
7137 + struct alarm *alarm = &timr->it.alarm.alarmtimer;
7138 +
7139 +- return (int) alarm_forward(alarm, timr->it_interval, now);
7140 ++ return alarm_forward(alarm, timr->it_interval, now);
7141 + }
7142 +
7143 + /**
7144 +@@ -808,7 +808,8 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
7145 + /* Convert (if necessary) to absolute time */
7146 + if (flags != TIMER_ABSTIME) {
7147 + ktime_t now = alarm_bases[type].gettime();
7148 +- exp = ktime_add(now, exp);
7149 ++
7150 ++ exp = ktime_add_safe(now, exp);
7151 + }
7152 +
7153 + ret = alarmtimer_do_nsleep(&alarm, exp, type);
7154 +diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
7155 +index 9cdf54b04ca8..294d7b65af33 100644
7156 +--- a/kernel/time/posix-cpu-timers.c
7157 ++++ b/kernel/time/posix-cpu-timers.c
7158 +@@ -85,7 +85,7 @@ static void bump_cpu_timer(struct k_itimer *timer, u64 now)
7159 + continue;
7160 +
7161 + timer->it.cpu.expires += incr;
7162 +- timer->it_overrun += 1 << i;
7163 ++ timer->it_overrun += 1LL << i;
7164 + delta -= incr;
7165 + }
7166 + }
7167 +diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
7168 +index e08ce3f27447..e475012bff7e 100644
7169 +--- a/kernel/time/posix-timers.c
7170 ++++ b/kernel/time/posix-timers.c
7171 +@@ -283,6 +283,17 @@ static __init int init_posix_timers(void)
7172 + }
7173 + __initcall(init_posix_timers);
7174 +
7175 ++/*
7176 ++ * The siginfo si_overrun field and the return value of timer_getoverrun(2)
7177 ++ * are of type int. Clamp the overrun value to INT_MAX
7178 ++ */
7179 ++static inline int timer_overrun_to_int(struct k_itimer *timr, int baseval)
7180 ++{
7181 ++ s64 sum = timr->it_overrun_last + (s64)baseval;
7182 ++
7183 ++ return sum > (s64)INT_MAX ? INT_MAX : (int)sum;
7184 ++}
7185 ++
7186 + static void common_hrtimer_rearm(struct k_itimer *timr)
7187 + {
7188 + struct hrtimer *timer = &timr->it.real.timer;
7189 +@@ -290,9 +301,8 @@ static void common_hrtimer_rearm(struct k_itimer *timr)
7190 + if (!timr->it_interval)
7191 + return;
7192 +
7193 +- timr->it_overrun += (unsigned int) hrtimer_forward(timer,
7194 +- timer->base->get_time(),
7195 +- timr->it_interval);
7196 ++ timr->it_overrun += hrtimer_forward(timer, timer->base->get_time(),
7197 ++ timr->it_interval);
7198 + hrtimer_restart(timer);
7199 + }
7200 +
7201 +@@ -321,10 +331,10 @@ void posixtimer_rearm(struct siginfo *info)
7202 +
7203 + timr->it_active = 1;
7204 + timr->it_overrun_last = timr->it_overrun;
7205 +- timr->it_overrun = -1;
7206 ++ timr->it_overrun = -1LL;
7207 + ++timr->it_requeue_pending;
7208 +
7209 +- info->si_overrun += timr->it_overrun_last;
7210 ++ info->si_overrun = timer_overrun_to_int(timr, info->si_overrun);
7211 + }
7212 +
7213 + unlock_timer(timr, flags);
7214 +@@ -418,9 +428,8 @@ static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer)
7215 + now = ktime_add(now, kj);
7216 + }
7217 + #endif
7218 +- timr->it_overrun += (unsigned int)
7219 +- hrtimer_forward(timer, now,
7220 +- timr->it_interval);
7221 ++ timr->it_overrun += hrtimer_forward(timer, now,
7222 ++ timr->it_interval);
7223 + ret = HRTIMER_RESTART;
7224 + ++timr->it_requeue_pending;
7225 + timr->it_active = 1;
7226 +@@ -524,7 +533,7 @@ static int do_timer_create(clockid_t which_clock, struct sigevent *event,
7227 + new_timer->it_id = (timer_t) new_timer_id;
7228 + new_timer->it_clock = which_clock;
7229 + new_timer->kclock = kc;
7230 +- new_timer->it_overrun = -1;
7231 ++ new_timer->it_overrun = -1LL;
7232 +
7233 + if (event) {
7234 + rcu_read_lock();
7235 +@@ -645,11 +654,11 @@ static ktime_t common_hrtimer_remaining(struct k_itimer *timr, ktime_t now)
7236 + return __hrtimer_expires_remaining_adjusted(timer, now);
7237 + }
7238 +
7239 +-static int common_hrtimer_forward(struct k_itimer *timr, ktime_t now)
7240 ++static s64 common_hrtimer_forward(struct k_itimer *timr, ktime_t now)
7241 + {
7242 + struct hrtimer *timer = &timr->it.real.timer;
7243 +
7244 +- return (int)hrtimer_forward(timer, now, timr->it_interval);
7245 ++ return hrtimer_forward(timer, now, timr->it_interval);
7246 + }
7247 +
7248 + /*
7249 +@@ -789,7 +798,7 @@ SYSCALL_DEFINE1(timer_getoverrun, timer_t, timer_id)
7250 + if (!timr)
7251 + return -EINVAL;
7252 +
7253 +- overrun = timr->it_overrun_last;
7254 ++ overrun = timer_overrun_to_int(timr, 0);
7255 + unlock_timer(timr, flags);
7256 +
7257 + return overrun;
7258 +diff --git a/kernel/time/posix-timers.h b/kernel/time/posix-timers.h
7259 +index 151e28f5bf30..ddb21145211a 100644
7260 +--- a/kernel/time/posix-timers.h
7261 ++++ b/kernel/time/posix-timers.h
7262 +@@ -19,7 +19,7 @@ struct k_clock {
7263 + void (*timer_get)(struct k_itimer *timr,
7264 + struct itimerspec64 *cur_setting);
7265 + void (*timer_rearm)(struct k_itimer *timr);
7266 +- int (*timer_forward)(struct k_itimer *timr, ktime_t now);
7267 ++ s64 (*timer_forward)(struct k_itimer *timr, ktime_t now);
7268 + ktime_t (*timer_remaining)(struct k_itimer *timr, ktime_t now);
7269 + int (*timer_try_to_cancel)(struct k_itimer *timr);
7270 + void (*timer_arm)(struct k_itimer *timr, ktime_t expires,
7271 +diff --git a/lib/klist.c b/lib/klist.c
7272 +index 0507fa5d84c5..f6b547812fe3 100644
7273 +--- a/lib/klist.c
7274 ++++ b/lib/klist.c
7275 +@@ -336,8 +336,9 @@ struct klist_node *klist_prev(struct klist_iter *i)
7276 + void (*put)(struct klist_node *) = i->i_klist->put;
7277 + struct klist_node *last = i->i_cur;
7278 + struct klist_node *prev;
7279 ++ unsigned long flags;
7280 +
7281 +- spin_lock(&i->i_klist->k_lock);
7282 ++ spin_lock_irqsave(&i->i_klist->k_lock, flags);
7283 +
7284 + if (last) {
7285 + prev = to_klist_node(last->n_node.prev);
7286 +@@ -356,7 +357,7 @@ struct klist_node *klist_prev(struct klist_iter *i)
7287 + prev = to_klist_node(prev->n_node.prev);
7288 + }
7289 +
7290 +- spin_unlock(&i->i_klist->k_lock);
7291 ++ spin_unlock_irqrestore(&i->i_klist->k_lock, flags);
7292 +
7293 + if (put && last)
7294 + put(last);
7295 +@@ -377,8 +378,9 @@ struct klist_node *klist_next(struct klist_iter *i)
7296 + void (*put)(struct klist_node *) = i->i_klist->put;
7297 + struct klist_node *last = i->i_cur;
7298 + struct klist_node *next;
7299 ++ unsigned long flags;
7300 +
7301 +- spin_lock(&i->i_klist->k_lock);
7302 ++ spin_lock_irqsave(&i->i_klist->k_lock, flags);
7303 +
7304 + if (last) {
7305 + next = to_klist_node(last->n_node.next);
7306 +@@ -397,7 +399,7 @@ struct klist_node *klist_next(struct klist_iter *i)
7307 + next = to_klist_node(next->n_node.next);
7308 + }
7309 +
7310 +- spin_unlock(&i->i_klist->k_lock);
7311 ++ spin_unlock_irqrestore(&i->i_klist->k_lock, flags);
7312 +
7313 + if (put && last)
7314 + put(last);
7315 +diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
7316 +index 6b1042e21656..52fad5dad9f7 100644
7317 +--- a/net/6lowpan/iphc.c
7318 ++++ b/net/6lowpan/iphc.c
7319 +@@ -770,6 +770,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
7320 + hdr.hop_limit, &hdr.daddr);
7321 +
7322 + skb_push(skb, sizeof(hdr));
7323 ++ skb_reset_mac_header(skb);
7324 + skb_reset_network_header(skb);
7325 + skb_copy_to_linear_data(skb, &hdr, sizeof(hdr));
7326 +
7327 +diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c
7328 +index 4bfff3c87e8e..e99d6afb70ef 100644
7329 +--- a/net/ipv4/tcp_bbr.c
7330 ++++ b/net/ipv4/tcp_bbr.c
7331 +@@ -95,11 +95,10 @@ struct bbr {
7332 + u32 mode:3, /* current bbr_mode in state machine */
7333 + prev_ca_state:3, /* CA state on previous ACK */
7334 + packet_conservation:1, /* use packet conservation? */
7335 +- restore_cwnd:1, /* decided to revert cwnd to old value */
7336 + round_start:1, /* start of packet-timed tx->ack round? */
7337 + idle_restart:1, /* restarting after idle? */
7338 + probe_rtt_round_done:1, /* a BBR_PROBE_RTT round at 4 pkts? */
7339 +- unused:12,
7340 ++ unused:13,
7341 + lt_is_sampling:1, /* taking long-term ("LT") samples now? */
7342 + lt_rtt_cnt:7, /* round trips in long-term interval */
7343 + lt_use_bw:1; /* use lt_bw as our bw estimate? */
7344 +@@ -175,6 +174,8 @@ static const u32 bbr_lt_bw_diff = 4000 / 8;
7345 + /* If we estimate we're policed, use lt_bw for this many round trips: */
7346 + static const u32 bbr_lt_bw_max_rtts = 48;
7347 +
7348 ++static void bbr_check_probe_rtt_done(struct sock *sk);
7349 ++
7350 + /* Do we estimate that STARTUP filled the pipe? */
7351 + static bool bbr_full_bw_reached(const struct sock *sk)
7352 + {
7353 +@@ -305,6 +306,8 @@ static void bbr_cwnd_event(struct sock *sk, enum tcp_ca_event event)
7354 + */
7355 + if (bbr->mode == BBR_PROBE_BW)
7356 + bbr_set_pacing_rate(sk, bbr_bw(sk), BBR_UNIT);
7357 ++ else if (bbr->mode == BBR_PROBE_RTT)
7358 ++ bbr_check_probe_rtt_done(sk);
7359 + }
7360 + }
7361 +
7362 +@@ -392,17 +395,11 @@ static bool bbr_set_cwnd_to_recover_or_restore(
7363 + cwnd = tcp_packets_in_flight(tp) + acked;
7364 + } else if (prev_state >= TCP_CA_Recovery && state < TCP_CA_Recovery) {
7365 + /* Exiting loss recovery; restore cwnd saved before recovery. */
7366 +- bbr->restore_cwnd = 1;
7367 ++ cwnd = max(cwnd, bbr->prior_cwnd);
7368 + bbr->packet_conservation = 0;
7369 + }
7370 + bbr->prev_ca_state = state;
7371 +
7372 +- if (bbr->restore_cwnd) {
7373 +- /* Restore cwnd after exiting loss recovery or PROBE_RTT. */
7374 +- cwnd = max(cwnd, bbr->prior_cwnd);
7375 +- bbr->restore_cwnd = 0;
7376 +- }
7377 +-
7378 + if (bbr->packet_conservation) {
7379 + *new_cwnd = max(cwnd, tcp_packets_in_flight(tp) + acked);
7380 + return true; /* yes, using packet conservation */
7381 +@@ -744,6 +741,20 @@ static void bbr_check_drain(struct sock *sk, const struct rate_sample *rs)
7382 + bbr_reset_probe_bw_mode(sk); /* we estimate queue is drained */
7383 + }
7384 +
7385 ++static void bbr_check_probe_rtt_done(struct sock *sk)
7386 ++{
7387 ++ struct tcp_sock *tp = tcp_sk(sk);
7388 ++ struct bbr *bbr = inet_csk_ca(sk);
7389 ++
7390 ++ if (!(bbr->probe_rtt_done_stamp &&
7391 ++ after(tcp_jiffies32, bbr->probe_rtt_done_stamp)))
7392 ++ return;
7393 ++
7394 ++ bbr->min_rtt_stamp = tcp_jiffies32; /* wait a while until PROBE_RTT */
7395 ++ tp->snd_cwnd = max(tp->snd_cwnd, bbr->prior_cwnd);
7396 ++ bbr_reset_mode(sk);
7397 ++}
7398 ++
7399 + /* The goal of PROBE_RTT mode is to have BBR flows cooperatively and
7400 + * periodically drain the bottleneck queue, to converge to measure the true
7401 + * min_rtt (unloaded propagation delay). This allows the flows to keep queues
7402 +@@ -802,12 +813,8 @@ static void bbr_update_min_rtt(struct sock *sk, const struct rate_sample *rs)
7403 + } else if (bbr->probe_rtt_done_stamp) {
7404 + if (bbr->round_start)
7405 + bbr->probe_rtt_round_done = 1;
7406 +- if (bbr->probe_rtt_round_done &&
7407 +- after(tcp_jiffies32, bbr->probe_rtt_done_stamp)) {
7408 +- bbr->min_rtt_stamp = tcp_jiffies32;
7409 +- bbr->restore_cwnd = 1; /* snap to prior_cwnd */
7410 +- bbr_reset_mode(sk);
7411 +- }
7412 ++ if (bbr->probe_rtt_round_done)
7413 ++ bbr_check_probe_rtt_done(sk);
7414 + }
7415 + }
7416 + /* Restart after idle ends only once we process a new S/ACK for data */
7417 +@@ -858,7 +865,6 @@ static void bbr_init(struct sock *sk)
7418 + bbr->has_seen_rtt = 0;
7419 + bbr_init_pacing_rate_from_rtt(sk);
7420 +
7421 +- bbr->restore_cwnd = 0;
7422 + bbr->round_start = 0;
7423 + bbr->idle_restart = 0;
7424 + bbr->full_bw_reached = 0;
7425 +diff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c
7426 +index 82e6edf9c5d9..45f33d6dedf7 100644
7427 +--- a/net/ncsi/ncsi-netlink.c
7428 ++++ b/net/ncsi/ncsi-netlink.c
7429 +@@ -100,7 +100,7 @@ static int ncsi_write_package_info(struct sk_buff *skb,
7430 + bool found;
7431 + int rc;
7432 +
7433 +- if (id > ndp->package_num) {
7434 ++ if (id > ndp->package_num - 1) {
7435 + netdev_info(ndp->ndev.dev, "NCSI: No package with id %u\n", id);
7436 + return -ENODEV;
7437 + }
7438 +@@ -240,7 +240,7 @@ static int ncsi_pkg_info_all_nl(struct sk_buff *skb,
7439 + return 0; /* done */
7440 +
7441 + hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
7442 +- &ncsi_genl_family, 0, NCSI_CMD_PKG_INFO);
7443 ++ &ncsi_genl_family, NLM_F_MULTI, NCSI_CMD_PKG_INFO);
7444 + if (!hdr) {
7445 + rc = -EMSGSIZE;
7446 + goto err;
7447 +diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
7448 +index 2ccf194c3ebb..8015e50e8d0a 100644
7449 +--- a/net/tls/tls_main.c
7450 ++++ b/net/tls/tls_main.c
7451 +@@ -222,9 +222,14 @@ static void tls_write_space(struct sock *sk)
7452 + {
7453 + struct tls_context *ctx = tls_get_ctx(sk);
7454 +
7455 +- /* We are already sending pages, ignore notification */
7456 +- if (ctx->in_tcp_sendpages)
7457 ++ /* If in_tcp_sendpages call lower protocol write space handler
7458 ++ * to ensure we wake up any waiting operations there. For example
7459 ++ * if do_tcp_sendpages where to call sk_wait_event.
7460 ++ */
7461 ++ if (ctx->in_tcp_sendpages) {
7462 ++ ctx->sk_write_space(sk);
7463 + return;
7464 ++ }
7465 +
7466 + if (!sk->sk_write_pending && tls_is_pending_closed_record(ctx)) {
7467 + gfp_t sk_allocation = sk->sk_allocation;
7468 +diff --git a/sound/aoa/core/gpio-feature.c b/sound/aoa/core/gpio-feature.c
7469 +index 71960089e207..65557421fe0b 100644
7470 +--- a/sound/aoa/core/gpio-feature.c
7471 ++++ b/sound/aoa/core/gpio-feature.c
7472 +@@ -88,8 +88,10 @@ static struct device_node *get_gpio(char *name,
7473 + }
7474 +
7475 + reg = of_get_property(np, "reg", NULL);
7476 +- if (!reg)
7477 ++ if (!reg) {
7478 ++ of_node_put(np);
7479 + return NULL;
7480 ++ }
7481 +
7482 + *gpioptr = *reg;
7483 +
7484 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
7485 +index 647ae1a71e10..28dc5e124995 100644
7486 +--- a/sound/pci/hda/hda_intel.c
7487 ++++ b/sound/pci/hda/hda_intel.c
7488 +@@ -2535,7 +2535,8 @@ static const struct pci_device_id azx_ids[] = {
7489 + .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB },
7490 + /* AMD Raven */
7491 + { PCI_DEVICE(0x1022, 0x15e3),
7492 +- .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB },
7493 ++ .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB |
7494 ++ AZX_DCAPS_PM_RUNTIME },
7495 + /* ATI HDMI */
7496 + { PCI_DEVICE(0x1002, 0x0002),
7497 + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
7498 +diff --git a/sound/soc/codecs/rt1305.c b/sound/soc/codecs/rt1305.c
7499 +index f4c8c45f4010..421b8fb2fa04 100644
7500 +--- a/sound/soc/codecs/rt1305.c
7501 ++++ b/sound/soc/codecs/rt1305.c
7502 +@@ -1066,7 +1066,7 @@ static void rt1305_calibrate(struct rt1305_priv *rt1305)
7503 + pr_debug("Left_rhl = 0x%x rh=0x%x rl=0x%x\n", rhl, rh, rl);
7504 + pr_info("Left channel %d.%dohm\n", (r0ohm/10), (r0ohm%10));
7505 +
7506 +- r0l = 562949953421312;
7507 ++ r0l = 562949953421312ULL;
7508 + if (rhl != 0)
7509 + do_div(r0l, rhl);
7510 + pr_debug("Left_r0 = 0x%llx\n", r0l);
7511 +@@ -1083,7 +1083,7 @@ static void rt1305_calibrate(struct rt1305_priv *rt1305)
7512 + pr_debug("Right_rhl = 0x%x rh=0x%x rl=0x%x\n", rhl, rh, rl);
7513 + pr_info("Right channel %d.%dohm\n", (r0ohm/10), (r0ohm%10));
7514 +
7515 +- r0r = 562949953421312;
7516 ++ r0r = 562949953421312ULL;
7517 + if (rhl != 0)
7518 + do_div(r0r, rhl);
7519 + pr_debug("Right_r0 = 0x%llx\n", r0r);
7520 +diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
7521 +index 33065ba294a9..d2c9d7865bde 100644
7522 +--- a/sound/soc/intel/boards/bytcr_rt5640.c
7523 ++++ b/sound/soc/intel/boards/bytcr_rt5640.c
7524 +@@ -404,7 +404,7 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
7525 + },
7526 + .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
7527 + BYT_RT5640_JD_SRC_JD1_IN4P |
7528 +- BYT_RT5640_OVCD_TH_2000UA |
7529 ++ BYT_RT5640_OVCD_TH_1500UA |
7530 + BYT_RT5640_OVCD_SF_0P75 |
7531 + BYT_RT5640_SSP0_AIF1 |
7532 + BYT_RT5640_MCLK_EN),
7533 +diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
7534 +index 01f43218984b..69a7896cb713 100644
7535 +--- a/sound/soc/qcom/qdsp6/q6afe.c
7536 ++++ b/sound/soc/qcom/qdsp6/q6afe.c
7537 +@@ -777,7 +777,7 @@ static int q6afe_callback(struct apr_device *adev, struct apr_resp_pkt *data)
7538 + */
7539 + int q6afe_get_port_id(int index)
7540 + {
7541 +- if (index < 0 || index > AFE_PORT_MAX)
7542 ++ if (index < 0 || index >= AFE_PORT_MAX)
7543 + return -EINVAL;
7544 +
7545 + return port_maps[index].port_id;
7546 +@@ -1014,7 +1014,7 @@ int q6afe_port_stop(struct q6afe_port *port)
7547 +
7548 + port_id = port->id;
7549 + index = port->token;
7550 +- if (index < 0 || index > AFE_PORT_MAX) {
7551 ++ if (index < 0 || index >= AFE_PORT_MAX) {
7552 + dev_err(afe->dev, "AFE port index[%d] invalid!\n", index);
7553 + return -EINVAL;
7554 + }
7555 +@@ -1355,7 +1355,7 @@ struct q6afe_port *q6afe_port_get_from_id(struct device *dev, int id)
7556 + unsigned long flags;
7557 + int cfg_type;
7558 +
7559 +- if (id < 0 || id > AFE_PORT_MAX) {
7560 ++ if (id < 0 || id >= AFE_PORT_MAX) {
7561 + dev_err(dev, "AFE port token[%d] invalid!\n", id);
7562 + return ERR_PTR(-EINVAL);
7563 + }
7564 +diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
7565 +index cf4b40d376e5..c675058b908b 100644
7566 +--- a/sound/soc/sh/rcar/ssi.c
7567 ++++ b/sound/soc/sh/rcar/ssi.c
7568 +@@ -37,6 +37,7 @@
7569 + #define CHNL_4 (1 << 22) /* Channels */
7570 + #define CHNL_6 (2 << 22) /* Channels */
7571 + #define CHNL_8 (3 << 22) /* Channels */
7572 ++#define DWL_MASK (7 << 19) /* Data Word Length mask */
7573 + #define DWL_8 (0 << 19) /* Data Word Length */
7574 + #define DWL_16 (1 << 19) /* Data Word Length */
7575 + #define DWL_18 (2 << 19) /* Data Word Length */
7576 +@@ -353,21 +354,18 @@ static void rsnd_ssi_config_init(struct rsnd_mod *mod,
7577 + struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
7578 + struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
7579 + struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
7580 +- u32 cr_own;
7581 +- u32 cr_mode;
7582 +- u32 wsr;
7583 ++ u32 cr_own = ssi->cr_own;
7584 ++ u32 cr_mode = ssi->cr_mode;
7585 ++ u32 wsr = ssi->wsr;
7586 + int is_tdm;
7587 +
7588 +- if (rsnd_ssi_is_parent(mod, io))
7589 +- return;
7590 +-
7591 + is_tdm = rsnd_runtime_is_ssi_tdm(io);
7592 +
7593 + /*
7594 + * always use 32bit system word.
7595 + * see also rsnd_ssi_master_clk_enable()
7596 + */
7597 +- cr_own = FORCE | SWL_32;
7598 ++ cr_own |= FORCE | SWL_32;
7599 +
7600 + if (rdai->bit_clk_inv)
7601 + cr_own |= SCKP;
7602 +@@ -377,9 +375,18 @@ static void rsnd_ssi_config_init(struct rsnd_mod *mod,
7603 + cr_own |= SDTA;
7604 + if (rdai->sys_delay)
7605 + cr_own |= DEL;
7606 ++
7607 ++ /*
7608 ++ * We shouldn't exchange SWSP after running.
7609 ++ * This means, parent needs to care it.
7610 ++ */
7611 ++ if (rsnd_ssi_is_parent(mod, io))
7612 ++ goto init_end;
7613 ++
7614 + if (rsnd_io_is_play(io))
7615 + cr_own |= TRMD;
7616 +
7617 ++ cr_own &= ~DWL_MASK;
7618 + switch (snd_pcm_format_width(runtime->format)) {
7619 + case 16:
7620 + cr_own |= DWL_16;
7621 +@@ -406,7 +413,7 @@ static void rsnd_ssi_config_init(struct rsnd_mod *mod,
7622 + wsr |= WS_MODE;
7623 + cr_own |= CHNL_8;
7624 + }
7625 +-
7626 ++init_end:
7627 + ssi->cr_own = cr_own;
7628 + ssi->cr_mode = cr_mode;
7629 + ssi->wsr = wsr;
7630 +@@ -465,15 +472,18 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
7631 + return -EIO;
7632 + }
7633 +
7634 +- if (!rsnd_ssi_is_parent(mod, io))
7635 +- ssi->cr_own = 0;
7636 +-
7637 + rsnd_ssi_master_clk_stop(mod, io);
7638 +
7639 + rsnd_mod_power_off(mod);
7640 +
7641 + ssi->usrcnt--;
7642 +
7643 ++ if (!ssi->usrcnt) {
7644 ++ ssi->cr_own = 0;
7645 ++ ssi->cr_mode = 0;
7646 ++ ssi->wsr = 0;
7647 ++ }
7648 ++
7649 + return 0;
7650 + }
7651 +
7652 +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
7653 +index 229c12349803..a099c3e45504 100644
7654 +--- a/sound/soc/soc-dapm.c
7655 ++++ b/sound/soc/soc-dapm.c
7656 +@@ -4073,6 +4073,13 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
7657 + continue;
7658 + }
7659 +
7660 ++ /* let users know there is no DAI to link */
7661 ++ if (!dai_w->priv) {
7662 ++ dev_dbg(card->dev, "dai widget %s has no DAI\n",
7663 ++ dai_w->name);
7664 ++ continue;
7665 ++ }
7666 ++
7667 + dai = dai_w->priv;
7668 +
7669 + /* ...find all widgets with the same stream and link them */
7670 +diff --git a/tools/bpf/bpftool/map_perf_ring.c b/tools/bpf/bpftool/map_perf_ring.c
7671 +index 1832100d1b27..6d41323be291 100644
7672 +--- a/tools/bpf/bpftool/map_perf_ring.c
7673 ++++ b/tools/bpf/bpftool/map_perf_ring.c
7674 +@@ -194,8 +194,10 @@ int do_event_pipe(int argc, char **argv)
7675 + }
7676 +
7677 + while (argc) {
7678 +- if (argc < 2)
7679 ++ if (argc < 2) {
7680 + BAD_ARG();
7681 ++ goto err_close_map;
7682 ++ }
7683 +
7684 + if (is_prefix(*argv, "cpu")) {
7685 + char *endptr;
7686 +@@ -221,6 +223,7 @@ int do_event_pipe(int argc, char **argv)
7687 + NEXT_ARG();
7688 + } else {
7689 + BAD_ARG();
7690 ++ goto err_close_map;
7691 + }
7692 +
7693 + do_all = false;
7694 +diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
7695 +index 4f5de8245b32..6631b0b8b4ab 100644
7696 +--- a/tools/perf/tests/builtin-test.c
7697 ++++ b/tools/perf/tests/builtin-test.c
7698 +@@ -385,7 +385,7 @@ static int test_and_print(struct test *t, bool force_skip, int subtest)
7699 + if (!t->subtest.get_nr)
7700 + pr_debug("%s:", t->desc);
7701 + else
7702 +- pr_debug("%s subtest %d:", t->desc, subtest);
7703 ++ pr_debug("%s subtest %d:", t->desc, subtest + 1);
7704 +
7705 + switch (err) {
7706 + case TEST_OK:
7707 +diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh b/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh
7708 +index 3bb4c2ba7b14..197e769c2ed1 100755
7709 +--- a/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh
7710 ++++ b/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh
7711 +@@ -74,12 +74,14 @@ test_vlan_match()
7712 +
7713 + test_gretap()
7714 + {
7715 +- test_vlan_match gt4 'vlan_id 555 vlan_ethtype ip' "mirror to gretap"
7716 ++ test_vlan_match gt4 'skip_hw vlan_id 555 vlan_ethtype ip' \
7717 ++ "mirror to gretap"
7718 + }
7719 +
7720 + test_ip6gretap()
7721 + {
7722 +- test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap"
7723 ++ test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ip' \
7724 ++ "mirror to ip6gretap"
7725 + }
7726 +
7727 + test_gretap_stp()
7728 +diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_lib.sh b/tools/testing/selftests/net/forwarding/mirror_gre_lib.sh
7729 +index 619b469365be..1c18e332cd4f 100644
7730 +--- a/tools/testing/selftests/net/forwarding/mirror_gre_lib.sh
7731 ++++ b/tools/testing/selftests/net/forwarding/mirror_gre_lib.sh
7732 +@@ -62,7 +62,7 @@ full_test_span_gre_dir_vlan_ips()
7733 + "$backward_type" "$ip1" "$ip2"
7734 +
7735 + tc filter add dev $h3 ingress pref 77 prot 802.1q \
7736 +- flower $vlan_match ip_proto 0x2f \
7737 ++ flower $vlan_match \
7738 + action pass
7739 + mirror_test v$h1 $ip1 $ip2 $h3 77 10
7740 + tc filter del dev $h3 ingress pref 77
7741 +diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
7742 +index 5dbc7a08f4bd..a12274776116 100755
7743 +--- a/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
7744 ++++ b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
7745 +@@ -79,12 +79,14 @@ test_vlan_match()
7746 +
7747 + test_gretap()
7748 + {
7749 +- test_vlan_match gt4 'vlan_id 555 vlan_ethtype ip' "mirror to gretap"
7750 ++ test_vlan_match gt4 'skip_hw vlan_id 555 vlan_ethtype ip' \
7751 ++ "mirror to gretap"
7752 + }
7753 +
7754 + test_ip6gretap()
7755 + {
7756 +- test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap"
7757 ++ test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ip' \
7758 ++ "mirror to ip6gretap"
7759 + }
7760 +
7761 + test_span_gre_forbidden_cpu()