Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.5 commit in: /
Date: Mon, 24 Feb 2020 11:11:04
Message-Id: 1582542644.5bd1273749aedbf70bead7dc7523d3759c12600e.mpagano@gentoo
1 commit: 5bd1273749aedbf70bead7dc7523d3759c12600e
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Mon Feb 24 11:10:44 2020 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Mon Feb 24 11:10:44 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=5bd12737
7
8 Linux patch 5.5.6
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1005_linux-5.5.6.patch | 16853 +++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 16857 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 7eb2076..ff99e11 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -63,6 +63,10 @@ Patch: 1004_linux-5.5.5.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.5.5
23
24 +Patch: 1005_linux-5.5.6.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.5.6
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1005_linux-5.5.6.patch b/1005_linux-5.5.6.patch
33 new file mode 100644
34 index 0000000..b234b2b
35 --- /dev/null
36 +++ b/1005_linux-5.5.6.patch
37 @@ -0,0 +1,16853 @@
38 +diff --git a/Documentation/admin-guide/device-mapper/dm-raid.rst b/Documentation/admin-guide/device-mapper/dm-raid.rst
39 +index f6344675e395..695a2ea1d1ae 100644
40 +--- a/Documentation/admin-guide/device-mapper/dm-raid.rst
41 ++++ b/Documentation/admin-guide/device-mapper/dm-raid.rst
42 +@@ -419,3 +419,5 @@ Version History
43 + rebuild errors.
44 + 1.15.0 Fix size extensions not being synchronized in case of new MD bitmap
45 + pages allocated; also fix those not occuring after previous reductions
46 ++ 1.15.1 Fix argument count and arguments for rebuild/write_mostly/journal_(dev|mode)
47 ++ on the status line.
48 +diff --git a/Documentation/fb/fbcon.rst b/Documentation/fb/fbcon.rst
49 +index ebca41785abe..65ba40255137 100644
50 +--- a/Documentation/fb/fbcon.rst
51 ++++ b/Documentation/fb/fbcon.rst
52 +@@ -127,7 +127,7 @@ C. Boot options
53 + is typically located on the same video card. Thus, the consoles that
54 + are controlled by the VGA console will be garbled.
55 +
56 +-4. fbcon=rotate:<n>
57 ++5. fbcon=rotate:<n>
58 +
59 + This option changes the orientation angle of the console display. The
60 + value 'n' accepts the following:
61 +@@ -152,21 +152,21 @@ C. Boot options
62 + Actually, the underlying fb driver is totally ignorant of console
63 + rotation.
64 +
65 +-5. fbcon=margin:<color>
66 ++6. fbcon=margin:<color>
67 +
68 + This option specifies the color of the margins. The margins are the
69 + leftover area at the right and the bottom of the screen that are not
70 + used by text. By default, this area will be black. The 'color' value
71 + is an integer number that depends on the framebuffer driver being used.
72 +
73 +-6. fbcon=nodefer
74 ++7. fbcon=nodefer
75 +
76 + If the kernel is compiled with deferred fbcon takeover support, normally
77 + the framebuffer contents, left in place by the firmware/bootloader, will
78 + be preserved until there actually is some text is output to the console.
79 + This option causes fbcon to bind immediately to the fbdev device.
80 +
81 +-7. fbcon=logo-pos:<location>
82 ++8. fbcon=logo-pos:<location>
83 +
84 + The only possible 'location' is 'center' (without quotes), and when
85 + given, the bootup logo is moved from the default top-left corner
86 +diff --git a/Makefile b/Makefile
87 +index 1f7dc3a2e1dd..7fb236f30926 100644
88 +--- a/Makefile
89 ++++ b/Makefile
90 +@@ -1,7 +1,7 @@
91 + # SPDX-License-Identifier: GPL-2.0
92 + VERSION = 5
93 + PATCHLEVEL = 5
94 +-SUBLEVEL = 5
95 ++SUBLEVEL = 6
96 + EXTRAVERSION =
97 + NAME = Kleptomaniac Octopus
98 +
99 +@@ -1691,7 +1691,7 @@ PHONY += descend $(build-dirs)
100 + descend: $(build-dirs)
101 + $(build-dirs): prepare
102 + $(Q)$(MAKE) $(build)=$@ \
103 +- single-build=$(if $(filter-out $@/, $(single-no-ko)),1) \
104 ++ single-build=$(if $(filter-out $@/, $(filter $@/%, $(single-no-ko))),1) \
105 + need-builtin=1 need-modorder=1
106 +
107 + clean-dirs := $(addprefix _clean_, $(clean-dirs))
108 +diff --git a/arch/Kconfig b/arch/Kconfig
109 +index 208aad121630..5e907a954532 100644
110 +--- a/arch/Kconfig
111 ++++ b/arch/Kconfig
112 +@@ -399,6 +399,9 @@ config HAVE_RCU_TABLE_FREE
113 + config HAVE_MMU_GATHER_PAGE_SIZE
114 + bool
115 +
116 ++config MMU_GATHER_NO_RANGE
117 ++ bool
118 ++
119 + config HAVE_MMU_GATHER_NO_GATHER
120 + bool
121 +
122 +diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
123 +index 96dab76da3b3..7ef1916fcbf4 100644
124 +--- a/arch/arm/Kconfig
125 ++++ b/arch/arm/Kconfig
126 +@@ -74,7 +74,7 @@ config ARM
127 + select HAVE_CONTEXT_TRACKING
128 + select HAVE_COPY_THREAD_TLS
129 + select HAVE_C_RECORDMCOUNT
130 +- select HAVE_DEBUG_KMEMLEAK
131 ++ select HAVE_DEBUG_KMEMLEAK if !XIP_KERNEL
132 + select HAVE_DMA_CONTIGUOUS if MMU
133 + select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU
134 + select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE
135 +@@ -1905,7 +1905,7 @@ config XIP_DEFLATED_DATA
136 + config KEXEC
137 + bool "Kexec system call (EXPERIMENTAL)"
138 + depends on (!SMP || PM_SLEEP_SMP)
139 +- depends on !CPU_V7M
140 ++ depends on MMU
141 + select KEXEC_CORE
142 + help
143 + kexec is a system call that implements the ability to shutdown your
144 +diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
145 +index ead21e5f2b80..469a2b3b60c0 100644
146 +--- a/arch/arm/boot/compressed/head.S
147 ++++ b/arch/arm/boot/compressed/head.S
148 +@@ -140,6 +140,17 @@
149 + #endif
150 + .endm
151 +
152 ++ .macro enable_cp15_barriers, reg
153 ++ mrc p15, 0, \reg, c1, c0, 0 @ read SCTLR
154 ++ tst \reg, #(1 << 5) @ CP15BEN bit set?
155 ++ bne .L_\@
156 ++ orr \reg, \reg, #(1 << 5) @ CP15 barrier instructions
157 ++ mcr p15, 0, \reg, c1, c0, 0 @ write SCTLR
158 ++ ARM( .inst 0xf57ff06f @ v7+ isb )
159 ++ THUMB( isb )
160 ++.L_\@:
161 ++ .endm
162 ++
163 + .section ".start", "ax"
164 + /*
165 + * sort out different calling conventions
166 +@@ -820,6 +831,7 @@ __armv4_mmu_cache_on:
167 + mov pc, r12
168 +
169 + __armv7_mmu_cache_on:
170 ++ enable_cp15_barriers r11
171 + mov r12, lr
172 + #ifdef CONFIG_MMU
173 + mrc p15, 0, r11, c0, c1, 4 @ read ID_MMFR0
174 +@@ -1209,6 +1221,7 @@ __armv6_mmu_cache_flush:
175 + mov pc, lr
176 +
177 + __armv7_mmu_cache_flush:
178 ++ enable_cp15_barriers r10
179 + tst r4, #1
180 + bne iflush
181 + mrc p15, 0, r10, c0, c1, 5 @ read ID_MMFR1
182 +diff --git a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
183 +index a2a4f33a3e3e..cbafadbe86f4 100644
184 +--- a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
185 ++++ b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
186 +@@ -629,7 +629,7 @@
187 + pinctrl-0 = <&pinctrl_usdhc2>;
188 + bus-width = <4>;
189 + cd-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
190 +- wp-gpios = <&gpio2 3 GPIO_ACTIVE_HIGH>;
191 ++ disable-wp;
192 + vmmc-supply = <&reg_3p3v_sd>;
193 + vqmmc-supply = <&reg_3p3v>;
194 + no-1-8-v;
195 +@@ -642,7 +642,7 @@
196 + pinctrl-0 = <&pinctrl_usdhc3>;
197 + bus-width = <4>;
198 + cd-gpios = <&gpio2 0 GPIO_ACTIVE_LOW>;
199 +- wp-gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>;
200 ++ disable-wp;
201 + vmmc-supply = <&reg_3p3v_sd>;
202 + vqmmc-supply = <&reg_3p3v>;
203 + no-1-8-v;
204 +@@ -776,6 +776,7 @@
205 + &usbh1 {
206 + vbus-supply = <&reg_5p0v_main>;
207 + disable-over-current;
208 ++ maximum-speed = "full-speed";
209 + status = "okay";
210 + };
211 +
212 +@@ -1056,7 +1057,6 @@
213 + MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x17059
214 + MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x17059
215 + MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x17059
216 +- MX6QDL_PAD_NANDF_D3__GPIO2_IO03 0x40010040
217 + MX6QDL_PAD_NANDF_D2__GPIO2_IO02 0x40010040
218 + >;
219 + };
220 +@@ -1069,7 +1069,6 @@
221 + MX6QDL_PAD_SD3_DAT1__SD3_DATA1 0x17059
222 + MX6QDL_PAD_SD3_DAT2__SD3_DATA2 0x17059
223 + MX6QDL_PAD_SD3_DAT3__SD3_DATA3 0x17059
224 +- MX6QDL_PAD_NANDF_D1__GPIO2_IO01 0x40010040
225 + MX6QDL_PAD_NANDF_D0__GPIO2_IO00 0x40010040
226 +
227 + >;
228 +diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
229 +index ebf5b7cfe215..63341635bddf 100644
230 +--- a/arch/arm/boot/dts/r8a7779.dtsi
231 ++++ b/arch/arm/boot/dts/r8a7779.dtsi
232 +@@ -68,6 +68,14 @@
233 + <0xf0000100 0x100>;
234 + };
235 +
236 ++ timer@f0000200 {
237 ++ compatible = "arm,cortex-a9-global-timer";
238 ++ reg = <0xf0000200 0x100>;
239 ++ interrupts = <GIC_PPI 11
240 ++ (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>;
241 ++ clocks = <&cpg_clocks R8A7779_CLK_ZS>;
242 ++ };
243 ++
244 + timer@f0000600 {
245 + compatible = "arm,cortex-a9-twd-timer";
246 + reg = <0xf0000600 0x20>;
247 +diff --git a/arch/arm/boot/dts/rk3188-bqedison2qc.dts b/arch/arm/boot/dts/rk3188-bqedison2qc.dts
248 +index c8b62bbd6a4a..ad1afd403052 100644
249 +--- a/arch/arm/boot/dts/rk3188-bqedison2qc.dts
250 ++++ b/arch/arm/boot/dts/rk3188-bqedison2qc.dts
251 +@@ -466,9 +466,12 @@
252 + pinctrl-names = "default";
253 + pinctrl-0 = <&sd1_clk>, <&sd1_cmd>, <&sd1_bus4>;
254 + vmmcq-supply = <&vccio_wl>;
255 ++ #address-cells = <1>;
256 ++ #size-cells = <0>;
257 + status = "okay";
258 +
259 + brcmf: wifi@1 {
260 ++ reg = <1>;
261 + compatible = "brcm,bcm4329-fmac";
262 + interrupt-parent = <&gpio3>;
263 + interrupts = <RK_PD2 GPIO_ACTIVE_HIGH>;
264 +diff --git a/arch/arm/boot/dts/stm32f469-disco.dts b/arch/arm/boot/dts/stm32f469-disco.dts
265 +index f3ce477b7bae..9397db0c43de 100644
266 +--- a/arch/arm/boot/dts/stm32f469-disco.dts
267 ++++ b/arch/arm/boot/dts/stm32f469-disco.dts
268 +@@ -76,6 +76,13 @@
269 + regulator-max-microvolt = <3300000>;
270 + };
271 +
272 ++ vdd_dsi: vdd-dsi {
273 ++ compatible = "regulator-fixed";
274 ++ regulator-name = "vdd_dsi";
275 ++ regulator-min-microvolt = <3300000>;
276 ++ regulator-max-microvolt = <3300000>;
277 ++ };
278 ++
279 + soc {
280 + dma-ranges = <0xc0000000 0x0 0x10000000>;
281 + };
282 +@@ -155,6 +162,7 @@
283 + compatible = "orisetech,otm8009a";
284 + reg = <0>; /* dsi virtual channel (0..3) */
285 + reset-gpios = <&gpioh 7 GPIO_ACTIVE_LOW>;
286 ++ power-supply = <&vdd_dsi>;
287 + status = "okay";
288 +
289 + port {
290 +diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi b/arch/arm/boot/dts/sun8i-h3.dtsi
291 +index fe773c72a69b..b4f1673df9ee 100644
292 +--- a/arch/arm/boot/dts/sun8i-h3.dtsi
293 ++++ b/arch/arm/boot/dts/sun8i-h3.dtsi
294 +@@ -80,7 +80,7 @@
295 + #cooling-cells = <2>;
296 + };
297 +
298 +- cpu@1 {
299 ++ cpu1: cpu@1 {
300 + compatible = "arm,cortex-a7";
301 + device_type = "cpu";
302 + reg = <1>;
303 +@@ -90,7 +90,7 @@
304 + #cooling-cells = <2>;
305 + };
306 +
307 +- cpu@2 {
308 ++ cpu2: cpu@2 {
309 + compatible = "arm,cortex-a7";
310 + device_type = "cpu";
311 + reg = <2>;
312 +@@ -100,7 +100,7 @@
313 + #cooling-cells = <2>;
314 + };
315 +
316 +- cpu@3 {
317 ++ cpu3: cpu@3 {
318 + compatible = "arm,cortex-a7";
319 + device_type = "cpu";
320 + reg = <3>;
321 +@@ -111,6 +111,15 @@
322 + };
323 + };
324 +
325 ++ pmu {
326 ++ compatible = "arm,cortex-a7-pmu";
327 ++ interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>,
328 ++ <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
329 ++ <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
330 ++ <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>;
331 ++ interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
332 ++ };
333 ++
334 + timer {
335 + compatible = "arm,armv7-timer";
336 + interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
337 +diff --git a/arch/arm/configs/exynos_defconfig b/arch/arm/configs/exynos_defconfig
338 +index fde84f123fbb..ead8348ec999 100644
339 +--- a/arch/arm/configs/exynos_defconfig
340 ++++ b/arch/arm/configs/exynos_defconfig
341 +@@ -38,6 +38,7 @@ CONFIG_CRYPTO_SHA256_ARM=m
342 + CONFIG_CRYPTO_SHA512_ARM=m
343 + CONFIG_CRYPTO_AES_ARM_BS=m
344 + CONFIG_CRYPTO_CHACHA20_NEON=m
345 ++CONFIG_KALLSYMS_ALL=y
346 + CONFIG_MODULES=y
347 + CONFIG_MODULE_UNLOAD=y
348 + CONFIG_PARTITION_ADVANCED=y
349 +@@ -92,6 +93,7 @@ CONFIG_BLK_DEV_LOOP=y
350 + CONFIG_BLK_DEV_CRYPTOLOOP=y
351 + CONFIG_BLK_DEV_RAM=y
352 + CONFIG_BLK_DEV_RAM_SIZE=8192
353 ++CONFIG_SCSI=y
354 + CONFIG_BLK_DEV_SD=y
355 + CONFIG_CHR_DEV_SG=y
356 + CONFIG_ATA=y
357 +@@ -291,6 +293,7 @@ CONFIG_CROS_EC_SPI=y
358 + CONFIG_COMMON_CLK_MAX77686=y
359 + CONFIG_COMMON_CLK_S2MPS11=y
360 + CONFIG_EXYNOS_IOMMU=y
361 ++CONFIG_PM_DEVFREQ=y
362 + CONFIG_DEVFREQ_GOV_PERFORMANCE=y
363 + CONFIG_DEVFREQ_GOV_POWERSAVE=y
364 + CONFIG_DEVFREQ_GOV_USERSPACE=y
365 +@@ -356,4 +359,7 @@ CONFIG_SOFTLOCKUP_DETECTOR=y
366 + # CONFIG_DETECT_HUNG_TASK is not set
367 + CONFIG_PROVE_LOCKING=y
368 + CONFIG_DEBUG_ATOMIC_SLEEP=y
369 ++CONFIG_DEBUG_RT_MUTEXES=y
370 ++CONFIG_DEBUG_SPINLOCK=y
371 ++CONFIG_DEBUG_MUTEXES=y
372 + CONFIG_DEBUG_USER=y
373 +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
374 +index e92c4de5bf3b..7c775a918a4e 100644
375 +--- a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
376 ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
377 +@@ -54,21 +54,21 @@
378 + enable-method = "psci";
379 + };
380 +
381 +- cpu@1 {
382 ++ cpu1: cpu@1 {
383 + compatible = "arm,cortex-a53";
384 + device_type = "cpu";
385 + reg = <1>;
386 + enable-method = "psci";
387 + };
388 +
389 +- cpu@2 {
390 ++ cpu2: cpu@2 {
391 + compatible = "arm,cortex-a53";
392 + device_type = "cpu";
393 + reg = <2>;
394 + enable-method = "psci";
395 + };
396 +
397 +- cpu@3 {
398 ++ cpu3: cpu@3 {
399 + compatible = "arm,cortex-a53";
400 + device_type = "cpu";
401 + reg = <3>;
402 +@@ -76,6 +76,16 @@
403 + };
404 + };
405 +
406 ++ pmu {
407 ++ compatible = "arm,cortex-a53-pmu",
408 ++ "arm,armv8-pmuv3";
409 ++ interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>,
410 ++ <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>,
411 ++ <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>,
412 ++ <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>;
413 ++ interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
414 ++ };
415 ++
416 + psci {
417 + compatible = "arm,psci-0.2";
418 + method = "smc";
419 +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
420 +index 29824081b43b..24ffe2dcbddb 100644
421 +--- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
422 ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
423 +@@ -70,6 +70,16 @@
424 + clock-output-names = "ext_osc32k";
425 + };
426 +
427 ++ pmu {
428 ++ compatible = "arm,cortex-a53-pmu",
429 ++ "arm,armv8-pmuv3";
430 ++ interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>,
431 ++ <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>,
432 ++ <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>,
433 ++ <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
434 ++ interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
435 ++ };
436 ++
437 + psci {
438 + compatible = "arm,psci-0.2";
439 + method = "smc";
440 +diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi
441 +index 4ca2e7b44559..1eed3c41521a 100644
442 +--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
443 ++++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
444 +@@ -1602,6 +1602,8 @@
445 + interrupts = <0 138 IRQ_TYPE_LEVEL_HIGH>;
446 + phys = <&hsusb_phy2>;
447 + phy-names = "usb2-phy";
448 ++ snps,dis_u2_susphy_quirk;
449 ++ snps,dis_enblslpm_quirk;
450 + };
451 + };
452 +
453 +@@ -1632,6 +1634,8 @@
454 + interrupts = <0 131 IRQ_TYPE_LEVEL_HIGH>;
455 + phys = <&hsusb_phy1>, <&ssusb_phy_0>;
456 + phy-names = "usb2-phy", "usb3-phy";
457 ++ snps,dis_u2_susphy_quirk;
458 ++ snps,dis_enblslpm_quirk;
459 + };
460 + };
461 +
462 +diff --git a/arch/arm64/boot/dts/qcom/sdm845-db845c.dts b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
463 +index d100f46791a6..912ba745c0fc 100644
464 +--- a/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
465 ++++ b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
466 +@@ -529,6 +529,8 @@
467 + vdd-1.8-xo-supply = <&vreg_l7a_1p8>;
468 + vdd-1.3-rfa-supply = <&vreg_l17a_1p3>;
469 + vdd-3.3-ch0-supply = <&vreg_l25a_3p3>;
470 ++
471 ++ qcom,snoc-host-cap-8bit-quirk;
472 + };
473 +
474 + /* PINCTRL - additions to nodes defined in sdm845.dtsi */
475 +diff --git a/arch/arm64/boot/dts/rockchip/px30.dtsi b/arch/arm64/boot/dts/rockchip/px30.dtsi
476 +index 8812b70f3911..5acd5ce714d4 100644
477 +--- a/arch/arm64/boot/dts/rockchip/px30.dtsi
478 ++++ b/arch/arm64/boot/dts/rockchip/px30.dtsi
479 +@@ -826,7 +826,7 @@
480 + interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>;
481 + clocks = <&cru HCLK_SDMMC>, <&cru SCLK_SDMMC>,
482 + <&cru SCLK_SDMMC_DRV>, <&cru SCLK_SDMMC_SAMPLE>;
483 +- clock-names = "biu", "ciu", "ciu-drv", "ciu-sample";
484 ++ clock-names = "biu", "ciu", "ciu-drive", "ciu-sample";
485 + fifo-depth = <0x100>;
486 + max-frequency = <150000000>;
487 + pinctrl-names = "default";
488 +@@ -841,7 +841,7 @@
489 + interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
490 + clocks = <&cru HCLK_SDIO>, <&cru SCLK_SDIO>,
491 + <&cru SCLK_SDIO_DRV>, <&cru SCLK_SDIO_SAMPLE>;
492 +- clock-names = "biu", "ciu", "ciu-drv", "ciu-sample";
493 ++ clock-names = "biu", "ciu", "ciu-drive", "ciu-sample";
494 + fifo-depth = <0x100>;
495 + max-frequency = <150000000>;
496 + pinctrl-names = "default";
497 +@@ -856,7 +856,7 @@
498 + interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>;
499 + clocks = <&cru HCLK_EMMC>, <&cru SCLK_EMMC>,
500 + <&cru SCLK_EMMC_DRV>, <&cru SCLK_EMMC_SAMPLE>;
501 +- clock-names = "biu", "ciu", "ciu-drv", "ciu-sample";
502 ++ clock-names = "biu", "ciu", "ciu-drive", "ciu-sample";
503 + fifo-depth = <0x100>;
504 + max-frequency = <150000000>;
505 + pinctrl-names = "default";
506 +diff --git a/arch/arm64/boot/dts/rockchip/rk3308.dtsi b/arch/arm64/boot/dts/rockchip/rk3308.dtsi
507 +index 8bdc66c62975..fa0d55f1a587 100644
508 +--- a/arch/arm64/boot/dts/rockchip/rk3308.dtsi
509 ++++ b/arch/arm64/boot/dts/rockchip/rk3308.dtsi
510 +@@ -591,7 +591,7 @@
511 + bus-width = <4>;
512 + clocks = <&cru HCLK_SDMMC>, <&cru SCLK_SDMMC>,
513 + <&cru SCLK_SDMMC_DRV>, <&cru SCLK_SDMMC_SAMPLE>;
514 +- clock-names = "biu", "ciu", "ciu-drv", "ciu-sample";
515 ++ clock-names = "biu", "ciu", "ciu-drive", "ciu-sample";
516 + fifo-depth = <0x100>;
517 + max-frequency = <150000000>;
518 + pinctrl-names = "default";
519 +@@ -606,7 +606,7 @@
520 + bus-width = <8>;
521 + clocks = <&cru HCLK_EMMC>, <&cru SCLK_EMMC>,
522 + <&cru SCLK_EMMC_DRV>, <&cru SCLK_EMMC_SAMPLE>;
523 +- clock-names = "biu", "ciu", "ciu-drv", "ciu-sample";
524 ++ clock-names = "biu", "ciu", "ciu-drive", "ciu-sample";
525 + fifo-depth = <0x100>;
526 + max-frequency = <150000000>;
527 + status = "disabled";
528 +@@ -619,7 +619,7 @@
529 + bus-width = <4>;
530 + clocks = <&cru HCLK_SDIO>, <&cru SCLK_SDIO>,
531 + <&cru SCLK_SDIO_DRV>, <&cru SCLK_SDIO_SAMPLE>;
532 +- clock-names = "biu", "ciu", "ciu-drv", "ciu-sample";
533 ++ clock-names = "biu", "ciu", "ciu-drive", "ciu-sample";
534 + fifo-depth = <0x100>;
535 + max-frequency = <150000000>;
536 + pinctrl-names = "default";
537 +diff --git a/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts b/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts
538 +index c706db0ee9ec..76f5db696009 100644
539 +--- a/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts
540 ++++ b/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts
541 +@@ -669,9 +669,12 @@
542 + vqmmc-supply = &vcc1v8_s3; /* IO line */
543 + vmmc-supply = &vcc_sdio; /* card's power */
544 +
545 ++ #address-cells = <1>;
546 ++ #size-cells = <0>;
547 + status = "okay";
548 +
549 + brcmf: wifi@1 {
550 ++ reg = <1>;
551 + compatible = "brcm,bcm4329-fmac";
552 + interrupt-parent = <&gpio0>;
553 + interrupts = <RK_PA3 GPIO_ACTIVE_HIGH>;
554 +diff --git a/arch/arm64/boot/dts/rockchip/rk3399-khadas-edge.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-khadas-edge.dtsi
555 +index 4944d78a0a1c..e87a04477440 100644
556 +--- a/arch/arm64/boot/dts/rockchip/rk3399-khadas-edge.dtsi
557 ++++ b/arch/arm64/boot/dts/rockchip/rk3399-khadas-edge.dtsi
558 +@@ -654,9 +654,12 @@
559 + sd-uhs-sdr104;
560 + vqmmc-supply = <&vcc1v8_s3>;
561 + vmmc-supply = <&vccio_sd>;
562 ++ #address-cells = <1>;
563 ++ #size-cells = <0>;
564 + status = "okay";
565 +
566 + brcmf: wifi@1 {
567 ++ reg = <1>;
568 + compatible = "brcm,bcm4329-fmac";
569 + interrupt-parent = <&gpio0>;
570 + interrupts = <RK_PA3 GPIO_ACTIVE_HIGH>;
571 +diff --git a/arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dts b/arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dts
572 +index 2a127985ab17..d3ed8e5e770f 100644
573 +--- a/arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dts
574 ++++ b/arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dts
575 +@@ -94,33 +94,6 @@
576 + };
577 + };
578 +
579 +-&gpu_thermal {
580 +- trips {
581 +- gpu_warm: gpu_warm {
582 +- temperature = <55000>;
583 +- hysteresis = <2000>;
584 +- type = "active";
585 +- };
586 +-
587 +- gpu_hot: gpu_hot {
588 +- temperature = <65000>;
589 +- hysteresis = <2000>;
590 +- type = "active";
591 +- };
592 +- };
593 +- cooling-maps {
594 +- map1 {
595 +- trip = <&gpu_warm>;
596 +- cooling-device = <&fan THERMAL_NO_LIMIT 1>;
597 +- };
598 +-
599 +- map2 {
600 +- trip = <&gpu_hot>;
601 +- cooling-device = <&fan 2 THERMAL_NO_LIMIT>;
602 +- };
603 +- };
604 +-};
605 +-
606 + &pinctrl {
607 + ir {
608 + ir_rx: ir-rx {
609 +diff --git a/arch/arm64/boot/dts/rockchip/rk3399-orangepi.dts b/arch/arm64/boot/dts/rockchip/rk3399-orangepi.dts
610 +index 0541dfce924d..9c659f3115c8 100644
611 +--- a/arch/arm64/boot/dts/rockchip/rk3399-orangepi.dts
612 ++++ b/arch/arm64/boot/dts/rockchip/rk3399-orangepi.dts
613 +@@ -648,9 +648,12 @@
614 + pinctrl-names = "default";
615 + pinctrl-0 = <&sdio0_bus4 &sdio0_cmd &sdio0_clk>;
616 + sd-uhs-sdr104;
617 ++ #address-cells = <1>;
618 ++ #size-cells = <0>;
619 + status = "okay";
620 +
621 + brcmf: wifi@1 {
622 ++ reg = <1>;
623 + compatible = "brcm,bcm4329-fmac";
624 + interrupt-parent = <&gpio0>;
625 + interrupts = <RK_PA3 GPIO_ACTIVE_HIGH>;
626 +diff --git a/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi b/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi
627 +index 1e4c2b78d66d..68d478af7a3e 100644
628 +--- a/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi
629 ++++ b/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi
630 +@@ -43,6 +43,7 @@
631 + smmu0: smmu@36600000 {
632 + compatible = "arm,smmu-v3";
633 + reg = <0x0 0x36600000 0x0 0x100000>;
634 ++ power-domains = <&k3_pds 229 TI_SCI_PD_EXCLUSIVE>;
635 + interrupt-parent = <&gic500>;
636 + interrupts = <GIC_SPI 772 IRQ_TYPE_EDGE_RISING>,
637 + <GIC_SPI 768 IRQ_TYPE_EDGE_RISING>;
638 +diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
639 +index b9f8d787eea9..324e7d5ab37e 100644
640 +--- a/arch/arm64/include/asm/alternative.h
641 ++++ b/arch/arm64/include/asm/alternative.h
642 +@@ -35,13 +35,16 @@ void apply_alternatives_module(void *start, size_t length);
643 + static inline void apply_alternatives_module(void *start, size_t length) { }
644 + #endif
645 +
646 +-#define ALTINSTR_ENTRY(feature,cb) \
647 ++#define ALTINSTR_ENTRY(feature) \
648 + " .word 661b - .\n" /* label */ \
649 +- " .if " __stringify(cb) " == 0\n" \
650 + " .word 663f - .\n" /* new instruction */ \
651 +- " .else\n" \
652 ++ " .hword " __stringify(feature) "\n" /* feature bit */ \
653 ++ " .byte 662b-661b\n" /* source len */ \
654 ++ " .byte 664f-663f\n" /* replacement len */
655 ++
656 ++#define ALTINSTR_ENTRY_CB(feature, cb) \
657 ++ " .word 661b - .\n" /* label */ \
658 + " .word " __stringify(cb) "- .\n" /* callback */ \
659 +- " .endif\n" \
660 + " .hword " __stringify(feature) "\n" /* feature bit */ \
661 + " .byte 662b-661b\n" /* source len */ \
662 + " .byte 664f-663f\n" /* replacement len */
663 +@@ -62,15 +65,14 @@ static inline void apply_alternatives_module(void *start, size_t length) { }
664 + *
665 + * Alternatives with callbacks do not generate replacement instructions.
666 + */
667 +-#define __ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg_enabled, cb) \
668 ++#define __ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg_enabled) \
669 + ".if "__stringify(cfg_enabled)" == 1\n" \
670 + "661:\n\t" \
671 + oldinstr "\n" \
672 + "662:\n" \
673 + ".pushsection .altinstructions,\"a\"\n" \
674 +- ALTINSTR_ENTRY(feature,cb) \
675 ++ ALTINSTR_ENTRY(feature) \
676 + ".popsection\n" \
677 +- " .if " __stringify(cb) " == 0\n" \
678 + ".pushsection .altinstr_replacement, \"a\"\n" \
679 + "663:\n\t" \
680 + newinstr "\n" \
681 +@@ -78,17 +80,25 @@ static inline void apply_alternatives_module(void *start, size_t length) { }
682 + ".popsection\n\t" \
683 + ".org . - (664b-663b) + (662b-661b)\n\t" \
684 + ".org . - (662b-661b) + (664b-663b)\n" \
685 +- ".else\n\t" \
686 ++ ".endif\n"
687 ++
688 ++#define __ALTERNATIVE_CFG_CB(oldinstr, feature, cfg_enabled, cb) \
689 ++ ".if "__stringify(cfg_enabled)" == 1\n" \
690 ++ "661:\n\t" \
691 ++ oldinstr "\n" \
692 ++ "662:\n" \
693 ++ ".pushsection .altinstructions,\"a\"\n" \
694 ++ ALTINSTR_ENTRY_CB(feature, cb) \
695 ++ ".popsection\n" \
696 + "663:\n\t" \
697 + "664:\n\t" \
698 +- ".endif\n" \
699 + ".endif\n"
700 +
701 + #define _ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg, ...) \
702 +- __ALTERNATIVE_CFG(oldinstr, newinstr, feature, IS_ENABLED(cfg), 0)
703 ++ __ALTERNATIVE_CFG(oldinstr, newinstr, feature, IS_ENABLED(cfg))
704 +
705 + #define ALTERNATIVE_CB(oldinstr, cb) \
706 +- __ALTERNATIVE_CFG(oldinstr, "NOT_AN_INSTRUCTION", ARM64_CB_PATCH, 1, cb)
707 ++ __ALTERNATIVE_CFG_CB(oldinstr, ARM64_CB_PATCH, 1, cb)
708 + #else
709 +
710 + #include <asm/assembler.h>
711 +diff --git a/arch/arm64/include/asm/atomic_lse.h b/arch/arm64/include/asm/atomic_lse.h
712 +index 574808b9df4c..da3280f639cd 100644
713 +--- a/arch/arm64/include/asm/atomic_lse.h
714 ++++ b/arch/arm64/include/asm/atomic_lse.h
715 +@@ -14,6 +14,7 @@
716 + static inline void __lse_atomic_##op(int i, atomic_t *v) \
717 + { \
718 + asm volatile( \
719 ++ __LSE_PREAMBLE \
720 + " " #asm_op " %w[i], %[v]\n" \
721 + : [i] "+r" (i), [v] "+Q" (v->counter) \
722 + : "r" (v)); \
723 +@@ -30,6 +31,7 @@ ATOMIC_OP(add, stadd)
724 + static inline int __lse_atomic_fetch_##op##name(int i, atomic_t *v) \
725 + { \
726 + asm volatile( \
727 ++ __LSE_PREAMBLE \
728 + " " #asm_op #mb " %w[i], %w[i], %[v]" \
729 + : [i] "+r" (i), [v] "+Q" (v->counter) \
730 + : "r" (v) \
731 +@@ -58,6 +60,7 @@ static inline int __lse_atomic_add_return##name(int i, atomic_t *v) \
732 + u32 tmp; \
733 + \
734 + asm volatile( \
735 ++ __LSE_PREAMBLE \
736 + " ldadd" #mb " %w[i], %w[tmp], %[v]\n" \
737 + " add %w[i], %w[i], %w[tmp]" \
738 + : [i] "+r" (i), [v] "+Q" (v->counter), [tmp] "=&r" (tmp) \
739 +@@ -77,6 +80,7 @@ ATOMIC_OP_ADD_RETURN( , al, "memory")
740 + static inline void __lse_atomic_and(int i, atomic_t *v)
741 + {
742 + asm volatile(
743 ++ __LSE_PREAMBLE
744 + " mvn %w[i], %w[i]\n"
745 + " stclr %w[i], %[v]"
746 + : [i] "+&r" (i), [v] "+Q" (v->counter)
747 +@@ -87,6 +91,7 @@ static inline void __lse_atomic_and(int i, atomic_t *v)
748 + static inline int __lse_atomic_fetch_and##name(int i, atomic_t *v) \
749 + { \
750 + asm volatile( \
751 ++ __LSE_PREAMBLE \
752 + " mvn %w[i], %w[i]\n" \
753 + " ldclr" #mb " %w[i], %w[i], %[v]" \
754 + : [i] "+&r" (i), [v] "+Q" (v->counter) \
755 +@@ -106,6 +111,7 @@ ATOMIC_FETCH_OP_AND( , al, "memory")
756 + static inline void __lse_atomic_sub(int i, atomic_t *v)
757 + {
758 + asm volatile(
759 ++ __LSE_PREAMBLE
760 + " neg %w[i], %w[i]\n"
761 + " stadd %w[i], %[v]"
762 + : [i] "+&r" (i), [v] "+Q" (v->counter)
763 +@@ -118,6 +124,7 @@ static inline int __lse_atomic_sub_return##name(int i, atomic_t *v) \
764 + u32 tmp; \
765 + \
766 + asm volatile( \
767 ++ __LSE_PREAMBLE \
768 + " neg %w[i], %w[i]\n" \
769 + " ldadd" #mb " %w[i], %w[tmp], %[v]\n" \
770 + " add %w[i], %w[i], %w[tmp]" \
771 +@@ -139,6 +146,7 @@ ATOMIC_OP_SUB_RETURN( , al, "memory")
772 + static inline int __lse_atomic_fetch_sub##name(int i, atomic_t *v) \
773 + { \
774 + asm volatile( \
775 ++ __LSE_PREAMBLE \
776 + " neg %w[i], %w[i]\n" \
777 + " ldadd" #mb " %w[i], %w[i], %[v]" \
778 + : [i] "+&r" (i), [v] "+Q" (v->counter) \
779 +@@ -159,6 +167,7 @@ ATOMIC_FETCH_OP_SUB( , al, "memory")
780 + static inline void __lse_atomic64_##op(s64 i, atomic64_t *v) \
781 + { \
782 + asm volatile( \
783 ++ __LSE_PREAMBLE \
784 + " " #asm_op " %[i], %[v]\n" \
785 + : [i] "+r" (i), [v] "+Q" (v->counter) \
786 + : "r" (v)); \
787 +@@ -175,6 +184,7 @@ ATOMIC64_OP(add, stadd)
788 + static inline long __lse_atomic64_fetch_##op##name(s64 i, atomic64_t *v)\
789 + { \
790 + asm volatile( \
791 ++ __LSE_PREAMBLE \
792 + " " #asm_op #mb " %[i], %[i], %[v]" \
793 + : [i] "+r" (i), [v] "+Q" (v->counter) \
794 + : "r" (v) \
795 +@@ -203,6 +213,7 @@ static inline long __lse_atomic64_add_return##name(s64 i, atomic64_t *v)\
796 + unsigned long tmp; \
797 + \
798 + asm volatile( \
799 ++ __LSE_PREAMBLE \
800 + " ldadd" #mb " %[i], %x[tmp], %[v]\n" \
801 + " add %[i], %[i], %x[tmp]" \
802 + : [i] "+r" (i), [v] "+Q" (v->counter), [tmp] "=&r" (tmp) \
803 +@@ -222,6 +233,7 @@ ATOMIC64_OP_ADD_RETURN( , al, "memory")
804 + static inline void __lse_atomic64_and(s64 i, atomic64_t *v)
805 + {
806 + asm volatile(
807 ++ __LSE_PREAMBLE
808 + " mvn %[i], %[i]\n"
809 + " stclr %[i], %[v]"
810 + : [i] "+&r" (i), [v] "+Q" (v->counter)
811 +@@ -232,6 +244,7 @@ static inline void __lse_atomic64_and(s64 i, atomic64_t *v)
812 + static inline long __lse_atomic64_fetch_and##name(s64 i, atomic64_t *v) \
813 + { \
814 + asm volatile( \
815 ++ __LSE_PREAMBLE \
816 + " mvn %[i], %[i]\n" \
817 + " ldclr" #mb " %[i], %[i], %[v]" \
818 + : [i] "+&r" (i), [v] "+Q" (v->counter) \
819 +@@ -251,6 +264,7 @@ ATOMIC64_FETCH_OP_AND( , al, "memory")
820 + static inline void __lse_atomic64_sub(s64 i, atomic64_t *v)
821 + {
822 + asm volatile(
823 ++ __LSE_PREAMBLE
824 + " neg %[i], %[i]\n"
825 + " stadd %[i], %[v]"
826 + : [i] "+&r" (i), [v] "+Q" (v->counter)
827 +@@ -263,6 +277,7 @@ static inline long __lse_atomic64_sub_return##name(s64 i, atomic64_t *v) \
828 + unsigned long tmp; \
829 + \
830 + asm volatile( \
831 ++ __LSE_PREAMBLE \
832 + " neg %[i], %[i]\n" \
833 + " ldadd" #mb " %[i], %x[tmp], %[v]\n" \
834 + " add %[i], %[i], %x[tmp]" \
835 +@@ -284,6 +299,7 @@ ATOMIC64_OP_SUB_RETURN( , al, "memory")
836 + static inline long __lse_atomic64_fetch_sub##name(s64 i, atomic64_t *v) \
837 + { \
838 + asm volatile( \
839 ++ __LSE_PREAMBLE \
840 + " neg %[i], %[i]\n" \
841 + " ldadd" #mb " %[i], %[i], %[v]" \
842 + : [i] "+&r" (i), [v] "+Q" (v->counter) \
843 +@@ -305,6 +321,7 @@ static inline s64 __lse_atomic64_dec_if_positive(atomic64_t *v)
844 + unsigned long tmp;
845 +
846 + asm volatile(
847 ++ __LSE_PREAMBLE
848 + "1: ldr %x[tmp], %[v]\n"
849 + " subs %[ret], %x[tmp], #1\n"
850 + " b.lt 2f\n"
851 +@@ -332,6 +349,7 @@ __lse__cmpxchg_case_##name##sz(volatile void *ptr, \
852 + unsigned long tmp; \
853 + \
854 + asm volatile( \
855 ++ __LSE_PREAMBLE \
856 + " mov %" #w "[tmp], %" #w "[old]\n" \
857 + " cas" #mb #sfx "\t%" #w "[tmp], %" #w "[new], %[v]\n" \
858 + " mov %" #w "[ret], %" #w "[tmp]" \
859 +@@ -379,6 +397,7 @@ __lse__cmpxchg_double##name(unsigned long old1, \
860 + register unsigned long x4 asm ("x4") = (unsigned long)ptr; \
861 + \
862 + asm volatile( \
863 ++ __LSE_PREAMBLE \
864 + " casp" #mb "\t%[old1], %[old2], %[new1], %[new2], %[v]\n"\
865 + " eor %[old1], %[old1], %[oldval1]\n" \
866 + " eor %[old2], %[old2], %[oldval2]\n" \
867 +diff --git a/arch/arm64/include/asm/lse.h b/arch/arm64/include/asm/lse.h
868 +index 80b388278149..73834996c4b6 100644
869 +--- a/arch/arm64/include/asm/lse.h
870 ++++ b/arch/arm64/include/asm/lse.h
871 +@@ -6,6 +6,8 @@
872 +
873 + #if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS)
874 +
875 ++#define __LSE_PREAMBLE ".arch armv8-a+lse\n"
876 ++
877 + #include <linux/compiler_types.h>
878 + #include <linux/export.h>
879 + #include <linux/jump_label.h>
880 +@@ -14,8 +16,6 @@
881 + #include <asm/atomic_lse.h>
882 + #include <asm/cpucaps.h>
883 +
884 +-__asm__(".arch_extension lse");
885 +-
886 + extern struct static_key_false cpu_hwcap_keys[ARM64_NCAPS];
887 + extern struct static_key_false arm64_const_caps_ready;
888 +
889 +@@ -34,7 +34,7 @@ static inline bool system_uses_lse_atomics(void)
890 +
891 + /* In-line patching at runtime */
892 + #define ARM64_LSE_ATOMIC_INSN(llsc, lse) \
893 +- ALTERNATIVE(llsc, lse, ARM64_HAS_LSE_ATOMICS)
894 ++ ALTERNATIVE(llsc, __LSE_PREAMBLE lse, ARM64_HAS_LSE_ATOMICS)
895 +
896 + #else /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
897 +
898 +diff --git a/arch/microblaze/kernel/cpu/cache.c b/arch/microblaze/kernel/cpu/cache.c
899 +index 0bde47e4fa69..dcba53803fa5 100644
900 +--- a/arch/microblaze/kernel/cpu/cache.c
901 ++++ b/arch/microblaze/kernel/cpu/cache.c
902 +@@ -92,7 +92,8 @@ static inline void __disable_dcache_nomsr(void)
903 + #define CACHE_LOOP_LIMITS(start, end, cache_line_length, cache_size) \
904 + do { \
905 + int align = ~(cache_line_length - 1); \
906 +- end = min(start + cache_size, end); \
907 ++ if (start < UINT_MAX - cache_size) \
908 ++ end = min(start + cache_size, end); \
909 + start &= align; \
910 + } while (0)
911 +
912 +diff --git a/arch/mips/boot/dts/ralink/gardena_smart_gateway_mt7688.dts b/arch/mips/boot/dts/ralink/gardena_smart_gateway_mt7688.dts
913 +index aa5caaa31104..aad9a8a8669b 100644
914 +--- a/arch/mips/boot/dts/ralink/gardena_smart_gateway_mt7688.dts
915 ++++ b/arch/mips/boot/dts/ralink/gardena_smart_gateway_mt7688.dts
916 +@@ -177,6 +177,9 @@
917 + pinctrl-names = "default";
918 + pinctrl-0 = <&pinmux_i2s_gpio>; /* GPIO0..3 */
919 +
920 ++ fifo-size = <8>;
921 ++ tx-threshold = <8>;
922 ++
923 + rts-gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
924 + cts-gpios = <&gpio 2 GPIO_ACTIVE_LOW>;
925 + };
926 +diff --git a/arch/powerpc/Makefile.postlink b/arch/powerpc/Makefile.postlink
927 +index 134f12f89b92..2268396ff4bb 100644
928 +--- a/arch/powerpc/Makefile.postlink
929 ++++ b/arch/powerpc/Makefile.postlink
930 +@@ -17,11 +17,11 @@ quiet_cmd_head_check = CHKHEAD $@
931 + quiet_cmd_relocs_check = CHKREL $@
932 + ifdef CONFIG_PPC_BOOK3S_64
933 + cmd_relocs_check = \
934 +- $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$@" ; \
935 ++ $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$(NM)" "$@" ; \
936 + $(BASH) $(srctree)/arch/powerpc/tools/unrel_branch_check.sh "$(OBJDUMP)" "$@"
937 + else
938 + cmd_relocs_check = \
939 +- $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$@"
940 ++ $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$(NM)" "$@"
941 + endif
942 +
943 + # `@true` prevents complaint when there is nothing to be done
944 +diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
945 +index 3dd1a422fc29..a1eaffe868de 100644
946 +--- a/arch/powerpc/kernel/eeh_driver.c
947 ++++ b/arch/powerpc/kernel/eeh_driver.c
948 +@@ -525,12 +525,6 @@ static void eeh_rmv_device(struct eeh_dev *edev, void *userdata)
949 +
950 + pci_iov_remove_virtfn(edev->physfn, pdn->vf_index);
951 + edev->pdev = NULL;
952 +-
953 +- /*
954 +- * We have to set the VF PE number to invalid one, which is
955 +- * required to plug the VF successfully.
956 +- */
957 +- pdn->pe_number = IODA_INVALID_PE;
958 + #endif
959 + if (rmv_data)
960 + list_add(&edev->rmv_entry, &rmv_data->removed_vf_list);
961 +diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
962 +index 9524009ca1ae..d876eda92609 100644
963 +--- a/arch/powerpc/kernel/pci_dn.c
964 ++++ b/arch/powerpc/kernel/pci_dn.c
965 +@@ -244,9 +244,22 @@ void remove_dev_pci_data(struct pci_dev *pdev)
966 + continue;
967 +
968 + #ifdef CONFIG_EEH
969 +- /* Release EEH device for the VF */
970 ++ /*
971 ++ * Release EEH state for this VF. The PCI core
972 ++ * has already torn down the pci_dev for this VF, but
973 ++ * we're responsible to removing the eeh_dev since it
974 ++ * has the same lifetime as the pci_dn that spawned it.
975 ++ */
976 + edev = pdn_to_eeh_dev(pdn);
977 + if (edev) {
978 ++ /*
979 ++ * We allocate pci_dn's for the totalvfs count,
980 ++ * but only only the vfs that were activated
981 ++ * have a configured PE.
982 ++ */
983 ++ if (edev->pe)
984 ++ eeh_rmv_from_parent_pe(edev);
985 ++
986 + pdn->edev = NULL;
987 + kfree(edev);
988 + }
989 +diff --git a/arch/powerpc/kvm/book3s_hv_uvmem.c b/arch/powerpc/kvm/book3s_hv_uvmem.c
990 +index 2de264fc3156..5914fbfa5e0a 100644
991 +--- a/arch/powerpc/kvm/book3s_hv_uvmem.c
992 ++++ b/arch/powerpc/kvm/book3s_hv_uvmem.c
993 +@@ -543,7 +543,7 @@ kvmppc_svm_page_out(struct vm_area_struct *vma, unsigned long start,
994 +
995 + ret = migrate_vma_setup(&mig);
996 + if (ret)
997 +- return ret;
998 ++ goto out;
999 +
1000 + spage = migrate_pfn_to_page(*mig.src);
1001 + if (!spage || !(*mig.src & MIGRATE_PFN_MIGRATE))
1002 +diff --git a/arch/powerpc/kvm/emulate_loadstore.c b/arch/powerpc/kvm/emulate_loadstore.c
1003 +index 2e496eb86e94..1139bc56e004 100644
1004 +--- a/arch/powerpc/kvm/emulate_loadstore.c
1005 ++++ b/arch/powerpc/kvm/emulate_loadstore.c
1006 +@@ -73,7 +73,6 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
1007 + {
1008 + struct kvm_run *run = vcpu->run;
1009 + u32 inst;
1010 +- int ra, rs, rt;
1011 + enum emulation_result emulated = EMULATE_FAIL;
1012 + int advance = 1;
1013 + struct instruction_op op;
1014 +@@ -85,10 +84,6 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
1015 + if (emulated != EMULATE_DONE)
1016 + return emulated;
1017 +
1018 +- ra = get_ra(inst);
1019 +- rs = get_rs(inst);
1020 +- rt = get_rt(inst);
1021 +-
1022 + vcpu->arch.mmio_vsx_copy_nums = 0;
1023 + vcpu->arch.mmio_vsx_offset = 0;
1024 + vcpu->arch.mmio_copy_type = KVMPPC_VSX_COPY_NONE;
1025 +diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
1026 +index 1baeb045f7f4..e083a9f67f70 100644
1027 +--- a/arch/powerpc/mm/fault.c
1028 ++++ b/arch/powerpc/mm/fault.c
1029 +@@ -354,6 +354,9 @@ static void sanity_check_fault(bool is_write, bool is_user,
1030 + * Userspace trying to access kernel address, we get PROTFAULT for that.
1031 + */
1032 + if (is_user && address >= TASK_SIZE) {
1033 ++ if ((long)address == -1)
1034 ++ return;
1035 ++
1036 + pr_crit_ratelimited("%s[%d]: User access of kernel address (%lx) - exploit attempt? (uid: %d)\n",
1037 + current->comm, current->pid, address,
1038 + from_kuid(&init_user_ns, current_uid()));
1039 +diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
1040 +index da1068a9c263..67e4628dd527 100644
1041 +--- a/arch/powerpc/platforms/powernv/pci-ioda.c
1042 ++++ b/arch/powerpc/platforms/powernv/pci-ioda.c
1043 +@@ -1558,6 +1558,10 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs)
1044 +
1045 + /* Reserve PE for each VF */
1046 + for (vf_index = 0; vf_index < num_vfs; vf_index++) {
1047 ++ int vf_devfn = pci_iov_virtfn_devfn(pdev, vf_index);
1048 ++ int vf_bus = pci_iov_virtfn_bus(pdev, vf_index);
1049 ++ struct pci_dn *vf_pdn;
1050 ++
1051 + if (pdn->m64_single_mode)
1052 + pe_num = pdn->pe_num_map[vf_index];
1053 + else
1054 +@@ -1570,13 +1574,11 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs)
1055 + pe->pbus = NULL;
1056 + pe->parent_dev = pdev;
1057 + pe->mve_number = -1;
1058 +- pe->rid = (pci_iov_virtfn_bus(pdev, vf_index) << 8) |
1059 +- pci_iov_virtfn_devfn(pdev, vf_index);
1060 ++ pe->rid = (vf_bus << 8) | vf_devfn;
1061 +
1062 + pe_info(pe, "VF %04d:%02d:%02d.%d associated with PE#%x\n",
1063 + hose->global_number, pdev->bus->number,
1064 +- PCI_SLOT(pci_iov_virtfn_devfn(pdev, vf_index)),
1065 +- PCI_FUNC(pci_iov_virtfn_devfn(pdev, vf_index)), pe_num);
1066 ++ PCI_SLOT(vf_devfn), PCI_FUNC(vf_devfn), pe_num);
1067 +
1068 + if (pnv_ioda_configure_pe(phb, pe)) {
1069 + /* XXX What do we do here ? */
1070 +@@ -1590,6 +1592,15 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs)
1071 + list_add_tail(&pe->list, &phb->ioda.pe_list);
1072 + mutex_unlock(&phb->ioda.pe_list_mutex);
1073 +
1074 ++ /* associate this pe to it's pdn */
1075 ++ list_for_each_entry(vf_pdn, &pdn->parent->child_list, list) {
1076 ++ if (vf_pdn->busno == vf_bus &&
1077 ++ vf_pdn->devfn == vf_devfn) {
1078 ++ vf_pdn->pe_number = pe_num;
1079 ++ break;
1080 ++ }
1081 ++ }
1082 ++
1083 + pnv_pci_ioda2_setup_dma_pe(phb, pe);
1084 + #ifdef CONFIG_IOMMU_API
1085 + iommu_register_group(&pe->table_group,
1086 +@@ -2889,9 +2900,6 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev)
1087 + struct pci_dn *pdn;
1088 + int mul, total_vfs;
1089 +
1090 +- if (!pdev->is_physfn || pci_dev_is_added(pdev))
1091 +- return;
1092 +-
1093 + pdn = pci_get_pdn(pdev);
1094 + pdn->vfs_expanded = 0;
1095 + pdn->m64_single_mode = false;
1096 +@@ -2966,6 +2974,30 @@ truncate_iov:
1097 + res->end = res->start - 1;
1098 + }
1099 + }
1100 ++
1101 ++static void pnv_pci_ioda_fixup_iov(struct pci_dev *pdev)
1102 ++{
1103 ++ if (WARN_ON(pci_dev_is_added(pdev)))
1104 ++ return;
1105 ++
1106 ++ if (pdev->is_virtfn) {
1107 ++ struct pnv_ioda_pe *pe = pnv_ioda_get_pe(pdev);
1108 ++
1109 ++ /*
1110 ++ * VF PEs are single-device PEs so their pdev pointer needs to
1111 ++ * be set. The pdev doesn't exist when the PE is allocated (in
1112 ++ * (pcibios_sriov_enable()) so we fix it up here.
1113 ++ */
1114 ++ pe->pdev = pdev;
1115 ++ WARN_ON(!(pe->flags & PNV_IODA_PE_VF));
1116 ++ } else if (pdev->is_physfn) {
1117 ++ /*
1118 ++ * For PFs adjust their allocated IOV resources to match what
1119 ++ * the PHB can support using it's M64 BAR table.
1120 ++ */
1121 ++ pnv_pci_ioda_fixup_iov_resources(pdev);
1122 ++ }
1123 ++}
1124 + #endif /* CONFIG_PCI_IOV */
1125 +
1126 + static void pnv_ioda_setup_pe_res(struct pnv_ioda_pe *pe,
1127 +@@ -3862,7 +3894,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
1128 + ppc_md.pcibios_default_alignment = pnv_pci_default_alignment;
1129 +
1130 + #ifdef CONFIG_PCI_IOV
1131 +- ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_iov_resources;
1132 ++ ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_iov;
1133 + ppc_md.pcibios_iov_resource_alignment = pnv_pci_iov_resource_alignment;
1134 + ppc_md.pcibios_sriov_enable = pnv_pcibios_sriov_enable;
1135 + ppc_md.pcibios_sriov_disable = pnv_pcibios_sriov_disable;
1136 +diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
1137 +index c0bea75ac27b..8307e1f4086c 100644
1138 +--- a/arch/powerpc/platforms/powernv/pci.c
1139 ++++ b/arch/powerpc/platforms/powernv/pci.c
1140 +@@ -814,24 +814,6 @@ void pnv_pci_dma_dev_setup(struct pci_dev *pdev)
1141 + {
1142 + struct pci_controller *hose = pci_bus_to_host(pdev->bus);
1143 + struct pnv_phb *phb = hose->private_data;
1144 +-#ifdef CONFIG_PCI_IOV
1145 +- struct pnv_ioda_pe *pe;
1146 +- struct pci_dn *pdn;
1147 +-
1148 +- /* Fix the VF pdn PE number */
1149 +- if (pdev->is_virtfn) {
1150 +- pdn = pci_get_pdn(pdev);
1151 +- WARN_ON(pdn->pe_number != IODA_INVALID_PE);
1152 +- list_for_each_entry(pe, &phb->ioda.pe_list, list) {
1153 +- if (pe->rid == ((pdev->bus->number << 8) |
1154 +- (pdev->devfn & 0xff))) {
1155 +- pdn->pe_number = pe->pe_number;
1156 +- pe->pdev = pdev;
1157 +- break;
1158 +- }
1159 +- }
1160 +- }
1161 +-#endif /* CONFIG_PCI_IOV */
1162 +
1163 + if (phb && phb->dma_dev_setup)
1164 + phb->dma_dev_setup(phb, pdev);
1165 +diff --git a/arch/powerpc/platforms/pseries/lparcfg.c b/arch/powerpc/platforms/pseries/lparcfg.c
1166 +index e33e8bc4b69b..38c306551f76 100644
1167 +--- a/arch/powerpc/platforms/pseries/lparcfg.c
1168 ++++ b/arch/powerpc/platforms/pseries/lparcfg.c
1169 +@@ -435,10 +435,10 @@ static void maxmem_data(struct seq_file *m)
1170 + {
1171 + unsigned long maxmem = 0;
1172 +
1173 +- maxmem += drmem_info->n_lmbs * drmem_info->lmb_size;
1174 ++ maxmem += (unsigned long)drmem_info->n_lmbs * drmem_info->lmb_size;
1175 + maxmem += hugetlb_total_pages() * PAGE_SIZE;
1176 +
1177 +- seq_printf(m, "MaxMem=%ld\n", maxmem);
1178 ++ seq_printf(m, "MaxMem=%lu\n", maxmem);
1179 + }
1180 +
1181 + static int pseries_lparcfg_data(struct seq_file *m, void *v)
1182 +diff --git a/arch/powerpc/tools/relocs_check.sh b/arch/powerpc/tools/relocs_check.sh
1183 +index 7b9fe0a567cf..014e00e74d2b 100755
1184 +--- a/arch/powerpc/tools/relocs_check.sh
1185 ++++ b/arch/powerpc/tools/relocs_check.sh
1186 +@@ -10,14 +10,21 @@
1187 + # based on relocs_check.pl
1188 + # Copyright © 2009 IBM Corporation
1189 +
1190 +-if [ $# -lt 2 ]; then
1191 +- echo "$0 [path to objdump] [path to vmlinux]" 1>&2
1192 ++if [ $# -lt 3 ]; then
1193 ++ echo "$0 [path to objdump] [path to nm] [path to vmlinux]" 1>&2
1194 + exit 1
1195 + fi
1196 +
1197 +-# Have Kbuild supply the path to objdump so we handle cross compilation.
1198 ++# Have Kbuild supply the path to objdump and nm so we handle cross compilation.
1199 + objdump="$1"
1200 +-vmlinux="$2"
1201 ++nm="$2"
1202 ++vmlinux="$3"
1203 ++
1204 ++# Remove from the bad relocations those that match an undefined weak symbol
1205 ++# which will result in an absolute relocation to 0.
1206 ++# Weak unresolved symbols are of that form in nm output:
1207 ++# " w _binary__btf_vmlinux_bin_end"
1208 ++undef_weak_symbols=$($nm "$vmlinux" | awk '$1 ~ /w/ { print $2 }')
1209 +
1210 + bad_relocs=$(
1211 + $objdump -R "$vmlinux" |
1212 +@@ -26,8 +33,6 @@ $objdump -R "$vmlinux" |
1213 + # These relocations are okay
1214 + # On PPC64:
1215 + # R_PPC64_RELATIVE, R_PPC64_NONE
1216 +- # R_PPC64_ADDR64 mach_<name>
1217 +- # R_PPC64_ADDR64 __crc_<name>
1218 + # On PPC:
1219 + # R_PPC_RELATIVE, R_PPC_ADDR16_HI,
1220 + # R_PPC_ADDR16_HA,R_PPC_ADDR16_LO,
1221 +@@ -39,8 +44,7 @@ R_PPC_ADDR16_HI
1222 + R_PPC_ADDR16_HA
1223 + R_PPC_RELATIVE
1224 + R_PPC_NONE' |
1225 +- grep -E -v '\<R_PPC64_ADDR64[[:space:]]+mach_' |
1226 +- grep -E -v '\<R_PPC64_ADDR64[[:space:]]+__crc_'
1227 ++ ([ "$undef_weak_symbols" ] && grep -F -w -v "$undef_weak_symbols" || cat)
1228 + )
1229 +
1230 + if [ -z "$bad_relocs" ]; then
1231 +diff --git a/arch/s390/Makefile b/arch/s390/Makefile
1232 +index ba8556bb0fb1..e0e3a465bbfd 100644
1233 +--- a/arch/s390/Makefile
1234 ++++ b/arch/s390/Makefile
1235 +@@ -69,7 +69,7 @@ cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
1236 + #
1237 + cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
1238 +
1239 +-ifeq ($(call cc-option-yn,-mpacked-stack),y)
1240 ++ifeq ($(call cc-option-yn,-mpacked-stack -mbackchain -msoft-float),y)
1241 + cflags-$(CONFIG_PACK_STACK) += -mpacked-stack -D__PACK_STACK
1242 + aflags-$(CONFIG_PACK_STACK) += -D__PACK_STACK
1243 + endif
1244 +diff --git a/arch/s390/boot/head.S b/arch/s390/boot/head.S
1245 +index 4b86a8d3c121..dae10961d072 100644
1246 +--- a/arch/s390/boot/head.S
1247 ++++ b/arch/s390/boot/head.S
1248 +@@ -329,7 +329,7 @@ ENTRY(startup_kdump)
1249 + .quad .Lduct # cr5: primary-aste origin
1250 + .quad 0 # cr6: I/O interrupts
1251 + .quad 0 # cr7: secondary space segment table
1252 +- .quad 0 # cr8: access registers translation
1253 ++ .quad 0x0000000000008000 # cr8: access registers translation
1254 + .quad 0 # cr9: tracing off
1255 + .quad 0 # cr10: tracing off
1256 + .quad 0 # cr11: tracing off
1257 +diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h
1258 +index a2b11ac00f60..7725f8006fdf 100644
1259 +--- a/arch/s390/include/asm/bug.h
1260 ++++ b/arch/s390/include/asm/bug.h
1261 +@@ -10,15 +10,14 @@
1262 +
1263 + #define __EMIT_BUG(x) do { \
1264 + asm_inline volatile( \
1265 +- "0: j 0b+2\n" \
1266 +- "1:\n" \
1267 ++ "0: mc 0,0\n" \
1268 + ".section .rodata.str,\"aMS\",@progbits,1\n" \
1269 +- "2: .asciz \""__FILE__"\"\n" \
1270 ++ "1: .asciz \""__FILE__"\"\n" \
1271 + ".previous\n" \
1272 + ".section __bug_table,\"awM\",@progbits,%2\n" \
1273 +- "3: .long 1b-3b,2b-3b\n" \
1274 ++ "2: .long 0b-2b,1b-2b\n" \
1275 + " .short %0,%1\n" \
1276 +- " .org 3b+%2\n" \
1277 ++ " .org 2b+%2\n" \
1278 + ".previous\n" \
1279 + : : "i" (__LINE__), \
1280 + "i" (x), \
1281 +@@ -29,12 +28,11 @@
1282 +
1283 + #define __EMIT_BUG(x) do { \
1284 + asm_inline volatile( \
1285 +- "0: j 0b+2\n" \
1286 +- "1:\n" \
1287 ++ "0: mc 0,0\n" \
1288 + ".section __bug_table,\"awM\",@progbits,%1\n" \
1289 +- "2: .long 1b-2b\n" \
1290 ++ "1: .long 0b-1b\n" \
1291 + " .short %0\n" \
1292 +- " .org 2b+%1\n" \
1293 ++ " .org 1b+%1\n" \
1294 + ".previous\n" \
1295 + : : "i" (x), \
1296 + "i" (sizeof(struct bug_entry))); \
1297 +diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
1298 +index 3a06c264ea53..b05187ce5dbd 100644
1299 +--- a/arch/s390/include/asm/pci.h
1300 ++++ b/arch/s390/include/asm/pci.h
1301 +@@ -180,7 +180,7 @@ void zpci_remove_reserved_devices(void);
1302 + /* CLP */
1303 + int clp_scan_pci_devices(void);
1304 + int clp_rescan_pci_devices(void);
1305 +-int clp_rescan_pci_devices_simple(void);
1306 ++int clp_rescan_pci_devices_simple(u32 *fid);
1307 + int clp_add_pci_device(u32, u32, int);
1308 + int clp_enable_fh(struct zpci_dev *, u8);
1309 + int clp_disable_fh(struct zpci_dev *);
1310 +diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h
1311 +index b2956d49b6ad..1d3927e01a5f 100644
1312 +--- a/arch/s390/kernel/entry.h
1313 ++++ b/arch/s390/kernel/entry.h
1314 +@@ -45,6 +45,7 @@ void specification_exception(struct pt_regs *regs);
1315 + void transaction_exception(struct pt_regs *regs);
1316 + void translation_exception(struct pt_regs *regs);
1317 + void vector_exception(struct pt_regs *regs);
1318 ++void monitor_event_exception(struct pt_regs *regs);
1319 +
1320 + void do_per_trap(struct pt_regs *regs);
1321 + void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str);
1322 +diff --git a/arch/s390/kernel/mcount.S b/arch/s390/kernel/mcount.S
1323 +index c3597d2e2ae0..f942341429b1 100644
1324 +--- a/arch/s390/kernel/mcount.S
1325 ++++ b/arch/s390/kernel/mcount.S
1326 +@@ -26,6 +26,12 @@ ENDPROC(ftrace_stub)
1327 + #define STACK_PTREGS (STACK_FRAME_OVERHEAD)
1328 + #define STACK_PTREGS_GPRS (STACK_PTREGS + __PT_GPRS)
1329 + #define STACK_PTREGS_PSW (STACK_PTREGS + __PT_PSW)
1330 ++#ifdef __PACK_STACK
1331 ++/* allocate just enough for r14, r15 and backchain */
1332 ++#define TRACED_FUNC_FRAME_SIZE 24
1333 ++#else
1334 ++#define TRACED_FUNC_FRAME_SIZE STACK_FRAME_OVERHEAD
1335 ++#endif
1336 +
1337 + ENTRY(_mcount)
1338 + BR_EX %r14
1339 +@@ -40,9 +46,16 @@ ENTRY(ftrace_caller)
1340 + #if !(defined(CC_USING_HOTPATCH) || defined(CC_USING_NOP_MCOUNT))
1341 + aghi %r0,MCOUNT_RETURN_FIXUP
1342 + #endif
1343 +- aghi %r15,-STACK_FRAME_SIZE
1344 ++ # allocate stack frame for ftrace_caller to contain traced function
1345 ++ aghi %r15,-TRACED_FUNC_FRAME_SIZE
1346 + stg %r1,__SF_BACKCHAIN(%r15)
1347 ++ stg %r0,(__SF_GPRS+8*8)(%r15)
1348 ++ stg %r15,(__SF_GPRS+9*8)(%r15)
1349 ++ # allocate pt_regs and stack frame for ftrace_trace_function
1350 ++ aghi %r15,-STACK_FRAME_SIZE
1351 + stg %r1,(STACK_PTREGS_GPRS+15*8)(%r15)
1352 ++ aghi %r1,-TRACED_FUNC_FRAME_SIZE
1353 ++ stg %r1,__SF_BACKCHAIN(%r15)
1354 + stg %r0,(STACK_PTREGS_PSW+8)(%r15)
1355 + stmg %r2,%r14,(STACK_PTREGS_GPRS+2*8)(%r15)
1356 + #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
1357 +diff --git a/arch/s390/kernel/pgm_check.S b/arch/s390/kernel/pgm_check.S
1358 +index 59dee9d3bebf..eee3a482195a 100644
1359 +--- a/arch/s390/kernel/pgm_check.S
1360 ++++ b/arch/s390/kernel/pgm_check.S
1361 +@@ -81,7 +81,7 @@ PGM_CHECK_DEFAULT /* 3c */
1362 + PGM_CHECK_DEFAULT /* 3d */
1363 + PGM_CHECK_DEFAULT /* 3e */
1364 + PGM_CHECK_DEFAULT /* 3f */
1365 +-PGM_CHECK_DEFAULT /* 40 */
1366 ++PGM_CHECK(monitor_event_exception) /* 40 */
1367 + PGM_CHECK_DEFAULT /* 41 */
1368 + PGM_CHECK_DEFAULT /* 42 */
1369 + PGM_CHECK_DEFAULT /* 43 */
1370 +diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
1371 +index 164c0282b41a..dc75588d7894 100644
1372 +--- a/arch/s390/kernel/traps.c
1373 ++++ b/arch/s390/kernel/traps.c
1374 +@@ -53,11 +53,6 @@ void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str)
1375 + if (fixup)
1376 + regs->psw.addr = extable_fixup(fixup);
1377 + else {
1378 +- enum bug_trap_type btt;
1379 +-
1380 +- btt = report_bug(regs->psw.addr, regs);
1381 +- if (btt == BUG_TRAP_TYPE_WARN)
1382 +- return;
1383 + die(regs, str);
1384 + }
1385 + }
1386 +@@ -245,6 +240,27 @@ void space_switch_exception(struct pt_regs *regs)
1387 + do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event");
1388 + }
1389 +
1390 ++void monitor_event_exception(struct pt_regs *regs)
1391 ++{
1392 ++ const struct exception_table_entry *fixup;
1393 ++
1394 ++ if (user_mode(regs))
1395 ++ return;
1396 ++
1397 ++ switch (report_bug(regs->psw.addr - (regs->int_code >> 16), regs)) {
1398 ++ case BUG_TRAP_TYPE_NONE:
1399 ++ fixup = s390_search_extables(regs->psw.addr);
1400 ++ if (fixup)
1401 ++ regs->psw.addr = extable_fixup(fixup);
1402 ++ break;
1403 ++ case BUG_TRAP_TYPE_WARN:
1404 ++ break;
1405 ++ case BUG_TRAP_TYPE_BUG:
1406 ++ die(regs, "monitor event");
1407 ++ break;
1408 ++ }
1409 ++}
1410 ++
1411 + void kernel_stack_overflow(struct pt_regs *regs)
1412 + {
1413 + bust_spinlocks(1);
1414 +@@ -255,8 +271,23 @@ void kernel_stack_overflow(struct pt_regs *regs)
1415 + }
1416 + NOKPROBE_SYMBOL(kernel_stack_overflow);
1417 +
1418 ++static void test_monitor_call(void)
1419 ++{
1420 ++ int val = 1;
1421 ++
1422 ++ asm volatile(
1423 ++ " mc 0,0\n"
1424 ++ "0: xgr %0,%0\n"
1425 ++ "1:\n"
1426 ++ EX_TABLE(0b,1b)
1427 ++ : "+d" (val));
1428 ++ if (!val)
1429 ++ panic("Monitor call doesn't work!\n");
1430 ++}
1431 ++
1432 + void __init trap_init(void)
1433 + {
1434 + sort_extable(__start_dma_ex_table, __stop_dma_ex_table);
1435 + local_mcck_enable();
1436 ++ test_monitor_call();
1437 + }
1438 +diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
1439 +index 165dea4c7f19..c06c89d370a7 100644
1440 +--- a/arch/s390/kvm/interrupt.c
1441 ++++ b/arch/s390/kvm/interrupt.c
1442 +@@ -2190,7 +2190,7 @@ static int flic_ais_mode_get_all(struct kvm *kvm, struct kvm_device_attr *attr)
1443 + return -EINVAL;
1444 +
1445 + if (!test_kvm_facility(kvm, 72))
1446 +- return -ENOTSUPP;
1447 ++ return -EOPNOTSUPP;
1448 +
1449 + mutex_lock(&fi->ais_lock);
1450 + ais.simm = fi->simm;
1451 +@@ -2499,7 +2499,7 @@ static int modify_ais_mode(struct kvm *kvm, struct kvm_device_attr *attr)
1452 + int ret = 0;
1453 +
1454 + if (!test_kvm_facility(kvm, 72))
1455 +- return -ENOTSUPP;
1456 ++ return -EOPNOTSUPP;
1457 +
1458 + if (copy_from_user(&req, (void __user *)attr->addr, sizeof(req)))
1459 + return -EFAULT;
1460 +@@ -2579,7 +2579,7 @@ static int flic_ais_mode_set_all(struct kvm *kvm, struct kvm_device_attr *attr)
1461 + struct kvm_s390_ais_all ais;
1462 +
1463 + if (!test_kvm_facility(kvm, 72))
1464 +- return -ENOTSUPP;
1465 ++ return -EOPNOTSUPP;
1466 +
1467 + if (copy_from_user(&ais, (void __user *)attr->addr, sizeof(ais)))
1468 + return -EFAULT;
1469 +diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
1470 +index 8e872951c07b..bc61ea18e88d 100644
1471 +--- a/arch/s390/pci/pci.c
1472 ++++ b/arch/s390/pci/pci.c
1473 +@@ -939,5 +939,5 @@ subsys_initcall_sync(pci_base_init);
1474 + void zpci_rescan(void)
1475 + {
1476 + if (zpci_is_enabled())
1477 +- clp_rescan_pci_devices_simple();
1478 ++ clp_rescan_pci_devices_simple(NULL);
1479 + }
1480 +diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c
1481 +index 4c613e569fe0..0d3d8f170ea4 100644
1482 +--- a/arch/s390/pci/pci_clp.c
1483 ++++ b/arch/s390/pci/pci_clp.c
1484 +@@ -240,12 +240,14 @@ error:
1485 + }
1486 +
1487 + /*
1488 +- * Enable/Disable a given PCI function defined by its function handle.
1489 ++ * Enable/Disable a given PCI function and update its function handle if
1490 ++ * necessary
1491 + */
1492 +-static int clp_set_pci_fn(u32 *fh, u8 nr_dma_as, u8 command)
1493 ++static int clp_set_pci_fn(struct zpci_dev *zdev, u8 nr_dma_as, u8 command)
1494 + {
1495 + struct clp_req_rsp_set_pci *rrb;
1496 + int rc, retries = 100;
1497 ++ u32 fid = zdev->fid;
1498 +
1499 + rrb = clp_alloc_block(GFP_KERNEL);
1500 + if (!rrb)
1501 +@@ -256,7 +258,7 @@ static int clp_set_pci_fn(u32 *fh, u8 nr_dma_as, u8 command)
1502 + rrb->request.hdr.len = sizeof(rrb->request);
1503 + rrb->request.hdr.cmd = CLP_SET_PCI_FN;
1504 + rrb->response.hdr.len = sizeof(rrb->response);
1505 +- rrb->request.fh = *fh;
1506 ++ rrb->request.fh = zdev->fh;
1507 + rrb->request.oc = command;
1508 + rrb->request.ndas = nr_dma_as;
1509 +
1510 +@@ -269,12 +271,17 @@ static int clp_set_pci_fn(u32 *fh, u8 nr_dma_as, u8 command)
1511 + }
1512 + } while (rrb->response.hdr.rsp == CLP_RC_SETPCIFN_BUSY);
1513 +
1514 +- if (!rc && rrb->response.hdr.rsp == CLP_RC_OK)
1515 +- *fh = rrb->response.fh;
1516 +- else {
1517 ++ if (rc || rrb->response.hdr.rsp != CLP_RC_OK) {
1518 + zpci_err("Set PCI FN:\n");
1519 + zpci_err_clp(rrb->response.hdr.rsp, rc);
1520 +- rc = -EIO;
1521 ++ }
1522 ++
1523 ++ if (!rc && rrb->response.hdr.rsp == CLP_RC_OK) {
1524 ++ zdev->fh = rrb->response.fh;
1525 ++ } else if (!rc && rrb->response.hdr.rsp == CLP_RC_SETPCIFN_ALRDY &&
1526 ++ rrb->response.fh == 0) {
1527 ++ /* Function is already in desired state - update handle */
1528 ++ rc = clp_rescan_pci_devices_simple(&fid);
1529 + }
1530 + clp_free_block(rrb);
1531 + return rc;
1532 +@@ -282,18 +289,17 @@ static int clp_set_pci_fn(u32 *fh, u8 nr_dma_as, u8 command)
1533 +
1534 + int clp_enable_fh(struct zpci_dev *zdev, u8 nr_dma_as)
1535 + {
1536 +- u32 fh = zdev->fh;
1537 + int rc;
1538 +
1539 +- rc = clp_set_pci_fn(&fh, nr_dma_as, CLP_SET_ENABLE_PCI_FN);
1540 +- zpci_dbg(3, "ena fid:%x, fh:%x, rc:%d\n", zdev->fid, fh, rc);
1541 ++ rc = clp_set_pci_fn(zdev, nr_dma_as, CLP_SET_ENABLE_PCI_FN);
1542 ++ zpci_dbg(3, "ena fid:%x, fh:%x, rc:%d\n", zdev->fid, zdev->fh, rc);
1543 + if (rc)
1544 + goto out;
1545 +
1546 +- zdev->fh = fh;
1547 + if (zpci_use_mio(zdev)) {
1548 +- rc = clp_set_pci_fn(&fh, nr_dma_as, CLP_SET_ENABLE_MIO);
1549 +- zpci_dbg(3, "ena mio fid:%x, fh:%x, rc:%d\n", zdev->fid, fh, rc);
1550 ++ rc = clp_set_pci_fn(zdev, nr_dma_as, CLP_SET_ENABLE_MIO);
1551 ++ zpci_dbg(3, "ena mio fid:%x, fh:%x, rc:%d\n",
1552 ++ zdev->fid, zdev->fh, rc);
1553 + if (rc)
1554 + clp_disable_fh(zdev);
1555 + }
1556 +@@ -309,11 +315,8 @@ int clp_disable_fh(struct zpci_dev *zdev)
1557 + if (!zdev_enabled(zdev))
1558 + return 0;
1559 +
1560 +- rc = clp_set_pci_fn(&fh, 0, CLP_SET_DISABLE_PCI_FN);
1561 ++ rc = clp_set_pci_fn(zdev, 0, CLP_SET_DISABLE_PCI_FN);
1562 + zpci_dbg(3, "dis fid:%x, fh:%x, rc:%d\n", zdev->fid, fh, rc);
1563 +- if (!rc)
1564 +- zdev->fh = fh;
1565 +-
1566 + return rc;
1567 + }
1568 +
1569 +@@ -370,10 +373,14 @@ static void __clp_add(struct clp_fh_list_entry *entry, void *data)
1570 + static void __clp_update(struct clp_fh_list_entry *entry, void *data)
1571 + {
1572 + struct zpci_dev *zdev;
1573 ++ u32 *fid = data;
1574 +
1575 + if (!entry->vendor_id)
1576 + return;
1577 +
1578 ++ if (fid && *fid != entry->fid)
1579 ++ return;
1580 ++
1581 + zdev = get_zdev_by_fid(entry->fid);
1582 + if (!zdev)
1583 + return;
1584 +@@ -413,7 +420,10 @@ int clp_rescan_pci_devices(void)
1585 + return rc;
1586 + }
1587 +
1588 +-int clp_rescan_pci_devices_simple(void)
1589 ++/* Rescan PCI functions and refresh function handles. If fid is non-NULL only
1590 ++ * refresh the handle of the function matching @fid
1591 ++ */
1592 ++int clp_rescan_pci_devices_simple(u32 *fid)
1593 + {
1594 + struct clp_req_rsp_list_pci *rrb;
1595 + int rc;
1596 +@@ -422,7 +432,7 @@ int clp_rescan_pci_devices_simple(void)
1597 + if (!rrb)
1598 + return -ENOMEM;
1599 +
1600 +- rc = clp_list_pci(rrb, NULL, __clp_update);
1601 ++ rc = clp_list_pci(rrb, fid, __clp_update);
1602 +
1603 + clp_free_block(rrb);
1604 + return rc;
1605 +diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c
1606 +index a433ba01a317..215f17437a4f 100644
1607 +--- a/arch/s390/pci/pci_sysfs.c
1608 ++++ b/arch/s390/pci/pci_sysfs.c
1609 +@@ -13,6 +13,8 @@
1610 + #include <linux/stat.h>
1611 + #include <linux/pci.h>
1612 +
1613 ++#include "../../../drivers/pci/pci.h"
1614 ++
1615 + #include <asm/sclp.h>
1616 +
1617 + #define zpci_attr(name, fmt, member) \
1618 +@@ -49,31 +51,50 @@ static DEVICE_ATTR_RO(mio_enabled);
1619 + static ssize_t recover_store(struct device *dev, struct device_attribute *attr,
1620 + const char *buf, size_t count)
1621 + {
1622 ++ struct kernfs_node *kn;
1623 + struct pci_dev *pdev = to_pci_dev(dev);
1624 + struct zpci_dev *zdev = to_zpci(pdev);
1625 +- int ret;
1626 +-
1627 +- if (!device_remove_file_self(dev, attr))
1628 +- return count;
1629 +-
1630 ++ int ret = 0;
1631 ++
1632 ++ /* Can't use device_remove_self() here as that would lead us to lock
1633 ++ * the pci_rescan_remove_lock while holding the device' kernfs lock.
1634 ++ * This would create a possible deadlock with disable_slot() which is
1635 ++ * not directly protected by the device' kernfs lock but takes it
1636 ++ * during the device removal which happens under
1637 ++ * pci_rescan_remove_lock.
1638 ++ *
1639 ++ * This is analogous to sdev_store_delete() in
1640 ++ * drivers/scsi/scsi_sysfs.c
1641 ++ */
1642 ++ kn = sysfs_break_active_protection(&dev->kobj, &attr->attr);
1643 ++ WARN_ON_ONCE(!kn);
1644 ++ /* device_remove_file() serializes concurrent calls ignoring all but
1645 ++ * the first
1646 ++ */
1647 ++ device_remove_file(dev, attr);
1648 ++
1649 ++ /* A concurrent call to recover_store() may slip between
1650 ++ * sysfs_break_active_protection() and the sysfs file removal.
1651 ++ * Once it unblocks from pci_lock_rescan_remove() the original pdev
1652 ++ * will already be removed.
1653 ++ */
1654 + pci_lock_rescan_remove();
1655 +- pci_stop_and_remove_bus_device(pdev);
1656 +- ret = zpci_disable_device(zdev);
1657 +- if (ret)
1658 +- goto error;
1659 +-
1660 +- ret = zpci_enable_device(zdev);
1661 +- if (ret)
1662 +- goto error;
1663 +-
1664 +- pci_rescan_bus(zdev->bus);
1665 ++ if (pci_dev_is_added(pdev)) {
1666 ++ pci_stop_and_remove_bus_device(pdev);
1667 ++ ret = zpci_disable_device(zdev);
1668 ++ if (ret)
1669 ++ goto out;
1670 ++
1671 ++ ret = zpci_enable_device(zdev);
1672 ++ if (ret)
1673 ++ goto out;
1674 ++ pci_rescan_bus(zdev->bus);
1675 ++ }
1676 ++out:
1677 + pci_unlock_rescan_remove();
1678 +-
1679 +- return count;
1680 +-
1681 +-error:
1682 +- pci_unlock_rescan_remove();
1683 +- return ret;
1684 ++ if (kn)
1685 ++ sysfs_unbreak_active_protection(kn);
1686 ++ return ret ? ret : count;
1687 + }
1688 + static DEVICE_ATTR_WO(recover);
1689 +
1690 +diff --git a/arch/sh/include/cpu-sh2a/cpu/sh7269.h b/arch/sh/include/cpu-sh2a/cpu/sh7269.h
1691 +index d516e5d48818..b887cc402b71 100644
1692 +--- a/arch/sh/include/cpu-sh2a/cpu/sh7269.h
1693 ++++ b/arch/sh/include/cpu-sh2a/cpu/sh7269.h
1694 +@@ -78,8 +78,15 @@ enum {
1695 + GPIO_FN_WDTOVF,
1696 +
1697 + /* CAN */
1698 +- GPIO_FN_CTX1, GPIO_FN_CRX1, GPIO_FN_CTX0, GPIO_FN_CTX0_CTX1,
1699 +- GPIO_FN_CRX0, GPIO_FN_CRX0_CRX1, GPIO_FN_CRX0_CRX1_CRX2,
1700 ++ GPIO_FN_CTX2, GPIO_FN_CRX2,
1701 ++ GPIO_FN_CTX1, GPIO_FN_CRX1,
1702 ++ GPIO_FN_CTX0, GPIO_FN_CRX0,
1703 ++ GPIO_FN_CTX0_CTX1, GPIO_FN_CRX0_CRX1,
1704 ++ GPIO_FN_CTX0_CTX1_CTX2, GPIO_FN_CRX0_CRX1_CRX2,
1705 ++ GPIO_FN_CTX2_PJ21, GPIO_FN_CRX2_PJ20,
1706 ++ GPIO_FN_CTX1_PJ23, GPIO_FN_CRX1_PJ22,
1707 ++ GPIO_FN_CTX0_CTX1_PJ23, GPIO_FN_CRX0_CRX1_PJ22,
1708 ++ GPIO_FN_CTX0_CTX1_CTX2_PJ21, GPIO_FN_CRX0_CRX1_CRX2_PJ20,
1709 +
1710 + /* DMAC */
1711 + GPIO_FN_TEND0, GPIO_FN_DACK0, GPIO_FN_DREQ0,
1712 +diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
1713 +index 7ec79918b566..f99e99e58075 100644
1714 +--- a/arch/sparc/kernel/vmlinux.lds.S
1715 ++++ b/arch/sparc/kernel/vmlinux.lds.S
1716 +@@ -171,12 +171,14 @@ SECTIONS
1717 + }
1718 + PERCPU_SECTION(SMP_CACHE_BYTES)
1719 +
1720 +-#ifdef CONFIG_JUMP_LABEL
1721 + . = ALIGN(PAGE_SIZE);
1722 + .exit.text : {
1723 + EXIT_TEXT
1724 + }
1725 +-#endif
1726 ++
1727 ++ .exit.data : {
1728 ++ EXIT_DATA
1729 ++ }
1730 +
1731 + . = ALIGN(PAGE_SIZE);
1732 + __init_end = .;
1733 +diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
1734 +index 95410d6ee2ff..748b6d28a91d 100644
1735 +--- a/arch/x86/boot/Makefile
1736 ++++ b/arch/x86/boot/Makefile
1737 +@@ -88,7 +88,7 @@ $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
1738 +
1739 + SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
1740 +
1741 +-sed-zoffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|kernel_info\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
1742 ++sed-zoffset := -e 's/^\([0-9a-fA-F]*\) [a-zA-Z] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|kernel_info\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
1743 +
1744 + quiet_cmd_zoffset = ZOFFSET $@
1745 + cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
1746 +diff --git a/arch/x86/entry/vdso/vdso32-setup.c b/arch/x86/entry/vdso/vdso32-setup.c
1747 +index 240626e7f55a..43842fade8fa 100644
1748 +--- a/arch/x86/entry/vdso/vdso32-setup.c
1749 ++++ b/arch/x86/entry/vdso/vdso32-setup.c
1750 +@@ -11,6 +11,7 @@
1751 + #include <linux/smp.h>
1752 + #include <linux/kernel.h>
1753 + #include <linux/mm_types.h>
1754 ++#include <linux/elf.h>
1755 +
1756 + #include <asm/processor.h>
1757 + #include <asm/vdso.h>
1758 +diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
1759 +index dede714b46e8..3253797fa8a1 100644
1760 +--- a/arch/x86/events/amd/core.c
1761 ++++ b/arch/x86/events/amd/core.c
1762 +@@ -302,6 +302,25 @@ static inline int amd_pmu_addr_offset(int index, bool eventsel)
1763 + return offset;
1764 + }
1765 +
1766 ++/*
1767 ++ * AMD64 events are detected based on their event codes.
1768 ++ */
1769 ++static inline unsigned int amd_get_event_code(struct hw_perf_event *hwc)
1770 ++{
1771 ++ return ((hwc->config >> 24) & 0x0f00) | (hwc->config & 0x00ff);
1772 ++}
1773 ++
1774 ++static inline bool amd_is_pair_event_code(struct hw_perf_event *hwc)
1775 ++{
1776 ++ if (!(x86_pmu.flags & PMU_FL_PAIR))
1777 ++ return false;
1778 ++
1779 ++ switch (amd_get_event_code(hwc)) {
1780 ++ case 0x003: return true; /* Retired SSE/AVX FLOPs */
1781 ++ default: return false;
1782 ++ }
1783 ++}
1784 ++
1785 + static int amd_core_hw_config(struct perf_event *event)
1786 + {
1787 + if (event->attr.exclude_host && event->attr.exclude_guest)
1788 +@@ -320,14 +339,6 @@ static int amd_core_hw_config(struct perf_event *event)
1789 + return 0;
1790 + }
1791 +
1792 +-/*
1793 +- * AMD64 events are detected based on their event codes.
1794 +- */
1795 +-static inline unsigned int amd_get_event_code(struct hw_perf_event *hwc)
1796 +-{
1797 +- return ((hwc->config >> 24) & 0x0f00) | (hwc->config & 0x00ff);
1798 +-}
1799 +-
1800 + static inline int amd_is_nb_event(struct hw_perf_event *hwc)
1801 + {
1802 + return (hwc->config & 0xe0) == 0xe0;
1803 +@@ -856,6 +867,20 @@ amd_get_event_constraints_f15h(struct cpu_hw_events *cpuc, int idx,
1804 + }
1805 + }
1806 +
1807 ++static struct event_constraint pair_constraint;
1808 ++
1809 ++static struct event_constraint *
1810 ++amd_get_event_constraints_f17h(struct cpu_hw_events *cpuc, int idx,
1811 ++ struct perf_event *event)
1812 ++{
1813 ++ struct hw_perf_event *hwc = &event->hw;
1814 ++
1815 ++ if (amd_is_pair_event_code(hwc))
1816 ++ return &pair_constraint;
1817 ++
1818 ++ return &unconstrained;
1819 ++}
1820 ++
1821 + static ssize_t amd_event_sysfs_show(char *page, u64 config)
1822 + {
1823 + u64 event = (config & ARCH_PERFMON_EVENTSEL_EVENT) |
1824 +@@ -899,33 +924,15 @@ static __initconst const struct x86_pmu amd_pmu = {
1825 +
1826 + static int __init amd_core_pmu_init(void)
1827 + {
1828 ++ u64 even_ctr_mask = 0ULL;
1829 ++ int i;
1830 ++
1831 + if (!boot_cpu_has(X86_FEATURE_PERFCTR_CORE))
1832 + return 0;
1833 +
1834 +- /* Avoid calulating the value each time in the NMI handler */
1835 ++ /* Avoid calculating the value each time in the NMI handler */
1836 + perf_nmi_window = msecs_to_jiffies(100);
1837 +
1838 +- switch (boot_cpu_data.x86) {
1839 +- case 0x15:
1840 +- pr_cont("Fam15h ");
1841 +- x86_pmu.get_event_constraints = amd_get_event_constraints_f15h;
1842 +- break;
1843 +- case 0x17:
1844 +- pr_cont("Fam17h ");
1845 +- /*
1846 +- * In family 17h, there are no event constraints in the PMC hardware.
1847 +- * We fallback to using default amd_get_event_constraints.
1848 +- */
1849 +- break;
1850 +- case 0x18:
1851 +- pr_cont("Fam18h ");
1852 +- /* Using default amd_get_event_constraints. */
1853 +- break;
1854 +- default:
1855 +- pr_err("core perfctr but no constraints; unknown hardware!\n");
1856 +- return -ENODEV;
1857 +- }
1858 +-
1859 + /*
1860 + * If core performance counter extensions exists, we must use
1861 + * MSR_F15H_PERF_CTL/MSR_F15H_PERF_CTR msrs. See also
1862 +@@ -940,6 +947,30 @@ static int __init amd_core_pmu_init(void)
1863 + */
1864 + x86_pmu.amd_nb_constraints = 0;
1865 +
1866 ++ if (boot_cpu_data.x86 == 0x15) {
1867 ++ pr_cont("Fam15h ");
1868 ++ x86_pmu.get_event_constraints = amd_get_event_constraints_f15h;
1869 ++ }
1870 ++ if (boot_cpu_data.x86 >= 0x17) {
1871 ++ pr_cont("Fam17h+ ");
1872 ++ /*
1873 ++ * Family 17h and compatibles have constraints for Large
1874 ++ * Increment per Cycle events: they may only be assigned an
1875 ++ * even numbered counter that has a consecutive adjacent odd
1876 ++ * numbered counter following it.
1877 ++ */
1878 ++ for (i = 0; i < x86_pmu.num_counters - 1; i += 2)
1879 ++ even_ctr_mask |= 1 << i;
1880 ++
1881 ++ pair_constraint = (struct event_constraint)
1882 ++ __EVENT_CONSTRAINT(0, even_ctr_mask, 0,
1883 ++ x86_pmu.num_counters / 2, 0,
1884 ++ PERF_X86_EVENT_PAIR);
1885 ++
1886 ++ x86_pmu.get_event_constraints = amd_get_event_constraints_f17h;
1887 ++ x86_pmu.flags |= PMU_FL_PAIR;
1888 ++ }
1889 ++
1890 + pr_cont("core perfctr, ");
1891 + return 0;
1892 + }
1893 +diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
1894 +index 930611db8f9a..e2fd363de649 100644
1895 +--- a/arch/x86/events/perf_event.h
1896 ++++ b/arch/x86/events/perf_event.h
1897 +@@ -77,6 +77,7 @@ static inline bool constraint_match(struct event_constraint *c, u64 ecode)
1898 + #define PERF_X86_EVENT_AUTO_RELOAD 0x0200 /* use PEBS auto-reload */
1899 + #define PERF_X86_EVENT_LARGE_PEBS 0x0400 /* use large PEBS */
1900 + #define PERF_X86_EVENT_PEBS_VIA_PT 0x0800 /* use PT buffer for PEBS */
1901 ++#define PERF_X86_EVENT_PAIR 0x1000 /* Large Increment per Cycle */
1902 +
1903 + struct amd_nb {
1904 + int nb_id; /* NorthBridge id */
1905 +@@ -743,6 +744,7 @@ do { \
1906 + #define PMU_FL_EXCL_ENABLED 0x8 /* exclusive counter active */
1907 + #define PMU_FL_PEBS_ALL 0x10 /* all events are valid PEBS events */
1908 + #define PMU_FL_TFA 0x20 /* deal with TSX force abort */
1909 ++#define PMU_FL_PAIR 0x40 /* merge counters for large incr. events */
1910 +
1911 + #define EVENT_VAR(_id) event_attr_##_id
1912 + #define EVENT_PTR(_id) &event_attr_##_id.attr.attr
1913 +diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
1914 +index 75ded1d13d98..9d5d949e662e 100644
1915 +--- a/arch/x86/include/asm/nmi.h
1916 ++++ b/arch/x86/include/asm/nmi.h
1917 +@@ -41,7 +41,6 @@ struct nmiaction {
1918 + struct list_head list;
1919 + nmi_handler_t handler;
1920 + u64 max_duration;
1921 +- struct irq_work irq_work;
1922 + unsigned long flags;
1923 + const char *name;
1924 + };
1925 +diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
1926 +index d5b51a740524..ad53b2abc859 100644
1927 +--- a/arch/x86/kernel/apic/x2apic_uv_x.c
1928 ++++ b/arch/x86/kernel/apic/x2apic_uv_x.c
1929 +@@ -1493,65 +1493,34 @@ static void check_efi_reboot(void)
1930 + }
1931 +
1932 + /* Setup user proc fs files */
1933 +-static int proc_hubbed_show(struct seq_file *file, void *data)
1934 ++static int __maybe_unused proc_hubbed_show(struct seq_file *file, void *data)
1935 + {
1936 + seq_printf(file, "0x%x\n", uv_hubbed_system);
1937 + return 0;
1938 + }
1939 +
1940 +-static int proc_hubless_show(struct seq_file *file, void *data)
1941 ++static int __maybe_unused proc_hubless_show(struct seq_file *file, void *data)
1942 + {
1943 + seq_printf(file, "0x%x\n", uv_hubless_system);
1944 + return 0;
1945 + }
1946 +
1947 +-static int proc_oemid_show(struct seq_file *file, void *data)
1948 ++static int __maybe_unused proc_oemid_show(struct seq_file *file, void *data)
1949 + {
1950 + seq_printf(file, "%s/%s\n", oem_id, oem_table_id);
1951 + return 0;
1952 + }
1953 +
1954 +-static int proc_hubbed_open(struct inode *inode, struct file *file)
1955 +-{
1956 +- return single_open(file, proc_hubbed_show, (void *)NULL);
1957 +-}
1958 +-
1959 +-static int proc_hubless_open(struct inode *inode, struct file *file)
1960 +-{
1961 +- return single_open(file, proc_hubless_show, (void *)NULL);
1962 +-}
1963 +-
1964 +-static int proc_oemid_open(struct inode *inode, struct file *file)
1965 +-{
1966 +- return single_open(file, proc_oemid_show, (void *)NULL);
1967 +-}
1968 +-
1969 +-/* (struct is "non-const" as open function is set at runtime) */
1970 +-static struct file_operations proc_version_fops = {
1971 +- .read = seq_read,
1972 +- .llseek = seq_lseek,
1973 +- .release = single_release,
1974 +-};
1975 +-
1976 +-static const struct file_operations proc_oemid_fops = {
1977 +- .open = proc_oemid_open,
1978 +- .read = seq_read,
1979 +- .llseek = seq_lseek,
1980 +- .release = single_release,
1981 +-};
1982 +-
1983 + static __init void uv_setup_proc_files(int hubless)
1984 + {
1985 + struct proc_dir_entry *pde;
1986 +- char *name = hubless ? "hubless" : "hubbed";
1987 +
1988 + pde = proc_mkdir(UV_PROC_NODE, NULL);
1989 +- proc_create("oemid", 0, pde, &proc_oemid_fops);
1990 +- proc_create(name, 0, pde, &proc_version_fops);
1991 ++ proc_create_single("oemid", 0, pde, proc_oemid_show);
1992 + if (hubless)
1993 +- proc_version_fops.open = proc_hubless_open;
1994 ++ proc_create_single("hubless", 0, pde, proc_hubless_show);
1995 + else
1996 +- proc_version_fops.open = proc_hubbed_open;
1997 ++ proc_create_single("hubbed", 0, pde, proc_hubbed_show);
1998 + }
1999 +
2000 + /* Initialize UV hubless systems */
2001 +diff --git a/arch/x86/kernel/cpu/mce/therm_throt.c b/arch/x86/kernel/cpu/mce/therm_throt.c
2002 +index 6c3e1c92f183..58b4ee3cda77 100644
2003 +--- a/arch/x86/kernel/cpu/mce/therm_throt.c
2004 ++++ b/arch/x86/kernel/cpu/mce/therm_throt.c
2005 +@@ -235,7 +235,7 @@ static void get_therm_status(int level, bool *proc_hot, u8 *temp)
2006 + *temp = (msr_val >> 16) & 0x7F;
2007 + }
2008 +
2009 +-static void throttle_active_work(struct work_struct *work)
2010 ++static void __maybe_unused throttle_active_work(struct work_struct *work)
2011 + {
2012 + struct _thermal_state *state = container_of(to_delayed_work(work),
2013 + struct _thermal_state, therm_work);
2014 +diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
2015 +index 0071b794ed19..400a05e1c1c5 100644
2016 +--- a/arch/x86/kernel/fpu/signal.c
2017 ++++ b/arch/x86/kernel/fpu/signal.c
2018 +@@ -352,6 +352,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
2019 + fpregs_unlock();
2020 + return 0;
2021 + }
2022 ++ fpregs_deactivate(fpu);
2023 + fpregs_unlock();
2024 + }
2025 +
2026 +@@ -403,6 +404,8 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
2027 + }
2028 + if (!ret)
2029 + fpregs_mark_activate();
2030 ++ else
2031 ++ fpregs_deactivate(fpu);
2032 + fpregs_unlock();
2033 +
2034 + err_out:
2035 +diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
2036 +index e676a9916c49..54c21d6abd5a 100644
2037 +--- a/arch/x86/kernel/nmi.c
2038 ++++ b/arch/x86/kernel/nmi.c
2039 +@@ -104,18 +104,22 @@ static int __init nmi_warning_debugfs(void)
2040 + }
2041 + fs_initcall(nmi_warning_debugfs);
2042 +
2043 +-static void nmi_max_handler(struct irq_work *w)
2044 ++static void nmi_check_duration(struct nmiaction *action, u64 duration)
2045 + {
2046 +- struct nmiaction *a = container_of(w, struct nmiaction, irq_work);
2047 ++ u64 whole_msecs = READ_ONCE(action->max_duration);
2048 + int remainder_ns, decimal_msecs;
2049 +- u64 whole_msecs = READ_ONCE(a->max_duration);
2050 ++
2051 ++ if (duration < nmi_longest_ns || duration < action->max_duration)
2052 ++ return;
2053 ++
2054 ++ action->max_duration = duration;
2055 +
2056 + remainder_ns = do_div(whole_msecs, (1000 * 1000));
2057 + decimal_msecs = remainder_ns / 1000;
2058 +
2059 + printk_ratelimited(KERN_INFO
2060 + "INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n",
2061 +- a->handler, whole_msecs, decimal_msecs);
2062 ++ action->handler, whole_msecs, decimal_msecs);
2063 + }
2064 +
2065 + static int nmi_handle(unsigned int type, struct pt_regs *regs)
2066 +@@ -142,11 +146,7 @@ static int nmi_handle(unsigned int type, struct pt_regs *regs)
2067 + delta = sched_clock() - delta;
2068 + trace_nmi_handler(a->handler, (int)delta, thishandled);
2069 +
2070 +- if (delta < nmi_longest_ns || delta < a->max_duration)
2071 +- continue;
2072 +-
2073 +- a->max_duration = delta;
2074 +- irq_work_queue(&a->irq_work);
2075 ++ nmi_check_duration(a, delta);
2076 + }
2077 +
2078 + rcu_read_unlock();
2079 +@@ -164,8 +164,6 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
2080 + if (!action->handler)
2081 + return -EINVAL;
2082 +
2083 +- init_irq_work(&action->irq_work, nmi_max_handler);
2084 +-
2085 + raw_spin_lock_irqsave(&desc->lock, flags);
2086 +
2087 + /*
2088 +diff --git a/arch/x86/kernel/sysfb_simplefb.c b/arch/x86/kernel/sysfb_simplefb.c
2089 +index 01f0e2263b86..298fc1edd9c9 100644
2090 +--- a/arch/x86/kernel/sysfb_simplefb.c
2091 ++++ b/arch/x86/kernel/sysfb_simplefb.c
2092 +@@ -90,11 +90,11 @@ __init int create_simplefb(const struct screen_info *si,
2093 + if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
2094 + size <<= 16;
2095 + length = mode->height * mode->stride;
2096 +- length = PAGE_ALIGN(length);
2097 + if (length > size) {
2098 + printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n");
2099 + return -EINVAL;
2100 + }
2101 ++ length = PAGE_ALIGN(length);
2102 +
2103 + /* setup IORESOURCE_MEM as framebuffer memory */
2104 + memset(&res, 0, sizeof(res));
2105 +diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt
2106 +index 8908c58bd6cd..53adc1762ec0 100644
2107 +--- a/arch/x86/lib/x86-opcode-map.txt
2108 ++++ b/arch/x86/lib/x86-opcode-map.txt
2109 +@@ -929,7 +929,7 @@ EndTable
2110 +
2111 + GrpTable: Grp3_2
2112 + 0: TEST Ev,Iz
2113 +-1:
2114 ++1: TEST Ev,Iz
2115 + 2: NOT Ev
2116 + 3: NEG Ev
2117 + 4: MUL rAX,Ev
2118 +diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
2119 +index 1b99ad05b117..f42780ba0893 100644
2120 +--- a/arch/x86/mm/pageattr.c
2121 ++++ b/arch/x86/mm/pageattr.c
2122 +@@ -2215,7 +2215,7 @@ int __init kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address,
2123 + .pgd = pgd,
2124 + .numpages = numpages,
2125 + .mask_set = __pgprot(0),
2126 +- .mask_clr = __pgprot(0),
2127 ++ .mask_clr = __pgprot(~page_flags & (_PAGE_NX|_PAGE_RW)),
2128 + .flags = 0,
2129 + };
2130 +
2131 +@@ -2224,12 +2224,6 @@ int __init kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address,
2132 + if (!(__supported_pte_mask & _PAGE_NX))
2133 + goto out;
2134 +
2135 +- if (!(page_flags & _PAGE_NX))
2136 +- cpa.mask_clr = __pgprot(_PAGE_NX);
2137 +-
2138 +- if (!(page_flags & _PAGE_RW))
2139 +- cpa.mask_clr = __pgprot(_PAGE_RW);
2140 +-
2141 + if (!(page_flags & _PAGE_ENC))
2142 + cpa.mask_clr = pgprot_encrypted(cpa.mask_clr);
2143 +
2144 +diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
2145 +index 38d44f36d5ed..ad4dd3a97753 100644
2146 +--- a/arch/x86/platform/efi/efi.c
2147 ++++ b/arch/x86/platform/efi/efi.c
2148 +@@ -541,7 +541,6 @@ void __init efi_init(void)
2149 + efi_char16_t *c16;
2150 + char vendor[100] = "unknown";
2151 + int i = 0;
2152 +- void *tmp;
2153 +
2154 + #ifdef CONFIG_X86_32
2155 + if (boot_params.efi_info.efi_systab_hi ||
2156 +@@ -566,14 +565,16 @@ void __init efi_init(void)
2157 + /*
2158 + * Show what we know for posterity
2159 + */
2160 +- c16 = tmp = early_memremap(efi.systab->fw_vendor, 2);
2161 ++ c16 = early_memremap_ro(efi.systab->fw_vendor,
2162 ++ sizeof(vendor) * sizeof(efi_char16_t));
2163 + if (c16) {
2164 +- for (i = 0; i < sizeof(vendor) - 1 && *c16; ++i)
2165 +- vendor[i] = *c16++;
2166 ++ for (i = 0; i < sizeof(vendor) - 1 && c16[i]; ++i)
2167 ++ vendor[i] = c16[i];
2168 + vendor[i] = '\0';
2169 +- } else
2170 ++ early_memunmap(c16, sizeof(vendor) * sizeof(efi_char16_t));
2171 ++ } else {
2172 + pr_err("Could not map the firmware vendor!\n");
2173 +- early_memunmap(tmp, 2);
2174 ++ }
2175 +
2176 + pr_info("EFI v%u.%.02u by %s\n",
2177 + efi.systab->hdr.revision >> 16,
2178 +@@ -999,16 +1000,14 @@ static void __init __efi_enter_virtual_mode(void)
2179 +
2180 + if (efi_alloc_page_tables()) {
2181 + pr_err("Failed to allocate EFI page tables\n");
2182 +- clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
2183 +- return;
2184 ++ goto err;
2185 + }
2186 +
2187 + efi_merge_regions();
2188 + new_memmap = efi_map_regions(&count, &pg_shift);
2189 + if (!new_memmap) {
2190 + pr_err("Error reallocating memory, EFI runtime non-functional!\n");
2191 +- clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
2192 +- return;
2193 ++ goto err;
2194 + }
2195 +
2196 + pa = __pa(new_memmap);
2197 +@@ -1022,8 +1021,7 @@ static void __init __efi_enter_virtual_mode(void)
2198 +
2199 + if (efi_memmap_init_late(pa, efi.memmap.desc_size * count)) {
2200 + pr_err("Failed to remap late EFI memory map\n");
2201 +- clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
2202 +- return;
2203 ++ goto err;
2204 + }
2205 +
2206 + if (efi_enabled(EFI_DBG)) {
2207 +@@ -1031,12 +1029,11 @@ static void __init __efi_enter_virtual_mode(void)
2208 + efi_print_memmap();
2209 + }
2210 +
2211 +- BUG_ON(!efi.systab);
2212 ++ if (WARN_ON(!efi.systab))
2213 ++ goto err;
2214 +
2215 +- if (efi_setup_page_tables(pa, 1 << pg_shift)) {
2216 +- clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
2217 +- return;
2218 +- }
2219 ++ if (efi_setup_page_tables(pa, 1 << pg_shift))
2220 ++ goto err;
2221 +
2222 + efi_sync_low_kernel_mappings();
2223 +
2224 +@@ -1056,9 +1053,9 @@ static void __init __efi_enter_virtual_mode(void)
2225 + }
2226 +
2227 + if (status != EFI_SUCCESS) {
2228 +- pr_alert("Unable to switch EFI into virtual mode (status=%lx)!\n",
2229 +- status);
2230 +- panic("EFI call to SetVirtualAddressMap() failed!");
2231 ++ pr_err("Unable to switch EFI into virtual mode (status=%lx)!\n",
2232 ++ status);
2233 ++ goto err;
2234 + }
2235 +
2236 + efi_free_boot_services();
2237 +@@ -1087,6 +1084,10 @@ static void __init __efi_enter_virtual_mode(void)
2238 +
2239 + /* clean DUMMY object */
2240 + efi_delete_dummy_variable();
2241 ++ return;
2242 ++
2243 ++err:
2244 ++ clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
2245 + }
2246 +
2247 + void __init efi_enter_virtual_mode(void)
2248 +diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
2249 +index 08ce8177c3af..52a1e5192fa8 100644
2250 +--- a/arch/x86/platform/efi/efi_64.c
2251 ++++ b/arch/x86/platform/efi/efi_64.c
2252 +@@ -392,11 +392,12 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
2253 + return 0;
2254 +
2255 + page = alloc_page(GFP_KERNEL|__GFP_DMA32);
2256 +- if (!page)
2257 +- panic("Unable to allocate EFI runtime stack < 4GB\n");
2258 ++ if (!page) {
2259 ++ pr_err("Unable to allocate EFI runtime stack < 4GB\n");
2260 ++ return 1;
2261 ++ }
2262 +
2263 +- efi_scratch.phys_stack = virt_to_phys(page_address(page));
2264 +- efi_scratch.phys_stack += PAGE_SIZE; /* stack grows down */
2265 ++ efi_scratch.phys_stack = page_to_phys(page + 1); /* stack grows down */
2266 +
2267 + npages = (_etext - _text) >> PAGE_SHIFT;
2268 + text = __pa(_text);
2269 +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
2270 +index ad4af4aaf2ce..5c239c540c47 100644
2271 +--- a/block/bfq-iosched.c
2272 ++++ b/block/bfq-iosched.c
2273 +@@ -3444,6 +3444,10 @@ static void bfq_dispatch_remove(struct request_queue *q, struct request *rq)
2274 + static bool idling_needed_for_service_guarantees(struct bfq_data *bfqd,
2275 + struct bfq_queue *bfqq)
2276 + {
2277 ++ /* No point in idling for bfqq if it won't get requests any longer */
2278 ++ if (unlikely(!bfqq_process_refs(bfqq)))
2279 ++ return false;
2280 ++
2281 + return (bfqq->wr_coeff > 1 &&
2282 + (bfqd->wr_busy_queues <
2283 + bfq_tot_busy_queues(bfqd) ||
2284 +@@ -4077,6 +4081,10 @@ static bool idling_boosts_thr_without_issues(struct bfq_data *bfqd,
2285 + bfqq_sequential_and_IO_bound,
2286 + idling_boosts_thr;
2287 +
2288 ++ /* No point in idling for bfqq if it won't get requests any longer */
2289 ++ if (unlikely(!bfqq_process_refs(bfqq)))
2290 ++ return false;
2291 ++
2292 + bfqq_sequential_and_IO_bound = !BFQQ_SEEKY(bfqq) &&
2293 + bfq_bfqq_IO_bound(bfqq) && bfq_bfqq_has_short_ttime(bfqq);
2294 +
2295 +@@ -4170,6 +4178,10 @@ static bool bfq_better_to_idle(struct bfq_queue *bfqq)
2296 + struct bfq_data *bfqd = bfqq->bfqd;
2297 + bool idling_boosts_thr_with_no_issue, idling_needed_for_service_guar;
2298 +
2299 ++ /* No point in idling for bfqq if it won't get requests any longer */
2300 ++ if (unlikely(!bfqq_process_refs(bfqq)))
2301 ++ return false;
2302 ++
2303 + if (unlikely(bfqd->strict_guarantees))
2304 + return true;
2305 +
2306 +diff --git a/crypto/Kconfig b/crypto/Kconfig
2307 +index 5575d48473bd..cdb51d4272d0 100644
2308 +--- a/crypto/Kconfig
2309 ++++ b/crypto/Kconfig
2310 +@@ -511,10 +511,10 @@ config CRYPTO_ESSIV
2311 + encryption.
2312 +
2313 + This driver implements a crypto API template that can be
2314 +- instantiated either as a skcipher or as a aead (depending on the
2315 ++ instantiated either as an skcipher or as an AEAD (depending on the
2316 + type of the first template argument), and which defers encryption
2317 + and decryption requests to the encapsulated cipher after applying
2318 +- ESSIV to the input IV. Note that in the aead case, it is assumed
2319 ++ ESSIV to the input IV. Note that in the AEAD case, it is assumed
2320 + that the keys are presented in the same format used by the authenc
2321 + template, and that the IV appears at the end of the authenticated
2322 + associated data (AAD) region (which is how dm-crypt uses it.)
2323 +diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
2324 +index faa38a22263a..ae713d746c8b 100644
2325 +--- a/drivers/acpi/acpica/dsfield.c
2326 ++++ b/drivers/acpi/acpica/dsfield.c
2327 +@@ -243,7 +243,7 @@ cleanup:
2328 + * FUNCTION: acpi_ds_get_field_names
2329 + *
2330 + * PARAMETERS: info - create_field info structure
2331 +- * ` walk_state - Current method state
2332 ++ * walk_state - Current method state
2333 + * arg - First parser arg for the field name list
2334 + *
2335 + * RETURN: Status
2336 +diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
2337 +index c88fd31208a5..4bcf15bf03de 100644
2338 +--- a/drivers/acpi/acpica/dswload.c
2339 ++++ b/drivers/acpi/acpica/dswload.c
2340 +@@ -410,6 +410,27 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
2341 + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
2342 + walk_state));
2343 +
2344 ++ /*
2345 ++ * Disassembler: handle create field operators here.
2346 ++ *
2347 ++ * create_buffer_field is a deferred op that is typically processed in load
2348 ++ * pass 2. However, disassembly of control method contents walk the parse
2349 ++ * tree with ACPI_PARSE_LOAD_PASS1 and AML_CREATE operators are processed
2350 ++ * in a later walk. This is a problem when there is a control method that
2351 ++ * has the same name as the AML_CREATE object. In this case, any use of the
2352 ++ * name segment will be detected as a method call rather than a reference
2353 ++ * to a buffer field.
2354 ++ *
2355 ++ * This earlier creation during disassembly solves this issue by inserting
2356 ++ * the named object in the ACPI namespace so that references to this name
2357 ++ * would be a name string rather than a method call.
2358 ++ */
2359 ++ if ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) &&
2360 ++ (walk_state->op_info->flags & AML_CREATE)) {
2361 ++ status = acpi_ds_create_buffer_field(op, walk_state);
2362 ++ return_ACPI_STATUS(status);
2363 ++ }
2364 ++
2365 + /* We are only interested in opcodes that have an associated name */
2366 +
2367 + if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) {
2368 +diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
2369 +index b758b45737f5..f6925f16c4a2 100644
2370 +--- a/drivers/acpi/button.c
2371 ++++ b/drivers/acpi/button.c
2372 +@@ -122,6 +122,17 @@ static const struct dmi_system_id dmi_lid_quirks[] = {
2373 + },
2374 + .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN,
2375 + },
2376 ++ {
2377 ++ /*
2378 ++ * Razer Blade Stealth 13 late 2019, notification of the LID device
2379 ++ * only happens on close, not on open and _LID always returns closed.
2380 ++ */
2381 ++ .matches = {
2382 ++ DMI_MATCH(DMI_SYS_VENDOR, "Razer"),
2383 ++ DMI_MATCH(DMI_PRODUCT_NAME, "Razer Blade Stealth 13 Late 2019"),
2384 ++ },
2385 ++ .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN,
2386 ++ },
2387 + {}
2388 + };
2389 +
2390 +diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
2391 +index f1a500205313..8fbd36eb8941 100644
2392 +--- a/drivers/atm/fore200e.c
2393 ++++ b/drivers/atm/fore200e.c
2394 +@@ -1414,12 +1414,14 @@ fore200e_open(struct atm_vcc *vcc)
2395 + static void
2396 + fore200e_close(struct atm_vcc* vcc)
2397 + {
2398 +- struct fore200e* fore200e = FORE200E_DEV(vcc->dev);
2399 + struct fore200e_vcc* fore200e_vcc;
2400 ++ struct fore200e* fore200e;
2401 + struct fore200e_vc_map* vc_map;
2402 + unsigned long flags;
2403 +
2404 + ASSERT(vcc);
2405 ++ fore200e = FORE200E_DEV(vcc->dev);
2406 ++
2407 + ASSERT((vcc->vpi >= 0) && (vcc->vpi < 1<<FORE200E_VPI_BITS));
2408 + ASSERT((vcc->vci >= 0) && (vcc->vci < 1<<FORE200E_VCI_BITS));
2409 +
2410 +@@ -1464,10 +1466,10 @@ fore200e_close(struct atm_vcc* vcc)
2411 + static int
2412 + fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
2413 + {
2414 +- struct fore200e* fore200e = FORE200E_DEV(vcc->dev);
2415 +- struct fore200e_vcc* fore200e_vcc = FORE200E_VCC(vcc);
2416 ++ struct fore200e* fore200e;
2417 ++ struct fore200e_vcc* fore200e_vcc;
2418 + struct fore200e_vc_map* vc_map;
2419 +- struct host_txq* txq = &fore200e->host_txq;
2420 ++ struct host_txq* txq;
2421 + struct host_txq_entry* entry;
2422 + struct tpd* tpd;
2423 + struct tpd_haddr tpd_haddr;
2424 +@@ -1480,9 +1482,18 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
2425 + unsigned char* data;
2426 + unsigned long flags;
2427 +
2428 +- ASSERT(vcc);
2429 +- ASSERT(fore200e);
2430 +- ASSERT(fore200e_vcc);
2431 ++ if (!vcc)
2432 ++ return -EINVAL;
2433 ++
2434 ++ fore200e = FORE200E_DEV(vcc->dev);
2435 ++ fore200e_vcc = FORE200E_VCC(vcc);
2436 ++
2437 ++ if (!fore200e)
2438 ++ return -EINVAL;
2439 ++
2440 ++ txq = &fore200e->host_txq;
2441 ++ if (!fore200e_vcc)
2442 ++ return -EINVAL;
2443 +
2444 + if (!test_bit(ATM_VF_READY, &vcc->flags)) {
2445 + DPRINTK(1, "VC %d.%d.%d not ready for tx\n", vcc->itf, vcc->vpi, vcc->vpi);
2446 +diff --git a/drivers/base/dd.c b/drivers/base/dd.c
2447 +index d811e60610d3..b25bcab2a26b 100644
2448 +--- a/drivers/base/dd.c
2449 ++++ b/drivers/base/dd.c
2450 +@@ -516,7 +516,10 @@ static int really_probe(struct device *dev, struct device_driver *drv)
2451 + atomic_inc(&probe_count);
2452 + pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
2453 + drv->bus->name, __func__, drv->name, dev_name(dev));
2454 +- WARN_ON(!list_empty(&dev->devres_head));
2455 ++ if (!list_empty(&dev->devres_head)) {
2456 ++ dev_crit(dev, "Resources present before probing\n");
2457 ++ return -EBUSY;
2458 ++ }
2459 +
2460 + re_probe:
2461 + dev->driver = drv;
2462 +diff --git a/drivers/base/platform.c b/drivers/base/platform.c
2463 +index cf6b6b722e5c..7fa654f1288b 100644
2464 +--- a/drivers/base/platform.c
2465 ++++ b/drivers/base/platform.c
2466 +@@ -27,6 +27,7 @@
2467 + #include <linux/limits.h>
2468 + #include <linux/property.h>
2469 + #include <linux/kmemleak.h>
2470 ++#include <linux/types.h>
2471 +
2472 + #include "base.h"
2473 + #include "power/power.h"
2474 +@@ -48,7 +49,7 @@ EXPORT_SYMBOL_GPL(platform_bus);
2475 + struct resource *platform_get_resource(struct platform_device *dev,
2476 + unsigned int type, unsigned int num)
2477 + {
2478 +- int i;
2479 ++ u32 i;
2480 +
2481 + for (i = 0; i < dev->num_resources; i++) {
2482 + struct resource *r = &dev->resource[i];
2483 +@@ -255,7 +256,7 @@ struct resource *platform_get_resource_byname(struct platform_device *dev,
2484 + unsigned int type,
2485 + const char *name)
2486 + {
2487 +- int i;
2488 ++ u32 i;
2489 +
2490 + for (i = 0; i < dev->num_resources; i++) {
2491 + struct resource *r = &dev->resource[i];
2492 +@@ -501,7 +502,8 @@ EXPORT_SYMBOL_GPL(platform_device_add_properties);
2493 + */
2494 + int platform_device_add(struct platform_device *pdev)
2495 + {
2496 +- int i, ret;
2497 ++ u32 i;
2498 ++ int ret;
2499 +
2500 + if (!pdev)
2501 + return -EINVAL;
2502 +@@ -569,7 +571,7 @@ int platform_device_add(struct platform_device *pdev)
2503 + pdev->id = PLATFORM_DEVID_AUTO;
2504 + }
2505 +
2506 +- while (--i >= 0) {
2507 ++ while (i--) {
2508 + struct resource *r = &pdev->resource[i];
2509 + if (r->parent)
2510 + release_resource(r);
2511 +@@ -590,7 +592,7 @@ EXPORT_SYMBOL_GPL(platform_device_add);
2512 + */
2513 + void platform_device_del(struct platform_device *pdev)
2514 + {
2515 +- int i;
2516 ++ u32 i;
2517 +
2518 + if (!IS_ERR_OR_NULL(pdev)) {
2519 + device_del(&pdev->dev);
2520 +diff --git a/drivers/block/brd.c b/drivers/block/brd.c
2521 +index a8730cc4db10..220c5e18aba0 100644
2522 +--- a/drivers/block/brd.c
2523 ++++ b/drivers/block/brd.c
2524 +@@ -473,6 +473,25 @@ static struct kobject *brd_probe(dev_t dev, int *part, void *data)
2525 + return kobj;
2526 + }
2527 +
2528 ++static inline void brd_check_and_reset_par(void)
2529 ++{
2530 ++ if (unlikely(!max_part))
2531 ++ max_part = 1;
2532 ++
2533 ++ /*
2534 ++ * make sure 'max_part' can be divided exactly by (1U << MINORBITS),
2535 ++ * otherwise, it is possiable to get same dev_t when adding partitions.
2536 ++ */
2537 ++ if ((1U << MINORBITS) % max_part != 0)
2538 ++ max_part = 1UL << fls(max_part);
2539 ++
2540 ++ if (max_part > DISK_MAX_PARTS) {
2541 ++ pr_info("brd: max_part can't be larger than %d, reset max_part = %d.\n",
2542 ++ DISK_MAX_PARTS, DISK_MAX_PARTS);
2543 ++ max_part = DISK_MAX_PARTS;
2544 ++ }
2545 ++}
2546 ++
2547 + static int __init brd_init(void)
2548 + {
2549 + struct brd_device *brd, *next;
2550 +@@ -496,8 +515,7 @@ static int __init brd_init(void)
2551 + if (register_blkdev(RAMDISK_MAJOR, "ramdisk"))
2552 + return -EIO;
2553 +
2554 +- if (unlikely(!max_part))
2555 +- max_part = 1;
2556 ++ brd_check_and_reset_par();
2557 +
2558 + for (i = 0; i < rd_nr; i++) {
2559 + brd = brd_alloc(i);
2560 +diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
2561 +index b4607dd96185..78181908f0df 100644
2562 +--- a/drivers/block/nbd.c
2563 ++++ b/drivers/block/nbd.c
2564 +@@ -1265,6 +1265,16 @@ static int nbd_start_device(struct nbd_device *nbd)
2565 + args = kzalloc(sizeof(*args), GFP_KERNEL);
2566 + if (!args) {
2567 + sock_shutdown(nbd);
2568 ++ /*
2569 ++ * If num_connections is m (2 < m),
2570 ++ * and NO.1 ~ NO.n(1 < n < m) kzallocs are successful.
2571 ++ * But NO.(n + 1) failed. We still have n recv threads.
2572 ++ * So, add flush_workqueue here to prevent recv threads
2573 ++ * dropping the last config_refs and trying to destroy
2574 ++ * the workqueue from inside the workqueue.
2575 ++ */
2576 ++ if (i)
2577 ++ flush_workqueue(nbd->recv_workq);
2578 + return -ENOMEM;
2579 + }
2580 + sk_set_memalloc(config->socks[i]->sock->sk);
2581 +diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
2582 +index 2b184563cd32..38dcb39051a7 100644
2583 +--- a/drivers/block/rbd.c
2584 ++++ b/drivers/block/rbd.c
2585 +@@ -2662,7 +2662,7 @@ static int rbd_img_fill_nodata(struct rbd_img_request *img_req,
2586 + u64 off, u64 len)
2587 + {
2588 + struct ceph_file_extent ex = { off, len };
2589 +- union rbd_img_fill_iter dummy;
2590 ++ union rbd_img_fill_iter dummy = {};
2591 + struct rbd_img_fill_ctx fctx = {
2592 + .pos_type = OBJ_REQUEST_NODATA,
2593 + .pos = &dummy,
2594 +diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
2595 +index 4285e75e52c3..1bf4a908a0bd 100644
2596 +--- a/drivers/block/zram/zram_drv.c
2597 ++++ b/drivers/block/zram/zram_drv.c
2598 +@@ -626,7 +626,7 @@ static ssize_t writeback_store(struct device *dev,
2599 + struct bio bio;
2600 + struct bio_vec bio_vec;
2601 + struct page *page;
2602 +- ssize_t ret;
2603 ++ ssize_t ret = len;
2604 + int mode;
2605 + unsigned long blk_idx = 0;
2606 +
2607 +@@ -762,7 +762,6 @@ next:
2608 +
2609 + if (blk_idx)
2610 + free_block_bdev(zram, blk_idx);
2611 +- ret = len;
2612 + __free_page(page);
2613 + release_init_lock:
2614 + up_read(&zram->init_lock);
2615 +diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
2616 +index a07cc19becdb..c78d10ea641f 100644
2617 +--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
2618 ++++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
2619 +@@ -715,9 +715,9 @@ EXPORT_SYMBOL_GPL(fsl_mc_device_remove);
2620 + struct fsl_mc_device *fsl_mc_get_endpoint(struct fsl_mc_device *mc_dev)
2621 + {
2622 + struct fsl_mc_device *mc_bus_dev, *endpoint;
2623 +- struct fsl_mc_obj_desc endpoint_desc = { 0 };
2624 +- struct dprc_endpoint endpoint1 = { 0 };
2625 +- struct dprc_endpoint endpoint2 = { 0 };
2626 ++ struct fsl_mc_obj_desc endpoint_desc = {{ 0 }};
2627 ++ struct dprc_endpoint endpoint1 = {{ 0 }};
2628 ++ struct dprc_endpoint endpoint2 = {{ 0 }};
2629 + int state, err;
2630 +
2631 + mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
2632 +diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
2633 +index ccb44fe790a7..3d79b074f958 100644
2634 +--- a/drivers/bus/ti-sysc.c
2635 ++++ b/drivers/bus/ti-sysc.c
2636 +@@ -479,7 +479,7 @@ static void sysc_clkdm_deny_idle(struct sysc *ddata)
2637 + {
2638 + struct ti_sysc_platform_data *pdata;
2639 +
2640 +- if (ddata->legacy_mode)
2641 ++ if (ddata->legacy_mode || (ddata->cfg.quirks & SYSC_QUIRK_CLKDM_NOAUTO))
2642 + return;
2643 +
2644 + pdata = dev_get_platdata(ddata->dev);
2645 +@@ -491,7 +491,7 @@ static void sysc_clkdm_allow_idle(struct sysc *ddata)
2646 + {
2647 + struct ti_sysc_platform_data *pdata;
2648 +
2649 +- if (ddata->legacy_mode)
2650 ++ if (ddata->legacy_mode || (ddata->cfg.quirks & SYSC_QUIRK_CLKDM_NOAUTO))
2651 + return;
2652 +
2653 + pdata = dev_get_platdata(ddata->dev);
2654 +@@ -1251,6 +1251,12 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
2655 + /* Quirks that need to be set based on detected module */
2656 + SYSC_QUIRK("aess", 0, 0, 0x10, -1, 0x40000000, 0xffffffff,
2657 + SYSC_MODULE_QUIRK_AESS),
2658 ++ SYSC_QUIRK("dcan", 0x48480000, 0x20, -1, -1, 0xa3170504, 0xffffffff,
2659 ++ SYSC_QUIRK_CLKDM_NOAUTO),
2660 ++ SYSC_QUIRK("dwc3", 0x48880000, 0, 0x10, -1, 0x500a0200, 0xffffffff,
2661 ++ SYSC_QUIRK_CLKDM_NOAUTO),
2662 ++ SYSC_QUIRK("dwc3", 0x488c0000, 0, 0x10, -1, 0x500a0200, 0xffffffff,
2663 ++ SYSC_QUIRK_CLKDM_NOAUTO),
2664 + SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x00000006, 0xffffffff,
2665 + SYSC_MODULE_QUIRK_HDQ1W),
2666 + SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x0000000a, 0xffffffff,
2667 +diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
2668 +index 9ac6671bb514..f69609b47fef 100644
2669 +--- a/drivers/char/hpet.c
2670 ++++ b/drivers/char/hpet.c
2671 +@@ -855,7 +855,7 @@ int hpet_alloc(struct hpet_data *hdp)
2672 + return 0;
2673 + }
2674 +
2675 +- hpetp = kzalloc(struct_size(hpetp, hp_dev, hdp->hd_nirqs - 1),
2676 ++ hpetp = kzalloc(struct_size(hpetp, hp_dev, hdp->hd_nirqs),
2677 + GFP_KERNEL);
2678 +
2679 + if (!hpetp)
2680 +diff --git a/drivers/char/random.c b/drivers/char/random.c
2681 +index cda12933a17d..ea1973d35843 100644
2682 +--- a/drivers/char/random.c
2683 ++++ b/drivers/char/random.c
2684 +@@ -1687,8 +1687,9 @@ static void _warn_unseeded_randomness(const char *func_name, void *caller,
2685 + print_once = true;
2686 + #endif
2687 + if (__ratelimit(&unseeded_warning))
2688 +- pr_notice("random: %s called from %pS with crng_init=%d\n",
2689 +- func_name, caller, crng_init);
2690 ++ printk_deferred(KERN_NOTICE "random: %s called from %pS "
2691 ++ "with crng_init=%d\n", func_name, caller,
2692 ++ crng_init);
2693 + }
2694 +
2695 + /*
2696 +diff --git a/drivers/clk/at91/sam9x60.c b/drivers/clk/at91/sam9x60.c
2697 +index 86238d5ecb4d..77398aefeb6d 100644
2698 +--- a/drivers/clk/at91/sam9x60.c
2699 ++++ b/drivers/clk/at91/sam9x60.c
2700 +@@ -47,6 +47,7 @@ static const struct clk_programmable_layout sam9x60_programmable_layout = {
2701 + .pres_shift = 8,
2702 + .css_mask = 0x1f,
2703 + .have_slck_mck = 0,
2704 ++ .is_pres_direct = 1,
2705 + };
2706 +
2707 + static const struct clk_pcr_layout sam9x60_pcr_layout = {
2708 +diff --git a/drivers/clk/clk-bm1880.c b/drivers/clk/clk-bm1880.c
2709 +index 4cd175afce9b..e6d6599d310a 100644
2710 +--- a/drivers/clk/clk-bm1880.c
2711 ++++ b/drivers/clk/clk-bm1880.c
2712 +@@ -474,11 +474,10 @@ static struct bm1880_composite_clock bm1880_composite_clks[] = {
2713 + static unsigned long bm1880_pll_rate_calc(u32 regval, unsigned long parent_rate)
2714 + {
2715 + u64 numerator;
2716 +- u32 fbdiv, fref, refdiv;
2717 ++ u32 fbdiv, refdiv;
2718 + u32 postdiv1, postdiv2, denominator;
2719 +
2720 + fbdiv = (regval >> 16) & 0xfff;
2721 +- fref = parent_rate;
2722 + refdiv = regval & 0x1f;
2723 + postdiv1 = (regval >> 8) & 0x7;
2724 + postdiv2 = (regval >> 12) & 0x7;
2725 +diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
2726 +index 772258de2d1f..66f056ac4c15 100644
2727 +--- a/drivers/clk/clk.c
2728 ++++ b/drivers/clk/clk.c
2729 +@@ -3338,6 +3338,21 @@ static int __clk_core_init(struct clk_core *core)
2730 + goto out;
2731 + }
2732 +
2733 ++ /*
2734 ++ * optional platform-specific magic
2735 ++ *
2736 ++ * The .init callback is not used by any of the basic clock types, but
2737 ++ * exists for weird hardware that must perform initialization magic.
2738 ++ * Please consider other ways of solving initialization problems before
2739 ++ * using this callback, as its use is discouraged.
2740 ++ *
2741 ++ * If it exist, this callback should called before any other callback of
2742 ++ * the clock
2743 ++ */
2744 ++ if (core->ops->init)
2745 ++ core->ops->init(core->hw);
2746 ++
2747 ++
2748 + core->parent = __clk_init_parent(core);
2749 +
2750 + /*
2751 +@@ -3362,17 +3377,6 @@ static int __clk_core_init(struct clk_core *core)
2752 + core->orphan = true;
2753 + }
2754 +
2755 +- /*
2756 +- * optional platform-specific magic
2757 +- *
2758 +- * The .init callback is not used by any of the basic clock types, but
2759 +- * exists for weird hardware that must perform initialization magic.
2760 +- * Please consider other ways of solving initialization problems before
2761 +- * using this callback, as its use is discouraged.
2762 +- */
2763 +- if (core->ops->init)
2764 +- core->ops->init(core->hw);
2765 +-
2766 + /*
2767 + * Set clk's accuracy. The preferred method is to use
2768 + * .recalc_accuracy. For simple clocks and lazy developers the default
2769 +@@ -3732,6 +3736,28 @@ fail_out:
2770 + return ERR_PTR(ret);
2771 + }
2772 +
2773 ++/**
2774 ++ * dev_or_parent_of_node() - Get device node of @dev or @dev's parent
2775 ++ * @dev: Device to get device node of
2776 ++ *
2777 ++ * Return: device node pointer of @dev, or the device node pointer of
2778 ++ * @dev->parent if dev doesn't have a device node, or NULL if neither
2779 ++ * @dev or @dev->parent have a device node.
2780 ++ */
2781 ++static struct device_node *dev_or_parent_of_node(struct device *dev)
2782 ++{
2783 ++ struct device_node *np;
2784 ++
2785 ++ if (!dev)
2786 ++ return NULL;
2787 ++
2788 ++ np = dev_of_node(dev);
2789 ++ if (!np)
2790 ++ np = dev_of_node(dev->parent);
2791 ++
2792 ++ return np;
2793 ++}
2794 ++
2795 + /**
2796 + * clk_register - allocate a new clock, register it and return an opaque cookie
2797 + * @dev: device that is registering this clock
2798 +@@ -3747,7 +3773,7 @@ fail_out:
2799 + */
2800 + struct clk *clk_register(struct device *dev, struct clk_hw *hw)
2801 + {
2802 +- return __clk_register(dev, dev_of_node(dev), hw);
2803 ++ return __clk_register(dev, dev_or_parent_of_node(dev), hw);
2804 + }
2805 + EXPORT_SYMBOL_GPL(clk_register);
2806 +
2807 +@@ -3763,7 +3789,8 @@ EXPORT_SYMBOL_GPL(clk_register);
2808 + */
2809 + int clk_hw_register(struct device *dev, struct clk_hw *hw)
2810 + {
2811 +- return PTR_ERR_OR_ZERO(__clk_register(dev, dev_of_node(dev), hw));
2812 ++ return PTR_ERR_OR_ZERO(__clk_register(dev, dev_or_parent_of_node(dev),
2813 ++ hw));
2814 + }
2815 + EXPORT_SYMBOL_GPL(clk_hw_register);
2816 +
2817 +diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
2818 +index bc5bb6ac8636..30ddbc1ced2e 100644
2819 +--- a/drivers/clk/imx/clk.h
2820 ++++ b/drivers/clk/imx/clk.h
2821 +@@ -54,48 +54,48 @@ extern struct imx_pll14xx_clk imx_1416x_pll;
2822 + extern struct imx_pll14xx_clk imx_1443x_pll;
2823 +
2824 + #define imx_clk_cpu(name, parent_name, div, mux, pll, step) \
2825 +- imx_clk_hw_cpu(name, parent_name, div, mux, pll, step)->clk
2826 ++ to_clk(imx_clk_hw_cpu(name, parent_name, div, mux, pll, step))
2827 +
2828 + #define clk_register_gate2(dev, name, parent_name, flags, reg, bit_idx, \
2829 + cgr_val, clk_gate_flags, lock, share_count) \
2830 +- clk_hw_register_gate2(dev, name, parent_name, flags, reg, bit_idx, \
2831 +- cgr_val, clk_gate_flags, lock, share_count)->clk
2832 ++ to_clk(clk_hw_register_gate2(dev, name, parent_name, flags, reg, bit_idx, \
2833 ++ cgr_val, clk_gate_flags, lock, share_count))
2834 +
2835 + #define imx_clk_pllv3(type, name, parent_name, base, div_mask) \
2836 +- imx_clk_hw_pllv3(type, name, parent_name, base, div_mask)->clk
2837 ++ to_clk(imx_clk_hw_pllv3(type, name, parent_name, base, div_mask))
2838 +
2839 + #define imx_clk_pfd(name, parent_name, reg, idx) \
2840 +- imx_clk_hw_pfd(name, parent_name, reg, idx)->clk
2841 ++ to_clk(imx_clk_hw_pfd(name, parent_name, reg, idx))
2842 +
2843 + #define imx_clk_gate_exclusive(name, parent, reg, shift, exclusive_mask) \
2844 +- imx_clk_hw_gate_exclusive(name, parent, reg, shift, exclusive_mask)->clk
2845 ++ to_clk(imx_clk_hw_gate_exclusive(name, parent, reg, shift, exclusive_mask))
2846 +
2847 + #define imx_clk_fixed_factor(name, parent, mult, div) \
2848 +- imx_clk_hw_fixed_factor(name, parent, mult, div)->clk
2849 ++ to_clk(imx_clk_hw_fixed_factor(name, parent, mult, div))
2850 +
2851 + #define imx_clk_divider2(name, parent, reg, shift, width) \
2852 +- imx_clk_hw_divider2(name, parent, reg, shift, width)->clk
2853 ++ to_clk(imx_clk_hw_divider2(name, parent, reg, shift, width))
2854 +
2855 + #define imx_clk_gate_dis(name, parent, reg, shift) \
2856 +- imx_clk_hw_gate_dis(name, parent, reg, shift)->clk
2857 ++ to_clk(imx_clk_hw_gate_dis(name, parent, reg, shift))
2858 +
2859 + #define imx_clk_gate2(name, parent, reg, shift) \
2860 +- imx_clk_hw_gate2(name, parent, reg, shift)->clk
2861 ++ to_clk(imx_clk_hw_gate2(name, parent, reg, shift))
2862 +
2863 + #define imx_clk_gate2_flags(name, parent, reg, shift, flags) \
2864 +- imx_clk_hw_gate2_flags(name, parent, reg, shift, flags)->clk
2865 ++ to_clk(imx_clk_hw_gate2_flags(name, parent, reg, shift, flags))
2866 +
2867 + #define imx_clk_gate2_shared2(name, parent, reg, shift, share_count) \
2868 +- imx_clk_hw_gate2_shared2(name, parent, reg, shift, share_count)->clk
2869 ++ to_clk(imx_clk_hw_gate2_shared2(name, parent, reg, shift, share_count))
2870 +
2871 + #define imx_clk_gate3(name, parent, reg, shift) \
2872 +- imx_clk_hw_gate3(name, parent, reg, shift)->clk
2873 ++ to_clk(imx_clk_hw_gate3(name, parent, reg, shift))
2874 +
2875 + #define imx_clk_gate4(name, parent, reg, shift) \
2876 +- imx_clk_hw_gate4(name, parent, reg, shift)->clk
2877 ++ to_clk(imx_clk_hw_gate4(name, parent, reg, shift))
2878 +
2879 + #define imx_clk_mux(name, reg, shift, width, parents, num_parents) \
2880 +- imx_clk_hw_mux(name, reg, shift, width, parents, num_parents)->clk
2881 ++ to_clk(imx_clk_hw_mux(name, reg, shift, width, parents, num_parents))
2882 +
2883 + struct clk *imx_clk_pll14xx(const char *name, const char *parent_name,
2884 + void __iomem *base, const struct imx_pll14xx_clk *pll_clk);
2885 +@@ -198,6 +198,13 @@ struct clk_hw *imx_clk_hw_fixup_mux(const char *name, void __iomem *reg,
2886 + u8 shift, u8 width, const char * const *parents,
2887 + int num_parents, void (*fixup)(u32 *val));
2888 +
2889 ++static inline struct clk *to_clk(struct clk_hw *hw)
2890 ++{
2891 ++ if (IS_ERR_OR_NULL(hw))
2892 ++ return ERR_CAST(hw);
2893 ++ return hw->clk;
2894 ++}
2895 ++
2896 + static inline struct clk *imx_clk_fixed(const char *name, int rate)
2897 + {
2898 + return clk_register_fixed_rate(NULL, name, NULL, 0, rate);
2899 +diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
2900 +index ddb1e5634739..3a5853ca98c6 100644
2901 +--- a/drivers/clk/meson/clk-pll.c
2902 ++++ b/drivers/clk/meson/clk-pll.c
2903 +@@ -77,6 +77,15 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw,
2904 + unsigned int m, n, frac;
2905 +
2906 + n = meson_parm_read(clk->map, &pll->n);
2907 ++
2908 ++ /*
2909 ++ * On some HW, N is set to zero on init. This value is invalid as
2910 ++ * it would result in a division by zero. The rate can't be
2911 ++ * calculated in this case
2912 ++ */
2913 ++ if (n == 0)
2914 ++ return 0;
2915 ++
2916 + m = meson_parm_read(clk->map, &pll->m);
2917 +
2918 + frac = MESON_PARM_APPLICABLE(&pll->frac) ?
2919 +diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c
2920 +index 67e6691e080c..8856ce476ccf 100644
2921 +--- a/drivers/clk/meson/meson8b.c
2922 ++++ b/drivers/clk/meson/meson8b.c
2923 +@@ -1764,8 +1764,11 @@ static struct clk_regmap meson8b_hdmi_sys = {
2924 +
2925 + /*
2926 + * The MALI IP is clocked by two identical clocks (mali_0 and mali_1)
2927 +- * muxed by a glitch-free switch on Meson8b and Meson8m2. Meson8 only
2928 +- * has mali_0 and no glitch-free mux.
2929 ++ * muxed by a glitch-free switch on Meson8b and Meson8m2. The CCF can
2930 ++ * actually manage this glitch-free mux because it does top-to-bottom
2931 ++ * updates the each clock tree and switches to the "inactive" one when
2932 ++ * CLK_SET_RATE_GATE is set.
2933 ++ * Meson8 only has mali_0 and no glitch-free mux.
2934 + */
2935 + static const struct clk_hw *meson8b_mali_0_1_parent_hws[] = {
2936 + &meson8b_xtal.hw,
2937 +@@ -1830,7 +1833,7 @@ static struct clk_regmap meson8b_mali_0 = {
2938 + &meson8b_mali_0_div.hw
2939 + },
2940 + .num_parents = 1,
2941 +- .flags = CLK_SET_RATE_PARENT,
2942 ++ .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
2943 + },
2944 + };
2945 +
2946 +@@ -1885,7 +1888,7 @@ static struct clk_regmap meson8b_mali_1 = {
2947 + &meson8b_mali_1_div.hw
2948 + },
2949 + .num_parents = 1,
2950 +- .flags = CLK_SET_RATE_PARENT,
2951 ++ .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
2952 + },
2953 + };
2954 +
2955 +diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
2956 +index 8f4b9bec2956..cecdb07ce13b 100644
2957 +--- a/drivers/clk/qcom/clk-rcg2.c
2958 ++++ b/drivers/clk/qcom/clk-rcg2.c
2959 +@@ -217,6 +217,9 @@ static int _freq_tbl_determine_rate(struct clk_hw *hw, const struct freq_tbl *f,
2960 +
2961 + clk_flags = clk_hw_get_flags(hw);
2962 + p = clk_hw_get_parent_by_index(hw, index);
2963 ++ if (!p)
2964 ++ return -EINVAL;
2965 ++
2966 + if (clk_flags & CLK_SET_RATE_PARENT) {
2967 + rate = f->freq;
2968 + if (f->pre_div) {
2969 +@@ -952,7 +955,7 @@ static void clk_rcg2_dfs_populate_freq(struct clk_hw *hw, unsigned int l,
2970 + struct clk_rcg2 *rcg = to_clk_rcg2(hw);
2971 + struct clk_hw *p;
2972 + unsigned long prate = 0;
2973 +- u32 val, mask, cfg, mode;
2974 ++ u32 val, mask, cfg, mode, src;
2975 + int i, num_parents;
2976 +
2977 + regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + SE_PERF_DFSR(l), &cfg);
2978 +@@ -962,12 +965,12 @@ static void clk_rcg2_dfs_populate_freq(struct clk_hw *hw, unsigned int l,
2979 + if (cfg & mask)
2980 + f->pre_div = cfg & mask;
2981 +
2982 +- cfg &= CFG_SRC_SEL_MASK;
2983 +- cfg >>= CFG_SRC_SEL_SHIFT;
2984 ++ src = cfg & CFG_SRC_SEL_MASK;
2985 ++ src >>= CFG_SRC_SEL_SHIFT;
2986 +
2987 + num_parents = clk_hw_get_num_parents(hw);
2988 + for (i = 0; i < num_parents; i++) {
2989 +- if (cfg == rcg->parent_map[i].cfg) {
2990 ++ if (src == rcg->parent_map[i].cfg) {
2991 + f->src = rcg->parent_map[i].src;
2992 + p = clk_hw_get_parent_by_index(&rcg->clkr.hw, i);
2993 + prate = clk_hw_get_rate(p);
2994 +diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c
2995 +index 930fa4a4c52a..e5c3db11bf26 100644
2996 +--- a/drivers/clk/qcom/clk-smd-rpm.c
2997 ++++ b/drivers/clk/qcom/clk-smd-rpm.c
2998 +@@ -648,6 +648,7 @@ static const struct rpm_smd_clk_desc rpm_clk_qcs404 = {
2999 + };
3000 +
3001 + /* msm8998 */
3002 ++DEFINE_CLK_SMD_RPM(msm8998, bimc_clk, bimc_a_clk, QCOM_SMD_RPM_MEM_CLK, 0);
3003 + DEFINE_CLK_SMD_RPM(msm8998, pcnoc_clk, pcnoc_a_clk, QCOM_SMD_RPM_BUS_CLK, 0);
3004 + DEFINE_CLK_SMD_RPM(msm8998, snoc_clk, snoc_a_clk, QCOM_SMD_RPM_BUS_CLK, 1);
3005 + DEFINE_CLK_SMD_RPM(msm8998, cnoc_clk, cnoc_a_clk, QCOM_SMD_RPM_BUS_CLK, 2);
3006 +@@ -671,6 +672,8 @@ DEFINE_CLK_SMD_RPM_XO_BUFFER_PINCTRL(msm8998, rf_clk2_pin, rf_clk2_a_pin, 5);
3007 + DEFINE_CLK_SMD_RPM_XO_BUFFER(msm8998, rf_clk3, rf_clk3_a, 6);
3008 + DEFINE_CLK_SMD_RPM_XO_BUFFER_PINCTRL(msm8998, rf_clk3_pin, rf_clk3_a_pin, 6);
3009 + static struct clk_smd_rpm *msm8998_clks[] = {
3010 ++ [RPM_SMD_BIMC_CLK] = &msm8998_bimc_clk,
3011 ++ [RPM_SMD_BIMC_A_CLK] = &msm8998_bimc_a_clk,
3012 + [RPM_SMD_PCNOC_CLK] = &msm8998_pcnoc_clk,
3013 + [RPM_SMD_PCNOC_A_CLK] = &msm8998_pcnoc_a_clk,
3014 + [RPM_SMD_SNOC_CLK] = &msm8998_snoc_clk,
3015 +diff --git a/drivers/clk/qcom/gcc-msm8998.c b/drivers/clk/qcom/gcc-msm8998.c
3016 +index cf31b5d03270..df1d7056436c 100644
3017 +--- a/drivers/clk/qcom/gcc-msm8998.c
3018 ++++ b/drivers/clk/qcom/gcc-msm8998.c
3019 +@@ -1996,6 +1996,19 @@ static struct clk_branch gcc_gp3_clk = {
3020 + },
3021 + };
3022 +
3023 ++static struct clk_branch gcc_bimc_gfx_clk = {
3024 ++ .halt_reg = 0x46040,
3025 ++ .halt_check = BRANCH_HALT,
3026 ++ .clkr = {
3027 ++ .enable_reg = 0x46040,
3028 ++ .enable_mask = BIT(0),
3029 ++ .hw.init = &(struct clk_init_data){
3030 ++ .name = "gcc_bimc_gfx_clk",
3031 ++ .ops = &clk_branch2_ops,
3032 ++ },
3033 ++ },
3034 ++};
3035 ++
3036 + static struct clk_branch gcc_gpu_bimc_gfx_clk = {
3037 + .halt_reg = 0x71010,
3038 + .halt_check = BRANCH_HALT,
3039 +@@ -2810,6 +2823,7 @@ static struct clk_regmap *gcc_msm8998_clocks[] = {
3040 + [GCC_GP1_CLK] = &gcc_gp1_clk.clkr,
3041 + [GCC_GP2_CLK] = &gcc_gp2_clk.clkr,
3042 + [GCC_GP3_CLK] = &gcc_gp3_clk.clkr,
3043 ++ [GCC_BIMC_GFX_CLK] = &gcc_bimc_gfx_clk.clkr,
3044 + [GCC_GPU_BIMC_GFX_CLK] = &gcc_gpu_bimc_gfx_clk.clkr,
3045 + [GCC_GPU_BIMC_GFX_SRC_CLK] = &gcc_gpu_bimc_gfx_src_clk.clkr,
3046 + [GCC_GPU_CFG_AHB_CLK] = &gcc_gpu_cfg_ahb_clk.clkr,
3047 +diff --git a/drivers/clk/renesas/rcar-gen3-cpg.c b/drivers/clk/renesas/rcar-gen3-cpg.c
3048 +index c97b647db9b6..488f8b3980c5 100644
3049 +--- a/drivers/clk/renesas/rcar-gen3-cpg.c
3050 ++++ b/drivers/clk/renesas/rcar-gen3-cpg.c
3051 +@@ -470,7 +470,8 @@ static struct clk * __init cpg_rpc_clk_register(const char *name,
3052 +
3053 + clk = clk_register_composite(NULL, name, &parent_name, 1, NULL, NULL,
3054 + &rpc->div.hw, &clk_divider_ops,
3055 +- &rpc->gate.hw, &clk_gate_ops, 0);
3056 ++ &rpc->gate.hw, &clk_gate_ops,
3057 ++ CLK_SET_RATE_PARENT);
3058 + if (IS_ERR(clk)) {
3059 + kfree(rpc);
3060 + return clk;
3061 +@@ -506,7 +507,8 @@ static struct clk * __init cpg_rpcd2_clk_register(const char *name,
3062 +
3063 + clk = clk_register_composite(NULL, name, &parent_name, 1, NULL, NULL,
3064 + &rpcd2->fixed.hw, &clk_fixed_factor_ops,
3065 +- &rpcd2->gate.hw, &clk_gate_ops, 0);
3066 ++ &rpcd2->gate.hw, &clk_gate_ops,
3067 ++ CLK_SET_RATE_PARENT);
3068 + if (IS_ERR(clk))
3069 + kfree(rpcd2);
3070 +
3071 +diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c b/drivers/clk/sunxi-ng/ccu-sun50i-a64.c
3072 +index 49bd7a4c015c..5f66bf879772 100644
3073 +--- a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c
3074 ++++ b/drivers/clk/sunxi-ng/ccu-sun50i-a64.c
3075 +@@ -921,11 +921,26 @@ static const struct sunxi_ccu_desc sun50i_a64_ccu_desc = {
3076 + .num_resets = ARRAY_SIZE(sun50i_a64_ccu_resets),
3077 + };
3078 +
3079 ++static struct ccu_pll_nb sun50i_a64_pll_cpu_nb = {
3080 ++ .common = &pll_cpux_clk.common,
3081 ++ /* copy from pll_cpux_clk */
3082 ++ .enable = BIT(31),
3083 ++ .lock = BIT(28),
3084 ++};
3085 ++
3086 ++static struct ccu_mux_nb sun50i_a64_cpu_nb = {
3087 ++ .common = &cpux_clk.common,
3088 ++ .cm = &cpux_clk.mux,
3089 ++ .delay_us = 1, /* > 8 clock cycles at 24 MHz */
3090 ++ .bypass_index = 1, /* index of 24 MHz oscillator */
3091 ++};
3092 ++
3093 + static int sun50i_a64_ccu_probe(struct platform_device *pdev)
3094 + {
3095 + struct resource *res;
3096 + void __iomem *reg;
3097 + u32 val;
3098 ++ int ret;
3099 +
3100 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
3101 + reg = devm_ioremap_resource(&pdev->dev, res);
3102 +@@ -939,7 +954,18 @@ static int sun50i_a64_ccu_probe(struct platform_device *pdev)
3103 +
3104 + writel(0x515, reg + SUN50I_A64_PLL_MIPI_REG);
3105 +
3106 +- return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a64_ccu_desc);
3107 ++ ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a64_ccu_desc);
3108 ++ if (ret)
3109 ++ return ret;
3110 ++
3111 ++ /* Gate then ungate PLL CPU after any rate changes */
3112 ++ ccu_pll_notifier_register(&sun50i_a64_pll_cpu_nb);
3113 ++
3114 ++ /* Reparent CPU during PLL CPU rate changes */
3115 ++ ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk,
3116 ++ &sun50i_a64_cpu_nb);
3117 ++
3118 ++ return 0;
3119 + }
3120 +
3121 + static const struct of_device_id sun50i_a64_ccu_ids[] = {
3122 +diff --git a/drivers/clk/ti/clk-7xx.c b/drivers/clk/ti/clk-7xx.c
3123 +index 5f46782cebeb..b656ba2abcf7 100644
3124 +--- a/drivers/clk/ti/clk-7xx.c
3125 ++++ b/drivers/clk/ti/clk-7xx.c
3126 +@@ -405,7 +405,7 @@ static const struct omap_clkctrl_bit_data dra7_gmac_bit_data[] __initconst = {
3127 + };
3128 +
3129 + static const struct omap_clkctrl_reg_data dra7_gmac_clkctrl_regs[] __initconst = {
3130 +- { DRA7_GMAC_GMAC_CLKCTRL, dra7_gmac_bit_data, CLKF_SW_SUP, "dpll_gmac_ck" },
3131 ++ { DRA7_GMAC_GMAC_CLKCTRL, dra7_gmac_bit_data, CLKF_SW_SUP, "gmac_main_clk" },
3132 + { 0 },
3133 + };
3134 +
3135 +diff --git a/drivers/clk/uniphier/clk-uniphier-peri.c b/drivers/clk/uniphier/clk-uniphier-peri.c
3136 +index 9caa52944b1c..3e32db9dad81 100644
3137 +--- a/drivers/clk/uniphier/clk-uniphier-peri.c
3138 ++++ b/drivers/clk/uniphier/clk-uniphier-peri.c
3139 +@@ -18,8 +18,8 @@
3140 + #define UNIPHIER_PERI_CLK_FI2C(idx, ch) \
3141 + UNIPHIER_CLK_GATE("i2c" #ch, (idx), "i2c", 0x24, 24 + (ch))
3142 +
3143 +-#define UNIPHIER_PERI_CLK_SCSSI(idx) \
3144 +- UNIPHIER_CLK_GATE("scssi", (idx), "spi", 0x20, 17)
3145 ++#define UNIPHIER_PERI_CLK_SCSSI(idx, ch) \
3146 ++ UNIPHIER_CLK_GATE("scssi" #ch, (idx), "spi", 0x20, 17 + (ch))
3147 +
3148 + #define UNIPHIER_PERI_CLK_MCSSI(idx) \
3149 + UNIPHIER_CLK_GATE("mcssi", (idx), "spi", 0x24, 14)
3150 +@@ -35,7 +35,7 @@ const struct uniphier_clk_data uniphier_ld4_peri_clk_data[] = {
3151 + UNIPHIER_PERI_CLK_I2C(6, 2),
3152 + UNIPHIER_PERI_CLK_I2C(7, 3),
3153 + UNIPHIER_PERI_CLK_I2C(8, 4),
3154 +- UNIPHIER_PERI_CLK_SCSSI(11),
3155 ++ UNIPHIER_PERI_CLK_SCSSI(11, 0),
3156 + { /* sentinel */ }
3157 + };
3158 +
3159 +@@ -51,7 +51,10 @@ const struct uniphier_clk_data uniphier_pro4_peri_clk_data[] = {
3160 + UNIPHIER_PERI_CLK_FI2C(8, 4),
3161 + UNIPHIER_PERI_CLK_FI2C(9, 5),
3162 + UNIPHIER_PERI_CLK_FI2C(10, 6),
3163 +- UNIPHIER_PERI_CLK_SCSSI(11),
3164 +- UNIPHIER_PERI_CLK_MCSSI(12),
3165 ++ UNIPHIER_PERI_CLK_SCSSI(11, 0),
3166 ++ UNIPHIER_PERI_CLK_SCSSI(12, 1),
3167 ++ UNIPHIER_PERI_CLK_SCSSI(13, 2),
3168 ++ UNIPHIER_PERI_CLK_SCSSI(14, 3),
3169 ++ UNIPHIER_PERI_CLK_MCSSI(15),
3170 + { /* sentinel */ }
3171 + };
3172 +diff --git a/drivers/clocksource/bcm2835_timer.c b/drivers/clocksource/bcm2835_timer.c
3173 +index 2b196cbfadb6..b235f446ee50 100644
3174 +--- a/drivers/clocksource/bcm2835_timer.c
3175 ++++ b/drivers/clocksource/bcm2835_timer.c
3176 +@@ -121,7 +121,7 @@ static int __init bcm2835_timer_init(struct device_node *node)
3177 + ret = setup_irq(irq, &timer->act);
3178 + if (ret) {
3179 + pr_err("Can't set up timer IRQ\n");
3180 +- goto err_iounmap;
3181 ++ goto err_timer_free;
3182 + }
3183 +
3184 + clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff);
3185 +@@ -130,6 +130,9 @@ static int __init bcm2835_timer_init(struct device_node *node)
3186 +
3187 + return 0;
3188 +
3189 ++err_timer_free:
3190 ++ kfree(timer);
3191 ++
3192 + err_iounmap:
3193 + iounmap(base);
3194 + return ret;
3195 +diff --git a/drivers/clocksource/timer-davinci.c b/drivers/clocksource/timer-davinci.c
3196 +index 62745c962049..e421946a91c5 100644
3197 +--- a/drivers/clocksource/timer-davinci.c
3198 ++++ b/drivers/clocksource/timer-davinci.c
3199 +@@ -302,10 +302,6 @@ int __init davinci_timer_register(struct clk *clk,
3200 + return rv;
3201 + }
3202 +
3203 +- clockevents_config_and_register(&clockevent->dev, tick_rate,
3204 +- DAVINCI_TIMER_MIN_DELTA,
3205 +- DAVINCI_TIMER_MAX_DELTA);
3206 +-
3207 + davinci_clocksource.dev.rating = 300;
3208 + davinci_clocksource.dev.read = davinci_clocksource_read;
3209 + davinci_clocksource.dev.mask =
3210 +@@ -323,6 +319,10 @@ int __init davinci_timer_register(struct clk *clk,
3211 + davinci_clocksource_init_tim34(base);
3212 + }
3213 +
3214 ++ clockevents_config_and_register(&clockevent->dev, tick_rate,
3215 ++ DAVINCI_TIMER_MIN_DELTA,
3216 ++ DAVINCI_TIMER_MAX_DELTA);
3217 ++
3218 + rv = clocksource_register_hz(&davinci_clocksource.dev, tick_rate);
3219 + if (rv) {
3220 + pr_err("Unable to register clocksource");
3221 +diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
3222 +index 91eb768d4221..0a73bebd04e5 100644
3223 +--- a/drivers/crypto/Kconfig
3224 ++++ b/drivers/crypto/Kconfig
3225 +@@ -716,7 +716,7 @@ source "drivers/crypto/stm32/Kconfig"
3226 +
3227 + config CRYPTO_DEV_SAFEXCEL
3228 + tristate "Inside Secure's SafeXcel cryptographic engine driver"
3229 +- depends on OF || PCI || COMPILE_TEST
3230 ++ depends on (OF || PCI || COMPILE_TEST) && HAS_IOMEM
3231 + select CRYPTO_LIB_AES
3232 + select CRYPTO_AUTHENC
3233 + select CRYPTO_SKCIPHER
3234 +diff --git a/drivers/crypto/amlogic/Kconfig b/drivers/crypto/amlogic/Kconfig
3235 +index b90850d18965..cf9547602670 100644
3236 +--- a/drivers/crypto/amlogic/Kconfig
3237 ++++ b/drivers/crypto/amlogic/Kconfig
3238 +@@ -1,5 +1,6 @@
3239 + config CRYPTO_DEV_AMLOGIC_GXL
3240 + tristate "Support for amlogic cryptographic offloader"
3241 ++ depends on HAS_IOMEM
3242 + default y if ARCH_MESON
3243 + select CRYPTO_SKCIPHER
3244 + select CRYPTO_ENGINE
3245 +diff --git a/drivers/crypto/chelsio/chtls/chtls_cm.c b/drivers/crypto/chelsio/chtls/chtls_cm.c
3246 +index aca75237bbcf..dffa2aa855fd 100644
3247 +--- a/drivers/crypto/chelsio/chtls/chtls_cm.c
3248 ++++ b/drivers/crypto/chelsio/chtls/chtls_cm.c
3249 +@@ -727,6 +727,14 @@ static int chtls_close_listsrv_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
3250 + return 0;
3251 + }
3252 +
3253 ++static void chtls_purge_wr_queue(struct sock *sk)
3254 ++{
3255 ++ struct sk_buff *skb;
3256 ++
3257 ++ while ((skb = dequeue_wr(sk)) != NULL)
3258 ++ kfree_skb(skb);
3259 ++}
3260 ++
3261 + static void chtls_release_resources(struct sock *sk)
3262 + {
3263 + struct chtls_sock *csk = rcu_dereference_sk_user_data(sk);
3264 +@@ -741,6 +749,11 @@ static void chtls_release_resources(struct sock *sk)
3265 + kfree_skb(csk->txdata_skb_cache);
3266 + csk->txdata_skb_cache = NULL;
3267 +
3268 ++ if (csk->wr_credits != csk->wr_max_credits) {
3269 ++ chtls_purge_wr_queue(sk);
3270 ++ chtls_reset_wr_list(csk);
3271 ++ }
3272 ++
3273 + if (csk->l2t_entry) {
3274 + cxgb4_l2t_release(csk->l2t_entry);
3275 + csk->l2t_entry = NULL;
3276 +@@ -1735,6 +1748,7 @@ static void chtls_peer_close(struct sock *sk, struct sk_buff *skb)
3277 + else
3278 + sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
3279 + }
3280 ++ kfree_skb(skb);
3281 + }
3282 +
3283 + static void chtls_close_con_rpl(struct sock *sk, struct sk_buff *skb)
3284 +@@ -2062,19 +2076,6 @@ rel_skb:
3285 + return 0;
3286 + }
3287 +
3288 +-static struct sk_buff *dequeue_wr(struct sock *sk)
3289 +-{
3290 +- struct chtls_sock *csk = rcu_dereference_sk_user_data(sk);
3291 +- struct sk_buff *skb = csk->wr_skb_head;
3292 +-
3293 +- if (likely(skb)) {
3294 +- /* Don't bother clearing the tail */
3295 +- csk->wr_skb_head = WR_SKB_CB(skb)->next_wr;
3296 +- WR_SKB_CB(skb)->next_wr = NULL;
3297 +- }
3298 +- return skb;
3299 +-}
3300 +-
3301 + static void chtls_rx_ack(struct sock *sk, struct sk_buff *skb)
3302 + {
3303 + struct cpl_fw4_ack *hdr = cplhdr(skb) + RSS_HDR;
3304 +diff --git a/drivers/crypto/chelsio/chtls/chtls_cm.h b/drivers/crypto/chelsio/chtls/chtls_cm.h
3305 +index 129d7ac649a9..3fac0c74a41f 100644
3306 +--- a/drivers/crypto/chelsio/chtls/chtls_cm.h
3307 ++++ b/drivers/crypto/chelsio/chtls/chtls_cm.h
3308 +@@ -185,6 +185,12 @@ static inline void chtls_kfree_skb(struct sock *sk, struct sk_buff *skb)
3309 + kfree_skb(skb);
3310 + }
3311 +
3312 ++static inline void chtls_reset_wr_list(struct chtls_sock *csk)
3313 ++{
3314 ++ csk->wr_skb_head = NULL;
3315 ++ csk->wr_skb_tail = NULL;
3316 ++}
3317 ++
3318 + static inline void enqueue_wr(struct chtls_sock *csk, struct sk_buff *skb)
3319 + {
3320 + WR_SKB_CB(skb)->next_wr = NULL;
3321 +@@ -197,4 +203,19 @@ static inline void enqueue_wr(struct chtls_sock *csk, struct sk_buff *skb)
3322 + WR_SKB_CB(csk->wr_skb_tail)->next_wr = skb;
3323 + csk->wr_skb_tail = skb;
3324 + }
3325 ++
3326 ++static inline struct sk_buff *dequeue_wr(struct sock *sk)
3327 ++{
3328 ++ struct chtls_sock *csk = rcu_dereference_sk_user_data(sk);
3329 ++ struct sk_buff *skb = NULL;
3330 ++
3331 ++ skb = csk->wr_skb_head;
3332 ++
3333 ++ if (likely(skb)) {
3334 ++ /* Don't bother clearing the tail */
3335 ++ csk->wr_skb_head = WR_SKB_CB(skb)->next_wr;
3336 ++ WR_SKB_CB(skb)->next_wr = NULL;
3337 ++ }
3338 ++ return skb;
3339 ++}
3340 + #endif
3341 +diff --git a/drivers/crypto/chelsio/chtls/chtls_hw.c b/drivers/crypto/chelsio/chtls/chtls_hw.c
3342 +index 2a34035d3cfb..a217fe72602d 100644
3343 +--- a/drivers/crypto/chelsio/chtls/chtls_hw.c
3344 ++++ b/drivers/crypto/chelsio/chtls/chtls_hw.c
3345 +@@ -350,6 +350,7 @@ int chtls_setkey(struct chtls_sock *csk, u32 keylen, u32 optname)
3346 + kwr->sc_imm.cmd_more = cpu_to_be32(ULPTX_CMD_V(ULP_TX_SC_IMM));
3347 + kwr->sc_imm.len = cpu_to_be32(klen);
3348 +
3349 ++ lock_sock(sk);
3350 + /* key info */
3351 + kctx = (struct _key_ctx *)(kwr + 1);
3352 + ret = chtls_key_info(csk, kctx, keylen, optname);
3353 +@@ -388,8 +389,10 @@ int chtls_setkey(struct chtls_sock *csk, u32 keylen, u32 optname)
3354 + csk->tlshws.txkey = keyid;
3355 + }
3356 +
3357 ++ release_sock(sk);
3358 + return ret;
3359 + out_notcb:
3360 ++ release_sock(sk);
3361 + free_tls_keyid(sk);
3362 + out_nokey:
3363 + kfree_skb(skb);
3364 +diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
3365 +index 98f037e6ea3e..d8b015266ee4 100644
3366 +--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
3367 ++++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
3368 +@@ -1043,6 +1043,7 @@ static unsigned int hpre_rsa_max_size(struct crypto_akcipher *tfm)
3369 + static int hpre_rsa_init_tfm(struct crypto_akcipher *tfm)
3370 + {
3371 + struct hpre_ctx *ctx = akcipher_tfm_ctx(tfm);
3372 ++ int ret;
3373 +
3374 + ctx->rsa.soft_tfm = crypto_alloc_akcipher("rsa-generic", 0, 0);
3375 + if (IS_ERR(ctx->rsa.soft_tfm)) {
3376 +@@ -1050,7 +1051,11 @@ static int hpre_rsa_init_tfm(struct crypto_akcipher *tfm)
3377 + return PTR_ERR(ctx->rsa.soft_tfm);
3378 + }
3379 +
3380 +- return hpre_ctx_init(ctx);
3381 ++ ret = hpre_ctx_init(ctx);
3382 ++ if (ret)
3383 ++ crypto_free_akcipher(ctx->rsa.soft_tfm);
3384 ++
3385 ++ return ret;
3386 + }
3387 +
3388 + static void hpre_rsa_exit_tfm(struct crypto_akcipher *tfm)
3389 +diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c
3390 +index 34e0424410bf..0c98c37e39f4 100644
3391 +--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
3392 ++++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
3393 +@@ -106,18 +106,18 @@ static const char * const hpre_debug_file_name[] = {
3394 + };
3395 +
3396 + static const struct hpre_hw_error hpre_hw_errors[] = {
3397 +- { .int_msk = BIT(0), .msg = "hpre_ecc_1bitt_err" },
3398 +- { .int_msk = BIT(1), .msg = "hpre_ecc_2bit_err" },
3399 +- { .int_msk = BIT(2), .msg = "hpre_data_wr_err" },
3400 +- { .int_msk = BIT(3), .msg = "hpre_data_rd_err" },
3401 +- { .int_msk = BIT(4), .msg = "hpre_bd_rd_err" },
3402 +- { .int_msk = BIT(5), .msg = "hpre_ooo_2bit_ecc_err" },
3403 +- { .int_msk = BIT(6), .msg = "hpre_cltr1_htbt_tm_out_err" },
3404 +- { .int_msk = BIT(7), .msg = "hpre_cltr2_htbt_tm_out_err" },
3405 +- { .int_msk = BIT(8), .msg = "hpre_cltr3_htbt_tm_out_err" },
3406 +- { .int_msk = BIT(9), .msg = "hpre_cltr4_htbt_tm_out_err" },
3407 +- { .int_msk = GENMASK(15, 10), .msg = "hpre_ooo_rdrsp_err" },
3408 +- { .int_msk = GENMASK(21, 16), .msg = "hpre_ooo_wrrsp_err" },
3409 ++ { .int_msk = BIT(0), .msg = "core_ecc_1bit_err_int_set" },
3410 ++ { .int_msk = BIT(1), .msg = "core_ecc_2bit_err_int_set" },
3411 ++ { .int_msk = BIT(2), .msg = "dat_wb_poison_int_set" },
3412 ++ { .int_msk = BIT(3), .msg = "dat_rd_poison_int_set" },
3413 ++ { .int_msk = BIT(4), .msg = "bd_rd_poison_int_set" },
3414 ++ { .int_msk = BIT(5), .msg = "ooo_ecc_2bit_err_int_set" },
3415 ++ { .int_msk = BIT(6), .msg = "cluster1_shb_timeout_int_set" },
3416 ++ { .int_msk = BIT(7), .msg = "cluster2_shb_timeout_int_set" },
3417 ++ { .int_msk = BIT(8), .msg = "cluster3_shb_timeout_int_set" },
3418 ++ { .int_msk = BIT(9), .msg = "cluster4_shb_timeout_int_set" },
3419 ++ { .int_msk = GENMASK(15, 10), .msg = "ooo_rdrsp_err_int_set" },
3420 ++ { .int_msk = GENMASK(21, 16), .msg = "ooo_wrrsp_err_int_set" },
3421 + { /* sentinel */ }
3422 + };
3423 +
3424 +diff --git a/drivers/crypto/hisilicon/sec2/sec.h b/drivers/crypto/hisilicon/sec2/sec.h
3425 +index b846d73d9a85..841f4c56ca73 100644
3426 +--- a/drivers/crypto/hisilicon/sec2/sec.h
3427 ++++ b/drivers/crypto/hisilicon/sec2/sec.h
3428 +@@ -40,7 +40,7 @@ struct sec_req {
3429 + int req_id;
3430 +
3431 + /* Status of the SEC request */
3432 +- atomic_t fake_busy;
3433 ++ bool fake_busy;
3434 + };
3435 +
3436 + /**
3437 +diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c
3438 +index 0a5391fff485..2475aaf0d59b 100644
3439 +--- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
3440 ++++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
3441 +@@ -141,7 +141,7 @@ static int sec_bd_send(struct sec_ctx *ctx, struct sec_req *req)
3442 + return -ENOBUFS;
3443 +
3444 + if (!ret) {
3445 +- if (atomic_read(&req->fake_busy))
3446 ++ if (req->fake_busy)
3447 + ret = -EBUSY;
3448 + else
3449 + ret = -EINPROGRESS;
3450 +@@ -641,7 +641,7 @@ static void sec_skcipher_callback(struct sec_ctx *ctx, struct sec_req *req)
3451 + if (ctx->c_ctx.c_mode == SEC_CMODE_CBC && req->c_req.encrypt)
3452 + sec_update_iv(req);
3453 +
3454 +- if (atomic_cmpxchg(&req->fake_busy, 1, 0) != 1)
3455 ++ if (req->fake_busy)
3456 + sk_req->base.complete(&sk_req->base, -EINPROGRESS);
3457 +
3458 + sk_req->base.complete(&sk_req->base, req->err_type);
3459 +@@ -672,9 +672,9 @@ static int sec_request_init(struct sec_ctx *ctx, struct sec_req *req)
3460 + }
3461 +
3462 + if (ctx->fake_req_limit <= atomic_inc_return(&qp_ctx->pending_reqs))
3463 +- atomic_set(&req->fake_busy, 1);
3464 ++ req->fake_busy = true;
3465 + else
3466 +- atomic_set(&req->fake_busy, 0);
3467 ++ req->fake_busy = false;
3468 +
3469 + ret = ctx->req_op->get_res(ctx, req);
3470 + if (ret) {
3471 +diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c
3472 +index ab742dfbab99..d40e2da3b05d 100644
3473 +--- a/drivers/crypto/hisilicon/sec2/sec_main.c
3474 ++++ b/drivers/crypto/hisilicon/sec2/sec_main.c
3475 +@@ -608,13 +608,13 @@ static const struct file_operations sec_dbg_fops = {
3476 + .write = sec_debug_write,
3477 + };
3478 +
3479 +-static int debugfs_atomic64_t_get(void *data, u64 *val)
3480 ++static int sec_debugfs_atomic64_get(void *data, u64 *val)
3481 + {
3482 +- *val = atomic64_read((atomic64_t *)data);
3483 +- return 0;
3484 ++ *val = atomic64_read((atomic64_t *)data);
3485 ++ return 0;
3486 + }
3487 +-DEFINE_DEBUGFS_ATTRIBUTE(fops_atomic64_t_ro, debugfs_atomic64_t_get, NULL,
3488 +- "%lld\n");
3489 ++DEFINE_DEBUGFS_ATTRIBUTE(sec_atomic64_ops, sec_debugfs_atomic64_get,
3490 ++ NULL, "%lld\n");
3491 +
3492 + static int sec_core_debug_init(struct sec_dev *sec)
3493 + {
3494 +@@ -636,11 +636,11 @@ static int sec_core_debug_init(struct sec_dev *sec)
3495 +
3496 + debugfs_create_regset32("regs", 0444, tmp_d, regset);
3497 +
3498 +- debugfs_create_file("send_cnt", 0444, tmp_d, &dfx->send_cnt,
3499 +- &fops_atomic64_t_ro);
3500 ++ debugfs_create_file("send_cnt", 0444, tmp_d,
3501 ++ &dfx->send_cnt, &sec_atomic64_ops);
3502 +
3503 +- debugfs_create_file("recv_cnt", 0444, tmp_d, &dfx->recv_cnt,
3504 +- &fops_atomic64_t_ro);
3505 ++ debugfs_create_file("recv_cnt", 0444, tmp_d,
3506 ++ &dfx->recv_cnt, &sec_atomic64_ops);
3507 +
3508 + return 0;
3509 + }
3510 +diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
3511 +index 35535833b6f7..c7804635e89e 100644
3512 +--- a/drivers/devfreq/Kconfig
3513 ++++ b/drivers/devfreq/Kconfig
3514 +@@ -115,7 +115,8 @@ config ARM_TEGRA20_DEVFREQ
3515 +
3516 + config ARM_RK3399_DMC_DEVFREQ
3517 + tristate "ARM RK3399 DMC DEVFREQ Driver"
3518 +- depends on ARCH_ROCKCHIP
3519 ++ depends on (ARCH_ROCKCHIP && HAVE_ARM_SMCCC) || \
3520 ++ (COMPILE_TEST && HAVE_ARM_SMCCC)
3521 + select DEVFREQ_EVENT_ROCKCHIP_DFI
3522 + select DEVFREQ_GOV_SIMPLE_ONDEMAND
3523 + select PM_DEVFREQ_EVENT
3524 +diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
3525 +index 07602083c743..e99f082d15df 100644
3526 +--- a/drivers/devfreq/devfreq.c
3527 ++++ b/drivers/devfreq/devfreq.c
3528 +@@ -10,6 +10,7 @@
3529 + #include <linux/kernel.h>
3530 + #include <linux/kmod.h>
3531 + #include <linux/sched.h>
3532 ++#include <linux/debugfs.h>
3533 + #include <linux/errno.h>
3534 + #include <linux/err.h>
3535 + #include <linux/init.h>
3536 +@@ -33,6 +34,7 @@
3537 + #define HZ_PER_KHZ 1000
3538 +
3539 + static struct class *devfreq_class;
3540 ++static struct dentry *devfreq_debugfs;
3541 +
3542 + /*
3543 + * devfreq core provides delayed work based load monitoring helper
3544 +@@ -209,10 +211,10 @@ static int set_freq_table(struct devfreq *devfreq)
3545 + int devfreq_update_status(struct devfreq *devfreq, unsigned long freq)
3546 + {
3547 + int lev, prev_lev, ret = 0;
3548 +- unsigned long cur_time;
3549 ++ u64 cur_time;
3550 +
3551 + lockdep_assert_held(&devfreq->lock);
3552 +- cur_time = jiffies;
3553 ++ cur_time = get_jiffies_64();
3554 +
3555 + /* Immediately exit if previous_freq is not initialized yet. */
3556 + if (!devfreq->previous_freq)
3557 +@@ -535,7 +537,7 @@ void devfreq_monitor_resume(struct devfreq *devfreq)
3558 + msecs_to_jiffies(devfreq->profile->polling_ms));
3559 +
3560 + out_update:
3561 +- devfreq->last_stat_updated = jiffies;
3562 ++ devfreq->last_stat_updated = get_jiffies_64();
3563 + devfreq->stop_polling = false;
3564 +
3565 + if (devfreq->profile->get_cur_freq &&
3566 +@@ -820,7 +822,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
3567 +
3568 + devfreq->time_in_state = devm_kcalloc(&devfreq->dev,
3569 + devfreq->profile->max_state,
3570 +- sizeof(unsigned long),
3571 ++ sizeof(*devfreq->time_in_state),
3572 + GFP_KERNEL);
3573 + if (!devfreq->time_in_state) {
3574 + mutex_unlock(&devfreq->lock);
3575 +@@ -828,7 +830,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
3576 + goto err_devfreq;
3577 + }
3578 +
3579 +- devfreq->last_stat_updated = jiffies;
3580 ++ devfreq->last_stat_updated = get_jiffies_64();
3581 +
3582 + srcu_init_notifier_head(&devfreq->transition_notifier_list);
3583 +
3584 +@@ -1589,8 +1591,8 @@ static ssize_t trans_stat_show(struct device *dev,
3585 + for (j = 0; j < max_state; j++)
3586 + len += sprintf(buf + len, "%10u",
3587 + devfreq->trans_table[(i * max_state) + j]);
3588 +- len += sprintf(buf + len, "%10u\n",
3589 +- jiffies_to_msecs(devfreq->time_in_state[i]));
3590 ++ len += sprintf(buf + len, "%10llu\n", (u64)
3591 ++ jiffies64_to_msecs(devfreq->time_in_state[i]));
3592 + }
3593 +
3594 + len += sprintf(buf + len, "Total transition : %u\n",
3595 +@@ -1614,6 +1616,81 @@ static struct attribute *devfreq_attrs[] = {
3596 + };
3597 + ATTRIBUTE_GROUPS(devfreq);
3598 +
3599 ++/**
3600 ++ * devfreq_summary_show() - Show the summary of the devfreq devices
3601 ++ * @s: seq_file instance to show the summary of devfreq devices
3602 ++ * @data: not used
3603 ++ *
3604 ++ * Show the summary of the devfreq devices via 'devfreq_summary' debugfs file.
3605 ++ * It helps that user can know the detailed information of the devfreq devices.
3606 ++ *
3607 ++ * Return 0 always because it shows the information without any data change.
3608 ++ */
3609 ++static int devfreq_summary_show(struct seq_file *s, void *data)
3610 ++{
3611 ++ struct devfreq *devfreq;
3612 ++ struct devfreq *p_devfreq = NULL;
3613 ++ unsigned long cur_freq, min_freq, max_freq;
3614 ++ unsigned int polling_ms;
3615 ++
3616 ++ seq_printf(s, "%-30s %-10s %-10s %-15s %10s %12s %12s %12s\n",
3617 ++ "dev_name",
3618 ++ "dev",
3619 ++ "parent_dev",
3620 ++ "governor",
3621 ++ "polling_ms",
3622 ++ "cur_freq_Hz",
3623 ++ "min_freq_Hz",
3624 ++ "max_freq_Hz");
3625 ++ seq_printf(s, "%30s %10s %10s %15s %10s %12s %12s %12s\n",
3626 ++ "------------------------------",
3627 ++ "----------",
3628 ++ "----------",
3629 ++ "---------------",
3630 ++ "----------",
3631 ++ "------------",
3632 ++ "------------",
3633 ++ "------------");
3634 ++
3635 ++ mutex_lock(&devfreq_list_lock);
3636 ++
3637 ++ list_for_each_entry_reverse(devfreq, &devfreq_list, node) {
3638 ++#if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE)
3639 ++ if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
3640 ++ DEVFREQ_NAME_LEN)) {
3641 ++ struct devfreq_passive_data *data = devfreq->data;
3642 ++
3643 ++ if (data)
3644 ++ p_devfreq = data->parent;
3645 ++ } else {
3646 ++ p_devfreq = NULL;
3647 ++ }
3648 ++#endif
3649 ++
3650 ++ mutex_lock(&devfreq->lock);
3651 ++ cur_freq = devfreq->previous_freq,
3652 ++ get_freq_range(devfreq, &min_freq, &max_freq);
3653 ++ polling_ms = devfreq->profile->polling_ms,
3654 ++ mutex_unlock(&devfreq->lock);
3655 ++
3656 ++ seq_printf(s,
3657 ++ "%-30s %-10s %-10s %-15s %10d %12ld %12ld %12ld\n",
3658 ++ dev_name(devfreq->dev.parent),
3659 ++ dev_name(&devfreq->dev),
3660 ++ p_devfreq ? dev_name(&p_devfreq->dev) : "null",
3661 ++ devfreq->governor_name,
3662 ++ polling_ms,
3663 ++ cur_freq,
3664 ++ min_freq,
3665 ++ max_freq);
3666 ++ }
3667 ++
3668 ++ mutex_unlock(&devfreq_list_lock);
3669 ++
3670 ++ return 0;
3671 ++}
3672 ++DEFINE_SHOW_ATTRIBUTE(devfreq_summary);
3673 ++
3674 + static int __init devfreq_init(void)
3675 + {
3676 + devfreq_class = class_create(THIS_MODULE, "devfreq");
3677 +@@ -1630,6 +1707,11 @@ static int __init devfreq_init(void)
3678 + }
3679 + devfreq_class->dev_groups = devfreq_groups;
3680 +
3681 ++ devfreq_debugfs = debugfs_create_dir("devfreq", NULL);
3682 ++ debugfs_create_file("devfreq_summary", 0444,
3683 ++ devfreq_debugfs, NULL,
3684 ++ &devfreq_summary_fops);
3685 ++
3686 + return 0;
3687 + }
3688 + subsys_initcall(devfreq_init);
3689 +diff --git a/drivers/devfreq/event/Kconfig b/drivers/devfreq/event/Kconfig
3690 +index cef2cf5347ca..a53e0a6ffdfe 100644
3691 +--- a/drivers/devfreq/event/Kconfig
3692 ++++ b/drivers/devfreq/event/Kconfig
3693 +@@ -34,7 +34,7 @@ config DEVFREQ_EVENT_EXYNOS_PPMU
3694 +
3695 + config DEVFREQ_EVENT_ROCKCHIP_DFI
3696 + tristate "ROCKCHIP DFI DEVFREQ event Driver"
3697 +- depends on ARCH_ROCKCHIP
3698 ++ depends on ARCH_ROCKCHIP || COMPILE_TEST
3699 + help
3700 + This add the devfreq-event driver for Rockchip SoC. It provides DFI
3701 + (DDR Monitor Module) driver to count ddr load.
3702 +diff --git a/drivers/devfreq/event/exynos-ppmu.c b/drivers/devfreq/event/exynos-ppmu.c
3703 +index 85c7a77bf3f0..055deea42c37 100644
3704 +--- a/drivers/devfreq/event/exynos-ppmu.c
3705 ++++ b/drivers/devfreq/event/exynos-ppmu.c
3706 +@@ -101,17 +101,22 @@ static struct __exynos_ppmu_events {
3707 + PPMU_EVENT(dmc1_1),
3708 + };
3709 +
3710 +-static int exynos_ppmu_find_ppmu_id(struct devfreq_event_dev *edev)
3711 ++static int __exynos_ppmu_find_ppmu_id(const char *edev_name)
3712 + {
3713 + int i;
3714 +
3715 + for (i = 0; i < ARRAY_SIZE(ppmu_events); i++)
3716 +- if (!strcmp(edev->desc->name, ppmu_events[i].name))
3717 ++ if (!strcmp(edev_name, ppmu_events[i].name))
3718 + return ppmu_events[i].id;
3719 +
3720 + return -EINVAL;
3721 + }
3722 +
3723 ++static int exynos_ppmu_find_ppmu_id(struct devfreq_event_dev *edev)
3724 ++{
3725 ++ return __exynos_ppmu_find_ppmu_id(edev->desc->name);
3726 ++}
3727 ++
3728 + /*
3729 + * The devfreq-event ops structure for PPMU v1.1
3730 + */
3731 +@@ -556,13 +561,11 @@ static int of_get_devfreq_events(struct device_node *np,
3732 + * use default if not.
3733 + */
3734 + if (info->ppmu_type == EXYNOS_TYPE_PPMU_V2) {
3735 +- struct devfreq_event_dev edev;
3736 + int id;
3737 + /* Not all registers take the same value for
3738 + * read+write data count.
3739 + */
3740 +- edev.desc = &desc[j];
3741 +- id = exynos_ppmu_find_ppmu_id(&edev);
3742 ++ id = __exynos_ppmu_find_ppmu_id(desc[j].name);
3743 +
3744 + switch (id) {
3745 + case PPMU_PMNCNT0:
3746 +diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
3747 +index 03ac4b96117c..4b604086b1b3 100644
3748 +--- a/drivers/dma/dmaengine.c
3749 ++++ b/drivers/dma/dmaengine.c
3750 +@@ -179,7 +179,7 @@ __dma_device_satisfies_mask(struct dma_device *device,
3751 +
3752 + static struct module *dma_chan_to_owner(struct dma_chan *chan)
3753 + {
3754 +- return chan->device->dev->driver->owner;
3755 ++ return chan->device->owner;
3756 + }
3757 +
3758 + /**
3759 +@@ -919,6 +919,8 @@ int dma_async_device_register(struct dma_device *device)
3760 + return -EIO;
3761 + }
3762 +
3763 ++ device->owner = device->dev->driver->owner;
3764 ++
3765 + if (dma_has_cap(DMA_MEMCPY, device->cap_mask) && !device->device_prep_dma_memcpy) {
3766 + dev_err(device->dev,
3767 + "Device claims capability %s, but op is not defined\n",
3768 +diff --git a/drivers/dma/fsl-qdma.c b/drivers/dma/fsl-qdma.c
3769 +index 89792083d62c..95cc0256b387 100644
3770 +--- a/drivers/dma/fsl-qdma.c
3771 ++++ b/drivers/dma/fsl-qdma.c
3772 +@@ -304,7 +304,7 @@ static void fsl_qdma_free_chan_resources(struct dma_chan *chan)
3773 +
3774 + vchan_dma_desc_free_list(&fsl_chan->vchan, &head);
3775 +
3776 +- if (!fsl_queue->comp_pool && !fsl_queue->comp_pool)
3777 ++ if (!fsl_queue->comp_pool && !fsl_queue->desc_pool)
3778 + return;
3779 +
3780 + list_for_each_entry_safe(comp_temp, _comp_temp,
3781 +diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
3782 +index c27e206a764c..66f1b2ac5cde 100644
3783 +--- a/drivers/dma/imx-sdma.c
3784 ++++ b/drivers/dma/imx-sdma.c
3785 +@@ -760,12 +760,8 @@ static void sdma_start_desc(struct sdma_channel *sdmac)
3786 + return;
3787 + }
3788 + sdmac->desc = desc = to_sdma_desc(&vd->tx);
3789 +- /*
3790 +- * Do not delete the node in desc_issued list in cyclic mode, otherwise
3791 +- * the desc allocated will never be freed in vchan_dma_desc_free_list
3792 +- */
3793 +- if (!(sdmac->flags & IMX_DMA_SG_LOOP))
3794 +- list_del(&vd->node);
3795 ++
3796 ++ list_del(&vd->node);
3797 +
3798 + sdma->channel_control[channel].base_bd_ptr = desc->bd_phys;
3799 + sdma->channel_control[channel].current_bd_ptr = desc->bd_phys;
3800 +@@ -1071,7 +1067,6 @@ static void sdma_channel_terminate_work(struct work_struct *work)
3801 +
3802 + spin_lock_irqsave(&sdmac->vc.lock, flags);
3803 + vchan_get_all_descriptors(&sdmac->vc, &head);
3804 +- sdmac->desc = NULL;
3805 + spin_unlock_irqrestore(&sdmac->vc.lock, flags);
3806 + vchan_dma_desc_free_list(&sdmac->vc, &head);
3807 + sdmac->context_loaded = false;
3808 +@@ -1080,11 +1075,19 @@ static void sdma_channel_terminate_work(struct work_struct *work)
3809 + static int sdma_disable_channel_async(struct dma_chan *chan)
3810 + {
3811 + struct sdma_channel *sdmac = to_sdma_chan(chan);
3812 ++ unsigned long flags;
3813 ++
3814 ++ spin_lock_irqsave(&sdmac->vc.lock, flags);
3815 +
3816 + sdma_disable_channel(chan);
3817 +
3818 +- if (sdmac->desc)
3819 ++ if (sdmac->desc) {
3820 ++ vchan_terminate_vdesc(&sdmac->desc->vd);
3821 ++ sdmac->desc = NULL;
3822 + schedule_work(&sdmac->terminate_worker);
3823 ++ }
3824 ++
3825 ++ spin_unlock_irqrestore(&sdmac->vc.lock, flags);
3826 +
3827 + return 0;
3828 + }
3829 +diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c
3830 +index 756a3c951dc7..03a7f647f7b2 100644
3831 +--- a/drivers/dma/ti/edma.c
3832 ++++ b/drivers/dma/ti/edma.c
3833 +@@ -2289,13 +2289,6 @@ static int edma_probe(struct platform_device *pdev)
3834 + if (!info)
3835 + return -ENODEV;
3836 +
3837 +- pm_runtime_enable(dev);
3838 +- ret = pm_runtime_get_sync(dev);
3839 +- if (ret < 0) {
3840 +- dev_err(dev, "pm_runtime_get_sync() failed\n");
3841 +- return ret;
3842 +- }
3843 +-
3844 + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
3845 + if (ret)
3846 + return ret;
3847 +@@ -2326,27 +2319,33 @@ static int edma_probe(struct platform_device *pdev)
3848 +
3849 + platform_set_drvdata(pdev, ecc);
3850 +
3851 ++ pm_runtime_enable(dev);
3852 ++ ret = pm_runtime_get_sync(dev);
3853 ++ if (ret < 0) {
3854 ++ dev_err(dev, "pm_runtime_get_sync() failed\n");
3855 ++ pm_runtime_disable(dev);
3856 ++ return ret;
3857 ++ }
3858 ++
3859 + /* Get eDMA3 configuration from IP */
3860 + ret = edma_setup_from_hw(dev, info, ecc);
3861 + if (ret)
3862 +- return ret;
3863 ++ goto err_disable_pm;
3864 +
3865 + /* Allocate memory based on the information we got from the IP */
3866 + ecc->slave_chans = devm_kcalloc(dev, ecc->num_channels,
3867 + sizeof(*ecc->slave_chans), GFP_KERNEL);
3868 +- if (!ecc->slave_chans)
3869 +- return -ENOMEM;
3870 +
3871 + ecc->slot_inuse = devm_kcalloc(dev, BITS_TO_LONGS(ecc->num_slots),
3872 + sizeof(unsigned long), GFP_KERNEL);
3873 +- if (!ecc->slot_inuse)
3874 +- return -ENOMEM;
3875 +
3876 + ecc->channels_mask = devm_kcalloc(dev,
3877 + BITS_TO_LONGS(ecc->num_channels),
3878 + sizeof(unsigned long), GFP_KERNEL);
3879 +- if (!ecc->channels_mask)
3880 +- return -ENOMEM;
3881 ++ if (!ecc->slave_chans || !ecc->slot_inuse || !ecc->channels_mask) {
3882 ++ ret = -ENOMEM;
3883 ++ goto err_disable_pm;
3884 ++ }
3885 +
3886 + /* Mark all channels available initially */
3887 + bitmap_fill(ecc->channels_mask, ecc->num_channels);
3888 +@@ -2388,7 +2387,7 @@ static int edma_probe(struct platform_device *pdev)
3889 + ecc);
3890 + if (ret) {
3891 + dev_err(dev, "CCINT (%d) failed --> %d\n", irq, ret);
3892 +- return ret;
3893 ++ goto err_disable_pm;
3894 + }
3895 + ecc->ccint = irq;
3896 + }
3897 +@@ -2404,7 +2403,7 @@ static int edma_probe(struct platform_device *pdev)
3898 + ecc);
3899 + if (ret) {
3900 + dev_err(dev, "CCERRINT (%d) failed --> %d\n", irq, ret);
3901 +- return ret;
3902 ++ goto err_disable_pm;
3903 + }
3904 + ecc->ccerrint = irq;
3905 + }
3906 +@@ -2412,7 +2411,8 @@ static int edma_probe(struct platform_device *pdev)
3907 + ecc->dummy_slot = edma_alloc_slot(ecc, EDMA_SLOT_ANY);
3908 + if (ecc->dummy_slot < 0) {
3909 + dev_err(dev, "Can't allocate PaRAM dummy slot\n");
3910 +- return ecc->dummy_slot;
3911 ++ ret = ecc->dummy_slot;
3912 ++ goto err_disable_pm;
3913 + }
3914 +
3915 + queue_priority_mapping = info->queue_priority_mapping;
3916 +@@ -2512,6 +2512,9 @@ static int edma_probe(struct platform_device *pdev)
3917 +
3918 + err_reg1:
3919 + edma_free_slot(ecc, ecc->dummy_slot);
3920 ++err_disable_pm:
3921 ++ pm_runtime_put_sync(dev);
3922 ++ pm_runtime_disable(dev);
3923 + return ret;
3924 + }
3925 +
3926 +@@ -2542,6 +2545,8 @@ static int edma_remove(struct platform_device *pdev)
3927 + if (ecc->dma_memcpy)
3928 + dma_async_device_unregister(ecc->dma_memcpy);
3929 + edma_free_slot(ecc, ecc->dummy_slot);
3930 ++ pm_runtime_put_sync(dev);
3931 ++ pm_runtime_disable(dev);
3932 +
3933 + return 0;
3934 + }
3935 +diff --git a/drivers/edac/sifive_edac.c b/drivers/edac/sifive_edac.c
3936 +index c0cc72a3b2be..3a3dcb14ed99 100644
3937 +--- a/drivers/edac/sifive_edac.c
3938 ++++ b/drivers/edac/sifive_edac.c
3939 +@@ -54,8 +54,8 @@ static int ecc_register(struct platform_device *pdev)
3940 + p->dci = edac_device_alloc_ctl_info(0, "sifive_ecc", 1, "sifive_ecc",
3941 + 1, 1, NULL, 0,
3942 + edac_device_alloc_index());
3943 +- if (IS_ERR(p->dci))
3944 +- return PTR_ERR(p->dci);
3945 ++ if (!p->dci)
3946 ++ return -ENOMEM;
3947 +
3948 + p->dci->dev = &pdev->dev;
3949 + p->dci->mod_name = "Sifive ECC Manager";
3950 +diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
3951 +index 904fa09e6a6b..d99f5b0c8a09 100644
3952 +--- a/drivers/firmware/efi/arm-init.c
3953 ++++ b/drivers/firmware/efi/arm-init.c
3954 +@@ -10,10 +10,12 @@
3955 + #define pr_fmt(fmt) "efi: " fmt
3956 +
3957 + #include <linux/efi.h>
3958 ++#include <linux/fwnode.h>
3959 + #include <linux/init.h>
3960 + #include <linux/memblock.h>
3961 + #include <linux/mm_types.h>
3962 + #include <linux/of.h>
3963 ++#include <linux/of_address.h>
3964 + #include <linux/of_fdt.h>
3965 + #include <linux/platform_device.h>
3966 + #include <linux/screen_info.h>
3967 +@@ -276,15 +278,112 @@ void __init efi_init(void)
3968 + efi_memmap_unmap();
3969 + }
3970 +
3971 ++static bool efifb_overlaps_pci_range(const struct of_pci_range *range)
3972 ++{
3973 ++ u64 fb_base = screen_info.lfb_base;
3974 ++
3975 ++ if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
3976 ++ fb_base |= (u64)(unsigned long)screen_info.ext_lfb_base << 32;
3977 ++
3978 ++ return fb_base >= range->cpu_addr &&
3979 ++ fb_base < (range->cpu_addr + range->size);
3980 ++}
3981 ++
3982 ++static struct device_node *find_pci_overlap_node(void)
3983 ++{
3984 ++ struct device_node *np;
3985 ++
3986 ++ for_each_node_by_type(np, "pci") {
3987 ++ struct of_pci_range_parser parser;
3988 ++ struct of_pci_range range;
3989 ++ int err;
3990 ++
3991 ++ err = of_pci_range_parser_init(&parser, np);
3992 ++ if (err) {
3993 ++ pr_warn("of_pci_range_parser_init() failed: %d\n", err);
3994 ++ continue;
3995 ++ }
3996 ++
3997 ++ for_each_of_pci_range(&parser, &range)
3998 ++ if (efifb_overlaps_pci_range(&range))
3999 ++ return np;
4000 ++ }
4001 ++ return NULL;
4002 ++}
4003 ++
4004 ++/*
4005 ++ * If the efifb framebuffer is backed by a PCI graphics controller, we have
4006 ++ * to ensure that this relation is expressed using a device link when
4007 ++ * running in DT mode, or the probe order may be reversed, resulting in a
4008 ++ * resource reservation conflict on the memory window that the efifb
4009 ++ * framebuffer steals from the PCIe host bridge.
4010 ++ */
4011 ++static int efifb_add_links(const struct fwnode_handle *fwnode,
4012 ++ struct device *dev)
4013 ++{
4014 ++ struct device_node *sup_np;
4015 ++ struct device *sup_dev;
4016 ++
4017 ++ sup_np = find_pci_overlap_node();
4018 ++
4019 ++ /*
4020 ++ * If there's no PCI graphics controller backing the efifb, we are
4021 ++ * done here.
4022 ++ */
4023 ++ if (!sup_np)
4024 ++ return 0;
4025 ++
4026 ++ sup_dev = get_dev_from_fwnode(&sup_np->fwnode);
4027 ++ of_node_put(sup_np);
4028 ++
4029 ++ /*
4030 ++ * Return -ENODEV if the PCI graphics controller device hasn't been
4031 ++ * registered yet. This ensures that efifb isn't allowed to probe
4032 ++ * and this function is retried again when new devices are
4033 ++ * registered.
4034 ++ */
4035 ++ if (!sup_dev)
4036 ++ return -ENODEV;
4037 ++
4038 ++ /*
4039 ++ * If this fails, retrying this function at a later point won't
4040 ++ * change anything. So, don't return an error after this.
4041 ++ */
4042 ++ if (!device_link_add(dev, sup_dev, 0))
4043 ++ dev_warn(dev, "device_link_add() failed\n");
4044 ++
4045 ++ put_device(sup_dev);
4046 ++
4047 ++ return 0;
4048 ++}
4049 ++
4050 ++static const struct fwnode_operations efifb_fwnode_ops = {
4051 ++ .add_links = efifb_add_links,
4052 ++};
4053 ++
4054 ++static struct fwnode_handle efifb_fwnode = {
4055 ++ .ops = &efifb_fwnode_ops,
4056 ++};
4057 ++
4058 + static int __init register_gop_device(void)
4059 + {
4060 +- void *pd;
4061 ++ struct platform_device *pd;
4062 ++ int err;
4063 +
4064 + if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
4065 + return 0;
4066 +
4067 +- pd = platform_device_register_data(NULL, "efi-framebuffer", 0,
4068 +- &screen_info, sizeof(screen_info));
4069 +- return PTR_ERR_OR_ZERO(pd);
4070 ++ pd = platform_device_alloc("efi-framebuffer", 0);
4071 ++ if (!pd)
4072 ++ return -ENOMEM;
4073 ++
4074 ++ if (IS_ENABLED(CONFIG_PCI))
4075 ++ pd->dev.fwnode = &efifb_fwnode;
4076 ++
4077 ++ err = platform_device_add_data(pd, &screen_info, sizeof(screen_info));
4078 ++ if (err)
4079 ++ return err;
4080 ++
4081 ++ return platform_device_add(pd);
4082 + }
4083 + subsys_initcall(register_gop_device);
4084 +diff --git a/drivers/gpio/gpio-grgpio.c b/drivers/gpio/gpio-grgpio.c
4085 +index 08234e64993a..3224933f4c8f 100644
4086 +--- a/drivers/gpio/gpio-grgpio.c
4087 ++++ b/drivers/gpio/gpio-grgpio.c
4088 +@@ -253,17 +253,16 @@ static int grgpio_irq_map(struct irq_domain *d, unsigned int irq,
4089 + lirq->irq = irq;
4090 + uirq = &priv->uirqs[lirq->index];
4091 + if (uirq->refcnt == 0) {
4092 ++ spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags);
4093 + ret = request_irq(uirq->uirq, grgpio_irq_handler, 0,
4094 + dev_name(priv->dev), priv);
4095 + if (ret) {
4096 + dev_err(priv->dev,
4097 + "Could not request underlying irq %d\n",
4098 + uirq->uirq);
4099 +-
4100 +- spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags);
4101 +-
4102 + return ret;
4103 + }
4104 ++ spin_lock_irqsave(&priv->gc.bgpio_lock, flags);
4105 + }
4106 + uirq->refcnt++;
4107 +
4108 +@@ -309,8 +308,11 @@ static void grgpio_irq_unmap(struct irq_domain *d, unsigned int irq)
4109 + if (index >= 0) {
4110 + uirq = &priv->uirqs[lirq->index];
4111 + uirq->refcnt--;
4112 +- if (uirq->refcnt == 0)
4113 ++ if (uirq->refcnt == 0) {
4114 ++ spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags);
4115 + free_irq(uirq->uirq, priv);
4116 ++ return;
4117 ++ }
4118 + }
4119 +
4120 + spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags);
4121 +diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
4122 +index bcfbfded9ba3..175c6363cf61 100644
4123 +--- a/drivers/gpio/gpiolib.c
4124 ++++ b/drivers/gpio/gpiolib.c
4125 +@@ -2053,6 +2053,7 @@ static int gpiochip_hierarchy_irq_domain_alloc(struct irq_domain *d,
4126 + parent_type);
4127 + chip_info(gc, "alloc_irqs_parent for %d parent hwirq %d\n",
4128 + irq, parent_hwirq);
4129 ++ irq_set_lockdep_class(irq, gc->irq.lock_key, gc->irq.request_key);
4130 + ret = irq_domain_alloc_irqs_parent(d, irq, 1, &parent_fwspec);
4131 + if (ret)
4132 + chip_err(gc,
4133 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
4134 +index 72232fccf61a..be6d0cfe41ae 100644
4135 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
4136 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
4137 +@@ -338,17 +338,9 @@ bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *
4138 + path_size += le16_to_cpu(path->usSize);
4139 +
4140 + if (device_support & le16_to_cpu(path->usDeviceTag)) {
4141 +- uint8_t con_obj_id, con_obj_num, con_obj_type;
4142 +-
4143 +- con_obj_id =
4144 ++ uint8_t con_obj_id =
4145 + (le16_to_cpu(path->usConnObjectId) & OBJECT_ID_MASK)
4146 + >> OBJECT_ID_SHIFT;
4147 +- con_obj_num =
4148 +- (le16_to_cpu(path->usConnObjectId) & ENUM_ID_MASK)
4149 +- >> ENUM_ID_SHIFT;
4150 +- con_obj_type =
4151 +- (le16_to_cpu(path->usConnObjectId) &
4152 +- OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT;
4153 +
4154 + /* Skip TV/CV support */
4155 + if ((le16_to_cpu(path->usDeviceTag) ==
4156 +@@ -373,14 +365,7 @@ bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *
4157 + router.ddc_valid = false;
4158 + router.cd_valid = false;
4159 + for (j = 0; j < ((le16_to_cpu(path->usSize) - 8) / 2); j++) {
4160 +- uint8_t grph_obj_id, grph_obj_num, grph_obj_type;
4161 +-
4162 +- grph_obj_id =
4163 +- (le16_to_cpu(path->usGraphicObjIds[j]) &
4164 +- OBJECT_ID_MASK) >> OBJECT_ID_SHIFT;
4165 +- grph_obj_num =
4166 +- (le16_to_cpu(path->usGraphicObjIds[j]) &
4167 +- ENUM_ID_MASK) >> ENUM_ID_SHIFT;
4168 ++ uint8_t grph_obj_type=
4169 + grph_obj_type =
4170 + (le16_to_cpu(path->usGraphicObjIds[j]) &
4171 + OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT;
4172 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
4173 +index c17505fba988..332b9c24a2cd 100644
4174 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
4175 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
4176 +@@ -3639,8 +3639,6 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
4177 + if (r)
4178 + return r;
4179 +
4180 +- amdgpu_amdkfd_pre_reset(adev);
4181 +-
4182 + /* Resume IP prior to SMC */
4183 + r = amdgpu_device_ip_reinit_early_sriov(adev);
4184 + if (r)
4185 +diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
4186 +index 0d8767eb7a70..1c3a7d4bb65d 100644
4187 +--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
4188 ++++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
4189 +@@ -269,7 +269,11 @@ flr_done:
4190 + }
4191 +
4192 + /* Trigger recovery for world switch failure if no TDR */
4193 +- if (amdgpu_device_should_recover_gpu(adev))
4194 ++ if (amdgpu_device_should_recover_gpu(adev)
4195 ++ && (adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT ||
4196 ++ adev->gfx_timeout == MAX_SCHEDULE_TIMEOUT ||
4197 ++ adev->compute_timeout == MAX_SCHEDULE_TIMEOUT ||
4198 ++ adev->video_timeout == MAX_SCHEDULE_TIMEOUT))
4199 + amdgpu_device_gpu_recover(adev, NULL);
4200 + }
4201 +
4202 +diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
4203 +index 0ba66bef5746..de40bf12c4a8 100644
4204 +--- a/drivers/gpu/drm/amd/amdgpu/nv.c
4205 ++++ b/drivers/gpu/drm/amd/amdgpu/nv.c
4206 +@@ -701,6 +701,12 @@ static int nv_common_early_init(void *handle)
4207 + adev->pg_flags = AMD_PG_SUPPORT_VCN |
4208 + AMD_PG_SUPPORT_VCN_DPG |
4209 + AMD_PG_SUPPORT_ATHUB;
4210 ++ /* guest vm gets 0xffffffff when reading RCC_DEV0_EPF0_STRAP0,
4211 ++ * as a consequence, the rev_id and external_rev_id are wrong.
4212 ++ * workaround it by hardcoding rev_id to 0 (default value).
4213 ++ */
4214 ++ if (amdgpu_sriov_vf(adev))
4215 ++ adev->rev_id = 0;
4216 + adev->external_rev_id = adev->rev_id + 0xa;
4217 + break;
4218 + default:
4219 +diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
4220 +index 8e1640bc07af..04ea7cd69295 100644
4221 +--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
4222 ++++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
4223 +@@ -1145,9 +1145,7 @@ static int soc15_common_early_init(void *handle)
4224 + AMD_CG_SUPPORT_SDMA_LS |
4225 + AMD_CG_SUPPORT_VCN_MGCG;
4226 +
4227 +- adev->pg_flags = AMD_PG_SUPPORT_SDMA |
4228 +- AMD_PG_SUPPORT_VCN |
4229 +- AMD_PG_SUPPORT_VCN_DPG;
4230 ++ adev->pg_flags = AMD_PG_SUPPORT_SDMA | AMD_PG_SUPPORT_VCN;
4231 + } else if (adev->pdev->device == 0x15d8) {
4232 + adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
4233 + AMD_CG_SUPPORT_GFX_MGLS |
4234 +@@ -1190,9 +1188,7 @@ static int soc15_common_early_init(void *handle)
4235 + AMD_CG_SUPPORT_SDMA_LS |
4236 + AMD_CG_SUPPORT_VCN_MGCG;
4237 +
4238 +- adev->pg_flags = AMD_PG_SUPPORT_SDMA |
4239 +- AMD_PG_SUPPORT_VCN |
4240 +- AMD_PG_SUPPORT_VCN_DPG;
4241 ++ adev->pg_flags = AMD_PG_SUPPORT_SDMA | AMD_PG_SUPPORT_VCN;
4242 + }
4243 + break;
4244 + case CHIP_ARCTURUS:
4245 +diff --git a/drivers/gpu/drm/amd/amdgpu/soc15_common.h b/drivers/gpu/drm/amd/amdgpu/soc15_common.h
4246 +index 839f186e1182..19e870c79896 100644
4247 +--- a/drivers/gpu/drm/amd/amdgpu/soc15_common.h
4248 ++++ b/drivers/gpu/drm/amd/amdgpu/soc15_common.h
4249 +@@ -52,6 +52,7 @@
4250 + uint32_t old_ = 0; \
4251 + uint32_t tmp_ = RREG32(adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg); \
4252 + uint32_t loop = adev->usec_timeout; \
4253 ++ ret = 0; \
4254 + while ((tmp_ & (mask)) != (expected_value)) { \
4255 + if (old_ != tmp_) { \
4256 + loop = adev->usec_timeout; \
4257 +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
4258 +index 15c523027285..511712c2e382 100644
4259 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
4260 ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
4261 +@@ -93,7 +93,7 @@ void kfd_debugfs_init(void)
4262 + kfd_debugfs_hqds_by_device, &kfd_debugfs_fops);
4263 + debugfs_create_file("rls", S_IFREG | 0444, debugfs_root,
4264 + kfd_debugfs_rls_by_device, &kfd_debugfs_fops);
4265 +- debugfs_create_file("hang_hws", S_IFREG | 0644, debugfs_root,
4266 ++ debugfs_create_file("hang_hws", S_IFREG | 0200, debugfs_root,
4267 + NULL, &kfd_debugfs_hang_hws_fops);
4268 + }
4269 +
4270 +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
4271 +index 984c2f2b24b6..d128a8bbe19d 100644
4272 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
4273 ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
4274 +@@ -1225,16 +1225,18 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
4275 +
4276 + list_add(&q->list, &qpd->queues_list);
4277 + qpd->queue_count++;
4278 ++
4279 ++ if (q->properties.type == KFD_QUEUE_TYPE_SDMA)
4280 ++ dqm->sdma_queue_count++;
4281 ++ else if (q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
4282 ++ dqm->xgmi_sdma_queue_count++;
4283 ++
4284 + if (q->properties.is_active) {
4285 + dqm->queue_count++;
4286 + retval = execute_queues_cpsch(dqm,
4287 + KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0);
4288 + }
4289 +
4290 +- if (q->properties.type == KFD_QUEUE_TYPE_SDMA)
4291 +- dqm->sdma_queue_count++;
4292 +- else if (q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
4293 +- dqm->xgmi_sdma_queue_count++;
4294 + /*
4295 + * Unconditionally increment this counter, regardless of the queue's
4296 + * type or whether the queue is active.
4297 +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
4298 +index 0b401dfbe98a..34f483ac36ca 100644
4299 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
4300 ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
4301 +@@ -97,8 +97,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
4302 + (struct edid *) edid->raw_edid);
4303 +
4304 + sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads);
4305 +- if (sad_count < 0)
4306 +- DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
4307 + if (sad_count <= 0)
4308 + return result;
4309 +
4310 +diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.h b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.h
4311 +deleted file mode 100644
4312 +index 45a07eeffbb6..000000000000
4313 +--- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.h
4314 ++++ /dev/null
4315 +@@ -1,43 +0,0 @@
4316 +-/*
4317 +- * Copyright 2017 Advanced Micro Devices, Inc.
4318 +- *
4319 +- * Permission is hereby granted, free of charge, to any person obtaining a
4320 +- * copy of this software and associated documentation files (the "Software"),
4321 +- * to deal in the Software without restriction, including without limitation
4322 +- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
4323 +- * and/or sell copies of the Software, and to permit persons to whom the
4324 +- * Software is furnished to do so, subject to the following conditions:
4325 +- *
4326 +- * The above copyright notice and this permission notice shall be included in
4327 +- * all copies or substantial portions of the Software.
4328 +- *
4329 +- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4330 +- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4331 +- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
4332 +- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
4333 +- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
4334 +- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
4335 +- * OTHER DEALINGS IN THE SOFTWARE.
4336 +- *
4337 +- * Authors: AMD
4338 +- *
4339 +- */
4340 +-
4341 +-#ifndef _DCN_CALC_MATH_H_
4342 +-#define _DCN_CALC_MATH_H_
4343 +-
4344 +-float dcn_bw_mod(const float arg1, const float arg2);
4345 +-float dcn_bw_min2(const float arg1, const float arg2);
4346 +-unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2);
4347 +-float dcn_bw_max2(const float arg1, const float arg2);
4348 +-float dcn_bw_floor2(const float arg, const float significance);
4349 +-float dcn_bw_floor(const float arg);
4350 +-float dcn_bw_ceil2(const float arg, const float significance);
4351 +-float dcn_bw_ceil(const float arg);
4352 +-float dcn_bw_max3(float v1, float v2, float v3);
4353 +-float dcn_bw_max5(float v1, float v2, float v3, float v4, float v5);
4354 +-float dcn_bw_pow(float a, float exp);
4355 +-float dcn_bw_log(float a, float b);
4356 +-double dcn_bw_fabs(double a);
4357 +-
4358 +-#endif /* _DCN_CALC_MATH_H_ */
4359 +diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c
4360 +index 9b2cb57bf2ba..c9a241fe46cf 100644
4361 +--- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c
4362 ++++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c
4363 +@@ -1438,6 +1438,7 @@ void dcn_bw_update_from_pplib(struct dc *dc)
4364 + struct dc_context *ctx = dc->ctx;
4365 + struct dm_pp_clock_levels_with_voltage fclks = {0}, dcfclks = {0};
4366 + bool res;
4367 ++ unsigned vmin0p65_idx, vmid0p72_idx, vnom0p8_idx, vmax0p9_idx;
4368 +
4369 + /* TODO: This is not the proper way to obtain fabric_and_dram_bandwidth, should be min(fclk, memclk) */
4370 + res = dm_pp_get_clock_levels_by_type_with_voltage(
4371 +@@ -1449,17 +1450,28 @@ void dcn_bw_update_from_pplib(struct dc *dc)
4372 + res = verify_clock_values(&fclks);
4373 +
4374 + if (res) {
4375 +- ASSERT(fclks.num_levels >= 3);
4376 +- dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 = 32 * (fclks.data[0].clocks_in_khz / 1000.0) / 1000.0;
4377 +- dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72 = dc->dcn_soc->number_of_channels *
4378 +- (fclks.data[fclks.num_levels - (fclks.num_levels > 2 ? 3 : 2)].clocks_in_khz / 1000.0)
4379 +- * ddr4_dram_factor_single_Channel / 1000.0;
4380 +- dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8 = dc->dcn_soc->number_of_channels *
4381 +- (fclks.data[fclks.num_levels - 2].clocks_in_khz / 1000.0)
4382 +- * ddr4_dram_factor_single_Channel / 1000.0;
4383 +- dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 = dc->dcn_soc->number_of_channels *
4384 +- (fclks.data[fclks.num_levels - 1].clocks_in_khz / 1000.0)
4385 +- * ddr4_dram_factor_single_Channel / 1000.0;
4386 ++ ASSERT(fclks.num_levels);
4387 ++
4388 ++ vmin0p65_idx = 0;
4389 ++ vmid0p72_idx = fclks.num_levels -
4390 ++ (fclks.num_levels > 2 ? 3 : (fclks.num_levels > 1 ? 2 : 1));
4391 ++ vnom0p8_idx = fclks.num_levels - (fclks.num_levels > 1 ? 2 : 1);
4392 ++ vmax0p9_idx = fclks.num_levels - 1;
4393 ++
4394 ++ dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 =
4395 ++ 32 * (fclks.data[vmin0p65_idx].clocks_in_khz / 1000.0) / 1000.0;
4396 ++ dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72 =
4397 ++ dc->dcn_soc->number_of_channels *
4398 ++ (fclks.data[vmid0p72_idx].clocks_in_khz / 1000.0)
4399 ++ * ddr4_dram_factor_single_Channel / 1000.0;
4400 ++ dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8 =
4401 ++ dc->dcn_soc->number_of_channels *
4402 ++ (fclks.data[vnom0p8_idx].clocks_in_khz / 1000.0)
4403 ++ * ddr4_dram_factor_single_Channel / 1000.0;
4404 ++ dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 =
4405 ++ dc->dcn_soc->number_of_channels *
4406 ++ (fclks.data[vmax0p9_idx].clocks_in_khz / 1000.0)
4407 ++ * ddr4_dram_factor_single_Channel / 1000.0;
4408 + } else
4409 + BREAK_TO_DEBUGGER();
4410 +
4411 +diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
4412 +index 25d7b7c6681c..7dca2e6eb3bc 100644
4413 +--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
4414 ++++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
4415 +@@ -100,13 +100,13 @@ uint32_t dentist_get_did_from_divider(int divider)
4416 + }
4417 +
4418 + void dcn20_update_clocks_update_dpp_dto(struct clk_mgr_internal *clk_mgr,
4419 +- struct dc_state *context)
4420 ++ struct dc_state *context, bool safe_to_lower)
4421 + {
4422 + int i;
4423 +
4424 + clk_mgr->dccg->ref_dppclk = clk_mgr->base.clks.dppclk_khz;
4425 + for (i = 0; i < clk_mgr->base.ctx->dc->res_pool->pipe_count; i++) {
4426 +- int dpp_inst, dppclk_khz;
4427 ++ int dpp_inst, dppclk_khz, prev_dppclk_khz;
4428 +
4429 + /* Loop index will match dpp->inst if resource exists,
4430 + * and we want to avoid dependency on dpp object
4431 +@@ -114,8 +114,12 @@ void dcn20_update_clocks_update_dpp_dto(struct clk_mgr_internal *clk_mgr,
4432 + dpp_inst = i;
4433 + dppclk_khz = context->res_ctx.pipe_ctx[i].plane_res.bw.dppclk_khz;
4434 +
4435 +- clk_mgr->dccg->funcs->update_dpp_dto(
4436 +- clk_mgr->dccg, dpp_inst, dppclk_khz);
4437 ++ prev_dppclk_khz = clk_mgr->base.ctx->dc->current_state->res_ctx.pipe_ctx[i].plane_res.bw.dppclk_khz;
4438 ++
4439 ++ if (safe_to_lower || prev_dppclk_khz < dppclk_khz) {
4440 ++ clk_mgr->dccg->funcs->update_dpp_dto(
4441 ++ clk_mgr->dccg, dpp_inst, dppclk_khz);
4442 ++ }
4443 + }
4444 + }
4445 +
4446 +@@ -240,7 +244,7 @@ void dcn2_update_clocks(struct clk_mgr *clk_mgr_base,
4447 + if (dc->config.forced_clocks == false || (force_reset && safe_to_lower)) {
4448 + if (dpp_clock_lowered) {
4449 + // if clock is being lowered, increase DTO before lowering refclk
4450 +- dcn20_update_clocks_update_dpp_dto(clk_mgr, context);
4451 ++ dcn20_update_clocks_update_dpp_dto(clk_mgr, context, safe_to_lower);
4452 + dcn20_update_clocks_update_dentist(clk_mgr);
4453 + } else {
4454 + // if clock is being raised, increase refclk before lowering DTO
4455 +@@ -248,7 +252,7 @@ void dcn2_update_clocks(struct clk_mgr *clk_mgr_base,
4456 + dcn20_update_clocks_update_dentist(clk_mgr);
4457 + // always update dtos unless clock is lowered and not safe to lower
4458 + if (new_clocks->dppclk_khz >= dc->current_state->bw_ctx.bw.dcn.clk.dppclk_khz)
4459 +- dcn20_update_clocks_update_dpp_dto(clk_mgr, context);
4460 ++ dcn20_update_clocks_update_dpp_dto(clk_mgr, context, safe_to_lower);
4461 + }
4462 + }
4463 +
4464 +diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.h b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.h
4465 +index c9fd824f3c23..74ccd6c04134 100644
4466 +--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.h
4467 ++++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.h
4468 +@@ -34,7 +34,7 @@ void dcn2_update_clocks_fpga(struct clk_mgr *clk_mgr,
4469 + struct dc_state *context,
4470 + bool safe_to_lower);
4471 + void dcn20_update_clocks_update_dpp_dto(struct clk_mgr_internal *clk_mgr,
4472 +- struct dc_state *context);
4473 ++ struct dc_state *context, bool safe_to_lower);
4474 +
4475 + void dcn2_init_clocks(struct clk_mgr *clk_mgr);
4476 +
4477 +diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
4478 +index 35c55e54eac0..dbf063856846 100644
4479 +--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
4480 ++++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
4481 +@@ -164,16 +164,16 @@ void rn_update_clocks(struct clk_mgr *clk_mgr_base,
4482 + }
4483 +
4484 + if (dpp_clock_lowered) {
4485 +- // if clock is being lowered, increase DTO before lowering refclk
4486 +- dcn20_update_clocks_update_dpp_dto(clk_mgr, context);
4487 ++ // increase per DPP DTO before lowering global dppclk
4488 ++ dcn20_update_clocks_update_dpp_dto(clk_mgr, context, safe_to_lower);
4489 + rn_vbios_smu_set_dppclk(clk_mgr, clk_mgr_base->clks.dppclk_khz);
4490 + } else {
4491 +- // if clock is being raised, increase refclk before lowering DTO
4492 ++ // increase global DPPCLK before lowering per DPP DTO
4493 + if (update_dppclk || update_dispclk)
4494 + rn_vbios_smu_set_dppclk(clk_mgr, clk_mgr_base->clks.dppclk_khz);
4495 + // always update dtos unless clock is lowered and not safe to lower
4496 + if (new_clocks->dppclk_khz >= dc->current_state->bw_ctx.bw.dcn.clk.dppclk_khz)
4497 +- dcn20_update_clocks_update_dpp_dto(clk_mgr, context);
4498 ++ dcn20_update_clocks_update_dpp_dto(clk_mgr, context, safe_to_lower);
4499 + }
4500 +
4501 + if (update_dispclk &&
4502 +diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
4503 +index 32f31bf91915..8904a85186aa 100644
4504 +--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
4505 ++++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
4506 +@@ -2396,12 +2396,7 @@ void dc_set_power_state(
4507 + enum dc_acpi_cm_power_state power_state)
4508 + {
4509 + struct kref refcount;
4510 +- struct display_mode_lib *dml = kzalloc(sizeof(struct display_mode_lib),
4511 +- GFP_KERNEL);
4512 +-
4513 +- ASSERT(dml);
4514 +- if (!dml)
4515 +- return;
4516 ++ struct display_mode_lib *dml;
4517 +
4518 + switch (power_state) {
4519 + case DC_ACPI_CM_POWER_STATE_D0:
4520 +@@ -2423,6 +2418,12 @@ void dc_set_power_state(
4521 + * clean state, and dc hw programming optimizations will not
4522 + * cause any trouble.
4523 + */
4524 ++ dml = kzalloc(sizeof(struct display_mode_lib),
4525 ++ GFP_KERNEL);
4526 ++
4527 ++ ASSERT(dml);
4528 ++ if (!dml)
4529 ++ return;
4530 +
4531 + /* Preserve refcount */
4532 + refcount = dc->current_state->refcount;
4533 +@@ -2436,10 +2437,10 @@ void dc_set_power_state(
4534 + dc->current_state->refcount = refcount;
4535 + dc->current_state->bw_ctx.dml = *dml;
4536 +
4537 ++ kfree(dml);
4538 ++
4539 + break;
4540 + }
4541 +-
4542 +- kfree(dml);
4543 + }
4544 +
4545 + void dc_resume(struct dc *dc)
4546 +diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
4547 +index 4619f94f0ac7..70846ae7d854 100644
4548 +--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
4549 ++++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
4550 +@@ -968,8 +968,7 @@ static bool dc_link_detect_helper(struct dc_link *link,
4551 + same_edid = is_same_edid(&prev_sink->dc_edid, &sink->dc_edid);
4552 +
4553 + if (link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT &&
4554 +- sink_caps.transaction_type == DDC_TRANSACTION_TYPE_I2C_OVER_AUX &&
4555 +- reason != DETECT_REASON_HPDRX) {
4556 ++ sink_caps.transaction_type == DDC_TRANSACTION_TYPE_I2C_OVER_AUX) {
4557 + /*
4558 + * TODO debug why Dell 2413 doesn't like
4559 + * two link trainings
4560 +diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
4561 +index 0416a17b0897..320f4eeebf84 100644
4562 +--- a/drivers/gpu/drm/amd/display/dc/dc.h
4563 ++++ b/drivers/gpu/drm/amd/display/dc/dc.h
4564 +@@ -417,6 +417,8 @@ struct dc_debug_options {
4565 + bool cm_in_bypass;
4566 + #endif
4567 + int force_clock_mode;/*every mode change.*/
4568 ++
4569 ++ bool nv12_iflip_vm_wa;
4570 + };
4571 +
4572 + struct dc_debug_data {
4573 +diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c
4574 +index 3b613fb93ef8..0162d3ffe268 100644
4575 +--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c
4576 ++++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c
4577 +@@ -233,12 +233,13 @@ void optc2_set_odm_combine(struct timing_generator *optc, int *opp_id, int opp_c
4578 + struct dc_crtc_timing *timing)
4579 + {
4580 + struct optc *optc1 = DCN10TG_FROM_TG(optc);
4581 +- /* 2 pieces of memory required for up to 5120 displays, 4 for up to 8192 */
4582 + int mpcc_hactive = (timing->h_addressable + timing->h_border_left + timing->h_border_right)
4583 + / opp_cnt;
4584 +- int memory_mask = mpcc_hactive <= 2560 ? 0x3 : 0xf;
4585 ++ uint32_t memory_mask;
4586 + uint32_t data_fmt = 0;
4587 +
4588 ++ ASSERT(opp_cnt == 2);
4589 ++
4590 + /* TODO: In pseudocode but does not affect maximus, delete comment if we dont need on asic
4591 + * REG_SET(OTG_GLOBAL_CONTROL2, 0, GLOBAL_UPDATE_LOCK_EN, 1);
4592 + * Program OTG register MASTER_UPDATE_LOCK_DB_X/Y to the position before DP frame start
4593 +@@ -246,9 +247,17 @@ void optc2_set_odm_combine(struct timing_generator *optc, int *opp_id, int opp_c
4594 + * MASTER_UPDATE_LOCK_DB_X, 160,
4595 + * MASTER_UPDATE_LOCK_DB_Y, 240);
4596 + */
4597 ++
4598 ++ /* 2 pieces of memory required for up to 5120 displays, 4 for up to 8192,
4599 ++ * however, for ODM combine we can simplify by always using 4.
4600 ++ * To make sure there's no overlap, each instance "reserves" 2 memories and
4601 ++ * they are uniquely combined here.
4602 ++ */
4603 ++ memory_mask = 0x3 << (opp_id[0] * 2) | 0x3 << (opp_id[1] * 2);
4604 ++
4605 + if (REG(OPTC_MEMORY_CONFIG))
4606 + REG_SET(OPTC_MEMORY_CONFIG, 0,
4607 +- OPTC_MEM_SEL, memory_mask << (optc->inst * 4));
4608 ++ OPTC_MEM_SEL, memory_mask);
4609 +
4610 + if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR422)
4611 + data_fmt = 1;
4612 +@@ -257,7 +266,6 @@ void optc2_set_odm_combine(struct timing_generator *optc, int *opp_id, int opp_c
4613 +
4614 + REG_UPDATE(OPTC_DATA_FORMAT_CONTROL, OPTC_DATA_FORMAT, data_fmt);
4615 +
4616 +- ASSERT(opp_cnt == 2);
4617 + REG_SET_3(OPTC_DATA_SOURCE_SELECT, 0,
4618 + OPTC_NUM_OF_INPUT_SEGMENT, 1,
4619 + OPTC_SEG0_SRC_SEL, opp_id[0],
4620 +diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
4621 +index 2f5a5867e674..1ddd6ae22155 100644
4622 +--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
4623 ++++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
4624 +@@ -164,6 +164,69 @@ static void hubp21_setup(
4625 +
4626 + }
4627 +
4628 ++void hubp21_set_viewport(
4629 ++ struct hubp *hubp,
4630 ++ const struct rect *viewport,
4631 ++ const struct rect *viewport_c)
4632 ++{
4633 ++ struct dcn21_hubp *hubp21 = TO_DCN21_HUBP(hubp);
4634 ++ int patched_viewport_height = 0;
4635 ++ struct dc_debug_options *debug = &hubp->ctx->dc->debug;
4636 ++
4637 ++ REG_SET_2(DCSURF_PRI_VIEWPORT_DIMENSION, 0,
4638 ++ PRI_VIEWPORT_WIDTH, viewport->width,
4639 ++ PRI_VIEWPORT_HEIGHT, viewport->height);
4640 ++
4641 ++ REG_SET_2(DCSURF_PRI_VIEWPORT_START, 0,
4642 ++ PRI_VIEWPORT_X_START, viewport->x,
4643 ++ PRI_VIEWPORT_Y_START, viewport->y);
4644 ++
4645 ++ /*for stereo*/
4646 ++ REG_SET_2(DCSURF_SEC_VIEWPORT_DIMENSION, 0,
4647 ++ SEC_VIEWPORT_WIDTH, viewport->width,
4648 ++ SEC_VIEWPORT_HEIGHT, viewport->height);
4649 ++
4650 ++ REG_SET_2(DCSURF_SEC_VIEWPORT_START, 0,
4651 ++ SEC_VIEWPORT_X_START, viewport->x,
4652 ++ SEC_VIEWPORT_Y_START, viewport->y);
4653 ++
4654 ++ /*
4655 ++ * Work around for underflow issue with NV12 + rIOMMU translation
4656 ++ * + immediate flip. This will cause hubp underflow, but will not
4657 ++ * be user visible since underflow is in blank region
4658 ++ */
4659 ++ patched_viewport_height = viewport_c->height;
4660 ++ if (viewport_c->height != 0 && debug->nv12_iflip_vm_wa) {
4661 ++ int pte_row_height = 0;
4662 ++ int pte_rows = 0;
4663 ++
4664 ++ REG_GET(DCHUBP_REQ_SIZE_CONFIG,
4665 ++ PTE_ROW_HEIGHT_LINEAR, &pte_row_height);
4666 ++
4667 ++ pte_row_height = 1 << (pte_row_height + 3);
4668 ++ pte_rows = (viewport_c->height + pte_row_height - 1) / pte_row_height;
4669 ++ patched_viewport_height = pte_rows * pte_row_height + 3;
4670 ++ }
4671 ++
4672 ++
4673 ++ /* DC supports NV12 only at the moment */
4674 ++ REG_SET_2(DCSURF_PRI_VIEWPORT_DIMENSION_C, 0,
4675 ++ PRI_VIEWPORT_WIDTH_C, viewport_c->width,
4676 ++ PRI_VIEWPORT_HEIGHT_C, patched_viewport_height);
4677 ++
4678 ++ REG_SET_2(DCSURF_PRI_VIEWPORT_START_C, 0,
4679 ++ PRI_VIEWPORT_X_START_C, viewport_c->x,
4680 ++ PRI_VIEWPORT_Y_START_C, viewport_c->y);
4681 ++
4682 ++ REG_SET_2(DCSURF_SEC_VIEWPORT_DIMENSION_C, 0,
4683 ++ SEC_VIEWPORT_WIDTH_C, viewport_c->width,
4684 ++ SEC_VIEWPORT_HEIGHT_C, patched_viewport_height);
4685 ++
4686 ++ REG_SET_2(DCSURF_SEC_VIEWPORT_START_C, 0,
4687 ++ SEC_VIEWPORT_X_START_C, viewport_c->x,
4688 ++ SEC_VIEWPORT_Y_START_C, viewport_c->y);
4689 ++}
4690 ++
4691 + void hubp21_set_vm_system_aperture_settings(struct hubp *hubp,
4692 + struct vm_system_aperture_param *apt)
4693 + {
4694 +@@ -211,7 +274,7 @@ static struct hubp_funcs dcn21_hubp_funcs = {
4695 + .hubp_set_vm_system_aperture_settings = hubp21_set_vm_system_aperture_settings,
4696 + .set_blank = hubp1_set_blank,
4697 + .dcc_control = hubp1_dcc_control,
4698 +- .mem_program_viewport = min_set_viewport,
4699 ++ .mem_program_viewport = hubp21_set_viewport,
4700 + .set_cursor_attributes = hubp2_cursor_set_attributes,
4701 + .set_cursor_position = hubp1_cursor_set_position,
4702 + .hubp_clk_cntl = hubp1_clk_cntl,
4703 +diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
4704 +index b29b2c99a564..83cda43a1b6b 100644
4705 +--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
4706 ++++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
4707 +@@ -847,6 +847,7 @@ static const struct dc_debug_options debug_defaults_drv = {
4708 + .scl_reset_length10 = true,
4709 + .sanity_checks = true,
4710 + .disable_48mhz_pwrdwn = false,
4711 ++ .nv12_iflip_vm_wa = true
4712 + };
4713 +
4714 + static const struct dc_debug_options debug_defaults_diags = {
4715 +@@ -1351,12 +1352,6 @@ struct display_stream_compressor *dcn21_dsc_create(
4716 +
4717 + static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
4718 + {
4719 +- /*
4720 +- TODO: Fix this function to calcualte correct values.
4721 +- There are known issues with this function currently
4722 +- that will need to be investigated. Use hardcoded known good values for now.
4723 +-
4724 +-
4725 + struct dcn21_resource_pool *pool = TO_DCN21_RES_POOL(dc->res_pool);
4726 + struct clk_limit_table *clk_table = &bw_params->clk_table;
4727 + int i;
4728 +@@ -1371,11 +1366,10 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param
4729 + dcn2_1_soc.clock_limits[i].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz;
4730 + dcn2_1_soc.clock_limits[i].fabricclk_mhz = clk_table->entries[i].fclk_mhz;
4731 + dcn2_1_soc.clock_limits[i].socclk_mhz = clk_table->entries[i].socclk_mhz;
4732 +- dcn2_1_soc.clock_limits[i].dram_speed_mts = clk_table->entries[i].memclk_mhz * 16 / 1000;
4733 ++ dcn2_1_soc.clock_limits[i].dram_speed_mts = clk_table->entries[i].memclk_mhz * 2;
4734 + }
4735 +- dcn2_1_soc.clock_limits[i] = dcn2_1_soc.clock_limits[i - i];
4736 ++ dcn2_1_soc.clock_limits[i] = dcn2_1_soc.clock_limits[i - 1];
4737 + dcn2_1_soc.num_states = i;
4738 +- */
4739 + }
4740 +
4741 + /* Temporary Place holder until we can get them from fuse */
4742 +diff --git a/drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c b/drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c
4743 +index b953b02a1512..723af0b2dda0 100644
4744 +--- a/drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c
4745 ++++ b/drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c
4746 +@@ -24,7 +24,7 @@
4747 + */
4748 +
4749 + #include "dml_common_defs.h"
4750 +-#include "../calcs/dcn_calc_math.h"
4751 ++#include "dcn_calc_math.h"
4752 +
4753 + #include "dml_inline_defs.h"
4754 +
4755 +diff --git a/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h b/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
4756 +index eca140da13d8..ded71ea82413 100644
4757 +--- a/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
4758 ++++ b/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
4759 +@@ -27,7 +27,7 @@
4760 + #define __DML_INLINE_DEFS_H__
4761 +
4762 + #include "dml_common_defs.h"
4763 +-#include "../calcs/dcn_calc_math.h"
4764 ++#include "dcn_calc_math.h"
4765 + #include "dml_logger.h"
4766 +
4767 + static inline double dml_min(double a, double b)
4768 +diff --git a/drivers/gpu/drm/amd/display/dc/inc/dcn_calc_math.h b/drivers/gpu/drm/amd/display/dc/inc/dcn_calc_math.h
4769 +new file mode 100644
4770 +index 000000000000..45a07eeffbb6
4771 +--- /dev/null
4772 ++++ b/drivers/gpu/drm/amd/display/dc/inc/dcn_calc_math.h
4773 +@@ -0,0 +1,43 @@
4774 ++/*
4775 ++ * Copyright 2017 Advanced Micro Devices, Inc.
4776 ++ *
4777 ++ * Permission is hereby granted, free of charge, to any person obtaining a
4778 ++ * copy of this software and associated documentation files (the "Software"),
4779 ++ * to deal in the Software without restriction, including without limitation
4780 ++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
4781 ++ * and/or sell copies of the Software, and to permit persons to whom the
4782 ++ * Software is furnished to do so, subject to the following conditions:
4783 ++ *
4784 ++ * The above copyright notice and this permission notice shall be included in
4785 ++ * all copies or substantial portions of the Software.
4786 ++ *
4787 ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4788 ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4789 ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
4790 ++ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
4791 ++ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
4792 ++ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
4793 ++ * OTHER DEALINGS IN THE SOFTWARE.
4794 ++ *
4795 ++ * Authors: AMD
4796 ++ *
4797 ++ */
4798 ++
4799 ++#ifndef _DCN_CALC_MATH_H_
4800 ++#define _DCN_CALC_MATH_H_
4801 ++
4802 ++float dcn_bw_mod(const float arg1, const float arg2);
4803 ++float dcn_bw_min2(const float arg1, const float arg2);
4804 ++unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2);
4805 ++float dcn_bw_max2(const float arg1, const float arg2);
4806 ++float dcn_bw_floor2(const float arg, const float significance);
4807 ++float dcn_bw_floor(const float arg);
4808 ++float dcn_bw_ceil2(const float arg, const float significance);
4809 ++float dcn_bw_ceil(const float arg);
4810 ++float dcn_bw_max3(float v1, float v2, float v3);
4811 ++float dcn_bw_max5(float v1, float v2, float v3, float v4, float v5);
4812 ++float dcn_bw_pow(float a, float exp);
4813 ++float dcn_bw_log(float a, float b);
4814 ++double dcn_bw_fabs(double a);
4815 ++
4816 ++#endif /* _DCN_CALC_MATH_H_ */
4817 +diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
4818 +index 5437b50e9f90..d9ea4ae690af 100644
4819 +--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
4820 ++++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
4821 +@@ -807,6 +807,7 @@ void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
4822 + 2 * in_out_vrr->min_refresh_in_uhz)
4823 + in_out_vrr->btr.btr_enabled = false;
4824 +
4825 ++ in_out_vrr->fixed.fixed_active = false;
4826 + in_out_vrr->btr.btr_active = false;
4827 + in_out_vrr->btr.inserted_duration_in_us = 0;
4828 + in_out_vrr->btr.frames_to_insert = 0;
4829 +@@ -826,6 +827,7 @@ void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
4830 + in_out_vrr->adjust.v_total_max = stream->timing.v_total;
4831 + } else if (in_out_vrr->state == VRR_STATE_ACTIVE_VARIABLE &&
4832 + refresh_range >= MIN_REFRESH_RANGE_IN_US) {
4833 ++
4834 + in_out_vrr->adjust.v_total_min =
4835 + calc_v_total_from_refresh(stream,
4836 + in_out_vrr->max_refresh_in_uhz);
4837 +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
4838 +index 1115761982a7..fed3fc4bb57a 100644
4839 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
4840 ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
4841 +@@ -1026,12 +1026,15 @@ static int smu10_get_clock_by_type_with_latency(struct pp_hwmgr *hwmgr,
4842 +
4843 + clocks->num_levels = 0;
4844 + for (i = 0; i < pclk_vol_table->count; i++) {
4845 +- clocks->data[i].clocks_in_khz = pclk_vol_table->entries[i].clk * 10;
4846 +- clocks->data[i].latency_in_us = latency_required ?
4847 +- smu10_get_mem_latency(hwmgr,
4848 +- pclk_vol_table->entries[i].clk) :
4849 +- 0;
4850 +- clocks->num_levels++;
4851 ++ if (pclk_vol_table->entries[i].clk) {
4852 ++ clocks->data[clocks->num_levels].clocks_in_khz =
4853 ++ pclk_vol_table->entries[i].clk * 10;
4854 ++ clocks->data[clocks->num_levels].latency_in_us = latency_required ?
4855 ++ smu10_get_mem_latency(hwmgr,
4856 ++ pclk_vol_table->entries[i].clk) :
4857 ++ 0;
4858 ++ clocks->num_levels++;
4859 ++ }
4860 + }
4861 +
4862 + return 0;
4863 +@@ -1077,9 +1080,11 @@ static int smu10_get_clock_by_type_with_voltage(struct pp_hwmgr *hwmgr,
4864 +
4865 + clocks->num_levels = 0;
4866 + for (i = 0; i < pclk_vol_table->count; i++) {
4867 +- clocks->data[i].clocks_in_khz = pclk_vol_table->entries[i].clk * 10;
4868 +- clocks->data[i].voltage_in_mv = pclk_vol_table->entries[i].vol;
4869 +- clocks->num_levels++;
4870 ++ if (pclk_vol_table->entries[i].clk) {
4871 ++ clocks->data[clocks->num_levels].clocks_in_khz = pclk_vol_table->entries[i].clk * 10;
4872 ++ clocks->data[clocks->num_levels].voltage_in_mv = pclk_vol_table->entries[i].vol;
4873 ++ clocks->num_levels++;
4874 ++ }
4875 + }
4876 +
4877 + return 0;
4878 +diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
4879 +index 895b73f23079..6d4a29e99ae2 100644
4880 +--- a/drivers/gpu/drm/drm_client_modeset.c
4881 ++++ b/drivers/gpu/drm/drm_client_modeset.c
4882 +@@ -114,6 +114,33 @@ drm_client_find_modeset(struct drm_client_dev *client, struct drm_crtc *crtc)
4883 + return NULL;
4884 + }
4885 +
4886 ++static struct drm_display_mode *
4887 ++drm_connector_get_tiled_mode(struct drm_connector *connector)
4888 ++{
4889 ++ struct drm_display_mode *mode;
4890 ++
4891 ++ list_for_each_entry(mode, &connector->modes, head) {
4892 ++ if (mode->hdisplay == connector->tile_h_size &&
4893 ++ mode->vdisplay == connector->tile_v_size)
4894 ++ return mode;
4895 ++ }
4896 ++ return NULL;
4897 ++}
4898 ++
4899 ++static struct drm_display_mode *
4900 ++drm_connector_fallback_non_tiled_mode(struct drm_connector *connector)
4901 ++{
4902 ++ struct drm_display_mode *mode;
4903 ++
4904 ++ list_for_each_entry(mode, &connector->modes, head) {
4905 ++ if (mode->hdisplay == connector->tile_h_size &&
4906 ++ mode->vdisplay == connector->tile_v_size)
4907 ++ continue;
4908 ++ return mode;
4909 ++ }
4910 ++ return NULL;
4911 ++}
4912 ++
4913 + static struct drm_display_mode *
4914 + drm_connector_has_preferred_mode(struct drm_connector *connector, int width, int height)
4915 + {
4916 +@@ -348,8 +375,15 @@ static bool drm_client_target_preferred(struct drm_connector **connectors,
4917 + struct drm_connector *connector;
4918 + u64 conn_configured = 0;
4919 + int tile_pass = 0;
4920 ++ int num_tiled_conns = 0;
4921 + int i;
4922 +
4923 ++ for (i = 0; i < connector_count; i++) {
4924 ++ if (connectors[i]->has_tile &&
4925 ++ connectors[i]->status == connector_status_connected)
4926 ++ num_tiled_conns++;
4927 ++ }
4928 ++
4929 + retry:
4930 + for (i = 0; i < connector_count; i++) {
4931 + connector = connectors[i];
4932 +@@ -399,6 +433,28 @@ retry:
4933 + list_for_each_entry(modes[i], &connector->modes, head)
4934 + break;
4935 + }
4936 ++ /*
4937 ++ * In case of tiled mode if all tiles not present fallback to
4938 ++ * first available non tiled mode.
4939 ++ * After all tiles are present, try to find the tiled mode
4940 ++ * for all and if tiled mode not present due to fbcon size
4941 ++ * limitations, use first non tiled mode only for
4942 ++ * tile 0,0 and set to no mode for all other tiles.
4943 ++ */
4944 ++ if (connector->has_tile) {
4945 ++ if (num_tiled_conns <
4946 ++ connector->num_h_tile * connector->num_v_tile ||
4947 ++ (connector->tile_h_loc == 0 &&
4948 ++ connector->tile_v_loc == 0 &&
4949 ++ !drm_connector_get_tiled_mode(connector))) {
4950 ++ DRM_DEBUG_KMS("Falling back to non tiled mode on Connector %d\n",
4951 ++ connector->base.id);
4952 ++ modes[i] = drm_connector_fallback_non_tiled_mode(connector);
4953 ++ } else {
4954 ++ modes[i] = drm_connector_get_tiled_mode(connector);
4955 ++ }
4956 ++ }
4957 ++
4958 + DRM_DEBUG_KMS("found mode %s\n", modes[i] ? modes[i]->name :
4959 + "none");
4960 + conn_configured |= BIT_ULL(i);
4961 +@@ -515,6 +571,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client,
4962 + bool fallback = true, ret = true;
4963 + int num_connectors_enabled = 0;
4964 + int num_connectors_detected = 0;
4965 ++ int num_tiled_conns = 0;
4966 + struct drm_modeset_acquire_ctx ctx;
4967 +
4968 + if (!drm_drv_uses_atomic_modeset(dev))
4969 +@@ -532,6 +589,11 @@ static bool drm_client_firmware_config(struct drm_client_dev *client,
4970 + memcpy(save_enabled, enabled, count);
4971 + mask = GENMASK(count - 1, 0);
4972 + conn_configured = 0;
4973 ++ for (i = 0; i < count; i++) {
4974 ++ if (connectors[i]->has_tile &&
4975 ++ connectors[i]->status == connector_status_connected)
4976 ++ num_tiled_conns++;
4977 ++ }
4978 + retry:
4979 + conn_seq = conn_configured;
4980 + for (i = 0; i < count; i++) {
4981 +@@ -631,6 +693,16 @@ retry:
4982 + connector->name);
4983 + modes[i] = &connector->state->crtc->mode;
4984 + }
4985 ++ /*
4986 ++ * In case of tiled modes, if all tiles are not present
4987 ++ * then fallback to a non tiled mode.
4988 ++ */
4989 ++ if (connector->has_tile &&
4990 ++ num_tiled_conns < connector->num_h_tile * connector->num_v_tile) {
4991 ++ DRM_DEBUG_KMS("Falling back to non tiled mode on Connector %d\n",
4992 ++ connector->base.id);
4993 ++ modes[i] = drm_connector_fallback_non_tiled_mode(connector);
4994 ++ }
4995 + crtcs[i] = new_crtc;
4996 +
4997 + DRM_DEBUG_KMS("connector %s on [CRTC:%d:%s]: %dx%d%s\n",
4998 +diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c
4999 +index ca3c55c6b815..2ece2957da1a 100644
5000 +--- a/drivers/gpu/drm/drm_debugfs_crc.c
5001 ++++ b/drivers/gpu/drm/drm_debugfs_crc.c
5002 +@@ -140,8 +140,8 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf,
5003 + if (IS_ERR(source))
5004 + return PTR_ERR(source);
5005 +
5006 +- if (source[len] == '\n')
5007 +- source[len] = '\0';
5008 ++ if (source[len - 1] == '\n')
5009 ++ source[len - 1] = '\0';
5010 +
5011 + ret = crtc->funcs->verify_crc_source(crtc, source, &values_cnt);
5012 + if (ret)
5013 +diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
5014 +index 6cd90cb4b6b1..4a65ef8d8bff 100644
5015 +--- a/drivers/gpu/drm/drm_dp_mst_topology.c
5016 ++++ b/drivers/gpu/drm/drm_dp_mst_topology.c
5017 +@@ -517,8 +517,10 @@ drm_dp_decode_sideband_req(const struct drm_dp_sideband_msg_tx *raw,
5018 + }
5019 +
5020 + if (failed) {
5021 +- for (i = 0; i < r->num_transactions; i++)
5022 ++ for (i = 0; i < r->num_transactions; i++) {
5023 ++ tx = &r->transactions[i];
5024 + kfree(tx->bytes);
5025 ++ }
5026 + return -ENOMEM;
5027 + }
5028 +
5029 +diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
5030 +index e34058c721be..16bff1be4b8a 100644
5031 +--- a/drivers/gpu/drm/drm_mipi_dbi.c
5032 ++++ b/drivers/gpu/drm/drm_mipi_dbi.c
5033 +@@ -367,9 +367,9 @@ static void mipi_dbi_blank(struct mipi_dbi_dev *dbidev)
5034 + memset(dbidev->tx_buf, 0, len);
5035 +
5036 + mipi_dbi_command(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, 0, 0,
5037 +- (width >> 8) & 0xFF, (width - 1) & 0xFF);
5038 ++ ((width - 1) >> 8) & 0xFF, (width - 1) & 0xFF);
5039 + mipi_dbi_command(dbi, MIPI_DCS_SET_PAGE_ADDRESS, 0, 0,
5040 +- (height >> 8) & 0xFF, (height - 1) & 0xFF);
5041 ++ ((height - 1) >> 8) & 0xFF, (height - 1) & 0xFF);
5042 + mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START,
5043 + (u8 *)dbidev->tx_buf, len);
5044 +
5045 +diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
5046 +index 218f3bb15276..90237abee088 100644
5047 +--- a/drivers/gpu/drm/gma500/framebuffer.c
5048 ++++ b/drivers/gpu/drm/gma500/framebuffer.c
5049 +@@ -462,6 +462,7 @@ static int psbfb_probe(struct drm_fb_helper *helper,
5050 + container_of(helper, struct psb_fbdev, psb_fb_helper);
5051 + struct drm_device *dev = psb_fbdev->psb_fb_helper.dev;
5052 + struct drm_psb_private *dev_priv = dev->dev_private;
5053 ++ unsigned int fb_size;
5054 + int bytespp;
5055 +
5056 + bytespp = sizes->surface_bpp / 8;
5057 +@@ -471,8 +472,11 @@ static int psbfb_probe(struct drm_fb_helper *helper,
5058 + /* If the mode will not fit in 32bit then switch to 16bit to get
5059 + a console on full resolution. The X mode setting server will
5060 + allocate its own 32bit GEM framebuffer */
5061 +- if (ALIGN(sizes->fb_width * bytespp, 64) * sizes->fb_height >
5062 +- dev_priv->vram_stolen_size) {
5063 ++ fb_size = ALIGN(sizes->surface_width * bytespp, 64) *
5064 ++ sizes->surface_height;
5065 ++ fb_size = ALIGN(fb_size, PAGE_SIZE);
5066 ++
5067 ++ if (fb_size > dev_priv->vram_stolen_size) {
5068 + sizes->surface_bpp = 16;
5069 + sizes->surface_depth = 16;
5070 + }
5071 +diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c
5072 +index ec32e1c67335..43a015f33e97 100644
5073 +--- a/drivers/gpu/drm/ingenic/ingenic-drm.c
5074 ++++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
5075 +@@ -372,14 +372,18 @@ static void ingenic_drm_plane_atomic_update(struct drm_plane *plane,
5076 + struct ingenic_drm *priv = drm_plane_get_priv(plane);
5077 + struct drm_plane_state *state = plane->state;
5078 + unsigned int width, height, cpp;
5079 ++ dma_addr_t addr;
5080 +
5081 +- width = state->crtc->state->adjusted_mode.hdisplay;
5082 +- height = state->crtc->state->adjusted_mode.vdisplay;
5083 +- cpp = state->fb->format->cpp[plane->index];
5084 ++ if (state && state->fb) {
5085 ++ addr = drm_fb_cma_get_gem_addr(state->fb, state, 0);
5086 ++ width = state->crtc->state->adjusted_mode.hdisplay;
5087 ++ height = state->crtc->state->adjusted_mode.vdisplay;
5088 ++ cpp = state->fb->format->cpp[plane->index];
5089 +
5090 +- priv->dma_hwdesc->addr = drm_fb_cma_get_gem_addr(state->fb, state, 0);
5091 +- priv->dma_hwdesc->cmd = width * height * cpp / 4;
5092 +- priv->dma_hwdesc->cmd |= JZ_LCD_CMD_EOF_IRQ;
5093 ++ priv->dma_hwdesc->addr = addr;
5094 ++ priv->dma_hwdesc->cmd = width * height * cpp / 4;
5095 ++ priv->dma_hwdesc->cmd |= JZ_LCD_CMD_EOF_IRQ;
5096 ++ }
5097 + }
5098 +
5099 + static void ingenic_drm_encoder_atomic_mode_set(struct drm_encoder *encoder,
5100 +diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
5101 +index 3305a94fc930..c3f5111fd563 100644
5102 +--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
5103 ++++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
5104 +@@ -328,6 +328,7 @@ err_pm_runtime_put:
5105 + static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc)
5106 + {
5107 + struct drm_device *drm = mtk_crtc->base.dev;
5108 ++ struct drm_crtc *crtc = &mtk_crtc->base;
5109 + int i;
5110 +
5111 + DRM_DEBUG_DRIVER("%s\n", __func__);
5112 +@@ -353,6 +354,13 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc)
5113 + mtk_disp_mutex_unprepare(mtk_crtc->mutex);
5114 +
5115 + pm_runtime_put(drm->dev);
5116 ++
5117 ++ if (crtc->state->event && !crtc->state->active) {
5118 ++ spin_lock_irq(&crtc->dev->event_lock);
5119 ++ drm_crtc_send_vblank_event(crtc, crtc->state->event);
5120 ++ crtc->state->event = NULL;
5121 ++ spin_unlock_irq(&crtc->dev->event_lock);
5122 ++ }
5123 + }
5124 +
5125 + static void mtk_crtc_ddp_config(struct drm_crtc *crtc)
5126 +@@ -633,6 +641,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
5127 + int pipe = priv->num_pipes;
5128 + int ret;
5129 + int i;
5130 ++ uint gamma_lut_size = 0;
5131 +
5132 + if (!path)
5133 + return 0;
5134 +@@ -683,6 +692,9 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
5135 + }
5136 +
5137 + mtk_crtc->ddp_comp[i] = comp;
5138 ++
5139 ++ if (comp->funcs && comp->funcs->gamma_set)
5140 ++ gamma_lut_size = MTK_LUT_SIZE;
5141 + }
5142 +
5143 + for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
5144 +@@ -703,8 +715,10 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
5145 + NULL, pipe);
5146 + if (ret < 0)
5147 + return ret;
5148 +- drm_mode_crtc_set_gamma_size(&mtk_crtc->base, MTK_LUT_SIZE);
5149 +- drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, false, MTK_LUT_SIZE);
5150 ++
5151 ++ if (gamma_lut_size)
5152 ++ drm_mode_crtc_set_gamma_size(&mtk_crtc->base, gamma_lut_size);
5153 ++ drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, false, gamma_lut_size);
5154 + priv->num_pipes++;
5155 +
5156 + return 0;
5157 +diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
5158 +index b02e2042547f..7d9e63e20ded 100644
5159 +--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
5160 ++++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
5161 +@@ -753,11 +753,18 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
5162 + gpu->funcs->flush(gpu, gpu->rb[0]);
5163 + if (!a5xx_idle(gpu, gpu->rb[0]))
5164 + return -EINVAL;
5165 +- } else {
5166 +- /* Print a warning so if we die, we know why */
5167 ++ } else if (ret == -ENODEV) {
5168 ++ /*
5169 ++ * This device does not use zap shader (but print a warning
5170 ++ * just in case someone got their dt wrong.. hopefully they
5171 ++ * have a debug UART to realize the error of their ways...
5172 ++ * if you mess this up you are about to crash horribly)
5173 ++ */
5174 + dev_warn_once(gpu->dev->dev,
5175 + "Zap shader not enabled - using SECVID_TRUST_CNTL instead\n");
5176 + gpu_write(gpu, REG_A5XX_RBBM_SECVID_TRUST_CNTL, 0x0);
5177 ++ } else {
5178 ++ return ret;
5179 + }
5180 +
5181 + /* Last step - yield the ringbuffer */
5182 +diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
5183 +index dc8ec2c94301..686c34d706b0 100644
5184 +--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
5185 ++++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
5186 +@@ -537,12 +537,19 @@ static int a6xx_hw_init(struct msm_gpu *gpu)
5187 + a6xx_flush(gpu, gpu->rb[0]);
5188 + if (!a6xx_idle(gpu, gpu->rb[0]))
5189 + return -EINVAL;
5190 +- } else {
5191 +- /* Print a warning so if we die, we know why */
5192 ++ } else if (ret == -ENODEV) {
5193 ++ /*
5194 ++ * This device does not use zap shader (but print a warning
5195 ++ * just in case someone got their dt wrong.. hopefully they
5196 ++ * have a debug UART to realize the error of their ways...
5197 ++ * if you mess this up you are about to crash horribly)
5198 ++ */
5199 + dev_warn_once(gpu->dev->dev,
5200 + "Zap shader not enabled - using SECVID_TRUST_CNTL instead\n");
5201 + gpu_write(gpu, REG_A6XX_RBBM_SECVID_TRUST_CNTL, 0x0);
5202 + ret = 0;
5203 ++ } else {
5204 ++ return ret;
5205 + }
5206 +
5207 + out:
5208 +diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c
5209 +index fa1439941596..0ad5d87b5a8e 100644
5210 +--- a/drivers/gpu/drm/nouveau/nouveau_dmem.c
5211 ++++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c
5212 +@@ -635,10 +635,10 @@ nouveau_dmem_migrate_vma(struct nouveau_drm *drm,
5213 + unsigned long c, i;
5214 + int ret = -ENOMEM;
5215 +
5216 +- args.src = kcalloc(max, sizeof(args.src), GFP_KERNEL);
5217 ++ args.src = kcalloc(max, sizeof(*args.src), GFP_KERNEL);
5218 + if (!args.src)
5219 + goto out;
5220 +- args.dst = kcalloc(max, sizeof(args.dst), GFP_KERNEL);
5221 ++ args.dst = kcalloc(max, sizeof(*args.dst), GFP_KERNEL);
5222 + if (!args.dst)
5223 + goto out_free_src;
5224 +
5225 +diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
5226 +index 9118df035b28..70bb6bb97af8 100644
5227 +--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
5228 ++++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
5229 +@@ -156,7 +156,7 @@ nouveau_fence_wait_uevent_handler(struct nvif_notify *notify)
5230 +
5231 + fence = list_entry(fctx->pending.next, typeof(*fence), head);
5232 + chan = rcu_dereference_protected(fence->channel, lockdep_is_held(&fctx->lock));
5233 +- if (nouveau_fence_update(fence->channel, fctx))
5234 ++ if (nouveau_fence_update(chan, fctx))
5235 + ret = NVIF_NOTIFY_DROP;
5236 + }
5237 + spin_unlock_irqrestore(&fctx->lock, flags);
5238 +diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
5239 +index 77a0c6ad3cef..7ca0a2498532 100644
5240 +--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
5241 ++++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
5242 +@@ -63,14 +63,12 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
5243 + {
5244 + struct nouveau_bo *nvbo = nouveau_bo(bo);
5245 + struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
5246 +- struct nouveau_mem *mem;
5247 + int ret;
5248 +
5249 + if (drm->client.device.info.ram_size == 0)
5250 + return -ENOMEM;
5251 +
5252 + ret = nouveau_mem_new(&drm->master, nvbo->kind, nvbo->comp, reg);
5253 +- mem = nouveau_mem(reg);
5254 + if (ret)
5255 + return ret;
5256 +
5257 +@@ -103,11 +101,9 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
5258 + {
5259 + struct nouveau_bo *nvbo = nouveau_bo(bo);
5260 + struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
5261 +- struct nouveau_mem *mem;
5262 + int ret;
5263 +
5264 + ret = nouveau_mem_new(&drm->master, nvbo->kind, nvbo->comp, reg);
5265 +- mem = nouveau_mem(reg);
5266 + if (ret)
5267 + return ret;
5268 +
5269 +diff --git a/drivers/gpu/drm/nouveau/nvkm/core/memory.c b/drivers/gpu/drm/nouveau/nvkm/core/memory.c
5270 +index e85a08ecd9da..4cc186262d34 100644
5271 +--- a/drivers/gpu/drm/nouveau/nvkm/core/memory.c
5272 ++++ b/drivers/gpu/drm/nouveau/nvkm/core/memory.c
5273 +@@ -91,8 +91,8 @@ nvkm_memory_tags_get(struct nvkm_memory *memory, struct nvkm_device *device,
5274 + }
5275 +
5276 + refcount_set(&tags->refcount, 1);
5277 ++ *ptags = memory->tags = tags;
5278 + mutex_unlock(&fb->subdev.mutex);
5279 +- *ptags = tags;
5280 + return 0;
5281 + }
5282 +
5283 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
5284 +index bcf32d92ee5a..50e3539f33d2 100644
5285 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
5286 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
5287 +@@ -74,6 +74,8 @@ nv50_disp_chan_mthd(struct nv50_disp_chan *chan, int debug)
5288 +
5289 + if (debug > subdev->debug)
5290 + return;
5291 ++ if (!mthd)
5292 ++ return;
5293 +
5294 + for (i = 0; (list = mthd->data[i].mthd) != NULL; i++) {
5295 + u32 base = chan->head * mthd->addr;
5296 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c
5297 +index 500cb08dd608..b57ab5cea9a1 100644
5298 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c
5299 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c
5300 +@@ -143,23 +143,24 @@ gk20a_gr_av_to_method(struct gf100_gr *gr, const char *fw_name,
5301 +
5302 + nent = (fuc.size / sizeof(struct gk20a_fw_av));
5303 +
5304 +- pack = vzalloc((sizeof(*pack) * max_classes) +
5305 +- (sizeof(*init) * (nent + 1)));
5306 ++ pack = vzalloc((sizeof(*pack) * (max_classes + 1)) +
5307 ++ (sizeof(*init) * (nent + max_classes + 1)));
5308 + if (!pack) {
5309 + ret = -ENOMEM;
5310 + goto end;
5311 + }
5312 +
5313 +- init = (void *)(pack + max_classes);
5314 ++ init = (void *)(pack + max_classes + 1);
5315 +
5316 +- for (i = 0; i < nent; i++) {
5317 +- struct gf100_gr_init *ent = &init[i];
5318 ++ for (i = 0; i < nent; i++, init++) {
5319 + struct gk20a_fw_av *av = &((struct gk20a_fw_av *)fuc.data)[i];
5320 + u32 class = av->addr & 0xffff;
5321 + u32 addr = (av->addr & 0xffff0000) >> 14;
5322 +
5323 + if (prevclass != class) {
5324 +- pack[classidx].init = ent;
5325 ++ if (prevclass) /* Add terminator to the method list. */
5326 ++ init++;
5327 ++ pack[classidx].init = init;
5328 + pack[classidx].type = class;
5329 + prevclass = class;
5330 + if (++classidx >= max_classes) {
5331 +@@ -169,10 +170,10 @@ gk20a_gr_av_to_method(struct gf100_gr *gr, const char *fw_name,
5332 + }
5333 + }
5334 +
5335 +- ent->addr = addr;
5336 +- ent->data = av->data;
5337 +- ent->count = 1;
5338 +- ent->pitch = 1;
5339 ++ init->addr = addr;
5340 ++ init->data = av->data;
5341 ++ init->count = 1;
5342 ++ init->pitch = 1;
5343 + }
5344 +
5345 + *ppack = pack;
5346 +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/base.c
5347 +index ca251560d3e0..bb4a4266897c 100644
5348 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/base.c
5349 ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/base.c
5350 +@@ -146,6 +146,7 @@ nvkm_fault_dtor(struct nvkm_subdev *subdev)
5351 + struct nvkm_fault *fault = nvkm_fault(subdev);
5352 + int i;
5353 +
5354 ++ nvkm_notify_fini(&fault->nrpfb);
5355 + nvkm_event_fini(&fault->event);
5356 +
5357 + for (i = 0; i < fault->buffer_nr; i++) {
5358 +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm20b.c b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm20b.c
5359 +index df8b919dcf09..ace6fefba428 100644
5360 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm20b.c
5361 ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm20b.c
5362 +@@ -108,6 +108,7 @@ gm20b_secboot_new(struct nvkm_device *device, int index,
5363 + struct gm200_secboot *gsb;
5364 + struct nvkm_acr *acr;
5365 +
5366 ++ *psb = NULL;
5367 + acr = acr_r352_new(BIT(NVKM_SECBOOT_FALCON_FECS) |
5368 + BIT(NVKM_SECBOOT_FALCON_PMU));
5369 + if (IS_ERR(acr))
5370 +@@ -116,10 +117,8 @@ gm20b_secboot_new(struct nvkm_device *device, int index,
5371 + acr->optional_falcons = BIT(NVKM_SECBOOT_FALCON_PMU);
5372 +
5373 + gsb = kzalloc(sizeof(*gsb), GFP_KERNEL);
5374 +- if (!gsb) {
5375 +- psb = NULL;
5376 ++ if (!gsb)
5377 + return -ENOMEM;
5378 +- }
5379 + *psb = &gsb->base;
5380 +
5381 + ret = nvkm_secboot_ctor(&gm20b_secboot, acr, device, index, &gsb->base);
5382 +diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
5383 +index 5d487686d25c..72f69709f349 100644
5384 +--- a/drivers/gpu/drm/panel/panel-simple.c
5385 ++++ b/drivers/gpu/drm/panel/panel-simple.c
5386 +@@ -2061,6 +2061,40 @@ static const struct drm_display_mode mitsubishi_aa070mc01_mode = {
5387 + .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
5388 + };
5389 +
5390 ++static const struct drm_display_mode logicpd_type_28_mode = {
5391 ++ .clock = 9000,
5392 ++ .hdisplay = 480,
5393 ++ .hsync_start = 480 + 3,
5394 ++ .hsync_end = 480 + 3 + 42,
5395 ++ .htotal = 480 + 3 + 42 + 2,
5396 ++
5397 ++ .vdisplay = 272,
5398 ++ .vsync_start = 272 + 2,
5399 ++ .vsync_end = 272 + 2 + 11,
5400 ++ .vtotal = 272 + 2 + 11 + 3,
5401 ++ .vrefresh = 60,
5402 ++ .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
5403 ++};
5404 ++
5405 ++static const struct panel_desc logicpd_type_28 = {
5406 ++ .modes = &logicpd_type_28_mode,
5407 ++ .num_modes = 1,
5408 ++ .bpc = 8,
5409 ++ .size = {
5410 ++ .width = 105,
5411 ++ .height = 67,
5412 ++ },
5413 ++ .delay = {
5414 ++ .prepare = 200,
5415 ++ .enable = 200,
5416 ++ .unprepare = 200,
5417 ++ .disable = 200,
5418 ++ },
5419 ++ .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
5420 ++ .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE |
5421 ++ DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE,
5422 ++};
5423 ++
5424 + static const struct panel_desc mitsubishi_aa070mc01 = {
5425 + .modes = &mitsubishi_aa070mc01_mode,
5426 + .num_modes = 1,
5427 +@@ -3287,6 +3321,9 @@ static const struct of_device_id platform_of_match[] = {
5428 + }, {
5429 + .compatible = "lg,lp129qe",
5430 + .data = &lg_lp129qe,
5431 ++ }, {
5432 ++ .compatible = "logicpd,type28",
5433 ++ .data = &logicpd_type_28,
5434 + }, {
5435 + .compatible = "mitsubishi,aa070mc01-ca1",
5436 + .data = &mitsubishi_aa070mc01,
5437 +diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
5438 +index 611cbe7aee69..bfc1631093e9 100644
5439 +--- a/drivers/gpu/drm/qxl/qxl_kms.c
5440 ++++ b/drivers/gpu/drm/qxl/qxl_kms.c
5441 +@@ -184,7 +184,7 @@ int qxl_device_init(struct qxl_device *qdev,
5442 +
5443 + if (!qxl_check_device(qdev)) {
5444 + r = -ENODEV;
5445 +- goto surface_mapping_free;
5446 ++ goto rom_unmap;
5447 + }
5448 +
5449 + r = qxl_bo_init(qdev);
5450 +diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
5451 +index e81b01f8db90..0826efd9b5f5 100644
5452 +--- a/drivers/gpu/drm/radeon/radeon_display.c
5453 ++++ b/drivers/gpu/drm/radeon/radeon_display.c
5454 +@@ -127,6 +127,8 @@ static void dce5_crtc_load_lut(struct drm_crtc *crtc)
5455 +
5456 + DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
5457 +
5458 ++ msleep(10);
5459 ++
5460 + WREG32(NI_INPUT_CSC_CONTROL + radeon_crtc->crtc_offset,
5461 + (NI_INPUT_CSC_GRPH_MODE(NI_INPUT_CSC_BYPASS) |
5462 + NI_INPUT_CSC_OVL_MODE(NI_INPUT_CSC_BYPASS)));
5463 +diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
5464 +index 0d59f390de19..662d8075f411 100644
5465 +--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
5466 ++++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
5467 +@@ -542,6 +542,7 @@ static int rcar_du_properties_init(struct rcar_du_device *rcdu)
5468 + static int rcar_du_vsps_init(struct rcar_du_device *rcdu)
5469 + {
5470 + const struct device_node *np = rcdu->dev->of_node;
5471 ++ const char *vsps_prop_name = "renesas,vsps";
5472 + struct of_phandle_args args;
5473 + struct {
5474 + struct device_node *np;
5475 +@@ -557,15 +558,21 @@ static int rcar_du_vsps_init(struct rcar_du_device *rcdu)
5476 + * entry contains a pointer to the VSP DT node and a bitmask of the
5477 + * connected DU CRTCs.
5478 + */
5479 +- cells = of_property_count_u32_elems(np, "vsps") / rcdu->num_crtcs - 1;
5480 ++ ret = of_property_count_u32_elems(np, vsps_prop_name);
5481 ++ if (ret < 0) {
5482 ++ /* Backward compatibility with old DTBs. */
5483 ++ vsps_prop_name = "vsps";
5484 ++ ret = of_property_count_u32_elems(np, vsps_prop_name);
5485 ++ }
5486 ++ cells = ret / rcdu->num_crtcs - 1;
5487 + if (cells > 1)
5488 + return -EINVAL;
5489 +
5490 + for (i = 0; i < rcdu->num_crtcs; ++i) {
5491 + unsigned int j;
5492 +
5493 +- ret = of_parse_phandle_with_fixed_args(np, "vsps", cells, i,
5494 +- &args);
5495 ++ ret = of_parse_phandle_with_fixed_args(np, vsps_prop_name,
5496 ++ cells, i, &args);
5497 + if (ret < 0)
5498 + goto error;
5499 +
5500 +@@ -587,8 +594,8 @@ static int rcar_du_vsps_init(struct rcar_du_device *rcdu)
5501 +
5502 + /*
5503 + * Store the VSP pointer and pipe index in the CRTC. If the
5504 +- * second cell of the 'vsps' specifier isn't present, default
5505 +- * to 0 to remain compatible with older DT bindings.
5506 ++ * second cell of the 'renesas,vsps' specifier isn't present,
5507 ++ * default to 0 to remain compatible with older DT bindings.
5508 + */
5509 + rcdu->crtcs[i].vsp = &rcdu->vsps[j];
5510 + rcdu->crtcs[i].vsp_pipe = cells >= 1 ? args.args[0] : 0;
5511 +diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
5512 +index 0b56ba005e25..eedae2a7b532 100644
5513 +--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
5514 ++++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
5515 +@@ -38,6 +38,7 @@
5516 + #include <drm/drm_gem_shmem_helper.h>
5517 + #include <drm/drm_ioctl.h>
5518 + #include <drm/drm_probe_helper.h>
5519 ++#include <drm/virtgpu_drm.h>
5520 +
5521 + #define DRIVER_NAME "virtio_gpu"
5522 + #define DRIVER_DESC "virtio GPU"
5523 +@@ -312,13 +313,13 @@ void virtio_gpu_cmd_submit(struct virtio_gpu_device *vgdev,
5524 + void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev,
5525 + uint32_t ctx_id,
5526 + uint64_t offset, uint32_t level,
5527 +- struct virtio_gpu_box *box,
5528 ++ struct drm_virtgpu_3d_box *box,
5529 + struct virtio_gpu_object_array *objs,
5530 + struct virtio_gpu_fence *fence);
5531 + void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
5532 + uint32_t ctx_id,
5533 + uint64_t offset, uint32_t level,
5534 +- struct virtio_gpu_box *box,
5535 ++ struct drm_virtgpu_3d_box *box,
5536 + struct virtio_gpu_object_array *objs,
5537 + struct virtio_gpu_fence *fence);
5538 + void
5539 +diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
5540 +index 9af1ec62434f..205ec4abae2b 100644
5541 +--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
5542 ++++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
5543 +@@ -33,17 +33,6 @@
5544 +
5545 + #include "virtgpu_drv.h"
5546 +
5547 +-static void convert_to_hw_box(struct virtio_gpu_box *dst,
5548 +- const struct drm_virtgpu_3d_box *src)
5549 +-{
5550 +- dst->x = cpu_to_le32(src->x);
5551 +- dst->y = cpu_to_le32(src->y);
5552 +- dst->z = cpu_to_le32(src->z);
5553 +- dst->w = cpu_to_le32(src->w);
5554 +- dst->h = cpu_to_le32(src->h);
5555 +- dst->d = cpu_to_le32(src->d);
5556 +-}
5557 +-
5558 + static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data,
5559 + struct drm_file *file_priv)
5560 + {
5561 +@@ -304,7 +293,6 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,
5562 + struct virtio_gpu_fence *fence;
5563 + int ret;
5564 + u32 offset = args->offset;
5565 +- struct virtio_gpu_box box;
5566 +
5567 + if (vgdev->has_virgl_3d == false)
5568 + return -ENOSYS;
5569 +@@ -317,8 +305,6 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,
5570 + if (ret != 0)
5571 + goto err_put_free;
5572 +
5573 +- convert_to_hw_box(&box, &args->box);
5574 +-
5575 + fence = virtio_gpu_fence_alloc(vgdev);
5576 + if (!fence) {
5577 + ret = -ENOMEM;
5578 +@@ -326,7 +312,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,
5579 + }
5580 + virtio_gpu_cmd_transfer_from_host_3d
5581 + (vgdev, vfpriv->ctx_id, offset, args->level,
5582 +- &box, objs, fence);
5583 ++ &args->box, objs, fence);
5584 + dma_fence_put(&fence->f);
5585 + return 0;
5586 +
5587 +@@ -345,7 +331,6 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
5588 + struct drm_virtgpu_3d_transfer_to_host *args = data;
5589 + struct virtio_gpu_object_array *objs;
5590 + struct virtio_gpu_fence *fence;
5591 +- struct virtio_gpu_box box;
5592 + int ret;
5593 + u32 offset = args->offset;
5594 +
5595 +@@ -353,11 +338,10 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
5596 + if (objs == NULL)
5597 + return -ENOENT;
5598 +
5599 +- convert_to_hw_box(&box, &args->box);
5600 + if (!vgdev->has_virgl_3d) {
5601 + virtio_gpu_cmd_transfer_to_host_2d
5602 + (vgdev, offset,
5603 +- box.w, box.h, box.x, box.y,
5604 ++ args->box.w, args->box.h, args->box.x, args->box.y,
5605 + objs, NULL);
5606 + } else {
5607 + ret = virtio_gpu_array_lock_resv(objs);
5608 +@@ -372,7 +356,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
5609 + virtio_gpu_cmd_transfer_to_host_3d
5610 + (vgdev,
5611 + vfpriv ? vfpriv->ctx_id : 0, offset,
5612 +- args->level, &box, objs, fence);
5613 ++ args->level, &args->box, objs, fence);
5614 + dma_fence_put(&fence->f);
5615 + }
5616 + return 0;
5617 +diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
5618 +index 74ad3bc3ebe8..9274c4063c70 100644
5619 +--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
5620 ++++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
5621 +@@ -40,6 +40,17 @@
5622 + + MAX_INLINE_CMD_SIZE \
5623 + + MAX_INLINE_RESP_SIZE)
5624 +
5625 ++static void convert_to_hw_box(struct virtio_gpu_box *dst,
5626 ++ const struct drm_virtgpu_3d_box *src)
5627 ++{
5628 ++ dst->x = cpu_to_le32(src->x);
5629 ++ dst->y = cpu_to_le32(src->y);
5630 ++ dst->z = cpu_to_le32(src->z);
5631 ++ dst->w = cpu_to_le32(src->w);
5632 ++ dst->h = cpu_to_le32(src->h);
5633 ++ dst->d = cpu_to_le32(src->d);
5634 ++}
5635 ++
5636 + void virtio_gpu_ctrl_ack(struct virtqueue *vq)
5637 + {
5638 + struct drm_device *dev = vq->vdev->priv;
5639 +@@ -965,7 +976,7 @@ virtio_gpu_cmd_resource_create_3d(struct virtio_gpu_device *vgdev,
5640 + void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
5641 + uint32_t ctx_id,
5642 + uint64_t offset, uint32_t level,
5643 +- struct virtio_gpu_box *box,
5644 ++ struct drm_virtgpu_3d_box *box,
5645 + struct virtio_gpu_object_array *objs,
5646 + struct virtio_gpu_fence *fence)
5647 + {
5648 +@@ -987,7 +998,7 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
5649 + cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D);
5650 + cmd_p->hdr.ctx_id = cpu_to_le32(ctx_id);
5651 + cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
5652 +- cmd_p->box = *box;
5653 ++ convert_to_hw_box(&cmd_p->box, box);
5654 + cmd_p->offset = cpu_to_le64(offset);
5655 + cmd_p->level = cpu_to_le32(level);
5656 +
5657 +@@ -997,7 +1008,7 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
5658 + void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev,
5659 + uint32_t ctx_id,
5660 + uint64_t offset, uint32_t level,
5661 +- struct virtio_gpu_box *box,
5662 ++ struct drm_virtgpu_3d_box *box,
5663 + struct virtio_gpu_object_array *objs,
5664 + struct virtio_gpu_fence *fence)
5665 + {
5666 +@@ -1013,7 +1024,7 @@ void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev,
5667 + cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D);
5668 + cmd_p->hdr.ctx_id = cpu_to_le32(ctx_id);
5669 + cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
5670 +- cmd_p->box = *box;
5671 ++ convert_to_hw_box(&cmd_p->box, box);
5672 + cmd_p->offset = cpu_to_le64(offset);
5673 + cmd_p->level = cpu_to_le32(level);
5674 +
5675 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
5676 +index 4ac55fc2bf97..44d858ce4ce7 100644
5677 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
5678 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
5679 +@@ -209,8 +209,10 @@ int vmw_cmdbuf_res_add(struct vmw_cmdbuf_res_manager *man,
5680 +
5681 + cres->hash.key = user_key | (res_type << 24);
5682 + ret = drm_ht_insert_item(&man->resources, &cres->hash);
5683 +- if (unlikely(ret != 0))
5684 ++ if (unlikely(ret != 0)) {
5685 ++ kfree(cres);
5686 + goto out_invalid_key;
5687 ++ }
5688 +
5689 + cres->state = VMW_CMDBUF_RES_ADD;
5690 + cres->res = vmw_resource_reference(res);
5691 +diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c
5692 +index a1898e11b04e..943bf944bf72 100644
5693 +--- a/drivers/ide/cmd64x.c
5694 ++++ b/drivers/ide/cmd64x.c
5695 +@@ -66,6 +66,9 @@ static void cmd64x_program_timings(ide_drive_t *drive, u8 mode)
5696 + struct ide_timing t;
5697 + u8 arttim = 0;
5698 +
5699 ++ if (drive->dn >= ARRAY_SIZE(drwtim_regs))
5700 ++ return;
5701 ++
5702 + ide_timing_compute(drive, mode, &t, T, 0);
5703 +
5704 + /*
5705 +diff --git a/drivers/ide/serverworks.c b/drivers/ide/serverworks.c
5706 +index ac6fc3fffa0d..458e72e034b0 100644
5707 +--- a/drivers/ide/serverworks.c
5708 ++++ b/drivers/ide/serverworks.c
5709 +@@ -115,6 +115,9 @@ static void svwks_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
5710 + struct pci_dev *dev = to_pci_dev(hwif->dev);
5711 + const u8 pio = drive->pio_mode - XFER_PIO_0;
5712 +
5713 ++ if (drive->dn >= ARRAY_SIZE(drive_pci))
5714 ++ return;
5715 ++
5716 + pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]);
5717 +
5718 + if (svwks_csb_check(dev)) {
5719 +@@ -141,6 +144,9 @@ static void svwks_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
5720 +
5721 + u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0;
5722 +
5723 ++ if (drive->dn >= ARRAY_SIZE(drive_pci2))
5724 ++ return;
5725 ++
5726 + pci_read_config_byte(dev, (0x56|hwif->channel), &ultra_timing);
5727 + pci_read_config_byte(dev, 0x54, &ultra_enable);
5728 +
5729 +diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
5730 +index b921dd9e108f..e45123d8d281 100644
5731 +--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
5732 ++++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
5733 +@@ -1506,8 +1506,11 @@ static int st_lsm6dsx_read_oneshot(struct st_lsm6dsx_sensor *sensor,
5734 + if (err < 0)
5735 + return err;
5736 +
5737 +- if (!hw->enable_event)
5738 +- st_lsm6dsx_sensor_set_enable(sensor, false);
5739 ++ if (!hw->enable_event) {
5740 ++ err = st_lsm6dsx_sensor_set_enable(sensor, false);
5741 ++ if (err < 0)
5742 ++ return err;
5743 ++ }
5744 +
5745 + *val = (s16)le16_to_cpu(data);
5746 +
5747 +diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
5748 +index d535995711c3..e55f345799e4 100644
5749 +--- a/drivers/infiniband/core/cache.c
5750 ++++ b/drivers/infiniband/core/cache.c
5751 +@@ -51,9 +51,8 @@ struct ib_pkey_cache {
5752 +
5753 + struct ib_update_work {
5754 + struct work_struct work;
5755 +- struct ib_device *device;
5756 +- u8 port_num;
5757 +- bool enforce_security;
5758 ++ struct ib_event event;
5759 ++ bool enforce_security;
5760 + };
5761 +
5762 + union ib_gid zgid;
5763 +@@ -130,7 +129,7 @@ static void dispatch_gid_change_event(struct ib_device *ib_dev, u8 port)
5764 + event.element.port_num = port;
5765 + event.event = IB_EVENT_GID_CHANGE;
5766 +
5767 +- ib_dispatch_event(&event);
5768 ++ ib_dispatch_event_clients(&event);
5769 + }
5770 +
5771 + static const char * const gid_type_str[] = {
5772 +@@ -1381,9 +1380,8 @@ err:
5773 + return ret;
5774 + }
5775 +
5776 +-static void ib_cache_update(struct ib_device *device,
5777 +- u8 port,
5778 +- bool enforce_security)
5779 ++static int
5780 ++ib_cache_update(struct ib_device *device, u8 port, bool enforce_security)
5781 + {
5782 + struct ib_port_attr *tprops = NULL;
5783 + struct ib_pkey_cache *pkey_cache = NULL, *old_pkey_cache;
5784 +@@ -1391,11 +1389,11 @@ static void ib_cache_update(struct ib_device *device,
5785 + int ret;
5786 +
5787 + if (!rdma_is_port_valid(device, port))
5788 +- return;
5789 ++ return -EINVAL;
5790 +
5791 + tprops = kmalloc(sizeof *tprops, GFP_KERNEL);
5792 + if (!tprops)
5793 +- return;
5794 ++ return -ENOMEM;
5795 +
5796 + ret = ib_query_port(device, port, tprops);
5797 + if (ret) {
5798 +@@ -1413,8 +1411,10 @@ static void ib_cache_update(struct ib_device *device,
5799 + pkey_cache = kmalloc(struct_size(pkey_cache, table,
5800 + tprops->pkey_tbl_len),
5801 + GFP_KERNEL);
5802 +- if (!pkey_cache)
5803 ++ if (!pkey_cache) {
5804 ++ ret = -ENOMEM;
5805 + goto err;
5806 ++ }
5807 +
5808 + pkey_cache->table_len = tprops->pkey_tbl_len;
5809 +
5810 +@@ -1446,50 +1446,84 @@ static void ib_cache_update(struct ib_device *device,
5811 +
5812 + kfree(old_pkey_cache);
5813 + kfree(tprops);
5814 +- return;
5815 ++ return 0;
5816 +
5817 + err:
5818 + kfree(pkey_cache);
5819 + kfree(tprops);
5820 ++ return ret;
5821 ++}
5822 ++
5823 ++static void ib_cache_event_task(struct work_struct *_work)
5824 ++{
5825 ++ struct ib_update_work *work =
5826 ++ container_of(_work, struct ib_update_work, work);
5827 ++ int ret;
5828 ++
5829 ++ /* Before distributing the cache update event, first sync
5830 ++ * the cache.
5831 ++ */
5832 ++ ret = ib_cache_update(work->event.device, work->event.element.port_num,
5833 ++ work->enforce_security);
5834 ++
5835 ++ /* GID event is notified already for individual GID entries by
5836 ++ * dispatch_gid_change_event(). Hence, notifiy for rest of the
5837 ++ * events.
5838 ++ */
5839 ++ if (!ret && work->event.event != IB_EVENT_GID_CHANGE)
5840 ++ ib_dispatch_event_clients(&work->event);
5841 ++
5842 ++ kfree(work);
5843 + }
5844 +
5845 +-static void ib_cache_task(struct work_struct *_work)
5846 ++static void ib_generic_event_task(struct work_struct *_work)
5847 + {
5848 + struct ib_update_work *work =
5849 + container_of(_work, struct ib_update_work, work);
5850 +
5851 +- ib_cache_update(work->device,
5852 +- work->port_num,
5853 +- work->enforce_security);
5854 ++ ib_dispatch_event_clients(&work->event);
5855 + kfree(work);
5856 + }
5857 +
5858 +-static void ib_cache_event(struct ib_event_handler *handler,
5859 +- struct ib_event *event)
5860 ++static bool is_cache_update_event(const struct ib_event *event)
5861 ++{
5862 ++ return (event->event == IB_EVENT_PORT_ERR ||
5863 ++ event->event == IB_EVENT_PORT_ACTIVE ||
5864 ++ event->event == IB_EVENT_LID_CHANGE ||
5865 ++ event->event == IB_EVENT_PKEY_CHANGE ||
5866 ++ event->event == IB_EVENT_CLIENT_REREGISTER ||
5867 ++ event->event == IB_EVENT_GID_CHANGE);
5868 ++}
5869 ++
5870 ++/**
5871 ++ * ib_dispatch_event - Dispatch an asynchronous event
5872 ++ * @event:Event to dispatch
5873 ++ *
5874 ++ * Low-level drivers must call ib_dispatch_event() to dispatch the
5875 ++ * event to all registered event handlers when an asynchronous event
5876 ++ * occurs.
5877 ++ */
5878 ++void ib_dispatch_event(const struct ib_event *event)
5879 + {
5880 + struct ib_update_work *work;
5881 +
5882 +- if (event->event == IB_EVENT_PORT_ERR ||
5883 +- event->event == IB_EVENT_PORT_ACTIVE ||
5884 +- event->event == IB_EVENT_LID_CHANGE ||
5885 +- event->event == IB_EVENT_PKEY_CHANGE ||
5886 +- event->event == IB_EVENT_CLIENT_REREGISTER ||
5887 +- event->event == IB_EVENT_GID_CHANGE) {
5888 +- work = kmalloc(sizeof *work, GFP_ATOMIC);
5889 +- if (work) {
5890 +- INIT_WORK(&work->work, ib_cache_task);
5891 +- work->device = event->device;
5892 +- work->port_num = event->element.port_num;
5893 +- if (event->event == IB_EVENT_PKEY_CHANGE ||
5894 +- event->event == IB_EVENT_GID_CHANGE)
5895 +- work->enforce_security = true;
5896 +- else
5897 +- work->enforce_security = false;
5898 +-
5899 +- queue_work(ib_wq, &work->work);
5900 +- }
5901 +- }
5902 ++ work = kzalloc(sizeof(*work), GFP_ATOMIC);
5903 ++ if (!work)
5904 ++ return;
5905 ++
5906 ++ if (is_cache_update_event(event))
5907 ++ INIT_WORK(&work->work, ib_cache_event_task);
5908 ++ else
5909 ++ INIT_WORK(&work->work, ib_generic_event_task);
5910 ++
5911 ++ work->event = *event;
5912 ++ if (event->event == IB_EVENT_PKEY_CHANGE ||
5913 ++ event->event == IB_EVENT_GID_CHANGE)
5914 ++ work->enforce_security = true;
5915 ++
5916 ++ queue_work(ib_wq, &work->work);
5917 + }
5918 ++EXPORT_SYMBOL(ib_dispatch_event);
5919 +
5920 + int ib_cache_setup_one(struct ib_device *device)
5921 + {
5922 +@@ -1505,9 +1539,6 @@ int ib_cache_setup_one(struct ib_device *device)
5923 + rdma_for_each_port (device, p)
5924 + ib_cache_update(device, p, true);
5925 +
5926 +- INIT_IB_EVENT_HANDLER(&device->cache.event_handler,
5927 +- device, ib_cache_event);
5928 +- ib_register_event_handler(&device->cache.event_handler);
5929 + return 0;
5930 + }
5931 +
5932 +@@ -1529,14 +1560,12 @@ void ib_cache_release_one(struct ib_device *device)
5933 +
5934 + void ib_cache_cleanup_one(struct ib_device *device)
5935 + {
5936 +- /* The cleanup function unregisters the event handler,
5937 +- * waits for all in-progress workqueue elements and cleans
5938 +- * up the GID cache. This function should be called after
5939 +- * the device was removed from the devices list and all
5940 +- * clients were removed, so the cache exists but is
5941 ++ /* The cleanup function waits for all in-progress workqueue
5942 ++ * elements and cleans up the GID cache. This function should be
5943 ++ * called after the device was removed from the devices list and
5944 ++ * all clients were removed, so the cache exists but is
5945 + * non-functional and shouldn't be updated anymore.
5946 + */
5947 +- ib_unregister_event_handler(&device->cache.event_handler);
5948 + flush_workqueue(ib_wq);
5949 + gid_table_cleanup_one(device);
5950 +
5951 +diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h
5952 +index 3645e092e1c7..d657d90e618b 100644
5953 +--- a/drivers/infiniband/core/core_priv.h
5954 ++++ b/drivers/infiniband/core/core_priv.h
5955 +@@ -149,6 +149,7 @@ unsigned long roce_gid_type_mask_support(struct ib_device *ib_dev, u8 port);
5956 + int ib_cache_setup_one(struct ib_device *device);
5957 + void ib_cache_cleanup_one(struct ib_device *device);
5958 + void ib_cache_release_one(struct ib_device *device);
5959 ++void ib_dispatch_event_clients(struct ib_event *event);
5960 +
5961 + #ifdef CONFIG_CGROUP_RDMA
5962 + void ib_device_register_rdmacg(struct ib_device *device);
5963 +diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
5964 +index 84dd74fe13b8..c38b2b0b078a 100644
5965 +--- a/drivers/infiniband/core/device.c
5966 ++++ b/drivers/infiniband/core/device.c
5967 +@@ -588,6 +588,7 @@ struct ib_device *_ib_alloc_device(size_t size)
5968 +
5969 + INIT_LIST_HEAD(&device->event_handler_list);
5970 + spin_lock_init(&device->event_handler_lock);
5971 ++ init_rwsem(&device->event_handler_rwsem);
5972 + mutex_init(&device->unregistration_lock);
5973 + /*
5974 + * client_data needs to be alloc because we don't want our mark to be
5975 +@@ -1931,17 +1932,15 @@ EXPORT_SYMBOL(ib_set_client_data);
5976 + *
5977 + * ib_register_event_handler() registers an event handler that will be
5978 + * called back when asynchronous IB events occur (as defined in
5979 +- * chapter 11 of the InfiniBand Architecture Specification). This
5980 +- * callback may occur in interrupt context.
5981 ++ * chapter 11 of the InfiniBand Architecture Specification). This
5982 ++ * callback occurs in workqueue context.
5983 + */
5984 + void ib_register_event_handler(struct ib_event_handler *event_handler)
5985 + {
5986 +- unsigned long flags;
5987 +-
5988 +- spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);
5989 ++ down_write(&event_handler->device->event_handler_rwsem);
5990 + list_add_tail(&event_handler->list,
5991 + &event_handler->device->event_handler_list);
5992 +- spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);
5993 ++ up_write(&event_handler->device->event_handler_rwsem);
5994 + }
5995 + EXPORT_SYMBOL(ib_register_event_handler);
5996 +
5997 +@@ -1954,35 +1953,23 @@ EXPORT_SYMBOL(ib_register_event_handler);
5998 + */
5999 + void ib_unregister_event_handler(struct ib_event_handler *event_handler)
6000 + {
6001 +- unsigned long flags;
6002 +-
6003 +- spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);
6004 ++ down_write(&event_handler->device->event_handler_rwsem);
6005 + list_del(&event_handler->list);
6006 +- spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);
6007 ++ up_write(&event_handler->device->event_handler_rwsem);
6008 + }
6009 + EXPORT_SYMBOL(ib_unregister_event_handler);
6010 +
6011 +-/**
6012 +- * ib_dispatch_event - Dispatch an asynchronous event
6013 +- * @event:Event to dispatch
6014 +- *
6015 +- * Low-level drivers must call ib_dispatch_event() to dispatch the
6016 +- * event to all registered event handlers when an asynchronous event
6017 +- * occurs.
6018 +- */
6019 +-void ib_dispatch_event(struct ib_event *event)
6020 ++void ib_dispatch_event_clients(struct ib_event *event)
6021 + {
6022 +- unsigned long flags;
6023 + struct ib_event_handler *handler;
6024 +
6025 +- spin_lock_irqsave(&event->device->event_handler_lock, flags);
6026 ++ down_read(&event->device->event_handler_rwsem);
6027 +
6028 + list_for_each_entry(handler, &event->device->event_handler_list, list)
6029 + handler->handler(handler, event);
6030 +
6031 +- spin_unlock_irqrestore(&event->device->event_handler_lock, flags);
6032 ++ up_read(&event->device->event_handler_rwsem);
6033 + }
6034 +-EXPORT_SYMBOL(ib_dispatch_event);
6035 +
6036 + static int iw_query_port(struct ib_device *device,
6037 + u8 port_num,
6038 +diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c
6039 +index 9b1fb84a3d45..10924f122072 100644
6040 +--- a/drivers/infiniband/hw/hfi1/chip.c
6041 ++++ b/drivers/infiniband/hw/hfi1/chip.c
6042 +@@ -1685,6 +1685,14 @@ static u64 access_sw_pio_drain(const struct cntr_entry *entry,
6043 + return dd->verbs_dev.n_piodrain;
6044 + }
6045 +
6046 ++static u64 access_sw_ctx0_seq_drop(const struct cntr_entry *entry,
6047 ++ void *context, int vl, int mode, u64 data)
6048 ++{
6049 ++ struct hfi1_devdata *dd = context;
6050 ++
6051 ++ return dd->ctx0_seq_drop;
6052 ++}
6053 ++
6054 + static u64 access_sw_vtx_wait(const struct cntr_entry *entry,
6055 + void *context, int vl, int mode, u64 data)
6056 + {
6057 +@@ -4106,6 +4114,7 @@ def_access_ibp_counter(rc_crwaits);
6058 + static struct cntr_entry dev_cntrs[DEV_CNTR_LAST] = {
6059 + [C_RCV_OVF] = RXE32_DEV_CNTR_ELEM(RcvOverflow, RCV_BUF_OVFL_CNT, CNTR_SYNTH),
6060 + [C_RX_LEN_ERR] = RXE32_DEV_CNTR_ELEM(RxLenErr, RCV_LENGTH_ERR_CNT, CNTR_SYNTH),
6061 ++[C_RX_SHORT_ERR] = RXE32_DEV_CNTR_ELEM(RxShrErr, RCV_SHORT_ERR_CNT, CNTR_SYNTH),
6062 + [C_RX_ICRC_ERR] = RXE32_DEV_CNTR_ELEM(RxICrcErr, RCV_ICRC_ERR_CNT, CNTR_SYNTH),
6063 + [C_RX_EBP] = RXE32_DEV_CNTR_ELEM(RxEbpCnt, RCV_EBP_CNT, CNTR_SYNTH),
6064 + [C_RX_TID_FULL] = RXE32_DEV_CNTR_ELEM(RxTIDFullEr, RCV_TID_FULL_ERR_CNT,
6065 +@@ -4249,6 +4258,8 @@ static struct cntr_entry dev_cntrs[DEV_CNTR_LAST] = {
6066 + access_sw_cpu_intr),
6067 + [C_SW_CPU_RCV_LIM] = CNTR_ELEM("RcvLimit", 0, 0, CNTR_NORMAL,
6068 + access_sw_cpu_rcv_limit),
6069 ++[C_SW_CTX0_SEQ_DROP] = CNTR_ELEM("SeqDrop0", 0, 0, CNTR_NORMAL,
6070 ++ access_sw_ctx0_seq_drop),
6071 + [C_SW_VTX_WAIT] = CNTR_ELEM("vTxWait", 0, 0, CNTR_NORMAL,
6072 + access_sw_vtx_wait),
6073 + [C_SW_PIO_WAIT] = CNTR_ELEM("PioWait", 0, 0, CNTR_NORMAL,
6074 +diff --git a/drivers/infiniband/hw/hfi1/chip.h b/drivers/infiniband/hw/hfi1/chip.h
6075 +index 4ca5ac8d7e9e..af0061936c66 100644
6076 +--- a/drivers/infiniband/hw/hfi1/chip.h
6077 ++++ b/drivers/infiniband/hw/hfi1/chip.h
6078 +@@ -859,6 +859,7 @@ static inline int idx_from_vl(int vl)
6079 + enum {
6080 + C_RCV_OVF = 0,
6081 + C_RX_LEN_ERR,
6082 ++ C_RX_SHORT_ERR,
6083 + C_RX_ICRC_ERR,
6084 + C_RX_EBP,
6085 + C_RX_TID_FULL,
6086 +@@ -926,6 +927,7 @@ enum {
6087 + C_DC_PG_STS_TX_MBE_CNT,
6088 + C_SW_CPU_INTR,
6089 + C_SW_CPU_RCV_LIM,
6090 ++ C_SW_CTX0_SEQ_DROP,
6091 + C_SW_VTX_WAIT,
6092 + C_SW_PIO_WAIT,
6093 + C_SW_PIO_DRAIN,
6094 +diff --git a/drivers/infiniband/hw/hfi1/chip_registers.h b/drivers/infiniband/hw/hfi1/chip_registers.h
6095 +index ab3589d17aee..fb3ec9bff7a2 100644
6096 +--- a/drivers/infiniband/hw/hfi1/chip_registers.h
6097 ++++ b/drivers/infiniband/hw/hfi1/chip_registers.h
6098 +@@ -381,6 +381,7 @@
6099 + #define DC_LCB_STS_LINK_TRANSFER_ACTIVE (DC_LCB_CSRS + 0x000000000468)
6100 + #define DC_LCB_STS_ROUND_TRIP_LTP_CNT (DC_LCB_CSRS + 0x0000000004B0)
6101 + #define RCV_LENGTH_ERR_CNT 0
6102 ++#define RCV_SHORT_ERR_CNT 2
6103 + #define RCV_ICRC_ERR_CNT 6
6104 + #define RCV_EBP_CNT 9
6105 + #define RCV_BUF_OVFL_CNT 10
6106 +diff --git a/drivers/infiniband/hw/hfi1/driver.c b/drivers/infiniband/hw/hfi1/driver.c
6107 +index 01aa1f132f55..941b465244ab 100644
6108 +--- a/drivers/infiniband/hw/hfi1/driver.c
6109 ++++ b/drivers/infiniband/hw/hfi1/driver.c
6110 +@@ -734,6 +734,7 @@ static noinline int skip_rcv_packet(struct hfi1_packet *packet, int thread)
6111 + {
6112 + int ret;
6113 +
6114 ++ packet->rcd->dd->ctx0_seq_drop++;
6115 + /* Set up for the next packet */
6116 + packet->rhqoff += packet->rsize;
6117 + if (packet->rhqoff >= packet->maxcnt)
6118 +diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h
6119 +index 27dea5e1e201..9edfd3e56f61 100644
6120 +--- a/drivers/infiniband/hw/hfi1/hfi.h
6121 ++++ b/drivers/infiniband/hw/hfi1/hfi.h
6122 +@@ -1153,6 +1153,8 @@ struct hfi1_devdata {
6123 +
6124 + char *boardname; /* human readable board info */
6125 +
6126 ++ u64 ctx0_seq_drop;
6127 ++
6128 + /* reset value */
6129 + u64 z_int_counter;
6130 + u64 z_rcv_limit;
6131 +diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
6132 +index 9ad19170c3f9..95765560c1cf 100644
6133 +--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
6134 ++++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
6135 +@@ -1064,8 +1064,8 @@ int hns_roce_ib_umem_write_mtt(struct hns_roce_dev *hr_dev,
6136 + if (!(npage % (1 << (mtt->page_shift - PAGE_SHIFT)))) {
6137 + if (page_addr & ((1 << mtt->page_shift) - 1)) {
6138 + dev_err(dev,
6139 +- "page_addr 0x%llx is not page_shift %d alignment!\n",
6140 +- page_addr, mtt->page_shift);
6141 ++ "page_addr is not page_shift %d alignment!\n",
6142 ++ mtt->page_shift);
6143 + ret = -EINVAL;
6144 + goto out;
6145 + }
6146 +diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
6147 +index 997cbfe4b90c..760630c7aae7 100644
6148 +--- a/drivers/infiniband/hw/mlx5/main.c
6149 ++++ b/drivers/infiniband/hw/mlx5/main.c
6150 +@@ -815,6 +815,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6151 + struct ib_device_attr *props,
6152 + struct ib_udata *uhw)
6153 + {
6154 ++ size_t uhw_outlen = (uhw) ? uhw->outlen : 0;
6155 + struct mlx5_ib_dev *dev = to_mdev(ibdev);
6156 + struct mlx5_core_dev *mdev = dev->mdev;
6157 + int err = -ENOMEM;
6158 +@@ -828,12 +829,12 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6159 + u64 max_tso;
6160 +
6161 + resp_len = sizeof(resp.comp_mask) + sizeof(resp.response_length);
6162 +- if (uhw->outlen && uhw->outlen < resp_len)
6163 ++ if (uhw_outlen && uhw_outlen < resp_len)
6164 + return -EINVAL;
6165 +
6166 + resp.response_length = resp_len;
6167 +
6168 +- if (uhw->inlen && !ib_is_udata_cleared(uhw, 0, uhw->inlen))
6169 ++ if (uhw && uhw->inlen && !ib_is_udata_cleared(uhw, 0, uhw->inlen))
6170 + return -EINVAL;
6171 +
6172 + memset(props, 0, sizeof(*props));
6173 +@@ -897,7 +898,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6174 + props->raw_packet_caps |=
6175 + IB_RAW_PACKET_CAP_CVLAN_STRIPPING;
6176 +
6177 +- if (field_avail(typeof(resp), tso_caps, uhw->outlen)) {
6178 ++ if (field_avail(typeof(resp), tso_caps, uhw_outlen)) {
6179 + max_tso = MLX5_CAP_ETH(mdev, max_lso_cap);
6180 + if (max_tso) {
6181 + resp.tso_caps.max_tso = 1 << max_tso;
6182 +@@ -907,7 +908,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6183 + }
6184 + }
6185 +
6186 +- if (field_avail(typeof(resp), rss_caps, uhw->outlen)) {
6187 ++ if (field_avail(typeof(resp), rss_caps, uhw_outlen)) {
6188 + resp.rss_caps.rx_hash_function =
6189 + MLX5_RX_HASH_FUNC_TOEPLITZ;
6190 + resp.rss_caps.rx_hash_fields_mask =
6191 +@@ -927,9 +928,9 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6192 + resp.response_length += sizeof(resp.rss_caps);
6193 + }
6194 + } else {
6195 +- if (field_avail(typeof(resp), tso_caps, uhw->outlen))
6196 ++ if (field_avail(typeof(resp), tso_caps, uhw_outlen))
6197 + resp.response_length += sizeof(resp.tso_caps);
6198 +- if (field_avail(typeof(resp), rss_caps, uhw->outlen))
6199 ++ if (field_avail(typeof(resp), rss_caps, uhw_outlen))
6200 + resp.response_length += sizeof(resp.rss_caps);
6201 + }
6202 +
6203 +@@ -1054,7 +1055,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6204 + MLX5_MAX_CQ_PERIOD;
6205 + }
6206 +
6207 +- if (field_avail(typeof(resp), cqe_comp_caps, uhw->outlen)) {
6208 ++ if (field_avail(typeof(resp), cqe_comp_caps, uhw_outlen)) {
6209 + resp.response_length += sizeof(resp.cqe_comp_caps);
6210 +
6211 + if (MLX5_CAP_GEN(dev->mdev, cqe_compression)) {
6212 +@@ -1072,7 +1073,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6213 + }
6214 + }
6215 +
6216 +- if (field_avail(typeof(resp), packet_pacing_caps, uhw->outlen) &&
6217 ++ if (field_avail(typeof(resp), packet_pacing_caps, uhw_outlen) &&
6218 + raw_support) {
6219 + if (MLX5_CAP_QOS(mdev, packet_pacing) &&
6220 + MLX5_CAP_GEN(mdev, qos)) {
6221 +@@ -1091,7 +1092,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6222 + }
6223 +
6224 + if (field_avail(typeof(resp), mlx5_ib_support_multi_pkt_send_wqes,
6225 +- uhw->outlen)) {
6226 ++ uhw_outlen)) {
6227 + if (MLX5_CAP_ETH(mdev, multi_pkt_send_wqe))
6228 + resp.mlx5_ib_support_multi_pkt_send_wqes =
6229 + MLX5_IB_ALLOW_MPW;
6230 +@@ -1104,7 +1105,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6231 + sizeof(resp.mlx5_ib_support_multi_pkt_send_wqes);
6232 + }
6233 +
6234 +- if (field_avail(typeof(resp), flags, uhw->outlen)) {
6235 ++ if (field_avail(typeof(resp), flags, uhw_outlen)) {
6236 + resp.response_length += sizeof(resp.flags);
6237 +
6238 + if (MLX5_CAP_GEN(mdev, cqe_compression_128))
6239 +@@ -1120,8 +1121,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6240 + resp.flags |= MLX5_IB_QUERY_DEV_RESP_FLAGS_SCAT2CQE_DCT;
6241 + }
6242 +
6243 +- if (field_avail(typeof(resp), sw_parsing_caps,
6244 +- uhw->outlen)) {
6245 ++ if (field_avail(typeof(resp), sw_parsing_caps, uhw_outlen)) {
6246 + resp.response_length += sizeof(resp.sw_parsing_caps);
6247 + if (MLX5_CAP_ETH(mdev, swp)) {
6248 + resp.sw_parsing_caps.sw_parsing_offloads |=
6249 +@@ -1141,7 +1141,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6250 + }
6251 + }
6252 +
6253 +- if (field_avail(typeof(resp), striding_rq_caps, uhw->outlen) &&
6254 ++ if (field_avail(typeof(resp), striding_rq_caps, uhw_outlen) &&
6255 + raw_support) {
6256 + resp.response_length += sizeof(resp.striding_rq_caps);
6257 + if (MLX5_CAP_GEN(mdev, striding_rq)) {
6258 +@@ -1164,8 +1164,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6259 + }
6260 + }
6261 +
6262 +- if (field_avail(typeof(resp), tunnel_offloads_caps,
6263 +- uhw->outlen)) {
6264 ++ if (field_avail(typeof(resp), tunnel_offloads_caps, uhw_outlen)) {
6265 + resp.response_length += sizeof(resp.tunnel_offloads_caps);
6266 + if (MLX5_CAP_ETH(mdev, tunnel_stateless_vxlan))
6267 + resp.tunnel_offloads_caps |=
6268 +@@ -1186,7 +1185,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6269 + MLX5_IB_TUNNELED_OFFLOADS_MPLS_UDP;
6270 + }
6271 +
6272 +- if (uhw->outlen) {
6273 ++ if (uhw_outlen) {
6274 + err = ib_copy_to_udata(uhw, &resp, resp.response_length);
6275 +
6276 + if (err)
6277 +@@ -4771,7 +4770,6 @@ static int __get_port_caps(struct mlx5_ib_dev *dev, u8 port)
6278 + struct ib_device_attr *dprops = NULL;
6279 + struct ib_port_attr *pprops = NULL;
6280 + int err = -ENOMEM;
6281 +- struct ib_udata uhw = {.inlen = 0, .outlen = 0};
6282 +
6283 + pprops = kzalloc(sizeof(*pprops), GFP_KERNEL);
6284 + if (!pprops)
6285 +@@ -4781,7 +4779,7 @@ static int __get_port_caps(struct mlx5_ib_dev *dev, u8 port)
6286 + if (!dprops)
6287 + goto out;
6288 +
6289 +- err = mlx5_ib_query_device(&dev->ib_dev, dprops, &uhw);
6290 ++ err = mlx5_ib_query_device(&dev->ib_dev, dprops, NULL);
6291 + if (err) {
6292 + mlx5_ib_warn(dev, "query_device failed %d\n", err);
6293 + goto out;
6294 +diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h
6295 +index 95834206c80c..92de39c4a7c1 100644
6296 +--- a/drivers/infiniband/sw/rxe/rxe_verbs.h
6297 ++++ b/drivers/infiniband/sw/rxe/rxe_verbs.h
6298 +@@ -408,7 +408,7 @@ struct rxe_dev {
6299 + struct list_head pending_mmaps;
6300 +
6301 + spinlock_t mmap_offset_lock; /* guard mmap_offset */
6302 +- int mmap_offset;
6303 ++ u64 mmap_offset;
6304 +
6305 + atomic64_t stats_counters[RXE_NUM_OF_COUNTERS];
6306 +
6307 +diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
6308 +index d61731c0037d..b87b1e074f62 100644
6309 +--- a/drivers/input/touchscreen/edt-ft5x06.c
6310 ++++ b/drivers/input/touchscreen/edt-ft5x06.c
6311 +@@ -1050,6 +1050,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
6312 + {
6313 + const struct edt_i2c_chip_data *chip_data;
6314 + struct edt_ft5x06_ts_data *tsdata;
6315 ++ u8 buf[2] = { 0xfc, 0x00 };
6316 + struct input_dev *input;
6317 + unsigned long irq_flags;
6318 + int error;
6319 +@@ -1140,6 +1141,12 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
6320 + return error;
6321 + }
6322 +
6323 ++ /*
6324 ++ * Dummy read access. EP0700MLP1 returns bogus data on the first
6325 ++ * register read access and ignores writes.
6326 ++ */
6327 ++ edt_ft5x06_ts_readwrite(tsdata->client, 2, buf, 2, buf);
6328 ++
6329 + edt_ft5x06_ts_set_regs(tsdata);
6330 + edt_ft5x06_ts_get_defaults(&client->dev, tsdata);
6331 + edt_ft5x06_ts_get_parameters(tsdata);
6332 +diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
6333 +index bd25674ee4db..7a6c056b9b9c 100644
6334 +--- a/drivers/iommu/amd_iommu.c
6335 ++++ b/drivers/iommu/amd_iommu.c
6336 +@@ -230,11 +230,8 @@ static struct pci_dev *setup_aliases(struct device *dev)
6337 + */
6338 + ivrs_alias = amd_iommu_alias_table[pci_dev_id(pdev)];
6339 + if (ivrs_alias != pci_dev_id(pdev) &&
6340 +- PCI_BUS_NUM(ivrs_alias) == pdev->bus->number) {
6341 +- pci_add_dma_alias(pdev, ivrs_alias & 0xff);
6342 +- pci_info(pdev, "Added PCI DMA alias %02x.%d\n",
6343 +- PCI_SLOT(ivrs_alias), PCI_FUNC(ivrs_alias));
6344 +- }
6345 ++ PCI_BUS_NUM(ivrs_alias) == pdev->bus->number)
6346 ++ pci_add_dma_alias(pdev, ivrs_alias & 0xff, 1);
6347 +
6348 + clone_aliases(pdev);
6349 +
6350 +diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
6351 +index 483f7bc379fa..d7cbca8bf2cd 100644
6352 +--- a/drivers/iommu/amd_iommu_init.c
6353 ++++ b/drivers/iommu/amd_iommu_init.c
6354 +@@ -147,7 +147,7 @@ bool amd_iommu_dump;
6355 + bool amd_iommu_irq_remap __read_mostly;
6356 +
6357 + int amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_VAPIC;
6358 +-static int amd_iommu_xt_mode = IRQ_REMAP_X2APIC_MODE;
6359 ++static int amd_iommu_xt_mode = IRQ_REMAP_XAPIC_MODE;
6360 +
6361 + static bool amd_iommu_detected;
6362 + static bool __initdata amd_iommu_disabled;
6363 +@@ -1523,8 +1523,6 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
6364 + iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET;
6365 + if (((h->efr_attr & (0x1 << IOMMU_FEAT_GASUP_SHIFT)) == 0))
6366 + amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY;
6367 +- if (((h->efr_attr & (0x1 << IOMMU_FEAT_XTSUP_SHIFT)) == 0))
6368 +- amd_iommu_xt_mode = IRQ_REMAP_XAPIC_MODE;
6369 + break;
6370 + case 0x11:
6371 + case 0x40:
6372 +@@ -1534,8 +1532,15 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
6373 + iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET;
6374 + if (((h->efr_reg & (0x1 << IOMMU_EFR_GASUP_SHIFT)) == 0))
6375 + amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY;
6376 +- if (((h->efr_reg & (0x1 << IOMMU_EFR_XTSUP_SHIFT)) == 0))
6377 +- amd_iommu_xt_mode = IRQ_REMAP_XAPIC_MODE;
6378 ++ /*
6379 ++ * Note: Since iommu_update_intcapxt() leverages
6380 ++ * the IOMMU MMIO access to MSI capability block registers
6381 ++ * for MSI address lo/hi/data, we need to check both
6382 ++ * EFR[XtSup] and EFR[MsiCapMmioSup] for x2APIC support.
6383 ++ */
6384 ++ if ((h->efr_reg & BIT(IOMMU_EFR_XTSUP_SHIFT)) &&
6385 ++ (h->efr_reg & BIT(IOMMU_EFR_MSICAPMMIOSUP_SHIFT)))
6386 ++ amd_iommu_xt_mode = IRQ_REMAP_X2APIC_MODE;
6387 + break;
6388 + default:
6389 + return -EINVAL;
6390 +@@ -1996,8 +2001,8 @@ static int iommu_init_intcapxt(struct amd_iommu *iommu)
6391 + struct irq_affinity_notify *notify = &iommu->intcapxt_notify;
6392 +
6393 + /**
6394 +- * IntCapXT requires XTSup=1, which can be inferred
6395 +- * amd_iommu_xt_mode.
6396 ++ * IntCapXT requires XTSup=1 and MsiCapMmioSup=1,
6397 ++ * which can be inferred from amd_iommu_xt_mode.
6398 + */
6399 + if (amd_iommu_xt_mode != IRQ_REMAP_X2APIC_MODE)
6400 + return 0;
6401 +diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
6402 +index f52f59d5c6bd..798e1533a147 100644
6403 +--- a/drivers/iommu/amd_iommu_types.h
6404 ++++ b/drivers/iommu/amd_iommu_types.h
6405 +@@ -377,12 +377,12 @@
6406 + #define IOMMU_CAP_EFR 27
6407 +
6408 + /* IOMMU Feature Reporting Field (for IVHD type 10h */
6409 +-#define IOMMU_FEAT_XTSUP_SHIFT 0
6410 + #define IOMMU_FEAT_GASUP_SHIFT 6
6411 +
6412 + /* IOMMU Extended Feature Register (EFR) */
6413 + #define IOMMU_EFR_XTSUP_SHIFT 2
6414 + #define IOMMU_EFR_GASUP_SHIFT 7
6415 ++#define IOMMU_EFR_MSICAPMMIOSUP_SHIFT 46
6416 +
6417 + #define MAX_DOMAIN_ID 65536
6418 +
6419 +diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
6420 +index 2f7680faba49..6bd6a3f3f471 100644
6421 +--- a/drivers/iommu/arm-smmu-v3.c
6422 ++++ b/drivers/iommu/arm-smmu-v3.c
6423 +@@ -1643,7 +1643,8 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid,
6424 + STRTAB_STE_1_EATS_TRANS));
6425 +
6426 + arm_smmu_sync_ste_for_sid(smmu, sid);
6427 +- dst[0] = cpu_to_le64(val);
6428 ++ /* See comment in arm_smmu_write_ctx_desc() */
6429 ++ WRITE_ONCE(dst[0], cpu_to_le64(val));
6430 + arm_smmu_sync_ste_for_sid(smmu, sid);
6431 +
6432 + /* It's likely that we'll want to use the new STE soon */
6433 +diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
6434 +index 3acfa6a25fa2..fb66f717127d 100644
6435 +--- a/drivers/iommu/dmar.c
6436 ++++ b/drivers/iommu/dmar.c
6437 +@@ -1354,7 +1354,6 @@ void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,
6438 + struct qi_desc desc;
6439 +
6440 + if (mask) {
6441 +- WARN_ON_ONCE(addr & ((1ULL << (VTD_PAGE_SHIFT + mask)) - 1));
6442 + addr |= (1ULL << (VTD_PAGE_SHIFT + mask - 1)) - 1;
6443 + desc.qw1 = QI_DEV_IOTLB_ADDR(addr) | QI_DEV_IOTLB_SIZE;
6444 + } else
6445 +diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
6446 +index 932267f49f9a..dfedbb04f647 100644
6447 +--- a/drivers/iommu/intel-iommu.c
6448 ++++ b/drivers/iommu/intel-iommu.c
6449 +@@ -3406,7 +3406,8 @@ static unsigned long intel_alloc_iova(struct device *dev,
6450 + iova_pfn = alloc_iova_fast(&domain->iovad, nrpages,
6451 + IOVA_PFN(dma_mask), true);
6452 + if (unlikely(!iova_pfn)) {
6453 +- dev_err(dev, "Allocating %ld-page iova failed", nrpages);
6454 ++ dev_err_once(dev, "Allocating %ld-page iova failed\n",
6455 ++ nrpages);
6456 + return 0;
6457 + }
6458 +
6459 +@@ -4319,12 +4320,16 @@ int __init dmar_parse_one_rmrr(struct acpi_dmar_header *header, void *arg)
6460 + {
6461 + struct acpi_dmar_reserved_memory *rmrr;
6462 + struct dmar_rmrr_unit *rmrru;
6463 +- int ret;
6464 +
6465 + rmrr = (struct acpi_dmar_reserved_memory *)header;
6466 +- ret = arch_rmrr_sanity_check(rmrr);
6467 +- if (ret)
6468 +- return ret;
6469 ++ if (arch_rmrr_sanity_check(rmrr))
6470 ++ WARN_TAINT(1, TAINT_FIRMWARE_WORKAROUND,
6471 ++ "Your BIOS is broken; bad RMRR [%#018Lx-%#018Lx]\n"
6472 ++ "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
6473 ++ rmrr->base_address, rmrr->end_address,
6474 ++ dmi_get_system_info(DMI_BIOS_VENDOR),
6475 ++ dmi_get_system_info(DMI_BIOS_VERSION),
6476 ++ dmi_get_system_info(DMI_PRODUCT_VERSION));
6477 +
6478 + rmrru = kzalloc(sizeof(*rmrru), GFP_KERNEL);
6479 + if (!rmrru)
6480 +diff --git a/drivers/iommu/intel-pasid.c b/drivers/iommu/intel-pasid.c
6481 +index 040a445be300..e7cb0b8a7332 100644
6482 +--- a/drivers/iommu/intel-pasid.c
6483 ++++ b/drivers/iommu/intel-pasid.c
6484 +@@ -499,8 +499,16 @@ int intel_pasid_setup_first_level(struct intel_iommu *iommu,
6485 + }
6486 +
6487 + #ifdef CONFIG_X86
6488 +- if (cpu_feature_enabled(X86_FEATURE_LA57))
6489 +- pasid_set_flpm(pte, 1);
6490 ++ /* Both CPU and IOMMU paging mode need to match */
6491 ++ if (cpu_feature_enabled(X86_FEATURE_LA57)) {
6492 ++ if (cap_5lp_support(iommu->cap)) {
6493 ++ pasid_set_flpm(pte, 1);
6494 ++ } else {
6495 ++ pr_err("VT-d has no 5-level paging support for CPU\n");
6496 ++ pasid_clear_entry(pte);
6497 ++ return -EINVAL;
6498 ++ }
6499 ++ }
6500 + #endif /* CONFIG_X86 */
6501 +
6502 + pasid_set_domain_id(pte, did);
6503 +diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
6504 +index dca88f9fdf29..518d0b2d12af 100644
6505 +--- a/drivers/iommu/intel-svm.c
6506 ++++ b/drivers/iommu/intel-svm.c
6507 +@@ -317,7 +317,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_
6508 + /* Do not use PASID 0 in caching mode (virtualised IOMMU) */
6509 + ret = intel_pasid_alloc_id(svm,
6510 + !!cap_caching_mode(iommu->cap),
6511 +- pasid_max - 1, GFP_KERNEL);
6512 ++ pasid_max, GFP_KERNEL);
6513 + if (ret < 0) {
6514 + kfree(svm);
6515 + kfree(sdev);
6516 +@@ -654,11 +654,10 @@ static irqreturn_t prq_event_thread(int irq, void *d)
6517 + if (req->priv_data_present)
6518 + memcpy(&resp.qw2, req->priv_data,
6519 + sizeof(req->priv_data));
6520 ++ resp.qw2 = 0;
6521 ++ resp.qw3 = 0;
6522 ++ qi_submit_sync(&resp, iommu);
6523 + }
6524 +- resp.qw2 = 0;
6525 +- resp.qw3 = 0;
6526 +- qi_submit_sync(&resp, iommu);
6527 +-
6528 + head = (head + sizeof(*req)) & PRQ_RING_MASK;
6529 + }
6530 +
6531 +diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
6532 +index c7a914b9bbbc..0e6a9536eca6 100644
6533 +--- a/drivers/iommu/iova.c
6534 ++++ b/drivers/iommu/iova.c
6535 +@@ -233,7 +233,7 @@ static DEFINE_MUTEX(iova_cache_mutex);
6536 +
6537 + struct iova *alloc_iova_mem(void)
6538 + {
6539 +- return kmem_cache_zalloc(iova_cache, GFP_ATOMIC);
6540 ++ return kmem_cache_zalloc(iova_cache, GFP_ATOMIC | __GFP_NOWARN);
6541 + }
6542 + EXPORT_SYMBOL(alloc_iova_mem);
6543 +
6544 +diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
6545 +index e05673bcd52b..50f89056c16b 100644
6546 +--- a/drivers/irqchip/irq-gic-v3-its.c
6547 ++++ b/drivers/irqchip/irq-gic-v3-its.c
6548 +@@ -598,7 +598,7 @@ static struct its_collection *its_build_invall_cmd(struct its_node *its,
6549 + struct its_cmd_desc *desc)
6550 + {
6551 + its_encode_cmd(cmd, GITS_CMD_INVALL);
6552 +- its_encode_collection(cmd, desc->its_mapc_cmd.col->col_id);
6553 ++ its_encode_collection(cmd, desc->its_invall_cmd.col->col_id);
6554 +
6555 + its_fixup_cmd(cmd);
6556 +
6557 +@@ -1170,13 +1170,14 @@ static void its_send_vclear(struct its_device *dev, u32 event_id)
6558 + */
6559 + static struct its_vlpi_map *get_vlpi_map(struct irq_data *d)
6560 + {
6561 +- struct its_device *its_dev = irq_data_get_irq_chip_data(d);
6562 +- u32 event = its_get_event_id(d);
6563 ++ if (irqd_is_forwarded_to_vcpu(d)) {
6564 ++ struct its_device *its_dev = irq_data_get_irq_chip_data(d);
6565 ++ u32 event = its_get_event_id(d);
6566 +
6567 +- if (!irqd_is_forwarded_to_vcpu(d))
6568 +- return NULL;
6569 ++ return dev_event_to_vlpi_map(its_dev, event);
6570 ++ }
6571 +
6572 +- return dev_event_to_vlpi_map(its_dev, event);
6573 ++ return NULL;
6574 + }
6575 +
6576 + static void lpi_write_config(struct irq_data *d, u8 clr, u8 set)
6577 +diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
6578 +index d6218012097b..3f5baa5043db 100644
6579 +--- a/drivers/irqchip/irq-gic-v3.c
6580 ++++ b/drivers/irqchip/irq-gic-v3.c
6581 +@@ -1821,6 +1821,7 @@ static struct
6582 + struct redist_region *redist_regs;
6583 + u32 nr_redist_regions;
6584 + bool single_redist;
6585 ++ int enabled_rdists;
6586 + u32 maint_irq;
6587 + int maint_irq_mode;
6588 + phys_addr_t vcpu_base;
6589 +@@ -1915,8 +1916,10 @@ static int __init gic_acpi_match_gicc(union acpi_subtable_headers *header,
6590 + * If GICC is enabled and has valid gicr base address, then it means
6591 + * GICR base is presented via GICC
6592 + */
6593 +- if ((gicc->flags & ACPI_MADT_ENABLED) && gicc->gicr_base_address)
6594 ++ if ((gicc->flags & ACPI_MADT_ENABLED) && gicc->gicr_base_address) {
6595 ++ acpi_data.enabled_rdists++;
6596 + return 0;
6597 ++ }
6598 +
6599 + /*
6600 + * It's perfectly valid firmware can pass disabled GICC entry, driver
6601 +@@ -1946,8 +1949,10 @@ static int __init gic_acpi_count_gicr_regions(void)
6602 +
6603 + count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
6604 + gic_acpi_match_gicc, 0);
6605 +- if (count > 0)
6606 ++ if (count > 0) {
6607 + acpi_data.single_redist = true;
6608 ++ count = acpi_data.enabled_rdists;
6609 ++ }
6610 +
6611 + return count;
6612 + }
6613 +diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
6614 +index 3f09f658e8e2..6b566bba263b 100644
6615 +--- a/drivers/irqchip/irq-mbigen.c
6616 ++++ b/drivers/irqchip/irq-mbigen.c
6617 +@@ -374,6 +374,7 @@ static struct platform_driver mbigen_platform_driver = {
6618 + .name = "Hisilicon MBIGEN-V2",
6619 + .of_match_table = mbigen_of_match,
6620 + .acpi_match_table = ACPI_PTR(mbigen_acpi_match),
6621 ++ .suppress_bind_attrs = true,
6622 + },
6623 + .probe = mbigen_device_probe,
6624 + };
6625 +diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
6626 +index 4afc317901a8..66cdc003b8f4 100644
6627 +--- a/drivers/leds/leds-pca963x.c
6628 ++++ b/drivers/leds/leds-pca963x.c
6629 +@@ -40,6 +40,8 @@
6630 + #define PCA963X_LED_PWM 0x2 /* Controlled through PWM */
6631 + #define PCA963X_LED_GRP_PWM 0x3 /* Controlled through PWM/GRPPWM */
6632 +
6633 ++#define PCA963X_MODE2_OUTDRV 0x04 /* Open-drain or totem pole */
6634 ++#define PCA963X_MODE2_INVRT 0x10 /* Normal or inverted direction */
6635 + #define PCA963X_MODE2_DMBLNK 0x20 /* Enable blinking */
6636 +
6637 + #define PCA963X_MODE1 0x00
6638 +@@ -438,12 +440,12 @@ static int pca963x_probe(struct i2c_client *client,
6639 + PCA963X_MODE2);
6640 + /* Configure output: open-drain or totem pole (push-pull) */
6641 + if (pdata->outdrv == PCA963X_OPEN_DRAIN)
6642 +- mode2 |= 0x01;
6643 ++ mode2 &= ~PCA963X_MODE2_OUTDRV;
6644 + else
6645 +- mode2 |= 0x05;
6646 ++ mode2 |= PCA963X_MODE2_OUTDRV;
6647 + /* Configure direction: normal or inverted */
6648 + if (pdata->dir == PCA963X_INVERTED)
6649 +- mode2 |= 0x10;
6650 ++ mode2 |= PCA963X_MODE2_INVRT;
6651 + i2c_smbus_write_byte_data(pca963x->chip->client, PCA963X_MODE2,
6652 + mode2);
6653 + }
6654 +diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h
6655 +index c71365e7c1fa..a50dcfda656f 100644
6656 +--- a/drivers/md/bcache/bset.h
6657 ++++ b/drivers/md/bcache/bset.h
6658 +@@ -397,7 +397,8 @@ void bch_btree_keys_stats(struct btree_keys *b, struct bset_stats *state);
6659 +
6660 + /* Bkey utility code */
6661 +
6662 +-#define bset_bkey_last(i) bkey_idx((struct bkey *) (i)->d, (i)->keys)
6663 ++#define bset_bkey_last(i) bkey_idx((struct bkey *) (i)->d, \
6664 ++ (unsigned int)(i)->keys)
6665 +
6666 + static inline struct bkey *bset_bkey_idx(struct bset *i, unsigned int idx)
6667 + {
6668 +diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
6669 +index 33ddc5269e8d..6730820780b0 100644
6670 +--- a/drivers/md/bcache/journal.c
6671 ++++ b/drivers/md/bcache/journal.c
6672 +@@ -422,7 +422,8 @@ err:
6673 + static void btree_flush_write(struct cache_set *c)
6674 + {
6675 + struct btree *b, *t, *btree_nodes[BTREE_FLUSH_NR];
6676 +- unsigned int i, nr, ref_nr;
6677 ++ unsigned int i, nr;
6678 ++ int ref_nr;
6679 + atomic_t *fifo_front_p, *now_fifo_front_p;
6680 + size_t mask;
6681 +
6682 +diff --git a/drivers/md/bcache/stats.c b/drivers/md/bcache/stats.c
6683 +index ba1c93791d8d..503aafe188dc 100644
6684 +--- a/drivers/md/bcache/stats.c
6685 ++++ b/drivers/md/bcache/stats.c
6686 +@@ -109,9 +109,13 @@ int bch_cache_accounting_add_kobjs(struct cache_accounting *acc,
6687 +
6688 + void bch_cache_accounting_clear(struct cache_accounting *acc)
6689 + {
6690 +- memset(&acc->total.cache_hits,
6691 +- 0,
6692 +- sizeof(struct cache_stats));
6693 ++ acc->total.cache_hits = 0;
6694 ++ acc->total.cache_misses = 0;
6695 ++ acc->total.cache_bypass_hits = 0;
6696 ++ acc->total.cache_bypass_misses = 0;
6697 ++ acc->total.cache_readaheads = 0;
6698 ++ acc->total.cache_miss_collisions = 0;
6699 ++ acc->total.sectors_bypassed = 0;
6700 + }
6701 +
6702 + void bch_cache_accounting_destroy(struct cache_accounting *acc)
6703 +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
6704 +index 77e9869345e7..3b3724285d90 100644
6705 +--- a/drivers/md/bcache/super.c
6706 ++++ b/drivers/md/bcache/super.c
6707 +@@ -1275,6 +1275,9 @@ static void cached_dev_free(struct closure *cl)
6708 +
6709 + mutex_unlock(&bch_register_lock);
6710 +
6711 ++ if (dc->sb_bio.bi_inline_vecs[0].bv_page)
6712 ++ put_page(bio_first_page_all(&dc->sb_bio));
6713 ++
6714 + if (!IS_ERR_OR_NULL(dc->bdev))
6715 + blkdev_put(dc->bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
6716 +
6717 +@@ -2372,29 +2375,35 @@ static bool bch_is_open(struct block_device *bdev)
6718 + static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
6719 + const char *buffer, size_t size)
6720 + {
6721 +- ssize_t ret = -EINVAL;
6722 +- const char *err = "cannot allocate memory";
6723 ++ const char *err;
6724 + char *path = NULL;
6725 +- struct cache_sb *sb = NULL;
6726 ++ struct cache_sb *sb;
6727 + struct block_device *bdev = NULL;
6728 +- struct page *sb_page = NULL;
6729 ++ struct page *sb_page;
6730 ++ ssize_t ret;
6731 +
6732 ++ ret = -EBUSY;
6733 ++ err = "failed to reference bcache module";
6734 + if (!try_module_get(THIS_MODULE))
6735 +- return -EBUSY;
6736 ++ goto out;
6737 +
6738 + /* For latest state of bcache_is_reboot */
6739 + smp_mb();
6740 ++ err = "bcache is in reboot";
6741 + if (bcache_is_reboot)
6742 +- return -EBUSY;
6743 ++ goto out_module_put;
6744 +
6745 ++ ret = -ENOMEM;
6746 ++ err = "cannot allocate memory";
6747 + path = kstrndup(buffer, size, GFP_KERNEL);
6748 + if (!path)
6749 +- goto err;
6750 ++ goto out_module_put;
6751 +
6752 + sb = kmalloc(sizeof(struct cache_sb), GFP_KERNEL);
6753 + if (!sb)
6754 +- goto err;
6755 ++ goto out_free_path;
6756 +
6757 ++ ret = -EINVAL;
6758 + err = "failed to open device";
6759 + bdev = blkdev_get_by_path(strim(path),
6760 + FMODE_READ|FMODE_WRITE|FMODE_EXCL,
6761 +@@ -2411,57 +2420,69 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
6762 + if (!IS_ERR(bdev))
6763 + bdput(bdev);
6764 + if (attr == &ksysfs_register_quiet)
6765 +- goto quiet_out;
6766 ++ goto done;
6767 + }
6768 +- goto err;
6769 ++ goto out_free_sb;
6770 + }
6771 +
6772 + err = "failed to set blocksize";
6773 + if (set_blocksize(bdev, 4096))
6774 +- goto err_close;
6775 ++ goto out_blkdev_put;
6776 +
6777 + err = read_super(sb, bdev, &sb_page);
6778 + if (err)
6779 +- goto err_close;
6780 ++ goto out_blkdev_put;
6781 +
6782 + err = "failed to register device";
6783 + if (SB_IS_BDEV(sb)) {
6784 + struct cached_dev *dc = kzalloc(sizeof(*dc), GFP_KERNEL);
6785 +
6786 + if (!dc)
6787 +- goto err_close;
6788 ++ goto out_put_sb_page;
6789 +
6790 + mutex_lock(&bch_register_lock);
6791 + ret = register_bdev(sb, sb_page, bdev, dc);
6792 + mutex_unlock(&bch_register_lock);
6793 + /* blkdev_put() will be called in cached_dev_free() */
6794 +- if (ret < 0)
6795 +- goto err;
6796 ++ if (ret < 0) {
6797 ++ bdev = NULL;
6798 ++ goto out_put_sb_page;
6799 ++ }
6800 + } else {
6801 + struct cache *ca = kzalloc(sizeof(*ca), GFP_KERNEL);
6802 +
6803 + if (!ca)
6804 +- goto err_close;
6805 ++ goto out_put_sb_page;
6806 +
6807 + /* blkdev_put() will be called in bch_cache_release() */
6808 +- if (register_cache(sb, sb_page, bdev, ca) != 0)
6809 +- goto err;
6810 ++ if (register_cache(sb, sb_page, bdev, ca) != 0) {
6811 ++ bdev = NULL;
6812 ++ goto out_put_sb_page;
6813 ++ }
6814 + }
6815 +-quiet_out:
6816 +- ret = size;
6817 +-out:
6818 +- if (sb_page)
6819 +- put_page(sb_page);
6820 ++
6821 ++ put_page(sb_page);
6822 ++done:
6823 ++ kfree(sb);
6824 ++ kfree(path);
6825 ++ module_put(THIS_MODULE);
6826 ++ return size;
6827 ++
6828 ++out_put_sb_page:
6829 ++ put_page(sb_page);
6830 ++out_blkdev_put:
6831 ++ if (bdev)
6832 ++ blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
6833 ++out_free_sb:
6834 + kfree(sb);
6835 ++out_free_path:
6836 + kfree(path);
6837 ++ path = NULL;
6838 ++out_module_put:
6839 + module_put(THIS_MODULE);
6840 ++out:
6841 ++ pr_info("error %s: %s", path?path:"", err);
6842 + return ret;
6843 +-
6844 +-err_close:
6845 +- blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
6846 +-err:
6847 +- pr_info("error %s: %s", path, err);
6848 +- goto out;
6849 + }
6850 +
6851 +
6852 +diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
6853 +index c412eaa975fc..9a18bef0a5ff 100644
6854 +--- a/drivers/md/dm-raid.c
6855 ++++ b/drivers/md/dm-raid.c
6856 +@@ -129,7 +129,9 @@ struct raid_dev {
6857 + CTR_FLAG_RAID10_COPIES | \
6858 + CTR_FLAG_RAID10_FORMAT | \
6859 + CTR_FLAG_DELTA_DISKS | \
6860 +- CTR_FLAG_DATA_OFFSET)
6861 ++ CTR_FLAG_DATA_OFFSET | \
6862 ++ CTR_FLAG_JOURNAL_DEV | \
6863 ++ CTR_FLAG_JOURNAL_MODE)
6864 +
6865 + /* Valid options definitions per raid level... */
6866 +
6867 +@@ -3001,7 +3003,6 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
6868 + { 1, 254, "Cannot understand number of raid devices parameters" }
6869 + };
6870 +
6871 +- /* Must have <raid_type> */
6872 + arg = dm_shift_arg(&as);
6873 + if (!arg) {
6874 + ti->error = "No arguments";
6875 +@@ -3508,8 +3509,7 @@ static void raid_status(struct dm_target *ti, status_type_t type,
6876 + unsigned long recovery;
6877 + unsigned int raid_param_cnt = 1; /* at least 1 for chunksize */
6878 + unsigned int sz = 0;
6879 +- unsigned int rebuild_disks;
6880 +- unsigned int write_mostly_params = 0;
6881 ++ unsigned int rebuild_writemostly_count = 0;
6882 + sector_t progress, resync_max_sectors, resync_mismatches;
6883 + enum sync_state state;
6884 + struct raid_type *rt;
6885 +@@ -3593,18 +3593,20 @@ static void raid_status(struct dm_target *ti, status_type_t type,
6886 + case STATUSTYPE_TABLE:
6887 + /* Report the table line string you would use to construct this raid set */
6888 +
6889 +- /* Calculate raid parameter count */
6890 +- for (i = 0; i < rs->raid_disks; i++)
6891 +- if (test_bit(WriteMostly, &rs->dev[i].rdev.flags))
6892 +- write_mostly_params += 2;
6893 +- rebuild_disks = memweight(rs->rebuild_disks, DISKS_ARRAY_ELEMS * sizeof(*rs->rebuild_disks));
6894 +- raid_param_cnt += rebuild_disks * 2 +
6895 +- write_mostly_params +
6896 ++ /*
6897 ++ * Count any rebuild or writemostly argument pairs and subtract the
6898 ++ * hweight count being added below of any rebuild and writemostly ctr flags.
6899 ++ */
6900 ++ for (i = 0; i < rs->raid_disks; i++) {
6901 ++ rebuild_writemostly_count += (test_bit(i, (void *) rs->rebuild_disks) ? 2 : 0) +
6902 ++ (test_bit(WriteMostly, &rs->dev[i].rdev.flags) ? 2 : 0);
6903 ++ }
6904 ++ rebuild_writemostly_count -= (test_bit(__CTR_FLAG_REBUILD, &rs->ctr_flags) ? 2 : 0) +
6905 ++ (test_bit(__CTR_FLAG_WRITE_MOSTLY, &rs->ctr_flags) ? 2 : 0);
6906 ++ /* Calculate raid parameter count based on ^ rebuild/writemostly argument counts and ctr flags set. */
6907 ++ raid_param_cnt += rebuild_writemostly_count +
6908 + hweight32(rs->ctr_flags & CTR_FLAG_OPTIONS_NO_ARGS) +
6909 +- hweight32(rs->ctr_flags & CTR_FLAG_OPTIONS_ONE_ARG) * 2 +
6910 +- (test_bit(__CTR_FLAG_JOURNAL_DEV, &rs->ctr_flags) ? 2 : 0) +
6911 +- (test_bit(__CTR_FLAG_JOURNAL_MODE, &rs->ctr_flags) ? 2 : 0);
6912 +-
6913 ++ hweight32(rs->ctr_flags & CTR_FLAG_OPTIONS_ONE_ARG) * 2;
6914 + /* Emit table line */
6915 + /* This has to be in the documented order for userspace! */
6916 + DMEMIT("%s %u %u", rs->raid_type->name, raid_param_cnt, mddev->new_chunk_sectors);
6917 +@@ -3612,11 +3614,10 @@ static void raid_status(struct dm_target *ti, status_type_t type,
6918 + DMEMIT(" %s", dm_raid_arg_name_by_flag(CTR_FLAG_SYNC));
6919 + if (test_bit(__CTR_FLAG_NOSYNC, &rs->ctr_flags))
6920 + DMEMIT(" %s", dm_raid_arg_name_by_flag(CTR_FLAG_NOSYNC));
6921 +- if (rebuild_disks)
6922 ++ if (test_bit(__CTR_FLAG_REBUILD, &rs->ctr_flags))
6923 + for (i = 0; i < rs->raid_disks; i++)
6924 +- if (test_bit(rs->dev[i].rdev.raid_disk, (void *) rs->rebuild_disks))
6925 +- DMEMIT(" %s %u", dm_raid_arg_name_by_flag(CTR_FLAG_REBUILD),
6926 +- rs->dev[i].rdev.raid_disk);
6927 ++ if (test_bit(i, (void *) rs->rebuild_disks))
6928 ++ DMEMIT(" %s %u", dm_raid_arg_name_by_flag(CTR_FLAG_REBUILD), i);
6929 + if (test_bit(__CTR_FLAG_DAEMON_SLEEP, &rs->ctr_flags))
6930 + DMEMIT(" %s %lu", dm_raid_arg_name_by_flag(CTR_FLAG_DAEMON_SLEEP),
6931 + mddev->bitmap_info.daemon_sleep);
6932 +@@ -3626,7 +3627,7 @@ static void raid_status(struct dm_target *ti, status_type_t type,
6933 + if (test_bit(__CTR_FLAG_MAX_RECOVERY_RATE, &rs->ctr_flags))
6934 + DMEMIT(" %s %d", dm_raid_arg_name_by_flag(CTR_FLAG_MAX_RECOVERY_RATE),
6935 + mddev->sync_speed_max);
6936 +- if (write_mostly_params)
6937 ++ if (test_bit(__CTR_FLAG_WRITE_MOSTLY, &rs->ctr_flags))
6938 + for (i = 0; i < rs->raid_disks; i++)
6939 + if (test_bit(WriteMostly, &rs->dev[i].rdev.flags))
6940 + DMEMIT(" %s %d", dm_raid_arg_name_by_flag(CTR_FLAG_WRITE_MOSTLY),
6941 +@@ -4029,7 +4030,7 @@ static void raid_resume(struct dm_target *ti)
6942 +
6943 + static struct target_type raid_target = {
6944 + .name = "raid",
6945 +- .version = {1, 15, 0},
6946 ++ .version = {1, 15, 1},
6947 + .module = THIS_MODULE,
6948 + .ctr = raid_ctr,
6949 + .dtr = raid_dtr,
6950 +diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
6951 +index a2bb2622cdbd..4fb6e89c8786 100644
6952 +--- a/drivers/md/dm-thin.c
6953 ++++ b/drivers/md/dm-thin.c
6954 +@@ -231,6 +231,7 @@ struct pool {
6955 + struct dm_target *ti; /* Only set if a pool target is bound */
6956 +
6957 + struct mapped_device *pool_md;
6958 ++ struct block_device *data_dev;
6959 + struct block_device *md_dev;
6960 + struct dm_pool_metadata *pmd;
6961 +
6962 +@@ -2933,6 +2934,7 @@ static struct kmem_cache *_new_mapping_cache;
6963 +
6964 + static struct pool *pool_create(struct mapped_device *pool_md,
6965 + struct block_device *metadata_dev,
6966 ++ struct block_device *data_dev,
6967 + unsigned long block_size,
6968 + int read_only, char **error)
6969 + {
6970 +@@ -3040,6 +3042,7 @@ static struct pool *pool_create(struct mapped_device *pool_md,
6971 + pool->last_commit_jiffies = jiffies;
6972 + pool->pool_md = pool_md;
6973 + pool->md_dev = metadata_dev;
6974 ++ pool->data_dev = data_dev;
6975 + __pool_table_insert(pool);
6976 +
6977 + return pool;
6978 +@@ -3081,6 +3084,7 @@ static void __pool_dec(struct pool *pool)
6979 +
6980 + static struct pool *__pool_find(struct mapped_device *pool_md,
6981 + struct block_device *metadata_dev,
6982 ++ struct block_device *data_dev,
6983 + unsigned long block_size, int read_only,
6984 + char **error, int *created)
6985 + {
6986 +@@ -3091,19 +3095,23 @@ static struct pool *__pool_find(struct mapped_device *pool_md,
6987 + *error = "metadata device already in use by a pool";
6988 + return ERR_PTR(-EBUSY);
6989 + }
6990 ++ if (pool->data_dev != data_dev) {
6991 ++ *error = "data device already in use by a pool";
6992 ++ return ERR_PTR(-EBUSY);
6993 ++ }
6994 + __pool_inc(pool);
6995 +
6996 + } else {
6997 + pool = __pool_table_lookup(pool_md);
6998 + if (pool) {
6999 +- if (pool->md_dev != metadata_dev) {
7000 ++ if (pool->md_dev != metadata_dev || pool->data_dev != data_dev) {
7001 + *error = "different pool cannot replace a pool";
7002 + return ERR_PTR(-EINVAL);
7003 + }
7004 + __pool_inc(pool);
7005 +
7006 + } else {
7007 +- pool = pool_create(pool_md, metadata_dev, block_size, read_only, error);
7008 ++ pool = pool_create(pool_md, metadata_dev, data_dev, block_size, read_only, error);
7009 + *created = 1;
7010 + }
7011 + }
7012 +@@ -3356,7 +3364,7 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
7013 + goto out;
7014 + }
7015 +
7016 +- pool = __pool_find(dm_table_get_md(ti->table), metadata_dev->bdev,
7017 ++ pool = __pool_find(dm_table_get_md(ti->table), metadata_dev->bdev, data_dev->bdev,
7018 + block_size, pf.mode == PM_READ_ONLY, &ti->error, &pool_created);
7019 + if (IS_ERR(pool)) {
7020 + r = PTR_ERR(pool);
7021 +@@ -4098,7 +4106,7 @@ static struct target_type pool_target = {
7022 + .name = "thin-pool",
7023 + .features = DM_TARGET_SINGLETON | DM_TARGET_ALWAYS_WRITEABLE |
7024 + DM_TARGET_IMMUTABLE,
7025 +- .version = {1, 21, 0},
7026 ++ .version = {1, 22, 0},
7027 + .module = THIS_MODULE,
7028 + .ctr = pool_ctr,
7029 + .dtr = pool_dtr,
7030 +@@ -4475,7 +4483,7 @@ static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits)
7031 +
7032 + static struct target_type thin_target = {
7033 + .name = "thin",
7034 +- .version = {1, 21, 0},
7035 ++ .version = {1, 22, 0},
7036 + .module = THIS_MODULE,
7037 + .ctr = thin_ctr,
7038 + .dtr = thin_dtr,
7039 +diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
7040 +index 4b9b98cf6674..5bd3ae82992f 100644
7041 +--- a/drivers/media/i2c/mt9v032.c
7042 ++++ b/drivers/media/i2c/mt9v032.c
7043 +@@ -428,10 +428,12 @@ static int mt9v032_enum_mbus_code(struct v4l2_subdev *subdev,
7044 + struct v4l2_subdev_pad_config *cfg,
7045 + struct v4l2_subdev_mbus_code_enum *code)
7046 + {
7047 ++ struct mt9v032 *mt9v032 = to_mt9v032(subdev);
7048 ++
7049 + if (code->index > 0)
7050 + return -EINVAL;
7051 +
7052 +- code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
7053 ++ code->code = mt9v032->format.code;
7054 + return 0;
7055 + }
7056 +
7057 +@@ -439,7 +441,11 @@ static int mt9v032_enum_frame_size(struct v4l2_subdev *subdev,
7058 + struct v4l2_subdev_pad_config *cfg,
7059 + struct v4l2_subdev_frame_size_enum *fse)
7060 + {
7061 +- if (fse->index >= 3 || fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
7062 ++ struct mt9v032 *mt9v032 = to_mt9v032(subdev);
7063 ++
7064 ++ if (fse->index >= 3)
7065 ++ return -EINVAL;
7066 ++ if (mt9v032->format.code != fse->code)
7067 + return -EINVAL;
7068 +
7069 + fse->min_width = MT9V032_WINDOW_WIDTH_DEF / (1 << fse->index);
7070 +diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
7071 +index 5e495c833d32..bb968e764f31 100644
7072 +--- a/drivers/media/i2c/ov5640.c
7073 ++++ b/drivers/media/i2c/ov5640.c
7074 +@@ -874,7 +874,7 @@ static unsigned long ov5640_calc_sys_clk(struct ov5640_dev *sensor,
7075 + * We have reached the maximum allowed PLL1 output,
7076 + * increase sysdiv.
7077 + */
7078 +- if (!rate)
7079 ++ if (!_rate)
7080 + break;
7081 +
7082 + /*
7083 +diff --git a/drivers/media/pci/cx23885/cx23885-cards.c b/drivers/media/pci/cx23885/cx23885-cards.c
7084 +index 8644205d3cd3..8e5a2c580821 100644
7085 +--- a/drivers/media/pci/cx23885/cx23885-cards.c
7086 ++++ b/drivers/media/pci/cx23885/cx23885-cards.c
7087 +@@ -801,6 +801,25 @@ struct cx23885_board cx23885_boards[] = {
7088 + .name = "Hauppauge WinTV-Starburst2",
7089 + .portb = CX23885_MPEG_DVB,
7090 + },
7091 ++ [CX23885_BOARD_AVERMEDIA_CE310B] = {
7092 ++ .name = "AVerMedia CE310B",
7093 ++ .porta = CX23885_ANALOG_VIDEO,
7094 ++ .force_bff = 1,
7095 ++ .input = {{
7096 ++ .type = CX23885_VMUX_COMPOSITE1,
7097 ++ .vmux = CX25840_VIN1_CH1 |
7098 ++ CX25840_NONE_CH2 |
7099 ++ CX25840_NONE0_CH3,
7100 ++ .amux = CX25840_AUDIO7,
7101 ++ }, {
7102 ++ .type = CX23885_VMUX_SVIDEO,
7103 ++ .vmux = CX25840_VIN8_CH1 |
7104 ++ CX25840_NONE_CH2 |
7105 ++ CX25840_VIN7_CH3 |
7106 ++ CX25840_SVIDEO_ON,
7107 ++ .amux = CX25840_AUDIO7,
7108 ++ } },
7109 ++ },
7110 + };
7111 + const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
7112 +
7113 +@@ -1124,6 +1143,10 @@ struct cx23885_subid cx23885_subids[] = {
7114 + .subvendor = 0x0070,
7115 + .subdevice = 0xf02a,
7116 + .card = CX23885_BOARD_HAUPPAUGE_STARBURST2,
7117 ++ }, {
7118 ++ .subvendor = 0x1461,
7119 ++ .subdevice = 0x3100,
7120 ++ .card = CX23885_BOARD_AVERMEDIA_CE310B,
7121 + },
7122 + };
7123 + const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
7124 +@@ -2348,6 +2371,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
7125 + case CX23885_BOARD_DVBSKY_T982:
7126 + case CX23885_BOARD_VIEWCAST_260E:
7127 + case CX23885_BOARD_VIEWCAST_460E:
7128 ++ case CX23885_BOARD_AVERMEDIA_CE310B:
7129 + dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
7130 + &dev->i2c_bus[2].i2c_adap,
7131 + "cx25840", 0x88 >> 1, NULL);
7132 +diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c
7133 +index 8098b15493de..7fc408ee4934 100644
7134 +--- a/drivers/media/pci/cx23885/cx23885-video.c
7135 ++++ b/drivers/media/pci/cx23885/cx23885-video.c
7136 +@@ -257,7 +257,8 @@ static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input)
7137 + (dev->board == CX23885_BOARD_MYGICA_X8507) ||
7138 + (dev->board == CX23885_BOARD_AVERMEDIA_HC81R) ||
7139 + (dev->board == CX23885_BOARD_VIEWCAST_260E) ||
7140 +- (dev->board == CX23885_BOARD_VIEWCAST_460E)) {
7141 ++ (dev->board == CX23885_BOARD_VIEWCAST_460E) ||
7142 ++ (dev->board == CX23885_BOARD_AVERMEDIA_CE310B)) {
7143 + /* Configure audio routing */
7144 + v4l2_subdev_call(dev->sd_cx25840, audio, s_routing,
7145 + INPUT(input)->amux, 0, 0);
7146 +diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h
7147 +index a95a2e4c6a0d..c472498e57c4 100644
7148 +--- a/drivers/media/pci/cx23885/cx23885.h
7149 ++++ b/drivers/media/pci/cx23885/cx23885.h
7150 +@@ -101,6 +101,7 @@
7151 + #define CX23885_BOARD_HAUPPAUGE_STARBURST2 59
7152 + #define CX23885_BOARD_HAUPPAUGE_QUADHD_DVB_885 60
7153 + #define CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC_885 61
7154 ++#define CX23885_BOARD_AVERMEDIA_CE310B 62
7155 +
7156 + #define GPIO_0 0x00000001
7157 + #define GPIO_1 0x00000002
7158 +diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c b/drivers/media/platform/sti/bdisp/bdisp-hw.c
7159 +index 4372abbb5950..a74e9fd65238 100644
7160 +--- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
7161 ++++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
7162 +@@ -14,8 +14,8 @@
7163 + #define MAX_SRC_WIDTH 2048
7164 +
7165 + /* Reset & boot poll config */
7166 +-#define POLL_RST_MAX 50
7167 +-#define POLL_RST_DELAY_MS 20
7168 ++#define POLL_RST_MAX 500
7169 ++#define POLL_RST_DELAY_MS 2
7170 +
7171 + enum bdisp_target_plan {
7172 + BDISP_RGB,
7173 +@@ -382,7 +382,7 @@ int bdisp_hw_reset(struct bdisp_dev *bdisp)
7174 + for (i = 0; i < POLL_RST_MAX; i++) {
7175 + if (readl(bdisp->regs + BLT_STA1) & BLT_STA1_IDLE)
7176 + break;
7177 +- msleep(POLL_RST_DELAY_MS);
7178 ++ udelay(POLL_RST_DELAY_MS * 1000);
7179 + }
7180 + if (i == POLL_RST_MAX)
7181 + dev_err(bdisp->dev, "Reset timeout\n");
7182 +diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
7183 +index f36dc6258900..b8b07c1de2a8 100644
7184 +--- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
7185 ++++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
7186 +@@ -11,6 +11,7 @@
7187 + #include <linux/module.h>
7188 + #include <linux/mutex.h>
7189 + #include <linux/of.h>
7190 ++#include <linux/of_device.h>
7191 + #include <linux/of_graph.h>
7192 + #include <linux/platform_device.h>
7193 + #include <linux/pm_runtime.h>
7194 +@@ -155,6 +156,27 @@ static int sun4i_csi_probe(struct platform_device *pdev)
7195 + subdev = &csi->subdev;
7196 + vdev = &csi->vdev;
7197 +
7198 ++ /*
7199 ++ * On Allwinner SoCs, some high memory bandwidth devices do DMA
7200 ++ * directly over the memory bus (called MBUS), instead of the
7201 ++ * system bus. The memory bus has a different addressing scheme
7202 ++ * without the DRAM starting offset.
7203 ++ *
7204 ++ * In some cases this can be described by an interconnect in
7205 ++ * the device tree. In other cases where the hardware is not
7206 ++ * fully understood and the interconnect is left out of the
7207 ++ * device tree, fall back to a default offset.
7208 ++ */
7209 ++ if (of_find_property(csi->dev->of_node, "interconnects", NULL)) {
7210 ++ ret = of_dma_configure(csi->dev, csi->dev->of_node, true);
7211 ++ if (ret)
7212 ++ return ret;
7213 ++ } else {
7214 ++#ifdef PHYS_PFN_OFFSET
7215 ++ csi->dev->dma_pfn_offset = PHYS_PFN_OFFSET;
7216 ++#endif
7217 ++ }
7218 ++
7219 + csi->mdev.dev = csi->dev;
7220 + strscpy(csi->mdev.model, "Allwinner Video Capture Device",
7221 + sizeof(csi->mdev.model));
7222 +diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h
7223 +index 001c8bde006c..88d39b3554c4 100644
7224 +--- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h
7225 ++++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h
7226 +@@ -22,8 +22,8 @@
7227 + #define CSI_CFG_INPUT_FMT(fmt) ((fmt) << 20)
7228 + #define CSI_CFG_OUTPUT_FMT(fmt) ((fmt) << 16)
7229 + #define CSI_CFG_YUV_DATA_SEQ(seq) ((seq) << 8)
7230 +-#define CSI_CFG_VSYNC_POL(pol) ((pol) << 2)
7231 +-#define CSI_CFG_HSYNC_POL(pol) ((pol) << 1)
7232 ++#define CSI_CFG_VREF_POL(pol) ((pol) << 2)
7233 ++#define CSI_CFG_HREF_POL(pol) ((pol) << 1)
7234 + #define CSI_CFG_PCLK_POL(pol) ((pol) << 0)
7235 +
7236 + #define CSI_CPT_CTRL_REG 0x08
7237 +diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c
7238 +index d6979e11a67b..78fa1c535ac6 100644
7239 +--- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c
7240 ++++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c
7241 +@@ -228,7 +228,7 @@ static int sun4i_csi_start_streaming(struct vb2_queue *vq, unsigned int count)
7242 + struct sun4i_csi *csi = vb2_get_drv_priv(vq);
7243 + struct v4l2_fwnode_bus_parallel *bus = &csi->bus;
7244 + const struct sun4i_csi_format *csi_fmt;
7245 +- unsigned long hsync_pol, pclk_pol, vsync_pol;
7246 ++ unsigned long href_pol, pclk_pol, vref_pol;
7247 + unsigned long flags;
7248 + unsigned int i;
7249 + int ret;
7250 +@@ -278,13 +278,21 @@ static int sun4i_csi_start_streaming(struct vb2_queue *vq, unsigned int count)
7251 + writel(CSI_WIN_CTRL_H_ACTIVE(csi->fmt.height),
7252 + csi->regs + CSI_WIN_CTRL_H_REG);
7253 +
7254 +- hsync_pol = !!(bus->flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH);
7255 +- pclk_pol = !!(bus->flags & V4L2_MBUS_DATA_ACTIVE_HIGH);
7256 +- vsync_pol = !!(bus->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH);
7257 ++ /*
7258 ++ * This hardware uses [HV]REF instead of [HV]SYNC. Based on the
7259 ++ * provided timing diagrams in the manual, positive polarity
7260 ++ * equals active high [HV]REF.
7261 ++ *
7262 ++ * When the back porch is 0, [HV]REF is more or less equivalent
7263 ++ * to [HV]SYNC inverted.
7264 ++ */
7265 ++ href_pol = !!(bus->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW);
7266 ++ vref_pol = !!(bus->flags & V4L2_MBUS_VSYNC_ACTIVE_LOW);
7267 ++ pclk_pol = !!(bus->flags & V4L2_MBUS_PCLK_SAMPLE_RISING);
7268 + writel(CSI_CFG_INPUT_FMT(csi_fmt->input) |
7269 + CSI_CFG_OUTPUT_FMT(csi_fmt->output) |
7270 +- CSI_CFG_VSYNC_POL(vsync_pol) |
7271 +- CSI_CFG_HSYNC_POL(hsync_pol) |
7272 ++ CSI_CFG_VREF_POL(vref_pol) |
7273 ++ CSI_CFG_HREF_POL(href_pol) |
7274 + CSI_CFG_PCLK_POL(pclk_pol),
7275 + csi->regs + CSI_CFG_REG);
7276 +
7277 +diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
7278 +index 2b688cc39bb8..99883550375e 100644
7279 +--- a/drivers/media/usb/uvc/uvc_driver.c
7280 ++++ b/drivers/media/usb/uvc/uvc_driver.c
7281 +@@ -497,6 +497,22 @@ static int uvc_parse_format(struct uvc_device *dev,
7282 + }
7283 + }
7284 +
7285 ++ /* Some devices report bpp that doesn't match the format. */
7286 ++ if (dev->quirks & UVC_QUIRK_FORCE_BPP) {
7287 ++ const struct v4l2_format_info *info =
7288 ++ v4l2_format_info(format->fcc);
7289 ++
7290 ++ if (info) {
7291 ++ unsigned int div = info->hdiv * info->vdiv;
7292 ++
7293 ++ n = info->bpp[0] * div;
7294 ++ for (i = 1; i < info->comp_planes; i++)
7295 ++ n += info->bpp[i];
7296 ++
7297 ++ format->bpp = DIV_ROUND_UP(8 * n, div);
7298 ++ }
7299 ++ }
7300 ++
7301 + if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) {
7302 + ftype = UVC_VS_FRAME_UNCOMPRESSED;
7303 + } else {
7304 +@@ -2874,6 +2890,15 @@ static const struct usb_device_id uvc_ids[] = {
7305 + .bInterfaceSubClass = 1,
7306 + .bInterfaceProtocol = 0,
7307 + .driver_info = (kernel_ulong_t)&uvc_quirk_force_y8 },
7308 ++ /* GEO Semiconductor GC6500 */
7309 ++ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
7310 ++ | USB_DEVICE_ID_MATCH_INT_INFO,
7311 ++ .idVendor = 0x29fe,
7312 ++ .idProduct = 0x4d53,
7313 ++ .bInterfaceClass = USB_CLASS_VIDEO,
7314 ++ .bInterfaceSubClass = 1,
7315 ++ .bInterfaceProtocol = 0,
7316 ++ .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_FORCE_BPP) },
7317 + /* Intel RealSense D4M */
7318 + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
7319 + | USB_DEVICE_ID_MATCH_INT_INFO,
7320 +diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
7321 +index f773dc5d802c..6ab972c643e3 100644
7322 +--- a/drivers/media/usb/uvc/uvcvideo.h
7323 ++++ b/drivers/media/usb/uvc/uvcvideo.h
7324 +@@ -198,6 +198,7 @@
7325 + #define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200
7326 + #define UVC_QUIRK_RESTORE_CTRLS_ON_INIT 0x00000400
7327 + #define UVC_QUIRK_FORCE_Y8 0x00000800
7328 ++#define UVC_QUIRK_FORCE_BPP 0x00001000
7329 +
7330 + /* Format flags */
7331 + #define UVC_FMT_FLAG_COMPRESSED 0x00000001
7332 +diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c
7333 +index 11835969e982..48ba7e02bed7 100644
7334 +--- a/drivers/misc/xilinx_sdfec.c
7335 ++++ b/drivers/misc/xilinx_sdfec.c
7336 +@@ -1025,25 +1025,25 @@ static long xsdfec_dev_compat_ioctl(struct file *file, unsigned int cmd,
7337 + }
7338 + #endif
7339 +
7340 +-static unsigned int xsdfec_poll(struct file *file, poll_table *wait)
7341 ++static __poll_t xsdfec_poll(struct file *file, poll_table *wait)
7342 + {
7343 +- unsigned int mask = 0;
7344 ++ __poll_t mask = 0;
7345 + struct xsdfec_dev *xsdfec;
7346 +
7347 + xsdfec = container_of(file->private_data, struct xsdfec_dev, miscdev);
7348 +
7349 + if (!xsdfec)
7350 +- return POLLNVAL | POLLHUP;
7351 ++ return EPOLLNVAL | EPOLLHUP;
7352 +
7353 + poll_wait(file, &xsdfec->waitq, wait);
7354 +
7355 + /* XSDFEC ISR detected an error */
7356 + spin_lock_irqsave(&xsdfec->error_data_lock, xsdfec->flags);
7357 + if (xsdfec->state_updated)
7358 +- mask |= POLLIN | POLLPRI;
7359 ++ mask |= EPOLLIN | EPOLLPRI;
7360 +
7361 + if (xsdfec->stats_updated)
7362 +- mask |= POLLIN | POLLRDNORM;
7363 ++ mask |= EPOLLIN | EPOLLRDNORM;
7364 + spin_unlock_irqrestore(&xsdfec->error_data_lock, xsdfec->flags);
7365 +
7366 + return mask;
7367 +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
7368 +index 01b603c5e76a..9d62200b6c33 100644
7369 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
7370 ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
7371 +@@ -944,6 +944,7 @@ static struct sk_buff *bnxt_rx_page_skb(struct bnxt *bp,
7372 + dma_addr -= bp->rx_dma_offset;
7373 + dma_unmap_page_attrs(&bp->pdev->dev, dma_addr, PAGE_SIZE, bp->rx_dir,
7374 + DMA_ATTR_WEAK_ORDERING);
7375 ++ page_pool_release_page(rxr->page_pool, page);
7376 +
7377 + if (unlikely(!payload))
7378 + payload = eth_get_headlen(bp->dev, data_ptr, len);
7379 +diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
7380 +index acb2856936d2..6e2ab10ad2e6 100644
7381 +--- a/drivers/net/ethernet/cisco/enic/enic_main.c
7382 ++++ b/drivers/net/ethernet/cisco/enic/enic_main.c
7383 +@@ -2013,10 +2013,10 @@ static int enic_stop(struct net_device *netdev)
7384 + napi_disable(&enic->napi[i]);
7385 +
7386 + netif_carrier_off(netdev);
7387 +- netif_tx_disable(netdev);
7388 + if (vnic_dev_get_intr_mode(enic->vdev) == VNIC_DEV_INTR_MODE_MSIX)
7389 + for (i = 0; i < enic->wq_count; i++)
7390 + napi_disable(&enic->napi[enic_cq_wq(enic, i)]);
7391 ++ netif_tx_disable(netdev);
7392 +
7393 + if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic))
7394 + enic_dev_del_station_addr(enic);
7395 +diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c
7396 +index 2e99438cb1bf..de52686b1d46 100644
7397 +--- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c
7398 ++++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c
7399 +@@ -36,7 +36,6 @@ void enetc_sched_speed_set(struct net_device *ndev)
7400 + case SPEED_10:
7401 + default:
7402 + pspeed = ENETC_PMR_PSPEED_10M;
7403 +- netdev_err(ndev, "Qbv PSPEED set speed link down.\n");
7404 + }
7405 +
7406 + priv->speed = speed;
7407 +@@ -192,7 +191,6 @@ int enetc_setup_tc_cbs(struct net_device *ndev, void *type_data)
7408 + u32 hi_credit_bit, hi_credit_reg;
7409 + u32 max_interference_size;
7410 + u32 port_frame_max_size;
7411 +- u32 tc_max_sized_frame;
7412 + u8 tc = cbs->queue;
7413 + u8 prio_top, prio_next;
7414 + int bw_sum = 0;
7415 +@@ -250,7 +248,7 @@ int enetc_setup_tc_cbs(struct net_device *ndev, void *type_data)
7416 + return -EINVAL;
7417 + }
7418 +
7419 +- tc_max_sized_frame = enetc_port_rd(&si->hw, ENETC_PTCMSDUR(tc));
7420 ++ enetc_port_rd(&si->hw, ENETC_PTCMSDUR(tc));
7421 +
7422 + /* For top prio TC, the max_interfrence_size is maxSizedFrame.
7423 + *
7424 +diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
7425 +index 72868a28b621..7d08bf6370ae 100644
7426 +--- a/drivers/net/ethernet/freescale/gianfar.c
7427 ++++ b/drivers/net/ethernet/freescale/gianfar.c
7428 +@@ -2205,13 +2205,17 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
7429 + skb_dirtytx = tx_queue->skb_dirtytx;
7430 +
7431 + while ((skb = tx_queue->tx_skbuff[skb_dirtytx])) {
7432 ++ bool do_tstamp;
7433 ++
7434 ++ do_tstamp = (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
7435 ++ priv->hwts_tx_en;
7436 +
7437 + frags = skb_shinfo(skb)->nr_frags;
7438 +
7439 + /* When time stamping, one additional TxBD must be freed.
7440 + * Also, we need to dma_unmap_single() the TxPAL.
7441 + */
7442 +- if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS))
7443 ++ if (unlikely(do_tstamp))
7444 + nr_txbds = frags + 2;
7445 + else
7446 + nr_txbds = frags + 1;
7447 +@@ -2225,7 +2229,7 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
7448 + (lstatus & BD_LENGTH_MASK))
7449 + break;
7450 +
7451 +- if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
7452 ++ if (unlikely(do_tstamp)) {
7453 + next = next_txbd(bdp, base, tx_ring_size);
7454 + buflen = be16_to_cpu(next->length) +
7455 + GMAC_FCB_LEN + GMAC_TXPAL_LEN;
7456 +@@ -2235,7 +2239,7 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
7457 + dma_unmap_single(priv->dev, be32_to_cpu(bdp->bufPtr),
7458 + buflen, DMA_TO_DEVICE);
7459 +
7460 +- if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
7461 ++ if (unlikely(do_tstamp)) {
7462 + struct skb_shared_hwtstamps shhwtstamps;
7463 + u64 *ns = (u64 *)(((uintptr_t)skb->data + 0x10) &
7464 + ~0x7UL);
7465 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
7466 +index f73cd917c44f..3156de786d95 100644
7467 +--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
7468 ++++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
7469 +@@ -791,7 +791,7 @@ int i40e_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)
7470 + struct i40e_ring *ring;
7471 +
7472 + if (test_bit(__I40E_CONFIG_BUSY, pf->state))
7473 +- return -ENETDOWN;
7474 ++ return -EAGAIN;
7475 +
7476 + if (test_bit(__I40E_VSI_DOWN, vsi->state))
7477 + return -ENETDOWN;
7478 +diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
7479 +index 2c212f64d99f..8b2b9e254d28 100644
7480 +--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
7481 ++++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
7482 +@@ -1071,13 +1071,16 @@ static int ice_clean_rx_irq(struct ice_ring *rx_ring, int budget)
7483 + ice_put_rx_buf(rx_ring, rx_buf);
7484 + continue;
7485 + construct_skb:
7486 +- if (skb)
7487 ++ if (skb) {
7488 + ice_add_rx_frag(rx_ring, rx_buf, skb, size);
7489 +- else if (ice_ring_uses_build_skb(rx_ring))
7490 +- skb = ice_build_skb(rx_ring, rx_buf, &xdp);
7491 +- else
7492 ++ } else if (likely(xdp.data)) {
7493 ++ if (ice_ring_uses_build_skb(rx_ring))
7494 ++ skb = ice_build_skb(rx_ring, rx_buf, &xdp);
7495 ++ else
7496 ++ skb = ice_construct_skb(rx_ring, rx_buf, &xdp);
7497 ++ } else {
7498 + skb = ice_construct_skb(rx_ring, rx_buf, &xdp);
7499 +-
7500 ++ }
7501 + /* exit if we failed to retrieve a buffer */
7502 + if (!skb) {
7503 + rx_ring->rx_stats.alloc_buf_failed++;
7504 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
7505 +index 9f09253f9f46..a05158472ed1 100644
7506 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
7507 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
7508 +@@ -297,6 +297,9 @@ static void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv)
7509 + s->tx_tls_drop_bypass_req += sq_stats->tls_drop_bypass_req;
7510 + #endif
7511 + s->tx_cqes += sq_stats->cqes;
7512 ++
7513 ++ /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92657 */
7514 ++ barrier();
7515 + }
7516 + }
7517 + }
7518 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/wq.c b/drivers/net/ethernet/mellanox/mlx5/core/wq.c
7519 +index f2a0e72285ba..02f7e4a39578 100644
7520 +--- a/drivers/net/ethernet/mellanox/mlx5/core/wq.c
7521 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/wq.c
7522 +@@ -89,7 +89,7 @@ void mlx5_wq_cyc_wqe_dump(struct mlx5_wq_cyc *wq, u16 ix, u8 nstrides)
7523 + len = nstrides << wq->fbc.log_stride;
7524 + wqe = mlx5_wq_cyc_get_wqe(wq, ix);
7525 +
7526 +- pr_info("WQE DUMP: WQ size %d WQ cur size %d, WQE index 0x%x, len: %ld\n",
7527 ++ pr_info("WQE DUMP: WQ size %d WQ cur size %d, WQE index 0x%x, len: %zu\n",
7528 + mlx5_wq_cyc_get_size(wq), wq->cur_sz, ix, len);
7529 + print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, wqe, len, false);
7530 + }
7531 +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
7532 +index 9bf8da5f6daf..3fe878d7c94c 100644
7533 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
7534 ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
7535 +@@ -573,6 +573,7 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
7536 +
7537 + static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon)
7538 + {
7539 ++ enum mlxsw_reg_mgpir_device_type device_type;
7540 + int index, max_index, sensor_index;
7541 + char mgpir_pl[MLXSW_REG_MGPIR_LEN];
7542 + char mtmp_pl[MLXSW_REG_MTMP_LEN];
7543 +@@ -584,8 +585,9 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon)
7544 + if (err)
7545 + return err;
7546 +
7547 +- mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, NULL, NULL, NULL);
7548 +- if (!gbox_num)
7549 ++ mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, NULL);
7550 ++ if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
7551 ++ !gbox_num)
7552 + return 0;
7553 +
7554 + index = mlxsw_hwmon->module_sensor_max;
7555 +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
7556 +index c721b171bd8d..ce0a6837daa3 100644
7557 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
7558 ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
7559 +@@ -895,8 +895,10 @@ static int
7560 + mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
7561 + struct mlxsw_thermal *thermal)
7562 + {
7563 ++ enum mlxsw_reg_mgpir_device_type device_type;
7564 + struct mlxsw_thermal_module *gearbox_tz;
7565 + char mgpir_pl[MLXSW_REG_MGPIR_LEN];
7566 ++ u8 gbox_num;
7567 + int i;
7568 + int err;
7569 +
7570 +@@ -908,11 +910,13 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
7571 + if (err)
7572 + return err;
7573 +
7574 +- mlxsw_reg_mgpir_unpack(mgpir_pl, &thermal->tz_gearbox_num, NULL, NULL,
7575 ++ mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL,
7576 + NULL);
7577 +- if (!thermal->tz_gearbox_num)
7578 ++ if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
7579 ++ !gbox_num)
7580 + return 0;
7581 +
7582 ++ thermal->tz_gearbox_num = gbox_num;
7583 + thermal->tz_gearbox_arr = kcalloc(thermal->tz_gearbox_num,
7584 + sizeof(*thermal->tz_gearbox_arr),
7585 + GFP_KERNEL);
7586 +diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
7587 +index 49933818c6f5..2dc0978428e6 100644
7588 +--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
7589 ++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
7590 +@@ -215,7 +215,7 @@ mlxsw_sp_dpipe_table_erif_entries_dump(void *priv, bool counters_enabled,
7591 + start_again:
7592 + err = devlink_dpipe_entry_ctx_prepare(dump_ctx);
7593 + if (err)
7594 +- return err;
7595 ++ goto err_ctx_prepare;
7596 + j = 0;
7597 + for (; i < rif_count; i++) {
7598 + struct mlxsw_sp_rif *rif = mlxsw_sp_rif_by_index(mlxsw_sp, i);
7599 +@@ -247,6 +247,7 @@ start_again:
7600 + return 0;
7601 + err_entry_append:
7602 + err_entry_get:
7603 ++err_ctx_prepare:
7604 + rtnl_unlock();
7605 + devlink_dpipe_entry_clear(&entry);
7606 + return err;
7607 +diff --git a/drivers/net/ethernet/netronome/nfp/abm/cls.c b/drivers/net/ethernet/netronome/nfp/abm/cls.c
7608 +index 9f8a1f69c0c4..23ebddfb9532 100644
7609 +--- a/drivers/net/ethernet/netronome/nfp/abm/cls.c
7610 ++++ b/drivers/net/ethernet/netronome/nfp/abm/cls.c
7611 +@@ -176,10 +176,8 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink,
7612 + u8 mask, val;
7613 + int err;
7614 +
7615 +- if (!nfp_abm_u32_check_knode(alink->abm, knode, proto, extack)) {
7616 +- err = -EOPNOTSUPP;
7617 ++ if (!nfp_abm_u32_check_knode(alink->abm, knode, proto, extack))
7618 + goto err_delete;
7619 +- }
7620 +
7621 + tos_off = proto == htons(ETH_P_IP) ? 16 : 20;
7622 +
7623 +@@ -200,18 +198,14 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink,
7624 + if ((iter->val & cmask) == (val & cmask) &&
7625 + iter->band != knode->res->classid) {
7626 + NL_SET_ERR_MSG_MOD(extack, "conflict with already offloaded filter");
7627 +- err = -EOPNOTSUPP;
7628 + goto err_delete;
7629 + }
7630 + }
7631 +
7632 + if (!match) {
7633 + match = kzalloc(sizeof(*match), GFP_KERNEL);
7634 +- if (!match) {
7635 +- err = -ENOMEM;
7636 +- goto err_delete;
7637 +- }
7638 +-
7639 ++ if (!match)
7640 ++ return -ENOMEM;
7641 + list_add(&match->list, &alink->dscp_map);
7642 + }
7643 + match->handle = knode->handle;
7644 +@@ -227,7 +221,7 @@ nfp_abm_u32_knode_replace(struct nfp_abm_link *alink,
7645 +
7646 + err_delete:
7647 + nfp_abm_u32_knode_delete(alink, knode);
7648 +- return err;
7649 ++ return -EOPNOTSUPP;
7650 + }
7651 +
7652 + static int nfp_abm_setup_tc_block_cb(enum tc_setup_type type,
7653 +diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
7654 +index 92a590154bb9..2d2d22f86dc6 100644
7655 +--- a/drivers/net/ethernet/realtek/r8169_main.c
7656 ++++ b/drivers/net/ethernet/realtek/r8169_main.c
7657 +@@ -6831,6 +6831,15 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7658 + int chipset, region;
7659 + int jumbo_max, rc;
7660 +
7661 ++ /* Some tools for creating an initramfs don't consider softdeps, then
7662 ++ * r8169.ko may be in initramfs, but realtek.ko not. Then the generic
7663 ++ * PHY driver is used that doesn't work with most chip versions.
7664 ++ */
7665 ++ if (!driver_find("RTL8201CP Ethernet", &mdio_bus_type)) {
7666 ++ dev_err(&pdev->dev, "realtek.ko not loaded, maybe it needs to be added to initramfs?\n");
7667 ++ return -ENOENT;
7668 ++ }
7669 ++
7670 + dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp));
7671 + if (!dev)
7672 + return -ENOMEM;
7673 +diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
7674 +index 6fc04ffb22c2..d4e095d0e8f1 100644
7675 +--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
7676 ++++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
7677 +@@ -517,25 +517,14 @@ static int ixp4xx_mdio_write(struct mii_bus *bus, int phy_id, int location,
7678 + return ret;
7679 + }
7680 +
7681 +-static int ixp4xx_mdio_register(void)
7682 ++static int ixp4xx_mdio_register(struct eth_regs __iomem *regs)
7683 + {
7684 + int err;
7685 +
7686 + if (!(mdio_bus = mdiobus_alloc()))
7687 + return -ENOMEM;
7688 +
7689 +- if (cpu_is_ixp43x()) {
7690 +- /* IXP43x lacks NPE-B and uses NPE-C for MII PHY access */
7691 +- if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEC_ETH))
7692 +- return -ENODEV;
7693 +- mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT;
7694 +- } else {
7695 +- /* All MII PHY accesses use NPE-B Ethernet registers */
7696 +- if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEB_ETH0))
7697 +- return -ENODEV;
7698 +- mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT;
7699 +- }
7700 +-
7701 ++ mdio_regs = regs;
7702 + __raw_writel(DEFAULT_CORE_CNTRL, &mdio_regs->core_control);
7703 + spin_lock_init(&mdio_lock);
7704 + mdio_bus->name = "IXP4xx MII Bus";
7705 +@@ -1374,7 +1363,7 @@ static const struct net_device_ops ixp4xx_netdev_ops = {
7706 + .ndo_validate_addr = eth_validate_addr,
7707 + };
7708 +
7709 +-static int eth_init_one(struct platform_device *pdev)
7710 ++static int ixp4xx_eth_probe(struct platform_device *pdev)
7711 + {
7712 + struct port *port;
7713 + struct net_device *dev;
7714 +@@ -1384,7 +1373,7 @@ static int eth_init_one(struct platform_device *pdev)
7715 + char phy_id[MII_BUS_ID_SIZE + 3];
7716 + int err;
7717 +
7718 +- if (!(dev = alloc_etherdev(sizeof(struct port))))
7719 ++ if (!(dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct port))))
7720 + return -ENOMEM;
7721 +
7722 + SET_NETDEV_DEV(dev, &pdev->dev);
7723 +@@ -1394,20 +1383,51 @@ static int eth_init_one(struct platform_device *pdev)
7724 +
7725 + switch (port->id) {
7726 + case IXP4XX_ETH_NPEA:
7727 ++ /* If the MDIO bus is not up yet, defer probe */
7728 ++ if (!mdio_bus)
7729 ++ return -EPROBE_DEFER;
7730 + port->regs = (struct eth_regs __iomem *)IXP4XX_EthA_BASE_VIRT;
7731 + regs_phys = IXP4XX_EthA_BASE_PHYS;
7732 + break;
7733 + case IXP4XX_ETH_NPEB:
7734 ++ /*
7735 ++ * On all except IXP43x, NPE-B is used for the MDIO bus.
7736 ++ * If there is no NPE-B in the feature set, bail out, else
7737 ++ * register the MDIO bus.
7738 ++ */
7739 ++ if (!cpu_is_ixp43x()) {
7740 ++ if (!(ixp4xx_read_feature_bits() &
7741 ++ IXP4XX_FEATURE_NPEB_ETH0))
7742 ++ return -ENODEV;
7743 ++ /* Else register the MDIO bus on NPE-B */
7744 ++ if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
7745 ++ return err;
7746 ++ }
7747 ++ if (!mdio_bus)
7748 ++ return -EPROBE_DEFER;
7749 + port->regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT;
7750 + regs_phys = IXP4XX_EthB_BASE_PHYS;
7751 + break;
7752 + case IXP4XX_ETH_NPEC:
7753 ++ /*
7754 ++ * IXP43x lacks NPE-B and uses NPE-C for the MDIO bus access,
7755 ++ * of there is no NPE-C, no bus, nothing works, so bail out.
7756 ++ */
7757 ++ if (cpu_is_ixp43x()) {
7758 ++ if (!(ixp4xx_read_feature_bits() &
7759 ++ IXP4XX_FEATURE_NPEC_ETH))
7760 ++ return -ENODEV;
7761 ++ /* Else register the MDIO bus on NPE-C */
7762 ++ if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
7763 ++ return err;
7764 ++ }
7765 ++ if (!mdio_bus)
7766 ++ return -EPROBE_DEFER;
7767 + port->regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT;
7768 + regs_phys = IXP4XX_EthC_BASE_PHYS;
7769 + break;
7770 + default:
7771 +- err = -ENODEV;
7772 +- goto err_free;
7773 ++ return -ENODEV;
7774 + }
7775 +
7776 + dev->netdev_ops = &ixp4xx_netdev_ops;
7777 +@@ -1416,10 +1436,8 @@ static int eth_init_one(struct platform_device *pdev)
7778 +
7779 + netif_napi_add(dev, &port->napi, eth_poll, NAPI_WEIGHT);
7780 +
7781 +- if (!(port->npe = npe_request(NPE_ID(port->id)))) {
7782 +- err = -EIO;
7783 +- goto err_free;
7784 +- }
7785 ++ if (!(port->npe = npe_request(NPE_ID(port->id))))
7786 ++ return -EIO;
7787 +
7788 + port->mem_res = request_mem_region(regs_phys, REGS_SIZE, dev->name);
7789 + if (!port->mem_res) {
7790 +@@ -1465,12 +1483,10 @@ err_free_mem:
7791 + release_resource(port->mem_res);
7792 + err_npe_rel:
7793 + npe_release(port->npe);
7794 +-err_free:
7795 +- free_netdev(dev);
7796 + return err;
7797 + }
7798 +
7799 +-static int eth_remove_one(struct platform_device *pdev)
7800 ++static int ixp4xx_eth_remove(struct platform_device *pdev)
7801 + {
7802 + struct net_device *dev = platform_get_drvdata(pdev);
7803 + struct phy_device *phydev = dev->phydev;
7804 +@@ -1478,45 +1494,21 @@ static int eth_remove_one(struct platform_device *pdev)
7805 +
7806 + unregister_netdev(dev);
7807 + phy_disconnect(phydev);
7808 ++ ixp4xx_mdio_remove();
7809 + npe_port_tab[NPE_ID(port->id)] = NULL;
7810 + npe_release(port->npe);
7811 + release_resource(port->mem_res);
7812 +- free_netdev(dev);
7813 + return 0;
7814 + }
7815 +
7816 + static struct platform_driver ixp4xx_eth_driver = {
7817 + .driver.name = DRV_NAME,
7818 +- .probe = eth_init_one,
7819 +- .remove = eth_remove_one,
7820 ++ .probe = ixp4xx_eth_probe,
7821 ++ .remove = ixp4xx_eth_remove,
7822 + };
7823 +-
7824 +-static int __init eth_init_module(void)
7825 +-{
7826 +- int err;
7827 +-
7828 +- /*
7829 +- * FIXME: we bail out on device tree boot but this really needs
7830 +- * to be fixed in a nicer way: this registers the MDIO bus before
7831 +- * even matching the driver infrastructure, we should only probe
7832 +- * detected hardware.
7833 +- */
7834 +- if (of_have_populated_dt())
7835 +- return -ENODEV;
7836 +- if ((err = ixp4xx_mdio_register()))
7837 +- return err;
7838 +- return platform_driver_register(&ixp4xx_eth_driver);
7839 +-}
7840 +-
7841 +-static void __exit eth_cleanup_module(void)
7842 +-{
7843 +- platform_driver_unregister(&ixp4xx_eth_driver);
7844 +- ixp4xx_mdio_remove();
7845 +-}
7846 ++module_platform_driver(ixp4xx_eth_driver);
7847 +
7848 + MODULE_AUTHOR("Krzysztof Halasa");
7849 + MODULE_DESCRIPTION("Intel IXP4xx Ethernet driver");
7850 + MODULE_LICENSE("GPL v2");
7851 + MODULE_ALIAS("platform:ixp4xx_eth");
7852 +-module_init(eth_init_module);
7853 +-module_exit(eth_cleanup_module);
7854 +diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
7855 +index 7c5265fd2b94..4190f9ed5313 100644
7856 +--- a/drivers/net/phy/fixed_phy.c
7857 ++++ b/drivers/net/phy/fixed_phy.c
7858 +@@ -212,16 +212,13 @@ static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
7859 + */
7860 + gpiod = gpiod_get_from_of_node(fixed_link_node, "link-gpios", 0,
7861 + GPIOD_IN, "mdio");
7862 +- of_node_put(fixed_link_node);
7863 +- if (IS_ERR(gpiod)) {
7864 +- if (PTR_ERR(gpiod) == -EPROBE_DEFER)
7865 +- return gpiod;
7866 +-
7867 ++ if (IS_ERR(gpiod) && PTR_ERR(gpiod) != -EPROBE_DEFER) {
7868 + if (PTR_ERR(gpiod) != -ENOENT)
7869 + pr_err("error getting GPIO for fixed link %pOF, proceed without\n",
7870 + fixed_link_node);
7871 + gpiod = NULL;
7872 + }
7873 ++ of_node_put(fixed_link_node);
7874 +
7875 + return gpiod;
7876 + }
7877 +diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
7878 +index 476db5345e1a..879ca37c8508 100644
7879 +--- a/drivers/net/phy/realtek.c
7880 ++++ b/drivers/net/phy/realtek.c
7881 +@@ -171,7 +171,9 @@ static int rtl8211c_config_init(struct phy_device *phydev)
7882 +
7883 + static int rtl8211f_config_init(struct phy_device *phydev)
7884 + {
7885 ++ struct device *dev = &phydev->mdio.dev;
7886 + u16 val;
7887 ++ int ret;
7888 +
7889 + /* enable TX-delay for rgmii-{id,txid}, and disable it for rgmii and
7890 + * rgmii-rxid. The RX-delay can be enabled by the external RXDLY pin.
7891 +@@ -189,7 +191,22 @@ static int rtl8211f_config_init(struct phy_device *phydev)
7892 + return 0;
7893 + }
7894 +
7895 +- return phy_modify_paged(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY, val);
7896 ++ ret = phy_modify_paged_changed(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY,
7897 ++ val);
7898 ++ if (ret < 0) {
7899 ++ dev_err(dev, "Failed to update the TX delay register\n");
7900 ++ return ret;
7901 ++ } else if (ret) {
7902 ++ dev_dbg(dev,
7903 ++ "%s 2ns TX delay (and changing the value from pin-strapping RXD1 or the bootloader)\n",
7904 ++ val ? "Enabling" : "Disabling");
7905 ++ } else {
7906 ++ dev_dbg(dev,
7907 ++ "2ns TX delay was already %s (by pin-strapping RXD1 or bootloader configuration)\n",
7908 ++ val ? "enabled" : "disabled");
7909 ++ }
7910 ++
7911 ++ return 0;
7912 + }
7913 +
7914 + static int rtl8211e_config_init(struct phy_device *phydev)
7915 +diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
7916 +index aef7de225783..4ad0a0c33d85 100644
7917 +--- a/drivers/net/wan/fsl_ucc_hdlc.c
7918 ++++ b/drivers/net/wan/fsl_ucc_hdlc.c
7919 +@@ -245,6 +245,11 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
7920 + ret = -ENOMEM;
7921 + goto free_riptr;
7922 + }
7923 ++ if (riptr != (u16)riptr || tiptr != (u16)tiptr) {
7924 ++ dev_err(priv->dev, "MURAM allocation out of addressable range\n");
7925 ++ ret = -ENOMEM;
7926 ++ goto free_tiptr;
7927 ++ }
7928 +
7929 + /* Set RIPTR, TIPTR */
7930 + iowrite16be(riptr, &priv->ucc_pram->riptr);
7931 +diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c
7932 +index 5643675ff724..bf78073ee7fd 100644
7933 +--- a/drivers/net/wan/hdlc_x25.c
7934 ++++ b/drivers/net/wan/hdlc_x25.c
7935 +@@ -62,11 +62,12 @@ static int x25_data_indication(struct net_device *dev, struct sk_buff *skb)
7936 + {
7937 + unsigned char *ptr;
7938 +
7939 +- skb_push(skb, 1);
7940 +-
7941 + if (skb_cow(skb, 1))
7942 + return NET_RX_DROP;
7943 +
7944 ++ skb_push(skb, 1);
7945 ++ skb_reset_network_header(skb);
7946 ++
7947 + ptr = skb->data;
7948 + *ptr = X25_IFACE_DATA;
7949 +
7950 +@@ -79,6 +80,13 @@ static int x25_data_indication(struct net_device *dev, struct sk_buff *skb)
7951 + static void x25_data_transmit(struct net_device *dev, struct sk_buff *skb)
7952 + {
7953 + hdlc_device *hdlc = dev_to_hdlc(dev);
7954 ++
7955 ++ skb_reset_network_header(skb);
7956 ++ skb->protocol = hdlc_type_trans(skb, dev);
7957 ++
7958 ++ if (dev_nit_active(dev))
7959 ++ dev_queue_xmit_nit(skb, dev);
7960 ++
7961 + hdlc->xmit(skb, dev); /* Ignore return value :-( */
7962 + }
7963 +
7964 +@@ -93,6 +101,7 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev)
7965 + switch (skb->data[0]) {
7966 + case X25_IFACE_DATA: /* Data to be transmitted */
7967 + skb_pull(skb, 1);
7968 ++ skb_reset_network_header(skb);
7969 + if ((result = lapb_data_request(dev, skb)) != LAPB_OK)
7970 + dev_kfree_skb(skb);
7971 + return NETDEV_TX_OK;
7972 +diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
7973 +index ea6ee6a608ce..e7619cec978a 100644
7974 +--- a/drivers/net/wan/ixp4xx_hss.c
7975 ++++ b/drivers/net/wan/ixp4xx_hss.c
7976 +@@ -258,7 +258,7 @@ struct port {
7977 + struct hss_plat_info *plat;
7978 + buffer_t *rx_buff_tab[RX_DESCS], *tx_buff_tab[TX_DESCS];
7979 + struct desc *desc_tab; /* coherent */
7980 +- u32 desc_tab_phys;
7981 ++ dma_addr_t desc_tab_phys;
7982 + unsigned int id;
7983 + unsigned int clock_type, clock_rate, loopback;
7984 + unsigned int initialized, carrier;
7985 +@@ -858,7 +858,7 @@ static int hss_hdlc_xmit(struct sk_buff *skb, struct net_device *dev)
7986 + dev->stats.tx_dropped++;
7987 + return NETDEV_TX_OK;
7988 + }
7989 +- memcpy_swab32(mem, (u32 *)((int)skb->data & ~3), bytes / 4);
7990 ++ memcpy_swab32(mem, (u32 *)((uintptr_t)skb->data & ~3), bytes / 4);
7991 + dev_kfree_skb(skb);
7992 + #endif
7993 +
7994 +diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c
7995 +index 16177497bba7..7e85c4916e7f 100644
7996 +--- a/drivers/net/wireless/ath/ath10k/snoc.c
7997 ++++ b/drivers/net/wireless/ath/ath10k/snoc.c
7998 +@@ -1563,13 +1563,16 @@ static int ath10k_snoc_probe(struct platform_device *pdev)
7999 + ret = ath10k_qmi_init(ar, msa_size);
8000 + if (ret) {
8001 + ath10k_warn(ar, "failed to register wlfw qmi client: %d\n", ret);
8002 +- goto err_core_destroy;
8003 ++ goto err_power_off;
8004 + }
8005 +
8006 + ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc probe\n");
8007 +
8008 + return 0;
8009 +
8010 ++err_power_off:
8011 ++ ath10k_hw_power_off(ar);
8012 ++
8013 + err_free_irq:
8014 + ath10k_snoc_free_irq(ar);
8015 +
8016 +diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
8017 +index 69a1ec53df29..7b358484940e 100644
8018 +--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
8019 ++++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
8020 +@@ -3707,6 +3707,7 @@ ath10k_wmi_tlv_op_gen_config_pno_start(struct ath10k *ar,
8021 + struct wmi_tlv *tlv;
8022 + struct sk_buff *skb;
8023 + __le32 *channel_list;
8024 ++ u16 tlv_len;
8025 + size_t len;
8026 + void *ptr;
8027 + u32 i;
8028 +@@ -3764,10 +3765,12 @@ ath10k_wmi_tlv_op_gen_config_pno_start(struct ath10k *ar,
8029 + /* nlo_configured_parameters(nlo_list) */
8030 + cmd->no_of_ssids = __cpu_to_le32(min_t(u8, pno->uc_networks_count,
8031 + WMI_NLO_MAX_SSIDS));
8032 ++ tlv_len = __le32_to_cpu(cmd->no_of_ssids) *
8033 ++ sizeof(struct nlo_configured_parameters);
8034 +
8035 + tlv = ptr;
8036 + tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
8037 +- tlv->len = __cpu_to_le16(len);
8038 ++ tlv->len = __cpu_to_le16(tlv_len);
8039 +
8040 + ptr += sizeof(*tlv);
8041 + nlo_list = ptr;
8042 +diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
8043 +index 9f564e2b7a14..214d65108b29 100644
8044 +--- a/drivers/net/wireless/ath/ath10k/wmi.c
8045 ++++ b/drivers/net/wireless/ath/ath10k/wmi.c
8046 +@@ -9476,7 +9476,7 @@ static int ath10k_wmi_mgmt_tx_clean_up_pending(int msdu_id, void *ptr,
8047 +
8048 + msdu = pkt_addr->vaddr;
8049 + dma_unmap_single(ar->dev, pkt_addr->paddr,
8050 +- msdu->len, DMA_FROM_DEVICE);
8051 ++ msdu->len, DMA_TO_DEVICE);
8052 + ieee80211_free_txskb(ar->hw, msdu);
8053 +
8054 + return 0;
8055 +diff --git a/drivers/net/wireless/ath/wil6210/txrx_edma.c b/drivers/net/wireless/ath/wil6210/txrx_edma.c
8056 +index 778b63be6a9a..02548d40253c 100644
8057 +--- a/drivers/net/wireless/ath/wil6210/txrx_edma.c
8058 ++++ b/drivers/net/wireless/ath/wil6210/txrx_edma.c
8059 +@@ -869,6 +869,7 @@ static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil,
8060 + u8 data_offset;
8061 + struct wil_rx_status_extended *s;
8062 + u16 sring_idx = sring - wil->srings;
8063 ++ int invalid_buff_id_retry;
8064 +
8065 + BUILD_BUG_ON(sizeof(struct wil_rx_status_extended) > sizeof(skb->cb));
8066 +
8067 +@@ -882,9 +883,9 @@ again:
8068 + /* Extract the buffer ID from the status message */
8069 + buff_id = le16_to_cpu(wil_rx_status_get_buff_id(msg));
8070 +
8071 ++ invalid_buff_id_retry = 0;
8072 + while (!buff_id) {
8073 + struct wil_rx_status_extended *s;
8074 +- int invalid_buff_id_retry = 0;
8075 +
8076 + wil_dbg_txrx(wil,
8077 + "buff_id is not updated yet by HW, (swhead 0x%x)\n",
8078 +diff --git a/drivers/net/wireless/broadcom/b43legacy/main.c b/drivers/net/wireless/broadcom/b43legacy/main.c
8079 +index 4325e91736eb..8b6b657c4b85 100644
8080 +--- a/drivers/net/wireless/broadcom/b43legacy/main.c
8081 ++++ b/drivers/net/wireless/broadcom/b43legacy/main.c
8082 +@@ -1275,8 +1275,9 @@ static void handle_irq_ucode_debug(struct b43legacy_wldev *dev)
8083 + }
8084 +
8085 + /* Interrupt handler bottom-half */
8086 +-static void b43legacy_interrupt_tasklet(struct b43legacy_wldev *dev)
8087 ++static void b43legacy_interrupt_tasklet(unsigned long data)
8088 + {
8089 ++ struct b43legacy_wldev *dev = (struct b43legacy_wldev *)data;
8090 + u32 reason;
8091 + u32 dma_reason[ARRAY_SIZE(dev->dma_reason)];
8092 + u32 merged_dma_reason = 0;
8093 +@@ -3741,7 +3742,7 @@ static int b43legacy_one_core_attach(struct ssb_device *dev,
8094 + b43legacy_set_status(wldev, B43legacy_STAT_UNINIT);
8095 + wldev->bad_frames_preempt = modparam_bad_frames_preempt;
8096 + tasklet_init(&wldev->isr_tasklet,
8097 +- (void (*)(unsigned long))b43legacy_interrupt_tasklet,
8098 ++ b43legacy_interrupt_tasklet,
8099 + (unsigned long)wldev);
8100 + if (modparam_pio)
8101 + wldev->__using_pio = true;
8102 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
8103 +index 7ba9f6a68645..1f5deea5a288 100644
8104 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
8105 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
8106 +@@ -2092,7 +2092,8 @@ static struct wireless_dev *brcmf_p2p_create_p2pdev(struct brcmf_p2p_info *p2p,
8107 + /* firmware requires unique mac address for p2pdev interface */
8108 + if (addr && ether_addr_equal(addr, pri_ifp->mac_addr)) {
8109 + bphy_err(drvr, "discovery vif must be different from primary interface\n");
8110 +- return ERR_PTR(-EINVAL);
8111 ++ err = -EINVAL;
8112 ++ goto fail;
8113 + }
8114 +
8115 + brcmf_p2p_generate_bss_mac(p2p, addr);
8116 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
8117 +index 264ad63232f8..a935993a3c51 100644
8118 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
8119 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
8120 +@@ -1935,6 +1935,7 @@ static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes)
8121 + BRCMF_SDIO_FT_NORMAL)) {
8122 + rd->len = 0;
8123 + brcmu_pkt_buf_free_skb(pkt);
8124 ++ continue;
8125 + }
8126 + bus->sdcnt.rx_readahead_cnt++;
8127 + if (rd->len != roundup(rd_new.len, 16)) {
8128 +@@ -4225,6 +4226,12 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
8129 + }
8130 +
8131 + if (err == 0) {
8132 ++ /* Assign bus interface call back */
8133 ++ sdiod->bus_if->dev = sdiod->dev;
8134 ++ sdiod->bus_if->ops = &brcmf_sdio_bus_ops;
8135 ++ sdiod->bus_if->chip = bus->ci->chip;
8136 ++ sdiod->bus_if->chiprev = bus->ci->chiprev;
8137 ++
8138 + /* Allow full data communication using DPC from now on. */
8139 + brcmf_sdiod_change_state(bus->sdiodev, BRCMF_SDIOD_DATA);
8140 +
8141 +@@ -4241,12 +4248,6 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
8142 +
8143 + sdio_release_host(sdiod->func1);
8144 +
8145 +- /* Assign bus interface call back */
8146 +- sdiod->bus_if->dev = sdiod->dev;
8147 +- sdiod->bus_if->ops = &brcmf_sdio_bus_ops;
8148 +- sdiod->bus_if->chip = bus->ci->chip;
8149 +- sdiod->bus_if->chiprev = bus->ci->chiprev;
8150 +-
8151 + err = brcmf_alloc(sdiod->dev, sdiod->settings);
8152 + if (err) {
8153 + brcmf_err("brcmf_alloc failed\n");
8154 +diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
8155 +index c4c83ab60cbc..0579554ed4b3 100644
8156 +--- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c
8157 ++++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
8158 +@@ -3206,8 +3206,9 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
8159 + }
8160 + }
8161 +
8162 +-static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
8163 ++static void ipw2100_irq_tasklet(unsigned long data)
8164 + {
8165 ++ struct ipw2100_priv *priv = (struct ipw2100_priv *)data;
8166 + struct net_device *dev = priv->net_dev;
8167 + unsigned long flags;
8168 + u32 inta, tmp;
8169 +@@ -6006,7 +6007,7 @@ static void ipw2100_rf_kill(struct work_struct *work)
8170 + spin_unlock_irqrestore(&priv->low_lock, flags);
8171 + }
8172 +
8173 +-static void ipw2100_irq_tasklet(struct ipw2100_priv *priv);
8174 ++static void ipw2100_irq_tasklet(unsigned long data);
8175 +
8176 + static const struct net_device_ops ipw2100_netdev_ops = {
8177 + .ndo_open = ipw2100_open,
8178 +@@ -6136,7 +6137,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
8179 + INIT_DELAYED_WORK(&priv->rf_kill, ipw2100_rf_kill);
8180 + INIT_DELAYED_WORK(&priv->scan_event, ipw2100_scan_event);
8181 +
8182 +- tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
8183 ++ tasklet_init(&priv->irq_tasklet,
8184 + ipw2100_irq_tasklet, (unsigned long)priv);
8185 +
8186 + /* NOTE: We do not start the deferred work for status checks yet */
8187 +diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
8188 +index 31e43fc1d12b..5ef6f87a48ac 100644
8189 +--- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c
8190 ++++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
8191 +@@ -1945,8 +1945,9 @@ static void notify_wx_assoc_event(struct ipw_priv *priv)
8192 + wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
8193 + }
8194 +
8195 +-static void ipw_irq_tasklet(struct ipw_priv *priv)
8196 ++static void ipw_irq_tasklet(unsigned long data)
8197 + {
8198 ++ struct ipw_priv *priv = (struct ipw_priv *)data;
8199 + u32 inta, inta_mask, handled = 0;
8200 + unsigned long flags;
8201 + int rc = 0;
8202 +@@ -10677,7 +10678,7 @@ static int ipw_setup_deferred_work(struct ipw_priv *priv)
8203 + INIT_WORK(&priv->qos_activate, ipw_bg_qos_activate);
8204 + #endif /* CONFIG_IPW2200_QOS */
8205 +
8206 +- tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
8207 ++ tasklet_init(&priv->irq_tasklet,
8208 + ipw_irq_tasklet, (unsigned long)priv);
8209 +
8210 + return ret;
8211 +diff --git a/drivers/net/wireless/intel/iwlegacy/3945-mac.c b/drivers/net/wireless/intel/iwlegacy/3945-mac.c
8212 +index 1168055da182..206b43b9dff8 100644
8213 +--- a/drivers/net/wireless/intel/iwlegacy/3945-mac.c
8214 ++++ b/drivers/net/wireless/intel/iwlegacy/3945-mac.c
8215 +@@ -1376,8 +1376,9 @@ il3945_dump_nic_error_log(struct il_priv *il)
8216 + }
8217 +
8218 + static void
8219 +-il3945_irq_tasklet(struct il_priv *il)
8220 ++il3945_irq_tasklet(unsigned long data)
8221 + {
8222 ++ struct il_priv *il = (struct il_priv *)data;
8223 + u32 inta, handled = 0;
8224 + u32 inta_fh;
8225 + unsigned long flags;
8226 +@@ -3401,7 +3402,7 @@ il3945_setup_deferred_work(struct il_priv *il)
8227 + timer_setup(&il->watchdog, il_bg_watchdog, 0);
8228 +
8229 + tasklet_init(&il->irq_tasklet,
8230 +- (void (*)(unsigned long))il3945_irq_tasklet,
8231 ++ il3945_irq_tasklet,
8232 + (unsigned long)il);
8233 + }
8234 +
8235 +diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
8236 +index 3664f56f8cbd..d1e17589dbeb 100644
8237 +--- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c
8238 ++++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
8239 +@@ -4343,8 +4343,9 @@ il4965_synchronize_irq(struct il_priv *il)
8240 + }
8241 +
8242 + static void
8243 +-il4965_irq_tasklet(struct il_priv *il)
8244 ++il4965_irq_tasklet(unsigned long data)
8245 + {
8246 ++ struct il_priv *il = (struct il_priv *)data;
8247 + u32 inta, handled = 0;
8248 + u32 inta_fh;
8249 + unsigned long flags;
8250 +@@ -6237,7 +6238,7 @@ il4965_setup_deferred_work(struct il_priv *il)
8251 + timer_setup(&il->watchdog, il_bg_watchdog, 0);
8252 +
8253 + tasklet_init(&il->irq_tasklet,
8254 +- (void (*)(unsigned long))il4965_irq_tasklet,
8255 ++ il4965_irq_tasklet,
8256 + (unsigned long)il);
8257 + }
8258 +
8259 +diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
8260 +index d966b29b45ee..348c17ce72f5 100644
8261 +--- a/drivers/net/wireless/intel/iwlegacy/common.c
8262 ++++ b/drivers/net/wireless/intel/iwlegacy/common.c
8263 +@@ -699,7 +699,7 @@ il_eeprom_init(struct il_priv *il)
8264 + u32 gp = _il_rd(il, CSR_EEPROM_GP);
8265 + int sz;
8266 + int ret;
8267 +- u16 addr;
8268 ++ int addr;
8269 +
8270 + /* allocate eeprom */
8271 + sz = il->cfg->eeprom_size;
8272 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
8273 +index efdf15f57f16..02df603b6400 100644
8274 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
8275 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
8276 +@@ -5,10 +5,9 @@
8277 + *
8278 + * GPL LICENSE SUMMARY
8279 + *
8280 +- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
8281 + * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
8282 + * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
8283 +- * Copyright(c) 2018 - 2019 Intel Corporation
8284 ++ * Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation
8285 + *
8286 + * This program is free software; you can redistribute it and/or modify
8287 + * it under the terms of version 2 of the GNU General Public License as
8288 +@@ -28,10 +27,9 @@
8289 + *
8290 + * BSD LICENSE
8291 + *
8292 +- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
8293 + * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
8294 + * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
8295 +- * Copyright(c) 2018 - 2019 Intel Corporation
8296 ++ * Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation
8297 + * All rights reserved.
8298 + *
8299 + * Redistribution and use in source and binary forms, with or without
8300 +@@ -2037,7 +2035,7 @@ static void iwl_mvm_cfg_he_sta(struct iwl_mvm *mvm,
8301 + rcu_read_lock();
8302 +
8303 + sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_ctxt_cmd.sta_id]);
8304 +- if (IS_ERR(sta)) {
8305 ++ if (IS_ERR_OR_NULL(sta)) {
8306 + rcu_read_unlock();
8307 + WARN(1, "Can't find STA to configure HE\n");
8308 + return;
8309 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
8310 +index b5a16f00bada..fcad25ffd811 100644
8311 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
8312 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
8313 +@@ -734,7 +734,8 @@ static struct thermal_zone_device_ops tzone_ops = {
8314 + static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
8315 + {
8316 + int i;
8317 +- char name[] = "iwlwifi";
8318 ++ char name[16];
8319 ++ static atomic_t counter = ATOMIC_INIT(0);
8320 +
8321 + if (!iwl_mvm_is_tt_in_fw(mvm)) {
8322 + mvm->tz_device.tzone = NULL;
8323 +@@ -744,6 +745,7 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
8324 +
8325 + BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH);
8326 +
8327 ++ sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF);
8328 + mvm->tz_device.tzone = thermal_zone_device_register(name,
8329 + IWL_MAX_DTS_TRIPS,
8330 + IWL_WRITABLE_TRIPS_MSK,
8331 +diff --git a/drivers/net/wireless/intersil/hostap/hostap_ap.c b/drivers/net/wireless/intersil/hostap/hostap_ap.c
8332 +index 0094b1d2b577..3ec46f48cfde 100644
8333 +--- a/drivers/net/wireless/intersil/hostap/hostap_ap.c
8334 ++++ b/drivers/net/wireless/intersil/hostap/hostap_ap.c
8335 +@@ -2508,7 +2508,7 @@ static int prism2_hostapd_add_sta(struct ap_data *ap,
8336 + sta->supported_rates[0] = 2;
8337 + if (sta->tx_supp_rates & WLAN_RATE_2M)
8338 + sta->supported_rates[1] = 4;
8339 +- if (sta->tx_supp_rates & WLAN_RATE_5M5)
8340 ++ if (sta->tx_supp_rates & WLAN_RATE_5M5)
8341 + sta->supported_rates[2] = 11;
8342 + if (sta->tx_supp_rates & WLAN_RATE_11M)
8343 + sta->supported_rates[3] = 22;
8344 +diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c
8345 +index 8c79b963bcff..e753f43e0162 100644
8346 +--- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c
8347 ++++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c
8348 +@@ -1361,7 +1361,8 @@ static int ezusb_init(struct hermes *hw)
8349 + int retval;
8350 +
8351 + BUG_ON(in_interrupt());
8352 +- BUG_ON(!upriv);
8353 ++ if (!upriv)
8354 ++ return -EINVAL;
8355 +
8356 + upriv->reply_count = 0;
8357 + /* Write the MAGIC number on the simulated registers to keep
8358 +diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
8359 +index f88d26535978..25335bd2873b 100644
8360 +--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
8361 ++++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
8362 +@@ -1061,13 +1061,15 @@ done:
8363 + return ret;
8364 + }
8365 +
8366 +-static void _rtl_pci_irq_tasklet(struct ieee80211_hw *hw)
8367 ++static void _rtl_pci_irq_tasklet(unsigned long data)
8368 + {
8369 ++ struct ieee80211_hw *hw = (struct ieee80211_hw *)data;
8370 + _rtl_pci_tx_chk_waitq(hw);
8371 + }
8372 +
8373 +-static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
8374 ++static void _rtl_pci_prepare_bcn_tasklet(unsigned long data)
8375 + {
8376 ++ struct ieee80211_hw *hw = (struct ieee80211_hw *)data;
8377 + struct rtl_priv *rtlpriv = rtl_priv(hw);
8378 + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
8379 + struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
8380 +@@ -1193,10 +1195,10 @@ static void _rtl_pci_init_struct(struct ieee80211_hw *hw,
8381 +
8382 + /*task */
8383 + tasklet_init(&rtlpriv->works.irq_tasklet,
8384 +- (void (*)(unsigned long))_rtl_pci_irq_tasklet,
8385 ++ _rtl_pci_irq_tasklet,
8386 + (unsigned long)hw);
8387 + tasklet_init(&rtlpriv->works.irq_prepare_bcn_tasklet,
8388 +- (void (*)(unsigned long))_rtl_pci_prepare_bcn_tasklet,
8389 ++ _rtl_pci_prepare_bcn_tasklet,
8390 + (unsigned long)hw);
8391 + INIT_WORK(&rtlpriv->works.lps_change_work,
8392 + rtl_lps_change_work_callback);
8393 +diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
8394 +index ae61415e1665..f369ddca953a 100644
8395 +--- a/drivers/net/wireless/realtek/rtw88/main.c
8396 ++++ b/drivers/net/wireless/realtek/rtw88/main.c
8397 +@@ -706,8 +706,8 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si)
8398 + if (sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80)
8399 + is_support_sgi = true;
8400 + } else if (sta->ht_cap.ht_supported) {
8401 +- ra_mask |= (sta->ht_cap.mcs.rx_mask[NL80211_BAND_5GHZ] << 20) |
8402 +- (sta->ht_cap.mcs.rx_mask[NL80211_BAND_2GHZ] << 12);
8403 ++ ra_mask |= (sta->ht_cap.mcs.rx_mask[1] << 20) |
8404 ++ (sta->ht_cap.mcs.rx_mask[0] << 12);
8405 + if (sta->ht_cap.cap & IEEE80211_HT_CAP_RX_STBC)
8406 + stbc_en = HT_STBC_EN;
8407 + if (sta->ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING)
8408 +@@ -717,6 +717,9 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si)
8409 + is_support_sgi = true;
8410 + }
8411 +
8412 ++ if (efuse->hw_cap.nss == 1)
8413 ++ ra_mask &= RA_MASK_VHT_RATES_1SS | RA_MASK_HT_RATES_1SS;
8414 ++
8415 + if (hal->current_band_type == RTW_BAND_5G) {
8416 + ra_mask |= (u64)sta->supp_rates[NL80211_BAND_5GHZ] << 4;
8417 + if (sta->vht_cap.vht_supported) {
8418 +@@ -750,11 +753,6 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si)
8419 + wireless_set = 0;
8420 + }
8421 +
8422 +- if (efuse->hw_cap.nss == 1) {
8423 +- ra_mask &= RA_MASK_VHT_RATES_1SS;
8424 +- ra_mask &= RA_MASK_HT_RATES_1SS;
8425 +- }
8426 +-
8427 + switch (sta->bandwidth) {
8428 + case IEEE80211_STA_RX_BW_80:
8429 + bw_mode = RTW_CHANNEL_WIDTH_80;
8430 +diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c
8431 +index a58e8276a41a..a6746b5a9ff2 100644
8432 +--- a/drivers/net/wireless/realtek/rtw88/pci.c
8433 ++++ b/drivers/net/wireless/realtek/rtw88/pci.c
8434 +@@ -832,6 +832,11 @@ static void rtw_pci_tx_isr(struct rtw_dev *rtwdev, struct rtw_pci *rtwpci,
8435 +
8436 + while (count--) {
8437 + skb = skb_dequeue(&ring->queue);
8438 ++ if (!skb) {
8439 ++ rtw_err(rtwdev, "failed to dequeue %d skb TX queue %d, BD=0x%08x, rp %d -> %d\n",
8440 ++ count, hw_queue, bd_idx, ring->r.rp, cur_rp);
8441 ++ break;
8442 ++ }
8443 + tx_data = rtw_pci_get_tx_data(skb);
8444 + pci_unmap_single(rtwpci->pdev, tx_data->dma, skb->len,
8445 + PCI_DMA_TODEVICE);
8446 +diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
8447 +index 604dba4f18af..8e4d355dc3ae 100644
8448 +--- a/drivers/nfc/port100.c
8449 ++++ b/drivers/nfc/port100.c
8450 +@@ -565,7 +565,7 @@ static void port100_tx_update_payload_len(void *_frame, int len)
8451 + {
8452 + struct port100_frame *frame = _frame;
8453 +
8454 +- frame->datalen = cpu_to_le16(le16_to_cpu(frame->datalen) + len);
8455 ++ le16_add_cpu(&frame->datalen, len);
8456 + }
8457 +
8458 + static bool port100_rx_frame_is_valid(void *_frame)
8459 +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
8460 +index 365a2ddbeaa7..da392b50f73e 100644
8461 +--- a/drivers/nvme/host/pci.c
8462 ++++ b/drivers/nvme/host/pci.c
8463 +@@ -167,7 +167,6 @@ struct nvme_queue {
8464 + /* only used for poll queues: */
8465 + spinlock_t cq_poll_lock ____cacheline_aligned_in_smp;
8466 + volatile struct nvme_completion *cqes;
8467 +- struct blk_mq_tags **tags;
8468 + dma_addr_t sq_dma_addr;
8469 + dma_addr_t cq_dma_addr;
8470 + u32 __iomem *q_db;
8471 +@@ -376,29 +375,17 @@ static int nvme_admin_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
8472 +
8473 + WARN_ON(hctx_idx != 0);
8474 + WARN_ON(dev->admin_tagset.tags[0] != hctx->tags);
8475 +- WARN_ON(nvmeq->tags);
8476 +
8477 + hctx->driver_data = nvmeq;
8478 +- nvmeq->tags = &dev->admin_tagset.tags[0];
8479 + return 0;
8480 + }
8481 +
8482 +-static void nvme_admin_exit_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx)
8483 +-{
8484 +- struct nvme_queue *nvmeq = hctx->driver_data;
8485 +-
8486 +- nvmeq->tags = NULL;
8487 +-}
8488 +-
8489 + static int nvme_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
8490 + unsigned int hctx_idx)
8491 + {
8492 + struct nvme_dev *dev = data;
8493 + struct nvme_queue *nvmeq = &dev->queues[hctx_idx + 1];
8494 +
8495 +- if (!nvmeq->tags)
8496 +- nvmeq->tags = &dev->tagset.tags[hctx_idx];
8497 +-
8498 + WARN_ON(dev->tagset.tags[hctx_idx] != hctx->tags);
8499 + hctx->driver_data = nvmeq;
8500 + return 0;
8501 +@@ -948,6 +935,13 @@ static inline void nvme_ring_cq_doorbell(struct nvme_queue *nvmeq)
8502 + writel(head, nvmeq->q_db + nvmeq->dev->db_stride);
8503 + }
8504 +
8505 ++static inline struct blk_mq_tags *nvme_queue_tagset(struct nvme_queue *nvmeq)
8506 ++{
8507 ++ if (!nvmeq->qid)
8508 ++ return nvmeq->dev->admin_tagset.tags[0];
8509 ++ return nvmeq->dev->tagset.tags[nvmeq->qid - 1];
8510 ++}
8511 ++
8512 + static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)
8513 + {
8514 + volatile struct nvme_completion *cqe = &nvmeq->cqes[idx];
8515 +@@ -972,7 +966,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)
8516 + return;
8517 + }
8518 +
8519 +- req = blk_mq_tag_to_rq(*nvmeq->tags, cqe->command_id);
8520 ++ req = blk_mq_tag_to_rq(nvme_queue_tagset(nvmeq), cqe->command_id);
8521 + trace_nvme_sq(req, cqe->sq_head, nvmeq->sq_tail);
8522 + nvme_end_request(req, cqe->status, cqe->result);
8523 + }
8524 +@@ -1572,7 +1566,6 @@ static const struct blk_mq_ops nvme_mq_admin_ops = {
8525 + .queue_rq = nvme_queue_rq,
8526 + .complete = nvme_pci_complete_rq,
8527 + .init_hctx = nvme_admin_init_hctx,
8528 +- .exit_hctx = nvme_admin_exit_hctx,
8529 + .init_request = nvme_init_request,
8530 + .timeout = nvme_timeout,
8531 + };
8532 +diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
8533 +index 28438b833c1b..461987f669c5 100644
8534 +--- a/drivers/nvme/target/core.c
8535 ++++ b/drivers/nvme/target/core.c
8536 +@@ -555,7 +555,8 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
8537 + } else {
8538 + struct nvmet_ns *old;
8539 +
8540 +- list_for_each_entry_rcu(old, &subsys->namespaces, dev_link) {
8541 ++ list_for_each_entry_rcu(old, &subsys->namespaces, dev_link,
8542 ++ lockdep_is_held(&subsys->lock)) {
8543 + BUG_ON(ns->nsid == old->nsid);
8544 + if (ns->nsid < old->nsid)
8545 + break;
8546 +@@ -938,6 +939,17 @@ bool nvmet_check_data_len(struct nvmet_req *req, size_t data_len)
8547 + }
8548 + EXPORT_SYMBOL_GPL(nvmet_check_data_len);
8549 +
8550 ++bool nvmet_check_data_len_lte(struct nvmet_req *req, size_t data_len)
8551 ++{
8552 ++ if (unlikely(data_len > req->transfer_len)) {
8553 ++ req->error_loc = offsetof(struct nvme_common_command, dptr);
8554 ++ nvmet_req_complete(req, NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR);
8555 ++ return false;
8556 ++ }
8557 ++
8558 ++ return true;
8559 ++}
8560 ++
8561 + int nvmet_req_alloc_sgl(struct nvmet_req *req)
8562 + {
8563 + struct pci_dev *p2p_dev = NULL;
8564 +@@ -1172,7 +1184,8 @@ static void nvmet_setup_p2p_ns_map(struct nvmet_ctrl *ctrl,
8565 +
8566 + ctrl->p2p_client = get_device(req->p2p_client);
8567 +
8568 +- list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link)
8569 ++ list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link,
8570 ++ lockdep_is_held(&ctrl->subsys->lock))
8571 + nvmet_p2pmem_ns_add_p2p(ctrl, ns);
8572 + }
8573 +
8574 +diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
8575 +index b6fca0e421ef..ea0e596be15d 100644
8576 +--- a/drivers/nvme/target/io-cmd-bdev.c
8577 ++++ b/drivers/nvme/target/io-cmd-bdev.c
8578 +@@ -280,7 +280,7 @@ static void nvmet_bdev_execute_discard(struct nvmet_req *req)
8579 +
8580 + static void nvmet_bdev_execute_dsm(struct nvmet_req *req)
8581 + {
8582 +- if (!nvmet_check_data_len(req, nvmet_dsm_len(req)))
8583 ++ if (!nvmet_check_data_len_lte(req, nvmet_dsm_len(req)))
8584 + return;
8585 +
8586 + switch (le32_to_cpu(req->cmd->dsm.attributes)) {
8587 +diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
8588 +index caebfce06605..cd5670b83118 100644
8589 +--- a/drivers/nvme/target/io-cmd-file.c
8590 ++++ b/drivers/nvme/target/io-cmd-file.c
8591 +@@ -336,7 +336,7 @@ static void nvmet_file_dsm_work(struct work_struct *w)
8592 +
8593 + static void nvmet_file_execute_dsm(struct nvmet_req *req)
8594 + {
8595 +- if (!nvmet_check_data_len(req, nvmet_dsm_len(req)))
8596 ++ if (!nvmet_check_data_len_lte(req, nvmet_dsm_len(req)))
8597 + return;
8598 + INIT_WORK(&req->f.work, nvmet_file_dsm_work);
8599 + schedule_work(&req->f.work);
8600 +diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
8601 +index 46df45e837c9..eda28b22a2c8 100644
8602 +--- a/drivers/nvme/target/nvmet.h
8603 ++++ b/drivers/nvme/target/nvmet.h
8604 +@@ -374,6 +374,7 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
8605 + struct nvmet_sq *sq, const struct nvmet_fabrics_ops *ops);
8606 + void nvmet_req_uninit(struct nvmet_req *req);
8607 + bool nvmet_check_data_len(struct nvmet_req *req, size_t data_len);
8608 ++bool nvmet_check_data_len_lte(struct nvmet_req *req, size_t data_len);
8609 + void nvmet_req_complete(struct nvmet_req *req, u16 status);
8610 + int nvmet_req_alloc_sgl(struct nvmet_req *req);
8611 + void nvmet_req_free_sgl(struct nvmet_req *req);
8612 +diff --git a/drivers/opp/of.c b/drivers/opp/of.c
8613 +index 1cbb58240b80..1e5fcdee043c 100644
8614 +--- a/drivers/opp/of.c
8615 ++++ b/drivers/opp/of.c
8616 +@@ -678,15 +678,17 @@ static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table)
8617 + dev_err(dev, "%s: Failed to add OPP, %d\n", __func__,
8618 + ret);
8619 + of_node_put(np);
8620 +- return ret;
8621 ++ goto put_list_kref;
8622 + } else if (opp) {
8623 + count++;
8624 + }
8625 + }
8626 +
8627 + /* There should be one of more OPP defined */
8628 +- if (WARN_ON(!count))
8629 +- return -ENOENT;
8630 ++ if (WARN_ON(!count)) {
8631 ++ ret = -ENOENT;
8632 ++ goto put_list_kref;
8633 ++ }
8634 +
8635 + list_for_each_entry(opp, &opp_table->opp_list, node)
8636 + pstate_count += !!opp->pstate;
8637 +@@ -695,7 +697,8 @@ static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table)
8638 + if (pstate_count && pstate_count != count) {
8639 + dev_err(dev, "Not all nodes have performance state set (%d: %d)\n",
8640 + count, pstate_count);
8641 +- return -ENOENT;
8642 ++ ret = -ENOENT;
8643 ++ goto put_list_kref;
8644 + }
8645 +
8646 + if (pstate_count)
8647 +@@ -704,6 +707,11 @@ static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table)
8648 + opp_table->parsed_static_opps = true;
8649 +
8650 + return 0;
8651 ++
8652 ++put_list_kref:
8653 ++ _put_opp_list_kref(opp_table);
8654 ++
8655 ++ return ret;
8656 + }
8657 +
8658 + /* Initializes OPP tables based on old-deprecated bindings */
8659 +@@ -738,6 +746,7 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
8660 + if (ret) {
8661 + dev_err(dev, "%s: Failed to add OPP %ld (%d)\n",
8662 + __func__, freq, ret);
8663 ++ _put_opp_list_kref(opp_table);
8664 + return ret;
8665 + }
8666 + nr -= 2;
8667 +diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
8668 +index b6f064c885c3..3ef0bb281e7c 100644
8669 +--- a/drivers/pci/ats.c
8670 ++++ b/drivers/pci/ats.c
8671 +@@ -69,6 +69,7 @@ int pci_enable_ats(struct pci_dev *dev, int ps)
8672 + dev->ats_enabled = 1;
8673 + return 0;
8674 + }
8675 ++EXPORT_SYMBOL_GPL(pci_enable_ats);
8676 +
8677 + /**
8678 + * pci_disable_ats - disable the ATS capability
8679 +@@ -87,6 +88,7 @@ void pci_disable_ats(struct pci_dev *dev)
8680 +
8681 + dev->ats_enabled = 0;
8682 + }
8683 ++EXPORT_SYMBOL_GPL(pci_disable_ats);
8684 +
8685 + void pci_restore_ats_state(struct pci_dev *dev)
8686 + {
8687 +diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c
8688 +index 0a468c73bae3..8c7f875acf7f 100644
8689 +--- a/drivers/pci/controller/pcie-iproc.c
8690 ++++ b/drivers/pci/controller/pcie-iproc.c
8691 +@@ -1588,6 +1588,30 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0xd802,
8692 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0xd804,
8693 + quirk_paxc_disable_msi_parsing);
8694 +
8695 ++static void quirk_paxc_bridge(struct pci_dev *pdev)
8696 ++{
8697 ++ /*
8698 ++ * The PCI config space is shared with the PAXC root port and the first
8699 ++ * Ethernet device. So, we need to workaround this by telling the PCI
8700 ++ * code that the bridge is not an Ethernet device.
8701 ++ */
8702 ++ if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE)
8703 ++ pdev->class = PCI_CLASS_BRIDGE_PCI << 8;
8704 ++
8705 ++ /*
8706 ++ * MPSS is not being set properly (as it is currently 0). This is
8707 ++ * because that area of the PCI config space is hard coded to zero, and
8708 ++ * is not modifiable by firmware. Set this to 2 (e.g., 512 byte MPS)
8709 ++ * so that the MPS can be set to the real max value.
8710 ++ */
8711 ++ pdev->pcie_mpss = 2;
8712 ++}
8713 ++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x16cd, quirk_paxc_bridge);
8714 ++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x16f0, quirk_paxc_bridge);
8715 ++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0xd750, quirk_paxc_bridge);
8716 ++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0xd802, quirk_paxc_bridge);
8717 ++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0xd804, quirk_paxc_bridge);
8718 ++
8719 + MODULE_AUTHOR("Ray Jui <rjui@××××××××.com>");
8720 + MODULE_DESCRIPTION("Broadcom iPROC PCIe common driver");
8721 + MODULE_LICENSE("GPL v2");
8722 +diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
8723 +index e87196cc1a7f..951099279192 100644
8724 +--- a/drivers/pci/pci.c
8725 ++++ b/drivers/pci/pci.c
8726 +@@ -5998,7 +5998,8 @@ EXPORT_SYMBOL_GPL(pci_pr3_present);
8727 + /**
8728 + * pci_add_dma_alias - Add a DMA devfn alias for a device
8729 + * @dev: the PCI device for which alias is added
8730 +- * @devfn: alias slot and function
8731 ++ * @devfn_from: alias slot and function
8732 ++ * @nr_devfns: number of subsequent devfns to alias
8733 + *
8734 + * This helper encodes an 8-bit devfn as a bit number in dma_alias_mask
8735 + * which is used to program permissible bus-devfn source addresses for DMA
8736 +@@ -6014,18 +6015,29 @@ EXPORT_SYMBOL_GPL(pci_pr3_present);
8737 + * cannot be left as a userspace activity). DMA aliases should therefore
8738 + * be configured via quirks, such as the PCI fixup header quirk.
8739 + */
8740 +-void pci_add_dma_alias(struct pci_dev *dev, u8 devfn)
8741 ++void pci_add_dma_alias(struct pci_dev *dev, u8 devfn_from, unsigned nr_devfns)
8742 + {
8743 ++ int devfn_to;
8744 ++
8745 ++ nr_devfns = min(nr_devfns, (unsigned) MAX_NR_DEVFNS - devfn_from);
8746 ++ devfn_to = devfn_from + nr_devfns - 1;
8747 ++
8748 + if (!dev->dma_alias_mask)
8749 +- dev->dma_alias_mask = bitmap_zalloc(U8_MAX, GFP_KERNEL);
8750 ++ dev->dma_alias_mask = bitmap_zalloc(MAX_NR_DEVFNS, GFP_KERNEL);
8751 + if (!dev->dma_alias_mask) {
8752 + pci_warn(dev, "Unable to allocate DMA alias mask\n");
8753 + return;
8754 + }
8755 +
8756 +- set_bit(devfn, dev->dma_alias_mask);
8757 +- pci_info(dev, "Enabling fixed DMA alias to %02x.%d\n",
8758 +- PCI_SLOT(devfn), PCI_FUNC(devfn));
8759 ++ bitmap_set(dev->dma_alias_mask, devfn_from, nr_devfns);
8760 ++
8761 ++ if (nr_devfns == 1)
8762 ++ pci_info(dev, "Enabling fixed DMA alias to %02x.%d\n",
8763 ++ PCI_SLOT(devfn_from), PCI_FUNC(devfn_from));
8764 ++ else if (nr_devfns > 1)
8765 ++ pci_info(dev, "Enabling fixed DMA alias for devfn range from %02x.%d to %02x.%d\n",
8766 ++ PCI_SLOT(devfn_from), PCI_FUNC(devfn_from),
8767 ++ PCI_SLOT(devfn_to), PCI_FUNC(devfn_to));
8768 + }
8769 +
8770 + bool pci_devs_are_dma_aliases(struct pci_dev *dev1, struct pci_dev *dev2)
8771 +diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
8772 +index a0a53bd05a0b..6394e7746fb5 100644
8773 +--- a/drivers/pci/pci.h
8774 ++++ b/drivers/pci/pci.h
8775 +@@ -4,6 +4,9 @@
8776 +
8777 + #include <linux/pci.h>
8778 +
8779 ++/* Number of possible devfns: 0.0 to 1f.7 inclusive */
8780 ++#define MAX_NR_DEVFNS 256
8781 ++
8782 + #define PCI_FIND_CAP_TTL 48
8783 +
8784 + #define PCI_VSEC_ID_INTEL_TBT 0x1234 /* Thunderbolt */
8785 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
8786 +index fbeb9f73ef28..83953752337c 100644
8787 +--- a/drivers/pci/quirks.c
8788 ++++ b/drivers/pci/quirks.c
8789 +@@ -1871,19 +1871,40 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2609, quirk_intel_pcie_pm);
8790 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260a, quirk_intel_pcie_pm);
8791 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260b, quirk_intel_pcie_pm);
8792 +
8793 ++static void quirk_d3hot_delay(struct pci_dev *dev, unsigned int delay)
8794 ++{
8795 ++ if (dev->d3_delay >= delay)
8796 ++ return;
8797 ++
8798 ++ dev->d3_delay = delay;
8799 ++ pci_info(dev, "extending delay after power-on from D3hot to %d msec\n",
8800 ++ dev->d3_delay);
8801 ++}
8802 ++
8803 + static void quirk_radeon_pm(struct pci_dev *dev)
8804 + {
8805 + if (dev->subsystem_vendor == PCI_VENDOR_ID_APPLE &&
8806 +- dev->subsystem_device == 0x00e2) {
8807 +- if (dev->d3_delay < 20) {
8808 +- dev->d3_delay = 20;
8809 +- pci_info(dev, "extending delay after power-on from D3 to %d msec\n",
8810 +- dev->d3_delay);
8811 +- }
8812 +- }
8813 ++ dev->subsystem_device == 0x00e2)
8814 ++ quirk_d3hot_delay(dev, 20);
8815 + }
8816 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6741, quirk_radeon_pm);
8817 +
8818 ++/*
8819 ++ * Ryzen5/7 XHCI controllers fail upon resume from runtime suspend or s2idle.
8820 ++ * https://bugzilla.kernel.org/show_bug.cgi?id=205587
8821 ++ *
8822 ++ * The kernel attempts to transition these devices to D3cold, but that seems
8823 ++ * to be ineffective on the platforms in question; the PCI device appears to
8824 ++ * remain on in D3hot state. The D3hot-to-D0 transition then requires an
8825 ++ * extended delay in order to succeed.
8826 ++ */
8827 ++static void quirk_ryzen_xhci_d3hot(struct pci_dev *dev)
8828 ++{
8829 ++ quirk_d3hot_delay(dev, 20);
8830 ++}
8831 ++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15e0, quirk_ryzen_xhci_d3hot);
8832 ++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15e1, quirk_ryzen_xhci_d3hot);
8833 ++
8834 + #ifdef CONFIG_X86_IO_APIC
8835 + static int dmi_disable_ioapicreroute(const struct dmi_system_id *d)
8836 + {
8837 +@@ -2381,32 +2402,6 @@ DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_BROADCOM,
8838 + PCI_DEVICE_ID_TIGON3_5719,
8839 + quirk_brcm_5719_limit_mrrs);
8840 +
8841 +-#ifdef CONFIG_PCIE_IPROC_PLATFORM
8842 +-static void quirk_paxc_bridge(struct pci_dev *pdev)
8843 +-{
8844 +- /*
8845 +- * The PCI config space is shared with the PAXC root port and the first
8846 +- * Ethernet device. So, we need to workaround this by telling the PCI
8847 +- * code that the bridge is not an Ethernet device.
8848 +- */
8849 +- if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE)
8850 +- pdev->class = PCI_CLASS_BRIDGE_PCI << 8;
8851 +-
8852 +- /*
8853 +- * MPSS is not being set properly (as it is currently 0). This is
8854 +- * because that area of the PCI config space is hard coded to zero, and
8855 +- * is not modifiable by firmware. Set this to 2 (e.g., 512 byte MPS)
8856 +- * so that the MPS can be set to the real max value.
8857 +- */
8858 +- pdev->pcie_mpss = 2;
8859 +-}
8860 +-DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x16cd, quirk_paxc_bridge);
8861 +-DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x16f0, quirk_paxc_bridge);
8862 +-DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0xd750, quirk_paxc_bridge);
8863 +-DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0xd802, quirk_paxc_bridge);
8864 +-DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0xd804, quirk_paxc_bridge);
8865 +-#endif
8866 +-
8867 + /*
8868 + * Originally in EDAC sources for i82875P: Intel tells BIOS developers to
8869 + * hide device 6 which configures the overflow device access containing the
8870 +@@ -3932,7 +3927,7 @@ int pci_dev_specific_reset(struct pci_dev *dev, int probe)
8871 + static void quirk_dma_func0_alias(struct pci_dev *dev)
8872 + {
8873 + if (PCI_FUNC(dev->devfn) != 0)
8874 +- pci_add_dma_alias(dev, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
8875 ++ pci_add_dma_alias(dev, PCI_DEVFN(PCI_SLOT(dev->devfn), 0), 1);
8876 + }
8877 +
8878 + /*
8879 +@@ -3946,7 +3941,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_RICOH, 0xe476, quirk_dma_func0_alias);
8880 + static void quirk_dma_func1_alias(struct pci_dev *dev)
8881 + {
8882 + if (PCI_FUNC(dev->devfn) != 1)
8883 +- pci_add_dma_alias(dev, PCI_DEVFN(PCI_SLOT(dev->devfn), 1));
8884 ++ pci_add_dma_alias(dev, PCI_DEVFN(PCI_SLOT(dev->devfn), 1), 1);
8885 + }
8886 +
8887 + /*
8888 +@@ -4031,7 +4026,7 @@ static void quirk_fixed_dma_alias(struct pci_dev *dev)
8889 +
8890 + id = pci_match_id(fixed_dma_alias_tbl, dev);
8891 + if (id)
8892 +- pci_add_dma_alias(dev, id->driver_data);
8893 ++ pci_add_dma_alias(dev, id->driver_data, 1);
8894 + }
8895 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ADAPTEC2, 0x0285, quirk_fixed_dma_alias);
8896 +
8897 +@@ -4072,9 +4067,9 @@ DECLARE_PCI_FIXUP_HEADER(0x8086, 0x244e, quirk_use_pcie_bridge_dma_alias);
8898 + */
8899 + static void quirk_mic_x200_dma_alias(struct pci_dev *pdev)
8900 + {
8901 +- pci_add_dma_alias(pdev, PCI_DEVFN(0x10, 0x0));
8902 +- pci_add_dma_alias(pdev, PCI_DEVFN(0x11, 0x0));
8903 +- pci_add_dma_alias(pdev, PCI_DEVFN(0x12, 0x3));
8904 ++ pci_add_dma_alias(pdev, PCI_DEVFN(0x10, 0x0), 1);
8905 ++ pci_add_dma_alias(pdev, PCI_DEVFN(0x11, 0x0), 1);
8906 ++ pci_add_dma_alias(pdev, PCI_DEVFN(0x12, 0x3), 1);
8907 + }
8908 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2260, quirk_mic_x200_dma_alias);
8909 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2264, quirk_mic_x200_dma_alias);
8910 +@@ -4098,13 +4093,8 @@ static void quirk_pex_vca_alias(struct pci_dev *pdev)
8911 + const unsigned int num_pci_slots = 0x20;
8912 + unsigned int slot;
8913 +
8914 +- for (slot = 0; slot < num_pci_slots; slot++) {
8915 +- pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x0));
8916 +- pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x1));
8917 +- pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x2));
8918 +- pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x3));
8919 +- pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x4));
8920 +- }
8921 ++ for (slot = 0; slot < num_pci_slots; slot++)
8922 ++ pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x0), 5);
8923 + }
8924 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2954, quirk_pex_vca_alias);
8925 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2955, quirk_pex_vca_alias);
8926 +@@ -5339,7 +5329,7 @@ static void quirk_switchtec_ntb_dma_alias(struct pci_dev *pdev)
8927 + pci_dbg(pdev,
8928 + "Aliasing Partition %d Proxy ID %02x.%d\n",
8929 + pp, PCI_SLOT(devfn), PCI_FUNC(devfn));
8930 +- pci_add_dma_alias(pdev, devfn);
8931 ++ pci_add_dma_alias(pdev, devfn, 1);
8932 + }
8933 + }
8934 +
8935 +@@ -5381,6 +5371,21 @@ SWITCHTEC_QUIRK(0x8574); /* PFXI 64XG3 */
8936 + SWITCHTEC_QUIRK(0x8575); /* PFXI 80XG3 */
8937 + SWITCHTEC_QUIRK(0x8576); /* PFXI 96XG3 */
8938 +
8939 ++/*
8940 ++ * The PLX NTB uses devfn proxy IDs to move TLPs between NT endpoints.
8941 ++ * These IDs are used to forward responses to the originator on the other
8942 ++ * side of the NTB. Alias all possible IDs to the NTB to permit access when
8943 ++ * the IOMMU is turned on.
8944 ++ */
8945 ++static void quirk_plx_ntb_dma_alias(struct pci_dev *pdev)
8946 ++{
8947 ++ pci_info(pdev, "Setting PLX NTB proxy ID aliases\n");
8948 ++ /* PLX NTB may use all 256 devfns */
8949 ++ pci_add_dma_alias(pdev, 0, 256);
8950 ++}
8951 ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PLX, 0x87b0, quirk_plx_ntb_dma_alias);
8952 ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PLX, 0x87b1, quirk_plx_ntb_dma_alias);
8953 ++
8954 + /*
8955 + * On Lenovo Thinkpad P50 SKUs with a Nvidia Quadro M1000M, the BIOS does
8956 + * not always reset the secondary Nvidia GPU between reboots if the system
8957 +diff --git a/drivers/pci/search.c b/drivers/pci/search.c
8958 +index bade14002fd8..e4dbdef5aef0 100644
8959 +--- a/drivers/pci/search.c
8960 ++++ b/drivers/pci/search.c
8961 +@@ -41,9 +41,9 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
8962 + * DMA, iterate over that too.
8963 + */
8964 + if (unlikely(pdev->dma_alias_mask)) {
8965 +- u8 devfn;
8966 ++ unsigned int devfn;
8967 +
8968 +- for_each_set_bit(devfn, pdev->dma_alias_mask, U8_MAX) {
8969 ++ for_each_set_bit(devfn, pdev->dma_alias_mask, MAX_NR_DEVFNS) {
8970 + ret = fn(pdev, PCI_DEVID(pdev->bus->number, devfn),
8971 + data);
8972 + if (ret)
8973 +diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c
8974 +index 55083c67b2bb..95dca2cb5265 100644
8975 +--- a/drivers/perf/fsl_imx8_ddr_perf.c
8976 ++++ b/drivers/perf/fsl_imx8_ddr_perf.c
8977 +@@ -633,13 +633,17 @@ static int ddr_perf_probe(struct platform_device *pdev)
8978 +
8979 + if (ret < 0) {
8980 + dev_err(&pdev->dev, "cpuhp_setup_state_multi failed\n");
8981 +- goto ddr_perf_err;
8982 ++ goto cpuhp_state_err;
8983 + }
8984 +
8985 + pmu->cpuhp_state = ret;
8986 +
8987 + /* Register the pmu instance for cpu hotplug */
8988 +- cpuhp_state_add_instance_nocalls(pmu->cpuhp_state, &pmu->node);
8989 ++ ret = cpuhp_state_add_instance_nocalls(pmu->cpuhp_state, &pmu->node);
8990 ++ if (ret) {
8991 ++ dev_err(&pdev->dev, "Error %d registering hotplug\n", ret);
8992 ++ goto cpuhp_instance_err;
8993 ++ }
8994 +
8995 + /* Request irq */
8996 + irq = of_irq_get(np, 0);
8997 +@@ -673,9 +677,10 @@ static int ddr_perf_probe(struct platform_device *pdev)
8998 + return 0;
8999 +
9000 + ddr_perf_err:
9001 +- if (pmu->cpuhp_state)
9002 +- cpuhp_state_remove_instance_nocalls(pmu->cpuhp_state, &pmu->node);
9003 +-
9004 ++ cpuhp_state_remove_instance_nocalls(pmu->cpuhp_state, &pmu->node);
9005 ++cpuhp_instance_err:
9006 ++ cpuhp_remove_multi_state(pmu->cpuhp_state);
9007 ++cpuhp_state_err:
9008 + ida_simple_remove(&ddr_ida, pmu->id);
9009 + dev_warn(&pdev->dev, "i.MX8 DDR Perf PMU failed (%d), disabled\n", ret);
9010 + return ret;
9011 +@@ -686,6 +691,7 @@ static int ddr_perf_remove(struct platform_device *pdev)
9012 + struct ddr_pmu *pmu = platform_get_drvdata(pdev);
9013 +
9014 + cpuhp_state_remove_instance_nocalls(pmu->cpuhp_state, &pmu->node);
9015 ++ cpuhp_remove_multi_state(pmu->cpuhp_state);
9016 + irq_set_affinity_hint(pmu->irq, NULL);
9017 +
9018 + perf_pmu_unregister(&pmu->pmu);
9019 +diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
9020 +index 72ffd19448e5..ce9cf50121bd 100644
9021 +--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
9022 ++++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
9023 +@@ -753,7 +753,13 @@ static void byt_gpio_clear_triggering(struct byt_gpio *vg, unsigned int offset)
9024 +
9025 + raw_spin_lock_irqsave(&byt_lock, flags);
9026 + value = readl(reg);
9027 +- value &= ~(BYT_TRIG_POS | BYT_TRIG_NEG | BYT_TRIG_LVL);
9028 ++
9029 ++ /* Do not clear direct-irq enabled IRQs (from gpio_disable_free) */
9030 ++ if (value & BYT_DIRECT_IRQ_EN)
9031 ++ /* nothing to do */ ;
9032 ++ else
9033 ++ value &= ~(BYT_TRIG_POS | BYT_TRIG_NEG | BYT_TRIG_LVL);
9034 ++
9035 + writel(value, reg);
9036 + raw_spin_unlock_irqrestore(&byt_lock, flags);
9037 + }
9038 +diff --git a/drivers/pinctrl/intel/pinctrl-tigerlake.c b/drivers/pinctrl/intel/pinctrl-tigerlake.c
9039 +index 58572b15b3ce..08a86f6fdea6 100644
9040 +--- a/drivers/pinctrl/intel/pinctrl-tigerlake.c
9041 ++++ b/drivers/pinctrl/intel/pinctrl-tigerlake.c
9042 +@@ -2,7 +2,7 @@
9043 + /*
9044 + * Intel Tiger Lake PCH pinctrl/GPIO driver
9045 + *
9046 +- * Copyright (C) 2019, Intel Corporation
9047 ++ * Copyright (C) 2019 - 2020, Intel Corporation
9048 + * Authors: Andy Shevchenko <andriy.shevchenko@×××××××××××.com>
9049 + * Mika Westerberg <mika.westerberg@×××××××××××.com>
9050 + */
9051 +@@ -21,15 +21,19 @@
9052 + #define TGL_GPI_IS 0x100
9053 + #define TGL_GPI_IE 0x120
9054 +
9055 +-#define TGL_GPP(r, s, e) \
9056 ++#define TGL_NO_GPIO -1
9057 ++
9058 ++#define TGL_GPP(r, s, e, g) \
9059 + { \
9060 + .reg_num = (r), \
9061 + .base = (s), \
9062 + .size = ((e) - (s) + 1), \
9063 ++ .gpio_base = (g), \
9064 + }
9065 +
9066 +-#define TGL_COMMUNITY(s, e, g) \
9067 ++#define TGL_COMMUNITY(b, s, e, g) \
9068 + { \
9069 ++ .barno = (b), \
9070 + .padown_offset = TGL_PAD_OWN, \
9071 + .padcfglock_offset = TGL_PADCFGLOCK, \
9072 + .hostown_offset = TGL_HOSTSW_OWN, \
9073 +@@ -42,7 +46,7 @@
9074 + }
9075 +
9076 + /* Tiger Lake-LP */
9077 +-static const struct pinctrl_pin_desc tgllp_community0_pins[] = {
9078 ++static const struct pinctrl_pin_desc tgllp_pins[] = {
9079 + /* GPP_B */
9080 + PINCTRL_PIN(0, "CORE_VID_0"),
9081 + PINCTRL_PIN(1, "CORE_VID_1"),
9082 +@@ -113,324 +117,273 @@ static const struct pinctrl_pin_desc tgllp_community0_pins[] = {
9083 + PINCTRL_PIN(64, "GPPC_A_22"),
9084 + PINCTRL_PIN(65, "I2S1_SCLK"),
9085 + PINCTRL_PIN(66, "ESPI_CLK_LOOPBK"),
9086 +-};
9087 +-
9088 +-static const struct intel_padgroup tgllp_community0_gpps[] = {
9089 +- TGL_GPP(0, 0, 25), /* GPP_B */
9090 +- TGL_GPP(1, 26, 41), /* GPP_T */
9091 +- TGL_GPP(2, 42, 66), /* GPP_A */
9092 +-};
9093 +-
9094 +-static const struct intel_community tgllp_community0[] = {
9095 +- TGL_COMMUNITY(0, 66, tgllp_community0_gpps),
9096 +-};
9097 +-
9098 +-static const struct intel_pinctrl_soc_data tgllp_community0_soc_data = {
9099 +- .uid = "0",
9100 +- .pins = tgllp_community0_pins,
9101 +- .npins = ARRAY_SIZE(tgllp_community0_pins),
9102 +- .communities = tgllp_community0,
9103 +- .ncommunities = ARRAY_SIZE(tgllp_community0),
9104 +-};
9105 +-
9106 +-static const struct pinctrl_pin_desc tgllp_community1_pins[] = {
9107 + /* GPP_S */
9108 +- PINCTRL_PIN(0, "SNDW0_CLK"),
9109 +- PINCTRL_PIN(1, "SNDW0_DATA"),
9110 +- PINCTRL_PIN(2, "SNDW1_CLK"),
9111 +- PINCTRL_PIN(3, "SNDW1_DATA"),
9112 +- PINCTRL_PIN(4, "SNDW2_CLK"),
9113 +- PINCTRL_PIN(5, "SNDW2_DATA"),
9114 +- PINCTRL_PIN(6, "SNDW3_CLK"),
9115 +- PINCTRL_PIN(7, "SNDW3_DATA"),
9116 ++ PINCTRL_PIN(67, "SNDW0_CLK"),
9117 ++ PINCTRL_PIN(68, "SNDW0_DATA"),
9118 ++ PINCTRL_PIN(69, "SNDW1_CLK"),
9119 ++ PINCTRL_PIN(70, "SNDW1_DATA"),
9120 ++ PINCTRL_PIN(71, "SNDW2_CLK"),
9121 ++ PINCTRL_PIN(72, "SNDW2_DATA"),
9122 ++ PINCTRL_PIN(73, "SNDW3_CLK"),
9123 ++ PINCTRL_PIN(74, "SNDW3_DATA"),
9124 + /* GPP_H */
9125 +- PINCTRL_PIN(8, "GPPC_H_0"),
9126 +- PINCTRL_PIN(9, "GPPC_H_1"),
9127 +- PINCTRL_PIN(10, "GPPC_H_2"),
9128 +- PINCTRL_PIN(11, "SX_EXIT_HOLDOFFB"),
9129 +- PINCTRL_PIN(12, "I2C2_SDA"),
9130 +- PINCTRL_PIN(13, "I2C2_SCL"),
9131 +- PINCTRL_PIN(14, "I2C3_SDA"),
9132 +- PINCTRL_PIN(15, "I2C3_SCL"),
9133 +- PINCTRL_PIN(16, "I2C4_SDA"),
9134 +- PINCTRL_PIN(17, "I2C4_SCL"),
9135 +- PINCTRL_PIN(18, "SRCCLKREQB_4"),
9136 +- PINCTRL_PIN(19, "SRCCLKREQB_5"),
9137 +- PINCTRL_PIN(20, "M2_SKT2_CFG_0"),
9138 +- PINCTRL_PIN(21, "M2_SKT2_CFG_1"),
9139 +- PINCTRL_PIN(22, "M2_SKT2_CFG_2"),
9140 +- PINCTRL_PIN(23, "M2_SKT2_CFG_3"),
9141 +- PINCTRL_PIN(24, "DDPB_CTRLCLK"),
9142 +- PINCTRL_PIN(25, "DDPB_CTRLDATA"),
9143 +- PINCTRL_PIN(26, "CPU_C10_GATEB"),
9144 +- PINCTRL_PIN(27, "TIME_SYNC_0"),
9145 +- PINCTRL_PIN(28, "IMGCLKOUT_1"),
9146 +- PINCTRL_PIN(29, "IMGCLKOUT_2"),
9147 +- PINCTRL_PIN(30, "IMGCLKOUT_3"),
9148 +- PINCTRL_PIN(31, "IMGCLKOUT_4"),
9149 ++ PINCTRL_PIN(75, "GPPC_H_0"),
9150 ++ PINCTRL_PIN(76, "GPPC_H_1"),
9151 ++ PINCTRL_PIN(77, "GPPC_H_2"),
9152 ++ PINCTRL_PIN(78, "SX_EXIT_HOLDOFFB"),
9153 ++ PINCTRL_PIN(79, "I2C2_SDA"),
9154 ++ PINCTRL_PIN(80, "I2C2_SCL"),
9155 ++ PINCTRL_PIN(81, "I2C3_SDA"),
9156 ++ PINCTRL_PIN(82, "I2C3_SCL"),
9157 ++ PINCTRL_PIN(83, "I2C4_SDA"),
9158 ++ PINCTRL_PIN(84, "I2C4_SCL"),
9159 ++ PINCTRL_PIN(85, "SRCCLKREQB_4"),
9160 ++ PINCTRL_PIN(86, "SRCCLKREQB_5"),
9161 ++ PINCTRL_PIN(87, "M2_SKT2_CFG_0"),
9162 ++ PINCTRL_PIN(88, "M2_SKT2_CFG_1"),
9163 ++ PINCTRL_PIN(89, "M2_SKT2_CFG_2"),
9164 ++ PINCTRL_PIN(90, "M2_SKT2_CFG_3"),
9165 ++ PINCTRL_PIN(91, "DDPB_CTRLCLK"),
9166 ++ PINCTRL_PIN(92, "DDPB_CTRLDATA"),
9167 ++ PINCTRL_PIN(93, "CPU_C10_GATEB"),
9168 ++ PINCTRL_PIN(94, "TIME_SYNC_0"),
9169 ++ PINCTRL_PIN(95, "IMGCLKOUT_1"),
9170 ++ PINCTRL_PIN(96, "IMGCLKOUT_2"),
9171 ++ PINCTRL_PIN(97, "IMGCLKOUT_3"),
9172 ++ PINCTRL_PIN(98, "IMGCLKOUT_4"),
9173 + /* GPP_D */
9174 +- PINCTRL_PIN(32, "ISH_GP_0"),
9175 +- PINCTRL_PIN(33, "ISH_GP_1"),
9176 +- PINCTRL_PIN(34, "ISH_GP_2"),
9177 +- PINCTRL_PIN(35, "ISH_GP_3"),
9178 +- PINCTRL_PIN(36, "IMGCLKOUT_0"),
9179 +- PINCTRL_PIN(37, "SRCCLKREQB_0"),
9180 +- PINCTRL_PIN(38, "SRCCLKREQB_1"),
9181 +- PINCTRL_PIN(39, "SRCCLKREQB_2"),
9182 +- PINCTRL_PIN(40, "SRCCLKREQB_3"),
9183 +- PINCTRL_PIN(41, "ISH_SPI_CSB"),
9184 +- PINCTRL_PIN(42, "ISH_SPI_CLK"),
9185 +- PINCTRL_PIN(43, "ISH_SPI_MISO"),
9186 +- PINCTRL_PIN(44, "ISH_SPI_MOSI"),
9187 +- PINCTRL_PIN(45, "ISH_UART0_RXD"),
9188 +- PINCTRL_PIN(46, "ISH_UART0_TXD"),
9189 +- PINCTRL_PIN(47, "ISH_UART0_RTSB"),
9190 +- PINCTRL_PIN(48, "ISH_UART0_CTSB"),
9191 +- PINCTRL_PIN(49, "ISH_GP_4"),
9192 +- PINCTRL_PIN(50, "ISH_GP_5"),
9193 +- PINCTRL_PIN(51, "I2S_MCLK1_OUT"),
9194 +- PINCTRL_PIN(52, "GSPI2_CLK_LOOPBK"),
9195 ++ PINCTRL_PIN(99, "ISH_GP_0"),
9196 ++ PINCTRL_PIN(100, "ISH_GP_1"),
9197 ++ PINCTRL_PIN(101, "ISH_GP_2"),
9198 ++ PINCTRL_PIN(102, "ISH_GP_3"),
9199 ++ PINCTRL_PIN(103, "IMGCLKOUT_0"),
9200 ++ PINCTRL_PIN(104, "SRCCLKREQB_0"),
9201 ++ PINCTRL_PIN(105, "SRCCLKREQB_1"),
9202 ++ PINCTRL_PIN(106, "SRCCLKREQB_2"),
9203 ++ PINCTRL_PIN(107, "SRCCLKREQB_3"),
9204 ++ PINCTRL_PIN(108, "ISH_SPI_CSB"),
9205 ++ PINCTRL_PIN(109, "ISH_SPI_CLK"),
9206 ++ PINCTRL_PIN(110, "ISH_SPI_MISO"),
9207 ++ PINCTRL_PIN(111, "ISH_SPI_MOSI"),
9208 ++ PINCTRL_PIN(112, "ISH_UART0_RXD"),
9209 ++ PINCTRL_PIN(113, "ISH_UART0_TXD"),
9210 ++ PINCTRL_PIN(114, "ISH_UART0_RTSB"),
9211 ++ PINCTRL_PIN(115, "ISH_UART0_CTSB"),
9212 ++ PINCTRL_PIN(116, "ISH_GP_4"),
9213 ++ PINCTRL_PIN(117, "ISH_GP_5"),
9214 ++ PINCTRL_PIN(118, "I2S_MCLK1_OUT"),
9215 ++ PINCTRL_PIN(119, "GSPI2_CLK_LOOPBK"),
9216 + /* GPP_U */
9217 +- PINCTRL_PIN(53, "UART3_RXD"),
9218 +- PINCTRL_PIN(54, "UART3_TXD"),
9219 +- PINCTRL_PIN(55, "UART3_RTSB"),
9220 +- PINCTRL_PIN(56, "UART3_CTSB"),
9221 +- PINCTRL_PIN(57, "GSPI3_CS0B"),
9222 +- PINCTRL_PIN(58, "GSPI3_CLK"),
9223 +- PINCTRL_PIN(59, "GSPI3_MISO"),
9224 +- PINCTRL_PIN(60, "GSPI3_MOSI"),
9225 +- PINCTRL_PIN(61, "GSPI4_CS0B"),
9226 +- PINCTRL_PIN(62, "GSPI4_CLK"),
9227 +- PINCTRL_PIN(63, "GSPI4_MISO"),
9228 +- PINCTRL_PIN(64, "GSPI4_MOSI"),
9229 +- PINCTRL_PIN(65, "GSPI5_CS0B"),
9230 +- PINCTRL_PIN(66, "GSPI5_CLK"),
9231 +- PINCTRL_PIN(67, "GSPI5_MISO"),
9232 +- PINCTRL_PIN(68, "GSPI5_MOSI"),
9233 +- PINCTRL_PIN(69, "GSPI6_CS0B"),
9234 +- PINCTRL_PIN(70, "GSPI6_CLK"),
9235 +- PINCTRL_PIN(71, "GSPI6_MISO"),
9236 +- PINCTRL_PIN(72, "GSPI6_MOSI"),
9237 +- PINCTRL_PIN(73, "GSPI3_CLK_LOOPBK"),
9238 +- PINCTRL_PIN(74, "GSPI4_CLK_LOOPBK"),
9239 +- PINCTRL_PIN(75, "GSPI5_CLK_LOOPBK"),
9240 +- PINCTRL_PIN(76, "GSPI6_CLK_LOOPBK"),
9241 ++ PINCTRL_PIN(120, "UART3_RXD"),
9242 ++ PINCTRL_PIN(121, "UART3_TXD"),
9243 ++ PINCTRL_PIN(122, "UART3_RTSB"),
9244 ++ PINCTRL_PIN(123, "UART3_CTSB"),
9245 ++ PINCTRL_PIN(124, "GSPI3_CS0B"),
9246 ++ PINCTRL_PIN(125, "GSPI3_CLK"),
9247 ++ PINCTRL_PIN(126, "GSPI3_MISO"),
9248 ++ PINCTRL_PIN(127, "GSPI3_MOSI"),
9249 ++ PINCTRL_PIN(128, "GSPI4_CS0B"),
9250 ++ PINCTRL_PIN(129, "GSPI4_CLK"),
9251 ++ PINCTRL_PIN(130, "GSPI4_MISO"),
9252 ++ PINCTRL_PIN(131, "GSPI4_MOSI"),
9253 ++ PINCTRL_PIN(132, "GSPI5_CS0B"),
9254 ++ PINCTRL_PIN(133, "GSPI5_CLK"),
9255 ++ PINCTRL_PIN(134, "GSPI5_MISO"),
9256 ++ PINCTRL_PIN(135, "GSPI5_MOSI"),
9257 ++ PINCTRL_PIN(136, "GSPI6_CS0B"),
9258 ++ PINCTRL_PIN(137, "GSPI6_CLK"),
9259 ++ PINCTRL_PIN(138, "GSPI6_MISO"),
9260 ++ PINCTRL_PIN(139, "GSPI6_MOSI"),
9261 ++ PINCTRL_PIN(140, "GSPI3_CLK_LOOPBK"),
9262 ++ PINCTRL_PIN(141, "GSPI4_CLK_LOOPBK"),
9263 ++ PINCTRL_PIN(142, "GSPI5_CLK_LOOPBK"),
9264 ++ PINCTRL_PIN(143, "GSPI6_CLK_LOOPBK"),
9265 + /* vGPIO */
9266 +- PINCTRL_PIN(77, "CNV_BTEN"),
9267 +- PINCTRL_PIN(78, "CNV_BT_HOST_WAKEB"),
9268 +- PINCTRL_PIN(79, "CNV_BT_IF_SELECT"),
9269 +- PINCTRL_PIN(80, "vCNV_BT_UART_TXD"),
9270 +- PINCTRL_PIN(81, "vCNV_BT_UART_RXD"),
9271 +- PINCTRL_PIN(82, "vCNV_BT_UART_CTS_B"),
9272 +- PINCTRL_PIN(83, "vCNV_BT_UART_RTS_B"),
9273 +- PINCTRL_PIN(84, "vCNV_MFUART1_TXD"),
9274 +- PINCTRL_PIN(85, "vCNV_MFUART1_RXD"),
9275 +- PINCTRL_PIN(86, "vCNV_MFUART1_CTS_B"),
9276 +- PINCTRL_PIN(87, "vCNV_MFUART1_RTS_B"),
9277 +- PINCTRL_PIN(88, "vUART0_TXD"),
9278 +- PINCTRL_PIN(89, "vUART0_RXD"),
9279 +- PINCTRL_PIN(90, "vUART0_CTS_B"),
9280 +- PINCTRL_PIN(91, "vUART0_RTS_B"),
9281 +- PINCTRL_PIN(92, "vISH_UART0_TXD"),
9282 +- PINCTRL_PIN(93, "vISH_UART0_RXD"),
9283 +- PINCTRL_PIN(94, "vISH_UART0_CTS_B"),
9284 +- PINCTRL_PIN(95, "vISH_UART0_RTS_B"),
9285 +- PINCTRL_PIN(96, "vCNV_BT_I2S_BCLK"),
9286 +- PINCTRL_PIN(97, "vCNV_BT_I2S_WS_SYNC"),
9287 +- PINCTRL_PIN(98, "vCNV_BT_I2S_SDO"),
9288 +- PINCTRL_PIN(99, "vCNV_BT_I2S_SDI"),
9289 +- PINCTRL_PIN(100, "vI2S2_SCLK"),
9290 +- PINCTRL_PIN(101, "vI2S2_SFRM"),
9291 +- PINCTRL_PIN(102, "vI2S2_TXD"),
9292 +- PINCTRL_PIN(103, "vI2S2_RXD"),
9293 +-};
9294 +-
9295 +-static const struct intel_padgroup tgllp_community1_gpps[] = {
9296 +- TGL_GPP(0, 0, 7), /* GPP_S */
9297 +- TGL_GPP(1, 8, 31), /* GPP_H */
9298 +- TGL_GPP(2, 32, 52), /* GPP_D */
9299 +- TGL_GPP(3, 53, 76), /* GPP_U */
9300 +- TGL_GPP(4, 77, 103), /* vGPIO */
9301 +-};
9302 +-
9303 +-static const struct intel_community tgllp_community1[] = {
9304 +- TGL_COMMUNITY(0, 103, tgllp_community1_gpps),
9305 +-};
9306 +-
9307 +-static const struct intel_pinctrl_soc_data tgllp_community1_soc_data = {
9308 +- .uid = "1",
9309 +- .pins = tgllp_community1_pins,
9310 +- .npins = ARRAY_SIZE(tgllp_community1_pins),
9311 +- .communities = tgllp_community1,
9312 +- .ncommunities = ARRAY_SIZE(tgllp_community1),
9313 +-};
9314 +-
9315 +-static const struct pinctrl_pin_desc tgllp_community4_pins[] = {
9316 ++ PINCTRL_PIN(144, "CNV_BTEN"),
9317 ++ PINCTRL_PIN(145, "CNV_BT_HOST_WAKEB"),
9318 ++ PINCTRL_PIN(146, "CNV_BT_IF_SELECT"),
9319 ++ PINCTRL_PIN(147, "vCNV_BT_UART_TXD"),
9320 ++ PINCTRL_PIN(148, "vCNV_BT_UART_RXD"),
9321 ++ PINCTRL_PIN(149, "vCNV_BT_UART_CTS_B"),
9322 ++ PINCTRL_PIN(150, "vCNV_BT_UART_RTS_B"),
9323 ++ PINCTRL_PIN(151, "vCNV_MFUART1_TXD"),
9324 ++ PINCTRL_PIN(152, "vCNV_MFUART1_RXD"),
9325 ++ PINCTRL_PIN(153, "vCNV_MFUART1_CTS_B"),
9326 ++ PINCTRL_PIN(154, "vCNV_MFUART1_RTS_B"),
9327 ++ PINCTRL_PIN(155, "vUART0_TXD"),
9328 ++ PINCTRL_PIN(156, "vUART0_RXD"),
9329 ++ PINCTRL_PIN(157, "vUART0_CTS_B"),
9330 ++ PINCTRL_PIN(158, "vUART0_RTS_B"),
9331 ++ PINCTRL_PIN(159, "vISH_UART0_TXD"),
9332 ++ PINCTRL_PIN(160, "vISH_UART0_RXD"),
9333 ++ PINCTRL_PIN(161, "vISH_UART0_CTS_B"),
9334 ++ PINCTRL_PIN(162, "vISH_UART0_RTS_B"),
9335 ++ PINCTRL_PIN(163, "vCNV_BT_I2S_BCLK"),
9336 ++ PINCTRL_PIN(164, "vCNV_BT_I2S_WS_SYNC"),
9337 ++ PINCTRL_PIN(165, "vCNV_BT_I2S_SDO"),
9338 ++ PINCTRL_PIN(166, "vCNV_BT_I2S_SDI"),
9339 ++ PINCTRL_PIN(167, "vI2S2_SCLK"),
9340 ++ PINCTRL_PIN(168, "vI2S2_SFRM"),
9341 ++ PINCTRL_PIN(169, "vI2S2_TXD"),
9342 ++ PINCTRL_PIN(170, "vI2S2_RXD"),
9343 + /* GPP_C */
9344 +- PINCTRL_PIN(0, "SMBCLK"),
9345 +- PINCTRL_PIN(1, "SMBDATA"),
9346 +- PINCTRL_PIN(2, "SMBALERTB"),
9347 +- PINCTRL_PIN(3, "SML0CLK"),
9348 +- PINCTRL_PIN(4, "SML0DATA"),
9349 +- PINCTRL_PIN(5, "SML0ALERTB"),
9350 +- PINCTRL_PIN(6, "SML1CLK"),
9351 +- PINCTRL_PIN(7, "SML1DATA"),
9352 +- PINCTRL_PIN(8, "UART0_RXD"),
9353 +- PINCTRL_PIN(9, "UART0_TXD"),
9354 +- PINCTRL_PIN(10, "UART0_RTSB"),
9355 +- PINCTRL_PIN(11, "UART0_CTSB"),
9356 +- PINCTRL_PIN(12, "UART1_RXD"),
9357 +- PINCTRL_PIN(13, "UART1_TXD"),
9358 +- PINCTRL_PIN(14, "UART1_RTSB"),
9359 +- PINCTRL_PIN(15, "UART1_CTSB"),
9360 +- PINCTRL_PIN(16, "I2C0_SDA"),
9361 +- PINCTRL_PIN(17, "I2C0_SCL"),
9362 +- PINCTRL_PIN(18, "I2C1_SDA"),
9363 +- PINCTRL_PIN(19, "I2C1_SCL"),
9364 +- PINCTRL_PIN(20, "UART2_RXD"),
9365 +- PINCTRL_PIN(21, "UART2_TXD"),
9366 +- PINCTRL_PIN(22, "UART2_RTSB"),
9367 +- PINCTRL_PIN(23, "UART2_CTSB"),
9368 ++ PINCTRL_PIN(171, "SMBCLK"),
9369 ++ PINCTRL_PIN(172, "SMBDATA"),
9370 ++ PINCTRL_PIN(173, "SMBALERTB"),
9371 ++ PINCTRL_PIN(174, "SML0CLK"),
9372 ++ PINCTRL_PIN(175, "SML0DATA"),
9373 ++ PINCTRL_PIN(176, "SML0ALERTB"),
9374 ++ PINCTRL_PIN(177, "SML1CLK"),
9375 ++ PINCTRL_PIN(178, "SML1DATA"),
9376 ++ PINCTRL_PIN(179, "UART0_RXD"),
9377 ++ PINCTRL_PIN(180, "UART0_TXD"),
9378 ++ PINCTRL_PIN(181, "UART0_RTSB"),
9379 ++ PINCTRL_PIN(182, "UART0_CTSB"),
9380 ++ PINCTRL_PIN(183, "UART1_RXD"),
9381 ++ PINCTRL_PIN(184, "UART1_TXD"),
9382 ++ PINCTRL_PIN(185, "UART1_RTSB"),
9383 ++ PINCTRL_PIN(186, "UART1_CTSB"),
9384 ++ PINCTRL_PIN(187, "I2C0_SDA"),
9385 ++ PINCTRL_PIN(188, "I2C0_SCL"),
9386 ++ PINCTRL_PIN(189, "I2C1_SDA"),
9387 ++ PINCTRL_PIN(190, "I2C1_SCL"),
9388 ++ PINCTRL_PIN(191, "UART2_RXD"),
9389 ++ PINCTRL_PIN(192, "UART2_TXD"),
9390 ++ PINCTRL_PIN(193, "UART2_RTSB"),
9391 ++ PINCTRL_PIN(194, "UART2_CTSB"),
9392 + /* GPP_F */
9393 +- PINCTRL_PIN(24, "CNV_BRI_DT"),
9394 +- PINCTRL_PIN(25, "CNV_BRI_RSP"),
9395 +- PINCTRL_PIN(26, "CNV_RGI_DT"),
9396 +- PINCTRL_PIN(27, "CNV_RGI_RSP"),
9397 +- PINCTRL_PIN(28, "CNV_RF_RESET_B"),
9398 +- PINCTRL_PIN(29, "GPPC_F_5"),
9399 +- PINCTRL_PIN(30, "CNV_PA_BLANKING"),
9400 +- PINCTRL_PIN(31, "GPPC_F_7"),
9401 +- PINCTRL_PIN(32, "I2S_MCLK2_INOUT"),
9402 +- PINCTRL_PIN(33, "BOOTMPC"),
9403 +- PINCTRL_PIN(34, "GPPC_F_10"),
9404 +- PINCTRL_PIN(35, "GPPC_F_11"),
9405 +- PINCTRL_PIN(36, "GSXDOUT"),
9406 +- PINCTRL_PIN(37, "GSXSLOAD"),
9407 +- PINCTRL_PIN(38, "GSXDIN"),
9408 +- PINCTRL_PIN(39, "GSXSRESETB"),
9409 +- PINCTRL_PIN(40, "GSXCLK"),
9410 +- PINCTRL_PIN(41, "GMII_MDC"),
9411 +- PINCTRL_PIN(42, "GMII_MDIO"),
9412 +- PINCTRL_PIN(43, "SRCCLKREQB_6"),
9413 +- PINCTRL_PIN(44, "EXT_PWR_GATEB"),
9414 +- PINCTRL_PIN(45, "EXT_PWR_GATE2B"),
9415 +- PINCTRL_PIN(46, "VNN_CTRL"),
9416 +- PINCTRL_PIN(47, "V1P05_CTRL"),
9417 +- PINCTRL_PIN(48, "GPPF_CLK_LOOPBACK"),
9418 ++ PINCTRL_PIN(195, "CNV_BRI_DT"),
9419 ++ PINCTRL_PIN(196, "CNV_BRI_RSP"),
9420 ++ PINCTRL_PIN(197, "CNV_RGI_DT"),
9421 ++ PINCTRL_PIN(198, "CNV_RGI_RSP"),
9422 ++ PINCTRL_PIN(199, "CNV_RF_RESET_B"),
9423 ++ PINCTRL_PIN(200, "GPPC_F_5"),
9424 ++ PINCTRL_PIN(201, "CNV_PA_BLANKING"),
9425 ++ PINCTRL_PIN(202, "GPPC_F_7"),
9426 ++ PINCTRL_PIN(203, "I2S_MCLK2_INOUT"),
9427 ++ PINCTRL_PIN(204, "BOOTMPC"),
9428 ++ PINCTRL_PIN(205, "GPPC_F_10"),
9429 ++ PINCTRL_PIN(206, "GPPC_F_11"),
9430 ++ PINCTRL_PIN(207, "GSXDOUT"),
9431 ++ PINCTRL_PIN(208, "GSXSLOAD"),
9432 ++ PINCTRL_PIN(209, "GSXDIN"),
9433 ++ PINCTRL_PIN(210, "GSXSRESETB"),
9434 ++ PINCTRL_PIN(211, "GSXCLK"),
9435 ++ PINCTRL_PIN(212, "GMII_MDC"),
9436 ++ PINCTRL_PIN(213, "GMII_MDIO"),
9437 ++ PINCTRL_PIN(214, "SRCCLKREQB_6"),
9438 ++ PINCTRL_PIN(215, "EXT_PWR_GATEB"),
9439 ++ PINCTRL_PIN(216, "EXT_PWR_GATE2B"),
9440 ++ PINCTRL_PIN(217, "VNN_CTRL"),
9441 ++ PINCTRL_PIN(218, "V1P05_CTRL"),
9442 ++ PINCTRL_PIN(219, "GPPF_CLK_LOOPBACK"),
9443 + /* HVCMOS */
9444 +- PINCTRL_PIN(49, "L_BKLTEN"),
9445 +- PINCTRL_PIN(50, "L_BKLTCTL"),
9446 +- PINCTRL_PIN(51, "L_VDDEN"),
9447 +- PINCTRL_PIN(52, "SYS_PWROK"),
9448 +- PINCTRL_PIN(53, "SYS_RESETB"),
9449 +- PINCTRL_PIN(54, "MLK_RSTB"),
9450 ++ PINCTRL_PIN(220, "L_BKLTEN"),
9451 ++ PINCTRL_PIN(221, "L_BKLTCTL"),
9452 ++ PINCTRL_PIN(222, "L_VDDEN"),
9453 ++ PINCTRL_PIN(223, "SYS_PWROK"),
9454 ++ PINCTRL_PIN(224, "SYS_RESETB"),
9455 ++ PINCTRL_PIN(225, "MLK_RSTB"),
9456 + /* GPP_E */
9457 +- PINCTRL_PIN(55, "SATAXPCIE_0"),
9458 +- PINCTRL_PIN(56, "SPI1_IO_2"),
9459 +- PINCTRL_PIN(57, "SPI1_IO_3"),
9460 +- PINCTRL_PIN(58, "CPU_GP_0"),
9461 +- PINCTRL_PIN(59, "SATA_DEVSLP_0"),
9462 +- PINCTRL_PIN(60, "SATA_DEVSLP_1"),
9463 +- PINCTRL_PIN(61, "GPPC_E_6"),
9464 +- PINCTRL_PIN(62, "CPU_GP_1"),
9465 +- PINCTRL_PIN(63, "SPI1_CS1B"),
9466 +- PINCTRL_PIN(64, "USB2_OCB_0"),
9467 +- PINCTRL_PIN(65, "SPI1_CSB"),
9468 +- PINCTRL_PIN(66, "SPI1_CLK"),
9469 +- PINCTRL_PIN(67, "SPI1_MISO_IO_1"),
9470 +- PINCTRL_PIN(68, "SPI1_MOSI_IO_0"),
9471 +- PINCTRL_PIN(69, "DDSP_HPD_A"),
9472 +- PINCTRL_PIN(70, "ISH_GP_6"),
9473 +- PINCTRL_PIN(71, "ISH_GP_7"),
9474 +- PINCTRL_PIN(72, "GPPC_E_17"),
9475 +- PINCTRL_PIN(73, "DDP1_CTRLCLK"),
9476 +- PINCTRL_PIN(74, "DDP1_CTRLDATA"),
9477 +- PINCTRL_PIN(75, "DDP2_CTRLCLK"),
9478 +- PINCTRL_PIN(76, "DDP2_CTRLDATA"),
9479 +- PINCTRL_PIN(77, "DDPA_CTRLCLK"),
9480 +- PINCTRL_PIN(78, "DDPA_CTRLDATA"),
9481 +- PINCTRL_PIN(79, "SPI1_CLK_LOOPBK"),
9482 ++ PINCTRL_PIN(226, "SATAXPCIE_0"),
9483 ++ PINCTRL_PIN(227, "SPI1_IO_2"),
9484 ++ PINCTRL_PIN(228, "SPI1_IO_3"),
9485 ++ PINCTRL_PIN(229, "CPU_GP_0"),
9486 ++ PINCTRL_PIN(230, "SATA_DEVSLP_0"),
9487 ++ PINCTRL_PIN(231, "SATA_DEVSLP_1"),
9488 ++ PINCTRL_PIN(232, "GPPC_E_6"),
9489 ++ PINCTRL_PIN(233, "CPU_GP_1"),
9490 ++ PINCTRL_PIN(234, "SPI1_CS1B"),
9491 ++ PINCTRL_PIN(235, "USB2_OCB_0"),
9492 ++ PINCTRL_PIN(236, "SPI1_CSB"),
9493 ++ PINCTRL_PIN(237, "SPI1_CLK"),
9494 ++ PINCTRL_PIN(238, "SPI1_MISO_IO_1"),
9495 ++ PINCTRL_PIN(239, "SPI1_MOSI_IO_0"),
9496 ++ PINCTRL_PIN(240, "DDSP_HPD_A"),
9497 ++ PINCTRL_PIN(241, "ISH_GP_6"),
9498 ++ PINCTRL_PIN(242, "ISH_GP_7"),
9499 ++ PINCTRL_PIN(243, "GPPC_E_17"),
9500 ++ PINCTRL_PIN(244, "DDP1_CTRLCLK"),
9501 ++ PINCTRL_PIN(245, "DDP1_CTRLDATA"),
9502 ++ PINCTRL_PIN(246, "DDP2_CTRLCLK"),
9503 ++ PINCTRL_PIN(247, "DDP2_CTRLDATA"),
9504 ++ PINCTRL_PIN(248, "DDPA_CTRLCLK"),
9505 ++ PINCTRL_PIN(249, "DDPA_CTRLDATA"),
9506 ++ PINCTRL_PIN(250, "SPI1_CLK_LOOPBK"),
9507 + /* JTAG */
9508 +- PINCTRL_PIN(80, "JTAG_TDO"),
9509 +- PINCTRL_PIN(81, "JTAGX"),
9510 +- PINCTRL_PIN(82, "PRDYB"),
9511 +- PINCTRL_PIN(83, "PREQB"),
9512 +- PINCTRL_PIN(84, "CPU_TRSTB"),
9513 +- PINCTRL_PIN(85, "JTAG_TDI"),
9514 +- PINCTRL_PIN(86, "JTAG_TMS"),
9515 +- PINCTRL_PIN(87, "JTAG_TCK"),
9516 +- PINCTRL_PIN(88, "DBG_PMODE"),
9517 +-};
9518 +-
9519 +-static const struct intel_padgroup tgllp_community4_gpps[] = {
9520 +- TGL_GPP(0, 0, 23), /* GPP_C */
9521 +- TGL_GPP(1, 24, 48), /* GPP_F */
9522 +- TGL_GPP(2, 49, 54), /* HVCMOS */
9523 +- TGL_GPP(3, 55, 79), /* GPP_E */
9524 +- TGL_GPP(4, 80, 88), /* JTAG */
9525 ++ PINCTRL_PIN(251, "JTAG_TDO"),
9526 ++ PINCTRL_PIN(252, "JTAGX"),
9527 ++ PINCTRL_PIN(253, "PRDYB"),
9528 ++ PINCTRL_PIN(254, "PREQB"),
9529 ++ PINCTRL_PIN(255, "CPU_TRSTB"),
9530 ++ PINCTRL_PIN(256, "JTAG_TDI"),
9531 ++ PINCTRL_PIN(257, "JTAG_TMS"),
9532 ++ PINCTRL_PIN(258, "JTAG_TCK"),
9533 ++ PINCTRL_PIN(259, "DBG_PMODE"),
9534 ++ /* GPP_R */
9535 ++ PINCTRL_PIN(260, "HDA_BCLK"),
9536 ++ PINCTRL_PIN(261, "HDA_SYNC"),
9537 ++ PINCTRL_PIN(262, "HDA_SDO"),
9538 ++ PINCTRL_PIN(263, "HDA_SDI_0"),
9539 ++ PINCTRL_PIN(264, "HDA_RSTB"),
9540 ++ PINCTRL_PIN(265, "HDA_SDI_1"),
9541 ++ PINCTRL_PIN(266, "GPP_R_6"),
9542 ++ PINCTRL_PIN(267, "GPP_R_7"),
9543 ++ /* SPI */
9544 ++ PINCTRL_PIN(268, "SPI0_IO_2"),
9545 ++ PINCTRL_PIN(269, "SPI0_IO_3"),
9546 ++ PINCTRL_PIN(270, "SPI0_MOSI_IO_0"),
9547 ++ PINCTRL_PIN(271, "SPI0_MISO_IO_1"),
9548 ++ PINCTRL_PIN(272, "SPI0_TPM_CSB"),
9549 ++ PINCTRL_PIN(273, "SPI0_FLASH_0_CSB"),
9550 ++ PINCTRL_PIN(274, "SPI0_FLASH_1_CSB"),
9551 ++ PINCTRL_PIN(275, "SPI0_CLK"),
9552 ++ PINCTRL_PIN(276, "SPI0_CLK_LOOPBK"),
9553 + };
9554 +
9555 +-static const struct intel_community tgllp_community4[] = {
9556 +- TGL_COMMUNITY(0, 88, tgllp_community4_gpps),
9557 ++static const struct intel_padgroup tgllp_community0_gpps[] = {
9558 ++ TGL_GPP(0, 0, 25, 0), /* GPP_B */
9559 ++ TGL_GPP(1, 26, 41, 32), /* GPP_T */
9560 ++ TGL_GPP(2, 42, 66, 64), /* GPP_A */
9561 + };
9562 +
9563 +-static const struct intel_pinctrl_soc_data tgllp_community4_soc_data = {
9564 +- .uid = "4",
9565 +- .pins = tgllp_community4_pins,
9566 +- .npins = ARRAY_SIZE(tgllp_community4_pins),
9567 +- .communities = tgllp_community4,
9568 +- .ncommunities = ARRAY_SIZE(tgllp_community4),
9569 ++static const struct intel_padgroup tgllp_community1_gpps[] = {
9570 ++ TGL_GPP(0, 67, 74, 96), /* GPP_S */
9571 ++ TGL_GPP(1, 75, 98, 128), /* GPP_H */
9572 ++ TGL_GPP(2, 99, 119, 160), /* GPP_D */
9573 ++ TGL_GPP(3, 120, 143, 192), /* GPP_U */
9574 ++ TGL_GPP(4, 144, 170, 224), /* vGPIO */
9575 + };
9576 +
9577 +-static const struct pinctrl_pin_desc tgllp_community5_pins[] = {
9578 +- /* GPP_R */
9579 +- PINCTRL_PIN(0, "HDA_BCLK"),
9580 +- PINCTRL_PIN(1, "HDA_SYNC"),
9581 +- PINCTRL_PIN(2, "HDA_SDO"),
9582 +- PINCTRL_PIN(3, "HDA_SDI_0"),
9583 +- PINCTRL_PIN(4, "HDA_RSTB"),
9584 +- PINCTRL_PIN(5, "HDA_SDI_1"),
9585 +- PINCTRL_PIN(6, "GPP_R_6"),
9586 +- PINCTRL_PIN(7, "GPP_R_7"),
9587 +- /* SPI */
9588 +- PINCTRL_PIN(8, "SPI0_IO_2"),
9589 +- PINCTRL_PIN(9, "SPI0_IO_3"),
9590 +- PINCTRL_PIN(10, "SPI0_MOSI_IO_0"),
9591 +- PINCTRL_PIN(11, "SPI0_MISO_IO_1"),
9592 +- PINCTRL_PIN(12, "SPI0_TPM_CSB"),
9593 +- PINCTRL_PIN(13, "SPI0_FLASH_0_CSB"),
9594 +- PINCTRL_PIN(14, "SPI0_FLASH_1_CSB"),
9595 +- PINCTRL_PIN(15, "SPI0_CLK"),
9596 +- PINCTRL_PIN(16, "SPI0_CLK_LOOPBK"),
9597 ++static const struct intel_padgroup tgllp_community4_gpps[] = {
9598 ++ TGL_GPP(0, 171, 194, 256), /* GPP_C */
9599 ++ TGL_GPP(1, 195, 219, 288), /* GPP_F */
9600 ++ TGL_GPP(2, 220, 225, TGL_NO_GPIO), /* HVCMOS */
9601 ++ TGL_GPP(3, 226, 250, 320), /* GPP_E */
9602 ++ TGL_GPP(4, 251, 259, TGL_NO_GPIO), /* JTAG */
9603 + };
9604 +
9605 + static const struct intel_padgroup tgllp_community5_gpps[] = {
9606 +- TGL_GPP(0, 0, 7), /* GPP_R */
9607 +- TGL_GPP(1, 8, 16), /* SPI */
9608 +-};
9609 +-
9610 +-static const struct intel_community tgllp_community5[] = {
9611 +- TGL_COMMUNITY(0, 16, tgllp_community5_gpps),
9612 ++ TGL_GPP(0, 260, 267, 352), /* GPP_R */
9613 ++ TGL_GPP(1, 268, 276, TGL_NO_GPIO), /* SPI */
9614 + };
9615 +
9616 +-static const struct intel_pinctrl_soc_data tgllp_community5_soc_data = {
9617 +- .uid = "5",
9618 +- .pins = tgllp_community5_pins,
9619 +- .npins = ARRAY_SIZE(tgllp_community5_pins),
9620 +- .communities = tgllp_community5,
9621 +- .ncommunities = ARRAY_SIZE(tgllp_community5),
9622 ++static const struct intel_community tgllp_communities[] = {
9623 ++ TGL_COMMUNITY(0, 0, 66, tgllp_community0_gpps),
9624 ++ TGL_COMMUNITY(1, 67, 170, tgllp_community1_gpps),
9625 ++ TGL_COMMUNITY(2, 171, 259, tgllp_community4_gpps),
9626 ++ TGL_COMMUNITY(3, 260, 276, tgllp_community5_gpps),
9627 + };
9628 +
9629 +-static const struct intel_pinctrl_soc_data *tgllp_soc_data_array[] = {
9630 +- &tgllp_community0_soc_data,
9631 +- &tgllp_community1_soc_data,
9632 +- &tgllp_community4_soc_data,
9633 +- &tgllp_community5_soc_data,
9634 +- NULL
9635 ++static const struct intel_pinctrl_soc_data tgllp_soc_data = {
9636 ++ .pins = tgllp_pins,
9637 ++ .npins = ARRAY_SIZE(tgllp_pins),
9638 ++ .communities = tgllp_communities,
9639 ++ .ncommunities = ARRAY_SIZE(tgllp_communities),
9640 + };
9641 +
9642 + static const struct acpi_device_id tgl_pinctrl_acpi_match[] = {
9643 +- { "INT34C5", (kernel_ulong_t)tgllp_soc_data_array },
9644 ++ { "INT34C5", (kernel_ulong_t)&tgllp_soc_data },
9645 + { }
9646 + };
9647 + MODULE_DEVICE_TABLE(acpi, tgl_pinctrl_acpi_match);
9648 +@@ -438,7 +391,7 @@ MODULE_DEVICE_TABLE(acpi, tgl_pinctrl_acpi_match);
9649 + static INTEL_PINCTRL_PM_OPS(tgl_pinctrl_pm_ops);
9650 +
9651 + static struct platform_driver tgl_pinctrl_driver = {
9652 +- .probe = intel_pinctrl_probe_by_uid,
9653 ++ .probe = intel_pinctrl_probe_by_hid,
9654 + .driver = {
9655 + .name = "tigerlake-pinctrl",
9656 + .acpi_match_table = tgl_pinctrl_acpi_match,
9657 +diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7264.c b/drivers/pinctrl/sh-pfc/pfc-sh7264.c
9658 +index 4a95867deb8a..5a026601d4f9 100644
9659 +--- a/drivers/pinctrl/sh-pfc/pfc-sh7264.c
9660 ++++ b/drivers/pinctrl/sh-pfc/pfc-sh7264.c
9661 +@@ -497,17 +497,15 @@ enum {
9662 + SD_WP_MARK, SD_CLK_MARK, SD_CMD_MARK,
9663 + CRX0_MARK, CRX1_MARK,
9664 + CTX0_MARK, CTX1_MARK,
9665 ++ CRX0_CRX1_MARK, CTX0_CTX1_MARK,
9666 +
9667 + PWM1A_MARK, PWM1B_MARK, PWM1C_MARK, PWM1D_MARK,
9668 + PWM1E_MARK, PWM1F_MARK, PWM1G_MARK, PWM1H_MARK,
9669 + PWM2A_MARK, PWM2B_MARK, PWM2C_MARK, PWM2D_MARK,
9670 + PWM2E_MARK, PWM2F_MARK, PWM2G_MARK, PWM2H_MARK,
9671 + IERXD_MARK, IETXD_MARK,
9672 +- CRX0_CRX1_MARK,
9673 + WDTOVF_MARK,
9674 +
9675 +- CRX0X1_MARK,
9676 +-
9677 + /* DMAC */
9678 + TEND0_MARK, DACK0_MARK, DREQ0_MARK,
9679 + TEND1_MARK, DACK1_MARK, DREQ1_MARK,
9680 +@@ -995,12 +993,12 @@ static const u16 pinmux_data[] = {
9681 +
9682 + PINMUX_DATA(PJ3_DATA, PJ3MD_00),
9683 + PINMUX_DATA(CRX1_MARK, PJ3MD_01),
9684 +- PINMUX_DATA(CRX0X1_MARK, PJ3MD_10),
9685 ++ PINMUX_DATA(CRX0_CRX1_MARK, PJ3MD_10),
9686 + PINMUX_DATA(IRQ1_PJ_MARK, PJ3MD_11),
9687 +
9688 + PINMUX_DATA(PJ2_DATA, PJ2MD_000),
9689 + PINMUX_DATA(CTX1_MARK, PJ2MD_001),
9690 +- PINMUX_DATA(CRX0_CRX1_MARK, PJ2MD_010),
9691 ++ PINMUX_DATA(CTX0_CTX1_MARK, PJ2MD_010),
9692 + PINMUX_DATA(CS2_MARK, PJ2MD_011),
9693 + PINMUX_DATA(SCK0_MARK, PJ2MD_100),
9694 + PINMUX_DATA(LCD_M_DISP_MARK, PJ2MD_101),
9695 +@@ -1245,6 +1243,7 @@ static const struct pinmux_func pinmux_func_gpios[] = {
9696 + GPIO_FN(CTX1),
9697 + GPIO_FN(CRX1),
9698 + GPIO_FN(CTX0),
9699 ++ GPIO_FN(CTX0_CTX1),
9700 + GPIO_FN(CRX0),
9701 + GPIO_FN(CRX0_CRX1),
9702 +
9703 +diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7269.c b/drivers/pinctrl/sh-pfc/pfc-sh7269.c
9704 +index 6cbb18ef77dc..d20974a55d93 100644
9705 +--- a/drivers/pinctrl/sh-pfc/pfc-sh7269.c
9706 ++++ b/drivers/pinctrl/sh-pfc/pfc-sh7269.c
9707 +@@ -737,13 +737,12 @@ enum {
9708 + CRX0_MARK, CTX0_MARK,
9709 + CRX1_MARK, CTX1_MARK,
9710 + CRX2_MARK, CTX2_MARK,
9711 +- CRX0_CRX1_MARK,
9712 +- CRX0_CRX1_CRX2_MARK,
9713 +- CTX0CTX1CTX2_MARK,
9714 ++ CRX0_CRX1_MARK, CTX0_CTX1_MARK,
9715 ++ CRX0_CRX1_CRX2_MARK, CTX0_CTX1_CTX2_MARK,
9716 + CRX1_PJ22_MARK, CTX1_PJ23_MARK,
9717 + CRX2_PJ20_MARK, CTX2_PJ21_MARK,
9718 +- CRX0CRX1_PJ22_MARK,
9719 +- CRX0CRX1CRX2_PJ20_MARK,
9720 ++ CRX0_CRX1_PJ22_MARK, CTX0_CTX1_PJ23_MARK,
9721 ++ CRX0_CRX1_CRX2_PJ20_MARK, CTX0_CTX1_CTX2_PJ21_MARK,
9722 +
9723 + /* VDC */
9724 + DV_CLK_MARK,
9725 +@@ -821,6 +820,7 @@ static const u16 pinmux_data[] = {
9726 + PINMUX_DATA(CS3_MARK, PC8MD_001),
9727 + PINMUX_DATA(TXD7_MARK, PC8MD_010),
9728 + PINMUX_DATA(CTX1_MARK, PC8MD_011),
9729 ++ PINMUX_DATA(CTX0_CTX1_MARK, PC8MD_100),
9730 +
9731 + PINMUX_DATA(PC7_DATA, PC7MD_000),
9732 + PINMUX_DATA(CKE_MARK, PC7MD_001),
9733 +@@ -833,11 +833,12 @@ static const u16 pinmux_data[] = {
9734 + PINMUX_DATA(CAS_MARK, PC6MD_001),
9735 + PINMUX_DATA(SCK7_MARK, PC6MD_010),
9736 + PINMUX_DATA(CTX0_MARK, PC6MD_011),
9737 ++ PINMUX_DATA(CTX0_CTX1_CTX2_MARK, PC6MD_100),
9738 +
9739 + PINMUX_DATA(PC5_DATA, PC5MD_000),
9740 + PINMUX_DATA(RAS_MARK, PC5MD_001),
9741 + PINMUX_DATA(CRX0_MARK, PC5MD_011),
9742 +- PINMUX_DATA(CTX0CTX1CTX2_MARK, PC5MD_100),
9743 ++ PINMUX_DATA(CTX0_CTX1_CTX2_MARK, PC5MD_100),
9744 + PINMUX_DATA(IRQ0_PC_MARK, PC5MD_101),
9745 +
9746 + PINMUX_DATA(PC4_DATA, PC4MD_00),
9747 +@@ -1289,30 +1290,32 @@ static const u16 pinmux_data[] = {
9748 + PINMUX_DATA(LCD_DATA23_PJ23_MARK, PJ23MD_010),
9749 + PINMUX_DATA(LCD_TCON6_MARK, PJ23MD_011),
9750 + PINMUX_DATA(IRQ3_PJ_MARK, PJ23MD_100),
9751 +- PINMUX_DATA(CTX1_MARK, PJ23MD_101),
9752 ++ PINMUX_DATA(CTX1_PJ23_MARK, PJ23MD_101),
9753 ++ PINMUX_DATA(CTX0_CTX1_PJ23_MARK, PJ23MD_110),
9754 +
9755 + PINMUX_DATA(PJ22_DATA, PJ22MD_000),
9756 + PINMUX_DATA(DV_DATA22_MARK, PJ22MD_001),
9757 + PINMUX_DATA(LCD_DATA22_PJ22_MARK, PJ22MD_010),
9758 + PINMUX_DATA(LCD_TCON5_MARK, PJ22MD_011),
9759 + PINMUX_DATA(IRQ2_PJ_MARK, PJ22MD_100),
9760 +- PINMUX_DATA(CRX1_MARK, PJ22MD_101),
9761 +- PINMUX_DATA(CRX0_CRX1_MARK, PJ22MD_110),
9762 ++ PINMUX_DATA(CRX1_PJ22_MARK, PJ22MD_101),
9763 ++ PINMUX_DATA(CRX0_CRX1_PJ22_MARK, PJ22MD_110),
9764 +
9765 + PINMUX_DATA(PJ21_DATA, PJ21MD_000),
9766 + PINMUX_DATA(DV_DATA21_MARK, PJ21MD_001),
9767 + PINMUX_DATA(LCD_DATA21_PJ21_MARK, PJ21MD_010),
9768 + PINMUX_DATA(LCD_TCON4_MARK, PJ21MD_011),
9769 + PINMUX_DATA(IRQ1_PJ_MARK, PJ21MD_100),
9770 +- PINMUX_DATA(CTX2_MARK, PJ21MD_101),
9771 ++ PINMUX_DATA(CTX2_PJ21_MARK, PJ21MD_101),
9772 ++ PINMUX_DATA(CTX0_CTX1_CTX2_PJ21_MARK, PJ21MD_110),
9773 +
9774 + PINMUX_DATA(PJ20_DATA, PJ20MD_000),
9775 + PINMUX_DATA(DV_DATA20_MARK, PJ20MD_001),
9776 + PINMUX_DATA(LCD_DATA20_PJ20_MARK, PJ20MD_010),
9777 + PINMUX_DATA(LCD_TCON3_MARK, PJ20MD_011),
9778 + PINMUX_DATA(IRQ0_PJ_MARK, PJ20MD_100),
9779 +- PINMUX_DATA(CRX2_MARK, PJ20MD_101),
9780 +- PINMUX_DATA(CRX0CRX1CRX2_PJ20_MARK, PJ20MD_110),
9781 ++ PINMUX_DATA(CRX2_PJ20_MARK, PJ20MD_101),
9782 ++ PINMUX_DATA(CRX0_CRX1_CRX2_PJ20_MARK, PJ20MD_110),
9783 +
9784 + PINMUX_DATA(PJ19_DATA, PJ19MD_000),
9785 + PINMUX_DATA(DV_DATA19_MARK, PJ19MD_001),
9786 +@@ -1663,12 +1666,24 @@ static const struct pinmux_func pinmux_func_gpios[] = {
9787 + GPIO_FN(WDTOVF),
9788 +
9789 + /* CAN */
9790 ++ GPIO_FN(CTX2),
9791 ++ GPIO_FN(CRX2),
9792 + GPIO_FN(CTX1),
9793 + GPIO_FN(CRX1),
9794 + GPIO_FN(CTX0),
9795 + GPIO_FN(CRX0),
9796 ++ GPIO_FN(CTX0_CTX1),
9797 + GPIO_FN(CRX0_CRX1),
9798 ++ GPIO_FN(CTX0_CTX1_CTX2),
9799 + GPIO_FN(CRX0_CRX1_CRX2),
9800 ++ GPIO_FN(CTX2_PJ21),
9801 ++ GPIO_FN(CRX2_PJ20),
9802 ++ GPIO_FN(CTX1_PJ23),
9803 ++ GPIO_FN(CRX1_PJ22),
9804 ++ GPIO_FN(CTX0_CTX1_PJ23),
9805 ++ GPIO_FN(CRX0_CRX1_PJ22),
9806 ++ GPIO_FN(CTX0_CTX1_CTX2_PJ21),
9807 ++ GPIO_FN(CRX0_CRX1_CRX2_PJ20),
9808 +
9809 + /* DMAC */
9810 + GPIO_FN(TEND0),
9811 +diff --git a/drivers/pwm/pwm-omap-dmtimer.c b/drivers/pwm/pwm-omap-dmtimer.c
9812 +index 00772fc53490..e36fcad668a6 100644
9813 +--- a/drivers/pwm/pwm-omap-dmtimer.c
9814 ++++ b/drivers/pwm/pwm-omap-dmtimer.c
9815 +@@ -298,15 +298,10 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
9816 + goto put;
9817 + }
9818 +
9819 +-put:
9820 +- of_node_put(timer);
9821 +- if (ret < 0)
9822 +- return ret;
9823 +-
9824 + omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL);
9825 + if (!omap) {
9826 +- pdata->free(dm_timer);
9827 +- return -ENOMEM;
9828 ++ ret = -ENOMEM;
9829 ++ goto err_alloc_omap;
9830 + }
9831 +
9832 + omap->pdata = pdata;
9833 +@@ -339,18 +334,38 @@ put:
9834 + ret = pwmchip_add(&omap->chip);
9835 + if (ret < 0) {
9836 + dev_err(&pdev->dev, "failed to register PWM\n");
9837 +- omap->pdata->free(omap->dm_timer);
9838 +- return ret;
9839 ++ goto err_pwmchip_add;
9840 + }
9841 +
9842 ++ of_node_put(timer);
9843 ++
9844 + platform_set_drvdata(pdev, omap);
9845 +
9846 + return 0;
9847 ++
9848 ++err_pwmchip_add:
9849 ++
9850 ++ /*
9851 ++ * *omap is allocated using devm_kzalloc,
9852 ++ * so no free necessary here
9853 ++ */
9854 ++err_alloc_omap:
9855 ++
9856 ++ pdata->free(dm_timer);
9857 ++put:
9858 ++ of_node_put(timer);
9859 ++
9860 ++ return ret;
9861 + }
9862 +
9863 + static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
9864 + {
9865 + struct pwm_omap_dmtimer_chip *omap = platform_get_drvdata(pdev);
9866 ++ int ret;
9867 ++
9868 ++ ret = pwmchip_remove(&omap->chip);
9869 ++ if (ret)
9870 ++ return ret;
9871 +
9872 + if (pm_runtime_active(&omap->dm_timer_pdev->dev))
9873 + omap->pdata->stop(omap->dm_timer);
9874 +@@ -359,7 +374,7 @@ static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
9875 +
9876 + mutex_destroy(&omap->mutex);
9877 +
9878 +- return pwmchip_remove(&omap->chip);
9879 ++ return 0;
9880 + }
9881 +
9882 + static const struct of_device_id pwm_omap_dmtimer_of_match[] = {
9883 +diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c
9884 +index 168684b02ebc..b07bdca3d510 100644
9885 +--- a/drivers/pwm/pwm-pca9685.c
9886 ++++ b/drivers/pwm/pwm-pca9685.c
9887 +@@ -159,13 +159,9 @@ static void pca9685_pwm_gpio_set(struct gpio_chip *gpio, unsigned int offset,
9888 + static void pca9685_pwm_gpio_free(struct gpio_chip *gpio, unsigned int offset)
9889 + {
9890 + struct pca9685 *pca = gpiochip_get_data(gpio);
9891 +- struct pwm_device *pwm;
9892 +
9893 + pca9685_pwm_gpio_set(gpio, offset, 0);
9894 + pm_runtime_put(pca->chip.dev);
9895 +- mutex_lock(&pca->lock);
9896 +- pwm = &pca->chip.pwms[offset];
9897 +- mutex_unlock(&pca->lock);
9898 + }
9899 +
9900 + static int pca9685_pwm_gpio_get_direction(struct gpio_chip *chip,
9901 +diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
9902 +index 03d79fee2987..d015d99cb59d 100644
9903 +--- a/drivers/regulator/core.c
9904 ++++ b/drivers/regulator/core.c
9905 +@@ -3470,6 +3470,7 @@ int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV,
9906 + out:
9907 + return ret;
9908 + }
9909 ++EXPORT_SYMBOL_GPL(regulator_set_voltage_rdev);
9910 +
9911 + static int regulator_limit_voltage_step(struct regulator_dev *rdev,
9912 + int *current_uV, int *min_uV)
9913 +@@ -4034,6 +4035,7 @@ int regulator_get_voltage_rdev(struct regulator_dev *rdev)
9914 + return ret;
9915 + return ret - rdev->constraints->uV_offset;
9916 + }
9917 ++EXPORT_SYMBOL_GPL(regulator_get_voltage_rdev);
9918 +
9919 + /**
9920 + * regulator_get_voltage - get regulator output voltage
9921 +diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
9922 +index 5b4003226484..31f79fda3238 100644
9923 +--- a/drivers/regulator/rk808-regulator.c
9924 ++++ b/drivers/regulator/rk808-regulator.c
9925 +@@ -1282,7 +1282,7 @@ static int rk808_regulator_dt_parse_pdata(struct device *dev,
9926 + }
9927 +
9928 + if (!pdata->dvs_gpio[i]) {
9929 +- dev_warn(dev, "there is no dvs%d gpio\n", i);
9930 ++ dev_info(dev, "there is no dvs%d gpio\n", i);
9931 + continue;
9932 + }
9933 +
9934 +diff --git a/drivers/regulator/vctrl-regulator.c b/drivers/regulator/vctrl-regulator.c
9935 +index 9a9ee8188109..cbadb1c99679 100644
9936 +--- a/drivers/regulator/vctrl-regulator.c
9937 ++++ b/drivers/regulator/vctrl-regulator.c
9938 +@@ -11,10 +11,13 @@
9939 + #include <linux/module.h>
9940 + #include <linux/of.h>
9941 + #include <linux/of_device.h>
9942 ++#include <linux/regulator/coupler.h>
9943 + #include <linux/regulator/driver.h>
9944 + #include <linux/regulator/of_regulator.h>
9945 + #include <linux/sort.h>
9946 +
9947 ++#include "internal.h"
9948 ++
9949 + struct vctrl_voltage_range {
9950 + int min_uV;
9951 + int max_uV;
9952 +@@ -79,7 +82,7 @@ static int vctrl_calc_output_voltage(struct vctrl_data *vctrl, int ctrl_uV)
9953 + static int vctrl_get_voltage(struct regulator_dev *rdev)
9954 + {
9955 + struct vctrl_data *vctrl = rdev_get_drvdata(rdev);
9956 +- int ctrl_uV = regulator_get_voltage(vctrl->ctrl_reg);
9957 ++ int ctrl_uV = regulator_get_voltage_rdev(vctrl->ctrl_reg->rdev);
9958 +
9959 + return vctrl_calc_output_voltage(vctrl, ctrl_uV);
9960 + }
9961 +@@ -90,16 +93,16 @@ static int vctrl_set_voltage(struct regulator_dev *rdev,
9962 + {
9963 + struct vctrl_data *vctrl = rdev_get_drvdata(rdev);
9964 + struct regulator *ctrl_reg = vctrl->ctrl_reg;
9965 +- int orig_ctrl_uV = regulator_get_voltage(ctrl_reg);
9966 ++ int orig_ctrl_uV = regulator_get_voltage_rdev(ctrl_reg->rdev);
9967 + int uV = vctrl_calc_output_voltage(vctrl, orig_ctrl_uV);
9968 + int ret;
9969 +
9970 + if (req_min_uV >= uV || !vctrl->ovp_threshold)
9971 + /* voltage rising or no OVP */
9972 +- return regulator_set_voltage(
9973 +- ctrl_reg,
9974 ++ return regulator_set_voltage_rdev(ctrl_reg->rdev,
9975 + vctrl_calc_ctrl_voltage(vctrl, req_min_uV),
9976 +- vctrl_calc_ctrl_voltage(vctrl, req_max_uV));
9977 ++ vctrl_calc_ctrl_voltage(vctrl, req_max_uV),
9978 ++ PM_SUSPEND_ON);
9979 +
9980 + while (uV > req_min_uV) {
9981 + int max_drop_uV = (uV * vctrl->ovp_threshold) / 100;
9982 +@@ -114,9 +117,10 @@ static int vctrl_set_voltage(struct regulator_dev *rdev,
9983 + next_uV = max_t(int, req_min_uV, uV - max_drop_uV);
9984 + next_ctrl_uV = vctrl_calc_ctrl_voltage(vctrl, next_uV);
9985 +
9986 +- ret = regulator_set_voltage(ctrl_reg,
9987 ++ ret = regulator_set_voltage_rdev(ctrl_reg->rdev,
9988 ++ next_ctrl_uV,
9989 + next_ctrl_uV,
9990 +- next_ctrl_uV);
9991 ++ PM_SUSPEND_ON);
9992 + if (ret)
9993 + goto err;
9994 +
9995 +@@ -130,7 +134,8 @@ static int vctrl_set_voltage(struct regulator_dev *rdev,
9996 +
9997 + err:
9998 + /* Try to go back to original voltage */
9999 +- regulator_set_voltage(ctrl_reg, orig_ctrl_uV, orig_ctrl_uV);
10000 ++ regulator_set_voltage_rdev(ctrl_reg->rdev, orig_ctrl_uV, orig_ctrl_uV,
10001 ++ PM_SUSPEND_ON);
10002 +
10003 + return ret;
10004 + }
10005 +@@ -155,9 +160,10 @@ static int vctrl_set_voltage_sel(struct regulator_dev *rdev,
10006 +
10007 + if (selector >= vctrl->sel || !vctrl->ovp_threshold) {
10008 + /* voltage rising or no OVP */
10009 +- ret = regulator_set_voltage(ctrl_reg,
10010 ++ ret = regulator_set_voltage_rdev(ctrl_reg->rdev,
10011 ++ vctrl->vtable[selector].ctrl,
10012 + vctrl->vtable[selector].ctrl,
10013 +- vctrl->vtable[selector].ctrl);
10014 ++ PM_SUSPEND_ON);
10015 + if (!ret)
10016 + vctrl->sel = selector;
10017 +
10018 +@@ -173,9 +179,10 @@ static int vctrl_set_voltage_sel(struct regulator_dev *rdev,
10019 + else
10020 + next_sel = vctrl->vtable[vctrl->sel].ovp_min_sel;
10021 +
10022 +- ret = regulator_set_voltage(ctrl_reg,
10023 ++ ret = regulator_set_voltage_rdev(ctrl_reg->rdev,
10024 + vctrl->vtable[next_sel].ctrl,
10025 +- vctrl->vtable[next_sel].ctrl);
10026 ++ vctrl->vtable[next_sel].ctrl,
10027 ++ PM_SUSPEND_ON);
10028 + if (ret) {
10029 + dev_err(&rdev->dev,
10030 + "failed to set control voltage to %duV\n",
10031 +@@ -195,9 +202,10 @@ static int vctrl_set_voltage_sel(struct regulator_dev *rdev,
10032 + err:
10033 + if (vctrl->sel != orig_sel) {
10034 + /* Try to go back to original voltage */
10035 +- if (!regulator_set_voltage(ctrl_reg,
10036 ++ if (!regulator_set_voltage_rdev(ctrl_reg->rdev,
10037 ++ vctrl->vtable[orig_sel].ctrl,
10038 + vctrl->vtable[orig_sel].ctrl,
10039 +- vctrl->vtable[orig_sel].ctrl))
10040 ++ PM_SUSPEND_ON))
10041 + vctrl->sel = orig_sel;
10042 + else
10043 + dev_warn(&rdev->dev,
10044 +@@ -482,7 +490,7 @@ static int vctrl_probe(struct platform_device *pdev)
10045 + if (ret)
10046 + return ret;
10047 +
10048 +- ctrl_uV = regulator_get_voltage(vctrl->ctrl_reg);
10049 ++ ctrl_uV = regulator_get_voltage_rdev(vctrl->ctrl_reg->rdev);
10050 + if (ctrl_uV < 0) {
10051 + dev_err(&pdev->dev, "failed to get control voltage\n");
10052 + return ctrl_uV;
10053 +diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c
10054 +index 471128a2e723..164fc2a53ef1 100644
10055 +--- a/drivers/remoteproc/qcom_q6v5_mss.c
10056 ++++ b/drivers/remoteproc/qcom_q6v5_mss.c
10057 +@@ -1594,7 +1594,6 @@ static const struct rproc_hexagon_res msm8998_mss = {
10058 + .active_clk_names = (char*[]){
10059 + "iface",
10060 + "bus",
10061 +- "mem",
10062 + "gpll0_mss",
10063 + "mnoc_axi",
10064 + "snoc_axi",
10065 +diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
10066 +index 307df98347ba..8115f945151b 100644
10067 +--- a/drivers/remoteproc/remoteproc_core.c
10068 ++++ b/drivers/remoteproc/remoteproc_core.c
10069 +@@ -2223,7 +2223,7 @@ static int __init remoteproc_init(void)
10070 +
10071 + return 0;
10072 + }
10073 +-module_init(remoteproc_init);
10074 ++subsys_initcall(remoteproc_init);
10075 +
10076 + static void __exit remoteproc_exit(void)
10077 + {
10078 +diff --git a/drivers/reset/reset-uniphier.c b/drivers/reset/reset-uniphier.c
10079 +index 74e589f5dd6a..279e535bf5d8 100644
10080 +--- a/drivers/reset/reset-uniphier.c
10081 ++++ b/drivers/reset/reset-uniphier.c
10082 +@@ -193,8 +193,8 @@ static const struct uniphier_reset_data uniphier_pro5_sd_reset_data[] = {
10083 + #define UNIPHIER_PERI_RESET_FI2C(id, ch) \
10084 + UNIPHIER_RESETX((id), 0x114, 24 + (ch))
10085 +
10086 +-#define UNIPHIER_PERI_RESET_SCSSI(id) \
10087 +- UNIPHIER_RESETX((id), 0x110, 17)
10088 ++#define UNIPHIER_PERI_RESET_SCSSI(id, ch) \
10089 ++ UNIPHIER_RESETX((id), 0x110, 17 + (ch))
10090 +
10091 + #define UNIPHIER_PERI_RESET_MCSSI(id) \
10092 + UNIPHIER_RESETX((id), 0x114, 14)
10093 +@@ -209,7 +209,7 @@ static const struct uniphier_reset_data uniphier_ld4_peri_reset_data[] = {
10094 + UNIPHIER_PERI_RESET_I2C(6, 2),
10095 + UNIPHIER_PERI_RESET_I2C(7, 3),
10096 + UNIPHIER_PERI_RESET_I2C(8, 4),
10097 +- UNIPHIER_PERI_RESET_SCSSI(11),
10098 ++ UNIPHIER_PERI_RESET_SCSSI(11, 0),
10099 + UNIPHIER_RESET_END,
10100 + };
10101 +
10102 +@@ -225,8 +225,11 @@ static const struct uniphier_reset_data uniphier_pro4_peri_reset_data[] = {
10103 + UNIPHIER_PERI_RESET_FI2C(8, 4),
10104 + UNIPHIER_PERI_RESET_FI2C(9, 5),
10105 + UNIPHIER_PERI_RESET_FI2C(10, 6),
10106 +- UNIPHIER_PERI_RESET_SCSSI(11),
10107 +- UNIPHIER_PERI_RESET_MCSSI(12),
10108 ++ UNIPHIER_PERI_RESET_SCSSI(11, 0),
10109 ++ UNIPHIER_PERI_RESET_SCSSI(12, 1),
10110 ++ UNIPHIER_PERI_RESET_SCSSI(13, 2),
10111 ++ UNIPHIER_PERI_RESET_SCSSI(14, 3),
10112 ++ UNIPHIER_PERI_RESET_MCSSI(15),
10113 + UNIPHIER_RESET_END,
10114 + };
10115 +
10116 +diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
10117 +index d77515d8382c..0f46e4a42889 100644
10118 +--- a/drivers/rtc/Kconfig
10119 ++++ b/drivers/rtc/Kconfig
10120 +@@ -240,6 +240,7 @@ config RTC_DRV_AS3722
10121 +
10122 + config RTC_DRV_DS1307
10123 + tristate "Dallas/Maxim DS1307/37/38/39/40/41, ST M41T00, EPSON RX-8025, ISL12057"
10124 ++ select REGMAP_I2C
10125 + help
10126 + If you say yes here you get support for various compatible RTC
10127 + chips (often with battery backup) connected with I2C. This driver
10128 +@@ -621,6 +622,7 @@ config RTC_DRV_RX8010
10129 +
10130 + config RTC_DRV_RX8581
10131 + tristate "Epson RX-8571/RX-8581"
10132 ++ select REGMAP_I2C
10133 + help
10134 + If you say yes here you will get support for the Epson RX-8571/
10135 + RX-8581.
10136 +@@ -648,6 +650,7 @@ config RTC_DRV_EM3027
10137 +
10138 + config RTC_DRV_RV3028
10139 + tristate "Micro Crystal RV3028"
10140 ++ select REGMAP_I2C
10141 + help
10142 + If you say yes here you get support for the Micro Crystal
10143 + RV3028.
10144 +@@ -677,6 +680,7 @@ config RTC_DRV_S5M
10145 +
10146 + config RTC_DRV_SD3078
10147 + tristate "ZXW Shenzhen whwave SD3078"
10148 ++ select REGMAP_I2C
10149 + help
10150 + If you say yes here you get support for the ZXW Shenzhen whwave
10151 + SD3078 RTC chips.
10152 +@@ -848,14 +852,14 @@ config RTC_I2C_AND_SPI
10153 + default m if I2C=m
10154 + default y if I2C=y
10155 + default y if SPI_MASTER=y
10156 +- select REGMAP_I2C if I2C
10157 +- select REGMAP_SPI if SPI_MASTER
10158 +
10159 + comment "SPI and I2C RTC drivers"
10160 +
10161 + config RTC_DRV_DS3232
10162 + tristate "Dallas/Maxim DS3232/DS3234"
10163 + depends on RTC_I2C_AND_SPI
10164 ++ select REGMAP_I2C if I2C
10165 ++ select REGMAP_SPI if SPI_MASTER
10166 + help
10167 + If you say yes here you get support for Dallas Semiconductor
10168 + DS3232 and DS3234 real-time clock chips. If an interrupt is associated
10169 +@@ -875,6 +879,8 @@ config RTC_DRV_DS3232_HWMON
10170 + config RTC_DRV_PCF2127
10171 + tristate "NXP PCF2127"
10172 + depends on RTC_I2C_AND_SPI
10173 ++ select REGMAP_I2C if I2C
10174 ++ select REGMAP_SPI if SPI_MASTER
10175 + select WATCHDOG_CORE if WATCHDOG
10176 + help
10177 + If you say yes here you get support for the NXP PCF2127/29 RTC
10178 +@@ -891,6 +897,8 @@ config RTC_DRV_PCF2127
10179 + config RTC_DRV_RV3029C2
10180 + tristate "Micro Crystal RV3029/3049"
10181 + depends on RTC_I2C_AND_SPI
10182 ++ select REGMAP_I2C if I2C
10183 ++ select REGMAP_SPI if SPI_MASTER
10184 + help
10185 + If you say yes here you get support for the Micro Crystal
10186 + RV3029 and RV3049 RTC chips.
10187 +diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
10188 +index a9d40d3b90ef..4190a025381a 100644
10189 +--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
10190 ++++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
10191 +@@ -2314,7 +2314,7 @@ ahc_find_syncrate(struct ahc_softc *ahc, u_int *period,
10192 + * At some speeds, we only support
10193 + * ST transfers.
10194 + */
10195 +- if ((syncrate->sxfr_u2 & ST_SXFR) != 0)
10196 ++ if ((syncrate->sxfr_u2 & ST_SXFR) != 0)
10197 + *ppr_options &= ~MSG_EXT_PPR_DT_REQ;
10198 + break;
10199 + }
10200 +diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
10201 +index 0bc63a7ab41c..b5dd1caae5e9 100644
10202 +--- a/drivers/scsi/iscsi_tcp.c
10203 ++++ b/drivers/scsi/iscsi_tcp.c
10204 +@@ -887,6 +887,10 @@ free_host:
10205 + static void iscsi_sw_tcp_session_destroy(struct iscsi_cls_session *cls_session)
10206 + {
10207 + struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
10208 ++ struct iscsi_session *session = cls_session->dd_data;
10209 ++
10210 ++ if (WARN_ON_ONCE(session->leadconn))
10211 ++ return;
10212 +
10213 + iscsi_tcp_r2tpool_free(cls_session->dd_data);
10214 + iscsi_session_teardown(cls_session);
10215 +diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
10216 +index 99c9bb249758..1b4dbb28fb41 100644
10217 +--- a/drivers/scsi/lpfc/lpfc_ct.c
10218 ++++ b/drivers/scsi/lpfc/lpfc_ct.c
10219 +@@ -1493,33 +1493,35 @@ int
10220 + lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol,
10221 + size_t size)
10222 + {
10223 +- char fwrev[FW_REV_STR_SIZE];
10224 +- int n;
10225 ++ char fwrev[FW_REV_STR_SIZE] = {0};
10226 ++ char tmp[MAXHOSTNAMELEN] = {0};
10227 +
10228 +- lpfc_decode_firmware_rev(vport->phba, fwrev, 0);
10229 ++ memset(symbol, 0, size);
10230 +
10231 +- n = scnprintf(symbol, size, "Emulex %s", vport->phba->ModelName);
10232 +- if (size < n)
10233 +- return n;
10234 ++ scnprintf(tmp, sizeof(tmp), "Emulex %s", vport->phba->ModelName);
10235 ++ if (strlcat(symbol, tmp, size) >= size)
10236 ++ goto buffer_done;
10237 +
10238 +- n += scnprintf(symbol + n, size - n, " FV%s", fwrev);
10239 +- if (size < n)
10240 +- return n;
10241 ++ lpfc_decode_firmware_rev(vport->phba, fwrev, 0);
10242 ++ scnprintf(tmp, sizeof(tmp), " FV%s", fwrev);
10243 ++ if (strlcat(symbol, tmp, size) >= size)
10244 ++ goto buffer_done;
10245 +
10246 +- n += scnprintf(symbol + n, size - n, " DV%s.",
10247 +- lpfc_release_version);
10248 +- if (size < n)
10249 +- return n;
10250 ++ scnprintf(tmp, sizeof(tmp), " DV%s", lpfc_release_version);
10251 ++ if (strlcat(symbol, tmp, size) >= size)
10252 ++ goto buffer_done;
10253 +
10254 +- n += scnprintf(symbol + n, size - n, " HN:%s.",
10255 +- init_utsname()->nodename);
10256 +- if (size < n)
10257 +- return n;
10258 ++ scnprintf(tmp, sizeof(tmp), " HN:%s", init_utsname()->nodename);
10259 ++ if (strlcat(symbol, tmp, size) >= size)
10260 ++ goto buffer_done;
10261 +
10262 + /* Note :- OS name is "Linux" */
10263 +- n += scnprintf(symbol + n, size - n, " OS:%s",
10264 +- init_utsname()->sysname);
10265 +- return n;
10266 ++ scnprintf(tmp, sizeof(tmp), " OS:%s", init_utsname()->sysname);
10267 ++ strlcat(symbol, tmp, size);
10268 ++
10269 ++buffer_done:
10270 ++ return strnlen(symbol, size);
10271 ++
10272 + }
10273 +
10274 + static uint32_t
10275 +diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
10276 +index ed8d9709b9b9..271afea654e2 100644
10277 +--- a/drivers/scsi/scsi_transport_iscsi.c
10278 ++++ b/drivers/scsi/scsi_transport_iscsi.c
10279 +@@ -2947,6 +2947,24 @@ iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
10280 + return err;
10281 + }
10282 +
10283 ++static int iscsi_session_has_conns(int sid)
10284 ++{
10285 ++ struct iscsi_cls_conn *conn;
10286 ++ unsigned long flags;
10287 ++ int found = 0;
10288 ++
10289 ++ spin_lock_irqsave(&connlock, flags);
10290 ++ list_for_each_entry(conn, &connlist, conn_list) {
10291 ++ if (iscsi_conn_get_sid(conn) == sid) {
10292 ++ found = 1;
10293 ++ break;
10294 ++ }
10295 ++ }
10296 ++ spin_unlock_irqrestore(&connlock, flags);
10297 ++
10298 ++ return found;
10299 ++}
10300 ++
10301 + static int
10302 + iscsi_set_iface_params(struct iscsi_transport *transport,
10303 + struct iscsi_uevent *ev, uint32_t len)
10304 +@@ -3524,10 +3542,12 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
10305 + break;
10306 + case ISCSI_UEVENT_DESTROY_SESSION:
10307 + session = iscsi_session_lookup(ev->u.d_session.sid);
10308 +- if (session)
10309 +- transport->destroy_session(session);
10310 +- else
10311 ++ if (!session)
10312 + err = -EINVAL;
10313 ++ else if (iscsi_session_has_conns(ev->u.d_session.sid))
10314 ++ err = -EBUSY;
10315 ++ else
10316 ++ transport->destroy_session(session);
10317 + break;
10318 + case ISCSI_UEVENT_UNBIND_SESSION:
10319 + session = iscsi_session_lookup(ev->u.d_session.sid);
10320 +diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
10321 +index 83e28edc3ac5..8a21f49caf0d 100644
10322 +--- a/drivers/scsi/ufs/ufs-mediatek.c
10323 ++++ b/drivers/scsi/ufs/ufs-mediatek.c
10324 +@@ -13,6 +13,7 @@
10325 +
10326 + #include "ufshcd.h"
10327 + #include "ufshcd-pltfrm.h"
10328 ++#include "ufs_quirks.h"
10329 + #include "unipro.h"
10330 + #include "ufs-mediatek.h"
10331 +
10332 +@@ -289,6 +290,15 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
10333 + return 0;
10334 + }
10335 +
10336 ++static int ufs_mtk_apply_dev_quirks(struct ufs_hba *hba,
10337 ++ struct ufs_dev_desc *card)
10338 ++{
10339 ++ if (card->wmanufacturerid == UFS_VENDOR_SAMSUNG)
10340 ++ ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TACTIVATE), 6);
10341 ++
10342 ++ return 0;
10343 ++}
10344 ++
10345 + /**
10346 + * struct ufs_hba_mtk_vops - UFS MTK specific variant operations
10347 + *
10348 +@@ -301,6 +311,7 @@ static struct ufs_hba_variant_ops ufs_hba_mtk_vops = {
10349 + .setup_clocks = ufs_mtk_setup_clocks,
10350 + .link_startup_notify = ufs_mtk_link_startup_notify,
10351 + .pwr_change_notify = ufs_mtk_pwr_change_notify,
10352 ++ .apply_dev_quirks = ufs_mtk_apply_dev_quirks,
10353 + .suspend = ufs_mtk_suspend,
10354 + .resume = ufs_mtk_resume,
10355 + };
10356 +diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
10357 +index c69c29a1ceb9..ebb5c66e069f 100644
10358 +--- a/drivers/scsi/ufs/ufs-qcom.c
10359 ++++ b/drivers/scsi/ufs/ufs-qcom.c
10360 +@@ -949,7 +949,8 @@ out:
10361 + return err;
10362 + }
10363 +
10364 +-static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba)
10365 ++static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba,
10366 ++ struct ufs_dev_desc *card)
10367 + {
10368 + int err = 0;
10369 +
10370 +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
10371 +index 3fbf9ea16c64..5340a980d24b 100644
10372 +--- a/drivers/scsi/ufs/ufshcd.c
10373 ++++ b/drivers/scsi/ufs/ufshcd.c
10374 +@@ -4799,7 +4799,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
10375 + break;
10376 + } /* end of switch */
10377 +
10378 +- if (host_byte(result) != DID_OK)
10379 ++ if ((host_byte(result) != DID_OK) && !hba->silence_err_logs)
10380 + ufshcd_print_trs(hba, 1 << lrbp->task_tag, true);
10381 + return result;
10382 + }
10383 +@@ -5351,8 +5351,8 @@ static void ufshcd_err_handler(struct work_struct *work)
10384 +
10385 + /*
10386 + * if host reset is required then skip clearing the pending
10387 +- * transfers forcefully because they will automatically get
10388 +- * cleared after link startup.
10389 ++ * transfers forcefully because they will get cleared during
10390 ++ * host reset and restore
10391 + */
10392 + if (needs_reset)
10393 + goto skip_pending_xfer_clear;
10394 +@@ -6282,9 +6282,15 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba)
10395 + int err;
10396 + unsigned long flags;
10397 +
10398 +- /* Reset the host controller */
10399 ++ /*
10400 ++ * Stop the host controller and complete the requests
10401 ++ * cleared by h/w
10402 ++ */
10403 + spin_lock_irqsave(hba->host->host_lock, flags);
10404 + ufshcd_hba_stop(hba, false);
10405 ++ hba->silence_err_logs = true;
10406 ++ ufshcd_complete_requests(hba);
10407 ++ hba->silence_err_logs = false;
10408 + spin_unlock_irqrestore(hba->host->host_lock, flags);
10409 +
10410 + /* scale up clocks to max frequency before full reinitialization */
10411 +@@ -6318,7 +6324,6 @@ out:
10412 + static int ufshcd_reset_and_restore(struct ufs_hba *hba)
10413 + {
10414 + int err = 0;
10415 +- unsigned long flags;
10416 + int retries = MAX_HOST_RESET_RETRIES;
10417 +
10418 + do {
10419 +@@ -6328,15 +6333,6 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba)
10420 + err = ufshcd_host_reset_and_restore(hba);
10421 + } while (err && --retries);
10422 +
10423 +- /*
10424 +- * After reset the door-bell might be cleared, complete
10425 +- * outstanding requests in s/w here.
10426 +- */
10427 +- spin_lock_irqsave(hba->host->host_lock, flags);
10428 +- ufshcd_transfer_req_compl(hba);
10429 +- ufshcd_tmc_handler(hba);
10430 +- spin_unlock_irqrestore(hba->host->host_lock, flags);
10431 +-
10432 + return err;
10433 + }
10434 +
10435 +@@ -6802,7 +6798,8 @@ out:
10436 + return ret;
10437 + }
10438 +
10439 +-static void ufshcd_tune_unipro_params(struct ufs_hba *hba)
10440 ++static void ufshcd_tune_unipro_params(struct ufs_hba *hba,
10441 ++ struct ufs_dev_desc *card)
10442 + {
10443 + if (ufshcd_is_unipro_pa_params_tuning_req(hba)) {
10444 + ufshcd_tune_pa_tactivate(hba);
10445 +@@ -6816,7 +6813,7 @@ static void ufshcd_tune_unipro_params(struct ufs_hba *hba)
10446 + if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE)
10447 + ufshcd_quirk_tune_host_pa_tactivate(hba);
10448 +
10449 +- ufshcd_vops_apply_dev_quirks(hba);
10450 ++ ufshcd_vops_apply_dev_quirks(hba, card);
10451 + }
10452 +
10453 + static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba)
10454 +@@ -6979,10 +6976,9 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
10455 + }
10456 +
10457 + ufs_fixup_device_setup(hba, &card);
10458 ++ ufshcd_tune_unipro_params(hba, &card);
10459 + ufs_put_device_desc(&card);
10460 +
10461 +- ufshcd_tune_unipro_params(hba);
10462 +-
10463 + /* UFS device is also active now */
10464 + ufshcd_set_ufs_dev_active(hba);
10465 + ufshcd_force_reset_auto_bkops(hba);
10466 +diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
10467 +index 2740f6941ec6..46bec0e18c72 100644
10468 +--- a/drivers/scsi/ufs/ufshcd.h
10469 ++++ b/drivers/scsi/ufs/ufshcd.h
10470 +@@ -322,7 +322,7 @@ struct ufs_hba_variant_ops {
10471 + void (*setup_task_mgmt)(struct ufs_hba *, int, u8);
10472 + void (*hibern8_notify)(struct ufs_hba *, enum uic_cmd_dme,
10473 + enum ufs_notify_change_status);
10474 +- int (*apply_dev_quirks)(struct ufs_hba *);
10475 ++ int (*apply_dev_quirks)(struct ufs_hba *, struct ufs_dev_desc *);
10476 + int (*suspend)(struct ufs_hba *, enum ufs_pm_op);
10477 + int (*resume)(struct ufs_hba *, enum ufs_pm_op);
10478 + void (*dbg_register_dump)(struct ufs_hba *hba);
10479 +@@ -513,6 +513,7 @@ struct ufs_stats {
10480 + * @uic_error: UFS interconnect layer error status
10481 + * @saved_err: sticky error mask
10482 + * @saved_uic_err: sticky UIC error mask
10483 ++ * @silence_err_logs: flag to silence error logs
10484 + * @dev_cmd: ufs device management command information
10485 + * @last_dme_cmd_tstamp: time stamp of the last completed DME command
10486 + * @auto_bkops_enabled: to track whether bkops is enabled in device
10487 +@@ -670,6 +671,7 @@ struct ufs_hba {
10488 + u32 saved_err;
10489 + u32 saved_uic_err;
10490 + struct ufs_stats ufs_stats;
10491 ++ bool silence_err_logs;
10492 +
10493 + /* Device management request data */
10494 + struct ufs_dev_cmd dev_cmd;
10495 +@@ -1055,10 +1057,11 @@ static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba,
10496 + return hba->vops->hibern8_notify(hba, cmd, status);
10497 + }
10498 +
10499 +-static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba)
10500 ++static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba,
10501 ++ struct ufs_dev_desc *card)
10502 + {
10503 + if (hba->vops && hba->vops->apply_dev_quirks)
10504 +- return hba->vops->apply_dev_quirks(hba);
10505 ++ return hba->vops->apply_dev_quirks(hba, card);
10506 + return 0;
10507 + }
10508 +
10509 +diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c
10510 +index df76778af601..f8b9c4058926 100644
10511 +--- a/drivers/soc/tegra/fuse/tegra-apbmisc.c
10512 ++++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c
10513 +@@ -123,7 +123,7 @@ void __init tegra_init_apbmisc(void)
10514 + apbmisc.flags = IORESOURCE_MEM;
10515 +
10516 + /* strapping options */
10517 +- if (tegra_get_chip_id() == TEGRA124) {
10518 ++ if (of_machine_is_compatible("nvidia,tegra124")) {
10519 + straps.start = 0x7000e864;
10520 + straps.end = 0x7000e867;
10521 + } else {
10522 +diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
10523 +index 2cc0ddb4a988..1375bdfc587b 100644
10524 +--- a/drivers/spi/spi-fsl-lpspi.c
10525 ++++ b/drivers/spi/spi-fsl-lpspi.c
10526 +@@ -862,6 +862,22 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
10527 + fsl_lpspi->dev = &pdev->dev;
10528 + fsl_lpspi->is_slave = is_slave;
10529 +
10530 ++ controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
10531 ++ controller->transfer_one = fsl_lpspi_transfer_one;
10532 ++ controller->prepare_transfer_hardware = lpspi_prepare_xfer_hardware;
10533 ++ controller->unprepare_transfer_hardware = lpspi_unprepare_xfer_hardware;
10534 ++ controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
10535 ++ controller->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX;
10536 ++ controller->dev.of_node = pdev->dev.of_node;
10537 ++ controller->bus_num = pdev->id;
10538 ++ controller->slave_abort = fsl_lpspi_slave_abort;
10539 ++
10540 ++ ret = devm_spi_register_controller(&pdev->dev, controller);
10541 ++ if (ret < 0) {
10542 ++ dev_err(&pdev->dev, "spi_register_controller error.\n");
10543 ++ goto out_controller_put;
10544 ++ }
10545 ++
10546 + if (!fsl_lpspi->is_slave) {
10547 + for (i = 0; i < controller->num_chipselect; i++) {
10548 + int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
10549 +@@ -885,16 +901,6 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
10550 + controller->prepare_message = fsl_lpspi_prepare_message;
10551 + }
10552 +
10553 +- controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
10554 +- controller->transfer_one = fsl_lpspi_transfer_one;
10555 +- controller->prepare_transfer_hardware = lpspi_prepare_xfer_hardware;
10556 +- controller->unprepare_transfer_hardware = lpspi_unprepare_xfer_hardware;
10557 +- controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
10558 +- controller->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX;
10559 +- controller->dev.of_node = pdev->dev.of_node;
10560 +- controller->bus_num = pdev->id;
10561 +- controller->slave_abort = fsl_lpspi_slave_abort;
10562 +-
10563 + init_completion(&fsl_lpspi->xfer_done);
10564 +
10565 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
10566 +@@ -952,12 +958,6 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
10567 + if (ret < 0)
10568 + dev_err(&pdev->dev, "dma setup error %d, use pio\n", ret);
10569 +
10570 +- ret = devm_spi_register_controller(&pdev->dev, controller);
10571 +- if (ret < 0) {
10572 +- dev_err(&pdev->dev, "spi_register_controller error.\n");
10573 +- goto out_controller_put;
10574 +- }
10575 +-
10576 + return 0;
10577 +
10578 + out_controller_put:
10579 +diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c
10580 +index 79b1558b74b8..e8a499cd1f13 100644
10581 +--- a/drivers/spi/spi-fsl-qspi.c
10582 ++++ b/drivers/spi/spi-fsl-qspi.c
10583 +@@ -410,7 +410,7 @@ static bool fsl_qspi_supports_op(struct spi_mem *mem,
10584 + op->data.nbytes > q->devtype_data->txfifo)
10585 + return false;
10586 +
10587 +- return true;
10588 ++ return spi_mem_default_supports_op(mem, op);
10589 + }
10590 +
10591 + static void fsl_qspi_prepare_lut(struct fsl_qspi *q,
10592 +diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c
10593 +index 0a1a04fd5d13..8dd1396909d7 100644
10594 +--- a/drivers/staging/media/meson/vdec/vdec.c
10595 ++++ b/drivers/staging/media/meson/vdec/vdec.c
10596 +@@ -133,6 +133,8 @@ vdec_queue_recycle(struct amvdec_session *sess, struct vb2_buffer *vb)
10597 + struct amvdec_buffer *new_buf;
10598 +
10599 + new_buf = kmalloc(sizeof(*new_buf), GFP_KERNEL);
10600 ++ if (!new_buf)
10601 ++ return;
10602 + new_buf->vb = vb;
10603 +
10604 + mutex_lock(&sess->bufs_recycle_lock);
10605 +diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
10606 +index 710c33fd4965..47f4cc6a19a9 100644
10607 +--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
10608 ++++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
10609 +@@ -222,18 +222,21 @@ static char *translate_scan(struct adapter *padapter,
10610 +
10611 + /* parsing WPA/WPA2 IE */
10612 + {
10613 +- u8 buf[MAX_WPA_IE_LEN];
10614 ++ u8 *buf;
10615 + u8 wpa_ie[255], rsn_ie[255];
10616 + u16 wpa_len = 0, rsn_len = 0;
10617 + u8 *p;
10618 +
10619 ++ buf = kzalloc(MAX_WPA_IE_LEN, GFP_ATOMIC);
10620 ++ if (!buf)
10621 ++ return start;
10622 ++
10623 + rtw_get_sec_ie(pnetwork->network.ies, pnetwork->network.ie_length, rsn_ie, &rsn_len, wpa_ie, &wpa_len);
10624 + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.ssid.ssid));
10625 + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len));
10626 +
10627 + if (wpa_len > 0) {
10628 + p = buf;
10629 +- memset(buf, 0, MAX_WPA_IE_LEN);
10630 + p += sprintf(p, "wpa_ie=");
10631 + for (i = 0; i < wpa_len; i++)
10632 + p += sprintf(p, "%02x", wpa_ie[i]);
10633 +@@ -250,7 +253,6 @@ static char *translate_scan(struct adapter *padapter,
10634 + }
10635 + if (rsn_len > 0) {
10636 + p = buf;
10637 +- memset(buf, 0, MAX_WPA_IE_LEN);
10638 + p += sprintf(p, "rsn_ie=");
10639 + for (i = 0; i < rsn_len; i++)
10640 + p += sprintf(p, "%02x", rsn_ie[i]);
10641 +@@ -264,6 +266,7 @@ static char *translate_scan(struct adapter *padapter,
10642 + iwe.u.data.length = rsn_len;
10643 + start = iwe_stream_add_point(info, start, stop, &iwe, rsn_ie);
10644 + }
10645 ++ kfree(buf);
10646 + }
10647 +
10648 + {/* parsing WPS IE */
10649 +diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
10650 +index b13d7341f8bb..0c6a3a1a1ddf 100644
10651 +--- a/drivers/staging/wfx/data_tx.c
10652 ++++ b/drivers/staging/wfx/data_tx.c
10653 +@@ -282,8 +282,7 @@ void wfx_tx_policy_init(struct wfx_vif *wvif)
10654 + static int wfx_alloc_link_id(struct wfx_vif *wvif, const u8 *mac)
10655 + {
10656 + int i, ret = 0;
10657 +- unsigned long max_inactivity = 0;
10658 +- unsigned long now = jiffies;
10659 ++ unsigned long oldest;
10660 +
10661 + spin_lock_bh(&wvif->ps_state_lock);
10662 + for (i = 0; i < WFX_MAX_STA_IN_AP_MODE; ++i) {
10663 +@@ -292,13 +291,10 @@ static int wfx_alloc_link_id(struct wfx_vif *wvif, const u8 *mac)
10664 + break;
10665 + } else if (wvif->link_id_db[i].status != WFX_LINK_HARD &&
10666 + !wvif->wdev->tx_queue_stats.link_map_cache[i + 1]) {
10667 +- unsigned long inactivity =
10668 +- now - wvif->link_id_db[i].timestamp;
10669 +-
10670 +- if (inactivity < max_inactivity)
10671 +- continue;
10672 +- max_inactivity = inactivity;
10673 +- ret = i + 1;
10674 ++ if (!ret || time_after(oldest, wvif->link_id_db[i].timestamp)) {
10675 ++ oldest = wvif->link_id_db[i].timestamp;
10676 ++ ret = i + 1;
10677 ++ }
10678 + }
10679 + }
10680 +
10681 +diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
10682 +index e8a9047de451..36f1a4d870eb 100644
10683 +--- a/drivers/tty/synclink_gt.c
10684 ++++ b/drivers/tty/synclink_gt.c
10685 +@@ -1334,10 +1334,10 @@ static void throttle(struct tty_struct * tty)
10686 + DBGINFO(("%s throttle\n", info->device_name));
10687 + if (I_IXOFF(tty))
10688 + send_xchar(tty, STOP_CHAR(tty));
10689 +- if (C_CRTSCTS(tty)) {
10690 ++ if (C_CRTSCTS(tty)) {
10691 + spin_lock_irqsave(&info->lock,flags);
10692 + info->signals &= ~SerialSignal_RTS;
10693 +- set_signals(info);
10694 ++ set_signals(info);
10695 + spin_unlock_irqrestore(&info->lock,flags);
10696 + }
10697 + }
10698 +@@ -1359,10 +1359,10 @@ static void unthrottle(struct tty_struct * tty)
10699 + else
10700 + send_xchar(tty, START_CHAR(tty));
10701 + }
10702 +- if (C_CRTSCTS(tty)) {
10703 ++ if (C_CRTSCTS(tty)) {
10704 + spin_lock_irqsave(&info->lock,flags);
10705 + info->signals |= SerialSignal_RTS;
10706 +- set_signals(info);
10707 ++ set_signals(info);
10708 + spin_unlock_irqrestore(&info->lock,flags);
10709 + }
10710 + }
10711 +@@ -2560,8 +2560,8 @@ static void change_params(struct slgt_info *info)
10712 + info->read_status_mask = IRQ_RXOVER;
10713 + if (I_INPCK(info->port.tty))
10714 + info->read_status_mask |= MASK_PARITY | MASK_FRAMING;
10715 +- if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
10716 +- info->read_status_mask |= MASK_BREAK;
10717 ++ if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
10718 ++ info->read_status_mask |= MASK_BREAK;
10719 + if (I_IGNPAR(info->port.tty))
10720 + info->ignore_status_mask |= MASK_PARITY | MASK_FRAMING;
10721 + if (I_IGNBRK(info->port.tty)) {
10722 +@@ -3192,7 +3192,7 @@ static int tiocmset(struct tty_struct *tty,
10723 + info->signals &= ~SerialSignal_DTR;
10724 +
10725 + spin_lock_irqsave(&info->lock,flags);
10726 +- set_signals(info);
10727 ++ set_signals(info);
10728 + spin_unlock_irqrestore(&info->lock,flags);
10729 + return 0;
10730 + }
10731 +@@ -3203,7 +3203,7 @@ static int carrier_raised(struct tty_port *port)
10732 + struct slgt_info *info = container_of(port, struct slgt_info, port);
10733 +
10734 + spin_lock_irqsave(&info->lock,flags);
10735 +- get_signals(info);
10736 ++ get_signals(info);
10737 + spin_unlock_irqrestore(&info->lock,flags);
10738 + return (info->signals & SerialSignal_DCD) ? 1 : 0;
10739 + }
10740 +@@ -3218,7 +3218,7 @@ static void dtr_rts(struct tty_port *port, int on)
10741 + info->signals |= SerialSignal_RTS | SerialSignal_DTR;
10742 + else
10743 + info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
10744 +- set_signals(info);
10745 ++ set_signals(info);
10746 + spin_unlock_irqrestore(&info->lock,flags);
10747 + }
10748 +
10749 +diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
10750 +index fcb91bf7a15b..54b897a646d0 100644
10751 +--- a/drivers/tty/synclinkmp.c
10752 ++++ b/drivers/tty/synclinkmp.c
10753 +@@ -1453,10 +1453,10 @@ static void throttle(struct tty_struct * tty)
10754 + if (I_IXOFF(tty))
10755 + send_xchar(tty, STOP_CHAR(tty));
10756 +
10757 +- if (C_CRTSCTS(tty)) {
10758 ++ if (C_CRTSCTS(tty)) {
10759 + spin_lock_irqsave(&info->lock,flags);
10760 + info->serial_signals &= ~SerialSignal_RTS;
10761 +- set_signals(info);
10762 ++ set_signals(info);
10763 + spin_unlock_irqrestore(&info->lock,flags);
10764 + }
10765 + }
10766 +@@ -1482,10 +1482,10 @@ static void unthrottle(struct tty_struct * tty)
10767 + send_xchar(tty, START_CHAR(tty));
10768 + }
10769 +
10770 +- if (C_CRTSCTS(tty)) {
10771 ++ if (C_CRTSCTS(tty)) {
10772 + spin_lock_irqsave(&info->lock,flags);
10773 + info->serial_signals |= SerialSignal_RTS;
10774 +- set_signals(info);
10775 ++ set_signals(info);
10776 + spin_unlock_irqrestore(&info->lock,flags);
10777 + }
10778 + }
10779 +@@ -2470,7 +2470,7 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
10780 + if (status & SerialSignal_CTS) {
10781 + if ( debug_level >= DEBUG_LEVEL_ISR )
10782 + printk("CTS tx start...");
10783 +- info->port.tty->hw_stopped = 0;
10784 ++ info->port.tty->hw_stopped = 0;
10785 + tx_start(info);
10786 + info->pending_bh |= BH_TRANSMIT;
10787 + return;
10788 +@@ -2479,7 +2479,7 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
10789 + if (!(status & SerialSignal_CTS)) {
10790 + if ( debug_level >= DEBUG_LEVEL_ISR )
10791 + printk("CTS tx stop...");
10792 +- info->port.tty->hw_stopped = 1;
10793 ++ info->port.tty->hw_stopped = 1;
10794 + tx_stop(info);
10795 + }
10796 + }
10797 +@@ -2806,8 +2806,8 @@ static void change_params(SLMP_INFO *info)
10798 + info->read_status_mask2 = OVRN;
10799 + if (I_INPCK(info->port.tty))
10800 + info->read_status_mask2 |= PE | FRME;
10801 +- if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
10802 +- info->read_status_mask1 |= BRKD;
10803 ++ if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
10804 ++ info->read_status_mask1 |= BRKD;
10805 + if (I_IGNPAR(info->port.tty))
10806 + info->ignore_status_mask2 |= PE | FRME;
10807 + if (I_IGNBRK(info->port.tty)) {
10808 +@@ -3177,7 +3177,7 @@ static int tiocmget(struct tty_struct *tty)
10809 + unsigned long flags;
10810 +
10811 + spin_lock_irqsave(&info->lock,flags);
10812 +- get_signals(info);
10813 ++ get_signals(info);
10814 + spin_unlock_irqrestore(&info->lock,flags);
10815 +
10816 + result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS : 0) |
10817 +@@ -3215,7 +3215,7 @@ static int tiocmset(struct tty_struct *tty,
10818 + info->serial_signals &= ~SerialSignal_DTR;
10819 +
10820 + spin_lock_irqsave(&info->lock,flags);
10821 +- set_signals(info);
10822 ++ set_signals(info);
10823 + spin_unlock_irqrestore(&info->lock,flags);
10824 +
10825 + return 0;
10826 +@@ -3227,7 +3227,7 @@ static int carrier_raised(struct tty_port *port)
10827 + unsigned long flags;
10828 +
10829 + spin_lock_irqsave(&info->lock,flags);
10830 +- get_signals(info);
10831 ++ get_signals(info);
10832 + spin_unlock_irqrestore(&info->lock,flags);
10833 +
10834 + return (info->serial_signals & SerialSignal_DCD) ? 1 : 0;
10835 +@@ -3243,7 +3243,7 @@ static void dtr_rts(struct tty_port *port, int on)
10836 + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR;
10837 + else
10838 + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
10839 +- set_signals(info);
10840 ++ set_signals(info);
10841 + spin_unlock_irqrestore(&info->lock,flags);
10842 + }
10843 +
10844 +diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
10845 +index 81c88f7bbbcb..f6ab3f28c838 100644
10846 +--- a/drivers/uio/uio_dmem_genirq.c
10847 ++++ b/drivers/uio/uio_dmem_genirq.c
10848 +@@ -132,11 +132,13 @@ static int uio_dmem_genirq_irqcontrol(struct uio_info *dev_info, s32 irq_on)
10849 + if (irq_on) {
10850 + if (test_and_clear_bit(0, &priv->flags))
10851 + enable_irq(dev_info->irq);
10852 ++ spin_unlock_irqrestore(&priv->lock, flags);
10853 + } else {
10854 +- if (!test_and_set_bit(0, &priv->flags))
10855 ++ if (!test_and_set_bit(0, &priv->flags)) {
10856 ++ spin_unlock_irqrestore(&priv->lock, flags);
10857 + disable_irq(dev_info->irq);
10858 ++ }
10859 + }
10860 +- spin_unlock_irqrestore(&priv->lock, flags);
10861 +
10862 + return 0;
10863 + }
10864 +diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
10865 +index 6be10e496e10..a9133773b89e 100644
10866 +--- a/drivers/usb/dwc2/gadget.c
10867 ++++ b/drivers/usb/dwc2/gadget.c
10868 +@@ -4056,11 +4056,12 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
10869 + * a unique tx-fifo even if it is non-periodic.
10870 + */
10871 + if (dir_in && hsotg->dedicated_fifos) {
10872 ++ unsigned fifo_count = dwc2_hsotg_tx_fifo_count(hsotg);
10873 + u32 fifo_index = 0;
10874 + u32 fifo_size = UINT_MAX;
10875 +
10876 + size = hs_ep->ep.maxpacket * hs_ep->mc;
10877 +- for (i = 1; i < hsotg->num_of_eps; ++i) {
10878 ++ for (i = 1; i <= fifo_count; ++i) {
10879 + if (hsotg->fifo_map & (1 << i))
10880 + continue;
10881 + val = dwc2_readl(hsotg, DPTXFSIZN(i));
10882 +diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
10883 +index 5567ed2cddbe..fa252870c926 100644
10884 +--- a/drivers/usb/dwc3/host.c
10885 ++++ b/drivers/usb/dwc3/host.c
10886 +@@ -88,10 +88,10 @@ int dwc3_host_init(struct dwc3 *dwc)
10887 + memset(props, 0, sizeof(struct property_entry) * ARRAY_SIZE(props));
10888 +
10889 + if (dwc->usb3_lpm_capable)
10890 +- props[prop_idx++].name = "usb3-lpm-capable";
10891 ++ props[prop_idx++] = PROPERTY_ENTRY_BOOL("usb3-lpm-capable");
10892 +
10893 + if (dwc->usb2_lpm_disable)
10894 +- props[prop_idx++].name = "usb2-lpm-disable";
10895 ++ props[prop_idx++] = PROPERTY_ENTRY_BOOL("usb2-lpm-disable");
10896 +
10897 + /**
10898 + * WORKAROUND: dwc3 revisions <=3.00a have a limitation
10899 +@@ -103,7 +103,7 @@ int dwc3_host_init(struct dwc3 *dwc)
10900 + * This following flag tells XHCI to do just that.
10901 + */
10902 + if (dwc->revision <= DWC3_REVISION_300A)
10903 +- props[prop_idx++].name = "quirk-broken-port-ped";
10904 ++ props[prop_idx++] = PROPERTY_ENTRY_BOOL("quirk-broken-port-ped");
10905 +
10906 + if (prop_idx) {
10907 + ret = platform_device_add_properties(xhci, props);
10908 +diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c
10909 +index 64d80c65bb96..aaf975c809bf 100644
10910 +--- a/drivers/usb/gadget/udc/gr_udc.c
10911 ++++ b/drivers/usb/gadget/udc/gr_udc.c
10912 +@@ -2175,8 +2175,6 @@ static int gr_probe(struct platform_device *pdev)
10913 + return -ENOMEM;
10914 + }
10915 +
10916 +- spin_lock(&dev->lock);
10917 +-
10918 + /* Inside lock so that no gadget can use this udc until probe is done */
10919 + retval = usb_add_gadget_udc(dev->dev, &dev->gadget);
10920 + if (retval) {
10921 +@@ -2185,15 +2183,21 @@ static int gr_probe(struct platform_device *pdev)
10922 + }
10923 + dev->added = 1;
10924 +
10925 ++ spin_lock(&dev->lock);
10926 ++
10927 + retval = gr_udc_init(dev);
10928 +- if (retval)
10929 ++ if (retval) {
10930 ++ spin_unlock(&dev->lock);
10931 + goto out;
10932 +-
10933 +- gr_dfs_create(dev);
10934 ++ }
10935 +
10936 + /* Clear all interrupt enables that might be left on since last boot */
10937 + gr_disable_interrupts_and_pullup(dev);
10938 +
10939 ++ spin_unlock(&dev->lock);
10940 ++
10941 ++ gr_dfs_create(dev);
10942 ++
10943 + retval = gr_request_irq(dev, dev->irq);
10944 + if (retval) {
10945 + dev_err(dev->dev, "Failed to request irq %d\n", dev->irq);
10946 +@@ -2222,8 +2226,6 @@ static int gr_probe(struct platform_device *pdev)
10947 + dev_info(dev->dev, "regs: %p, irq %d\n", dev->regs, dev->irq);
10948 +
10949 + out:
10950 +- spin_unlock(&dev->lock);
10951 +-
10952 + if (retval)
10953 + gr_remove(pdev);
10954 +
10955 +diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
10956 +index a3d2fef67746..5c93226e0e20 100644
10957 +--- a/drivers/usb/musb/omap2430.c
10958 ++++ b/drivers/usb/musb/omap2430.c
10959 +@@ -361,8 +361,6 @@ static const struct musb_platform_ops omap2430_ops = {
10960 + .init = omap2430_musb_init,
10961 + .exit = omap2430_musb_exit,
10962 +
10963 +- .set_vbus = omap2430_musb_set_vbus,
10964 +-
10965 + .enable = omap2430_musb_enable,
10966 + .disable = omap2430_musb_disable,
10967 +
10968 +diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
10969 +index f2983f0f84be..3f5f8198a6bb 100644
10970 +--- a/drivers/vfio/pci/vfio_pci_nvlink2.c
10971 ++++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
10972 +@@ -97,8 +97,10 @@ static void vfio_pci_nvgpu_release(struct vfio_pci_device *vdev,
10973 +
10974 + /* If there were any mappings at all... */
10975 + if (data->mm) {
10976 +- ret = mm_iommu_put(data->mm, data->mem);
10977 +- WARN_ON(ret);
10978 ++ if (data->mem) {
10979 ++ ret = mm_iommu_put(data->mm, data->mem);
10980 ++ WARN_ON(ret);
10981 ++ }
10982 +
10983 + mmdrop(data->mm);
10984 + }
10985 +diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
10986 +index d46052d8ff41..3d276b30a78c 100644
10987 +--- a/drivers/video/backlight/qcom-wled.c
10988 ++++ b/drivers/video/backlight/qcom-wled.c
10989 +@@ -956,8 +956,8 @@ static int wled_configure(struct wled *wled, int version)
10990 + struct wled_config *cfg = &wled->cfg;
10991 + struct device *dev = wled->dev;
10992 + const __be32 *prop_addr;
10993 +- u32 size, val, c, string_len;
10994 +- int rc, i, j;
10995 ++ u32 size, val, c;
10996 ++ int rc, i, j, string_len;
10997 +
10998 + const struct wled_u32_opts *u32_opts = NULL;
10999 + const struct wled_u32_opts wled3_opts[] = {
11000 +diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
11001 +index aa9541bf964b..f65991a67af2 100644
11002 +--- a/drivers/video/fbdev/Kconfig
11003 ++++ b/drivers/video/fbdev/Kconfig
11004 +@@ -2215,6 +2215,7 @@ config FB_HYPERV
11005 + select FB_CFB_COPYAREA
11006 + select FB_CFB_IMAGEBLIT
11007 + select FB_DEFERRED_IO
11008 ++ select DMA_CMA if HAVE_DMA_CONTIGUOUS && CMA
11009 + help
11010 + This framebuffer driver supports Microsoft Hyper-V Synthetic Video.
11011 +
11012 +diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
11013 +index 4cd27e5172a1..8cf39d98b2bd 100644
11014 +--- a/drivers/video/fbdev/hyperv_fb.c
11015 ++++ b/drivers/video/fbdev/hyperv_fb.c
11016 +@@ -31,6 +31,16 @@
11017 + * "set-vmvideo" command. For example
11018 + * set-vmvideo -vmname name -horizontalresolution:1920 \
11019 + * -verticalresolution:1200 -resolutiontype single
11020 ++ *
11021 ++ * Gen 1 VMs also support direct using VM's physical memory for framebuffer.
11022 ++ * It could improve the efficiency and performance for framebuffer and VM.
11023 ++ * This requires to allocate contiguous physical memory from Linux kernel's
11024 ++ * CMA memory allocator. To enable this, supply a kernel parameter to give
11025 ++ * enough memory space to CMA allocator for framebuffer. For example:
11026 ++ * cma=130m
11027 ++ * This gives 130MB memory to CMA allocator that can be allocated to
11028 ++ * framebuffer. For reference, 8K resolution (7680x4320) takes about
11029 ++ * 127MB memory.
11030 + */
11031 +
11032 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11033 +@@ -228,7 +238,6 @@ struct synthvid_msg {
11034 + } __packed;
11035 +
11036 +
11037 +-
11038 + /* FB driver definitions and structures */
11039 + #define HVFB_WIDTH 1152 /* default screen width */
11040 + #define HVFB_HEIGHT 864 /* default screen height */
11041 +@@ -258,12 +267,15 @@ struct hvfb_par {
11042 + /* If true, the VSC notifies the VSP on every framebuffer change */
11043 + bool synchronous_fb;
11044 +
11045 ++ /* If true, need to copy from deferred IO mem to framebuffer mem */
11046 ++ bool need_docopy;
11047 ++
11048 + struct notifier_block hvfb_panic_nb;
11049 +
11050 + /* Memory for deferred IO and frame buffer itself */
11051 + unsigned char *dio_vp;
11052 + unsigned char *mmio_vp;
11053 +- unsigned long mmio_pp;
11054 ++ phys_addr_t mmio_pp;
11055 +
11056 + /* Dirty rectangle, protected by delayed_refresh_lock */
11057 + int x1, y1, x2, y2;
11058 +@@ -434,7 +446,7 @@ static void synthvid_deferred_io(struct fb_info *p,
11059 + maxy = max_t(int, maxy, y2);
11060 +
11061 + /* Copy from dio space to mmio address */
11062 +- if (par->fb_ready)
11063 ++ if (par->fb_ready && par->need_docopy)
11064 + hvfb_docopy(par, start, PAGE_SIZE);
11065 + }
11066 +
11067 +@@ -751,12 +763,12 @@ static void hvfb_update_work(struct work_struct *w)
11068 + return;
11069 +
11070 + /* Copy the dirty rectangle to frame buffer memory */
11071 +- for (j = y1; j < y2; j++) {
11072 +- hvfb_docopy(par,
11073 +- j * info->fix.line_length +
11074 +- (x1 * screen_depth / 8),
11075 +- (x2 - x1) * screen_depth / 8);
11076 +- }
11077 ++ if (par->need_docopy)
11078 ++ for (j = y1; j < y2; j++)
11079 ++ hvfb_docopy(par,
11080 ++ j * info->fix.line_length +
11081 ++ (x1 * screen_depth / 8),
11082 ++ (x2 - x1) * screen_depth / 8);
11083 +
11084 + /* Refresh */
11085 + if (par->fb_ready && par->update)
11086 +@@ -801,7 +813,8 @@ static int hvfb_on_panic(struct notifier_block *nb,
11087 + par = container_of(nb, struct hvfb_par, hvfb_panic_nb);
11088 + par->synchronous_fb = true;
11089 + info = par->info;
11090 +- hvfb_docopy(par, 0, dio_fb_size);
11091 ++ if (par->need_docopy)
11092 ++ hvfb_docopy(par, 0, dio_fb_size);
11093 + synthvid_update(info, 0, 0, INT_MAX, INT_MAX);
11094 +
11095 + return NOTIFY_DONE;
11096 +@@ -940,6 +953,62 @@ static void hvfb_get_option(struct fb_info *info)
11097 + return;
11098 + }
11099 +
11100 ++/*
11101 ++ * Allocate enough contiguous physical memory.
11102 ++ * Return physical address if succeeded or -1 if failed.
11103 ++ */
11104 ++static phys_addr_t hvfb_get_phymem(struct hv_device *hdev,
11105 ++ unsigned int request_size)
11106 ++{
11107 ++ struct page *page = NULL;
11108 ++ dma_addr_t dma_handle;
11109 ++ void *vmem;
11110 ++ phys_addr_t paddr = 0;
11111 ++ unsigned int order = get_order(request_size);
11112 ++
11113 ++ if (request_size == 0)
11114 ++ return -1;
11115 ++
11116 ++ if (order < MAX_ORDER) {
11117 ++ /* Call alloc_pages if the size is less than 2^MAX_ORDER */
11118 ++ page = alloc_pages(GFP_KERNEL | __GFP_ZERO, order);
11119 ++ if (!page)
11120 ++ return -1;
11121 ++
11122 ++ paddr = (page_to_pfn(page) << PAGE_SHIFT);
11123 ++ } else {
11124 ++ /* Allocate from CMA */
11125 ++ hdev->device.coherent_dma_mask = DMA_BIT_MASK(64);
11126 ++
11127 ++ vmem = dma_alloc_coherent(&hdev->device,
11128 ++ round_up(request_size, PAGE_SIZE),
11129 ++ &dma_handle,
11130 ++ GFP_KERNEL | __GFP_NOWARN);
11131 ++
11132 ++ if (!vmem)
11133 ++ return -1;
11134 ++
11135 ++ paddr = virt_to_phys(vmem);
11136 ++ }
11137 ++
11138 ++ return paddr;
11139 ++}
11140 ++
11141 ++/* Release contiguous physical memory */
11142 ++static void hvfb_release_phymem(struct hv_device *hdev,
11143 ++ phys_addr_t paddr, unsigned int size)
11144 ++{
11145 ++ unsigned int order = get_order(size);
11146 ++
11147 ++ if (order < MAX_ORDER)
11148 ++ __free_pages(pfn_to_page(paddr >> PAGE_SHIFT), order);
11149 ++ else
11150 ++ dma_free_coherent(&hdev->device,
11151 ++ round_up(size, PAGE_SIZE),
11152 ++ phys_to_virt(paddr),
11153 ++ paddr);
11154 ++}
11155 ++
11156 +
11157 + /* Get framebuffer memory from Hyper-V video pci space */
11158 + static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
11159 +@@ -949,22 +1018,61 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
11160 + void __iomem *fb_virt;
11161 + int gen2vm = efi_enabled(EFI_BOOT);
11162 + resource_size_t pot_start, pot_end;
11163 ++ phys_addr_t paddr;
11164 + int ret;
11165 +
11166 +- dio_fb_size =
11167 +- screen_width * screen_height * screen_depth / 8;
11168 ++ info->apertures = alloc_apertures(1);
11169 ++ if (!info->apertures)
11170 ++ return -ENOMEM;
11171 +
11172 +- if (gen2vm) {
11173 +- pot_start = 0;
11174 +- pot_end = -1;
11175 +- } else {
11176 ++ if (!gen2vm) {
11177 + pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
11178 +- PCI_DEVICE_ID_HYPERV_VIDEO, NULL);
11179 ++ PCI_DEVICE_ID_HYPERV_VIDEO, NULL);
11180 + if (!pdev) {
11181 + pr_err("Unable to find PCI Hyper-V video\n");
11182 ++ kfree(info->apertures);
11183 + return -ENODEV;
11184 + }
11185 +
11186 ++ info->apertures->ranges[0].base = pci_resource_start(pdev, 0);
11187 ++ info->apertures->ranges[0].size = pci_resource_len(pdev, 0);
11188 ++
11189 ++ /*
11190 ++ * For Gen 1 VM, we can directly use the contiguous memory
11191 ++ * from VM. If we succeed, deferred IO happens directly
11192 ++ * on this allocated framebuffer memory, avoiding extra
11193 ++ * memory copy.
11194 ++ */
11195 ++ paddr = hvfb_get_phymem(hdev, screen_fb_size);
11196 ++ if (paddr != (phys_addr_t) -1) {
11197 ++ par->mmio_pp = paddr;
11198 ++ par->mmio_vp = par->dio_vp = __va(paddr);
11199 ++
11200 ++ info->fix.smem_start = paddr;
11201 ++ info->fix.smem_len = screen_fb_size;
11202 ++ info->screen_base = par->mmio_vp;
11203 ++ info->screen_size = screen_fb_size;
11204 ++
11205 ++ par->need_docopy = false;
11206 ++ goto getmem_done;
11207 ++ }
11208 ++ pr_info("Unable to allocate enough contiguous physical memory on Gen 1 VM. Using MMIO instead.\n");
11209 ++ } else {
11210 ++ info->apertures->ranges[0].base = screen_info.lfb_base;
11211 ++ info->apertures->ranges[0].size = screen_info.lfb_size;
11212 ++ }
11213 ++
11214 ++ /*
11215 ++ * Cannot use the contiguous physical memory.
11216 ++ * Allocate mmio space for framebuffer.
11217 ++ */
11218 ++ dio_fb_size =
11219 ++ screen_width * screen_height * screen_depth / 8;
11220 ++
11221 ++ if (gen2vm) {
11222 ++ pot_start = 0;
11223 ++ pot_end = -1;
11224 ++ } else {
11225 + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM) ||
11226 + pci_resource_len(pdev, 0) < screen_fb_size) {
11227 + pr_err("Resource not available or (0x%lx < 0x%lx)\n",
11228 +@@ -993,20 +1101,6 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
11229 + if (par->dio_vp == NULL)
11230 + goto err3;
11231 +
11232 +- info->apertures = alloc_apertures(1);
11233 +- if (!info->apertures)
11234 +- goto err4;
11235 +-
11236 +- if (gen2vm) {
11237 +- info->apertures->ranges[0].base = screen_info.lfb_base;
11238 +- info->apertures->ranges[0].size = screen_info.lfb_size;
11239 +- remove_conflicting_framebuffers(info->apertures,
11240 +- KBUILD_MODNAME, false);
11241 +- } else {
11242 +- info->apertures->ranges[0].base = pci_resource_start(pdev, 0);
11243 +- info->apertures->ranges[0].size = pci_resource_len(pdev, 0);
11244 +- }
11245 +-
11246 + /* Physical address of FB device */
11247 + par->mmio_pp = par->mem->start;
11248 + /* Virtual address of FB device */
11249 +@@ -1017,13 +1111,15 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
11250 + info->screen_base = par->dio_vp;
11251 + info->screen_size = dio_fb_size;
11252 +
11253 ++getmem_done:
11254 ++ remove_conflicting_framebuffers(info->apertures,
11255 ++ KBUILD_MODNAME, false);
11256 + if (!gen2vm)
11257 + pci_dev_put(pdev);
11258 ++ kfree(info->apertures);
11259 +
11260 + return 0;
11261 +
11262 +-err4:
11263 +- vfree(par->dio_vp);
11264 + err3:
11265 + iounmap(fb_virt);
11266 + err2:
11267 +@@ -1032,18 +1128,25 @@ err2:
11268 + err1:
11269 + if (!gen2vm)
11270 + pci_dev_put(pdev);
11271 ++ kfree(info->apertures);
11272 +
11273 + return -ENOMEM;
11274 + }
11275 +
11276 + /* Release the framebuffer */
11277 +-static void hvfb_putmem(struct fb_info *info)
11278 ++static void hvfb_putmem(struct hv_device *hdev, struct fb_info *info)
11279 + {
11280 + struct hvfb_par *par = info->par;
11281 +
11282 +- vfree(par->dio_vp);
11283 +- iounmap(info->screen_base);
11284 +- vmbus_free_mmio(par->mem->start, screen_fb_size);
11285 ++ if (par->need_docopy) {
11286 ++ vfree(par->dio_vp);
11287 ++ iounmap(info->screen_base);
11288 ++ vmbus_free_mmio(par->mem->start, screen_fb_size);
11289 ++ } else {
11290 ++ hvfb_release_phymem(hdev, info->fix.smem_start,
11291 ++ screen_fb_size);
11292 ++ }
11293 ++
11294 + par->mem = NULL;
11295 + }
11296 +
11297 +@@ -1062,6 +1165,7 @@ static int hvfb_probe(struct hv_device *hdev,
11298 + par = info->par;
11299 + par->info = info;
11300 + par->fb_ready = false;
11301 ++ par->need_docopy = true;
11302 + init_completion(&par->wait);
11303 + INIT_DELAYED_WORK(&par->dwork, hvfb_update_work);
11304 +
11305 +@@ -1147,7 +1251,7 @@ static int hvfb_probe(struct hv_device *hdev,
11306 +
11307 + error:
11308 + fb_deferred_io_cleanup(info);
11309 +- hvfb_putmem(info);
11310 ++ hvfb_putmem(hdev, info);
11311 + error2:
11312 + vmbus_close(hdev->channel);
11313 + error1:
11314 +@@ -1177,7 +1281,7 @@ static int hvfb_remove(struct hv_device *hdev)
11315 + vmbus_close(hdev->channel);
11316 + hv_set_drvdata(hdev, NULL);
11317 +
11318 +- hvfb_putmem(info);
11319 ++ hvfb_putmem(hdev, info);
11320 + framebuffer_release(info);
11321 +
11322 + return 0;
11323 +diff --git a/drivers/video/fbdev/pxa168fb.c b/drivers/video/fbdev/pxa168fb.c
11324 +index 1410f476e135..1fc50fc0694b 100644
11325 +--- a/drivers/video/fbdev/pxa168fb.c
11326 ++++ b/drivers/video/fbdev/pxa168fb.c
11327 +@@ -766,8 +766,8 @@ failed_free_cmap:
11328 + failed_free_clk:
11329 + clk_disable_unprepare(fbi->clk);
11330 + failed_free_fbmem:
11331 +- dma_free_coherent(fbi->dev, info->fix.smem_len,
11332 +- info->screen_base, fbi->fb_start_dma);
11333 ++ dma_free_wc(fbi->dev, info->fix.smem_len,
11334 ++ info->screen_base, fbi->fb_start_dma);
11335 + failed_free_info:
11336 + kfree(info);
11337 +
11338 +@@ -801,7 +801,7 @@ static int pxa168fb_remove(struct platform_device *pdev)
11339 +
11340 + irq = platform_get_irq(pdev, 0);
11341 +
11342 +- dma_free_wc(fbi->dev, PAGE_ALIGN(info->fix.smem_len),
11343 ++ dma_free_wc(fbi->dev, info->fix.smem_len,
11344 + info->screen_base, info->fix.smem_start);
11345 +
11346 + clk_disable_unprepare(fbi->clk);
11347 +diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
11348 +index 7e5d84caeb94..7bfe365d9372 100644
11349 +--- a/drivers/virtio/virtio_balloon.c
11350 ++++ b/drivers/virtio/virtio_balloon.c
11351 +@@ -158,6 +158,8 @@ static void set_page_pfns(struct virtio_balloon *vb,
11352 + {
11353 + unsigned int i;
11354 +
11355 ++ BUILD_BUG_ON(VIRTIO_BALLOON_PAGES_PER_PAGE > VIRTIO_BALLOON_ARRAY_PFNS_MAX);
11356 ++
11357 + /*
11358 + * Set balloon pfns pointing at this page.
11359 + * Note that the first pfn points at start of the page.
11360 +diff --git a/drivers/visorbus/visorchipset.c b/drivers/visorbus/visorchipset.c
11361 +index ca752b8f495f..cb1eb7e05f87 100644
11362 +--- a/drivers/visorbus/visorchipset.c
11363 ++++ b/drivers/visorbus/visorchipset.c
11364 +@@ -1210,14 +1210,17 @@ static void setup_crash_devices_work_queue(struct work_struct *work)
11365 + {
11366 + struct controlvm_message local_crash_bus_msg;
11367 + struct controlvm_message local_crash_dev_msg;
11368 +- struct controlvm_message msg;
11369 ++ struct controlvm_message msg = {
11370 ++ .hdr.id = CONTROLVM_CHIPSET_INIT,
11371 ++ .cmd.init_chipset = {
11372 ++ .bus_count = 23,
11373 ++ .switch_count = 0,
11374 ++ },
11375 ++ };
11376 + u32 local_crash_msg_offset;
11377 + u16 local_crash_msg_count;
11378 +
11379 + /* send init chipset msg */
11380 +- msg.hdr.id = CONTROLVM_CHIPSET_INIT;
11381 +- msg.cmd.init_chipset.bus_count = 23;
11382 +- msg.cmd.init_chipset.switch_count = 0;
11383 + chipset_init(&msg);
11384 + /* get saved message count */
11385 + if (visorchannel_read(chipset_dev->controlvm_channel,
11386 +diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
11387 +index 3208a4409e44..6a1bc284f297 100644
11388 +--- a/drivers/vme/bridges/vme_fake.c
11389 ++++ b/drivers/vme/bridges/vme_fake.c
11390 +@@ -414,8 +414,9 @@ static void fake_lm_check(struct fake_driver *bridge, unsigned long long addr,
11391 + }
11392 + }
11393 +
11394 +-static u8 fake_vmeread8(struct fake_driver *bridge, unsigned long long addr,
11395 +- u32 aspace, u32 cycle)
11396 ++static noinline_for_stack u8 fake_vmeread8(struct fake_driver *bridge,
11397 ++ unsigned long long addr,
11398 ++ u32 aspace, u32 cycle)
11399 + {
11400 + u8 retval = 0xff;
11401 + int i;
11402 +@@ -446,8 +447,9 @@ static u8 fake_vmeread8(struct fake_driver *bridge, unsigned long long addr,
11403 + return retval;
11404 + }
11405 +
11406 +-static u16 fake_vmeread16(struct fake_driver *bridge, unsigned long long addr,
11407 +- u32 aspace, u32 cycle)
11408 ++static noinline_for_stack u16 fake_vmeread16(struct fake_driver *bridge,
11409 ++ unsigned long long addr,
11410 ++ u32 aspace, u32 cycle)
11411 + {
11412 + u16 retval = 0xffff;
11413 + int i;
11414 +@@ -478,8 +480,9 @@ static u16 fake_vmeread16(struct fake_driver *bridge, unsigned long long addr,
11415 + return retval;
11416 + }
11417 +
11418 +-static u32 fake_vmeread32(struct fake_driver *bridge, unsigned long long addr,
11419 +- u32 aspace, u32 cycle)
11420 ++static noinline_for_stack u32 fake_vmeread32(struct fake_driver *bridge,
11421 ++ unsigned long long addr,
11422 ++ u32 aspace, u32 cycle)
11423 + {
11424 + u32 retval = 0xffffffff;
11425 + int i;
11426 +@@ -609,8 +612,9 @@ out:
11427 + return retval;
11428 + }
11429 +
11430 +-static void fake_vmewrite8(struct fake_driver *bridge, u8 *buf,
11431 +- unsigned long long addr, u32 aspace, u32 cycle)
11432 ++static noinline_for_stack void fake_vmewrite8(struct fake_driver *bridge,
11433 ++ u8 *buf, unsigned long long addr,
11434 ++ u32 aspace, u32 cycle)
11435 + {
11436 + int i;
11437 + unsigned long long start, end, offset;
11438 +@@ -639,8 +643,9 @@ static void fake_vmewrite8(struct fake_driver *bridge, u8 *buf,
11439 +
11440 + }
11441 +
11442 +-static void fake_vmewrite16(struct fake_driver *bridge, u16 *buf,
11443 +- unsigned long long addr, u32 aspace, u32 cycle)
11444 ++static noinline_for_stack void fake_vmewrite16(struct fake_driver *bridge,
11445 ++ u16 *buf, unsigned long long addr,
11446 ++ u32 aspace, u32 cycle)
11447 + {
11448 + int i;
11449 + unsigned long long start, end, offset;
11450 +@@ -669,8 +674,9 @@ static void fake_vmewrite16(struct fake_driver *bridge, u16 *buf,
11451 +
11452 + }
11453 +
11454 +-static void fake_vmewrite32(struct fake_driver *bridge, u32 *buf,
11455 +- unsigned long long addr, u32 aspace, u32 cycle)
11456 ++static noinline_for_stack void fake_vmewrite32(struct fake_driver *bridge,
11457 ++ u32 *buf, unsigned long long addr,
11458 ++ u32 aspace, u32 cycle)
11459 + {
11460 + int i;
11461 + unsigned long long start, end, offset;
11462 +diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
11463 +index 0b52ab4cb964..72c70f59fc60 100644
11464 +--- a/fs/btrfs/check-integrity.c
11465 ++++ b/fs/btrfs/check-integrity.c
11466 +@@ -629,7 +629,6 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(dev_t dev,
11467 + static int btrfsic_process_superblock(struct btrfsic_state *state,
11468 + struct btrfs_fs_devices *fs_devices)
11469 + {
11470 +- struct btrfs_fs_info *fs_info = state->fs_info;
11471 + struct btrfs_super_block *selected_super;
11472 + struct list_head *dev_head = &fs_devices->devices;
11473 + struct btrfs_device *device;
11474 +@@ -700,7 +699,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
11475 + break;
11476 + }
11477 +
11478 +- num_copies = btrfs_num_copies(fs_info, next_bytenr,
11479 ++ num_copies = btrfs_num_copies(state->fs_info, next_bytenr,
11480 + state->metablock_size);
11481 + if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES)
11482 + pr_info("num_copies(log_bytenr=%llu) = %d\n",
11483 +diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
11484 +index ba7292435c14..2e9f938508e9 100644
11485 +--- a/fs/btrfs/ctree.h
11486 ++++ b/fs/btrfs/ctree.h
11487 +@@ -3108,17 +3108,21 @@ do { \
11488 + rcu_read_unlock(); \
11489 + } while (0)
11490 +
11491 +-__cold
11492 +-static inline void assfail(const char *expr, const char *file, int line)
11493 ++#ifdef CONFIG_BTRFS_ASSERT
11494 ++__cold __noreturn
11495 ++static inline void assertfail(const char *expr, const char *file, int line)
11496 + {
11497 +- if (IS_ENABLED(CONFIG_BTRFS_ASSERT)) {
11498 +- pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
11499 +- BUG();
11500 +- }
11501 ++ pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
11502 ++ BUG();
11503 + }
11504 +
11505 +-#define ASSERT(expr) \
11506 +- (likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
11507 ++#define ASSERT(expr) \
11508 ++ (likely(expr) ? (void)0 : assertfail(#expr, __FILE__, __LINE__))
11509 ++
11510 ++#else
11511 ++static inline void assertfail(const char *expr, const char* file, int line) { }
11512 ++#define ASSERT(expr) (void)(expr)
11513 ++#endif
11514 +
11515 + /*
11516 + * Use that for functions that are conditionally exported for sanity tests but
11517 +diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
11518 +index b1bfdc5c1387..6f18333e83c3 100644
11519 +--- a/fs/btrfs/file-item.c
11520 ++++ b/fs/btrfs/file-item.c
11521 +@@ -274,7 +274,8 @@ found:
11522 + csum += count * csum_size;
11523 + nblocks -= count;
11524 + next:
11525 +- while (count--) {
11526 ++ while (count > 0) {
11527 ++ count--;
11528 + disk_bytenr += fs_info->sectorsize;
11529 + offset += fs_info->sectorsize;
11530 + page_bytes_left -= fs_info->sectorsize;
11531 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
11532 +index c70baafb2a39..537b4c563f09 100644
11533 +--- a/fs/btrfs/inode.c
11534 ++++ b/fs/btrfs/inode.c
11535 +@@ -2191,6 +2191,7 @@ int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,
11536 + /* see btrfs_writepage_start_hook for details on why this is required */
11537 + struct btrfs_writepage_fixup {
11538 + struct page *page;
11539 ++ struct inode *inode;
11540 + struct btrfs_work work;
11541 + };
11542 +
11543 +@@ -2204,27 +2205,71 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)
11544 + struct inode *inode;
11545 + u64 page_start;
11546 + u64 page_end;
11547 +- int ret;
11548 ++ int ret = 0;
11549 ++ bool free_delalloc_space = true;
11550 +
11551 + fixup = container_of(work, struct btrfs_writepage_fixup, work);
11552 + page = fixup->page;
11553 ++ inode = fixup->inode;
11554 ++ page_start = page_offset(page);
11555 ++ page_end = page_offset(page) + PAGE_SIZE - 1;
11556 ++
11557 ++ /*
11558 ++ * This is similar to page_mkwrite, we need to reserve the space before
11559 ++ * we take the page lock.
11560 ++ */
11561 ++ ret = btrfs_delalloc_reserve_space(inode, &data_reserved, page_start,
11562 ++ PAGE_SIZE);
11563 + again:
11564 + lock_page(page);
11565 ++
11566 ++ /*
11567 ++ * Before we queued this fixup, we took a reference on the page.
11568 ++ * page->mapping may go NULL, but it shouldn't be moved to a different
11569 ++ * address space.
11570 ++ */
11571 + if (!page->mapping || !PageDirty(page) || !PageChecked(page)) {
11572 +- ClearPageChecked(page);
11573 ++ /*
11574 ++ * Unfortunately this is a little tricky, either
11575 ++ *
11576 ++ * 1) We got here and our page had already been dealt with and
11577 ++ * we reserved our space, thus ret == 0, so we need to just
11578 ++ * drop our space reservation and bail. This can happen the
11579 ++ * first time we come into the fixup worker, or could happen
11580 ++ * while waiting for the ordered extent.
11581 ++ * 2) Our page was already dealt with, but we happened to get an
11582 ++ * ENOSPC above from the btrfs_delalloc_reserve_space. In
11583 ++ * this case we obviously don't have anything to release, but
11584 ++ * because the page was already dealt with we don't want to
11585 ++ * mark the page with an error, so make sure we're resetting
11586 ++ * ret to 0. This is why we have this check _before_ the ret
11587 ++ * check, because we do not want to have a surprise ENOSPC
11588 ++ * when the page was already properly dealt with.
11589 ++ */
11590 ++ if (!ret) {
11591 ++ btrfs_delalloc_release_extents(BTRFS_I(inode),
11592 ++ PAGE_SIZE);
11593 ++ btrfs_delalloc_release_space(inode, data_reserved,
11594 ++ page_start, PAGE_SIZE,
11595 ++ true);
11596 ++ }
11597 ++ ret = 0;
11598 + goto out_page;
11599 + }
11600 +
11601 +- inode = page->mapping->host;
11602 +- page_start = page_offset(page);
11603 +- page_end = page_offset(page) + PAGE_SIZE - 1;
11604 ++ /*
11605 ++ * We can't mess with the page state unless it is locked, so now that
11606 ++ * it is locked bail if we failed to make our space reservation.
11607 ++ */
11608 ++ if (ret)
11609 ++ goto out_page;
11610 +
11611 + lock_extent_bits(&BTRFS_I(inode)->io_tree, page_start, page_end,
11612 + &cached_state);
11613 +
11614 + /* already ordered? We're done */
11615 + if (PagePrivate2(page))
11616 +- goto out;
11617 ++ goto out_reserved;
11618 +
11619 + ordered = btrfs_lookup_ordered_range(BTRFS_I(inode), page_start,
11620 + PAGE_SIZE);
11621 +@@ -2237,39 +2282,49 @@ again:
11622 + goto again;
11623 + }
11624 +
11625 +- ret = btrfs_delalloc_reserve_space(inode, &data_reserved, page_start,
11626 +- PAGE_SIZE);
11627 +- if (ret) {
11628 +- mapping_set_error(page->mapping, ret);
11629 +- end_extent_writepage(page, ret, page_start, page_end);
11630 +- ClearPageChecked(page);
11631 +- goto out;
11632 +- }
11633 +-
11634 + ret = btrfs_set_extent_delalloc(inode, page_start, page_end, 0,
11635 + &cached_state);
11636 +- if (ret) {
11637 +- mapping_set_error(page->mapping, ret);
11638 +- end_extent_writepage(page, ret, page_start, page_end);
11639 +- ClearPageChecked(page);
11640 ++ if (ret)
11641 + goto out_reserved;
11642 +- }
11643 +
11644 +- ClearPageChecked(page);
11645 +- set_page_dirty(page);
11646 ++ /*
11647 ++ * Everything went as planned, we're now the owner of a dirty page with
11648 ++ * delayed allocation bits set and space reserved for our COW
11649 ++ * destination.
11650 ++ *
11651 ++ * The page was dirty when we started, nothing should have cleaned it.
11652 ++ */
11653 ++ BUG_ON(!PageDirty(page));
11654 ++ free_delalloc_space = false;
11655 + out_reserved:
11656 + btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE);
11657 +- if (ret)
11658 ++ if (free_delalloc_space)
11659 + btrfs_delalloc_release_space(inode, data_reserved, page_start,
11660 + PAGE_SIZE, true);
11661 +-out:
11662 + unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, page_end,
11663 + &cached_state);
11664 + out_page:
11665 ++ if (ret) {
11666 ++ /*
11667 ++ * We hit ENOSPC or other errors. Update the mapping and page
11668 ++ * to reflect the errors and clean the page.
11669 ++ */
11670 ++ mapping_set_error(page->mapping, ret);
11671 ++ end_extent_writepage(page, ret, page_start, page_end);
11672 ++ clear_page_dirty_for_io(page);
11673 ++ SetPageError(page);
11674 ++ }
11675 ++ ClearPageChecked(page);
11676 + unlock_page(page);
11677 + put_page(page);
11678 + kfree(fixup);
11679 + extent_changeset_free(data_reserved);
11680 ++ /*
11681 ++ * As a precaution, do a delayed iput in case it would be the last iput
11682 ++ * that could need flushing space. Recursing back to fixup worker would
11683 ++ * deadlock.
11684 ++ */
11685 ++ btrfs_add_delayed_iput(inode);
11686 + }
11687 +
11688 + /*
11689 +@@ -2293,6 +2348,13 @@ int btrfs_writepage_cow_fixup(struct page *page, u64 start, u64 end)
11690 + if (TestClearPagePrivate2(page))
11691 + return 0;
11692 +
11693 ++ /*
11694 ++ * PageChecked is set below when we create a fixup worker for this page,
11695 ++ * don't try to create another one if we're already PageChecked()
11696 ++ *
11697 ++ * The extent_io writepage code will redirty the page if we send back
11698 ++ * EAGAIN.
11699 ++ */
11700 + if (PageChecked(page))
11701 + return -EAGAIN;
11702 +
11703 +@@ -2300,12 +2362,21 @@ int btrfs_writepage_cow_fixup(struct page *page, u64 start, u64 end)
11704 + if (!fixup)
11705 + return -EAGAIN;
11706 +
11707 ++ /*
11708 ++ * We are already holding a reference to this inode from
11709 ++ * write_cache_pages. We need to hold it because the space reservation
11710 ++ * takes place outside of the page lock, and we can't trust
11711 ++ * page->mapping outside of the page lock.
11712 ++ */
11713 ++ ihold(inode);
11714 + SetPageChecked(page);
11715 + get_page(page);
11716 + btrfs_init_work(&fixup->work, btrfs_writepage_fixup_worker, NULL, NULL);
11717 + fixup->page = page;
11718 ++ fixup->inode = inode;
11719 + btrfs_queue_work(fs_info->fixup_workers, &fixup->work);
11720 +- return -EBUSY;
11721 ++
11722 ++ return -EAGAIN;
11723 + }
11724 +
11725 + static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
11726 +diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
11727 +index 72ff80f7f24c..a8b71ded4d21 100644
11728 +--- a/fs/btrfs/volumes.c
11729 ++++ b/fs/btrfs/volumes.c
11730 +@@ -723,6 +723,32 @@ static struct btrfs_fs_devices *find_fsid_changed(
11731 +
11732 + return NULL;
11733 + }
11734 ++
11735 ++static struct btrfs_fs_devices *find_fsid_reverted_metadata(
11736 ++ struct btrfs_super_block *disk_super)
11737 ++{
11738 ++ struct btrfs_fs_devices *fs_devices;
11739 ++
11740 ++ /*
11741 ++ * Handle the case where the scanned device is part of an fs whose last
11742 ++ * metadata UUID change reverted it to the original FSID. At the same
11743 ++ * time * fs_devices was first created by another constitutent device
11744 ++ * which didn't fully observe the operation. This results in an
11745 ++ * btrfs_fs_devices created with metadata/fsid different AND
11746 ++ * btrfs_fs_devices::fsid_change set AND the metadata_uuid of the
11747 ++ * fs_devices equal to the FSID of the disk.
11748 ++ */
11749 ++ list_for_each_entry(fs_devices, &fs_uuids, fs_list) {
11750 ++ if (memcmp(fs_devices->fsid, fs_devices->metadata_uuid,
11751 ++ BTRFS_FSID_SIZE) != 0 &&
11752 ++ memcmp(fs_devices->metadata_uuid, disk_super->fsid,
11753 ++ BTRFS_FSID_SIZE) == 0 &&
11754 ++ fs_devices->fsid_change)
11755 ++ return fs_devices;
11756 ++ }
11757 ++
11758 ++ return NULL;
11759 ++}
11760 + /*
11761 + * Add new device to list of registered devices
11762 + *
11763 +@@ -762,7 +788,9 @@ static noinline struct btrfs_device *device_list_add(const char *path,
11764 + fs_devices = find_fsid(disk_super->fsid,
11765 + disk_super->metadata_uuid);
11766 + } else {
11767 +- fs_devices = find_fsid(disk_super->fsid, NULL);
11768 ++ fs_devices = find_fsid_reverted_metadata(disk_super);
11769 ++ if (!fs_devices)
11770 ++ fs_devices = find_fsid(disk_super->fsid, NULL);
11771 + }
11772 +
11773 +
11774 +@@ -792,12 +820,18 @@ static noinline struct btrfs_device *device_list_add(const char *path,
11775 + * a device which had the CHANGING_FSID_V2 flag then replace the
11776 + * metadata_uuid/fsid values of the fs_devices.
11777 + */
11778 +- if (has_metadata_uuid && fs_devices->fsid_change &&
11779 ++ if (fs_devices->fsid_change &&
11780 + found_transid > fs_devices->latest_generation) {
11781 + memcpy(fs_devices->fsid, disk_super->fsid,
11782 + BTRFS_FSID_SIZE);
11783 +- memcpy(fs_devices->metadata_uuid,
11784 +- disk_super->metadata_uuid, BTRFS_FSID_SIZE);
11785 ++
11786 ++ if (has_metadata_uuid)
11787 ++ memcpy(fs_devices->metadata_uuid,
11788 ++ disk_super->metadata_uuid,
11789 ++ BTRFS_FSID_SIZE);
11790 ++ else
11791 ++ memcpy(fs_devices->metadata_uuid,
11792 ++ disk_super->fsid, BTRFS_FSID_SIZE);
11793 +
11794 + fs_devices->fsid_change = false;
11795 + }
11796 +@@ -7342,6 +7376,8 @@ int btrfs_get_dev_stats(struct btrfs_fs_info *fs_info,
11797 + else
11798 + btrfs_dev_stat_set(dev, i, 0);
11799 + }
11800 ++ btrfs_info(fs_info, "device stats zeroed by %s (%d)",
11801 ++ current->comm, task_pid_nr(current));
11802 + } else {
11803 + for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++)
11804 + if (stats->nr_items > i)
11805 +diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
11806 +index 145d46ba25ae..816d49aed96b 100644
11807 +--- a/fs/ceph/mds_client.c
11808 ++++ b/fs/ceph/mds_client.c
11809 +@@ -2558,8 +2558,7 @@ static void __do_request(struct ceph_mds_client *mdsc,
11810 + if (!(mdsc->fsc->mount_options->flags &
11811 + CEPH_MOUNT_OPT_MOUNTWAIT) &&
11812 + !ceph_mdsmap_is_cluster_available(mdsc->mdsmap)) {
11813 +- err = -ENOENT;
11814 +- pr_info("probably no mds server is up\n");
11815 ++ err = -EHOSTUNREACH;
11816 + goto finish;
11817 + }
11818 + }
11819 +diff --git a/fs/ceph/super.c b/fs/ceph/super.c
11820 +index 9b5536451528..5a708ac9a54c 100644
11821 +--- a/fs/ceph/super.c
11822 ++++ b/fs/ceph/super.c
11823 +@@ -1066,6 +1066,11 @@ static int ceph_get_tree(struct fs_context *fc)
11824 + return 0;
11825 +
11826 + out_splat:
11827 ++ if (!ceph_mdsmap_is_cluster_available(fsc->mdsc->mdsmap)) {
11828 ++ pr_info("No mds server is up or the cluster is laggy\n");
11829 ++ err = -EHOSTUNREACH;
11830 ++ }
11831 ++
11832 + ceph_mdsc_close_sessions(fsc->mdsc);
11833 + deactivate_locked_super(sb);
11834 + goto out_final;
11835 +diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
11836 +index 41957b82d796..606f26d862dc 100644
11837 +--- a/fs/cifs/cifs_dfs_ref.c
11838 ++++ b/fs/cifs/cifs_dfs_ref.c
11839 +@@ -120,17 +120,17 @@ cifs_build_devname(char *nodename, const char *prepath)
11840 +
11841 +
11842 + /**
11843 +- * cifs_compose_mount_options - creates mount options for refferral
11844 ++ * cifs_compose_mount_options - creates mount options for referral
11845 + * @sb_mountdata: parent/root DFS mount options (template)
11846 + * @fullpath: full path in UNC format
11847 +- * @ref: server's referral
11848 ++ * @ref: optional server's referral
11849 + * @devname: optional pointer for saving device name
11850 + *
11851 + * creates mount options for submount based on template options sb_mountdata
11852 + * and replacing unc,ip,prefixpath options with ones we've got form ref_unc.
11853 + *
11854 + * Returns: pointer to new mount options or ERR_PTR.
11855 +- * Caller is responcible for freeing retunrned value if it is not error.
11856 ++ * Caller is responsible for freeing returned value if it is not error.
11857 + */
11858 + char *cifs_compose_mount_options(const char *sb_mountdata,
11859 + const char *fullpath,
11860 +@@ -150,18 +150,27 @@ char *cifs_compose_mount_options(const char *sb_mountdata,
11861 + if (sb_mountdata == NULL)
11862 + return ERR_PTR(-EINVAL);
11863 +
11864 +- if (strlen(fullpath) - ref->path_consumed) {
11865 +- prepath = fullpath + ref->path_consumed;
11866 +- /* skip initial delimiter */
11867 +- if (*prepath == '/' || *prepath == '\\')
11868 +- prepath++;
11869 +- }
11870 ++ if (ref) {
11871 ++ if (strlen(fullpath) - ref->path_consumed) {
11872 ++ prepath = fullpath + ref->path_consumed;
11873 ++ /* skip initial delimiter */
11874 ++ if (*prepath == '/' || *prepath == '\\')
11875 ++ prepath++;
11876 ++ }
11877 +
11878 +- name = cifs_build_devname(ref->node_name, prepath);
11879 +- if (IS_ERR(name)) {
11880 +- rc = PTR_ERR(name);
11881 +- name = NULL;
11882 +- goto compose_mount_options_err;
11883 ++ name = cifs_build_devname(ref->node_name, prepath);
11884 ++ if (IS_ERR(name)) {
11885 ++ rc = PTR_ERR(name);
11886 ++ name = NULL;
11887 ++ goto compose_mount_options_err;
11888 ++ }
11889 ++ } else {
11890 ++ name = cifs_build_devname((char *)fullpath, NULL);
11891 ++ if (IS_ERR(name)) {
11892 ++ rc = PTR_ERR(name);
11893 ++ name = NULL;
11894 ++ goto compose_mount_options_err;
11895 ++ }
11896 + }
11897 +
11898 + rc = dns_resolve_server_name_to_ip(name, &srvIP);
11899 +@@ -225,6 +234,8 @@ char *cifs_compose_mount_options(const char *sb_mountdata,
11900 +
11901 + if (devname)
11902 + *devname = name;
11903 ++ else
11904 ++ kfree(name);
11905 +
11906 + /*cifs_dbg(FYI, "%s: parent mountdata: %s\n", __func__, sb_mountdata);*/
11907 + /*cifs_dbg(FYI, "%s: submount mountdata: %s\n", __func__, mountdata );*/
11908 +@@ -241,23 +252,23 @@ compose_mount_options_err:
11909 + }
11910 +
11911 + /**
11912 +- * cifs_dfs_do_refmount - mounts specified path using provided refferal
11913 ++ * cifs_dfs_do_mount - mounts specified path using DFS full path
11914 ++ *
11915 ++ * Always pass down @fullpath to smb3_do_mount() so we can use the root server
11916 ++ * to perform failover in case we failed to connect to the first target in the
11917 ++ * referral.
11918 ++ *
11919 + * @cifs_sb: parent/root superblock
11920 + * @fullpath: full path in UNC format
11921 +- * @ref: server's referral
11922 + */
11923 +-static struct vfsmount *cifs_dfs_do_refmount(struct dentry *mntpt,
11924 +- struct cifs_sb_info *cifs_sb,
11925 +- const char *fullpath, const struct dfs_info3_param *ref)
11926 ++static struct vfsmount *cifs_dfs_do_mount(struct dentry *mntpt,
11927 ++ struct cifs_sb_info *cifs_sb,
11928 ++ const char *fullpath)
11929 + {
11930 + struct vfsmount *mnt;
11931 + char *mountdata;
11932 + char *devname;
11933 +
11934 +- /*
11935 +- * Always pass down the DFS full path to smb3_do_mount() so we
11936 +- * can use it later for failover.
11937 +- */
11938 + devname = kstrndup(fullpath, strlen(fullpath), GFP_KERNEL);
11939 + if (!devname)
11940 + return ERR_PTR(-ENOMEM);
11941 +@@ -266,7 +277,7 @@ static struct vfsmount *cifs_dfs_do_refmount(struct dentry *mntpt,
11942 +
11943 + /* strip first '\' from fullpath */
11944 + mountdata = cifs_compose_mount_options(cifs_sb->mountdata,
11945 +- fullpath + 1, ref, NULL);
11946 ++ fullpath + 1, NULL, NULL);
11947 + if (IS_ERR(mountdata)) {
11948 + kfree(devname);
11949 + return (struct vfsmount *)mountdata;
11950 +@@ -278,28 +289,16 @@ static struct vfsmount *cifs_dfs_do_refmount(struct dentry *mntpt,
11951 + return mnt;
11952 + }
11953 +
11954 +-static void dump_referral(const struct dfs_info3_param *ref)
11955 +-{
11956 +- cifs_dbg(FYI, "DFS: ref path: %s\n", ref->path_name);
11957 +- cifs_dbg(FYI, "DFS: node path: %s\n", ref->node_name);
11958 +- cifs_dbg(FYI, "DFS: fl: %d, srv_type: %d\n",
11959 +- ref->flags, ref->server_type);
11960 +- cifs_dbg(FYI, "DFS: ref_flags: %d, path_consumed: %d\n",
11961 +- ref->ref_flag, ref->path_consumed);
11962 +-}
11963 +-
11964 + /*
11965 + * Create a vfsmount that we can automount
11966 + */
11967 + static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt)
11968 + {
11969 +- struct dfs_info3_param referral = {0};
11970 + struct cifs_sb_info *cifs_sb;
11971 + struct cifs_ses *ses;
11972 + struct cifs_tcon *tcon;
11973 + char *full_path, *root_path;
11974 + unsigned int xid;
11975 +- int len;
11976 + int rc;
11977 + struct vfsmount *mnt;
11978 +
11979 +@@ -357,7 +356,7 @@ static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt)
11980 + if (!rc) {
11981 + rc = dfs_cache_find(xid, ses, cifs_sb->local_nls,
11982 + cifs_remap(cifs_sb), full_path + 1,
11983 +- &referral, NULL);
11984 ++ NULL, NULL);
11985 + }
11986 +
11987 + free_xid(xid);
11988 +@@ -366,26 +365,16 @@ static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt)
11989 + mnt = ERR_PTR(rc);
11990 + goto free_root_path;
11991 + }
11992 +-
11993 +- dump_referral(&referral);
11994 +-
11995 +- len = strlen(referral.node_name);
11996 +- if (len < 2) {
11997 +- cifs_dbg(VFS, "%s: Net Address path too short: %s\n",
11998 +- __func__, referral.node_name);
11999 +- mnt = ERR_PTR(-EINVAL);
12000 +- goto free_dfs_ref;
12001 +- }
12002 + /*
12003 +- * cifs_mount() will retry every available node server in case
12004 +- * of failures.
12005 ++ * OK - we were able to get and cache a referral for @full_path.
12006 ++ *
12007 ++ * Now, pass it down to cifs_mount() and it will retry every available
12008 ++ * node server in case of failures - no need to do it here.
12009 + */
12010 +- mnt = cifs_dfs_do_refmount(mntpt, cifs_sb, full_path, &referral);
12011 +- cifs_dbg(FYI, "%s: cifs_dfs_do_refmount:%s , mnt:%p\n", __func__,
12012 +- referral.node_name, mnt);
12013 ++ mnt = cifs_dfs_do_mount(mntpt, cifs_sb, full_path);
12014 ++ cifs_dbg(FYI, "%s: cifs_dfs_do_mount:%s , mnt:%p\n", __func__,
12015 ++ full_path + 1, mnt);
12016 +
12017 +-free_dfs_ref:
12018 +- free_dfs_info_param(&referral);
12019 + free_root_path:
12020 + kfree(root_path);
12021 + free_full_path:
12022 +diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
12023 +index 05ea0e2b7e0e..0aa3623ae0e1 100644
12024 +--- a/fs/cifs/connect.c
12025 ++++ b/fs/cifs/connect.c
12026 +@@ -3709,8 +3709,10 @@ match_prepath(struct super_block *sb, struct cifs_mnt_data *mnt_data)
12027 + {
12028 + struct cifs_sb_info *old = CIFS_SB(sb);
12029 + struct cifs_sb_info *new = mnt_data->cifs_sb;
12030 +- bool old_set = old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
12031 +- bool new_set = new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
12032 ++ bool old_set = (old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) &&
12033 ++ old->prepath;
12034 ++ bool new_set = (new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) &&
12035 ++ new->prepath;
12036 +
12037 + if (old_set && new_set && !strcmp(new->prepath, old->prepath))
12038 + return 1;
12039 +diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c
12040 +index 2faa05860a48..cf6cec59696c 100644
12041 +--- a/fs/cifs/dfs_cache.c
12042 ++++ b/fs/cifs/dfs_cache.c
12043 +@@ -1319,7 +1319,7 @@ static struct cifs_ses *find_root_ses(struct dfs_cache_vol_info *vi,
12044 + char *mdata = NULL, *devname = NULL;
12045 + struct TCP_Server_Info *server;
12046 + struct cifs_ses *ses;
12047 +- struct smb_vol vol;
12048 ++ struct smb_vol vol = {NULL};
12049 +
12050 + rpath = get_dfs_root(path);
12051 + if (IS_ERR(rpath))
12052 +diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
12053 +index 0a3b37abc5e1..6c9497c18f0b 100644
12054 +--- a/fs/cifs/smb2pdu.c
12055 ++++ b/fs/cifs/smb2pdu.c
12056 +@@ -4029,6 +4029,9 @@ smb2_writev_callback(struct mid_q_entry *mid)
12057 + wdata->cfile->fid.persistent_fid,
12058 + tcon->tid, tcon->ses->Suid, wdata->offset,
12059 + wdata->bytes, wdata->result);
12060 ++ if (wdata->result == -ENOSPC)
12061 ++ printk_once(KERN_WARNING "Out of space writing to %s\n",
12062 ++ tcon->treeName);
12063 + } else
12064 + trace_smb3_write_done(0 /* no xid */,
12065 + wdata->cfile->fid.persistent_fid,
12066 +diff --git a/fs/ext4/file.c b/fs/ext4/file.c
12067 +index 6a7293a5cda2..977ac58dc718 100644
12068 +--- a/fs/ext4/file.c
12069 ++++ b/fs/ext4/file.c
12070 +@@ -88,9 +88,10 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)
12071 + struct inode *inode = file_inode(iocb->ki_filp);
12072 + ssize_t ret;
12073 +
12074 +- if (!inode_trylock_shared(inode)) {
12075 +- if (iocb->ki_flags & IOCB_NOWAIT)
12076 ++ if (iocb->ki_flags & IOCB_NOWAIT) {
12077 ++ if (!inode_trylock_shared(inode))
12078 + return -EAGAIN;
12079 ++ } else {
12080 + inode_lock_shared(inode);
12081 + }
12082 + /*
12083 +@@ -487,9 +488,10 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)
12084 + bool extend = false;
12085 + struct inode *inode = file_inode(iocb->ki_filp);
12086 +
12087 +- if (!inode_trylock(inode)) {
12088 +- if (iocb->ki_flags & IOCB_NOWAIT)
12089 ++ if (iocb->ki_flags & IOCB_NOWAIT) {
12090 ++ if (!inode_trylock(inode))
12091 + return -EAGAIN;
12092 ++ } else {
12093 + inode_lock(inode);
12094 + }
12095 +
12096 +diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c
12097 +index fef7755300c3..410c904cf59b 100644
12098 +--- a/fs/ext4/readpage.c
12099 ++++ b/fs/ext4/readpage.c
12100 +@@ -57,6 +57,7 @@ enum bio_post_read_step {
12101 + STEP_INITIAL = 0,
12102 + STEP_DECRYPT,
12103 + STEP_VERITY,
12104 ++ STEP_MAX,
12105 + };
12106 +
12107 + struct bio_post_read_ctx {
12108 +@@ -106,10 +107,22 @@ static void verity_work(struct work_struct *work)
12109 + {
12110 + struct bio_post_read_ctx *ctx =
12111 + container_of(work, struct bio_post_read_ctx, work);
12112 ++ struct bio *bio = ctx->bio;
12113 +
12114 +- fsverity_verify_bio(ctx->bio);
12115 ++ /*
12116 ++ * fsverity_verify_bio() may call readpages() again, and although verity
12117 ++ * will be disabled for that, decryption may still be needed, causing
12118 ++ * another bio_post_read_ctx to be allocated. So to guarantee that
12119 ++ * mempool_alloc() never deadlocks we must free the current ctx first.
12120 ++ * This is safe because verity is the last post-read step.
12121 ++ */
12122 ++ BUILD_BUG_ON(STEP_VERITY + 1 != STEP_MAX);
12123 ++ mempool_free(ctx, bio_post_read_ctx_pool);
12124 ++ bio->bi_private = NULL;
12125 +
12126 +- bio_post_read_processing(ctx);
12127 ++ fsverity_verify_bio(bio);
12128 ++
12129 ++ __read_end_io(bio);
12130 + }
12131 +
12132 + static void bio_post_read_processing(struct bio_post_read_ctx *ctx)
12133 +diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
12134 +index a034cd0ce021..fc40a72f7827 100644
12135 +--- a/fs/f2fs/data.c
12136 ++++ b/fs/f2fs/data.c
12137 +@@ -1180,19 +1180,6 @@ int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from)
12138 + int err = 0;
12139 + bool direct_io = iocb->ki_flags & IOCB_DIRECT;
12140 +
12141 +- /* convert inline data for Direct I/O*/
12142 +- if (direct_io) {
12143 +- err = f2fs_convert_inline_inode(inode);
12144 +- if (err)
12145 +- return err;
12146 +- }
12147 +-
12148 +- if (direct_io && allow_outplace_dio(inode, iocb, from))
12149 +- return 0;
12150 +-
12151 +- if (is_inode_flag_set(inode, FI_NO_PREALLOC))
12152 +- return 0;
12153 +-
12154 + map.m_lblk = F2FS_BLK_ALIGN(iocb->ki_pos);
12155 + map.m_len = F2FS_BYTES_TO_BLK(iocb->ki_pos + iov_iter_count(from));
12156 + if (map.m_len > map.m_lblk)
12157 +diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
12158 +index 13aef5f28fa8..6c4436a5ce79 100644
12159 +--- a/fs/f2fs/file.c
12160 ++++ b/fs/f2fs/file.c
12161 +@@ -50,7 +50,7 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
12162 + struct page *page = vmf->page;
12163 + struct inode *inode = file_inode(vmf->vma->vm_file);
12164 + struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
12165 +- struct dnode_of_data dn = { .node_changed = false };
12166 ++ struct dnode_of_data dn;
12167 + int err;
12168 +
12169 + if (unlikely(f2fs_cp_error(sbi))) {
12170 +@@ -63,6 +63,9 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
12171 + goto err;
12172 + }
12173 +
12174 ++ /* should do out of any locked page */
12175 ++ f2fs_balance_fs(sbi, true);
12176 ++
12177 + sb_start_pagefault(inode->i_sb);
12178 +
12179 + f2fs_bug_on(sbi, f2fs_has_inline_data(inode));
12180 +@@ -120,8 +123,6 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
12181 + out_sem:
12182 + up_read(&F2FS_I(inode)->i_mmap_sem);
12183 +
12184 +- f2fs_balance_fs(sbi, dn.node_changed);
12185 +-
12186 + sb_end_pagefault(inode->i_sb);
12187 + err:
12188 + return block_page_mkwrite_return(err);
12189 +@@ -3383,18 +3384,41 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
12190 + ret = -EAGAIN;
12191 + goto out;
12192 + }
12193 +- } else {
12194 +- preallocated = true;
12195 +- target_size = iocb->ki_pos + iov_iter_count(from);
12196 ++ goto write;
12197 ++ }
12198 +
12199 +- err = f2fs_preallocate_blocks(iocb, from);
12200 +- if (err) {
12201 +- clear_inode_flag(inode, FI_NO_PREALLOC);
12202 +- inode_unlock(inode);
12203 +- ret = err;
12204 +- goto out;
12205 +- }
12206 ++ if (is_inode_flag_set(inode, FI_NO_PREALLOC))
12207 ++ goto write;
12208 ++
12209 ++ if (iocb->ki_flags & IOCB_DIRECT) {
12210 ++ /*
12211 ++ * Convert inline data for Direct I/O before entering
12212 ++ * f2fs_direct_IO().
12213 ++ */
12214 ++ err = f2fs_convert_inline_inode(inode);
12215 ++ if (err)
12216 ++ goto out_err;
12217 ++ /*
12218 ++ * If force_buffere_io() is true, we have to allocate
12219 ++ * blocks all the time, since f2fs_direct_IO will fall
12220 ++ * back to buffered IO.
12221 ++ */
12222 ++ if (!f2fs_force_buffered_io(inode, iocb, from) &&
12223 ++ allow_outplace_dio(inode, iocb, from))
12224 ++ goto write;
12225 ++ }
12226 ++ preallocated = true;
12227 ++ target_size = iocb->ki_pos + iov_iter_count(from);
12228 ++
12229 ++ err = f2fs_preallocate_blocks(iocb, from);
12230 ++ if (err) {
12231 ++out_err:
12232 ++ clear_inode_flag(inode, FI_NO_PREALLOC);
12233 ++ inode_unlock(inode);
12234 ++ ret = err;
12235 ++ goto out;
12236 + }
12237 ++write:
12238 + ret = __generic_file_write_iter(iocb, from);
12239 + clear_inode_flag(inode, FI_NO_PREALLOC);
12240 +
12241 +diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
12242 +index a1c507b0b4ac..5d9584281935 100644
12243 +--- a/fs/f2fs/namei.c
12244 ++++ b/fs/f2fs/namei.c
12245 +@@ -797,6 +797,7 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
12246 +
12247 + if (whiteout) {
12248 + f2fs_i_links_write(inode, false);
12249 ++ inode->i_state |= I_LINKABLE;
12250 + *whiteout = inode;
12251 + } else {
12252 + d_tmpfile(dentry, inode);
12253 +@@ -867,6 +868,12 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
12254 + F2FS_I(old_dentry->d_inode)->i_projid)))
12255 + return -EXDEV;
12256 +
12257 ++ if (flags & RENAME_WHITEOUT) {
12258 ++ err = f2fs_create_whiteout(old_dir, &whiteout);
12259 ++ if (err)
12260 ++ return err;
12261 ++ }
12262 ++
12263 + err = dquot_initialize(old_dir);
12264 + if (err)
12265 + goto out;
12266 +@@ -898,17 +905,11 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
12267 + }
12268 + }
12269 +
12270 +- if (flags & RENAME_WHITEOUT) {
12271 +- err = f2fs_create_whiteout(old_dir, &whiteout);
12272 +- if (err)
12273 +- goto out_dir;
12274 +- }
12275 +-
12276 + if (new_inode) {
12277 +
12278 + err = -ENOTEMPTY;
12279 + if (old_dir_entry && !f2fs_empty_dir(new_inode))
12280 +- goto out_whiteout;
12281 ++ goto out_dir;
12282 +
12283 + err = -ENOENT;
12284 + new_entry = f2fs_find_entry(new_dir, &new_dentry->d_name,
12285 +@@ -916,7 +917,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
12286 + if (!new_entry) {
12287 + if (IS_ERR(new_page))
12288 + err = PTR_ERR(new_page);
12289 +- goto out_whiteout;
12290 ++ goto out_dir;
12291 + }
12292 +
12293 + f2fs_balance_fs(sbi, true);
12294 +@@ -948,7 +949,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
12295 + err = f2fs_add_link(new_dentry, old_inode);
12296 + if (err) {
12297 + f2fs_unlock_op(sbi);
12298 +- goto out_whiteout;
12299 ++ goto out_dir;
12300 + }
12301 +
12302 + if (old_dir_entry)
12303 +@@ -972,7 +973,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
12304 + if (IS_ERR(old_page))
12305 + err = PTR_ERR(old_page);
12306 + f2fs_unlock_op(sbi);
12307 +- goto out_whiteout;
12308 ++ goto out_dir;
12309 + }
12310 + }
12311 + }
12312 +@@ -991,7 +992,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
12313 + f2fs_delete_entry(old_entry, old_page, old_dir, NULL);
12314 +
12315 + if (whiteout) {
12316 +- whiteout->i_state |= I_LINKABLE;
12317 + set_inode_flag(whiteout, FI_INC_LINK);
12318 + err = f2fs_add_link(old_dentry, whiteout);
12319 + if (err)
12320 +@@ -1027,15 +1027,14 @@ put_out_dir:
12321 + f2fs_unlock_op(sbi);
12322 + if (new_page)
12323 + f2fs_put_page(new_page, 0);
12324 +-out_whiteout:
12325 +- if (whiteout)
12326 +- iput(whiteout);
12327 + out_dir:
12328 + if (old_dir_entry)
12329 + f2fs_put_page(old_dir_page, 0);
12330 + out_old:
12331 + f2fs_put_page(old_page, 0);
12332 + out:
12333 ++ if (whiteout)
12334 ++ iput(whiteout);
12335 + return err;
12336 + }
12337 +
12338 +diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
12339 +index 70945ceb9c0c..e79c86b8553a 100644
12340 +--- a/fs/f2fs/sysfs.c
12341 ++++ b/fs/f2fs/sysfs.c
12342 +@@ -733,10 +733,12 @@ int __init f2fs_init_sysfs(void)
12343 +
12344 + ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype,
12345 + NULL, "features");
12346 +- if (ret)
12347 ++ if (ret) {
12348 ++ kobject_put(&f2fs_feat);
12349 + kset_unregister(&f2fs_kset);
12350 +- else
12351 ++ } else {
12352 + f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
12353 ++ }
12354 + return ret;
12355 + }
12356 +
12357 +@@ -757,8 +759,11 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
12358 + init_completion(&sbi->s_kobj_unregister);
12359 + err = kobject_init_and_add(&sbi->s_kobj, &f2fs_sb_ktype, NULL,
12360 + "%s", sb->s_id);
12361 +- if (err)
12362 ++ if (err) {
12363 ++ kobject_put(&sbi->s_kobj);
12364 ++ wait_for_completion(&sbi->s_kobj_unregister);
12365 + return err;
12366 ++ }
12367 +
12368 + if (f2fs_proc_root)
12369 + sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root);
12370 +@@ -786,4 +791,5 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
12371 + remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
12372 + }
12373 + kobject_del(&sbi->s_kobj);
12374 ++ kobject_put(&sbi->s_kobj);
12375 + }
12376 +diff --git a/fs/fuse/file.c b/fs/fuse/file.c
12377 +index 695369f46f92..3dd37a998ea9 100644
12378 +--- a/fs/fuse/file.c
12379 ++++ b/fs/fuse/file.c
12380 +@@ -803,6 +803,10 @@ static int fuse_do_readpage(struct file *file, struct page *page)
12381 +
12382 + attr_ver = fuse_get_attr_version(fc);
12383 +
12384 ++ /* Don't overflow end offset */
12385 ++ if (pos + (desc.length - 1) == LLONG_MAX)
12386 ++ desc.length--;
12387 ++
12388 + fuse_read_args_fill(&ia, file, pos, desc.length, FUSE_READ);
12389 + res = fuse_simple_request(fc, &ia.ap.args);
12390 + if (res < 0)
12391 +@@ -888,6 +892,14 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file)
12392 + ap->args.out_pages = true;
12393 + ap->args.page_zeroing = true;
12394 + ap->args.page_replace = true;
12395 ++
12396 ++ /* Don't overflow end offset */
12397 ++ if (pos + (count - 1) == LLONG_MAX) {
12398 ++ count--;
12399 ++ ap->descs[ap->num_pages - 1].length--;
12400 ++ }
12401 ++ WARN_ON((loff_t) (pos + count) < 0);
12402 ++
12403 + fuse_read_args_fill(ia, file, pos, count, FUSE_READ);
12404 + ia->read.attr_ver = fuse_get_attr_version(fc);
12405 + if (fc->async_read) {
12406 +diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
12407 +index 8fff6677a5da..96bf33986d03 100644
12408 +--- a/fs/jbd2/checkpoint.c
12409 ++++ b/fs/jbd2/checkpoint.c
12410 +@@ -164,7 +164,7 @@ void __jbd2_log_wait_for_space(journal_t *journal)
12411 + "journal space in %s\n", __func__,
12412 + journal->j_devname);
12413 + WARN_ON(1);
12414 +- jbd2_journal_abort(journal, 0);
12415 ++ jbd2_journal_abort(journal, -EIO);
12416 + }
12417 + write_lock(&journal->j_state_lock);
12418 + } else {
12419 +diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
12420 +index 3845750f70ec..27373f5792a4 100644
12421 +--- a/fs/jbd2/commit.c
12422 ++++ b/fs/jbd2/commit.c
12423 +@@ -782,7 +782,7 @@ start_journal_io:
12424 + err = journal_submit_commit_record(journal, commit_transaction,
12425 + &cbh, crc32_sum);
12426 + if (err)
12427 +- __jbd2_journal_abort_hard(journal);
12428 ++ jbd2_journal_abort(journal, err);
12429 + }
12430 +
12431 + blk_finish_plug(&plug);
12432 +@@ -875,7 +875,7 @@ start_journal_io:
12433 + err = journal_submit_commit_record(journal, commit_transaction,
12434 + &cbh, crc32_sum);
12435 + if (err)
12436 +- __jbd2_journal_abort_hard(journal);
12437 ++ jbd2_journal_abort(journal, err);
12438 + }
12439 + if (cbh)
12440 + err = journal_wait_on_commit_record(journal, cbh);
12441 +diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
12442 +index b3e2433f94fe..0b4280fcad91 100644
12443 +--- a/fs/jbd2/journal.c
12444 ++++ b/fs/jbd2/journal.c
12445 +@@ -1711,6 +1711,11 @@ int jbd2_journal_load(journal_t *journal)
12446 + journal->j_devname);
12447 + return -EFSCORRUPTED;
12448 + }
12449 ++ /*
12450 ++ * clear JBD2_ABORT flag initialized in journal_init_common
12451 ++ * here to update log tail information with the newest seq.
12452 ++ */
12453 ++ journal->j_flags &= ~JBD2_ABORT;
12454 +
12455 + /* OK, we've finished with the dynamic journal bits:
12456 + * reinitialise the dynamic contents of the superblock in memory
12457 +@@ -1718,7 +1723,6 @@ int jbd2_journal_load(journal_t *journal)
12458 + if (journal_reset(journal))
12459 + goto recovery_error;
12460 +
12461 +- journal->j_flags &= ~JBD2_ABORT;
12462 + journal->j_flags |= JBD2_LOADED;
12463 + return 0;
12464 +
12465 +@@ -2143,8 +2147,7 @@ static void __journal_abort_soft (journal_t *journal, int errno)
12466 +
12467 + if (journal->j_flags & JBD2_ABORT) {
12468 + write_unlock(&journal->j_state_lock);
12469 +- if (!old_errno && old_errno != -ESHUTDOWN &&
12470 +- errno == -ESHUTDOWN)
12471 ++ if (old_errno != -ESHUTDOWN && errno == -ESHUTDOWN)
12472 + jbd2_journal_update_sb_errno(journal);
12473 + return;
12474 + }
12475 +@@ -2152,12 +2155,10 @@ static void __journal_abort_soft (journal_t *journal, int errno)
12476 +
12477 + __jbd2_journal_abort_hard(journal);
12478 +
12479 +- if (errno) {
12480 +- jbd2_journal_update_sb_errno(journal);
12481 +- write_lock(&journal->j_state_lock);
12482 +- journal->j_flags |= JBD2_REC_ERR;
12483 +- write_unlock(&journal->j_state_lock);
12484 +- }
12485 ++ jbd2_journal_update_sb_errno(journal);
12486 ++ write_lock(&journal->j_state_lock);
12487 ++ journal->j_flags |= JBD2_REC_ERR;
12488 ++ write_unlock(&journal->j_state_lock);
12489 + }
12490 +
12491 + /**
12492 +@@ -2199,11 +2200,6 @@ static void __journal_abort_soft (journal_t *journal, int errno)
12493 + * failure to disk. ext3_error, for example, now uses this
12494 + * functionality.
12495 + *
12496 +- * Errors which originate from within the journaling layer will NOT
12497 +- * supply an errno; a null errno implies that absolutely no further
12498 +- * writes are done to the journal (unless there are any already in
12499 +- * progress).
12500 +- *
12501 + */
12502 +
12503 + void jbd2_journal_abort(journal_t *journal, int errno)
12504 +diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
12505 +index 9637aad36bdc..e2ae54b35dfe 100644
12506 +--- a/fs/nfs/nfs42proc.c
12507 ++++ b/fs/nfs/nfs42proc.c
12508 +@@ -343,14 +343,14 @@ static ssize_t _nfs42_proc_copy(struct file *src,
12509 + status = handle_async_copy(res, dst_server, src_server, src,
12510 + dst, &args->src_stateid, restart);
12511 + if (status)
12512 +- return status;
12513 ++ goto out;
12514 + }
12515 +
12516 + if ((!res->synchronous || !args->sync) &&
12517 + res->write_res.verifier.committed != NFS_FILE_SYNC) {
12518 + status = process_copy_commit(dst, pos_dst, res);
12519 + if (status)
12520 +- return status;
12521 ++ goto out;
12522 + }
12523 +
12524 + truncate_pagecache_range(dst_inode, pos_dst,
12525 +diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
12526 +index d0feef17db50..dc6b9c2f36b2 100644
12527 +--- a/fs/nfs/nfs4xdr.c
12528 ++++ b/fs/nfs/nfs4xdr.c
12529 +@@ -4097,7 +4097,7 @@ static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, str
12530 + status = NFS_ATTR_FATTR_ATIME;
12531 + bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS;
12532 + }
12533 +- dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec);
12534 ++ dprintk("%s: atime=%lld\n", __func__, time->tv_sec);
12535 + return status;
12536 + }
12537 +
12538 +@@ -4115,7 +4115,7 @@ static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, s
12539 + status = NFS_ATTR_FATTR_CTIME;
12540 + bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA;
12541 + }
12542 +- dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec);
12543 ++ dprintk("%s: ctime=%lld\n", __func__, time->tv_sec);
12544 + return status;
12545 + }
12546 +
12547 +@@ -4132,8 +4132,8 @@ static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap,
12548 + status = decode_attr_time(xdr, time);
12549 + bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA;
12550 + }
12551 +- dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec,
12552 +- (long)time->tv_nsec);
12553 ++ dprintk("%s: time_delta=%lld %ld\n", __func__, time->tv_sec,
12554 ++ time->tv_nsec);
12555 + return status;
12556 + }
12557 +
12558 +@@ -4197,7 +4197,7 @@ static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, str
12559 + status = NFS_ATTR_FATTR_MTIME;
12560 + bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY;
12561 + }
12562 +- dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec);
12563 ++ dprintk("%s: mtime=%lld\n", __func__, time->tv_sec);
12564 + return status;
12565 + }
12566 +
12567 +diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
12568 +index f0bca0e87d0c..82cf80dde5c7 100644
12569 +--- a/fs/nfsd/vfs.c
12570 ++++ b/fs/nfsd/vfs.c
12571 +@@ -280,19 +280,25 @@ out:
12572 + * Commit metadata changes to stable storage.
12573 + */
12574 + static int
12575 +-commit_metadata(struct svc_fh *fhp)
12576 ++commit_inode_metadata(struct inode *inode)
12577 + {
12578 +- struct inode *inode = d_inode(fhp->fh_dentry);
12579 + const struct export_operations *export_ops = inode->i_sb->s_export_op;
12580 +
12581 +- if (!EX_ISSYNC(fhp->fh_export))
12582 +- return 0;
12583 +-
12584 + if (export_ops->commit_metadata)
12585 + return export_ops->commit_metadata(inode);
12586 + return sync_inode_metadata(inode, 1);
12587 + }
12588 +
12589 ++static int
12590 ++commit_metadata(struct svc_fh *fhp)
12591 ++{
12592 ++ struct inode *inode = d_inode(fhp->fh_dentry);
12593 ++
12594 ++ if (!EX_ISSYNC(fhp->fh_export))
12595 ++ return 0;
12596 ++ return commit_inode_metadata(inode);
12597 ++}
12598 ++
12599 + /*
12600 + * Go over the attributes and take care of the small differences between
12601 + * NFS semantics and what Linux expects.
12602 +@@ -537,6 +543,9 @@ __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst,
12603 + if (sync) {
12604 + loff_t dst_end = count ? dst_pos + count - 1 : LLONG_MAX;
12605 + int status = vfs_fsync_range(dst, dst_pos, dst_end, 0);
12606 ++
12607 ++ if (!status)
12608 ++ status = commit_inode_metadata(file_inode(src));
12609 + if (status < 0)
12610 + return nfserrno(status);
12611 + }
12612 +diff --git a/fs/ocfs2/dlm/Makefile b/fs/ocfs2/dlm/Makefile
12613 +index 38b224372776..5e700b45d32d 100644
12614 +--- a/fs/ocfs2/dlm/Makefile
12615 ++++ b/fs/ocfs2/dlm/Makefile
12616 +@@ -1,6 +1,4 @@
12617 + # SPDX-License-Identifier: GPL-2.0-only
12618 +-ccflags-y := -I $(srctree)/$(src)/..
12619 +-
12620 + obj-$(CONFIG_OCFS2_FS_O2CB) += ocfs2_dlm.o
12621 +
12622 + ocfs2_dlm-objs := dlmdomain.o dlmdebug.o dlmthread.o dlmrecovery.o \
12623 +diff --git a/fs/ocfs2/dlm/dlmast.c b/fs/ocfs2/dlm/dlmast.c
12624 +index 4de89af96abf..6abaded3ff6b 100644
12625 +--- a/fs/ocfs2/dlm/dlmast.c
12626 ++++ b/fs/ocfs2/dlm/dlmast.c
12627 +@@ -23,15 +23,15 @@
12628 + #include <linux/spinlock.h>
12629 +
12630 +
12631 +-#include "cluster/heartbeat.h"
12632 +-#include "cluster/nodemanager.h"
12633 +-#include "cluster/tcp.h"
12634 ++#include "../cluster/heartbeat.h"
12635 ++#include "../cluster/nodemanager.h"
12636 ++#include "../cluster/tcp.h"
12637 +
12638 + #include "dlmapi.h"
12639 + #include "dlmcommon.h"
12640 +
12641 + #define MLOG_MASK_PREFIX ML_DLM
12642 +-#include "cluster/masklog.h"
12643 ++#include "../cluster/masklog.h"
12644 +
12645 + static void dlm_update_lvb(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
12646 + struct dlm_lock *lock);
12647 +diff --git a/fs/ocfs2/dlm/dlmconvert.c b/fs/ocfs2/dlm/dlmconvert.c
12648 +index 965f45dbe17b..6051edc33aef 100644
12649 +--- a/fs/ocfs2/dlm/dlmconvert.c
12650 ++++ b/fs/ocfs2/dlm/dlmconvert.c
12651 +@@ -23,9 +23,9 @@
12652 + #include <linux/spinlock.h>
12653 +
12654 +
12655 +-#include "cluster/heartbeat.h"
12656 +-#include "cluster/nodemanager.h"
12657 +-#include "cluster/tcp.h"
12658 ++#include "../cluster/heartbeat.h"
12659 ++#include "../cluster/nodemanager.h"
12660 ++#include "../cluster/tcp.h"
12661 +
12662 + #include "dlmapi.h"
12663 + #include "dlmcommon.h"
12664 +@@ -33,7 +33,7 @@
12665 + #include "dlmconvert.h"
12666 +
12667 + #define MLOG_MASK_PREFIX ML_DLM
12668 +-#include "cluster/masklog.h"
12669 ++#include "../cluster/masklog.h"
12670 +
12671 + /* NOTE: __dlmconvert_master is the only function in here that
12672 + * needs a spinlock held on entry (res->spinlock) and it is the
12673 +diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
12674 +index 4d0b452012b2..c5c6efba7b5e 100644
12675 +--- a/fs/ocfs2/dlm/dlmdebug.c
12676 ++++ b/fs/ocfs2/dlm/dlmdebug.c
12677 +@@ -17,9 +17,9 @@
12678 + #include <linux/debugfs.h>
12679 + #include <linux/export.h>
12680 +
12681 +-#include "cluster/heartbeat.h"
12682 +-#include "cluster/nodemanager.h"
12683 +-#include "cluster/tcp.h"
12684 ++#include "../cluster/heartbeat.h"
12685 ++#include "../cluster/nodemanager.h"
12686 ++#include "../cluster/tcp.h"
12687 +
12688 + #include "dlmapi.h"
12689 + #include "dlmcommon.h"
12690 +@@ -27,7 +27,7 @@
12691 + #include "dlmdebug.h"
12692 +
12693 + #define MLOG_MASK_PREFIX ML_DLM
12694 +-#include "cluster/masklog.h"
12695 ++#include "../cluster/masklog.h"
12696 +
12697 + static int stringify_lockname(const char *lockname, int locklen, char *buf,
12698 + int len);
12699 +diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
12700 +index ee6f459f9770..357cfc702ce3 100644
12701 +--- a/fs/ocfs2/dlm/dlmdomain.c
12702 ++++ b/fs/ocfs2/dlm/dlmdomain.c
12703 +@@ -20,9 +20,9 @@
12704 + #include <linux/debugfs.h>
12705 + #include <linux/sched/signal.h>
12706 +
12707 +-#include "cluster/heartbeat.h"
12708 +-#include "cluster/nodemanager.h"
12709 +-#include "cluster/tcp.h"
12710 ++#include "../cluster/heartbeat.h"
12711 ++#include "../cluster/nodemanager.h"
12712 ++#include "../cluster/tcp.h"
12713 +
12714 + #include "dlmapi.h"
12715 + #include "dlmcommon.h"
12716 +@@ -30,7 +30,7 @@
12717 + #include "dlmdebug.h"
12718 +
12719 + #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_DOMAIN)
12720 +-#include "cluster/masklog.h"
12721 ++#include "../cluster/masklog.h"
12722 +
12723 + /*
12724 + * ocfs2 node maps are array of long int, which limits to send them freely
12725 +diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c
12726 +index baff087f3863..83f0760e4fba 100644
12727 +--- a/fs/ocfs2/dlm/dlmlock.c
12728 ++++ b/fs/ocfs2/dlm/dlmlock.c
12729 +@@ -25,9 +25,9 @@
12730 + #include <linux/delay.h>
12731 +
12732 +
12733 +-#include "cluster/heartbeat.h"
12734 +-#include "cluster/nodemanager.h"
12735 +-#include "cluster/tcp.h"
12736 ++#include "../cluster/heartbeat.h"
12737 ++#include "../cluster/nodemanager.h"
12738 ++#include "../cluster/tcp.h"
12739 +
12740 + #include "dlmapi.h"
12741 + #include "dlmcommon.h"
12742 +@@ -35,7 +35,7 @@
12743 + #include "dlmconvert.h"
12744 +
12745 + #define MLOG_MASK_PREFIX ML_DLM
12746 +-#include "cluster/masklog.h"
12747 ++#include "../cluster/masklog.h"
12748 +
12749 + static struct kmem_cache *dlm_lock_cache;
12750 +
12751 +diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
12752 +index 74b768ca1cd8..c9d7037b6793 100644
12753 +--- a/fs/ocfs2/dlm/dlmmaster.c
12754 ++++ b/fs/ocfs2/dlm/dlmmaster.c
12755 +@@ -25,9 +25,9 @@
12756 + #include <linux/delay.h>
12757 +
12758 +
12759 +-#include "cluster/heartbeat.h"
12760 +-#include "cluster/nodemanager.h"
12761 +-#include "cluster/tcp.h"
12762 ++#include "../cluster/heartbeat.h"
12763 ++#include "../cluster/nodemanager.h"
12764 ++#include "../cluster/tcp.h"
12765 +
12766 + #include "dlmapi.h"
12767 + #include "dlmcommon.h"
12768 +@@ -35,7 +35,7 @@
12769 + #include "dlmdebug.h"
12770 +
12771 + #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_MASTER)
12772 +-#include "cluster/masklog.h"
12773 ++#include "../cluster/masklog.h"
12774 +
12775 + static void dlm_mle_node_down(struct dlm_ctxt *dlm,
12776 + struct dlm_master_list_entry *mle,
12777 +diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
12778 +index 064ce5bbc3f6..bcaaca5112d6 100644
12779 +--- a/fs/ocfs2/dlm/dlmrecovery.c
12780 ++++ b/fs/ocfs2/dlm/dlmrecovery.c
12781 +@@ -26,16 +26,16 @@
12782 + #include <linux/delay.h>
12783 +
12784 +
12785 +-#include "cluster/heartbeat.h"
12786 +-#include "cluster/nodemanager.h"
12787 +-#include "cluster/tcp.h"
12788 ++#include "../cluster/heartbeat.h"
12789 ++#include "../cluster/nodemanager.h"
12790 ++#include "../cluster/tcp.h"
12791 +
12792 + #include "dlmapi.h"
12793 + #include "dlmcommon.h"
12794 + #include "dlmdomain.h"
12795 +
12796 + #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_RECOVERY)
12797 +-#include "cluster/masklog.h"
12798 ++#include "../cluster/masklog.h"
12799 +
12800 + static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node);
12801 +
12802 +diff --git a/fs/ocfs2/dlm/dlmthread.c b/fs/ocfs2/dlm/dlmthread.c
12803 +index 61c51c268460..fd40c17cd022 100644
12804 +--- a/fs/ocfs2/dlm/dlmthread.c
12805 ++++ b/fs/ocfs2/dlm/dlmthread.c
12806 +@@ -25,16 +25,16 @@
12807 + #include <linux/delay.h>
12808 +
12809 +
12810 +-#include "cluster/heartbeat.h"
12811 +-#include "cluster/nodemanager.h"
12812 +-#include "cluster/tcp.h"
12813 ++#include "../cluster/heartbeat.h"
12814 ++#include "../cluster/nodemanager.h"
12815 ++#include "../cluster/tcp.h"
12816 +
12817 + #include "dlmapi.h"
12818 + #include "dlmcommon.h"
12819 + #include "dlmdomain.h"
12820 +
12821 + #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_THREAD)
12822 +-#include "cluster/masklog.h"
12823 ++#include "../cluster/masklog.h"
12824 +
12825 + static int dlm_thread(void *data);
12826 + static void dlm_flush_asts(struct dlm_ctxt *dlm);
12827 +diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c
12828 +index 3883633e82eb..dcb17ca8ae74 100644
12829 +--- a/fs/ocfs2/dlm/dlmunlock.c
12830 ++++ b/fs/ocfs2/dlm/dlmunlock.c
12831 +@@ -23,15 +23,15 @@
12832 + #include <linux/spinlock.h>
12833 + #include <linux/delay.h>
12834 +
12835 +-#include "cluster/heartbeat.h"
12836 +-#include "cluster/nodemanager.h"
12837 +-#include "cluster/tcp.h"
12838 ++#include "../cluster/heartbeat.h"
12839 ++#include "../cluster/nodemanager.h"
12840 ++#include "../cluster/tcp.h"
12841 +
12842 + #include "dlmapi.h"
12843 + #include "dlmcommon.h"
12844 +
12845 + #define MLOG_MASK_PREFIX ML_DLM
12846 +-#include "cluster/masklog.h"
12847 ++#include "../cluster/masklog.h"
12848 +
12849 + #define DLM_UNLOCK_FREE_LOCK 0x00000001
12850 + #define DLM_UNLOCK_CALL_AST 0x00000002
12851 +diff --git a/fs/ocfs2/dlmfs/Makefile b/fs/ocfs2/dlmfs/Makefile
12852 +index a9874e441bd4..c7895f65be0e 100644
12853 +--- a/fs/ocfs2/dlmfs/Makefile
12854 ++++ b/fs/ocfs2/dlmfs/Makefile
12855 +@@ -1,6 +1,4 @@
12856 + # SPDX-License-Identifier: GPL-2.0-only
12857 +-ccflags-y := -I $(srctree)/$(src)/..
12858 +-
12859 + obj-$(CONFIG_OCFS2_FS) += ocfs2_dlmfs.o
12860 +
12861 + ocfs2_dlmfs-objs := userdlm.o dlmfs.o
12862 +diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
12863 +index 4f1668c81e1f..8e4f1ace467c 100644
12864 +--- a/fs/ocfs2/dlmfs/dlmfs.c
12865 ++++ b/fs/ocfs2/dlmfs/dlmfs.c
12866 +@@ -33,11 +33,11 @@
12867 +
12868 + #include <linux/uaccess.h>
12869 +
12870 +-#include "stackglue.h"
12871 ++#include "../stackglue.h"
12872 + #include "userdlm.h"
12873 +
12874 + #define MLOG_MASK_PREFIX ML_DLMFS
12875 +-#include "cluster/masklog.h"
12876 ++#include "../cluster/masklog.h"
12877 +
12878 +
12879 + static const struct super_operations dlmfs_ops;
12880 +diff --git a/fs/ocfs2/dlmfs/userdlm.c b/fs/ocfs2/dlmfs/userdlm.c
12881 +index 525b14ddfba5..3df5be25bfb1 100644
12882 +--- a/fs/ocfs2/dlmfs/userdlm.c
12883 ++++ b/fs/ocfs2/dlmfs/userdlm.c
12884 +@@ -21,12 +21,12 @@
12885 + #include <linux/types.h>
12886 + #include <linux/crc32.h>
12887 +
12888 +-#include "ocfs2_lockingver.h"
12889 +-#include "stackglue.h"
12890 ++#include "../ocfs2_lockingver.h"
12891 ++#include "../stackglue.h"
12892 + #include "userdlm.h"
12893 +
12894 + #define MLOG_MASK_PREFIX ML_DLMFS
12895 +-#include "cluster/masklog.h"
12896 ++#include "../cluster/masklog.h"
12897 +
12898 +
12899 + static inline struct user_lock_res *user_lksb_to_lock_res(struct ocfs2_dlm_lksb *lksb)
12900 +diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
12901 +index 3103ba7f97a2..bfe611ed1b1d 100644
12902 +--- a/fs/ocfs2/journal.h
12903 ++++ b/fs/ocfs2/journal.h
12904 +@@ -597,9 +597,11 @@ static inline void ocfs2_update_inode_fsync_trans(handle_t *handle,
12905 + {
12906 + struct ocfs2_inode_info *oi = OCFS2_I(inode);
12907 +
12908 +- oi->i_sync_tid = handle->h_transaction->t_tid;
12909 +- if (datasync)
12910 +- oi->i_datasync_tid = handle->h_transaction->t_tid;
12911 ++ if (!is_handle_aborted(handle)) {
12912 ++ oi->i_sync_tid = handle->h_transaction->t_tid;
12913 ++ if (datasync)
12914 ++ oi->i_datasync_tid = handle->h_transaction->t_tid;
12915 ++ }
12916 + }
12917 +
12918 + #endif /* OCFS2_JOURNAL_H */
12919 +diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
12920 +index 25543a966c48..29eaa4544372 100644
12921 +--- a/fs/orangefs/orangefs-debugfs.c
12922 ++++ b/fs/orangefs/orangefs-debugfs.c
12923 +@@ -273,6 +273,7 @@ static void *help_start(struct seq_file *m, loff_t *pos)
12924 +
12925 + static void *help_next(struct seq_file *m, void *v, loff_t *pos)
12926 + {
12927 ++ (*pos)++;
12928 + gossip_debug(GOSSIP_DEBUGFS_DEBUG, "help_next: start\n");
12929 +
12930 + return NULL;
12931 +diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
12932 +index da9ebe33882b..bb4973aefbb1 100644
12933 +--- a/fs/reiserfs/stree.c
12934 ++++ b/fs/reiserfs/stree.c
12935 +@@ -2246,7 +2246,8 @@ error_out:
12936 + /* also releases the path */
12937 + unfix_nodes(&s_ins_balance);
12938 + #ifdef REISERQUOTA_DEBUG
12939 +- reiserfs_debug(th->t_super, REISERFS_DEBUG_CODE,
12940 ++ if (inode)
12941 ++ reiserfs_debug(th->t_super, REISERFS_DEBUG_CODE,
12942 + "reiserquota insert_item(): freeing %u id=%u type=%c",
12943 + quota_bytes, inode->i_uid, head2type(ih));
12944 + #endif
12945 +diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
12946 +index d127af64283e..a6bce5b1fb1d 100644
12947 +--- a/fs/reiserfs/super.c
12948 ++++ b/fs/reiserfs/super.c
12949 +@@ -1948,7 +1948,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
12950 + if (!sbi->s_jdev) {
12951 + SWARN(silent, s, "", "Cannot allocate memory for "
12952 + "journal device name");
12953 +- goto error;
12954 ++ goto error_unlocked;
12955 + }
12956 + }
12957 + #ifdef CONFIG_QUOTA
12958 +diff --git a/fs/udf/super.c b/fs/udf/super.c
12959 +index 8c28e93e9b73..4baa1ca91e9b 100644
12960 +--- a/fs/udf/super.c
12961 ++++ b/fs/udf/super.c
12962 +@@ -1035,7 +1035,6 @@ static int check_partition_desc(struct super_block *sb,
12963 + switch (le32_to_cpu(p->accessType)) {
12964 + case PD_ACCESS_TYPE_READ_ONLY:
12965 + case PD_ACCESS_TYPE_WRITE_ONCE:
12966 +- case PD_ACCESS_TYPE_REWRITABLE:
12967 + case PD_ACCESS_TYPE_NONE:
12968 + goto force_ro;
12969 + }
12970 +@@ -2492,17 +2491,29 @@ static unsigned int udf_count_free_table(struct super_block *sb,
12971 + static unsigned int udf_count_free(struct super_block *sb)
12972 + {
12973 + unsigned int accum = 0;
12974 +- struct udf_sb_info *sbi;
12975 ++ struct udf_sb_info *sbi = UDF_SB(sb);
12976 + struct udf_part_map *map;
12977 ++ unsigned int part = sbi->s_partition;
12978 ++ int ptype = sbi->s_partmaps[part].s_partition_type;
12979 ++
12980 ++ if (ptype == UDF_METADATA_MAP25) {
12981 ++ part = sbi->s_partmaps[part].s_type_specific.s_metadata.
12982 ++ s_phys_partition_ref;
12983 ++ } else if (ptype == UDF_VIRTUAL_MAP15 || ptype == UDF_VIRTUAL_MAP20) {
12984 ++ /*
12985 ++ * Filesystems with VAT are append-only and we cannot write to
12986 ++ * them. Let's just report 0 here.
12987 ++ */
12988 ++ return 0;
12989 ++ }
12990 +
12991 +- sbi = UDF_SB(sb);
12992 + if (sbi->s_lvid_bh) {
12993 + struct logicalVolIntegrityDesc *lvid =
12994 + (struct logicalVolIntegrityDesc *)
12995 + sbi->s_lvid_bh->b_data;
12996 +- if (le32_to_cpu(lvid->numOfPartitions) > sbi->s_partition) {
12997 ++ if (le32_to_cpu(lvid->numOfPartitions) > part) {
12998 + accum = le32_to_cpu(
12999 +- lvid->freeSpaceTable[sbi->s_partition]);
13000 ++ lvid->freeSpaceTable[part]);
13001 + if (accum == 0xFFFFFFFF)
13002 + accum = 0;
13003 + }
13004 +@@ -2511,7 +2522,7 @@ static unsigned int udf_count_free(struct super_block *sb)
13005 + if (accum)
13006 + return accum;
13007 +
13008 +- map = &sbi->s_partmaps[sbi->s_partition];
13009 ++ map = &sbi->s_partmaps[part];
13010 + if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
13011 + accum += udf_count_free_bitmap(sb,
13012 + map->s_uspace.s_bitmap);
13013 +diff --git a/include/dt-bindings/clock/qcom,gcc-msm8998.h b/include/dt-bindings/clock/qcom,gcc-msm8998.h
13014 +index de1d8a1f5966..63e02dc32a0b 100644
13015 +--- a/include/dt-bindings/clock/qcom,gcc-msm8998.h
13016 ++++ b/include/dt-bindings/clock/qcom,gcc-msm8998.h
13017 +@@ -182,6 +182,7 @@
13018 + #define GCC_MSS_GPLL0_DIV_CLK_SRC 173
13019 + #define GCC_MSS_SNOC_AXI_CLK 174
13020 + #define GCC_MSS_MNOC_BIMC_AXI_CLK 175
13021 ++#define GCC_BIMC_GFX_CLK 176
13022 +
13023 + #define PCIE_0_GDSC 0
13024 + #define UFS_GDSC 1
13025 +diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
13026 +index e51ee772b9f5..def48a583670 100644
13027 +--- a/include/linux/cpuhotplug.h
13028 ++++ b/include/linux/cpuhotplug.h
13029 +@@ -59,6 +59,7 @@ enum cpuhp_state {
13030 + CPUHP_IOMMU_INTEL_DEAD,
13031 + CPUHP_LUSTRE_CFS_DEAD,
13032 + CPUHP_AP_ARM_CACHE_B15_RAC_DEAD,
13033 ++ CPUHP_PADATA_DEAD,
13034 + CPUHP_WORKQUEUE_PREP,
13035 + CPUHP_POWER_NUMA_PREPARE,
13036 + CPUHP_HRTIMERS_PREPARE,
13037 +diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
13038 +index fb376b5b7281..95816a8e3d26 100644
13039 +--- a/include/linux/devfreq.h
13040 ++++ b/include/linux/devfreq.h
13041 +@@ -177,8 +177,8 @@ struct devfreq {
13042 + /* information for device frequency transition */
13043 + unsigned int total_trans;
13044 + unsigned int *trans_table;
13045 +- unsigned long *time_in_state;
13046 +- unsigned long last_stat_updated;
13047 ++ u64 *time_in_state;
13048 ++ u64 last_stat_updated;
13049 +
13050 + struct srcu_notifier_head transition_notifier_list;
13051 +
13052 +diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
13053 +index dad4a68fa009..8013562751a5 100644
13054 +--- a/include/linux/dmaengine.h
13055 ++++ b/include/linux/dmaengine.h
13056 +@@ -674,6 +674,7 @@ struct dma_filter {
13057 + * @fill_align: alignment shift for memset operations
13058 + * @dev_id: unique device ID
13059 + * @dev: struct device reference for dma mapping api
13060 ++ * @owner: owner module (automatically set based on the provided dev)
13061 + * @src_addr_widths: bit mask of src addr widths the device supports
13062 + * Width is specified in bytes, e.g. for a device supporting
13063 + * a width of 4 the mask should have BIT(4) set.
13064 +@@ -737,6 +738,7 @@ struct dma_device {
13065 +
13066 + int dev_id;
13067 + struct device *dev;
13068 ++ struct module *owner;
13069 +
13070 + u32 src_addr_widths;
13071 + u32 dst_addr_widths;
13072 +diff --git a/include/linux/list_nulls.h b/include/linux/list_nulls.h
13073 +index 3ef96743db8d..1ecd35664e0d 100644
13074 +--- a/include/linux/list_nulls.h
13075 ++++ b/include/linux/list_nulls.h
13076 +@@ -72,10 +72,10 @@ static inline void hlist_nulls_add_head(struct hlist_nulls_node *n,
13077 + struct hlist_nulls_node *first = h->first;
13078 +
13079 + n->next = first;
13080 +- n->pprev = &h->first;
13081 ++ WRITE_ONCE(n->pprev, &h->first);
13082 + h->first = n;
13083 + if (!is_a_nulls(first))
13084 +- first->pprev = &n->next;
13085 ++ WRITE_ONCE(first->pprev, &n->next);
13086 + }
13087 +
13088 + static inline void __hlist_nulls_del(struct hlist_nulls_node *n)
13089 +@@ -85,13 +85,13 @@ static inline void __hlist_nulls_del(struct hlist_nulls_node *n)
13090 +
13091 + WRITE_ONCE(*pprev, next);
13092 + if (!is_a_nulls(next))
13093 +- next->pprev = pprev;
13094 ++ WRITE_ONCE(next->pprev, pprev);
13095 + }
13096 +
13097 + static inline void hlist_nulls_del(struct hlist_nulls_node *n)
13098 + {
13099 + __hlist_nulls_del(n);
13100 +- n->pprev = LIST_POISON2;
13101 ++ WRITE_ONCE(n->pprev, LIST_POISON2);
13102 + }
13103 +
13104 + /**
13105 +diff --git a/include/linux/pci.h b/include/linux/pci.h
13106 +index c393dff2d66f..930fab293073 100644
13107 +--- a/include/linux/pci.h
13108 ++++ b/include/linux/pci.h
13109 +@@ -2310,7 +2310,7 @@ static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
13110 + }
13111 + #endif
13112 +
13113 +-void pci_add_dma_alias(struct pci_dev *dev, u8 devfn);
13114 ++void pci_add_dma_alias(struct pci_dev *dev, u8 devfn_from, unsigned nr_devfns);
13115 + bool pci_devs_are_dma_aliases(struct pci_dev *dev1, struct pci_dev *dev2);
13116 + int pci_for_each_dma_alias(struct pci_dev *pdev,
13117 + int (*fn)(struct pci_dev *pdev,
13118 +diff --git a/include/linux/platform_data/ti-sysc.h b/include/linux/platform_data/ti-sysc.h
13119 +index 8cfe570fdece..2cbde6542849 100644
13120 +--- a/include/linux/platform_data/ti-sysc.h
13121 ++++ b/include/linux/platform_data/ti-sysc.h
13122 +@@ -49,6 +49,7 @@ struct sysc_regbits {
13123 + s8 emufree_shift;
13124 + };
13125 +
13126 ++#define SYSC_QUIRK_CLKDM_NOAUTO BIT(21)
13127 + #define SYSC_QUIRK_FORCE_MSTANDBY BIT(20)
13128 + #define SYSC_MODULE_QUIRK_AESS BIT(19)
13129 + #define SYSC_MODULE_QUIRK_SGX BIT(18)
13130 +diff --git a/include/linux/raid/pq.h b/include/linux/raid/pq.h
13131 +index 0832c9b66852..e0ddb47f4402 100644
13132 +--- a/include/linux/raid/pq.h
13133 ++++ b/include/linux/raid/pq.h
13134 +@@ -27,7 +27,6 @@ extern const char raid6_empty_zero_page[PAGE_SIZE];
13135 +
13136 + #include <errno.h>
13137 + #include <inttypes.h>
13138 +-#include <limits.h>
13139 + #include <stddef.h>
13140 + #include <sys/mman.h>
13141 + #include <sys/time.h>
13142 +@@ -59,7 +58,9 @@ extern const char raid6_empty_zero_page[PAGE_SIZE];
13143 + #define enable_kernel_altivec()
13144 + #define disable_kernel_altivec()
13145 +
13146 ++#undef EXPORT_SYMBOL
13147 + #define EXPORT_SYMBOL(sym)
13148 ++#undef EXPORT_SYMBOL_GPL
13149 + #define EXPORT_SYMBOL_GPL(sym)
13150 + #define MODULE_LICENSE(licence)
13151 + #define MODULE_DESCRIPTION(desc)
13152 +diff --git a/include/linux/rculist_nulls.h b/include/linux/rculist_nulls.h
13153 +index 61974c4c566b..90f2e2232c6d 100644
13154 +--- a/include/linux/rculist_nulls.h
13155 ++++ b/include/linux/rculist_nulls.h
13156 +@@ -34,7 +34,7 @@ static inline void hlist_nulls_del_init_rcu(struct hlist_nulls_node *n)
13157 + {
13158 + if (!hlist_nulls_unhashed(n)) {
13159 + __hlist_nulls_del(n);
13160 +- n->pprev = NULL;
13161 ++ WRITE_ONCE(n->pprev, NULL);
13162 + }
13163 + }
13164 +
13165 +@@ -66,7 +66,7 @@ static inline void hlist_nulls_del_init_rcu(struct hlist_nulls_node *n)
13166 + static inline void hlist_nulls_del_rcu(struct hlist_nulls_node *n)
13167 + {
13168 + __hlist_nulls_del(n);
13169 +- n->pprev = LIST_POISON2;
13170 ++ WRITE_ONCE(n->pprev, LIST_POISON2);
13171 + }
13172 +
13173 + /**
13174 +@@ -94,10 +94,10 @@ static inline void hlist_nulls_add_head_rcu(struct hlist_nulls_node *n,
13175 + struct hlist_nulls_node *first = h->first;
13176 +
13177 + n->next = first;
13178 +- n->pprev = &h->first;
13179 ++ WRITE_ONCE(n->pprev, &h->first);
13180 + rcu_assign_pointer(hlist_nulls_first_rcu(h), n);
13181 + if (!is_a_nulls(first))
13182 +- first->pprev = &n->next;
13183 ++ WRITE_ONCE(first->pprev, &n->next);
13184 + }
13185 +
13186 + /**
13187 +diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
13188 +index 5f36e0d2ede6..95353ae476a1 100644
13189 +--- a/include/media/v4l2-device.h
13190 ++++ b/include/media/v4l2-device.h
13191 +@@ -371,7 +371,7 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev)
13192 + struct v4l2_subdev *__sd; \
13193 + \
13194 + __v4l2_device_call_subdevs_p(v4l2_dev, __sd, \
13195 +- !(grpid) || __sd->grp_id == (grpid), o, f , \
13196 ++ (grpid) == 0 || __sd->grp_id == (grpid), o, f , \
13197 + ##args); \
13198 + } while (0)
13199 +
13200 +@@ -403,7 +403,7 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev)
13201 + ({ \
13202 + struct v4l2_subdev *__sd; \
13203 + __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \
13204 +- !(grpid) || __sd->grp_id == (grpid), o, f , \
13205 ++ (grpid) == 0 || __sd->grp_id == (grpid), o, f , \
13206 + ##args); \
13207 + })
13208 +
13209 +@@ -431,8 +431,8 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev)
13210 + struct v4l2_subdev *__sd; \
13211 + \
13212 + __v4l2_device_call_subdevs_p(v4l2_dev, __sd, \
13213 +- !(grpmsk) || (__sd->grp_id & (grpmsk)), o, f , \
13214 +- ##args); \
13215 ++ (grpmsk) == 0 || (__sd->grp_id & (grpmsk)), o, \
13216 ++ f , ##args); \
13217 + } while (0)
13218 +
13219 + /**
13220 +@@ -462,8 +462,8 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev)
13221 + ({ \
13222 + struct v4l2_subdev *__sd; \
13223 + __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \
13224 +- !(grpmsk) || (__sd->grp_id & (grpmsk)), o, f , \
13225 +- ##args); \
13226 ++ (grpmsk) == 0 || (__sd->grp_id & (grpmsk)), o, \
13227 ++ f , ##args); \
13228 + })
13229 +
13230 +
13231 +diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
13232 +index 8d0f447e1faa..a14f837fb1c8 100644
13233 +--- a/include/rdma/ib_verbs.h
13234 ++++ b/include/rdma/ib_verbs.h
13235 +@@ -2149,7 +2149,6 @@ struct ib_port_cache {
13236 +
13237 + struct ib_cache {
13238 + rwlock_t lock;
13239 +- struct ib_event_handler event_handler;
13240 + };
13241 +
13242 + struct ib_port_immutable {
13243 +@@ -2627,7 +2626,11 @@ struct ib_device {
13244 + struct rcu_head rcu_head;
13245 +
13246 + struct list_head event_handler_list;
13247 +- spinlock_t event_handler_lock;
13248 ++ /* Protects event_handler_list */
13249 ++ struct rw_semaphore event_handler_rwsem;
13250 ++
13251 ++ /* Protects QP's event_handler calls and open_qp list */
13252 ++ spinlock_t event_handler_lock;
13253 +
13254 + struct rw_semaphore client_data_rwsem;
13255 + struct xarray client_data;
13256 +@@ -2942,7 +2945,7 @@ bool ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state,
13257 +
13258 + void ib_register_event_handler(struct ib_event_handler *event_handler);
13259 + void ib_unregister_event_handler(struct ib_event_handler *event_handler);
13260 +-void ib_dispatch_event(struct ib_event *event);
13261 ++void ib_dispatch_event(const struct ib_event *event);
13262 +
13263 + int ib_query_port(struct ib_device *device,
13264 + u8 port_num, struct ib_port_attr *port_attr);
13265 +diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h
13266 +index 66122602bd08..697e2c0624dc 100644
13267 +--- a/include/trace/events/rcu.h
13268 ++++ b/include/trace/events/rcu.h
13269 +@@ -449,7 +449,7 @@ TRACE_EVENT_RCU(rcu_fqs,
13270 + */
13271 + TRACE_EVENT_RCU(rcu_dyntick,
13272 +
13273 +- TP_PROTO(const char *polarity, long oldnesting, long newnesting, atomic_t dynticks),
13274 ++ TP_PROTO(const char *polarity, long oldnesting, long newnesting, int dynticks),
13275 +
13276 + TP_ARGS(polarity, oldnesting, newnesting, dynticks),
13277 +
13278 +@@ -464,7 +464,7 @@ TRACE_EVENT_RCU(rcu_dyntick,
13279 + __entry->polarity = polarity;
13280 + __entry->oldnesting = oldnesting;
13281 + __entry->newnesting = newnesting;
13282 +- __entry->dynticks = atomic_read(&dynticks);
13283 ++ __entry->dynticks = dynticks;
13284 + ),
13285 +
13286 + TP_printk("%s %lx %lx %#3x", __entry->polarity,
13287 +diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
13288 +index ecf42bec38c0..6f22e0e74ef2 100644
13289 +--- a/kernel/bpf/inode.c
13290 ++++ b/kernel/bpf/inode.c
13291 +@@ -196,6 +196,7 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos)
13292 + void *key = map_iter(m)->key;
13293 + void *prev_key;
13294 +
13295 ++ (*pos)++;
13296 + if (map_iter(m)->done)
13297 + return NULL;
13298 +
13299 +@@ -208,8 +209,6 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos)
13300 + map_iter(m)->done = true;
13301 + return NULL;
13302 + }
13303 +-
13304 +- ++(*pos);
13305 + return key;
13306 + }
13307 +
13308 +diff --git a/kernel/cpu.c b/kernel/cpu.c
13309 +index 4dc279ed3b2d..9c706af713fb 100644
13310 +--- a/kernel/cpu.c
13311 ++++ b/kernel/cpu.c
13312 +@@ -525,8 +525,7 @@ static int bringup_wait_for_ap(unsigned int cpu)
13313 + if (WARN_ON_ONCE((!cpu_online(cpu))))
13314 + return -ECANCELED;
13315 +
13316 +- /* Unpark the stopper thread and the hotplug thread of the target cpu */
13317 +- stop_machine_unpark(cpu);
13318 ++ /* Unpark the hotplug thread of the target cpu */
13319 + kthread_unpark(st->thread);
13320 +
13321 + /*
13322 +@@ -1089,8 +1088,8 @@ void notify_cpu_starting(unsigned int cpu)
13323 +
13324 + /*
13325 + * Called from the idle task. Wake up the controlling task which brings the
13326 +- * stopper and the hotplug thread of the upcoming CPU up and then delegates
13327 +- * the rest of the online bringup to the hotplug thread.
13328 ++ * hotplug thread of the upcoming CPU up and then delegates the rest of the
13329 ++ * online bringup to the hotplug thread.
13330 + */
13331 + void cpuhp_online_idle(enum cpuhp_state state)
13332 + {
13333 +@@ -1100,6 +1099,12 @@ void cpuhp_online_idle(enum cpuhp_state state)
13334 + if (state != CPUHP_AP_ONLINE_IDLE)
13335 + return;
13336 +
13337 ++ /*
13338 ++ * Unpart the stopper thread before we start the idle loop (and start
13339 ++ * scheduling); this ensures the stopper task is always available.
13340 ++ */
13341 ++ stop_machine_unpark(smp_processor_id());
13342 ++
13343 + st->state = CPUHP_AP_ONLINE_IDLE;
13344 + complete_ap_thread(st, true);
13345 + }
13346 +diff --git a/kernel/kprobes.c b/kernel/kprobes.c
13347 +index 53534aa258a6..fd81882f0521 100644
13348 +--- a/kernel/kprobes.c
13349 ++++ b/kernel/kprobes.c
13350 +@@ -610,6 +610,18 @@ void wait_for_kprobe_optimizer(void)
13351 + mutex_unlock(&kprobe_mutex);
13352 + }
13353 +
13354 ++static bool optprobe_queued_unopt(struct optimized_kprobe *op)
13355 ++{
13356 ++ struct optimized_kprobe *_op;
13357 ++
13358 ++ list_for_each_entry(_op, &unoptimizing_list, list) {
13359 ++ if (op == _op)
13360 ++ return true;
13361 ++ }
13362 ++
13363 ++ return false;
13364 ++}
13365 ++
13366 + /* Optimize kprobe if p is ready to be optimized */
13367 + static void optimize_kprobe(struct kprobe *p)
13368 + {
13369 +@@ -631,17 +643,21 @@ static void optimize_kprobe(struct kprobe *p)
13370 + return;
13371 +
13372 + /* Check if it is already optimized. */
13373 +- if (op->kp.flags & KPROBE_FLAG_OPTIMIZED)
13374 ++ if (op->kp.flags & KPROBE_FLAG_OPTIMIZED) {
13375 ++ if (optprobe_queued_unopt(op)) {
13376 ++ /* This is under unoptimizing. Just dequeue the probe */
13377 ++ list_del_init(&op->list);
13378 ++ }
13379 + return;
13380 ++ }
13381 + op->kp.flags |= KPROBE_FLAG_OPTIMIZED;
13382 +
13383 +- if (!list_empty(&op->list))
13384 +- /* This is under unoptimizing. Just dequeue the probe */
13385 +- list_del_init(&op->list);
13386 +- else {
13387 +- list_add(&op->list, &optimizing_list);
13388 +- kick_kprobe_optimizer();
13389 +- }
13390 ++ /* On unoptimizing/optimizing_list, op must have OPTIMIZED flag */
13391 ++ if (WARN_ON_ONCE(!list_empty(&op->list)))
13392 ++ return;
13393 ++
13394 ++ list_add(&op->list, &optimizing_list);
13395 ++ kick_kprobe_optimizer();
13396 + }
13397 +
13398 + /* Short cut to direct unoptimizing */
13399 +@@ -662,31 +678,34 @@ static void unoptimize_kprobe(struct kprobe *p, bool force)
13400 + return; /* This is not an optprobe nor optimized */
13401 +
13402 + op = container_of(p, struct optimized_kprobe, kp);
13403 +- if (!kprobe_optimized(p)) {
13404 +- /* Unoptimized or unoptimizing case */
13405 +- if (force && !list_empty(&op->list)) {
13406 +- /*
13407 +- * Only if this is unoptimizing kprobe and forced,
13408 +- * forcibly unoptimize it. (No need to unoptimize
13409 +- * unoptimized kprobe again :)
13410 +- */
13411 +- list_del_init(&op->list);
13412 +- force_unoptimize_kprobe(op);
13413 +- }
13414 ++ if (!kprobe_optimized(p))
13415 + return;
13416 +- }
13417 +
13418 + op->kp.flags &= ~KPROBE_FLAG_OPTIMIZED;
13419 + if (!list_empty(&op->list)) {
13420 +- /* Dequeue from the optimization queue */
13421 +- list_del_init(&op->list);
13422 ++ if (optprobe_queued_unopt(op)) {
13423 ++ /* Queued in unoptimizing queue */
13424 ++ if (force) {
13425 ++ /*
13426 ++ * Forcibly unoptimize the kprobe here, and queue it
13427 ++ * in the freeing list for release afterwards.
13428 ++ */
13429 ++ force_unoptimize_kprobe(op);
13430 ++ list_move(&op->list, &freeing_list);
13431 ++ }
13432 ++ } else {
13433 ++ /* Dequeue from the optimizing queue */
13434 ++ list_del_init(&op->list);
13435 ++ op->kp.flags &= ~KPROBE_FLAG_OPTIMIZED;
13436 ++ }
13437 + return;
13438 + }
13439 ++
13440 + /* Optimized kprobe case */
13441 +- if (force)
13442 ++ if (force) {
13443 + /* Forcibly update the code: this is a special case */
13444 + force_unoptimize_kprobe(op);
13445 +- else {
13446 ++ } else {
13447 + list_add(&op->list, &unoptimizing_list);
13448 + kick_kprobe_optimizer();
13449 + }
13450 +diff --git a/kernel/module.c b/kernel/module.c
13451 +index b56f3224b161..4810ce0fbbca 100644
13452 +--- a/kernel/module.c
13453 ++++ b/kernel/module.c
13454 +@@ -214,7 +214,8 @@ static struct module *mod_find(unsigned long addr)
13455 + {
13456 + struct module *mod;
13457 +
13458 +- list_for_each_entry_rcu(mod, &modules, list) {
13459 ++ list_for_each_entry_rcu(mod, &modules, list,
13460 ++ lockdep_is_held(&module_mutex)) {
13461 + if (within_module(addr, mod))
13462 + return mod;
13463 + }
13464 +@@ -448,7 +449,8 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
13465 + if (each_symbol_in_section(arr, ARRAY_SIZE(arr), NULL, fn, data))
13466 + return true;
13467 +
13468 +- list_for_each_entry_rcu(mod, &modules, list) {
13469 ++ list_for_each_entry_rcu(mod, &modules, list,
13470 ++ lockdep_is_held(&module_mutex)) {
13471 + struct symsearch arr[] = {
13472 + { mod->syms, mod->syms + mod->num_syms, mod->crcs,
13473 + NOT_GPL_ONLY, false },
13474 +@@ -616,7 +618,8 @@ static struct module *find_module_all(const char *name, size_t len,
13475 +
13476 + module_assert_mutex_or_preempt();
13477 +
13478 +- list_for_each_entry_rcu(mod, &modules, list) {
13479 ++ list_for_each_entry_rcu(mod, &modules, list,
13480 ++ lockdep_is_held(&module_mutex)) {
13481 + if (!even_unformed && mod->state == MODULE_STATE_UNFORMED)
13482 + continue;
13483 + if (strlen(mod->name) == len && !memcmp(mod->name, name, len))
13484 +@@ -1781,6 +1784,8 @@ static int module_add_modinfo_attrs(struct module *mod)
13485 + error_out:
13486 + if (i > 0)
13487 + module_remove_modinfo_attrs(mod, --i);
13488 ++ else
13489 ++ kfree(mod->modinfo_attrs);
13490 + return error;
13491 + }
13492 +
13493 +@@ -3054,9 +3059,7 @@ static int setup_load_info(struct load_info *info, int flags)
13494 +
13495 + /* Try to find a name early so we can log errors with a module name */
13496 + info->index.info = find_sec(info, ".modinfo");
13497 +- if (!info->index.info)
13498 +- info->name = "(missing .modinfo section)";
13499 +- else
13500 ++ if (info->index.info)
13501 + info->name = get_modinfo(info, "name");
13502 +
13503 + /* Find internal symbols and strings. */
13504 +@@ -3071,14 +3074,15 @@ static int setup_load_info(struct load_info *info, int flags)
13505 + }
13506 +
13507 + if (info->index.sym == 0) {
13508 +- pr_warn("%s: module has no symbols (stripped?)\n", info->name);
13509 ++ pr_warn("%s: module has no symbols (stripped?)\n",
13510 ++ info->name ?: "(missing .modinfo section or name field)");
13511 + return -ENOEXEC;
13512 + }
13513 +
13514 + info->index.mod = find_sec(info, ".gnu.linkonce.this_module");
13515 + if (!info->index.mod) {
13516 + pr_warn("%s: No module found in object\n",
13517 +- info->name ?: "(missing .modinfo name field)");
13518 ++ info->name ?: "(missing .modinfo section or name field)");
13519 + return -ENOEXEC;
13520 + }
13521 + /* This is temporary: point mod into copy of data. */
13522 +diff --git a/kernel/padata.c b/kernel/padata.c
13523 +index 9c82ee4a9732..fda7a7039422 100644
13524 +--- a/kernel/padata.c
13525 ++++ b/kernel/padata.c
13526 +@@ -512,7 +512,7 @@ static int padata_replace_one(struct padata_shell *ps)
13527 + return 0;
13528 + }
13529 +
13530 +-static int padata_replace(struct padata_instance *pinst, int cpu)
13531 ++static int padata_replace(struct padata_instance *pinst)
13532 + {
13533 + int notification_mask = 0;
13534 + struct padata_shell *ps;
13535 +@@ -523,16 +523,12 @@ static int padata_replace(struct padata_instance *pinst, int cpu)
13536 + cpumask_copy(pinst->omask, pinst->rcpumask.pcpu);
13537 + cpumask_and(pinst->rcpumask.pcpu, pinst->cpumask.pcpu,
13538 + cpu_online_mask);
13539 +- if (cpu >= 0)
13540 +- cpumask_clear_cpu(cpu, pinst->rcpumask.pcpu);
13541 + if (!cpumask_equal(pinst->omask, pinst->rcpumask.pcpu))
13542 + notification_mask |= PADATA_CPU_PARALLEL;
13543 +
13544 + cpumask_copy(pinst->omask, pinst->rcpumask.cbcpu);
13545 + cpumask_and(pinst->rcpumask.cbcpu, pinst->cpumask.cbcpu,
13546 + cpu_online_mask);
13547 +- if (cpu >= 0)
13548 +- cpumask_clear_cpu(cpu, pinst->rcpumask.cbcpu);
13549 + if (!cpumask_equal(pinst->omask, pinst->rcpumask.cbcpu))
13550 + notification_mask |= PADATA_CPU_SERIAL;
13551 +
13552 +@@ -624,7 +620,7 @@ out_replace:
13553 + cpumask_copy(pinst->cpumask.pcpu, pcpumask);
13554 + cpumask_copy(pinst->cpumask.cbcpu, cbcpumask);
13555 +
13556 +- err = padata_setup_cpumasks(pinst) ?: padata_replace(pinst, -1);
13557 ++ err = padata_setup_cpumasks(pinst) ?: padata_replace(pinst);
13558 +
13559 + if (valid)
13560 + __padata_start(pinst);
13561 +@@ -715,7 +711,7 @@ static int __padata_add_cpu(struct padata_instance *pinst, int cpu)
13562 + int err = 0;
13563 +
13564 + if (cpumask_test_cpu(cpu, cpu_online_mask)) {
13565 +- err = padata_replace(pinst, -1);
13566 ++ err = padata_replace(pinst);
13567 +
13568 + if (padata_validate_cpumask(pinst, pinst->cpumask.pcpu) &&
13569 + padata_validate_cpumask(pinst, pinst->cpumask.cbcpu))
13570 +@@ -729,12 +725,12 @@ static int __padata_remove_cpu(struct padata_instance *pinst, int cpu)
13571 + {
13572 + int err = 0;
13573 +
13574 +- if (cpumask_test_cpu(cpu, cpu_online_mask)) {
13575 ++ if (!cpumask_test_cpu(cpu, cpu_online_mask)) {
13576 + if (!padata_validate_cpumask(pinst, pinst->cpumask.pcpu) ||
13577 + !padata_validate_cpumask(pinst, pinst->cpumask.cbcpu))
13578 + __padata_stop(pinst);
13579 +
13580 +- err = padata_replace(pinst, cpu);
13581 ++ err = padata_replace(pinst);
13582 + }
13583 +
13584 + return err;
13585 +@@ -796,7 +792,7 @@ static int padata_cpu_online(unsigned int cpu, struct hlist_node *node)
13586 + return ret;
13587 + }
13588 +
13589 +-static int padata_cpu_prep_down(unsigned int cpu, struct hlist_node *node)
13590 ++static int padata_cpu_dead(unsigned int cpu, struct hlist_node *node)
13591 + {
13592 + struct padata_instance *pinst;
13593 + int ret;
13594 +@@ -817,6 +813,7 @@ static enum cpuhp_state hp_online;
13595 + static void __padata_free(struct padata_instance *pinst)
13596 + {
13597 + #ifdef CONFIG_HOTPLUG_CPU
13598 ++ cpuhp_state_remove_instance_nocalls(CPUHP_PADATA_DEAD, &pinst->node);
13599 + cpuhp_state_remove_instance_nocalls(hp_online, &pinst->node);
13600 + #endif
13601 +
13602 +@@ -1024,6 +1021,8 @@ static struct padata_instance *padata_alloc(const char *name,
13603 +
13604 + #ifdef CONFIG_HOTPLUG_CPU
13605 + cpuhp_state_add_instance_nocalls_cpuslocked(hp_online, &pinst->node);
13606 ++ cpuhp_state_add_instance_nocalls_cpuslocked(CPUHP_PADATA_DEAD,
13607 ++ &pinst->node);
13608 + #endif
13609 +
13610 + put_online_cpus();
13611 +@@ -1136,17 +1135,24 @@ static __init int padata_driver_init(void)
13612 + int ret;
13613 +
13614 + ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "padata:online",
13615 +- padata_cpu_online,
13616 +- padata_cpu_prep_down);
13617 ++ padata_cpu_online, NULL);
13618 + if (ret < 0)
13619 + return ret;
13620 + hp_online = ret;
13621 ++
13622 ++ ret = cpuhp_setup_state_multi(CPUHP_PADATA_DEAD, "padata:dead",
13623 ++ NULL, padata_cpu_dead);
13624 ++ if (ret < 0) {
13625 ++ cpuhp_remove_multi_state(hp_online);
13626 ++ return ret;
13627 ++ }
13628 + return 0;
13629 + }
13630 + module_init(padata_driver_init);
13631 +
13632 + static __exit void padata_driver_exit(void)
13633 + {
13634 ++ cpuhp_remove_multi_state(CPUHP_PADATA_DEAD);
13635 + cpuhp_remove_multi_state(hp_online);
13636 + }
13637 + module_exit(padata_driver_exit);
13638 +diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
13639 +index 1ef6f75d92f1..fada22dc4ab6 100644
13640 +--- a/kernel/printk/printk.c
13641 ++++ b/kernel/printk/printk.c
13642 +@@ -2770,8 +2770,6 @@ void register_console(struct console *newcon)
13643 + * for us.
13644 + */
13645 + logbuf_lock_irqsave(flags);
13646 +- console_seq = syslog_seq;
13647 +- console_idx = syslog_idx;
13648 + /*
13649 + * We're about to replay the log buffer. Only do this to the
13650 + * just-registered console to avoid excessive message spam to
13651 +@@ -2783,6 +2781,8 @@ void register_console(struct console *newcon)
13652 + */
13653 + exclusive_console = newcon;
13654 + exclusive_console_stop_seq = console_seq;
13655 ++ console_seq = syslog_seq;
13656 ++ console_idx = syslog_idx;
13657 + logbuf_unlock_irqrestore(flags);
13658 + }
13659 + console_unlock();
13660 +diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
13661 +index 1694a6b57ad8..6145e08a1407 100644
13662 +--- a/kernel/rcu/tree.c
13663 ++++ b/kernel/rcu/tree.c
13664 +@@ -577,7 +577,7 @@ static void rcu_eqs_enter(bool user)
13665 + }
13666 +
13667 + lockdep_assert_irqs_disabled();
13668 +- trace_rcu_dyntick(TPS("Start"), rdp->dynticks_nesting, 0, rdp->dynticks);
13669 ++ trace_rcu_dyntick(TPS("Start"), rdp->dynticks_nesting, 0, atomic_read(&rdp->dynticks));
13670 + WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !user && !is_idle_task(current));
13671 + rdp = this_cpu_ptr(&rcu_data);
13672 + do_nocb_deferred_wakeup(rdp);
13673 +@@ -650,14 +650,15 @@ static __always_inline void rcu_nmi_exit_common(bool irq)
13674 + * leave it in non-RCU-idle state.
13675 + */
13676 + if (rdp->dynticks_nmi_nesting != 1) {
13677 +- trace_rcu_dyntick(TPS("--="), rdp->dynticks_nmi_nesting, rdp->dynticks_nmi_nesting - 2, rdp->dynticks);
13678 ++ trace_rcu_dyntick(TPS("--="), rdp->dynticks_nmi_nesting, rdp->dynticks_nmi_nesting - 2,
13679 ++ atomic_read(&rdp->dynticks));
13680 + WRITE_ONCE(rdp->dynticks_nmi_nesting, /* No store tearing. */
13681 + rdp->dynticks_nmi_nesting - 2);
13682 + return;
13683 + }
13684 +
13685 + /* This NMI interrupted an RCU-idle CPU, restore RCU-idleness. */
13686 +- trace_rcu_dyntick(TPS("Startirq"), rdp->dynticks_nmi_nesting, 0, rdp->dynticks);
13687 ++ trace_rcu_dyntick(TPS("Startirq"), rdp->dynticks_nmi_nesting, 0, atomic_read(&rdp->dynticks));
13688 + WRITE_ONCE(rdp->dynticks_nmi_nesting, 0); /* Avoid store tearing. */
13689 +
13690 + if (irq)
13691 +@@ -744,7 +745,7 @@ static void rcu_eqs_exit(bool user)
13692 + rcu_dynticks_task_exit();
13693 + rcu_dynticks_eqs_exit();
13694 + rcu_cleanup_after_idle();
13695 +- trace_rcu_dyntick(TPS("End"), rdp->dynticks_nesting, 1, rdp->dynticks);
13696 ++ trace_rcu_dyntick(TPS("End"), rdp->dynticks_nesting, 1, atomic_read(&rdp->dynticks));
13697 + WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !user && !is_idle_task(current));
13698 + WRITE_ONCE(rdp->dynticks_nesting, 1);
13699 + WARN_ON_ONCE(rdp->dynticks_nmi_nesting);
13700 +@@ -833,7 +834,7 @@ static __always_inline void rcu_nmi_enter_common(bool irq)
13701 + }
13702 + trace_rcu_dyntick(incby == 1 ? TPS("Endirq") : TPS("++="),
13703 + rdp->dynticks_nmi_nesting,
13704 +- rdp->dynticks_nmi_nesting + incby, rdp->dynticks);
13705 ++ rdp->dynticks_nmi_nesting + incby, atomic_read(&rdp->dynticks));
13706 + WRITE_ONCE(rdp->dynticks_nmi_nesting, /* Prevent store tearing. */
13707 + rdp->dynticks_nmi_nesting + incby);
13708 + barrier();
13709 +diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
13710 +index 69c5aa64fcfd..f504ac831779 100644
13711 +--- a/kernel/rcu/tree_exp.h
13712 ++++ b/kernel/rcu/tree_exp.h
13713 +@@ -558,7 +558,7 @@ static void rcu_exp_wait_wake(unsigned long s)
13714 + spin_unlock(&rnp->exp_lock);
13715 + }
13716 + smp_mb(); /* All above changes before wakeup. */
13717 +- wake_up_all(&rnp->exp_wq[rcu_seq_ctr(rcu_state.expedited_sequence) & 0x3]);
13718 ++ wake_up_all(&rnp->exp_wq[rcu_seq_ctr(s) & 0x3]);
13719 + }
13720 + trace_rcu_exp_grace_period(rcu_state.name, s, TPS("endwake"));
13721 + mutex_unlock(&rcu_state.exp_wake_mutex);
13722 +diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
13723 +index f849e7429816..f7118842a2b8 100644
13724 +--- a/kernel/rcu/tree_plugin.h
13725 ++++ b/kernel/rcu/tree_plugin.h
13726 +@@ -2322,6 +2322,8 @@ static void __init rcu_organize_nocb_kthreads(void)
13727 + {
13728 + int cpu;
13729 + bool firsttime = true;
13730 ++ bool gotnocbs = false;
13731 ++ bool gotnocbscbs = true;
13732 + int ls = rcu_nocb_gp_stride;
13733 + int nl = 0; /* Next GP kthread. */
13734 + struct rcu_data *rdp;
13735 +@@ -2344,21 +2346,31 @@ static void __init rcu_organize_nocb_kthreads(void)
13736 + rdp = per_cpu_ptr(&rcu_data, cpu);
13737 + if (rdp->cpu >= nl) {
13738 + /* New GP kthread, set up for CBs & next GP. */
13739 ++ gotnocbs = true;
13740 + nl = DIV_ROUND_UP(rdp->cpu + 1, ls) * ls;
13741 + rdp->nocb_gp_rdp = rdp;
13742 + rdp_gp = rdp;
13743 +- if (!firsttime && dump_tree)
13744 +- pr_cont("\n");
13745 +- firsttime = false;
13746 +- pr_alert("%s: No-CB GP kthread CPU %d:", __func__, cpu);
13747 ++ if (dump_tree) {
13748 ++ if (!firsttime)
13749 ++ pr_cont("%s\n", gotnocbscbs
13750 ++ ? "" : " (self only)");
13751 ++ gotnocbscbs = false;
13752 ++ firsttime = false;
13753 ++ pr_alert("%s: No-CB GP kthread CPU %d:",
13754 ++ __func__, cpu);
13755 ++ }
13756 + } else {
13757 + /* Another CB kthread, link to previous GP kthread. */
13758 ++ gotnocbscbs = true;
13759 + rdp->nocb_gp_rdp = rdp_gp;
13760 + rdp_prev->nocb_next_cb_rdp = rdp;
13761 +- pr_alert(" %d", cpu);
13762 ++ if (dump_tree)
13763 ++ pr_cont(" %d", cpu);
13764 + }
13765 + rdp_prev = rdp;
13766 + }
13767 ++ if (gotnocbs && dump_tree)
13768 ++ pr_cont("%s\n", gotnocbscbs ? "" : " (self only)");
13769 + }
13770 +
13771 + /*
13772 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
13773 +index 894fb81313fd..b2564d62a0f7 100644
13774 +--- a/kernel/sched/core.c
13775 ++++ b/kernel/sched/core.c
13776 +@@ -1253,7 +1253,8 @@ static void __init init_uclamp(void)
13777 + mutex_init(&uclamp_mutex);
13778 +
13779 + for_each_possible_cpu(cpu) {
13780 +- memset(&cpu_rq(cpu)->uclamp, 0, sizeof(struct uclamp_rq));
13781 ++ memset(&cpu_rq(cpu)->uclamp, 0,
13782 ++ sizeof(struct uclamp_rq)*UCLAMP_CNT);
13783 + cpu_rq(cpu)->uclamp_flags = 0;
13784 + }
13785 +
13786 +diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
13787 +index 6ec1e595b1d4..dfb64c08a407 100644
13788 +--- a/kernel/sched/topology.c
13789 ++++ b/kernel/sched/topology.c
13790 +@@ -1879,6 +1879,42 @@ static struct sched_domain *build_sched_domain(struct sched_domain_topology_leve
13791 + return sd;
13792 + }
13793 +
13794 ++/*
13795 ++ * Ensure topology masks are sane, i.e. there are no conflicts (overlaps) for
13796 ++ * any two given CPUs at this (non-NUMA) topology level.
13797 ++ */
13798 ++static bool topology_span_sane(struct sched_domain_topology_level *tl,
13799 ++ const struct cpumask *cpu_map, int cpu)
13800 ++{
13801 ++ int i;
13802 ++
13803 ++ /* NUMA levels are allowed to overlap */
13804 ++ if (tl->flags & SDTL_OVERLAP)
13805 ++ return true;
13806 ++
13807 ++ /*
13808 ++ * Non-NUMA levels cannot partially overlap - they must be either
13809 ++ * completely equal or completely disjoint. Otherwise we can end up
13810 ++ * breaking the sched_group lists - i.e. a later get_group() pass
13811 ++ * breaks the linking done for an earlier span.
13812 ++ */
13813 ++ for_each_cpu(i, cpu_map) {
13814 ++ if (i == cpu)
13815 ++ continue;
13816 ++ /*
13817 ++ * We should 'and' all those masks with 'cpu_map' to exactly
13818 ++ * match the topology we're about to build, but that can only
13819 ++ * remove CPUs, which only lessens our ability to detect
13820 ++ * overlaps
13821 ++ */
13822 ++ if (!cpumask_equal(tl->mask(cpu), tl->mask(i)) &&
13823 ++ cpumask_intersects(tl->mask(cpu), tl->mask(i)))
13824 ++ return false;
13825 ++ }
13826 ++
13827 ++ return true;
13828 ++}
13829 ++
13830 + /*
13831 + * Find the sched_domain_topology_level where all CPU capacities are visible
13832 + * for all CPUs.
13833 +@@ -1975,6 +2011,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
13834 + has_asym = true;
13835 + }
13836 +
13837 ++ if (WARN_ON(!topology_span_sane(tl, cpu_map, i)))
13838 ++ goto error;
13839 ++
13840 + sd = build_sched_domain(tl, cpu_map, attr, sd, dflags, i);
13841 +
13842 + if (tl == sched_domain_topology)
13843 +diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
13844 +index 4b11f0309eee..b97401f6bc23 100644
13845 +--- a/kernel/time/alarmtimer.c
13846 ++++ b/kernel/time/alarmtimer.c
13847 +@@ -88,6 +88,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
13848 + unsigned long flags;
13849 + struct rtc_device *rtc = to_rtc_device(dev);
13850 + struct wakeup_source *__ws;
13851 ++ struct platform_device *pdev;
13852 + int ret = 0;
13853 +
13854 + if (rtcdev)
13855 +@@ -99,9 +100,11 @@ static int alarmtimer_rtc_add_device(struct device *dev,
13856 + return -1;
13857 +
13858 + __ws = wakeup_source_register(dev, "alarmtimer");
13859 ++ pdev = platform_device_register_data(dev, "alarmtimer",
13860 ++ PLATFORM_DEVID_AUTO, NULL, 0);
13861 +
13862 + spin_lock_irqsave(&rtcdev_lock, flags);
13863 +- if (!rtcdev) {
13864 ++ if (__ws && !IS_ERR(pdev) && !rtcdev) {
13865 + if (!try_module_get(rtc->owner)) {
13866 + ret = -1;
13867 + goto unlock;
13868 +@@ -112,10 +115,14 @@ static int alarmtimer_rtc_add_device(struct device *dev,
13869 + get_device(dev);
13870 + ws = __ws;
13871 + __ws = NULL;
13872 ++ pdev = NULL;
13873 ++ } else {
13874 ++ ret = -1;
13875 + }
13876 + unlock:
13877 + spin_unlock_irqrestore(&rtcdev_lock, flags);
13878 +
13879 ++ platform_device_unregister(pdev);
13880 + wakeup_source_unregister(__ws);
13881 +
13882 + return ret;
13883 +@@ -876,8 +883,7 @@ static struct platform_driver alarmtimer_driver = {
13884 + */
13885 + static int __init alarmtimer_init(void)
13886 + {
13887 +- struct platform_device *pdev;
13888 +- int error = 0;
13889 ++ int error;
13890 + int i;
13891 +
13892 + alarmtimer_rtc_timer_init();
13893 +@@ -900,15 +906,7 @@ static int __init alarmtimer_init(void)
13894 + if (error)
13895 + goto out_if;
13896 +
13897 +- pdev = platform_device_register_simple("alarmtimer", -1, NULL, 0);
13898 +- if (IS_ERR(pdev)) {
13899 +- error = PTR_ERR(pdev);
13900 +- goto out_drv;
13901 +- }
13902 + return 0;
13903 +-
13904 +-out_drv:
13905 +- platform_driver_unregister(&alarmtimer_driver);
13906 + out_if:
13907 + alarmtimer_rtc_interface_remove();
13908 + return error;
13909 +diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
13910 +index 3581bd96d6eb..ddb47a0af854 100644
13911 +--- a/kernel/trace/ftrace.c
13912 ++++ b/kernel/trace/ftrace.c
13913 +@@ -7038,9 +7038,10 @@ static void *fpid_next(struct seq_file *m, void *v, loff_t *pos)
13914 + struct trace_array *tr = m->private;
13915 + struct trace_pid_list *pid_list = rcu_dereference_sched(tr->function_pids);
13916 +
13917 +- if (v == FTRACE_NO_PIDS)
13918 ++ if (v == FTRACE_NO_PIDS) {
13919 ++ (*pos)++;
13920 + return NULL;
13921 +-
13922 ++ }
13923 + return trace_pid_next(pid_list, v, pos);
13924 + }
13925 +
13926 +diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
13927 +index 6ac35b9e195d..e10585ef00e1 100644
13928 +--- a/kernel/trace/trace_events_hist.c
13929 ++++ b/kernel/trace/trace_events_hist.c
13930 +@@ -470,11 +470,12 @@ struct action_data {
13931 + * When a histogram trigger is hit, the values of any
13932 + * references to variables, including variables being passed
13933 + * as parameters to synthetic events, are collected into a
13934 +- * var_ref_vals array. This var_ref_idx is the index of the
13935 +- * first param in the array to be passed to the synthetic
13936 +- * event invocation.
13937 ++ * var_ref_vals array. This var_ref_idx array is an array of
13938 ++ * indices into the var_ref_vals array, one for each synthetic
13939 ++ * event param, and is passed to the synthetic event
13940 ++ * invocation.
13941 + */
13942 +- unsigned int var_ref_idx;
13943 ++ unsigned int var_ref_idx[TRACING_MAP_VARS_MAX];
13944 + struct synth_event *synth_event;
13945 + bool use_trace_keyword;
13946 + char *synth_event_name;
13947 +@@ -875,14 +876,14 @@ static struct trace_event_functions synth_event_funcs = {
13948 +
13949 + static notrace void trace_event_raw_event_synth(void *__data,
13950 + u64 *var_ref_vals,
13951 +- unsigned int var_ref_idx)
13952 ++ unsigned int *var_ref_idx)
13953 + {
13954 + struct trace_event_file *trace_file = __data;
13955 + struct synth_trace_event *entry;
13956 + struct trace_event_buffer fbuffer;
13957 + struct ring_buffer *buffer;
13958 + struct synth_event *event;
13959 +- unsigned int i, n_u64;
13960 ++ unsigned int i, n_u64, val_idx;
13961 + int fields_size = 0;
13962 +
13963 + event = trace_file->event_call->data;
13964 +@@ -905,15 +906,16 @@ static notrace void trace_event_raw_event_synth(void *__data,
13965 + goto out;
13966 +
13967 + for (i = 0, n_u64 = 0; i < event->n_fields; i++) {
13968 ++ val_idx = var_ref_idx[i];
13969 + if (event->fields[i]->is_string) {
13970 +- char *str_val = (char *)(long)var_ref_vals[var_ref_idx + i];
13971 ++ char *str_val = (char *)(long)var_ref_vals[val_idx];
13972 + char *str_field = (char *)&entry->fields[n_u64];
13973 +
13974 + strscpy(str_field, str_val, STR_VAR_LEN_MAX);
13975 + n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
13976 + } else {
13977 + struct synth_field *field = event->fields[i];
13978 +- u64 val = var_ref_vals[var_ref_idx + i];
13979 ++ u64 val = var_ref_vals[val_idx];
13980 +
13981 + switch (field->size) {
13982 + case 1:
13983 +@@ -1113,10 +1115,10 @@ static struct tracepoint *alloc_synth_tracepoint(char *name)
13984 + }
13985 +
13986 + typedef void (*synth_probe_func_t) (void *__data, u64 *var_ref_vals,
13987 +- unsigned int var_ref_idx);
13988 ++ unsigned int *var_ref_idx);
13989 +
13990 + static inline void trace_synth(struct synth_event *event, u64 *var_ref_vals,
13991 +- unsigned int var_ref_idx)
13992 ++ unsigned int *var_ref_idx)
13993 + {
13994 + struct tracepoint *tp = event->tp;
13995 +
13996 +@@ -2035,12 +2037,6 @@ static int parse_map_size(char *str)
13997 + unsigned long size, map_bits;
13998 + int ret;
13999 +
14000 +- strsep(&str, "=");
14001 +- if (!str) {
14002 +- ret = -EINVAL;
14003 +- goto out;
14004 +- }
14005 +-
14006 + ret = kstrtoul(str, 0, &size);
14007 + if (ret)
14008 + goto out;
14009 +@@ -2100,25 +2096,25 @@ static int parse_action(char *str, struct hist_trigger_attrs *attrs)
14010 + static int parse_assignment(struct trace_array *tr,
14011 + char *str, struct hist_trigger_attrs *attrs)
14012 + {
14013 +- int ret = 0;
14014 ++ int len, ret = 0;
14015 +
14016 +- if ((str_has_prefix(str, "key=")) ||
14017 +- (str_has_prefix(str, "keys="))) {
14018 +- attrs->keys_str = kstrdup(str, GFP_KERNEL);
14019 ++ if ((len = str_has_prefix(str, "key=")) ||
14020 ++ (len = str_has_prefix(str, "keys="))) {
14021 ++ attrs->keys_str = kstrdup(str + len, GFP_KERNEL);
14022 + if (!attrs->keys_str) {
14023 + ret = -ENOMEM;
14024 + goto out;
14025 + }
14026 +- } else if ((str_has_prefix(str, "val=")) ||
14027 +- (str_has_prefix(str, "vals=")) ||
14028 +- (str_has_prefix(str, "values="))) {
14029 +- attrs->vals_str = kstrdup(str, GFP_KERNEL);
14030 ++ } else if ((len = str_has_prefix(str, "val=")) ||
14031 ++ (len = str_has_prefix(str, "vals=")) ||
14032 ++ (len = str_has_prefix(str, "values="))) {
14033 ++ attrs->vals_str = kstrdup(str + len, GFP_KERNEL);
14034 + if (!attrs->vals_str) {
14035 + ret = -ENOMEM;
14036 + goto out;
14037 + }
14038 +- } else if (str_has_prefix(str, "sort=")) {
14039 +- attrs->sort_key_str = kstrdup(str, GFP_KERNEL);
14040 ++ } else if ((len = str_has_prefix(str, "sort="))) {
14041 ++ attrs->sort_key_str = kstrdup(str + len, GFP_KERNEL);
14042 + if (!attrs->sort_key_str) {
14043 + ret = -ENOMEM;
14044 + goto out;
14045 +@@ -2129,12 +2125,8 @@ static int parse_assignment(struct trace_array *tr,
14046 + ret = -ENOMEM;
14047 + goto out;
14048 + }
14049 +- } else if (str_has_prefix(str, "clock=")) {
14050 +- strsep(&str, "=");
14051 +- if (!str) {
14052 +- ret = -EINVAL;
14053 +- goto out;
14054 +- }
14055 ++ } else if ((len = str_has_prefix(str, "clock="))) {
14056 ++ str += len;
14057 +
14058 + str = strstrip(str);
14059 + attrs->clock = kstrdup(str, GFP_KERNEL);
14060 +@@ -2142,8 +2134,8 @@ static int parse_assignment(struct trace_array *tr,
14061 + ret = -ENOMEM;
14062 + goto out;
14063 + }
14064 +- } else if (str_has_prefix(str, "size=")) {
14065 +- int map_bits = parse_map_size(str);
14066 ++ } else if ((len = str_has_prefix(str, "size="))) {
14067 ++ int map_bits = parse_map_size(str + len);
14068 +
14069 + if (map_bits < 0) {
14070 + ret = map_bits;
14071 +@@ -2183,8 +2175,14 @@ parse_hist_trigger_attrs(struct trace_array *tr, char *trigger_str)
14072 +
14073 + while (trigger_str) {
14074 + char *str = strsep(&trigger_str, ":");
14075 ++ char *rhs;
14076 +
14077 +- if (strchr(str, '=')) {
14078 ++ rhs = strchr(str, '=');
14079 ++ if (rhs) {
14080 ++ if (!strlen(++rhs)) {
14081 ++ ret = -EINVAL;
14082 ++ goto free;
14083 ++ }
14084 + ret = parse_assignment(tr, str, attrs);
14085 + if (ret)
14086 + goto free;
14087 +@@ -2655,6 +2653,22 @@ static int init_var_ref(struct hist_field *ref_field,
14088 + goto out;
14089 + }
14090 +
14091 ++static int find_var_ref_idx(struct hist_trigger_data *hist_data,
14092 ++ struct hist_field *var_field)
14093 ++{
14094 ++ struct hist_field *ref_field;
14095 ++ int i;
14096 ++
14097 ++ for (i = 0; i < hist_data->n_var_refs; i++) {
14098 ++ ref_field = hist_data->var_refs[i];
14099 ++ if (ref_field->var.idx == var_field->var.idx &&
14100 ++ ref_field->var.hist_data == var_field->hist_data)
14101 ++ return i;
14102 ++ }
14103 ++
14104 ++ return -ENOENT;
14105 ++}
14106 ++
14107 + /**
14108 + * create_var_ref - Create a variable reference and attach it to trigger
14109 + * @hist_data: The trigger that will be referencing the variable
14110 +@@ -4228,11 +4242,11 @@ static int trace_action_create(struct hist_trigger_data *hist_data,
14111 + struct trace_array *tr = hist_data->event_file->tr;
14112 + char *event_name, *param, *system = NULL;
14113 + struct hist_field *hist_field, *var_ref;
14114 +- unsigned int i, var_ref_idx;
14115 ++ unsigned int i;
14116 + unsigned int field_pos = 0;
14117 + struct synth_event *event;
14118 + char *synth_event_name;
14119 +- int ret = 0;
14120 ++ int var_ref_idx, ret = 0;
14121 +
14122 + lockdep_assert_held(&event_mutex);
14123 +
14124 +@@ -4249,8 +4263,6 @@ static int trace_action_create(struct hist_trigger_data *hist_data,
14125 +
14126 + event->ref++;
14127 +
14128 +- var_ref_idx = hist_data->n_var_refs;
14129 +-
14130 + for (i = 0; i < data->n_params; i++) {
14131 + char *p;
14132 +
14133 +@@ -4299,6 +4311,14 @@ static int trace_action_create(struct hist_trigger_data *hist_data,
14134 + goto err;
14135 + }
14136 +
14137 ++ var_ref_idx = find_var_ref_idx(hist_data, var_ref);
14138 ++ if (WARN_ON(var_ref_idx < 0)) {
14139 ++ ret = var_ref_idx;
14140 ++ goto err;
14141 ++ }
14142 ++
14143 ++ data->var_ref_idx[i] = var_ref_idx;
14144 ++
14145 + field_pos++;
14146 + kfree(p);
14147 + continue;
14148 +@@ -4317,7 +4337,6 @@ static int trace_action_create(struct hist_trigger_data *hist_data,
14149 + }
14150 +
14151 + data->synth_event = event;
14152 +- data->var_ref_idx = var_ref_idx;
14153 + out:
14154 + return ret;
14155 + err:
14156 +@@ -4536,10 +4555,6 @@ static int create_val_fields(struct hist_trigger_data *hist_data,
14157 + if (!fields_str)
14158 + goto out;
14159 +
14160 +- strsep(&fields_str, "=");
14161 +- if (!fields_str)
14162 +- goto out;
14163 +-
14164 + for (i = 0, j = 1; i < TRACING_MAP_VALS_MAX &&
14165 + j < TRACING_MAP_VALS_MAX; i++) {
14166 + field_str = strsep(&fields_str, ",");
14167 +@@ -4634,10 +4649,6 @@ static int create_key_fields(struct hist_trigger_data *hist_data,
14168 + if (!fields_str)
14169 + goto out;
14170 +
14171 +- strsep(&fields_str, "=");
14172 +- if (!fields_str)
14173 +- goto out;
14174 +-
14175 + for (i = n_vals; i < n_vals + TRACING_MAP_KEYS_MAX; i++) {
14176 + field_str = strsep(&fields_str, ",");
14177 + if (!field_str)
14178 +@@ -4795,12 +4806,6 @@ static int create_sort_keys(struct hist_trigger_data *hist_data)
14179 + if (!fields_str)
14180 + goto out;
14181 +
14182 +- strsep(&fields_str, "=");
14183 +- if (!fields_str) {
14184 +- ret = -EINVAL;
14185 +- goto out;
14186 +- }
14187 +-
14188 + for (i = 0; i < TRACING_MAP_SORT_KEYS_MAX; i++) {
14189 + struct hist_field *hist_field;
14190 + char *field_str, *field_name;
14191 +@@ -4809,9 +4814,11 @@ static int create_sort_keys(struct hist_trigger_data *hist_data)
14192 + sort_key = &hist_data->sort_keys[i];
14193 +
14194 + field_str = strsep(&fields_str, ",");
14195 +- if (!field_str) {
14196 +- if (i == 0)
14197 +- ret = -EINVAL;
14198 ++ if (!field_str)
14199 ++ break;
14200 ++
14201 ++ if (!*field_str) {
14202 ++ ret = -EINVAL;
14203 + break;
14204 + }
14205 +
14206 +@@ -4821,7 +4828,7 @@ static int create_sort_keys(struct hist_trigger_data *hist_data)
14207 + }
14208 +
14209 + field_name = strsep(&field_str, ".");
14210 +- if (!field_name) {
14211 ++ if (!field_name || !*field_name) {
14212 + ret = -EINVAL;
14213 + break;
14214 + }
14215 +diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
14216 +index 40106fff06a4..287d77eae59b 100644
14217 +--- a/kernel/trace/trace_events_trigger.c
14218 ++++ b/kernel/trace/trace_events_trigger.c
14219 +@@ -116,9 +116,10 @@ static void *trigger_next(struct seq_file *m, void *t, loff_t *pos)
14220 + {
14221 + struct trace_event_file *event_file = event_file_data(m->private);
14222 +
14223 +- if (t == SHOW_AVAILABLE_TRIGGERS)
14224 ++ if (t == SHOW_AVAILABLE_TRIGGERS) {
14225 ++ (*pos)++;
14226 + return NULL;
14227 +-
14228 ++ }
14229 + return seq_list_next(t, &event_file->triggers, pos);
14230 + }
14231 +
14232 +diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c
14233 +index 874f1274cf99..d1fa19773cc8 100644
14234 +--- a/kernel/trace/trace_stat.c
14235 ++++ b/kernel/trace/trace_stat.c
14236 +@@ -280,18 +280,22 @@ static int tracing_stat_init(void)
14237 +
14238 + d_tracing = tracing_init_dentry();
14239 + if (IS_ERR(d_tracing))
14240 +- return 0;
14241 ++ return -ENODEV;
14242 +
14243 + stat_dir = tracefs_create_dir("trace_stat", d_tracing);
14244 +- if (!stat_dir)
14245 ++ if (!stat_dir) {
14246 + pr_warn("Could not create tracefs 'trace_stat' entry\n");
14247 ++ return -ENOMEM;
14248 ++ }
14249 + return 0;
14250 + }
14251 +
14252 + static int init_stat_file(struct stat_session *session)
14253 + {
14254 +- if (!stat_dir && tracing_stat_init())
14255 +- return -ENODEV;
14256 ++ int ret;
14257 ++
14258 ++ if (!stat_dir && (ret = tracing_stat_init()))
14259 ++ return ret;
14260 +
14261 + session->file = tracefs_create_file(session->ts->name, 0644,
14262 + stat_dir,
14263 +@@ -304,7 +308,7 @@ static int init_stat_file(struct stat_session *session)
14264 + int register_stat_tracer(struct tracer_stat *trace)
14265 + {
14266 + struct stat_session *session, *node;
14267 +- int ret;
14268 ++ int ret = -EINVAL;
14269 +
14270 + if (!trace)
14271 + return -EINVAL;
14272 +@@ -315,17 +319,15 @@ int register_stat_tracer(struct tracer_stat *trace)
14273 + /* Already registered? */
14274 + mutex_lock(&all_stat_sessions_mutex);
14275 + list_for_each_entry(node, &all_stat_sessions, session_list) {
14276 +- if (node->ts == trace) {
14277 +- mutex_unlock(&all_stat_sessions_mutex);
14278 +- return -EINVAL;
14279 +- }
14280 ++ if (node->ts == trace)
14281 ++ goto out;
14282 + }
14283 +- mutex_unlock(&all_stat_sessions_mutex);
14284 +
14285 ++ ret = -ENOMEM;
14286 + /* Init the session */
14287 + session = kzalloc(sizeof(*session), GFP_KERNEL);
14288 + if (!session)
14289 +- return -ENOMEM;
14290 ++ goto out;
14291 +
14292 + session->ts = trace;
14293 + INIT_LIST_HEAD(&session->session_list);
14294 +@@ -334,15 +336,16 @@ int register_stat_tracer(struct tracer_stat *trace)
14295 + ret = init_stat_file(session);
14296 + if (ret) {
14297 + destroy_session(session);
14298 +- return ret;
14299 ++ goto out;
14300 + }
14301 +
14302 ++ ret = 0;
14303 + /* Register */
14304 +- mutex_lock(&all_stat_sessions_mutex);
14305 + list_add_tail(&session->session_list, &all_stat_sessions);
14306 ++ out:
14307 + mutex_unlock(&all_stat_sessions_mutex);
14308 +
14309 +- return 0;
14310 ++ return ret;
14311 + }
14312 +
14313 + void unregister_stat_tracer(struct tracer_stat *trace)
14314 +diff --git a/kernel/watchdog.c b/kernel/watchdog.c
14315 +index f41334ef0971..cbd3cf503c90 100644
14316 +--- a/kernel/watchdog.c
14317 ++++ b/kernel/watchdog.c
14318 +@@ -161,6 +161,8 @@ static void lockup_detector_update_enable(void)
14319 +
14320 + #ifdef CONFIG_SOFTLOCKUP_DETECTOR
14321 +
14322 ++#define SOFTLOCKUP_RESET ULONG_MAX
14323 ++
14324 + /* Global variables, exported for sysctl */
14325 + unsigned int __read_mostly softlockup_panic =
14326 + CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE;
14327 +@@ -274,7 +276,7 @@ notrace void touch_softlockup_watchdog_sched(void)
14328 + * Preemption can be enabled. It doesn't matter which CPU's timestamp
14329 + * gets zeroed here, so use the raw_ operation.
14330 + */
14331 +- raw_cpu_write(watchdog_touch_ts, 0);
14332 ++ raw_cpu_write(watchdog_touch_ts, SOFTLOCKUP_RESET);
14333 + }
14334 +
14335 + notrace void touch_softlockup_watchdog(void)
14336 +@@ -298,14 +300,14 @@ void touch_all_softlockup_watchdogs(void)
14337 + * the softlockup check.
14338 + */
14339 + for_each_cpu(cpu, &watchdog_allowed_mask)
14340 +- per_cpu(watchdog_touch_ts, cpu) = 0;
14341 ++ per_cpu(watchdog_touch_ts, cpu) = SOFTLOCKUP_RESET;
14342 + wq_watchdog_touch(-1);
14343 + }
14344 +
14345 + void touch_softlockup_watchdog_sync(void)
14346 + {
14347 + __this_cpu_write(softlockup_touch_sync, true);
14348 +- __this_cpu_write(watchdog_touch_ts, 0);
14349 ++ __this_cpu_write(watchdog_touch_ts, SOFTLOCKUP_RESET);
14350 + }
14351 +
14352 + static int is_softlockup(unsigned long touch_ts)
14353 +@@ -383,7 +385,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
14354 + /* .. and repeat */
14355 + hrtimer_forward_now(hrtimer, ns_to_ktime(sample_period));
14356 +
14357 +- if (touch_ts == 0) {
14358 ++ if (touch_ts == SOFTLOCKUP_RESET) {
14359 + if (unlikely(__this_cpu_read(softlockup_touch_sync))) {
14360 + /*
14361 + * If the time stamp was touched atomically
14362 +diff --git a/lib/debugobjects.c b/lib/debugobjects.c
14363 +index 61261195f5b6..48054dbf1b51 100644
14364 +--- a/lib/debugobjects.c
14365 ++++ b/lib/debugobjects.c
14366 +@@ -132,14 +132,18 @@ static void fill_pool(void)
14367 + struct debug_obj *obj;
14368 + unsigned long flags;
14369 +
14370 +- if (likely(obj_pool_free >= debug_objects_pool_min_level))
14371 ++ if (likely(READ_ONCE(obj_pool_free) >= debug_objects_pool_min_level))
14372 + return;
14373 +
14374 + /*
14375 + * Reuse objs from the global free list; they will be reinitialized
14376 + * when allocating.
14377 ++ *
14378 ++ * Both obj_nr_tofree and obj_pool_free are checked locklessly; the
14379 ++ * READ_ONCE()s pair with the WRITE_ONCE()s in pool_lock critical
14380 ++ * sections.
14381 + */
14382 +- while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) {
14383 ++ while (READ_ONCE(obj_nr_tofree) && (READ_ONCE(obj_pool_free) < obj_pool_min_free)) {
14384 + raw_spin_lock_irqsave(&pool_lock, flags);
14385 + /*
14386 + * Recheck with the lock held as the worker thread might have
14387 +@@ -148,9 +152,9 @@ static void fill_pool(void)
14388 + while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) {
14389 + obj = hlist_entry(obj_to_free.first, typeof(*obj), node);
14390 + hlist_del(&obj->node);
14391 +- obj_nr_tofree--;
14392 ++ WRITE_ONCE(obj_nr_tofree, obj_nr_tofree - 1);
14393 + hlist_add_head(&obj->node, &obj_pool);
14394 +- obj_pool_free++;
14395 ++ WRITE_ONCE(obj_pool_free, obj_pool_free + 1);
14396 + }
14397 + raw_spin_unlock_irqrestore(&pool_lock, flags);
14398 + }
14399 +@@ -158,7 +162,7 @@ static void fill_pool(void)
14400 + if (unlikely(!obj_cache))
14401 + return;
14402 +
14403 +- while (obj_pool_free < debug_objects_pool_min_level) {
14404 ++ while (READ_ONCE(obj_pool_free) < debug_objects_pool_min_level) {
14405 + struct debug_obj *new[ODEBUG_BATCH_SIZE];
14406 + int cnt;
14407 +
14408 +@@ -174,7 +178,7 @@ static void fill_pool(void)
14409 + while (cnt) {
14410 + hlist_add_head(&new[--cnt]->node, &obj_pool);
14411 + debug_objects_allocated++;
14412 +- obj_pool_free++;
14413 ++ WRITE_ONCE(obj_pool_free, obj_pool_free + 1);
14414 + }
14415 + raw_spin_unlock_irqrestore(&pool_lock, flags);
14416 + }
14417 +@@ -236,7 +240,7 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr)
14418 + obj = __alloc_object(&obj_pool);
14419 + if (obj) {
14420 + obj_pool_used++;
14421 +- obj_pool_free--;
14422 ++ WRITE_ONCE(obj_pool_free, obj_pool_free - 1);
14423 +
14424 + /*
14425 + * Looking ahead, allocate one batch of debug objects and
14426 +@@ -255,7 +259,7 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr)
14427 + &percpu_pool->free_objs);
14428 + percpu_pool->obj_free++;
14429 + obj_pool_used++;
14430 +- obj_pool_free--;
14431 ++ WRITE_ONCE(obj_pool_free, obj_pool_free - 1);
14432 + }
14433 + }
14434 +
14435 +@@ -309,8 +313,8 @@ static void free_obj_work(struct work_struct *work)
14436 + obj = hlist_entry(obj_to_free.first, typeof(*obj), node);
14437 + hlist_del(&obj->node);
14438 + hlist_add_head(&obj->node, &obj_pool);
14439 +- obj_pool_free++;
14440 +- obj_nr_tofree--;
14441 ++ WRITE_ONCE(obj_pool_free, obj_pool_free + 1);
14442 ++ WRITE_ONCE(obj_nr_tofree, obj_nr_tofree - 1);
14443 + }
14444 + raw_spin_unlock_irqrestore(&pool_lock, flags);
14445 + return;
14446 +@@ -324,7 +328,7 @@ free_objs:
14447 + if (obj_nr_tofree) {
14448 + hlist_move_list(&obj_to_free, &tofree);
14449 + debug_objects_freed += obj_nr_tofree;
14450 +- obj_nr_tofree = 0;
14451 ++ WRITE_ONCE(obj_nr_tofree, 0);
14452 + }
14453 + raw_spin_unlock_irqrestore(&pool_lock, flags);
14454 +
14455 +@@ -375,10 +379,10 @@ free_to_obj_pool:
14456 + obj_pool_used--;
14457 +
14458 + if (work) {
14459 +- obj_nr_tofree++;
14460 ++ WRITE_ONCE(obj_nr_tofree, obj_nr_tofree + 1);
14461 + hlist_add_head(&obj->node, &obj_to_free);
14462 + if (lookahead_count) {
14463 +- obj_nr_tofree += lookahead_count;
14464 ++ WRITE_ONCE(obj_nr_tofree, obj_nr_tofree + lookahead_count);
14465 + obj_pool_used -= lookahead_count;
14466 + while (lookahead_count) {
14467 + hlist_add_head(&objs[--lookahead_count]->node,
14468 +@@ -396,15 +400,15 @@ free_to_obj_pool:
14469 + for (i = 0; i < ODEBUG_BATCH_SIZE; i++) {
14470 + obj = __alloc_object(&obj_pool);
14471 + hlist_add_head(&obj->node, &obj_to_free);
14472 +- obj_pool_free--;
14473 +- obj_nr_tofree++;
14474 ++ WRITE_ONCE(obj_pool_free, obj_pool_free - 1);
14475 ++ WRITE_ONCE(obj_nr_tofree, obj_nr_tofree + 1);
14476 + }
14477 + }
14478 + } else {
14479 +- obj_pool_free++;
14480 ++ WRITE_ONCE(obj_pool_free, obj_pool_free + 1);
14481 + hlist_add_head(&obj->node, &obj_pool);
14482 + if (lookahead_count) {
14483 +- obj_pool_free += lookahead_count;
14484 ++ WRITE_ONCE(obj_pool_free, obj_pool_free + lookahead_count);
14485 + obj_pool_used -= lookahead_count;
14486 + while (lookahead_count) {
14487 + hlist_add_head(&objs[--lookahead_count]->node,
14488 +@@ -423,7 +427,7 @@ free_to_obj_pool:
14489 + static void free_object(struct debug_obj *obj)
14490 + {
14491 + __free_object(obj);
14492 +- if (!obj_freeing && obj_nr_tofree) {
14493 ++ if (!READ_ONCE(obj_freeing) && READ_ONCE(obj_nr_tofree)) {
14494 + WRITE_ONCE(obj_freeing, true);
14495 + schedule_delayed_work(&debug_obj_work, ODEBUG_FREE_WORK_DELAY);
14496 + }
14497 +@@ -982,7 +986,7 @@ repeat:
14498 + debug_objects_maxchecked = objs_checked;
14499 +
14500 + /* Schedule work to actually kmem_cache_free() objects */
14501 +- if (!obj_freeing && obj_nr_tofree) {
14502 ++ if (!READ_ONCE(obj_freeing) && READ_ONCE(obj_nr_tofree)) {
14503 + WRITE_ONCE(obj_freeing, true);
14504 + schedule_delayed_work(&debug_obj_work, ODEBUG_FREE_WORK_DELAY);
14505 + }
14506 +@@ -1008,12 +1012,12 @@ static int debug_stats_show(struct seq_file *m, void *v)
14507 + seq_printf(m, "max_checked :%d\n", debug_objects_maxchecked);
14508 + seq_printf(m, "warnings :%d\n", debug_objects_warnings);
14509 + seq_printf(m, "fixups :%d\n", debug_objects_fixups);
14510 +- seq_printf(m, "pool_free :%d\n", obj_pool_free + obj_percpu_free);
14511 ++ seq_printf(m, "pool_free :%d\n", READ_ONCE(obj_pool_free) + obj_percpu_free);
14512 + seq_printf(m, "pool_pcp_free :%d\n", obj_percpu_free);
14513 + seq_printf(m, "pool_min_free :%d\n", obj_pool_min_free);
14514 + seq_printf(m, "pool_used :%d\n", obj_pool_used - obj_percpu_free);
14515 + seq_printf(m, "pool_max_used :%d\n", obj_pool_max_used);
14516 +- seq_printf(m, "on_free_list :%d\n", obj_nr_tofree);
14517 ++ seq_printf(m, "on_free_list :%d\n", READ_ONCE(obj_nr_tofree));
14518 + seq_printf(m, "objs_allocated:%d\n", debug_objects_allocated);
14519 + seq_printf(m, "objs_freed :%d\n", debug_objects_freed);
14520 + return 0;
14521 +diff --git a/lib/kunit/try-catch.c b/lib/kunit/try-catch.c
14522 +index 55686839eb61..6b9c5242017f 100644
14523 +--- a/lib/kunit/try-catch.c
14524 ++++ b/lib/kunit/try-catch.c
14525 +@@ -12,7 +12,6 @@
14526 + #include <linux/completion.h>
14527 + #include <linux/kernel.h>
14528 + #include <linux/kthread.h>
14529 +-#include <linux/sched/sysctl.h>
14530 +
14531 + void __noreturn kunit_try_catch_throw(struct kunit_try_catch *try_catch)
14532 + {
14533 +@@ -31,8 +30,6 @@ static int kunit_generic_run_threadfn_adapter(void *data)
14534 +
14535 + static unsigned long kunit_test_timeout(void)
14536 + {
14537 +- unsigned long timeout_msecs;
14538 +-
14539 + /*
14540 + * TODO(brendanhiggins@××××××.com): We should probably have some type of
14541 + * variable timeout here. The only question is what that timeout value
14542 +@@ -49,22 +46,11 @@ static unsigned long kunit_test_timeout(void)
14543 + *
14544 + * For more background on this topic, see:
14545 + * https://mike-bland.com/2011/11/01/small-medium-large.html
14546 ++ *
14547 ++ * If tests timeout due to exceeding sysctl_hung_task_timeout_secs,
14548 ++ * the task will be killed and an oops generated.
14549 + */
14550 +- if (sysctl_hung_task_timeout_secs) {
14551 +- /*
14552 +- * If sysctl_hung_task is active, just set the timeout to some
14553 +- * value less than that.
14554 +- *
14555 +- * In regards to the above TODO, if we decide on variable
14556 +- * timeouts, this logic will likely need to change.
14557 +- */
14558 +- timeout_msecs = (sysctl_hung_task_timeout_secs - 1) *
14559 +- MSEC_PER_SEC;
14560 +- } else {
14561 +- timeout_msecs = 300 * MSEC_PER_SEC; /* 5 min */
14562 +- }
14563 +-
14564 +- return timeout_msecs;
14565 ++ return 300 * MSEC_PER_SEC; /* 5 min */
14566 + }
14567 +
14568 + void kunit_try_catch_run(struct kunit_try_catch *try_catch, void *context)
14569 +diff --git a/lib/raid6/mktables.c b/lib/raid6/mktables.c
14570 +index 9c485df1308f..f02e10fa6238 100644
14571 +--- a/lib/raid6/mktables.c
14572 ++++ b/lib/raid6/mktables.c
14573 +@@ -56,8 +56,8 @@ int main(int argc, char *argv[])
14574 + uint8_t v;
14575 + uint8_t exptbl[256], invtbl[256];
14576 +
14577 +- printf("#include <linux/raid/pq.h>\n");
14578 + printf("#include <linux/export.h>\n");
14579 ++ printf("#include <linux/raid/pq.h>\n");
14580 +
14581 + /* Compute multiplication table */
14582 + printf("\nconst u8 __attribute__((aligned(256)))\n"
14583 +diff --git a/lib/scatterlist.c b/lib/scatterlist.c
14584 +index c2cf2c311b7d..5813072bc589 100644
14585 +--- a/lib/scatterlist.c
14586 ++++ b/lib/scatterlist.c
14587 +@@ -311,7 +311,7 @@ int __sg_alloc_table(struct sg_table *table, unsigned int nents,
14588 + if (prv)
14589 + table->nents = ++table->orig_nents;
14590 +
14591 +- return -ENOMEM;
14592 ++ return -ENOMEM;
14593 + }
14594 +
14595 + sg_init_table(sg, alloc_size);
14596 +diff --git a/net/core/dev.c b/net/core/dev.c
14597 +index 81befd0c2510..466f2e4144b0 100644
14598 +--- a/net/core/dev.c
14599 ++++ b/net/core/dev.c
14600 +@@ -4477,14 +4477,14 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
14601 + /* Reinjected packets coming from act_mirred or similar should
14602 + * not get XDP generic processing.
14603 + */
14604 +- if (skb_cloned(skb) || skb_is_tc_redirected(skb))
14605 ++ if (skb_is_tc_redirected(skb))
14606 + return XDP_PASS;
14607 +
14608 + /* XDP packets must be linear and must have sufficient headroom
14609 + * of XDP_PACKET_HEADROOM bytes. This is the guarantee that also
14610 + * native XDP provides, thus we need to do it here as well.
14611 + */
14612 +- if (skb_is_nonlinear(skb) ||
14613 ++ if (skb_cloned(skb) || skb_is_nonlinear(skb) ||
14614 + skb_headroom(skb) < XDP_PACKET_HEADROOM) {
14615 + int hroom = XDP_PACKET_HEADROOM - skb_headroom(skb);
14616 + int troom = skb->tail + skb->data_len - skb->end;
14617 +diff --git a/net/core/filter.c b/net/core/filter.c
14618 +index 538f6a735a19..f797b1599c92 100644
14619 +--- a/net/core/filter.c
14620 ++++ b/net/core/filter.c
14621 +@@ -3543,7 +3543,7 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd,
14622 + return err;
14623 + }
14624 + default:
14625 +- break;
14626 ++ return -EBADRQC;
14627 + }
14628 + return 0;
14629 + }
14630 +diff --git a/net/core/sock_map.c b/net/core/sock_map.c
14631 +index 085cef5857bb..405397801bb0 100644
14632 +--- a/net/core/sock_map.c
14633 ++++ b/net/core/sock_map.c
14634 +@@ -881,6 +881,9 @@ static void sock_hash_free(struct bpf_map *map)
14635 + /* wait for psock readers accessing its map link */
14636 + synchronize_rcu();
14637 +
14638 ++ /* wait for psock readers accessing its map link */
14639 ++ synchronize_rcu();
14640 ++
14641 + bpf_map_area_free(htab->buckets);
14642 + kfree(htab);
14643 + }
14644 +diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c
14645 +index c8a128c9e5e0..70db7c909f74 100644
14646 +--- a/net/dsa/tag_qca.c
14647 ++++ b/net/dsa/tag_qca.c
14648 +@@ -33,7 +33,7 @@ static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev)
14649 + struct dsa_port *dp = dsa_slave_to_port(dev);
14650 + u16 *phdr, hdr;
14651 +
14652 +- if (skb_cow_head(skb, 0) < 0)
14653 ++ if (skb_cow_head(skb, QCA_HDR_LEN) < 0)
14654 + return NULL;
14655 +
14656 + skb_push(skb, QCA_HDR_LEN);
14657 +diff --git a/net/netfilter/nft_tunnel.c b/net/netfilter/nft_tunnel.c
14658 +index 5284fcf16be7..f8d2919cf9fd 100644
14659 +--- a/net/netfilter/nft_tunnel.c
14660 ++++ b/net/netfilter/nft_tunnel.c
14661 +@@ -248,8 +248,9 @@ static int nft_tunnel_obj_vxlan_init(const struct nlattr *attr,
14662 + }
14663 +
14664 + static const struct nla_policy nft_tunnel_opts_erspan_policy[NFTA_TUNNEL_KEY_ERSPAN_MAX + 1] = {
14665 ++ [NFTA_TUNNEL_KEY_ERSPAN_VERSION] = { .type = NLA_U32 },
14666 + [NFTA_TUNNEL_KEY_ERSPAN_V1_INDEX] = { .type = NLA_U32 },
14667 +- [NFTA_TUNNEL_KEY_ERSPAN_V2_DIR] = { .type = NLA_U8 },
14668 ++ [NFTA_TUNNEL_KEY_ERSPAN_V2_DIR] = { .type = NLA_U8 },
14669 + [NFTA_TUNNEL_KEY_ERSPAN_V2_HWID] = { .type = NLA_U8 },
14670 + };
14671 +
14672 +diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
14673 +index f9c0d1e8d380..7e54d2ab5254 100644
14674 +--- a/net/sched/cls_flower.c
14675 ++++ b/net/sched/cls_flower.c
14676 +@@ -691,6 +691,7 @@ static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = {
14677 + .len = 128 / BITS_PER_BYTE },
14678 + [TCA_FLOWER_KEY_CT_LABELS_MASK] = { .type = NLA_BINARY,
14679 + .len = 128 / BITS_PER_BYTE },
14680 ++ [TCA_FLOWER_FLAGS] = { .type = NLA_U32 },
14681 + };
14682 +
14683 + static const struct nla_policy
14684 +diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
14685 +index 039cc86974f4..610a0b728161 100644
14686 +--- a/net/sched/cls_matchall.c
14687 ++++ b/net/sched/cls_matchall.c
14688 +@@ -157,6 +157,7 @@ static void *mall_get(struct tcf_proto *tp, u32 handle)
14689 + static const struct nla_policy mall_policy[TCA_MATCHALL_MAX + 1] = {
14690 + [TCA_MATCHALL_UNSPEC] = { .type = NLA_UNSPEC },
14691 + [TCA_MATCHALL_CLASSID] = { .type = NLA_U32 },
14692 ++ [TCA_MATCHALL_FLAGS] = { .type = NLA_U32 },
14693 + };
14694 +
14695 + static int mall_set_parms(struct net *net, struct tcf_proto *tp,
14696 +diff --git a/net/smc/smc_diag.c b/net/smc/smc_diag.c
14697 +index f38727ecf8b2..e1f64f4ba236 100644
14698 +--- a/net/smc/smc_diag.c
14699 ++++ b/net/smc/smc_diag.c
14700 +@@ -39,16 +39,15 @@ static void smc_diag_msg_common_fill(struct smc_diag_msg *r, struct sock *sk)
14701 + {
14702 + struct smc_sock *smc = smc_sk(sk);
14703 +
14704 ++ memset(r, 0, sizeof(*r));
14705 + r->diag_family = sk->sk_family;
14706 ++ sock_diag_save_cookie(sk, r->id.idiag_cookie);
14707 + if (!smc->clcsock)
14708 + return;
14709 + r->id.idiag_sport = htons(smc->clcsock->sk->sk_num);
14710 + r->id.idiag_dport = smc->clcsock->sk->sk_dport;
14711 + r->id.idiag_if = smc->clcsock->sk->sk_bound_dev_if;
14712 +- sock_diag_save_cookie(sk, r->id.idiag_cookie);
14713 + if (sk->sk_protocol == SMCPROTO_SMC) {
14714 +- memset(&r->id.idiag_src, 0, sizeof(r->id.idiag_src));
14715 +- memset(&r->id.idiag_dst, 0, sizeof(r->id.idiag_dst));
14716 + r->id.idiag_src[0] = smc->clcsock->sk->sk_rcv_saddr;
14717 + r->id.idiag_dst[0] = smc->clcsock->sk->sk_daddr;
14718 + #if IS_ENABLED(CONFIG_IPV6)
14719 +diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
14720 +index f740cb51802a..7ede1e52fd81 100644
14721 +--- a/net/sunrpc/cache.c
14722 ++++ b/net/sunrpc/cache.c
14723 +@@ -1888,7 +1888,9 @@ void sunrpc_cache_unhash(struct cache_detail *cd, struct cache_head *h)
14724 + if (!hlist_unhashed(&h->cache_list)){
14725 + hlist_del_init_rcu(&h->cache_list);
14726 + cd->entries--;
14727 ++ set_bit(CACHE_CLEANED, &h->flags);
14728 + spin_unlock(&cd->hash_lock);
14729 ++ cache_fresh_unlocked(h, cd);
14730 + cache_put(h, cd);
14731 + } else
14732 + spin_unlock(&cd->hash_lock);
14733 +diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
14734 +index c0147a8cf188..06ebe3104cc0 100644
14735 +--- a/samples/bpf/Makefile
14736 ++++ b/samples/bpf/Makefile
14737 +@@ -236,6 +236,7 @@ BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
14738 + readelf -S ./llvm_btf_verify.o | grep BTF; \
14739 + /bin/rm -f ./llvm_btf_verify.o)
14740 +
14741 ++BPF_EXTRA_CFLAGS += -fno-stack-protector
14742 + ifneq ($(BTF_LLVM_PROBE),)
14743 + BPF_EXTRA_CFLAGS += -g
14744 + else
14745 +diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
14746 +index bc5f25763c1b..f3155af04d85 100644
14747 +--- a/scripts/Kbuild.include
14748 ++++ b/scripts/Kbuild.include
14749 +@@ -55,14 +55,13 @@ kecho := $($(quiet)kecho)
14750 + # - stdin is piped in from the first prerequisite ($<) so one has
14751 + # to specify a valid file as first prerequisite (often the kbuild file)
14752 + define filechk
14753 +- $(Q)set -e; \
14754 +- mkdir -p $(dir $@); \
14755 +- { $(filechk_$(1)); } > $@.tmp; \
14756 +- if [ -r $@ ] && cmp -s $@ $@.tmp; then \
14757 +- rm -f $@.tmp; \
14758 +- else \
14759 +- $(kecho) ' UPD $@'; \
14760 +- mv -f $@.tmp $@; \
14761 ++ $(Q)set -e; \
14762 ++ mkdir -p $(dir $@); \
14763 ++ trap "rm -f $(dot-target).tmp" EXIT; \
14764 ++ { $(filechk_$(1)); } > $(dot-target).tmp; \
14765 ++ if [ ! -r $@ ] || ! cmp -s $@ $(dot-target).tmp; then \
14766 ++ $(kecho) ' UPD $@'; \
14767 ++ mv -f $(dot-target).tmp $@; \
14768 + fi
14769 + endef
14770 +
14771 +diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
14772 +index d4adfbe42690..bfb44b265a94 100644
14773 +--- a/scripts/Kconfig.include
14774 ++++ b/scripts/Kconfig.include
14775 +@@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y)
14776 +
14777 + # $(cc-option,<flag>)
14778 + # Return y if the compiler supports <flag>, n otherwise
14779 +-cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -E -x c /dev/null -o /dev/null)
14780 ++cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null)
14781 +
14782 + # $(ld-option,<flag>)
14783 + # Return y if the linker supports <flag>, n otherwise
14784 +diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
14785 +index 3569d2dec37c..17298239e363 100644
14786 +--- a/scripts/kconfig/confdata.c
14787 ++++ b/scripts/kconfig/confdata.c
14788 +@@ -1353,7 +1353,7 @@ bool conf_set_all_new_symbols(enum conf_def_mode mode)
14789 +
14790 + sym_calc_value(csym);
14791 + if (mode == def_random)
14792 +- has_changed = randomize_choice_values(csym);
14793 ++ has_changed |= randomize_choice_values(csym);
14794 + else {
14795 + set_all_choice_values(csym);
14796 + has_changed = true;
14797 +diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
14798 +index 436379940356..408b5c0b99b1 100755
14799 +--- a/scripts/link-vmlinux.sh
14800 ++++ b/scripts/link-vmlinux.sh
14801 +@@ -108,13 +108,13 @@ gen_btf()
14802 + local bin_arch
14803 +
14804 + if ! [ -x "$(command -v ${PAHOLE})" ]; then
14805 +- info "BTF" "${1}: pahole (${PAHOLE}) is not available"
14806 ++ echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available"
14807 + return 1
14808 + fi
14809 +
14810 + pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
14811 + if [ "${pahole_ver}" -lt "113" ]; then
14812 +- info "BTF" "${1}: pahole version $(${PAHOLE} --version) is too old, need at least v1.13"
14813 ++ echo >&2 "BTF: ${1}: pahole version $(${PAHOLE} --version) is too old, need at least v1.13"
14814 + return 1
14815 + fi
14816 +
14817 +diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
14818 +index d7e987baf127..9b35db2fc777 100644
14819 +--- a/security/integrity/ima/ima_main.c
14820 ++++ b/security/integrity/ima/ima_main.c
14821 +@@ -655,6 +655,9 @@ void process_buffer_measurement(const void *buf, int size,
14822 + int action = 0;
14823 + u32 secid;
14824 +
14825 ++ if (!ima_policy_flag)
14826 ++ return;
14827 ++
14828 + /*
14829 + * Both LSM hooks and auxilary based buffer measurements are
14830 + * based on policy. To avoid code duplication, differentiate
14831 +diff --git a/security/selinux/avc.c b/security/selinux/avc.c
14832 +index 23dc888ae305..d18cb32a242a 100644
14833 +--- a/security/selinux/avc.c
14834 ++++ b/security/selinux/avc.c
14835 +@@ -617,40 +617,37 @@ static struct avc_node *avc_insert(struct selinux_avc *avc,
14836 + struct avc_node *pos, *node = NULL;
14837 + int hvalue;
14838 + unsigned long flag;
14839 ++ spinlock_t *lock;
14840 ++ struct hlist_head *head;
14841 +
14842 + if (avc_latest_notif_update(avc, avd->seqno, 1))
14843 +- goto out;
14844 ++ return NULL;
14845 +
14846 + node = avc_alloc_node(avc);
14847 +- if (node) {
14848 +- struct hlist_head *head;
14849 +- spinlock_t *lock;
14850 +- int rc = 0;
14851 +-
14852 +- hvalue = avc_hash(ssid, tsid, tclass);
14853 +- avc_node_populate(node, ssid, tsid, tclass, avd);
14854 +- rc = avc_xperms_populate(node, xp_node);
14855 +- if (rc) {
14856 +- kmem_cache_free(avc_node_cachep, node);
14857 +- return NULL;
14858 +- }
14859 +- head = &avc->avc_cache.slots[hvalue];
14860 +- lock = &avc->avc_cache.slots_lock[hvalue];
14861 ++ if (!node)
14862 ++ return NULL;
14863 +
14864 +- spin_lock_irqsave(lock, flag);
14865 +- hlist_for_each_entry(pos, head, list) {
14866 +- if (pos->ae.ssid == ssid &&
14867 +- pos->ae.tsid == tsid &&
14868 +- pos->ae.tclass == tclass) {
14869 +- avc_node_replace(avc, node, pos);
14870 +- goto found;
14871 +- }
14872 ++ avc_node_populate(node, ssid, tsid, tclass, avd);
14873 ++ if (avc_xperms_populate(node, xp_node)) {
14874 ++ avc_node_kill(avc, node);
14875 ++ return NULL;
14876 ++ }
14877 ++
14878 ++ hvalue = avc_hash(ssid, tsid, tclass);
14879 ++ head = &avc->avc_cache.slots[hvalue];
14880 ++ lock = &avc->avc_cache.slots_lock[hvalue];
14881 ++ spin_lock_irqsave(lock, flag);
14882 ++ hlist_for_each_entry(pos, head, list) {
14883 ++ if (pos->ae.ssid == ssid &&
14884 ++ pos->ae.tsid == tsid &&
14885 ++ pos->ae.tclass == tclass) {
14886 ++ avc_node_replace(avc, node, pos);
14887 ++ goto found;
14888 + }
14889 +- hlist_add_head_rcu(&node->list, head);
14890 +-found:
14891 +- spin_unlock_irqrestore(lock, flag);
14892 + }
14893 +-out:
14894 ++ hlist_add_head_rcu(&node->list, head);
14895 ++found:
14896 ++ spin_unlock_irqrestore(lock, flag);
14897 + return node;
14898 + }
14899 +
14900 +@@ -894,7 +891,7 @@ static int avc_update_node(struct selinux_avc *avc,
14901 + if (orig->ae.xp_node) {
14902 + rc = avc_xperms_populate(node, orig->ae.xp_node);
14903 + if (rc) {
14904 +- kmem_cache_free(avc_node_cachep, node);
14905 ++ avc_node_kill(avc, node);
14906 + goto out_unlock;
14907 + }
14908 + }
14909 +diff --git a/sound/core/control.c b/sound/core/control.c
14910 +index 7a4d8690ce41..08ca7666e84c 100644
14911 +--- a/sound/core/control.c
14912 ++++ b/sound/core/control.c
14913 +@@ -1430,8 +1430,9 @@ static int call_tlv_handler(struct snd_ctl_file *file, int op_flag,
14914 + if (kctl->tlv.c == NULL)
14915 + return -ENXIO;
14916 +
14917 +- /* When locked, this is unavailable. */
14918 +- if (vd->owner != NULL && vd->owner != file)
14919 ++ /* Write and command operations are not allowed for locked element. */
14920 ++ if (op_flag != SNDRV_CTL_TLV_OP_READ &&
14921 ++ vd->owner != NULL && vd->owner != file)
14922 + return -EPERM;
14923 +
14924 + return kctl->tlv.c(kctl, op_flag, size, buf);
14925 +diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
14926 +index 90aa0f400a57..1e20e85e9b46 100644
14927 +--- a/sound/pci/hda/patch_conexant.c
14928 ++++ b/sound/pci/hda/patch_conexant.c
14929 +@@ -922,6 +922,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
14930 + SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410),
14931 + SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410),
14932 + SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410),
14933 ++ SND_PCI_QUIRK(0x17aa, 0x21d2, "Lenovo T420s", CXT_PINCFG_LENOVO_TP410),
14934 + SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410),
14935 + SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410),
14936 + SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo IdeaPad Z560", CXT_FIXUP_MUTE_LED_EAPD),
14937 +diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
14938 +index bde50414029d..4f195c7d966a 100644
14939 +--- a/sound/pci/hda/patch_hdmi.c
14940 ++++ b/sound/pci/hda/patch_hdmi.c
14941 +@@ -2862,9 +2862,12 @@ static int alloc_intel_hdmi(struct hda_codec *codec)
14942 + /* parse and post-process for Intel codecs */
14943 + static int parse_intel_hdmi(struct hda_codec *codec)
14944 + {
14945 +- int err;
14946 ++ int err, retries = 3;
14947 ++
14948 ++ do {
14949 ++ err = hdmi_parse_codec(codec);
14950 ++ } while (err < 0 && retries--);
14951 +
14952 +- err = hdmi_parse_codec(codec);
14953 + if (err < 0) {
14954 + generic_spec_free(codec);
14955 + return err;
14956 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
14957 +index 128d81b4140b..c6b1581c6ffa 100644
14958 +--- a/sound/pci/hda/patch_realtek.c
14959 ++++ b/sound/pci/hda/patch_realtek.c
14960 +@@ -5852,6 +5852,7 @@ enum {
14961 + ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
14962 + ALC288_FIXUP_DELL_XPS_13,
14963 + ALC288_FIXUP_DISABLE_AAMIX,
14964 ++ ALC292_FIXUP_DELL_E7X_AAMIX,
14965 + ALC292_FIXUP_DELL_E7X,
14966 + ALC292_FIXUP_DISABLE_AAMIX,
14967 + ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK,
14968 +@@ -6547,12 +6548,19 @@ static const struct hda_fixup alc269_fixups[] = {
14969 + .chained = true,
14970 + .chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE
14971 + },
14972 +- [ALC292_FIXUP_DELL_E7X] = {
14973 ++ [ALC292_FIXUP_DELL_E7X_AAMIX] = {
14974 + .type = HDA_FIXUP_FUNC,
14975 + .v.func = alc_fixup_dell_xps13,
14976 + .chained = true,
14977 + .chain_id = ALC292_FIXUP_DISABLE_AAMIX
14978 + },
14979 ++ [ALC292_FIXUP_DELL_E7X] = {
14980 ++ .type = HDA_FIXUP_FUNC,
14981 ++ .v.func = snd_hda_gen_fixup_micmute_led,
14982 ++ /* micmute fixup must be applied at last */
14983 ++ .chained_before = true,
14984 ++ .chain_id = ALC292_FIXUP_DELL_E7X_AAMIX,
14985 ++ },
14986 + [ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE] = {
14987 + .type = HDA_FIXUP_PINS,
14988 + .v.pins = (const struct hda_pintbl[]) {
14989 +diff --git a/sound/sh/aica.c b/sound/sh/aica.c
14990 +index bf1fb0d8a930..f69072d2564c 100644
14991 +--- a/sound/sh/aica.c
14992 ++++ b/sound/sh/aica.c
14993 +@@ -101,10 +101,10 @@ static void spu_memset(u32 toi, u32 what, int length)
14994 + }
14995 +
14996 + /* spu_memload - write to SPU address space */
14997 +-static void spu_memload(u32 toi, void *from, int length)
14998 ++static void spu_memload(u32 toi, const void *from, int length)
14999 + {
15000 + unsigned long flags;
15001 +- u32 *froml = from;
15002 ++ const u32 *froml = from;
15003 + u32 __iomem *to = (u32 __iomem *) (SPU_MEMORY_BASE + toi);
15004 + int i;
15005 + u32 val;
15006 +diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c
15007 +index f9e36abc98ac..725992937e8f 100644
15008 +--- a/sound/sh/sh_dac_audio.c
15009 ++++ b/sound/sh/sh_dac_audio.c
15010 +@@ -175,7 +175,6 @@ static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream,
15011 + {
15012 + /* channel is not used (interleaved data) */
15013 + struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
15014 +- struct snd_pcm_runtime *runtime = substream->runtime;
15015 +
15016 + if (copy_from_user_toio(chip->data_buffer + pos, src, count))
15017 + return -EFAULT;
15018 +@@ -195,7 +194,6 @@ static int snd_sh_dac_pcm_copy_kernel(struct snd_pcm_substream *substream,
15019 + {
15020 + /* channel is not used (interleaved data) */
15021 + struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
15022 +- struct snd_pcm_runtime *runtime = substream->runtime;
15023 +
15024 + memcpy_toio(chip->data_buffer + pos, src, count);
15025 + chip->buffer_end = chip->data_buffer + pos + count;
15026 +@@ -214,7 +212,6 @@ static int snd_sh_dac_pcm_silence(struct snd_pcm_substream *substream,
15027 + {
15028 + /* channel is not used (interleaved data) */
15029 + struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
15030 +- struct snd_pcm_runtime *runtime = substream->runtime;
15031 +
15032 + memset_io(chip->data_buffer + pos, 0, count);
15033 + chip->buffer_end = chip->data_buffer + pos + count;
15034 +diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig
15035 +index f118c229ed82..d1dc8e6366dc 100644
15036 +--- a/sound/soc/atmel/Kconfig
15037 ++++ b/sound/soc/atmel/Kconfig
15038 +@@ -19,6 +19,8 @@ config SND_ATMEL_SOC_DMA
15039 +
15040 + config SND_ATMEL_SOC_SSC
15041 + tristate
15042 ++ select SND_ATMEL_SOC_DMA
15043 ++ select SND_ATMEL_SOC_PDC
15044 +
15045 + config SND_ATMEL_SOC_SSC_PDC
15046 + tristate "SoC PCM DAI support for AT91 SSC controller using PDC"
15047 +diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
15048 +index 2a9b610f6d43..d3d32b501aca 100644
15049 +--- a/sound/soc/codecs/wm_adsp.c
15050 ++++ b/sound/soc/codecs/wm_adsp.c
15051 +@@ -1030,8 +1030,8 @@ static int wm_coeff_write_acked_control(struct wm_coeff_ctl *ctl,
15052 + return -ETIMEDOUT;
15053 + }
15054 +
15055 +-static int wm_coeff_write_control(struct wm_coeff_ctl *ctl,
15056 +- const void *buf, size_t len)
15057 ++static int wm_coeff_write_ctrl_raw(struct wm_coeff_ctl *ctl,
15058 ++ const void *buf, size_t len)
15059 + {
15060 + struct wm_adsp *dsp = ctl->dsp;
15061 + void *scratch;
15062 +@@ -1061,6 +1061,23 @@ static int wm_coeff_write_control(struct wm_coeff_ctl *ctl,
15063 + return 0;
15064 + }
15065 +
15066 ++static int wm_coeff_write_ctrl(struct wm_coeff_ctl *ctl,
15067 ++ const void *buf, size_t len)
15068 ++{
15069 ++ int ret = 0;
15070 ++
15071 ++ if (ctl->flags & WMFW_CTL_FLAG_VOLATILE)
15072 ++ ret = -EPERM;
15073 ++ else if (buf != ctl->cache)
15074 ++ memcpy(ctl->cache, buf, len);
15075 ++
15076 ++ ctl->set = 1;
15077 ++ if (ctl->enabled && ctl->dsp->running)
15078 ++ ret = wm_coeff_write_ctrl_raw(ctl, buf, len);
15079 ++
15080 ++ return ret;
15081 ++}
15082 ++
15083 + static int wm_coeff_put(struct snd_kcontrol *kctl,
15084 + struct snd_ctl_elem_value *ucontrol)
15085 + {
15086 +@@ -1071,16 +1088,7 @@ static int wm_coeff_put(struct snd_kcontrol *kctl,
15087 + int ret = 0;
15088 +
15089 + mutex_lock(&ctl->dsp->pwr_lock);
15090 +-
15091 +- if (ctl->flags & WMFW_CTL_FLAG_VOLATILE)
15092 +- ret = -EPERM;
15093 +- else
15094 +- memcpy(ctl->cache, p, ctl->len);
15095 +-
15096 +- ctl->set = 1;
15097 +- if (ctl->enabled && ctl->dsp->running)
15098 +- ret = wm_coeff_write_control(ctl, p, ctl->len);
15099 +-
15100 ++ ret = wm_coeff_write_ctrl(ctl, p, ctl->len);
15101 + mutex_unlock(&ctl->dsp->pwr_lock);
15102 +
15103 + return ret;
15104 +@@ -1096,15 +1104,10 @@ static int wm_coeff_tlv_put(struct snd_kcontrol *kctl,
15105 +
15106 + mutex_lock(&ctl->dsp->pwr_lock);
15107 +
15108 +- if (copy_from_user(ctl->cache, bytes, size)) {
15109 ++ if (copy_from_user(ctl->cache, bytes, size))
15110 + ret = -EFAULT;
15111 +- } else {
15112 +- ctl->set = 1;
15113 +- if (ctl->enabled && ctl->dsp->running)
15114 +- ret = wm_coeff_write_control(ctl, ctl->cache, size);
15115 +- else if (ctl->flags & WMFW_CTL_FLAG_VOLATILE)
15116 +- ret = -EPERM;
15117 +- }
15118 ++ else
15119 ++ ret = wm_coeff_write_ctrl(ctl, ctl->cache, size);
15120 +
15121 + mutex_unlock(&ctl->dsp->pwr_lock);
15122 +
15123 +@@ -1135,8 +1138,8 @@ static int wm_coeff_put_acked(struct snd_kcontrol *kctl,
15124 + return ret;
15125 + }
15126 +
15127 +-static int wm_coeff_read_control(struct wm_coeff_ctl *ctl,
15128 +- void *buf, size_t len)
15129 ++static int wm_coeff_read_ctrl_raw(struct wm_coeff_ctl *ctl,
15130 ++ void *buf, size_t len)
15131 + {
15132 + struct wm_adsp *dsp = ctl->dsp;
15133 + void *scratch;
15134 +@@ -1166,29 +1169,37 @@ static int wm_coeff_read_control(struct wm_coeff_ctl *ctl,
15135 + return 0;
15136 + }
15137 +
15138 +-static int wm_coeff_get(struct snd_kcontrol *kctl,
15139 +- struct snd_ctl_elem_value *ucontrol)
15140 ++static int wm_coeff_read_ctrl(struct wm_coeff_ctl *ctl, void *buf, size_t len)
15141 + {
15142 +- struct soc_bytes_ext *bytes_ext =
15143 +- (struct soc_bytes_ext *)kctl->private_value;
15144 +- struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext);
15145 +- char *p = ucontrol->value.bytes.data;
15146 + int ret = 0;
15147 +
15148 +- mutex_lock(&ctl->dsp->pwr_lock);
15149 +-
15150 + if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) {
15151 + if (ctl->enabled && ctl->dsp->running)
15152 +- ret = wm_coeff_read_control(ctl, p, ctl->len);
15153 ++ return wm_coeff_read_ctrl_raw(ctl, buf, len);
15154 + else
15155 +- ret = -EPERM;
15156 ++ return -EPERM;
15157 + } else {
15158 + if (!ctl->flags && ctl->enabled && ctl->dsp->running)
15159 +- ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len);
15160 ++ ret = wm_coeff_read_ctrl_raw(ctl, ctl->cache, ctl->len);
15161 +
15162 +- memcpy(p, ctl->cache, ctl->len);
15163 ++ if (buf != ctl->cache)
15164 ++ memcpy(buf, ctl->cache, len);
15165 + }
15166 +
15167 ++ return ret;
15168 ++}
15169 ++
15170 ++static int wm_coeff_get(struct snd_kcontrol *kctl,
15171 ++ struct snd_ctl_elem_value *ucontrol)
15172 ++{
15173 ++ struct soc_bytes_ext *bytes_ext =
15174 ++ (struct soc_bytes_ext *)kctl->private_value;
15175 ++ struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext);
15176 ++ char *p = ucontrol->value.bytes.data;
15177 ++ int ret;
15178 ++
15179 ++ mutex_lock(&ctl->dsp->pwr_lock);
15180 ++ ret = wm_coeff_read_ctrl(ctl, p, ctl->len);
15181 + mutex_unlock(&ctl->dsp->pwr_lock);
15182 +
15183 + return ret;
15184 +@@ -1204,15 +1215,7 @@ static int wm_coeff_tlv_get(struct snd_kcontrol *kctl,
15185 +
15186 + mutex_lock(&ctl->dsp->pwr_lock);
15187 +
15188 +- if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) {
15189 +- if (ctl->enabled && ctl->dsp->running)
15190 +- ret = wm_coeff_read_control(ctl, ctl->cache, size);
15191 +- else
15192 +- ret = -EPERM;
15193 +- } else {
15194 +- if (!ctl->flags && ctl->enabled && ctl->dsp->running)
15195 +- ret = wm_coeff_read_control(ctl, ctl->cache, size);
15196 +- }
15197 ++ ret = wm_coeff_read_ctrl_raw(ctl, ctl->cache, size);
15198 +
15199 + if (!ret && copy_to_user(bytes, ctl->cache, size))
15200 + ret = -EFAULT;
15201 +@@ -1340,7 +1343,7 @@ static int wm_coeff_init_control_caches(struct wm_adsp *dsp)
15202 + * created so we don't need to do anything.
15203 + */
15204 + if (!ctl->flags || (ctl->flags & WMFW_CTL_FLAG_READABLE)) {
15205 +- ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len);
15206 ++ ret = wm_coeff_read_ctrl_raw(ctl, ctl->cache, ctl->len);
15207 + if (ret < 0)
15208 + return ret;
15209 + }
15210 +@@ -1358,7 +1361,8 @@ static int wm_coeff_sync_controls(struct wm_adsp *dsp)
15211 + if (!ctl->enabled)
15212 + continue;
15213 + if (ctl->set && !(ctl->flags & WMFW_CTL_FLAG_VOLATILE)) {
15214 +- ret = wm_coeff_write_control(ctl, ctl->cache, ctl->len);
15215 ++ ret = wm_coeff_write_ctrl_raw(ctl, ctl->cache,
15216 ++ ctl->len);
15217 + if (ret < 0)
15218 + return ret;
15219 + }
15220 +@@ -2048,7 +2052,7 @@ int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type,
15221 + if (len > ctl->len)
15222 + return -EINVAL;
15223 +
15224 +- ret = wm_coeff_write_control(ctl, buf, len);
15225 ++ ret = wm_coeff_write_ctrl(ctl, buf, len);
15226 +
15227 + kcontrol = snd_soc_card_get_kcontrol(dsp->component->card, ctl->name);
15228 + snd_ctl_notify(dsp->component->card->snd_card,
15229 +@@ -2070,7 +2074,7 @@ int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type,
15230 + if (len > ctl->len)
15231 + return -EINVAL;
15232 +
15233 +- return wm_coeff_read_control(ctl, buf, len);
15234 ++ return wm_coeff_read_ctrl(ctl, buf, len);
15235 + }
15236 + EXPORT_SYMBOL_GPL(wm_adsp_read_ctl);
15237 +
15238 +diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c
15239 +index 5873abb46441..749b1c4f1cee 100644
15240 +--- a/sound/soc/intel/boards/bxt_da7219_max98357a.c
15241 ++++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c
15242 +@@ -617,12 +617,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
15243 + snd_soc_dapm_add_routes(&card->dapm, broxton_map,
15244 + ARRAY_SIZE(broxton_map));
15245 +
15246 +- pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
15247 +- head);
15248 +- component = pcm->codec_dai->component;
15249 ++ if (list_empty(&ctx->hdmi_pcm_list))
15250 ++ return -EINVAL;
15251 +
15252 +- if (ctx->common_hdmi_codec_drv)
15253 ++ if (ctx->common_hdmi_codec_drv) {
15254 ++ pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
15255 ++ head);
15256 ++ component = pcm->codec_dai->component;
15257 + return hda_dsp_hdmi_build_controls(card, component);
15258 ++ }
15259 +
15260 + list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
15261 + component = pcm->codec_dai->component;
15262 +@@ -643,9 +646,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
15263 + i++;
15264 + }
15265 +
15266 +- if (!component)
15267 +- return -EINVAL;
15268 +-
15269 + return hdac_hdmi_jack_port_init(component, &card->dapm);
15270 + }
15271 +
15272 +diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c
15273 +index eabf9d8468ae..becfc4fc1aff 100644
15274 +--- a/sound/soc/intel/boards/bxt_rt298.c
15275 ++++ b/sound/soc/intel/boards/bxt_rt298.c
15276 +@@ -529,12 +529,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
15277 + int err, i = 0;
15278 + char jack_name[NAME_SIZE];
15279 +
15280 +- pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
15281 +- head);
15282 +- component = pcm->codec_dai->component;
15283 ++ if (list_empty(&ctx->hdmi_pcm_list))
15284 ++ return -EINVAL;
15285 +
15286 +- if (ctx->common_hdmi_codec_drv)
15287 ++ if (ctx->common_hdmi_codec_drv) {
15288 ++ pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
15289 ++ head);
15290 ++ component = pcm->codec_dai->component;
15291 + return hda_dsp_hdmi_build_controls(card, component);
15292 ++ }
15293 +
15294 + list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
15295 + component = pcm->codec_dai->component;
15296 +@@ -555,9 +558,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
15297 + i++;
15298 + }
15299 +
15300 +- if (!component)
15301 +- return -EINVAL;
15302 +-
15303 + return hdac_hdmi_jack_port_init(component, &card->dapm);
15304 + }
15305 +
15306 +diff --git a/sound/soc/intel/boards/cml_rt1011_rt5682.c b/sound/soc/intel/boards/cml_rt1011_rt5682.c
15307 +index 5f1bf6d3800c..a54636f77c8e 100644
15308 +--- a/sound/soc/intel/boards/cml_rt1011_rt5682.c
15309 ++++ b/sound/soc/intel/boards/cml_rt1011_rt5682.c
15310 +@@ -241,12 +241,15 @@ static int sof_card_late_probe(struct snd_soc_card *card)
15311 + struct hdmi_pcm *pcm;
15312 + int ret, i = 0;
15313 +
15314 +- pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
15315 +- head);
15316 +- component = pcm->codec_dai->component;
15317 ++ if (list_empty(&ctx->hdmi_pcm_list))
15318 ++ return -EINVAL;
15319 +
15320 +- if (ctx->common_hdmi_codec_drv)
15321 ++ if (ctx->common_hdmi_codec_drv) {
15322 ++ pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
15323 ++ head);
15324 ++ component = pcm->codec_dai->component;
15325 + return hda_dsp_hdmi_build_controls(card, component);
15326 ++ }
15327 +
15328 + list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
15329 + component = pcm->codec_dai->component;
15330 +@@ -265,8 +268,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
15331 +
15332 + i++;
15333 + }
15334 +- if (!component)
15335 +- return -EINVAL;
15336 +
15337 + return hdac_hdmi_jack_port_init(component, &card->dapm);
15338 + }
15339 +diff --git a/sound/soc/intel/boards/glk_rt5682_max98357a.c b/sound/soc/intel/boards/glk_rt5682_max98357a.c
15340 +index b36264d1d1cd..94c6bdfab63b 100644
15341 +--- a/sound/soc/intel/boards/glk_rt5682_max98357a.c
15342 ++++ b/sound/soc/intel/boards/glk_rt5682_max98357a.c
15343 +@@ -544,15 +544,18 @@ static int glk_card_late_probe(struct snd_soc_card *card)
15344 + struct snd_soc_component *component = NULL;
15345 + char jack_name[NAME_SIZE];
15346 + struct glk_hdmi_pcm *pcm;
15347 +- int err = 0;
15348 ++ int err;
15349 + int i = 0;
15350 +
15351 +- pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm,
15352 +- head);
15353 +- component = pcm->codec_dai->component;
15354 ++ if (list_empty(&ctx->hdmi_pcm_list))
15355 ++ return -EINVAL;
15356 +
15357 +- if (ctx->common_hdmi_codec_drv)
15358 ++ if (ctx->common_hdmi_codec_drv) {
15359 ++ pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm,
15360 ++ head);
15361 ++ component = pcm->codec_dai->component;
15362 + return hda_dsp_hdmi_build_controls(card, component);
15363 ++ }
15364 +
15365 + list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
15366 + component = pcm->codec_dai->component;
15367 +@@ -573,9 +576,6 @@ static int glk_card_late_probe(struct snd_soc_card *card)
15368 + i++;
15369 + }
15370 +
15371 +- if (!component)
15372 +- return -EINVAL;
15373 +-
15374 + return hdac_hdmi_jack_port_init(component, &card->dapm);
15375 + }
15376 +
15377 +diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c
15378 +index 751b8ea6ae1f..5d878873a8e0 100644
15379 +--- a/sound/soc/intel/boards/sof_rt5682.c
15380 ++++ b/sound/soc/intel/boards/sof_rt5682.c
15381 +@@ -35,6 +35,10 @@
15382 + #define SOF_RT5682_SSP_AMP(quirk) \
15383 + (((quirk) << SOF_RT5682_SSP_AMP_SHIFT) & SOF_RT5682_SSP_AMP_MASK)
15384 + #define SOF_RT5682_MCLK_BYTCHT_EN BIT(9)
15385 ++#define SOF_RT5682_NUM_HDMIDEV_SHIFT 10
15386 ++#define SOF_RT5682_NUM_HDMIDEV_MASK (GENMASK(12, 10))
15387 ++#define SOF_RT5682_NUM_HDMIDEV(quirk) \
15388 ++ ((quirk << SOF_RT5682_NUM_HDMIDEV_SHIFT) & SOF_RT5682_NUM_HDMIDEV_MASK)
15389 +
15390 + /* Default: MCLK on, MCLK 19.2M, SSP0 */
15391 + static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
15392 +@@ -269,19 +273,22 @@ static int sof_card_late_probe(struct snd_soc_card *card)
15393 + struct snd_soc_component *component = NULL;
15394 + char jack_name[NAME_SIZE];
15395 + struct sof_hdmi_pcm *pcm;
15396 +- int err = 0;
15397 ++ int err;
15398 + int i = 0;
15399 +
15400 + /* HDMI is not supported by SOF on Baytrail/CherryTrail */
15401 + if (is_legacy_cpu)
15402 + return 0;
15403 +
15404 +- pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm,
15405 +- head);
15406 +- component = pcm->codec_dai->component;
15407 ++ if (list_empty(&ctx->hdmi_pcm_list))
15408 ++ return -EINVAL;
15409 +
15410 +- if (ctx->common_hdmi_codec_drv)
15411 ++ if (ctx->common_hdmi_codec_drv) {
15412 ++ pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm,
15413 ++ head);
15414 ++ component = pcm->codec_dai->component;
15415 + return hda_dsp_hdmi_build_controls(card, component);
15416 ++ }
15417 +
15418 + list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
15419 + component = pcm->codec_dai->component;
15420 +@@ -301,8 +308,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
15421 +
15422 + i++;
15423 + }
15424 +- if (!component)
15425 +- return -EINVAL;
15426 +
15427 + return hdac_hdmi_jack_port_init(component, &card->dapm);
15428 + }
15429 +@@ -594,6 +599,19 @@ static int sof_audio_probe(struct platform_device *pdev)
15430 + if (!ctx)
15431 + return -ENOMEM;
15432 +
15433 ++ if (pdev->id_entry && pdev->id_entry->driver_data)
15434 ++ sof_rt5682_quirk = (unsigned long)pdev->id_entry->driver_data;
15435 ++
15436 ++ dmi_check_system(sof_rt5682_quirk_table);
15437 ++
15438 ++ mach = (&pdev->dev)->platform_data;
15439 ++
15440 ++ /* A speaker amp might not be present when the quirk claims one is.
15441 ++ * Detect this via whether the machine driver match includes quirk_data.
15442 ++ */
15443 ++ if ((sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT) && !mach->quirk_data)
15444 ++ sof_rt5682_quirk &= ~SOF_SPEAKER_AMP_PRESENT;
15445 ++
15446 + if (soc_intel_is_byt() || soc_intel_is_cht()) {
15447 + is_legacy_cpu = 1;
15448 + dmic_be_num = 0;
15449 +@@ -604,11 +622,13 @@ static int sof_audio_probe(struct platform_device *pdev)
15450 + SOF_RT5682_SSP_CODEC(2);
15451 + } else {
15452 + dmic_be_num = 2;
15453 +- hdmi_num = 3;
15454 ++ hdmi_num = (sof_rt5682_quirk & SOF_RT5682_NUM_HDMIDEV_MASK) >>
15455 ++ SOF_RT5682_NUM_HDMIDEV_SHIFT;
15456 ++ /* default number of HDMI DAI's */
15457 ++ if (!hdmi_num)
15458 ++ hdmi_num = 3;
15459 + }
15460 +
15461 +- dmi_check_system(sof_rt5682_quirk_table);
15462 +-
15463 + /* need to get main clock from pmc */
15464 + if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) {
15465 + ctx->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
15466 +@@ -652,7 +672,6 @@ static int sof_audio_probe(struct platform_device *pdev)
15467 + INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
15468 +
15469 + sof_audio_card_rt5682.dev = &pdev->dev;
15470 +- mach = (&pdev->dev)->platform_data;
15471 +
15472 + /* set platform name for each dailink */
15473 + ret = snd_soc_fixup_dai_links_platform_name(&sof_audio_card_rt5682,
15474 +@@ -683,6 +702,21 @@ static int sof_rt5682_remove(struct platform_device *pdev)
15475 + return 0;
15476 + }
15477 +
15478 ++static const struct platform_device_id board_ids[] = {
15479 ++ {
15480 ++ .name = "sof_rt5682",
15481 ++ },
15482 ++ {
15483 ++ .name = "tgl_max98357a_rt5682",
15484 ++ .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
15485 ++ SOF_RT5682_SSP_CODEC(0) |
15486 ++ SOF_SPEAKER_AMP_PRESENT |
15487 ++ SOF_RT5682_SSP_AMP(1) |
15488 ++ SOF_RT5682_NUM_HDMIDEV(4)),
15489 ++ },
15490 ++ { }
15491 ++};
15492 ++
15493 + static struct platform_driver sof_audio = {
15494 + .probe = sof_audio_probe,
15495 + .remove = sof_rt5682_remove,
15496 +@@ -690,6 +724,7 @@ static struct platform_driver sof_audio = {
15497 + .name = "sof_rt5682",
15498 + .pm = &snd_soc_pm_ops,
15499 + },
15500 ++ .id_table = board_ids,
15501 + };
15502 + module_platform_driver(sof_audio)
15503 +
15504 +@@ -699,3 +734,4 @@ MODULE_AUTHOR("Bard Liao <bard.liao@×××××.com>");
15505 + MODULE_AUTHOR("Sathya Prakash M R <sathya.prakash.m.r@×××××.com>");
15506 + MODULE_LICENSE("GPL v2");
15507 + MODULE_ALIAS("platform:sof_rt5682");
15508 ++MODULE_ALIAS("platform:tgl_max98357a_rt5682");
15509 +diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
15510 +index 4e1fe623c390..0119f07cece6 100644
15511 +--- a/sound/soc/soc-topology.c
15512 ++++ b/sound/soc/soc-topology.c
15513 +@@ -604,9 +604,11 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr,
15514 + ext_ops = tplg->bytes_ext_ops;
15515 + num_ops = tplg->bytes_ext_ops_count;
15516 + for (i = 0; i < num_ops; i++) {
15517 +- if (!sbe->put && ext_ops[i].id == be->ext_ops.put)
15518 ++ if (!sbe->put &&
15519 ++ ext_ops[i].id == le32_to_cpu(be->ext_ops.put))
15520 + sbe->put = ext_ops[i].put;
15521 +- if (!sbe->get && ext_ops[i].id == be->ext_ops.get)
15522 ++ if (!sbe->get &&
15523 ++ ext_ops[i].id == le32_to_cpu(be->ext_ops.get))
15524 + sbe->get = ext_ops[i].get;
15525 + }
15526 +
15527 +@@ -621,11 +623,11 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr,
15528 + num_ops = tplg->io_ops_count;
15529 + for (i = 0; i < num_ops; i++) {
15530 +
15531 +- if (k->put == NULL && ops[i].id == hdr->ops.put)
15532 ++ if (k->put == NULL && ops[i].id == le32_to_cpu(hdr->ops.put))
15533 + k->put = ops[i].put;
15534 +- if (k->get == NULL && ops[i].id == hdr->ops.get)
15535 ++ if (k->get == NULL && ops[i].id == le32_to_cpu(hdr->ops.get))
15536 + k->get = ops[i].get;
15537 +- if (k->info == NULL && ops[i].id == hdr->ops.info)
15538 ++ if (k->info == NULL && ops[i].id == le32_to_cpu(hdr->ops.info))
15539 + k->info = ops[i].info;
15540 + }
15541 +
15542 +@@ -638,11 +640,11 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr,
15543 + num_ops = ARRAY_SIZE(io_ops);
15544 + for (i = 0; i < num_ops; i++) {
15545 +
15546 +- if (k->put == NULL && ops[i].id == hdr->ops.put)
15547 ++ if (k->put == NULL && ops[i].id == le32_to_cpu(hdr->ops.put))
15548 + k->put = ops[i].put;
15549 +- if (k->get == NULL && ops[i].id == hdr->ops.get)
15550 ++ if (k->get == NULL && ops[i].id == le32_to_cpu(hdr->ops.get))
15551 + k->get = ops[i].get;
15552 +- if (k->info == NULL && ops[i].id == hdr->ops.info)
15553 ++ if (k->info == NULL && ops[i].id == le32_to_cpu(hdr->ops.info))
15554 + k->info = ops[i].info;
15555 + }
15556 +
15557 +@@ -931,7 +933,7 @@ static int soc_tplg_denum_create_texts(struct soc_enum *se,
15558 + if (se->dobj.control.dtexts == NULL)
15559 + return -ENOMEM;
15560 +
15561 +- for (i = 0; i < ec->items; i++) {
15562 ++ for (i = 0; i < le32_to_cpu(ec->items); i++) {
15563 +
15564 + if (strnlen(ec->texts[i], SNDRV_CTL_ELEM_ID_NAME_MAXLEN) ==
15565 + SNDRV_CTL_ELEM_ID_NAME_MAXLEN) {
15566 +@@ -1325,7 +1327,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create(
15567 + if (kc[i].name == NULL)
15568 + goto err_sm;
15569 + kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
15570 +- kc[i].access = mc->hdr.access;
15571 ++ kc[i].access = le32_to_cpu(mc->hdr.access);
15572 +
15573 + /* we only support FL/FR channel mapping atm */
15574 + sm->reg = tplc_chan_get_reg(tplg, mc->channel,
15575 +@@ -1337,10 +1339,10 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create(
15576 + sm->rshift = tplc_chan_get_shift(tplg, mc->channel,
15577 + SNDRV_CHMAP_FR);
15578 +
15579 +- sm->max = mc->max;
15580 +- sm->min = mc->min;
15581 +- sm->invert = mc->invert;
15582 +- sm->platform_max = mc->platform_max;
15583 ++ sm->max = le32_to_cpu(mc->max);
15584 ++ sm->min = le32_to_cpu(mc->min);
15585 ++ sm->invert = le32_to_cpu(mc->invert);
15586 ++ sm->platform_max = le32_to_cpu(mc->platform_max);
15587 + sm->dobj.index = tplg->index;
15588 + INIT_LIST_HEAD(&sm->dobj.list);
15589 +
15590 +@@ -1401,7 +1403,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
15591 + goto err_se;
15592 +
15593 + tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) +
15594 +- ec->priv.size);
15595 ++ le32_to_cpu(ec->priv.size));
15596 +
15597 + dev_dbg(tplg->dev, " adding DAPM widget enum control %s\n",
15598 + ec->hdr.name);
15599 +@@ -1411,7 +1413,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
15600 + if (kc[i].name == NULL)
15601 + goto err_se;
15602 + kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
15603 +- kc[i].access = ec->hdr.access;
15604 ++ kc[i].access = le32_to_cpu(ec->hdr.access);
15605 +
15606 + /* we only support FL/FR channel mapping atm */
15607 + se->reg = tplc_chan_get_reg(tplg, ec->channel, SNDRV_CHMAP_FL);
15608 +@@ -1420,8 +1422,8 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
15609 + se->shift_r = tplc_chan_get_shift(tplg, ec->channel,
15610 + SNDRV_CHMAP_FR);
15611 +
15612 +- se->items = ec->items;
15613 +- se->mask = ec->mask;
15614 ++ se->items = le32_to_cpu(ec->items);
15615 ++ se->mask = le32_to_cpu(ec->mask);
15616 + se->dobj.index = tplg->index;
15617 +
15618 + switch (le32_to_cpu(ec->hdr.ops.info)) {
15619 +@@ -1523,9 +1525,9 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dbytes_create(
15620 + if (kc[i].name == NULL)
15621 + goto err_sbe;
15622 + kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
15623 +- kc[i].access = be->hdr.access;
15624 ++ kc[i].access = le32_to_cpu(be->hdr.access);
15625 +
15626 +- sbe->max = be->max;
15627 ++ sbe->max = le32_to_cpu(be->max);
15628 + INIT_LIST_HEAD(&sbe->dobj.list);
15629 +
15630 + /* map standard io handlers and check for external handlers */
15631 +diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c
15632 +index 7daa8eb456c8..6f45e14f2b2e 100644
15633 +--- a/sound/soc/sof/intel/apl.c
15634 ++++ b/sound/soc/sof/intel/apl.c
15635 +@@ -41,7 +41,6 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
15636 + .block_write = sof_block_write,
15637 +
15638 + /* doorbell */
15639 +- .irq_handler = hda_dsp_ipc_irq_handler,
15640 + .irq_thread = hda_dsp_ipc_irq_thread,
15641 +
15642 + /* ipc */
15643 +diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c
15644 +index 0e1e265f3f3b..9bd169e2691e 100644
15645 +--- a/sound/soc/sof/intel/cnl.c
15646 ++++ b/sound/soc/sof/intel/cnl.c
15647 +@@ -106,10 +106,6 @@ static irqreturn_t cnl_ipc_irq_thread(int irq, void *context)
15648 + "nothing to do in IPC IRQ thread\n");
15649 + }
15650 +
15651 +- /* re-enable IPC interrupt */
15652 +- snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC,
15653 +- HDA_DSP_ADSPIC_IPC, HDA_DSP_ADSPIC_IPC);
15654 +-
15655 + return IRQ_HANDLED;
15656 + }
15657 +
15658 +@@ -231,7 +227,6 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
15659 + .block_write = sof_block_write,
15660 +
15661 + /* doorbell */
15662 +- .irq_handler = hda_dsp_ipc_irq_handler,
15663 + .irq_thread = cnl_ipc_irq_thread,
15664 +
15665 + /* ipc */
15666 +diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c
15667 +index 896d21984b73..1923b0c36bce 100644
15668 +--- a/sound/soc/sof/intel/hda-dai.c
15669 ++++ b/sound/soc/sof/intel/hda-dai.c
15670 +@@ -261,14 +261,11 @@ static int hda_link_pcm_prepare(struct snd_pcm_substream *substream,
15671 + {
15672 + struct hdac_ext_stream *link_dev =
15673 + snd_soc_dai_get_dma_data(dai, substream);
15674 +- struct sof_intel_hda_stream *hda_stream;
15675 + struct snd_sof_dev *sdev =
15676 + snd_soc_component_get_drvdata(dai->component);
15677 + struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
15678 + int stream = substream->stream;
15679 +
15680 +- hda_stream = hstream_to_sof_hda_stream(link_dev);
15681 +-
15682 + if (link_dev->link_prepared)
15683 + return 0;
15684 +
15685 +diff --git a/sound/soc/sof/intel/hda-ipc.c b/sound/soc/sof/intel/hda-ipc.c
15686 +index 0fd2153c1769..1837f66e361f 100644
15687 +--- a/sound/soc/sof/intel/hda-ipc.c
15688 ++++ b/sound/soc/sof/intel/hda-ipc.c
15689 +@@ -230,22 +230,15 @@ irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context)
15690 + "nothing to do in IPC IRQ thread\n");
15691 + }
15692 +
15693 +- /* re-enable IPC interrupt */
15694 +- snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC,
15695 +- HDA_DSP_ADSPIC_IPC, HDA_DSP_ADSPIC_IPC);
15696 +-
15697 + return IRQ_HANDLED;
15698 + }
15699 +
15700 +-/* is this IRQ for ADSP ? - we only care about IPC here */
15701 +-irqreturn_t hda_dsp_ipc_irq_handler(int irq, void *context)
15702 ++/* Check if an IPC IRQ occurred */
15703 ++bool hda_dsp_check_ipc_irq(struct snd_sof_dev *sdev)
15704 + {
15705 +- struct snd_sof_dev *sdev = context;
15706 +- int ret = IRQ_NONE;
15707 ++ bool ret = false;
15708 + u32 irq_status;
15709 +
15710 +- spin_lock(&sdev->hw_lock);
15711 +-
15712 + /* store status */
15713 + irq_status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIS);
15714 + dev_vdbg(sdev->dev, "irq handler: irq_status:0x%x\n", irq_status);
15715 +@@ -255,16 +248,10 @@ irqreturn_t hda_dsp_ipc_irq_handler(int irq, void *context)
15716 + goto out;
15717 +
15718 + /* IPC message ? */
15719 +- if (irq_status & HDA_DSP_ADSPIS_IPC) {
15720 +- /* disable IPC interrupt */
15721 +- snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR,
15722 +- HDA_DSP_REG_ADSPIC,
15723 +- HDA_DSP_ADSPIC_IPC, 0);
15724 +- ret = IRQ_WAKE_THREAD;
15725 +- }
15726 ++ if (irq_status & HDA_DSP_ADSPIS_IPC)
15727 ++ ret = true;
15728 +
15729 + out:
15730 +- spin_unlock(&sdev->hw_lock);
15731 + return ret;
15732 + }
15733 +
15734 +diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c
15735 +index 29ab43281670..927a36f92c24 100644
15736 +--- a/sound/soc/sof/intel/hda-stream.c
15737 ++++ b/sound/soc/sof/intel/hda-stream.c
15738 +@@ -549,22 +549,23 @@ int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
15739 + return 0;
15740 + }
15741 +
15742 +-irqreturn_t hda_dsp_stream_interrupt(int irq, void *context)
15743 ++bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev)
15744 + {
15745 +- struct hdac_bus *bus = context;
15746 +- int ret = IRQ_WAKE_THREAD;
15747 ++ struct hdac_bus *bus = sof_to_bus(sdev);
15748 ++ bool ret = false;
15749 + u32 status;
15750 +
15751 +- spin_lock(&bus->reg_lock);
15752 ++ /* The function can be called at irq thread, so use spin_lock_irq */
15753 ++ spin_lock_irq(&bus->reg_lock);
15754 +
15755 + status = snd_hdac_chip_readl(bus, INTSTS);
15756 + dev_vdbg(bus->dev, "stream irq, INTSTS status: 0x%x\n", status);
15757 +
15758 +- /* Register inaccessible, ignore it.*/
15759 +- if (status == 0xffffffff)
15760 +- ret = IRQ_NONE;
15761 ++ /* if Register inaccessible, ignore it.*/
15762 ++ if (status != 0xffffffff)
15763 ++ ret = true;
15764 +
15765 +- spin_unlock(&bus->reg_lock);
15766 ++ spin_unlock_irq(&bus->reg_lock);
15767 +
15768 + return ret;
15769 + }
15770 +@@ -602,7 +603,8 @@ static bool hda_dsp_stream_check(struct hdac_bus *bus, u32 status)
15771 +
15772 + irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context)
15773 + {
15774 +- struct hdac_bus *bus = context;
15775 ++ struct snd_sof_dev *sdev = context;
15776 ++ struct hdac_bus *bus = sof_to_bus(sdev);
15777 + #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
15778 + u32 rirb_status;
15779 + #endif
15780 +diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
15781 +index fb17b87b684b..82ecadda886c 100644
15782 +--- a/sound/soc/sof/intel/hda.c
15783 ++++ b/sound/soc/sof/intel/hda.c
15784 +@@ -499,6 +499,49 @@ static const struct sof_intel_dsp_desc
15785 + return chip_info;
15786 + }
15787 +
15788 ++static irqreturn_t hda_dsp_interrupt_handler(int irq, void *context)
15789 ++{
15790 ++ struct snd_sof_dev *sdev = context;
15791 ++
15792 ++ /*
15793 ++ * Get global interrupt status. It includes all hardware interrupt
15794 ++ * sources in the Intel HD Audio controller.
15795 ++ */
15796 ++ if (snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS) &
15797 ++ SOF_HDA_INTSTS_GIS) {
15798 ++
15799 ++ /* disable GIE interrupt */
15800 ++ snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
15801 ++ SOF_HDA_INTCTL,
15802 ++ SOF_HDA_INT_GLOBAL_EN,
15803 ++ 0);
15804 ++
15805 ++ return IRQ_WAKE_THREAD;
15806 ++ }
15807 ++
15808 ++ return IRQ_NONE;
15809 ++}
15810 ++
15811 ++static irqreturn_t hda_dsp_interrupt_thread(int irq, void *context)
15812 ++{
15813 ++ struct snd_sof_dev *sdev = context;
15814 ++
15815 ++ /* deal with streams and controller first */
15816 ++ if (hda_dsp_check_stream_irq(sdev))
15817 ++ hda_dsp_stream_threaded_handler(irq, sdev);
15818 ++
15819 ++ if (hda_dsp_check_ipc_irq(sdev))
15820 ++ sof_ops(sdev)->irq_thread(irq, sdev);
15821 ++
15822 ++ /* enable GIE interrupt */
15823 ++ snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
15824 ++ SOF_HDA_INTCTL,
15825 ++ SOF_HDA_INT_GLOBAL_EN,
15826 ++ SOF_HDA_INT_GLOBAL_EN);
15827 ++
15828 ++ return IRQ_HANDLED;
15829 ++}
15830 ++
15831 + int hda_dsp_probe(struct snd_sof_dev *sdev)
15832 + {
15833 + struct pci_dev *pci = to_pci_dev(sdev->dev);
15834 +@@ -603,9 +646,7 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
15835 + */
15836 + if (hda_use_msi && pci_alloc_irq_vectors(pci, 1, 1, PCI_IRQ_MSI) > 0) {
15837 + dev_info(sdev->dev, "use msi interrupt mode\n");
15838 +- hdev->irq = pci_irq_vector(pci, 0);
15839 +- /* ipc irq number is the same of hda irq */
15840 +- sdev->ipc_irq = hdev->irq;
15841 ++ sdev->ipc_irq = pci_irq_vector(pci, 0);
15842 + /* initialised to "false" by kzalloc() */
15843 + sdev->msi_enabled = true;
15844 + }
15845 +@@ -616,28 +657,17 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
15846 + * in IO-APIC mode, hda->irq and ipc_irq are using the same
15847 + * irq number of pci->irq
15848 + */
15849 +- hdev->irq = pci->irq;
15850 + sdev->ipc_irq = pci->irq;
15851 + }
15852 +
15853 +- dev_dbg(sdev->dev, "using HDA IRQ %d\n", hdev->irq);
15854 +- ret = request_threaded_irq(hdev->irq, hda_dsp_stream_interrupt,
15855 +- hda_dsp_stream_threaded_handler,
15856 +- IRQF_SHARED, "AudioHDA", bus);
15857 +- if (ret < 0) {
15858 +- dev_err(sdev->dev, "error: failed to register HDA IRQ %d\n",
15859 +- hdev->irq);
15860 +- goto free_irq_vector;
15861 +- }
15862 +-
15863 + dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq);
15864 +- ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_ipc_irq_handler,
15865 +- sof_ops(sdev)->irq_thread, IRQF_SHARED,
15866 +- "AudioDSP", sdev);
15867 ++ ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler,
15868 ++ hda_dsp_interrupt_thread,
15869 ++ IRQF_SHARED, "AudioDSP", sdev);
15870 + if (ret < 0) {
15871 + dev_err(sdev->dev, "error: failed to register IPC IRQ %d\n",
15872 + sdev->ipc_irq);
15873 +- goto free_hda_irq;
15874 ++ goto free_irq_vector;
15875 + }
15876 +
15877 + pci_set_master(pci);
15878 +@@ -668,8 +698,6 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
15879 +
15880 + free_ipc_irq:
15881 + free_irq(sdev->ipc_irq, sdev);
15882 +-free_hda_irq:
15883 +- free_irq(hdev->irq, bus);
15884 + free_irq_vector:
15885 + if (sdev->msi_enabled)
15886 + pci_free_irq_vectors(pci);
15887 +@@ -715,7 +743,6 @@ int hda_dsp_remove(struct snd_sof_dev *sdev)
15888 + SOF_HDA_PPCTL_GPROCEN, 0);
15889 +
15890 + free_irq(sdev->ipc_irq, sdev);
15891 +- free_irq(hda->irq, bus);
15892 + if (sdev->msi_enabled)
15893 + pci_free_irq_vectors(pci);
15894 +
15895 +diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h
15896 +index 18d7e72bf9b7..de0115294c74 100644
15897 +--- a/sound/soc/sof/intel/hda.h
15898 ++++ b/sound/soc/sof/intel/hda.h
15899 +@@ -43,11 +43,14 @@
15900 + /* SOF_HDA_GCTL register bist */
15901 + #define SOF_HDA_GCTL_RESET BIT(0)
15902 +
15903 +-/* SOF_HDA_INCTL and SOF_HDA_INTSTS regs */
15904 ++/* SOF_HDA_INCTL regs */
15905 + #define SOF_HDA_INT_GLOBAL_EN BIT(31)
15906 + #define SOF_HDA_INT_CTRL_EN BIT(30)
15907 + #define SOF_HDA_INT_ALL_STREAM 0xff
15908 +
15909 ++/* SOF_HDA_INTSTS regs */
15910 ++#define SOF_HDA_INTSTS_GIS BIT(31)
15911 ++
15912 + #define SOF_HDA_MAX_CAPS 10
15913 + #define SOF_HDA_CAP_ID_OFF 16
15914 + #define SOF_HDA_CAP_ID_MASK GENMASK(SOF_HDA_CAP_ID_OFF + 11,\
15915 +@@ -345,7 +348,7 @@
15916 +
15917 + /* Number of DAIs */
15918 + #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
15919 +-#define SOF_SKL_NUM_DAIS 14
15920 ++#define SOF_SKL_NUM_DAIS 15
15921 + #else
15922 + #define SOF_SKL_NUM_DAIS 8
15923 + #endif
15924 +@@ -406,8 +409,6 @@ struct sof_intel_hda_dev {
15925 + /* the maximum number of streams (playback + capture) supported */
15926 + u32 stream_max;
15927 +
15928 +- int irq;
15929 +-
15930 + /* PM related */
15931 + bool l1_support_changed;/* during suspend, is L1SEN changed or not */
15932 +
15933 +@@ -511,11 +512,12 @@ int hda_dsp_stream_hw_params(struct snd_sof_dev *sdev,
15934 + struct snd_pcm_hw_params *params);
15935 + int hda_dsp_stream_trigger(struct snd_sof_dev *sdev,
15936 + struct hdac_ext_stream *stream, int cmd);
15937 +-irqreturn_t hda_dsp_stream_interrupt(int irq, void *context);
15938 + irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context);
15939 + int hda_dsp_stream_setup_bdl(struct snd_sof_dev *sdev,
15940 + struct snd_dma_buffer *dmab,
15941 + struct hdac_stream *stream);
15942 ++bool hda_dsp_check_ipc_irq(struct snd_sof_dev *sdev);
15943 ++bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev);
15944 +
15945 + struct hdac_ext_stream *
15946 + hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction);
15947 +@@ -540,7 +542,6 @@ void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev);
15948 + int hda_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev);
15949 + int hda_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id);
15950 +
15951 +-irqreturn_t hda_dsp_ipc_irq_handler(int irq, void *context);
15952 + irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context);
15953 + int hda_dsp_ipc_cmd_done(struct snd_sof_dev *sdev, int dir);
15954 +
15955 +diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c
15956 +index 33c78d33e5a1..9a55926ebf07 100644
15957 +--- a/sound/soc/txx9/txx9aclc.c
15958 ++++ b/sound/soc/txx9/txx9aclc.c
15959 +@@ -51,7 +51,6 @@ static int txx9aclc_pcm_hw_params(struct snd_soc_component *component,
15960 + struct snd_pcm_substream *substream,
15961 + struct snd_pcm_hw_params *params)
15962 + {
15963 +- struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
15964 + struct snd_pcm_runtime *runtime = substream->runtime;
15965 + struct txx9aclc_dmadata *dmadata = runtime->private_data;
15966 + int ret;
15967 +diff --git a/sound/usb/card.c b/sound/usb/card.c
15968 +index 9f743ebae615..827fb0bc8b56 100644
15969 +--- a/sound/usb/card.c
15970 ++++ b/sound/usb/card.c
15971 +@@ -600,6 +600,10 @@ static int usb_audio_probe(struct usb_interface *intf,
15972 + }
15973 + }
15974 + if (! chip) {
15975 ++ err = snd_usb_apply_boot_quirk_once(dev, intf, quirk, id);
15976 ++ if (err < 0)
15977 ++ goto __error;
15978 ++
15979 + /* it's a fresh one.
15980 + * now look for an empty slot and create a new card instance
15981 + */
15982 +diff --git a/sound/usb/format.c b/sound/usb/format.c
15983 +index 25668ba5e68e..f4f0cf3deaf0 100644
15984 +--- a/sound/usb/format.c
15985 ++++ b/sound/usb/format.c
15986 +@@ -296,6 +296,9 @@ static int line6_parse_audio_format_rates_quirk(struct snd_usb_audio *chip,
15987 + case USB_ID(0x0E41, 0x4242): /* Line6 Helix Rack */
15988 + case USB_ID(0x0E41, 0x4244): /* Line6 Helix LT */
15989 + case USB_ID(0x0E41, 0x4246): /* Line6 HX-Stomp */
15990 ++ case USB_ID(0x0E41, 0x4248): /* Line6 Helix >= fw 2.82 */
15991 ++ case USB_ID(0x0E41, 0x4249): /* Line6 Helix Rack >= fw 2.82 */
15992 ++ case USB_ID(0x0E41, 0x424a): /* Line6 Helix LT >= fw 2.82 */
15993 + /* supported rates: 48Khz */
15994 + kfree(fp->rate_table);
15995 + fp->rate_table = kmalloc(sizeof(int), GFP_KERNEL);
15996 +diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
15997 +index 0e4eab96e23e..c9e1609296df 100644
15998 +--- a/sound/usb/pcm.c
15999 ++++ b/sound/usb/pcm.c
16000 +@@ -348,6 +348,10 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
16001 + ep = 0x84;
16002 + ifnum = 0;
16003 + goto add_sync_ep_from_ifnum;
16004 ++ case USB_ID(0x07fd, 0x0008): /* MOTU M Series */
16005 ++ ep = 0x81;
16006 ++ ifnum = 2;
16007 ++ goto add_sync_ep_from_ifnum;
16008 + case USB_ID(0x0582, 0x01d8): /* BOSS Katana */
16009 + /* BOSS Katana amplifiers do not need quirks */
16010 + return 0;
16011 +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
16012 +index 1ed25b1d2a6a..7448ab07bd36 100644
16013 +--- a/sound/usb/quirks.c
16014 ++++ b/sound/usb/quirks.c
16015 +@@ -1113,6 +1113,31 @@ free_buf:
16016 + return err;
16017 + }
16018 +
16019 ++static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev)
16020 ++{
16021 ++ int ret;
16022 ++
16023 ++ if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0)))
16024 ++ return -EINVAL;
16025 ++ ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
16026 ++ 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE,
16027 ++ 0x0, 0, NULL, 0, 1000);
16028 ++
16029 ++ if (ret < 0)
16030 ++ return ret;
16031 ++
16032 ++ msleep(2000);
16033 ++
16034 ++ ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
16035 ++ 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE,
16036 ++ 0x20, 0, NULL, 0, 1000);
16037 ++
16038 ++ if (ret < 0)
16039 ++ return ret;
16040 ++
16041 ++ return 0;
16042 ++}
16043 ++
16044 + /*
16045 + * Setup quirks
16046 + */
16047 +@@ -1297,6 +1322,19 @@ int snd_usb_apply_boot_quirk(struct usb_device *dev,
16048 + return 0;
16049 + }
16050 +
16051 ++int snd_usb_apply_boot_quirk_once(struct usb_device *dev,
16052 ++ struct usb_interface *intf,
16053 ++ const struct snd_usb_audio_quirk *quirk,
16054 ++ unsigned int id)
16055 ++{
16056 ++ switch (id) {
16057 ++ case USB_ID(0x07fd, 0x0008): /* MOTU M Series */
16058 ++ return snd_usb_motu_m_series_boot_quirk(dev);
16059 ++ }
16060 ++
16061 ++ return 0;
16062 ++}
16063 ++
16064 + /*
16065 + * check if the device uses big-endian samples
16066 + */
16067 +diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h
16068 +index a80e0ddd0736..df0355843a4c 100644
16069 +--- a/sound/usb/quirks.h
16070 ++++ b/sound/usb/quirks.h
16071 +@@ -20,6 +20,11 @@ int snd_usb_apply_boot_quirk(struct usb_device *dev,
16072 + const struct snd_usb_audio_quirk *quirk,
16073 + unsigned int usb_id);
16074 +
16075 ++int snd_usb_apply_boot_quirk_once(struct usb_device *dev,
16076 ++ struct usb_interface *intf,
16077 ++ const struct snd_usb_audio_quirk *quirk,
16078 ++ unsigned int usb_id);
16079 ++
16080 + void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
16081 + struct audioformat *fmt);
16082 +
16083 +diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c
16084 +index d1caa8ed9e68..9985fc139487 100644
16085 +--- a/sound/usb/usx2y/usX2Yhwdep.c
16086 ++++ b/sound/usb/usx2y/usX2Yhwdep.c
16087 +@@ -119,7 +119,7 @@ static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw,
16088 + info->num_dsps = 2; // 0: Prepad Data, 1: FPGA Code
16089 + if (us428->chip_status & USX2Y_STAT_CHIP_INIT)
16090 + info->chip_ready = 1;
16091 +- info->version = USX2Y_DRIVER_VERSION;
16092 ++ info->version = USX2Y_DRIVER_VERSION;
16093 + return 0;
16094 + }
16095 +
16096 +diff --git a/tools/arch/x86/lib/x86-opcode-map.txt b/tools/arch/x86/lib/x86-opcode-map.txt
16097 +index 8908c58bd6cd..53adc1762ec0 100644
16098 +--- a/tools/arch/x86/lib/x86-opcode-map.txt
16099 ++++ b/tools/arch/x86/lib/x86-opcode-map.txt
16100 +@@ -929,7 +929,7 @@ EndTable
16101 +
16102 + GrpTable: Grp3_2
16103 + 0: TEST Ev,Iz
16104 +-1:
16105 ++1: TEST Ev,Iz
16106 + 2: NOT Ev
16107 + 3: NEG Ev
16108 + 4: MUL rAX,Ev
16109 +diff --git a/tools/bpf/bpftool/cgroup.c b/tools/bpf/bpftool/cgroup.c
16110 +index 1ef45e55039e..2f017caa678d 100644
16111 +--- a/tools/bpf/bpftool/cgroup.c
16112 ++++ b/tools/bpf/bpftool/cgroup.c
16113 +@@ -117,6 +117,25 @@ static int count_attached_bpf_progs(int cgroup_fd, enum bpf_attach_type type)
16114 + return prog_cnt;
16115 + }
16116 +
16117 ++static int cgroup_has_attached_progs(int cgroup_fd)
16118 ++{
16119 ++ enum bpf_attach_type type;
16120 ++ bool no_prog = true;
16121 ++
16122 ++ for (type = 0; type < __MAX_BPF_ATTACH_TYPE; type++) {
16123 ++ int count = count_attached_bpf_progs(cgroup_fd, type);
16124 ++
16125 ++ if (count < 0 && errno != EINVAL)
16126 ++ return -1;
16127 ++
16128 ++ if (count > 0) {
16129 ++ no_prog = false;
16130 ++ break;
16131 ++ }
16132 ++ }
16133 ++
16134 ++ return no_prog ? 0 : 1;
16135 ++}
16136 + static int show_attached_bpf_progs(int cgroup_fd, enum bpf_attach_type type,
16137 + int level)
16138 + {
16139 +@@ -161,6 +180,7 @@ static int show_attached_bpf_progs(int cgroup_fd, enum bpf_attach_type type,
16140 + static int do_show(int argc, char **argv)
16141 + {
16142 + enum bpf_attach_type type;
16143 ++ int has_attached_progs;
16144 + const char *path;
16145 + int cgroup_fd;
16146 + int ret = -1;
16147 +@@ -192,6 +212,16 @@ static int do_show(int argc, char **argv)
16148 + goto exit;
16149 + }
16150 +
16151 ++ has_attached_progs = cgroup_has_attached_progs(cgroup_fd);
16152 ++ if (has_attached_progs < 0) {
16153 ++ p_err("can't query bpf programs attached to %s: %s",
16154 ++ path, strerror(errno));
16155 ++ goto exit_cgroup;
16156 ++ } else if (!has_attached_progs) {
16157 ++ ret = 0;
16158 ++ goto exit_cgroup;
16159 ++ }
16160 ++
16161 + if (json_output)
16162 + jsonw_start_array(json_wtr);
16163 + else
16164 +@@ -212,6 +242,7 @@ static int do_show(int argc, char **argv)
16165 + if (json_output)
16166 + jsonw_end_array(json_wtr);
16167 +
16168 ++exit_cgroup:
16169 + close(cgroup_fd);
16170 + exit:
16171 + return ret;
16172 +@@ -228,7 +259,7 @@ static int do_show_tree_fn(const char *fpath, const struct stat *sb,
16173 + int typeflag, struct FTW *ftw)
16174 + {
16175 + enum bpf_attach_type type;
16176 +- bool skip = true;
16177 ++ int has_attached_progs;
16178 + int cgroup_fd;
16179 +
16180 + if (typeflag != FTW_D)
16181 +@@ -240,22 +271,13 @@ static int do_show_tree_fn(const char *fpath, const struct stat *sb,
16182 + return SHOW_TREE_FN_ERR;
16183 + }
16184 +
16185 +- for (type = 0; type < __MAX_BPF_ATTACH_TYPE; type++) {
16186 +- int count = count_attached_bpf_progs(cgroup_fd, type);
16187 +-
16188 +- if (count < 0 && errno != EINVAL) {
16189 +- p_err("can't query bpf programs attached to %s: %s",
16190 +- fpath, strerror(errno));
16191 +- close(cgroup_fd);
16192 +- return SHOW_TREE_FN_ERR;
16193 +- }
16194 +- if (count > 0) {
16195 +- skip = false;
16196 +- break;
16197 +- }
16198 +- }
16199 +-
16200 +- if (skip) {
16201 ++ has_attached_progs = cgroup_has_attached_progs(cgroup_fd);
16202 ++ if (has_attached_progs < 0) {
16203 ++ p_err("can't query bpf programs attached to %s: %s",
16204 ++ fpath, strerror(errno));
16205 ++ close(cgroup_fd);
16206 ++ return SHOW_TREE_FN_ERR;
16207 ++ } else if (!has_attached_progs) {
16208 + close(cgroup_fd);
16209 + return 0;
16210 + }
16211 +diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
16212 +index 11b3885e833e..027b18f7ed8c 100644
16213 +--- a/tools/lib/api/fs/fs.c
16214 ++++ b/tools/lib/api/fs/fs.c
16215 +@@ -210,6 +210,7 @@ static bool fs__env_override(struct fs *fs)
16216 + size_t name_len = strlen(fs->name);
16217 + /* name + "_PATH" + '\0' */
16218 + char upper_name[name_len + 5 + 1];
16219 ++
16220 + memcpy(upper_name, fs->name, name_len);
16221 + mem_toupper(upper_name, name_len);
16222 + strcpy(&upper_name[name_len], "_PATH");
16223 +@@ -219,7 +220,8 @@ static bool fs__env_override(struct fs *fs)
16224 + return false;
16225 +
16226 + fs->found = true;
16227 +- strncpy(fs->path, override_path, sizeof(fs->path));
16228 ++ strncpy(fs->path, override_path, sizeof(fs->path) - 1);
16229 ++ fs->path[sizeof(fs->path) - 1] = '\0';
16230 + return true;
16231 + }
16232 +
16233 +diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
16234 +index d2a19b0bc05a..ee08aeff30a1 100644
16235 +--- a/tools/objtool/Makefile
16236 ++++ b/tools/objtool/Makefile
16237 +@@ -2,10 +2,6 @@
16238 + include ../scripts/Makefile.include
16239 + include ../scripts/Makefile.arch
16240 +
16241 +-ifeq ($(ARCH),x86_64)
16242 +-ARCH := x86
16243 +-endif
16244 +-
16245 + # always use the host compiler
16246 + HOSTAR ?= ar
16247 + HOSTCC ?= gcc
16248 +@@ -33,7 +29,7 @@ all: $(OBJTOOL)
16249 +
16250 + INCLUDES := -I$(srctree)/tools/include \
16251 + -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
16252 +- -I$(srctree)/tools/arch/$(ARCH)/include
16253 ++ -I$(srctree)/tools/arch/$(SRCARCH)/include
16254 + WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
16255 + CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS)
16256 + LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
16257 +diff --git a/tools/testing/selftests/bpf/test_select_reuseport.c b/tools/testing/selftests/bpf/test_select_reuseport.c
16258 +index 7566c13eb51a..079d0f5a2909 100644
16259 +--- a/tools/testing/selftests/bpf/test_select_reuseport.c
16260 ++++ b/tools/testing/selftests/bpf/test_select_reuseport.c
16261 +@@ -30,7 +30,7 @@
16262 + #define REUSEPORT_ARRAY_SIZE 32
16263 +
16264 + static int result_map, tmp_index_ovr_map, linum_map, data_check_map;
16265 +-static enum result expected_results[NR_RESULTS];
16266 ++static __u32 expected_results[NR_RESULTS];
16267 + static int sk_fds[REUSEPORT_ARRAY_SIZE];
16268 + static int reuseport_array, outer_map;
16269 + static int select_by_skb_data_prog;
16270 +@@ -662,7 +662,19 @@ static void setup_per_test(int type, unsigned short family, bool inany)
16271 +
16272 + static void cleanup_per_test(void)
16273 + {
16274 +- int i, err;
16275 ++ int i, err, zero = 0;
16276 ++
16277 ++ memset(expected_results, 0, sizeof(expected_results));
16278 ++
16279 ++ for (i = 0; i < NR_RESULTS; i++) {
16280 ++ err = bpf_map_update_elem(result_map, &i, &zero, BPF_ANY);
16281 ++ RET_IF(err, "reset elem in result_map",
16282 ++ "i:%u err:%d errno:%d\n", i, err, errno);
16283 ++ }
16284 ++
16285 ++ err = bpf_map_update_elem(linum_map, &zero, &zero, BPF_ANY);
16286 ++ RET_IF(err, "reset line number in linum_map", "err:%d errno:%d\n",
16287 ++ err, errno);
16288 +
16289 + for (i = 0; i < REUSEPORT_ARRAY_SIZE; i++)
16290 + close(sk_fds[i]);
16291 +diff --git a/tools/testing/selftests/cgroup/test_core.c b/tools/testing/selftests/cgroup/test_core.c
16292 +index c5ca669feb2b..e19ce940cd6a 100644
16293 +--- a/tools/testing/selftests/cgroup/test_core.c
16294 ++++ b/tools/testing/selftests/cgroup/test_core.c
16295 +@@ -369,7 +369,7 @@ static void *dummy_thread_fn(void *arg)
16296 + static int test_cgcore_proc_migration(const char *root)
16297 + {
16298 + int ret = KSFT_FAIL;
16299 +- int t, c_threads, n_threads = 13;
16300 ++ int t, c_threads = 0, n_threads = 13;
16301 + char *src = NULL, *dst = NULL;
16302 + pthread_t threads[n_threads];
16303 +
16304 +diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh
16305 +index a8d20cbb711c..e84d901f8567 100644
16306 +--- a/tools/testing/selftests/kselftest/runner.sh
16307 ++++ b/tools/testing/selftests/kselftest/runner.sh
16308 +@@ -91,7 +91,7 @@ run_one()
16309 + run_many()
16310 + {
16311 + echo "TAP version 13"
16312 +- DIR=$(basename "$PWD")
16313 ++ DIR="${PWD#${BASE_DIR}/}"
16314 + test_num=0
16315 + total=$(echo "$@" | wc -w)
16316 + echo "1..$total"
16317 +diff --git a/tools/testing/selftests/net/so_txtime.c b/tools/testing/selftests/net/so_txtime.c
16318 +index 34df4c8882af..383bac05ac32 100644
16319 +--- a/tools/testing/selftests/net/so_txtime.c
16320 ++++ b/tools/testing/selftests/net/so_txtime.c
16321 +@@ -12,7 +12,11 @@
16322 + #include <arpa/inet.h>
16323 + #include <error.h>
16324 + #include <errno.h>
16325 ++#include <inttypes.h>
16326 + #include <linux/net_tstamp.h>
16327 ++#include <linux/errqueue.h>
16328 ++#include <linux/ipv6.h>
16329 ++#include <linux/tcp.h>
16330 + #include <stdbool.h>
16331 + #include <stdlib.h>
16332 + #include <stdio.h>
16333 +@@ -28,7 +32,7 @@ static int cfg_clockid = CLOCK_TAI;
16334 + static bool cfg_do_ipv4;
16335 + static bool cfg_do_ipv6;
16336 + static uint16_t cfg_port = 8000;
16337 +-static int cfg_variance_us = 2000;
16338 ++static int cfg_variance_us = 4000;
16339 +
16340 + static uint64_t glob_tstart;
16341 +
16342 +@@ -43,6 +47,9 @@ static struct timed_send cfg_in[MAX_NUM_PKT];
16343 + static struct timed_send cfg_out[MAX_NUM_PKT];
16344 + static int cfg_num_pkt;
16345 +
16346 ++static int cfg_errq_level;
16347 ++static int cfg_errq_type;
16348 ++
16349 + static uint64_t gettime_ns(void)
16350 + {
16351 + struct timespec ts;
16352 +@@ -90,13 +97,15 @@ static void do_send_one(int fdt, struct timed_send *ts)
16353 +
16354 + }
16355 +
16356 +-static void do_recv_one(int fdr, struct timed_send *ts)
16357 ++static bool do_recv_one(int fdr, struct timed_send *ts)
16358 + {
16359 + int64_t tstop, texpect;
16360 + char rbuf[2];
16361 + int ret;
16362 +
16363 + ret = recv(fdr, rbuf, sizeof(rbuf), 0);
16364 ++ if (ret == -1 && errno == EAGAIN)
16365 ++ return true;
16366 + if (ret == -1)
16367 + error(1, errno, "read");
16368 + if (ret != 1)
16369 +@@ -113,6 +122,8 @@ static void do_recv_one(int fdr, struct timed_send *ts)
16370 +
16371 + if (labs(tstop - texpect) > cfg_variance_us)
16372 + error(1, 0, "exceeds variance (%d us)", cfg_variance_us);
16373 ++
16374 ++ return false;
16375 + }
16376 +
16377 + static void do_recv_verify_empty(int fdr)
16378 +@@ -125,12 +136,70 @@ static void do_recv_verify_empty(int fdr)
16379 + error(1, 0, "recv: not empty as expected (%d, %d)", ret, errno);
16380 + }
16381 +
16382 ++static void do_recv_errqueue_timeout(int fdt)
16383 ++{
16384 ++ char control[CMSG_SPACE(sizeof(struct sock_extended_err)) +
16385 ++ CMSG_SPACE(sizeof(struct sockaddr_in6))] = {0};
16386 ++ char data[sizeof(struct ipv6hdr) +
16387 ++ sizeof(struct tcphdr) + 1];
16388 ++ struct sock_extended_err *err;
16389 ++ struct msghdr msg = {0};
16390 ++ struct iovec iov = {0};
16391 ++ struct cmsghdr *cm;
16392 ++ int64_t tstamp = 0;
16393 ++ int ret;
16394 ++
16395 ++ iov.iov_base = data;
16396 ++ iov.iov_len = sizeof(data);
16397 ++
16398 ++ msg.msg_iov = &iov;
16399 ++ msg.msg_iovlen = 1;
16400 ++
16401 ++ msg.msg_control = control;
16402 ++ msg.msg_controllen = sizeof(control);
16403 ++
16404 ++ while (1) {
16405 ++ ret = recvmsg(fdt, &msg, MSG_ERRQUEUE);
16406 ++ if (ret == -1 && errno == EAGAIN)
16407 ++ break;
16408 ++ if (ret == -1)
16409 ++ error(1, errno, "errqueue");
16410 ++ if (msg.msg_flags != MSG_ERRQUEUE)
16411 ++ error(1, 0, "errqueue: flags 0x%x\n", msg.msg_flags);
16412 ++
16413 ++ cm = CMSG_FIRSTHDR(&msg);
16414 ++ if (cm->cmsg_level != cfg_errq_level ||
16415 ++ cm->cmsg_type != cfg_errq_type)
16416 ++ error(1, 0, "errqueue: type 0x%x.0x%x\n",
16417 ++ cm->cmsg_level, cm->cmsg_type);
16418 ++
16419 ++ err = (struct sock_extended_err *)CMSG_DATA(cm);
16420 ++ if (err->ee_origin != SO_EE_ORIGIN_TXTIME)
16421 ++ error(1, 0, "errqueue: origin 0x%x\n", err->ee_origin);
16422 ++ if (err->ee_code != ECANCELED)
16423 ++ error(1, 0, "errqueue: code 0x%x\n", err->ee_code);
16424 ++
16425 ++ tstamp = ((int64_t) err->ee_data) << 32 | err->ee_info;
16426 ++ tstamp -= (int64_t) glob_tstart;
16427 ++ tstamp /= 1000 * 1000;
16428 ++ fprintf(stderr, "send: pkt %c at %" PRId64 "ms dropped\n",
16429 ++ data[ret - 1], tstamp);
16430 ++
16431 ++ msg.msg_flags = 0;
16432 ++ msg.msg_controllen = sizeof(control);
16433 ++ }
16434 ++
16435 ++ error(1, 0, "recv: timeout");
16436 ++}
16437 ++
16438 + static void setsockopt_txtime(int fd)
16439 + {
16440 + struct sock_txtime so_txtime_val = { .clockid = cfg_clockid };
16441 + struct sock_txtime so_txtime_val_read = { 0 };
16442 + socklen_t vallen = sizeof(so_txtime_val);
16443 +
16444 ++ so_txtime_val.flags = SOF_TXTIME_REPORT_ERRORS;
16445 ++
16446 + if (setsockopt(fd, SOL_SOCKET, SO_TXTIME,
16447 + &so_txtime_val, sizeof(so_txtime_val)))
16448 + error(1, errno, "setsockopt txtime");
16449 +@@ -194,7 +263,8 @@ static void do_test(struct sockaddr *addr, socklen_t alen)
16450 + for (i = 0; i < cfg_num_pkt; i++)
16451 + do_send_one(fdt, &cfg_in[i]);
16452 + for (i = 0; i < cfg_num_pkt; i++)
16453 +- do_recv_one(fdr, &cfg_out[i]);
16454 ++ if (do_recv_one(fdr, &cfg_out[i]))
16455 ++ do_recv_errqueue_timeout(fdt);
16456 +
16457 + do_recv_verify_empty(fdr);
16458 +
16459 +@@ -280,6 +350,10 @@ int main(int argc, char **argv)
16460 + addr6.sin6_family = AF_INET6;
16461 + addr6.sin6_port = htons(cfg_port);
16462 + addr6.sin6_addr = in6addr_loopback;
16463 ++
16464 ++ cfg_errq_level = SOL_IPV6;
16465 ++ cfg_errq_type = IPV6_RECVERR;
16466 ++
16467 + do_test((void *)&addr6, sizeof(addr6));
16468 + }
16469 +
16470 +@@ -289,6 +363,10 @@ int main(int argc, char **argv)
16471 + addr4.sin_family = AF_INET;
16472 + addr4.sin_port = htons(cfg_port);
16473 + addr4.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
16474 ++
16475 ++ cfg_errq_level = SOL_IP;
16476 ++ cfg_errq_type = IP_RECVERR;
16477 ++
16478 + do_test((void *)&addr4, sizeof(addr4));
16479 + }
16480 +
16481 +diff --git a/tools/testing/selftests/net/so_txtime.sh b/tools/testing/selftests/net/so_txtime.sh
16482 +index 5aa519328a5b..3f7800eaecb1 100755
16483 +--- a/tools/testing/selftests/net/so_txtime.sh
16484 ++++ b/tools/testing/selftests/net/so_txtime.sh
16485 +@@ -5,7 +5,12 @@
16486 +
16487 + # Run in network namespace
16488 + if [[ $# -eq 0 ]]; then
16489 +- ./in_netns.sh $0 __subprocess
16490 ++ if ! ./in_netns.sh $0 __subprocess; then
16491 ++ # test is time sensitive, can be flaky
16492 ++ echo "test failed: retry once"
16493 ++ ./in_netns.sh $0 __subprocess
16494 ++ fi
16495 ++
16496 + exit $?
16497 + fi
16498 +
16499 +@@ -18,7 +23,7 @@ tc qdisc add dev lo root fq
16500 + ./so_txtime -4 -6 -c mono a,10,b,20 a,10,b,20
16501 + ./so_txtime -4 -6 -c mono a,20,b,10 b,20,a,20
16502 +
16503 +-if tc qdisc replace dev lo root etf clockid CLOCK_TAI delta 200000; then
16504 ++if tc qdisc replace dev lo root etf clockid CLOCK_TAI delta 400000; then
16505 + ! ./so_txtime -4 -6 -c tai a,-1 a,-1
16506 + ! ./so_txtime -4 -6 -c tai a,0 a,0
16507 + ./so_txtime -4 -6 -c tai a,10 a,10
16508 +diff --git a/tools/testing/selftests/powerpc/eeh/eeh-functions.sh b/tools/testing/selftests/powerpc/eeh/eeh-functions.sh
16509 +index 26112ab5cdf4..f52ed92b53e7 100755
16510 +--- a/tools/testing/selftests/powerpc/eeh/eeh-functions.sh
16511 ++++ b/tools/testing/selftests/powerpc/eeh/eeh-functions.sh
16512 +@@ -53,9 +53,13 @@ eeh_one_dev() {
16513 + # is a no-op.
16514 + echo $dev >/sys/kernel/debug/powerpc/eeh_dev_check
16515 +
16516 +- # Enforce a 30s timeout for recovery. Even the IPR, which is infamously
16517 +- # slow to reset, should recover within 30s.
16518 +- max_wait=30
16519 ++ # Default to a 60s timeout when waiting for a device to recover. This
16520 ++ # is an arbitrary default which can be overridden by setting the
16521 ++ # EEH_MAX_WAIT environmental variable when required.
16522 ++
16523 ++ # The current record holder for longest recovery time is:
16524 ++ # "Adaptec Series 8 12G SAS/PCIe 3" at 39 seconds
16525 ++ max_wait=${EEH_MAX_WAIT:=60}
16526 +
16527 + for i in `seq 0 ${max_wait}` ; do
16528 + if pe_ok $dev ; then
16529 +diff --git a/tools/testing/selftests/size/get_size.c b/tools/testing/selftests/size/get_size.c
16530 +index 2ad45b944355..2980b1a63366 100644
16531 +--- a/tools/testing/selftests/size/get_size.c
16532 ++++ b/tools/testing/selftests/size/get_size.c
16533 +@@ -11,23 +11,35 @@
16534 + * own execution. It also attempts to have as few dependencies
16535 + * on kernel features as possible.
16536 + *
16537 +- * It should be statically linked, with startup libs avoided.
16538 +- * It uses no library calls, and only the following 3 syscalls:
16539 ++ * It should be statically linked, with startup libs avoided. It uses
16540 ++ * no library calls except the syscall() function for the following 3
16541 ++ * syscalls:
16542 + * sysinfo(), write(), and _exit()
16543 + *
16544 + * For output, it avoids printf (which in some C libraries
16545 + * has large external dependencies) by implementing it's own
16546 + * number output and print routines, and using __builtin_strlen()
16547 ++ *
16548 ++ * The test may crash if any of the above syscalls fails because in some
16549 ++ * libc implementations (e.g. the GNU C Library) errno is saved in
16550 ++ * thread-local storage, which does not get initialized due to avoiding
16551 ++ * startup libs.
16552 + */
16553 +
16554 + #include <sys/sysinfo.h>
16555 + #include <unistd.h>
16556 ++#include <sys/syscall.h>
16557 +
16558 + #define STDOUT_FILENO 1
16559 +
16560 + static int print(const char *s)
16561 + {
16562 +- return write(STDOUT_FILENO, s, __builtin_strlen(s));
16563 ++ size_t len = 0;
16564 ++
16565 ++ while (s[len] != '\0')
16566 ++ len++;
16567 ++
16568 ++ return syscall(SYS_write, STDOUT_FILENO, s, len);
16569 + }
16570 +
16571 + static inline char *num_to_str(unsigned long num, char *buf, int len)
16572 +@@ -79,12 +91,12 @@ void _start(void)
16573 + print("TAP version 13\n");
16574 + print("# Testing system size.\n");
16575 +
16576 +- ccode = sysinfo(&info);
16577 ++ ccode = syscall(SYS_sysinfo, &info);
16578 + if (ccode < 0) {
16579 + print("not ok 1");
16580 + print(test_name);
16581 + print(" ---\n reason: \"could not get sysinfo\"\n ...\n");
16582 +- _exit(ccode);
16583 ++ syscall(SYS_exit, ccode);
16584 + }
16585 + print("ok 1");
16586 + print(test_name);
16587 +@@ -100,5 +112,5 @@ void _start(void)
16588 + print(" ...\n");
16589 + print("1..1\n");
16590 +
16591 +- _exit(0);
16592 ++ syscall(SYS_exit, 0);
16593 + }
16594 +diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/basic.json b/tools/testing/selftests/tc-testing/tc-tests/filters/basic.json
16595 +index 2e361cea63bc..98a20faf3198 100644
16596 +--- a/tools/testing/selftests/tc-testing/tc-tests/filters/basic.json
16597 ++++ b/tools/testing/selftests/tc-testing/tc-tests/filters/basic.json
16598 +@@ -6,6 +6,9 @@
16599 + "filter",
16600 + "basic"
16601 + ],
16602 ++ "plugins": {
16603 ++ "requires": "nsPlugin"
16604 ++ },
16605 + "setup": [
16606 + "$TC qdisc add dev $DEV1 ingress"
16607 + ],
16608 +@@ -25,6 +28,9 @@
16609 + "filter",
16610 + "basic"
16611 + ],
16612 ++ "plugins": {
16613 ++ "requires": "nsPlugin"
16614 ++ },
16615 + "setup": [
16616 + "$TC qdisc add dev $DEV1 ingress"
16617 + ],
16618 +@@ -44,6 +50,9 @@
16619 + "filter",
16620 + "basic"
16621 + ],
16622 ++ "plugins": {
16623 ++ "requires": "nsPlugin"
16624 ++ },
16625 + "setup": [
16626 + "$TC qdisc add dev $DEV1 ingress"
16627 + ],
16628 +@@ -63,6 +72,9 @@
16629 + "filter",
16630 + "basic"
16631 + ],
16632 ++ "plugins": {
16633 ++ "requires": "nsPlugin"
16634 ++ },
16635 + "setup": [
16636 + "$TC qdisc add dev $DEV1 ingress"
16637 + ],
16638 +@@ -82,6 +94,9 @@
16639 + "filter",
16640 + "basic"
16641 + ],
16642 ++ "plugins": {
16643 ++ "requires": "nsPlugin"
16644 ++ },
16645 + "setup": [
16646 + "$TC qdisc add dev $DEV1 ingress"
16647 + ],
16648 +@@ -101,6 +116,9 @@
16649 + "filter",
16650 + "basic"
16651 + ],
16652 ++ "plugins": {
16653 ++ "requires": "nsPlugin"
16654 ++ },
16655 + "setup": [
16656 + "$TC qdisc add dev $DEV1 ingress"
16657 + ],
16658 +@@ -120,6 +138,9 @@
16659 + "filter",
16660 + "basic"
16661 + ],
16662 ++ "plugins": {
16663 ++ "requires": "nsPlugin"
16664 ++ },
16665 + "setup": [
16666 + "$TC qdisc add dev $DEV1 ingress"
16667 + ],
16668 +@@ -139,6 +160,9 @@
16669 + "filter",
16670 + "basic"
16671 + ],
16672 ++ "plugins": {
16673 ++ "requires": "nsPlugin"
16674 ++ },
16675 + "setup": [
16676 + "$TC qdisc add dev $DEV1 ingress"
16677 + ],
16678 +@@ -158,6 +182,9 @@
16679 + "filter",
16680 + "basic"
16681 + ],
16682 ++ "plugins": {
16683 ++ "requires": "nsPlugin"
16684 ++ },
16685 + "setup": [
16686 + "$TC qdisc add dev $DEV1 ingress"
16687 + ],
16688 +@@ -177,6 +204,9 @@
16689 + "filter",
16690 + "basic"
16691 + ],
16692 ++ "plugins": {
16693 ++ "requires": "nsPlugin"
16694 ++ },
16695 + "setup": [
16696 + "$TC qdisc add dev $DEV1 ingress"
16697 + ],
16698 +@@ -196,6 +226,9 @@
16699 + "filter",
16700 + "basic"
16701 + ],
16702 ++ "plugins": {
16703 ++ "requires": "nsPlugin"
16704 ++ },
16705 + "setup": [
16706 + "$TC qdisc add dev $DEV1 ingress"
16707 + ],
16708 +@@ -215,6 +248,9 @@
16709 + "filter",
16710 + "basic"
16711 + ],
16712 ++ "plugins": {
16713 ++ "requires": "nsPlugin"
16714 ++ },
16715 + "setup": [
16716 + "$TC qdisc add dev $DEV1 ingress"
16717 + ],
16718 +@@ -234,6 +270,9 @@
16719 + "filter",
16720 + "basic"
16721 + ],
16722 ++ "plugins": {
16723 ++ "requires": "nsPlugin"
16724 ++ },
16725 + "setup": [
16726 + "$TC qdisc add dev $DEV1 ingress"
16727 + ],
16728 +@@ -253,6 +292,9 @@
16729 + "filter",
16730 + "basic"
16731 + ],
16732 ++ "plugins": {
16733 ++ "requires": "nsPlugin"
16734 ++ },
16735 + "setup": [
16736 + "$TC qdisc add dev $DEV1 ingress"
16737 + ],
16738 +@@ -272,6 +314,9 @@
16739 + "filter",
16740 + "basic"
16741 + ],
16742 ++ "plugins": {
16743 ++ "requires": "nsPlugin"
16744 ++ },
16745 + "setup": [
16746 + "$TC qdisc add dev $DEV1 ingress"
16747 + ],
16748 +@@ -291,6 +336,9 @@
16749 + "filter",
16750 + "basic"
16751 + ],
16752 ++ "plugins": {
16753 ++ "requires": "nsPlugin"
16754 ++ },
16755 + "setup": [
16756 + "$TC qdisc add dev $DEV1 ingress"
16757 + ],
16758 +@@ -310,6 +358,9 @@
16759 + "filter",
16760 + "basic"
16761 + ],
16762 ++ "plugins": {
16763 ++ "requires": "nsPlugin"
16764 ++ },
16765 + "setup": [
16766 + "$TC qdisc add dev $DEV1 ingress"
16767 + ],
16768 +diff --git a/tools/usb/usbip/src/usbip_network.c b/tools/usb/usbip/src/usbip_network.c
16769 +index d595d72693fb..ed4dc8c14269 100644
16770 +--- a/tools/usb/usbip/src/usbip_network.c
16771 ++++ b/tools/usb/usbip/src/usbip_network.c
16772 +@@ -50,39 +50,39 @@ void usbip_setup_port_number(char *arg)
16773 + info("using port %d (\"%s\")", usbip_port, usbip_port_string);
16774 + }
16775 +
16776 +-void usbip_net_pack_uint32_t(int pack, uint32_t *num)
16777 ++uint32_t usbip_net_pack_uint32_t(int pack, uint32_t num)
16778 + {
16779 + uint32_t i;
16780 +
16781 + if (pack)
16782 +- i = htonl(*num);
16783 ++ i = htonl(num);
16784 + else
16785 +- i = ntohl(*num);
16786 ++ i = ntohl(num);
16787 +
16788 +- *num = i;
16789 ++ return i;
16790 + }
16791 +
16792 +-void usbip_net_pack_uint16_t(int pack, uint16_t *num)
16793 ++uint16_t usbip_net_pack_uint16_t(int pack, uint16_t num)
16794 + {
16795 + uint16_t i;
16796 +
16797 + if (pack)
16798 +- i = htons(*num);
16799 ++ i = htons(num);
16800 + else
16801 +- i = ntohs(*num);
16802 ++ i = ntohs(num);
16803 +
16804 +- *num = i;
16805 ++ return i;
16806 + }
16807 +
16808 + void usbip_net_pack_usb_device(int pack, struct usbip_usb_device *udev)
16809 + {
16810 +- usbip_net_pack_uint32_t(pack, &udev->busnum);
16811 +- usbip_net_pack_uint32_t(pack, &udev->devnum);
16812 +- usbip_net_pack_uint32_t(pack, &udev->speed);
16813 ++ udev->busnum = usbip_net_pack_uint32_t(pack, udev->busnum);
16814 ++ udev->devnum = usbip_net_pack_uint32_t(pack, udev->devnum);
16815 ++ udev->speed = usbip_net_pack_uint32_t(pack, udev->speed);
16816 +
16817 +- usbip_net_pack_uint16_t(pack, &udev->idVendor);
16818 +- usbip_net_pack_uint16_t(pack, &udev->idProduct);
16819 +- usbip_net_pack_uint16_t(pack, &udev->bcdDevice);
16820 ++ udev->idVendor = usbip_net_pack_uint16_t(pack, udev->idVendor);
16821 ++ udev->idProduct = usbip_net_pack_uint16_t(pack, udev->idProduct);
16822 ++ udev->bcdDevice = usbip_net_pack_uint16_t(pack, udev->bcdDevice);
16823 + }
16824 +
16825 + void usbip_net_pack_usb_interface(int pack __attribute__((unused)),
16826 +@@ -129,6 +129,14 @@ ssize_t usbip_net_send(int sockfd, void *buff, size_t bufflen)
16827 + return usbip_net_xmit(sockfd, buff, bufflen, 1);
16828 + }
16829 +
16830 ++static inline void usbip_net_pack_op_common(int pack,
16831 ++ struct op_common *op_common)
16832 ++{
16833 ++ op_common->version = usbip_net_pack_uint16_t(pack, op_common->version);
16834 ++ op_common->code = usbip_net_pack_uint16_t(pack, op_common->code);
16835 ++ op_common->status = usbip_net_pack_uint32_t(pack, op_common->status);
16836 ++}
16837 ++
16838 + int usbip_net_send_op_common(int sockfd, uint32_t code, uint32_t status)
16839 + {
16840 + struct op_common op_common;
16841 +@@ -140,7 +148,7 @@ int usbip_net_send_op_common(int sockfd, uint32_t code, uint32_t status)
16842 + op_common.code = code;
16843 + op_common.status = status;
16844 +
16845 +- PACK_OP_COMMON(1, &op_common);
16846 ++ usbip_net_pack_op_common(1, &op_common);
16847 +
16848 + rc = usbip_net_send(sockfd, &op_common, sizeof(op_common));
16849 + if (rc < 0) {
16850 +@@ -164,7 +172,7 @@ int usbip_net_recv_op_common(int sockfd, uint16_t *code, int *status)
16851 + goto err;
16852 + }
16853 +
16854 +- PACK_OP_COMMON(0, &op_common);
16855 ++ usbip_net_pack_op_common(0, &op_common);
16856 +
16857 + if (op_common.version != USBIP_VERSION) {
16858 + err("USBIP Kernel and tool version mismatch: %d %d:",
16859 +diff --git a/tools/usb/usbip/src/usbip_network.h b/tools/usb/usbip/src/usbip_network.h
16860 +index 555215eae43e..83b4c5344f72 100644
16861 +--- a/tools/usb/usbip/src/usbip_network.h
16862 ++++ b/tools/usb/usbip/src/usbip_network.h
16863 +@@ -32,12 +32,6 @@ struct op_common {
16864 +
16865 + } __attribute__((packed));
16866 +
16867 +-#define PACK_OP_COMMON(pack, op_common) do {\
16868 +- usbip_net_pack_uint16_t(pack, &(op_common)->version);\
16869 +- usbip_net_pack_uint16_t(pack, &(op_common)->code);\
16870 +- usbip_net_pack_uint32_t(pack, &(op_common)->status);\
16871 +-} while (0)
16872 +-
16873 + /* ---------------------------------------------------------------------- */
16874 + /* Dummy Code */
16875 + #define OP_UNSPEC 0x00
16876 +@@ -163,11 +157,11 @@ struct op_devlist_reply_extra {
16877 + } while (0)
16878 +
16879 + #define PACK_OP_DEVLIST_REPLY(pack, reply) do {\
16880 +- usbip_net_pack_uint32_t(pack, &(reply)->ndev);\
16881 ++ (reply)->ndev = usbip_net_pack_uint32_t(pack, (reply)->ndev);\
16882 + } while (0)
16883 +
16884 +-void usbip_net_pack_uint32_t(int pack, uint32_t *num);
16885 +-void usbip_net_pack_uint16_t(int pack, uint16_t *num);
16886 ++uint32_t usbip_net_pack_uint32_t(int pack, uint32_t num);
16887 ++uint16_t usbip_net_pack_uint16_t(int pack, uint16_t num);
16888 + void usbip_net_pack_usb_device(int pack, struct usbip_usb_device *udev);
16889 + void usbip_net_pack_usb_interface(int pack, struct usbip_usb_interface *uinf);
16890 +