Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.10 commit in: /
Date: Sat, 18 Sep 2021 16:07:29
Message-Id: 1631981227.dee0860ae0aea5f984943a6421f17e9f1bfe5ab7.mpagano@gentoo
1 commit: dee0860ae0aea5f984943a6421f17e9f1bfe5ab7
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 18 16:07:07 2021 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 18 16:07:07 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=dee0860a
7
8 Linux patch 5.10.67
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1066_linux-5.10.67.patch | 12089 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 12093 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 1521f72..20bba3a 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -307,6 +307,10 @@ Patch: 1065_linux-5.10.66.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.10.66
23
24 +Patch: 1066_linux-5.10.67.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.10.67
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/1066_linux-5.10.67.patch b/1066_linux-5.10.67.patch
33 new file mode 100644
34 index 0000000..3aee0f0
35 --- /dev/null
36 +++ b/1066_linux-5.10.67.patch
37 @@ -0,0 +1,12089 @@
38 +diff --git a/Documentation/admin-guide/devices.txt b/Documentation/admin-guide/devices.txt
39 +index 63fd4e6a014bc..8b738855e1c5a 100644
40 +--- a/Documentation/admin-guide/devices.txt
41 ++++ b/Documentation/admin-guide/devices.txt
42 +@@ -3003,10 +3003,10 @@
43 + 65 = /dev/infiniband/issm1 Second InfiniBand IsSM device
44 + ...
45 + 127 = /dev/infiniband/issm63 63rd InfiniBand IsSM device
46 +- 128 = /dev/infiniband/uverbs0 First InfiniBand verbs device
47 +- 129 = /dev/infiniband/uverbs1 Second InfiniBand verbs device
48 ++ 192 = /dev/infiniband/uverbs0 First InfiniBand verbs device
49 ++ 193 = /dev/infiniband/uverbs1 Second InfiniBand verbs device
50 + ...
51 +- 159 = /dev/infiniband/uverbs31 31st InfiniBand verbs device
52 ++ 223 = /dev/infiniband/uverbs31 31st InfiniBand verbs device
53 +
54 + 232 char Biometric Devices
55 + 0 = /dev/biometric/sensor0/fingerprint first fingerprint sensor on first device
56 +diff --git a/Documentation/devicetree/bindings/pinctrl/marvell,armada-37xx-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/marvell,armada-37xx-pinctrl.txt
57 +index 38dc56a577604..ecec514b31550 100644
58 +--- a/Documentation/devicetree/bindings/pinctrl/marvell,armada-37xx-pinctrl.txt
59 ++++ b/Documentation/devicetree/bindings/pinctrl/marvell,armada-37xx-pinctrl.txt
60 +@@ -43,19 +43,19 @@ group emmc_nb
61 +
62 + group pwm0
63 + - pin 11 (GPIO1-11)
64 +- - functions pwm, gpio
65 ++ - functions pwm, led, gpio
66 +
67 + group pwm1
68 + - pin 12
69 +- - functions pwm, gpio
70 ++ - functions pwm, led, gpio
71 +
72 + group pwm2
73 + - pin 13
74 +- - functions pwm, gpio
75 ++ - functions pwm, led, gpio
76 +
77 + group pwm3
78 + - pin 14
79 +- - functions pwm, gpio
80 ++ - functions pwm, led, gpio
81 +
82 + group pmic1
83 + - pin 7
84 +diff --git a/Makefile b/Makefile
85 +index 8b1f1e7517b94..a47273ecfdf21 100644
86 +--- a/Makefile
87 ++++ b/Makefile
88 +@@ -1,7 +1,7 @@
89 + # SPDX-License-Identifier: GPL-2.0
90 + VERSION = 5
91 + PATCHLEVEL = 10
92 +-SUBLEVEL = 66
93 ++SUBLEVEL = 67
94 + EXTRAVERSION =
95 + NAME = Dare mighty things
96 +
97 +diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
98 +index 0d6ee56f5831e..175213d7a1aa1 100644
99 +--- a/arch/arm/boot/compressed/Makefile
100 ++++ b/arch/arm/boot/compressed/Makefile
101 +@@ -84,6 +84,8 @@ compress-$(CONFIG_KERNEL_LZ4) = lz4
102 + libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o
103 +
104 + ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
105 ++CFLAGS_REMOVE_atags_to_fdt.o += -Wframe-larger-than=${CONFIG_FRAME_WARN}
106 ++CFLAGS_atags_to_fdt.o += -Wframe-larger-than=1280
107 + OBJS += $(libfdt_objs) atags_to_fdt.o
108 + endif
109 +
110 +diff --git a/arch/arm/boot/dts/at91-kizbox3_common.dtsi b/arch/arm/boot/dts/at91-kizbox3_common.dtsi
111 +index 7c3076e245efa..dc77d8e80e567 100644
112 +--- a/arch/arm/boot/dts/at91-kizbox3_common.dtsi
113 ++++ b/arch/arm/boot/dts/at91-kizbox3_common.dtsi
114 +@@ -336,7 +336,7 @@
115 + };
116 +
117 + &shutdown_controller {
118 +- atmel,shdwc-debouncer = <976>;
119 ++ debounce-delay-us = <976>;
120 + atmel,wakeup-rtc-timer;
121 +
122 + input@0 {
123 +diff --git a/arch/arm/boot/dts/at91-sam9x60ek.dts b/arch/arm/boot/dts/at91-sam9x60ek.dts
124 +index ebbc9b23aef1c..b1068cca42287 100644
125 +--- a/arch/arm/boot/dts/at91-sam9x60ek.dts
126 ++++ b/arch/arm/boot/dts/at91-sam9x60ek.dts
127 +@@ -662,7 +662,7 @@
128 + };
129 +
130 + &shutdown_controller {
131 +- atmel,shdwc-debouncer = <976>;
132 ++ debounce-delay-us = <976>;
133 + status = "okay";
134 +
135 + input@0 {
136 +diff --git a/arch/arm/boot/dts/at91-sama5d27_som1_ek.dts b/arch/arm/boot/dts/at91-sama5d27_som1_ek.dts
137 +index d3cd2443ba252..9a18453d78428 100644
138 +--- a/arch/arm/boot/dts/at91-sama5d27_som1_ek.dts
139 ++++ b/arch/arm/boot/dts/at91-sama5d27_som1_ek.dts
140 +@@ -138,7 +138,7 @@
141 + };
142 +
143 + shdwc@f8048010 {
144 +- atmel,shdwc-debouncer = <976>;
145 ++ debounce-delay-us = <976>;
146 + atmel,wakeup-rtc-timer;
147 +
148 + input@0 {
149 +diff --git a/arch/arm/boot/dts/at91-sama5d27_wlsom1_ek.dts b/arch/arm/boot/dts/at91-sama5d27_wlsom1_ek.dts
150 +index 4883b84b4eded..20bcb7480d2ea 100644
151 +--- a/arch/arm/boot/dts/at91-sama5d27_wlsom1_ek.dts
152 ++++ b/arch/arm/boot/dts/at91-sama5d27_wlsom1_ek.dts
153 +@@ -205,7 +205,7 @@
154 + };
155 +
156 + &shutdown_controller {
157 +- atmel,shdwc-debouncer = <976>;
158 ++ debounce-delay-us = <976>;
159 + atmel,wakeup-rtc-timer;
160 +
161 + input@0 {
162 +diff --git a/arch/arm/boot/dts/at91-sama5d2_icp.dts b/arch/arm/boot/dts/at91-sama5d2_icp.dts
163 +index 19bb50f50c1fc..308d472bd1044 100644
164 +--- a/arch/arm/boot/dts/at91-sama5d2_icp.dts
165 ++++ b/arch/arm/boot/dts/at91-sama5d2_icp.dts
166 +@@ -693,7 +693,7 @@
167 + };
168 +
169 + &shutdown_controller {
170 +- atmel,shdwc-debouncer = <976>;
171 ++ debounce-delay-us = <976>;
172 + atmel,wakeup-rtc-timer;
173 +
174 + input@0 {
175 +diff --git a/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts b/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts
176 +index 1c6361ba1aca4..317c6ddb56775 100644
177 +--- a/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts
178 ++++ b/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts
179 +@@ -203,7 +203,7 @@
180 + };
181 +
182 + shdwc@f8048010 {
183 +- atmel,shdwc-debouncer = <976>;
184 ++ debounce-delay-us = <976>;
185 +
186 + input@0 {
187 + reg = <0>;
188 +diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
189 +index d767968ae2175..08c5182ba86bd 100644
190 +--- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
191 ++++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
192 +@@ -347,7 +347,7 @@
193 + };
194 +
195 + shdwc@f8048010 {
196 +- atmel,shdwc-debouncer = <976>;
197 ++ debounce-delay-us = <976>;
198 + atmel,wakeup-rtc-timer;
199 +
200 + input@0 {
201 +diff --git a/arch/arm/boot/dts/imx53-ppd.dts b/arch/arm/boot/dts/imx53-ppd.dts
202 +index f7dcdf96e5c00..6d9a5ede94aaf 100644
203 +--- a/arch/arm/boot/dts/imx53-ppd.dts
204 ++++ b/arch/arm/boot/dts/imx53-ppd.dts
205 +@@ -70,6 +70,12 @@
206 + clock-frequency = <11289600>;
207 + };
208 +
209 ++ achc_24M: achc-clock {
210 ++ compatible = "fixed-clock";
211 ++ #clock-cells = <0>;
212 ++ clock-frequency = <24000000>;
213 ++ };
214 ++
215 + sgtlsound: sound {
216 + compatible = "fsl,imx53-cpuvo-sgtl5000",
217 + "fsl,imx-audio-sgtl5000";
218 +@@ -313,16 +319,13 @@
219 + &gpio4 12 GPIO_ACTIVE_LOW>;
220 + status = "okay";
221 +
222 +- spidev0: spi@0 {
223 +- compatible = "ge,achc";
224 +- reg = <0>;
225 +- spi-max-frequency = <1000000>;
226 +- };
227 +-
228 +- spidev1: spi@1 {
229 +- compatible = "ge,achc";
230 +- reg = <1>;
231 +- spi-max-frequency = <1000000>;
232 ++ spidev0: spi@1 {
233 ++ compatible = "ge,achc", "nxp,kinetis-k20";
234 ++ reg = <1>, <0>;
235 ++ vdd-supply = <&reg_3v3>;
236 ++ vdda-supply = <&reg_3v3>;
237 ++ clocks = <&achc_24M>;
238 ++ reset-gpios = <&gpio3 6 GPIO_ACTIVE_LOW>;
239 + };
240 +
241 + gpioxra0: gpio@2 {
242 +diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi b/arch/arm/boot/dts/qcom-apq8064.dtsi
243 +index 2687c4e890ba8..e36d590e83732 100644
244 +--- a/arch/arm/boot/dts/qcom-apq8064.dtsi
245 ++++ b/arch/arm/boot/dts/qcom-apq8064.dtsi
246 +@@ -1262,9 +1262,9 @@
247 + <&mmcc DSI1_BYTE_CLK>,
248 + <&mmcc DSI_PIXEL_CLK>,
249 + <&mmcc DSI1_ESC_CLK>;
250 +- clock-names = "iface_clk", "bus_clk", "core_mmss_clk",
251 +- "src_clk", "byte_clk", "pixel_clk",
252 +- "core_clk";
253 ++ clock-names = "iface", "bus", "core_mmss",
254 ++ "src", "byte", "pixel",
255 ++ "core";
256 +
257 + assigned-clocks = <&mmcc DSI1_BYTE_SRC>,
258 + <&mmcc DSI1_ESC_SRC>,
259 +diff --git a/arch/arm/boot/dts/stm32mp15xx-dhcom-pdk2.dtsi b/arch/arm/boot/dts/stm32mp15xx-dhcom-pdk2.dtsi
260 +index 633079245601b..fd0cd10cb0931 100644
261 +--- a/arch/arm/boot/dts/stm32mp15xx-dhcom-pdk2.dtsi
262 ++++ b/arch/arm/boot/dts/stm32mp15xx-dhcom-pdk2.dtsi
263 +@@ -172,15 +172,15 @@
264 + sgtl5000_tx_endpoint: endpoint@0 {
265 + reg = <0>;
266 + remote-endpoint = <&sai2a_endpoint>;
267 +- frame-master;
268 +- bitclock-master;
269 ++ frame-master = <&sgtl5000_tx_endpoint>;
270 ++ bitclock-master = <&sgtl5000_tx_endpoint>;
271 + };
272 +
273 + sgtl5000_rx_endpoint: endpoint@1 {
274 + reg = <1>;
275 + remote-endpoint = <&sai2b_endpoint>;
276 +- frame-master;
277 +- bitclock-master;
278 ++ frame-master = <&sgtl5000_rx_endpoint>;
279 ++ bitclock-master = <&sgtl5000_rx_endpoint>;
280 + };
281 + };
282 +
283 +diff --git a/arch/arm/boot/dts/stm32mp15xx-dhcor-avenger96.dtsi b/arch/arm/boot/dts/stm32mp15xx-dhcor-avenger96.dtsi
284 +index ec02cee1dd9b0..944d38b85eef4 100644
285 +--- a/arch/arm/boot/dts/stm32mp15xx-dhcor-avenger96.dtsi
286 ++++ b/arch/arm/boot/dts/stm32mp15xx-dhcor-avenger96.dtsi
287 +@@ -185,8 +185,8 @@
288 + &i2c4 {
289 + hdmi-transmitter@3d {
290 + compatible = "adi,adv7513";
291 +- reg = <0x3d>, <0x2d>, <0x4d>, <0x5d>;
292 +- reg-names = "main", "cec", "edid", "packet";
293 ++ reg = <0x3d>, <0x4d>, <0x2d>, <0x5d>;
294 ++ reg-names = "main", "edid", "cec", "packet";
295 + clocks = <&cec_clock>;
296 + clock-names = "cec";
297 +
298 +@@ -204,8 +204,6 @@
299 + adi,input-depth = <8>;
300 + adi,input-colorspace = "rgb";
301 + adi,input-clock = "1x";
302 +- adi,input-style = <1>;
303 +- adi,input-justification = "evenly";
304 +
305 + ports {
306 + #address-cells = <1>;
307 +diff --git a/arch/arm/boot/dts/stm32mp15xx-dkx.dtsi b/arch/arm/boot/dts/stm32mp15xx-dkx.dtsi
308 +index 93398cfae97ee..47df8ac67cf1a 100644
309 +--- a/arch/arm/boot/dts/stm32mp15xx-dkx.dtsi
310 ++++ b/arch/arm/boot/dts/stm32mp15xx-dkx.dtsi
311 +@@ -212,15 +212,15 @@
312 + cs42l51_tx_endpoint: endpoint@0 {
313 + reg = <0>;
314 + remote-endpoint = <&sai2a_endpoint>;
315 +- frame-master;
316 +- bitclock-master;
317 ++ frame-master = <&cs42l51_tx_endpoint>;
318 ++ bitclock-master = <&cs42l51_tx_endpoint>;
319 + };
320 +
321 + cs42l51_rx_endpoint: endpoint@1 {
322 + reg = <1>;
323 + remote-endpoint = <&sai2b_endpoint>;
324 +- frame-master;
325 +- bitclock-master;
326 ++ frame-master = <&cs42l51_rx_endpoint>;
327 ++ bitclock-master = <&cs42l51_rx_endpoint>;
328 + };
329 + };
330 + };
331 +diff --git a/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts b/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
332 +index 5d0f0fbba1d2e..5dbfb83c1b06b 100644
333 +--- a/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
334 ++++ b/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
335 +@@ -704,7 +704,6 @@
336 + nvidia,xcvr-setup-use-fuses;
337 + nvidia,xcvr-lsfslew = <2>;
338 + nvidia,xcvr-lsrslew = <2>;
339 +- vbus-supply = <&vdd_vbus1>;
340 + };
341 +
342 + usb@c5008000 {
343 +@@ -716,7 +715,7 @@
344 + nvidia,xcvr-setup-use-fuses;
345 + nvidia,xcvr-lsfslew = <2>;
346 + nvidia,xcvr-lsrslew = <2>;
347 +- vbus-supply = <&vdd_vbus3>;
348 ++ vbus-supply = <&vdd_5v0_sys>;
349 + };
350 +
351 + brcm_wifi_pwrseq: wifi-pwrseq {
352 +@@ -967,28 +966,6 @@
353 + vin-supply = <&vdd_5v0_sys>;
354 + };
355 +
356 +- vdd_vbus1: regulator@4 {
357 +- compatible = "regulator-fixed";
358 +- regulator-name = "vdd_usb1_vbus";
359 +- regulator-min-microvolt = <5000000>;
360 +- regulator-max-microvolt = <5000000>;
361 +- regulator-always-on;
362 +- gpio = <&gpio TEGRA_GPIO(D, 0) GPIO_ACTIVE_HIGH>;
363 +- enable-active-high;
364 +- vin-supply = <&vdd_5v0_sys>;
365 +- };
366 +-
367 +- vdd_vbus3: regulator@5 {
368 +- compatible = "regulator-fixed";
369 +- regulator-name = "vdd_usb3_vbus";
370 +- regulator-min-microvolt = <5000000>;
371 +- regulator-max-microvolt = <5000000>;
372 +- regulator-always-on;
373 +- gpio = <&gpio TEGRA_GPIO(D, 3) GPIO_ACTIVE_HIGH>;
374 +- enable-active-high;
375 +- vin-supply = <&vdd_5v0_sys>;
376 +- };
377 +-
378 + sound {
379 + compatible = "nvidia,tegra-audio-wm8903-picasso",
380 + "nvidia,tegra-audio-wm8903";
381 +diff --git a/arch/arm/boot/dts/tegra20-tamonten.dtsi b/arch/arm/boot/dts/tegra20-tamonten.dtsi
382 +index 95e6bccdb4f6e..dd4d506683de7 100644
383 +--- a/arch/arm/boot/dts/tegra20-tamonten.dtsi
384 ++++ b/arch/arm/boot/dts/tegra20-tamonten.dtsi
385 +@@ -185,8 +185,9 @@
386 + nvidia,pins = "ata", "atb", "atc", "atd", "ate",
387 + "cdev1", "cdev2", "dap1", "dtb", "gma",
388 + "gmb", "gmc", "gmd", "gme", "gpu7",
389 +- "gpv", "i2cp", "pta", "rm", "slxa",
390 +- "slxk", "spia", "spib", "uac";
391 ++ "gpv", "i2cp", "irrx", "irtx", "pta",
392 ++ "rm", "slxa", "slxk", "spia", "spib",
393 ++ "uac";
394 + nvidia,pull = <TEGRA_PIN_PULL_NONE>;
395 + nvidia,tristate = <TEGRA_PIN_DISABLE>;
396 + };
397 +@@ -211,7 +212,7 @@
398 + conf_ddc {
399 + nvidia,pins = "ddc", "dta", "dtd", "kbca",
400 + "kbcb", "kbcc", "kbcd", "kbce", "kbcf",
401 +- "sdc";
402 ++ "sdc", "uad", "uca";
403 + nvidia,pull = <TEGRA_PIN_PULL_UP>;
404 + nvidia,tristate = <TEGRA_PIN_DISABLE>;
405 + };
406 +@@ -221,10 +222,9 @@
407 + "lvp0", "owc", "sdb";
408 + nvidia,tristate = <TEGRA_PIN_ENABLE>;
409 + };
410 +- conf_irrx {
411 +- nvidia,pins = "irrx", "irtx", "sdd", "spic",
412 +- "spie", "spih", "uaa", "uab", "uad",
413 +- "uca", "ucb";
414 ++ conf_sdd {
415 ++ nvidia,pins = "sdd", "spic", "spie", "spih",
416 ++ "uaa", "uab", "ucb";
417 + nvidia,pull = <TEGRA_PIN_PULL_UP>;
418 + nvidia,tristate = <TEGRA_PIN_ENABLE>;
419 + };
420 +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts b/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
421 +index be81330db14f6..02641191682e0 100644
422 +--- a/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
423 ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
424 +@@ -32,14 +32,14 @@
425 + };
426 + };
427 +
428 +- reg_vcc3v3: vcc3v3 {
429 ++ reg_vcc3v3: regulator-vcc3v3 {
430 + compatible = "regulator-fixed";
431 + regulator-name = "vcc3v3";
432 + regulator-min-microvolt = <3300000>;
433 + regulator-max-microvolt = <3300000>;
434 + };
435 +
436 +- reg_vdd_cpu_gpu: vdd-cpu-gpu {
437 ++ reg_vdd_cpu_gpu: regulator-vdd-cpu-gpu {
438 + compatible = "regulator-fixed";
439 + regulator-name = "vdd-cpu-gpu";
440 + regulator-min-microvolt = <1135000>;
441 +diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1046a-frwy.dts b/arch/arm64/boot/dts/freescale/fsl-ls1046a-frwy.dts
442 +index db3d303093f61..6d22efbd645cb 100644
443 +--- a/arch/arm64/boot/dts/freescale/fsl-ls1046a-frwy.dts
444 ++++ b/arch/arm64/boot/dts/freescale/fsl-ls1046a-frwy.dts
445 +@@ -83,15 +83,9 @@
446 + };
447 +
448 + eeprom@52 {
449 +- compatible = "atmel,24c512";
450 ++ compatible = "onnn,cat24c04", "atmel,24c04";
451 + reg = <0x52>;
452 + };
453 +-
454 +- eeprom@53 {
455 +- compatible = "atmel,24c512";
456 +- reg = <0x53>;
457 +- };
458 +-
459 + };
460 + };
461 + };
462 +diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1046a-rdb.dts b/arch/arm64/boot/dts/freescale/fsl-ls1046a-rdb.dts
463 +index d53ccc56bb639..07139e35686d7 100644
464 +--- a/arch/arm64/boot/dts/freescale/fsl-ls1046a-rdb.dts
465 ++++ b/arch/arm64/boot/dts/freescale/fsl-ls1046a-rdb.dts
466 +@@ -58,14 +58,9 @@
467 + };
468 +
469 + eeprom@52 {
470 +- compatible = "atmel,24c512";
471 ++ compatible = "onnn,cat24c05", "atmel,24c04";
472 + reg = <0x52>;
473 + };
474 +-
475 +- eeprom@53 {
476 +- compatible = "atmel,24c512";
477 +- reg = <0x53>;
478 +- };
479 + };
480 +
481 + &i2c3 {
482 +diff --git a/arch/arm64/boot/dts/nvidia/tegra132.dtsi b/arch/arm64/boot/dts/nvidia/tegra132.dtsi
483 +index e40281510c0c0..b14e9f3bfdbdc 100644
484 +--- a/arch/arm64/boot/dts/nvidia/tegra132.dtsi
485 ++++ b/arch/arm64/boot/dts/nvidia/tegra132.dtsi
486 +@@ -1215,13 +1215,13 @@
487 +
488 + cpu@0 {
489 + device_type = "cpu";
490 +- compatible = "nvidia,denver";
491 ++ compatible = "nvidia,tegra132-denver";
492 + reg = <0>;
493 + };
494 +
495 + cpu@1 {
496 + device_type = "cpu";
497 +- compatible = "nvidia,denver";
498 ++ compatible = "nvidia,tegra132-denver";
499 + reg = <1>;
500 + };
501 + };
502 +diff --git a/arch/arm64/boot/dts/nvidia/tegra194.dtsi b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
503 +index 6946fb210e484..9b5007e5f790f 100644
504 +--- a/arch/arm64/boot/dts/nvidia/tegra194.dtsi
505 ++++ b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
506 +@@ -1976,7 +1976,7 @@
507 + };
508 +
509 + pcie_ep@14160000 {
510 +- compatible = "nvidia,tegra194-pcie-ep", "snps,dw-pcie-ep";
511 ++ compatible = "nvidia,tegra194-pcie-ep";
512 + power-domains = <&bpmp TEGRA194_POWER_DOMAIN_PCIEX4A>;
513 + reg = <0x00 0x14160000 0x0 0x00020000>, /* appl registers (128K) */
514 + <0x00 0x36040000 0x0 0x00040000>, /* iATU_DMA reg space (256K) */
515 +@@ -2008,7 +2008,7 @@
516 + };
517 +
518 + pcie_ep@14180000 {
519 +- compatible = "nvidia,tegra194-pcie-ep", "snps,dw-pcie-ep";
520 ++ compatible = "nvidia,tegra194-pcie-ep";
521 + power-domains = <&bpmp TEGRA194_POWER_DOMAIN_PCIEX8B>;
522 + reg = <0x00 0x14180000 0x0 0x00020000>, /* appl registers (128K) */
523 + <0x00 0x38040000 0x0 0x00040000>, /* iATU_DMA reg space (256K) */
524 +@@ -2040,7 +2040,7 @@
525 + };
526 +
527 + pcie_ep@141a0000 {
528 +- compatible = "nvidia,tegra194-pcie-ep", "snps,dw-pcie-ep";
529 ++ compatible = "nvidia,tegra194-pcie-ep";
530 + power-domains = <&bpmp TEGRA194_POWER_DOMAIN_PCIEX8A>;
531 + reg = <0x00 0x141a0000 0x0 0x00020000>, /* appl registers (128K) */
532 + <0x00 0x3a040000 0x0 0x00040000>, /* iATU_DMA reg space (256K) */
533 +diff --git a/arch/arm64/boot/dts/qcom/ipq6018.dtsi b/arch/arm64/boot/dts/qcom/ipq6018.dtsi
534 +index cdc1e3d60c58e..3ceb36cac512f 100644
535 +--- a/arch/arm64/boot/dts/qcom/ipq6018.dtsi
536 ++++ b/arch/arm64/boot/dts/qcom/ipq6018.dtsi
537 +@@ -151,7 +151,7 @@
538 + #size-cells = <2>;
539 + ranges;
540 +
541 +- rpm_msg_ram: memory@0x60000 {
542 ++ rpm_msg_ram: memory@60000 {
543 + reg = <0x0 0x60000 0x0 0x6000>;
544 + no-map;
545 + };
546 +diff --git a/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts b/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts
547 +index e8c37a1693d3b..cc08dc4eb56a5 100644
548 +--- a/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts
549 ++++ b/arch/arm64/boot/dts/qcom/ipq8074-hk01.dts
550 +@@ -20,7 +20,7 @@
551 + stdout-path = "serial0";
552 + };
553 +
554 +- memory {
555 ++ memory@40000000 {
556 + device_type = "memory";
557 + reg = <0x0 0x40000000 0x0 0x20000000>;
558 + };
559 +diff --git a/arch/arm64/boot/dts/qcom/ipq8074.dtsi b/arch/arm64/boot/dts/qcom/ipq8074.dtsi
560 +index 829e37ac82f66..776a6b0f61a62 100644
561 +--- a/arch/arm64/boot/dts/qcom/ipq8074.dtsi
562 ++++ b/arch/arm64/boot/dts/qcom/ipq8074.dtsi
563 +@@ -567,10 +567,10 @@
564 +
565 + pcie1: pci@10000000 {
566 + compatible = "qcom,pcie-ipq8074";
567 +- reg = <0x10000000 0xf1d
568 +- 0x10000f20 0xa8
569 +- 0x00088000 0x2000
570 +- 0x10100000 0x1000>;
571 ++ reg = <0x10000000 0xf1d>,
572 ++ <0x10000f20 0xa8>,
573 ++ <0x00088000 0x2000>,
574 ++ <0x10100000 0x1000>;
575 + reg-names = "dbi", "elbi", "parf", "config";
576 + device_type = "pci";
577 + linux,pci-domain = <1>;
578 +@@ -629,10 +629,10 @@
579 +
580 + pcie0: pci@20000000 {
581 + compatible = "qcom,pcie-ipq8074";
582 +- reg = <0x20000000 0xf1d
583 +- 0x20000f20 0xa8
584 +- 0x00080000 0x2000
585 +- 0x20100000 0x1000>;
586 ++ reg = <0x20000000 0xf1d>,
587 ++ <0x20000f20 0xa8>,
588 ++ <0x00080000 0x2000>,
589 ++ <0x20100000 0x1000>;
590 + reg-names = "dbi", "elbi", "parf", "config";
591 + device_type = "pci";
592 + linux,pci-domain = <0>;
593 +diff --git a/arch/arm64/boot/dts/qcom/msm8994.dtsi b/arch/arm64/boot/dts/qcom/msm8994.dtsi
594 +index 6707f898607fe..45f9a44326a6d 100644
595 +--- a/arch/arm64/boot/dts/qcom/msm8994.dtsi
596 ++++ b/arch/arm64/boot/dts/qcom/msm8994.dtsi
597 +@@ -14,16 +14,18 @@
598 + chosen { };
599 +
600 + clocks {
601 +- xo_board: xo_board {
602 ++ xo_board: xo-board {
603 + compatible = "fixed-clock";
604 + #clock-cells = <0>;
605 + clock-frequency = <19200000>;
606 ++ clock-output-names = "xo_board";
607 + };
608 +
609 +- sleep_clk: sleep_clk {
610 ++ sleep_clk: sleep-clk {
611 + compatible = "fixed-clock";
612 + #clock-cells = <0>;
613 + clock-frequency = <32768>;
614 ++ clock-output-names = "sleep_clk";
615 + };
616 + };
617 +
618 +diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi
619 +index fd6ae5464dea4..eef17434d12ae 100644
620 +--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
621 ++++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
622 +@@ -17,14 +17,14 @@
623 + chosen { };
624 +
625 + clocks {
626 +- xo_board: xo_board {
627 ++ xo_board: xo-board {
628 + compatible = "fixed-clock";
629 + #clock-cells = <0>;
630 + clock-frequency = <19200000>;
631 + clock-output-names = "xo_board";
632 + };
633 +
634 +- sleep_clk: sleep_clk {
635 ++ sleep_clk: sleep-clk {
636 + compatible = "fixed-clock";
637 + #clock-cells = <0>;
638 + clock-frequency = <32764>;
639 +diff --git a/arch/arm64/boot/dts/qcom/sdm630.dtsi b/arch/arm64/boot/dts/qcom/sdm630.dtsi
640 +index deb928d303c22..f87054575ce7f 100644
641 +--- a/arch/arm64/boot/dts/qcom/sdm630.dtsi
642 ++++ b/arch/arm64/boot/dts/qcom/sdm630.dtsi
643 +@@ -17,14 +17,14 @@
644 + chosen { };
645 +
646 + clocks {
647 +- xo_board: xo_board {
648 ++ xo_board: xo-board {
649 + compatible = "fixed-clock";
650 + #clock-cells = <0>;
651 + clock-frequency = <19200000>;
652 + clock-output-names = "xo_board";
653 + };
654 +
655 +- sleep_clk: sleep_clk {
656 ++ sleep_clk: sleep-clk {
657 + compatible = "fixed-clock";
658 + #clock-cells = <0>;
659 + clock-frequency = <32764>;
660 +@@ -343,10 +343,19 @@
661 + };
662 +
663 + qhee_code: qhee-code@85800000 {
664 +- reg = <0x0 0x85800000 0x0 0x3700000>;
665 ++ reg = <0x0 0x85800000 0x0 0x600000>;
666 + no-map;
667 + };
668 +
669 ++ rmtfs_mem: memory@85e00000 {
670 ++ compatible = "qcom,rmtfs-mem";
671 ++ reg = <0x0 0x85e00000 0x0 0x200000>;
672 ++ no-map;
673 ++
674 ++ qcom,client-id = <1>;
675 ++ qcom,vmid = <15>;
676 ++ };
677 ++
678 + smem_region: smem-mem@86000000 {
679 + reg = <0 0x86000000 0 0x200000>;
680 + no-map;
681 +@@ -357,58 +366,44 @@
682 + no-map;
683 + };
684 +
685 +- modem_fw_mem: modem-fw-region@8ac00000 {
686 ++ mpss_region: mpss@8ac00000 {
687 + reg = <0x0 0x8ac00000 0x0 0x7e00000>;
688 + no-map;
689 + };
690 +
691 +- adsp_fw_mem: adsp-fw-region@92a00000 {
692 ++ adsp_region: adsp@92a00000 {
693 + reg = <0x0 0x92a00000 0x0 0x1e00000>;
694 + no-map;
695 + };
696 +
697 +- pil_mba_mem: pil-mba-region@94800000 {
698 ++ mba_region: mba@94800000 {
699 + reg = <0x0 0x94800000 0x0 0x200000>;
700 + no-map;
701 + };
702 +
703 +- buffer_mem: buffer-region@94a00000 {
704 ++ buffer_mem: tzbuffer@94a00000 {
705 + reg = <0x0 0x94a00000 0x0 0x100000>;
706 + no-map;
707 + };
708 +
709 +- venus_fw_mem: venus-fw-region@9f800000 {
710 ++ venus_region: venus@9f800000 {
711 + reg = <0x0 0x9f800000 0x0 0x800000>;
712 + no-map;
713 + };
714 +
715 +- secure_region2: secure-region2@f7c00000 {
716 +- reg = <0x0 0xf7c00000 0x0 0x5c00000>;
717 +- no-map;
718 +- };
719 +-
720 + adsp_mem: adsp-region@f6000000 {
721 + reg = <0x0 0xf6000000 0x0 0x800000>;
722 + no-map;
723 + };
724 +
725 +- qseecom_ta_mem: qseecom-ta-region@fec00000 {
726 +- reg = <0x0 0xfec00000 0x0 0x1000000>;
727 +- no-map;
728 +- };
729 +-
730 + qseecom_mem: qseecom-region@f6800000 {
731 + reg = <0x0 0xf6800000 0x0 0x1400000>;
732 + no-map;
733 + };
734 +
735 +- secure_display_memory: secure-region@f5c00000 {
736 +- reg = <0x0 0xf5c00000 0x0 0x5c00000>;
737 +- no-map;
738 +- };
739 +-
740 +- cont_splash_mem: cont-splash-region@9d400000 {
741 +- reg = <0x0 0x9d400000 0x0 0x23ff000>;
742 ++ zap_shader_region: gpu@fed00000 {
743 ++ compatible = "shared-dma-pool";
744 ++ reg = <0x0 0xfed00000 0x0 0xa00000>;
745 + no-map;
746 + };
747 + };
748 +@@ -527,14 +522,18 @@
749 + reg = <0x01f40000 0x20000>;
750 + };
751 +
752 +- tlmm: pinctrl@3000000 {
753 ++ tlmm: pinctrl@3100000 {
754 + compatible = "qcom,sdm630-pinctrl";
755 +- reg = <0x03000000 0xc00000>;
756 ++ reg = <0x03100000 0x400000>,
757 ++ <0x03500000 0x400000>,
758 ++ <0x03900000 0x400000>;
759 ++ reg-names = "south", "center", "north";
760 + interrupts = <GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH>;
761 + gpio-controller;
762 +- #gpio-cells = <0x2>;
763 ++ gpio-ranges = <&tlmm 0 0 114>;
764 ++ #gpio-cells = <2>;
765 + interrupt-controller;
766 +- #interrupt-cells = <0x2>;
767 ++ #interrupt-cells = <2>;
768 +
769 + blsp1_uart1_default: blsp1-uart1-default {
770 + pins = "gpio0", "gpio1", "gpio2", "gpio3";
771 +@@ -554,40 +553,48 @@
772 + bias-disable;
773 + };
774 +
775 +- blsp2_uart1_tx_active: blsp2-uart1-tx-active {
776 +- pins = "gpio16";
777 +- drive-strength = <2>;
778 +- bias-disable;
779 +- };
780 +-
781 +- blsp2_uart1_tx_sleep: blsp2-uart1-tx-sleep {
782 +- pins = "gpio16";
783 +- drive-strength = <2>;
784 +- bias-pull-up;
785 +- };
786 ++ blsp2_uart1_default: blsp2-uart1-active {
787 ++ tx-rts {
788 ++ pins = "gpio16", "gpio19";
789 ++ function = "blsp_uart5";
790 ++ drive-strength = <2>;
791 ++ bias-disable;
792 ++ };
793 +
794 +- blsp2_uart1_rxcts_active: blsp2-uart1-rxcts-active {
795 +- pins = "gpio17", "gpio18";
796 +- drive-strength = <2>;
797 +- bias-disable;
798 +- };
799 ++ rx {
800 ++ /*
801 ++ * Avoid garbage data while BT module
802 ++ * is powered off or not driving signal
803 ++ */
804 ++ pins = "gpio17";
805 ++ function = "blsp_uart5";
806 ++ drive-strength = <2>;
807 ++ bias-pull-up;
808 ++ };
809 +
810 +- blsp2_uart1_rxcts_sleep: blsp2-uart1-rxcts-sleep {
811 +- pins = "gpio17", "gpio18";
812 +- drive-strength = <2>;
813 +- bias-no-pull;
814 ++ cts {
815 ++ /* Match the pull of the BT module */
816 ++ pins = "gpio18";
817 ++ function = "blsp_uart5";
818 ++ drive-strength = <2>;
819 ++ bias-pull-down;
820 ++ };
821 + };
822 +
823 +- blsp2_uart1_rfr_active: blsp2-uart1-rfr-active {
824 +- pins = "gpio19";
825 +- drive-strength = <2>;
826 +- bias-disable;
827 +- };
828 ++ blsp2_uart1_sleep: blsp2-uart1-sleep {
829 ++ tx {
830 ++ pins = "gpio16";
831 ++ function = "gpio";
832 ++ drive-strength = <2>;
833 ++ bias-pull-up;
834 ++ };
835 +
836 +- blsp2_uart1_rfr_sleep: blsp2-uart1-rfr-sleep {
837 +- pins = "gpio19";
838 +- drive-strength = <2>;
839 +- bias-no-pull;
840 ++ rx-cts-rts {
841 ++ pins = "gpio17", "gpio18", "gpio19";
842 ++ function = "gpio";
843 ++ drive-strength = <2>;
844 ++ bias-no-pull;
845 ++ };
846 + };
847 +
848 + i2c1_default: i2c1-default {
849 +@@ -686,50 +693,106 @@
850 + bias-pull-up;
851 + };
852 +
853 +- sdc1_clk_on: sdc1-clk-on {
854 +- pins = "sdc1_clk";
855 +- bias-disable;
856 +- drive-strength = <16>;
857 +- };
858 ++ sdc1_state_on: sdc1-on {
859 ++ clk {
860 ++ pins = "sdc1_clk";
861 ++ bias-disable;
862 ++ drive-strength = <16>;
863 ++ };
864 +
865 +- sdc1_clk_off: sdc1-clk-off {
866 +- pins = "sdc1_clk";
867 +- bias-disable;
868 +- drive-strength = <2>;
869 +- };
870 ++ cmd {
871 ++ pins = "sdc1_cmd";
872 ++ bias-pull-up;
873 ++ drive-strength = <10>;
874 ++ };
875 +
876 +- sdc1_cmd_on: sdc1-cmd-on {
877 +- pins = "sdc1_cmd";
878 +- bias-pull-up;
879 +- drive-strength = <10>;
880 +- };
881 ++ data {
882 ++ pins = "sdc1_data";
883 ++ bias-pull-up;
884 ++ drive-strength = <10>;
885 ++ };
886 +
887 +- sdc1_cmd_off: sdc1-cmd-off {
888 +- pins = "sdc1_cmd";
889 +- bias-pull-up;
890 +- drive-strength = <2>;
891 ++ rclk {
892 ++ pins = "sdc1_rclk";
893 ++ bias-pull-down;
894 ++ };
895 + };
896 +
897 +- sdc1_data_on: sdc1-data-on {
898 +- pins = "sdc1_data";
899 +- bias-pull-up;
900 +- drive-strength = <8>;
901 +- };
902 ++ sdc1_state_off: sdc1-off {
903 ++ clk {
904 ++ pins = "sdc1_clk";
905 ++ bias-disable;
906 ++ drive-strength = <2>;
907 ++ };
908 +
909 +- sdc1_data_off: sdc1-data-off {
910 +- pins = "sdc1_data";
911 +- bias-pull-up;
912 +- drive-strength = <2>;
913 ++ cmd {
914 ++ pins = "sdc1_cmd";
915 ++ bias-pull-up;
916 ++ drive-strength = <2>;
917 ++ };
918 ++
919 ++ data {
920 ++ pins = "sdc1_data";
921 ++ bias-pull-up;
922 ++ drive-strength = <2>;
923 ++ };
924 ++
925 ++ rclk {
926 ++ pins = "sdc1_rclk";
927 ++ bias-pull-down;
928 ++ };
929 + };
930 +
931 +- sdc1_rclk_on: sdc1-rclk-on {
932 +- pins = "sdc1_rclk";
933 +- bias-pull-down;
934 ++ sdc2_state_on: sdc2-on {
935 ++ clk {
936 ++ pins = "sdc2_clk";
937 ++ bias-disable;
938 ++ drive-strength = <16>;
939 ++ };
940 ++
941 ++ cmd {
942 ++ pins = "sdc2_cmd";
943 ++ bias-pull-up;
944 ++ drive-strength = <10>;
945 ++ };
946 ++
947 ++ data {
948 ++ pins = "sdc2_data";
949 ++ bias-pull-up;
950 ++ drive-strength = <10>;
951 ++ };
952 ++
953 ++ sd-cd {
954 ++ pins = "gpio54";
955 ++ bias-pull-up;
956 ++ drive-strength = <2>;
957 ++ };
958 + };
959 +
960 +- sdc1_rclk_off: sdc1-rclk-off {
961 +- pins = "sdc1_rclk";
962 +- bias-pull-down;
963 ++ sdc2_state_off: sdc2-off {
964 ++ clk {
965 ++ pins = "sdc2_clk";
966 ++ bias-disable;
967 ++ drive-strength = <2>;
968 ++ };
969 ++
970 ++ cmd {
971 ++ pins = "sdc2_cmd";
972 ++ bias-pull-up;
973 ++ drive-strength = <2>;
974 ++ };
975 ++
976 ++ data {
977 ++ pins = "sdc2_data";
978 ++ bias-pull-up;
979 ++ drive-strength = <2>;
980 ++ };
981 ++
982 ++ sd-cd {
983 ++ pins = "gpio54";
984 ++ bias-disable;
985 ++ drive-strength = <2>;
986 ++ };
987 + };
988 + };
989 +
990 +@@ -821,8 +884,8 @@
991 + clock-names = "core", "iface", "xo";
992 +
993 + pinctrl-names = "default", "sleep";
994 +- pinctrl-0 = <&sdc1_clk_on &sdc1_cmd_on &sdc1_data_on &sdc1_rclk_on>;
995 +- pinctrl-1 = <&sdc1_clk_off &sdc1_cmd_off &sdc1_data_off &sdc1_rclk_off>;
996 ++ pinctrl-0 = <&sdc1_state_on>;
997 ++ pinctrl-1 = <&sdc1_state_off>;
998 +
999 + bus-width = <8>;
1000 + non-removable;
1001 +@@ -967,10 +1030,8 @@
1002 + dmas = <&blsp2_dma 0>, <&blsp2_dma 1>;
1003 + dma-names = "tx", "rx";
1004 + pinctrl-names = "default", "sleep";
1005 +- pinctrl-0 = <&blsp2_uart1_tx_active &blsp2_uart1_rxcts_active
1006 +- &blsp2_uart1_rfr_active>;
1007 +- pinctrl-1 = <&blsp2_uart1_tx_sleep &blsp2_uart1_rxcts_sleep
1008 +- &blsp2_uart1_rfr_sleep>;
1009 ++ pinctrl-0 = <&blsp2_uart1_default>;
1010 ++ pinctrl-1 = <&blsp2_uart1_sleep>;
1011 + status = "disabled";
1012 + };
1013 +
1014 +diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi b/arch/arm64/boot/dts/qcom/sm8250.dtsi
1015 +index d4547a192748b..ec356fe07ac8a 100644
1016 +--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
1017 ++++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
1018 +@@ -2346,7 +2346,7 @@
1019 + };
1020 + };
1021 +
1022 +- epss_l3: interconnect@18591000 {
1023 ++ epss_l3: interconnect@18590000 {
1024 + compatible = "qcom,sm8250-epss-l3";
1025 + reg = <0 0x18590000 0 0x1000>;
1026 +
1027 +diff --git a/arch/arm64/include/asm/kernel-pgtable.h b/arch/arm64/include/asm/kernel-pgtable.h
1028 +index 587c504a4c8b2..4b06cf9a8c8aa 100644
1029 +--- a/arch/arm64/include/asm/kernel-pgtable.h
1030 ++++ b/arch/arm64/include/asm/kernel-pgtable.h
1031 +@@ -65,8 +65,8 @@
1032 + #define EARLY_KASLR (0)
1033 + #endif
1034 +
1035 +-#define EARLY_ENTRIES(vstart, vend, shift) (((vend) >> (shift)) \
1036 +- - ((vstart) >> (shift)) + 1 + EARLY_KASLR)
1037 ++#define EARLY_ENTRIES(vstart, vend, shift) \
1038 ++ ((((vend) - 1) >> (shift)) - ((vstart) >> (shift)) + 1 + EARLY_KASLR)
1039 +
1040 + #define EARLY_PGDS(vstart, vend) (EARLY_ENTRIES(vstart, vend, PGDIR_SHIFT))
1041 +
1042 +diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
1043 +index b2e91c187e2a6..c7315862e2435 100644
1044 +--- a/arch/arm64/include/asm/mmu.h
1045 ++++ b/arch/arm64/include/asm/mmu.h
1046 +@@ -30,11 +30,32 @@ typedef struct {
1047 + } mm_context_t;
1048 +
1049 + /*
1050 +- * This macro is only used by the TLBI and low-level switch_mm() code,
1051 +- * neither of which can race with an ASID change. We therefore don't
1052 +- * need to reload the counter using atomic64_read().
1053 ++ * We use atomic64_read() here because the ASID for an 'mm_struct' can
1054 ++ * be reallocated when scheduling one of its threads following a
1055 ++ * rollover event (see new_context() and flush_context()). In this case,
1056 ++ * a concurrent TLBI (e.g. via try_to_unmap_one() and ptep_clear_flush())
1057 ++ * may use a stale ASID. This is fine in principle as the new ASID is
1058 ++ * guaranteed to be clean in the TLB, but the TLBI routines have to take
1059 ++ * care to handle the following race:
1060 ++ *
1061 ++ * CPU 0 CPU 1 CPU 2
1062 ++ *
1063 ++ * // ptep_clear_flush(mm)
1064 ++ * xchg_relaxed(pte, 0)
1065 ++ * DSB ISHST
1066 ++ * old = ASID(mm)
1067 ++ * | <rollover>
1068 ++ * | new = new_context(mm)
1069 ++ * \-----------------> atomic_set(mm->context.id, new)
1070 ++ * cpu_switch_mm(mm)
1071 ++ * // Hardware walk of pte using new ASID
1072 ++ * TLBI(old)
1073 ++ *
1074 ++ * In this scenario, the barrier on CPU 0 and the dependency on CPU 1
1075 ++ * ensure that the page-table walker on CPU 1 *must* see the invalid PTE
1076 ++ * written by CPU 0.
1077 + */
1078 +-#define ASID(mm) ((mm)->context.id.counter & 0xffff)
1079 ++#define ASID(mm) (atomic64_read(&(mm)->context.id) & 0xffff)
1080 +
1081 + static inline bool arm64_kernel_unmapped_at_el0(void)
1082 + {
1083 +diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
1084 +index cc3f5a33ff9c5..36f02892e1df8 100644
1085 +--- a/arch/arm64/include/asm/tlbflush.h
1086 ++++ b/arch/arm64/include/asm/tlbflush.h
1087 +@@ -245,9 +245,10 @@ static inline void flush_tlb_all(void)
1088 +
1089 + static inline void flush_tlb_mm(struct mm_struct *mm)
1090 + {
1091 +- unsigned long asid = __TLBI_VADDR(0, ASID(mm));
1092 ++ unsigned long asid;
1093 +
1094 + dsb(ishst);
1095 ++ asid = __TLBI_VADDR(0, ASID(mm));
1096 + __tlbi(aside1is, asid);
1097 + __tlbi_user(aside1is, asid);
1098 + dsb(ish);
1099 +@@ -256,9 +257,10 @@ static inline void flush_tlb_mm(struct mm_struct *mm)
1100 + static inline void flush_tlb_page_nosync(struct vm_area_struct *vma,
1101 + unsigned long uaddr)
1102 + {
1103 +- unsigned long addr = __TLBI_VADDR(uaddr, ASID(vma->vm_mm));
1104 ++ unsigned long addr;
1105 +
1106 + dsb(ishst);
1107 ++ addr = __TLBI_VADDR(uaddr, ASID(vma->vm_mm));
1108 + __tlbi(vale1is, addr);
1109 + __tlbi_user(vale1is, addr);
1110 + }
1111 +@@ -283,9 +285,7 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma,
1112 + {
1113 + int num = 0;
1114 + int scale = 0;
1115 +- unsigned long asid = ASID(vma->vm_mm);
1116 +- unsigned long addr;
1117 +- unsigned long pages;
1118 ++ unsigned long asid, addr, pages;
1119 +
1120 + start = round_down(start, stride);
1121 + end = round_up(end, stride);
1122 +@@ -305,6 +305,7 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma,
1123 + }
1124 +
1125 + dsb(ishst);
1126 ++ asid = ASID(vma->vm_mm);
1127 +
1128 + /*
1129 + * When the CPU does not support TLB range operations, flush the TLB
1130 +diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
1131 +index 78cdd6b24172c..f9119eea735e2 100644
1132 +--- a/arch/arm64/kernel/head.S
1133 ++++ b/arch/arm64/kernel/head.S
1134 +@@ -191,7 +191,7 @@ SYM_CODE_END(preserve_boot_args)
1135 + * to be composed of multiple pages. (This effectively scales the end index).
1136 + *
1137 + * vstart: virtual address of start of range
1138 +- * vend: virtual address of end of range
1139 ++ * vend: virtual address of end of range - we map [vstart, vend]
1140 + * shift: shift used to transform virtual address into index
1141 + * ptrs: number of entries in page table
1142 + * istart: index in table corresponding to vstart
1143 +@@ -228,17 +228,18 @@ SYM_CODE_END(preserve_boot_args)
1144 + *
1145 + * tbl: location of page table
1146 + * rtbl: address to be used for first level page table entry (typically tbl + PAGE_SIZE)
1147 +- * vstart: start address to map
1148 +- * vend: end address to map - we map [vstart, vend]
1149 ++ * vstart: virtual address of start of range
1150 ++ * vend: virtual address of end of range - we map [vstart, vend - 1]
1151 + * flags: flags to use to map last level entries
1152 + * phys: physical address corresponding to vstart - physical memory is contiguous
1153 + * pgds: the number of pgd entries
1154 + *
1155 + * Temporaries: istart, iend, tmp, count, sv - these need to be different registers
1156 +- * Preserves: vstart, vend, flags
1157 +- * Corrupts: tbl, rtbl, istart, iend, tmp, count, sv
1158 ++ * Preserves: vstart, flags
1159 ++ * Corrupts: tbl, rtbl, vend, istart, iend, tmp, count, sv
1160 + */
1161 + .macro map_memory, tbl, rtbl, vstart, vend, flags, phys, pgds, istart, iend, tmp, count, sv
1162 ++ sub \vend, \vend, #1
1163 + add \rtbl, \tbl, #PAGE_SIZE
1164 + mov \sv, \rtbl
1165 + mov \count, #0
1166 +diff --git a/arch/m68k/Kconfig.bus b/arch/m68k/Kconfig.bus
1167 +index f1be832e2b746..d1e93a39cd3bc 100644
1168 +--- a/arch/m68k/Kconfig.bus
1169 ++++ b/arch/m68k/Kconfig.bus
1170 +@@ -63,7 +63,7 @@ source "drivers/zorro/Kconfig"
1171 +
1172 + endif
1173 +
1174 +-if !MMU
1175 ++if COLDFIRE
1176 +
1177 + config ISA_DMA_API
1178 + def_bool !M5272
1179 +diff --git a/arch/mips/mti-malta/malta-dtshim.c b/arch/mips/mti-malta/malta-dtshim.c
1180 +index 0ddf03df62688..f451268f6c384 100644
1181 +--- a/arch/mips/mti-malta/malta-dtshim.c
1182 ++++ b/arch/mips/mti-malta/malta-dtshim.c
1183 +@@ -22,7 +22,7 @@
1184 + #define ROCIT_CONFIG_GEN1_MEMMAP_SHIFT 8
1185 + #define ROCIT_CONFIG_GEN1_MEMMAP_MASK (0xf << 8)
1186 +
1187 +-static unsigned char fdt_buf[16 << 10] __initdata;
1188 ++static unsigned char fdt_buf[16 << 10] __initdata __aligned(8);
1189 +
1190 + /* determined physical memory size, not overridden by command line args */
1191 + extern unsigned long physical_memsize;
1192 +diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
1193 +index bc657e55c15f8..98e4f97db5159 100644
1194 +--- a/arch/openrisc/kernel/entry.S
1195 ++++ b/arch/openrisc/kernel/entry.S
1196 +@@ -547,6 +547,7 @@ EXCEPTION_ENTRY(_external_irq_handler)
1197 + l.bnf 1f // ext irq enabled, all ok.
1198 + l.nop
1199 +
1200 ++#ifdef CONFIG_PRINTK
1201 + l.addi r1,r1,-0x8
1202 + l.movhi r3,hi(42f)
1203 + l.ori r3,r3,lo(42f)
1204 +@@ -560,6 +561,7 @@ EXCEPTION_ENTRY(_external_irq_handler)
1205 + .string "\n\rESR interrupt bug: in _external_irq_handler (ESR %x)\n\r"
1206 + .align 4
1207 + .previous
1208 ++#endif
1209 +
1210 + l.ori r4,r4,SPR_SR_IEE // fix the bug
1211 + // l.sw PT_SR(r1),r4
1212 +diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
1213 +index 9f43eaeb0b0af..8d6c9b88eb3f2 100644
1214 +--- a/arch/parisc/kernel/signal.c
1215 ++++ b/arch/parisc/kernel/signal.c
1216 +@@ -237,6 +237,12 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs,
1217 + #endif
1218 +
1219 + usp = (regs->gr[30] & ~(0x01UL));
1220 ++#ifdef CONFIG_64BIT
1221 ++ if (is_compat_task()) {
1222 ++ /* The gcc alloca implementation leaves garbage in the upper 32 bits of sp */
1223 ++ usp = (compat_uint_t)usp;
1224 ++ }
1225 ++#endif
1226 + /*FIXME: frame_size parameter is unused, remove it. */
1227 + frame = get_sigframe(&ksig->ka, usp, sizeof(*frame));
1228 +
1229 +diff --git a/arch/powerpc/configs/mpc885_ads_defconfig b/arch/powerpc/configs/mpc885_ads_defconfig
1230 +index 949ff9ccda5e7..dbf3ff8adc654 100644
1231 +--- a/arch/powerpc/configs/mpc885_ads_defconfig
1232 ++++ b/arch/powerpc/configs/mpc885_ads_defconfig
1233 +@@ -34,6 +34,7 @@ CONFIG_MTD_CFI_GEOMETRY=y
1234 + # CONFIG_MTD_CFI_I2 is not set
1235 + CONFIG_MTD_CFI_I4=y
1236 + CONFIG_MTD_CFI_AMDSTD=y
1237 ++CONFIG_MTD_PHYSMAP=y
1238 + CONFIG_MTD_PHYSMAP_OF=y
1239 + # CONFIG_BLK_DEV is not set
1240 + CONFIG_NETDEVICES=y
1241 +diff --git a/arch/powerpc/include/asm/pmc.h b/arch/powerpc/include/asm/pmc.h
1242 +index c6bbe9778d3cd..3c09109e708ef 100644
1243 +--- a/arch/powerpc/include/asm/pmc.h
1244 ++++ b/arch/powerpc/include/asm/pmc.h
1245 +@@ -34,6 +34,13 @@ static inline void ppc_set_pmu_inuse(int inuse)
1246 + #endif
1247 + }
1248 +
1249 ++#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
1250 ++static inline int ppc_get_pmu_inuse(void)
1251 ++{
1252 ++ return get_paca()->pmcregs_in_use;
1253 ++}
1254 ++#endif
1255 ++
1256 + extern void power4_enable_pmcs(void);
1257 +
1258 + #else /* CONFIG_PPC64 */
1259 +diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
1260 +index 26a028a9233af..91f274134884e 100644
1261 +--- a/arch/powerpc/kernel/smp.c
1262 ++++ b/arch/powerpc/kernel/smp.c
1263 +@@ -1385,6 +1385,7 @@ static void add_cpu_to_masks(int cpu)
1264 + * add it to it's own thread sibling mask.
1265 + */
1266 + cpumask_set_cpu(cpu, cpu_sibling_mask(cpu));
1267 ++ cpumask_set_cpu(cpu, cpu_core_mask(cpu));
1268 +
1269 + for (i = first_thread; i < first_thread + threads_per_core; i++)
1270 + if (cpu_online(i))
1271 +@@ -1399,11 +1400,6 @@ static void add_cpu_to_masks(int cpu)
1272 + if (has_coregroup_support())
1273 + update_coregroup_mask(cpu, &mask);
1274 +
1275 +- if (chip_id == -1 || !ret) {
1276 +- cpumask_copy(per_cpu(cpu_core_map, cpu), cpu_cpu_mask(cpu));
1277 +- goto out;
1278 +- }
1279 +-
1280 + if (shared_caches)
1281 + submask_fn = cpu_l2_cache_mask;
1282 +
1283 +@@ -1413,6 +1409,10 @@ static void add_cpu_to_masks(int cpu)
1284 + /* Skip all CPUs already part of current CPU core mask */
1285 + cpumask_andnot(mask, cpu_online_mask, cpu_core_mask(cpu));
1286 +
1287 ++ /* If chip_id is -1; limit the cpu_core_mask to within DIE*/
1288 ++ if (chip_id == -1)
1289 ++ cpumask_and(mask, mask, cpu_cpu_mask(cpu));
1290 ++
1291 + for_each_cpu(i, mask) {
1292 + if (chip_id == cpu_to_chip_id(i)) {
1293 + or_cpumasks_related(cpu, i, submask_fn, cpu_core_mask);
1294 +@@ -1422,7 +1422,6 @@ static void add_cpu_to_masks(int cpu)
1295 + }
1296 + }
1297 +
1298 +-out:
1299 + free_cpumask_var(mask);
1300 + }
1301 +
1302 +diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
1303 +index 2f926ea9b7b94..d4a66ce93f522 100644
1304 +--- a/arch/powerpc/kernel/stacktrace.c
1305 ++++ b/arch/powerpc/kernel/stacktrace.c
1306 +@@ -8,6 +8,7 @@
1307 + * Copyright 2018 Nick Piggin, Michael Ellerman, IBM Corp.
1308 + */
1309 +
1310 ++#include <linux/delay.h>
1311 + #include <linux/export.h>
1312 + #include <linux/kallsyms.h>
1313 + #include <linux/module.h>
1314 +diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
1315 +index bb35490400e99..04028f905e50e 100644
1316 +--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
1317 ++++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
1318 +@@ -64,10 +64,12 @@ unsigned long __kvmhv_copy_tofrom_guest_radix(int lpid, int pid,
1319 + }
1320 + isync();
1321 +
1322 ++ pagefault_disable();
1323 + if (is_load)
1324 +- ret = copy_from_user_nofault(to, (const void __user *)from, n);
1325 ++ ret = __copy_from_user_inatomic(to, (const void __user *)from, n);
1326 + else
1327 +- ret = copy_to_user_nofault((void __user *)to, from, n);
1328 ++ ret = __copy_to_user_inatomic((void __user *)to, from, n);
1329 ++ pagefault_enable();
1330 +
1331 + /* switch the pid first to avoid running host with unallocated pid */
1332 + if (quadrant == 1 && pid != old_pid)
1333 +diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c
1334 +index 083a4e037718d..e5ba96c41f3fc 100644
1335 +--- a/arch/powerpc/kvm/book3s_64_vio_hv.c
1336 ++++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
1337 +@@ -173,10 +173,13 @@ static void kvmppc_rm_tce_put(struct kvmppc_spapr_tce_table *stt,
1338 + idx -= stt->offset;
1339 + page = stt->pages[idx / TCES_PER_PAGE];
1340 + /*
1341 +- * page must not be NULL in real mode,
1342 +- * kvmppc_rm_ioba_validate() must have taken care of this.
1343 ++ * kvmppc_rm_ioba_validate() allows pages not be allocated if TCE is
1344 ++ * being cleared, otherwise it returns H_TOO_HARD and we skip this.
1345 + */
1346 +- WARN_ON_ONCE_RM(!page);
1347 ++ if (!page) {
1348 ++ WARN_ON_ONCE_RM(tce != 0);
1349 ++ return;
1350 ++ }
1351 + tbl = kvmppc_page_address(page);
1352 +
1353 + tbl[idx % TCES_PER_PAGE] = tce;
1354 +diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
1355 +index bd7350a608d4b..175967a195c44 100644
1356 +--- a/arch/powerpc/kvm/book3s_hv.c
1357 ++++ b/arch/powerpc/kvm/book3s_hv.c
1358 +@@ -58,6 +58,7 @@
1359 + #include <asm/kvm_book3s.h>
1360 + #include <asm/mmu_context.h>
1361 + #include <asm/lppaca.h>
1362 ++#include <asm/pmc.h>
1363 + #include <asm/processor.h>
1364 + #include <asm/cputhreads.h>
1365 + #include <asm/page.h>
1366 +@@ -3619,6 +3620,18 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
1367 + cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST))
1368 + kvmppc_restore_tm_hv(vcpu, vcpu->arch.shregs.msr, true);
1369 +
1370 ++#ifdef CONFIG_PPC_PSERIES
1371 ++ if (kvmhv_on_pseries()) {
1372 ++ barrier();
1373 ++ if (vcpu->arch.vpa.pinned_addr) {
1374 ++ struct lppaca *lp = vcpu->arch.vpa.pinned_addr;
1375 ++ get_lppaca()->pmcregs_in_use = lp->pmcregs_in_use;
1376 ++ } else {
1377 ++ get_lppaca()->pmcregs_in_use = 1;
1378 ++ }
1379 ++ barrier();
1380 ++ }
1381 ++#endif
1382 + kvmhv_load_guest_pmu(vcpu);
1383 +
1384 + msr_check_and_set(MSR_FP | MSR_VEC | MSR_VSX);
1385 +@@ -3756,6 +3769,13 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
1386 + save_pmu |= nesting_enabled(vcpu->kvm);
1387 +
1388 + kvmhv_save_guest_pmu(vcpu, save_pmu);
1389 ++#ifdef CONFIG_PPC_PSERIES
1390 ++ if (kvmhv_on_pseries()) {
1391 ++ barrier();
1392 ++ get_lppaca()->pmcregs_in_use = ppc_get_pmu_inuse();
1393 ++ barrier();
1394 ++ }
1395 ++#endif
1396 +
1397 + vc->entry_exit_map = 0x101;
1398 + vc->in_guest = 0;
1399 +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
1400 +index f2bf98bdcea28..094a1076fd1fe 100644
1401 +--- a/arch/powerpc/mm/numa.c
1402 ++++ b/arch/powerpc/mm/numa.c
1403 +@@ -893,7 +893,7 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)
1404 + static void __init find_possible_nodes(void)
1405 + {
1406 + struct device_node *rtas;
1407 +- const __be32 *domains;
1408 ++ const __be32 *domains = NULL;
1409 + int prop_length, max_nodes;
1410 + u32 i;
1411 +
1412 +@@ -909,9 +909,14 @@ static void __init find_possible_nodes(void)
1413 + * it doesn't exist, then fallback on ibm,max-associativity-domains.
1414 + * Current denotes what the platform can support compared to max
1415 + * which denotes what the Hypervisor can support.
1416 ++ *
1417 ++ * If the LPAR is migratable, new nodes might be activated after a LPM,
1418 ++ * so we should consider the max number in that case.
1419 + */
1420 +- domains = of_get_property(rtas, "ibm,current-associativity-domains",
1421 +- &prop_length);
1422 ++ if (!of_get_property(of_root, "ibm,migratable-partition", NULL))
1423 ++ domains = of_get_property(rtas,
1424 ++ "ibm,current-associativity-domains",
1425 ++ &prop_length);
1426 + if (!domains) {
1427 + domains = of_get_property(rtas, "ibm,max-associativity-domains",
1428 + &prop_length);
1429 +@@ -920,6 +925,8 @@ static void __init find_possible_nodes(void)
1430 + }
1431 +
1432 + max_nodes = of_read_number(&domains[min_common_depth], 1);
1433 ++ pr_info("Partition configured for %d NUMA nodes.\n", max_nodes);
1434 ++
1435 + for (i = 0; i < max_nodes; i++) {
1436 + if (!node_possible(i))
1437 + node_set(i, node_possible_map);
1438 +diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
1439 +index d48413e28c39e..c756228a081fb 100644
1440 +--- a/arch/powerpc/perf/hv-gpci.c
1441 ++++ b/arch/powerpc/perf/hv-gpci.c
1442 +@@ -175,7 +175,7 @@ static unsigned long single_gpci_request(u32 req, u32 starting_index,
1443 + */
1444 + count = 0;
1445 + for (i = offset; i < offset + length; i++)
1446 +- count |= arg->bytes[i] << (i - offset);
1447 ++ count |= (u64)(arg->bytes[i]) << ((length - 1 - (i - offset)) * 8);
1448 +
1449 + *value = count;
1450 + out:
1451 +diff --git a/arch/s390/include/asm/setup.h b/arch/s390/include/asm/setup.h
1452 +index bdb242a1544eb..75a2ecec2ab8a 100644
1453 +--- a/arch/s390/include/asm/setup.h
1454 ++++ b/arch/s390/include/asm/setup.h
1455 +@@ -38,6 +38,7 @@
1456 + #define MACHINE_FLAG_NX BIT(15)
1457 + #define MACHINE_FLAG_GS BIT(16)
1458 + #define MACHINE_FLAG_SCC BIT(17)
1459 ++#define MACHINE_FLAG_PCI_MIO BIT(18)
1460 +
1461 + #define LPP_MAGIC BIT(31)
1462 + #define LPP_PID_MASK _AC(0xffffffff, UL)
1463 +@@ -113,6 +114,7 @@ extern unsigned long mio_wb_bit_mask;
1464 + #define MACHINE_HAS_NX (S390_lowcore.machine_flags & MACHINE_FLAG_NX)
1465 + #define MACHINE_HAS_GS (S390_lowcore.machine_flags & MACHINE_FLAG_GS)
1466 + #define MACHINE_HAS_SCC (S390_lowcore.machine_flags & MACHINE_FLAG_SCC)
1467 ++#define MACHINE_HAS_PCI_MIO (S390_lowcore.machine_flags & MACHINE_FLAG_PCI_MIO)
1468 +
1469 + /*
1470 + * Console mode. Override with conmode=
1471 +diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
1472 +index 705844f739345..985e1e7553336 100644
1473 +--- a/arch/s390/kernel/early.c
1474 ++++ b/arch/s390/kernel/early.c
1475 +@@ -238,6 +238,10 @@ static __init void detect_machine_facilities(void)
1476 + clock_comparator_max = -1ULL >> 1;
1477 + __ctl_set_bit(0, 53);
1478 + }
1479 ++ if (IS_ENABLED(CONFIG_PCI) && test_facility(153)) {
1480 ++ S390_lowcore.machine_flags |= MACHINE_FLAG_PCI_MIO;
1481 ++ /* the control bit is set during PCI initialization */
1482 ++ }
1483 + }
1484 +
1485 + static inline void save_vector_registers(void)
1486 +diff --git a/arch/s390/kernel/jump_label.c b/arch/s390/kernel/jump_label.c
1487 +index ab584e8e35275..9156653b56f69 100644
1488 +--- a/arch/s390/kernel/jump_label.c
1489 ++++ b/arch/s390/kernel/jump_label.c
1490 +@@ -36,7 +36,7 @@ static void jump_label_bug(struct jump_entry *entry, struct insn *expected,
1491 + unsigned char *ipe = (unsigned char *)expected;
1492 + unsigned char *ipn = (unsigned char *)new;
1493 +
1494 +- pr_emerg("Jump label code mismatch at %pS [%p]\n", ipc, ipc);
1495 ++ pr_emerg("Jump label code mismatch at %pS [%px]\n", ipc, ipc);
1496 + pr_emerg("Found: %6ph\n", ipc);
1497 + pr_emerg("Expected: %6ph\n", ipe);
1498 + pr_emerg("New: %6ph\n", ipn);
1499 +diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
1500 +index 77767850d0d07..9d5960bbc45f2 100644
1501 +--- a/arch/s390/mm/init.c
1502 ++++ b/arch/s390/mm/init.c
1503 +@@ -180,9 +180,9 @@ static void pv_init(void)
1504 + return;
1505 +
1506 + /* make sure bounce buffers are shared */
1507 ++ swiotlb_force = SWIOTLB_FORCE;
1508 + swiotlb_init(1);
1509 + swiotlb_update_mem_attributes();
1510 +- swiotlb_force = SWIOTLB_FORCE;
1511 + }
1512 +
1513 + void __init mem_init(void)
1514 +diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
1515 +index 0ddb1fe353dc8..f5ddbc625c1a5 100644
1516 +--- a/arch/s390/pci/pci.c
1517 ++++ b/arch/s390/pci/pci.c
1518 +@@ -866,7 +866,6 @@ static void zpci_mem_exit(void)
1519 + }
1520 +
1521 + static unsigned int s390_pci_probe __initdata = 1;
1522 +-static unsigned int s390_pci_no_mio __initdata;
1523 + unsigned int s390_pci_force_floating __initdata;
1524 + static unsigned int s390_pci_initialized;
1525 +
1526 +@@ -877,7 +876,7 @@ char * __init pcibios_setup(char *str)
1527 + return NULL;
1528 + }
1529 + if (!strcmp(str, "nomio")) {
1530 +- s390_pci_no_mio = 1;
1531 ++ S390_lowcore.machine_flags &= ~MACHINE_FLAG_PCI_MIO;
1532 + return NULL;
1533 + }
1534 + if (!strcmp(str, "force_floating")) {
1535 +@@ -906,7 +905,7 @@ static int __init pci_base_init(void)
1536 + if (!test_facility(69) || !test_facility(71))
1537 + return 0;
1538 +
1539 +- if (test_facility(153) && !s390_pci_no_mio) {
1540 ++ if (MACHINE_HAS_PCI_MIO) {
1541 + static_branch_enable(&have_mio);
1542 + ctl_set_bit(2, 5);
1543 + }
1544 +diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
1545 +index 6cc50ab07bded..65d11711cd7bb 100644
1546 +--- a/arch/x86/kernel/cpu/mshyperv.c
1547 ++++ b/arch/x86/kernel/cpu/mshyperv.c
1548 +@@ -322,8 +322,6 @@ static void __init ms_hyperv_init_platform(void)
1549 + if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
1550 + wrmsrl(HV_X64_MSR_TSC_INVARIANT_CONTROL, 0x1);
1551 + setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
1552 +- } else {
1553 +- mark_tsc_unstable("running on Hyper-V");
1554 + }
1555 +
1556 + /*
1557 +@@ -382,6 +380,13 @@ static void __init ms_hyperv_init_platform(void)
1558 + /* Register Hyper-V specific clocksource */
1559 + hv_init_clocksource();
1560 + #endif
1561 ++ /*
1562 ++ * TSC should be marked as unstable only after Hyper-V
1563 ++ * clocksource has been initialized. This ensures that the
1564 ++ * stability of the sched_clock is not altered.
1565 ++ */
1566 ++ if (!(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
1567 ++ mark_tsc_unstable("running on Hyper-V");
1568 + }
1569 +
1570 + const __initconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
1571 +diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
1572 +index 56e0f290fef65..e809f14468464 100644
1573 +--- a/arch/x86/xen/p2m.c
1574 ++++ b/arch/x86/xen/p2m.c
1575 +@@ -618,8 +618,8 @@ int xen_alloc_p2m_entry(unsigned long pfn)
1576 + }
1577 +
1578 + /* Expanded the p2m? */
1579 +- if (pfn > xen_p2m_last_pfn) {
1580 +- xen_p2m_last_pfn = pfn;
1581 ++ if (pfn >= xen_p2m_last_pfn) {
1582 ++ xen_p2m_last_pfn = ALIGN(pfn + 1, P2M_PER_PAGE);
1583 + HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn;
1584 + }
1585 +
1586 +diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
1587 +index af81a62faba64..e7faea3d73d3b 100644
1588 +--- a/arch/xtensa/platforms/iss/console.c
1589 ++++ b/arch/xtensa/platforms/iss/console.c
1590 +@@ -168,9 +168,13 @@ static const struct tty_operations serial_ops = {
1591 +
1592 + int __init rs_init(void)
1593 + {
1594 +- tty_port_init(&serial_port);
1595 ++ int ret;
1596 +
1597 + serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES);
1598 ++ if (!serial_driver)
1599 ++ return -ENOMEM;
1600 ++
1601 ++ tty_port_init(&serial_port);
1602 +
1603 + pr_info("%s %s\n", serial_name, serial_version);
1604 +
1605 +@@ -190,8 +194,15 @@ int __init rs_init(void)
1606 + tty_set_operations(serial_driver, &serial_ops);
1607 + tty_port_link_device(&serial_port, serial_driver, 0);
1608 +
1609 +- if (tty_register_driver(serial_driver))
1610 +- panic("Couldn't register serial driver\n");
1611 ++ ret = tty_register_driver(serial_driver);
1612 ++ if (ret) {
1613 ++ pr_err("Couldn't register serial driver\n");
1614 ++ tty_driver_kref_put(serial_driver);
1615 ++ tty_port_destroy(&serial_port);
1616 ++
1617 ++ return ret;
1618 ++ }
1619 ++
1620 + return 0;
1621 + }
1622 +
1623 +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
1624 +index 8ea37328ca84e..b8c2ddc01aec3 100644
1625 +--- a/block/bfq-iosched.c
1626 ++++ b/block/bfq-iosched.c
1627 +@@ -5011,7 +5011,7 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic)
1628 + if (bfqq->new_ioprio >= IOPRIO_BE_NR) {
1629 + pr_crit("bfq_set_next_ioprio_data: new_ioprio %d\n",
1630 + bfqq->new_ioprio);
1631 +- bfqq->new_ioprio = IOPRIO_BE_NR;
1632 ++ bfqq->new_ioprio = IOPRIO_BE_NR - 1;
1633 + }
1634 +
1635 + bfqq->entity.new_weight = bfq_ioprio_to_weight(bfqq->new_ioprio);
1636 +diff --git a/block/blk-zoned.c b/block/blk-zoned.c
1637 +index ab7d7ebcf6ddc..61b452272f94e 100644
1638 +--- a/block/blk-zoned.c
1639 ++++ b/block/blk-zoned.c
1640 +@@ -296,9 +296,6 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
1641 + if (!blk_queue_is_zoned(q))
1642 + return -ENOTTY;
1643 +
1644 +- if (!capable(CAP_SYS_ADMIN))
1645 +- return -EACCES;
1646 +-
1647 + if (copy_from_user(&rep, argp, sizeof(struct blk_zone_report)))
1648 + return -EFAULT;
1649 +
1650 +@@ -357,9 +354,6 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
1651 + if (!blk_queue_is_zoned(q))
1652 + return -ENOTTY;
1653 +
1654 +- if (!capable(CAP_SYS_ADMIN))
1655 +- return -EACCES;
1656 +-
1657 + if (!(mode & FMODE_WRITE))
1658 + return -EBADF;
1659 +
1660 +diff --git a/block/bsg.c b/block/bsg.c
1661 +index 3d78e843a83f6..2cbc1fcc8247b 100644
1662 +--- a/block/bsg.c
1663 ++++ b/block/bsg.c
1664 +@@ -371,10 +371,13 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1665 + case SG_GET_RESERVED_SIZE:
1666 + case SG_SET_RESERVED_SIZE:
1667 + case SG_EMULATED_HOST:
1668 +- case SCSI_IOCTL_SEND_COMMAND:
1669 + return scsi_cmd_ioctl(bd->queue, NULL, file->f_mode, cmd, uarg);
1670 + case SG_IO:
1671 + return bsg_sg_io(bd->queue, file->f_mode, uarg);
1672 ++ case SCSI_IOCTL_SEND_COMMAND:
1673 ++ pr_warn_ratelimited("%s: calling unsupported SCSI_IOCTL_SEND_COMMAND\n",
1674 ++ current->comm);
1675 ++ return -EINVAL;
1676 + default:
1677 + return -ENOTTY;
1678 + }
1679 +diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
1680 +index 44f434acfce08..0e6e73b8023fc 100644
1681 +--- a/drivers/ata/libata-core.c
1682 ++++ b/drivers/ata/libata-core.c
1683 +@@ -3950,6 +3950,10 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
1684 + ATA_HORKAGE_ZERO_AFTER_TRIM, },
1685 + { "Samsung SSD 850*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
1686 + ATA_HORKAGE_ZERO_AFTER_TRIM, },
1687 ++ { "Samsung SSD 860*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
1688 ++ ATA_HORKAGE_ZERO_AFTER_TRIM, },
1689 ++ { "Samsung SSD 870*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
1690 ++ ATA_HORKAGE_ZERO_AFTER_TRIM, },
1691 + { "FCCT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
1692 + ATA_HORKAGE_ZERO_AFTER_TRIM, },
1693 +
1694 +diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
1695 +index 9dcef6ac643b9..982fe91125322 100644
1696 +--- a/drivers/ata/sata_dwc_460ex.c
1697 ++++ b/drivers/ata/sata_dwc_460ex.c
1698 +@@ -1249,24 +1249,20 @@ static int sata_dwc_probe(struct platform_device *ofdev)
1699 + irq = irq_of_parse_and_map(np, 0);
1700 + if (irq == NO_IRQ) {
1701 + dev_err(&ofdev->dev, "no SATA DMA irq\n");
1702 +- err = -ENODEV;
1703 +- goto error_out;
1704 ++ return -ENODEV;
1705 + }
1706 +
1707 + #ifdef CONFIG_SATA_DWC_OLD_DMA
1708 + if (!of_find_property(np, "dmas", NULL)) {
1709 + err = sata_dwc_dma_init_old(ofdev, hsdev);
1710 + if (err)
1711 +- goto error_out;
1712 ++ return err;
1713 + }
1714 + #endif
1715 +
1716 + hsdev->phy = devm_phy_optional_get(hsdev->dev, "sata-phy");
1717 +- if (IS_ERR(hsdev->phy)) {
1718 +- err = PTR_ERR(hsdev->phy);
1719 +- hsdev->phy = NULL;
1720 +- goto error_out;
1721 +- }
1722 ++ if (IS_ERR(hsdev->phy))
1723 ++ return PTR_ERR(hsdev->phy);
1724 +
1725 + err = phy_init(hsdev->phy);
1726 + if (err)
1727 +diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
1728 +index 806766b1b45f6..e329cdd7156c9 100644
1729 +--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
1730 ++++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
1731 +@@ -64,6 +64,8 @@ struct fsl_mc_addr_translation_range {
1732 + #define MC_FAPR_PL BIT(18)
1733 + #define MC_FAPR_BMT BIT(17)
1734 +
1735 ++static phys_addr_t mc_portal_base_phys_addr;
1736 ++
1737 + /**
1738 + * fsl_mc_bus_match - device to driver matching callback
1739 + * @dev: the fsl-mc device to match against
1740 +@@ -597,14 +599,30 @@ static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev,
1741 + * If base address is in the region_desc use it otherwise
1742 + * revert to old mechanism
1743 + */
1744 +- if (region_desc.base_address)
1745 ++ if (region_desc.base_address) {
1746 + regions[i].start = region_desc.base_address +
1747 + region_desc.base_offset;
1748 +- else
1749 ++ } else {
1750 + error = translate_mc_addr(mc_dev, mc_region_type,
1751 + region_desc.base_offset,
1752 + &regions[i].start);
1753 +
1754 ++ /*
1755 ++ * Some versions of the MC firmware wrongly report
1756 ++ * 0 for register base address of the DPMCP associated
1757 ++ * with child DPRC objects thus rendering them unusable.
1758 ++ * This is particularly troublesome in ACPI boot
1759 ++ * scenarios where the legacy way of extracting this
1760 ++ * base address from the device tree does not apply.
1761 ++ * Given that DPMCPs share the same base address,
1762 ++ * workaround this by using the base address extracted
1763 ++ * from the root DPRC container.
1764 ++ */
1765 ++ if (is_fsl_mc_bus_dprc(mc_dev) &&
1766 ++ regions[i].start == region_desc.base_offset)
1767 ++ regions[i].start += mc_portal_base_phys_addr;
1768 ++ }
1769 ++
1770 + if (error < 0) {
1771 + dev_err(parent_dev,
1772 + "Invalid MC offset: %#x (for %s.%d\'s region %d)\n",
1773 +@@ -996,6 +1014,8 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
1774 + plat_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1775 + mc_portal_phys_addr = plat_res->start;
1776 + mc_portal_size = resource_size(plat_res);
1777 ++ mc_portal_base_phys_addr = mc_portal_phys_addr & ~0x3ffffff;
1778 ++
1779 + error = fsl_create_mc_io(&pdev->dev, mc_portal_phys_addr,
1780 + mc_portal_size, NULL,
1781 + FSL_MC_IO_ATOMIC_CONTEXT_PORTAL, &mc_io);
1782 +diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c
1783 +index b4fc8d71daf20..b656d25a97678 100644
1784 +--- a/drivers/clk/at91/clk-generated.c
1785 ++++ b/drivers/clk/at91/clk-generated.c
1786 +@@ -128,6 +128,12 @@ static int clk_generated_determine_rate(struct clk_hw *hw,
1787 + int i;
1788 + u32 div;
1789 +
1790 ++ /* do not look for a rate that is outside of our range */
1791 ++ if (gck->range.max && req->rate > gck->range.max)
1792 ++ req->rate = gck->range.max;
1793 ++ if (gck->range.min && req->rate < gck->range.min)
1794 ++ req->rate = gck->range.min;
1795 ++
1796 + for (i = 0; i < clk_hw_get_num_parents(hw); i++) {
1797 + if (gck->chg_pid == i)
1798 + continue;
1799 +diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c
1800 +index 2c309e3dc8e34..04e728538cefe 100644
1801 +--- a/drivers/clk/imx/clk-composite-8m.c
1802 ++++ b/drivers/clk/imx/clk-composite-8m.c
1803 +@@ -216,7 +216,8 @@ struct clk_hw *imx8m_clk_hw_composite_flags(const char *name,
1804 + div->width = PCG_PREDIV_WIDTH;
1805 + divider_ops = &imx8m_clk_composite_divider_ops;
1806 + mux_ops = &clk_mux_ops;
1807 +- flags |= CLK_SET_PARENT_GATE;
1808 ++ if (!(composite_flags & IMX_COMPOSITE_FW_MANAGED))
1809 ++ flags |= CLK_SET_PARENT_GATE;
1810 + }
1811 +
1812 + div->lock = &imx_ccm_lock;
1813 +diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
1814 +index 4cbf86ab2eacf..711bd2294c70b 100644
1815 +--- a/drivers/clk/imx/clk-imx8mm.c
1816 ++++ b/drivers/clk/imx/clk-imx8mm.c
1817 +@@ -458,10 +458,11 @@ static int imx8mm_clocks_probe(struct platform_device *pdev)
1818 +
1819 + /*
1820 + * DRAM clocks are manipulated from TF-A outside clock framework.
1821 +- * Mark with GET_RATE_NOCACHE to always read div value from hardware
1822 ++ * The fw_managed helper sets GET_RATE_NOCACHE and clears SET_PARENT_GATE
1823 ++ * as div value should always be read from hardware
1824 + */
1825 +- hws[IMX8MM_CLK_DRAM_ALT] = __imx8m_clk_hw_composite("dram_alt", imx8mm_dram_alt_sels, base + 0xa000, CLK_GET_RATE_NOCACHE);
1826 +- hws[IMX8MM_CLK_DRAM_APB] = __imx8m_clk_hw_composite("dram_apb", imx8mm_dram_apb_sels, base + 0xa080, CLK_IS_CRITICAL | CLK_GET_RATE_NOCACHE);
1827 ++ hws[IMX8MM_CLK_DRAM_ALT] = imx8m_clk_hw_fw_managed_composite("dram_alt", imx8mm_dram_alt_sels, base + 0xa000);
1828 ++ hws[IMX8MM_CLK_DRAM_APB] = imx8m_clk_hw_fw_managed_composite_critical("dram_apb", imx8mm_dram_apb_sels, base + 0xa080);
1829 +
1830 + /* IP */
1831 + hws[IMX8MM_CLK_VPU_G1] = imx8m_clk_hw_composite("vpu_g1", imx8mm_vpu_g1_sels, base + 0xa100);
1832 +diff --git a/drivers/clk/imx/clk-imx8mn.c b/drivers/clk/imx/clk-imx8mn.c
1833 +index f98f252795396..33a7ddc23cd24 100644
1834 +--- a/drivers/clk/imx/clk-imx8mn.c
1835 ++++ b/drivers/clk/imx/clk-imx8mn.c
1836 +@@ -441,10 +441,11 @@ static int imx8mn_clocks_probe(struct platform_device *pdev)
1837 +
1838 + /*
1839 + * DRAM clocks are manipulated from TF-A outside clock framework.
1840 +- * Mark with GET_RATE_NOCACHE to always read div value from hardware
1841 ++ * The fw_managed helper sets GET_RATE_NOCACHE and clears SET_PARENT_GATE
1842 ++ * as div value should always be read from hardware
1843 + */
1844 +- hws[IMX8MN_CLK_DRAM_ALT] = __imx8m_clk_hw_composite("dram_alt", imx8mn_dram_alt_sels, base + 0xa000, CLK_GET_RATE_NOCACHE);
1845 +- hws[IMX8MN_CLK_DRAM_APB] = __imx8m_clk_hw_composite("dram_apb", imx8mn_dram_apb_sels, base + 0xa080, CLK_IS_CRITICAL | CLK_GET_RATE_NOCACHE);
1846 ++ hws[IMX8MN_CLK_DRAM_ALT] = imx8m_clk_hw_fw_managed_composite("dram_alt", imx8mn_dram_alt_sels, base + 0xa000);
1847 ++ hws[IMX8MN_CLK_DRAM_APB] = imx8m_clk_hw_fw_managed_composite_critical("dram_apb", imx8mn_dram_apb_sels, base + 0xa080);
1848 +
1849 + hws[IMX8MN_CLK_DISP_PIXEL] = imx8m_clk_hw_composite("disp_pixel", imx8mn_disp_pixel_sels, base + 0xa500);
1850 + hws[IMX8MN_CLK_SAI2] = imx8m_clk_hw_composite("sai2", imx8mn_sai2_sels, base + 0xa600);
1851 +diff --git a/drivers/clk/imx/clk-imx8mq.c b/drivers/clk/imx/clk-imx8mq.c
1852 +index aac6bcc65c20c..f679e5cc320b5 100644
1853 +--- a/drivers/clk/imx/clk-imx8mq.c
1854 ++++ b/drivers/clk/imx/clk-imx8mq.c
1855 +@@ -427,11 +427,12 @@ static int imx8mq_clocks_probe(struct platform_device *pdev)
1856 +
1857 + /*
1858 + * DRAM clocks are manipulated from TF-A outside clock framework.
1859 +- * Mark with GET_RATE_NOCACHE to always read div value from hardware
1860 ++ * The fw_managed helper sets GET_RATE_NOCACHE and clears SET_PARENT_GATE
1861 ++ * as div value should always be read from hardware
1862 + */
1863 + hws[IMX8MQ_CLK_DRAM_CORE] = imx_clk_hw_mux2_flags("dram_core_clk", base + 0x9800, 24, 1, imx8mq_dram_core_sels, ARRAY_SIZE(imx8mq_dram_core_sels), CLK_IS_CRITICAL);
1864 +- hws[IMX8MQ_CLK_DRAM_ALT] = __imx8m_clk_hw_composite("dram_alt", imx8mq_dram_alt_sels, base + 0xa000, CLK_GET_RATE_NOCACHE);
1865 +- hws[IMX8MQ_CLK_DRAM_APB] = __imx8m_clk_hw_composite("dram_apb", imx8mq_dram_apb_sels, base + 0xa080, CLK_IS_CRITICAL | CLK_GET_RATE_NOCACHE);
1866 ++ hws[IMX8MQ_CLK_DRAM_ALT] = imx8m_clk_hw_fw_managed_composite("dram_alt", imx8mq_dram_alt_sels, base + 0xa000);
1867 ++ hws[IMX8MQ_CLK_DRAM_APB] = imx8m_clk_hw_fw_managed_composite_critical("dram_apb", imx8mq_dram_apb_sels, base + 0xa080);
1868 +
1869 + /* IP */
1870 + hws[IMX8MQ_CLK_VPU_G1] = imx8m_clk_hw_composite("vpu_g1", imx8mq_vpu_g1_sels, base + 0xa100);
1871 +diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
1872 +index f04cbbab9fccd..c66e00e877114 100644
1873 +--- a/drivers/clk/imx/clk.h
1874 ++++ b/drivers/clk/imx/clk.h
1875 +@@ -533,8 +533,9 @@ struct clk_hw *imx_clk_hw_cpu(const char *name, const char *parent_name,
1876 + struct clk *div, struct clk *mux, struct clk *pll,
1877 + struct clk *step);
1878 +
1879 +-#define IMX_COMPOSITE_CORE BIT(0)
1880 +-#define IMX_COMPOSITE_BUS BIT(1)
1881 ++#define IMX_COMPOSITE_CORE BIT(0)
1882 ++#define IMX_COMPOSITE_BUS BIT(1)
1883 ++#define IMX_COMPOSITE_FW_MANAGED BIT(2)
1884 +
1885 + struct clk_hw *imx8m_clk_hw_composite_flags(const char *name,
1886 + const char * const *parent_names,
1887 +@@ -570,6 +571,17 @@ struct clk_hw *imx8m_clk_hw_composite_flags(const char *name,
1888 + ARRAY_SIZE(parent_names), reg, 0, \
1889 + flags | CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE)
1890 +
1891 ++#define __imx8m_clk_hw_fw_managed_composite(name, parent_names, reg, flags) \
1892 ++ imx8m_clk_hw_composite_flags(name, parent_names, \
1893 ++ ARRAY_SIZE(parent_names), reg, IMX_COMPOSITE_FW_MANAGED, \
1894 ++ flags | CLK_GET_RATE_NOCACHE | CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE)
1895 ++
1896 ++#define imx8m_clk_hw_fw_managed_composite(name, parent_names, reg) \
1897 ++ __imx8m_clk_hw_fw_managed_composite(name, parent_names, reg, 0)
1898 ++
1899 ++#define imx8m_clk_hw_fw_managed_composite_critical(name, parent_names, reg) \
1900 ++ __imx8m_clk_hw_fw_managed_composite(name, parent_names, reg, CLK_IS_CRITICAL)
1901 ++
1902 + #define __imx8m_clk_composite(name, parent_names, reg, flags) \
1903 + to_clk(__imx8m_clk_hw_composite(name, parent_names, reg, flags))
1904 +
1905 +diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c
1906 +index 4c6c9167ef509..bbbf9ce428672 100644
1907 +--- a/drivers/clk/rockchip/clk-pll.c
1908 ++++ b/drivers/clk/rockchip/clk-pll.c
1909 +@@ -940,7 +940,7 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
1910 + switch (pll_type) {
1911 + case pll_rk3036:
1912 + case pll_rk3328:
1913 +- if (!pll->rate_table || IS_ERR(ctx->grf))
1914 ++ if (!pll->rate_table)
1915 + init.ops = &rockchip_rk3036_pll_clk_norate_ops;
1916 + else
1917 + init.ops = &rockchip_rk3036_pll_clk_ops;
1918 +diff --git a/drivers/clk/socfpga/clk-agilex.c b/drivers/clk/socfpga/clk-agilex.c
1919 +index 438075a50b9f2..7182afb4258a7 100644
1920 +--- a/drivers/clk/socfpga/clk-agilex.c
1921 ++++ b/drivers/clk/socfpga/clk-agilex.c
1922 +@@ -107,10 +107,10 @@ static const struct clk_parent_data gpio_db_free_mux[] = {
1923 + };
1924 +
1925 + static const struct clk_parent_data psi_ref_free_mux[] = {
1926 +- { .fw_name = "main_pll_c3",
1927 +- .name = "main_pll_c3", },
1928 +- { .fw_name = "peri_pll_c3",
1929 +- .name = "peri_pll_c3", },
1930 ++ { .fw_name = "main_pll_c2",
1931 ++ .name = "main_pll_c2", },
1932 ++ { .fw_name = "peri_pll_c2",
1933 ++ .name = "peri_pll_c2", },
1934 + { .fw_name = "osc1",
1935 + .name = "osc1", },
1936 + { .fw_name = "cb-intosc-hs-div2-clk",
1937 +@@ -193,6 +193,13 @@ static const struct clk_parent_data sdmmc_mux[] = {
1938 + .name = "boot_clk", },
1939 + };
1940 +
1941 ++static const struct clk_parent_data s2f_user0_mux[] = {
1942 ++ { .fw_name = "s2f_user0_free_clk",
1943 ++ .name = "s2f_user0_free_clk", },
1944 ++ { .fw_name = "boot_clk",
1945 ++ .name = "boot_clk", },
1946 ++};
1947 ++
1948 + static const struct clk_parent_data s2f_user1_mux[] = {
1949 + { .fw_name = "s2f_user1_free_clk",
1950 + .name = "s2f_user1_free_clk", },
1951 +@@ -260,7 +267,7 @@ static const struct stratix10_perip_cnt_clock agilex_main_perip_cnt_clks[] = {
1952 + { AGILEX_SDMMC_FREE_CLK, "sdmmc_free_clk", NULL, sdmmc_free_mux,
1953 + ARRAY_SIZE(sdmmc_free_mux), 0, 0xE4, 0, 0, 0},
1954 + { AGILEX_S2F_USER0_FREE_CLK, "s2f_user0_free_clk", NULL, s2f_usr0_free_mux,
1955 +- ARRAY_SIZE(s2f_usr0_free_mux), 0, 0xE8, 0, 0, 0},
1956 ++ ARRAY_SIZE(s2f_usr0_free_mux), 0, 0xE8, 0, 0x30, 2},
1957 + { AGILEX_S2F_USER1_FREE_CLK, "s2f_user1_free_clk", NULL, s2f_usr1_free_mux,
1958 + ARRAY_SIZE(s2f_usr1_free_mux), 0, 0xEC, 0, 0x88, 5},
1959 + { AGILEX_PSI_REF_FREE_CLK, "psi_ref_free_clk", NULL, psi_ref_free_mux,
1960 +@@ -306,6 +313,8 @@ static const struct stratix10_gate_clock agilex_gate_clks[] = {
1961 + 4, 0x98, 0, 16, 0x88, 3, 0},
1962 + { AGILEX_SDMMC_CLK, "sdmmc_clk", NULL, sdmmc_mux, ARRAY_SIZE(sdmmc_mux), 0, 0x7C,
1963 + 5, 0, 0, 0, 0x88, 4, 4},
1964 ++ { AGILEX_S2F_USER0_CLK, "s2f_user0_clk", NULL, s2f_user0_mux, ARRAY_SIZE(s2f_user0_mux), 0, 0x24,
1965 ++ 6, 0, 0, 0, 0x30, 2, 0},
1966 + { AGILEX_S2F_USER1_CLK, "s2f_user1_clk", NULL, s2f_user1_mux, ARRAY_SIZE(s2f_user1_mux), 0, 0x7C,
1967 + 6, 0, 0, 0, 0x88, 5, 0},
1968 + { AGILEX_PSI_REF_CLK, "psi_ref_clk", NULL, psi_mux, ARRAY_SIZE(psi_mux), 0, 0x7C,
1969 +diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
1970 +index e439b43c19ebe..8977e4de59157 100644
1971 +--- a/drivers/cpufreq/powernv-cpufreq.c
1972 ++++ b/drivers/cpufreq/powernv-cpufreq.c
1973 +@@ -36,6 +36,7 @@
1974 + #define MAX_PSTATE_SHIFT 32
1975 + #define LPSTATE_SHIFT 48
1976 + #define GPSTATE_SHIFT 56
1977 ++#define MAX_NR_CHIPS 32
1978 +
1979 + #define MAX_RAMP_DOWN_TIME 5120
1980 + /*
1981 +@@ -1051,12 +1052,20 @@ static int init_chip_info(void)
1982 + unsigned int *chip;
1983 + unsigned int cpu, i;
1984 + unsigned int prev_chip_id = UINT_MAX;
1985 ++ cpumask_t *chip_cpu_mask;
1986 + int ret = 0;
1987 +
1988 + chip = kcalloc(num_possible_cpus(), sizeof(*chip), GFP_KERNEL);
1989 + if (!chip)
1990 + return -ENOMEM;
1991 +
1992 ++ /* Allocate a chip cpu mask large enough to fit mask for all chips */
1993 ++ chip_cpu_mask = kcalloc(MAX_NR_CHIPS, sizeof(cpumask_t), GFP_KERNEL);
1994 ++ if (!chip_cpu_mask) {
1995 ++ ret = -ENOMEM;
1996 ++ goto free_and_return;
1997 ++ }
1998 ++
1999 + for_each_possible_cpu(cpu) {
2000 + unsigned int id = cpu_to_chip_id(cpu);
2001 +
2002 +@@ -1064,22 +1073,25 @@ static int init_chip_info(void)
2003 + prev_chip_id = id;
2004 + chip[nr_chips++] = id;
2005 + }
2006 ++ cpumask_set_cpu(cpu, &chip_cpu_mask[nr_chips-1]);
2007 + }
2008 +
2009 + chips = kcalloc(nr_chips, sizeof(struct chip), GFP_KERNEL);
2010 + if (!chips) {
2011 + ret = -ENOMEM;
2012 +- goto free_and_return;
2013 ++ goto out_free_chip_cpu_mask;
2014 + }
2015 +
2016 + for (i = 0; i < nr_chips; i++) {
2017 + chips[i].id = chip[i];
2018 +- cpumask_copy(&chips[i].mask, cpumask_of_node(chip[i]));
2019 ++ cpumask_copy(&chips[i].mask, &chip_cpu_mask[i]);
2020 + INIT_WORK(&chips[i].throttle, powernv_cpufreq_work_fn);
2021 + for_each_cpu(cpu, &chips[i].mask)
2022 + per_cpu(chip_info, cpu) = &chips[i];
2023 + }
2024 +
2025 ++out_free_chip_cpu_mask:
2026 ++ kfree(chip_cpu_mask);
2027 + free_and_return:
2028 + kfree(chip);
2029 + return ret;
2030 +diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c
2031 +index a2b5c6f60cf0e..ff164dec8422e 100644
2032 +--- a/drivers/cpuidle/cpuidle-pseries.c
2033 ++++ b/drivers/cpuidle/cpuidle-pseries.c
2034 +@@ -402,7 +402,7 @@ static void __init fixup_cede0_latency(void)
2035 + * pseries_idle_probe()
2036 + * Choose state table for shared versus dedicated partition
2037 + */
2038 +-static int pseries_idle_probe(void)
2039 ++static int __init pseries_idle_probe(void)
2040 + {
2041 +
2042 + if (cpuidle_disable != IDLE_NO_OVERRIDE)
2043 +@@ -419,7 +419,21 @@ static int pseries_idle_probe(void)
2044 + cpuidle_state_table = shared_states;
2045 + max_idle_state = ARRAY_SIZE(shared_states);
2046 + } else {
2047 +- fixup_cede0_latency();
2048 ++ /*
2049 ++ * Use firmware provided latency values
2050 ++ * starting with POWER10 platforms. In the
2051 ++ * case that we are running on a POWER10
2052 ++ * platform but in an earlier compat mode, we
2053 ++ * can still use the firmware provided values.
2054 ++ *
2055 ++ * However, on platforms prior to POWER10, we
2056 ++ * cannot rely on the accuracy of the firmware
2057 ++ * provided latency values. On such platforms,
2058 ++ * go with the conservative default estimate
2059 ++ * of 10us.
2060 ++ */
2061 ++ if (cpu_has_feature(CPU_FTR_ARCH_31) || pvr_version_is(PVR_POWER10))
2062 ++ fixup_cede0_latency();
2063 + cpuidle_state_table = dedicated_states;
2064 + max_idle_state = NR_DEDICATED_STATES;
2065 + }
2066 +diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
2067 +index d0018794e92e8..57b57d4db500c 100644
2068 +--- a/drivers/crypto/ccp/sev-dev.c
2069 ++++ b/drivers/crypto/ccp/sev-dev.c
2070 +@@ -278,6 +278,9 @@ static int __sev_platform_shutdown_locked(int *error)
2071 + struct sev_device *sev = psp_master->sev_data;
2072 + int ret;
2073 +
2074 ++ if (sev->state == SEV_STATE_UNINIT)
2075 ++ return 0;
2076 ++
2077 + ret = __sev_do_cmd_locked(SEV_CMD_SHUTDOWN, NULL, error);
2078 + if (ret)
2079 + return ret;
2080 +@@ -1018,6 +1021,20 @@ e_err:
2081 + return ret;
2082 + }
2083 +
2084 ++static void sev_firmware_shutdown(struct sev_device *sev)
2085 ++{
2086 ++ sev_platform_shutdown(NULL);
2087 ++
2088 ++ if (sev_es_tmr) {
2089 ++ /* The TMR area was encrypted, flush it from the cache */
2090 ++ wbinvd_on_all_cpus();
2091 ++
2092 ++ free_pages((unsigned long)sev_es_tmr,
2093 ++ get_order(SEV_ES_TMR_SIZE));
2094 ++ sev_es_tmr = NULL;
2095 ++ }
2096 ++}
2097 ++
2098 + void sev_dev_destroy(struct psp_device *psp)
2099 + {
2100 + struct sev_device *sev = psp->sev_data;
2101 +@@ -1025,6 +1042,8 @@ void sev_dev_destroy(struct psp_device *psp)
2102 + if (!sev)
2103 + return;
2104 +
2105 ++ sev_firmware_shutdown(sev);
2106 ++
2107 + if (sev->misc)
2108 + kref_put(&misc_dev->refcount, sev_exit);
2109 +
2110 +@@ -1055,21 +1074,6 @@ void sev_pci_init(void)
2111 + if (sev_get_api_version())
2112 + goto err;
2113 +
2114 +- /*
2115 +- * If platform is not in UNINIT state then firmware upgrade and/or
2116 +- * platform INIT command will fail. These command require UNINIT state.
2117 +- *
2118 +- * In a normal boot we should never run into case where the firmware
2119 +- * is not in UNINIT state on boot. But in case of kexec boot, a reboot
2120 +- * may not go through a typical shutdown sequence and may leave the
2121 +- * firmware in INIT or WORKING state.
2122 +- */
2123 +-
2124 +- if (sev->state != SEV_STATE_UNINIT) {
2125 +- sev_platform_shutdown(NULL);
2126 +- sev->state = SEV_STATE_UNINIT;
2127 +- }
2128 +-
2129 + if (sev_version_greater_or_equal(0, 15) &&
2130 + sev_update_firmware(sev->dev) == 0)
2131 + sev_get_api_version();
2132 +@@ -1114,17 +1118,10 @@ err:
2133 +
2134 + void sev_pci_exit(void)
2135 + {
2136 +- if (!psp_master->sev_data)
2137 +- return;
2138 +-
2139 +- sev_platform_shutdown(NULL);
2140 ++ struct sev_device *sev = psp_master->sev_data;
2141 +
2142 +- if (sev_es_tmr) {
2143 +- /* The TMR area was encrypted, flush it from the cache */
2144 +- wbinvd_on_all_cpus();
2145 ++ if (!sev)
2146 ++ return;
2147 +
2148 +- free_pages((unsigned long)sev_es_tmr,
2149 +- get_order(SEV_ES_TMR_SIZE));
2150 +- sev_es_tmr = NULL;
2151 +- }
2152 ++ sev_firmware_shutdown(sev);
2153 + }
2154 +diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
2155 +index 7d346d842a39e..c319e7e3917dc 100644
2156 +--- a/drivers/crypto/ccp/sp-pci.c
2157 ++++ b/drivers/crypto/ccp/sp-pci.c
2158 +@@ -241,6 +241,17 @@ e_err:
2159 + return ret;
2160 + }
2161 +
2162 ++static void sp_pci_shutdown(struct pci_dev *pdev)
2163 ++{
2164 ++ struct device *dev = &pdev->dev;
2165 ++ struct sp_device *sp = dev_get_drvdata(dev);
2166 ++
2167 ++ if (!sp)
2168 ++ return;
2169 ++
2170 ++ sp_destroy(sp);
2171 ++}
2172 ++
2173 + static void sp_pci_remove(struct pci_dev *pdev)
2174 + {
2175 + struct device *dev = &pdev->dev;
2176 +@@ -370,6 +381,7 @@ static struct pci_driver sp_pci_driver = {
2177 + .id_table = sp_pci_table,
2178 + .probe = sp_pci_probe,
2179 + .remove = sp_pci_remove,
2180 ++ .shutdown = sp_pci_shutdown,
2181 + .driver.pm = &sp_pci_pm_ops,
2182 + };
2183 +
2184 +diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
2185 +index 7daed8b78ac83..5edc91cdb4e65 100644
2186 +--- a/drivers/crypto/mxs-dcp.c
2187 ++++ b/drivers/crypto/mxs-dcp.c
2188 +@@ -299,21 +299,20 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
2189 +
2190 + struct scatterlist *dst = req->dst;
2191 + struct scatterlist *src = req->src;
2192 +- const int nents = sg_nents(req->src);
2193 ++ int dst_nents = sg_nents(dst);
2194 +
2195 + const int out_off = DCP_BUF_SZ;
2196 + uint8_t *in_buf = sdcp->coh->aes_in_buf;
2197 + uint8_t *out_buf = sdcp->coh->aes_out_buf;
2198 +
2199 +- uint8_t *out_tmp, *src_buf, *dst_buf = NULL;
2200 + uint32_t dst_off = 0;
2201 ++ uint8_t *src_buf = NULL;
2202 + uint32_t last_out_len = 0;
2203 +
2204 + uint8_t *key = sdcp->coh->aes_key;
2205 +
2206 + int ret = 0;
2207 +- int split = 0;
2208 +- unsigned int i, len, clen, rem = 0, tlen = 0;
2209 ++ unsigned int i, len, clen, tlen = 0;
2210 + int init = 0;
2211 + bool limit_hit = false;
2212 +
2213 +@@ -331,7 +330,7 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
2214 + memset(key + AES_KEYSIZE_128, 0, AES_KEYSIZE_128);
2215 + }
2216 +
2217 +- for_each_sg(req->src, src, nents, i) {
2218 ++ for_each_sg(req->src, src, sg_nents(src), i) {
2219 + src_buf = sg_virt(src);
2220 + len = sg_dma_len(src);
2221 + tlen += len;
2222 +@@ -356,34 +355,17 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
2223 + * submit the buffer.
2224 + */
2225 + if (actx->fill == out_off || sg_is_last(src) ||
2226 +- limit_hit) {
2227 ++ limit_hit) {
2228 + ret = mxs_dcp_run_aes(actx, req, init);
2229 + if (ret)
2230 + return ret;
2231 + init = 0;
2232 +
2233 +- out_tmp = out_buf;
2234 ++ sg_pcopy_from_buffer(dst, dst_nents, out_buf,
2235 ++ actx->fill, dst_off);
2236 ++ dst_off += actx->fill;
2237 + last_out_len = actx->fill;
2238 +- while (dst && actx->fill) {
2239 +- if (!split) {
2240 +- dst_buf = sg_virt(dst);
2241 +- dst_off = 0;
2242 +- }
2243 +- rem = min(sg_dma_len(dst) - dst_off,
2244 +- actx->fill);
2245 +-
2246 +- memcpy(dst_buf + dst_off, out_tmp, rem);
2247 +- out_tmp += rem;
2248 +- dst_off += rem;
2249 +- actx->fill -= rem;
2250 +-
2251 +- if (dst_off == sg_dma_len(dst)) {
2252 +- dst = sg_next(dst);
2253 +- split = 0;
2254 +- } else {
2255 +- split = 1;
2256 +- }
2257 +- }
2258 ++ actx->fill = 0;
2259 + }
2260 + } while (len);
2261 +
2262 +diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
2263 +index 16b908c77db30..306f93e4b26a8 100644
2264 +--- a/drivers/dma/imx-sdma.c
2265 ++++ b/drivers/dma/imx-sdma.c
2266 +@@ -379,7 +379,6 @@ struct sdma_channel {
2267 + unsigned long watermark_level;
2268 + u32 shp_addr, per_addr;
2269 + enum dma_status status;
2270 +- bool context_loaded;
2271 + struct imx_dma_data data;
2272 + struct work_struct terminate_worker;
2273 + };
2274 +@@ -985,9 +984,6 @@ static int sdma_load_context(struct sdma_channel *sdmac)
2275 + int ret;
2276 + unsigned long flags;
2277 +
2278 +- if (sdmac->context_loaded)
2279 +- return 0;
2280 +-
2281 + if (sdmac->direction == DMA_DEV_TO_MEM)
2282 + load_address = sdmac->pc_from_device;
2283 + else if (sdmac->direction == DMA_DEV_TO_DEV)
2284 +@@ -1030,8 +1026,6 @@ static int sdma_load_context(struct sdma_channel *sdmac)
2285 +
2286 + spin_unlock_irqrestore(&sdma->channel_0_lock, flags);
2287 +
2288 +- sdmac->context_loaded = true;
2289 +-
2290 + return ret;
2291 + }
2292 +
2293 +@@ -1070,7 +1064,6 @@ static void sdma_channel_terminate_work(struct work_struct *work)
2294 + vchan_get_all_descriptors(&sdmac->vc, &head);
2295 + spin_unlock_irqrestore(&sdmac->vc.lock, flags);
2296 + vchan_dma_desc_free_list(&sdmac->vc, &head);
2297 +- sdmac->context_loaded = false;
2298 + }
2299 +
2300 + static int sdma_terminate_all(struct dma_chan *chan)
2301 +@@ -1145,7 +1138,6 @@ static void sdma_set_watermarklevel_for_p2p(struct sdma_channel *sdmac)
2302 + static int sdma_config_channel(struct dma_chan *chan)
2303 + {
2304 + struct sdma_channel *sdmac = to_sdma_chan(chan);
2305 +- int ret;
2306 +
2307 + sdma_disable_channel(chan);
2308 +
2309 +@@ -1185,9 +1177,7 @@ static int sdma_config_channel(struct dma_chan *chan)
2310 + sdmac->watermark_level = 0; /* FIXME: M3_BASE_ADDRESS */
2311 + }
2312 +
2313 +- ret = sdma_load_context(sdmac);
2314 +-
2315 +- return ret;
2316 ++ return 0;
2317 + }
2318 +
2319 + static int sdma_set_channel_priority(struct sdma_channel *sdmac,
2320 +@@ -1338,7 +1328,6 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
2321 +
2322 + sdmac->event_id0 = 0;
2323 + sdmac->event_id1 = 0;
2324 +- sdmac->context_loaded = false;
2325 +
2326 + sdma_set_channel_priority(sdmac, 0);
2327 +
2328 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
2329 +index 47cad23a6b9e2..b91d3d29b4102 100644
2330 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
2331 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
2332 +@@ -339,7 +339,7 @@ static void amdgpu_i2c_put_byte(struct amdgpu_i2c_chan *i2c_bus,
2333 + void
2334 + amdgpu_i2c_router_select_ddc_port(const struct amdgpu_connector *amdgpu_connector)
2335 + {
2336 +- u8 val;
2337 ++ u8 val = 0;
2338 +
2339 + if (!amdgpu_connector->router.ddc_valid)
2340 + return;
2341 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
2342 +index ac043baac05d6..ad9863b84f1fc 100644
2343 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
2344 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
2345 +@@ -207,7 +207,7 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
2346 + c++;
2347 + }
2348 +
2349 +- BUG_ON(c >= AMDGPU_BO_MAX_PLACEMENTS);
2350 ++ BUG_ON(c > AMDGPU_BO_MAX_PLACEMENTS);
2351 +
2352 + placement->num_placement = c;
2353 + placement->placement = places;
2354 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
2355 +index 0e64c39a23722..7c3efc5f1be07 100644
2356 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
2357 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
2358 +@@ -305,7 +305,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control,
2359 + return ret;
2360 + }
2361 +
2362 +- __decode_table_header_from_buff(hdr, &buff[2]);
2363 ++ __decode_table_header_from_buff(hdr, buff);
2364 +
2365 + if (hdr->header == EEPROM_TABLE_HDR_VAL) {
2366 + control->num_recs = (hdr->tbl_size - EEPROM_TABLE_HEADER_SIZE) /
2367 +diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
2368 +index aa8ae0ca62f91..e8737fa438f06 100644
2369 +--- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
2370 ++++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
2371 +@@ -120,7 +120,7 @@ static int vcn_v1_0_sw_init(void *handle)
2372 + adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].fw = adev->vcn.fw;
2373 + adev->firmware.fw_size +=
2374 + ALIGN(le32_to_cpu(hdr->ucode_size_bytes), PAGE_SIZE);
2375 +- DRM_INFO("PSP loading VCN firmware\n");
2376 ++ dev_info(adev->dev, "Will use PSP to load VCN firmware\n");
2377 + }
2378 +
2379 + r = amdgpu_vcn_resume(adev);
2380 +diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
2381 +index fc939d4f4841e..f493b5c3d382b 100644
2382 +--- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
2383 ++++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
2384 +@@ -122,7 +122,7 @@ static int vcn_v2_0_sw_init(void *handle)
2385 + adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].fw = adev->vcn.fw;
2386 + adev->firmware.fw_size +=
2387 + ALIGN(le32_to_cpu(hdr->ucode_size_bytes), PAGE_SIZE);
2388 +- DRM_INFO("PSP loading VCN firmware\n");
2389 ++ dev_info(adev->dev, "Will use PSP to load VCN firmware\n");
2390 + }
2391 +
2392 + r = amdgpu_vcn_resume(adev);
2393 +diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
2394 +index 2c328362eee3c..ce64d4016f903 100644
2395 +--- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
2396 ++++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
2397 +@@ -152,7 +152,7 @@ static int vcn_v2_5_sw_init(void *handle)
2398 + adev->firmware.fw_size +=
2399 + ALIGN(le32_to_cpu(hdr->ucode_size_bytes), PAGE_SIZE);
2400 + }
2401 +- DRM_INFO("PSP loading VCN firmware\n");
2402 ++ dev_info(adev->dev, "Will use PSP to load VCN firmware\n");
2403 + }
2404 +
2405 + r = amdgpu_vcn_resume(adev);
2406 +diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
2407 +index c9c888be12285..2099f6ebd8338 100644
2408 +--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
2409 ++++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
2410 +@@ -148,7 +148,7 @@ static int vcn_v3_0_sw_init(void *handle)
2411 + adev->firmware.fw_size +=
2412 + ALIGN(le32_to_cpu(hdr->ucode_size_bytes), PAGE_SIZE);
2413 + }
2414 +- DRM_INFO("PSP loading VCN firmware\n");
2415 ++ dev_info(adev->dev, "Will use PSP to load VCN firmware\n");
2416 + }
2417 +
2418 + r = amdgpu_vcn_resume(adev);
2419 +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
2420 +index 88813dad731fa..c021519af8106 100644
2421 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
2422 ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
2423 +@@ -98,36 +98,78 @@ void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm,
2424 + uint32_t *se_mask)
2425 + {
2426 + struct kfd_cu_info cu_info;
2427 +- uint32_t cu_per_se[KFD_MAX_NUM_SE] = {0};
2428 +- int i, se, sh, cu = 0;
2429 +-
2430 ++ uint32_t cu_per_sh[KFD_MAX_NUM_SE][KFD_MAX_NUM_SH_PER_SE] = {0};
2431 ++ int i, se, sh, cu;
2432 + amdgpu_amdkfd_get_cu_info(mm->dev->kgd, &cu_info);
2433 +
2434 + if (cu_mask_count > cu_info.cu_active_number)
2435 + cu_mask_count = cu_info.cu_active_number;
2436 +
2437 ++ /* Exceeding these bounds corrupts the stack and indicates a coding error.
2438 ++ * Returning with no CU's enabled will hang the queue, which should be
2439 ++ * attention grabbing.
2440 ++ */
2441 ++ if (cu_info.num_shader_engines > KFD_MAX_NUM_SE) {
2442 ++ pr_err("Exceeded KFD_MAX_NUM_SE, chip reports %d\n", cu_info.num_shader_engines);
2443 ++ return;
2444 ++ }
2445 ++ if (cu_info.num_shader_arrays_per_engine > KFD_MAX_NUM_SH_PER_SE) {
2446 ++ pr_err("Exceeded KFD_MAX_NUM_SH, chip reports %d\n",
2447 ++ cu_info.num_shader_arrays_per_engine * cu_info.num_shader_engines);
2448 ++ return;
2449 ++ }
2450 ++ /* Count active CUs per SH.
2451 ++ *
2452 ++ * Some CUs in an SH may be disabled. HW expects disabled CUs to be
2453 ++ * represented in the high bits of each SH's enable mask (the upper and lower
2454 ++ * 16 bits of se_mask) and will take care of the actual distribution of
2455 ++ * disabled CUs within each SH automatically.
2456 ++ * Each half of se_mask must be filled only on bits 0-cu_per_sh[se][sh]-1.
2457 ++ *
2458 ++ * See note on Arcturus cu_bitmap layout in gfx_v9_0_get_cu_info.
2459 ++ */
2460 + for (se = 0; se < cu_info.num_shader_engines; se++)
2461 + for (sh = 0; sh < cu_info.num_shader_arrays_per_engine; sh++)
2462 +- cu_per_se[se] += hweight32(cu_info.cu_bitmap[se % 4][sh + (se / 4)]);
2463 +-
2464 +- /* Symmetrically map cu_mask to all SEs:
2465 +- * cu_mask[0] bit0 -> se_mask[0] bit0;
2466 +- * cu_mask[0] bit1 -> se_mask[1] bit0;
2467 +- * ... (if # SE is 4)
2468 +- * cu_mask[0] bit4 -> se_mask[0] bit1;
2469 ++ cu_per_sh[se][sh] = hweight32(cu_info.cu_bitmap[se % 4][sh + (se / 4)]);
2470 ++
2471 ++ /* Symmetrically map cu_mask to all SEs & SHs:
2472 ++ * se_mask programs up to 2 SH in the upper and lower 16 bits.
2473 ++ *
2474 ++ * Examples
2475 ++ * Assuming 1 SH/SE, 4 SEs:
2476 ++ * cu_mask[0] bit0 -> se_mask[0] bit0
2477 ++ * cu_mask[0] bit1 -> se_mask[1] bit0
2478 ++ * ...
2479 ++ * cu_mask[0] bit4 -> se_mask[0] bit1
2480 ++ * ...
2481 ++ *
2482 ++ * Assuming 2 SH/SE, 4 SEs
2483 ++ * cu_mask[0] bit0 -> se_mask[0] bit0 (SE0,SH0,CU0)
2484 ++ * cu_mask[0] bit1 -> se_mask[1] bit0 (SE1,SH0,CU0)
2485 ++ * ...
2486 ++ * cu_mask[0] bit4 -> se_mask[0] bit16 (SE0,SH1,CU0)
2487 ++ * cu_mask[0] bit5 -> se_mask[1] bit16 (SE1,SH1,CU0)
2488 ++ * ...
2489 ++ * cu_mask[0] bit8 -> se_mask[0] bit1 (SE0,SH0,CU1)
2490 + * ...
2491 ++ *
2492 ++ * First ensure all CUs are disabled, then enable user specified CUs.
2493 + */
2494 +- se = 0;
2495 +- for (i = 0; i < cu_mask_count; i++) {
2496 +- if (cu_mask[i / 32] & (1 << (i % 32)))
2497 +- se_mask[se] |= 1 << cu;
2498 +-
2499 +- do {
2500 +- se++;
2501 +- if (se == cu_info.num_shader_engines) {
2502 +- se = 0;
2503 +- cu++;
2504 ++ for (i = 0; i < cu_info.num_shader_engines; i++)
2505 ++ se_mask[i] = 0;
2506 ++
2507 ++ i = 0;
2508 ++ for (cu = 0; cu < 16; cu++) {
2509 ++ for (sh = 0; sh < cu_info.num_shader_arrays_per_engine; sh++) {
2510 ++ for (se = 0; se < cu_info.num_shader_engines; se++) {
2511 ++ if (cu_per_sh[se][sh] > cu) {
2512 ++ if (cu_mask[i / 32] & (1 << (i % 32)))
2513 ++ se_mask[se] |= 1 << (cu + sh * 16);
2514 ++ i++;
2515 ++ if (i == cu_mask_count)
2516 ++ return;
2517 ++ }
2518 + }
2519 +- } while (cu >= cu_per_se[se] && cu < 32);
2520 ++ }
2521 + }
2522 + }
2523 +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h
2524 +index fbdb16418847c..4edc012e31387 100644
2525 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h
2526 ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h
2527 +@@ -27,6 +27,7 @@
2528 + #include "kfd_priv.h"
2529 +
2530 + #define KFD_MAX_NUM_SE 8
2531 ++#define KFD_MAX_NUM_SH_PER_SE 2
2532 +
2533 + /**
2534 + * struct mqd_manager
2535 +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
2536 +index e02a55fc1382f..fbb65c95464b3 100644
2537 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
2538 ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
2539 +@@ -197,29 +197,29 @@ static ssize_t dp_link_settings_read(struct file *f, char __user *buf,
2540 +
2541 + rd_buf_ptr = rd_buf;
2542 +
2543 +- str_len = strlen("Current: %d %d %d ");
2544 +- snprintf(rd_buf_ptr, str_len, "Current: %d %d %d ",
2545 ++ str_len = strlen("Current: %d 0x%x %d ");
2546 ++ snprintf(rd_buf_ptr, str_len, "Current: %d 0x%x %d ",
2547 + link->cur_link_settings.lane_count,
2548 + link->cur_link_settings.link_rate,
2549 + link->cur_link_settings.link_spread);
2550 + rd_buf_ptr += str_len;
2551 +
2552 +- str_len = strlen("Verified: %d %d %d ");
2553 +- snprintf(rd_buf_ptr, str_len, "Verified: %d %d %d ",
2554 ++ str_len = strlen("Verified: %d 0x%x %d ");
2555 ++ snprintf(rd_buf_ptr, str_len, "Verified: %d 0x%x %d ",
2556 + link->verified_link_cap.lane_count,
2557 + link->verified_link_cap.link_rate,
2558 + link->verified_link_cap.link_spread);
2559 + rd_buf_ptr += str_len;
2560 +
2561 +- str_len = strlen("Reported: %d %d %d ");
2562 +- snprintf(rd_buf_ptr, str_len, "Reported: %d %d %d ",
2563 ++ str_len = strlen("Reported: %d 0x%x %d ");
2564 ++ snprintf(rd_buf_ptr, str_len, "Reported: %d 0x%x %d ",
2565 + link->reported_link_cap.lane_count,
2566 + link->reported_link_cap.link_rate,
2567 + link->reported_link_cap.link_spread);
2568 + rd_buf_ptr += str_len;
2569 +
2570 +- str_len = strlen("Preferred: %d %d %d ");
2571 +- snprintf(rd_buf_ptr, str_len, "Preferred: %d %d %d\n",
2572 ++ str_len = strlen("Preferred: %d 0x%x %d ");
2573 ++ snprintf(rd_buf_ptr, str_len, "Preferred: %d 0x%x %d\n",
2574 + link->preferred_link_setting.lane_count,
2575 + link->preferred_link_setting.link_rate,
2576 + link->preferred_link_setting.link_spread);
2577 +diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
2578 +index 0d1e7b56fb395..532f6a1145b55 100644
2579 +--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
2580 ++++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
2581 +@@ -3740,13 +3740,12 @@ enum dc_status dcn10_set_clock(struct dc *dc,
2582 + struct dc_clock_config clock_cfg = {0};
2583 + struct dc_clocks *current_clocks = &context->bw_ctx.bw.dcn.clk;
2584 +
2585 +- if (dc->clk_mgr && dc->clk_mgr->funcs->get_clock)
2586 +- dc->clk_mgr->funcs->get_clock(dc->clk_mgr,
2587 +- context, clock_type, &clock_cfg);
2588 +-
2589 +- if (!dc->clk_mgr->funcs->get_clock)
2590 ++ if (!dc->clk_mgr || !dc->clk_mgr->funcs->get_clock)
2591 + return DC_FAIL_UNSUPPORTED_1;
2592 +
2593 ++ dc->clk_mgr->funcs->get_clock(dc->clk_mgr,
2594 ++ context, clock_type, &clock_cfg);
2595 ++
2596 + if (clk_khz > clock_cfg.max_clock_khz)
2597 + return DC_FAIL_CLK_EXCEED_MAX;
2598 +
2599 +@@ -3764,7 +3763,7 @@ enum dc_status dcn10_set_clock(struct dc *dc,
2600 + else
2601 + return DC_ERROR_UNEXPECTED;
2602 +
2603 +- if (dc->clk_mgr && dc->clk_mgr->funcs->update_clocks)
2604 ++ if (dc->clk_mgr->funcs->update_clocks)
2605 + dc->clk_mgr->funcs->update_clocks(dc->clk_mgr,
2606 + context, true);
2607 + return DC_OK;
2608 +diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
2609 +index 9d3ccdd355825..79a2b9c785f05 100644
2610 +--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
2611 ++++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
2612 +@@ -1704,13 +1704,15 @@ void dcn20_program_front_end_for_ctx(
2613 + dcn20_program_pipe(dc, pipe, context);
2614 + pipe = pipe->bottom_pipe;
2615 + }
2616 +- /* Program secondary blending tree and writeback pipes */
2617 +- pipe = &context->res_ctx.pipe_ctx[i];
2618 +- if (!pipe->prev_odm_pipe && pipe->stream->num_wb_info > 0
2619 +- && (pipe->update_flags.raw || pipe->plane_state->update_flags.raw || pipe->stream->update_flags.raw)
2620 +- && hws->funcs.program_all_writeback_pipes_in_tree)
2621 +- hws->funcs.program_all_writeback_pipes_in_tree(dc, pipe->stream, context);
2622 + }
2623 ++ /* Program secondary blending tree and writeback pipes */
2624 ++ pipe = &context->res_ctx.pipe_ctx[i];
2625 ++ if (!pipe->top_pipe && !pipe->prev_odm_pipe
2626 ++ && pipe->stream && pipe->stream->num_wb_info > 0
2627 ++ && (pipe->update_flags.raw || (pipe->plane_state && pipe->plane_state->update_flags.raw)
2628 ++ || pipe->stream->update_flags.raw)
2629 ++ && hws->funcs.program_all_writeback_pipes_in_tree)
2630 ++ hws->funcs.program_all_writeback_pipes_in_tree(dc, pipe->stream, context);
2631 + }
2632 + }
2633 +
2634 +diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
2635 +index cfe85ba1018e8..5dbc290bcbe86 100644
2636 +--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
2637 ++++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
2638 +@@ -2455,7 +2455,7 @@ void dcn20_set_mcif_arb_params(
2639 + wb_arb_params->cli_watermark[k] = get_wm_writeback_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
2640 + wb_arb_params->pstate_watermark[k] = get_wm_writeback_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
2641 + }
2642 +- wb_arb_params->time_per_pixel = 16.0 / context->res_ctx.pipe_ctx[i].stream->phy_pix_clk; /* 4 bit fraction, ms */
2643 ++ wb_arb_params->time_per_pixel = 16.0 * 1000 / (context->res_ctx.pipe_ctx[i].stream->phy_pix_clk / 1000); /* 4 bit fraction, ms */
2644 + wb_arb_params->slice_lines = 32;
2645 + wb_arb_params->arbitration_slice = 2;
2646 + wb_arb_params->max_scaled_time = dcn20_calc_max_scaled_time(wb_arb_params->time_per_pixel,
2647 +diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb_cm.c b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb_cm.c
2648 +index 8593145379d99..6d621f07be489 100644
2649 +--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb_cm.c
2650 ++++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb_cm.c
2651 +@@ -49,6 +49,11 @@
2652 + static void dwb3_get_reg_field_ogam(struct dcn30_dwbc *dwbc30,
2653 + struct dcn3_xfer_func_reg *reg)
2654 + {
2655 ++ reg->shifts.field_region_start_base = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_BASE_B;
2656 ++ reg->masks.field_region_start_base = dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_START_BASE_B;
2657 ++ reg->shifts.field_offset = dwbc30->dwbc_shift->DWB_OGAM_RAMA_OFFSET_B;
2658 ++ reg->masks.field_offset = dwbc30->dwbc_mask->DWB_OGAM_RAMA_OFFSET_B;
2659 ++
2660 + reg->shifts.exp_region0_lut_offset = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION0_LUT_OFFSET;
2661 + reg->masks.exp_region0_lut_offset = dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION0_LUT_OFFSET;
2662 + reg->shifts.exp_region0_num_segments = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION0_NUM_SEGMENTS;
2663 +@@ -66,8 +71,6 @@ static void dwb3_get_reg_field_ogam(struct dcn30_dwbc *dwbc30,
2664 + reg->masks.field_region_end_base = dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_END_BASE_B;
2665 + reg->shifts.field_region_linear_slope = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_SLOPE_B;
2666 + reg->masks.field_region_linear_slope = dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_START_SLOPE_B;
2667 +- reg->masks.field_offset = dwbc30->dwbc_mask->DWB_OGAM_RAMA_OFFSET_B;
2668 +- reg->shifts.field_offset = dwbc30->dwbc_shift->DWB_OGAM_RAMA_OFFSET_B;
2669 + reg->shifts.exp_region_start = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_B;
2670 + reg->masks.exp_region_start = dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_START_B;
2671 + reg->shifts.exp_resion_start_segment = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_SEGMENT_B;
2672 +@@ -147,18 +150,19 @@ static enum dc_lut_mode dwb3_get_ogam_current(
2673 + uint32_t state_mode;
2674 + uint32_t ram_select;
2675 +
2676 +- REG_GET(DWB_OGAM_CONTROL,
2677 +- DWB_OGAM_MODE, &state_mode);
2678 +- REG_GET(DWB_OGAM_CONTROL,
2679 +- DWB_OGAM_SELECT, &ram_select);
2680 ++ REG_GET_2(DWB_OGAM_CONTROL,
2681 ++ DWB_OGAM_MODE_CURRENT, &state_mode,
2682 ++ DWB_OGAM_SELECT_CURRENT, &ram_select);
2683 +
2684 + if (state_mode == 0) {
2685 + mode = LUT_BYPASS;
2686 + } else if (state_mode == 2) {
2687 + if (ram_select == 0)
2688 + mode = LUT_RAM_A;
2689 +- else
2690 ++ else if (ram_select == 1)
2691 + mode = LUT_RAM_B;
2692 ++ else
2693 ++ mode = LUT_BYPASS;
2694 + } else {
2695 + // Reserved value
2696 + mode = LUT_BYPASS;
2697 +@@ -172,10 +176,10 @@ static void dwb3_configure_ogam_lut(
2698 + struct dcn30_dwbc *dwbc30,
2699 + bool is_ram_a)
2700 + {
2701 +- REG_UPDATE(DWB_OGAM_LUT_CONTROL,
2702 +- DWB_OGAM_LUT_READ_COLOR_SEL, 7);
2703 +- REG_UPDATE(DWB_OGAM_CONTROL,
2704 +- DWB_OGAM_SELECT, is_ram_a == true ? 0 : 1);
2705 ++ REG_UPDATE_2(DWB_OGAM_LUT_CONTROL,
2706 ++ DWB_OGAM_LUT_WRITE_COLOR_MASK, 7,
2707 ++ DWB_OGAM_LUT_HOST_SEL, (is_ram_a == true) ? 0 : 1);
2708 ++
2709 + REG_SET(DWB_OGAM_LUT_INDEX, 0, DWB_OGAM_LUT_INDEX, 0);
2710 + }
2711 +
2712 +@@ -185,17 +189,45 @@ static void dwb3_program_ogam_pwl(struct dcn30_dwbc *dwbc30,
2713 + {
2714 + uint32_t i;
2715 +
2716 +- // triple base implementation
2717 +- for (i = 0; i < num/2; i++) {
2718 +- REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+0].red_reg);
2719 +- REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+0].green_reg);
2720 +- REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+0].blue_reg);
2721 +- REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+1].red_reg);
2722 +- REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+1].green_reg);
2723 +- REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+1].blue_reg);
2724 +- REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+2].red_reg);
2725 +- REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+2].green_reg);
2726 +- REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+2].blue_reg);
2727 ++ uint32_t last_base_value_red = rgb[num-1].red_reg + rgb[num-1].delta_red_reg;
2728 ++ uint32_t last_base_value_green = rgb[num-1].green_reg + rgb[num-1].delta_green_reg;
2729 ++ uint32_t last_base_value_blue = rgb[num-1].blue_reg + rgb[num-1].delta_blue_reg;
2730 ++
2731 ++ if (is_rgb_equal(rgb, num)) {
2732 ++ for (i = 0 ; i < num; i++)
2733 ++ REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[i].red_reg);
2734 ++
2735 ++ REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, last_base_value_red);
2736 ++
2737 ++ } else {
2738 ++
2739 ++ REG_UPDATE(DWB_OGAM_LUT_CONTROL,
2740 ++ DWB_OGAM_LUT_WRITE_COLOR_MASK, 4);
2741 ++
2742 ++ for (i = 0 ; i < num; i++)
2743 ++ REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[i].red_reg);
2744 ++
2745 ++ REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, last_base_value_red);
2746 ++
2747 ++ REG_SET(DWB_OGAM_LUT_INDEX, 0, DWB_OGAM_LUT_INDEX, 0);
2748 ++
2749 ++ REG_UPDATE(DWB_OGAM_LUT_CONTROL,
2750 ++ DWB_OGAM_LUT_WRITE_COLOR_MASK, 2);
2751 ++
2752 ++ for (i = 0 ; i < num; i++)
2753 ++ REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[i].green_reg);
2754 ++
2755 ++ REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, last_base_value_green);
2756 ++
2757 ++ REG_SET(DWB_OGAM_LUT_INDEX, 0, DWB_OGAM_LUT_INDEX, 0);
2758 ++
2759 ++ REG_UPDATE(DWB_OGAM_LUT_CONTROL,
2760 ++ DWB_OGAM_LUT_WRITE_COLOR_MASK, 1);
2761 ++
2762 ++ for (i = 0 ; i < num; i++)
2763 ++ REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[i].blue_reg);
2764 ++
2765 ++ REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, last_base_value_blue);
2766 + }
2767 + }
2768 +
2769 +@@ -211,6 +243,8 @@ static bool dwb3_program_ogam_lut(
2770 + return false;
2771 + }
2772 +
2773 ++ REG_SET(DWB_OGAM_CONTROL, 0, DWB_OGAM_MODE, 2);
2774 ++
2775 + current_mode = dwb3_get_ogam_current(dwbc30);
2776 + if (current_mode == LUT_BYPASS || current_mode == LUT_RAM_A)
2777 + next_mode = LUT_RAM_B;
2778 +@@ -227,8 +261,7 @@ static bool dwb3_program_ogam_lut(
2779 + dwb3_program_ogam_pwl(
2780 + dwbc30, params->rgb_resulted, params->hw_points_num);
2781 +
2782 +- REG_SET(DWB_OGAM_CONTROL, 0, DWB_OGAM_MODE, 2);
2783 +- REG_SET(DWB_OGAM_CONTROL, 0, DWB_OGAM_SELECT, next_mode == LUT_RAM_A ? 0 : 1);
2784 ++ REG_UPDATE(DWB_OGAM_CONTROL, DWB_OGAM_SELECT, next_mode == LUT_RAM_A ? 0 : 1);
2785 +
2786 + return true;
2787 + }
2788 +@@ -271,14 +304,19 @@ static void dwb3_program_gamut_remap(
2789 +
2790 + struct color_matrices_reg gam_regs;
2791 +
2792 +- REG_UPDATE(DWB_GAMUT_REMAP_COEF_FORMAT, DWB_GAMUT_REMAP_COEF_FORMAT, coef_format);
2793 +-
2794 + if (regval == NULL || select == CM_GAMUT_REMAP_MODE_BYPASS) {
2795 + REG_SET(DWB_GAMUT_REMAP_MODE, 0,
2796 + DWB_GAMUT_REMAP_MODE, 0);
2797 + return;
2798 + }
2799 +
2800 ++ REG_UPDATE(DWB_GAMUT_REMAP_COEF_FORMAT, DWB_GAMUT_REMAP_COEF_FORMAT, coef_format);
2801 ++
2802 ++ gam_regs.shifts.csc_c11 = dwbc30->dwbc_shift->DWB_GAMUT_REMAPA_C11;
2803 ++ gam_regs.masks.csc_c11 = dwbc30->dwbc_mask->DWB_GAMUT_REMAPA_C11;
2804 ++ gam_regs.shifts.csc_c12 = dwbc30->dwbc_shift->DWB_GAMUT_REMAPA_C12;
2805 ++ gam_regs.masks.csc_c12 = dwbc30->dwbc_mask->DWB_GAMUT_REMAPA_C12;
2806 ++
2807 + switch (select) {
2808 + case CM_GAMUT_REMAP_MODE_RAMA_COEFF:
2809 + gam_regs.csc_c11_c12 = REG(DWB_GAMUT_REMAPA_C11_C12);
2810 +diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c
2811 +index 97909d5aab344..22c77e96f6a54 100644
2812 +--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c
2813 ++++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c
2814 +@@ -396,12 +396,22 @@ void dcn30_program_all_writeback_pipes_in_tree(
2815 + for (i_pipe = 0; i_pipe < dc->res_pool->pipe_count; i_pipe++) {
2816 + struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i_pipe];
2817 +
2818 ++ if (!pipe_ctx->plane_state)
2819 ++ continue;
2820 ++
2821 + if (pipe_ctx->plane_state == wb_info.writeback_source_plane) {
2822 + wb_info.mpcc_inst = pipe_ctx->plane_res.mpcc_inst;
2823 + break;
2824 + }
2825 + }
2826 +- ASSERT(wb_info.mpcc_inst != -1);
2827 ++
2828 ++ if (wb_info.mpcc_inst == -1) {
2829 ++ /* Disable writeback pipe and disconnect from MPCC
2830 ++ * if source plane has been removed
2831 ++ */
2832 ++ dc->hwss.disable_writeback(dc, wb_info.dwb_pipe_inst);
2833 ++ continue;
2834 ++ }
2835 +
2836 + ASSERT(wb_info.dwb_pipe_inst < dc->res_pool->res_cap->num_dwb);
2837 + dwb = dc->res_pool->dwbc[wb_info.dwb_pipe_inst];
2838 +diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
2839 +index e5f4f93317cf3..32993ce24a585 100644
2840 +--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
2841 ++++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
2842 +@@ -2455,16 +2455,37 @@ void dcn30_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params
2843 + dc->dml.soc.dispclk_dppclk_vco_speed_mhz = dc->clk_mgr->dentist_vco_freq_khz / 1000.0;
2844 +
2845 + if (bw_params->clk_table.entries[0].memclk_mhz) {
2846 ++ int max_dcfclk_mhz = 0, max_dispclk_mhz = 0, max_dppclk_mhz = 0, max_phyclk_mhz = 0;
2847 ++
2848 ++ for (i = 0; i < MAX_NUM_DPM_LVL; i++) {
2849 ++ if (bw_params->clk_table.entries[i].dcfclk_mhz > max_dcfclk_mhz)
2850 ++ max_dcfclk_mhz = bw_params->clk_table.entries[i].dcfclk_mhz;
2851 ++ if (bw_params->clk_table.entries[i].dispclk_mhz > max_dispclk_mhz)
2852 ++ max_dispclk_mhz = bw_params->clk_table.entries[i].dispclk_mhz;
2853 ++ if (bw_params->clk_table.entries[i].dppclk_mhz > max_dppclk_mhz)
2854 ++ max_dppclk_mhz = bw_params->clk_table.entries[i].dppclk_mhz;
2855 ++ if (bw_params->clk_table.entries[i].phyclk_mhz > max_phyclk_mhz)
2856 ++ max_phyclk_mhz = bw_params->clk_table.entries[i].phyclk_mhz;
2857 ++ }
2858 ++
2859 ++ if (!max_dcfclk_mhz)
2860 ++ max_dcfclk_mhz = dcn3_0_soc.clock_limits[0].dcfclk_mhz;
2861 ++ if (!max_dispclk_mhz)
2862 ++ max_dispclk_mhz = dcn3_0_soc.clock_limits[0].dispclk_mhz;
2863 ++ if (!max_dppclk_mhz)
2864 ++ max_dppclk_mhz = dcn3_0_soc.clock_limits[0].dppclk_mhz;
2865 ++ if (!max_phyclk_mhz)
2866 ++ max_phyclk_mhz = dcn3_0_soc.clock_limits[0].phyclk_mhz;
2867 +
2868 +- if (bw_params->clk_table.entries[1].dcfclk_mhz > dcfclk_sta_targets[num_dcfclk_sta_targets-1]) {
2869 ++ if (max_dcfclk_mhz > dcfclk_sta_targets[num_dcfclk_sta_targets-1]) {
2870 + // If max DCFCLK is greater than the max DCFCLK STA target, insert into the DCFCLK STA target array
2871 +- dcfclk_sta_targets[num_dcfclk_sta_targets] = bw_params->clk_table.entries[1].dcfclk_mhz;
2872 ++ dcfclk_sta_targets[num_dcfclk_sta_targets] = max_dcfclk_mhz;
2873 + num_dcfclk_sta_targets++;
2874 +- } else if (bw_params->clk_table.entries[1].dcfclk_mhz < dcfclk_sta_targets[num_dcfclk_sta_targets-1]) {
2875 ++ } else if (max_dcfclk_mhz < dcfclk_sta_targets[num_dcfclk_sta_targets-1]) {
2876 + // If max DCFCLK is less than the max DCFCLK STA target, cap values and remove duplicates
2877 + for (i = 0; i < num_dcfclk_sta_targets; i++) {
2878 +- if (dcfclk_sta_targets[i] > bw_params->clk_table.entries[1].dcfclk_mhz) {
2879 +- dcfclk_sta_targets[i] = bw_params->clk_table.entries[1].dcfclk_mhz;
2880 ++ if (dcfclk_sta_targets[i] > max_dcfclk_mhz) {
2881 ++ dcfclk_sta_targets[i] = max_dcfclk_mhz;
2882 + break;
2883 + }
2884 + }
2885 +@@ -2502,7 +2523,7 @@ void dcn30_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params
2886 + dcfclk_mhz[num_states] = dcfclk_sta_targets[i];
2887 + dram_speed_mts[num_states++] = optimal_uclk_for_dcfclk_sta_targets[i++];
2888 + } else {
2889 +- if (j < num_uclk_states && optimal_dcfclk_for_uclk[j] <= bw_params->clk_table.entries[1].dcfclk_mhz) {
2890 ++ if (j < num_uclk_states && optimal_dcfclk_for_uclk[j] <= max_dcfclk_mhz) {
2891 + dcfclk_mhz[num_states] = optimal_dcfclk_for_uclk[j];
2892 + dram_speed_mts[num_states++] = bw_params->clk_table.entries[j++].memclk_mhz * 16;
2893 + } else {
2894 +@@ -2517,11 +2538,12 @@ void dcn30_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params
2895 + }
2896 +
2897 + while (j < num_uclk_states && num_states < DC__VOLTAGE_STATES &&
2898 +- optimal_dcfclk_for_uclk[j] <= bw_params->clk_table.entries[1].dcfclk_mhz) {
2899 ++ optimal_dcfclk_for_uclk[j] <= max_dcfclk_mhz) {
2900 + dcfclk_mhz[num_states] = optimal_dcfclk_for_uclk[j];
2901 + dram_speed_mts[num_states++] = bw_params->clk_table.entries[j++].memclk_mhz * 16;
2902 + }
2903 +
2904 ++ dcn3_0_soc.num_states = num_states;
2905 + for (i = 0; i < dcn3_0_soc.num_states; i++) {
2906 + dcn3_0_soc.clock_limits[i].state = i;
2907 + dcn3_0_soc.clock_limits[i].dcfclk_mhz = dcfclk_mhz[i];
2908 +@@ -2529,9 +2551,9 @@ void dcn30_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params
2909 + dcn3_0_soc.clock_limits[i].dram_speed_mts = dram_speed_mts[i];
2910 +
2911 + /* Fill all states with max values of all other clocks */
2912 +- dcn3_0_soc.clock_limits[i].dispclk_mhz = bw_params->clk_table.entries[1].dispclk_mhz;
2913 +- dcn3_0_soc.clock_limits[i].dppclk_mhz = bw_params->clk_table.entries[1].dppclk_mhz;
2914 +- dcn3_0_soc.clock_limits[i].phyclk_mhz = bw_params->clk_table.entries[1].phyclk_mhz;
2915 ++ dcn3_0_soc.clock_limits[i].dispclk_mhz = max_dispclk_mhz;
2916 ++ dcn3_0_soc.clock_limits[i].dppclk_mhz = max_dppclk_mhz;
2917 ++ dcn3_0_soc.clock_limits[i].phyclk_mhz = max_phyclk_mhz;
2918 + dcn3_0_soc.clock_limits[i].dtbclk_mhz = dcn3_0_soc.clock_limits[0].dtbclk_mhz;
2919 + /* These clocks cannot come from bw_params, always fill from dcn3_0_soc[1] */
2920 + /* FCLK, PHYCLK_D18, SOCCLK, DSCCLK */
2921 +diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c
2922 +index c65ca860712d2..6cac2e58cd15f 100644
2923 +--- a/drivers/gpu/drm/bridge/nwl-dsi.c
2924 ++++ b/drivers/gpu/drm/bridge/nwl-dsi.c
2925 +@@ -196,7 +196,7 @@ static u32 ps2bc(struct nwl_dsi *dsi, unsigned long long ps)
2926 + u32 bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
2927 +
2928 + return DIV64_U64_ROUND_UP(ps * dsi->mode.clock * bpp,
2929 +- dsi->lanes * 8 * NSEC_PER_SEC);
2930 ++ dsi->lanes * 8ULL * NSEC_PER_SEC);
2931 + }
2932 +
2933 + /*
2934 +diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
2935 +index 232abbba36868..c7adbeaf10b1b 100644
2936 +--- a/drivers/gpu/drm/drm_auth.c
2937 ++++ b/drivers/gpu/drm/drm_auth.c
2938 +@@ -135,16 +135,18 @@ static void drm_set_master(struct drm_device *dev, struct drm_file *fpriv,
2939 + static int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv)
2940 + {
2941 + struct drm_master *old_master;
2942 ++ struct drm_master *new_master;
2943 +
2944 + lockdep_assert_held_once(&dev->master_mutex);
2945 +
2946 + WARN_ON(fpriv->is_master);
2947 + old_master = fpriv->master;
2948 +- fpriv->master = drm_master_create(dev);
2949 +- if (!fpriv->master) {
2950 +- fpriv->master = old_master;
2951 ++ new_master = drm_master_create(dev);
2952 ++ if (!new_master)
2953 + return -ENOMEM;
2954 +- }
2955 ++ spin_lock(&fpriv->master_lookup_lock);
2956 ++ fpriv->master = new_master;
2957 ++ spin_unlock(&fpriv->master_lookup_lock);
2958 +
2959 + fpriv->is_master = 1;
2960 + fpriv->authenticated = 1;
2961 +@@ -302,10 +304,13 @@ int drm_master_open(struct drm_file *file_priv)
2962 + /* if there is no current master make this fd it, but do not create
2963 + * any master object for render clients */
2964 + mutex_lock(&dev->master_mutex);
2965 +- if (!dev->master)
2966 ++ if (!dev->master) {
2967 + ret = drm_new_set_master(dev, file_priv);
2968 +- else
2969 ++ } else {
2970 ++ spin_lock(&file_priv->master_lookup_lock);
2971 + file_priv->master = drm_master_get(dev->master);
2972 ++ spin_unlock(&file_priv->master_lookup_lock);
2973 ++ }
2974 + mutex_unlock(&dev->master_mutex);
2975 +
2976 + return ret;
2977 +@@ -371,6 +376,31 @@ struct drm_master *drm_master_get(struct drm_master *master)
2978 + }
2979 + EXPORT_SYMBOL(drm_master_get);
2980 +
2981 ++/**
2982 ++ * drm_file_get_master - reference &drm_file.master of @file_priv
2983 ++ * @file_priv: DRM file private
2984 ++ *
2985 ++ * Increments the reference count of @file_priv's &drm_file.master and returns
2986 ++ * the &drm_file.master. If @file_priv has no &drm_file.master, returns NULL.
2987 ++ *
2988 ++ * Master pointers returned from this function should be unreferenced using
2989 ++ * drm_master_put().
2990 ++ */
2991 ++struct drm_master *drm_file_get_master(struct drm_file *file_priv)
2992 ++{
2993 ++ struct drm_master *master = NULL;
2994 ++
2995 ++ spin_lock(&file_priv->master_lookup_lock);
2996 ++ if (!file_priv->master)
2997 ++ goto unlock;
2998 ++ master = drm_master_get(file_priv->master);
2999 ++
3000 ++unlock:
3001 ++ spin_unlock(&file_priv->master_lookup_lock);
3002 ++ return master;
3003 ++}
3004 ++EXPORT_SYMBOL(drm_file_get_master);
3005 ++
3006 + static void drm_master_destroy(struct kref *kref)
3007 + {
3008 + struct drm_master *master = container_of(kref, struct drm_master, refcount);
3009 +diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
3010 +index 3d7182001004d..b0a8264894885 100644
3011 +--- a/drivers/gpu/drm/drm_debugfs.c
3012 ++++ b/drivers/gpu/drm/drm_debugfs.c
3013 +@@ -91,6 +91,7 @@ static int drm_clients_info(struct seq_file *m, void *data)
3014 + mutex_lock(&dev->filelist_mutex);
3015 + list_for_each_entry_reverse(priv, &dev->filelist, lhead) {
3016 + struct task_struct *task;
3017 ++ bool is_current_master = drm_is_current_master(priv);
3018 +
3019 + rcu_read_lock(); /* locks pid_task()->comm */
3020 + task = pid_task(priv->pid, PIDTYPE_PID);
3021 +@@ -99,7 +100,7 @@ static int drm_clients_info(struct seq_file *m, void *data)
3022 + task ? task->comm : "<unknown>",
3023 + pid_vnr(priv->pid),
3024 + priv->minor->index,
3025 +- drm_is_current_master(priv) ? 'y' : 'n',
3026 ++ is_current_master ? 'y' : 'n',
3027 + priv->authenticated ? 'y' : 'n',
3028 + from_kuid_munged(seq_user_ns(m), uid),
3029 + priv->magic);
3030 +diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
3031 +index 861f16dfd1a3d..1f54e9470165a 100644
3032 +--- a/drivers/gpu/drm/drm_dp_mst_topology.c
3033 ++++ b/drivers/gpu/drm/drm_dp_mst_topology.c
3034 +@@ -2869,11 +2869,13 @@ static int process_single_tx_qlock(struct drm_dp_mst_topology_mgr *mgr,
3035 + idx += tosend + 1;
3036 +
3037 + ret = drm_dp_send_sideband_msg(mgr, up, chunk, idx);
3038 +- if (unlikely(ret) && drm_debug_enabled(DRM_UT_DP)) {
3039 +- struct drm_printer p = drm_debug_printer(DBG_PREFIX);
3040 ++ if (ret) {
3041 ++ if (drm_debug_enabled(DRM_UT_DP)) {
3042 ++ struct drm_printer p = drm_debug_printer(DBG_PREFIX);
3043 +
3044 +- drm_printf(&p, "sideband msg failed to send\n");
3045 +- drm_dp_mst_dump_sideband_msg_tx(&p, txmsg);
3046 ++ drm_printf(&p, "sideband msg failed to send\n");
3047 ++ drm_dp_mst_dump_sideband_msg_tx(&p, txmsg);
3048 ++ }
3049 + return ret;
3050 + }
3051 +
3052 +diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
3053 +index 0ac4566ae3f45..537e7de8e9c33 100644
3054 +--- a/drivers/gpu/drm/drm_file.c
3055 ++++ b/drivers/gpu/drm/drm_file.c
3056 +@@ -177,6 +177,7 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor)
3057 + init_waitqueue_head(&file->event_wait);
3058 + file->event_space = 4096; /* set aside 4k for event buffer */
3059 +
3060 ++ spin_lock_init(&file->master_lookup_lock);
3061 + mutex_init(&file->event_read_lock);
3062 +
3063 + if (drm_core_check_feature(dev, DRIVER_GEM))
3064 +diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c
3065 +index da4f085fc09e7..aef22634005ef 100644
3066 +--- a/drivers/gpu/drm/drm_lease.c
3067 ++++ b/drivers/gpu/drm/drm_lease.c
3068 +@@ -107,10 +107,19 @@ static bool _drm_has_leased(struct drm_master *master, int id)
3069 + */
3070 + bool _drm_lease_held(struct drm_file *file_priv, int id)
3071 + {
3072 +- if (!file_priv || !file_priv->master)
3073 ++ bool ret;
3074 ++ struct drm_master *master;
3075 ++
3076 ++ if (!file_priv)
3077 + return true;
3078 +
3079 +- return _drm_lease_held_master(file_priv->master, id);
3080 ++ master = drm_file_get_master(file_priv);
3081 ++ if (!master)
3082 ++ return true;
3083 ++ ret = _drm_lease_held_master(master, id);
3084 ++ drm_master_put(&master);
3085 ++
3086 ++ return ret;
3087 + }
3088 +
3089 + /**
3090 +@@ -129,13 +138,22 @@ bool drm_lease_held(struct drm_file *file_priv, int id)
3091 + struct drm_master *master;
3092 + bool ret;
3093 +
3094 +- if (!file_priv || !file_priv->master || !file_priv->master->lessor)
3095 ++ if (!file_priv)
3096 + return true;
3097 +
3098 +- master = file_priv->master;
3099 ++ master = drm_file_get_master(file_priv);
3100 ++ if (!master)
3101 ++ return true;
3102 ++ if (!master->lessor) {
3103 ++ ret = true;
3104 ++ goto out;
3105 ++ }
3106 + mutex_lock(&master->dev->mode_config.idr_mutex);
3107 + ret = _drm_lease_held_master(master, id);
3108 + mutex_unlock(&master->dev->mode_config.idr_mutex);
3109 ++
3110 ++out:
3111 ++ drm_master_put(&master);
3112 + return ret;
3113 + }
3114 +
3115 +@@ -155,10 +173,16 @@ uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs_in)
3116 + int count_in, count_out;
3117 + uint32_t crtcs_out = 0;
3118 +
3119 +- if (!file_priv || !file_priv->master || !file_priv->master->lessor)
3120 ++ if (!file_priv)
3121 + return crtcs_in;
3122 +
3123 +- master = file_priv->master;
3124 ++ master = drm_file_get_master(file_priv);
3125 ++ if (!master)
3126 ++ return crtcs_in;
3127 ++ if (!master->lessor) {
3128 ++ crtcs_out = crtcs_in;
3129 ++ goto out;
3130 ++ }
3131 + dev = master->dev;
3132 +
3133 + count_in = count_out = 0;
3134 +@@ -177,6 +201,9 @@ uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs_in)
3135 + count_in++;
3136 + }
3137 + mutex_unlock(&master->dev->mode_config.idr_mutex);
3138 ++
3139 ++out:
3140 ++ drm_master_put(&master);
3141 + return crtcs_out;
3142 + }
3143 +
3144 +@@ -490,7 +517,7 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
3145 + size_t object_count;
3146 + int ret = 0;
3147 + struct idr leases;
3148 +- struct drm_master *lessor = lessor_priv->master;
3149 ++ struct drm_master *lessor;
3150 + struct drm_master *lessee = NULL;
3151 + struct file *lessee_file = NULL;
3152 + struct file *lessor_file = lessor_priv->filp;
3153 +@@ -502,12 +529,6 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
3154 + if (!drm_core_check_feature(dev, DRIVER_MODESET))
3155 + return -EOPNOTSUPP;
3156 +
3157 +- /* Do not allow sub-leases */
3158 +- if (lessor->lessor) {
3159 +- DRM_DEBUG_LEASE("recursive leasing not allowed\n");
3160 +- return -EINVAL;
3161 +- }
3162 +-
3163 + /* need some objects */
3164 + if (cl->object_count == 0) {
3165 + DRM_DEBUG_LEASE("no objects in lease\n");
3166 +@@ -519,12 +540,22 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
3167 + return -EINVAL;
3168 + }
3169 +
3170 ++ lessor = drm_file_get_master(lessor_priv);
3171 ++ /* Do not allow sub-leases */
3172 ++ if (lessor->lessor) {
3173 ++ DRM_DEBUG_LEASE("recursive leasing not allowed\n");
3174 ++ ret = -EINVAL;
3175 ++ goto out_lessor;
3176 ++ }
3177 ++
3178 + object_count = cl->object_count;
3179 +
3180 + object_ids = memdup_user(u64_to_user_ptr(cl->object_ids),
3181 + array_size(object_count, sizeof(__u32)));
3182 +- if (IS_ERR(object_ids))
3183 +- return PTR_ERR(object_ids);
3184 ++ if (IS_ERR(object_ids)) {
3185 ++ ret = PTR_ERR(object_ids);
3186 ++ goto out_lessor;
3187 ++ }
3188 +
3189 + idr_init(&leases);
3190 +
3191 +@@ -535,14 +566,15 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
3192 + if (ret) {
3193 + DRM_DEBUG_LEASE("lease object lookup failed: %i\n", ret);
3194 + idr_destroy(&leases);
3195 +- return ret;
3196 ++ goto out_lessor;
3197 + }
3198 +
3199 + /* Allocate a file descriptor for the lease */
3200 + fd = get_unused_fd_flags(cl->flags & (O_CLOEXEC | O_NONBLOCK));
3201 + if (fd < 0) {
3202 + idr_destroy(&leases);
3203 +- return fd;
3204 ++ ret = fd;
3205 ++ goto out_lessor;
3206 + }
3207 +
3208 + DRM_DEBUG_LEASE("Creating lease\n");
3209 +@@ -578,6 +610,7 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
3210 + /* Hook up the fd */
3211 + fd_install(fd, lessee_file);
3212 +
3213 ++ drm_master_put(&lessor);
3214 + DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl succeeded\n");
3215 + return 0;
3216 +
3217 +@@ -587,6 +620,8 @@ out_lessee:
3218 + out_leases:
3219 + put_unused_fd(fd);
3220 +
3221 ++out_lessor:
3222 ++ drm_master_put(&lessor);
3223 + DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl failed: %d\n", ret);
3224 + return ret;
3225 + }
3226 +@@ -609,7 +644,7 @@ int drm_mode_list_lessees_ioctl(struct drm_device *dev,
3227 + struct drm_mode_list_lessees *arg = data;
3228 + __u32 __user *lessee_ids = (__u32 __user *) (uintptr_t) (arg->lessees_ptr);
3229 + __u32 count_lessees = arg->count_lessees;
3230 +- struct drm_master *lessor = lessor_priv->master, *lessee;
3231 ++ struct drm_master *lessor, *lessee;
3232 + int count;
3233 + int ret = 0;
3234 +
3235 +@@ -620,6 +655,7 @@ int drm_mode_list_lessees_ioctl(struct drm_device *dev,
3236 + if (!drm_core_check_feature(dev, DRIVER_MODESET))
3237 + return -EOPNOTSUPP;
3238 +
3239 ++ lessor = drm_file_get_master(lessor_priv);
3240 + DRM_DEBUG_LEASE("List lessees for %d\n", lessor->lessee_id);
3241 +
3242 + mutex_lock(&dev->mode_config.idr_mutex);
3243 +@@ -643,6 +679,7 @@ int drm_mode_list_lessees_ioctl(struct drm_device *dev,
3244 + arg->count_lessees = count;
3245 +
3246 + mutex_unlock(&dev->mode_config.idr_mutex);
3247 ++ drm_master_put(&lessor);
3248 +
3249 + return ret;
3250 + }
3251 +@@ -662,7 +699,7 @@ int drm_mode_get_lease_ioctl(struct drm_device *dev,
3252 + struct drm_mode_get_lease *arg = data;
3253 + __u32 __user *object_ids = (__u32 __user *) (uintptr_t) (arg->objects_ptr);
3254 + __u32 count_objects = arg->count_objects;
3255 +- struct drm_master *lessee = lessee_priv->master;
3256 ++ struct drm_master *lessee;
3257 + struct idr *object_idr;
3258 + int count;
3259 + void *entry;
3260 +@@ -676,6 +713,7 @@ int drm_mode_get_lease_ioctl(struct drm_device *dev,
3261 + if (!drm_core_check_feature(dev, DRIVER_MODESET))
3262 + return -EOPNOTSUPP;
3263 +
3264 ++ lessee = drm_file_get_master(lessee_priv);
3265 + DRM_DEBUG_LEASE("get lease for %d\n", lessee->lessee_id);
3266 +
3267 + mutex_lock(&dev->mode_config.idr_mutex);
3268 +@@ -703,6 +741,7 @@ int drm_mode_get_lease_ioctl(struct drm_device *dev,
3269 + arg->count_objects = count;
3270 +
3271 + mutex_unlock(&dev->mode_config.idr_mutex);
3272 ++ drm_master_put(&lessee);
3273 +
3274 + return ret;
3275 + }
3276 +@@ -721,7 +760,7 @@ int drm_mode_revoke_lease_ioctl(struct drm_device *dev,
3277 + void *data, struct drm_file *lessor_priv)
3278 + {
3279 + struct drm_mode_revoke_lease *arg = data;
3280 +- struct drm_master *lessor = lessor_priv->master;
3281 ++ struct drm_master *lessor;
3282 + struct drm_master *lessee;
3283 + int ret = 0;
3284 +
3285 +@@ -731,6 +770,7 @@ int drm_mode_revoke_lease_ioctl(struct drm_device *dev,
3286 + if (!drm_core_check_feature(dev, DRIVER_MODESET))
3287 + return -EOPNOTSUPP;
3288 +
3289 ++ lessor = drm_file_get_master(lessor_priv);
3290 + mutex_lock(&dev->mode_config.idr_mutex);
3291 +
3292 + lessee = _drm_find_lessee(lessor, arg->lessee_id);
3293 +@@ -751,6 +791,7 @@ int drm_mode_revoke_lease_ioctl(struct drm_device *dev,
3294 +
3295 + fail:
3296 + mutex_unlock(&dev->mode_config.idr_mutex);
3297 ++ drm_master_put(&lessor);
3298 +
3299 + return ret;
3300 + }
3301 +diff --git a/drivers/gpu/drm/exynos/exynos_drm_dma.c b/drivers/gpu/drm/exynos/exynos_drm_dma.c
3302 +index 0644936afee26..bf33c3084cb41 100644
3303 +--- a/drivers/gpu/drm/exynos/exynos_drm_dma.c
3304 ++++ b/drivers/gpu/drm/exynos/exynos_drm_dma.c
3305 +@@ -115,6 +115,8 @@ int exynos_drm_register_dma(struct drm_device *drm, struct device *dev,
3306 + EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE);
3307 + else if (IS_ENABLED(CONFIG_IOMMU_DMA))
3308 + mapping = iommu_get_domain_for_dev(priv->dma_dev);
3309 ++ else
3310 ++ mapping = ERR_PTR(-ENODEV);
3311 +
3312 + if (IS_ERR(mapping))
3313 + return PTR_ERR(mapping);
3314 +diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h
3315 +index 749a075fe9e4c..d1b51c133e27a 100644
3316 +--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
3317 ++++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
3318 +@@ -43,6 +43,22 @@
3319 + #define ATTR_INDEX 0x1fc0
3320 + #define ATTR_DATA 0x1fc1
3321 +
3322 ++#define WREG_MISC(v) \
3323 ++ WREG8(MGA_MISC_OUT, v)
3324 ++
3325 ++#define RREG_MISC(v) \
3326 ++ ((v) = RREG8(MGA_MISC_IN))
3327 ++
3328 ++#define WREG_MISC_MASKED(v, mask) \
3329 ++ do { \
3330 ++ u8 misc_; \
3331 ++ u8 mask_ = (mask); \
3332 ++ RREG_MISC(misc_); \
3333 ++ misc_ &= ~mask_; \
3334 ++ misc_ |= ((v) & mask_); \
3335 ++ WREG_MISC(misc_); \
3336 ++ } while (0)
3337 ++
3338 + #define WREG_ATTR(reg, v) \
3339 + do { \
3340 + RREG8(0x1fda); \
3341 +diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
3342 +index 38672f9e5c4f3..509968c0d16bc 100644
3343 +--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
3344 ++++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
3345 +@@ -172,6 +172,8 @@ static int mgag200_g200_set_plls(struct mga_device *mdev, long clock)
3346 + drm_dbg_kms(dev, "clock: %ld vco: %ld m: %d n: %d p: %d s: %d\n",
3347 + clock, f_vco, m, n, p, s);
3348 +
3349 ++ WREG_MISC_MASKED(MGAREG_MISC_CLKSEL_MGA, MGAREG_MISC_CLKSEL_MASK);
3350 ++
3351 + WREG_DAC(MGA1064_PIX_PLLC_M, m);
3352 + WREG_DAC(MGA1064_PIX_PLLC_N, n);
3353 + WREG_DAC(MGA1064_PIX_PLLC_P, (p | (s << 3)));
3354 +@@ -287,6 +289,8 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock)
3355 + return 1;
3356 + }
3357 +
3358 ++ WREG_MISC_MASKED(MGAREG_MISC_CLKSEL_MGA, MGAREG_MISC_CLKSEL_MASK);
3359 ++
3360 + WREG_DAC(MGA1064_PIX_PLLC_M, m);
3361 + WREG_DAC(MGA1064_PIX_PLLC_N, n);
3362 + WREG_DAC(MGA1064_PIX_PLLC_P, p);
3363 +@@ -383,6 +387,8 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
3364 + }
3365 + }
3366 +
3367 ++ WREG_MISC_MASKED(MGAREG_MISC_CLKSEL_MGA, MGAREG_MISC_CLKSEL_MASK);
3368 ++
3369 + for (i = 0; i <= 32 && pll_locked == false; i++) {
3370 + if (i > 0) {
3371 + WREG8(MGAREG_CRTC_INDEX, 0x1e);
3372 +@@ -520,6 +526,8 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
3373 + }
3374 + }
3375 +
3376 ++ WREG_MISC_MASKED(MGAREG_MISC_CLKSEL_MGA, MGAREG_MISC_CLKSEL_MASK);
3377 ++
3378 + WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
3379 + tmp = RREG8(DAC_DATA);
3380 + tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS;
3381 +@@ -652,6 +660,9 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
3382 + }
3383 + }
3384 + }
3385 ++
3386 ++ WREG_MISC_MASKED(MGAREG_MISC_CLKSEL_MGA, MGAREG_MISC_CLKSEL_MASK);
3387 ++
3388 + for (i = 0; i <= 32 && pll_locked == false; i++) {
3389 + WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
3390 + tmp = RREG8(DAC_DATA);
3391 +@@ -752,6 +763,8 @@ static int mga_g200er_set_plls(struct mga_device *mdev, long clock)
3392 + }
3393 + }
3394 +
3395 ++ WREG_MISC_MASKED(MGAREG_MISC_CLKSEL_MGA, MGAREG_MISC_CLKSEL_MASK);
3396 ++
3397 + WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
3398 + tmp = RREG8(DAC_DATA);
3399 + tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS;
3400 +@@ -785,8 +798,6 @@ static int mga_g200er_set_plls(struct mga_device *mdev, long clock)
3401 +
3402 + static int mgag200_crtc_set_plls(struct mga_device *mdev, long clock)
3403 + {
3404 +- u8 misc;
3405 +-
3406 + switch(mdev->type) {
3407 + case G200_PCI:
3408 + case G200_AGP:
3409 +@@ -811,11 +822,6 @@ static int mgag200_crtc_set_plls(struct mga_device *mdev, long clock)
3410 + break;
3411 + }
3412 +
3413 +- misc = RREG8(MGA_MISC_IN);
3414 +- misc &= ~MGAREG_MISC_CLK_SEL_MASK;
3415 +- misc |= MGAREG_MISC_CLK_SEL_MGA_MSK;
3416 +- WREG8(MGA_MISC_OUT, misc);
3417 +-
3418 + return 0;
3419 + }
3420 +
3421 +diff --git a/drivers/gpu/drm/mgag200/mgag200_reg.h b/drivers/gpu/drm/mgag200/mgag200_reg.h
3422 +index 977be0565c061..60e705283fe84 100644
3423 +--- a/drivers/gpu/drm/mgag200/mgag200_reg.h
3424 ++++ b/drivers/gpu/drm/mgag200/mgag200_reg.h
3425 +@@ -222,11 +222,10 @@
3426 +
3427 + #define MGAREG_MISC_IOADSEL (0x1 << 0)
3428 + #define MGAREG_MISC_RAMMAPEN (0x1 << 1)
3429 +-#define MGAREG_MISC_CLK_SEL_MASK GENMASK(3, 2)
3430 +-#define MGAREG_MISC_CLK_SEL_VGA25 (0x0 << 2)
3431 +-#define MGAREG_MISC_CLK_SEL_VGA28 (0x1 << 2)
3432 +-#define MGAREG_MISC_CLK_SEL_MGA_PIX (0x2 << 2)
3433 +-#define MGAREG_MISC_CLK_SEL_MGA_MSK (0x3 << 2)
3434 ++#define MGAREG_MISC_CLKSEL_MASK GENMASK(3, 2)
3435 ++#define MGAREG_MISC_CLKSEL_VGA25 (0x0 << 2)
3436 ++#define MGAREG_MISC_CLKSEL_VGA28 (0x1 << 2)
3437 ++#define MGAREG_MISC_CLKSEL_MGA (0x3 << 2)
3438 + #define MGAREG_MISC_VIDEO_DIS (0x1 << 4)
3439 + #define MGAREG_MISC_HIGH_PG_SEL (0x1 << 5)
3440 + #define MGAREG_MISC_HSYNCPOL BIT(6)
3441 +diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
3442 +index c1c152e39918b..913de5938782a 100644
3443 +--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
3444 ++++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
3445 +@@ -89,13 +89,6 @@ static void mdp4_disable_commit(struct msm_kms *kms)
3446 +
3447 + static void mdp4_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *state)
3448 + {
3449 +- int i;
3450 +- struct drm_crtc *crtc;
3451 +- struct drm_crtc_state *crtc_state;
3452 +-
3453 +- /* see 119ecb7fd */
3454 +- for_each_new_crtc_in_state(state, crtc, crtc_state, i)
3455 +- drm_crtc_vblank_get(crtc);
3456 + }
3457 +
3458 + static void mdp4_flush_commit(struct msm_kms *kms, unsigned crtc_mask)
3459 +@@ -114,12 +107,6 @@ static void mdp4_wait_flush(struct msm_kms *kms, unsigned crtc_mask)
3460 +
3461 + static void mdp4_complete_commit(struct msm_kms *kms, unsigned crtc_mask)
3462 + {
3463 +- struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
3464 +- struct drm_crtc *crtc;
3465 +-
3466 +- /* see 119ecb7fd */
3467 +- for_each_crtc_mask(mdp4_kms->dev, crtc, crtc_mask)
3468 +- drm_crtc_vblank_put(crtc);
3469 + }
3470 +
3471 + static long mdp4_round_pixclk(struct msm_kms *kms, unsigned long rate,
3472 +@@ -410,6 +397,7 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev)
3473 + {
3474 + struct platform_device *pdev = to_platform_device(dev->dev);
3475 + struct mdp4_platform_config *config = mdp4_get_config(pdev);
3476 ++ struct msm_drm_private *priv = dev->dev_private;
3477 + struct mdp4_kms *mdp4_kms;
3478 + struct msm_kms *kms = NULL;
3479 + struct msm_gem_address_space *aspace;
3480 +@@ -425,7 +413,8 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev)
3481 +
3482 + mdp_kms_init(&mdp4_kms->base, &kms_funcs);
3483 +
3484 +- kms = &mdp4_kms->base.base;
3485 ++ priv->kms = &mdp4_kms->base.base;
3486 ++ kms = priv->kms;
3487 +
3488 + mdp4_kms->dev = dev;
3489 +
3490 +diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c b/drivers/gpu/drm/msm/dp/dp_panel.c
3491 +index 18cec4fc5e0ba..2768d1d306f00 100644
3492 +--- a/drivers/gpu/drm/msm/dp/dp_panel.c
3493 ++++ b/drivers/gpu/drm/msm/dp/dp_panel.c
3494 +@@ -261,7 +261,7 @@ static u8 dp_panel_get_edid_checksum(struct edid *edid)
3495 + {
3496 + struct edid *last_block;
3497 + u8 *raw_edid;
3498 +- bool is_edid_corrupt;
3499 ++ bool is_edid_corrupt = false;
3500 +
3501 + if (!edid) {
3502 + DRM_ERROR("invalid edid input\n");
3503 +@@ -293,7 +293,12 @@ void dp_panel_handle_sink_request(struct dp_panel *dp_panel)
3504 + panel = container_of(dp_panel, struct dp_panel_private, dp_panel);
3505 +
3506 + if (panel->link->sink_request & DP_TEST_LINK_EDID_READ) {
3507 +- u8 checksum = dp_panel_get_edid_checksum(dp_panel->edid);
3508 ++ u8 checksum;
3509 ++
3510 ++ if (dp_panel->edid)
3511 ++ checksum = dp_panel_get_edid_checksum(dp_panel->edid);
3512 ++ else
3513 ++ checksum = dp_panel->connector->real_edid_checksum;
3514 +
3515 + dp_link_send_edid_checksum(panel->link, checksum);
3516 + dp_link_send_test_response(panel->link);
3517 +diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
3518 +index b2ff68a15791a..d255bea87ca41 100644
3519 +--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
3520 ++++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
3521 +@@ -158,7 +158,6 @@ static const struct msm_dsi_config sdm660_dsi_cfg = {
3522 + .reg_cfg = {
3523 + .num = 2,
3524 + .regs = {
3525 +- {"vdd", 73400, 32 }, /* 0.9 V */
3526 + {"vdda", 12560, 4 }, /* 1.2 V */
3527 + },
3528 + },
3529 +diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c
3530 +index 519400501bcdf..1ca9e73c6e078 100644
3531 +--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c
3532 ++++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c
3533 +@@ -168,7 +168,7 @@ const struct msm_dsi_phy_cfg dsi_phy_14nm_660_cfgs = {
3534 + .reg_cfg = {
3535 + .num = 1,
3536 + .regs = {
3537 +- {"vcca", 17000, 32},
3538 ++ {"vcca", 73400, 32},
3539 + },
3540 + },
3541 + .ops = {
3542 +diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h
3543 +index 597cf1459b0a8..4c6bdea5537b9 100644
3544 +--- a/drivers/gpu/drm/panfrost/panfrost_device.h
3545 ++++ b/drivers/gpu/drm/panfrost/panfrost_device.h
3546 +@@ -120,8 +120,12 @@ struct panfrost_device {
3547 + };
3548 +
3549 + struct panfrost_mmu {
3550 ++ struct panfrost_device *pfdev;
3551 ++ struct kref refcount;
3552 + struct io_pgtable_cfg pgtbl_cfg;
3553 + struct io_pgtable_ops *pgtbl_ops;
3554 ++ struct drm_mm mm;
3555 ++ spinlock_t mm_lock;
3556 + int as;
3557 + atomic_t as_count;
3558 + struct list_head list;
3559 +@@ -132,9 +136,7 @@ struct panfrost_file_priv {
3560 +
3561 + struct drm_sched_entity sched_entity[NUM_JOB_SLOTS];
3562 +
3563 +- struct panfrost_mmu mmu;
3564 +- struct drm_mm mm;
3565 +- spinlock_t mm_lock;
3566 ++ struct panfrost_mmu *mmu;
3567 + };
3568 +
3569 + static inline struct panfrost_device *to_panfrost_device(struct drm_device *ddev)
3570 +diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
3571 +index 689be734ed200..a70261809cdd2 100644
3572 +--- a/drivers/gpu/drm/panfrost/panfrost_drv.c
3573 ++++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
3574 +@@ -417,7 +417,7 @@ static int panfrost_ioctl_madvise(struct drm_device *dev, void *data,
3575 + * anyway, so let's not bother.
3576 + */
3577 + if (!list_is_singular(&bo->mappings.list) ||
3578 +- WARN_ON_ONCE(first->mmu != &priv->mmu)) {
3579 ++ WARN_ON_ONCE(first->mmu != priv->mmu)) {
3580 + ret = -EINVAL;
3581 + goto out_unlock_mappings;
3582 + }
3583 +@@ -449,32 +449,6 @@ int panfrost_unstable_ioctl_check(void)
3584 + return 0;
3585 + }
3586 +
3587 +-#define PFN_4G (SZ_4G >> PAGE_SHIFT)
3588 +-#define PFN_4G_MASK (PFN_4G - 1)
3589 +-#define PFN_16M (SZ_16M >> PAGE_SHIFT)
3590 +-
3591 +-static void panfrost_drm_mm_color_adjust(const struct drm_mm_node *node,
3592 +- unsigned long color,
3593 +- u64 *start, u64 *end)
3594 +-{
3595 +- /* Executable buffers can't start or end on a 4GB boundary */
3596 +- if (!(color & PANFROST_BO_NOEXEC)) {
3597 +- u64 next_seg;
3598 +-
3599 +- if ((*start & PFN_4G_MASK) == 0)
3600 +- (*start)++;
3601 +-
3602 +- if ((*end & PFN_4G_MASK) == 0)
3603 +- (*end)--;
3604 +-
3605 +- next_seg = ALIGN(*start, PFN_4G);
3606 +- if (next_seg - *start <= PFN_16M)
3607 +- *start = next_seg + 1;
3608 +-
3609 +- *end = min(*end, ALIGN(*start, PFN_4G) - 1);
3610 +- }
3611 +-}
3612 +-
3613 + static int
3614 + panfrost_open(struct drm_device *dev, struct drm_file *file)
3615 + {
3616 +@@ -489,15 +463,11 @@ panfrost_open(struct drm_device *dev, struct drm_file *file)
3617 + panfrost_priv->pfdev = pfdev;
3618 + file->driver_priv = panfrost_priv;
3619 +
3620 +- spin_lock_init(&panfrost_priv->mm_lock);
3621 +-
3622 +- /* 4G enough for now. can be 48-bit */
3623 +- drm_mm_init(&panfrost_priv->mm, SZ_32M >> PAGE_SHIFT, (SZ_4G - SZ_32M) >> PAGE_SHIFT);
3624 +- panfrost_priv->mm.color_adjust = panfrost_drm_mm_color_adjust;
3625 +-
3626 +- ret = panfrost_mmu_pgtable_alloc(panfrost_priv);
3627 +- if (ret)
3628 +- goto err_pgtable;
3629 ++ panfrost_priv->mmu = panfrost_mmu_ctx_create(pfdev);
3630 ++ if (IS_ERR(panfrost_priv->mmu)) {
3631 ++ ret = PTR_ERR(panfrost_priv->mmu);
3632 ++ goto err_free;
3633 ++ }
3634 +
3635 + ret = panfrost_job_open(panfrost_priv);
3636 + if (ret)
3637 +@@ -506,9 +476,8 @@ panfrost_open(struct drm_device *dev, struct drm_file *file)
3638 + return 0;
3639 +
3640 + err_job:
3641 +- panfrost_mmu_pgtable_free(panfrost_priv);
3642 +-err_pgtable:
3643 +- drm_mm_takedown(&panfrost_priv->mm);
3644 ++ panfrost_mmu_ctx_put(panfrost_priv->mmu);
3645 ++err_free:
3646 + kfree(panfrost_priv);
3647 + return ret;
3648 + }
3649 +@@ -521,8 +490,7 @@ panfrost_postclose(struct drm_device *dev, struct drm_file *file)
3650 + panfrost_perfcnt_close(file);
3651 + panfrost_job_close(panfrost_priv);
3652 +
3653 +- panfrost_mmu_pgtable_free(panfrost_priv);
3654 +- drm_mm_takedown(&panfrost_priv->mm);
3655 ++ panfrost_mmu_ctx_put(panfrost_priv->mmu);
3656 + kfree(panfrost_priv);
3657 + }
3658 +
3659 +diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
3660 +index 57a31dd0ffed1..1d917cea5ceb4 100644
3661 +--- a/drivers/gpu/drm/panfrost/panfrost_gem.c
3662 ++++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
3663 +@@ -60,7 +60,7 @@ panfrost_gem_mapping_get(struct panfrost_gem_object *bo,
3664 +
3665 + mutex_lock(&bo->mappings.lock);
3666 + list_for_each_entry(iter, &bo->mappings.list, node) {
3667 +- if (iter->mmu == &priv->mmu) {
3668 ++ if (iter->mmu == priv->mmu) {
3669 + kref_get(&iter->refcount);
3670 + mapping = iter;
3671 + break;
3672 +@@ -74,16 +74,13 @@ panfrost_gem_mapping_get(struct panfrost_gem_object *bo,
3673 + static void
3674 + panfrost_gem_teardown_mapping(struct panfrost_gem_mapping *mapping)
3675 + {
3676 +- struct panfrost_file_priv *priv;
3677 +-
3678 + if (mapping->active)
3679 + panfrost_mmu_unmap(mapping);
3680 +
3681 +- priv = container_of(mapping->mmu, struct panfrost_file_priv, mmu);
3682 +- spin_lock(&priv->mm_lock);
3683 ++ spin_lock(&mapping->mmu->mm_lock);
3684 + if (drm_mm_node_allocated(&mapping->mmnode))
3685 + drm_mm_remove_node(&mapping->mmnode);
3686 +- spin_unlock(&priv->mm_lock);
3687 ++ spin_unlock(&mapping->mmu->mm_lock);
3688 + }
3689 +
3690 + static void panfrost_gem_mapping_release(struct kref *kref)
3691 +@@ -94,6 +91,7 @@ static void panfrost_gem_mapping_release(struct kref *kref)
3692 +
3693 + panfrost_gem_teardown_mapping(mapping);
3694 + drm_gem_object_put(&mapping->obj->base.base);
3695 ++ panfrost_mmu_ctx_put(mapping->mmu);
3696 + kfree(mapping);
3697 + }
3698 +
3699 +@@ -143,11 +141,11 @@ int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_priv)
3700 + else
3701 + align = size >= SZ_2M ? SZ_2M >> PAGE_SHIFT : 0;
3702 +
3703 +- mapping->mmu = &priv->mmu;
3704 +- spin_lock(&priv->mm_lock);
3705 +- ret = drm_mm_insert_node_generic(&priv->mm, &mapping->mmnode,
3706 ++ mapping->mmu = panfrost_mmu_ctx_get(priv->mmu);
3707 ++ spin_lock(&mapping->mmu->mm_lock);
3708 ++ ret = drm_mm_insert_node_generic(&mapping->mmu->mm, &mapping->mmnode,
3709 + size >> PAGE_SHIFT, align, color, 0);
3710 +- spin_unlock(&priv->mm_lock);
3711 ++ spin_unlock(&mapping->mmu->mm_lock);
3712 + if (ret)
3713 + goto err;
3714 +
3715 +@@ -176,7 +174,7 @@ void panfrost_gem_close(struct drm_gem_object *obj, struct drm_file *file_priv)
3716 +
3717 + mutex_lock(&bo->mappings.lock);
3718 + list_for_each_entry(iter, &bo->mappings.list, node) {
3719 +- if (iter->mmu == &priv->mmu) {
3720 ++ if (iter->mmu == priv->mmu) {
3721 + mapping = iter;
3722 + list_del(&iter->node);
3723 + break;
3724 +diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
3725 +index 04e6f6f9b742e..7e1a5664d4525 100644
3726 +--- a/drivers/gpu/drm/panfrost/panfrost_job.c
3727 ++++ b/drivers/gpu/drm/panfrost/panfrost_job.c
3728 +@@ -165,7 +165,7 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js)
3729 + return;
3730 + }
3731 +
3732 +- cfg = panfrost_mmu_as_get(pfdev, &job->file_priv->mmu);
3733 ++ cfg = panfrost_mmu_as_get(pfdev, job->file_priv->mmu);
3734 +
3735 + job_write(pfdev, JS_HEAD_NEXT_LO(js), jc_head & 0xFFFFFFFF);
3736 + job_write(pfdev, JS_HEAD_NEXT_HI(js), jc_head >> 32);
3737 +@@ -524,7 +524,7 @@ static irqreturn_t panfrost_job_irq_handler(int irq, void *data)
3738 + if (job) {
3739 + pfdev->jobs[j] = NULL;
3740 +
3741 +- panfrost_mmu_as_put(pfdev, &job->file_priv->mmu);
3742 ++ panfrost_mmu_as_put(pfdev, job->file_priv->mmu);
3743 + panfrost_devfreq_record_idle(&pfdev->pfdevfreq);
3744 +
3745 + dma_fence_signal_locked(job->done_fence);
3746 +diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c
3747 +index 1986862163178..7fc45b13a52c2 100644
3748 +--- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
3749 ++++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
3750 +@@ -1,5 +1,8 @@
3751 + // SPDX-License-Identifier: GPL-2.0
3752 + /* Copyright 2019 Linaro, Ltd, Rob Herring <robh@××××××.org> */
3753 ++
3754 ++#include <drm/panfrost_drm.h>
3755 ++
3756 + #include <linux/atomic.h>
3757 + #include <linux/bitfield.h>
3758 + #include <linux/delay.h>
3759 +@@ -52,25 +55,16 @@ static int write_cmd(struct panfrost_device *pfdev, u32 as_nr, u32 cmd)
3760 + }
3761 +
3762 + static void lock_region(struct panfrost_device *pfdev, u32 as_nr,
3763 +- u64 iova, size_t size)
3764 ++ u64 iova, u64 size)
3765 + {
3766 + u8 region_width;
3767 + u64 region = iova & PAGE_MASK;
3768 +- /*
3769 +- * fls returns:
3770 +- * 1 .. 32
3771 +- *
3772 +- * 10 + fls(num_pages)
3773 +- * results in the range (11 .. 42)
3774 +- */
3775 +-
3776 +- size = round_up(size, PAGE_SIZE);
3777 +
3778 +- region_width = 10 + fls(size >> PAGE_SHIFT);
3779 +- if ((size >> PAGE_SHIFT) != (1ul << (region_width - 11))) {
3780 +- /* not pow2, so must go up to the next pow2 */
3781 +- region_width += 1;
3782 +- }
3783 ++ /* The size is encoded as ceil(log2) minus(1), which may be calculated
3784 ++ * with fls. The size must be clamped to hardware bounds.
3785 ++ */
3786 ++ size = max_t(u64, size, AS_LOCK_REGION_MIN_SIZE);
3787 ++ region_width = fls64(size - 1) - 1;
3788 + region |= region_width;
3789 +
3790 + /* Lock the region that needs to be updated */
3791 +@@ -81,7 +75,7 @@ static void lock_region(struct panfrost_device *pfdev, u32 as_nr,
3792 +
3793 +
3794 + static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr,
3795 +- u64 iova, size_t size, u32 op)
3796 ++ u64 iova, u64 size, u32 op)
3797 + {
3798 + if (as_nr < 0)
3799 + return 0;
3800 +@@ -98,7 +92,7 @@ static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr,
3801 +
3802 + static int mmu_hw_do_operation(struct panfrost_device *pfdev,
3803 + struct panfrost_mmu *mmu,
3804 +- u64 iova, size_t size, u32 op)
3805 ++ u64 iova, u64 size, u32 op)
3806 + {
3807 + int ret;
3808 +
3809 +@@ -115,7 +109,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m
3810 + u64 transtab = cfg->arm_mali_lpae_cfg.transtab;
3811 + u64 memattr = cfg->arm_mali_lpae_cfg.memattr;
3812 +
3813 +- mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM);
3814 ++ mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM);
3815 +
3816 + mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), transtab & 0xffffffffUL);
3817 + mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), transtab >> 32);
3818 +@@ -131,7 +125,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m
3819 +
3820 + static void panfrost_mmu_disable(struct panfrost_device *pfdev, u32 as_nr)
3821 + {
3822 +- mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM);
3823 ++ mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM);
3824 +
3825 + mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), 0);
3826 + mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), 0);
3827 +@@ -231,7 +225,7 @@ static size_t get_pgsize(u64 addr, size_t size)
3828 +
3829 + static void panfrost_mmu_flush_range(struct panfrost_device *pfdev,
3830 + struct panfrost_mmu *mmu,
3831 +- u64 iova, size_t size)
3832 ++ u64 iova, u64 size)
3833 + {
3834 + if (mmu->as < 0)
3835 + return;
3836 +@@ -337,7 +331,7 @@ static void mmu_tlb_inv_context_s1(void *cookie)
3837 +
3838 + static void mmu_tlb_sync_context(void *cookie)
3839 + {
3840 +- //struct panfrost_device *pfdev = cookie;
3841 ++ //struct panfrost_mmu *mmu = cookie;
3842 + // TODO: Wait 1000 GPU cycles for HW_ISSUE_6367/T60X
3843 + }
3844 +
3845 +@@ -359,57 +353,10 @@ static const struct iommu_flush_ops mmu_tlb_ops = {
3846 + .tlb_flush_leaf = mmu_tlb_flush_leaf,
3847 + };
3848 +
3849 +-int panfrost_mmu_pgtable_alloc(struct panfrost_file_priv *priv)
3850 +-{
3851 +- struct panfrost_mmu *mmu = &priv->mmu;
3852 +- struct panfrost_device *pfdev = priv->pfdev;
3853 +-
3854 +- INIT_LIST_HEAD(&mmu->list);
3855 +- mmu->as = -1;
3856 +-
3857 +- mmu->pgtbl_cfg = (struct io_pgtable_cfg) {
3858 +- .pgsize_bitmap = SZ_4K | SZ_2M,
3859 +- .ias = FIELD_GET(0xff, pfdev->features.mmu_features),
3860 +- .oas = FIELD_GET(0xff00, pfdev->features.mmu_features),
3861 +- .coherent_walk = pfdev->coherent,
3862 +- .tlb = &mmu_tlb_ops,
3863 +- .iommu_dev = pfdev->dev,
3864 +- };
3865 +-
3866 +- mmu->pgtbl_ops = alloc_io_pgtable_ops(ARM_MALI_LPAE, &mmu->pgtbl_cfg,
3867 +- priv);
3868 +- if (!mmu->pgtbl_ops)
3869 +- return -EINVAL;
3870 +-
3871 +- return 0;
3872 +-}
3873 +-
3874 +-void panfrost_mmu_pgtable_free(struct panfrost_file_priv *priv)
3875 +-{
3876 +- struct panfrost_device *pfdev = priv->pfdev;
3877 +- struct panfrost_mmu *mmu = &priv->mmu;
3878 +-
3879 +- spin_lock(&pfdev->as_lock);
3880 +- if (mmu->as >= 0) {
3881 +- pm_runtime_get_noresume(pfdev->dev);
3882 +- if (pm_runtime_active(pfdev->dev))
3883 +- panfrost_mmu_disable(pfdev, mmu->as);
3884 +- pm_runtime_put_autosuspend(pfdev->dev);
3885 +-
3886 +- clear_bit(mmu->as, &pfdev->as_alloc_mask);
3887 +- clear_bit(mmu->as, &pfdev->as_in_use_mask);
3888 +- list_del(&mmu->list);
3889 +- }
3890 +- spin_unlock(&pfdev->as_lock);
3891 +-
3892 +- free_io_pgtable_ops(mmu->pgtbl_ops);
3893 +-}
3894 +-
3895 + static struct panfrost_gem_mapping *
3896 + addr_to_mapping(struct panfrost_device *pfdev, int as, u64 addr)
3897 + {
3898 + struct panfrost_gem_mapping *mapping = NULL;
3899 +- struct panfrost_file_priv *priv;
3900 + struct drm_mm_node *node;
3901 + u64 offset = addr >> PAGE_SHIFT;
3902 + struct panfrost_mmu *mmu;
3903 +@@ -422,11 +369,10 @@ addr_to_mapping(struct panfrost_device *pfdev, int as, u64 addr)
3904 + goto out;
3905 +
3906 + found_mmu:
3907 +- priv = container_of(mmu, struct panfrost_file_priv, mmu);
3908 +
3909 +- spin_lock(&priv->mm_lock);
3910 ++ spin_lock(&mmu->mm_lock);
3911 +
3912 +- drm_mm_for_each_node(node, &priv->mm) {
3913 ++ drm_mm_for_each_node(node, &mmu->mm) {
3914 + if (offset >= node->start &&
3915 + offset < (node->start + node->size)) {
3916 + mapping = drm_mm_node_to_panfrost_mapping(node);
3917 +@@ -436,7 +382,7 @@ found_mmu:
3918 + }
3919 + }
3920 +
3921 +- spin_unlock(&priv->mm_lock);
3922 ++ spin_unlock(&mmu->mm_lock);
3923 + out:
3924 + spin_unlock(&pfdev->as_lock);
3925 + return mapping;
3926 +@@ -549,6 +495,107 @@ err_bo:
3927 + return ret;
3928 + }
3929 +
3930 ++static void panfrost_mmu_release_ctx(struct kref *kref)
3931 ++{
3932 ++ struct panfrost_mmu *mmu = container_of(kref, struct panfrost_mmu,
3933 ++ refcount);
3934 ++ struct panfrost_device *pfdev = mmu->pfdev;
3935 ++
3936 ++ spin_lock(&pfdev->as_lock);
3937 ++ if (mmu->as >= 0) {
3938 ++ pm_runtime_get_noresume(pfdev->dev);
3939 ++ if (pm_runtime_active(pfdev->dev))
3940 ++ panfrost_mmu_disable(pfdev, mmu->as);
3941 ++ pm_runtime_put_autosuspend(pfdev->dev);
3942 ++
3943 ++ clear_bit(mmu->as, &pfdev->as_alloc_mask);
3944 ++ clear_bit(mmu->as, &pfdev->as_in_use_mask);
3945 ++ list_del(&mmu->list);
3946 ++ }
3947 ++ spin_unlock(&pfdev->as_lock);
3948 ++
3949 ++ free_io_pgtable_ops(mmu->pgtbl_ops);
3950 ++ drm_mm_takedown(&mmu->mm);
3951 ++ kfree(mmu);
3952 ++}
3953 ++
3954 ++void panfrost_mmu_ctx_put(struct panfrost_mmu *mmu)
3955 ++{
3956 ++ kref_put(&mmu->refcount, panfrost_mmu_release_ctx);
3957 ++}
3958 ++
3959 ++struct panfrost_mmu *panfrost_mmu_ctx_get(struct panfrost_mmu *mmu)
3960 ++{
3961 ++ kref_get(&mmu->refcount);
3962 ++
3963 ++ return mmu;
3964 ++}
3965 ++
3966 ++#define PFN_4G (SZ_4G >> PAGE_SHIFT)
3967 ++#define PFN_4G_MASK (PFN_4G - 1)
3968 ++#define PFN_16M (SZ_16M >> PAGE_SHIFT)
3969 ++
3970 ++static void panfrost_drm_mm_color_adjust(const struct drm_mm_node *node,
3971 ++ unsigned long color,
3972 ++ u64 *start, u64 *end)
3973 ++{
3974 ++ /* Executable buffers can't start or end on a 4GB boundary */
3975 ++ if (!(color & PANFROST_BO_NOEXEC)) {
3976 ++ u64 next_seg;
3977 ++
3978 ++ if ((*start & PFN_4G_MASK) == 0)
3979 ++ (*start)++;
3980 ++
3981 ++ if ((*end & PFN_4G_MASK) == 0)
3982 ++ (*end)--;
3983 ++
3984 ++ next_seg = ALIGN(*start, PFN_4G);
3985 ++ if (next_seg - *start <= PFN_16M)
3986 ++ *start = next_seg + 1;
3987 ++
3988 ++ *end = min(*end, ALIGN(*start, PFN_4G) - 1);
3989 ++ }
3990 ++}
3991 ++
3992 ++struct panfrost_mmu *panfrost_mmu_ctx_create(struct panfrost_device *pfdev)
3993 ++{
3994 ++ struct panfrost_mmu *mmu;
3995 ++
3996 ++ mmu = kzalloc(sizeof(*mmu), GFP_KERNEL);
3997 ++ if (!mmu)
3998 ++ return ERR_PTR(-ENOMEM);
3999 ++
4000 ++ mmu->pfdev = pfdev;
4001 ++ spin_lock_init(&mmu->mm_lock);
4002 ++
4003 ++ /* 4G enough for now. can be 48-bit */
4004 ++ drm_mm_init(&mmu->mm, SZ_32M >> PAGE_SHIFT, (SZ_4G - SZ_32M) >> PAGE_SHIFT);
4005 ++ mmu->mm.color_adjust = panfrost_drm_mm_color_adjust;
4006 ++
4007 ++ INIT_LIST_HEAD(&mmu->list);
4008 ++ mmu->as = -1;
4009 ++
4010 ++ mmu->pgtbl_cfg = (struct io_pgtable_cfg) {
4011 ++ .pgsize_bitmap = SZ_4K | SZ_2M,
4012 ++ .ias = FIELD_GET(0xff, pfdev->features.mmu_features),
4013 ++ .oas = FIELD_GET(0xff00, pfdev->features.mmu_features),
4014 ++ .coherent_walk = pfdev->coherent,
4015 ++ .tlb = &mmu_tlb_ops,
4016 ++ .iommu_dev = pfdev->dev,
4017 ++ };
4018 ++
4019 ++ mmu->pgtbl_ops = alloc_io_pgtable_ops(ARM_MALI_LPAE, &mmu->pgtbl_cfg,
4020 ++ mmu);
4021 ++ if (!mmu->pgtbl_ops) {
4022 ++ kfree(mmu);
4023 ++ return ERR_PTR(-EINVAL);
4024 ++ }
4025 ++
4026 ++ kref_init(&mmu->refcount);
4027 ++
4028 ++ return mmu;
4029 ++}
4030 ++
4031 + static const char *access_type_name(struct panfrost_device *pfdev,
4032 + u32 fault_status)
4033 + {
4034 +diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.h b/drivers/gpu/drm/panfrost/panfrost_mmu.h
4035 +index 44fc2edf63ce6..cc2a0d307febc 100644
4036 +--- a/drivers/gpu/drm/panfrost/panfrost_mmu.h
4037 ++++ b/drivers/gpu/drm/panfrost/panfrost_mmu.h
4038 +@@ -18,7 +18,8 @@ void panfrost_mmu_reset(struct panfrost_device *pfdev);
4039 + u32 panfrost_mmu_as_get(struct panfrost_device *pfdev, struct panfrost_mmu *mmu);
4040 + void panfrost_mmu_as_put(struct panfrost_device *pfdev, struct panfrost_mmu *mmu);
4041 +
4042 +-int panfrost_mmu_pgtable_alloc(struct panfrost_file_priv *priv);
4043 +-void panfrost_mmu_pgtable_free(struct panfrost_file_priv *priv);
4044 ++struct panfrost_mmu *panfrost_mmu_ctx_get(struct panfrost_mmu *mmu);
4045 ++void panfrost_mmu_ctx_put(struct panfrost_mmu *mmu);
4046 ++struct panfrost_mmu *panfrost_mmu_ctx_create(struct panfrost_device *pfdev);
4047 +
4048 + #endif
4049 +diff --git a/drivers/gpu/drm/panfrost/panfrost_regs.h b/drivers/gpu/drm/panfrost/panfrost_regs.h
4050 +index eddaa62ad8b0e..2ae3a4d301d39 100644
4051 +--- a/drivers/gpu/drm/panfrost/panfrost_regs.h
4052 ++++ b/drivers/gpu/drm/panfrost/panfrost_regs.h
4053 +@@ -318,6 +318,8 @@
4054 + #define AS_FAULTSTATUS_ACCESS_TYPE_READ (0x2 << 8)
4055 + #define AS_FAULTSTATUS_ACCESS_TYPE_WRITE (0x3 << 8)
4056 +
4057 ++#define AS_LOCK_REGION_MIN_SIZE (1ULL << 15)
4058 ++
4059 + #define gpu_write(dev, reg, data) writel(data, dev->iomem + reg)
4060 + #define gpu_read(dev, reg) readl(dev->iomem + reg)
4061 +
4062 +diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
4063 +index c58b8840090ab..ee293f061f0a8 100644
4064 +--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
4065 ++++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
4066 +@@ -1074,7 +1074,9 @@ static int vc4_hdmi_audio_trigger(struct snd_pcm_substream *substream, int cmd,
4067 + HDMI_WRITE(HDMI_MAI_CTL,
4068 + VC4_SET_FIELD(vc4_hdmi->audio.channels,
4069 + VC4_HD_MAI_CTL_CHNUM) |
4070 +- VC4_HD_MAI_CTL_ENABLE);
4071 ++ VC4_HD_MAI_CTL_WHOLSMP |
4072 ++ VC4_HD_MAI_CTL_CHALIGN |
4073 ++ VC4_HD_MAI_CTL_ENABLE);
4074 + break;
4075 + case SNDRV_PCM_TRIGGER_STOP:
4076 + HDMI_WRITE(HDMI_MAI_CTL,
4077 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
4078 +index f493b20c7a38c..f1a51371de5b1 100644
4079 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
4080 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
4081 +@@ -866,7 +866,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
4082 + user_srf->prime.base.shareable = false;
4083 + user_srf->prime.base.tfile = NULL;
4084 + if (drm_is_primary_client(file_priv))
4085 +- user_srf->master = drm_master_get(file_priv->master);
4086 ++ user_srf->master = drm_file_get_master(file_priv);
4087 +
4088 + /**
4089 + * From this point, the generic resource management functions
4090 +@@ -1537,7 +1537,7 @@ vmw_gb_surface_define_internal(struct drm_device *dev,
4091 +
4092 + user_srf = container_of(srf, struct vmw_user_surface, srf);
4093 + if (drm_is_primary_client(file_priv))
4094 +- user_srf->master = drm_master_get(file_priv->master);
4095 ++ user_srf->master = drm_file_get_master(file_priv);
4096 +
4097 + ret = ttm_read_lock(&dev_priv->reservation_sem, true);
4098 + if (unlikely(ret != 0))
4099 +diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c b/drivers/gpu/drm/xlnx/zynqmp_disp.c
4100 +index 8cd8af35cfaac..205c72a249b75 100644
4101 +--- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
4102 ++++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
4103 +@@ -1447,9 +1447,10 @@ zynqmp_disp_crtc_atomic_enable(struct drm_crtc *crtc,
4104 + struct drm_display_mode *adjusted_mode = &crtc->state->adjusted_mode;
4105 + int ret, vrefresh;
4106 +
4107 ++ pm_runtime_get_sync(disp->dev);
4108 ++
4109 + zynqmp_disp_crtc_setup_clock(crtc, adjusted_mode);
4110 +
4111 +- pm_runtime_get_sync(disp->dev);
4112 + ret = clk_prepare_enable(disp->pclk);
4113 + if (ret) {
4114 + dev_err(disp->dev, "failed to enable a pixel clock\n");
4115 +diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
4116 +index 59d1fb017da01..13811332b349f 100644
4117 +--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
4118 ++++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
4119 +@@ -402,10 +402,6 @@ static int zynqmp_dp_phy_init(struct zynqmp_dp *dp)
4120 + }
4121 + }
4122 +
4123 +- ret = zynqmp_dp_reset(dp, false);
4124 +- if (ret < 0)
4125 +- return ret;
4126 +-
4127 + zynqmp_dp_clr(dp, ZYNQMP_DP_PHY_RESET, ZYNQMP_DP_PHY_RESET_ALL_RESET);
4128 +
4129 + /*
4130 +@@ -441,8 +437,6 @@ static void zynqmp_dp_phy_exit(struct zynqmp_dp *dp)
4131 + ret);
4132 + }
4133 +
4134 +- zynqmp_dp_reset(dp, true);
4135 +-
4136 + for (i = 0; i < dp->num_lanes; i++) {
4137 + ret = phy_exit(dp->phy[i]);
4138 + if (ret)
4139 +@@ -1682,9 +1676,13 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm)
4140 + return PTR_ERR(dp->reset);
4141 + }
4142 +
4143 ++ ret = zynqmp_dp_reset(dp, false);
4144 ++ if (ret < 0)
4145 ++ return ret;
4146 ++
4147 + ret = zynqmp_dp_phy_probe(dp);
4148 + if (ret)
4149 +- return ret;
4150 ++ goto err_reset;
4151 +
4152 + /* Initialize the hardware. */
4153 + zynqmp_dp_write(dp, ZYNQMP_DP_TX_PHY_POWER_DOWN,
4154 +@@ -1696,7 +1694,7 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm)
4155 +
4156 + ret = zynqmp_dp_phy_init(dp);
4157 + if (ret)
4158 +- return ret;
4159 ++ goto err_reset;
4160 +
4161 + zynqmp_dp_write(dp, ZYNQMP_DP_TRANSMITTER_ENABLE, 1);
4162 +
4163 +@@ -1708,15 +1706,18 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm)
4164 + zynqmp_dp_irq_handler, IRQF_ONESHOT,
4165 + dev_name(dp->dev), dp);
4166 + if (ret < 0)
4167 +- goto error;
4168 ++ goto err_phy_exit;
4169 +
4170 + dev_dbg(dp->dev, "ZynqMP DisplayPort Tx probed with %u lanes\n",
4171 + dp->num_lanes);
4172 +
4173 + return 0;
4174 +
4175 +-error:
4176 ++err_phy_exit:
4177 + zynqmp_dp_phy_exit(dp);
4178 ++err_reset:
4179 ++ zynqmp_dp_reset(dp, true);
4180 ++
4181 + return ret;
4182 + }
4183 +
4184 +@@ -1734,4 +1735,5 @@ void zynqmp_dp_remove(struct zynqmp_dpsub *dpsub)
4185 + zynqmp_dp_write(dp, ZYNQMP_DP_INT_DS, 0xffffffff);
4186 +
4187 + zynqmp_dp_phy_exit(dp);
4188 ++ zynqmp_dp_reset(dp, true);
4189 + }
4190 +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
4191 +index d1ab2dccf6fd7..580d378342c41 100644
4192 +--- a/drivers/hid/hid-input.c
4193 ++++ b/drivers/hid/hid-input.c
4194 +@@ -415,8 +415,6 @@ static int hidinput_get_battery_property(struct power_supply *psy,
4195 +
4196 + if (dev->battery_status == HID_BATTERY_UNKNOWN)
4197 + val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
4198 +- else if (dev->battery_capacity == 100)
4199 +- val->intval = POWER_SUPPLY_STATUS_FULL;
4200 + else
4201 + val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
4202 + break;
4203 +diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
4204 +index 1f08c848c33de..998aad8a9e608 100644
4205 +--- a/drivers/hid/i2c-hid/i2c-hid-core.c
4206 ++++ b/drivers/hid/i2c-hid/i2c-hid-core.c
4207 +@@ -176,8 +176,6 @@ static const struct i2c_hid_quirks {
4208 + I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
4209 + { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_3118,
4210 + I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
4211 +- { USB_VENDOR_ID_ELAN, HID_ANY_ID,
4212 +- I2C_HID_QUIRK_BOGUS_IRQ },
4213 + { USB_VENDOR_ID_ALPS_JP, HID_ANY_ID,
4214 + I2C_HID_QUIRK_RESET_ON_RESUME },
4215 + { I2C_VENDOR_ID_SYNAPTICS, I2C_PRODUCT_ID_SYNAPTICS_SYNA2393,
4216 +@@ -188,7 +186,8 @@ static const struct i2c_hid_quirks {
4217 + * Sending the wakeup after reset actually break ELAN touchscreen controller
4218 + */
4219 + { USB_VENDOR_ID_ELAN, HID_ANY_ID,
4220 +- I2C_HID_QUIRK_NO_WAKEUP_AFTER_RESET },
4221 ++ I2C_HID_QUIRK_NO_WAKEUP_AFTER_RESET |
4222 ++ I2C_HID_QUIRK_BOGUS_IRQ },
4223 + { 0, 0 }
4224 + };
4225 +
4226 +diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
4227 +index 2fb7540ee952b..79bc2032dcb2a 100644
4228 +--- a/drivers/hwmon/pmbus/ibm-cffps.c
4229 ++++ b/drivers/hwmon/pmbus/ibm-cffps.c
4230 +@@ -50,9 +50,9 @@
4231 + #define CFFPS_MFR_VAUX_FAULT BIT(6)
4232 + #define CFFPS_MFR_CURRENT_SHARE_WARNING BIT(7)
4233 +
4234 +-#define CFFPS_LED_BLINK BIT(0)
4235 +-#define CFFPS_LED_ON BIT(1)
4236 +-#define CFFPS_LED_OFF BIT(2)
4237 ++#define CFFPS_LED_BLINK (BIT(0) | BIT(6))
4238 ++#define CFFPS_LED_ON (BIT(1) | BIT(6))
4239 ++#define CFFPS_LED_OFF (BIT(2) | BIT(6))
4240 + #define CFFPS_BLINK_RATE_MS 250
4241 +
4242 + enum {
4243 +diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c
4244 +index 2b2b8edfd258c..ab4997bfd6d45 100644
4245 +--- a/drivers/iio/dac/ad5624r_spi.c
4246 ++++ b/drivers/iio/dac/ad5624r_spi.c
4247 +@@ -229,7 +229,7 @@ static int ad5624r_probe(struct spi_device *spi)
4248 + if (!indio_dev)
4249 + return -ENOMEM;
4250 + st = iio_priv(indio_dev);
4251 +- st->reg = devm_regulator_get(&spi->dev, "vcc");
4252 ++ st->reg = devm_regulator_get_optional(&spi->dev, "vref");
4253 + if (!IS_ERR(st->reg)) {
4254 + ret = regulator_enable(st->reg);
4255 + if (ret)
4256 +@@ -240,6 +240,22 @@ static int ad5624r_probe(struct spi_device *spi)
4257 + goto error_disable_reg;
4258 +
4259 + voltage_uv = ret;
4260 ++ } else {
4261 ++ if (PTR_ERR(st->reg) != -ENODEV)
4262 ++ return PTR_ERR(st->reg);
4263 ++ /* Backwards compatibility. This naming is not correct */
4264 ++ st->reg = devm_regulator_get_optional(&spi->dev, "vcc");
4265 ++ if (!IS_ERR(st->reg)) {
4266 ++ ret = regulator_enable(st->reg);
4267 ++ if (ret)
4268 ++ return ret;
4269 ++
4270 ++ ret = regulator_get_voltage(st->reg);
4271 ++ if (ret < 0)
4272 ++ goto error_disable_reg;
4273 ++
4274 ++ voltage_uv = ret;
4275 ++ }
4276 + }
4277 +
4278 + spi_set_drvdata(spi, indio_dev);
4279 +diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
4280 +index 3b5ba26d7d867..3b4a0e60e6059 100644
4281 +--- a/drivers/iio/temperature/ltc2983.c
4282 ++++ b/drivers/iio/temperature/ltc2983.c
4283 +@@ -89,6 +89,8 @@
4284 +
4285 + #define LTC2983_STATUS_START_MASK BIT(7)
4286 + #define LTC2983_STATUS_START(x) FIELD_PREP(LTC2983_STATUS_START_MASK, x)
4287 ++#define LTC2983_STATUS_UP_MASK GENMASK(7, 6)
4288 ++#define LTC2983_STATUS_UP(reg) FIELD_GET(LTC2983_STATUS_UP_MASK, reg)
4289 +
4290 + #define LTC2983_STATUS_CHAN_SEL_MASK GENMASK(4, 0)
4291 + #define LTC2983_STATUS_CHAN_SEL(x) \
4292 +@@ -1362,17 +1364,16 @@ put_child:
4293 +
4294 + static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio)
4295 + {
4296 +- u32 iio_chan_t = 0, iio_chan_v = 0, chan, iio_idx = 0;
4297 ++ u32 iio_chan_t = 0, iio_chan_v = 0, chan, iio_idx = 0, status;
4298 + int ret;
4299 +- unsigned long time;
4300 +-
4301 +- /* make sure the device is up */
4302 +- time = wait_for_completion_timeout(&st->completion,
4303 +- msecs_to_jiffies(250));
4304 +
4305 +- if (!time) {
4306 ++ /* make sure the device is up: start bit (7) is 0 and done bit (6) is 1 */
4307 ++ ret = regmap_read_poll_timeout(st->regmap, LTC2983_STATUS_REG, status,
4308 ++ LTC2983_STATUS_UP(status) == 1, 25000,
4309 ++ 25000 * 10);
4310 ++ if (ret) {
4311 + dev_err(&st->spi->dev, "Device startup timed out\n");
4312 +- return -ETIMEDOUT;
4313 ++ return ret;
4314 + }
4315 +
4316 + st->iio_chan = devm_kzalloc(&st->spi->dev,
4317 +@@ -1492,10 +1493,11 @@ static int ltc2983_probe(struct spi_device *spi)
4318 + ret = ltc2983_parse_dt(st);
4319 + if (ret)
4320 + return ret;
4321 +- /*
4322 +- * let's request the irq now so it is used to sync the device
4323 +- * startup in ltc2983_setup()
4324 +- */
4325 ++
4326 ++ ret = ltc2983_setup(st, true);
4327 ++ if (ret)
4328 ++ return ret;
4329 ++
4330 + ret = devm_request_irq(&spi->dev, spi->irq, ltc2983_irq_handler,
4331 + IRQF_TRIGGER_RISING, name, st);
4332 + if (ret) {
4333 +@@ -1503,10 +1505,6 @@ static int ltc2983_probe(struct spi_device *spi)
4334 + return ret;
4335 + }
4336 +
4337 +- ret = ltc2983_setup(st, true);
4338 +- if (ret)
4339 +- return ret;
4340 +-
4341 + indio_dev->name = name;
4342 + indio_dev->num_channels = st->iio_channels;
4343 + indio_dev->channels = st->iio_chan;
4344 +diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
4345 +index da8adadf47559..75b6da00065a3 100644
4346 +--- a/drivers/infiniband/core/iwcm.c
4347 ++++ b/drivers/infiniband/core/iwcm.c
4348 +@@ -1187,29 +1187,34 @@ static int __init iw_cm_init(void)
4349 +
4350 + ret = iwpm_init(RDMA_NL_IWCM);
4351 + if (ret)
4352 +- pr_err("iw_cm: couldn't init iwpm\n");
4353 +- else
4354 +- rdma_nl_register(RDMA_NL_IWCM, iwcm_nl_cb_table);
4355 ++ return ret;
4356 ++
4357 + iwcm_wq = alloc_ordered_workqueue("iw_cm_wq", 0);
4358 + if (!iwcm_wq)
4359 +- return -ENOMEM;
4360 ++ goto err_alloc;
4361 +
4362 + iwcm_ctl_table_hdr = register_net_sysctl(&init_net, "net/iw_cm",
4363 + iwcm_ctl_table);
4364 + if (!iwcm_ctl_table_hdr) {
4365 + pr_err("iw_cm: couldn't register sysctl paths\n");
4366 +- destroy_workqueue(iwcm_wq);
4367 +- return -ENOMEM;
4368 ++ goto err_sysctl;
4369 + }
4370 +
4371 ++ rdma_nl_register(RDMA_NL_IWCM, iwcm_nl_cb_table);
4372 + return 0;
4373 ++
4374 ++err_sysctl:
4375 ++ destroy_workqueue(iwcm_wq);
4376 ++err_alloc:
4377 ++ iwpm_exit(RDMA_NL_IWCM);
4378 ++ return -ENOMEM;
4379 + }
4380 +
4381 + static void __exit iw_cm_cleanup(void)
4382 + {
4383 ++ rdma_nl_unregister(RDMA_NL_IWCM);
4384 + unregister_net_sysctl_table(iwcm_ctl_table_hdr);
4385 + destroy_workqueue(iwcm_wq);
4386 +- rdma_nl_unregister(RDMA_NL_IWCM);
4387 + iwpm_exit(RDMA_NL_IWCM);
4388 + }
4389 +
4390 +diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
4391 +index 4e940fc50bba6..2ece682c7835b 100644
4392 +--- a/drivers/infiniband/hw/efa/efa_verbs.c
4393 ++++ b/drivers/infiniband/hw/efa/efa_verbs.c
4394 +@@ -717,7 +717,6 @@ struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
4395 +
4396 + qp->qp_handle = create_qp_resp.qp_handle;
4397 + qp->ibqp.qp_num = create_qp_resp.qp_num;
4398 +- qp->ibqp.qp_type = init_attr->qp_type;
4399 + qp->max_send_wr = init_attr->cap.max_send_wr;
4400 + qp->max_recv_wr = init_attr->cap.max_recv_wr;
4401 + qp->max_send_sge = init_attr->cap.max_send_sge;
4402 +diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
4403 +index 786c6316273f7..b6e453e9ba236 100644
4404 +--- a/drivers/infiniband/hw/hfi1/init.c
4405 ++++ b/drivers/infiniband/hw/hfi1/init.c
4406 +@@ -650,12 +650,7 @@ void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd,
4407 +
4408 + ppd->pkeys[default_pkey_idx] = DEFAULT_P_KEY;
4409 + ppd->part_enforce |= HFI1_PART_ENFORCE_IN;
4410 +-
4411 +- if (loopback) {
4412 +- dd_dev_err(dd, "Faking data partition 0x8001 in idx %u\n",
4413 +- !default_pkey_idx);
4414 +- ppd->pkeys[!default_pkey_idx] = 0x8001;
4415 +- }
4416 ++ ppd->pkeys[0] = 0x8001;
4417 +
4418 + INIT_WORK(&ppd->link_vc_work, handle_verify_cap);
4419 + INIT_WORK(&ppd->link_up_work, handle_link_up);
4420 +diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
4421 +index ef1452215b17d..7ce9ad8aee1ec 100644
4422 +--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
4423 ++++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
4424 +@@ -740,7 +740,6 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
4425 + goto err_out;
4426 + }
4427 + hr_qp->en_flags |= HNS_ROCE_QP_CAP_SQ_RECORD_DB;
4428 +- resp->cap_flags |= HNS_ROCE_QP_CAP_SQ_RECORD_DB;
4429 + }
4430 +
4431 + if (user_qp_has_rdb(hr_dev, init_attr, udata, resp)) {
4432 +@@ -752,7 +751,6 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
4433 + goto err_sdb;
4434 + }
4435 + hr_qp->en_flags |= HNS_ROCE_QP_CAP_RQ_RECORD_DB;
4436 +- resp->cap_flags |= HNS_ROCE_QP_CAP_RQ_RECORD_DB;
4437 + }
4438 + } else {
4439 + /* QP doorbell register address */
4440 +@@ -959,6 +957,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
4441 + }
4442 +
4443 + if (udata) {
4444 ++ resp.cap_flags = hr_qp->en_flags;
4445 + ret = ib_copy_to_udata(udata, &resp,
4446 + min(udata->outlen, sizeof(resp)));
4447 + if (ret) {
4448 +diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
4449 +index 8beba002e5dd7..011477356a1de 100644
4450 +--- a/drivers/infiniband/hw/mlx5/qp.c
4451 ++++ b/drivers/infiniband/hw/mlx5/qp.c
4452 +@@ -1842,7 +1842,6 @@ static int get_atomic_mode(struct mlx5_ib_dev *dev,
4453 + static int create_xrc_tgt_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
4454 + struct mlx5_create_qp_params *params)
4455 + {
4456 +- struct mlx5_ib_create_qp *ucmd = params->ucmd;
4457 + struct ib_qp_init_attr *attr = params->attr;
4458 + u32 uidx = params->uidx;
4459 + struct mlx5_ib_resources *devr = &dev->devr;
4460 +@@ -1862,8 +1861,6 @@ static int create_xrc_tgt_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
4461 + if (!in)
4462 + return -ENOMEM;
4463 +
4464 +- if (MLX5_CAP_GEN(mdev, ece_support) && ucmd)
4465 +- MLX5_SET(create_qp_in, in, ece, ucmd->ece_options);
4466 + qpc = MLX5_ADDR_OF(create_qp_in, in, qpc);
4467 +
4468 + MLX5_SET(qpc, qpc, st, MLX5_QP_ST_XRC);
4469 +diff --git a/drivers/iommu/intel/pasid.h b/drivers/iommu/intel/pasid.h
4470 +index 30cb30046b15e..35963e6bf9fab 100644
4471 +--- a/drivers/iommu/intel/pasid.h
4472 ++++ b/drivers/iommu/intel/pasid.h
4473 +@@ -28,12 +28,12 @@
4474 + #define VCMD_CMD_ALLOC 0x1
4475 + #define VCMD_CMD_FREE 0x2
4476 + #define VCMD_VRSP_IP 0x1
4477 +-#define VCMD_VRSP_SC(e) (((e) >> 1) & 0x3)
4478 ++#define VCMD_VRSP_SC(e) (((e) & 0xff) >> 1)
4479 + #define VCMD_VRSP_SC_SUCCESS 0
4480 +-#define VCMD_VRSP_SC_NO_PASID_AVAIL 2
4481 +-#define VCMD_VRSP_SC_INVALID_PASID 2
4482 +-#define VCMD_VRSP_RESULT_PASID(e) (((e) >> 8) & 0xfffff)
4483 +-#define VCMD_CMD_OPERAND(e) ((e) << 8)
4484 ++#define VCMD_VRSP_SC_NO_PASID_AVAIL 16
4485 ++#define VCMD_VRSP_SC_INVALID_PASID 16
4486 ++#define VCMD_VRSP_RESULT_PASID(e) (((e) >> 16) & 0xfffff)
4487 ++#define VCMD_CMD_OPERAND(e) ((e) << 16)
4488 + /*
4489 + * Domain ID reserved for pasid entries programmed for first-level
4490 + * only and pass-through transfer modes.
4491 +diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
4492 +index 5665b6ea8119f..75378e35c3d66 100644
4493 +--- a/drivers/mailbox/mtk-cmdq-mailbox.c
4494 ++++ b/drivers/mailbox/mtk-cmdq-mailbox.c
4495 +@@ -168,7 +168,8 @@ static void cmdq_task_insert_into_thread(struct cmdq_task *task)
4496 + dma_sync_single_for_cpu(dev, prev_task->pa_base,
4497 + prev_task->pkt->cmd_buf_size, DMA_TO_DEVICE);
4498 + prev_task_base[CMDQ_NUM_CMD(prev_task->pkt) - 1] =
4499 +- (u64)CMDQ_JUMP_BY_PA << 32 | task->pa_base;
4500 ++ (u64)CMDQ_JUMP_BY_PA << 32 |
4501 ++ (task->pa_base >> task->cmdq->shift_pa);
4502 + dma_sync_single_for_device(dev, prev_task->pa_base,
4503 + prev_task->pkt->cmd_buf_size, DMA_TO_DEVICE);
4504 +
4505 +diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
4506 +index 70ae6f3aede94..2aa4acd33af39 100644
4507 +--- a/drivers/md/dm-crypt.c
4508 ++++ b/drivers/md/dm-crypt.c
4509 +@@ -2643,7 +2643,12 @@ static void *crypt_page_alloc(gfp_t gfp_mask, void *pool_data)
4510 + struct crypt_config *cc = pool_data;
4511 + struct page *page;
4512 +
4513 +- if (unlikely(percpu_counter_compare(&cc->n_allocated_pages, dm_crypt_pages_per_client) >= 0) &&
4514 ++ /*
4515 ++ * Note, percpu_counter_read_positive() may over (and under) estimate
4516 ++ * the current usage by at most (batch - 1) * num_online_cpus() pages,
4517 ++ * but avoids potential spinlock contention of an exact result.
4518 ++ */
4519 ++ if (unlikely(percpu_counter_read_positive(&cc->n_allocated_pages) >= dm_crypt_pages_per_client) &&
4520 + likely(gfp_mask & __GFP_NORETRY))
4521 + return NULL;
4522 +
4523 +diff --git a/drivers/media/cec/platform/stm32/stm32-cec.c b/drivers/media/cec/platform/stm32/stm32-cec.c
4524 +index ea4b1ebfca991..0ffd89712536b 100644
4525 +--- a/drivers/media/cec/platform/stm32/stm32-cec.c
4526 ++++ b/drivers/media/cec/platform/stm32/stm32-cec.c
4527 +@@ -305,14 +305,16 @@ static int stm32_cec_probe(struct platform_device *pdev)
4528 +
4529 + cec->clk_hdmi_cec = devm_clk_get(&pdev->dev, "hdmi-cec");
4530 + if (IS_ERR(cec->clk_hdmi_cec) &&
4531 +- PTR_ERR(cec->clk_hdmi_cec) == -EPROBE_DEFER)
4532 +- return -EPROBE_DEFER;
4533 ++ PTR_ERR(cec->clk_hdmi_cec) == -EPROBE_DEFER) {
4534 ++ ret = -EPROBE_DEFER;
4535 ++ goto err_unprepare_cec_clk;
4536 ++ }
4537 +
4538 + if (!IS_ERR(cec->clk_hdmi_cec)) {
4539 + ret = clk_prepare(cec->clk_hdmi_cec);
4540 + if (ret) {
4541 + dev_err(&pdev->dev, "Can't prepare hdmi-cec clock\n");
4542 +- return ret;
4543 ++ goto err_unprepare_cec_clk;
4544 + }
4545 + }
4546 +
4547 +@@ -324,19 +326,27 @@ static int stm32_cec_probe(struct platform_device *pdev)
4548 + CEC_NAME, caps, CEC_MAX_LOG_ADDRS);
4549 + ret = PTR_ERR_OR_ZERO(cec->adap);
4550 + if (ret)
4551 +- return ret;
4552 ++ goto err_unprepare_hdmi_cec_clk;
4553 +
4554 + ret = cec_register_adapter(cec->adap, &pdev->dev);
4555 +- if (ret) {
4556 +- cec_delete_adapter(cec->adap);
4557 +- return ret;
4558 +- }
4559 ++ if (ret)
4560 ++ goto err_delete_adapter;
4561 +
4562 + cec_hw_init(cec);
4563 +
4564 + platform_set_drvdata(pdev, cec);
4565 +
4566 + return 0;
4567 ++
4568 ++err_delete_adapter:
4569 ++ cec_delete_adapter(cec->adap);
4570 ++
4571 ++err_unprepare_hdmi_cec_clk:
4572 ++ clk_unprepare(cec->clk_hdmi_cec);
4573 ++
4574 ++err_unprepare_cec_clk:
4575 ++ clk_unprepare(cec->clk_cec);
4576 ++ return ret;
4577 + }
4578 +
4579 + static int stm32_cec_remove(struct platform_device *pdev)
4580 +diff --git a/drivers/media/cec/platform/tegra/tegra_cec.c b/drivers/media/cec/platform/tegra/tegra_cec.c
4581 +index 1ac0c70a59818..5e907395ca2e5 100644
4582 +--- a/drivers/media/cec/platform/tegra/tegra_cec.c
4583 ++++ b/drivers/media/cec/platform/tegra/tegra_cec.c
4584 +@@ -366,7 +366,11 @@ static int tegra_cec_probe(struct platform_device *pdev)
4585 + return -ENOENT;
4586 + }
4587 +
4588 +- clk_prepare_enable(cec->clk);
4589 ++ ret = clk_prepare_enable(cec->clk);
4590 ++ if (ret) {
4591 ++ dev_err(&pdev->dev, "Unable to prepare clock for CEC\n");
4592 ++ return ret;
4593 ++ }
4594 +
4595 + /* set context info. */
4596 + cec->dev = &pdev->dev;
4597 +@@ -446,9 +450,7 @@ static int tegra_cec_resume(struct platform_device *pdev)
4598 +
4599 + dev_notice(&pdev->dev, "Resuming\n");
4600 +
4601 +- clk_prepare_enable(cec->clk);
4602 +-
4603 +- return 0;
4604 ++ return clk_prepare_enable(cec->clk);
4605 + }
4606 + #endif
4607 +
4608 +diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c
4609 +index 082796534b0ae..bb02354a48b81 100644
4610 +--- a/drivers/media/dvb-frontends/dib8000.c
4611 ++++ b/drivers/media/dvb-frontends/dib8000.c
4612 +@@ -2107,32 +2107,55 @@ static void dib8000_load_ana_fe_coefs(struct dib8000_state *state, const s16 *an
4613 + dib8000_write_word(state, 117 + mode, ana_fe[mode]);
4614 + }
4615 +
4616 +-static const u16 lut_prbs_2k[14] = {
4617 +- 0, 0x423, 0x009, 0x5C7, 0x7A6, 0x3D8, 0x527, 0x7FF, 0x79B, 0x3D6, 0x3A2, 0x53B, 0x2F4, 0x213
4618 ++static const u16 lut_prbs_2k[13] = {
4619 ++ 0x423, 0x009, 0x5C7,
4620 ++ 0x7A6, 0x3D8, 0x527,
4621 ++ 0x7FF, 0x79B, 0x3D6,
4622 ++ 0x3A2, 0x53B, 0x2F4,
4623 ++ 0x213
4624 + };
4625 +-static const u16 lut_prbs_4k[14] = {
4626 +- 0, 0x208, 0x0C3, 0x7B9, 0x423, 0x5C7, 0x3D8, 0x7FF, 0x3D6, 0x53B, 0x213, 0x029, 0x0D0, 0x48E
4627 ++
4628 ++static const u16 lut_prbs_4k[13] = {
4629 ++ 0x208, 0x0C3, 0x7B9,
4630 ++ 0x423, 0x5C7, 0x3D8,
4631 ++ 0x7FF, 0x3D6, 0x53B,
4632 ++ 0x213, 0x029, 0x0D0,
4633 ++ 0x48E
4634 + };
4635 +-static const u16 lut_prbs_8k[14] = {
4636 +- 0, 0x740, 0x069, 0x7DD, 0x208, 0x7B9, 0x5C7, 0x7FF, 0x53B, 0x029, 0x48E, 0x4C4, 0x367, 0x684
4637 ++
4638 ++static const u16 lut_prbs_8k[13] = {
4639 ++ 0x740, 0x069, 0x7DD,
4640 ++ 0x208, 0x7B9, 0x5C7,
4641 ++ 0x7FF, 0x53B, 0x029,
4642 ++ 0x48E, 0x4C4, 0x367,
4643 ++ 0x684
4644 + };
4645 +
4646 + static u16 dib8000_get_init_prbs(struct dib8000_state *state, u16 subchannel)
4647 + {
4648 + int sub_channel_prbs_group = 0;
4649 ++ int prbs_group;
4650 +
4651 +- sub_channel_prbs_group = (subchannel / 3) + 1;
4652 +- dprintk("sub_channel_prbs_group = %d , subchannel =%d prbs = 0x%04x\n", sub_channel_prbs_group, subchannel, lut_prbs_8k[sub_channel_prbs_group]);
4653 ++ sub_channel_prbs_group = subchannel / 3;
4654 ++ if (sub_channel_prbs_group >= ARRAY_SIZE(lut_prbs_2k))
4655 ++ return 0;
4656 +
4657 + switch (state->fe[0]->dtv_property_cache.transmission_mode) {
4658 + case TRANSMISSION_MODE_2K:
4659 +- return lut_prbs_2k[sub_channel_prbs_group];
4660 ++ prbs_group = lut_prbs_2k[sub_channel_prbs_group];
4661 ++ break;
4662 + case TRANSMISSION_MODE_4K:
4663 +- return lut_prbs_4k[sub_channel_prbs_group];
4664 ++ prbs_group = lut_prbs_4k[sub_channel_prbs_group];
4665 ++ break;
4666 + default:
4667 + case TRANSMISSION_MODE_8K:
4668 +- return lut_prbs_8k[sub_channel_prbs_group];
4669 ++ prbs_group = lut_prbs_8k[sub_channel_prbs_group];
4670 + }
4671 ++
4672 ++ dprintk("sub_channel_prbs_group = %d , subchannel =%d prbs = 0x%04x\n",
4673 ++ sub_channel_prbs_group, subchannel, prbs_group);
4674 ++
4675 ++ return prbs_group;
4676 + }
4677 +
4678 + static void dib8000_set_13seg_channel(struct dib8000_state *state)
4679 +@@ -2409,10 +2432,8 @@ static void dib8000_set_isdbt_common_channel(struct dib8000_state *state, u8 seq
4680 + /* TSB or ISDBT ? apply it now */
4681 + if (c->isdbt_sb_mode) {
4682 + dib8000_set_sb_channel(state);
4683 +- if (c->isdbt_sb_subchannel < 14)
4684 +- init_prbs = dib8000_get_init_prbs(state, c->isdbt_sb_subchannel);
4685 +- else
4686 +- init_prbs = 0;
4687 ++ init_prbs = dib8000_get_init_prbs(state,
4688 ++ c->isdbt_sb_subchannel);
4689 + } else {
4690 + dib8000_set_13seg_channel(state);
4691 + init_prbs = 0xfff;
4692 +@@ -3004,6 +3025,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
4693 +
4694 + unsigned long *timeout = &state->timeout;
4695 + unsigned long now = jiffies;
4696 ++ u16 init_prbs;
4697 + #ifdef DIB8000_AGC_FREEZE
4698 + u16 agc1, agc2;
4699 + #endif
4700 +@@ -3302,8 +3324,10 @@ static int dib8000_tune(struct dvb_frontend *fe)
4701 + break;
4702 +
4703 + case CT_DEMOD_STEP_11: /* 41 : init prbs autosearch */
4704 +- if (state->subchannel <= 41) {
4705 +- dib8000_set_subchannel_prbs(state, dib8000_get_init_prbs(state, state->subchannel));
4706 ++ init_prbs = dib8000_get_init_prbs(state, state->subchannel);
4707 ++
4708 ++ if (init_prbs) {
4709 ++ dib8000_set_subchannel_prbs(state, init_prbs);
4710 + *tune_state = CT_DEMOD_STEP_9;
4711 + } else {
4712 + *tune_state = CT_DEMOD_STOP;
4713 +diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
4714 +index ccb55fd1d506f..e6104ee97ed29 100644
4715 +--- a/drivers/media/i2c/imx258.c
4716 ++++ b/drivers/media/i2c/imx258.c
4717 +@@ -22,7 +22,7 @@
4718 + #define IMX258_CHIP_ID 0x0258
4719 +
4720 + /* V_TIMING internal */
4721 +-#define IMX258_VTS_30FPS 0x0c98
4722 ++#define IMX258_VTS_30FPS 0x0c50
4723 + #define IMX258_VTS_30FPS_2K 0x0638
4724 + #define IMX258_VTS_30FPS_VGA 0x034c
4725 + #define IMX258_VTS_MAX 0xffff
4726 +@@ -46,7 +46,7 @@
4727 + /* Analog gain control */
4728 + #define IMX258_REG_ANALOG_GAIN 0x0204
4729 + #define IMX258_ANA_GAIN_MIN 0
4730 +-#define IMX258_ANA_GAIN_MAX 0x1fff
4731 ++#define IMX258_ANA_GAIN_MAX 480
4732 + #define IMX258_ANA_GAIN_STEP 1
4733 + #define IMX258_ANA_GAIN_DEFAULT 0x0
4734 +
4735 +diff --git a/drivers/media/i2c/tda1997x.c b/drivers/media/i2c/tda1997x.c
4736 +index 9554c8348c020..17cc69c3227f8 100644
4737 +--- a/drivers/media/i2c/tda1997x.c
4738 ++++ b/drivers/media/i2c/tda1997x.c
4739 +@@ -1695,14 +1695,15 @@ static int tda1997x_query_dv_timings(struct v4l2_subdev *sd,
4740 + struct v4l2_dv_timings *timings)
4741 + {
4742 + struct tda1997x_state *state = to_state(sd);
4743 ++ int ret;
4744 +
4745 + v4l_dbg(1, debug, state->client, "%s\n", __func__);
4746 + memset(timings, 0, sizeof(struct v4l2_dv_timings));
4747 + mutex_lock(&state->lock);
4748 +- tda1997x_detect_std(state, timings);
4749 ++ ret = tda1997x_detect_std(state, timings);
4750 + mutex_unlock(&state->lock);
4751 +
4752 +- return 0;
4753 ++ return ret;
4754 + }
4755 +
4756 + static const struct v4l2_subdev_video_ops tda1997x_video_ops = {
4757 +diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
4758 +index 1ba3f96ffa7dc..40ab66c850f23 100644
4759 +--- a/drivers/media/rc/rc-loopback.c
4760 ++++ b/drivers/media/rc/rc-loopback.c
4761 +@@ -42,7 +42,7 @@ static int loop_set_tx_mask(struct rc_dev *dev, u32 mask)
4762 +
4763 + if ((mask & (RXMASK_REGULAR | RXMASK_LEARNING)) != mask) {
4764 + dprintk("invalid tx mask: %u\n", mask);
4765 +- return -EINVAL;
4766 ++ return 2;
4767 + }
4768 +
4769 + dprintk("setting tx mask: %u\n", mask);
4770 +diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
4771 +index c7172b8952a96..5f0e2fa69da5c 100644
4772 +--- a/drivers/media/usb/uvc/uvc_v4l2.c
4773 ++++ b/drivers/media/usb/uvc/uvc_v4l2.c
4774 +@@ -898,8 +898,8 @@ static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input)
4775 + {
4776 + struct uvc_fh *handle = fh;
4777 + struct uvc_video_chain *chain = handle->chain;
4778 ++ u8 *buf;
4779 + int ret;
4780 +- u8 i;
4781 +
4782 + if (chain->selector == NULL ||
4783 + (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
4784 +@@ -907,22 +907,27 @@ static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input)
4785 + return 0;
4786 + }
4787 +
4788 ++ buf = kmalloc(1, GFP_KERNEL);
4789 ++ if (!buf)
4790 ++ return -ENOMEM;
4791 ++
4792 + ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, chain->selector->id,
4793 + chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL,
4794 +- &i, 1);
4795 +- if (ret < 0)
4796 +- return ret;
4797 ++ buf, 1);
4798 ++ if (!ret)
4799 ++ *input = *buf - 1;
4800 +
4801 +- *input = i - 1;
4802 +- return 0;
4803 ++ kfree(buf);
4804 ++
4805 ++ return ret;
4806 + }
4807 +
4808 + static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
4809 + {
4810 + struct uvc_fh *handle = fh;
4811 + struct uvc_video_chain *chain = handle->chain;
4812 ++ u8 *buf;
4813 + int ret;
4814 +- u32 i;
4815 +
4816 + ret = uvc_acquire_privileges(handle);
4817 + if (ret < 0)
4818 +@@ -938,10 +943,17 @@ static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
4819 + if (input >= chain->selector->bNrInPins)
4820 + return -EINVAL;
4821 +
4822 +- i = input + 1;
4823 +- return uvc_query_ctrl(chain->dev, UVC_SET_CUR, chain->selector->id,
4824 +- chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL,
4825 +- &i, 1);
4826 ++ buf = kmalloc(1, GFP_KERNEL);
4827 ++ if (!buf)
4828 ++ return -ENOMEM;
4829 ++
4830 ++ *buf = input + 1;
4831 ++ ret = uvc_query_ctrl(chain->dev, UVC_SET_CUR, chain->selector->id,
4832 ++ chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL,
4833 ++ buf, 1);
4834 ++ kfree(buf);
4835 ++
4836 ++ return ret;
4837 + }
4838 +
4839 + static int uvc_ioctl_queryctrl(struct file *file, void *fh,
4840 +diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
4841 +index 230d65a642178..af48705c704f8 100644
4842 +--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
4843 ++++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
4844 +@@ -196,7 +196,7 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
4845 + if (!v4l2_valid_dv_timings(t, cap, fnc, fnc_handle))
4846 + return false;
4847 +
4848 +- for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) {
4849 ++ for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
4850 + if (v4l2_valid_dv_timings(v4l2_dv_timings_presets + i, cap,
4851 + fnc, fnc_handle) &&
4852 + v4l2_match_dv_timings(t, v4l2_dv_timings_presets + i,
4853 +@@ -218,7 +218,7 @@ bool v4l2_find_dv_timings_cea861_vic(struct v4l2_dv_timings *t, u8 vic)
4854 + {
4855 + unsigned int i;
4856 +
4857 +- for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) {
4858 ++ for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
4859 + const struct v4l2_bt_timings *bt =
4860 + &v4l2_dv_timings_presets[i].bt;
4861 +
4862 +diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
4863 +index c2338750313c4..a49782dd903cd 100644
4864 +--- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
4865 ++++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
4866 +@@ -2238,7 +2238,8 @@ int vmci_qp_broker_map(struct vmci_handle handle,
4867 +
4868 + result = VMCI_SUCCESS;
4869 +
4870 +- if (context_id != VMCI_HOST_CONTEXT_ID) {
4871 ++ if (context_id != VMCI_HOST_CONTEXT_ID &&
4872 ++ !QPBROKERSTATE_HAS_MEM(entry)) {
4873 + struct vmci_qp_page_store page_store;
4874 +
4875 + page_store.pages = guest_mem;
4876 +@@ -2345,7 +2346,8 @@ int vmci_qp_broker_unmap(struct vmci_handle handle,
4877 + goto out;
4878 + }
4879 +
4880 +- if (context_id != VMCI_HOST_CONTEXT_ID) {
4881 ++ if (context_id != VMCI_HOST_CONTEXT_ID &&
4882 ++ QPBROKERSTATE_HAS_MEM(entry)) {
4883 + qp_acquire_queue_mutex(entry->produce_q);
4884 + result = qp_save_headers(entry);
4885 + if (result < VMCI_SUCCESS)
4886 +diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
4887 +index 87bac99207023..94caee49da99c 100644
4888 +--- a/drivers/mmc/core/block.c
4889 ++++ b/drivers/mmc/core/block.c
4890 +@@ -541,6 +541,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
4891 + return mmc_sanitize(card);
4892 +
4893 + mmc_wait_for_req(card->host, &mrq);
4894 ++ memcpy(&idata->ic.response, cmd.resp, sizeof(cmd.resp));
4895 +
4896 + if (cmd.error) {
4897 + dev_err(mmc_dev(card->host), "%s: cmd error %d\n",
4898 +@@ -590,8 +591,6 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
4899 + if (idata->ic.postsleep_min_us)
4900 + usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);
4901 +
4902 +- memcpy(&(idata->ic.response), cmd.resp, sizeof(cmd.resp));
4903 +-
4904 + if (idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B) {
4905 + /*
4906 + * Ensure RPMB/R1B command has completed by polling CMD13
4907 +diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
4908 +index eb395e1442071..e00167bcfaf6d 100644
4909 +--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
4910 ++++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
4911 +@@ -539,9 +539,22 @@ static int sd_write_long_data(struct realtek_pci_sdmmc *host,
4912 + return 0;
4913 + }
4914 +
4915 ++static inline void sd_enable_initial_mode(struct realtek_pci_sdmmc *host)
4916 ++{
4917 ++ rtsx_pci_write_register(host->pcr, SD_CFG1,
4918 ++ SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_128);
4919 ++}
4920 ++
4921 ++static inline void sd_disable_initial_mode(struct realtek_pci_sdmmc *host)
4922 ++{
4923 ++ rtsx_pci_write_register(host->pcr, SD_CFG1,
4924 ++ SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0);
4925 ++}
4926 ++
4927 + static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
4928 + {
4929 + struct mmc_data *data = mrq->data;
4930 ++ int err;
4931 +
4932 + if (host->sg_count < 0) {
4933 + data->error = host->sg_count;
4934 +@@ -550,22 +563,19 @@ static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
4935 + return data->error;
4936 + }
4937 +
4938 +- if (data->flags & MMC_DATA_READ)
4939 +- return sd_read_long_data(host, mrq);
4940 ++ if (data->flags & MMC_DATA_READ) {
4941 ++ if (host->initial_mode)
4942 ++ sd_disable_initial_mode(host);
4943 +
4944 +- return sd_write_long_data(host, mrq);
4945 +-}
4946 ++ err = sd_read_long_data(host, mrq);
4947 +
4948 +-static inline void sd_enable_initial_mode(struct realtek_pci_sdmmc *host)
4949 +-{
4950 +- rtsx_pci_write_register(host->pcr, SD_CFG1,
4951 +- SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_128);
4952 +-}
4953 ++ if (host->initial_mode)
4954 ++ sd_enable_initial_mode(host);
4955 +
4956 +-static inline void sd_disable_initial_mode(struct realtek_pci_sdmmc *host)
4957 +-{
4958 +- rtsx_pci_write_register(host->pcr, SD_CFG1,
4959 +- SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0);
4960 ++ return err;
4961 ++ }
4962 ++
4963 ++ return sd_write_long_data(host, mrq);
4964 + }
4965 +
4966 + static void sd_normal_rw(struct realtek_pci_sdmmc *host,
4967 +diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
4968 +index 3b8d456e857d5..fc38db64a6b48 100644
4969 +--- a/drivers/mmc/host/sdhci-of-arasan.c
4970 ++++ b/drivers/mmc/host/sdhci-of-arasan.c
4971 +@@ -159,6 +159,12 @@ struct sdhci_arasan_data {
4972 + /* Controller immediately reports SDHCI_CLOCK_INT_STABLE after enabling the
4973 + * internal clock even when the clock isn't stable */
4974 + #define SDHCI_ARASAN_QUIRK_CLOCK_UNSTABLE BIT(1)
4975 ++/*
4976 ++ * Some of the Arasan variations might not have timing requirements
4977 ++ * met at 25MHz for Default Speed mode, those controllers work at
4978 ++ * 19MHz instead
4979 ++ */
4980 ++#define SDHCI_ARASAN_QUIRK_CLOCK_25_BROKEN BIT(2)
4981 + };
4982 +
4983 + struct sdhci_arasan_of_data {
4984 +@@ -267,7 +273,12 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
4985 + * through low speeds without power cycling.
4986 + */
4987 + sdhci_set_clock(host, host->max_clk);
4988 +- phy_power_on(sdhci_arasan->phy);
4989 ++ if (phy_power_on(sdhci_arasan->phy)) {
4990 ++ pr_err("%s: Cannot power on phy.\n",
4991 ++ mmc_hostname(host->mmc));
4992 ++ return;
4993 ++ }
4994 ++
4995 + sdhci_arasan->is_phy_on = true;
4996 +
4997 + /*
4998 +@@ -290,6 +301,16 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
4999 + sdhci_arasan->is_phy_on = false;
5000 + }
5001 +
5002 ++ if (sdhci_arasan->quirks & SDHCI_ARASAN_QUIRK_CLOCK_25_BROKEN) {
5003 ++ /*
5004 ++ * Some of the Arasan variations might not have timing
5005 ++ * requirements met at 25MHz for Default Speed mode,
5006 ++ * those controllers work at 19MHz instead.
5007 ++ */
5008 ++ if (clock == DEFAULT_SPEED_MAX_DTR)
5009 ++ clock = (DEFAULT_SPEED_MAX_DTR * 19) / 25;
5010 ++ }
5011 ++
5012 + /* Set the Input and Output Clock Phase Delays */
5013 + if (clk_data->set_clk_delays)
5014 + clk_data->set_clk_delays(host);
5015 +@@ -307,7 +328,12 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
5016 + msleep(20);
5017 +
5018 + if (ctrl_phy) {
5019 +- phy_power_on(sdhci_arasan->phy);
5020 ++ if (phy_power_on(sdhci_arasan->phy)) {
5021 ++ pr_err("%s: Cannot power on phy.\n",
5022 ++ mmc_hostname(host->mmc));
5023 ++ return;
5024 ++ }
5025 ++
5026 + sdhci_arasan->is_phy_on = true;
5027 + }
5028 + }
5029 +@@ -463,7 +489,9 @@ static int sdhci_arasan_suspend(struct device *dev)
5030 + ret = phy_power_off(sdhci_arasan->phy);
5031 + if (ret) {
5032 + dev_err(dev, "Cannot power off phy.\n");
5033 +- sdhci_resume_host(host);
5034 ++ if (sdhci_resume_host(host))
5035 ++ dev_err(dev, "Cannot resume host.\n");
5036 ++
5037 + return ret;
5038 + }
5039 + sdhci_arasan->is_phy_on = false;
5040 +@@ -1598,6 +1626,8 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
5041 + if (of_device_is_compatible(np, "xlnx,zynqmp-8.9a")) {
5042 + host->mmc_host_ops.execute_tuning =
5043 + arasan_zynqmp_execute_tuning;
5044 ++
5045 ++ sdhci_arasan->quirks |= SDHCI_ARASAN_QUIRK_CLOCK_25_BROKEN;
5046 + }
5047 +
5048 + arasan_dt_parse_clk_phases(&pdev->dev, &sdhci_arasan->clk_data);
5049 +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
5050 +index 018af1e38eb9b..645c7cabcbe4d 100644
5051 +--- a/drivers/net/bonding/bond_main.c
5052 ++++ b/drivers/net/bonding/bond_main.c
5053 +@@ -2219,7 +2219,6 @@ static int __bond_release_one(struct net_device *bond_dev,
5054 + /* recompute stats just before removing the slave */
5055 + bond_get_stats(bond->dev, &bond->bond_stats);
5056 +
5057 +- bond_upper_dev_unlink(bond, slave);
5058 + /* unregister rx_handler early so bond_handle_frame wouldn't be called
5059 + * for this slave anymore.
5060 + */
5061 +@@ -2228,6 +2227,8 @@ static int __bond_release_one(struct net_device *bond_dev,
5062 + if (BOND_MODE(bond) == BOND_MODE_8023AD)
5063 + bond_3ad_unbind_slave(slave);
5064 +
5065 ++ bond_upper_dev_unlink(bond, slave);
5066 ++
5067 + if (bond_mode_can_use_xmit_hash(bond))
5068 + bond_update_slave_arr(bond, slave);
5069 +
5070 +diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
5071 +index a455534740cdf..95e634cbc4b63 100644
5072 +--- a/drivers/net/dsa/lantiq_gswip.c
5073 ++++ b/drivers/net/dsa/lantiq_gswip.c
5074 +@@ -853,7 +853,8 @@ static int gswip_setup(struct dsa_switch *ds)
5075 +
5076 + gswip_switch_mask(priv, 0, GSWIP_MAC_CTRL_2_MLEN,
5077 + GSWIP_MAC_CTRL_2p(cpu_port));
5078 +- gswip_switch_w(priv, VLAN_ETH_FRAME_LEN + 8, GSWIP_MAC_FLEN);
5079 ++ gswip_switch_w(priv, VLAN_ETH_FRAME_LEN + 8 + ETH_FCS_LEN,
5080 ++ GSWIP_MAC_FLEN);
5081 + gswip_switch_mask(priv, 0, GSWIP_BM_QUEUE_GCTRL_GL_MOD,
5082 + GSWIP_BM_QUEUE_GCTRL);
5083 +
5084 +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
5085 +index 61f6f0287cbe1..ff9d84a7147f1 100644
5086 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
5087 ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
5088 +@@ -10,7 +10,14 @@
5089 +
5090 + static u16 hclge_errno_to_resp(int errno)
5091 + {
5092 +- return abs(errno);
5093 ++ int resp = abs(errno);
5094 ++
5095 ++ /* The status for pf to vf msg cmd is u16, constrainted by HW.
5096 ++ * We need to keep the same type with it.
5097 ++ * The intput errno is the stander error code, it's safely to
5098 ++ * use a u16 to store the abs(errno).
5099 ++ */
5100 ++ return (u16)resp;
5101 + }
5102 +
5103 + /* hclge_gen_resp_to_vf: used to generate a synchronous response to VF when PF
5104 +diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
5105 +index 7023aa147043f..f06c079e812ec 100644
5106 +--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
5107 ++++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
5108 +@@ -131,6 +131,30 @@ enum iavf_status iavf_free_virt_mem_d(struct iavf_hw *hw,
5109 + return 0;
5110 + }
5111 +
5112 ++/**
5113 ++ * iavf_lock_timeout - try to set bit but give up after timeout
5114 ++ * @adapter: board private structure
5115 ++ * @bit: bit to set
5116 ++ * @msecs: timeout in msecs
5117 ++ *
5118 ++ * Returns 0 on success, negative on failure
5119 ++ **/
5120 ++static int iavf_lock_timeout(struct iavf_adapter *adapter,
5121 ++ enum iavf_critical_section_t bit,
5122 ++ unsigned int msecs)
5123 ++{
5124 ++ unsigned int wait, delay = 10;
5125 ++
5126 ++ for (wait = 0; wait < msecs; wait += delay) {
5127 ++ if (!test_and_set_bit(bit, &adapter->crit_section))
5128 ++ return 0;
5129 ++
5130 ++ msleep(delay);
5131 ++ }
5132 ++
5133 ++ return -1;
5134 ++}
5135 ++
5136 + /**
5137 + * iavf_schedule_reset - Set the flags and schedule a reset event
5138 + * @adapter: board private structure
5139 +@@ -1951,7 +1975,6 @@ static void iavf_watchdog_task(struct work_struct *work)
5140 + /* check for hw reset */
5141 + reg_val = rd32(hw, IAVF_VF_ARQLEN1) & IAVF_VF_ARQLEN1_ARQENABLE_MASK;
5142 + if (!reg_val) {
5143 +- adapter->state = __IAVF_RESETTING;
5144 + adapter->flags |= IAVF_FLAG_RESET_PENDING;
5145 + adapter->aq_required = 0;
5146 + adapter->current_op = VIRTCHNL_OP_UNKNOWN;
5147 +@@ -2065,6 +2088,10 @@ static void iavf_reset_task(struct work_struct *work)
5148 + if (test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section))
5149 + return;
5150 +
5151 ++ if (iavf_lock_timeout(adapter, __IAVF_IN_CRITICAL_TASK, 200)) {
5152 ++ schedule_work(&adapter->reset_task);
5153 ++ return;
5154 ++ }
5155 + while (test_and_set_bit(__IAVF_IN_CLIENT_TASK,
5156 + &adapter->crit_section))
5157 + usleep_range(500, 1000);
5158 +@@ -2279,6 +2306,8 @@ static void iavf_adminq_task(struct work_struct *work)
5159 + if (!event.msg_buf)
5160 + goto out;
5161 +
5162 ++ if (iavf_lock_timeout(adapter, __IAVF_IN_CRITICAL_TASK, 200))
5163 ++ goto freedom;
5164 + do {
5165 + ret = iavf_clean_arq_element(hw, &event, &pending);
5166 + v_op = (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
5167 +@@ -2292,6 +2321,7 @@ static void iavf_adminq_task(struct work_struct *work)
5168 + if (pending != 0)
5169 + memset(event.msg_buf, 0, IAVF_MAX_AQ_BUF_SIZE);
5170 + } while (pending);
5171 ++ clear_bit(__IAVF_IN_CRITICAL_TASK, &adapter->crit_section);
5172 +
5173 + if ((adapter->flags &
5174 + (IAVF_FLAG_RESET_PENDING | IAVF_FLAG_RESET_NEEDED)) ||
5175 +@@ -3594,6 +3624,10 @@ static void iavf_init_task(struct work_struct *work)
5176 + init_task.work);
5177 + struct iavf_hw *hw = &adapter->hw;
5178 +
5179 ++ if (iavf_lock_timeout(adapter, __IAVF_IN_CRITICAL_TASK, 5000)) {
5180 ++ dev_warn(&adapter->pdev->dev, "failed to set __IAVF_IN_CRITICAL_TASK in %s\n", __FUNCTION__);
5181 ++ return;
5182 ++ }
5183 + switch (adapter->state) {
5184 + case __IAVF_STARTUP:
5185 + if (iavf_startup(adapter) < 0)
5186 +@@ -3606,14 +3640,14 @@ static void iavf_init_task(struct work_struct *work)
5187 + case __IAVF_INIT_GET_RESOURCES:
5188 + if (iavf_init_get_resources(adapter) < 0)
5189 + goto init_failed;
5190 +- return;
5191 ++ goto out;
5192 + default:
5193 + goto init_failed;
5194 + }
5195 +
5196 + queue_delayed_work(iavf_wq, &adapter->init_task,
5197 + msecs_to_jiffies(30));
5198 +- return;
5199 ++ goto out;
5200 + init_failed:
5201 + if (++adapter->aq_wait_count > IAVF_AQ_MAX_ERR) {
5202 + dev_err(&adapter->pdev->dev,
5203 +@@ -3622,9 +3656,11 @@ init_failed:
5204 + iavf_shutdown_adminq(hw);
5205 + adapter->state = __IAVF_STARTUP;
5206 + queue_delayed_work(iavf_wq, &adapter->init_task, HZ * 5);
5207 +- return;
5208 ++ goto out;
5209 + }
5210 + queue_delayed_work(iavf_wq, &adapter->init_task, HZ);
5211 ++out:
5212 ++ clear_bit(__IAVF_IN_CRITICAL_TASK, &adapter->crit_section);
5213 + }
5214 +
5215 + /**
5216 +@@ -3641,9 +3677,12 @@ static void iavf_shutdown(struct pci_dev *pdev)
5217 + if (netif_running(netdev))
5218 + iavf_close(netdev);
5219 +
5220 ++ if (iavf_lock_timeout(adapter, __IAVF_IN_CRITICAL_TASK, 5000))
5221 ++ dev_warn(&adapter->pdev->dev, "failed to set __IAVF_IN_CRITICAL_TASK in %s\n", __FUNCTION__);
5222 + /* Prevent the watchdog from running. */
5223 + adapter->state = __IAVF_REMOVE;
5224 + adapter->aq_required = 0;
5225 ++ clear_bit(__IAVF_IN_CRITICAL_TASK, &adapter->crit_section);
5226 +
5227 + #ifdef CONFIG_PM
5228 + pci_save_state(pdev);
5229 +@@ -3871,10 +3910,6 @@ static void iavf_remove(struct pci_dev *pdev)
5230 + err);
5231 + }
5232 +
5233 +- /* Shut down all the garbage mashers on the detention level */
5234 +- adapter->state = __IAVF_REMOVE;
5235 +- adapter->aq_required = 0;
5236 +- adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
5237 + iavf_request_reset(adapter);
5238 + msleep(50);
5239 + /* If the FW isn't responding, kick it once, but only once. */
5240 +@@ -3882,6 +3917,13 @@ static void iavf_remove(struct pci_dev *pdev)
5241 + iavf_request_reset(adapter);
5242 + msleep(50);
5243 + }
5244 ++ if (iavf_lock_timeout(adapter, __IAVF_IN_CRITICAL_TASK, 5000))
5245 ++ dev_warn(&adapter->pdev->dev, "failed to set __IAVF_IN_CRITICAL_TASK in %s\n", __FUNCTION__);
5246 ++
5247 ++ /* Shut down all the garbage mashers on the detention level */
5248 ++ adapter->state = __IAVF_REMOVE;
5249 ++ adapter->aq_required = 0;
5250 ++ adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
5251 + iavf_free_all_tx_resources(adapter);
5252 + iavf_free_all_rx_resources(adapter);
5253 + iavf_misc_irq_disable(adapter);
5254 +diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
5255 +index 013dd29553814..cae090a072524 100644
5256 +--- a/drivers/net/ethernet/intel/igc/igc_main.c
5257 ++++ b/drivers/net/ethernet/intel/igc/igc_main.c
5258 +@@ -4083,6 +4083,7 @@ static irqreturn_t igc_msix_ring(int irq, void *data)
5259 + */
5260 + static int igc_request_msix(struct igc_adapter *adapter)
5261 + {
5262 ++ unsigned int num_q_vectors = adapter->num_q_vectors;
5263 + int i = 0, err = 0, vector = 0, free_vector = 0;
5264 + struct net_device *netdev = adapter->netdev;
5265 +
5266 +@@ -4091,7 +4092,13 @@ static int igc_request_msix(struct igc_adapter *adapter)
5267 + if (err)
5268 + goto err_out;
5269 +
5270 +- for (i = 0; i < adapter->num_q_vectors; i++) {
5271 ++ if (num_q_vectors > MAX_Q_VECTORS) {
5272 ++ num_q_vectors = MAX_Q_VECTORS;
5273 ++ dev_warn(&adapter->pdev->dev,
5274 ++ "The number of queue vectors (%d) is higher than max allowed (%d)\n",
5275 ++ adapter->num_q_vectors, MAX_Q_VECTORS);
5276 ++ }
5277 ++ for (i = 0; i < num_q_vectors; i++) {
5278 + struct igc_q_vector *q_vector = adapter->q_vector[i];
5279 +
5280 + vector++;
5281 +diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
5282 +index df238e46e2aeb..b062ed06235d2 100644
5283 +--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
5284 ++++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
5285 +@@ -1129,7 +1129,22 @@ static int otx2_aura_init(struct otx2_nic *pfvf, int aura_id,
5286 + /* Enable backpressure for RQ aura */
5287 + if (aura_id < pfvf->hw.rqpool_cnt) {
5288 + aq->aura.bp_ena = 0;
5289 ++ /* If NIX1 LF is attached then specify NIX1_RX.
5290 ++ *
5291 ++ * Below NPA_AURA_S[BP_ENA] is set according to the
5292 ++ * NPA_BPINTF_E enumeration given as:
5293 ++ * 0x0 + a*0x1 where 'a' is 0 for NIX0_RX and 1 for NIX1_RX so
5294 ++ * NIX0_RX is 0x0 + 0*0x1 = 0
5295 ++ * NIX1_RX is 0x0 + 1*0x1 = 1
5296 ++ * But in HRM it is given that
5297 ++ * "NPA_AURA_S[BP_ENA](w1[33:32]) - Enable aura backpressure to
5298 ++ * NIX-RX based on [BP] level. One bit per NIX-RX; index
5299 ++ * enumerated by NPA_BPINTF_E."
5300 ++ */
5301 ++ if (pfvf->nix_blkaddr == BLKADDR_NIX1)
5302 ++ aq->aura.bp_ena = 1;
5303 + aq->aura.nix0_bpid = pfvf->bpid[0];
5304 ++
5305 + /* Set backpressure level for RQ's Aura */
5306 + aq->aura.bp = RQ_BP_LVL_AURA;
5307 + }
5308 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
5309 +index e49387dbef987..2e55e00888715 100644
5310 +--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
5311 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
5312 +@@ -865,7 +865,7 @@ static void cb_timeout_handler(struct work_struct *work)
5313 + ent->ret = -ETIMEDOUT;
5314 + mlx5_core_warn(dev, "cmd[%d]: %s(0x%x) Async, timeout. Will cause a leak of a command resource\n",
5315 + ent->idx, mlx5_command_str(msg_to_opcode(ent->in)), msg_to_opcode(ent->in));
5316 +- mlx5_cmd_comp_handler(dev, 1UL << ent->idx, true);
5317 ++ mlx5_cmd_comp_handler(dev, 1ULL << ent->idx, true);
5318 +
5319 + out:
5320 + cmd_ent_put(ent); /* for the cmd_ent_get() took on schedule delayed work */
5321 +@@ -982,7 +982,7 @@ static void cmd_work_handler(struct work_struct *work)
5322 + MLX5_SET(mbox_out, ent->out, status, status);
5323 + MLX5_SET(mbox_out, ent->out, syndrome, drv_synd);
5324 +
5325 +- mlx5_cmd_comp_handler(dev, 1UL << ent->idx, true);
5326 ++ mlx5_cmd_comp_handler(dev, 1ULL << ent->idx, true);
5327 + return;
5328 + }
5329 +
5330 +@@ -996,7 +996,7 @@ static void cmd_work_handler(struct work_struct *work)
5331 + poll_timeout(ent);
5332 + /* make sure we read the descriptor after ownership is SW */
5333 + rmb();
5334 +- mlx5_cmd_comp_handler(dev, 1UL << ent->idx, (ent->ret == -ETIMEDOUT));
5335 ++ mlx5_cmd_comp_handler(dev, 1ULL << ent->idx, (ent->ret == -ETIMEDOUT));
5336 + }
5337 + }
5338 +
5339 +@@ -1056,7 +1056,7 @@ static void wait_func_handle_exec_timeout(struct mlx5_core_dev *dev,
5340 + mlx5_command_str(msg_to_opcode(ent->in)), msg_to_opcode(ent->in));
5341 +
5342 + ent->ret = -ETIMEDOUT;
5343 +- mlx5_cmd_comp_handler(dev, 1UL << ent->idx, true);
5344 ++ mlx5_cmd_comp_handler(dev, 1ULL << ent->idx, true);
5345 + }
5346 +
5347 + static int wait_func(struct mlx5_core_dev *dev, struct mlx5_cmd_work_ent *ent)
5348 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
5349 +index b3c9dc032026c..478de5ded7c21 100644
5350 +--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
5351 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
5352 +@@ -824,9 +824,9 @@ again:
5353 + new_htbl = dr_rule_rehash(rule, nic_rule, cur_htbl,
5354 + ste_location, send_ste_list);
5355 + if (!new_htbl) {
5356 +- mlx5dr_htbl_put(cur_htbl);
5357 + mlx5dr_err(dmn, "Failed creating rehash table, htbl-log_size: %d\n",
5358 + cur_htbl->chunk_size);
5359 ++ mlx5dr_htbl_put(cur_htbl);
5360 + } else {
5361 + cur_htbl = new_htbl;
5362 + }
5363 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c
5364 +index ea3c6cf27db42..eb6677f737a0f 100644
5365 +--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c
5366 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c
5367 +@@ -605,6 +605,7 @@ static int dr_cmd_modify_qp_rtr2rts(struct mlx5_core_dev *mdev,
5368 +
5369 + MLX5_SET(qpc, qpc, retry_count, attr->retry_cnt);
5370 + MLX5_SET(qpc, qpc, rnr_retry, attr->rnr_retry);
5371 ++ MLX5_SET(qpc, qpc, primary_address_path.ack_timeout, 0x8); /* ~1ms */
5372 +
5373 + MLX5_SET(rtr2rts_qp_in, in, opcode, MLX5_CMD_OP_RTR2RTS_QP);
5374 + MLX5_SET(rtr2rts_qp_in, in, qpn, dr_qp->qpn);
5375 +diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
5376 +index 437226866ce81..dfc1f32cda2b3 100644
5377 +--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
5378 ++++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
5379 +@@ -1697,7 +1697,7 @@ nfp_net_parse_meta(struct net_device *netdev, struct nfp_meta_parsed *meta,
5380 + case NFP_NET_META_RESYNC_INFO:
5381 + if (nfp_net_tls_rx_resync_req(netdev, data, pkt,
5382 + pkt_len))
5383 +- return NULL;
5384 ++ return false;
5385 + data += sizeof(struct nfp_net_tls_resync_req);
5386 + break;
5387 + default:
5388 +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
5389 +index 749585fe6fc96..90f69f43770a4 100644
5390 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
5391 ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
5392 +@@ -289,10 +289,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
5393 + val &= ~NSS_COMMON_GMAC_CTL_PHY_IFACE_SEL;
5394 + break;
5395 + default:
5396 +- dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
5397 +- phy_modes(gmac->phy_mode));
5398 +- err = -EINVAL;
5399 +- goto err_remove_config_dt;
5400 ++ goto err_unsupported_phy;
5401 + }
5402 + regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val);
5403 +
5404 +@@ -309,10 +306,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
5405 + NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id);
5406 + break;
5407 + default:
5408 +- dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
5409 +- phy_modes(gmac->phy_mode));
5410 +- err = -EINVAL;
5411 +- goto err_remove_config_dt;
5412 ++ goto err_unsupported_phy;
5413 + }
5414 + regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val);
5415 +
5416 +@@ -329,8 +323,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
5417 + NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id);
5418 + break;
5419 + default:
5420 +- /* We don't get here; the switch above will have errored out */
5421 +- unreachable();
5422 ++ goto err_unsupported_phy;
5423 + }
5424 + regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val);
5425 +
5426 +@@ -361,6 +354,11 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
5427 +
5428 + return 0;
5429 +
5430 ++err_unsupported_phy:
5431 ++ dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
5432 ++ phy_modes(gmac->phy_mode));
5433 ++ err = -EINVAL;
5434 ++
5435 + err_remove_config_dt:
5436 + stmmac_remove_config_dt(pdev, plat_dat);
5437 +
5438 +diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiznet/w5100.c
5439 +index c0d181a7f83ae..0b7135a3c585a 100644
5440 +--- a/drivers/net/ethernet/wiznet/w5100.c
5441 ++++ b/drivers/net/ethernet/wiznet/w5100.c
5442 +@@ -1052,6 +1052,8 @@ static int w5100_mmio_probe(struct platform_device *pdev)
5443 + mac_addr = data->mac_addr;
5444 +
5445 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
5446 ++ if (!mem)
5447 ++ return -EINVAL;
5448 + if (resource_size(mem) < W5100_BUS_DIRECT_SIZE)
5449 + ops = &w5100_mmio_indirect_ops;
5450 + else
5451 +diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
5452 +index a9b058bb1be87..7bf43031cea8c 100644
5453 +--- a/drivers/net/phy/dp83822.c
5454 ++++ b/drivers/net/phy/dp83822.c
5455 +@@ -305,11 +305,9 @@ static int dp83822_config_intr(struct phy_device *phydev)
5456 +
5457 + static int dp8382x_disable_wol(struct phy_device *phydev)
5458 + {
5459 +- int value = DP83822_WOL_EN | DP83822_WOL_MAGIC_EN |
5460 +- DP83822_WOL_SECURE_ON;
5461 +-
5462 +- return phy_clear_bits_mmd(phydev, DP83822_DEVADDR,
5463 +- MII_DP83822_WOL_CFG, value);
5464 ++ return phy_clear_bits_mmd(phydev, DP83822_DEVADDR, MII_DP83822_WOL_CFG,
5465 ++ DP83822_WOL_EN | DP83822_WOL_MAGIC_EN |
5466 ++ DP83822_WOL_SECURE_ON);
5467 + }
5468 +
5469 + static int dp83822_read_status(struct phy_device *phydev)
5470 +diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
5471 +index b4885a700296e..b0a4ca3559fd8 100644
5472 +--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
5473 ++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
5474 +@@ -3351,7 +3351,8 @@ found:
5475 + "Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n",
5476 + cptr, code, reference, length, major, minor);
5477 + if ((!AR_SREV_9485(ah) && length >= 1024) ||
5478 +- (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485)) {
5479 ++ (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485) ||
5480 ++ (length > cptr)) {
5481 + ath_dbg(common, EEPROM, "Skipping bad header\n");
5482 + cptr -= COMP_HDR_LEN;
5483 + continue;
5484 +diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
5485 +index c86faebbc4594..6b2668f065d54 100644
5486 +--- a/drivers/net/wireless/ath/ath9k/hw.c
5487 ++++ b/drivers/net/wireless/ath/ath9k/hw.c
5488 +@@ -1622,7 +1622,6 @@ static void ath9k_hw_apply_gpio_override(struct ath_hw *ah)
5489 + ath9k_hw_gpio_request_out(ah, i, NULL,
5490 + AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
5491 + ath9k_hw_set_gpio(ah, i, !!(ah->gpio_val & BIT(i)));
5492 +- ath9k_hw_gpio_free(ah, i);
5493 + }
5494 + }
5495 +
5496 +@@ -2730,14 +2729,17 @@ static void ath9k_hw_gpio_cfg_output_mux(struct ath_hw *ah, u32 gpio, u32 type)
5497 + static void ath9k_hw_gpio_cfg_soc(struct ath_hw *ah, u32 gpio, bool out,
5498 + const char *label)
5499 + {
5500 ++ int err;
5501 ++
5502 + if (ah->caps.gpio_requested & BIT(gpio))
5503 + return;
5504 +
5505 +- /* may be requested by BSP, free anyway */
5506 +- gpio_free(gpio);
5507 +-
5508 +- if (gpio_request_one(gpio, out ? GPIOF_OUT_INIT_LOW : GPIOF_IN, label))
5509 ++ err = gpio_request_one(gpio, out ? GPIOF_OUT_INIT_LOW : GPIOF_IN, label);
5510 ++ if (err) {
5511 ++ ath_err(ath9k_hw_common(ah), "request GPIO%d failed:%d\n",
5512 ++ gpio, err);
5513 + return;
5514 ++ }
5515 +
5516 + ah->caps.gpio_requested |= BIT(gpio);
5517 + }
5518 +diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
5519 +index 9f8e44210e89a..6bed619535427 100644
5520 +--- a/drivers/net/wireless/ath/wcn36xx/main.c
5521 ++++ b/drivers/net/wireless/ath/wcn36xx/main.c
5522 +@@ -405,13 +405,14 @@ static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed)
5523 + wcn36xx_dbg(WCN36XX_DBG_MAC, "wcn36xx_config channel switch=%d\n",
5524 + ch);
5525 +
5526 +- if (wcn->sw_scan_opchannel == ch) {
5527 ++ if (wcn->sw_scan_opchannel == ch && wcn->sw_scan_channel) {
5528 + /* If channel is the initial operating channel, we may
5529 + * want to receive/transmit regular data packets, then
5530 + * simply stop the scan session and exit PS mode.
5531 + */
5532 + wcn36xx_smd_finish_scan(wcn, HAL_SYS_MODE_SCAN,
5533 + wcn->sw_scan_vif);
5534 ++ wcn->sw_scan_channel = 0;
5535 + } else if (wcn->sw_scan) {
5536 + /* A scan is ongoing, do not change the operating
5537 + * channel, but start a scan session on the channel.
5538 +@@ -419,6 +420,7 @@ static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed)
5539 + wcn36xx_smd_init_scan(wcn, HAL_SYS_MODE_SCAN,
5540 + wcn->sw_scan_vif);
5541 + wcn36xx_smd_start_scan(wcn, ch);
5542 ++ wcn->sw_scan_channel = ch;
5543 + } else {
5544 + wcn36xx_change_opchannel(wcn, ch);
5545 + }
5546 +@@ -699,6 +701,7 @@ static void wcn36xx_sw_scan_start(struct ieee80211_hw *hw,
5547 +
5548 + wcn->sw_scan = true;
5549 + wcn->sw_scan_vif = vif;
5550 ++ wcn->sw_scan_channel = 0;
5551 + if (vif_priv->sta_assoc)
5552 + wcn->sw_scan_opchannel = WCN36XX_HW_CHANNEL(wcn);
5553 + else
5554 +diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.c b/drivers/net/wireless/ath/wcn36xx/txrx.c
5555 +index 1b831157ede17..cab196bb38cd4 100644
5556 +--- a/drivers/net/wireless/ath/wcn36xx/txrx.c
5557 ++++ b/drivers/net/wireless/ath/wcn36xx/txrx.c
5558 +@@ -287,6 +287,10 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb)
5559 + status.rate_idx = 0;
5560 + }
5561 +
5562 ++ if (ieee80211_is_beacon(hdr->frame_control) ||
5563 ++ ieee80211_is_probe_resp(hdr->frame_control))
5564 ++ status.boottime_ns = ktime_get_boottime_ns();
5565 ++
5566 + memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
5567 +
5568 + if (ieee80211_is_beacon(hdr->frame_control)) {
5569 +diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
5570 +index 71fa9992b118c..d0fcce86903ae 100644
5571 +--- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
5572 ++++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
5573 +@@ -232,6 +232,7 @@ struct wcn36xx {
5574 + struct cfg80211_scan_request *scan_req;
5575 + bool sw_scan;
5576 + u8 sw_scan_opchannel;
5577 ++ u8 sw_scan_channel;
5578 + struct ieee80211_vif *sw_scan_vif;
5579 + struct mutex scan_lock;
5580 + bool scan_aborted;
5581 +diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
5582 +index ab4a8b942c81d..419eaa5cf0b50 100644
5583 +--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
5584 ++++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
5585 +@@ -2303,7 +2303,7 @@ static void iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
5586 + return;
5587 +
5588 + if (dump_data->monitor_only)
5589 +- dump_mask &= IWL_FW_ERROR_DUMP_FW_MONITOR;
5590 ++ dump_mask &= BIT(IWL_FW_ERROR_DUMP_FW_MONITOR);
5591 +
5592 + fw_error_dump.trans_ptr = iwl_trans_dump_data(fwrt->trans, dump_mask);
5593 + file_len = le32_to_cpu(dump_file->file_len);
5594 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
5595 +index 5243b84e653cf..6a8bf9bb9c455 100644
5596 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
5597 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
5598 +@@ -1044,8 +1044,10 @@ int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
5599 + return -ENOMEM;
5600 +
5601 + #ifdef CONFIG_IWLWIFI_DEBUGFS
5602 +- if (mvm->beacon_inject_active)
5603 ++ if (mvm->beacon_inject_active) {
5604 ++ dev_kfree_skb(beacon);
5605 + return -EBUSY;
5606 ++ }
5607 + #endif
5608 +
5609 + ret = iwl_mvm_mac_ctxt_send_beacon(mvm, vif, beacon);
5610 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
5611 +index 9caff70cbd276..6f301ac8cce20 100644
5612 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
5613 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
5614 +@@ -3029,16 +3029,20 @@ static void iwl_mvm_check_he_obss_narrow_bw_ru_iter(struct wiphy *wiphy,
5615 + void *_data)
5616 + {
5617 + struct iwl_mvm_he_obss_narrow_bw_ru_data *data = _data;
5618 ++ const struct cfg80211_bss_ies *ies;
5619 + const struct element *elem;
5620 +
5621 +- elem = cfg80211_find_elem(WLAN_EID_EXT_CAPABILITY, bss->ies->data,
5622 +- bss->ies->len);
5623 ++ rcu_read_lock();
5624 ++ ies = rcu_dereference(bss->ies);
5625 ++ elem = cfg80211_find_elem(WLAN_EID_EXT_CAPABILITY, ies->data,
5626 ++ ies->len);
5627 +
5628 + if (!elem || elem->datalen < 10 ||
5629 + !(elem->data[10] &
5630 + WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT)) {
5631 + data->tolerated = false;
5632 + }
5633 ++ rcu_read_unlock();
5634 + }
5635 +
5636 + static void iwl_mvm_check_he_obss_narrow_bw_ru(struct ieee80211_hw *hw,
5637 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
5638 +index cb83490f1016f..0be8ff30b13e6 100644
5639 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
5640 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
5641 +@@ -678,10 +678,26 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
5642 +
5643 + mvm->fw_restart = iwlwifi_mod_params.fw_restart ? -1 : 0;
5644 +
5645 +- mvm->aux_queue = IWL_MVM_DQA_AUX_QUEUE;
5646 +- mvm->snif_queue = IWL_MVM_DQA_INJECT_MONITOR_QUEUE;
5647 +- mvm->probe_queue = IWL_MVM_DQA_AP_PROBE_RESP_QUEUE;
5648 +- mvm->p2p_dev_queue = IWL_MVM_DQA_P2P_DEVICE_QUEUE;
5649 ++ if (iwl_mvm_has_new_tx_api(mvm)) {
5650 ++ /*
5651 ++ * If we have the new TX/queue allocation API initialize them
5652 ++ * all to invalid numbers. We'll rewrite the ones that we need
5653 ++ * later, but that doesn't happen for all of them all of the
5654 ++ * time (e.g. P2P Device is optional), and if a dynamic queue
5655 ++ * ends up getting number 2 (IWL_MVM_DQA_P2P_DEVICE_QUEUE) then
5656 ++ * iwl_mvm_is_static_queue() erroneously returns true, and we
5657 ++ * might have things getting stuck.
5658 ++ */
5659 ++ mvm->aux_queue = IWL_MVM_INVALID_QUEUE;
5660 ++ mvm->snif_queue = IWL_MVM_INVALID_QUEUE;
5661 ++ mvm->probe_queue = IWL_MVM_INVALID_QUEUE;
5662 ++ mvm->p2p_dev_queue = IWL_MVM_INVALID_QUEUE;
5663 ++ } else {
5664 ++ mvm->aux_queue = IWL_MVM_DQA_AUX_QUEUE;
5665 ++ mvm->snif_queue = IWL_MVM_DQA_INJECT_MONITOR_QUEUE;
5666 ++ mvm->probe_queue = IWL_MVM_DQA_AP_PROBE_RESP_QUEUE;
5667 ++ mvm->p2p_dev_queue = IWL_MVM_DQA_P2P_DEVICE_QUEUE;
5668 ++ }
5669 +
5670 + mvm->sf_state = SF_UNINIT;
5671 + if (iwl_mvm_has_unified_ucode(mvm))
5672 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
5673 +index aebaad45043fa..a5d90e028833c 100644
5674 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
5675 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
5676 +@@ -1682,7 +1682,7 @@ iwl_mvm_umac_scan_cfg_channels_v6(struct iwl_mvm *mvm,
5677 + struct iwl_scan_channel_cfg_umac *cfg = &cp->channel_config[i];
5678 + u32 n_aps_flag =
5679 + iwl_mvm_scan_ch_n_aps_flag(vif_type,
5680 +- cfg->v2.channel_num);
5681 ++ channels[i]->hw_value);
5682 +
5683 + cfg->flags = cpu_to_le32(flags | n_aps_flag);
5684 + cfg->v2.channel_num = channels[i]->hw_value;
5685 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
5686 +index a66a5c19474a9..ef62839894c77 100644
5687 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
5688 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
5689 +@@ -362,8 +362,9 @@ static int iwl_mvm_invalidate_sta_queue(struct iwl_mvm *mvm, int queue,
5690 + }
5691 +
5692 + static int iwl_mvm_disable_txq(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
5693 +- int queue, u8 tid, u8 flags)
5694 ++ u16 *queueptr, u8 tid, u8 flags)
5695 + {
5696 ++ int queue = *queueptr;
5697 + struct iwl_scd_txq_cfg_cmd cmd = {
5698 + .scd_queue = queue,
5699 + .action = SCD_CFG_DISABLE_QUEUE,
5700 +@@ -372,6 +373,7 @@ static int iwl_mvm_disable_txq(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
5701 +
5702 + if (iwl_mvm_has_new_tx_api(mvm)) {
5703 + iwl_trans_txq_free(mvm->trans, queue);
5704 ++ *queueptr = IWL_MVM_INVALID_QUEUE;
5705 +
5706 + return 0;
5707 + }
5708 +@@ -533,6 +535,7 @@ static int iwl_mvm_free_inactive_queue(struct iwl_mvm *mvm, int queue,
5709 + u8 sta_id, tid;
5710 + unsigned long disable_agg_tids = 0;
5711 + bool same_sta;
5712 ++ u16 queue_tmp = queue;
5713 + int ret;
5714 +
5715 + lockdep_assert_held(&mvm->mutex);
5716 +@@ -555,7 +558,7 @@ static int iwl_mvm_free_inactive_queue(struct iwl_mvm *mvm, int queue,
5717 + iwl_mvm_invalidate_sta_queue(mvm, queue,
5718 + disable_agg_tids, false);
5719 +
5720 +- ret = iwl_mvm_disable_txq(mvm, old_sta, queue, tid, 0);
5721 ++ ret = iwl_mvm_disable_txq(mvm, old_sta, &queue_tmp, tid, 0);
5722 + if (ret) {
5723 + IWL_ERR(mvm,
5724 + "Failed to free inactive queue %d (ret=%d)\n",
5725 +@@ -1230,6 +1233,7 @@ static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm,
5726 + unsigned int wdg_timeout =
5727 + iwl_mvm_get_wd_timeout(mvm, mvmsta->vif, false, false);
5728 + int queue = -1;
5729 ++ u16 queue_tmp;
5730 + unsigned long disable_agg_tids = 0;
5731 + enum iwl_mvm_agg_state queue_state;
5732 + bool shared_queue = false, inc_ssn;
5733 +@@ -1378,7 +1382,8 @@ static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm,
5734 + return 0;
5735 +
5736 + out_err:
5737 +- iwl_mvm_disable_txq(mvm, sta, queue, tid, 0);
5738 ++ queue_tmp = queue;
5739 ++ iwl_mvm_disable_txq(mvm, sta, &queue_tmp, tid, 0);
5740 +
5741 + return ret;
5742 + }
5743 +@@ -1825,7 +1830,7 @@ static void iwl_mvm_disable_sta_queues(struct iwl_mvm *mvm,
5744 + if (mvm_sta->tid_data[i].txq_id == IWL_MVM_INVALID_QUEUE)
5745 + continue;
5746 +
5747 +- iwl_mvm_disable_txq(mvm, sta, mvm_sta->tid_data[i].txq_id, i,
5748 ++ iwl_mvm_disable_txq(mvm, sta, &mvm_sta->tid_data[i].txq_id, i,
5749 + 0);
5750 + mvm_sta->tid_data[i].txq_id = IWL_MVM_INVALID_QUEUE;
5751 + }
5752 +@@ -2033,7 +2038,7 @@ static int iwl_mvm_add_int_sta_with_queue(struct iwl_mvm *mvm, int macidx,
5753 + ret = iwl_mvm_add_int_sta_common(mvm, sta, addr, macidx, maccolor);
5754 + if (ret) {
5755 + if (!iwl_mvm_has_new_tx_api(mvm))
5756 +- iwl_mvm_disable_txq(mvm, NULL, *queue,
5757 ++ iwl_mvm_disable_txq(mvm, NULL, queue,
5758 + IWL_MAX_TID_COUNT, 0);
5759 + return ret;
5760 + }
5761 +@@ -2106,7 +2111,7 @@ int iwl_mvm_rm_snif_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
5762 + if (WARN_ON_ONCE(mvm->snif_sta.sta_id == IWL_MVM_INVALID_STA))
5763 + return -EINVAL;
5764 +
5765 +- iwl_mvm_disable_txq(mvm, NULL, mvm->snif_queue, IWL_MAX_TID_COUNT, 0);
5766 ++ iwl_mvm_disable_txq(mvm, NULL, &mvm->snif_queue, IWL_MAX_TID_COUNT, 0);
5767 + ret = iwl_mvm_rm_sta_common(mvm, mvm->snif_sta.sta_id);
5768 + if (ret)
5769 + IWL_WARN(mvm, "Failed sending remove station\n");
5770 +@@ -2123,7 +2128,7 @@ int iwl_mvm_rm_aux_sta(struct iwl_mvm *mvm)
5771 + if (WARN_ON_ONCE(mvm->aux_sta.sta_id == IWL_MVM_INVALID_STA))
5772 + return -EINVAL;
5773 +
5774 +- iwl_mvm_disable_txq(mvm, NULL, mvm->aux_queue, IWL_MAX_TID_COUNT, 0);
5775 ++ iwl_mvm_disable_txq(mvm, NULL, &mvm->aux_queue, IWL_MAX_TID_COUNT, 0);
5776 + ret = iwl_mvm_rm_sta_common(mvm, mvm->aux_sta.sta_id);
5777 + if (ret)
5778 + IWL_WARN(mvm, "Failed sending remove station\n");
5779 +@@ -2219,7 +2224,7 @@ static void iwl_mvm_free_bcast_sta_queues(struct iwl_mvm *mvm,
5780 + struct ieee80211_vif *vif)
5781 + {
5782 + struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
5783 +- int queue;
5784 ++ u16 *queueptr, queue;
5785 +
5786 + lockdep_assert_held(&mvm->mutex);
5787 +
5788 +@@ -2228,10 +2233,10 @@ static void iwl_mvm_free_bcast_sta_queues(struct iwl_mvm *mvm,
5789 + switch (vif->type) {
5790 + case NL80211_IFTYPE_AP:
5791 + case NL80211_IFTYPE_ADHOC:
5792 +- queue = mvm->probe_queue;
5793 ++ queueptr = &mvm->probe_queue;
5794 + break;
5795 + case NL80211_IFTYPE_P2P_DEVICE:
5796 +- queue = mvm->p2p_dev_queue;
5797 ++ queueptr = &mvm->p2p_dev_queue;
5798 + break;
5799 + default:
5800 + WARN(1, "Can't free bcast queue on vif type %d\n",
5801 +@@ -2239,7 +2244,8 @@ static void iwl_mvm_free_bcast_sta_queues(struct iwl_mvm *mvm,
5802 + return;
5803 + }
5804 +
5805 +- iwl_mvm_disable_txq(mvm, NULL, queue, IWL_MAX_TID_COUNT, 0);
5806 ++ queue = *queueptr;
5807 ++ iwl_mvm_disable_txq(mvm, NULL, queueptr, IWL_MAX_TID_COUNT, 0);
5808 + if (iwl_mvm_has_new_tx_api(mvm))
5809 + return;
5810 +
5811 +@@ -2474,7 +2480,7 @@ int iwl_mvm_rm_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
5812 +
5813 + iwl_mvm_flush_sta(mvm, &mvmvif->mcast_sta, true);
5814 +
5815 +- iwl_mvm_disable_txq(mvm, NULL, mvmvif->cab_queue, 0, 0);
5816 ++ iwl_mvm_disable_txq(mvm, NULL, &mvmvif->cab_queue, 0, 0);
5817 +
5818 + ret = iwl_mvm_rm_sta_common(mvm, mvmvif->mcast_sta.sta_id);
5819 + if (ret)
5820 +diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
5821 +index 94299f259518d..2c13fa8f28200 100644
5822 +--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
5823 ++++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
5824 +@@ -544,6 +544,9 @@ void iwl_pcie_free_rbs_pool(struct iwl_trans *trans)
5825 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
5826 + int i;
5827 +
5828 ++ if (!trans_pcie->rx_pool)
5829 ++ return;
5830 ++
5831 + for (i = 0; i < RX_POOL_SIZE(trans_pcie->num_rx_bufs); i++) {
5832 + if (!trans_pcie->rx_pool[i].page)
5833 + continue;
5834 +@@ -1094,7 +1097,7 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans)
5835 + INIT_LIST_HEAD(&rba->rbd_empty);
5836 + spin_unlock(&rba->lock);
5837 +
5838 +- /* free all first - we might be reconfigured for a different size */
5839 ++ /* free all first - we overwrite everything here */
5840 + iwl_pcie_free_rbs_pool(trans);
5841 +
5842 + for (i = 0; i < RX_QUEUE_SIZE; i++)
5843 +diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
5844 +index bb990be7c870b..082768ec8aa80 100644
5845 +--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
5846 ++++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
5847 +@@ -1909,6 +1909,9 @@ static void iwl_trans_pcie_configure(struct iwl_trans *trans,
5848 + {
5849 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
5850 +
5851 ++ /* free all first - we might be reconfigured for a different size */
5852 ++ iwl_pcie_free_rbs_pool(trans);
5853 ++
5854 + trans->txqs.cmd.q_id = trans_cfg->cmd_queue;
5855 + trans->txqs.cmd.fifo = trans_cfg->cmd_fifo;
5856 + trans->txqs.cmd.wdg_timeout = trans_cfg->cmd_q_wdg_timeout;
5857 +diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
5858 +index acb6b0cd36672..b28fa0c4d180c 100644
5859 +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
5860 ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
5861 +@@ -1378,6 +1378,8 @@ struct rtl8xxxu_priv {
5862 + u8 no_pape:1;
5863 + u8 int_buf[USB_INTR_CONTENT_LENGTH];
5864 + u8 rssi_level;
5865 ++ DECLARE_BITMAP(tx_aggr_started, IEEE80211_NUM_TIDS);
5866 ++ DECLARE_BITMAP(tid_tx_operational, IEEE80211_NUM_TIDS);
5867 + /*
5868 + * Only one virtual interface permitted because only STA mode
5869 + * is supported and no iface_combinations are provided.
5870 +diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
5871 +index 5cd7ef3625c5e..0d374a2948406 100644
5872 +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
5873 ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
5874 +@@ -4805,6 +4805,8 @@ rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
5875 + struct ieee80211_rate *tx_rate = ieee80211_get_tx_rate(hw, tx_info);
5876 + struct rtl8xxxu_priv *priv = hw->priv;
5877 + struct device *dev = &priv->udev->dev;
5878 ++ u8 *qc = ieee80211_get_qos_ctl(hdr);
5879 ++ u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
5880 + u32 rate;
5881 + u16 rate_flags = tx_info->control.rates[0].flags;
5882 + u16 seq_number;
5883 +@@ -4828,7 +4830,7 @@ rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
5884 +
5885 + tx_desc->txdw3 = cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT);
5886 +
5887 +- if (ampdu_enable)
5888 ++ if (ampdu_enable && test_bit(tid, priv->tid_tx_operational))
5889 + tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_ENABLE);
5890 + else
5891 + tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK);
5892 +@@ -4876,6 +4878,8 @@ rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
5893 + struct rtl8xxxu_priv *priv = hw->priv;
5894 + struct device *dev = &priv->udev->dev;
5895 + struct rtl8xxxu_txdesc40 *tx_desc40;
5896 ++ u8 *qc = ieee80211_get_qos_ctl(hdr);
5897 ++ u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
5898 + u32 rate;
5899 + u16 rate_flags = tx_info->control.rates[0].flags;
5900 + u16 seq_number;
5901 +@@ -4902,7 +4906,7 @@ rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
5902 +
5903 + tx_desc40->txdw9 = cpu_to_le32((u32)seq_number << TXDESC40_SEQ_SHIFT);
5904 +
5905 +- if (ampdu_enable)
5906 ++ if (ampdu_enable && test_bit(tid, priv->tid_tx_operational))
5907 + tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE);
5908 + else
5909 + tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK);
5910 +@@ -5015,12 +5019,19 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
5911 + if (ieee80211_is_data_qos(hdr->frame_control) && sta) {
5912 + if (sta->ht_cap.ht_supported) {
5913 + u32 ampdu, val32;
5914 ++ u8 *qc = ieee80211_get_qos_ctl(hdr);
5915 ++ u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
5916 +
5917 + ampdu = (u32)sta->ht_cap.ampdu_density;
5918 + val32 = ampdu << TXDESC_AMPDU_DENSITY_SHIFT;
5919 + tx_desc->txdw2 |= cpu_to_le32(val32);
5920 +
5921 + ampdu_enable = true;
5922 ++
5923 ++ if (!test_bit(tid, priv->tx_aggr_started) &&
5924 ++ !(skb->protocol == cpu_to_be16(ETH_P_PAE)))
5925 ++ if (!ieee80211_start_tx_ba_session(sta, tid, 0))
5926 ++ set_bit(tid, priv->tx_aggr_started);
5927 + }
5928 + }
5929 +
5930 +@@ -6095,6 +6106,7 @@ rtl8xxxu_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5931 + struct device *dev = &priv->udev->dev;
5932 + u8 ampdu_factor, ampdu_density;
5933 + struct ieee80211_sta *sta = params->sta;
5934 ++ u16 tid = params->tid;
5935 + enum ieee80211_ampdu_mlme_action action = params->action;
5936 +
5937 + switch (action) {
5938 +@@ -6107,17 +6119,20 @@ rtl8xxxu_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5939 + dev_dbg(dev,
5940 + "Changed HT: ampdu_factor %02x, ampdu_density %02x\n",
5941 + ampdu_factor, ampdu_density);
5942 +- break;
5943 ++ return IEEE80211_AMPDU_TX_START_IMMEDIATE;
5944 ++ case IEEE80211_AMPDU_TX_STOP_CONT:
5945 + case IEEE80211_AMPDU_TX_STOP_FLUSH:
5946 +- dev_dbg(dev, "%s: IEEE80211_AMPDU_TX_STOP_FLUSH\n", __func__);
5947 +- rtl8xxxu_set_ampdu_factor(priv, 0);
5948 +- rtl8xxxu_set_ampdu_min_space(priv, 0);
5949 +- break;
5950 + case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
5951 +- dev_dbg(dev, "%s: IEEE80211_AMPDU_TX_STOP_FLUSH_CONT\n",
5952 +- __func__);
5953 ++ dev_dbg(dev, "%s: IEEE80211_AMPDU_TX_STOP\n", __func__);
5954 + rtl8xxxu_set_ampdu_factor(priv, 0);
5955 + rtl8xxxu_set_ampdu_min_space(priv, 0);
5956 ++ clear_bit(tid, priv->tx_aggr_started);
5957 ++ clear_bit(tid, priv->tid_tx_operational);
5958 ++ ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
5959 ++ break;
5960 ++ case IEEE80211_AMPDU_TX_OPERATIONAL:
5961 ++ dev_dbg(dev, "%s: IEEE80211_AMPDU_TX_OPERATIONAL\n", __func__);
5962 ++ set_bit(tid, priv->tid_tx_operational);
5963 + break;
5964 + case IEEE80211_AMPDU_RX_START:
5965 + dev_dbg(dev, "%s: IEEE80211_AMPDU_RX_START\n", __func__);
5966 +diff --git a/drivers/net/wireless/realtek/rtw88/Makefile b/drivers/net/wireless/realtek/rtw88/Makefile
5967 +index c0e4b111c8b4e..73d6807a8cdfb 100644
5968 +--- a/drivers/net/wireless/realtek/rtw88/Makefile
5969 ++++ b/drivers/net/wireless/realtek/rtw88/Makefile
5970 +@@ -15,9 +15,9 @@ rtw88_core-y += main.o \
5971 + ps.o \
5972 + sec.o \
5973 + bf.o \
5974 +- wow.o \
5975 + regd.o
5976 +
5977 ++rtw88_core-$(CONFIG_PM) += wow.o
5978 +
5979 + obj-$(CONFIG_RTW88_8822B) += rtw88_8822b.o
5980 + rtw88_8822b-objs := rtw8822b.o rtw8822b_table.o
5981 +diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
5982 +index b2fd87834f23d..0452630bcfacc 100644
5983 +--- a/drivers/net/wireless/realtek/rtw88/fw.c
5984 ++++ b/drivers/net/wireless/realtek/rtw88/fw.c
5985 +@@ -684,7 +684,7 @@ static u16 rtw_get_rsvd_page_probe_req_size(struct rtw_dev *rtwdev,
5986 + continue;
5987 + if ((!ssid && !rsvd_pkt->ssid) ||
5988 + rtw_ssid_equal(rsvd_pkt->ssid, ssid))
5989 +- size = rsvd_pkt->skb->len;
5990 ++ size = rsvd_pkt->probe_req_size;
5991 + }
5992 +
5993 + return size;
5994 +@@ -912,6 +912,8 @@ static struct sk_buff *rtw_get_rsvd_page_skb(struct ieee80211_hw *hw,
5995 + ssid->ssid_len, 0);
5996 + else
5997 + skb_new = ieee80211_probereq_get(hw, vif->addr, NULL, 0, 0);
5998 ++ if (skb_new)
5999 ++ rsvd_pkt->probe_req_size = (u16)skb_new->len;
6000 + break;
6001 + case RSVD_NLO_INFO:
6002 + skb_new = rtw_nlo_info_get(hw);
6003 +@@ -1508,6 +1510,7 @@ int rtw_fw_dump_fifo(struct rtw_dev *rtwdev, u8 fifo_sel, u32 addr, u32 size,
6004 + static void __rtw_fw_update_pkt(struct rtw_dev *rtwdev, u8 pkt_id, u16 size,
6005 + u8 location)
6006 + {
6007 ++ struct rtw_chip_info *chip = rtwdev->chip;
6008 + u8 h2c_pkt[H2C_PKT_SIZE] = {0};
6009 + u16 total_size = H2C_PKT_HDR_SIZE + H2C_PKT_UPDATE_PKT_LEN;
6010 +
6011 +@@ -1518,6 +1521,7 @@ static void __rtw_fw_update_pkt(struct rtw_dev *rtwdev, u8 pkt_id, u16 size,
6012 + UPDATE_PKT_SET_LOCATION(h2c_pkt, location);
6013 +
6014 + /* include txdesc size */
6015 ++ size += chip->tx_pkt_desc_sz;
6016 + UPDATE_PKT_SET_SIZE(h2c_pkt, size);
6017 +
6018 + rtw_fw_send_h2c_packet(rtwdev, h2c_pkt);
6019 +@@ -1527,7 +1531,7 @@ void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev,
6020 + struct cfg80211_ssid *ssid)
6021 + {
6022 + u8 loc;
6023 +- u32 size;
6024 ++ u16 size;
6025 +
6026 + loc = rtw_get_rsvd_page_probe_req_location(rtwdev, ssid);
6027 + if (!loc) {
6028 +diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h
6029 +index 08644540d2595..f4aed247e3bdb 100644
6030 +--- a/drivers/net/wireless/realtek/rtw88/fw.h
6031 ++++ b/drivers/net/wireless/realtek/rtw88/fw.h
6032 +@@ -117,6 +117,7 @@ struct rtw_rsvd_page {
6033 + u8 page;
6034 + bool add_txdesc;
6035 + struct cfg80211_ssid *ssid;
6036 ++ u16 probe_req_size;
6037 + };
6038 +
6039 + enum rtw_keep_alive_pkt_type {
6040 +diff --git a/drivers/net/wireless/realtek/rtw88/wow.c b/drivers/net/wireless/realtek/rtw88/wow.c
6041 +index 2fcdf70a3a77e..bb2fd4e544f00 100644
6042 +--- a/drivers/net/wireless/realtek/rtw88/wow.c
6043 ++++ b/drivers/net/wireless/realtek/rtw88/wow.c
6044 +@@ -283,15 +283,26 @@ static void rtw_wow_rx_dma_start(struct rtw_dev *rtwdev)
6045 +
6046 + static int rtw_wow_check_fw_status(struct rtw_dev *rtwdev, bool wow_enable)
6047 + {
6048 +- /* wait 100ms for wow firmware to finish work */
6049 +- msleep(100);
6050 ++ int ret;
6051 ++ u8 check;
6052 ++ u32 check_dis;
6053 +
6054 + if (wow_enable) {
6055 +- if (rtw_read8(rtwdev, REG_WOWLAN_WAKE_REASON))
6056 ++ ret = read_poll_timeout(rtw_read8, check, !check, 1000,
6057 ++ 100000, true, rtwdev,
6058 ++ REG_WOWLAN_WAKE_REASON);
6059 ++ if (ret)
6060 + goto wow_fail;
6061 + } else {
6062 +- if (rtw_read32_mask(rtwdev, REG_FE1IMR, BIT_FS_RXDONE) ||
6063 +- rtw_read32_mask(rtwdev, REG_RXPKT_NUM, BIT_RW_RELEASE))
6064 ++ ret = read_poll_timeout(rtw_read32_mask, check_dis,
6065 ++ !check_dis, 1000, 100000, true, rtwdev,
6066 ++ REG_FE1IMR, BIT_FS_RXDONE);
6067 ++ if (ret)
6068 ++ goto wow_fail;
6069 ++ ret = read_poll_timeout(rtw_read32_mask, check_dis,
6070 ++ !check_dis, 1000, 100000, false, rtwdev,
6071 ++ REG_RXPKT_NUM, BIT_RW_RELEASE);
6072 ++ if (ret)
6073 + goto wow_fail;
6074 + }
6075 +
6076 +diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
6077 +index 875076b0ea6c1..d5dd79b59b16c 100644
6078 +--- a/drivers/nvdimm/pmem.c
6079 ++++ b/drivers/nvdimm/pmem.c
6080 +@@ -448,11 +448,11 @@ static int pmem_attach_disk(struct device *dev,
6081 + pmem->pfn_flags |= PFN_MAP;
6082 + bb_range = pmem->pgmap.range;
6083 + } else {
6084 ++ addr = devm_memremap(dev, pmem->phys_addr,
6085 ++ pmem->size, ARCH_MEMREMAP_PMEM);
6086 + if (devm_add_action_or_reset(dev, pmem_release_queue,
6087 + &pmem->pgmap))
6088 + return -ENOMEM;
6089 +- addr = devm_memremap(dev, pmem->phys_addr,
6090 +- pmem->size, ARCH_MEMREMAP_PMEM);
6091 + bb_range.start = res->start;
6092 + bb_range.end = res->end;
6093 + }
6094 +diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
6095 +index ff5a16b17133d..5a9b2f1b1418a 100644
6096 +--- a/drivers/nvme/host/core.c
6097 ++++ b/drivers/nvme/host/core.c
6098 +@@ -878,7 +878,8 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
6099 + return BLK_STS_IOERR;
6100 + }
6101 +
6102 +- cmd->common.command_id = req->tag;
6103 ++ nvme_req(req)->genctr++;
6104 ++ cmd->common.command_id = nvme_cid(req);
6105 + trace_nvme_setup_cmd(req, cmd);
6106 + return ret;
6107 + }
6108 +diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
6109 +index 3cb3c82061d7e..8c735c55c15bf 100644
6110 +--- a/drivers/nvme/host/nvme.h
6111 ++++ b/drivers/nvme/host/nvme.h
6112 +@@ -153,6 +153,7 @@ enum nvme_quirks {
6113 + struct nvme_request {
6114 + struct nvme_command *cmd;
6115 + union nvme_result result;
6116 ++ u8 genctr;
6117 + u8 retries;
6118 + u8 flags;
6119 + u16 status;
6120 +@@ -469,6 +470,49 @@ struct nvme_ctrl_ops {
6121 + int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);
6122 + };
6123 +
6124 ++/*
6125 ++ * nvme command_id is constructed as such:
6126 ++ * | xxxx | xxxxxxxxxxxx |
6127 ++ * gen request tag
6128 ++ */
6129 ++#define nvme_genctr_mask(gen) (gen & 0xf)
6130 ++#define nvme_cid_install_genctr(gen) (nvme_genctr_mask(gen) << 12)
6131 ++#define nvme_genctr_from_cid(cid) ((cid & 0xf000) >> 12)
6132 ++#define nvme_tag_from_cid(cid) (cid & 0xfff)
6133 ++
6134 ++static inline u16 nvme_cid(struct request *rq)
6135 ++{
6136 ++ return nvme_cid_install_genctr(nvme_req(rq)->genctr) | rq->tag;
6137 ++}
6138 ++
6139 ++static inline struct request *nvme_find_rq(struct blk_mq_tags *tags,
6140 ++ u16 command_id)
6141 ++{
6142 ++ u8 genctr = nvme_genctr_from_cid(command_id);
6143 ++ u16 tag = nvme_tag_from_cid(command_id);
6144 ++ struct request *rq;
6145 ++
6146 ++ rq = blk_mq_tag_to_rq(tags, tag);
6147 ++ if (unlikely(!rq)) {
6148 ++ pr_err("could not locate request for tag %#x\n",
6149 ++ tag);
6150 ++ return NULL;
6151 ++ }
6152 ++ if (unlikely(nvme_genctr_mask(nvme_req(rq)->genctr) != genctr)) {
6153 ++ dev_err(nvme_req(rq)->ctrl->device,
6154 ++ "request %#x genctr mismatch (got %#x expected %#x)\n",
6155 ++ tag, genctr, nvme_genctr_mask(nvme_req(rq)->genctr));
6156 ++ return NULL;
6157 ++ }
6158 ++ return rq;
6159 ++}
6160 ++
6161 ++static inline struct request *nvme_cid_to_rq(struct blk_mq_tags *tags,
6162 ++ u16 command_id)
6163 ++{
6164 ++ return blk_mq_tag_to_rq(tags, nvme_tag_from_cid(command_id));
6165 ++}
6166 ++
6167 + #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
6168 + void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj,
6169 + const char *dev_name);
6170 +@@ -566,7 +610,8 @@ static inline void nvme_put_ctrl(struct nvme_ctrl *ctrl)
6171 +
6172 + static inline bool nvme_is_aen_req(u16 qid, __u16 command_id)
6173 + {
6174 +- return !qid && command_id >= NVME_AQ_BLK_MQ_DEPTH;
6175 ++ return !qid &&
6176 ++ nvme_tag_from_cid(command_id) >= NVME_AQ_BLK_MQ_DEPTH;
6177 + }
6178 +
6179 + void nvme_complete_rq(struct request *req);
6180 +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
6181 +index fb48a88d1acb5..09767a805492c 100644
6182 +--- a/drivers/nvme/host/pci.c
6183 ++++ b/drivers/nvme/host/pci.c
6184 +@@ -1012,7 +1012,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)
6185 + return;
6186 + }
6187 +
6188 +- req = blk_mq_tag_to_rq(nvme_queue_tagset(nvmeq), command_id);
6189 ++ req = nvme_find_rq(nvme_queue_tagset(nvmeq), command_id);
6190 + if (unlikely(!req)) {
6191 + dev_warn(nvmeq->dev->ctrl.device,
6192 + "invalid id %d completed on queue %d\n",
6193 +diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
6194 +index c6c2e2361b2fe..9c356be7f016e 100644
6195 +--- a/drivers/nvme/host/rdma.c
6196 ++++ b/drivers/nvme/host/rdma.c
6197 +@@ -1738,10 +1738,10 @@ static void nvme_rdma_process_nvme_rsp(struct nvme_rdma_queue *queue,
6198 + struct request *rq;
6199 + struct nvme_rdma_request *req;
6200 +
6201 +- rq = blk_mq_tag_to_rq(nvme_rdma_tagset(queue), cqe->command_id);
6202 ++ rq = nvme_find_rq(nvme_rdma_tagset(queue), cqe->command_id);
6203 + if (!rq) {
6204 + dev_err(queue->ctrl->ctrl.device,
6205 +- "tag 0x%x on QP %#x not found\n",
6206 ++ "got bad command_id %#x on QP %#x\n",
6207 + cqe->command_id, queue->qp->qp_num);
6208 + nvme_rdma_error_recovery(queue->ctrl);
6209 + return;
6210 +diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
6211 +index 5b11d8a23813f..c9a925999c6ea 100644
6212 +--- a/drivers/nvme/host/tcp.c
6213 ++++ b/drivers/nvme/host/tcp.c
6214 +@@ -484,11 +484,11 @@ static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue,
6215 + {
6216 + struct request *rq;
6217 +
6218 +- rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue), cqe->command_id);
6219 ++ rq = nvme_find_rq(nvme_tcp_tagset(queue), cqe->command_id);
6220 + if (!rq) {
6221 + dev_err(queue->ctrl->ctrl.device,
6222 +- "queue %d tag 0x%x not found\n",
6223 +- nvme_tcp_queue_id(queue), cqe->command_id);
6224 ++ "got bad cqe.command_id %#x on queue %d\n",
6225 ++ cqe->command_id, nvme_tcp_queue_id(queue));
6226 + nvme_tcp_error_recovery(&queue->ctrl->ctrl);
6227 + return -EINVAL;
6228 + }
6229 +@@ -505,11 +505,11 @@ static int nvme_tcp_handle_c2h_data(struct nvme_tcp_queue *queue,
6230 + {
6231 + struct request *rq;
6232 +
6233 +- rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue), pdu->command_id);
6234 ++ rq = nvme_find_rq(nvme_tcp_tagset(queue), pdu->command_id);
6235 + if (!rq) {
6236 + dev_err(queue->ctrl->ctrl.device,
6237 +- "queue %d tag %#x not found\n",
6238 +- nvme_tcp_queue_id(queue), pdu->command_id);
6239 ++ "got bad c2hdata.command_id %#x on queue %d\n",
6240 ++ pdu->command_id, nvme_tcp_queue_id(queue));
6241 + return -ENOENT;
6242 + }
6243 +
6244 +@@ -603,7 +603,7 @@ static int nvme_tcp_setup_h2c_data_pdu(struct nvme_tcp_request *req,
6245 + data->hdr.plen =
6246 + cpu_to_le32(data->hdr.hlen + hdgst + req->pdu_len + ddgst);
6247 + data->ttag = pdu->ttag;
6248 +- data->command_id = rq->tag;
6249 ++ data->command_id = nvme_cid(rq);
6250 + data->data_offset = cpu_to_le32(req->data_sent);
6251 + data->data_length = cpu_to_le32(req->pdu_len);
6252 + return 0;
6253 +@@ -616,11 +616,11 @@ static int nvme_tcp_handle_r2t(struct nvme_tcp_queue *queue,
6254 + struct request *rq;
6255 + int ret;
6256 +
6257 +- rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue), pdu->command_id);
6258 ++ rq = nvme_find_rq(nvme_tcp_tagset(queue), pdu->command_id);
6259 + if (!rq) {
6260 + dev_err(queue->ctrl->ctrl.device,
6261 +- "queue %d tag %#x not found\n",
6262 +- nvme_tcp_queue_id(queue), pdu->command_id);
6263 ++ "got bad r2t.command_id %#x on queue %d\n",
6264 ++ pdu->command_id, nvme_tcp_queue_id(queue));
6265 + return -ENOENT;
6266 + }
6267 + req = blk_mq_rq_to_pdu(rq);
6268 +@@ -699,17 +699,9 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
6269 + unsigned int *offset, size_t *len)
6270 + {
6271 + struct nvme_tcp_data_pdu *pdu = (void *)queue->pdu;
6272 +- struct nvme_tcp_request *req;
6273 +- struct request *rq;
6274 +-
6275 +- rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue), pdu->command_id);
6276 +- if (!rq) {
6277 +- dev_err(queue->ctrl->ctrl.device,
6278 +- "queue %d tag %#x not found\n",
6279 +- nvme_tcp_queue_id(queue), pdu->command_id);
6280 +- return -ENOENT;
6281 +- }
6282 +- req = blk_mq_rq_to_pdu(rq);
6283 ++ struct request *rq =
6284 ++ nvme_cid_to_rq(nvme_tcp_tagset(queue), pdu->command_id);
6285 ++ struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq);
6286 +
6287 + while (true) {
6288 + int recv_len, ret;
6289 +@@ -801,8 +793,8 @@ static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue,
6290 + }
6291 +
6292 + if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS) {
6293 +- struct request *rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue),
6294 +- pdu->command_id);
6295 ++ struct request *rq = nvme_cid_to_rq(nvme_tcp_tagset(queue),
6296 ++ pdu->command_id);
6297 +
6298 + nvme_tcp_end_request(rq, NVME_SC_SUCCESS);
6299 + queue->nr_cqe++;
6300 +diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
6301 +index 16d71cc5a50eb..ff3258c3eb8b6 100644
6302 +--- a/drivers/nvme/target/loop.c
6303 ++++ b/drivers/nvme/target/loop.c
6304 +@@ -107,10 +107,10 @@ static void nvme_loop_queue_response(struct nvmet_req *req)
6305 + } else {
6306 + struct request *rq;
6307 +
6308 +- rq = blk_mq_tag_to_rq(nvme_loop_tagset(queue), cqe->command_id);
6309 ++ rq = nvme_find_rq(nvme_loop_tagset(queue), cqe->command_id);
6310 + if (!rq) {
6311 + dev_err(queue->ctrl->ctrl.device,
6312 +- "tag 0x%x on queue %d not found\n",
6313 ++ "got bad command_id %#x on queue %d\n",
6314 + cqe->command_id, nvme_loop_queue_idx(queue));
6315 + return;
6316 + }
6317 +diff --git a/drivers/nvmem/qfprom.c b/drivers/nvmem/qfprom.c
6318 +index 955b8b8c82386..8ef772ccfb367 100644
6319 +--- a/drivers/nvmem/qfprom.c
6320 ++++ b/drivers/nvmem/qfprom.c
6321 +@@ -104,6 +104,9 @@ static void qfprom_disable_fuse_blowing(const struct qfprom_priv *priv,
6322 + {
6323 + int ret;
6324 +
6325 ++ writel(old->timer_val, priv->qfpconf + QFPROM_BLOW_TIMER_OFFSET);
6326 ++ writel(old->accel_val, priv->qfpconf + QFPROM_ACCEL_OFFSET);
6327 ++
6328 + /*
6329 + * This may be a shared rail and may be able to run at a lower rate
6330 + * when we're not blowing fuses. At the moment, the regulator framework
6331 +@@ -124,9 +127,6 @@ static void qfprom_disable_fuse_blowing(const struct qfprom_priv *priv,
6332 + "Failed to set clock rate for disable (ignoring)\n");
6333 +
6334 + clk_disable_unprepare(priv->secclk);
6335 +-
6336 +- writel(old->timer_val, priv->qfpconf + QFPROM_BLOW_TIMER_OFFSET);
6337 +- writel(old->accel_val, priv->qfpconf + QFPROM_ACCEL_OFFSET);
6338 + }
6339 +
6340 + /**
6341 +diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c
6342 +index a32e60b024b8d..6675b5e56960c 100644
6343 +--- a/drivers/of/kobj.c
6344 ++++ b/drivers/of/kobj.c
6345 +@@ -119,7 +119,7 @@ int __of_attach_node_sysfs(struct device_node *np)
6346 + struct property *pp;
6347 + int rc;
6348 +
6349 +- if (!of_kset)
6350 ++ if (!IS_ENABLED(CONFIG_SYSFS) || !of_kset)
6351 + return 0;
6352 +
6353 + np->kobj.kset = of_kset;
6354 +diff --git a/drivers/opp/of.c b/drivers/opp/of.c
6355 +index d92a1bfe16905..f83f4f6d70349 100644
6356 +--- a/drivers/opp/of.c
6357 ++++ b/drivers/opp/of.c
6358 +@@ -95,15 +95,7 @@ static struct dev_pm_opp *_find_opp_of_np(struct opp_table *opp_table,
6359 + static struct device_node *of_parse_required_opp(struct device_node *np,
6360 + int index)
6361 + {
6362 +- struct device_node *required_np;
6363 +-
6364 +- required_np = of_parse_phandle(np, "required-opps", index);
6365 +- if (unlikely(!required_np)) {
6366 +- pr_err("%s: Unable to parse required-opps: %pOF, index: %d\n",
6367 +- __func__, np, index);
6368 +- }
6369 +-
6370 +- return required_np;
6371 ++ return of_parse_phandle(np, "required-opps", index);
6372 + }
6373 +
6374 + /* The caller must call dev_pm_opp_put_opp_table() after the table is used */
6375 +@@ -1193,7 +1185,7 @@ int of_get_required_opp_performance_state(struct device_node *np, int index)
6376 +
6377 + required_np = of_parse_required_opp(np, index);
6378 + if (!required_np)
6379 +- return -EINVAL;
6380 ++ return -ENODEV;
6381 +
6382 + opp_table = _find_table_of_opp_np(required_np);
6383 + if (IS_ERR(opp_table)) {
6384 +diff --git a/drivers/parport/ieee1284_ops.c b/drivers/parport/ieee1284_ops.c
6385 +index 2c11bd3fe1fd6..17061f1df0f44 100644
6386 +--- a/drivers/parport/ieee1284_ops.c
6387 ++++ b/drivers/parport/ieee1284_ops.c
6388 +@@ -518,7 +518,7 @@ size_t parport_ieee1284_ecp_read_data (struct parport *port,
6389 + goto out;
6390 +
6391 + /* Yield the port for a while. */
6392 +- if (count && dev->port->irq != PARPORT_IRQ_NONE) {
6393 ++ if (dev->port->irq != PARPORT_IRQ_NONE) {
6394 + parport_release (dev);
6395 + schedule_timeout_interruptible(msecs_to_jiffies(40));
6396 + parport_claim_or_block (dev);
6397 +diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
6398 +index b1b41b61e0bd0..88e19ad54f646 100644
6399 +--- a/drivers/pci/controller/pci-aardvark.c
6400 ++++ b/drivers/pci/controller/pci-aardvark.c
6401 +@@ -57,6 +57,7 @@
6402 + #define PIO_COMPLETION_STATUS_CRS 2
6403 + #define PIO_COMPLETION_STATUS_CA 4
6404 + #define PIO_NON_POSTED_REQ BIT(10)
6405 ++#define PIO_ERR_STATUS BIT(11)
6406 + #define PIO_ADDR_LS (PIO_BASE_ADDR + 0x8)
6407 + #define PIO_ADDR_MS (PIO_BASE_ADDR + 0xc)
6408 + #define PIO_WR_DATA (PIO_BASE_ADDR + 0x10)
6409 +@@ -117,6 +118,46 @@
6410 + #define PCIE_MSI_MASK_REG (CONTROL_BASE_ADDR + 0x5C)
6411 + #define PCIE_MSI_PAYLOAD_REG (CONTROL_BASE_ADDR + 0x9C)
6412 +
6413 ++/* PCIe window configuration */
6414 ++#define OB_WIN_BASE_ADDR 0x4c00
6415 ++#define OB_WIN_BLOCK_SIZE 0x20
6416 ++#define OB_WIN_COUNT 8
6417 ++#define OB_WIN_REG_ADDR(win, offset) (OB_WIN_BASE_ADDR + \
6418 ++ OB_WIN_BLOCK_SIZE * (win) + \
6419 ++ (offset))
6420 ++#define OB_WIN_MATCH_LS(win) OB_WIN_REG_ADDR(win, 0x00)
6421 ++#define OB_WIN_ENABLE BIT(0)
6422 ++#define OB_WIN_MATCH_MS(win) OB_WIN_REG_ADDR(win, 0x04)
6423 ++#define OB_WIN_REMAP_LS(win) OB_WIN_REG_ADDR(win, 0x08)
6424 ++#define OB_WIN_REMAP_MS(win) OB_WIN_REG_ADDR(win, 0x0c)
6425 ++#define OB_WIN_MASK_LS(win) OB_WIN_REG_ADDR(win, 0x10)
6426 ++#define OB_WIN_MASK_MS(win) OB_WIN_REG_ADDR(win, 0x14)
6427 ++#define OB_WIN_ACTIONS(win) OB_WIN_REG_ADDR(win, 0x18)
6428 ++#define OB_WIN_DEFAULT_ACTIONS (OB_WIN_ACTIONS(OB_WIN_COUNT-1) + 0x4)
6429 ++#define OB_WIN_FUNC_NUM_MASK GENMASK(31, 24)
6430 ++#define OB_WIN_FUNC_NUM_SHIFT 24
6431 ++#define OB_WIN_FUNC_NUM_ENABLE BIT(23)
6432 ++#define OB_WIN_BUS_NUM_BITS_MASK GENMASK(22, 20)
6433 ++#define OB_WIN_BUS_NUM_BITS_SHIFT 20
6434 ++#define OB_WIN_MSG_CODE_ENABLE BIT(22)
6435 ++#define OB_WIN_MSG_CODE_MASK GENMASK(21, 14)
6436 ++#define OB_WIN_MSG_CODE_SHIFT 14
6437 ++#define OB_WIN_MSG_PAYLOAD_LEN BIT(12)
6438 ++#define OB_WIN_ATTR_ENABLE BIT(11)
6439 ++#define OB_WIN_ATTR_TC_MASK GENMASK(10, 8)
6440 ++#define OB_WIN_ATTR_TC_SHIFT 8
6441 ++#define OB_WIN_ATTR_RELAXED BIT(7)
6442 ++#define OB_WIN_ATTR_NOSNOOP BIT(6)
6443 ++#define OB_WIN_ATTR_POISON BIT(5)
6444 ++#define OB_WIN_ATTR_IDO BIT(4)
6445 ++#define OB_WIN_TYPE_MASK GENMASK(3, 0)
6446 ++#define OB_WIN_TYPE_SHIFT 0
6447 ++#define OB_WIN_TYPE_MEM 0x0
6448 ++#define OB_WIN_TYPE_IO 0x4
6449 ++#define OB_WIN_TYPE_CONFIG_TYPE0 0x8
6450 ++#define OB_WIN_TYPE_CONFIG_TYPE1 0x9
6451 ++#define OB_WIN_TYPE_MSG 0xc
6452 ++
6453 + /* LMI registers base address and register offsets */
6454 + #define LMI_BASE_ADDR 0x6000
6455 + #define CFG_REG (LMI_BASE_ADDR + 0x0)
6456 +@@ -187,8 +228,16 @@
6457 + struct advk_pcie {
6458 + struct platform_device *pdev;
6459 + void __iomem *base;
6460 ++ struct {
6461 ++ phys_addr_t match;
6462 ++ phys_addr_t remap;
6463 ++ phys_addr_t mask;
6464 ++ u32 actions;
6465 ++ } wins[OB_WIN_COUNT];
6466 ++ u8 wins_count;
6467 + struct irq_domain *irq_domain;
6468 + struct irq_chip irq_chip;
6469 ++ raw_spinlock_t irq_lock;
6470 + struct irq_domain *msi_domain;
6471 + struct irq_domain *msi_inner_domain;
6472 + struct irq_chip msi_bottom_irq_chip;
6473 +@@ -366,9 +415,39 @@ err:
6474 + dev_err(dev, "link never came up\n");
6475 + }
6476 +
6477 ++/*
6478 ++ * Set PCIe address window register which could be used for memory
6479 ++ * mapping.
6480 ++ */
6481 ++static void advk_pcie_set_ob_win(struct advk_pcie *pcie, u8 win_num,
6482 ++ phys_addr_t match, phys_addr_t remap,
6483 ++ phys_addr_t mask, u32 actions)
6484 ++{
6485 ++ advk_writel(pcie, OB_WIN_ENABLE |
6486 ++ lower_32_bits(match), OB_WIN_MATCH_LS(win_num));
6487 ++ advk_writel(pcie, upper_32_bits(match), OB_WIN_MATCH_MS(win_num));
6488 ++ advk_writel(pcie, lower_32_bits(remap), OB_WIN_REMAP_LS(win_num));
6489 ++ advk_writel(pcie, upper_32_bits(remap), OB_WIN_REMAP_MS(win_num));
6490 ++ advk_writel(pcie, lower_32_bits(mask), OB_WIN_MASK_LS(win_num));
6491 ++ advk_writel(pcie, upper_32_bits(mask), OB_WIN_MASK_MS(win_num));
6492 ++ advk_writel(pcie, actions, OB_WIN_ACTIONS(win_num));
6493 ++}
6494 ++
6495 ++static void advk_pcie_disable_ob_win(struct advk_pcie *pcie, u8 win_num)
6496 ++{
6497 ++ advk_writel(pcie, 0, OB_WIN_MATCH_LS(win_num));
6498 ++ advk_writel(pcie, 0, OB_WIN_MATCH_MS(win_num));
6499 ++ advk_writel(pcie, 0, OB_WIN_REMAP_LS(win_num));
6500 ++ advk_writel(pcie, 0, OB_WIN_REMAP_MS(win_num));
6501 ++ advk_writel(pcie, 0, OB_WIN_MASK_LS(win_num));
6502 ++ advk_writel(pcie, 0, OB_WIN_MASK_MS(win_num));
6503 ++ advk_writel(pcie, 0, OB_WIN_ACTIONS(win_num));
6504 ++}
6505 ++
6506 + static void advk_pcie_setup_hw(struct advk_pcie *pcie)
6507 + {
6508 + u32 reg;
6509 ++ int i;
6510 +
6511 + /* Enable TX */
6512 + reg = advk_readl(pcie, PCIE_CORE_REF_CLK_REG);
6513 +@@ -447,15 +526,51 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)
6514 + reg = PCIE_IRQ_ALL_MASK & (~PCIE_IRQ_ENABLE_INTS_MASK);
6515 + advk_writel(pcie, reg, HOST_CTRL_INT_MASK_REG);
6516 +
6517 ++ /*
6518 ++ * Enable AXI address window location generation:
6519 ++ * When it is enabled, the default outbound window
6520 ++ * configurations (Default User Field: 0xD0074CFC)
6521 ++ * are used to transparent address translation for
6522 ++ * the outbound transactions. Thus, PCIe address
6523 ++ * windows are not required for transparent memory
6524 ++ * access when default outbound window configuration
6525 ++ * is set for memory access.
6526 ++ */
6527 + reg = advk_readl(pcie, PCIE_CORE_CTRL2_REG);
6528 + reg |= PCIE_CORE_CTRL2_OB_WIN_ENABLE;
6529 + advk_writel(pcie, reg, PCIE_CORE_CTRL2_REG);
6530 +
6531 +- /* Bypass the address window mapping for PIO */
6532 ++ /*
6533 ++ * Set memory access in Default User Field so it
6534 ++ * is not required to configure PCIe address for
6535 ++ * transparent memory access.
6536 ++ */
6537 ++ advk_writel(pcie, OB_WIN_TYPE_MEM, OB_WIN_DEFAULT_ACTIONS);
6538 ++
6539 ++ /*
6540 ++ * Bypass the address window mapping for PIO:
6541 ++ * Since PIO access already contains all required
6542 ++ * info over AXI interface by PIO registers, the
6543 ++ * address window is not required.
6544 ++ */
6545 + reg = advk_readl(pcie, PIO_CTRL);
6546 + reg |= PIO_CTRL_ADDR_WIN_DISABLE;
6547 + advk_writel(pcie, reg, PIO_CTRL);
6548 +
6549 ++ /*
6550 ++ * Configure PCIe address windows for non-memory or
6551 ++ * non-transparent access as by default PCIe uses
6552 ++ * transparent memory access.
6553 ++ */
6554 ++ for (i = 0; i < pcie->wins_count; i++)
6555 ++ advk_pcie_set_ob_win(pcie, i,
6556 ++ pcie->wins[i].match, pcie->wins[i].remap,
6557 ++ pcie->wins[i].mask, pcie->wins[i].actions);
6558 ++
6559 ++ /* Disable remaining PCIe outbound windows */
6560 ++ for (i = pcie->wins_count; i < OB_WIN_COUNT; i++)
6561 ++ advk_pcie_disable_ob_win(pcie, i);
6562 ++
6563 + advk_pcie_train_link(pcie);
6564 +
6565 + /*
6566 +@@ -472,7 +587,7 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)
6567 + advk_writel(pcie, reg, PCIE_CORE_CMD_STATUS_REG);
6568 + }
6569 +
6570 +-static void advk_pcie_check_pio_status(struct advk_pcie *pcie)
6571 ++static int advk_pcie_check_pio_status(struct advk_pcie *pcie, u32 *val)
6572 + {
6573 + struct device *dev = &pcie->pdev->dev;
6574 + u32 reg;
6575 +@@ -483,14 +598,49 @@ static void advk_pcie_check_pio_status(struct advk_pcie *pcie)
6576 + status = (reg & PIO_COMPLETION_STATUS_MASK) >>
6577 + PIO_COMPLETION_STATUS_SHIFT;
6578 +
6579 +- if (!status)
6580 +- return;
6581 +-
6582 ++ /*
6583 ++ * According to HW spec, the PIO status check sequence as below:
6584 ++ * 1) even if COMPLETION_STATUS(bit9:7) indicates successful,
6585 ++ * it still needs to check Error Status(bit11), only when this bit
6586 ++ * indicates no error happen, the operation is successful.
6587 ++ * 2) value Unsupported Request(1) of COMPLETION_STATUS(bit9:7) only
6588 ++ * means a PIO write error, and for PIO read it is successful with
6589 ++ * a read value of 0xFFFFFFFF.
6590 ++ * 3) value Completion Retry Status(CRS) of COMPLETION_STATUS(bit9:7)
6591 ++ * only means a PIO write error, and for PIO read it is successful
6592 ++ * with a read value of 0xFFFF0001.
6593 ++ * 4) value Completer Abort (CA) of COMPLETION_STATUS(bit9:7) means
6594 ++ * error for both PIO read and PIO write operation.
6595 ++ * 5) other errors are indicated as 'unknown'.
6596 ++ */
6597 + switch (status) {
6598 ++ case PIO_COMPLETION_STATUS_OK:
6599 ++ if (reg & PIO_ERR_STATUS) {
6600 ++ strcomp_status = "COMP_ERR";
6601 ++ break;
6602 ++ }
6603 ++ /* Get the read result */
6604 ++ if (val)
6605 ++ *val = advk_readl(pcie, PIO_RD_DATA);
6606 ++ /* No error */
6607 ++ strcomp_status = NULL;
6608 ++ break;
6609 + case PIO_COMPLETION_STATUS_UR:
6610 + strcomp_status = "UR";
6611 + break;
6612 + case PIO_COMPLETION_STATUS_CRS:
6613 ++ /* PCIe r4.0, sec 2.3.2, says:
6614 ++ * If CRS Software Visibility is not enabled, the Root Complex
6615 ++ * must re-issue the Configuration Request as a new Request.
6616 ++ * A Root Complex implementation may choose to limit the number
6617 ++ * of Configuration Request/CRS Completion Status loops before
6618 ++ * determining that something is wrong with the target of the
6619 ++ * Request and taking appropriate action, e.g., complete the
6620 ++ * Request to the host as a failed transaction.
6621 ++ *
6622 ++ * To simplify implementation do not re-issue the Configuration
6623 ++ * Request and complete the Request as a failed transaction.
6624 ++ */
6625 + strcomp_status = "CRS";
6626 + break;
6627 + case PIO_COMPLETION_STATUS_CA:
6628 +@@ -501,6 +651,9 @@ static void advk_pcie_check_pio_status(struct advk_pcie *pcie)
6629 + break;
6630 + }
6631 +
6632 ++ if (!strcomp_status)
6633 ++ return 0;
6634 ++
6635 + if (reg & PIO_NON_POSTED_REQ)
6636 + str_posted = "Non-posted";
6637 + else
6638 +@@ -508,6 +661,8 @@ static void advk_pcie_check_pio_status(struct advk_pcie *pcie)
6639 +
6640 + dev_err(dev, "%s PIO Response Status: %s, %#x @ %#x\n",
6641 + str_posted, strcomp_status, reg, advk_readl(pcie, PIO_ADDR_LS));
6642 ++
6643 ++ return -EFAULT;
6644 + }
6645 +
6646 + static int advk_pcie_wait_pio(struct advk_pcie *pcie)
6647 +@@ -745,10 +900,13 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
6648 + return PCIBIOS_SET_FAILED;
6649 + }
6650 +
6651 +- advk_pcie_check_pio_status(pcie);
6652 ++ /* Check PIO status and get the read result */
6653 ++ ret = advk_pcie_check_pio_status(pcie, val);
6654 ++ if (ret < 0) {
6655 ++ *val = 0xffffffff;
6656 ++ return PCIBIOS_SET_FAILED;
6657 ++ }
6658 +
6659 +- /* Get the read result */
6660 +- *val = advk_readl(pcie, PIO_RD_DATA);
6661 + if (size == 1)
6662 + *val = (*val >> (8 * (where & 3))) & 0xff;
6663 + else if (size == 2)
6664 +@@ -812,7 +970,9 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
6665 + if (ret < 0)
6666 + return PCIBIOS_SET_FAILED;
6667 +
6668 +- advk_pcie_check_pio_status(pcie);
6669 ++ ret = advk_pcie_check_pio_status(pcie, NULL);
6670 ++ if (ret < 0)
6671 ++ return PCIBIOS_SET_FAILED;
6672 +
6673 + return PCIBIOS_SUCCESSFUL;
6674 + }
6675 +@@ -886,22 +1046,28 @@ static void advk_pcie_irq_mask(struct irq_data *d)
6676 + {
6677 + struct advk_pcie *pcie = d->domain->host_data;
6678 + irq_hw_number_t hwirq = irqd_to_hwirq(d);
6679 ++ unsigned long flags;
6680 + u32 mask;
6681 +
6682 ++ raw_spin_lock_irqsave(&pcie->irq_lock, flags);
6683 + mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
6684 + mask |= PCIE_ISR1_INTX_ASSERT(hwirq);
6685 + advk_writel(pcie, mask, PCIE_ISR1_MASK_REG);
6686 ++ raw_spin_unlock_irqrestore(&pcie->irq_lock, flags);
6687 + }
6688 +
6689 + static void advk_pcie_irq_unmask(struct irq_data *d)
6690 + {
6691 + struct advk_pcie *pcie = d->domain->host_data;
6692 + irq_hw_number_t hwirq = irqd_to_hwirq(d);
6693 ++ unsigned long flags;
6694 + u32 mask;
6695 +
6696 ++ raw_spin_lock_irqsave(&pcie->irq_lock, flags);
6697 + mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
6698 + mask &= ~PCIE_ISR1_INTX_ASSERT(hwirq);
6699 + advk_writel(pcie, mask, PCIE_ISR1_MASK_REG);
6700 ++ raw_spin_unlock_irqrestore(&pcie->irq_lock, flags);
6701 + }
6702 +
6703 + static int advk_pcie_irq_map(struct irq_domain *h,
6704 +@@ -985,6 +1151,8 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
6705 + struct irq_chip *irq_chip;
6706 + int ret = 0;
6707 +
6708 ++ raw_spin_lock_init(&pcie->irq_lock);
6709 ++
6710 + pcie_intc_node = of_get_next_child(node, NULL);
6711 + if (!pcie_intc_node) {
6712 + dev_err(dev, "No PCIe Intc node found\n");
6713 +@@ -1162,6 +1330,7 @@ static int advk_pcie_probe(struct platform_device *pdev)
6714 + struct device *dev = &pdev->dev;
6715 + struct advk_pcie *pcie;
6716 + struct pci_host_bridge *bridge;
6717 ++ struct resource_entry *entry;
6718 + int ret, irq;
6719 +
6720 + bridge = devm_pci_alloc_host_bridge(dev, sizeof(struct advk_pcie));
6721 +@@ -1172,6 +1341,80 @@ static int advk_pcie_probe(struct platform_device *pdev)
6722 + pcie->pdev = pdev;
6723 + platform_set_drvdata(pdev, pcie);
6724 +
6725 ++ resource_list_for_each_entry(entry, &bridge->windows) {
6726 ++ resource_size_t start = entry->res->start;
6727 ++ resource_size_t size = resource_size(entry->res);
6728 ++ unsigned long type = resource_type(entry->res);
6729 ++ u64 win_size;
6730 ++
6731 ++ /*
6732 ++ * Aardvark hardware allows to configure also PCIe window
6733 ++ * for config type 0 and type 1 mapping, but driver uses
6734 ++ * only PIO for issuing configuration transfers which does
6735 ++ * not use PCIe window configuration.
6736 ++ */
6737 ++ if (type != IORESOURCE_MEM && type != IORESOURCE_MEM_64 &&
6738 ++ type != IORESOURCE_IO)
6739 ++ continue;
6740 ++
6741 ++ /*
6742 ++ * Skip transparent memory resources. Default outbound access
6743 ++ * configuration is set to transparent memory access so it
6744 ++ * does not need window configuration.
6745 ++ */
6746 ++ if ((type == IORESOURCE_MEM || type == IORESOURCE_MEM_64) &&
6747 ++ entry->offset == 0)
6748 ++ continue;
6749 ++
6750 ++ /*
6751 ++ * The n-th PCIe window is configured by tuple (match, remap, mask)
6752 ++ * and an access to address A uses this window if A matches the
6753 ++ * match with given mask.
6754 ++ * So every PCIe window size must be a power of two and every start
6755 ++ * address must be aligned to window size. Minimal size is 64 KiB
6756 ++ * because lower 16 bits of mask must be zero. Remapped address
6757 ++ * may have set only bits from the mask.
6758 ++ */
6759 ++ while (pcie->wins_count < OB_WIN_COUNT && size > 0) {
6760 ++ /* Calculate the largest aligned window size */
6761 ++ win_size = (1ULL << (fls64(size)-1)) |
6762 ++ (start ? (1ULL << __ffs64(start)) : 0);
6763 ++ win_size = 1ULL << __ffs64(win_size);
6764 ++ if (win_size < 0x10000)
6765 ++ break;
6766 ++
6767 ++ dev_dbg(dev,
6768 ++ "Configuring PCIe window %d: [0x%llx-0x%llx] as %lu\n",
6769 ++ pcie->wins_count, (unsigned long long)start,
6770 ++ (unsigned long long)start + win_size, type);
6771 ++
6772 ++ if (type == IORESOURCE_IO) {
6773 ++ pcie->wins[pcie->wins_count].actions = OB_WIN_TYPE_IO;
6774 ++ pcie->wins[pcie->wins_count].match = pci_pio_to_address(start);
6775 ++ } else {
6776 ++ pcie->wins[pcie->wins_count].actions = OB_WIN_TYPE_MEM;
6777 ++ pcie->wins[pcie->wins_count].match = start;
6778 ++ }
6779 ++ pcie->wins[pcie->wins_count].remap = start - entry->offset;
6780 ++ pcie->wins[pcie->wins_count].mask = ~(win_size - 1);
6781 ++
6782 ++ if (pcie->wins[pcie->wins_count].remap & (win_size - 1))
6783 ++ break;
6784 ++
6785 ++ start += win_size;
6786 ++ size -= win_size;
6787 ++ pcie->wins_count++;
6788 ++ }
6789 ++
6790 ++ if (size > 0) {
6791 ++ dev_err(&pcie->pdev->dev,
6792 ++ "Invalid PCIe region [0x%llx-0x%llx]\n",
6793 ++ (unsigned long long)entry->res->start,
6794 ++ (unsigned long long)entry->res->end + 1);
6795 ++ return -EINVAL;
6796 ++ }
6797 ++ }
6798 ++
6799 + pcie->base = devm_platform_ioremap_resource(pdev, 0);
6800 + if (IS_ERR(pcie->base))
6801 + return PTR_ERR(pcie->base);
6802 +@@ -1252,6 +1495,7 @@ static int advk_pcie_remove(struct platform_device *pdev)
6803 + {
6804 + struct advk_pcie *pcie = platform_get_drvdata(pdev);
6805 + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
6806 ++ int i;
6807 +
6808 + pci_lock_rescan_remove();
6809 + pci_stop_root_bus(bridge->bus);
6810 +@@ -1261,6 +1505,10 @@ static int advk_pcie_remove(struct platform_device *pdev)
6811 + advk_pcie_remove_msi_irq_domain(pcie);
6812 + advk_pcie_remove_irq_domain(pcie);
6813 +
6814 ++ /* Disable outbound address windows mapping */
6815 ++ for (i = 0; i < OB_WIN_COUNT; i++)
6816 ++ advk_pcie_disable_ob_win(pcie, i);
6817 ++
6818 + return 0;
6819 + }
6820 +
6821 +diff --git a/drivers/pci/controller/pcie-xilinx-nwl.c b/drivers/pci/controller/pcie-xilinx-nwl.c
6822 +index f3cf7d61924f1..2a9fe7c3aef9f 100644
6823 +--- a/drivers/pci/controller/pcie-xilinx-nwl.c
6824 ++++ b/drivers/pci/controller/pcie-xilinx-nwl.c
6825 +@@ -6,6 +6,7 @@
6826 + * (C) Copyright 2014 - 2015, Xilinx, Inc.
6827 + */
6828 +
6829 ++#include <linux/clk.h>
6830 + #include <linux/delay.h>
6831 + #include <linux/interrupt.h>
6832 + #include <linux/irq.h>
6833 +@@ -168,6 +169,7 @@ struct nwl_pcie {
6834 + u8 last_busno;
6835 + struct nwl_msi msi;
6836 + struct irq_domain *legacy_irq_domain;
6837 ++ struct clk *clk;
6838 + raw_spinlock_t leg_mask_lock;
6839 + };
6840 +
6841 +@@ -825,6 +827,16 @@ static int nwl_pcie_probe(struct platform_device *pdev)
6842 + return err;
6843 + }
6844 +
6845 ++ pcie->clk = devm_clk_get(dev, NULL);
6846 ++ if (IS_ERR(pcie->clk))
6847 ++ return PTR_ERR(pcie->clk);
6848 ++
6849 ++ err = clk_prepare_enable(pcie->clk);
6850 ++ if (err) {
6851 ++ dev_err(dev, "can't enable PCIe ref clock\n");
6852 ++ return err;
6853 ++ }
6854 ++
6855 + err = nwl_pcie_bridge_init(pcie);
6856 + if (err) {
6857 + dev_err(dev, "HW Initialization failed\n");
6858 +diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
6859 +index 2548c64194ca9..a7a1c74113483 100644
6860 +--- a/drivers/pci/msi.c
6861 ++++ b/drivers/pci/msi.c
6862 +@@ -783,6 +783,9 @@ static void msix_mask_all(void __iomem *base, int tsize)
6863 + u32 ctrl = PCI_MSIX_ENTRY_CTRL_MASKBIT;
6864 + int i;
6865 +
6866 ++ if (pci_msi_ignore_mask)
6867 ++ return;
6868 ++
6869 + for (i = 0; i < tsize; i++, base += PCI_MSIX_ENTRY_SIZE)
6870 + writel(ctrl, base + PCI_MSIX_ENTRY_VECTOR_CTRL);
6871 + }
6872 +diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
6873 +index 29f5d699fa06d..eae6a9fdd33d4 100644
6874 +--- a/drivers/pci/pci.c
6875 ++++ b/drivers/pci/pci.c
6876 +@@ -1880,11 +1880,7 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
6877 + * so that things like MSI message writing will behave as expected
6878 + * (e.g. if the device really is in D0 at enable time).
6879 + */
6880 +- if (dev->pm_cap) {
6881 +- u16 pmcsr;
6882 +- pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
6883 +- dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
6884 +- }
6885 ++ pci_update_current_state(dev, dev->current_state);
6886 +
6887 + if (atomic_inc_return(&dev->enable_cnt) > 1)
6888 + return 0; /* already enabled */
6889 +@@ -4043,6 +4039,7 @@ phys_addr_t pci_pio_to_address(unsigned long pio)
6890 +
6891 + return address;
6892 + }
6893 ++EXPORT_SYMBOL_GPL(pci_pio_to_address);
6894 +
6895 + unsigned long __weak pci_address_to_pio(phys_addr_t address)
6896 + {
6897 +diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
6898 +index 50a9522ab07df..3779b264dbec3 100644
6899 +--- a/drivers/pci/pcie/portdrv_core.c
6900 ++++ b/drivers/pci/pcie/portdrv_core.c
6901 +@@ -260,8 +260,13 @@ static int get_port_device_capability(struct pci_dev *dev)
6902 + services |= PCIE_PORT_SERVICE_DPC;
6903 +
6904 + if (pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM ||
6905 +- pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
6906 +- services |= PCIE_PORT_SERVICE_BWNOTIF;
6907 ++ pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) {
6908 ++ u32 linkcap;
6909 ++
6910 ++ pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &linkcap);
6911 ++ if (linkcap & PCI_EXP_LNKCAP_LBNC)
6912 ++ services |= PCIE_PORT_SERVICE_BWNOTIF;
6913 ++ }
6914 +
6915 + return services;
6916 + }
6917 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
6918 +index a91c944961caa..bad294c352519 100644
6919 +--- a/drivers/pci/quirks.c
6920 ++++ b/drivers/pci/quirks.c
6921 +@@ -3252,6 +3252,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
6922 + PCI_DEVICE_ID_SOLARFLARE_SFC4000A_1, fixup_mpss_256);
6923 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
6924 + PCI_DEVICE_ID_SOLARFLARE_SFC4000B, fixup_mpss_256);
6925 ++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ASMEDIA, 0x0612, fixup_mpss_256);
6926 +
6927 + /*
6928 + * Intel 5000 and 5100 Memory controllers have an erratum with read completion
6929 +diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c
6930 +index 8b003c890b87b..c9f03418e71e0 100644
6931 +--- a/drivers/pci/syscall.c
6932 ++++ b/drivers/pci/syscall.c
6933 +@@ -22,8 +22,10 @@ SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn,
6934 + long err;
6935 + int cfg_ret;
6936 +
6937 ++ err = -EPERM;
6938 ++ dev = NULL;
6939 + if (!capable(CAP_SYS_ADMIN))
6940 +- return -EPERM;
6941 ++ goto error;
6942 +
6943 + err = -ENODEV;
6944 + dev = pci_get_domain_bus_and_slot(0, bus, dfn);
6945 +diff --git a/drivers/pinctrl/actions/pinctrl-owl.c b/drivers/pinctrl/actions/pinctrl-owl.c
6946 +index 903a4baf3846c..c8b3e396ea275 100644
6947 +--- a/drivers/pinctrl/actions/pinctrl-owl.c
6948 ++++ b/drivers/pinctrl/actions/pinctrl-owl.c
6949 +@@ -444,7 +444,6 @@ static int owl_group_config_get(struct pinctrl_dev *pctrldev,
6950 + *config = pinconf_to_config_packed(param, arg);
6951 +
6952 + return ret;
6953 +-
6954 + }
6955 +
6956 + static int owl_group_config_set(struct pinctrl_dev *pctrldev,
6957 +diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
6958 +index 20b477cd5a30a..6e6825d17a1d1 100644
6959 +--- a/drivers/pinctrl/core.c
6960 ++++ b/drivers/pinctrl/core.c
6961 +@@ -2119,7 +2119,6 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
6962 + return ERR_PTR(error);
6963 +
6964 + return pctldev;
6965 +-
6966 + }
6967 + EXPORT_SYMBOL_GPL(pinctrl_register);
6968 +
6969 +diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
6970 +index 08d110078c439..70186448d2f4a 100644
6971 +--- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c
6972 ++++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
6973 +@@ -290,7 +290,6 @@ static const struct pinctrl_ops imx1_pctrl_ops = {
6974 + .pin_dbg_show = imx1_pin_dbg_show,
6975 + .dt_node_to_map = imx1_dt_node_to_map,
6976 + .dt_free_map = imx1_dt_free_map,
6977 +-
6978 + };
6979 +
6980 + static int imx1_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
6981 +diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
6982 +index 68894e9e05d2e..5cb018f988003 100644
6983 +--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
6984 ++++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
6985 +@@ -167,10 +167,14 @@ static struct armada_37xx_pin_group armada_37xx_nb_groups[] = {
6986 + PIN_GRP_GPIO("jtag", 20, 5, BIT(0), "jtag"),
6987 + PIN_GRP_GPIO("sdio0", 8, 3, BIT(1), "sdio"),
6988 + PIN_GRP_GPIO("emmc_nb", 27, 9, BIT(2), "emmc"),
6989 +- PIN_GRP_GPIO("pwm0", 11, 1, BIT(3), "pwm"),
6990 +- PIN_GRP_GPIO("pwm1", 12, 1, BIT(4), "pwm"),
6991 +- PIN_GRP_GPIO("pwm2", 13, 1, BIT(5), "pwm"),
6992 +- PIN_GRP_GPIO("pwm3", 14, 1, BIT(6), "pwm"),
6993 ++ PIN_GRP_GPIO_3("pwm0", 11, 1, BIT(3) | BIT(20), 0, BIT(20), BIT(3),
6994 ++ "pwm", "led"),
6995 ++ PIN_GRP_GPIO_3("pwm1", 12, 1, BIT(4) | BIT(21), 0, BIT(21), BIT(4),
6996 ++ "pwm", "led"),
6997 ++ PIN_GRP_GPIO_3("pwm2", 13, 1, BIT(5) | BIT(22), 0, BIT(22), BIT(5),
6998 ++ "pwm", "led"),
6999 ++ PIN_GRP_GPIO_3("pwm3", 14, 1, BIT(6) | BIT(23), 0, BIT(23), BIT(6),
7000 ++ "pwm", "led"),
7001 + PIN_GRP_GPIO("pmic1", 7, 1, BIT(7), "pmic"),
7002 + PIN_GRP_GPIO("pmic0", 6, 1, BIT(8), "pmic"),
7003 + PIN_GRP_GPIO("i2c2", 2, 2, BIT(9), "i2c"),
7004 +@@ -184,11 +188,6 @@ static struct armada_37xx_pin_group armada_37xx_nb_groups[] = {
7005 + PIN_GRP_EXTRA("uart2", 9, 2, BIT(1) | BIT(13) | BIT(14) | BIT(19),
7006 + BIT(1) | BIT(13) | BIT(14), BIT(1) | BIT(19),
7007 + 18, 2, "gpio", "uart"),
7008 +- PIN_GRP_GPIO_2("led0_od", 11, 1, BIT(20), BIT(20), 0, "led"),
7009 +- PIN_GRP_GPIO_2("led1_od", 12, 1, BIT(21), BIT(21), 0, "led"),
7010 +- PIN_GRP_GPIO_2("led2_od", 13, 1, BIT(22), BIT(22), 0, "led"),
7011 +- PIN_GRP_GPIO_2("led3_od", 14, 1, BIT(23), BIT(23), 0, "led"),
7012 +-
7013 + };
7014 +
7015 + static struct armada_37xx_pin_group armada_37xx_sb_groups[] = {
7016 +diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
7017 +index 72edc675431ce..9015486e38c18 100644
7018 +--- a/drivers/pinctrl/pinctrl-at91.c
7019 ++++ b/drivers/pinctrl/pinctrl-at91.c
7020 +@@ -733,7 +733,6 @@ static const struct at91_pinctrl_mux_ops sam9x60_ops = {
7021 + .get_slewrate = at91_mux_sam9x60_get_slewrate,
7022 + .set_slewrate = at91_mux_sam9x60_set_slewrate,
7023 + .irq_type = alt_gpio_irq_type,
7024 +-
7025 + };
7026 +
7027 + static struct at91_pinctrl_mux_ops sama5d3_ops = {
7028 +diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
7029 +index 033d142f0c272..e0df5ad6741dc 100644
7030 +--- a/drivers/pinctrl/pinctrl-ingenic.c
7031 ++++ b/drivers/pinctrl/pinctrl-ingenic.c
7032 +@@ -363,7 +363,7 @@ static const struct ingenic_chip_info jz4725b_chip_info = {
7033 + };
7034 +
7035 + static const u32 jz4760_pull_ups[6] = {
7036 +- 0xffffffff, 0xfffcf3ff, 0xffffffff, 0xffffcfff, 0xfffffb7c, 0xfffff00f,
7037 ++ 0xffffffff, 0xfffcf3ff, 0xffffffff, 0xffffcfff, 0xfffffb7c, 0x0000000f,
7038 + };
7039 +
7040 + static const u32 jz4760_pull_downs[6] = {
7041 +@@ -618,11 +618,11 @@ static const struct ingenic_chip_info jz4760_chip_info = {
7042 + };
7043 +
7044 + static const u32 jz4770_pull_ups[6] = {
7045 +- 0x3fffffff, 0xfff0030c, 0xffffffff, 0xffff4fff, 0xfffffb7c, 0xffa7f00f,
7046 ++ 0x3fffffff, 0xfff0f3fc, 0xffffffff, 0xffff4fff, 0xfffffb7c, 0x0024f00f,
7047 + };
7048 +
7049 + static const u32 jz4770_pull_downs[6] = {
7050 +- 0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x00580ff0,
7051 ++ 0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x005b0ff0,
7052 + };
7053 +
7054 + static int jz4770_uart0_data_pins[] = { 0xa0, 0xa3, };
7055 +diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
7056 +index 12cc4eb186377..17aa0d542d925 100644
7057 +--- a/drivers/pinctrl/pinctrl-single.c
7058 ++++ b/drivers/pinctrl/pinctrl-single.c
7059 +@@ -1222,6 +1222,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
7060 +
7061 + if (PCS_HAS_PINCONF) {
7062 + dev_err(pcs->dev, "pinconf not supported\n");
7063 ++ res = -ENOTSUPP;
7064 + goto free_pingroups;
7065 + }
7066 +
7067 +diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
7068 +index 7b8c7a0b13de0..43d9e6c7fd81f 100644
7069 +--- a/drivers/pinctrl/pinctrl-st.c
7070 ++++ b/drivers/pinctrl/pinctrl-st.c
7071 +@@ -541,7 +541,6 @@ static void st_pinconf_set_retime_packed(struct st_pinctrl *info,
7072 + st_regmap_field_bit_set_clear_pin(rt_p->delay_0, delay & 0x1, pin);
7073 + /* 2 bit delay, msb */
7074 + st_regmap_field_bit_set_clear_pin(rt_p->delay_1, delay & 0x2, pin);
7075 +-
7076 + }
7077 +
7078 + static void st_pinconf_set_retime_dedicated(struct st_pinctrl *info,
7079 +diff --git a/drivers/pinctrl/pinctrl-stmfx.c b/drivers/pinctrl/pinctrl-stmfx.c
7080 +index 008c83107a3ca..5fa2488fae87a 100644
7081 +--- a/drivers/pinctrl/pinctrl-stmfx.c
7082 ++++ b/drivers/pinctrl/pinctrl-stmfx.c
7083 +@@ -566,7 +566,7 @@ static irqreturn_t stmfx_pinctrl_irq_thread_fn(int irq, void *dev_id)
7084 + u8 pending[NR_GPIO_REGS];
7085 + u8 src[NR_GPIO_REGS] = {0, 0, 0};
7086 + unsigned long n, status;
7087 +- int ret;
7088 ++ int i, ret;
7089 +
7090 + ret = regmap_bulk_read(pctl->stmfx->map, STMFX_REG_IRQ_GPI_PENDING,
7091 + &pending, NR_GPIO_REGS);
7092 +@@ -576,7 +576,9 @@ static irqreturn_t stmfx_pinctrl_irq_thread_fn(int irq, void *dev_id)
7093 + regmap_bulk_write(pctl->stmfx->map, STMFX_REG_IRQ_GPI_SRC,
7094 + src, NR_GPIO_REGS);
7095 +
7096 +- status = *(unsigned long *)pending;
7097 ++ BUILD_BUG_ON(NR_GPIO_REGS > sizeof(status));
7098 ++ for (i = 0, status = 0; i < NR_GPIO_REGS; i++)
7099 ++ status |= (unsigned long)pending[i] << (i * 8);
7100 + for_each_set_bit(n, &status, gc->ngpio) {
7101 + handle_nested_irq(irq_find_mapping(gc->irq.domain, n));
7102 + stmfx_pinctrl_irq_toggle_trigger(pctl, n);
7103 +diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c
7104 +index c110f780407bd..484a3b9e875c1 100644
7105 +--- a/drivers/pinctrl/pinctrl-sx150x.c
7106 ++++ b/drivers/pinctrl/pinctrl-sx150x.c
7107 +@@ -443,7 +443,6 @@ static void sx150x_gpio_set(struct gpio_chip *chip, unsigned int offset,
7108 + sx150x_gpio_oscio_set(pctl, value);
7109 + else
7110 + __sx150x_gpio_set(pctl, offset, value);
7111 +-
7112 + }
7113 +
7114 + static void sx150x_gpio_set_multiple(struct gpio_chip *chip,
7115 +diff --git a/drivers/pinctrl/qcom/pinctrl-sdm845.c b/drivers/pinctrl/qcom/pinctrl-sdm845.c
7116 +index 2834d2c1338c8..c51793f6546f1 100644
7117 +--- a/drivers/pinctrl/qcom/pinctrl-sdm845.c
7118 ++++ b/drivers/pinctrl/qcom/pinctrl-sdm845.c
7119 +@@ -1310,7 +1310,6 @@ static const struct msm_pinctrl_soc_data sdm845_pinctrl = {
7120 + .ngpios = 151,
7121 + .wakeirq_map = sdm845_pdc_map,
7122 + .nwakeirq_map = ARRAY_SIZE(sdm845_pdc_map),
7123 +-
7124 + };
7125 +
7126 + static const struct msm_pinctrl_soc_data sdm845_acpi_pinctrl = {
7127 +diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c
7128 +index 681d8dcf37e34..92e7f2602847c 100644
7129 +--- a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c
7130 ++++ b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c
7131 +@@ -617,7 +617,6 @@ static void pm8xxx_mpp_dbg_show_one(struct seq_file *s,
7132 + }
7133 + break;
7134 + }
7135 +-
7136 + }
7137 +
7138 + static void pm8xxx_mpp_dbg_show(struct seq_file *s, struct gpio_chip *chip)
7139 +diff --git a/drivers/pinctrl/renesas/pfc-r8a77950.c b/drivers/pinctrl/renesas/pfc-r8a77950.c
7140 +index 04812e62f3a47..9d89da2319e56 100644
7141 +--- a/drivers/pinctrl/renesas/pfc-r8a77950.c
7142 ++++ b/drivers/pinctrl/renesas/pfc-r8a77950.c
7143 +@@ -1668,7 +1668,6 @@ static const unsigned int avb_mii_pins[] = {
7144 + PIN_AVB_RX_CTL, PIN_AVB_RXC, PIN_AVB_RD0,
7145 + PIN_AVB_RD1, PIN_AVB_RD2, PIN_AVB_RD3,
7146 + PIN_AVB_TXCREFCLK,
7147 +-
7148 + };
7149 + static const unsigned int avb_mii_mux[] = {
7150 + AVB_TX_CTL_MARK, AVB_TXC_MARK, AVB_TD0_MARK,
7151 +diff --git a/drivers/pinctrl/renesas/pfc-r8a77951.c b/drivers/pinctrl/renesas/pfc-r8a77951.c
7152 +index a94ebe0bf5d06..4aea6e4b71571 100644
7153 +--- a/drivers/pinctrl/renesas/pfc-r8a77951.c
7154 ++++ b/drivers/pinctrl/renesas/pfc-r8a77951.c
7155 +@@ -1727,7 +1727,6 @@ static const unsigned int avb_mii_pins[] = {
7156 + PIN_AVB_RX_CTL, PIN_AVB_RXC, PIN_AVB_RD0,
7157 + PIN_AVB_RD1, PIN_AVB_RD2, PIN_AVB_RD3,
7158 + PIN_AVB_TXCREFCLK,
7159 +-
7160 + };
7161 + static const unsigned int avb_mii_mux[] = {
7162 + AVB_TX_CTL_MARK, AVB_TXC_MARK, AVB_TD0_MARK,
7163 +diff --git a/drivers/pinctrl/renesas/pfc-r8a7796.c b/drivers/pinctrl/renesas/pfc-r8a7796.c
7164 +index 3878d6b0db149..a67fa0e4df7c7 100644
7165 +--- a/drivers/pinctrl/renesas/pfc-r8a7796.c
7166 ++++ b/drivers/pinctrl/renesas/pfc-r8a7796.c
7167 +@@ -1732,7 +1732,6 @@ static const unsigned int avb_mii_pins[] = {
7168 + PIN_AVB_RX_CTL, PIN_AVB_RXC, PIN_AVB_RD0,
7169 + PIN_AVB_RD1, PIN_AVB_RD2, PIN_AVB_RD3,
7170 + PIN_AVB_TXCREFCLK,
7171 +-
7172 + };
7173 + static const unsigned int avb_mii_mux[] = {
7174 + AVB_TX_CTL_MARK, AVB_TXC_MARK, AVB_TD0_MARK,
7175 +diff --git a/drivers/pinctrl/renesas/pfc-r8a77965.c b/drivers/pinctrl/renesas/pfc-r8a77965.c
7176 +index 7a50b9b69a7dc..7db2b7f2ff678 100644
7177 +--- a/drivers/pinctrl/renesas/pfc-r8a77965.c
7178 ++++ b/drivers/pinctrl/renesas/pfc-r8a77965.c
7179 +@@ -1736,7 +1736,6 @@ static const unsigned int avb_mii_pins[] = {
7180 + PIN_AVB_RX_CTL, PIN_AVB_RXC, PIN_AVB_RD0,
7181 + PIN_AVB_RD1, PIN_AVB_RD2, PIN_AVB_RD3,
7182 + PIN_AVB_TXCREFCLK,
7183 +-
7184 + };
7185 + static const unsigned int avb_mii_mux[] = {
7186 + AVB_TX_CTL_MARK, AVB_TXC_MARK, AVB_TD0_MARK,
7187 +diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
7188 +index 608eb5a07248e..7f809a57bee50 100644
7189 +--- a/drivers/pinctrl/samsung/pinctrl-samsung.c
7190 ++++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
7191 +@@ -918,7 +918,7 @@ static int samsung_pinctrl_register(struct platform_device *pdev,
7192 + pin_bank->grange.pin_base = drvdata->pin_base
7193 + + pin_bank->pin_base;
7194 + pin_bank->grange.base = pin_bank->grange.pin_base;
7195 +- pin_bank->grange.npins = pin_bank->gpio_chip.ngpio;
7196 ++ pin_bank->grange.npins = pin_bank->nr_pins;
7197 + pin_bank->grange.gc = &pin_bank->gpio_chip;
7198 + pinctrl_add_gpio_range(drvdata->pctl_dev, &pin_bank->grange);
7199 + }
7200 +diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
7201 +index ea5149efcbeae..9f698a7aad129 100644
7202 +--- a/drivers/platform/chrome/cros_ec_proto.c
7203 ++++ b/drivers/platform/chrome/cros_ec_proto.c
7204 +@@ -279,6 +279,15 @@ static int cros_ec_host_command_proto_query(struct cros_ec_device *ec_dev,
7205 + msg->insize = sizeof(struct ec_response_get_protocol_info);
7206 +
7207 + ret = send_command(ec_dev, msg);
7208 ++ /*
7209 ++ * Send command once again when timeout occurred.
7210 ++ * Fingerprint MCU (FPMCU) is restarted during system boot which
7211 ++ * introduces small window in which FPMCU won't respond for any
7212 ++ * messages sent by kernel. There is no need to wait before next
7213 ++ * attempt because we waited at least EC_MSG_DEADLINE_MS.
7214 ++ */
7215 ++ if (ret == -ETIMEDOUT)
7216 ++ ret = send_command(ec_dev, msg);
7217 +
7218 + if (ret < 0) {
7219 + dev_dbg(ec_dev->dev,
7220 +diff --git a/drivers/platform/x86/dell-smbios-wmi.c b/drivers/platform/x86/dell-smbios-wmi.c
7221 +index c97bd4a452422..5821e9d9a4ce4 100644
7222 +--- a/drivers/platform/x86/dell-smbios-wmi.c
7223 ++++ b/drivers/platform/x86/dell-smbios-wmi.c
7224 +@@ -69,6 +69,7 @@ static int run_smbios_call(struct wmi_device *wdev)
7225 + if (obj->type == ACPI_TYPE_INTEGER)
7226 + dev_dbg(&wdev->dev, "SMBIOS call failed: %llu\n",
7227 + obj->integer.value);
7228 ++ kfree(output.pointer);
7229 + return -EIO;
7230 + }
7231 + memcpy(&priv->buf->std, obj->buffer.pointer, obj->buffer.length);
7232 +diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
7233 +index 48d3985eaa8ad..69bb0f56e492a 100644
7234 +--- a/drivers/power/supply/max17042_battery.c
7235 ++++ b/drivers/power/supply/max17042_battery.c
7236 +@@ -859,8 +859,12 @@ static irqreturn_t max17042_thread_handler(int id, void *dev)
7237 + {
7238 + struct max17042_chip *chip = dev;
7239 + u32 val;
7240 ++ int ret;
7241 ++
7242 ++ ret = regmap_read(chip->regmap, MAX17042_STATUS, &val);
7243 ++ if (ret)
7244 ++ return IRQ_HANDLED;
7245 +
7246 +- regmap_read(chip->regmap, MAX17042_STATUS, &val);
7247 + if ((val & STATUS_INTR_SOCMIN_BIT) ||
7248 + (val & STATUS_INTR_SOCMAX_BIT)) {
7249 + dev_info(&chip->client->dev, "SOC threshold INTR\n");
7250 +diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c
7251 +index e3840386f430c..6eec86b0b1751 100644
7252 +--- a/drivers/rtc/rtc-tps65910.c
7253 ++++ b/drivers/rtc/rtc-tps65910.c
7254 +@@ -469,6 +469,6 @@ static struct platform_driver tps65910_rtc_driver = {
7255 + };
7256 +
7257 + module_platform_driver(tps65910_rtc_driver);
7258 +-MODULE_ALIAS("platform:rtc-tps65910");
7259 ++MODULE_ALIAS("platform:tps65910-rtc");
7260 + MODULE_AUTHOR("Venu Byravarasu <vbyravarasu@××××××.com>");
7261 + MODULE_LICENSE("GPL");
7262 +diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
7263 +index f9a31c7819ae6..3e29c26f01856 100644
7264 +--- a/drivers/s390/cio/qdio_main.c
7265 ++++ b/drivers/s390/cio/qdio_main.c
7266 +@@ -1025,6 +1025,33 @@ static void qdio_shutdown_queues(struct qdio_irq *irq_ptr)
7267 + }
7268 + }
7269 +
7270 ++static int qdio_cancel_ccw(struct qdio_irq *irq, int how)
7271 ++{
7272 ++ struct ccw_device *cdev = irq->cdev;
7273 ++ int rc;
7274 ++
7275 ++ spin_lock_irq(get_ccwdev_lock(cdev));
7276 ++ qdio_set_state(irq, QDIO_IRQ_STATE_CLEANUP);
7277 ++ if (how & QDIO_FLAG_CLEANUP_USING_CLEAR)
7278 ++ rc = ccw_device_clear(cdev, QDIO_DOING_CLEANUP);
7279 ++ else
7280 ++ /* default behaviour is halt */
7281 ++ rc = ccw_device_halt(cdev, QDIO_DOING_CLEANUP);
7282 ++ spin_unlock_irq(get_ccwdev_lock(cdev));
7283 ++ if (rc) {
7284 ++ DBF_ERROR("%4x SHUTD ERR", irq->schid.sch_no);
7285 ++ DBF_ERROR("rc:%4d", rc);
7286 ++ return rc;
7287 ++ }
7288 ++
7289 ++ wait_event_interruptible_timeout(cdev->private->wait_q,
7290 ++ irq->state == QDIO_IRQ_STATE_INACTIVE ||
7291 ++ irq->state == QDIO_IRQ_STATE_ERR,
7292 ++ 10 * HZ);
7293 ++
7294 ++ return 0;
7295 ++}
7296 ++
7297 + /**
7298 + * qdio_shutdown - shut down a qdio subchannel
7299 + * @cdev: associated ccw device
7300 +@@ -1063,27 +1090,7 @@ int qdio_shutdown(struct ccw_device *cdev, int how)
7301 + qdio_shutdown_queues(irq_ptr);
7302 + qdio_shutdown_debug_entries(irq_ptr);
7303 +
7304 +- /* cleanup subchannel */
7305 +- spin_lock_irq(get_ccwdev_lock(cdev));
7306 +- qdio_set_state(irq_ptr, QDIO_IRQ_STATE_CLEANUP);
7307 +- if (how & QDIO_FLAG_CLEANUP_USING_CLEAR)
7308 +- rc = ccw_device_clear(cdev, QDIO_DOING_CLEANUP);
7309 +- else
7310 +- /* default behaviour is halt */
7311 +- rc = ccw_device_halt(cdev, QDIO_DOING_CLEANUP);
7312 +- spin_unlock_irq(get_ccwdev_lock(cdev));
7313 +- if (rc) {
7314 +- DBF_ERROR("%4x SHUTD ERR", irq_ptr->schid.sch_no);
7315 +- DBF_ERROR("rc:%4d", rc);
7316 +- goto no_cleanup;
7317 +- }
7318 +-
7319 +- wait_event_interruptible_timeout(cdev->private->wait_q,
7320 +- irq_ptr->state == QDIO_IRQ_STATE_INACTIVE ||
7321 +- irq_ptr->state == QDIO_IRQ_STATE_ERR,
7322 +- 10 * HZ);
7323 +-
7324 +-no_cleanup:
7325 ++ rc = qdio_cancel_ccw(irq_ptr, how);
7326 + qdio_shutdown_thinint(irq_ptr);
7327 + qdio_shutdown_irq(irq_ptr);
7328 +
7329 +@@ -1243,6 +1250,7 @@ int qdio_establish(struct ccw_device *cdev,
7330 + {
7331 + struct qdio_irq *irq_ptr = cdev->private->qdio_data;
7332 + struct subchannel_id schid;
7333 ++ long timeout;
7334 + int rc;
7335 +
7336 + ccw_device_get_schid(cdev, &schid);
7337 +@@ -1268,11 +1276,8 @@ int qdio_establish(struct ccw_device *cdev,
7338 + qdio_setup_irq(irq_ptr, init_data);
7339 +
7340 + rc = qdio_establish_thinint(irq_ptr);
7341 +- if (rc) {
7342 +- qdio_shutdown_irq(irq_ptr);
7343 +- mutex_unlock(&irq_ptr->setup_mutex);
7344 +- return rc;
7345 +- }
7346 ++ if (rc)
7347 ++ goto err_thinint;
7348 +
7349 + /* establish q */
7350 + irq_ptr->ccw.cmd_code = irq_ptr->equeue.cmd;
7351 +@@ -1288,15 +1293,16 @@ int qdio_establish(struct ccw_device *cdev,
7352 + if (rc) {
7353 + DBF_ERROR("%4x est IO ERR", irq_ptr->schid.sch_no);
7354 + DBF_ERROR("rc:%4x", rc);
7355 +- qdio_shutdown_thinint(irq_ptr);
7356 +- qdio_shutdown_irq(irq_ptr);
7357 +- mutex_unlock(&irq_ptr->setup_mutex);
7358 +- return rc;
7359 ++ goto err_ccw_start;
7360 + }
7361 +
7362 +- wait_event_interruptible_timeout(cdev->private->wait_q,
7363 +- irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED ||
7364 +- irq_ptr->state == QDIO_IRQ_STATE_ERR, HZ);
7365 ++ timeout = wait_event_interruptible_timeout(cdev->private->wait_q,
7366 ++ irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED ||
7367 ++ irq_ptr->state == QDIO_IRQ_STATE_ERR, HZ);
7368 ++ if (timeout <= 0) {
7369 ++ rc = (timeout == -ERESTARTSYS) ? -EINTR : -ETIME;
7370 ++ goto err_ccw_timeout;
7371 ++ }
7372 +
7373 + if (irq_ptr->state != QDIO_IRQ_STATE_ESTABLISHED) {
7374 + mutex_unlock(&irq_ptr->setup_mutex);
7375 +@@ -1315,6 +1321,16 @@ int qdio_establish(struct ccw_device *cdev,
7376 + qdio_print_subchannel_info(irq_ptr);
7377 + qdio_setup_debug_entries(irq_ptr);
7378 + return 0;
7379 ++
7380 ++err_ccw_timeout:
7381 ++ qdio_cancel_ccw(irq_ptr, QDIO_FLAG_CLEANUP_USING_CLEAR);
7382 ++err_ccw_start:
7383 ++ qdio_shutdown_thinint(irq_ptr);
7384 ++err_thinint:
7385 ++ qdio_shutdown_irq(irq_ptr);
7386 ++ qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE);
7387 ++ mutex_unlock(&irq_ptr->setup_mutex);
7388 ++ return rc;
7389 + }
7390 + EXPORT_SYMBOL_GPL(qdio_establish);
7391 +
7392 +diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
7393 +index 7231de2767a96..39ef074069971 100644
7394 +--- a/drivers/scsi/BusLogic.c
7395 ++++ b/drivers/scsi/BusLogic.c
7396 +@@ -1845,7 +1845,7 @@ static bool __init blogic_reportconfig(struct blogic_adapter *adapter)
7397 + else
7398 + blogic_info("None, ", adapter);
7399 + if (adapter->bios_addr > 0)
7400 +- blogic_info("BIOS Address: 0x%lX, ", adapter,
7401 ++ blogic_info("BIOS Address: 0x%X, ", adapter,
7402 + adapter->bios_addr);
7403 + else
7404 + blogic_info("BIOS Address: None, ", adapter);
7405 +@@ -3603,7 +3603,7 @@ static void blogic_msg(enum blogic_msglevel msglevel, char *fmt,
7406 + if (buf[0] != '\n' || len > 1)
7407 + printk("%sscsi%d: %s", blogic_msglevelmap[msglevel], adapter->host_no, buf);
7408 + } else
7409 +- printk("%s", buf);
7410 ++ pr_cont("%s", buf);
7411 + } else {
7412 + if (begin) {
7413 + if (adapter != NULL && adapter->adapter_initd)
7414 +@@ -3611,7 +3611,7 @@ static void blogic_msg(enum blogic_msglevel msglevel, char *fmt,
7415 + else
7416 + printk("%s%s", blogic_msglevelmap[msglevel], buf);
7417 + } else
7418 +- printk("%s", buf);
7419 ++ pr_cont("%s", buf);
7420 + }
7421 + begin = (buf[len - 1] == '\n');
7422 + }
7423 +diff --git a/drivers/scsi/pcmcia/fdomain_cs.c b/drivers/scsi/pcmcia/fdomain_cs.c
7424 +index e42acf314d068..33df6a9ba9b5f 100644
7425 +--- a/drivers/scsi/pcmcia/fdomain_cs.c
7426 ++++ b/drivers/scsi/pcmcia/fdomain_cs.c
7427 +@@ -45,8 +45,10 @@ static int fdomain_probe(struct pcmcia_device *link)
7428 + goto fail_disable;
7429 +
7430 + if (!request_region(link->resource[0]->start, FDOMAIN_REGION_SIZE,
7431 +- "fdomain_cs"))
7432 ++ "fdomain_cs")) {
7433 ++ ret = -EBUSY;
7434 + goto fail_disable;
7435 ++ }
7436 +
7437 + sh = fdomain_create(link->resource[0]->start, link->irq, 7, &link->dev);
7438 + if (!sh) {
7439 +diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
7440 +index 846a02de4d510..c63dcc39f76c2 100644
7441 +--- a/drivers/scsi/qedf/qedf_main.c
7442 ++++ b/drivers/scsi/qedf/qedf_main.c
7443 +@@ -3000,7 +3000,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
7444 + {
7445 + u32 *list;
7446 + int i;
7447 +- int status = 0, rc;
7448 ++ int status;
7449 + u32 *pbl;
7450 + dma_addr_t page;
7451 + int num_pages;
7452 +@@ -3012,7 +3012,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
7453 + */
7454 + if (!qedf->num_queues) {
7455 + QEDF_ERR(&(qedf->dbg_ctx), "No MSI-X vectors available!\n");
7456 +- return 1;
7457 ++ return -ENOMEM;
7458 + }
7459 +
7460 + /*
7461 +@@ -3020,7 +3020,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
7462 + * addresses of our queues
7463 + */
7464 + if (!qedf->p_cpuq) {
7465 +- status = 1;
7466 ++ status = -EINVAL;
7467 + QEDF_ERR(&qedf->dbg_ctx, "p_cpuq is NULL.\n");
7468 + goto mem_alloc_failure;
7469 + }
7470 +@@ -3036,8 +3036,8 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
7471 + "qedf->global_queues=%p.\n", qedf->global_queues);
7472 +
7473 + /* Allocate DMA coherent buffers for BDQ */
7474 +- rc = qedf_alloc_bdq(qedf);
7475 +- if (rc) {
7476 ++ status = qedf_alloc_bdq(qedf);
7477 ++ if (status) {
7478 + QEDF_ERR(&qedf->dbg_ctx, "Unable to allocate bdq.\n");
7479 + goto mem_alloc_failure;
7480 + }
7481 +diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
7482 +index b33eff9ea80ba..299d0369e4f08 100644
7483 +--- a/drivers/scsi/qedi/qedi_main.c
7484 ++++ b/drivers/scsi/qedi/qedi_main.c
7485 +@@ -1623,7 +1623,7 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi)
7486 + {
7487 + u32 *list;
7488 + int i;
7489 +- int status = 0, rc;
7490 ++ int status;
7491 + u32 *pbl;
7492 + dma_addr_t page;
7493 + int num_pages;
7494 +@@ -1634,14 +1634,14 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi)
7495 + */
7496 + if (!qedi->num_queues) {
7497 + QEDI_ERR(&qedi->dbg_ctx, "No MSI-X vectors available!\n");
7498 +- return 1;
7499 ++ return -ENOMEM;
7500 + }
7501 +
7502 + /* Make sure we allocated the PBL that will contain the physical
7503 + * addresses of our queues
7504 + */
7505 + if (!qedi->p_cpuq) {
7506 +- status = 1;
7507 ++ status = -EINVAL;
7508 + goto mem_alloc_failure;
7509 + }
7510 +
7511 +@@ -1656,13 +1656,13 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi)
7512 + "qedi->global_queues=%p.\n", qedi->global_queues);
7513 +
7514 + /* Allocate DMA coherent buffers for BDQ */
7515 +- rc = qedi_alloc_bdq(qedi);
7516 +- if (rc)
7517 ++ status = qedi_alloc_bdq(qedi);
7518 ++ if (status)
7519 + goto mem_alloc_failure;
7520 +
7521 + /* Allocate DMA coherent buffers for NVM_ISCSI_CFG */
7522 +- rc = qedi_alloc_nvm_iscsi_cfg(qedi);
7523 +- if (rc)
7524 ++ status = qedi_alloc_nvm_iscsi_cfg(qedi);
7525 ++ if (status)
7526 + goto mem_alloc_failure;
7527 +
7528 + /* Allocate a CQ and an associated PBL for each MSI-X
7529 +diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
7530 +index b7a1dc24db380..f6c76a063294b 100644
7531 +--- a/drivers/scsi/qla2xxx/qla_nvme.c
7532 ++++ b/drivers/scsi/qla2xxx/qla_nvme.c
7533 +@@ -91,8 +91,9 @@ static int qla_nvme_alloc_queue(struct nvme_fc_local_port *lport,
7534 + struct qla_hw_data *ha;
7535 + struct qla_qpair *qpair;
7536 +
7537 +- if (!qidx)
7538 +- qidx++;
7539 ++ /* Map admin queue and 1st IO queue to index 0 */
7540 ++ if (qidx)
7541 ++ qidx--;
7542 +
7543 + vha = (struct scsi_qla_host *)lport->private;
7544 + ha = vha->hw;
7545 +diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
7546 +index 21be50b35bc27..4af794c46d175 100644
7547 +--- a/drivers/scsi/qla2xxx/qla_os.c
7548 ++++ b/drivers/scsi/qla2xxx/qla_os.c
7549 +@@ -14,6 +14,7 @@
7550 + #include <linux/slab.h>
7551 + #include <linux/blk-mq-pci.h>
7552 + #include <linux/refcount.h>
7553 ++#include <linux/crash_dump.h>
7554 +
7555 + #include <scsi/scsi_tcq.h>
7556 + #include <scsi/scsicam.h>
7557 +@@ -2828,6 +2829,11 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
7558 + return ret;
7559 + }
7560 +
7561 ++ if (is_kdump_kernel()) {
7562 ++ ql2xmqsupport = 0;
7563 ++ ql2xallocfwdump = 0;
7564 ++ }
7565 ++
7566 + /* This may fail but that's ok */
7567 + pci_enable_pcie_error_reporting(pdev);
7568 +
7569 +diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
7570 +index 5083e5d2b4675..de73ade70c24c 100644
7571 +--- a/drivers/scsi/smartpqi/smartpqi_init.c
7572 ++++ b/drivers/scsi/smartpqi/smartpqi_init.c
7573 +@@ -1207,6 +1207,7 @@ static int pqi_get_raid_map(struct pqi_ctrl_info *ctrl_info,
7574 + "Requested %d bytes, received %d bytes",
7575 + raid_map_size,
7576 + get_unaligned_le32(&raid_map->structure_size));
7577 ++ rc = -EINVAL;
7578 + goto error;
7579 + }
7580 + }
7581 +diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
7582 +index f54b494ca4486..3f4f3d6f48f9f 100644
7583 +--- a/drivers/scsi/ufs/ufs-exynos.c
7584 ++++ b/drivers/scsi/ufs/ufs-exynos.c
7585 +@@ -259,7 +259,7 @@ static int exynos_ufs_get_clk_info(struct exynos_ufs *ufs)
7586 + struct ufs_hba *hba = ufs->hba;
7587 + struct list_head *head = &hba->clk_list_head;
7588 + struct ufs_clk_info *clki;
7589 +- u32 pclk_rate;
7590 ++ unsigned long pclk_rate;
7591 + u32 f_min, f_max;
7592 + u8 div = 0;
7593 + int ret = 0;
7594 +@@ -298,7 +298,7 @@ static int exynos_ufs_get_clk_info(struct exynos_ufs *ufs)
7595 + }
7596 +
7597 + if (unlikely(pclk_rate < f_min || pclk_rate > f_max)) {
7598 +- dev_err(hba->dev, "not available pclk range %d\n", pclk_rate);
7599 ++ dev_err(hba->dev, "not available pclk range %lu\n", pclk_rate);
7600 + ret = -EINVAL;
7601 + goto out;
7602 + }
7603 +diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h
7604 +index 76d6e39efb2f0..541b577c371ce 100644
7605 +--- a/drivers/scsi/ufs/ufs-exynos.h
7606 ++++ b/drivers/scsi/ufs/ufs-exynos.h
7607 +@@ -197,7 +197,7 @@ struct exynos_ufs {
7608 + u32 pclk_div;
7609 + u32 pclk_avail_min;
7610 + u32 pclk_avail_max;
7611 +- u32 mclk_rate;
7612 ++ unsigned long mclk_rate;
7613 + int avail_ln_rx;
7614 + int avail_ln_tx;
7615 + int rx_sel_idx;
7616 +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
7617 +index 854c96e630077..4dabd09400c6d 100644
7618 +--- a/drivers/scsi/ufs/ufshcd.c
7619 ++++ b/drivers/scsi/ufs/ufshcd.c
7620 +@@ -3249,9 +3249,11 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
7621 +
7622 + if (is_kmalloc) {
7623 + /* Make sure we don't copy more data than available */
7624 +- if (param_offset + param_size > buff_len)
7625 +- param_size = buff_len - param_offset;
7626 +- memcpy(param_read_buf, &desc_buf[param_offset], param_size);
7627 ++ if (param_offset >= buff_len)
7628 ++ ret = -EINVAL;
7629 ++ else
7630 ++ memcpy(param_read_buf, &desc_buf[param_offset],
7631 ++ min_t(u32, param_size, buff_len - param_offset));
7632 + }
7633 + out:
7634 + if (is_kmalloc)
7635 +diff --git a/drivers/soc/aspeed/aspeed-lpc-ctrl.c b/drivers/soc/aspeed/aspeed-lpc-ctrl.c
7636 +index 01ed21e8bfee5..040c7dc1d4792 100644
7637 +--- a/drivers/soc/aspeed/aspeed-lpc-ctrl.c
7638 ++++ b/drivers/soc/aspeed/aspeed-lpc-ctrl.c
7639 +@@ -46,7 +46,7 @@ static int aspeed_lpc_ctrl_mmap(struct file *file, struct vm_area_struct *vma)
7640 + unsigned long vsize = vma->vm_end - vma->vm_start;
7641 + pgprot_t prot = vma->vm_page_prot;
7642 +
7643 +- if (vma->vm_pgoff + vsize > lpc_ctrl->mem_base + lpc_ctrl->mem_size)
7644 ++ if (vma->vm_pgoff + vma_pages(vma) > lpc_ctrl->mem_size >> PAGE_SHIFT)
7645 + return -EINVAL;
7646 +
7647 + /* ast2400/2500 AHB accesses are not cache coherent */
7648 +diff --git a/drivers/soc/aspeed/aspeed-p2a-ctrl.c b/drivers/soc/aspeed/aspeed-p2a-ctrl.c
7649 +index b60fbeaffcbd0..20b5fb2a207cc 100644
7650 +--- a/drivers/soc/aspeed/aspeed-p2a-ctrl.c
7651 ++++ b/drivers/soc/aspeed/aspeed-p2a-ctrl.c
7652 +@@ -110,7 +110,7 @@ static int aspeed_p2a_mmap(struct file *file, struct vm_area_struct *vma)
7653 + vsize = vma->vm_end - vma->vm_start;
7654 + prot = vma->vm_page_prot;
7655 +
7656 +- if (vma->vm_pgoff + vsize > ctrl->mem_base + ctrl->mem_size)
7657 ++ if (vma->vm_pgoff + vma_pages(vma) > ctrl->mem_size >> PAGE_SHIFT)
7658 + return -EINVAL;
7659 +
7660 + /* ast2400/2500 AHB accesses are not cache coherent */
7661 +diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c
7662 +index ed2c687c16b31..4fe88d4690e2b 100644
7663 +--- a/drivers/soc/qcom/qcom_aoss.c
7664 ++++ b/drivers/soc/qcom/qcom_aoss.c
7665 +@@ -476,12 +476,12 @@ static int qmp_cooling_device_add(struct qmp *qmp,
7666 + static int qmp_cooling_devices_register(struct qmp *qmp)
7667 + {
7668 + struct device_node *np, *child;
7669 +- int count = QMP_NUM_COOLING_RESOURCES;
7670 ++ int count = 0;
7671 + int ret;
7672 +
7673 + np = qmp->dev->of_node;
7674 +
7675 +- qmp->cooling_devs = devm_kcalloc(qmp->dev, count,
7676 ++ qmp->cooling_devs = devm_kcalloc(qmp->dev, QMP_NUM_COOLING_RESOURCES,
7677 + sizeof(*qmp->cooling_devs),
7678 + GFP_KERNEL);
7679 +
7680 +@@ -497,12 +497,16 @@ static int qmp_cooling_devices_register(struct qmp *qmp)
7681 + goto unroll;
7682 + }
7683 +
7684 ++ if (!count)
7685 ++ devm_kfree(qmp->dev, qmp->cooling_devs);
7686 ++
7687 + return 0;
7688 +
7689 + unroll:
7690 + while (--count >= 0)
7691 + thermal_cooling_device_unregister
7692 + (qmp->cooling_devs[count].cdev);
7693 ++ devm_kfree(qmp->dev, qmp->cooling_devs);
7694 +
7695 + return ret;
7696 + }
7697 +diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c
7698 +index 6a1e862b16c38..dad4326a2a714 100644
7699 +--- a/drivers/soundwire/intel.c
7700 ++++ b/drivers/soundwire/intel.c
7701 +@@ -537,12 +537,14 @@ static int intel_link_power_down(struct sdw_intel *sdw)
7702 +
7703 + mutex_lock(sdw->link_res->shim_lock);
7704 +
7705 +- intel_shim_master_ip_to_glue(sdw);
7706 +-
7707 + if (!(*shim_mask & BIT(link_id)))
7708 + dev_err(sdw->cdns.dev,
7709 + "%s: Unbalanced power-up/down calls\n", __func__);
7710 +
7711 ++ sdw->cdns.link_up = false;
7712 ++
7713 ++ intel_shim_master_ip_to_glue(sdw);
7714 ++
7715 + *shim_mask &= ~BIT(link_id);
7716 +
7717 + if (!*shim_mask) {
7718 +@@ -559,20 +561,21 @@ static int intel_link_power_down(struct sdw_intel *sdw)
7719 + link_control &= spa_mask;
7720 +
7721 + ret = intel_clear_bit(shim, SDW_SHIM_LCTL, link_control, cpa_mask);
7722 ++ if (ret < 0) {
7723 ++ dev_err(sdw->cdns.dev, "%s: could not power down link\n", __func__);
7724 ++
7725 ++ /*
7726 ++ * we leave the sdw->cdns.link_up flag as false since we've disabled
7727 ++ * the link at this point and cannot handle interrupts any longer.
7728 ++ */
7729 ++ }
7730 + }
7731 +
7732 + link_control = intel_readl(shim, SDW_SHIM_LCTL);
7733 +
7734 + mutex_unlock(sdw->link_res->shim_lock);
7735 +
7736 +- if (ret < 0) {
7737 +- dev_err(sdw->cdns.dev, "%s: could not power down link\n", __func__);
7738 +-
7739 +- return ret;
7740 +- }
7741 +-
7742 +- sdw->cdns.link_up = false;
7743 +- return 0;
7744 ++ return ret;
7745 + }
7746 +
7747 + static void intel_shim_sync_arm(struct sdw_intel *sdw)
7748 +diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
7749 +index cb6feb34dd401..f980af0373452 100644
7750 +--- a/drivers/staging/board/board.c
7751 ++++ b/drivers/staging/board/board.c
7752 +@@ -136,6 +136,7 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
7753 + static int board_staging_add_dev_domain(struct platform_device *pdev,
7754 + const char *domain)
7755 + {
7756 ++ struct device *dev = &pdev->dev;
7757 + struct of_phandle_args pd_args;
7758 + struct device_node *np;
7759 +
7760 +@@ -148,7 +149,11 @@ static int board_staging_add_dev_domain(struct platform_device *pdev,
7761 + pd_args.np = np;
7762 + pd_args.args_count = 0;
7763 +
7764 +- return of_genpd_add_device(&pd_args, &pdev->dev);
7765 ++ /* Initialization similar to device_pm_init_common() */
7766 ++ spin_lock_init(&dev->power.lock);
7767 ++ dev->power.early_init = true;
7768 ++
7769 ++ return of_genpd_add_device(&pd_args, dev);
7770 + }
7771 + #else
7772 + static inline int board_staging_add_dev_domain(struct platform_device *pdev,
7773 +diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
7774 +index 78dc8beeae98e..8c740c771f509 100644
7775 +--- a/drivers/staging/ks7010/ks7010_sdio.c
7776 ++++ b/drivers/staging/ks7010/ks7010_sdio.c
7777 +@@ -939,9 +939,9 @@ static void ks7010_private_init(struct ks_wlan_private *priv,
7778 + memset(&priv->wstats, 0, sizeof(priv->wstats));
7779 +
7780 + /* sleep mode */
7781 ++ atomic_set(&priv->sleepstatus.status, 0);
7782 + atomic_set(&priv->sleepstatus.doze_request, 0);
7783 + atomic_set(&priv->sleepstatus.wakeup_request, 0);
7784 +- atomic_set(&priv->sleepstatus.wakeup_request, 0);
7785 +
7786 + trx_device_init(priv);
7787 + hostif_init(priv);
7788 +diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
7789 +index 0295e2e32d797..fa1bd99cd6f17 100644
7790 +--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
7791 ++++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
7792 +@@ -1763,7 +1763,8 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
7793 + if (err < 0)
7794 + goto register_entities_fail;
7795 + /* init atomisp wdts */
7796 +- if (init_atomisp_wdts(isp) != 0)
7797 ++ err = init_atomisp_wdts(isp);
7798 ++ if (err != 0)
7799 + goto wdt_work_queue_fail;
7800 +
7801 + /* save the iunit context only once after all the values are init'ed. */
7802 +@@ -1815,6 +1816,7 @@ request_irq_fail:
7803 + hmm_cleanup();
7804 + hmm_pool_unregister(HMM_POOL_TYPE_RESERVED);
7805 + hmm_pool_fail:
7806 ++ pm_runtime_get_noresume(&pdev->dev);
7807 + destroy_workqueue(isp->wdt_work_queue);
7808 + wdt_work_queue_fail:
7809 + atomisp_acc_cleanup(isp);
7810 +diff --git a/drivers/staging/media/hantro/hantro_g1_vp8_dec.c b/drivers/staging/media/hantro/hantro_g1_vp8_dec.c
7811 +index a5cdf150cd16c..d30bdc678cc24 100644
7812 +--- a/drivers/staging/media/hantro/hantro_g1_vp8_dec.c
7813 ++++ b/drivers/staging/media/hantro/hantro_g1_vp8_dec.c
7814 +@@ -377,12 +377,17 @@ static void cfg_ref(struct hantro_ctx *ctx,
7815 + vb2_dst = hantro_get_dst_buf(ctx);
7816 +
7817 + ref = hantro_get_ref(ctx, hdr->last_frame_ts);
7818 +- if (!ref)
7819 ++ if (!ref) {
7820 ++ vpu_debug(0, "failed to find last frame ts=%llu\n",
7821 ++ hdr->last_frame_ts);
7822 + ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
7823 ++ }
7824 + vdpu_write_relaxed(vpu, ref, G1_REG_ADDR_REF(0));
7825 +
7826 + ref = hantro_get_ref(ctx, hdr->golden_frame_ts);
7827 +- WARN_ON(!ref && hdr->golden_frame_ts);
7828 ++ if (!ref && hdr->golden_frame_ts)
7829 ++ vpu_debug(0, "failed to find golden frame ts=%llu\n",
7830 ++ hdr->golden_frame_ts);
7831 + if (!ref)
7832 + ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
7833 + if (hdr->flags & V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_GOLDEN)
7834 +@@ -390,7 +395,9 @@ static void cfg_ref(struct hantro_ctx *ctx,
7835 + vdpu_write_relaxed(vpu, ref, G1_REG_ADDR_REF(4));
7836 +
7837 + ref = hantro_get_ref(ctx, hdr->alt_frame_ts);
7838 +- WARN_ON(!ref && hdr->alt_frame_ts);
7839 ++ if (!ref && hdr->alt_frame_ts)
7840 ++ vpu_debug(0, "failed to find alt frame ts=%llu\n",
7841 ++ hdr->alt_frame_ts);
7842 + if (!ref)
7843 + ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
7844 + if (hdr->flags & V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_ALT)
7845 +diff --git a/drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c b/drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c
7846 +index a4a792f00b111..5b8c8fc49cce8 100644
7847 +--- a/drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c
7848 ++++ b/drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c
7849 +@@ -454,12 +454,17 @@ static void cfg_ref(struct hantro_ctx *ctx,
7850 + vb2_dst = hantro_get_dst_buf(ctx);
7851 +
7852 + ref = hantro_get_ref(ctx, hdr->last_frame_ts);
7853 +- if (!ref)
7854 ++ if (!ref) {
7855 ++ vpu_debug(0, "failed to find last frame ts=%llu\n",
7856 ++ hdr->last_frame_ts);
7857 + ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
7858 ++ }
7859 + vdpu_write_relaxed(vpu, ref, VDPU_REG_VP8_ADDR_REF0);
7860 +
7861 + ref = hantro_get_ref(ctx, hdr->golden_frame_ts);
7862 +- WARN_ON(!ref && hdr->golden_frame_ts);
7863 ++ if (!ref && hdr->golden_frame_ts)
7864 ++ vpu_debug(0, "failed to find golden frame ts=%llu\n",
7865 ++ hdr->golden_frame_ts);
7866 + if (!ref)
7867 + ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
7868 + if (hdr->flags & V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_GOLDEN)
7869 +@@ -467,7 +472,9 @@ static void cfg_ref(struct hantro_ctx *ctx,
7870 + vdpu_write_relaxed(vpu, ref, VDPU_REG_VP8_ADDR_REF2_5(2));
7871 +
7872 + ref = hantro_get_ref(ctx, hdr->alt_frame_ts);
7873 +- WARN_ON(!ref && hdr->alt_frame_ts);
7874 ++ if (!ref && hdr->alt_frame_ts)
7875 ++ vpu_debug(0, "failed to find alt frame ts=%llu\n",
7876 ++ hdr->alt_frame_ts);
7877 + if (!ref)
7878 + ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
7879 + if (hdr->flags & V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_ALT)
7880 +diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c
7881 +index 1deb74112ad43..11d9d9155eef2 100644
7882 +--- a/drivers/staging/rts5208/rtsx_scsi.c
7883 ++++ b/drivers/staging/rts5208/rtsx_scsi.c
7884 +@@ -2802,10 +2802,10 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip)
7885 + }
7886 +
7887 + if (dev_info_id == 0x15) {
7888 +- buf_len = 0x3A;
7889 ++ buf_len = 0x3C;
7890 + data_len = 0x3A;
7891 + } else {
7892 +- buf_len = 0x6A;
7893 ++ buf_len = 0x6C;
7894 + data_len = 0x6A;
7895 + }
7896 +
7897 +@@ -2855,11 +2855,7 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip)
7898 + }
7899 +
7900 + rtsx_stor_set_xfer_buf(buf, buf_len, srb);
7901 +-
7902 +- if (dev_info_id == 0x15)
7903 +- scsi_set_resid(srb, scsi_bufflen(srb) - 0x3C);
7904 +- else
7905 +- scsi_set_resid(srb, scsi_bufflen(srb) - 0x6C);
7906 ++ scsi_set_resid(srb, scsi_bufflen(srb) - buf_len);
7907 +
7908 + kfree(buf);
7909 + return STATUS_SUCCESS;
7910 +diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
7911 +index 9a272a516b2d7..c4b157c29af7a 100644
7912 +--- a/drivers/thunderbolt/switch.c
7913 ++++ b/drivers/thunderbolt/switch.c
7914 +@@ -2204,7 +2204,7 @@ static void tb_switch_default_link_ports(struct tb_switch *sw)
7915 + {
7916 + int i;
7917 +
7918 +- for (i = 1; i <= sw->config.max_port_number; i += 2) {
7919 ++ for (i = 1; i <= sw->config.max_port_number; i++) {
7920 + struct tb_port *port = &sw->ports[i];
7921 + struct tb_port *subordinate;
7922 +
7923 +diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
7924 +index e8c58f9bd2632..d6afaae1729aa 100644
7925 +--- a/drivers/tty/hvc/hvsi.c
7926 ++++ b/drivers/tty/hvc/hvsi.c
7927 +@@ -1038,7 +1038,7 @@ static const struct tty_operations hvsi_ops = {
7928 +
7929 + static int __init hvsi_init(void)
7930 + {
7931 +- int i;
7932 ++ int i, ret;
7933 +
7934 + hvsi_driver = alloc_tty_driver(hvsi_count);
7935 + if (!hvsi_driver)
7936 +@@ -1069,12 +1069,25 @@ static int __init hvsi_init(void)
7937 + }
7938 + hvsi_wait = wait_for_state; /* irqs active now */
7939 +
7940 +- if (tty_register_driver(hvsi_driver))
7941 +- panic("Couldn't register hvsi console driver\n");
7942 ++ ret = tty_register_driver(hvsi_driver);
7943 ++ if (ret) {
7944 ++ pr_err("Couldn't register hvsi console driver\n");
7945 ++ goto err_free_irq;
7946 ++ }
7947 +
7948 + printk(KERN_DEBUG "HVSI: registered %i devices\n", hvsi_count);
7949 +
7950 + return 0;
7951 ++err_free_irq:
7952 ++ hvsi_wait = poll_for_state;
7953 ++ for (i = 0; i < hvsi_count; i++) {
7954 ++ struct hvsi_struct *hp = &hvsi_ports[i];
7955 ++
7956 ++ free_irq(hp->virq, hp);
7957 ++ }
7958 ++ tty_driver_kref_put(hvsi_driver);
7959 ++
7960 ++ return ret;
7961 + }
7962 + device_initcall(hvsi_init);
7963 +
7964 +diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
7965 +index c37468887fd2a..efe4cf32add2c 100644
7966 +--- a/drivers/tty/serial/8250/8250_omap.c
7967 ++++ b/drivers/tty/serial/8250/8250_omap.c
7968 +@@ -617,7 +617,7 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)
7969 + struct uart_port *port = dev_id;
7970 + struct omap8250_priv *priv = port->private_data;
7971 + struct uart_8250_port *up = up_to_u8250p(port);
7972 +- unsigned int iir;
7973 ++ unsigned int iir, lsr;
7974 + int ret;
7975 +
7976 + #ifdef CONFIG_SERIAL_8250_DMA
7977 +@@ -628,6 +628,7 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)
7978 + #endif
7979 +
7980 + serial8250_rpm_get(up);
7981 ++ lsr = serial_port_in(port, UART_LSR);
7982 + iir = serial_port_in(port, UART_IIR);
7983 + ret = serial8250_handle_irq(port, iir);
7984 +
7985 +@@ -642,6 +643,24 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)
7986 + serial_port_in(port, UART_RX);
7987 + }
7988 +
7989 ++ /* Stop processing interrupts on input overrun */
7990 ++ if ((lsr & UART_LSR_OE) && up->overrun_backoff_time_ms > 0) {
7991 ++ unsigned long delay;
7992 ++
7993 ++ up->ier = port->serial_in(port, UART_IER);
7994 ++ if (up->ier & (UART_IER_RLSI | UART_IER_RDI)) {
7995 ++ port->ops->stop_rx(port);
7996 ++ } else {
7997 ++ /* Keep restarting the timer until
7998 ++ * the input overrun subsides.
7999 ++ */
8000 ++ cancel_delayed_work(&up->overrun_backoff);
8001 ++ }
8002 ++
8003 ++ delay = msecs_to_jiffies(up->overrun_backoff_time_ms);
8004 ++ schedule_delayed_work(&up->overrun_backoff, delay);
8005 ++ }
8006 ++
8007 + serial8250_rpm_put(up);
8008 +
8009 + return IRQ_RETVAL(ret);
8010 +@@ -1353,6 +1372,10 @@ static int omap8250_probe(struct platform_device *pdev)
8011 + }
8012 + }
8013 +
8014 ++ if (of_property_read_u32(np, "overrun-throttle-ms",
8015 ++ &up.overrun_backoff_time_ms) != 0)
8016 ++ up.overrun_backoff_time_ms = 0;
8017 ++
8018 + priv->wakeirq = irq_of_parse_and_map(np, 1);
8019 +
8020 + pdata = of_device_get_match_data(&pdev->dev);
8021 +diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
8022 +index 39f9ea24e3169..58f718ed1bb98 100644
8023 +--- a/drivers/tty/serial/8250/8250_pci.c
8024 ++++ b/drivers/tty/serial/8250/8250_pci.c
8025 +@@ -87,7 +87,7 @@ static void moan_device(const char *str, struct pci_dev *dev)
8026 +
8027 + static int
8028 + setup_port(struct serial_private *priv, struct uart_8250_port *port,
8029 +- int bar, int offset, int regshift)
8030 ++ u8 bar, unsigned int offset, int regshift)
8031 + {
8032 + struct pci_dev *dev = priv->dev;
8033 +
8034 +diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
8035 +index 3de0a16e055a3..5d40f1010fbfd 100644
8036 +--- a/drivers/tty/serial/8250/8250_port.c
8037 ++++ b/drivers/tty/serial/8250/8250_port.c
8038 +@@ -122,7 +122,8 @@ static const struct serial8250_config uart_config[] = {
8039 + .name = "16C950/954",
8040 + .fifo_size = 128,
8041 + .tx_loadsz = 128,
8042 +- .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
8043 ++ .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01,
8044 ++ .rxtrig_bytes = {16, 32, 112, 120},
8045 + /* UART_CAP_EFR breaks billionon CF bluetooth card. */
8046 + .flags = UART_CAP_FIFO | UART_CAP_SLEEP,
8047 + },
8048 +diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
8049 +index bf0e2a4cb0cef..c6f927a76c3be 100644
8050 +--- a/drivers/tty/serial/jsm/jsm_neo.c
8051 ++++ b/drivers/tty/serial/jsm/jsm_neo.c
8052 +@@ -815,7 +815,9 @@ static void neo_parse_isr(struct jsm_board *brd, u32 port)
8053 + /* Parse any modem signal changes */
8054 + jsm_dbg(INTR, &ch->ch_bd->pci_dev,
8055 + "MOD_STAT: sending to parse_modem_sigs\n");
8056 ++ spin_lock_irqsave(&ch->uart_port.lock, lock_flags);
8057 + neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr));
8058 ++ spin_unlock_irqrestore(&ch->uart_port.lock, lock_flags);
8059 + }
8060 + }
8061 +
8062 +diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
8063 +index 689774c073ca4..8438454ca653f 100644
8064 +--- a/drivers/tty/serial/jsm/jsm_tty.c
8065 ++++ b/drivers/tty/serial/jsm/jsm_tty.c
8066 +@@ -187,6 +187,7 @@ static void jsm_tty_break(struct uart_port *port, int break_state)
8067 +
8068 + static int jsm_tty_open(struct uart_port *port)
8069 + {
8070 ++ unsigned long lock_flags;
8071 + struct jsm_board *brd;
8072 + struct jsm_channel *channel =
8073 + container_of(port, struct jsm_channel, uart_port);
8074 +@@ -240,6 +241,7 @@ static int jsm_tty_open(struct uart_port *port)
8075 + channel->ch_cached_lsr = 0;
8076 + channel->ch_stops_sent = 0;
8077 +
8078 ++ spin_lock_irqsave(&port->lock, lock_flags);
8079 + termios = &port->state->port.tty->termios;
8080 + channel->ch_c_cflag = termios->c_cflag;
8081 + channel->ch_c_iflag = termios->c_iflag;
8082 +@@ -259,6 +261,7 @@ static int jsm_tty_open(struct uart_port *port)
8083 + jsm_carrier(channel);
8084 +
8085 + channel->ch_open_count++;
8086 ++ spin_unlock_irqrestore(&port->lock, lock_flags);
8087 +
8088 + jsm_dbg(OPEN, &channel->ch_bd->pci_dev, "finish\n");
8089 + return 0;
8090 +diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
8091 +index 70898a999a498..f700bfaef1293 100644
8092 +--- a/drivers/tty/serial/sh-sci.c
8093 ++++ b/drivers/tty/serial/sh-sci.c
8094 +@@ -1760,6 +1760,10 @@ static irqreturn_t sci_br_interrupt(int irq, void *ptr)
8095 +
8096 + /* Handle BREAKs */
8097 + sci_handle_breaks(port);
8098 ++
8099 ++ /* drop invalid character received before break was detected */
8100 ++ serial_port_in(port, SCxRDR);
8101 ++
8102 + sci_clear_SCxSR(port, SCxSR_BREAK_CLEAR(port));
8103 +
8104 + return IRQ_HANDLED;
8105 +@@ -1839,7 +1843,8 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
8106 + ret = sci_er_interrupt(irq, ptr);
8107 +
8108 + /* Break Interrupt */
8109 +- if ((ssr_status & SCxSR_BRK(port)) && err_enabled)
8110 ++ if (s->irqs[SCIx_ERI_IRQ] != s->irqs[SCIx_BRI_IRQ] &&
8111 ++ (ssr_status & SCxSR_BRK(port)) && err_enabled)
8112 + ret = sci_br_interrupt(irq, ptr);
8113 +
8114 + /* Overrun Interrupt */
8115 +diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
8116 +index 48e4a5ca18359..f5f56ee07729f 100644
8117 +--- a/drivers/usb/chipidea/host.c
8118 ++++ b/drivers/usb/chipidea/host.c
8119 +@@ -233,18 +233,26 @@ static int ci_ehci_hub_control(
8120 + )
8121 + {
8122 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
8123 ++ unsigned int ports = HCS_N_PORTS(ehci->hcs_params);
8124 + u32 __iomem *status_reg;
8125 +- u32 temp;
8126 ++ u32 temp, port_index;
8127 + unsigned long flags;
8128 + int retval = 0;
8129 + struct device *dev = hcd->self.controller;
8130 + struct ci_hdrc *ci = dev_get_drvdata(dev);
8131 +
8132 +- status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1];
8133 ++ port_index = wIndex & 0xff;
8134 ++ port_index -= (port_index > 0);
8135 ++ status_reg = &ehci->regs->port_status[port_index];
8136 +
8137 + spin_lock_irqsave(&ehci->lock, flags);
8138 +
8139 + if (typeReq == SetPortFeature && wValue == USB_PORT_FEAT_SUSPEND) {
8140 ++ if (!wIndex || wIndex > ports) {
8141 ++ retval = -EPIPE;
8142 ++ goto done;
8143 ++ }
8144 ++
8145 + temp = ehci_readl(ehci, status_reg);
8146 + if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) != 0) {
8147 + retval = -EPIPE;
8148 +@@ -273,7 +281,7 @@ static int ci_ehci_hub_control(
8149 + ehci_writel(ehci, temp, status_reg);
8150 + }
8151 +
8152 +- set_bit((wIndex & 0xff) - 1, &ehci->suspended_ports);
8153 ++ set_bit(port_index, &ehci->suspended_ports);
8154 + goto done;
8155 + }
8156 +
8157 +diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
8158 +index 1a556a628971f..3ffa939678d77 100644
8159 +--- a/drivers/usb/gadget/composite.c
8160 ++++ b/drivers/usb/gadget/composite.c
8161 +@@ -481,7 +481,7 @@ static u8 encode_bMaxPower(enum usb_device_speed speed,
8162 + {
8163 + unsigned val;
8164 +
8165 +- if (c->MaxPower)
8166 ++ if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
8167 + val = c->MaxPower;
8168 + else
8169 + val = CONFIG_USB_GADGET_VBUS_DRAW;
8170 +@@ -905,7 +905,11 @@ static int set_config(struct usb_composite_dev *cdev,
8171 + }
8172 +
8173 + /* when we return, be sure our power usage is valid */
8174 +- power = c->MaxPower ? c->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW;
8175 ++ if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
8176 ++ power = c->MaxPower;
8177 ++ else
8178 ++ power = CONFIG_USB_GADGET_VBUS_DRAW;
8179 ++
8180 + if (gadget->speed < USB_SPEED_SUPER)
8181 + power = min(power, 500U);
8182 + else
8183 +diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
8184 +index c019f2b0c0af3..a9cb647bac6fb 100644
8185 +--- a/drivers/usb/gadget/function/u_ether.c
8186 ++++ b/drivers/usb/gadget/function/u_ether.c
8187 +@@ -491,8 +491,9 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
8188 + }
8189 + spin_unlock_irqrestore(&dev->lock, flags);
8190 +
8191 +- if (skb && !in) {
8192 +- dev_kfree_skb_any(skb);
8193 ++ if (!in) {
8194 ++ if (skb)
8195 ++ dev_kfree_skb_any(skb);
8196 + return NETDEV_TX_OK;
8197 + }
8198 +
8199 +diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
8200 +index cffdc8d01b2a8..8fd27249ad257 100644
8201 +--- a/drivers/usb/host/ehci-mv.c
8202 ++++ b/drivers/usb/host/ehci-mv.c
8203 +@@ -42,26 +42,25 @@ struct ehci_hcd_mv {
8204 + int (*set_vbus)(unsigned int vbus);
8205 + };
8206 +
8207 +-static void ehci_clock_enable(struct ehci_hcd_mv *ehci_mv)
8208 ++static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv)
8209 + {
8210 +- clk_prepare_enable(ehci_mv->clk);
8211 +-}
8212 ++ int retval;
8213 +
8214 +-static void ehci_clock_disable(struct ehci_hcd_mv *ehci_mv)
8215 +-{
8216 +- clk_disable_unprepare(ehci_mv->clk);
8217 +-}
8218 ++ retval = clk_prepare_enable(ehci_mv->clk);
8219 ++ if (retval)
8220 ++ return retval;
8221 +
8222 +-static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv)
8223 +-{
8224 +- ehci_clock_enable(ehci_mv);
8225 +- return phy_init(ehci_mv->phy);
8226 ++ retval = phy_init(ehci_mv->phy);
8227 ++ if (retval)
8228 ++ clk_disable_unprepare(ehci_mv->clk);
8229 ++
8230 ++ return retval;
8231 + }
8232 +
8233 + static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv)
8234 + {
8235 + phy_exit(ehci_mv->phy);
8236 +- ehci_clock_disable(ehci_mv);
8237 ++ clk_disable_unprepare(ehci_mv->clk);
8238 + }
8239 +
8240 + static int mv_ehci_reset(struct usb_hcd *hcd)
8241 +diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
8242 +index bd958f059fe64..ff0b3457fd342 100644
8243 +--- a/drivers/usb/host/fotg210-hcd.c
8244 ++++ b/drivers/usb/host/fotg210-hcd.c
8245 +@@ -2509,11 +2509,6 @@ retry_xacterr:
8246 + return count;
8247 + }
8248 +
8249 +-/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
8250 +-#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
8251 +-/* ... and packet size, for any kind of endpoint descriptor */
8252 +-#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
8253 +-
8254 + /* reverse of qh_urb_transaction: free a list of TDs.
8255 + * used for cleanup after errors, before HC sees an URB's TDs.
8256 + */
8257 +@@ -2599,7 +2594,7 @@ static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210,
8258 + token |= (1 /* "in" */ << 8);
8259 + /* else it's already initted to "out" pid (0 << 8) */
8260 +
8261 +- maxpacket = max_packet(usb_maxpacket(urb->dev, urb->pipe, !is_input));
8262 ++ maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input);
8263 +
8264 + /*
8265 + * buffer gets wrapped in one or more qtds;
8266 +@@ -2713,9 +2708,11 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
8267 + gfp_t flags)
8268 + {
8269 + struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags);
8270 ++ struct usb_host_endpoint *ep;
8271 + u32 info1 = 0, info2 = 0;
8272 + int is_input, type;
8273 + int maxp = 0;
8274 ++ int mult;
8275 + struct usb_tt *tt = urb->dev->tt;
8276 + struct fotg210_qh_hw *hw;
8277 +
8278 +@@ -2730,14 +2727,15 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
8279 +
8280 + is_input = usb_pipein(urb->pipe);
8281 + type = usb_pipetype(urb->pipe);
8282 +- maxp = usb_maxpacket(urb->dev, urb->pipe, !is_input);
8283 ++ ep = usb_pipe_endpoint(urb->dev, urb->pipe);
8284 ++ maxp = usb_endpoint_maxp(&ep->desc);
8285 ++ mult = usb_endpoint_maxp_mult(&ep->desc);
8286 +
8287 + /* 1024 byte maxpacket is a hardware ceiling. High bandwidth
8288 + * acts like up to 3KB, but is built from smaller packets.
8289 + */
8290 +- if (max_packet(maxp) > 1024) {
8291 +- fotg210_dbg(fotg210, "bogus qh maxpacket %d\n",
8292 +- max_packet(maxp));
8293 ++ if (maxp > 1024) {
8294 ++ fotg210_dbg(fotg210, "bogus qh maxpacket %d\n", maxp);
8295 + goto done;
8296 + }
8297 +
8298 +@@ -2751,8 +2749,7 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
8299 + */
8300 + if (type == PIPE_INTERRUPT) {
8301 + qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH,
8302 +- is_input, 0,
8303 +- hb_mult(maxp) * max_packet(maxp)));
8304 ++ is_input, 0, mult * maxp));
8305 + qh->start = NO_FRAME;
8306 +
8307 + if (urb->dev->speed == USB_SPEED_HIGH) {
8308 +@@ -2789,7 +2786,7 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
8309 + think_time = tt ? tt->think_time : 0;
8310 + qh->tt_usecs = NS_TO_US(think_time +
8311 + usb_calc_bus_time(urb->dev->speed,
8312 +- is_input, 0, max_packet(maxp)));
8313 ++ is_input, 0, maxp));
8314 + qh->period = urb->interval;
8315 + if (qh->period > fotg210->periodic_size) {
8316 + qh->period = fotg210->periodic_size;
8317 +@@ -2852,11 +2849,11 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
8318 + * to help them do so. So now people expect to use
8319 + * such nonconformant devices with Linux too; sigh.
8320 + */
8321 +- info1 |= max_packet(maxp) << 16;
8322 ++ info1 |= maxp << 16;
8323 + info2 |= (FOTG210_TUNE_MULT_HS << 30);
8324 + } else { /* PIPE_INTERRUPT */
8325 +- info1 |= max_packet(maxp) << 16;
8326 +- info2 |= hb_mult(maxp) << 30;
8327 ++ info1 |= maxp << 16;
8328 ++ info2 |= mult << 30;
8329 + }
8330 + break;
8331 + default:
8332 +@@ -3926,6 +3923,7 @@ static void iso_stream_init(struct fotg210_hcd *fotg210,
8333 + int is_input;
8334 + long bandwidth;
8335 + unsigned multi;
8336 ++ struct usb_host_endpoint *ep;
8337 +
8338 + /*
8339 + * this might be a "high bandwidth" highspeed endpoint,
8340 +@@ -3933,14 +3931,14 @@ static void iso_stream_init(struct fotg210_hcd *fotg210,
8341 + */
8342 + epnum = usb_pipeendpoint(pipe);
8343 + is_input = usb_pipein(pipe) ? USB_DIR_IN : 0;
8344 +- maxp = usb_maxpacket(dev, pipe, !is_input);
8345 ++ ep = usb_pipe_endpoint(dev, pipe);
8346 ++ maxp = usb_endpoint_maxp(&ep->desc);
8347 + if (is_input)
8348 + buf1 = (1 << 11);
8349 + else
8350 + buf1 = 0;
8351 +
8352 +- maxp = max_packet(maxp);
8353 +- multi = hb_mult(maxp);
8354 ++ multi = usb_endpoint_maxp_mult(&ep->desc);
8355 + buf1 |= maxp;
8356 + maxp *= multi;
8357 +
8358 +@@ -4461,13 +4459,12 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
8359 +
8360 + /* HC need not update length with this error */
8361 + if (!(t & FOTG210_ISOC_BABBLE)) {
8362 +- desc->actual_length =
8363 +- fotg210_itdlen(urb, desc, t);
8364 ++ desc->actual_length = FOTG210_ITD_LENGTH(t);
8365 + urb->actual_length += desc->actual_length;
8366 + }
8367 + } else if (likely((t & FOTG210_ISOC_ACTIVE) == 0)) {
8368 + desc->status = 0;
8369 +- desc->actual_length = fotg210_itdlen(urb, desc, t);
8370 ++ desc->actual_length = FOTG210_ITD_LENGTH(t);
8371 + urb->actual_length += desc->actual_length;
8372 + } else {
8373 + /* URB was too late */
8374 +diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/host/fotg210.h
8375 +index 6cee40ec65b41..67f59517ebade 100644
8376 +--- a/drivers/usb/host/fotg210.h
8377 ++++ b/drivers/usb/host/fotg210.h
8378 +@@ -686,11 +686,6 @@ static inline unsigned fotg210_read_frame_index(struct fotg210_hcd *fotg210)
8379 + return fotg210_readl(fotg210, &fotg210->regs->frame_index);
8380 + }
8381 +
8382 +-#define fotg210_itdlen(urb, desc, t) ({ \
8383 +- usb_pipein((urb)->pipe) ? \
8384 +- (desc)->length - FOTG210_ITD_LENGTH(t) : \
8385 +- FOTG210_ITD_LENGTH(t); \
8386 +-})
8387 + /*-------------------------------------------------------------------------*/
8388 +
8389 + #endif /* __LINUX_FOTG210_H */
8390 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
8391 +index a8d97e23f601f..c51391b45207e 100644
8392 +--- a/drivers/usb/host/xhci.c
8393 ++++ b/drivers/usb/host/xhci.c
8394 +@@ -4666,19 +4666,19 @@ static u16 xhci_calculate_u1_timeout(struct xhci_hcd *xhci,
8395 + {
8396 + unsigned long long timeout_ns;
8397 +
8398 +- if (xhci->quirks & XHCI_INTEL_HOST)
8399 +- timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);
8400 +- else
8401 +- timeout_ns = udev->u1_params.sel;
8402 +-
8403 + /* Prevent U1 if service interval is shorter than U1 exit latency */
8404 + if (usb_endpoint_xfer_int(desc) || usb_endpoint_xfer_isoc(desc)) {
8405 +- if (xhci_service_interval_to_ns(desc) <= timeout_ns) {
8406 ++ if (xhci_service_interval_to_ns(desc) <= udev->u1_params.mel) {
8407 + dev_dbg(&udev->dev, "Disable U1, ESIT shorter than exit latency\n");
8408 + return USB3_LPM_DISABLED;
8409 + }
8410 + }
8411 +
8412 ++ if (xhci->quirks & XHCI_INTEL_HOST)
8413 ++ timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);
8414 ++ else
8415 ++ timeout_ns = udev->u1_params.sel;
8416 ++
8417 + /* The U1 timeout is encoded in 1us intervals.
8418 + * Don't return a timeout of zero, because that's USB3_LPM_DISABLED.
8419 + */
8420 +@@ -4730,19 +4730,19 @@ static u16 xhci_calculate_u2_timeout(struct xhci_hcd *xhci,
8421 + {
8422 + unsigned long long timeout_ns;
8423 +
8424 +- if (xhci->quirks & XHCI_INTEL_HOST)
8425 +- timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
8426 +- else
8427 +- timeout_ns = udev->u2_params.sel;
8428 +-
8429 + /* Prevent U2 if service interval is shorter than U2 exit latency */
8430 + if (usb_endpoint_xfer_int(desc) || usb_endpoint_xfer_isoc(desc)) {
8431 +- if (xhci_service_interval_to_ns(desc) <= timeout_ns) {
8432 ++ if (xhci_service_interval_to_ns(desc) <= udev->u2_params.mel) {
8433 + dev_dbg(&udev->dev, "Disable U2, ESIT shorter than exit latency\n");
8434 + return USB3_LPM_DISABLED;
8435 + }
8436 + }
8437 +
8438 ++ if (xhci->quirks & XHCI_INTEL_HOST)
8439 ++ timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
8440 ++ else
8441 ++ timeout_ns = udev->u2_params.sel;
8442 ++
8443 + /* The U2 timeout is encoded in 256us intervals */
8444 + timeout_ns = DIV_ROUND_UP_ULL(timeout_ns, 256 * 1000);
8445 + /* If the necessary timeout value is bigger than what we can set in the
8446 +diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
8447 +index 5892f3ce0cdc8..ce9fc46c92661 100644
8448 +--- a/drivers/usb/musb/musb_dsps.c
8449 ++++ b/drivers/usb/musb/musb_dsps.c
8450 +@@ -890,23 +890,22 @@ static int dsps_probe(struct platform_device *pdev)
8451 + if (!glue->usbss_base)
8452 + return -ENXIO;
8453 +
8454 +- if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) {
8455 +- ret = dsps_setup_optional_vbus_irq(pdev, glue);
8456 +- if (ret)
8457 +- goto err_iounmap;
8458 +- }
8459 +-
8460 + platform_set_drvdata(pdev, glue);
8461 + pm_runtime_enable(&pdev->dev);
8462 + ret = dsps_create_musb_pdev(glue, pdev);
8463 + if (ret)
8464 + goto err;
8465 +
8466 ++ if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) {
8467 ++ ret = dsps_setup_optional_vbus_irq(pdev, glue);
8468 ++ if (ret)
8469 ++ goto err;
8470 ++ }
8471 ++
8472 + return 0;
8473 +
8474 + err:
8475 + pm_runtime_disable(&pdev->dev);
8476 +-err_iounmap:
8477 + iounmap(glue->usbss_base);
8478 + return ret;
8479 + }
8480 +diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
8481 +index 4ba6bcdaa8e9d..b07b2925ff78b 100644
8482 +--- a/drivers/usb/usbip/vhci_hcd.c
8483 ++++ b/drivers/usb/usbip/vhci_hcd.c
8484 +@@ -455,8 +455,14 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
8485 + vhci_hcd->port_status[rhport] &= ~(1 << USB_PORT_FEAT_RESET);
8486 + vhci_hcd->re_timeout = 0;
8487 +
8488 ++ /*
8489 ++ * A few drivers do usb reset during probe when
8490 ++ * the device could be in VDEV_ST_USED state
8491 ++ */
8492 + if (vhci_hcd->vdev[rhport].ud.status ==
8493 +- VDEV_ST_NOTASSIGNED) {
8494 ++ VDEV_ST_NOTASSIGNED ||
8495 ++ vhci_hcd->vdev[rhport].ud.status ==
8496 ++ VDEV_ST_USED) {
8497 + usbip_dbg_vhci_rh(
8498 + " enable rhport %d (status %u)\n",
8499 + rhport,
8500 +@@ -957,8 +963,32 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
8501 + spin_lock(&vdev->priv_lock);
8502 +
8503 + list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) {
8504 ++ struct urb *urb;
8505 ++
8506 ++ /* give back urb of unsent unlink request */
8507 + pr_info("unlink cleanup tx %lu\n", unlink->unlink_seqnum);
8508 ++
8509 ++ urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
8510 ++ if (!urb) {
8511 ++ list_del(&unlink->list);
8512 ++ kfree(unlink);
8513 ++ continue;
8514 ++ }
8515 ++
8516 ++ urb->status = -ENODEV;
8517 ++
8518 ++ usb_hcd_unlink_urb_from_ep(hcd, urb);
8519 ++
8520 + list_del(&unlink->list);
8521 ++
8522 ++ spin_unlock(&vdev->priv_lock);
8523 ++ spin_unlock_irqrestore(&vhci->lock, flags);
8524 ++
8525 ++ usb_hcd_giveback_urb(hcd, urb, urb->status);
8526 ++
8527 ++ spin_lock_irqsave(&vhci->lock, flags);
8528 ++ spin_lock(&vdev->priv_lock);
8529 ++
8530 + kfree(unlink);
8531 + }
8532 +
8533 +diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig
8534 +index 67d0bf4efa160..e44bf736e2b22 100644
8535 +--- a/drivers/vfio/Kconfig
8536 ++++ b/drivers/vfio/Kconfig
8537 +@@ -29,7 +29,7 @@ menuconfig VFIO
8538 +
8539 + If you don't know what to do here, say N.
8540 +
8541 +-menuconfig VFIO_NOIOMMU
8542 ++config VFIO_NOIOMMU
8543 + bool "VFIO No-IOMMU support"
8544 + depends on VFIO
8545 + help
8546 +diff --git a/drivers/video/fbdev/asiliantfb.c b/drivers/video/fbdev/asiliantfb.c
8547 +index 3e006da477523..84c56f525889f 100644
8548 +--- a/drivers/video/fbdev/asiliantfb.c
8549 ++++ b/drivers/video/fbdev/asiliantfb.c
8550 +@@ -227,6 +227,9 @@ static int asiliantfb_check_var(struct fb_var_screeninfo *var,
8551 + {
8552 + unsigned long Ftarget, ratio, remainder;
8553 +
8554 ++ if (!var->pixclock)
8555 ++ return -EINVAL;
8556 ++
8557 + ratio = 1000000 / var->pixclock;
8558 + remainder = 1000000 % var->pixclock;
8559 + Ftarget = 1000000 * ratio + (1000000 * remainder) / var->pixclock;
8560 +diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
8561 +index 8fbde92ae8b9c..25801e8e3f74a 100644
8562 +--- a/drivers/video/fbdev/kyro/fbdev.c
8563 ++++ b/drivers/video/fbdev/kyro/fbdev.c
8564 +@@ -372,6 +372,11 @@ static int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight
8565 + /* probably haven't called CreateOverlay yet */
8566 + return -EINVAL;
8567 +
8568 ++ if (ulWidth == 0 || ulWidth == 0xffffffff ||
8569 ++ ulHeight == 0 || ulHeight == 0xffffffff ||
8570 ++ (x < 2 && ulWidth + 2 == 0))
8571 ++ return -EINVAL;
8572 ++
8573 + /* Stop Ramdac Output */
8574 + DisableRamdacOutput(deviceInfo.pSTGReg);
8575 +
8576 +@@ -394,6 +399,9 @@ static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
8577 + {
8578 + struct kyrofb_info *par = info->par;
8579 +
8580 ++ if (!var->pixclock)
8581 ++ return -EINVAL;
8582 ++
8583 + if (var->bits_per_pixel != 16 && var->bits_per_pixel != 32) {
8584 + printk(KERN_WARNING "kyrofb: depth not supported: %u\n", var->bits_per_pixel);
8585 + return -EINVAL;
8586 +diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c
8587 +index ce55b9d2e862b..7dd621c7afe4c 100644
8588 +--- a/drivers/video/fbdev/riva/fbdev.c
8589 ++++ b/drivers/video/fbdev/riva/fbdev.c
8590 +@@ -1084,6 +1084,9 @@ static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
8591 + int mode_valid = 0;
8592 +
8593 + NVTRACE_ENTER();
8594 ++ if (!var->pixclock)
8595 ++ return -EINVAL;
8596 ++
8597 + switch (var->bits_per_pixel) {
8598 + case 1 ... 8:
8599 + var->red.offset = var->green.offset = var->blue.offset = 0;
8600 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
8601 +index 69c6786a9fdf2..ff3f0638cdb90 100644
8602 +--- a/fs/btrfs/inode.c
8603 ++++ b/fs/btrfs/inode.c
8604 +@@ -1202,11 +1202,6 @@ static noinline void async_cow_submit(struct btrfs_work *work)
8605 + nr_pages = (async_chunk->end - async_chunk->start + PAGE_SIZE) >>
8606 + PAGE_SHIFT;
8607 +
8608 +- /* atomic_sub_return implies a barrier */
8609 +- if (atomic_sub_return(nr_pages, &fs_info->async_delalloc_pages) <
8610 +- 5 * SZ_1M)
8611 +- cond_wake_up_nomb(&fs_info->async_submit_wait);
8612 +-
8613 + /*
8614 + * ->inode could be NULL if async_chunk_start has failed to compress,
8615 + * in which case we don't have anything to submit, yet we need to
8616 +@@ -1215,6 +1210,11 @@ static noinline void async_cow_submit(struct btrfs_work *work)
8617 + */
8618 + if (async_chunk->inode)
8619 + submit_compressed_extents(async_chunk);
8620 ++
8621 ++ /* atomic_sub_return implies a barrier */
8622 ++ if (atomic_sub_return(nr_pages, &fs_info->async_delalloc_pages) <
8623 ++ 5 * SZ_1M)
8624 ++ cond_wake_up_nomb(&fs_info->async_submit_wait);
8625 + }
8626 +
8627 + static noinline void async_cow_free(struct btrfs_work *work)
8628 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
8629 +index f36928efcf92d..ec25e5eab3499 100644
8630 +--- a/fs/btrfs/tree-log.c
8631 ++++ b/fs/btrfs/tree-log.c
8632 +@@ -708,7 +708,9 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
8633 + */
8634 + ret = btrfs_lookup_data_extent(fs_info, ins.objectid,
8635 + ins.offset);
8636 +- if (ret == 0) {
8637 ++ if (ret < 0) {
8638 ++ goto out;
8639 ++ } else if (ret == 0) {
8640 + btrfs_init_generic_ref(&ref,
8641 + BTRFS_ADD_DELAYED_REF,
8642 + ins.objectid, ins.offset, 0);
8643 +diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
8644 +index d1fccddcf4035..b4fcc48f255b3 100644
8645 +--- a/fs/btrfs/volumes.c
8646 ++++ b/fs/btrfs/volumes.c
8647 +@@ -1129,6 +1129,9 @@ static void btrfs_close_one_device(struct btrfs_device *device)
8648 + fs_devices->rw_devices--;
8649 + }
8650 +
8651 ++ if (device->devid == BTRFS_DEV_REPLACE_DEVID)
8652 ++ clear_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state);
8653 ++
8654 + if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state))
8655 + fs_devices->missing_devices--;
8656 +
8657 +diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
8658 +index b864c9b9e8df1..678dac8365ed3 100644
8659 +--- a/fs/ceph/caps.c
8660 ++++ b/fs/ceph/caps.c
8661 +@@ -1755,6 +1755,9 @@ struct ceph_cap_flush *ceph_alloc_cap_flush(void)
8662 + struct ceph_cap_flush *cf;
8663 +
8664 + cf = kmem_cache_alloc(ceph_cap_flush_cachep, GFP_KERNEL);
8665 ++ if (!cf)
8666 ++ return NULL;
8667 ++
8668 + cf->is_capsnap = false;
8669 + return cf;
8670 + }
8671 +diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
8672 +index 1a0298d1e7cda..d58c5ffeca0d9 100644
8673 +--- a/fs/cifs/sess.c
8674 ++++ b/fs/cifs/sess.c
8675 +@@ -888,7 +888,7 @@ sess_alloc_buffer(struct sess_data *sess_data, int wct)
8676 + return 0;
8677 +
8678 + out_free_smb_buf:
8679 +- kfree(smb_buf);
8680 ++ cifs_small_buf_release(smb_buf);
8681 + sess_data->iov[0].iov_base = NULL;
8682 + sess_data->iov[0].iov_len = 0;
8683 + sess_data->buf0_type = CIFS_NO_BUFFER;
8684 +diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
8685 +index f94b13075ea47..30987ea011f1a 100644
8686 +--- a/fs/f2fs/compress.c
8687 ++++ b/fs/f2fs/compress.c
8688 +@@ -1308,12 +1308,6 @@ out_destroy_crypt:
8689 +
8690 + for (--i; i >= 0; i--)
8691 + fscrypt_finalize_bounce_page(&cc->cpages[i]);
8692 +- for (i = 0; i < cc->nr_cpages; i++) {
8693 +- if (!cc->cpages[i])
8694 +- continue;
8695 +- f2fs_compress_free_page(cc->cpages[i]);
8696 +- cc->cpages[i] = NULL;
8697 +- }
8698 + out_put_cic:
8699 + kmem_cache_free(cic_entry_slab, cic);
8700 + out_put_dnode:
8701 +@@ -1324,6 +1318,12 @@ out_unlock_op:
8702 + else
8703 + f2fs_unlock_op(sbi);
8704 + out_free:
8705 ++ for (i = 0; i < cc->nr_cpages; i++) {
8706 ++ if (!cc->cpages[i])
8707 ++ continue;
8708 ++ f2fs_compress_free_page(cc->cpages[i]);
8709 ++ cc->cpages[i] = NULL;
8710 ++ }
8711 + page_array_free(cc->inode, cc->cpages, cc->nr_cpages);
8712 + cc->cpages = NULL;
8713 + return -EAGAIN;
8714 +diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
8715 +index cfae2dddb0bae..1b11a42847c48 100644
8716 +--- a/fs/f2fs/data.c
8717 ++++ b/fs/f2fs/data.c
8718 +@@ -1550,7 +1550,21 @@ next_dnode:
8719 + if (err) {
8720 + if (flag == F2FS_GET_BLOCK_BMAP)
8721 + map->m_pblk = 0;
8722 ++
8723 + if (err == -ENOENT) {
8724 ++ /*
8725 ++ * There is one exceptional case that read_node_page()
8726 ++ * may return -ENOENT due to filesystem has been
8727 ++ * shutdown or cp_error, so force to convert error
8728 ++ * number to EIO for such case.
8729 ++ */
8730 ++ if (map->m_may_create &&
8731 ++ (is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN) ||
8732 ++ f2fs_cp_error(sbi))) {
8733 ++ err = -EIO;
8734 ++ goto unlock_out;
8735 ++ }
8736 ++
8737 + err = 0;
8738 + if (map->m_next_pgofs)
8739 + *map->m_next_pgofs =
8740 +@@ -2205,6 +2219,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
8741 + continue;
8742 + }
8743 + unlock_page(page);
8744 ++ if (for_write)
8745 ++ put_page(page);
8746 + cc->rpages[i] = NULL;
8747 + cc->nr_rpages--;
8748 + }
8749 +diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
8750 +index 4b9ef8bbfa4a9..6694298b1660f 100644
8751 +--- a/fs/f2fs/dir.c
8752 ++++ b/fs/f2fs/dir.c
8753 +@@ -938,6 +938,7 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
8754 + struct f2fs_sb_info *sbi = F2FS_I_SB(d->inode);
8755 + struct blk_plug plug;
8756 + bool readdir_ra = sbi->readdir_ra == 1;
8757 ++ bool found_valid_dirent = false;
8758 + int err = 0;
8759 +
8760 + bit_pos = ((unsigned long)ctx->pos % d->max);
8761 +@@ -952,13 +953,15 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
8762 +
8763 + de = &d->dentry[bit_pos];
8764 + if (de->name_len == 0) {
8765 ++ if (found_valid_dirent || !bit_pos) {
8766 ++ printk_ratelimited(
8767 ++ "%sF2FS-fs (%s): invalid namelen(0), ino:%u, run fsck to fix.",
8768 ++ KERN_WARNING, sbi->sb->s_id,
8769 ++ le32_to_cpu(de->ino));
8770 ++ set_sbi_flag(sbi, SBI_NEED_FSCK);
8771 ++ }
8772 + bit_pos++;
8773 + ctx->pos = start_pos + bit_pos;
8774 +- printk_ratelimited(
8775 +- "%sF2FS-fs (%s): invalid namelen(0), ino:%u, run fsck to fix.",
8776 +- KERN_WARNING, sbi->sb->s_id,
8777 +- le32_to_cpu(de->ino));
8778 +- set_sbi_flag(sbi, SBI_NEED_FSCK);
8779 + continue;
8780 + }
8781 +
8782 +@@ -1001,6 +1004,7 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
8783 + f2fs_ra_node_page(sbi, le32_to_cpu(de->ino));
8784 +
8785 + ctx->pos = start_pos + bit_pos;
8786 ++ found_valid_dirent = true;
8787 + }
8788 + out:
8789 + if (readdir_ra)
8790 +diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
8791 +index 6ee8b1e0e1741..1fbaab1f7aba8 100644
8792 +--- a/fs/f2fs/file.c
8793 ++++ b/fs/f2fs/file.c
8794 +@@ -1080,7 +1080,6 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
8795 + }
8796 +
8797 + if (pg_start < pg_end) {
8798 +- struct address_space *mapping = inode->i_mapping;
8799 + loff_t blk_start, blk_end;
8800 + struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
8801 +
8802 +@@ -1092,8 +1091,7 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
8803 + down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
8804 + down_write(&F2FS_I(inode)->i_mmap_sem);
8805 +
8806 +- truncate_inode_pages_range(mapping, blk_start,
8807 +- blk_end - 1);
8808 ++ truncate_pagecache_range(inode, blk_start, blk_end - 1);
8809 +
8810 + f2fs_lock_op(sbi);
8811 + ret = f2fs_truncate_hole(inode, pg_start, pg_end);
8812 +diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
8813 +index e02affb5c0e79..72f227f6ebad0 100644
8814 +--- a/fs/f2fs/gc.c
8815 ++++ b/fs/f2fs/gc.c
8816 +@@ -1477,8 +1477,10 @@ next_step:
8817 + int err;
8818 +
8819 + if (S_ISREG(inode->i_mode)) {
8820 +- if (!down_write_trylock(&fi->i_gc_rwsem[READ]))
8821 ++ if (!down_write_trylock(&fi->i_gc_rwsem[READ])) {
8822 ++ sbi->skipped_gc_rwsem++;
8823 + continue;
8824 ++ }
8825 + if (!down_write_trylock(
8826 + &fi->i_gc_rwsem[WRITE])) {
8827 + sbi->skipped_gc_rwsem++;
8828 +diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
8829 +index 476b2c497d282..de543168b3708 100644
8830 +--- a/fs/f2fs/super.c
8831 ++++ b/fs/f2fs/super.c
8832 +@@ -2206,6 +2206,33 @@ static int f2fs_enable_quotas(struct super_block *sb)
8833 + return 0;
8834 + }
8835 +
8836 ++static int f2fs_quota_sync_file(struct f2fs_sb_info *sbi, int type)
8837 ++{
8838 ++ struct quota_info *dqopt = sb_dqopt(sbi->sb);
8839 ++ struct address_space *mapping = dqopt->files[type]->i_mapping;
8840 ++ int ret = 0;
8841 ++
8842 ++ ret = dquot_writeback_dquots(sbi->sb, type);
8843 ++ if (ret)
8844 ++ goto out;
8845 ++
8846 ++ ret = filemap_fdatawrite(mapping);
8847 ++ if (ret)
8848 ++ goto out;
8849 ++
8850 ++ /* if we are using journalled quota */
8851 ++ if (is_journalled_quota(sbi))
8852 ++ goto out;
8853 ++
8854 ++ ret = filemap_fdatawait(mapping);
8855 ++
8856 ++ truncate_inode_pages(&dqopt->files[type]->i_data, 0);
8857 ++out:
8858 ++ if (ret)
8859 ++ set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
8860 ++ return ret;
8861 ++}
8862 ++
8863 + int f2fs_quota_sync(struct super_block *sb, int type)
8864 + {
8865 + struct f2fs_sb_info *sbi = F2FS_SB(sb);
8866 +@@ -2213,57 +2240,42 @@ int f2fs_quota_sync(struct super_block *sb, int type)
8867 + int cnt;
8868 + int ret;
8869 +
8870 +- /*
8871 +- * do_quotactl
8872 +- * f2fs_quota_sync
8873 +- * down_read(quota_sem)
8874 +- * dquot_writeback_dquots()
8875 +- * f2fs_dquot_commit
8876 +- * block_operation
8877 +- * down_read(quota_sem)
8878 +- */
8879 +- f2fs_lock_op(sbi);
8880 +-
8881 +- down_read(&sbi->quota_sem);
8882 +- ret = dquot_writeback_dquots(sb, type);
8883 +- if (ret)
8884 +- goto out;
8885 +-
8886 + /*
8887 + * Now when everything is written we can discard the pagecache so
8888 + * that userspace sees the changes.
8889 + */
8890 + for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
8891 +- struct address_space *mapping;
8892 +
8893 + if (type != -1 && cnt != type)
8894 + continue;
8895 +- if (!sb_has_quota_active(sb, cnt))
8896 +- continue;
8897 +
8898 +- mapping = dqopt->files[cnt]->i_mapping;
8899 ++ if (!sb_has_quota_active(sb, type))
8900 ++ return 0;
8901 +
8902 +- ret = filemap_fdatawrite(mapping);
8903 +- if (ret)
8904 +- goto out;
8905 ++ inode_lock(dqopt->files[cnt]);
8906 +
8907 +- /* if we are using journalled quota */
8908 +- if (is_journalled_quota(sbi))
8909 +- continue;
8910 ++ /*
8911 ++ * do_quotactl
8912 ++ * f2fs_quota_sync
8913 ++ * down_read(quota_sem)
8914 ++ * dquot_writeback_dquots()
8915 ++ * f2fs_dquot_commit
8916 ++ * block_operation
8917 ++ * down_read(quota_sem)
8918 ++ */
8919 ++ f2fs_lock_op(sbi);
8920 ++ down_read(&sbi->quota_sem);
8921 +
8922 +- ret = filemap_fdatawait(mapping);
8923 +- if (ret)
8924 +- set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
8925 ++ ret = f2fs_quota_sync_file(sbi, cnt);
8926 ++
8927 ++ up_read(&sbi->quota_sem);
8928 ++ f2fs_unlock_op(sbi);
8929 +
8930 +- inode_lock(dqopt->files[cnt]);
8931 +- truncate_inode_pages(&dqopt->files[cnt]->i_data, 0);
8932 + inode_unlock(dqopt->files[cnt]);
8933 ++
8934 ++ if (ret)
8935 ++ break;
8936 + }
8937 +-out:
8938 +- if (ret)
8939 +- set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
8940 +- up_read(&sbi->quota_sem);
8941 +- f2fs_unlock_op(sbi);
8942 + return ret;
8943 + }
8944 +
8945 +@@ -2898,11 +2910,13 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
8946 + return -EFSCORRUPTED;
8947 + }
8948 +
8949 +- if (le32_to_cpu(raw_super->cp_payload) >
8950 +- (blocks_per_seg - F2FS_CP_PACKS)) {
8951 +- f2fs_info(sbi, "Insane cp_payload (%u > %u)",
8952 ++ if (le32_to_cpu(raw_super->cp_payload) >=
8953 ++ (blocks_per_seg - F2FS_CP_PACKS -
8954 ++ NR_CURSEG_PERSIST_TYPE)) {
8955 ++ f2fs_info(sbi, "Insane cp_payload (%u >= %u)",
8956 + le32_to_cpu(raw_super->cp_payload),
8957 +- blocks_per_seg - F2FS_CP_PACKS);
8958 ++ blocks_per_seg - F2FS_CP_PACKS -
8959 ++ NR_CURSEG_PERSIST_TYPE);
8960 + return -EFSCORRUPTED;
8961 + }
8962 +
8963 +@@ -2938,6 +2952,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)
8964 + unsigned int cp_pack_start_sum, cp_payload;
8965 + block_t user_block_count, valid_user_blocks;
8966 + block_t avail_node_count, valid_node_count;
8967 ++ unsigned int nat_blocks, nat_bits_bytes, nat_bits_blocks;
8968 + int i, j;
8969 +
8970 + total = le32_to_cpu(raw_super->segment_count);
8971 +@@ -3058,6 +3073,17 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)
8972 + return 1;
8973 + }
8974 +
8975 ++ nat_blocks = nat_segs << log_blocks_per_seg;
8976 ++ nat_bits_bytes = nat_blocks / BITS_PER_BYTE;
8977 ++ nat_bits_blocks = F2FS_BLK_ALIGN((nat_bits_bytes << 1) + 8);
8978 ++ if (__is_set_ckpt_flags(ckpt, CP_NAT_BITS_FLAG) &&
8979 ++ (cp_payload + F2FS_CP_PACKS +
8980 ++ NR_CURSEG_PERSIST_TYPE + nat_bits_blocks >= blocks_per_seg)) {
8981 ++ f2fs_warn(sbi, "Insane cp_payload: %u, nat_bits_blocks: %u)",
8982 ++ cp_payload, nat_bits_blocks);
8983 ++ return -EFSCORRUPTED;
8984 ++ }
8985 ++
8986 + if (unlikely(f2fs_cp_error(sbi))) {
8987 + f2fs_err(sbi, "A bug case: need to run fsck");
8988 + return 1;
8989 +diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
8990 +index 751bc5b1cddf9..6104f627cc712 100644
8991 +--- a/fs/fscache/cookie.c
8992 ++++ b/fs/fscache/cookie.c
8993 +@@ -74,10 +74,8 @@ void fscache_free_cookie(struct fscache_cookie *cookie)
8994 + static int fscache_set_key(struct fscache_cookie *cookie,
8995 + const void *index_key, size_t index_key_len)
8996 + {
8997 +- unsigned long long h;
8998 + u32 *buf;
8999 + int bufs;
9000 +- int i;
9001 +
9002 + bufs = DIV_ROUND_UP(index_key_len, sizeof(*buf));
9003 +
9004 +@@ -91,17 +89,7 @@ static int fscache_set_key(struct fscache_cookie *cookie,
9005 + }
9006 +
9007 + memcpy(buf, index_key, index_key_len);
9008 +-
9009 +- /* Calculate a hash and combine this with the length in the first word
9010 +- * or first half word
9011 +- */
9012 +- h = (unsigned long)cookie->parent;
9013 +- h += index_key_len + cookie->type;
9014 +-
9015 +- for (i = 0; i < bufs; i++)
9016 +- h += buf[i];
9017 +-
9018 +- cookie->key_hash = h ^ (h >> 32);
9019 ++ cookie->key_hash = fscache_hash(0, buf, bufs);
9020 + return 0;
9021 + }
9022 +
9023 +diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
9024 +index 08e91efbce538..64aa552b296d7 100644
9025 +--- a/fs/fscache/internal.h
9026 ++++ b/fs/fscache/internal.h
9027 +@@ -97,6 +97,8 @@ extern struct workqueue_struct *fscache_object_wq;
9028 + extern struct workqueue_struct *fscache_op_wq;
9029 + DECLARE_PER_CPU(wait_queue_head_t, fscache_object_cong_wait);
9030 +
9031 ++extern unsigned int fscache_hash(unsigned int salt, unsigned int *data, unsigned int n);
9032 ++
9033 + static inline bool fscache_object_congested(void)
9034 + {
9035 + return workqueue_congested(WORK_CPU_UNBOUND, fscache_object_wq);
9036 +diff --git a/fs/fscache/main.c b/fs/fscache/main.c
9037 +index c1e6cc9091aac..4207f98e405fd 100644
9038 +--- a/fs/fscache/main.c
9039 ++++ b/fs/fscache/main.c
9040 +@@ -93,6 +93,45 @@ static struct ctl_table fscache_sysctls_root[] = {
9041 + };
9042 + #endif
9043 +
9044 ++/*
9045 ++ * Mixing scores (in bits) for (7,20):
9046 ++ * Input delta: 1-bit 2-bit
9047 ++ * 1 round: 330.3 9201.6
9048 ++ * 2 rounds: 1246.4 25475.4
9049 ++ * 3 rounds: 1907.1 31295.1
9050 ++ * 4 rounds: 2042.3 31718.6
9051 ++ * Perfect: 2048 31744
9052 ++ * (32*64) (32*31/2 * 64)
9053 ++ */
9054 ++#define HASH_MIX(x, y, a) \
9055 ++ ( x ^= (a), \
9056 ++ y ^= x, x = rol32(x, 7),\
9057 ++ x += y, y = rol32(y,20),\
9058 ++ y *= 9 )
9059 ++
9060 ++static inline unsigned int fold_hash(unsigned long x, unsigned long y)
9061 ++{
9062 ++ /* Use arch-optimized multiply if one exists */
9063 ++ return __hash_32(y ^ __hash_32(x));
9064 ++}
9065 ++
9066 ++/*
9067 ++ * Generate a hash. This is derived from full_name_hash(), but we want to be
9068 ++ * sure it is arch independent and that it doesn't change as bits of the
9069 ++ * computed hash value might appear on disk. The caller also guarantees that
9070 ++ * the hashed data will be a series of aligned 32-bit words.
9071 ++ */
9072 ++unsigned int fscache_hash(unsigned int salt, unsigned int *data, unsigned int n)
9073 ++{
9074 ++ unsigned int a, x = 0, y = salt;
9075 ++
9076 ++ for (; n; n--) {
9077 ++ a = *data++;
9078 ++ HASH_MIX(x, y, a);
9079 ++ }
9080 ++ return fold_hash(x, y);
9081 ++}
9082 ++
9083 + /*
9084 + * initialise the fs caching module
9085 + */
9086 +diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
9087 +index 3faa421568b0a..bf539eab92c6f 100644
9088 +--- a/fs/gfs2/glops.c
9089 ++++ b/fs/gfs2/glops.c
9090 +@@ -623,16 +623,13 @@ static int freeze_go_xmote_bh(struct gfs2_glock *gl, struct gfs2_holder *gh)
9091 + j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
9092 +
9093 + error = gfs2_find_jhead(sdp->sd_jdesc, &head, false);
9094 +- if (error)
9095 +- gfs2_consist(sdp);
9096 +- if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT))
9097 +- gfs2_consist(sdp);
9098 +-
9099 +- /* Initialize some head of the log stuff */
9100 +- if (!gfs2_withdrawn(sdp)) {
9101 +- sdp->sd_log_sequence = head.lh_sequence + 1;
9102 +- gfs2_log_pointers_init(sdp, head.lh_blkno);
9103 +- }
9104 ++ if (gfs2_assert_withdraw_delayed(sdp, !error))
9105 ++ return error;
9106 ++ if (gfs2_assert_withdraw_delayed(sdp, head.lh_flags &
9107 ++ GFS2_LOG_HEAD_UNMOUNT))
9108 ++ return -EIO;
9109 ++ sdp->sd_log_sequence = head.lh_sequence + 1;
9110 ++ gfs2_log_pointers_init(sdp, head.lh_blkno);
9111 + }
9112 + return 0;
9113 + }
9114 +diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
9115 +index 153272f82984b..5564aa8b45929 100644
9116 +--- a/fs/gfs2/lock_dlm.c
9117 ++++ b/fs/gfs2/lock_dlm.c
9118 +@@ -296,6 +296,11 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
9119 + gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT);
9120 + gfs2_update_request_times(gl);
9121 +
9122 ++ /* don't want to call dlm if we've unmounted the lock protocol */
9123 ++ if (test_bit(DFL_UNMOUNT, &ls->ls_recover_flags)) {
9124 ++ gfs2_glock_free(gl);
9125 ++ return;
9126 ++ }
9127 + /* don't want to skip dlm_unlock writing the lvb when lock has one */
9128 +
9129 + if (test_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags) &&
9130 +diff --git a/fs/io-wq.c b/fs/io-wq.c
9131 +index 8bb17b6d4de3c..3d5fc76b92d01 100644
9132 +--- a/fs/io-wq.c
9133 ++++ b/fs/io-wq.c
9134 +@@ -895,7 +895,7 @@ append:
9135 + static void io_wqe_enqueue(struct io_wqe *wqe, struct io_wq_work *work)
9136 + {
9137 + struct io_wqe_acct *acct = io_work_get_acct(wqe, work);
9138 +- int work_flags;
9139 ++ bool do_wake;
9140 + unsigned long flags;
9141 +
9142 + /*
9143 +@@ -909,14 +909,14 @@ static void io_wqe_enqueue(struct io_wqe *wqe, struct io_wq_work *work)
9144 + return;
9145 + }
9146 +
9147 +- work_flags = work->flags;
9148 + raw_spin_lock_irqsave(&wqe->lock, flags);
9149 + io_wqe_insert_work(wqe, work);
9150 + wqe->flags &= ~IO_WQE_FLAG_STALLED;
9151 ++ do_wake = (work->flags & IO_WQ_WORK_CONCURRENT) ||
9152 ++ !atomic_read(&acct->nr_running);
9153 + raw_spin_unlock_irqrestore(&wqe->lock, flags);
9154 +
9155 +- if ((work_flags & IO_WQ_WORK_CONCURRENT) ||
9156 +- !atomic_read(&acct->nr_running))
9157 ++ if (do_wake)
9158 + io_wqe_wake_worker(wqe, acct);
9159 + }
9160 +
9161 +diff --git a/fs/io_uring.c b/fs/io_uring.c
9162 +index 2009d1cda606c..d0089039fee79 100644
9163 +--- a/fs/io_uring.c
9164 ++++ b/fs/io_uring.c
9165 +@@ -1498,6 +1498,8 @@ static void io_kill_timeout(struct io_kiocb *req, int status)
9166 +
9167 + ret = hrtimer_try_to_cancel(&io->timer);
9168 + if (ret != -1) {
9169 ++ if (status)
9170 ++ req_set_fail_links(req);
9171 + atomic_set(&req->ctx->cq_timeouts,
9172 + atomic_read(&req->ctx->cq_timeouts) + 1);
9173 + list_del_init(&req->timeout.list);
9174 +@@ -3126,7 +3128,7 @@ static ssize_t __io_import_iovec(int rw, struct io_kiocb *req,
9175 +
9176 + ret = import_single_range(rw, buf, sqe_len, *iovec, iter);
9177 + *iovec = NULL;
9178 +- return ret < 0 ? ret : sqe_len;
9179 ++ return ret;
9180 + }
9181 +
9182 + if (req->flags & REQ_F_BUFFER_SELECT) {
9183 +@@ -3152,7 +3154,7 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
9184 + if (!iorw)
9185 + return __io_import_iovec(rw, req, iovec, iter, needs_lock);
9186 + *iovec = NULL;
9187 +- return iov_iter_count(&iorw->iter);
9188 ++ return 0;
9189 + }
9190 +
9191 + static inline loff_t *io_kiocb_ppos(struct kiocb *kiocb)
9192 +@@ -3411,7 +3413,6 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
9193 + struct iov_iter __iter, *iter = &__iter;
9194 + struct io_async_rw *rw = req->async_data;
9195 + ssize_t io_size, ret, ret2;
9196 +- size_t iov_count;
9197 + bool no_async;
9198 +
9199 + if (rw)
9200 +@@ -3420,8 +3421,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
9201 + ret = io_import_iovec(READ, req, &iovec, iter, !force_nonblock);
9202 + if (ret < 0)
9203 + return ret;
9204 +- iov_count = iov_iter_count(iter);
9205 +- io_size = ret;
9206 ++ io_size = iov_iter_count(iter);
9207 + req->result = io_size;
9208 + ret = 0;
9209 +
9210 +@@ -3437,7 +3437,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
9211 + if (no_async)
9212 + goto copy_iov;
9213 +
9214 +- ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), iov_count);
9215 ++ ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), io_size);
9216 + if (unlikely(ret))
9217 + goto out_free;
9218 +
9219 +@@ -3456,7 +3456,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
9220 + if (req->file->f_flags & O_NONBLOCK)
9221 + goto done;
9222 + /* some cases will consume bytes even on error returns */
9223 +- iov_iter_revert(iter, iov_count - iov_iter_count(iter));
9224 ++ iov_iter_revert(iter, io_size - iov_iter_count(iter));
9225 + ret = 0;
9226 + goto copy_iov;
9227 + } else if (ret < 0) {
9228 +@@ -3540,7 +3540,6 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
9229 + struct kiocb *kiocb = &req->rw.kiocb;
9230 + struct iov_iter __iter, *iter = &__iter;
9231 + struct io_async_rw *rw = req->async_data;
9232 +- size_t iov_count;
9233 + ssize_t ret, ret2, io_size;
9234 +
9235 + if (rw)
9236 +@@ -3549,8 +3548,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
9237 + ret = io_import_iovec(WRITE, req, &iovec, iter, !force_nonblock);
9238 + if (ret < 0)
9239 + return ret;
9240 +- iov_count = iov_iter_count(iter);
9241 +- io_size = ret;
9242 ++ io_size = iov_iter_count(iter);
9243 + req->result = io_size;
9244 +
9245 + /* Ensure we clear previously set non-block flag */
9246 +@@ -3568,7 +3566,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
9247 + (req->flags & REQ_F_ISREG))
9248 + goto copy_iov;
9249 +
9250 +- ret = rw_verify_area(WRITE, req->file, io_kiocb_ppos(kiocb), iov_count);
9251 ++ ret = rw_verify_area(WRITE, req->file, io_kiocb_ppos(kiocb), io_size);
9252 + if (unlikely(ret))
9253 + goto out_free;
9254 +
9255 +@@ -3611,7 +3609,7 @@ done:
9256 + } else {
9257 + copy_iov:
9258 + /* some cases will consume bytes even on error returns */
9259 +- iov_iter_revert(iter, iov_count - iov_iter_count(iter));
9260 ++ iov_iter_revert(iter, io_size - iov_iter_count(iter));
9261 + ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false);
9262 + if (!ret)
9263 + return -EAGAIN;
9264 +@@ -3746,7 +3744,8 @@ static int io_prep_fsync(struct io_kiocb *req, const struct io_uring_sqe *sqe)
9265 +
9266 + if (unlikely(ctx->flags & IORING_SETUP_IOPOLL))
9267 + return -EINVAL;
9268 +- if (unlikely(sqe->addr || sqe->ioprio || sqe->buf_index))
9269 ++ if (unlikely(sqe->addr || sqe->ioprio || sqe->buf_index ||
9270 ++ sqe->splice_fd_in))
9271 + return -EINVAL;
9272 +
9273 + req->sync.flags = READ_ONCE(sqe->fsync_flags);
9274 +@@ -3779,7 +3778,8 @@ static int io_fsync(struct io_kiocb *req, bool force_nonblock)
9275 + static int io_fallocate_prep(struct io_kiocb *req,
9276 + const struct io_uring_sqe *sqe)
9277 + {
9278 +- if (sqe->ioprio || sqe->buf_index || sqe->rw_flags)
9279 ++ if (sqe->ioprio || sqe->buf_index || sqe->rw_flags ||
9280 ++ sqe->splice_fd_in)
9281 + return -EINVAL;
9282 + if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
9283 + return -EINVAL;
9284 +@@ -3810,7 +3810,7 @@ static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
9285 + const char __user *fname;
9286 + int ret;
9287 +
9288 +- if (unlikely(sqe->ioprio || sqe->buf_index))
9289 ++ if (unlikely(sqe->ioprio || sqe->buf_index || sqe->splice_fd_in))
9290 + return -EINVAL;
9291 + if (unlikely(req->flags & REQ_F_FIXED_FILE))
9292 + return -EBADF;
9293 +@@ -3926,7 +3926,8 @@ static int io_remove_buffers_prep(struct io_kiocb *req,
9294 + struct io_provide_buf *p = &req->pbuf;
9295 + u64 tmp;
9296 +
9297 +- if (sqe->ioprio || sqe->rw_flags || sqe->addr || sqe->len || sqe->off)
9298 ++ if (sqe->ioprio || sqe->rw_flags || sqe->addr || sqe->len || sqe->off ||
9299 ++ sqe->splice_fd_in)
9300 + return -EINVAL;
9301 +
9302 + tmp = READ_ONCE(sqe->fd);
9303 +@@ -4002,7 +4003,7 @@ static int io_provide_buffers_prep(struct io_kiocb *req,
9304 + struct io_provide_buf *p = &req->pbuf;
9305 + u64 tmp;
9306 +
9307 +- if (sqe->ioprio || sqe->rw_flags)
9308 ++ if (sqe->ioprio || sqe->rw_flags || sqe->splice_fd_in)
9309 + return -EINVAL;
9310 +
9311 + tmp = READ_ONCE(sqe->fd);
9312 +@@ -4095,7 +4096,7 @@ static int io_epoll_ctl_prep(struct io_kiocb *req,
9313 + const struct io_uring_sqe *sqe)
9314 + {
9315 + #if defined(CONFIG_EPOLL)
9316 +- if (sqe->ioprio || sqe->buf_index)
9317 ++ if (sqe->ioprio || sqe->buf_index || sqe->splice_fd_in)
9318 + return -EINVAL;
9319 + if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL | IORING_SETUP_SQPOLL)))
9320 + return -EINVAL;
9321 +@@ -4141,7 +4142,7 @@ static int io_epoll_ctl(struct io_kiocb *req, bool force_nonblock,
9322 + static int io_madvise_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
9323 + {
9324 + #if defined(CONFIG_ADVISE_SYSCALLS) && defined(CONFIG_MMU)
9325 +- if (sqe->ioprio || sqe->buf_index || sqe->off)
9326 ++ if (sqe->ioprio || sqe->buf_index || sqe->off || sqe->splice_fd_in)
9327 + return -EINVAL;
9328 + if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
9329 + return -EINVAL;
9330 +@@ -4176,7 +4177,7 @@ static int io_madvise(struct io_kiocb *req, bool force_nonblock)
9331 +
9332 + static int io_fadvise_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
9333 + {
9334 +- if (sqe->ioprio || sqe->buf_index || sqe->addr)
9335 ++ if (sqe->ioprio || sqe->buf_index || sqe->addr || sqe->splice_fd_in)
9336 + return -EINVAL;
9337 + if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
9338 + return -EINVAL;
9339 +@@ -4214,7 +4215,7 @@ static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
9340 + {
9341 + if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL | IORING_SETUP_SQPOLL)))
9342 + return -EINVAL;
9343 +- if (sqe->ioprio || sqe->buf_index)
9344 ++ if (sqe->ioprio || sqe->buf_index || sqe->splice_fd_in)
9345 + return -EINVAL;
9346 + if (req->flags & REQ_F_FIXED_FILE)
9347 + return -EBADF;
9348 +@@ -4261,7 +4262,7 @@ static int io_close_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
9349 + if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
9350 + return -EINVAL;
9351 + if (sqe->ioprio || sqe->off || sqe->addr || sqe->len ||
9352 +- sqe->rw_flags || sqe->buf_index)
9353 ++ sqe->rw_flags || sqe->buf_index || sqe->splice_fd_in)
9354 + return -EINVAL;
9355 + if (req->flags & REQ_F_FIXED_FILE)
9356 + return -EBADF;
9357 +@@ -4317,7 +4318,8 @@ static int io_prep_sfr(struct io_kiocb *req, const struct io_uring_sqe *sqe)
9358 +
9359 + if (unlikely(ctx->flags & IORING_SETUP_IOPOLL))
9360 + return -EINVAL;
9361 +- if (unlikely(sqe->addr || sqe->ioprio || sqe->buf_index))
9362 ++ if (unlikely(sqe->addr || sqe->ioprio || sqe->buf_index ||
9363 ++ sqe->splice_fd_in))
9364 + return -EINVAL;
9365 +
9366 + req->sync.off = READ_ONCE(sqe->off);
9367 +@@ -4760,7 +4762,7 @@ static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
9368 +
9369 + if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
9370 + return -EINVAL;
9371 +- if (sqe->ioprio || sqe->len || sqe->buf_index)
9372 ++ if (sqe->ioprio || sqe->len || sqe->buf_index || sqe->splice_fd_in)
9373 + return -EINVAL;
9374 +
9375 + accept->addr = u64_to_user_ptr(READ_ONCE(sqe->addr));
9376 +@@ -4801,7 +4803,8 @@ static int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
9377 +
9378 + if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
9379 + return -EINVAL;
9380 +- if (sqe->ioprio || sqe->len || sqe->buf_index || sqe->rw_flags)
9381 ++ if (sqe->ioprio || sqe->len || sqe->buf_index || sqe->rw_flags ||
9382 ++ sqe->splice_fd_in)
9383 + return -EINVAL;
9384 +
9385 + conn->addr = u64_to_user_ptr(READ_ONCE(sqe->addr));
9386 +@@ -5553,7 +5556,8 @@ static int io_timeout_remove_prep(struct io_kiocb *req,
9387 + return -EINVAL;
9388 + if (unlikely(req->flags & (REQ_F_FIXED_FILE | REQ_F_BUFFER_SELECT)))
9389 + return -EINVAL;
9390 +- if (sqe->ioprio || sqe->buf_index || sqe->len || sqe->timeout_flags)
9391 ++ if (sqe->ioprio || sqe->buf_index || sqe->len || sqe->timeout_flags |
9392 ++ sqe->splice_fd_in)
9393 + return -EINVAL;
9394 +
9395 + req->timeout_rem.addr = READ_ONCE(sqe->addr);
9396 +@@ -5590,7 +5594,8 @@ static int io_timeout_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,
9397 +
9398 + if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
9399 + return -EINVAL;
9400 +- if (sqe->ioprio || sqe->buf_index || sqe->len != 1)
9401 ++ if (sqe->ioprio || sqe->buf_index || sqe->len != 1 ||
9402 ++ sqe->splice_fd_in)
9403 + return -EINVAL;
9404 + if (off && is_timeout_link)
9405 + return -EINVAL;
9406 +@@ -5734,7 +5739,8 @@ static int io_async_cancel_prep(struct io_kiocb *req,
9407 + return -EINVAL;
9408 + if (unlikely(req->flags & (REQ_F_FIXED_FILE | REQ_F_BUFFER_SELECT)))
9409 + return -EINVAL;
9410 +- if (sqe->ioprio || sqe->off || sqe->len || sqe->cancel_flags)
9411 ++ if (sqe->ioprio || sqe->off || sqe->len || sqe->cancel_flags ||
9412 ++ sqe->splice_fd_in)
9413 + return -EINVAL;
9414 +
9415 + req->cancel.addr = READ_ONCE(sqe->addr);
9416 +@@ -7383,7 +7389,7 @@ static int io_sqe_alloc_file_tables(struct fixed_file_data *file_data,
9417 +
9418 + this_files = min(nr_files, IORING_MAX_FILES_TABLE);
9419 + table->files = kcalloc(this_files, sizeof(struct file *),
9420 +- GFP_KERNEL);
9421 ++ GFP_KERNEL_ACCOUNT);
9422 + if (!table->files)
9423 + break;
9424 + nr_files -= this_files;
9425 +@@ -7579,8 +7585,10 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
9426 + return -EINVAL;
9427 + if (nr_args > IORING_MAX_FIXED_FILES)
9428 + return -EMFILE;
9429 ++ if (nr_args > rlimit(RLIMIT_NOFILE))
9430 ++ return -EMFILE;
9431 +
9432 +- file_data = kzalloc(sizeof(*ctx->file_data), GFP_KERNEL);
9433 ++ file_data = kzalloc(sizeof(*ctx->file_data), GFP_KERNEL_ACCOUNT);
9434 + if (!file_data)
9435 + return -ENOMEM;
9436 + file_data->ctx = ctx;
9437 +@@ -7590,7 +7598,7 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
9438 +
9439 + nr_tables = DIV_ROUND_UP(nr_args, IORING_MAX_FILES_TABLE);
9440 + file_data->table = kcalloc(nr_tables, sizeof(*file_data->table),
9441 +- GFP_KERNEL);
9442 ++ GFP_KERNEL_ACCOUNT);
9443 + if (!file_data->table)
9444 + goto out_free;
9445 +
9446 +diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
9447 +index 10cc7979ce380..caed9d98c64aa 100644
9448 +--- a/fs/iomap/buffered-io.c
9449 ++++ b/fs/iomap/buffered-io.c
9450 +@@ -1045,7 +1045,7 @@ iomap_finish_page_writeback(struct inode *inode, struct page *page,
9451 +
9452 + if (error) {
9453 + SetPageError(page);
9454 +- mapping_set_error(inode->i_mapping, -EIO);
9455 ++ mapping_set_error(inode->i_mapping, error);
9456 + }
9457 +
9458 + WARN_ON_ONCE(i_blocks_per_page(inode, page) > 1 && !iop);
9459 +diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
9460 +index 498cb70c2c0d0..273a81971ed57 100644
9461 +--- a/fs/lockd/svclock.c
9462 ++++ b/fs/lockd/svclock.c
9463 +@@ -395,28 +395,10 @@ nlmsvc_release_lockowner(struct nlm_lock *lock)
9464 + nlmsvc_put_lockowner(lock->fl.fl_owner);
9465 + }
9466 +
9467 +-static void nlmsvc_locks_copy_lock(struct file_lock *new, struct file_lock *fl)
9468 +-{
9469 +- struct nlm_lockowner *nlm_lo = (struct nlm_lockowner *)fl->fl_owner;
9470 +- new->fl_owner = nlmsvc_get_lockowner(nlm_lo);
9471 +-}
9472 +-
9473 +-static void nlmsvc_locks_release_private(struct file_lock *fl)
9474 +-{
9475 +- nlmsvc_put_lockowner((struct nlm_lockowner *)fl->fl_owner);
9476 +-}
9477 +-
9478 +-static const struct file_lock_operations nlmsvc_lock_ops = {
9479 +- .fl_copy_lock = nlmsvc_locks_copy_lock,
9480 +- .fl_release_private = nlmsvc_locks_release_private,
9481 +-};
9482 +-
9483 + void nlmsvc_locks_init_private(struct file_lock *fl, struct nlm_host *host,
9484 + pid_t pid)
9485 + {
9486 + fl->fl_owner = nlmsvc_find_lockowner(host, pid);
9487 +- if (fl->fl_owner != NULL)
9488 +- fl->fl_ops = &nlmsvc_lock_ops;
9489 + }
9490 +
9491 + /*
9492 +@@ -788,9 +770,21 @@ nlmsvc_notify_blocked(struct file_lock *fl)
9493 + printk(KERN_WARNING "lockd: notification for unknown block!\n");
9494 + }
9495 +
9496 ++static fl_owner_t nlmsvc_get_owner(fl_owner_t owner)
9497 ++{
9498 ++ return nlmsvc_get_lockowner(owner);
9499 ++}
9500 ++
9501 ++static void nlmsvc_put_owner(fl_owner_t owner)
9502 ++{
9503 ++ nlmsvc_put_lockowner(owner);
9504 ++}
9505 ++
9506 + const struct lock_manager_operations nlmsvc_lock_operations = {
9507 + .lm_notify = nlmsvc_notify_blocked,
9508 + .lm_grant = nlmsvc_grant_deferred,
9509 ++ .lm_get_owner = nlmsvc_get_owner,
9510 ++ .lm_put_owner = nlmsvc_put_owner,
9511 + };
9512 +
9513 + /*
9514 +diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
9515 +index 371665e0c154c..5370e082aded5 100644
9516 +--- a/fs/nfs/pnfs.c
9517 ++++ b/fs/nfs/pnfs.c
9518 +@@ -335,7 +335,7 @@ static bool pnfs_seqid_is_newer(u32 s1, u32 s2)
9519 +
9520 + static void pnfs_barrier_update(struct pnfs_layout_hdr *lo, u32 newseq)
9521 + {
9522 +- if (pnfs_seqid_is_newer(newseq, lo->plh_barrier))
9523 ++ if (pnfs_seqid_is_newer(newseq, lo->plh_barrier) || !lo->plh_barrier)
9524 + lo->plh_barrier = newseq;
9525 + }
9526 +
9527 +@@ -347,11 +347,15 @@ pnfs_set_plh_return_info(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode,
9528 + iomode = IOMODE_ANY;
9529 + lo->plh_return_iomode = iomode;
9530 + set_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags);
9531 +- if (seq != 0) {
9532 +- WARN_ON_ONCE(lo->plh_return_seq != 0 && lo->plh_return_seq != seq);
9533 ++ /*
9534 ++ * We must set lo->plh_return_seq to avoid livelocks with
9535 ++ * pnfs_layout_need_return()
9536 ++ */
9537 ++ if (seq == 0)
9538 ++ seq = be32_to_cpu(lo->plh_stateid.seqid);
9539 ++ if (!lo->plh_return_seq || pnfs_seqid_is_newer(seq, lo->plh_return_seq))
9540 + lo->plh_return_seq = seq;
9541 +- pnfs_barrier_update(lo, seq);
9542 +- }
9543 ++ pnfs_barrier_update(lo, seq);
9544 + }
9545 +
9546 + static void
9547 +@@ -1000,7 +1004,7 @@ pnfs_layout_stateid_blocked(const struct pnfs_layout_hdr *lo,
9548 + {
9549 + u32 seqid = be32_to_cpu(stateid->seqid);
9550 +
9551 +- return !pnfs_seqid_is_newer(seqid, lo->plh_barrier) && lo->plh_barrier;
9552 ++ return lo->plh_barrier && pnfs_seqid_is_newer(lo->plh_barrier, seqid);
9553 + }
9554 +
9555 + /* lget is set to 1 if called from inside send_layoutget call chain */
9556 +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
9557 +index 142aac9b63a89..0313390fa4b44 100644
9558 +--- a/fs/nfsd/nfs4state.c
9559 ++++ b/fs/nfsd/nfs4state.c
9560 +@@ -6855,8 +6855,7 @@ out:
9561 + /*
9562 + * The NFSv4 spec allows a client to do a LOCKT without holding an OPEN,
9563 + * so we do a temporary open here just to get an open file to pass to
9564 +- * vfs_test_lock. (Arguably perhaps test_lock should be done with an
9565 +- * inode operation.)
9566 ++ * vfs_test_lock.
9567 + */
9568 + static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
9569 + {
9570 +@@ -6871,7 +6870,9 @@ static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct
9571 + NFSD_MAY_READ));
9572 + if (err)
9573 + goto out;
9574 ++ lock->fl_file = nf->nf_file;
9575 + err = nfserrno(vfs_test_lock(nf->nf_file, lock));
9576 ++ lock->fl_file = NULL;
9577 + out:
9578 + fh_unlock(fhp);
9579 + nfsd_file_put(nf);
9580 +diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
9581 +index 1192c99536200..c3af99e94f1d1 100644
9582 +--- a/fs/notify/fanotify/fanotify.c
9583 ++++ b/fs/notify/fanotify/fanotify.c
9584 +@@ -129,11 +129,15 @@ static bool fanotify_should_merge(struct fsnotify_event *old_fsn,
9585 + return false;
9586 + }
9587 +
9588 ++/* Limit event merges to limit CPU overhead per event */
9589 ++#define FANOTIFY_MAX_MERGE_EVENTS 128
9590 ++
9591 + /* and the list better be locked by something too! */
9592 + static int fanotify_merge(struct list_head *list, struct fsnotify_event *event)
9593 + {
9594 + struct fsnotify_event *test_event;
9595 + struct fanotify_event *new;
9596 ++ int i = 0;
9597 +
9598 + pr_debug("%s: list=%p event=%p\n", __func__, list, event);
9599 + new = FANOTIFY_E(event);
9600 +@@ -147,6 +151,8 @@ static int fanotify_merge(struct list_head *list, struct fsnotify_event *event)
9601 + return 0;
9602 +
9603 + list_for_each_entry_reverse(test_event, list, list) {
9604 ++ if (++i > FANOTIFY_MAX_MERGE_EVENTS)
9605 ++ break;
9606 + if (fanotify_should_merge(test_event, event)) {
9607 + FANOTIFY_E(test_event)->mask |= new->mask;
9608 + return 1;
9609 +diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
9610 +index d1efa3a5a5032..08b595c526d74 100644
9611 +--- a/fs/overlayfs/dir.c
9612 ++++ b/fs/overlayfs/dir.c
9613 +@@ -542,8 +542,10 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
9614 + goto out_cleanup;
9615 + }
9616 + err = ovl_instantiate(dentry, inode, newdentry, hardlink);
9617 +- if (err)
9618 +- goto out_cleanup;
9619 ++ if (err) {
9620 ++ ovl_cleanup(udir, newdentry);
9621 ++ dput(newdentry);
9622 ++ }
9623 + out_dput:
9624 + dput(upper);
9625 + out_unlock:
9626 +diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
9627 +index 3d181b1a6d567..17397c7532f12 100644
9628 +--- a/fs/userfaultfd.c
9629 ++++ b/fs/userfaultfd.c
9630 +@@ -32,11 +32,6 @@ int sysctl_unprivileged_userfaultfd __read_mostly = 1;
9631 +
9632 + static struct kmem_cache *userfaultfd_ctx_cachep __read_mostly;
9633 +
9634 +-enum userfaultfd_state {
9635 +- UFFD_STATE_WAIT_API,
9636 +- UFFD_STATE_RUNNING,
9637 +-};
9638 +-
9639 + /*
9640 + * Start with fault_pending_wqh and fault_wqh so they're more likely
9641 + * to be in the same cacheline.
9642 +@@ -68,8 +63,6 @@ struct userfaultfd_ctx {
9643 + unsigned int flags;
9644 + /* features requested from the userspace */
9645 + unsigned int features;
9646 +- /* state machine */
9647 +- enum userfaultfd_state state;
9648 + /* released */
9649 + bool released;
9650 + /* memory mappings are changing because of non-cooperative event */
9651 +@@ -103,6 +96,14 @@ struct userfaultfd_wake_range {
9652 + unsigned long len;
9653 + };
9654 +
9655 ++/* internal indication that UFFD_API ioctl was successfully executed */
9656 ++#define UFFD_FEATURE_INITIALIZED (1u << 31)
9657 ++
9658 ++static bool userfaultfd_is_initialized(struct userfaultfd_ctx *ctx)
9659 ++{
9660 ++ return ctx->features & UFFD_FEATURE_INITIALIZED;
9661 ++}
9662 ++
9663 + static int userfaultfd_wake_function(wait_queue_entry_t *wq, unsigned mode,
9664 + int wake_flags, void *key)
9665 + {
9666 +@@ -659,7 +660,6 @@ int dup_userfaultfd(struct vm_area_struct *vma, struct list_head *fcs)
9667 +
9668 + refcount_set(&ctx->refcount, 1);
9669 + ctx->flags = octx->flags;
9670 +- ctx->state = UFFD_STATE_RUNNING;
9671 + ctx->features = octx->features;
9672 + ctx->released = false;
9673 + ctx->mmap_changing = false;
9674 +@@ -936,38 +936,33 @@ static __poll_t userfaultfd_poll(struct file *file, poll_table *wait)
9675 +
9676 + poll_wait(file, &ctx->fd_wqh, wait);
9677 +
9678 +- switch (ctx->state) {
9679 +- case UFFD_STATE_WAIT_API:
9680 ++ if (!userfaultfd_is_initialized(ctx))
9681 + return EPOLLERR;
9682 +- case UFFD_STATE_RUNNING:
9683 +- /*
9684 +- * poll() never guarantees that read won't block.
9685 +- * userfaults can be waken before they're read().
9686 +- */
9687 +- if (unlikely(!(file->f_flags & O_NONBLOCK)))
9688 +- return EPOLLERR;
9689 +- /*
9690 +- * lockless access to see if there are pending faults
9691 +- * __pollwait last action is the add_wait_queue but
9692 +- * the spin_unlock would allow the waitqueue_active to
9693 +- * pass above the actual list_add inside
9694 +- * add_wait_queue critical section. So use a full
9695 +- * memory barrier to serialize the list_add write of
9696 +- * add_wait_queue() with the waitqueue_active read
9697 +- * below.
9698 +- */
9699 +- ret = 0;
9700 +- smp_mb();
9701 +- if (waitqueue_active(&ctx->fault_pending_wqh))
9702 +- ret = EPOLLIN;
9703 +- else if (waitqueue_active(&ctx->event_wqh))
9704 +- ret = EPOLLIN;
9705 +
9706 +- return ret;
9707 +- default:
9708 +- WARN_ON_ONCE(1);
9709 ++ /*
9710 ++ * poll() never guarantees that read won't block.
9711 ++ * userfaults can be waken before they're read().
9712 ++ */
9713 ++ if (unlikely(!(file->f_flags & O_NONBLOCK)))
9714 + return EPOLLERR;
9715 +- }
9716 ++ /*
9717 ++ * lockless access to see if there are pending faults
9718 ++ * __pollwait last action is the add_wait_queue but
9719 ++ * the spin_unlock would allow the waitqueue_active to
9720 ++ * pass above the actual list_add inside
9721 ++ * add_wait_queue critical section. So use a full
9722 ++ * memory barrier to serialize the list_add write of
9723 ++ * add_wait_queue() with the waitqueue_active read
9724 ++ * below.
9725 ++ */
9726 ++ ret = 0;
9727 ++ smp_mb();
9728 ++ if (waitqueue_active(&ctx->fault_pending_wqh))
9729 ++ ret = EPOLLIN;
9730 ++ else if (waitqueue_active(&ctx->event_wqh))
9731 ++ ret = EPOLLIN;
9732 ++
9733 ++ return ret;
9734 + }
9735 +
9736 + static const struct file_operations userfaultfd_fops;
9737 +@@ -1161,7 +1156,7 @@ static ssize_t userfaultfd_read(struct file *file, char __user *buf,
9738 + struct uffd_msg msg;
9739 + int no_wait = file->f_flags & O_NONBLOCK;
9740 +
9741 +- if (ctx->state == UFFD_STATE_WAIT_API)
9742 ++ if (!userfaultfd_is_initialized(ctx))
9743 + return -EINVAL;
9744 +
9745 + for (;;) {
9746 +@@ -1816,9 +1811,10 @@ static int userfaultfd_writeprotect(struct userfaultfd_ctx *ctx,
9747 + static inline unsigned int uffd_ctx_features(__u64 user_features)
9748 + {
9749 + /*
9750 +- * For the current set of features the bits just coincide
9751 ++ * For the current set of features the bits just coincide. Set
9752 ++ * UFFD_FEATURE_INITIALIZED to mark the features as enabled.
9753 + */
9754 +- return (unsigned int)user_features;
9755 ++ return (unsigned int)user_features | UFFD_FEATURE_INITIALIZED;
9756 + }
9757 +
9758 + /*
9759 +@@ -1831,12 +1827,10 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx,
9760 + {
9761 + struct uffdio_api uffdio_api;
9762 + void __user *buf = (void __user *)arg;
9763 ++ unsigned int ctx_features;
9764 + int ret;
9765 + __u64 features;
9766 +
9767 +- ret = -EINVAL;
9768 +- if (ctx->state != UFFD_STATE_WAIT_API)
9769 +- goto out;
9770 + ret = -EFAULT;
9771 + if (copy_from_user(&uffdio_api, buf, sizeof(uffdio_api)))
9772 + goto out;
9773 +@@ -1853,9 +1847,13 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx,
9774 + ret = -EFAULT;
9775 + if (copy_to_user(buf, &uffdio_api, sizeof(uffdio_api)))
9776 + goto out;
9777 +- ctx->state = UFFD_STATE_RUNNING;
9778 ++
9779 + /* only enable the requested features for this uffd context */
9780 +- ctx->features = uffd_ctx_features(features);
9781 ++ ctx_features = uffd_ctx_features(features);
9782 ++ ret = -EINVAL;
9783 ++ if (cmpxchg(&ctx->features, 0, ctx_features) != 0)
9784 ++ goto err_out;
9785 ++
9786 + ret = 0;
9787 + out:
9788 + return ret;
9789 +@@ -1872,7 +1870,7 @@ static long userfaultfd_ioctl(struct file *file, unsigned cmd,
9790 + int ret = -EINVAL;
9791 + struct userfaultfd_ctx *ctx = file->private_data;
9792 +
9793 +- if (cmd != UFFDIO_API && ctx->state == UFFD_STATE_WAIT_API)
9794 ++ if (cmd != UFFDIO_API && !userfaultfd_is_initialized(ctx))
9795 + return -EINVAL;
9796 +
9797 + switch(cmd) {
9798 +@@ -1976,7 +1974,6 @@ SYSCALL_DEFINE1(userfaultfd, int, flags)
9799 + refcount_set(&ctx->refcount, 1);
9800 + ctx->flags = flags;
9801 + ctx->features = 0;
9802 +- ctx->state = UFFD_STATE_WAIT_API;
9803 + ctx->released = false;
9804 + ctx->mmap_changing = false;
9805 + ctx->mm = current->mm;
9806 +diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
9807 +index 948c5203ca9c6..f5bd80858fc51 100644
9808 +--- a/include/crypto/public_key.h
9809 ++++ b/include/crypto/public_key.h
9810 +@@ -39,9 +39,9 @@ extern void public_key_free(struct public_key *key);
9811 + struct public_key_signature {
9812 + struct asymmetric_key_id *auth_ids[2];
9813 + u8 *s; /* Signature */
9814 +- u32 s_size; /* Number of bytes in signature */
9815 + u8 *digest;
9816 +- u8 digest_size; /* Number of bytes in digest */
9817 ++ u32 s_size; /* Number of bytes in signature */
9818 ++ u32 digest_size; /* Number of bytes in digest */
9819 + const char *pkey_algo;
9820 + const char *hash_algo;
9821 + const char *encoding;
9822 +diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h
9823 +index 6bf8b2b789919..f99d3417f3042 100644
9824 +--- a/include/drm/drm_auth.h
9825 ++++ b/include/drm/drm_auth.h
9826 +@@ -107,6 +107,7 @@ struct drm_master {
9827 + };
9828 +
9829 + struct drm_master *drm_master_get(struct drm_master *master);
9830 ++struct drm_master *drm_file_get_master(struct drm_file *file_priv);
9831 + void drm_master_put(struct drm_master **master);
9832 + bool drm_is_current_master(struct drm_file *fpriv);
9833 +
9834 +diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
9835 +index 716990bace104..42d04607d091f 100644
9836 +--- a/include/drm/drm_file.h
9837 ++++ b/include/drm/drm_file.h
9838 +@@ -226,15 +226,27 @@ struct drm_file {
9839 + /**
9840 + * @master:
9841 + *
9842 +- * Master this node is currently associated with. Only relevant if
9843 +- * drm_is_primary_client() returns true. Note that this only
9844 +- * matches &drm_device.master if the master is the currently active one.
9845 ++ * Master this node is currently associated with. Protected by struct
9846 ++ * &drm_device.master_mutex, and serialized by @master_lookup_lock.
9847 ++ *
9848 ++ * Only relevant if drm_is_primary_client() returns true. Note that
9849 ++ * this only matches &drm_device.master if the master is the currently
9850 ++ * active one.
9851 ++ *
9852 ++ * When dereferencing this pointer, either hold struct
9853 ++ * &drm_device.master_mutex for the duration of the pointer's use, or
9854 ++ * use drm_file_get_master() if struct &drm_device.master_mutex is not
9855 ++ * currently held and there is no other need to hold it. This prevents
9856 ++ * @master from being freed during use.
9857 + *
9858 + * See also @authentication and @is_master and the :ref:`section on
9859 + * primary nodes and authentication <drm_primary_node>`.
9860 + */
9861 + struct drm_master *master;
9862 +
9863 ++ /** @master_lock: Serializes @master. */
9864 ++ spinlock_t master_lookup_lock;
9865 ++
9866 + /** @pid: Process that opened this file. */
9867 + struct pid *pid;
9868 +
9869 +diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
9870 +index 6408b446051f8..b98291d391f34 100644
9871 +--- a/include/linux/ethtool.h
9872 ++++ b/include/linux/ethtool.h
9873 +@@ -17,8 +17,6 @@
9874 + #include <linux/compat.h>
9875 + #include <uapi/linux/ethtool.h>
9876 +
9877 +-#ifdef CONFIG_COMPAT
9878 +-
9879 + struct compat_ethtool_rx_flow_spec {
9880 + u32 flow_type;
9881 + union ethtool_flow_union h_u;
9882 +@@ -38,8 +36,6 @@ struct compat_ethtool_rxnfc {
9883 + u32 rule_locs[];
9884 + };
9885 +
9886 +-#endif /* CONFIG_COMPAT */
9887 +-
9888 + #include <linux/rculist.h>
9889 +
9890 + /**
9891 +diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
9892 +index 5b68c9787f7c2..b9fbb6d4150e2 100644
9893 +--- a/include/linux/hugetlb.h
9894 ++++ b/include/linux/hugetlb.h
9895 +@@ -722,6 +722,11 @@ static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
9896 +
9897 + void hugetlb_report_usage(struct seq_file *m, struct mm_struct *mm);
9898 +
9899 ++static inline void hugetlb_count_init(struct mm_struct *mm)
9900 ++{
9901 ++ atomic_long_set(&mm->hugetlb_usage, 0);
9902 ++}
9903 ++
9904 + static inline void hugetlb_count_add(long l, struct mm_struct *mm)
9905 + {
9906 + atomic_long_add(l, &mm->hugetlb_usage);
9907 +@@ -897,6 +902,10 @@ static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
9908 + return &mm->page_table_lock;
9909 + }
9910 +
9911 ++static inline void hugetlb_count_init(struct mm_struct *mm)
9912 ++{
9913 ++}
9914 ++
9915 + static inline void hugetlb_report_usage(struct seq_file *f, struct mm_struct *m)
9916 + {
9917 + }
9918 +diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h
9919 +index 0bff345c4bc68..171bf1be40115 100644
9920 +--- a/include/linux/hugetlb_cgroup.h
9921 ++++ b/include/linux/hugetlb_cgroup.h
9922 +@@ -118,6 +118,13 @@ static inline void hugetlb_cgroup_put_rsvd_cgroup(struct hugetlb_cgroup *h_cg)
9923 + css_put(&h_cg->css);
9924 + }
9925 +
9926 ++static inline void resv_map_dup_hugetlb_cgroup_uncharge_info(
9927 ++ struct resv_map *resv_map)
9928 ++{
9929 ++ if (resv_map->css)
9930 ++ css_get(resv_map->css);
9931 ++}
9932 ++
9933 + extern int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
9934 + struct hugetlb_cgroup **ptr);
9935 + extern int hugetlb_cgroup_charge_cgroup_rsvd(int idx, unsigned long nr_pages,
9936 +@@ -196,6 +203,11 @@ static inline void hugetlb_cgroup_put_rsvd_cgroup(struct hugetlb_cgroup *h_cg)
9937 + {
9938 + }
9939 +
9940 ++static inline void resv_map_dup_hugetlb_cgroup_uncharge_info(
9941 ++ struct resv_map *resv_map)
9942 ++{
9943 ++}
9944 ++
9945 + static inline int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
9946 + struct hugetlb_cgroup **ptr)
9947 + {
9948 +diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
9949 +index c00ee3458a919..142ec79cda84f 100644
9950 +--- a/include/linux/intel-iommu.h
9951 ++++ b/include/linux/intel-iommu.h
9952 +@@ -122,9 +122,9 @@
9953 + #define DMAR_MTRR_PHYSMASK8_REG 0x208
9954 + #define DMAR_MTRR_PHYSBASE9_REG 0x210
9955 + #define DMAR_MTRR_PHYSMASK9_REG 0x218
9956 +-#define DMAR_VCCAP_REG 0xe00 /* Virtual command capability register */
9957 +-#define DMAR_VCMD_REG 0xe10 /* Virtual command register */
9958 +-#define DMAR_VCRSP_REG 0xe20 /* Virtual command response register */
9959 ++#define DMAR_VCCAP_REG 0xe30 /* Virtual command capability register */
9960 ++#define DMAR_VCMD_REG 0xe00 /* Virtual command register */
9961 ++#define DMAR_VCRSP_REG 0xe10 /* Virtual command response register */
9962 +
9963 + #define OFFSET_STRIDE (9)
9964 +
9965 +diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
9966 +index 0d7013da818cb..095b3b39bd032 100644
9967 +--- a/include/linux/rcupdate.h
9968 ++++ b/include/linux/rcupdate.h
9969 +@@ -163,7 +163,7 @@ void synchronize_rcu_tasks(void);
9970 + # define synchronize_rcu_tasks synchronize_rcu
9971 + # endif
9972 +
9973 +-# ifdef CONFIG_TASKS_RCU_TRACE
9974 ++# ifdef CONFIG_TASKS_TRACE_RCU
9975 + # define rcu_tasks_trace_qs(t) \
9976 + do { \
9977 + if (!likely(READ_ONCE((t)->trc_reader_checked)) && \
9978 +diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
9979 +index cad1fa2b6baa2..e7b997d6f0313 100644
9980 +--- a/include/linux/sunrpc/xprt.h
9981 ++++ b/include/linux/sunrpc/xprt.h
9982 +@@ -421,6 +421,7 @@ void xprt_unlock_connect(struct rpc_xprt *, void *);
9983 + #define XPRT_CONGESTED (9)
9984 + #define XPRT_CWND_WAIT (10)
9985 + #define XPRT_WRITE_SPACE (11)
9986 ++#define XPRT_SND_IS_COOKIE (12)
9987 +
9988 + static inline void xprt_set_connected(struct rpc_xprt *xprt)
9989 + {
9990 +diff --git a/include/linux/sunrpc/xprtsock.h b/include/linux/sunrpc/xprtsock.h
9991 +index 3c1423ee74b4e..8c2a712cb2420 100644
9992 +--- a/include/linux/sunrpc/xprtsock.h
9993 ++++ b/include/linux/sunrpc/xprtsock.h
9994 +@@ -10,6 +10,7 @@
9995 +
9996 + int init_socket_xprt(void);
9997 + void cleanup_socket_xprt(void);
9998 ++unsigned short get_srcport(struct rpc_xprt *);
9999 +
10000 + #define RPC_MIN_RESVPORT (1U)
10001 + #define RPC_MAX_RESVPORT (65535U)
10002 +diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
10003 +index 123b1e9ea304a..010d581598873 100644
10004 +--- a/include/net/flow_offload.h
10005 ++++ b/include/net/flow_offload.h
10006 +@@ -444,6 +444,7 @@ struct flow_block_offload {
10007 + struct list_head *driver_block_list;
10008 + struct netlink_ext_ack *extack;
10009 + struct Qdisc *sch;
10010 ++ struct list_head *cb_list_head;
10011 + };
10012 +
10013 + enum tc_setup_type;
10014 +diff --git a/include/uapi/linux/serial_reg.h b/include/uapi/linux/serial_reg.h
10015 +index be07b5470f4bb..f51bc8f368134 100644
10016 +--- a/include/uapi/linux/serial_reg.h
10017 ++++ b/include/uapi/linux/serial_reg.h
10018 +@@ -62,6 +62,7 @@
10019 + * ST16C654: 8 16 56 60 8 16 32 56 PORT_16654
10020 + * TI16C750: 1 16 32 56 xx xx xx xx PORT_16750
10021 + * TI16C752: 8 16 56 60 8 16 32 56
10022 ++ * OX16C950: 16 32 112 120 16 32 64 112 PORT_16C950
10023 + * Tegra: 1 4 8 14 16 8 4 1 PORT_TEGRA
10024 + */
10025 + #define UART_FCR_R_TRIG_00 0x00
10026 +diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
10027 +index 14de1271463fd..4457545299177 100644
10028 +--- a/kernel/dma/debug.c
10029 ++++ b/kernel/dma/debug.c
10030 +@@ -794,7 +794,7 @@ static int dump_show(struct seq_file *seq, void *v)
10031 + }
10032 + DEFINE_SHOW_ATTRIBUTE(dump);
10033 +
10034 +-static void dma_debug_fs_init(void)
10035 ++static int __init dma_debug_fs_init(void)
10036 + {
10037 + struct dentry *dentry = debugfs_create_dir("dma-api", NULL);
10038 +
10039 +@@ -807,7 +807,10 @@ static void dma_debug_fs_init(void)
10040 + debugfs_create_u32("nr_total_entries", 0444, dentry, &nr_total_entries);
10041 + debugfs_create_file("driver_filter", 0644, dentry, NULL, &filter_fops);
10042 + debugfs_create_file("dump", 0444, dentry, NULL, &dump_fops);
10043 ++
10044 ++ return 0;
10045 + }
10046 ++core_initcall_sync(dma_debug_fs_init);
10047 +
10048 + static int device_dma_allocations(struct device *dev, struct dma_debug_entry **out_entry)
10049 + {
10050 +@@ -892,8 +895,6 @@ static int dma_debug_init(void)
10051 + spin_lock_init(&dma_entry_hash[i].lock);
10052 + }
10053 +
10054 +- dma_debug_fs_init();
10055 +-
10056 + nr_pages = DIV_ROUND_UP(nr_prealloc_entries, DMA_DEBUG_DYNAMIC_ENTRIES);
10057 + for (i = 0; i < nr_pages; ++i)
10058 + dma_debug_create_entries(GFP_KERNEL);
10059 +diff --git a/kernel/fork.c b/kernel/fork.c
10060 +index 9705439439fe3..3f96400a0ac61 100644
10061 +--- a/kernel/fork.c
10062 ++++ b/kernel/fork.c
10063 +@@ -1037,6 +1037,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
10064 + mm->pmd_huge_pte = NULL;
10065 + #endif
10066 + mm_init_uprobes_state(mm);
10067 ++ hugetlb_count_init(mm);
10068 +
10069 + if (current->mm) {
10070 + mm->flags = current->mm->flags & MMF_INIT_MASK;
10071 +diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
10072 +index 9de21803a8ae2..ef8733e2a476e 100644
10073 +--- a/kernel/pid_namespace.c
10074 ++++ b/kernel/pid_namespace.c
10075 +@@ -51,7 +51,8 @@ static struct kmem_cache *create_pid_cachep(unsigned int level)
10076 + mutex_lock(&pid_caches_mutex);
10077 + /* Name collision forces to do allocation under mutex. */
10078 + if (!*pkc)
10079 +- *pkc = kmem_cache_create(name, len, 0, SLAB_HWCACHE_ALIGN, 0);
10080 ++ *pkc = kmem_cache_create(name, len, 0,
10081 ++ SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT, 0);
10082 + mutex_unlock(&pid_caches_mutex);
10083 + /* current can fail, but someone else can succeed. */
10084 + return READ_ONCE(*pkc);
10085 +diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
10086 +index 574aeaac9272d..c5091aeaa37bb 100644
10087 +--- a/kernel/rcu/tree_plugin.h
10088 ++++ b/kernel/rcu/tree_plugin.h
10089 +@@ -2591,17 +2591,17 @@ static void noinstr rcu_dynticks_task_exit(void)
10090 + /* Turn on heavyweight RCU tasks trace readers on idle/user entry. */
10091 + static void rcu_dynticks_task_trace_enter(void)
10092 + {
10093 +-#ifdef CONFIG_TASKS_RCU_TRACE
10094 ++#ifdef CONFIG_TASKS_TRACE_RCU
10095 + if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB))
10096 + current->trc_reader_special.b.need_mb = true;
10097 +-#endif /* #ifdef CONFIG_TASKS_RCU_TRACE */
10098 ++#endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
10099 + }
10100 +
10101 + /* Turn off heavyweight RCU tasks trace readers on idle/user exit. */
10102 + static void rcu_dynticks_task_trace_exit(void)
10103 + {
10104 +-#ifdef CONFIG_TASKS_RCU_TRACE
10105 ++#ifdef CONFIG_TASKS_TRACE_RCU
10106 + if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB))
10107 + current->trc_reader_special.b.need_mb = false;
10108 +-#endif /* #ifdef CONFIG_TASKS_RCU_TRACE */
10109 ++#endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
10110 + }
10111 +diff --git a/kernel/workqueue.c b/kernel/workqueue.c
10112 +index 51d19fc71e616..4cb622b2661b5 100644
10113 +--- a/kernel/workqueue.c
10114 ++++ b/kernel/workqueue.c
10115 +@@ -5893,6 +5893,13 @@ static void __init wq_numa_init(void)
10116 + return;
10117 + }
10118 +
10119 ++ for_each_possible_cpu(cpu) {
10120 ++ if (WARN_ON(cpu_to_node(cpu) == NUMA_NO_NODE)) {
10121 ++ pr_warn("workqueue: NUMA node mapping not available for cpu%d, disabling NUMA support\n", cpu);
10122 ++ return;
10123 ++ }
10124 ++ }
10125 ++
10126 + wq_update_unbound_numa_attrs_buf = alloc_workqueue_attrs();
10127 + BUG_ON(!wq_update_unbound_numa_attrs_buf);
10128 +
10129 +@@ -5910,11 +5917,6 @@ static void __init wq_numa_init(void)
10130 +
10131 + for_each_possible_cpu(cpu) {
10132 + node = cpu_to_node(cpu);
10133 +- if (WARN_ON(node == NUMA_NO_NODE)) {
10134 +- pr_warn("workqueue: NUMA node mapping not available for cpu%d, disabling NUMA support\n", cpu);
10135 +- /* happens iff arch is bonkers, let's just proceed */
10136 +- return;
10137 +- }
10138 + cpumask_set_cpu(cpu, tbl[node]);
10139 + }
10140 +
10141 +diff --git a/lib/test_bpf.c b/lib/test_bpf.c
10142 +index ca7d635bccd9d..4a9137c8551ad 100644
10143 +--- a/lib/test_bpf.c
10144 ++++ b/lib/test_bpf.c
10145 +@@ -4286,8 +4286,8 @@ static struct bpf_test tests[] = {
10146 + .u.insns_int = {
10147 + BPF_LD_IMM64(R0, 0),
10148 + BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
10149 +- BPF_STX_MEM(BPF_W, R10, R1, -40),
10150 +- BPF_LDX_MEM(BPF_W, R0, R10, -40),
10151 ++ BPF_STX_MEM(BPF_DW, R10, R1, -40),
10152 ++ BPF_LDX_MEM(BPF_DW, R0, R10, -40),
10153 + BPF_EXIT_INSN(),
10154 + },
10155 + INTERNAL,
10156 +@@ -6664,7 +6664,14 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
10157 + u64 duration;
10158 + u32 ret;
10159 +
10160 +- if (test->test[i].data_size == 0 &&
10161 ++ /*
10162 ++ * NOTE: Several sub-tests may be present, in which case
10163 ++ * a zero {data_size, result} tuple indicates the end of
10164 ++ * the sub-test array. The first test is always run,
10165 ++ * even if both data_size and result happen to be zero.
10166 ++ */
10167 ++ if (i > 0 &&
10168 ++ test->test[i].data_size == 0 &&
10169 + test->test[i].result == 0)
10170 + break;
10171 +
10172 +diff --git a/lib/test_stackinit.c b/lib/test_stackinit.c
10173 +index f93b1e145ada7..16b1d3a3a4975 100644
10174 +--- a/lib/test_stackinit.c
10175 ++++ b/lib/test_stackinit.c
10176 +@@ -67,10 +67,10 @@ static bool range_contains(char *haystack_start, size_t haystack_size,
10177 + #define INIT_STRUCT_none /**/
10178 + #define INIT_STRUCT_zero = { }
10179 + #define INIT_STRUCT_static_partial = { .two = 0, }
10180 +-#define INIT_STRUCT_static_all = { .one = arg->one, \
10181 +- .two = arg->two, \
10182 +- .three = arg->three, \
10183 +- .four = arg->four, \
10184 ++#define INIT_STRUCT_static_all = { .one = 0, \
10185 ++ .two = 0, \
10186 ++ .three = 0, \
10187 ++ .four = 0, \
10188 + }
10189 + #define INIT_STRUCT_dynamic_partial = { .two = arg->two, }
10190 + #define INIT_STRUCT_dynamic_all = { .one = arg->one, \
10191 +@@ -84,8 +84,7 @@ static bool range_contains(char *haystack_start, size_t haystack_size,
10192 + var.one = 0; \
10193 + var.two = 0; \
10194 + var.three = 0; \
10195 +- memset(&var.four, 0, \
10196 +- sizeof(var.four))
10197 ++ var.four = 0
10198 +
10199 + /*
10200 + * @name: unique string name for the test
10201 +@@ -210,18 +209,13 @@ struct test_small_hole {
10202 + unsigned long four;
10203 + };
10204 +
10205 +-/* Try to trigger unhandled padding in a structure. */
10206 +-struct test_aligned {
10207 +- u32 internal1;
10208 +- u64 internal2;
10209 +-} __aligned(64);
10210 +-
10211 ++/* Trigger unhandled padding in a structure. */
10212 + struct test_big_hole {
10213 + u8 one;
10214 + u8 two;
10215 + u8 three;
10216 + /* 61 byte padding hole here. */
10217 +- struct test_aligned four;
10218 ++ u8 four __aligned(64);
10219 + } __aligned(64);
10220 +
10221 + struct test_trailing_hole {
10222 +diff --git a/mm/hmm.c b/mm/hmm.c
10223 +index 943cb2ba44423..fb617054f9631 100644
10224 +--- a/mm/hmm.c
10225 ++++ b/mm/hmm.c
10226 +@@ -291,10 +291,13 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,
10227 + goto fault;
10228 +
10229 + /*
10230 ++ * Bypass devmap pte such as DAX page when all pfn requested
10231 ++ * flags(pfn_req_flags) are fulfilled.
10232 + * Since each architecture defines a struct page for the zero page, just
10233 + * fall through and treat it like a normal page.
10234 + */
10235 +- if (pte_special(pte) && !is_zero_pfn(pte_pfn(pte))) {
10236 ++ if (pte_special(pte) && !pte_devmap(pte) &&
10237 ++ !is_zero_pfn(pte_pfn(pte))) {
10238 + if (hmm_pte_need_fault(hmm_vma_walk, pfn_req_flags, 0)) {
10239 + pte_unmap(ptep);
10240 + return -EFAULT;
10241 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
10242 +index fa6b0ac6c280d..6e92ab0ae070f 100644
10243 +--- a/mm/hugetlb.c
10244 ++++ b/mm/hugetlb.c
10245 +@@ -3659,8 +3659,10 @@ static void hugetlb_vm_op_open(struct vm_area_struct *vma)
10246 + * after this open call completes. It is therefore safe to take a
10247 + * new reference here without additional locking.
10248 + */
10249 +- if (resv && is_vma_resv_set(vma, HPAGE_RESV_OWNER))
10250 ++ if (resv && is_vma_resv_set(vma, HPAGE_RESV_OWNER)) {
10251 ++ resv_map_dup_hugetlb_cgroup_uncharge_info(resv);
10252 + kref_get(&resv->refs);
10253 ++ }
10254 + }
10255 +
10256 + static void hugetlb_vm_op_close(struct vm_area_struct *vma)
10257 +diff --git a/mm/vmscan.c b/mm/vmscan.c
10258 +index 7fb9af001ed5c..f2817e80a1ab3 100644
10259 +--- a/mm/vmscan.c
10260 ++++ b/mm/vmscan.c
10261 +@@ -2378,7 +2378,7 @@ out:
10262 + cgroup_size = max(cgroup_size, protection);
10263 +
10264 + scan = lruvec_size - lruvec_size * protection /
10265 +- cgroup_size;
10266 ++ (cgroup_size + 1);
10267 +
10268 + /*
10269 + * Minimally target SWAP_CLUSTER_MAX pages to keep
10270 +diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
10271 +index f4fea28e05da6..3ec1a51a6944e 100644
10272 +--- a/net/9p/trans_xen.c
10273 ++++ b/net/9p/trans_xen.c
10274 +@@ -138,7 +138,7 @@ static bool p9_xen_write_todo(struct xen_9pfs_dataring *ring, RING_IDX size)
10275 +
10276 + static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req)
10277 + {
10278 +- struct xen_9pfs_front_priv *priv = NULL;
10279 ++ struct xen_9pfs_front_priv *priv;
10280 + RING_IDX cons, prod, masked_cons, masked_prod;
10281 + unsigned long flags;
10282 + u32 size = p9_req->tc.size;
10283 +@@ -151,7 +151,7 @@ static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req)
10284 + break;
10285 + }
10286 + read_unlock(&xen_9pfs_lock);
10287 +- if (!priv || priv->client != client)
10288 ++ if (list_entry_is_head(priv, &xen_9pfs_devs, list))
10289 + return -EINVAL;
10290 +
10291 + num = p9_req->tc.tag % priv->num_rings;
10292 +diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
10293 +index e59ae24a8f17f..9f52145bb7b76 100644
10294 +--- a/net/bluetooth/hci_event.c
10295 ++++ b/net/bluetooth/hci_event.c
10296 +@@ -4329,6 +4329,21 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,
10297 +
10298 + switch (ev->status) {
10299 + case 0x00:
10300 ++ /* The synchronous connection complete event should only be
10301 ++ * sent once per new connection. Receiving a successful
10302 ++ * complete event when the connection status is already
10303 ++ * BT_CONNECTED means that the device is misbehaving and sent
10304 ++ * multiple complete event packets for the same new connection.
10305 ++ *
10306 ++ * Registering the device more than once can corrupt kernel
10307 ++ * memory, hence upon detecting this invalid event, we report
10308 ++ * an error and ignore the packet.
10309 ++ */
10310 ++ if (conn->state == BT_CONNECTED) {
10311 ++ bt_dev_err(hdev, "Ignoring connect complete event for existing connection");
10312 ++ goto unlock;
10313 ++ }
10314 ++
10315 + conn->handle = __le16_to_cpu(ev->handle);
10316 + conn->state = BT_CONNECTED;
10317 + conn->type = ev->link_type;
10318 +@@ -5055,9 +5070,64 @@ static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev,
10319 + }
10320 + #endif
10321 +
10322 ++static void le_conn_update_addr(struct hci_conn *conn, bdaddr_t *bdaddr,
10323 ++ u8 bdaddr_type, bdaddr_t *local_rpa)
10324 ++{
10325 ++ if (conn->out) {
10326 ++ conn->dst_type = bdaddr_type;
10327 ++ conn->resp_addr_type = bdaddr_type;
10328 ++ bacpy(&conn->resp_addr, bdaddr);
10329 ++
10330 ++ /* Check if the controller has set a Local RPA then it must be
10331 ++ * used instead or hdev->rpa.
10332 ++ */
10333 ++ if (local_rpa && bacmp(local_rpa, BDADDR_ANY)) {
10334 ++ conn->init_addr_type = ADDR_LE_DEV_RANDOM;
10335 ++ bacpy(&conn->init_addr, local_rpa);
10336 ++ } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) {
10337 ++ conn->init_addr_type = ADDR_LE_DEV_RANDOM;
10338 ++ bacpy(&conn->init_addr, &conn->hdev->rpa);
10339 ++ } else {
10340 ++ hci_copy_identity_address(conn->hdev, &conn->init_addr,
10341 ++ &conn->init_addr_type);
10342 ++ }
10343 ++ } else {
10344 ++ conn->resp_addr_type = conn->hdev->adv_addr_type;
10345 ++ /* Check if the controller has set a Local RPA then it must be
10346 ++ * used instead or hdev->rpa.
10347 ++ */
10348 ++ if (local_rpa && bacmp(local_rpa, BDADDR_ANY)) {
10349 ++ conn->resp_addr_type = ADDR_LE_DEV_RANDOM;
10350 ++ bacpy(&conn->resp_addr, local_rpa);
10351 ++ } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) {
10352 ++ /* In case of ext adv, resp_addr will be updated in
10353 ++ * Adv Terminated event.
10354 ++ */
10355 ++ if (!ext_adv_capable(conn->hdev))
10356 ++ bacpy(&conn->resp_addr,
10357 ++ &conn->hdev->random_addr);
10358 ++ } else {
10359 ++ bacpy(&conn->resp_addr, &conn->hdev->bdaddr);
10360 ++ }
10361 ++
10362 ++ conn->init_addr_type = bdaddr_type;
10363 ++ bacpy(&conn->init_addr, bdaddr);
10364 ++
10365 ++ /* For incoming connections, set the default minimum
10366 ++ * and maximum connection interval. They will be used
10367 ++ * to check if the parameters are in range and if not
10368 ++ * trigger the connection update procedure.
10369 ++ */
10370 ++ conn->le_conn_min_interval = conn->hdev->le_conn_min_interval;
10371 ++ conn->le_conn_max_interval = conn->hdev->le_conn_max_interval;
10372 ++ }
10373 ++}
10374 ++
10375 + static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
10376 +- bdaddr_t *bdaddr, u8 bdaddr_type, u8 role, u16 handle,
10377 +- u16 interval, u16 latency, u16 supervision_timeout)
10378 ++ bdaddr_t *bdaddr, u8 bdaddr_type,
10379 ++ bdaddr_t *local_rpa, u8 role, u16 handle,
10380 ++ u16 interval, u16 latency,
10381 ++ u16 supervision_timeout)
10382 + {
10383 + struct hci_conn_params *params;
10384 + struct hci_conn *conn;
10385 +@@ -5105,32 +5175,7 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
10386 + cancel_delayed_work(&conn->le_conn_timeout);
10387 + }
10388 +
10389 +- if (!conn->out) {
10390 +- /* Set the responder (our side) address type based on
10391 +- * the advertising address type.
10392 +- */
10393 +- conn->resp_addr_type = hdev->adv_addr_type;
10394 +- if (hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) {
10395 +- /* In case of ext adv, resp_addr will be updated in
10396 +- * Adv Terminated event.
10397 +- */
10398 +- if (!ext_adv_capable(hdev))
10399 +- bacpy(&conn->resp_addr, &hdev->random_addr);
10400 +- } else {
10401 +- bacpy(&conn->resp_addr, &hdev->bdaddr);
10402 +- }
10403 +-
10404 +- conn->init_addr_type = bdaddr_type;
10405 +- bacpy(&conn->init_addr, bdaddr);
10406 +-
10407 +- /* For incoming connections, set the default minimum
10408 +- * and maximum connection interval. They will be used
10409 +- * to check if the parameters are in range and if not
10410 +- * trigger the connection update procedure.
10411 +- */
10412 +- conn->le_conn_min_interval = hdev->le_conn_min_interval;
10413 +- conn->le_conn_max_interval = hdev->le_conn_max_interval;
10414 +- }
10415 ++ le_conn_update_addr(conn, bdaddr, bdaddr_type, local_rpa);
10416 +
10417 + /* Lookup the identity address from the stored connection
10418 + * address and address type.
10419 +@@ -5224,7 +5269,7 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
10420 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
10421 +
10422 + le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type,
10423 +- ev->role, le16_to_cpu(ev->handle),
10424 ++ NULL, ev->role, le16_to_cpu(ev->handle),
10425 + le16_to_cpu(ev->interval),
10426 + le16_to_cpu(ev->latency),
10427 + le16_to_cpu(ev->supervision_timeout));
10428 +@@ -5238,7 +5283,7 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev,
10429 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
10430 +
10431 + le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type,
10432 +- ev->role, le16_to_cpu(ev->handle),
10433 ++ &ev->local_rpa, ev->role, le16_to_cpu(ev->handle),
10434 + le16_to_cpu(ev->interval),
10435 + le16_to_cpu(ev->latency),
10436 + le16_to_cpu(ev->supervision_timeout));
10437 +@@ -5274,7 +5319,8 @@ static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb)
10438 + if (conn) {
10439 + struct adv_info *adv_instance;
10440 +
10441 +- if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM)
10442 ++ if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM ||
10443 ++ bacmp(&conn->resp_addr, BDADDR_ANY))
10444 + return;
10445 +
10446 + if (!hdev->cur_adv_instance) {
10447 +diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
10448 +index 600b1832e1dd6..7c24a9acbc459 100644
10449 +--- a/net/bluetooth/sco.c
10450 ++++ b/net/bluetooth/sco.c
10451 +@@ -48,6 +48,8 @@ struct sco_conn {
10452 + spinlock_t lock;
10453 + struct sock *sk;
10454 +
10455 ++ struct delayed_work timeout_work;
10456 ++
10457 + unsigned int mtu;
10458 + };
10459 +
10460 +@@ -74,9 +76,20 @@ struct sco_pinfo {
10461 + #define SCO_CONN_TIMEOUT (HZ * 40)
10462 + #define SCO_DISCONN_TIMEOUT (HZ * 2)
10463 +
10464 +-static void sco_sock_timeout(struct timer_list *t)
10465 ++static void sco_sock_timeout(struct work_struct *work)
10466 + {
10467 +- struct sock *sk = from_timer(sk, t, sk_timer);
10468 ++ struct sco_conn *conn = container_of(work, struct sco_conn,
10469 ++ timeout_work.work);
10470 ++ struct sock *sk;
10471 ++
10472 ++ sco_conn_lock(conn);
10473 ++ sk = conn->sk;
10474 ++ if (sk)
10475 ++ sock_hold(sk);
10476 ++ sco_conn_unlock(conn);
10477 ++
10478 ++ if (!sk)
10479 ++ return;
10480 +
10481 + BT_DBG("sock %p state %d", sk, sk->sk_state);
10482 +
10483 +@@ -90,14 +103,21 @@ static void sco_sock_timeout(struct timer_list *t)
10484 +
10485 + static void sco_sock_set_timer(struct sock *sk, long timeout)
10486 + {
10487 ++ if (!sco_pi(sk)->conn)
10488 ++ return;
10489 ++
10490 + BT_DBG("sock %p state %d timeout %ld", sk, sk->sk_state, timeout);
10491 +- sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout);
10492 ++ cancel_delayed_work(&sco_pi(sk)->conn->timeout_work);
10493 ++ schedule_delayed_work(&sco_pi(sk)->conn->timeout_work, timeout);
10494 + }
10495 +
10496 + static void sco_sock_clear_timer(struct sock *sk)
10497 + {
10498 ++ if (!sco_pi(sk)->conn)
10499 ++ return;
10500 ++
10501 + BT_DBG("sock %p state %d", sk, sk->sk_state);
10502 +- sk_stop_timer(sk, &sk->sk_timer);
10503 ++ cancel_delayed_work(&sco_pi(sk)->conn->timeout_work);
10504 + }
10505 +
10506 + /* ---- SCO connections ---- */
10507 +@@ -177,6 +197,9 @@ static void sco_conn_del(struct hci_conn *hcon, int err)
10508 + sco_chan_del(sk, err);
10509 + bh_unlock_sock(sk);
10510 + sock_put(sk);
10511 ++
10512 ++ /* Ensure no more work items will run before freeing conn. */
10513 ++ cancel_delayed_work_sync(&conn->timeout_work);
10514 + }
10515 +
10516 + hcon->sco_data = NULL;
10517 +@@ -191,6 +214,8 @@ static void __sco_chan_add(struct sco_conn *conn, struct sock *sk,
10518 + sco_pi(sk)->conn = conn;
10519 + conn->sk = sk;
10520 +
10521 ++ INIT_DELAYED_WORK(&conn->timeout_work, sco_sock_timeout);
10522 ++
10523 + if (parent)
10524 + bt_accept_enqueue(parent, sk, true);
10525 + }
10526 +@@ -210,44 +235,32 @@ static int sco_chan_add(struct sco_conn *conn, struct sock *sk,
10527 + return err;
10528 + }
10529 +
10530 +-static int sco_connect(struct sock *sk)
10531 ++static int sco_connect(struct hci_dev *hdev, struct sock *sk)
10532 + {
10533 + struct sco_conn *conn;
10534 + struct hci_conn *hcon;
10535 +- struct hci_dev *hdev;
10536 + int err, type;
10537 +
10538 + BT_DBG("%pMR -> %pMR", &sco_pi(sk)->src, &sco_pi(sk)->dst);
10539 +
10540 +- hdev = hci_get_route(&sco_pi(sk)->dst, &sco_pi(sk)->src, BDADDR_BREDR);
10541 +- if (!hdev)
10542 +- return -EHOSTUNREACH;
10543 +-
10544 +- hci_dev_lock(hdev);
10545 +-
10546 + if (lmp_esco_capable(hdev) && !disable_esco)
10547 + type = ESCO_LINK;
10548 + else
10549 + type = SCO_LINK;
10550 +
10551 + if (sco_pi(sk)->setting == BT_VOICE_TRANSPARENT &&
10552 +- (!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev))) {
10553 +- err = -EOPNOTSUPP;
10554 +- goto done;
10555 +- }
10556 ++ (!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev)))
10557 ++ return -EOPNOTSUPP;
10558 +
10559 + hcon = hci_connect_sco(hdev, type, &sco_pi(sk)->dst,
10560 + sco_pi(sk)->setting);
10561 +- if (IS_ERR(hcon)) {
10562 +- err = PTR_ERR(hcon);
10563 +- goto done;
10564 +- }
10565 ++ if (IS_ERR(hcon))
10566 ++ return PTR_ERR(hcon);
10567 +
10568 + conn = sco_conn_add(hcon);
10569 + if (!conn) {
10570 + hci_conn_drop(hcon);
10571 +- err = -ENOMEM;
10572 +- goto done;
10573 ++ return -ENOMEM;
10574 + }
10575 +
10576 + /* Update source addr of the socket */
10577 +@@ -255,7 +268,7 @@ static int sco_connect(struct sock *sk)
10578 +
10579 + err = sco_chan_add(conn, sk, NULL);
10580 + if (err)
10581 +- goto done;
10582 ++ return err;
10583 +
10584 + if (hcon->state == BT_CONNECTED) {
10585 + sco_sock_clear_timer(sk);
10586 +@@ -265,9 +278,6 @@ static int sco_connect(struct sock *sk)
10587 + sco_sock_set_timer(sk, sk->sk_sndtimeo);
10588 + }
10589 +
10590 +-done:
10591 +- hci_dev_unlock(hdev);
10592 +- hci_dev_put(hdev);
10593 + return err;
10594 + }
10595 +
10596 +@@ -496,8 +506,6 @@ static struct sock *sco_sock_alloc(struct net *net, struct socket *sock,
10597 +
10598 + sco_pi(sk)->setting = BT_VOICE_CVSD_16BIT;
10599 +
10600 +- timer_setup(&sk->sk_timer, sco_sock_timeout, 0);
10601 +-
10602 + bt_sock_link(&sco_sk_list, sk);
10603 + return sk;
10604 + }
10605 +@@ -562,6 +570,7 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
10606 + {
10607 + struct sockaddr_sco *sa = (struct sockaddr_sco *) addr;
10608 + struct sock *sk = sock->sk;
10609 ++ struct hci_dev *hdev;
10610 + int err;
10611 +
10612 + BT_DBG("sk %p", sk);
10613 +@@ -576,12 +585,19 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
10614 + if (sk->sk_type != SOCK_SEQPACKET)
10615 + return -EINVAL;
10616 +
10617 ++ hdev = hci_get_route(&sa->sco_bdaddr, &sco_pi(sk)->src, BDADDR_BREDR);
10618 ++ if (!hdev)
10619 ++ return -EHOSTUNREACH;
10620 ++ hci_dev_lock(hdev);
10621 ++
10622 + lock_sock(sk);
10623 +
10624 + /* Set destination address and psm */
10625 + bacpy(&sco_pi(sk)->dst, &sa->sco_bdaddr);
10626 +
10627 +- err = sco_connect(sk);
10628 ++ err = sco_connect(hdev, sk);
10629 ++ hci_dev_unlock(hdev);
10630 ++ hci_dev_put(hdev);
10631 + if (err)
10632 + goto done;
10633 +
10634 +diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
10635 +index c52e5ea654e99..813c709c61cfb 100644
10636 +--- a/net/core/flow_dissector.c
10637 ++++ b/net/core/flow_dissector.c
10638 +@@ -1047,8 +1047,10 @@ proto_again:
10639 + FLOW_DISSECTOR_KEY_IPV4_ADDRS,
10640 + target_container);
10641 +
10642 +- memcpy(&key_addrs->v4addrs, &iph->saddr,
10643 +- sizeof(key_addrs->v4addrs));
10644 ++ memcpy(&key_addrs->v4addrs.src, &iph->saddr,
10645 ++ sizeof(key_addrs->v4addrs.src));
10646 ++ memcpy(&key_addrs->v4addrs.dst, &iph->daddr,
10647 ++ sizeof(key_addrs->v4addrs.dst));
10648 + key_control->addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
10649 + }
10650 +
10651 +@@ -1092,8 +1094,10 @@ proto_again:
10652 + FLOW_DISSECTOR_KEY_IPV6_ADDRS,
10653 + target_container);
10654 +
10655 +- memcpy(&key_addrs->v6addrs, &iph->saddr,
10656 +- sizeof(key_addrs->v6addrs));
10657 ++ memcpy(&key_addrs->v6addrs.src, &iph->saddr,
10658 ++ sizeof(key_addrs->v6addrs.src));
10659 ++ memcpy(&key_addrs->v6addrs.dst, &iph->daddr,
10660 ++ sizeof(key_addrs->v6addrs.dst));
10661 + key_control->addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
10662 + }
10663 +
10664 +diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c
10665 +index 715b67f6c62f3..e3f0d59068117 100644
10666 +--- a/net/core/flow_offload.c
10667 ++++ b/net/core/flow_offload.c
10668 +@@ -321,6 +321,7 @@ EXPORT_SYMBOL(flow_block_cb_setup_simple);
10669 + static DEFINE_MUTEX(flow_indr_block_lock);
10670 + static LIST_HEAD(flow_block_indr_list);
10671 + static LIST_HEAD(flow_block_indr_dev_list);
10672 ++static LIST_HEAD(flow_indir_dev_list);
10673 +
10674 + struct flow_indr_dev {
10675 + struct list_head list;
10676 +@@ -346,6 +347,33 @@ static struct flow_indr_dev *flow_indr_dev_alloc(flow_indr_block_bind_cb_t *cb,
10677 + return indr_dev;
10678 + }
10679 +
10680 ++struct flow_indir_dev_info {
10681 ++ void *data;
10682 ++ struct net_device *dev;
10683 ++ struct Qdisc *sch;
10684 ++ enum tc_setup_type type;
10685 ++ void (*cleanup)(struct flow_block_cb *block_cb);
10686 ++ struct list_head list;
10687 ++ enum flow_block_command command;
10688 ++ enum flow_block_binder_type binder_type;
10689 ++ struct list_head *cb_list;
10690 ++};
10691 ++
10692 ++static void existing_qdiscs_register(flow_indr_block_bind_cb_t *cb, void *cb_priv)
10693 ++{
10694 ++ struct flow_block_offload bo;
10695 ++ struct flow_indir_dev_info *cur;
10696 ++
10697 ++ list_for_each_entry(cur, &flow_indir_dev_list, list) {
10698 ++ memset(&bo, 0, sizeof(bo));
10699 ++ bo.command = cur->command;
10700 ++ bo.binder_type = cur->binder_type;
10701 ++ INIT_LIST_HEAD(&bo.cb_list);
10702 ++ cb(cur->dev, cur->sch, cb_priv, cur->type, &bo, cur->data, cur->cleanup);
10703 ++ list_splice(&bo.cb_list, cur->cb_list);
10704 ++ }
10705 ++}
10706 ++
10707 + int flow_indr_dev_register(flow_indr_block_bind_cb_t *cb, void *cb_priv)
10708 + {
10709 + struct flow_indr_dev *indr_dev;
10710 +@@ -367,6 +395,7 @@ int flow_indr_dev_register(flow_indr_block_bind_cb_t *cb, void *cb_priv)
10711 + }
10712 +
10713 + list_add(&indr_dev->list, &flow_block_indr_dev_list);
10714 ++ existing_qdiscs_register(cb, cb_priv);
10715 + mutex_unlock(&flow_indr_block_lock);
10716 +
10717 + return 0;
10718 +@@ -463,7 +492,59 @@ out:
10719 + }
10720 + EXPORT_SYMBOL(flow_indr_block_cb_alloc);
10721 +
10722 +-int flow_indr_dev_setup_offload(struct net_device *dev, struct Qdisc *sch,
10723 ++static struct flow_indir_dev_info *find_indir_dev(void *data)
10724 ++{
10725 ++ struct flow_indir_dev_info *cur;
10726 ++
10727 ++ list_for_each_entry(cur, &flow_indir_dev_list, list) {
10728 ++ if (cur->data == data)
10729 ++ return cur;
10730 ++ }
10731 ++ return NULL;
10732 ++}
10733 ++
10734 ++static int indir_dev_add(void *data, struct net_device *dev, struct Qdisc *sch,
10735 ++ enum tc_setup_type type, void (*cleanup)(struct flow_block_cb *block_cb),
10736 ++ struct flow_block_offload *bo)
10737 ++{
10738 ++ struct flow_indir_dev_info *info;
10739 ++
10740 ++ info = find_indir_dev(data);
10741 ++ if (info)
10742 ++ return -EEXIST;
10743 ++
10744 ++ info = kzalloc(sizeof(*info), GFP_KERNEL);
10745 ++ if (!info)
10746 ++ return -ENOMEM;
10747 ++
10748 ++ info->data = data;
10749 ++ info->dev = dev;
10750 ++ info->sch = sch;
10751 ++ info->type = type;
10752 ++ info->cleanup = cleanup;
10753 ++ info->command = bo->command;
10754 ++ info->binder_type = bo->binder_type;
10755 ++ info->cb_list = bo->cb_list_head;
10756 ++
10757 ++ list_add(&info->list, &flow_indir_dev_list);
10758 ++ return 0;
10759 ++}
10760 ++
10761 ++static int indir_dev_remove(void *data)
10762 ++{
10763 ++ struct flow_indir_dev_info *info;
10764 ++
10765 ++ info = find_indir_dev(data);
10766 ++ if (!info)
10767 ++ return -ENOENT;
10768 ++
10769 ++ list_del(&info->list);
10770 ++
10771 ++ kfree(info);
10772 ++ return 0;
10773 ++}
10774 ++
10775 ++int flow_indr_dev_setup_offload(struct net_device *dev, struct Qdisc *sch,
10776 + enum tc_setup_type type, void *data,
10777 + struct flow_block_offload *bo,
10778 + void (*cleanup)(struct flow_block_cb *block_cb))
10779 +@@ -471,6 +552,12 @@ int flow_indr_dev_setup_offload(struct net_device *dev, struct Qdisc *sch,
10780 + struct flow_indr_dev *this;
10781 +
10782 + mutex_lock(&flow_indr_block_lock);
10783 ++
10784 ++ if (bo->command == FLOW_BLOCK_BIND)
10785 ++ indir_dev_add(data, dev, sch, type, cleanup, bo);
10786 ++ else if (bo->command == FLOW_BLOCK_UNBIND)
10787 ++ indir_dev_remove(data);
10788 ++
10789 + list_for_each_entry(this, &flow_block_indr_dev_list, list)
10790 + this->cb(dev, sch, this->cb_priv, type, bo, data, cleanup);
10791 +
10792 +diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
10793 +index 68ff19af195c6..97b402b2d6fbd 100644
10794 +--- a/net/ethtool/ioctl.c
10795 ++++ b/net/ethtool/ioctl.c
10796 +@@ -7,6 +7,7 @@
10797 + * the information ethtool needs.
10798 + */
10799 +
10800 ++#include <linux/compat.h>
10801 + #include <linux/module.h>
10802 + #include <linux/types.h>
10803 + #include <linux/capability.h>
10804 +@@ -807,6 +808,120 @@ out:
10805 + return ret;
10806 + }
10807 +
10808 ++static noinline_for_stack int
10809 ++ethtool_rxnfc_copy_from_compat(struct ethtool_rxnfc *rxnfc,
10810 ++ const struct compat_ethtool_rxnfc __user *useraddr,
10811 ++ size_t size)
10812 ++{
10813 ++ struct compat_ethtool_rxnfc crxnfc = {};
10814 ++
10815 ++ /* We expect there to be holes between fs.m_ext and
10816 ++ * fs.ring_cookie and at the end of fs, but nowhere else.
10817 ++ * On non-x86, no conversion should be needed.
10818 ++ */
10819 ++ BUILD_BUG_ON(!IS_ENABLED(CONFIG_X86_64) &&
10820 ++ sizeof(struct compat_ethtool_rxnfc) !=
10821 ++ sizeof(struct ethtool_rxnfc));
10822 ++ BUILD_BUG_ON(offsetof(struct compat_ethtool_rxnfc, fs.m_ext) +
10823 ++ sizeof(useraddr->fs.m_ext) !=
10824 ++ offsetof(struct ethtool_rxnfc, fs.m_ext) +
10825 ++ sizeof(rxnfc->fs.m_ext));
10826 ++ BUILD_BUG_ON(offsetof(struct compat_ethtool_rxnfc, fs.location) -
10827 ++ offsetof(struct compat_ethtool_rxnfc, fs.ring_cookie) !=
10828 ++ offsetof(struct ethtool_rxnfc, fs.location) -
10829 ++ offsetof(struct ethtool_rxnfc, fs.ring_cookie));
10830 ++
10831 ++ if (copy_from_user(&crxnfc, useraddr, min(size, sizeof(crxnfc))))
10832 ++ return -EFAULT;
10833 ++
10834 ++ *rxnfc = (struct ethtool_rxnfc) {
10835 ++ .cmd = crxnfc.cmd,
10836 ++ .flow_type = crxnfc.flow_type,
10837 ++ .data = crxnfc.data,
10838 ++ .fs = {
10839 ++ .flow_type = crxnfc.fs.flow_type,
10840 ++ .h_u = crxnfc.fs.h_u,
10841 ++ .h_ext = crxnfc.fs.h_ext,
10842 ++ .m_u = crxnfc.fs.m_u,
10843 ++ .m_ext = crxnfc.fs.m_ext,
10844 ++ .ring_cookie = crxnfc.fs.ring_cookie,
10845 ++ .location = crxnfc.fs.location,
10846 ++ },
10847 ++ .rule_cnt = crxnfc.rule_cnt,
10848 ++ };
10849 ++
10850 ++ return 0;
10851 ++}
10852 ++
10853 ++static int ethtool_rxnfc_copy_from_user(struct ethtool_rxnfc *rxnfc,
10854 ++ const void __user *useraddr,
10855 ++ size_t size)
10856 ++{
10857 ++ if (compat_need_64bit_alignment_fixup())
10858 ++ return ethtool_rxnfc_copy_from_compat(rxnfc, useraddr, size);
10859 ++
10860 ++ if (copy_from_user(rxnfc, useraddr, size))
10861 ++ return -EFAULT;
10862 ++
10863 ++ return 0;
10864 ++}
10865 ++
10866 ++static int ethtool_rxnfc_copy_to_compat(void __user *useraddr,
10867 ++ const struct ethtool_rxnfc *rxnfc,
10868 ++ size_t size, const u32 *rule_buf)
10869 ++{
10870 ++ struct compat_ethtool_rxnfc crxnfc;
10871 ++
10872 ++ memset(&crxnfc, 0, sizeof(crxnfc));
10873 ++ crxnfc = (struct compat_ethtool_rxnfc) {
10874 ++ .cmd = rxnfc->cmd,
10875 ++ .flow_type = rxnfc->flow_type,
10876 ++ .data = rxnfc->data,
10877 ++ .fs = {
10878 ++ .flow_type = rxnfc->fs.flow_type,
10879 ++ .h_u = rxnfc->fs.h_u,
10880 ++ .h_ext = rxnfc->fs.h_ext,
10881 ++ .m_u = rxnfc->fs.m_u,
10882 ++ .m_ext = rxnfc->fs.m_ext,
10883 ++ .ring_cookie = rxnfc->fs.ring_cookie,
10884 ++ .location = rxnfc->fs.location,
10885 ++ },
10886 ++ .rule_cnt = rxnfc->rule_cnt,
10887 ++ };
10888 ++
10889 ++ if (copy_to_user(useraddr, &crxnfc, min(size, sizeof(crxnfc))))
10890 ++ return -EFAULT;
10891 ++
10892 ++ return 0;
10893 ++}
10894 ++
10895 ++static int ethtool_rxnfc_copy_to_user(void __user *useraddr,
10896 ++ const struct ethtool_rxnfc *rxnfc,
10897 ++ size_t size, const u32 *rule_buf)
10898 ++{
10899 ++ int ret;
10900 ++
10901 ++ if (compat_need_64bit_alignment_fixup()) {
10902 ++ ret = ethtool_rxnfc_copy_to_compat(useraddr, rxnfc, size,
10903 ++ rule_buf);
10904 ++ useraddr += offsetof(struct compat_ethtool_rxnfc, rule_locs);
10905 ++ } else {
10906 ++ ret = copy_to_user(useraddr, &rxnfc, size);
10907 ++ useraddr += offsetof(struct ethtool_rxnfc, rule_locs);
10908 ++ }
10909 ++
10910 ++ if (ret)
10911 ++ return -EFAULT;
10912 ++
10913 ++ if (rule_buf) {
10914 ++ if (copy_to_user(useraddr, rule_buf,
10915 ++ rxnfc->rule_cnt * sizeof(u32)))
10916 ++ return -EFAULT;
10917 ++ }
10918 ++
10919 ++ return 0;
10920 ++}
10921 ++
10922 + static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
10923 + u32 cmd, void __user *useraddr)
10924 + {
10925 +@@ -825,7 +940,7 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
10926 + info_size = (offsetof(struct ethtool_rxnfc, data) +
10927 + sizeof(info.data));
10928 +
10929 +- if (copy_from_user(&info, useraddr, info_size))
10930 ++ if (ethtool_rxnfc_copy_from_user(&info, useraddr, info_size))
10931 + return -EFAULT;
10932 +
10933 + rc = dev->ethtool_ops->set_rxnfc(dev, &info);
10934 +@@ -833,7 +948,7 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
10935 + return rc;
10936 +
10937 + if (cmd == ETHTOOL_SRXCLSRLINS &&
10938 +- copy_to_user(useraddr, &info, info_size))
10939 ++ ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, NULL))
10940 + return -EFAULT;
10941 +
10942 + return 0;
10943 +@@ -859,7 +974,7 @@ static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
10944 + info_size = (offsetof(struct ethtool_rxnfc, data) +
10945 + sizeof(info.data));
10946 +
10947 +- if (copy_from_user(&info, useraddr, info_size))
10948 ++ if (ethtool_rxnfc_copy_from_user(&info, useraddr, info_size))
10949 + return -EFAULT;
10950 +
10951 + /* If FLOW_RSS was requested then user-space must be using the
10952 +@@ -867,7 +982,7 @@ static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
10953 + */
10954 + if (cmd == ETHTOOL_GRXFH && info.flow_type & FLOW_RSS) {
10955 + info_size = sizeof(info);
10956 +- if (copy_from_user(&info, useraddr, info_size))
10957 ++ if (ethtool_rxnfc_copy_from_user(&info, useraddr, info_size))
10958 + return -EFAULT;
10959 + /* Since malicious users may modify the original data,
10960 + * we need to check whether FLOW_RSS is still requested.
10961 +@@ -893,18 +1008,7 @@ static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
10962 + if (ret < 0)
10963 + goto err_out;
10964 +
10965 +- ret = -EFAULT;
10966 +- if (copy_to_user(useraddr, &info, info_size))
10967 +- goto err_out;
10968 +-
10969 +- if (rule_buf) {
10970 +- useraddr += offsetof(struct ethtool_rxnfc, rule_locs);
10971 +- if (copy_to_user(useraddr, rule_buf,
10972 +- info.rule_cnt * sizeof(u32)))
10973 +- goto err_out;
10974 +- }
10975 +- ret = 0;
10976 +-
10977 ++ ret = ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, rule_buf);
10978 + err_out:
10979 + kfree(rule_buf);
10980 +
10981 +diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
10982 +index 560d5dc435629..10d4cde31c6bf 100644
10983 +--- a/net/ipv4/ip_output.c
10984 ++++ b/net/ipv4/ip_output.c
10985 +@@ -445,8 +445,9 @@ static void ip_copy_addrs(struct iphdr *iph, const struct flowi4 *fl4)
10986 + {
10987 + BUILD_BUG_ON(offsetof(typeof(*fl4), daddr) !=
10988 + offsetof(typeof(*fl4), saddr) + sizeof(fl4->saddr));
10989 +- memcpy(&iph->saddr, &fl4->saddr,
10990 +- sizeof(fl4->saddr) + sizeof(fl4->daddr));
10991 ++
10992 ++ iph->saddr = fl4->saddr;
10993 ++ iph->daddr = fl4->daddr;
10994 + }
10995 +
10996 + /* Note: skb->sk can be different from sk, in case of tunnels */
10997 +diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
10998 +index d49709ba8e165..1071119843843 100644
10999 +--- a/net/ipv4/tcp_fastopen.c
11000 ++++ b/net/ipv4/tcp_fastopen.c
11001 +@@ -379,8 +379,7 @@ struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb,
11002 + return NULL;
11003 + }
11004 +
11005 +- if (syn_data &&
11006 +- tcp_fastopen_no_cookie(sk, dst, TFO_SERVER_COOKIE_NOT_REQD))
11007 ++ if (tcp_fastopen_no_cookie(sk, dst, TFO_SERVER_COOKIE_NOT_REQD))
11008 + goto fastopen;
11009 +
11010 + if (foc->len == 0) {
11011 +diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
11012 +index 30589b4c09da4..3a15ef8dd3228 100644
11013 +--- a/net/mac80211/iface.c
11014 ++++ b/net/mac80211/iface.c
11015 +@@ -2000,9 +2000,16 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
11016 +
11017 + netdev_set_default_ethtool_ops(ndev, &ieee80211_ethtool_ops);
11018 +
11019 +- /* MTU range: 256 - 2304 */
11020 ++ /* MTU range is normally 256 - 2304, where the upper limit is
11021 ++ * the maximum MSDU size. Monitor interfaces send and receive
11022 ++ * MPDU and A-MSDU frames which may be much larger so we do
11023 ++ * not impose an upper limit in that case.
11024 ++ */
11025 + ndev->min_mtu = 256;
11026 +- ndev->max_mtu = local->hw.max_mtu;
11027 ++ if (type == NL80211_IFTYPE_MONITOR)
11028 ++ ndev->max_mtu = 0;
11029 ++ else
11030 ++ ndev->max_mtu = local->hw.max_mtu;
11031 +
11032 + ret = register_netdevice(ndev);
11033 + if (ret) {
11034 +diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c
11035 +index 92047cea3c170..a6b654b028dd4 100644
11036 +--- a/net/netfilter/nf_flow_table_offload.c
11037 ++++ b/net/netfilter/nf_flow_table_offload.c
11038 +@@ -940,6 +940,7 @@ static void nf_flow_table_block_offload_init(struct flow_block_offload *bo,
11039 + bo->command = cmd;
11040 + bo->binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
11041 + bo->extack = extack;
11042 ++ bo->cb_list_head = &flowtable->flow_block.cb_list;
11043 + INIT_LIST_HEAD(&bo->cb_list);
11044 + }
11045 +
11046 +diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
11047 +index 9ce776175214c..e5fcbb0e4b8e5 100644
11048 +--- a/net/netfilter/nf_tables_offload.c
11049 ++++ b/net/netfilter/nf_tables_offload.c
11050 +@@ -323,6 +323,7 @@ static void nft_flow_block_offload_init(struct flow_block_offload *bo,
11051 + bo->command = cmd;
11052 + bo->binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
11053 + bo->extack = extack;
11054 ++ bo->cb_list_head = &basechain->flow_block.cb_list;
11055 + INIT_LIST_HEAD(&bo->cb_list);
11056 + }
11057 +
11058 +diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
11059 +index 50f40943c8153..f3f1df1b0f8e2 100644
11060 +--- a/net/netlabel/netlabel_cipso_v4.c
11061 ++++ b/net/netlabel/netlabel_cipso_v4.c
11062 +@@ -144,8 +144,8 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
11063 + return -ENOMEM;
11064 + doi_def->map.std = kzalloc(sizeof(*doi_def->map.std), GFP_KERNEL);
11065 + if (doi_def->map.std == NULL) {
11066 +- ret_val = -ENOMEM;
11067 +- goto add_std_failure;
11068 ++ kfree(doi_def);
11069 ++ return -ENOMEM;
11070 + }
11071 + doi_def->type = CIPSO_V4_MAP_TRANS;
11072 +
11073 +diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
11074 +index e527f5686e2bf..8434da3c0487a 100644
11075 +--- a/net/netlink/af_netlink.c
11076 ++++ b/net/netlink/af_netlink.c
11077 +@@ -2537,13 +2537,15 @@ int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 portid,
11078 + /* errors reported via destination sk->sk_err, but propagate
11079 + * delivery errors if NETLINK_BROADCAST_ERROR flag is set */
11080 + err = nlmsg_multicast(sk, skb, exclude_portid, group, flags);
11081 ++ if (err == -ESRCH)
11082 ++ err = 0;
11083 + }
11084 +
11085 + if (report) {
11086 + int err2;
11087 +
11088 + err2 = nlmsg_unicast(sk, skb, portid);
11089 +- if (!err || err == -ESRCH)
11090 ++ if (!err)
11091 + err = err2;
11092 + }
11093 +
11094 +diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
11095 +index 31ac76a9189ee..8073657a0fd25 100644
11096 +--- a/net/sched/cls_api.c
11097 ++++ b/net/sched/cls_api.c
11098 +@@ -634,6 +634,7 @@ static void tcf_block_offload_init(struct flow_block_offload *bo,
11099 + bo->block_shared = shared;
11100 + bo->extack = extack;
11101 + bo->sch = sch;
11102 ++ bo->cb_list_head = &flow_block->cb_list;
11103 + INIT_LIST_HEAD(&bo->cb_list);
11104 + }
11105 +
11106 +diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
11107 +index 00853065dfa06..cb5e5220da552 100644
11108 +--- a/net/sched/sch_taprio.c
11109 ++++ b/net/sched/sch_taprio.c
11110 +@@ -1502,7 +1502,9 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
11111 + taprio_set_picos_per_byte(dev, q);
11112 +
11113 + if (mqprio) {
11114 +- netdev_set_num_tc(dev, mqprio->num_tc);
11115 ++ err = netdev_set_num_tc(dev, mqprio->num_tc);
11116 ++ if (err)
11117 ++ goto free_sched;
11118 + for (i = 0; i < mqprio->num_tc; i++)
11119 + netdev_set_tc_queue(dev, i,
11120 + mqprio->count[i],
11121 +diff --git a/net/socket.c b/net/socket.c
11122 +index dd5da07bc1ffc..d52c265ad449b 100644
11123 +--- a/net/socket.c
11124 ++++ b/net/socket.c
11125 +@@ -3112,128 +3112,6 @@ static int compat_dev_ifconf(struct net *net, struct compat_ifconf __user *uifc3
11126 + return 0;
11127 + }
11128 +
11129 +-static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
11130 +-{
11131 +- struct compat_ethtool_rxnfc __user *compat_rxnfc;
11132 +- bool convert_in = false, convert_out = false;
11133 +- size_t buf_size = 0;
11134 +- struct ethtool_rxnfc __user *rxnfc = NULL;
11135 +- struct ifreq ifr;
11136 +- u32 rule_cnt = 0, actual_rule_cnt;
11137 +- u32 ethcmd;
11138 +- u32 data;
11139 +- int ret;
11140 +-
11141 +- if (get_user(data, &ifr32->ifr_ifru.ifru_data))
11142 +- return -EFAULT;
11143 +-
11144 +- compat_rxnfc = compat_ptr(data);
11145 +-
11146 +- if (get_user(ethcmd, &compat_rxnfc->cmd))
11147 +- return -EFAULT;
11148 +-
11149 +- /* Most ethtool structures are defined without padding.
11150 +- * Unfortunately struct ethtool_rxnfc is an exception.
11151 +- */
11152 +- switch (ethcmd) {
11153 +- default:
11154 +- break;
11155 +- case ETHTOOL_GRXCLSRLALL:
11156 +- /* Buffer size is variable */
11157 +- if (get_user(rule_cnt, &compat_rxnfc->rule_cnt))
11158 +- return -EFAULT;
11159 +- if (rule_cnt > KMALLOC_MAX_SIZE / sizeof(u32))
11160 +- return -ENOMEM;
11161 +- buf_size += rule_cnt * sizeof(u32);
11162 +- fallthrough;
11163 +- case ETHTOOL_GRXRINGS:
11164 +- case ETHTOOL_GRXCLSRLCNT:
11165 +- case ETHTOOL_GRXCLSRULE:
11166 +- case ETHTOOL_SRXCLSRLINS:
11167 +- convert_out = true;
11168 +- fallthrough;
11169 +- case ETHTOOL_SRXCLSRLDEL:
11170 +- buf_size += sizeof(struct ethtool_rxnfc);
11171 +- convert_in = true;
11172 +- rxnfc = compat_alloc_user_space(buf_size);
11173 +- break;
11174 +- }
11175 +-
11176 +- if (copy_from_user(&ifr.ifr_name, &ifr32->ifr_name, IFNAMSIZ))
11177 +- return -EFAULT;
11178 +-
11179 +- ifr.ifr_data = convert_in ? rxnfc : (void __user *)compat_rxnfc;
11180 +-
11181 +- if (convert_in) {
11182 +- /* We expect there to be holes between fs.m_ext and
11183 +- * fs.ring_cookie and at the end of fs, but nowhere else.
11184 +- */
11185 +- BUILD_BUG_ON(offsetof(struct compat_ethtool_rxnfc, fs.m_ext) +
11186 +- sizeof(compat_rxnfc->fs.m_ext) !=
11187 +- offsetof(struct ethtool_rxnfc, fs.m_ext) +
11188 +- sizeof(rxnfc->fs.m_ext));
11189 +- BUILD_BUG_ON(
11190 +- offsetof(struct compat_ethtool_rxnfc, fs.location) -
11191 +- offsetof(struct compat_ethtool_rxnfc, fs.ring_cookie) !=
11192 +- offsetof(struct ethtool_rxnfc, fs.location) -
11193 +- offsetof(struct ethtool_rxnfc, fs.ring_cookie));
11194 +-
11195 +- if (copy_in_user(rxnfc, compat_rxnfc,
11196 +- (void __user *)(&rxnfc->fs.m_ext + 1) -
11197 +- (void __user *)rxnfc) ||
11198 +- copy_in_user(&rxnfc->fs.ring_cookie,
11199 +- &compat_rxnfc->fs.ring_cookie,
11200 +- (void __user *)(&rxnfc->fs.location + 1) -
11201 +- (void __user *)&rxnfc->fs.ring_cookie))
11202 +- return -EFAULT;
11203 +- if (ethcmd == ETHTOOL_GRXCLSRLALL) {
11204 +- if (put_user(rule_cnt, &rxnfc->rule_cnt))
11205 +- return -EFAULT;
11206 +- } else if (copy_in_user(&rxnfc->rule_cnt,
11207 +- &compat_rxnfc->rule_cnt,
11208 +- sizeof(rxnfc->rule_cnt)))
11209 +- return -EFAULT;
11210 +- }
11211 +-
11212 +- ret = dev_ioctl(net, SIOCETHTOOL, &ifr, NULL);
11213 +- if (ret)
11214 +- return ret;
11215 +-
11216 +- if (convert_out) {
11217 +- if (copy_in_user(compat_rxnfc, rxnfc,
11218 +- (const void __user *)(&rxnfc->fs.m_ext + 1) -
11219 +- (const void __user *)rxnfc) ||
11220 +- copy_in_user(&compat_rxnfc->fs.ring_cookie,
11221 +- &rxnfc->fs.ring_cookie,
11222 +- (const void __user *)(&rxnfc->fs.location + 1) -
11223 +- (const void __user *)&rxnfc->fs.ring_cookie) ||
11224 +- copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
11225 +- sizeof(rxnfc->rule_cnt)))
11226 +- return -EFAULT;
11227 +-
11228 +- if (ethcmd == ETHTOOL_GRXCLSRLALL) {
11229 +- /* As an optimisation, we only copy the actual
11230 +- * number of rules that the underlying
11231 +- * function returned. Since Mallory might
11232 +- * change the rule count in user memory, we
11233 +- * check that it is less than the rule count
11234 +- * originally given (as the user buffer size),
11235 +- * which has been range-checked.
11236 +- */
11237 +- if (get_user(actual_rule_cnt, &rxnfc->rule_cnt))
11238 +- return -EFAULT;
11239 +- if (actual_rule_cnt < rule_cnt)
11240 +- rule_cnt = actual_rule_cnt;
11241 +- if (copy_in_user(&compat_rxnfc->rule_locs[0],
11242 +- &rxnfc->rule_locs[0],
11243 +- rule_cnt * sizeof(u32)))
11244 +- return -EFAULT;
11245 +- }
11246 +- }
11247 +-
11248 +- return 0;
11249 +-}
11250 +-
11251 + static int compat_siocwandev(struct net *net, struct compat_ifreq __user *uifr32)
11252 + {
11253 + compat_uptr_t uptr32;
11254 +@@ -3390,8 +3268,6 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
11255 + return old_bridge_ioctl(argp);
11256 + case SIOCGIFCONF:
11257 + return compat_dev_ifconf(net, argp);
11258 +- case SIOCETHTOOL:
11259 +- return ethtool_ioctl(net, argp);
11260 + case SIOCWANDEV:
11261 + return compat_siocwandev(net, argp);
11262 + case SIOCGIFMAP:
11263 +@@ -3404,6 +3280,7 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
11264 + return sock->ops->gettstamp(sock, argp, cmd == SIOCGSTAMP_OLD,
11265 + !COMPAT_USE_64BIT_TIME);
11266 +
11267 ++ case SIOCETHTOOL:
11268 + case SIOCBONDSLAVEINFOQUERY:
11269 + case SIOCBONDINFOQUERY:
11270 + case SIOCSHWTSTAMP:
11271 +diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
11272 +index 6dff64374bfe1..e22f2d65457da 100644
11273 +--- a/net/sunrpc/auth_gss/svcauth_gss.c
11274 ++++ b/net/sunrpc/auth_gss/svcauth_gss.c
11275 +@@ -1980,7 +1980,7 @@ gss_svc_init_net(struct net *net)
11276 + goto out2;
11277 + return 0;
11278 + out2:
11279 +- destroy_use_gss_proxy_proc_entry(net);
11280 ++ rsi_cache_destroy_net(net);
11281 + out1:
11282 + rsc_cache_destroy_net(net);
11283 + return rv;
11284 +diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
11285 +index 9a50764be9160..8201531ce5d97 100644
11286 +--- a/net/sunrpc/xprt.c
11287 ++++ b/net/sunrpc/xprt.c
11288 +@@ -746,9 +746,9 @@ void xprt_force_disconnect(struct rpc_xprt *xprt)
11289 + /* Try to schedule an autoclose RPC call */
11290 + if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0)
11291 + queue_work(xprtiod_workqueue, &xprt->task_cleanup);
11292 +- else if (xprt->snd_task)
11293 ++ else if (xprt->snd_task && !test_bit(XPRT_SND_IS_COOKIE, &xprt->state))
11294 + rpc_wake_up_queued_task_set_status(&xprt->pending,
11295 +- xprt->snd_task, -ENOTCONN);
11296 ++ xprt->snd_task, -ENOTCONN);
11297 + spin_unlock(&xprt->transport_lock);
11298 + }
11299 + EXPORT_SYMBOL_GPL(xprt_force_disconnect);
11300 +@@ -837,12 +837,14 @@ bool xprt_lock_connect(struct rpc_xprt *xprt,
11301 + goto out;
11302 + if (xprt->snd_task != task)
11303 + goto out;
11304 ++ set_bit(XPRT_SND_IS_COOKIE, &xprt->state);
11305 + xprt->snd_task = cookie;
11306 + ret = true;
11307 + out:
11308 + spin_unlock(&xprt->transport_lock);
11309 + return ret;
11310 + }
11311 ++EXPORT_SYMBOL_GPL(xprt_lock_connect);
11312 +
11313 + void xprt_unlock_connect(struct rpc_xprt *xprt, void *cookie)
11314 + {
11315 +@@ -852,12 +854,14 @@ void xprt_unlock_connect(struct rpc_xprt *xprt, void *cookie)
11316 + if (!test_bit(XPRT_LOCKED, &xprt->state))
11317 + goto out;
11318 + xprt->snd_task =NULL;
11319 ++ clear_bit(XPRT_SND_IS_COOKIE, &xprt->state);
11320 + xprt->ops->release_xprt(xprt, NULL);
11321 + xprt_schedule_autodisconnect(xprt);
11322 + out:
11323 + spin_unlock(&xprt->transport_lock);
11324 + wake_up_bit(&xprt->state, XPRT_LOCKED);
11325 + }
11326 ++EXPORT_SYMBOL_GPL(xprt_unlock_connect);
11327 +
11328 + /**
11329 + * xprt_connect - schedule a transport connect operation
11330 +diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
11331 +index c26db0a379967..8e2368a0c2a29 100644
11332 +--- a/net/sunrpc/xprtrdma/transport.c
11333 ++++ b/net/sunrpc/xprtrdma/transport.c
11334 +@@ -249,12 +249,9 @@ xprt_rdma_connect_worker(struct work_struct *work)
11335 + xprt->stat.connect_start;
11336 + xprt_set_connected(xprt);
11337 + rc = -EAGAIN;
11338 +- } else {
11339 +- /* Force a call to xprt_rdma_close to clean up */
11340 +- spin_lock(&xprt->transport_lock);
11341 +- set_bit(XPRT_CLOSE_WAIT, &xprt->state);
11342 +- spin_unlock(&xprt->transport_lock);
11343 +- }
11344 ++ } else
11345 ++ rpcrdma_xprt_disconnect(r_xprt);
11346 ++ xprt_unlock_connect(xprt, r_xprt);
11347 + xprt_wake_pending_tasks(xprt, rc);
11348 + }
11349 +
11350 +@@ -487,6 +484,8 @@ xprt_rdma_connect(struct rpc_xprt *xprt, struct rpc_task *task)
11351 + struct rpcrdma_ep *ep = r_xprt->rx_ep;
11352 + unsigned long delay;
11353 +
11354 ++ WARN_ON_ONCE(!xprt_lock_connect(xprt, task, r_xprt));
11355 ++
11356 + delay = 0;
11357 + if (ep && ep->re_connect_status != 0) {
11358 + delay = xprt_reconnect_delay(xprt);
11359 +diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
11360 +index 9c0f71e82d978..16c7758e7bf30 100644
11361 +--- a/net/sunrpc/xprtsock.c
11362 ++++ b/net/sunrpc/xprtsock.c
11363 +@@ -1639,6 +1639,13 @@ static int xs_get_srcport(struct sock_xprt *transport)
11364 + return port;
11365 + }
11366 +
11367 ++unsigned short get_srcport(struct rpc_xprt *xprt)
11368 ++{
11369 ++ struct sock_xprt *sock = container_of(xprt, struct sock_xprt, xprt);
11370 ++ return xs_sock_getport(sock->sock);
11371 ++}
11372 ++EXPORT_SYMBOL(get_srcport);
11373 ++
11374 + static unsigned short xs_next_srcport(struct sock_xprt *transport, unsigned short port)
11375 + {
11376 + if (transport->srcport != 0)
11377 +diff --git a/net/tipc/socket.c b/net/tipc/socket.c
11378 +index 9bd72468bc68e..963047c57c27b 100644
11379 +--- a/net/tipc/socket.c
11380 ++++ b/net/tipc/socket.c
11381 +@@ -1887,6 +1887,7 @@ static int tipc_recvmsg(struct socket *sock, struct msghdr *m,
11382 + bool connected = !tipc_sk_type_connectionless(sk);
11383 + struct tipc_sock *tsk = tipc_sk(sk);
11384 + int rc, err, hlen, dlen, copy;
11385 ++ struct tipc_skb_cb *skb_cb;
11386 + struct sk_buff_head xmitq;
11387 + struct tipc_msg *hdr;
11388 + struct sk_buff *skb;
11389 +@@ -1910,6 +1911,7 @@ static int tipc_recvmsg(struct socket *sock, struct msghdr *m,
11390 + if (unlikely(rc))
11391 + goto exit;
11392 + skb = skb_peek(&sk->sk_receive_queue);
11393 ++ skb_cb = TIPC_SKB_CB(skb);
11394 + hdr = buf_msg(skb);
11395 + dlen = msg_data_sz(hdr);
11396 + hlen = msg_hdr_sz(hdr);
11397 +@@ -1929,18 +1931,33 @@ static int tipc_recvmsg(struct socket *sock, struct msghdr *m,
11398 +
11399 + /* Capture data if non-error msg, otherwise just set return value */
11400 + if (likely(!err)) {
11401 +- copy = min_t(int, dlen, buflen);
11402 +- if (unlikely(copy != dlen))
11403 +- m->msg_flags |= MSG_TRUNC;
11404 +- rc = skb_copy_datagram_msg(skb, hlen, m, copy);
11405 ++ int offset = skb_cb->bytes_read;
11406 ++
11407 ++ copy = min_t(int, dlen - offset, buflen);
11408 ++ rc = skb_copy_datagram_msg(skb, hlen + offset, m, copy);
11409 ++ if (unlikely(rc))
11410 ++ goto exit;
11411 ++ if (unlikely(offset + copy < dlen)) {
11412 ++ if (flags & MSG_EOR) {
11413 ++ if (!(flags & MSG_PEEK))
11414 ++ skb_cb->bytes_read = offset + copy;
11415 ++ } else {
11416 ++ m->msg_flags |= MSG_TRUNC;
11417 ++ skb_cb->bytes_read = 0;
11418 ++ }
11419 ++ } else {
11420 ++ if (flags & MSG_EOR)
11421 ++ m->msg_flags |= MSG_EOR;
11422 ++ skb_cb->bytes_read = 0;
11423 ++ }
11424 + } else {
11425 + copy = 0;
11426 + rc = 0;
11427 +- if (err != TIPC_CONN_SHUTDOWN && connected && !m->msg_control)
11428 ++ if (err != TIPC_CONN_SHUTDOWN && connected && !m->msg_control) {
11429 + rc = -ECONNRESET;
11430 ++ goto exit;
11431 ++ }
11432 + }
11433 +- if (unlikely(rc))
11434 +- goto exit;
11435 +
11436 + /* Mark message as group event if applicable */
11437 + if (unlikely(grp_evt)) {
11438 +@@ -1963,9 +1980,10 @@ static int tipc_recvmsg(struct socket *sock, struct msghdr *m,
11439 + tipc_node_distr_xmit(sock_net(sk), &xmitq);
11440 + }
11441 +
11442 +- tsk_advance_rx_queue(sk);
11443 ++ if (!skb_cb->bytes_read)
11444 ++ tsk_advance_rx_queue(sk);
11445 +
11446 +- if (likely(!connected))
11447 ++ if (likely(!connected) || skb_cb->bytes_read)
11448 + goto exit;
11449 +
11450 + /* Send connection flow control advertisement when applicable */
11451 +diff --git a/samples/bpf/test_override_return.sh b/samples/bpf/test_override_return.sh
11452 +index e68b9ee6814b8..35db26f736b9d 100755
11453 +--- a/samples/bpf/test_override_return.sh
11454 ++++ b/samples/bpf/test_override_return.sh
11455 +@@ -1,5 +1,6 @@
11456 + #!/bin/bash
11457 +
11458 ++rm -r tmpmnt
11459 + rm -f testfile.img
11460 + dd if=/dev/zero of=testfile.img bs=1M seek=1000 count=1
11461 + DEVICE=$(losetup --show -f testfile.img)
11462 +diff --git a/samples/bpf/tracex7_user.c b/samples/bpf/tracex7_user.c
11463 +index fdcd6580dd736..8be7ce18d3ba0 100644
11464 +--- a/samples/bpf/tracex7_user.c
11465 ++++ b/samples/bpf/tracex7_user.c
11466 +@@ -14,6 +14,11 @@ int main(int argc, char **argv)
11467 + int ret = 0;
11468 + FILE *f;
11469 +
11470 ++ if (!argv[1]) {
11471 ++ fprintf(stderr, "ERROR: Run with the btrfs device argument!\n");
11472 ++ return 0;
11473 ++ }
11474 ++
11475 + snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
11476 + obj = bpf_object__open_file(filename, NULL);
11477 + if (libbpf_get_error(obj)) {
11478 +diff --git a/scripts/gen_ksymdeps.sh b/scripts/gen_ksymdeps.sh
11479 +index 1324986e1362c..725e8c9c1b53f 100755
11480 +--- a/scripts/gen_ksymdeps.sh
11481 ++++ b/scripts/gen_ksymdeps.sh
11482 +@@ -4,7 +4,13 @@
11483 + set -e
11484 +
11485 + # List of exported symbols
11486 +-ksyms=$($NM $1 | sed -n 's/.*__ksym_marker_\(.*\)/\1/p' | tr A-Z a-z)
11487 ++#
11488 ++# If the object has no symbol, $NM warns 'no symbols'.
11489 ++# Suppress the stderr.
11490 ++# TODO:
11491 ++# Use -q instead of 2>/dev/null when we upgrade the minimum version of
11492 ++# binutils to 2.37, llvm to 13.0.0.
11493 ++ksyms=$($NM $1 2>/dev/null | sed -n 's/.*__ksym_marker_\(.*\)/\1/p' | tr A-Z a-z)
11494 +
11495 + if [ -z "$ksyms" ]; then
11496 + exit 0
11497 +diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
11498 +index 7eabb448acab4..169929c6c4eb3 100644
11499 +--- a/security/smack/smack_access.c
11500 ++++ b/security/smack/smack_access.c
11501 +@@ -81,23 +81,22 @@ int log_policy = SMACK_AUDIT_DENIED;
11502 + int smk_access_entry(char *subject_label, char *object_label,
11503 + struct list_head *rule_list)
11504 + {
11505 +- int may = -ENOENT;
11506 + struct smack_rule *srp;
11507 +
11508 + list_for_each_entry_rcu(srp, rule_list, list) {
11509 + if (srp->smk_object->smk_known == object_label &&
11510 + srp->smk_subject->smk_known == subject_label) {
11511 +- may = srp->smk_access;
11512 +- break;
11513 ++ int may = srp->smk_access;
11514 ++ /*
11515 ++ * MAY_WRITE implies MAY_LOCK.
11516 ++ */
11517 ++ if ((may & MAY_WRITE) == MAY_WRITE)
11518 ++ may |= MAY_LOCK;
11519 ++ return may;
11520 + }
11521 + }
11522 +
11523 +- /*
11524 +- * MAY_WRITE implies MAY_LOCK.
11525 +- */
11526 +- if ((may & MAY_WRITE) == MAY_WRITE)
11527 +- may |= MAY_LOCK;
11528 +- return may;
11529 ++ return -ENOENT;
11530 + }
11531 +
11532 + /**
11533 +diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig
11534 +index 142373ec411ad..89210048e6c2b 100644
11535 +--- a/sound/soc/atmel/Kconfig
11536 ++++ b/sound/soc/atmel/Kconfig
11537 +@@ -11,7 +11,6 @@ if SND_ATMEL_SOC
11538 +
11539 + config SND_ATMEL_SOC_PDC
11540 + bool
11541 +- depends on HAS_DMA
11542 +
11543 + config SND_ATMEL_SOC_DMA
11544 + bool
11545 +diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
11546 +index ca14730232ba9..43ee3d095a1be 100644
11547 +--- a/sound/soc/intel/boards/bytcr_rt5640.c
11548 ++++ b/sound/soc/intel/boards/bytcr_rt5640.c
11549 +@@ -286,9 +286,6 @@ static const struct snd_soc_dapm_widget byt_rt5640_widgets[] = {
11550 + static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = {
11551 + {"Headphone", NULL, "Platform Clock"},
11552 + {"Headset Mic", NULL, "Platform Clock"},
11553 +- {"Internal Mic", NULL, "Platform Clock"},
11554 +- {"Speaker", NULL, "Platform Clock"},
11555 +-
11556 + {"Headset Mic", NULL, "MICBIAS1"},
11557 + {"IN2P", NULL, "Headset Mic"},
11558 + {"Headphone", NULL, "HPOL"},
11559 +@@ -296,19 +293,23 @@ static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = {
11560 + };
11561 +
11562 + static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic1_map[] = {
11563 ++ {"Internal Mic", NULL, "Platform Clock"},
11564 + {"DMIC1", NULL, "Internal Mic"},
11565 + };
11566 +
11567 + static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic2_map[] = {
11568 ++ {"Internal Mic", NULL, "Platform Clock"},
11569 + {"DMIC2", NULL, "Internal Mic"},
11570 + };
11571 +
11572 + static const struct snd_soc_dapm_route byt_rt5640_intmic_in1_map[] = {
11573 ++ {"Internal Mic", NULL, "Platform Clock"},
11574 + {"Internal Mic", NULL, "MICBIAS1"},
11575 + {"IN1P", NULL, "Internal Mic"},
11576 + };
11577 +
11578 + static const struct snd_soc_dapm_route byt_rt5640_intmic_in3_map[] = {
11579 ++ {"Internal Mic", NULL, "Platform Clock"},
11580 + {"Internal Mic", NULL, "MICBIAS1"},
11581 + {"IN3P", NULL, "Internal Mic"},
11582 + };
11583 +@@ -350,6 +351,7 @@ static const struct snd_soc_dapm_route byt_rt5640_ssp0_aif2_map[] = {
11584 + };
11585 +
11586 + static const struct snd_soc_dapm_route byt_rt5640_stereo_spk_map[] = {
11587 ++ {"Speaker", NULL, "Platform Clock"},
11588 + {"Speaker", NULL, "SPOLP"},
11589 + {"Speaker", NULL, "SPOLN"},
11590 + {"Speaker", NULL, "SPORP"},
11591 +@@ -357,6 +359,7 @@ static const struct snd_soc_dapm_route byt_rt5640_stereo_spk_map[] = {
11592 + };
11593 +
11594 + static const struct snd_soc_dapm_route byt_rt5640_mono_spk_map[] = {
11595 ++ {"Speaker", NULL, "Platform Clock"},
11596 + {"Speaker", NULL, "SPOLP"},
11597 + {"Speaker", NULL, "SPOLN"},
11598 + };
11599 +diff --git a/sound/soc/intel/boards/sof_pcm512x.c b/sound/soc/intel/boards/sof_pcm512x.c
11600 +index d2b0456236c72..bdd671f07659c 100644
11601 +--- a/sound/soc/intel/boards/sof_pcm512x.c
11602 ++++ b/sound/soc/intel/boards/sof_pcm512x.c
11603 +@@ -26,11 +26,16 @@
11604 +
11605 + #define SOF_PCM512X_SSP_CODEC(quirk) ((quirk) & GENMASK(3, 0))
11606 + #define SOF_PCM512X_SSP_CODEC_MASK (GENMASK(3, 0))
11607 ++#define SOF_PCM512X_ENABLE_SSP_CAPTURE BIT(4)
11608 ++#define SOF_PCM512X_ENABLE_DMIC BIT(5)
11609 +
11610 + #define IDISP_CODEC_MASK 0x4
11611 +
11612 + /* Default: SSP5 */
11613 +-static unsigned long sof_pcm512x_quirk = SOF_PCM512X_SSP_CODEC(5);
11614 ++static unsigned long sof_pcm512x_quirk =
11615 ++ SOF_PCM512X_SSP_CODEC(5) |
11616 ++ SOF_PCM512X_ENABLE_SSP_CAPTURE |
11617 ++ SOF_PCM512X_ENABLE_DMIC;
11618 +
11619 + static bool is_legacy_cpu;
11620 +
11621 +@@ -245,8 +250,9 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
11622 + links[id].dpcm_playback = 1;
11623 + /*
11624 + * capture only supported with specific versions of the Hifiberry DAC+
11625 +- * links[id].dpcm_capture = 1;
11626 + */
11627 ++ if (sof_pcm512x_quirk & SOF_PCM512X_ENABLE_SSP_CAPTURE)
11628 ++ links[id].dpcm_capture = 1;
11629 + links[id].no_pcm = 1;
11630 + links[id].cpus = &cpus[id];
11631 + links[id].num_cpus = 1;
11632 +@@ -381,6 +387,9 @@ static int sof_audio_probe(struct platform_device *pdev)
11633 +
11634 + ssp_codec = sof_pcm512x_quirk & SOF_PCM512X_SSP_CODEC_MASK;
11635 +
11636 ++ if (!(sof_pcm512x_quirk & SOF_PCM512X_ENABLE_DMIC))
11637 ++ dmic_be_num = 0;
11638 ++
11639 + /* compute number of dai links */
11640 + sof_audio_card_pcm512x.num_links = 1 + dmic_be_num + hdmi_num;
11641 +
11642 +diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c
11643 +index 476ef1897961d..79c6cf2c14bfb 100644
11644 +--- a/sound/soc/intel/skylake/skl-messages.c
11645 ++++ b/sound/soc/intel/skylake/skl-messages.c
11646 +@@ -802,9 +802,12 @@ static u16 skl_get_module_param_size(struct skl_dev *skl,
11647 +
11648 + case SKL_MODULE_TYPE_BASE_OUTFMT:
11649 + case SKL_MODULE_TYPE_MIC_SELECT:
11650 +- case SKL_MODULE_TYPE_KPB:
11651 + return sizeof(struct skl_base_outfmt_cfg);
11652 +
11653 ++ case SKL_MODULE_TYPE_MIXER:
11654 ++ case SKL_MODULE_TYPE_KPB:
11655 ++ return sizeof(struct skl_base_cfg);
11656 ++
11657 + default:
11658 + /*
11659 + * return only base cfg when no specific module type is
11660 +@@ -857,10 +860,14 @@ static int skl_set_module_format(struct skl_dev *skl,
11661 +
11662 + case SKL_MODULE_TYPE_BASE_OUTFMT:
11663 + case SKL_MODULE_TYPE_MIC_SELECT:
11664 +- case SKL_MODULE_TYPE_KPB:
11665 + skl_set_base_outfmt_format(skl, module_config, *param_data);
11666 + break;
11667 +
11668 ++ case SKL_MODULE_TYPE_MIXER:
11669 ++ case SKL_MODULE_TYPE_KPB:
11670 ++ skl_set_base_module_format(skl, module_config, *param_data);
11671 ++ break;
11672 ++
11673 + default:
11674 + skl_set_base_module_format(skl, module_config, *param_data);
11675 + break;
11676 +diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
11677 +index bbe8d782e0af6..b1897a057397d 100644
11678 +--- a/sound/soc/intel/skylake/skl-pcm.c
11679 ++++ b/sound/soc/intel/skylake/skl-pcm.c
11680 +@@ -1318,21 +1318,6 @@ static int skl_get_module_info(struct skl_dev *skl,
11681 + return -EIO;
11682 + }
11683 +
11684 +- list_for_each_entry(module, &skl->uuid_list, list) {
11685 +- if (guid_equal(uuid_mod, &module->uuid)) {
11686 +- mconfig->id.module_id = module->id;
11687 +- if (mconfig->module)
11688 +- mconfig->module->loadable = module->is_loadable;
11689 +- ret = 0;
11690 +- break;
11691 +- }
11692 +- }
11693 +-
11694 +- if (ret)
11695 +- return ret;
11696 +-
11697 +- uuid_mod = &module->uuid;
11698 +- ret = -EIO;
11699 + for (i = 0; i < skl->nr_modules; i++) {
11700 + skl_module = skl->modules[i];
11701 + uuid_tplg = &skl_module->uuid;
11702 +@@ -1342,10 +1327,18 @@ static int skl_get_module_info(struct skl_dev *skl,
11703 + break;
11704 + }
11705 + }
11706 ++
11707 + if (skl->nr_modules && ret)
11708 + return ret;
11709 +
11710 ++ ret = -EIO;
11711 + list_for_each_entry(module, &skl->uuid_list, list) {
11712 ++ if (guid_equal(uuid_mod, &module->uuid)) {
11713 ++ mconfig->id.module_id = module->id;
11714 ++ mconfig->module->loadable = module->is_loadable;
11715 ++ ret = 0;
11716 ++ }
11717 ++
11718 + for (i = 0; i < MAX_IN_QUEUE; i++) {
11719 + pin_id = &mconfig->m_in_pin[i].id;
11720 + if (guid_equal(&pin_id->mod_uuid, &module->uuid))
11721 +@@ -1359,7 +1352,7 @@ static int skl_get_module_info(struct skl_dev *skl,
11722 + }
11723 + }
11724 +
11725 +- return 0;
11726 ++ return ret;
11727 + }
11728 +
11729 + static int skl_populate_modules(struct skl_dev *skl)
11730 +diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
11731 +index 593299675b8c7..fa84ec695b525 100644
11732 +--- a/sound/soc/rockchip/rockchip_i2s.c
11733 ++++ b/sound/soc/rockchip/rockchip_i2s.c
11734 +@@ -186,7 +186,9 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
11735 + {
11736 + struct rk_i2s_dev *i2s = to_info(cpu_dai);
11737 + unsigned int mask = 0, val = 0;
11738 ++ int ret = 0;
11739 +
11740 ++ pm_runtime_get_sync(cpu_dai->dev);
11741 + mask = I2S_CKR_MSS_MASK;
11742 + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
11743 + case SND_SOC_DAIFMT_CBS_CFS:
11744 +@@ -199,7 +201,8 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
11745 + i2s->is_master_mode = false;
11746 + break;
11747 + default:
11748 +- return -EINVAL;
11749 ++ ret = -EINVAL;
11750 ++ goto err_pm_put;
11751 + }
11752 +
11753 + regmap_update_bits(i2s->regmap, I2S_CKR, mask, val);
11754 +@@ -213,7 +216,8 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
11755 + val = I2S_CKR_CKP_POS;
11756 + break;
11757 + default:
11758 +- return -EINVAL;
11759 ++ ret = -EINVAL;
11760 ++ goto err_pm_put;
11761 + }
11762 +
11763 + regmap_update_bits(i2s->regmap, I2S_CKR, mask, val);
11764 +@@ -229,14 +233,15 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
11765 + case SND_SOC_DAIFMT_I2S:
11766 + val = I2S_TXCR_IBM_NORMAL;
11767 + break;
11768 +- case SND_SOC_DAIFMT_DSP_A: /* PCM no delay mode */
11769 +- val = I2S_TXCR_TFS_PCM;
11770 +- break;
11771 +- case SND_SOC_DAIFMT_DSP_B: /* PCM delay 1 mode */
11772 ++ case SND_SOC_DAIFMT_DSP_A: /* PCM delay 1 bit mode */
11773 + val = I2S_TXCR_TFS_PCM | I2S_TXCR_PBM_MODE(1);
11774 + break;
11775 ++ case SND_SOC_DAIFMT_DSP_B: /* PCM no delay mode */
11776 ++ val = I2S_TXCR_TFS_PCM;
11777 ++ break;
11778 + default:
11779 +- return -EINVAL;
11780 ++ ret = -EINVAL;
11781 ++ goto err_pm_put;
11782 + }
11783 +
11784 + regmap_update_bits(i2s->regmap, I2S_TXCR, mask, val);
11785 +@@ -252,19 +257,23 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
11786 + case SND_SOC_DAIFMT_I2S:
11787 + val = I2S_RXCR_IBM_NORMAL;
11788 + break;
11789 +- case SND_SOC_DAIFMT_DSP_A: /* PCM no delay mode */
11790 +- val = I2S_RXCR_TFS_PCM;
11791 +- break;
11792 +- case SND_SOC_DAIFMT_DSP_B: /* PCM delay 1 mode */
11793 ++ case SND_SOC_DAIFMT_DSP_A: /* PCM delay 1 bit mode */
11794 + val = I2S_RXCR_TFS_PCM | I2S_RXCR_PBM_MODE(1);
11795 + break;
11796 ++ case SND_SOC_DAIFMT_DSP_B: /* PCM no delay mode */
11797 ++ val = I2S_RXCR_TFS_PCM;
11798 ++ break;
11799 + default:
11800 +- return -EINVAL;
11801 ++ ret = -EINVAL;
11802 ++ goto err_pm_put;
11803 + }
11804 +
11805 + regmap_update_bits(i2s->regmap, I2S_RXCR, mask, val);
11806 +
11807 +- return 0;
11808 ++err_pm_put:
11809 ++ pm_runtime_put(cpu_dai->dev);
11810 ++
11811 ++ return ret;
11812 + }
11813 +
11814 + static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
11815 +diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
11816 +index 28923b776cdc8..b337d6f29098b 100644
11817 +--- a/tools/lib/bpf/libbpf.c
11818 ++++ b/tools/lib/bpf/libbpf.c
11819 +@@ -3613,6 +3613,42 @@ static int bpf_map_find_btf_info(struct bpf_object *obj, struct bpf_map *map)
11820 + return 0;
11821 + }
11822 +
11823 ++static int bpf_get_map_info_from_fdinfo(int fd, struct bpf_map_info *info)
11824 ++{
11825 ++ char file[PATH_MAX], buff[4096];
11826 ++ FILE *fp;
11827 ++ __u32 val;
11828 ++ int err;
11829 ++
11830 ++ snprintf(file, sizeof(file), "/proc/%d/fdinfo/%d", getpid(), fd);
11831 ++ memset(info, 0, sizeof(*info));
11832 ++
11833 ++ fp = fopen(file, "r");
11834 ++ if (!fp) {
11835 ++ err = -errno;
11836 ++ pr_warn("failed to open %s: %d. No procfs support?\n", file,
11837 ++ err);
11838 ++ return err;
11839 ++ }
11840 ++
11841 ++ while (fgets(buff, sizeof(buff), fp)) {
11842 ++ if (sscanf(buff, "map_type:\t%u", &val) == 1)
11843 ++ info->type = val;
11844 ++ else if (sscanf(buff, "key_size:\t%u", &val) == 1)
11845 ++ info->key_size = val;
11846 ++ else if (sscanf(buff, "value_size:\t%u", &val) == 1)
11847 ++ info->value_size = val;
11848 ++ else if (sscanf(buff, "max_entries:\t%u", &val) == 1)
11849 ++ info->max_entries = val;
11850 ++ else if (sscanf(buff, "map_flags:\t%i", &val) == 1)
11851 ++ info->map_flags = val;
11852 ++ }
11853 ++
11854 ++ fclose(fp);
11855 ++
11856 ++ return 0;
11857 ++}
11858 ++
11859 + int bpf_map__reuse_fd(struct bpf_map *map, int fd)
11860 + {
11861 + struct bpf_map_info info = {};
11862 +@@ -3621,6 +3657,8 @@ int bpf_map__reuse_fd(struct bpf_map *map, int fd)
11863 + char *new_name;
11864 +
11865 + err = bpf_obj_get_info_by_fd(fd, &info, &len);
11866 ++ if (err && errno == EINVAL)
11867 ++ err = bpf_get_map_info_from_fdinfo(fd, &info);
11868 + if (err)
11869 + return err;
11870 +
11871 +@@ -4032,12 +4070,16 @@ static bool map_is_reuse_compat(const struct bpf_map *map, int map_fd)
11872 + struct bpf_map_info map_info = {};
11873 + char msg[STRERR_BUFSIZE];
11874 + __u32 map_info_len;
11875 ++ int err;
11876 +
11877 + map_info_len = sizeof(map_info);
11878 +
11879 +- if (bpf_obj_get_info_by_fd(map_fd, &map_info, &map_info_len)) {
11880 +- pr_warn("failed to get map info for map FD %d: %s\n",
11881 +- map_fd, libbpf_strerror_r(errno, msg, sizeof(msg)));
11882 ++ err = bpf_obj_get_info_by_fd(map_fd, &map_info, &map_info_len);
11883 ++ if (err && errno == EINVAL)
11884 ++ err = bpf_get_map_info_from_fdinfo(map_fd, &map_info);
11885 ++ if (err) {
11886 ++ pr_warn("failed to get map info for map FD %d: %s\n", map_fd,
11887 ++ libbpf_strerror_r(errno, msg, sizeof(msg)));
11888 + return false;
11889 + }
11890 +
11891 +@@ -4242,10 +4284,13 @@ bpf_object__create_maps(struct bpf_object *obj)
11892 + char *cp, errmsg[STRERR_BUFSIZE];
11893 + unsigned int i, j;
11894 + int err;
11895 ++ bool retried;
11896 +
11897 + for (i = 0; i < obj->nr_maps; i++) {
11898 + map = &obj->maps[i];
11899 +
11900 ++ retried = false;
11901 ++retry:
11902 + if (map->pin_path) {
11903 + err = bpf_object__reuse_map(map);
11904 + if (err) {
11905 +@@ -4253,6 +4298,12 @@ bpf_object__create_maps(struct bpf_object *obj)
11906 + map->name);
11907 + goto err_out;
11908 + }
11909 ++ if (retried && map->fd < 0) {
11910 ++ pr_warn("map '%s': cannot find pinned map\n",
11911 ++ map->name);
11912 ++ err = -ENOENT;
11913 ++ goto err_out;
11914 ++ }
11915 + }
11916 +
11917 + if (map->fd >= 0) {
11918 +@@ -4286,9 +4337,13 @@ bpf_object__create_maps(struct bpf_object *obj)
11919 + if (map->pin_path && !map->pinned) {
11920 + err = bpf_map__pin(map, NULL);
11921 + if (err) {
11922 ++ zclose(map->fd);
11923 ++ if (!retried && err == -EEXIST) {
11924 ++ retried = true;
11925 ++ goto retry;
11926 ++ }
11927 + pr_warn("map '%s': failed to auto-pin at '%s': %d\n",
11928 + map->name, map->pin_path, err);
11929 +- zclose(map->fd);
11930 + goto err_out;
11931 + }
11932 + }
11933 +diff --git a/tools/testing/selftests/arm64/mte/mte_common_util.c b/tools/testing/selftests/arm64/mte/mte_common_util.c
11934 +index 70665ba88cbb1..2703bd628d06c 100644
11935 +--- a/tools/testing/selftests/arm64/mte/mte_common_util.c
11936 ++++ b/tools/testing/selftests/arm64/mte/mte_common_util.c
11937 +@@ -285,7 +285,7 @@ int mte_default_setup(void)
11938 + int ret;
11939 +
11940 + if (!(hwcaps2 & HWCAP2_MTE)) {
11941 +- ksft_print_msg("FAIL: MTE features unavailable\n");
11942 ++ ksft_print_msg("SKIP: MTE features unavailable\n");
11943 + return KSFT_SKIP;
11944 + }
11945 + /* Get current mte mode */
11946 +diff --git a/tools/testing/selftests/arm64/pauth/pac.c b/tools/testing/selftests/arm64/pauth/pac.c
11947 +index 592fe538506e3..b743daa772f55 100644
11948 +--- a/tools/testing/selftests/arm64/pauth/pac.c
11949 ++++ b/tools/testing/selftests/arm64/pauth/pac.c
11950 +@@ -25,13 +25,15 @@
11951 + do { \
11952 + unsigned long hwcaps = getauxval(AT_HWCAP); \
11953 + /* data key instructions are not in NOP space. This prevents a SIGILL */ \
11954 +- ASSERT_NE(0, hwcaps & HWCAP_PACA) TH_LOG("PAUTH not enabled"); \
11955 ++ if (!(hwcaps & HWCAP_PACA)) \
11956 ++ SKIP(return, "PAUTH not enabled"); \
11957 + } while (0)
11958 + #define ASSERT_GENERIC_PAUTH_ENABLED() \
11959 + do { \
11960 + unsigned long hwcaps = getauxval(AT_HWCAP); \
11961 + /* generic key instructions are not in NOP space. This prevents a SIGILL */ \
11962 +- ASSERT_NE(0, hwcaps & HWCAP_PACG) TH_LOG("Generic PAUTH not enabled"); \
11963 ++ if (!(hwcaps & HWCAP_PACG)) \
11964 ++ SKIP(return, "Generic PAUTH not enabled"); \
11965 + } while (0)
11966 +
11967 + void sign_specific(struct signatures *sign, size_t val)
11968 +@@ -256,7 +258,7 @@ TEST(single_thread_different_keys)
11969 + unsigned long hwcaps = getauxval(AT_HWCAP);
11970 +
11971 + /* generic and data key instructions are not in NOP space. This prevents a SIGILL */
11972 +- ASSERT_NE(0, hwcaps & HWCAP_PACA) TH_LOG("PAUTH not enabled");
11973 ++ ASSERT_PAUTH_ENABLED();
11974 + if (!(hwcaps & HWCAP_PACG)) {
11975 + TH_LOG("WARNING: Generic PAUTH not enabled. Skipping generic key checks");
11976 + nkeys = NKEYS - 1;
11977 +@@ -299,7 +301,7 @@ TEST(exec_changed_keys)
11978 + unsigned long hwcaps = getauxval(AT_HWCAP);
11979 +
11980 + /* generic and data key instructions are not in NOP space. This prevents a SIGILL */
11981 +- ASSERT_NE(0, hwcaps & HWCAP_PACA) TH_LOG("PAUTH not enabled");
11982 ++ ASSERT_PAUTH_ENABLED();
11983 + if (!(hwcaps & HWCAP_PACG)) {
11984 + TH_LOG("WARNING: Generic PAUTH not enabled. Skipping generic key checks");
11985 + nkeys = NKEYS - 1;
11986 +diff --git a/tools/testing/selftests/bpf/prog_tests/send_signal.c b/tools/testing/selftests/bpf/prog_tests/send_signal.c
11987 +index 7043e6ded0e60..75b72c751772b 100644
11988 +--- a/tools/testing/selftests/bpf/prog_tests/send_signal.c
11989 ++++ b/tools/testing/selftests/bpf/prog_tests/send_signal.c
11990 +@@ -1,5 +1,7 @@
11991 + // SPDX-License-Identifier: GPL-2.0
11992 + #include <test_progs.h>
11993 ++#include <sys/time.h>
11994 ++#include <sys/resource.h>
11995 + #include "test_send_signal_kern.skel.h"
11996 +
11997 + static volatile int sigusr1_received = 0;
11998 +@@ -41,12 +43,23 @@ static void test_send_signal_common(struct perf_event_attr *attr,
11999 + }
12000 +
12001 + if (pid == 0) {
12002 ++ int old_prio;
12003 ++
12004 + /* install signal handler and notify parent */
12005 + signal(SIGUSR1, sigusr1_handler);
12006 +
12007 + close(pipe_c2p[0]); /* close read */
12008 + close(pipe_p2c[1]); /* close write */
12009 +
12010 ++ /* boost with a high priority so we got a higher chance
12011 ++ * that if an interrupt happens, the underlying task
12012 ++ * is this process.
12013 ++ */
12014 ++ errno = 0;
12015 ++ old_prio = getpriority(PRIO_PROCESS, 0);
12016 ++ ASSERT_OK(errno, "getpriority");
12017 ++ ASSERT_OK(setpriority(PRIO_PROCESS, 0, -20), "setpriority");
12018 ++
12019 + /* notify parent signal handler is installed */
12020 + CHECK(write(pipe_c2p[1], buf, 1) != 1, "pipe_write", "err %d\n", -errno);
12021 +
12022 +@@ -62,6 +75,9 @@ static void test_send_signal_common(struct perf_event_attr *attr,
12023 + /* wait for parent notification and exit */
12024 + CHECK(read(pipe_p2c[0], buf, 1) != 1, "pipe_read", "err %d\n", -errno);
12025 +
12026 ++ /* restore the old priority */
12027 ++ ASSERT_OK(setpriority(PRIO_PROCESS, 0, old_prio), "setpriority");
12028 ++
12029 + close(pipe_c2p[1]);
12030 + close(pipe_p2c[0]);
12031 + exit(0);
12032 +diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c b/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c
12033 +index ec281b0363b82..86f97681ad898 100644
12034 +--- a/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c
12035 ++++ b/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c
12036 +@@ -195,8 +195,10 @@ static void run_test(int cgroup_fd)
12037 +
12038 + pthread_mutex_lock(&server_started_mtx);
12039 + if (CHECK_FAIL(pthread_create(&tid, NULL, server_thread,
12040 +- (void *)&server_fd)))
12041 ++ (void *)&server_fd))) {
12042 ++ pthread_mutex_unlock(&server_started_mtx);
12043 + goto close_server_fd;
12044 ++ }
12045 + pthread_cond_wait(&server_started, &server_started_mtx);
12046 + pthread_mutex_unlock(&server_started_mtx);
12047 +
12048 +diff --git a/tools/testing/selftests/bpf/progs/xdp_tx.c b/tools/testing/selftests/bpf/progs/xdp_tx.c
12049 +index 94e6c2b281cb6..5f725c720e008 100644
12050 +--- a/tools/testing/selftests/bpf/progs/xdp_tx.c
12051 ++++ b/tools/testing/selftests/bpf/progs/xdp_tx.c
12052 +@@ -3,7 +3,7 @@
12053 + #include <linux/bpf.h>
12054 + #include <bpf/bpf_helpers.h>
12055 +
12056 +-SEC("tx")
12057 ++SEC("xdp")
12058 + int xdp_tx(struct xdp_md *xdp)
12059 + {
12060 + return XDP_TX;
12061 +diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
12062 +index 0d92ebcb335d1..179e680e8d134 100644
12063 +--- a/tools/testing/selftests/bpf/test_maps.c
12064 ++++ b/tools/testing/selftests/bpf/test_maps.c
12065 +@@ -968,7 +968,7 @@ static void test_sockmap(unsigned int tasks, void *data)
12066 +
12067 + FD_ZERO(&w);
12068 + FD_SET(sfd[3], &w);
12069 +- to.tv_sec = 1;
12070 ++ to.tv_sec = 30;
12071 + to.tv_usec = 0;
12072 + s = select(sfd[3] + 1, &w, NULL, NULL, &to);
12073 + if (s == -1) {
12074 +diff --git a/tools/testing/selftests/bpf/test_xdp_veth.sh b/tools/testing/selftests/bpf/test_xdp_veth.sh
12075 +index ba8ffcdaac302..995278e684b6e 100755
12076 +--- a/tools/testing/selftests/bpf/test_xdp_veth.sh
12077 ++++ b/tools/testing/selftests/bpf/test_xdp_veth.sh
12078 +@@ -108,7 +108,7 @@ ip link set dev veth2 xdp pinned $BPF_DIR/progs/redirect_map_1
12079 + ip link set dev veth3 xdp pinned $BPF_DIR/progs/redirect_map_2
12080 +
12081 + ip -n ns1 link set dev veth11 xdp obj xdp_dummy.o sec xdp_dummy
12082 +-ip -n ns2 link set dev veth22 xdp obj xdp_tx.o sec tx
12083 ++ip -n ns2 link set dev veth22 xdp obj xdp_tx.o sec xdp
12084 + ip -n ns3 link set dev veth33 xdp obj xdp_dummy.o sec xdp_dummy
12085 +
12086 + trap cleanup EXIT
12087 +diff --git a/tools/testing/selftests/firmware/fw_namespace.c b/tools/testing/selftests/firmware/fw_namespace.c
12088 +index 5ebc1aec7923b..817b2f1e8ee6a 100644
12089 +--- a/tools/testing/selftests/firmware/fw_namespace.c
12090 ++++ b/tools/testing/selftests/firmware/fw_namespace.c
12091 +@@ -129,7 +129,8 @@ int main(int argc, char **argv)
12092 + die("mounting tmpfs to /lib/firmware failed\n");
12093 +
12094 + sys_path = argv[1];
12095 +- asprintf(&fw_path, "/lib/firmware/%s", fw_name);
12096 ++ if (asprintf(&fw_path, "/lib/firmware/%s", fw_name) < 0)
12097 ++ die("error: failed to build full fw_path\n");
12098 +
12099 + setup_fw(fw_path);
12100 +
12101 +diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
12102 +index a6fac927ee82f..0cee6b067a374 100644
12103 +--- a/tools/testing/selftests/ftrace/test.d/functions
12104 ++++ b/tools/testing/selftests/ftrace/test.d/functions
12105 +@@ -115,7 +115,7 @@ check_requires() { # Check required files and tracers
12106 + echo "Required tracer $t is not configured."
12107 + exit_unsupported
12108 + fi
12109 +- elif [ $r != $i ]; then
12110 ++ elif [ "$r" != "$i" ]; then
12111 + if ! grep -Fq "$r" README ; then
12112 + echo "Required feature pattern \"$r\" is not in README."
12113 + exit_unsupported
12114 +diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile
12115 +index 59e417ec3e134..25d7f8f37cfd6 100644
12116 +--- a/tools/thermal/tmon/Makefile
12117 ++++ b/tools/thermal/tmon/Makefile
12118 +@@ -10,7 +10,7 @@ override CFLAGS+= $(call cc-option,-O3,-O1) ${WARNFLAGS}
12119 + # Add "-fstack-protector" only if toolchain supports it.
12120 + override CFLAGS+= $(call cc-option,-fstack-protector-strong)
12121 + CC?= $(CROSS_COMPILE)gcc
12122 +-PKG_CONFIG?= pkg-config
12123 ++PKG_CONFIG?= $(CROSS_COMPILE)pkg-config
12124 +
12125 + override CFLAGS+=-D VERSION=\"$(VERSION)\"
12126 + LDFLAGS+=