Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.17 commit in: /
Date: Mon, 09 May 2022 10:58:01
Message-Id: 1652093865.760c4239d500c231656fcae059304b1cc31d9a5a.mpagano@gentoo
1 commit: 760c4239d500c231656fcae059304b1cc31d9a5a
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Mon May 9 10:57:45 2022 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Mon May 9 10:57:45 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=760c4239
7
8 Linux patch 5.17.6
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1005_linux-5.17.6.patch | 7840 +++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 7844 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index a5f79181..91016f55 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -63,6 +63,10 @@ Patch: 1004_linux-5.17.5.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.17.5
23
24 +Patch: 1005_linux-5.17.6.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.17.6
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/1005_linux-5.17.6.patch b/1005_linux-5.17.6.patch
33 new file mode 100644
34 index 00000000..eeadfd47
35 --- /dev/null
36 +++ b/1005_linux-5.17.6.patch
37 @@ -0,0 +1,7840 @@
38 +diff --git a/Makefile b/Makefile
39 +index 3ad5dc6be3930..7ef8dd5ab6f28 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 5
45 + PATCHLEVEL = 17
46 +-SUBLEVEL = 5
47 ++SUBLEVEL = 6
48 + EXTRAVERSION =
49 + NAME = Superb Owl
50 +
51 +diff --git a/arch/arm/boot/dts/am33xx-l4.dtsi b/arch/arm/boot/dts/am33xx-l4.dtsi
52 +index c9629cb5ccd1e..7da42a5b959cf 100644
53 +--- a/arch/arm/boot/dts/am33xx-l4.dtsi
54 ++++ b/arch/arm/boot/dts/am33xx-l4.dtsi
55 +@@ -263,6 +263,8 @@
56 + compatible = "ti,am3359-tscadc";
57 + reg = <0x0 0x1000>;
58 + interrupts = <16>;
59 ++ clocks = <&adc_tsc_fck>;
60 ++ clock-names = "fck";
61 + status = "disabled";
62 + dmas = <&edma 53 0>, <&edma 57 0>;
63 + dma-names = "fifo0", "fifo1";
64 +diff --git a/arch/arm/boot/dts/am3517-evm.dts b/arch/arm/boot/dts/am3517-evm.dts
65 +index 0d2fac98ce7d2..c8b80f156ec98 100644
66 +--- a/arch/arm/boot/dts/am3517-evm.dts
67 ++++ b/arch/arm/boot/dts/am3517-evm.dts
68 +@@ -161,6 +161,8 @@
69 +
70 + /* HS USB Host PHY on PORT 1 */
71 + hsusb1_phy: hsusb1_phy {
72 ++ pinctrl-names = "default";
73 ++ pinctrl-0 = <&hsusb1_rst_pins>;
74 + compatible = "usb-nop-xceiv";
75 + reset-gpios = <&gpio2 25 GPIO_ACTIVE_LOW>; /* gpio_57 */
76 + #phy-cells = <0>;
77 +@@ -168,7 +170,9 @@
78 + };
79 +
80 + &davinci_emac {
81 +- status = "okay";
82 ++ pinctrl-names = "default";
83 ++ pinctrl-0 = <&ethernet_pins>;
84 ++ status = "okay";
85 + };
86 +
87 + &davinci_mdio {
88 +@@ -193,6 +197,8 @@
89 + };
90 +
91 + &i2c2 {
92 ++ pinctrl-names = "default";
93 ++ pinctrl-0 = <&i2c2_pins>;
94 + clock-frequency = <400000>;
95 + /* User DIP swithes [1:8] / User LEDS [1:2] */
96 + tca6416: gpio@21 {
97 +@@ -205,6 +211,8 @@
98 + };
99 +
100 + &i2c3 {
101 ++ pinctrl-names = "default";
102 ++ pinctrl-0 = <&i2c3_pins>;
103 + clock-frequency = <400000>;
104 + };
105 +
106 +@@ -223,6 +231,8 @@
107 + };
108 +
109 + &usbhshost {
110 ++ pinctrl-names = "default";
111 ++ pinctrl-0 = <&hsusb1_pins>;
112 + port1-mode = "ehci-phy";
113 + };
114 +
115 +@@ -231,8 +241,35 @@
116 + };
117 +
118 + &omap3_pmx_core {
119 +- pinctrl-names = "default";
120 +- pinctrl-0 = <&hsusb1_rst_pins>;
121 ++
122 ++ ethernet_pins: pinmux_ethernet_pins {
123 ++ pinctrl-single,pins = <
124 ++ OMAP3_CORE1_IOPAD(0x21fe, PIN_INPUT | MUX_MODE0) /* rmii_mdio_data */
125 ++ OMAP3_CORE1_IOPAD(0x2200, MUX_MODE0) /* rmii_mdio_clk */
126 ++ OMAP3_CORE1_IOPAD(0x2202, PIN_INPUT_PULLDOWN | MUX_MODE0) /* rmii_rxd0 */
127 ++ OMAP3_CORE1_IOPAD(0x2204, PIN_INPUT_PULLDOWN | MUX_MODE0) /* rmii_rxd1 */
128 ++ OMAP3_CORE1_IOPAD(0x2206, PIN_INPUT_PULLDOWN | MUX_MODE0) /* rmii_crs_dv */
129 ++ OMAP3_CORE1_IOPAD(0x2208, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* rmii_rxer */
130 ++ OMAP3_CORE1_IOPAD(0x220a, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* rmii_txd0 */
131 ++ OMAP3_CORE1_IOPAD(0x220c, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* rmii_txd1 */
132 ++ OMAP3_CORE1_IOPAD(0x220e, PIN_OUTPUT_PULLDOWN |MUX_MODE0) /* rmii_txen */
133 ++ OMAP3_CORE1_IOPAD(0x2210, PIN_INPUT_PULLDOWN | MUX_MODE0) /* rmii_50mhz_clk */
134 ++ >;
135 ++ };
136 ++
137 ++ i2c2_pins: pinmux_i2c2_pins {
138 ++ pinctrl-single,pins = <
139 ++ OMAP3_CORE1_IOPAD(0x21be, PIN_INPUT_PULLUP | MUX_MODE0) /* i2c2_scl */
140 ++ OMAP3_CORE1_IOPAD(0x21c0, PIN_INPUT_PULLUP | MUX_MODE0) /* i2c2_sda */
141 ++ >;
142 ++ };
143 ++
144 ++ i2c3_pins: pinmux_i2c3_pins {
145 ++ pinctrl-single,pins = <
146 ++ OMAP3_CORE1_IOPAD(0x21c2, PIN_INPUT_PULLUP | MUX_MODE0) /* i2c3_scl */
147 ++ OMAP3_CORE1_IOPAD(0x21c4, PIN_INPUT_PULLUP | MUX_MODE0) /* i2c3_sda */
148 ++ >;
149 ++ };
150 +
151 + leds_pins: pinmux_leds_pins {
152 + pinctrl-single,pins = <
153 +@@ -300,8 +337,6 @@
154 + };
155 +
156 + &omap3_pmx_core2 {
157 +- pinctrl-names = "default";
158 +- pinctrl-0 = <&hsusb1_pins>;
159 +
160 + hsusb1_pins: pinmux_hsusb1_pins {
161 + pinctrl-single,pins = <
162 +diff --git a/arch/arm/boot/dts/am3517-som.dtsi b/arch/arm/boot/dts/am3517-som.dtsi
163 +index 8b669e2eafec4..f7b680f6c48ad 100644
164 +--- a/arch/arm/boot/dts/am3517-som.dtsi
165 ++++ b/arch/arm/boot/dts/am3517-som.dtsi
166 +@@ -69,6 +69,8 @@
167 + };
168 +
169 + &i2c1 {
170 ++ pinctrl-names = "default";
171 ++ pinctrl-0 = <&i2c1_pins>;
172 + clock-frequency = <400000>;
173 +
174 + s35390a: s35390a@30 {
175 +@@ -179,6 +181,13 @@
176 +
177 + &omap3_pmx_core {
178 +
179 ++ i2c1_pins: pinmux_i2c1_pins {
180 ++ pinctrl-single,pins = <
181 ++ OMAP3_CORE1_IOPAD(0x21ba, PIN_INPUT_PULLUP | MUX_MODE0) /* i2c1_scl */
182 ++ OMAP3_CORE1_IOPAD(0x21bc, PIN_INPUT_PULLUP | MUX_MODE0) /* i2c1_sda */
183 ++ >;
184 ++ };
185 ++
186 + wl12xx_buffer_pins: pinmux_wl12xx_buffer_pins {
187 + pinctrl-single,pins = <
188 + OMAP3_CORE1_IOPAD(0x2156, PIN_OUTPUT | MUX_MODE4) /* mmc1_dat7.gpio_129 */
189 +diff --git a/arch/arm/boot/dts/at91-sama5d3_xplained.dts b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
190 +index d72c042f28507..a49c2966b41e2 100644
191 +--- a/arch/arm/boot/dts/at91-sama5d3_xplained.dts
192 ++++ b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
193 +@@ -57,8 +57,8 @@
194 + };
195 +
196 + spi0: spi@f0004000 {
197 +- pinctrl-names = "default";
198 +- pinctrl-0 = <&pinctrl_spi0_cs>;
199 ++ pinctrl-names = "default", "cs";
200 ++ pinctrl-1 = <&pinctrl_spi0_cs>;
201 + cs-gpios = <&pioD 13 0>, <0>, <0>, <&pioD 16 0>;
202 + status = "okay";
203 + };
204 +@@ -171,8 +171,8 @@
205 + };
206 +
207 + spi1: spi@f8008000 {
208 +- pinctrl-names = "default";
209 +- pinctrl-0 = <&pinctrl_spi1_cs>;
210 ++ pinctrl-names = "default", "cs";
211 ++ pinctrl-1 = <&pinctrl_spi1_cs>;
212 + cs-gpios = <&pioC 25 0>;
213 + status = "okay";
214 + };
215 +diff --git a/arch/arm/boot/dts/at91-sama5d4_xplained.dts b/arch/arm/boot/dts/at91-sama5d4_xplained.dts
216 +index d241c24f0d836..e519d27479362 100644
217 +--- a/arch/arm/boot/dts/at91-sama5d4_xplained.dts
218 ++++ b/arch/arm/boot/dts/at91-sama5d4_xplained.dts
219 +@@ -81,8 +81,8 @@
220 + };
221 +
222 + spi1: spi@fc018000 {
223 +- pinctrl-names = "default";
224 +- pinctrl-0 = <&pinctrl_spi0_cs>;
225 ++ pinctrl-names = "default", "cs";
226 ++ pinctrl-1 = <&pinctrl_spi1_cs>;
227 + cs-gpios = <&pioB 21 0>;
228 + status = "okay";
229 + };
230 +@@ -140,7 +140,7 @@
231 + atmel,pins =
232 + <AT91_PIOE 1 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_UP_DEGLITCH>;
233 + };
234 +- pinctrl_spi0_cs: spi0_cs_default {
235 ++ pinctrl_spi1_cs: spi1_cs_default {
236 + atmel,pins =
237 + <AT91_PIOB 21 AT91_PERIPH_GPIO AT91_PINCTRL_NONE>;
238 + };
239 +diff --git a/arch/arm/boot/dts/at91-sama7g5ek.dts b/arch/arm/boot/dts/at91-sama7g5ek.dts
240 +index ccf9e224da781..fed260473b6b8 100644
241 +--- a/arch/arm/boot/dts/at91-sama7g5ek.dts
242 ++++ b/arch/arm/boot/dts/at91-sama7g5ek.dts
243 +@@ -465,7 +465,7 @@
244 + pinctrl_flx3_default: flx3_default {
245 + pinmux = <PIN_PD16__FLEXCOM3_IO0>,
246 + <PIN_PD17__FLEXCOM3_IO1>;
247 +- bias-disable;
248 ++ bias-pull-up;
249 + };
250 +
251 + pinctrl_flx4_default: flx4_default {
252 +diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
253 +index 87bb39060e8be..ca03685f0f086 100644
254 +--- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
255 ++++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
256 +@@ -219,6 +219,12 @@
257 + wm8731: wm8731@1b {
258 + compatible = "wm8731";
259 + reg = <0x1b>;
260 ++
261 ++ /* PCK0 at 12MHz */
262 ++ clocks = <&pmc PMC_TYPE_SYSTEM 8>;
263 ++ clock-names = "mclk";
264 ++ assigned-clocks = <&pmc PMC_TYPE_SYSTEM 8>;
265 ++ assigned-clock-rates = <12000000>;
266 + };
267 + };
268 +
269 +diff --git a/arch/arm/boot/dts/dra7-l4.dtsi b/arch/arm/boot/dts/dra7-l4.dtsi
270 +index 0a11bacffc1f1..5733e3a4ea8e7 100644
271 +--- a/arch/arm/boot/dts/dra7-l4.dtsi
272 ++++ b/arch/arm/boot/dts/dra7-l4.dtsi
273 +@@ -4188,11 +4188,11 @@
274 + reg = <0x1d0010 0x4>;
275 + reg-names = "sysc";
276 + ti,sysc-midle = <SYSC_IDLE_FORCE>,
277 +- <SYSC_IDLE_NO>,
278 +- <SYSC_IDLE_SMART>;
279 ++ <SYSC_IDLE_NO>;
280 + ti,sysc-sidle = <SYSC_IDLE_FORCE>,
281 + <SYSC_IDLE_NO>,
282 + <SYSC_IDLE_SMART>;
283 ++ power-domains = <&prm_vpe>;
284 + clocks = <&vpe_clkctrl DRA7_VPE_VPE_CLKCTRL 0>;
285 + clock-names = "fck";
286 + #address-cells = <1>;
287 +diff --git a/arch/arm/boot/dts/imx6qdl-apalis.dtsi b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
288 +index ed2739e390856..bd763bae596b0 100644
289 +--- a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
290 ++++ b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
291 +@@ -286,6 +286,8 @@
292 + codec: sgtl5000@a {
293 + compatible = "fsl,sgtl5000";
294 + reg = <0x0a>;
295 ++ pinctrl-names = "default";
296 ++ pinctrl-0 = <&pinctrl_sgtl5000>;
297 + clocks = <&clks IMX6QDL_CLK_CKO>;
298 + VDDA-supply = <&reg_module_3v3_audio>;
299 + VDDIO-supply = <&reg_module_3v3>;
300 +@@ -517,8 +519,6 @@
301 + MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x130b0
302 + MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS 0x130b0
303 + MX6QDL_PAD_DISP0_DAT23__AUD4_RXD 0x130b0
304 +- /* SGTL5000 sys_mclk */
305 +- MX6QDL_PAD_GPIO_5__CCM_CLKO1 0x130b0
306 + >;
307 + };
308 +
309 +@@ -811,6 +811,12 @@
310 + >;
311 + };
312 +
313 ++ pinctrl_sgtl5000: sgtl5000grp {
314 ++ fsl,pins = <
315 ++ MX6QDL_PAD_GPIO_5__CCM_CLKO1 0x130b0
316 ++ >;
317 ++ };
318 ++
319 + pinctrl_spdif: spdifgrp {
320 + fsl,pins = <
321 + MX6QDL_PAD_GPIO_16__SPDIF_IN 0x1b0b0
322 +diff --git a/arch/arm/boot/dts/imx6ull-colibri.dtsi b/arch/arm/boot/dts/imx6ull-colibri.dtsi
323 +index 7f35a06dff95b..951a2a6c5a657 100644
324 +--- a/arch/arm/boot/dts/imx6ull-colibri.dtsi
325 ++++ b/arch/arm/boot/dts/imx6ull-colibri.dtsi
326 +@@ -37,7 +37,7 @@
327 +
328 + reg_sd1_vmmc: regulator-sd1-vmmc {
329 + compatible = "regulator-gpio";
330 +- gpio = <&gpio5 9 GPIO_ACTIVE_HIGH>;
331 ++ gpios = <&gpio5 9 GPIO_ACTIVE_HIGH>;
332 + pinctrl-names = "default";
333 + pinctrl-0 = <&pinctrl_snvs_reg_sd>;
334 + regulator-always-on;
335 +diff --git a/arch/arm/boot/dts/logicpd-som-lv-35xx-devkit.dts b/arch/arm/boot/dts/logicpd-som-lv-35xx-devkit.dts
336 +index 2a0a98fe67f06..3240c67e0c392 100644
337 +--- a/arch/arm/boot/dts/logicpd-som-lv-35xx-devkit.dts
338 ++++ b/arch/arm/boot/dts/logicpd-som-lv-35xx-devkit.dts
339 +@@ -11,3 +11,18 @@
340 + model = "LogicPD Zoom OMAP35xx SOM-LV Development Kit";
341 + compatible = "logicpd,dm3730-som-lv-devkit", "ti,omap3430", "ti,omap3";
342 + };
343 ++
344 ++&omap3_pmx_core2 {
345 ++ pinctrl-names = "default";
346 ++ pinctrl-0 = <&hsusb2_2_pins>;
347 ++ hsusb2_2_pins: pinmux_hsusb2_2_pins {
348 ++ pinctrl-single,pins = <
349 ++ OMAP3430_CORE2_IOPAD(0x25f0, PIN_OUTPUT | MUX_MODE3) /* etk_d10.hsusb2_clk */
350 ++ OMAP3430_CORE2_IOPAD(0x25f2, PIN_OUTPUT | MUX_MODE3) /* etk_d11.hsusb2_stp */
351 ++ OMAP3430_CORE2_IOPAD(0x25f4, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d12.hsusb2_dir */
352 ++ OMAP3430_CORE2_IOPAD(0x25f6, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d13.hsusb2_nxt */
353 ++ OMAP3430_CORE2_IOPAD(0x25f8, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d14.hsusb2_data0 */
354 ++ OMAP3430_CORE2_IOPAD(0x25fa, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d15.hsusb2_data1 */
355 ++ >;
356 ++ };
357 ++};
358 +diff --git a/arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts b/arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts
359 +index a604d92221a4f..c757f0d7781c1 100644
360 +--- a/arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts
361 ++++ b/arch/arm/boot/dts/logicpd-som-lv-37xx-devkit.dts
362 +@@ -11,3 +11,18 @@
363 + model = "LogicPD Zoom DM3730 SOM-LV Development Kit";
364 + compatible = "logicpd,dm3730-som-lv-devkit", "ti,omap3630", "ti,omap3";
365 + };
366 ++
367 ++&omap3_pmx_core2 {
368 ++ pinctrl-names = "default";
369 ++ pinctrl-0 = <&hsusb2_2_pins>;
370 ++ hsusb2_2_pins: pinmux_hsusb2_2_pins {
371 ++ pinctrl-single,pins = <
372 ++ OMAP3630_CORE2_IOPAD(0x25f0, PIN_OUTPUT | MUX_MODE3) /* etk_d10.hsusb2_clk */
373 ++ OMAP3630_CORE2_IOPAD(0x25f2, PIN_OUTPUT | MUX_MODE3) /* etk_d11.hsusb2_stp */
374 ++ OMAP3630_CORE2_IOPAD(0x25f4, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d12.hsusb2_dir */
375 ++ OMAP3630_CORE2_IOPAD(0x25f6, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d13.hsusb2_nxt */
376 ++ OMAP3630_CORE2_IOPAD(0x25f8, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d14.hsusb2_data0 */
377 ++ OMAP3630_CORE2_IOPAD(0x25fa, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d15.hsusb2_data1 */
378 ++ >;
379 ++ };
380 ++};
381 +diff --git a/arch/arm/boot/dts/logicpd-som-lv.dtsi b/arch/arm/boot/dts/logicpd-som-lv.dtsi
382 +index b56524cc7fe27..55b619c99e24d 100644
383 +--- a/arch/arm/boot/dts/logicpd-som-lv.dtsi
384 ++++ b/arch/arm/boot/dts/logicpd-som-lv.dtsi
385 +@@ -265,21 +265,6 @@
386 + };
387 + };
388 +
389 +-&omap3_pmx_core2 {
390 +- pinctrl-names = "default";
391 +- pinctrl-0 = <&hsusb2_2_pins>;
392 +- hsusb2_2_pins: pinmux_hsusb2_2_pins {
393 +- pinctrl-single,pins = <
394 +- OMAP3630_CORE2_IOPAD(0x25f0, PIN_OUTPUT | MUX_MODE3) /* etk_d10.hsusb2_clk */
395 +- OMAP3630_CORE2_IOPAD(0x25f2, PIN_OUTPUT | MUX_MODE3) /* etk_d11.hsusb2_stp */
396 +- OMAP3630_CORE2_IOPAD(0x25f4, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d12.hsusb2_dir */
397 +- OMAP3630_CORE2_IOPAD(0x25f6, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d13.hsusb2_nxt */
398 +- OMAP3630_CORE2_IOPAD(0x25f8, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d14.hsusb2_data0 */
399 +- OMAP3630_CORE2_IOPAD(0x25fa, PIN_INPUT_PULLDOWN | MUX_MODE3) /* etk_d15.hsusb2_data1 */
400 +- >;
401 +- };
402 +-};
403 +-
404 + &uart2 {
405 + interrupts-extended = <&intc 73 &omap3_pmx_core OMAP3_UART2_RX>;
406 + pinctrl-names = "default";
407 +diff --git a/arch/arm/boot/dts/omap3-gta04.dtsi b/arch/arm/boot/dts/omap3-gta04.dtsi
408 +index 7e3d8147e2c1c..0365f06165e90 100644
409 +--- a/arch/arm/boot/dts/omap3-gta04.dtsi
410 ++++ b/arch/arm/boot/dts/omap3-gta04.dtsi
411 +@@ -31,6 +31,8 @@
412 + aliases {
413 + display0 = &lcd;
414 + display1 = &tv0;
415 ++ /delete-property/ mmc2;
416 ++ /delete-property/ mmc3;
417 + };
418 +
419 + ldo_3v3: fixedregulator {
420 +diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
421 +index f7d993628cb70..a9c1efcf7c9cf 100644
422 +--- a/arch/arm/mach-exynos/Kconfig
423 ++++ b/arch/arm/mach-exynos/Kconfig
424 +@@ -17,7 +17,6 @@ menuconfig ARCH_EXYNOS
425 + select EXYNOS_PMU
426 + select EXYNOS_SROM
427 + select EXYNOS_PM_DOMAINS if PM_GENERIC_DOMAINS
428 +- select GPIOLIB
429 + select HAVE_ARM_ARCH_TIMER if ARCH_EXYNOS5
430 + select HAVE_ARM_SCU if SMP
431 + select PINCTRL
432 +diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c
433 +index 5c3845730dbf5..0b80f8bcd3047 100644
434 +--- a/arch/arm/mach-omap2/omap4-common.c
435 ++++ b/arch/arm/mach-omap2/omap4-common.c
436 +@@ -314,10 +314,12 @@ void __init omap_gic_of_init(void)
437 +
438 + np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-gic");
439 + gic_dist_base_addr = of_iomap(np, 0);
440 ++ of_node_put(np);
441 + WARN_ON(!gic_dist_base_addr);
442 +
443 + np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-twd-timer");
444 + twd_base = of_iomap(np, 0);
445 ++ of_node_put(np);
446 + WARN_ON(!twd_base);
447 +
448 + skip_errata_init:
449 +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-a311d.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d.dtsi
450 +index d61f43052a344..8e9ad1e51d665 100644
451 +--- a/arch/arm64/boot/dts/amlogic/meson-g12b-a311d.dtsi
452 ++++ b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d.dtsi
453 +@@ -11,26 +11,6 @@
454 + compatible = "operating-points-v2";
455 + opp-shared;
456 +
457 +- opp-100000000 {
458 +- opp-hz = /bits/ 64 <100000000>;
459 +- opp-microvolt = <731000>;
460 +- };
461 +-
462 +- opp-250000000 {
463 +- opp-hz = /bits/ 64 <250000000>;
464 +- opp-microvolt = <731000>;
465 +- };
466 +-
467 +- opp-500000000 {
468 +- opp-hz = /bits/ 64 <500000000>;
469 +- opp-microvolt = <731000>;
470 +- };
471 +-
472 +- opp-667000000 {
473 +- opp-hz = /bits/ 64 <667000000>;
474 +- opp-microvolt = <731000>;
475 +- };
476 +-
477 + opp-1000000000 {
478 + opp-hz = /bits/ 64 <1000000000>;
479 + opp-microvolt = <761000>;
480 +@@ -71,26 +51,6 @@
481 + compatible = "operating-points-v2";
482 + opp-shared;
483 +
484 +- opp-100000000 {
485 +- opp-hz = /bits/ 64 <100000000>;
486 +- opp-microvolt = <731000>;
487 +- };
488 +-
489 +- opp-250000000 {
490 +- opp-hz = /bits/ 64 <250000000>;
491 +- opp-microvolt = <731000>;
492 +- };
493 +-
494 +- opp-500000000 {
495 +- opp-hz = /bits/ 64 <500000000>;
496 +- opp-microvolt = <731000>;
497 +- };
498 +-
499 +- opp-667000000 {
500 +- opp-hz = /bits/ 64 <667000000>;
501 +- opp-microvolt = <731000>;
502 +- };
503 +-
504 + opp-1000000000 {
505 + opp-hz = /bits/ 64 <1000000000>;
506 + opp-microvolt = <731000>;
507 +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-s922x.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12b-s922x.dtsi
508 +index 1e5d0ee5d541b..44c23c984034c 100644
509 +--- a/arch/arm64/boot/dts/amlogic/meson-g12b-s922x.dtsi
510 ++++ b/arch/arm64/boot/dts/amlogic/meson-g12b-s922x.dtsi
511 +@@ -11,26 +11,6 @@
512 + compatible = "operating-points-v2";
513 + opp-shared;
514 +
515 +- opp-100000000 {
516 +- opp-hz = /bits/ 64 <100000000>;
517 +- opp-microvolt = <731000>;
518 +- };
519 +-
520 +- opp-250000000 {
521 +- opp-hz = /bits/ 64 <250000000>;
522 +- opp-microvolt = <731000>;
523 +- };
524 +-
525 +- opp-500000000 {
526 +- opp-hz = /bits/ 64 <500000000>;
527 +- opp-microvolt = <731000>;
528 +- };
529 +-
530 +- opp-667000000 {
531 +- opp-hz = /bits/ 64 <667000000>;
532 +- opp-microvolt = <731000>;
533 +- };
534 +-
535 + opp-1000000000 {
536 + opp-hz = /bits/ 64 <1000000000>;
537 + opp-microvolt = <731000>;
538 +@@ -76,26 +56,6 @@
539 + compatible = "operating-points-v2";
540 + opp-shared;
541 +
542 +- opp-100000000 {
543 +- opp-hz = /bits/ 64 <100000000>;
544 +- opp-microvolt = <751000>;
545 +- };
546 +-
547 +- opp-250000000 {
548 +- opp-hz = /bits/ 64 <250000000>;
549 +- opp-microvolt = <751000>;
550 +- };
551 +-
552 +- opp-500000000 {
553 +- opp-hz = /bits/ 64 <500000000>;
554 +- opp-microvolt = <751000>;
555 +- };
556 +-
557 +- opp-667000000 {
558 +- opp-hz = /bits/ 64 <667000000>;
559 +- opp-microvolt = <751000>;
560 +- };
561 +-
562 + opp-1000000000 {
563 + opp-hz = /bits/ 64 <1000000000>;
564 + opp-microvolt = <771000>;
565 +diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m5.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m5.dts
566 +index 5751c48620edf..cadba194b149b 100644
567 +--- a/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m5.dts
568 ++++ b/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m5.dts
569 +@@ -437,6 +437,7 @@
570 + "",
571 + "eMMC_RST#", /* BOOT_12 */
572 + "eMMC_DS", /* BOOT_13 */
573 ++ "", "",
574 + /* GPIOC */
575 + "SD_D0_B", /* GPIOC_0 */
576 + "SD_D1_B", /* GPIOC_1 */
577 +diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi b/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi
578 +index 3d8b1f4f2001b..78bdbd2ccc9de 100644
579 +--- a/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi
580 ++++ b/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi
581 +@@ -95,26 +95,6 @@
582 + compatible = "operating-points-v2";
583 + opp-shared;
584 +
585 +- opp-100000000 {
586 +- opp-hz = /bits/ 64 <100000000>;
587 +- opp-microvolt = <730000>;
588 +- };
589 +-
590 +- opp-250000000 {
591 +- opp-hz = /bits/ 64 <250000000>;
592 +- opp-microvolt = <730000>;
593 +- };
594 +-
595 +- opp-500000000 {
596 +- opp-hz = /bits/ 64 <500000000>;
597 +- opp-microvolt = <730000>;
598 +- };
599 +-
600 +- opp-667000000 {
601 +- opp-hz = /bits/ 64 <666666666>;
602 +- opp-microvolt = <750000>;
603 +- };
604 +-
605 + opp-1000000000 {
606 + opp-hz = /bits/ 64 <1000000000>;
607 + opp-microvolt = <770000>;
608 +diff --git a/arch/arm64/boot/dts/freescale/imx8mm-venice-gw71xx.dtsi b/arch/arm64/boot/dts/freescale/imx8mm-venice-gw71xx.dtsi
609 +index 28012279f6f67..7ebbba6bd1665 100644
610 +--- a/arch/arm64/boot/dts/freescale/imx8mm-venice-gw71xx.dtsi
611 ++++ b/arch/arm64/boot/dts/freescale/imx8mm-venice-gw71xx.dtsi
612 +@@ -103,12 +103,14 @@
613 +
614 + &usbotg1 {
615 + dr_mode = "otg";
616 ++ over-current-active-low;
617 + vbus-supply = <&reg_usb_otg1_vbus>;
618 + status = "okay";
619 + };
620 +
621 + &usbotg2 {
622 + dr_mode = "host";
623 ++ disable-over-current;
624 + status = "okay";
625 + };
626 +
627 +@@ -166,7 +168,7 @@
628 + fsl,pins = <
629 + MX8MM_IOMUXC_ECSPI2_SCLK_ECSPI2_SCLK 0xd6
630 + MX8MM_IOMUXC_ECSPI2_MOSI_ECSPI2_MOSI 0xd6
631 +- MX8MM_IOMUXC_ECSPI2_SCLK_ECSPI2_SCLK 0xd6
632 ++ MX8MM_IOMUXC_ECSPI2_MISO_ECSPI2_MISO 0xd6
633 + MX8MM_IOMUXC_ECSPI2_SS0_GPIO5_IO13 0xd6
634 + >;
635 + };
636 +diff --git a/arch/arm64/boot/dts/freescale/imx8mm-venice-gw72xx.dtsi b/arch/arm64/boot/dts/freescale/imx8mm-venice-gw72xx.dtsi
637 +index 27afa46a253a3..4337a231bbea5 100644
638 +--- a/arch/arm64/boot/dts/freescale/imx8mm-venice-gw72xx.dtsi
639 ++++ b/arch/arm64/boot/dts/freescale/imx8mm-venice-gw72xx.dtsi
640 +@@ -139,12 +139,14 @@
641 +
642 + &usbotg1 {
643 + dr_mode = "otg";
644 ++ over-current-active-low;
645 + vbus-supply = <&reg_usb_otg1_vbus>;
646 + status = "okay";
647 + };
648 +
649 + &usbotg2 {
650 + dr_mode = "host";
651 ++ disable-over-current;
652 + vbus-supply = <&reg_usb_otg2_vbus>;
653 + status = "okay";
654 + };
655 +@@ -231,7 +233,7 @@
656 + fsl,pins = <
657 + MX8MM_IOMUXC_ECSPI2_SCLK_ECSPI2_SCLK 0xd6
658 + MX8MM_IOMUXC_ECSPI2_MOSI_ECSPI2_MOSI 0xd6
659 +- MX8MM_IOMUXC_ECSPI2_SCLK_ECSPI2_SCLK 0xd6
660 ++ MX8MM_IOMUXC_ECSPI2_MISO_ECSPI2_MISO 0xd6
661 + MX8MM_IOMUXC_ECSPI2_SS0_GPIO5_IO13 0xd6
662 + >;
663 + };
664 +diff --git a/arch/arm64/boot/dts/freescale/imx8mm-venice-gw73xx.dtsi b/arch/arm64/boot/dts/freescale/imx8mm-venice-gw73xx.dtsi
665 +index a59e849c7be29..8eba6079bbf38 100644
666 +--- a/arch/arm64/boot/dts/freescale/imx8mm-venice-gw73xx.dtsi
667 ++++ b/arch/arm64/boot/dts/freescale/imx8mm-venice-gw73xx.dtsi
668 +@@ -166,12 +166,14 @@
669 +
670 + &usbotg1 {
671 + dr_mode = "otg";
672 ++ over-current-active-low;
673 + vbus-supply = <&reg_usb_otg1_vbus>;
674 + status = "okay";
675 + };
676 +
677 + &usbotg2 {
678 + dr_mode = "host";
679 ++ disable-over-current;
680 + vbus-supply = <&reg_usb_otg2_vbus>;
681 + status = "okay";
682 + };
683 +@@ -280,7 +282,7 @@
684 + fsl,pins = <
685 + MX8MM_IOMUXC_ECSPI2_SCLK_ECSPI2_SCLK 0xd6
686 + MX8MM_IOMUXC_ECSPI2_MOSI_ECSPI2_MOSI 0xd6
687 +- MX8MM_IOMUXC_ECSPI2_SCLK_ECSPI2_SCLK 0xd6
688 ++ MX8MM_IOMUXC_ECSPI2_MISO_ECSPI2_MISO 0xd6
689 + MX8MM_IOMUXC_ECSPI2_SS0_GPIO5_IO13 0xd6
690 + >;
691 + };
692 +diff --git a/arch/arm64/boot/dts/freescale/imx8mn-ddr4-evk.dts b/arch/arm64/boot/dts/freescale/imx8mn-ddr4-evk.dts
693 +index 7dfee715a2c4d..d8ce217c60166 100644
694 +--- a/arch/arm64/boot/dts/freescale/imx8mn-ddr4-evk.dts
695 ++++ b/arch/arm64/boot/dts/freescale/imx8mn-ddr4-evk.dts
696 +@@ -59,6 +59,10 @@
697 + interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
698 + rohm,reset-snvs-powered;
699 +
700 ++ #clock-cells = <0>;
701 ++ clocks = <&osc_32k 0>;
702 ++ clock-output-names = "clk-32k-out";
703 ++
704 + regulators {
705 + buck1_reg: BUCK1 {
706 + regulator-name = "buck1";
707 +diff --git a/arch/arm64/boot/dts/freescale/imx8mn.dtsi b/arch/arm64/boot/dts/freescale/imx8mn.dtsi
708 +index b8d49d5f26681..98bfb53491fc0 100644
709 +--- a/arch/arm64/boot/dts/freescale/imx8mn.dtsi
710 ++++ b/arch/arm64/boot/dts/freescale/imx8mn.dtsi
711 +@@ -291,7 +291,7 @@
712 + ranges;
713 +
714 + sai2: sai@30020000 {
715 +- compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai";
716 ++ compatible = "fsl,imx8mn-sai", "fsl,imx8mq-sai";
717 + reg = <0x30020000 0x10000>;
718 + interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
719 + clocks = <&clk IMX8MN_CLK_SAI2_IPG>,
720 +@@ -305,7 +305,7 @@
721 + };
722 +
723 + sai3: sai@30030000 {
724 +- compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai";
725 ++ compatible = "fsl,imx8mn-sai", "fsl,imx8mq-sai";
726 + reg = <0x30030000 0x10000>;
727 + interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;
728 + clocks = <&clk IMX8MN_CLK_SAI3_IPG>,
729 +@@ -319,7 +319,7 @@
730 + };
731 +
732 + sai5: sai@30050000 {
733 +- compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai";
734 ++ compatible = "fsl,imx8mn-sai", "fsl,imx8mq-sai";
735 + reg = <0x30050000 0x10000>;
736 + interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
737 + clocks = <&clk IMX8MN_CLK_SAI5_IPG>,
738 +@@ -335,7 +335,7 @@
739 + };
740 +
741 + sai6: sai@30060000 {
742 +- compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai";
743 ++ compatible = "fsl,imx8mn-sai", "fsl,imx8mq-sai";
744 + reg = <0x30060000 0x10000>;
745 + interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
746 + clocks = <&clk IMX8MN_CLK_SAI6_IPG>,
747 +@@ -392,7 +392,7 @@
748 + };
749 +
750 + sai7: sai@300b0000 {
751 +- compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai";
752 ++ compatible = "fsl,imx8mn-sai", "fsl,imx8mq-sai";
753 + reg = <0x300b0000 0x10000>;
754 + interrupts = <GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
755 + clocks = <&clk IMX8MN_CLK_SAI7_IPG>,
756 +diff --git a/arch/arm64/boot/dts/freescale/imx8mq-tqma8mq.dtsi b/arch/arm64/boot/dts/freescale/imx8mq-tqma8mq.dtsi
757 +index 8aedcddfeab87..2c63b01e93e01 100644
758 +--- a/arch/arm64/boot/dts/freescale/imx8mq-tqma8mq.dtsi
759 ++++ b/arch/arm64/boot/dts/freescale/imx8mq-tqma8mq.dtsi
760 +@@ -253,7 +253,7 @@
761 + #address-cells = <1>;
762 + #size-cells = <1>;
763 + spi-max-frequency = <84000000>;
764 +- spi-tx-bus-width = <4>;
765 ++ spi-tx-bus-width = <1>;
766 + spi-rx-bus-width = <4>;
767 + };
768 + };
769 +diff --git a/arch/arm64/boot/dts/freescale/imx8qm.dtsi b/arch/arm64/boot/dts/freescale/imx8qm.dtsi
770 +index 4a7c017b5f31c..8fecd54198fbf 100644
771 +--- a/arch/arm64/boot/dts/freescale/imx8qm.dtsi
772 ++++ b/arch/arm64/boot/dts/freescale/imx8qm.dtsi
773 +@@ -193,7 +193,7 @@
774 + };
775 +
776 + clk: clock-controller {
777 +- compatible = "fsl,imx8qxp-clk", "fsl,scu-clk";
778 ++ compatible = "fsl,imx8qm-clk", "fsl,scu-clk";
779 + #clock-cells = <2>;
780 + };
781 +
782 +diff --git a/arch/powerpc/kernel/reloc_64.S b/arch/powerpc/kernel/reloc_64.S
783 +index 02d4719bf43a8..232e4549defe1 100644
784 +--- a/arch/powerpc/kernel/reloc_64.S
785 ++++ b/arch/powerpc/kernel/reloc_64.S
786 +@@ -8,8 +8,10 @@
787 + #include <asm/ppc_asm.h>
788 +
789 + RELA = 7
790 +-RELACOUNT = 0x6ffffff9
791 ++RELASZ = 8
792 ++RELAENT = 9
793 + R_PPC64_RELATIVE = 22
794 ++R_PPC64_UADDR64 = 43
795 +
796 + /*
797 + * r3 = desired final address of kernel
798 +@@ -25,29 +27,38 @@ _GLOBAL(relocate)
799 + add r9,r9,r12 /* r9 has runtime addr of .rela.dyn section */
800 + ld r10,(p_st - 0b)(r12)
801 + add r10,r10,r12 /* r10 has runtime addr of _stext */
802 ++ ld r13,(p_sym - 0b)(r12)
803 ++ add r13,r13,r12 /* r13 has runtime addr of .dynsym */
804 +
805 + /*
806 +- * Scan the dynamic section for the RELA and RELACOUNT entries.
807 ++ * Scan the dynamic section for the RELA, RELASZ and RELAENT entries.
808 + */
809 + li r7,0
810 + li r8,0
811 +-1: ld r6,0(r11) /* get tag */
812 ++.Ltags:
813 ++ ld r6,0(r11) /* get tag */
814 + cmpdi r6,0
815 +- beq 4f /* end of list */
816 ++ beq .Lend_of_list /* end of list */
817 + cmpdi r6,RELA
818 + bne 2f
819 + ld r7,8(r11) /* get RELA pointer in r7 */
820 +- b 3f
821 +-2: addis r6,r6,(-RELACOUNT)@ha
822 +- cmpdi r6,RELACOUNT@l
823 ++ b 4f
824 ++2: cmpdi r6,RELASZ
825 + bne 3f
826 +- ld r8,8(r11) /* get RELACOUNT value in r8 */
827 +-3: addi r11,r11,16
828 +- b 1b
829 +-4: cmpdi r7,0 /* check we have both RELA and RELACOUNT */
830 ++ ld r8,8(r11) /* get RELASZ value in r8 */
831 ++ b 4f
832 ++3: cmpdi r6,RELAENT
833 ++ bne 4f
834 ++ ld r12,8(r11) /* get RELAENT value in r12 */
835 ++4: addi r11,r11,16
836 ++ b .Ltags
837 ++.Lend_of_list:
838 ++ cmpdi r7,0 /* check we have RELA, RELASZ, RELAENT */
839 + cmpdi cr1,r8,0
840 +- beq 6f
841 +- beq cr1,6f
842 ++ beq .Lout
843 ++ beq cr1,.Lout
844 ++ cmpdi r12,0
845 ++ beq .Lout
846 +
847 + /*
848 + * Work out linktime address of _stext and hence the
849 +@@ -62,23 +73,39 @@ _GLOBAL(relocate)
850 +
851 + /*
852 + * Run through the list of relocations and process the
853 +- * R_PPC64_RELATIVE ones.
854 ++ * R_PPC64_RELATIVE and R_PPC64_UADDR64 ones.
855 + */
856 ++ divd r8,r8,r12 /* RELASZ / RELAENT */
857 + mtctr r8
858 +-5: ld r0,8(9) /* ELF64_R_TYPE(reloc->r_info) */
859 ++.Lrels: ld r0,8(r9) /* ELF64_R_TYPE(reloc->r_info) */
860 + cmpdi r0,R_PPC64_RELATIVE
861 +- bne 6f
862 ++ bne .Luaddr64
863 + ld r6,0(r9) /* reloc->r_offset */
864 + ld r0,16(r9) /* reloc->r_addend */
865 ++ b .Lstore
866 ++.Luaddr64:
867 ++ srdi r14,r0,32 /* ELF64_R_SYM(reloc->r_info) */
868 ++ clrldi r0,r0,32
869 ++ cmpdi r0,R_PPC64_UADDR64
870 ++ bne .Lnext
871 ++ ld r6,0(r9)
872 ++ ld r0,16(r9)
873 ++ mulli r14,r14,24 /* 24 == sizeof(elf64_sym) */
874 ++ add r14,r14,r13 /* elf64_sym[ELF64_R_SYM] */
875 ++ ld r14,8(r14)
876 ++ add r0,r0,r14
877 ++.Lstore:
878 + add r0,r0,r3
879 + stdx r0,r7,r6
880 +- addi r9,r9,24
881 +- bdnz 5b
882 +-
883 +-6: blr
884 ++.Lnext:
885 ++ add r9,r9,r12
886 ++ bdnz .Lrels
887 ++.Lout:
888 ++ blr
889 +
890 + .balign 8
891 + p_dyn: .8byte __dynamic_start - 0b
892 + p_rela: .8byte __rela_dyn_start - 0b
893 ++p_sym: .8byte __dynamic_symtab - 0b
894 + p_st: .8byte _stext - 0b
895 +
896 +diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
897 +index 2bcca818136ae..fe22d940412fd 100644
898 +--- a/arch/powerpc/kernel/vmlinux.lds.S
899 ++++ b/arch/powerpc/kernel/vmlinux.lds.S
900 +@@ -281,9 +281,7 @@ SECTIONS
901 + . = ALIGN(8);
902 + .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
903 + {
904 +-#ifdef CONFIG_PPC32
905 + __dynamic_symtab = .;
906 +-#endif
907 + *(.dynsym)
908 + }
909 + .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
910 +diff --git a/arch/powerpc/perf/Makefile b/arch/powerpc/perf/Makefile
911 +index 2f46e31c76129..4f53d0b97539b 100644
912 +--- a/arch/powerpc/perf/Makefile
913 ++++ b/arch/powerpc/perf/Makefile
914 +@@ -3,11 +3,11 @@
915 + obj-y += callchain.o callchain_$(BITS).o perf_regs.o
916 + obj-$(CONFIG_COMPAT) += callchain_32.o
917 +
918 +-obj-$(CONFIG_PPC_PERF_CTRS) += core-book3s.o bhrb.o
919 ++obj-$(CONFIG_PPC_PERF_CTRS) += core-book3s.o
920 + obj64-$(CONFIG_PPC_PERF_CTRS) += ppc970-pmu.o power5-pmu.o \
921 + power5+-pmu.o power6-pmu.o power7-pmu.o \
922 + isa207-common.o power8-pmu.o power9-pmu.o \
923 +- generic-compat-pmu.o power10-pmu.o
924 ++ generic-compat-pmu.o power10-pmu.o bhrb.o
925 + obj32-$(CONFIG_PPC_PERF_CTRS) += mpc7450-pmu.o
926 +
927 + obj-$(CONFIG_PPC_POWERNV) += imc-pmu.o
928 +diff --git a/arch/powerpc/tools/relocs_check.sh b/arch/powerpc/tools/relocs_check.sh
929 +index 014e00e74d2b6..63792af004170 100755
930 +--- a/arch/powerpc/tools/relocs_check.sh
931 ++++ b/arch/powerpc/tools/relocs_check.sh
932 +@@ -39,6 +39,7 @@ $objdump -R "$vmlinux" |
933 + # R_PPC_NONE
934 + grep -F -w -v 'R_PPC64_RELATIVE
935 + R_PPC64_NONE
936 ++R_PPC64_UADDR64
937 + R_PPC_ADDR16_LO
938 + R_PPC_ADDR16_HI
939 + R_PPC_ADDR16_HA
940 +@@ -54,9 +55,3 @@ fi
941 + num_bad=$(echo "$bad_relocs" | wc -l)
942 + echo "WARNING: $num_bad bad relocations"
943 + echo "$bad_relocs"
944 +-
945 +-# If we see this type of relocation it's an idication that
946 +-# we /may/ be using an old version of binutils.
947 +-if echo "$bad_relocs" | grep -q -F -w R_PPC64_UADDR64; then
948 +- echo "WARNING: You need at least binutils >= 2.19 to build a CONFIG_RELOCATABLE kernel"
949 +-fi
950 +diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c
951 +index 0b552873a5778..765004b605132 100644
952 +--- a/arch/riscv/kernel/patch.c
953 ++++ b/arch/riscv/kernel/patch.c
954 +@@ -104,7 +104,7 @@ static int patch_text_cb(void *data)
955 + struct patch_insn *patch = data;
956 + int ret = 0;
957 +
958 +- if (atomic_inc_return(&patch->cpu_count) == 1) {
959 ++ if (atomic_inc_return(&patch->cpu_count) == num_online_cpus()) {
960 + ret =
961 + patch_text_nosync(patch->addr, &patch->insn,
962 + GET_INSN_LENGTH(patch->insn));
963 +diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
964 +index d6bfdfb0f0afe..0c3d3440fe278 100644
965 +--- a/arch/x86/include/asm/microcode.h
966 ++++ b/arch/x86/include/asm/microcode.h
967 +@@ -131,10 +131,12 @@ extern void __init load_ucode_bsp(void);
968 + extern void load_ucode_ap(void);
969 + void reload_early_microcode(void);
970 + extern bool initrd_gone;
971 ++void microcode_bsp_resume(void);
972 + #else
973 + static inline void __init load_ucode_bsp(void) { }
974 + static inline void load_ucode_ap(void) { }
975 + static inline void reload_early_microcode(void) { }
976 ++static inline void microcode_bsp_resume(void) { }
977 + #endif
978 +
979 + #endif /* _ASM_X86_MICROCODE_H */
980 +diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
981 +index f955d25076bab..239ff5fcec6a2 100644
982 +--- a/arch/x86/kernel/cpu/microcode/core.c
983 ++++ b/arch/x86/kernel/cpu/microcode/core.c
984 +@@ -758,9 +758,9 @@ static struct subsys_interface mc_cpu_interface = {
985 + };
986 +
987 + /**
988 +- * mc_bp_resume - Update boot CPU microcode during resume.
989 ++ * microcode_bsp_resume - Update boot CPU microcode during resume.
990 + */
991 +-static void mc_bp_resume(void)
992 ++void microcode_bsp_resume(void)
993 + {
994 + int cpu = smp_processor_id();
995 + struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
996 +@@ -772,7 +772,7 @@ static void mc_bp_resume(void)
997 + }
998 +
999 + static struct syscore_ops mc_syscore_ops = {
1000 +- .resume = mc_bp_resume,
1001 ++ .resume = microcode_bsp_resume,
1002 + };
1003 +
1004 + static int mc_cpu_starting(unsigned int cpu)
1005 +diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
1006 +index 0402a749f3a0e..0ae6cf8041970 100644
1007 +--- a/arch/x86/lib/usercopy_64.c
1008 ++++ b/arch/x86/lib/usercopy_64.c
1009 +@@ -119,7 +119,7 @@ void __memcpy_flushcache(void *_dst, const void *_src, size_t size)
1010 +
1011 + /* cache copy and flush to align dest */
1012 + if (!IS_ALIGNED(dest, 8)) {
1013 +- unsigned len = min_t(unsigned, size, ALIGN(dest, 8) - dest);
1014 ++ size_t len = min_t(size_t, size, ALIGN(dest, 8) - dest);
1015 +
1016 + memcpy((void *) dest, (void *) source, len);
1017 + clean_cache_range((void *) dest, len);
1018 +diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
1019 +index 9bb1e29411796..b94f727251b64 100644
1020 +--- a/arch/x86/pci/xen.c
1021 ++++ b/arch/x86/pci/xen.c
1022 +@@ -467,7 +467,6 @@ static __init void xen_setup_pci_msi(void)
1023 + else
1024 + xen_msi_ops.setup_msi_irqs = xen_setup_msi_irqs;
1025 + xen_msi_ops.teardown_msi_irqs = xen_pv_teardown_msi_irqs;
1026 +- pci_msi_ignore_mask = 1;
1027 + } else if (xen_hvm_domain()) {
1028 + xen_msi_ops.setup_msi_irqs = xen_hvm_setup_msi_irqs;
1029 + xen_msi_ops.teardown_msi_irqs = xen_teardown_msi_irqs;
1030 +@@ -481,6 +480,11 @@ static __init void xen_setup_pci_msi(void)
1031 + * in allocating the native domain and never use it.
1032 + */
1033 + x86_init.irqs.create_pci_msi_domain = xen_create_pci_msi_domain;
1034 ++ /*
1035 ++ * With XEN PIRQ/Eventchannels in use PCI/MSI[-X] masking is solely
1036 ++ * controlled by the hypervisor.
1037 ++ */
1038 ++ pci_msi_ignore_mask = 1;
1039 + }
1040 +
1041 + #else /* CONFIG_PCI_MSI */
1042 +diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
1043 +index 3822666fb73d5..bb176c72891c9 100644
1044 +--- a/arch/x86/power/cpu.c
1045 ++++ b/arch/x86/power/cpu.c
1046 +@@ -25,6 +25,7 @@
1047 + #include <asm/cpu.h>
1048 + #include <asm/mmu_context.h>
1049 + #include <asm/cpu_device_id.h>
1050 ++#include <asm/microcode.h>
1051 +
1052 + #ifdef CONFIG_X86_32
1053 + __visible unsigned long saved_context_ebx;
1054 +@@ -262,11 +263,18 @@ static void notrace __restore_processor_state(struct saved_context *ctxt)
1055 + x86_platform.restore_sched_clock_state();
1056 + mtrr_bp_restore();
1057 + perf_restore_debug_store();
1058 +- msr_restore_context(ctxt);
1059 +
1060 + c = &cpu_data(smp_processor_id());
1061 + if (cpu_has(c, X86_FEATURE_MSR_IA32_FEAT_CTL))
1062 + init_ia32_feat_ctl(c);
1063 ++
1064 ++ microcode_bsp_resume();
1065 ++
1066 ++ /*
1067 ++ * This needs to happen after the microcode has been updated upon resume
1068 ++ * because some of the MSRs are "emulated" in microcode.
1069 ++ */
1070 ++ msr_restore_context(ctxt);
1071 + }
1072 +
1073 + /* Needed by apm.c */
1074 +diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
1075 +index 81d7c7e8f7e96..10b79d3c74e07 100644
1076 +--- a/arch/xtensa/platforms/iss/console.c
1077 ++++ b/arch/xtensa/platforms/iss/console.c
1078 +@@ -36,24 +36,19 @@ static void rs_poll(struct timer_list *);
1079 + static struct tty_driver *serial_driver;
1080 + static struct tty_port serial_port;
1081 + static DEFINE_TIMER(serial_timer, rs_poll);
1082 +-static DEFINE_SPINLOCK(timer_lock);
1083 +
1084 + static int rs_open(struct tty_struct *tty, struct file * filp)
1085 + {
1086 +- spin_lock_bh(&timer_lock);
1087 + if (tty->count == 1)
1088 + mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE);
1089 +- spin_unlock_bh(&timer_lock);
1090 +
1091 + return 0;
1092 + }
1093 +
1094 + static void rs_close(struct tty_struct *tty, struct file * filp)
1095 + {
1096 +- spin_lock_bh(&timer_lock);
1097 + if (tty->count == 1)
1098 + del_timer_sync(&serial_timer);
1099 +- spin_unlock_bh(&timer_lock);
1100 + }
1101 +
1102 +
1103 +@@ -73,8 +68,6 @@ static void rs_poll(struct timer_list *unused)
1104 + int rd = 1;
1105 + unsigned char c;
1106 +
1107 +- spin_lock(&timer_lock);
1108 +-
1109 + while (simc_poll(0)) {
1110 + rd = simc_read(0, &c, 1);
1111 + if (rd <= 0)
1112 +@@ -87,7 +80,6 @@ static void rs_poll(struct timer_list *unused)
1113 + tty_flip_buffer_push(port);
1114 + if (rd)
1115 + mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE);
1116 +- spin_unlock(&timer_lock);
1117 + }
1118 +
1119 +
1120 +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
1121 +index 1dff82d34b44b..963f9f549232b 100644
1122 +--- a/block/bfq-iosched.c
1123 ++++ b/block/bfq-iosched.c
1124 +@@ -569,7 +569,7 @@ static bool bfqq_request_over_limit(struct bfq_queue *bfqq, int limit)
1125 + struct bfq_entity *entity = &bfqq->entity;
1126 + struct bfq_entity *inline_entities[BFQ_LIMIT_INLINE_DEPTH];
1127 + struct bfq_entity **entities = inline_entities;
1128 +- int depth, level;
1129 ++ int depth, level, alloc_depth = BFQ_LIMIT_INLINE_DEPTH;
1130 + int class_idx = bfqq->ioprio_class - 1;
1131 + struct bfq_sched_data *sched_data;
1132 + unsigned long wsum;
1133 +@@ -578,15 +578,21 @@ static bool bfqq_request_over_limit(struct bfq_queue *bfqq, int limit)
1134 + if (!entity->on_st_or_in_serv)
1135 + return false;
1136 +
1137 ++retry:
1138 ++ spin_lock_irq(&bfqd->lock);
1139 + /* +1 for bfqq entity, root cgroup not included */
1140 + depth = bfqg_to_blkg(bfqq_group(bfqq))->blkcg->css.cgroup->level + 1;
1141 +- if (depth > BFQ_LIMIT_INLINE_DEPTH) {
1142 ++ if (depth > alloc_depth) {
1143 ++ spin_unlock_irq(&bfqd->lock);
1144 ++ if (entities != inline_entities)
1145 ++ kfree(entities);
1146 + entities = kmalloc_array(depth, sizeof(*entities), GFP_NOIO);
1147 + if (!entities)
1148 + return false;
1149 ++ alloc_depth = depth;
1150 ++ goto retry;
1151 + }
1152 +
1153 +- spin_lock_irq(&bfqd->lock);
1154 + sched_data = entity->sched_data;
1155 + /* Gather our ancestors as we need to traverse them in reverse order */
1156 + level = 0;
1157 +diff --git a/block/blk-iocost.c b/block/blk-iocost.c
1158 +index 769b643942989..871d9529ea357 100644
1159 +--- a/block/blk-iocost.c
1160 ++++ b/block/blk-iocost.c
1161 +@@ -2322,7 +2322,17 @@ static void ioc_timer_fn(struct timer_list *timer)
1162 + iocg->hweight_donating = hwa;
1163 + iocg->hweight_after_donation = new_hwi;
1164 + list_add(&iocg->surplus_list, &surpluses);
1165 +- } else {
1166 ++ } else if (!iocg->abs_vdebt) {
1167 ++ /*
1168 ++ * @iocg doesn't have enough to donate. Reset
1169 ++ * its inuse to active.
1170 ++ *
1171 ++ * Don't reset debtors as their inuse's are
1172 ++ * owned by debt handling. This shouldn't affect
1173 ++ * donation calculuation in any meaningful way
1174 ++ * as @iocg doesn't have a meaningful amount of
1175 ++ * share anyway.
1176 ++ */
1177 + TRACE_IOCG_PATH(inuse_shortage, iocg, &now,
1178 + iocg->inuse, iocg->active,
1179 + iocg->hweight_inuse, new_hwi);
1180 +diff --git a/block/blk-mq.c b/block/blk-mq.c
1181 +index cb50097366cd4..0aa20df31e369 100644
1182 +--- a/block/blk-mq.c
1183 ++++ b/block/blk-mq.c
1184 +@@ -1122,14 +1122,7 @@ void blk_mq_start_request(struct request *rq)
1185 + trace_block_rq_issue(rq);
1186 +
1187 + if (test_bit(QUEUE_FLAG_STATS, &q->queue_flags)) {
1188 +- u64 start_time;
1189 +-#ifdef CONFIG_BLK_CGROUP
1190 +- if (rq->bio)
1191 +- start_time = bio_issue_time(&rq->bio->bi_issue);
1192 +- else
1193 +-#endif
1194 +- start_time = ktime_get_ns();
1195 +- rq->io_start_time_ns = start_time;
1196 ++ rq->io_start_time_ns = ktime_get_ns();
1197 + rq->stats_sectors = blk_rq_sectors(rq);
1198 + rq->rq_flags |= RQF_STATS;
1199 + rq_qos_issue(q, rq);
1200 +diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
1201 +index 4556c86c34659..eb95e188d62bc 100644
1202 +--- a/drivers/acpi/processor_idle.c
1203 ++++ b/drivers/acpi/processor_idle.c
1204 +@@ -96,11 +96,6 @@ static const struct dmi_system_id processor_power_dmi_table[] = {
1205 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
1206 + DMI_MATCH(DMI_PRODUCT_NAME,"L8400B series Notebook PC")},
1207 + (void *)1},
1208 +- /* T40 can not handle C3 idle state */
1209 +- { set_max_cstate, "IBM ThinkPad T40", {
1210 +- DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
1211 +- DMI_MATCH(DMI_PRODUCT_NAME, "23737CU")},
1212 +- (void *)2},
1213 + {},
1214 + };
1215 +
1216 +@@ -795,7 +790,8 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)
1217 + if (cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2 ||
1218 + cx->type == ACPI_STATE_C3) {
1219 + state->enter_dead = acpi_idle_play_dead;
1220 +- drv->safe_state_index = count;
1221 ++ if (cx->type != ACPI_STATE_C3)
1222 ++ drv->safe_state_index = count;
1223 + }
1224 + /*
1225 + * Halt-induced C1 is not good for ->enter_s2idle, because it
1226 +diff --git a/drivers/android/binder.c b/drivers/android/binder.c
1227 +index 8351c5638880b..f3b639e89dd88 100644
1228 +--- a/drivers/android/binder.c
1229 ++++ b/drivers/android/binder.c
1230 +@@ -2295,6 +2295,7 @@ static int binder_do_deferred_txn_copies(struct binder_alloc *alloc,
1231 + {
1232 + int ret = 0;
1233 + struct binder_sg_copy *sgc, *tmpsgc;
1234 ++ struct binder_ptr_fixup *tmppf;
1235 + struct binder_ptr_fixup *pf =
1236 + list_first_entry_or_null(pf_head, struct binder_ptr_fixup,
1237 + node);
1238 +@@ -2349,7 +2350,11 @@ static int binder_do_deferred_txn_copies(struct binder_alloc *alloc,
1239 + list_del(&sgc->node);
1240 + kfree(sgc);
1241 + }
1242 +- BUG_ON(!list_empty(pf_head));
1243 ++ list_for_each_entry_safe(pf, tmppf, pf_head, node) {
1244 ++ BUG_ON(pf->skip_size == 0);
1245 ++ list_del(&pf->node);
1246 ++ kfree(pf);
1247 ++ }
1248 + BUG_ON(!list_empty(sgc_head));
1249 +
1250 + return ret > 0 ? -EINVAL : ret;
1251 +@@ -2486,6 +2491,9 @@ static int binder_translate_fd_array(struct list_head *pf_head,
1252 + struct binder_proc *proc = thread->proc;
1253 + int ret;
1254 +
1255 ++ if (fda->num_fds == 0)
1256 ++ return 0;
1257 ++
1258 + fd_buf_size = sizeof(u32) * fda->num_fds;
1259 + if (fda->num_fds >= SIZE_MAX / sizeof(u32)) {
1260 + binder_user_error("%d:%d got transaction with invalid number of fds (%lld)\n",
1261 +diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
1262 +index 976154140f0b0..78b911a2c4c72 100644
1263 +--- a/drivers/base/arch_topology.c
1264 ++++ b/drivers/base/arch_topology.c
1265 +@@ -628,6 +628,15 @@ const struct cpumask *cpu_coregroup_mask(int cpu)
1266 + core_mask = &cpu_topology[cpu].llc_sibling;
1267 + }
1268 +
1269 ++ /*
1270 ++ * For systems with no shared cpu-side LLC but with clusters defined,
1271 ++ * extend core_mask to cluster_siblings. The sched domain builder will
1272 ++ * then remove MC as redundant with CLS if SCHED_CLUSTER is enabled.
1273 ++ */
1274 ++ if (IS_ENABLED(CONFIG_SCHED_CLUSTER) &&
1275 ++ cpumask_subset(core_mask, &cpu_topology[cpu].cluster_sibling))
1276 ++ core_mask = &cpu_topology[cpu].cluster_sibling;
1277 ++
1278 + return core_mask;
1279 + }
1280 +
1281 +@@ -645,7 +654,7 @@ void update_siblings_masks(unsigned int cpuid)
1282 + for_each_online_cpu(cpu) {
1283 + cpu_topo = &cpu_topology[cpu];
1284 +
1285 +- if (cpuid_topo->llc_id == cpu_topo->llc_id) {
1286 ++ if (cpu_topo->llc_id != -1 && cpuid_topo->llc_id == cpu_topo->llc_id) {
1287 + cpumask_set_cpu(cpu, &cpuid_topo->llc_sibling);
1288 + cpumask_set_cpu(cpuid, &cpu_topo->llc_sibling);
1289 + }
1290 +diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
1291 +index 519b6d38d4df6..fdb81f2794cde 100644
1292 +--- a/drivers/block/Kconfig
1293 ++++ b/drivers/block/Kconfig
1294 +@@ -33,6 +33,22 @@ config BLK_DEV_FD
1295 + To compile this driver as a module, choose M here: the
1296 + module will be called floppy.
1297 +
1298 ++config BLK_DEV_FD_RAWCMD
1299 ++ bool "Support for raw floppy disk commands (DEPRECATED)"
1300 ++ depends on BLK_DEV_FD
1301 ++ help
1302 ++ If you want to use actual physical floppies and expect to do
1303 ++ special low-level hardware accesses to them (access and use
1304 ++ non-standard formats, for example), then enable this.
1305 ++
1306 ++ Note that the code enabled by this option is rarely used and
1307 ++ might be unstable or insecure, and distros should not enable it.
1308 ++
1309 ++ Note: FDRAWCMD is deprecated and will be removed from the kernel
1310 ++ in the near future.
1311 ++
1312 ++ If unsure, say N.
1313 ++
1314 + config AMIGA_FLOPPY
1315 + tristate "Amiga floppy support"
1316 + depends on AMIGA
1317 +diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
1318 +index e611411a934ce..a29cc2928be47 100644
1319 +--- a/drivers/block/floppy.c
1320 ++++ b/drivers/block/floppy.c
1321 +@@ -2984,6 +2984,8 @@ static const char *drive_name(int type, int drive)
1322 + return "(null)";
1323 + }
1324 +
1325 ++#ifdef CONFIG_BLK_DEV_FD_RAWCMD
1326 ++
1327 + /* raw commands */
1328 + static void raw_cmd_done(int flag)
1329 + {
1330 +@@ -3183,6 +3185,35 @@ static int raw_cmd_ioctl(int cmd, void __user *param)
1331 + return ret;
1332 + }
1333 +
1334 ++static int floppy_raw_cmd_ioctl(int type, int drive, int cmd,
1335 ++ void __user *param)
1336 ++{
1337 ++ int ret;
1338 ++
1339 ++ pr_warn_once("Note: FDRAWCMD is deprecated and will be removed from the kernel in the near future.\n");
1340 ++
1341 ++ if (type)
1342 ++ return -EINVAL;
1343 ++ if (lock_fdc(drive))
1344 ++ return -EINTR;
1345 ++ set_floppy(drive);
1346 ++ ret = raw_cmd_ioctl(cmd, param);
1347 ++ if (ret == -EINTR)
1348 ++ return -EINTR;
1349 ++ process_fd_request();
1350 ++ return ret;
1351 ++}
1352 ++
1353 ++#else /* CONFIG_BLK_DEV_FD_RAWCMD */
1354 ++
1355 ++static int floppy_raw_cmd_ioctl(int type, int drive, int cmd,
1356 ++ void __user *param)
1357 ++{
1358 ++ return -EOPNOTSUPP;
1359 ++}
1360 ++
1361 ++#endif
1362 ++
1363 + static int invalidate_drive(struct block_device *bdev)
1364 + {
1365 + /* invalidate the buffer track to force a reread */
1366 +@@ -3371,7 +3402,6 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
1367 + {
1368 + int drive = (long)bdev->bd_disk->private_data;
1369 + int type = ITYPE(drive_state[drive].fd_device);
1370 +- int i;
1371 + int ret;
1372 + int size;
1373 + union inparam {
1374 +@@ -3522,16 +3552,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
1375 + outparam = &write_errors[drive];
1376 + break;
1377 + case FDRAWCMD:
1378 +- if (type)
1379 +- return -EINVAL;
1380 +- if (lock_fdc(drive))
1381 +- return -EINTR;
1382 +- set_floppy(drive);
1383 +- i = raw_cmd_ioctl(cmd, (void __user *)param);
1384 +- if (i == -EINTR)
1385 +- return -EINTR;
1386 +- process_fd_request();
1387 +- return i;
1388 ++ return floppy_raw_cmd_ioctl(type, drive, cmd, (void __user *)param);
1389 + case FDTWADDLE:
1390 + if (lock_fdc(drive))
1391 + return -EINTR;
1392 +diff --git a/drivers/bus/fsl-mc/fsl-mc-msi.c b/drivers/bus/fsl-mc/fsl-mc-msi.c
1393 +index 5e0e4393ce4d4..0cfe859a4ac4d 100644
1394 +--- a/drivers/bus/fsl-mc/fsl-mc-msi.c
1395 ++++ b/drivers/bus/fsl-mc/fsl-mc-msi.c
1396 +@@ -224,8 +224,12 @@ int fsl_mc_msi_domain_alloc_irqs(struct device *dev, unsigned int irq_count)
1397 + if (error)
1398 + return error;
1399 +
1400 ++ msi_lock_descs(dev);
1401 + if (msi_first_desc(dev, MSI_DESC_ALL))
1402 +- return -EINVAL;
1403 ++ error = -EINVAL;
1404 ++ msi_unlock_descs(dev);
1405 ++ if (error)
1406 ++ return error;
1407 +
1408 + /*
1409 + * NOTE: Calling this function will trigger the invocation of the
1410 +diff --git a/drivers/bus/mhi/pci_generic.c b/drivers/bus/mhi/pci_generic.c
1411 +index 9527b7d638401..541ced27d9412 100644
1412 +--- a/drivers/bus/mhi/pci_generic.c
1413 ++++ b/drivers/bus/mhi/pci_generic.c
1414 +@@ -1060,6 +1060,7 @@ static int __maybe_unused mhi_pci_freeze(struct device *dev)
1415 + * the intermediate restore kernel reinitializes MHI device with new
1416 + * context.
1417 + */
1418 ++ flush_work(&mhi_pdev->recovery_work);
1419 + if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) {
1420 + mhi_power_down(mhi_cntrl, true);
1421 + mhi_unprepare_after_power_down(mhi_cntrl);
1422 +@@ -1085,6 +1086,7 @@ static const struct dev_pm_ops mhi_pci_pm_ops = {
1423 + .resume = mhi_pci_resume,
1424 + .freeze = mhi_pci_freeze,
1425 + .thaw = mhi_pci_restore,
1426 ++ .poweroff = mhi_pci_freeze,
1427 + .restore = mhi_pci_restore,
1428 + #endif
1429 + };
1430 +diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c
1431 +index 4566e730ef2b8..60b082fe2ed02 100644
1432 +--- a/drivers/bus/sunxi-rsb.c
1433 ++++ b/drivers/bus/sunxi-rsb.c
1434 +@@ -227,6 +227,8 @@ static struct sunxi_rsb_device *sunxi_rsb_device_create(struct sunxi_rsb *rsb,
1435 +
1436 + dev_dbg(&rdev->dev, "device %s registered\n", dev_name(&rdev->dev));
1437 +
1438 ++ return rdev;
1439 ++
1440 + err_device_add:
1441 + put_device(&rdev->dev);
1442 +
1443 +diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
1444 +index 54c0ee6dda302..7a1b1f9e49333 100644
1445 +--- a/drivers/bus/ti-sysc.c
1446 ++++ b/drivers/bus/ti-sysc.c
1447 +@@ -3232,13 +3232,27 @@ static int sysc_check_disabled_devices(struct sysc *ddata)
1448 + */
1449 + static int sysc_check_active_timer(struct sysc *ddata)
1450 + {
1451 ++ int error;
1452 ++
1453 + if (ddata->cap->type != TI_SYSC_OMAP2_TIMER &&
1454 + ddata->cap->type != TI_SYSC_OMAP4_TIMER)
1455 + return 0;
1456 +
1457 ++ /*
1458 ++ * Quirk for omap3 beagleboard revision A to B4 to use gpt12.
1459 ++ * Revision C and later are fixed with commit 23885389dbbb ("ARM:
1460 ++ * dts: Fix timer regression for beagleboard revision c"). This all
1461 ++ * can be dropped if we stop supporting old beagleboard revisions
1462 ++ * A to B4 at some point.
1463 ++ */
1464 ++ if (sysc_soc->soc == SOC_3430)
1465 ++ error = -ENXIO;
1466 ++ else
1467 ++ error = -EBUSY;
1468 ++
1469 + if ((ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT) &&
1470 + (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE))
1471 +- return -ENXIO;
1472 ++ return error;
1473 +
1474 + return 0;
1475 + }
1476 +diff --git a/drivers/clk/sunxi/clk-sun9i-mmc.c b/drivers/clk/sunxi/clk-sun9i-mmc.c
1477 +index 542b31d6e96dd..636bcf2439ef2 100644
1478 +--- a/drivers/clk/sunxi/clk-sun9i-mmc.c
1479 ++++ b/drivers/clk/sunxi/clk-sun9i-mmc.c
1480 +@@ -109,6 +109,8 @@ static int sun9i_a80_mmc_config_clk_probe(struct platform_device *pdev)
1481 + spin_lock_init(&data->lock);
1482 +
1483 + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1484 ++ if (!r)
1485 ++ return -EINVAL;
1486 + /* one clock/reset pair per word */
1487 + count = DIV_ROUND_UP((resource_size(r)), SUN9I_MMC_WIDTH);
1488 + data->membase = devm_ioremap_resource(&pdev->dev, r);
1489 +diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
1490 +index effbb680b453f..ca0f1be1c3b23 100644
1491 +--- a/drivers/cpufreq/qcom-cpufreq-hw.c
1492 ++++ b/drivers/cpufreq/qcom-cpufreq-hw.c
1493 +@@ -24,12 +24,16 @@
1494 + #define CLK_HW_DIV 2
1495 + #define LUT_TURBO_IND 1
1496 +
1497 ++#define GT_IRQ_STATUS BIT(2)
1498 ++
1499 + #define HZ_PER_KHZ 1000
1500 +
1501 + struct qcom_cpufreq_soc_data {
1502 + u32 reg_enable;
1503 ++ u32 reg_domain_state;
1504 + u32 reg_freq_lut;
1505 + u32 reg_volt_lut;
1506 ++ u32 reg_intr_clr;
1507 + u32 reg_current_vote;
1508 + u32 reg_perf_state;
1509 + u8 lut_row_size;
1510 +@@ -267,37 +271,46 @@ static void qcom_get_related_cpus(int index, struct cpumask *m)
1511 + }
1512 + }
1513 +
1514 +-static unsigned int qcom_lmh_get_throttle_freq(struct qcom_cpufreq_data *data)
1515 ++static unsigned long qcom_lmh_get_throttle_freq(struct qcom_cpufreq_data *data)
1516 + {
1517 +- unsigned int val = readl_relaxed(data->base + data->soc_data->reg_current_vote);
1518 ++ unsigned int lval;
1519 ++
1520 ++ if (data->soc_data->reg_current_vote)
1521 ++ lval = readl_relaxed(data->base + data->soc_data->reg_current_vote) & 0x3ff;
1522 ++ else
1523 ++ lval = readl_relaxed(data->base + data->soc_data->reg_domain_state) & 0xff;
1524 +
1525 +- return (val & 0x3FF) * 19200;
1526 ++ return lval * xo_rate;
1527 + }
1528 +
1529 + static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)
1530 + {
1531 + struct cpufreq_policy *policy = data->policy;
1532 +- int cpu = cpumask_first(policy->cpus);
1533 ++ int cpu = cpumask_first(policy->related_cpus);
1534 + struct device *dev = get_cpu_device(cpu);
1535 + unsigned long freq_hz, throttled_freq;
1536 + struct dev_pm_opp *opp;
1537 +- unsigned int freq;
1538 +
1539 + /*
1540 + * Get the h/w throttled frequency, normalize it using the
1541 + * registered opp table and use it to calculate thermal pressure.
1542 + */
1543 +- freq = qcom_lmh_get_throttle_freq(data);
1544 +- freq_hz = freq * HZ_PER_KHZ;
1545 ++ freq_hz = qcom_lmh_get_throttle_freq(data);
1546 +
1547 + opp = dev_pm_opp_find_freq_floor(dev, &freq_hz);
1548 + if (IS_ERR(opp) && PTR_ERR(opp) == -ERANGE)
1549 +- dev_pm_opp_find_freq_ceil(dev, &freq_hz);
1550 ++ opp = dev_pm_opp_find_freq_ceil(dev, &freq_hz);
1551 +
1552 +- throttled_freq = freq_hz / HZ_PER_KHZ;
1553 ++ if (IS_ERR(opp)) {
1554 ++ dev_warn(dev, "Can't find the OPP for throttling: %pe!\n", opp);
1555 ++ } else {
1556 ++ throttled_freq = freq_hz / HZ_PER_KHZ;
1557 +
1558 +- /* Update thermal pressure (the boost frequencies are accepted) */
1559 +- arch_update_thermal_pressure(policy->related_cpus, throttled_freq);
1560 ++ /* Update thermal pressure (the boost frequencies are accepted) */
1561 ++ arch_update_thermal_pressure(policy->related_cpus, throttled_freq);
1562 ++
1563 ++ dev_pm_opp_put(opp);
1564 ++ }
1565 +
1566 + /*
1567 + * In the unlikely case policy is unregistered do not enable
1568 +@@ -337,6 +350,10 @@ static irqreturn_t qcom_lmh_dcvs_handle_irq(int irq, void *data)
1569 + disable_irq_nosync(c_data->throttle_irq);
1570 + schedule_delayed_work(&c_data->throttle_work, 0);
1571 +
1572 ++ if (c_data->soc_data->reg_intr_clr)
1573 ++ writel_relaxed(GT_IRQ_STATUS,
1574 ++ c_data->base + c_data->soc_data->reg_intr_clr);
1575 ++
1576 + return IRQ_HANDLED;
1577 + }
1578 +
1579 +@@ -351,8 +368,10 @@ static const struct qcom_cpufreq_soc_data qcom_soc_data = {
1580 +
1581 + static const struct qcom_cpufreq_soc_data epss_soc_data = {
1582 + .reg_enable = 0x0,
1583 ++ .reg_domain_state = 0x20,
1584 + .reg_freq_lut = 0x100,
1585 + .reg_volt_lut = 0x200,
1586 ++ .reg_intr_clr = 0x308,
1587 + .reg_perf_state = 0x320,
1588 + .lut_row_size = 4,
1589 + };
1590 +@@ -412,6 +431,7 @@ static void qcom_cpufreq_hw_lmh_exit(struct qcom_cpufreq_data *data)
1591 + mutex_unlock(&data->throttle_lock);
1592 +
1593 + cancel_delayed_work_sync(&data->throttle_work);
1594 ++ irq_set_affinity_hint(data->throttle_irq, NULL);
1595 + free_irq(data->throttle_irq, data);
1596 + }
1597 +
1598 +diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
1599 +index 2deed8d8773fa..75e1bf3a08f7c 100644
1600 +--- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
1601 ++++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
1602 +@@ -98,8 +98,10 @@ static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev)
1603 + return -ENOMEM;
1604 +
1605 + ret = sun50i_cpufreq_get_efuse(&speed);
1606 +- if (ret)
1607 ++ if (ret) {
1608 ++ kfree(opp_tables);
1609 + return ret;
1610 ++ }
1611 +
1612 + snprintf(name, MAX_NAME_LEN, "speed%d", speed);
1613 +
1614 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
1615 +index c853266957ce1..f09aeff513ee9 100644
1616 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
1617 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
1618 +@@ -2348,6 +2348,71 @@ static int amdgpu_pmops_restore(struct device *dev)
1619 + return amdgpu_device_resume(drm_dev, true);
1620 + }
1621 +
1622 ++static int amdgpu_runtime_idle_check_display(struct device *dev)
1623 ++{
1624 ++ struct pci_dev *pdev = to_pci_dev(dev);
1625 ++ struct drm_device *drm_dev = pci_get_drvdata(pdev);
1626 ++ struct amdgpu_device *adev = drm_to_adev(drm_dev);
1627 ++
1628 ++ if (adev->mode_info.num_crtc) {
1629 ++ struct drm_connector *list_connector;
1630 ++ struct drm_connector_list_iter iter;
1631 ++ int ret = 0;
1632 ++
1633 ++ /* XXX: Return busy if any displays are connected to avoid
1634 ++ * possible display wakeups after runtime resume due to
1635 ++ * hotplug events in case any displays were connected while
1636 ++ * the GPU was in suspend. Remove this once that is fixed.
1637 ++ */
1638 ++ mutex_lock(&drm_dev->mode_config.mutex);
1639 ++ drm_connector_list_iter_begin(drm_dev, &iter);
1640 ++ drm_for_each_connector_iter(list_connector, &iter) {
1641 ++ if (list_connector->status == connector_status_connected) {
1642 ++ ret = -EBUSY;
1643 ++ break;
1644 ++ }
1645 ++ }
1646 ++ drm_connector_list_iter_end(&iter);
1647 ++ mutex_unlock(&drm_dev->mode_config.mutex);
1648 ++
1649 ++ if (ret)
1650 ++ return ret;
1651 ++
1652 ++ if (amdgpu_device_has_dc_support(adev)) {
1653 ++ struct drm_crtc *crtc;
1654 ++
1655 ++ drm_for_each_crtc(crtc, drm_dev) {
1656 ++ drm_modeset_lock(&crtc->mutex, NULL);
1657 ++ if (crtc->state->active)
1658 ++ ret = -EBUSY;
1659 ++ drm_modeset_unlock(&crtc->mutex);
1660 ++ if (ret < 0)
1661 ++ break;
1662 ++ }
1663 ++ } else {
1664 ++ mutex_lock(&drm_dev->mode_config.mutex);
1665 ++ drm_modeset_lock(&drm_dev->mode_config.connection_mutex, NULL);
1666 ++
1667 ++ drm_connector_list_iter_begin(drm_dev, &iter);
1668 ++ drm_for_each_connector_iter(list_connector, &iter) {
1669 ++ if (list_connector->dpms == DRM_MODE_DPMS_ON) {
1670 ++ ret = -EBUSY;
1671 ++ break;
1672 ++ }
1673 ++ }
1674 ++
1675 ++ drm_connector_list_iter_end(&iter);
1676 ++
1677 ++ drm_modeset_unlock(&drm_dev->mode_config.connection_mutex);
1678 ++ mutex_unlock(&drm_dev->mode_config.mutex);
1679 ++ }
1680 ++ if (ret)
1681 ++ return ret;
1682 ++ }
1683 ++
1684 ++ return 0;
1685 ++}
1686 ++
1687 + static int amdgpu_pmops_runtime_suspend(struct device *dev)
1688 + {
1689 + struct pci_dev *pdev = to_pci_dev(dev);
1690 +@@ -2360,6 +2425,10 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
1691 + return -EBUSY;
1692 + }
1693 +
1694 ++ ret = amdgpu_runtime_idle_check_display(dev);
1695 ++ if (ret)
1696 ++ return ret;
1697 ++
1698 + /* wait for all rings to drain before suspending */
1699 + for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
1700 + struct amdgpu_ring *ring = adev->rings[i];
1701 +@@ -2469,41 +2538,7 @@ static int amdgpu_pmops_runtime_idle(struct device *dev)
1702 + return -EBUSY;
1703 + }
1704 +
1705 +- if (amdgpu_device_has_dc_support(adev)) {
1706 +- struct drm_crtc *crtc;
1707 +-
1708 +- drm_for_each_crtc(crtc, drm_dev) {
1709 +- drm_modeset_lock(&crtc->mutex, NULL);
1710 +- if (crtc->state->active)
1711 +- ret = -EBUSY;
1712 +- drm_modeset_unlock(&crtc->mutex);
1713 +- if (ret < 0)
1714 +- break;
1715 +- }
1716 +-
1717 +- } else {
1718 +- struct drm_connector *list_connector;
1719 +- struct drm_connector_list_iter iter;
1720 +-
1721 +- mutex_lock(&drm_dev->mode_config.mutex);
1722 +- drm_modeset_lock(&drm_dev->mode_config.connection_mutex, NULL);
1723 +-
1724 +- drm_connector_list_iter_begin(drm_dev, &iter);
1725 +- drm_for_each_connector_iter(list_connector, &iter) {
1726 +- if (list_connector->dpms == DRM_MODE_DPMS_ON) {
1727 +- ret = -EBUSY;
1728 +- break;
1729 +- }
1730 +- }
1731 +-
1732 +- drm_connector_list_iter_end(&iter);
1733 +-
1734 +- drm_modeset_unlock(&drm_dev->mode_config.connection_mutex);
1735 +- mutex_unlock(&drm_dev->mode_config.mutex);
1736 +- }
1737 +-
1738 +- if (ret == -EBUSY)
1739 +- DRM_DEBUG_DRIVER("failing to power off - crtc active\n");
1740 ++ ret = amdgpu_runtime_idle_check_display(dev);
1741 +
1742 + pm_runtime_mark_last_busy(dev);
1743 + pm_runtime_autosuspend(dev);
1744 +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
1745 +index 4b6814949aad0..8d40b93747e06 100644
1746 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
1747 ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
1748 +@@ -129,19 +129,33 @@ void program_sh_mem_settings(struct device_queue_manager *dqm,
1749 + }
1750 +
1751 + static void increment_queue_count(struct device_queue_manager *dqm,
1752 +- enum kfd_queue_type type)
1753 ++ struct qcm_process_device *qpd,
1754 ++ struct queue *q)
1755 + {
1756 + dqm->active_queue_count++;
1757 +- if (type == KFD_QUEUE_TYPE_COMPUTE || type == KFD_QUEUE_TYPE_DIQ)
1758 ++ if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE ||
1759 ++ q->properties.type == KFD_QUEUE_TYPE_DIQ)
1760 + dqm->active_cp_queue_count++;
1761 ++
1762 ++ if (q->properties.is_gws) {
1763 ++ dqm->gws_queue_count++;
1764 ++ qpd->mapped_gws_queue = true;
1765 ++ }
1766 + }
1767 +
1768 + static void decrement_queue_count(struct device_queue_manager *dqm,
1769 +- enum kfd_queue_type type)
1770 ++ struct qcm_process_device *qpd,
1771 ++ struct queue *q)
1772 + {
1773 + dqm->active_queue_count--;
1774 +- if (type == KFD_QUEUE_TYPE_COMPUTE || type == KFD_QUEUE_TYPE_DIQ)
1775 ++ if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE ||
1776 ++ q->properties.type == KFD_QUEUE_TYPE_DIQ)
1777 + dqm->active_cp_queue_count--;
1778 ++
1779 ++ if (q->properties.is_gws) {
1780 ++ dqm->gws_queue_count--;
1781 ++ qpd->mapped_gws_queue = false;
1782 ++ }
1783 + }
1784 +
1785 + static int allocate_doorbell(struct qcm_process_device *qpd, struct queue *q)
1786 +@@ -380,7 +394,7 @@ add_queue_to_list:
1787 + list_add(&q->list, &qpd->queues_list);
1788 + qpd->queue_count++;
1789 + if (q->properties.is_active)
1790 +- increment_queue_count(dqm, q->properties.type);
1791 ++ increment_queue_count(dqm, qpd, q);
1792 +
1793 + /*
1794 + * Unconditionally increment this counter, regardless of the queue's
1795 +@@ -505,13 +519,8 @@ static int destroy_queue_nocpsch_locked(struct device_queue_manager *dqm,
1796 + deallocate_vmid(dqm, qpd, q);
1797 + }
1798 + qpd->queue_count--;
1799 +- if (q->properties.is_active) {
1800 +- decrement_queue_count(dqm, q->properties.type);
1801 +- if (q->properties.is_gws) {
1802 +- dqm->gws_queue_count--;
1803 +- qpd->mapped_gws_queue = false;
1804 +- }
1805 +- }
1806 ++ if (q->properties.is_active)
1807 ++ decrement_queue_count(dqm, qpd, q);
1808 +
1809 + return retval;
1810 + }
1811 +@@ -604,12 +613,11 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q,
1812 + * dqm->active_queue_count to determine whether a new runlist must be
1813 + * uploaded.
1814 + */
1815 +- if (q->properties.is_active && !prev_active)
1816 +- increment_queue_count(dqm, q->properties.type);
1817 +- else if (!q->properties.is_active && prev_active)
1818 +- decrement_queue_count(dqm, q->properties.type);
1819 +-
1820 +- if (q->gws && !q->properties.is_gws) {
1821 ++ if (q->properties.is_active && !prev_active) {
1822 ++ increment_queue_count(dqm, &pdd->qpd, q);
1823 ++ } else if (!q->properties.is_active && prev_active) {
1824 ++ decrement_queue_count(dqm, &pdd->qpd, q);
1825 ++ } else if (q->gws && !q->properties.is_gws) {
1826 + if (q->properties.is_active) {
1827 + dqm->gws_queue_count++;
1828 + pdd->qpd.mapped_gws_queue = true;
1829 +@@ -671,11 +679,7 @@ static int evict_process_queues_nocpsch(struct device_queue_manager *dqm,
1830 + mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type(
1831 + q->properties.type)];
1832 + q->properties.is_active = false;
1833 +- decrement_queue_count(dqm, q->properties.type);
1834 +- if (q->properties.is_gws) {
1835 +- dqm->gws_queue_count--;
1836 +- qpd->mapped_gws_queue = false;
1837 +- }
1838 ++ decrement_queue_count(dqm, qpd, q);
1839 +
1840 + if (WARN_ONCE(!dqm->sched_running, "Evict when stopped\n"))
1841 + continue;
1842 +@@ -721,7 +725,7 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,
1843 + continue;
1844 +
1845 + q->properties.is_active = false;
1846 +- decrement_queue_count(dqm, q->properties.type);
1847 ++ decrement_queue_count(dqm, qpd, q);
1848 + }
1849 + pdd->last_evict_timestamp = get_jiffies_64();
1850 + retval = execute_queues_cpsch(dqm,
1851 +@@ -792,11 +796,7 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm,
1852 + mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type(
1853 + q->properties.type)];
1854 + q->properties.is_active = true;
1855 +- increment_queue_count(dqm, q->properties.type);
1856 +- if (q->properties.is_gws) {
1857 +- dqm->gws_queue_count++;
1858 +- qpd->mapped_gws_queue = true;
1859 +- }
1860 ++ increment_queue_count(dqm, qpd, q);
1861 +
1862 + if (WARN_ONCE(!dqm->sched_running, "Restore when stopped\n"))
1863 + continue;
1864 +@@ -854,7 +854,7 @@ static int restore_process_queues_cpsch(struct device_queue_manager *dqm,
1865 + continue;
1866 +
1867 + q->properties.is_active = true;
1868 +- increment_queue_count(dqm, q->properties.type);
1869 ++ increment_queue_count(dqm, &pdd->qpd, q);
1870 + }
1871 + retval = execute_queues_cpsch(dqm,
1872 + KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0);
1873 +@@ -1260,7 +1260,7 @@ static int create_kernel_queue_cpsch(struct device_queue_manager *dqm,
1874 + dqm->total_queue_count);
1875 +
1876 + list_add(&kq->list, &qpd->priv_queue_list);
1877 +- increment_queue_count(dqm, kq->queue->properties.type);
1878 ++ increment_queue_count(dqm, qpd, kq->queue);
1879 + qpd->is_debug = true;
1880 + execute_queues_cpsch(dqm, KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0);
1881 + dqm_unlock(dqm);
1882 +@@ -1274,7 +1274,7 @@ static void destroy_kernel_queue_cpsch(struct device_queue_manager *dqm,
1883 + {
1884 + dqm_lock(dqm);
1885 + list_del(&kq->list);
1886 +- decrement_queue_count(dqm, kq->queue->properties.type);
1887 ++ decrement_queue_count(dqm, qpd, kq->queue);
1888 + qpd->is_debug = false;
1889 + execute_queues_cpsch(dqm, KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES, 0);
1890 + /*
1891 +@@ -1341,7 +1341,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
1892 + qpd->queue_count++;
1893 +
1894 + if (q->properties.is_active) {
1895 +- increment_queue_count(dqm, q->properties.type);
1896 ++ increment_queue_count(dqm, qpd, q);
1897 +
1898 + execute_queues_cpsch(dqm,
1899 + KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0);
1900 +@@ -1558,15 +1558,11 @@ static int destroy_queue_cpsch(struct device_queue_manager *dqm,
1901 + list_del(&q->list);
1902 + qpd->queue_count--;
1903 + if (q->properties.is_active) {
1904 +- decrement_queue_count(dqm, q->properties.type);
1905 ++ decrement_queue_count(dqm, qpd, q);
1906 + retval = execute_queues_cpsch(dqm,
1907 + KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0);
1908 + if (retval == -ETIME)
1909 + qpd->reset_wavefronts = true;
1910 +- if (q->properties.is_gws) {
1911 +- dqm->gws_queue_count--;
1912 +- qpd->mapped_gws_queue = false;
1913 +- }
1914 + }
1915 +
1916 + /*
1917 +@@ -1757,7 +1753,7 @@ static int process_termination_cpsch(struct device_queue_manager *dqm,
1918 + /* Clean all kernel queues */
1919 + list_for_each_entry_safe(kq, kq_next, &qpd->priv_queue_list, list) {
1920 + list_del(&kq->list);
1921 +- decrement_queue_count(dqm, kq->queue->properties.type);
1922 ++ decrement_queue_count(dqm, qpd, kq->queue);
1923 + qpd->is_debug = false;
1924 + dqm->total_queue_count--;
1925 + filter = KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES;
1926 +@@ -1770,13 +1766,8 @@ static int process_termination_cpsch(struct device_queue_manager *dqm,
1927 + else if (q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
1928 + deallocate_sdma_queue(dqm, q);
1929 +
1930 +- if (q->properties.is_active) {
1931 +- decrement_queue_count(dqm, q->properties.type);
1932 +- if (q->properties.is_gws) {
1933 +- dqm->gws_queue_count--;
1934 +- qpd->mapped_gws_queue = false;
1935 +- }
1936 +- }
1937 ++ if (q->properties.is_active)
1938 ++ decrement_queue_count(dqm, qpd, q);
1939 +
1940 + dqm->total_queue_count--;
1941 + }
1942 +diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
1943 +index ca1bbc942fd40..67f3cae553e0d 100644
1944 +--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
1945 ++++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
1946 +@@ -1427,6 +1427,7 @@ static struct clock_source *dcn21_clock_source_create(
1947 + return &clk_src->base;
1948 + }
1949 +
1950 ++ kfree(clk_src);
1951 + BREAK_TO_DEBUGGER();
1952 + return NULL;
1953 + }
1954 +diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
1955 +index 97cf3cac01058..fb6cf30ee6281 100644
1956 +--- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
1957 ++++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
1958 +@@ -97,6 +97,14 @@
1959 +
1960 + #define INTEL_EDP_BRIGHTNESS_OPTIMIZATION_1 0x359
1961 +
1962 ++enum intel_dp_aux_backlight_modparam {
1963 ++ INTEL_DP_AUX_BACKLIGHT_AUTO = -1,
1964 ++ INTEL_DP_AUX_BACKLIGHT_OFF = 0,
1965 ++ INTEL_DP_AUX_BACKLIGHT_ON = 1,
1966 ++ INTEL_DP_AUX_BACKLIGHT_FORCE_VESA = 2,
1967 ++ INTEL_DP_AUX_BACKLIGHT_FORCE_INTEL = 3,
1968 ++};
1969 ++
1970 + /* Intel EDP backlight callbacks */
1971 + static bool
1972 + intel_dp_aux_supports_hdr_backlight(struct intel_connector *connector)
1973 +@@ -126,6 +134,24 @@ intel_dp_aux_supports_hdr_backlight(struct intel_connector *connector)
1974 + return false;
1975 + }
1976 +
1977 ++ /*
1978 ++ * If we don't have HDR static metadata there is no way to
1979 ++ * runtime detect used range for nits based control. For now
1980 ++ * do not use Intel proprietary eDP backlight control if we
1981 ++ * don't have this data in panel EDID. In case we find panel
1982 ++ * which supports only nits based control, but doesn't provide
1983 ++ * HDR static metadata we need to start maintaining table of
1984 ++ * ranges for such panels.
1985 ++ */
1986 ++ if (i915->params.enable_dpcd_backlight != INTEL_DP_AUX_BACKLIGHT_FORCE_INTEL &&
1987 ++ !(connector->base.hdr_sink_metadata.hdmi_type1.metadata_type &
1988 ++ BIT(HDMI_STATIC_METADATA_TYPE1))) {
1989 ++ drm_info(&i915->drm,
1990 ++ "Panel is missing HDR static metadata. Possible support for Intel HDR backlight interface is not used. If your backlight controls don't work try booting with i915.enable_dpcd_backlight=%d. needs this, please file a _new_ bug report on drm/i915, see " FDO_BUG_URL " for details.\n",
1991 ++ INTEL_DP_AUX_BACKLIGHT_FORCE_INTEL);
1992 ++ return false;
1993 ++ }
1994 ++
1995 + panel->backlight.edp.intel.sdr_uses_aux =
1996 + tcon_cap[2] & INTEL_EDP_SDR_TCON_BRIGHTNESS_AUX_CAP;
1997 +
1998 +@@ -413,14 +439,6 @@ static const struct intel_panel_bl_funcs intel_dp_vesa_bl_funcs = {
1999 + .get = intel_dp_aux_vesa_get_backlight,
2000 + };
2001 +
2002 +-enum intel_dp_aux_backlight_modparam {
2003 +- INTEL_DP_AUX_BACKLIGHT_AUTO = -1,
2004 +- INTEL_DP_AUX_BACKLIGHT_OFF = 0,
2005 +- INTEL_DP_AUX_BACKLIGHT_ON = 1,
2006 +- INTEL_DP_AUX_BACKLIGHT_FORCE_VESA = 2,
2007 +- INTEL_DP_AUX_BACKLIGHT_FORCE_INTEL = 3,
2008 +-};
2009 +-
2010 + int intel_dp_aux_init_backlight_funcs(struct intel_connector *connector)
2011 + {
2012 + struct drm_device *dev = connector->base.dev;
2013 +diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
2014 +index 902e4c802a123..4b8fee1be8ae5 100644
2015 +--- a/drivers/gpu/drm/i915/i915_reg.h
2016 ++++ b/drivers/gpu/drm/i915/i915_reg.h
2017 +@@ -7578,7 +7578,7 @@ enum {
2018 + #define _SEL_FETCH_PLANE_BASE_6_A 0x70940
2019 + #define _SEL_FETCH_PLANE_BASE_7_A 0x70960
2020 + #define _SEL_FETCH_PLANE_BASE_CUR_A 0x70880
2021 +-#define _SEL_FETCH_PLANE_BASE_1_B 0x70990
2022 ++#define _SEL_FETCH_PLANE_BASE_1_B 0x71890
2023 +
2024 + #define _SEL_FETCH_PLANE_BASE_A(plane) _PICK(plane, \
2025 + _SEL_FETCH_PLANE_BASE_1_A, \
2026 +diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c
2027 +index 56ae38389db0b..462fae73eae98 100644
2028 +--- a/drivers/gpu/drm/sun4i/sun4i_frontend.c
2029 ++++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c
2030 +@@ -222,13 +222,11 @@ void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend,
2031 +
2032 + /* Set the physical address of the buffer in memory */
2033 + paddr = drm_fb_cma_get_gem_addr(fb, state, 0);
2034 +- paddr -= PHYS_OFFSET;
2035 + DRM_DEBUG_DRIVER("Setting buffer #0 address to %pad\n", &paddr);
2036 + regmap_write(frontend->regs, SUN4I_FRONTEND_BUF_ADDR0_REG, paddr);
2037 +
2038 + if (fb->format->num_planes > 1) {
2039 + paddr = drm_fb_cma_get_gem_addr(fb, state, swap ? 2 : 1);
2040 +- paddr -= PHYS_OFFSET;
2041 + DRM_DEBUG_DRIVER("Setting buffer #1 address to %pad\n", &paddr);
2042 + regmap_write(frontend->regs, SUN4I_FRONTEND_BUF_ADDR1_REG,
2043 + paddr);
2044 +@@ -236,7 +234,6 @@ void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend,
2045 +
2046 + if (fb->format->num_planes > 2) {
2047 + paddr = drm_fb_cma_get_gem_addr(fb, state, swap ? 1 : 2);
2048 +- paddr -= PHYS_OFFSET;
2049 + DRM_DEBUG_DRIVER("Setting buffer #2 address to %pad\n", &paddr);
2050 + regmap_write(frontend->regs, SUN4I_FRONTEND_BUF_ADDR2_REG,
2051 + paddr);
2052 +diff --git a/drivers/iio/chemical/scd4x.c b/drivers/iio/chemical/scd4x.c
2053 +index 267bc3c053380..746a40365e976 100644
2054 +--- a/drivers/iio/chemical/scd4x.c
2055 ++++ b/drivers/iio/chemical/scd4x.c
2056 +@@ -471,12 +471,15 @@ static ssize_t calibration_forced_value_store(struct device *dev,
2057 + ret = scd4x_write_and_fetch(state, CMD_FRC, arg, &val, sizeof(val));
2058 + mutex_unlock(&state->lock);
2059 +
2060 ++ if (ret)
2061 ++ return ret;
2062 ++
2063 + if (val == 0xff) {
2064 + dev_err(dev, "forced calibration has failed");
2065 + return -EINVAL;
2066 + }
2067 +
2068 +- return ret ?: len;
2069 ++ return len;
2070 + }
2071 +
2072 + static IIO_DEVICE_ATTR_RW(calibration_auto_enable, 0);
2073 +diff --git a/drivers/iio/dac/ad3552r.c b/drivers/iio/dac/ad3552r.c
2074 +index 97f13c0b96312..d5ea1a1be1226 100644
2075 +--- a/drivers/iio/dac/ad3552r.c
2076 ++++ b/drivers/iio/dac/ad3552r.c
2077 +@@ -656,7 +656,7 @@ static int ad3552r_reset(struct ad3552r_desc *dac)
2078 + {
2079 + struct reg_addr_pool addr;
2080 + int ret;
2081 +- u16 val;
2082 ++ int val;
2083 +
2084 + dac->gpio_reset = devm_gpiod_get_optional(&dac->spi->dev, "reset",
2085 + GPIOD_OUT_LOW);
2086 +@@ -809,10 +809,10 @@ static int ad3552r_configure_custom_gain(struct ad3552r_desc *dac,
2087 +
2088 + gain_child = fwnode_get_named_child_node(child,
2089 + "custom-output-range-config");
2090 +- if (IS_ERR(gain_child)) {
2091 ++ if (!gain_child) {
2092 + dev_err(dev,
2093 + "mandatory custom-output-range-config property missing\n");
2094 +- return PTR_ERR(gain_child);
2095 ++ return -EINVAL;
2096 + }
2097 +
2098 + dac->ch_data[ch].range_override = 1;
2099 +diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c
2100 +index 1c9b54c012a7e..ddf18f13fa4ee 100644
2101 +--- a/drivers/iio/dac/ad5446.c
2102 ++++ b/drivers/iio/dac/ad5446.c
2103 +@@ -178,7 +178,7 @@ static int ad5446_read_raw(struct iio_dev *indio_dev,
2104 +
2105 + switch (m) {
2106 + case IIO_CHAN_INFO_RAW:
2107 +- *val = st->cached_val;
2108 ++ *val = st->cached_val >> chan->scan_type.shift;
2109 + return IIO_VAL_INT;
2110 + case IIO_CHAN_INFO_SCALE:
2111 + *val = st->vref_mv;
2112 +diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
2113 +index 2fcc59728fd6b..4f58d1ad68d73 100644
2114 +--- a/drivers/iio/dac/ad5592r-base.c
2115 ++++ b/drivers/iio/dac/ad5592r-base.c
2116 +@@ -523,7 +523,7 @@ static int ad5592r_alloc_channels(struct iio_dev *iio_dev)
2117 + if (!ret)
2118 + st->channel_modes[reg] = tmp;
2119 +
2120 +- fwnode_property_read_u32(child, "adi,off-state", &tmp);
2121 ++ ret = fwnode_property_read_u32(child, "adi,off-state", &tmp);
2122 + if (!ret)
2123 + st->channel_offstate[reg] = tmp;
2124 + }
2125 +diff --git a/drivers/iio/filter/Kconfig b/drivers/iio/filter/Kconfig
2126 +index 3ae35817ad827..a85b345ea14ef 100644
2127 +--- a/drivers/iio/filter/Kconfig
2128 ++++ b/drivers/iio/filter/Kconfig
2129 +@@ -8,6 +8,7 @@ menu "Filters"
2130 + config ADMV8818
2131 + tristate "Analog Devices ADMV8818 High-Pass and Low-Pass Filter"
2132 + depends on SPI && COMMON_CLK && 64BIT
2133 ++ select REGMAP_SPI
2134 + help
2135 + Say yes here to build support for Analog Devices ADMV8818
2136 + 2 GHz to 18 GHz, Digitally Tunable, High-Pass and Low-Pass Filter.
2137 +diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c
2138 +index 824b5124a5f55..01336105792ee 100644
2139 +--- a/drivers/iio/imu/bmi160/bmi160_core.c
2140 ++++ b/drivers/iio/imu/bmi160/bmi160_core.c
2141 +@@ -730,7 +730,7 @@ static int bmi160_chip_init(struct bmi160_data *data, bool use_spi)
2142 +
2143 + ret = regmap_write(data->regmap, BMI160_REG_CMD, BMI160_CMD_SOFTRESET);
2144 + if (ret)
2145 +- return ret;
2146 ++ goto disable_regulator;
2147 +
2148 + usleep_range(BMI160_SOFTRESET_USLEEP, BMI160_SOFTRESET_USLEEP + 1);
2149 +
2150 +@@ -741,29 +741,37 @@ static int bmi160_chip_init(struct bmi160_data *data, bool use_spi)
2151 + if (use_spi) {
2152 + ret = regmap_read(data->regmap, BMI160_REG_DUMMY, &val);
2153 + if (ret)
2154 +- return ret;
2155 ++ goto disable_regulator;
2156 + }
2157 +
2158 + ret = regmap_read(data->regmap, BMI160_REG_CHIP_ID, &val);
2159 + if (ret) {
2160 + dev_err(dev, "Error reading chip id\n");
2161 +- return ret;
2162 ++ goto disable_regulator;
2163 + }
2164 + if (val != BMI160_CHIP_ID_VAL) {
2165 + dev_err(dev, "Wrong chip id, got %x expected %x\n",
2166 + val, BMI160_CHIP_ID_VAL);
2167 +- return -ENODEV;
2168 ++ ret = -ENODEV;
2169 ++ goto disable_regulator;
2170 + }
2171 +
2172 + ret = bmi160_set_mode(data, BMI160_ACCEL, true);
2173 + if (ret)
2174 +- return ret;
2175 ++ goto disable_regulator;
2176 +
2177 + ret = bmi160_set_mode(data, BMI160_GYRO, true);
2178 + if (ret)
2179 +- return ret;
2180 ++ goto disable_accel;
2181 +
2182 + return 0;
2183 ++
2184 ++disable_accel:
2185 ++ bmi160_set_mode(data, BMI160_ACCEL, false);
2186 ++
2187 ++disable_regulator:
2188 ++ regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies);
2189 ++ return ret;
2190 + }
2191 +
2192 + static int bmi160_data_rdy_trigger_set_state(struct iio_trigger *trig,
2193 +diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c
2194 +index 33d9afb1ba914..d4a692b838d0f 100644
2195 +--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c
2196 ++++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c
2197 +@@ -18,12 +18,15 @@ static int inv_icm42600_i2c_bus_setup(struct inv_icm42600_state *st)
2198 + unsigned int mask, val;
2199 + int ret;
2200 +
2201 +- /* setup interface registers */
2202 +- ret = regmap_update_bits(st->map, INV_ICM42600_REG_INTF_CONFIG6,
2203 +- INV_ICM42600_INTF_CONFIG6_MASK,
2204 +- INV_ICM42600_INTF_CONFIG6_I3C_EN);
2205 +- if (ret)
2206 +- return ret;
2207 ++ /*
2208 ++ * setup interface registers
2209 ++ * This register write to REG_INTF_CONFIG6 enables a spike filter that
2210 ++ * is impacting the line and can prevent the I2C ACK to be seen by the
2211 ++ * controller. So we don't test the return value.
2212 ++ */
2213 ++ regmap_update_bits(st->map, INV_ICM42600_REG_INTF_CONFIG6,
2214 ++ INV_ICM42600_INTF_CONFIG6_MASK,
2215 ++ INV_ICM42600_INTF_CONFIG6_I3C_EN);
2216 +
2217 + ret = regmap_update_bits(st->map, INV_ICM42600_REG_INTF_CONFIG4,
2218 + INV_ICM42600_INTF_CONFIG4_I3C_BUS_ONLY, 0);
2219 +diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
2220 +index 55879a20ae52e..30181bc23b387 100644
2221 +--- a/drivers/iio/magnetometer/ak8975.c
2222 ++++ b/drivers/iio/magnetometer/ak8975.c
2223 +@@ -416,6 +416,7 @@ static int ak8975_power_on(const struct ak8975_data *data)
2224 + if (ret) {
2225 + dev_warn(&data->client->dev,
2226 + "Failed to enable specified Vid supply\n");
2227 ++ regulator_disable(data->vdd);
2228 + return ret;
2229 + }
2230 +
2231 +diff --git a/drivers/input/keyboard/cypress-sf.c b/drivers/input/keyboard/cypress-sf.c
2232 +index c28996028e803..9a23eed6a4f41 100644
2233 +--- a/drivers/input/keyboard/cypress-sf.c
2234 ++++ b/drivers/input/keyboard/cypress-sf.c
2235 +@@ -61,6 +61,14 @@ static irqreturn_t cypress_sf_irq_handler(int irq, void *devid)
2236 + return IRQ_HANDLED;
2237 + }
2238 +
2239 ++static void cypress_sf_disable_regulators(void *arg)
2240 ++{
2241 ++ struct cypress_sf_data *touchkey = arg;
2242 ++
2243 ++ regulator_bulk_disable(ARRAY_SIZE(touchkey->regulators),
2244 ++ touchkey->regulators);
2245 ++}
2246 ++
2247 + static int cypress_sf_probe(struct i2c_client *client)
2248 + {
2249 + struct cypress_sf_data *touchkey;
2250 +@@ -121,6 +129,12 @@ static int cypress_sf_probe(struct i2c_client *client)
2251 + return error;
2252 + }
2253 +
2254 ++ error = devm_add_action_or_reset(&client->dev,
2255 ++ cypress_sf_disable_regulators,
2256 ++ touchkey);
2257 ++ if (error)
2258 ++ return error;
2259 ++
2260 + touchkey->input_dev = devm_input_allocate_device(&client->dev);
2261 + if (!touchkey->input_dev) {
2262 + dev_err(&client->dev, "Failed to allocate input device\n");
2263 +diff --git a/drivers/interconnect/qcom/sc7180.c b/drivers/interconnect/qcom/sc7180.c
2264 +index 12d59c36df530..5f7c0f85fa8e3 100644
2265 +--- a/drivers/interconnect/qcom/sc7180.c
2266 ++++ b/drivers/interconnect/qcom/sc7180.c
2267 +@@ -47,7 +47,6 @@ DEFINE_QNODE(qnm_mnoc_sf, SC7180_MASTER_MNOC_SF_MEM_NOC, 1, 32, SC7180_SLAVE_GEM
2268 + DEFINE_QNODE(qnm_snoc_gc, SC7180_MASTER_SNOC_GC_MEM_NOC, 1, 8, SC7180_SLAVE_LLCC);
2269 + DEFINE_QNODE(qnm_snoc_sf, SC7180_MASTER_SNOC_SF_MEM_NOC, 1, 16, SC7180_SLAVE_LLCC);
2270 + DEFINE_QNODE(qxm_gpu, SC7180_MASTER_GFX3D, 2, 32, SC7180_SLAVE_GEM_NOC_SNOC, SC7180_SLAVE_LLCC);
2271 +-DEFINE_QNODE(ipa_core_master, SC7180_MASTER_IPA_CORE, 1, 8, SC7180_SLAVE_IPA_CORE);
2272 + DEFINE_QNODE(llcc_mc, SC7180_MASTER_LLCC, 2, 4, SC7180_SLAVE_EBI1);
2273 + DEFINE_QNODE(qhm_mnoc_cfg, SC7180_MASTER_CNOC_MNOC_CFG, 1, 4, SC7180_SLAVE_SERVICE_MNOC);
2274 + DEFINE_QNODE(qxm_camnoc_hf0, SC7180_MASTER_CAMNOC_HF0, 2, 32, SC7180_SLAVE_MNOC_HF_MEM_NOC);
2275 +@@ -129,7 +128,6 @@ DEFINE_QNODE(qhs_mdsp_ms_mpu_cfg, SC7180_SLAVE_MSS_PROC_MS_MPU_CFG, 1, 4);
2276 + DEFINE_QNODE(qns_gem_noc_snoc, SC7180_SLAVE_GEM_NOC_SNOC, 1, 8, SC7180_MASTER_GEM_NOC_SNOC);
2277 + DEFINE_QNODE(qns_llcc, SC7180_SLAVE_LLCC, 1, 16, SC7180_MASTER_LLCC);
2278 + DEFINE_QNODE(srvc_gemnoc, SC7180_SLAVE_SERVICE_GEM_NOC, 1, 4);
2279 +-DEFINE_QNODE(ipa_core_slave, SC7180_SLAVE_IPA_CORE, 1, 8);
2280 + DEFINE_QNODE(ebi, SC7180_SLAVE_EBI1, 2, 4);
2281 + DEFINE_QNODE(qns_mem_noc_hf, SC7180_SLAVE_MNOC_HF_MEM_NOC, 1, 32, SC7180_MASTER_MNOC_HF_MEM_NOC);
2282 + DEFINE_QNODE(qns_mem_noc_sf, SC7180_SLAVE_MNOC_SF_MEM_NOC, 1, 32, SC7180_MASTER_MNOC_SF_MEM_NOC);
2283 +@@ -160,7 +158,6 @@ DEFINE_QBCM(bcm_mc0, "MC0", true, &ebi);
2284 + DEFINE_QBCM(bcm_sh0, "SH0", true, &qns_llcc);
2285 + DEFINE_QBCM(bcm_mm0, "MM0", false, &qns_mem_noc_hf);
2286 + DEFINE_QBCM(bcm_ce0, "CE0", false, &qxm_crypto);
2287 +-DEFINE_QBCM(bcm_ip0, "IP0", false, &ipa_core_slave);
2288 + DEFINE_QBCM(bcm_cn0, "CN0", true, &qnm_snoc, &xm_qdss_dap, &qhs_a1_noc_cfg, &qhs_a2_noc_cfg, &qhs_ahb2phy0, &qhs_aop, &qhs_aoss, &qhs_boot_rom, &qhs_camera_cfg, &qhs_camera_nrt_throttle_cfg, &qhs_camera_rt_throttle_cfg, &qhs_clk_ctl, &qhs_cpr_cx, &qhs_cpr_mx, &qhs_crypto0_cfg, &qhs_dcc_cfg, &qhs_ddrss_cfg, &qhs_display_cfg, &qhs_display_rt_throttle_cfg, &qhs_display_throttle_cfg, &qhs_glm, &qhs_gpuss_cfg, &qhs_imem_cfg, &qhs_ipa, &qhs_mnoc_cfg, &qhs_mss_cfg, &qhs_npu_cfg, &qhs_npu_dma_throttle_cfg, &qhs_npu_dsp_throttle_cfg, &qhs_pimem_cfg, &qhs_prng, &qhs_qdss_cfg, &qhs_qm_cfg, &qhs_qm_mpu_cfg, &qhs_qup0, &qhs_qup1, &qhs_security, &qhs_snoc_cfg, &qhs_tcsr, &qhs_tlmm_1, &qhs_tlmm_2, &qhs_tlmm_3, &qhs_ufs_mem_cfg, &qhs_usb3, &qhs_venus_cfg, &qhs_venus_throttle_cfg, &qhs_vsense_ctrl_cfg, &srvc_cnoc);
2289 + DEFINE_QBCM(bcm_mm1, "MM1", false, &qxm_camnoc_hf0_uncomp, &qxm_camnoc_hf1_uncomp, &qxm_camnoc_sf_uncomp, &qhm_mnoc_cfg, &qxm_mdp0, &qxm_rot, &qxm_venus0, &qxm_venus_arm9);
2290 + DEFINE_QBCM(bcm_sh2, "SH2", false, &acm_sys_tcu);
2291 +@@ -372,22 +369,6 @@ static struct qcom_icc_desc sc7180_gem_noc = {
2292 + .num_bcms = ARRAY_SIZE(gem_noc_bcms),
2293 + };
2294 +
2295 +-static struct qcom_icc_bcm *ipa_virt_bcms[] = {
2296 +- &bcm_ip0,
2297 +-};
2298 +-
2299 +-static struct qcom_icc_node *ipa_virt_nodes[] = {
2300 +- [MASTER_IPA_CORE] = &ipa_core_master,
2301 +- [SLAVE_IPA_CORE] = &ipa_core_slave,
2302 +-};
2303 +-
2304 +-static struct qcom_icc_desc sc7180_ipa_virt = {
2305 +- .nodes = ipa_virt_nodes,
2306 +- .num_nodes = ARRAY_SIZE(ipa_virt_nodes),
2307 +- .bcms = ipa_virt_bcms,
2308 +- .num_bcms = ARRAY_SIZE(ipa_virt_bcms),
2309 +-};
2310 +-
2311 + static struct qcom_icc_bcm *mc_virt_bcms[] = {
2312 + &bcm_acv,
2313 + &bcm_mc0,
2314 +@@ -519,8 +500,6 @@ static const struct of_device_id qnoc_of_match[] = {
2315 + .data = &sc7180_dc_noc},
2316 + { .compatible = "qcom,sc7180-gem-noc",
2317 + .data = &sc7180_gem_noc},
2318 +- { .compatible = "qcom,sc7180-ipa-virt",
2319 +- .data = &sc7180_ipa_virt},
2320 + { .compatible = "qcom,sc7180-mc-virt",
2321 + .data = &sc7180_mc_virt},
2322 + { .compatible = "qcom,sc7180-mmss-noc",
2323 +diff --git a/drivers/interconnect/qcom/sdx55.c b/drivers/interconnect/qcom/sdx55.c
2324 +index 03d604f84cc57..e3ac25a997b71 100644
2325 +--- a/drivers/interconnect/qcom/sdx55.c
2326 ++++ b/drivers/interconnect/qcom/sdx55.c
2327 +@@ -18,7 +18,6 @@
2328 + #include "icc-rpmh.h"
2329 + #include "sdx55.h"
2330 +
2331 +-DEFINE_QNODE(ipa_core_master, SDX55_MASTER_IPA_CORE, 1, 8, SDX55_SLAVE_IPA_CORE);
2332 + DEFINE_QNODE(llcc_mc, SDX55_MASTER_LLCC, 4, 4, SDX55_SLAVE_EBI_CH0);
2333 + DEFINE_QNODE(acm_tcu, SDX55_MASTER_TCU_0, 1, 8, SDX55_SLAVE_LLCC, SDX55_SLAVE_MEM_NOC_SNOC, SDX55_SLAVE_MEM_NOC_PCIE_SNOC);
2334 + DEFINE_QNODE(qnm_snoc_gc, SDX55_MASTER_SNOC_GC_MEM_NOC, 1, 8, SDX55_SLAVE_LLCC);
2335 +@@ -40,7 +39,6 @@ DEFINE_QNODE(xm_pcie, SDX55_MASTER_PCIE, 1, 8, SDX55_SLAVE_ANOC_SNOC);
2336 + DEFINE_QNODE(xm_qdss_etr, SDX55_MASTER_QDSS_ETR, 1, 8, SDX55_SLAVE_SNOC_CFG, SDX55_SLAVE_EMAC_CFG, SDX55_SLAVE_USB3, SDX55_SLAVE_AOSS, SDX55_SLAVE_SPMI_FETCHER, SDX55_SLAVE_QDSS_CFG, SDX55_SLAVE_PDM, SDX55_SLAVE_SNOC_MEM_NOC_GC, SDX55_SLAVE_TCSR, SDX55_SLAVE_CNOC_DDRSS, SDX55_SLAVE_SPMI_VGI_COEX, SDX55_SLAVE_QPIC, SDX55_SLAVE_OCIMEM, SDX55_SLAVE_IPA_CFG, SDX55_SLAVE_USB3_PHY_CFG, SDX55_SLAVE_AOP, SDX55_SLAVE_BLSP_1, SDX55_SLAVE_SDCC_1, SDX55_SLAVE_CNOC_MSS, SDX55_SLAVE_PCIE_PARF, SDX55_SLAVE_ECC_CFG, SDX55_SLAVE_AUDIO, SDX55_SLAVE_AOSS, SDX55_SLAVE_PRNG, SDX55_SLAVE_CRYPTO_0_CFG, SDX55_SLAVE_TCU, SDX55_SLAVE_CLK_CTL, SDX55_SLAVE_IMEM_CFG);
2337 + DEFINE_QNODE(xm_sdc1, SDX55_MASTER_SDCC_1, 1, 8, SDX55_SLAVE_AOSS, SDX55_SLAVE_IPA_CFG, SDX55_SLAVE_ANOC_SNOC, SDX55_SLAVE_AOP, SDX55_SLAVE_AUDIO);
2338 + DEFINE_QNODE(xm_usb3, SDX55_MASTER_USB3, 1, 8, SDX55_SLAVE_ANOC_SNOC);
2339 +-DEFINE_QNODE(ipa_core_slave, SDX55_SLAVE_IPA_CORE, 1, 8);
2340 + DEFINE_QNODE(ebi, SDX55_SLAVE_EBI_CH0, 1, 4);
2341 + DEFINE_QNODE(qns_llcc, SDX55_SLAVE_LLCC, 1, 16, SDX55_SLAVE_EBI_CH0);
2342 + DEFINE_QNODE(qns_memnoc_snoc, SDX55_SLAVE_MEM_NOC_SNOC, 1, 8, SDX55_MASTER_MEM_NOC_SNOC);
2343 +@@ -82,7 +80,6 @@ DEFINE_QNODE(xs_sys_tcu_cfg, SDX55_SLAVE_TCU, 1, 8);
2344 + DEFINE_QBCM(bcm_mc0, "MC0", true, &ebi);
2345 + DEFINE_QBCM(bcm_sh0, "SH0", true, &qns_llcc);
2346 + DEFINE_QBCM(bcm_ce0, "CE0", false, &qxm_crypto);
2347 +-DEFINE_QBCM(bcm_ip0, "IP0", false, &ipa_core_slave);
2348 + DEFINE_QBCM(bcm_pn0, "PN0", false, &qhm_snoc_cfg);
2349 + DEFINE_QBCM(bcm_sh3, "SH3", false, &xm_apps_rdwr);
2350 + DEFINE_QBCM(bcm_sh4, "SH4", false, &qns_memnoc_snoc, &qns_sys_pcie);
2351 +@@ -219,22 +216,6 @@ static const struct qcom_icc_desc sdx55_system_noc = {
2352 + .num_bcms = ARRAY_SIZE(system_noc_bcms),
2353 + };
2354 +
2355 +-static struct qcom_icc_bcm *ipa_virt_bcms[] = {
2356 +- &bcm_ip0,
2357 +-};
2358 +-
2359 +-static struct qcom_icc_node *ipa_virt_nodes[] = {
2360 +- [MASTER_IPA_CORE] = &ipa_core_master,
2361 +- [SLAVE_IPA_CORE] = &ipa_core_slave,
2362 +-};
2363 +-
2364 +-static const struct qcom_icc_desc sdx55_ipa_virt = {
2365 +- .nodes = ipa_virt_nodes,
2366 +- .num_nodes = ARRAY_SIZE(ipa_virt_nodes),
2367 +- .bcms = ipa_virt_bcms,
2368 +- .num_bcms = ARRAY_SIZE(ipa_virt_bcms),
2369 +-};
2370 +-
2371 + static const struct of_device_id qnoc_of_match[] = {
2372 + { .compatible = "qcom,sdx55-mc-virt",
2373 + .data = &sdx55_mc_virt},
2374 +@@ -242,8 +223,6 @@ static const struct of_device_id qnoc_of_match[] = {
2375 + .data = &sdx55_mem_noc},
2376 + { .compatible = "qcom,sdx55-system-noc",
2377 + .data = &sdx55_system_noc},
2378 +- { .compatible = "qcom,sdx55-ipa-virt",
2379 +- .data = &sdx55_ipa_virt},
2380 + { }
2381 + };
2382 + MODULE_DEVICE_TABLE(of, qnoc_of_match);
2383 +diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-if.c
2384 +index 2e545f473cc68..019a0822bde0e 100644
2385 +--- a/drivers/memory/renesas-rpc-if.c
2386 ++++ b/drivers/memory/renesas-rpc-if.c
2387 +@@ -164,25 +164,39 @@ static const struct regmap_access_table rpcif_volatile_table = {
2388 +
2389 +
2390 + /*
2391 +- * Custom accessor functions to ensure SMRDR0 and SMWDR0 are always accessed
2392 +- * with proper width. Requires SMENR_SPIDE to be correctly set before!
2393 ++ * Custom accessor functions to ensure SM[RW]DR[01] are always accessed with
2394 ++ * proper width. Requires rpcif.xfer_size to be correctly set before!
2395 + */
2396 + static int rpcif_reg_read(void *context, unsigned int reg, unsigned int *val)
2397 + {
2398 + struct rpcif *rpc = context;
2399 +
2400 +- if (reg == RPCIF_SMRDR0 || reg == RPCIF_SMWDR0) {
2401 +- u32 spide = readl(rpc->base + RPCIF_SMENR) & RPCIF_SMENR_SPIDE(0xF);
2402 +-
2403 +- if (spide == 0x8) {
2404 ++ switch (reg) {
2405 ++ case RPCIF_SMRDR0:
2406 ++ case RPCIF_SMWDR0:
2407 ++ switch (rpc->xfer_size) {
2408 ++ case 1:
2409 + *val = readb(rpc->base + reg);
2410 + return 0;
2411 +- } else if (spide == 0xC) {
2412 ++
2413 ++ case 2:
2414 + *val = readw(rpc->base + reg);
2415 + return 0;
2416 +- } else if (spide != 0xF) {
2417 ++
2418 ++ case 4:
2419 ++ case 8:
2420 ++ *val = readl(rpc->base + reg);
2421 ++ return 0;
2422 ++
2423 ++ default:
2424 + return -EILSEQ;
2425 + }
2426 ++
2427 ++ case RPCIF_SMRDR1:
2428 ++ case RPCIF_SMWDR1:
2429 ++ if (rpc->xfer_size != 8)
2430 ++ return -EILSEQ;
2431 ++ break;
2432 + }
2433 +
2434 + *val = readl(rpc->base + reg);
2435 +@@ -193,18 +207,34 @@ static int rpcif_reg_write(void *context, unsigned int reg, unsigned int val)
2436 + {
2437 + struct rpcif *rpc = context;
2438 +
2439 +- if (reg == RPCIF_SMRDR0 || reg == RPCIF_SMWDR0) {
2440 +- u32 spide = readl(rpc->base + RPCIF_SMENR) & RPCIF_SMENR_SPIDE(0xF);
2441 +-
2442 +- if (spide == 0x8) {
2443 ++ switch (reg) {
2444 ++ case RPCIF_SMWDR0:
2445 ++ switch (rpc->xfer_size) {
2446 ++ case 1:
2447 + writeb(val, rpc->base + reg);
2448 + return 0;
2449 +- } else if (spide == 0xC) {
2450 ++
2451 ++ case 2:
2452 + writew(val, rpc->base + reg);
2453 + return 0;
2454 +- } else if (spide != 0xF) {
2455 ++
2456 ++ case 4:
2457 ++ case 8:
2458 ++ writel(val, rpc->base + reg);
2459 ++ return 0;
2460 ++
2461 ++ default:
2462 + return -EILSEQ;
2463 + }
2464 ++
2465 ++ case RPCIF_SMWDR1:
2466 ++ if (rpc->xfer_size != 8)
2467 ++ return -EILSEQ;
2468 ++ break;
2469 ++
2470 ++ case RPCIF_SMRDR0:
2471 ++ case RPCIF_SMRDR1:
2472 ++ return -EPERM;
2473 + }
2474 +
2475 + writel(val, rpc->base + reg);
2476 +@@ -469,6 +499,7 @@ int rpcif_manual_xfer(struct rpcif *rpc)
2477 +
2478 + smenr |= RPCIF_SMENR_SPIDE(rpcif_bits_set(rpc, nbytes));
2479 + regmap_write(rpc->regmap, RPCIF_SMENR, smenr);
2480 ++ rpc->xfer_size = nbytes;
2481 +
2482 + memcpy(data, rpc->buffer + pos, nbytes);
2483 + if (nbytes == 8) {
2484 +@@ -533,6 +564,7 @@ int rpcif_manual_xfer(struct rpcif *rpc)
2485 + regmap_write(rpc->regmap, RPCIF_SMENR, smenr);
2486 + regmap_write(rpc->regmap, RPCIF_SMCR,
2487 + rpc->smcr | RPCIF_SMCR_SPIE);
2488 ++ rpc->xfer_size = nbytes;
2489 + ret = wait_msg_xfer_end(rpc);
2490 + if (ret)
2491 + goto err_out;
2492 +diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
2493 +index bee727ed98db5..d22044edcc9fb 100644
2494 +--- a/drivers/misc/eeprom/at25.c
2495 ++++ b/drivers/misc/eeprom/at25.c
2496 +@@ -31,6 +31,8 @@
2497 + */
2498 +
2499 + #define FM25_SN_LEN 8 /* serial number length */
2500 ++#define EE_MAXADDRLEN 3 /* 24 bit addresses, up to 2 MBytes */
2501 ++
2502 + struct at25_data {
2503 + struct spi_eeprom chip;
2504 + struct spi_device *spi;
2505 +@@ -39,6 +41,7 @@ struct at25_data {
2506 + struct nvmem_config nvmem_config;
2507 + struct nvmem_device *nvmem;
2508 + u8 sernum[FM25_SN_LEN];
2509 ++ u8 command[EE_MAXADDRLEN + 1];
2510 + };
2511 +
2512 + #define AT25_WREN 0x06 /* latch the write enable */
2513 +@@ -61,8 +64,6 @@ struct at25_data {
2514 +
2515 + #define FM25_ID_LEN 9 /* ID length */
2516 +
2517 +-#define EE_MAXADDRLEN 3 /* 24 bit addresses, up to 2 MBytes */
2518 +-
2519 + /*
2520 + * Specs often allow 5ms for a page write, sometimes 20ms;
2521 + * it's important to recover from write timeouts.
2522 +@@ -78,7 +79,6 @@ static int at25_ee_read(void *priv, unsigned int offset,
2523 + {
2524 + struct at25_data *at25 = priv;
2525 + char *buf = val;
2526 +- u8 command[EE_MAXADDRLEN + 1];
2527 + u8 *cp;
2528 + ssize_t status;
2529 + struct spi_transfer t[2];
2530 +@@ -92,12 +92,15 @@ static int at25_ee_read(void *priv, unsigned int offset,
2531 + if (unlikely(!count))
2532 + return -EINVAL;
2533 +
2534 +- cp = command;
2535 ++ cp = at25->command;
2536 +
2537 + instr = AT25_READ;
2538 + if (at25->chip.flags & EE_INSTR_BIT3_IS_ADDR)
2539 + if (offset >= BIT(at25->addrlen * 8))
2540 + instr |= AT25_INSTR_BIT3;
2541 ++
2542 ++ mutex_lock(&at25->lock);
2543 ++
2544 + *cp++ = instr;
2545 +
2546 + /* 8/16/24-bit address is written MSB first */
2547 +@@ -116,7 +119,7 @@ static int at25_ee_read(void *priv, unsigned int offset,
2548 + spi_message_init(&m);
2549 + memset(t, 0, sizeof(t));
2550 +
2551 +- t[0].tx_buf = command;
2552 ++ t[0].tx_buf = at25->command;
2553 + t[0].len = at25->addrlen + 1;
2554 + spi_message_add_tail(&t[0], &m);
2555 +
2556 +@@ -124,8 +127,6 @@ static int at25_ee_read(void *priv, unsigned int offset,
2557 + t[1].len = count;
2558 + spi_message_add_tail(&t[1], &m);
2559 +
2560 +- mutex_lock(&at25->lock);
2561 +-
2562 + /*
2563 + * Read it all at once.
2564 + *
2565 +@@ -152,7 +153,7 @@ static int fm25_aux_read(struct at25_data *at25, u8 *buf, uint8_t command,
2566 + spi_message_init(&m);
2567 + memset(t, 0, sizeof(t));
2568 +
2569 +- t[0].tx_buf = &command;
2570 ++ t[0].tx_buf = at25->command;
2571 + t[0].len = 1;
2572 + spi_message_add_tail(&t[0], &m);
2573 +
2574 +@@ -162,6 +163,8 @@ static int fm25_aux_read(struct at25_data *at25, u8 *buf, uint8_t command,
2575 +
2576 + mutex_lock(&at25->lock);
2577 +
2578 ++ at25->command[0] = command;
2579 ++
2580 + status = spi_sync(at25->spi, &m);
2581 + dev_dbg(&at25->spi->dev, "read %d aux bytes --> %d\n", len, status);
2582 +
2583 +diff --git a/drivers/mtd/nand/raw/mtk_ecc.c b/drivers/mtd/nand/raw/mtk_ecc.c
2584 +index 1b47964cb6da2..4f6adb657c89c 100644
2585 +--- a/drivers/mtd/nand/raw/mtk_ecc.c
2586 ++++ b/drivers/mtd/nand/raw/mtk_ecc.c
2587 +@@ -43,6 +43,7 @@
2588 +
2589 + struct mtk_ecc_caps {
2590 + u32 err_mask;
2591 ++ u32 err_shift;
2592 + const u8 *ecc_strength;
2593 + const u32 *ecc_regs;
2594 + u8 num_ecc_strength;
2595 +@@ -76,7 +77,7 @@ static const u8 ecc_strength_mt2712[] = {
2596 + };
2597 +
2598 + static const u8 ecc_strength_mt7622[] = {
2599 +- 4, 6, 8, 10, 12, 14, 16
2600 ++ 4, 6, 8, 10, 12
2601 + };
2602 +
2603 + enum mtk_ecc_regs {
2604 +@@ -221,7 +222,7 @@ void mtk_ecc_get_stats(struct mtk_ecc *ecc, struct mtk_ecc_stats *stats,
2605 + for (i = 0; i < sectors; i++) {
2606 + offset = (i >> 2) << 2;
2607 + err = readl(ecc->regs + ECC_DECENUM0 + offset);
2608 +- err = err >> ((i % 4) * 8);
2609 ++ err = err >> ((i % 4) * ecc->caps->err_shift);
2610 + err &= ecc->caps->err_mask;
2611 + if (err == ecc->caps->err_mask) {
2612 + /* uncorrectable errors */
2613 +@@ -449,6 +450,7 @@ EXPORT_SYMBOL(mtk_ecc_get_parity_bits);
2614 +
2615 + static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = {
2616 + .err_mask = 0x3f,
2617 ++ .err_shift = 8,
2618 + .ecc_strength = ecc_strength_mt2701,
2619 + .ecc_regs = mt2701_ecc_regs,
2620 + .num_ecc_strength = 20,
2621 +@@ -459,6 +461,7 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = {
2622 +
2623 + static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = {
2624 + .err_mask = 0x7f,
2625 ++ .err_shift = 8,
2626 + .ecc_strength = ecc_strength_mt2712,
2627 + .ecc_regs = mt2712_ecc_regs,
2628 + .num_ecc_strength = 23,
2629 +@@ -468,10 +471,11 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = {
2630 + };
2631 +
2632 + static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = {
2633 +- .err_mask = 0x3f,
2634 ++ .err_mask = 0x1f,
2635 ++ .err_shift = 5,
2636 + .ecc_strength = ecc_strength_mt7622,
2637 + .ecc_regs = mt7622_ecc_regs,
2638 +- .num_ecc_strength = 7,
2639 ++ .num_ecc_strength = 5,
2640 + .ecc_mode_shift = 4,
2641 + .parity_bits = 13,
2642 + .pg_irq_sel = 0,
2643 +diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
2644 +index 1a77542c6d67c..048b255faa769 100644
2645 +--- a/drivers/mtd/nand/raw/qcom_nandc.c
2646 ++++ b/drivers/mtd/nand/raw/qcom_nandc.c
2647 +@@ -2651,10 +2651,23 @@ static int qcom_nand_attach_chip(struct nand_chip *chip)
2648 + ecc->engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
2649 +
2650 + mtd_set_ooblayout(mtd, &qcom_nand_ooblayout_ops);
2651 ++ /* Free the initially allocated BAM transaction for reading the ONFI params */
2652 ++ if (nandc->props->is_bam)
2653 ++ free_bam_transaction(nandc);
2654 +
2655 + nandc->max_cwperpage = max_t(unsigned int, nandc->max_cwperpage,
2656 + cwperpage);
2657 +
2658 ++ /* Now allocate the BAM transaction based on updated max_cwperpage */
2659 ++ if (nandc->props->is_bam) {
2660 ++ nandc->bam_txn = alloc_bam_transaction(nandc);
2661 ++ if (!nandc->bam_txn) {
2662 ++ dev_err(nandc->dev,
2663 ++ "failed to allocate bam transaction\n");
2664 ++ return -ENOMEM;
2665 ++ }
2666 ++ }
2667 ++
2668 + /*
2669 + * DATA_UD_BYTES varies based on whether the read/write command protects
2670 + * spare data with ECC too. We protect spare data by default, so we set
2671 +@@ -2955,17 +2968,6 @@ static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc,
2672 + if (ret)
2673 + return ret;
2674 +
2675 +- if (nandc->props->is_bam) {
2676 +- free_bam_transaction(nandc);
2677 +- nandc->bam_txn = alloc_bam_transaction(nandc);
2678 +- if (!nandc->bam_txn) {
2679 +- dev_err(nandc->dev,
2680 +- "failed to allocate bam transaction\n");
2681 +- nand_cleanup(chip);
2682 +- return -ENOMEM;
2683 +- }
2684 +- }
2685 +-
2686 + ret = mtd_device_parse_register(mtd, probes, NULL, NULL, 0);
2687 + if (ret)
2688 + nand_cleanup(chip);
2689 +diff --git a/drivers/mtd/nand/raw/sh_flctl.c b/drivers/mtd/nand/raw/sh_flctl.c
2690 +index 13df4bdf792af..8f89e2d3d817f 100644
2691 +--- a/drivers/mtd/nand/raw/sh_flctl.c
2692 ++++ b/drivers/mtd/nand/raw/sh_flctl.c
2693 +@@ -384,7 +384,8 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf,
2694 + dma_addr_t dma_addr;
2695 + dma_cookie_t cookie;
2696 + uint32_t reg;
2697 +- int ret;
2698 ++ int ret = 0;
2699 ++ unsigned long time_left;
2700 +
2701 + if (dir == DMA_FROM_DEVICE) {
2702 + chan = flctl->chan_fifo0_rx;
2703 +@@ -425,13 +426,14 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf,
2704 + goto out;
2705 + }
2706 +
2707 +- ret =
2708 ++ time_left =
2709 + wait_for_completion_timeout(&flctl->dma_complete,
2710 + msecs_to_jiffies(3000));
2711 +
2712 +- if (ret <= 0) {
2713 ++ if (time_left == 0) {
2714 + dmaengine_terminate_all(chan);
2715 + dev_err(&flctl->pdev->dev, "wait_for_completion_timeout\n");
2716 ++ ret = -ETIMEDOUT;
2717 + }
2718 +
2719 + out:
2720 +@@ -441,7 +443,7 @@ out:
2721 +
2722 + dma_unmap_single(chan->device->dev, dma_addr, len, dir);
2723 +
2724 +- /* ret > 0 is success */
2725 ++ /* ret == 0 is success */
2726 + return ret;
2727 + }
2728 +
2729 +@@ -465,7 +467,7 @@ static void read_fiforeg(struct sh_flctl *flctl, int rlen, int offset)
2730 +
2731 + /* initiate DMA transfer */
2732 + if (flctl->chan_fifo0_rx && rlen >= 32 &&
2733 +- flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_FROM_DEVICE) > 0)
2734 ++ !flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_FROM_DEVICE))
2735 + goto convert; /* DMA success */
2736 +
2737 + /* do polling transfer */
2738 +@@ -524,7 +526,7 @@ static void write_ec_fiforeg(struct sh_flctl *flctl, int rlen,
2739 +
2740 + /* initiate DMA transfer */
2741 + if (flctl->chan_fifo0_tx && rlen >= 32 &&
2742 +- flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_TO_DEVICE) > 0)
2743 ++ !flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_TO_DEVICE))
2744 + return; /* DMA success */
2745 +
2746 + /* do polling transfer */
2747 +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
2748 +index aebeb46e6fa6f..c9107a8b4b906 100644
2749 +--- a/drivers/net/bonding/bond_main.c
2750 ++++ b/drivers/net/bonding/bond_main.c
2751 +@@ -3819,14 +3819,19 @@ static bool bond_flow_dissect(struct bonding *bond, struct sk_buff *skb, const v
2752 + return true;
2753 + }
2754 +
2755 +-static u32 bond_ip_hash(u32 hash, struct flow_keys *flow)
2756 ++static u32 bond_ip_hash(u32 hash, struct flow_keys *flow, int xmit_policy)
2757 + {
2758 + hash ^= (__force u32)flow_get_u32_dst(flow) ^
2759 + (__force u32)flow_get_u32_src(flow);
2760 + hash ^= (hash >> 16);
2761 + hash ^= (hash >> 8);
2762 ++
2763 + /* discard lowest hash bit to deal with the common even ports pattern */
2764 +- return hash >> 1;
2765 ++ if (xmit_policy == BOND_XMIT_POLICY_LAYER34 ||
2766 ++ xmit_policy == BOND_XMIT_POLICY_ENCAP34)
2767 ++ return hash >> 1;
2768 ++
2769 ++ return hash;
2770 + }
2771 +
2772 + /* Generate hash based on xmit policy. If @skb is given it is used to linearize
2773 +@@ -3856,7 +3861,7 @@ static u32 __bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, const voi
2774 + memcpy(&hash, &flow.ports.ports, sizeof(hash));
2775 + }
2776 +
2777 +- return bond_ip_hash(hash, &flow);
2778 ++ return bond_ip_hash(hash, &flow, bond->params.xmit_policy);
2779 + }
2780 +
2781 + /**
2782 +@@ -5051,7 +5056,7 @@ static u32 bond_sk_hash_l34(struct sock *sk)
2783 + /* L4 */
2784 + memcpy(&hash, &flow.ports.ports, sizeof(hash));
2785 + /* L3 */
2786 +- return bond_ip_hash(hash, &flow);
2787 ++ return bond_ip_hash(hash, &flow, BOND_XMIT_POLICY_LAYER34);
2788 + }
2789 +
2790 + static struct net_device *__bond_sk_get_lower_dev(struct bonding *bond,
2791 +diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
2792 +index 8a7a8093a1569..8acec33a47027 100644
2793 +--- a/drivers/net/dsa/lantiq_gswip.c
2794 ++++ b/drivers/net/dsa/lantiq_gswip.c
2795 +@@ -1637,9 +1637,6 @@ static void gswip_phylink_mac_config(struct dsa_switch *ds, int port,
2796 + break;
2797 + case PHY_INTERFACE_MODE_RMII:
2798 + miicfg |= GSWIP_MII_CFG_MODE_RMIIM;
2799 +-
2800 +- /* Configure the RMII clock as output: */
2801 +- miicfg |= GSWIP_MII_CFG_RMII_CLK;
2802 + break;
2803 + case PHY_INTERFACE_MODE_RGMII:
2804 + case PHY_INTERFACE_MODE_RGMII_ID:
2805 +diff --git a/drivers/net/dsa/mv88e6xxx/port_hidden.c b/drivers/net/dsa/mv88e6xxx/port_hidden.c
2806 +index b49d05f0e1179..7a9f9ff6dedf3 100644
2807 +--- a/drivers/net/dsa/mv88e6xxx/port_hidden.c
2808 ++++ b/drivers/net/dsa/mv88e6xxx/port_hidden.c
2809 +@@ -40,8 +40,9 @@ int mv88e6xxx_port_hidden_wait(struct mv88e6xxx_chip *chip)
2810 + {
2811 + int bit = __bf_shf(MV88E6XXX_PORT_RESERVED_1A_BUSY);
2812 +
2813 +- return mv88e6xxx_wait_bit(chip, MV88E6XXX_PORT_RESERVED_1A_CTRL_PORT,
2814 +- MV88E6XXX_PORT_RESERVED_1A, bit, 0);
2815 ++ return mv88e6xxx_port_wait_bit(chip,
2816 ++ MV88E6XXX_PORT_RESERVED_1A_CTRL_PORT,
2817 ++ MV88E6XXX_PORT_RESERVED_1A, bit, 0);
2818 + }
2819 +
2820 + int mv88e6xxx_port_hidden_read(struct mv88e6xxx_chip *chip, int block, int port,
2821 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
2822 +index c19b072f3a237..962253db25b82 100644
2823 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
2824 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
2825 +@@ -14153,10 +14153,6 @@ static int bnx2x_eeh_nic_unload(struct bnx2x *bp)
2826 +
2827 + /* Stop Tx */
2828 + bnx2x_tx_disable(bp);
2829 +- /* Delete all NAPI objects */
2830 +- bnx2x_del_all_napi(bp);
2831 +- if (CNIC_LOADED(bp))
2832 +- bnx2x_del_all_napi_cnic(bp);
2833 + netdev_reset_tc(bp->dev);
2834 +
2835 + del_timer_sync(&bp->timer);
2836 +@@ -14261,6 +14257,11 @@ static pci_ers_result_t bnx2x_io_slot_reset(struct pci_dev *pdev)
2837 + bnx2x_drain_tx_queues(bp);
2838 + bnx2x_send_unload_req(bp, UNLOAD_RECOVERY);
2839 + bnx2x_netif_stop(bp, 1);
2840 ++ bnx2x_del_all_napi(bp);
2841 ++
2842 ++ if (CNIC_LOADED(bp))
2843 ++ bnx2x_del_all_napi_cnic(bp);
2844 ++
2845 + bnx2x_free_irq(bp);
2846 +
2847 + /* Report UNLOAD_DONE to MCP */
2848 +diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
2849 +index 2da804f84b480..c2bfb25e087c1 100644
2850 +--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
2851 ++++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
2852 +@@ -2035,6 +2035,11 @@ static struct sk_buff *bcmgenet_add_tsb(struct net_device *dev,
2853 + return skb;
2854 + }
2855 +
2856 ++static void bcmgenet_hide_tsb(struct sk_buff *skb)
2857 ++{
2858 ++ __skb_pull(skb, sizeof(struct status_64));
2859 ++}
2860 ++
2861 + static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
2862 + {
2863 + struct bcmgenet_priv *priv = netdev_priv(dev);
2864 +@@ -2141,6 +2146,8 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
2865 + }
2866 +
2867 + GENET_CB(skb)->last_cb = tx_cb_ptr;
2868 ++
2869 ++ bcmgenet_hide_tsb(skb);
2870 + skb_tx_timestamp(skb);
2871 +
2872 + /* Decrement total BD count and advance our write pointer */
2873 +diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c
2874 +index d3d7172e0fcc5..3b148d4e0f0cf 100644
2875 +--- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c
2876 ++++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c
2877 +@@ -308,10 +308,6 @@ int enetc_setup_tc_txtime(struct net_device *ndev, void *type_data)
2878 + if (tc < 0 || tc >= priv->num_tx_rings)
2879 + return -EINVAL;
2880 +
2881 +- /* Do not support TXSTART and TX CSUM offload simutaniously */
2882 +- if (ndev->features & NETIF_F_CSUM_MASK)
2883 +- return -EBUSY;
2884 +-
2885 + /* TSD and Qbv are mutually exclusive in hardware */
2886 + if (enetc_rd(&priv->si->hw, ENETC_QBV_PTGCR_OFFSET) & ENETC_QBV_TGE)
2887 + return -EBUSY;
2888 +diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
2889 +index 796133de527e4..870919c665185 100644
2890 +--- a/drivers/net/ethernet/freescale/fec_main.c
2891 ++++ b/drivers/net/ethernet/freescale/fec_main.c
2892 +@@ -3731,7 +3731,7 @@ static int fec_enet_init_stop_mode(struct fec_enet_private *fep,
2893 + ARRAY_SIZE(out_val));
2894 + if (ret) {
2895 + dev_dbg(&fep->pdev->dev, "no stop mode property\n");
2896 +- return ret;
2897 ++ goto out;
2898 + }
2899 +
2900 + fep->stop_gpr.gpr = syscon_node_to_regmap(gpr_np);
2901 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_tqp_stats.c b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_tqp_stats.c
2902 +index 0c60f41fca8a6..f3c9395d8351c 100644
2903 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_tqp_stats.c
2904 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_tqp_stats.c
2905 +@@ -75,7 +75,7 @@ int hclge_comm_tqps_update_stats(struct hnae3_handle *handle,
2906 + ret = hclge_comm_cmd_send(hw, &desc, 1);
2907 + if (ret) {
2908 + dev_err(&hw->cmq.csq.pdev->dev,
2909 +- "failed to get tqp stat, ret = %d, tx = %u.\n",
2910 ++ "failed to get tqp stat, ret = %d, rx = %u.\n",
2911 + ret, i);
2912 + return ret;
2913 + }
2914 +@@ -89,7 +89,7 @@ int hclge_comm_tqps_update_stats(struct hnae3_handle *handle,
2915 + ret = hclge_comm_cmd_send(hw, &desc, 1);
2916 + if (ret) {
2917 + dev_err(&hw->cmq.csq.pdev->dev,
2918 +- "failed to get tqp stat, ret = %d, rx = %u.\n",
2919 ++ "failed to get tqp stat, ret = %d, tx = %u.\n",
2920 + ret, i);
2921 + return ret;
2922 + }
2923 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
2924 +index f6082be7481c1..f33b4c351a703 100644
2925 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
2926 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
2927 +@@ -5132,6 +5132,13 @@ static void hns3_state_init(struct hnae3_handle *handle)
2928 + set_bit(HNS3_NIC_STATE_RXD_ADV_LAYOUT_ENABLE, &priv->state);
2929 + }
2930 +
2931 ++static void hns3_state_uninit(struct hnae3_handle *handle)
2932 ++{
2933 ++ struct hns3_nic_priv *priv = handle->priv;
2934 ++
2935 ++ clear_bit(HNS3_NIC_STATE_INITED, &priv->state);
2936 ++}
2937 ++
2938 + static int hns3_client_init(struct hnae3_handle *handle)
2939 + {
2940 + struct pci_dev *pdev = handle->pdev;
2941 +@@ -5249,7 +5256,9 @@ static int hns3_client_init(struct hnae3_handle *handle)
2942 + return ret;
2943 +
2944 + out_reg_netdev_fail:
2945 ++ hns3_state_uninit(handle);
2946 + hns3_dbg_uninit(handle);
2947 ++ hns3_client_stop(handle);
2948 + out_client_start:
2949 + hns3_free_rx_cpu_rmap(netdev);
2950 + hns3_nic_uninit_irq(priv);
2951 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
2952 +index 6799d16de34b9..7998ca617a92e 100644
2953 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
2954 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
2955 +@@ -94,6 +94,13 @@ static int hclge_send_mbx_msg(struct hclge_vport *vport, u8 *msg, u16 msg_len,
2956 + enum hclge_comm_cmd_status status;
2957 + struct hclge_desc desc;
2958 +
2959 ++ if (msg_len > HCLGE_MBX_MAX_MSG_SIZE) {
2960 ++ dev_err(&hdev->pdev->dev,
2961 ++ "msg data length(=%u) exceeds maximum(=%u)\n",
2962 ++ msg_len, HCLGE_MBX_MAX_MSG_SIZE);
2963 ++ return -EMSGSIZE;
2964 ++ }
2965 ++
2966 + resp_pf_to_vf = (struct hclge_mbx_pf_to_vf_cmd *)desc.data;
2967 +
2968 + hclge_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_MBX_PF_TO_VF, false);
2969 +@@ -176,7 +183,7 @@ static int hclge_get_ring_chain_from_mbx(
2970 + ring_num = req->msg.ring_num;
2971 +
2972 + if (ring_num > HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM)
2973 +- return -ENOMEM;
2974 ++ return -EINVAL;
2975 +
2976 + for (i = 0; i < ring_num; i++) {
2977 + if (req->msg.param[i].tqp_index >= vport->nic.kinfo.rss_size) {
2978 +@@ -587,9 +594,9 @@ static int hclge_set_vf_mtu(struct hclge_vport *vport,
2979 + return hclge_set_vport_mtu(vport, mtu);
2980 + }
2981 +
2982 +-static void hclge_get_queue_id_in_pf(struct hclge_vport *vport,
2983 +- struct hclge_mbx_vf_to_pf_cmd *mbx_req,
2984 +- struct hclge_respond_to_vf_msg *resp_msg)
2985 ++static int hclge_get_queue_id_in_pf(struct hclge_vport *vport,
2986 ++ struct hclge_mbx_vf_to_pf_cmd *mbx_req,
2987 ++ struct hclge_respond_to_vf_msg *resp_msg)
2988 + {
2989 + struct hnae3_handle *handle = &vport->nic;
2990 + struct hclge_dev *hdev = vport->back;
2991 +@@ -599,17 +606,18 @@ static void hclge_get_queue_id_in_pf(struct hclge_vport *vport,
2992 + if (queue_id >= handle->kinfo.num_tqps) {
2993 + dev_err(&hdev->pdev->dev, "Invalid queue id(%u) from VF %u\n",
2994 + queue_id, mbx_req->mbx_src_vfid);
2995 +- return;
2996 ++ return -EINVAL;
2997 + }
2998 +
2999 + qid_in_pf = hclge_covert_handle_qid_global(&vport->nic, queue_id);
3000 + memcpy(resp_msg->data, &qid_in_pf, sizeof(qid_in_pf));
3001 + resp_msg->len = sizeof(qid_in_pf);
3002 ++ return 0;
3003 + }
3004 +
3005 +-static void hclge_get_rss_key(struct hclge_vport *vport,
3006 +- struct hclge_mbx_vf_to_pf_cmd *mbx_req,
3007 +- struct hclge_respond_to_vf_msg *resp_msg)
3008 ++static int hclge_get_rss_key(struct hclge_vport *vport,
3009 ++ struct hclge_mbx_vf_to_pf_cmd *mbx_req,
3010 ++ struct hclge_respond_to_vf_msg *resp_msg)
3011 + {
3012 + #define HCLGE_RSS_MBX_RESP_LEN 8
3013 + struct hclge_dev *hdev = vport->back;
3014 +@@ -627,13 +635,14 @@ static void hclge_get_rss_key(struct hclge_vport *vport,
3015 + dev_warn(&hdev->pdev->dev,
3016 + "failed to get the rss hash key, the index(%u) invalid !\n",
3017 + index);
3018 +- return;
3019 ++ return -EINVAL;
3020 + }
3021 +
3022 + memcpy(resp_msg->data,
3023 + &rss_cfg->rss_hash_key[index * HCLGE_RSS_MBX_RESP_LEN],
3024 + HCLGE_RSS_MBX_RESP_LEN);
3025 + resp_msg->len = HCLGE_RSS_MBX_RESP_LEN;
3026 ++ return 0;
3027 + }
3028 +
3029 + static void hclge_link_fail_parse(struct hclge_dev *hdev, u8 link_fail_code)
3030 +@@ -809,10 +818,10 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
3031 + "VF fail(%d) to set mtu\n", ret);
3032 + break;
3033 + case HCLGE_MBX_GET_QID_IN_PF:
3034 +- hclge_get_queue_id_in_pf(vport, req, &resp_msg);
3035 ++ ret = hclge_get_queue_id_in_pf(vport, req, &resp_msg);
3036 + break;
3037 + case HCLGE_MBX_GET_RSS_KEY:
3038 +- hclge_get_rss_key(vport, req, &resp_msg);
3039 ++ ret = hclge_get_rss_key(vport, req, &resp_msg);
3040 + break;
3041 + case HCLGE_MBX_GET_LINK_MODE:
3042 + hclge_get_link_mode(vport, req);
3043 +diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
3044 +index b4804ce63151f..a4428a7d0f357 100644
3045 +--- a/drivers/net/ethernet/ibm/ibmvnic.c
3046 ++++ b/drivers/net/ethernet/ibm/ibmvnic.c
3047 +@@ -3209,13 +3209,8 @@ static void ibmvnic_get_ringparam(struct net_device *netdev,
3048 + {
3049 + struct ibmvnic_adapter *adapter = netdev_priv(netdev);
3050 +
3051 +- if (adapter->priv_flags & IBMVNIC_USE_SERVER_MAXES) {
3052 +- ring->rx_max_pending = adapter->max_rx_add_entries_per_subcrq;
3053 +- ring->tx_max_pending = adapter->max_tx_entries_per_subcrq;
3054 +- } else {
3055 +- ring->rx_max_pending = IBMVNIC_MAX_QUEUE_SZ;
3056 +- ring->tx_max_pending = IBMVNIC_MAX_QUEUE_SZ;
3057 +- }
3058 ++ ring->rx_max_pending = adapter->max_rx_add_entries_per_subcrq;
3059 ++ ring->tx_max_pending = adapter->max_tx_entries_per_subcrq;
3060 + ring->rx_mini_max_pending = 0;
3061 + ring->rx_jumbo_max_pending = 0;
3062 + ring->rx_pending = adapter->req_rx_add_entries_per_subcrq;
3063 +@@ -3230,23 +3225,21 @@ static int ibmvnic_set_ringparam(struct net_device *netdev,
3064 + struct netlink_ext_ack *extack)
3065 + {
3066 + struct ibmvnic_adapter *adapter = netdev_priv(netdev);
3067 +- int ret;
3068 +
3069 +- ret = 0;
3070 ++ if (ring->rx_pending > adapter->max_rx_add_entries_per_subcrq ||
3071 ++ ring->tx_pending > adapter->max_tx_entries_per_subcrq) {
3072 ++ netdev_err(netdev, "Invalid request.\n");
3073 ++ netdev_err(netdev, "Max tx buffers = %llu\n",
3074 ++ adapter->max_rx_add_entries_per_subcrq);
3075 ++ netdev_err(netdev, "Max rx buffers = %llu\n",
3076 ++ adapter->max_tx_entries_per_subcrq);
3077 ++ return -EINVAL;
3078 ++ }
3079 ++
3080 + adapter->desired.rx_entries = ring->rx_pending;
3081 + adapter->desired.tx_entries = ring->tx_pending;
3082 +
3083 +- ret = wait_for_reset(adapter);
3084 +-
3085 +- if (!ret &&
3086 +- (adapter->req_rx_add_entries_per_subcrq != ring->rx_pending ||
3087 +- adapter->req_tx_entries_per_subcrq != ring->tx_pending))
3088 +- netdev_info(netdev,
3089 +- "Could not match full ringsize request. Requested: RX %d, TX %d; Allowed: RX %llu, TX %llu\n",
3090 +- ring->rx_pending, ring->tx_pending,
3091 +- adapter->req_rx_add_entries_per_subcrq,
3092 +- adapter->req_tx_entries_per_subcrq);
3093 +- return ret;
3094 ++ return wait_for_reset(adapter);
3095 + }
3096 +
3097 + static void ibmvnic_get_channels(struct net_device *netdev,
3098 +@@ -3254,14 +3247,8 @@ static void ibmvnic_get_channels(struct net_device *netdev,
3099 + {
3100 + struct ibmvnic_adapter *adapter = netdev_priv(netdev);
3101 +
3102 +- if (adapter->priv_flags & IBMVNIC_USE_SERVER_MAXES) {
3103 +- channels->max_rx = adapter->max_rx_queues;
3104 +- channels->max_tx = adapter->max_tx_queues;
3105 +- } else {
3106 +- channels->max_rx = IBMVNIC_MAX_QUEUES;
3107 +- channels->max_tx = IBMVNIC_MAX_QUEUES;
3108 +- }
3109 +-
3110 ++ channels->max_rx = adapter->max_rx_queues;
3111 ++ channels->max_tx = adapter->max_tx_queues;
3112 + channels->max_other = 0;
3113 + channels->max_combined = 0;
3114 + channels->rx_count = adapter->req_rx_queues;
3115 +@@ -3274,22 +3261,11 @@ static int ibmvnic_set_channels(struct net_device *netdev,
3116 + struct ethtool_channels *channels)
3117 + {
3118 + struct ibmvnic_adapter *adapter = netdev_priv(netdev);
3119 +- int ret;
3120 +
3121 +- ret = 0;
3122 + adapter->desired.rx_queues = channels->rx_count;
3123 + adapter->desired.tx_queues = channels->tx_count;
3124 +
3125 +- ret = wait_for_reset(adapter);
3126 +-
3127 +- if (!ret &&
3128 +- (adapter->req_rx_queues != channels->rx_count ||
3129 +- adapter->req_tx_queues != channels->tx_count))
3130 +- netdev_info(netdev,
3131 +- "Could not match full channels request. Requested: RX %d, TX %d; Allowed: RX %llu, TX %llu\n",
3132 +- channels->rx_count, channels->tx_count,
3133 +- adapter->req_rx_queues, adapter->req_tx_queues);
3134 +- return ret;
3135 ++ return wait_for_reset(adapter);
3136 + }
3137 +
3138 + static void ibmvnic_get_strings(struct net_device *dev, u32 stringset, u8 *data)
3139 +@@ -3297,43 +3273,32 @@ static void ibmvnic_get_strings(struct net_device *dev, u32 stringset, u8 *data)
3140 + struct ibmvnic_adapter *adapter = netdev_priv(dev);
3141 + int i;
3142 +
3143 +- switch (stringset) {
3144 +- case ETH_SS_STATS:
3145 +- for (i = 0; i < ARRAY_SIZE(ibmvnic_stats);
3146 +- i++, data += ETH_GSTRING_LEN)
3147 +- memcpy(data, ibmvnic_stats[i].name, ETH_GSTRING_LEN);
3148 ++ if (stringset != ETH_SS_STATS)
3149 ++ return;
3150 +
3151 +- for (i = 0; i < adapter->req_tx_queues; i++) {
3152 +- snprintf(data, ETH_GSTRING_LEN, "tx%d_packets", i);
3153 +- data += ETH_GSTRING_LEN;
3154 ++ for (i = 0; i < ARRAY_SIZE(ibmvnic_stats); i++, data += ETH_GSTRING_LEN)
3155 ++ memcpy(data, ibmvnic_stats[i].name, ETH_GSTRING_LEN);
3156 +
3157 +- snprintf(data, ETH_GSTRING_LEN, "tx%d_bytes", i);
3158 +- data += ETH_GSTRING_LEN;
3159 ++ for (i = 0; i < adapter->req_tx_queues; i++) {
3160 ++ snprintf(data, ETH_GSTRING_LEN, "tx%d_packets", i);
3161 ++ data += ETH_GSTRING_LEN;
3162 +
3163 +- snprintf(data, ETH_GSTRING_LEN,
3164 +- "tx%d_dropped_packets", i);
3165 +- data += ETH_GSTRING_LEN;
3166 +- }
3167 ++ snprintf(data, ETH_GSTRING_LEN, "tx%d_bytes", i);
3168 ++ data += ETH_GSTRING_LEN;
3169 +
3170 +- for (i = 0; i < adapter->req_rx_queues; i++) {
3171 +- snprintf(data, ETH_GSTRING_LEN, "rx%d_packets", i);
3172 +- data += ETH_GSTRING_LEN;
3173 ++ snprintf(data, ETH_GSTRING_LEN, "tx%d_dropped_packets", i);
3174 ++ data += ETH_GSTRING_LEN;
3175 ++ }
3176 +
3177 +- snprintf(data, ETH_GSTRING_LEN, "rx%d_bytes", i);
3178 +- data += ETH_GSTRING_LEN;
3179 ++ for (i = 0; i < adapter->req_rx_queues; i++) {
3180 ++ snprintf(data, ETH_GSTRING_LEN, "rx%d_packets", i);
3181 ++ data += ETH_GSTRING_LEN;
3182 +
3183 +- snprintf(data, ETH_GSTRING_LEN, "rx%d_interrupts", i);
3184 +- data += ETH_GSTRING_LEN;
3185 +- }
3186 +- break;
3187 ++ snprintf(data, ETH_GSTRING_LEN, "rx%d_bytes", i);
3188 ++ data += ETH_GSTRING_LEN;
3189 +
3190 +- case ETH_SS_PRIV_FLAGS:
3191 +- for (i = 0; i < ARRAY_SIZE(ibmvnic_priv_flags); i++)
3192 +- strcpy(data + i * ETH_GSTRING_LEN,
3193 +- ibmvnic_priv_flags[i]);
3194 +- break;
3195 +- default:
3196 +- return;
3197 ++ snprintf(data, ETH_GSTRING_LEN, "rx%d_interrupts", i);
3198 ++ data += ETH_GSTRING_LEN;
3199 + }
3200 + }
3201 +
3202 +@@ -3346,8 +3311,6 @@ static int ibmvnic_get_sset_count(struct net_device *dev, int sset)
3203 + return ARRAY_SIZE(ibmvnic_stats) +
3204 + adapter->req_tx_queues * NUM_TX_STATS +
3205 + adapter->req_rx_queues * NUM_RX_STATS;
3206 +- case ETH_SS_PRIV_FLAGS:
3207 +- return ARRAY_SIZE(ibmvnic_priv_flags);
3208 + default:
3209 + return -EOPNOTSUPP;
3210 + }
3211 +@@ -3400,26 +3363,6 @@ static void ibmvnic_get_ethtool_stats(struct net_device *dev,
3212 + }
3213 + }
3214 +
3215 +-static u32 ibmvnic_get_priv_flags(struct net_device *netdev)
3216 +-{
3217 +- struct ibmvnic_adapter *adapter = netdev_priv(netdev);
3218 +-
3219 +- return adapter->priv_flags;
3220 +-}
3221 +-
3222 +-static int ibmvnic_set_priv_flags(struct net_device *netdev, u32 flags)
3223 +-{
3224 +- struct ibmvnic_adapter *adapter = netdev_priv(netdev);
3225 +- bool which_maxes = !!(flags & IBMVNIC_USE_SERVER_MAXES);
3226 +-
3227 +- if (which_maxes)
3228 +- adapter->priv_flags |= IBMVNIC_USE_SERVER_MAXES;
3229 +- else
3230 +- adapter->priv_flags &= ~IBMVNIC_USE_SERVER_MAXES;
3231 +-
3232 +- return 0;
3233 +-}
3234 +-
3235 + static const struct ethtool_ops ibmvnic_ethtool_ops = {
3236 + .get_drvinfo = ibmvnic_get_drvinfo,
3237 + .get_msglevel = ibmvnic_get_msglevel,
3238 +@@ -3433,8 +3376,6 @@ static const struct ethtool_ops ibmvnic_ethtool_ops = {
3239 + .get_sset_count = ibmvnic_get_sset_count,
3240 + .get_ethtool_stats = ibmvnic_get_ethtool_stats,
3241 + .get_link_ksettings = ibmvnic_get_link_ksettings,
3242 +- .get_priv_flags = ibmvnic_get_priv_flags,
3243 +- .set_priv_flags = ibmvnic_set_priv_flags,
3244 + };
3245 +
3246 + /* Routines for managing CRQs/sCRQs */
3247 +diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
3248 +index 8f5cefb932dd1..1310c861bf834 100644
3249 +--- a/drivers/net/ethernet/ibm/ibmvnic.h
3250 ++++ b/drivers/net/ethernet/ibm/ibmvnic.h
3251 +@@ -41,11 +41,6 @@
3252 +
3253 + #define IBMVNIC_RESET_DELAY 100
3254 +
3255 +-static const char ibmvnic_priv_flags[][ETH_GSTRING_LEN] = {
3256 +-#define IBMVNIC_USE_SERVER_MAXES 0x1
3257 +- "use-server-maxes"
3258 +-};
3259 +-
3260 + struct ibmvnic_login_buffer {
3261 + __be32 len;
3262 + __be32 version;
3263 +@@ -883,7 +878,6 @@ struct ibmvnic_adapter {
3264 + struct ibmvnic_control_ip_offload_buffer ip_offload_ctrl;
3265 + dma_addr_t ip_offload_ctrl_tok;
3266 + u32 msg_enable;
3267 +- u32 priv_flags;
3268 +
3269 + /* Vital Product Data (VPD) */
3270 + struct ibmvnic_vpd *vpd;
3271 +diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
3272 +index 2de2bbbca1e97..e347030ee2e33 100644
3273 +--- a/drivers/net/ethernet/intel/ice/ice_main.c
3274 ++++ b/drivers/net/ethernet/intel/ice/ice_main.c
3275 +@@ -6662,12 +6662,15 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
3276 +
3277 + dev_dbg(dev, "rebuilding PF after reset_type=%d\n", reset_type);
3278 +
3279 ++#define ICE_EMP_RESET_SLEEP_MS 5000
3280 + if (reset_type == ICE_RESET_EMPR) {
3281 + /* If an EMP reset has occurred, any previously pending flash
3282 + * update will have completed. We no longer know whether or
3283 + * not the NVM update EMP reset is restricted.
3284 + */
3285 + pf->fw_emp_reset_disabled = false;
3286 ++
3287 ++ msleep(ICE_EMP_RESET_SLEEP_MS);
3288 + }
3289 +
3290 + err = ice_init_all_ctrlq(hw);
3291 +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
3292 +index e596e1a9fc757..69d11ff7677d6 100644
3293 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
3294 ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
3295 +@@ -903,7 +903,8 @@ int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf)
3296 + /* Tx IPsec offload doesn't seem to work on this
3297 + * device, so block these requests for now.
3298 + */
3299 +- if (!(sam->flags & XFRM_OFFLOAD_INBOUND)) {
3300 ++ sam->flags = sam->flags & ~XFRM_OFFLOAD_IPV6;
3301 ++ if (sam->flags != XFRM_OFFLOAD_INBOUND) {
3302 + err = -EOPNOTSUPP;
3303 + goto err_out;
3304 + }
3305 +diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c b/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c
3306 +index 2679111ef6696..005e56ea5da12 100644
3307 +--- a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c
3308 ++++ b/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c
3309 +@@ -346,7 +346,7 @@ static void lan966x_mac_irq_process(struct lan966x *lan966x, u32 row,
3310 +
3311 + lan966x_mac_process_raw_entry(&raw_entries[column],
3312 + mac, &vid, &dest_idx);
3313 +- if (WARN_ON(dest_idx > lan966x->num_phys_ports))
3314 ++ if (WARN_ON(dest_idx >= lan966x->num_phys_ports))
3315 + continue;
3316 +
3317 + /* If the entry in SW is found, then there is nothing
3318 +@@ -393,7 +393,7 @@ static void lan966x_mac_irq_process(struct lan966x *lan966x, u32 row,
3319 +
3320 + lan966x_mac_process_raw_entry(&raw_entries[column],
3321 + mac, &vid, &dest_idx);
3322 +- if (WARN_ON(dest_idx > lan966x->num_phys_ports))
3323 ++ if (WARN_ON(dest_idx >= lan966x->num_phys_ports))
3324 + continue;
3325 +
3326 + mac_entry = lan966x_mac_alloc_entry(mac, vid, dest_idx);
3327 +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
3328 +index ac9e6c7a33b55..6b447d8f0bd8a 100644
3329 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
3330 ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
3331 +@@ -65,8 +65,9 @@ static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed)
3332 + struct phy_device *phy_dev = ndev->phydev;
3333 + u32 val;
3334 +
3335 +- writew(SGMII_ADAPTER_DISABLE,
3336 +- sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
3337 ++ if (sgmii_adapter_base)
3338 ++ writew(SGMII_ADAPTER_DISABLE,
3339 ++ sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
3340 +
3341 + if (splitter_base) {
3342 + val = readl(splitter_base + EMAC_SPLITTER_CTRL_REG);
3343 +@@ -88,10 +89,11 @@ static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed)
3344 + writel(val, splitter_base + EMAC_SPLITTER_CTRL_REG);
3345 + }
3346 +
3347 +- writew(SGMII_ADAPTER_ENABLE,
3348 +- sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
3349 +- if (phy_dev)
3350 ++ if (phy_dev && sgmii_adapter_base) {
3351 ++ writew(SGMII_ADAPTER_ENABLE,
3352 ++ sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
3353 + tse_pcs_fix_mac_speed(&dwmac->pcs, phy_dev, speed);
3354 ++ }
3355 + }
3356 +
3357 + static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *dev)
3358 +diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
3359 +index 16105292b140b..74e845fa2e07e 100644
3360 +--- a/drivers/net/hippi/rrunner.c
3361 ++++ b/drivers/net/hippi/rrunner.c
3362 +@@ -1355,7 +1355,9 @@ static int rr_close(struct net_device *dev)
3363 +
3364 + rrpriv->fw_running = 0;
3365 +
3366 ++ spin_unlock_irqrestore(&rrpriv->lock, flags);
3367 + del_timer_sync(&rrpriv->timer);
3368 ++ spin_lock_irqsave(&rrpriv->lock, flags);
3369 +
3370 + writel(0, &regs->TxPi);
3371 + writel(0, &regs->IpRxPi);
3372 +diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
3373 +index b6fea119fe137..2b7d0720720b6 100644
3374 +--- a/drivers/net/phy/marvell10g.c
3375 ++++ b/drivers/net/phy/marvell10g.c
3376 +@@ -880,7 +880,7 @@ static int mv3310_read_status_copper(struct phy_device *phydev)
3377 +
3378 + cssr1 = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_CSSR1);
3379 + if (cssr1 < 0)
3380 +- return val;
3381 ++ return cssr1;
3382 +
3383 + /* If the link settings are not resolved, mark the link down */
3384 + if (!(cssr1 & MV_PCS_CSSR1_RESOLVED)) {
3385 +diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
3386 +index a801ea40908ff..3b02dd54e2e27 100644
3387 +--- a/drivers/net/virtio_net.c
3388 ++++ b/drivers/net/virtio_net.c
3389 +@@ -978,6 +978,24 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
3390 + * xdp.data_meta were adjusted
3391 + */
3392 + len = xdp.data_end - xdp.data + vi->hdr_len + metasize;
3393 ++
3394 ++ /* recalculate headroom if xdp.data or xdp_data_meta
3395 ++ * were adjusted, note that offset should always point
3396 ++ * to the start of the reserved bytes for virtio_net
3397 ++ * header which are followed by xdp.data, that means
3398 ++ * that offset is equal to the headroom (when buf is
3399 ++ * starting at the beginning of the page, otherwise
3400 ++ * there is a base offset inside the page) but it's used
3401 ++ * with a different starting point (buf start) than
3402 ++ * xdp.data (buf start + vnet hdr size). If xdp.data or
3403 ++ * data_meta were adjusted by the xdp prog then the
3404 ++ * headroom size has changed and so has the offset, we
3405 ++ * can use data_hard_start, which points at buf start +
3406 ++ * vnet hdr size, to calculate the new headroom and use
3407 ++ * it later to compute buf start in page_to_skb()
3408 ++ */
3409 ++ headroom = xdp.data - xdp.data_hard_start - metasize;
3410 ++
3411 + /* We can only create skb based on xdp_page. */
3412 + if (unlikely(xdp_page != page)) {
3413 + rcu_read_unlock();
3414 +@@ -985,7 +1003,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
3415 + head_skb = page_to_skb(vi, rq, xdp_page, offset,
3416 + len, PAGE_SIZE, false,
3417 + metasize,
3418 +- VIRTIO_XDP_HEADROOM);
3419 ++ headroom);
3420 + return head_skb;
3421 + }
3422 + break;
3423 +diff --git a/drivers/net/wireguard/device.c b/drivers/net/wireguard/device.c
3424 +index a46067c38bf5d..5eaef79c06e16 100644
3425 +--- a/drivers/net/wireguard/device.c
3426 ++++ b/drivers/net/wireguard/device.c
3427 +@@ -19,6 +19,7 @@
3428 + #include <linux/if_arp.h>
3429 + #include <linux/icmp.h>
3430 + #include <linux/suspend.h>
3431 ++#include <net/dst_metadata.h>
3432 + #include <net/icmp.h>
3433 + #include <net/rtnetlink.h>
3434 + #include <net/ip_tunnels.h>
3435 +@@ -152,7 +153,7 @@ static netdev_tx_t wg_xmit(struct sk_buff *skb, struct net_device *dev)
3436 + goto err_peer;
3437 + }
3438 +
3439 +- mtu = skb_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu;
3440 ++ mtu = skb_valid_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu;
3441 +
3442 + __skb_queue_head_init(&packets);
3443 + if (!skb_is_gso(skb)) {
3444 +diff --git a/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c b/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c
3445 +index 5b471ab80fe28..54d65a6f0fccf 100644
3446 +--- a/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c
3447 ++++ b/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c
3448 +@@ -414,19 +414,19 @@ static int phy_g12a_usb3_pcie_probe(struct platform_device *pdev)
3449 +
3450 + ret = clk_prepare_enable(priv->clk_ref);
3451 + if (ret)
3452 +- goto err_disable_clk_ref;
3453 ++ return ret;
3454 +
3455 + priv->reset = devm_reset_control_array_get_exclusive(dev);
3456 +- if (IS_ERR(priv->reset))
3457 +- return PTR_ERR(priv->reset);
3458 ++ if (IS_ERR(priv->reset)) {
3459 ++ ret = PTR_ERR(priv->reset);
3460 ++ goto err_disable_clk_ref;
3461 ++ }
3462 +
3463 + priv->phy = devm_phy_create(dev, np, &phy_g12a_usb3_pcie_ops);
3464 + if (IS_ERR(priv->phy)) {
3465 + ret = PTR_ERR(priv->phy);
3466 +- if (ret != -EPROBE_DEFER)
3467 +- dev_err(dev, "failed to create PHY\n");
3468 +-
3469 +- return ret;
3470 ++ dev_err_probe(dev, ret, "failed to create PHY\n");
3471 ++ goto err_disable_clk_ref;
3472 + }
3473 +
3474 + phy_set_drvdata(priv->phy, priv);
3475 +@@ -434,8 +434,12 @@ static int phy_g12a_usb3_pcie_probe(struct platform_device *pdev)
3476 +
3477 + phy_provider = devm_of_phy_provider_register(dev,
3478 + phy_g12a_usb3_pcie_xlate);
3479 ++ if (IS_ERR(phy_provider)) {
3480 ++ ret = PTR_ERR(phy_provider);
3481 ++ goto err_disable_clk_ref;
3482 ++ }
3483 +
3484 +- return PTR_ERR_OR_ZERO(phy_provider);
3485 ++ return 0;
3486 +
3487 + err_disable_clk_ref:
3488 + clk_disable_unprepare(priv->clk_ref);
3489 +diff --git a/drivers/phy/motorola/phy-mapphone-mdm6600.c b/drivers/phy/motorola/phy-mapphone-mdm6600.c
3490 +index 5172971f4c360..3cd4d51c247c3 100644
3491 +--- a/drivers/phy/motorola/phy-mapphone-mdm6600.c
3492 ++++ b/drivers/phy/motorola/phy-mapphone-mdm6600.c
3493 +@@ -629,7 +629,8 @@ idle:
3494 + cleanup:
3495 + if (error < 0)
3496 + phy_mdm6600_device_power_off(ddata);
3497 +-
3498 ++ pm_runtime_disable(ddata->dev);
3499 ++ pm_runtime_dont_use_autosuspend(ddata->dev);
3500 + return error;
3501 + }
3502 +
3503 +diff --git a/drivers/phy/samsung/phy-exynos5250-sata.c b/drivers/phy/samsung/phy-exynos5250-sata.c
3504 +index 9ec234243f7c6..595adba5fb8f1 100644
3505 +--- a/drivers/phy/samsung/phy-exynos5250-sata.c
3506 ++++ b/drivers/phy/samsung/phy-exynos5250-sata.c
3507 +@@ -187,6 +187,7 @@ static int exynos_sata_phy_probe(struct platform_device *pdev)
3508 + return -EINVAL;
3509 +
3510 + sata_phy->client = of_find_i2c_device_by_node(node);
3511 ++ of_node_put(node);
3512 + if (!sata_phy->client)
3513 + return -EPROBE_DEFER;
3514 +
3515 +@@ -195,20 +196,21 @@ static int exynos_sata_phy_probe(struct platform_device *pdev)
3516 + sata_phy->phyclk = devm_clk_get(dev, "sata_phyctrl");
3517 + if (IS_ERR(sata_phy->phyclk)) {
3518 + dev_err(dev, "failed to get clk for PHY\n");
3519 +- return PTR_ERR(sata_phy->phyclk);
3520 ++ ret = PTR_ERR(sata_phy->phyclk);
3521 ++ goto put_dev;
3522 + }
3523 +
3524 + ret = clk_prepare_enable(sata_phy->phyclk);
3525 + if (ret < 0) {
3526 + dev_err(dev, "failed to enable source clk\n");
3527 +- return ret;
3528 ++ goto put_dev;
3529 + }
3530 +
3531 + sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops);
3532 + if (IS_ERR(sata_phy->phy)) {
3533 +- clk_disable_unprepare(sata_phy->phyclk);
3534 + dev_err(dev, "failed to create PHY\n");
3535 +- return PTR_ERR(sata_phy->phy);
3536 ++ ret = PTR_ERR(sata_phy->phy);
3537 ++ goto clk_disable;
3538 + }
3539 +
3540 + phy_set_drvdata(sata_phy->phy, sata_phy);
3541 +@@ -216,11 +218,18 @@ static int exynos_sata_phy_probe(struct platform_device *pdev)
3542 + phy_provider = devm_of_phy_provider_register(dev,
3543 + of_phy_simple_xlate);
3544 + if (IS_ERR(phy_provider)) {
3545 +- clk_disable_unprepare(sata_phy->phyclk);
3546 +- return PTR_ERR(phy_provider);
3547 ++ ret = PTR_ERR(phy_provider);
3548 ++ goto clk_disable;
3549 + }
3550 +
3551 + return 0;
3552 ++
3553 ++clk_disable:
3554 ++ clk_disable_unprepare(sata_phy->phyclk);
3555 ++put_dev:
3556 ++ put_device(&sata_phy->client->dev);
3557 ++
3558 ++ return ret;
3559 + }
3560 +
3561 + static const struct of_device_id exynos_sata_phy_of_match[] = {
3562 +diff --git a/drivers/phy/ti/phy-am654-serdes.c b/drivers/phy/ti/phy-am654-serdes.c
3563 +index c1211c4f863ca..0be727bb9f792 100644
3564 +--- a/drivers/phy/ti/phy-am654-serdes.c
3565 ++++ b/drivers/phy/ti/phy-am654-serdes.c
3566 +@@ -838,7 +838,7 @@ static int serdes_am654_probe(struct platform_device *pdev)
3567 +
3568 + clk_err:
3569 + of_clk_del_provider(node);
3570 +-
3571 ++ pm_runtime_disable(dev);
3572 + return ret;
3573 + }
3574 +
3575 +diff --git a/drivers/phy/ti/phy-omap-usb2.c b/drivers/phy/ti/phy-omap-usb2.c
3576 +index 3a505fe5715ad..31a775877f6e3 100644
3577 +--- a/drivers/phy/ti/phy-omap-usb2.c
3578 ++++ b/drivers/phy/ti/phy-omap-usb2.c
3579 +@@ -215,7 +215,7 @@ static int omap_usb2_enable_clocks(struct omap_usb *phy)
3580 + return 0;
3581 +
3582 + err1:
3583 +- clk_disable(phy->wkupclk);
3584 ++ clk_disable_unprepare(phy->wkupclk);
3585 +
3586 + err0:
3587 + return ret;
3588 +diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig
3589 +index 66db4ac5d169a..c7fa1525e42af 100644
3590 +--- a/drivers/pinctrl/mediatek/Kconfig
3591 ++++ b/drivers/pinctrl/mediatek/Kconfig
3592 +@@ -30,6 +30,7 @@ config PINCTRL_MTK_MOORE
3593 + select GENERIC_PINMUX_FUNCTIONS
3594 + select GPIOLIB
3595 + select OF_GPIO
3596 ++ select EINT_MTK
3597 + select PINCTRL_MTK_V2
3598 +
3599 + config PINCTRL_MTK_PARIS
3600 +diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
3601 +index 8d271c6b0ca41..5de691c630b4f 100644
3602 +--- a/drivers/pinctrl/pinctrl-pistachio.c
3603 ++++ b/drivers/pinctrl/pinctrl-pistachio.c
3604 +@@ -1374,10 +1374,10 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
3605 + }
3606 +
3607 + irq = irq_of_parse_and_map(child, 0);
3608 +- if (irq < 0) {
3609 +- dev_err(pctl->dev, "No IRQ for bank %u: %d\n", i, irq);
3610 ++ if (!irq) {
3611 ++ dev_err(pctl->dev, "No IRQ for bank %u\n", i);
3612 + of_node_put(child);
3613 +- ret = irq;
3614 ++ ret = -EINVAL;
3615 + goto err;
3616 + }
3617 +
3618 +diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
3619 +index a1b598b86aa9f..65fa305b5f59f 100644
3620 +--- a/drivers/pinctrl/pinctrl-rockchip.c
3621 ++++ b/drivers/pinctrl/pinctrl-rockchip.c
3622 +@@ -457,95 +457,110 @@ static struct rockchip_mux_recalced_data rk3128_mux_recalced_data[] = {
3623 +
3624 + static struct rockchip_mux_recalced_data rk3308_mux_recalced_data[] = {
3625 + {
3626 ++ /* gpio1b6_sel */
3627 + .num = 1,
3628 + .pin = 14,
3629 + .reg = 0x28,
3630 + .bit = 12,
3631 + .mask = 0xf
3632 + }, {
3633 ++ /* gpio1b7_sel */
3634 + .num = 1,
3635 + .pin = 15,
3636 + .reg = 0x2c,
3637 + .bit = 0,
3638 + .mask = 0x3
3639 + }, {
3640 ++ /* gpio1c2_sel */
3641 + .num = 1,
3642 + .pin = 18,
3643 + .reg = 0x30,
3644 + .bit = 4,
3645 + .mask = 0xf
3646 + }, {
3647 ++ /* gpio1c3_sel */
3648 + .num = 1,
3649 + .pin = 19,
3650 + .reg = 0x30,
3651 + .bit = 8,
3652 + .mask = 0xf
3653 + }, {
3654 ++ /* gpio1c4_sel */
3655 + .num = 1,
3656 + .pin = 20,
3657 + .reg = 0x30,
3658 + .bit = 12,
3659 + .mask = 0xf
3660 + }, {
3661 ++ /* gpio1c5_sel */
3662 + .num = 1,
3663 + .pin = 21,
3664 + .reg = 0x34,
3665 + .bit = 0,
3666 + .mask = 0xf
3667 + }, {
3668 ++ /* gpio1c6_sel */
3669 + .num = 1,
3670 + .pin = 22,
3671 + .reg = 0x34,
3672 + .bit = 4,
3673 + .mask = 0xf
3674 + }, {
3675 ++ /* gpio1c7_sel */
3676 + .num = 1,
3677 + .pin = 23,
3678 + .reg = 0x34,
3679 + .bit = 8,
3680 + .mask = 0xf
3681 + }, {
3682 ++ /* gpio3b4_sel */
3683 + .num = 3,
3684 + .pin = 12,
3685 + .reg = 0x68,
3686 + .bit = 8,
3687 + .mask = 0xf
3688 + }, {
3689 ++ /* gpio3b5_sel */
3690 + .num = 3,
3691 + .pin = 13,
3692 + .reg = 0x68,
3693 + .bit = 12,
3694 + .mask = 0xf
3695 + }, {
3696 ++ /* gpio2a2_sel */
3697 + .num = 2,
3698 + .pin = 2,
3699 +- .reg = 0x608,
3700 +- .bit = 0,
3701 +- .mask = 0x7
3702 ++ .reg = 0x40,
3703 ++ .bit = 4,
3704 ++ .mask = 0x3
3705 + }, {
3706 ++ /* gpio2a3_sel */
3707 + .num = 2,
3708 + .pin = 3,
3709 +- .reg = 0x608,
3710 +- .bit = 4,
3711 +- .mask = 0x7
3712 ++ .reg = 0x40,
3713 ++ .bit = 6,
3714 ++ .mask = 0x3
3715 + }, {
3716 ++ /* gpio2c0_sel */
3717 + .num = 2,
3718 + .pin = 16,
3719 +- .reg = 0x610,
3720 +- .bit = 8,
3721 +- .mask = 0x7
3722 ++ .reg = 0x50,
3723 ++ .bit = 0,
3724 ++ .mask = 0x3
3725 + }, {
3726 ++ /* gpio3b2_sel */
3727 + .num = 3,
3728 + .pin = 10,
3729 +- .reg = 0x610,
3730 +- .bit = 0,
3731 +- .mask = 0x7
3732 ++ .reg = 0x68,
3733 ++ .bit = 4,
3734 ++ .mask = 0x3
3735 + }, {
3736 ++ /* gpio3b3_sel */
3737 + .num = 3,
3738 + .pin = 11,
3739 +- .reg = 0x610,
3740 +- .bit = 4,
3741 +- .mask = 0x7
3742 ++ .reg = 0x68,
3743 ++ .bit = 6,
3744 ++ .mask = 0x3
3745 + },
3746 + };
3747 +
3748 +diff --git a/drivers/pinctrl/qcom/pinctrl-sm6350.c b/drivers/pinctrl/qcom/pinctrl-sm6350.c
3749 +index 4d37b817b2328..a91a86628f2f8 100644
3750 +--- a/drivers/pinctrl/qcom/pinctrl-sm6350.c
3751 ++++ b/drivers/pinctrl/qcom/pinctrl-sm6350.c
3752 +@@ -264,14 +264,14 @@ static const struct pinctrl_pin_desc sm6350_pins[] = {
3753 + PINCTRL_PIN(153, "GPIO_153"),
3754 + PINCTRL_PIN(154, "GPIO_154"),
3755 + PINCTRL_PIN(155, "GPIO_155"),
3756 +- PINCTRL_PIN(156, "SDC1_RCLK"),
3757 +- PINCTRL_PIN(157, "SDC1_CLK"),
3758 +- PINCTRL_PIN(158, "SDC1_CMD"),
3759 +- PINCTRL_PIN(159, "SDC1_DATA"),
3760 +- PINCTRL_PIN(160, "SDC2_CLK"),
3761 +- PINCTRL_PIN(161, "SDC2_CMD"),
3762 +- PINCTRL_PIN(162, "SDC2_DATA"),
3763 +- PINCTRL_PIN(163, "UFS_RESET"),
3764 ++ PINCTRL_PIN(156, "UFS_RESET"),
3765 ++ PINCTRL_PIN(157, "SDC1_RCLK"),
3766 ++ PINCTRL_PIN(158, "SDC1_CLK"),
3767 ++ PINCTRL_PIN(159, "SDC1_CMD"),
3768 ++ PINCTRL_PIN(160, "SDC1_DATA"),
3769 ++ PINCTRL_PIN(161, "SDC2_CLK"),
3770 ++ PINCTRL_PIN(162, "SDC2_CMD"),
3771 ++ PINCTRL_PIN(163, "SDC2_DATA"),
3772 + };
3773 +
3774 + #define DECLARE_MSM_GPIO_PINS(pin) \
3775 +diff --git a/drivers/pinctrl/samsung/Kconfig b/drivers/pinctrl/samsung/Kconfig
3776 +index dfd805e768624..7b0576f71376e 100644
3777 +--- a/drivers/pinctrl/samsung/Kconfig
3778 ++++ b/drivers/pinctrl/samsung/Kconfig
3779 +@@ -4,14 +4,13 @@
3780 + #
3781 + config PINCTRL_SAMSUNG
3782 + bool
3783 +- depends on OF_GPIO
3784 ++ select GPIOLIB
3785 + select PINMUX
3786 + select PINCONF
3787 +
3788 + config PINCTRL_EXYNOS
3789 + bool "Pinctrl common driver part for Samsung Exynos SoCs"
3790 +- depends on OF_GPIO
3791 +- depends on ARCH_EXYNOS || ARCH_S5PV210 || COMPILE_TEST
3792 ++ depends on ARCH_EXYNOS || ARCH_S5PV210 || (COMPILE_TEST && OF)
3793 + select PINCTRL_SAMSUNG
3794 + select PINCTRL_EXYNOS_ARM if ARM && (ARCH_EXYNOS || ARCH_S5PV210)
3795 + select PINCTRL_EXYNOS_ARM64 if ARM64 && ARCH_EXYNOS
3796 +@@ -26,12 +25,10 @@ config PINCTRL_EXYNOS_ARM64
3797 +
3798 + config PINCTRL_S3C24XX
3799 + bool "Samsung S3C24XX SoC pinctrl driver"
3800 +- depends on OF_GPIO
3801 +- depends on ARCH_S3C24XX || COMPILE_TEST
3802 ++ depends on ARCH_S3C24XX || (COMPILE_TEST && OF)
3803 + select PINCTRL_SAMSUNG
3804 +
3805 + config PINCTRL_S3C64XX
3806 + bool "Samsung S3C64XX SoC pinctrl driver"
3807 +- depends on OF_GPIO
3808 +- depends on ARCH_S3C64XX || COMPILE_TEST
3809 ++ depends on ARCH_S3C64XX || (COMPILE_TEST && OF)
3810 + select PINCTRL_SAMSUNG
3811 +diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
3812 +index 9ed7647315707..f7c9459f66283 100644
3813 +--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
3814 ++++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
3815 +@@ -225,6 +225,13 @@ static void stm32_gpio_free(struct gpio_chip *chip, unsigned offset)
3816 + pinctrl_gpio_free(chip->base + offset);
3817 + }
3818 +
3819 ++static int stm32_gpio_get_noclk(struct gpio_chip *chip, unsigned int offset)
3820 ++{
3821 ++ struct stm32_gpio_bank *bank = gpiochip_get_data(chip);
3822 ++
3823 ++ return !!(readl_relaxed(bank->base + STM32_GPIO_IDR) & BIT(offset));
3824 ++}
3825 ++
3826 + static int stm32_gpio_get(struct gpio_chip *chip, unsigned offset)
3827 + {
3828 + struct stm32_gpio_bank *bank = gpiochip_get_data(chip);
3829 +@@ -232,7 +239,7 @@ static int stm32_gpio_get(struct gpio_chip *chip, unsigned offset)
3830 +
3831 + clk_enable(bank->clk);
3832 +
3833 +- ret = !!(readl_relaxed(bank->base + STM32_GPIO_IDR) & BIT(offset));
3834 ++ ret = stm32_gpio_get_noclk(chip, offset);
3835 +
3836 + clk_disable(bank->clk);
3837 +
3838 +@@ -311,8 +318,12 @@ static void stm32_gpio_irq_trigger(struct irq_data *d)
3839 + struct stm32_gpio_bank *bank = d->domain->host_data;
3840 + int level;
3841 +
3842 ++ /* Do not access the GPIO if this is not LEVEL triggered IRQ. */
3843 ++ if (!(bank->irq_type[d->hwirq] & IRQ_TYPE_LEVEL_MASK))
3844 ++ return;
3845 ++
3846 + /* If level interrupt type then retrig */
3847 +- level = stm32_gpio_get(&bank->gpio_chip, d->hwirq);
3848 ++ level = stm32_gpio_get_noclk(&bank->gpio_chip, d->hwirq);
3849 + if ((level == 0 && bank->irq_type[d->hwirq] == IRQ_TYPE_LEVEL_LOW) ||
3850 + (level == 1 && bank->irq_type[d->hwirq] == IRQ_TYPE_LEVEL_HIGH))
3851 + irq_chip_retrigger_hierarchy(d);
3852 +@@ -354,6 +365,7 @@ static int stm32_gpio_irq_request_resources(struct irq_data *irq_data)
3853 + {
3854 + struct stm32_gpio_bank *bank = irq_data->domain->host_data;
3855 + struct stm32_pinctrl *pctl = dev_get_drvdata(bank->gpio_chip.parent);
3856 ++ unsigned long flags;
3857 + int ret;
3858 +
3859 + ret = stm32_gpio_direction_input(&bank->gpio_chip, irq_data->hwirq);
3860 +@@ -367,6 +379,10 @@ static int stm32_gpio_irq_request_resources(struct irq_data *irq_data)
3861 + return ret;
3862 + }
3863 +
3864 ++ flags = irqd_get_trigger_type(irq_data);
3865 ++ if (flags & IRQ_TYPE_LEVEL_MASK)
3866 ++ clk_enable(bank->clk);
3867 ++
3868 + return 0;
3869 + }
3870 +
3871 +@@ -374,6 +390,9 @@ static void stm32_gpio_irq_release_resources(struct irq_data *irq_data)
3872 + {
3873 + struct stm32_gpio_bank *bank = irq_data->domain->host_data;
3874 +
3875 ++ if (bank->irq_type[irq_data->hwirq] & IRQ_TYPE_LEVEL_MASK)
3876 ++ clk_disable(bank->clk);
3877 ++
3878 + gpiochip_unlock_as_irq(&bank->gpio_chip, irq_data->hwirq);
3879 + }
3880 +
3881 +diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
3882 +index adab31b52f2af..1e7bc0c595c78 100644
3883 +--- a/drivers/platform/x86/asus-wmi.c
3884 ++++ b/drivers/platform/x86/asus-wmi.c
3885 +@@ -371,10 +371,14 @@ static int asus_wmi_evaluate_method_buf(u32 method_id,
3886 +
3887 + switch (obj->type) {
3888 + case ACPI_TYPE_BUFFER:
3889 +- if (obj->buffer.length > size)
3890 ++ if (obj->buffer.length > size) {
3891 + err = -ENOSPC;
3892 +- if (obj->buffer.length == 0)
3893 ++ break;
3894 ++ }
3895 ++ if (obj->buffer.length == 0) {
3896 + err = -ENODATA;
3897 ++ break;
3898 ++ }
3899 +
3900 + memcpy(ret_buffer, obj->buffer.pointer, obj->buffer.length);
3901 + break;
3902 +@@ -2223,9 +2227,10 @@ static int fan_curve_check_present(struct asus_wmi *asus, bool *available,
3903 +
3904 + err = fan_curve_get_factory_default(asus, fan_dev);
3905 + if (err) {
3906 +- if (err == -ENODEV || err == -ENODATA)
3907 +- return 0;
3908 +- return err;
3909 ++ pr_debug("fan_curve_get_factory_default(0x%08x) failed: %d\n",
3910 ++ fan_dev, err);
3911 ++ /* Don't cause probe to fail on devices without fan-curves */
3912 ++ return 0;
3913 + }
3914 +
3915 + *available = true;
3916 +diff --git a/drivers/soc/imx/imx8m-blk-ctrl.c b/drivers/soc/imx/imx8m-blk-ctrl.c
3917 +index 511e74f0db8a9..e096cca9f18a2 100644
3918 +--- a/drivers/soc/imx/imx8m-blk-ctrl.c
3919 ++++ b/drivers/soc/imx/imx8m-blk-ctrl.c
3920 +@@ -49,7 +49,7 @@ struct imx8m_blk_ctrl_domain_data {
3921 + u32 mipi_phy_rst_mask;
3922 + };
3923 +
3924 +-#define DOMAIN_MAX_CLKS 3
3925 ++#define DOMAIN_MAX_CLKS 4
3926 +
3927 + struct imx8m_blk_ctrl_domain {
3928 + struct generic_pm_domain genpd;
3929 +diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
3930 +index f744ab15bf2c6..30a6119a2b16a 100644
3931 +--- a/drivers/tee/optee/ffa_abi.c
3932 ++++ b/drivers/tee/optee/ffa_abi.c
3933 +@@ -894,6 +894,7 @@ err_rhashtable_free:
3934 + rhashtable_free_and_destroy(&optee->ffa.global_ids, rh_free_fn, NULL);
3935 + optee_supp_uninit(&optee->supp);
3936 + mutex_destroy(&optee->call_queue.mutex);
3937 ++ mutex_destroy(&optee->ffa.mutex);
3938 + err_unreg_supp_teedev:
3939 + tee_device_unregister(optee->supp_teedev);
3940 + err_unreg_teedev:
3941 +diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
3942 +index a0b599100106b..ba7eab0c62d43 100644
3943 +--- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
3944 ++++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
3945 +@@ -67,7 +67,7 @@ static int evaluate_odvp(struct int3400_thermal_priv *priv);
3946 + struct odvp_attr {
3947 + int odvp;
3948 + struct int3400_thermal_priv *priv;
3949 +- struct kobj_attribute attr;
3950 ++ struct device_attribute attr;
3951 + };
3952 +
3953 + static ssize_t data_vault_read(struct file *file, struct kobject *kobj,
3954 +@@ -271,7 +271,7 @@ static int int3400_thermal_run_osc(acpi_handle handle,
3955 + return result;
3956 + }
3957 +
3958 +-static ssize_t odvp_show(struct kobject *kobj, struct kobj_attribute *attr,
3959 ++static ssize_t odvp_show(struct device *dev, struct device_attribute *attr,
3960 + char *buf)
3961 + {
3962 + struct odvp_attr *odvp_attr;
3963 +diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
3964 +index fa92f727fdf89..a38b922bcbc10 100644
3965 +--- a/drivers/tty/n_gsm.c
3966 ++++ b/drivers/tty/n_gsm.c
3967 +@@ -73,6 +73,8 @@ module_param(debug, int, 0600);
3968 + */
3969 + #define MAX_MRU 1500
3970 + #define MAX_MTU 1500
3971 ++/* SOF, ADDR, CTRL, LEN1, LEN2, ..., FCS, EOF */
3972 ++#define PROT_OVERHEAD 7
3973 + #define GSM_NET_TX_TIMEOUT (HZ*10)
3974 +
3975 + /*
3976 +@@ -219,7 +221,6 @@ struct gsm_mux {
3977 + int encoding;
3978 + u8 control;
3979 + u8 fcs;
3980 +- u8 received_fcs;
3981 + u8 *txframe; /* TX framing buffer */
3982 +
3983 + /* Method for the receiver side */
3984 +@@ -231,6 +232,7 @@ struct gsm_mux {
3985 + int initiator; /* Did we initiate connection */
3986 + bool dead; /* Has the mux been shut down */
3987 + struct gsm_dlci *dlci[NUM_DLCI];
3988 ++ int old_c_iflag; /* termios c_iflag value before attach */
3989 + bool constipated; /* Asked by remote to shut up */
3990 +
3991 + spinlock_t tx_lock;
3992 +@@ -271,10 +273,6 @@ static DEFINE_SPINLOCK(gsm_mux_lock);
3993 +
3994 + static struct tty_driver *gsm_tty_driver;
3995 +
3996 +-/* Save dlci open address */
3997 +-static int addr_open[256] = { 0 };
3998 +-/* Save dlci open count */
3999 +-static int addr_cnt;
4000 + /*
4001 + * This section of the driver logic implements the GSM encodings
4002 + * both the basic and the 'advanced'. Reliable transport is not
4003 +@@ -369,6 +367,7 @@ static const u8 gsm_fcs8[256] = {
4004 + #define GOOD_FCS 0xCF
4005 +
4006 + static int gsmld_output(struct gsm_mux *gsm, u8 *data, int len);
4007 ++static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk);
4008 +
4009 + /**
4010 + * gsm_fcs_add - update FCS
4011 +@@ -832,7 +831,7 @@ static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci)
4012 + break;
4013 + case 2: /* Unstructed with modem bits.
4014 + Always one byte as we never send inline break data */
4015 +- *dp++ = gsm_encode_modem(dlci);
4016 ++ *dp++ = (gsm_encode_modem(dlci) << 1) | EA;
4017 + break;
4018 + }
4019 + WARN_ON(kfifo_out_locked(&dlci->fifo, dp , len, &dlci->lock) != len);
4020 +@@ -916,6 +915,66 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
4021 + return size;
4022 + }
4023 +
4024 ++/**
4025 ++ * gsm_dlci_modem_output - try and push modem status out of a DLCI
4026 ++ * @gsm: mux
4027 ++ * @dlci: the DLCI to pull modem status from
4028 ++ * @brk: break signal
4029 ++ *
4030 ++ * Push an empty frame in to the transmit queue to update the modem status
4031 ++ * bits and to transmit an optional break.
4032 ++ *
4033 ++ * Caller must hold the tx_lock of the mux.
4034 ++ */
4035 ++
4036 ++static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlci,
4037 ++ u8 brk)
4038 ++{
4039 ++ u8 *dp = NULL;
4040 ++ struct gsm_msg *msg;
4041 ++ int size = 0;
4042 ++
4043 ++ /* for modem bits without break data */
4044 ++ switch (dlci->adaption) {
4045 ++ case 1: /* Unstructured */
4046 ++ break;
4047 ++ case 2: /* Unstructured with modem bits. */
4048 ++ size++;
4049 ++ if (brk > 0)
4050 ++ size++;
4051 ++ break;
4052 ++ default:
4053 ++ pr_err("%s: unsupported adaption %d\n", __func__,
4054 ++ dlci->adaption);
4055 ++ return -EINVAL;
4056 ++ }
4057 ++
4058 ++ msg = gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype);
4059 ++ if (!msg) {
4060 ++ pr_err("%s: gsm_data_alloc error", __func__);
4061 ++ return -ENOMEM;
4062 ++ }
4063 ++ dp = msg->data;
4064 ++ switch (dlci->adaption) {
4065 ++ case 1: /* Unstructured */
4066 ++ break;
4067 ++ case 2: /* Unstructured with modem bits. */
4068 ++ if (brk == 0) {
4069 ++ *dp++ = (gsm_encode_modem(dlci) << 1) | EA;
4070 ++ } else {
4071 ++ *dp++ = gsm_encode_modem(dlci) << 1;
4072 ++ *dp++ = (brk << 4) | 2 | EA; /* Length, Break, EA */
4073 ++ }
4074 ++ break;
4075 ++ default:
4076 ++ /* Handled above */
4077 ++ break;
4078 ++ }
4079 ++
4080 ++ __gsm_data_queue(dlci, msg);
4081 ++ return size;
4082 ++}
4083 ++
4084 + /**
4085 + * gsm_dlci_data_sweep - look for data to send
4086 + * @gsm: the GSM mux
4087 +@@ -1093,7 +1152,6 @@ static void gsm_control_modem(struct gsm_mux *gsm, const u8 *data, int clen)
4088 + {
4089 + unsigned int addr = 0;
4090 + unsigned int modem = 0;
4091 +- unsigned int brk = 0;
4092 + struct gsm_dlci *dlci;
4093 + int len = clen;
4094 + int slen;
4095 +@@ -1123,17 +1181,8 @@ static void gsm_control_modem(struct gsm_mux *gsm, const u8 *data, int clen)
4096 + return;
4097 + }
4098 + len--;
4099 +- if (len > 0) {
4100 +- while (gsm_read_ea(&brk, *dp++) == 0) {
4101 +- len--;
4102 +- if (len == 0)
4103 +- return;
4104 +- }
4105 +- modem <<= 7;
4106 +- modem |= (brk & 0x7f);
4107 +- }
4108 + tty = tty_port_tty_get(&dlci->port);
4109 +- gsm_process_modem(tty, dlci, modem, slen);
4110 ++ gsm_process_modem(tty, dlci, modem, slen - len);
4111 + if (tty) {
4112 + tty_wakeup(tty);
4113 + tty_kref_put(tty);
4114 +@@ -1193,7 +1242,6 @@ static void gsm_control_rls(struct gsm_mux *gsm, const u8 *data, int clen)
4115 + }
4116 +
4117 + static void gsm_dlci_begin_close(struct gsm_dlci *dlci);
4118 +-static void gsm_dlci_close(struct gsm_dlci *dlci);
4119 +
4120 + /**
4121 + * gsm_control_message - DLCI 0 control processing
4122 +@@ -1212,28 +1260,15 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
4123 + {
4124 + u8 buf[1];
4125 + unsigned long flags;
4126 +- struct gsm_dlci *dlci;
4127 +- int i;
4128 +- int address;
4129 +
4130 + switch (command) {
4131 + case CMD_CLD: {
4132 +- if (addr_cnt > 0) {
4133 +- for (i = 0; i < addr_cnt; i++) {
4134 +- address = addr_open[i];
4135 +- dlci = gsm->dlci[address];
4136 +- gsm_dlci_close(dlci);
4137 +- addr_open[i] = 0;
4138 +- }
4139 +- }
4140 ++ struct gsm_dlci *dlci = gsm->dlci[0];
4141 + /* Modem wishes to close down */
4142 +- dlci = gsm->dlci[0];
4143 + if (dlci) {
4144 + dlci->dead = true;
4145 + gsm->dead = true;
4146 +- gsm_dlci_close(dlci);
4147 +- addr_cnt = 0;
4148 +- gsm_response(gsm, 0, UA|PF);
4149 ++ gsm_dlci_begin_close(dlci);
4150 + }
4151 + }
4152 + break;
4153 +@@ -1326,11 +1361,12 @@ static void gsm_control_response(struct gsm_mux *gsm, unsigned int command,
4154 +
4155 + static void gsm_control_transmit(struct gsm_mux *gsm, struct gsm_control *ctrl)
4156 + {
4157 +- struct gsm_msg *msg = gsm_data_alloc(gsm, 0, ctrl->len + 1, gsm->ftype);
4158 ++ struct gsm_msg *msg = gsm_data_alloc(gsm, 0, ctrl->len + 2, gsm->ftype);
4159 + if (msg == NULL)
4160 + return;
4161 +- msg->data[0] = (ctrl->cmd << 1) | 2 | EA; /* command */
4162 +- memcpy(msg->data + 1, ctrl->data, ctrl->len);
4163 ++ msg->data[0] = (ctrl->cmd << 1) | CR | EA; /* command */
4164 ++ msg->data[1] = (ctrl->len << 1) | EA;
4165 ++ memcpy(msg->data + 2, ctrl->data, ctrl->len);
4166 + gsm_data_queue(gsm->dlci[0], msg);
4167 + }
4168 +
4169 +@@ -1353,7 +1389,6 @@ static void gsm_control_retransmit(struct timer_list *t)
4170 + spin_lock_irqsave(&gsm->control_lock, flags);
4171 + ctrl = gsm->pending_cmd;
4172 + if (ctrl) {
4173 +- gsm->cretries--;
4174 + if (gsm->cretries == 0) {
4175 + gsm->pending_cmd = NULL;
4176 + ctrl->error = -ETIMEDOUT;
4177 +@@ -1362,6 +1397,7 @@ static void gsm_control_retransmit(struct timer_list *t)
4178 + wake_up(&gsm->event);
4179 + return;
4180 + }
4181 ++ gsm->cretries--;
4182 + gsm_control_transmit(gsm, ctrl);
4183 + mod_timer(&gsm->t2_timer, jiffies + gsm->t2 * HZ / 100);
4184 + }
4185 +@@ -1402,7 +1438,7 @@ retry:
4186 +
4187 + /* If DLCI0 is in ADM mode skip retries, it won't respond */
4188 + if (gsm->dlci[0]->mode == DLCI_MODE_ADM)
4189 +- gsm->cretries = 1;
4190 ++ gsm->cretries = 0;
4191 + else
4192 + gsm->cretries = gsm->n2;
4193 +
4194 +@@ -1450,20 +1486,22 @@ static int gsm_control_wait(struct gsm_mux *gsm, struct gsm_control *control)
4195 +
4196 + static void gsm_dlci_close(struct gsm_dlci *dlci)
4197 + {
4198 ++ unsigned long flags;
4199 ++
4200 + del_timer(&dlci->t1);
4201 + if (debug & 8)
4202 + pr_debug("DLCI %d goes closed.\n", dlci->addr);
4203 + dlci->state = DLCI_CLOSED;
4204 + if (dlci->addr != 0) {
4205 + tty_port_tty_hangup(&dlci->port, false);
4206 ++ spin_lock_irqsave(&dlci->lock, flags);
4207 + kfifo_reset(&dlci->fifo);
4208 ++ spin_unlock_irqrestore(&dlci->lock, flags);
4209 + /* Ensure that gsmtty_open() can return. */
4210 + tty_port_set_initialized(&dlci->port, 0);
4211 + wake_up_interruptible(&dlci->port.open_wait);
4212 + } else
4213 + dlci->gsm->dead = true;
4214 +- /* Unregister gsmtty driver,report gsmtty dev remove uevent for user */
4215 +- tty_unregister_device(gsm_tty_driver, dlci->addr);
4216 + wake_up(&dlci->gsm->event);
4217 + /* A DLCI 0 close is a MUX termination so we need to kick that
4218 + back to userspace somehow */
4219 +@@ -1485,8 +1523,9 @@ static void gsm_dlci_open(struct gsm_dlci *dlci)
4220 + dlci->state = DLCI_OPEN;
4221 + if (debug & 8)
4222 + pr_debug("DLCI %d goes open.\n", dlci->addr);
4223 +- /* Register gsmtty driver,report gsmtty dev add uevent for user */
4224 +- tty_register_device(gsm_tty_driver, dlci->addr, NULL);
4225 ++ /* Send current modem state */
4226 ++ if (dlci->addr)
4227 ++ gsm_modem_update(dlci, 0);
4228 + wake_up(&dlci->gsm->event);
4229 + }
4230 +
4231 +@@ -1623,6 +1662,7 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, const u8 *data, int clen)
4232 + tty = tty_port_tty_get(port);
4233 + if (tty) {
4234 + gsm_process_modem(tty, dlci, modem, slen);
4235 ++ tty_wakeup(tty);
4236 + tty_kref_put(tty);
4237 + }
4238 + fallthrough;
4239 +@@ -1793,19 +1833,7 @@ static void gsm_queue(struct gsm_mux *gsm)
4240 + struct gsm_dlci *dlci;
4241 + u8 cr;
4242 + int address;
4243 +- int i, j, k, address_tmp;
4244 +- /* We have to sneak a look at the packet body to do the FCS.
4245 +- A somewhat layering violation in the spec */
4246 +
4247 +- if ((gsm->control & ~PF) == UI)
4248 +- gsm->fcs = gsm_fcs_add_block(gsm->fcs, gsm->buf, gsm->len);
4249 +- if (gsm->encoding == 0) {
4250 +- /* WARNING: gsm->received_fcs is used for
4251 +- gsm->encoding = 0 only.
4252 +- In this case it contain the last piece of data
4253 +- required to generate final CRC */
4254 +- gsm->fcs = gsm_fcs_add(gsm->fcs, gsm->received_fcs);
4255 +- }
4256 + if (gsm->fcs != GOOD_FCS) {
4257 + gsm->bad_fcs++;
4258 + if (debug & 4)
4259 +@@ -1836,11 +1864,6 @@ static void gsm_queue(struct gsm_mux *gsm)
4260 + else {
4261 + gsm_response(gsm, address, UA|PF);
4262 + gsm_dlci_open(dlci);
4263 +- /* Save dlci open address */
4264 +- if (address) {
4265 +- addr_open[addr_cnt] = address;
4266 +- addr_cnt++;
4267 +- }
4268 + }
4269 + break;
4270 + case DISC|PF:
4271 +@@ -1851,35 +1874,9 @@ static void gsm_queue(struct gsm_mux *gsm)
4272 + return;
4273 + }
4274 + /* Real close complete */
4275 +- if (!address) {
4276 +- if (addr_cnt > 0) {
4277 +- for (i = 0; i < addr_cnt; i++) {
4278 +- address = addr_open[i];
4279 +- dlci = gsm->dlci[address];
4280 +- gsm_dlci_close(dlci);
4281 +- addr_open[i] = 0;
4282 +- }
4283 +- }
4284 +- dlci = gsm->dlci[0];
4285 +- gsm_dlci_close(dlci);
4286 +- addr_cnt = 0;
4287 +- gsm_response(gsm, 0, UA|PF);
4288 +- } else {
4289 +- gsm_response(gsm, address, UA|PF);
4290 +- gsm_dlci_close(dlci);
4291 +- /* clear dlci address */
4292 +- for (j = 0; j < addr_cnt; j++) {
4293 +- address_tmp = addr_open[j];
4294 +- if (address_tmp == address) {
4295 +- for (k = j; k < addr_cnt; k++)
4296 +- addr_open[k] = addr_open[k+1];
4297 +- addr_cnt--;
4298 +- break;
4299 +- }
4300 +- }
4301 +- }
4302 ++ gsm_response(gsm, address, UA|PF);
4303 ++ gsm_dlci_close(dlci);
4304 + break;
4305 +- case UA:
4306 + case UA|PF:
4307 + if (cr == 0 || dlci == NULL)
4308 + break;
4309 +@@ -1993,19 +1990,25 @@ static void gsm0_receive(struct gsm_mux *gsm, unsigned char c)
4310 + break;
4311 + case GSM_DATA: /* Data */
4312 + gsm->buf[gsm->count++] = c;
4313 +- if (gsm->count == gsm->len)
4314 ++ if (gsm->count == gsm->len) {
4315 ++ /* Calculate final FCS for UI frames over all data */
4316 ++ if ((gsm->control & ~PF) != UIH) {
4317 ++ gsm->fcs = gsm_fcs_add_block(gsm->fcs, gsm->buf,
4318 ++ gsm->count);
4319 ++ }
4320 + gsm->state = GSM_FCS;
4321 ++ }
4322 + break;
4323 + case GSM_FCS: /* FCS follows the packet */
4324 +- gsm->received_fcs = c;
4325 +- gsm_queue(gsm);
4326 ++ gsm->fcs = gsm_fcs_add(gsm->fcs, c);
4327 + gsm->state = GSM_SSOF;
4328 + break;
4329 + case GSM_SSOF:
4330 +- if (c == GSM0_SOF) {
4331 +- gsm->state = GSM_SEARCH;
4332 +- break;
4333 +- }
4334 ++ gsm->state = GSM_SEARCH;
4335 ++ if (c == GSM0_SOF)
4336 ++ gsm_queue(gsm);
4337 ++ else
4338 ++ gsm->bad_size++;
4339 + break;
4340 + default:
4341 + pr_debug("%s: unhandled state: %d\n", __func__, gsm->state);
4342 +@@ -2023,12 +2026,35 @@ static void gsm0_receive(struct gsm_mux *gsm, unsigned char c)
4343 +
4344 + static void gsm1_receive(struct gsm_mux *gsm, unsigned char c)
4345 + {
4346 ++ /* handle XON/XOFF */
4347 ++ if ((c & ISO_IEC_646_MASK) == XON) {
4348 ++ gsm->constipated = true;
4349 ++ return;
4350 ++ } else if ((c & ISO_IEC_646_MASK) == XOFF) {
4351 ++ gsm->constipated = false;
4352 ++ /* Kick the link in case it is idling */
4353 ++ gsm_data_kick(gsm, NULL);
4354 ++ return;
4355 ++ }
4356 + if (c == GSM1_SOF) {
4357 +- /* EOF is only valid in frame if we have got to the data state
4358 +- and received at least one byte (the FCS) */
4359 +- if (gsm->state == GSM_DATA && gsm->count) {
4360 +- /* Extract the FCS */
4361 ++ /* EOF is only valid in frame if we have got to the data state */
4362 ++ if (gsm->state == GSM_DATA) {
4363 ++ if (gsm->count < 1) {
4364 ++ /* Missing FSC */
4365 ++ gsm->malformed++;
4366 ++ gsm->state = GSM_START;
4367 ++ return;
4368 ++ }
4369 ++ /* Remove the FCS from data */
4370 + gsm->count--;
4371 ++ if ((gsm->control & ~PF) != UIH) {
4372 ++ /* Calculate final FCS for UI frames over all
4373 ++ * data but FCS
4374 ++ */
4375 ++ gsm->fcs = gsm_fcs_add_block(gsm->fcs, gsm->buf,
4376 ++ gsm->count);
4377 ++ }
4378 ++ /* Add the FCS itself to test against GOOD_FCS */
4379 + gsm->fcs = gsm_fcs_add(gsm->fcs, gsm->buf[gsm->count]);
4380 + gsm->len = gsm->count;
4381 + gsm_queue(gsm);
4382 +@@ -2037,7 +2063,8 @@ static void gsm1_receive(struct gsm_mux *gsm, unsigned char c)
4383 + }
4384 + /* Any partial frame was a runt so go back to start */
4385 + if (gsm->state != GSM_START) {
4386 +- gsm->malformed++;
4387 ++ if (gsm->state != GSM_SEARCH)
4388 ++ gsm->malformed++;
4389 + gsm->state = GSM_START;
4390 + }
4391 + /* A SOF in GSM_START means we are still reading idling or
4392 +@@ -2106,74 +2133,43 @@ static void gsm_error(struct gsm_mux *gsm)
4393 + gsm->io_error++;
4394 + }
4395 +
4396 +-static int gsm_disconnect(struct gsm_mux *gsm)
4397 +-{
4398 +- struct gsm_dlci *dlci = gsm->dlci[0];
4399 +- struct gsm_control *gc;
4400 +-
4401 +- if (!dlci)
4402 +- return 0;
4403 +-
4404 +- /* In theory disconnecting DLCI 0 is sufficient but for some
4405 +- modems this is apparently not the case. */
4406 +- gc = gsm_control_send(gsm, CMD_CLD, NULL, 0);
4407 +- if (gc)
4408 +- gsm_control_wait(gsm, gc);
4409 +-
4410 +- del_timer_sync(&gsm->t2_timer);
4411 +- /* Now we are sure T2 has stopped */
4412 +-
4413 +- gsm_dlci_begin_close(dlci);
4414 +- wait_event_interruptible(gsm->event,
4415 +- dlci->state == DLCI_CLOSED);
4416 +-
4417 +- if (signal_pending(current))
4418 +- return -EINTR;
4419 +-
4420 +- return 0;
4421 +-}
4422 +-
4423 + /**
4424 + * gsm_cleanup_mux - generic GSM protocol cleanup
4425 + * @gsm: our mux
4426 ++ * @disc: disconnect link?
4427 + *
4428 + * Clean up the bits of the mux which are the same for all framing
4429 + * protocols. Remove the mux from the mux table, stop all the timers
4430 + * and then shut down each device hanging up the channels as we go.
4431 + */
4432 +
4433 +-static void gsm_cleanup_mux(struct gsm_mux *gsm)
4434 ++static void gsm_cleanup_mux(struct gsm_mux *gsm, bool disc)
4435 + {
4436 + int i;
4437 + struct gsm_dlci *dlci = gsm->dlci[0];
4438 + struct gsm_msg *txq, *ntxq;
4439 +
4440 + gsm->dead = true;
4441 ++ mutex_lock(&gsm->mutex);
4442 +
4443 +- spin_lock(&gsm_mux_lock);
4444 +- for (i = 0; i < MAX_MUX; i++) {
4445 +- if (gsm_mux[i] == gsm) {
4446 +- gsm_mux[i] = NULL;
4447 +- break;
4448 ++ if (dlci) {
4449 ++ if (disc && dlci->state != DLCI_CLOSED) {
4450 ++ gsm_dlci_begin_close(dlci);
4451 ++ wait_event(gsm->event, dlci->state == DLCI_CLOSED);
4452 + }
4453 ++ dlci->dead = true;
4454 + }
4455 +- spin_unlock(&gsm_mux_lock);
4456 +- /* open failed before registering => nothing to do */
4457 +- if (i == MAX_MUX)
4458 +- return;
4459 +
4460 ++ /* Finish outstanding timers, making sure they are done */
4461 + del_timer_sync(&gsm->t2_timer);
4462 +- /* Now we are sure T2 has stopped */
4463 +- if (dlci)
4464 +- dlci->dead = true;
4465 +
4466 +- /* Free up any link layer users */
4467 +- mutex_lock(&gsm->mutex);
4468 +- for (i = 0; i < NUM_DLCI; i++)
4469 ++ /* Free up any link layer users and finally the control channel */
4470 ++ for (i = NUM_DLCI - 1; i >= 0; i--)
4471 + if (gsm->dlci[i])
4472 + gsm_dlci_release(gsm->dlci[i]);
4473 + mutex_unlock(&gsm->mutex);
4474 + /* Now wipe the queues */
4475 ++ tty_ldisc_flush(gsm->tty);
4476 + list_for_each_entry_safe(txq, ntxq, &gsm->tx_list, list)
4477 + kfree(txq);
4478 + INIT_LIST_HEAD(&gsm->tx_list);
4479 +@@ -2191,7 +2187,6 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm)
4480 + static int gsm_activate_mux(struct gsm_mux *gsm)
4481 + {
4482 + struct gsm_dlci *dlci;
4483 +- int i = 0;
4484 +
4485 + timer_setup(&gsm->t2_timer, gsm_control_retransmit, 0);
4486 + init_waitqueue_head(&gsm->event);
4487 +@@ -2203,18 +2198,6 @@ static int gsm_activate_mux(struct gsm_mux *gsm)
4488 + else
4489 + gsm->receive = gsm1_receive;
4490 +
4491 +- spin_lock(&gsm_mux_lock);
4492 +- for (i = 0; i < MAX_MUX; i++) {
4493 +- if (gsm_mux[i] == NULL) {
4494 +- gsm->num = i;
4495 +- gsm_mux[i] = gsm;
4496 +- break;
4497 +- }
4498 +- }
4499 +- spin_unlock(&gsm_mux_lock);
4500 +- if (i == MAX_MUX)
4501 +- return -EBUSY;
4502 +-
4503 + dlci = gsm_dlci_alloc(gsm, 0);
4504 + if (dlci == NULL)
4505 + return -ENOMEM;
4506 +@@ -2230,6 +2213,15 @@ static int gsm_activate_mux(struct gsm_mux *gsm)
4507 + */
4508 + static void gsm_free_mux(struct gsm_mux *gsm)
4509 + {
4510 ++ int i;
4511 ++
4512 ++ for (i = 0; i < MAX_MUX; i++) {
4513 ++ if (gsm == gsm_mux[i]) {
4514 ++ gsm_mux[i] = NULL;
4515 ++ break;
4516 ++ }
4517 ++ }
4518 ++ mutex_destroy(&gsm->mutex);
4519 + kfree(gsm->txframe);
4520 + kfree(gsm->buf);
4521 + kfree(gsm);
4522 +@@ -2249,12 +2241,20 @@ static void gsm_free_muxr(struct kref *ref)
4523 +
4524 + static inline void mux_get(struct gsm_mux *gsm)
4525 + {
4526 ++ unsigned long flags;
4527 ++
4528 ++ spin_lock_irqsave(&gsm_mux_lock, flags);
4529 + kref_get(&gsm->ref);
4530 ++ spin_unlock_irqrestore(&gsm_mux_lock, flags);
4531 + }
4532 +
4533 + static inline void mux_put(struct gsm_mux *gsm)
4534 + {
4535 ++ unsigned long flags;
4536 ++
4537 ++ spin_lock_irqsave(&gsm_mux_lock, flags);
4538 + kref_put(&gsm->ref, gsm_free_muxr);
4539 ++ spin_unlock_irqrestore(&gsm_mux_lock, flags);
4540 + }
4541 +
4542 + static inline unsigned int mux_num_to_base(struct gsm_mux *gsm)
4543 +@@ -2275,6 +2275,7 @@ static inline unsigned int mux_line_to_num(unsigned int line)
4544 +
4545 + static struct gsm_mux *gsm_alloc_mux(void)
4546 + {
4547 ++ int i;
4548 + struct gsm_mux *gsm = kzalloc(sizeof(struct gsm_mux), GFP_KERNEL);
4549 + if (gsm == NULL)
4550 + return NULL;
4551 +@@ -2283,7 +2284,7 @@ static struct gsm_mux *gsm_alloc_mux(void)
4552 + kfree(gsm);
4553 + return NULL;
4554 + }
4555 +- gsm->txframe = kmalloc(2 * MAX_MRU + 2, GFP_KERNEL);
4556 ++ gsm->txframe = kmalloc(2 * (MAX_MTU + PROT_OVERHEAD - 1), GFP_KERNEL);
4557 + if (gsm->txframe == NULL) {
4558 + kfree(gsm->buf);
4559 + kfree(gsm);
4560 +@@ -2304,6 +2305,26 @@ static struct gsm_mux *gsm_alloc_mux(void)
4561 + gsm->mtu = 64;
4562 + gsm->dead = true; /* Avoid early tty opens */
4563 +
4564 ++ /* Store the instance to the mux array or abort if no space is
4565 ++ * available.
4566 ++ */
4567 ++ spin_lock(&gsm_mux_lock);
4568 ++ for (i = 0; i < MAX_MUX; i++) {
4569 ++ if (!gsm_mux[i]) {
4570 ++ gsm_mux[i] = gsm;
4571 ++ gsm->num = i;
4572 ++ break;
4573 ++ }
4574 ++ }
4575 ++ spin_unlock(&gsm_mux_lock);
4576 ++ if (i == MAX_MUX) {
4577 ++ mutex_destroy(&gsm->mutex);
4578 ++ kfree(gsm->txframe);
4579 ++ kfree(gsm->buf);
4580 ++ kfree(gsm);
4581 ++ return NULL;
4582 ++ }
4583 ++
4584 + return gsm;
4585 + }
4586 +
4587 +@@ -2339,7 +2360,7 @@ static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c)
4588 + /* Check the MRU/MTU range looks sane */
4589 + if (c->mru > MAX_MRU || c->mtu > MAX_MTU || c->mru < 8 || c->mtu < 8)
4590 + return -EINVAL;
4591 +- if (c->n2 < 3)
4592 ++ if (c->n2 > 255)
4593 + return -EINVAL;
4594 + if (c->encapsulation > 1) /* Basic, advanced, no I */
4595 + return -EINVAL;
4596 +@@ -2370,19 +2391,11 @@ static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c)
4597 +
4598 + /*
4599 + * Close down what is needed, restart and initiate the new
4600 +- * configuration
4601 ++ * configuration. On the first time there is no DLCI[0]
4602 ++ * and closing or cleaning up is not necessary.
4603 + */
4604 +-
4605 +- if (gsm->initiator && (need_close || need_restart)) {
4606 +- int ret;
4607 +-
4608 +- ret = gsm_disconnect(gsm);
4609 +-
4610 +- if (ret)
4611 +- return ret;
4612 +- }
4613 +- if (need_restart)
4614 +- gsm_cleanup_mux(gsm);
4615 ++ if (need_close || need_restart)
4616 ++ gsm_cleanup_mux(gsm, true);
4617 +
4618 + gsm->initiator = c->initiator;
4619 + gsm->mru = c->mru;
4620 +@@ -2450,25 +2463,26 @@ static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
4621 + int ret, i;
4622 +
4623 + gsm->tty = tty_kref_get(tty);
4624 ++ /* Turn off tty XON/XOFF handling to handle it explicitly. */
4625 ++ gsm->old_c_iflag = tty->termios.c_iflag;
4626 ++ tty->termios.c_iflag &= (IXON | IXOFF);
4627 + ret = gsm_activate_mux(gsm);
4628 + if (ret != 0)
4629 + tty_kref_put(gsm->tty);
4630 + else {
4631 + /* Don't register device 0 - this is the control channel and not
4632 + a usable tty interface */
4633 +- if (gsm->initiator) {
4634 +- base = mux_num_to_base(gsm); /* Base for this MUX */
4635 +- for (i = 1; i < NUM_DLCI; i++) {
4636 +- struct device *dev;
4637 ++ base = mux_num_to_base(gsm); /* Base for this MUX */
4638 ++ for (i = 1; i < NUM_DLCI; i++) {
4639 ++ struct device *dev;
4640 +
4641 +- dev = tty_register_device(gsm_tty_driver,
4642 ++ dev = tty_register_device(gsm_tty_driver,
4643 + base + i, NULL);
4644 +- if (IS_ERR(dev)) {
4645 +- for (i--; i >= 1; i--)
4646 +- tty_unregister_device(gsm_tty_driver,
4647 +- base + i);
4648 +- return PTR_ERR(dev);
4649 +- }
4650 ++ if (IS_ERR(dev)) {
4651 ++ for (i--; i >= 1; i--)
4652 ++ tty_unregister_device(gsm_tty_driver,
4653 ++ base + i);
4654 ++ return PTR_ERR(dev);
4655 + }
4656 + }
4657 + }
4658 +@@ -2490,11 +2504,10 @@ static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
4659 + int i;
4660 +
4661 + WARN_ON(tty != gsm->tty);
4662 +- if (gsm->initiator) {
4663 +- for (i = 1; i < NUM_DLCI; i++)
4664 +- tty_unregister_device(gsm_tty_driver, base + i);
4665 +- }
4666 +- gsm_cleanup_mux(gsm);
4667 ++ for (i = 1; i < NUM_DLCI; i++)
4668 ++ tty_unregister_device(gsm_tty_driver, base + i);
4669 ++ /* Restore tty XON/XOFF handling. */
4670 ++ gsm->tty->termios.c_iflag = gsm->old_c_iflag;
4671 + tty_kref_put(gsm->tty);
4672 + gsm->tty = NULL;
4673 + }
4674 +@@ -2559,6 +2572,12 @@ static void gsmld_close(struct tty_struct *tty)
4675 + {
4676 + struct gsm_mux *gsm = tty->disc_data;
4677 +
4678 ++ /* The ldisc locks and closes the port before calling our close. This
4679 ++ * means we have no way to do a proper disconnect. We will not bother
4680 ++ * to do one.
4681 ++ */
4682 ++ gsm_cleanup_mux(gsm, false);
4683 ++
4684 + gsmld_detach_gsm(tty, gsm);
4685 +
4686 + gsmld_flush_buffer(tty);
4687 +@@ -2597,7 +2616,7 @@ static int gsmld_open(struct tty_struct *tty)
4688 +
4689 + ret = gsmld_attach_gsm(tty, gsm);
4690 + if (ret != 0) {
4691 +- gsm_cleanup_mux(gsm);
4692 ++ gsm_cleanup_mux(gsm, false);
4693 + mux_put(gsm);
4694 + }
4695 + return ret;
4696 +@@ -2954,26 +2973,78 @@ static struct tty_ldisc_ops tty_ldisc_packet = {
4697 +
4698 + #define TX_SIZE 512
4699 +
4700 +-static int gsmtty_modem_update(struct gsm_dlci *dlci, u8 brk)
4701 ++/**
4702 ++ * gsm_modem_upd_via_data - send modem bits via convergence layer
4703 ++ * @dlci: channel
4704 ++ * @brk: break signal
4705 ++ *
4706 ++ * Send an empty frame to signal mobile state changes and to transmit the
4707 ++ * break signal for adaption 2.
4708 ++ */
4709 ++
4710 ++static void gsm_modem_upd_via_data(struct gsm_dlci *dlci, u8 brk)
4711 + {
4712 +- u8 modembits[5];
4713 ++ struct gsm_mux *gsm = dlci->gsm;
4714 ++ unsigned long flags;
4715 ++
4716 ++ if (dlci->state != DLCI_OPEN || dlci->adaption != 2)
4717 ++ return;
4718 ++
4719 ++ spin_lock_irqsave(&gsm->tx_lock, flags);
4720 ++ gsm_dlci_modem_output(gsm, dlci, brk);
4721 ++ spin_unlock_irqrestore(&gsm->tx_lock, flags);
4722 ++}
4723 ++
4724 ++/**
4725 ++ * gsm_modem_upd_via_msc - send modem bits via control frame
4726 ++ * @dlci: channel
4727 ++ * @brk: break signal
4728 ++ */
4729 ++
4730 ++static int gsm_modem_upd_via_msc(struct gsm_dlci *dlci, u8 brk)
4731 ++{
4732 ++ u8 modembits[3];
4733 + struct gsm_control *ctrl;
4734 + int len = 2;
4735 +
4736 +- if (brk)
4737 +- len++;
4738 ++ if (dlci->gsm->encoding != 0)
4739 ++ return 0;
4740 +
4741 +- modembits[0] = len << 1 | EA; /* Data bytes */
4742 +- modembits[1] = dlci->addr << 2 | 3; /* DLCI, EA, 1 */
4743 +- modembits[2] = gsm_encode_modem(dlci) << 1 | EA;
4744 +- if (brk)
4745 +- modembits[3] = brk << 4 | 2 | EA; /* Valid, EA */
4746 +- ctrl = gsm_control_send(dlci->gsm, CMD_MSC, modembits, len + 1);
4747 ++ modembits[0] = (dlci->addr << 2) | 2 | EA; /* DLCI, Valid, EA */
4748 ++ if (!brk) {
4749 ++ modembits[1] = (gsm_encode_modem(dlci) << 1) | EA;
4750 ++ } else {
4751 ++ modembits[1] = gsm_encode_modem(dlci) << 1;
4752 ++ modembits[2] = (brk << 4) | 2 | EA; /* Length, Break, EA */
4753 ++ len++;
4754 ++ }
4755 ++ ctrl = gsm_control_send(dlci->gsm, CMD_MSC, modembits, len);
4756 + if (ctrl == NULL)
4757 + return -ENOMEM;
4758 + return gsm_control_wait(dlci->gsm, ctrl);
4759 + }
4760 +
4761 ++/**
4762 ++ * gsm_modem_update - send modem status line state
4763 ++ * @dlci: channel
4764 ++ * @brk: break signal
4765 ++ */
4766 ++
4767 ++static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk)
4768 ++{
4769 ++ if (dlci->adaption == 2) {
4770 ++ /* Send convergence layer type 2 empty data frame. */
4771 ++ gsm_modem_upd_via_data(dlci, brk);
4772 ++ return 0;
4773 ++ } else if (dlci->gsm->encoding == 0) {
4774 ++ /* Send as MSC control message. */
4775 ++ return gsm_modem_upd_via_msc(dlci, brk);
4776 ++ }
4777 ++
4778 ++ /* Modem status lines are not supported. */
4779 ++ return -EPROTONOSUPPORT;
4780 ++}
4781 ++
4782 + static int gsm_carrier_raised(struct tty_port *port)
4783 + {
4784 + struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port);
4785 +@@ -3006,7 +3077,7 @@ static void gsm_dtr_rts(struct tty_port *port, int onoff)
4786 + modem_tx &= ~(TIOCM_DTR | TIOCM_RTS);
4787 + if (modem_tx != dlci->modem_tx) {
4788 + dlci->modem_tx = modem_tx;
4789 +- gsmtty_modem_update(dlci, 0);
4790 ++ gsm_modem_update(dlci, 0);
4791 + }
4792 + }
4793 +
4794 +@@ -3155,13 +3226,17 @@ static unsigned int gsmtty_chars_in_buffer(struct tty_struct *tty)
4795 + static void gsmtty_flush_buffer(struct tty_struct *tty)
4796 + {
4797 + struct gsm_dlci *dlci = tty->driver_data;
4798 ++ unsigned long flags;
4799 ++
4800 + if (dlci->state == DLCI_CLOSED)
4801 + return;
4802 + /* Caution needed: If we implement reliable transport classes
4803 + then the data being transmitted can't simply be junked once
4804 + it has first hit the stack. Until then we can just blow it
4805 + away */
4806 ++ spin_lock_irqsave(&dlci->lock, flags);
4807 + kfifo_reset(&dlci->fifo);
4808 ++ spin_unlock_irqrestore(&dlci->lock, flags);
4809 + /* Need to unhook this DLCI from the transmit queue logic */
4810 + }
4811 +
4812 +@@ -3193,7 +3268,7 @@ static int gsmtty_tiocmset(struct tty_struct *tty,
4813 +
4814 + if (modem_tx != dlci->modem_tx) {
4815 + dlci->modem_tx = modem_tx;
4816 +- return gsmtty_modem_update(dlci, 0);
4817 ++ return gsm_modem_update(dlci, 0);
4818 + }
4819 + return 0;
4820 + }
4821 +@@ -3254,7 +3329,7 @@ static void gsmtty_throttle(struct tty_struct *tty)
4822 + dlci->modem_tx &= ~TIOCM_RTS;
4823 + dlci->throttled = true;
4824 + /* Send an MSC with RTS cleared */
4825 +- gsmtty_modem_update(dlci, 0);
4826 ++ gsm_modem_update(dlci, 0);
4827 + }
4828 +
4829 + static void gsmtty_unthrottle(struct tty_struct *tty)
4830 +@@ -3266,7 +3341,7 @@ static void gsmtty_unthrottle(struct tty_struct *tty)
4831 + dlci->modem_tx |= TIOCM_RTS;
4832 + dlci->throttled = false;
4833 + /* Send an MSC with RTS set */
4834 +- gsmtty_modem_update(dlci, 0);
4835 ++ gsm_modem_update(dlci, 0);
4836 + }
4837 +
4838 + static int gsmtty_break_ctl(struct tty_struct *tty, int state)
4839 +@@ -3284,7 +3359,7 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int state)
4840 + if (encode > 0x0F)
4841 + encode = 0x0F; /* Best effort */
4842 + }
4843 +- return gsmtty_modem_update(dlci, encode);
4844 ++ return gsm_modem_update(dlci, encode);
4845 + }
4846 +
4847 + static void gsmtty_cleanup(struct tty_struct *tty)
4848 +diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
4849 +index e17e97ea86fad..a293e9f107d0f 100644
4850 +--- a/drivers/tty/serial/8250/8250_pci.c
4851 ++++ b/drivers/tty/serial/8250/8250_pci.c
4852 +@@ -2667,7 +2667,7 @@ enum pci_board_num_t {
4853 + pbn_panacom2,
4854 + pbn_panacom4,
4855 + pbn_plx_romulus,
4856 +- pbn_endrun_2_4000000,
4857 ++ pbn_endrun_2_3906250,
4858 + pbn_oxsemi,
4859 + pbn_oxsemi_1_3906250,
4860 + pbn_oxsemi_2_3906250,
4861 +@@ -3195,10 +3195,10 @@ static struct pciserial_board pci_boards[] = {
4862 + * signal now many ports are available
4863 + * 2 port 952 Uart support
4864 + */
4865 +- [pbn_endrun_2_4000000] = {
4866 ++ [pbn_endrun_2_3906250] = {
4867 + .flags = FL_BASE0,
4868 + .num_ports = 2,
4869 +- .base_baud = 4000000,
4870 ++ .base_baud = 3906250,
4871 + .uart_offset = 0x200,
4872 + .first_offset = 0x1000,
4873 + },
4874 +@@ -4115,7 +4115,7 @@ static const struct pci_device_id serial_pci_tbl[] = {
4875 + */
4876 + { PCI_VENDOR_ID_ENDRUN, PCI_DEVICE_ID_ENDRUN_1588,
4877 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
4878 +- pbn_endrun_2_4000000 },
4879 ++ pbn_endrun_2_3906250 },
4880 + /*
4881 + * Quatech cards. These actually have configurable clocks but for
4882 + * now we just use the default.
4883 +diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
4884 +index 9f116e75956e2..992b71efd4a36 100644
4885 +--- a/drivers/tty/serial/8250/8250_port.c
4886 ++++ b/drivers/tty/serial/8250/8250_port.c
4887 +@@ -3340,7 +3340,7 @@ static void serial8250_console_restore(struct uart_8250_port *up)
4888 +
4889 + serial8250_set_divisor(port, baud, quot, frac);
4890 + serial_port_out(port, UART_LCR, up->lcr);
4891 +- serial8250_out_MCR(up, UART_MCR_DTR | UART_MCR_RTS);
4892 ++ serial8250_out_MCR(up, up->mcr | UART_MCR_DTR | UART_MCR_RTS);
4893 + }
4894 +
4895 + /*
4896 +diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
4897 +index ba053a68529f7..26d2a031aee2d 100644
4898 +--- a/drivers/tty/serial/amba-pl011.c
4899 ++++ b/drivers/tty/serial/amba-pl011.c
4900 +@@ -1255,13 +1255,18 @@ static inline bool pl011_dma_rx_running(struct uart_amba_port *uap)
4901 +
4902 + static void pl011_rs485_tx_stop(struct uart_amba_port *uap)
4903 + {
4904 ++ /*
4905 ++ * To be on the safe side only time out after twice as many iterations
4906 ++ * as fifo size.
4907 ++ */
4908 ++ const int MAX_TX_DRAIN_ITERS = uap->port.fifosize * 2;
4909 + struct uart_port *port = &uap->port;
4910 + int i = 0;
4911 + u32 cr;
4912 +
4913 + /* Wait until hardware tx queue is empty */
4914 + while (!pl011_tx_empty(port)) {
4915 +- if (i == port->fifosize) {
4916 ++ if (i > MAX_TX_DRAIN_ITERS) {
4917 + dev_warn(port->dev,
4918 + "timeout while draining hardware tx queue\n");
4919 + break;
4920 +@@ -2052,7 +2057,7 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
4921 + * with the given baud rate. We use this as the poll interval when we
4922 + * wait for the tx queue to empty.
4923 + */
4924 +- uap->rs485_tx_drain_interval = (bits * 1000 * 1000) / baud;
4925 ++ uap->rs485_tx_drain_interval = DIV_ROUND_UP(bits * 1000 * 1000, baud);
4926 +
4927 + pl011_setup_status_masks(port, termios);
4928 +
4929 +diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
4930 +index df8a0c8b8b29b..8dcffa69088a4 100644
4931 +--- a/drivers/tty/serial/imx.c
4932 ++++ b/drivers/tty/serial/imx.c
4933 +@@ -1438,7 +1438,7 @@ static int imx_uart_startup(struct uart_port *port)
4934 + imx_uart_writel(sport, ucr1, UCR1);
4935 +
4936 + ucr4 = imx_uart_readl(sport, UCR4) & ~(UCR4_OREN | UCR4_INVR);
4937 +- if (!sport->dma_is_enabled)
4938 ++ if (!dma_is_inited)
4939 + ucr4 |= UCR4_OREN;
4940 + if (sport->inverted_rx)
4941 + ucr4 |= UCR4_INVR;
4942 +diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
4943 +index f9af7ebe003d7..d6d515d598dc0 100644
4944 +--- a/drivers/usb/cdns3/cdns3-gadget.c
4945 ++++ b/drivers/usb/cdns3/cdns3-gadget.c
4946 +@@ -2684,6 +2684,7 @@ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
4947 + struct usb_request *request;
4948 + struct cdns3_request *priv_req;
4949 + struct cdns3_trb *trb = NULL;
4950 ++ struct cdns3_trb trb_tmp;
4951 + int ret;
4952 + int val;
4953 +
4954 +@@ -2693,8 +2694,10 @@ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
4955 + if (request) {
4956 + priv_req = to_cdns3_request(request);
4957 + trb = priv_req->trb;
4958 +- if (trb)
4959 ++ if (trb) {
4960 ++ trb_tmp = *trb;
4961 + trb->control = trb->control ^ cpu_to_le32(TRB_CYCLE);
4962 ++ }
4963 + }
4964 +
4965 + writel(EP_CMD_CSTALL | EP_CMD_EPRST, &priv_dev->regs->ep_cmd);
4966 +@@ -2709,7 +2712,7 @@ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
4967 +
4968 + if (request) {
4969 + if (trb)
4970 +- trb->control = trb->control ^ cpu_to_le32(TRB_CYCLE);
4971 ++ *trb = trb_tmp;
4972 +
4973 + cdns3_rearm_transfer(priv_ep, 1);
4974 + }
4975 +diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
4976 +index fa66e6e587928..656ba91c32831 100644
4977 +--- a/drivers/usb/core/devio.c
4978 ++++ b/drivers/usb/core/devio.c
4979 +@@ -1197,12 +1197,16 @@ static int do_proc_control(struct usb_dev_state *ps,
4980 +
4981 + usb_unlock_device(dev);
4982 + i = usbfs_start_wait_urb(urb, tmo, &actlen);
4983 ++
4984 ++ /* Linger a bit, prior to the next control message. */
4985 ++ if (dev->quirks & USB_QUIRK_DELAY_CTRL_MSG)
4986 ++ msleep(200);
4987 + usb_lock_device(dev);
4988 + snoop_urb(dev, NULL, pipe, actlen, i, COMPLETE, tbuf, actlen);
4989 + if (!i && actlen) {
4990 + if (copy_to_user(ctrl->data, tbuf, actlen)) {
4991 + ret = -EFAULT;
4992 +- goto recv_fault;
4993 ++ goto done;
4994 + }
4995 + }
4996 + } else {
4997 +@@ -1219,6 +1223,10 @@ static int do_proc_control(struct usb_dev_state *ps,
4998 +
4999 + usb_unlock_device(dev);
5000 + i = usbfs_start_wait_urb(urb, tmo, &actlen);
5001 ++
5002 ++ /* Linger a bit, prior to the next control message. */
5003 ++ if (dev->quirks & USB_QUIRK_DELAY_CTRL_MSG)
5004 ++ msleep(200);
5005 + usb_lock_device(dev);
5006 + snoop_urb(dev, NULL, pipe, actlen, i, COMPLETE, NULL, 0);
5007 + }
5008 +@@ -1230,10 +1238,6 @@ static int do_proc_control(struct usb_dev_state *ps,
5009 + }
5010 + ret = (i < 0 ? i : actlen);
5011 +
5012 +- recv_fault:
5013 +- /* Linger a bit, prior to the next control message. */
5014 +- if (dev->quirks & USB_QUIRK_DELAY_CTRL_MSG)
5015 +- msleep(200);
5016 + done:
5017 + kfree(dr);
5018 + usb_free_urb(urb);
5019 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
5020 +index d3c14b5ed4a1f..97b44a68668a5 100644
5021 +--- a/drivers/usb/core/quirks.c
5022 ++++ b/drivers/usb/core/quirks.c
5023 +@@ -404,6 +404,9 @@ static const struct usb_device_id usb_quirk_list[] = {
5024 + { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
5025 + USB_QUIRK_IGNORE_REMOTE_WAKEUP },
5026 +
5027 ++ /* Realtek Semiconductor Corp. Mass Storage Device (Multicard Reader)*/
5028 ++ { USB_DEVICE(0x0bda, 0x0151), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
5029 ++
5030 + /* Realtek hub in Dell WD19 (Type-C) */
5031 + { USB_DEVICE(0x0bda, 0x0487), .driver_info = USB_QUIRK_NO_LPM },
5032 +
5033 +@@ -507,6 +510,9 @@ static const struct usb_device_id usb_quirk_list[] = {
5034 + /* DJI CineSSD */
5035 + { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
5036 +
5037 ++ /* VCOM device */
5038 ++ { USB_DEVICE(0x4296, 0x7570), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
5039 ++
5040 + /* INTEL VALUE SSD */
5041 + { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
5042 +
5043 +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
5044 +index f4c09951b517e..f9cdfd9606864 100644
5045 +--- a/drivers/usb/dwc3/core.c
5046 ++++ b/drivers/usb/dwc3/core.c
5047 +@@ -276,7 +276,8 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)
5048 +
5049 + reg = dwc3_readl(dwc->regs, DWC3_DCTL);
5050 + reg |= DWC3_DCTL_CSFTRST;
5051 +- dwc3_writel(dwc->regs, DWC3_DCTL, reg);
5052 ++ reg &= ~DWC3_DCTL_RUN_STOP;
5053 ++ dwc3_gadget_dctl_write_safe(dwc, reg);
5054 +
5055 + /*
5056 + * For DWC_usb31 controller 1.90a and later, the DCTL.CSFRST bit
5057 +@@ -1295,10 +1296,10 @@ static void dwc3_get_properties(struct dwc3 *dwc)
5058 + u8 lpm_nyet_threshold;
5059 + u8 tx_de_emphasis;
5060 + u8 hird_threshold;
5061 +- u8 rx_thr_num_pkt_prd;
5062 +- u8 rx_max_burst_prd;
5063 +- u8 tx_thr_num_pkt_prd;
5064 +- u8 tx_max_burst_prd;
5065 ++ u8 rx_thr_num_pkt_prd = 0;
5066 ++ u8 rx_max_burst_prd = 0;
5067 ++ u8 tx_thr_num_pkt_prd = 0;
5068 ++ u8 tx_max_burst_prd = 0;
5069 + u8 tx_fifo_resize_max_num;
5070 + const char *usb_psy_name;
5071 + int ret;
5072 +diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
5073 +index d7f76835137fa..f148b0370f829 100644
5074 +--- a/drivers/usb/dwc3/drd.c
5075 ++++ b/drivers/usb/dwc3/drd.c
5076 +@@ -571,16 +571,15 @@ int dwc3_drd_init(struct dwc3 *dwc)
5077 + {
5078 + int ret, irq;
5079 +
5080 ++ if (ROLE_SWITCH &&
5081 ++ device_property_read_bool(dwc->dev, "usb-role-switch"))
5082 ++ return dwc3_setup_role_switch(dwc);
5083 ++
5084 + dwc->edev = dwc3_get_extcon(dwc);
5085 + if (IS_ERR(dwc->edev))
5086 + return PTR_ERR(dwc->edev);
5087 +
5088 +- if (ROLE_SWITCH &&
5089 +- device_property_read_bool(dwc->dev, "usb-role-switch")) {
5090 +- ret = dwc3_setup_role_switch(dwc);
5091 +- if (ret < 0)
5092 +- return ret;
5093 +- } else if (dwc->edev) {
5094 ++ if (dwc->edev) {
5095 + dwc->edev_nb.notifier_call = dwc3_drd_notifier;
5096 + ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,
5097 + &dwc->edev_nb);
5098 +diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
5099 +index 4d9608cc55f73..f08b2178fd32d 100644
5100 +--- a/drivers/usb/dwc3/dwc3-pci.c
5101 ++++ b/drivers/usb/dwc3/dwc3-pci.c
5102 +@@ -44,6 +44,8 @@
5103 + #define PCI_DEVICE_ID_INTEL_ADLM 0x54ee
5104 + #define PCI_DEVICE_ID_INTEL_ADLS 0x7ae1
5105 + #define PCI_DEVICE_ID_INTEL_RPLS 0x7a61
5106 ++#define PCI_DEVICE_ID_INTEL_MTLP 0x7ec1
5107 ++#define PCI_DEVICE_ID_INTEL_MTL 0x7e7e
5108 + #define PCI_DEVICE_ID_INTEL_TGL 0x9a15
5109 + #define PCI_DEVICE_ID_AMD_MR 0x163a
5110 +
5111 +@@ -421,6 +423,12 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
5112 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_RPLS),
5113 + (kernel_ulong_t) &dwc3_pci_intel_swnode, },
5114 +
5115 ++ { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTLP),
5116 ++ (kernel_ulong_t) &dwc3_pci_intel_swnode, },
5117 ++
5118 ++ { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTL),
5119 ++ (kernel_ulong_t) &dwc3_pci_intel_swnode, },
5120 ++
5121 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TGL),
5122 + (kernel_ulong_t) &dwc3_pci_intel_swnode, },
5123 +
5124 +diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
5125 +index a0c883f19a417..836049887ac83 100644
5126 +--- a/drivers/usb/dwc3/gadget.c
5127 ++++ b/drivers/usb/dwc3/gadget.c
5128 +@@ -3229,6 +3229,7 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
5129 + const struct dwc3_event_depevt *event,
5130 + struct dwc3_request *req, int status)
5131 + {
5132 ++ int request_status;
5133 + int ret;
5134 +
5135 + if (req->request.num_mapped_sgs)
5136 +@@ -3249,7 +3250,35 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
5137 + req->needs_extra_trb = false;
5138 + }
5139 +
5140 +- dwc3_gadget_giveback(dep, req, status);
5141 ++ /*
5142 ++ * The event status only reflects the status of the TRB with IOC set.
5143 ++ * For the requests that don't set interrupt on completion, the driver
5144 ++ * needs to check and return the status of the completed TRBs associated
5145 ++ * with the request. Use the status of the last TRB of the request.
5146 ++ */
5147 ++ if (req->request.no_interrupt) {
5148 ++ struct dwc3_trb *trb;
5149 ++
5150 ++ trb = dwc3_ep_prev_trb(dep, dep->trb_dequeue);
5151 ++ switch (DWC3_TRB_SIZE_TRBSTS(trb->size)) {
5152 ++ case DWC3_TRBSTS_MISSED_ISOC:
5153 ++ /* Isoc endpoint only */
5154 ++ request_status = -EXDEV;
5155 ++ break;
5156 ++ case DWC3_TRB_STS_XFER_IN_PROG:
5157 ++ /* Applicable when End Transfer with ForceRM=0 */
5158 ++ case DWC3_TRBSTS_SETUP_PENDING:
5159 ++ /* Control endpoint only */
5160 ++ case DWC3_TRBSTS_OK:
5161 ++ default:
5162 ++ request_status = 0;
5163 ++ break;
5164 ++ }
5165 ++ } else {
5166 ++ request_status = status;
5167 ++ }
5168 ++
5169 ++ dwc3_gadget_giveback(dep, req, request_status);
5170 +
5171 + out:
5172 + return ret;
5173 +diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
5174 +index d4a678c0806e3..34d45525be1b5 100644
5175 +--- a/drivers/usb/gadget/configfs.c
5176 ++++ b/drivers/usb/gadget/configfs.c
5177 +@@ -1434,6 +1434,8 @@ static void configfs_composite_unbind(struct usb_gadget *gadget)
5178 + usb_ep_autoconfig_reset(cdev->gadget);
5179 + spin_lock_irqsave(&gi->spinlock, flags);
5180 + cdev->gadget = NULL;
5181 ++ cdev->deactivations = 0;
5182 ++ gadget->deactivated = false;
5183 + set_gadget_data(gadget, NULL);
5184 + spin_unlock_irqrestore(&gi->spinlock, flags);
5185 + }
5186 +diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c
5187 +index d852ac9e47e72..2cda982f37650 100644
5188 +--- a/drivers/usb/gadget/function/uvc_queue.c
5189 ++++ b/drivers/usb/gadget/function/uvc_queue.c
5190 +@@ -264,6 +264,8 @@ void uvcg_queue_cancel(struct uvc_video_queue *queue, int disconnect)
5191 + buf->state = UVC_BUF_STATE_ERROR;
5192 + vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_ERROR);
5193 + }
5194 ++ queue->buf_used = 0;
5195 ++
5196 + /* This must be protected by the irqlock spinlock to avoid race
5197 + * conditions between uvc_queue_buffer and the disconnection event that
5198 + * could result in an interruptible wait in uvc_dequeue_buffer. Do not
5199 +diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
5200 +index 1e7dc130c39a6..f65f1ba2b5929 100644
5201 +--- a/drivers/usb/host/xhci-hub.c
5202 ++++ b/drivers/usb/host/xhci-hub.c
5203 +@@ -1434,7 +1434,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
5204 + }
5205 + spin_unlock_irqrestore(&xhci->lock, flags);
5206 + if (!wait_for_completion_timeout(&bus_state->u3exit_done[wIndex],
5207 +- msecs_to_jiffies(100)))
5208 ++ msecs_to_jiffies(500)))
5209 + xhci_dbg(xhci, "missing U0 port change event for port %d-%d\n",
5210 + hcd->self.busnum, wIndex + 1);
5211 + spin_lock_irqsave(&xhci->lock, flags);
5212 +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
5213 +index 5c351970cdf1c..d7e0e6ebf0800 100644
5214 +--- a/drivers/usb/host/xhci-pci.c
5215 ++++ b/drivers/usb/host/xhci-pci.c
5216 +@@ -59,6 +59,7 @@
5217 + #define PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI 0x9a13
5218 + #define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI 0x1138
5219 + #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI 0x461e
5220 ++#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI 0x51ed
5221 +
5222 + #define PCI_DEVICE_ID_AMD_RENOIR_XHCI 0x1639
5223 + #define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9
5224 +@@ -266,7 +267,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
5225 + pdev->device == PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI ||
5226 + pdev->device == PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI ||
5227 + pdev->device == PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI ||
5228 +- pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI))
5229 ++ pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI ||
5230 ++ pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI))
5231 + xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW;
5232 +
5233 + if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
5234 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
5235 +index d0b6806275e01..f9707997969d4 100644
5236 +--- a/drivers/usb/host/xhci-ring.c
5237 ++++ b/drivers/usb/host/xhci-ring.c
5238 +@@ -3141,6 +3141,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
5239 + if (event_loop++ < TRBS_PER_SEGMENT / 2)
5240 + continue;
5241 + xhci_update_erst_dequeue(xhci, event_ring_deq);
5242 ++ event_ring_deq = xhci->event_ring->dequeue;
5243 +
5244 + /* ring is half-full, force isoc trbs to interrupt more often */
5245 + if (xhci->isoc_bei_interval > AVOID_BEI_INTERVAL_MIN)
5246 +diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
5247 +index c8af2cd2216d6..996958a6565c3 100644
5248 +--- a/drivers/usb/host/xhci-tegra.c
5249 ++++ b/drivers/usb/host/xhci-tegra.c
5250 +@@ -1034,13 +1034,13 @@ static int tegra_xusb_unpowergate_partitions(struct tegra_xusb *tegra)
5251 + int rc;
5252 +
5253 + if (tegra->use_genpd) {
5254 +- rc = pm_runtime_get_sync(tegra->genpd_dev_ss);
5255 ++ rc = pm_runtime_resume_and_get(tegra->genpd_dev_ss);
5256 + if (rc < 0) {
5257 + dev_err(dev, "failed to enable XUSB SS partition\n");
5258 + return rc;
5259 + }
5260 +
5261 +- rc = pm_runtime_get_sync(tegra->genpd_dev_host);
5262 ++ rc = pm_runtime_resume_and_get(tegra->genpd_dev_host);
5263 + if (rc < 0) {
5264 + dev_err(dev, "failed to enable XUSB Host partition\n");
5265 + pm_runtime_put_sync(tegra->genpd_dev_ss);
5266 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
5267 +index 7d1ad8d654cbb..2b78ed3233433 100644
5268 +--- a/drivers/usb/host/xhci.c
5269 ++++ b/drivers/usb/host/xhci.c
5270 +@@ -778,6 +778,17 @@ void xhci_shutdown(struct usb_hcd *hcd)
5271 + if (xhci->quirks & XHCI_SPURIOUS_REBOOT)
5272 + usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
5273 +
5274 ++ /* Don't poll the roothubs after shutdown. */
5275 ++ xhci_dbg(xhci, "%s: stopping usb%d port polling.\n",
5276 ++ __func__, hcd->self.busnum);
5277 ++ clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
5278 ++ del_timer_sync(&hcd->rh_timer);
5279 ++
5280 ++ if (xhci->shared_hcd) {
5281 ++ clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
5282 ++ del_timer_sync(&xhci->shared_hcd->rh_timer);
5283 ++ }
5284 ++
5285 + spin_lock_irq(&xhci->lock);
5286 + xhci_halt(xhci);
5287 + /* Workaround for spurious wakeups at shutdown with HSW */
5288 +diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
5289 +index 748139d262633..0be8efcda15d5 100644
5290 +--- a/drivers/usb/misc/uss720.c
5291 ++++ b/drivers/usb/misc/uss720.c
5292 +@@ -71,6 +71,7 @@ static void destroy_priv(struct kref *kref)
5293 +
5294 + dev_dbg(&priv->usbdev->dev, "destroying priv datastructure\n");
5295 + usb_put_dev(priv->usbdev);
5296 ++ priv->usbdev = NULL;
5297 + kfree(priv);
5298 + }
5299 +
5300 +@@ -736,7 +737,6 @@ static int uss720_probe(struct usb_interface *intf,
5301 + parport_announce_port(pp);
5302 +
5303 + usb_set_intfdata(intf, pp);
5304 +- usb_put_dev(usbdev);
5305 + return 0;
5306 +
5307 + probe_abort:
5308 +@@ -754,7 +754,6 @@ static void uss720_disconnect(struct usb_interface *intf)
5309 + usb_set_intfdata(intf, NULL);
5310 + if (pp) {
5311 + priv = pp->private_data;
5312 +- priv->usbdev = NULL;
5313 + priv->pp = NULL;
5314 + dev_dbg(&intf->dev, "parport_remove_port\n");
5315 + parport_remove_port(pp);
5316 +diff --git a/drivers/usb/mtu3/mtu3_dr.c b/drivers/usb/mtu3/mtu3_dr.c
5317 +index a6b04831b20bf..9b8aded3d95e9 100644
5318 +--- a/drivers/usb/mtu3/mtu3_dr.c
5319 ++++ b/drivers/usb/mtu3/mtu3_dr.c
5320 +@@ -21,10 +21,8 @@ static inline struct ssusb_mtk *otg_sx_to_ssusb(struct otg_switch_mtk *otg_sx)
5321 +
5322 + static void toggle_opstate(struct ssusb_mtk *ssusb)
5323 + {
5324 +- if (!ssusb->otg_switch.is_u3_drd) {
5325 +- mtu3_setbits(ssusb->mac_base, U3D_DEVICE_CONTROL, DC_SESSION);
5326 +- mtu3_setbits(ssusb->mac_base, U3D_POWER_MANAGEMENT, SOFT_CONN);
5327 +- }
5328 ++ mtu3_setbits(ssusb->mac_base, U3D_DEVICE_CONTROL, DC_SESSION);
5329 ++ mtu3_setbits(ssusb->mac_base, U3D_POWER_MANAGEMENT, SOFT_CONN);
5330 + }
5331 +
5332 + /* only port0 supports dual-role mode */
5333 +diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
5334 +index 661a229c105dd..34b9f81401871 100644
5335 +--- a/drivers/usb/phy/phy-generic.c
5336 ++++ b/drivers/usb/phy/phy-generic.c
5337 +@@ -268,6 +268,13 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop)
5338 + return -EPROBE_DEFER;
5339 + }
5340 +
5341 ++ nop->vbus_draw = devm_regulator_get_exclusive(dev, "vbus");
5342 ++ if (PTR_ERR(nop->vbus_draw) == -ENODEV)
5343 ++ nop->vbus_draw = NULL;
5344 ++ if (IS_ERR(nop->vbus_draw))
5345 ++ return dev_err_probe(dev, PTR_ERR(nop->vbus_draw),
5346 ++ "could not get vbus regulator\n");
5347 ++
5348 + nop->dev = dev;
5349 + nop->phy.dev = nop->dev;
5350 + nop->phy.label = "nop-xceiv";
5351 +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
5352 +index a27f7efcec6a8..c374620a486f0 100644
5353 +--- a/drivers/usb/serial/cp210x.c
5354 ++++ b/drivers/usb/serial/cp210x.c
5355 +@@ -194,6 +194,8 @@ static const struct usb_device_id id_table[] = {
5356 + { USB_DEVICE(0x16DC, 0x0015) }, /* W-IE-NE-R Plein & Baus GmbH CML Control, Monitoring and Data Logger */
5357 + { USB_DEVICE(0x17A8, 0x0001) }, /* Kamstrup Optical Eye/3-wire */
5358 + { USB_DEVICE(0x17A8, 0x0005) }, /* Kamstrup M-Bus Master MultiPort 250D */
5359 ++ { USB_DEVICE(0x17A8, 0x0101) }, /* Kamstrup 868 MHz wM-Bus C-Mode Meter Reader (Int Ant) */
5360 ++ { USB_DEVICE(0x17A8, 0x0102) }, /* Kamstrup 868 MHz wM-Bus C-Mode Meter Reader (Ext Ant) */
5361 + { USB_DEVICE(0x17F4, 0xAAAA) }, /* Wavesense Jazz blood glucose meter */
5362 + { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
5363 + { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
5364 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
5365 +index e7755d9cfc61a..1364ce7f0abf0 100644
5366 +--- a/drivers/usb/serial/option.c
5367 ++++ b/drivers/usb/serial/option.c
5368 +@@ -432,6 +432,8 @@ static void option_instat_callback(struct urb *urb);
5369 + #define CINTERION_PRODUCT_CLS8 0x00b0
5370 + #define CINTERION_PRODUCT_MV31_MBIM 0x00b3
5371 + #define CINTERION_PRODUCT_MV31_RMNET 0x00b7
5372 ++#define CINTERION_PRODUCT_MV32_WA 0x00f1
5373 ++#define CINTERION_PRODUCT_MV32_WB 0x00f2
5374 +
5375 + /* Olivetti products */
5376 + #define OLIVETTI_VENDOR_ID 0x0b3c
5377 +@@ -1217,6 +1219,10 @@ static const struct usb_device_id option_ids[] = {
5378 + .driver_info = NCTRL(0) | RSVD(1) },
5379 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1056, 0xff), /* Telit FD980 */
5380 + .driver_info = NCTRL(2) | RSVD(3) },
5381 ++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1057, 0xff), /* Telit FN980 */
5382 ++ .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
5383 ++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1058, 0xff), /* Telit FN980 (PCIe) */
5384 ++ .driver_info = NCTRL(0) | RSVD(1) },
5385 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1060, 0xff), /* Telit LN920 (rmnet) */
5386 + .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
5387 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1061, 0xff), /* Telit LN920 (MBIM) */
5388 +@@ -1233,6 +1239,8 @@ static const struct usb_device_id option_ids[] = {
5389 + .driver_info = NCTRL(2) | RSVD(3) },
5390 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1073, 0xff), /* Telit FN990 (ECM) */
5391 + .driver_info = NCTRL(0) | RSVD(1) },
5392 ++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1075, 0xff), /* Telit FN990 (PCIe) */
5393 ++ .driver_info = RSVD(0) },
5394 + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910),
5395 + .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) },
5396 + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
5397 +@@ -1969,6 +1977,10 @@ static const struct usb_device_id option_ids[] = {
5398 + .driver_info = RSVD(3)},
5399 + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_MV31_RMNET, 0xff),
5400 + .driver_info = RSVD(0)},
5401 ++ { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_MV32_WA, 0xff),
5402 ++ .driver_info = RSVD(3)},
5403 ++ { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_MV32_WB, 0xff),
5404 ++ .driver_info = RSVD(3)},
5405 + { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100),
5406 + .driver_info = RSVD(4) },
5407 + { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD120),
5408 +diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
5409 +index da65d14c9ed5e..06aad0d727ddc 100644
5410 +--- a/drivers/usb/serial/whiteheat.c
5411 ++++ b/drivers/usb/serial/whiteheat.c
5412 +@@ -584,9 +584,8 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command,
5413 + switch (command) {
5414 + case WHITEHEAT_GET_DTR_RTS:
5415 + info = usb_get_serial_port_data(port);
5416 +- memcpy(&info->mcr, command_info->result_buffer,
5417 +- sizeof(struct whiteheat_dr_info));
5418 +- break;
5419 ++ info->mcr = command_info->result_buffer[0];
5420 ++ break;
5421 + }
5422 + }
5423 + exit:
5424 +diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
5425 +index f0c2fa19f3e0f..a6045aef0d04f 100644
5426 +--- a/drivers/usb/typec/ucsi/ucsi.c
5427 ++++ b/drivers/usb/typec/ucsi/ucsi.c
5428 +@@ -949,6 +949,8 @@ static int ucsi_dr_swap(struct typec_port *port, enum typec_data_role role)
5429 + role == TYPEC_HOST))
5430 + goto out_unlock;
5431 +
5432 ++ reinit_completion(&con->complete);
5433 ++
5434 + command = UCSI_SET_UOR | UCSI_CONNECTOR_NUMBER(con->num);
5435 + command |= UCSI_SET_UOR_ROLE(role);
5436 + command |= UCSI_SET_UOR_ACCEPT_ROLE_SWAPS;
5437 +@@ -956,14 +958,18 @@ static int ucsi_dr_swap(struct typec_port *port, enum typec_data_role role)
5438 + if (ret < 0)
5439 + goto out_unlock;
5440 +
5441 ++ mutex_unlock(&con->lock);
5442 ++
5443 + if (!wait_for_completion_timeout(&con->complete,
5444 +- msecs_to_jiffies(UCSI_SWAP_TIMEOUT_MS)))
5445 +- ret = -ETIMEDOUT;
5446 ++ msecs_to_jiffies(UCSI_SWAP_TIMEOUT_MS)))
5447 ++ return -ETIMEDOUT;
5448 ++
5449 ++ return 0;
5450 +
5451 + out_unlock:
5452 + mutex_unlock(&con->lock);
5453 +
5454 +- return ret < 0 ? ret : 0;
5455 ++ return ret;
5456 + }
5457 +
5458 + static int ucsi_pr_swap(struct typec_port *port, enum typec_role role)
5459 +@@ -985,6 +991,8 @@ static int ucsi_pr_swap(struct typec_port *port, enum typec_role role)
5460 + if (cur_role == role)
5461 + goto out_unlock;
5462 +
5463 ++ reinit_completion(&con->complete);
5464 ++
5465 + command = UCSI_SET_PDR | UCSI_CONNECTOR_NUMBER(con->num);
5466 + command |= UCSI_SET_PDR_ROLE(role);
5467 + command |= UCSI_SET_PDR_ACCEPT_ROLE_SWAPS;
5468 +@@ -992,11 +1000,13 @@ static int ucsi_pr_swap(struct typec_port *port, enum typec_role role)
5469 + if (ret < 0)
5470 + goto out_unlock;
5471 +
5472 ++ mutex_unlock(&con->lock);
5473 ++
5474 + if (!wait_for_completion_timeout(&con->complete,
5475 +- msecs_to_jiffies(UCSI_SWAP_TIMEOUT_MS))) {
5476 +- ret = -ETIMEDOUT;
5477 +- goto out_unlock;
5478 +- }
5479 ++ msecs_to_jiffies(UCSI_SWAP_TIMEOUT_MS)))
5480 ++ return -ETIMEDOUT;
5481 ++
5482 ++ mutex_lock(&con->lock);
5483 +
5484 + /* Something has gone wrong while swapping the role */
5485 + if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) !=
5486 +diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
5487 +index 90f48b71fd8f7..d9eec1b60e665 100644
5488 +--- a/drivers/video/fbdev/udlfb.c
5489 ++++ b/drivers/video/fbdev/udlfb.c
5490 +@@ -1649,8 +1649,9 @@ static int dlfb_usb_probe(struct usb_interface *intf,
5491 + const struct device_attribute *attr;
5492 + struct dlfb_data *dlfb;
5493 + struct fb_info *info;
5494 +- int retval = -ENOMEM;
5495 ++ int retval;
5496 + struct usb_device *usbdev = interface_to_usbdev(intf);
5497 ++ struct usb_endpoint_descriptor *out;
5498 +
5499 + /* usb initialization */
5500 + dlfb = kzalloc(sizeof(*dlfb), GFP_KERNEL);
5501 +@@ -1664,6 +1665,12 @@ static int dlfb_usb_probe(struct usb_interface *intf,
5502 + dlfb->udev = usb_get_dev(usbdev);
5503 + usb_set_intfdata(intf, dlfb);
5504 +
5505 ++ retval = usb_find_common_endpoints(intf->cur_altsetting, NULL, &out, NULL, NULL);
5506 ++ if (retval) {
5507 ++ dev_err(&intf->dev, "Device should have at lease 1 bulk endpoint!\n");
5508 ++ goto error;
5509 ++ }
5510 ++
5511 + dev_dbg(&intf->dev, "console enable=%d\n", console);
5512 + dev_dbg(&intf->dev, "fb_defio enable=%d\n", fb_defio);
5513 + dev_dbg(&intf->dev, "shadow enable=%d\n", shadow);
5514 +@@ -1673,6 +1680,7 @@ static int dlfb_usb_probe(struct usb_interface *intf,
5515 + if (!dlfb_parse_vendor_descriptor(dlfb, intf)) {
5516 + dev_err(&intf->dev,
5517 + "firmware not recognized, incompatible device?\n");
5518 ++ retval = -ENODEV;
5519 + goto error;
5520 + }
5521 +
5522 +@@ -1686,8 +1694,10 @@ static int dlfb_usb_probe(struct usb_interface *intf,
5523 +
5524 + /* allocates framebuffer driver structure, not framebuffer memory */
5525 + info = framebuffer_alloc(0, &dlfb->udev->dev);
5526 +- if (!info)
5527 ++ if (!info) {
5528 ++ retval = -ENOMEM;
5529 + goto error;
5530 ++ }
5531 +
5532 + dlfb->info = info;
5533 + info->par = dlfb;
5534 +diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
5535 +index ebb2d109e8bb2..1022dd383664a 100644
5536 +--- a/fs/btrfs/ctree.h
5537 ++++ b/fs/btrfs/ctree.h
5538 +@@ -1029,6 +1029,7 @@ struct btrfs_fs_info {
5539 + */
5540 + spinlock_t relocation_bg_lock;
5541 + u64 data_reloc_bg;
5542 ++ struct mutex zoned_data_reloc_io_lock;
5543 +
5544 + spinlock_t zone_active_bgs_lock;
5545 + struct list_head zone_active_bgs;
5546 +diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
5547 +index 62b9651ea6629..7f98d3744656a 100644
5548 +--- a/fs/btrfs/dev-replace.c
5549 ++++ b/fs/btrfs/dev-replace.c
5550 +@@ -730,7 +730,12 @@ static int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
5551 +
5552 + btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1);
5553 +
5554 +- /* Commit dev_replace state and reserve 1 item for it. */
5555 ++ /*
5556 ++ * Commit dev_replace state and reserve 1 item for it.
5557 ++ * This is crucial to ensure we won't miss copying extents for new block
5558 ++ * groups that are allocated after we started the device replace, and
5559 ++ * must be done after setting up the device replace state.
5560 ++ */
5561 + trans = btrfs_start_transaction(root, 1);
5562 + if (IS_ERR(trans)) {
5563 + ret = PTR_ERR(trans);
5564 +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
5565 +index b43f80c3bffd9..ed986c70cbc5e 100644
5566 +--- a/fs/btrfs/disk-io.c
5567 ++++ b/fs/btrfs/disk-io.c
5568 +@@ -3068,6 +3068,7 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info)
5569 + mutex_init(&fs_info->reloc_mutex);
5570 + mutex_init(&fs_info->delalloc_root_mutex);
5571 + mutex_init(&fs_info->zoned_meta_io_lock);
5572 ++ mutex_init(&fs_info->zoned_data_reloc_io_lock);
5573 + seqlock_init(&fs_info->profiles_lock);
5574 +
5575 + INIT_LIST_HEAD(&fs_info->dirty_cowonly_roots);
5576 +diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
5577 +index e93526d86a922..9b488a737f8ae 100644
5578 +--- a/fs/btrfs/extent_io.c
5579 ++++ b/fs/btrfs/extent_io.c
5580 +@@ -2657,6 +2657,7 @@ int btrfs_repair_one_sector(struct inode *inode,
5581 +
5582 + repair_bio = btrfs_bio_alloc(1);
5583 + repair_bbio = btrfs_bio(repair_bio);
5584 ++ repair_bbio->file_offset = start;
5585 + repair_bio->bi_opf = REQ_OP_READ;
5586 + repair_bio->bi_end_io = failed_bio->bi_end_io;
5587 + repair_bio->bi_iter.bi_sector = failrec->logical >> 9;
5588 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
5589 +index 9547088a93066..ecd305649e129 100644
5590 +--- a/fs/btrfs/inode.c
5591 ++++ b/fs/btrfs/inode.c
5592 +@@ -7789,8 +7789,6 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
5593 + const bool csum = !(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM);
5594 + struct bio_vec bvec;
5595 + struct bvec_iter iter;
5596 +- const u64 orig_file_offset = dip->file_offset;
5597 +- u64 start = orig_file_offset;
5598 + u32 bio_offset = 0;
5599 + blk_status_t err = BLK_STS_OK;
5600 +
5601 +@@ -7800,6 +7798,8 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
5602 + nr_sectors = BTRFS_BYTES_TO_BLKS(fs_info, bvec.bv_len);
5603 + pgoff = bvec.bv_offset;
5604 + for (i = 0; i < nr_sectors; i++) {
5605 ++ u64 start = bbio->file_offset + bio_offset;
5606 ++
5607 + ASSERT(pgoff < PAGE_SIZE);
5608 + if (uptodate &&
5609 + (!csum || !check_data_csum(inode, bbio,
5610 +@@ -7812,17 +7812,13 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
5611 + } else {
5612 + int ret;
5613 +
5614 +- ASSERT((start - orig_file_offset) < UINT_MAX);
5615 +- ret = btrfs_repair_one_sector(inode,
5616 +- &bbio->bio,
5617 +- start - orig_file_offset,
5618 +- bvec.bv_page, pgoff,
5619 ++ ret = btrfs_repair_one_sector(inode, &bbio->bio,
5620 ++ bio_offset, bvec.bv_page, pgoff,
5621 + start, bbio->mirror_num,
5622 + submit_dio_repair_bio);
5623 + if (ret)
5624 + err = errno_to_blk_status(ret);
5625 + }
5626 +- start += sectorsize;
5627 + ASSERT(bio_offset + sectorsize > bio_offset);
5628 + bio_offset += sectorsize;
5629 + pgoff += sectorsize;
5630 +@@ -7849,6 +7845,7 @@ static blk_status_t btrfs_submit_bio_start_direct_io(struct inode *inode,
5631 + static void btrfs_end_dio_bio(struct bio *bio)
5632 + {
5633 + struct btrfs_dio_private *dip = bio->bi_private;
5634 ++ struct btrfs_bio *bbio = btrfs_bio(bio);
5635 + blk_status_t err = bio->bi_status;
5636 +
5637 + if (err)
5638 +@@ -7859,12 +7856,12 @@ static void btrfs_end_dio_bio(struct bio *bio)
5639 + bio->bi_iter.bi_size, err);
5640 +
5641 + if (bio_op(bio) == REQ_OP_READ)
5642 +- err = btrfs_check_read_dio_bio(dip, btrfs_bio(bio), !err);
5643 ++ err = btrfs_check_read_dio_bio(dip, bbio, !err);
5644 +
5645 + if (err)
5646 + dip->dio_bio->bi_status = err;
5647 +
5648 +- btrfs_record_physical_zoned(dip->inode, dip->file_offset, bio);
5649 ++ btrfs_record_physical_zoned(dip->inode, bbio->file_offset, bio);
5650 +
5651 + bio_put(bio);
5652 + btrfs_dio_private_put(dip);
5653 +@@ -8025,6 +8022,7 @@ static void btrfs_submit_direct(const struct iomap_iter *iter,
5654 + bio = btrfs_bio_clone_partial(dio_bio, clone_offset, clone_len);
5655 + bio->bi_private = dip;
5656 + bio->bi_end_io = btrfs_end_dio_bio;
5657 ++ btrfs_bio(bio)->file_offset = file_offset;
5658 +
5659 + if (bio_op(bio) == REQ_OP_ZONE_APPEND) {
5660 + status = extract_ordered_extent(BTRFS_I(inode), bio,
5661 +diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
5662 +index 2e9a322773f28..5a223de90af8a 100644
5663 +--- a/fs/btrfs/scrub.c
5664 ++++ b/fs/btrfs/scrub.c
5665 +@@ -3699,6 +3699,31 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
5666 + if (!cache)
5667 + goto skip;
5668 +
5669 ++ ASSERT(cache->start <= chunk_offset);
5670 ++ /*
5671 ++ * We are using the commit root to search for device extents, so
5672 ++ * that means we could have found a device extent item from a
5673 ++ * block group that was deleted in the current transaction. The
5674 ++ * logical start offset of the deleted block group, stored at
5675 ++ * @chunk_offset, might be part of the logical address range of
5676 ++ * a new block group (which uses different physical extents).
5677 ++ * In this case btrfs_lookup_block_group() has returned the new
5678 ++ * block group, and its start address is less than @chunk_offset.
5679 ++ *
5680 ++ * We skip such new block groups, because it's pointless to
5681 ++ * process them, as we won't find their extents because we search
5682 ++ * for them using the commit root of the extent tree. For a device
5683 ++ * replace it's also fine to skip it, we won't miss copying them
5684 ++ * to the target device because we have the write duplication
5685 ++ * setup through the regular write path (by btrfs_map_block()),
5686 ++ * and we have committed a transaction when we started the device
5687 ++ * replace, right after setting up the device replace state.
5688 ++ */
5689 ++ if (cache->start < chunk_offset) {
5690 ++ btrfs_put_block_group(cache);
5691 ++ goto skip;
5692 ++ }
5693 ++
5694 + if (sctx->is_dev_replace && btrfs_is_zoned(fs_info)) {
5695 + spin_lock(&cache->lock);
5696 + if (!cache->to_copy) {
5697 +@@ -3822,7 +3847,6 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
5698 + dev_replace->item_needs_writeback = 1;
5699 + up_write(&dev_replace->rwsem);
5700 +
5701 +- ASSERT(cache->start == chunk_offset);
5702 + ret = scrub_chunk(sctx, cache, scrub_dev, found_key.offset,
5703 + dev_extent_len);
5704 +
5705 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
5706 +index 6bc8834ac8f7d..7a0bfa5bedb95 100644
5707 +--- a/fs/btrfs/tree-log.c
5708 ++++ b/fs/btrfs/tree-log.c
5709 +@@ -3225,6 +3225,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
5710 + ret = btrfs_alloc_log_tree_node(trans, log_root_tree);
5711 + if (ret) {
5712 + mutex_unlock(&fs_info->tree_root->log_mutex);
5713 ++ blk_finish_plug(&plug);
5714 + goto out;
5715 + }
5716 + }
5717 +diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
5718 +index 005c9e2a491a1..c22148bebc2f5 100644
5719 +--- a/fs/btrfs/volumes.h
5720 ++++ b/fs/btrfs/volumes.h
5721 +@@ -323,6 +323,9 @@ struct btrfs_fs_devices {
5722 + struct btrfs_bio {
5723 + unsigned int mirror_num;
5724 +
5725 ++ /* for direct I/O */
5726 ++ u64 file_offset;
5727 ++
5728 + /* @device is for stripe IO submission. */
5729 + struct btrfs_device *device;
5730 + u8 *csum;
5731 +diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h
5732 +index cbf016a7bb5dd..6dee76248cb4d 100644
5733 +--- a/fs/btrfs/zoned.h
5734 ++++ b/fs/btrfs/zoned.h
5735 +@@ -359,7 +359,7 @@ static inline void btrfs_zoned_data_reloc_lock(struct btrfs_inode *inode)
5736 + struct btrfs_root *root = inode->root;
5737 +
5738 + if (btrfs_is_data_reloc_root(root) && btrfs_is_zoned(root->fs_info))
5739 +- btrfs_inode_lock(&inode->vfs_inode, 0);
5740 ++ mutex_lock(&root->fs_info->zoned_data_reloc_io_lock);
5741 + }
5742 +
5743 + static inline void btrfs_zoned_data_reloc_unlock(struct btrfs_inode *inode)
5744 +@@ -367,7 +367,7 @@ static inline void btrfs_zoned_data_reloc_unlock(struct btrfs_inode *inode)
5745 + struct btrfs_root *root = inode->root;
5746 +
5747 + if (btrfs_is_data_reloc_root(root) && btrfs_is_zoned(root->fs_info))
5748 +- btrfs_inode_unlock(&inode->vfs_inode, 0);
5749 ++ mutex_unlock(&root->fs_info->zoned_data_reloc_io_lock);
5750 + }
5751 +
5752 + #endif
5753 +diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
5754 +index b472cd066d1c8..ca7b23dded4c0 100644
5755 +--- a/fs/ceph/caps.c
5756 ++++ b/fs/ceph/caps.c
5757 +@@ -2267,6 +2267,8 @@ retry:
5758 + list_for_each_entry(req, &ci->i_unsafe_dirops,
5759 + r_unsafe_dir_item) {
5760 + s = req->r_session;
5761 ++ if (!s)
5762 ++ continue;
5763 + if (unlikely(s->s_mds >= max_sessions)) {
5764 + spin_unlock(&ci->i_unsafe_lock);
5765 + for (i = 0; i < max_sessions; i++) {
5766 +@@ -2287,6 +2289,8 @@ retry:
5767 + list_for_each_entry(req, &ci->i_unsafe_iops,
5768 + r_unsafe_target_item) {
5769 + s = req->r_session;
5770 ++ if (!s)
5771 ++ continue;
5772 + if (unlikely(s->s_mds >= max_sessions)) {
5773 + spin_unlock(&ci->i_unsafe_lock);
5774 + for (i = 0; i < max_sessions; i++) {
5775 +diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
5776 +index 5d120cd8bc78f..13080d6a140b3 100644
5777 +--- a/fs/cifs/smb2ops.c
5778 ++++ b/fs/cifs/smb2ops.c
5779 +@@ -1861,9 +1861,17 @@ smb2_copychunk_range(const unsigned int xid,
5780 + int chunks_copied = 0;
5781 + bool chunk_sizes_updated = false;
5782 + ssize_t bytes_written, total_bytes_written = 0;
5783 ++ struct inode *inode;
5784 +
5785 + pcchunk = kmalloc(sizeof(struct copychunk_ioctl), GFP_KERNEL);
5786 +
5787 ++ /*
5788 ++ * We need to flush all unwritten data before we can send the
5789 ++ * copychunk ioctl to the server.
5790 ++ */
5791 ++ inode = d_inode(trgtfile->dentry);
5792 ++ filemap_write_and_wait(inode->i_mapping);
5793 ++
5794 + if (pcchunk == NULL)
5795 + return -ENOMEM;
5796 +
5797 +diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
5798 +index 423bc1a61da5c..a1b48bcafe632 100644
5799 +--- a/fs/erofs/zdata.c
5800 ++++ b/fs/erofs/zdata.c
5801 +@@ -1073,12 +1073,9 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io,
5802 +
5803 + /* wake up the caller thread for sync decompression */
5804 + if (sync) {
5805 +- unsigned long flags;
5806 +-
5807 +- spin_lock_irqsave(&io->u.wait.lock, flags);
5808 + if (!atomic_add_return(bios, &io->pending_bios))
5809 +- wake_up_locked(&io->u.wait);
5810 +- spin_unlock_irqrestore(&io->u.wait.lock, flags);
5811 ++ complete(&io->u.done);
5812 ++
5813 + return;
5814 + }
5815 +
5816 +@@ -1224,7 +1221,7 @@ jobqueue_init(struct super_block *sb,
5817 + } else {
5818 + fg_out:
5819 + q = fgq;
5820 +- init_waitqueue_head(&fgq->u.wait);
5821 ++ init_completion(&fgq->u.done);
5822 + atomic_set(&fgq->pending_bios, 0);
5823 + }
5824 + q->sb = sb;
5825 +@@ -1428,8 +1425,7 @@ static void z_erofs_runqueue(struct super_block *sb,
5826 + return;
5827 +
5828 + /* wait until all bios are completed */
5829 +- io_wait_event(io[JQ_SUBMIT].u.wait,
5830 +- !atomic_read(&io[JQ_SUBMIT].pending_bios));
5831 ++ wait_for_completion_io(&io[JQ_SUBMIT].u.done);
5832 +
5833 + /* handle synchronous decompress queue in the caller context */
5834 + z_erofs_decompress_queue(&io[JQ_SUBMIT], pagepool);
5835 +diff --git a/fs/erofs/zdata.h b/fs/erofs/zdata.h
5836 +index e043216b545f1..800b11c53f574 100644
5837 +--- a/fs/erofs/zdata.h
5838 ++++ b/fs/erofs/zdata.h
5839 +@@ -97,7 +97,7 @@ struct z_erofs_decompressqueue {
5840 + z_erofs_next_pcluster_t head;
5841 +
5842 + union {
5843 +- wait_queue_head_t wait;
5844 ++ struct completion done;
5845 + struct work_struct work;
5846 + } u;
5847 + };
5848 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
5849 +index ba6530c2d2711..fe30f483c59f0 100644
5850 +--- a/fs/ext4/super.c
5851 ++++ b/fs/ext4/super.c
5852 +@@ -1199,20 +1199,25 @@ static void ext4_put_super(struct super_block *sb)
5853 + int aborted = 0;
5854 + int i, err;
5855 +
5856 +- ext4_unregister_li_request(sb);
5857 +- ext4_quota_off_umount(sb);
5858 +-
5859 +- flush_work(&sbi->s_error_work);
5860 +- destroy_workqueue(sbi->rsv_conversion_wq);
5861 +- ext4_release_orphan_info(sb);
5862 +-
5863 + /*
5864 + * Unregister sysfs before destroying jbd2 journal.
5865 + * Since we could still access attr_journal_task attribute via sysfs
5866 + * path which could have sbi->s_journal->j_task as NULL
5867 ++ * Unregister sysfs before flush sbi->s_error_work.
5868 ++ * Since user may read /proc/fs/ext4/xx/mb_groups during umount, If
5869 ++ * read metadata verify failed then will queue error work.
5870 ++ * flush_stashed_error_work will call start_this_handle may trigger
5871 ++ * BUG_ON.
5872 + */
5873 + ext4_unregister_sysfs(sb);
5874 +
5875 ++ ext4_unregister_li_request(sb);
5876 ++ ext4_quota_off_umount(sb);
5877 ++
5878 ++ flush_work(&sbi->s_error_work);
5879 ++ destroy_workqueue(sbi->rsv_conversion_wq);
5880 ++ ext4_release_orphan_info(sb);
5881 ++
5882 + if (sbi->s_journal) {
5883 + aborted = is_journal_aborted(sbi->s_journal);
5884 + err = jbd2_journal_destroy(sbi->s_journal);
5885 +diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
5886 +index 71f232dcf3c20..83639238a1fe9 100644
5887 +--- a/fs/f2fs/inode.c
5888 ++++ b/fs/f2fs/inode.c
5889 +@@ -550,7 +550,8 @@ make_now:
5890 + }
5891 + f2fs_set_inode_flags(inode);
5892 +
5893 +- if (file_should_truncate(inode)) {
5894 ++ if (file_should_truncate(inode) &&
5895 ++ !is_sbi_flag_set(sbi, SBI_POR_DOING)) {
5896 + ret = f2fs_truncate(inode);
5897 + if (ret)
5898 + goto bad_inode;
5899 +diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
5900 +index b53ad18e5ccbf..fa071d738c78e 100644
5901 +--- a/fs/gfs2/file.c
5902 ++++ b/fs/gfs2/file.c
5903 +@@ -851,9 +851,9 @@ retry_under_glock:
5904 + leftover = fault_in_iov_iter_writeable(to, window_size);
5905 + gfs2_holder_disallow_demote(gh);
5906 + if (leftover != window_size) {
5907 +- if (!gfs2_holder_queued(gh))
5908 +- goto retry;
5909 +- goto retry_under_glock;
5910 ++ if (gfs2_holder_queued(gh))
5911 ++ goto retry_under_glock;
5912 ++ goto retry;
5913 + }
5914 + }
5915 + if (gfs2_holder_queued(gh))
5916 +@@ -920,9 +920,9 @@ retry_under_glock:
5917 + leftover = fault_in_iov_iter_readable(from, window_size);
5918 + gfs2_holder_disallow_demote(gh);
5919 + if (leftover != window_size) {
5920 +- if (!gfs2_holder_queued(gh))
5921 +- goto retry;
5922 +- goto retry_under_glock;
5923 ++ if (gfs2_holder_queued(gh))
5924 ++ goto retry_under_glock;
5925 ++ goto retry;
5926 + }
5927 + }
5928 + out:
5929 +@@ -989,12 +989,9 @@ retry_under_glock:
5930 + leftover = fault_in_iov_iter_writeable(to, window_size);
5931 + gfs2_holder_disallow_demote(&gh);
5932 + if (leftover != window_size) {
5933 +- if (!gfs2_holder_queued(&gh)) {
5934 +- if (written)
5935 +- goto out_uninit;
5936 +- goto retry;
5937 +- }
5938 +- goto retry_under_glock;
5939 ++ if (gfs2_holder_queued(&gh))
5940 ++ goto retry_under_glock;
5941 ++ goto retry;
5942 + }
5943 + }
5944 + if (gfs2_holder_queued(&gh))
5945 +@@ -1068,12 +1065,9 @@ retry_under_glock:
5946 + gfs2_holder_disallow_demote(gh);
5947 + if (leftover != window_size) {
5948 + from->count = min(from->count, window_size - leftover);
5949 +- if (!gfs2_holder_queued(gh)) {
5950 +- if (read)
5951 +- goto out_uninit;
5952 +- goto retry;
5953 +- }
5954 +- goto retry_under_glock;
5955 ++ if (gfs2_holder_queued(gh))
5956 ++ goto retry_under_glock;
5957 ++ goto retry;
5958 + }
5959 + }
5960 + out_unlock:
5961 +diff --git a/fs/io_uring.c b/fs/io_uring.c
5962 +index fbba8342172a0..87df379120551 100644
5963 +--- a/fs/io_uring.c
5964 ++++ b/fs/io_uring.c
5965 +@@ -3584,6 +3584,7 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)
5966 + if (!(kiocb->ki_flags & IOCB_DIRECT) || !file->f_op->iopoll)
5967 + return -EOPNOTSUPP;
5968 +
5969 ++ kiocb->private = NULL;
5970 + kiocb->ki_flags |= IOCB_HIPRI | IOCB_ALLOC_CACHE;
5971 + kiocb->ki_complete = io_complete_rw_iopoll;
5972 + req->iopoll_completed = 0;
5973 +@@ -4890,6 +4891,8 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
5974 +
5975 + if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
5976 + return -EINVAL;
5977 ++ if (unlikely(sqe->addr2 || sqe->file_index))
5978 ++ return -EINVAL;
5979 +
5980 + sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
5981 + sr->len = READ_ONCE(sqe->len);
5982 +@@ -5101,6 +5104,8 @@ static int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
5983 +
5984 + if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
5985 + return -EINVAL;
5986 ++ if (unlikely(sqe->addr2 || sqe->file_index))
5987 ++ return -EINVAL;
5988 +
5989 + sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
5990 + sr->len = READ_ONCE(sqe->len);
5991 +diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
5992 +index e6d9772ddb4ca..4096953390b44 100644
5993 +--- a/fs/kernfs/dir.c
5994 ++++ b/fs/kernfs/dir.c
5995 +@@ -1397,7 +1397,12 @@ static void __kernfs_remove(struct kernfs_node *kn)
5996 + */
5997 + void kernfs_remove(struct kernfs_node *kn)
5998 + {
5999 +- struct kernfs_root *root = kernfs_root(kn);
6000 ++ struct kernfs_root *root;
6001 ++
6002 ++ if (!kn)
6003 ++ return;
6004 ++
6005 ++ root = kernfs_root(kn);
6006 +
6007 + down_write(&root->kernfs_rwsem);
6008 + __kernfs_remove(kn);
6009 +diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
6010 +index 67e8e28e3fc35..83ffa73c93484 100644
6011 +--- a/fs/ksmbd/smb2pdu.c
6012 ++++ b/fs/ksmbd/smb2pdu.c
6013 +@@ -11,6 +11,7 @@
6014 + #include <linux/statfs.h>
6015 + #include <linux/ethtool.h>
6016 + #include <linux/falloc.h>
6017 ++#include <linux/mount.h>
6018 +
6019 + #include "glob.h"
6020 + #include "smbfsctl.h"
6021 +@@ -5005,15 +5006,17 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
6022 + case FS_SECTOR_SIZE_INFORMATION:
6023 + {
6024 + struct smb3_fs_ss_info *info;
6025 ++ unsigned int sector_size =
6026 ++ min_t(unsigned int, path.mnt->mnt_sb->s_blocksize, 4096);
6027 +
6028 + info = (struct smb3_fs_ss_info *)(rsp->Buffer);
6029 +
6030 +- info->LogicalBytesPerSector = cpu_to_le32(stfs.f_bsize);
6031 ++ info->LogicalBytesPerSector = cpu_to_le32(sector_size);
6032 + info->PhysicalBytesPerSectorForAtomicity =
6033 +- cpu_to_le32(stfs.f_bsize);
6034 +- info->PhysicalBytesPerSectorForPerf = cpu_to_le32(stfs.f_bsize);
6035 ++ cpu_to_le32(sector_size);
6036 ++ info->PhysicalBytesPerSectorForPerf = cpu_to_le32(sector_size);
6037 + info->FSEffPhysicalBytesPerSectorForAtomicity =
6038 +- cpu_to_le32(stfs.f_bsize);
6039 ++ cpu_to_le32(sector_size);
6040 + info->Flags = cpu_to_le32(SSINFO_FLAGS_ALIGNED_DEVICE |
6041 + SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE);
6042 + info->ByteOffsetForSectorAlignment = 0;
6043 +@@ -5771,8 +5774,10 @@ static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp,
6044 + if (parent_fp) {
6045 + if (parent_fp->daccess & FILE_DELETE_LE) {
6046 + pr_err("parent dir is opened with delete access\n");
6047 ++ ksmbd_fd_put(work, parent_fp);
6048 + return -ESHARE;
6049 + }
6050 ++ ksmbd_fd_put(work, parent_fp);
6051 + }
6052 + next:
6053 + return smb2_rename(work, fp, user_ns, rename_info,
6054 +diff --git a/fs/ksmbd/vfs_cache.c b/fs/ksmbd/vfs_cache.c
6055 +index 29c1db66bd0f7..8b873d92d7854 100644
6056 +--- a/fs/ksmbd/vfs_cache.c
6057 ++++ b/fs/ksmbd/vfs_cache.c
6058 +@@ -497,6 +497,7 @@ struct ksmbd_file *ksmbd_lookup_fd_inode(struct inode *inode)
6059 + list_for_each_entry(lfp, &ci->m_fp_list, node) {
6060 + if (inode == file_inode(lfp->filp)) {
6061 + atomic_dec(&ci->m_count);
6062 ++ lfp = ksmbd_fp_get(lfp);
6063 + read_unlock(&ci->m_lock);
6064 + return lfp;
6065 + }
6066 +diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
6067 +index b76dfb310ab65..63e09caf19b82 100644
6068 +--- a/fs/zonefs/super.c
6069 ++++ b/fs/zonefs/super.c
6070 +@@ -35,6 +35,17 @@ static inline int zonefs_zone_mgmt(struct inode *inode,
6071 +
6072 + lockdep_assert_held(&zi->i_truncate_mutex);
6073 +
6074 ++ /*
6075 ++ * With ZNS drives, closing an explicitly open zone that has not been
6076 ++ * written will change the zone state to "closed", that is, the zone
6077 ++ * will remain active. Since this can then cause failure of explicit
6078 ++ * open operation on other zones if the drive active zone resources
6079 ++ * are exceeded, make sure that the zone does not remain active by
6080 ++ * resetting it.
6081 ++ */
6082 ++ if (op == REQ_OP_ZONE_CLOSE && !zi->i_wpoffset)
6083 ++ op = REQ_OP_ZONE_RESET;
6084 ++
6085 + trace_zonefs_zone_mgmt(inode, op);
6086 + ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector,
6087 + zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS);
6088 +@@ -1144,6 +1155,7 @@ static struct inode *zonefs_alloc_inode(struct super_block *sb)
6089 + inode_init_once(&zi->i_vnode);
6090 + mutex_init(&zi->i_truncate_mutex);
6091 + zi->i_wr_refcnt = 0;
6092 ++ zi->i_flags = 0;
6093 +
6094 + return &zi->i_vnode;
6095 + }
6096 +@@ -1295,12 +1307,13 @@ static void zonefs_init_dir_inode(struct inode *parent, struct inode *inode,
6097 + inc_nlink(parent);
6098 + }
6099 +
6100 +-static void zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
6101 +- enum zonefs_ztype type)
6102 ++static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
6103 ++ enum zonefs_ztype type)
6104 + {
6105 + struct super_block *sb = inode->i_sb;
6106 + struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
6107 + struct zonefs_inode_info *zi = ZONEFS_I(inode);
6108 ++ int ret = 0;
6109 +
6110 + inode->i_ino = zone->start >> sbi->s_zone_sectors_shift;
6111 + inode->i_mode = S_IFREG | sbi->s_perm;
6112 +@@ -1325,6 +1338,22 @@ static void zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
6113 + sb->s_maxbytes = max(zi->i_max_size, sb->s_maxbytes);
6114 + sbi->s_blocks += zi->i_max_size >> sb->s_blocksize_bits;
6115 + sbi->s_used_blocks += zi->i_wpoffset >> sb->s_blocksize_bits;
6116 ++
6117 ++ /*
6118 ++ * For sequential zones, make sure that any open zone is closed first
6119 ++ * to ensure that the initial number of open zones is 0, in sync with
6120 ++ * the open zone accounting done when the mount option
6121 ++ * ZONEFS_MNTOPT_EXPLICIT_OPEN is used.
6122 ++ */
6123 ++ if (type == ZONEFS_ZTYPE_SEQ &&
6124 ++ (zone->cond == BLK_ZONE_COND_IMP_OPEN ||
6125 ++ zone->cond == BLK_ZONE_COND_EXP_OPEN)) {
6126 ++ mutex_lock(&zi->i_truncate_mutex);
6127 ++ ret = zonefs_zone_mgmt(inode, REQ_OP_ZONE_CLOSE);
6128 ++ mutex_unlock(&zi->i_truncate_mutex);
6129 ++ }
6130 ++
6131 ++ return ret;
6132 + }
6133 +
6134 + static struct dentry *zonefs_create_inode(struct dentry *parent,
6135 +@@ -1334,6 +1363,7 @@ static struct dentry *zonefs_create_inode(struct dentry *parent,
6136 + struct inode *dir = d_inode(parent);
6137 + struct dentry *dentry;
6138 + struct inode *inode;
6139 ++ int ret;
6140 +
6141 + dentry = d_alloc_name(parent, name);
6142 + if (!dentry)
6143 +@@ -1344,10 +1374,16 @@ static struct dentry *zonefs_create_inode(struct dentry *parent,
6144 + goto dput;
6145 +
6146 + inode->i_ctime = inode->i_mtime = inode->i_atime = dir->i_ctime;
6147 +- if (zone)
6148 +- zonefs_init_file_inode(inode, zone, type);
6149 +- else
6150 ++ if (zone) {
6151 ++ ret = zonefs_init_file_inode(inode, zone, type);
6152 ++ if (ret) {
6153 ++ iput(inode);
6154 ++ goto dput;
6155 ++ }
6156 ++ } else {
6157 + zonefs_init_dir_inode(dir, inode, type);
6158 ++ }
6159 ++
6160 + d_add(dentry, inode);
6161 + dir->i_size++;
6162 +
6163 +diff --git a/include/linux/kernel.h b/include/linux/kernel.h
6164 +index 33f47a9965132..a56354bccf292 100644
6165 +--- a/include/linux/kernel.h
6166 ++++ b/include/linux/kernel.h
6167 +@@ -280,7 +280,7 @@ static inline char *hex_byte_pack_upper(char *buf, u8 byte)
6168 + return buf;
6169 + }
6170 +
6171 +-extern int hex_to_bin(char ch);
6172 ++extern int hex_to_bin(unsigned char ch);
6173 + extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
6174 + extern char *bin2hex(char *dst, const void *src, size_t count);
6175 +
6176 +diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
6177 +index 1ffa933121f6e..12ed7bb071be6 100644
6178 +--- a/include/linux/mtd/mtd.h
6179 ++++ b/include/linux/mtd/mtd.h
6180 +@@ -392,10 +392,8 @@ struct mtd_info {
6181 + /* List of partitions attached to this MTD device */
6182 + struct list_head partitions;
6183 +
6184 +- union {
6185 +- struct mtd_part part;
6186 +- struct mtd_master master;
6187 +- };
6188 ++ struct mtd_part part;
6189 ++ struct mtd_master master;
6190 + };
6191 +
6192 + static inline struct mtd_info *mtd_get_master(struct mtd_info *mtd)
6193 +diff --git a/include/memory/renesas-rpc-if.h b/include/memory/renesas-rpc-if.h
6194 +index 7c93f5177532f..9c0ad64b8d292 100644
6195 +--- a/include/memory/renesas-rpc-if.h
6196 ++++ b/include/memory/renesas-rpc-if.h
6197 +@@ -72,6 +72,7 @@ struct rpcif {
6198 + enum rpcif_type type;
6199 + enum rpcif_data_dir dir;
6200 + u8 bus_size;
6201 ++ u8 xfer_size;
6202 + void *buffer;
6203 + u32 xferlen;
6204 + u32 smcr;
6205 +diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
6206 +index 5cb095b09a940..69ef31cea5822 100644
6207 +--- a/include/net/bluetooth/hci.h
6208 ++++ b/include/net/bluetooth/hci.h
6209 +@@ -578,6 +578,7 @@ enum {
6210 + #define HCI_ERROR_CONNECTION_TIMEOUT 0x08
6211 + #define HCI_ERROR_REJ_LIMITED_RESOURCES 0x0d
6212 + #define HCI_ERROR_REJ_BAD_ADDR 0x0f
6213 ++#define HCI_ERROR_INVALID_PARAMETERS 0x12
6214 + #define HCI_ERROR_REMOTE_USER_TERM 0x13
6215 + #define HCI_ERROR_REMOTE_LOW_RESOURCES 0x14
6216 + #define HCI_ERROR_REMOTE_POWER_OFF 0x15
6217 +diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
6218 +index a38c4f1e4e5c6..74b369bddf49e 100644
6219 +--- a/include/net/ip6_tunnel.h
6220 ++++ b/include/net/ip6_tunnel.h
6221 +@@ -58,7 +58,7 @@ struct ip6_tnl {
6222 +
6223 + /* These fields used only by GRE */
6224 + __u32 i_seqno; /* The last seen seqno */
6225 +- __u32 o_seqno; /* The last output seqno */
6226 ++ atomic_t o_seqno; /* The last output seqno */
6227 + int hlen; /* tun_hlen + encap_hlen */
6228 + int tun_hlen; /* Precalculated header length */
6229 + int encap_hlen; /* Encap header length (FOU,GUE) */
6230 +diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
6231 +index 0219fe907b261..3ec6146f87342 100644
6232 +--- a/include/net/ip_tunnels.h
6233 ++++ b/include/net/ip_tunnels.h
6234 +@@ -116,7 +116,7 @@ struct ip_tunnel {
6235 +
6236 + /* These four fields used only by GRE */
6237 + u32 i_seqno; /* The last seen seqno */
6238 +- u32 o_seqno; /* The last output seqno */
6239 ++ atomic_t o_seqno; /* The last output seqno */
6240 + int tun_hlen; /* Precalculated header length */
6241 +
6242 + /* These four fields used only by ERSPAN */
6243 +diff --git a/include/net/tcp.h b/include/net/tcp.h
6244 +index b9fc978fb2cad..a3fe2f9bc01ce 100644
6245 +--- a/include/net/tcp.h
6246 ++++ b/include/net/tcp.h
6247 +@@ -480,6 +480,7 @@ int __cookie_v4_check(const struct iphdr *iph, const struct tcphdr *th,
6248 + u32 cookie);
6249 + struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb);
6250 + struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops,
6251 ++ const struct tcp_request_sock_ops *af_ops,
6252 + struct sock *sk, struct sk_buff *skb);
6253 + #ifdef CONFIG_SYN_COOKIES
6254 +
6255 +@@ -620,6 +621,7 @@ void tcp_synack_rtt_meas(struct sock *sk, struct request_sock *req);
6256 + void tcp_reset(struct sock *sk, struct sk_buff *skb);
6257 + void tcp_skb_mark_lost_uncond_verify(struct tcp_sock *tp, struct sk_buff *skb);
6258 + void tcp_fin(struct sock *sk);
6259 ++void tcp_check_space(struct sock *sk);
6260 +
6261 + /* tcp_timer.c */
6262 + void tcp_init_xmit_timers(struct sock *);
6263 +@@ -1042,6 +1044,7 @@ struct rate_sample {
6264 + int losses; /* number of packets marked lost upon ACK */
6265 + u32 acked_sacked; /* number of packets newly (S)ACKed upon ACK */
6266 + u32 prior_in_flight; /* in flight before this ACK */
6267 ++ u32 last_end_seq; /* end_seq of most recently ACKed packet */
6268 + bool is_app_limited; /* is sample from packet with bubble in pipe? */
6269 + bool is_retrans; /* is sample from retransmission? */
6270 + bool is_ack_delayed; /* is this (likely) a delayed ACK? */
6271 +@@ -1164,6 +1167,11 @@ void tcp_rate_gen(struct sock *sk, u32 delivered, u32 lost,
6272 + bool is_sack_reneg, struct rate_sample *rs);
6273 + void tcp_rate_check_app_limited(struct sock *sk);
6274 +
6275 ++static inline bool tcp_skb_sent_after(u64 t1, u64 t2, u32 seq1, u32 seq2)
6276 ++{
6277 ++ return t1 > t2 || (t1 == t2 && after(seq1, seq2));
6278 ++}
6279 ++
6280 + /* These functions determine how the current flow behaves in respect of SACK
6281 + * handling. SACK is negotiated with the peer, and therefore it can vary
6282 + * between different flows.
6283 +diff --git a/lib/hexdump.c b/lib/hexdump.c
6284 +index 9301578f98e8c..06833d404398d 100644
6285 +--- a/lib/hexdump.c
6286 ++++ b/lib/hexdump.c
6287 +@@ -22,15 +22,33 @@ EXPORT_SYMBOL(hex_asc_upper);
6288 + *
6289 + * hex_to_bin() converts one hex digit to its actual value or -1 in case of bad
6290 + * input.
6291 ++ *
6292 ++ * This function is used to load cryptographic keys, so it is coded in such a
6293 ++ * way that there are no conditions or memory accesses that depend on data.
6294 ++ *
6295 ++ * Explanation of the logic:
6296 ++ * (ch - '9' - 1) is negative if ch <= '9'
6297 ++ * ('0' - 1 - ch) is negative if ch >= '0'
6298 ++ * we "and" these two values, so the result is negative if ch is in the range
6299 ++ * '0' ... '9'
6300 ++ * we are only interested in the sign, so we do a shift ">> 8"; note that right
6301 ++ * shift of a negative value is implementation-defined, so we cast the
6302 ++ * value to (unsigned) before the shift --- we have 0xffffff if ch is in
6303 ++ * the range '0' ... '9', 0 otherwise
6304 ++ * we "and" this value with (ch - '0' + 1) --- we have a value 1 ... 10 if ch is
6305 ++ * in the range '0' ... '9', 0 otherwise
6306 ++ * we add this value to -1 --- we have a value 0 ... 9 if ch is in the range '0'
6307 ++ * ... '9', -1 otherwise
6308 ++ * the next line is similar to the previous one, but we need to decode both
6309 ++ * uppercase and lowercase letters, so we use (ch & 0xdf), which converts
6310 ++ * lowercase to uppercase
6311 + */
6312 +-int hex_to_bin(char ch)
6313 ++int hex_to_bin(unsigned char ch)
6314 + {
6315 +- if ((ch >= '0') && (ch <= '9'))
6316 +- return ch - '0';
6317 +- ch = tolower(ch);
6318 +- if ((ch >= 'a') && (ch <= 'f'))
6319 +- return ch - 'a' + 10;
6320 +- return -1;
6321 ++ unsigned char cu = ch & 0xdf;
6322 ++ return -1 +
6323 ++ ((ch - '0' + 1) & (unsigned)((ch - '9' - 1) & ('0' - 1 - ch)) >> 8) +
6324 ++ ((cu - 'A' + 11) & (unsigned)((cu - 'F' - 1) & ('A' - 1 - cu)) >> 8);
6325 + }
6326 + EXPORT_SYMBOL(hex_to_bin);
6327 +
6328 +@@ -45,10 +63,13 @@ EXPORT_SYMBOL(hex_to_bin);
6329 + int hex2bin(u8 *dst, const char *src, size_t count)
6330 + {
6331 + while (count--) {
6332 +- int hi = hex_to_bin(*src++);
6333 +- int lo = hex_to_bin(*src++);
6334 ++ int hi, lo;
6335 +
6336 +- if ((hi < 0) || (lo < 0))
6337 ++ hi = hex_to_bin(*src++);
6338 ++ if (unlikely(hi < 0))
6339 ++ return -EINVAL;
6340 ++ lo = hex_to_bin(*src++);
6341 ++ if (unlikely(lo < 0))
6342 + return -EINVAL;
6343 +
6344 + *dst++ = (hi << 4) | lo;
6345 +diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c
6346 +index 08291ed33e93a..0a9def8ce5e8b 100644
6347 +--- a/mm/kasan/quarantine.c
6348 ++++ b/mm/kasan/quarantine.c
6349 +@@ -315,6 +315,13 @@ static void per_cpu_remove_cache(void *arg)
6350 + struct qlist_head *q;
6351 +
6352 + q = this_cpu_ptr(&cpu_quarantine);
6353 ++ /*
6354 ++ * Ensure the ordering between the writing to q->offline and
6355 ++ * per_cpu_remove_cache. Prevent cpu_quarantine from being corrupted
6356 ++ * by interrupt.
6357 ++ */
6358 ++ if (READ_ONCE(q->offline))
6359 ++ return;
6360 + qlist_move_cache(q, &to_free, cache);
6361 + qlist_free_all(&to_free, cache);
6362 + }
6363 +diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
6364 +index d984777c9b58b..33a1b4115194e 100644
6365 +--- a/net/bluetooth/hci_event.c
6366 ++++ b/net/bluetooth/hci_event.c
6367 +@@ -3067,13 +3067,9 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
6368 + {
6369 + struct hci_ev_conn_complete *ev = data;
6370 + struct hci_conn *conn;
6371 ++ u8 status = ev->status;
6372 +
6373 +- if (__le16_to_cpu(ev->handle) > HCI_CONN_HANDLE_MAX) {
6374 +- bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for invalid handle");
6375 +- return;
6376 +- }
6377 +-
6378 +- bt_dev_dbg(hdev, "status 0x%2.2x", ev->status);
6379 ++ bt_dev_dbg(hdev, "status 0x%2.2x", status);
6380 +
6381 + hci_dev_lock(hdev);
6382 +
6383 +@@ -3122,8 +3118,14 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
6384 + goto unlock;
6385 + }
6386 +
6387 +- if (!ev->status) {
6388 ++ if (!status) {
6389 + conn->handle = __le16_to_cpu(ev->handle);
6390 ++ if (conn->handle > HCI_CONN_HANDLE_MAX) {
6391 ++ bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x",
6392 ++ conn->handle, HCI_CONN_HANDLE_MAX);
6393 ++ status = HCI_ERROR_INVALID_PARAMETERS;
6394 ++ goto done;
6395 ++ }
6396 +
6397 + if (conn->type == ACL_LINK) {
6398 + conn->state = BT_CONFIG;
6399 +@@ -3164,18 +3166,18 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
6400 + hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp),
6401 + &cp);
6402 + }
6403 +- } else {
6404 +- conn->state = BT_CLOSED;
6405 +- if (conn->type == ACL_LINK)
6406 +- mgmt_connect_failed(hdev, &conn->dst, conn->type,
6407 +- conn->dst_type, ev->status);
6408 + }
6409 +
6410 + if (conn->type == ACL_LINK)
6411 + hci_sco_setup(conn, ev->status);
6412 +
6413 +- if (ev->status) {
6414 +- hci_connect_cfm(conn, ev->status);
6415 ++done:
6416 ++ if (status) {
6417 ++ conn->state = BT_CLOSED;
6418 ++ if (conn->type == ACL_LINK)
6419 ++ mgmt_connect_failed(hdev, &conn->dst, conn->type,
6420 ++ conn->dst_type, status);
6421 ++ hci_connect_cfm(conn, status);
6422 + hci_conn_del(conn);
6423 + } else if (ev->link_type == SCO_LINK) {
6424 + switch (conn->setting & SCO_AIRMODE_MASK) {
6425 +@@ -3185,7 +3187,7 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
6426 + break;
6427 + }
6428 +
6429 +- hci_connect_cfm(conn, ev->status);
6430 ++ hci_connect_cfm(conn, status);
6431 + }
6432 +
6433 + unlock:
6434 +@@ -4676,6 +4678,7 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev, void *data,
6435 + {
6436 + struct hci_ev_sync_conn_complete *ev = data;
6437 + struct hci_conn *conn;
6438 ++ u8 status = ev->status;
6439 +
6440 + switch (ev->link_type) {
6441 + case SCO_LINK:
6442 +@@ -4690,12 +4693,7 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev, void *data,
6443 + return;
6444 + }
6445 +
6446 +- if (__le16_to_cpu(ev->handle) > HCI_CONN_HANDLE_MAX) {
6447 +- bt_dev_err(hdev, "Ignoring HCI_Sync_Conn_Complete for invalid handle");
6448 +- return;
6449 +- }
6450 +-
6451 +- bt_dev_dbg(hdev, "status 0x%2.2x", ev->status);
6452 ++ bt_dev_dbg(hdev, "status 0x%2.2x", status);
6453 +
6454 + hci_dev_lock(hdev);
6455 +
6456 +@@ -4729,9 +4727,17 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev, void *data,
6457 + goto unlock;
6458 + }
6459 +
6460 +- switch (ev->status) {
6461 ++ switch (status) {
6462 + case 0x00:
6463 + conn->handle = __le16_to_cpu(ev->handle);
6464 ++ if (conn->handle > HCI_CONN_HANDLE_MAX) {
6465 ++ bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x",
6466 ++ conn->handle, HCI_CONN_HANDLE_MAX);
6467 ++ status = HCI_ERROR_INVALID_PARAMETERS;
6468 ++ conn->state = BT_CLOSED;
6469 ++ break;
6470 ++ }
6471 ++
6472 + conn->state = BT_CONNECTED;
6473 + conn->type = ev->link_type;
6474 +
6475 +@@ -4775,8 +4781,8 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev, void *data,
6476 + }
6477 + }
6478 +
6479 +- hci_connect_cfm(conn, ev->status);
6480 +- if (ev->status)
6481 ++ hci_connect_cfm(conn, status);
6482 ++ if (status)
6483 + hci_conn_del(conn);
6484 +
6485 + unlock:
6486 +@@ -5527,11 +5533,6 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
6487 + struct smp_irk *irk;
6488 + u8 addr_type;
6489 +
6490 +- if (handle > HCI_CONN_HANDLE_MAX) {
6491 +- bt_dev_err(hdev, "Ignoring HCI_LE_Connection_Complete for invalid handle");
6492 +- return;
6493 +- }
6494 +-
6495 + hci_dev_lock(hdev);
6496 +
6497 + /* All controllers implicitly stop advertising in the event of a
6498 +@@ -5603,6 +5604,12 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
6499 +
6500 + conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL);
6501 +
6502 ++ if (handle > HCI_CONN_HANDLE_MAX) {
6503 ++ bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x", handle,
6504 ++ HCI_CONN_HANDLE_MAX);
6505 ++ status = HCI_ERROR_INVALID_PARAMETERS;
6506 ++ }
6507 ++
6508 + if (status) {
6509 + hci_le_conn_failed(conn, status);
6510 + goto unlock;
6511 +diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
6512 +index 349480ef68a51..8b6b5e72b2179 100644
6513 +--- a/net/core/lwt_bpf.c
6514 ++++ b/net/core/lwt_bpf.c
6515 +@@ -159,10 +159,8 @@ static int bpf_output(struct net *net, struct sock *sk, struct sk_buff *skb)
6516 + return dst->lwtstate->orig_output(net, sk, skb);
6517 + }
6518 +
6519 +-static int xmit_check_hhlen(struct sk_buff *skb)
6520 ++static int xmit_check_hhlen(struct sk_buff *skb, int hh_len)
6521 + {
6522 +- int hh_len = skb_dst(skb)->dev->hard_header_len;
6523 +-
6524 + if (skb_headroom(skb) < hh_len) {
6525 + int nhead = HH_DATA_ALIGN(hh_len - skb_headroom(skb));
6526 +
6527 +@@ -274,6 +272,7 @@ static int bpf_xmit(struct sk_buff *skb)
6528 +
6529 + bpf = bpf_lwt_lwtunnel(dst->lwtstate);
6530 + if (bpf->xmit.prog) {
6531 ++ int hh_len = dst->dev->hard_header_len;
6532 + __be16 proto = skb->protocol;
6533 + int ret;
6534 +
6535 +@@ -291,7 +290,7 @@ static int bpf_xmit(struct sk_buff *skb)
6536 + /* If the header was expanded, headroom might be too
6537 + * small for L2 header to come, expand as needed.
6538 + */
6539 +- ret = xmit_check_hhlen(skb);
6540 ++ ret = xmit_check_hhlen(skb, hh_len);
6541 + if (unlikely(ret))
6542 + return ret;
6543 +
6544 +diff --git a/net/dsa/port.c b/net/dsa/port.c
6545 +index 1a40c52f5a42d..4368fd32c4a50 100644
6546 +--- a/net/dsa/port.c
6547 ++++ b/net/dsa/port.c
6548 +@@ -1240,8 +1240,10 @@ int dsa_port_link_register_of(struct dsa_port *dp)
6549 + if (ds->ops->phylink_mac_link_down)
6550 + ds->ops->phylink_mac_link_down(ds, port,
6551 + MLO_AN_FIXED, PHY_INTERFACE_MODE_NA);
6552 ++ of_node_put(phy_np);
6553 + return dsa_port_phylink_register(dp);
6554 + }
6555 ++ of_node_put(phy_np);
6556 + return 0;
6557 + }
6558 +
6559 +diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
6560 +index 99db2e41ed10f..8cf86e42c1d1c 100644
6561 +--- a/net/ipv4/ip_gre.c
6562 ++++ b/net/ipv4/ip_gre.c
6563 +@@ -459,14 +459,12 @@ static void __gre_xmit(struct sk_buff *skb, struct net_device *dev,
6564 + __be16 proto)
6565 + {
6566 + struct ip_tunnel *tunnel = netdev_priv(dev);
6567 +-
6568 +- if (tunnel->parms.o_flags & TUNNEL_SEQ)
6569 +- tunnel->o_seqno++;
6570 ++ __be16 flags = tunnel->parms.o_flags;
6571 +
6572 + /* Push GRE header. */
6573 + gre_build_header(skb, tunnel->tun_hlen,
6574 +- tunnel->parms.o_flags, proto, tunnel->parms.o_key,
6575 +- htonl(tunnel->o_seqno));
6576 ++ flags, proto, tunnel->parms.o_key,
6577 ++ (flags & TUNNEL_SEQ) ? htonl(atomic_fetch_inc(&tunnel->o_seqno)) : 0);
6578 +
6579 + ip_tunnel_xmit(skb, dev, tnl_params, tnl_params->protocol);
6580 + }
6581 +@@ -504,7 +502,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
6582 + (TUNNEL_CSUM | TUNNEL_KEY | TUNNEL_SEQ);
6583 + gre_build_header(skb, tunnel_hlen, flags, proto,
6584 + tunnel_id_to_key32(tun_info->key.tun_id),
6585 +- (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0);
6586 ++ (flags & TUNNEL_SEQ) ? htonl(atomic_fetch_inc(&tunnel->o_seqno)) : 0);
6587 +
6588 + ip_md_tunnel_xmit(skb, dev, IPPROTO_GRE, tunnel_hlen);
6589 +
6590 +@@ -581,7 +579,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
6591 + }
6592 +
6593 + gre_build_header(skb, 8, TUNNEL_SEQ,
6594 +- proto, 0, htonl(tunnel->o_seqno++));
6595 ++ proto, 0, htonl(atomic_fetch_inc(&tunnel->o_seqno)));
6596 +
6597 + ip_md_tunnel_xmit(skb, dev, IPPROTO_GRE, tunnel_hlen);
6598 +
6599 +diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
6600 +index 2cb3b852d1486..f33c31dd7366c 100644
6601 +--- a/net/ipv4/syncookies.c
6602 ++++ b/net/ipv4/syncookies.c
6603 +@@ -281,6 +281,7 @@ bool cookie_ecn_ok(const struct tcp_options_received *tcp_opt,
6604 + EXPORT_SYMBOL(cookie_ecn_ok);
6605 +
6606 + struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops,
6607 ++ const struct tcp_request_sock_ops *af_ops,
6608 + struct sock *sk,
6609 + struct sk_buff *skb)
6610 + {
6611 +@@ -297,6 +298,10 @@ struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops,
6612 + return NULL;
6613 +
6614 + treq = tcp_rsk(req);
6615 ++
6616 ++ /* treq->af_specific might be used to perform TCP_MD5 lookup */
6617 ++ treq->af_specific = af_ops;
6618 ++
6619 + treq->syn_tos = TCP_SKB_CB(skb)->ip_dsfield;
6620 + #if IS_ENABLED(CONFIG_MPTCP)
6621 + treq->is_mptcp = sk_is_mptcp(sk);
6622 +@@ -364,7 +369,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
6623 + goto out;
6624 +
6625 + ret = NULL;
6626 +- req = cookie_tcp_reqsk_alloc(&tcp_request_sock_ops, sk, skb);
6627 ++ req = cookie_tcp_reqsk_alloc(&tcp_request_sock_ops,
6628 ++ &tcp_request_sock_ipv4_ops, sk, skb);
6629 + if (!req)
6630 + goto out;
6631 +
6632 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
6633 +index bfe4112e000c0..7bf84ce34d9e7 100644
6634 +--- a/net/ipv4/tcp_input.c
6635 ++++ b/net/ipv4/tcp_input.c
6636 +@@ -3867,7 +3867,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
6637 + tcp_process_tlp_ack(sk, ack, flag);
6638 +
6639 + if (tcp_ack_is_dubious(sk, flag)) {
6640 +- if (!(flag & (FLAG_SND_UNA_ADVANCED | FLAG_NOT_DUP))) {
6641 ++ if (!(flag & (FLAG_SND_UNA_ADVANCED |
6642 ++ FLAG_NOT_DUP | FLAG_DSACKING_ACK))) {
6643 + num_dupack = 1;
6644 + /* Consider if pure acks were aggregated in tcp_add_backlog() */
6645 + if (!(flag & FLAG_DATA))
6646 +@@ -5437,7 +5438,17 @@ static void tcp_new_space(struct sock *sk)
6647 + INDIRECT_CALL_1(sk->sk_write_space, sk_stream_write_space, sk);
6648 + }
6649 +
6650 +-static void tcp_check_space(struct sock *sk)
6651 ++/* Caller made space either from:
6652 ++ * 1) Freeing skbs in rtx queues (after tp->snd_una has advanced)
6653 ++ * 2) Sent skbs from output queue (and thus advancing tp->snd_nxt)
6654 ++ *
6655 ++ * We might be able to generate EPOLLOUT to the application if:
6656 ++ * 1) Space consumed in output/rtx queues is below sk->sk_sndbuf/2
6657 ++ * 2) notsent amount (tp->write_seq - tp->snd_nxt) became
6658 ++ * small enough that tcp_stream_memory_free() decides it
6659 ++ * is time to generate EPOLLOUT.
6660 ++ */
6661 ++void tcp_check_space(struct sock *sk)
6662 + {
6663 + /* pairs with tcp_poll() */
6664 + smp_mb();
6665 +diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
6666 +index 7c2d3ac2363ac..492737d2b7d35 100644
6667 +--- a/net/ipv4/tcp_minisocks.c
6668 ++++ b/net/ipv4/tcp_minisocks.c
6669 +@@ -531,7 +531,7 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
6670 + newtp->tsoffset = treq->ts_off;
6671 + #ifdef CONFIG_TCP_MD5SIG
6672 + newtp->md5sig_info = NULL; /*XXX*/
6673 +- if (newtp->af_specific->md5_lookup(sk, newsk))
6674 ++ if (treq->af_specific->req_md5_lookup(sk, req_to_sk(req)))
6675 + newtp->tcp_header_len += TCPOLEN_MD5SIG_ALIGNED;
6676 + #endif
6677 + if (skb->len >= TCP_MSS_DEFAULT + newtp->tcp_header_len)
6678 +diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
6679 +index 257780f93305f..0b5eab6851549 100644
6680 +--- a/net/ipv4/tcp_output.c
6681 ++++ b/net/ipv4/tcp_output.c
6682 +@@ -82,6 +82,7 @@ static void tcp_event_new_data_sent(struct sock *sk, struct sk_buff *skb)
6683 +
6684 + NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPORIGDATASENT,
6685 + tcp_skb_pcount(skb));
6686 ++ tcp_check_space(sk);
6687 + }
6688 +
6689 + /* SND.NXT, if window was not shrunk or the amount of shrunk was less than one
6690 +diff --git a/net/ipv4/tcp_rate.c b/net/ipv4/tcp_rate.c
6691 +index fbab921670cc9..9a8e014d9b5b9 100644
6692 +--- a/net/ipv4/tcp_rate.c
6693 ++++ b/net/ipv4/tcp_rate.c
6694 +@@ -74,27 +74,32 @@ void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb)
6695 + *
6696 + * If an ACK (s)acks multiple skbs (e.g., stretched-acks), this function is
6697 + * called multiple times. We favor the information from the most recently
6698 +- * sent skb, i.e., the skb with the highest prior_delivered count.
6699 ++ * sent skb, i.e., the skb with the most recently sent time and the highest
6700 ++ * sequence.
6701 + */
6702 + void tcp_rate_skb_delivered(struct sock *sk, struct sk_buff *skb,
6703 + struct rate_sample *rs)
6704 + {
6705 + struct tcp_sock *tp = tcp_sk(sk);
6706 + struct tcp_skb_cb *scb = TCP_SKB_CB(skb);
6707 ++ u64 tx_tstamp;
6708 +
6709 + if (!scb->tx.delivered_mstamp)
6710 + return;
6711 +
6712 ++ tx_tstamp = tcp_skb_timestamp_us(skb);
6713 + if (!rs->prior_delivered ||
6714 +- after(scb->tx.delivered, rs->prior_delivered)) {
6715 ++ tcp_skb_sent_after(tx_tstamp, tp->first_tx_mstamp,
6716 ++ scb->end_seq, rs->last_end_seq)) {
6717 + rs->prior_delivered_ce = scb->tx.delivered_ce;
6718 + rs->prior_delivered = scb->tx.delivered;
6719 + rs->prior_mstamp = scb->tx.delivered_mstamp;
6720 + rs->is_app_limited = scb->tx.is_app_limited;
6721 + rs->is_retrans = scb->sacked & TCPCB_RETRANS;
6722 ++ rs->last_end_seq = scb->end_seq;
6723 +
6724 + /* Record send time of most recently ACKed packet: */
6725 +- tp->first_tx_mstamp = tcp_skb_timestamp_us(skb);
6726 ++ tp->first_tx_mstamp = tx_tstamp;
6727 + /* Find the duration of the "send phase" of this window: */
6728 + rs->interval_us = tcp_stamp_us_delta(tp->first_tx_mstamp,
6729 + scb->tx.first_tx_mstamp);
6730 +diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
6731 +index 9762367361463..5136959b3dc5d 100644
6732 +--- a/net/ipv6/ip6_gre.c
6733 ++++ b/net/ipv6/ip6_gre.c
6734 +@@ -724,6 +724,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
6735 + {
6736 + struct ip6_tnl *tunnel = netdev_priv(dev);
6737 + __be16 protocol;
6738 ++ __be16 flags;
6739 +
6740 + if (dev->type == ARPHRD_ETHER)
6741 + IPCB(skb)->flags = 0;
6742 +@@ -739,7 +740,6 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
6743 + if (tunnel->parms.collect_md) {
6744 + struct ip_tunnel_info *tun_info;
6745 + const struct ip_tunnel_key *key;
6746 +- __be16 flags;
6747 + int tun_hlen;
6748 +
6749 + tun_info = skb_tunnel_info_txcheck(skb);
6750 +@@ -766,19 +766,19 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
6751 + gre_build_header(skb, tun_hlen,
6752 + flags, protocol,
6753 + tunnel_id_to_key32(tun_info->key.tun_id),
6754 +- (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++)
6755 ++ (flags & TUNNEL_SEQ) ? htonl(atomic_fetch_inc(&tunnel->o_seqno))
6756 + : 0);
6757 +
6758 + } else {
6759 +- if (tunnel->parms.o_flags & TUNNEL_SEQ)
6760 +- tunnel->o_seqno++;
6761 +-
6762 + if (skb_cow_head(skb, dev->needed_headroom ?: tunnel->hlen))
6763 + return -ENOMEM;
6764 +
6765 +- gre_build_header(skb, tunnel->tun_hlen, tunnel->parms.o_flags,
6766 ++ flags = tunnel->parms.o_flags;
6767 ++
6768 ++ gre_build_header(skb, tunnel->tun_hlen, flags,
6769 + protocol, tunnel->parms.o_key,
6770 +- htonl(tunnel->o_seqno));
6771 ++ (flags & TUNNEL_SEQ) ? htonl(atomic_fetch_inc(&tunnel->o_seqno))
6772 ++ : 0);
6773 + }
6774 +
6775 + return ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu,
6776 +@@ -1056,7 +1056,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
6777 + /* Push GRE header. */
6778 + proto = (t->parms.erspan_ver == 1) ? htons(ETH_P_ERSPAN)
6779 + : htons(ETH_P_ERSPAN2);
6780 +- gre_build_header(skb, 8, TUNNEL_SEQ, proto, 0, htonl(t->o_seqno++));
6781 ++ gre_build_header(skb, 8, TUNNEL_SEQ, proto, 0, htonl(atomic_fetch_inc(&t->o_seqno)));
6782 +
6783 + /* TooBig packet may have updated dst->dev's mtu */
6784 + if (!t->parms.collect_md && dst && dst_mtu(dst) > dst->dev->mtu)
6785 +diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c
6786 +index 6ab710b5a1a82..118e834e91902 100644
6787 +--- a/net/ipv6/netfilter.c
6788 ++++ b/net/ipv6/netfilter.c
6789 +@@ -24,14 +24,13 @@ int ip6_route_me_harder(struct net *net, struct sock *sk_partial, struct sk_buff
6790 + {
6791 + const struct ipv6hdr *iph = ipv6_hdr(skb);
6792 + struct sock *sk = sk_to_full_sk(sk_partial);
6793 ++ struct net_device *dev = skb_dst(skb)->dev;
6794 + struct flow_keys flkeys;
6795 + unsigned int hh_len;
6796 + struct dst_entry *dst;
6797 + int strict = (ipv6_addr_type(&iph->daddr) &
6798 + (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL));
6799 + struct flowi6 fl6 = {
6800 +- .flowi6_oif = sk && sk->sk_bound_dev_if ? sk->sk_bound_dev_if :
6801 +- strict ? skb_dst(skb)->dev->ifindex : 0,
6802 + .flowi6_mark = skb->mark,
6803 + .flowi6_uid = sock_net_uid(net, sk),
6804 + .daddr = iph->daddr,
6805 +@@ -39,6 +38,13 @@ int ip6_route_me_harder(struct net *net, struct sock *sk_partial, struct sk_buff
6806 + };
6807 + int err;
6808 +
6809 ++ if (sk && sk->sk_bound_dev_if)
6810 ++ fl6.flowi6_oif = sk->sk_bound_dev_if;
6811 ++ else if (strict)
6812 ++ fl6.flowi6_oif = dev->ifindex;
6813 ++ else
6814 ++ fl6.flowi6_oif = l3mdev_master_ifindex(dev);
6815 ++
6816 + fib6_rules_early_flow_dissect(net, skb, &fl6, &flkeys);
6817 + dst = ip6_route_output(net, sk, &fl6);
6818 + err = dst->error;
6819 +diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
6820 +index d1b61d00368e1..9cc123f000fbc 100644
6821 +--- a/net/ipv6/syncookies.c
6822 ++++ b/net/ipv6/syncookies.c
6823 +@@ -170,7 +170,8 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
6824 + goto out;
6825 +
6826 + ret = NULL;
6827 +- req = cookie_tcp_reqsk_alloc(&tcp6_request_sock_ops, sk, skb);
6828 ++ req = cookie_tcp_reqsk_alloc(&tcp6_request_sock_ops,
6829 ++ &tcp_request_sock_ipv6_ops, sk, skb);
6830 + if (!req)
6831 + goto out;
6832 +
6833 +diff --git a/net/mctp/device.c b/net/mctp/device.c
6834 +index f86ef6d751bdc..9150b9789d251 100644
6835 +--- a/net/mctp/device.c
6836 ++++ b/net/mctp/device.c
6837 +@@ -312,6 +312,7 @@ void mctp_dev_hold(struct mctp_dev *mdev)
6838 + void mctp_dev_put(struct mctp_dev *mdev)
6839 + {
6840 + if (mdev && refcount_dec_and_test(&mdev->refs)) {
6841 ++ kfree(mdev->addrs);
6842 + dev_put(mdev->dev);
6843 + kfree_rcu(mdev, rcu);
6844 + }
6845 +@@ -440,7 +441,6 @@ static void mctp_unregister(struct net_device *dev)
6846 +
6847 + mctp_route_remove_dev(mdev);
6848 + mctp_neigh_remove_dev(mdev);
6849 +- kfree(mdev->addrs);
6850 +
6851 + mctp_dev_put(mdev);
6852 + }
6853 +diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
6854 +index 2c467c422dc63..fb67f1ca2495b 100644
6855 +--- a/net/netfilter/ipvs/ip_vs_conn.c
6856 ++++ b/net/netfilter/ipvs/ip_vs_conn.c
6857 +@@ -1495,7 +1495,7 @@ int __init ip_vs_conn_init(void)
6858 + pr_info("Connection hash table configured "
6859 + "(size=%d, memory=%ldKbytes)\n",
6860 + ip_vs_conn_tab_size,
6861 +- (long)(ip_vs_conn_tab_size*sizeof(struct list_head))/1024);
6862 ++ (long)(ip_vs_conn_tab_size*sizeof(*ip_vs_conn_tab))/1024);
6863 + IP_VS_DBG(0, "Each connection entry needs %zd bytes at least\n",
6864 + sizeof(struct ip_vs_conn));
6865 +
6866 +diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
6867 +index 8ec55cd72572e..204a5cdff5b11 100644
6868 +--- a/net/netfilter/nf_conntrack_proto_tcp.c
6869 ++++ b/net/netfilter/nf_conntrack_proto_tcp.c
6870 +@@ -556,24 +556,14 @@ static bool tcp_in_window(struct nf_conn *ct,
6871 + }
6872 +
6873 + }
6874 +- } else if (((state->state == TCP_CONNTRACK_SYN_SENT
6875 +- && dir == IP_CT_DIR_ORIGINAL)
6876 +- || (state->state == TCP_CONNTRACK_SYN_RECV
6877 +- && dir == IP_CT_DIR_REPLY))
6878 +- && after(end, sender->td_end)) {
6879 ++ } else if (tcph->syn &&
6880 ++ after(end, sender->td_end) &&
6881 ++ (state->state == TCP_CONNTRACK_SYN_SENT ||
6882 ++ state->state == TCP_CONNTRACK_SYN_RECV)) {
6883 + /*
6884 + * RFC 793: "if a TCP is reinitialized ... then it need
6885 + * not wait at all; it must only be sure to use sequence
6886 + * numbers larger than those recently used."
6887 +- */
6888 +- sender->td_end =
6889 +- sender->td_maxend = end;
6890 +- sender->td_maxwin = (win == 0 ? 1 : win);
6891 +-
6892 +- tcp_options(skb, dataoff, tcph, sender);
6893 +- } else if (tcph->syn && dir == IP_CT_DIR_REPLY &&
6894 +- state->state == TCP_CONNTRACK_SYN_SENT) {
6895 +- /* Retransmitted syn-ack, or syn (simultaneous open).
6896 + *
6897 + * Re-init state for this direction, just like for the first
6898 + * syn(-ack) reply, it might differ in seq, ack or tcp options.
6899 +@@ -581,7 +571,8 @@ static bool tcp_in_window(struct nf_conn *ct,
6900 + tcp_init_sender(sender, receiver,
6901 + skb, dataoff, tcph,
6902 + end, win);
6903 +- if (!tcph->ack)
6904 ++
6905 ++ if (dir == IP_CT_DIR_REPLY && !tcph->ack)
6906 + return true;
6907 + }
6908 +
6909 +diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
6910 +index 3e1afd10a9b60..55aa55b252b20 100644
6911 +--- a/net/netfilter/nf_conntrack_standalone.c
6912 ++++ b/net/netfilter/nf_conntrack_standalone.c
6913 +@@ -823,7 +823,7 @@ static struct ctl_table nf_ct_sysctl_table[] = {
6914 + .mode = 0644,
6915 + .proc_handler = proc_dointvec_jiffies,
6916 + },
6917 +-#if IS_ENABLED(CONFIG_NFT_FLOW_OFFLOAD)
6918 ++#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
6919 + [NF_SYSCTL_CT_PROTO_TIMEOUT_UDP_OFFLOAD] = {
6920 + .procname = "nf_flowtable_udp_timeout",
6921 + .maxlen = sizeof(unsigned int),
6922 +diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c
6923 +index d600a566da324..7325bee7d1442 100644
6924 +--- a/net/netfilter/nft_set_rbtree.c
6925 ++++ b/net/netfilter/nft_set_rbtree.c
6926 +@@ -349,7 +349,11 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
6927 + *ext = &rbe->ext;
6928 + return -EEXIST;
6929 + } else {
6930 +- p = &parent->rb_left;
6931 ++ overlap = false;
6932 ++ if (nft_rbtree_interval_end(rbe))
6933 ++ p = &parent->rb_left;
6934 ++ else
6935 ++ p = &parent->rb_right;
6936 + }
6937 + }
6938 +
6939 +diff --git a/net/netfilter/nft_socket.c b/net/netfilter/nft_socket.c
6940 +index b8f0111457650..9ad9cc0d1d27c 100644
6941 +--- a/net/netfilter/nft_socket.c
6942 ++++ b/net/netfilter/nft_socket.c
6943 +@@ -53,6 +53,32 @@ nft_sock_get_eval_cgroupv2(u32 *dest, struct sock *sk, const struct nft_pktinfo
6944 + }
6945 + #endif
6946 +
6947 ++static struct sock *nft_socket_do_lookup(const struct nft_pktinfo *pkt)
6948 ++{
6949 ++ const struct net_device *indev = nft_in(pkt);
6950 ++ const struct sk_buff *skb = pkt->skb;
6951 ++ struct sock *sk = NULL;
6952 ++
6953 ++ if (!indev)
6954 ++ return NULL;
6955 ++
6956 ++ switch (nft_pf(pkt)) {
6957 ++ case NFPROTO_IPV4:
6958 ++ sk = nf_sk_lookup_slow_v4(nft_net(pkt), skb, indev);
6959 ++ break;
6960 ++#if IS_ENABLED(CONFIG_NF_TABLES_IPV6)
6961 ++ case NFPROTO_IPV6:
6962 ++ sk = nf_sk_lookup_slow_v6(nft_net(pkt), skb, indev);
6963 ++ break;
6964 ++#endif
6965 ++ default:
6966 ++ WARN_ON_ONCE(1);
6967 ++ break;
6968 ++ }
6969 ++
6970 ++ return sk;
6971 ++}
6972 ++
6973 + static void nft_socket_eval(const struct nft_expr *expr,
6974 + struct nft_regs *regs,
6975 + const struct nft_pktinfo *pkt)
6976 +@@ -66,20 +92,7 @@ static void nft_socket_eval(const struct nft_expr *expr,
6977 + sk = NULL;
6978 +
6979 + if (!sk)
6980 +- switch(nft_pf(pkt)) {
6981 +- case NFPROTO_IPV4:
6982 +- sk = nf_sk_lookup_slow_v4(nft_net(pkt), skb, nft_in(pkt));
6983 +- break;
6984 +-#if IS_ENABLED(CONFIG_NF_TABLES_IPV6)
6985 +- case NFPROTO_IPV6:
6986 +- sk = nf_sk_lookup_slow_v6(nft_net(pkt), skb, nft_in(pkt));
6987 +- break;
6988 +-#endif
6989 +- default:
6990 +- WARN_ON_ONCE(1);
6991 +- regs->verdict.code = NFT_BREAK;
6992 +- return;
6993 +- }
6994 ++ sk = nft_socket_do_lookup(pkt);
6995 +
6996 + if (!sk) {
6997 + regs->verdict.code = NFT_BREAK;
6998 +@@ -197,6 +210,16 @@ static int nft_socket_dump(struct sk_buff *skb,
6999 + return 0;
7000 + }
7001 +
7002 ++static int nft_socket_validate(const struct nft_ctx *ctx,
7003 ++ const struct nft_expr *expr,
7004 ++ const struct nft_data **data)
7005 ++{
7006 ++ return nft_chain_validate_hooks(ctx->chain,
7007 ++ (1 << NF_INET_PRE_ROUTING) |
7008 ++ (1 << NF_INET_LOCAL_IN) |
7009 ++ (1 << NF_INET_LOCAL_OUT));
7010 ++}
7011 ++
7012 + static struct nft_expr_type nft_socket_type;
7013 + static const struct nft_expr_ops nft_socket_ops = {
7014 + .type = &nft_socket_type,
7015 +@@ -204,6 +227,7 @@ static const struct nft_expr_ops nft_socket_ops = {
7016 + .eval = nft_socket_eval,
7017 + .init = nft_socket_init,
7018 + .dump = nft_socket_dump,
7019 ++ .validate = nft_socket_validate,
7020 + };
7021 +
7022 + static struct nft_expr_type nft_socket_type __read_mostly = {
7023 +diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
7024 +index b3815b568e8e5..463c4a58d2c36 100644
7025 +--- a/net/sctp/sm_sideeffect.c
7026 ++++ b/net/sctp/sm_sideeffect.c
7027 +@@ -458,6 +458,10 @@ void sctp_generate_reconf_event(struct timer_list *t)
7028 + goto out_unlock;
7029 + }
7030 +
7031 ++ /* This happens when the response arrives after the timer is triggered. */
7032 ++ if (!asoc->strreset_chunk)
7033 ++ goto out_unlock;
7034 ++
7035 + error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
7036 + SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_RECONF),
7037 + asoc->state, asoc->ep, asoc,
7038 +diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
7039 +index 68cd110722a4a..fd9d9cfd0f3dd 100644
7040 +--- a/net/smc/af_smc.c
7041 ++++ b/net/smc/af_smc.c
7042 +@@ -1357,6 +1357,8 @@ static void smc_connect_work(struct work_struct *work)
7043 + smc->sk.sk_state = SMC_CLOSED;
7044 + if (rc == -EPIPE || rc == -EAGAIN)
7045 + smc->sk.sk_err = EPIPE;
7046 ++ else if (rc == -ECONNREFUSED)
7047 ++ smc->sk.sk_err = ECONNREFUSED;
7048 + else if (signal_pending(current))
7049 + smc->sk.sk_err = -sock_intr_errno(timeo);
7050 + sock_put(&smc->sk); /* passive closing */
7051 +diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
7052 +index b932469ee69cc..a40553e83f8b2 100644
7053 +--- a/net/tls/tls_device.c
7054 ++++ b/net/tls/tls_device.c
7055 +@@ -483,11 +483,13 @@ handle_error:
7056 + copy = min_t(size_t, size, (pfrag->size - pfrag->offset));
7057 + copy = min_t(size_t, copy, (max_open_record_len - record->len));
7058 +
7059 +- rc = tls_device_copy_data(page_address(pfrag->page) +
7060 +- pfrag->offset, copy, msg_iter);
7061 +- if (rc)
7062 +- goto handle_error;
7063 +- tls_append_frag(record, pfrag, copy);
7064 ++ if (copy) {
7065 ++ rc = tls_device_copy_data(page_address(pfrag->page) +
7066 ++ pfrag->offset, copy, msg_iter);
7067 ++ if (rc)
7068 ++ goto handle_error;
7069 ++ tls_append_frag(record, pfrag, copy);
7070 ++ }
7071 +
7072 + size -= copy;
7073 + if (!size) {
7074 +diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
7075 +index ac343cd8ff3f6..39a82bfb5caa3 100644
7076 +--- a/net/xdp/xsk.c
7077 ++++ b/net/xdp/xsk.c
7078 +@@ -640,7 +640,7 @@ static int __xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len
7079 + if (sk_can_busy_loop(sk))
7080 + sk_busy_loop(sk, 1); /* only support non-blocking sockets */
7081 +
7082 +- if (xsk_no_wakeup(sk))
7083 ++ if (xs->zc && xsk_no_wakeup(sk))
7084 + return 0;
7085 +
7086 + pool = xs->pool;
7087 +diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c
7088 +index 8b0a16ba27d39..a8fe01764b254 100644
7089 +--- a/sound/hda/intel-dsp-config.c
7090 ++++ b/sound/hda/intel-dsp-config.c
7091 +@@ -424,6 +424,15 @@ static const struct config_entry config_table[] = {
7092 + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
7093 + .device = 0x54c8,
7094 + },
7095 ++ /* RaptorLake-P */
7096 ++ {
7097 ++ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
7098 ++ .device = 0x51ca,
7099 ++ },
7100 ++ {
7101 ++ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
7102 ++ .device = 0x51cb,
7103 ++ },
7104 + #endif
7105 +
7106 + };
7107 +diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c
7108 +index e5a56bcbb223d..281a710a41231 100644
7109 +--- a/sound/soc/codecs/cs35l41-lib.c
7110 ++++ b/sound/soc/codecs/cs35l41-lib.c
7111 +@@ -831,12 +831,14 @@ int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap)
7112 + GENMASK(bit_offset + otp_map[i].size - 33, 0)) <<
7113 + (32 - bit_offset);
7114 + bit_offset += otp_map[i].size - 32;
7115 +- } else {
7116 ++ } else if (bit_offset + otp_map[i].size - 1 >= 0) {
7117 + otp_val = (otp_mem[word_offset] &
7118 + GENMASK(bit_offset + otp_map[i].size - 1, bit_offset)
7119 + ) >> bit_offset;
7120 + bit_offset += otp_map[i].size;
7121 +- }
7122 ++ } else /* both bit_offset and otp_map[i].size are 0 */
7123 ++ otp_val = 0;
7124 ++
7125 + bit_sum += otp_map[i].size;
7126 +
7127 + if (bit_offset == 32) {
7128 +diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
7129 +index c9ff9c89adf70..2b6c6d6b9771e 100644
7130 +--- a/sound/soc/codecs/rt5682.c
7131 ++++ b/sound/soc/codecs/rt5682.c
7132 +@@ -1100,6 +1100,15 @@ void rt5682_jack_detect_handler(struct work_struct *work)
7133 + return;
7134 + }
7135 +
7136 ++ if (rt5682->is_sdw) {
7137 ++ if (pm_runtime_status_suspended(rt5682->slave->dev.parent)) {
7138 ++ dev_dbg(&rt5682->slave->dev,
7139 ++ "%s: parent device is pm_runtime_status_suspended, skipping jack detection\n",
7140 ++ __func__);
7141 ++ return;
7142 ++ }
7143 ++ }
7144 ++
7145 + dapm = snd_soc_component_get_dapm(rt5682->component);
7146 +
7147 + snd_soc_dapm_mutex_lock(dapm);
7148 +diff --git a/sound/soc/codecs/rt711.c b/sound/soc/codecs/rt711.c
7149 +index 6770825d037a8..ea25fd58d43a9 100644
7150 +--- a/sound/soc/codecs/rt711.c
7151 ++++ b/sound/soc/codecs/rt711.c
7152 +@@ -245,6 +245,13 @@ static void rt711_jack_detect_handler(struct work_struct *work)
7153 + if (!rt711->component->card->instantiated)
7154 + return;
7155 +
7156 ++ if (pm_runtime_status_suspended(rt711->slave->dev.parent)) {
7157 ++ dev_dbg(&rt711->slave->dev,
7158 ++ "%s: parent device is pm_runtime_status_suspended, skipping jack detection\n",
7159 ++ __func__);
7160 ++ return;
7161 ++ }
7162 ++
7163 + reg = RT711_VERB_GET_PIN_SENSE | RT711_HP_OUT;
7164 + ret = regmap_read(rt711->regmap, reg, &jack_status);
7165 + if (ret < 0)
7166 +diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
7167 +index 86b1f6eaa5991..518167d90b105 100644
7168 +--- a/sound/soc/codecs/wm8731.c
7169 ++++ b/sound/soc/codecs/wm8731.c
7170 +@@ -602,7 +602,7 @@ static int wm8731_hw_init(struct device *dev, struct wm8731_priv *wm8731)
7171 + ret = wm8731_reset(wm8731->regmap);
7172 + if (ret < 0) {
7173 + dev_err(dev, "Failed to issue reset: %d\n", ret);
7174 +- goto err_regulator_enable;
7175 ++ goto err;
7176 + }
7177 +
7178 + /* Clear POWEROFF, keep everything else disabled */
7179 +@@ -619,10 +619,7 @@ static int wm8731_hw_init(struct device *dev, struct wm8731_priv *wm8731)
7180 +
7181 + regcache_mark_dirty(wm8731->regmap);
7182 +
7183 +-err_regulator_enable:
7184 +- /* Regulators will be enabled by bias management */
7185 +- regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
7186 +-
7187 ++err:
7188 + return ret;
7189 + }
7190 +
7191 +@@ -760,21 +757,27 @@ static int wm8731_i2c_probe(struct i2c_client *i2c,
7192 + ret = PTR_ERR(wm8731->regmap);
7193 + dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
7194 + ret);
7195 +- return ret;
7196 ++ goto err_regulator_enable;
7197 + }
7198 +
7199 + ret = wm8731_hw_init(&i2c->dev, wm8731);
7200 + if (ret != 0)
7201 +- return ret;
7202 ++ goto err_regulator_enable;
7203 +
7204 + ret = devm_snd_soc_register_component(&i2c->dev,
7205 + &soc_component_dev_wm8731, &wm8731_dai, 1);
7206 + if (ret != 0) {
7207 + dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
7208 +- return ret;
7209 ++ goto err_regulator_enable;
7210 + }
7211 +
7212 + return 0;
7213 ++
7214 ++err_regulator_enable:
7215 ++ /* Regulators will be enabled by bias management */
7216 ++ regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
7217 ++
7218 ++ return ret;
7219 + }
7220 +
7221 + static int wm8731_i2c_remove(struct i2c_client *client)
7222 +diff --git a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c
7223 +index e2658bca69318..3137cea78d48c 100644
7224 +--- a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c
7225 ++++ b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c
7226 +@@ -132,13 +132,13 @@ static const struct snd_soc_acpi_adr_device mx8373_1_adr[] = {
7227 + {
7228 + .adr = 0x000123019F837300ull,
7229 + .num_endpoints = 1,
7230 +- .endpoints = &spk_l_endpoint,
7231 ++ .endpoints = &spk_r_endpoint,
7232 + .name_prefix = "Right"
7233 + },
7234 + {
7235 + .adr = 0x000127019F837300ull,
7236 + .num_endpoints = 1,
7237 +- .endpoints = &spk_r_endpoint,
7238 ++ .endpoints = &spk_l_endpoint,
7239 + .name_prefix = "Left"
7240 + }
7241 + };
7242 +diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
7243 +index 9a954680d4928..11c9853e9e807 100644
7244 +--- a/sound/soc/soc-pcm.c
7245 ++++ b/sound/soc/soc-pcm.c
7246 +@@ -1214,7 +1214,7 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
7247 + be_substream->pcm->nonatomic = 1;
7248 + }
7249 +
7250 +- dpcm = kzalloc(sizeof(struct snd_soc_dpcm), GFP_ATOMIC);
7251 ++ dpcm = kzalloc(sizeof(struct snd_soc_dpcm), GFP_KERNEL);
7252 + if (!dpcm)
7253 + return -ENOMEM;
7254 +
7255 +diff --git a/tools/objtool/check.c b/tools/objtool/check.c
7256 +index 3470813daf4aa..af675c8cf05d6 100644
7257 +--- a/tools/objtool/check.c
7258 ++++ b/tools/objtool/check.c
7259 +@@ -546,12 +546,12 @@ static int add_dead_ends(struct objtool_file *file)
7260 + else if (reloc->addend == reloc->sym->sec->sh.sh_size) {
7261 + insn = find_last_insn(file, reloc->sym->sec);
7262 + if (!insn) {
7263 +- WARN("can't find unreachable insn at %s+0x%x",
7264 ++ WARN("can't find unreachable insn at %s+0x%lx",
7265 + reloc->sym->sec->name, reloc->addend);
7266 + return -1;
7267 + }
7268 + } else {
7269 +- WARN("can't find unreachable insn at %s+0x%x",
7270 ++ WARN("can't find unreachable insn at %s+0x%lx",
7271 + reloc->sym->sec->name, reloc->addend);
7272 + return -1;
7273 + }
7274 +@@ -581,12 +581,12 @@ reachable:
7275 + else if (reloc->addend == reloc->sym->sec->sh.sh_size) {
7276 + insn = find_last_insn(file, reloc->sym->sec);
7277 + if (!insn) {
7278 +- WARN("can't find reachable insn at %s+0x%x",
7279 ++ WARN("can't find reachable insn at %s+0x%lx",
7280 + reloc->sym->sec->name, reloc->addend);
7281 + return -1;
7282 + }
7283 + } else {
7284 +- WARN("can't find reachable insn at %s+0x%x",
7285 ++ WARN("can't find reachable insn at %s+0x%lx",
7286 + reloc->sym->sec->name, reloc->addend);
7287 + return -1;
7288 + }
7289 +diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
7290 +index 4b384c907027e..2a7061e6f465a 100644
7291 +--- a/tools/objtool/elf.c
7292 ++++ b/tools/objtool/elf.c
7293 +@@ -486,7 +486,7 @@ static struct section *elf_create_reloc_section(struct elf *elf,
7294 + int reltype);
7295 +
7296 + int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
7297 +- unsigned int type, struct symbol *sym, int addend)
7298 ++ unsigned int type, struct symbol *sym, long addend)
7299 + {
7300 + struct reloc *reloc;
7301 +
7302 +@@ -515,37 +515,180 @@ int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
7303 + return 0;
7304 + }
7305 +
7306 +-int elf_add_reloc_to_insn(struct elf *elf, struct section *sec,
7307 +- unsigned long offset, unsigned int type,
7308 +- struct section *insn_sec, unsigned long insn_off)
7309 ++/*
7310 ++ * Ensure that any reloc section containing references to @sym is marked
7311 ++ * changed such that it will get re-generated in elf_rebuild_reloc_sections()
7312 ++ * with the new symbol index.
7313 ++ */
7314 ++static void elf_dirty_reloc_sym(struct elf *elf, struct symbol *sym)
7315 ++{
7316 ++ struct section *sec;
7317 ++
7318 ++ list_for_each_entry(sec, &elf->sections, list) {
7319 ++ struct reloc *reloc;
7320 ++
7321 ++ if (sec->changed)
7322 ++ continue;
7323 ++
7324 ++ list_for_each_entry(reloc, &sec->reloc_list, list) {
7325 ++ if (reloc->sym == sym) {
7326 ++ sec->changed = true;
7327 ++ break;
7328 ++ }
7329 ++ }
7330 ++ }
7331 ++}
7332 ++
7333 ++/*
7334 ++ * Move the first global symbol, as per sh_info, into a new, higher symbol
7335 ++ * index. This fees up the shndx for a new local symbol.
7336 ++ */
7337 ++static int elf_move_global_symbol(struct elf *elf, struct section *symtab,
7338 ++ struct section *symtab_shndx)
7339 + {
7340 ++ Elf_Data *data, *shndx_data = NULL;
7341 ++ Elf32_Word first_non_local;
7342 + struct symbol *sym;
7343 +- int addend;
7344 ++ Elf_Scn *s;
7345 +
7346 +- if (insn_sec->sym) {
7347 +- sym = insn_sec->sym;
7348 +- addend = insn_off;
7349 ++ first_non_local = symtab->sh.sh_info;
7350 +
7351 +- } else {
7352 +- /*
7353 +- * The Clang assembler strips section symbols, so we have to
7354 +- * reference the function symbol instead:
7355 +- */
7356 +- sym = find_symbol_containing(insn_sec, insn_off);
7357 +- if (!sym) {
7358 +- /*
7359 +- * Hack alert. This happens when we need to reference
7360 +- * the NOP pad insn immediately after the function.
7361 +- */
7362 +- sym = find_symbol_containing(insn_sec, insn_off - 1);
7363 ++ sym = find_symbol_by_index(elf, first_non_local);
7364 ++ if (!sym) {
7365 ++ WARN("no non-local symbols !?");
7366 ++ return first_non_local;
7367 ++ }
7368 ++
7369 ++ s = elf_getscn(elf->elf, symtab->idx);
7370 ++ if (!s) {
7371 ++ WARN_ELF("elf_getscn");
7372 ++ return -1;
7373 ++ }
7374 ++
7375 ++ data = elf_newdata(s);
7376 ++ if (!data) {
7377 ++ WARN_ELF("elf_newdata");
7378 ++ return -1;
7379 ++ }
7380 ++
7381 ++ data->d_buf = &sym->sym;
7382 ++ data->d_size = sizeof(sym->sym);
7383 ++ data->d_align = 1;
7384 ++ data->d_type = ELF_T_SYM;
7385 ++
7386 ++ sym->idx = symtab->sh.sh_size / sizeof(sym->sym);
7387 ++ elf_dirty_reloc_sym(elf, sym);
7388 ++
7389 ++ symtab->sh.sh_info += 1;
7390 ++ symtab->sh.sh_size += data->d_size;
7391 ++ symtab->changed = true;
7392 ++
7393 ++ if (symtab_shndx) {
7394 ++ s = elf_getscn(elf->elf, symtab_shndx->idx);
7395 ++ if (!s) {
7396 ++ WARN_ELF("elf_getscn");
7397 ++ return -1;
7398 + }
7399 +
7400 +- if (!sym) {
7401 +- WARN("can't find symbol containing %s+0x%lx", insn_sec->name, insn_off);
7402 ++ shndx_data = elf_newdata(s);
7403 ++ if (!shndx_data) {
7404 ++ WARN_ELF("elf_newshndx_data");
7405 + return -1;
7406 + }
7407 +
7408 +- addend = insn_off - sym->offset;
7409 ++ shndx_data->d_buf = &sym->sec->idx;
7410 ++ shndx_data->d_size = sizeof(Elf32_Word);
7411 ++ shndx_data->d_align = 4;
7412 ++ shndx_data->d_type = ELF_T_WORD;
7413 ++
7414 ++ symtab_shndx->sh.sh_size += 4;
7415 ++ symtab_shndx->changed = true;
7416 ++ }
7417 ++
7418 ++ return first_non_local;
7419 ++}
7420 ++
7421 ++static struct symbol *
7422 ++elf_create_section_symbol(struct elf *elf, struct section *sec)
7423 ++{
7424 ++ struct section *symtab, *symtab_shndx;
7425 ++ Elf_Data *shndx_data = NULL;
7426 ++ struct symbol *sym;
7427 ++ Elf32_Word shndx;
7428 ++
7429 ++ symtab = find_section_by_name(elf, ".symtab");
7430 ++ if (symtab) {
7431 ++ symtab_shndx = find_section_by_name(elf, ".symtab_shndx");
7432 ++ if (symtab_shndx)
7433 ++ shndx_data = symtab_shndx->data;
7434 ++ } else {
7435 ++ WARN("no .symtab");
7436 ++ return NULL;
7437 ++ }
7438 ++
7439 ++ sym = malloc(sizeof(*sym));
7440 ++ if (!sym) {
7441 ++ perror("malloc");
7442 ++ return NULL;
7443 ++ }
7444 ++ memset(sym, 0, sizeof(*sym));
7445 ++
7446 ++ sym->idx = elf_move_global_symbol(elf, symtab, symtab_shndx);
7447 ++ if (sym->idx < 0) {
7448 ++ WARN("elf_move_global_symbol");
7449 ++ return NULL;
7450 ++ }
7451 ++
7452 ++ sym->name = sec->name;
7453 ++ sym->sec = sec;
7454 ++
7455 ++ // st_name 0
7456 ++ sym->sym.st_info = GELF_ST_INFO(STB_LOCAL, STT_SECTION);
7457 ++ // st_other 0
7458 ++ // st_value 0
7459 ++ // st_size 0
7460 ++ shndx = sec->idx;
7461 ++ if (shndx >= SHN_UNDEF && shndx < SHN_LORESERVE) {
7462 ++ sym->sym.st_shndx = shndx;
7463 ++ if (!shndx_data)
7464 ++ shndx = 0;
7465 ++ } else {
7466 ++ sym->sym.st_shndx = SHN_XINDEX;
7467 ++ if (!shndx_data) {
7468 ++ WARN("no .symtab_shndx");
7469 ++ return NULL;
7470 ++ }
7471 ++ }
7472 ++
7473 ++ if (!gelf_update_symshndx(symtab->data, shndx_data, sym->idx, &sym->sym, shndx)) {
7474 ++ WARN_ELF("gelf_update_symshndx");
7475 ++ return NULL;
7476 ++ }
7477 ++
7478 ++ elf_add_symbol(elf, sym);
7479 ++
7480 ++ return sym;
7481 ++}
7482 ++
7483 ++int elf_add_reloc_to_insn(struct elf *elf, struct section *sec,
7484 ++ unsigned long offset, unsigned int type,
7485 ++ struct section *insn_sec, unsigned long insn_off)
7486 ++{
7487 ++ struct symbol *sym = insn_sec->sym;
7488 ++ int addend = insn_off;
7489 ++
7490 ++ if (!sym) {
7491 ++ /*
7492 ++ * Due to how weak functions work, we must use section based
7493 ++ * relocations. Symbol based relocations would result in the
7494 ++ * weak and non-weak function annotations being overlaid on the
7495 ++ * non-weak function after linking.
7496 ++ */
7497 ++ sym = elf_create_section_symbol(elf, insn_sec);
7498 ++ if (!sym)
7499 ++ return -1;
7500 ++
7501 ++ insn_sec->sym = sym;
7502 + }
7503 +
7504 + return elf_add_reloc(elf, sec, offset, type, sym, addend);
7505 +diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
7506 +index d223367814017..18a26e3c13290 100644
7507 +--- a/tools/objtool/include/objtool/elf.h
7508 ++++ b/tools/objtool/include/objtool/elf.h
7509 +@@ -73,7 +73,7 @@ struct reloc {
7510 + struct symbol *sym;
7511 + unsigned long offset;
7512 + unsigned int type;
7513 +- int addend;
7514 ++ long addend;
7515 + int idx;
7516 + bool jump_table_start;
7517 + };
7518 +@@ -135,7 +135,7 @@ struct elf *elf_open_read(const char *name, int flags);
7519 + struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr);
7520 +
7521 + int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
7522 +- unsigned int type, struct symbol *sym, int addend);
7523 ++ unsigned int type, struct symbol *sym, long addend);
7524 + int elf_add_reloc_to_insn(struct elf *elf, struct section *sec,
7525 + unsigned long offset, unsigned int type,
7526 + struct section *insn_sec, unsigned long insn_off);
7527 +diff --git a/tools/perf/arch/arm64/util/machine.c b/tools/perf/arch/arm64/util/machine.c
7528 +index d2ce31e28cd79..41c1596e52071 100644
7529 +--- a/tools/perf/arch/arm64/util/machine.c
7530 ++++ b/tools/perf/arch/arm64/util/machine.c
7531 +@@ -8,27 +8,6 @@
7532 + #include "callchain.h"
7533 + #include "record.h"
7534 +
7535 +-/* On arm64, kernel text segment starts at high memory address,
7536 +- * for example 0xffff 0000 8xxx xxxx. Modules start at a low memory
7537 +- * address, like 0xffff 0000 00ax xxxx. When only small amount of
7538 +- * memory is used by modules, gap between end of module's text segment
7539 +- * and start of kernel text segment may reach 2G.
7540 +- * Therefore do not fill this gap and do not assign it to the kernel dso map.
7541 +- */
7542 +-
7543 +-#define SYMBOL_LIMIT (1 << 12) /* 4K */
7544 +-
7545 +-void arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
7546 +-{
7547 +- if ((strchr(p->name, '[') && strchr(c->name, '[') == NULL) ||
7548 +- (strchr(p->name, '[') == NULL && strchr(c->name, '[')))
7549 +- /* Limit range of last symbol in module and kernel */
7550 +- p->end += SYMBOL_LIMIT;
7551 +- else
7552 +- p->end = c->start;
7553 +- pr_debug4("%s sym:%s end:%#" PRIx64 "\n", __func__, p->name, p->end);
7554 +-}
7555 +-
7556 + void arch__add_leaf_frame_record_opts(struct record_opts *opts)
7557 + {
7558 + opts->sample_user_regs |= sample_reg_masks[PERF_REG_ARM64_LR].mask;
7559 +diff --git a/tools/perf/arch/powerpc/util/Build b/tools/perf/arch/powerpc/util/Build
7560 +index 8a79c4126e5b4..0115f31665684 100644
7561 +--- a/tools/perf/arch/powerpc/util/Build
7562 ++++ b/tools/perf/arch/powerpc/util/Build
7563 +@@ -1,5 +1,4 @@
7564 + perf-y += header.o
7565 +-perf-y += machine.o
7566 + perf-y += kvm-stat.o
7567 + perf-y += perf_regs.o
7568 + perf-y += mem-events.o
7569 +diff --git a/tools/perf/arch/powerpc/util/machine.c b/tools/perf/arch/powerpc/util/machine.c
7570 +deleted file mode 100644
7571 +index e652a1aa81322..0000000000000
7572 +--- a/tools/perf/arch/powerpc/util/machine.c
7573 ++++ /dev/null
7574 +@@ -1,25 +0,0 @@
7575 +-// SPDX-License-Identifier: GPL-2.0
7576 +-
7577 +-#include <inttypes.h>
7578 +-#include <stdio.h>
7579 +-#include <string.h>
7580 +-#include <internal/lib.h> // page_size
7581 +-#include "debug.h"
7582 +-#include "symbol.h"
7583 +-
7584 +-/* On powerpc kernel text segment start at memory addresses, 0xc000000000000000
7585 +- * whereas the modules are located at very high memory addresses,
7586 +- * for example 0xc00800000xxxxxxx. The gap between end of kernel text segment
7587 +- * and beginning of first module's text segment is very high.
7588 +- * Therefore do not fill this gap and do not assign it to the kernel dso map.
7589 +- */
7590 +-
7591 +-void arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
7592 +-{
7593 +- if (strchr(p->name, '[') == NULL && strchr(c->name, '['))
7594 +- /* Limit the range of last kernel symbol */
7595 +- p->end += page_size;
7596 +- else
7597 +- p->end = c->start;
7598 +- pr_debug4("%s sym:%s end:%#" PRIx64 "\n", __func__, p->name, p->end);
7599 +-}
7600 +diff --git a/tools/perf/arch/s390/util/machine.c b/tools/perf/arch/s390/util/machine.c
7601 +index 7644a4f6d4a40..98bc3f39d5f35 100644
7602 +--- a/tools/perf/arch/s390/util/machine.c
7603 ++++ b/tools/perf/arch/s390/util/machine.c
7604 +@@ -35,19 +35,3 @@ int arch__fix_module_text_start(u64 *start, u64 *size, const char *name)
7605 +
7606 + return 0;
7607 + }
7608 +-
7609 +-/* On s390 kernel text segment start is located at very low memory addresses,
7610 +- * for example 0x10000. Modules are located at very high memory addresses,
7611 +- * for example 0x3ff xxxx xxxx. The gap between end of kernel text segment
7612 +- * and beginning of first module's text segment is very big.
7613 +- * Therefore do not fill this gap and do not assign it to the kernel dso map.
7614 +- */
7615 +-void arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
7616 +-{
7617 +- if (strchr(p->name, '[') == NULL && strchr(c->name, '['))
7618 +- /* Last kernel symbol mapped to end of page */
7619 +- p->end = roundup(p->end, page_size);
7620 +- else
7621 +- p->end = c->start;
7622 +- pr_debug4("%s sym:%s end:%#" PRIx64 "\n", __func__, p->name, p->end);
7623 +-}
7624 +diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
7625 +index d2b64e3f588b2..151cc38a171cf 100644
7626 +--- a/tools/perf/util/arm-spe.c
7627 ++++ b/tools/perf/util/arm-spe.c
7628 +@@ -1036,7 +1036,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session)
7629 + attr.sample_type = evsel->core.attr.sample_type & PERF_SAMPLE_MASK;
7630 + attr.sample_type |= PERF_SAMPLE_IP | PERF_SAMPLE_TID |
7631 + PERF_SAMPLE_PERIOD | PERF_SAMPLE_DATA_SRC |
7632 +- PERF_SAMPLE_WEIGHT;
7633 ++ PERF_SAMPLE_WEIGHT | PERF_SAMPLE_ADDR;
7634 + if (spe->timeless_decoding)
7635 + attr.sample_type &= ~(u64)PERF_SAMPLE_TIME;
7636 + else
7637 +diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
7638 +index 31cd59a2b66e6..ecd377938eea8 100644
7639 +--- a/tools/perf/util/symbol-elf.c
7640 ++++ b/tools/perf/util/symbol-elf.c
7641 +@@ -1290,7 +1290,7 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
7642 + * For misannotated, zeroed, ASM function sizes.
7643 + */
7644 + if (nr > 0) {
7645 +- symbols__fixup_end(&dso->symbols);
7646 ++ symbols__fixup_end(&dso->symbols, false);
7647 + symbols__fixup_duplicate(&dso->symbols);
7648 + if (kmap) {
7649 + /*
7650 +diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
7651 +index dfde9eada224a..24dd8c08e901f 100644
7652 +--- a/tools/perf/util/symbol.c
7653 ++++ b/tools/perf/util/symbol.c
7654 +@@ -101,11 +101,6 @@ static int prefix_underscores_count(const char *str)
7655 + return tail - str;
7656 + }
7657 +
7658 +-void __weak arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
7659 +-{
7660 +- p->end = c->start;
7661 +-}
7662 +-
7663 + const char * __weak arch__normalize_symbol_name(const char *name)
7664 + {
7665 + return name;
7666 +@@ -217,7 +212,8 @@ again:
7667 + }
7668 + }
7669 +
7670 +-void symbols__fixup_end(struct rb_root_cached *symbols)
7671 ++/* Update zero-sized symbols using the address of the next symbol */
7672 ++void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms)
7673 + {
7674 + struct rb_node *nd, *prevnd = rb_first_cached(symbols);
7675 + struct symbol *curr, *prev;
7676 +@@ -231,8 +227,29 @@ void symbols__fixup_end(struct rb_root_cached *symbols)
7677 + prev = curr;
7678 + curr = rb_entry(nd, struct symbol, rb_node);
7679 +
7680 +- if (prev->end == prev->start || prev->end != curr->start)
7681 +- arch__symbols__fixup_end(prev, curr);
7682 ++ /*
7683 ++ * On some architecture kernel text segment start is located at
7684 ++ * some low memory address, while modules are located at high
7685 ++ * memory addresses (or vice versa). The gap between end of
7686 ++ * kernel text segment and beginning of first module's text
7687 ++ * segment is very big. Therefore do not fill this gap and do
7688 ++ * not assign it to the kernel dso map (kallsyms).
7689 ++ *
7690 ++ * In kallsyms, it determines module symbols using '[' character
7691 ++ * like in:
7692 ++ * ffffffffc1937000 T hdmi_driver_init [snd_hda_codec_hdmi]
7693 ++ */
7694 ++ if (prev->end == prev->start) {
7695 ++ /* Last kernel/module symbol mapped to end of page */
7696 ++ if (is_kallsyms && (!strchr(prev->name, '[') !=
7697 ++ !strchr(curr->name, '[')))
7698 ++ prev->end = roundup(prev->end + 4096, 4096);
7699 ++ else
7700 ++ prev->end = curr->start;
7701 ++
7702 ++ pr_debug4("%s sym:%s end:%#" PRIx64 "\n",
7703 ++ __func__, prev->name, prev->end);
7704 ++ }
7705 + }
7706 +
7707 + /* Last entry */
7708 +@@ -1467,7 +1484,7 @@ int __dso__load_kallsyms(struct dso *dso, const char *filename,
7709 + if (kallsyms__delta(kmap, filename, &delta))
7710 + return -1;
7711 +
7712 +- symbols__fixup_end(&dso->symbols);
7713 ++ symbols__fixup_end(&dso->symbols, true);
7714 + symbols__fixup_duplicate(&dso->symbols);
7715 +
7716 + if (dso->kernel == DSO_SPACE__KERNEL_GUEST)
7717 +@@ -1659,7 +1676,7 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
7718 + #undef bfd_asymbol_section
7719 + #endif
7720 +
7721 +- symbols__fixup_end(&dso->symbols);
7722 ++ symbols__fixup_end(&dso->symbols, false);
7723 + symbols__fixup_duplicate(&dso->symbols);
7724 + dso->adjust_symbols = 1;
7725 +
7726 +diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
7727 +index fbf866d82dccd..0b893dcc8ea68 100644
7728 +--- a/tools/perf/util/symbol.h
7729 ++++ b/tools/perf/util/symbol.h
7730 +@@ -203,7 +203,7 @@ void __symbols__insert(struct rb_root_cached *symbols, struct symbol *sym,
7731 + bool kernel);
7732 + void symbols__insert(struct rb_root_cached *symbols, struct symbol *sym);
7733 + void symbols__fixup_duplicate(struct rb_root_cached *symbols);
7734 +-void symbols__fixup_end(struct rb_root_cached *symbols);
7735 ++void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms);
7736 + void maps__fixup_end(struct maps *maps);
7737 +
7738 + typedef int (*mapfn_t)(u64 start, u64 len, u64 pgoff, void *data);
7739 +@@ -241,7 +241,6 @@ const char *arch__normalize_symbol_name(const char *name);
7740 + #define SYMBOL_A 0
7741 + #define SYMBOL_B 1
7742 +
7743 +-void arch__symbols__fixup_end(struct symbol *p, struct symbol *c);
7744 + int arch__compare_symbol_names(const char *namea, const char *nameb);
7745 + int arch__compare_symbol_names_n(const char *namea, const char *nameb,
7746 + unsigned int n);
7747 +diff --git a/tools/testing/selftests/vm/mremap_test.c b/tools/testing/selftests/vm/mremap_test.c
7748 +index 7c0b0617b9f85..58775dab3cc6c 100644
7749 +--- a/tools/testing/selftests/vm/mremap_test.c
7750 ++++ b/tools/testing/selftests/vm/mremap_test.c
7751 +@@ -6,9 +6,11 @@
7752 +
7753 + #include <errno.h>
7754 + #include <stdlib.h>
7755 ++#include <stdio.h>
7756 + #include <string.h>
7757 + #include <sys/mman.h>
7758 + #include <time.h>
7759 ++#include <stdbool.h>
7760 +
7761 + #include "../kselftest.h"
7762 +
7763 +@@ -63,6 +65,59 @@ enum {
7764 + .expect_failure = should_fail \
7765 + }
7766 +
7767 ++/*
7768 ++ * Returns false if the requested remap region overlaps with an
7769 ++ * existing mapping (e.g text, stack) else returns true.
7770 ++ */
7771 ++static bool is_remap_region_valid(void *addr, unsigned long long size)
7772 ++{
7773 ++ void *remap_addr = NULL;
7774 ++ bool ret = true;
7775 ++
7776 ++ /* Use MAP_FIXED_NOREPLACE flag to ensure region is not mapped */
7777 ++ remap_addr = mmap(addr, size, PROT_READ | PROT_WRITE,
7778 ++ MAP_FIXED_NOREPLACE | MAP_ANONYMOUS | MAP_SHARED,
7779 ++ -1, 0);
7780 ++
7781 ++ if (remap_addr == MAP_FAILED) {
7782 ++ if (errno == EEXIST)
7783 ++ ret = false;
7784 ++ } else {
7785 ++ munmap(remap_addr, size);
7786 ++ }
7787 ++
7788 ++ return ret;
7789 ++}
7790 ++
7791 ++/* Returns mmap_min_addr sysctl tunable from procfs */
7792 ++static unsigned long long get_mmap_min_addr(void)
7793 ++{
7794 ++ FILE *fp;
7795 ++ int n_matched;
7796 ++ static unsigned long long addr;
7797 ++
7798 ++ if (addr)
7799 ++ return addr;
7800 ++
7801 ++ fp = fopen("/proc/sys/vm/mmap_min_addr", "r");
7802 ++ if (fp == NULL) {
7803 ++ ksft_print_msg("Failed to open /proc/sys/vm/mmap_min_addr: %s\n",
7804 ++ strerror(errno));
7805 ++ exit(KSFT_SKIP);
7806 ++ }
7807 ++
7808 ++ n_matched = fscanf(fp, "%llu", &addr);
7809 ++ if (n_matched != 1) {
7810 ++ ksft_print_msg("Failed to read /proc/sys/vm/mmap_min_addr: %s\n",
7811 ++ strerror(errno));
7812 ++ fclose(fp);
7813 ++ exit(KSFT_SKIP);
7814 ++ }
7815 ++
7816 ++ fclose(fp);
7817 ++ return addr;
7818 ++}
7819 ++
7820 + /*
7821 + * Returns the start address of the mapping on success, else returns
7822 + * NULL on failure.
7823 +@@ -71,11 +126,18 @@ static void *get_source_mapping(struct config c)
7824 + {
7825 + unsigned long long addr = 0ULL;
7826 + void *src_addr = NULL;
7827 ++ unsigned long long mmap_min_addr;
7828 ++
7829 ++ mmap_min_addr = get_mmap_min_addr();
7830 ++
7831 + retry:
7832 + addr += c.src_alignment;
7833 ++ if (addr < mmap_min_addr)
7834 ++ goto retry;
7835 ++
7836 + src_addr = mmap((void *) addr, c.region_size, PROT_READ | PROT_WRITE,
7837 +- MAP_FIXED_NOREPLACE | MAP_ANONYMOUS | MAP_SHARED,
7838 +- -1, 0);
7839 ++ MAP_FIXED_NOREPLACE | MAP_ANONYMOUS | MAP_SHARED,
7840 ++ -1, 0);
7841 + if (src_addr == MAP_FAILED) {
7842 + if (errno == EPERM || errno == EEXIST)
7843 + goto retry;
7844 +@@ -90,8 +152,10 @@ retry:
7845 + * alignment in the tests.
7846 + */
7847 + if (((unsigned long long) src_addr & (c.src_alignment - 1)) ||
7848 +- !((unsigned long long) src_addr & c.src_alignment))
7849 ++ !((unsigned long long) src_addr & c.src_alignment)) {
7850 ++ munmap(src_addr, c.region_size);
7851 + goto retry;
7852 ++ }
7853 +
7854 + if (!src_addr)
7855 + goto error;
7856 +@@ -140,9 +204,20 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
7857 + if (!((unsigned long long) addr & c.dest_alignment))
7858 + addr = (void *) ((unsigned long long) addr | c.dest_alignment);
7859 +
7860 ++ /* Don't destroy existing mappings unless expected to overlap */
7861 ++ while (!is_remap_region_valid(addr, c.region_size) && !c.overlapping) {
7862 ++ /* Check for unsigned overflow */
7863 ++ if (addr + c.dest_alignment < addr) {
7864 ++ ksft_print_msg("Couldn't find a valid region to remap to\n");
7865 ++ ret = -1;
7866 ++ goto out;
7867 ++ }
7868 ++ addr += c.dest_alignment;
7869 ++ }
7870 ++
7871 + clock_gettime(CLOCK_MONOTONIC, &t_start);
7872 + dest_addr = mremap(src_addr, c.region_size, c.region_size,
7873 +- MREMAP_MAYMOVE|MREMAP_FIXED, (char *) addr);
7874 ++ MREMAP_MAYMOVE|MREMAP_FIXED, (char *) addr);
7875 + clock_gettime(CLOCK_MONOTONIC, &t_end);
7876 +
7877 + if (dest_addr == MAP_FAILED) {